# HG changeset patch # User Mark Doliner # Date 1056592916 0 # Node ID 0a2a32b1917c16d6f981e4c436ca4795aca0b123 # Parent b432fa2402638dba5e5c133122c281ecd313da77 [gaim-migrate @ 6405] Some minor UI fixes from yours truely: -Closing a conversation that has a "select image to insert" dialog open now also closes and frees the "select image to insert" dialog. -The buddy icon selection dialog now lets you type, eg "~/.gaim/icons" and hit enter without it thinking you've selected "~/.gaim/icons" as your buddy icon. It will instead change the icon selection dialog to that directory. -Same for the "select file to send" dialog. -Same for the right-click-on-an-icon "save icon" dialog. -Same for the right-click-on-an-IM-image "save image" dialog. -Same for buddy pounce "select sound" and "select program" dialogs. I think there is a small leak here, but I don't have time to figure it out. Someone should memprof this. I think it's gtkpounce.c line 140. -Same for toc's "select file to send" dialog. This needs to change-- toc has gtk code in it. -Made file_is_dir() accept a GtkFileSelection rather than a GtkWidget (there is no reason it would need to accept anything other than a GtkFileSelection) -Some minor pounce dialog memleak fixes, I think. The hash table wasn't getting freed on cancel. Line 4960 of gtkconv.c might be leaking somehow. Someone should look into that. committer: Tailor Script diff -r b432fa240263 -r 0a2a32b1917c src/dialogs.c --- a/src/dialogs.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/dialogs.c Thu Jun 26 02:01:56 2003 +0000 @@ -2495,7 +2495,7 @@ strncpy(path, file, PATHSIZE - 1); - if (file_is_dir(path, gtkconv->dialogs.log)) + if (file_is_dir(path, GTK_FILE_SELECTION(gtkconv->dialogs.log))) return; l = (struct log_conversation *)g_new0(struct log_conversation, 1); @@ -3806,7 +3806,7 @@ file = (const char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); strncpy(path, file, PATHSIZE - 1); - if (file_is_dir(path, filesel)) + if (file_is_dir(path, GTK_FILE_SELECTION(filesel))) return; if ((fp_new = fopen(path, "w")) == NULL) { @@ -4504,7 +4504,7 @@ return button; } -int file_is_dir(const char *path, GtkWidget *w) +int file_is_dir(const char *path, GtkFileSelection *w) { struct stat st; char *name; @@ -4516,7 +4516,7 @@ } else { name = g_strdup(path); } - gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name); + gtk_file_selection_set_filename(w, name); g_free(name); return 1; } diff -r b432fa240263 -r 0a2a32b1917c src/gtkaccount.c --- a/src/gtkaccount.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkaccount.c Thu Jun 26 02:01:56 2003 +0000 @@ -217,6 +217,10 @@ { const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->buddy_icon_filesel)); + /* If they typed in a directory, change there */ + if (file_is_dir(filename, GTK_FILE_SELECTION(dialog->buddy_icon_filesel))) + return; + if (dialog->account) { const char *username; struct buddy *b; diff -r b432fa240263 -r 0a2a32b1917c src/gtkconv.c --- a/src/gtkconv.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkconv.c Thu Jun 26 02:01:56 2003 +0000 @@ -149,7 +149,7 @@ filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); - if (file_is_dir(filename, wid)) + if (file_is_dir(filename, GTK_FILE_SELECTION(wid))) return; if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && @@ -189,7 +189,7 @@ name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); id = g_slist_length(im->images) + 1; - if (file_is_dir(name, wid)) + if (file_is_dir(name, GTK_FILE_SELECTION(wid))) return; gtk_widget_destroy(wid); @@ -4134,6 +4134,9 @@ if (gtkconv->dialogs.font != NULL) gtk_widget_destroy(gtkconv->dialogs.font); + if (gtkconv->dialogs.image != NULL) + gtk_widget_destroy(gtkconv->dialogs.image); + if (gtkconv->dialogs.smiley != NULL) gtk_widget_destroy(gtkconv->dialogs.smiley); diff -r b432fa240263 -r 0a2a32b1917c src/gtkft.c --- a/src/gtkft.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkft.c Thu Jun 26 02:01:56 2003 +0000 @@ -996,6 +996,9 @@ name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data->filesel)); + if (file_is_dir(name, GTK_FILE_SELECTION(data->filesel))) + return; + if (stat(name, &st) != 0) { /* File not found. */ if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { diff -r b432fa240263 -r 0a2a32b1917c src/gtkimhtml.c --- a/src/gtkimhtml.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkimhtml.c Thu Jun 26 02:01:56 2003 +0000 @@ -1618,7 +1618,12 @@ GError *error = NULL; #if GTK_CHECK_VERSION(2,2,0) GSList *formats = gdk_pixbuf_get_formats(); +#endif + if (file_is_dir(filename, GTK_FILE_SELECTION(sel))) + return; + +#if GTK_CHECK_VERSION(2,2,0) while(formats){ GdkPixbufFormat *format = formats->data; gchar **extensions = gdk_pixbuf_format_get_extensions(format); diff -r b432fa240263 -r 0a2a32b1917c src/gtkpounce.c --- a/src/gtkpounce.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkpounce.c Thu Jun 26 02:01:56 2003 +0000 @@ -110,17 +110,22 @@ { const char *filename; GHashTable *args; + GtkFileSelection *filesel; args = (GHashTable *)data; + filesel = GTK_FILE_SELECTION(g_hash_table_lookup(args, "filesel")); - filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION( - g_hash_table_lookup(args, "filesel"))); + filename = gtk_file_selection_get_filename(filesel); + + if (file_is_dir(filename, filesel)) + return; if (filename != NULL) gtk_entry_set_text(GTK_ENTRY(g_hash_table_lookup(args, "entry")), filename); - g_free(args); + gtk_widget_destroy(GTK_WIDGET(filesel)); + g_hash_table_destroy(args); } static void @@ -138,18 +143,16 @@ gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(filesel)); gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(filesel), FALSE); - args = g_hash_table_new(g_str_hash,g_str_equal); + args = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(args, "filesel", filesel); g_hash_table_insert(args, "entry", entry); g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", G_CALLBACK(pounce_update_entryfields), args); - - g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), + g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), "clicked", - G_CALLBACK(gtk_widget_destroy), filesel); - + G_CALLBACK(g_hash_table_destroy), args); g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), "clicked", G_CALLBACK(gtk_widget_destroy), filesel); diff -r b432fa240263 -r 0a2a32b1917c src/gtkprefs.c --- a/src/gtkprefs.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkprefs.c Thu Jun 26 02:01:56 2003 +0000 @@ -1918,7 +1918,7 @@ file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sounddialog)); /* If they type in a directory, change there */ - if (file_is_dir(file, sounddialog)) + if (file_is_dir(file, GTK_FILE_SELECTION(sounddialog))) return; /* Set it -- and forget it */ diff -r b432fa240263 -r 0a2a32b1917c src/gtkutils.c --- a/src/gtkutils.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/gtkutils.c Thu Jun 26 02:01:56 2003 +0000 @@ -265,7 +265,7 @@ f = gtk_file_selection_get_filename( GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); - if (file_is_dir(f, gtkconv->u.im->save_icon)) + if (file_is_dir(f, GTK_FILE_SELECTION(gtkconv->u.im->save_icon))) return; if ((file = fopen(f, "w")) != NULL) { diff -r b432fa240263 -r 0a2a32b1917c src/protocols/toc/toc.c --- a/src/protocols/toc/toc.c Wed Jun 25 22:30:49 2003 +0000 +++ b/src/protocols/toc/toc.c Thu Jun 26 02:01:56 2003 +0000 @@ -1646,7 +1646,7 @@ GaimAccount *account; char buf[BUF_LEN * 2]; - if (file_is_dir(dirname, old_ft->window)) + if (file_is_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) return; ft = g_new0(struct file_transfer, 1); if (old_ft->files == 1) @@ -1845,7 +1845,7 @@ GaimAccount *account; char *buf, buf2[BUF_LEN * 2]; - if (file_is_dir(dirname, old_ft->window)) + if (file_is_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) return; ft = g_new0(struct file_transfer, 1); ft->filename = g_strdup(dirname); diff -r b432fa240263 -r 0a2a32b1917c src/ui.h --- a/src/ui.h Wed Jun 25 22:30:49 2003 +0000 +++ b/src/ui.h Thu Jun 26 02:01:56 2003 +0000 @@ -228,7 +228,7 @@ extern GtkWidget *gaim_pixbuf_button(char *, char *, GaimButtonOrientation); extern GtkWidget *gaim_pixbuf_button_from_stock(const char *, const char *, GaimButtonOrientation); extern GtkWidget *gaim_pixbuf_toolbar_button_from_stock(char *); -extern int file_is_dir(const char *, GtkWidget *); +extern int file_is_dir(const char *, GtkFileSelection *); extern void update_privacy_connections(); extern void show_privacy_options(); extern void build_allow_list();