changeset 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 da5e1b57adb0
files doc/the_penguin.txt src/prefs.c
diffstat 2 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/doc/the_penguin.txt	Fri Jan 17 08:35:21 2003 +0000
+++ b/doc/the_penguin.txt	Fri Jan 17 09:27:15 2003 +0000
@@ -1,8 +1,8 @@
 The Penguin
 
-by Jeramey Crawford <jacrawf@marko.net>
+by Rob Flynn <rob@marko.net>
    and
-   Rob Flynn <rob@marko.net>
+   Jeramey Crawford <jacrawf@marko.net>
 
 
 Once upon a term'nal dreary, while I hack'ed, weak and weary,
--- a/src/prefs.c	Fri Jan 17 08:35:21 2003 +0000
+++ b/src/prefs.c	Fri Jan 17 09:27:15 2003 +0000
@@ -259,7 +259,7 @@
 	return path;
 }
 
-void theme_install_theme(char *path) {
+void theme_install_theme(char *path, char *extn) {
 	gchar *command;
 	gchar *destdir;
 	gchar *tail;
@@ -268,7 +268,9 @@
 	g_strchomp(path);
 
 	/* I dont know what you are, get out of here */
-	if ((tail = strrchr(path, '.')) == NULL)
+	if (extn != NULL)
+		tail = extn;
+	else if ((tail = strrchr(path, '.')) == NULL)
 		return;
 
 	destdir = g_strconcat(gaim_user_dir(), G_DIR_SEPARATOR_S "smileys", NULL);
@@ -291,6 +293,20 @@
 	theme_refresh_theme_list();
 }
 
+static void theme_got_url(gpointer data, char *themedata, unsigned long len) {
+	FILE *f;
+	gchar *path;
+
+	f = gaim_mkstemp(&path);
+	fwrite(themedata, len, 1, f);
+	fclose(f);
+
+	theme_install_theme(path, data);
+
+	unlink(path);
+	g_free(path);
+}
+
 gint theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, 
 				guint info, guint t, gpointer data) {
 	GList *dcl = dc->targets;
@@ -303,7 +319,21 @@
 		if (!g_strncasecmp(name, "file://", 7)) {
 			/* It looks like we're dealing with a local file. Let's 
 			 * just untar it in the right place */
-			theme_install_theme(name + 7);
+			theme_install_theme(name + 7, NULL);
+		} else if (!g_strncasecmp(name, "http://", 7)) {
+			/* Oo, a web drag and drop. This is where things
+			 * will start to get interesting */
+			gchar *tail;
+			
+			if ((tail = strrchr(name, '.')) == NULL)
+				return;
+
+			/* We'll check this just to make sure. This also lets us do something different on
+			 * other platforms, if need be */
+			if (!g_strcasecmp(tail, ".gz") || !g_strcasecmp(tail, ".tgz"))
+				grab_url(name, FALSE, theme_got_url, ".tgz");
+
+			g_free(tail);
 		}
 
 		gtk_drag_finish(dc, TRUE, FALSE, t);