[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-user: [pcb GTK HID] Updated patch for filters in filechooser dialog
Hi all,
Updated my patch after some useful comments by Frank Bergmann.
The patch is also filed in the SF tracker as patch #2686963
Kind regards,
Bert Timmerman.
From ad9ea9e52a757371a731353c7c3a38cb50f3f38e Mon Sep 17 00:00:00 2001
From: Bert Timmerman <bert.timmerman@xxxxxxxxx>
Date: Wed, 25 Mar 2009 23:57:24 +0100
Subject: [PATCH] Apply filters on the filechooser dialogs when loading layouts (to buffer), elements (to buffer) and netlists.
---
src/hid/gtk/gui-dialog.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/src/hid/gtk/gui-dialog.c b/src/hid/gtk/gui-dialog.c
index 5993b14..37842d8 100644
--- a/src/hid/gtk/gui-dialog.c
+++ b/src/hid/gtk/gui-dialog.c
@@ -262,6 +262,7 @@ ghid_dialog_file_select_open (gchar * title, gchar ** path, gchar * shortcuts)
GtkWidget *dialog;
gchar *result = NULL, *folder, *seed;
GHidPort *out = &ghid_port;
+ GtkFileFilter *no_filter;
dialog = gtk_file_chooser_dialog_new (title,
GTK_WINDOW (out->top_window),
@@ -272,6 +273,50 @@ ghid_dialog_file_select_open (gchar * title, gchar ** path, gchar * shortcuts)
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ /* add a default filter for not filtering files */
+ no_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (no_filter, "all");
+ gtk_file_filter_add_pattern (no_filter, "*.*");
+ gtk_file_filter_add_pattern (no_filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), no_filter);
+
+ /* in case we have a dialog for loading a footprint file */
+ if (strcmp (title, "Load element to buffer") == 0)
+ {
+ /* add a filter for footprint files */
+ GtkFileFilter *fp_filter;
+ fp_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (fp_filter, "fp");
+ gtk_file_filter_add_pattern (fp_filter, "*.fp");
+ gtk_file_filter_add_pattern (fp_filter, "*.FP");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), fp_filter);
+ }
+
+ /* in case we have a dialog for loading a layout file */
+ if ((strcmp (title, "Load layout file") == 0)
+ || (strcmp (title, "Load layout file to buffer") == 0))
+ {
+ /* add a filter for layout files */
+ GtkFileFilter *pcb_filter;
+ pcb_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (pcb_filter, "pcb");
+ gtk_file_filter_add_pattern (pcb_filter, "*.pcb");
+ gtk_file_filter_add_pattern (pcb_filter, "*.PCB");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), pcb_filter);
+ }
+
+ /* in case we have a dialog for loading a netlist file */
+ if (strcmp (title, "Load netlist file") == 0)
+ {
+ /* add a filter for netlist files */
+ GtkFileFilter *net_filter;
+ net_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (net_filter, "netlist");
+ gtk_file_filter_add_pattern (net_filter, "*.net");
+ gtk_file_filter_add_pattern (net_filter, "*.NET");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), net_filter);
+ }
+
if (path && *path)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), *path);
--
1.5.0.6
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user