settings: Move setting property registration in gtksettings.c

Some GtkSettings property are registered by other classes. This leads
to the "interesting" issue that setting GtkSettings:gtk-button-images
requires that the GtkButton class is referenced first - or that a
GtkButton is created.

https://bugzilla.gnome.org/show_bug.cgi?id=632538

This commit is a cherry-pick from master which (sadly) fixed the issue
only after we started the 2.9x work, and I completely forgot to backport
it. This is needed because GTK 2.x started tripping the warning added in
GObject by this bug:

https://bugzilla.gnome.org/show_bug.cgi?id=698614

Cherry-picked-from: 9f9edb662e
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
This commit is contained in:
Emmanuele Bassi 2010-10-19 11:47:40 +01:00
parent 59d49e1566
commit 162430fe5a
10 changed files with 191 additions and 134 deletions

View File

@ -519,19 +519,6 @@ gtk_button_class_init (GtkButtonClass *klass)
2,
GTK_PARAM_READABLE));
/**
* GtkSettings::gtk-button-images:
*
* Whether images should be shown on buttons
*
* Since: 2.4
*/
gtk_settings_install_property (g_param_spec_boolean ("gtk-button-images",
P_("Show button images"),
P_("Whether images should be shown on buttons"),
TRUE,
GTK_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (GtkButtonPrivate));
}

View File

@ -61,6 +61,9 @@
#include "gtkintl.h"
#include "gtkalias.h"
/* Keep it in sync with gtksettings.c:default_color_palette */
#define DEFAULT_COLOR_PALETTE "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90"
/* Number of elements in the custom palatte */
#define GTK_CUSTOM_PALETTE_WIDTH 10
#define GTK_CUSTOM_PALETTE_HEIGHT 2
@ -232,8 +235,6 @@ static void shutdown_eyedropper (GtkWidget *widget);
static guint color_selection_signals[LAST_SIGNAL] = { 0 };
static const gchar default_colors[] = "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90";
static GtkColorSelectionChangePaletteFunc noscreen_change_palette_hook = default_noscreen_change_palette_func;
static GtkColorSelectionChangePaletteWithScreenFunc change_palette_hook = default_change_palette_func;
@ -320,13 +321,7 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gtk_settings_install_property (g_param_spec_string ("gtk-color-palette",
P_("Custom palette"),
P_("Palette to use in the color selector"),
default_colors,
GTK_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (ColorSelectionPrivate));
g_type_class_add_private (gobject_class, sizeof (ColorSelectionPrivate));
}
static void
@ -1175,13 +1170,13 @@ get_current_colors (GtkColorSelection *colorsel)
gchar *palette;
settings = gtk_widget_get_settings (GTK_WIDGET (colorsel));
g_object_get (settings,
"gtk-color-palette", &palette,
NULL);
g_object_get (settings, "gtk-color-palette", &palette, NULL);
if (!gtk_color_selection_palette_from_string (palette, &colors, &n_colors))
{
gtk_color_selection_palette_from_string (default_colors, &colors, &n_colors);
gtk_color_selection_palette_from_string (DEFAULT_COLOR_PALETTE,
&colors,
&n_colors);
}
else
{
@ -1193,14 +1188,17 @@ get_current_colors (GtkColorSelection *colorsel)
GdkColor *tmp_colors = colors;
gint tmp_n_colors = n_colors;
gtk_color_selection_palette_from_string (default_colors, &colors, &n_colors);
gtk_color_selection_palette_from_string (DEFAULT_COLOR_PALETTE,
&colors,
&n_colors);
memcpy (colors, tmp_colors, sizeof (GdkColor) * tmp_n_colors);
g_free (tmp_colors);
}
}
g_assert (n_colors >= GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
/* make sure that we fill every slot */
g_assert (n_colors == GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
g_free (palette);
return colors;

View File

@ -1759,27 +1759,6 @@ gtk_entry_class_init (GtkEntryClass *class)
FALSE,
GTK_PARAM_READABLE));
gtk_settings_install_property (g_param_spec_boolean ("gtk-entry-select-on-focus",
P_("Select on focus"),
P_("Whether to select the contents of an entry when it is focused"),
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkSettings:gtk-entry-password-hint-timeout:
*
* How long to show the last input character in hidden
* entries. This value is in milliseconds. 0 disables showing the
* last char. 600 is a good value for enabling it.
*
* Since: 2.10
*/
gtk_settings_install_property (g_param_spec_uint ("gtk-entry-password-hint-timeout",
P_("Password Hint Timeout"),
P_("How long to show the last input character in hidden entries"),
0, G_MAXUINT, 0,
GTK_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (GtkEntryPrivate));
}

View File

@ -186,15 +186,7 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
GTK_TYPE_ACCEL_GROUP,
GTK_PARAM_WRITABLE));
gtk_settings_install_property (g_param_spec_boolean ("gtk-menu-images",
P_("Show menu images"),
P_("Whether images should be shown in menus"),
TRUE,
GTK_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (GtkImageMenuItemPrivate));
g_type_class_add_private (klass, sizeof (GtkImageMenuItemPrivate));
}
static void

View File

@ -855,13 +855,6 @@ gtk_label_class_init (GtkLabelClass *class)
gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0,
"activate-current-link", 0);
gtk_settings_install_property (g_param_spec_boolean ("gtk-label-select-on-focus",
P_("Select on focus"),
P_("Whether to select the contents of a selectable label when it is focused"),
TRUE,
GTK_PARAM_READWRITE));
g_type_class_add_private (class, sizeof (GtkLabelPrivate));
}

View File

@ -46,9 +46,6 @@
#include "gtkalias.h"
#define DEFAULT_POPUP_DELAY 225
#define DEFAULT_POPDOWN_DELAY 1000
#define NAVIGATION_REGION_OVERSHOOT 50 /* How much the navigation region
* extends below the submenu
*/
@ -801,28 +798,6 @@ gtk_menu_class_init (GtkMenuClass *class)
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_PAGE_DOWN);
gtk_settings_install_property (g_param_spec_boolean ("gtk-can-change-accels",
P_("Can change accelerators"),
P_("Whether menu accelerators can be changed by pressing a key over the menu item"),
FALSE,
GTK_PARAM_READWRITE));
gtk_settings_install_property (g_param_spec_int ("gtk-menu-popup-delay",
P_("Delay before submenus appear"),
P_("Minimum time the pointer must stay over a menu item before the submenu appear"),
0,
G_MAXINT,
DEFAULT_POPUP_DELAY,
GTK_PARAM_READWRITE));
gtk_settings_install_property (g_param_spec_int ("gtk-menu-popdown-delay",
P_("Delay before hiding a submenu"),
P_("The time before hiding a submenu when the pointer is moving towards the submenu"),
0,
G_MAXINT,
DEFAULT_POPDOWN_DELAY,
GTK_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (GtkMenuPrivate));
}

View File

@ -206,15 +206,7 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
DEFAULT_IPADDING,
GTK_PARAM_READABLE));
gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
P_("Delay before drop down menus appear"),
P_("Delay before the submenus of a menu bar appear"),
0,
G_MAXINT,
0,
GTK_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
}
static void

View File

@ -301,21 +301,18 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
GTK_PARAM_READABLE));
/**
* GtkSettings:gtk-scrolled-window-placement:
* GtkScrolledWindow::scroll-child:
* @scrolled_window: a #GtkScrolledWindow
* @scroll: a #GtkScrollType describing how much to scroll
* @horizontal: whether the keybinding scrolls the child
* horizontally or not
*
* Where the contents of scrolled windows are located with respect to the
* scrollbars, if not overridden by the scrolled window's own placement.
*
* Since: 2.10
* The ::scroll-child signal is a
* <link linkend="keybinding-signals">keybinding signal</link>
* which gets emitted when a keybinding that scrolls is pressed.
* The horizontal or vertical adjustment is updated which triggers a
* signal that the scrolled windows child may listen to and scroll itself.
*/
gtk_settings_install_property (g_param_spec_enum ("gtk-scrolled-window-placement",
P_("Scrolled Window Placement"),
P_("Where the contents of scrolled windows are located with respect to the scrollbars, if not overridden by the scrolled window's own placement."),
GTK_TYPE_CORNER_TYPE,
GTK_CORNER_TOP_LEFT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
signals[SCROLL_CHILD] =
g_signal_new (I_("scroll-child"),
G_TYPE_FROM_CLASS (object_class),

View File

@ -126,10 +126,22 @@ enum {
PROP_TOOLBAR_STYLE,
PROP_TOOLBAR_ICON_SIZE,
PROP_AUTO_MNEMONICS,
PROP_PRIMARY_BUTTON_WARPS_SLIDER
PROP_PRIMARY_BUTTON_WARPS_SLIDER,
PROP_BUTTON_IMAGES,
PROP_ENTRY_SELECT_ON_FOCUS,
PROP_ENTRY_PASSWORD_HINT_TIMEOUT,
PROP_MENU_IMAGES,
PROP_MENU_BAR_POPUP_DELAY,
PROP_SCROLLED_WINDOW_PLACEMENT,
PROP_CAN_CHANGE_ACCELS,
PROP_MENU_POPUP_DELAY,
PROP_MENU_POPDOWN_DELAY,
PROP_LABEL_SELECT_ON_FOCUS,
PROP_COLOR_PALETTE,
PROP_IM_PREEDIT_STYLE,
PROP_IM_STATUS_STYLE
};
/* --- prototypes --- */
static void gtk_settings_finalize (GObject *object);
static void gtk_settings_get_property (GObject *object,
@ -162,6 +174,10 @@ static void merge_color_scheme (GtkSettings *setting
static gchar *get_color_scheme (GtkSettings *settings);
static GHashTable *get_color_hash (GtkSettings *settings);
/* the default palette for GtkColorSelelection */
static const gchar default_color_palette[] =
"black:white:gray50:red:purple:blue:light blue:green:yellow:orange:"
"lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90";
/* --- variables --- */
static GQuark quark_property_parser = 0;
@ -1040,8 +1056,155 @@ gtk_settings_class_init (GtkSettingsClass *class)
FALSE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_PRIMARY_BUTTON_WARPS_SLIDER);
/**
* GtkSettings::gtk-button-images:
*
* Whether images should be shown on buttons
*
* Since: 2.4
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-button-images",
P_("Show button images"),
P_("Whether images should be shown on buttons"),
TRUE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_BUTTON_IMAGES);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-entry-select-on-focus",
P_("Select on focus"),
P_("Whether to select the contents of an entry when it is focused"),
TRUE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_ENTRY_SELECT_ON_FOCUS);
/**
* GtkSettings:gtk-entry-password-hint-timeout:
*
* How long to show the last input character in hidden
* entries. This value is in milliseconds. 0 disables showing the
* last char. 600 is a good value for enabling it.
*
* Since: 2.10
*/
result = settings_install_property_parser (class,
g_param_spec_uint ("gtk-entry-password-hint-timeout",
P_("Password Hint Timeout"),
P_("How long to show the last input character in hidden entries"),
0, G_MAXUINT,
0,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_ENTRY_PASSWORD_HINT_TIMEOUT);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-menu-images",
P_("Show menu images"),
P_("Whether images should be shown in menus"),
TRUE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_MENU_IMAGES);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-menu-bar-popup-delay",
P_("Delay before drop down menus appear"),
P_("Delay before the submenus of a menu bar appear"),
0, G_MAXINT,
0,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_MENU_BAR_POPUP_DELAY);
/**
* GtkSettings:gtk-scrolled-window-placement:
*
* Where the contents of scrolled windows are located with respect to the
* scrollbars, if not overridden by the scrolled window's own placement.
*
* Since: 2.10
*/
result = settings_install_property_parser (class,
g_param_spec_enum ("gtk-scrolled-window-placement",
P_("Scrolled Window Placement"),
P_("Where the contents of scrolled windows are located with respect to the scrollbars, if not overridden by the scrolled window's own placement."),
GTK_TYPE_CORNER_TYPE,
GTK_CORNER_TOP_LEFT,
GTK_PARAM_READWRITE),
gtk_rc_property_parse_enum);
g_assert (result == PROP_SCROLLED_WINDOW_PLACEMENT);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-can-change-accels",
P_("Can change accelerators"),
P_("Whether menu accelerators can be changed by pressing a key over the menu item"),
FALSE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_CAN_CHANGE_ACCELS);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-menu-popup-delay",
P_("Delay before submenus appear"),
P_("Minimum time the pointer must stay over a menu item before the submenu appear"),
0, G_MAXINT,
225,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_MENU_POPUP_DELAY);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-menu-popdown-delay",
P_("Delay before hiding a submenu"),
P_("The time before hiding a submenu when the pointer is moving towards the submenu"),
0, G_MAXINT,
1000,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_MENU_POPDOWN_DELAY);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-label-select-on-focus",
P_("Select on focus"),
P_("Whether to select the contents of a selectable label when it is focused"),
TRUE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_LABEL_SELECT_ON_FOCUS);
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-color-palette",
P_("Custom palette"),
P_("Palette to use in the color selector"),
default_color_palette,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_COLOR_PALETTE);
result = settings_install_property_parser (class,
g_param_spec_enum ("gtk-im-preedit-style",
P_("IM Preedit style"),
P_("How to draw the input method preedit string"),
GTK_TYPE_IM_PREEDIT_STYLE,
GTK_IM_PREEDIT_CALLBACK,
GTK_PARAM_READWRITE),
gtk_rc_property_parse_enum);
g_assert (result == PROP_IM_PREEDIT_STYLE);
result = settings_install_property_parser (class,
g_param_spec_enum ("gtk-im-status-style",
P_("IM Status style"),
P_("How to draw the input method statusbar"),
GTK_TYPE_IM_STATUS_STYLE,
GTK_IM_STATUS_CALLBACK,
GTK_PARAM_READWRITE),
gtk_rc_property_parse_enum);
g_assert (result == PROP_IM_STATUS_STYLE);
}
static void

View File

@ -327,25 +327,6 @@ setup_im (GtkXIMInfo *info)
NULL);
info->settings = gtk_settings_get_for_screen (info->screen);
if (!g_object_class_find_property (G_OBJECT_GET_CLASS (info->settings),
"gtk-im-preedit-style"))
gtk_settings_install_property (g_param_spec_enum ("gtk-im-preedit-style",
P_("IM Preedit style"),
P_("How to draw the input method preedit string"),
GTK_TYPE_IM_PREEDIT_STYLE,
GTK_IM_PREEDIT_CALLBACK,
G_PARAM_READWRITE));
if (!g_object_class_find_property (G_OBJECT_GET_CLASS (info->settings),
"gtk-im-status-style"))
gtk_settings_install_property (g_param_spec_enum ("gtk-im-status-style",
P_("IM Status style"),
P_("How to draw the input method statusbar"),
GTK_TYPE_IM_STATUS_STYLE,
GTK_IM_STATUS_CALLBACK,
G_PARAM_READWRITE));
info->status_set = g_signal_connect_swapped (info->settings,
"notify::gtk-im-status-style",
G_CALLBACK (status_style_change),