gnome-games r8428 - trunk/aisleriot
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8428 - trunk/aisleriot
- Date: Tue, 6 Jan 2009 18:18:24 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:18:24 2009
New Revision: 8428
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8428&view=rev
Log:
Move the card theme font options setting code to a style-set handler in
AisleriotWindow, eliminating duplicated code from the two AisleriotBoard
implementations.
Modified:
trunk/aisleriot/board-noclutter.c
trunk/aisleriot/board.c
trunk/aisleriot/window.c
Modified: trunk/aisleriot/board-noclutter.c
==============================================================================
--- trunk/aisleriot/board-noclutter.c (original)
+++ trunk/aisleriot/board-noclutter.c Tue Jan 6 18:18:24 2009
@@ -1403,29 +1403,6 @@
#endif /* !HAVE_HILDON */
}
-#if GTK_CHECK_VERSION (2, 10, 0)
-static void
-aisleriot_board_screen_font_options_changed (GdkScreen *screen,
- GParamSpec *pspec,
- AisleriotBoard *board)
-{
- AisleriotBoardPrivate *priv = board->priv;
- GtkWidget *widget = GTK_WIDGET (board);
- const cairo_font_options_t *font_options;
-
- if (!priv->theme)
- return;
-
- font_options = gdk_screen_get_font_options (gtk_widget_get_screen (widget));
- games_card_theme_set_font_options (priv->theme, font_options);
-
- /* FIXMEchpe: clear the cached cards in the slots! */
- if (GTK_WIDGET_REALIZED (widget)) {
- gtk_widget_queue_draw (widget);
- }
-}
-#endif /* GTK 2.10.0 */
-
/* Note: this unsets the selection! */
static gboolean
aisleriot_board_move_selected_cards_to_slot (AisleriotBoard *board,
@@ -2505,9 +2482,6 @@
g_signal_handlers_disconnect_by_func (gtk_settings_get_for_screen (previous_screen),
G_CALLBACK (aisleriot_board_settings_update),
board);
- g_signal_handlers_disconnect_by_func (previous_screen,
- G_CALLBACK (aisleriot_board_screen_font_options_changed),
- board);
}
if (screen == NULL)
@@ -2522,12 +2496,6 @@
g_signal_connect (settings, "notify::gtk-touchscreen-mode",
G_CALLBACK (aisleriot_board_settings_update), board);
#endif /* !HAVE_HILDON */
-
-#if GTK_CHECK_VERSION (2, 10, 0)
- aisleriot_board_screen_font_options_changed (screen, NULL, board);
- g_signal_connect (screen, "notify::font-options",
- G_CALLBACK (aisleriot_board_screen_font_options_changed), board);
-#endif
}
static void
@@ -3386,10 +3354,6 @@
widget);
#endif
- g_signal_handlers_disconnect_by_func (gtk_widget_get_screen (GTK_WIDGET (object)),
- G_CALLBACK (aisleriot_board_screen_font_options_changed),
- board);
-
G_OBJECT_CLASS (aisleriot_board_parent_class)->finalize (object);
}
@@ -3650,14 +3614,6 @@
priv->geometry_set = FALSE;
priv->slot_image = NULL;
- if (gtk_widget_has_screen (widget)) {
-#warning FIXMEchpe move this to AisleriotWindow
- const cairo_font_options_t *font_options;
-
- font_options = gdk_screen_get_font_options (gtk_widget_get_screen (widget));
- games_card_theme_set_font_options (theme, font_options);
- }
-
priv->theme = g_object_ref (theme);
games_card_images_set_theme (priv->images, priv->theme);
Modified: trunk/aisleriot/board.c
==============================================================================
--- trunk/aisleriot/board.c (original)
+++ trunk/aisleriot/board.c Tue Jan 6 18:18:24 2009
@@ -1473,29 +1473,6 @@
#endif /* !HAVE_HILDON */
}
-#if GTK_CHECK_VERSION (2, 10, 0)
-static void
-aisleriot_board_screen_font_options_changed (GdkScreen *screen,
- GParamSpec *pspec,
- AisleriotBoard *board)
-{
- AisleriotBoardPrivate *priv = board->priv;
- GtkWidget *widget = GTK_WIDGET (board);
- const cairo_font_options_t *font_options;
-
- if (!priv->theme)
- return;
-
- font_options = gdk_screen_get_font_options (gtk_widget_get_screen (widget));
- games_card_theme_set_font_options (priv->theme, font_options);
-
- /* FIXMEchpe: clear the cached cards in the slots! */
- if (GTK_WIDGET_REALIZED (widget)) {
- gtk_widget_queue_draw (widget);
- }
-}
-#endif /* GTK 2.10.0 */
-
/* Note: this unsets the selection! */
static gboolean
aisleriot_board_move_selected_cards_to_slot (AisleriotBoard *board,
@@ -2582,9 +2559,6 @@
g_signal_handlers_disconnect_by_func (gtk_settings_get_for_screen (previous_screen),
G_CALLBACK (aisleriot_board_settings_update),
board);
- g_signal_handlers_disconnect_by_func (previous_screen,
- G_CALLBACK (aisleriot_board_screen_font_options_changed),
- board);
}
if (screen == NULL)
@@ -2601,13 +2575,6 @@
g_signal_connect (settings, "notify::gtk-touchscreen-mode",
G_CALLBACK (aisleriot_board_settings_update), board);
#endif /* !HAVE_HILDON */
-
-#if GTK_CHECK_VERSION (2, 10, 0)
- /* FIXMEchpe: this can be replaced by a simple style-set handler! */
- aisleriot_board_screen_font_options_changed (screen, NULL, board);
- g_signal_connect (screen, "notify::font-options",
- G_CALLBACK (aisleriot_board_screen_font_options_changed), board);
-#endif
}
static void
@@ -3216,10 +3183,6 @@
widget);
#endif
- g_signal_handlers_disconnect_by_func (gtk_widget_get_screen (GTK_WIDGET (object)),
- G_CALLBACK (aisleriot_board_screen_font_options_changed),
- board);
-
G_OBJECT_CLASS (aisleriot_board_parent_class)->finalize (object);
}
@@ -3503,14 +3466,6 @@
priv->geometry_set = FALSE;
- if (gtk_widget_has_screen (widget)) {
- const cairo_font_options_t *font_options;
-
-#warning FIXMEchpe move this to AisleriotWindow
- font_options = gdk_screen_get_font_options (gtk_widget_get_screen (widget));
- games_card_theme_set_font_options (theme, font_options);
- }
-
priv->theme = g_object_ref (theme);
games_card_images_set_theme (priv->images, priv->theme);
Modified: trunk/aisleriot/window.c
==============================================================================
--- trunk/aisleriot/window.c (original)
+++ trunk/aisleriot/window.c Tue Jan 6 18:18:24 2009
@@ -1436,33 +1436,26 @@
/* Card Theme menu */
static void
-card_theme_changed_cb (GtkToggleAction *action,
- AisleriotWindow *window)
+aisleriot_window_take_card_theme (AisleriotWindow *window,
+ GamesCardTheme *theme /* adopting */)
{
AisleriotWindowPrivate *priv = window->priv;
- GamesCardThemeInfo *info;
- GamesCardTheme *theme;
+ GtkWidget *widget = GTK_WIDGET (window);
- if (!gtk_toggle_action_get_active (action))
+ if (theme == priv->theme)
return;
- info = g_object_get_data (G_OBJECT (action), "card-theme-info");
- g_return_if_fail (info != NULL);
-
- if (priv->theme != NULL &&
- info == games_card_theme_get_theme (priv->theme))
- return;
-
- theme = games_card_theme_get (info);
- if (!theme)
- return; // FIXMEchpe re-set the right radio action to active!!
-
if (priv->theme) {
g_object_unref (priv->theme);
}
priv->theme = theme;
- aisleriot_board_set_card_theme (priv->board, theme);
+ if (gtk_widget_has_screen (widget)) {
+ const cairo_font_options_t *font_options;
+
+ font_options = gdk_screen_get_font_options (gtk_widget_get_screen (widget));
+ games_card_theme_set_font_options (theme, font_options);
+ }
//XXX FIXMEchpe
#if 0//#ifdef HAVE_GNOME
@@ -1478,6 +1471,33 @@
// XXX FIXMEchpe
//games_conf_set_string (NULL, aisleriot_conf_get_key (CONF_THEME), theme);
// }
+
+ aisleriot_board_set_card_theme (priv->board, theme);
+}
+
+static void
+card_theme_changed_cb (GtkToggleAction *action,
+ AisleriotWindow *window)
+{
+ AisleriotWindowPrivate *priv = window->priv;
+ GamesCardThemeInfo *info;
+ GamesCardTheme *theme;
+
+ if (!gtk_toggle_action_get_active (action))
+ return;
+
+ info = g_object_get_data (G_OBJECT (action), "card-theme-info");
+ g_return_if_fail (info != NULL);
+
+ if (priv->theme != NULL &&
+ info == games_card_theme_get_theme (priv->theme))
+ return;
+
+ theme = games_card_theme_get (info);
+ if (!theme)
+ return; // FIXMEchpe re-set the right radio action to active!!
+
+ aisleriot_window_take_card_theme (window, theme);
}
static void
@@ -1951,6 +1971,32 @@
G_DEFINE_TYPE (AisleriotWindow, aisleriot_window, GTK_TYPE_WINDOW);
#endif
+#if GTK_CHECK_VERSION (2, 10, 0)
+
+static void
+aisleriot_window_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ AisleriotWindow *window = AISLERIOT_WINDOW (widget);
+ AisleriotWindowPrivate *priv = window->priv;
+ const cairo_font_options_t *font_options;
+ void (* style_set) (GtkWidget *, GtkStyle *) =
+ GTK_WIDGET_CLASS (aisleriot_window_parent_class)->style_set;
+
+ if (style_set)
+ style_set (widget, previous_style);
+
+ if (!priv->theme)
+ return;
+
+ font_options = gdk_screen_get_font_options (gtk_widget_get_screen (widget));
+ games_card_theme_set_font_options (priv->theme, font_options);
+
+ /* FIXMEchpe: clear the cached cards in the slots?? */
+}
+
+#endif /* GTK >= 2.10.0 */
+
static gboolean
aisleriot_window_state_event (GtkWidget *widget,
GdkEventWindowState *event)
@@ -2335,8 +2381,6 @@
aisleriot_board_set_pixbuf_drawing (priv->board, priv->use_pixbuf_drawing);
- aisleriot_board_set_card_theme (priv->board, games_card_theme_get_any ());
-
#if 0
// FIXMEchpe
theme = games_conf_get_string (NULL, aisleriot_conf_get_key (CONF_THEME), NULL);
@@ -2357,6 +2401,8 @@
g_free (theme);
#endif
+ aisleriot_window_take_card_theme (window, games_card_theme_get_any ());
+
priv->action_group = gtk_action_group_new ("MenuActions");
gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE);
gtk_action_group_add_actions (priv->action_group,
@@ -2629,6 +2675,9 @@
gobject_class->finalize = aisleriot_window_finalize;
widget_class->window_state_event = aisleriot_window_state_event;
+#if GTK_CHECK_VERSION (2, 10, 0)
+ widget_class->style_set = aisleriot_window_style_set;
+#endif
g_type_class_add_private (gobject_class, sizeof (AisleriotWindowPrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]