diff options
author | Tim Janik <timj@gtk.org> | 2001-04-03 13:18:00 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2001-04-03 13:18:00 +0000 |
commit | 748560e1fcccc046183f82818960ca53f0b69295 (patch) | |
tree | 0ca1f02f7507559371d48bcea85cb1e9647ef5be | |
parent | 655abd087209e246966e68330f1b2f6861be8154 (diff) | |
download | gtk+-748560e1fcccc046183f82818960ca53f0b69295.tar.gz |
changed gtk_item_factory_dump_items() and gtk_item_factory_dump_rc()
Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org>
* gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
and gtk_item_factory_dump_rc() GtkPatternSpec argument to
GPatternSpec. this is actually unlikely to cause breakage in
third-party apps since except for gle, pretty much ever caller
passes NULL here.
* gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
* *.c: use g_pattern_*() API.
* docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
directions aren't passed in.
* gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
functionality to be usable from gtkstyle.c as well, give precedence
for conversion to user-supplied parsers.
s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
* gtk/gtkstyle.c (_gtk_style_peek_property_value): use
_gtk_settings_parse_convert() for rcporperty value conversion.
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 25 | ||||
-rw-r--r-- | docs/Changes-2.0.txt | 4 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtk-unused.sgml | 56 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtkbindings.sgml | 61 | ||||
-rw-r--r-- | gtk/gtkbindings.c | 282 | ||||
-rw-r--r-- | gtk/gtkbindings.h | 27 | ||||
-rw-r--r-- | gtk/gtkitemfactory.c | 32 | ||||
-rw-r--r-- | gtk/gtkitemfactory.h | 5 | ||||
-rw-r--r-- | gtk/gtkrc.c | 12 | ||||
-rw-r--r-- | gtk/gtksettings.c | 120 | ||||
-rw-r--r-- | gtk/gtksettings.h | 10 | ||||
-rw-r--r-- | gtk/gtkstyle.c | 60 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 2 | ||||
-rw-r--r-- | gtk/testgtkrc | 2 | ||||
-rw-r--r-- | tests/testgtkrc | 2 |
21 files changed, 382 insertions, 468 deletions
@@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 6234293879..37c281cee4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6234293879..37c281cee4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 6234293879..37c281cee4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 6234293879..37c281cee4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 6234293879..37c281cee4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 6234293879..37c281cee4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,28 @@ +Tue Apr 3 13:52:57 2001 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items() + and gtk_item_factory_dump_rc() GtkPatternSpec argument to + GPatternSpec. this is actually unlikely to cause breakage in + third-party apps since except for gle, pretty much ever caller + passes NULL here. + + * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API. + + * *.c: use g_pattern_*() API. + + * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates. + + * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled + directions aren't passed in. + + * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion + functionality to be usable from gtkstyle.c as well, give precedence + for conversion to user-supplied parsers. + s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/; + + * gtk/gtkstyle.c (_gtk_style_peek_property_value): use + _gtk_settings_parse_convert() for rcporperty value conversion. + 2001-04-03 Alexander Larsson <alexl@redhat.com> * gdk/linux-fb/gdkevents-fb.c: diff --git a/docs/Changes-2.0.txt b/docs/Changes-2.0.txt index f834f605c4..304c968e06 100644 --- a/docs/Changes-2.0.txt +++ b/docs/Changes-2.0.txt @@ -32,6 +32,10 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0: * gtk_widget_shape_combine_mask() now keeps a reference count on the mask pixmap that is passed in. +* the GtkPatternSpec has been moved to glib as GPatternSpec, the pattern + arguments to gtk_item_factory_dump_items() and gtk_item_factory_dump_rc() + have thusly been changed to take a GPatternSpec instead of GtkPatternSpec. + * Type system changes: - GTK_TYPE_OBJECT is not a fundamental type anymore. Type checks of the style (GTK_FUNDAMENTAL_TYPE (some_type) == GTK_TYPE_OBJECT) diff --git a/docs/reference/gtk/tmpl/gtk-unused.sgml b/docs/reference/gtk/tmpl/gtk-unused.sgml index f4cce16521..9b136f005c 100644 --- a/docs/reference/gtk/tmpl/gtk-unused.sgml +++ b/docs/reference/gtk/tmpl/gtk-unused.sgml @@ -604,6 +604,18 @@ after other user handlers and the default handler. </para> +<!-- ##### STRUCT GtkPatternSpec ##### --> +<para> + +</para> + +@match_type: +@pattern_length: +@pattern: +@pattern_reversed: +@user_data: +@seq_id: + <!-- ##### ENUM GtkPrivateFlags ##### --> <para> @@ -1172,6 +1184,50 @@ Set the the handle size to @size x @size pixels. @paned: a paned widget @size: the size in pixels +<!-- ##### FUNCTION gtk_pattern_match ##### --> +<para> + +</para> + +@pspec: +@string_length: +@string: +@string_reversed: +@Returns: + +<!-- ##### FUNCTION gtk_pattern_match_simple ##### --> +<para> + +</para> + +@pattern: +@string: +@Returns: + +<!-- ##### FUNCTION gtk_pattern_match_string ##### --> +<para> + +</para> + +@pspec: +@string: +@Returns: + +<!-- ##### FUNCTION gtk_pattern_spec_free_segs ##### --> +<para> + +</para> + +@pspec: + +<!-- ##### FUNCTION gtk_pattern_spec_init ##### --> +<para> + +</para> + +@pspec: +@pattern: + <!-- ##### FUNCTION gtk_rc_init ##### --> <para> Internal function. diff --git a/docs/reference/gtk/tmpl/gtkbindings.sgml b/docs/reference/gtk/tmpl/gtkbindings.sgml index a5c84f097d..e790765b32 100644 --- a/docs/reference/gtk/tmpl/gtkbindings.sgml +++ b/docs/reference/gtk/tmpl/gtkbindings.sgml @@ -14,67 +14,6 @@ Bindings </para> -<!-- ##### STRUCT GtkPatternSpec ##### --> -<para> - -</para> - -@match_type: -@pattern_length: -@pattern: -@pattern_reversed: -@user_data: -@seq_id: - -<!-- ##### FUNCTION gtk_pattern_spec_init ##### --> -<para> - -</para> - -@pspec: -@pattern: - - -<!-- ##### FUNCTION gtk_pattern_spec_free_segs ##### --> -<para> - -</para> - -@pspec: - - -<!-- ##### FUNCTION gtk_pattern_match ##### --> -<para> - -</para> - -@pspec: -@string_length: -@string: -@string_reversed: -@Returns: - - -<!-- ##### FUNCTION gtk_pattern_match_string ##### --> -<para> - -</para> - -@pspec: -@string: -@Returns: - - -<!-- ##### FUNCTION gtk_pattern_match_simple ##### --> -<para> - -</para> - -@pattern: -@string: -@Returns: - - <!-- ##### STRUCT GtkBindingSet ##### --> <para> diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c index 4004622f70..41e65a15a2 100644 --- a/gtk/gtkbindings.c +++ b/gtk/gtkbindings.c @@ -40,6 +40,14 @@ #define BINDING_MOD_MASK() (gtk_accelerator_get_default_mod_mask () | GDK_RELEASE_MASK) +/* --- structures --- */ +typedef struct { + GPatternSpec *pspec; + gpointer user_data; + guint seq_id; +} PatternSpec; + + /* --- variables --- */ static GHashTable *binding_entry_hash_table = NULL; static GSList *binding_set_list = NULL; @@ -719,7 +727,7 @@ gtk_binding_set_add_path (GtkBindingSet *binding_set, const gchar *path_pattern, GtkPathPriorityType priority) { - GtkPatternSpec *pspec; + PatternSpec *pspec; GSList **slist_p, *slist; static guint seq_id = 0; @@ -745,8 +753,8 @@ gtk_binding_set_add_path (GtkBindingSet *binding_set, break; } - pspec = g_new (GtkPatternSpec, 1); - gtk_pattern_spec_init (pspec, path_pattern); + pspec = g_new (PatternSpec, 1); + pspec->pspec = g_pattern_spec_new (path_pattern); pspec->seq_id = seq_id++ & 0x0fffffff; pspec->seq_id |= priority << 28; pspec->user_data = binding_set; @@ -754,15 +762,15 @@ gtk_binding_set_add_path (GtkBindingSet *binding_set, slist = *slist_p; while (slist) { - GtkPatternSpec *tmp_pspec; + PatternSpec *tmp_pspec; tmp_pspec = slist->data; slist = slist->next; - if (tmp_pspec->pattern_length == pspec->pattern_length && - g_str_equal (tmp_pspec->pattern_reversed, pspec->pattern_reversed)) + if (tmp_pspec->pspec->pattern_length == pspec->pspec->pattern_length && + g_str_equal (tmp_pspec->pspec->pattern_reversed, pspec->pspec->pattern_reversed)) { - gtk_pattern_spec_free_segs (pspec); + g_pattern_spec_free (pspec->pspec); g_free (pspec); pspec = NULL; break; @@ -783,10 +791,10 @@ binding_match_activate (GSList *pspec_list, for (slist = pspec_list; slist; slist = slist->next) { - GtkPatternSpec *pspec; + PatternSpec *pspec; pspec = slist->data; - if (gtk_pattern_match (pspec, path_length, path, path_reversed)) + if (g_pattern_match (pspec->pspec, path_length, path, path_reversed)) { GtkBindingSet *binding_set; @@ -805,8 +813,8 @@ static gint gtk_binding_pattern_compare (gconstpointer new_pattern, gconstpointer existing_pattern) { - register const GtkPatternSpec *np = new_pattern; - register const GtkPatternSpec *ep = existing_pattern; + register const PatternSpec *np = new_pattern; + register const PatternSpec *ep = existing_pattern; /* walk the list as long as the existing patterns have * higher priorities. @@ -845,7 +853,7 @@ gtk_binding_entries_sort_patterns (GtkBindingEntry *entries, for (; slist; slist = slist->next) { - GtkPatternSpec *pspec; + PatternSpec *pspec; pspec = slist->data; patterns = g_slist_insert_sorted (patterns, pspec, gtk_binding_pattern_compare); @@ -938,255 +946,6 @@ gtk_bindings_activate (GtkObject *object, return handled; } - - - - - - - - - -/* Patterns - */ - -static inline gboolean -gtk_pattern_ph_match (const gchar *match_pattern, - const gchar *match_string) -{ - register const gchar *pattern, *string; - register gchar ch; - - pattern = match_pattern; - string = match_string; - - ch = *pattern; - pattern++; - while (ch) - { - switch (ch) - { - case '?': - if (!*string) - return FALSE; - string++; - break; - - case '*': - do - { - ch = *pattern; - pattern++; - if (ch == '?') - { - if (!*string) - return FALSE; - string++; - } - } - while (ch == '*' || ch == '?'); - if (!ch) - return TRUE; - do - { - while (ch != *string) - { - if (!*string) - return FALSE; - string++; - } - string++; - if (gtk_pattern_ph_match (pattern, string)) - return TRUE; - } - while (*string); - break; - - default: - if (ch == *string) - string++; - else - return FALSE; - break; - } - - ch = *pattern; - pattern++; - } - - return *string == 0; -} - -gboolean -gtk_pattern_match (GtkPatternSpec *pspec, - guint string_length, - const gchar *string, - const gchar *string_reversed) -{ - g_return_val_if_fail (pspec != NULL, FALSE); - g_return_val_if_fail (string != NULL, FALSE); - g_return_val_if_fail (string_reversed != NULL, FALSE); - - switch (pspec->match_type) - { - case GTK_MATCH_ALL: - return gtk_pattern_ph_match (pspec->pattern, string); - - case GTK_MATCH_ALL_TAIL: - return gtk_pattern_ph_match (pspec->pattern_reversed, string_reversed); - - case GTK_MATCH_HEAD: - if (pspec->pattern_length > string_length) - return FALSE; - else if (pspec->pattern_length == string_length) - return strcmp (pspec->pattern, string) == 0; - else if (pspec->pattern_length) - return strncmp (pspec->pattern, string, pspec->pattern_length) == 0; - else - return TRUE; - - case GTK_MATCH_TAIL: - if (pspec->pattern_length > string_length) - return FALSE; - else if (pspec->pattern_length == string_length) - return strcmp (pspec->pattern_reversed, string_reversed) == 0; - else if (pspec->pattern_length) - return strncmp (pspec->pattern_reversed, - string_reversed, - pspec->pattern_length) == 0; - else - return TRUE; - - case GTK_MATCH_EXACT: - if (pspec->pattern_length != string_length) - return FALSE; - else - return strcmp (pspec->pattern_reversed, string_reversed) == 0; - - default: - g_return_val_if_fail (pspec->match_type < GTK_MATCH_LAST, FALSE); - return FALSE; - } -} - -void -gtk_pattern_spec_init (GtkPatternSpec *pspec, - const gchar *pattern) -{ - gchar *p; - - g_return_if_fail (pspec != NULL); - - pspec->match_type = GTK_MATCH_ALL; - pspec->seq_id = 0; - pspec->user_data = NULL; - - if (!pattern) - pattern = ""; - - pspec->pattern = g_strdup (pattern); - pspec->pattern_length = strlen (pspec->pattern); - pspec->pattern_reversed = g_strdup (pspec->pattern); - g_strreverse (pspec->pattern_reversed); - if (pspec->pattern_reversed[0] != '*') - pspec->match_type = GTK_MATCH_ALL_TAIL; - - if (strchr (pspec->pattern, '?')) - return; - - if (!strchr (pspec->pattern, '*')) - { - pspec->match_type = GTK_MATCH_EXACT; - return; - } - - p = pspec->pattern; - while (*p == '*') - p++; - if (p > pspec->pattern && - !strchr (p, '*')) - { - gchar *t; - - pspec->match_type = GTK_MATCH_TAIL; - t = pspec->pattern; - pspec->pattern = g_strdup (p); - g_free (t); - g_free (pspec->pattern_reversed); - pspec->pattern_reversed = g_strdup (pspec->pattern); - g_strreverse (pspec->pattern_reversed); - pspec->pattern_length = strlen (pspec->pattern); - return; - } - - p = pspec->pattern_reversed; - while (*p == '*') - p++; - if (p > pspec->pattern_reversed && - !strchr (p, '*')) - { - gchar *t; - - pspec->match_type = GTK_MATCH_HEAD; - t = pspec->pattern_reversed; - pspec->pattern_reversed = g_strdup (p); - g_free (t); - g_free (pspec->pattern); - pspec->pattern = g_strdup (pspec->pattern_reversed); - g_strreverse (pspec->pattern); - pspec->pattern_length = strlen (pspec->pattern); - } -} - -gboolean -gtk_pattern_match_string (GtkPatternSpec *pspec, - const gchar *string) -{ - gchar *string_reversed; - guint length; - gboolean ergo; - - g_return_val_if_fail (pspec != NULL, FALSE); - g_return_val_if_fail (string != NULL, FALSE); - - length = strlen (string); - string_reversed = g_strdup (string); - g_strreverse (string_reversed); - - ergo = gtk_pattern_match (pspec, length, string, string_reversed); - g_free (string_reversed); - - return ergo; -} - -gboolean -gtk_pattern_match_simple (const gchar *pattern, - const gchar *string) -{ - GtkPatternSpec pspec; - gboolean ergo; - - g_return_val_if_fail (pattern != NULL, FALSE); - g_return_val_if_fail (string != NULL, FALSE); - - gtk_pattern_spec_init (&pspec, pattern); - ergo = gtk_pattern_match_string (&pspec, string); - gtk_pattern_spec_free_segs (&pspec); - - return ergo; -} - -void -gtk_pattern_spec_free_segs (GtkPatternSpec *pspec) -{ - g_return_if_fail (pspec != NULL); - - g_free (pspec->pattern); - pspec->pattern = NULL; - g_free (pspec->pattern_reversed); - pspec->pattern_reversed = NULL; -} - static guint gtk_binding_parse_signal (GScanner *scanner, GtkBindingSet *binding_set, @@ -1447,4 +1206,3 @@ gtk_binding_parse_binding (GScanner *scanner) return G_TOKEN_NONE; } - diff --git a/gtk/gtkbindings.h b/gtk/gtkbindings.h index 051947d9d1..b5e6ed246a 100644 --- a/gtk/gtkbindings.h +++ b/gtk/gtkbindings.h @@ -41,33 +41,6 @@ extern "C" { #endif /* __cplusplus */ -/* Pattern matching - */ -typedef struct _GtkPatternSpec GtkPatternSpec; - -struct _GtkPatternSpec -{ - GtkMatchType match_type; - guint pattern_length; - gchar *pattern; - gchar *pattern_reversed; - gpointer user_data; - guint seq_id; -}; - -void gtk_pattern_spec_init (GtkPatternSpec *pspec, - const gchar *pattern); -void gtk_pattern_spec_free_segs (GtkPatternSpec *pspec); -gboolean gtk_pattern_match (GtkPatternSpec *pspec, - guint string_length, - const gchar *string, - const gchar *string_reversed); -gboolean gtk_pattern_match_string (GtkPatternSpec *pspec, - const gchar *string); -gboolean gtk_pattern_match_simple (const gchar *pattern, - const gchar *string); - - /* Binding sets */ diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c index 5239421c3a..dc305332ba 100644 --- a/gtk/gtkitemfactory.c +++ b/gtk/gtkitemfactory.c @@ -78,10 +78,10 @@ struct _GtkIFCBData }; struct _GtkIFDumpData { - GtkPrintFunc print_func; - gpointer func_data; - guint modified_only : 1; - GtkPatternSpec *pspec; + GtkPrintFunc print_func; + gpointer func_data; + guint modified_only : 1; + GPatternSpec *pspec; }; @@ -777,7 +777,7 @@ gtk_item_factory_foreach (gpointer hash_key, item = value; data = user_data; - if (data->pspec && !gtk_pattern_match_string (data->pspec, item->path)) + if (data->pspec && !g_pattern_match_string (data->pspec, item->path)) return; comment_prefix[0] = gtk_item_factory_class->cpair_comment_single[0]; @@ -800,7 +800,7 @@ gtk_item_factory_foreach (gpointer hash_key, } void -gtk_item_factory_dump_items (GtkPatternSpec *path_pspec, +gtk_item_factory_dump_items (GPatternSpec *path_pspec, gboolean modified_only, GtkPrintFunc print_func, gpointer func_data) @@ -834,9 +834,9 @@ gtk_item_factory_print_func (gpointer FILE_pointer, } void -gtk_item_factory_dump_rc (const gchar *file_name, - GtkPatternSpec *path_pspec, - gboolean modified_only) +gtk_item_factory_dump_rc (const gchar *file_name, + GPatternSpec *path_pspec, + gboolean modified_only) { FILE *f_out; @@ -1319,18 +1319,18 @@ void gtk_item_factory_create_menu_entries (guint n_entries, GtkMenuEntry *entries) { - static GtkPatternSpec pspec_separator = { 42, 0 }; - static GtkPatternSpec pspec_check = { 42, 0 }; + static GPatternSpec *pspec_separator = NULL; + static GPatternSpec *pspec_check = NULL; guint i; if (!n_entries) return; g_return_if_fail (entries != NULL); - if (pspec_separator.pattern_length == 0) + if (!pspec_separator) { - gtk_pattern_spec_init (&pspec_separator, "*<separator>*"); - gtk_pattern_spec_init (&pspec_check, "*<check>*"); + pspec_separator = g_pattern_spec_new ("*<separator>*"); + pspec_check = g_pattern_spec_new ("*<check>*"); } for (i = 0; i < n_entries; i++) @@ -1359,9 +1359,9 @@ gtk_item_factory_create_menu_entries (guint n_entries, entry.accelerator = entries[i].accelerator; entry.callback = entries[i].callback; entry.callback_action = 0; - if (gtk_pattern_match_string (&pspec_separator, path)) + if (g_pattern_match_string (pspec_separator, path)) entry.item_type = "<Separator>"; - else if (!gtk_pattern_match_string (&pspec_check, path)) + else if (!g_pattern_match_string (pspec_check, path)) entry.item_type = NULL; else { diff --git a/gtk/gtkitemfactory.h b/gtk/gtkitemfactory.h index bbe2febe6c..536d4ea7be 100644 --- a/gtk/gtkitemfactory.h +++ b/gtk/gtkitemfactory.h @@ -32,7 +32,6 @@ #include <gtk/gtkwidget.h> -#include <gtk/gtkbindings.h> /* for GtkPatternSpec */ #ifdef __cplusplus @@ -171,12 +170,12 @@ GtkWidget* gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory, * all hash entries. otherwise only those entries will be dumped for which * the pattern matches, e.g. "<Image>*...". */ -void gtk_item_factory_dump_items (GtkPatternSpec *path_pspec, +void gtk_item_factory_dump_items (GPatternSpec *path_pspec, gboolean modified_only, GtkPrintFunc print_func, gpointer func_data); void gtk_item_factory_dump_rc (const gchar *file_name, - GtkPatternSpec *path_pspec, + GPatternSpec *path_pspec, gboolean modified_only); void gtk_item_factory_print_func (gpointer FILE_pointer, const gchar *string); diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 01c26c2fa2..10544dc97e 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -69,8 +69,8 @@ typedef struct _GtkRcFile GtkRcFile; struct _GtkRcSet { - GtkPatternSpec pspec; - GtkRcStyle *rc_style; + GPatternSpec *pspec; + GtkRcStyle *rc_style; }; struct _GtkRcFile @@ -1064,7 +1064,7 @@ gtk_rc_free_rc_sets (GSList *slist) GtkRcSet *rc_set; rc_set = slist->data; - gtk_pattern_spec_free_segs (&rc_set->pspec); + g_pattern_spec_free (rc_set->pspec); g_free (rc_set); slist = slist->next; @@ -1156,7 +1156,7 @@ gtk_rc_styles_match (GSList *rc_styles, rc_set = sets->data; sets = sets->next; - if (gtk_pattern_match (&rc_set->pspec, path_length, path, path_reversed)) + if (g_pattern_match (rc_set->pspec, path_length, path, path_reversed)) rc_styles = g_slist_append (rc_styles, rc_set->rc_style); } @@ -1254,7 +1254,7 @@ gtk_rc_add_rc_sets (GSList *slist, new_style->bg_pixmap_name[i] = g_strdup (rc_style->bg_pixmap_name[i]); rc_set = g_new (GtkRcSet, 1); - gtk_pattern_spec_init (&rc_set->pspec, pattern); + rc_set->pspec = g_pattern_spec_new (pattern); rc_set->rc_style = rc_style; return g_slist_prepend (slist, rc_set); @@ -3002,7 +3002,7 @@ gtk_rc_parse_path_pattern (GScanner *scanner) } rc_set = g_new (GtkRcSet, 1); - gtk_pattern_spec_init (&rc_set->pspec, pattern); + rc_set->pspec = g_pattern_spec_new (pattern); rc_set->rc_style = rc_style; if (path_type == GTK_PATH_WIDGET) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 0b4cbac2e7..e0b82820e1 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -259,59 +259,89 @@ gtk_settings_notify (GObject *object, #endif } -static void -apply_queued_setting (GtkSettings *data, - GParamSpec *pspec, - GtkSettingsValue *qvalue) +gboolean +_gtk_settings_parse_convert (GtkRcPropertyParser parser, + const GValue *src_value, + GParamSpec *pspec, + GValue *dest_value) { - gboolean warn_convert = TRUE; + gboolean success = FALSE; - if (g_value_type_transformable (G_VALUE_TYPE (&qvalue->value), G_PARAM_SPEC_VALUE_TYPE (pspec))) - { - GValue tmp_value = { 0, }; + g_return_val_if_fail (G_VALUE_HOLDS (dest_value, G_PARAM_SPEC_VALUE_TYPE (pspec)), FALSE); - warn_convert = FALSE; - g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - if (g_param_value_convert (pspec, &qvalue->value, &tmp_value, TRUE)) - g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value); + if (parser) + { + GString *gstring; + gboolean free_gstring = TRUE; + + if (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING)) + { + gstring = g_value_get_boxed (src_value); + free_gstring = FALSE; + } + else if (G_VALUE_HOLDS_LONG (src_value)) + { + gstring = g_string_new (""); + g_string_printfa (gstring, "%ld", g_value_get_long (src_value)); + } + else if (G_VALUE_HOLDS_DOUBLE (src_value)) + { + gstring = g_string_new (""); + g_string_printfa (gstring, "%f", g_value_get_double (src_value)); + } + else if (G_VALUE_HOLDS_STRING (src_value)) + { + gchar *tstr = g_strescape (g_value_get_string (src_value), NULL); + + gstring = g_string_new ("\""); + g_string_append (gstring, tstr); + g_string_append_c (gstring, '\"'); + g_free (tstr); + } else { - gchar *debug = g_strdup_value_contents (&tmp_value); - - g_message ("%s: rc-value `%s' for rc-property \"%s\" of type `%s' has invalid contents \"%s\"", - qvalue->origin, - G_VALUE_TYPE_NAME (&qvalue->value), - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - debug); - g_free (debug); + g_return_val_if_fail (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING), FALSE); + gstring = NULL; /* silence compiler */ } - g_value_unset (&tmp_value); + + success = (parser (pspec, gstring, dest_value) && + !g_param_value_validate (pspec, dest_value)); + + if (free_gstring) + g_string_free (gstring, TRUE); } + else if (!G_VALUE_HOLDS (src_value, G_TYPE_GSTRING) && + g_value_type_transformable (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value))) + success = g_param_value_convert (pspec, src_value, dest_value, TRUE); + + return success; +} + +static void +apply_queued_setting (GtkSettings *data, + GParamSpec *pspec, + GtkSettingsValue *qvalue) +{ + GValue tmp_value = { 0, }; + GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec, quark_property_parser); + + g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + if (_gtk_settings_parse_convert (parser, &qvalue->value, + pspec, &tmp_value)) + g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value); else { - GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec, quark_property_parser); - - if (parser) - { - GValue tmp_value = { 0, }; - - g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - if (parser (pspec, g_value_get_boxed (&qvalue->value), &tmp_value)) - { - warn_convert = FALSE; - g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value); - } - g_value_unset (&tmp_value); - } + gchar *debug = g_strdup_value_contents (&tmp_value); + + g_message ("%s: failed to retrive property `%s' of type `%s' from rc file value \"%s\" of type `%s'", + qvalue->origin, + pspec->name, + g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), + debug, + G_VALUE_TYPE_NAME (&tmp_value)); + g_free (debug); } - - if (warn_convert) - g_message ("%s: unable to convert rc-value of type `%s' to rc-property \"%s\" of type `%s'", - qvalue->origin, - G_VALUE_TYPE_NAME (&qvalue->value), - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); + g_value_unset (&tmp_value); } static guint @@ -379,7 +409,7 @@ settings_install_property_parser (GtkSettingsClass *class, } GtkRcPropertyParser -_gtk_rc_property_parser_for_type (GType type) +_gtk_rc_property_parser_from_type (GType type) { if (type == GDK_TYPE_COLOR) return gtk_rc_property_parse_color; @@ -404,7 +434,7 @@ gtk_settings_install_property (GtkSettings *settings, g_return_if_fail (GTK_IS_SETTINGS (settings)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - parser = _gtk_rc_property_parser_for_type (G_PARAM_SPEC_VALUE_TYPE (pspec)); + parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec)); settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, parser); } diff --git a/gtk/gtksettings.h b/gtk/gtksettings.h index 6a861ad322..59c2fd90cd 100644 --- a/gtk/gtksettings.h +++ b/gtk/gtksettings.h @@ -110,9 +110,15 @@ void gtk_settings_set_double_property (GtkSettings *settings, gdouble v_double, const gchar *origin); -void _gtk_settings_handle_event (GdkEventSetting *event); -GtkRcPropertyParser _gtk_rc_property_parser_for_type (GType type); +/* implementation details */ +void _gtk_settings_handle_event (GdkEventSetting *event); +GtkRcPropertyParser _gtk_rc_property_parser_from_type (GType type); +gboolean _gtk_settings_parse_convert (GtkRcPropertyParser parser, + const GValue *src_value, + GParamSpec *pspec, + GValue *dest_value); + #ifdef __cplusplus } diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 3b01a5614a..b749777020 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -32,6 +32,7 @@ #include "gtkwidget.h" #include "gtkthemes.h" #include "gtkiconfactory.h" +#include "gtksettings.h" /* _gtk_settings_parse_convert() */ #define LIGHTNESS_MULT 1.3 #define DARKNESS_MULT 0.7 @@ -1244,6 +1245,7 @@ _gtk_style_peek_property_value (GtkStyle *style, return &pcache->value; /* 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? */ @@ -1264,55 +1266,25 @@ _gtk_style_peek_property_value (GtkStyle *style, } /* when supplied by rc style, we need to convert */ - if (rcprop) + if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value, + pspec, &pcache->value)) { - if (G_VALUE_TYPE (&rcprop->value) == G_TYPE_GSTRING) - { - GString *gstring; - - /* value still unparsed, need to revert to user supplied parser function */ - - gstring = g_value_get_boxed (&rcprop->value); - - if (!parser || !parser (pspec, gstring, &pcache->value) || - g_param_value_validate (pspec, &pcache->value)) - { - gchar *contents = g_strescape (gstring->str, NULL); - - g_message ("%s: failed to parse property `%s::%s' of type `%s' from rc file value \"%s\"", - rcprop->origin, - g_type_name (pspec->owner_type), pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - gstring->str); - g_free (contents); - rcprop = NULL; - } - } - else - { - /* we use the normal conversion functionality of param specs */ - if (!g_param_value_convert (pspec, &rcprop->value, &pcache->value, TRUE)) - { - gchar *contents = g_strdup_value_contents (&rcprop->value); - - g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'", - rcprop->origin, - 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; - } - } + gchar *contents = g_strdup_value_contents (&rcprop->value); + + g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'", + rcprop->origin, + 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); - g_param_spec_ref (pcache->pspec); - return &pcache->value; } @@ -4025,7 +3997,9 @@ gtk_default_draw_resize_grip (GtkStyle *style, } } break; - + default: + g_assert_not_reached (); + break; } if (area) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 84d8db2229..3a63ace0f3 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5411,7 +5411,7 @@ gtk_widget_class_install_style_property (GtkWidgetClass *class, g_return_if_fail (GTK_IS_WIDGET_CLASS (class)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - parser = _gtk_rc_property_parser_for_type (G_PARAM_SPEC_VALUE_TYPE (pspec)); + parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec)); gtk_widget_class_install_style_property_parser (class, pspec, parser); } diff --git a/gtk/testgtkrc b/gtk/testgtkrc index 2772f40691..408cd54a65 100644 --- a/gtk/testgtkrc +++ b/gtk/testgtkrc @@ -32,7 +32,7 @@ style "global-style-properties" { # xthickness = 20 GtkSpinButton::shadow_type = etched-out - GtkEntry::cursor_color = { 1.0, 0.0, 0.0 } + GtkEntry::cursor_color = "#ff00ff" } class "GtkWidget" style "global-style-properties" diff --git a/tests/testgtkrc b/tests/testgtkrc index 2772f40691..408cd54a65 100644 --- a/tests/testgtkrc +++ b/tests/testgtkrc @@ -32,7 +32,7 @@ style "global-style-properties" { # xthickness = 20 GtkSpinButton::shadow_type = etched-out - GtkEntry::cursor_color = { 1.0, 0.0, 0.0 } + GtkEntry::cursor_color = "#ff00ff" } class "GtkWidget" style "global-style-properties" |