diff -up mate-panel-2.29.5.1/mate-panel/panel-ditem-editor.c.launcher-desktop-files mate-panel-2.29.5.1/mate-panel/panel-ditem-editor.c --- mate-panel-2.29.5.1/mate-panel/panel-ditem-editor.c.launcher-desktop-files 2010-01-13 22:26:27.000000000 -0500 +++ mate-panel-2.29.5.1/mate-panel/panel-ditem-editor.c 2010-01-17 18:05:34.492279538 -0500 @@ -960,6 +960,51 @@ panel_ditem_editor_icon_changed (PanelDI icon); } +static gboolean +update_editor_from_desktop_file (PanelDItemEditor *dialog, + const gchar *uri) +{ + GKeyFile *key_file; + char *name; + char *comment; + char *exec; + char *icon; + gboolean retval = FALSE; + + key_file = g_key_file_new (); + if (g_key_file_load_from_file (key_file, uri, 0, NULL)) { + if (panel_key_file_get_boolean (key_file, "Terminal", FALSE)) + gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->type_combo), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->type_combo), 0); + + name = panel_key_file_get_locale_string (key_file, "Name"); + comment = panel_key_file_get_locale_string (key_file, "Comment"); + icon = panel_key_file_get_locale_string (key_file, "Icon"); + exec = panel_key_file_get_string (key_file, "Exec"); + + gtk_entry_set_text (GTK_ENTRY (dialog->priv->name_entry), name ? name : ""); + gtk_entry_set_text (GTK_ENTRY (dialog->priv->comment_entry), comment ? comment : ""); + gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry), exec ? exec : ""); + + /* Note: we need to set the icon last, since the editor + * tries to guess the icon when the command is modified + */ + setup_icon_chooser (dialog, icon); + + g_free (name); + g_free (comment); + g_free (icon); + g_free (exec); + + retval = TRUE; + } + + g_key_file_free (key_file); + + return retval; +} + static void command_browse_chooser_response (GtkFileChooser *chooser, gint response_id, @@ -973,7 +1018,11 @@ command_browse_chooser_response (GtkFile case PANEL_DITEM_EDITOR_TYPE_APPLICATION: case PANEL_DITEM_EDITOR_TYPE_TERMINAL_APPLICATION: text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); - uri = panel_util_make_exec_uri_for_desktop (text); + if (g_str_has_suffix (text, ".desktop") && + update_editor_from_desktop_file (dialog, text)) + uri = NULL; + else + uri = panel_util_make_exec_uri_for_desktop (text); g_free (text); break; case PANEL_DITEM_EDITOR_TYPE_LINK: @@ -983,8 +1032,9 @@ command_browse_chooser_response (GtkFile g_assert_not_reached (); } - gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry), - uri); + if (uri) + gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry), + uri); g_free (uri); }