diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index b1421a8c..bdc9ef0a 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -14,6 +14,17 @@
padding: 12px;
}
+.view-overlay .frame {
+ border-left: 0;
+ border-right: 0;
+ border-bottom: 0;
+}
+
+.view-overlay .scrollbar.trough {
+ background-color: transparent;
+ background-image: none;
+}
+
.calendar-view {
padding: 6px;
font: 10;
@@ -43,15 +54,6 @@
border-radius: 0;
}
-.calendar-view .scrollbar.slider {
- background-color: alpha (@scrollbar_slider, 0.5);
- border: #6e6e6e 1px solid;
-}
-.calendar-view .scrollbar.trough {
- background-color: transparent;
- background-image: none;
-}
-
.entry {
border-radius: 0;
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 24311a3e..bb7eb8e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,6 +56,8 @@ gnome_calendar_SOURCES = \
gcal-manager.h \
gcal-nav-bar.h \
gcal-nav-bar.c \
+ gcal-viewport.c \
+ gcal-viewport.h \
gcal-all-day-grid.c \
gcal-all-day-grid.h \
gcal-utils.c \
diff --git a/src/calendar.gresource.xml b/src/calendar.gresource.xml
index d06cc335..44ea605c 100644
--- a/src/calendar.gresource.xml
+++ b/src/calendar.gresource.xml
@@ -1,6 +1,7 @@
- nav_bar.ui
+ nav_bar.ui
+ viewport.ui
diff --git a/src/gcal-viewport.c b/src/gcal-viewport.c
new file mode 100644
index 00000000..1b5f9601
--- /dev/null
+++ b/src/gcal-viewport.c
@@ -0,0 +1,175 @@
+/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * gcal-viewport.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-viewport.h"
+
+#include
+
+#include
+
+struct _GcalViewportPrivate
+{
+ /* property */
+ GtkWidget *viewport;
+ GtkWidget *hscrollbar;
+ GtkWidget *vscrollbar;
+};
+
+static void gcal_viewport_constructed (GObject *object);
+
+static void gcal_viewport_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+
+static void gcal_viewport_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+
+static void gcal_viewport_child_allocated (GtkWidget *widget,
+ GdkRectangle *allocation,
+ gpointer user_data);
+
+G_DEFINE_TYPE (GcalViewport,gcal_viewport, GTK_TYPE_OVERLAY);
+
+static void
+gcal_viewport_class_init (GcalViewportClass *klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->constructed = gcal_viewport_constructed;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->get_preferred_width = gcal_viewport_get_preferred_width;
+ widget_class->get_preferred_height = gcal_viewport_get_preferred_height;
+
+ /* Setup the template GtkBuilder xml for this class */
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/viewport.ui");
+
+ /* Bind internals widgets */
+ gtk_widget_class_bind_child (widget_class, GcalViewportPrivate, hscrollbar);
+ gtk_widget_class_bind_child (widget_class, GcalViewportPrivate, vscrollbar);
+ gtk_widget_class_bind_child (widget_class, GcalViewportPrivate, viewport);
+
+ g_type_class_add_private ((gpointer)klass, sizeof (GcalViewportPrivate));
+}
+
+
+
+static void
+gcal_viewport_init (GcalViewport *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GCAL_TYPE_VIEWPORT,
+ GcalViewportPrivate);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+gcal_viewport_constructed (GObject *object)
+{
+ GcalViewportPrivate *priv;
+
+ GtkAdjustment *adj;
+
+ priv = GCAL_VIEWPORT (object)->priv;
+
+ adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (priv->viewport));
+ gtk_range_set_adjustment (GTK_RANGE (priv->hscrollbar), adj);
+
+ adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->viewport));
+ gtk_range_set_adjustment (GTK_RANGE (priv->vscrollbar), adj);
+}
+
+static void
+gcal_viewport_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ if (minimum != NULL)
+ *minimum = 12;
+ if (natural != NULL)
+ *natural = 12;
+}
+
+static void
+gcal_viewport_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ if (minimum != NULL)
+ *minimum = 12;
+ if (natural != NULL)
+ *natural = 12;
+}
+
+static void
+gcal_viewport_child_allocated (GtkWidget *widget,
+ GdkRectangle *allocation,
+ gpointer user_data)
+{
+ GcalViewportPrivate *priv;
+ gint width, height;
+
+ priv = GCAL_VIEWPORT (user_data)->priv;
+
+ width = gtk_widget_get_allocated_width (GTK_WIDGET (user_data));
+ height = gtk_widget_get_allocated_height (GTK_WIDGET (user_data));
+
+ if (width >= allocation->width)
+ gtk_widget_hide (priv->hscrollbar);
+ else
+ gtk_widget_show (priv->hscrollbar);
+
+ if (height >= allocation->height)
+ gtk_widget_hide (priv->vscrollbar);
+ else
+ gtk_widget_show (priv->vscrollbar);
+}
+
+/* Public API */
+/**
+ * gcal_viewport_new:
+ *
+ * Since: 0.1
+ * Return value: A new #GcalViewport
+ * Returns: (transfer full):
+ **/
+GtkWidget*
+gcal_viewport_new ()
+{
+ return g_object_new (GCAL_TYPE_VIEWPORT, NULL);
+}
+
+void
+gcal_viewport_add (GcalViewport *viewport,
+ GtkWidget *widget)
+{
+ GcalViewportPrivate *priv;
+
+ priv = viewport->priv;
+ gtk_container_add (GTK_CONTAINER (priv->viewport), widget);
+
+ /* signals handlers */
+ g_signal_connect_after (widget, "size-allocate",
+ G_CALLBACK (gcal_viewport_child_allocated), viewport);
+}
diff --git a/src/gcal-viewport.h b/src/gcal-viewport.h
new file mode 100644
index 00000000..fe659c15
--- /dev/null
+++ b/src/gcal-viewport.h
@@ -0,0 +1,60 @@
+/*
+ * gcal-viewport.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_VIEWPORT_H__
+#define __GCAL_VIEWPORT_H__
+
+#include
+
+G_BEGIN_DECLS
+
+#define GCAL_TYPE_VIEWPORT (gcal_viewport_get_type ())
+#define GCAL_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_VIEWPORT, GcalViewport))
+#define GCAL_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_VIEWPORT, GcalViewportClass))
+#define GCAL_IS_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_VIEWPORT))
+#define GCAL_IS_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_VIEWPORT))
+#define GCAL_VIEWPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_VIEWPORT, GcalViewportClass))
+
+typedef struct _GcalViewport GcalViewport;
+typedef struct _GcalViewportClass GcalViewportClass;
+typedef struct _GcalViewportPrivate GcalViewportPrivate;
+
+struct _GcalViewport
+{
+ GtkOverlay parent;
+
+ /* add your public declarations here */
+ GcalViewportPrivate *priv;
+};
+
+struct _GcalViewportClass
+{
+ GtkOverlayClass parent_class;
+};
+
+GType gcal_viewport_get_type (void);
+
+GtkWidget* gcal_viewport_new (void);
+
+void gcal_viewport_add (GcalViewport *viewport,
+ GtkWidget *widget);
+
+G_END_DECLS
+
+#endif /* __GCAL_VIEWPORT_H__ */
diff --git a/src/viewport.ui b/src/viewport.ui
new file mode 100644
index 00000000..832d0688
--- /dev/null
+++ b/src/viewport.ui
@@ -0,0 +1,35 @@
+
+
+
+
+ True
+ False
+
+
+
+
+
+
+
+
+
+
+
+