summaryrefslogtreecommitdiff
path: root/font-viewer
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-01-08 17:21:52 +0100
committerraveit65 <[email protected]>2017-02-17 12:28:22 +0100
commit8ac1f9414dd84603a5dc972088993677572333ce (patch)
tree54e0445acd66ff0ddf63ef0bde84301c4fae0a22 /font-viewer
parent9214a3c0e8101391f3e6c8533af9e4f4444f1db4 (diff)
downloadmate-control-center-8ac1f9414dd84603a5dc972088993677572333ce.tar.bz2
mate-control-center-8ac1f9414dd84603a5dc972088993677572333ce.tar.xz
Font-viewer: add an application menu
taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=3261384
Diffstat (limited to 'font-viewer')
-rw-r--r--font-viewer/font-view.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c
index 93c56a2f..f2f01e57 100644
--- a/font-viewer/font-view.c
+++ b/font-viewer/font-view.c
@@ -73,6 +73,22 @@ G_DEFINE_TYPE (FontViewApplication, font_view_application, GTK_TYPE_APPLICATION)
static void font_view_application_do_overview (FontViewApplication *self);
+static const gchar *app_menu =
+ "<interface>"
+ " <menu id=\"app-menu\">"
+ " <section>"
+ " <item>"
+ " <attribute name=\"action\">app.about</attribute>"
+ " <attribute name=\"label\" translatable=\"yes\">About Font Viewer</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name=\"action\">app.quit</attribute>"
+ " <attribute name=\"label\" translatable=\"yes\">Quit</attribute>"
+ " </item>"
+ " </section>"
+ " <menu>"
+ "</interface>";
+
#define VIEW_ITEM_WIDTH 140
#define VIEW_ITEM_WRAP_WIDTH 128
#define VIEW_COLUMN_SPACING 36
@@ -532,13 +548,65 @@ font_view_application_open (GApplication *application,
}
static void
+action_quit (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ FontViewApplication *self = user_data;
+ gtk_widget_destroy (self->main_window);
+}
+
+static void
+action_about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ FontViewApplication *self = user_data;
+ const gchar *authors[] = {
+ "Mate Developer",
+ "Cosimo Cecchi",
+ "James Henstridge",
+ NULL
+ };
+
+ gtk_show_about_dialog (GTK_WINDOW (self->main_window),
+ "version", VERSION,
+ "authors", authors,
+ "program-name", _("Font Viewer"),
+ "comments", _("View fonts on your system"),
+ "logo-icon-name", "preferences-desktop-font",
+ "translator-credits", _("translator-credits"),
+ "license-type", GTK_LICENSE_GPL_2_0,
+ "wrap-license", TRUE,
+ NULL);
+
+}
+
+static GActionEntry action_entries[] = {
+ { "about", action_about, NULL, NULL, NULL },
+ { "quit", action_quit, NULL, NULL, NULL }
+};
+
+static void
font_view_application_startup (GApplication *application)
{
FontViewApplication *self = FONT_VIEW_APPLICATION (application);
GtkWidget *window, *swin;
+ GtkBuilder *builder;
+ GMenuModel *menu;
G_APPLICATION_CLASS (font_view_application_parent_class)->startup (application);
+ g_action_map_add_action_entries (G_ACTION_MAP (self), action_entries,
+ G_N_ELEMENTS (action_entries), self);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_string (builder, app_menu, -1, NULL);
+ menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
+ gtk_application_set_app_menu (GTK_APPLICATION (self), menu);
+
+ g_object_unref (builder);
+ g_object_unref (menu);
+
self->model = font_view_model_new ();
self->main_window = window = gtk_application_window_new (GTK_APPLICATION (application));