Skip to content

Commit

Permalink
README, config, main, callbacks: added tool options -A, -T, moved com…
Browse files Browse the repository at this point in the history
…ment in config.h, free default colors when exiting, add missing snap minlen maxangle simplify to callbacks
  • Loading branch information
pascal-niklaus committed Apr 2, 2024
1 parent 048ec6a commit 4e0919b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ Usage:
gromit-mpx --redo
will redo the last undone drawing stroke (or "-y")
gromit-mpx --change-tool <definition>
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 <definition>
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 <startX> <startY> <endX> <endY> <color> <thickness>
Expand Down
22 changes: 21 additions & 1 deletion src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4e0919b

Please sign in to comment.