summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid King <amigadave@amigadave.com>2015-05-07 10:42:11 +0700
committerDavid King <amigadave@amigadave.com>2015-05-07 10:42:11 +0700
commitb0d895dafa2e56765a5ea01d17eda773d3e0142c (patch)
treecf679ab5ca58ec0c5d5c298e91b3a66b4733130d
parent5f1283970c40b4727f51a90784b24cfbd04e5148 (diff)
downloadc-gnome-app-b0d895dafa2e56765a5ea01d17eda773d3e0142c.tar.gz
c-gnome-app-b0d895dafa2e56765a5ea01d17eda773d3e0142c.tar.xz
c-gnome-app-b0d895dafa2e56765a5ea01d17eda773d3e0142c.zip
Add a button and link it to the hello-world action
Create a button, and link it to the "app.hello-world" action, so that clicking it does the same as selecting the menu item or pressing the keyboard shortcut for that action.
-rw-r--r--c-gnome-app.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/c-gnome-app.c b/c-gnome-app.c
index d03f69b..e7fd3c5 100644
--- a/c-gnome-app.c
+++ b/c-gnome-app.c
@@ -37,6 +37,7 @@ on_startup (GApplication *app,
gpointer user_data)
{
GtkApplication *gtk_app;
+ GtkWidget *button;
const gchar * const hello_world_accel[] = { "<Primary>h", NULL };
const gchar * const quit_accel[] = { "<Primary>q", NULL };
GMenu *appmenu;
@@ -47,6 +48,11 @@ on_startup (GApplication *app,
g_action_map_add_action_entries (G_ACTION_MAP (app), actions,
G_N_ELEMENTS (actions), app);
window = gtk_application_window_new (gtk_app);
+
+ button = gtk_button_new_with_label ("Hello world!");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.hello-world");
+ gtk_container_add (GTK_CONTAINER (window), button);
+
gtk_application_set_accels_for_action (gtk_app,
"app.hello-world",
hello_world_accel);