diff --git a/unix/gtkapp.c b/unix/gtkapp.c index 4afe8be5..1c057f21 100644 --- a/unix/gtkapp.c +++ b/unix/gtkapp.c @@ -124,12 +124,20 @@ static void startup(GApplication *app, gpointer user_data) section = g_menu_new(); g_menu_append_section(menu, NULL, G_MENU_MODEL(section)); + g_menu_append(section, "Copy", "win.copy"); g_menu_append(section, "Paste", "win.paste"); gtk_application_set_menubar(GTK_APPLICATION(app), G_MENU_MODEL(menubar)); } +static void copy_cb(GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + copy_menu_action(user_data); +} + static void paste_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) @@ -138,6 +146,7 @@ static void paste_cb(GSimpleAction *action, } static const GActionEntry win_actions[] = { + { "copy", copy_cb }, { "paste", paste_cb }, }; diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 4b380ddc..76abb736 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -3243,10 +3243,17 @@ void init_clipboard(struct gui_data *inst) #endif /* JUST_USE_GTK_CLIPBOARD_UTF8 */ +void copy_menu_action(void *frontend) +{ + struct gui_data *inst = (struct gui_data *)frontend; + static const int clips[] = { MENU_CLIPBOARD }; + term_request_copy(inst->term, clips, lenof(clips)); +} + void paste_menu_action(void *frontend) { struct gui_data *inst = (struct gui_data *)frontend; - term_request_paste(inst->term, CLIP_CLIPBOARD); + term_request_paste(inst->term, MENU_CLIPBOARD); } static void set_window_titles(struct gui_data *inst) @@ -4290,20 +4297,20 @@ void reset_terminal_menuitem(GtkMenuItem *item, gpointer data) void copy_clipboard_menuitem(GtkMenuItem *item, gpointer data) { struct gui_data *inst = (struct gui_data *)data; - static const int clips[] = { CLIP_CLIPBOARD }; + static const int clips[] = { MENU_CLIPBOARD }; term_request_copy(inst->term, clips, lenof(clips)); } void paste_clipboard_menuitem(GtkMenuItem *item, gpointer data) { struct gui_data *inst = (struct gui_data *)data; - term_request_paste(inst->term, CLIP_CLIPBOARD); + term_request_paste(inst->term, MENU_CLIPBOARD); } void copy_all_menuitem(GtkMenuItem *item, gpointer data) { struct gui_data *inst = (struct gui_data *)data; - static const int clips[] = { CLIP_PRIMARY, CLIP_CLIPBOARD }; + static const int clips[] = { COPYALL_CLIPBOARDS }; term_copyall(inst->term, clips, lenof(clips)); } @@ -5224,8 +5231,10 @@ void new_session_window(Conf *conf, const char *geometry_string) MKMENUITEM("Clear Scrollback", clear_scrollback_menuitem); MKMENUITEM("Reset Terminal", reset_terminal_menuitem); MKSEP(); - MKMENUITEM("Copy to CLIPBOARD", copy_clipboard_menuitem); - MKMENUITEM("Paste from CLIPBOARD", paste_clipboard_menuitem); + MKMENUITEM("Copy to " CLIPNAME_EXPLICIT_OBJECT, + copy_clipboard_menuitem); + MKMENUITEM("Paste from " CLIPNAME_EXPLICIT_OBJECT, + paste_clipboard_menuitem); MKMENUITEM("Copy All", copy_all_menuitem); MKSEP(); s = dupcat("About ", appname, NULL); diff --git a/unix/unix.h b/unix/unix.h index dc216b4a..eac1eb56 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -141,6 +141,8 @@ unsigned long getticks(void); #define CLIPUI_DEFAULT_AUTOCOPY FALSE #define CLIPUI_DEFAULT_MOUSE CLIPUI_IMPLICIT #define CLIPUI_DEFAULT_INS CLIPUI_EXPLICIT +#define MENU_CLIPBOARD CLIP_SYSTEM +#define COPYALL_CLIPBOARDS CLIP_SYSTEM #else #define MOUSE_SELECT_CLIPBOARD CLIP_PRIMARY #define MOUSE_PASTE_CLIPBOARD CLIP_PRIMARY @@ -152,6 +154,8 @@ unsigned long getticks(void); #define CLIPUI_DEFAULT_AUTOCOPY FALSE #define CLIPUI_DEFAULT_MOUSE CLIPUI_IMPLICIT #define CLIPUI_DEFAULT_INS CLIPUI_IMPLICIT +#define MENU_CLIPBOARD CLIP_CLIPBOARD +#define COPYALL_CLIPBOARDS CLIP_PRIMARY, CLIP_CLIPBOARD /* X11 supports arbitrary named clipboards */ #define NAMED_CLIPBOARDS #endif @@ -181,6 +185,7 @@ GtkWidget *make_gtk_toplevel_window(void *frontend); void gtkcomm_setup(void); /* Defined in gtkwin.c */ +void copy_menu_action(void *frontend); void paste_menu_action(void *frontend); /* Things pty.c needs from pterm.c */