[gnome-calendar] month-view: makes a descendant of GcalSubscriber
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] month-view: makes a descendant of GcalSubscriber
- Date: Thu, 4 Dec 2014 22:39:05 +0000 (UTC)
commit aca1b66743d01e084b5b1c483878ce3f4fee674e
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Tue Oct 21 00:24:34 2014 -0400
month-view: makes a descendant of GcalSubscriber
By making GcalMonthView a descendat of GcalSubscriber it gets
implementation for each of the methods on ECalDataModel subscriber and
utomatically gains the functionality of adding and removing events widgets
src/gcal-month-view.c | 135 ++----------------------------------------------
src/gcal-month-view.h | 7 +--
2 files changed, 9 insertions(+), 133 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 46f04a9..00dda35 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -65,8 +65,6 @@ static void event_opened (GcalEventWidget *ev
static void gcal_view_interface_init (GcalViewIface *iface);
-static void gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface);
-
static void gcal_month_view_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -141,31 +139,12 @@ static void gcal_month_view_clear (GcalView *vie
static gboolean gcal_month_view_will_add_event (GcalView *view,
GcalEventWidget *event);
-static void gcal_month_view_subscriber_component_added (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- ECalComponent *comp);
-
-static void gcal_month_view_subscriber_component_modified (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- ECalComponent *comp);
-
-static void gcal_month_view_subscriber_component_removed (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- const gchar *uid,
- const gchar *rid);
-
-static void gcal_month_view_subscriber_freeze (ECalDataModelSubscriber *subscriber);
-
-static void gcal_month_view_subscriber_thaw (ECalDataModelSubscriber *subscriber);
-
G_DEFINE_TYPE_WITH_CODE (GcalMonthView,
gcal_month_view,
- GTK_TYPE_CONTAINER,
+ GCAL_TYPE_SUBSCRIBER,
G_ADD_PRIVATE (GcalMonthView)
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
- gcal_view_interface_init)
- G_IMPLEMENT_INTERFACE (E_TYPE_CAL_DATA_MODEL_SUBSCRIBER,
- gcal_data_model_subscriber_interface_init));
+ gcal_view_interface_init));
static void
@@ -254,17 +233,6 @@ gcal_view_interface_init (GcalViewIface *iface)
}
static void
-gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface)
-{
- iface->component_added = gcal_month_view_subscriber_component_added;
- iface->component_modified = gcal_month_view_subscriber_component_modified;
- iface->component_removed = gcal_month_view_subscriber_component_removed;
- iface->freeze = gcal_month_view_subscriber_freeze;
- iface->thaw = gcal_month_view_subscriber_thaw;
-}
-
-
-static void
gcal_month_view_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -1078,6 +1046,10 @@ gcal_month_view_add (GtkContainer *container,
gcal_compare_event_widget_by_date);
gtk_widget_set_parent (widget, GTK_WIDGET (container));
+ g_signal_connect (widget,
+ "activate",
+ G_CALLBACK (event_opened),
+ container);
g_free (date);
}
@@ -1395,101 +1367,6 @@ gcal_month_view_will_add_event (GcalView *view,
return !(gcal_month_view_get_by_uuid (view, event_uuid) != NULL);
}
-/* ECalDataModelSubscriber interface API */
-static void
-gcal_month_view_subscriber_component_added (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- ECalComponent *comp)
-{
- GtkWidget *event;
- GcalEventData *data;
-
- data = g_new0 (GcalEventData, 1);
- data->source = e_client_get_source (E_CLIENT (client));
- data->event_component = e_cal_component_clone (comp);
-
- event = gcal_event_widget_new_from_data (data);
- g_free (data);
-
- gtk_widget_show (event);
- gtk_container_add (GTK_CONTAINER (subscriber), event);
-
- g_signal_connect (event,
- "activate",
- G_CALLBACK (event_opened),
- subscriber);
-}
-
-static void
-gcal_month_view_subscriber_component_modified (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- ECalComponent *comp)
-{
- GtkWidget *event;
- GtkWidget *widget;
- GcalEventData *data;
-
- data = g_new0 (GcalEventData, 1);
- data->source = e_client_get_source (E_CLIENT (client));
- data->event_component = e_cal_component_clone (comp);
-
- event = gcal_event_widget_new_from_data (data);
- g_free (data);
-
- widget =
- gcal_view_get_by_uuid (GCAL_VIEW (subscriber),
- gcal_event_widget_peek_uuid (GCAL_EVENT_WIDGET (event)));
- if (widget != NULL)
- {
- gtk_widget_destroy (widget);
-
- gtk_widget_show (event);
- gtk_container_add (GTK_CONTAINER (subscriber), event);
- }
-
- g_signal_connect (event,
- "activate",
- G_CALLBACK (event_opened),
- subscriber);
-}
-
-static void
-gcal_month_view_subscriber_component_removed (ECalDataModelSubscriber *subscriber,
- ECalClient *client,
- const gchar *uid,
- const gchar *rid)
-{
- GtkWidget *widget;
- const gchar *sid;
- gchar *uuid;
-
- sid = e_source_get_uid (e_client_get_source (E_CLIENT (client)));
-
- if (rid != NULL)
- uuid = g_strdup_printf ("%s:%s:%s", sid, uid, rid);
- else
- uuid = g_strdup_printf ("%s:%s", sid, uid);
-
- widget = gcal_view_get_by_uuid (GCAL_VIEW (subscriber), uuid);
- if (widget != NULL)
- gtk_widget_destroy (widget);
- else
- g_warning ("%s: Widget with uuid: %s not found",
- G_STRFUNC, uuid);
-
- g_free (uuid);
-}
-
-static void
-gcal_month_view_subscriber_freeze (ECalDataModelSubscriber *subscriber)
-{
-}
-
-static void
-gcal_month_view_subscriber_thaw (ECalDataModelSubscriber *subscriber)
-{
-}
-
/* Public API */
/**
* gcal_month_view_new:
diff --git a/src/gcal-month-view.h b/src/gcal-month-view.h
index cf5b50c..96c67d8 100644
--- a/src/gcal-month-view.h
+++ b/src/gcal-month-view.h
@@ -21,8 +21,7 @@
#define __GCAL_MONTH_VIEW_H__
#include "gcal-manager.h"
-
-#include <gtk/gtk.h>
+#include "gcal-subscriber.h"
G_BEGIN_DECLS
@@ -38,12 +37,12 @@ typedef struct _GcalMonthViewClass GcalMonthViewClass;
struct _GcalMonthView
{
- GtkContainer parent;
+ GcalSubscriber parent;
};
struct _GcalMonthViewClass
{
- GtkContainerClass parent_class;
+ GcalSubscriberClass parent_class;
/* signals */
void (*new_event) (gint new_day);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]