Removed executable flag from COPYING
[nautilus.git] / src / nautilus-file-management-properties.c
blob6fcb70026700ed44b30cb16599db94581d1a60b8
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
3 /* nautilus-file-management-properties.c - Functions to create and show the nautilus preference dialog.
5 Copyright (C) 2002 Jan Arne Petersen
7 The Gnome Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The Gnome Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the Gnome Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 Authors: Jan Arne Petersen <jpetersen@uni-bonn.de>
25 #include <config.h>
27 #include "nautilus-file-management-properties.h"
29 #include <string.h>
30 #include <time.h>
31 #include <gtk/gtk.h>
32 #include <gio/gio.h>
34 #include <libgnome/gnome-help.h>
35 #include <glib/gi18n.h>
37 #include <glade/glade.h>
39 #include <eel/eel-gconf-extensions.h>
40 #include <eel/eel-glib-extensions.h>
41 #include <eel/eel-preferences-glade.h>
43 #include <libnautilus-private/nautilus-column-chooser.h>
44 #include <libnautilus-private/nautilus-column-utilities.h>
45 #include <libnautilus-private/nautilus-global-preferences.h>
46 #include <libnautilus-private/nautilus-module.h>
48 #include <libnautilus-private/nautilus-autorun.h>
50 /* string enum preferences */
51 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox"
52 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "icon_view_zoom_combobox"
53 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET "list_view_zoom_combobox"
54 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET "sort_order_combobox"
55 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET "date_format_combobox"
56 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET "preview_text_combobox"
57 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET "preview_image_combobox"
58 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_SOUND_WIDGET "preview_sound_combobox"
59 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET "preview_folder_combobox"
61 /* bool preferences */
62 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET "sort_folders_first_checkbutton"
63 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET "compact_layout_checkbutton"
64 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET "labels_beside_icons_checkbutton"
65 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET "always_use_browser_checkbutton"
66 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_LOCATION_ENTRY_WIDGET "always_use_location_entry_checkbutton"
67 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET "trash_confirm_checkbutton"
68 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET "trash_delete_checkbutton"
69 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_OPEN_NEW_WINDOW_WIDGET "new_window_checkbutton"
70 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET "hidden_files_checkbutton"
71 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET "treeview_folders_checkbutton"
72 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTOMOUNT_OPEN "media_automount_open_checkbutton"
73 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTORUN_NEVER "media_autorun_never_checkbutton"
75 /* int enums */
76 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET "preview_image_size_combobox"
78 static const char * const default_view_values[] = {
79 "icon_view",
80 "list_view",
81 NULL
84 static const char * const zoom_values[] = {
85 "smallest",
86 "smaller",
87 "small",
88 "standard",
89 "large",
90 "larger",
91 "largest",
92 NULL
95 static const char * const sort_order_values[] = {
96 "name",
97 "size",
98 "type",
99 "modification_date",
100 "emblems",
101 NULL
104 static const char * const date_format_values[] = {
105 "locale",
106 "iso",
107 "informal",
108 NULL
111 static const char * const preview_values[] = {
112 "always",
113 "local_only",
114 "never",
115 NULL
118 static const char * const click_behavior_components[] = {
119 "single_click_radiobutton",
120 "double_click_radiobutton",
121 NULL
124 static const char * const click_behavior_values[] = {
125 "single",
126 "double",
127 NULL
130 static const char * const executable_text_components[] = {
131 "scripts_execute_radiobutton",
132 "scripts_view_radiobutton",
133 "scripts_confirm_radiobutton",
134 NULL
137 static const char * const executable_text_values[] = {
138 "launch",
139 "display",
140 "ask",
141 NULL
144 static const int thumbnail_limit_values[] = {
145 102400,
146 512000,
147 1048576,
148 3145728,
149 5242880,
150 10485760,
151 104857600,
152 1073741824,
156 static const char * const icon_captions_components[] = {
157 "captions_0_combobox",
158 "captions_1_combobox",
159 "captions_2_combobox",
160 NULL
163 static void
164 nautilus_file_management_properties_size_group_create (GladeXML *xml_dialog,
165 char *prefix,
166 int items)
168 GtkSizeGroup *size_group;
169 int i;
170 char *item_name;
172 size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
174 for (i = 0; i < items; i++) {
175 item_name = g_strdup_printf ("%s_%d", prefix, i);
176 gtk_size_group_add_widget (size_group,
177 glade_xml_get_widget (xml_dialog, item_name));
178 g_free (item_name);
180 g_object_unref (G_OBJECT (size_group));
183 static void
184 preferences_show_help (GtkWindow *parent,
185 char const *helpfile,
186 char const *sect_id)
188 GError *error = NULL;
189 GtkWidget *dialog;
191 g_return_if_fail (helpfile != NULL);
192 g_return_if_fail (sect_id != NULL);
194 gnome_help_display_desktop (NULL,
195 "user-guide",
196 helpfile, sect_id, &error);
198 if (error) {
199 dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
200 GTK_DIALOG_DESTROY_WITH_PARENT,
201 GTK_MESSAGE_ERROR,
202 GTK_BUTTONS_OK,
203 _("There was an error displaying help: \n%s"),
204 error->message);
206 g_signal_connect (G_OBJECT (dialog),
207 "response", G_CALLBACK (gtk_widget_destroy),
208 NULL);
209 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
210 gtk_widget_show (dialog);
211 g_error_free (error);
216 static void
217 nautilus_file_management_properties_dialog_response_cb (GtkDialog *parent,
218 int response_id,
219 GladeXML *xml_dialog)
221 char *section;
223 if (response_id == GTK_RESPONSE_HELP) {
224 switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (glade_xml_get_widget (xml_dialog, "notebook1")))) {
225 default:
226 case 0:
227 section = "gosnautilus-438";
228 break;
229 case 1:
230 section = "gosnautilus-56";
231 break;
232 case 2:
233 section = "gosnautilus-439";
234 break;
235 case 3:
236 section = "gosnautilus-490";
237 break;
238 case 4:
239 section = "gosnautilus-60";
241 preferences_show_help (GTK_WINDOW (parent), "user-guide.xml", section);
242 } else if (response_id == GTK_RESPONSE_CLOSE) {
243 /* remove gconf monitors */
244 eel_gconf_monitor_remove ("/apps/nautilus/icon_view");
245 eel_gconf_monitor_remove ("/apps/nautilus/list_view");
246 eel_gconf_monitor_remove ("/apps/nautilus/preferences");
247 eel_gconf_monitor_remove ("/desktop/gnome/file_views");
251 static void
252 columns_changed_callback (NautilusColumnChooser *chooser,
253 gpointer callback_data)
255 char **visible_columns;
256 char **column_order;
258 nautilus_column_chooser_get_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
259 &visible_columns,
260 &column_order);
262 eel_preferences_set_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS, visible_columns);
263 eel_preferences_set_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER, column_order);
265 g_strfreev (visible_columns);
266 g_strfreev (column_order);
269 static void
270 free_column_names_array (GPtrArray *column_names)
272 g_ptr_array_foreach (column_names, (GFunc) g_free, NULL);
273 g_ptr_array_free (column_names, TRUE);
276 static void
277 create_icon_caption_combo_box_items (GtkComboBox *combo_box,
278 GList *columns)
280 GList *l;
281 GPtrArray *column_names;
283 column_names = g_ptr_array_new ();
285 gtk_combo_box_append_text (combo_box, _("None"));
286 g_ptr_array_add (column_names, g_strdup ("none"));
288 for (l = columns; l != NULL; l = l->next) {
289 NautilusColumn *column;
290 char *name;
291 char *label;
293 column = NAUTILUS_COLUMN (l->data);
295 g_object_get (G_OBJECT (column),
296 "name", &name, "label", &label,
297 NULL);
299 /* Don't show name here, it doesn't make sense */
300 if (!strcmp (name, "name")) {
301 g_free (name);
302 g_free (label);
303 continue;
306 gtk_combo_box_append_text (combo_box, label);
307 g_ptr_array_add (column_names, name);
309 g_free (label);
311 g_object_set_data_full (G_OBJECT (combo_box), "column_names",
312 column_names,
313 (GDestroyNotify) free_column_names_array);
316 static void
317 icon_captions_changed_callback (GtkComboBox *combo_box,
318 gpointer user_data)
320 GPtrArray *captions;
321 GladeXML *xml;
322 int i;
324 xml = GLADE_XML (user_data);
326 captions = g_ptr_array_new ();
328 for (i = 0; icon_captions_components[i] != NULL; i++) {
329 GtkWidget *combo_box;
330 int active;
331 GPtrArray *column_names;
332 char *name;
334 combo_box = glade_xml_get_widget
335 (GLADE_XML (xml), icon_captions_components[i]);
336 active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
338 column_names = g_object_get_data (G_OBJECT (combo_box),
339 "column_names");
341 name = g_ptr_array_index (column_names, active);
342 g_ptr_array_add (captions, name);
344 g_ptr_array_add (captions, NULL);
346 eel_preferences_set_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
347 (char **)captions->pdata);
348 g_ptr_array_free (captions, TRUE);
351 static void
352 update_caption_combo_box (GladeXML *xml,
353 const char *combo_box_name,
354 const char *name)
356 GtkWidget *combo_box;
357 int i;
358 GPtrArray *column_names;
360 combo_box = glade_xml_get_widget (xml, combo_box_name);
362 g_signal_handlers_block_by_func
363 (combo_box,
364 G_CALLBACK (icon_captions_changed_callback),
365 xml);
367 column_names = g_object_get_data (G_OBJECT (combo_box),
368 "column_names");
370 for (i = 0; i < column_names->len; ++i) {
371 if (!strcmp (name, g_ptr_array_index (column_names, i))) {
372 gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), i);
373 break;
377 g_signal_handlers_unblock_by_func
378 (combo_box,
379 G_CALLBACK (icon_captions_changed_callback),
380 xml);
383 static void
384 update_icon_captions_from_gconf (GladeXML *xml)
386 char **captions;
387 int i, j;
389 captions = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
390 if (captions == NULL)
391 return;
393 for (i = 0, j = 0;
394 icon_captions_components[i] != NULL;
395 i++) {
396 char *data;
398 if (captions[j]) {
399 data = captions[j];
400 ++j;
401 } else {
402 data = "none";
405 update_caption_combo_box (xml,
406 icon_captions_components[i],
407 data);
410 g_strfreev (captions);
413 static void
414 nautilus_file_management_properties_dialog_setup_icon_caption_page (GladeXML *xml_dialog)
416 GList *columns;
417 int i;
418 gboolean writable;
420 writable = eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
422 columns = nautilus_get_all_columns ();
424 for (i = 0; icon_captions_components[i] != NULL; i++) {
425 GtkWidget *combo_box;
427 combo_box = glade_xml_get_widget (xml_dialog,
428 icon_captions_components[i]);
430 create_icon_caption_combo_box_items (GTK_COMBO_BOX (combo_box), columns);
431 gtk_widget_set_sensitive (combo_box, writable);
433 g_signal_connect (combo_box, "changed",
434 G_CALLBACK (icon_captions_changed_callback),
435 xml_dialog);
438 nautilus_column_list_free (columns);
440 update_icon_captions_from_gconf (xml_dialog);
443 static void
444 create_date_format_menu (GladeXML *xml_dialog)
446 GtkWidget *combo_box;
447 gchar *date_string;
448 time_t now_raw;
449 struct tm* now;
450 combo_box = glade_xml_get_widget (xml_dialog,
451 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET);
453 now_raw = time (NULL);
454 now = localtime (&now_raw);
456 date_string = eel_strdup_strftime ("%c", now);
457 gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
458 g_free (date_string);
460 date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now);
461 gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
462 g_free (date_string);
464 date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now);
465 gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
466 g_free (date_string);
469 static void
470 set_columns_from_gconf (NautilusColumnChooser *chooser)
472 char **visible_columns;
473 char **column_order;
475 visible_columns = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
476 column_order = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
478 nautilus_column_chooser_set_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
479 visible_columns,
480 column_order);
482 g_strfreev (visible_columns);
483 g_strfreev (column_order);
486 static void
487 use_default_callback (NautilusColumnChooser *chooser,
488 gpointer user_data)
490 eel_preferences_unset (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
491 eel_preferences_unset (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
492 set_columns_from_gconf (chooser);
495 static void
496 nautilus_file_management_properties_dialog_setup_list_column_page (GladeXML *xml_dialog)
498 GtkWidget *chooser;
499 GtkWidget *box;
501 chooser = nautilus_column_chooser_new ();
502 g_signal_connect (chooser, "changed",
503 G_CALLBACK (columns_changed_callback), chooser);
504 g_signal_connect (chooser, "use_default",
505 G_CALLBACK (use_default_callback), chooser);
507 set_columns_from_gconf (NAUTILUS_COLUMN_CHOOSER (chooser));
509 gtk_widget_show (chooser);
510 box = glade_xml_get_widget (xml_dialog, "list_columns_vbox");
512 gtk_box_pack_start (GTK_BOX (box), chooser, TRUE, TRUE, 0);
515 static void
516 nautilus_file_management_properties_dialog_update_media_sensitivity (GladeXML *xml_dialog)
518 gtk_widget_set_sensitive (glade_xml_get_widget (xml_dialog, "media_handling_vbox"),
519 ! eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER));
522 static void
523 other_type_combo_box_changed (GtkComboBox *combo_box, GtkComboBox *action_combo_box)
525 GtkTreeIter iter;
526 GtkTreeModel *model;
527 char *x_content_type;
529 x_content_type = NULL;
531 if (!gtk_combo_box_get_active_iter (combo_box, &iter)) {
532 goto out;
535 model = gtk_combo_box_get_model (combo_box);
536 if (model == NULL) {
537 goto out;
540 gtk_tree_model_get (model, &iter,
541 2, &x_content_type,
542 -1);
544 nautilus_autorun_prepare_combo_box (GTK_WIDGET (action_combo_box),
545 x_content_type,
546 TRUE,
547 TRUE,
548 NULL, NULL);
549 out:
550 g_free (x_content_type);
554 static void
555 nautilus_file_management_properties_dialog_setup_media_page (GladeXML *xml_dialog)
557 unsigned int n;
558 GList *l;
559 GList *content_types;
560 GtkWidget *other_type_combo_box;
561 GtkListStore *other_type_list_store;
562 GtkCellRenderer *renderer;
563 GtkTreeIter iter;
564 const char *s[] = {"media_audio_cdda_combobox", "x-content/audio-cdda",
565 "media_video_dvd_combobox", "x-content/video-dvd",
566 "media_music_player_combobox", "x-content/audio-player",
567 "media_dcf_combobox", "x-content/image-dcf",
568 "media_software_combobox", "x-content/software",
569 NULL};
571 for (n = 0; s[n*2] != NULL; n++) {
572 nautilus_autorun_prepare_combo_box (glade_xml_get_widget (xml_dialog, s[n*2]), s[n*2 + 1],
573 TRUE, TRUE, NULL, NULL);
576 other_type_combo_box = glade_xml_get_widget (xml_dialog, "media_other_type_combobox");
578 other_type_list_store = gtk_list_store_new (3,
579 GDK_TYPE_PIXBUF,
580 G_TYPE_STRING,
581 G_TYPE_STRING);
583 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (other_type_list_store),
584 1, GTK_SORT_ASCENDING);
587 content_types = g_content_types_get_registered ();
589 for (l = content_types; l != NULL; l = l->next) {
590 char *content_type = l->data;
591 char *description;
592 GIcon *icon;
593 NautilusIconInfo *icon_info;
594 GdkPixbuf *pixbuf;
595 int icon_size;
597 if (!g_str_has_prefix (content_type, "x-content/"))
598 continue;
599 for (n = 0; s[n*2] != NULL; n++) {
600 if (strcmp (content_type, s[n*2 + 1]) == 0) {
601 goto skip;
605 icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
607 description = g_content_type_get_description (content_type);
608 gtk_list_store_append (other_type_list_store, &iter);
609 icon = g_content_type_get_icon (content_type);
610 if (icon != NULL) {
611 icon_info = nautilus_icon_info_lookup (icon, icon_size);
612 g_object_unref (icon);
613 pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (icon_info, icon_size);
614 g_object_unref (icon_info);
615 } else {
616 pixbuf = NULL;
619 gtk_list_store_set (other_type_list_store, &iter,
620 0, pixbuf,
621 1, description,
622 2, content_type,
623 -1);
624 if (pixbuf != NULL)
625 g_object_unref (pixbuf);
626 g_free (description);
627 skip:
630 g_list_foreach (content_types, (GFunc) g_free, NULL);
631 g_list_free (content_types);
633 gtk_combo_box_set_model (GTK_COMBO_BOX (other_type_combo_box), GTK_TREE_MODEL (other_type_list_store));
635 renderer = gtk_cell_renderer_pixbuf_new ();
636 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (other_type_combo_box), renderer, FALSE);
637 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (other_type_combo_box), renderer,
638 "pixbuf", 0,
639 NULL);
640 renderer = gtk_cell_renderer_text_new ();
641 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (other_type_combo_box), renderer, TRUE);
642 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (other_type_combo_box), renderer,
643 "text", 1,
644 NULL);
646 g_signal_connect (G_OBJECT (other_type_combo_box),
647 "changed",
648 G_CALLBACK (other_type_combo_box_changed),
649 glade_xml_get_widget (xml_dialog, "media_other_action_combobox"));
651 gtk_combo_box_set_active (GTK_COMBO_BOX (other_type_combo_box), 0);
653 nautilus_file_management_properties_dialog_update_media_sensitivity (xml_dialog);
656 static void
657 nautilus_file_management_properties_dialog_setup (GladeXML *xml_dialog, GtkWindow *window)
659 GtkWidget *dialog;
661 /* setup gconf stuff */
662 eel_gconf_monitor_add ("/apps/nautilus/icon_view");
663 eel_gconf_preload_cache ("/apps/nautilus/icon_view", GCONF_CLIENT_PRELOAD_ONELEVEL);
664 eel_gconf_monitor_add ("/apps/nautilus/list_view");
665 eel_gconf_preload_cache ("/apps/nautilus/list_view", GCONF_CLIENT_PRELOAD_ONELEVEL);
666 eel_gconf_monitor_add ("/apps/nautilus/preferences");
667 eel_gconf_preload_cache ("/apps/nautilus/preferences", GCONF_CLIENT_PRELOAD_ONELEVEL);
668 eel_gconf_monitor_add ("/desktop/gnome/file_views");
669 eel_gconf_preload_cache ("/desktop/gnome/file_views", GCONF_CLIENT_PRELOAD_ONELEVEL);
671 /* setup UI */
672 nautilus_file_management_properties_size_group_create (xml_dialog,
673 "views_label",
675 nautilus_file_management_properties_size_group_create (xml_dialog,
676 "captions_label",
678 nautilus_file_management_properties_size_group_create (xml_dialog,
679 "preview_label",
681 create_date_format_menu (xml_dialog);
683 /* setup preferences */
684 eel_preferences_glade_connect_bool (xml_dialog,
685 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET,
686 NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT);
687 eel_preferences_glade_connect_bool (xml_dialog,
688 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET,
689 NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
690 eel_preferences_glade_connect_bool (xml_dialog,
691 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
692 NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
693 eel_preferences_glade_connect_bool (xml_dialog,
694 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET,
695 NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
697 eel_preferences_glade_connect_bool (xml_dialog,
698 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTOMOUNT_OPEN,
699 NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN);
700 eel_preferences_glade_connect_bool (xml_dialog,
701 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTORUN_NEVER,
702 NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER);
704 eel_preferences_glade_connect_bool (xml_dialog,
705 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET,
706 NAUTILUS_PREFERENCES_CONFIRM_TRASH);
707 eel_preferences_glade_connect_bool (xml_dialog,
708 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET,
709 NAUTILUS_PREFERENCES_ENABLE_DELETE);
710 eel_preferences_glade_connect_bool (xml_dialog,
711 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
712 NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
713 eel_preferences_glade_connect_bool_slave (xml_dialog,
714 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
715 NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
716 eel_preferences_glade_connect_bool (xml_dialog,
717 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET,
718 NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES);
720 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
721 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET,
722 NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
723 (const char **) default_view_values);
724 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
725 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET,
726 NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
727 (const char **) zoom_values);
728 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
729 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET,
730 NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
731 (const char **) zoom_values);
732 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
733 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
734 NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
735 (const char **) sort_order_values);
736 eel_preferences_glade_connect_string_enum_combo_box_slave (xml_dialog,
737 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
738 NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER);
739 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
740 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET,
741 NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
742 (const char **) preview_values);
743 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
744 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET,
745 NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
746 (const char **) preview_values);
747 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
748 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_SOUND_WIDGET,
749 NAUTILUS_PREFERENCES_PREVIEW_SOUND,
750 (const char **) preview_values);
751 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
752 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET,
753 NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
754 (const char **) preview_values);
755 eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
756 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
757 NAUTILUS_PREFERENCES_DATE_FORMAT,
758 (const char **) date_format_values);
760 eel_preferences_glade_connect_string_enum_radio_button (xml_dialog,
761 (const char **) click_behavior_components,
762 NAUTILUS_PREFERENCES_CLICK_POLICY,
763 (const char **) click_behavior_values);
764 eel_preferences_glade_connect_string_enum_radio_button (xml_dialog,
765 (const char **) executable_text_components,
766 NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
767 (const char **) executable_text_values);
769 eel_preferences_glade_connect_int_enum (xml_dialog,
770 NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET,
771 NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
772 (const int *) thumbnail_limit_values);
775 nautilus_file_management_properties_dialog_setup_icon_caption_page (xml_dialog);
776 nautilus_file_management_properties_dialog_setup_list_column_page (xml_dialog);
777 nautilus_file_management_properties_dialog_setup_media_page (xml_dialog);
779 eel_preferences_add_callback (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER,
780 (EelPreferencesCallback ) nautilus_file_management_properties_dialog_update_media_sensitivity,
781 g_object_ref (xml_dialog));
784 /* UI callbacks */
785 dialog = glade_xml_get_widget (xml_dialog, "file_management_dialog");
786 g_signal_connect_data (G_OBJECT (dialog), "response",
787 G_CALLBACK (nautilus_file_management_properties_dialog_response_cb),
788 g_object_ref (xml_dialog),
789 (GClosureNotify)g_object_unref,
792 gtk_window_set_icon_name (GTK_WINDOW (dialog), "file-manager");
794 if (window) {
795 gtk_window_set_screen (GTK_WINDOW (dialog), gtk_window_get_screen(window));
798 gtk_widget_show (dialog);
801 static gboolean
802 delete_event_callback (GtkWidget *widget,
803 GdkEventAny *event,
804 gpointer data)
806 void (*response_callback) (GtkDialog *dialog,
807 gint response_id);
809 response_callback = data;
811 response_callback (GTK_DIALOG (widget), GTK_RESPONSE_CLOSE);
813 return TRUE;
816 void
817 nautilus_file_management_properties_dialog_show (GCallback close_callback, GtkWindow *window)
819 GladeXML *xml_dialog;
821 xml_dialog = glade_xml_new (GLADEDIR "/nautilus-file-management-properties.glade",
822 NULL, NULL);
824 g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "file_management_dialog")),
825 "response", close_callback, NULL);
826 g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "file_management_dialog")),
827 "delete_event", G_CALLBACK (delete_event_callback), close_callback);
829 nautilus_file_management_properties_dialog_setup (xml_dialog, window);
831 g_object_unref (xml_dialog);