[tracker/harmattan: 1896/2240] src/plugins/nautilus: Fixed crasher when right clicking on background



commit 8b18a1f19eb512f69a73840a7f9fa774e60f72c0
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Dec 21 09:52:03 2009 +0000

    src/plugins/nautilus: Fixed crasher when right clicking on background
    
    This was spotted by Debarshi Ray.
    
    There is no action for the background now, unless we decide to tag the
    background at some point, this won't be enabled (for now disabled).
    
    If this code is enabled it won't crash, however, we can only list
    tags, we have no file to apply them to.

 src/plugins/nautilus/tracker-tags-extension.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/nautilus/tracker-tags-extension.c b/src/plugins/nautilus/tracker-tags-extension.c
index 0036fd8..c070875 100644
--- a/src/plugins/nautilus/tracker-tags-extension.c
+++ b/src/plugins/nautilus/tracker-tags-extension.c
@@ -60,7 +60,7 @@ typedef void (*MenuDataFreeFunc)(gpointer data);
 
 typedef struct {
 	gpointer data;
-	gboolean free_data;
+	gboolean data_is_files;
 	GtkWidget *widget;
 } MenuData;
 
@@ -77,7 +77,7 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (TrackerTagsExtension, tracker_tags_extension, G_
 
 static MenuData *
 menu_data_new (gpointer   data,
-               gboolean   free_data,
+               gboolean   data_is_files,
                GtkWidget *window)
 {
 	MenuData *md;
@@ -85,7 +85,7 @@ menu_data_new (gpointer   data,
 	md = g_slice_new (MenuData);
 
 	md->data = data;
-	md->free_data = free_data;
+	md->data_is_files = data_is_files;
 	md->widget = window;
 
 	return md;
@@ -94,7 +94,7 @@ menu_data_new (gpointer   data,
 static void
 menu_data_free (MenuData *md)
 {
-	if (md->free_data) {
+	if (md->data_is_files) {
 		g_list_foreach (md->data, (GFunc) g_object_unref, NULL);
 		g_list_free (md->data);
 	}
@@ -142,7 +142,13 @@ menu_tags_activate_cb (NautilusMenuItem *menu_item,
 	vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 	gtk_box_set_spacing (GTK_BOX (vbox), 2);
 
-	view = tracker_tags_view_new (files);
+	/* For the background we have no files */
+	if (md->data_is_files) {
+		view = tracker_tags_view_new (files);
+	} else {
+		view = tracker_tags_view_new (NULL);
+	}
+
 	gtk_box_pack_start (GTK_BOX (vbox), view, TRUE, TRUE, 0);
 
 	gtk_widget_show_all (dialog);
@@ -195,7 +201,7 @@ extension_get_file_items (NautilusMenuProvider *provider,
 
 	g_signal_connect_data (menu_item, "activate", 
 	                       G_CALLBACK (menu_tags_activate_cb), 
-	                       menu_data_new (tracker_glist_copy_with_nautilus_files (files), FALSE, window),
+	                       menu_data_new (tracker_glist_copy_with_nautilus_files (files), TRUE, window),
 	                       menu_data_destroy,
 	                       G_CONNECT_AFTER);
 
@@ -235,8 +241,11 @@ static void
 tracker_tags_extension_menu_provider_iface_init (NautilusMenuProviderIface *iface)
 {
         iface->get_file_items = extension_get_file_items;
-        iface->get_background_items = extension_get_background_items;
         iface->get_toolbar_items = extension_get_toolbar_items;
+
+        if (0) {
+        iface->get_background_items = extension_get_background_items;
+        }
 }
 
 static void



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