[gimp/soc-2011-gimpunitentry: 31/68] GimpUnitEntryTable: add activates_default() function



commit ef7303605b6baa4aa1dba7d49d314dd1cfaac1b9
Author: Enrico Schröder <enni schroeder gmail com>
Date:   Fri Jul 1 15:02:46 2011 +0200

    GimpUnitEntryTable: add activates_default() function
    
    - adds activates_default function which calls gtk_entry_activates_default for all entries
    - makes new image dialog use this function, which restores behavior as it was before and should make the 
unit-tests pass again.

 app/dialogs/image-new-dialog.c      |   15 +++++++--------
 libgimpwidgets/gimpunitentrytable.c |   16 ++++++++++++++++
 libgimpwidgets/gimpunitentrytable.h |    2 ++
 libgimpwidgets/gimpwidgets.def      |    1 +
 4 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c
index 29c5926..aecfe82 100644
--- a/app/dialogs/image-new-dialog.c
+++ b/app/dialogs/image-new-dialog.c
@@ -80,11 +80,10 @@ static void   image_new_create_image     (ImageNewDialog *dialog);
 GtkWidget *
 image_new_dialog_new (GimpContext *context)
 {
-  ImageNewDialog *dialog;
-  GtkWidget      *main_vbox;
-  GtkWidget      *hbox;
-  GtkWidget      *label;
-  GimpSizeEntry  *entry;
+  ImageNewDialog      *dialog;
+  GtkWidget           *main_vbox;
+  GtkWidget           *table;
+  GimpUnitEntryTable  *UETable;
 
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
@@ -159,9 +158,9 @@ image_new_dialog_new (GimpContext *context)
   gtk_box_pack_start (GTK_BOX (main_vbox), dialog->editor, FALSE, FALSE, 0);
   gtk_widget_show (dialog->editor);
 
-  /*entry = GIMP_SIZE_ENTRY (gimp_template_editor_get_size_se (GIMP_TEMPLATE_EDITOR (dialog->editor)));
-  gimp_size_entry_set_activates_default (entry, TRUE);
-  gimp_size_entry_grab_focus (entry);*/
+  UETable = GIMP_UNIT_ENTRY_TABLE (gimp_template_editor_get_size_se (GIMP_TEMPLATE_EDITOR (dialog->editor)));
+  gimp_unit_entry_table_set_activates_default (UETable, TRUE);
+  gtk_widget_grab_focus (GTK_WIDGET (gimp_unit_entry_table_get_nth_entry (UETable, 0)));
 
   image_new_template_changed (dialog->context,
                               gimp_context_get_template (dialog->context),
diff --git a/libgimpwidgets/gimpunitentrytable.c b/libgimpwidgets/gimpunitentrytable.c
index 26d53c9..92e97e1 100644
--- a/libgimpwidgets/gimpunitentrytable.c
+++ b/libgimpwidgets/gimpunitentrytable.c
@@ -354,3 +354,19 @@ gimp_unit_entry_table_set_res_mode (GimpUnitEntryTable *table,
     gimp_unit_entry_set_res_mode (entry, enable);
   }
 }
+
+/* calls gtk_entry_set_activates_default for all UnitEntries */
+void 
+gimp_unit_entry_table_set_activates_default (GimpUnitEntryTable *table, 
+                                             gboolean setting)
+{
+  GimpUnitEntry *entry;
+  gint i, count = g_list_length (table->entries);
+
+  /* iterate over list of entries */
+  for (i = 0; i < count; i++) 
+  {
+    entry = gimp_unit_entry_table_get_nth_entry (table, i);
+    gtk_entry_set_activates_default (GTK_ENTRY (entry), setting);
+  }
+}
diff --git a/libgimpwidgets/gimpunitentrytable.h b/libgimpwidgets/gimpunitentrytable.h
index f055475..913b4b1 100644
--- a/libgimpwidgets/gimpunitentrytable.h
+++ b/libgimpwidgets/gimpunitentrytable.h
@@ -87,6 +87,8 @@ void gimp_unit_entry_table_set_unit (GimpUnitEntryTable *table, GimpUnit unit);
 void 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);
+/* calls gtk_entry_set_activates_default for all UnitEntries */
+void gimp_unit_entry_table_set_activates_default (GimpUnitEntryTable *table, gboolean setting);
 G_END_DECLS
 
 #endif /*__GIMP_UNIT_ENTRY_TABLE_H__*/
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index 831592f..d8f9f4d 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -399,6 +399,7 @@ EXPORTS
        gimp_unit_entry_table_get_nth_entry
        gimp_unit_entry_table_get_type
        gimp_unit_entry_table_new
+       gimp_unit_entry_table_set_activates_default
        gimp_unit_entry_table_set_resolution
        gimp_unit_entry_table_set_res_mode
        gimp_unit_entry_table_set_unit


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