Skip to content

Commit

Permalink
feat(swappy): copy to clipboard with CTRL+C
Browse files Browse the repository at this point in the history
  • Loading branch information
jtheoof committed Dec 23, 2019
1 parent e946b24 commit b90500e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ static void keypress_handler(GtkWidget *widget, GdkEventKey *event,
switch_mode_to_arrow(state);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(state->popover->arrow),
true);
} else if (event->keyval == GDK_KEY_c && event->state & GDK_CONTROL_MASK) {
clipboard_copy_drawing_area_to_selection(state);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/clipboard.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "clipboard.h"

#include "notification.h"

bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state) {
g_debug("generating pixbuf from area");
GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
Expand All @@ -10,5 +12,9 @@ bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state) {

gtk_clipboard_set_image(clipboard, pixbuf);

char message[MAX_PATH];
snprintf(message, MAX_PATH, "Swappshot copied to clipboard\n");
notification_send("Swappy", message);

return true;
}

0 comments on commit b90500e

Please sign in to comment.