mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
Remove dead Gtk[Rc]Style code
Most code in gtkrc.c has been turned into a no-op, but that one reverting in public API (gtk_rc_scanner_new() and such). GtStyle is also more shallow, now fully relies in the backing GtkStyleContext and all connection to gtkrc.c has been removed. GtkBinding has been also affected, there is no replacement yet for custom keybindings in style files, so that piece of code that hooked into gtkrc has been replaced by a FIXME so in the future it may be added back.
This commit is contained in:
parent
d7dc12d301
commit
56c3d4b1be
@ -47,7 +47,6 @@
|
||||
typedef struct {
|
||||
GtkPathType type;
|
||||
GPatternSpec *pspec;
|
||||
GSList *path;
|
||||
gpointer user_data;
|
||||
guint seq_id;
|
||||
} PatternSpec;
|
||||
@ -65,7 +64,6 @@ static GQuark key_id_class_binding_set = 0;
|
||||
static void
|
||||
pattern_spec_free (PatternSpec *pspec)
|
||||
{
|
||||
_gtk_rc_free_widget_class_path (pspec->path);
|
||||
if (pspec->pspec)
|
||||
g_pattern_spec_free (pspec->pspec);
|
||||
g_free (pspec);
|
||||
@ -972,6 +970,8 @@ gtk_binding_entry_add_signal (GtkBindingSet *binding_set,
|
||||
*
|
||||
* This function is used internally by the GtkRC parsing mechanism to
|
||||
* assign match patterns to #GtkBindingSet structures.
|
||||
*
|
||||
* Deprecated: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_binding_set_add_path (GtkBindingSet *binding_set,
|
||||
@ -1009,16 +1009,10 @@ gtk_binding_set_add_path (GtkBindingSet *binding_set,
|
||||
pspec = g_new (PatternSpec, 1);
|
||||
pspec->type = path_type;
|
||||
if (path_type == GTK_PATH_WIDGET_CLASS)
|
||||
{
|
||||
pspec->pspec = NULL;
|
||||
pspec->path = _gtk_rc_parse_widget_class_path (path_pattern);
|
||||
}
|
||||
pspec->pspec = NULL;
|
||||
else
|
||||
{
|
||||
pspec->pspec = g_pattern_spec_new (path_pattern);
|
||||
pspec->path = NULL;
|
||||
}
|
||||
|
||||
pspec->pspec = g_pattern_spec_new (path_pattern);
|
||||
|
||||
pspec->seq_id = priority << 28;
|
||||
pspec->user_data = binding_set;
|
||||
|
||||
@ -1070,13 +1064,8 @@ binding_match_activate (GSList *pspec_list,
|
||||
|
||||
binding_set = NULL;
|
||||
pspec = slist->data;
|
||||
|
||||
if (pspec->type == GTK_PATH_WIDGET_CLASS)
|
||||
{
|
||||
if (_gtk_rc_match_widget_class (pspec->path, path_length, path, path_reversed))
|
||||
binding_set = pspec->user_data;
|
||||
}
|
||||
else
|
||||
|
||||
if (pspec->type != GTK_PATH_WIDGET_CLASS)
|
||||
{
|
||||
if (g_pattern_match (pspec->pspec, path_length, path, path_reversed))
|
||||
binding_set = pspec->user_data;
|
||||
@ -1175,47 +1164,12 @@ gtk_bindings_activate_list (GObject *object,
|
||||
GSList *entries,
|
||||
gboolean is_release)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (object);
|
||||
gboolean handled = FALSE;
|
||||
|
||||
if (!entries)
|
||||
return FALSE;
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
guint path_length;
|
||||
gchar *path, *path_reversed;
|
||||
GSList *patterns;
|
||||
gboolean unbound;
|
||||
|
||||
gtk_widget_path (widget, &path_length, &path, &path_reversed);
|
||||
patterns = gtk_binding_entries_sort_patterns (entries, GTK_PATH_WIDGET, is_release);
|
||||
handled = binding_match_activate (patterns, object, path_length, path, path_reversed, &unbound);
|
||||
g_slist_free (patterns);
|
||||
g_free (path);
|
||||
g_free (path_reversed);
|
||||
|
||||
if (unbound)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
guint path_length;
|
||||
gchar *path, *path_reversed;
|
||||
GSList *patterns;
|
||||
gboolean unbound;
|
||||
|
||||
gtk_widget_class_path (widget, &path_length, &path, &path_reversed);
|
||||
patterns = gtk_binding_entries_sort_patterns (entries, GTK_PATH_WIDGET_CLASS, is_release);
|
||||
handled = binding_match_activate (patterns, object, path_length, path, path_reversed, &unbound);
|
||||
g_slist_free (patterns);
|
||||
g_free (path);
|
||||
g_free (path_reversed);
|
||||
|
||||
if (unbound)
|
||||
return FALSE;
|
||||
}
|
||||
/* FIXME: Add back binding parsing from user config files */
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
@ -1333,348 +1287,3 @@ gtk_bindings_activate_event (GObject *object,
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_binding_parse_signal (GScanner *scanner,
|
||||
GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
gchar *signal;
|
||||
guint expected_token = 0;
|
||||
GSList *args;
|
||||
GSList *slist;
|
||||
gboolean done;
|
||||
gboolean negate;
|
||||
gboolean need_arg;
|
||||
gboolean seen_comma;
|
||||
guint token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
if (scanner->token != G_TOKEN_STRING)
|
||||
return G_TOKEN_STRING;
|
||||
g_scanner_peek_next_token (scanner);
|
||||
if (scanner->next_token != '(')
|
||||
{
|
||||
g_scanner_get_next_token (scanner);
|
||||
return '(';
|
||||
}
|
||||
signal = g_strdup (scanner->value.v_string);
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
negate = FALSE;
|
||||
args = NULL;
|
||||
done = FALSE;
|
||||
need_arg = TRUE;
|
||||
seen_comma = FALSE;
|
||||
scanner->config->scan_symbols = FALSE;
|
||||
do
|
||||
{
|
||||
if (need_arg)
|
||||
expected_token = G_TOKEN_INT;
|
||||
else
|
||||
expected_token = ')';
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
switch (token)
|
||||
{
|
||||
GtkBindingArg *arg;
|
||||
|
||||
case G_TOKEN_FLOAT:
|
||||
if (need_arg)
|
||||
{
|
||||
need_arg = FALSE;
|
||||
arg = g_new (GtkBindingArg, 1);
|
||||
arg->arg_type = G_TYPE_DOUBLE;
|
||||
arg->d.double_data = scanner->value.v_float;
|
||||
if (negate)
|
||||
{
|
||||
arg->d.double_data = - arg->d.double_data;
|
||||
negate = FALSE;
|
||||
}
|
||||
args = g_slist_prepend (args, arg);
|
||||
}
|
||||
else
|
||||
done = TRUE;
|
||||
break;
|
||||
case G_TOKEN_INT:
|
||||
if (need_arg)
|
||||
{
|
||||
need_arg = FALSE;
|
||||
arg = g_new (GtkBindingArg, 1);
|
||||
arg->arg_type = G_TYPE_LONG;
|
||||
arg->d.long_data = scanner->value.v_int;
|
||||
if (negate)
|
||||
{
|
||||
arg->d.long_data = - arg->d.long_data;
|
||||
negate = FALSE;
|
||||
}
|
||||
args = g_slist_prepend (args, arg);
|
||||
}
|
||||
else
|
||||
done = TRUE;
|
||||
break;
|
||||
case G_TOKEN_STRING:
|
||||
if (need_arg && !negate)
|
||||
{
|
||||
need_arg = FALSE;
|
||||
arg = g_new (GtkBindingArg, 1);
|
||||
arg->arg_type = G_TYPE_STRING;
|
||||
arg->d.string_data = g_strdup (scanner->value.v_string);
|
||||
args = g_slist_prepend (args, arg);
|
||||
}
|
||||
else
|
||||
done = TRUE;
|
||||
break;
|
||||
case G_TOKEN_IDENTIFIER:
|
||||
if (need_arg && !negate)
|
||||
{
|
||||
need_arg = FALSE;
|
||||
arg = g_new (GtkBindingArg, 1);
|
||||
arg->arg_type = GTK_TYPE_IDENTIFIER;
|
||||
arg->d.string_data = g_strdup (scanner->value.v_identifier);
|
||||
args = g_slist_prepend (args, arg);
|
||||
}
|
||||
else
|
||||
done = TRUE;
|
||||
break;
|
||||
case '-':
|
||||
if (!need_arg)
|
||||
done = TRUE;
|
||||
else if (negate)
|
||||
{
|
||||
expected_token = G_TOKEN_INT;
|
||||
done = TRUE;
|
||||
}
|
||||
else
|
||||
negate = TRUE;
|
||||
break;
|
||||
case ',':
|
||||
seen_comma = TRUE;
|
||||
if (need_arg)
|
||||
done = TRUE;
|
||||
else
|
||||
need_arg = TRUE;
|
||||
break;
|
||||
case ')':
|
||||
if (!(need_arg && seen_comma) && !negate)
|
||||
{
|
||||
args = g_slist_reverse (args);
|
||||
_gtk_binding_entry_add_signall (binding_set,
|
||||
keyval,
|
||||
modifiers,
|
||||
signal,
|
||||
args);
|
||||
expected_token = G_TOKEN_NONE;
|
||||
}
|
||||
done = TRUE;
|
||||
break;
|
||||
default:
|
||||
done = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (!done);
|
||||
scanner->config->scan_symbols = TRUE;
|
||||
|
||||
for (slist = args; slist; slist = slist->next)
|
||||
{
|
||||
GtkBindingArg *arg;
|
||||
|
||||
arg = slist->data;
|
||||
if (G_TYPE_FUNDAMENTAL (arg->arg_type) == G_TYPE_STRING)
|
||||
g_free (arg->d.string_data);
|
||||
g_free (arg);
|
||||
}
|
||||
g_slist_free (args);
|
||||
g_free (signal);
|
||||
|
||||
return expected_token;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
gtk_binding_parse_bind (GScanner *scanner,
|
||||
GtkBindingSet *binding_set)
|
||||
{
|
||||
guint keyval = 0;
|
||||
GdkModifierType modifiers = 0;
|
||||
gboolean unbind = FALSE;
|
||||
guint token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != GTK_RC_TOKEN_BIND &&
|
||||
token != GTK_RC_TOKEN_UNBIND)
|
||||
return GTK_RC_TOKEN_BIND;
|
||||
unbind = token == GTK_RC_TOKEN_UNBIND;
|
||||
g_scanner_get_next_token (scanner);
|
||||
if (scanner->token != G_TOKEN_STRING)
|
||||
return G_TOKEN_STRING;
|
||||
gtk_accelerator_parse (scanner->value.v_string, &keyval, &modifiers);
|
||||
modifiers &= BINDING_MOD_MASK ();
|
||||
if (keyval == 0)
|
||||
return G_TOKEN_STRING;
|
||||
|
||||
if (unbind)
|
||||
{
|
||||
gtk_binding_entry_skip (binding_set, keyval, modifiers);
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
if (scanner->token != '{')
|
||||
return '{';
|
||||
|
||||
gtk_binding_entry_clear_internal (binding_set, keyval, modifiers);
|
||||
|
||||
g_scanner_peek_next_token (scanner);
|
||||
while (scanner->next_token != '}')
|
||||
{
|
||||
switch (scanner->next_token)
|
||||
{
|
||||
guint expected_token;
|
||||
|
||||
case G_TOKEN_STRING:
|
||||
expected_token = gtk_binding_parse_signal (scanner,
|
||||
binding_set,
|
||||
keyval,
|
||||
modifiers);
|
||||
if (expected_token != G_TOKEN_NONE)
|
||||
return expected_token;
|
||||
break;
|
||||
default:
|
||||
g_scanner_get_next_token (scanner);
|
||||
return '}';
|
||||
}
|
||||
g_scanner_peek_next_token (scanner);
|
||||
}
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
|
||||
guint
|
||||
_gtk_binding_parse_binding (GScanner *scanner)
|
||||
{
|
||||
GtkBindingSet *binding_set;
|
||||
gchar *name;
|
||||
guint token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != GTK_RC_TOKEN_BINDING)
|
||||
return GTK_RC_TOKEN_BINDING;
|
||||
g_scanner_get_next_token (scanner);
|
||||
if (scanner->token != G_TOKEN_STRING)
|
||||
return G_TOKEN_STRING;
|
||||
name = g_strdup (scanner->value.v_string);
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
if (scanner->token != '{')
|
||||
{
|
||||
g_free (name);
|
||||
return G_TOKEN_STRING;
|
||||
}
|
||||
|
||||
binding_set = gtk_binding_set_find (name);
|
||||
if (!binding_set)
|
||||
{
|
||||
binding_set = gtk_binding_set_new (name);
|
||||
binding_set->parsed = 1;
|
||||
}
|
||||
g_free (name);
|
||||
|
||||
g_scanner_peek_next_token (scanner);
|
||||
while (scanner->next_token != '}')
|
||||
{
|
||||
guint next_token = scanner->next_token;
|
||||
switch (next_token)
|
||||
{
|
||||
guint expected_token;
|
||||
|
||||
case GTK_RC_TOKEN_BIND:
|
||||
case GTK_RC_TOKEN_UNBIND:
|
||||
expected_token = gtk_binding_parse_bind (scanner, binding_set);
|
||||
if (expected_token != G_TOKEN_NONE)
|
||||
return expected_token;
|
||||
break;
|
||||
default:
|
||||
g_scanner_get_next_token (scanner);
|
||||
return '}';
|
||||
}
|
||||
g_scanner_peek_next_token (scanner);
|
||||
}
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
free_pattern_specs (GSList *pattern_specs)
|
||||
{
|
||||
GSList *slist;
|
||||
|
||||
for (slist = pattern_specs; slist; slist = slist->next)
|
||||
{
|
||||
PatternSpec *pspec;
|
||||
|
||||
pspec = slist->data;
|
||||
|
||||
pattern_spec_free (pspec);
|
||||
}
|
||||
|
||||
g_slist_free (pattern_specs);
|
||||
}
|
||||
|
||||
static void
|
||||
binding_set_delete (GtkBindingSet *binding_set)
|
||||
{
|
||||
GtkBindingEntry *entry, *next;
|
||||
|
||||
entry = binding_set->entries;
|
||||
while (entry)
|
||||
{
|
||||
next = entry->set_next;
|
||||
binding_entry_destroy (entry);
|
||||
entry = next;
|
||||
}
|
||||
|
||||
free_pattern_specs (binding_set->widget_path_pspecs);
|
||||
free_pattern_specs (binding_set->widget_class_pspecs);
|
||||
free_pattern_specs (binding_set->class_branch_pspecs);
|
||||
|
||||
g_free (binding_set);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_binding_reset_parsed:
|
||||
*
|
||||
* Remove all binding sets that were added by gtk_binding_parse_binding().
|
||||
*/
|
||||
void
|
||||
_gtk_binding_reset_parsed (void)
|
||||
{
|
||||
GSList *slist, *next;
|
||||
|
||||
slist = binding_set_list;
|
||||
while (slist)
|
||||
{
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
binding_set = slist->data;
|
||||
next = slist->next;
|
||||
|
||||
if (binding_set->parsed)
|
||||
{
|
||||
binding_set_list = g_slist_delete_link (binding_set_list, slist);
|
||||
binding_set_delete (binding_set);
|
||||
}
|
||||
|
||||
slist = next;
|
||||
}
|
||||
}
|
||||
|
1796
gtk/gtkrc.c
1796
gtk/gtkrc.c
File diff suppressed because it is too large
Load Diff
18
gtk/gtkrc.h
18
gtk/gtkrc.h
@ -123,7 +123,6 @@ struct _GtkRcStyleClass
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
void _gtk_rc_init (void);
|
||||
GSList* _gtk_rc_parse_widget_class_path (const gchar *pattern);
|
||||
void _gtk_rc_free_widget_class_path (GSList *list);
|
||||
gboolean _gtk_rc_match_widget_class (GSList *list,
|
||||
@ -234,23 +233,6 @@ struct _GtkRcProperty
|
||||
gchar *origin;
|
||||
GValue value;
|
||||
};
|
||||
const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
|
||||
GQuark type_name,
|
||||
GQuark property_name);
|
||||
void _gtk_rc_style_set_rc_property (GtkRcStyle *rc_style,
|
||||
GtkRcProperty *property);
|
||||
void _gtk_rc_style_unset_rc_property (GtkRcStyle *rc_style,
|
||||
GQuark type_name,
|
||||
GQuark property_name);
|
||||
|
||||
GSList * _gtk_rc_style_get_color_hashes (GtkRcStyle *rc_style);
|
||||
|
||||
void _gtk_rc_style_set_symbolic_color (GtkRcStyle *rc_style,
|
||||
const gchar *name,
|
||||
const GdkColor *color);
|
||||
|
||||
const gchar* _gtk_rc_context_get_default_font_name (GtkSettings *settings);
|
||||
void _gtk_rc_context_destroy (GtkSettings *settings);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -1334,8 +1334,6 @@ gtk_settings_finalize (GObject *object)
|
||||
|
||||
object_list = g_slist_remove (object_list, settings);
|
||||
|
||||
_gtk_rc_context_destroy (settings);
|
||||
|
||||
for (i = 0; i < class_n_properties; i++)
|
||||
g_value_unset (&settings->property_values[i].value);
|
||||
g_free (settings->property_values);
|
||||
|
481
gtk/gtkstyle.c
481
gtk/gtkstyle.c
@ -82,7 +82,6 @@ typedef struct {
|
||||
typedef struct _GtkStylePrivate GtkStylePrivate;
|
||||
|
||||
struct _GtkStylePrivate {
|
||||
GSList *color_hashes;
|
||||
GtkStyleContext *context;
|
||||
gulong context_changed_id;
|
||||
};
|
||||
@ -104,8 +103,6 @@ static void gtk_style_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gtk_style_realize (GtkStyle *style,
|
||||
GdkVisual *visual);
|
||||
static void gtk_style_real_realize (GtkStyle *style);
|
||||
static void gtk_style_real_unrealize (GtkStyle *style);
|
||||
static void gtk_style_real_copy (GtkStyle *style,
|
||||
@ -334,8 +331,6 @@ static void hls_to_rgb (gdouble *h,
|
||||
gdouble *l,
|
||||
gdouble *s);
|
||||
|
||||
static void style_unrealize_cursors (GtkStyle *style);
|
||||
|
||||
static void transform_detail_string (const gchar *detail,
|
||||
GtkStyleContext *context);
|
||||
|
||||
@ -378,54 +373,13 @@ G_DEFINE_TYPE (GtkStyle, gtk_style, G_TYPE_OBJECT)
|
||||
|
||||
/* --- functions --- */
|
||||
|
||||
/**
|
||||
* _gtk_style_init_for_settings:
|
||||
* @style: a #GtkStyle
|
||||
* @settings: a #GtkSettings
|
||||
*
|
||||
* Initializes the font description in @style according to the default
|
||||
* font name of @settings. This is called for gtk_style_new() with
|
||||
* the settings for the default screen (if any); if we are creating
|
||||
* a style for a particular screen, we then call it again in a
|
||||
* location where we know the correct settings.
|
||||
* The reason for this is that gtk_rc_style_create_style() doesn't
|
||||
* take the screen for an argument.
|
||||
**/
|
||||
void
|
||||
_gtk_style_init_for_settings (GtkStyle *style,
|
||||
GtkSettings *settings)
|
||||
{
|
||||
const gchar *font_name = _gtk_rc_context_get_default_font_name (settings);
|
||||
|
||||
if (style->font_desc)
|
||||
pango_font_description_free (style->font_desc);
|
||||
|
||||
style->font_desc = pango_font_description_from_string (font_name);
|
||||
|
||||
if (!pango_font_description_get_family (style->font_desc))
|
||||
{
|
||||
g_warning ("Default font does not have a family set");
|
||||
pango_font_description_set_family (style->font_desc, "Sans");
|
||||
}
|
||||
if (pango_font_description_get_size (style->font_desc) <= 0)
|
||||
{
|
||||
g_warning ("Default font does not have a positive size");
|
||||
pango_font_description_set_size (style->font_desc, 10 * PANGO_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_init (GtkStyle *style)
|
||||
{
|
||||
gint i;
|
||||
|
||||
GtkSettings *settings = gtk_settings_get_default ();
|
||||
|
||||
if (settings)
|
||||
_gtk_style_init_for_settings (style, settings);
|
||||
else
|
||||
style->font_desc = pango_font_description_from_string ("Sans 10");
|
||||
|
||||
|
||||
style->font_desc = pango_font_description_from_string ("Sans 10");
|
||||
|
||||
style->attach_count = 0;
|
||||
|
||||
style->black.red = 0;
|
||||
@ -556,25 +510,6 @@ gtk_style_class_init (GtkStyleClass *klass)
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_property_cache (GtkStyle *style)
|
||||
{
|
||||
if (style->property_cache)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < style->property_cache->len; i++)
|
||||
{
|
||||
PropertyValue *node = &g_array_index (style->property_cache, PropertyValue, i);
|
||||
|
||||
g_param_spec_unref (node->pspec);
|
||||
g_value_unset (&node->value);
|
||||
}
|
||||
g_array_free (style->property_cache, TRUE);
|
||||
style->property_cache = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_finalize (GObject *object)
|
||||
{
|
||||
@ -583,8 +518,6 @@ gtk_style_finalize (GObject *object)
|
||||
|
||||
g_return_if_fail (style->attach_count == 0);
|
||||
|
||||
clear_property_cache (style);
|
||||
|
||||
/* All the styles in the list have the same
|
||||
* style->styles pointer. If we delete the
|
||||
* *first* style from the list, we need to update
|
||||
@ -612,9 +545,6 @@ gtk_style_finalize (GObject *object)
|
||||
g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
|
||||
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);
|
||||
|
||||
if (style->private_font_desc)
|
||||
@ -748,6 +678,7 @@ gtk_style_update_from_context (GtkStyle *style)
|
||||
GtkStylePrivate *priv;
|
||||
GtkStateType state;
|
||||
GtkBorder *padding;
|
||||
gint i;
|
||||
|
||||
priv = GTK_STYLE_GET_PRIVATE (style);
|
||||
|
||||
@ -792,6 +723,33 @@ gtk_style_update_from_context (GtkStyle *style)
|
||||
|
||||
gtk_border_free (padding);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
|
||||
style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
|
||||
style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
|
||||
}
|
||||
|
||||
style->black.red = 0x0000;
|
||||
style->black.green = 0x0000;
|
||||
style->black.blue = 0x0000;
|
||||
|
||||
style->white.red = 0xffff;
|
||||
style->white.green = 0xffff;
|
||||
style->white.blue = 0xffff;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
style->background[i] = cairo_pattern_create_rgb (style->bg[i].red / 65535.0,
|
||||
style->bg[i].green / 65535.0,
|
||||
style->bg[i].blue / 65535.0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -840,26 +798,6 @@ gtk_style_copy (GtkStyle *style)
|
||||
return new_style;
|
||||
}
|
||||
|
||||
static GtkStyle*
|
||||
gtk_style_duplicate (GtkStyle *style)
|
||||
{
|
||||
GtkStyle *new_style;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
|
||||
|
||||
new_style = gtk_style_copy (style);
|
||||
|
||||
/* All the styles in the list have the same
|
||||
* style->styles pointer. When we insert a new
|
||||
* style, we append it to the list to avoid having
|
||||
* to update the existing ones.
|
||||
*/
|
||||
style->styles = g_slist_append (style->styles, new_style);
|
||||
new_style->styles = style->styles;
|
||||
|
||||
return new_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_new:
|
||||
* @returns: a new #GtkStyle.
|
||||
@ -914,69 +852,10 @@ GtkStyle*
|
||||
gtk_style_attach (GtkStyle *style,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GSList *styles;
|
||||
GtkStyle *new_style = NULL;
|
||||
GdkVisual *visual;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
visual = gdk_window_get_visual (window);
|
||||
|
||||
if (!style->styles)
|
||||
style->styles = g_slist_append (NULL, style);
|
||||
|
||||
styles = style->styles;
|
||||
while (styles)
|
||||
{
|
||||
new_style = styles->data;
|
||||
|
||||
if (new_style->visual == visual)
|
||||
break;
|
||||
|
||||
new_style = NULL;
|
||||
styles = styles->next;
|
||||
}
|
||||
|
||||
if (!new_style)
|
||||
{
|
||||
styles = style->styles;
|
||||
|
||||
while (styles)
|
||||
{
|
||||
new_style = styles->data;
|
||||
|
||||
if (new_style->attach_count == 0)
|
||||
{
|
||||
gtk_style_realize (new_style, visual);
|
||||
break;
|
||||
}
|
||||
|
||||
new_style = NULL;
|
||||
styles = styles->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (!new_style)
|
||||
{
|
||||
new_style = gtk_style_duplicate (style);
|
||||
gtk_style_realize (new_style, visual);
|
||||
}
|
||||
|
||||
/* A style gets a refcount from being attached */
|
||||
if (new_style->attach_count == 0)
|
||||
g_object_ref (new_style);
|
||||
|
||||
/* Another refcount belongs to the parent */
|
||||
if (style != new_style)
|
||||
{
|
||||
g_object_unref (style);
|
||||
g_object_ref (new_style);
|
||||
}
|
||||
|
||||
new_style->attach_count++;
|
||||
|
||||
return new_style;
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -992,35 +871,6 @@ void
|
||||
gtk_style_detach (GtkStyle *style)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_STYLE (style));
|
||||
|
||||
if (style->attach_count == 0)
|
||||
return;
|
||||
|
||||
style->attach_count -= 1;
|
||||
if (style->attach_count == 0)
|
||||
{
|
||||
g_signal_emit (style, unrealize_signal, 0);
|
||||
|
||||
g_object_unref (style->visual);
|
||||
style->visual = NULL;
|
||||
|
||||
if (style->private_font_desc)
|
||||
{
|
||||
pango_font_description_free (style->private_font_desc);
|
||||
style->private_font_desc = NULL;
|
||||
}
|
||||
|
||||
g_object_unref (style);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_realize (GtkStyle *style,
|
||||
GdkVisual *visual)
|
||||
{
|
||||
style->visual = g_object_ref (visual);
|
||||
|
||||
g_signal_emit (style, realize_signal, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1141,8 +991,6 @@ static void
|
||||
gtk_style_real_copy (GtkStyle *style,
|
||||
GtkStyle *src)
|
||||
{
|
||||
GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
|
||||
GtkStylePrivate *src_priv = GTK_STYLE_GET_PRIVATE (src);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
@ -1179,64 +1027,12 @@ gtk_style_real_copy (GtkStyle *style,
|
||||
g_slist_free (style->icon_factories);
|
||||
style->icon_factories = g_slist_copy (src->icon_factories);
|
||||
g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
|
||||
|
||||
g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
|
||||
g_slist_free (priv->color_hashes);
|
||||
priv->color_hashes = g_slist_copy (src_priv->color_hashes);
|
||||
g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_ref, NULL);
|
||||
|
||||
/* don't copy, just clear cache */
|
||||
clear_property_cache (style);
|
||||
}
|
||||
|
||||
static void
|
||||
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 */
|
||||
clear_property_cache (style);
|
||||
|
||||
if (rc_style->font_desc)
|
||||
pango_font_description_merge (style->font_desc, rc_style->font_desc, TRUE);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
if (rc_style->color_flags[i] & GTK_RC_FG)
|
||||
style->fg[i] = rc_style->fg[i];
|
||||
if (rc_style->color_flags[i] & GTK_RC_BG)
|
||||
style->bg[i] = rc_style->bg[i];
|
||||
if (rc_style->color_flags[i] & GTK_RC_TEXT)
|
||||
style->text[i] = rc_style->text[i];
|
||||
if (rc_style->color_flags[i] & GTK_RC_BASE)
|
||||
style->base[i] = rc_style->base[i];
|
||||
}
|
||||
|
||||
if (rc_style->xthickness >= 0)
|
||||
style->xthickness = rc_style->xthickness;
|
||||
if (rc_style->ythickness >= 0)
|
||||
style->ythickness = rc_style->ythickness;
|
||||
|
||||
style->icon_factories = g_slist_copy (rc_style->icon_factories);
|
||||
g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
|
||||
|
||||
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
|
||||
style_property_values_cmp (gconstpointer bsearch_node1,
|
||||
gconstpointer bsearch_node2)
|
||||
{
|
||||
const PropertyValue *val1 = bsearch_node1;
|
||||
const PropertyValue *val2 = bsearch_node2;
|
||||
|
||||
if (val1->widget_type == val2->widget_type)
|
||||
return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1;
|
||||
else
|
||||
return val1->widget_type < val2->widget_type ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1258,9 +1054,9 @@ gtk_style_get_style_property (GtkStyle *style,
|
||||
const gchar *property_name,
|
||||
GValue *value)
|
||||
{
|
||||
GtkStylePrivate *priv;
|
||||
GtkWidgetClass *klass;
|
||||
GParamSpec *pspec;
|
||||
GtkRcPropertyParser parser;
|
||||
const GValue *peek_value;
|
||||
|
||||
klass = g_type_class_ref (widget_type);
|
||||
@ -1276,10 +1072,10 @@ gtk_style_get_style_property (GtkStyle *style,
|
||||
return;
|
||||
}
|
||||
|
||||
parser = g_param_spec_get_qdata (pspec,
|
||||
g_quark_from_static_string ("gtk-rc-property-parser"));
|
||||
|
||||
peek_value = _gtk_style_peek_property_value (style, widget_type, pspec, parser);
|
||||
priv = GTK_STYLE_GET_PRIVATE (style);
|
||||
peek_value = _gtk_style_context_peek_style_property (priv->context,
|
||||
widget_type,
|
||||
0, pspec);
|
||||
|
||||
if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
|
||||
g_value_copy (peek_value, value);
|
||||
@ -1312,6 +1108,7 @@ gtk_style_get_valist (GtkStyle *style,
|
||||
const gchar *first_property_name,
|
||||
va_list var_args)
|
||||
{
|
||||
GtkStylePrivate *priv;
|
||||
const char *property_name;
|
||||
GtkWidgetClass *klass;
|
||||
|
||||
@ -1319,11 +1116,11 @@ gtk_style_get_valist (GtkStyle *style,
|
||||
|
||||
klass = g_type_class_ref (widget_type);
|
||||
|
||||
priv = GTK_STYLE_GET_PRIVATE (style);
|
||||
property_name = first_property_name;
|
||||
while (property_name)
|
||||
{
|
||||
GParamSpec *pspec;
|
||||
GtkRcPropertyParser parser;
|
||||
const GValue *peek_value;
|
||||
gchar *error;
|
||||
|
||||
@ -1338,10 +1135,8 @@ gtk_style_get_valist (GtkStyle *style,
|
||||
break;
|
||||
}
|
||||
|
||||
parser = g_param_spec_get_qdata (pspec,
|
||||
g_quark_from_static_string ("gtk-rc-property-parser"));
|
||||
|
||||
peek_value = _gtk_style_peek_property_value (style, widget_type, pspec, parser);
|
||||
peek_value = _gtk_style_context_peek_style_property (priv->context, widget_type,
|
||||
0, pspec);
|
||||
G_VALUE_LCOPY (peek_value, var_args, 0, &error);
|
||||
if (error)
|
||||
{
|
||||
@ -1383,195 +1178,14 @@ gtk_style_get (GtkStyle *style,
|
||||
va_end (var_args);
|
||||
}
|
||||
|
||||
const GValue*
|
||||
_gtk_style_peek_property_value (GtkStyle *style,
|
||||
GType widget_type,
|
||||
GParamSpec *pspec,
|
||||
GtkRcPropertyParser parser)
|
||||
{
|
||||
PropertyValue *pcache, key = { 0, NULL, { 0, } };
|
||||
const GtkRcProperty *rcprop = NULL;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
|
||||
g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), NULL);
|
||||
g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
|
||||
|
||||
key.widget_type = widget_type;
|
||||
key.pspec = pspec;
|
||||
|
||||
/* need value cache array */
|
||||
if (!style->property_cache)
|
||||
style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
|
||||
else
|
||||
{
|
||||
pcache = bsearch (&key,
|
||||
style->property_cache->data, style->property_cache->len,
|
||||
sizeof (PropertyValue), style_property_values_cmp);
|
||||
if (pcache)
|
||||
return &pcache->value;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < style->property_cache->len &&
|
||||
style_property_values_cmp (&key, &g_array_index (style->property_cache, PropertyValue, i)) >= 0)
|
||||
i++;
|
||||
|
||||
g_array_insert_val (style->property_cache, i, key);
|
||||
pcache = &g_array_index (style->property_cache, PropertyValue, i);
|
||||
|
||||
/* cache miss, initialize value type, then set contents */
|
||||
g_param_spec_ref (pcache->pspec);
|
||||
g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
|
||||
/* value provided by rc style? */
|
||||
if (style->rc_style)
|
||||
{
|
||||
GQuark prop_quark = g_quark_from_string (pspec->name);
|
||||
|
||||
do
|
||||
{
|
||||
rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
|
||||
g_type_qname (widget_type),
|
||||
prop_quark);
|
||||
if (rcprop)
|
||||
break;
|
||||
widget_type = g_type_parent (widget_type);
|
||||
}
|
||||
while (g_type_is_a (widget_type, pspec->owner_type));
|
||||
}
|
||||
|
||||
/* when supplied by rc style, we need to convert */
|
||||
if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
|
||||
pspec, &pcache->value))
|
||||
{
|
||||
gchar *contents = g_strdup_value_contents (&rcprop->value);
|
||||
|
||||
g_message ("%s: failed to retrieve property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
|
||||
rcprop->origin ? rcprop->origin : "(for origin information, set GTK_DEBUG)",
|
||||
g_type_name (pspec->owner_type), pspec->name,
|
||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
|
||||
contents,
|
||||
G_VALUE_TYPE_NAME (&rcprop->value));
|
||||
g_free (contents);
|
||||
rcprop = NULL; /* needs default */
|
||||
}
|
||||
|
||||
/* not supplied by rc style (or conversion failed), revert to default */
|
||||
if (!rcprop)
|
||||
g_param_value_set_default (pspec, &pcache->value);
|
||||
|
||||
return &pcache->value;
|
||||
}
|
||||
|
||||
static cairo_pattern_t *
|
||||
load_background (GdkVisual *visual,
|
||||
GdkColor *bg_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
if (filename == NULL)
|
||||
{
|
||||
return cairo_pattern_create_rgb (bg_color->red / 65535.0,
|
||||
bg_color->green / 65535.0,
|
||||
bg_color->blue / 65535.0);
|
||||
}
|
||||
if (strcmp (filename, "<parent>") == 0)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
cairo_surface_t *surface;
|
||||
cairo_pattern_t *pattern;
|
||||
cairo_t *cr;
|
||||
GdkScreen *screen = gdk_visual_get_screen (visual);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen),
|
||||
CAIRO_CONTENT_COLOR,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
gdk_cairo_set_source_color (cr, bg_color);
|
||||
cairo_paint (cr);
|
||||
|
||||
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
pattern = cairo_pattern_create_for_surface (surface);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return pattern;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_real_realize (GtkStyle *style)
|
||||
{
|
||||
gint i;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
|
||||
style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
|
||||
style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
|
||||
}
|
||||
|
||||
style->black.red = 0x0000;
|
||||
style->black.green = 0x0000;
|
||||
style->black.blue = 0x0000;
|
||||
|
||||
style->white.red = 0xffff;
|
||||
style->white.green = 0xffff;
|
||||
style->white.blue = 0xffff;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
const char *image_name;
|
||||
|
||||
if (style->rc_style)
|
||||
image_name = style->rc_style->bg_pixmap_name[i];
|
||||
else
|
||||
image_name = NULL;
|
||||
|
||||
style->background[i] = load_background (style->visual,
|
||||
&style->bg[i],
|
||||
image_name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_real_unrealize (GtkStyle *style)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
if (style->background[i])
|
||||
{
|
||||
cairo_pattern_destroy (style->background[i]);
|
||||
style->background[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
style_unrealize_cursors (style);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4320,19 +3934,6 @@ struct _CursorInfo
|
||||
GdkColor secondary;
|
||||
};
|
||||
|
||||
static void
|
||||
style_unrealize_cursors (GtkStyle *style)
|
||||
{
|
||||
CursorInfo *
|
||||
|
||||
cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info");
|
||||
if (cursor_info)
|
||||
{
|
||||
g_free (cursor_info);
|
||||
g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static const GdkColor *
|
||||
get_insertion_cursor_color (GtkWidget *widget,
|
||||
gboolean is_primary)
|
||||
|
@ -634,14 +634,6 @@ void gtk_style_get (GtkStyle *style,
|
||||
#endif
|
||||
|
||||
/* --- private API --- */
|
||||
const GValue* _gtk_style_peek_property_value (GtkStyle *style,
|
||||
GType widget_type,
|
||||
GParamSpec *pspec,
|
||||
GtkRcPropertyParser parser);
|
||||
|
||||
void _gtk_style_init_for_settings (GtkStyle *style,
|
||||
GtkSettings *settings);
|
||||
|
||||
void _gtk_style_shade (const GdkColor *a,
|
||||
GdkColor *b,
|
||||
gdouble k);
|
||||
@ -655,7 +647,7 @@ void gtk_draw_insertion_cursor (GtkWidget *widget,
|
||||
void _gtk_widget_get_cursor_color (GtkWidget *widget,
|
||||
GdkColor *color);
|
||||
|
||||
gboolean gtk_style_has_context (GtkStyle *style);
|
||||
gboolean gtk_style_has_context (GtkStyle *style);
|
||||
|
||||
|
||||
|
||||
|
163
gtk/gtkwidget.c
163
gtk/gtkwidget.c
@ -45,7 +45,6 @@
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gdk/gdk.h"
|
||||
#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
|
||||
#include <gobject/gvaluecollector.h>
|
||||
#include <gobject/gobjectnotifyqueue.c>
|
||||
#include <cairo-gobject.h>
|
||||
@ -560,10 +559,7 @@ static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
|
||||
static void gtk_widget_update_pango_context (GtkWidget *widget);
|
||||
static void gtk_widget_propagate_state (GtkWidget *widget,
|
||||
GtkStateData *data);
|
||||
static void gtk_widget_reset_rc_style (GtkWidget *widget);
|
||||
static void gtk_widget_set_style_internal (GtkWidget *widget,
|
||||
GtkStyle *style,
|
||||
gboolean initial_emission);
|
||||
;
|
||||
static gint gtk_widget_event_internal (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
|
||||
@ -6290,9 +6286,29 @@ gtk_widget_real_query_tooltip (GtkWidget *widget,
|
||||
static void
|
||||
gtk_widget_real_style_updated (GtkWidget *widget)
|
||||
{
|
||||
if (gtk_widget_get_realized (widget))
|
||||
{
|
||||
/* Trigger ::style-set for old
|
||||
* widgets not listening to this
|
||||
*/
|
||||
g_signal_emit (widget,
|
||||
widget_signals[STYLE_SET],
|
||||
0,
|
||||
widget->priv->style);
|
||||
}
|
||||
|
||||
if (widget->priv->context)
|
||||
gtk_style_context_invalidate (widget->priv->context);
|
||||
gtk_widget_queue_resize (widget);
|
||||
{
|
||||
gtk_style_context_invalidate (widget->priv->context);
|
||||
|
||||
if (gtk_widget_get_realized (widget) &&
|
||||
gtk_widget_get_has_window (widget))
|
||||
gtk_style_context_set_background (widget->priv->context,
|
||||
widget->priv->window);
|
||||
}
|
||||
|
||||
if (widget->priv->anchored)
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -6734,9 +6750,6 @@ gtk_widget_set_name (GtkWidget *widget,
|
||||
if (priv->context)
|
||||
gtk_style_context_set_path (priv->context, priv->path);
|
||||
|
||||
if (priv->rc_style)
|
||||
gtk_widget_reset_rc_style (widget);
|
||||
|
||||
g_object_notify (G_OBJECT (widget), "name");
|
||||
}
|
||||
|
||||
@ -7658,23 +7671,6 @@ gtk_widget_set_style (GtkWidget *widget,
|
||||
GtkStyle *style)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
if (style)
|
||||
{
|
||||
gboolean initial_emission;
|
||||
|
||||
initial_emission = !widget->priv->rc_style && !widget->priv->user_style;
|
||||
|
||||
widget->priv->rc_style = FALSE;
|
||||
widget->priv->user_style = TRUE;
|
||||
|
||||
gtk_widget_set_style_internal (widget, style, initial_emission);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (widget->priv->user_style)
|
||||
gtk_widget_reset_rc_style (widget);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7698,42 +7694,21 @@ gtk_widget_ensure_style (GtkWidget *widget)
|
||||
{
|
||||
GtkStyle *style;
|
||||
|
||||
if (widget->priv->style)
|
||||
g_object_unref (widget->priv->style);
|
||||
|
||||
style = g_object_new (GTK_TYPE_STYLE,
|
||||
"context", gtk_widget_get_style_context (widget),
|
||||
NULL);
|
||||
|
||||
gtk_widget_set_style_internal (widget, style, TRUE);
|
||||
widget->priv->style = g_object_ref (style);
|
||||
|
||||
g_signal_emit (widget,
|
||||
widget_signals[STYLE_SET],
|
||||
0, NULL);
|
||||
|
||||
g_object_unref (style);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!widget->priv->rc_style && !widget->priv->user_style)
|
||||
gtk_widget_reset_rc_style (widget);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Look up the RC style for this widget, unsetting any user style that
|
||||
* may be in effect currently
|
||||
**/
|
||||
static void
|
||||
gtk_widget_reset_rc_style (GtkWidget *widget)
|
||||
{
|
||||
GtkWidgetPrivate *priv = widget->priv;
|
||||
GtkStyle *new_style = NULL;
|
||||
gboolean initial_emission;
|
||||
|
||||
initial_emission = !priv->rc_style && !priv->user_style;
|
||||
|
||||
priv->user_style = FALSE;
|
||||
priv->rc_style = TRUE;
|
||||
|
||||
if (gtk_widget_has_screen (widget))
|
||||
new_style = gtk_rc_get_style (widget);
|
||||
if (!new_style)
|
||||
new_style = gtk_widget_get_default_style ();
|
||||
|
||||
if (initial_emission || new_style != priv->style)
|
||||
gtk_widget_set_style_internal (widget, new_style, initial_emission);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7790,13 +7765,6 @@ gtk_widget_modify_style (GtkWidget *widget,
|
||||
quark_rc_style,
|
||||
gtk_rc_style_copy (style),
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
/* note that "style" may be invalid here if it was the old
|
||||
* modifier style and the only reference was our own.
|
||||
*/
|
||||
|
||||
if (widget->priv->rc_style)
|
||||
gtk_widget_reset_rc_style (widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7888,11 +7856,6 @@ modifier_style_changed (GtkModifierStyle *style,
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_invalidate (context);
|
||||
|
||||
g_signal_emit (widget,
|
||||
widget_signals[STYLE_SET],
|
||||
0,
|
||||
widget->priv->style);
|
||||
}
|
||||
|
||||
static GtkModifierStyle *
|
||||
@ -8347,59 +8310,6 @@ static void
|
||||
gtk_widget_real_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous_style)
|
||||
{
|
||||
GtkWidgetPrivate *priv = widget->priv;
|
||||
|
||||
if (gtk_widget_get_realized (widget) &&
|
||||
gtk_widget_get_has_window (widget))
|
||||
gtk_style_set_background (priv->style, priv->window,
|
||||
gtk_widget_get_state (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_set_style_internal (GtkWidget *widget,
|
||||
GtkStyle *style,
|
||||
gboolean initial_emission)
|
||||
{
|
||||
GtkWidgetPrivate *priv = widget->priv;
|
||||
|
||||
g_object_ref (widget);
|
||||
g_object_freeze_notify (G_OBJECT (widget));
|
||||
|
||||
if (priv->style != style)
|
||||
{
|
||||
GtkStyle *previous_style;
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
gtk_style_detach (priv->style);
|
||||
|
||||
previous_style = priv->style;
|
||||
priv->style = style;
|
||||
g_object_ref (priv->style);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
priv->style = gtk_style_attach (priv->style, priv->window);
|
||||
|
||||
gtk_widget_update_pango_context (widget);
|
||||
g_signal_emit (widget,
|
||||
widget_signals[STYLE_SET],
|
||||
0,
|
||||
initial_emission ? NULL : previous_style);
|
||||
g_object_unref (previous_style);
|
||||
|
||||
if (priv->anchored && !initial_emission)
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
else if (initial_emission)
|
||||
{
|
||||
gtk_widget_update_pango_context (widget);
|
||||
g_signal_emit (widget,
|
||||
widget_signals[STYLE_SET],
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
g_object_notify (G_OBJECT (widget), "style");
|
||||
g_object_thaw_notify (G_OBJECT (widget));
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@ -8594,11 +8504,6 @@ _gtk_widget_propagate_screen_changed (GtkWidget *widget,
|
||||
static void
|
||||
reset_style_recurse (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
#if 0
|
||||
if (widget->priv->rc_style)
|
||||
gtk_widget_reset_rc_style (widget);
|
||||
#endif
|
||||
|
||||
if (widget->priv->context)
|
||||
{
|
||||
_gtk_widget_update_path (widget);
|
||||
@ -13797,7 +13702,11 @@ style_context_changed (GtkStyleContext *context,
|
||||
{
|
||||
GtkWidget *widget = user_data;
|
||||
|
||||
gtk_widget_update_pango_context (widget);
|
||||
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
|
||||
|
||||
if (widget->priv->anchored)
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user