Mercurial > pidgin.yaz
changeset 5966:5fb6bd688a5b
[gaim-migrate @ 6413]
I renamed file_is_dir to gaim_gtk_check_if_dir and moved it to gtkutils.c/h
Chipster (or whoever) - Lemme know if that's notsogood, remember: I pretend
not to know anything about gtk.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 27 Jun 2003 23:11:21 +0000 |
parents | cd8f8e5d697e |
children | 156953fe3e14 |
files | src/dialogs.c src/gtkaccount.c src/gtkconv.c src/gtkft.c src/gtkimhtml.c src/gtkpounce.c src/gtkprefs.c src/gtkutils.c src/gtkutils.h src/protocols/toc/toc.c src/ui.h |
diffstat | 11 files changed, 46 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dialogs.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/dialogs.c Fri Jun 27 23:11:21 2003 +0000 @@ -2495,7 +2495,7 @@ strncpy(path, file, PATHSIZE - 1); - if (file_is_dir(path, GTK_FILE_SELECTION(gtkconv->dialogs.log))) + if (gaim_gtk_check_if_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, GTK_FILE_SELECTION(filesel))) + if (gaim_gtk_check_if_dir(path, GTK_FILE_SELECTION(filesel))) return; if ((fp_new = fopen(path, "w")) == NULL) { @@ -4504,26 +4504,6 @@ return button; } -int file_is_dir(const char *path, GtkFileSelection *w) -{ - struct stat st; - char *name; - - if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { - /* append a / if needed */ - if (path[strlen(path) - 1] != '/') { - name = g_strconcat(path, "/", NULL); - } else { - name = g_strdup(path); - } - gtk_file_selection_set_filename(w, name); - g_free(name); - return 1; - } - - return 0; -} - /*------------------------------------------------------------------------*/ /* The dialog for setting V-Card info */ /*------------------------------------------------------------------------*/
--- a/src/gtkaccount.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkaccount.c Fri Jun 27 23:11:21 2003 +0000 @@ -218,7 +218,7 @@ 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))) + if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(dialog->buddy_icon_filesel))) return; if (dialog->account) {
--- a/src/gtkconv.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkconv.c Fri Jun 27 23:11:21 2003 +0000 @@ -149,7 +149,7 @@ filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); - if (file_is_dir(filename, GTK_FILE_SELECTION(wid))) + if (gaim_gtk_check_if_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, GTK_FILE_SELECTION(wid))) + if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(wid))) return; gtk_widget_destroy(wid);
--- a/src/gtkft.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkft.c Fri Jun 27 23:11:21 2003 +0000 @@ -32,6 +32,7 @@ #include "gaim-disclosure.h" #include "gtkcellrendererprogress.h" #include "gtkft.h" +#include "gtkutils.h" #include "stock.h" #define GAIM_GTKXFER(xfer) \ @@ -996,7 +997,7 @@ name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data->filesel)); - if (file_is_dir(name, GTK_FILE_SELECTION(data->filesel))) + if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(data->filesel))) return; if (stat(name, &st) != 0) {
--- a/src/gtkimhtml.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkimhtml.c Fri Jun 27 23:11:21 2003 +0000 @@ -1620,7 +1620,7 @@ GSList *formats = gdk_pixbuf_get_formats(); #endif - if (file_is_dir(filename, GTK_FILE_SELECTION(sel))) + if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(sel))) return; #if GTK_CHECK_VERSION(2,2,0)
--- a/src/gtkpounce.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkpounce.c Fri Jun 27 23:11:21 2003 +0000 @@ -117,7 +117,7 @@ filename = gtk_file_selection_get_filename(filesel); - if (file_is_dir(filename, filesel)) + if (gaim_gtk_check_if_dir(filename, filesel)) return; if (filename != NULL)
--- a/src/gtkprefs.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkprefs.c Fri Jun 27 23:11:21 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, GTK_FILE_SELECTION(sounddialog))) + if (gaim_gtk_check_if_dir(file, GTK_FILE_SELECTION(sounddialog))) return; /* Set it -- and forget it */
--- a/src/gtkutils.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkutils.c Fri Jun 27 23:11:21 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, GTK_FILE_SELECTION(gtkconv->u.im->save_icon))) + if (gaim_gtk_check_if_dir(f, GTK_FILE_SELECTION(gtkconv->u.im->save_icon))) return; if ((file = fopen(f, "w")) != NULL) { @@ -810,6 +810,26 @@ return optmenu; } +gboolean gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) +{ + struct stat st; + char *name; + + if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { + /* append a / if needed */ + if (path[strlen(path) - 1] != '/') { + name = g_strconcat(path, "/", NULL); + } else { + name = g_strdup(path); + } + gtk_file_selection_set_filename(filesel, name); + g_free(name); + return TRUE; + } + + return FALSE; +} + char *stylize(const gchar *text, int length) { gchar *buf;
--- a/src/gtkutils.h Fri Jun 27 22:44:03 2003 +0000 +++ b/src/gtkutils.h Fri Jun 27 23:11:21 2003 +0000 @@ -206,6 +206,18 @@ gpointer user_data); /** + * Check if the given path is a directory or not. If it is, then modify + * the given GtkFileSelection dialog so that it displays the given path. + * If the given path is not a directory, then do nothing. + * + * @param path The path entered in the file selection window by the user. + * @param filesel The file selection window. + * + * @return TRUE if given path is a directory, FALSE otherwise. + */ +gboolean gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel); + +/** * Stylizes the specified text using HTML, according to the current * font options. *
--- a/src/protocols/toc/toc.c Fri Jun 27 22:44:03 2003 +0000 +++ b/src/protocols/toc/toc.c Fri Jun 27 23:11:21 2003 +0000 @@ -34,6 +34,7 @@ /* XXX */ #include "gaim.h" #include "ui.h" +#include "gtkutils.h" static GaimPlugin *my_protocol = NULL; @@ -1646,7 +1647,7 @@ GaimAccount *account; char buf[BUF_LEN * 2]; - if (file_is_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) + if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) return; ft = g_new0(struct file_transfer, 1); if (old_ft->files == 1) @@ -1845,7 +1846,7 @@ GaimAccount *account; char *buf, buf2[BUF_LEN * 2]; - if (file_is_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) + if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) return; ft = g_new0(struct file_transfer, 1); ft->filename = g_strdup(dirname);
--- a/src/ui.h Fri Jun 27 22:44:03 2003 +0000 +++ b/src/ui.h Fri Jun 27 23:11:21 2003 +0000 @@ -228,7 +228,6 @@ 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 *, GtkFileSelection *); extern void update_privacy_connections(); extern void show_privacy_options(); extern void build_allow_list();