Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv11716/src Modified Files: dialogs.c gtkaccount.c gtkconv.c gtkft.c gtkimhtml.c gtkpounce.c gtkprefs.c gtkutils.c gtkutils.h ui.h Log Message: 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. Index: dialogs.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/dialogs.c,v retrieving revision 1.491 retrieving revision 1.492 diff -u -d -r1.491 -r1.492 --- dialogs.c 26 Jun 2003 02:01:56 -0000 1.491 +++ dialogs.c 27 Jun 2003 23:11:21 -0000 1.492 @@ -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) { @@ -4502,26 +4502,6 @@ gtk_widget_show_all(bbox); 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; } /*------------------------------------------------------------------------*/ Index: gtkaccount.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkaccount.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- gtkaccount.c 26 Jun 2003 02:01:56 -0000 1.71 +++ gtkaccount.c 27 Jun 2003 23:11:21 -0000 1.72 @@ -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) { Index: gtkconv.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkconv.c,v retrieving revision 1.149 retrieving revision 1.150 diff -u -d -r1.149 -r1.150 --- gtkconv.c 26 Jun 2003 02:01:56 -0000 1.149 +++ gtkconv.c 27 Jun 2003 23:11:21 -0000 1.150 @@ -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); Index: gtkft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkft.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- gtkft.c 26 Jun 2003 02:01:56 -0000 1.31 +++ gtkft.c 27 Jun 2003 23:11:21 -0000 1.32 @@ -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) { Index: gtkimhtml.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkimhtml.c,v retrieving revision 1.185 retrieving revision 1.186 diff -u -d -r1.185 -r1.186 --- gtkimhtml.c 26 Jun 2003 02:01:56 -0000 1.185 +++ gtkimhtml.c 27 Jun 2003 23:11:21 -0000 1.186 @@ -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) Index: gtkpounce.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkpounce.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- gtkpounce.c 26 Jun 2003 02:01:56 -0000 1.27 +++ gtkpounce.c 27 Jun 2003 23:11:21 -0000 1.28 @@ -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) Index: gtkprefs.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkprefs.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- gtkprefs.c 26 Jun 2003 02:01:56 -0000 1.44 +++ gtkprefs.c 27 Jun 2003 23:11:21 -0000 1.45 @@ -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 */ Index: gtkutils.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkutils.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- gtkutils.c 26 Jun 2003 02:01:56 -0000 1.29 +++ gtkutils.c 27 Jun 2003 23:11:21 -0000 1.30 @@ -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) { @@ -808,6 +808,26 @@ g_object_unref(sg); 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) Index: gtkutils.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkutils.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- gtkutils.h 23 Jun 2003 02:00:15 -0000 1.12 +++ gtkutils.h 27 Jun 2003 23:11:21 -0000 1.13 @@ -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. * Index: ui.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ui.h,v retrieving revision 1.124 retrieving revision 1.125 diff -u -d -r1.124 -r1.125 --- ui.h 26 Jun 2003 02:01:56 -0000 1.124 +++ ui.h 27 Jun 2003 23:11:21 -0000 1.125 @@ -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(); |