Merge lp://staging/~jassmith/go-home-applet/url-favorites into lp://staging/go-home-applet

Proposed by Jason Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~jassmith/go-home-applet/url-favorites
Merge into: lp://staging/go-home-applet
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~jassmith/go-home-applet/url-favorites
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+11342@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Let netbook-launcher handle the adding of favorites through its --add-favorite flag

Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/applet.c'
2--- src/applet.c 2009-08-26 14:35:22 +0000
3+++ src/applet.c 2009-09-08 04:16:17 +0000
4@@ -83,50 +83,6 @@
5 NULL
6 };
7
8-/* D&D Callbacks */
9-static gchar *
10-_get_website_name (void)
11-{
12- GtkWidget *dialog;
13- GtkWidget *hbox;
14- GtkWidget *vbox;
15- GtkWidget *image, *label, *entry;
16- gchar *name;
17- gint res;
18-
19- dialog = gtk_dialog_new_with_buttons ("Add web shortcut",
20- NULL, 0,
21- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
22- NULL);
23-
24- hbox = gtk_hbox_new (FALSE, 12);
25- gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
26- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
27-
28- image = gtk_image_new_from_icon_name ("applications-internet",
29- GTK_ICON_SIZE_DIALOG);
30- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
31-
32- vbox = gtk_vbox_new (FALSE, 8);
33- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
34-
35- label = gtk_label_new ("Please name your web shortcut:");
36- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
37-
38- entry = gtk_entry_new ();
39- gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
40-
41- gtk_widget_show_all (hbox);
42- res = gtk_dialog_run (GTK_DIALOG (dialog));
43-
44- name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
45-
46- gtk_widget_destroy (dialog);
47-
48- return name;
49-}
50-
51-
52 static gchar *
53 get_applet_icon_name (PanelApplet *applet)
54 {
55@@ -165,65 +121,6 @@
56 set_icon (app);
57 }
58
59-
60-/* Taken from nautilus::panel-util.c, with some modifications */
61-static gchar *
62-get_icon_name (GIcon *icon)
63-{
64- const gchar * const *names;
65- GtkIconTheme *icon_theme;
66- int i;
67-
68- if (!G_IS_THEMED_ICON (icon))
69- return g_strdup ("gnome-fs-folder");
70-
71- names = g_themed_icon_get_names (G_THEMED_ICON (icon));
72- icon_theme = gtk_icon_theme_get_default ();
73-
74- for (i = 0; names[i] != NULL; i++)
75- {
76- if (gtk_icon_theme_has_icon (icon_theme, names[i]))
77- return g_strdup (names[i]);
78- }
79-
80- return NULL;
81-}
82-
83-static gchar *
84-_get_icon (const gchar *filename)
85-{
86- gchar *thumb;
87- gchar *ret = NULL;
88-
89- thumb = gnome_thumbnail_path_for_uri (filename, GNOME_THUMBNAIL_SIZE_NORMAL);
90-
91- if ((g_file_test (thumb, G_FILE_TEST_EXISTS)))
92- ret = g_strdup (thumb);
93-
94- if (!ret)
95- {
96- GFile *file;
97- GFileInfo *info;
98- GIcon *icon;
99-
100- file = g_file_new_for_uri (filename);
101- info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON,
102- 0, NULL, NULL);
103- icon = (GIcon*)g_file_info_get_attribute_object (info,
104- G_FILE_ATTRIBUTE_STANDARD_ICON);
105-
106- ret = get_icon_name (icon);
107-
108- g_object_unref (file);
109- g_object_unref (info);
110- }
111-
112- if (!ret)
113- ret = g_strdup ("gnome-fs-folder");
114-
115- return ret;
116-}
117-
118 static void
119 on_drag_data_recieved (GtkWidget *widget,
120 GdkDragContext *context,
121@@ -250,45 +147,36 @@
122
123 _sdata = g_strdup (_sdata);
124 _sdata = g_strstrip (_sdata);
125-
126- if (g_str_has_prefix (_sdata, "file:///"))
127- {
128- if (strstr (_sdata, ".desktop"))
129- {
130- launcher_util_create_favorite (_sdata);
131- }
132- else
133- {
134- gchar *name, *temp, *exec, *icon;
135- temp = g_filename_display_basename (_sdata);
136- name= g_uri_unescape_string (temp, NULL);
137- icon = _get_icon (_sdata);
138- exec = g_strdup_printf ("%s %s", XDG_OPEN, _sdata);
139- launcher_util_new_shortcut (name, "Favorites",
140- exec, icon);
141- g_free (name);
142- g_free (temp);
143- g_free (exec);
144- g_free (icon);
145- }
146- }
147- else if (g_str_has_prefix (_sdata, "http") ||
148- g_str_has_prefix (_sdata, "ftp"))
149- {
150- gchar *name, *exec;
151- name = _get_website_name ();
152- exec = g_strdup_printf ("%s %s", XDG_OPEN, _sdata);
153- launcher_util_new_shortcut (name, "Favorites",
154- exec, "applications-internet");
155- g_free (name);
156- g_free (exec);
157+
158+ if (g_str_has_prefix (_sdata, "file:///") ||
159+ g_str_has_prefix (_sdata, "http") ||
160+ g_str_has_prefix (_sdata, "ftp"))
161+ {
162+ gint argc;
163+ gchar **argv;
164+ gchar *args = g_strdup_printf ("netbook-launcher --add-favorite %s", _sdata);
165+
166+ if (g_shell_parse_argv (args, &argc, &argv, NULL))
167+ {
168+ g_spawn_async (NULL,
169+ argv,
170+ NULL,
171+ G_SPAWN_SEARCH_PATH,
172+ NULL,
173+ NULL,
174+ NULL,
175+ NULL);
176+ g_strfreev (argv);
177+ }
178+ g_free (args);
179+
180 }
181 else
182 {
183 dnd_success = FALSE;
184 }
185
186- gtk_drag_finish (context, dnd_success, delete_selection_data, time);
187+ gtk_drag_finish (context, dnd_success, delete_selection_data, time);
188 }
189
190

Subscribers

People subscribed via source and target branches

to all changes: