[gimp/soc-2011-gimpunitentry: 7/68] app: Use GimpUnitEntry in New Layer dialog



commit 700ca7e13a1ee4fdf5b576642a6f4c9062eb6b09
Author: Enrico Schröder <enni schroeder gmail com>
Date:   Mon Jun 6 16:20:46 2011 +0200

    app: Use GimpUnitEntry in New Layer dialog
    
    Replaces GimpSizeEntry with GimpUnitEntries in the New Layer dialog

 app/actions/layers-commands.c      |    9 +++++----
 app/dialogs/layer-options-dialog.c |   31 +++++++++++++++++++++++++------
 app/dialogs/layer-options-dialog.h |    3 ++-
 3 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index c494c52..ffa7bde 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -1020,11 +1020,12 @@ layers_new_layer_response (GtkWidget          *widget,
       layer_fill_type = dialog->fill_type;
 
       dialog->xsize =
-        RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->size_se),
-                                          0));
+        RINT (gimp_unit_entry_get_value_in_unit (gimp_unit_entry_table_get_entry (dialog->size_se, "width"),
+                                                 GIMP_UNIT_PIXEL));
+
       dialog->ysize =
-        RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->size_se),
-                                          1));
+        RINT (gimp_unit_entry_get_value_in_unit (gimp_unit_entry_table_get_entry (dialog->size_se, "height"),
+                                                 GIMP_UNIT_PIXEL));
 
       layer = gimp_layer_new (dialog->image,
                               dialog->xsize,
diff --git a/app/dialogs/layer-options-dialog.c b/app/dialogs/layer-options-dialog.c
index 66602e8..aa87619 100644
--- a/app/dialogs/layer-options-dialog.c
+++ b/app/dialogs/layer-options-dialog.c
@@ -72,6 +72,9 @@ layer_options_dialog_new (GimpImage    *image,
   GtkWidget          *spinbutton;
   GtkWidget          *frame;
   GtkWidget          *button;
+  GimpUnitEntryTable *unitEntryTable;
+  GtkWidget          *entry1;
+  GtkWidget          *entry2;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (layer == NULL || GIMP_IS_LAYER (layer), NULL);
@@ -116,7 +119,7 @@ layer_options_dialog_new (GimpImage    *image,
                       vbox, TRUE, TRUE, 0);
   gtk_widget_show (vbox);
 
-  table = gtk_table_new (layer ? 1 : 3, 2, FALSE);
+  table = gtk_table_new (layer ? 1 : 4, 2, FALSE);
   gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
   gtk_table_set_row_spacing (GTK_TABLE (table), 0, 6);
   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
@@ -139,7 +142,7 @@ layer_options_dialog_new (GimpImage    *image,
       gimp_image_get_resolution (image, &xres, &yres);
 
       /*  The size labels  */
-      label = gtk_label_new (_("Width:"));
+      /*label = gtk_label_new (_("Width:"));
       gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
       gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
@@ -149,10 +152,10 @@ layer_options_dialog_new (GimpImage    *image,
       gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
       gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
-      gtk_widget_show (label);
+      gtk_widget_show (label);*/
 
       /*  The size sizeentry  */
-      spinbutton = gimp_spin_button_new (&adjustment,
+      /*spinbutton = gimp_spin_button_new (&adjustment,
                                          1, 1, 1, 1, 10, 0,
                                          1, 2);
       gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
@@ -169,7 +172,7 @@ layer_options_dialog_new (GimpImage    *image,
                                  1, 2, 0, 1);
       gtk_widget_show (spinbutton);
 
-      gtk_table_attach (GTK_TABLE (table), options->size_se, 1, 2, 1, 3,
+      /*gtk_table_attach (GTK_TABLE (table), options->size_se, 1, 2, 1, 3,
                         GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
       gtk_widget_show (options->size_se);
 
@@ -196,7 +199,23 @@ layer_options_dialog_new (GimpImage    *image,
       gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 0,
                                   gimp_image_get_width  (image));
       gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 1,
-                                  gimp_image_get_height (image));
+                                  gimp_image_get_height (image));*/
+
+      /* UnitEntry */
+      options->size_se = GIMP_UNIT_ENTRY_TABLE (gimp_unit_entry_table_new ());
+      entry1 = gimp_unit_entry_table_add_entry (options->size_se, "width", _("Width:"));
+      entry2 = gimp_unit_entry_table_add_entry (options->size_se, "height", _("Height:"));
+      gimp_unit_entry_table_add_label (options->size_se, GIMP_UNIT_PIXEL);
+
+      gimp_unit_entry_set_unit (GIMP_UNIT_ENTRY (entry1), GIMP_UNIT_PIXEL);
+      gimp_unit_entry_set_resolution (GIMP_UNIT_ENTRY (entry1), xres);
+      gimp_unit_entry_set_resolution (GIMP_UNIT_ENTRY (entry2), yres);
+      gimp_unit_entry_set_value (GIMP_UNIT_ENTRY (entry1), gimp_image_get_width  (image));
+      gimp_unit_entry_set_value (GIMP_UNIT_ENTRY (entry2), gimp_image_get_height  (image));
+
+      gtk_table_attach (GTK_TABLE (table), options->size_se->table, 0, 2, 1, 3,
+                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+      gtk_widget_show (options->size_se->table);
 
       /*  The radio frame  */
       frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
diff --git a/app/dialogs/layer-options-dialog.h b/app/dialogs/layer-options-dialog.h
index f841bf2..c47a295 100644
--- a/app/dialogs/layer-options-dialog.h
+++ b/app/dialogs/layer-options-dialog.h
@@ -18,6 +18,7 @@
 #ifndef __LAYER_OPTIONS_DIALOG_H__
 #define __LAYER_OPTIONS_DIALOG_H__
 
+#include "libgimpwidgets/gimpwidgets.h"
 
 typedef struct _LayerOptionsDialog LayerOptionsDialog;
 
@@ -25,7 +26,7 @@ struct _LayerOptionsDialog
 {
   GtkWidget    *dialog;
   GtkWidget    *name_entry;
-  GtkWidget    *size_se;
+  GimpUnitEntryTable    *size_se;
   GtkWidget    *rename_toggle;
 
   GimpFillType  fill_type;


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