Skip to content

Commit 048ec6a

Browse files
parser.[ch] removed from CMakeLists.txt
1 parent 074531a commit 048ec6a

11 files changed

+67
-384
lines changed

CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ set(sources
5555
src/callbacks.h
5656
src/config.c
5757
src/config.h
58-
src/parser.c
59-
src/parser.h
6058
src/drawing.c
6159
src/drawing.h
6260
src/coordlist_ops.c

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,17 @@ Usage:
9797
will undo the last drawing stroke (or "-z")
9898
gromit-mpx --redo
9999
will redo the last undone drawing stroke (or "-y")
100+
gromit-mpx --change-tool <definition>
101+
will redefine a tool, using the same syntax as in the .cfg file
102+
e.g. gromit-mpx --change-tool '"default"=RECT(color="yellow" size=2)'
103+
gromit-mpx --change-attribute <definition>
104+
will change one or several attributes of a tool, keeping the others
105+
as they were. This can be used to change e.g. to color or type of a tool
106+
e.g. gromit-mpx --change-attribute '"default"=(color="cyan")'
107+
gromit-mpx --change-attribute '"default"=LINE'
100108
gromit-mpx --line <startX> <startY> <endX> <endY> <color> <thickness>
101109
will draw a straight line with characteristics specified by the arguments (or "-l")
102-
eg: gromit-mpx -l 200 200 400 400 '#C4A7E7' 6
110+
e.g.: gromit-mpx -l 200 200 400 400 '#C4A7E7' 6
103111

104112
If activated Gromit-MPX prevents you from using other programs with the
105113
mouse. You can press the button and paint on the screen. Key presses

gromit-mpx.1

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" Hey, vim: ft=nroff
2-
.TH GROMIT-MPX 1 "November 3, 2018"
2+
.TH GROMIT-MPX 1 "March 31, 2024"
33
.\" Please adjust this date whenever revising the manpage.
44
.\"
55
.\" Some roff macros, for reference:
@@ -95,9 +95,6 @@ running Gromit-MPX process, see above for the options available to start Gromit-
9595
.B \-c, \-\-clear
9696
will clear the screen.
9797
.TP
98-
.B \-l <x1> <y1> <x2> <y2> <color> <width>, \-\-line <x1> <y1> <x2> <y2> <color> <width>
99-
will draw a line from (x1,y1) to (x2,y2) with color <color> and width <width>.
100-
.TP
10198
.B \-q, \-\-quit
10299
will cause the main Gromit-MPX process to quit.
103100
.TP
@@ -107,6 +104,12 @@ will toggle the grabbing of the cursor.
107104
.B \-T <definition>, \-\-change-tool <definition>
108105
will change the definition of a tool. The syntax is as in the .cfg file
109106
read at startup, except for the trailing semicolon.
107+
(example: gromit-mpx -T '"default"=RECT(color="yellow" size=2)'
108+
.TP
109+
.B \-A <definition>, \-\-change-attribute <definition>
110+
will change one or several attributes of a tool, keeping the other settings.
111+
(example 1: change just the color: gromit-mpx -A '"default"=(color="yellow")';
112+
example 2: change tool type, keeping color, size etc: gromit-mpx -A '"default"=LINE')
110113
.TP
111114
.B \-v, \-\-visibility
112115
will toggle the visibility of the window.

src/callbacks.c

+7-46
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <stdlib.h>
2626
#include <stdint.h>
2727
#include <math.h>
28-
#include "cairo.h"
2928
#include "main.h"
3029
#include "input.h"
3130
#include "callbacks.h"
@@ -142,18 +141,10 @@ void on_monitors_changed ( GdkScreen *screen,
142141

143142
parse_config(data); // also calls paint_context_new() :-(
144143

145-
146-
<<<<<<< HEAD
147-
data->default_pen = paint_context_new (data, GROMIT_PEN, data->red, 7, 0, GROMIT_ARROW_END,
144+
data->default_pen = paint_context_new (data, GROMIT_PEN, gdk_rgba_copy(data->red), 7, 0, GROMIT_ARROW_END,
148145
5, 10, 15, 25, 1, 0, G_MAXUINT);
149-
data->default_eraser = paint_context_new (data, GROMIT_ERASER, data->red, 75, 0, GROMIT_ARROW_END,
146+
data->default_eraser = paint_context_new (data, GROMIT_ERASER, gdk_rgba_copy(data->red), 75, 0, GROMIT_ARROW_END,
150147
5, 10, 15, 25, 1, 0, G_MAXUINT);
151-
=======
152-
data->default_pen = paint_context_new (data, GROMIT_PEN, gdk_rgba_copy(data->red), 7,
153-
0, GROMIT_ARROW_END, 1, G_MAXUINT);
154-
data->default_eraser = paint_context_new (data, GROMIT_ERASER, gdk_rgba_copy(data->red), 75,
155-
0, GROMIT_ARROW_END, 1, G_MAXUINT);
156-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
157148

158149
if(!data->composited) // set shape
159150
{
@@ -221,7 +212,7 @@ void on_clientapp_selection_get (GtkWidget *widget,
221212

222213
if (gtk_selection_data_get_target(selection_data) == GA_TOGGLEDATA ||
223214
gtk_selection_data_get_target(selection_data) == GA_LINEDATA ||
224-
gtk_selection_data_get_target(selection_data) == GA_DEFTOOLDATA ||
215+
gtk_selection_data_get_target(selection_data) == GA_CHGTOOLDATA ||
225216
gtk_selection_data_get_target(selection_data) == GA_CHGATTRDATA)
226217
{
227218
ans = data->clientdata;
@@ -292,11 +283,7 @@ gboolean on_buttonpress (GtkWidget *win,
292283
GromitPaintType type = devdata->cur_context->type;
293284

294285
// store original state to have dynamic update of line and rect
295-
<<<<<<< HEAD
296286
if (type == GROMIT_LINE || type == GROMIT_RECT || type == GROMIT_SMOOTH || type == GROMIT_ORTHOGONAL)
297-
=======
298-
if (type == GROMIT_LINE || type == GROMIT_RECT)
299-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
300287
{
301288
copy_surface(data->aux_backbuffer, data->backbuffer);
302289
}
@@ -413,12 +400,8 @@ gboolean on_motion (GtkWidget *win,
413400
}
414401
if (type == GROMIT_LINE)
415402
{
416-
<<<<<<< HEAD
417-
GromitArrowType atype = devdata->cur_context->arrow_type;
418-
=======
419-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
420403
draw_line (data, ev->device, devdata->lastx, devdata->lasty, ev->x, ev->y);
421-
if (devdata->cur_context->arrowsize > 0)
404+
if (devdata->cur_context->arrowsize > 0.0)
422405
{
423406
GromitArrowType atype = devdata->cur_context->arrow_type;
424407
gint width = devdata->cur_context->arrowsize * devdata->cur_context->width / 2;
@@ -467,14 +450,8 @@ gboolean on_buttonrelease (GtkWidget *win,
467450

468451
gfloat direction = 0;
469452
gint width = 0;
470-
<<<<<<< HEAD
471453
if(ctx)
472454
width = ctx->arrowsize * ctx->width / 2;
473-
=======
474-
if(devdata->cur_context)
475-
width = devdata->cur_context->arrowsize * devdata->cur_context->width / 2;
476-
477-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
478455

479456
if ((ev->x != devdata->lastx) ||
480457
(ev->y != devdata->lasty))
@@ -483,7 +460,6 @@ gboolean on_buttonrelease (GtkWidget *win,
483460
if (!devdata->is_grabbed)
484461
return FALSE;
485462

486-
<<<<<<< HEAD
487463
GromitPaintType type = ctx->type;
488464

489465
if (type == GROMIT_SMOOTH || type == GROMIT_ORTHOGONAL)
@@ -517,13 +493,6 @@ gboolean on_buttonrelease (GtkWidget *win,
517493
if (ctx->arrowsize != 0)
518494
{
519495
GromitArrowType atype = ctx->arrow_type;
520-
=======
521-
GromitPaintType type = devdata->cur_context->type;
522-
523-
if (devdata->cur_context->arrowsize != 0)
524-
{
525-
GromitArrowType atype = devdata->cur_context->arrow_type;
526-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
527496
if (type == GROMIT_LINE)
528497
{
529498
direction = atan2 (ev->y - devdata->lasty, ev->x - devdata->lastx);
@@ -590,9 +559,9 @@ void on_mainapp_selection_get (GtkWidget *widget,
590559
undo_drawing (data);
591560
else if (action == GA_REDO)
592561
redo_drawing (data);
593-
else if (action == GA_DEFTOOL)
562+
else if (action == GA_CHGTOOL)
594563
{
595-
gtk_selection_convert(data->win, GA_DATA, GA_DEFTOOLDATA, time);
564+
gtk_selection_convert(data->win, GA_DATA, GA_CHGTOOLDATA, time);
596565
gtk_main();
597566
}
598567
else if (action == GA_CHGATTR)
@@ -687,13 +656,8 @@ void on_mainapp_selection_received (GtkWidget *widget,
687656
"Keeping default.\n");
688657
}
689658
GromitPaintContext* line_ctx =
690-
<<<<<<< HEAD
691659
paint_context_new(data, GROMIT_PEN, fg_color, thickness, 0, GROMIT_ARROW_END,
692660
5, 10, 15, 25, 0, thickness, thickness);
693-
=======
694-
paint_context_new(data, GROMIT_PEN, fg_color, thickness,
695-
0, GROMIT_ARROW_END, thickness, thickness);
696-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
697661

698662
GdkRectangle rect;
699663
rect.x = MIN (startX,endX) - thickness / 2;
@@ -719,7 +683,7 @@ void on_mainapp_selection_received (GtkWidget *widget,
719683
else
720684
{
721685
GdkAtom atom = gtk_selection_data_get_target(selection_data);
722-
if (atom == GA_DEFTOOLDATA || atom == GA_CHGATTRDATA)
686+
if (atom == GA_CHGTOOLDATA || atom == GA_CHGATTRDATA)
723687
{
724688
gchar *a = (gchar *)gtk_selection_data_get_data(selection_data);
725689
if(data->debug) g_printerr("DEBUG: define tool: %s\n", a);
@@ -1100,7 +1064,6 @@ void on_intro(GtkMenuItem *menuitem,
11001064
gtk_widget_show_all (assistant);
11011065
}
11021066

1103-
<<<<<<< HEAD
11041067
void on_edit_config(GtkMenuItem *menuitem,
11051068
gpointer user_data)
11061069
{
@@ -1155,8 +1118,6 @@ void on_edit_config(GtkMenuItem *menuitem,
11551118
}
11561119

11571120

1158-
=======
1159-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
11601121
void on_issues(GtkMenuItem *menuitem,
11611122
gpointer user_data)
11621123
{

src/callbacks.h

-3
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,9 @@ void on_about(GtkMenuItem *menuitem,
128128
void on_intro(GtkMenuItem *menuitem,
129129
gpointer user_data);
130130

131-
<<<<<<< HEAD
132131
void on_edit_config(GtkMenuItem *menuitem,
133132
gpointer user_data);
134133

135-
=======
136-
>>>>>>> 5385d7b (config, callbacks: add option to change tool definitions and individual tool attributes)
137134
void on_issues(GtkMenuItem *menuitem,
138135
gpointer user_data);
139136

0 commit comments

Comments
 (0)