Re: gdk_settings()
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Subject: Re: gdk_settings()
- Date: 03 Apr 2001 10:23:23 -0400
Tim Janik <timj gtk org> writes:
> hey owen,
>
> haven't looked at the gdk_settings code yet, but i don#t particularly like:
>
> static void
> gtk_settings_get_property (GObject *object,
> guint property_id,
> GValue *value,
> GParamSpec *pspec)
> {
> GtkSettings *settings = GTK_SETTINGS (object);
>
> if (!gdk_setting_get (pspec->name, value))
> g_value_copy (settings->property_values + property_id - 1, value);
> }
>
>
> void
> _gtk_settings_handle_event (GdkEventSetting *event)
> {
> GtkSettings *settings = gtk_settings_get_global ();
>
> if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name))
> g_object_notify (G_OBJECT (settings), event->name);
> }
>
>
> gtk_settings_get_property() should furtherly retrive values
> only from its local copy, and _gtk_settings_handle_event() should
> simply get the new value from gdk and set it on gtksettings, i.e.:
>
> static void
> gtk_settings_get_property (GObject *object,
> guint property_id,
> GValue *value,
> GParamSpec *pspec)
> {
> GtkSettings *settings = GTK_SETTINGS (object);
>
> g_value_copy (settings->property_values + property_id - 1, value);
> }
>
>
> void
> _gtk_settings_handle_event (GdkEventSetting *event)
> {
> GtkSettings *settings = gtk_settings_get_global ();
> GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name);
>
> if (pspec)
> {
> GValue tmp_value = { 0, };
>
> g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
> gdk_setting_get (pspec->name, &tmp_value);
> g_object_set_property (G_OBJECT (settings), pspec->name, &tmp_value);
> g_value_unset (&tmp_value);
> }
> }
>
>
> is there any reason you didn't do things this way?
I originally did it essentially in this way, but backed that out and did
it the way that it is now for a number of reasons:
- When a property is unset through the XSETTINGS mechanism, it should be
restored to the RC file value, not to the default value
- Even restoring to the default value required quite a bit of changes
to GtkSettings because it became necessary to be able to unset
a value.
- By reading through to GDK, instead of trying to mirror, you get
consistency when multiple related settings change at once.
(Otherwise, you would need to have more types of events, with a
freeze-notify and thaw-notify, which is just ugly.)
- It was a lot simpler the current way.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]