1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
diff -up gnome-panel-2.29.5.1/gnome-panel/panel-ditem-editor.c.launcher-desktop-files gnome-panel-2.29.5.1/gnome-panel/panel-ditem-editor.c
--- gnome-panel-2.29.5.1/gnome-panel/panel-ditem-editor.c.launcher-desktop-files 2010-01-13 22:26:27.000000000 -0500
+++ gnome-panel-2.29.5.1/gnome-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);
}
|