summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/chanlist.c2
-rw-r--r--src/fe-gtk/dccgui.c2
-rw-r--r--src/fe-gtk/fe-gtk.c4
-rw-r--r--src/fe-gtk/gtkutil.c22
-rw-r--r--src/fe-gtk/gtkutil.h2
-rw-r--r--src/fe-gtk/menu.c2
-rw-r--r--src/fe-gtk/plugingui.c7
-rw-r--r--src/fe-gtk/rawlog.c2
-rw-r--r--src/fe-gtk/setup.c6
-rw-r--r--src/fe-gtk/textgui.c4
-rw-r--r--src/fe-gtk/urlgrab.c2
11 files changed, 40 insertions, 15 deletions
diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c
index e75b97bc..f2e40248 100644
--- a/src/fe-gtk/chanlist.c
+++ b/src/fe-gtk/chanlist.c
@@ -530,7 +530,7 @@ chanlist_save (GtkWidget * wid, server *serv)
 
 	if (gtk_tree_model_get_iter_first (model, &iter))
 		gtkutil_file_req (_("Select an output filename"), chanlist_filereq_done,
-								serv, NULL, FRF_WRITE);
+								serv, NULL, NULL, FRF_WRITE);
 }
 
 static gboolean
diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c
index b3f538f8..6019b3b2 100644
--- a/src/fe-gtk/dccgui.c
+++ b/src/fe-gtk/dccgui.c
@@ -165,7 +165,7 @@ fe_dcc_send_filereq (struct session *sess, char *nick, int maxcps, int passive)
 	mdc->passive = passive;
 
 	snprintf (tbuf, sizeof tbuf, _("Send file to %s"), nick);
-	gtkutil_file_req (tbuf, dcc_send_filereq_file, mdc, NULL, FRF_MULTIPLE);
+	gtkutil_file_req (tbuf, dcc_send_filereq_file, mdc, NULL, NULL, FRF_MULTIPLE);
 }
 
 static void
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index 295d68a1..318395a2 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -893,7 +893,7 @@ fe_confirm (const char *message, void (*yesproc)(void *), void (*noproc)(void *)
 	struct DCC *dcc = ud;
 
 	if (dcc->file)
-		gtkutil_file_req (message, dcc_saveas_cb, ud, dcc->file,
+		gtkutil_file_req (message, dcc_saveas_cb, ud, dcc->file, NULL,
 								FRF_WRITE|FRF_FILTERISINITIAL|FRF_NOASKOVERWRITE);
 }
 
@@ -1144,5 +1144,5 @@ fe_get_file (const char *title, char *initial,
 {
 	/* OK: Call callback once per file, then once more with file=NULL. */
 	/* CANCEL: Call callback once with file=NULL. */
-	gtkutil_file_req (title, callback, userdata, initial, flags | FRF_FILTERISINITIAL);
+	gtkutil_file_req (title, callback, userdata, initial, NULL, flags | FRF_FILTERISINITIAL);
 }
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index 165f8d4e..e8b47074 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -370,12 +370,15 @@ win32_read_thread (GIOChannel *source, GIOCondition cond, struct file_req *freq)
 #endif	/* native file dialogs */
 
 void
-gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter,
+gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions,
 						int flags)
 {
 	struct file_req *freq;
 	GtkWidget *dialog;
+	GtkFileFilter *filefilter;
 	extern char *get_xdir_fs (void);
+	char *token;
+	char *tokenbuffer;
 
 #if 0	/* native file dialogs */
 #ifdef WIN32
@@ -473,6 +476,23 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
 			gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filter);
 	}
 
+	if (flags & FRF_EXTENSIONS && extensions != NULL)
+	{
+		filefilter = gtk_file_filter_new ();
+		tokenbuffer = g_strdup (extensions);
+		token = strtok (tokenbuffer, ";");
+
+		while (token != NULL)
+		{
+			gtk_file_filter_add_pattern (filefilter, token);
+			token = strtok (NULL, ";");
+		}
+
+		g_free (tokenbuffer);
+		gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filefilter);
+		g_free (filefilter);
+	}
+
 	freq = malloc (sizeof (struct file_req));
 	freq->dialog = dialog;
 	freq->flags = flags;
diff --git a/src/fe-gtk/gtkutil.h b/src/fe-gtk/gtkutil.h
index 9bf9e058..65b5c079 100644
--- a/src/fe-gtk/gtkutil.h
+++ b/src/fe-gtk/gtkutil.h
@@ -10,7 +10,7 @@ typedef void (*filereqcallback) (void *, char *file);
 #define FRF_FILTERISINITIAL 16
 #define FRF_NOASKOVERWRITE 32
 
-void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, int flags);
+void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags);
 void gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad);
 GtkWidget *gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
 				 void *userdata, char *labeltext);
diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c
index 400b709b..2bca63c8 100644
--- a/src/fe-gtk/menu.c
+++ b/src/fe-gtk/menu.c
@@ -1288,7 +1288,7 @@ static void
 menu_savebuffer (GtkWidget * wid, gpointer none)
 {
 	gtkutil_file_req (_("Select an output filename"), savebuffer_req_done,
-							current_sess, NULL, FRF_WRITE);
+							current_sess, NULL, NULL, FRF_WRITE);
 }
 
 static void
diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c
index 33b27663..d17aadb7 100644
--- a/src/fe-gtk/plugingui.c
+++ b/src/fe-gtk/plugingui.c
@@ -41,6 +41,7 @@ typedef struct session xchat_context;
 #include "../common/outbound.h"
 #include "../common/fe.h"
 #include "../common/xchatc.h"
+#include "../common/cfgfiles.h"
 #include "gtkutil.h"
 
 /* model for the plugin treeview */
@@ -154,7 +155,11 @@ plugingui_load (void)
 #else
 #endif
 #endif	/* native file dialogs */
-							NULL, FRF_ADDFOLDER);
+#ifdef WIN32
+							get_xdir_utf8 (), "*.dll;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS);
+#else
+							get_xdir_utf8 (), "*.so;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS);
+#endif
 }
 
 static void
diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c
index 78a7eb2f..39dca988 100644
--- a/src/fe-gtk/rawlog.c
+++ b/src/fe-gtk/rawlog.c
@@ -81,7 +81,7 @@ rawlog_clearbutton (GtkWidget * wid, server *serv)
 static int
 rawlog_savebutton (GtkWidget * wid, server *serv)
 {
-	gtkutil_file_req (_("Save As..."), rawlog_save, serv, NULL, FRF_WRITE);
+	gtkutil_file_req (_("Save As..."), rawlog_save, serv, NULL, NULL, FRF_WRITE);
 	return FALSE;
 }
 
diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c
index 9d1079ad..fafb8334 100644
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -955,7 +955,7 @@ setup_filereq_cb (GtkWidget *entry, char *file)
 static void
 setup_browsefile_cb (GtkWidget *button, GtkWidget *entry)
 {
-	gtkutil_file_req (_("Select an Image File"), setup_filereq_cb, entry, NULL, 0);
+	gtkutil_file_req (_("Select an Image File"), setup_filereq_cb, entry, NULL, NULL, 0);
 }
 
 static void
@@ -990,7 +990,7 @@ setup_fontsel_cancel (GtkWidget *button, GtkFontSelectionDialog *dialog)
 static void
 setup_browsefolder_cb (GtkWidget *button, GtkEntry *entry)
 {
-	gtkutil_file_req (_("Select Download Folder"), setup_filereq_cb, entry, entry->text, FRF_CHOOSEFOLDER);
+	gtkutil_file_req (_("Select Download Folder"), setup_filereq_cb, entry, entry->text, NULL, FRF_CHOOSEFOLDER);
 }
 
 static void
@@ -1552,7 +1552,7 @@ setup_snd_filereq_cb (GtkWidget *entry, char *file)
 static void
 setup_snd_browse_cb (GtkWidget *button, GtkEntry *entry)
 {
-	gtkutil_file_req (_("Select a sound file"), setup_snd_filereq_cb, entry, NULL, 0);
+	gtkutil_file_req (_("Select a sound file"), setup_snd_filereq_cb, entry, NULL, NULL, 0);
 }
 
 static void
diff --git a/src/fe-gtk/textgui.c b/src/fe-gtk/textgui.c
index 604da44b..fbee6590 100644
--- a/src/fe-gtk/textgui.c
+++ b/src/fe-gtk/textgui.c
@@ -302,7 +302,7 @@ pevent_save_cb (GtkWidget * wid, void *data)
 	if (data)
 	{
 		gtkutil_file_req (_("Print Texts File"), pevent_save_req_cb, NULL,
-								NULL, FRF_WRITE);
+								NULL, NULL, FRF_WRITE);
 		return;
 	}
 	pevent_save (NULL);
@@ -324,7 +324,7 @@ pevent_load_req_cb (void *arg1, char *file)
 static void
 pevent_load_cb (GtkWidget * wid, void *data)
 {
-	gtkutil_file_req (_("Print Texts File"), pevent_load_req_cb, NULL, NULL, 0);
+	gtkutil_file_req (_("Print Texts File"), pevent_load_req_cb, NULL, NULL, NULL, 0);
 }
 
 static void
diff --git a/src/fe-gtk/urlgrab.c b/src/fe-gtk/urlgrab.c
index 14b446a8..9ab238cf 100644
--- a/src/fe-gtk/urlgrab.c
+++ b/src/fe-gtk/urlgrab.c
@@ -145,7 +145,7 @@ static void
 url_button_save (void)
 {
 	gtkutil_file_req (_("Select an output filename"),
-							url_save_callback, NULL, NULL, FRF_WRITE);
+							url_save_callback, NULL, NULL, NULL, FRF_WRITE);
 }
 
 void