[gnome-builder] preferences: add fallback for small screen sizes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] preferences: add fallback for small screen sizes
- Date: Tue, 11 Oct 2016 22:59:43 +0000 (UTC)
commit 8cce59d7d34c9d6a92f13e099232c24d0cfd4585
Author: Christian Hergert <chergert redhat com>
Date: Tue Oct 11 15:57:25 2016 -0700
preferences: add fallback for small screen sizes
If we have a small display (such as 1280xH) then we had the
chance we would clip off widgets that should be displayed.
Instead, we can simply enable the horizontal scrolling so that
the widget can be displayed, albeit with some scrolling.
https://bugzilla.gnome.org/show_bug.cgi?id=772700
libide/preferences/ide-preferences-perspective.c | 31 +++++++++++++++++++++
libide/preferences/ide-preferences-perspective.ui | 2 +-
2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-perspective.c
b/libide/preferences/ide-preferences-perspective.c
index 3d57b3f..ca7130a 100644
--- a/libide/preferences/ide-preferences-perspective.c
+++ b/libide/preferences/ide-preferences-perspective.c
@@ -50,6 +50,7 @@ struct _IdePreferencesPerspective
GSequence *pages;
GHashTable *widgets;
+ GtkScrolledWindow *scroller;
GtkStack *page_stack;
GtkStackSwitcher *page_stack_sidebar;
GtkSearchEntry *search_entry;
@@ -256,6 +257,7 @@ ide_preferences_perspective_class_init (IdePreferencesPerspectiveClass *klass)
gtk_widget_class_set_css_name (widget_class, "preferences");
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, scroller);
gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, search_entry);
gtk_widget_class_bind_template_child (widget_class, IdePreferencesPerspective, subpage_stack);
}
@@ -286,6 +288,29 @@ ide_preferences_perspective_search_entry_changed (IdePreferencesPerspective *sel
}
static void
+ide_preferences_perspective_notify_subpage_stack_visible (IdePreferencesPerspective *self,
+ GParamSpec *pspec,
+ GtkStack *subpage_stack)
+{
+ g_assert (IDE_IS_PREFERENCES_PERSPECTIVE (self));
+ g_assert (GTK_IS_STACK (subpage_stack));
+
+ /*
+ * Because the subpage stack can cause us to have a wider display than
+ * the screen has, we need to allow scrolling. This can happen because
+ * side-by-side we could be just a bit bigger than 1280px which is a
+ * fairly common laptop screen size (especially under HiDPI).
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=772700
+ */
+
+ if (gtk_widget_get_visible (GTK_WIDGET (subpage_stack)))
+ g_object_set (self->scroller, "hscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
+ else
+ g_object_set (self->scroller, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
+}
+
+static void
ide_preferences_perspective_init (IdePreferencesPerspective *self)
{
static const GActionEntry entries[] = {
@@ -306,6 +331,12 @@ ide_preferences_perspective_init (IdePreferencesPerspective *self)
self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->subpage_stack,
+ "notify::visible",
+ G_CALLBACK (ide_preferences_perspective_notify_subpage_stack_visible),
+ self,
+ G_CONNECT_SWAPPED);
+
self->pages = g_sequence_new (NULL);
self->widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
diff --git a/libide/preferences/ide-preferences-perspective.ui
b/libide/preferences/ide-preferences-perspective.ui
index 066142f..9866019 100644
--- a/libide/preferences/ide-preferences-perspective.ui
+++ b/libide/preferences/ide-preferences-perspective.ui
@@ -30,7 +30,7 @@
</object>
</child>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkScrolledWindow" id="scroller">
<property name="hscrollbar-policy">never</property>
<property name="visible">true</property>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]