3
3
* Copyright (c) 2005-2007 Benedikt Meurer <benny@xfce.org>
4
* Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
5
6
* This program is free software; you can redistribute it and/or modify it
6
7
* under the terms of the GNU General Public License as published by the Free
92
static void thunar_preferences_class_init (ThunarPreferencesClass *klass);
93
static void thunar_preferences_init (ThunarPreferences *preferences);
94
92
static void thunar_preferences_finalize (GObject *object);
95
93
static void thunar_preferences_get_property (GObject *object,
102
100
GParamSpec *pspec);
103
101
static void thunar_preferences_resume_monitor (ThunarPreferences *preferences);
104
102
static void thunar_preferences_suspend_monitor (ThunarPreferences *preferences);
105
static void thunar_preferences_monitor (ThunarVfsMonitor *monitor,
106
ThunarVfsMonitorHandle *handle,
107
ThunarVfsMonitorEvent event,
108
ThunarVfsPath *handle_path,
109
ThunarVfsPath *event_path,
103
static void thunar_preferences_monitor (GFileMonitor *monitor,
106
GFileMonitorEvent event_type,
110
107
gpointer user_data);
111
108
static void thunar_preferences_queue_load (ThunarPreferences *preferences);
112
109
static void thunar_preferences_queue_store (ThunarPreferences *preferences);
127
124
GObject __parent__;
129
ThunarVfsMonitorHandle *handle;
130
ThunarVfsMonitor *monitor;
132
GValue values[N_PROPERTIES];
134
gboolean loading_in_progress;
126
GFileMonitor *monitor;
128
GValue values[N_PROPERTIES];
130
gboolean loading_in_progress;
142
static GObjectClass *thunar_preferences_parent_class;
147
thunar_preferences_get_type (void)
149
static GType type = G_TYPE_INVALID;
151
if (G_UNLIKELY (type == G_TYPE_INVALID))
153
static const GTypeInfo info =
155
sizeof (ThunarPreferencesClass),
158
(GClassInitFunc) thunar_preferences_class_init,
161
sizeof (ThunarPreferences),
163
(GInstanceInitFunc) thunar_preferences_init,
167
type = g_type_register_static (G_TYPE_OBJECT, I_("ThunarPreferences"), &info, 0);
138
G_DEFINE_TYPE (ThunarPreferences, thunar_preferences, G_TYPE_OBJECT)
178
145
GObjectClass *gobject_class;
180
/* determine the parent type class */
181
thunar_preferences_parent_class = g_type_class_peek_parent (klass);
183
147
gobject_class = G_OBJECT_CLASS (klass);
184
148
gobject_class->finalize = thunar_preferences_finalize;
185
149
gobject_class->get_property = thunar_preferences_get_property;
436
400
"last-window-width",
437
401
1, G_MAXINT, 640,
438
402
EXO_PARAM_READWRITE));
405
* ThunarPreferences:last-window-maximized:
407
* The last known maximized state of a #ThunarWindow, which will be used as
408
* default width for newly created windows.
410
g_object_class_install_property (gobject_class,
411
PROP_LAST_WINDOW_FULLSCREEN,
412
g_param_spec_boolean ("last-window-maximized",
413
"LastWindowMaximized",
414
"last-window-maximized",
416
EXO_PARAM_READWRITE));
441
419
* ThunarPreferences:misc-volume-management:
672
650
thunar_preferences_init (ThunarPreferences *preferences)
674
/* grab a reference on the VFS monitor */
675
preferences->monitor = thunar_vfs_monitor_get_default ();
652
preferences->monitor = NULL;
677
654
/* load the settings */
678
655
thunar_preferences_load_idle (preferences);
764
741
thunar_preferences_resume_monitor (ThunarPreferences *preferences)
769
746
/* verify that the monitor is suspended */
770
if (G_LIKELY (preferences->handle == NULL))
747
if (G_LIKELY (preferences->monitor == NULL))
772
749
/* determine the save location for thunarrc to monitor */
773
750
filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "Thunar/thunarrc", TRUE);
774
751
if (G_LIKELY (filename != NULL))
776
/* determine the VFS path for the filename */
777
path = thunar_vfs_path_new (filename, NULL);
778
if (G_LIKELY (path != NULL))
780
/* add the monitor handle for the file */
781
preferences->handle = thunar_vfs_monitor_add_file (preferences->monitor, path, thunar_preferences_monitor, preferences);
782
thunar_vfs_path_unref (path);
753
/* monitor this file */
754
file = g_file_new_for_path (filename);
755
preferences->monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL);
756
if (G_LIKELY (preferences->monitor != NULL))
757
g_signal_connect (preferences->monitor, "changed", G_CALLBACK (thunar_preferences_monitor), preferences);
758
g_object_unref (file);
785
760
/* release the filename */
786
761
g_free (filename);
794
769
thunar_preferences_suspend_monitor (ThunarPreferences *preferences)
796
771
/* verify that the monitor is active */
797
if (G_LIKELY (preferences->handle != NULL))
772
if (G_LIKELY (preferences->monitor != NULL
773
&& !g_file_monitor_is_cancelled (preferences->monitor)))
799
775
/* disconnect the handle from the monitor */
800
thunar_vfs_monitor_remove (preferences->monitor, preferences->handle);
801
preferences->handle = NULL;
776
g_file_monitor_cancel (preferences->monitor);
808
thunar_preferences_monitor (ThunarVfsMonitor *monitor,
809
ThunarVfsMonitorHandle *handle,
810
ThunarVfsMonitorEvent event,
811
ThunarVfsPath *handle_path,
812
ThunarVfsPath *event_path,
783
thunar_preferences_monitor (GFileMonitor *monitor,
786
GFileMonitorEvent event_type,
813
787
gpointer user_data)
815
789
ThunarPreferences *preferences = THUNAR_PREFERENCES (user_data);
817
791
_thunar_return_if_fail (THUNAR_IS_PREFERENCES (preferences));
818
_thunar_return_if_fail (THUNAR_VFS_IS_MONITOR (monitor));
792
_thunar_return_if_fail (G_IS_FILE_MONITOR (monitor));
819
793
_thunar_return_if_fail (preferences->monitor == monitor);
820
_thunar_return_if_fail (preferences->handle == handle);
822
795
/* schedule a reload whenever the file is created/changed */
823
if (event == THUNAR_VFS_MONITOR_EVENT_CHANGED || event == THUNAR_VFS_MONITOR_EVENT_CREATED)
824
thunar_preferences_queue_load (preferences);
796
if (event_type == G_FILE_MONITOR_EVENT_CHANGED
797
|| event_type == G_FILE_MONITOR_EVENT_CREATED)
799
thunar_preferences_queue_load (preferences);