window: disable sidebar button when not available

This commit is contained in:
Christian Hergert
2023-07-13 17:47:53 -07:00
parent 2c8bae5a7f
commit 1786df875e

View File

@ -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);