pygobject r817 - in trunk: . gio gobject



Author: johan
Date: Thu Jul 17 09:51:19 2008
New Revision: 817
URL: http://svn.gnome.org/viewvc/pygobject?rev=817&view=rev

Log:
2008-07-17  Johan Dahlin  <johan gnome org>

        * gio/giomodule.c (init_gio):
        Use the prefix G_IO_ for stripping constants instead of just G_
        * gobject/gobjectmodule.c (pyg_constant_strip_prefix):
        Check so the fist part of name and strip_prefix are the same,
        if they don't, just strip of the part of strip_prefix which
        matches.

        This removes the initial IO_* prefix for some constants in gio.
        Eg, gio.IO_ERROR_* -> gio.ERROR_*



Modified:
   trunk/ChangeLog
   trunk/gio/giomodule.c
   trunk/gobject/gobjectmodule.c

Modified: trunk/gio/giomodule.c
==============================================================================
--- trunk/gio/giomodule.c	(original)
+++ trunk/gio/giomodule.c	Thu Jul 17 09:51:19 2008
@@ -47,7 +47,7 @@
     init_pygobject();
 
     pygio_register_classes(d);
-    pygio_add_constants(m, "G_");
+    pygio_add_constants(m, "G_IO_");
 
 }
 

Modified: trunk/gobject/gobjectmodule.c
==============================================================================
--- trunk/gobject/gobjectmodule.c	(original)
+++ trunk/gobject/gobjectmodule.c	Thu Jul 17 09:51:19 2008
@@ -2964,15 +2964,24 @@
 pyg_constant_strip_prefix(const gchar *name, const gchar *strip_prefix)
 {
     gint prefix_len;
-    guint j;
+    guint i;
     
     prefix_len = strlen(strip_prefix);
-    
+
+    /* Check so name starts with strip_prefix, if it doesn't:
+     * return the rest of the part which doesn't match
+     */
+    for (i = 0; i < prefix_len; i++) {
+	if (name[i] != strip_prefix[i] && name[i] != '_') {
+	    return &name[i];
+	}
+    }
+
     /* strip off prefix from value name, while keeping it a valid
      * identifier */
-    for (j = prefix_len; j >= 0; j--) {
-	if (g_ascii_isalpha(name[j]) || name[j] == '_') {
-	    return &name[j];
+    for (i = prefix_len; i >= 0; i--) {
+	if (g_ascii_isalpha(name[i]) || name[i] == '_') {
+	    return &name[i];
 	}
     }
     return name;



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