[gimp] Bug 766628 - Preferences window is too tall



commit 9b8009d8c760d7241f1afaae55b90e2a7a2af5e7
Author: Michael Natterer <mitch gimp org>
Date:   Wed Aug 24 12:52:33 2016 +0200

    Bug 766628 - Preferences window is too tall
    
    Add gimp_prefs_box_set_page_scrollable() which does what it says, and
    make the tallest pages of the prefs dialog scrollable. This method
    allows the dialog's smaller pages to still enforce a minimum height
    for the window.

 app/dialogs/preferences-dialog.c |    6 +++++
 app/widgets/gimpprefsbox.c       |   44 +++++++++++++++++++++++++++++++------
 app/widgets/gimpprefsbox.h       |   28 +++++++++++++----------
 3 files changed, 59 insertions(+), 19 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 7f1a728..deded09 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1325,6 +1325,8 @@ prefs_dialog_new (Gimp       *gimp,
                                   NULL,
                                   &top_iter);
 
+  gimp_prefs_box_set_page_scrollable (GIMP_PREFS_BOX (prefs_box), vbox, TRUE);
+
   {
     GObject      *color_config;
     GtkListStore *store;
@@ -1608,6 +1610,8 @@ prefs_dialog_new (Gimp       *gimp,
                                   NULL,
                                   &top_iter);
 
+  gimp_prefs_box_set_page_scrollable (GIMP_PREFS_BOX (prefs_box), vbox, TRUE);
+
   table = prefs_table_new (1, GTK_CONTAINER (vbox));
 
   {
@@ -2018,6 +2022,8 @@ prefs_dialog_new (Gimp       *gimp,
                                   &top_iter,
                                   &child_iter);
 
+  gimp_prefs_box_set_page_scrollable (GIMP_PREFS_BOX (prefs_box), vbox, TRUE);
+
   size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
   /*  Color profile import dialog  */
diff --git a/app/widgets/gimpprefsbox.c b/app/widgets/gimpprefsbox.c
index ba99311..87e929d 100644
--- a/app/widgets/gimpprefsbox.c
+++ b/app/widgets/gimpprefsbox.c
@@ -316,24 +316,30 @@ gimp_prefs_box_add_page (GimpPrefsBox      *box,
                          GtkTreeIter       *iter)
 {
   GimpPrefsBoxPrivate *private;
-  GtkWidget           *event_box;
+  GtkWidget           *scrolled_win;
   GtkWidget           *vbox;
+  GtkWidget           *viewport;
 
   g_return_val_if_fail (GIMP_IS_PREFS_BOX (box), NULL);
 
   private = GET_PRIVATE (box);
 
-  event_box = gtk_event_box_new ();
-  gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
-  gtk_notebook_append_page (GTK_NOTEBOOK (private->notebook), event_box, NULL);
-  gtk_widget_show (event_box);
+  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+                                  GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+  gtk_notebook_append_page (GTK_NOTEBOOK (private->notebook), scrolled_win, NULL);
+  gtk_widget_show (scrolled_win);
 
-  gimp_help_set_help_data (event_box, NULL, help_id);
+  gimp_help_set_help_data (scrolled_win, NULL, help_id);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
-  gtk_container_add (GTK_CONTAINER (event_box), vbox);
+  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
+                                         vbox);
   gtk_widget_show (vbox);
 
+  viewport = gtk_bin_get_child (GTK_BIN (scrolled_win));
+  gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
+
   gtk_tree_store_append (private->store, iter, parent);
   gtk_tree_store_set (private->store, iter,
                       COLUMN_TREE_ICON_NAME,     icon_name,
@@ -348,6 +354,30 @@ gimp_prefs_box_add_page (GimpPrefsBox      *box,
   return vbox;
 }
 
+void
+gimp_prefs_box_set_page_scrollable (GimpPrefsBox *box,
+                                   GtkWidget    *page,
+                                   gboolean      scrollable)
+{
+  GimpPrefsBoxPrivate *private;
+  GtkWidget           *scrolled_win;
+
+  g_return_if_fail (GIMP_IS_PREFS_BOX (box));
+  g_return_if_fail (GTK_IS_BOX (page));
+  g_return_if_fail (gtk_widget_is_ancestor (page, GTK_WIDGET (box)));
+
+  private = GET_PRIVATE (box);
+
+  scrolled_win = gtk_widget_get_ancestor (page, GTK_TYPE_SCROLLED_WINDOW);
+
+  g_return_if_fail (gtk_widget_get_parent (scrolled_win) == private->notebook);
+
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+                                  GTK_POLICY_NEVER,
+                                 scrollable ?
+                                 GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER);
+}
+
 GtkWidget *
 gimp_prefs_box_get_tree_view (GimpPrefsBox *box)
 {
diff --git a/app/widgets/gimpprefsbox.h b/app/widgets/gimpprefsbox.h
index 734c605..ebab598 100644
--- a/app/widgets/gimpprefsbox.h
+++ b/app/widgets/gimpprefsbox.h
@@ -43,21 +43,25 @@ struct _GimpPrefsBoxClass
 };
 
 
-GType       gimp_prefs_box_get_type      (void) G_GNUC_CONST;
+GType       gimp_prefs_box_get_type            (void) G_GNUC_CONST;
 
-GtkWidget * gimp_prefs_box_new           (void);
+GtkWidget * gimp_prefs_box_new                 (void);
 
-GtkWidget * gimp_prefs_box_add_page      (GimpPrefsBox      *box,
-                                          const gchar       *icon_name,
-                                          const gchar       *notebook_label,
-                                          const gchar       *tree_label,
-                                          const gchar       *help_id,
-                                          GtkTreeIter       *parent,
-                                          GtkTreeIter       *iter);
+GtkWidget * gimp_prefs_box_add_page            (GimpPrefsBox *box,
+                                               const gchar  *icon_name,
+                                               const gchar  *notebook_label,
+                                               const gchar  *tree_label,
+                                               const gchar  *help_id,
+                                               GtkTreeIter  *parent,
+                                               GtkTreeIter  *iter);
 
-GtkWidget * gimp_prefs_box_get_tree_view (GimpPrefsBox      *box);
-GtkWidget * gimp_prefs_box_get_notebook  (GimpPrefsBox      *box);
-GtkWidget * gimp_prefs_box_get_image     (GimpPrefsBox      *box);
+void        gimp_prefs_box_set_page_scrollable (GimpPrefsBox *box,
+                                               GtkWidget    *page,
+                                               gboolean      scrollable);
+
+GtkWidget * gimp_prefs_box_get_tree_view       (GimpPrefsBox *box);
+GtkWidget * gimp_prefs_box_get_notebook        (GimpPrefsBox *box);
+GtkWidget * gimp_prefs_box_get_image           (GimpPrefsBox *box);
 
 
 #endif  /*  __GIMP_PREFS_BOX_H__  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]