Re: Can't read gtk-double-click-time property



Lars Clausen wrote:

I'm trying to get the default setting for gtk-double-click-time, but can't
seem to get it out of the GtkSettings object.  Here's what I do:

   GtkSettings *settings = gtk_settings_get_default();
   GValue dctvalue;

Hmm, you need to do this, to initialize GValue:

{
GValue dctvalue={0};

/* if you want to be sure that value is initialized as G_TYPE_INT value */
	g_init_value(&dctvalue, G_TYPE_INT);
}


   if (settings == NULL) {
     g_message(_("Couldn't get GTK settings"));
   } else {
g_object_get(G_OBJECT(settings), "gtk-double-click-time", &dctvalue, NULL);

g_object_get() doesn't accept the GValues, pass the pointer to gint instead:

{
gint double_click;
	g_object_get(
G_OBJECT(settings), "gtk-double-click-time", &double_click,
			NULL
	);
}

Or (if you want to play with GValue):

{
GValue value={0};
	g_init_value(&value, G_TYPE_INT);
	g_object_get_property(
				(GObject*)object,
				"gtk-double-click-time",
				&value
	);

   /* now you can use g_value_get_int() */

}


     if (g_type_is_a(G_VALUE_TYPE(&dctvalue), G_TYPE_INT)) {
	double_click_time = g_value_get_int(&dctvalue);
     }
   }

The settings are non-null, but g_object_get doesn't give me the value.  I
also get this error:

(lt-dia:1687): GLib-GObject-CRITICAL **: file gvaluetypes.c: line 820 (g_strdup_value_contents): assertion `G_IS_VALUE (value)' failed


Olexiy





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]