Mercurial > pidgin
comparison src/prefs.c @ 4326:eb63f9960d07
[gaim-migrate @ 4582]
You can drag and drop from the web to install themes. Yay.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 17 Jan 2003 09:27:15 +0000 |
parents | 7fd57453e6fc |
children | 2cbcaf41cfee |
comparison
equal
deleted
inserted
replaced
4325:7fd57453e6fc | 4326:eb63f9960d07 |
---|---|
257 } | 257 } |
258 | 258 |
259 return path; | 259 return path; |
260 } | 260 } |
261 | 261 |
262 void theme_install_theme(char *path) { | 262 void theme_install_theme(char *path, char *extn) { |
263 gchar *command; | 263 gchar *command; |
264 gchar *destdir; | 264 gchar *destdir; |
265 gchar *tail; | 265 gchar *tail; |
266 | 266 |
267 /* Just to be safe */ | 267 /* Just to be safe */ |
268 g_strchomp(path); | 268 g_strchomp(path); |
269 | 269 |
270 /* I dont know what you are, get out of here */ | 270 /* I dont know what you are, get out of here */ |
271 if ((tail = strrchr(path, '.')) == NULL) | 271 if (extn != NULL) |
272 tail = extn; | |
273 else if ((tail = strrchr(path, '.')) == NULL) | |
272 return; | 274 return; |
273 | 275 |
274 destdir = g_strconcat(gaim_user_dir(), G_DIR_SEPARATOR_S "smileys", NULL); | 276 destdir = g_strconcat(gaim_user_dir(), G_DIR_SEPARATOR_S "smileys", NULL); |
275 | 277 |
276 /* We'll check this just to make sure. This also lets us do something different on | 278 /* We'll check this just to make sure. This also lets us do something different on |
289 g_free(destdir); | 291 g_free(destdir); |
290 | 292 |
291 theme_refresh_theme_list(); | 293 theme_refresh_theme_list(); |
292 } | 294 } |
293 | 295 |
296 static void theme_got_url(gpointer data, char *themedata, unsigned long len) { | |
297 FILE *f; | |
298 gchar *path; | |
299 | |
300 f = gaim_mkstemp(&path); | |
301 fwrite(themedata, len, 1, f); | |
302 fclose(f); | |
303 | |
304 theme_install_theme(path, data); | |
305 | |
306 unlink(path); | |
307 g_free(path); | |
308 } | |
309 | |
294 gint theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, | 310 gint theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, |
295 guint info, guint t, gpointer data) { | 311 guint info, guint t, gpointer data) { |
296 GList *dcl = dc->targets; | 312 GList *dcl = dc->targets; |
297 gchar *name = sd->data; | 313 gchar *name = sd->data; |
298 | 314 |
301 * Let's do something with it */ | 317 * Let's do something with it */ |
302 | 318 |
303 if (!g_strncasecmp(name, "file://", 7)) { | 319 if (!g_strncasecmp(name, "file://", 7)) { |
304 /* It looks like we're dealing with a local file. Let's | 320 /* It looks like we're dealing with a local file. Let's |
305 * just untar it in the right place */ | 321 * just untar it in the right place */ |
306 theme_install_theme(name + 7); | 322 theme_install_theme(name + 7, NULL); |
323 } else if (!g_strncasecmp(name, "http://", 7)) { | |
324 /* Oo, a web drag and drop. This is where things | |
325 * will start to get interesting */ | |
326 gchar *tail; | |
327 | |
328 if ((tail = strrchr(name, '.')) == NULL) | |
329 return; | |
330 | |
331 /* We'll check this just to make sure. This also lets us do something different on | |
332 * other platforms, if need be */ | |
333 if (!g_strcasecmp(tail, ".gz") || !g_strcasecmp(tail, ".tgz")) | |
334 grab_url(name, FALSE, theme_got_url, ".tgz"); | |
335 | |
336 g_free(tail); | |
307 } | 337 } |
308 | 338 |
309 gtk_drag_finish(dc, TRUE, FALSE, t); | 339 gtk_drag_finish(dc, TRUE, FALSE, t); |
310 } | 340 } |
311 | 341 |