]> Pileus Git - ~andy/gtk/commitdiff
Add a comment about unused bits.
authorMatthias Clasen <mclasen@redhat.com>
Fri, 14 May 2004 13:37:07 +0000 (13:37 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 14 May 2004 13:37:07 +0000 (13:37 +0000)
2004-05-14  Matthias Clasen  <mclasen@redhat.com>

* gdk/gdktypes.h (GdkModifierType): Add a comment about unused
bits.

* gtk/gtkstock.c (real_add, gtk_stock_lookup): Use an unused
modifier bit to mark stock item which need to be freed
eventually.  (#140654, Michal Pasternak, Scott Tsai)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdktypes.h
gtk/gtkstock.c

index 7ccaf3175c162d3099a2daf28af614e4891071d3..34fe2cf02806c511a60bc03c880e7d0fdd1642d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-05-14  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/gdktypes.h (GdkModifierType): Add a comment about unused
+       bits.
+
+       * gtk/gtkstock.c (real_add, gtk_stock_lookup): Use an unused
+       modifier bit to mark stock item which need to be freed 
+       eventually.  (#140654, Michal Pasternak, Scott Tsai)
+
 2004-05-11  Robert Ögren  <gtk@roboros.com>
 
        * gdk/win32/gdkevents-win32.c (gdk_event_translate): Add missing
index 7ccaf3175c162d3099a2daf28af614e4891071d3..34fe2cf02806c511a60bc03c880e7d0fdd1642d2 100644 (file)
@@ -1,3 +1,12 @@
+2004-05-14  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/gdktypes.h (GdkModifierType): Add a comment about unused
+       bits.
+
+       * gtk/gtkstock.c (real_add, gtk_stock_lookup): Use an unused
+       modifier bit to mark stock item which need to be freed 
+       eventually.  (#140654, Michal Pasternak, Scott Tsai)
+
 2004-05-11  Robert Ögren  <gtk@roboros.com>
 
        * gdk/win32/gdkevents-win32.c (gdk_event_translate): Add missing
index 7ccaf3175c162d3099a2daf28af614e4891071d3..34fe2cf02806c511a60bc03c880e7d0fdd1642d2 100644 (file)
@@ -1,3 +1,12 @@
+2004-05-14  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/gdktypes.h (GdkModifierType): Add a comment about unused
+       bits.
+
+       * gtk/gtkstock.c (real_add, gtk_stock_lookup): Use an unused
+       modifier bit to mark stock item which need to be freed 
+       eventually.  (#140654, Michal Pasternak, Scott Tsai)
+
 2004-05-11  Robert Ögren  <gtk@roboros.com>
 
        * gdk/win32/gdkevents-win32.c (gdk_event_translate): Add missing
index 7ccaf3175c162d3099a2daf28af614e4891071d3..34fe2cf02806c511a60bc03c880e7d0fdd1642d2 100644 (file)
@@ -1,3 +1,12 @@
+2004-05-14  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/gdktypes.h (GdkModifierType): Add a comment about unused
+       bits.
+
+       * gtk/gtkstock.c (real_add, gtk_stock_lookup): Use an unused
+       modifier bit to mark stock item which need to be freed 
+       eventually.  (#140654, Michal Pasternak, Scott Tsai)
+
 2004-05-11  Robert Ögren  <gtk@roboros.com>
 
        * gdk/win32/gdkevents-win32.c (gdk_event_translate): Add missing
index c454cae80a6994fb217b1eefe6f8779dfe7d4338..d9fdcd6ec1da9251b5ae00cb85f4d02e5130a87d 100644 (file)
@@ -130,7 +130,9 @@ typedef enum
   GDK_BUTTON3_MASK  = 1 << 10,
   GDK_BUTTON4_MASK  = 1 << 11,
   GDK_BUTTON5_MASK  = 1 << 12,
-  /* The next few modifiers are used by XKB, so we skip to the end
+  /* The next few modifiers are used by XKB, so we skip to the end.
+   * Bits 16 - 28 are currently unused, but will eventually
+   * be used for "virtual modifiers". Bit 29 is used internally.
    */
   GDK_RELEASE_MASK  = 1 << 30,
   GDK_MODIFIER_MASK = GDK_RELEASE_MASK | 0x1fff
index 5aea0eabaa39aa81fe09f50290ed3dc6f2425a77..6bf445190ee0b98e636474e39cd8673165032f98 100644 (file)
 static GHashTable *stock_hash = NULL;
 static void init_stock_hash (void);
 
+/* We use an unused modifier bit to mark stock items which
+ * must be freed when they are removed from the hash table.
+ */
+#define NON_STATIC_MASK (1 << 29)
+
 static void
 real_add (const GtkStockItem *items,
           guint               n_items,
@@ -52,14 +57,25 @@ real_add (const GtkStockItem *items,
     {
       gpointer old_key, old_value;
       const GtkStockItem *item = &items[i];
+
+      if (item->modifier & NON_STATIC_MASK)
+       {
+         g_warning ("Bit 29 set in stock accelerator.\n");
+         copy = TRUE;
+       }
+
       if (copy)
-        item = gtk_stock_item_copy (item);
+       {
+         item = gtk_stock_item_copy (item);
+         ((GtkStockItem *)item)->modifier |= NON_STATIC_MASK;
+       }
 
       if (g_hash_table_lookup_extended (stock_hash, item->stock_id,
                                         &old_key, &old_value))
         {
           g_hash_table_remove (stock_hash, old_key);
-          gtk_stock_item_free (old_value);
+         if (((GtkStockItem *)old_value)->modifier & NON_STATIC_MASK)
+           gtk_stock_item_free (old_value);
         }
       
       g_hash_table_insert (stock_hash,
@@ -136,6 +152,7 @@ gtk_stock_lookup (const gchar  *stock_id,
   if (found)
     {
       *item = *found;
+      item->modifier &= ~NON_STATIC_MASK;
       if (item->label)
         item->label = dgettext (item->translation_domain, item->label);
     }