Converted GcalMonthView to GtkContainer subclass.
Added gcal_view_add_event method GcalView interface. Fixed size_allocate implementation in GcalMonthView to allocate children events. There's still work to be done here.
This commit is contained in:
+141
-52
@@ -21,6 +21,7 @@
|
|||||||
#include "gcal-month-view.h"
|
#include "gcal-month-view.h"
|
||||||
#include "gcal-utils.h"
|
#include "gcal-utils.h"
|
||||||
#include "gcal-view.h"
|
#include "gcal-view.h"
|
||||||
|
#include "gcal-event-widget.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
@@ -32,12 +33,14 @@ enum
|
|||||||
|
|
||||||
struct _GcalMonthViewPrivate
|
struct _GcalMonthViewPrivate
|
||||||
{
|
{
|
||||||
|
GList *events;
|
||||||
|
|
||||||
GdkWindow *event_window;
|
GdkWindow *event_window;
|
||||||
|
|
||||||
icaltimetype *date;
|
icaltimetype *date;
|
||||||
|
|
||||||
|
gint days_delay;
|
||||||
gint header_font_size;
|
gint header_font_size;
|
||||||
|
|
||||||
gdouble vertical_step;
|
gdouble vertical_step;
|
||||||
gdouble horizontal_step;
|
gdouble horizontal_step;
|
||||||
};
|
};
|
||||||
@@ -56,9 +59,6 @@ const char* weekdays [] =
|
|||||||
|
|
||||||
static void _gcal_view_interface_init (GcalViewIface *iface);
|
static void _gcal_view_interface_init (GcalViewIface *iface);
|
||||||
|
|
||||||
static gboolean _gcal_month_view_is_in_range (GcalView *view,
|
|
||||||
icaltimetype *date);
|
|
||||||
|
|
||||||
static void gcal_month_view_set_property (GObject *object,
|
static void gcal_month_view_set_property (GObject *object,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
@@ -69,6 +69,8 @@ static void gcal_month_view_get_property (GObject *object,
|
|||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static void gcal_month_view_finalize (GObject *object);
|
||||||
|
|
||||||
static void gcal_month_view_realize (GtkWidget *widget);
|
static void gcal_month_view_realize (GtkWidget *widget);
|
||||||
|
|
||||||
static void gcal_month_view_unrealize (GtkWidget *widget);
|
static void gcal_month_view_unrealize (GtkWidget *widget);
|
||||||
@@ -83,27 +85,38 @@ static void gcal_month_view_size_allocate (GtkWidget *widget,
|
|||||||
static gboolean gcal_month_view_draw (GtkWidget *widget,
|
static gboolean gcal_month_view_draw (GtkWidget *widget,
|
||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
|
|
||||||
static void gcal_month_view_finalize (GObject *object);
|
static void gcal_month_view_forall (GtkContainer *container,
|
||||||
|
gboolean include_internals,
|
||||||
|
GtkCallback callback,
|
||||||
|
gpointer callback_data);
|
||||||
|
|
||||||
static void _gcal_month_view_draw_month_grid (GcalMonthView *mont_view,
|
static void _gcal_month_view_draw_month_grid (GcalMonthView *mont_view,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y);
|
||||||
gint width,
|
|
||||||
gint height);
|
static gboolean _gcal_month_view_is_in_range (GcalView *view,
|
||||||
|
icaltimetype *date);
|
||||||
|
|
||||||
|
static void _gcal_month_view_add_event (GcalView *view,
|
||||||
|
GtkWidget *event);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GcalMonthView,
|
G_DEFINE_TYPE_WITH_CODE (GcalMonthView,
|
||||||
gcal_month_view,
|
gcal_month_view,
|
||||||
GTK_TYPE_WIDGET,
|
GTK_TYPE_CONTAINER,
|
||||||
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
|
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
|
||||||
_gcal_view_interface_init));
|
_gcal_view_interface_init));
|
||||||
|
|
||||||
|
|
||||||
static void gcal_month_view_class_init (GcalMonthViewClass *klass)
|
static void gcal_month_view_class_init (GcalMonthViewClass *klass)
|
||||||
{
|
{
|
||||||
GtkWidgetClass* widget_class;
|
GtkContainerClass *container_class;
|
||||||
|
GtkWidgetClass *widget_class;
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
container_class = GTK_CONTAINER_CLASS (klass);
|
||||||
|
container_class->forall = gcal_month_view_forall;
|
||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
widget_class->realize = gcal_month_view_realize;
|
widget_class->realize = gcal_month_view_realize;
|
||||||
widget_class->unrealize = gcal_month_view_unrealize;
|
widget_class->unrealize = gcal_month_view_unrealize;
|
||||||
@@ -138,23 +151,18 @@ static void gcal_month_view_init (GcalMonthView *self)
|
|||||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||||
GCAL_TYPE_MONTH_VIEW,
|
GCAL_TYPE_MONTH_VIEW,
|
||||||
GcalMonthViewPrivate);
|
GcalMonthViewPrivate);
|
||||||
|
|
||||||
|
gtk_container_set_reallocate_redraws (GTK_CONTAINER (self),
|
||||||
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gcal_view_interface_init (GcalViewIface *iface)
|
_gcal_view_interface_init (GcalViewIface *iface)
|
||||||
{
|
{
|
||||||
iface->is_in_range = _gcal_month_view_is_in_range;
|
iface->is_in_range = _gcal_month_view_is_in_range;
|
||||||
|
iface->add_event = _gcal_month_view_add_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_gcal_month_view_is_in_range (GcalView *view,
|
|
||||||
icaltimetype *date)
|
|
||||||
{
|
|
||||||
g_debug ("Implementation of is_in_range called");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_month_view_set_property (GObject *object,
|
gcal_month_view_set_property (GObject *object,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
@@ -166,11 +174,20 @@ gcal_month_view_set_property (GObject *object,
|
|||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
case PROP_DATE:
|
case PROP_DATE:
|
||||||
if (priv->date != NULL)
|
{
|
||||||
g_free (priv->date);
|
icaltimetype *first_of_month;
|
||||||
|
|
||||||
priv->date = g_value_dup_boxed (value);
|
if (priv->date != NULL)
|
||||||
break;
|
g_free (priv->date);
|
||||||
|
|
||||||
|
priv->date = g_value_dup_boxed (value);
|
||||||
|
|
||||||
|
first_of_month = gcal_dup_icaltime (priv->date);
|
||||||
|
first_of_month->day = 1;
|
||||||
|
priv->days_delay = - icaltime_day_of_week (*first_of_month) + 2;
|
||||||
|
g_free (first_of_month);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -196,6 +213,18 @@ gcal_month_view_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gcal_month_view_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GcalMonthViewPrivate *priv = GCAL_MONTH_VIEW (object)->priv;
|
||||||
|
|
||||||
|
if (priv->date != NULL)
|
||||||
|
g_free (priv->date);
|
||||||
|
|
||||||
|
/* Chain up to parent's finalize() method. */
|
||||||
|
G_OBJECT_CLASS (gcal_month_view_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_month_view_realize (GtkWidget *widget)
|
gcal_month_view_realize (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@@ -278,9 +307,14 @@ gcal_month_view_unmap (GtkWidget *widget)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_month_view_size_allocate (GtkWidget *widget,
|
gcal_month_view_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation)
|
GtkAllocation *allocation)
|
||||||
{
|
{
|
||||||
GcalMonthViewPrivate *priv;
|
GcalMonthViewPrivate *priv;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkStateFlags state;
|
||||||
|
GtkBorder padding;
|
||||||
|
|
||||||
priv = GCAL_MONTH_VIEW (widget)->priv;
|
priv = GCAL_MONTH_VIEW (widget)->priv;
|
||||||
gtk_widget_set_allocation (widget, allocation);
|
gtk_widget_set_allocation (widget, allocation);
|
||||||
@@ -291,6 +325,44 @@ gcal_month_view_size_allocate (GtkWidget *widget,
|
|||||||
allocation->y,
|
allocation->y,
|
||||||
allocation->width,
|
allocation->width,
|
||||||
allocation->height);
|
allocation->height);
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
state = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
|
gtk_style_context_get_padding (context, state, &padding);
|
||||||
|
/* init values */
|
||||||
|
priv->header_font_size = 12;
|
||||||
|
priv->horizontal_step =
|
||||||
|
(allocation->width - (allocation->x + padding.left + padding.right)) / 7;
|
||||||
|
priv->vertical_step =
|
||||||
|
(allocation->height - (allocation->y + padding.top + padding.bottom + priv->header_font_size)) / 5;
|
||||||
|
|
||||||
|
g_debug ("[IWSIZEA]: hs %f vs %f\n",
|
||||||
|
priv->horizontal_step,
|
||||||
|
priv->vertical_step);
|
||||||
|
|
||||||
|
for (l = priv->events; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
icaltimetype *date;
|
||||||
|
gint pos_x;
|
||||||
|
gint pos_y;
|
||||||
|
gint min_height;
|
||||||
|
gint natural_height;
|
||||||
|
GtkAllocation child_allocation;
|
||||||
|
|
||||||
|
date = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (l->data));
|
||||||
|
pos_x = ( (date->day + priv->days_delay + 1) % 7 ) * priv->horizontal_step;
|
||||||
|
pos_y = ( (date->day + priv->days_delay + 1) / 7 ) * priv->vertical_step;
|
||||||
|
|
||||||
|
gtk_widget_get_preferred_height (GTK_WIDGET (l->data),
|
||||||
|
&min_height,
|
||||||
|
&natural_height);
|
||||||
|
child_allocation.x = pos_x + allocation->x + padding.left;
|
||||||
|
child_allocation.y = pos_y + allocation->y + padding.top + priv->header_font_size;
|
||||||
|
child_allocation.width = priv->horizontal_step;
|
||||||
|
child_allocation.height = MIN (natural_height, priv->vertical_step);
|
||||||
|
gtk_widget_set_allocation (GTK_WIDGET (l->data), &child_allocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -311,7 +383,6 @@ gcal_month_view_draw (GtkWidget *widget,
|
|||||||
state = gtk_widget_get_state_flags (widget);
|
state = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
gtk_style_context_get_padding (context, state, &padding);
|
gtk_style_context_get_padding (context, state, &padding);
|
||||||
|
|
||||||
gtk_style_context_get_color (context, state, &color);
|
gtk_style_context_get_color (context, state, &color);
|
||||||
|
|
||||||
/* header_font_size is found through pango_get_size_in_pixels */
|
/* header_font_size is found through pango_get_size_in_pixels */
|
||||||
@@ -324,32 +395,36 @@ gcal_month_view_draw (GtkWidget *widget,
|
|||||||
GCAL_MONTH_VIEW (widget),
|
GCAL_MONTH_VIEW (widget),
|
||||||
cr,
|
cr,
|
||||||
alloc.x + padding.left,
|
alloc.x + padding.left,
|
||||||
alloc.y + padding.top + priv->header_font_size,
|
alloc.y + padding.top + priv->header_font_size);
|
||||||
alloc.width - (alloc.x + padding.left + padding.right),
|
|
||||||
alloc.height - (alloc.y + padding.top + padding.bottom + priv->header_font_size));
|
if (GTK_WIDGET_CLASS (gcal_month_view_parent_class)->draw != NULL)
|
||||||
|
GTK_WIDGET_CLASS (gcal_month_view_parent_class)->draw (widget, cr);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_month_view_finalize (GObject *object)
|
gcal_month_view_forall (GtkContainer *container,
|
||||||
|
gboolean include_internals,
|
||||||
|
GtkCallback callback,
|
||||||
|
gpointer callback_data)
|
||||||
{
|
{
|
||||||
GcalMonthViewPrivate *priv = GCAL_MONTH_VIEW (object)->priv;
|
GcalMonthViewPrivate *priv;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
if (priv->date != NULL)
|
priv = GCAL_MONTH_VIEW (container)->priv;
|
||||||
g_free (priv->date);
|
|
||||||
|
|
||||||
/* Chain up to parent's finalize() method. */
|
for (l = priv->events; l != NULL; l = l->next)
|
||||||
G_OBJECT_CLASS (gcal_month_view_parent_class)->finalize (object);
|
{
|
||||||
|
(* callback) (l->data, callback_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gcal_month_view_draw_month_grid (GcalMonthView *month_view,
|
_gcal_month_view_draw_month_grid (GcalMonthView *month_view,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y)
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
{
|
||||||
GcalMonthViewPrivate *priv;
|
GcalMonthViewPrivate *priv;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
@@ -363,8 +438,6 @@ _gcal_month_view_draw_month_grid (GcalMonthView *month_view,
|
|||||||
gint font_height;
|
gint font_height;
|
||||||
|
|
||||||
guint8 n_days_in_month;
|
guint8 n_days_in_month;
|
||||||
icaltimetype *first_of_month;
|
|
||||||
gint space;
|
|
||||||
|
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
gchar *day;
|
gchar *day;
|
||||||
@@ -382,18 +455,9 @@ _gcal_month_view_draw_month_grid (GcalMonthView *month_view,
|
|||||||
gtk_style_context_get_font (context,
|
gtk_style_context_get_font (context,
|
||||||
state));
|
state));
|
||||||
|
|
||||||
priv->vertical_step = (gdouble) height / 5;
|
|
||||||
priv->horizontal_step= (gdouble) width / 7;
|
|
||||||
|
|
||||||
n_days_in_month = icaltime_days_in_month (priv->date->month,
|
n_days_in_month = icaltime_days_in_month (priv->date->month,
|
||||||
priv->date->year);
|
priv->date->year);
|
||||||
|
|
||||||
first_of_month = gcal_dup_icaltime (priv->date);
|
|
||||||
first_of_month->day = 1;
|
|
||||||
|
|
||||||
space = - icaltime_day_of_week (*first_of_month) + 2;
|
|
||||||
g_free (first_of_month);
|
|
||||||
|
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
pango_layout_set_text (layout, weekdays[i], -1);
|
pango_layout_set_text (layout, weekdays[i], -1);
|
||||||
@@ -406,7 +470,7 @@ _gcal_month_view_draw_month_grid (GcalMonthView *month_view,
|
|||||||
|
|
||||||
for (j = 0; j < 5; j++)
|
for (j = 0; j < 5; j++)
|
||||||
{
|
{
|
||||||
gint n_day = j * 7 + i + space;
|
gint n_day = j * 7 + i + priv->days_delay;
|
||||||
if (n_day <= 0 ||
|
if (n_day <= 0 ||
|
||||||
n_day > n_days_in_month)
|
n_day > n_days_in_month)
|
||||||
continue;
|
continue;
|
||||||
@@ -428,19 +492,44 @@ _gcal_month_view_draw_month_grid (GcalMonthView *month_view,
|
|||||||
{
|
{
|
||||||
cairo_move_to (cr, x, y + priv->vertical_step * i);
|
cairo_move_to (cr, x, y + priv->vertical_step * i);
|
||||||
cairo_line_to (cr,
|
cairo_line_to (cr,
|
||||||
x + priv->horizontal_step * 7,
|
x + priv->horizontal_step * 7,
|
||||||
y + priv->vertical_step * i);
|
y + priv->vertical_step * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
cairo_move_to (cr, x + priv->horizontal_step * i, y);
|
cairo_move_to (cr, x + priv->horizontal_step * i, y);
|
||||||
cairo_line_to (cr, x + priv->horizontal_step * i, y + height);
|
cairo_line_to (cr,
|
||||||
|
x + priv->horizontal_step * i,
|
||||||
|
y + priv->vertical_step * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_gcal_month_view_is_in_range (GcalView *view,
|
||||||
|
icaltimetype *date)
|
||||||
|
{
|
||||||
|
g_debug ("Implementation of is_in_range called");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gcal_month_view_add_event (GcalView *view,
|
||||||
|
GtkWidget *event)
|
||||||
|
{
|
||||||
|
GcalMonthViewPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (GCAL_IS_MONTH_VIEW (view));
|
||||||
|
g_return_if_fail (GCAL_IS_EVENT_WIDGET (event));
|
||||||
|
g_return_if_fail (gtk_widget_get_parent (event) == NULL);
|
||||||
|
priv = GCAL_MONTH_VIEW (view)->priv;
|
||||||
|
|
||||||
|
priv->events = g_list_append (priv->events, event);
|
||||||
|
gtk_widget_set_parent (event, GTK_WIDGET (view));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gcal_month_view_new:
|
* gcal_month_view_new:
|
||||||
* @date:
|
* @date:
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ typedef struct _GcalMonthViewPrivate GcalMonthViewPrivate;
|
|||||||
|
|
||||||
struct _GcalMonthView
|
struct _GcalMonthView
|
||||||
{
|
{
|
||||||
GtkWidget parent;
|
GtkContainer parent;
|
||||||
|
|
||||||
/* add your public declarations here */
|
/* add your public declarations here */
|
||||||
GcalMonthViewPrivate *priv;
|
GcalMonthViewPrivate *priv;
|
||||||
@@ -47,7 +47,7 @@ struct _GcalMonthView
|
|||||||
|
|
||||||
struct _GcalMonthViewClass
|
struct _GcalMonthViewClass
|
||||||
{
|
{
|
||||||
GtkWidgetClass parent_class;
|
GtkContainerClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gcal_month_view_get_type (void);
|
GType gcal_month_view_get_type (void);
|
||||||
|
|||||||
@@ -70,3 +70,12 @@ gcal_view_is_in_range (GcalView *view,
|
|||||||
|
|
||||||
return GCAL_VIEW_GET_INTERFACE (view)->is_in_range (view, date);
|
return GCAL_VIEW_GET_INTERFACE (view)->is_in_range (view, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gcal_view_add_event (GcalView *view,
|
||||||
|
GtkWidget *event)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GCAL_IS_VIEW (view));
|
||||||
|
|
||||||
|
GCAL_VIEW_GET_INTERFACE (view)->add_event (view, event);
|
||||||
|
}
|
||||||
|
|||||||
+8
-2
@@ -21,6 +21,7 @@
|
|||||||
#define __GCAL_VIEW_H__
|
#define __GCAL_VIEW_H__
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <libical/icaltime.h>
|
#include <libical/icaltime.h>
|
||||||
|
|
||||||
@@ -39,12 +40,17 @@ struct _GcalViewIface
|
|||||||
{
|
{
|
||||||
GTypeInterface parent_iface;
|
GTypeInterface parent_iface;
|
||||||
|
|
||||||
gboolean (*is_in_range) (GcalView *view, icaltimetype* date);
|
gboolean (*is_in_range) (GcalView *view, icaltimetype *date);
|
||||||
|
void (*add_event) (GcalView *view, GtkWidget *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gcal_view_get_type (void);
|
GType gcal_view_get_type (void);
|
||||||
|
|
||||||
gboolean gcal_view_is_in_range (GcalView *view, icaltimetype* date);
|
gboolean gcal_view_is_in_range (GcalView *view,
|
||||||
|
icaltimetype *date);
|
||||||
|
|
||||||
|
void gcal_view_add_event (GcalView *view,
|
||||||
|
GtkWidget *event);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
+28
-7
@@ -23,6 +23,7 @@
|
|||||||
#include "gcal-main-toolbar.h"
|
#include "gcal-main-toolbar.h"
|
||||||
#include "gcal-month-view.h"
|
#include "gcal-month-view.h"
|
||||||
#include "gcal-view.h"
|
#include "gcal-view.h"
|
||||||
|
#include "gcal-event-widget.h"
|
||||||
#include "gcal-utils.h"
|
#include "gcal-utils.h"
|
||||||
|
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
@@ -397,24 +398,26 @@ _gcal_window_events_added (GcalManager *manager,
|
|||||||
{
|
{
|
||||||
GcalWindowPrivate *priv;
|
GcalWindowPrivate *priv;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
icaltimetype *starting_date;
|
|
||||||
gchar **tokens;
|
gchar **tokens;
|
||||||
gchar *source_uid;
|
gchar *source_uid;
|
||||||
gchar *event_uid;
|
gchar *event_uid;
|
||||||
|
|
||||||
|
GtkWidget *event;
|
||||||
|
icaltimetype *starting_date;
|
||||||
|
gchar *summary;
|
||||||
|
GdkRGBA *color;
|
||||||
|
|
||||||
priv = GCAL_WINDOW (user_data)->priv;
|
priv = GCAL_WINDOW (user_data)->priv;
|
||||||
|
|
||||||
g_debug ("[IWEA]: obtained %d events", g_slist_length (events_list));
|
|
||||||
for (l = events_list; l != NULL; l = l->next)
|
for (l = events_list; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
g_debug ("event %s", (gchar*) l->data);
|
|
||||||
tokens = g_strsplit ((gchar*) l->data, ":", -1);
|
tokens = g_strsplit ((gchar*) l->data, ":", -1);
|
||||||
source_uid = tokens[0];
|
source_uid = tokens[0];
|
||||||
event_uid = tokens[1];
|
event_uid = tokens[1];
|
||||||
starting_date = gcal_manager_get_start_date (manager,
|
starting_date = gcal_manager_get_event_start_date (manager,
|
||||||
source_uid,
|
source_uid,
|
||||||
event_uid);
|
event_uid);
|
||||||
g_debug ("starts on %s", icaltime_as_ical_string (*starting_date));
|
|
||||||
g_debug ("GcalViewTypeEnum in GcalWindow %d", priv->active_view);
|
g_debug ("GcalViewTypeEnum in GcalWindow %d", priv->active_view);
|
||||||
/* FIXME: here priv->views[priv->active_view] instead of hardcoding
|
/* FIXME: here priv->views[priv->active_view] instead of hardcoding
|
||||||
* GCAL_VIEW_TYPE_MONTHLY */
|
* GCAL_VIEW_TYPE_MONTHLY */
|
||||||
@@ -422,7 +425,25 @@ _gcal_window_events_added (GcalManager *manager,
|
|||||||
GCAL_VIEW (priv->views[GCAL_VIEW_TYPE_MONTHLY]),
|
GCAL_VIEW (priv->views[GCAL_VIEW_TYPE_MONTHLY]),
|
||||||
starting_date))
|
starting_date))
|
||||||
{
|
{
|
||||||
|
summary = gcal_manager_get_event_summary (manager,
|
||||||
|
source_uid,
|
||||||
|
event_uid);
|
||||||
|
color = gcal_manager_get_event_color (manager,
|
||||||
|
source_uid,
|
||||||
|
event_uid);
|
||||||
|
event =
|
||||||
|
gcal_event_widget_new_with_summary_and_color (summary, color);
|
||||||
|
gcal_event_widget_set_date (GCAL_EVENT_WIDGET (event),
|
||||||
|
starting_date);
|
||||||
|
gcal_view_add_event (
|
||||||
|
GCAL_VIEW (priv->views[GCAL_VIEW_TYPE_MONTHLY]),
|
||||||
|
event);
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (event),
|
||||||
|
"event");
|
||||||
|
gtk_widget_show (event);
|
||||||
g_debug ("Returned true call on interface function");
|
g_debug ("Returned true call on interface function");
|
||||||
|
g_free (summary);
|
||||||
|
gdk_rgba_free (color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user