-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolbar.c
92 lines (70 loc) · 2.03 KB
/
toolbar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <gtk/gtk.h>
#include "toolbar.h"
#include "paint.h"
//Button functions
void selecter(GtkWidget *widget, gpointer datal) {
g_print ("Selection tool\n");
}
void move(GtkWidget *widget, gpointer data) {
g_print ("Move tool\n");
}
void pencil(GtkWidget *widget, gpointer data) {
g_print ("Pencil tool\n");
GtkWidget* canvas = data;
if (tool > 0) {
g_signal_handler_disconnect(canvas, tool);
}
lastX = -1;
lastY = -1;
tool = g_signal_connect(canvas, "motion-notify-event", G_CALLBACK(brush_mouse_motion), NULL);
printf("%d\n", tool);
}
void eraser(GtkWidget *widget, gpointer data) {
g_print ("Eraser tool\n");
GtkWidget* canvas = data;
if (tool > 0) {
g_signal_handler_disconnect(canvas, tool);
}
lastX = -1;
lastY = -1;
curr_color.red = 255;
curr_color.green = 255;
curr_color.blue = 255;
curr_color.alpha = 255;
tool = g_signal_connect(canvas, "motion-notify-event", G_CALLBACK(eraser_mouse_motion), NULL);
printf("%d\n", tool);
}
void text(GtkWidget *widget, gpointer data) {
g_print ("Text tool\n");
}
void bucket(GtkWidget *widget, gpointer data) {
g_print ("Bucket tool\n");
GtkWidget* canvas = data;
if (tool > 0) {
g_signal_handler_disconnect(canvas, tool);
}
tool = g_signal_connect(canvas, "button-press-event", G_CALLBACK(paint_bucket_mouse_clicked), NULL);
printf("%d\n", tool);
}
void picker(GtkWidget *widget, gpointer data) {
GtkWidget *colorWheel;
colorWheel = gtk_color_chooser_dialog_new ("Colors", NULL);
gtk_dialog_run(colorWheel);
gtk_color_chooser_get_rgba(colorWheel, &color);
curr_color.red = (int)(color.red*255);
curr_color.green = (int)(color.green*255);
curr_color.blue = (int)(color.blue*255);
curr_color.alpha = (int)(color.alpha*255);
gtk_widget_destroy(colorWheel);
}
void line(GtkWidget *widget, gpointer data) {
g_print ("Line tool\n");
GtkWidget* canvas = data;
if (tool > 0) {
g_signal_handler_disconnect(canvas, tool);
}
lastX = -1;
lastY = -1;
tool = g_signal_connect(canvas, "button-press-event", G_CALLBACK(line_mouse_clicked), NULL);
printf("%d\n", tool);
}