From 1786df875ec4c644be3126b17d24c0d33af196e3 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 13 Jul 2023 17:47:53 -0700 Subject: [PATCH] window: disable sidebar button when not available --- src/sysprof/sysprof-window.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index c8981ad8..89b5baac 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -42,6 +42,8 @@ struct _SysprofWindow SysprofDocument *document; SysprofSession *session; + + GtkToggleButton *show_right_sidebar; }; enum { @@ -138,11 +140,17 @@ main_view_notify_sidebar (SysprofWindow *self, GParamSpec *pspec, AdwOverlaySplitView *main_view) { + GtkWidget *sidebar; + g_assert (SYSPROF_IS_WINDOW (self)); g_assert (ADW_IS_OVERLAY_SPLIT_VIEW (main_view)); - if (adw_overlay_split_view_get_sidebar (main_view) == NULL) + sidebar = adw_overlay_split_view_get_sidebar (main_view); + + if (sidebar == NULL) adw_overlay_split_view_set_show_sidebar (main_view, FALSE); + + gtk_widget_set_sensitive (GTK_WIDGET (self->show_right_sidebar), sidebar != NULL); } static void @@ -224,6 +232,7 @@ sysprof_window_class_init (SysprofWindowClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-window.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofWindow, show_right_sidebar); gtk_widget_class_bind_template_callback (widget_class, main_view_notify_sidebar); gtk_widget_class_install_action (widget_class, "win.open-capture", NULL, sysprof_window_open_capture_action);