[gnome-builder] preferences: put subpages side-by-side with parent page
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] preferences: put subpages side-by-side with parent page
- Date: Sun, 18 Sep 2016 03:24:05 +0000 (UTC)
commit 0bc1fb04049316fea58e4f3dc3d0d23f8ff2b0fe
Author: Christian Hergert <chergert redhat com>
Date: Sat Sep 17 11:44:44 2016 -0700
preferences: put subpages side-by-side with parent page
This follows the preferences design more closely, and starts to get us
something that makes up for our loss of back button.
libide/preferences/ide-preferences-perspective.c | 70 ++++++++++++++++-----
libide/preferences/ide-preferences-perspective.ui | 6 +-
2 files changed, 55 insertions(+), 21 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-perspective.c
b/libide/preferences/ide-preferences-perspective.c
index 8d5a231..3d57b3f 100644
--- a/libide/preferences/ide-preferences-perspective.c
+++ b/libide/preferences/ide-preferences-perspective.c
@@ -31,6 +31,7 @@
#include "preferences/ide-preferences-file-chooser-button.h"
#include "preferences/ide-preferences-font-button.h"
#include "preferences/ide-preferences-group.h"
+#include "preferences/ide-preferences-group-private.h"
#include "preferences/ide-preferences-page.h"
#include "preferences/ide-preferences-page-private.h"
#include "preferences/ide-preferences-perspective.h"
@@ -49,12 +50,10 @@ struct _IdePreferencesPerspective
GSequence *pages;
GHashTable *widgets;
- GtkButton *back_button;
GtkStack *page_stack;
GtkStackSwitcher *page_stack_sidebar;
GtkSearchEntry *search_entry;
GtkStack *subpage_stack;
- GtkStack *top_stack;
};
static void ide_preferences_iface_init (IdePreferencesInterface *iface);
@@ -156,10 +155,52 @@ ide_preferences_perspective_notify_visible_child (IdePreferencesPerspective *sel
GParamSpec *pspec,
GtkStack *stack)
{
+ IdePreferencesPage *page;
+ GHashTableIter iter;
+ gpointer value;
+
g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- gtk_stack_set_visible_child (self->top_stack, GTK_WIDGET (self->page_stack));
- //gtk_widget_hide (GTK_WIDGET (self->back_button));
+ /* Short circuit if we are destroying everything */
+ if (gtk_widget_in_destruction (GTK_WIDGET (self)))
+ return;
+
+ gtk_widget_hide (GTK_WIDGET (self->subpage_stack));
+
+ /*
+ * If there are any selections in list groups, re-select it to cause
+ * the subpage to potentially reappear.
+ */
+
+ if (NULL == (page = IDE_PREFERENCES_PAGE (gtk_stack_get_visible_child (stack))))
+ return;
+
+ g_hash_table_iter_init (&iter, page->groups_by_name);
+
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ {
+ IdePreferencesGroup *group = value;
+ GtkSelectionMode mode = GTK_SELECTION_NONE;
+
+ g_assert (IDE_IS_PREFERENCES_GROUP (group));
+
+ if (!group->is_list)
+ continue;
+
+ g_object_get (group, "mode", &mode, NULL);
+
+ if (mode == GTK_SELECTION_SINGLE)
+ {
+ GtkListBoxRow *selected;
+
+ selected = gtk_list_box_get_selected_row (group->list_box);
+
+ g_assert (!selected || GTK_IS_LIST_BOX_ROW (selected));
+
+ if (selected != NULL && gtk_widget_activate (GTK_WIDGET (selected)))
+ break;
+ }
+ }
}
static void
@@ -213,12 +254,10 @@ ide_preferences_perspective_class_init (IdePreferencesPerspectiveClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-preferences-perspective.ui");
gtk_widget_class_set_css_name (widget_class, "preferences");
- //gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, back_button);
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, page_stack_sidebar);
gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, page_stack);
+ gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, page_stack_sidebar);
gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, search_entry);
gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, subpage_stack);
- gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, top_stack);
}
static void
@@ -230,8 +269,7 @@ go_back_activate (GSimpleAction *action,
g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
- gtk_stack_set_visible_child (self->top_stack, GTK_WIDGET (self->page_stack));
- //gtk_widget_hide (GTK_WIDGET (self->back_button));
+ gtk_widget_hide (GTK_WIDGET (self->subpage_stack));
}
static void
@@ -274,8 +312,6 @@ ide_preferences_perspective_init (IdePreferencesPerspective *self)
self->actions = G_ACTION_GROUP (g_simple_action_group_new ());
g_action_map_add_action_entries (G_ACTION_MAP (self->actions),
entries, G_N_ELEMENTS (entries), self);
-
- gtk_stack_set_visible_child (self->top_stack, GTK_WIDGET (self->page_stack));
}
static GtkWidget *
@@ -839,13 +875,13 @@ ide_preferences_perspective_set_page (IdePreferences *preferences,
{
_ide_preferences_page_set_map (IDE_PREFERENCES_PAGE (page), map);
gtk_stack_set_visible_child (self->subpage_stack, page);
- gtk_stack_set_visible_child (self->top_stack, GTK_WIDGET (self->subpage_stack));
- //gtk_widget_set_visible (GTK_WIDGET (self->back_button), TRUE);
- return;
+ gtk_widget_show (GTK_WIDGET (self->subpage_stack));
+ }
+ else
+ {
+ gtk_stack_set_visible_child (self->page_stack, page);
+ gtk_widget_hide (GTK_WIDGET (self->subpage_stack));
}
-
- gtk_stack_set_visible_child (self->page_stack, page);
- //gtk_widget_set_visible (GTK_WIDGET (self->back_button), FALSE);
}
static GtkWidget *
diff --git a/libide/preferences/ide-preferences-perspective.ui
b/libide/preferences/ide-preferences-perspective.ui
index 3601087..07fe6f3 100644
--- a/libide/preferences/ide-preferences-perspective.ui
+++ b/libide/preferences/ide-preferences-perspective.ui
@@ -30,9 +30,8 @@
</object>
</child>
<child>
- <object class="GtkStack" id="top_stack">
- <property name="transition-duration">333</property>
- <property name="transition-type">crossfade</property>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
<property name="visible">true</property>
<child>
<object class="GtkStack" id="page_stack">
@@ -45,7 +44,6 @@
<object class="GtkStack" id="subpage_stack">
<property name="transition-duration">333</property>
<property name="transition-type">crossfade</property>
- <property name="visible">true</property>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]