aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2005-12-27 10:40:10 +0000
committerJan Djärv2005-12-27 10:40:10 +0000
commit78c55a8031e29bd5b0552d2727558057eafc4f71 (patch)
treeb969f68eb5575c0db6c1979377cd5b475dfb4195 /src
parenta8a35720091ca039e331497e45d720bc8ff405c6 (diff)
downloademacs-78c55a8031e29bd5b0552d2727558057eafc4f71.tar.gz
emacs-78c55a8031e29bd5b0552d2727558057eafc4f71.zip
* gtkutil.c (xg_toggle_visibility_cb): New function.
(xg_get_file_with_chooser): Add toggle hidden files and a message to the new file chooser dialog. Show hidden files if x_show_hidden_files is non-zero.
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9da3c5bf457..05750c42646 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1220,6 +1220,19 @@ xg_get_file_name_from_chooser (w)
1220 return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w)); 1220 return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w));
1221} 1221}
1222 1222
1223static void
1224xg_toggle_visibility_cb(widget, data)
1225 GtkWidget *widget;
1226 gpointer data;
1227{
1228 GtkFileChooser *dialog = GTK_FILE_CHOOSER (data);
1229 gboolean visible;
1230 extern int x_gtk_show_hidden_files;
1231 g_object_get (G_OBJECT (dialog), "show-hidden", &visible, NULL);
1232 g_object_set (G_OBJECT (dialog), "show-hidden", !visible, NULL);
1233 x_gtk_show_hidden_files = !visible;
1234}
1235
1223/* Read a file name from the user using a file chooser dialog. 1236/* Read a file name from the user using a file chooser dialog.
1224 F is the current frame. 1237 F is the current frame.
1225 PROMPT is a prompt to show to the user. May not be NULL. 1238 PROMPT is a prompt to show to the user. May not be NULL.
@@ -1239,11 +1252,14 @@ xg_get_file_with_chooser (f, prompt, default_filename,
1239 int mustmatch_p, only_dir_p; 1252 int mustmatch_p, only_dir_p;
1240 xg_get_file_func *func; 1253 xg_get_file_func *func;
1241{ 1254{
1242 GtkWidget *filewin; 1255 char message[1024];
1256
1257 GtkWidget *filewin, *wtoggle, *wbox, *wmessage;
1243 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); 1258 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
1244 GtkFileChooserAction action = (mustmatch_p ? 1259 GtkFileChooserAction action = (mustmatch_p ?
1245 GTK_FILE_CHOOSER_ACTION_OPEN : 1260 GTK_FILE_CHOOSER_ACTION_OPEN :
1246 GTK_FILE_CHOOSER_ACTION_SAVE); 1261 GTK_FILE_CHOOSER_ACTION_SAVE);
1262 extern int x_gtk_show_hidden_files;
1247 1263
1248 if (only_dir_p) 1264 if (only_dir_p)
1249 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; 1265 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
@@ -1256,6 +1272,39 @@ xg_get_file_with_chooser (f, prompt, default_filename,
1256 NULL); 1272 NULL);
1257 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filewin), TRUE); 1273 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filewin), TRUE);
1258 1274
1275 wbox = gtk_vbox_new (FALSE, 0);
1276 gtk_widget_show (wbox);
1277 wtoggle = gtk_check_button_new_with_label ("Show hidden files.");
1278
1279 if (x_gtk_show_hidden_files)
1280 {
1281 g_object_set (G_OBJECT (filewin), "show-hidden", TRUE, NULL);
1282 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wtoggle), TRUE);
1283 }
1284 gtk_widget_show (wtoggle);
1285 g_signal_connect (G_OBJECT (wtoggle), "clicked",
1286 G_CALLBACK (xg_toggle_visibility_cb), G_OBJECT(filewin));
1287
1288#ifdef HAVE_GTK_FILE_SELECTION_NEW
1289 strcpy (message, "If you find this file dialog inconvinient "
1290 "you can customize x-use-old-gtk-file-dialog\n"
1291 "to get the old file dialog, or you can customize "
1292 "use-file-dialog to disable file dialogs, or just\n"
1293 "use C-x C-f to open files.");
1294#else
1295 strcpy (message, "If you find this file dialog inconvinient"
1296 "you can customize use-file-dialog to disable file dialogs,\n"
1297 "or just use C-x C-f to open files.");
1298#endif
1299 if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
1300 strcat (message, "\nUse C-l to bring up a text input area.");
1301
1302 wmessage = gtk_label_new (message);
1303 gtk_widget_show (wmessage);
1304 gtk_box_pack_start (GTK_BOX (wbox), wtoggle, FALSE, FALSE, 0);
1305 gtk_box_pack_start (GTK_BOX (wbox), wmessage, FALSE, FALSE, 0);
1306 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filewin), wbox);
1307
1259 if (default_filename) 1308 if (default_filename)
1260 { 1309 {
1261 Lisp_Object file; 1310 Lisp_Object file;