[gnome-todo/wip/gbsneto/plugins: 12/62] panel: add GtdPanel interface



commit fe068e38df8b9edb9fbd7b9165c60f6356bc7b0e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Dec 13 14:44:17 2015 -0200

    panel: add GtdPanel interface
    
    Every panel visible in the main window, such as
    Today, Scheduled or Lists, will be an GtdPanel
    implementation.

 src/Makefile.am            |    2 +
 src/gtd-types.h            |    1 +
 src/interfaces/gtd-panel.c |  113 ++++++++++++++++++++++++++++++++++++++++++++
 src/interfaces/gtd-panel.h |   57 ++++++++++++++++++++++
 4 files changed, 173 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a96fef0..6c6dca8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,8 @@ ENUM_TYPES = \
 
 gnome_todo_SOURCES = \
        $(BUILT_SOURCES) \
+       interfaces/gtd-panel.c \
+       interfaces/gtd-panel.h \
        notification/gtd-notification.c \
        notification/gtd-notification.h \
        notification/gtd-notification-widget.c \
diff --git a/src/gtd-types.h b/src/gtd-types.h
index 5bd651a..d1b3cc9 100644
--- a/src/gtd-types.h
+++ b/src/gtd-types.h
@@ -32,6 +32,7 @@ typedef struct _GtdManager              GtdManager;
 typedef struct _GtdNotification         GtdNotification;
 typedef struct _GtdNotificationWidget   GtdNotificationWidget;
 typedef struct _GtdObject               GtdObject;
+typedef struct _GtdPanel                GtdPanel;
 typedef struct _GtdStorage              GtdStorage;
 typedef struct _GtdStoragePopover       GtdStoragePopover;
 typedef struct _GtdStorageRow           GtdStorageRow;
diff --git a/src/interfaces/gtd-panel.c b/src/interfaces/gtd-panel.c
new file mode 100644
index 0000000..62f7a71
--- /dev/null
+++ b/src/interfaces/gtd-panel.c
@@ -0,0 +1,113 @@
+/* gtd-panel.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-panel.h"
+
+G_DEFINE_INTERFACE (GtdPanel, gtd_panel, GTK_TYPE_WIDGET)
+
+static void
+gtd_panel_default_init (GtdPanelInterface *iface)
+{
+  /**
+   * GtdPanel::name:
+   *
+   * The identifier name of the panel. It is used as the #GtkStack
+   * name, so be sure to use a specific name that won't collide with
+   * other plugins.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_string ("name",
+                                                            "The name of the panel",
+                                                            "The identifier name of the panel",
+                                                            NULL,
+                                                            G_PARAM_READABLE));
+
+  /**
+   * GtdPanel::title:
+   *
+   * The user-visible title of the panel. It is used as the #GtkStack
+   * title.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_string ("title",
+                                                            "The title of the panel",
+                                                            "The user-visible title of the panel",
+                                                            NULL,
+                                                            G_PARAM_READABLE));
+
+  /**
+   * GtdPanel::header-widgets:
+   *
+   * A #GList of widgets to be added to the headerbar.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_boxed ("header-widgets",
+                                                           "The header widgets",
+                                                           "The widgets to be added in the headerbar",
+                                                           G_TYPE_POINTER,
+                                                           G_PARAM_READABLE));
+
+  /**
+   * GtdPanel::menu:
+   *
+   * A #GMenu of entries of the window menu.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_object ("menu",
+                                                            "The title of the panel",
+                                                            "The user-visible title of the panel",
+                                                            G_TYPE_MENU,
+                                                            G_PARAM_READABLE));
+
+}
+
+const gchar*
+gtd_panel_get_name (GtdPanel *panel)
+{
+  g_return_val_if_fail (GTD_IS_PANEL (panel), NULL);
+  g_return_val_if_fail (GTD_PANEL_GET_IFACE (panel)->get_name, NULL);
+
+  return GTD_PANEL_GET_IFACE (panel)->get_name (panel);
+}
+
+const gchar*
+gtd_panel_get_title (GtdPanel *panel)
+{
+  g_return_val_if_fail (GTD_IS_PANEL (panel), NULL);
+  g_return_val_if_fail (GTD_PANEL_GET_IFACE (panel)->get_title, NULL);
+
+  return GTD_PANEL_GET_IFACE (panel)->get_title (panel);
+}
+
+const GtkWidget*
+gtd_panel_get_header_widget (GtdPanel *panel)
+{
+  g_return_val_if_fail (GTD_IS_PANEL (panel), NULL);
+  g_return_val_if_fail (GTD_PANEL_GET_IFACE (panel)->get_header_widget, NULL);
+
+  return GTD_PANEL_GET_IFACE (panel)->get_header_widget (panel);
+}
+
+const GMenu*
+gtd_panel_get_menu (GtdPanel *panel)
+{
+  g_return_val_if_fail (GTD_IS_PANEL (panel), NULL);
+  g_return_val_if_fail (GTD_PANEL_GET_IFACE (panel)->get_menu, NULL);
+
+  return GTD_PANEL_GET_IFACE (panel)->get_menu (panel);
+}
diff --git a/src/interfaces/gtd-panel.h b/src/interfaces/gtd-panel.h
new file mode 100644
index 0000000..f012285
--- /dev/null
+++ b/src/interfaces/gtd-panel.h
@@ -0,0 +1,57 @@
+/* gtd-panel.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_PANEL_H
+#define GTD_PANEL_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include <gtd-types.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_PANEL (gtd_panel_get_type ())
+
+G_DECLARE_INTERFACE (GtdPanel, gtd_panel, GTD, PANEL, GtkWidget)
+
+struct _GtdPanelInterface
+{
+  GTypeInterface parent;
+
+  const gchar*       (*get_name)                           (GtdPanel        *panel);
+
+  const gchar*       (*get_title)                          (GtdPanel        *panel);
+
+  const GtkWidget*   (*get_header_widget)                  (GtdPanel        *panel);
+
+  const GMenu*       (*get_menu)                           (GtdPanel        *panel);
+};
+
+const gchar*         gtd_panel_get_name                          (GtdPanel           *panel);
+
+const gchar*         gtd_panel_get_title                         (GtdPanel           *panel);
+
+const GtkWidget*     gtd_panel_get_header_widget                 (GtdPanel           *panel);
+
+const GMenu*         gtd_panel_get_menu                          (GtdPanel           *panel);
+
+G_END_DECLS
+
+#endif /* GTD_PANEL_H */


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