[gimp] Bug 770901 - Improve the "New Layer" and "Layer Attributes" dialogs



commit 3518a150649d119ce6022ad0914c8fdd13ecf0ff
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 21 22:54:10 2016 +0200

    Bug 770901 - Improve the "New Layer" and "Layer Attributes" dialogs
    
    Add "Mode", "Opacity" and "Offset" controls to the dialogs. Remember
    the "New Layer" mode and opacity in GimpDialogConfig.
    
    Also addresses bug #361810.

 app/actions/layers-commands.c      |  114 +++++++++++++++++-------
 app/config/gimpdialogconfig.c      |   30 ++++++
 app/config/gimpdialogconfig.h      |    2 +
 app/config/gimprc-blurbs.h         |    6 ++
 app/dialogs/layer-options-dialog.c |  173 ++++++++++++++++++++++++++++++------
 app/dialogs/layer-options-dialog.h |   26 ++++--
 6 files changed, 282 insertions(+), 69 deletions(-)
---
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 8508e36..3b379db 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -117,9 +117,13 @@ static void   layers_new_callback             (GtkWidget             *dialog,
                                                GimpLayer             *layer,
                                                GimpContext           *context,
                                                const gchar           *layer_name,
+                                               GimpLayerModeEffects   layer_mode,
+                                               gdouble                layer_opacity,
                                                GimpFillType           layer_fill_type,
                                                gint                   layer_width,
                                                gint                   layer_height,
+                                               gint                   layer_offset_x,
+                                               gint                   layer_offset_y,
                                                gboolean               rename_text_layer,
                                                gpointer               user_data);
 static void   layers_edit_attributes_callback (GtkWidget             *dialog,
@@ -127,9 +131,13 @@ static void   layers_edit_attributes_callback (GtkWidget             *dialog,
                                                GimpLayer             *layer,
                                                GimpContext           *context,
                                                const gchar           *layer_name,
+                                               GimpLayerModeEffects   layer_mode,
+                                               gdouble                layer_opacity,
                                                GimpFillType           layer_fill_type,
                                                gint                   layer_width,
                                                gint                   layer_height,
+                                               gint                   layer_offset_x,
+                                               gint                   layer_offset_y,
                                                gboolean               rename_text_layer,
                                                gpointer               user_data);
 static void   layers_add_mask_callback        (GtkWidget             *dialog,
@@ -235,6 +243,8 @@ layers_edit_attributes_cmd_callback (GtkAction *action,
                                          _("Edit Layer Attributes"),
                                          GIMP_HELP_LAYER_EDIT,
                                          gimp_object_get_name (layer),
+                                         gimp_layer_get_mode (layer),
+                                         gimp_layer_get_opacity (layer),
                                          0 /* unused */,
                                          layers_edit_attributes_callback,
                                          NULL);
@@ -293,6 +303,8 @@ layers_new_cmd_callback (GtkAction *action,
                                          _("Create a New Layer"),
                                          GIMP_HELP_LAYER_NEW,
                                          config->layer_new_name,
+                                         config->layer_new_mode,
+                                         config->layer_new_opacity,
                                          config->layer_new_fill_type,
                                          layers_new_callback,
                                          NULL);
@@ -1125,31 +1137,39 @@ layers_lock_alpha_cmd_callback (GtkAction *action,
 /*  private functions  */
 
 static void
-layers_new_callback (GtkWidget    *dialog,
-                     GimpImage    *image,
-                     GimpLayer    *layer,
-                     GimpContext  *context,
-                     const gchar  *layer_name,
-                     GimpFillType  layer_fill_type,
-                     gint          layer_width,
-                     gint          layer_height,
-                     gboolean      rename_text_layer, /* unused */
-                     gpointer      user_data)
+layers_new_callback (GtkWidget            *dialog,
+                     GimpImage            *image,
+                     GimpLayer            *layer,
+                     GimpContext          *context,
+                     const gchar          *layer_name,
+                     GimpLayerModeEffects  layer_mode,
+                     gdouble               layer_opacity,
+                     GimpFillType          layer_fill_type,
+                     gint                  layer_width,
+                     gint                  layer_height,
+                     gint                  layer_offset_x,
+                     gint                  layer_offset_y,
+                     gboolean              rename_text_layer, /* unused */
+                     gpointer              user_data)
 {
   GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
 
   g_object_set (config,
                 "layer-new-name",      layer_name,
+                "layer-new-mode",      layer_mode,
+                "layer-new-opacity",   layer_opacity,
                 "layer-new-fill-type", layer_fill_type,
                 NULL);
 
   layer = gimp_layer_new (image, layer_width, layer_height,
                           gimp_image_get_layer_format (image, TRUE),
                           config->layer_new_name,
-                          GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+                          config->layer_new_opacity,
+                          config->layer_new_mode);
 
   if (layer)
     {
+      gimp_item_set_offset (GIMP_ITEM (layer), layer_offset_x, layer_offset_y);
       gimp_drawable_fill (GIMP_DRAWABLE (layer), context,
                           config->layer_new_fill_type);
       gimp_image_add_layer (image, layer,
@@ -1165,34 +1185,64 @@ layers_new_callback (GtkWidget    *dialog,
 }
 
 static void
-layers_edit_attributes_callback (GtkWidget    *dialog,
-                                 GimpImage    *image,
-                                 GimpLayer    *layer,
-                                 GimpContext  *context,
-                                 const gchar  *layer_name,
-                                 GimpFillType  layer_fill_type, /* unused */
-                                 gint          layer_width,     /* unused */
-                                 gint          layer_height,    /* unused */
-                                 gboolean      rename_text_layer,
-                                 gpointer      user_data)
+layers_edit_attributes_callback (GtkWidget            *dialog,
+                                 GimpImage            *image,
+                                 GimpLayer            *layer,
+                                 GimpContext          *context,
+                                 const gchar          *layer_name,
+                                 GimpLayerModeEffects  layer_mode,
+                                 gdouble               layer_opacity,
+                                 GimpFillType          unused1,
+                                 gint                  unused2,
+                                 gint                  unused3,
+                                 gint                  layer_offset_x,
+                                 gint                  layer_offset_y,
+                                 gboolean              rename_text_layer,
+                                 gpointer              user_data)
 {
-  if (strcmp (layer_name, gimp_object_get_name (layer)))
+  GimpItem *item = GIMP_ITEM (layer);
+
+  if (strcmp (layer_name, gimp_object_get_name (layer)) ||
+      layer_mode     != gimp_layer_get_mode (layer)     ||
+      layer_opacity  != gimp_layer_get_opacity (layer)  ||
+      layer_offset_x != gimp_item_get_offset_x (item)   ||
+      layer_offset_y != gimp_item_get_offset_y (item))
     {
-      GError *error = NULL;
+      gimp_image_undo_group_start (image,
+                                   GIMP_UNDO_GROUP_ITEM_PROPERTIES,
+                                   _("Layer Attributes"));
 
-      if (gimp_item_rename (GIMP_ITEM (layer), layer_name, &error))
+      if (strcmp (layer_name, gimp_object_get_name (layer)))
         {
-          gimp_image_flush (image);
+          GError *error = NULL;
+
+          if (! gimp_item_rename (GIMP_ITEM (layer), layer_name, &error))
+            {
+              gimp_message_literal (image->gimp,
+                                    G_OBJECT (dialog), GIMP_MESSAGE_WARNING,
+                                    error->message);
+              g_clear_error (&error);
+            }
         }
-      else
-        {
-          gimp_message_literal (image->gimp,
-                                G_OBJECT (dialog), GIMP_MESSAGE_WARNING,
-                                error->message);
-          g_clear_error (&error);
 
-          return;
+      if (layer_mode != gimp_layer_get_mode (layer))
+        gimp_layer_set_mode (layer, layer_mode, TRUE);
+
+      if (layer_opacity != gimp_layer_get_opacity (layer))
+        gimp_layer_set_opacity (layer, layer_opacity, TRUE);
+
+      if (layer_offset_x != gimp_item_get_offset_x (item) ||
+          layer_offset_y != gimp_item_get_offset_y (item))
+        {
+          gimp_item_translate (item,
+                               layer_offset_x - gimp_item_get_offset_x (item),
+                               layer_offset_y - gimp_item_get_offset_y (item),
+                               TRUE);
         }
+
+      gimp_image_undo_group_end (image);
+
+      gimp_image_flush (image);
     }
 
   if (gimp_item_is_text_layer (GIMP_ITEM (layer)))
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index 8456569..ee437f8 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -67,6 +67,8 @@ enum
   PROP_IMAGE_RESIZE_RESIZE_TEXT_LAYERS,
 
   PROP_LAYER_NEW_NAME,
+  PROP_LAYER_NEW_MODE,
+  PROP_LAYER_NEW_OPACITY,
   PROP_LAYER_NEW_FILL_TYPE,
 
   PROP_LAYER_RESIZE_FILL_TYPE,
@@ -292,6 +294,22 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
                            _("Layer"),
                            GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_ENUM (object_class, PROP_LAYER_NEW_MODE,
+                         "layer-new-mode",
+                         "Default new layer mode",
+                         LAYER_NEW_MODE_BLURB,
+                         GIMP_TYPE_LAYER_MODE_EFFECTS,
+                         GIMP_NORMAL_MODE,
+                         GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_LAYER_NEW_OPACITY,
+                           "layer-new-opacity",
+                           "Default new layer opacity",
+                           LAYER_NEW_OPACITY_BLURB,
+                           GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE,
+                           GIMP_OPACITY_OPAQUE,
+                           GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_ENUM (object_class, PROP_LAYER_NEW_FILL_TYPE,
                          "layer-new-fill-type",
                          "Default new layer fill type",
@@ -619,6 +637,12 @@ gimp_dialog_config_set_property (GObject      *object,
         g_free (config->layer_new_name);
       config->layer_new_name = g_value_dup_string (value);
       break;
+    case PROP_LAYER_NEW_MODE:
+      config->layer_new_mode = g_value_get_enum (value);
+      break;
+    case PROP_LAYER_NEW_OPACITY:
+      config->layer_new_opacity = g_value_get_double (value);
+      break;
     case PROP_LAYER_NEW_FILL_TYPE:
       config->layer_new_fill_type = g_value_get_enum (value);
       break;
@@ -793,6 +817,12 @@ gimp_dialog_config_get_property (GObject    *object,
     case PROP_LAYER_NEW_NAME:
       g_value_set_string (value, config->layer_new_name);
       break;
+    case PROP_LAYER_NEW_MODE:
+      g_value_set_enum (value, config->layer_new_mode);
+      break;
+    case PROP_LAYER_NEW_OPACITY:
+      g_value_set_double (value, config->layer_new_opacity);
+      break;
     case PROP_LAYER_NEW_FILL_TYPE:
       g_value_set_enum (value, config->layer_new_fill_type);
       break;
diff --git a/app/config/gimpdialogconfig.h b/app/config/gimpdialogconfig.h
index 5a1dc33..c04337b 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -65,6 +65,8 @@ struct _GimpDialogConfig
   gboolean                  image_resize_resize_text_layers;
 
   gchar                    *layer_new_name;
+  GimpLayerModeEffects      layer_new_mode;
+  gdouble                   layer_new_opacity;
   GimpFillType              layer_new_fill_type;
 
   GimpFillType              layer_resize_fill_type;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 7f25b5b..f2ea019 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -471,6 +471,12 @@ _("Sets the default 'Resize text layers' state for the 'Canvas Size' dialog.")
 #define LAYER_NEW_NAME_BLURB \
 _("Sets the default layer name for the 'New Layer' dialog.")
 
+#define LAYER_NEW_MODE_BLURB \
+_("Sets the default mode for the 'New Layer' dialog.")
+
+#define LAYER_NEW_OPACITY_BLURB \
+_("Sets the default opacity for the 'New Layer' dialog.")
+
 #define LAYER_NEW_FILL_TYPE_BLURB \
 _("Sets the default fill type for the 'New Layer' dialog.")
 
diff --git a/app/dialogs/layer-options-dialog.c b/app/dialogs/layer-options-dialog.c
index 92f9a20..3f98d59 100644
--- a/app/dialogs/layer-options-dialog.c
+++ b/app/dialogs/layer-options-dialog.c
@@ -35,7 +35,9 @@
 #include "text/gimptextlayer.h"
 
 #include "widgets/gimpcontainertreeview.h"
+#include "widgets/gimpspinscale.h"
 #include "widgets/gimpviewabledialog.h"
+#include "widgets/gimpwidgets-constructors.h"
 
 #include "layer-options-dialog.h"
 
@@ -49,12 +51,15 @@ struct _LayerOptionsDialog
   GimpImage                *image;
   GimpLayer                *layer;
   GimpContext              *context;
+  GimpLayerModeEffects      mode;
+  gdouble                   opacity;
   GimpFillType              fill_type;
   GimpLayerOptionsCallback  callback;
   gpointer                  user_data;
 
   GtkWidget                *name_entry;
   GtkWidget                *size_se;
+  GtkWidget                *offset_se;
   GtkWidget                *rename_toggle;
 };
 
@@ -82,6 +87,8 @@ layer_options_dialog_new (GimpImage                *image,
                           const gchar              *desc,
                           const gchar              *help_id,
                           const gchar              *layer_name,
+                          GimpLayerModeEffects      layer_mode,
+                          gdouble                   layer_opacity,
                           GimpFillType              layer_fill_type,
                           GimpLayerOptionsCallback  callback,
                           gpointer                  user_data)
@@ -91,11 +98,14 @@ layer_options_dialog_new (GimpImage                *image,
   GimpViewable       *viewable;
   GtkWidget          *vbox;
   GtkWidget          *table;
+  GtkWidget          *combo;
+  GtkWidget          *scale;
   GtkWidget          *label;
   GtkAdjustment      *adjustment;
   GtkWidget          *spinbutton;
-  GtkWidget          *frame;
-  GtkWidget          *button;
+  gdouble             xres;
+  gdouble             yres;
+  gint                row = 0;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (layer == NULL || GIMP_IS_LAYER (layer), NULL);
@@ -107,6 +117,8 @@ layer_options_dialog_new (GimpImage                *image,
   private->image     = image;
   private->layer     = layer;
   private->context   = context;
+  private->mode      = layer_mode;
+  private->opacity   = layer_opacity * 100.0;
   private->fill_type = layer_fill_type;
   private->callback  = callback;
   private->user_data = user_data;
@@ -145,38 +157,58 @@ layer_options_dialog_new (GimpImage                *image,
                       vbox, TRUE, TRUE, 0);
   gtk_widget_show (vbox);
 
-  table = gtk_table_new (layer ? 1 : 3, 2, FALSE);
-  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
-  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 6);
+  table = gtk_table_new (layer ? 5 : 8, 2, FALSE);
+  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+  gtk_table_set_row_spacing (GTK_TABLE (table), 3, 4);
+  if (! layer)
+    gtk_table_set_row_spacing (GTK_TABLE (table), 5, 4);
   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
   gtk_widget_show (table);
 
   /*  The name label and entry  */
   private->name_entry = gtk_entry_new ();
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
                              _("Layer _name:"), 0.0, 0.5,
                              private->name_entry, 1, FALSE);
 
   gtk_entry_set_activates_default (GTK_ENTRY (private->name_entry), TRUE);
   gtk_entry_set_text (GTK_ENTRY (private->name_entry), layer_name);
 
-  if (! layer)
-    {
-      gdouble xres;
-      gdouble yres;
+  combo = gimp_paint_mode_menu_new (FALSE, FALSE);
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
+                             _("_Mode:"), 0.0, 0.5,
+                             combo, 1, FALSE);
+  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
+                              private->mode,
+                              G_CALLBACK (gimp_int_combo_box_get_active),
+                              &private->mode);
 
-      gimp_image_get_resolution (image, &xres, &yres);
+  adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (private->opacity, 0.0, 100.0,
+                                                   1.0, 10.0, 0.0));
+  scale = gimp_spin_scale_new (adjustment, NULL, 1);
+  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
+                             _("_Opacity:"), 0.0, 0.5,
+                             scale, 1, FALSE);
 
+  g_signal_connect (adjustment, "value-changed",
+                    G_CALLBACK (gimp_double_adjustment_update),
+                    &private->opacity);
+
+  gimp_image_get_resolution (image, &xres, &yres);
+
+  if (! layer)
+    {
       /*  The size labels  */
       label = gtk_label_new (_("Width:"));
       gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+      gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
       gtk_widget_show (label);
 
       label = gtk_label_new (_("Height:"));
       gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
+      gtk_table_attach (GTK_TABLE (table), label, 0, 1, row + 1, row + 2,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
       gtk_widget_show (label);
 
@@ -199,7 +231,7 @@ layer_options_dialog_new (GimpImage                *image,
                                  1, 2, 0, 1);
       gtk_widget_show (spinbutton);
 
-      gtk_table_attach (GTK_TABLE (table), private->size_se, 1, 2, 1, 3,
+      gtk_table_attach (GTK_TABLE (table), private->size_se, 1, 2, row, row + 2,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
       gtk_widget_show (private->size_se);
 
@@ -228,21 +260,95 @@ layer_options_dialog_new (GimpImage                *image,
       gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se), 1,
                                   gimp_image_get_height (image));
 
-      /*  The radio frame  */
-      frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
-                                                    GIMP_FILL_FOREGROUND,
-                                                    GIMP_FILL_TRANSPARENT,
-                                                    gtk_label_new (_("Layer Fill Type")),
-                                                    G_CALLBACK (gimp_radio_button_update),
-                                                    &private->fill_type,
-                                                    &button);
-      gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button),
-                                       private->fill_type);
-      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-      gtk_widget_show (frame);
+      row += 2;
+    }
+
+  /*  The offset labels  */
+  label = gtk_label_new (_("Offset X:"));
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
+                    GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+  gtk_widget_show (label);
+
+  label = gtk_label_new (_("Offset Y:"));
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row + 1, row + 2,
+                    GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+  gtk_widget_show (label);
+
+  /*  The offset sizeentry  */
+  adjustment = (GtkAdjustment *)
+    gtk_adjustment_new (0, 1, 1, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (adjustment, 1.0, 2);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
+  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
+
+  private->offset_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
+                                            TRUE, TRUE, FALSE, 10,
+                                            GIMP_SIZE_ENTRY_UPDATE_SIZE);
+  gtk_table_set_col_spacing (GTK_TABLE (private->offset_se), 1, 4);
+  gtk_table_set_row_spacing (GTK_TABLE (private->offset_se), 0, 2);
+
+  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->offset_se),
+                             GTK_SPIN_BUTTON (spinbutton), NULL);
+  gtk_table_attach_defaults (GTK_TABLE (private->offset_se), spinbutton,
+                             1, 2, 0, 1);
+  gtk_widget_show (spinbutton);
+
+  gtk_table_attach (GTK_TABLE (table), private->offset_se, 1, 2, row, row + 2,
+                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+  gtk_widget_show (private->offset_se);
+
+  gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se),
+                            GIMP_UNIT_PIXEL);
+
+  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0,
+                                  xres, FALSE);
+  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 1,
+                                  yres, FALSE);
+
+  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->offset_se), 0,
+                                         -GIMP_MAX_IMAGE_SIZE,
+                                         GIMP_MAX_IMAGE_SIZE);
+  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->offset_se), 1,
+                                         -GIMP_MAX_IMAGE_SIZE,
+                                         GIMP_MAX_IMAGE_SIZE);
+
+  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->offset_se), 0,
+                            0, gimp_image_get_width  (image));
+  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->offset_se), 1,
+                            0, gimp_image_get_height (image));
+
+  if (layer)
+    {
+      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 0,
+                                  gimp_item_get_offset_x (GIMP_ITEM (layer)));
+      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 1,
+                                  gimp_item_get_offset_y (GIMP_ITEM (layer)));
     }
   else
     {
+      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 0, 0);
+      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 1, 0);
+    }
+
+  row += 2;
+
+  if (! layer)
+    {
+      /*  The fill type  */
+      combo = gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
+      gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
+                                 _("_Fill with:"), 0.0, 0.5,
+                                 combo, 1, FALSE);
+      gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
+                                  private->fill_type,
+                                  G_CALLBACK (gimp_int_combo_box_get_active),
+                                  &private->fill_type);
+    }
+
+  if (layer)
+    {
       GimpContainer *filters;
       GtkWidget     *frame;
       GtkWidget     *view;
@@ -293,6 +399,8 @@ layer_options_dialog_response (GtkWidget          *dialog,
       const gchar *name;
       gint         width             = 0;
       gint         height            = 0;
+      gint         offset_x;
+      gint         offset_y;
       gboolean     rename_text_layer = FALSE;
 
       name = gtk_entry_get_text (GTK_ENTRY (private->name_entry));
@@ -307,7 +415,14 @@ layer_options_dialog_response (GtkWidget          *dialog,
                                               1));
         }
 
-      if (private->layer &&
+      offset_x =
+        RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se),
+                                          0));
+      offset_y =
+        RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se),
+                                          1));
+
+          if (private->layer &&
           gimp_item_is_text_layer (GIMP_ITEM (private->layer)))
         {
           rename_text_layer =
@@ -319,9 +434,13 @@ layer_options_dialog_response (GtkWidget          *dialog,
                          private->layer,
                          private->context,
                          name,
+                         private->mode,
+                         private->opacity / 100.0,
                          private->fill_type,
                          width,
                          height,
+                         offset_x,
+                         offset_y,
                          rename_text_layer,
                          private->user_data);
     }
diff --git a/app/dialogs/layer-options-dialog.h b/app/dialogs/layer-options-dialog.h
index 34d7168..28b0fa1 100644
--- a/app/dialogs/layer-options-dialog.h
+++ b/app/dialogs/layer-options-dialog.h
@@ -19,16 +19,20 @@
 #define __LAYER_OPTIONS_DIALOG_H__
 
 
-typedef void (* GimpLayerOptionsCallback) (GtkWidget    *dialog,
-                                           GimpImage    *image,
-                                           GimpLayer    *layer,
-                                           GimpContext  *context,
-                                           const gchar  *layer_name,
-                                           GimpFillType  layer_fill_type,
-                                           gint          layer_width,
-                                           gint          layer_height,
-                                           gboolean      rename_text_layer,
-                                           gpointer      user_data);
+typedef void (* GimpLayerOptionsCallback) (GtkWidget            *dialog,
+                                           GimpImage            *image,
+                                           GimpLayer            *layer,
+                                           GimpContext          *context,
+                                           const gchar          *layer_name,
+                                           GimpLayerModeEffects  layer_mode,
+                                           gdouble               layer_opacity,
+                                           GimpFillType          layer_fill_type,
+                                           gint                  layer_width,
+                                           gint                  layer_height,
+                                           gint                  layer_offset_x,
+                                           gint                  layer_offset_y,
+                                           gboolean              rename_text_layer,
+                                           gpointer              user_data);
 
 
 GtkWidget * layer_options_dialog_new (GimpImage                *image,
@@ -41,6 +45,8 @@ GtkWidget * layer_options_dialog_new (GimpImage                *image,
                                       const gchar              *desc,
                                       const gchar              *help_id,
                                       const gchar              *layer_name,
+                                      GimpLayerModeEffects      layer_mode,
+                                      gdouble                   layer_opacity,
                                       GimpFillType              layer_fill_type,
                                       GimpLayerOptionsCallback  callback,
                                       gpointer                  user_data);


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