[pygtk/gtk-3.0: 9/55] Override: Fix GtkTagTable, GtkTag. Is this still correct wrt anonymous tags?



commit 1aeaecadf3e608a32bcdceabf997544d87b9586d
Author: John Stowers <john stowers gmail com>
Date:   Mon Jul 5 13:11:51 2010 +1200

    Override: Fix GtkTagTable, GtkTag. Is this still correct wrt anonymous tags?

 gtk/gtktextview.override |   52 +++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtktextview.override b/gtk/gtktextview.override
index aa002ed..9ee0327 100644
--- a/gtk/gtktextview.override
+++ b/gtk/gtktextview.override
@@ -595,7 +595,7 @@ _wrap_gtk_text_buffer_create_tag(PyGObject *self, PyObject *args, PyObject *kwar
     }
 
     table = gtk_text_buffer_get_tag_table(GTK_TEXT_BUFFER(self->obj));
-    if (tag_name && table && g_hash_table_lookup(table->hash, tag_name)) {
+    if (tag_name && table && gtk_text_tag_table_lookup(table, tag_name)) {
         gchar buf[512];
         g_snprintf(buf, sizeof(buf),
                    "A tag named '%s' is already in the tag table",
@@ -960,6 +960,7 @@ _wrap_gtk_text_tag_table_add(PyGObject *self, PyObject *args, PyObject *kwargs)
     static char *kwlist[] = { "tag", NULL };
     GtkTextTag *tag;
     GtkTextTagTable *table;
+    gchar *name;
     PyGObject *pytag;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextTagTable.add",
@@ -969,22 +970,18 @@ _wrap_gtk_text_tag_table_add(PyGObject *self, PyObject *args, PyObject *kwargs)
 
     tag = GTK_TEXT_TAG(pytag->obj);
     table = GTK_TEXT_TAG_TABLE(self->obj);
+    g_object_get(G_OBJECT(tag), "name", &name, NULL);
 
-    if (tag->table) {
+    if (gtk_text_tag_table_lookup(table, name)) {
         gchar buf[512];
-        g_snprintf(buf, sizeof(buf),
-                   "The tag is already in a tag table");
-
-        PyErr_SetString(PyExc_ValueError, buf);
-        return NULL;
-    }
-
-    if (tag->name && table && g_hash_table_lookup(table->hash, tag->name)) {
-        gchar buf[512];
-        g_snprintf(buf, sizeof(buf),
-                   "A tag named '%s' is already in the tag table",
-                   tag->name);
-
+        if (name) {
+            g_snprintf(buf, sizeof(buf),
+                       "A tag named '%s' is already in the tag table",
+                       name);
+        } else {
+            g_snprintf(buf, sizeof(buf),
+                       "The tag is already in a tag table");
+        }
         PyErr_SetString(PyExc_ValueError, buf);
         return NULL;
     }
@@ -1003,6 +1000,7 @@ _wrap_gtk_text_tag_table_remove(PyGObject *self, PyObject *args,
     static char *kwlist[] = { "tag", NULL };
     GtkTextTag *tag;
     GtkTextTagTable *table;
+    gchar *name;
     PyGObject *pytag;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
@@ -1014,18 +1012,20 @@ _wrap_gtk_text_tag_table_remove(PyGObject *self, PyObject *args,
     tag = GTK_TEXT_TAG(pytag->obj);
     table = GTK_TEXT_TAG_TABLE(self->obj);
 
-    if (tag->table != table) {
-        gchar buf[512];
-	if (tag->name)
-	    g_snprintf(buf, sizeof(buf),
-		       "The tag named '%s' is not in the tag table",
-		       tag->name);
-	else
-	    g_snprintf(buf, sizeof(buf),
-		       "The tag is not in the tag table");
+    g_object_get(G_OBJECT(tag), "name", &name, NULL);
 
-        PyErr_SetString(PyExc_ValueError, buf);
-        return NULL;
+    /* check if the tag is in the table */
+    if (!gtk_text_tag_table_lookup(table, name)) {
+        gchar buf[512];
+	    if (name)
+	        g_snprintf(buf, sizeof(buf),
+		           "The tag named '%s' is not in the tag table", name);
+	    else
+	        g_snprintf(buf, sizeof(buf),
+		           "The tag is not in the tag table");
+
+            PyErr_SetString(PyExc_ValueError, buf);
+            return NULL;
     }
 
     gtk_text_tag_table_remove(table, tag);



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