[gimp/tito: 3/4] app: action-search-dialog opacity now changed by ctrl-scroll.



commit d3dfa63e77b2e511ebc201b1a2a01d2f375c83ff
Author: Jehan <jehan girinstud io>
Date:   Sat Oct 19 01:45:06 2013 +1300

    app: action-search-dialog opacity now changed by ctrl-scroll.

 app/config/gimpguiconfig.c         |    4 +-
 app/config/gimprc-blurbs.h         |    3 --
 app/dialogs/action-search-dialog.c |   43 ++++++++++++++++++++++++++++++++++++
 app/dialogs/preferences-dialog.c   |    3 --
 4 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index fdb88f6..d39ffe2 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -265,8 +265,8 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
                                                      GIMP_PARAM_STATIC_STRINGS));
   g_object_class_install_property (object_class, PROP_SEARCH_DIALOG_OPACITY,
                                    g_param_spec_int ("search-dialog-opacity",
-                                                     NULL, SEARCH_DIALOG_OPACITY_BLURB,
-                                                     1, 100, 100,
+                                                     NULL, NULL,
+                                                     10, 100, 100,
                                                      G_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT |
                                                      GIMP_PARAM_STATIC_STRINGS));
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 64a2764..093a6e2 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -474,9 +474,6 @@ N_("When enabled, uses OpenCL for some operations.")
 "Bugs in event history buffer are frequent so in case of cursor " \
 "offset problems turning it off helps."
 
-#define SEARCH_DIALOG_OPACITY_BLURB \
-"Opacity of the action search box."
-
 #define SEARCH_SHOW_UNAVAILABLE_BLURB \
 "When enabled, a search of actions will also return inactive actions."
 
diff --git a/app/dialogs/action-search-dialog.c b/app/dialogs/action-search-dialog.c
index 1450544..7f0ba62 100644
--- a/app/dialogs/action-search-dialog.c
+++ b/app/dialogs/action-search-dialog.c
@@ -83,6 +83,9 @@ static gboolean     quit_button_clicked                    (GtkWidget         *w
 static void         size_allocated                         (GtkWidget         *widget,
                                                             GdkRectangle      *rec,
                                                             SearchDialog      *private);
+static gboolean     window_scrolled                        (GtkWidget         *widget,
+                                                            GdkEvent          *event,
+                                                            SearchDialog      *private);
 
 static void         action_search_setup_results_list       (GtkWidget        **results_list,
                                                             GtkWidget        **list_view);
@@ -160,6 +163,7 @@ action_search_dialog_create (Gimp *gimp)
   g_signal_connect (private->results_list, "key_press_event", G_CALLBACK (result_selected), private);
   g_signal_connect (quit_button, "clicked", G_CALLBACK (quit_button_clicked), private);
   g_signal_connect (action_search_dialog, "size-allocate", G_CALLBACK (size_allocated), private);
+  g_signal_connect (action_search_dialog, "scroll-event", G_CALLBACK (window_scrolled), private);
 
   gtk_widget_show (action_search_dialog);
 
@@ -656,6 +660,45 @@ size_allocated (GtkWidget    *widget,
     }
 }
 
+static gboolean
+window_scrolled (GtkWidget    *widget,
+                 GdkEvent     *event,
+                 SearchDialog *private)
+{
+  GdkEventScroll *scroll = (GdkEventScroll*) event;
+
+  if (scroll->state & GDK_CONTROL_MASK)
+    {
+      GimpGuiConfig *config      = private->config;
+      gint           new_opacity = config->search_dialog_opacity;
+
+      switch (scroll->direction)
+        {
+        case GDK_SCROLL_UP:
+          new_opacity = MIN (config->search_dialog_opacity + 5, 100);
+          break;
+
+        case GDK_SCROLL_DOWN:
+          new_opacity = MAX (config->search_dialog_opacity - 5, 10);
+          break;
+
+        default:
+          break;
+        }
+
+      if (new_opacity != config->search_dialog_opacity)
+        {
+          config->search_dialog_opacity = new_opacity;
+          gtk_window_set_opacity (GTK_WINDOW (private->dialog),
+                                  (gdouble) new_opacity / 100.0);
+        }
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 action_search_setup_results_list (GtkWidget **results_list,
                                   GtkWidget **list_view)
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index b2cc034..bdf64f4 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1690,9 +1690,6 @@ prefs_dialog_new (Gimp       *gimp,
   prefs_spin_button_add (object, "action-history-size", 1.0, 10.0, 0,
                          _("Maximum History Size:"),
                          GTK_TABLE (table), 0, size_group);
-  prefs_spin_button_add (object, "search-dialog-opacity", 1.0, 10.0, 0,
-                         _("Search Dialog Opacity:"),
-                         GTK_TABLE (table), 3, size_group);
 
   button = prefs_button_add (GTK_STOCK_CLEAR,
                              _("Clear Action History"),


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