week-view: add subscriber range update
Remove unneeded GcalView deprecated method. Hook event widget activation
This commit is contained in:
+95
-87
@@ -77,6 +77,9 @@ typedef struct
|
|||||||
gint clicked_cell;
|
gint clicked_cell;
|
||||||
} GcalWeekViewPrivate;
|
} GcalWeekViewPrivate;
|
||||||
|
|
||||||
|
static void event_opened (GcalEventWidget *event_widget,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
static void gcal_view_interface_init (GcalViewIface *iface);
|
static void gcal_view_interface_init (GcalViewIface *iface);
|
||||||
|
|
||||||
static void gcal_week_view_constructed (GObject *object);
|
static void gcal_week_view_constructed (GObject *object);
|
||||||
@@ -123,9 +126,6 @@ static void gcal_week_view_forall (GtkContainer *cont
|
|||||||
GtkCallback callback,
|
GtkCallback callback,
|
||||||
gpointer callback_data);
|
gpointer callback_data);
|
||||||
|
|
||||||
static void gcal_week_view_set_date (GcalWeekView *view,
|
|
||||||
icaltimetype *date);
|
|
||||||
|
|
||||||
static void gcal_week_view_draw_header (GcalWeekView *view,
|
static void gcal_week_view_draw_header (GcalWeekView *view,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
GtkAllocation *alloc,
|
GtkAllocation *alloc,
|
||||||
@@ -136,8 +136,6 @@ static void gcal_week_view_draw_grid_window (GcalWeekView *view
|
|||||||
|
|
||||||
static gint gcal_week_view_get_sidebar_width (GtkWidget *widget);
|
static gint gcal_week_view_get_sidebar_width (GtkWidget *widget);
|
||||||
|
|
||||||
static gint gcal_week_view_get_start_grid_y (GtkWidget *widget);
|
|
||||||
|
|
||||||
static void gcal_week_view_scroll_value_changed (GtkAdjustment *adjusment,
|
static void gcal_week_view_scroll_value_changed (GtkAdjustment *adjusment,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
@@ -149,20 +147,73 @@ static gchar* gcal_week_view_get_left_header (GcalView *view
|
|||||||
|
|
||||||
static gchar* gcal_week_view_get_right_header (GcalView *view);
|
static gchar* gcal_week_view_get_right_header (GcalView *view);
|
||||||
|
|
||||||
static gboolean gcal_week_view_draw_event (GcalView *view,
|
|
||||||
icaltimetype *start_date,
|
|
||||||
icaltimetype *end_date);
|
|
||||||
|
|
||||||
static GtkWidget* gcal_week_view_get_by_uuid (GcalView *view,
|
static GtkWidget* gcal_week_view_get_by_uuid (GcalView *view,
|
||||||
const gchar *uuid);
|
const gchar *uuid);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GcalWeekView,
|
G_DEFINE_TYPE_WITH_CODE (GcalWeekView,
|
||||||
gcal_week_view,
|
gcal_week_view,
|
||||||
GTK_TYPE_CONTAINER,
|
GCAL_TYPE_SUBSCRIBER,
|
||||||
G_ADD_PRIVATE (GcalWeekView)
|
G_ADD_PRIVATE (GcalWeekView)
|
||||||
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
|
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
|
||||||
gcal_view_interface_init));
|
gcal_view_interface_init));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_start_grid_y:
|
||||||
|
*
|
||||||
|
* In GcalMonthView this method returns the height of the headers of the view
|
||||||
|
* and the grid. Here this points just the place where the grid_window hides
|
||||||
|
* behind the header
|
||||||
|
* Here this height includes:
|
||||||
|
* - The big header of the view
|
||||||
|
* - The grid header dislaying weekdays
|
||||||
|
* - The cell containing all-day events.
|
||||||
|
*/
|
||||||
|
static gint
|
||||||
|
get_start_grid_y (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkStateFlags flags;
|
||||||
|
GtkBorder padding;
|
||||||
|
|
||||||
|
PangoLayout *layout;
|
||||||
|
PangoFontDescription *font_desc;
|
||||||
|
gint font_height;
|
||||||
|
gdouble start_grid_y;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
flags = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
|
layout = gtk_widget_create_pango_layout (widget, NULL);
|
||||||
|
|
||||||
|
/* init header values */
|
||||||
|
gtk_style_context_get_padding (context, flags, &padding);
|
||||||
|
|
||||||
|
gtk_style_context_get (context, flags, "font", &font_desc, NULL);
|
||||||
|
|
||||||
|
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_SEMIBOLD);
|
||||||
|
pango_layout_set_font_description (layout, font_desc);
|
||||||
|
pango_layout_get_pixel_size (layout, NULL, &font_height);
|
||||||
|
pango_font_description_free (font_desc);
|
||||||
|
|
||||||
|
/* 6: is padding around the header */
|
||||||
|
start_grid_y = font_height + padding.bottom;
|
||||||
|
|
||||||
|
/* for including the all-day cells */
|
||||||
|
start_grid_y += ALL_DAY_CELLS_HEIGHT;
|
||||||
|
|
||||||
|
g_object_unref (layout);
|
||||||
|
return start_grid_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
event_opened (GcalEventWidget *event_widget,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_signal_emit_by_name (GCAL_VIEW (user_data),
|
||||||
|
"event-activated",
|
||||||
|
event_widget);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_week_view_class_init (GcalWeekViewClass *klass)
|
gcal_week_view_class_init (GcalWeekViewClass *klass)
|
||||||
{
|
{
|
||||||
@@ -292,13 +343,37 @@ gcal_week_view_set_property (GObject *object,
|
|||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
case PROP_DATE:
|
case PROP_DATE:
|
||||||
gcal_week_view_set_date (
|
{
|
||||||
GCAL_WEEK_VIEW (object),
|
time_t range_start, range_end;
|
||||||
g_value_dup_boxed (value));
|
icaltimetype *date;
|
||||||
break;
|
icaltimezone* default_zone;
|
||||||
|
|
||||||
|
if (priv->date != NULL)
|
||||||
|
g_free (priv->date);
|
||||||
|
|
||||||
|
priv->date = g_value_dup_boxed (value);
|
||||||
|
|
||||||
|
default_zone =
|
||||||
|
gcal_manager_get_system_timezone (priv->manager);
|
||||||
|
date = gcal_view_get_initial_date (GCAL_VIEW (object));
|
||||||
|
range_start = icaltime_as_timet_with_zone (*date,
|
||||||
|
default_zone);
|
||||||
|
g_free (date);
|
||||||
|
date = gcal_view_get_final_date (GCAL_VIEW (object));
|
||||||
|
range_end = icaltime_as_timet_with_zone (*date,
|
||||||
|
default_zone);
|
||||||
|
g_free (date);
|
||||||
|
gcal_manager_set_subscriber (priv->manager,
|
||||||
|
E_CAL_DATA_MODEL_SUBSCRIBER (object),
|
||||||
|
range_start,
|
||||||
|
range_end);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case PROP_MANAGER:
|
case PROP_MANAGER:
|
||||||
priv->manager = g_value_get_pointer (value);
|
{
|
||||||
break;
|
priv->manager = g_value_get_pointer (value);
|
||||||
|
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;
|
||||||
@@ -837,6 +912,10 @@ gcal_week_view_add (GtkContainer *container,
|
|||||||
priv->days[day - 1] = g_list_append (priv->days[day - 1], new_child);
|
priv->days[day - 1] = g_list_append (priv->days[day - 1], new_child);
|
||||||
gtk_widget_set_parent (widget, GTK_WIDGET (container));
|
gtk_widget_set_parent (widget, GTK_WIDGET (container));
|
||||||
|
|
||||||
|
g_signal_connect (widget,
|
||||||
|
"activate",
|
||||||
|
G_CALLBACK (event_opened),
|
||||||
|
container);
|
||||||
g_free (date);
|
g_free (date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,52 +990,6 @@ gcal_week_view_forall (GtkContainer *container,
|
|||||||
(* callback) (priv->vscrollbar, callback_data);
|
(* callback) (priv->vscrollbar, callback_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gcal_week_view_set_date (GcalWeekView *view,
|
|
||||||
icaltimetype *date)
|
|
||||||
{
|
|
||||||
GcalWeekViewPrivate *priv;
|
|
||||||
gboolean will_resize;
|
|
||||||
|
|
||||||
gint i;
|
|
||||||
GList *l;
|
|
||||||
GList *to_remove;
|
|
||||||
|
|
||||||
priv = gcal_week_view_get_instance_private (view);
|
|
||||||
will_resize = FALSE;
|
|
||||||
|
|
||||||
/* FIXME: draw_event don't exist anymore */
|
|
||||||
/* if span_updated: queue_resize */
|
|
||||||
will_resize = ! gcal_week_view_draw_event (GCAL_VIEW (view), date, NULL);
|
|
||||||
|
|
||||||
if (priv->date != NULL)
|
|
||||||
g_free (priv->date);
|
|
||||||
|
|
||||||
priv->date = date;
|
|
||||||
|
|
||||||
if (will_resize)
|
|
||||||
{
|
|
||||||
to_remove = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < 7; i++)
|
|
||||||
{
|
|
||||||
for (l = priv->days[i]; l != NULL; l = l->next)
|
|
||||||
{
|
|
||||||
GcalWeekViewChild *child;
|
|
||||||
icaltimetype *child_date;
|
|
||||||
|
|
||||||
child = (GcalWeekViewChild*) l->data;
|
|
||||||
child_date = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
|
|
||||||
if (! gcal_week_view_draw_event (GCAL_VIEW (view), child_date, NULL))
|
|
||||||
to_remove = g_list_append (to_remove, child->widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_list_foreach (to_remove, (GFunc) gtk_widget_destroy, NULL);
|
|
||||||
|
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (view));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_week_view_draw_header (GcalWeekView *view,
|
gcal_week_view_draw_header (GcalWeekView *view,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
@@ -1378,31 +1411,6 @@ gcal_week_view_get_right_header (GcalView *view)
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: replace cause it doesn't exist anymore */
|
|
||||||
static gboolean
|
|
||||||
gcal_week_view_draw_event (GcalView *view,
|
|
||||||
icaltimetype *start_date,
|
|
||||||
icaltimetype *end_date)
|
|
||||||
{
|
|
||||||
GcalWeekViewPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GCAL_IS_WEEK_VIEW (view), FALSE);
|
|
||||||
priv = gcal_week_view_get_instance_private (GCAL_WEEK_VIEW(view));
|
|
||||||
|
|
||||||
if (priv->date == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (icaltime_week_number (*(priv->date)) == icaltime_week_number (*start_date)
|
|
||||||
&& priv->date->year == start_date->year)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
gcal_week_view_get_by_uuid (GcalView *view,
|
gcal_week_view_get_by_uuid (GcalView *view,
|
||||||
const gchar *uuid)
|
const gchar *uuid)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "gcal-manager.h"
|
#include "gcal-manager.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include "gcal-subscriber.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@@ -38,12 +38,12 @@ typedef struct _GcalWeekViewClass GcalWeekViewClass;
|
|||||||
|
|
||||||
struct _GcalWeekView
|
struct _GcalWeekView
|
||||||
{
|
{
|
||||||
GtkContainer parent;
|
GcalSubscriber parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GcalWeekViewClass
|
struct _GcalWeekViewClass
|
||||||
{
|
{
|
||||||
GtkContainerClass parent_class;
|
GcalSubscriberClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gcal_week_view_get_type (void);
|
GType gcal_week_view_get_type (void);
|
||||||
|
|||||||
Reference in New Issue
Block a user