From c6ae3221a10fa604be7b4dc29cb47a6453e1ae1f Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 11 Jul 2022 12:55:12 -0700 Subject: [PATCH] libsysprof-ui: use adwaita rows for assistant This isn't exactly ideal in our use, but it's transitionary so that we can get rid of the EggThreeGrid which is very out of place in a libadwaita world. --- .../sysprof-profiler-assistant.c | 37 +- .../sysprof-profiler-assistant.ui | 670 ++++++------------ 2 files changed, 219 insertions(+), 488 deletions(-) diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.c b/src/libsysprof-ui/sysprof-profiler-assistant.c index 28827544..2dc3d4ed 100644 --- a/src/libsysprof-ui/sysprof-profiler-assistant.c +++ b/src/libsysprof-ui/sysprof-profiler-assistant.c @@ -22,6 +22,7 @@ #include "config.h" +#include #include #include "egg-three-grid.h" @@ -54,16 +55,14 @@ struct _SysprofProfilerAssistant /* Template Objects */ GtkSwitch *allow_throttling; GtkButton *record_button; - GtkEntry *command_line; + AdwEntryRow *command_line; GtkSearchEntry *search_entry; - GtkRevealer *process_revealer; GtkListBox *process_list_box; SysprofEnvironEditor *environ_editor; GtkFlowBox *aid_flow_box; GtkSwitch *whole_system_switch; GtkSwitch *launch_switch; GtkSwitch *inherit_switch; - GtkWidget *scroller; }; enum { @@ -114,12 +113,15 @@ create_process_row_cb (gpointer item_, } static void -sysprof_profiler_assistant_notify_reveal_child_cb (SysprofProfilerAssistant *self, - GParamSpec *pspec, - GtkRevealer *revealer) +sysprof_profiler_assistant_notify_active_cb (SysprofProfilerAssistant *self, + GParamSpec *pspec, + GtkSwitch *switch_) { g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self)); - g_assert (GTK_IS_REVEALER (revealer)); + g_assert (GTK_IS_SWITCH (switch_)); + + if (gtk_switch_get_active (switch_)) + return; if (self->process_model == NULL) { @@ -155,7 +157,7 @@ sysprof_profiler_assistant_command_line_changed_cb (SysprofProfilerAssistant *se gint argc; g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self)); - g_assert (GTK_IS_ENTRY (entry)); + g_assert (ADW_IS_ENTRY_ROW (entry)); style_context = gtk_widget_get_style_context (GTK_WIDGET (entry)); text = gtk_editable_get_text (GTK_EDITABLE (entry)); @@ -314,13 +316,13 @@ filter_by_search_text (GObject *object, static void sysprof_profiler_assistant_search_changed_cb (SysprofProfilerAssistant *self, - GtkSearchEntry *search_entry) + GtkEditable *search_entry) { g_autoptr(SysprofModelFilter) filter = NULL; - const gchar *text; + const char *text; g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self)); - g_assert (GTK_IS_SEARCH_ENTRY (search_entry)); + g_assert (GTK_IS_EDITABLE (search_entry)); if (self->process_model == NULL) return; @@ -353,9 +355,12 @@ static void sysprof_profiler_assistant_dispose (GObject *object) { SysprofProfilerAssistant *self = (SysprofProfilerAssistant *)object; + GtkWidget *child; g_clear_object (&self->process_model); - g_clear_pointer (&self->scroller, gtk_widget_unparent); + + while ((child = gtk_widget_get_first_child (GTK_WIDGET (self)))) + gtk_widget_unparent (child); G_OBJECT_CLASS (sysprof_profiler_assistant_parent_class)->dispose (object); } @@ -390,13 +395,11 @@ sysprof_profiler_assistant_class_init (SysprofProfilerAssistantClass *klass) gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, command_line); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, environ_editor); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_list_box); - gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_revealer); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, record_button); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, whole_system_switch); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, launch_switch); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, inherit_switch); gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, search_entry); - gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, scroller); g_type_ensure (EGG_TYPE_THREE_GRID); @@ -439,9 +442,9 @@ sysprof_profiler_assistant_init (SysprofProfilerAssistant *self) self, G_CONNECT_SWAPPED); - g_signal_connect_object (self->process_revealer, - "notify::reveal-child", - G_CALLBACK (sysprof_profiler_assistant_notify_reveal_child_cb), + g_signal_connect_object (self->whole_system_switch, + "notify::active", + G_CALLBACK (sysprof_profiler_assistant_notify_active_cb), self, G_CONNECT_SWAPPED); diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.ui b/src/libsysprof-ui/sysprof-profiler-assistant.ui index 5ad2c4dc..7a6a9223 100644 --- a/src/libsysprof-ui/sysprof-profiler-assistant.ui +++ b/src/libsysprof-ui/sysprof-profiler-assistant.ui @@ -63,468 +63,212 @@ - - vertical - - - - - - - vertical - - - - - - -