~noskcaj/ubuntu/vivid/thunar/1.6.4

« back to all changes in this revision

Viewing changes to thunar/thunar-preferences.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2010-12-04 16:46:20 UTC
  • mto: (2.1.3 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: james.westby@ubuntu.com-20101204164620-h7p4t2e9z6hfhz6l
Tags: upstream-1.1.4
ImportĀ upstreamĀ versionĀ 1.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* $Id$ */
2
2
/*-
3
3
 * Copyright (c) 2005-2007 Benedikt Meurer <benny@xfce.org>
 
4
 * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
4
5
 *
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
37
38
#include <string.h>
38
39
#endif
39
40
 
40
 
#include <thunar-vfs/thunar-vfs.h>
41
 
 
42
41
#include <thunar/thunar-enum-types.h>
43
42
#include <thunar/thunar-gobject-extensions.h>
44
43
#include <thunar/thunar-preferences.h>
68
67
  PROP_LAST_VIEW,
69
68
  PROP_LAST_WINDOW_HEIGHT,
70
69
  PROP_LAST_WINDOW_WIDTH,
 
70
  PROP_LAST_WINDOW_FULLSCREEN,
71
71
  PROP_MISC_VOLUME_MANAGEMENT,
72
72
  PROP_MISC_CASE_SENSITIVE,
73
73
  PROP_MISC_DATE_STYLE,
89
89
 
90
90
 
91
91
 
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,
96
94
                                                       guint                   prop_id,
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,
 
104
                                                       GFile                  *file,
 
105
                                                       GFile                  *other_file,
 
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);
126
123
{
127
124
  GObject __parent__;
128
125
 
129
 
  ThunarVfsMonitorHandle *handle;
130
 
  ThunarVfsMonitor       *monitor;
131
 
 
132
 
  GValue                  values[N_PROPERTIES];
133
 
 
134
 
  gboolean                loading_in_progress;
135
 
 
136
 
  gint                    load_idle_id;
137
 
  gint                    store_idle_id;
 
126
  GFileMonitor *monitor;
 
127
 
 
128
  GValue        values[N_PROPERTIES];
 
129
 
 
130
  gboolean      loading_in_progress;
 
131
 
 
132
  gint          load_idle_id;
 
133
  gint          store_idle_id;
138
134
};
139
135
 
140
136
 
141
137
 
142
 
static GObjectClass *thunar_preferences_parent_class;
143
 
 
144
 
 
145
 
 
146
 
GType
147
 
thunar_preferences_get_type (void)
148
 
{
149
 
  static GType type = G_TYPE_INVALID;
150
 
 
151
 
  if (G_UNLIKELY (type == G_TYPE_INVALID))
152
 
    {
153
 
      static const GTypeInfo info =
154
 
      {
155
 
        sizeof (ThunarPreferencesClass),
156
 
        NULL,
157
 
        NULL,
158
 
        (GClassInitFunc) thunar_preferences_class_init,
159
 
        NULL,
160
 
        NULL,
161
 
        sizeof (ThunarPreferences),
162
 
        0,
163
 
        (GInstanceInitFunc) thunar_preferences_init,
164
 
        NULL,
165
 
      };
166
 
 
167
 
      type = g_type_register_static (G_TYPE_OBJECT, I_("ThunarPreferences"), &info, 0);
168
 
    }
169
 
 
170
 
  return type;
171
 
}
 
138
G_DEFINE_TYPE (ThunarPreferences, thunar_preferences, G_TYPE_OBJECT)
172
139
 
173
140
 
174
141
 
177
144
{
178
145
  GObjectClass *gobject_class;
179
146
 
180
 
  /* determine the parent type class */
181
 
  thunar_preferences_parent_class = g_type_class_peek_parent (klass);
182
 
 
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));
 
403
                                                     
 
404
  /**
 
405
   * ThunarPreferences:last-window-maximized:
 
406
   *
 
407
   * The last known maximized state of a #ThunarWindow, which will be used as
 
408
   * default width for newly created windows.
 
409
   **/
 
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",
 
415
                                                         FALSE,
 
416
                                                         EXO_PARAM_READWRITE));
439
417
 
440
418
  /**
441
419
   * ThunarPreferences:misc-volume-management:
671
649
static void
672
650
thunar_preferences_init (ThunarPreferences *preferences)
673
651
{
674
 
  /* grab a reference on the VFS monitor */
675
 
  preferences->monitor = thunar_vfs_monitor_get_default ();
 
652
  preferences->monitor = NULL;
676
653
 
677
654
  /* load the settings */
678
655
  thunar_preferences_load_idle (preferences);
763
740
static void
764
741
thunar_preferences_resume_monitor (ThunarPreferences *preferences)
765
742
{
766
 
  ThunarVfsPath *path;
767
 
  gchar         *filename;
 
743
  GFile *file;
 
744
  gchar *filename;
768
745
 
769
746
  /* verify that the monitor is suspended */
770
 
  if (G_LIKELY (preferences->handle == NULL))
 
747
  if (G_LIKELY (preferences->monitor == NULL))
771
748
    {
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))
775
752
        {
776
 
          /* determine the VFS path for the filename */
777
 
          path = thunar_vfs_path_new (filename, NULL);
778
 
          if (G_LIKELY (path != NULL))
779
 
            {
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);
783
 
            }
 
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);
784
759
 
785
760
          /* release the filename */
786
761
          g_free (filename);
794
769
thunar_preferences_suspend_monitor (ThunarPreferences *preferences)
795
770
{
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)))
798
774
    {
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);
802
777
    }
803
778
}
804
779
 
805
780
 
806
781
 
807
782
static void
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,
 
784
                            GFile                  *file,
 
785
                            GFile                  *other_file,
 
786
                            GFileMonitorEvent       event_type,
813
787
                            gpointer                user_data)
814
788
{
815
789
  ThunarPreferences *preferences = THUNAR_PREFERENCES (user_data);
816
790
 
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);
821
794
 
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)
 
798
    {
 
799
      thunar_preferences_queue_load (preferences);
 
800
    }
825
801
}
826
802
 
827
803