[gimp/soc-2011-gimpunitentry] GimpUnitEntry: added enum for mode (unit/resolution input)
- From: Enrico SchrÃder <eschroeder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-gimpunitentry] GimpUnitEntry: added enum for mode (unit/resolution input)
- Date: Fri, 8 Jul 2011 12:38:37 +0000 (UTC)
commit 5673c7c9ac7d7db454024cfa73ba10e2113492b9
Author: Enrico SchroÌder <enni schroeder gmail com>
Date: Fri Jul 8 14:07:00 2011 +0200
GimpUnitEntry: added enum for mode (unit/resolution input)
app/widgets/gimptemplateeditor.c | 3 +-
libgimpwidgets/gimpunitentry.c | 36 +++++++++++++++++-----------------
libgimpwidgets/gimpunitentry.h | 20 +++++++++++-------
libgimpwidgets/gimpunitentrytable.c | 6 ++--
libgimpwidgets/gimpunitentrytable.h | 6 ++--
libgimpwidgets/gimpwidgets.def | 4 +-
libgimpwidgets/test-unitentrygui.c | 4 +-
7 files changed, 41 insertions(+), 38 deletions(-)
---
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index bdfc52e..a834d10 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -133,7 +133,6 @@ gimp_template_editor_constructed (GObject *object)
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *table;
- GtkWidget *label;
GtkObject *adjustment;
GtkWidget *width;
GtkWidget *height;
@@ -291,7 +290,7 @@ gimp_template_editor_constructed (GObject *object)
gimp_unit_entry_table_add_entry_defaults (private->resolution_entries,
"yres",
_("Y resolution:"));
- gimp_unit_entry_table_set_res_mode (private->resolution_entries, TRUE);
+ gimp_unit_entry_table_set_mode (private->resolution_entries, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
gtk_box_pack_start (GTK_BOX (hbox), private->resolution_entries->table, TRUE, TRUE, 0);
gtk_widget_show (private->resolution_entries->table);
diff --git a/libgimpwidgets/gimpunitentry.c b/libgimpwidgets/gimpunitentry.c
index 43468ed..59888c9 100644
--- a/libgimpwidgets/gimpunitentry.c
+++ b/libgimpwidgets/gimpunitentry.c
@@ -104,7 +104,7 @@ gimp_unit_entry_init (GimpUnitEntry *unitEntry)
/* some default values */
unitEntry->dontUpdateText = FALSE;
- unitEntry->resMode = FALSE;
+ unitEntry->mode = GIMP_UNIT_ENTRY_MODE_UNIT;
/* connect signals */
/* we don't need all of them... */
@@ -242,7 +242,7 @@ on_output (GtkSpinButton *spin, gpointer data)
}
/* set text of the entry */
- if (!entry->resMode)
+ if (entry->mode == GIMP_UNIT_ENTRY_MODE_UNIT)
{
text = gimp_unit_adjustment_to_string (adj);
}
@@ -281,14 +281,14 @@ void on_text_changed (GtkEditable *editable, gpointer user_data)
DEBUG (("on_text_changed\n");)
- if (!entry->resMode)
+ if (!entry->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
{
- /* disable updating the displayed text (user input must not be overwriten) */
- entry->dontUpdateText = TRUE;
- /* parse input */
- gimp_unit_entry_parse (entry);
- /* reenable updating */
- entry->dontUpdateText = FALSE;
+ /* disable updating the displayed text (user input must not be overwriten) */
+ entry->dontUpdateText = TRUE;
+ /* parse input */
+ gimp_unit_entry_parse (entry);
+ /* reenable updating */
+ entry->dontUpdateText = FALSE;
}
}
@@ -297,12 +297,12 @@ gint on_input (GtkSpinButton *spinButton,
gpointer arg1,
gpointer user_data)
{
- if (!GIMP_UNIT_ENTRY (spinButton)->resMode)
+ if (!GIMP_UNIT_ENTRY (spinButton)->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION)
{
- /* parse and set value ourselves before GtkSpinButton does so, because
- GtkSpinButton would truncate our input and ignore parts of it */
- gimp_unit_entry_parse (GIMP_UNIT_ENTRY (spinButton));
- on_output (spinButton, (gpointer)GIMP_UNIT_ENTRY(spinButton)->unitAdjustment);
+ /* parse and set value ourselves before GtkSpinButton does so, because
+ GtkSpinButton would truncate our input and ignore parts of it */
+ gimp_unit_entry_parse (GIMP_UNIT_ENTRY (spinButton));
+ on_output (spinButton, (gpointer)GIMP_UNIT_ENTRY(spinButton)->unitAdjustment);
}
/* we want GtkSpinButton to handle the input nontheless (there is no problem anymore
@@ -323,7 +323,7 @@ void on_populate_popup (GtkEntry *entry,
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuItem);
/* ignore PIXEL when in resolution mode */
- (GIMP_UNIT_ENTRY (entry)->resMode) ? (i = 1) : (i = 0);
+ (GIMP_UNIT_ENTRY (entry)->mode == GIMP_UNIT_ENTRY_MODE_RESOLUTION) ? (i = 1) : (i = 0);
for (; i < gimp_unit_get_number_of_units(); i++)
{
@@ -474,8 +474,8 @@ gimp_unit_entry_set_bounds (GimpUnitEntry *entry, GimpUnit unit, gdouble upper,
}
void
-gimp_unit_entry_set_res_mode (GimpUnitEntry *entry,
- gboolean activate)
+gimp_unit_entry_set_mode (GimpUnitEntry *entry,
+ GimpUnitEntryMode mode)
{
- entry->resMode = TRUE;
+ entry->mode = mode;
}
diff --git a/libgimpwidgets/gimpunitentry.h b/libgimpwidgets/gimpunitentry.h
index 937f293..62968de 100644
--- a/libgimpwidgets/gimpunitentry.h
+++ b/libgimpwidgets/gimpunitentry.h
@@ -41,6 +41,12 @@ G_BEGIN_DECLS
typedef struct _GimpUnitEntry GimpUnitEntry;
typedef struct _GimpUnitEntryClass GimpUnitEntryClass;
+typedef enum
+{
+ GIMP_UNIT_ENTRY_MODE_UNIT = 0,
+ GIMP_UNIT_ENTRY_MODE_RESOLUTION
+} GimpUnitEntryMode;
+
struct _GimpUnitEntry
{
GtkSpinButton parent_instance;
@@ -50,11 +56,12 @@ struct _GimpUnitEntry
/* flag set TRUE when entry's text should not be overwritten
(i.e. during user input) */
- gboolean dontUpdateText;
+ gboolean dontUpdateText;
- /* set TRUE when the entry shall be used for resolution input */
- gboolean resMode;
- const gchar *id; /* identifier string of unit entry (used by GimpUnitEntryTable) */
+ /* input mode */
+ GimpUnitEntryMode mode;
+ /* identifier string of unit entry (used by GimpUnitEntryTable) */
+ const gchar *id;
};
struct _GimpUnitEntryClass
@@ -62,9 +69,6 @@ struct _GimpUnitEntryClass
GtkSpinButtonClass parent_class;
};
-/**
- * prototypes
- **/
GType gimp_unit_entry_get_type (void);
GtkWidget *gimp_unit_entry_new (const gchar *id);
GimpUnitAdjustment *gimp_unit_entry_get_adjustment (GimpUnitEntry *entry);
@@ -80,7 +84,7 @@ gdouble gimp_unit_entry_get_value (GimpUnitEntry *entry);
gdouble gimp_unit_entry_get_value_in_unit (GimpUnitEntry *entry, GimpUnit unit);
GimpUnit gimp_unit_entry_get_unit (GimpUnitEntry *entry);
void gimp_unit_entry_set_bounds (GimpUnitEntry *entry, GimpUnit unit, gdouble upper, gdouble lower);
-void gimp_unit_entry_set_res_mode (GimpUnitEntry *entry, gboolean activate);
+void gimp_unit_entry_set_mode (GimpUnitEntry *entry, GimpUnitEntryMode mode);
G_END_DECLS
diff --git a/libgimpwidgets/gimpunitentrytable.c b/libgimpwidgets/gimpunitentrytable.c
index 4306ab4..02ee184 100644
--- a/libgimpwidgets/gimpunitentrytable.c
+++ b/libgimpwidgets/gimpunitentrytable.c
@@ -386,8 +386,8 @@ gimp_unit_entry_table_set_resolution (GimpUnitEntryTable *table, gdouble res)
/* sets resolution mode for all entries */
void
-gimp_unit_entry_table_set_res_mode (GimpUnitEntryTable *table,
- gboolean enable)
+gimp_unit_entry_table_set_mode (GimpUnitEntryTable *table,
+ GimpUnitEntryMode mode)
{
GimpUnitEntry *entry;
gint i, count = g_list_length (table->entries);
@@ -396,7 +396,7 @@ gimp_unit_entry_table_set_res_mode (GimpUnitEntryTable *table,
for (i = 0; i < count; i++)
{
entry = gimp_unit_entry_table_get_nth_entry (table, i);
- gimp_unit_entry_set_res_mode (entry, enable);
+ gimp_unit_entry_set_mode (entry, mode);
}
}
diff --git a/libgimpwidgets/gimpunitentrytable.h b/libgimpwidgets/gimpunitentrytable.h
index cde2d07..413fd52 100644
--- a/libgimpwidgets/gimpunitentrytable.h
+++ b/libgimpwidgets/gimpunitentrytable.h
@@ -98,11 +98,11 @@ void gimp_unit_entry_table_set_unit (GimpUnitEntryTable
GimpUnit unit);
void gimp_unit_entry_table_set_resolution (GimpUnitEntryTable *table,
gdouble res);
-void gimp_unit_entry_table_set_res_mode (GimpUnitEntryTable *table,
- gboolean enable);
+void gimp_unit_entry_table_set_mode (GimpUnitEntryTable *table,
+ GimpUnitEntryMode mode);
void gimp_unit_entry_table_set_activates_default (GimpUnitEntryTable *table,
gboolean setting);
-
+
void gimp_unit_entry_table_grab_focus (GimpUnitEntryTable *table);
G_END_DECLS
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index 1d112d6..4805d3b 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -383,7 +383,7 @@ EXPORTS
gimp_unit_entry_get_value_in_unit
gimp_unit_entry_new
gimp_unit_entry_set_bounds
- gimp_unit_entry_set_res_mode
+ gimp_unit_entry_set_mode
gimp_unit_entry_set_resolution
gimp_unit_entry_set_unit
gimp_unit_entry_set_value
@@ -402,7 +402,7 @@ EXPORTS
gimp_unit_entry_table_grab_focus
gimp_unit_entry_table_new
gimp_unit_entry_table_set_activates_default
- gimp_unit_entry_table_set_res_mode
+ gimp_unit_entry_table_set_mode
gimp_unit_entry_table_set_resolution
gimp_unit_entry_table_set_unit
gimp_unit_menu_get_pixel_digits
diff --git a/libgimpwidgets/test-unitentrygui.c b/libgimpwidgets/test-unitentrygui.c
index a16f85e..0f8aaa0 100644
--- a/libgimpwidgets/test-unitentrygui.c
+++ b/libgimpwidgets/test-unitentrygui.c
@@ -65,8 +65,8 @@ create_interface(void)
b = gimp_unit_entry_table_get_entry (entryTable, "yres");
gimp_unit_entry_set_value (a, 72);
gimp_unit_entry_set_value (b, 72);
- gimp_unit_entry_set_res_mode (a, TRUE);
- gimp_unit_entry_set_res_mode (b, TRUE);
+ gimp_unit_entry_set_mode (a, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
+ gimp_unit_entry_set_mode (b, GIMP_UNIT_ENTRY_MODE_RESOLUTION);
gtk_box_pack_end (GTK_BOX (vbox), entryTable->table, FALSE, TRUE, 5);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]