gtk+ r20686 - in trunk: . gtk



Author: mitch
Date: Thu Jun 26 09:06:48 2008
New Revision: 20686
URL: http://svn.gnome.org/viewvc/gtk+?rev=20686&view=rev

Log:
2008-06-26  Michael Natterer  <mitch imendio com>

	* gtk/gtktextutil.c (_gtk_text_util_append_special_char_menuitems):
	allocate the GtkTextUtilCallbackInfo structs with GSlice.



Modified:
   trunk/ChangeLog
   trunk/gtk/gtktextutil.c

Modified: trunk/gtk/gtktextutil.c
==============================================================================
--- trunk/gtk/gtktextutil.c	(original)
+++ trunk/gtk/gtktextutil.c	Thu Jun 26 09:06:48 2008
@@ -70,6 +70,26 @@
   { N_("ZWNJ Zero width _non-joiner"), 0x200C }
 };
 
+static GtkTextUtilCallbackInfo *
+callback_info_new (GtkTextUtilCharChosenFunc  func,
+                   gpointer                   data)
+{
+  GtkTextUtilCallbackInfo *info;
+
+  info = g_slice_new (GtkTextUtilCallbackInfo);
+
+  info->func = func;
+  info->data = data;
+
+  return info;
+}
+
+static void
+callback_info_free (GtkTextUtilCallbackInfo *info)
+{
+  g_slice_free (GtkTextUtilCallbackInfo, info);
+}
+
 static void
 activate_cb (GtkWidget *menu_item,
              gpointer   data)
@@ -106,25 +126,22 @@
                                               gpointer                   data)
 {
   int i;
-  
+
   for (i = 0; i < G_N_ELEMENTS (bidi_menu_entries); i++)
     {
       GtkWidget *menuitem;
       GtkTextUtilCallbackInfo *info;
 
-      /* wasteful to have a bunch of copies, but simplifies mem management */
-      info = g_new (GtkTextUtilCallbackInfo, 1);
-      info->func = func;
-      info->data = data;
-      
+      info = callback_info_new (func, data);
+
       menuitem = gtk_menu_item_new_with_mnemonic (_(bidi_menu_entries[i].label));
       g_object_set_data (G_OBJECT (menuitem), I_("gtk-unicode-menu-entry"),
                          (gpointer)&bidi_menu_entries[i]);
-      
+
       g_signal_connect_data (menuitem, "activate",
                              G_CALLBACK (activate_cb),
-                             info, (GClosureNotify) g_free, 0);
-      
+                             info, (GClosureNotify) callback_info_free, 0);
+
       gtk_widget_show (menuitem);
       gtk_menu_shell_append (menushell, menuitem);
     }



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