1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-10 15:48:06 -05:00

Fill in some more of the OS X menu bar.

This still isn't complete: I also need to add the variable collections
of things like mid-session special commands and saved session names,
and also I need to try to grey out menu items when they're not
applicable. But it's a start.
This commit is contained in:
Simon Tatham 2017-12-18 11:46:48 +00:00
parent 2065fb647f
commit 04184c87cc
4 changed files with 85 additions and 24 deletions

View File

@ -40,11 +40,10 @@ but if I mouse off the menu and back on (without un-popping-it-up)
then suddenly that does work. I don't know if this is something I can
fix, though; it might very well be a quirk of the underlying GTK.
The application menu bar is very minimal at the moment. Should include
all the usual stuff from the Ctrl-right-click menu - saved sessions,
mid-session special commands, Duplicate Session, Change Settings,
Event Log, clear scrollback, reset terminal, about box, anything else
I can think of.
Still to do on the application menu bar: items that have to vary with
context or user action (saved sessions and mid-session special
commands), and disabling/enabling the main actions in parallel with
their counterparts in the Ctrl-rightclick context menu.
Does OS X have a standard system of online help that I could tie into?
@ -97,6 +96,8 @@ void launch_saved_session(const char *str) {}
void session_window_closed(void) {}
#else /* GTK_CHECK_VERSION(3,0,0) */
extern const int use_event_log;
static void startup(GApplication *app, gpointer user_data)
{
GMenu *menubar, *menu, *section;
@ -117,6 +118,30 @@ static void startup(GApplication *app, gpointer user_data)
g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
g_menu_append(section, "Copy", "win.copy");
g_menu_append(section, "Paste", "win.paste");
g_menu_append(section, "Copy All", "win.copyall");
menu = g_menu_new();
g_menu_append_submenu(menubar, "Window", G_MENU_MODEL(menu));
section = g_menu_new();
g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
g_menu_append(section, "Restart Session", "win.restart");
g_menu_append(section, "Duplicate Session", "win.duplicate");
section = g_menu_new();
g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
g_menu_append(section, "Change Settings", "win.changesettings");
if (use_event_log) {
section = g_menu_new();
g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
g_menu_append(section, "Event Log", "win.eventlog");
}
section = g_menu_new();
g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
g_menu_append(section, "Clear Scrollback", "win.clearscrollback");
g_menu_append(section, "Reset Terminal", "win.resetterm");
#define SET_ACCEL(app, command, accel) do \
{ \
@ -138,6 +163,13 @@ static void startup(GApplication *app, gpointer user_data)
#define WIN_ACTION_LIST(X) \
X("copy", MA_COPY) \
X("paste", MA_PASTE) \
X("copyall", MA_COPY_ALL) \
X("duplicate", MA_DUPLICATE_SESSION) \
X("restart", MA_RESTART_SESSION) \
X("changesettings", MA_CHANGE_SETTINGS) \
X("clearscrollback", MA_CLEAR_SCROLLBACK) \
X("resetterm", MA_RESET_TERMINAL) \
X("eventlog", MA_EVENT_LOG) \
/* end of list */
#define WIN_ACTION_CALLBACK(name, id) \
@ -247,8 +279,16 @@ static void quit_cb(GSimpleAction *action,
g_application_quit(G_APPLICATION(user_data));
}
static void about_cb(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
about_box(NULL);
}
static const GActionEntry app_actions[] = {
{ "newwin", newwin_cb },
{ "about", about_cb },
{ "quit", quit_cb },
};

View File

@ -3779,8 +3779,9 @@ void about_box(void *window)
G_CALLBACK(about_key_press), NULL);
set_transient_window_pos(GTK_WIDGET(window), aboutbox);
gtk_window_set_transient_for(GTK_WINDOW(aboutbox),
GTK_WINDOW(window));
if (window)
gtk_window_set_transient_for(GTK_WINDOW(aboutbox),
GTK_WINDOW(window));
gtk_container_set_focus_child(GTK_CONTAINER(aboutbox), NULL);
gtk_widget_show(aboutbox);
gtk_window_set_focus(GTK_WINDOW(aboutbox), NULL);

View File

@ -3252,22 +3252,6 @@ void init_clipboard(struct gui_data *inst)
#endif /* JUST_USE_GTK_CLIPBOARD_UTF8 */
void app_menu_action(void *frontend, enum MenuAction action)
{
struct gui_data *inst = (struct gui_data *)frontend;
switch (action) {
case MA_COPY:
{
static const int clips[] = { MENU_CLIPBOARD };
term_request_copy(inst->term, clips, lenof(clips));
}
break;
case MA_PASTE:
term_request_paste(inst->term, MENU_CLIPBOARD);
break;
}
}
static void set_window_titles(struct gui_data *inst)
{
/*
@ -4725,6 +4709,40 @@ void saved_session_freedata(GtkMenuItem *item, gpointer data)
sfree(str);
}
void app_menu_action(void *frontend, enum MenuAction action)
{
struct gui_data *inst = (struct gui_data *)frontend;
switch (action) {
case MA_COPY:
copy_clipboard_menuitem(NULL, inst);
break;
case MA_PASTE:
paste_clipboard_menuitem(NULL, inst);
break;
case MA_COPY_ALL:
copy_all_menuitem(NULL, inst);
break;
case MA_DUPLICATE_SESSION:
dup_session_menuitem(NULL, inst);
break;
case MA_RESTART_SESSION:
restart_session_menuitem(NULL, inst);
break;
case MA_CHANGE_SETTINGS:
change_settings_menuitem(NULL, inst);
break;
case MA_CLEAR_SCROLLBACK:
clear_scrollback_menuitem(NULL, inst);
break;
case MA_RESET_TERMINAL:
reset_terminal_menuitem(NULL, inst);
break;
case MA_EVENT_LOG:
event_log_menuitem(NULL, inst);
break;
}
}
static void update_savedsess_menu(GtkMenuItem *menuitem, gpointer data)
{
struct gui_data *inst = (struct gui_data *)data;

View File

@ -186,7 +186,9 @@ void gtkcomm_setup(void);
/* Used to pass application-menu operations from gtkapp.c to gtkwin.c */
enum MenuAction {
MA_COPY, MA_PASTE,
MA_COPY, MA_PASTE, MA_COPY_ALL, MA_DUPLICATE_SESSION,
MA_RESTART_SESSION, MA_CHANGE_SETTINGS, MA_CLEAR_SCROLLBACK,
MA_RESET_TERMINAL, MA_EVENT_LOG
};
void app_menu_action(void *frontend, enum MenuAction);