示例#1
0
static void *
vips_operation_class_usage_arg( VipsObjectClass *object_class, 
	GParamSpec *pspec, VipsArgumentClass *argument_class,
	VipsBuf *buf, VipsOperationClassUsage *usage )
{
	/* Only show construct args ... others are internal.
	 */
	if( usage->required == 
		((argument_class->flags & VIPS_ARGUMENT_REQUIRED) != 0) &&
		(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
		!(argument_class->flags & VIPS_ARGUMENT_DEPRECATED) ) { 
		if( usage->message && usage->n == 0 ) 
			vips_buf_appendf( buf, "%s\n", usage->message );

		if( usage->oftype ) {
			vips_buf_appendf( buf, "   %-12s - %s, %s %s\n",
				g_param_spec_get_name( pspec ), 
				g_param_spec_get_blurb( pspec ), 
				(argument_class->flags & VIPS_ARGUMENT_INPUT) ?
					_( "input" ) : _( "output" ),
				g_type_name( 
					G_PARAM_SPEC_VALUE_TYPE( pspec ) ) );
		}
		else {
			if( usage->n > 0 )
				vips_buf_appends( buf, " " );
			vips_buf_appends( buf, g_param_spec_get_name( pspec ) );
		}

		usage->n += 1;
	}

	return( NULL );
}
示例#2
0
static void
e_bind_properties_transfer (GObject *src_object,
                            GParamSpec *src_pspec,
                            GObject *dst_object,
                            GParamSpec *dst_pspec,
                            GlideBindingTransform  transform,
                            gpointer user_data)
{
	const gchar *src_name;
	const gchar *dst_name;
	gboolean result;
	GValue src_value = { 0, };
	GValue dst_value = { 0, };

	src_name = g_param_spec_get_name (src_pspec);
	dst_name = g_param_spec_get_name (dst_pspec);

	g_value_init (&src_value, G_PARAM_SPEC_VALUE_TYPE (src_pspec));
	g_object_get_property (src_object, src_name, &src_value);

	g_value_init (&dst_value, G_PARAM_SPEC_VALUE_TYPE (dst_pspec));
	result = (*transform) (&src_value, &dst_value, user_data);

	g_value_unset (&src_value);

	g_return_if_fail (result);

	g_param_value_validate (dst_pspec, &dst_value);
	g_object_set_property (dst_object, dst_name, &dst_value);
	g_value_unset (&dst_value);
}
示例#3
0
/* Register stylable property of a class */
void xfdashboard_actor_install_stylable_property(XfdashboardActorClass *klass, GParamSpec *inParamSpec)
{
	GParamSpec		*stylableParamSpec;

	g_return_if_fail(XFDASHBOARD_IS_ACTOR_CLASS(klass));
	g_return_if_fail(G_IS_PARAM_SPEC(inParamSpec));
	g_return_if_fail(inParamSpec->flags & G_PARAM_WRITABLE);
	g_return_if_fail(!(inParamSpec->flags & G_PARAM_CONSTRUCT_ONLY));

	/* Check if param-spec is already registered */
	if(g_param_spec_pool_lookup(_xfdashboard_actor_stylable_properties_pool, g_param_spec_get_name(inParamSpec), G_OBJECT_CLASS_TYPE(klass), FALSE))
	{
		g_warning("Class '%s' already contains a stylable property '%s'",
					G_OBJECT_CLASS_NAME(klass),
					g_param_spec_get_name(inParamSpec));
		return;
	}

	/* Add param-spec to pool of themable properties */
	stylableParamSpec=g_param_spec_internal(G_PARAM_SPEC_TYPE(inParamSpec),
												g_param_spec_get_name(inParamSpec),
												NULL,
												NULL,
												0);
	g_param_spec_set_qdata_full(stylableParamSpec,
									XFDASHBOARD_ACTOR_PARAM_SPEC_REF,
									g_param_spec_ref(inParamSpec),
									(GDestroyNotify)g_param_spec_unref);
	g_param_spec_pool_insert(_xfdashboard_actor_stylable_properties_pool, stylableParamSpec, G_OBJECT_CLASS_TYPE(klass));
	XFDASHBOARD_DEBUG(NULL, STYLE,
						"Registered stylable property '%s' for class '%s'",
						g_param_spec_get_name(inParamSpec), G_OBJECT_CLASS_NAME(klass));
}
示例#4
0
static void
gst_test_class_init (GstTestClass * klass)
{
  GstBaseSinkClass *basesink_class = GST_BASE_SINK_CLASS (klass);
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  guint i;

  object_class->set_property = gst_test_set_property;
  object_class->get_property = gst_test_get_property;

  object_class->finalize = (GObjectFinalizeFunc) gst_test_finalize;

  for (i = 0; i < TESTS_COUNT; i++) {
    GParamSpec *spec;

    spec = tests[i].get_spec (&tests[i], FALSE);
    klass->param_names[2 * i] = g_strdup (g_param_spec_get_name (spec));
    g_object_class_install_property (object_class, 2 * i + 1, spec);
    spec = tests[i].get_spec (&tests[i], TRUE);
    klass->param_names[2 * i + 1] = g_strdup (g_param_spec_get_name (spec));
    g_object_class_install_property (object_class, 2 * i + 2, spec);
  }

  basesink_class->render = GST_DEBUG_FUNCPTR (gst_test_render_buffer);
  basesink_class->event = GST_DEBUG_FUNCPTR (gst_test_sink_event);
  basesink_class->start = GST_DEBUG_FUNCPTR (gst_test_start);
  basesink_class->stop = GST_DEBUG_FUNCPTR (gst_test_stop);
}
示例#5
0
/* Get parameter specification of stylable properties and add them to hashtable.
 * If requested do it recursively over all parent classes.
 */
static void _xfdashboard_actor_hashtable_get_all_stylable_param_specs(GHashTable *ioHashtable, GObjectClass *inClass, gboolean inRecursive)
{
	GList						*paramSpecs, *entry;
	GObjectClass				*parentClass;

	/* Get list of all parameter specification registered for class */
	paramSpecs=g_param_spec_pool_list_owned(_xfdashboard_actor_stylable_properties_pool, G_OBJECT_CLASS_TYPE(inClass));
	for(entry=paramSpecs; entry; entry=g_list_next(entry))
	{
		GParamSpec				*paramSpec=G_PARAM_SPEC(entry->data);

		/* Only add parameter specification which aren't already in hashtable */
		if(paramSpec &&
			!g_hash_table_lookup_extended(ioHashtable, g_param_spec_get_name(paramSpec), NULL, NULL))
		{
			g_hash_table_insert(ioHashtable,
									g_strdup(g_param_spec_get_name(paramSpec)),
									g_param_spec_ref(paramSpec));
		}
	}
	g_list_free(paramSpecs);

	/* Call us recursive for parent class if it exists and requested */
	parentClass=g_type_class_peek_parent(inClass);
	if(inRecursive && parentClass) _xfdashboard_actor_hashtable_get_all_stylable_param_specs(ioHashtable, parentClass, inRecursive);
}
示例#6
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;
}
static GObject *constructor(GType gtype, guint n_properties, GObjectConstructParam *properties) {
	GObject *object;

#if (GTK_CHECK_VERSION(2,24,0))
	guint i;
	gchar const *name;
	GObjectConstructParam *property;

	for (i = 0, property = properties; i < n_properties; ++i, ++property) {
		name = g_param_spec_get_name(property->pspec);
		if (!strcmp(name, "has-entry")) // is G_PARAM_CONSTRUCT_ONLY
			g_value_set_boolean(property->value, TRUE);
	}
#endif

	object = G_OBJECT_CLASS(ryostklconfig_pro_dimness_selector_parent_class)->constructor(gtype, n_properties, properties);

#if (GTK_CHECK_VERSION(2,24,0))
	g_object_set(object, "entry-text-column", TITLE_COLUMN, NULL);
#else
	g_object_set(object, "text-column", TITLE_COLUMN, NULL);
#endif

	gtk_editable_set_editable(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(object))), FALSE);

	return object;
}
示例#8
0
static GObject *point3d_constructor (GType                  type,
                                     guint                  n_construct_properties,
                                     GObjectConstructParam *construct_properties) {
    GObject *obj;
    PointClass *parent_class = g_type_class_peek(TYPE_POINT);
    
    obj = G_OBJECT_CLASS(parent_class)->constructor(type,
                                        n_construct_properties,
                                        construct_properties);

    {
        int i;
        g_print("point3d_constructor(type=%s", g_type_name(type));
        for (i = 0; i < n_construct_properties; i++) {
            GParamSpec *pspec = construct_properties[i].pspec;
            GValue *value = construct_properties[i].value;
            gchar *contents = g_strdup_value_contents(value);
            g_print(", %s => %s", g_param_spec_get_name(pspec), contents);
            g_free(contents);
        }
        g_print(")\n");
    }
    
    return obj;
}
示例#9
0
/* Color has changed at settings */
static void _plugin_on_settings_color_change(GObject *inObject,
												GParamSpec *inSpec,
												gpointer inUserData)
{
	XfdashboardClockViewSettings	*settings;
	GtkColorButton					*button;
	ClutterColor					*settingsColor;
	GdkRGBA							widgetColor;

	g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(inObject));
	g_return_if_fail(GTK_IS_COLOR_BUTTON(inUserData));

	settings=XFDASHBOARD_CLOCK_VIEW_SETTINGS(inObject);
	button=GTK_COLOR_BUTTON(inUserData);

	/* Get current color from settings */
	g_object_get(G_OBJECT(settings), g_param_spec_get_name(inSpec), &settingsColor, NULL);

	/* Convert color for color button */
	widgetColor.red=settingsColor->red/255.0f;
	widgetColor.green=settingsColor->green/255.0f;
	widgetColor.blue=settingsColor->blue/255.0f;
	widgetColor.alpha=settingsColor->alpha/255.0f;

	/* Set converted color at color button */
#if GTK_CHECK_VERSION(3, 4, 0)
	gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(button), &widgetColor);
#else
	gtk_color_button_set_rgba(button, &widgetColor);
#endif
}
示例#10
0
static void
peas_extension_gjs_get_property (GObject    *object,
                                 guint       prop_id,
                                 GValue     *value,
                                 GParamSpec *pspec)
{
  PeasExtensionGjs *gexten = PEAS_EXTENSION_GJS (object);
  gchar *prop_name;
  jsval js_value;

  prop_name = convert_property_name (g_param_spec_get_name (pspec));

  if (!JS_GetProperty (gexten->js_context, gexten->js_object,
                       prop_name, &js_value))
    {
      g_warning ("Error: failed to get property '%s'", prop_name);
    }
  else if (!gjs_value_to_g_value (gexten->js_context, js_value, value))
    {
      g_warning ("Error: failed to convert jsval to "
                 "GValue for property '%s'", prop_name);
    }

  g_free (prop_name);
}
static GObject *
kms_sdp_rtp_avpf_media_handler_constructor (GType gtype, guint n_properties,
    GObjectConstructParam * properties)
{
  GObjectConstructParam *property;
  gchar const *name;
  GObject *object;
  guint i;

  for (i = 0, property = properties; i < n_properties; ++i, ++property) {
    name = g_param_spec_get_name (property->pspec);
    if (g_strcmp0 (name, "proto") == 0) {
      if (g_value_get_string (property->value) == NULL) {
        /* change G_PARAM_CONSTRUCT_ONLY value */
        g_value_set_string (property->value, SDP_MEDIA_RTP_AVPF_PROTO);
      }
    }
  }

  object =
      G_OBJECT_CLASS (parent_class)->constructor (gtype, n_properties,
      properties);

  return object;
}
示例#12
0
static void *
vips_object_unref_arg( VipsObject *object,
	GParamSpec *pspec,
	VipsArgumentClass *argument_class,
	VipsArgumentInstance *argument_instance,
	void *a, void *b )
{
	if( (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
		(argument_class->flags & VIPS_ARGUMENT_OUTPUT) &&
		argument_instance->assigned &&
		G_IS_PARAM_SPEC_OBJECT( pspec ) ) {
		GObject *value;

		/* This will up the ref count for us.
		 */
		g_object_get( G_OBJECT( object ), 
			g_param_spec_get_name( pspec ), &value, NULL );

		/* Drop the ref we just got, then drop the ref we make when we
		 * added to the cache.
		 */
		g_object_unref( value );
		g_object_unref( value );
	}

	return( NULL );
}
示例#13
0
static void mame_gui_prefs_save_string (MameGuiPrefs *pr, GParamSpec *param, gpointer user_data)
{
	gchar *key;
	gchar *value;

	g_return_if_fail (pr->priv->prefs_ini_file != NULL);
	g_return_if_fail (pr->priv->filename != NULL);
	
	key = g_strdup (g_param_spec_get_name (param));
	
	g_return_if_fail (key != NULL);	
	
	g_object_get (pr, key, &value, NULL);
	
	GMAMEUI_DEBUG ("Saving %s - setting string value %s with value %s",
		       pr->priv->filename, key, value);

	/* Set the value and save the file */
	g_key_file_set_string (pr->priv->prefs_ini_file, "Preferences", key, value);
	g_key_file_save_to_file (pr->priv->prefs_ini_file, pr->priv->filename);
	
	g_free (key);
	
	/* FIXME TODO Preferences is a temporary group name - need to find a way to
	   add more groups */
}
示例#14
0
文件: vipsobject.c 项目: jcupitt/nip2
/* Looking for required output args ... append to out.
 */
static void *
vo_get_required_output( VipsObject *object, GParamSpec *pspec,
        VipsArgumentClass *argument_class, 
	VipsArgumentInstance *argument_instance, Vo *vo, PElement *out )
{
	if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
		(argument_class->flags & VIPS_ARGUMENT_OUTPUT) &&
		argument_instance->assigned ) {
		const char *name = g_param_spec_get_name( pspec );
		GType type = G_PARAM_SPEC_VALUE_TYPE( pspec );
		PElement lhs;

		GValue value = { 0 };

		if( !heap_list_add( vo->rc->heap, out, &lhs ) )
			return( object );
		g_value_init( &value, type );
		g_object_get_property( G_OBJECT( object ), name, &value );
		if( !heap_gvalue_to_ip( &value, &lhs ) ) {
			g_value_unset( &value );
			return( object );
		}
		g_value_unset( &value );

		(void) heap_list_next( out );
	}

	return( NULL );
}
示例#15
0
文件: vipsobject.c 项目: jcupitt/nip2
static void *
vo_set_required_input( VipsObject *object, GParamSpec *pspec,
        VipsArgumentClass *argument_class, 
	VipsArgumentInstance *argument_instance, Vo *vo )
{
	/* Looking for required input args ... these are the ones we can set
	 * from the supplied required list. 
	 */
	if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
		(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
		(argument_class->flags & VIPS_ARGUMENT_INPUT) &&
		!argument_instance->assigned &&
		vo->nargs_required < vo->nargs_supplied ) {
		const char *name = g_param_spec_get_name( pspec );
		int i = vo->nargs_required;

		GValue gvalue = { 0 };

		if( !heap_ip_to_gvalue( &vo->args[i], &gvalue ) )
			return( object );
		if( vo_set_property( vo, name, pspec, &gvalue ) ) {
			g_value_unset( &gvalue );
			return( object );
		}
		g_value_unset( &gvalue );

		vo->nargs_required += 1;
	}

	return( NULL );
}
示例#16
0
static void *
vips_object_equal_arg( VipsObject *object,
	GParamSpec *pspec,
	VipsArgumentClass *argument_class,
	VipsArgumentInstance *argument_instance,
	void *a, void *b )
{
	VipsObject *other = (VipsObject *) a;

	if( (argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
		(argument_class->flags & VIPS_ARGUMENT_INPUT) &&
		argument_instance->assigned ) {
		const char *name = g_param_spec_get_name( pspec );
		GType type = G_PARAM_SPEC_VALUE_TYPE( pspec );
		GValue v1 = { 0, };
		GValue v2 = { 0, };

		gboolean equal;

		g_value_init( &v1, type );
		g_value_init( &v2, type );
		g_object_get_property( G_OBJECT( object ), name, &v1 ); 
		g_object_get_property( G_OBJECT( other ), name, &v2 ); 
		equal = vips_value_equal( pspec, &v1, &v2 );
		g_value_unset( &v1 );
		g_value_unset( &v2 );

		if( !equal )
			return( object );
	}

	return( NULL );
}
示例#17
0
void
deep_prop_changed_cb (GESTrackObject * obj, GstElement * element,
    GParamSpec * spec)
{
  GST_DEBUG ("%s property changed", g_param_spec_get_name (spec));
  fail_unless (GES_IS_TRACK_OBJECT (obj));
  fail_unless (GST_IS_ELEMENT (element));
}
static GObject *
g_local_directory_monitor_constructor (GType                  type,
                                       guint                  n_construct_properties,
                                       GObjectConstructParam *construct_properties)
{
  GObject *obj;
  GLocalDirectoryMonitorClass *klass;
  GObjectClass *parent_class;
  GLocalDirectoryMonitor *local_monitor;
  const gchar *dirname = NULL;
  gint i;
  
  klass = G_LOCAL_DIRECTORY_MONITOR_CLASS (g_type_class_peek (G_TYPE_LOCAL_DIRECTORY_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_DIRECTORY_MONITOR (obj);

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

  local_monitor->dirname = g_strdup (dirname);

  if (!klass->mount_notify)
    {
#ifdef G_OS_WIN32
      /*claim everything was mounted */
      local_monitor->was_mounted = TRUE;
#else
      GUnixMountEntry *mount;
      
      /* Emulate unmount detection */
      
      mount = g_unix_mount_at (local_monitor->dirname, NULL);
      
      local_monitor->was_mounted = mount != NULL;
      
      if (mount)
        g_unix_mount_free (mount);

      local_monitor->mount_monitor = g_unix_mount_monitor_new ();
      g_signal_connect_object (local_monitor->mount_monitor, "mounts-changed",
			       G_CALLBACK (mounts_changed), local_monitor, 0);
#endif
    }

  return obj;
}
示例#19
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;
}
示例#20
0
static GObject*
base_object_constructor  (GType                  type,
			  guint                  n_construct_properties,
			  GObjectConstructParam *construct_properties)
{
  /* The constructor is the one place where a GParamSpecOverride is visible
   * to the outside world, so we do a bunch of checks here
   */
  GValue value1 = { 0, };
  GValue value2 = { 0, };
  GParamSpec *pspec;

  g_assert (n_construct_properties == 1);

  pspec = construct_properties->pspec;

  /* Check we got the param spec we expected
   */
  g_assert (G_IS_PARAM_SPEC_OVERRIDE (pspec));
  g_assert (pspec->param_id == BASE_PROP1);
  g_assert (strcmp (g_param_spec_get_name (pspec), "prop1") == 0);
  g_assert (g_param_spec_get_redirect_target (pspec) == iface_spec1);

  /* Test redirection of the nick and blurb to the redirect target
   */
  g_assert (strcmp (g_param_spec_get_nick (pspec), "Prop1") == 0);
  g_assert (strcmp (g_param_spec_get_blurb (pspec), "Property 1") == 0);

  /* Test forwarding of the various GParamSpec methods to the redirect target
   */
  g_value_init (&value1, G_TYPE_INT);
  g_value_init (&value2, G_TYPE_INT);
  
  g_param_value_set_default (pspec, &value1);
  g_assert (g_value_get_int (&value1) == 42);

  g_value_reset (&value1);
  g_value_set_int (&value1, 0x10000);
  g_assert (g_param_value_validate (pspec, &value1));
  g_assert (g_value_get_int (&value1) == 0xFFFF);
  g_assert (!g_param_value_validate (pspec, &value1));
  
  g_value_reset (&value1);
  g_value_set_int (&value1, 1);
  g_value_set_int (&value2, 2);
  g_assert (g_param_values_cmp (pspec, &value1, &value2) < 0);
  g_assert (g_param_values_cmp (pspec, &value2, &value1) > 0);
  
  g_value_unset (&value1);
  g_value_unset (&value2);

  return base_parent_class->constructor (type,
					 n_construct_properties,
					 construct_properties);
}
示例#21
0
/* This function is used to handle the string arrays representing the ROM
   and sample paths */
static void
mame_gui_prefs_save_string_arr (MameGuiPrefs *pr, GParamSpec *param, gpointer user_data)
{
	gchar *key;
	GValueArray *va;
	gchar **value;
	guint n_va;
	guint i;

	g_return_if_fail (pr->priv->prefs_ini_file != NULL);
	g_return_if_fail (pr->priv->filename != NULL);
	
	key = g_strdup (g_param_spec_get_name (param));
	
	g_return_if_fail (key != NULL);	
	
	g_object_get (pr, key, &va, NULL);
	
	g_return_if_fail (va != NULL);

	GMAMEUI_DEBUG ("Saving string array %s", key);
	
	if (va->n_values == 0) {
		/* If the va has no values, then they have all been removed -
		   need to delete the key from the file */
		GMAMEUI_DEBUG ("Saving %s - removing string array value %s",
			       pr->priv->filename, key);
		
		g_key_file_remove_key (pr->priv->prefs_ini_file, "Preferences", key, NULL);
	} else {	
		/* Copy all the elements in the value array to a string array */
		n_va = va->n_values;
		value = g_new0 (gchar*, n_va);
		for (i = 0; i < n_va; i++) {
			GMAMEUI_DEBUG ("Value at %d is %s", i, g_value_get_string (g_value_array_get_nth (va, i)));
			value[i] = g_strdup (g_value_get_string (g_value_array_get_nth (va, i)));
		}
	
		GMAMEUI_DEBUG ("Saving %s - setting string array value %s",
			       pr->priv->filename, key);

		/* Set the value and save the file */
		g_key_file_set_string_list (pr->priv->prefs_ini_file, "Preferences", key, value, n_va);
	}
	g_key_file_save_to_file (pr->priv->prefs_ini_file, pr->priv->filename);
		
	GMAMEUI_DEBUG ("Saving string array %s... done", key);
	
	g_free (key);
	/* FIXME TODO g_strfreev (value);*/
	
	/* FIXME TODO Preferences is a temporary group name - need to find a way to
	   add more groups */
}
示例#22
0
static void
gimp_clone_options_notify (GObject    *object,
                           GParamSpec *pspec)
{
  if (G_OBJECT_CLASS (parent_class)->notify)
    G_OBJECT_CLASS (parent_class)->notify (object, pspec);

  if (! strcmp ("clone-type", g_param_spec_get_name (pspec)))
    GIMP_SOURCE_OPTIONS (object)->use_source =
      (GIMP_CLONE_OPTIONS (object)->clone_type == GIMP_IMAGE_CLONE);
}
示例#23
0
 static void
 gtkfilechooserwidget_notify_callback( GObject *WXUNUSED( gobject ), GParamSpec *arg1, wxGtkFileCtrl *fileCtrl )
 {
     const char *name = g_param_spec_get_name (arg1);
     if ( strcmp( name, "filter" ) == 0 &&
          fileCtrl->HasFilterChoice() &&
          !fileCtrl->GTKShouldIgnoreNextFilterEvent() )
     {
         GenerateFilterChangedEvent( fileCtrl, fileCtrl );
     }
 }
示例#24
0
static void
fs_transmitter_get_property (GObject *object,
                             guint prop_id,
                             GValue *value,
                             GParamSpec *pspec)
{
  GST_WARNING ("Subclass %s of FsTransmitter does not override the %s property"
      " getter",
      G_OBJECT_TYPE_NAME(object),
      g_param_spec_get_name (pspec));
}
示例#25
0
static void
layout_notify (GObject    *object,
               GParamSpec *pspec,
               gpointer    user_data)
{
  GObject *self = user_data;
  const char *prop_name = g_param_spec_get_name (pspec);

  if (g_object_class_find_property (G_OBJECT_GET_CLASS (self), prop_name))
    g_object_notify (self, prop_name);
}
static GObjectConstructParam *
find_construct_property (guint                  n_construct_properties,
                         GObjectConstructParam *construct_properties,
                         const gchar           *name)
{
    guint n;
    for (n = 0; n < n_construct_properties; n++)
        if (g_strcmp0 (g_param_spec_get_name (construct_properties[n].pspec), name) == 0)
            return &construct_properties[n];
    return NULL;
}
示例#27
0
static void
fs_session_set_property (GObject *object,
                         guint prop_id,
                         const GValue *value,
                         GParamSpec *pspec)
{
  GST_WARNING ("Subclass %s of FsSession does not override the %s property"
      " setter",
      G_OBJECT_TYPE_NAME(object),
      g_param_spec_get_name (pspec));
}
static void
extension_subclass_get_property (GObject    *object,
                                 guint       prop_id,
                                 GValue     *value,
                                 GParamSpec *pspec)
{
  g_debug ("Getting '%s:%s'",
           G_OBJECT_TYPE_NAME (object),
           g_param_spec_get_name (pspec));

  G_OBJECT_CLASS (get_parent_class (object))->get_property (object, prop_id,
                                                            value, pspec);
}
示例#29
0
文件: gegl-pad.c 项目: jonnor/gegl
void
gegl_pad_set_param_spec (GeglPad    *self,
                         GParamSpec *param_spec)
{
  g_return_if_fail (GEGL_IS_PAD (self));

  if (self->param_spec)
    g_param_spec_unref (self->param_spec);

  self->param_spec = g_param_spec_ref (param_spec);

  gegl_pad_set_name (self, g_param_spec_get_name (param_spec));
}
示例#30
0
static VALUE
inspect(VALUE self)
{
    GParamSpec* pspec = rbgobj_get_param_spec(self);
    VALUE v = rb_inspect(GTYPE2CLASS(pspec->owner_type));
    gchar* str = g_strdup_printf("#<%s: %s#%s>",
                                 rb_class2name(CLASS_OF(self)),
                                 StringValuePtr(v),
                                 g_param_spec_get_name(pspec));
    VALUE result = rb_str_new2(str);
    g_free(str);
    return result;
}