[gnome-todo] window: Add an action to activate a workspace by id
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] window: Add an action to activate a workspace by id
- Date: Tue, 28 Apr 2020 17:00:38 +0000 (UTC)
commit e5b878ff3a07844dce194b89eccc4d21e77d4886
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Apr 28 13:53:12 2020 -0300
window: Add an action to activate a workspace by id
src/gtd-window.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/src/gtd-window.c b/src/gtd-window.c
index d96b809..94f410d 100644
--- a/src/gtd-window.c
+++ b/src/gtd-window.c
@@ -231,6 +231,20 @@ remove_all_workspace_header_widgets (GtdWindow *self)
*/
+static void
+on_action_activate_workspace_activated_cb (GSimpleAction *simple,
+ GVariant *state,
+ gpointer user_data)
+{
+ GtdWindow *self;
+ const gchar *workspace_id;
+
+ self = GTD_WINDOW (user_data);
+ workspace_id = g_variant_get_string (state, NULL);
+
+ gtk_stack_set_visible_child_name (self->stack, workspace_id);
+}
+
static gint
compare_workspaced_func (gconstpointer a,
gconstpointer b,
@@ -489,6 +503,15 @@ gtd_window_class_init (GtdWindowClass *klass)
static void
gtd_window_init (GtdWindow *self)
{
+ static const GActionEntry entries[] = {
+ { "activate-workspace", on_action_activate_workspace_activated_cb, "s" },
+ };
+
+ g_action_map_add_action_entries (G_ACTION_MAP (self),
+ entries,
+ G_N_ELEMENTS (entries),
+ self);
+
self->workspace_header_widgets = g_ptr_array_new_with_free_func (g_object_unref);
self->workspaces = g_list_store_new (GTD_TYPE_WORKSPACE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]