static guint gtk_rc_parse_logical_color (GScanner *scanner,
GtkRcStyle *rc_style,
GHashTable *hash);
-static guint gtk_rc_parse_color_full (GScanner *scanner,
- GtkRcStyle *style,
- GdkColor *color);
static void gtk_rc_clear_hash_node (gpointer key,
gpointer data,
gconstpointer bsearch_node2);
static void gtk_rc_set_free (GtkRcSet *rc_set);
+static void insert_rc_property (GtkRcStyle *style,
+ GtkRcProperty *property,
+ gboolean replace);
+
static const GScannerConfig gtk_rc_scanner_config =
{
"im_module_file\0"
"LTR\0"
"RTL\0"
- "color\0";
+ "color\0"
+ "unbind\0";
static const struct
{
{ 245, GTK_RC_TOKEN_IM_MODULE_FILE },
{ 260, GTK_RC_TOKEN_LTR },
{ 264, GTK_RC_TOKEN_RTL },
- { 268, GTK_RC_TOKEN_COLOR }
+ { 268, GTK_RC_TOKEN_COLOR },
+ { 274, GTK_RC_TOKEN_UNBIND }
};
static GHashTable *realized_style_ht = NULL;
g_object_get (settings, "color-hash", &context->color_hash, NULL);
- if (context->color_hash)
- g_hash_table_ref (context->color_hash);
-
- if (!context->reloading)
- gtk_rc_reparse_all_for_settings (settings, TRUE);
+ gtk_rc_reparse_all_for_settings (settings, TRUE);
}
static GtkRcContext *
context->rc_sets_class = NULL;
context->rc_files = NULL;
context->default_style = NULL;
+ context->reloading = FALSE;
g_object_get (settings,
"gtk-theme-name", &context->theme_name,
"color-hash", &context->color_hash,
NULL);
- if (context->color_hash)
- g_hash_table_ref (context->color_hash);
-
g_signal_connect (settings,
"notify::gtk-theme-name",
G_CALLBACK (gtk_rc_settings_changed),
" text[PRELIGHT] = \"#ffffff\"\n"
"}\n"
"\n"
+ /* Make transparent tray icons work */
"style \"gtk-default-tray-icon-style\" {\n"
" bg_pixmap[NORMAL] = \"<parent>\"\n"
"}\n"
"\n"
+ /* Work around clipping of accelerator underlines */
+ "style \"gtk-default-label-style\" {\n"
+ " GtkWidget::draw-border = {0,0,0,1}\n"
+ "}\n"
+ "\n"
"class \"GtkProgressBar\" style : gtk \"gtk-default-progress-bar-style\"\n"
"class \"GtkTrayIcon\" style : gtk \"gtk-default-tray-icon-style\"\n"
- "widget \"gtk-tooltips*\" style : gtk \"gtk-default-tooltips-style\"\n"
+ "widget \"gtk-tooltip*\" style : gtk \"gtk-default-tooltips-style\"\n"
"widget_class \"*<GtkMenuItem>*\" style : gtk \"gtk-default-menu-item-style\"\n"
"widget_class \"*<GtkMenuBar>*<GtkMenuItem>\" style : gtk \"gtk-default-menu-bar-item-style\"\n"
+ "class \"GtkLabel\" style : gtk \"gtk-default-label-style\"\n"
);
}
rc_style = GTK_RC_STYLE (object);
rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
- if (rc_style->name)
- g_free (rc_style->name);
+ g_free (rc_style->name);
if (rc_style->font_desc)
pango_font_description_free (rc_style->font_desc);
for (i = 0; i < 5; i++)
- if (rc_style->bg_pixmap_name[i])
- g_free (rc_style->bg_pixmap_name[i]);
+ g_free (rc_style->bg_pixmap_name[i]);
/* Now remove all references to this rc_style from
* realized_style_ht
return style;
}
+void
+_gtk_rc_style_set_rc_property (GtkRcStyle *rc_style,
+ GtkRcProperty *property)
+{
+ g_return_if_fail (GTK_IS_RC_STYLE (rc_style));
+ g_return_if_fail (property != NULL);
+
+ insert_rc_property (rc_style, property, TRUE);
+}
+
+void
+_gtk_rc_style_unset_rc_property (GtkRcStyle *rc_style,
+ GQuark type_name,
+ GQuark property_name)
+{
+ GtkRcProperty *node;
+
+ g_return_if_fail (GTK_IS_RC_STYLE (rc_style));
+
+ node = _gtk_rc_style_lookup_rc_property (rc_style, type_name, property_name);
+
+ if (node != NULL)
+ {
+ guint index = node - (GtkRcProperty *) rc_style->rc_properties->data;
+ g_value_unset (&node->value);
+ g_free (node->origin);
+ g_array_remove_index (rc_style->rc_properties, index);
+ }
+}
+
void
gtk_rc_style_ref (GtkRcStyle *rc_style)
{
{
gtk_rc_style_prepend_empty_color_hash (rc_style);
- priv->color_hashes =
- g_slist_append (priv->color_hashes,
- g_hash_table_ref (context->color_hash));
+ priv->color_hashes = g_slist_append (priv->color_hashes,
+ g_hash_table_ref (context->color_hash));
}
}
context = gtk_rc_context_get (settings);
+ if (context->reloading)
+ return FALSE;
+
if (!force_load)
{
/* Check through and see if any of the RC's have had their
return gtk_rc_parse_style (context, scanner);
case GTK_RC_TOKEN_BINDING:
- return gtk_binding_parse_binding (scanner);
+ return _gtk_binding_parse_binding (scanner);
case GTK_RC_TOKEN_PIXMAP_PATH:
return gtk_rc_parse_pixmap_path (context, scanner);
for (i = 0; i < 5; i++)
{
- if (rc_style->bg_pixmap_name[i])
- g_free (rc_style->bg_pixmap_name[i]);
+ g_free (rc_style->bg_pixmap_name[i]);
rc_style->bg_pixmap_name[i] = g_strdup (parent_style->bg_pixmap_name[i]);
}
}
token = gtk_rc_parse_logical_color (scanner, rc_style, our_hash);
break;
case G_TOKEN_IDENTIFIER:
- if (is_c_identifier (scanner->next_value.v_identifier) &&
- scanner->next_value.v_identifier[0] >= 'A' &&
- scanner->next_value.v_identifier[0] <= 'Z') /* match namespaced type names */
+ if (is_c_identifier (scanner->next_value.v_identifier))
{
GtkRcProperty prop = { 0, 0, NULL, { 0, }, };
gchar *name;
if (pixmap_file)
{
- if (rc_style->bg_pixmap_name[state])
- g_free (rc_style->bg_pixmap_name[state]);
+ g_free (rc_style->bg_pixmap_name[state]);
rc_style->bg_pixmap_name[state] = pixmap_file;
}
guint result = G_TOKEN_NONE;
GtkRcStyle *new_style = NULL;
gboolean parsed_curlies = FALSE;
+ GtkRcStylePrivate *rc_priv, *new_priv;
token = g_scanner_get_next_token (scanner);
if (token != GTK_RC_TOKEN_ENGINE)
parsed_curlies = TRUE;
+ rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style);
+
if (G_OBJECT_TYPE (*rc_style) != GTK_TYPE_RC_STYLE)
{
new_style = gtk_rc_style_new ();
gtk_rc_style_real_merge (new_style, *rc_style);
-
- if ((*rc_style)->name)
- new_style->name = g_strdup ((*rc_style)->name);
+
+ new_style->name = g_strdup ((*rc_style)->name);
+
+ /* take over icon factories and color hashes
+ * from the to-be-deleted style
+ */
+ new_style->icon_factories = (*rc_style)->icon_factories;
+ (*rc_style)->icon_factories = NULL;
+ new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style);
+ new_priv->color_hashes = rc_priv->color_hashes;
+ rc_priv->color_hashes = NULL;
}
else
(*rc_style)->engine_specified = TRUE;
{
GtkRcStyleClass *new_class;
+ rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style);
new_style = gtk_theme_engine_create_rc_style (engine);
g_type_module_unuse (G_TYPE_MODULE (engine));
new_class = GTK_RC_STYLE_GET_CLASS (new_style);
-
+
new_class->merge (new_style, *rc_style);
- if ((*rc_style)->name)
- new_style->name = g_strdup ((*rc_style)->name);
+
+ new_style->name = g_strdup ((*rc_style)->name);
+
+ /* take over icon factories and color hashes
+ * from the to-be-deleted style
+ */
+ new_style->icon_factories = (*rc_style)->icon_factories;
+ (*rc_style)->icon_factories = NULL;
+ new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style);
+ new_priv->color_hashes = rc_priv->color_hashes;
+ rc_priv->color_hashes = NULL;
if (new_class->parse)
{
if (result != G_TOKEN_NONE)
{
+ /* copy icon factories and color hashes back
+ */
+ (*rc_style)->icon_factories = new_style->icon_factories;
+ new_style->icon_factories = NULL;
+ rc_priv->color_hashes = new_priv->color_hashes;
+ new_priv->color_hashes = NULL;
+
g_object_unref (new_style);
new_style = NULL;
}
if (new_style)
{
- GtkRcStylePrivate *rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style);
- GtkRcStylePrivate *new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style);
-
- /* take over icon factories and color hashes from the to-be-deleted style
- */
-
- new_style->icon_factories = (*rc_style)->icon_factories;
- (*rc_style)->icon_factories = NULL;
-
- new_priv->color_hashes = rc_priv->color_hashes;
- rc_priv->color_hashes = NULL;
-
new_style->engine_specified = TRUE;
g_object_unref (*rc_style);
return G_TOKEN_NONE;
}
+/**
+ * gtk_rc_parse_color:
+ * @scanner: a #GScanner
+ * @color: a pointer to a #GtkColor structure in which to store the result
+ *
+ * Parses a color in the <link linkend="color=format">format</link> expected
+ * in a RC file.
+ *
+ * Note that theme engines should use gtk_rc_parse_color_full() in
+ * order to support symbolic colors.
+ *
+ * Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
+ * that was expected but not found
+ */
guint
gtk_rc_parse_color (GScanner *scanner,
GdkColor *color)
return gtk_rc_parse_color_full (scanner, NULL, color);
}
-static guint
+/**
+ * gtk_rc_parse_color_full:
+ * @scanner: a #GScanner
+ * @style: a #GtkRcStyle, or %NULL
+ * @color: a pointer to a #GtkColor structure in which to store the result
+ *
+ * Parses a color in the <link linkend="color=format">format</link> expected
+ * in a RC file. If @style is not %NULL, it will be consulted to resolve
+ * references to symbolic colors.
+ *
+ * Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
+ * that was expected but not found
+ *
+ * Since: 2.12
+ */
+guint
gtk_rc_parse_color_full (GScanner *scanner,
GtkRcStyle *style,
GdkColor *color)
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
- if (im_module_file)
- g_free (im_module_file);
+ g_free (im_module_file);
im_module_file = g_strdup (scanner->value.v_string);
gboolean *icon_set_valid)
{
guint token;
- GtkIconSource *source;
gchar *full_filename;
-
+ GtkIconSource *source = NULL;
+
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_LEFT_CURLY)
return G_TOKEN_LEFT_CURLY;
if (token != G_TOKEN_STRING && token != '@')
return G_TOKEN_STRING;
- source = gtk_icon_source_new ();
-
if (token == G_TOKEN_STRING)
{
/* Filename */
-
+
+ source = gtk_icon_source_new ();
full_filename = gtk_rc_find_pixmap_in_path (context->settings, scanner, scanner->value.v_string);
if (full_filename)
{
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
+ source = gtk_icon_source_new ();
gtk_icon_source_set_icon_name (source, scanner->value.v_string);
}