nautilus-3.6.3/src/nautilus-file-management-properties.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found nautilus-file-management-properties.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
  2 
  3 /* nautilus-file-management-properties.c - Functions to create and show the nautilus preference dialog.
  4 
  5    Copyright (C) 2002 Jan Arne Petersen
  6 
  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.
 11 
 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.
 16 
 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.
 21 
 22    Authors: Jan Arne Petersen <jpetersen@uni-bonn.de>
 23 */
 24 
 25 #include <config.h>
 26 
 27 #include "nautilus-file-management-properties.h"
 28 
 29 #include <string.h>
 30 #include <time.h>
 31 #include <gtk/gtk.h>
 32 #include <gio/gio.h>
 33 
 34 #include <glib/gi18n.h>
 35 
 36 #include <eel/eel-glib-extensions.h>
 37 
 38 #include <libnautilus-private/nautilus-column-chooser.h>
 39 #include <libnautilus-private/nautilus-column-utilities.h>
 40 #include <libnautilus-private/nautilus-global-preferences.h>
 41 #include <libnautilus-private/nautilus-module.h>
 42 
 43 /* string enum preferences */
 44 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox"
 45 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "icon_view_zoom_combobox"
 46 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET "list_view_zoom_combobox"
 47 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET "sort_order_combobox"
 48 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FILES_WIDGET "preview_image_combobox"
 49 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET "preview_folder_combobox"
 50 
 51 /* bool preferences */
 52 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET "sort_folders_first_checkbutton"
 53 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET "trash_confirm_checkbutton"
 54 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET "trash_delete_checkbutton"
 55 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_OPEN_NEW_WINDOW_WIDGET "new_window_checkbutton"
 56 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET "hidden_files_checkbutton"
 57 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET "treeview_folders_checkbutton"
 58 
 59 /* int enums */
 60 #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET "preview_image_size_combobox"
 61 
 62 static const char * const default_view_values[] = {
 63 	"icon-view",
 64 	"list-view",
 65 	NULL
 66 };
 67 
 68 static const char * const zoom_values[] = {
 69 	"smallest",
 70 	"smaller",
 71 	"small",
 72 	"standard",
 73 	"large",
 74 	"larger",
 75 	"largest",
 76 	NULL
 77 };
 78 
 79 static const char * const sort_order_values[] = {
 80 	"name",
 81 	"size",
 82 	"type",
 83 	"mtime",
 84 	"atime",
 85 	"trash-time",
 86 	NULL
 87 };
 88 
 89 static const char * const date_format_values[] = {
 90 	"locale",
 91 	"iso",
 92 	"informal",
 93 	NULL
 94 };
 95 
 96 static const char * const preview_values[] = {
 97 	"always",
 98 	"local-only",
 99 	"never",
100 	NULL
101 };
102 
103 static const char * const click_behavior_components[] = {
104 	"single_click_radiobutton",
105 	"double_click_radiobutton",
106 	NULL
107 };
108 
109 static const char * const click_behavior_values[] = {
110 	"single",
111 	"double",
112 	NULL
113 };
114 
115 static const char * const executable_text_components[] = {
116 	"scripts_execute_radiobutton",
117 	"scripts_view_radiobutton",
118 	"scripts_confirm_radiobutton",
119 	NULL
120 };
121 
122 static const char * const executable_text_values[] = {
123 	"launch",
124 	"display",
125 	"ask",
126 	NULL
127 };
128 
129 static const guint64 thumbnail_limit_values[] = {
130 	102400,
131 	512000,
132 	1048576,
133 	3145728,
134 	5242880,
135 	10485760,
136 	104857600,
137 	1073741824,
138 	2147483648U,
139 	4294967295U
140 };
141 
142 static const char * const icon_captions_components[] = {
143 	"captions_0_combobox",
144 	"captions_1_combobox",
145 	"captions_2_combobox",
146 	NULL
147 };
148 
149 static GtkWidget *preferences_dialog = NULL;
150 
151 static void
152 nautilus_file_management_properties_size_group_create (GtkBuilder *builder,
153 						       char *prefix,
154 						       int items)
155 {
156 	GtkSizeGroup *size_group;
157 	int i;
158 	char *item_name;
159 	GtkWidget *widget;
160 
161 	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
162 
163 	for (i = 0; i < items; i++) {	
164 		item_name = g_strdup_printf ("%s_%d", prefix, i);
165 		widget = GTK_WIDGET (gtk_builder_get_object (builder, item_name));
166 		gtk_size_group_add_widget (size_group, widget);
167 		g_free (item_name);
168 	}
169 	g_object_unref (G_OBJECT (size_group));
170 }
171 
172 static void
173 preferences_show_help (GtkWindow *parent,
174 		       char const *helpfile,
175 		       char const *sect_id)
176 {
177 	GError *error = NULL;
178 	GtkWidget *dialog;
179 	char *help_string;
180 
181 	g_assert (helpfile != NULL);
182 	g_assert (sect_id != NULL);
183 
184 	help_string = g_strdup_printf ("help:%s/%s", helpfile, sect_id);
185 
186 	gtk_show_uri (gtk_window_get_screen (parent),
187 		      help_string, gtk_get_current_event_time (),
188 		      &error);
189 	g_free (help_string);
190 
191 	if (error) {
192 		dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
193 						 GTK_DIALOG_DESTROY_WITH_PARENT,
194 						 GTK_MESSAGE_ERROR,
195 						 GTK_BUTTONS_OK,
196 						 _("There was an error displaying help: \n%s"),
197 						 error->message);
198 
199 		g_signal_connect (G_OBJECT (dialog),
200 				  "response", G_CALLBACK (gtk_widget_destroy),
201 				  NULL);
202 		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
203 		gtk_widget_show (dialog);
204 		g_error_free (error);
205 	}
206 }
207 
208 
209 static void
210 nautilus_file_management_properties_dialog_response_cb (GtkDialog *parent,
211 							int response_id,
212 							GtkBuilder *builder)
213 {
214 	char *section;
215 
216 	if (response_id == GTK_RESPONSE_HELP) {
217 		switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (gtk_builder_get_object (builder, "notebook1")))) {
218 		default:
219 		case 0:
220 			section = "nautilus-views";
221 			break;
222 		case 1:
223 			section = "nautilus-behavior";
224 			break;
225 		case 2:
226 			section = "nautilus-display";
227 			break;
228 		case 3:
229 			section = "nautilus-list";
230 			break;
231 		case 4:
232 			section = "nautilus-preview";
233 			break;
234 		}
235 		preferences_show_help (GTK_WINDOW (parent), "gnome-help", section);
236 	} else if (response_id == GTK_RESPONSE_CLOSE) {
237 		gtk_widget_destroy (GTK_WIDGET (parent));
238 	}
239 }
240 
241 static void
242 columns_changed_callback (NautilusColumnChooser *chooser,
243 			  gpointer callback_data)
244 {
245 	char **visible_columns;
246 	char **column_order;
247 
248 	nautilus_column_chooser_get_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
249 					      &visible_columns,
250 					      &column_order);
251 
252 	g_settings_set_strv (nautilus_list_view_preferences,
253 			     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
254 			     (const char * const *)visible_columns);
255 	g_settings_set_strv (nautilus_list_view_preferences,
256 			     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
257 			     (const char * const *)column_order);
258 
259 	g_strfreev (visible_columns);
260 	g_strfreev (column_order);
261 }
262 
263 static void
264 free_column_names_array (GPtrArray *column_names)
265 {
266 	g_ptr_array_foreach (column_names, (GFunc) g_free, NULL);
267 	g_ptr_array_free (column_names, TRUE);
268 }
269 
270 static void
271 create_icon_caption_combo_box_items (GtkComboBoxText *combo_box,
272 			             GList *columns)
273 {
274 	GList *l;
275 	GPtrArray *column_names;
276 
277 	column_names = g_ptr_array_new ();
278 
279 	/* Translators: this is referred to captions under icons. */
280 	gtk_combo_box_text_append_text (combo_box, _("None"));
281 	g_ptr_array_add (column_names, g_strdup ("none"));
282 
283 	for (l = columns; l != NULL; l = l->next) {
284 		NautilusColumn *column;
285 		char *name;
286 		char *label;
287 
288 		column = NAUTILUS_COLUMN (l->data);
289 
290 		g_object_get (G_OBJECT (column), 
291 			      "name", &name, "label", &label, 
292 			      NULL);
293 
294 		/* Don't show name here, it doesn't make sense */
295 		if (!strcmp (name, "name")) {
296 			g_free (name);
297 			g_free (label);
298 			continue;
299 		}
300 
301 		gtk_combo_box_text_append_text (combo_box, label);
302 		g_ptr_array_add (column_names, name);
303 
304 		g_free (label);
305 	}
306 	g_object_set_data_full (G_OBJECT (combo_box), "column_names",
307 			        column_names,
308 			        (GDestroyNotify) free_column_names_array);
309 }
310 
311 static void
312 icon_captions_changed_callback (GtkComboBox *combo_box,
313 				gpointer user_data)
314 {
315 	GPtrArray *captions;
316 	GtkBuilder *builder;
317 	int i;
318 
319 	builder = GTK_BUILDER (user_data);
320 
321 	captions = g_ptr_array_new ();
322 
323 	for (i = 0; icon_captions_components[i] != NULL; i++) {
324 		GtkWidget *combo_box;
325 		int active;
326 		GPtrArray *column_names;
327 		char *name;
328 
329 		combo_box = GTK_WIDGET (gtk_builder_get_object
330 					(builder, icon_captions_components[i]));
331 		active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
332 
333 		column_names = g_object_get_data (G_OBJECT (combo_box),
334 						  "column_names");
335 
336 		name = g_ptr_array_index (column_names, active);
337 		g_ptr_array_add (captions, name);
338 	}
339 	g_ptr_array_add (captions, NULL);
340 
341 	g_settings_set_strv (nautilus_icon_view_preferences,
342 			     NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
343 			     (const char **)captions->pdata);
344 	g_ptr_array_free (captions, TRUE);
345 }
346 
347 static void
348 update_caption_combo_box (GtkBuilder *builder,
349 			  const char *combo_box_name,
350 			  const char *name)
351 {
352 	GtkWidget *combo_box;
353 	int i;
354 	GPtrArray *column_names;
355 
356 	combo_box = GTK_WIDGET (gtk_builder_get_object (builder, combo_box_name));
357 
358 	g_signal_handlers_block_by_func
359 		(combo_box,
360 		 G_CALLBACK (icon_captions_changed_callback),
361 		 builder);
362 
363 	column_names = g_object_get_data (G_OBJECT (combo_box), 
364 					  "column_names");
365 
366 	for (i = 0; i < column_names->len; ++i) {
367 		if (!strcmp (name, g_ptr_array_index (column_names, i))) {
368 			gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), i);
369 			break;
370 		}
371 	}
372 
373 	g_signal_handlers_unblock_by_func
374 		(combo_box,
375 		 G_CALLBACK (icon_captions_changed_callback),
376 		 builder);
377 }
378 
379 static void
380 update_icon_captions_from_settings (GtkBuilder *builder)
381 {
382 	char **captions;
383 	int i, j;
384 
385 	captions = g_settings_get_strv (nautilus_icon_view_preferences, NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
386 	if (captions == NULL)
387 		return;
388 
389 	for (i = 0, j = 0; 
390 	     icon_captions_components[i] != NULL;
391 	     i++) {
392 		char *data;
393 
394 		if (captions[j]) {
395 			data = captions[j];
396 			++j;
397 		} else {
398 			data = "none";
399 		}
400 
401 		update_caption_combo_box (builder, 
402 					  icon_captions_components[i],
403 					  data);
404 	}
405 
406 	g_strfreev (captions);
407 }
408 
409 static void
410 nautilus_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *builder)
411 {
412 	GList *columns;
413 	int i;
414 	gboolean writable;
415 
416 	writable = g_settings_is_writable (nautilus_icon_view_preferences,
417 					   NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
418 
419 	columns = nautilus_get_common_columns ();
420 
421 	for (i = 0; icon_captions_components[i] != NULL; i++) {
422 		GtkWidget *combo_box;
423 
424 		combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
425 								icon_captions_components[i]));
426 
427 		create_icon_caption_combo_box_items (GTK_COMBO_BOX_TEXT (combo_box), columns);
428 		gtk_widget_set_sensitive (combo_box, writable);
429 
430 		g_signal_connect (combo_box, "changed",
431 				  G_CALLBACK (icon_captions_changed_callback),
432 				  builder);
433 	}
434 
435 	nautilus_column_list_free (columns);
436 
437 	update_icon_captions_from_settings (builder);
438 }
439 
440 static void
441 set_columns_from_settings (NautilusColumnChooser *chooser)
442 {
443 	char **visible_columns;
444 	char **column_order;
445 
446 	visible_columns = g_settings_get_strv (nautilus_list_view_preferences,
447 					       NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
448 	column_order = g_settings_get_strv (nautilus_list_view_preferences,
449 					    NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
450 
451 	nautilus_column_chooser_set_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
452 					      visible_columns,
453 					      column_order);
454 
455 	g_strfreev (visible_columns);
456 	g_strfreev (column_order);
457 }
458 
459 static void
460 use_default_callback (NautilusColumnChooser *chooser,
461 		      gpointer user_data)
462 {
463 	g_settings_reset (nautilus_list_view_preferences,
464 			  NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
465 	g_settings_reset (nautilus_list_view_preferences,
466 			  NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
467 	set_columns_from_settings (chooser);
468 }
469 
470 static void
471 nautilus_file_management_properties_dialog_setup_list_column_page (GtkBuilder *builder)
472 {
473 	GtkWidget *chooser;
474 	GtkWidget *box;
475 
476 	chooser = nautilus_column_chooser_new (NULL);
477 	g_signal_connect (chooser, "changed",
478 			  G_CALLBACK (columns_changed_callback), chooser);
479 	g_signal_connect (chooser, "use_default",
480 			  G_CALLBACK (use_default_callback), chooser);
481 
482 	set_columns_from_settings (NAUTILUS_COLUMN_CHOOSER (chooser));
483 
484 	gtk_widget_show (chooser);
485 	box = GTK_WIDGET (gtk_builder_get_object (builder, "list_columns_vbox"));
486 
487 	gtk_box_pack_start (GTK_BOX (box), chooser, TRUE, TRUE, 0);
488 }
489 
490 static void
491 bind_builder_bool (GtkBuilder *builder,
492 		   GSettings *settings,
493 		   const char *widget_name,
494 		   const char *prefs)
495 {
496 	g_settings_bind (settings, prefs,
497 			 gtk_builder_get_object (builder, widget_name),
498 			 "active", G_SETTINGS_BIND_DEFAULT);
499 }
500 
501 static gboolean
502 enum_get_mapping (GValue             *value,
503 		  GVariant           *variant,
504 		  gpointer            user_data)
505 {
506 	const char **enum_values = user_data;
507 	const char *str;
508 	int i;
509 
510 	str = g_variant_get_string (variant, NULL);
511 	for (i = 0; enum_values[i] != NULL; i++) {
512 		if (strcmp (enum_values[i], str) == 0) {
513 			g_value_set_int (value, i);
514 			return TRUE;
515 		}
516 	}
517 
518 	return FALSE;
519 }
520 
521 static GVariant *
522 enum_set_mapping (const GValue       *value,
523 		  const GVariantType *expected_type,
524 		  gpointer            user_data)
525 {
526 	const char **enum_values = user_data;
527 
528 	return g_variant_new_string (enum_values[g_value_get_int (value)]);
529 }
530 
531 static void
532 bind_builder_enum (GtkBuilder *builder,
533 		   GSettings *settings,
534 		   const char *widget_name,
535 		   const char *prefs,
536 		   const char **enum_values)
537 {
538 	g_settings_bind_with_mapping (settings, prefs,
539 				      gtk_builder_get_object (builder, widget_name),
540 				      "active", G_SETTINGS_BIND_DEFAULT,
541 				      enum_get_mapping,
542 				      enum_set_mapping,
543 				      enum_values, NULL);
544 }
545 
546 typedef struct {
547 	const guint64 *values;
548 	int n_values;
549 } UIntEnumBinding;
550 
551 static gboolean
552 uint_enum_get_mapping (GValue             *value,
553 		       GVariant           *variant,
554 		       gpointer            user_data)
555 {
556 	UIntEnumBinding *binding = user_data;
557 	guint64 v;
558 	int i;
559 
560 	v = g_variant_get_uint64 (variant);
561 	for (i = 0; i < binding->n_values; i++) {
562 		if (binding->values[i] >= v) {
563 			g_value_set_int (value, i);
564 			return TRUE;
565 		}
566 	}
567 
568 	return FALSE;
569 }
570 
571 static GVariant *
572 uint_enum_set_mapping (const GValue       *value,
573 		       const GVariantType *expected_type,
574 		       gpointer            user_data)
575 {
576 	UIntEnumBinding *binding = user_data;
577 
578 	return g_variant_new_uint64 (binding->values[g_value_get_int (value)]);
579 }
580 
581 static void
582 bind_builder_uint_enum (GtkBuilder *builder,
583 			GSettings *settings,
584 			const char *widget_name,
585 			const char *prefs,
586 			const guint64 *values,
587 			int n_values)
588 {
589 	UIntEnumBinding *binding;
590 
591 	binding = g_new (UIntEnumBinding, 1);
592 	binding->values = values;
593 	binding->n_values = n_values;
594 
595 	g_settings_bind_with_mapping (settings, prefs,
596 				      gtk_builder_get_object (builder, widget_name),
597 				      "active", G_SETTINGS_BIND_DEFAULT,
598 				      uint_enum_get_mapping,
599 				      uint_enum_set_mapping,
600 				      binding, g_free);
601 }
602 
603 static GVariant *
604 radio_mapping_set (const GValue *gvalue,
605 		   const GVariantType *expected_type,
606 		   gpointer user_data)
607 {
608 	const gchar *widget_value = user_data;
609 	GVariant *retval = NULL;
610 
611 	if (g_value_get_boolean (gvalue)) {
612 		retval = g_variant_new_string (widget_value);
613 	}
614 
615 	return retval;
616 }
617 
618 static gboolean
619 radio_mapping_get (GValue *gvalue,
620 		   GVariant *variant,
621 		   gpointer user_data)
622 {
623 	const gchar *widget_value = user_data;
624 	const gchar *value;
625 
626 	value = g_variant_get_string (variant, NULL);
627 
628 	if (g_strcmp0 (value, widget_value) == 0) {
629 		g_value_set_boolean (gvalue, TRUE);
630 	} else {
631 		g_value_set_boolean (gvalue, FALSE);
632 	}
633 
634 	return TRUE;
635 }
636 
637 static void
638 bind_builder_radio (GtkBuilder *builder,
639 		    GSettings *settings,
640 		    const char **widget_names,
641 		    const char *prefs,
642 		    const char **values)
643 {
644 	GtkWidget *button;
645 	int i;
646 
647 	for (i = 0; widget_names[i] != NULL; i++) {
648 		button = GTK_WIDGET (gtk_builder_get_object (builder, widget_names[i]));
649 
650 		g_settings_bind_with_mapping (settings, prefs,
651 					      button, "active",
652 					      G_SETTINGS_BIND_DEFAULT,
653 					      radio_mapping_get, radio_mapping_set,
654 					      (gpointer) values[i], NULL);
655 	}
656 }
657 
658 
659 static  void
660 nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *window)
661 {
662 	GtkWidget *dialog;
663 
664 	/* setup UI */
665 	nautilus_file_management_properties_size_group_create (builder,
666 							       "views_label",
667 							       4);
668 	nautilus_file_management_properties_size_group_create (builder,
669 							       "captions_label",
670 							       3);
671 	nautilus_file_management_properties_size_group_create (builder,
672 							       "preview_label",
673 							       3);
674 
675 	/* setup preferences */
676 	bind_builder_bool (builder, nautilus_preferences,
677 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
678 			   NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
679 
680 	bind_builder_bool (builder, nautilus_preferences,
681 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET,
682 			   NAUTILUS_PREFERENCES_CONFIRM_TRASH);
683 	bind_builder_bool (builder, nautilus_preferences,
684 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET,
685 			   NAUTILUS_PREFERENCES_ENABLE_DELETE);
686 	bind_builder_bool (builder, nautilus_preferences,
687 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
688 			   NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
689 
690 	bind_builder_enum (builder, nautilus_preferences,
691 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET,
692 			   NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
693 			   (const char **) default_view_values);
694 	bind_builder_enum (builder, nautilus_icon_view_preferences,
695 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET,
696 			   NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
697 			   (const char **) zoom_values);
698 	bind_builder_enum (builder, nautilus_list_view_preferences,
699 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET,
700 			   NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
701 			   (const char **) zoom_values);
702 	bind_builder_enum (builder, nautilus_preferences,
703 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
704 			   NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER,
705 			   (const char **) sort_order_values);
706 	bind_builder_enum (builder, nautilus_preferences,
707 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FILES_WIDGET,
708 			   NAUTILUS_PREFERENCES_SHOW_FILE_THUMBNAILS,
709 			   (const char **) preview_values);
710 	bind_builder_enum (builder, nautilus_preferences,
711 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET,
712 			   NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
713 			   (const char **) preview_values);
714 
715 	bind_builder_radio (builder, nautilus_preferences,
716 			    (const char **) click_behavior_components,
717 			    NAUTILUS_PREFERENCES_CLICK_POLICY,
718 			    (const char **) click_behavior_values);
719 	bind_builder_radio (builder, nautilus_preferences,
720 			    (const char **) executable_text_components,
721 			    NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
722 			    (const char **) executable_text_values);
723 
724 	bind_builder_uint_enum (builder, nautilus_preferences,
725 				NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET,
726 				NAUTILUS_PREFERENCES_FILE_THUMBNAIL_LIMIT,
727 				thumbnail_limit_values,
728 				G_N_ELEMENTS (thumbnail_limit_values));
729 
730 	nautilus_file_management_properties_dialog_setup_icon_caption_page (builder);
731 	nautilus_file_management_properties_dialog_setup_list_column_page (builder);
732 
733 	/* UI callbacks */
734 	dialog = GTK_WIDGET (gtk_builder_get_object (builder, "file_management_dialog"));
735 	g_signal_connect_data (dialog, "response",
736 			       G_CALLBACK (nautilus_file_management_properties_dialog_response_cb),
737 			       g_object_ref (builder),
738 			       (GClosureNotify)g_object_unref,
739 			       0);
740 	g_signal_connect (dialog, "delete-event",
741 			  G_CALLBACK (gtk_widget_destroy), NULL);
742 
743 	gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-file-manager");
744 
745 	if (window) {
746 		gtk_window_set_screen (GTK_WINDOW (dialog), gtk_window_get_screen(window));
747 	}
748 
749 	preferences_dialog = dialog;
750 	g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &preferences_dialog);
751 	gtk_widget_show (dialog);
752 }
753 
754 void
755 nautilus_file_management_properties_dialog_show (GtkWindow *window)
756 {
757 	GtkBuilder *builder;
758 
759 	if (preferences_dialog != NULL) {
760 		gtk_window_present (GTK_WINDOW (preferences_dialog));
761 		return;
762 	}
763 
764 	builder = gtk_builder_new ();
765 
766 	gtk_builder_add_from_resource (builder,
767 				       "/org/gnome/nautilus/nautilus-file-management-properties.ui",
768 				       NULL);
769 
770 	nautilus_file_management_properties_dialog_setup (builder, window);
771 
772 	g_object_unref (builder);
773 }