diff --git a/Makefile.am b/Makefile.am
index c984b1bf..b71d8b03 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-SUBDIRS = src po doc
+SUBDIRS = src data po doc
gnome_calendardocdir = ${prefix}/doc/gnome_calendar
gnome_calendardoc_DATA = \
diff --git a/configure.ac b/configure.ac
index a7a8a348..cf269833 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,8 @@ PKG_CHECK_MODULES(CALENDAR,
AC_CONFIG_FILES([
Makefile
src/Makefile
+ data/Makefile
+ data/gnome-calendar.desktop.in
po/Makefile.in
doc/Makefile
])
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 00000000..2b106e5e
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,26 @@
+desktopdir = $(datadir)/applications
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+ desktop_in_files = gnome-calendar.desktop.in
+
+@INTLTOOL_DESKTOP_RULE@
+
+gsettingsschema_in_files = org.gnome.calendar.gschema.xml.in
+gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
+.PRECIOUS: $(gsettings_SCHEMAS)
+
+@INTLTOOL_XML_NOMERGE_RULE@
+@GSETTINGS_RULES@
+
+styledir = $(pkgdatadir)/style
+
+dist_style_DATA = \
+ gtk-style.css
+
+EXTRA_DIST= \
+ gnome-calendar.desktop \
+ $(desktop_in_files) \
+ $(gsettingsschema_in_files)
+
+CLEANFILES = \
+ $(desktop_DATA) \
+ $(gsettings_SCHEMAS)
diff --git a/data/gnome-calendar.desktop.in.in b/data/gnome-calendar.desktop.in.in
new file mode 100644
index 00000000..57d6e7f7
--- /dev/null
+++ b/data/gnome-calendar.desktop.in.in
@@ -0,0 +1,10 @@
+[Desktop Entry]
+_Name=Calendar
+_Comment=Access, and manage calendar
+Exec=gnome-calendar
+Icon=calendr
+Terminal=false
+Type=Application
+StartupNotify=true
+OnlyShowIn=GNOME;
+Categories=GNOME;GTK;Utility;Core;
diff --git a/data/gtk-style.css b/data/gtk-style.css
new file mode 100644
index 00000000..14710824
--- /dev/null
+++ b/data/gtk-style.css
@@ -0,0 +1,3 @@
+.views {
+ padding: 10px;
+}
diff --git a/data/org.gnome.calendar.gschema.xml.in b/data/org.gnome.calendar.gschema.xml.in
new file mode 100644
index 00000000..65c363b9
--- /dev/null
+++ b/data/org.gnome.calendar.gschema.xml.in
@@ -0,0 +1,9 @@
+
+
+
+ true
+ <_summary>Window maximized
+ <_description>Window maximized state
+
+
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 07a66ca5..7f010899 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,3 +3,7 @@
src/main.c
src/gcal-application.c
src/gcal-main-toolbar.c
+src/gcal-month-view.c
+
+data/gnome-calendar.desktop.in.in
+data/org.gnome.calendar.gschema.xml.in
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
new file mode 100644
index 00000000..994497eb
--- /dev/null
+++ b/po/POTFILES.skip
@@ -0,0 +1,3 @@
+# List of skipped of translation files
+
+data/gnome-calendar.desktop.in
diff --git a/src/Makefile.am b/src/Makefile.am
index 795c9afa..6defa035 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,31 +1,35 @@
-AM_CPPFLAGS = \
- -DCLUTTER_VERSION_MIN_REQUIRED=CLUTTER_VERSION_1_10 \
- -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
- -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
- -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
- $(MAINTAINER_COMPILER_FLAGS) \
+AM_CPPFLAGS = \
+ -DCLUTTER_VERSION_MIN_REQUIRED=CLUTTER_VERSION_1_10 \
+ -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
+ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
+ -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
+ -DUI_DATA_DIR=\""$(pkgdatadir)/style"\" \
+ $(MAINTAINER_COMPILER_FLAGS) \
$(CALENDAR_CFLAGS)
-AM_CFLAGS = \
- -Wall -Wextra \
+AM_CFLAGS = \
+ -Wall \
-g -O0
bin_PROGRAMS = gnome-calendar
-gnome_calendar_SOURCES = \
- main.c \
- gcal-application.h \
- gcal-application.c \
- gcal-main-toolbar.h \
- gcal-main-toolbar.c \
- gcal-window.h \
- gcal-window.c
+gnome_calendar_SOURCES = \
+ main.c \
+ gcal-application.h \
+ gcal-application.c \
+ gcal-main-toolbar.h \
+ gcal-main-toolbar.c \
+ gcal-window.h \
+ gcal-window.c \
+ gcal-month-view.c \
+ gcal-month-view.h \
+ gcal-utils.h
-gnome_calendar_LDFLAGS = \
+gnome_calendar_LDFLAGS = \
-Wl,--export-dynamic
-gnome_calendar_LDADD = \
+gnome_calendar_LDADD = \
$(CALENDAR_LIBS)
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 41b198b9..9376ed1b 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -17,6 +17,7 @@
* with this program. If not, see .
*/
+#include "config.h"
#include "gcal-application.h"
#include "gcal-window.h"
@@ -24,9 +25,13 @@
#include
+#define CSS_FILE UI_DATA_DIR "/gtk-style.css"
+
struct _GcalApplicationPrivate
{
- GtkWidget *window;
+ GtkWidget *window;
+
+ GtkCssProvider *provider;
};
static void gcal_application_startup (GApplication *app);
@@ -91,9 +96,30 @@ gcal_application_class_init (GcalApplicationClass *klass)
static void
gcal_application_startup (GApplication *app)
{
+ GcalApplicationPrivate *priv;
+ GError *error;
+ priv = GCAL_APPLICATION (app)->priv;
+
G_APPLICATION_CLASS (gcal_application_parent_class)->startup (app);
- gtk_clutter_init (NULL, NULL);
+ if (gtk_clutter_init (NULL, NULL) < 0)
+ {
+ g_error (_("Unable to initialize GtkClutter\n"));
+ g_application_quit (app);
+ }
+
+ if (priv->provider == NULL)
+ {
+ priv->provider = gtk_css_provider_new ();
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (priv->provider),
+ G_MAXUINT);
+
+ error = NULL;
+ gtk_css_provider_load_from_path (priv->provider, CSS_FILE, &error);
+ if (error != NULL)
+ g_warning ("Not loading stylesheet from file %s\n", CSS_FILE);
+ }
_gcal_application_set_app_menu (app);
}
diff --git a/src/gcal-main-toolbar.c b/src/gcal-main-toolbar.c
index 67b09509..1d8124f7 100644
--- a/src/gcal-main-toolbar.c
+++ b/src/gcal-main-toolbar.c
@@ -18,6 +18,7 @@
*/
#include "gcal-main-toolbar.h"
+#include "gcal-utils.h"
#include
@@ -26,6 +27,20 @@ struct _GcalMainToolbarPrivate
GtkWidget *widget;
};
+enum
+{
+ VIEW_CHANGED = 1,
+ SOURCES_SHOWN,
+ NUM_SIGNALS
+};
+
+static guint signals[NUM_SIGNALS] = { 0, };
+
+static void _gcal_main_toolbar_view_changed (GtkWidget *button,
+ gpointer user_data);
+static void _gcal_main_toolbar_sources_shown (GtkWidget *button,
+ gpointer user_data);
+
G_DEFINE_TYPE (GcalMainToolbar, gcal_main_toolbar, GTK_CLUTTER_TYPE_ACTOR);
static void
@@ -70,6 +85,11 @@ gcal_main_toolbar_constructed (GObject *object)
context = gtk_widget_get_style_context (button);
gtk_style_context_add_class (context, "raised");
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (_gcal_main_toolbar_sources_shown),
+ GCAL_MAIN_TOOLBAR (object));
+
item = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (item), button);
gtk_toolbar_insert (GTK_TOOLBAR (priv->widget), item, 0);
@@ -99,6 +119,14 @@ gcal_main_toolbar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (views_box), button);
+ g_object_set_data (G_OBJECT (button),
+ "view-type",
+ GUINT_TO_POINTER (GCAL_VIEW_TYPE_DAILY));
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (_gcal_main_toolbar_view_changed),
+ GCAL_MAIN_TOOLBAR (object));
+
/* week */
button = gtk_button_new_with_label (_("Week"));
gtk_widget_set_size_request (button, 80, -1);
@@ -108,6 +136,14 @@ gcal_main_toolbar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (views_box), button);
+ g_object_set_data (G_OBJECT (button),
+ "view-type",
+ GUINT_TO_POINTER (GCAL_VIEW_TYPE_WEEKLY));
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (_gcal_main_toolbar_view_changed),
+ GCAL_MAIN_TOOLBAR (object));
+
/* month */
button = gtk_button_new_with_label (_("Month"));
gtk_widget_set_size_request (button, 80, -1);
@@ -117,6 +153,14 @@ gcal_main_toolbar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (views_box), button);
+ g_object_set_data (G_OBJECT (button),
+ "view-type",
+ GUINT_TO_POINTER (GCAL_VIEW_TYPE_MONTHLY));
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (_gcal_main_toolbar_view_changed),
+ GCAL_MAIN_TOOLBAR (object));
+
/* year */
button = gtk_button_new_with_label (_("Year"));
gtk_widget_set_size_request (button, 80, -1);
@@ -126,6 +170,14 @@ gcal_main_toolbar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (views_box), button);
+ g_object_set_data (G_OBJECT (button),
+ "view-type",
+ GUINT_TO_POINTER (GCAL_VIEW_TYPE_YEARLY));
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (_gcal_main_toolbar_view_changed),
+ GCAL_MAIN_TOOLBAR (object));
+
/* list */
button = gtk_button_new_with_label (_("List"));
gtk_widget_set_size_request (button, 80, -1);
@@ -135,6 +187,14 @@ gcal_main_toolbar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (views_box), button);
+ g_object_set_data (G_OBJECT (button),
+ "view-type",
+ GUINT_TO_POINTER (GCAL_VIEW_TYPE_LIST));
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (_gcal_main_toolbar_view_changed),
+ GCAL_MAIN_TOOLBAR (object));
+
/* spacer */
spacer = gtk_tool_item_new ();
gtk_tool_item_set_expand (spacer, TRUE);
@@ -173,9 +233,58 @@ gcal_main_toolbar_class_init (GcalMainToolbarClass *klass)
G_OBJECT_CLASS (klass)->constructed = gcal_main_toolbar_constructed;
G_OBJECT_CLASS (klass)->finalize = gcal_main_toolbar_finalize;
+ signals[VIEW_CHANGED] = g_signal_new ("view-changed",
+ GCAL_TYPE_MAIN_TOOLBAR,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalMainToolbarClass,
+ view_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_UINT);
+
+ signals[SOURCES_SHOWN] = g_signal_new ("sources-shown",
+ GCAL_TYPE_MAIN_TOOLBAR,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalMainToolbarClass,
+ sources_shown),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
+
g_type_class_add_private ((gpointer) klass, sizeof(GcalMainToolbarPrivate));
}
+static void
+_gcal_main_toolbar_view_changed (GtkWidget *button,
+ gpointer user_data)
+{
+ GcalMainToolbar *app;
+ guint view_type;
+
+ app = GCAL_MAIN_TOOLBAR (user_data);
+ view_type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button),
+ "view-type"));
+
+ g_signal_emit (app, signals[VIEW_CHANGED], 0, view_type);
+}
+
+static void
+_gcal_main_toolbar_sources_shown (GtkWidget *button,
+ gpointer user_data)
+{
+ GcalMainToolbar *app;
+
+ app = GCAL_MAIN_TOOLBAR (user_data);
+ g_signal_emit (app,
+ signals[SOURCES_SHOWN],
+ 0,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
+}
+
ClutterActor*
gcal_main_toolbar_new (void)
{
diff --git a/src/gcal-main-toolbar.h b/src/gcal-main-toolbar.h
index 44c30e6b..30c41239 100644
--- a/src/gcal-main-toolbar.h
+++ b/src/gcal-main-toolbar.h
@@ -38,6 +38,10 @@ typedef struct _GcalMainToolbarPrivate GcalMainToolbarPrivate;
struct _GcalMainToolbarClass
{
GtkClutterActorClass parent_class;
+
+ /* Signals */
+ void (*view_changed) (GcalMainToolbar *main_toolbar, guint view_type);
+ void (*sources_shown) (GcalMainToolbar *main_toolbar, gboolean visible);
};
struct _GcalMainToolbar
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
new file mode 100644
index 00000000..34504c81
--- /dev/null
+++ b/src/gcal-month-view.c
@@ -0,0 +1,355 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
+/*
+ * gcal-month-view.c
+ *
+ * Copyright (C) 2012 - Erick Pérez Castellanos
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "gcal-month-view.h"
+
+#include
+
+enum
+{
+ PROP_0,
+ PROP_DATE
+};
+
+struct _GcalMonthViewPrivate
+{
+ GDate *date;
+
+ gint header_font_size;
+
+ gdouble vertical_step;
+ gdouble horizontal_step;
+};
+
+/* this will need translation */
+const char* weekdays [] =
+ {
+ "Sun",
+ "Mon",
+ "Tue",
+ "Wed",
+ "Thu",
+ "Fri",
+ "Sat"
+ };
+
+static void gcal_month_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void gcal_month_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static gboolean gcal_month_view_draw (GtkWidget *widget,
+ cairo_t *cr);
+
+static void gcal_month_view_finalize (GObject *object);
+
+static void _gcal_month_view_draw_month_grid (GcalMonthView *mont_view,
+ cairo_t *cr,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+
+G_DEFINE_TYPE(GcalMonthView, gcal_month_view, GTK_TYPE_WIDGET)
+
+static void gcal_month_view_class_init (GcalMonthViewClass *klass)
+{
+ GtkWidgetClass* widget_class;
+ GObjectClass *object_class;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->draw = gcal_month_view_draw;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->set_property = gcal_month_view_set_property;
+ object_class->get_property = gcal_month_view_get_property;
+ object_class->finalize = gcal_month_view_finalize;
+
+ g_object_class_install_property (object_class, PROP_DATE,
+ g_param_spec_boxed ("date",
+ "date",
+ _("Date"),
+ G_TYPE_DATE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private ((gpointer)klass, sizeof (GcalMonthViewPrivate));
+}
+
+
+
+static void gcal_month_view_init (GcalMonthView *self)
+{
+ gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GCAL_TYPE_MONTH_VIEW,
+ GcalMonthViewPrivate);
+}
+
+static void
+gcal_month_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GcalMonthViewPrivate *priv = GCAL_MONTH_VIEW (object)->priv;
+
+ switch (property_id)
+ {
+ case PROP_DATE:
+ if (priv->date)
+ g_date_free (priv->date);
+
+ priv->date = g_value_dup_boxed (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gcal_month_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GcalMonthViewPrivate *priv = GCAL_MONTH_VIEW (object)->priv;
+
+ switch (property_id)
+ {
+ case PROP_DATE:
+ g_value_set_boxed (value, priv->date);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+gcal_month_view_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GcalMonthViewPrivate *priv;
+
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GtkBorder padding;
+ GdkRGBA color;
+ GtkAllocation alloc;
+
+ priv = GCAL_MONTH_VIEW (widget)->priv;
+
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_padding (context, state, &padding);
+
+ gtk_style_context_get_color (context, state, &color);
+
+ /* header_font_size is found through pango_get_size_in_pixels */
+ priv->header_font_size = 12;
+
+ /* getting allocation, and so on */
+ gtk_widget_get_allocation (widget, &alloc);
+
+ _gcal_month_view_draw_month_grid (
+ GCAL_MONTH_VIEW (widget),
+ cr,
+ alloc.x + padding.left,
+ 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));
+
+ return FALSE;
+}
+
+static void
+gcal_month_view_finalize (GObject *object)
+{
+ GcalMonthViewPrivate *priv = GCAL_MONTH_VIEW (object)->priv;
+
+ if (priv->date)
+ g_date_free (priv->date);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (gcal_month_view_parent_class)->finalize (object);
+}
+
+static void
+_gcal_month_view_draw_month_grid (GcalMonthView *month_view,
+ cairo_t *cr,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ GcalMonthViewPrivate *priv;
+ GtkWidget *widget;
+
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GdkRGBA color;
+
+ gint i, j;
+ gint font_width;
+ gint font_height;
+
+ guint8 n_days_in_month;
+ GDate *first_of_month;
+ GDateWeekday lapse;
+ gint space;
+
+ PangoLayout *layout;
+ gchar *day;
+
+ priv = month_view->priv;
+ widget = GTK_WIDGET (month_view);
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_color (context, state, &color);
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
+
+ layout = pango_cairo_create_layout (cr);
+ pango_layout_set_font_description (layout,
+ gtk_style_context_get_font (context,
+ state));
+
+ priv->vertical_step = (gdouble) height / 5;
+ priv->horizontal_step= (gdouble) width / 7;
+
+ n_days_in_month = g_date_get_days_in_month (g_date_get_month (priv->date),
+ g_date_get_year (priv->date));
+
+ first_of_month = g_date_new_dmy (1,
+ g_date_get_month (priv->date),
+ g_date_get_year (priv->date));
+
+ lapse = g_date_get_weekday (first_of_month);
+ space = (lapse == 7 ? 1 : 1 - lapse);
+ g_date_free (first_of_month);
+
+ for (i = 0; i < 7; i++)
+ {
+ pango_layout_set_text (layout, weekdays[i], -1);
+ pango_cairo_update_layout (cr, layout);
+ pango_layout_get_pixel_size (layout, &font_width, &font_height);
+ cairo_move_to (cr,
+ x + priv->horizontal_step * i + 1,
+ y - font_height - 1);
+ pango_cairo_show_layout (cr, layout);
+
+ for (j = 0; j < 5; j++)
+ {
+ gint n_day = j * 7 + i + space;
+ if (n_day <= 0 ||
+ n_day > n_days_in_month)
+ continue;
+ day = g_strdup_printf ("%d", n_day);
+ pango_layout_set_text (layout, day, -1);
+ pango_cairo_update_layout (cr, layout);
+ pango_layout_get_pixel_size (layout, &font_width, &font_height);
+ cairo_move_to (cr,
+ x + priv->horizontal_step * i + 2,
+ y + priv->vertical_step * j + 1);
+ pango_cairo_show_layout (cr, layout);
+ g_free (day);
+ }
+ }
+ /* free the layout object */
+ g_object_unref (layout);
+
+ for (i = 0; i < 6; i++) {
+ cairo_move_to (cr, x, y + priv->vertical_step * i);
+ cairo_line_to (cr,
+ x + priv->horizontal_step * 7,
+ y + priv->vertical_step * i);
+ }
+
+ for (i = 0; i < 8; i++) {
+ cairo_move_to (cr, x + priv->horizontal_step * i, y);
+ cairo_line_to (cr, x + priv->horizontal_step * i, y + height);
+ }
+
+ cairo_stroke (cr);
+}
+
+/**
+ * gcal_month_view_new:
+ * @date:
+ *
+ * Since: 0.1
+ * Return value: the new month view widget
+ * Returns: (transfer full):
+ **/
+GtkWidget*
+gcal_month_view_new (GDate *date)
+{
+ g_return_val_if_fail (g_date_valid (date), NULL);
+
+ return g_object_new (GCAL_TYPE_MONTH_VIEW, "date", date, NULL);
+}
+
+/**
+ * gcal_month_view_get_initial_date:
+ *
+ * Since: 0.1
+ * Return value: the first day of the month
+ * Returns: (transfer full):
+ **/
+GDate*
+gcal_month_view_get_initial_date (GcalMonthView *view)
+{
+ GcalMonthViewPrivate *priv = view->priv;
+ GDate *initial = g_date_new_dmy (1,
+ g_date_get_month (priv->date),
+ g_date_get_year (priv->date));
+ return initial;
+}
+
+/**
+ * gcal_month_view_get_final_date:
+ *
+ * Since: 0.1
+ * Return value: the last day of the month
+ * Returns: (transfer full):
+ **/
+GDate*
+gcal_month_view_get_final_date (GcalMonthView *view)
+{
+ GcalMonthViewPrivate *priv = view->priv;
+ GDate *last = g_date_new_dmy (g_date_get_days_in_month (
+ g_date_get_month (priv->date),
+ g_date_get_year (priv->date)),
+ g_date_get_month (priv->date),
+ g_date_get_year (priv->date));
+ return last;
+}
diff --git a/src/gcal-month-view.h b/src/gcal-month-view.h
new file mode 100644
index 00000000..d02e0d00
--- /dev/null
+++ b/src/gcal-month-view.h
@@ -0,0 +1,61 @@
+/*
+ * gcal-month-view.h
+ *
+ * Copyright (C) 2012 - Erick Pérez Castellanos
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __GCAL_MONTH_VIEW_H__
+#define __GCAL_MONTH_VIEW_H__
+
+#include
+
+G_BEGIN_DECLS
+
+
+#define GCAL_TYPE_MONTH_VIEW (gcal_month_view_get_type ())
+#define GCAL_MONTH_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_MONTH_VIEW, GcalMonthView))
+#define GCAL_MONTH_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_MONTH_VIEW, GcalMonthViewClass))
+#define GCAL_IS_MONTH_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_MONTH_VIEW))
+#define GCAL_IS_MONTH_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_MONTH_VIEW))
+#define GCAL_MONTH_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_MONTH_VIEW, GcalMonthViewClass))
+
+typedef struct _GcalMonthView GcalMonthView;
+typedef struct _GcalMonthViewClass GcalMonthViewClass;
+typedef struct _GcalMonthViewPrivate GcalMonthViewPrivate;
+
+struct _GcalMonthView
+{
+ GtkWidget parent;
+
+ /* add your public declarations here */
+ GcalMonthViewPrivate *priv;
+};
+
+struct _GcalMonthViewClass
+{
+ GtkWidgetClass parent_class;
+};
+
+GType gcal_month_view_get_type (void);
+
+GtkWidget* gcal_month_view_new (GDate *date);
+
+GDate* gcal_month_view_get_initial_date (GcalMonthView *view);
+GDate* gcal_month_view_get_final_date (GcalMonthView *view);
+
+G_END_DECLS
+
+#endif /* __GCAL_MONTH_VIEW_H__ */
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
new file mode 100644
index 00000000..92c4c18b
--- /dev/null
+++ b/src/gcal-utils.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
+/*
+ * gcal-window.h
+ * Copyright (C) 2012 Erick Pérez Castellanos
+ *
+ * gnome-calendar is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gnome-calendar is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+typedef enum
+{
+ GCAL_VIEW_TYPE_DAILY = 0,
+ GCAL_VIEW_TYPE_WEEKLY,
+ GCAL_VIEW_TYPE_MONTHLY,
+ GCAL_VIEW_TYPE_YEARLY,
+ GCAL_VIEW_TYPE_LIST,
+} GcalViewType;
diff --git a/src/gcal-window.c b/src/gcal-window.c
index e27fb577..e0bec434 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -19,6 +19,8 @@
#include "gcal-window.h"
#include "gcal-main-toolbar.h"
+#include "gcal-month-view.h"
+#include "gcal-utils.h"
#include
#include
@@ -26,8 +28,18 @@
struct _GcalWindowPrivate
{
ClutterActor *main_toolbar;
+
+ GtkWidget *notebook;
+ GtkWidget *views [5];
};
+static void _gcal_window_view_changed (GcalMainToolbar *main_toolbar,
+ GcalViewType view_type,
+ gpointer user_data);
+static void _gcal_window_sources_shown (GcalMainToolbar *main_toolbar,
+ gboolean visible,
+ gpointer user_data);
+
G_DEFINE_TYPE(GcalWindow, gcal_window, GTK_TYPE_APPLICATION_WINDOW)
static void
@@ -45,6 +57,11 @@ static void gcal_window_init(GcalWindow *self)
ClutterActor *body_actor;
ClutterLayoutManager *body_layout_manager;
ClutterActor *main_toolbar;
+ ClutterActor *contents_actor;
+ ClutterLayoutManager *contents_layout_manager;
+ ClutterActor *notebook_actor;
+
+ GtkStyleContext *context;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
GCAL_TYPE_WINDOW,
@@ -90,9 +107,71 @@ static void gcal_window_init(GcalWindow *self)
CLUTTER_BOX_ALIGNMENT_START,
CLUTTER_BOX_ALIGNMENT_START);
+ /* contents */
+ contents_layout_manager = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+ CLUTTER_BIN_ALIGNMENT_CENTER);
+ contents_actor = clutter_actor_new ();
+ clutter_actor_set_layout_manager (contents_actor, contents_layout_manager);
+ clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (body_layout_manager),
+ contents_actor,
+ TRUE,
+ TRUE,
+ TRUE,
+ CLUTTER_BOX_ALIGNMENT_START,
+ CLUTTER_BOX_ALIGNMENT_START);
+
+ self->priv->notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->priv->notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (self->priv->notebook), FALSE);
+ gtk_widget_show (self->priv->notebook);
+
+ notebook_actor = gtk_clutter_actor_new_with_contents (self->priv->notebook);
+
+ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (contents_layout_manager),
+ notebook_actor,
+ CLUTTER_BIN_ALIGNMENT_FILL,
+ CLUTTER_BIN_ALIGNMENT_FILL);
+
+ GDate *date = g_date_new ();
+ g_date_set_time_t (date, time (NULL));
+ self->priv->views[GCAL_VIEW_TYPE_MONTHLY] = gcal_month_view_new (date);
+
+ context = gtk_widget_get_style_context (self->priv->views[GCAL_VIEW_TYPE_MONTHLY]);
+ gtk_style_context_add_class (context, "views");
+
+ gtk_widget_show (self->priv->views[GCAL_VIEW_TYPE_MONTHLY]);
+ gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+ self->priv->views[GCAL_VIEW_TYPE_MONTHLY],
+ NULL);
+
+ g_signal_connect (main_toolbar,
+ "view-changed",
+ G_CALLBACK (_gcal_window_view_changed),
+ self);
+ g_signal_connect (main_toolbar,
+ "sources-shown",
+ G_CALLBACK (_gcal_window_sources_shown),
+ self);
+
gtk_widget_show (embed);
}
+static void
+_gcal_window_view_changed (GcalMainToolbar *main_toolbar,
+ GcalViewType view_type,
+ gpointer user_data)
+{
+ g_print ("GcalViewType in GcalWindow %d\n", view_type);
+}
+
+static void
+_gcal_window_sources_shown (GcalMainToolbar *main_toolbar,
+ gboolean visible,
+ gpointer user_data)
+{
+ g_print ("Visible: %s\n", visible ? "yes" : "no");
+}
+
GtkWidget*
gcal_window_new (void)
{