[gnome-control-center/gbsneto/panel-widget-in-sidebar: 4/7] window: Properly update headebar buttons and title
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/panel-widget-in-sidebar: 4/7] window: Properly update headebar buttons and title
- Date: Fri, 16 Nov 2018 21:28:45 +0000 (UTC)
commit 8d2265c6b9bcf443f92c66c9238b9050ef7e7916
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Nov 16 15:10:11 2018 -0200
window: Properly update headebar buttons and title
With the new sidebar view in place, a new problem arose: we
need the current panel to be configured to update the title,
but cc_panel_list_add_sidebar_widget() changes the view while
activating the panel. That makes Settings crash.
Fix that by explicitly updating the headerbar widget, instead
of using notify::view of the panel list.
shell/cc-window.c | 39 +++++++++++++++++++++++----------------
shell/cc-window.ui | 1 -
2 files changed, 23 insertions(+), 17 deletions(-)
---
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 5ecbd98f8..8d84eaf83 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -380,6 +380,23 @@ setup_model (CcWindow *shell)
g_signal_connect_object (model, "row-changed", G_CALLBACK (on_row_changed_cb), shell, 0);
}
+static void
+update_headerbar_buttons (CcWindow *self)
+{
+ gboolean is_main_view;
+
+ CC_ENTRY;
+
+ is_main_view = cc_panel_list_get_view (CC_PANEL_LIST (self->panel_list)) == CC_PANEL_LIST_MAIN;
+
+ gtk_widget_set_visible (self->previous_button, !is_main_view);
+ gtk_widget_set_visible (self->search_button, is_main_view);
+
+ update_list_title (self);
+
+ CC_EXIT;
+}
+
static gboolean
set_active_panel_from_id (CcShell *shell,
const gchar *start_id,
@@ -447,6 +464,8 @@ set_active_panel_from_id (CcShell *shell,
cc_panel_list_set_active_panel (CC_PANEL_LIST (self->panel_list), start_id);
+ update_headerbar_buttons (self);
+
CC_RETURN (TRUE);
}
@@ -501,21 +520,6 @@ show_panel_cb (CcPanelList *panel_list,
set_active_panel_from_id (CC_SHELL (self), panel_id, NULL, TRUE, NULL);
}
-static void
-panel_list_view_changed_cb (CcPanelList *panel_list,
- GParamSpec *pspec,
- CcWindow *self)
-{
- gboolean is_main_view;
-
- is_main_view = cc_panel_list_get_view (panel_list) == CC_PANEL_LIST_MAIN;
-
- gtk_widget_set_visible (self->previous_button, !is_main_view);
- gtk_widget_set_visible (self->search_button, is_main_view);
-
- update_list_title (self);
-}
-
static void
search_entry_activate_cb (GtkEntry *entry,
CcWindow *self)
@@ -538,6 +542,8 @@ previous_button_clicked_cb (GtkButton *button,
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (shell->search_bar), FALSE);
else
cc_panel_list_go_previous (CC_PANEL_LIST (shell->panel_list));
+
+ update_headerbar_buttons (shell);
}
static void
@@ -807,6 +813,8 @@ cc_window_constructed (GObject *object)
else
cc_panel_list_activate (CC_PANEL_LIST (self->panel_list));
+ update_headerbar_buttons (self);
+
G_OBJECT_CLASS (cc_window_parent_class)->constructed (object);
}
@@ -881,7 +889,6 @@ cc_window_class_init (CcWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, gdk_window_set_cb);
gtk_widget_class_bind_template_callback (widget_class, on_development_warning_dialog_responded_cb);
- gtk_widget_class_bind_template_callback (widget_class, panel_list_view_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, previous_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, search_entry_activate_cb);
gtk_widget_class_bind_template_callback (widget_class, show_panel_cb);
diff --git a/shell/cc-window.ui b/shell/cc-window.ui
index d67e77a42..cd7e0e3f7 100644
--- a/shell/cc-window.ui
+++ b/shell/cc-window.ui
@@ -63,7 +63,6 @@
<property name="search-mode" bind-source="search_bar"
bind-property="search-mode-enabled" bind-flags="bidirectional" />
<property name="search-query" bind-source="search_entry" bind-property="text"
bind-flags="default" />
<signal name="show-panel" handler="show_panel_cb" object="CcWindow" swapped="no" />
- <signal name="notify::view" handler="panel_list_view_changed_cb" object="CcWindow"
swapped="no" />
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]