Re: PATCH: make gnome-desktop-item-edit work



> Could you do up a ChangeLog so I can see more easily what you
> are trying to fix with each of these changes ?

Ok, I've attached an updated patch with the ChangeLog.

- Frank

? prepare-ChangeLog.pl
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/ChangeLog,v
retrieving revision 1.434
diff -u -r1.434 ChangeLog
--- ChangeLog	2002/04/18 14:31:43	1.434
+++ ChangeLog	2002/04/22 18:51:45
@@ -1,3 +1,18 @@
+2002-04-22  Frank Worsley  <fworsley shaw ca>
+
+	* gnome-panel/gnome-desktop-item-edit.c:
+	call panel functions with correct parameters
+	fix so that existing files can be edited
+	
+	* gnome-panel/launcher.c:
+	change window titles to match other panel/nautilus terminology
+	
+	* gnome-panel/menu-ditem.c: 
+	change window titles to match other panel/nautilus terminology	
+	(is_item_writable): check correct parameter when dir != NULL
+	(panel_edit_direntry): don't free dirfile if we use it again
+	(create_launcher): display a message box if location not writable
+
 2002-04-18  Mark McLoughlin  <mark skynet ie>
 
 	* configure.in: update our requirements so
Index: gnome-panel/gnome-desktop-item-edit.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/gnome-desktop-item-edit.c,v
retrieving revision 1.4
diff -u -r1.4 gnome-desktop-item-edit.c
--- gnome-panel/gnome-desktop-item-edit.c	2002/03/26 04:19:39	1.4
+++ gnome-panel/gnome-desktop-item-edit.c	2002/04/22 18:51:46
@@ -105,34 +105,31 @@
 		gnome_vfs_file_info_clear (info);
 
 		if (gnome_vfs_get_file_info
-		    (uri, info, GNOME_VFS_FILE_INFO_DEFAULT) != GNOME_VFS_OK) {
-			/* ok, this doesn't exist, really */
-			if (is_ext (desktops[i], ".directory")) {
+		    (uri, info, GNOME_VFS_FILE_INFO_DEFAULT) == GNOME_VFS_OK) {
+
+			if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY && create_new) {
+				dlg = panel_new_launcher (uri);
+
+			} else if (info->type == GNOME_VFS_FILE_TYPE_REGULAR
+				   && is_ext (desktops[i], ".directory")
+				   && !create_new) {
 				char *dirname = g_path_get_dirname (uri);
-				char *basename = g_path_get_basename (dirname);
-				dlg = panel_edit_direntry (dirname, basename);
-				g_free (basename);
+				dlg = panel_edit_direntry (dirname, NULL);
 				g_free (dirname);
-			} else {
+			
+			} else if (info->type == GNOME_VFS_FILE_TYPE_REGULAR
+				   && is_ext (desktops[i], ".desktop")
+				   && !create_new) {
 				char *dirname = g_path_get_dirname (uri);
 				dlg = panel_edit_dentry (uri, dirname);
 				g_free (dirname);
-			}
-		}
-
-		if (dlg == NULL &&
-		    info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
-			if (create_new) {
-				dlg = panel_new_launcher (uri);
+				
 			} else {
-				char *basename = g_path_get_basename (desktops[i]);
-				dlg = panel_edit_direntry (uri, basename);
-				g_free (basename);
+				fprintf (stderr, "gnome-desktop-item-edit: no file to edit\n");
+				return 0;
 			}
-		} else if (dlg == NULL) {
-			char *dirname = g_path_get_dirname (uri);
-			dlg = panel_edit_dentry (uri, dirname);
-			g_free (dirname);
+		} else {
+			fprintf (stderr, "gnome-desktop-item-edit: no file to edit\n");
 		}
 
 		if (dlg != NULL) {
Index: gnome-panel/launcher.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/launcher.c,v
retrieving revision 1.199
diff -u -r1.199 launcher.c
--- gnome-panel/launcher.c	2002/04/15 16:57:29	1.199
+++ gnome-panel/launcher.c	2002/04/22 18:51:46
@@ -569,7 +569,7 @@
 
 	dialog = gtk_dialog_new ();
 
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Launcher properties"));
+	gtk_window_set_title (GTK_WINDOW (dialog), _("Launcher Properties"));
 
 	help = gtk_dialog_add_button (
 			GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP);
@@ -758,7 +758,7 @@
 	GnomeDItemEdit *dee;
 	GnomeDesktopItem *ditem;
 
-	dialog = gtk_dialog_new_with_buttons (_("Create launcher applet"),
+	dialog = gtk_dialog_new_with_buttons (_("Create Launcher"),
 					      NULL /* parent */,
 					      0 /* flags */,
 					      GTK_STOCK_HELP,
Index: gnome-panel/menu-ditem.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/menu-ditem.c,v
retrieving revision 1.7
diff -u -r1.7 menu-ditem.c
--- gnome-panel/menu-ditem.c	2002/04/12 17:23:41	1.7
+++ gnome-panel/menu-ditem.c	2002/04/22 18:51:46
@@ -123,8 +123,7 @@
 is_item_writable (const char *loc, const char *dir)
 {
 	if (loc != NULL) {
-		/* if old style kde link file, don't allow
-		 * editting */
+		/* if old style kde link file, don't allow editing */
 		if (is_ext (loc, ".kdelnk"))
 			return FALSE;
 		if (panel_is_uri_writable (loc))
@@ -132,9 +131,9 @@
 		else
 			return FALSE;
 	}
-
+	
 	if (dir != NULL) {
-		if (panel_is_uri_writable (loc))
+		if (panel_is_uri_writable (dir))
 			return TRUE;
 		else
 			return FALSE;
@@ -171,10 +170,10 @@
 
 	ditem = gnome_desktop_item_new_from_uri (loc,
 						 0 /* flags */,
-						 NULL /* error */);
+						 NULL /* error */);		 
 
 	/* watch the enum at the top of the file */
-	dialog = gtk_dialog_new_with_buttons (_("Desktop entry properties"),
+	dialog = gtk_dialog_new_with_buttons (_("Launcher Properties"),
 					      NULL /* parent */,
 					      0 /* flags */,
 					      GTK_STOCK_HELP,
@@ -242,15 +241,17 @@
 {
 	GtkWidget *dialog;
 	GtkWidget *dedit;
-	char *dirfile = g_build_path ("/", dir, ".directory", NULL);
 	GnomeDesktopItem *ditem;
+	char *dirfile;
+	
+	dirfile = g_strconcat (dir, "/", ".directory", NULL);
 
 	ditem = gnome_desktop_item_new_from_uri (dirfile,
 						 0 /* flags */,
 						 NULL /* error */);
 
 	/* watch the enum at the top of the file */
-	dialog = gtk_dialog_new_with_buttons (_("Desktop entry properties"),
+	dialog = gtk_dialog_new_with_buttons (_("Launcher Properties"),
 					      NULL /* parent */,
 					      0 /* flags */,
 					      GTK_STOCK_HELP,
@@ -274,8 +275,6 @@
 		g_object_set_data_full (G_OBJECT (dedit), "location",
 					g_strdup (gnome_desktop_item_get_location (ditem)),
 					(GDestroyNotify)g_free);
-		g_free (dirfile);
-		dirfile = NULL;
 	} else {
 		ditem = gnome_desktop_item_new ();
 		if (dir_name == NULL) {
@@ -294,12 +293,11 @@
 		gnome_desktop_item_set_string (ditem,
 					       GNOME_DESKTOP_ITEM_TYPE,
 					       "Directory");
-		/*we don't have to free dirfile here it will be freed as if
-		  we had strduped it here*/
+
+		/* we free dirfile below so make a copy here */
 		g_object_set_data_full (G_OBJECT (dedit),
-					"location", dirfile,
+					"location", g_strdup (dirfile),
 					(GDestroyNotify)g_free);
-		dirfile = NULL;
 		gnome_ditem_edit_set_ditem (GNOME_DITEM_EDIT (dedit), ditem);
 	}
 
@@ -333,6 +331,8 @@
 				    NULL);
 	}
 
+	g_free (dirfile);
+		
 	gtk_widget_show (dialog);
 
 	gnome_ditem_edit_grab_focus (GNOME_DITEM_EDIT (dedit));
@@ -475,8 +475,16 @@
 {
 	GtkWidget *dialog;
 	GtkWidget *dee;
+
+	if (!is_item_writable (item_loc, NULL)) {
+		
+		dialog = panel_error_dialog ("can_not_create_launcher",
+				             _("You can not create a new launcher at this location since the location is not writable."));
+
+		return dialog;
+	}
 
-	dialog = gtk_dialog_new_with_buttons (_("Create menu item"),
+	dialog = gtk_dialog_new_with_buttons (_("Create Launcher"),
 					      NULL /* parent */,
 					      0 /* flags */,
 					      GTK_STOCK_CANCEL,


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