Ejemplo n.º 1
0
static void
copy_properties (GObject *dst,
                 GObject *src)
{
    GParamSpec **props;
    guint n_props;

    props = g_object_class_list_properties (G_OBJECT_GET_CLASS (src), &n_props);

    for (guint i = 0; i < n_props; i++) {
        if (props[i]->flags & G_PARAM_WRITABLE) {
            GValue value = {0};

            g_value_init (&value, props[i]->value_type);
            g_object_get_property (src, props[i]->name, &value);

            if (UFO_IS_NODE_CLASS (&(props[i]->value_type))) {
                g_value_set_object (&value, ufo_node_copy_real (UFO_NODE(g_value_get_object(&value)), NULL));
            }

            g_object_set_property (dst, props[i]->name, &value);
        }
    }

    g_free (props);
}
Ejemplo n.º 2
0
GObject *
g_object_clone(GObject *src)
{
    GObject *dst;
    GParameter *params;
    GParamSpec **specs;
    guint n, n_specs, n_params;

    specs = g_object_class_list_properties(G_OBJECT_GET_CLASS(src), &n_specs);
    params = g_new0(GParameter, n_specs);
    n_params = 0;

    for (n = 0; n < n_specs; ++n)
        if (strcmp(specs[n]->name, "parent") &&
            (specs[n]->flags & G_PARAM_READWRITE) == G_PARAM_READWRITE) {
            params[n_params].name = g_intern_string(specs[n]->name);
            g_value_init(&params[n_params].value, specs[n]->value_type);
            g_object_get_property(src, specs[n]->name, &params[n_params].value);
            ++ n_params;
        }

    dst = g_object_newv(G_TYPE_FROM_INSTANCE(src), n_params, params);
    g_free(specs);
    g_free(params);

    return dst;
}
Ejemplo n.º 3
0
void print_properties(GObject *object)
{
	GObjectClass *oclass;
	GParamSpec **specs;
	guint n;
	guint i;

	oclass = G_OBJECT_GET_CLASS(object);
	specs = g_object_class_list_properties(oclass, &n);
	for (i = 0; i < n; i++) {
		GParamSpec *spec = specs[i];
		GValue value = { 0 };
		gchar *str;

		g_value_init(&value, spec->value_type);
		g_object_get_property(object, spec->name, &value);
		str = g_strdup_value_contents(&value);

		g_print("property '%s' is '%s'\n", spec->name, str);

		g_value_unset(&value);
		g_free(str);
	}

	g_free(specs);
}
Ejemplo n.º 4
0
static VALUE
gobj_s_properties(int argc, VALUE* argv, VALUE self)
{
    GObjectClass* oclass = g_type_class_ref(CLASS2GTYPE(self));
    guint n_properties;
    GParamSpec** props;
    VALUE inherited_too;
    VALUE ary;
    guint i;

    if (rb_scan_args(argc, argv, "01", &inherited_too) == 0)
        inherited_too = Qtrue;

    props = g_object_class_list_properties(oclass, &n_properties);

    ary = rb_ary_new();
    for (i = 0; i < n_properties; i++){
        if (RVAL2CBOOL(inherited_too)
            || GTYPE2CLASS(props[i]->owner_type) == self)
            rb_ary_push(ary, rb_str_new2(props[i]->name));
    }
    g_free(props);
    g_type_class_unref(oclass);
    return ary;
}
Ejemplo n.º 5
0
static void
add_fields (GString          *str,
            GomResourceClass *klass)
{
   GParamSpec **pspecs;
   gboolean mapped = FALSE;
   guint n_pspecs;
   guint i;

   pspecs = g_object_class_list_properties(G_OBJECT_CLASS(klass), &n_pspecs);
   for (i = 0; i < n_pspecs; i++) {
      if (is_mapped(pspecs[i])) {
         if (mapped) {
            g_string_append(str, ", ");
         }
         klass = g_type_class_peek(pspecs[i]->owner_type);
         g_string_append_printf(str, "'%s'.'%s' AS '%s'",
                                klass->table,
                                pspecs[i]->name,
                                pspecs[i]->name);
         mapped = TRUE;
      }
   }
   g_free(pspecs);

   g_string_append(str, " ");
}
Ejemplo n.º 6
0
/**
 * gimp_rc_migrate:
 * @rc: a #GimpRc object.
 *
 * Resets all GimpParamConfigPath properties of the passed rc object
 * to their default values, in order to prevent paths in a migrated
 * gimprc to refer to folders in the old GIMP's user directory.
 **/
void
gimp_rc_migrate (GimpRc *rc)
{
  GParamSpec **pspecs;
  guint        n_pspecs;
  gint         i;

  g_return_if_fail (GIMP_IS_RC (rc));

  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (rc), &n_pspecs);

  for (i = 0; i < n_pspecs; i++)
    {
      GParamSpec *pspec = pspecs[i];

      if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
        {
          GValue value = { 0, };

          g_value_init (&value, pspec->value_type);

          g_param_value_set_default (pspec, &value);
          g_object_set_property (G_OBJECT (rc), pspec->name, &value);

          g_value_unset (&value);
        }
    }

  g_free (pspecs);
}
Ejemplo n.º 7
0
json_t *json_gobject_serialize (GObject *gobject)
{
    json_t *object = json_object();
    GParamSpec **pspecs;
    guint n_pspecs, i;

    pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (gobject), &n_pspecs);

    for (i=0; i!=n_pspecs; ++i) {
        json_t *node;
        GParamSpec *pspec = pspecs[i];
        GValue value = { 0, };

        g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
        g_object_get_property(gobject, pspec->name, &value);
        node=json_serialize_pspec (&value);

        if (node)
            json_object_set_new (object, pspec->name, node);

        g_value_unset (&value);
    }

    g_free (pspecs);

    return object;

}
Ejemplo n.º 8
0
static void
__statement_update_add_metadata_fields (MidgardDBObjectClass *klass, GString *sql)
{
	MidgardMetadataClass *mklass = MGD_DBCLASS_METADATA_CLASS (klass);
	if (!mklass)
		return;

	guint i;
	guint n_prop;
	GParamSpec **pspecs = g_object_class_list_properties (G_OBJECT_CLASS (mklass), &n_prop);

	if (!pspecs)
		return;

	for (i = 0; i < n_prop; i++) {
		const gchar *col_name = midgard_core_class_get_property_colname (MIDGARD_DBOBJECT_CLASS (mklass), pspecs[i]->name);
		if (!col_name)
			continue;
		const gchar *type_name = g_type_name (pspecs[i]->value_type);
		if (pspecs[i]->value_type == MIDGARD_TYPE_TIMESTAMP)
			type_name = "string";
		g_string_append_printf (sql, ", %s=##%s::%s", col_name, col_name, type_name);
	}

	g_free (pspecs);
}
Ejemplo n.º 9
0
static void
gobj_mark(gpointer ptr)
{
    GObject* gobj = ptr;
    guint n_properties;
    GParamSpec** properties;
    GValue gval = {0,};
    guint i;

    properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(gobj), &n_properties);

    for (i = 0; i < n_properties; i++) {
        GParamSpec* pspec = properties[i];
        GType value_type = G_PARAM_SPEC_VALUE_TYPE(pspec);
        if (G_TYPE_FUNDAMENTAL(value_type) != G_TYPE_OBJECT) continue;
        if (!(pspec->flags & G_PARAM_READABLE)) continue;
        /* FIXME: exclude types that doesn't have identity. */

        {
            g_value_init(&gval, value_type);
            g_object_get_property(gobj, pspec->name, &gval);
            rbgobj_gc_mark_gvalue(&gval);
            g_value_unset(&gval);
        }
    }

    g_free(properties);
}
static void
test_defaults (GType type, const char *name)
{
	GParamSpec **property_specs;
	guint n_property_specs;
	GObject *setting;
	int i;

	setting = g_object_new (type, NULL);

	property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
	ASSERT (property_specs != NULL,
	        name, "couldn't find property specs for object of type '%s'",
	        g_type_name (G_OBJECT_TYPE (setting)));

	for (i = 0; i < n_property_specs; i++) {
		GParamSpec *prop_spec = property_specs[i];
		GValue value = G_VALUE_INIT;
		GValue defvalue = G_VALUE_INIT;
		char *actual, *expected;
		gboolean ok = FALSE;

		/* Ignore non-fundamental types since they won't really have
		 * defaults.
		 */
		if (!G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
			continue;

		g_value_init (&value, prop_spec->value_type);
		g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);

		g_value_init (&defvalue, prop_spec->value_type);
		g_param_value_set_default (prop_spec, &defvalue);

		actual = g_strdup_value_contents (&value);
		expected = g_strdup_value_contents (&defvalue);

		if (!strcmp (prop_spec->name, NM_SETTING_NAME)) {
			/* 'name' is always the setting name, not the default value */
			ok = !strcmp (nm_setting_get_name (NM_SETTING (setting)), name);
			g_free (expected);
			expected = g_strdup (name);
		} else
			ok = g_param_value_defaults (prop_spec, &value);

		ASSERT (ok,
		        name, "property '%s' value '%s' not the expected default value '%s'",
		        prop_spec->name, actual, expected);

		g_free (actual);
		g_free (expected);
		g_value_unset (&value);
		g_value_unset (&defvalue);
	}

	g_free (property_specs);
	g_object_unref (setting);
}
Ejemplo n.º 11
0
static void
gst_xvidenc_init (GstXvidEnc * xvidenc)
{
  GParamSpec **pspecs;
  guint i, num_props;

  /* create the sink pad */
  xvidenc->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
  gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->sinkpad);

  gst_pad_set_chain_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_chain));
  gst_pad_set_setcaps_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_setcaps));
  gst_pad_set_getcaps_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_getcaps));
  gst_pad_set_event_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_handle_sink_event));

  /* create the src pad */
  xvidenc->srcpad = gst_pad_new_from_static_template (&src_template, "src");
  gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->srcpad);
  gst_pad_use_fixed_caps (xvidenc->srcpad);

  /* init properties. */
  xvidenc->width = xvidenc->height = xvidenc->csp = -1;
  xvidenc->par_width = xvidenc->par_height = 1;

  /* set defaults for user properties */
  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (xvidenc),
      &num_props);

  for (i = 0; i < num_props; ++i) {
    GValue val = { 0, };
    GParamSpec *pspec = pspecs[i];

    /* only touch those that are really ours; i.e. should have some qdata */
    if (!g_param_spec_get_qdata (pspec, xvidenc_pspec_quark))
      continue;
    g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
    g_param_value_set_default (pspec, &val);
    g_object_set_property (G_OBJECT (xvidenc), g_param_spec_get_name (pspec),
        &val);
    g_value_unset (&val);
  }

  g_free (pspecs);

  /* set xvid handle to NULL */
  xvidenc->handle = NULL;

  /* get a queue to keep time info if frames get delayed */
  xvidenc->delay = NULL;

  /* cache some xvid data so need not rebuild for each frame */
  xvidenc->xframe_cache = NULL;
}
Ejemplo n.º 12
0
static gboolean
gimp_config_iface_equal (GimpConfig *a,
                         GimpConfig *b)
{
  GObjectClass  *klass;
  GParamSpec   **property_specs;
  guint          n_property_specs;
  guint          i;
  gboolean       equal = TRUE;

  klass = G_OBJECT_GET_CLASS (a);

  property_specs = g_object_class_list_properties (klass, &n_property_specs);

  for (i = 0; equal && i < n_property_specs; i++)
    {
      GParamSpec  *prop_spec;
      GValue       a_value = G_VALUE_INIT;
      GValue       b_value = G_VALUE_INIT;

      prop_spec = property_specs[i];

      if (! (prop_spec->flags & G_PARAM_READABLE))
        continue;

      g_value_init (&a_value, prop_spec->value_type);
      g_value_init (&b_value, prop_spec->value_type);
      g_object_get_property (G_OBJECT (a), prop_spec->name, &a_value);
      g_object_get_property (G_OBJECT (b), prop_spec->name, &b_value);

      if (g_param_values_cmp (prop_spec, &a_value, &b_value))
        {
          if ((prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE) &&
              G_IS_PARAM_SPEC_OBJECT (prop_spec)        &&
              g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
                                     GIMP_TYPE_CONFIG))
            {
              if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
                                             g_value_get_object (&b_value)))
                {
                  equal = FALSE;
                }
            }
          else
            {
              equal = FALSE;
            }
        }

      g_value_unset (&a_value);
      g_value_unset (&b_value);
    }

  g_free (property_specs);

  return equal;
}
/**
 * nm_setting_to_hash:
 * @setting: the #NMSetting
 * @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
 *
 * Converts the #NMSetting into a #GHashTable mapping each setting property
 * name to a GValue describing that property, suitable for marshalling over
 * D-Bus or serializing.  The mapping is string to GValue.
 * 
 * Returns: (transfer full) (element-type utf8 GObject.Value): a new #GHashTable
 * describing the setting's properties
 **/
GHashTable *
nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
{
	GHashTable *hash;
	GParamSpec **property_specs;
	guint n_property_specs;
	guint i;

	g_return_val_if_fail (setting != NULL, NULL);
	g_return_val_if_fail (NM_IS_SETTING (setting), NULL);

	property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
	if (!property_specs) {
		g_warning ("%s: couldn't find property specs for object of type '%s'",
		           __func__, g_type_name (G_OBJECT_TYPE (setting)));
		return NULL;
	}

	hash = g_hash_table_new_full (g_str_hash, g_str_equal,
	                              (GDestroyNotify) g_free, destroy_gvalue);

	for (i = 0; i < n_property_specs; i++) {
		GParamSpec *prop_spec = property_specs[i];
		GValue *value;

		if (!(prop_spec->flags & NM_SETTING_PARAM_SERIALIZE))
			continue;

		if (   (flags & NM_SETTING_HASH_FLAG_NO_SECRETS)
		    && (prop_spec->flags & NM_SETTING_PARAM_SECRET))
			continue;

		if (   (flags & NM_SETTING_HASH_FLAG_ONLY_SECRETS)
		    && !(prop_spec->flags & NM_SETTING_PARAM_SECRET))
			continue;

		value = g_slice_new0 (GValue);
		g_value_init (value, prop_spec->value_type);
		g_object_get_property (G_OBJECT (setting), prop_spec->name, value);

		/* Don't serialize values with default values */
		if (!g_param_value_defaults (prop_spec, value))
			g_hash_table_insert (hash, g_strdup (prop_spec->name), value);
		else
			destroy_gvalue (value);
	}
	g_free (property_specs);

	/* Don't return empty hashes */
	if (g_hash_table_size (hash) < 1) {
		g_hash_table_destroy (hash);
		hash = NULL;
	}

	return hash;
}
Ejemplo n.º 14
0
static JsonObject *
json_gobject_dump (GObject *gobject)
{
  JsonSerializableIface *iface = NULL;
  JsonSerializable *serializable = NULL;
  gboolean serialize_property = FALSE;
  JsonObject *object;
  GParamSpec **pspecs;
  guint n_pspecs, i;

  if (JSON_IS_SERIALIZABLE (gobject))
    {
      serializable = JSON_SERIALIZABLE (gobject);
      iface = JSON_SERIALIZABLE_GET_IFACE (gobject);
      serialize_property = (iface->serialize_property != NULL);
    }

  object = json_object_new ();

  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (gobject), &n_pspecs);
  for (i = 0; i < n_pspecs; i++)
    {
      GParamSpec *pspec = pspecs[i];
      GValue value = { 0, };
      JsonNode *node = NULL;

      /* read only what we can */
      if (!(pspec->flags & G_PARAM_READABLE))
        continue;

      g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
      g_object_get_property (gobject, pspec->name, &value);

      /* if there is a serialization vfunc, then it is completely responsible
       * for serializing the property, possibly by calling the implementation
       * of the default JsonSerializable interface through chaining up
       */
      if (serialize_property)
        {
          node = iface->serialize_property (serializable, pspec->name,
                                            &value,
                                            pspec);
        }
      else
        node = json_serialize_pspec (&value, pspec);

      if (node)
        json_object_set_member (object, pspec->name, node);

      g_value_unset (&value);
    }

  g_free (pspecs);

  return object;
}
Ejemplo n.º 15
0
static GimpConfig *
gimp_config_iface_duplicate (GimpConfig *config)
{
  GObject       *object = G_OBJECT (config);
  GObjectClass  *klass  = G_OBJECT_GET_CLASS (object);
  GParamSpec   **property_specs;
  guint          n_property_specs;
  gint           n_construct_properties = 0;
  const gchar  **construct_names        = NULL;
  GValue        *construct_values       = NULL;
  guint          i;
  GObject       *dup;

  property_specs = g_object_class_list_properties (klass, &n_property_specs);

  construct_names  = g_new0 (const gchar *, n_property_specs);
  construct_values = g_new0 (GValue,        n_property_specs);

  for (i = 0; i < n_property_specs; i++)
    {
      GParamSpec *prop_spec = property_specs[i];

      if ((prop_spec->flags & G_PARAM_READABLE) &&
          (prop_spec->flags & G_PARAM_WRITABLE) &&
          (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
        {
          construct_names[n_construct_properties] = prop_spec->name;

          g_value_init (&construct_values[n_construct_properties],
                        prop_spec->value_type);
          g_object_get_property (object, prop_spec->name,
                                 &construct_values[n_construct_properties]);

          n_construct_properties++;
        }
    }

  g_free (property_specs);

  dup = g_object_new_with_properties (G_TYPE_FROM_INSTANCE (object),
                                      n_construct_properties,
                                      (const gchar **) construct_names,
                                      (const GValue *) construct_values);

  for (i = 0; i < n_construct_properties; i++)
    g_value_unset (&construct_values[i]);

  g_free (construct_names);
  g_free (construct_values);

  gimp_config_copy (config, GIMP_CONFIG (dup), 0);

  return GIMP_CONFIG (dup);
}
Ejemplo n.º 16
0
static void
dump_gimprc_manpage (GimpConfig       *rc,
                     GimpConfigWriter *writer,
                     GOutputStream    *output)
{
  GObjectClass  *klass;
  GParamSpec   **property_specs;
  guint          n_property_specs;
  guint          i;

  g_output_stream_printf (output, NULL, NULL, NULL,
                          "%s", man_page_header);

  klass = G_OBJECT_GET_CLASS (rc);
  property_specs = g_object_class_list_properties (klass, &n_property_specs);

  for (i = 0; i < n_property_specs; i++)
    {
      GParamSpec *prop_spec = property_specs[i];
      gchar      *desc;

      if (! (prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE))
        continue;

      if (prop_spec->flags & GIMP_CONFIG_PARAM_IGNORE)
        continue;

      g_output_stream_printf (output, NULL, NULL, NULL,
                              ".TP\n");

      if (gimp_config_serialize_property (rc, prop_spec, writer))
        {
          g_output_stream_printf (output, NULL, NULL, NULL,
                                  "\n");

          desc = dump_describe_param (prop_spec);

          dump_with_linebreaks (output, desc);

          g_output_stream_printf (output, NULL, NULL, NULL,
                                  "\n");

          g_free (desc);
        }
    }

  g_free (property_specs);

  g_output_stream_printf (output, NULL, NULL, NULL,
                          "%s", man_page_path);
  g_output_stream_printf (output, NULL, NULL, NULL,
                          "%s", man_page_footer);
}
Ejemplo n.º 17
0
nsresult
xgGtkElement::DefineProperties ()
{
    nsresult rv;

    JSContext *jscx;
    rv = GetJSContext (&jscx);
    NS_ENSURE_SUCCESS (rv, rv);

    nsCOMPtr<nsIXPConnect> xpc (do_GetService ("@mozilla.org/js/xpc/XPConnect;1", &rv));
    NS_ENSURE_SUCCESS (rv, rv);

    nsCOMPtr<nsIDOMElement> elem;
    rv = mWrapper->GetElementNode (getter_AddRefs (elem));
    NS_ENSURE_SUCCESS (rv, rv);

    nsCOMPtr<nsIXPConnectJSObjectHolder> jswrapper;
    rv = xpc->WrapNative (jscx, JS_GetGlobalObject (jscx), elem,
			  NS_GET_IID (nsISupports),
			  getter_AddRefs (jswrapper));
    NS_ENSURE_SUCCESS (rv, rv);

    JSObject *jsobj;
    rv = jswrapper->GetJSObject (&jsobj);
    NS_ENSURE_SUCCESS (rv, rv);

    g_message (GOM_LOC ("Got JSObject: %p"), (void *)jsobj);

    guint n_properties;
    GParamSpec **props = g_object_class_list_properties (G_OBJECT_GET_CLASS (mObject), &n_properties);
    g_message (GOM_LOC ("Adding %d properties from %s"), n_properties, G_OBJECT_TYPE_NAME (mObject));

    JS_BeginRequest (jscx);

    const char *camelName;
    for (guint i = 0; i < n_properties; i++) {
	camelName = gom_camel_case (props[i]->name);
	if (!JS_DefineProperty (jscx, jsobj, camelName, JSVAL_VOID,
				xgGObject::GetProperty,
				xgGObject::SetProperty,
				JSPROP_ENUMERATE | JSPROP_PERMANENT)) {
	    g_printerr ("Could not define a property for %s\n", camelName);
	} else {
	    g_print (GOM_LOC ("Defined property: %s.%s\n"),
		     G_OBJECT_TYPE_NAME (mObject), camelName);
	}
	GOM_CAMEL_FREE (camelName, props[i]->name);
    }

    JS_EndRequest (jscx);

    return NS_OK;
}
/**
 * ges_timeline_element_copy:
 * @self: The #GESTimelineElement to copy
 * @deep: whether we want to create the elements @self contains or not
 *
 * Copies @self
 *
 * Returns: (transfer floating): The newly create #GESTimelineElement, copied from @self
 */
GESTimelineElement *
ges_timeline_element_copy (GESTimelineElement * self, gboolean deep)
{
  GESAsset *asset;
  GParameter *params;
  GParamSpec **specs;
  GESTimelineElementClass *klass;
  guint n, n_specs, n_params;

  GESTimelineElement *ret = NULL;

  g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), FALSE);

  klass = GES_TIMELINE_ELEMENT_GET_CLASS (self);

  specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (self), &n_specs);
  params = g_new0 (GParameter, n_specs);
  n_params = 0;

  for (n = 0; n < n_specs; ++n) {
    /* We do not want the timeline or the name to be copied */
    if (g_strcmp0 (specs[n]->name, "parent") &&
        g_strcmp0 (specs[n]->name, "timeline") &&
        g_strcmp0 (specs[n]->name, "name") &&
        (specs[n]->flags & G_PARAM_READWRITE) == G_PARAM_READWRITE) {
      params[n_params].name = g_intern_string (specs[n]->name);
      g_value_init (&params[n_params].value, specs[n]->value_type);
      g_object_get_property (G_OBJECT (self), specs[n]->name,
          &params[n_params].value);
      ++n_params;
    }
  }

  ret = g_object_newv (G_OBJECT_TYPE (self), n_params, params);

  g_free (specs);
  g_free (params);


  asset = ges_extractable_get_asset (GES_EXTRACTABLE (self));
  if (asset)
    ges_extractable_set_asset (GES_EXTRACTABLE (ret), asset);
  if (deep) {
    if (klass->deep_copy)
      klass->deep_copy (self, ret);
    else
      GST_WARNING_OBJECT (self, "No deep_copy virtual method implementation"
          " on class %s. Can not finish the copy", G_OBJECT_CLASS_NAME (klass));
  }

  return ret;
}
Ejemplo n.º 19
0
static GimpConfig *
gimp_config_iface_duplicate (GimpConfig *config)
{
  GObject       *object = G_OBJECT (config);
  GObjectClass  *klass  = G_OBJECT_GET_CLASS (object);
  GParamSpec   **property_specs;
  guint          n_property_specs;
  GParameter    *construct_params   = NULL;
  gint           n_construct_params = 0;
  guint          i;
  GObject       *dup;

  property_specs = g_object_class_list_properties (klass, &n_property_specs);

  construct_params = g_new0 (GParameter, n_property_specs);

  for (i = 0; i < n_property_specs; i++)
    {
      GParamSpec *prop_spec = property_specs[i];

      if ((prop_spec->flags & G_PARAM_READABLE) &&
          (prop_spec->flags & G_PARAM_WRITABLE) &&
          (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
        {
          GParameter *construct_param;

          construct_param = &construct_params[n_construct_params++];

          construct_param->name = prop_spec->name;

          g_value_init (&construct_param->value, prop_spec->value_type);
          g_object_get_property (object,
                                 prop_spec->name, &construct_param->value);
        }
    }

  g_free (property_specs);

  dup = g_object_newv (G_TYPE_FROM_INSTANCE (object),
                       n_construct_params, construct_params);

  for (i = 0; i < n_construct_params; i++)
    g_value_unset (&construct_params[i].value);

  g_free (construct_params);

  gimp_config_sync (object, dup, 0);

  return GIMP_CONFIG (dup);
}
Ejemplo n.º 20
0
Archivo: gen-doc.c Proyecto: miq/libuca
static void
print_properties (UcaCamera *camera)
{
    GObjectClass *oclass;
    GParamSpec **pspecs;
    guint n_props;

    oclass = G_OBJECT_GET_CLASS (camera);
    pspecs = g_object_class_list_properties (oclass, &n_props);

    print_property_toc (pspecs, n_props);
    print_property_descriptions (pspecs, n_props);

    g_free (pspecs);
}
Ejemplo n.º 21
0
static void
widget_test_properties (GtkWidget   *widget,
                        double       dvalue)
{
  /* try setting all possible properties, according to dvalue */
  guint i, n_pspecs = 0;
  GParamSpec **pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (widget), &n_pspecs);
  for (i = 0; i < n_pspecs; i++)
    {
      GParamSpec *pspec = pspecs[i];
      if (pspec->flags & G_PARAM_WRITABLE &&
          !(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
        object_test_property (G_OBJECT (widget), pspecs[i], dvalue);
    }
  g_free (pspecs);
}
Ejemplo n.º 22
0
static void
unrealize_notify (NMDevice *device)
{
	NMDeviceTun *self = NM_DEVICE_TUN (device);
	NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
	GParamSpec **properties;
	guint n_properties, i;

	NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize_notify (device);

	memset (&priv->props, 0, sizeof (NMPlatformTunProperties));

	properties = g_object_class_list_properties (G_OBJECT_GET_CLASS (self), &n_properties);
	for (i = 0; i < n_properties; i++)
		g_object_notify_by_pspec (G_OBJECT (self), properties[i]);
	g_free (properties);
}
Ejemplo n.º 23
0
static void
uca_camera_finalize (GObject *object)
{
    GParamSpec **props;
    guint n_props;

    /* We will reset property units of all subclassed objects  */
    props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &n_props);

    for (guint i = 0; i < n_props; i++) {
        g_param_spec_set_qdata (props[i], UCA_UNIT_QUARK, NULL);
    }

    g_free (props);

    G_OBJECT_CLASS (uca_camera_parent_class)->finalize (object);
}
Ejemplo n.º 24
0
void           remote_client_send_all_params  (RemoteClient*     self,
					       ParameterHolder*  ph)
{
    /* Find all serializable parameters, and send them */

    guint n_properties;
    GParamSpec** properties;
    int i;

    properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(ph), &n_properties);

    for (i=0; i<n_properties; i++)
	if (properties[i]->flags & PARAM_SERIALIZED)
	    remote_client_send_param(self, ph, properties[i]->name);

    g_free(properties);
}
Ejemplo n.º 25
0
void GstVideoCodec::make_codec_properties() {
  uninstall_codec_properties();
  guint num_properties = 0;
  GParamSpec** props =
      g_object_class_list_properties(G_OBJECT_GET_CLASS(codec_element_.get_raw()), &num_properties);
  On_scope_exit { g_free(props); };
  for (guint i = 0; i < num_properties; i++) {
    auto param_name = g_param_spec_get_name(props[i]);
    if (param_black_list_.end() == param_black_list_.find(param_name)) {
      quid_->pmanage<MPtr(&PContainer::push_parented)>(
          param_name,
          "codec_params",
          GPropToProp::to_prop(G_OBJECT(codec_element_.get_raw()), param_name));
      codec_properties_.push_back(param_name);
    }
  }
}
Ejemplo n.º 26
0
static gchar *
debug_dump_get_element_params (GstElement * element)
{
  gchar *param_name = NULL;
  GParamSpec **properties, *property;
  GValue value = { 0, };
  guint i, number_of_properties;
  gchar *tmp, *value_str;

  /* get paramspecs and show non-default properties */
  properties =
      g_object_class_list_properties (G_OBJECT_CLASS (GST_ELEMENT_GET_CLASS
          (element)), &number_of_properties);
  if (properties) {
    for (i = 0; i < number_of_properties; i++) {
      property = properties[i];

      /* ski some properties */
      if (!(property->flags & G_PARAM_READABLE))
        continue;
      if (!strcmp (property->name, "name"))
        continue;

      g_value_init (&value, property->value_type);
      g_object_get_property (G_OBJECT (element), property->name, &value);
      if (!(g_param_value_defaults (property, &value))) {
        tmp = g_strdup_value_contents (&value);
        value_str = g_strescape (tmp, NULL);
        g_free (tmp);
        if (param_name) {
          tmp = param_name;
          param_name = g_strdup_printf ("%s\\n%s=%s",
              tmp, property->name, value_str);
          g_free (tmp);
        } else {
          param_name = g_strdup_printf ("\\n%s=%s", property->name, value_str);
        }
        g_free (value_str);
      }
      g_value_unset (&value);
    }
    g_free (properties);
  }
  return param_name;
}
Ejemplo n.º 27
0
static void
dump_gimprc_system (GimpConfig       *rc,
                    GimpConfigWriter *writer,
                    GOutputStream    *output)
{
  GObjectClass  *klass;
  GParamSpec   **property_specs;
  guint          n_property_specs;
  guint          i;

  gimp_config_writer_comment (writer, system_gimprc_header);
  gimp_config_writer_linefeed (writer);

  klass = G_OBJECT_GET_CLASS (rc);
  property_specs = g_object_class_list_properties (klass, &n_property_specs);

  for (i = 0; i < n_property_specs; i++)
    {
      GParamSpec *prop_spec = property_specs[i];
      gchar      *comment;

      if (! (prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE))
        continue;

      if (prop_spec->flags & GIMP_CONFIG_PARAM_IGNORE)
        continue;

      comment = dump_describe_param (prop_spec);
      if (comment)
        {
          gimp_config_writer_comment (writer, comment);
          g_free (comment);
        }

      gimp_config_writer_comment_mode (writer, TRUE);
      gimp_config_writer_linefeed (writer);

      gimp_config_serialize_property (rc, prop_spec, writer);

      gimp_config_writer_comment_mode (writer, FALSE);
      gimp_config_writer_linefeed (writer);
    }

  g_free (property_specs);
}
Ejemplo n.º 28
0
/* Binds the properties on a generated server-side GDBus object to the
 * corresponding properties on the public object.
 */
void
_nm_dbus_bind_properties (gpointer object, gpointer skeleton)
{
	GParamSpec **properties;
	guint n_properties;
	int i;

	properties = g_object_class_list_properties (G_OBJECT_GET_CLASS (skeleton), &n_properties);
	for (i = 0; i < n_properties; i++) {
		if (g_str_has_prefix (properties[i]->name, "g-"))
			continue;

		g_object_bind_property (object, properties[i]->name,
		                        skeleton, properties[i]->name,
		                        G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
	}
	g_free (properties);
}
Ejemplo n.º 29
0
static GVariant *
serialize_object_default(GvsSerializer *self, EntityRef *ref)
{
    GObjectClass *klass;
    guint n_props, i;
    GParamSpec **pspecs;
    GVariantBuilder builder;
    GObject *object;

    object = g_value_get_object(&ref->value);

    g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);

    klass = G_OBJECT_GET_CLASS(object);
    
    pspecs = g_object_class_list_properties(klass, &n_props);
    
    for (i = 0; i < n_props; i++)
    {
        GValue value = G_VALUE_INIT;
        GParamSpec *pspec = pspecs[i];

        /* Skip read-only properties which we can't deserialize, and write-only
         * properties which are just stupid */
        if ((pspec->flags & G_PARAM_READABLE) == 0 ||
            (pspec->flags & G_PARAM_WRITABLE) == 0)
        {
            continue;
        }

        g_value_init(&value, pspec->value_type);

        g_object_get_property(object, pspec->name, &value);

        g_variant_builder_add(&builder, "{sv}", pspec->name,
                              serialize_pspec(self, pspec, &value));

        g_value_unset (&value);
    }

    g_free(pspecs);

    return g_variant_builder_end (&builder);
}
Ejemplo n.º 30
0
static void
distribution_changed_cb (GtkComboBox *box, DistPrefs *prefs)
{
	GODistribution *dist = NULL;
	int i, j, n;
	GtkTreeIter iter;
	GODistributionType dist_type;
	GParamSpec **props;
	GtkTreeModel *model = gtk_combo_box_get_model (box);
	gtk_combo_box_get_active_iter (box, &iter);
	gtk_tree_model_get (model, &iter, 1, &dist_type, -1);
	dist = go_distribution_new (dist_type);
	g_object_set (prefs->client, "distribution", dist, NULL);
	props = g_object_class_list_properties (G_OBJECT_GET_CLASS (dist), &n);
	for (j = i = 0; j < n; j++)
		if (props[j]->flags & GO_PARAM_PERSISTENT) {
			char *lbl = g_strconcat (_(g_param_spec_get_nick (props[j])), _(":"), NULL);
			if (!prefs->labels[i]) {
				GtkWidget *w = gtk_label_new (lbl);
				g_free (lbl);
				g_object_set (w, "xalign", 0., NULL);
				gtk_grid_attach (prefs->grid, w, 0, i + 1, 1, 1);
				prefs->labels[i] = w;
			} else
				gtk_label_set_text (GTK_LABEL (prefs->labels[i]), lbl);
			if (!prefs->data[i]) {
				GtkWidget *w = GTK_WIDGET (gog_data_allocator_editor (prefs->dalloc, GOG_DATASET (prefs->client), i, GOG_DATA_SCALAR));
				gtk_grid_attach (prefs->grid, w, 1, i + 1, 1, 1);
				prefs->data[i] = w;
			}
			gtk_widget_show (prefs->labels[i]);
			gtk_widget_show (prefs->data[i]);
			prefs->props[i++] = props[j];
		}
	while (i < 2) {
		if (prefs->labels[i])
			gtk_widget_hide (prefs->labels[i]);
		if (prefs->data[i])
			gtk_widget_hide (prefs->data[i]);
		prefs->props[i++] = NULL;
	}
	g_free (props);
	g_object_unref (dist);
}