summaryrefslogtreecommitdiff
path: root/gtk/gtkwin32theme.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2016-02-14 00:54:37 +0100
committerBenjamin Otte <otte@gnome.org>2016-02-15 04:41:12 +0100
commit3b19db425e63fb6f16b1daf4c8da288c631e1cc0 (patch)
tree33bad8c455fdc4830b22e7b898e55894a9d9ab42 /gtk/gtkwin32theme.c
parent915fe87a629319c3a089874c148ec5b4319e3f09 (diff)
downloadgtk+-3b19db425e63fb6f16b1daf4c8da288c631e1cc0.tar.gz
css: Add a number value handling win32 sizes
Diffstat (limited to 'gtk/gtkwin32theme.c')
-rw-r--r--gtk/gtkwin32theme.c99
1 files changed, 27 insertions, 72 deletions
diff --git a/gtk/gtkwin32theme.c b/gtk/gtkwin32theme.c
index 167abf375a..c55a66a314 100644
--- a/gtk/gtkwin32theme.c
+++ b/gtk/gtkwin32theme.c
@@ -126,6 +126,14 @@ gtk_win32_theme_unref (GtkWin32Theme *theme)
g_slice_free (GtkWin32Theme, theme);
}
+gboolean
+gtk_win32_theme_equal (GtkWin32Theme *theme1,
+ GtkWin32Theme *theme2)
+{
+ /* Themes are cached so they're guaranteed unique. */
+ return theme1 == theme2;
+}
+
#ifdef G_OS_WIN32
static GdkFilterReturn
@@ -213,8 +221,6 @@ gtk_win32_theme_init (void)
use_xp_theme = FALSE;
}
- themes_by_class = g_hash_table_new (g_str_hash, g_str_equal);
-
gdk_window_add_filter (NULL, invalidate_win32_themes, NULL);
}
@@ -246,6 +252,9 @@ gtk_win32_theme_lookup (const char *classname)
{
GtkWin32Theme *theme;
+ if (G_UNLIKELY (themes_by_class == NULL))
+ themes_by_class = g_hash_table_new (g_str_hash, g_str_equal);
+
theme = g_hash_table_lookup (themes_by_class, classname);
if (theme != NULL)
@@ -353,82 +362,22 @@ gtk_win32_theme_create_surface (GtkWin32Theme *theme,
}
int
-_gtk_win32_theme_int_parse (GtkCssParser *parser,
- int *value)
+gtk_win32_theme_get_size (GtkWin32Theme *theme,
+ int id)
{
- char *theme_class;
- int arg;
#ifdef G_OS_WIN32
- GtkWin32Theme *theme;
- HTHEME htheme;
-#endif
-
- if (_gtk_css_parser_try (parser,
- "-gtk-win32-size",
- TRUE))
+ if (use_xp_theme && get_theme_sys_metric != NULL)
{
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- _gtk_css_parser_error (parser,
- "Expected '(' after '-gtk-win32-size'");
- return 0;
- }
-
- theme_class = _gtk_css_parser_try_name (parser, TRUE);
- if (theme_class == NULL)
- {
- _gtk_css_parser_error (parser,
- "Expected name as first argument to '-gtk-win32-size'");
- return 0;
- }
-
- if (! _gtk_css_parser_try (parser, ",", TRUE))
- {
- g_free (theme_class);
- _gtk_css_parser_error (parser,
- "Expected ','");
- return 0;
- }
-
- if (!_gtk_css_parser_try_int (parser, &arg))
- {
- g_free (theme_class);
- _gtk_css_parser_error (parser, "Expected a valid integer value");
- return 0;
- }
-
- if (!_gtk_css_parser_try (parser, ")", TRUE))
- {
- g_free (theme_class);
- _gtk_css_parser_error (parser,
- "Expected ')'");
- return 0;
- }
+ HTHEME htheme = gtk_win32_theme_get_htheme (theme);
-#ifdef G_OS_WIN32
- theme = gtk_win32_theme_lookup (theme_class);
- if (use_xp_theme && get_theme_sys_metric != NULL)
- {
- htheme = gtk_win32_theme_get_htheme (theme);
-
- /* If htheme is NULL it will just return the GetSystemMetrics value */
- *value = get_theme_sys_metric (htheme, arg);
- }
- else
- *value = GetSystemMetrics (arg);
-
- gtk_win32_theme_unref (theme);
-
-#else
- *value = 1;
-#endif
-
- g_free (theme_class);
-
- return 1;
+ /* If htheme is NULL it will just return the GetSystemMetrics value */
+ return get_theme_sys_metric (htheme, id);
}
-
+ else
+ return GetSystemMetrics (id);
+#else
return -1;
+#endif
}
gboolean
@@ -465,3 +414,9 @@ _gtk_win32_theme_color_resolve (const char *theme_class,
return TRUE;
}
+void
+gtk_win32_theme_print (GtkWin32Theme *theme,
+ GString *string)
+{
+ g_string_append (string, theme->class_name);
+}