2020-03-29 21:13:35 -03:00
|
|
|
/* cc-multitasking-panel.h
|
|
|
|
*
|
|
|
|
* Copyright 2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "cc-multitasking-panel.h"
|
|
|
|
|
|
|
|
#include "cc-multitasking-resources.h"
|
2023-02-13 14:42:33 +01:00
|
|
|
#include "cc-illustrated-row.h"
|
2020-03-29 21:13:35 -03:00
|
|
|
|
|
|
|
struct _CcMultitaskingPanel
|
|
|
|
{
|
|
|
|
CcPanel parent_instance;
|
|
|
|
|
|
|
|
GSettings *interface_settings;
|
|
|
|
GSettings *mutter_settings;
|
|
|
|
GSettings *shell_settings;
|
|
|
|
GSettings *wm_settings;
|
|
|
|
|
2023-02-13 14:42:33 +01:00
|
|
|
CcIllustratedRow *active_screen_edges_row;
|
2020-03-29 21:13:35 -03:00
|
|
|
GtkSwitch *active_screen_edges_switch;
|
2022-01-06 18:24:25 -08:00
|
|
|
GtkCheckButton *all_workspaces_radio;
|
2021-10-20 23:42:46 -03:00
|
|
|
GtkCheckButton *current_workspace_radio;
|
|
|
|
GtkCheckButton *dynamic_workspaces_radio;
|
|
|
|
GtkCheckButton *fixed_workspaces_radio;
|
2023-02-13 14:42:33 +01:00
|
|
|
CcIllustratedRow *hot_corner_row;
|
2020-03-29 21:13:35 -03:00
|
|
|
GtkSwitch *hot_corner_switch;
|
2023-09-28 14:15:06 -03:00
|
|
|
AdwSpinRow *number_of_workspaces_spin_row;
|
2021-10-20 23:42:46 -03:00
|
|
|
GtkCheckButton *workspaces_primary_display_radio;
|
|
|
|
GtkCheckButton *workspaces_span_displays_radio;
|
2020-03-29 21:13:35 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
CC_PANEL_REGISTER (CcMultitaskingPanel, cc_multitasking_panel)
|
|
|
|
|
|
|
|
/* GObject overrides */
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_multitasking_panel_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
CcMultitaskingPanel *self = (CcMultitaskingPanel *)object;
|
|
|
|
|
|
|
|
g_clear_object (&self->interface_settings);
|
|
|
|
g_clear_object (&self->mutter_settings);
|
|
|
|
g_clear_object (&self->shell_settings);
|
|
|
|
g_clear_object (&self->wm_settings);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_multitasking_panel_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_multitasking_panel_class_init (CcMultitaskingPanelClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = cc_multitasking_panel_finalize;
|
|
|
|
|
2023-02-13 14:42:33 +01:00
|
|
|
g_type_ensure (CC_TYPE_ILLUSTRATED_ROW);
|
|
|
|
|
2020-03-29 21:13:35 -03:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/multitasking/cc-multitasking-panel.ui");
|
|
|
|
|
2023-02-13 14:42:33 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, active_screen_edges_row);
|
2020-03-29 21:13:35 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, active_screen_edges_switch);
|
2022-01-06 18:24:25 -08:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, all_workspaces_radio);
|
2020-03-29 21:13:35 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, current_workspace_radio);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, dynamic_workspaces_radio);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, fixed_workspaces_radio);
|
2023-02-13 14:42:33 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, hot_corner_row);
|
2020-03-29 21:13:35 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, hot_corner_switch);
|
2023-09-28 14:15:06 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, number_of_workspaces_spin_row);
|
2020-03-29 21:13:35 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, workspaces_primary_display_radio);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, workspaces_span_displays_radio);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_multitasking_panel_init (CcMultitaskingPanel *self)
|
|
|
|
{
|
|
|
|
g_resources_register (cc_multitasking_get_resource ());
|
|
|
|
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
|
|
|
|
self->interface_settings = g_settings_new ("org.gnome.desktop.interface");
|
|
|
|
g_settings_bind (self->interface_settings,
|
|
|
|
"enable-hot-corners",
|
|
|
|
self->hot_corner_switch,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
|
|
|
self->mutter_settings = g_settings_new ("org.gnome.mutter");
|
|
|
|
|
|
|
|
if (g_settings_get_boolean (self->mutter_settings, "workspaces-only-on-primary"))
|
2021-10-20 23:42:46 -03:00
|
|
|
gtk_check_button_set_active (self->workspaces_primary_display_radio, TRUE);
|
2020-03-29 21:13:35 -03:00
|
|
|
else
|
2021-10-20 23:42:46 -03:00
|
|
|
gtk_check_button_set_active (self->workspaces_span_displays_radio, TRUE);
|
2020-03-29 21:13:35 -03:00
|
|
|
|
|
|
|
g_settings_bind (self->mutter_settings,
|
|
|
|
"workspaces-only-on-primary",
|
|
|
|
self->workspaces_primary_display_radio,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
g_settings_bind (self->mutter_settings,
|
|
|
|
"edge-tiling",
|
|
|
|
self->active_screen_edges_switch,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
2023-09-28 13:57:32 -03:00
|
|
|
if (g_settings_get_boolean (self->mutter_settings, "dynamic-workspaces"))
|
2021-10-20 23:42:46 -03:00
|
|
|
gtk_check_button_set_active (self->dynamic_workspaces_radio, TRUE);
|
2020-03-29 21:13:35 -03:00
|
|
|
else
|
2021-10-20 23:42:46 -03:00
|
|
|
gtk_check_button_set_active (self->fixed_workspaces_radio, TRUE);
|
2020-03-29 21:13:35 -03:00
|
|
|
|
2021-08-13 18:39:57 -03:00
|
|
|
g_settings_bind (self->mutter_settings,
|
2020-03-29 21:13:35 -03:00
|
|
|
"dynamic-workspaces",
|
|
|
|
self->dynamic_workspaces_radio,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
|
|
|
self->wm_settings = g_settings_new ("org.gnome.desktop.wm.preferences");
|
|
|
|
g_settings_bind (self->wm_settings,
|
|
|
|
"num-workspaces",
|
2023-09-28 14:15:06 -03:00
|
|
|
self->number_of_workspaces_spin_row,
|
2020-03-29 21:13:35 -03:00
|
|
|
"value",
|
2023-09-28 13:57:32 -03:00
|
|
|
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY);
|
2023-09-25 08:51:53 -03:00
|
|
|
|
2020-03-29 21:13:35 -03:00
|
|
|
self->shell_settings = g_settings_new ("org.gnome.shell.app-switcher");
|
|
|
|
|
|
|
|
if (g_settings_get_boolean (self->shell_settings, "current-workspace-only"))
|
2021-10-20 23:42:46 -03:00
|
|
|
gtk_check_button_set_active (self->current_workspace_radio, TRUE);
|
2022-01-06 18:24:25 -08:00
|
|
|
else
|
|
|
|
gtk_check_button_set_active (self->all_workspaces_radio, TRUE);
|
2020-03-29 21:13:35 -03:00
|
|
|
|
|
|
|
g_settings_bind (self->shell_settings,
|
|
|
|
"current-workspace-only",
|
|
|
|
self->current_workspace_radio,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
2022-02-28 11:23:48 +01:00
|
|
|
|
|
|
|
if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
|
|
|
|
{
|
2023-02-13 14:42:33 +01:00
|
|
|
cc_illustrated_row_set_resource (self->hot_corner_row,
|
|
|
|
"/org/gnome/control-center/multitasking/assets/hot-corner-rtl.svg");
|
|
|
|
cc_illustrated_row_set_resource (self->active_screen_edges_row,
|
|
|
|
"/org/gnome/control-center/multitasking/assets/active-screen-edges-rtl.svg");
|
2022-02-28 11:23:48 +01:00
|
|
|
}
|
2020-03-29 21:13:35 -03:00
|
|
|
}
|