[gnome-calendar] view: update interface code
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] view: update interface code
- Date: Wed, 9 Mar 2016 17:22:39 +0000 (UTC)
commit 34a6ac389adb99844dc21fd3fd6fe68a62b04f23
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Mar 9 14:19:04 2016 -0300
view: update interface code
This commit updates GcalView interface to use
modern GLib API and, consequently, removes tons
of obsolete code.
src/gcal-month-view.c | 6 +-
src/gcal-utils.c | 23 ---------
src/gcal-utils.h | 3 -
src/gcal-view.c | 124 +++++++++++++++++++++---------------------------
src/gcal-view.h | 42 +++++++----------
src/gcal-week-view.c | 6 +-
src/gcal-year-view.c | 4 +-
7 files changed, 79 insertions(+), 129 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 7e185f8..cba452b 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -121,8 +121,6 @@ static gboolean gcal_month_view_key_press (GtkWidget *wid
static void add_new_event_button_cb (GtkWidget *button,
gpointer user_data);
-static void gcal_view_interface_init (GcalViewIface *iface);
-
static void gcal_month_view_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -175,6 +173,8 @@ static void gcal_month_view_clear_marks (GcalView *vie
static GList* gcal_month_view_get_children_by_uuid (GcalView *view,
const gchar *uuid);
+static void gcal_view_interface_init (GcalViewInterface *iface);
+
G_DEFINE_TYPE_WITH_CODE (GcalMonthView, gcal_month_view,GCAL_TYPE_SUBSCRIBER_VIEW,
G_ADD_PRIVATE (GcalMonthView)
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW, gcal_view_interface_init));
@@ -841,7 +841,7 @@ gcal_month_view_init (GcalMonthView *self)
}
static void
-gcal_view_interface_init (GcalViewIface *iface)
+gcal_view_interface_init (GcalViewInterface *iface)
{
iface->get_initial_date = gcal_month_view_get_initial_date;
iface->get_final_date = gcal_month_view_get_final_date;
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index db89741..d8b82fe 100644
--- a/src/gcal-utils.c
+++ b/src/gcal-utils.c
@@ -245,29 +245,6 @@ get_color_name_from_source (ESource *source, GdkRGBA *out_color)
gdk_rgba_parse (out_color, "#becedd"); /* calendar default colour */
}
-gint
-gcal_compare_event_widget_by_date (gconstpointer a,
- gconstpointer b)
-{
- /* negative value if a < b; zero if a = b; positive value if a > b. */
- GcalViewChild *a_child;
- GcalViewChild *b_child;
- GDateTime *a_date;
- GDateTime *b_date;
-
- gint comparison;
-
- a_child = (GcalViewChild*) a;
- b_child = (GcalViewChild*) b;
-
- a_date = gcal_event_get_date_start (gcal_event_widget_get_event (GCAL_EVENT_WIDGET (a_child->widget)));
- b_date = gcal_event_get_date_start (gcal_event_widget_get_event (GCAL_EVENT_WIDGET (b_child->widget)));
-
- comparison = g_date_time_compare (a_date, b_date);
-
- return comparison;
-}
-
/**
* get_desc_from_component:
* @component:
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
index a5984aa..e3c4148 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -76,9 +76,6 @@ GdkPixbuf* get_circle_pixbuf_from_color (GdkRGBA
void get_color_name_from_source (ESource *source,
GdkRGBA *out_color);
-gint gcal_compare_event_widget_by_date (gconstpointer a,
- gconstpointer b);
-
gchar* get_desc_from_component (ECalComponent *component,
const gchar *joint_char);
diff --git a/src/gcal-view.c b/src/gcal-view.c
index cd04e64..6c29102 100644
--- a/src/gcal-view.c
+++ b/src/gcal-view.c
@@ -3,6 +3,7 @@
* gcal-view.c
*
* Copyright (C) 2015 - Erick PĂ©rez Castellanos
+ * 2016 - 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
@@ -23,70 +24,53 @@
#include <glib.h>
-static void
-gcal_view_base_init (gpointer g_iface)
-{
- static gboolean initialized = FALSE;
-
- if (!initialized)
- {
- /* create interface signals && properties here. */
- g_object_interface_install_property (
- g_iface,
- g_param_spec_boxed ("active-date",
- "The active date",
- "The active/selecetd date in the view",
- ICAL_TIME_TYPE,
- G_PARAM_READWRITE));
-
- g_signal_new ("create-event",
- GCAL_TYPE_VIEW,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GcalViewIface,
- create_event),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 4,
- G_TYPE_POINTER,
- G_TYPE_POINTER,
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE);
-
- g_signal_new ("create-event-detailed", GCAL_TYPE_VIEW, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GcalViewIface, create_event_detailed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
-
- initialized = TRUE;
- }
-}
-GType
-gcal_view_get_type (void)
+G_DEFINE_INTERFACE (GcalView, gcal_view, GTK_TYPE_WIDGET)
+
+static void
+gcal_view_default_init (GcalViewInterface *iface)
{
- static GType type = 0;
- if (type == 0)
- {
- const GTypeInfo info =
- {
- sizeof (GcalViewIface),
- gcal_view_base_init, /* base_init */
- NULL, /* base_finalize */
- NULL, /* class_init */
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL /* instance_init */
- };
- type = g_type_register_static (G_TYPE_INTERFACE,
- "GcalView",
- &info,
- 0);
- g_type_interface_add_prerequisite (type,
- G_TYPE_OBJECT);
- }
- return type;
+ /**
+ * GcalView::active-date:
+ *
+ * The active date of the view.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_boxed ("active-date",
+ "The active date",
+ "The active/selecetd date in the view",
+ ICAL_TIME_TYPE,
+ G_PARAM_READWRITE));
+
+ /**
+ * GcalView::create-event:
+ *
+ * Emitted when the view wants to create an event.
+ */
+ g_signal_new ("create-event",
+ GCAL_TYPE_VIEW,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalViewInterface, create_event),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 4,
+ G_TYPE_POINTER,
+ G_TYPE_POINTER,
+ G_TYPE_DOUBLE,
+ G_TYPE_DOUBLE);
+
+ /**
+ * GcalView::create-event-detailed:
+ *
+ * Emitted when the view wants to create an event and immediately
+ * edit it.
+ */
+ g_signal_new ("create-event-detailed",
+ GCAL_TYPE_VIEW,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalViewInterface, create_event_detailed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
}
void
@@ -121,9 +105,9 @@ icaltimetype*
gcal_view_get_initial_date (GcalView *view)
{
g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
- g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_initial_date, NULL);
+ g_return_val_if_fail (GCAL_VIEW_GET_IFACE (view)->get_initial_date, NULL);
- return GCAL_VIEW_GET_INTERFACE (view)->get_initial_date (view);
+ return GCAL_VIEW_GET_IFACE (view)->get_initial_date (view);
}
/**
@@ -138,9 +122,9 @@ icaltimetype*
gcal_view_get_final_date (GcalView *view)
{
g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
- g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_final_date, NULL);
+ g_return_val_if_fail (GCAL_VIEW_GET_IFACE (view)->get_final_date, NULL);
- return GCAL_VIEW_GET_INTERFACE (view)->get_final_date (view);
+ return GCAL_VIEW_GET_IFACE (view)->get_final_date (view);
}
/**
@@ -153,9 +137,9 @@ void
gcal_view_clear_marks (GcalView *view)
{
g_return_if_fail (GCAL_IS_VIEW (view));
- g_return_if_fail (GCAL_VIEW_GET_INTERFACE (view)->clear_marks);
+ g_return_if_fail (GCAL_VIEW_GET_IFACE (view)->clear_marks);
- GCAL_VIEW_GET_INTERFACE (view)->clear_marks (view);
+ GCAL_VIEW_GET_IFACE (view)->clear_marks (view);
}
/**
@@ -172,7 +156,7 @@ gcal_view_get_children_by_uuid (GcalView *view,
const gchar *uuid)
{
g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
- g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_children_by_uuid, NULL);
+ g_return_val_if_fail (GCAL_VIEW_GET_IFACE (view)->get_children_by_uuid, NULL);
- return GCAL_VIEW_GET_INTERFACE (view)->get_children_by_uuid (view, uuid);
+ return GCAL_VIEW_GET_IFACE (view)->get_children_by_uuid (view, uuid);
}
diff --git a/src/gcal-view.h b/src/gcal-view.h
index 8472287..3c4ec90 100644
--- a/src/gcal-view.h
+++ b/src/gcal-view.h
@@ -24,43 +24,35 @@
G_BEGIN_DECLS
-#define GCAL_TYPE_VIEW (gcal_view_get_type ())
-#define GCAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCAL_TYPE_VIEW, GcalView))
-#define GCAL_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCAL_TYPE_VIEW))
-#define GCAL_VIEW_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GCAL_TYPE_VIEW,
GcalViewIface))
+#define GCAL_TYPE_VIEW (gcal_view_get_type ())
-struct _GcalViewChild
-{
- GtkWidget *widget;
- gboolean hidden;
-};
-
-typedef struct _GcalViewChild GcalViewChild;
+G_DECLARE_INTERFACE (GcalView, gcal_view, GCAL, VIEW, GtkWidget)
-typedef struct _GcalView GcalView;
-typedef struct _GcalViewIface GcalViewIface;
-
-struct _GcalViewIface
+struct _GcalViewInterface
{
- GTypeInterface parent_iface;
+ GTypeInterface parent;
/* signals */
- void (*create_event) (GcalView *view, icaltimetype *start_span,
icaltimetype *end_span, gdouble x, gdouble y);
- void (*create_event_detailed) (GcalView *view, icaltimetype *start_span,
icaltimetype *end_span);
+ void (*create_event) (GcalView *view,
+ icaltimetype *start_span,
+ icaltimetype *end_span,
+ gdouble x,
+ gdouble y);
+ void (*create_event_detailed) (GcalView *view,
+ icaltimetype *start_span,
+ icaltimetype *end_span);
/* Time handling related API */
- icaltimetype* (*get_initial_date) (GcalView *view);
- icaltimetype* (*get_final_date) (GcalView *view);
+ icaltimetype* (*get_initial_date) (GcalView *view);
+ icaltimetype* (*get_final_date) (GcalView *view);
/* Marks related API */
- void (*clear_marks) (GcalView *view);
+ void (*clear_marks) (GcalView *view);
- GList* (*get_children_by_uuid) (GcalView *view, const gchar *uuid);
+ GList* (*get_children_by_uuid) (GcalView *view,
+ const gchar *uuid);
};
-GType gcal_view_get_type (void);
-
-
void gcal_view_set_date (GcalView *view,
icaltimetype *date);
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index 8854a79..4d9323d 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -102,8 +102,6 @@ static void draw_grid_window (GcalWeekView *view
static gint get_sidebar_width (GtkWidget *widget);
-static void gcal_view_interface_init (GcalViewIface *iface);
-
static void gcal_week_view_constructed (GObject *object);
static void gcal_week_view_finalize (GObject *object);
@@ -158,6 +156,8 @@ static icaltimetype* gcal_week_view_get_final_date (GcalView *view
static GtkWidget* gcal_week_view_get_by_uuid (GcalSubscriberView *view,
const gchar *uuid);
+static void gcal_view_interface_init (GcalViewInterface *iface);
+
G_DEFINE_TYPE_WITH_CODE (GcalWeekView, gcal_week_view, GCAL_TYPE_SUBSCRIBER_VIEW,
G_ADD_PRIVATE (GcalWeekView)
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW, gcal_view_interface_init));
@@ -553,7 +553,7 @@ gcal_week_view_init (GcalWeekView *self)
}
static void
-gcal_view_interface_init (GcalViewIface *iface)
+gcal_view_interface_init (GcalViewInterface *iface)
{
iface->get_initial_date = gcal_week_view_get_initial_date;
iface->get_final_date = gcal_week_view_get_final_date;
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index b04ab9a..994a2e0 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -112,7 +112,7 @@ enum
static guint signals[NUM_SIGNALS] = { 0, };
static void reset_sidebar (GcalYearView *year_view);
-static void gcal_view_interface_init (GcalViewIface *iface);
+static void gcal_view_interface_init (GcalViewInterface *iface);
static void gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GcalYearView, gcal_year_view, GTK_TYPE_BOX,
@@ -1474,7 +1474,7 @@ gcal_year_view_init (GcalYearView *self)
}
static void
-gcal_view_interface_init (GcalViewIface *iface)
+gcal_view_interface_init (GcalViewInterface *iface)
{
/* FIXME: implement what's needed */
iface->get_children_by_uuid = gcal_year_view_get_children_by_uuid;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]