[gnome-software: 6/29] gs-shell: Simplify some callbacks by using a GtkBuilder binding




commit 2d4cff2dcf78e8ebaef482cd1a70e0ab142cb7a1
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Jan 20 23:41:14 2021 +0000

    gs-shell: Simplify some callbacks by using a GtkBuilder binding
    
    This introduces no functional changes.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 src/gnome-software.ui |  1 +
 src/gs-shell.c        | 21 ---------------------
 2 files changed, 1 insertion(+), 21 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index ef392bf9e..75d46db75 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -224,6 +224,7 @@
               <object class="GtkToggleButton" id="search_button">
                 <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" />
                 <child internal-child="accessible">
                   <object class="AtkObject" id="search_button_accessible">
                     <property name="accessible-name" translatable="yes">Search</property>
diff --git a/src/gs-shell.c b/src/gs-shell.c
index d7616d44b..ae26c70a5 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -913,11 +913,6 @@ static void
 search_button_clicked_cb (GtkToggleButton *toggle_button, GsShell *shell)
 {
        GsShellPrivate *priv = gs_shell_get_instance_private (shell);
-       GtkWidget *search_bar;
-
-       search_bar = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
-       gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (search_bar),
-                                       gtk_toggle_button_get_active (toggle_button));
 
        if (priv->in_mode_change)
                return;
@@ -928,17 +923,6 @@ search_button_clicked_cb (GtkToggleButton *toggle_button, GsShell *shell)
                gs_shell_go_back (shell);
 }
 
-static void
-search_mode_enabled_cb (GtkSearchBar *search_bar, GParamSpec *pspec, GsShell *shell)
-{
-       GsShellPrivate *priv = gs_shell_get_instance_private (shell);
-       GtkWidget *search_button;
-
-       search_button = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_button"));
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (search_button),
-                                     gtk_search_bar_get_search_mode (search_bar));
-}
-
 static gboolean
 window_key_press_event (GtkWidget *win, GdkEventKey *event, GsShell *shell)
 {
@@ -2255,11 +2239,6 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
        g_signal_connect (widget, "clicked",
                          G_CALLBACK (search_button_clicked_cb),
                          shell);
-       /* set the search button enabled when search bar appears */
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
-       g_signal_connect (widget, "notify::search-mode-enabled",
-                         G_CALLBACK (search_mode_enabled_cb),
-                         shell);
 
        /* show the account popover when clicking on the account button */
        /* widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "menu_button"));


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