Index: gtk/gtk.symbols
===================================================================
--- gtk/gtk.symbols	(revisão 18004)
+++ gtk/gtk.symbols	(cópia de trabalho)
@@ -4415,6 +4415,8 @@
 #if IN_HEADER(__GTK_TYPE_UTILS_H__)
 #if IN_FILE(__GTK_TYPE_UTILS_C__)
 gtk_type_class
+gtk_type_register
+gtk_registered_type_from_name
 gtk_identifier_get_type G_GNUC_CONST
 #ifndef GTK_DISABLE_DEPRECATED
 gtk_type_enum_find_value
Index: gtk/gtkmain.c
===================================================================
--- gtk/gtkmain.c	(revisão 18004)
+++ gtk/gtkmain.c	(cópia de trabalho)
@@ -658,6 +658,7 @@ do_post_parse_initialization (int    *ar
   }
 
   gtk_type_init (0);
+  _gtk_type_table_init ();
   _gtk_accel_map_init ();  
   _gtk_rc_init ();
 
Index: gtk/gtktypeutils.c
===================================================================
--- gtk/gtktypeutils.c	(revisão 18004)
+++ gtk/gtktypeutils.c	(cópia de trabalho)
@@ -28,6 +28,8 @@
 
 #include <config.h>
 #include <string.h> /* strcmp */
+#include <ctype.h> /* toupper */
+#include <stdlib.h> /* strtol, strtoul */
 
 #include "gtktypeutils.h"
 #include "gtkobject.h"
@@ -199,6 +200,211 @@ gtk_type_flags_find_value (GtkType      
   return value;
 }
 
+gint
+_gtk_enum_from_string (GType type, const char *string)
+{
+  GEnumClass *eclass;
+  GEnumValue *ev;
+  gchar *endptr;
+  gint ret = 0;
+
+  ret = strtoul (string, &endptr, 0);
+  if (endptr != string) /* parsed a number */
+    return ret;
+
+  eclass = g_type_class_ref (type);
+  ev = g_enum_get_value_by_name (eclass, string);
+  if (!ev)
+    ev = g_enum_get_value_by_nick (eclass, string);
+
+  if (ev)
+    ret = ev->value;
+
+  g_type_class_unref (eclass);
+
+  return ret;
+}
+
+guint
+_gtk_flags_from_string (GType type, const char *string)
+{
+  GFlagsClass *fclass;
+  gchar *endptr, *prevptr;
+  guint i, j, ret;
+  char *flagstr;
+  GFlagsValue *fv;
+  const char  *flag;
+  gunichar ch;
+  gboolean eos;
+
+  ret = strtoul (string, &endptr, 0);
+  if (endptr != string) /* parsed a number */
+    return ret;
+
+  fclass = g_type_class_ref (type);
+
+  flagstr = g_strdup (string);
+  for (ret = i = j = 0; ; i++)
+    {
+
+      eos = flagstr[i] == '\0';
+
+      if (!eos && flagstr[i] != '|')
+        continue;
+
+      flag = &flagstr[j];
+      endptr = &flagstr[i];
+
+      if (!eos)
+        {
+          flagstr[i++] = '\0';
+          j = i;
+        }
+
+      /* trim spaces */
+      for (;;)
+        {
+          ch = g_utf8_get_char (flag);
+          if (!g_unichar_isspace (ch))
+            break;
+          flag = g_utf8_next_char (flag);
+        }
+
+      while (endptr > flag)
+        {
+          prevptr = g_utf8_prev_char (endptr);
+          ch = g_utf8_get_char (prevptr);
+          if (!g_unichar_isspace (ch))
+            break;
+          endptr = prevptr;
+        }
+
+      if (endptr > flag)
+        {
+          *endptr = '\0';
+          fv = g_flags_get_value_by_name (fclass, flag);
+
+          if (!fv)
+            fv = g_flags_get_value_by_nick (fclass, flag);
+
+          if (fv)
+            ret |= fv->value;
+          else
+            g_warning ("Unknown flag: '%s'", flag);
+        }
+
+      if (eos)
+        break;
+    }
+
+  g_free (flagstr);
+
+  g_type_class_unref (fclass);
+
+  return ret;
+}
+
+static GHashTable* type_table;
+
+/*
+ * Try to map a type name to a _get_type function
+ * and call it, eg:
+ *
+ * GtkWindow -> gtk_window_get_type
+ * GtkHBox -> gtk_hbox_get_type
+ *
+ */
+static GType
+_gtk_resolve_type_lazily (const gchar *name)
+{
+  static GModule *module = NULL;
+  GTypeGetFunc func;
+  GString *symbol_name = g_string_new ("");
+  char c, *symbol;
+  int i;
+  GType gtype = G_TYPE_INVALID;
+
+  if (!module)
+    module = g_module_open (NULL, 0);
+  
+  for (i = 0; name[i] != '\0'; i++) {
+    c = name[i];
+    /* skip if uppercase, first or previous is uppercase */
+    if (c == toupper (c) &&
+	i > 0 && name[i-1] != toupper (name[i-1])) {
+      g_string_append_c (symbol_name, '_');
+    } 
+    g_string_append_c (symbol_name, tolower (c));
+  }
+  g_string_append (symbol_name, "_get_type");
+  
+  symbol = g_string_free (symbol_name, FALSE);
+  
+  if (g_module_symbol (module, symbol, (gpointer)&func))
+    gtype = func ();
+  
+  g_free (symbol);
+
+  return gtype;
+}
+
+/**
+ * gtk_registered_type_from_name
+ * @name: a type name
+ *
+ * Like g_type_from_name, but takes into account the types registered
+ * using the gtk_type_register function.
+ *
+ * Since: 2.12
+ */
+GType
+gtk_registered_type_from_name (const gchar *name)
+{
+  GType gtype;
+  GTypeGetFunc func;
+  
+  gtype = g_type_from_name (name);
+  if (gtype != G_TYPE_INVALID)
+    return gtype;
+
+  func = g_hash_table_lookup (type_table, name);
+  if (func)
+    gtype = func ();
+  if (gtype != G_TYPE_INVALID)
+    return gtype;
+
+  return _gtk_resolve_type_lazily (name);
+}
+
+/**
+ * gtk_type_register
+ * @name: a type name
+ * @func: a #GTypeGetFunc
+ *
+ * Registers a type registration function for a type name.
+ * This is used by GtkBuilder to be able to register a type on demand.
+ *
+ * You can call this in a your library to map a type name to a function
+ * which will register a GType, it's useful for libraries defining
+ * #GtkBuildable types.
+ *
+ * Since: 2.12
+ */
+void
+gtk_type_register (const gchar *name, GTypeGetFunc func)
+{
+  g_return_if_fail (g_hash_table_lookup (type_table, name) == NULL);
+
+  g_hash_table_insert (type_table, g_strdup (name), func);
+}
+
+void
+_gtk_type_table_init (void)
+{
+  type_table = g_hash_table_new (g_str_hash, g_str_equal);
+
+  g_hash_table_insert (type_table, "GtkUIManager", gtk_ui_manager_get_type);
+}
 
 #define __GTK_TYPE_UTILS_C__
 #include "gtkaliasdef.c"
Index: gtk/gtktypeutils.h
===================================================================
--- gtk/gtktypeutils.h	(revisão 18004)
+++ gtk/gtktypeutils.h	(cópia de trabalho)
@@ -229,8 +229,19 @@
 
 #endif /* GTK_DISABLE_DEPRECATED */
 
+typedef GType (*GTypeGetFunc) (void);
+
 gpointer	gtk_type_class	(GtkType	 type);
 
+void            _gtk_type_table_init     (void);
+guint           _gtk_flags_from_string   (GType         type,
+					  const char   *string);
+gint            _gtk_enum_from_string    (GType         type,
+					  const char   *string);
+void            gtk_type_register        (const gchar  *name,
+                                          GTypeGetFunc  func);
+GType           gtk_registered_type_from_name (const gchar  *name);
+
 #ifndef GTK_DISABLE_DEPRECATED
 
 GtkType		gtk_type_unique	(GtkType	   parent_type,

Mudanças de propriedades em: tests
___________________________________________________________________
Nome: svn:ignore
   - Makefile
Makefile.in
makefile.mingw
makefile.msc
.deps
.libs
autotestfilechooser
pixbuf-lowmem
pixbuf-random
pixbuf-random-image
pixbuf-random-seed
pixbuf-randomly-modified
pixbuf-read
pixbuf-threads
simple
stresstest-toolbar
floatingtest
testactions
testaccel
testassistant
testbbox
testcairo
testcalendar
testcellrenderertext
testcombo
testcombochange
testdnd
testellipsise
testentrycompletion
testfilechooser
testfilechooserbutton
testgrouping
testgtk
testicontheme
testiconview
testimage
testinput
testmenubars
testmenus
testmerge
testmultidisplay
testmultiscreen
testnotebookdnd
testnouiprint
testprint
testrecentchooser
testrecentchoosermenu
testrgb
testrichtext
testselection
testsocket
testsocket_child
testspinbutton
teststatusicon
testtext
testtextbuffer
testtoolbar
testtooltips
testtreecolumns
testtreeedit
testtreeflow
testtreefocus
testtreemodel
testtreesort
testtreeview
testvolumebutton
testxinerama
treestoretest
print-editor

   + Makefile
Makefile.in
makefile.mingw
makefile.msc
.deps
.libs
autotestfilechooser
pixbuf-lowmem
pixbuf-random
pixbuf-random-image
pixbuf-random-seed
pixbuf-randomly-modified
pixbuf-read
pixbuf-threads
simple
stresstest-toolbar
floatingtest
typeutilstest
testactions
testaccel
testassistant
testbbox
testcairo
testcalendar
testcellrenderertext
testcombo
testcombochange
testdnd
testellipsise
testentrycompletion
testfilechooser
testfilechooserbutton
testgrouping
testgtk
testicontheme
testiconview
testimage
testinput
testmenubars
testmenus
testmerge
testmultidisplay
testmultiscreen
testnotebookdnd
testnouiprint
testprint
testrecentchooser
testrecentchoosermenu
testrgb
testrichtext
testselection
testsocket
testsocket_child
testspinbutton
teststatusicon
testtext
testtextbuffer
testtoolbar
testtooltips
testtreecolumns
testtreeedit
testtreeflow
testtreefocus
testtreemodel
testtreesort
testtreeview
testvolumebutton
testxinerama
treestoretest
print-editor


Index: tests/typeutilstest.c
===================================================================
--- tests/typeutilstest.c	(revisão 0)
+++ tests/typeutilstest.c	(revisão 0)
@@ -0,0 +1,65 @@
+/* example-start calendar calendar.c */
+/*
+ * Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund
+ * Copyright (C) 2000 Tony Gale
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <string.h>
+#include <gtk/gtk.h>
+
+int main(int   argc,
+         char *argv[])
+{
+  int i;
+  char *names[] = {
+    "GdkPixbuf", "GtkAboutDialog", "GtkAccelLabel", "GtkAction",
+    "GtkActionGroup", "GtkAdjustment", "GtkAlignment", "GtkArrow",
+    "GtkAspectFrame", "GtkAssistant", "GtkButton", "GtkCalendar",
+    "GtkCheckButton", "GtkCellRenderer", "GtkCellRendererText", "GtkCellView",
+    "GtkColorButton", "GtkColorSelection", "GtkColorSelectionDialog",
+    "GtkComboBox", "GtkComboBoxEntry", "GtkCurve", "GtkDialog",
+    "GtkDrawingArea", "GtkEventBox", "GtkEntry", "GtkEntryCompletion",
+    "GtkFileChooser", "GtkFileChooserDialog", "GtkFileChooserButton",
+    "GtkFileSelection", "GtkFixed", "GtkFontSelection",
+    "GtkFontSelectionDialog", "GtkFrame", "GtkExpander", "GtkFontButton",
+    "GtkGammaCurve", "GtkHandleBox", "GtkHButtonBox", "GtkHBox", "GtkHPaned",
+    "GtkHRuler", "GtkHScale", "GtkHScrollbar", "GtkHSeparator", "GtkIconView",
+    "GtkImage", "GtkInputDialog", "GtkLabel", "GtkLayout", "GtkLinkButton",
+    "GtkListStore", "GtkMenu", "GtkMenuBar", "GtkMessageDialog", "GtkNotebook",
+    "GtkProgressBar", "GtkRadioAction", "GtkRadioButton",
+    "GtkRecentChooserDialog", "GtkSizeGroup", "GtkScrolledWindow",
+    "GtkSpinButton", "GtkStatusbar", "GtkTextBuffer", "GtkTextView",
+    "GtkToggleAction", "GtkToggleButton", "GtkToolbar", "GtkTooltips",
+    "GtkTreeModelFilter", "GtkTreeModelSort", "GtkTreeStore", "GtkTreeView",
+    "GtkTreeViewColumn", "GtkTable", "GtkVBox", "GtkVButtonBox",
+    "GtkVScrollbar", "GtkVSeparator", "GtkViewport", "GtkVRuler", "GtkVPaned",
+    "GtkVScale", "GtkWindow", "GtkUIManager", NULL };
+
+  gtk_init (&argc, &argv);
+
+  for (i = 0; i < g_strv_length (names); i++) {
+    GType type = gtk_registered_type_from_name (names[i]);
+    g_assert (type != G_TYPE_INVALID);
+
+    if (strcmp (g_type_name (type), names[i]) != 0) {
+      g_print("%s != %s\n", g_type_name (type), names[i]);
+      return 1;
+    }
+  }
+ 
+  return(0);
+}
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revisão 18004)
+++ tests/Makefile.am	(cópia de trabalho)
@@ -24,11 +24,12 @@
 testsocket_programs = testsocket testsocket_child
 endif
 
-TESTS = floatingtest
+TESTS = floatingtest typeutilstest
 
 noinst_PROGRAMS =			\
 	autotestfilechooser		\
 	floatingtest			\
+	typeutilstest			\
 	simple				\
 	print-editor			\
 	testaccel			\
@@ -91,6 +92,7 @@
 autotestfilechooser_DEPENDENCIES = $(TEST_DEPS)
 simple_DEPENDENCIES = $(TEST_DEPS)
 floatingtest_DEPENDENCIES = $(TEST_DEPS)
+typeutilstest_DEPENDENCIES = $(TEST_DEPS)
 print_editor_DEPENDENCIES = $(TEST_DEPS)
 testicontheme_DEPENDENCIES = $(TEST_DEPS)
 testiconview_DEPENDENCIES = $(TEST_DEPS)
@@ -146,6 +148,7 @@
 autotestfilechooser_LDADD = $(LDADDS)
 simple_LDADD = $(LDADDS)
 floatingtest_LDADD = $(LDADDS)
+typeutilstest_LDADD = $(LDADDS)
 print_editor_LDADD = $(LDADDS)
 testaccel_LDADD = $(LDADDS)
 testassistant_LDADD = $(LDADDS)
