From 6299c0d614575c6090e6cd2409397393405169e5 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 24 Jun 2019 09:54:54 +0200 Subject: file menu actions --- main.ui | 3 +++ vconsole.c | 56 ++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/main.ui b/main.ui index 626d4ba..c10507f 100644 --- a/main.ui +++ b/main.ui @@ -35,6 +35,7 @@ Connect ... True False + main.ConnectAsk True False @@ -44,6 +45,7 @@ Close _Tab True False + main.CloseTab True False @@ -53,6 +55,7 @@ gtk-quit True False + main.CloseApp True True diff --git a/vconsole.c b/vconsole.c index b6be027..86bf85d 100644 --- a/vconsole.c +++ b/vconsole.c @@ -149,9 +149,9 @@ static int gtk_getstring(GtkWidget *window, char *title, char *message, /* ------------------------------------------------------------------ */ -#if 0 - -static void menu_cb_connect_ask(GtkAction *action, gpointer userdata) +static void menu_cb_connect_ask(GSimpleAction *action, + GVariant *parameter, + gpointer userdata) { struct vconsole_window *win = userdata; char uri[256] = ""; @@ -163,7 +163,11 @@ static void menu_cb_connect_ask(GtkAction *action, gpointer userdata) connect_init(win, uri); } -static void menu_cb_connect_menu(GtkAction *action, gpointer userdata) +#if 0 + +static void menu_cb_connect_menu(GSimpleAction *action, + GVariant *parameter, + gpointer userdata) { struct vconsole_window *win = userdata; GError *err = NULL; @@ -181,18 +185,26 @@ static void menu_cb_connect_menu(GtkAction *action, gpointer userdata) } } -static void menu_cb_close_tab(GtkAction *action, gpointer userdata) +#endif + +static void menu_cb_close_tab(GSimpleAction *action, + GVariant *parameter, + gpointer userdata) { struct vconsole_window *win = userdata; domain_close_current_tab(win); } -static void menu_cb_close_app(GtkAction *action, gpointer userdata) +static void menu_cb_close_app(GSimpleAction *action, + GVariant *parameter, + gpointer userdata) { struct vconsole_window *win = userdata; gtk_widget_destroy(win->toplevel); } +#if 0 + static gboolean terminal_font_filter(const PangoFontFamily *family, const PangoFontFace *face, gpointer data) @@ -531,8 +543,11 @@ static void menu_cb_vm_logging(GtkToggleAction *action, gpointer userdata) /* ------------------------------------------------------------------ */ -static const GtkActionEntry entries[] = { +#endif + +static const GActionEntry entries[] = { { +#if 0 /* --- menu bar --- */ .name = "FileMenu", .label = "_File", @@ -551,23 +566,18 @@ static const GtkActionEntry entries[] = { .name = "ConnectMenu", .label = "_Recent", },{ +#endif /* --- file menu --- */ .name = "ConnectAsk", - .stock_id = GTK_STOCK_CONNECT, - .label = "_Connect ...", - .callback = G_CALLBACK(menu_cb_connect_ask), + .activate = menu_cb_connect_ask, },{ .name = "CloseTab", - .stock_id = GTK_STOCK_CLOSE, - .label = "Close _Tab", - .tooltip = "Close Tab", - .callback = G_CALLBACK(menu_cb_close_tab), + .activate = menu_cb_close_tab, },{ .name = "CloseApp", - .stock_id = GTK_STOCK_QUIT, - .label = "_Quit", - .callback = G_CALLBACK(menu_cb_close_app), + .activate = menu_cb_close_app, +#if 0 },{ /* --- view menu --- */ @@ -657,9 +667,12 @@ static const GtkActionEntry entries[] = { .stock_id = GTK_STOCK_HELP, .label = "_Manual page", .callback = G_CALLBACK(menu_cb_manual), +#endif }, }; +#if 0 + static const GtkToggleActionEntry tentries[] = { { .name = "TerminalBlink", @@ -891,7 +904,8 @@ static struct vconsole_window *vconsole_toplevel_create(void) gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), win->notebook, TRUE, TRUE, 0); #else - GtkBuilder *builder; + GtkBuilder *builder; + GSimpleActionGroup *ag; win = g_new0(struct vconsole_window, 1); @@ -905,6 +919,12 @@ static struct vconsole_window *vconsole_toplevel_create(void) NULL); gtk_builder_connect_signals(builder, win); + ag = g_simple_action_group_new(); + g_action_map_add_action_entries(G_ACTION_MAP(ag), + entries, G_N_ELEMENTS(entries), + win); + gtk_widget_insert_action_group(win->toplevel, "main", G_ACTION_GROUP(ag)); + g_object_unref(builder); #endif -- cgit