g_object_unref (priv->view);
priv->view = NULL;
}
- GtkCalExViewDay *vd = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, FALSE);
+ GtkCalExViewDay *vd = gtk_calex_view_day_new (priv->goo_canvas, priv->date, FALSE);
priv->view = G_OBJECT (vd);
break;
g_object_unref (priv->view);
priv->view = NULL;
}
- GtkCalExViewDay *vww = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, TRUE);
+ GtkCalExViewDay *vww = gtk_calex_view_day_new (priv->goo_canvas, priv->date, TRUE);
priv->view = G_OBJECT (vww);
break;
g_object_unref (priv->view);
priv->view = NULL;
}
- GtkCalExViewWeek *vw = gtk_calex_view_week_new (priv->goo_canvas_root, priv->date);
+ GtkCalExViewWeek *vw = gtk_calex_view_week_new (priv->goo_canvas, priv->date);
priv->view = G_OBJECT (vw);
break;
g_object_unref (priv->view);
priv->view = NULL;
}
- GtkCalExViewDay *vm = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, FALSE);
+ GtkCalExViewDay *vm = gtk_calex_view_day_new (priv->goo_canvas, priv->date, FALSE);
priv->view = G_OBJECT (vm);
break;
g_object_unref (priv->view);
priv->view = NULL;
}
- GtkCalExViewDay *vl = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, FALSE);
+ GtkCalExViewDay *vl = gtk_calex_view_day_new (priv->goo_canvas, priv->date, FALSE);
priv->view = G_OBJECT (vl);
break;
typedef struct _GtkCalExViewDayPrivate GtkCalExViewDayPrivate;
struct _GtkCalExViewDayPrivate
{
- GooCanvasItem *goo_canvas_root;
+ GtkWidget *canvas;
+ GooCanvasItem *canvas_root;
GDate *date;
gboolean working_week;
/**
* gtk_calex_view_day_new:
- * @root:
+ * @canvas:
* @date:
* @working_week:
*
* Returns: the newly created #GtkCalExViewDay object.
*/
GtkCalExViewDay
-*gtk_calex_view_day_new (GooCanvasItem *root, GDate *date, gboolean working_week)
+*gtk_calex_view_day_new (GtkWidget *canvas, GDate *date, gboolean working_week)
{
GtkCalExViewDay *gtk_calex_view_day = GTK_CALEX_VIEW_DAY (g_object_new (gtk_calex_view_day_get_type (), NULL));
GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtk_calex_view_day);
- priv->goo_canvas_root = root;
+ priv->canvas = canvas;
+ priv->canvas_root = goo_canvas_get_root_item (GOO_CANVAS (priv->canvas));
priv->date = date;
priv->working_week = working_week;
static void
gtk_calex_view_day_draw (GtkCalExViewDay *gtk_calex_view_day)
{
+ GtkAllocation allocation;
+
+ gchar *str_day;
+
guint hour;
guint division;
GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtk_calex_view_day);
+ gtk_widget_get_allocation (priv->canvas, &allocation);
+
+ str_day = g_malloc0 (100);
+ g_date_strftime (str_day, 100, "%A %d %B", priv->date);
+
+ goo_canvas_text_new (priv->canvas_root, str_day,
+ 0, 0, allocation.width,
+ GTK_ANCHOR_NORTH_WEST,
+ "font", "Sans 10",
+ NULL);
+
divisions = 60 / priv->division;
- y = -20;
+ y = 0;
for (hour = 0; hour < 24; hour++)
{
y += 20;
- goo_canvas_polyline_new_line (priv->goo_canvas_root,
+ goo_canvas_polyline_new_line (priv->canvas_root,
0, y, 50, y,
"stroke-color", "black",
NULL);
- goo_canvas_rect_new (priv->goo_canvas_root,
- 55, y, 400, 20,
+ goo_canvas_rect_new (priv->canvas_root,
+ 55, y, allocation.width - 55, 20,
"line-width", 1.0,
"stroke-color", "black",
"fill-color", "yellow",
NULL);
- goo_canvas_text_new (priv->goo_canvas_root, g_strdup_printf ("%d", hour),
+ goo_canvas_text_new (priv->canvas_root, g_strdup_printf ("%d", hour),
0, y, 50,
GTK_ANCHOR_NORTH_WEST,
"font", "Sans 24",
NULL);
- goo_canvas_text_new (priv->goo_canvas_root, "00",
+ goo_canvas_text_new (priv->canvas_root, "00",
25, y, 25,
GTK_ANCHOR_NORTH_WEST,
"font", "Sans 12",
for (division = 1; division < divisions; division++)
{
y += 20;
- goo_canvas_polyline_new_line (priv->goo_canvas_root,
+ goo_canvas_polyline_new_line (priv->canvas_root,
25, y, 50, y,
"stroke-color", "black",
NULL);
- goo_canvas_text_new (priv->goo_canvas_root, g_strdup_printf ("%02d", 60 / divisions * division),
+ goo_canvas_text_new (priv->canvas_root, g_strdup_printf ("%02d", 60 / divisions * division),
25, y, 25,
GTK_ANCHOR_NORTH_WEST,
"font", "Sans 12",
NULL);
- goo_canvas_rect_new (priv->goo_canvas_root,
- 55, y, 400, 20,
+ goo_canvas_rect_new (priv->canvas_root,
+ 55, y, allocation.width - 55, 20,
"line-width", 1.0,
"stroke-color", "black",
"fill-color", "yellow",
typedef struct _GtkCalExViewWeekPrivate GtkCalExViewWeekPrivate;
struct _GtkCalExViewWeekPrivate
{
- GooCanvasItem *goo_canvas_root;
+ GtkWidget *canvas;
+ GooCanvasItem *canvas_root;
GDate *date;
};
/**
* gtk_calex_view_week_new:
- * @root:
+ * @canvas:
* @date:
*
* Returns: the newly created #GtkCalExViewWeek object.
*/
GtkCalExViewWeek
-*gtk_calex_view_week_new (GooCanvasItem *root, GDate *date)
+*gtk_calex_view_week_new (GtkWidget *canvas, GDate *date)
{
GtkCalExViewWeek *gtk_calex_view_week = GTK_CALEX_VIEW_WEEK (g_object_new (gtk_calex_view_week_get_type (), NULL));
GtkCalExViewWeekPrivate *priv = GTK_CALEX_VIEW_WEEK_GET_PRIVATE (gtk_calex_view_week);
- priv->goo_canvas_root = root;
+ priv->canvas = canvas;
+ priv->canvas_root = goo_canvas_get_root_item (GOO_CANVAS (priv->canvas));
priv->date = date;
gtk_calex_view_week_draw (gtk_calex_view_week);