1c078e5
diff -up gnome-panel-2.19.92/gnome-panel/panel-ditem-editor.c.launcher-desktop-files gnome-panel-2.19.92/gnome-panel/panel-ditem-editor.c
1c078e5
--- gnome-panel-2.19.92/gnome-panel/panel-ditem-editor.c.launcher-desktop-files	2007-09-04 13:34:26.000000000 -0400
1c078e5
+++ gnome-panel-2.19.92/gnome-panel/panel-ditem-editor.c	2007-09-13 12:13:36.000000000 -0400
1c078e5
@@ -973,6 +973,51 @@ panel_ditem_editor_icon_changed (PanelDI
adb8fd2
 	g_free (file);
adb8fd2
 }
adb8fd2
 
adb8fd2
+static gboolean
adb8fd2
+update_editor_from_desktop_file (PanelDItemEditor *dialog,
adb8fd2
+				 const gchar      *uri)
adb8fd2
+{
adb8fd2
+	GKeyFile *key_file;
adb8fd2
+	char *name;
adb8fd2
+	char *comment;
adb8fd2
+	char *exec;
adb8fd2
+	char *icon;
1c078e5
+	gboolean retval = FALSE;
adb8fd2
+
adb8fd2
+	key_file = g_key_file_new ();
adb8fd2
+	if (g_key_file_load_from_file (key_file, uri, 0, NULL)) {
5107e18
+		if (panel_key_file_get_boolean (key_file, "Terminal", FALSE)) 
adb8fd2
+			gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->type_combo), 1);
adb8fd2
+		else
adb8fd2
+			gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->type_combo), 0); 
adb8fd2
+
5107e18
+		name = panel_key_file_get_locale_string (key_file, "Name");
5107e18
+		comment = panel_key_file_get_locale_string (key_file, "Comment");
5107e18
+		icon = panel_key_file_get_locale_string (key_file, "Icon");
5107e18
+		exec = panel_key_file_get_string (key_file, "Exec");
adb8fd2
+
1c078e5
+		gtk_entry_set_text (GTK_ENTRY (dialog->priv->name_entry), name ? name : "");
1c078e5
+		gtk_entry_set_text (GTK_ENTRY (dialog->priv->comment_entry), comment ? comment : "");
1c078e5
+		gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry), exec ? exec : "");
1c078e5
+
adb8fd2
+		/* Note: we need to set the icon last, since the editor
adb8fd2
+		 * tries to guess the icon when the command is modified
adb8fd2
+		 */ 
adb8fd2
+		setup_icon_entry (dialog, icon);
adb8fd2
+
1c078e5
+		g_free (name);
1c078e5
+		g_free (comment);
1c078e5
+		g_free (icon);
1c078e5
+		g_free (exec);
1c078e5
+
1c078e5
+		retval = TRUE;    
adb8fd2
+	}
adb8fd2
+
1c078e5
+	g_key_file_free (key_file);
1c078e5
+
1c078e5
+	return retval;
adb8fd2
+}
adb8fd2
+
adb8fd2
 static void
adb8fd2
 command_browse_chooser_response (GtkFileChooser   *chooser,
adb8fd2
 				 gint              response_id,
1c078e5
@@ -986,7 +1031,11 @@ command_browse_chooser_response (GtkFile
adb8fd2
 		case PANEL_DITEM_EDITOR_TYPE_APPLICATION:
adb8fd2
 		case PANEL_DITEM_EDITOR_TYPE_TERMINAL_APPLICATION:
adb8fd2
 			text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
adb8fd2
-			uri = panel_util_make_exec_uri_for_desktop (text);
adb8fd2
+			if (g_str_has_suffix (text, ".desktop") &&
adb8fd2
+			    update_editor_from_desktop_file (dialog, text))
adb8fd2
+				uri = NULL;
adb8fd2
+			else 
adb8fd2
+				uri = panel_util_make_exec_uri_for_desktop (text);
adb8fd2
 			g_free (text);
adb8fd2
 			break;
adb8fd2
 		case PANEL_DITEM_EDITOR_TYPE_LINK:
1c078e5
@@ -996,8 +1045,9 @@ command_browse_chooser_response (GtkFile
adb8fd2
 			g_assert_not_reached ();
adb8fd2
 		}
adb8fd2
 
adb8fd2
-		gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry),
adb8fd2
-				    uri);
adb8fd2
+		if (uri)
adb8fd2
+			gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry),
adb8fd2
+				    	    uri);
adb8fd2
 		g_free (uri);
adb8fd2
 	}
adb8fd2