[PATCH] Proper Launcher Editing



The fact that Nautilus wasn't smart about modifying or creating
launchers always heavily bugged me. Therefore I've put up a nifty patch
that seems to resolve some bugzilla entries :).
It allows the user to create launchers whereever he wants (provided that
this directory allows it) and edit existing ones.
Feedback welcome!

regs,
 Chris
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.618
diff -u -r1.618 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	30 Mar 2004 22:54:53 -0000	1.618
+++ src/file-manager/fm-directory-view.c	1 Apr 2004 21:13:50 -0000
@@ -1191,29 +1191,27 @@
 }
 
 static gboolean
-we_are_in_vfolder_desktop_dir (FMDirectoryView *view)
+selection_is_launcher (GList *selection)
 {
 	NautilusFile *file;
 	char *mime_type;
+	gboolean retval;
 
-	g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE);
+	g_return_val_if_fail (eel_g_list_exactly_one_item (selection), FALSE);
 
-	if (view->details->model == NULL) {
-		return FALSE;
-	}
-
-	file = nautilus_directory_get_corresponding_file (view->details->model);
+	file = NAUTILUS_FILE (selection->data);
 	mime_type = nautilus_file_get_mime_type (file);
-	nautilus_file_unref (file);
 
-	if (mime_type != NULL
-	    && strcmp (mime_type, "x-directory/vfolder-desktop") == 0) {
-		g_free (mime_type);
-		return TRUE;
-	} else {
-		g_free (mime_type);
-		return FALSE;
-	}
+	if (mime_type != NULL &&
+	    ((strcmp (mime_type, "application/x-desktop") == 0) ||
+	     (strcmp (mime_type, "application/x-gnome-app-info") == 0)))
+	  retval = TRUE;
+	else
+	  retval = FALSE;
+
+	g_free (mime_type);
+
+	return retval;
 }
 
 static void
@@ -5462,7 +5460,6 @@
 	gboolean can_link_files;
 	gboolean can_duplicate_files;
 	gboolean show_separate_delete_command;
-	gboolean vfolder_directory;
 	gboolean show_open_alternate;
 	EelBackground *background;
 
@@ -5486,8 +5483,6 @@
 	can_duplicate_files = can_create_files && can_copy_files;
 	can_link_files = can_create_files && can_copy_files;
 	
-	vfolder_directory = we_are_in_vfolder_desktop_dir (view);
-
 	bonobo_ui_component_freeze (view->details->ui, NULL);
 
 	nautilus_bonobo_set_sensitive (view->details->ui, 
@@ -5638,22 +5633,12 @@
 	real_update_paste_menu (view, selection, selection_count);
 
 	nautilus_bonobo_set_hidden (view->details->ui, 
-				    FM_DIRECTORY_VIEW_COMMAND_NEW_LAUNCHER,
-				    ! vfolder_directory);
-
-	nautilus_bonobo_set_hidden (view->details->ui, 
 				    FM_DIRECTORY_VIEW_COMMAND_EDIT_LAUNCHER,
-				    ! vfolder_directory);
+				    selection_count == 1 ? !selection_is_launcher (selection) : 1);
 
 	nautilus_bonobo_set_sensitive (view->details->ui, 
 				       FM_DIRECTORY_VIEW_COMMAND_NEW_LAUNCHER,
 				       can_create_files);
-
-	nautilus_bonobo_set_sensitive (view->details->ui, 
-				       FM_DIRECTORY_VIEW_COMMAND_EDIT_LAUNCHER,
-				       selection_count == 1);
-
-
 
 	real_update_menus_volumes (view, selection, selection_count);
 	


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