mirror of
https://github.com/jtheoof/swappy.git
synced 2024-10-26 15:44:47 +03:00
application: implement signal for brush button
This commit is contained in:
parent
b41c572f1e
commit
5a006cf1f6
@ -6,3 +6,4 @@ bool application_init(struct swappy_state *state);
|
|||||||
int application_run(struct swappy_state *state);
|
int application_run(struct swappy_state *state);
|
||||||
void application_finish(struct swappy_state *state);
|
void application_finish(struct swappy_state *state);
|
||||||
|
|
||||||
|
void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state);
|
@ -53,6 +53,7 @@ executable(
|
|||||||
wayland_client,
|
wayland_client,
|
||||||
wayland_cursor,
|
wayland_cursor,
|
||||||
],
|
],
|
||||||
|
link_args: '-rdynamic',
|
||||||
include_directories: [swappy_inc],
|
include_directories: [swappy_inc],
|
||||||
install: true,
|
install: true,
|
||||||
)
|
)
|
||||||
|
@ -162,6 +162,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="brush_clicked_handler" swapped="no"/>
|
||||||
<style>
|
<style>
|
||||||
<class name="brush"/>
|
<class name="brush"/>
|
||||||
</style>
|
</style>
|
||||||
|
@ -18,6 +18,11 @@ static void swappy_overlay_clear(struct swappy_state *state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void switch_mode_to_brush(struct swappy_state *state) {
|
||||||
|
g_debug("switching mode to brush");
|
||||||
|
state->mode = SWAPPY_PAINT_MODE_BRUSH;
|
||||||
|
}
|
||||||
|
|
||||||
void application_finish(struct swappy_state *state) {
|
void application_finish(struct swappy_state *state) {
|
||||||
g_debug("application is shutting down");
|
g_debug("application is shutting down");
|
||||||
swappy_overlay_clear(state);
|
swappy_overlay_clear(state);
|
||||||
@ -29,6 +34,10 @@ void application_finish(struct swappy_state *state) {
|
|||||||
g_object_unref(state->app);
|
g_object_unref(state->app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
|
||||||
|
switch_mode_to_brush(state);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean draw_area_handler(GtkWidget *widget, cairo_t *cr,
|
static gboolean draw_area_handler(GtkWidget *widget, cairo_t *cr,
|
||||||
struct swappy_state *state) {
|
struct swappy_state *state) {
|
||||||
cairo_set_source_surface(cr, state->cairo_surface, 0, 0);
|
cairo_set_source_surface(cr, state->cairo_surface, 0, 0);
|
||||||
@ -119,12 +128,13 @@ static void tools_menu_button_copy_clicked_handler(GtkToggleButton *source,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void keypress_handler(GtkWidget *widget, GdkEventKey *event,
|
static void keypress_handler(GtkWidget *widget, GdkEventKey *event,
|
||||||
gpointer data) {
|
struct swappy_state *state) {
|
||||||
struct swappy_state *state = data;
|
|
||||||
g_debug("keypress_handler key pressed: %d\n", event->keyval);
|
g_debug("keypress_handler key pressed: %d\n", event->keyval);
|
||||||
if (event->keyval == GDK_KEY_Escape) {
|
if (event->keyval == GDK_KEY_Escape) {
|
||||||
g_debug("keypress_handler: escape key pressed, ciao bye\n");
|
g_debug("keypress_handler: escape key pressed, ciao bye\n");
|
||||||
gtk_window_close(state->window);
|
gtk_window_close(state->window);
|
||||||
|
} else if (event->keyval == GDK_KEY_B || event->keyval == GDK_KEY_b) {
|
||||||
|
switch_mode_to_brush(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +242,8 @@ static bool load_layout(struct swappy_state *state) {
|
|||||||
area = GTK_WIDGET(gtk_builder_get_object(builder, "paint_area"));
|
area = GTK_WIDGET(gtk_builder_get_object(builder, "paint_area"));
|
||||||
popover = GTK_POPOVER(gtk_builder_get_object(builder, "popover"));
|
popover = GTK_POPOVER(gtk_builder_get_object(builder, "popover"));
|
||||||
|
|
||||||
|
gtk_builder_connect_signals(builder, state);
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(state->window), "key_press_event",
|
g_signal_connect(G_OBJECT(state->window), "key_press_event",
|
||||||
G_CALLBACK(keypress_handler), state);
|
G_CALLBACK(keypress_handler), state);
|
||||||
g_signal_connect(brush, "toggled",
|
g_signal_connect(brush, "toggled",
|
||||||
|
Loading…
Reference in New Issue
Block a user