From fdaa448ae9bedd07356d5c8337b698f23c61f1fe Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 20 Jun 2013 22:17:45 +0200 Subject: [PATCH] appmenu: Add Quit item https://bugzilla.gnome.org/show_bug.cgi?id=690910 --- src/terminal-app.c | 18 +++++++++++++++++- src/terminal-appmenu.ui | 4 ++++ src/terminal-window.c | 16 ++++++++++++---- src/terminal-window.h | 2 ++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/terminal-app.c b/src/terminal-app.c index 54a4ccd..4e061b6 100644 --- a/src/terminal-app.c +++ b/src/terminal-app.c @@ -281,6 +281,21 @@ app_menu_about_cb (GSimpleAction *action, terminal_util_show_about (gtk_application_get_active_window (application)); } +static void +app_menu_quit_cb (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GtkApplication *application = user_data; + GtkWindow *window; + + window = gtk_application_get_active_window (application); + if (TERMINAL_IS_WINDOW (window)) + terminal_window_request_close (TERMINAL_WINDOW (window)); + else /* a dialogue */ + gtk_widget_destroy (GTK_WIDGET (window)); +} + /* Class implementation */ G_DEFINE_TYPE (TerminalApp, terminal_app, GTK_TYPE_APPLICATION) @@ -299,7 +314,8 @@ terminal_app_startup (GApplication *application) const GActionEntry app_menu_actions[] = { { "preferences", app_menu_preferences_cb, NULL, NULL, NULL }, { "help", app_menu_help_cb, NULL, NULL, NULL }, - { "about", app_menu_about_cb, NULL, NULL, NULL } + { "about", app_menu_about_cb, NULL, NULL, NULL }, + { "quit", app_menu_quit_cb, NULL, NULL, NULL } }; GtkBuilder *builder; diff --git a/src/terminal-appmenu.ui b/src/terminal-appmenu.ui index 36b7e0b..0c6b86b 100644 --- a/src/terminal-appmenu.ui +++ b/src/terminal-appmenu.ui @@ -32,6 +32,10 @@ _About app.about + + _Quit + app.quit + diff --git a/src/terminal-window.c b/src/terminal-window.c index 3670da0..1fafb39 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -2948,10 +2948,7 @@ static void file_close_window_callback (GtkAction *action, TerminalWindow *window) { - if (confirm_close_window_or_tab (window, NULL)) - return; - - gtk_widget_destroy (GTK_WIDGET (window)); + terminal_window_request_close (window); } #ifdef ENABLE_SAVE @@ -3612,3 +3609,14 @@ terminal_window_get_ui_manager (TerminalWindow *window) return priv->ui_manager; } + +void +terminal_window_request_close (TerminalWindow *window) +{ + g_return_if_fail (TERMINAL_IS_WINDOW (window)); + + if (confirm_close_window_or_tab (window, NULL)) + return; + + gtk_widget_destroy (GTK_WIDGET (window)); +} diff --git a/src/terminal-window.h b/src/terminal-window.h index 880ec19..3cf6794 100644 --- a/src/terminal-window.h +++ b/src/terminal-window.h @@ -87,6 +87,8 @@ void terminal_window_update_geometry (TerminalWindow *window); GtkWidget* terminal_window_get_mdi_container (TerminalWindow *window); +void terminal_window_request_close (TerminalWindow *window); + G_END_DECLS #endif /* TERMINAL_WINDOW_H */ -- 1.8.4.2