gimp r25049 - in trunk: . app/display app/tools



Author: neo
Date: Thu Mar  6 11:54:44 2008
New Revision: 25049
URL: http://svn.gnome.org/viewvc/gimp?rev=25049&view=rev

Log:
2008-03-06  Sven Neumann  <sven gimp org>

	* app/tools/gimptransformtool.c
	* app/tools/gimptransformoptions.[ch]
	* app/display/gimpdisplayshell-preview.c: take the preview opacity
	from the transform tool options. Based on a patch from Tom Lechner.
	Closes bug #520690.


Modified:
   trunk/ChangeLog
   trunk/app/display/gimpdisplayshell-preview.c
   trunk/app/tools/gimptransformoptions.c
   trunk/app/tools/gimptransformoptions.h
   trunk/app/tools/gimptransformtool.c

Modified: trunk/app/display/gimpdisplayshell-preview.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-preview.c	(original)
+++ trunk/app/display/gimpdisplayshell-preview.c	Thu Mar  6 11:54:44 2008
@@ -27,7 +27,6 @@
 
 #include "core/gimpchannel.h"
 #include "core/gimpdrawable.h"
-#include "core/gimplayer.h"
 #include "core/gimpimage.h"
 
 #include "base/tile-manager.h"
@@ -185,8 +184,16 @@
   if (! ((z1 * z2 > 0) && (z3 * z4 > 0)))
     return;
 
-  if (GIMP_IS_LAYER (tool->drawable))
-    opacity = gimp_layer_get_opacity (GIMP_LAYER (tool->drawable)) * 255.999;
+  /* take opacity from the tool options */
+  {
+    gdouble value;
+
+    g_object_get (gimp_tool_get_options (tool),
+                  "preview-opacity", &value,
+                  NULL);
+
+    opacity = value * 255.999;
+  }
 
   mask = NULL;
   mask_offx = mask_offy = 0;

Modified: trunk/app/tools/gimptransformoptions.c
==============================================================================
--- trunk/app/tools/gimptransformoptions.c	(original)
+++ trunk/app/tools/gimptransformoptions.c	Thu Mar  6 11:54:44 2008
@@ -48,9 +48,10 @@
   PROP_INTERPOLATION,
   PROP_CLIP,
   PROP_PREVIEW_TYPE,
+  PROP_PREVIEW_OPACITY,
   PROP_GRID_TYPE,
   PROP_GRID_SIZE,
-  PROP_CONSTRAIN
+  PROP_CONSTRAIN,
 };
 
 
@@ -67,7 +68,11 @@
 
 static void   gimp_transform_options_preview_notify (GimpTransformOptions *options,
                                                      GParamSpec           *pspec,
-                                                     GtkWidget            *density_box);
+                                                     GtkWidget            *box);
+
+static void   gimp_transform_options_preview_opacity_notify (GimpTransformOptions *options,
+                                                     GParamSpec           *pspec,
+                                                     GtkWidget            *table);
 
 
 G_DEFINE_TYPE (GimpTransformOptions, gimp_transform_options,
@@ -112,6 +117,10 @@
                                  GIMP_TYPE_TRANSFORM_PREVIEW_TYPE,
                                  GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE,
                                  GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_PREVIEW_OPACITY,
+                                   "preview-opacity", NULL,
+                                   0.0, 1.0, 1.0,
+                                GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRID_TYPE,
                                  "grid-type", NULL,
                                  GIMP_TYPE_TRANSFORM_GRID_TYPE,
@@ -158,6 +167,9 @@
     case PROP_PREVIEW_TYPE:
       options->preview_type = g_value_get_enum (value);
       break;
+    case PROP_PREVIEW_OPACITY:
+      options->preview_opacity = g_value_get_double (value);
+      break;
     case PROP_GRID_TYPE:
       options->grid_type = g_value_get_enum (value);
       break;
@@ -198,6 +210,9 @@
     case PROP_PREVIEW_TYPE:
       g_value_set_enum (value, options->preview_type);
       break;
+    case PROP_PREVIEW_OPACITY:
+      g_value_set_double (value, options->preview_opacity);
+      break;
     case PROP_GRID_TYPE:
       g_value_set_enum (value, options->grid_type);
       break;
@@ -228,6 +243,14 @@
   GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
 }
 
+/**
+ * gimp_transform_options_gui:
+ * @tool_options: a #GimpToolOptions
+ *
+ * Build the Transform Tool Options.
+ *
+ * Return value: a container holding the transform tool options
+ **/
 GtkWidget *
 gimp_transform_options_gui (GimpToolOptions *tool_options)
 {
@@ -239,7 +262,7 @@
   GtkWidget            *frame;
   GtkWidget            *table;
   GtkWidget            *combo;
-  GtkWidget            *button;
+  GtkWidget            *preview_box;
   const gchar          *constrain = NULL;
 
   hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0);
@@ -296,22 +319,42 @@
   gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
   gtk_widget_show (combo);
 
-  /*  the grid type menu  */
-  button = gtk_vbox_new (FALSE, 6);
-  gtk_container_add (GTK_CONTAINER (frame), button);
-  gtk_widget_show (button);
+  preview_box = gtk_vbox_new (FALSE, 6);
+  gtk_container_add (GTK_CONTAINER (frame), preview_box);
+  gtk_widget_show (preview_box);
+
+  /*  the preview opacity scale  */
+  table = gtk_table_new (1, 3, FALSE);
+  gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
+  gtk_box_pack_start (GTK_BOX (preview_box), table, FALSE, FALSE, 0);
+  gtk_widget_show (table);
+
+  gtk_widget_set_sensitive (table,
+                            options->preview_type ==
+                            GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE ||
+                            options->preview_type ==
+                            GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
 
+  g_signal_connect (config, "notify::preview-type",
+                    G_CALLBACK (gimp_transform_options_preview_opacity_notify),
+                    table);
+
+  gimp_prop_opacity_entry_new (config, "preview-opacity",
+                               GTK_TABLE (table), 0, 0,
+                               _("Opacity:"));
+
+  /*  the grid type menu  */
   combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0);
-  gtk_box_pack_start (GTK_BOX (button), combo, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (preview_box), combo, FALSE, FALSE, 0);
   gtk_widget_show (combo);
 
   /*  the grid density scale  */
   table = gtk_table_new (1, 3, FALSE);
   gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
-  gtk_box_pack_start (GTK_BOX (button), table, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (preview_box), table, FALSE, FALSE, 0);
   gtk_widget_show (table);
 
-  gtk_widget_set_sensitive (button,
+  gtk_widget_set_sensitive (combo,
                             options->preview_type ==
                             GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
                             options->preview_type ==
@@ -319,7 +362,17 @@
 
   g_signal_connect (config, "notify::preview-type",
                     G_CALLBACK (gimp_transform_options_preview_notify),
-                    button);
+                    combo);
+
+  gtk_widget_set_sensitive (table,
+                            options->preview_type ==
+                            GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
+                            options->preview_type ==
+                            GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
+
+  g_signal_connect (config, "notify::preview-type",
+                    G_CALLBACK (gimp_transform_options_preview_notify),
+                    table);
 
   gimp_prop_scale_entry_new (config, "grid-size",
                              GTK_TABLE (table), 0, 0,
@@ -338,8 +391,11 @@
 
   if (constrain)
     {
-      gchar *label = g_strdup_printf (constrain,
-                                      gimp_get_mod_string (GDK_CONTROL_MASK));
+      GtkWidget *button;
+      gchar     *label;
+
+      label = g_strdup_printf (constrain,
+                               gimp_get_mod_string (GDK_CONTROL_MASK));
 
       button = gimp_prop_check_button_new (config, "constrain", label);
       gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
@@ -357,11 +413,24 @@
 static void
 gimp_transform_options_preview_notify (GimpTransformOptions *options,
                                        GParamSpec           *pspec,
-                                       GtkWidget            *density_box)
+                                       GtkWidget            *box)
 {
-  gtk_widget_set_sensitive (density_box,
+  gtk_widget_set_sensitive (box,
                             options->preview_type ==
                             GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
                             options->preview_type ==
                             GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
 }
+
+static void
+gimp_transform_options_preview_opacity_notify (GimpTransformOptions *options,
+                                               GParamSpec           *pspec,
+                                               GtkWidget            *table)
+{
+  gtk_widget_set_sensitive (table,
+                            options->preview_type ==
+                            GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE ||
+                            options->preview_type ==
+                            GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
+}
+

Modified: trunk/app/tools/gimptransformoptions.h
==============================================================================
--- trunk/app/tools/gimptransformoptions.h	(original)
+++ trunk/app/tools/gimptransformoptions.h	Thu Mar  6 11:54:44 2008
@@ -44,6 +44,7 @@
   gint                      recursion_level;
   gboolean                  clip;
   GimpTransformPreviewType  preview_type;
+  gdouble                   preview_opacity;
   GimpTransformGridType     grid_type;
   gint                      grid_size;
   gboolean                  constrain;

Modified: trunk/app/tools/gimptransformtool.c
==============================================================================
--- trunk/app/tools/gimptransformtool.c	(original)
+++ trunk/app/tools/gimptransformtool.c	Thu Mar  6 11:54:44 2008
@@ -280,6 +280,10 @@
       g_signal_connect_object (options, "notify::grid-size",
                                G_CALLBACK (gimp_transform_tool_notify_preview),
                                tr_tool, 0);
+      g_signal_connect_object (tool->tool_info->tool_options,
+                               "notify::preview-opacity",
+                               G_CALLBACK (gimp_transform_tool_notify_preview),
+                               tr_tool, 0);
     }
 
   g_signal_connect_object (options, "notify::constrain",



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