[gnome-todo/wip/gbsneto/plugins] list-selector: stub out interface



commit 9a8a15c46c4bb8309510df3ed42a3eb46b4adaa2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Dec 28 13:17:56 2015 -0200

    list-selector: stub out interface
    
    This interface will be implemented by
    the Grid & List view selectors. After
    that, I'll add a GtdPanel impl for
    list selectors.

 src/Makefile.am               |    2 +
 src/views/gtd-list-selector.c |  114 +++++++++++++++++++++++++++++++++++++++++
 src/views/gtd-list-selector.h |   60 +++++++++++++++++++++
 3 files changed, 176 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index f47b0f2..718d0d1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,6 +38,8 @@ gnome_todo_SOURCES = \
        provider/gtd-provider-row.h \
        provider/gtd-provider-selector.c \
        provider/gtd-provider-selector.h \
+       views/gtd-list-selector.c \
+       views/gtd-list-selector.h \
        gtd-application.c \
        gtd-application.h \
        gtd-arrow-frame.c \
diff --git a/src/views/gtd-list-selector.c b/src/views/gtd-list-selector.c
new file mode 100644
index 0000000..8bb8963
--- /dev/null
+++ b/src/views/gtd-list-selector.c
@@ -0,0 +1,114 @@
+/* gtd-list-selector.c
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#include "gtd-enum-types.h"
+#include "gtd-task-list.h"
+#include "gtd-list-selector.h"
+
+G_DEFINE_INTERFACE (GtdListSelector, gtd_list_selector, GTK_TYPE_WIDGET)
+
+enum {
+  LIST_SELECTED,
+  NUM_SIGNALS
+};
+
+static guint signals[NUM_SIGNALS] = { 0, };
+
+static void
+gtd_list_selector_default_init (GtdListSelectorInterface *iface)
+{
+  /**
+   * GtdListSelector::mode:
+   *
+   * The #GtdWindowMode of the list selector.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_enum ("mode",
+                                                          "Mode of the list selector",
+                                                          "The mode of the list selector",
+                                                          GTD_TYPE_WINDOW_MODE,
+                                                          GTD_WINDOW_MODE_NORMAL,
+                                                          G_PARAM_READWRITE));
+
+  /**
+   * GtdListSelector::search-query:
+   *
+   * The search query of the list selector.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_string ("search-query",
+                                                            "Search query of the list selector",
+                                                            "The search query of the list selector",
+                                                            NULL,
+                                                            G_PARAM_READWRITE));
+
+  /**
+   * GtdListSelector::list-selected:
+   *
+   * The ::list-selected signals is emited whenever
+   * a #GtdTaskList is selected.
+   */
+  signals[LIST_SELECTED] = g_signal_new ("list-selected",
+                                         GTD_TYPE_LIST_SELECTOR,
+                                         G_SIGNAL_RUN_LAST,
+                                         0,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         G_TYPE_NONE,
+                                         1,
+                                         GTD_TYPE_TASK_LIST);
+}
+
+GtdWindowMode
+gtd_list_selector_get_mode (GtdListSelector *selector)
+{
+  g_return_val_if_fail (GTD_IS_LIST_SELECTOR (selector), GTD_WINDOW_MODE_NORMAL);
+  g_return_val_if_fail (GTD_LIST_SELECTOR_GET_IFACE (selector)->get_mode, GTD_WINDOW_MODE_NORMAL);
+
+  return GTD_LIST_SELECTOR_GET_IFACE (selector)->get_mode (selector);
+}
+
+void
+gtd_list_selector_set_mode (GtdListSelector *selector,
+                            GtdWindowMode    mode)
+{
+  g_return_if_fail (GTD_IS_LIST_SELECTOR (selector));
+  g_return_if_fail (GTD_LIST_SELECTOR_GET_IFACE (selector)->set_mode);
+
+  GTD_LIST_SELECTOR_GET_IFACE (selector)->set_mode (selector, mode);
+}
+
+const gchar*
+gtd_list_selector_get_search_query (GtdListSelector *selector)
+{
+  g_return_val_if_fail (GTD_IS_LIST_SELECTOR (selector), NULL);
+  g_return_val_if_fail (GTD_LIST_SELECTOR_GET_IFACE (selector)->get_search_query, NULL);
+
+  return GTD_LIST_SELECTOR_GET_IFACE (selector)->get_search_query (selector);
+}
+
+void
+gtd_list_selector_set_search_query (GtdListSelector *selector,
+                                    const gchar     *search_query)
+{
+  g_return_if_fail (GTD_IS_LIST_SELECTOR (selector));
+  g_return_if_fail (GTD_LIST_SELECTOR_GET_IFACE (selector)->set_search_query);
+
+  GTD_LIST_SELECTOR_GET_IFACE (selector)->set_search_query (selector, search_query);
+}
diff --git a/src/views/gtd-list-selector.h b/src/views/gtd-list-selector.h
new file mode 100644
index 0000000..6de2561
--- /dev/null
+++ b/src/views/gtd-list-selector.h
@@ -0,0 +1,60 @@
+/* gtd-list-selector.h
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#ifndef GTD_LIST_SELECTOR_H
+#define GTD_LIST_SELECTOR_H
+
+#include "gtd-enums.h"
+#include "gtd-types.h"
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_LIST_SELECTOR (gtd_list_selector_get_type ())
+
+G_DECLARE_INTERFACE (GtdListSelector, gtd_list_selector, GTD, LIST_SELECTOR, GtkWidget)
+
+struct _GtdListSelectorInterface
+{
+  GTypeInterface parent;
+
+  GtdWindowMode      (*get_mode)                                 (GtdListSelector    *selector);
+
+  void               (*set_mode)                                 (GtdListSelector    *selector,
+                                                                  GtdWindowMode       mode);
+
+  const gchar*       (*get_search_query)                         (GtdListSelector    *selector);
+
+  void               (*set_search_query)                         (GtdListSelector    *selector,
+                                                                  const gchar        *search_query);
+};
+
+GtdWindowMode        gtd_list_selector_get_mode                  (GtdListSelector    *selector);
+
+void                 gtd_list_selector_set_mode                  (GtdListSelector    *selector,
+                                                                  GtdWindowMode       mode);
+
+const gchar*         gtd_list_selector_get_search_query          (GtdListSelector    *selector);
+
+void                 gtd_list_selector_set_search_query          (GtdListSelector    *selector,
+                                                                  const gchar        *search_query);
+
+G_END_DECLS
+
+#endif /* GTD_LIST_SELECTOR_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]