[sysprof/wip/visualizers] window: expand for visualizers as necessary
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] window: expand for visualizers as necessary
- Date: Wed, 28 Sep 2016 20:24:48 +0000 (UTC)
commit 388557cdfe7305dc81bd15469ea2087247a1d550
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 28 13:23:51 2016 -0700
window: expand for visualizers as necessary
We want the paned to expand for the visualizers so that the
UI looks natural as often as possible without scrolling.
src/resources/ui/sp-window.ui | 12 +++++++++++-
src/sp-window.c | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/src/resources/ui/sp-window.ui b/src/resources/ui/sp-window.ui
index 569ce90..4d84b3f 100644
--- a/src/resources/ui/sp-window.ui
+++ b/src/resources/ui/sp-window.ui
@@ -160,9 +160,10 @@
</packing>
</child>
<child>
- <object class="GtkPaned">
+ <object class="GtkPaned" id="paned">
<property name="orientation">vertical</property>
<property name="visible">true</property>
+ <property name="vexpand">true</property>
<child>
<object class="SpVisualizerView" id="visualizers">
<property name="visible">true</property>
@@ -177,11 +178,20 @@
</object>
</child>
</object>
+ <packing>
+ <property name="shrink">false</property>
+ <property name="resize">false</property>
+ </packing>
</child>
<child>
<object class="SpCallgraphView" id="callgraph_view">
<property name="visible">true</property>
+ <property name="vexpand">true</property>
</object>
+ <packing>
+ <property name="shrink">false</property>
+ <property name="resize">true</property>
+ </packing>
</child>
</object>
<packing>
diff --git a/src/sp-window.c b/src/sp-window.c
index 5d0241f..b8a7d96 100644
--- a/src/sp-window.c
+++ b/src/sp-window.c
@@ -42,6 +42,7 @@ struct _SpWindow
GtkInfoBar *info_bar;
GtkLabel *info_bar_label;
GtkRevealer *info_bar_revealer;
+ GtkPaned *paned;
SpProfilerMenuButton *profiler_menu_button;
SpRecordingStateView *recording_view;
GtkButton *record_button;
@@ -702,6 +703,18 @@ sp_window_delete_event (GtkWidget *widget,
}
static void
+sp_window_reset_paned (SpWindow *self)
+{
+ gint min_height;
+ gint nat_height;
+
+ g_assert (SP_IS_WINDOW (self));
+
+ gtk_widget_get_preferred_height (GTK_WIDGET (self->visualizers), &min_height, &nat_height);
+ gtk_paned_set_position (self->paned, MAX (min_height, MIN (nat_height, 300)));
+}
+
+static void
sp_window_destroy (GtkWidget *widget)
{
SpWindow *self = (SpWindow *)widget;
@@ -763,6 +776,7 @@ sp_window_class_init (SpWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, SpWindow, info_bar);
gtk_widget_class_bind_template_child (widget_class, SpWindow, info_bar_label);
gtk_widget_class_bind_template_child (widget_class, SpWindow, info_bar_revealer);
+ gtk_widget_class_bind_template_child (widget_class, SpWindow, paned);
gtk_widget_class_bind_template_child (widget_class, SpWindow, profiler_menu_button);
gtk_widget_class_bind_template_child (widget_class, SpWindow, record_button);
gtk_widget_class_bind_template_child (widget_class, SpWindow, recording_view);
@@ -810,10 +824,21 @@ sp_window_init (SpWindow *self)
self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->visualizers,
+ "visualizer-added",
+ G_CALLBACK (sp_window_reset_paned),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->visualizers,
+ "visualizer-removed",
+ G_CALLBACK (sp_window_reset_paned),
+ self,
+ G_CONNECT_SWAPPED);
+
/*
* Setup actions for the window.
*/
-
g_action_map_add_action_entries (G_ACTION_MAP (self),
action_entries,
G_N_ELEMENTS (action_entries),
@@ -822,7 +847,6 @@ sp_window_init (SpWindow *self)
/*
* Setup our gear (hamburger) menu.
*/
-
app = GTK_APPLICATION (g_application_get_default ());
menu = gtk_application_get_menu_by_id (app, "gear-menu");
gtk_menu_button_set_menu_model (self->gear_menu_button, G_MENU_MODEL (menu));
@@ -837,7 +861,6 @@ sp_window_init (SpWindow *self)
/*
* Restore previous window settings.
*/
-
sp_window_settings_register (GTK_WINDOW (self));
/*
@@ -845,6 +868,12 @@ sp_window_init (SpWindow *self)
* launch, enter, escape, view.
*/
gtk_window_set_focus (GTK_WINDOW (self), GTK_WIDGET (self->record_button));
+
+ /*
+ * And finally ensure we have proper placement of our paned taking
+ * into account the size of the visualizers.
+ */
+ sp_window_reset_paned (self);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]