changeset 1035:80a47e3b1bca

[gaim-migrate @ 1045] thanks to bmiller for yet another patch ;) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 31 Oct 2000 07:36:11 +0000
parents 1d43fda97960
children faa5afc2b89e
files src/dialogs.c src/gaim.h src/plugins.c src/rvous.c src/util.c
diffstat 5 files changed, 58 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Tue Oct 31 07:18:44 2000 +0000
+++ b/src/dialogs.c	Tue Oct 31 07:36:11 2000 +0000
@@ -67,6 +67,8 @@
 
 #define DEFAULT_FONT_NAME "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1"
 
+#define PATHSIZE 1024
+
 int smiley_array[FACE_TOTAL];
 GdkColor bgcolor;
 GdkColor fgcolor;
@@ -1862,11 +1864,19 @@
 {
         struct log_conversation *l;
         char buf[128];
+	char *file;
+	char path[PATHSIZE];
 
         if (!find_log_info(c->name)) {
+		file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(c->log_dialog));
+		strncpy( path, file, PATHSIZE - 1 );
+		if (file_is_dir(path, c->log_dialog)) {
+			return;
+		}
+
                 l = (struct log_conversation *)g_new0(struct log_conversation, 1);
                 strcpy(l->name, c->name);
-                strcpy(l->filename, gtk_file_selection_get_filename(GTK_FILE_SELECTION(c->log_dialog)));
+                strcpy(l->filename, file);
                 log_conversations = g_list_append(log_conversations, l);
 
                 if (c != NULL)
@@ -2623,8 +2633,6 @@
 /*  The dialog for import/export                                          */
 /*------------------------------------------------------------------------*/
 
-#define PATHSIZE 1024
-
 /* see if a buddy list cache file for this user exists */
 
 gboolean
@@ -2670,6 +2678,10 @@
 	if ( show_dialog == 1 ) {
 		file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(exportdialog));
 		strncpy( path, file, PATHSIZE - 1 );
+		if (file_is_dir(path, exportdialog)) {
+			g_free (buf);
+			return;
+		}
 		if ((f = fopen(path,"w"))) {
 			toc_build_config(connections->data, buf, 8192 - 1, TRUE);
 			fprintf(f, "%s\n", buf);
@@ -2772,6 +2784,11 @@
         if ( !gc ) {
         	file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog));
                 strncpy( path, file, PATHSIZE - 1 );
+		if (file_is_dir(path, importdialog)) {
+			g_free (buf);
+			g_free (first);
+			return;
+		}
         }
         else {
 		for (i = 0; i < strlen(gc->username); i++)
--- a/src/gaim.h	Tue Oct 31 07:18:44 2000 +0000
+++ b/src/gaim.h	Tue Oct 31 07:36:11 2000 +0000
@@ -618,6 +618,7 @@
 extern void show_usage (int, char *);
 extern void set_first_user (char *);
 extern int do_auto_login (char *);
+extern int file_is_dir (char *, GtkWidget *);
 
 /* Functions in server.c */
 /* input to serv */
--- a/src/plugins.c	Tue Oct 31 07:18:44 2000 +0000
+++ b/src/plugins.c	Tue Oct 31 07:36:11 2000 +0000
@@ -128,8 +128,15 @@
 }
 
 static void load_which_plugin(GtkWidget *w, gpointer data) {
-	load_plugin(gtk_file_selection_get_filename(
-					GTK_FILE_SELECTION(plugin_dialog)));
+	char *file;
+
+	file = gtk_file_selection_get_filename(
+		                   GTK_FILE_SELECTION(plugin_dialog));
+	if (file_is_dir(file, plugin_dialog)) {
+		return;
+	}
+
+	load_plugin(file);
 
 	if (plugin_dialog)
 		gtk_widget_destroy(plugin_dialog);
--- a/src/rvous.c	Tue Oct 31 07:18:44 2000 +0000
+++ b/src/rvous.c	Tue Oct 31 07:36:11 2000 +0000
@@ -216,6 +216,10 @@
 	GtkWidget *fw = NULL, *fbar = NULL, *label = NULL;
 	GtkWidget *button = NULL, *pct = NULL;
 
+	if (file_is_dir(file, ft->window)) {
+	  	return;
+	}
+
 	if (!(ft->f = fopen(file,"w"))) {
                 g_snprintf(buf, BUF_LONG / 2, _("Error writing file %s"), file);
 		do_error_dialog(buf, _("Error"));
@@ -486,6 +490,11 @@
 	struct stat st;
 	struct tm *fortime;
 
+	if (file_is_dir (file, ft->window)) {
+		g_free(file);
+		return;
+	}
+
 	stat(file, &st);
 	if (!(ft->f = fopen(file, "r"))) {
 		g_snprintf(buf, BUF_LONG / 2, _("Error reading file %s"), file);
--- a/src/util.c	Tue Oct 31 07:18:44 2000 +0000
+++ b/src/util.c	Tue Oct 31 07:36:11 2000 +0000
@@ -1272,3 +1272,22 @@
 	return retval;
 }
 		
+
+int file_is_dir (char *path, GtkWidget *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(GTK_FILE_SELECTION(w), name);
+		g_free(name);
+		return 1;
+	}
+
+	return 0;
+}