Beispiel #1
0
static GObject *
g_local_file_monitor_constructor (GType                  type,
                                  guint                  n_construct_properties,
                                  GObjectConstructParam *construct_properties)
{
  GObject *obj;
  GLocalFileMonitorClass *klass;
  GObjectClass *parent_class;
  GLocalFileMonitor *local_monitor;
  const gchar *filename = NULL;
  gint i;
  
  klass = G_LOCAL_FILE_MONITOR_CLASS (g_type_class_peek (G_TYPE_LOCAL_FILE_MONITOR));
  parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
  obj = parent_class->constructor (type,
                                   n_construct_properties,
                                   construct_properties);

  local_monitor = G_LOCAL_FILE_MONITOR (obj);

  for (i = 0; i < n_construct_properties; i++)
    {
      if (strcmp ("filename", g_param_spec_get_name (construct_properties[i].pspec)) == 0)
        {
          g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value));
          filename = g_value_get_string (construct_properties[i].value);
          break;
        }
    }

  g_warn_if_fail (filename != NULL);

  local_monitor->filename = g_strdup (filename);
  return obj;
}
Beispiel #2
0
static void
g_local_file_monitor_finalize (GObject *object)
{
  GLocalFileMonitor *local_monitor = G_LOCAL_FILE_MONITOR (object);
  if (local_monitor->filename)
    {
      g_free (local_monitor->filename);
      local_monitor->filename = NULL;
    }

  G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize (object);
}
static void
g_local_file_monitor_get_property (GObject *object, guint prop_id,
                                   GValue *value, GParamSpec *pspec)
{
  GLocalFileMonitor *monitor = G_LOCAL_FILE_MONITOR (object);
  gint64 rate_limit;

  g_assert (prop_id == PROP_RATE_LIMIT);

  rate_limit = g_file_monitor_source_get_rate_limit (monitor->source);
  rate_limit /= G_TIME_SPAN_MILLISECOND;

  g_value_set_int (value, rate_limit);
}