nautilus-file-management-properties.c 20.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */

/* nautilus-file-management-properties.c - Functions to create and show the nautilus preference dialog.

   Copyright (C) 2002 Jan Arne Petersen

   The Gnome Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The Gnome Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.

   Authors: Jan Arne Petersen <jpetersen@uni-bonn.de>
*/

#include <config.h>

#include "nautilus-file-management-properties.h"

29
#include <string.h>
30
#include <time.h>
31
#include <gtk/gtkdialog.h>
32 33
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
34
#include <gtk/gtkmessagedialog.h>
Alexander Larsson's avatar
Alexander Larsson committed
35
#include <gtk/gtknotebook.h>
36
#include <gtk/gtkcombobox.h>
37
#include <gtk/gtksizegroup.h>
Alexander Larsson's avatar
Alexander Larsson committed
38 39

#include <libgnome/gnome-help.h>
40
#include <glib/gi18n.h>
41 42 43 44

#include <glade/glade.h>

#include <eel/eel-gconf-extensions.h>
45
#include <eel/eel-glib-extensions.h>
46
#include <eel/eel-preferences-glade.h>
47
#include <eel/eel-string-list.h>
48

49 50
#include <libnautilus-private/nautilus-column-chooser.h>
#include <libnautilus-private/nautilus-column-utilities.h>
51
#include <libnautilus-private/nautilus-global-preferences.h>
52
#include <libnautilus-private/nautilus-module.h>
53 54

/* string enum preferences */
55 56 57 58 59 60 61 62 63
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "icon_view_zoom_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET "list_view_zoom_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET "sort_order_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET "date_format_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET "preview_text_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET "preview_image_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_SOUND_WIDGET "preview_sound_combobox"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET "preview_folder_combobox"
64 65 66 67

/* bool preferences */
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET "sort_folders_first_checkbutton"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET "compact_layout_checkbutton"
Dave Camp's avatar
Dave Camp committed
68
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET "labels_beside_icons_checkbutton"
69
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET "always_use_browser_checkbutton"
70
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_LOCATION_ENTRY_WIDGET "always_use_location_entry_checkbutton"
71 72 73 74 75 76 77
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET "trash_confirm_checkbutton"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET "trash_delete_checkbutton"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_OPEN_NEW_WINDOW_WIDGET "new_window_checkbutton"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET "hidden_files_checkbutton"
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET "treeview_folders_checkbutton"

/* int enums */
78
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET "preview_image_size_combobox"
79

80
static const char * const default_view_values[] = {
81 82 83 84 85
	"icon_view",
	"list_view",
	NULL
};

86
static const char * const zoom_values[] = {
87 88 89 90 91 92 93 94 95 96
	"smallest",
	"smaller",
	"small",
	"standard",
	"large",
	"larger",
	"largest",
	NULL
};

97
static const char * const sort_order_values[] = {
98 99 100 101 102 103 104 105
	"name",
	"size",
	"type",
	"modification_date",
	"emblems",
	NULL
};

106
static const char * const date_format_values[] = {
107 108 109 110 111 112
	"locale",
	"iso",
	"informal",
	NULL
};

113
static const char * const preview_values[] = {
114 115 116 117 118 119
	"always",
	"local_only",
	"never",
	NULL
};

120
static const char * const click_behavior_components[] = {
121 122 123 124 125
	"single_click_radiobutton",
	"double_click_radiobutton",
	NULL
};

126
static const char * const click_behavior_values[] = {
127 128 129 130 131
	"single",
	"double",
	NULL
};

132
static const char * const executable_text_components[] = {
133 134 135 136 137 138
	"scripts_execute_radiobutton",
	"scripts_view_radiobutton",
	"scripts_confirm_radiobutton",
	NULL
};

139
static const char * const executable_text_values[] = {
140 141 142 143 144 145
	"launch",
	"display",
	"ask",
	NULL
};

146
static const int thumbnail_limit_values[] = {
147 148 149 150 151 152 153
	102400,
	512000,
	1048576,
	3145728,
	5242880,
	10485760,
	104857600,
154
	1073741824,
155 156 157
	-1
};

158
static const char * const icon_captions_components[] = {
159 160 161
	"captions_0_combobox",
	"captions_1_combobox",
	"captions_2_combobox",
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
	NULL
};

static GladeXML *
nautilus_file_management_properties_dialog_create (void)
{
	GladeXML *xml_dialog;

	xml_dialog = glade_xml_new (GLADEDIR "/nautilus-file-management-properties.glade",
				    NULL, NULL);

	return xml_dialog;
}

static void
nautilus_file_management_properties_size_group_create (GladeXML *xml_dialog,
						       char *prefix,
						       int items)
{
	GtkSizeGroup *size_group;
	int i;
	char *item_name;

	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

	for (i = 0; i < items; i++) {	
		item_name = g_strdup_printf ("%s_%d", prefix, i);
		gtk_size_group_add_widget (size_group,
					   glade_xml_get_widget (xml_dialog, item_name));
		g_free (item_name);
	}
193
	g_object_unref (G_OBJECT (size_group));
194 195 196
}

static void
Alexander Larsson's avatar
Alexander Larsson committed
197 198 199
preferences_show_help (GtkWindow *parent,
		       char const *helpfile,
		       char const *sect_id)
200
{
Alexander Larsson's avatar
Alexander Larsson committed
201
	GError *error = NULL;
202 203
	GtkWidget *dialog;

Alexander Larsson's avatar
Alexander Larsson committed
204 205 206 207 208 209 210 211
	g_return_if_fail (helpfile != NULL);
	g_return_if_fail (sect_id != NULL);

	gnome_help_display_desktop (NULL,
				    "user-guide",
				    helpfile, sect_id, &error);

	if (error) {
212 213 214
		dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
						 GTK_DIALOG_DESTROY_WITH_PARENT,
						 GTK_MESSAGE_ERROR,
215
						 GTK_BUTTONS_OK,
Alexander Larsson's avatar
Alexander Larsson committed
216 217
						 _("There was an error displaying help: \n%s"),
						 error->message);
218 219 220 221 222 223

		g_signal_connect (G_OBJECT (dialog),
				  "response", G_CALLBACK (gtk_widget_destroy),
				  NULL);
		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
		gtk_widget_show (dialog);
Alexander Larsson's avatar
Alexander Larsson committed
224 225 226
		g_error_free (error);
	}
}
227

Alexander Larsson's avatar
Alexander Larsson committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242

static void
nautilus_file_management_properties_dialog_response_cb (GtkDialog *parent,
							int response_id,
							GladeXML *xml_dialog)
{
	char *section;

	if (response_id == GTK_RESPONSE_HELP) {
		switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (glade_xml_get_widget (xml_dialog, "notebook1")))) {
		default:
		case 0:
			section = "gosnautilus-438";
			break;
		case 1:
243
			section = "gosnautilus-56";
Alexander Larsson's avatar
Alexander Larsson committed
244 245 246 247 248
			break;
		case 2:
			section = "gosnautilus-439";
			break;
		case 3:
249
			section = "gosnautilus-490";
Alexander Larsson's avatar
Alexander Larsson committed
250
			break;
251 252
		case 4:
			section = "gosnautilus-60";
Alexander Larsson's avatar
Alexander Larsson committed
253
		}
254
		preferences_show_help (GTK_WINDOW (parent), "user-guide.xml", section);
255 256 257 258 259 260 261 262 263 264 265
	} else if (response_id == GTK_RESPONSE_CLOSE) {
		/* remove gconf monitors */
		eel_gconf_monitor_remove ("/apps/nautilus/icon_view");
		eel_gconf_monitor_remove ("/apps/nautilus/list_view");
		eel_gconf_monitor_remove ("/apps/nautilus/preferences");
		eel_gconf_monitor_remove ("/desktop/gnome/file_views");

		g_object_unref (xml_dialog);
	}
}

266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
static void
columns_changed_callback (NautilusColumnChooser *chooser,
			  gpointer callback_data)
{
	GList *visible_columns;
	GList *column_order;
	
	nautilus_column_chooser_get_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
					      &visible_columns,
					      &column_order);

	eel_preferences_set_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS, visible_columns);
	eel_preferences_set_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER, column_order);

	eel_g_list_free_deep (visible_columns);
	eel_g_list_free_deep (column_order);
}

284 285 286
static void
create_icon_caption_combo_box_items (GtkComboBox *combo_box,
			             GList *columns)
287 288
{
	GList *l;
289
	EelStringList *column_names;
290

291 292 293 294
	column_names = eel_string_list_new (FALSE);
	
	gtk_combo_box_append_text (combo_box, _("None"));
	eel_string_list_insert (column_names, "none");
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313

	for (l = columns; l != NULL; l = l->next) {
		NautilusColumn *column;
		char *name;
		char *label;

		column = NAUTILUS_COLUMN (l->data);
		
		g_object_get (G_OBJECT (column), 
			      "name", &name, "label", &label, 
			      NULL);

		/* Don't show name here, it doesn't make sense */
		if (!strcmp (name, "name")) {
			g_free (name);
			g_free (label);
			continue;
		}
		
314 315 316
		gtk_combo_box_append_text (combo_box, label);
		eel_string_list_insert (column_names, name);

317 318 319
		g_free (name);
		g_free (label);
	}
320 321 322
	g_object_set_data_full (G_OBJECT (combo_box), "column_names",
			        column_names,
			        (GDestroyNotify) eel_string_list_free);
323 324 325
}

static void
326
icon_captions_changed_callback (GtkComboBox *combo_box,
327 328 329 330 331 332 333 334 335 336 337
				gpointer user_data)
{
	GList *captions;
	GladeXML *xml;
	int i;
	
	xml = GLADE_XML (user_data);

	captions = NULL;

	for (i = 0; icon_captions_components[i] != NULL; i++) {
338 339 340
		GtkWidget *combo_box;
		int active;
		EelStringList *column_names;
341 342
		char *name;
		
343 344 345
		combo_box = glade_xml_get_widget
			    (GLADE_XML (xml), icon_captions_components[i]);
		active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
346

347 348 349 350
		column_names = g_object_get_data (G_OBJECT (combo_box), "column_names");
		
		name = eel_string_list_nth (column_names, active);
		captions = g_list_prepend (captions, name);
351 352 353 354 355 356 357
	}
	captions = g_list_reverse (captions);
	eel_preferences_set_string_glist (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS, captions);
	eel_g_list_free_deep (captions);
}

static void
358 359 360
update_caption_combo_box (GladeXML *xml,
			  const char *combo_box_name,
			  const char *name)
361
{
362
	GtkWidget *combo_box;
363
	int i;
364
	EelStringList *column_names;
365
	
366
	combo_box = glade_xml_get_widget (xml, combo_box_name);
367 368

	g_signal_handlers_block_by_func
369
		(combo_box,
370 371
		 G_CALLBACK (icon_captions_changed_callback),
		 xml);
372 373 374 375 376 377 378

	column_names = g_object_get_data (G_OBJECT (combo_box), 
					  "column_names");

	for (i = 0; i < eel_string_list_get_length (column_names); i++) {
		if (!strcmp (name, eel_string_list_peek_nth (column_names, i))) {
			gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), i);
379 380 381 382 383
			break;
		}
	}

	g_signal_handlers_unblock_by_func
384
		(combo_box,
385 386 387 388 389 390 391 392 393 394
		 G_CALLBACK (icon_captions_changed_callback),
		 xml);
}

static void
update_icon_captions_from_gconf (GladeXML *xml)
{
	GList *captions;
	int i;
	GList *l;
395
	char *data;
396 397 398 399

	captions = eel_preferences_get_string_glist (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);

	for (l = captions, i = 0; 
400 401 402 403 404 405 406 407 408
	     icon_captions_components[i] != NULL;
	     i++) {
		if (l != NULL) {
			data = l->data;
			l = l->next;
		} else {
			data = "none";
		}
		
409 410
		update_caption_combo_box (xml, 
					  icon_captions_components[i],
411
					  data);
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
	}
	eel_g_list_free_deep (captions);
}

static void
nautilus_file_management_properties_dialog_setup_icon_caption_page (GladeXML *xml_dialog)
{
	GList *columns;
	int i;
	gboolean writable;
	
	writable = eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);

	columns = nautilus_get_all_columns ();
	
	for (i = 0; icon_captions_components[i] != NULL; i++) {
428
		GtkWidget *combo_box;
429
		
430
		combo_box = glade_xml_get_widget (xml_dialog, 
431 432
						    icon_captions_components[i]);

433 434
		create_icon_caption_combo_box_items (GTK_COMBO_BOX (combo_box), columns);
		gtk_widget_set_sensitive (combo_box, writable);
435

436
		g_signal_connect (combo_box, "changed", 
437 438 439 440 441 442 443 444 445
				  G_CALLBACK (icon_captions_changed_callback),
				  xml_dialog);
	}

	nautilus_column_list_free (columns);

	update_icon_captions_from_gconf (xml_dialog);
}

446 447 448
static void
create_date_format_menu (GladeXML *xml_dialog)
{
449
	GtkWidget *combo_box;
450 451 452
	gchar *date_string;
	time_t now_raw;
	struct tm* now;
453 454
	combo_box = glade_xml_get_widget (xml_dialog,
					  NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET);
455 456 457 458 459

	now_raw = time (NULL);
	now = localtime (&now_raw);

	date_string = eel_strdup_strftime ("%c", now);
460
	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
461 462 463
	g_free (date_string);

	date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now);
464
	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
465 466 467
	g_free (date_string);

	date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now);
468
	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
469 470 471
	g_free (date_string);
}

472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
static void
set_columns_from_gconf (NautilusColumnChooser *chooser)
{
	GList *visible_columns;
	GList *column_order;
	
	visible_columns = eel_preferences_get_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
	column_order = eel_preferences_get_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);

	nautilus_column_chooser_set_settings (NAUTILUS_COLUMN_CHOOSER (chooser), 
					      visible_columns,
					      column_order);


	eel_g_list_free_deep (visible_columns);
	eel_g_list_free_deep (column_order);
}

static void 
use_default_callback (NautilusColumnChooser *chooser, 
		      gpointer user_data)
{
	eel_preferences_unset (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
	eel_preferences_unset (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
	set_columns_from_gconf (chooser);
}

static void
nautilus_file_management_properties_dialog_setup_list_column_page (GladeXML *xml_dialog)
{
	GtkWidget *chooser;
	GtkWidget *box;
	
	chooser = nautilus_column_chooser_new ();
	g_signal_connect (chooser, "changed", 
			  G_CALLBACK (columns_changed_callback), chooser);
	g_signal_connect (chooser, "use_default", 
			  G_CALLBACK (use_default_callback), chooser);

	set_columns_from_gconf (NAUTILUS_COLUMN_CHOOSER (chooser));

	gtk_widget_show (chooser);
	box = glade_xml_get_widget (xml_dialog, "list_columns_vbox");
	
	gtk_box_pack_start (GTK_BOX (box), chooser, TRUE, TRUE, 0);
}

519 520
static  void
nautilus_file_management_properties_dialog_setup (GladeXML *xml_dialog, GtkWindow *window)
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
{
	GtkWidget *dialog;

	/* setup gconf stuff */
	eel_gconf_monitor_add ("/apps/nautilus/icon_view");
	eel_gconf_preload_cache ("/apps/nautilus/icon_view", GCONF_CLIENT_PRELOAD_ONELEVEL);
	eel_gconf_monitor_add ("/apps/nautilus/list_view");
	eel_gconf_preload_cache ("/apps/nautilus/list_view", GCONF_CLIENT_PRELOAD_ONELEVEL);
	eel_gconf_monitor_add ("/apps/nautilus/preferences");
	eel_gconf_preload_cache ("/apps/nautilus/preferences", GCONF_CLIENT_PRELOAD_ONELEVEL);
	eel_gconf_monitor_add ("/desktop/gnome/file_views");
	eel_gconf_preload_cache ("/desktop/gnome/file_views", GCONF_CLIENT_PRELOAD_ONELEVEL);

	/* setup UI */
	nautilus_file_management_properties_size_group_create (xml_dialog, 
							       "views_label",
							       4);
	nautilus_file_management_properties_size_group_create (xml_dialog,
							       "captions_label",
							       3);
	nautilus_file_management_properties_size_group_create (xml_dialog,
							       "preview_label",
							       5);
544
	create_date_format_menu (xml_dialog);
545 546 547 548 549

	/* setup preferences */
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET,
					    NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT);
Dave Camp's avatar
Dave Camp committed
550 551 552
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET,
					    NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
553 554 555
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
					    NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST); 
556 557 558
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET,
					    NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
559 560 561 562 563 564 565 566 567
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET,
					    NAUTILUS_PREFERENCES_CONFIRM_TRASH);
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET,
					    NAUTILUS_PREFERENCES_ENABLE_DELETE);
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
					    NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
568 569 570
	eel_preferences_glade_connect_bool_slave (xml_dialog,
						  NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
						  NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
571 572 573
	eel_preferences_glade_connect_bool (xml_dialog,
					    NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET,
					    NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES);
574

575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET,
							     NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
							     (const char **) default_view_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET,						     
							     NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
							     (const char **) zoom_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET,
							     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
							     (const char **) zoom_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
							     NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
							     (const char **) sort_order_values);
	eel_preferences_glade_connect_string_enum_combo_box_slave (xml_dialog,
								   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
								   NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET,
							     NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
							     (const char **) preview_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET,
							     NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
							     (const char **) preview_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_SOUND_WIDGET,
							     NAUTILUS_PREFERENCES_PREVIEW_SOUND,
							     (const char **) preview_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET,
							     NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
							     (const char **) preview_values);
	eel_preferences_glade_connect_string_enum_combo_box (xml_dialog,
							     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
							     NAUTILUS_PREFERENCES_DATE_FORMAT,
							     (const char **) date_format_values);
614 615

	eel_preferences_glade_connect_string_enum_radio_button (xml_dialog,
616
								(const char **) click_behavior_components,
617
								NAUTILUS_PREFERENCES_CLICK_POLICY,
618
								(const char **) click_behavior_values);
619
	eel_preferences_glade_connect_string_enum_radio_button (xml_dialog,
620
								(const char **) executable_text_components,
621
								NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
622
								(const char **) executable_text_values);
623 624 625 626

	eel_preferences_glade_connect_int_enum (xml_dialog,
						NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET,
						NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
627
						(const int *) thumbnail_limit_values);
628

629 630 631 632

	nautilus_file_management_properties_dialog_setup_icon_caption_page (xml_dialog);
	nautilus_file_management_properties_dialog_setup_list_column_page (xml_dialog);
	
633 634 635 636 637 638
	/* UI callbacks */
	dialog = glade_xml_get_widget (xml_dialog, "file_management_dialog");
	g_signal_connect (G_OBJECT (dialog), "response",
			  G_CALLBACK (nautilus_file_management_properties_dialog_response_cb),
			  xml_dialog);

639
	gtk_window_set_icon_name (GTK_WINDOW (dialog), "file-manager");
640 641 642 643 644

	if (window) {
		gtk_window_set_screen (GTK_WINDOW (dialog), gtk_window_get_screen(window));
	}

645 646 647
	gtk_widget_show (dialog);
}

648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
static gboolean
delete_event_callback (GtkWidget       *widget,
		       GdkEventAny     *event,
		       gpointer         data)
{
	void (*response_callback) (GtkDialog *dialog,
				   gint response_id);

	response_callback = data;

	response_callback (GTK_DIALOG (widget), GTK_RESPONSE_CLOSE);
	
	return TRUE;
}

663
void
664
nautilus_file_management_properties_dialog_show (GCallback close_callback, GtkWindow *window)
665 666 667 668 669 670 671
{
	GladeXML *xml_dialog;

	xml_dialog = nautilus_file_management_properties_dialog_create ();
	
	g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "file_management_dialog")),
			  "response", close_callback, NULL);
672 673
	g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "file_management_dialog")),
			  "delete_event", G_CALLBACK (delete_event_callback), close_callback);
674

675
	nautilus_file_management_properties_dialog_setup (xml_dialog, window);
676
}