]> saetta.ns0.it Git - libgtkcalendarex/commitdiff
Added divisions on GtkCalExViewDay.
authorAndrea Zagli <azagli@libero.it>
Sun, 7 Nov 2010 08:44:57 +0000 (09:44 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 7 Nov 2010 08:44:57 +0000 (09:44 +0100)
src/gtkcalex.c
src/gtkcalex.h
src/gtkcalexviewday.c
src/gtkcalexviewday.h

index cd7d95c3ba74a29aef00017c3566a73722bc2a43..1bfec6957ffea60f7c97db7b4728d826280f28c0 100644 (file)
@@ -80,6 +80,10 @@ struct _GtkCalExPrivate
                GDate *date;
 
                GObject *view;
+
+               GList *calendars;
+               GList *categories;
+               GList *events;
        };
 
 G_DEFINE_TYPE (GtkCalEx, gtk_calex, GTK_TYPE_BIN)
index 8f4acaf5fa1aa4b543e9f882bffd01b47481878f..ba6e3f70b908fbae1f2b514fda70bb34f77ac138 100644 (file)
@@ -73,9 +73,13 @@ void gtk_calex_set_date (GtkCalEx *calex, GDate *date);
 void gtk_calex_add_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar);
 void gtk_calex_remove_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar);
 
+GList *gtk_calex_get_calendars (GtkCalEx *calex);
+
 void gtk_calex_add_category (GtkCalEx *calex, GtkCalExCategory *category);
 void gtk_calex_remove_category (GtkCalEx *calex, GtkCalExCategory *category);
 
+GList *gtk_calex_get_categories (GtkCalEx *calex);
+
 void gtk_calex_add_event (GtkCalEx *calex, GtkCalExEvent *event);
 void gtk_calex_remove_event (GtkCalEx *calex, GtkCalExEvent *event);
 
index dc97185a462d37853195507a9de83141cf39e66f..f96f3f6c067570da0a4aa32a86b866e474fd5cc9 100644 (file)
@@ -50,6 +50,8 @@ struct _GtkCalExViewDayPrivate
                GooCanvasItem *goo_canvas_root;
                GDate *date;
                gboolean working_week;
+
+               guint division;
        };
 
 G_DEFINE_TYPE (GtkCalExViewDay, gtk_calex_view_day, G_TYPE_OBJECT)
@@ -69,6 +71,8 @@ static void
 gtk_calex_view_day_init (GtkCalExViewDay *gtk_calex_view_day)
 {
        GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtk_calex_view_day);
+
+       priv->division = 30;
 }
 
 static void
@@ -125,42 +129,86 @@ GtkCalExViewDay
        return gtk_calex_view_day;
 }
 
+void
+gtk_calex_view_day_set_division (GtkCalExViewDay *view_day, guint division)
+{
+       g_return_if_fail (IS_GTK_CALEX_VIEW_DAY (view_day));
+
+       GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (view_day);
+
+       priv->division = division;
+
+       gtk_calex_view_day_draw (view_day);
+}
+
+guint
+gtk_calex_view_day_get_division (GtkCalExViewDay *view_day)
+{
+       g_return_if_fail (IS_GTK_CALEX_VIEW_DAY (view_day));
+
+       GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (view_day);
+
+       return priv->division;
+}
+
 static void
 gtk_calex_view_day_draw (GtkCalExViewDay *gtk_calex_view_day)
 {
        guint hour;
 
+       guint division;
+       guint divisions;
+
+       gdouble y;
+
        g_return_if_fail (IS_GTK_CALEX_VIEW_DAY (gtk_calex_view_day));
 
        GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtk_calex_view_day);
 
+       divisions = 60 / priv->division;
+       y = -20;
        for (hour = 0; hour < 24; hour++)
                {
-                       goo_canvas_text_new (priv->goo_canvas_root, g_strdup_printf ("%d", hour),
-                                            0, hour * 40, 50,
-                                            GTK_ANCHOR_NORTH_WEST,
-                                            "font", "Sans 24",
-                                            NULL);
-                       goo_canvas_text_new (priv->goo_canvas_root, "00",
-                                            25, hour * 40, 25,
-                                            GTK_ANCHOR_NORTH_WEST,
-                                            "font", "Sans 12",
-                                            NULL);
-                       goo_canvas_polyline_new_line (priv->goo_canvas_root, 0, hour * 40, 50, hour * 40,
+                       y += 20;
+                       goo_canvas_polyline_new_line (priv->goo_canvas_root,
+                                            0, y, 50, y,
                                             "stroke-color", "black",
                                             NULL);
-                       goo_canvas_rect_new (priv->goo_canvas_root, 55, hour * 40, 400, 20,
+                       goo_canvas_rect_new (priv->goo_canvas_root,
+                                            55, y, 400, 20,
                                             "line-width", 1.0,
                                             "stroke-color", "black",
                                             "fill-color", "yellow",
                                             NULL);
-                       goo_canvas_polyline_new_line (priv->goo_canvas_root, 25, hour * 40 + 20, 50, hour * 40 + 20,
-                                            "stroke-color", "black",
+                       goo_canvas_text_new (priv->goo_canvas_root, g_strdup_printf ("%d", hour),
+                                            0, y, 50,
+                                            GTK_ANCHOR_NORTH_WEST,
+                                            "font", "Sans 24",
                                             NULL);
-                       goo_canvas_rect_new (priv->goo_canvas_root, 55, hour * 40 + 20, 400, 20,
-                                            "line-width", 1.0,
-                                            "stroke-color", "black",
-                                            "fill-color", "yellow",
+                       goo_canvas_text_new (priv->goo_canvas_root, "00",
+                                            25, y, 25,
+                                            GTK_ANCHOR_NORTH_WEST,
+                                            "font", "Sans 12",
                                             NULL);
+
+                       for (division = 1; division < divisions; division++)
+                               {
+                                       y += 20;
+                                       goo_canvas_polyline_new_line (priv->goo_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),
+                                                            25, y, 25,
+                                                            GTK_ANCHOR_NORTH_WEST,
+                                                            "font", "Sans 12",
+                                                            NULL);
+                                       goo_canvas_rect_new (priv->goo_canvas_root,
+                                                            55, y, 400, 20,
+                                                            "line-width", 1.0,
+                                                            "stroke-color", "black",
+                                                            "fill-color", "yellow",
+                                                            NULL);
+                               }
                }
 }
index b8d92f7831e30ac6a8ddfe2d95ab9eb30076005e..7ee2be3da27810f3edf88456a1ec9f0e36a44424 100644 (file)
@@ -54,6 +54,9 @@ GType gtk_calex_view_day_get_type (void) G_GNUC_CONST;
 
 GtkCalExViewDay *gtk_calex_view_day_new (GooCanvasItem *root, GDate *date, gboolean working_week);
 
+void gtk_calex_view_day_set_division (GtkCalExViewDay *view_day, guint division);
+guint gtk_calex_view_day_get_division (GtkCalExViewDay *view_day);
+
 
 G_END_DECLS