multitasking: Port to GTK4

This commit is contained in:
Georges Basile Stavracas Neto 2021-10-20 23:42:46 -03:00
parent a0d49cb3a8
commit 6cfd6e0652
7 changed files with 100 additions and 264 deletions

View file

@ -15,7 +15,7 @@ panels = [
'lock', 'lock',
'microphone', 'microphone',
# 'mouse', # 'mouse',
# 'multitasking', 'multitasking',
'notifications', 'notifications',
# 'online-accounts', # 'online-accounts',
'power', 'power',

View file

@ -23,7 +23,6 @@
#include "cc-multitasking-resources.h" #include "cc-multitasking-resources.h"
#include "cc-multitasking-row.h" #include "cc-multitasking-row.h"
#include "list-box-helper.h"
struct _CcMultitaskingPanel struct _CcMultitaskingPanel
{ {
@ -35,13 +34,13 @@ struct _CcMultitaskingPanel
GSettings *wm_settings; GSettings *wm_settings;
GtkSwitch *active_screen_edges_switch; GtkSwitch *active_screen_edges_switch;
GtkToggleButton *current_workspace_radio; GtkCheckButton *current_workspace_radio;
GtkToggleButton *dynamic_workspaces_radio; GtkCheckButton *dynamic_workspaces_radio;
GtkToggleButton *fixed_workspaces_radio; GtkCheckButton *fixed_workspaces_radio;
GtkSwitch *hot_corner_switch; GtkSwitch *hot_corner_switch;
GtkSpinButton *number_of_workspaces_spin; GtkSpinButton *number_of_workspaces_spin;
GtkToggleButton *workspaces_primary_display_radio; GtkCheckButton *workspaces_primary_display_radio;
GtkToggleButton *workspaces_span_displays_radio; GtkCheckButton *workspaces_span_displays_radio;
}; };
CC_PANEL_REGISTER (CcMultitaskingPanel, cc_multitasking_panel) CC_PANEL_REGISTER (CcMultitaskingPanel, cc_multitasking_panel)
@ -100,9 +99,9 @@ cc_multitasking_panel_init (CcMultitaskingPanel *self)
self->mutter_settings = g_settings_new ("org.gnome.mutter"); self->mutter_settings = g_settings_new ("org.gnome.mutter");
if (g_settings_get_boolean (self->mutter_settings, "workspaces-only-on-primary")) if (g_settings_get_boolean (self->mutter_settings, "workspaces-only-on-primary"))
gtk_toggle_button_set_active (self->workspaces_primary_display_radio, TRUE); gtk_check_button_set_active (self->workspaces_primary_display_radio, TRUE);
else else
gtk_toggle_button_set_active (self->workspaces_span_displays_radio, TRUE); gtk_check_button_set_active (self->workspaces_span_displays_radio, TRUE);
g_settings_bind (self->mutter_settings, g_settings_bind (self->mutter_settings,
"workspaces-only-on-primary", "workspaces-only-on-primary",
@ -116,9 +115,9 @@ cc_multitasking_panel_init (CcMultitaskingPanel *self)
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
if (g_settings_get_boolean (self->mutter_settings, "dynamic-workspaces")) if (g_settings_get_boolean (self->mutter_settings, "dynamic-workspaces"))
gtk_toggle_button_set_active (self->dynamic_workspaces_radio, TRUE); gtk_check_button_set_active (self->dynamic_workspaces_radio, TRUE);
else else
gtk_toggle_button_set_active (self->fixed_workspaces_radio, TRUE); gtk_check_button_set_active (self->fixed_workspaces_radio, TRUE);
g_settings_bind (self->mutter_settings, g_settings_bind (self->mutter_settings,
"dynamic-workspaces", "dynamic-workspaces",
@ -136,7 +135,7 @@ cc_multitasking_panel_init (CcMultitaskingPanel *self)
self->shell_settings = g_settings_new ("org.gnome.shell.app-switcher"); self->shell_settings = g_settings_new ("org.gnome.shell.app-switcher");
if (g_settings_get_boolean (self->shell_settings, "current-workspace-only")) if (g_settings_get_boolean (self->shell_settings, "current-workspace-only"))
gtk_toggle_button_set_active (self->current_workspace_radio, TRUE); gtk_check_button_set_active (self->current_workspace_radio, TRUE);
g_settings_bind (self->shell_settings, g_settings_bind (self->shell_settings,
"current-workspace-only", "current-workspace-only",

View file

@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="CcMultitaskingPanel" parent="CcPanel"> <template class="CcMultitaskingPanel" parent="CcPanel">
<property name="visible">True</property>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="visible">true</property>
<property name="hscrollbar-policy">never</property> <property name="hscrollbar-policy">never</property>
<child> <child>
<object class="HdyClamp"> <object class="AdwClamp">
<property name="visible">True</property>
<property name="maximum-size">600</property> <property name="maximum-size">600</property>
<property name="tightening-threshold">400</property> <property name="tightening-threshold">400</property>
<property name="margin_top">32</property> <property name="margin_top">32</property>
@ -18,16 +15,12 @@
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">true</property>
<property name="can-focus">false</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<!-- General --> <!-- General -->
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="label" translatable="yes">General</property> <property name="label" translatable="yes">General</property>
<property name="xalign">0.0</property> <property name="xalign">0.0</property>
<attributes> <attributes>
@ -38,8 +31,6 @@
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<property name="margin-bottom">24</property> <property name="margin-bottom">24</property>
@ -50,7 +41,6 @@
<!-- Hot Corner --> <!-- Hot Corner -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">hot_corner_switch</property> <property name="activatable-widget">hot_corner_switch</property>
<property name="title" translatable="yes">_Hot Corner</property> <property name="title" translatable="yes">_Hot Corner</property>
@ -58,18 +48,20 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<object class="GtkSwitch" id="hot_corner_switch"> <object class="GtkSwitch" id="hot_corner_switch">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
<child type="artwork"> <child type="artwork">
<object class="GtkImage"> <object class="GtkPicture">
<property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="margin">18</property> <property name="margin-top">18</property>
<property name="resource">/org/gnome/control-center/multitasking/assets/hot-corner.svg</property> <property name="margin-bottom">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="can-shrink">False</property>
<property name="file">resource:///org/gnome/control-center/multitasking/assets/hot-corner.svg</property>
</object> </object>
</child> </child>
</object> </object>
@ -78,7 +70,6 @@
<!-- Active Screen Edges --> <!-- Active Screen Edges -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">active_screen_edges_switch</property> <property name="activatable-widget">active_screen_edges_switch</property>
<property name="title" translatable="yes">_Active Screen Edges</property> <property name="title" translatable="yes">_Active Screen Edges</property>
@ -86,18 +77,20 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<object class="GtkSwitch" id="active_screen_edges_switch"> <object class="GtkSwitch" id="active_screen_edges_switch">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
<child type="artwork"> <child type="artwork">
<object class="GtkImage"> <object class="GtkPicture">
<property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="margin">18</property> <property name="margin-top">18</property>
<property name="resource">/org/gnome/control-center/multitasking/assets/active-screen-edges.svg</property> <property name="margin-bottom">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="can-shrink">False</property>
<property name="file">resource:///org/gnome/control-center/multitasking/assets/active-screen-edges.svg</property>
</object> </object>
</child> </child>
</object> </object>
@ -109,8 +102,6 @@
<!-- Workspaces --> <!-- Workspaces -->
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="label" translatable="yes">Workspaces</property> <property name="label" translatable="yes">Workspaces</property>
<property name="xalign">0.0</property> <property name="xalign">0.0</property>
<attributes> <attributes>
@ -121,8 +112,6 @@
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<property name="margin-bottom">18</property> <property name="margin-bottom">18</property>
@ -133,15 +122,13 @@
<!-- Dynamic Workspaces --> <!-- Dynamic Workspaces -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">dynamic_workspaces_radio</property> <property name="activatable-widget">dynamic_workspaces_radio</property>
<property name="title" translatable="yes">_Dynamic workspaces</property> <property name="title" translatable="yes">_Dynamic workspaces</property>
<property name="subtitle" translatable="yes">Automatically removes empty workspaces.</property> <property name="subtitle" translatable="yes">Automatically removes empty workspaces.</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child type="prefix"> <child type="prefix">
<object class="GtkRadioButton" id="dynamic_workspaces_radio"> <object class="GtkCheckButton" id="dynamic_workspaces_radio">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
@ -152,15 +139,13 @@
<!-- Fixed Number of Workspaces --> <!-- Fixed Number of Workspaces -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">fixed_workspaces_radio</property> <property name="activatable-widget">fixed_workspaces_radio</property>
<property name="title" translatable="yes">_Fixed number of workspaces</property> <property name="title" translatable="yes">_Fixed number of workspaces</property>
<property name="subtitle" translatable="yes">Specify a number of permanent workspaces.</property> <property name="subtitle" translatable="yes">Specify a number of permanent workspaces.</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child type="prefix"> <child type="prefix">
<object class="GtkRadioButton" id="fixed_workspaces_radio"> <object class="GtkCheckButton" id="fixed_workspaces_radio">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="group">dynamic_workspaces_radio</property> <property name="group">dynamic_workspaces_radio</property>
@ -172,7 +157,6 @@
<!-- Number of Workspaces --> <!-- Number of Workspaces -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="sensitive" bind-source="fixed_workspaces_radio" bind-property="active" bind-flags="default|sync-create" /> <property name="sensitive" bind-source="fixed_workspaces_radio" bind-property="active" bind-flags="default|sync-create" />
<property name="activatable-widget">number_of_workspaces_spin</property> <property name="activatable-widget">number_of_workspaces_spin</property>
@ -180,7 +164,6 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<object class="GtkSpinButton" id="number_of_workspaces_spin"> <object class="GtkSpinButton" id="number_of_workspaces_spin">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="adjustment">workspaces_adjustment</property> <property name="adjustment">workspaces_adjustment</property>
@ -195,8 +178,6 @@
<!-- Multi-Monitor --> <!-- Multi-Monitor -->
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="label" translatable="yes">Multi-Monitor</property> <property name="label" translatable="yes">Multi-Monitor</property>
<property name="xalign">0.0</property> <property name="xalign">0.0</property>
<attributes> <attributes>
@ -207,8 +188,6 @@
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<property name="margin-bottom">18</property> <property name="margin-bottom">18</property>
@ -219,25 +198,26 @@
<!-- Primary Display --> <!-- Primary Display -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">workspaces_primary_display_radio</property> <property name="activatable-widget">workspaces_primary_display_radio</property>
<property name="title" translatable="yes">Workspaces on _primary display only</property> <property name="title" translatable="yes">Workspaces on _primary display only</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child type="prefix"> <child type="prefix">
<object class="GtkRadioButton" id="workspaces_primary_display_radio"> <object class="GtkCheckButton" id="workspaces_primary_display_radio">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
<child type="artwork"> <child type="artwork">
<object class="GtkImage"> <object class="GtkPicture">
<property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="margin">18</property> <property name="margin-top">18</property>
<property name="resource">/org/gnome/control-center/multitasking/assets/workspaces-primary-display.svg</property> <property name="margin-bottom">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="can-shrink">False</property>
<property name="file">resource:///org/gnome/control-center/multitasking/assets/workspaces-primary-display.svg</property>
</object> </object>
</child> </child>
</object> </object>
@ -246,26 +226,27 @@
<!-- Span Displays --> <!-- Span Displays -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">workspaces_span_displays_radio</property> <property name="activatable-widget">workspaces_span_displays_radio</property>
<property name="title" translatable="yes">Workspaces on all d_isplays</property> <property name="title" translatable="yes">Workspaces on all d_isplays</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child type="prefix"> <child type="prefix">
<object class="GtkRadioButton" id="workspaces_span_displays_radio"> <object class="GtkCheckButton" id="workspaces_span_displays_radio">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="group">workspaces_primary_display_radio</property> <property name="group">workspaces_primary_display_radio</property>
</object> </object>
</child> </child>
<child type="artwork"> <child type="artwork">
<object class="GtkImage"> <object class="GtkPicture">
<property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="margin">18</property> <property name="margin-top">18</property>
<property name="resource">/org/gnome/control-center/multitasking/assets/workspaces-span-displays.svg</property> <property name="margin-bottom">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="can-shrink">False</property>
<property name="file">resource:///org/gnome/control-center/multitasking/assets/workspaces-span-displays.svg</property>
</object> </object>
</child> </child>
</object> </object>
@ -277,8 +258,6 @@
<!-- Application Switching --> <!-- Application Switching -->
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="label" translatable="yes">Application Switching</property> <property name="label" translatable="yes">Application Switching</property>
<property name="xalign">0.0</property> <property name="xalign">0.0</property>
<attributes> <attributes>
@ -289,8 +268,6 @@
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<property name="margin-bottom">18</property> <property name="margin-bottom">18</property>
@ -301,14 +278,12 @@
<!-- All Workspaces --> <!-- All Workspaces -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">all_workspaces_radio</property> <property name="activatable-widget">all_workspaces_radio</property>
<property name="title" translatable="yes">Include applications from all _workspaces</property> <property name="title" translatable="yes">Include applications from all _workspaces</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child type="prefix"> <child type="prefix">
<object class="GtkRadioButton" id="all_workspaces_radio"> <object class="GtkCheckButton" id="all_workspaces_radio">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
@ -319,14 +294,12 @@
<!-- Current Workspace --> <!-- Current Workspace -->
<child> <child>
<object class="CcMultitaskingRow"> <object class="CcMultitaskingRow">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable-widget">current_workspace_radio</property> <property name="activatable-widget">current_workspace_radio</property>
<property name="title" translatable="yes">Include applications from the _current workspace only</property> <property name="title" translatable="yes">Include applications from the _current workspace only</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child type="prefix"> <child type="prefix">
<object class="GtkRadioButton" id="current_workspace_radio"> <object class="GtkCheckButton" id="current_workspace_radio">
<property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="group">all_workspaces_radio</property> <property name="group">all_workspaces_radio</property>

View file

@ -23,7 +23,7 @@
struct _CcMultitaskingRow struct _CcMultitaskingRow
{ {
HdyPreferencesRow parent; AdwPreferencesRow parent;
GtkBox *artwork_box; GtkBox *artwork_box;
GtkBox *header; GtkBox *header;
@ -42,9 +42,11 @@ struct _CcMultitaskingRow
GtkWidget *activatable_widget; GtkWidget *activatable_widget;
}; };
static GtkBuildableIface *parent_buildable_iface;
static void cc_multitasking_row_buildable_init (GtkBuildableIface *iface); static void cc_multitasking_row_buildable_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_WITH_CODE (CcMultitaskingRow, cc_multitasking_row, HDY_TYPE_PREFERENCES_ROW, G_DEFINE_TYPE_WITH_CODE (CcMultitaskingRow, cc_multitasking_row, ADW_TYPE_PREFERENCES_ROW,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, cc_multitasking_row_buildable_init)) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, cc_multitasking_row_buildable_init))
enum enum
@ -181,145 +183,10 @@ cc_multitasking_row_dispose (GObject *object)
self->previous_parent = NULL; self->previous_parent = NULL;
} }
G_OBJECT_CLASS (cc_multitasking_row_parent_class)->dispose (object);
}
static void
cc_multitasking_row_show_all (GtkWidget *widget)
{
CcMultitaskingRow *self = CC_MULTITASKING_ROW (widget);
g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
gtk_container_foreach (GTK_CONTAINER (self->prefixes),
(GtkCallback) gtk_widget_show_all,
NULL);
gtk_container_foreach (GTK_CONTAINER (self->suffixes),
(GtkCallback) gtk_widget_show_all,
NULL);
GTK_WIDGET_CLASS (cc_multitasking_row_parent_class)->show_all (widget);
}
static void
cc_multitasking_row_destroy (GtkWidget *widget)
{
CcMultitaskingRow *self = CC_MULTITASKING_ROW (widget);
if (self->header)
{
gtk_widget_destroy (GTK_WIDGET (self->header));
self->header = NULL;
}
cc_multitasking_row_set_activatable_widget (self, NULL); cc_multitasking_row_set_activatable_widget (self, NULL);
g_clear_pointer ((GtkWidget**)&self->header, gtk_widget_unparent);
self->prefixes = NULL; G_OBJECT_CLASS (cc_multitasking_row_parent_class)->dispose (object);
self->suffixes = NULL;
GTK_WIDGET_CLASS (cc_multitasking_row_parent_class)->destroy (widget);
}
static void
cc_multitasking_row_add (GtkContainer *container,
GtkWidget *child)
{
CcMultitaskingRow *self = CC_MULTITASKING_ROW (container);
/* When constructing the widget, we want the box to be added as the child of
* the GtkListBoxRow, as an implementation detail.
*/
if (!self->header)
{
GTK_CONTAINER_CLASS (cc_multitasking_row_parent_class)->add (container, child);
}
else
{
gtk_container_add (GTK_CONTAINER (self->suffixes), child);
gtk_widget_show (GTK_WIDGET (self->suffixes));
}
}
static void
cc_multitasking_row_remove (GtkContainer *container,
GtkWidget *child)
{
CcMultitaskingRow *self = CC_MULTITASKING_ROW (container);
if (child == GTK_WIDGET (self->header))
GTK_CONTAINER_CLASS (cc_multitasking_row_parent_class)->remove (container, child);
else if (gtk_widget_get_parent (child) == GTK_WIDGET (self->prefixes))
gtk_container_remove (GTK_CONTAINER (self->prefixes), child);
else
gtk_container_remove (GTK_CONTAINER (self->suffixes), child);
}
typedef struct {
CcMultitaskingRow *row;
GtkCallback callback;
gpointer callback_data;
} ForallData;
static void
for_non_internal_child (GtkWidget *widget,
gpointer callback_data)
{
ForallData *data = callback_data;
CcMultitaskingRow *self = data->row;
if (widget != (GtkWidget *) self->image &&
widget != (GtkWidget *) self->prefixes &&
widget != (GtkWidget *) self->suffixes &&
widget != (GtkWidget *) self->title_box)
{
data->callback (widget, data->callback_data);
}
}
static void
cc_multitasking_row_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data)
{
CcMultitaskingRow *self = CC_MULTITASKING_ROW (container);
ForallData data;
if (include_internals)
{
GTK_CONTAINER_CLASS (cc_multitasking_row_parent_class)->forall (GTK_CONTAINER (self),
include_internals,
callback,
callback_data);
return;
}
data.row = self;
data.callback = callback;
data.callback_data = callback_data;
if (self->prefixes)
{
GTK_CONTAINER_GET_CLASS (self->prefixes)->forall (GTK_CONTAINER (self->prefixes),
include_internals,
for_non_internal_child,
&data);
}
if (self->suffixes)
{
GTK_CONTAINER_GET_CLASS (self->suffixes)->forall (GTK_CONTAINER (self->suffixes),
include_internals,
for_non_internal_child,
&data);
}
if (self->header)
{
GTK_CONTAINER_GET_CLASS (self->header)->forall (GTK_CONTAINER (self->header),
include_internals,
for_non_internal_child,
&data);
}
} }
static void static void
@ -327,19 +194,11 @@ cc_multitasking_row_class_init (CcMultitaskingRowClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->get_property = cc_multitasking_row_get_property; object_class->get_property = cc_multitasking_row_get_property;
object_class->set_property = cc_multitasking_row_set_property; object_class->set_property = cc_multitasking_row_set_property;
object_class->dispose = cc_multitasking_row_dispose; object_class->dispose = cc_multitasking_row_dispose;
widget_class->destroy = cc_multitasking_row_destroy;
widget_class->show_all = cc_multitasking_row_show_all;
container_class->add = cc_multitasking_row_add;
container_class->remove = cc_multitasking_row_remove;
container_class->forall = cc_multitasking_row_forall;
props[PROP_ICON_NAME] = props[PROP_ICON_NAME] =
g_param_spec_string ("icon-name", g_param_spec_string ("icon-name",
"Icon name", "Icon name",
@ -447,19 +306,25 @@ cc_multitasking_row_buildable_add_child (GtkBuildable *buildable,
{ {
CcMultitaskingRow *self = CC_MULTITASKING_ROW (buildable); CcMultitaskingRow *self = CC_MULTITASKING_ROW (buildable);
if (self->header == NULL || !type) if (!self->header)
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (child)); parent_buildable_iface->add_child (buildable, builder, child, type);
else if (type && strcmp (type, "prefix") == 0) else if (type && strcmp (type, "prefix") == 0)
cc_multitasking_row_add_prefix (self, GTK_WIDGET (child)); cc_multitasking_row_add_prefix (self, GTK_WIDGET (child));
else if (type && strcmp (type, "artwork") == 0) else if (type && strcmp (type, "artwork") == 0)
cc_multitasking_row_add_artwork (self, GTK_WIDGET (child)); cc_multitasking_row_add_artwork (self, GTK_WIDGET (child));
else if (!type && GTK_IS_WIDGET (child))
{
gtk_box_append (self->suffixes, GTK_WIDGET (child));
gtk_widget_show (GTK_WIDGET (self->suffixes));
}
else else
GTK_BUILDER_WARN_INVALID_CHILD_TYPE (self, type); parent_buildable_iface->add_child (buildable, builder, child, type);
} }
static void static void
cc_multitasking_row_buildable_init (GtkBuildableIface *iface) cc_multitasking_row_buildable_init (GtkBuildableIface *iface)
{ {
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->add_child = cc_multitasking_row_buildable_add_child; iface->add_child = cc_multitasking_row_buildable_add_child;
} }
@ -490,13 +355,9 @@ cc_multitasking_row_set_subtitle (CcMultitaskingRow *self,
const gchar * const gchar *
cc_multitasking_row_get_icon_name (CcMultitaskingRow *self) cc_multitasking_row_get_icon_name (CcMultitaskingRow *self)
{ {
const gchar *icon_name;
g_return_val_if_fail (CC_IS_MULTITASKING_ROW (self), NULL); g_return_val_if_fail (CC_IS_MULTITASKING_ROW (self), NULL);
gtk_image_get_icon_name (self->image, &icon_name, NULL); return gtk_image_get_icon_name (self->image);
return icon_name;
} }
void void
@ -507,11 +368,11 @@ cc_multitasking_row_set_icon_name (CcMultitaskingRow *self,
g_return_if_fail (CC_IS_MULTITASKING_ROW (self)); g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
gtk_image_get_icon_name (self->image, &old_icon_name, NULL); old_icon_name = gtk_image_get_icon_name (self->image);
if (g_strcmp0 (old_icon_name, icon_name) == 0) if (g_strcmp0 (old_icon_name, icon_name) == 0)
return; return;
gtk_image_set_from_icon_name (self->image, icon_name, GTK_ICON_SIZE_INVALID); gtk_image_set_from_icon_name (self->image, icon_name);
gtk_widget_set_visible (GTK_WIDGET (self->image), gtk_widget_set_visible (GTK_WIDGET (self->image),
icon_name != NULL && g_strcmp0 (icon_name, "") != 0); icon_name != NULL && g_strcmp0 (icon_name, "") != 0);
@ -584,7 +445,7 @@ cc_multitasking_row_set_use_underline (CcMultitaskingRow *self,
return; return;
self->use_underline = use_underline; self->use_underline = use_underline;
hdy_preferences_row_set_use_underline (HDY_PREFERENCES_ROW (self), self->use_underline); adw_preferences_row_set_use_underline (ADW_PREFERENCES_ROW (self), self->use_underline);
gtk_label_set_use_underline (self->title, self->use_underline); gtk_label_set_use_underline (self->title, self->use_underline);
gtk_label_set_use_underline (self->subtitle, self->use_underline); gtk_label_set_use_underline (self->subtitle, self->use_underline);
gtk_label_set_mnemonic_widget (self->title, GTK_WIDGET (self)); gtk_label_set_mnemonic_widget (self->title, GTK_WIDGET (self));
@ -652,7 +513,7 @@ cc_multitasking_row_add_prefix (CcMultitaskingRow *self,
g_return_if_fail (CC_IS_MULTITASKING_ROW (self)); g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
g_return_if_fail (GTK_IS_WIDGET (self)); g_return_if_fail (GTK_IS_WIDGET (self));
gtk_box_pack_start (self->prefixes, widget, FALSE, TRUE, 0); gtk_box_append (self->prefixes, widget);
gtk_widget_show (GTK_WIDGET (self->prefixes)); gtk_widget_show (GTK_WIDGET (self->prefixes));
} }
@ -668,7 +529,7 @@ cc_multitasking_row_add_artwork (CcMultitaskingRow *self,
*/ */
gtk_widget_set_margin_top (GTK_WIDGET (self->header), 12); gtk_widget_set_margin_top (GTK_WIDGET (self->header), 12);
gtk_box_pack_start (self->artwork_box, widget, FALSE, TRUE, 0); gtk_box_append (self->artwork_box, widget);
gtk_widget_show (GTK_WIDGET (self->artwork_box)); gtk_widget_show (GTK_WIDGET (self->artwork_box));
} }
@ -682,3 +543,25 @@ cc_multitasking_row_activate (CcMultitaskingRow *self)
g_signal_emit (self, signals[SIGNAL_ACTIVATED], 0); g_signal_emit (self, signals[SIGNAL_ACTIVATED], 0);
} }
void
cc_multitasking_row_remove (CcMultitaskingRow *self,
GtkWidget *child)
{
GtkWidget *parent;
g_return_if_fail (CC_IS_MULTITASKING_ROW (self));
g_return_if_fail (GTK_IS_WIDGET (child));
parent = gtk_widget_get_parent (child);
if (parent == GTK_WIDGET (self->prefixes))
gtk_box_remove (self->prefixes, child);
else if (parent == GTK_WIDGET (self->suffixes))
gtk_box_remove (self->suffixes, child);
else if (parent == GTK_WIDGET (self->artwork_box))
gtk_box_remove (self->artwork_box, child);
else
g_warning ("%p is not a child of %p", child, self);
}

View file

@ -21,12 +21,12 @@
#pragma once #pragma once
#include <handy.h> #include <adwaita.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define CC_TYPE_MULTITASKING_ROW (cc_multitasking_row_get_type()) #define CC_TYPE_MULTITASKING_ROW (cc_multitasking_row_get_type())
G_DECLARE_FINAL_TYPE (CcMultitaskingRow, cc_multitasking_row, CC, MULTITASKING_ROW, HdyPreferencesRow) G_DECLARE_FINAL_TYPE (CcMultitaskingRow, cc_multitasking_row, CC, MULTITASKING_ROW, AdwPreferencesRow)
const gchar *cc_multitasking_row_get_subtitle (CcMultitaskingRow *self); const gchar *cc_multitasking_row_get_subtitle (CcMultitaskingRow *self);
void cc_multitasking_row_set_subtitle (CcMultitaskingRow *self, void cc_multitasking_row_set_subtitle (CcMultitaskingRow *self,
@ -60,4 +60,7 @@ void cc_multitasking_row_add_artwork (CcMultitaskingRow *self,
void cc_multitasking_row_activate (CcMultitaskingRow *self); void cc_multitasking_row_activate (CcMultitaskingRow *self);
void cc_multitasking_row_remove (CcMultitaskingRow *self,
GtkWidget *child);
G_END_DECLS G_END_DECLS

View file

@ -1,77 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="CcMultitaskingRow" parent="HdyPreferencesRow"> <template class="CcMultitaskingRow" parent="AdwPreferencesRow">
<property name="activatable">False</property> <property name="activatable">False</property>
<accessibility> <accessibility>
<relation target="title" type="labelled-by"/> <relation name="labelled-by">title</relation>
</accessibility> </accessibility>
<child> <child>
<object class="GtkBox" id="header"> <object class="GtkBox" id="header">
<property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="visible">True</property>
<style> <style>
<class name="header"/> <class name="header"/>
</style> </style>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="visible">True</property>
<child> <child>
<object class="GtkBox" id="prefixes"> <object class="GtkBox" id="prefixes">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="visible">False</property> <property name="visible">False</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImage" id="image"> <object class="GtkImage" id="image">
<property name="no_show_all">True</property>
<property name="pixel_size">32</property> <property name="pixel_size">32</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="visible">False</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkBox" id="title_box"> <object class="GtkBox" id="title_box">
<property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="no_show_all">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="visible">True</property>
<style> <style>
<class name="title"/> <class name="title"/>
</style> </style>
<child> <child>
<object class="GtkLabel" id="title"> <object class="GtkLabel" id="title">
<property name="can_focus">False</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="label" bind-source="CcMultitaskingRow" bind-property="title" bind-flags="sync-create"/> <property name="label" bind-source="CcMultitaskingRow" bind-property="title" bind-flags="sync-create"/>
<property name="lines">1</property> <property name="lines">1</property>
<property name="visible">True</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="wrap-mode">word-char</property> <property name="wrap-mode">word-char</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<style> <style>
<class name="title"/> <class name="title"/>
</style> </style>
<accessibility>
<relation target="CcMultitaskingRow" type="label-for"/>
</accessibility>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkLabel" id="subtitle"> <object class="GtkLabel" id="subtitle">
<property name="can_focus">False</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -88,14 +73,9 @@
</child> </child>
<child> <child>
<object class="GtkBox" id="suffixes"> <object class="GtkBox" id="suffixes">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="visible">False</property> <property name="visible">False</property>
</object> </object>
<packing>
<property name="pack-type">end</property>
</packing>
</child> </child>
</object> </object>
@ -103,8 +83,6 @@
<child> <child>
<object class="GtkBox" id="artwork_box"> <object class="GtkBox" id="artwork_box">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="visible">False</property> <property name="visible">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="margin-top">12</property> <property name="margin-top">12</property>

View file

@ -43,7 +43,7 @@ extern GType cc_default_apps_panel_get_type (void);
extern GType cc_info_overview_panel_get_type (void); extern GType cc_info_overview_panel_get_type (void);
//extern GType cc_keyboard_panel_get_type (void); //extern GType cc_keyboard_panel_get_type (void);
//extern GType cc_mouse_panel_get_type (void); //extern GType cc_mouse_panel_get_type (void);
//extern GType cc_multitasking_panel_get_type (void); extern GType cc_multitasking_panel_get_type (void);
#ifdef BUILD_NETWORK #ifdef BUILD_NETWORK
//extern GType cc_network_panel_get_type (void); //extern GType cc_network_panel_get_type (void);
//extern GType cc_wifi_panel_get_type (void); //extern GType cc_wifi_panel_get_type (void);
@ -114,7 +114,7 @@ static CcPanelLoaderVtable default_panels[] =
PANEL_TYPE("lock", cc_lock_panel_get_type, NULL), PANEL_TYPE("lock", cc_lock_panel_get_type, NULL),
PANEL_TYPE("microphone", cc_microphone_panel_get_type, NULL), PANEL_TYPE("microphone", cc_microphone_panel_get_type, NULL),
//PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL), //PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL),
//PANEL_TYPE("multitasking", cc_multitasking_panel_get_type, NULL), PANEL_TYPE("multitasking", cc_multitasking_panel_get_type, NULL),
#ifdef BUILD_NETWORK #ifdef BUILD_NETWORK
//PANEL_TYPE("network", cc_network_panel_get_type, NULL), //PANEL_TYPE("network", cc_network_panel_get_type, NULL),
//PANEL_TYPE("wifi", cc_wifi_panel_get_type, cc_wifi_panel_static_init_func), //PANEL_TYPE("wifi", cc_wifi_panel_get_type, cc_wifi_panel_static_init_func),