Commit 8c56db61 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

introduce testbindings on C-1 for buttons, to check out binding

Thu Jul 23 00:11:39 1998  Tim Janik  <timj@gtk.org>

        * gtk/testgtkrc: introduce testbindings on C-1 for buttons,
        to check out binding priorities. someone should really write
        gtkrc-mode for emacs.

        * gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
        * gtk/testgtk.c (main): and move it here ;). this test says something
        on release of C-9. (this works only if the mouse pointer is on a
        spinbutton and there is no focus widget).

        * gtk/gtkrc.h:
        * gtk/gtkrc.c:
        export gtk_rc_parse_color, gtk_rc_parse_state and a new function
        gtk_rc_parse_priority to parse path priority types.
        export rc tokens.
        feature binding parsing.

Wed Jul 22 23:41:17 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtkbindings.h:
        * gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
        feature binding parsing in rc files.
        * gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
        * gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
        order the bindings with lowest priority first.
parent 3ea4f70f
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
Thu Jul 23 00:11:39 1998 Tim Janik <timj@gtk.org>
* gtk/testgtkrc: introduce testbindings on C-1 for buttons,
to check out binding priorities. someone should really write
gtkrc-mode for emacs.
* gtk/gtkwidget.c (gtk_widget_class_init): remove ugly bindings test.
* gtk/testgtk.c (main): and move it here ;). this test says something
on release of C-9. (this works only if the mouse pointer is on a
spinbutton and there is no focus widget).
* gtk/gtkrc.h:
* gtk/gtkrc.c:
export gtk_rc_parse_color, gtk_rc_parse_state and a new function
gtk_rc_parse_priority to parse path priority types.
export rc tokens.
feature binding parsing.
Wed Jul 22 23:41:17 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.h:
* gtk/gtkbindings.c: new function gtk_binding_parse_binding() to
feature binding parsing in rc files.
* gtk/gtkbindings.c (gtk_binding_set_new): bug fix.
* gtk/gtkbindings.c (gtk_binding_pattern_compare): bug fix, we used to
order the bindings with lowest priority first.
Wed Jul 22 15:21:08 PDT 1998 Manish Singh <yosh@gimp.org>
* gdk/gdkrgb.c: actually builds and runs properly on big
......
......@@ -299,6 +299,37 @@
(bottom-to-top GTK_PROGRESS_BOTTOM_TO_TOP)
(top-to-bottom GTK_PROGRESS_TOP_TO_BOTTOM))
; enumerations from "./gtkrc.h"
(define-enum GtkRcTokenType
(invalid GTK_RC_TOKEN_INVALID)
(include GTK_RC_TOKEN_INCLUDE)
(normal GTK_RC_TOKEN_NORMAL)
(active GTK_RC_TOKEN_ACTIVE)
(prelight GTK_RC_TOKEN_PRELIGHT)
(selected GTK_RC_TOKEN_SELECTED)
(insensitive GTK_RC_TOKEN_INSENSITIVE)
(fg GTK_RC_TOKEN_FG)
(bg GTK_RC_TOKEN_BG)
(base GTK_RC_TOKEN_BASE)
(text GTK_RC_TOKEN_TEXT)
(font GTK_RC_TOKEN_FONT)
(fontset GTK_RC_TOKEN_FONTSET)
(bg-pixmap GTK_RC_TOKEN_BG_PIXMAP)
(pixmap-path GTK_RC_TOKEN_PIXMAP_PATH)
(style GTK_RC_TOKEN_STYLE)
(binding GTK_RC_TOKEN_BINDING)
(bind GTK_RC_TOKEN_BIND)
(widget GTK_RC_TOKEN_WIDGET)
(widget-class GTK_RC_TOKEN_WIDGET_CLASS)
(class GTK_RC_TOKEN_CLASS)
(lowest GTK_RC_TOKEN_LOWEST)
(gtk GTK_RC_TOKEN_GTK)
(application GTK_RC_TOKEN_APPLICATION)
(rc GTK_RC_TOKEN_RC)
(highest GTK_RC_TOKEN_HIGHEST)
(last GTK_RC_TOKEN_LAST))
; enumerations from "./gtkspinbutton.h"
(define-enum GtkSpinButtonUpdatePolicy
......
......@@ -25,6 +25,7 @@
#include "gtkbindings.h"
#include "gtksignal.h"
#include "gtkwidget.h"
#include "gtkrc.h"
/* --- defines --- */
......@@ -302,10 +303,12 @@ binding_compose_params (GtkBindingArg *args,
valid = FALSE;
break;
case GTK_TYPE_STRING:
if (param_ftype == GTK_TYPE_STRING)
if (args->arg_type == GTK_TYPE_STRING &&
param_ftype == GTK_TYPE_STRING)
GTK_VALUE_STRING (*params) = args->d.string_data;
else if (param_ftype == GTK_TYPE_ENUM ||
param_ftype == GTK_TYPE_FLAGS)
else if (args->arg_type == GTK_TYPE_IDENTIFIER &&
(param_ftype == GTK_TYPE_ENUM ||
param_ftype == GTK_TYPE_FLAGS))
{
/* FIXME: we need identifier lookups here */
valid = FALSE;
......@@ -421,7 +424,7 @@ gtk_binding_set_new (const gchar *set_name)
binding_set->entries = NULL;
binding_set->current = NULL;
binding_set_list = g_slist_prepend (NULL, binding_set);
binding_set_list = g_slist_prepend (binding_set_list, binding_set);
return binding_set;
}
......@@ -790,13 +793,17 @@ binding_match_activate (GSList *pspec_list,
}
static gint
gtk_binding_pattern_compare (gconstpointer a,
gconstpointer b)
gtk_binding_pattern_compare (gconstpointer new_pattern,
gconstpointer existing_pattern)
{
register const GtkPatternSpec *pa = a;
register const GtkPatternSpec *pb = b;
register const GtkPatternSpec *np = new_pattern;
register const GtkPatternSpec *ep = existing_pattern;
return pa->seq_id < pb->seq_id ? -1 : 1;
/* walk the list as long as the existing patterns have
* higher priorities.
*/
return np->seq_id < ep->seq_id;
}
static inline GSList*
......@@ -1169,3 +1176,265 @@ gtk_pattern_spec_free_segs (GtkPatternSpec *pspec)
g_free (pspec->pattern_reversed);
pspec->pattern_reversed = NULL;
}
static guint
gtk_binding_parse_signal (GScanner *scanner,
GtkBindingSet *binding_set,
guint keyval,
guint modifiers)
{
gchar *signal;
guint expected_token = 0;
GSList *args;
GSList *slist;
gboolean done;
gboolean negate;
gboolean need_arg;
gboolean seen_comma;
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 = ')';
g_scanner_get_next_token (scanner);
switch (scanner->token)
{
GtkBindingArg *arg;
case G_TOKEN_FLOAT:
if (need_arg)
{
need_arg = FALSE;
arg = g_new (GtkBindingArg, 1);
arg->arg_type = GTK_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 = GTK_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 = GTK_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 (GTK_FUNDAMENTAL_TYPE (arg->arg_type) == GTK_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;
guint modifiers = 0;
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
g_scanner_get_next_token (scanner);
if (scanner->token != GTK_RC_TOKEN_BIND)
return GTK_RC_TOKEN_BIND;
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;
g_scanner_get_next_token (scanner);
if (scanner->token != '{')
return '{';
gtk_binding_entry_clear (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)
{
gchar *name;
GtkBindingSet *binding_set;
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
g_scanner_get_next_token (scanner);
if (scanner->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);
g_free (name);
g_scanner_peek_next_token (scanner);
while (scanner->next_token != '}')
{
switch (scanner->next_token)
{
guint expected_token;
case GTK_RC_TOKEN_BIND:
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;
}
......@@ -152,6 +152,7 @@ void gtk_binding_entry_add_signall (GtkBindingSet *binding_set,
guint modifiers,
const gchar *signal_name,
GSList *binding_args);
guint gtk_binding_parse_binding (GScanner *scanner);
......
......@@ -94,10 +94,6 @@ static guint gtk_rc_parse_font (GScanner *scanner,
GtkRcStyle *rc_style);
static guint gtk_rc_parse_fontset (GScanner *scanner,
GtkRcStyle *rc_style);
static guint gtk_rc_parse_state (GScanner *scanner,
GtkStateType *state);
static guint gtk_rc_parse_color (GScanner *scanner,
GdkColor *color);
static guint gtk_rc_parse_pixmap_path (GScanner *scanner);
static void gtk_rc_parse_pixmap_path_string (gchar *pix_path);
static char* gtk_rc_find_pixmap_in_path (GScanner *scanner,
......@@ -122,10 +118,8 @@ static GScannerConfig gtk_rc_scanner_config =
) /* cset_identifier_first */,
(
G_CSET_a_2_z
"_0123456789"
"_-0123456789"
G_CSET_A_2_Z
G_CSET_LATINS
G_CSET_LATINC
) /* cset_identifier_nth */,
( "#\n" ) /* cpair_comment_single */,
......@@ -147,33 +141,10 @@ static GScannerConfig gtk_rc_scanner_config =
TRUE /* scan_string_dq */,
TRUE /* numbers_2_int */,
FALSE /* int_2_float */,
TRUE /* identifier_2_string */,
FALSE /* identifier_2_string */,
TRUE /* char_2_token */,
TRUE /* symbol_2_token */,
};
enum {
TOKEN_INVALID = G_TOKEN_LAST,
TOKEN_INCLUDE,
TOKEN_NORMAL,
TOKEN_ACTIVE,
TOKEN_PRELIGHT,
TOKEN_SELECTED,
TOKEN_INSENSITIVE,
TOKEN_FG,
TOKEN_BG,
TOKEN_BASE,
TOKEN_TEXT,
TOKEN_FONT,
TOKEN_FONTSET,
TOKEN_BG_PIXMAP,
TOKEN_PIXMAP_PATH,
TOKEN_STYLE,
TOKEN_BINDING,
TOKEN_WIDGET,
TOKEN_WIDGET_CLASS,
TOKEN_CLASS,
TOKEN_LAST
FALSE /* scope_0_fallback */,
};
static struct
......@@ -181,27 +152,34 @@ static struct
gchar *name;
guint token;
} symbols[] = {
{ "include", TOKEN_INCLUDE },
{ "NORMAL", TOKEN_NORMAL },
{ "ACTIVE", TOKEN_ACTIVE },
{ "PRELIGHT", TOKEN_PRELIGHT },
{ "SELECTED", TOKEN_SELECTED },
{ "INSENSITIVE", TOKEN_INSENSITIVE },
{ "fg", TOKEN_FG },
{ "bg", TOKEN_BG },
{ "base", TOKEN_BASE },
{ "text", TOKEN_TEXT },
{ "font", TOKEN_FONT },
{ "fontset", TOKEN_FONTSET },
{ "bg_pixmap", TOKEN_BG_PIXMAP },
{ "pixmap_path", TOKEN_PIXMAP_PATH },
{ "style", TOKEN_STYLE },
{ "binding", TOKEN_BINDING },
{ "widget", TOKEN_WIDGET },
{ "widget_class", TOKEN_WIDGET_CLASS },
{ "class", TOKEN_CLASS },
{ "include", GTK_RC_TOKEN_INCLUDE },
{ "NORMAL", GTK_RC_TOKEN_NORMAL },
{ "ACTIVE", GTK_RC_TOKEN_ACTIVE },
{ "PRELIGHT", GTK_RC_TOKEN_PRELIGHT },
{ "SELECTED", GTK_RC_TOKEN_SELECTED },
{ "INSENSITIVE", GTK_RC_TOKEN_INSENSITIVE },
{ "fg", GTK_RC_TOKEN_FG },
{ "bg", GTK_RC_TOKEN_BG },
{ "base", GTK_RC_TOKEN_BASE },
{ "text", GTK_RC_TOKEN_TEXT },
{ "font", GTK_RC_TOKEN_FONT },
{ "fontset", GTK_RC_TOKEN_FONTSET },
{ "bg_pixmap", GTK_RC_TOKEN_BG_PIXMAP },
{ "pixmap_path", GTK_RC_TOKEN_PIXMAP_PATH },
{ "style", GTK_RC_TOKEN_STYLE },
{ "binding", GTK_RC_TOKEN_BINDING },
{ "bind", GTK_RC_TOKEN_BIND },
{ "widget", GTK_RC_TOKEN_WIDGET },
{ "widget_class", GTK_RC_TOKEN_WIDGET_CLASS },
{ "class", GTK_RC_TOKEN_CLASS },
{ "lowest", GTK_RC_TOKEN_LOWEST },
{ "gtk", GTK_RC_TOKEN_GTK },
{ "application", GTK_RC_TOKEN_APPLICATION },
{ "rc", GTK_RC_TOKEN_RC },
{ "highest", GTK_RC_TOKEN_HIGHEST },
};
static guint nsymbols = sizeof (symbols) / sizeof (symbols[0]);
static guint n_symbols = sizeof (symbols) / sizeof (symbols[0]);
static GHashTable *rc_style_ht = NULL;
static GSList *gtk_rc_sets_widget = NULL;
......@@ -592,9 +570,9 @@ gtk_rc_parse_any (const gchar *input_name,
g_scanner_input_text (scanner, input_string, strlen (input_string));
}
scanner->input_name = input_name;
g_scanner_freeze_symbol_table (scanner);
for (i = 0; i < nsymbols; i++)
for (i = 0; i < n_symbols; i++)
g_scanner_add_symbol (scanner, symbols[i].name, GINT_TO_POINTER (symbols[i].token));
g_scanner_thaw_symbol_table (scanner);
......@@ -615,25 +593,32 @@ gtk_rc_parse_any (const gchar *input_name,
gchar *msg;
msg = NULL;
if (expected_token > TOKEN_INVALID &&
expected_token < TOKEN_LAST)
{
for (i = 0; i < nsymbols; i++)
if (symbols[i].token == expected_token)
msg = symbols[i].name;
if (msg)
msg = g_strconcat ("e.g. `", msg, "'", NULL);
}
if (scanner->token > TOKEN_INVALID &&
scanner->token < TOKEN_LAST)
symbol_name = NULL;
if (scanner->scope_id == 0)
{
symbol_name = "???";
for (i = 0; i < nsymbols; i++)
if (symbols[i].token == scanner->token)
symbol_name = symbols[i].name;
/* if we are in scope 0, we know the symbol names
* that are associated with certaintoken values.
* so we look them up to make the error messages
* more readable.
*/
if (expected_token > GTK_RC_TOKEN_INVALID &&
expected_token < GTK_RC_TOKEN_LAST)
{
for (i = 0; i < n_symbols; i++)
if (symbols[i].token == expected_token)
msg = symbols[i].name;
if (msg)
msg = g_strconcat ("e.g. `", msg, "'", NULL);
}
if (scanner->token > GTK_RC_TOKEN_INVALID &&
scanner->token < GTK_RC_TOKEN_LAST)
{
symbol_name = "???";
for (i = 0; i < n_symbols; i++)
if (symbols[i].token == scanner->token)