[gromit: 3/13] Import of gromit history
- From: Simon Budig <simon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gromit: 3/13] Import of gromit history
- Date: Tue, 16 Mar 2010 22:23:42 +0000 (UTC)
commit 57909c66b36a52e9f3883b9765d8ed4fb695e4d8
Author: Simon Budig <simon budig de>
Date: Mon Oct 30 12:00:00 2000 +0100
Import of gromit history
gromit.c | 414 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------
gromitconf | 22 ++--
parser.c | 109 ++++++++--------
3 files changed, 439 insertions(+), 106 deletions(-)
---
diff --git a/gromit.c b/gromit.c
index 9c177ea..49fe03f 100644
--- a/gromit.c
+++ b/gromit.c
@@ -21,6 +21,8 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
+#include <fcntl.h>
+
#include "paint_cursor.xbm"
#include "paint_cursor_mask.xbm"
@@ -70,9 +72,12 @@ typedef struct
GdkColor *red;
GdkColor *blue;
- GromitPaintContext *contexts[6];
+ GromitPaintContext *default_pen;
+ GromitPaintContext *default_eraser;
GromitPaintContext *cur_context;
+ GHashTable *tool_config;
+
GdkBitmap *shape;
GdkGC *shape_gc;
GdkGCValues *shape_gcv;
@@ -95,8 +100,7 @@ typedef struct
GromitPaintContext *
-gromit_paint_context_new (GdkDrawable *pixmap,
- GdkDrawable *shape, GromitPaintType type,
+gromit_paint_context_new (GromitData *data, GromitPaintType type,
GdkColor *fg_color, guint width)
{
GromitPaintContext *context;
@@ -112,7 +116,7 @@ gromit_paint_context_new (GdkDrawable *pixmap,
context->paint_gc = NULL;
else {
/* GROMIT_PEN || GROMIT_RECOLOR */
- context->paint_gc = gdk_gc_new (pixmap);
+ context->paint_gc = gdk_gc_new (data->pixmap);
gdk_gc_set_foreground (context->paint_gc, fg_color);
gdk_gc_set_line_attributes (context->paint_gc, width, GDK_LINE_SOLID,
GDK_CAP_ROUND, GDK_JOIN_ROUND);
@@ -122,7 +126,7 @@ gromit_paint_context_new (GdkDrawable *pixmap,
context->shape_gc = NULL;
else {
/* GROMIT_PEN || GROMIT_ERASER */
- context->shape_gc = gdk_gc_new (shape);
+ context->shape_gc = gdk_gc_new (data->shape);
gdk_gc_get_values (context->shape_gc, &shape_gcv);
if (type == GROMIT_ERASER)
@@ -139,6 +143,27 @@ gromit_paint_context_new (GdkDrawable *pixmap,
void
+gromit_paint_context_print (gchar *name, GromitPaintContext *context)
+{
+ g_printerr ("Tool name: \"%-20s\": ", name);
+ switch (context->type)
+ {
+ case GROMIT_PEN:
+ g_printerr ("Pen, "); break;
+ case GROMIT_ERASER:
+ g_printerr ("Eraser, "); break;
+ case GROMIT_RECOLOR:
+ g_printerr ("Recolor, "); break;
+ default:
+ g_printerr ("UNKNOWN, "); break;
+ };
+ g_printerr ("width: %2d, ", context->width);
+ g_printerr ("color: #%02X%02X%02X\n", context->fg_color->red >> 8,
+ context->fg_color->green >> 8, context->fg_color->blue >> 8);
+}
+
+
+void
gromit_paint_context_free (GromitPaintContext *context)
{
gdk_gc_unref (context->paint_gc);
@@ -224,6 +249,74 @@ reshape (gpointer user_data)
void
+gromit_select_tool (GromitData *data, guint32 deviceid, guint state)
+{
+ GList *dev_list;
+ GdkDeviceInfo *info = NULL;
+ guint buttons = 0, modifier = 0, len = 0;
+ guint req_buttons = 0, req_modifier = 0;
+ guint i, j, success = 0;
+ GromitPaintContext *context = NULL;
+ guchar *name;
+
+ dev_list = gdk_input_list_devices ();
+ while (dev_list)
+ {
+ if (((GdkDeviceInfo *) dev_list->data)->deviceid == deviceid) {
+ info = (GdkDeviceInfo *) dev_list->data;
+ break;
+ }
+ dev_list = dev_list->next;
+ }
+
+ if (info) {
+ len = strlen (info->name);
+ name = g_strndup (info->name, len + 3);
+
+ /* Extract Button/Modifiers from state (see GdkModifierType) */
+ req_buttons = (state >> 8) & 31;
+
+ if (state & GDK_SHIFT_MASK) state |= GDK_LOCK_MASK;
+ req_modifier = (state >> 1) & 7;
+
+ name [len] = 124;
+ name [len+3] = 0;
+
+ /* 0, 1, 3, 7, 15, 31 */
+ context = NULL;
+ i=-1;
+ do {
+ i++;
+ buttons = req_buttons & ((1 << i)-1);
+ j=-1;
+ do {
+ j++;
+ modifier = req_modifier & ((1 << j)-1);
+ name [len+1] = buttons + 64;
+ name [len+2] = modifier + 48;
+ context = g_hash_table_lookup (data->tool_config, name);
+ if (context) {
+ data->cur_context = context;
+ success = 1;
+ }
+ } while (j<=3 && req_modifier >= (1 << j));
+ } while (i<=5 && req_buttons >= (1 << i));
+
+ g_free (name);
+ } else
+ g_printerr ("ERROR: Attempt to select nonexistent device!\n");
+
+ if (!success) {
+ if (info->source == GDK_SOURCE_ERASER)
+ data->cur_context = data->default_eraser;
+ else
+ data->cur_context = data->default_pen;
+ }
+}
+
+
+
+void
gromit_draw_line (GromitData *data, gint x1, gint y1,
gint x2, gint y2)
{
@@ -268,21 +361,10 @@ paint (GtkWidget *win, GdkEventButton *ev, gpointer user_data)
{
GromitData *data = (GromitData *) user_data;
- g_printerr ("Source: %d\n", ev->source);
- switch (ev->source) {
- case GDK_SOURCE_MOUSE:
- case GDK_SOURCE_CURSOR:
- data->cur_context = data->contexts[1];
- break;
- case GDK_SOURCE_PEN:
- data->cur_context = data->contexts[0];
- break;
- case GDK_SOURCE_ERASER:
- data->cur_context = data->contexts[4];
- break;
- default:
- data->cur_context = data->contexts[0];
- }
+ /* See GdkModifierType. Am I fixing a Gtk misbehaviour??? */
+ ev->state |= 1 << (ev->button + 7);
+
+ gromit_select_tool (data, ev->deviceid, ev->state);
gdk_window_set_background (data->area->window,
data->cur_context->fg_color);
@@ -297,7 +379,7 @@ paint (GtkWidget *win, GdkEventButton *ev, gpointer user_data)
data->maxwidth = (CLAMP (ev->pressure * ev->pressure,0,1) *
(double) data->cur_context->width);
- if (ev->button <= 3)
+ if (ev->button <= 5)
gromit_draw_line (data, ev->x, ev->y, ev->x, ev->y);
/* if (data->cur_context->shape_gc && !gtk_events_pending ())
@@ -317,7 +399,7 @@ paintto (GtkWidget *win, GdkEventMotion *ev, gpointer user_data)
coords = gdk_input_motion_events (ev->window, ev->deviceid,
data->motion_time, ev->time, &nevents);
- // g_printerr ("Got %d coords\n", nevents);
+ /* g_printerr ("Got %d coords\n", nevents); */
if (coords)
{
for (i=0; i<nevents; i++) {
@@ -456,6 +538,256 @@ event_selection_received (GtkWidget *widget,
/*
+ * Functions for parsing the Configuration-file
+ */
+
+gchar *parse_name (GScanner *scanner) {
+ GTokenType token;
+
+ guint buttons = 0;
+ guint modifier = 0;
+ guint len = 0;
+ gchar *name;
+
+ token = g_scanner_cur_token(scanner);
+
+ if (token != G_TOKEN_STRING) {
+ g_scanner_unexp_token (scanner, G_TOKEN_STRING, NULL,
+ NULL, NULL, "aborting", TRUE);
+ exit (1);
+ }
+
+ len = strlen (scanner->value.v_string);
+ name = g_strndup (scanner->value.v_string, len + 3);
+
+ token = g_scanner_get_next_token (scanner);
+
+ /*
+ * Are there any options to limit the scope of the definition?
+ */
+
+ if (token == G_TOKEN_LEFT_BRACE) {
+ g_scanner_set_scope (scanner, 1);
+ scanner->config->int_2_float = 0;
+ modifier = buttons = 0;
+ while ((token = g_scanner_get_next_token (scanner))
+ != G_TOKEN_RIGHT_BRACE) {
+ if (token == G_TOKEN_SYMBOL) {
+ if ((guint) scanner->value.v_symbol < 11)
+ buttons |= 1 << ((guint) scanner->value.v_symbol - 1);
+ else
+ modifier |= 1 << ((guint) scanner->value.v_symbol - 11);
+ } else if (token == G_TOKEN_INT) {
+ if (scanner->value.v_int <= 5 && scanner->value.v_int > 0) {
+ buttons |= 1 << (scanner->value.v_int - 1);
+ } else {
+ g_printerr ("Only Buttons 1-5 are supported!\n");
+ }
+ } else {
+ g_printerr ("skipped token\n");
+ }
+ }
+ g_scanner_set_scope (scanner, 0);
+ scanner->config->int_2_float = 1;
+ token = g_scanner_get_next_token (scanner);
+ }
+
+ name [len] = 124;
+ name [len+1] = buttons + 64;
+ name [len+2] = modifier + 48;
+ name [len+3] = 0;
+
+ return name;
+}
+
+void
+parse_print_help (gpointer key, gpointer value, gpointer user_data)
+{
+ gromit_paint_context_print ((gchar *) key, (GromitPaintContext *) value);
+}
+
+gint parse_config (GromitData *data) {
+
+ GromitPaintContext *context=NULL;
+ GromitPaintContext *context_template=NULL;
+ GScanner *scanner;
+ GTokenType token;
+ int file;
+
+ gchar *name, *copy;
+
+ GromitPaintType type;
+ GdkColor *fg_color=NULL;
+ guint width;
+
+ guint buttons, modifier;
+
+ scanner = g_scanner_new (NULL);
+ scanner->config->case_sensitive = 0;
+ scanner->config->scan_octal = 0;
+ scanner->config->identifier_2_string = 0;
+ scanner->config->char_2_token = 1;
+ scanner->config->numbers_2_int = 1;
+ scanner->config->int_2_float = 1;
+
+ g_scanner_scope_add_symbol (scanner, 0, "PEN", (gpointer) GROMIT_PEN);
+ g_scanner_scope_add_symbol (scanner, 0, "ERASER", (gpointer) GROMIT_ERASER);
+ g_scanner_scope_add_symbol (scanner, 0, "RECOLOR",(gpointer) GROMIT_RECOLOR);
+
+ g_scanner_scope_add_symbol (scanner, 1, "BUTTON1",(gpointer) 1);
+ g_scanner_scope_add_symbol (scanner, 1, "BUTTON2",(gpointer) 2);
+ g_scanner_scope_add_symbol (scanner, 1, "BUTTON3",(gpointer) 3);
+ g_scanner_scope_add_symbol (scanner, 1, "BUTTON4",(gpointer) 4);
+ g_scanner_scope_add_symbol (scanner, 1, "BUTTON5",(gpointer) 5);
+ g_scanner_scope_add_symbol (scanner, 1, "SHIFT", (gpointer) 11);
+ g_scanner_scope_add_symbol (scanner, 1, "CONTROL",(gpointer) 12);
+ g_scanner_scope_add_symbol (scanner, 1, "META", (gpointer) 13);
+ g_scanner_scope_add_symbol (scanner, 1, "ALT", (gpointer) 13);
+
+ g_scanner_scope_add_symbol (scanner, 2, "size", (gpointer) 1);
+ g_scanner_scope_add_symbol (scanner, 2, "color", (gpointer) 2);
+
+ g_scanner_set_scope (scanner, 0);
+ scanner->config->scope_0_fallback = 0;
+
+ file = open ("./gromitconf", O_RDONLY);
+ g_scanner_input_file (scanner, file);
+
+ token = g_scanner_get_next_token (scanner);
+ while (token != G_TOKEN_EOF) {
+
+ /*
+ * New tool definition
+ */
+
+ if (token == G_TOKEN_STRING) {
+ name = parse_name (scanner);
+ token = g_scanner_cur_token(scanner);
+
+ if (token != G_TOKEN_EQUAL_SIGN) {
+ g_scanner_unexp_token (scanner, G_TOKEN_EQUAL_SIGN, NULL,
+ NULL, NULL, "aborting", TRUE);
+ exit (1);
+ }
+
+ token = g_scanner_get_next_token (scanner);
+
+ /* defaults */
+
+ type = GROMIT_PEN;
+ width = 7;
+ fg_color = data->red;
+
+ if (token == G_TOKEN_SYMBOL) {
+ type = (GromitPaintType) scanner->value.v_symbol;
+ token = g_scanner_get_next_token (scanner);
+ } else if (token == G_TOKEN_STRING) {
+ copy = parse_name (scanner);
+ token = g_scanner_cur_token(scanner);
+ context_template = g_hash_table_lookup (data->tool_config, copy);
+ if (context_template) {
+ type = context_template->type;
+ width = context_template->width;
+ fg_color = context_template->fg_color;
+ } else {
+ g_printerr ("WARNING: Unable to copy \"%s\": not yet defined!\n", copy);
+ }
+ } else {
+ g_printerr ("Expected Tool-definition or name of template tool\n");
+ exit (1);
+ }
+
+ /* Are there any tool-options?
+ */
+
+ if (token == G_TOKEN_LEFT_PAREN) {
+ GdkColor *color = NULL;
+ g_scanner_set_scope (scanner, 2);
+ scanner->config->int_2_float = 1;
+ token = g_scanner_get_next_token (scanner);
+ while (token != G_TOKEN_RIGHT_PAREN) {
+ if (token == G_TOKEN_SYMBOL) {
+ if ((guint) scanner->value.v_symbol == 1) {
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN) {
+ g_printerr ("Missing \"=\"... aborting\n");
+ exit (1);
+ }
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_FLOAT) {
+ g_printerr ("Missing Size (float)... aborting\n");
+ exit (1);
+ }
+ width = (guint) (scanner->value.v_float + 0.5);
+ } else if ((guint) scanner->value.v_symbol == 2) {
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN) {
+ g_printerr ("Missing \"=\"... aborting\n");
+ exit (1);
+ }
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_STRING) {
+ g_printerr ("Missing Color (string)... aborting\n");
+ exit (1);
+ }
+ color = g_malloc (sizeof (GdkColor));
+ if (gdk_color_parse (scanner->value.v_string, color)) {
+ if (gdk_colormap_alloc_color (data->cm, color, 0, 1)) {
+ fg_color = color;
+ } else {
+ g_printerr ("Unable to allocate color. Keeping default!\n");
+ g_free (color);
+ }
+ } else {
+ g_printerr ("Unable to parse color. Keeping default.\n");
+ g_free (color);
+ }
+ color = NULL;
+
+ } else {
+ g_printerr ("Unknown tool type?????\n");
+ }
+ } else {
+ g_printerr ("skipped token!!!\n");
+ }
+ token = g_scanner_get_next_token (scanner);
+ }
+ g_scanner_set_scope (scanner, 0);
+ token = g_scanner_get_next_token (scanner);
+ }
+
+ /*
+ * Finally we expect a semicolon
+ */
+
+ if (token != ';') {
+ g_printerr ("Expected \";\"\n");
+ exit (1);
+ }
+
+ context = gromit_paint_context_new (data, type, fg_color, width);
+ g_hash_table_insert (data->tool_config, name, context);
+
+ } else {
+ g_printerr ("Expected name of Tool to define\n");
+ exit(1);
+ }
+
+ token = g_scanner_get_next_token (scanner);
+
+ }
+ g_scanner_destroy (scanner);
+ close (file);
+
+ g_printerr ("\n-----------------------------\n");
+ g_hash_table_foreach (data->tool_config, parse_print_help, NULL);
+ g_printerr ("-----------------------------\n\n");
+}
+
+
+
+
+/*
* Functions for setting up (parts of) the application
*/
@@ -470,9 +802,14 @@ setup_input_devices ()
GdkDeviceInfo *info = (GdkDeviceInfo *) tmp_list->data;
if (strstr (info->name, "raser")) /* Guess "Eraser"-Type devices */
gdk_input_set_source (info->deviceid, GDK_SOURCE_ERASER);
+
g_printerr ("Enabling No. %d: \"%s\" (Type: %d)\n",
info->deviceid, info->name, info->source);
- gdk_input_set_mode (info->deviceid, GDK_MODE_SCREEN);
+
+ if (! strstr (info->name, "SWITCH"))
+ /* Dont touch the "SWITCH"-Device - this seems to confuse Gtk+ */
+ gdk_input_set_mode (info->deviceid, GDK_MODE_SCREEN);
+
tmp_list = tmp_list->next;
}
}
@@ -516,13 +853,10 @@ setup_main_app (GromitData *data)
data->white = g_malloc (sizeof (GdkColor));
data->black = g_malloc (sizeof (GdkColor));
data->red = g_malloc (sizeof (GdkColor));
- data->blue = g_malloc (sizeof (GdkColor));
gdk_color_white (data->cm, data->white);
gdk_color_black (data->cm, data->black);
gdk_color_parse ("#FF0000", data->red);
gdk_colormap_alloc_color (data->cm, data->red, 0, 1);
- gdk_color_parse ("#2266FF", data->blue);
- gdk_colormap_alloc_color (data->cm, data->blue, 0, 1);
/* CURSORS */
cursor_src = gdk_bitmap_create_from_data (NULL, paint_cursor_bits,
@@ -573,23 +907,17 @@ setup_main_app (GromitData *data)
data->timeout_id = gtk_timeout_add (20, reshape, data);
data->modified = 0;
- data->contexts[0] = gromit_paint_context_new (data->pixmap, data->shape,
- GROMIT_PEN, data->red, 7);
- data->contexts[1] = gromit_paint_context_new (data->pixmap, data->shape,
- GROMIT_PEN, data->blue, 7);
- data->contexts[2] = gromit_paint_context_new (data->pixmap, data->shape,
- GROMIT_RECOLOR, data->red,
- 10);
- data->contexts[3] = gromit_paint_context_new (data->pixmap, data->shape,
- GROMIT_RECOLOR, data->blue,
- 10);
- data->contexts[4] = gromit_paint_context_new (data->pixmap, data->shape,
- GROMIT_ERASER, data->white,
- 150);
- data->contexts[5] = gromit_paint_context_new (data->pixmap, data->shape,
- GROMIT_ERASER, data->white,
- 50);
+ data->default_pen = gromit_paint_context_new (data, GROMIT_PEN, data->red, 7);
+ data->default_eraser = gromit_paint_context_new (data, GROMIT_ERASER, data->red, 75);
+
+ /*
+ * Parse Config file
+ */
+ data->tool_config = g_hash_table_new (g_str_hash, g_str_equal);
+ parse_config (data);
+
+
gtk_key_snooper_install ((GtkKeySnoopFunc) event_key_snoop, NULL);
gtk_selection_owner_set (data->win, GA_CONTROL, GDK_CURRENT_TIME);
@@ -646,8 +974,8 @@ main (int argc, char **argv)
{
GromitData *data;
- data = g_malloc (sizeof (GromitData));
gtk_init (&argc, &argv);
+ data = g_malloc (sizeof (GromitData));
/* g_set_printerr_handler (quiet_print_handler); */
diff --git a/gromitconf b/gromitconf
index d1b4cc8..b559781 100644
--- a/gromitconf
+++ b/gromitconf
@@ -2,14 +2,20 @@
# Tools
-"roter Stift" = PEN ( size = 12, color = "red" ) ;
-"Radierer" = Eraser ( size = 50 ) ;
+"roter Stift" = PEN (size=12 color="red");
+"blauer Stift" = "roter Stift" (color="blue");
+"gelber Stift" = "roter Stift" (color="yellow");
+"rosa Stift" = "roter Stift" (color="#ff00aa");
+"Radierer" = ERASER (size = 75);
+"grüner Marker" = RECOLOR (color = "Limegreen");
-"Pen1" = "roter Stift";
-"Pen1"[SHIFT,CONTROL] = "Radierer";
-"Pen1"[BUTTON1 3 SHIFT CONTROL] = PEN ( SIZE=30, color="red" );
-"Eraser" = ERASER ( color="#0000ff", siZE=50 );
-"Recolor" = REcolor ( coLOr="#0000ff", SIZE=50 );
-# "Mouse" = NULL
+# Mapping to Pointing devices
+
+"Core Pointer" = "roter Stift";
+"Core Pointer"[SHIFT] = "blauer Stift";
+"Core Pointer"[CONTROL] = "gelber Stift";
+"Core Pointer"[META] = "rosa Stift";
+"Core Pointer"[2] = "grüner Marker";
+"Core Pointer"[3] = "Radierer";
diff --git a/parser.c b/parser.c
index 6fd3596..66617da 100644
--- a/parser.c
+++ b/parser.c
@@ -137,71 +137,70 @@ gint parse (void) {
token = g_scanner_get_next_token (scanner);
if (token == G_TOKEN_SYMBOL) {
- printf ("Tool Type: %d\n", scanner->value.v_symbol);
-
+ printf ("New Tool: Type: %d\n", scanner->value.v_symbol);
token = g_scanner_get_next_token (scanner);
+ } else if (token == G_TOKEN_STRING) {
+ copy = parse_name (scanner);
+ token = g_scanner_cur_token(scanner);
+ printf ("Copying Config:\"%s\" from \"%s\"\n", name, copy);
+ } else {
+ printf ("Expected Tool-definition or name of template tool\n");
+ exit (1);
+ }
- /* Are there any tool-options?
- */
+ /* Are there any tool-options?
+ */
- if (token == G_TOKEN_LEFT_PAREN) {
- /* printf ("Extra tool options\n");
- */
- if (color)
- g_free (color);
- color = NULL;
- size = 0;
- g_scanner_set_scope (scanner, 2);
- scanner->config->int_2_float = 1;
- token = g_scanner_get_next_token (scanner);
- while (token != G_TOKEN_RIGHT_PAREN) {
- if (token == G_TOKEN_SYMBOL) {
- if ((guint) scanner->value.v_symbol == 1) {
- token = g_scanner_get_next_token (scanner);
- if (token != G_TOKEN_EQUAL_SIGN) {
- printf ("Missing \"=\"... aborting\n");
- exit (1);
- }
- token = g_scanner_get_next_token (scanner);
- if (token != G_TOKEN_FLOAT) {
- printf ("Missing Size (float)... aborting\n");
- exit (1);
- }
- size = scanner->value.v_float;
- } else if ((guint) scanner->value.v_symbol == 2) {
- token = g_scanner_get_next_token (scanner);
- if (token != G_TOKEN_EQUAL_SIGN) {
- printf ("Missing \"=\"... aborting\n");
- exit (1);
- }
- token = g_scanner_get_next_token (scanner);
- if (token != G_TOKEN_STRING) {
- printf ("Missing Color (string)... aborting\n");
- exit (1);
- }
- if (color != NULL)
- g_free (color);
- color = g_strdup (scanner->value.v_string);
- } else {
- printf ("Unknown tool type?????\n");
+ if (token == G_TOKEN_LEFT_PAREN) {
+ /* printf ("Extra tool options\n");
+ */
+ if (color)
+ g_free (color);
+ color = NULL;
+ size = 0;
+ g_scanner_set_scope (scanner, 2);
+ scanner->config->int_2_float = 1;
+ token = g_scanner_get_next_token (scanner);
+ while (token != G_TOKEN_RIGHT_PAREN) {
+ if (token == G_TOKEN_SYMBOL) {
+ if ((guint) scanner->value.v_symbol == 1) {
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN) {
+ printf ("Missing \"=\"... aborting\n");
+ exit (1);
+ }
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_FLOAT) {
+ printf ("Missing Size (float)... aborting\n");
+ exit (1);
+ }
+ size = scanner->value.v_float;
+ } else if ((guint) scanner->value.v_symbol == 2) {
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN) {
+ printf ("Missing \"=\"... aborting\n");
+ exit (1);
+ }
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_STRING) {
+ printf ("Missing Color (string)... aborting\n");
+ exit (1);
}
+ if (color != NULL)
+ g_free (color);
+ color = g_strdup (scanner->value.v_string);
} else {
- printf ("skipped token!!!\n");
+ printf ("Unknown tool type?????\n");
}
- token = g_scanner_get_next_token (scanner);
+ } else {
+ printf ("skipped token!!!\n");
}
- g_scanner_set_scope (scanner, 0);
token = g_scanner_get_next_token (scanner);
}
- printf ("Size: %.2f ; Color \"%s\"\n", size, color);
- } else if (token == G_TOKEN_STRING) {
- copy = parse_name (scanner);
- token = g_scanner_cur_token(scanner);
- printf ("\"%s\" gets config from \"%s\"\n", name, copy);
- } else {
- printf ("Expected either Tool-definition or name of template tool\n");
- exit (1);
+ g_scanner_set_scope (scanner, 0);
+ token = g_scanner_get_next_token (scanner);
}
+ printf ("Size: %.2f ; Color \"%s\"\n", size, color);
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]