[gnome-software: 27/29] gs-shell: Set up signal bindings in the UI file where possible
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 27/29] gs-shell: Set up signal bindings in the UI file where possible
- Date: Wed, 31 Mar 2021 16:03:46 +0000 (UTC)
commit e2e9290799542ff3392baa9b4b59eb16dc8528f2
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Jan 22 00:48:14 2021 +0000
gs-shell: Set up signal bindings in the UI file where possible
This simplifies the code a little.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
src/gs-shell.c | 105 ++++++++++++--------------------------------------------
src/gs-shell.ui | 25 ++++++++++++++
2 files changed, 46 insertions(+), 84 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index f39d5927a..380ddf7af 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -67,14 +67,11 @@ struct _GsShell
GtkWidget *header_end_widget;
GQueue *back_entry_stack;
GPtrArray *modal_dialogs;
- gulong search_changed_id;
gchar *events_info_uri;
GtkStack *stack_main;
GsPage *page;
GBinding *application_details_header_binding;
- GBinding *button_installed_counter_binding;
- GBinding *button_updates_counter_binding;
#ifdef HAVE_MOGWAI
MwscScheduler *scheduler;
@@ -103,8 +100,6 @@ struct _GsShell
GtkWidget *button_events_dismiss;
GtkWidget *label_events;
GtkWidget *primary_menu;
- GtkWidget *button_installed_counter;
- GtkWidget *button_updates_counter;
GtkWidget *application_details_header;
GsPage *pages[GS_SHELL_MODE_LAST];
@@ -2105,14 +2100,6 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
shell->settings = g_settings_new ("org.gnome.software");
/* get UI */
- g_signal_connect (shell, "map",
- G_CALLBACK (gs_shell_main_window_mapped_cb), shell);
- g_signal_connect (shell, "realize",
- G_CALLBACK (gs_shell_main_window_realized_cb), shell);
-
- g_signal_connect (shell, "delete-event",
- G_CALLBACK (main_window_closed_cb), shell);
-
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (shell), accel_group);
closure = g_cclosure_new (G_CALLBACK (gs_shell_close_window_accel_cb), NULL, NULL);
@@ -2131,91 +2118,24 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
g_object_unref (shell->header);
}
- /* global keynav */
- g_signal_connect_after (shell, "key_press_event",
- G_CALLBACK (window_key_press_event), shell);
- /* mouse hardware back button */
- g_signal_connect_after (shell, "button_press_event",
- G_CALLBACK (window_button_press_event), shell);
-
- g_signal_connect (shell->stack_main, "notify::visible-child", G_CALLBACK
(stack_notify_visible_child_cb), shell);
-
- /* show the search bar when clicking on the search button */
- g_signal_connect (shell->search_button, "clicked",
- G_CALLBACK (search_button_clicked_cb),
- shell);
-
- /* show the account popover when clicking on the account button */
- /*
- g_signal_connect (shell->menu_button, "clicked",
- G_CALLBACK (menu_button_clicked_cb),
- shell); */
-
/* setup buttons */
- g_signal_connect (shell->button_back, "clicked",
- G_CALLBACK (gs_shell_back_button_cb), shell);
g_object_set_data (G_OBJECT (shell->button_explore),
"gnome-software::overview-mode",
GINT_TO_POINTER (GS_SHELL_MODE_OVERVIEW));
- g_signal_connect (shell->button_explore, "clicked",
- G_CALLBACK (gs_overview_page_button_cb), shell);
g_object_set_data (G_OBJECT (shell->button_installed),
"gnome-software::overview-mode",
GINT_TO_POINTER (GS_SHELL_MODE_INSTALLED));
- g_signal_connect (shell->button_installed, "clicked",
- G_CALLBACK (gs_overview_page_button_cb), shell);
g_object_set_data (G_OBJECT (shell->button_updates),
"gnome-software::overview-mode",
GINT_TO_POINTER (GS_SHELL_MODE_UPDATES));
- g_signal_connect (shell->button_updates, "clicked",
- G_CALLBACK (gs_overview_page_button_cb), shell);
-
- /* set up in-app notification controls */
- g_signal_connect (shell->button_events_dismiss, "clicked",
- G_CALLBACK (gs_shell_plugin_event_dismissed_cb), shell);
- g_signal_connect (shell->button_events_sources, "clicked",
- G_CALLBACK (gs_shell_plugin_events_sources_cb), shell);
- g_signal_connect (shell->button_events_no_space, "clicked",
- G_CALLBACK (gs_shell_plugin_events_no_space_cb), shell);
- g_signal_connect (shell->button_events_network_settings, "clicked",
- G_CALLBACK (gs_shell_plugin_events_network_settings_cb), shell);
- g_signal_connect (shell->button_events_more_info, "clicked",
- G_CALLBACK (gs_shell_plugin_events_more_info_cb), shell);
- g_signal_connect (shell->button_events_restart_required, "clicked",
- G_CALLBACK (gs_shell_plugin_events_restart_required_cb), shell);
/* set up pages */
gs_shell_setup_pages (shell);
/* set up the metered data info bar and mogwai */
- g_signal_connect (shell->metered_updates_bar, "response",
- (GCallback) gs_shell_metered_updates_bar_response_cb, shell);
-
g_signal_connect (shell->settings, "changed::download-updates",
(GCallback) gs_shell_download_updates_changed_cb, shell);
- /* set up search */
- g_signal_connect (shell, "key-press-event",
- G_CALLBACK (window_keypress_handler), shell);
- shell->search_changed_id =
- g_signal_connect (shell->entry_search, "search-changed",
- G_CALLBACK (search_changed_handler), shell);
-
- /* bind the counters */
- shell->button_installed_counter_binding = g_object_bind_property
(shell->pages[GS_SHELL_MODE_INSTALLED], "counter",
- shell->button_installed_counter,
"label",
- G_BINDING_SYNC_CREATE);
- g_signal_connect (shell->button_installed_counter, "notify::label", G_CALLBACK
(counter_notify_label_cb), shell);
-
- shell->button_updates_counter_binding = g_object_bind_property (shell->pages[GS_SHELL_MODE_UPDATES],
"counter",
- shell->button_updates_counter,
"label",
- G_BINDING_SYNC_CREATE);
- g_signal_connect (shell->button_updates_counter, "notify::label", G_CALLBACK
(counter_notify_label_cb), shell);
-
- /* load content */
- g_signal_connect (shell->pages[GS_SHELL_MODE_LOADING], "refreshed",
- G_CALLBACK (initial_refresh_done), shell);
-
/* coldplug */
gs_shell_rescan_events (shell);
@@ -2386,8 +2306,6 @@ gs_shell_dispose (GObject *object)
GsShell *shell = GS_SHELL (object);
g_clear_object (&shell->application_details_header_binding);
- g_clear_object (&shell->button_installed_counter_binding);
- g_clear_object (&shell->button_updates_counter_binding);
if (shell->back_entry_stack != NULL) {
g_queue_free_full (shell->back_entry_stack, (GDestroyNotify) free_back_entry);
@@ -2459,8 +2377,6 @@ gs_shell_class_init (GsShellClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsShell, button_events_dismiss);
gtk_widget_class_bind_template_child (widget_class, GsShell, label_events);
gtk_widget_class_bind_template_child (widget_class, GsShell, primary_menu);
- gtk_widget_class_bind_template_child (widget_class, GsShell, button_installed_counter);
- gtk_widget_class_bind_template_child (widget_class, GsShell, button_updates_counter);
gtk_widget_class_bind_template_child (widget_class, GsShell, application_details_header);
gtk_widget_class_bind_template_child_full (widget_class, "overview_page", FALSE, G_STRUCT_OFFSET
(GsShell, pages[GS_SHELL_MODE_OVERVIEW]));
@@ -2472,6 +2388,27 @@ gs_shell_class_init (GsShellClass *klass)
gtk_widget_class_bind_template_child_full (widget_class, "details_page", FALSE, G_STRUCT_OFFSET
(GsShell, pages[GS_SHELL_MODE_DETAILS]));
gtk_widget_class_bind_template_child_full (widget_class, "category_page", FALSE, G_STRUCT_OFFSET
(GsShell, pages[GS_SHELL_MODE_CATEGORY]));
gtk_widget_class_bind_template_child_full (widget_class, "extras_page", FALSE, G_STRUCT_OFFSET
(GsShell, pages[GS_SHELL_MODE_EXTRAS]));
+
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_main_window_mapped_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_main_window_realized_cb);
+ gtk_widget_class_bind_template_callback (widget_class, main_window_closed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, window_key_press_event);
+ gtk_widget_class_bind_template_callback (widget_class, window_keypress_handler);
+ gtk_widget_class_bind_template_callback (widget_class, window_button_press_event);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_back_button_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_overview_page_button_cb);
+ gtk_widget_class_bind_template_callback (widget_class, counter_notify_label_cb);
+ gtk_widget_class_bind_template_callback (widget_class, search_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, search_changed_handler);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_plugin_events_sources_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_plugin_events_no_space_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_plugin_events_network_settings_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_plugin_events_restart_required_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_plugin_events_more_info_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_plugin_event_dismissed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_metered_updates_bar_response_cb);
+ gtk_widget_class_bind_template_callback (widget_class, stack_notify_visible_child_cb);
+ gtk_widget_class_bind_template_callback (widget_class, initial_refresh_done);
}
static void
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index c9136436c..a3cb2513d 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -35,6 +35,12 @@
<property name="default-height">800</property>
<property name="title" translatable="yes">Software</property>
<property name="icon_name">org.gnome.Software</property>
+ <signal name="map" handler="gs_shell_main_window_mapped_cb"/>
+ <signal name="realize" handler="gs_shell_main_window_realized_cb"/>
+ <signal name="delete-event" handler="main_window_closed_cb"/>
+ <signal name="key-press-event" handler="window_key_press_event" after="yes"/>
+ <signal name="key-press-event" handler="window_keypress_handler"/>
+ <signal name="button-press-event" handler="window_button_press_event" after="yes"/>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
@@ -47,6 +53,7 @@
<object class="GtkButton" id="button_back">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <signal name="clicked" handler="gs_shell_back_button_cb"/>
<child internal-child="accessible">
<object class="AtkObject" id="button_back_accessible">
<property name="accessible-name" translatable="yes">Go back</property>
@@ -82,6 +89,7 @@
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<property name="label" translatable="yes" comments="Translators: A label for a
button to show all available software.">_Explore</property>
+ <signal name="clicked" handler="gs_overview_page_button_cb"/>
<style>
<class name="toolbar-primary-buttons-software"/>
</style>
@@ -92,6 +100,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_overview_page_button_cb"/>
<child>
<object class="GtkBox" id="button_installed_box">
<property name="visible">True</property>
@@ -115,6 +124,8 @@
<object class="GtkLabel" id="button_installed_counter">
<property name="visible">False</property>
<property name="width-chars">2</property>
+ <property name="label" bind-source="installed_page" bind-property="counter"
bind-flags="sync-create"/>
+ <signal name="notify::label" handler="counter_notify_label_cb"/>
<style>
<class name="counter-label"/>
</style>
@@ -132,6 +143,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_overview_page_button_cb"/>
<child>
<object class="GtkBox" id="button_updates_box">
<property name="visible">True</property>
@@ -155,6 +167,8 @@
<object class="GtkLabel" id="button_updates_counter">
<property name="visible">False</property>
<property name="width-chars">2</property>
+ <property name="label" bind-source="updates_page" bind-property="counter"
bind-flags="sync-create"/>
+ <signal name="notify::label" handler="counter_notify_label_cb"/>
<style>
<class name="counter-label"/>
</style>
@@ -212,6 +226,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="active" bind-source="search_bar" bind-property="search-mode-enabled"
bind-flags="sync-create|bidirectional" />
+ <signal name="clicked" handler="search_button_clicked_cb"/>
<child internal-child="accessible">
<object class="AtkObject" id="search_button_accessible">
<property name="accessible-name" translatable="yes">Search</property>
@@ -264,6 +279,7 @@
<property name="max_length">100</property>
<property name="hexpand">True</property>
<property name="halign">center</property>
+ <signal name="search-changed" handler="search_changed_handler"/>
</object>
</child>
</object>
@@ -313,6 +329,7 @@
<property name="label" translatable="yes" comments="button in the info
bar">Software Repositories</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_shell_plugin_events_sources_cb"/>
</object>
</child>
<child>
@@ -321,6 +338,7 @@
<property name="label" translatable="yes" comments="button in the info
bar">Examine Disk</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_shell_plugin_events_no_space_cb"/>
</object>
</child>
<child>
@@ -329,6 +347,7 @@
<property name="label" translatable="yes" comments="button in the info
bar">Network Settings</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_shell_plugin_events_network_settings_cb"/>
</object>
</child>
<child>
@@ -337,6 +356,7 @@
<property name="label" translatable="yes" comments="button in the info
bar">Restart Now</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_shell_plugin_events_restart_required_cb"/>
</object>
</child>
<child>
@@ -345,6 +365,7 @@
<property name="label" translatable="yes" comments="button in the info bar">More
Information</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="gs_shell_plugin_events_more_info_cb"/>
</object>
</child>
</object>
@@ -353,6 +374,7 @@
<object class="GtkButton" id="button_events_dismiss">
<property name="visible">True</property>
<property name="valign">start</property>
+ <signal name="clicked" handler="gs_shell_plugin_event_dismissed_cb"/>
<style>
<class name="flat"/>
</style>
@@ -382,6 +404,7 @@
<property name="message-type">GTK_MESSAGE_INFO</property>
<property name="show-close-button">False</property>
<property name="revealed">False</property>
+ <signal name="response" handler="gs_shell_metered_updates_bar_response_cb"/>
<child internal-child="content_area">
<object class="GtkBox">
<property name="visible">True</property>
@@ -429,6 +452,7 @@
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="transition-type">crossfade</property>
+ <signal name="notify::visible-child" handler="stack_notify_visible_child_cb"/>
<child>
<object class="GsOverviewPage" id="overview_page">
<property name="visible">True</property>
@@ -456,6 +480,7 @@
<child>
<object class="GsLoadingPage" id="loading_page">
<property name="visible">True</property>
+ <signal name="refreshed" handler="initial_refresh_done"/>
</object>
<packing>
<property name="name">loading</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]