1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Sort out clipboard-related menu items.

The gtkapp.c menu now has a Copy as well as Paste option; those menu
items, as well as the corresponding ones on the context menu and Copy
All, now address sets of clipboards parametrised between OS X and
ordinary GTK in unix.h. Also I've tweaked the wording of the
context-menu items to not use the X-specific terminology "CLIPBOARD"
on OS X.
This commit is contained in:
Simon Tatham 2017-12-17 20:35:45 +00:00
parent 1ed2f98c89
commit 7bc637ad07
3 changed files with 29 additions and 6 deletions

View File

@ -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 },
};

View File

@ -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);

View File

@ -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 */