diff options
| author | Matthew Fennell <matthew@fennell.dev> | 2025-12-27 12:40:20 +0000 |
|---|---|---|
| committer | Matthew Fennell <matthew@fennell.dev> | 2025-12-27 12:40:20 +0000 |
| commit | 5d8e439bc597159e3c9f0a8b65c0ae869dead3a8 (patch) | |
| tree | ed28aefed8add0da1c55c08fdf80b23c4346e0dc /src/plugins/task-lists-workspace | |
Import Upstream version 43.0upstream/latest
Diffstat (limited to 'src/plugins/task-lists-workspace')
22 files changed, 3968 insertions, 0 deletions
diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-list-row.c b/src/plugins/task-lists-workspace/gtd-sidebar-list-row.c new file mode 100644 index 0000000..5919665 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-list-row.c @@ -0,0 +1,333 @@ +/* gtd-sidebar-list-row.c + * + * Copyright 2018-2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "GtdSidebarListRow" + +#include "gtd-debug.h" +#include "gtd-manager.h" +#include "gtd-notification.h" +#include "gtd-provider.h" +#include "gtd-sidebar-list-row.h" +#include "gtd-task.h" +#include "gtd-task-list.h" +#include "gtd-utils.h" + +#include <math.h> +#include <glib/gi18n.h> + +struct _GtdSidebarListRow +{ + GtkListBoxRow parent; + + GtkImage *color_icon; + GtkLabel *name_label; + GtkLabel *tasks_counter_label; + + GtdTaskList *list; +}; + + +static void on_list_changed_cb (GtdSidebarListRow *self); + +static void on_list_color_changed_cb (GtdTaskList *list, + GParamSpec *pspec, + GtdSidebarListRow *self); + +G_DEFINE_TYPE (GtdSidebarListRow, gtd_sidebar_list_row, GTK_TYPE_LIST_BOX_ROW) + +enum +{ + PROP_0, + PROP_LIST, + N_PROPS +}; + +static GParamSpec *properties [N_PROPS]; + + +/* + * Auxiliary methods + */ + +static void +update_color_icon (GtdSidebarListRow *self) +{ + g_autoptr (GdkPaintable) paintable = NULL; + g_autoptr (GdkRGBA) color = NULL; + + color = gtd_task_list_get_color (self->list); + paintable = gtd_create_circular_paintable (color, 12); + + gtk_image_set_from_paintable (self->color_icon, paintable); +} + +static void +update_counter_label (GtdSidebarListRow *self) +{ + g_autofree gchar *label = NULL; + GListModel *model; + guint counter = 0; + guint i; + + model = G_LIST_MODEL (self->list); + + for (i = 0; i < g_list_model_get_n_items (model); i++) + counter += !gtd_task_get_complete (g_list_model_get_item (model, i)); + + label = counter > 0 ? g_strdup_printf ("%u", counter) : g_strdup (""); + + gtk_label_set_label (self->tasks_counter_label, label); +} + +static void +set_list (GtdSidebarListRow *self, + GtdTaskList *list) +{ + g_assert (list != NULL); + g_assert (self->list == NULL); + + self->list = g_object_ref (list); + + g_object_bind_property (list, + "name", + self->name_label, + "label", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + g_object_bind_property (gtd_task_list_get_provider (list), + "enabled", + self, + "visible", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + /* Always keep the counter label updated */ + g_signal_connect_object (list, "task-added", G_CALLBACK (on_list_changed_cb), self, G_CONNECT_SWAPPED); + g_signal_connect_object (list, "task-updated", G_CALLBACK (on_list_changed_cb), self, G_CONNECT_SWAPPED); + g_signal_connect_object (list, "task-removed", G_CALLBACK (on_list_changed_cb), self, G_CONNECT_SWAPPED); + + update_counter_label (self); + + /* And also the color icon */ + g_signal_connect_object (list, "notify::color", G_CALLBACK (on_list_color_changed_cb), self, 0); + + update_color_icon (self); +} + + +/* + * Callbacks + */ + +static void +on_import_task_cb (GObject *object, + GAsyncResult *result, + gpointer user_data) +{ + g_autoptr (GError) error = NULL; + + gtd_task_list_import_task_finish (GTD_TASK_LIST (object), result, &error); + + if (error) + g_warning ("Error updating task: %s", error->message); +} + +static void +on_list_changed_cb (GtdSidebarListRow *self) +{ + update_counter_label (self); +} + +static void +on_list_color_changed_cb (GtdTaskList *list, + GParamSpec *pspec, + GtdSidebarListRow *self) +{ + update_color_icon (self); +} + +static void +on_rename_popover_hidden_cb (GtkPopover *popover, + GtdSidebarListRow *self) +{ + /* + * Remove the relative to, to remove the popover from the widget + * list and avoid parsing any CSS for it. It's a small performance + * improvement. + */ + gtk_widget_set_parent (GTK_WIDGET (popover), NULL); +} + +static gboolean +on_task_drop (GtkDropTarget *target, + const GValue *value, + double x, + double y, + GtdSidebarListRow *self) +{ + GtdTask *task; + + GTD_ENTRY; + + task = g_value_get_object (value); + gtd_task_list_import_task (self->list, + task, + NULL, + on_import_task_cb, + self); + + GTD_RETURN (TRUE); +} + + +static gboolean +on_task_enter_drop (GtkDropTarget *target, + double x, + double y, + GtdSidebarListRow *self) +{ + GTD_ENTRY; + + gtk_widget_set_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_SELECTED , FALSE); + + GTD_RETURN (TRUE); +} + +static gboolean +on_task_leave_drop (GtkDropTarget *target, + double x, + double y, + GtdSidebarListRow *self) +{ + GTD_ENTRY; + + gtk_widget_unset_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_SELECTED); + + GTD_RETURN (TRUE); +} + +/* + * GObject overrides + */ + +static void +gtd_sidebar_list_row_finalize (GObject *object) +{ + GtdSidebarListRow *self = (GtdSidebarListRow *)object; + + g_clear_object (&self->list); + + G_OBJECT_CLASS (gtd_sidebar_list_row_parent_class)->finalize (object); +} + +static void +gtd_sidebar_list_row_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtdSidebarListRow *self = GTD_SIDEBAR_LIST_ROW (object); + + switch (prop_id) + { + case PROP_LIST: + g_value_set_object (value, self->list); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_sidebar_list_row_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtdSidebarListRow *self = GTD_SIDEBAR_LIST_ROW (object); + + switch (prop_id) + { + case PROP_LIST: + set_list (self, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_sidebar_list_row_class_init (GtdSidebarListRowClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->finalize = gtd_sidebar_list_row_finalize; + object_class->get_property = gtd_sidebar_list_row_get_property; + object_class->set_property = gtd_sidebar_list_row_set_property; + + properties[PROP_LIST] = g_param_spec_object ("list", + "List", + "The task list this row represents", + GTD_TYPE_TASK_LIST, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/plugins/task-lists-workspace/gtd-sidebar-list-row.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtdSidebarListRow, color_icon); + gtk_widget_class_bind_template_child (widget_class, GtdSidebarListRow, name_label); + gtk_widget_class_bind_template_child (widget_class, GtdSidebarListRow, tasks_counter_label); + + gtk_widget_class_bind_template_callback (widget_class, on_rename_popover_hidden_cb); +} + +static void +gtd_sidebar_list_row_init (GtdSidebarListRow *self) +{ + GtkDropTarget *target; + + gtk_widget_init_template (GTK_WIDGET (self)); + + target = gtk_drop_target_new (GTD_TYPE_TASK, GDK_ACTION_MOVE); + gtk_drop_target_set_preload (target, TRUE); + g_signal_connect (target, "drop", G_CALLBACK (on_task_drop), self); + g_signal_connect (target, "enter", G_CALLBACK (on_task_enter_drop), self); + g_signal_connect (target, "leave", G_CALLBACK (on_task_leave_drop), self); + gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (target)); +} + +GtkWidget* +gtd_sidebar_list_row_new (GtdTaskList *list) +{ + return g_object_new (GTD_TYPE_SIDEBAR_LIST_ROW, + "list", list, + NULL); +} + +GtdTaskList* +gtd_sidebar_list_row_get_task_list (GtdSidebarListRow *self) +{ + g_return_val_if_fail (GTD_IS_SIDEBAR_LIST_ROW (self), NULL); + + return self->list; +} diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-list-row.h b/src/plugins/task-lists-workspace/gtd-sidebar-list-row.h new file mode 100644 index 0000000..3660608 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-list-row.h @@ -0,0 +1,37 @@ +/* gtd-sidebar-list-row.h + * + * Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "gtd-types.h" + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GTD_TYPE_SIDEBAR_LIST_ROW (gtd_sidebar_list_row_get_type()) + +G_DECLARE_FINAL_TYPE (GtdSidebarListRow, gtd_sidebar_list_row, GTD, SIDEBAR_LIST_ROW, GtkListBoxRow) + +GtkWidget* gtd_sidebar_list_row_new (GtdTaskList *list); + +GtdTaskList* gtd_sidebar_list_row_get_task_list (GtdSidebarListRow *self); + +G_END_DECLS diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-list-row.ui b/src/plugins/task-lists-workspace/gtd-sidebar-list-row.ui new file mode 100644 index 0000000..380d1ed --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-list-row.ui @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="3.20"/> + <template class="GtdSidebarListRow" parent="GtkListBoxRow"> + <property name="can_focus">1</property> + <child> + <object class="GtkBox"> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="margin-start">6</property> + <property name="margin-end">6</property> + <property name="spacing">6</property> + <child> + <object class="GtkImage" id="color_icon"> + <property name="width-request">12</property> + <property name="height-request">12</property> + <property name="halign">center</property> + <property name="valign">center</property> + <style> + <class name="color-circle-icon"/> + </style> + </object> + </child> + <child> + <object class="GtkLabel" id="name_label"> + <property name="hexpand">1</property> + <property name="xalign">0</property> + </object> + </child> + <child> + <object class="GtkLabel" id="tasks_counter_label"> + <style> + <class name="caption"/> + <class name="dim-label"/> + </style> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.c b/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.c new file mode 100644 index 0000000..a379f24 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.c @@ -0,0 +1,180 @@ +/* gtd-sidebar-panel-row.c + * + * Copyright 2018-2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "gtd-panel.h" +#include "gtd-sidebar-panel-row.h" + +struct _GtdSidebarPanelRow +{ + GtkListBoxRow parent; + + GtkWidget *panel_icon; + GtkWidget *subtitle_label; + GtkWidget *title_label; + + GtdPanel *panel; +}; + +G_DEFINE_TYPE (GtdSidebarPanelRow, gtd_sidebar_panel_row, GTK_TYPE_LIST_BOX_ROW) + +enum +{ + PROP_0, + PROP_PANEL, + N_PROPS +}; + +static GParamSpec *properties [N_PROPS]; + + +/* + * Auxiliary methods + */ + +static void +set_panel (GtdSidebarPanelRow *self, + GtdPanel *panel) +{ + g_assert (panel != NULL); + g_assert (self->panel == NULL); + + self->panel = g_object_ref (panel); + + /* Bind panel properties to the row widgets */ + g_object_bind_property (self->panel, + "icon", + self->panel_icon, + "gicon", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + g_object_bind_property (self->panel, + "title", + self->title_label, + "label", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + g_object_bind_property (self->panel, + "subtitle", + self->subtitle_label, + "label", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PANEL]); +} + + +/* + * GObject overrides + */ + +static void +gtd_sidebar_panel_row_finalize (GObject *object) +{ + GtdSidebarPanelRow *self = (GtdSidebarPanelRow *)object; + + g_clear_object (&self->panel); + + G_OBJECT_CLASS (gtd_sidebar_panel_row_parent_class)->finalize (object); +} + +static void +gtd_sidebar_panel_row_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtdSidebarPanelRow *self = GTD_SIDEBAR_PANEL_ROW (object); + + switch (prop_id) + { + case PROP_PANEL: + g_value_set_object (value, self->panel); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_sidebar_panel_row_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtdSidebarPanelRow *self = GTD_SIDEBAR_PANEL_ROW (object); + + switch (prop_id) + { + case PROP_PANEL: + set_panel (self, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_sidebar_panel_row_class_init (GtdSidebarPanelRowClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->finalize = gtd_sidebar_panel_row_finalize; + object_class->get_property = gtd_sidebar_panel_row_get_property; + object_class->set_property = gtd_sidebar_panel_row_set_property; + + properties[PROP_PANEL] = g_param_spec_object ("panel", + "Panel", + "The panel this row represents", + GTD_TYPE_PANEL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/plugins/task-lists-workspace/gtd-sidebar-panel-row.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtdSidebarPanelRow, panel_icon); + gtk_widget_class_bind_template_child (widget_class, GtdSidebarPanelRow, subtitle_label); + gtk_widget_class_bind_template_child (widget_class, GtdSidebarPanelRow, title_label); +} + +static void +gtd_sidebar_panel_row_init (GtdSidebarPanelRow *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} + +GtkWidget* +gtd_sidebar_panel_row_new (GtdPanel *panel) +{ + return g_object_new (GTD_TYPE_SIDEBAR_PANEL_ROW, + "panel", panel, + NULL); +} + +GtdPanel* +gtd_sidebar_panel_row_get_panel (GtdSidebarPanelRow *self) +{ + g_return_val_if_fail (GTD_IS_SIDEBAR_PANEL_ROW (self), NULL); + + return self->panel; +} diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.h b/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.h new file mode 100644 index 0000000..58decde --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.h @@ -0,0 +1,37 @@ +/* gtd-sidebar-panel-row.h + * + * Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "gtd-types.h" + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GTD_TYPE_SIDEBAR_PANEL_ROW (gtd_sidebar_panel_row_get_type()) + +G_DECLARE_FINAL_TYPE (GtdSidebarPanelRow, gtd_sidebar_panel_row, GTD, SIDEBAR_PANEL_ROW, GtkListBoxRow) + +GtkWidget* gtd_sidebar_panel_row_new (GtdPanel *panel); + +GtdPanel* gtd_sidebar_panel_row_get_panel (GtdSidebarPanelRow *self); + +G_END_DECLS diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.ui b/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.ui new file mode 100644 index 0000000..5722bd8 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-panel-row.ui @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="3.20"/> + <template class="GtdSidebarPanelRow" parent="GtkListBoxRow"> + <property name="can_focus">1</property> + <child> + <object class="GtkBox"> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="margin-start">6</property> + <property name="margin-end">6</property> + <property name="spacing">12</property> + <child> + <object class="GtkImage" id="panel_icon"/> + </child> + <child> + <object class="GtkLabel" id="title_label"> + <property name="hexpand">1</property> + <property name="xalign">0</property> + </object> + </child> + <child> + <object class="GtkLabel" id="subtitle_label"> + <property name="xalign">1.0</property> + <style> + <class name="caption"/> + <class name="dim-label"/> + </style> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.c b/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.c new file mode 100644 index 0000000..19bb256 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.c @@ -0,0 +1,300 @@ +/* gtd-sidebar-provider-row.c + * + * Copyright 2018-2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "GtdSidebarProviderRow" + +#include "gtd-debug.h" +#include "gtd-manager.h" +#include "gtd-provider.h" +#include "gtd-sidebar-provider-row.h" + +struct _GtdSidebarProviderRow +{ + GtkListBoxRow parent; + + GtkWidget *loading_label; + GtkLabel *provider_label; + GtkStack *stack; + + GtdProvider *provider; +}; + +static void on_provider_changed_cb (GtdManager *manager, + GtdProvider *provider, + GtdSidebarProviderRow *self); + +static void on_provider_lists_changed_cb (GtdProvider *provider, + GtdTaskList *list, + GtdSidebarProviderRow *self); + +static void on_provider_notify_loading_cb (GtdProvider *provider, + GParamSpec *pspec, + GtdSidebarProviderRow *self); + +G_DEFINE_TYPE (GtdSidebarProviderRow, gtd_sidebar_provider_row, GTK_TYPE_LIST_BOX_ROW) + +enum +{ + PROP_0, + PROP_PROVIDER, + N_PROPS +}; + +static GParamSpec *properties [N_PROPS]; + + +/* + * Auxiliary methods + */ + +static void +update_provider_label (GtdSidebarProviderRow *self) +{ + g_autoptr (GList) providers = NULL; + GtdManager *manager; + GList *l; + gboolean is_unique; + const gchar *title; + + manager = gtd_manager_get_default (); + providers = gtd_manager_get_providers (manager); + is_unique = TRUE; + + /* + * We need to check if there is another provider with + * the same GType of the provider. + */ + for (l = providers; l; l = l->next) + { + GtdProvider *provider = l->data; + + if (self->provider != provider && + g_str_equal (gtd_provider_get_provider_type (self->provider), gtd_provider_get_provider_type (provider))) + { + is_unique = FALSE; + break; + } + } + + if (is_unique) + title = gtd_provider_get_name (self->provider); + else + title = gtd_provider_get_description (self->provider); + + gtk_label_set_label (self->provider_label, title); +} + +static void +update_loading_state (GtdSidebarProviderRow *self) +{ + g_autoptr (GList) lists = NULL; + gboolean is_loading; + gboolean has_lists; + + g_assert (self->provider != NULL); + + lists = gtd_provider_get_task_lists (self->provider); + is_loading = gtd_object_get_loading (GTD_OBJECT (self->provider)); + has_lists = lists != NULL; + + GTD_TRACE_MSG ("'%s' (%s): is_loading: %d, has_lists: %d", + gtd_provider_get_name (self->provider), + gtd_provider_get_id (self->provider), + is_loading, + has_lists); + + gtk_stack_set_visible_child_name (self->stack, is_loading ? "spinner" : "empty"); + gtk_widget_set_visible (self->loading_label, is_loading && !has_lists); +} + +static void +set_provider (GtdSidebarProviderRow *self, + GtdProvider *provider) +{ + GtdManager *manager; + + g_assert (provider != NULL); + g_assert (self->provider == NULL); + + self->provider = g_object_ref (provider); + + g_object_bind_property (provider, + "enabled", + self, + "visible", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + /* Setup the title label */ + manager = gtd_manager_get_default (); + + g_signal_connect_object (manager, "provider-added", G_CALLBACK (on_provider_changed_cb), self, 0); + g_signal_connect_object (manager, "provider-removed", G_CALLBACK (on_provider_changed_cb), self, 0); + + update_provider_label (self); + + /* And the icon */ + g_signal_connect_object (provider, "notify::loading", G_CALLBACK (on_provider_notify_loading_cb), self, 0); + g_signal_connect_object (provider, "list-added", G_CALLBACK (on_provider_lists_changed_cb), self, 0); + g_signal_connect_object (provider, "list-removed", G_CALLBACK (on_provider_lists_changed_cb), self, 0); + + update_loading_state (self); +} + + +/* + * Callbacks + */ + +static void +on_provider_changed_cb (GtdManager *manager, + GtdProvider *provider, + GtdSidebarProviderRow *self) +{ + update_provider_label (self); +} + +static void +on_provider_lists_changed_cb (GtdProvider *provider, + GtdTaskList *list, + GtdSidebarProviderRow *self) +{ + update_loading_state (self); +} + +static void +on_provider_notify_loading_cb (GtdProvider *provider, + GParamSpec *pspec, + GtdSidebarProviderRow *self) +{ + update_loading_state (self); +} + + +/* + * GObject overrides + */ + +static void +gtd_sidebar_provider_row_finalize (GObject *object) +{ + GtdSidebarProviderRow *self = (GtdSidebarProviderRow *)object; + + g_clear_object (&self->provider); + + G_OBJECT_CLASS (gtd_sidebar_provider_row_parent_class)->finalize (object); +} + +static void +gtd_sidebar_provider_row_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtdSidebarProviderRow *self = GTD_SIDEBAR_PROVIDER_ROW (object); + + switch (prop_id) + { + case PROP_PROVIDER: + g_value_set_object (value, self->provider); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_sidebar_provider_row_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtdSidebarProviderRow *self = GTD_SIDEBAR_PROVIDER_ROW (object); + + switch (prop_id) + { + case PROP_PROVIDER: + set_provider (self, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + + +/* + * GtkWidget overrides + */ + +static void +gtd_sidebar_provider_row_class_init (GtdSidebarProviderRowClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->finalize = gtd_sidebar_provider_row_finalize; + object_class->get_property = gtd_sidebar_provider_row_get_property; + object_class->set_property = gtd_sidebar_provider_row_set_property; + + properties[PROP_PROVIDER] = g_param_spec_object ("provider", + "Provider", + "Provider of the row", + GTD_TYPE_PROVIDER, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/plugins/task-lists-workspace/gtd-sidebar-provider-row.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtdSidebarProviderRow, loading_label); + gtk_widget_class_bind_template_child (widget_class, GtdSidebarProviderRow, provider_label); + gtk_widget_class_bind_template_child (widget_class, GtdSidebarProviderRow, stack); +} + +static void +gtd_sidebar_provider_row_init (GtdSidebarProviderRow *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} + +GtkWidget* +gtd_sidebar_provider_row_new (GtdProvider *provider) +{ + return g_object_new (GTD_TYPE_SIDEBAR_PROVIDER_ROW, + "provider", provider, + NULL); +} + +GtdProvider* +gtd_sidebar_provider_row_get_provider (GtdSidebarProviderRow *self) +{ + g_return_val_if_fail (GTD_IS_SIDEBAR_PROVIDER_ROW (self), NULL); + + return self->provider; +} + +void +gtd_sidebar_provider_row_popup_menu (GtdSidebarProviderRow *self) +{ + g_assert (GTD_IS_SIDEBAR_PROVIDER_ROW (self)); + + /* TODO: Implement me */ +} diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.h b/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.h new file mode 100644 index 0000000..640e6b2 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.h @@ -0,0 +1,39 @@ +/* gtd-sidebar-provider-row.h + * + * Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "gtd-types.h" + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GTD_TYPE_SIDEBAR_PROVIDER_ROW (gtd_sidebar_provider_row_get_type()) + +G_DECLARE_FINAL_TYPE (GtdSidebarProviderRow, gtd_sidebar_provider_row, GTD, SIDEBAR_PROVIDER_ROW, GtkListBoxRow) + +GtkWidget* gtd_sidebar_provider_row_new (GtdProvider *provider); + +GtdProvider* gtd_sidebar_provider_row_get_provider (GtdSidebarProviderRow *self); + +void gtd_sidebar_provider_row_popup_menu (GtdSidebarProviderRow *self); + +G_END_DECLS diff --git a/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.ui b/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.ui new file mode 100644 index 0000000..e97e318 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar-provider-row.ui @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="3.20"/> + <template class="GtdSidebarProviderRow" parent="GtkListBoxRow"> + <property name="can_focus">1</property> + <property name="selectable">0</property> + <property name="activatable">0</property> + <property name="margin_top">6</property> + <child> + <object class="GtkBox"> + <property name="margin_top">6</property> + <property name="spacing">3</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox"> + <property name="margin_start">6</property> + <property name="margin_end">6</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="provider_label"> + <property name="hexpand">1</property> + <property name="xalign">0.0</property> + <style> + <class name="caption-heading"/> + <class name="dim-label"/> + </style> + </object> + </child> + <child> + <object class="GtkStack" id="stack"> + <property name="transition-type">crossfade</property> + <child> + <object class="GtkStackPage"> + <property name="name">spinner</property> + <property name="child"> + <object class="GtkSpinner"> + <property name="spinning">true</property> + </object> + </property> + </object> + </child> + <child> + <object class="GtkStackPage"> + <property name="name">empty</property> + <property name="child"> + <object class="GtkBox"/> + </property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkSeparator"/> + </child> + <child> + <object class="GtkLabel" id="loading_label"> + <property name="margin-start">6</property> + <property name="margin-end">6</property> + <property name="margin-top">6</property> + <property name="margin-bottom">12</property> + <property name="xalign">0.0</property> + <property name="label" translatable="yes">Loading…</property> + <style> + <class name="caption"/> + <class name="dim-label"/> + </style> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/src/plugins/task-lists-workspace/gtd-sidebar.c b/src/plugins/task-lists-workspace/gtd-sidebar.c new file mode 100644 index 0000000..0f5760b --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar.c @@ -0,0 +1,929 @@ +/* gtd-sidebar.c + * + * Copyright 2018-2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "GtdSidebar" + +#include "gtd-debug.h" +#include "gtd-manager.h" +#include "gtd-max-size-layout.h" +#include "gtd-notification.h" +#include "gtd-panel.h" +#include "gtd-provider.h" +#include "gtd-sidebar.h" +#include "gtd-sidebar-list-row.h" +#include "gtd-sidebar-panel-row.h" +#include "gtd-sidebar-provider-row.h" +#include "gtd-task-list.h" +#include "gtd-task-list-panel.h" +#include "gtd-utils.h" + +#include <glib/gi18n.h> + +struct _GtdSidebar +{ + GtdWidget parent; + + GtkListBox *archive_listbox; + GtkListBoxRow *archive_row; + GtkListBox *listbox; + GtkStack *stack; + + GtkStack *panel_stack; + GtdPanel *task_list_panel; + + GSimpleActionGroup *action_group; +}; + +G_DEFINE_TYPE (GtdSidebar, gtd_sidebar, GTD_TYPE_WIDGET) + + +/* + * Auxiliary methods + */ + +static gboolean +activate_row_below (GtdSidebar *self, + GtdSidebarListRow *current_row) +{ + GtkWidget *next_row; + GtkWidget *parent; + GtkWidget *child; + gboolean after_deleted; + + parent = gtk_widget_get_parent (GTK_WIDGET (current_row)); + after_deleted = FALSE; + next_row = NULL; + + for (child = gtk_widget_get_first_child (parent); + child; + child = gtk_widget_get_next_sibling (child)) + { + if (child == (GtkWidget*) current_row) + { + after_deleted = TRUE; + continue; + } + + if (!gtk_widget_get_visible (child) || + !gtk_list_box_row_get_activatable (GTK_LIST_BOX_ROW (child))) + { + continue; + } + + next_row = child; + + if (after_deleted) + break; + } + + if (next_row) + g_signal_emit_by_name (next_row, "activate"); + + return next_row != NULL; +} + +static void +add_task_list (GtdSidebar *self, + GtdTaskList *list) +{ + if (gtd_task_list_is_inbox (list)) + return; + + g_debug ("Adding task list '%s'", gtd_task_list_get_name (list)); + + if (!gtd_task_list_get_archived (list)) + { + gtk_list_box_prepend (self->listbox, gtd_sidebar_list_row_new (list)); + gtk_list_box_invalidate_filter (self->listbox); + } + else + { + gtk_list_box_prepend (self->archive_listbox, gtd_sidebar_list_row_new (list)); + gtk_list_box_invalidate_filter (self->archive_listbox); + } +} + +static void +add_panel (GtdSidebar *self, + GtdPanel *panel) +{ + GtkWidget *row; + + g_debug ("Adding panel '%s'", gtd_panel_get_panel_name (panel)); + + row = gtd_sidebar_panel_row_new (panel); + + gtk_list_box_prepend (self->listbox, row); +} + +static void +add_provider (GtdSidebar *self, + GtdProvider *provider) +{ + g_debug ("Adding provider '%s'", gtd_provider_get_name (provider)); + + gtk_list_box_prepend (self->listbox, gtd_sidebar_provider_row_new (provider)); + gtk_list_box_prepend (self->archive_listbox, gtd_sidebar_provider_row_new (provider)); +} + +static gint +compare_panels (GtdSidebarPanelRow *row_a, + GtdSidebarPanelRow *row_b) +{ + GtdPanel *panel_a; + GtdPanel *panel_b; + + panel_a = gtd_sidebar_panel_row_get_panel (row_a); + panel_b = gtd_sidebar_panel_row_get_panel (row_b); + + return gtd_panel_get_priority (panel_b) - gtd_panel_get_priority (panel_a); +} + +static gint +compare_providers (GtdSidebarProviderRow *row_a, + GtdSidebarProviderRow *row_b) +{ + GtdProvider *provider_a; + GtdProvider *provider_b; + + provider_a = gtd_sidebar_provider_row_get_provider (row_a); + provider_b = gtd_sidebar_provider_row_get_provider (row_b); + + return gtd_provider_compare (provider_a, provider_b); +} + +static gint +compare_lists (GtdSidebarListRow *row_a, + GtdSidebarListRow *row_b) +{ + GtdTaskList *list_a; + GtdTaskList *list_b; + gint result; + + list_a = gtd_sidebar_list_row_get_task_list (row_a); + list_b = gtd_sidebar_list_row_get_task_list (row_b); + + /* First, compare by their providers */ + result = gtd_provider_compare (gtd_task_list_get_provider (list_a), gtd_task_list_get_provider (list_b)); + + if (result != 0) + return result; + + return gtd_collate_compare_strings (gtd_task_list_get_name (list_a), gtd_task_list_get_name (list_b)); +} + +typedef gpointer (*GetDataFunc) (gpointer data); + +static gpointer +get_row_internal (GtdSidebar *self, + GtkListBox *listbox, + GType type, + GetDataFunc get_data_func, + gpointer data) +{ + GtkWidget *child; + + for (child = gtk_widget_get_first_child (GTK_WIDGET (listbox)); + child; + child = gtk_widget_get_next_sibling (child)) + { + if (g_type_is_a (G_OBJECT_TYPE (child), type) && get_data_func (child) == data) + return child; + } + + return NULL; +} + +static GtkListBoxRow* +get_row_for_panel (GtdSidebar *self, + GtdPanel *panel) +{ + return get_row_internal (self, + self->listbox, + GTD_TYPE_SIDEBAR_PANEL_ROW, + (GetDataFunc) gtd_sidebar_panel_row_get_panel, + panel); +} + +static GtkListBoxRow* +get_row_for_provider (GtdSidebar *self, + GtkListBox *listbox, + GtdProvider *provider) +{ + return get_row_internal (self, + listbox, + GTD_TYPE_SIDEBAR_PROVIDER_ROW, + (GetDataFunc) gtd_sidebar_provider_row_get_provider, + provider); +} + +static GtkListBoxRow* +get_row_for_task_list (GtdSidebar *self, + GtkListBox *listbox, + GtdTaskList *list) +{ + return get_row_internal (self, + listbox, + GTD_TYPE_SIDEBAR_LIST_ROW, + (GetDataFunc) gtd_sidebar_list_row_get_task_list, + list); +} + +static void +activate_appropriate_row (GtdSidebar *self, + GtkListBoxRow *row) +{ + GtkListBoxRow *to_be_activated; + + if (activate_row_below (self, GTD_SIDEBAR_LIST_ROW (row))) + return; + + gtk_widget_activate_action (GTK_WIDGET (self), + "task-lists-workspace.toggle-archive", + "b", + FALSE); + + to_be_activated = gtk_list_box_get_row_at_index (self->listbox, 0); + g_signal_emit_by_name (to_be_activated, "activate"); +} + +/* + * Callbacks + */ + +static void +on_action_move_up_activated_cb (GSimpleAction *simple, + GVariant *parameters, + gpointer user_data) +{ + GtkListBoxRow *selected_row; + GtkListBoxRow *previous_row; + GtdSidebar *self; + gint selected_row_index; + + GTD_ENTRY; + + self = GTD_SIDEBAR (user_data); + selected_row = gtk_list_box_get_selected_row (self->listbox); + g_assert (selected_row != NULL); + + selected_row_index = gtk_list_box_row_get_index (selected_row); + if (selected_row_index == 0) + return; + + do + { + previous_row = gtk_list_box_get_row_at_index (self->listbox, + --selected_row_index); + } + while (previous_row && + (previous_row == self->archive_row || + !gtk_list_box_row_get_activatable (previous_row))); + + + if (previous_row) + g_signal_emit_by_name (previous_row, "activate"); + + GTD_EXIT; +} + +static void +on_action_move_down_activated_cb (GSimpleAction *simple, + GVariant *parameters, + gpointer user_data) +{ + GtkListBoxRow *selected_row; + GtkListBoxRow *next_row; + GtdSidebar *self; + gint selected_row_index; + + GTD_ENTRY; + + self = GTD_SIDEBAR (user_data); + selected_row = gtk_list_box_get_selected_row (self->listbox); + g_assert (selected_row != NULL); + + selected_row_index = gtk_list_box_row_get_index (selected_row); + + do + { + next_row = gtk_list_box_get_row_at_index (self->listbox, + ++selected_row_index); + } + while (next_row && + (next_row == self->archive_row || + !gtk_list_box_row_get_activatable (next_row))); + + + if (next_row) + g_signal_emit_by_name (next_row, "activate"); + + GTD_EXIT; +} + +static void +on_panel_added_cb (GtdManager *manager, + GtdPanel *panel, + GtdSidebar *self) +{ + add_panel (self, panel); +} + +static void +on_panel_removed_cb (GtdManager *manager, + GtdPanel *panel, + GtdSidebar *self) +{ + GtkListBoxRow *row = get_row_for_panel (self, panel); + + g_debug ("Removing panel '%s'", gtd_panel_get_panel_name (panel)); + + if (row) + gtk_list_box_remove (self->listbox, GTK_WIDGET (row)); +} + +static void +on_provider_task_list_removed_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + g_autoptr (GError) error = NULL; + + gtd_provider_remove_task_list_finish (GTD_PROVIDER (source), result, &error); +} + +static void +delete_list_cb (GtdNotification *notification, + gpointer user_data) +{ + GtdTaskList *list; + GtdProvider *provider; + + list = GTD_TASK_LIST (user_data); + provider = gtd_task_list_get_provider (list); + + g_assert (provider != NULL); + g_assert (gtd_task_list_is_removable (list)); + + gtd_provider_remove_task_list (provider, + list, + NULL, + on_provider_task_list_removed_cb, + NULL); +} + +static void +undo_delete_list_cb (GtdNotification *notification, + gpointer user_data) +{ + g_assert (GTD_IS_SIDEBAR_LIST_ROW (user_data)); + + gtk_widget_show (GTK_WIDGET (user_data)); +} + +static void +on_task_list_panel_list_deleted_cb (GtdTaskListPanel *panel, + GtdTaskList *list, + GtdSidebar *self) +{ + GtdSidebarListRow *row; + GtdNotification *notification; + g_autofree gchar *title = NULL; + + if (gtd_task_list_get_archived (list)) + row = (GtdSidebarListRow*) get_row_for_task_list (self, self->archive_listbox, list); + else + row = (GtdSidebarListRow*) get_row_for_task_list (self, self->listbox, list); + + g_assert (row != NULL && GTD_IS_SIDEBAR_LIST_ROW (row)); + + GTD_TRACE_MSG ("Removing task list row from sidebar"); + + title = g_strdup_printf (_("Task list <b>%s</b> removed"), gtd_task_list_get_name (list)); + notification = gtd_notification_new (title); + gtd_notification_set_dismissal_action (notification, delete_list_cb, list); + gtd_notification_set_secondary_action (notification, _("Undo"), undo_delete_list_cb, row); + + gtd_manager_send_notification (gtd_manager_get_default (), notification); + + /* + * If the deleted list is selected, go to the next one (or previous, if + * there are no other task list after this one). + */ + if (gtk_list_box_row_is_selected (GTK_LIST_BOX_ROW (row))) + activate_appropriate_row (self, GTK_LIST_BOX_ROW (row)); + + gtk_widget_hide (GTK_WIDGET (row)); +} + +static void +on_listbox_row_activated_cb (GtkListBox *panels_listbox, + GtkListBoxRow *row, + GtdSidebar *self) +{ + if (GTD_IS_SIDEBAR_PANEL_ROW (row)) + { + GtdPanel *panel = gtd_sidebar_panel_row_get_panel (GTD_SIDEBAR_PANEL_ROW (row)); + + gtk_widget_activate_action (GTK_WIDGET (self), + "task-lists-workspace.activate-panel", + "(sv)", + gtd_panel_get_panel_name (panel), + g_variant_new_maybe (G_VARIANT_TYPE_VARIANT, NULL)); + } + else if (GTD_IS_SIDEBAR_PROVIDER_ROW (row)) + { + /* Do nothing */ + } + else if (GTD_IS_SIDEBAR_LIST_ROW (row)) + { + GVariantBuilder builder; + GtdProvider *provider; + GtdTaskList *list; + + list = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row)); + provider = gtd_task_list_get_provider (list); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, "{sv}", + "provider-id", + g_variant_new_string (gtd_provider_get_id (provider))); + g_variant_builder_add (&builder, "{sv}", + "task-list-id", + g_variant_new_string (gtd_object_get_uid (GTD_OBJECT (list)))); + + gtk_widget_activate_action (GTK_WIDGET (self), + "task-lists-workspace.activate-panel", + "(sv)", + "task-list-panel", + g_variant_builder_end (&builder)); + } + else if (row == self->archive_row) + { + gtk_widget_activate_action (GTK_WIDGET (self), + "task-lists-workspace.toggle-archive", + "b", + TRUE); + } + else + { + g_assert_not_reached (); + } +} + +static void +on_panel_stack_visible_child_changed_cb (GtkStack *panel_stack, + GParamSpec *pspec, + GtdSidebar *self) +{ + GtkListBoxRow *panel_row; + GtkListBox *listbox; + GtdPanel *visible_panel; + + GTD_ENTRY; + + g_assert (GTD_IS_PANEL (gtk_stack_get_visible_child (panel_stack))); + + visible_panel = GTD_PANEL (gtk_stack_get_visible_child (panel_stack)); + listbox = self->listbox; + + /* + * If the currently visible panel is the tasklist panel, we + * should choose the tasklist that is visible. Otherwise, + * just select the panel. + */ + if (visible_panel == self->task_list_panel) + { + GtdTaskList *task_list; + + task_list = gtd_task_list_panel_get_task_list (GTD_TASK_LIST_PANEL (self->task_list_panel)); + g_assert (task_list != NULL); + + panel_row = get_row_for_task_list (self, self->listbox, task_list); + + if (!panel_row) + { + panel_row = get_row_for_task_list (self, self->archive_listbox, task_list); + listbox = self->archive_listbox; + } + } + else + { + panel_row = get_row_for_panel (self, visible_panel); + } + + /* Select the row if it's not already selected*/ + if (!gtk_list_box_row_is_selected (panel_row)) + gtk_list_box_select_row (listbox, panel_row); + + GTD_EXIT; +} + +static void +on_provider_added_cb (GtdManager *manager, + GtdProvider *provider, + GtdSidebar *self) +{ + add_provider (self, provider); +} + +static void +on_provider_removed_cb (GtdManager *manager, + GtdProvider *provider, + GtdSidebar *self) +{ + GtkListBoxRow *row; + + g_debug ("Removing provider '%s'", gtd_provider_get_name (provider)); + + row = get_row_for_provider (self, self->listbox, provider); + gtk_list_box_remove (self->listbox, GTK_WIDGET (row)); + + row = get_row_for_provider (self, self->archive_listbox, provider); + gtk_list_box_remove (self->archive_listbox, GTK_WIDGET (row)); +} + + +static void +on_task_list_added_cb (GtdManager *manager, + GtdTaskList *list, + GtdSidebar *self) +{ + add_task_list (self, list); +} + +static void +on_task_list_changed_cb (GtdManager *manager, + GtdTaskList *list, + GtdSidebar *self) +{ + GtkListBoxRow *row; + GtkListBox *listbox; + gboolean archived; + + archived = gtd_task_list_get_archived (list); + listbox = archived ? self->archive_listbox : self->listbox; + row = get_row_for_task_list (self, listbox, list); + + /* + * The task was either archived or unarchived; remove it and add to + * the appropriate listbox. + */ + if (!row) + { + listbox = archived ? self->listbox : self->archive_listbox; + row = get_row_for_task_list (self, listbox, list); + + if (!row) + goto out; + + /* Change to another panel or taklist */ + if (gtk_list_box_row_is_selected (row)) + activate_appropriate_row (self, row); + + /* Destroy the old row */ + gtk_list_box_remove (listbox, GTK_WIDGET (row)); + + /* Add a new row */ + add_task_list (self, list); + } + +out: + gtk_list_box_invalidate_filter (listbox); +} + +static void +on_task_list_removed_cb (GtdManager *manager, + GtdTaskList *list, + GtdSidebar *self) +{ + GtkListBoxRow *row; + GtkListBox *listbox; + + g_debug ("Removing task list '%s'", gtd_task_list_get_name (list)); + + g_assert (!gtd_task_list_is_inbox (list)); + + if (!gtd_task_list_get_archived (list)) + listbox = self->listbox; + else + listbox = self->archive_listbox; + + row = get_row_for_task_list (self, listbox, list); + if (!row) + return; + + gtk_list_box_remove (listbox, GTK_WIDGET (row)); + gtk_list_box_invalidate_filter (listbox); +} + +static gboolean +filter_archive_listbox_cb (GtkListBoxRow *row, + gpointer user_data) +{ + if (GTD_IS_SIDEBAR_LIST_ROW (row)) + { + GtdTaskList *list; + + list = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row)); + return gtd_task_list_get_archived (list); + } + else if (GTD_IS_SIDEBAR_PROVIDER_ROW (row)) + { + g_autoptr (GList) lists = NULL; + GtdProvider *provider; + GList *l; + + provider = gtd_sidebar_provider_row_get_provider (GTD_SIDEBAR_PROVIDER_ROW (row)); + lists = gtd_provider_get_task_lists (provider); + + for (l = lists; l; l = l->next) + { + if (gtd_task_list_get_archived (l->data)) + return TRUE; + } + + return FALSE; + } + else + { + g_assert_not_reached (); + } + + return FALSE; +} + +static gboolean +filter_listbox_cb (GtkListBoxRow *row, + gpointer user_data) +{ + GtdTaskList *list; + + if (!GTD_IS_SIDEBAR_LIST_ROW (row)) + return TRUE; + + list = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row)); + return !gtd_task_list_get_archived (list); +} + +static gint +sort_listbox_cb (GtkListBoxRow *row_a, + GtkListBoxRow *row_b, + gpointer user_data) +{ + GtdSidebar *self = GTD_SIDEBAR (user_data); + + /* Special-case the Archive row */ + if (row_a == self->archive_row || row_b == self->archive_row) + { + if (GTD_IS_SIDEBAR_PANEL_ROW (row_b)) + return 1; + else + return -1; + } + + if (G_OBJECT_TYPE (row_a) != G_OBJECT_TYPE (row_b)) + { + gint result; + + /* Panels go above everything else */ + if (GTD_IS_SIDEBAR_PANEL_ROW (row_b) != GTD_IS_SIDEBAR_PANEL_ROW (row_a)) + return GTD_IS_SIDEBAR_PANEL_ROW (row_b) - GTD_IS_SIDEBAR_PANEL_ROW (row_a); + + /* + * At this point, we know that row_a and row_b are either provider rows, or + * tasklist rows. We also know that they're different, i.e. if row_a is a + * provider row, row_b will be a list one, and vice-versa. + */ + if (GTD_IS_SIDEBAR_PROVIDER_ROW (row_a)) + { + GtdProvider *provider_a; + GtdTaskList *list_b; + + provider_a = gtd_sidebar_provider_row_get_provider (GTD_SIDEBAR_PROVIDER_ROW (row_a)); + list_b = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row_b)); + + /* + * If the providers are different, respect the provider order. If the providers are the + * same, we must put the provider row above the tasklist row. + */ + result = gtd_provider_compare (provider_a, gtd_task_list_get_provider (list_b)); + + if (result != 0) + return result; + + return -1; + } + else + { + GtdTaskList *list_a; + GtdProvider *provider_b; + + list_a = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row_a)); + provider_b = gtd_sidebar_provider_row_get_provider (GTD_SIDEBAR_PROVIDER_ROW (row_b)); + + /* See comment above */ + result = gtd_provider_compare (gtd_task_list_get_provider (list_a), provider_b); + + if (result != 0) + return result; + + return 1; + } + } + else + { + /* + * We only reach this section of the code if both rows are of the same type, + * so it doesn't matter which one we get the type from. + */ + + if (GTD_IS_SIDEBAR_PANEL_ROW (row_a)) + return compare_panels (GTD_SIDEBAR_PANEL_ROW (row_a), GTD_SIDEBAR_PANEL_ROW (row_b)); + + if (GTD_IS_SIDEBAR_PROVIDER_ROW (row_a)) + return compare_providers (GTD_SIDEBAR_PROVIDER_ROW (row_a), GTD_SIDEBAR_PROVIDER_ROW (row_b)); + + if (GTD_IS_SIDEBAR_LIST_ROW (row_a)) + return compare_lists (GTD_SIDEBAR_LIST_ROW (row_a), GTD_SIDEBAR_LIST_ROW (row_b)); + } + + return 0; +} + + +/* + * GObject overrides + */ + +static void +gtd_sidebar_constructed (GObject *object) +{ + g_autoptr (GList) providers = NULL; + GListModel *lists; + GtdManager *manager; + GtdSidebar *self; + GList *l; + guint i; + + self = (GtdSidebar *)object; + manager = gtd_manager_get_default (); + + G_OBJECT_CLASS (gtd_sidebar_parent_class)->constructed (object); + + /* Add providers */ + providers = gtd_manager_get_providers (manager); + + for (l = providers; l; l = l->next) + add_provider (self, l->data); + + g_signal_connect (manager, "provider-added", G_CALLBACK (on_provider_added_cb), self); + g_signal_connect (manager, "provider-removed", G_CALLBACK (on_provider_removed_cb), self); + + /* Add task lists */ + lists = gtd_manager_get_task_lists_model (manager); + + for (i = 0; i < g_list_model_get_n_items (lists); i++) + { + g_autoptr (GtdTaskList) list = g_list_model_get_item (lists, i); + + add_task_list (self, list); + } + + g_signal_connect (manager, "list-added", G_CALLBACK (on_task_list_added_cb), self); + g_signal_connect (manager, "list-changed", G_CALLBACK (on_task_list_changed_cb), self); + g_signal_connect (manager, "list-removed", G_CALLBACK (on_task_list_removed_cb), self); +} + +static void +gtd_sidebar_class_init (GtdSidebarClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->constructed = gtd_sidebar_constructed; + + g_type_ensure (GTD_TYPE_MAX_SIZE_LAYOUT); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/plugins/task-lists-workspace/gtd-sidebar.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtdSidebar, archive_listbox); + gtk_widget_class_bind_template_child (widget_class, GtdSidebar, archive_row); + gtk_widget_class_bind_template_child (widget_class, GtdSidebar, listbox); + gtk_widget_class_bind_template_child (widget_class, GtdSidebar, stack); + + gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb); + + gtk_widget_class_set_css_name (widget_class, "sidebar"); +} + +static void +gtd_sidebar_init (GtdSidebar *self) +{ + static const GActionEntry entries[] = { + { "move-up", on_action_move_up_activated_cb }, + { "move-down", on_action_move_down_activated_cb }, + }; + gtk_widget_init_template (GTK_WIDGET (self)); + + gtk_list_box_set_sort_func (self->listbox, sort_listbox_cb, self, NULL); + gtk_list_box_set_filter_func (self->listbox, filter_listbox_cb, self, NULL); + + gtk_list_box_set_sort_func (self->archive_listbox, sort_listbox_cb, self, NULL); + gtk_list_box_set_filter_func (self->archive_listbox, filter_archive_listbox_cb, self, NULL); + + self->action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP (self->action_group), + entries, + G_N_ELEMENTS (entries), + self); + + gtk_widget_insert_action_group (GTK_WIDGET (self), + "sidebar", + G_ACTION_GROUP (self->action_group)); +} + +void +gtd_sidebar_set_panel_stack (GtdSidebar *self, + GtkStack *stack) +{ + g_return_if_fail (GTD_IS_SIDEBAR (self)); + g_return_if_fail (GTK_IS_STACK (stack)); + + g_assert (self->panel_stack == NULL); + + self->panel_stack = g_object_ref (stack); + + g_signal_connect_object (stack, + "notify::visible-child", + G_CALLBACK (on_panel_stack_visible_child_changed_cb), + self, + 0); +} + + +void +gtd_sidebar_set_task_list_panel (GtdSidebar *self, + GtdPanel *task_list_panel) +{ + g_return_if_fail (GTD_IS_SIDEBAR (self)); + g_return_if_fail (GTD_IS_PANEL (task_list_panel)); + + g_assert (self->task_list_panel == NULL); + + self->task_list_panel = g_object_ref (task_list_panel); + g_signal_connect_object (self->task_list_panel, + "list-deleted", + G_CALLBACK (on_task_list_panel_list_deleted_cb), + self, + 0); +} + +void +gtd_sidebar_activate (GtdSidebar *self) +{ + GtkListBoxRow *first_row; + + g_assert (GTD_IS_SIDEBAR (self)); + + first_row = gtk_list_box_get_row_at_index (self->listbox, 0); + g_signal_emit_by_name (first_row, "activate"); +} + +void +gtd_sidebar_set_archive_visible (GtdSidebar *self, + gboolean show_archive) +{ + g_assert (GTD_IS_SIDEBAR (self)); + + if (show_archive) + gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->archive_listbox)); + else + gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->listbox)); +} + +void +gtd_sidebar_connect (GtdSidebar *self, + GtkWidget *workspace) +{ + g_signal_connect (workspace, "panel-added", G_CALLBACK (on_panel_added_cb), self); + g_signal_connect (workspace, "panel-removed", G_CALLBACK (on_panel_removed_cb), self); +} diff --git a/src/plugins/task-lists-workspace/gtd-sidebar.h b/src/plugins/task-lists-workspace/gtd-sidebar.h new file mode 100644 index 0000000..d85a996 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar.h @@ -0,0 +1,44 @@ +/* gtd-sidebar.h + * + * Copyright 2018-2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "endeavour.h" + +G_BEGIN_DECLS + +#define GTD_TYPE_SIDEBAR (gtd_sidebar_get_type()) +G_DECLARE_FINAL_TYPE (GtdSidebar, gtd_sidebar, GTD, SIDEBAR, GtdWidget) + +void gtd_sidebar_set_panel_stack (GtdSidebar *self, + GtkStack *stack); + +void gtd_sidebar_set_task_list_panel (GtdSidebar *self, + GtdPanel *task_list_panel); + +void gtd_sidebar_activate (GtdSidebar *self); + +void gtd_sidebar_set_archive_visible (GtdSidebar *self, + gboolean show_archive); + +void gtd_sidebar_connect (GtdSidebar *self, + GtkWidget *workspace); + +G_END_DECLS diff --git a/src/plugins/task-lists-workspace/gtd-sidebar.ui b/src/plugins/task-lists-workspace/gtd-sidebar.ui new file mode 100644 index 0000000..356eb9c --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-sidebar.ui @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <template class="GtdSidebar" parent="GtdWidget"> + <property name="hexpand">0</property> + <property name="layout-manager"> + <object class="GtdMaxSizeLayout"> + <property name="width-chars">35</property> + <property name="max-width-chars">35</property> + </object> + </property> + + <child> + <object class="GtkShortcutController"> + <property name="name">Sidebar Keyboard Shortcuts</property> + <property name="scope">global</property> + <child> + <object class="GtkShortcut"> + <property name="trigger"><Control>Page_Down</property> + <property name="action">action(sidebar.move-down)</property> + </object> + </child> + <child> + <object class="GtkShortcut"> + <property name="trigger"><Alt>Down</property> + <property name="action">action(sidebar.move-down)</property> + </object> + </child> + <child> + <object class="GtkShortcut"> + <property name="trigger"><Control>Page_Up</property> + <property name="action">action(sidebar.move-up)</property> + </object> + </child> + <child> + <object class="GtkShortcut"> + <property name="trigger"><Alt>Up</property> + <property name="action">action(sidebar.move-up)</property> + </object> + </child> + </object> + </child> + + <child> + <object class="GtkScrolledWindow"> + <property name="can_focus">1</property> + <property name="min-content-width">300</property> + <property name="hscrollbar-policy">never</property> + <child> + <object class="GtkStack" id="stack"> + <property name="hexpand">true</property> + <property name="vexpand">true</property> + <property name="hhomogeneous">true</property> + <property name="vhomogeneous">false</property> + <property name="transition-type">slide-left-right</property> + + <!-- Main Listbox --> + <child> + <object class="GtkStackPage"> + <property name="name">main</property> + <property name="child"> + <object class="GtkListBox" id="listbox"> + <property name="hexpand">true</property> + <property name="vexpand">true</property> + <property name="selection_mode">browse</property> + <signal name="row-activated" handler="on_listbox_row_activated_cb" object="GtdSidebar" swapped="no"/> + <style> + <class name="navigation-sidebar"/> + </style> + + <!-- Archive row --> + <child> + <object class="GtkListBoxRow" id="archive_row"> + <property name="can_focus">1</property> + <child> + <object class="GtkBox"> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="margin-start">6</property> + <property name="margin-end">6</property> + <property name="spacing">12</property> + <child> + <object class="GtkImage"> + <property name="icon-name">folder-symbolic</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="hexpand">1</property> + <property name="xalign">0</property> + <property name="label" translatable="yes" comments="Translators: 'archived' as in 'archived task lists'">Archived</property> + </object> + </child> + <child> + <object class="GtkImage"> + <property name="icon-name">go-next-symbolic</property> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + </object> + </child> + </object> + </child> + + </object> + </property> + </object> + </child> + + <!-- Archived lists --> + <child> + <object class="GtkStackPage"> + <property name="name">archive</property> + <property name="child"> + <object class="GtkListBox" id="archive_listbox"> + <property name="hexpand">true</property> + <property name="vexpand">true</property> + <property name="selection_mode">browse</property> + <signal name="row-activated" handler="on_listbox_row_activated_cb" object="GtdSidebar" swapped="no"/> + <style> + <class name="navigation-sidebar"/> + </style> + + <child type="placeholder"> + <object class="AdwStatusPage"> + <property name="title" translatable="yes">No Archived Lists</property> + <property name="icon_name">folder-symbolic</property> + <style> + <class name="compact"/> + </style> + </object> + </child> + </object> + </property> + </object> + </child> + + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/src/plugins/task-lists-workspace/gtd-task-list-panel.c b/src/plugins/task-lists-workspace/gtd-task-list-panel.c new file mode 100644 index 0000000..111c777 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-task-list-panel.c @@ -0,0 +1,636 @@ +/* gtd-task-list-panel.c + * + * Copyright 2018-2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "GtdTaskListPanel" + +#include <glib/gi18n.h> + +#include "gtd-color-button.h" +#include "gtd-debug.h" +#include "gtd-manager.h" +#include "gtd-panel.h" +#include "gtd-provider.h" +#include "gtd-task-list.h" +#include "gtd-task-list-panel.h" +#include "gtd-task-list-view.h" +#include "gtd-utils.h" + +struct _GtdTaskListPanel +{ + GtkBox parent; + + GtkButton *archive_button; + GtkFlowBox *colors_flowbox; + GtkPopover *popover; + GtkStack *popover_stack; + GtkWidget *rename_button; + GtkEditable *rename_entry; + GtdTaskListView *task_list_view; + + GtkWidget *previous_color_button; +}; + + +static void on_colors_flowbox_child_activated_cb (GtkFlowBox *colors_flowbox, + GtkFlowBoxChild *child, + GtdTaskListPanel *self); + +static void on_task_list_updated_cb (GObject *source, + GAsyncResult *result, + gpointer user_data); + +static void gtd_panel_iface_init (GtdPanelInterface *iface); + + +G_DEFINE_TYPE_WITH_CODE (GtdTaskListPanel, gtd_task_list_panel, GTK_TYPE_BOX, + G_IMPLEMENT_INTERFACE (GTD_TYPE_PANEL, gtd_panel_iface_init)) + +enum +{ + PROP_0, + PROP_ICON, + PROP_MENU, + PROP_NAME, + PROP_PRIORITY, + PROP_SUBTITLE, + PROP_TITLE, + N_PROPS +}; + +enum +{ + LIST_DELETED, + N_SIGNALS +}; + +static guint signals[N_SIGNALS] = { 0, }; + +/* + * Auxiliary methods + */ + +static const gchar * const colors[] = +{ + "#3584e4", + "#33d17a", + "#f6d32d", + "#ff7800", + "#e01b24", + "#9141ac", + "#986a44", + "#3d3846", + "#ffffff", +}; + +static void +populate_color_grid (GtdTaskListPanel *self) +{ + guint i; + + for (i = 0; i < G_N_ELEMENTS (colors); i++) + { + GtkWidget *button; + GdkRGBA color; + + gdk_rgba_parse (&color, colors[i]); + + button = gtd_color_button_new (&color); + gtk_widget_set_size_request (button, -1, 24); + + gtk_flow_box_insert (self->colors_flowbox, button, -1); + } +} + +static void +update_selected_color (GtdTaskListPanel *self) +{ + g_autoptr (GdkRGBA) color = NULL; + GtdTaskList *list; + GtkWidget *button; + guint i; + + list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); + color = gtd_task_list_get_color (list); + button = NULL; + + for (i = 0; i < G_N_ELEMENTS (colors); i++) + { + GdkRGBA c; + + gdk_rgba_parse (&c, colors[i]); + + if (gdk_rgba_equal (&c, color)) + { + button = GTK_WIDGET (gtk_flow_box_get_child_at_index (self->colors_flowbox, i)); + break; + } + } + + if (button) + { + g_signal_handlers_block_by_func (button, on_colors_flowbox_child_activated_cb, self); + g_signal_emit_by_name (button, "activate"); + g_signal_handlers_unblock_by_func (button, on_colors_flowbox_child_activated_cb, self); + } + else if (self->previous_color_button) + { + gtk_widget_unset_state_flags (self->previous_color_button, GTK_STATE_FLAG_SELECTED); + self->previous_color_button = NULL; + } +} + +static void +rename_list (GtdTaskListPanel *self) +{ + g_autofree gchar *new_name = NULL; + GtdTaskList *list; + + g_assert (gtk_widget_get_visible (GTK_WIDGET (self->popover))); + g_assert (g_utf8_validate (gtk_editable_get_text (self->rename_entry), -1, NULL)); + + list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); + g_assert (list != NULL); + + new_name = g_strdup (gtk_editable_get_text (self->rename_entry)); + new_name = g_strstrip (new_name); + + /* + * Even though the Rename button is insensitive, we may still reach here + * by activating the entry. + */ + if (!new_name || new_name[0] == '\0') + return; + + if (g_strcmp0 (new_name, gtd_task_list_get_name (list)) != 0) + { + gtd_task_list_set_name (list, new_name); + gtd_provider_update_task_list (gtd_task_list_get_provider (list), + list, + NULL, + on_task_list_updated_cb, + self); + } + + gtk_popover_popdown (self->popover); + gtk_editable_set_text (self->rename_entry, ""); +} + +static void +update_archive_button (GtdTaskListPanel *self) +{ + GtdTaskList *list; + gboolean archived; + + GTD_ENTRY; + + list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); + g_assert (list != NULL); + + archived = gtd_task_list_get_archived (list); + g_object_set (self->archive_button, + "text", archived ? _("Unarchive") : _("Archive"), + NULL); + + GTD_EXIT; +} + + +/* + * Callbacks + */ + +static void +on_task_list_updated_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + g_autoptr (GError) error = NULL; + + gtd_provider_update_task_list_finish (GTD_PROVIDER (source), result, &error); + + if (error) + { + g_warning ("Error creating task: %s", error->message); + + gtd_manager_emit_error_message (gtd_manager_get_default (), + _("An error occurred while updating a task"), + error->message, + NULL, + NULL); + } +} + +static void +on_archive_button_clicked_cb (GtkButton *button, + GtdTaskListPanel *self) +{ + GtdProvider *provider; + GtdTaskList *list; + gboolean archived; + + GTD_ENTRY; + + list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); + g_assert (list != NULL); + + archived = gtd_task_list_get_archived (list); + gtd_task_list_set_archived (list, !archived); + + update_archive_button (self); + + provider = gtd_task_list_get_provider (list); + gtd_provider_update_task_list (provider, + list, + NULL, + on_task_list_updated_cb, + self); + + GTD_EXIT; +} + +static void +on_colors_flowbox_child_activated_cb (GtkFlowBox *colors_flowbox, + GtkFlowBoxChild *child, + GtdTaskListPanel *self) +{ + const GdkRGBA *color; + GtdTaskList *list; + GtkWidget *color_button; + + list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); + + g_assert (list != NULL); + + color_button = gtk_flow_box_child_get_child (child); + + if (self->previous_color_button == color_button) + return; + + gtk_widget_set_state_flags (color_button, GTK_STATE_FLAG_SELECTED, FALSE); + + if (self->previous_color_button) + gtk_widget_unset_state_flags (self->previous_color_button, GTK_STATE_FLAG_SELECTED); + + g_debug ("Setting new color for task list '%s'", gtd_task_list_get_name (list)); + + color = gtd_color_button_get_color (GTD_COLOR_BUTTON (color_button)); + gtd_task_list_set_color (list, color); + + gtd_provider_update_task_list (gtd_task_list_get_provider (list), + list, + NULL, + on_task_list_updated_cb, + self); + + self->previous_color_button = color_button; +} + +static void +on_delete_button_clicked_cb (GtkButton *button, + GtdTaskListPanel *self) +{ + GtdTaskList *list; + + list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); + g_assert (list != NULL); + + GTD_TRACE_MSG ("Emitting GtdTaskListPanel:list-deleted"); + + g_signal_emit (self, signals[LIST_DELETED], 0, list); +} + +static void +on_go_to_rename_page_button_clicked_cb (GtkButton *button, + GtdTaskListPanel *self) +{ + gtk_stack_set_visible_child_name (self->popover_stack, "rename"); +} + +static void +on_popover_hidden_cb (GtkPopover *popover, + GtdTaskListPanel *self) +{ + gtk_editable_set_text (self->rename_entry, ""); + gtk_stack_set_visible_child_name (self->popover_stack, "main"); +} + +static void +on_rename_button_clicked_cb (GtkButton *button, + GtdTaskListPanel *self) +{ + rename_list (self); +} + +static void +on_rename_entry_activated_cb (GtkEntry *entry, + GtdTaskListPanel *self) +{ + rename_list (self); +} + +static void +on_rename_entry_text_changed_cb (GtkEditable *entry, + GParamSpec *pspec, + GtdTaskListPanel *self) +{ + g_autofree gchar *new_name = NULL; + gboolean valid; + + new_name = g_strdup (gtk_editable_get_text (entry)); + new_name = g_strstrip (new_name); + + valid = new_name && new_name[0] != '\0'; + + gtk_widget_set_sensitive (self->rename_button, valid); +} + + +/* + * GtdPanel iface + */ + +static const gchar* +gtd_task_list_panel_get_panel_name (GtdPanel *panel) +{ + return "task-list-panel"; +} + +static const gchar* +gtd_task_list_panel_get_panel_title (GtdPanel *panel) +{ + GtdTaskListPanel *self; + GtdTaskList *list; + + self = GTD_TASK_LIST_PANEL (panel); + list = (GtdTaskList *) gtd_task_list_view_get_model (self->task_list_view); + + return list ? gtd_task_list_get_name (list) : ""; +} + +static GList* +gtd_task_list_panel_get_header_widgets (GtdPanel *panel) +{ + return NULL; +} + +static const GMenu* +gtd_task_list_panel_get_menu (GtdPanel *panel) +{ + return NULL; +} + +static GIcon* +gtd_task_list_panel_get_icon (GtdPanel *panel) +{ + return NULL; +} + +static GtkPopover* +gtd_task_list_panel_get_popover (GtdPanel *panel) +{ + GtdTaskListPanel *self = GTD_TASK_LIST_PANEL (panel); + return self->popover; +} + + +static guint32 +gtd_task_list_panel_get_priority (GtdPanel *panel) +{ + return 0; +} + +static gchar* +gtd_task_list_panel_get_subtitle (GtdPanel *panel) +{ + return NULL; +} + +static void +gtd_task_list_panel_activate (GtdPanel *panel, + GVariant *parameters) +{ + GtdTaskListPanel *self; + GVariantDict dict; + GtdTaskList *list; + GListModel *model; + const gchar *task_list_id; + const gchar *provider_id; + guint i; + + GTD_ENTRY; + + self = GTD_TASK_LIST_PANEL (panel); + + /* + * The task list panel must receive an a{sv} and looks for: + * + * * provider-id: the id of the provider + * * task-list-id: the id of the task list + * + * So it can find the task list from the GtdManager. + */ + + g_variant_dict_init (&dict, parameters); + g_variant_dict_lookup (&dict, "provider-id", "&s", &provider_id); + g_variant_dict_lookup (&dict, "task-list-id", "&s", &task_list_id); + + GTD_TRACE_MSG ("Activating %s with 'provider-id': %s and 'task-list-id': %s", + G_OBJECT_TYPE_NAME (self), + provider_id, + task_list_id); + + model = gtd_manager_get_task_lists_model (gtd_manager_get_default ()); + list = NULL; + + for (i = 0; i < g_list_model_get_n_items (model); i++) + { + g_autoptr (GtdTaskList) task_list = NULL; + GtdProvider *provider; + + task_list = g_list_model_get_item (model, i); + if (g_strcmp0 (gtd_object_get_uid (GTD_OBJECT (task_list)), task_list_id) != 0) + continue; + + provider = gtd_task_list_get_provider (task_list); + if (g_strcmp0 (gtd_provider_get_id (provider), provider_id) != 0) + return; + + list = task_list; + break; + } + + g_assert (list != NULL); + + gtd_task_list_panel_set_task_list (self, list); + + GTD_EXIT; +} + +static void +gtd_panel_iface_init (GtdPanelInterface *iface) +{ + iface->get_panel_name = gtd_task_list_panel_get_panel_name; + iface->get_panel_title = gtd_task_list_panel_get_panel_title; + iface->get_header_widgets = gtd_task_list_panel_get_header_widgets; + iface->get_menu = gtd_task_list_panel_get_menu; + iface->get_icon = gtd_task_list_panel_get_icon; + iface->get_popover = gtd_task_list_panel_get_popover; + iface->get_priority = gtd_task_list_panel_get_priority; + iface->get_subtitle = gtd_task_list_panel_get_subtitle; + iface->activate = gtd_task_list_panel_activate; +} + + +/* + * GObject overrides + */ + +static void +gtd_task_list_panel_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_ICON: + g_value_set_object (value, NULL); + break; + + case PROP_MENU: + g_value_set_object (value, NULL); + break; + + case PROP_NAME: + g_value_set_string (value, "task-list-panel"); + break; + + case PROP_PRIORITY: + g_value_set_uint (value, 0); + break; + + case PROP_SUBTITLE: + g_value_take_string (value, NULL); + break; + + case PROP_TITLE: + g_value_set_string (value, gtd_panel_get_panel_title (GTD_PANEL (object))); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_task_list_panel_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); +} + + +static void +gtd_task_list_panel_class_init (GtdTaskListPanelClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->get_property = gtd_task_list_panel_get_property; + object_class->set_property = gtd_task_list_panel_set_property; + + g_object_class_override_property (object_class, PROP_ICON, "icon"); + g_object_class_override_property (object_class, PROP_MENU, "menu"); + g_object_class_override_property (object_class, PROP_NAME, "name"); + g_object_class_override_property (object_class, PROP_PRIORITY, "priority"); + g_object_class_override_property (object_class, PROP_SUBTITLE, "subtitle"); + g_object_class_override_property (object_class, PROP_TITLE, "title"); + + signals[LIST_DELETED] = g_signal_new ("list-deleted", + GTD_TYPE_TASK_LIST_PANEL, + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 1, + GTD_TYPE_TASK_LIST); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/plugins/task-lists-workspace/gtd-task-list-panel.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, archive_button); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, colors_flowbox); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, popover); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, popover_stack); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, rename_button); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, rename_entry); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, rename_entry); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, task_list_view); + + gtk_widget_class_bind_template_callback (widget_class, on_archive_button_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_colors_flowbox_child_activated_cb); + gtk_widget_class_bind_template_callback (widget_class, on_delete_button_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_go_to_rename_page_button_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_popover_hidden_cb); + gtk_widget_class_bind_template_callback (widget_class, on_rename_button_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_rename_entry_activated_cb); + gtk_widget_class_bind_template_callback (widget_class, on_rename_entry_text_changed_cb); +} + +static void +gtd_task_list_panel_init (GtdTaskListPanel *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + populate_color_grid (self); +} + +GtkWidget* +gtd_task_list_panel_new (void) +{ + return g_object_new (GTD_TYPE_TASK_LIST_PANEL, NULL); +} + +GtdTaskList* +gtd_task_list_panel_get_task_list (GtdTaskListPanel *self) +{ + g_return_val_if_fail (GTD_IS_TASK_LIST_PANEL (self), NULL); + + return GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view)); +} + +void +gtd_task_list_panel_set_task_list (GtdTaskListPanel *self, + GtdTaskList *list) +{ + g_return_if_fail (GTD_IS_TASK_LIST_PANEL (self)); + g_return_if_fail (GTD_IS_TASK_LIST (list)); + + gtd_task_list_view_set_model (self->task_list_view, G_LIST_MODEL (list)); + + update_selected_color (self); + update_archive_button (self); + + g_object_notify (G_OBJECT (self), "title"); +} + diff --git a/src/plugins/task-lists-workspace/gtd-task-list-panel.h b/src/plugins/task-lists-workspace/gtd-task-list-panel.h new file mode 100644 index 0000000..1db7e70 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-task-list-panel.h @@ -0,0 +1,40 @@ +/* gtd-task-list-panel.h + * + * Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "gtd-types.h" + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GTD_TYPE_TASK_LIST_PANEL (gtd_task_list_panel_get_type()) + +G_DECLARE_FINAL_TYPE (GtdTaskListPanel, gtd_task_list_panel, GTD, TASK_LIST_PANEL, GtkBox) + +GtkWidget* gtd_task_list_panel_new (void); + +GtdTaskList* gtd_task_list_panel_get_task_list (GtdTaskListPanel *self); + +void gtd_task_list_panel_set_task_list (GtdTaskListPanel *self, + GtdTaskList *list); + +G_END_DECLS diff --git a/src/plugins/task-lists-workspace/gtd-task-list-panel.ui b/src/plugins/task-lists-workspace/gtd-task-list-panel.ui new file mode 100644 index 0000000..f5db9d7 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-task-list-panel.ui @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <template class="GtdTaskListPanel" parent="GtkBox"> + <child> + <object class="GtdTaskListView" id="task_list_view"/> + </child> + </template> + <object class="GtkPopover" id="popover"> + <property name="visible">0</property> + <signal name="hide" handler="on_popover_hidden_cb" object="GtdTaskListPanel" swapped="no"/> + <style> + <class name="menu" /> + </style> + + <child> + <object class="GtkStack" id="popover_stack"> + + <!-- Main Page --> + <child> + <object class="GtkStackPage"> + <property name="name">main</property> + <property name="child"> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkFlowBox" id="colors_flowbox"> + <property name="hexpand">true</property> + <property name="vexpand">true</property> + <property name="selection-mode">none</property> + <property name="min-children-per-line">3</property> + <property name="max-children-per-line">3</property> + <signal name="child-activated" handler="on_colors_flowbox_child_activated_cb" object="GtdTaskListPanel" swapped="no"/> + </object> + </child> + <child> + <object class="GtkModelButton"> + <property name="text" translatable="yes">Rename</property> + <signal name="clicked" handler="on_go_to_rename_page_button_clicked_cb" object="GtdTaskListPanel" swapped="no"/> + </object> + </child> + <child> + <object class="GtkModelButton"> + <property name="text" translatable="yes">Clear completed tasks…</property> + <property name="action-name">list.clear-completed-tasks</property> + </object> + </child> + <child> + <object class="GtkSeparator"/> + </child> + <child> + <object class="GtkModelButton" id="archive_button"> + <property name="text" translatable="yes">Archive</property> + <signal name="clicked" handler="on_archive_button_clicked_cb" object="GtdTaskListPanel" swapped="no"/> + </object> + </child> + <child> + <object class="GtkModelButton"> + <property name="text" translatable="yes">Delete</property> + <signal name="clicked" handler="on_delete_button_clicked_cb" object="GtdTaskListPanel" swapped="no"/> + </object> + </child> + </object> + </property> + </object> + </child> + + <!-- Rename Page --> + <child> + <object class="GtkStackPage"> + <property name="name">rename</property> + <property name="child"> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <child> + <object class="GtkModelButton" id="rename_header_button"> + <property name="text" translatable="yes">Rename</property> + <property name="role">title</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">12</property> + <child> + <object class="GtkEntry" id="rename_entry"> + <signal name="activate" handler="on_rename_entry_activated_cb" object="GtdTaskListPanel" swapped="no"/> + <signal name="notify::text" handler="on_rename_entry_text_changed_cb" object="GtdTaskListPanel" swapped="no"/> + </object> + </child> + <child> + <object class="GtkButton" id="rename_button"> + <property name="label" translatable="yes">Rename</property> + <signal name="clicked" handler="on_rename_button_clicked_cb" object="GtdTaskListPanel" swapped="no"/> + <style> + <class name="destructive-action"/> + </style> + </object> + </child> + </object> + </child> + </object> + </property> + </object> + </child> + + </object> + </child> + </object> +</interface> diff --git a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c new file mode 100644 index 0000000..407de89 --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c @@ -0,0 +1,711 @@ +/* gtd-task-lists-workspace.c + * + * Copyright 2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "GtdTaskListsWorkspace" + +#include "gtd-task-lists-workspace.h" + +#include "gtd-debug.h" +#include "task-lists-workspace.h" +#include "gtd-sidebar.h" +#include "gtd-task-list-panel.h" + +#include <libpeas/peas.h> +#include <glib/gi18n.h> + +struct _GtdTaskListsWorkspace +{ + GtkBox parent; + + GtkWidget *back_button; + GtkWidget *content_box; + GtkMenuButton *gear_menu_button; + AdwLeaflet *leaflet; + GtkWidget *new_list_button; + GtkBox *panel_box_end; + GtkBox *panel_box_start; + GtkMenuButton *primary_menu_button; + GtkStack *stack; + GtdSidebar *sidebar; + GtkWidget *sidebar_box; + + AdwToastOverlay *sidebar_overlay; + AdwToastOverlay *content_overlay; + + GtdPanel *active_panel; + GtdPanel *task_list_panel; + + GHashTable *notification_list; + + PeasExtensionSet *panels_set; + GSimpleActionGroup *action_group; +}; + +typedef struct +{ + GtdWindow *window; + gchar *primary_text; + gchar *secondary_text; +} ErrorData; + +static void gtd_workspace_iface_init (GtdWorkspaceInterface *iface); + +G_DEFINE_TYPE_WITH_CODE (GtdTaskListsWorkspace, gtd_task_lists_workspace, GTK_TYPE_BOX, + G_IMPLEMENT_INTERFACE (GTD_TYPE_WORKSPACE, gtd_workspace_iface_init)) + +enum +{ + PROP_0, + PROP_ICON, + PROP_TITLE, + N_PROPS +}; + +enum +{ + PANEL_ADDED, + PANEL_REMOVED, + NUM_SIGNALS +}; + +static guint signals[NUM_SIGNALS] = { 0, }; + + +/* + * Auxiliary methods + */ + +static void +error_data_free (ErrorData *error_data) +{ + g_free (error_data->primary_text); + g_free (error_data->secondary_text); + g_free (error_data); +} + +static void +add_widgets (GtdTaskListsWorkspace *self, + GList *widgets) +{ + GList *l; + + for (l = widgets; l; l = l->next) + { + switch (gtk_widget_get_halign (l->data)) + { + case GTK_ALIGN_END: + gtk_box_append (self->panel_box_end, l->data); + break; + + case GTK_ALIGN_START: + case GTK_ALIGN_BASELINE: + case GTK_ALIGN_FILL: + default: + gtk_box_append (self->panel_box_start, l->data); + break; + } + } +} + +static void +remove_widgets (GtdTaskListsWorkspace *self, + GList *widgets) +{ + GList *l; + + for (l = widgets; l; l = l->next) + { + GtkBox *box; + + if (gtk_widget_get_halign (l->data) == GTK_ALIGN_END) + box = self->panel_box_end; + else + box = self->panel_box_start; + + g_object_ref (l->data); + gtk_box_remove (box, l->data); + } +} + +static void +update_panel_menu (GtdTaskListsWorkspace *self) +{ + GtkPopover *popover; + const GMenu *menu; + + popover = gtd_panel_get_popover (self->active_panel); + menu = gtd_panel_get_menu (self->active_panel); + + gtk_widget_set_visible (GTK_WIDGET (self->gear_menu_button), popover || menu); + + if (popover) + { + gtk_menu_button_set_popover (self->gear_menu_button, GTK_WIDGET (popover)); + } + else + { + gtk_menu_button_set_popover (self->gear_menu_button, NULL); + gtk_menu_button_set_menu_model (self->gear_menu_button, G_MENU_MODEL (menu)); + } +} + + +/* + * Callbacks + */ + +static void +on_action_activate_panel_activated_cb (GSimpleAction *simple, + GVariant *parameters, + gpointer user_data) +{ + GtdTaskListsWorkspace *self; + g_autoptr (GVariant) panel_parameters = NULL; + g_autofree gchar *panel_id = NULL; + GtdPanel *panel; + + self = GTD_TASK_LISTS_WORKSPACE (user_data); + + g_variant_get (parameters, + "(sv)", + &panel_id, + &panel_parameters); + + g_debug ("Activating panel '%s'", panel_id); + + panel = (GtdPanel *) gtk_stack_get_child_by_name (self->stack, panel_id); + g_return_if_fail (panel && GTD_IS_PANEL (panel)); + + gtd_panel_activate (panel, panel_parameters); + + gtk_stack_set_visible_child (self->stack, GTK_WIDGET (panel)); + adw_leaflet_navigate (self->leaflet, ADW_NAVIGATION_DIRECTION_FORWARD); +} + +static void +on_action_toggle_archive_activated_cb (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + GtdTaskListsWorkspace *self; + gboolean archive_visible; + + self = GTD_TASK_LISTS_WORKSPACE (user_data); + archive_visible = g_variant_get_boolean (state); + + gtk_widget_set_visible (self->new_list_button, !archive_visible); + gtd_sidebar_set_archive_visible (self->sidebar, archive_visible); +} + +static void +on_back_sidebar_button_clicked_cb (GtkButton *button, + GtdTaskListsWorkspace *self) +{ + adw_leaflet_navigate (self->leaflet, ADW_NAVIGATION_DIRECTION_BACK); +} + +static void +on_back_button_clicked_cb (GtkButton *button, + GtdTaskListsWorkspace *self) +{ + gtk_widget_activate_action (GTK_WIDGET (self), + "task-lists-workspace.toggle-archive", + "b", + FALSE); +} + +static void +on_panel_added_cb (PeasExtensionSet *extension_set, + PeasPluginInfo *plugin_info, + GtdPanel *panel, + GtdTaskListsWorkspace *self) +{ + gtk_stack_add_titled (self->stack, + GTK_WIDGET (g_object_ref_sink (panel)), + gtd_panel_get_panel_name (panel), + gtd_panel_get_panel_title (panel)); + + g_signal_emit (self, signals[PANEL_ADDED], 0, panel); +} + +static void +on_panel_removed_cb (PeasExtensionSet *extension_set, + PeasPluginInfo *plugin_info, + GtdPanel *panel, + GtdTaskListsWorkspace *self) +{ + g_object_ref (panel); + + gtk_stack_remove (self->stack, GTK_WIDGET (panel)); + g_signal_emit (self, signals[PANEL_REMOVED], 0, panel); + + g_object_unref (panel); +} + +static void +on_panel_menu_changed_cb (GObject *object, + GParamSpec *pspec, + GtdTaskListsWorkspace *self) +{ + if (GTD_PANEL (object) != self->active_panel) + return; + + update_panel_menu (self); +} +static void +on_stack_visible_child_cb (GtdTaskListsWorkspace *self, + GParamSpec *pspec, + GtkStack *stack) +{ + GtkWidget *visible_child; + GtdPanel *panel; + GList *header_widgets; + + GTD_ENTRY; + + visible_child = gtk_stack_get_visible_child (stack); + panel = GTD_PANEL (visible_child); + + /* Remove previous panel's widgets */ + if (self->active_panel) + { + header_widgets = gtd_panel_get_header_widgets (self->active_panel); + + /* Disconnect signals */ + g_signal_handlers_disconnect_by_func (self->active_panel, + on_panel_menu_changed_cb, + self); + + remove_widgets (self, header_widgets); + + g_list_free (header_widgets); + } + + /* Add current panel's header widgets */ + header_widgets = gtd_panel_get_header_widgets (panel); + add_widgets (self, header_widgets); + + g_list_free (header_widgets); + + g_signal_connect (panel, "notify::menu", G_CALLBACK (on_panel_menu_changed_cb), self); + + /* Set panel as the new active panel */ + g_set_object (&self->active_panel, panel); + + /* Setup the panel's menu */ + update_panel_menu (self); + + GTD_EXIT; +} + +void +on_toast_dismissed_cb (AdwToast *self, + gpointer user_data) +{ + GtdNotification *notification = user_data; + + GTD_ENTRY; + + gtd_notification_execute_dismissal_action (notification); + + GTD_EXIT; +} + +void +toast_activated_cb (GtdTaskListsWorkspace *self, + const char *action_name, + GVariant *parameter) +{ + AdwToast *toast; + GtdNotification *notification; + + GTD_ENTRY; + + toast = g_hash_table_lookup (self->notification_list, g_variant_get_string (parameter, NULL)); + + if (toast != NULL) { + notification = g_object_get_data (G_OBJECT (toast), "notification"); + + g_signal_handlers_block_by_func (toast, on_toast_dismissed_cb, notification); + gtd_notification_execute_secondary_action (notification); + } + + GTD_EXIT; +} + +static void +on_show_notification_cb (GtdManager *manager, + GtdNotification *notification, + GtdTaskListsWorkspace *self) +{ + AdwToast *toast; + GValue btn_label = G_VALUE_INIT; + + g_object_get_property (G_OBJECT (notification), "secondary-action-name", &btn_label); + + /* Convert GtdNotification to AdwToast */ + toast = adw_toast_new (gtd_notification_get_text (notification)); + adw_toast_set_button_label (toast, g_value_get_string (&btn_label)); + adw_toast_set_action_name (toast, "toast.activated"); + adw_toast_set_action_target_value (toast, g_variant_new_string (g_value_get_string (&btn_label))); + g_object_set_data (G_OBJECT (toast), "notification", notification); + + g_hash_table_insert (self->notification_list, (char *) g_value_get_string (&btn_label), toast); + g_signal_connect (toast, "dismissed", G_CALLBACK (on_toast_dismissed_cb), notification); + + if (adw_leaflet_get_folded (self->leaflet)) { + if (adw_leaflet_get_visible_child (self->leaflet) == self->content_box) + adw_toast_overlay_add_toast (self->content_overlay, toast); + if (adw_leaflet_get_visible_child (self->leaflet) == self->sidebar_box) + adw_toast_overlay_add_toast (self->sidebar_overlay, toast); + } else { + adw_toast_overlay_add_toast (self->content_overlay, toast); + } +} + +static void +error_message_notification_primary_action (GtdNotification *notification, + gpointer user_data) +{ + error_data_free (user_data); +} + +static void +error_message_notification_secondary_action (GtdNotification *notification, + gpointer user_data) +{ + GtkWidget *dialog; + ErrorData *data; + + data = user_data; + dialog = adw_message_dialog_new (GTK_WINDOW (data->window), + data->primary_text, + NULL); + + adw_message_dialog_format_body (ADW_MESSAGE_DIALOG (dialog), + "%s", + data->secondary_text); + + adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), + "close", _("Close")); + + g_signal_connect (dialog, + "response", + G_CALLBACK (gtk_window_destroy), + NULL); + + gtk_widget_show (dialog); + + error_data_free (data); +} + +static void +on_show_error_message_cb (GtdManager *manager, + const gchar *primary_text, + const gchar *secondary_text, + GtdNotificationActionFunc function, + gpointer user_data, + GtdTaskListsWorkspace *self) +{ + GtdNotification *notification; + ErrorData *error_data; + + error_data = g_new0 (ErrorData, 1); + notification = gtd_notification_new (primary_text); + + error_data->window = GTD_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))); + error_data->primary_text = g_strdup (primary_text); + error_data->secondary_text = g_strdup (secondary_text); + + gtd_notification_set_dismissal_action (notification, + error_message_notification_primary_action, + error_data); + + if (!function) + { + gtd_notification_set_secondary_action (notification, + _("Details"), + error_message_notification_secondary_action, + error_data); + } + else + { + gtd_notification_set_secondary_action (notification, secondary_text, function, user_data); + } + + gtd_manager_send_notification (gtd_manager_get_default (), notification); +} + +/* + * GtdWorkspace implementation + */ + +static const gchar* +gtd_task_lists_workspace_get_id (GtdWorkspace *workspace) +{ + return "task-lists"; +} + +static const gchar* +gtd_task_lists_workspace_get_title (GtdWorkspace *workspace) +{ + return _("Task Lists"); +} + +static gint +gtd_task_lists_workspace_get_priority (GtdWorkspace *workspace) +{ + return 1000; +} + +static GIcon* +gtd_task_lists_workspace_get_icon (GtdWorkspace *workspace) +{ + return g_themed_icon_new ("view-list-symbolic"); +} + +static void +gtd_task_lists_workspace_activate (GtdWorkspace *workspace, + GVariant *parameters) +{ + GtdTaskListsWorkspace *self = GTD_TASK_LISTS_WORKSPACE (workspace); + + if (parameters) + { + const gchar *panel_id = g_variant_get_string (parameters, NULL); + + g_debug ("Activating panel '%s'", panel_id); + gtk_stack_set_visible_child_name (self->stack, panel_id); + } + else + { + gtd_sidebar_activate (self->sidebar); + } +} + +static void +gtd_workspace_iface_init (GtdWorkspaceInterface *iface) +{ + iface->get_id = gtd_task_lists_workspace_get_id; + iface->get_title = gtd_task_lists_workspace_get_title; + iface->get_priority = gtd_task_lists_workspace_get_priority; + iface->get_icon = gtd_task_lists_workspace_get_icon; + iface->activate = gtd_task_lists_workspace_activate; +} + + +/* + * GObject overrides + */ + +static void +gtd_task_lists_workspace_dispose (GObject *object) +{ + GtdTaskListsWorkspace *self = (GtdTaskListsWorkspace *)object; + + G_OBJECT_CLASS (gtd_task_lists_workspace_parent_class)->dispose (object); + + g_signal_handlers_disconnect_by_func (self->panels_set, on_panel_added_cb, self); + g_signal_handlers_disconnect_by_func (self->panels_set, on_panel_removed_cb, self); + g_clear_object (&self->panels_set); +} + +static void +gtd_task_lists_workspace_constructed (GObject *object) +{ + GtdManager *manager = gtd_manager_get_default (); + GtdTaskListsWorkspace *self = (GtdTaskListsWorkspace *)object; + + G_OBJECT_CLASS (gtd_task_lists_workspace_parent_class)->constructed (object); + + /* Add loaded panels */ + self->panels_set = peas_extension_set_new (peas_engine_get_default (), + GTD_TYPE_PANEL, + NULL); + + peas_extension_set_foreach (self->panels_set, + (PeasExtensionSetForeachFunc) on_panel_added_cb, + self); + + g_signal_connect (self->panels_set, "extension-added", G_CALLBACK (on_panel_added_cb), self); + g_signal_connect (self->panels_set, "extension-removed", G_CALLBACK (on_panel_removed_cb), self); + g_signal_connect (manager, "show-notification", G_CALLBACK (on_show_notification_cb), self); + g_signal_connect (manager, "show-error-message", G_CALLBACK (on_show_error_message_cb), self); +} + +static void +gtd_task_lists_workspace_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtdWorkspace *workspace = GTD_WORKSPACE (object); + + switch (prop_id) + { + case PROP_ICON: + g_value_take_object (value, gtd_workspace_get_icon (workspace)); + break; + + case PROP_TITLE: + g_value_set_string (value, gtd_workspace_get_title (workspace)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtd_task_lists_workspace_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); +} + +static void +gtd_task_lists_workspace_class_init (GtdTaskListsWorkspaceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + g_resources_register (task_lists_workspace_get_resource ()); + + object_class->dispose = gtd_task_lists_workspace_dispose; + object_class->constructed = gtd_task_lists_workspace_constructed; + object_class->get_property = gtd_task_lists_workspace_get_property; + object_class->set_property = gtd_task_lists_workspace_set_property; + + + /** + * GtdTaskListsWorkspace::panel-added: + * @manager: a #GtdManager + * @panel: a #GtdPanel + * + * The ::panel-added signal is emmited after a #GtdPanel + * is added. + */ + signals[PANEL_ADDED] = g_signal_new ("panel-added", + GTD_TYPE_TASK_LISTS_WORKSPACE, + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 1, + GTD_TYPE_PANEL); + + /** + * GtdTaskListsWorkspace::panel-removed: + * @manager: a #GtdManager + * @panel: a #GtdPanel + * + * The ::panel-removed signal is emmited after a #GtdPanel + * is removed from the list. + */ + signals[PANEL_REMOVED] = g_signal_new ("panel-removed", + GTD_TYPE_TASK_LISTS_WORKSPACE, + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 1, + GTD_TYPE_PANEL); + + g_object_class_override_property (object_class, PROP_ICON, "icon"); + g_object_class_override_property (object_class, PROP_TITLE, "title"); + + g_type_ensure (GTD_TYPE_PROVIDER_POPOVER); + g_type_ensure (GTD_TYPE_SIDEBAR); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/plugins/task-lists-workspace/gtd-task-lists-workspace.ui"); + + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, back_button); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, content_box); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, gear_menu_button); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, leaflet); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, new_list_button); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, panel_box_end); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, panel_box_start); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, primary_menu_button); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, sidebar); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, sidebar_box); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, stack); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, sidebar_overlay); + gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, content_overlay); + + gtk_widget_class_bind_template_callback (widget_class, on_back_button_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_back_sidebar_button_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_stack_visible_child_cb); + + gtk_widget_class_install_action (widget_class, "toast.activated", "s", (GtkWidgetActionActivateFunc) toast_activated_cb); +} + +static void +gtd_task_lists_workspace_init (GtdTaskListsWorkspace *self) +{ + GtkApplication *application; + GMenu *primary_menu; + + static const GActionEntry entries[] = { + { "activate-panel", on_action_activate_panel_activated_cb, "(sv)" }, + { "toggle-archive", on_action_toggle_archive_activated_cb, "b" }, + }; + + gtk_widget_init_template (GTK_WIDGET (self)); + + self->notification_list = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + + self->action_group = g_simple_action_group_new (); + g_action_map_add_action_entries (G_ACTION_MAP (self->action_group), + entries, + G_N_ELEMENTS (entries), + self); + gtk_widget_insert_action_group (GTK_WIDGET (self), + "task-lists-workspace", + G_ACTION_GROUP (self->action_group)); + + gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->back_button), + g_variant_new_boolean (FALSE)); + + /* Task list panel */ + self->task_list_panel = GTD_PANEL (gtd_task_list_panel_new ()); + on_panel_added_cb (NULL, NULL, self->task_list_panel, self); + + gtd_sidebar_connect (self->sidebar, GTK_WIDGET (self)); + gtd_sidebar_set_panel_stack (self->sidebar, self->stack); + gtd_sidebar_set_task_list_panel (self->sidebar, self->task_list_panel); + + /* Fancy primary menu */ + application = GTK_APPLICATION (g_application_get_default ()); + primary_menu = gtk_application_get_menu_by_id (application, "primary-menu"); + gtk_menu_button_set_menu_model (self->primary_menu_button, G_MENU_MODEL (primary_menu)); +} + +GtdWorkspace* +gtd_task_lists_workspace_new (void) +{ + return g_object_new (GTD_TYPE_TASK_LISTS_WORKSPACE, NULL); +} diff --git a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.h b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.h new file mode 100644 index 0000000..0cbc97a --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.h @@ -0,0 +1,35 @@ +/* gtd-task-lists-workspace.h + * + * Copyright 2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include <gtk/gtk.h> + +#include "endeavour.h" + +G_BEGIN_DECLS + +#define GTD_TYPE_TASK_LISTS_WORKSPACE (gtd_task_lists_workspace_get_type()) + +G_DECLARE_FINAL_TYPE (GtdTaskListsWorkspace, gtd_task_lists_workspace, GTD, TASK_LISTS_WORKSPACE, GtkBox) + +GtdWorkspace* gtd_task_lists_workspace_new (void); + +G_END_DECLS diff --git a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui new file mode 100644 index 0000000..7d63d1d --- /dev/null +++ b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <template class="GtdTaskListsWorkspace" parent="GtkBox"> + + <!-- Main leaflet --> + <child> + <object class="AdwLeaflet" id="leaflet"> + <property name="can-navigate-back">true</property> + <property name="width-request">360</property> + + <child> + <object class="GtkBox" id="sidebar_box"> + <property name="orientation">vertical</property> + <property name="hexpand">False</property> + + <child> + <object class="AdwHeaderBar" id="start_headerbar"> + <property name="hexpand">1</property> + <property name="show-start-title-buttons">True</property> + <property name="show-end-title-buttons" bind-source="leaflet" bind-property="folded" bind-flags="sync-create" /> + + <property name="title-widget"> + <object class="AdwWindowTitle"> + <property name="visible">False</property> + </object> + </property> + + <!-- New List --> + <child> + <object class="GtkMenuButton" id="new_list_button"> + <property name="can_focus">1</property> + <property name="label" translatable="yes">New List</property> + <property name="receives_default">1</property> + <property name="popover">new_list_popover</property> + <property name="halign">start</property> + </object> + </child> + + <child> + <object class="GtkButton" id="back_button"> + <property name="visible" bind-source="new_list_button" bind-property="visible" bind-flags="sync-create|invert-boolean" /> + <property name="can_focus">1</property> + <property name="receives_default">1</property> + <property name="halign">start</property> + <property name="icon-name">go-previous-symbolic</property> + <signal name="clicked" handler="on_back_button_clicked_cb" object="GtdTaskListsWorkspace" swapped="no" /> + </object> + </child> + + <child type="end"> + <object class="GtkMenuButton" id="primary_menu_button"> + <property name="icon-name">open-menu-symbolic</property> + </object> + </child> + + </object> + </child> + + <child> + <object class="AdwToastOverlay" id="sidebar_overlay"> + <child> + <object class="GtdSidebar" id="sidebar"> + <property name="can_focus">False</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> + + </object> + </child> + + <child> + <object class="AdwLeafletPage"> + <property name="navigatable">False</property> + <property name="child"> + <object class="GtkSeparator"/> + </property> + </object> + </child> + + <child> + <object class="GtkBox" id="content_box"> + <property name="orientation">vertical</property> + <property name="hexpand">true</property> + + <child> + <object class="AdwHeaderBar" id="headerbar"> + <property name="hexpand">1</property> + <property name="show-start-title-buttons" bind-source="leaflet" bind-property="folded" bind-flags="sync-create" /> + <property name="show-end-title-buttons">True</property> + + <child> + <object class="GtkButton" id="back_sidebar_button"> + <property name="visible" bind-source="leaflet" bind-property="folded" bind-flags="sync-create" /> + <property name="can_focus">1</property> + <property name="receives_default">1</property> + <property name="halign">start</property> + <property name="icon-name">go-previous-symbolic</property> + <signal name="clicked" handler="on_back_sidebar_button_clicked_cb" object="GtdTaskListsWorkspace" swapped="no" /> + </object> + </child> + + <child> + <object class="GtkBox" id="panel_box_start"> + <property name="spacing">6</property> + </object> + </child> + + <!-- Omni Area --> + <child type="title"> + <object class="GtdOmniArea" id="omni_area"> + </object> + </child> + + <child type="end"> + <object class="GtkMenuButton" id="gear_menu_button"> + <property name="can_focus">1</property> + <property name="icon-name">view-more-symbolic</property> + </object> + </child> + + <child type="end"> + <object class="GtkBox" id="panel_box_end"> + <property name="spacing">6</property> + </object> + </child> + + </object> + </child> + + <child> + <object class="AdwToastOverlay" id="content_overlay"> + <!-- Panels Stack --> + <child> + <object class="GtkStack" id="stack"> + <property name="hexpand">true</property> + <property name="vexpand">true</property> + <property name="transition_duration">250</property> + <property name="transition_type">crossfade</property> + <signal name="notify::visible-child" handler="on_stack_visible_child_cb" object="GtdTaskListsWorkspace" swapped="yes"/> + <style> + <class name="background"/> + </style> + </object> + </child> + </object> + </child> + + + + + </object> + </child> + + </object> + </child> + + </template> + + <object class="GtdProviderPopover" id="new_list_popover"> + <property name="position">bottom</property> + </object> +</interface> diff --git a/src/plugins/task-lists-workspace/meson.build b/src/plugins/task-lists-workspace/meson.build new file mode 100644 index 0000000..b80dc50 --- /dev/null +++ b/src/plugins/task-lists-workspace/meson.build @@ -0,0 +1,20 @@ +plugins_ldflags += ['-Wl,--undefined=task_lists_workspace_plugin_register_types'] + +task_lists_panel_sources = files( + 'gtd-sidebar.c', + 'gtd-sidebar-list-row.c', + 'gtd-sidebar-panel-row.c', + 'gtd-sidebar-provider-row.c', + 'gtd-task-list-panel.c', + 'gtd-task-lists-workspace.c', + 'task-lists-workspace-plugin.c', +) + +task_lists_panel_sources += gnome.compile_resources( + 'task-lists-workspace', + 'task-lists-workspace.gresource.xml', + c_name: 'task_lists_workspace', + export: true, +) + +plugins_sources += task_lists_panel_sources diff --git a/src/plugins/task-lists-workspace/task-lists-workspace-plugin.c b/src/plugins/task-lists-workspace/task-lists-workspace-plugin.c new file mode 100644 index 0000000..78d071d --- /dev/null +++ b/src/plugins/task-lists-workspace/task-lists-workspace-plugin.c @@ -0,0 +1,31 @@ +/* gtd-plugin-task-lists-workspace.c + * + * Copyright 2020 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "endeavour.h" + +#include "gtd-task-lists-workspace.h" + +G_MODULE_EXPORT void +task_lists_workspace_plugin_register_types (PeasObjectModule *module) +{ + peas_object_module_register_extension_type (module, + GTD_TYPE_WORKSPACE, + GTD_TYPE_TASK_LISTS_WORKSPACE); +} diff --git a/src/plugins/task-lists-workspace/task-lists-workspace.gresource.xml b/src/plugins/task-lists-workspace/task-lists-workspace.gresource.xml new file mode 100644 index 0000000..cf76721 --- /dev/null +++ b/src/plugins/task-lists-workspace/task-lists-workspace.gresource.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/gnome/todo/plugins/task-lists-workspace"> + <file>gtd-sidebar.ui</file> + <file>gtd-sidebar-list-row.ui</file> + <file>gtd-sidebar-panel-row.ui</file> + <file>gtd-sidebar-provider-row.ui</file> + <file>gtd-task-list-panel.ui</file> + <file>gtd-task-lists-workspace.ui</file> + <file>task-lists-workspace.plugin</file> + </gresource> +</gresources> diff --git a/src/plugins/task-lists-workspace/task-lists-workspace.plugin b/src/plugins/task-lists-workspace/task-lists-workspace.plugin new file mode 100644 index 0000000..2b2f090 --- /dev/null +++ b/src/plugins/task-lists-workspace/task-lists-workspace.plugin @@ -0,0 +1,14 @@ +[Plugin] +Name = Task Lists Workspace +Module = task-lists-workspace +Description = Plugin implementing the task lists workspace +Version = @VERSION@ +Authors = Georges Basile Stavracas Neto <gbsneto@gnome.org> +Copyright = Copyleft © The Endeavour maintainers +Website = https://wiki.gnome.org/Apps/Todo +Builtin = true +Hidden = true +License = GPL +Loader = C +Embedded = task_lists_workspace_plugin_register_types +Depends = |
