[gimp] libgimpwidgets: deprecate GimpUnitMenu and gimp_prop_unit_menu_new()



commit c36f762f7d149cbbebac44f8974474f7dfb89421
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 14 23:03:34 2010 +0200

    libgimpwidgets: deprecate GimpUnitMenu and gimp_prop_unit_menu_new()
    
    Add gimp_prop_unit_combo_box_new() and adapt all places using the
    prop_unit_menu. Some things are broken now, like there are no pixel
    digits set, resolution unit menus show "pixels" and warn badly when
    pixels is selected, and file-pdf-load is not built right now.
    More fixes to come...

 app/tools/gimppaintoptions-gui.c |    5 +-
 app/tools/gimprectangleoptions.c |    2 +-
 libgimpwidgets/gimppropwidgets.c |  128 ++++++++++++++++++++++++++++++++++++++
 libgimpwidgets/gimppropwidgets.h |    4 +
 libgimpwidgets/gimpsizeentry.c   |   50 ++++++++-------
 libgimpwidgets/gimpunitmenu.c    |    4 +-
 libgimpwidgets/gimpunitmenu.h    |    4 +
 plug-ins/common/.gitignore       |    2 -
 plug-ins/common/Makefile.am      |   22 -------
 plug-ins/common/gimprc.common    |    1 -
 plug-ins/common/plugin-defs.pl   |    2 +-
 11 files changed, 173 insertions(+), 51 deletions(-)
---
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index b89e37e..4d724a5 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -224,13 +224,16 @@ fade_options_gui (GimpPaintOptions *paint_options,
                              spinbutton, 1, FALSE);
 
   /*  the fade-out unitmenu  */
-  menu = gimp_prop_unit_menu_new (config, "fade-unit", "%a");
+  menu = gimp_prop_unit_combo_box_new (config, "fade-unit");
   gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 0, 1,
                     GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
   gtk_widget_show (menu);
 
+#if 0
+  /* FIXME pixel digits */
   g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
   gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0);
+#endif
 
     /*  the repeat type  */
   combo = gimp_prop_enum_combo_box_new (config, "fade-repeat", 0, 0);
diff --git a/app/tools/gimprectangleoptions.c b/app/tools/gimprectangleoptions.c
index 3fc14ad..b11f31a 100644
--- a/app/tools/gimprectangleoptions.c
+++ b/app/tools/gimprectangleoptions.c
@@ -757,7 +757,7 @@ gimp_rectangle_options_prop_dimension_frame_new (GObject      *config,
   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   gtk_widget_show (label);
 
-  menu = gimp_prop_unit_menu_new (config, unit_property_name, "%a");
+  menu = gimp_prop_unit_combo_box_new (config, unit_property_name);
   gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
   gtk_widget_show (menu);
 
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index 0a10d68..2c518c2 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -26,6 +26,13 @@
 #include "libgimpbase/gimpbase.h"
 #include "libgimpconfig/gimpconfig.h"
 
+#include "gimpwidgetstypes.h"
+
+#undef GIMP_DISABLE_DEPRECATED
+#include "gimppropwidgets.h"
+#include "gimpunitmenu.h"
+
+#define GIMP_DISABLE_DEPRECATED
 #include "gimpwidgets.h"
 
 #include "libgimp/libgimp-intl.h"
@@ -3373,6 +3380,127 @@ gimp_prop_color_area_notify (GObject    *config,
 }
 
 
+/********************/
+/*  unit combo box  */
+/********************/
+
+static void   gimp_prop_unit_combo_box_callback (GtkWidget  *combo,
+                                                 GObject    *config);
+static void   gimp_prop_unit_combo_box_notify   (GObject    *config,
+                                                 GParamSpec *param_spec,
+                                                 GtkWidget  *combo);
+
+/**
+ * gimp_prop_unit_combo_box_new:
+ * @config:        Object to which property is attached.
+ * @property_name: Name of Unit property.
+ *
+ * Creates a #GimpUnitComboBox to set and display the value of a Unit
+ * property.  See gimp_unit_combo_box_new() for more information.
+ *
+ * Return value:  A new #GimpUnitComboBox widget.
+ *
+ * Since GIMP 2.8
+ */
+GtkWidget *
+gimp_prop_unit_combo_box_new (GObject     *config,
+                              const gchar *property_name)
+{
+  GParamSpec *param_spec;
+  GtkWidget  *combo;
+  GimpUnit    unit;
+  GValue      value = { 0, };
+  gboolean    show_pixels;
+  gboolean    show_percent;
+
+  param_spec = check_param_spec_w (config, property_name,
+                                   GIMP_TYPE_PARAM_UNIT, G_STRFUNC);
+  if (! param_spec)
+    return NULL;
+
+  g_value_init (&value, param_spec->value_type);
+
+  g_value_set_int (&value, GIMP_UNIT_PIXEL);
+  show_pixels = (g_param_value_validate (param_spec, &value) == FALSE);
+
+  g_value_set_int (&value, GIMP_UNIT_PERCENT);
+  show_percent = (g_param_value_validate (param_spec, &value) == FALSE);
+
+  g_value_unset (&value);
+
+  g_object_get (config,
+                property_name, &unit,
+                NULL);
+
+  /* FIXME implement show_pixels and show_percent */
+  combo = gimp_unit_combo_box_new ();
+
+  set_param_spec (G_OBJECT (combo), combo, param_spec);
+
+  g_signal_connect (combo, "changed",
+                    G_CALLBACK (gimp_prop_unit_combo_box_callback),
+                    config);
+
+  connect_notify (config, property_name,
+                  G_CALLBACK (gimp_prop_unit_combo_box_notify),
+                  combo);
+
+  return combo;
+}
+
+static void
+gimp_prop_unit_combo_box_callback (GtkWidget *combo,
+                                   GObject   *config)
+{
+  GParamSpec *param_spec;
+  GimpUnit    unit;
+
+  param_spec = get_param_spec (G_OBJECT (combo));
+  if (! param_spec)
+    return;
+
+  unit = gimp_unit_combo_box_get_active (GIMP_UNIT_COMBO_BOX (combo));
+
+  /* FIXME gimp_unit_menu_update (menu, &unit); */
+
+  g_signal_handlers_block_by_func (config,
+                                   gimp_prop_unit_combo_box_notify,
+                                   combo);
+
+  g_object_set (config,
+                param_spec->name, unit,
+                NULL);
+
+  g_signal_handlers_unblock_by_func (config,
+                                     gimp_prop_unit_combo_box_notify,
+                                     combo);
+}
+
+static void
+gimp_prop_unit_combo_box_notify (GObject    *config,
+                                 GParamSpec *param_spec,
+                                 GtkWidget  *combo)
+{
+  GimpUnit  unit;
+
+  g_object_get (config,
+                param_spec->name, &unit,
+                NULL);
+
+  g_signal_handlers_block_by_func (combo,
+                                   gimp_prop_unit_combo_box_callback,
+                                   config);
+
+  gimp_unit_combo_box_set_active (GIMP_UNIT_COMBO_BOX (combo), unit);
+
+  /* FIXME gimp_unit_menu_update (menu, &unit); */
+
+  g_signal_handlers_unblock_by_func (combo,
+                                     gimp_prop_unit_combo_box_callback,
+                                     config);
+}
+
+
 /***************/
 /*  unit menu  */
 /***************/
diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h
index 6a55aba..50cfd75 100644
--- a/libgimpwidgets/gimppropwidgets.h
+++ b/libgimpwidgets/gimppropwidgets.h
@@ -202,9 +202,13 @@ GtkWidget     * gimp_prop_color_area_new          (GObject       *config,
 
 /*  GimpParamUnit  */
 
+GtkWidget     * gimp_prop_unit_combo_box_new      (GObject       *config,
+                                                   const gchar   *property_name);
+#ifndef GIMP_DISABLE_DEPRECATED
 GtkWidget     * gimp_prop_unit_menu_new           (GObject       *config,
                                                    const gchar   *property_name,
                                                    const gchar   *unit_format);
+#endif /* GIMP_DISABLE_DEPRECATED */
 
 
 /*  GParamString (stock_id)  */
diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c
index 0f5ca20..d0dff2f 100644
--- a/libgimpwidgets/gimpsizeentry.c
+++ b/libgimpwidgets/gimpsizeentry.c
@@ -40,7 +40,7 @@
  * SECTION: gimpsizeentry
  * @title: GimpSizeEntry
  * @short_description: Widget for entering pixel values and resolutions.
- * @see_also: #GimpUnit, #GimpUnitMenu, gimp_coordinates_new()
+ * @see_also: #GimpUnit, #GimpUnitComboBox, gimp_coordinates_new()
  *
  * This widget is used to enter pixel distances/sizes and resolutions.
  *
@@ -48,13 +48,13 @@
  * each field automatic mappings are performed between the field's
  * "reference value" and its "value".
  *
- * There is a #GimpUnitMenu right of the entry fields which lets you
- * specify the #GimpUnit of the displayed values.
+ * There is a #GimpUnitComboBox right of the entry fields which lets
+ * you specify the #GimpUnit of the displayed values.
  *
  * For each field, there can be one or two #GtkSpinButton's to enter
  * "value" and "reference value". If you specify @show_refval as
  * #FALSE in gimp_size_entry_new() there will be only one
- * #GtkSpinButton and the #GimpUnitMenu will contain an item for
+ * #GtkSpinButton and the #GimpUnitComboBox will contain an item for
  * selecting GIMP_UNIT_PIXEL.
  *
  * The "reference value" is either of GIMP_UNIT_PIXEL or dpi,
@@ -246,7 +246,7 @@ gimp_size_entry_finalize (GObject *object)
  *
  * The #GimpSizeEntry is derived from #GtkTable and will have
  * an empty border of one cell width on each side plus an empty column left
- * of the #GimpUnitMenu to allow the caller to add labels or a
+ * of the #GimpUnitComboBox to allow the caller to add labels or a
  * #GimpChainButton.
  *
  * Returns: A Pointer to the new #GimpSizeEntry widget.
@@ -262,6 +262,7 @@ gimp_size_entry_new (gint                       number_of_fields,
                      GimpSizeEntryUpdatePolicy  update_policy)
 {
   GimpSizeEntry *gse;
+  GimpUnitStore *store;
   gint           i;
 
   g_return_val_if_fail ((number_of_fields >= 0) && (number_of_fields <= 16),
@@ -376,14 +377,17 @@ gimp_size_entry_new (gint                       number_of_fields,
                                     gsef->refval_digits);
     }
 
-  gse->unitmenu = gimp_unit_menu_new (unit_format, unit,
-                                      gse->menu_show_pixels,
-                                      gse->menu_show_percent, TRUE);
+  store = gimp_unit_store_new (gse->number_of_fields);
+  gse->unitmenu = gimp_unit_combo_box_new_with_model (store);
+  g_object_unref (store);
+
+  gimp_unit_combo_box_set_active (GIMP_UNIT_COMBO_BOX (gse->unitmenu), unit);
+
   gtk_table_attach (GTK_TABLE (gse), gse->unitmenu,
                     i+2, i+3,
                     gse->show_refval+1, gse->show_refval+2,
                     GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-  g_signal_connect (gse->unitmenu, "unit-changed",
+  g_signal_connect (gse->unitmenu, "changed",
                     G_CALLBACK (gimp_size_entry_unit_callback),
                     gse);
   gtk_widget_show (gse->unitmenu);
@@ -595,7 +599,7 @@ gimp_size_entry_set_resolution (GimpSizeEntry *gse,
  *
  * These values will be used if you specified @menu_show_percent as %TRUE
  * in gimp_size_entry_new() and the user has selected GIMP_UNIT_PERCENT in
- * the #GimpSizeEntry's #GimpUnitMenu.
+ * the #GimpSizeEntry's #GimpUnitComboBox.
  *
  * This function does nothing if the #GimpSizeEntryUpdatePolicy specified in
  * gimp_size_entry_new() doesn't equal to GIMP_SIZE_ENTRY_UPDATE_SIZE.
@@ -721,7 +725,7 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
  *
  * The @value returned is a distance or resolution
  * in the #GimpUnit the user has selected in the #GimpSizeEntry's
- * #GimpUnitMenu.
+ * #GimpUnitComboBox.
  *
  * NOTE: In most cases you won't be interested in this value because the
  *       #GimpSizeEntry's purpose is to shield the programmer from unit
@@ -805,7 +809,7 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
  *
  * The @value passed is treated to be a distance or resolution
  * in the #GimpUnit the user has selected in the #GimpSizeEntry's
- * #GimpUnitMenu.
+ * #GimpUnitComboBox.
  *
  * NOTE: In most cases you won't be interested in this value because the
  *       #GimpSizeEntry's purpose is to shield the programmer from unit
@@ -1107,7 +1111,7 @@ gimp_size_entry_refval_callback (GtkWidget *widget,
  * @gse: The sizeentry you want to know the unit of.
  *
  * Returns the #GimpUnit the user has selected in the #GimpSizeEntry's
- * #GimpUnitMenu.
+ * #GimpUnitComboBox.
  *
  * Returns: The sizeentry's unit.
  **/
@@ -1129,7 +1133,8 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
 
   gse->unit = unit;
 
-  digits = gimp_unit_menu_get_pixel_digits (GIMP_UNIT_MENU (gse->unitmenu));
+  digits = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (gse),
+                                               "gimp-pixel-digits"));
 
   for (i = 0; i < gse->number_of_fields; i++)
     {
@@ -1184,7 +1189,7 @@ gimp_size_entry_set_unit (GimpSizeEntry *gse,
   g_return_if_fail (gse->menu_show_pixels || (unit != GIMP_UNIT_PIXEL));
   g_return_if_fail (gse->menu_show_percent || (unit != GIMP_UNIT_PERCENT));
 
-  gimp_unit_menu_set_unit (GIMP_UNIT_MENU (gse->unitmenu), unit);
+  gimp_unit_combo_box_set_active (GIMP_UNIT_COMBO_BOX (gse->unitmenu), unit);
   gimp_size_entry_update_unit (gse, unit);
 }
 
@@ -1194,7 +1199,7 @@ gimp_size_entry_unit_callback (GtkWidget     *widget,
 {
   GimpUnit new_unit;
 
-  new_unit = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget));
+  new_unit = gimp_unit_combo_box_get_active (GIMP_UNIT_COMBO_BOX (widget));
 
   if (gse->unit != new_unit)
     gimp_size_entry_update_unit (gse, new_unit);
@@ -1392,21 +1397,22 @@ gimp_size_entry_show_unit_menu (GimpSizeEntry *gse,
  * @gse: a #GimpSizeEntry
  * @digits: the number of digits to display for a pixel size
  *
- * Similar to gimp_unit_menu_set_pixel_digits(), this function allows
- * you set up a #GimpSizeEntry so that sub-pixel sizes can be entered.
+ * This function allows you set up a #GimpSizeEntry so that sub-pixel
+ * sizes can be entered.
  **/
 void
 gimp_size_entry_set_pixel_digits (GimpSizeEntry *gse,
                                   gint           digits)
 {
-  GimpUnitMenu *menu;
+  GimpUnitComboBox *combo;
 
   g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse));
 
-  menu = GIMP_UNIT_MENU (gse->unitmenu);
+  combo = GIMP_UNIT_COMBO_BOX (gse->unitmenu);
 
-  gimp_unit_menu_set_pixel_digits (menu, digits);
-  gimp_size_entry_update_unit (gse, gimp_unit_menu_get_unit (menu));
+  g_object_set_data (G_OBJECT (gse), "gimp-pixel-digits",
+                     GINT_TO_POINTER (digits));
+  gimp_size_entry_update_unit (gse, gimp_unit_combo_box_get_active (combo));
 }
 
 
diff --git a/libgimpwidgets/gimpunitmenu.c b/libgimpwidgets/gimpunitmenu.c
index 2a9fe71..b0a5d36 100644
--- a/libgimpwidgets/gimpunitmenu.c
+++ b/libgimpwidgets/gimpunitmenu.c
@@ -31,9 +31,11 @@
 
 #include "gimpdialog.h"
 #include "gimphelpui.h"
-#include "gimpunitmenu.h"
 #include "gimpwidgets.h"
 
+#undef GIMP_DISABLE_DEPRECATED
+#include "gimpunitmenu.h"
+
 #include "libgimp/libgimp-intl.h"
 
 
diff --git a/libgimpwidgets/gimpunitmenu.h b/libgimpwidgets/gimpunitmenu.h
index c3099ed..14ae7cd 100644
--- a/libgimpwidgets/gimpunitmenu.h
+++ b/libgimpwidgets/gimpunitmenu.h
@@ -19,6 +19,8 @@
  * <http://www.gnu.org/licenses/>.
  */
 
+#ifndef GIMP_DISABLE_DEPRECATED
+
 #ifndef __GIMP_UNIT_MENU_H__
 #define __GIMP_UNIT_MENU_H__
 
@@ -95,3 +97,5 @@ gint        gimp_unit_menu_get_pixel_digits (GimpUnitMenu *menu);
 G_END_DECLS
 
 #endif /* __GIMP_UNIT_MENU_H__ */
+
+#endif /* GIMP_DISABLE_DEPRECATED */
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 11db5ef..08f9f39 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -130,8 +130,6 @@
 /file-pat.exe
 /file-pcx
 /file-pcx.exe
-/file-pdf-load
-/file-pdf-load.exe
 /file-pdf-save
 /file-pdf-save.exe
 /file-pix
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 1870dd1..1f2a563 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -107,7 +107,6 @@ libexec_PROGRAMS = \
 	$(FILE_MNG) \
 	file-pat \
 	file-pcx \
-	$(FILE_PDF_LOAD) \
 	$(FILE_PDF_SAVE) \
 	file-pix \
 	$(FILE_PNG) \
@@ -193,7 +192,6 @@ EXTRA_PROGRAMS = \
 	file-aa \
 	file-jp2-load \
 	file-mng \
-	file-pdf-load \
 	file-pdf-save \
 	file-png \
 	file-psp \
@@ -1272,26 +1270,6 @@ file_pcx_LDADD = \
 	$(INTLLIBS)		\
 	$(file_pcx_RC)
 
-file_pdf_load_CFLAGS = $(POPPLER_CFLAGS)
-
-file_pdf_load_SOURCES = \
-	file-pdf-load.c
-
-file_pdf_load_LDADD = \
-	$(libgimpui)		\
-	$(libgimpwidgets)	\
-	$(libgimpmodule)	\
-	$(libgimp)		\
-	$(libgimpmath)		\
-	$(libgimpconfig)	\
-	$(libgimpcolor)		\
-	$(libgimpbase)		\
-	$(GTK_LIBS)		\
-	$(POPPLER_LIBS)		\
-	$(RT_LIBS)		\
-	$(INTLLIBS)		\
-	$(file_pdf_load_RC)
-
 file_pdf_save_CFLAGS = $(CAIRO_PDF_CFLAGS)
 
 file_pdf_save_SOURCES = \
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index b90d25b..871789d 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -62,7 +62,6 @@ file_jp2_load_RC = file-jp2-load.rc.o
 file_mng_RC = file-mng.rc.o
 file_pat_RC = file-pat.rc.o
 file_pcx_RC = file-pcx.rc.o
-file_pdf_load_RC = file-pdf-load.rc.o
 file_pdf_save_RC = file-pdf-save.rc.o
 file_pix_RC = file-pix.rc.o
 file_png_RC = file-png.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 1b778ba..1ef7edb 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -66,7 +66,7 @@
     'file-pix' => { ui => 1 },
     'file-png' => { ui => 1, optional => 1, libs => 'PNG_LIBS', cflags => 'PNG_CFLAGS' },
     'file-pnm' => { ui => 1 },
-    'file-pdf-load' => { ui => 1, optional => 1, libs => 'POPPLER_LIBS', cflags => 'POPPLER_CFLAGS' },
+#    'file-pdf-load' => { ui => 1, optional => 1, libs => 'POPPLER_LIBS', cflags => 'POPPLER_CFLAGS' },
     'file-pdf-save' => { ui => 1, optional => 1, libs => 'CAIRO_PDF_LIBS', cflags => 'CAIRO_PDF_CFLAGS' },
     'file-ps' => { ui => 1 },
     'file-psp' => { ui => 1, optional => 1, libs => 'Z_LIBS' },



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