[gimp/gimp-2-10] Issue #2898 - Gegl Operations - Color Wrap does not fit the screen on...



commit 6be6ea0e92f6c66f6db7ef48d7f4330cb608e860
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 3 18:06:01 2019 +0100

    Issue #2898 - Gegl Operations - Color Wrap does not fit the screen on...
    
    ...1920*1980 resolution
    
    In GimpOperationTool, make the generated GUI scrollable if it is
    higher than half the monitor's workarea. This is meant as a last
    resort for generated GUIs that do not have a custom constructor that
    makes them usable using better layouts.
    
    (cherry picked from commit b85d7c233487006a381ff678389431d51e2618aa)

 app/tools/gimpoperationtool.c | 55 +++++++++++++++++++++++++++++++++++++------
 app/tools/gimpoperationtool.h |  1 +
 2 files changed, 49 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index a5ca9f2b15..ed77ce30a8 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -282,16 +282,33 @@ gimp_operation_tool_dialog (GimpFilterTool *filter_tool)
 {
   GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool);
   GtkWidget         *main_vbox;
+  GtkWidget         *options_sw;
   GtkWidget         *options_gui;
   GtkWidget         *options_box;
+  GtkWidget         *viewport;
 
   main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool);
 
+  /*  The options scrolled window  */
+  options_sw = gtk_scrolled_window_new (NULL, NULL);
+  g_weak_ref_set (&op_tool->options_sw_ref, options_sw);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (options_sw),
+                                       GTK_SHADOW_NONE);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (options_sw),
+                                  GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+  gtk_box_pack_start (GTK_BOX (main_vbox), options_sw,
+                      TRUE, TRUE, 0);
+  gtk_widget_show (options_sw);
+
+  viewport = gtk_viewport_new (NULL, NULL);
+  gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
+  gtk_container_add (GTK_CONTAINER (options_sw), viewport);
+  gtk_widget_show (viewport);
+
   /*  The options vbox  */
   options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
   g_weak_ref_set (&op_tool->options_box_ref, options_box);
-  gtk_box_pack_start (GTK_BOX (main_vbox), options_box,
-                      TRUE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (viewport), options_box);
   gtk_widget_show (options_box);
 
   options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
@@ -573,14 +590,20 @@ gimp_operation_tool_create_gui (GimpOperationTool *op_tool)
 static void
 gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
 {
-  GtkSizeGroup *size_group  = NULL;
-  GtkWidget    *options_gui;
-  GtkWidget    *options_box;
-  GList        *list;
+  GtkSizeGroup   *size_group  = NULL;
+  GtkWidget      *options_gui;
+  GtkWidget      *options_box;
+  GtkWidget      *options_sw;
+  GtkWidget      *shell;
+  GdkRectangle    workarea;
+  GtkRequisition  minimum;
+  GList          *list;
+  gboolean        scrolling;
 
   options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
   options_box = g_weak_ref_get (&op_tool->options_box_ref);
-  g_return_if_fail (options_gui && options_box);
+  options_sw  = g_weak_ref_get (&op_tool->options_sw_ref);
+  g_return_if_fail (options_gui && options_box && options_sw);
 
   for (list = op_tool->aux_inputs; list; list = g_list_next (list))
     {
@@ -606,8 +629,26 @@ gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
   gtk_box_pack_start (GTK_BOX (options_box), options_gui, TRUE, TRUE, 0);
   gtk_widget_show (options_gui);
 
+  shell = GTK_WIDGET (gimp_display_get_shell (GIMP_TOOL (op_tool)->display));
+  gdk_screen_get_monitor_workarea (gtk_widget_get_screen (shell),
+                                   gimp_widget_get_monitor (shell), &workarea);
+  gtk_widget_size_request (options_box, &minimum);
+
+  scrolling = minimum.height > workarea.height / 2;
+
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (options_sw),
+                                  GTK_POLICY_NEVER,
+                                  scrolling ?
+                                  GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER);
+
+  if (scrolling)
+    gtk_widget_set_size_request (options_sw, -1, workarea.height / 2);
+  else
+    gtk_widget_set_size_request (options_sw, -1, -1);
+
   g_object_unref (options_gui);
   g_object_unref (options_box);
+  g_object_unref (options_sw);
 }
 
 
diff --git a/app/tools/gimpoperationtool.h b/app/tools/gimpoperationtool.h
index 60dc21cac4..c35c8aba6d 100644
--- a/app/tools/gimpoperationtool.h
+++ b/app/tools/gimpoperationtool.h
@@ -43,6 +43,7 @@ struct _GimpOperationTool
   GList          *aux_inputs;
 
   /* dialog */
+  GWeakRef        options_sw_ref;
   GWeakRef        options_box_ref;
   GWeakRef        options_gui_ref;
 };


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