[gnome-system-log] app-menu: add an application menu
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-log] app-menu: add an application menu
- Date: Fri, 29 Jun 2012 00:52:11 +0000 (UTC)
commit 6bc1e9082af9c122f1b275e8cbfcfb3995de272e
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Jun 28 20:25:29 2012 -0400
app-menu: add an application menu
Move the About and Quit entries there; more to come.
src/Makefile.am | 1 +
src/logview-app-menu.ui | 15 +++++++++++
src/logview-app.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-
src/logview-main.c | 2 -
src/logview-menubar.xml | 2 -
src/logview-window.c | 39 ----------------------------
6 files changed, 79 insertions(+), 45 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a7564ce..ee4c84e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = \
bin_PROGRAMS = gnome-system-log
ui_files = \
+ logview-app-menu.ui \
logview-filter.ui \
logview-menubar.xml
diff --git a/src/logview-app-menu.ui b/src/logview-app-menu.ui
new file mode 100644
index 0000000..34b7a39
--- /dev/null
+++ b/src/logview-app-menu.ui
@@ -0,0 +1,15 @@
+<interface>
+ <menu id="app-menu">
+ <section>
+ <item>
+ <attribute name="action">app.about</attribute>
+ <attribute name="label" translatable="yes">About System Log</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="label" translatable="yes">Quit</attribute>
+ <attribute name="accel"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/src/logview-app.c b/src/logview-app.c
index 465d5d7..24d7496 100644
--- a/src/logview-app.c
+++ b/src/logview-app.c
@@ -24,14 +24,15 @@
#include <config.h>
#endif
+#include <glib/gi18n.h>
+
#include "logview-app.h"
+#include "logview-about.h"
#include "logview-manager.h"
#include "logview-window.h"
#include "logview-prefs.h"
-#include <glib/gi18n.h>
-
struct _LogviewAppPrivate {
LogviewPrefs *prefs;
LogviewManager *manager;
@@ -271,6 +272,65 @@ logview_app_activate (GApplication *application)
}
static void
+action_about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ LogviewApp *app = user_data;
+
+ char *license_trans = g_strjoin ("\n\n", _(logview_about_license[0]),
+ _(logview_about_license[1]),
+ _(logview_about_license[2]), NULL);
+
+ gtk_show_about_dialog (GTK_WINDOW (app->priv->window),
+ "program-name", _("System Log"),
+ "version", VERSION,
+ "copyright", "Copyright \xc2\xa9 1998-2008 Free Software Foundation, Inc.",
+ "license", license_trans,
+ "wrap-license", TRUE,
+ "comments", _("A system log viewer for GNOME."),
+ "authors", logview_about_authors,
+ "documenters", logview_about_documenters,
+ "translator_credits", strcmp (logview_about_translator_credits,
+ "translator-credits") != 0 ?
+ logview_about_translator_credits : NULL,
+ "logo_icon_name", "logview",
+ NULL);
+ g_free (license_trans);
+}
+
+static void
+action_quit (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ LogviewApp *app = user_data;
+ gtk_widget_destroy (app->priv->window);
+}
+
+static GActionEntry action_entries[] = {
+ { "about", action_about, NULL, NULL, NULL },
+ { "quit", action_quit, NULL, NULL, NULL }
+};
+
+static void
+logview_app_init_menus (LogviewApp *app)
+{
+ GtkBuilder *builder = gtk_builder_new ();
+ GMenuModel *app_menu;
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app), action_entries,
+ G_N_ELEMENTS (action_entries), app);
+
+ gtk_builder_add_from_resource (builder, "/org/gnome/logview/logview-app-menu.ui", NULL);
+ app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
+ gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
+
+ g_object_unref (builder);
+ g_object_unref (app_menu);
+}
+
+static void
logview_app_startup (GApplication *application)
{
LogviewApp *app = LOGVIEW_APP (application);
@@ -278,6 +338,7 @@ logview_app_startup (GApplication *application)
G_APPLICATION_CLASS (logview_app_parent_class)->startup (application);
app->priv->window = logview_window_new (GTK_APPLICATION (app));
+ logview_app_init_menus (app);
}
static void
diff --git a/src/logview-main.c b/src/logview-main.c
index 1a08372..b266dfe 100644
--- a/src/logview-main.c
+++ b/src/logview-main.c
@@ -42,8 +42,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- g_set_application_name (_("Log Viewer"));
-
app = logview_app_new ();
result = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
diff --git a/src/logview-menubar.xml b/src/logview-menubar.xml
index 73883da..90a7422 100644
--- a/src/logview-menubar.xml
+++ b/src/logview-menubar.xml
@@ -3,7 +3,6 @@
<menu action="FileMenu">
<menuitem action="OpenLog"/>
<menuitem action="CloseLog"/>
- <menuitem action="Quit"/>
</menu>
<menu action="EditMenu">
<menuitem action="Copy"/>
@@ -29,7 +28,6 @@
</menu>
<menu action="HelpMenu">
<menuitem action="HelpContents"/>
- <menuitem action="AboutAction"/>
</menu>
</menubar>
</ui>
diff --git a/src/logview-window.c b/src/logview-window.c
index 09452b6..0a39813 100644
--- a/src/logview-window.c
+++ b/src/logview-window.c
@@ -30,7 +30,6 @@
#include "logview-loglist.h"
#include "logview-findbar.h"
-#include "logview-about.h"
#include "logview-prefs.h"
#include "logview-manager.h"
#include "logview-filter-manager.h"
@@ -746,40 +745,6 @@ logview_manage_filters (GtkAction *action, LogviewWindow *logview)
}
static void
-logview_about (GtkWidget *widget, GtkWidget *window)
-{
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- char *license_trans = g_strjoin ("\n\n", _(logview_about_license[0]),
- _(logview_about_license[1]),
- _(logview_about_license[2]), NULL);
-
- gtk_show_about_dialog (GTK_WINDOW (window),
- "name", _("System Log Viewer"),
- "version", VERSION,
- "copyright", "Copyright \xc2\xa9 1998-2008 Free Software Foundation, Inc.",
- "license", license_trans,
- "wrap-license", TRUE,
- "comments", _("A system log viewer for GNOME."),
- "authors", logview_about_authors,
- "documenters", logview_about_documenters,
- "translator_credits", strcmp (logview_about_translator_credits,
- "translator-credits") != 0 ?
- logview_about_translator_credits : NULL,
- "logo_icon_name", "logview",
- NULL);
- g_free (license_trans);
-
- return;
-}
-
-static void
-logview_quit (GtkAction *action, LogviewWindow *logview)
-{
- gtk_widget_destroy (GTK_WIDGET (logview));
-}
-
-static void
logview_toggle_statusbar (GtkAction *action, LogviewWindow *logview)
{
if (gtk_widget_get_visible (logview->priv->statusbar))
@@ -825,8 +790,6 @@ static GtkActionEntry entries[] = {
G_CALLBACK (logview_open_log) },
{ "CloseLog", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", N_("Close this log"),
G_CALLBACK (logview_close_log) },
- { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", N_("Quit the log viewer"),
- G_CALLBACK (logview_quit) },
{ "Copy", GTK_STOCK_COPY, N_("_Copy"), "<control>C", N_("Copy the selection"),
G_CALLBACK (logview_copy) },
@@ -847,8 +810,6 @@ static GtkActionEntry entries[] = {
{ "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Open the help contents for the log viewer"),
G_CALLBACK (logview_help) },
- { "AboutAction", GTK_STOCK_ABOUT, N_("_About"), NULL, N_("Show the about dialog for the log viewer"),
- G_CALLBACK (logview_about) },
};
static GtkToggleActionEntry toggle_entries[] = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]