From 4e0919b24899459c0ecd5ffcff555c9a95939bd4 Mon Sep 17 00:00:00 2001 From: Pascal Niklaus Date: Tue, 2 Apr 2024 12:59:10 +0200 Subject: [PATCH] README, config, main, callbacks: added tool options -A, -T, moved comment in config.h, free default colors when exiting, add missing snap minlen maxangle simplify to callbacks --- README.md | 4 ++-- src/callbacks.c | 22 +++++++++++++++++++++- src/config.h | 2 +- src/main.c | 3 +++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 24d6957..071d8ef 100644 --- a/README.md +++ b/README.md @@ -98,11 +98,11 @@ Usage: gromit-mpx --redo will redo the last undone drawing stroke (or "-y") gromit-mpx --change-tool - will redefine a tool, using the same syntax as in the .cfg file + will redefine a tool, using the same syntax as in the .cfg file (or "-T") e.g. gromit-mpx --change-tool '"default"=RECT(color="yellow" size=2)' gromit-mpx --change-attribute will change one or several attributes of a tool, keeping the others - as they were. This can be used to change e.g. to color or type of a tool + as they were. This can be used to change e.g. to color or type of a tool (or "-A") e.g. gromit-mpx --change-attribute '"default"=(color="cyan")' gromit-mpx --change-attribute '"default"=LINE' gromit-mpx --line diff --git a/src/callbacks.c b/src/callbacks.c index cf792f4..a4796d9 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -759,6 +759,21 @@ void on_mainapp_selection_received (GtkWidget *widget, case SYM_MAXSIZE: context->maxwidth = style.maxwidth; break; + case SYM_MINLEN: + context->minlen = style.minlen; + break; + case SYM_MAXANGLE: + context->maxangle = style.maxangle; + break; + case SYM_RADIUS: + context->radius = style.radius; + break; + case SYM_SIMPLIFY: + context->simplify = style.simplify; + break; + case SYM_SNAP: + context->snapdist = style.snapdist; + break; case SYM_ERROR: break; } @@ -776,12 +791,17 @@ void on_mainapp_selection_received (GtkWidget *widget, if (g_scanner_cur_token(scanner) != G_TOKEN_EOF) goto cleanup; context->type = style.type; - *context->paint_color = *style.paint_color; context->width = style.width; context->arrowsize = style.arrowsize; context->arrow_type = style.arrow_type; context->minwidth = style.minwidth; context->maxwidth = style.maxwidth; + context->radius = style.radius; + context->minlen = style.minlen; + context->maxangle = style.maxangle; + context->simplify = style.simplify; + context->snapdist = style.snapdist; + *context->paint_color = *style.paint_color; cairo_set_source_rgba(context->paint_ctx, style.paint_color->red, diff --git a/src/config.h b/src/config.h index 306ec98..c3a2bb2 100644 --- a/src/config.h +++ b/src/config.h @@ -33,6 +33,7 @@ Select and parse system or user .cfg file. Returns TRUE if something got parsed successfully, FALSE otherwise. */ +gboolean parse_config (GromitData *data); typedef enum { SYM_ERROR = 0, @@ -51,7 +52,6 @@ typedef enum { void scanner_init(GScanner *scanner); gboolean parse_tool(GromitData *data, GScanner *scanner, GromitPaintContext *style); -gboolean parse_config (GromitData *data); gchar* parse_name (GScanner *scanner); gfloat parse_get_float(GScanner *scanner, const gchar *msg); gboolean parse_style(GScanner *scanner, GromitPaintContext *style); diff --git a/src/main.c b/src/main.c index 251537a..4b2a667 100644 --- a/src/main.c +++ b/src/main.c @@ -1293,6 +1293,9 @@ int main (int argc, char **argv) gtk_main (); shutdown_input_devices(data); write_keyfile(data); // save keyfile config + g_free(data->red); + g_free(data->white); + g_free(data->black); g_free (data); return 0; }