From 29278b0b916e8f7a2701c0448726abb68bf79696 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Sat, 12 Feb 2022 21:43:24 -0800 Subject: [PATCH 1/3] sharing: Use AdwPreferences{Page, Group} for main panel --- panels/sharing/cc-sharing-panel.c | 100 ++++++++++++-------------- panels/sharing/cc-sharing-panel.ui | 111 ++++++++++++----------------- 2 files changed, 91 insertions(+), 120 deletions(-) diff --git a/panels/sharing/cc-sharing-panel.c b/panels/sharing/cc-sharing-panel.c index fb48c8b29..c2b92a3de 100644 --- a/panels/sharing/cc-sharing-panel.c +++ b/panels/sharing/cc-sharing-panel.c @@ -57,7 +57,7 @@ struct _CcSharingPanel GtkWidget *approve_connections_radiobutton; GtkWidget *hostname_entry; - GtkWidget *main_list_box; + GtkWidget *main_group; GtkWidget *master_switch; GtkWidget *media_sharing_dialog; GtkWidget *media_sharing_headerbar; @@ -117,7 +117,7 @@ cc_sharing_panel_master_switch_notify (CcSharingPanel *self) gtk_switch_set_active (GTK_SWITCH (self->remote_login_switch), FALSE); } - gtk_widget_set_sensitive (self->main_list_box, active); + gtk_widget_set_sensitive (self->main_group, active); } static void @@ -164,6 +164,46 @@ cc_sharing_panel_get_help_uri (CcPanel *panel) return "help:gnome-help/prefs-sharing"; } +static void +cc_sharing_panel_run_dialog (CcSharingPanel *self, + GtkWidget *dialog) +{ + GtkWidget *parent; + + /* ensure labels with the hostname are updated if the hostname has changed */ + cc_sharing_panel_setup_label_with_hostname (self, + self->screen_sharing_label); + cc_sharing_panel_setup_label_with_hostname (self, self->remote_login_label); + cc_sharing_panel_setup_label_with_hostname (self, + self->personal_file_sharing_label); + + + parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); + gtk_window_present (GTK_WINDOW (dialog)); +} + +static void +cc_sharing_panel_main_list_box_row_activated (CcSharingPanel *self, + AdwActionRow *row) +{ + GtkWidget *dialog; + + if (row == ADW_ACTION_ROW (self->media_sharing_row)) + dialog = self->media_sharing_dialog; + else if (row == ADW_ACTION_ROW (self->personal_file_sharing_row)) + dialog = self->personal_file_sharing_dialog; + else if (row == ADW_ACTION_ROW (self->remote_login_row)) + dialog = self->remote_login_dialog; + else if (row == ADW_ACTION_ROW (self->screen_sharing_row)) + dialog = self->screen_sharing_dialog; + else + return; + + cc_sharing_panel_run_dialog (self, dialog); +} + static void cc_sharing_panel_class_init (CcSharingPanelClass *klass) { @@ -182,7 +222,7 @@ cc_sharing_panel_class_init (CcSharingPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_grid); gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_grid); gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, master_switch); - gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, main_list_box); + gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, main_group); gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_dialog); gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_headerbar); gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_row); @@ -210,52 +250,12 @@ cc_sharing_panel_class_init (CcSharingPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_listbox); gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, show_password_checkbutton); + gtk_widget_class_bind_template_callback (widget_class, cc_sharing_panel_main_list_box_row_activated); + g_type_ensure (CC_TYPE_LIST_ROW); g_type_ensure (CC_TYPE_HOSTNAME_ENTRY); } -static void -cc_sharing_panel_run_dialog (CcSharingPanel *self, - GtkWidget *dialog) -{ - GtkWidget *parent; - - /* ensure labels with the hostname are updated if the hostname has changed */ - cc_sharing_panel_setup_label_with_hostname (self, - self->screen_sharing_label); - cc_sharing_panel_setup_label_with_hostname (self, self->remote_login_label); - cc_sharing_panel_setup_label_with_hostname (self, - self->personal_file_sharing_label); - - - parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))); - - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); - gtk_window_present (GTK_WINDOW (dialog)); -} - -static void -cc_sharing_panel_main_list_box_row_activated (CcSharingPanel *self, - GtkListBoxRow *row) -{ - GtkWidget *dialog; - - if (row == GTK_LIST_BOX_ROW (self->media_sharing_row)) - dialog = self->media_sharing_dialog; - else if (row == GTK_LIST_BOX_ROW (self->personal_file_sharing_row)) - dialog = self->personal_file_sharing_dialog; - else if (row == GTK_LIST_BOX_ROW (self->remote_login_row)) - dialog = self->remote_login_dialog; - else if (row == GTK_LIST_BOX_ROW (self->screen_sharing_row)) - dialog = self->screen_sharing_dialog; - else - return; - - gtk_list_box_select_row (GTK_LIST_BOX (self->main_list_box), NULL); - - cc_sharing_panel_run_dialog (self, dialog); -} - static gboolean cc_sharing_panel_switch_to_label_transform_func (GBinding *binding, const GValue *source_value, @@ -1113,9 +1113,6 @@ cc_sharing_panel_init (CcSharingPanel *self) gtk_widget_init_template (GTK_WIDGET (self)); - g_signal_connect_object (self->main_list_box, "row-activated", - G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self, G_CONNECT_SWAPPED); - g_signal_connect (self->media_sharing_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); g_signal_connect (self->personal_file_sharing_dialog, "response", @@ -1125,12 +1122,9 @@ cc_sharing_panel_init (CcSharingPanel *self) g_signal_connect (self->screen_sharing_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); - gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (self->main_list_box), - TRUE); - /* start the panel in the disabled state */ gtk_switch_set_active (GTK_SWITCH (self->master_switch), FALSE); - gtk_widget_set_sensitive (self->main_list_box, FALSE); + gtk_widget_set_sensitive (self->main_group, FALSE); g_signal_connect_object (self->master_switch, "notify::active", G_CALLBACK (cc_sharing_panel_master_switch_notify), self, G_CONNECT_SWAPPED); @@ -1144,7 +1138,7 @@ cc_sharing_panel_init (CcSharingPanel *self) /* make sure the hostname entry isn't focused by default */ g_signal_connect_swapped (self, "map", G_CALLBACK (gtk_widget_grab_focus), - self->main_list_box); + self->main_group); } CcSharingPanel * diff --git a/panels/sharing/cc-sharing-panel.ui b/panels/sharing/cc-sharing-panel.ui index 57bac425f..9a26d69b1 100644 --- a/panels/sharing/cc-sharing-panel.ui +++ b/panels/sharing/cc-sharing-panel.ui @@ -12,75 +12,52 @@ - - never + - - 32 - 32 - 12 - 12 + + Computer Name - - True - vertical - - - 12 - 0 - _Computer Name - True - hostname_entry - - - - - - - - 32 - - - label6 - - - - - - none - - - - True - True - _File Sharing - - - - - True - True - _Screen Sharing - - - - - True - True - _Media Sharing - - - - - True - True - _Remote Login - - - - + + + + hostname_group + + + + + + + + + + True + True + _File Sharing + + + + + + True + True + _Screen Sharing + + + + + + True + True + _Media Sharing + + + + + + True + True + _Remote Login + -- GitLab From a4f2842b2aec7e44320a812a68820d88a1e79f94 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Wed, 23 Feb 2022 15:04:05 -0800 Subject: [PATCH 2/3] sharing: Make Network list an AdwPreferencesGroup --- panels/sharing/cc-sharing-networks.c | 5 ++--- panels/sharing/cc-sharing-networks.h | 3 ++- panels/sharing/cc-sharing-networks.ui | 31 ++++++++------------------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/panels/sharing/cc-sharing-networks.c b/panels/sharing/cc-sharing-networks.c index c7beac1fb..060b059db 100644 --- a/panels/sharing/cc-sharing-networks.c +++ b/panels/sharing/cc-sharing-networks.c @@ -19,7 +19,6 @@ #include "config.h" -#include #include #include @@ -28,7 +27,7 @@ #include "gsd-sharing-enums.h" struct _CcSharingNetworks { - GtkBox parent_instance; + AdwPreferencesGroup parent_instance; GtkWidget *listbox; @@ -46,7 +45,7 @@ struct _CcSharingNetworks { }; -G_DEFINE_TYPE (CcSharingNetworks, cc_sharing_networks, GTK_TYPE_BOX) +G_DEFINE_TYPE (CcSharingNetworks, cc_sharing_networks, ADW_TYPE_PREFERENCES_GROUP) enum { PROP_0, diff --git a/panels/sharing/cc-sharing-networks.h b/panels/sharing/cc-sharing-networks.h index f44567ebf..359cb9bd5 100644 --- a/panels/sharing/cc-sharing-networks.h +++ b/panels/sharing/cc-sharing-networks.h @@ -19,12 +19,13 @@ #pragma once +#include #include G_BEGIN_DECLS #define CC_TYPE_SHARING_NETWORKS (cc_sharing_networks_get_type ()) -G_DECLARE_FINAL_TYPE (CcSharingNetworks, cc_sharing_networks, CC, SHARING_NETWORKS, GtkBox) +G_DECLARE_FINAL_TYPE (CcSharingNetworks, cc_sharing_networks, CC, SHARING_NETWORKS, AdwPreferencesGroup) typedef enum { CC_SHARING_STATUS_UNSET, diff --git a/panels/sharing/cc-sharing-networks.ui b/panels/sharing/cc-sharing-networks.ui index 5703441df..c5a3c5fd2 100644 --- a/panels/sharing/cc-sharing-networks.ui +++ b/panels/sharing/cc-sharing-networks.ui @@ -2,29 +2,16 @@ - File Sharing - False - 1 + True True + 558 + 378 - - 12 - 12 - 12 - 12 - 12 - vertical + - - 12 - 6 - 12 - 12 - 12 - 6 - - - 0 - File Sharing allows you to share your Public folder with others on your current network using: <a href="dav://%s">dav://%s</a> - True - True - 36 - - 0 - 0 - 2 - - - + - - 12 - 6 - - 0 - 2 - 2 - - - - start - _Require Password - True - True - personal_file_sharing_require_password_switch - - 0 - 0 - - - - - - start - True - _Password - True - personal_file_sharing_password_entry - - 0 - 1 - - - - + + _Require Password + True + personal_file_sharing_require_password_switch + - end - - 1 - 0 - + center + + + + + Password + - - False - - True - password - - 1 - 1 - + + center @@ -170,49 +110,22 @@ Remote Login - False + True 1 True + 558 + 222 - - 12 - 12 - 12 - 12 - 12 - vertical - - - 0 - When remote login is enabled, remote users can connect using the Secure Shell command: -<a href="ssh %s">ssh %s</a> - True - True - 36 - - + - - + - - 12 - 12 - 12 - 12 - - - Remote Login - True - 0 - - - + + Remote Login + remote_login_switch + - end + center @@ -221,144 +134,59 @@ - Screen Sharing - False - 1 + True True + 558 + 498 - - 12 - 12 - 12 - 12 - vertical + - - vertical + - - 12 - 6 - 12 - 12 - 6 - - - 0 - Screen sharing allows remote users to view or control your screen by connecting to: <a href="vnc://%s">vnc://%s</a> - True - True - 36 - 6 - - 0 - 0 - 2 - + + _Allow connections to control the screen + True + remote_control_switch + + + center - - - vertical - 12 - - 0 - 2 - 2 - - - - True - _Allow connections to control the screen - - - - - 6 - - - 6 - 6 - - 0 - 3 - - - - start - 12 - _Password: - True - remote_control_password_entry - - 0 - 0 - - - - - - True - False - - password - - 1 - 0 - - - - - - _Show Password - True - - 1 - 1 - - - - - - - - 0 - Access Options - - 0 - 0 - - - - - - - - - _New connections must ask for access - require_password_radiobutton - True - - 0 - 1 - - - - - - _Require a password - True - - 0 - 2 - - - - - + + + + + + + Access Options + + + _New connections must ask for access + True + approve_connections_radiobutton + + + require_password_radiobutton + + + + + + + _Require a password + True + require_password_radiobutton + + + + + + center + True + @@ -375,63 +203,29 @@ Media Sharing - False + True True + 558 + 528 - - 12 - 12 - 12 - 12 - 12 - vertical + - - 12 - 6 - 12 - 12 - 12 - 6 - - - 0 - Share music, photos and videos over the network. - 36 - True - - 0 - 0 - 2 - - - - - - 0 - Folders - shared_folders_listbox - - 0 - 1 - 2 - - - - - - + + Share music, photos and videos over the network. + + + + + Folders none + + shared_folders_group + - - 0 - 3 - 2 - -- GitLab