Commit 6bc1e908 authored by Cosimo Cecchi's avatar Cosimo Cecchi
Browse files

app-menu: add an application menu

Move the About and Quit entries there; more to come.
parent 0c4d021e
...@@ -10,6 +10,7 @@ INCLUDES = \ ...@@ -10,6 +10,7 @@ INCLUDES = \
bin_PROGRAMS = gnome-system-log bin_PROGRAMS = gnome-system-log
ui_files = \ ui_files = \
logview-app-menu.ui \
logview-filter.ui \ logview-filter.ui \
logview-menubar.xml logview-menubar.xml
......
<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">&lt;Primary&gt;q</attribute>
</item>
</section>
</menu>
</interface>
...@@ -24,14 +24,15 @@ ...@@ -24,14 +24,15 @@
#include <config.h> #include <config.h>
#endif #endif
#include <glib/gi18n.h>
#include "logview-app.h" #include "logview-app.h"
#include "logview-about.h"
#include "logview-manager.h" #include "logview-manager.h"
#include "logview-window.h" #include "logview-window.h"
#include "logview-prefs.h" #include "logview-prefs.h"
#include <glib/gi18n.h>
struct _LogviewAppPrivate { struct _LogviewAppPrivate {
LogviewPrefs *prefs; LogviewPrefs *prefs;
LogviewManager *manager; LogviewManager *manager;
...@@ -270,6 +271,65 @@ logview_app_activate (GApplication *application) ...@@ -270,6 +271,65 @@ logview_app_activate (GApplication *application)
gtk_widget_show (app->priv->window); gtk_widget_show (app->priv->window);
} }
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 static void
logview_app_startup (GApplication *application) logview_app_startup (GApplication *application)
{ {
...@@ -278,6 +338,7 @@ logview_app_startup (GApplication *application) ...@@ -278,6 +338,7 @@ logview_app_startup (GApplication *application)
G_APPLICATION_CLASS (logview_app_parent_class)->startup (application); G_APPLICATION_CLASS (logview_app_parent_class)->startup (application);
app->priv->window = logview_window_new (GTK_APPLICATION (app)); app->priv->window = logview_window_new (GTK_APPLICATION (app));
logview_app_init_menus (app);
} }
static void static void
......
...@@ -42,8 +42,6 @@ main (int argc, char *argv[]) ...@@ -42,8 +42,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE); textdomain (GETTEXT_PACKAGE);
g_set_application_name (_("Log Viewer"));
app = logview_app_new (); app = logview_app_new ();
result = g_application_run (G_APPLICATION (app), argc, argv); result = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app); g_object_unref (app);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<menu action="FileMenu"> <menu action="FileMenu">
<menuitem action="OpenLog"/> <menuitem action="OpenLog"/>
<menuitem action="CloseLog"/> <menuitem action="CloseLog"/>
<menuitem action="Quit"/>
</menu> </menu>
<menu action="EditMenu"> <menu action="EditMenu">
<menuitem action="Copy"/> <menuitem action="Copy"/>
...@@ -29,7 +28,6 @@ ...@@ -29,7 +28,6 @@
</menu> </menu>
<menu action="HelpMenu"> <menu action="HelpMenu">
<menuitem action="HelpContents"/> <menuitem action="HelpContents"/>
<menuitem action="AboutAction"/>
</menu> </menu>
</menubar> </menubar>
</ui> </ui>
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "logview-loglist.h" #include "logview-loglist.h"
#include "logview-findbar.h" #include "logview-findbar.h"
#include "logview-about.h"
#include "logview-prefs.h" #include "logview-prefs.h"
#include "logview-manager.h" #include "logview-manager.h"
#include "logview-filter-manager.h" #include "logview-filter-manager.h"
...@@ -745,40 +744,6 @@ logview_manage_filters (GtkAction *action, LogviewWindow *logview) ...@@ -745,40 +744,6 @@ logview_manage_filters (GtkAction *action, LogviewWindow *logview)
gtk_widget_show (GTK_WIDGET (manager)); gtk_widget_show (GTK_WIDGET (manager));
} }
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 static void
logview_toggle_statusbar (GtkAction *action, LogviewWindow *logview) logview_toggle_statusbar (GtkAction *action, LogviewWindow *logview)
{ {
...@@ -825,8 +790,6 @@ static GtkActionEntry entries[] = { ...@@ -825,8 +790,6 @@ static GtkActionEntry entries[] = {
G_CALLBACK (logview_open_log) }, G_CALLBACK (logview_open_log) },
{ "CloseLog", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", N_("Close this log"), { "CloseLog", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", N_("Close this log"),
G_CALLBACK (logview_close_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"), { "Copy", GTK_STOCK_COPY, N_("_Copy"), "<control>C", N_("Copy the selection"),
G_CALLBACK (logview_copy) }, G_CALLBACK (logview_copy) },
...@@ -847,8 +810,6 @@ static GtkActionEntry entries[] = { ...@@ -847,8 +810,6 @@ static GtkActionEntry entries[] = {
{ "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Open the help contents for the log viewer"), { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", N_("Open the help contents for the log viewer"),
G_CALLBACK (logview_help) }, 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[] = { static GtkToggleActionEntry toggle_entries[] = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment