gnome-main-menu r514 - trunk/libslab



Author: federico
Date: Tue Oct 28 01:26:11 2008
New Revision: 514
URL: http://svn.gnome.org/viewvc/gnome-main-menu?rev=514&view=rev

Log:
Don't leak menus attached to tiles

Signed-off-by: Federico Mena Quintero <federico novell com>

Modified:
   trunk/libslab/ChangeLog
   trunk/libslab/tile.c

Modified: trunk/libslab/tile.c
==============================================================================
--- trunk/libslab/tile.c	(original)
+++ trunk/libslab/tile.c	Tue Oct 28 01:26:11 2008
@@ -209,7 +209,7 @@
 	if (tile->uri)
 		g_free (tile->uri);
 	if (tile->context_menu)
-		gtk_object_sink (GTK_OBJECT (tile->context_menu));
+		gtk_widget_destroy (GTK_WIDGET (tile->context_menu));
 
 	g_object_unref (priv->double_click_detector);
 
@@ -240,17 +240,34 @@
 static void
 tile_set_property (GObject * g_obj, guint prop_id, const GValue * value, GParamSpec * param_spec)
 {
+	Tile *tile;
+	GtkMenu *menu;
+
 	if (!IS_TILE (g_obj))
 		return;
 
+	tile = TILE (g_obj);
+
 	switch (prop_id)
 	{
 	case PROP_TILE_URI:
-		TILE (g_obj)->uri = g_strdup (g_value_get_string (value));
+		tile->uri = g_strdup (g_value_get_string (value));
 		break;
 
 	case PROP_TILE_CONTEXT_MENU:
-		TILE (g_obj)->context_menu = g_value_get_object (value);
+		menu = g_value_get_object (value);
+
+		if (menu == tile->context_menu)
+			break;
+
+		if (tile->context_menu)
+			gtk_menu_detach (tile->context_menu);
+
+		tile->context_menu = menu;
+
+		if (tile->context_menu)
+			gtk_menu_attach_to_widget (tile->context_menu, GTK_WIDGET (tile), NULL);
+
 		break;
 
 	default:



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