[gnome-control-center/gbsneto/multitasking: 42/42] Introduce the Multitasking panel



commit 92c81a9b77735d4f37e2eab3bb429110fdbb007e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Mar 29 21:13:35 2020 -0300

    Introduce the Multitasking panel
    
    The Multitasking panel brings some additional settings
    from Tweaks that are relevant to the general platform.
    
    Related: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/558

 panels/meson.build                                 |   1 +
 panels/multitasking/cc-multitasking-panel.c        | 148 ++++++++++++++++
 panels/multitasking/cc-multitasking-panel.h        |  30 ++++
 panels/multitasking/cc-multitasking-panel.ui       | 195 +++++++++++++++++++++
 .../gnome-multitasking-panel.desktop.in.in         |  14 ++
 panels/multitasking/meson.build                    |  46 +++++
 panels/multitasking/multitasking.gresource.xml     |   6 +
 shell/cc-panel-list.c                              |   1 +
 shell/cc-panel-loader.c                            |   2 +
 9 files changed, 443 insertions(+)
---
diff --git a/panels/meson.build b/panels/meson.build
index 2f4fdc5e3..1318904ae 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -15,6 +15,7 @@ panels = [
   'lock',
   'microphone',
   'mouse',
+  'multitasking',
   'notifications',
   'online-accounts',
   'power',
diff --git a/panels/multitasking/cc-multitasking-panel.c b/panels/multitasking/cc-multitasking-panel.c
new file mode 100644
index 000000000..906a75ccd
--- /dev/null
+++ b/panels/multitasking/cc-multitasking-panel.c
@@ -0,0 +1,148 @@
+/* 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"
+#include "list-box-helper.h"
+
+struct _CcMultitaskingPanel
+{
+  CcPanel        parent_instance;
+
+  GSettings     *interface_settings;
+  GSettings     *mutter_settings;
+  GSettings     *overrides_settings;
+  GSettings     *wm_settings;
+
+  GtkSwitch     *dynamic_workspaces_switch;
+  GtkSwitch     *drag_to_screen_edge_switch;
+  GtkSwitch     *hot_corner_switch;
+  GtkWidget     *keyboard_shortcuts_row;
+  GtkSpinButton *number_of_workspaces_spin;
+  GtkSwitch     *span_displays_switch;
+  GtkListBox    *top_listbox;
+  GtkListBox    *workspaces_listbox;
+};
+
+CC_PANEL_REGISTER (CcMultitaskingPanel, cc_multitasking_panel)
+
+/* Callbacks */
+
+static void
+on_listbox_row_activated_cb (GtkListBox          *listbox,
+                             GtkWidget           *row,
+                             CcMultitaskingPanel *self)
+{
+  g_autoptr(GError) error = NULL;
+  CcShell *shell;
+
+  if (self->keyboard_shortcuts_row != row)
+    return;
+
+  shell = cc_panel_get_shell (CC_PANEL (self));
+  cc_shell_set_active_panel_from_id (shell, "keyboard", NULL, &error);
+
+  if (error)
+    g_warning ("Error activating Keyboard Shortcuts panel: %s", error->message);
+}
+
+/* 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->overrides_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;
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/multitasking/cc-multitasking-panel.ui");
+
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, dynamic_workspaces_switch);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, drag_to_screen_edge_switch);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, hot_corner_switch);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, keyboard_shortcuts_row);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, number_of_workspaces_spin);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, span_displays_switch);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, top_listbox);
+  gtk_widget_class_bind_template_child (widget_class, CcMultitaskingPanel, workspaces_listbox);
+
+  gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb);
+}
+
+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");
+  g_settings_bind (self->mutter_settings,
+                   "workspaces-only-on-primary",
+                   self->span_displays_switch,
+                   "active",
+                   G_SETTINGS_BIND_DEFAULT);
+  g_settings_bind (self->mutter_settings,
+                   "edge-tiling",
+                   self->drag_to_screen_edge_switch,
+                   "active",
+                   G_SETTINGS_BIND_DEFAULT);
+
+  self->overrides_settings = g_settings_new ("org.gnome.shell.overrides");
+  g_settings_bind (self->overrides_settings,
+                   "dynamic-workspaces",
+                   self->dynamic_workspaces_switch,
+                   "active",
+                   G_SETTINGS_BIND_DEFAULT);
+
+  self->wm_settings = g_settings_new ("org.gnome.desktop.wm.preferences");
+  g_settings_bind (self->wm_settings,
+                   "num-workspaces",
+                   self->number_of_workspaces_spin,
+                   "value",
+                   G_SETTINGS_BIND_DEFAULT);
+
+  /* Separators */
+  gtk_list_box_set_header_func (self->top_listbox, cc_list_box_update_header_func, NULL, NULL);
+  gtk_list_box_set_header_func (self->workspaces_listbox, cc_list_box_update_header_func, NULL, NULL);
+}
diff --git a/panels/multitasking/cc-multitasking-panel.h b/panels/multitasking/cc-multitasking-panel.h
new file mode 100644
index 000000000..81e78f071
--- /dev/null
+++ b/panels/multitasking/cc-multitasking-panel.h
@@ -0,0 +1,30 @@
+/* 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
+ */
+
+#pragma once
+
+#include <shell/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_MULTITASKING_PANEL (cc_multitasking_panel_get_type())
+G_DECLARE_FINAL_TYPE (CcMultitaskingPanel, cc_multitasking_panel, CC, MULTITASKING_PANEL, CcPanel)
+
+G_END_DECLS
diff --git a/panels/multitasking/cc-multitasking-panel.ui b/panels/multitasking/cc-multitasking-panel.ui
new file mode 100644
index 000000000..7ddd7e40f
--- /dev/null
+++ b/panels/multitasking/cc-multitasking-panel.ui
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="CcMultitaskingPanel" parent="CcPanel">
+    <property name="visible">True</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">true</property>
+        <property name="hscrollbar-policy">never</property>
+        <child>
+          <object class="HdyColumn">
+            <property name="visible">True</property>
+            <property name="maximum_width">600</property>
+            <property name="linear_growth_width">400</property>
+            <property name="margin_top">32</property>
+            <property name="margin_bottom">32</property>
+            <property name="margin_start">12</property>
+            <property name="margin_end">12</property>
+
+            <child>
+              <object class="GtkBox">
+                <property name="visible">true</property>
+                <property name="can-focus">false</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">12</property>
+
+                <!-- Top Listbox -->
+                <child>
+                  <object class="GtkListBox" id="top_listbox">
+                    <property name="visible">true</property>
+                    <property name="can-focus">true</property>
+                    <property name="selection-mode">none</property>
+                    <property name="margin-bottom">24</property>
+                    <signal name="row-activated" handler="on_listbox_row_activated_cb" 
object="CcMultitaskingPanel" swapped="no" />
+
+                    <style>
+                      <class name="frame"/>
+                    </style>
+
+                    <!-- Hot Corner -->
+                    <child>
+                      <object class="HdyActionRow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="activatable-widget">hot_corner_switch</property>
+                        <property name="title" translatable="yes">_Hot Corner</property>
+                        <property name="subtitle" translatable="yes">Touch the top-left corner to open the 
Activities Overview.</property>
+                        <property name="use_underline">True</property>
+                        <child type="action">
+                          <object class="GtkSwitch" id="hot_corner_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="valign">center</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+
+                    <!-- Drag to Screen Edges -->
+                    <child>
+                      <object class="HdyActionRow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="activatable-widget">drag_to_screen_edge_switch</property>
+                        <property name="title" translatable="yes">_Drag to Screen Edges</property>
+                        <property name="subtitle" translatable="yes">Drag windows against the top, left, and 
right screen edges to resize them.</property>
+                        <property name="use_underline">True</property>
+                        <child type="action">
+                          <object class="GtkSwitch" id="drag_to_screen_edge_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="valign">center</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+
+                    <!-- Keyboard Shortcuts -->
+                    <child>
+                      <object class="HdyActionRow" id="keyboard_shortcuts_row">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="title" translatable="yes">_Keyboard Shortcuts</property>
+                        <property name="use_underline">True</property>
+                        <child type="action">
+                          <object class="GtkImage">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="icon-name">go-next-symbolic</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+
+                  </object>
+                </child>
+
+                <!-- Workspaces -->
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">true</property>
+                    <property name="can-focus">true</property>
+                    <property name="label" translatable="yes">Workspaces</property>
+                    <property name="xalign">0.0</property>
+                    <attributes>
+                      <attribute name="weight" value="bold" />
+                    </attributes>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkListBox" id="workspaces_listbox">
+                    <property name="visible">true</property>
+                    <property name="can-focus">true</property>
+                    <property name="selection-mode">none</property>
+                    <property name="margin-bottom">24</property>
+
+                    <style>
+                      <class name="frame"/>
+                    </style>
+
+                    <!-- Span Displays -->
+                    <child>
+                      <object class="HdyActionRow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="activatable-widget">span_displays_switch</property>
+                        <property name="title" translatable="yes">_Span Displays</property>
+                        <property name="use_underline">True</property>
+                        <child type="action">
+                          <object class="GtkSwitch" id="span_displays_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="valign">center</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+
+                    <!-- Dynamic Workspaces -->
+                    <child>
+                      <object class="HdyActionRow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="activatable-widget">dynamic_workspaces_switch</property>
+                        <property name="title" translatable="yes">_Automatic Add/Remove</property>
+                        <property name="use_underline">True</property>
+                        <child type="action">
+                          <object class="GtkSwitch" id="dynamic_workspaces_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="valign">center</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+
+                    <!-- Number of Workspaces -->
+                    <child>
+                      <object class="HdyActionRow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="sensitive" bind-source="dynamic_workspaces_switch" 
bind-property="active" bind-flags="default|invert-boolean|sync-create" />
+                        <property name="activatable-widget">number_of_workspaces_spin</property>
+                        <property name="title" translatable="yes">_Number of Workspaces</property>
+                        <property name="use_underline">True</property>
+                        <child type="action">
+                          <object class="GtkSpinButton" id="number_of_workspaces_spin">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="valign">center</property>
+                            <property name="adjustment">workspaces_adjustment</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+
+                  </object>
+                </child>
+              </object>
+            </child>
+
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+
+  <object class="GtkAdjustment" id="workspaces_adjustment">
+    <property name="lower">1.0</property>
+    <property name="step-increment">1.0</property>
+    <property name="value">4.0</property>
+    <!-- 36 is the maximum value allowed by Mutter -->
+    <property name="upper">36.0</property>
+  </object>
+</interface>
diff --git a/panels/multitasking/gnome-multitasking-panel.desktop.in.in 
b/panels/multitasking/gnome-multitasking-panel.desktop.in.in
new file mode 100644
index 000000000..4f06a3446
--- /dev/null
+++ b/panels/multitasking/gnome-multitasking-panel.desktop.in.in
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Name=Multitasking
+Comment=Manage preferences for productivity and multitasking
+Exec=gnome-control-center multitasking
+# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
+Icon=computer-symbolic
+Terminal=false
+Type=Application
+NoDisplay=true
+StartupNotify=true
+Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-PersonalizationSettings;
+OnlyShowIn=GNOME;
+# Translators: Search terms to find the Search panel. Do NOT translate or localize the semicolons! The list 
MUST also end with a semicolon!
+Keywords=Multitasking;Multitask;Productivity;Customize;Desktop;
diff --git a/panels/multitasking/meson.build b/panels/multitasking/meson.build
new file mode 100644
index 000000000..c38b531ef
--- /dev/null
+++ b/panels/multitasking/meson.build
@@ -0,0 +1,46 @@
+panels_list += cappletname
+desktop = 'gnome-@0@-panel.desktop'.format(cappletname)
+
+desktop_in = configure_file(
+  input: desktop + '.in.in',
+  output: desktop + '.in',
+  configuration: desktop_conf
+)
+
+i18n.merge_file(
+  desktop,
+  type: 'desktop',
+  input: desktop_in,
+  output: desktop,
+  po_dir: po_dir,
+  install: true,
+  install_dir: control_center_desktopdir
+)
+
+sources = files(
+  'cc-multitasking-panel.c',
+)
+
+resource_data = files(
+  'cc-multitasking-panel.ui',
+)
+
+sources += gnome.compile_resources(
+  'cc-' + cappletname + '-resources',
+  cappletname + '.gresource.xml',
+  c_name: 'cc_' + cappletname,
+  dependencies: resource_data,
+  export: true
+)
+
+cflags += [
+  '-DDATADIR="@0@"'.format(control_center_datadir)
+]
+
+panels_libs += static_library(
+  cappletname,
+  sources: sources,
+  include_directories: [ top_inc, common_inc ],
+  dependencies: common_deps,
+  c_args: cflags
+)
diff --git a/panels/multitasking/multitasking.gresource.xml b/panels/multitasking/multitasking.gresource.xml
new file mode 100644
index 000000000..41b64497c
--- /dev/null
+++ b/panels/multitasking/multitasking.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/multitasking">
+    <file preprocess="xml-stripblanks">cc-multitasking-panel.ui</file>
+  </gresource>
+</gresources>
diff --git a/shell/cc-panel-list.c b/shell/cc-panel-list.c
index 25785901f..3e3a61632 100644
--- a/shell/cc-panel-list.c
+++ b/shell/cc-panel-list.c
@@ -392,6 +392,7 @@ static const gchar * const panel_order[] = {
   "background",
   "notifications",
   "search",
+  "multitasking",
   "applications",
   "privacy",
   "online-accounts",
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index f20384394..fcbf398ca 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -43,6 +43,7 @@ extern GType cc_display_panel_get_type (void);
 extern GType cc_info_overview_panel_get_type (void);
 extern GType cc_keyboard_panel_get_type (void);
 extern GType cc_mouse_panel_get_type (void);
+extern GType cc_multitasking_panel_get_type (void);
 #ifdef BUILD_NETWORK
 extern GType cc_network_panel_get_type (void);
 extern GType cc_wifi_panel_get_type (void);
@@ -107,6 +108,7 @@ static CcPanelLoaderVtable default_panels[] =
   PANEL_TYPE("lock",             cc_lock_panel_get_type,                 NULL),
   PANEL_TYPE("microphone",       cc_microphone_panel_get_type,           NULL),
   PANEL_TYPE("mouse",            cc_mouse_panel_get_type,                NULL),
+  PANEL_TYPE("multitasking",     cc_multitasking_panel_get_type,         NULL),
 #ifdef BUILD_NETWORK
   PANEL_TYPE("network",          cc_network_panel_get_type,              NULL),
   PANEL_TYPE("wifi",             cc_wifi_panel_get_type,                 cc_wifi_panel_static_init_func),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]