Line |
Branch |
Exec |
Source |
1 |
|
|
/* cc-multitasking-panel.h |
2 |
|
|
* |
3 |
|
|
* Copyright 2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> |
4 |
|
|
* |
5 |
|
|
* This program is free software: you can redistribute it and/or modify |
6 |
|
|
* it under the terms of the GNU General Public License as published by |
7 |
|
|
* the Free Software Foundation, either version 2 of the License, or |
8 |
|
|
* (at your option) any later version. |
9 |
|
|
* |
10 |
|
|
* This program is distributed in the hope that it will be useful, |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
* GNU General Public License for more details. |
14 |
|
|
* |
15 |
|
|
* You should have received a copy of the GNU General Public License |
16 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 |
|
|
* |
18 |
|
|
* SPDX-License-Identifier: GPL-2.0-or-later |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
#include "cc-multitasking-panel.h" |
23 |
|
|
|
24 |
|
|
#include "cc-multitasking-resources.h" |
25 |
|
|
#include "cc-illustrated-row.h" |
26 |
|
|
|
27 |
|
|
struct _CcMultitaskingPanel |
28 |
|
|
{ |
29 |
|
|
CcPanel parent_instance; |
30 |
|
|
|
31 |
|
|
GSettings *interface_settings; |
32 |
|
|
GSettings *mutter_settings; |
33 |
|
|
GSettings *shell_settings; |
34 |
|
|
GSettings *wm_settings; |
35 |
|
|
|
36 |
|
|
CcIllustratedRow *active_screen_edges_row; |
37 |
|
|
GtkSwitch *active_screen_edges_switch; |
38 |
|
|
GtkCheckButton *all_workspaces_radio; |
39 |
|
|
GtkCheckButton *current_workspace_radio; |
40 |
|
|
GtkCheckButton *dynamic_workspaces_radio; |
41 |
|
|
GtkCheckButton *fixed_workspaces_radio; |
42 |
|
|
CcIllustratedRow *hot_corner_row; |
43 |
|
|
GtkSwitch *hot_corner_switch; |
44 |
|
|
AdwSpinRow *number_of_workspaces_spin_row; |
45 |
|
|
GtkCheckButton *workspaces_primary_display_radio; |
46 |
|
|
GtkCheckButton *workspaces_span_displays_radio; |
47 |
|
|
}; |
48 |
|
|
|
49 |
|
✗ |
CC_PANEL_REGISTER (CcMultitaskingPanel, cc_multitasking_panel) |
50 |
|
|
|
51 |
|
|
/* GObject overrides */ |
52 |
|
|
|
53 |
|
|
static void |
54 |
|
✗ |
cc_multitasking_panel_finalize (GObject *object) |
55 |
|
|
{ |
56 |
|
✗ |
CcMultitaskingPanel *self = (CcMultitaskingPanel *)object; |
57 |
|
|
|
58 |
|
✗ |
g_clear_object (&self->interface_settings); |
59 |
|
✗ |
g_clear_object (&self->mutter_settings); |
60 |
|
✗ |
g_clear_object (&self->shell_settings); |
61 |
|
✗ |
g_clear_object (&self->wm_settings); |
62 |
|
|
|
63 |
|
✗ |
G_OBJECT_CLASS (cc_multitasking_panel_parent_class)->finalize (object); |
64 |
|
✗ |
} |
65 |
|
|
|
66 |
|
|
static void |
67 |
|
✗ |
cc_multitasking_panel_class_init (CcMultitaskingPanelClass *klass) |
68 |
|
|
{ |
69 |
|
✗ |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
70 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
71 |
|
|
|
72 |
|
✗ |
object_class->finalize = cc_multitasking_panel_finalize; |
73 |
|
|
|
74 |
|
✗ |
g_type_ensure (CC_TYPE_ILLUSTRATED_ROW); |
75 |
|
|
|
76 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/multitasking/cc-multitasking-panel.ui"); |
77 |
|
|
|
78 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, active_screen_edges_row); |
79 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, active_screen_edges_switch); |
80 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, all_workspaces_radio); |
81 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, current_workspace_radio); |
82 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, dynamic_workspaces_radio); |
83 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, fixed_workspaces_radio); |
84 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, hot_corner_row); |
85 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, hot_corner_switch); |
86 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, number_of_workspaces_spin_row); |
87 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, workspaces_primary_display_radio); |
88 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, workspaces_span_displays_radio); |
89 |
|
✗ |
} |
90 |
|
|
|
91 |
|
|
static void |
92 |
|
✗ |
cc_multitasking_panel_init (CcMultitaskingPanel *self) |
93 |
|
|
{ |
94 |
|
✗ |
g_resources_register (cc_multitasking_get_resource ()); |
95 |
|
|
|
96 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
97 |
|
|
|
98 |
|
✗ |
self->interface_settings = g_settings_new ("org.gnome.desktop.interface"); |
99 |
|
✗ |
g_settings_bind (self->interface_settings, |
100 |
|
|
"enable-hot-corners", |
101 |
|
✗ |
self->hot_corner_switch, |
102 |
|
|
"active", |
103 |
|
|
G_SETTINGS_BIND_DEFAULT); |
104 |
|
|
|
105 |
|
✗ |
self->mutter_settings = g_settings_new ("org.gnome.mutter"); |
106 |
|
|
|
107 |
|
✗ |
if (g_settings_get_boolean (self->mutter_settings, "workspaces-only-on-primary")) |
108 |
|
✗ |
gtk_check_button_set_active (self->workspaces_primary_display_radio, TRUE); |
109 |
|
|
else |
110 |
|
✗ |
gtk_check_button_set_active (self->workspaces_span_displays_radio, TRUE); |
111 |
|
|
|
112 |
|
✗ |
g_settings_bind (self->mutter_settings, |
113 |
|
|
"workspaces-only-on-primary", |
114 |
|
✗ |
self->workspaces_primary_display_radio, |
115 |
|
|
"active", |
116 |
|
|
G_SETTINGS_BIND_DEFAULT); |
117 |
|
✗ |
g_settings_bind (self->mutter_settings, |
118 |
|
|
"edge-tiling", |
119 |
|
✗ |
self->active_screen_edges_switch, |
120 |
|
|
"active", |
121 |
|
|
G_SETTINGS_BIND_DEFAULT); |
122 |
|
|
|
123 |
|
✗ |
if (g_settings_get_boolean (self->mutter_settings, "dynamic-workspaces")) |
124 |
|
✗ |
gtk_check_button_set_active (self->dynamic_workspaces_radio, TRUE); |
125 |
|
|
else |
126 |
|
✗ |
gtk_check_button_set_active (self->fixed_workspaces_radio, TRUE); |
127 |
|
|
|
128 |
|
✗ |
g_settings_bind (self->mutter_settings, |
129 |
|
|
"dynamic-workspaces", |
130 |
|
✗ |
self->dynamic_workspaces_radio, |
131 |
|
|
"active", |
132 |
|
|
G_SETTINGS_BIND_DEFAULT); |
133 |
|
|
|
134 |
|
✗ |
self->wm_settings = g_settings_new ("org.gnome.desktop.wm.preferences"); |
135 |
|
✗ |
g_settings_bind (self->wm_settings, |
136 |
|
|
"num-workspaces", |
137 |
|
✗ |
self->number_of_workspaces_spin_row, |
138 |
|
|
"value", |
139 |
|
|
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY); |
140 |
|
|
|
141 |
|
✗ |
self->shell_settings = g_settings_new ("org.gnome.shell.app-switcher"); |
142 |
|
|
|
143 |
|
✗ |
if (g_settings_get_boolean (self->shell_settings, "current-workspace-only")) |
144 |
|
✗ |
gtk_check_button_set_active (self->current_workspace_radio, TRUE); |
145 |
|
|
else |
146 |
|
✗ |
gtk_check_button_set_active (self->all_workspaces_radio, TRUE); |
147 |
|
|
|
148 |
|
✗ |
g_settings_bind (self->shell_settings, |
149 |
|
|
"current-workspace-only", |
150 |
|
✗ |
self->current_workspace_radio, |
151 |
|
|
"active", |
152 |
|
|
G_SETTINGS_BIND_DEFAULT); |
153 |
|
|
|
154 |
|
✗ |
if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) |
155 |
|
|
{ |
156 |
|
✗ |
cc_illustrated_row_set_resource (self->hot_corner_row, |
157 |
|
|
"/org/gnome/control-center/multitasking/assets/hot-corner-rtl.svg"); |
158 |
|
✗ |
cc_illustrated_row_set_resource (self->active_screen_edges_row, |
159 |
|
|
"/org/gnome/control-center/multitasking/assets/active-screen-edges-rtl.svg"); |
160 |
|
|
} |
161 |
|
✗ |
} |
162 |
|
|
|