[gtk+/wip/matthiasc/help-overlay] widget-factory: Beef up help overlay
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/help-overlay] widget-factory: Beef up help overlay
- Date: Wed, 21 Oct 2015 17:18:23 +0000 (UTC)
commit 25629697f28379fbe29f15fe4aef3b8cca0f7f1d
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 21 11:58:59 2015 -0400
widget-factory: Beef up help overlay
Add bindings for page 3.
demos/widget-factory/help-overlay.ui | 28 ++++++++++++++
demos/widget-factory/widget-factory.c | 65 ++++++++++++++++++++++++++++++++
demos/widget-factory/widget-factory.ui | 2 +-
3 files changed, 94 insertions(+), 1 deletions(-)
---
diff --git a/demos/widget-factory/help-overlay.ui b/demos/widget-factory/help-overlay.ui
index 5502143..5f2d99f 100644
--- a/demos/widget-factory/help-overlay.ui
+++ b/demos/widget-factory/help-overlay.ui
@@ -58,6 +58,34 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">1</property>
+ <property name="title">Modern</property>
+ <property name="view">page3</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="accelerator"><Primary>o</property>
+ <property name="title">Open a file</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="accelerator"><Primary>r</property>
+ <property name="title">Start recording</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="accelerator"><Primary>l</property>
+ <property name="title">Lock or unlock</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 7956521..92de85d 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -128,6 +128,51 @@ activate_background (GSimpleAction *action,
}
static void
+activate_open (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkWidget *window = user_data;
+ GtkWidget *button;
+
+ if (!on_page (3))
+ return;
+
+ button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
+ gtk_button_clicked (GTK_BUTTON (button));
+}
+
+static void
+activate_record (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkWidget *window = user_data;
+ GtkWidget *button;
+
+ if (!on_page (3))
+ return;
+
+ button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "record_button"));
+ gtk_button_clicked (GTK_BUTTON (button));
+}
+
+static void
+activate_lock (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkWidget *window = user_data;
+ GtkWidget *button;
+
+ if (!on_page (3))
+ return;
+
+ button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "lockbutton"));
+ gtk_button_clicked (GTK_BUTTON (button));
+}
+
+static void
activate_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -1430,6 +1475,9 @@ activate (GApplication *app)
{ "delete", activate_delete, NULL, NULL, NULL },
{ "busy", get_busy, NULL, NULL, NULL },
{ "background", activate_background, NULL, NULL, NULL },
+ { "open", activate_open, NULL, NULL, NULL },
+ { "record", activate_record, NULL, NULL, NULL },
+ { "lock", activate_lock, NULL, NULL, NULL },
};
struct {
const gchar *action_and_target;
@@ -1441,9 +1489,13 @@ activate (GApplication *app)
{ "win.search", { "<Primary>s", NULL } },
{ "win.delete", { "Delete", NULL } },
{ "win.background", { "<Primary>b", NULL } },
+ { "win.open", { "<Primary>o", NULL } },
+ { "win.record", { "<Primary>r", NULL } },
+ { "win.lock", { "<Primary>l", NULL } },
};
gint i;
GPermission *permission;
+ GAction *action;
g_type_ensure (my_text_view_get_type ());
@@ -1635,13 +1687,26 @@ activate (GApplication *app)
gtk_popover_set_default_widget (GTK_POPOVER (widget), widget3);
g_signal_connect (widget2, "notify::text", G_CALLBACK (open_popover_text_changed), widget3);
g_signal_connect_swapped (widget3, "clicked", G_CALLBACK (gtk_widget_hide), widget);
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "open_menubutton");
+ g_object_set_data (G_OBJECT (window), "open_menubutton", widget);
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "record_button");
+ g_object_set_data (G_OBJECT (window), "record_button", widget);
widget = (GtkWidget *)gtk_builder_get_object (builder, "lockbox");
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "lockbutton");
+ g_object_set_data (G_OBJECT (window), "lockbutton", widget2);
permission = g_object_new (g_test_permission_get_type (), NULL);
g_object_bind_property (permission, "allowed",
widget, "sensitive",
G_BINDING_SYNC_CREATE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "open");
+ g_object_bind_property (permission, "allowed",
+ action, "enabled",
+ G_BINDING_SYNC_CREATE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "record");
+ g_object_bind_property (permission, "allowed",
+ action, "enabled",
+ G_BINDING_SYNC_CREATE);
gtk_lock_button_set_permission (GTK_LOCK_BUTTON (widget2), permission);
g_object_unref (permission);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 37d57ef..b90ca34 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -2911,7 +2911,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="halign">start</property>
<property name="spacing">6</property>
<child>
- <object class="GtkMenuButton">
+ <object class="GtkMenuButton" id="open_menubutton">
<property name="visible">1</property>
<property name="halign">center</property>
<property name="popover">open_popover</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]