gint default_priority;
GtkStyle *default_style;
+
+ gchar *colors;
+ GHashTable *color_hash;
+};
+
+#define GTK_RC_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_RC_STYLE, GtkRcStylePrivate))
+
+typedef struct _GtkRcStylePrivate GtkRcStylePrivate;
+
+struct _GtkRcStylePrivate
+{
+ GSList *color_hashes;
};
static GtkRcContext *gtk_rc_context_get (GtkSettings *settings);
GScanner *scanner,
GtkRcStyle *rc_style,
GtkIconFactory *factory);
+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,
gpointer user_data);
{ "stock", GTK_RC_TOKEN_STOCK },
{ "im_module_file", GTK_RC_TOKEN_IM_MODULE_FILE },
{ "LTR", GTK_RC_TOKEN_LTR },
- { "RTL", GTK_RC_TOKEN_RTL }
+ { "RTL", GTK_RC_TOKEN_RTL },
+ { "color", GTK_RC_TOKEN_COLOR }
};
static GHashTable *realized_style_ht = NULL;
_gtk_rc_context_get_default_font_name (settings);
}
+static void
+gtk_rc_color_scheme_changed (GtkSettings *settings,
+ GParamSpec *pspec,
+ GtkRcContext *context)
+{
+ gchar *colors;
+
+ g_object_get (settings,
+ "gtk-color-scheme", &colors,
+ NULL);
+
+ if (!colors && !context->colors)
+ return;
+
+ if (!colors || !context->colors ||
+ strcmp (colors, context->colors) != 0)
+ {
+ g_free (context->colors);
+ context->colors = g_strdup (colors);
+
+ if (context->color_hash)
+ g_hash_table_unref (context->color_hash);
+
+ context->color_hash = g_object_get_data (G_OBJECT (settings),
+ "gtk-color-scheme");
+ if (context->color_hash)
+ g_hash_table_ref (context->color_hash);
+
+ gtk_rc_reparse_all_for_settings (settings, TRUE);
+ }
+
+ g_free (colors);
+}
+
static GtkRcContext *
gtk_rc_context_get (GtkSettings *settings)
{
"gtk-theme-name", &context->theme_name,
"gtk-key-theme-name", &context->key_theme_name,
"gtk-font-name", &context->font_name,
+ "gtk-color-scheme", &context->colors,
NULL);
+ context->color_hash = g_object_get_data (G_OBJECT (settings),
+ "gtk-color-scheme");
+ 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),
"notify::gtk-font-name",
G_CALLBACK (gtk_rc_font_name_changed),
context);
+ g_signal_connect (settings,
+ "notify::gtk-color-scheme",
+ G_CALLBACK (gtk_rc_color_scheme_changed),
+ context);
-
context->pixmap_path[0] = NULL;
context->default_priority = GTK_PATH_PRIO_RC;
static void
gtk_rc_style_init (GtkRcStyle *style)
{
+ GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (style);
guint i;
style->name = NULL;
style->rc_style_lists = NULL;
style->icon_factories = NULL;
+
+ priv->color_hashes = NULL;
}
static void
klass->create_rc_style = gtk_rc_style_real_create_rc_style;
klass->merge = gtk_rc_style_real_merge;
klass->create_style = gtk_rc_style_real_create_style;
+
+ g_type_class_add_private (object_class, sizeof (GtkRcStylePrivate));
}
static void
{
GSList *tmp_list1, *tmp_list2;
GtkRcStyle *rc_style;
+ GtkRcStylePrivate *rc_priv;
gint i;
rc_style = GTK_RC_STYLE (object);
-
+ rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
+
if (rc_style->name)
g_free (rc_style->name);
if (rc_style->font_desc)
rc_style->rc_properties = NULL;
}
- tmp_list1 = rc_style->icon_factories;
- while (tmp_list1)
- {
- g_object_unref (tmp_list1->data);
- tmp_list1 = tmp_list1->next;
- }
+ g_slist_foreach (rc_style->icon_factories, (GFunc) g_object_unref, NULL);
g_slist_free (rc_style->icon_factories);
-
+
+ g_slist_foreach (rc_priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
+ g_slist_free (rc_priv->color_hashes);
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
return g_object_new (G_OBJECT_TYPE (style), NULL);
}
+GSList *
+_gtk_rc_style_get_color_hashes (GtkRcStyle *rc_style)
+{
+ GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
+
+ return priv->color_hashes;
+}
+
static gint
gtk_rc_properties_cmp (gconstpointer bsearch_node1,
gconstpointer bsearch_node2)
{
GtkRcStyle *base_style = NULL;
GtkRcStyle *proto_style;
+ GtkRcStylePrivate *proto_priv;
GtkRcStyleClass *proto_style_class;
GSList *tmp_styles;
GType rc_style_type = GTK_TYPE_RC_STYLE;
proto_style_class = GTK_RC_STYLE_GET_CLASS (base_style);
proto_style = proto_style_class->create_rc_style (base_style);
-
+ proto_priv = GTK_RC_STYLE_GET_PRIVATE (proto_style);
+
tmp_styles = rc_styles;
while (tmp_styles)
{
GtkRcStyle *rc_style = tmp_styles->data;
- GSList *factories;
+ GtkRcStylePrivate *rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
+ GSList *concat_list;
proto_style_class->merge (proto_style, rc_style);
if (!g_slist_find (rc_style->rc_style_lists, rc_styles))
rc_style->rc_style_lists = g_slist_prepend (rc_style->rc_style_lists, rc_styles);
- factories = g_slist_copy (rc_style->icon_factories);
- if (factories)
- {
- GSList *iter;
-
- iter = factories;
- while (iter != NULL)
- {
- g_object_ref (iter->data);
- iter = g_slist_next (iter);
- }
+ concat_list = g_slist_copy (rc_style->icon_factories);
+ g_slist_foreach (concat_list, (GFunc) g_object_ref, NULL);
+ proto_style->icon_factories = g_slist_concat (proto_style->icon_factories,
+ concat_list);
- proto_style->icon_factories = g_slist_concat (proto_style->icon_factories,
- factories);
+ concat_list = g_slist_copy (rc_priv->color_hashes);
+ g_slist_foreach (concat_list, (GFunc) g_hash_table_ref, NULL);
+ proto_priv->color_hashes = g_slist_concat (proto_priv->color_hashes,
+ concat_list);
- }
-
tmp_styles = tmp_styles->next;
}
GtkRcStyle *rc_style;
GtkRcStyle *orig_style;
GtkRcStyle *parent_style;
+ GtkRcStylePrivate *rc_priv = NULL;
guint token;
gint i;
GtkIconFactory *our_factory = NULL;
-
+ GHashTable *our_hash = NULL;
+
token = g_scanner_get_next_token (scanner);
if (token != GTK_RC_TOKEN_STYLE)
return GTK_RC_TOKEN_STYLE;
else
orig_style = NULL;
- /* If there's a list, its first member is always the factory belonging
- * to this RcStyle
- */
- if (rc_style && rc_style->icon_factories)
- our_factory = rc_style->icon_factories->data;
-
if (!rc_style)
{
rc_style = gtk_rc_style_new ();
rc_style->color_flags[i] = 0;
}
+ rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
+
+ /* If there's a list, its first member is always the factory belonging
+ * to this RcStyle
+ */
+ if (rc_style->icon_factories)
+ our_factory = rc_style->icon_factories->data;
+ if (rc_priv->color_hashes)
+ our_hash = rc_priv->color_hashes->data;
+
token = g_scanner_peek_next_token (scanner);
if (token == G_TOKEN_EQUAL_SIGN)
{
parent_style = gtk_rc_style_find (context, scanner->value.v_string);
if (parent_style)
{
- GSList *factories;
-
+ GtkRcStylePrivate *parent_priv = GTK_RC_STYLE_GET_PRIVATE (parent_style);
+ GSList *concat_list;
+
for (i = 0; i < 5; i++)
{
rc_style->color_flags[i] = parent_style->color_flags[i];
rc_style->icon_factories = g_slist_prepend (rc_style->icon_factories,
our_factory);
}
-
+
+ concat_list = g_slist_copy (parent_style->icon_factories);
+ g_slist_foreach (concat_list, (GFunc) g_object_ref, NULL);
rc_style->icon_factories = g_slist_concat (rc_style->icon_factories,
- g_slist_copy (parent_style->icon_factories));
-
- factories = parent_style->icon_factories;
- while (factories != NULL)
+ concat_list);
+ }
+
+ /* Also append parent's color hashes, adding a ref to them */
+ if (parent_priv->color_hashes != NULL)
+ {
+ /* See comment above .. */
+ if (our_hash == NULL)
{
- g_object_ref (factories->data);
- factories = factories->next;
+ our_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free,
+ (GDestroyNotify) gdk_color_free);
+ rc_priv->color_hashes = g_slist_prepend (rc_priv->color_hashes,
+ our_hash);
}
+
+ concat_list = g_slist_copy (parent_priv->color_hashes);
+ g_slist_foreach (concat_list, (GFunc) g_hash_table_ref, NULL);
+ rc_priv->color_hashes = g_slist_concat (rc_priv->color_hashes,
+ concat_list);
}
}
}
-
+
+ /* if we didn't get color hashes from our parent style, initialize
+ * the list with the settings' color scheme (if it exists)
+ */
+ if (our_hash == NULL && context->color_hash != NULL)
+ {
+ our_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free,
+ (GDestroyNotify) gdk_color_free);
+ rc_priv->color_hashes = g_slist_prepend (rc_priv->color_hashes,
+ our_hash);
+ rc_priv->color_hashes = g_slist_append (rc_priv->color_hashes,
+ g_hash_table_ref (context->color_hash));
+ }
+
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_LEFT_CURLY)
{
}
token = gtk_rc_parse_stock (context, scanner, rc_style, our_factory);
break;
+ case GTK_RC_TOKEN_COLOR:
+ if (our_hash == NULL)
+ {
+ our_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free,
+ (GDestroyNotify) gdk_color_free);
+ rc_priv->color_hashes = g_slist_prepend (rc_priv->color_hashes,
+ our_hash);
+ }
+ 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' &&
{
GtkRcProperty prop = { 0, 0, NULL, { 0, }, };
gchar *name;
-
+
g_scanner_get_next_token (scanner); /* eat type name */
prop.type_name = g_quark_from_string (scanner->value.v_identifier);
if (g_scanner_get_next_token (scanner) != ':' ||
return G_TOKEN_EQUAL_SIGN;
style->color_flags[state] |= GTK_RC_BG;
- return gtk_rc_parse_color (scanner, &style->bg[state]);
+ return gtk_rc_parse_color_full (scanner, style, &style->bg[state]);
}
static guint
return G_TOKEN_EQUAL_SIGN;
style->color_flags[state] |= GTK_RC_FG;
- return gtk_rc_parse_color (scanner, &style->fg[state]);
+ return gtk_rc_parse_color_full (scanner, style, &style->fg[state]);
}
static guint
return G_TOKEN_EQUAL_SIGN;
style->color_flags[state] |= GTK_RC_TEXT;
- return gtk_rc_parse_color (scanner, &style->text[state]);
+ return gtk_rc_parse_color_full (scanner, style, &style->text[state]);
}
static guint
return G_TOKEN_EQUAL_SIGN;
style->color_flags[state] |= GTK_RC_BASE;
- return gtk_rc_parse_color (scanner, &style->base[state]);
+ return gtk_rc_parse_color_full (scanner, style, &style->base[state]);
}
static guint
return G_TOKEN_NONE;
}
+static gboolean
+lookup_color (GtkRcStyle *style,
+ const char *color_name,
+ GdkColor *color)
+{
+ GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (style);
+ GSList *iter;
+
+ for (iter = priv->color_hashes; iter != NULL; iter = iter->next)
+ {
+ GHashTable *hash = iter->data;
+ GdkColor *match = g_hash_table_lookup (hash, color_name);
+
+ if (match)
+ {
+ color->red = match->red;
+ color->green = match->green;
+ color->blue = match->blue;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
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 (GScanner *scanner,
+ GtkRcStyle *style,
+ GdkColor *color)
{
guint token;
switch (token)
{
gint token_int;
-
+ GdkColor c1, c2;
+ gboolean negate;
+ gdouble l;
+
case G_TOKEN_LEFT_CURLY:
token = g_scanner_get_next_token (scanner);
if (token == G_TOKEN_INT)
case G_TOKEN_STRING:
if (!gdk_color_parse (scanner->value.v_string, color))
{
- g_scanner_warn (scanner, "Invalid color constant '%s'",
- scanner->value.v_string);
- return G_TOKEN_STRING;
+ g_scanner_warn (scanner, "Invalid color constant '%s'",
+ scanner->value.v_string);
+ return G_TOKEN_STRING;
}
+ return G_TOKEN_NONE;
+
+ case '@':
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_IDENTIFIER)
+ return G_TOKEN_IDENTIFIER;
+
+ if (!style || !lookup_color (style, scanner->value.v_identifier, color))
+ {
+ g_scanner_warn (scanner, "Invalid symbolic color '%s'",
+ scanner->value.v_identifier);
+ return G_TOKEN_IDENTIFIER;
+ }
+
+ return G_TOKEN_NONE;
+
+ case G_TOKEN_IDENTIFIER:
+ if (strcmp (scanner->value.v_identifier, "mix") == 0)
+ {
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_LEFT_PAREN)
+ return G_TOKEN_LEFT_PAREN;
+
+ negate = FALSE;
+ if (g_scanner_peek_next_token (scanner) == '-')
+ {
+ g_scanner_get_next_token (scanner); /* eat sign */
+ negate = TRUE;
+ }
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_FLOAT)
+ return G_TOKEN_FLOAT;
+
+ l = negate ? -scanner->value.v_float : scanner->value.v_float;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_COMMA)
+ return G_TOKEN_COMMA;
+
+ token = gtk_rc_parse_color_full (scanner, style, &c1);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_COMMA)
+ return G_TOKEN_COMMA;
+
+ token = gtk_rc_parse_color_full (scanner, style, &c2);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_RIGHT_PAREN)
+ return G_TOKEN_RIGHT_PAREN;
+
+ color->red = l * c1.red + (1.0 - l) * c2.red;
+ color->green = l * c1.green + (1.0 - l) * c2.green;
+ color->blue = l * c1.blue + (1.0 - l) * c2.blue;
+
+ return G_TOKEN_NONE;
+ }
+ else if (strcmp (scanner->value.v_identifier, "shade") == 0)
+ {
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_LEFT_PAREN)
+ return G_TOKEN_LEFT_PAREN;
+
+ negate = FALSE;
+ if (g_scanner_peek_next_token (scanner) == '-')
+ {
+ g_scanner_get_next_token (scanner); /* eat sign */
+ negate = TRUE;
+ }
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_FLOAT)
+ return G_TOKEN_FLOAT;
+
+ l = negate ? -scanner->value.v_float : scanner->value.v_float;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_COMMA)
+ return G_TOKEN_COMMA;
+
+ token = gtk_rc_parse_color_full (scanner, style, &c1);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_RIGHT_PAREN)
+ return G_TOKEN_RIGHT_PAREN;
+
+ _gtk_style_shade (&c1, color, l);
+
+ return G_TOKEN_NONE;
+ }
+ else if (strcmp (scanner->value.v_identifier, "lighter") == 0 ||
+ strcmp (scanner->value.v_identifier, "darker") == 0)
+ {
+ if (scanner->value.v_identifier[0] == 'l')
+ l = 1.3;
+ else
+ l = 0.7;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_LEFT_PAREN)
+ return G_TOKEN_LEFT_PAREN;
+
+ token = gtk_rc_parse_color_full (scanner, style, &c1);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_RIGHT_PAREN)
+ return G_TOKEN_RIGHT_PAREN;
+
+ _gtk_style_shade (&c1, color, l);
+
+ return G_TOKEN_NONE;
+ }
else
- return G_TOKEN_NONE;
-
+ return G_TOKEN_IDENTIFIER;
+
default:
return G_TOKEN_STRING;
}
}
static guint
-gtk_rc_parse_stock_id (GScanner *scanner,
- gchar **stock_id)
+gtk_rc_parse_hash_key (GScanner *scanner,
+ gchar **hash_key)
{
guint token;
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
- *stock_id = g_strdup (scanner->value.v_string);
+ *hash_key = g_strdup (scanner->value.v_string);
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_RIGHT_BRACE)
{
- g_free (*stock_id);
+ g_free (*hash_key);
return G_TOKEN_RIGHT_BRACE;
}
if (token != GTK_RC_TOKEN_STOCK)
return GTK_RC_TOKEN_STOCK;
- token = gtk_rc_parse_stock_id (scanner, &stock_id);
+ token = gtk_rc_parse_hash_key (scanner, &stock_id);
if (token != G_TOKEN_NONE)
return token;
return G_TOKEN_NONE;
}
+static guint
+gtk_rc_parse_logical_color (GScanner *scanner,
+ GtkRcStyle *rc_style,
+ GHashTable *hash)
+{
+ gchar *color_id = NULL;
+ guint token;
+ GdkColor color;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != GTK_RC_TOKEN_COLOR)
+ return GTK_RC_TOKEN_COLOR;
+
+ token = gtk_rc_parse_hash_key (scanner, &color_id);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN)
+ {
+ g_free (color_id);
+ return G_TOKEN_EQUAL_SIGN;
+ }
+
+ token = gtk_rc_parse_color_full (scanner, rc_style, &color);
+ if (token != G_TOKEN_NONE)
+ {
+ g_free (color_id);
+ return token;
+ }
+
+ /* Because the hash is created with destroy functions,
+ * g_hash_table_insert will free any old values for us,
+ * if a mapping with the specified key already exists.
+ */
+ g_hash_table_insert (hash, color_id, gdk_color_copy (&color));
+
+ return G_TOKEN_NONE;
+}
+
#ifdef G_OS_WIN32
/* DLL ABI stability backward compatibility versions */
GValue value;
} PropertyValue;
+#define GTK_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_STYLE, GtkStylePrivate))
+
+typedef struct _GtkStylePrivate GtkStylePrivate;
+
+struct _GtkStylePrivate {
+ GSList *color_hashes;
+};
+
/* --- prototypes --- */
static void gtk_style_init (GtkStyle *style);
static void gtk_style_class_init (GtkStyleClass *klass);
gint width,
gint height);
-static void gtk_style_shade (GdkColor *a,
- GdkColor *b,
- gdouble k);
static void rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *b);
klass->draw_layout = gtk_default_draw_layout;
klass->draw_resize_grip = gtk_default_draw_resize_grip;
-
+ g_type_class_add_private (object_class, sizeof (GtkStylePrivate));
+
/**
* GtkStyle::realize:
* @style: the object which received the signal
gtk_style_finalize (GObject *object)
{
GtkStyle *style = GTK_STYLE (object);
+ GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
g_return_if_fail (style->attach_count == 0);
}
}
- if (style->icon_factories)
- {
- GSList *tmp_list = style->icon_factories;
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
+ g_slist_free (style->icon_factories);
- while (tmp_list)
- {
- g_object_unref (tmp_list->data);
- tmp_list = tmp_list->next;
- }
-
- g_slist_free (style->icon_factories);
- }
+ g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
+ g_slist_free (priv->color_hashes);
pango_font_description_free (style->font_desc);
return gtk_icon_factory_lookup_default (stock_id);
}
+/**
+ * gtk_style_lookup_color:
+ * @style: a #GtkStyle
+ * @color_name: the name of the logical color to look up
+ * @color: the #GdkColor to fill in
+ *
+ * Looks up @color_name in the style's logical color mappings,
+ * filling in @color and returning %TRUE if found, otherwise
+ * returning %FALSE. Do not cache the found mapping, because
+ * it depends on the #GtkStyle and might change when a theme
+ * switch occurs.
+ *
+ * Return value: %TRUE if the mapping was found.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gtk_style_lookup_color (GtkStyle *style,
+ const char *color_name,
+ GdkColor *color)
+{
+ GtkStylePrivate *priv;
+ GSList *iter;
+
+ g_return_val_if_fail (GTK_IS_STYLE (style), FALSE);
+ g_return_val_if_fail (color_name != NULL, FALSE);
+ g_return_val_if_fail (color != NULL, FALSE);
+
+ priv = GTK_STYLE_GET_PRIVATE (style);
+
+ for (iter = priv->color_hashes; iter != NULL; iter = iter->next)
+ {
+ GHashTable *hash = iter->data;
+ GdkColor *mapping = g_hash_table_lookup (hash, color_name);
+
+ if (mapping)
+ {
+ color->red = mapping->red;
+ color->green = mapping->green;
+ color->blue = mapping->blue;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
/**
* gtk_draw_hline:
* @style: a #GtkStyle
gtk_style_real_init_from_rc (GtkStyle *style,
GtkRcStyle *rc_style)
{
+ GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
gint i;
/* cache _should_ be still empty */
if (rc_style->ythickness >= 0)
style->ythickness = rc_style->ythickness;
- if (rc_style->icon_factories)
- {
- GSList *iter;
+ style->icon_factories = g_slist_copy (rc_style->icon_factories);
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
- style->icon_factories = g_slist_copy (rc_style->icon_factories);
-
- iter = style->icon_factories;
- while (iter != NULL)
- {
- g_object_ref (iter->data);
- iter = g_slist_next (iter);
- }
- }
+ priv->color_hashes = g_slist_copy (_gtk_rc_style_get_color_hashes (rc_style));
+ g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_ref, NULL);
}
static gint
for (i = 0; i < 5; i++)
{
- gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
- gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
-
+ _gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
+ _gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
+
style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
while (darken_count)
{
- gtk_style_shade (&src, &shaded, 0.93);
+ _gtk_style_shade (&src, &shaded, 0.93);
src = shaded;
--darken_count;
}
if (state_type == GTK_STATE_SELECTED && widget && !GTK_WIDGET_HAS_FOCUS (widget))
{
GdkColor unfocused_light;
-
- gtk_style_shade (&style->base[GTK_STATE_ACTIVE], &unfocused_light,
- LIGHTNESS_MULT);
+
+ _gtk_style_shade (&style->base[GTK_STATE_ACTIVE], &unfocused_light,
+ LIGHTNESS_MULT);
light_gc = free_me = gdk_gc_new (window);
gdk_gc_set_rgb_fg_color (light_gc, &unfocused_light);
}
}
-static void
-gtk_style_shade (GdkColor *a,
- GdkColor *b,
- gdouble k)
+void
+_gtk_style_shade (GdkColor *a,
+ GdkColor *b,
+ gdouble k)
{
gdouble red;
gdouble green;