]> Pileus Git - ~andy/gtk/commitdiff
settings: Move setting property registration in gtksettings.c
authorEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 19 Oct 2010 10:47:40 +0000 (11:47 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 20 Oct 2010 09:34:25 +0000 (10:34 +0100)
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

gtk/gtkbutton.c
gtk/gtkcolorsel.c
gtk/gtkentry.c
gtk/gtkimagemenuitem.c
gtk/gtklabel.c
gtk/gtkmenu.c
gtk/gtkmenubar.c
gtk/gtkscrolledwindow.c
gtk/gtksettings.c
modules/input/gtkimcontextxim.c

index b862ebf07753d0f4862747647fd5a7283e747138..940b2cc93fef05bca1acaac1690e05778a79d4e9 100644 (file)
@@ -538,19 +538,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));
 }
 
index 1814394697197859db1327d854f76b607dbc04f1..100f764dd956082b253106ab9f6440c40bcf23d5 100644 (file)
@@ -63,6 +63,9 @@
 #include "gtkprivate.h"
 #include "gtkintl.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
@@ -235,8 +238,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;
 
@@ -341,13 +342,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 (GtkColorSelectionPrivate));
+  g_type_class_add_private (gobject_class, sizeof (GtkColorSelectionPrivate));
 }
 
 static void
@@ -1189,13 +1184,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
     {
@@ -1207,14 +1202,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;
index 040d35bb45387990cfef9084fa1002a57a743386..67f7565657350d060d0eeaae6136c22145dcd9d5 100644 (file)
@@ -1741,28 +1741,7 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                                P_("Inner Border"),
                                                                P_("Border between text and frame."),
                                                                GTK_TYPE_BORDER,
-                                                               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));
+                                                               GTK_PARAM_READABLE)); 
 
   g_type_class_add_private (gobject_class, sizeof (GtkEntryPrivate));
 }
index 16d8ddca4265c487e92152ed7be0da77b81e331a..e39c3c10d8d15faaf1c02d4b6e269d2e3c1299a4 100644 (file)
@@ -189,13 +189,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 (klass, sizeof (GtkImageMenuItemPrivate));
+    g_type_class_add_private (klass, sizeof (GtkImageMenuItemPrivate));
 }
 
 static void
index 1f05d05936a3e3d4107c05908aeab0af5059a9af..f024b2847e6732b7da77c39c8c35aa7af410e34d 100644 (file)
@@ -899,12 +899,6 @@ gtk_label_class_init (GtkLabelClass *class)
   gtk_binding_entry_add_signal (binding_set, GDK_KEY_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));
 }
 
index 0199614b345a348b703c5670364ad8c3ce5b321f..c5b3109e041089d2cac9ea4f4ddbec1795b2b64b 100644 (file)
@@ -44,9 +44,6 @@
 #include "gtkprivate.h"
 #include "gtkintl.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
                                         */
@@ -817,28 +814,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));
 }
 
index 298f6258c650dfd59ba20995f21afa6a9f80e234..8dab56b972aab443d9533cf6dea846e39f65db7f 100644 (file)
@@ -201,14 +201,6 @@ 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));
 }
 
index bdd4a2d197bf8b68b0fbec9515e7109018516160..191c3c3921feedb864f09aa3165706e7cce8f3ed 100644 (file)
@@ -380,21 +380,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
                                                             DEFAULT_SCROLLBAR_SPACING,
                                                             GTK_PARAM_READABLE));
 
-  /**
-   * 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
-   */
-  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));
-
   /**
    * GtkScrolledWindow::scroll-child:
    * @scrolled_window: a #GtkScrolledWindow
index 9152c33f1fd156952a38d2563ad294d9a9d8164f..4ea8685bd68fb4e4f166e44a2a447685330fa07c 100644 (file)
@@ -126,10 +126,22 @@ enum {
   PROP_TOOLBAR_STYLE,
   PROP_TOOLBAR_ICON_SIZE,
   PROP_AUTO_MNEMONICS,
-  PROP_APPLICATION_PREFER_DARK_THEME
+  PROP_APPLICATION_PREFER_DARK_THEME,
+  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;
@@ -1044,6 +1060,154 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                                                  GTK_PARAM_READWRITE),
                                              NULL);
   g_assert (result == PROP_APPLICATION_PREFER_DARK_THEME);
+
+  /**
+   * 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
index df00becae241069eaca8fb6ad283d86e4caa58f7..c9de4207c6e11c48a43f5e2fc828048dc29ed6d8 100644 (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),