Mercurial > pidgin.yaz
comparison src/prefs.c @ 4325:7fd57453e6fc
[gaim-migrate @ 4580]
Drag-n-drop smiley theme installation
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 17 Jan 2003 08:35:21 +0000 |
parents | 561316116cd8 |
children | eb63f9960d07 |
comparison
equal
deleted
inserted
replaced
4324:561316116cd8 | 4325:7fd57453e6fc |
---|---|
218 { | 218 { |
219 GdkPixbuf *pixbuf; | 219 GdkPixbuf *pixbuf; |
220 GSList *themes; | 220 GSList *themes; |
221 GtkTreeIter iter; | 221 GtkTreeIter iter; |
222 GtkTreePath *path; | 222 GtkTreePath *path; |
223 int ind; | 223 int ind = 0; |
224 | |
224 | 225 |
225 smiley_theme_probe(); | 226 smiley_theme_probe(); |
227 | |
226 if (!smiley_themes) | 228 if (!smiley_themes) |
227 return; | 229 return; |
230 | |
228 themes = smiley_themes; | 231 themes = smiley_themes; |
232 | |
233 gtk_list_store_clear(smiley_theme_store); | |
234 | |
229 while (themes) { | 235 while (themes) { |
230 struct smiley_theme *theme = themes->data; | 236 struct smiley_theme *theme = themes->data; |
231 char *description = g_strdup_printf("<span size='larger' weight='bold'>%s</span> - %s\n" | 237 char *description = g_strdup_printf("<span size='larger' weight='bold'>%s</span> - %s\n" |
232 "<span size='smaller' foreground='gray'>%s</span>", | 238 "<span size='smaller' foreground='gray'>%s</span>", |
233 theme->name, theme->author, theme->desc);; | 239 theme->name, theme->author, theme->desc);; |
247 path = gtk_tree_path_new_from_string(iwishihadgtk2_2); | 253 path = gtk_tree_path_new_from_string(iwishihadgtk2_2); |
248 g_free(iwishihadgtk2_2); | 254 g_free(iwishihadgtk2_2); |
249 } | 255 } |
250 ind++; | 256 ind++; |
251 } | 257 } |
258 | |
252 return path; | 259 return path; |
253 } | 260 } |
261 | |
262 void theme_install_theme(char *path) { | |
263 gchar *command; | |
264 gchar *destdir; | |
265 gchar *tail; | |
266 | |
267 /* Just to be safe */ | |
268 g_strchomp(path); | |
269 | |
270 /* I dont know what you are, get out of here */ | |
271 if ((tail = strrchr(path, '.')) == NULL) | |
272 return; | |
273 | |
274 destdir = g_strconcat(gaim_user_dir(), G_DIR_SEPARATOR_S "smileys", NULL); | |
275 | |
276 /* We'll check this just to make sure. This also lets us do something different on | |
277 * other platforms, if need be */ | |
278 if (!g_strcasecmp(tail, ".gz") || !g_strcasecmp(tail, ".tgz")) | |
279 command = g_strdup_printf("tar > /dev/null xzf \"%s\" -C %s", path, destdir); | |
280 else { | |
281 g_free(destdir); | |
282 return; | |
283 } | |
284 | |
285 /* Fire! */ | |
286 system(command); | |
287 | |
288 g_free(command); | |
289 g_free(destdir); | |
290 | |
291 theme_refresh_theme_list(); | |
292 } | |
293 | |
294 gint theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, | |
295 guint info, guint t, gpointer data) { | |
296 GList *dcl = dc->targets; | |
297 gchar *name = sd->data; | |
298 | |
299 if ((sd->length >= 0) && (sd->format == 8)) { | |
300 /* Well, it looks like the drag event was cool. | |
301 * Let's do something with it */ | |
302 | |
303 if (!g_strncasecmp(name, "file://", 7)) { | |
304 /* It looks like we're dealing with a local file. Let's | |
305 * just untar it in the right place */ | |
306 theme_install_theme(name + 7); | |
307 } | |
308 | |
309 gtk_drag_finish(dc, TRUE, FALSE, t); | |
310 } | |
311 | |
312 gtk_drag_finish(dc, FALSE, FALSE, t); | |
313 } | |
314 | |
254 GtkWidget *theme_page() { | 315 GtkWidget *theme_page() { |
255 GtkWidget *ret; | 316 GtkWidget *ret; |
256 GtkWidget *sw; | 317 GtkWidget *sw; |
257 GSList *themes; | 318 GSList *themes; |
258 GtkTreeIter iter; | 319 GtkTreeIter iter; |
261 GtkTreeViewColumn *col; | 322 GtkTreeViewColumn *col; |
262 GtkTreeSelection *sel; | 323 GtkTreeSelection *sel; |
263 GtkTreePath *path = NULL; | 324 GtkTreePath *path = NULL; |
264 GdkPixbuf *pixbuf; | 325 GdkPixbuf *pixbuf; |
265 int ind =0; | 326 int ind =0; |
327 GtkTargetEntry te[3] = {{"text/plain", 0, 0},{"text/uri-list", 1, 0},{"STRING", 2, 0}}; | |
266 | 328 |
267 ret = gtk_vbox_new(FALSE, 18); | 329 ret = gtk_vbox_new(FALSE, 18); |
268 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | 330 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); |
269 | 331 |
270 sw = gtk_scrolled_window_new(NULL,NULL); | 332 sw = gtk_scrolled_window_new(NULL,NULL); |
275 smiley_theme_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); | 337 smiley_theme_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); |
276 | 338 |
277 path = theme_refresh_theme_list(); | 339 path = theme_refresh_theme_list(); |
278 | 340 |
279 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(smiley_theme_store)); | 341 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(smiley_theme_store)); |
280 | 342 |
343 gtk_drag_dest_set(view, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, te, | |
344 sizeof(te) / sizeof(GtkTargetEntry) , GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
345 | |
346 g_signal_connect(G_OBJECT(view), "drag_data_received", G_CALLBACK(theme_dnd_recv), smiley_theme_store); | |
347 | |
281 rend = gtk_cell_renderer_pixbuf_new(); | 348 rend = gtk_cell_renderer_pixbuf_new(); |
282 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); | 349 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); |
283 | 350 |
284 gtk_tree_selection_select_path(sel, path); | 351 gtk_tree_selection_select_path(sel, path); |
285 gtk_tree_path_free(path); | 352 gtk_tree_path_free(path); |