[gnome-calendar/date-selector] date-selector: set calendar's date
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/date-selector] date-selector: set calendar's date
- Date: Sun, 21 Dec 2014 00:16:15 +0000 (UTC)
commit ff1b2bbda7dff63e8d1b25a7c9ff9fd5b2408425
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Dec 20 22:16:06 2014 -0200
date-selector: set calendar's date
src/gcal-date-selector.c | 44 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/src/gcal-date-selector.c b/src/gcal-date-selector.c
index d034d36..0467235 100644
--- a/src/gcal-date-selector.c
+++ b/src/gcal-date-selector.c
@@ -33,14 +33,18 @@ enum
struct _GcalDateSelectorPrivate
{
+ /* widgets */
GtkWidget *date_label;
GtkWidget *popover;
GtkWidget *entries[NUM_ENTRIES];
+ GtkWidget *calendar;
+ /* date */
gint day;
gint month;
gint year;
+ /* misc */
gchar *mask;
guint day_pos;
guint month_pos;
@@ -58,11 +62,37 @@ enum
static guint signals[NUM_SIGNALS] = { 0, };
+static void set_date (GcalDateSelector *selector,
+ gint day,
+ gint month,
+ gint year);
+
static void gcal_date_selector_constructed (GObject *object);
G_DEFINE_TYPE_WITH_PRIVATE (GcalDateSelector, gcal_date_selector, GTK_TYPE_TOGGLE_BUTTON);
static void
+set_date (GcalDateSelector *selector,
+ gint day,
+ gint month,
+ gint year)
+{
+ GcalDateSelectorPrivate *priv;
+
+ g_return_if_fail (GCAL_IS_DATE_SELECTOR (selector));
+ priv = gcal_date_selector_get_instance_private (selector);
+
+ priv->day = day;
+ priv->month = month;
+ priv->year = year;
+
+ month = CLAMP (month - 1, 0, 11);
+
+ /* set calendar's date */
+ g_object_set (priv->calendar, "day", day, "month", month, "year", year, NULL);
+}
+
+static void
gcal_date_selector_class_init (GcalDateSelectorClass *klass)
{
GObjectClass *object_class;
@@ -155,6 +185,11 @@ gcal_date_selector_constructed (GObject *object)
grid = (GtkWidget*) gtk_builder_get_object (builder, "grid");
g_object_ref (grid);
+ /* calendar */
+ priv->calendar = (GtkWidget*) gtk_builder_get_object (builder, "calendar");
+ g_object_ref (priv->calendar);
+
+ /* signals and properties */
gtk_container_add (GTK_CONTAINER (priv->popover), grid);
g_object_bind_property (priv->popover, "visible", object, "active", G_BINDING_BIDIRECTIONAL);
}
@@ -172,14 +207,7 @@ gcal_date_selector_set_date (GcalDateSelector *selector,
gint month,
gint year)
{
- GcalDateSelectorPrivate *priv;
-
- g_return_if_fail (GCAL_IS_DATE_SELECTOR (selector));
- priv = gcal_date_selector_get_instance_private (selector);
-
- priv->day = day;
- priv->month = month;
- priv->year = year;
+ set_date (selector, day, month, year);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]