~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to gio/glocalfilemonitor.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
                                                       G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
151
151
}
152
152
 
153
 
static gpointer
154
 
get_default_local_file_monitor (gpointer data)
155
 
{
156
 
  GLocalFileMonitorClass *chosen_class;
157
 
  GLocalFileMonitorClass **ret = data;
158
 
  GIOExtensionPoint *ep;
159
 
  GList *extensions, *l;
160
 
 
161
 
  _g_io_modules_ensure_loaded ();
162
 
 
163
 
  ep = g_io_extension_point_lookup (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME);
164
 
 
165
 
  extensions = g_io_extension_point_get_extensions (ep);
166
 
  
167
 
  chosen_class = NULL;
168
 
  for (l = extensions; l != NULL; l = l->next)
169
 
    {
170
 
      GIOExtension *extension = l->data;
171
 
      GLocalFileMonitorClass *klass;
172
 
      
173
 
      klass = G_LOCAL_FILE_MONITOR_CLASS (g_io_extension_ref_class (extension));
174
 
      
175
 
      if (klass->is_supported ())
176
 
        {
177
 
          chosen_class = klass;
178
 
          break;
179
 
        }
180
 
      else
181
 
        g_type_class_unref (klass);
182
 
    }
183
 
  
184
 
  if (chosen_class)
185
 
    {
186
 
      *ret = chosen_class;
187
 
      return (gpointer)G_TYPE_FROM_CLASS (chosen_class);
188
 
    }
189
 
  else
190
 
    return (gpointer)G_TYPE_INVALID;
191
 
}
192
 
 
193
153
GFileMonitor*
194
154
_g_local_file_monitor_new (const char         *pathname,
195
 
                           GFileMonitorFlags   flags,
196
 
                           GError            **error)
 
155
                           GFileMonitorFlags   flags,
 
156
                           gboolean            is_remote_fs,
 
157
                           GError            **error)
197
158
{
198
 
  static GOnce once_init = G_ONCE_INIT;
199
 
  GTypeClass *type_class;
200
 
  GFileMonitor *monitor;
201
 
  GType type;
202
 
 
203
 
  type_class = NULL;
204
 
  g_once (&once_init, get_default_local_file_monitor, &type_class);
205
 
  type = (GType)once_init.retval;
206
 
 
207
 
  monitor = NULL;
 
159
  GFileMonitor *monitor = NULL;
 
160
  GType type = G_TYPE_INVALID;
 
161
 
 
162
  if (is_remote_fs)
 
163
    type = _g_io_module_get_default_type (G_NFS_FILE_MONITOR_EXTENSION_POINT_NAME,
 
164
                                          "GIO_USE_FILE_MONITOR",
 
165
                                          G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
 
166
 
 
167
  if (type == G_TYPE_INVALID)
 
168
    type = _g_io_module_get_default_type (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME,
 
169
                                          "GIO_USE_FILE_MONITOR",
 
170
                                          G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
 
171
 
208
172
  if (type != G_TYPE_INVALID)
209
173
    monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, "flags", flags, NULL));
210
174
  else
211
175
    g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
212
176
                         _("Unable to find default local file monitor type"));
213
177
 
214
 
  /* This is non-null on first pass here. Unref the class now.
215
 
   * This is to avoid unloading the module and then loading it
216
 
   * again which would happen if we unrefed the class
217
 
   * before creating the monitor.
218
 
   */
219
 
  
220
 
  if (type_class)
221
 
    g_type_class_unref (type_class);
222
 
  
223
178
  return monitor;
224
179
}