[evolution/wip/webkit2] Hide private members of ECalendar into a private structure



commit 1f2dee89ce4557eb3454cb62cba23703b146534d
Author: Milan Crha <mcrha redhat com>
Date:   Fri Apr 8 14:52:52 2016 +0200

    Hide private members of ECalendar into a private structure

 calendar/gui/e-cal-dialogs.c                 |   20 ++--
 calendar/gui/e-comp-editor-page-recurrence.c |    8 +-
 calendar/gui/tag-calendar.c                  |   14 +-
 e-util/e-calendar.c                          |  206 +++++++++++++++-----------
 e-util/e-calendar.h                          |   24 +---
 e-util/e-cell-date-edit.c                    |    6 +-
 e-util/e-dateedit.c                          |   18 +-
 e-util/test-calendar.c                       |    2 +-
 modules/calendar/e-cal-base-shell-sidebar.c  |    6 +-
 modules/calendar/e-cal-shell-backend.c       |    2 +-
 modules/calendar/e-cal-shell-content.c       |   18 +-
 modules/calendar/e-cal-shell-view-private.c  |    6 +-
 12 files changed, 170 insertions(+), 160 deletions(-)
---
diff --git a/calendar/gui/e-cal-dialogs.c b/calendar/gui/e-cal-dialogs.c
index 1be2f02..10e8de4 100644
--- a/calendar/gui/e-cal-dialogs.c
+++ b/calendar/gui/e-cal-dialogs.c
@@ -603,7 +603,7 @@ year_changed (GtkAdjustment *adj,
        dlg->year_val = gtk_spin_button_get_value_as_int (spin_button);
 
        e_calendar_item_set_first_month (
-               dlg->ecal->calitem, dlg->year_val, dlg->month_val);
+               e_calendar_get_item (dlg->ecal), dlg->year_val, dlg->month_val);
 }
 
 /* Callback used when a month button is toggled */
@@ -618,7 +618,7 @@ month_changed (GtkToggleButton *toggle,
        dlg->month_val = gtk_combo_box_get_active (combo_box);
 
        e_calendar_item_set_first_month (
-               dlg->ecal->calitem, dlg->year_val, dlg->month_val);
+               e_calendar_get_item (dlg->ecal), dlg->year_val, dlg->month_val);
 }
 
 /* Event handler for day groups in the month item.  A button press makes
@@ -729,7 +729,7 @@ goto_dialog_create_widgets (GoToDialog *dlg,
        dlg->ecal = E_CALENDAR (e_calendar_new ());
        dlg->tag_calendar = e_tag_calendar_new (dlg->ecal);
 
-       calitem = dlg->ecal->calitem;
+       calitem = e_calendar_get_item (dlg->ecal);
 
        gnome_canvas_item_set (
                GNOME_CANVAS_ITEM (calitem),
@@ -806,7 +806,7 @@ e_cal_dialogs_goto_run (GtkWindow *parent,
                G_CALLBACK (year_changed), dlg);
 
        g_signal_connect (
-               dlg->ecal->calitem, "selection_changed",
+               e_calendar_get_item (dlg->ecal), "selection_changed",
                G_CALLBACK (ecal_event), dlg);
 
        gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->month_combobox), dlg->month_val);
@@ -816,13 +816,13 @@ e_cal_dialogs_goto_run (GtkWindow *parent,
 
        /* set initial selection to current day */
 
-       dlg->ecal->calitem->selection_set = TRUE;
-       dlg->ecal->calitem->selection_start_month_offset = 0;
-       dlg->ecal->calitem->selection_start_day = dlg->day_val;
-       dlg->ecal->calitem->selection_end_month_offset = 0;
-       dlg->ecal->calitem->selection_end_day = dlg->day_val;
+       e_calendar_get_item (dlg->ecal)->selection_set = TRUE;
+       e_calendar_get_item (dlg->ecal)->selection_start_month_offset = 0;
+       e_calendar_get_item (dlg->ecal)->selection_start_day = dlg->day_val;
+       e_calendar_get_item (dlg->ecal)->selection_end_month_offset = 0;
+       e_calendar_get_item (dlg->ecal)->selection_end_day = dlg->day_val;
 
-       gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem));
+       gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (e_calendar_get_item (dlg->ecal)));
 
        e_tag_calendar_subscribe (dlg->tag_calendar, dlg->data_model);
 
diff --git a/calendar/gui/e-comp-editor-page-recurrence.c b/calendar/gui/e-comp-editor-page-recurrence.c
index a8fa3e5..0f901e7 100644
--- a/calendar/gui/e-comp-editor-page-recurrence.c
+++ b/calendar/gui/e-comp-editor-page-recurrence.c
@@ -175,7 +175,7 @@ ecep_recurrence_update_preview (ECompEditorPageRecurrence *page_recurrence)
        if (!client)
                client = e_comp_editor_get_target_client (comp_editor);
 
-       e_calendar_item_clear_marks (E_CALENDAR (page_recurrence->priv->preview)->calitem);
+       e_calendar_item_clear_marks (e_calendar_get_item (E_CALENDAR (page_recurrence->priv->preview)));
 
        editing_comp = e_comp_editor_get_component (comp_editor);
        if (!editing_comp || e_cal_util_component_is_instance ((icalcomponent *) editing_comp)) {
@@ -2284,10 +2284,10 @@ ecep_recurrence_constructed (GObject *object)
 
        ecal = E_CALENDAR (page_recurrence->priv->preview);
        g_signal_connect_swapped (
-               ecal->calitem, "date-range-changed",
+               e_calendar_get_item (ecal), "date-range-changed",
                G_CALLBACK (ecep_recurrence_update_preview), page_recurrence);
-       e_calendar_item_set_max_days_sel (ecal->calitem, 0);
-       e_calendar_item_set_get_time_callback (ecal->calitem, ecep_recurrence_get_current_time_cb, NULL, 
NULL);
+       e_calendar_item_set_max_days_sel (e_calendar_get_item (ecal), 0);
+       e_calendar_item_set_get_time_callback (e_calendar_get_item (ecal), 
ecep_recurrence_get_current_time_cb, NULL, NULL);
 
        g_signal_connect_swapped (page_recurrence->priv->recr_interval_value_spin, "value-changed",
                G_CALLBACK (ecep_recurrence_changed), page_recurrence);
diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c
index ffb2dc1..e507aa9 100644
--- a/calendar/gui/tag-calendar.c
+++ b/calendar/gui/tag-calendar.c
@@ -361,7 +361,7 @@ e_tag_calendar_query_tooltip_cb (ECalendar *calendar,
        g_return_val_if_fail (E_IS_TAG_CALENDAR (tag_calendar), FALSE);
        g_return_val_if_fail (GTK_IS_TOOLTIP (tooltip), FALSE);
 
-       if (!e_calendar_item_convert_position_to_date (calendar->calitem, x, y, &date))
+       if (!e_calendar_item_convert_position_to_date (e_calendar_get_item (calendar), x, y, &date))
                return FALSE;
 
        julian = encode_ymd_to_julian (g_date_get_year (&date), g_date_get_month (&date), g_date_get_day 
(&date));
@@ -595,11 +595,11 @@ e_tag_calendar_set_calendar (ETagCalendar *tag_calendar,
 {
        g_return_if_fail (E_IS_TAG_CALENDAR (tag_calendar));
        g_return_if_fail (E_IS_CALENDAR (calendar));
-       g_return_if_fail (calendar->calitem != NULL);
+       g_return_if_fail (e_calendar_get_item (calendar) != NULL);
        g_return_if_fail (tag_calendar->priv->calendar == NULL);
 
        tag_calendar->priv->calendar = calendar;
-       tag_calendar->priv->calitem = calendar->calitem;
+       tag_calendar->priv->calitem = e_calendar_get_item (calendar);
 
        g_object_weak_ref (G_OBJECT (tag_calendar->priv->calendar),
                (GWeakNotify) g_nullify_pointer, &tag_calendar->priv->calendar);
@@ -687,7 +687,7 @@ e_tag_calendar_dispose (GObject *object)
        ETagCalendar *tag_calendar = E_TAG_CALENDAR (object);
 
        if (tag_calendar->priv->calendar != NULL) {
-               g_signal_handlers_disconnect_by_func (tag_calendar->priv->calendar->calitem,
+               g_signal_handlers_disconnect_by_func (e_calendar_get_item (tag_calendar->priv->calendar),
                        G_CALLBACK (e_tag_calendar_date_range_changed_cb), tag_calendar);
                g_signal_handlers_disconnect_by_func (tag_calendar->priv->calendar,
                        G_CALLBACK (e_tag_calendar_query_tooltip_cb), tag_calendar);
@@ -890,10 +890,10 @@ prepare_tag (ECalendar *ecal,
        struct icaltimetype end_tt = icaltime_null_time ();
 
        if (clear_first)
-               e_calendar_item_clear_marks (ecal->calitem);
+               e_calendar_item_clear_marks (e_calendar_get_item (ecal));
 
        if (!e_calendar_item_get_date_range (
-               ecal->calitem,
+               e_calendar_get_item (ecal),
                &start_year, &start_month, &start_day,
                &end_year, &end_month, &end_day))
                return FALSE;
@@ -908,7 +908,7 @@ prepare_tag (ECalendar *ecal,
 
        icaltime_adjust (&end_tt, 1, 0, 0, 0);
 
-       closure->calitem = ecal->calitem;
+       closure->calitem = e_calendar_get_item (ecal);
 
        if (zone != NULL)
                closure->zone = zone;
diff --git a/e-util/e-calendar.c b/e-util/e-calendar.c
index d5f7391..f429ec0 100644
--- a/e-util/e-calendar.c
+++ b/e-util/e-calendar.c
@@ -66,7 +66,29 @@
 #define E_CALENDAR_AUTO_MOVE_TIMEOUT           150
 #define E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY     2
 
-#define REPOSITION_TIMEOUT_KEY "e-calendar-reposition-timeout-id"
+struct _ECalendarPrivate {
+       ECalendarItem *calitem;
+
+       GnomeCanvasItem *prev_item;
+       GnomeCanvasItem *next_item;
+       GnomeCanvasItem *prev_item_year;
+       GnomeCanvasItem *next_item_year;
+
+       gint min_rows;
+       gint min_cols;
+
+       gint max_rows;
+       gint max_cols;
+
+       /* These are all used when the prev/next buttons are held down.
+        * moving_forward is TRUE if we are moving forward in time, i.e. the
+        * next button is pressed. */
+       gint timeout_id;
+       gint timeout_delay;
+       gboolean moving_forward;
+
+       gint reposition_timeout_id;
+};
 
 static void e_calendar_dispose         (GObject        *object);
 static void e_calendar_realize         (GtkWidget      *widget);
@@ -176,11 +198,12 @@ e_calendar_class_init (ECalendarClass *class)
        GObjectClass   *object_class;
        GtkWidgetClass *widget_class;
 
-       object_class = (GObjectClass *) class;
-       widget_class = (GtkWidgetClass *) class;
+       g_type_class_add_private (class, sizeof (ECalendarPrivate));
 
+       object_class = (GObjectClass *) class;
        object_class->dispose = e_calendar_dispose;
 
+       widget_class = (GtkWidgetClass *) class;
        widget_class->realize = e_calendar_realize;
        widget_class->style_updated = e_calendar_style_updated;
        widget_class->get_preferred_width = e_calendar_get_preferred_width;
@@ -200,6 +223,8 @@ e_calendar_init (ECalendar *cal)
        GtkWidget *button;
        AtkObject *a11y;
 
+       cal->priv = G_TYPE_INSTANCE_GET_PRIVATE (cal, E_TYPE_CALENDAR, ECalendarPrivate);
+
        pango_context = gtk_widget_create_pango_context (GTK_WIDGET (cal));
        g_warn_if_fail (pango_context != NULL);
 
@@ -213,7 +238,7 @@ e_calendar_init (ECalendar *cal)
 
        canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (cal)->root);
 
-       cal->calitem = E_CALENDAR_ITEM (
+       cal->priv->calitem = E_CALENDAR_ITEM (
                gnome_canvas_item_new (
                        canvas_group,
                        e_calendar_item_get_type (),
@@ -223,7 +248,7 @@ e_calendar_init (ECalendar *cal)
        pango_font_description_free (small_font_desc);
        g_object_unref (pango_context);
 
-       g_signal_connect (cal->calitem, "month-width-changed",
+       g_signal_connect (cal->priv->calitem, "month-width-changed",
                G_CALLBACK (calitem_month_width_changed_cb), cal);
 
        /* Create the arrow buttons to move to the previous/next month. */
@@ -238,7 +263,7 @@ e_calendar_init (ECalendar *cal)
                button, "clicked",
                G_CALLBACK (e_calendar_on_prev_clicked), cal);
 
-       cal->prev_item = gnome_canvas_item_new (
+       cal->priv->prev_item = gnome_canvas_item_new (
                canvas_group,
                gnome_canvas_widget_get_type (),
                "widget", button,
@@ -257,7 +282,7 @@ e_calendar_init (ECalendar *cal)
                button, "clicked",
                G_CALLBACK (e_calendar_on_next_clicked), cal);
 
-       cal->next_item = gnome_canvas_item_new (
+       cal->priv->next_item = gnome_canvas_item_new (
                canvas_group,
                gnome_canvas_widget_get_type (),
                "widget", button,
@@ -277,7 +302,7 @@ e_calendar_init (ECalendar *cal)
                button, "clicked",
                G_CALLBACK (e_calendar_on_prev_year_clicked), cal);
 
-       cal->prev_item_year = gnome_canvas_item_new (
+       cal->priv->prev_item_year = gnome_canvas_item_new (
                canvas_group,
                gnome_canvas_widget_get_type (),
                "widget", button,
@@ -296,7 +321,7 @@ e_calendar_init (ECalendar *cal)
                button, "clicked",
                G_CALLBACK (e_calendar_on_next_year_clicked), cal);
 
-       cal->next_item_year = gnome_canvas_item_new (
+       cal->priv->next_item_year = gnome_canvas_item_new (
                canvas_group,
                gnome_canvas_widget_get_type (),
                "widget", button,
@@ -304,12 +329,12 @@ e_calendar_init (ECalendar *cal)
        a11y = gtk_widget_get_accessible (button);
        atk_object_set_name (a11y, _("Next year"));
 
-       cal->min_rows = 1;
-       cal->min_cols = 1;
-       cal->max_rows = -1;
-       cal->max_cols = -1;
+       cal->priv->min_rows = 1;
+       cal->priv->min_cols = 1;
+       cal->priv->max_rows = -1;
+       cal->priv->max_cols = -1;
 
-       cal->timeout_id = 0;
+       cal->priv->timeout_id = 0;
 }
 
 /**
@@ -331,18 +356,12 @@ e_calendar_new (void)
        return cal;
 }
 
-static void
-cancel_pending_reposition_timeout (GObject *cal)
+ECalendarItem *
+e_calendar_get_item (ECalendar *cal)
 {
-       guint reposition_timeout_id;
+       g_return_val_if_fail (E_IS_CALENDAR (cal), NULL);
 
-       g_return_if_fail (E_IS_CALENDAR (cal));
-
-       reposition_timeout_id = GPOINTER_TO_UINT (g_object_get_data (cal, REPOSITION_TIMEOUT_KEY));
-       if (reposition_timeout_id) {
-               g_source_remove (reposition_timeout_id);
-               g_object_set_data (cal, REPOSITION_TIMEOUT_KEY, NULL);
-       }
+       return cal->priv->calitem;
 }
 
 static void
@@ -355,12 +374,15 @@ e_calendar_dispose (GObject *object)
 
        cal = E_CALENDAR (object);
 
-       if (cal->timeout_id != 0) {
-               g_source_remove (cal->timeout_id);
-               cal->timeout_id = 0;
+       if (cal->priv->timeout_id != 0) {
+               g_source_remove (cal->priv->timeout_id);
+               cal->priv->timeout_id = 0;
        }
 
-       cancel_pending_reposition_timeout (object);
+       if (cal->priv->reposition_timeout_id) {
+               g_source_remove (cal->priv->reposition_timeout_id);
+               cal->priv->reposition_timeout_id = 0;
+       }
 
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (e_calendar_parent_class)->dispose (object);
@@ -402,7 +424,7 @@ e_calendar_style_updated (GtkWidget *widget)
        if (gtk_widget_get_realized (widget))
                e_calendar_update_window_background (widget);
 
-       e_calendar_item_style_updated (widget, e_calendar->calitem);
+       e_calendar_item_style_updated (widget, e_calendar->priv->calitem);
 }
 
 static void
@@ -417,11 +439,11 @@ e_calendar_get_preferred_width (GtkWidget *widget,
 
        cal = E_CALENDAR (widget);
 
-       g_object_get ((cal->calitem), "column_width", &col_width, NULL);
+       g_object_get ((cal->priv->calitem), "column_width", &col_width, NULL);
        style_context = gtk_widget_get_style_context (widget);
        gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
-       *minimum = *natural = col_width * cal->min_cols + padding.left * 2;
+       *minimum = *natural = col_width * cal->priv->min_cols + padding.left * 2;
 }
 
 static void
@@ -436,11 +458,11 @@ e_calendar_get_preferred_height (GtkWidget *widget,
 
        cal = E_CALENDAR (widget);
 
-       g_object_get ((cal->calitem), "row_height", &row_height, NULL);
+       g_object_get ((cal->priv->calitem), "row_height", &row_height, NULL);
        style_context = gtk_widget_get_style_context (widget);
        gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
-       *minimum = *natural = row_height * cal->min_rows + padding.top * 2;
+       *minimum = *natural = row_height * cal->priv->min_rows + padding.top * 2;
 }
 
 static gboolean
@@ -459,7 +481,7 @@ e_calendar_reposition_timeout_cb (gpointer user_data)
 
        g_return_val_if_fail (E_IS_CALENDAR (cal), FALSE);
 
-       g_object_set_data (G_OBJECT (cal), REPOSITION_TIMEOUT_KEY, NULL);
+       cal->priv->reposition_timeout_id = 0;
 
        widget = GTK_WIDGET (cal);
        style_context = gtk_widget_get_style_context (widget);
@@ -487,15 +509,15 @@ e_calendar_reposition_timeout_cb (gpointer user_data)
 
        /* Take off space for line & buttons if shown. */
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (cal->calitem),
+               GNOME_CANVAS_ITEM (cal->priv->calitem),
                "x1", 0.0,
                "y1", 0.0,
                "x2", new_x2,
                "y2", new_y2,
                NULL);
 
-       if (cal->calitem->month_width > 0)
-               month_width = cal->calitem->month_width;
+       if (cal->priv->calitem->month_width > 0)
+               month_width = cal->priv->calitem->month_width;
        else
                month_width = new_x2;
        month_width -= E_CALENDAR_ITEM_MIN_CELL_XPAD + E_CALENDAR_ARROW_BUTTON_X_PAD;
@@ -514,17 +536,17 @@ e_calendar_reposition_timeout_cb (gpointer user_data)
                (xthickness);
 
        gnome_canvas_item_set (
-               cal->prev_item,
+               cal->priv->prev_item,
                "x", current_x,
                "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
                "width", arrow_button_size,
                "height", arrow_button_size,
                NULL);
 
-       current_x += (is_rtl ? -1.0 : +1.0) * (cal->calitem->max_month_name_width - xthickness + 2 * 
arrow_button_size);
+       current_x += (is_rtl ? -1.0 : +1.0) * (cal->priv->calitem->max_month_name_width - xthickness + 2 * 
arrow_button_size);
 
        gnome_canvas_item_set (
-               cal->next_item,
+               cal->priv->next_item,
                "x", current_x,
                "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
                "width", arrow_button_size,
@@ -536,17 +558,17 @@ e_calendar_reposition_timeout_cb (gpointer user_data)
                (month_width - 2 * xthickness - E_CALENDAR_ARROW_BUTTON_X_PAD - arrow_button_size);
 
        gnome_canvas_item_set (
-               cal->next_item_year,
+               cal->priv->next_item_year,
                "x", current_x,
                "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
                "width", arrow_button_size,
                "height", arrow_button_size,
                NULL);
 
-       current_x += (is_rtl ? +1.0 : -1.0) * (cal->calitem->max_digit_width * 5 - xthickness + 2 * 
arrow_button_size);
+       current_x += (is_rtl ? +1.0 : -1.0) * (cal->priv->calitem->max_digit_width * 5 - xthickness + 2 * 
arrow_button_size);
 
        gnome_canvas_item_set (
-               cal->prev_item_year,
+               cal->priv->prev_item_year,
                "x", current_x,
                "y", ythickness + E_CALENDAR_ARROW_BUTTON_Y_PAD,
                "width", arrow_button_size,
@@ -562,15 +584,19 @@ static void
 e_calendar_size_allocate (GtkWidget *widget,
                           GtkAllocation *allocation)
 {
-       GObject *object;
+       ECalendar *cal;
 
        (*GTK_WIDGET_CLASS (e_calendar_parent_class)->size_allocate) (widget, allocation);
 
-       object = G_OBJECT (widget);
+       cal = E_CALENDAR (widget);
+
+       if (cal->priv->reposition_timeout_id) {
+               g_source_remove (cal->priv->reposition_timeout_id);
+               cal->priv->reposition_timeout_id = 0;
+       }
 
-       cancel_pending_reposition_timeout (object);
-       g_object_set_data (object, REPOSITION_TIMEOUT_KEY, GUINT_TO_POINTER (
-               g_timeout_add (1, e_calendar_reposition_timeout_cb, widget)));
+       cal->priv->reposition_timeout_id =
+               g_timeout_add (1, e_calendar_reposition_timeout_cb, widget);
 }
 
 void
@@ -580,11 +606,11 @@ e_calendar_set_minimum_size (ECalendar *cal,
 {
        g_return_if_fail (E_IS_CALENDAR (cal));
 
-       cal->min_rows = rows;
-       cal->min_cols = cols;
+       cal->priv->min_rows = rows;
+       cal->priv->min_cols = cols;
 
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (cal->calitem),
+               GNOME_CANVAS_ITEM (cal->priv->calitem),
                "minimum_rows", rows,
                "minimum_columns", cols,
                NULL);
@@ -599,11 +625,11 @@ e_calendar_set_maximum_size (ECalendar *cal,
 {
        g_return_if_fail (E_IS_CALENDAR (cal));
 
-       cal->max_rows = rows;
-       cal->max_cols = cols;
+       cal->priv->max_rows = rows;
+       cal->priv->max_cols = cols;
 
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (cal->calitem),
+               GNOME_CANVAS_ITEM (cal->priv->calitem),
                "maximum_rows", rows,
                "maximum_columns", cols,
                NULL);
@@ -667,14 +693,14 @@ static void
 e_calendar_start_auto_move (ECalendar *cal,
                             gboolean moving_forward)
 {
-       if (cal->timeout_id == 0) {
-               cal->timeout_id = e_named_timeout_add (
+       if (cal->priv->timeout_id == 0) {
+               cal->priv->timeout_id = e_named_timeout_add (
                        E_CALENDAR_AUTO_MOVE_TIMEOUT,
                        e_calendar_auto_move_handler, cal);
        }
 
-       cal->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY;
-       cal->moving_forward = moving_forward;
+       cal->priv->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY;
+       cal->priv->moving_forward = moving_forward;
 
 }
 
@@ -682,14 +708,14 @@ static void
 e_calendar_start_auto_move_year (ECalendar *cal,
                                  gboolean moving_forward)
 {
-       if (cal->timeout_id == 0) {
-               cal->timeout_id = e_named_timeout_add (
+       if (cal->priv->timeout_id == 0) {
+               cal->priv->timeout_id = e_named_timeout_add (
                        E_CALENDAR_AUTO_MOVE_TIMEOUT,
                        e_calendar_auto_move_year_handler, cal);
        }
 
-       cal->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY;
-       cal->moving_forward = moving_forward;
+       cal->priv->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY;
+       cal->priv->moving_forward = moving_forward;
 }
 
 static gboolean
@@ -702,12 +728,12 @@ e_calendar_auto_move_year_handler (gpointer data)
        g_return_val_if_fail (E_IS_CALENDAR (data), FALSE);
 
        cal = E_CALENDAR (data);
-       calitem = cal->calitem;
+       calitem = cal->priv->calitem;
 
-       if (cal->timeout_delay > 0) {
-               cal->timeout_delay--;
+       if (cal->priv->timeout_delay > 0) {
+               cal->priv->timeout_delay--;
        } else {
-               offset = cal->moving_forward ? 12 : -12;
+               offset = cal->priv->moving_forward ? 12 : -12;
                e_calendar_item_set_first_month (
                        calitem, calitem->year,
                        calitem->month + offset);
@@ -726,12 +752,12 @@ e_calendar_auto_move_handler (gpointer data)
        g_return_val_if_fail (E_IS_CALENDAR (data), FALSE);
 
        cal = E_CALENDAR (data);
-       calitem = cal->calitem;
+       calitem = cal->priv->calitem;
 
-       if (cal->timeout_delay > 0) {
-               cal->timeout_delay--;
+       if (cal->priv->timeout_delay > 0) {
+               cal->priv->timeout_delay--;
        } else {
-               offset = cal->moving_forward ? 1 : -1;
+               offset = cal->priv->moving_forward ? 1 : -1;
                e_calendar_item_set_first_month (
                        calitem, calitem->year,
                        calitem->month + offset);
@@ -767,9 +793,9 @@ e_calendar_on_next_year_released (ECalendar *cal)
 static void
 e_calendar_stop_auto_move (ECalendar *cal)
 {
-       if (cal->timeout_id != 0) {
-               g_source_remove (cal->timeout_id);
-               cal->timeout_id = 0;
+       if (cal->priv->timeout_id != 0) {
+               g_source_remove (cal->priv->timeout_id);
+               cal->priv->timeout_id = 0;
        }
 }
 
@@ -777,32 +803,32 @@ static void
 e_calendar_on_prev_clicked (ECalendar *cal)
 {
        e_calendar_item_set_first_month (
-               cal->calitem, cal->calitem->year,
-               cal->calitem->month - 1);
+               cal->priv->calitem, cal->priv->calitem->year,
+               cal->priv->calitem->month - 1);
 }
 
 static void
 e_calendar_on_next_clicked (ECalendar *cal)
 {
        e_calendar_item_set_first_month (
-               cal->calitem, cal->calitem->year,
-               cal->calitem->month + 1);
+               cal->priv->calitem, cal->priv->calitem->year,
+               cal->priv->calitem->month + 1);
 }
 
 static void
 e_calendar_on_prev_year_clicked (ECalendar *cal)
 {
        e_calendar_item_set_first_month (
-               cal->calitem, cal->calitem->year,
-               cal->calitem->month - 12);
+               cal->priv->calitem, cal->priv->calitem->year,
+               cal->priv->calitem->month - 12);
 }
 
 static void
 e_calendar_on_next_year_clicked (ECalendar *cal)
 {
        e_calendar_item_set_first_month (
-               cal->calitem, cal->calitem->year,
-               cal->calitem->month + 12);
+               cal->priv->calitem, cal->priv->calitem->year,
+               cal->priv->calitem->month + 12);
 }
 
 static gint
@@ -830,8 +856,8 @@ e_calendar_button_has_focus (ECalendar *cal)
 
        g_return_val_if_fail (E_IS_CALENDAR (cal), FALSE);
 
-       prev_widget = GNOME_CANVAS_WIDGET (cal->prev_item)->widget;
-       next_widget = GNOME_CANVAS_WIDGET (cal->next_item)->widget;
+       prev_widget = GNOME_CANVAS_WIDGET (cal->priv->prev_item)->widget;
+       next_widget = GNOME_CANVAS_WIDGET (cal->priv->next_item)->widget;
        ret_val = gtk_widget_has_focus (prev_widget) ||
                gtk_widget_has_focus (next_widget);
        return ret_val;
@@ -856,11 +882,11 @@ e_calendar_focus (GtkWidget *widget,
        if (!gtk_widget_get_can_focus (widget))
                return FALSE;
 
-       children[0] = GNOME_CANVAS_ITEM (cal->calitem);
-       children[1] = cal->prev_item;
-       children[2] = cal->next_item;
-       children[3] = cal->prev_item_year;
-       children[4] = cal->next_item_year;
+       children[0] = GNOME_CANVAS_ITEM (cal->priv->calitem);
+       children[1] = cal->priv->prev_item;
+       children[2] = cal->priv->next_item;
+       children[3] = cal->priv->prev_item_year;
+       children[4] = cal->priv->next_item_year;
 
        /* get current focused item, if e-calendar has had focus */
        if (gtk_widget_has_focus (widget) || e_calendar_button_has_focus (cal))
@@ -908,8 +934,8 @@ e_calendar_set_focusable (ECalendar *cal,
        g_return_if_fail (E_IS_CALENDAR (cal));
 
        widget = GTK_WIDGET (cal);
-       prev_widget = GNOME_CANVAS_WIDGET (cal->prev_item)->widget;
-       next_widget = GNOME_CANVAS_WIDGET (cal->next_item)->widget;
+       prev_widget = GNOME_CANVAS_WIDGET (cal->priv->prev_item)->widget;
+       next_widget = GNOME_CANVAS_WIDGET (cal->priv->next_item)->widget;
 
        if (focusable) {
                gtk_widget_set_can_focus (widget, TRUE);
diff --git a/e-util/e-calendar.h b/e-util/e-calendar.h
index 40ec4f8..60395e8 100644
--- a/e-util/e-calendar.h
+++ b/e-util/e-calendar.h
@@ -60,30 +60,13 @@ G_BEGIN_DECLS
        ((obj), E_TYPE_CALENDAR, ECalendarClass))
 
 typedef struct _ECalendar ECalendar;
-typedef struct _ECalendarClass  ECalendarClass;
+typedef struct _ECalendarClass ECalendarClass;
+typedef struct _ECalendarPrivate ECalendarPrivate;
 
 struct _ECalendar {
        ECanvas parent;
 
-       ECalendarItem *calitem;
-
-       GnomeCanvasItem *prev_item;
-       GnomeCanvasItem *next_item;
-       GnomeCanvasItem *prev_item_year;
-       GnomeCanvasItem *next_item_year;
-
-       gint min_rows;
-       gint min_cols;
-
-       gint max_rows;
-       gint max_cols;
-
-       /* These are all used when the prev/next buttons are held down.
-        * moving_forward is TRUE if we are moving forward in time, i.e. the
-        * next button is pressed. */
-       gint timeout_id;
-       gint timeout_delay;
-       gboolean moving_forward;
+       ECalendarPrivate *priv;
 };
 
 struct _ECalendarClass {
@@ -92,6 +75,7 @@ struct _ECalendarClass {
 
 GType          e_calendar_get_type             (void) G_GNUC_CONST;
 GtkWidget *    e_calendar_new                  (void);
+ECalendarItem *        e_calendar_get_item             (ECalendar *cal);
 void           e_calendar_set_minimum_size     (ECalendar *cal,
                                                 gint rows,
                                                 gint cols);
diff --git a/e-util/e-cell-date-edit.c b/e-util/e-cell-date-edit.c
index 4d5f5b2..a1abd55 100644
--- a/e-util/e-cell-date-edit.c
+++ b/e-util/e-cell-date-edit.c
@@ -239,7 +239,7 @@ e_cell_date_edit_init (ECellDateEdit *ecde)
 
        ecde->calendar = e_calendar_new ();
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (E_CALENDAR (ecde->calendar)->calitem),
+               GNOME_CANVAS_ITEM (e_calendar_get_item (E_CALENDAR (ecde->calendar))),
                "move_selection_when_moving", FALSE,
                NULL);
        gtk_box_pack_start (GTK_BOX (hbox), ecde->calendar, TRUE, TRUE, 0);
@@ -534,7 +534,7 @@ e_cell_date_edit_set_popup_values (ECellDateEdit *ecde)
 
        /* If there is no date and time set, or the date is invalid, we clear
         * the selections, else we select the appropriate date & time. */
-       calitem = E_CALENDAR_ITEM (E_CALENDAR (ecde->calendar)->calitem);
+       calitem = E_CALENDAR_ITEM (e_calendar_get_item (E_CALENDAR (ecde->calendar)));
        if (status == E_TIME_PARSE_NONE || status == E_TIME_PARSE_INVALID) {
                gtk_entry_set_text (GTK_ENTRY (ecde->time_entry), "");
                e_calendar_item_set_selection (calitem, NULL, NULL);
@@ -820,7 +820,7 @@ e_cell_date_edit_on_ok_clicked (GtkWidget *button,
        ETimeParseStatus status;
        gboolean is_date = FALSE;
 
-       calitem = E_CALENDAR_ITEM (E_CALENDAR (ecde->calendar)->calitem);
+       calitem = E_CALENDAR_ITEM (e_calendar_get_item (E_CALENDAR (ecde->calendar)));
        day_selected = e_calendar_item_get_selection (
                calitem, &start_date, &end_date);
 
diff --git a/e-util/e-dateedit.c b/e-util/e-dateedit.c
index 8f9e615..6b08132 100644
--- a/e-util/e-dateedit.c
+++ b/e-util/e-dateedit.c
@@ -683,13 +683,13 @@ create_children (EDateEdit *dedit)
        priv->calendar = e_calendar_new ();
        calendar = E_CALENDAR (priv->calendar);
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (calendar->calitem),
+               GNOME_CANVAS_ITEM (e_calendar_get_item (calendar)),
                "maximum_days_selected", 1,
                "move_selection_when_moving", FALSE,
                NULL);
 
        g_signal_connect (
-               calendar->calitem, "selection_changed",
+               e_calendar_get_item (calendar), "selection_changed",
                G_CALLBACK (on_date_popup_date_selected), dedit);
 
        gtk_box_pack_start (GTK_BOX (vbox), priv->calendar, FALSE, FALSE, 0);
@@ -1225,7 +1225,7 @@ e_date_edit_get_week_start_day (EDateEdit *dedit)
        g_return_val_if_fail (E_IS_DATE_EDIT (dedit), 1);
 
        g_object_get (
-               E_CALENDAR (dedit->priv->calendar)->calitem,
+               e_calendar_get_item (E_CALENDAR (dedit->priv->calendar)),
                "week-start-day", &week_start_day, NULL);
 
        return week_start_day;
@@ -1246,7 +1246,7 @@ e_date_edit_set_week_start_day (EDateEdit *dedit,
        g_return_if_fail (g_date_valid_weekday (week_start_day));
 
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (E_CALENDAR (dedit->priv->calendar)->calitem),
+               GNOME_CANVAS_ITEM (e_calendar_get_item (E_CALENDAR (dedit->priv->calendar))),
                "week-start-day", week_start_day, NULL);
 
        g_object_notify (G_OBJECT (dedit), "week-start-day");
@@ -1261,7 +1261,7 @@ e_date_edit_get_show_week_numbers (EDateEdit *dedit)
        g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
 
        g_object_get (
-               E_CALENDAR (dedit->priv->calendar)->calitem,
+               e_calendar_get_item (E_CALENDAR (dedit->priv->calendar)),
                "show_week_numbers", &show_week_numbers, NULL);
 
        return show_week_numbers;
@@ -1274,7 +1274,7 @@ e_date_edit_set_show_week_numbers (EDateEdit *dedit,
        g_return_if_fail (E_IS_DATE_EDIT (dedit));
 
        gnome_canvas_item_set (
-               GNOME_CANVAS_ITEM (E_CALENDAR (dedit->priv->calendar)->calitem),
+               GNOME_CANVAS_ITEM (e_calendar_get_item (E_CALENDAR (dedit->priv->calendar))),
                "show_week_numbers", show_week_numbers, NULL);
 
        g_object_notify (G_OBJECT (dedit), "show-week-numbers");
@@ -1423,20 +1423,20 @@ e_date_edit_show_date_popup (EDateEdit *dedit,
                clear_selection = TRUE;
 
        if (clear_selection) {
-               e_calendar_item_set_selection (calendar->calitem, NULL, NULL);
+               e_calendar_item_set_selection (e_calendar_get_item (calendar), NULL, NULL);
        } else {
                g_date_clear (&selected_day, 1);
                g_date_set_dmy (
                        &selected_day, mtm.tm_mday, mtm.tm_mon + 1,
                        mtm.tm_year + 1900);
                e_calendar_item_set_selection (
-                       calendar->calitem,
+                       e_calendar_get_item (calendar),
                        &selected_day, NULL);
        }
 
        /* FIXME: Hack. Change ECalendarItem so it doesn't queue signal
         * emissions. */
-       calendar->calitem->selection_changed = FALSE;
+       e_calendar_get_item (calendar)->selection_changed = FALSE;
 
        position_date_popup (dedit);
        gtk_widget_show (priv->cal_popup);
diff --git a/e-util/test-calendar.c b/e-util/test-calendar.c
index da3f661..2a64a4f 100644
--- a/e-util/test-calendar.c
+++ b/e-util/test-calendar.c
@@ -73,7 +73,7 @@ main (gint argc,
 
        cal = e_calendar_new ();
        e_calendar_set_minimum_size (E_CALENDAR (cal), 1, 1);
-       calitem = E_CALENDAR (cal)->calitem;
+       calitem = e_calendar_get_item (E_CALENDAR (cal));
        gtk_widget_show (cal);
 
        g_signal_connect (
diff --git a/modules/calendar/e-cal-base-shell-sidebar.c b/modules/calendar/e-cal-base-shell-sidebar.c
index dc81a7e..da10449 100644
--- a/modules/calendar/e-cal-base-shell-sidebar.c
+++ b/modules/calendar/e-cal-base-shell-sidebar.c
@@ -244,7 +244,7 @@ cal_base_shell_sidebar_date_navigator_scroll_event_cb (ECalBaseShellSidebar *cal
        gint year = -1, month = -1;
        GdkScrollDirection direction;
 
-       calitem = date_navigator->calitem;
+       calitem = e_calendar_get_item (date_navigator);
        e_calendar_item_get_first_month (calitem, &year, &month);
        if (year == -1 || month == -1)
                return FALSE;
@@ -748,7 +748,7 @@ cal_base_shell_sidebar_constructed (GObject *object)
                gtk_widget_set_margin_start (widget, 6);
                gtk_widget_set_margin_end (widget, 6);
                #endif
-               calitem = E_CALENDAR (widget)->calitem;
+               calitem = e_calendar_get_item (E_CALENDAR (widget));
                e_calendar_item_set_days_start_week_sel (calitem, 9);
                e_calendar_item_set_max_days_sel (calitem, 42);
                gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
@@ -756,7 +756,7 @@ cal_base_shell_sidebar_constructed (GObject *object)
                gtk_widget_show (widget);
 
                gnome_canvas_item_set (
-                       GNOME_CANVAS_ITEM (cal_base_shell_sidebar->priv->date_navigator->calitem),
+                       GNOME_CANVAS_ITEM (e_calendar_get_item 
(cal_base_shell_sidebar->priv->date_navigator)),
                        "move-selection-when-moving", FALSE,
                        NULL);
 
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index 82e850d..35a58fb 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -383,5 +383,5 @@ e_cal_shell_backend_open_date_range (ECalShellBackend *cal_shell_backend,
        shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
        calendar = e_cal_base_shell_sidebar_get_date_navigator (E_CAL_BASE_SHELL_SIDEBAR (shell_sidebar));
 
-       e_calendar_item_set_selection (calendar->calitem, start_date, end_date);
+       e_calendar_item_set_selection (e_calendar_get_item (calendar), start_date, end_date);
 }
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 740ba42..114ab8d 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -281,11 +281,11 @@ e_cal_shell_content_change_view (ECalShellContent *cal_shell_content,
            g_date_valid (&cal_shell_content->priv->view_end) &&
            g_date_compare (&cal_shell_content->priv->view_start, view_start) == 0 &&
            g_date_compare (&cal_shell_content->priv->view_end, view_end) == 0) {
-               ECalendarItem *calitem = calendar->calitem;
+               ECalendarItem *calitem = e_calendar_get_item (calendar);
 
                if (view_changed)
                        cal_shell_content_update_model_and_current_view_times (
-                               cal_shell_content, model, calendar->calitem, view_start_tt, view_end_tt, 
view_start, view_end);
+                               cal_shell_content, model, calitem, view_start_tt, view_end_tt, view_start, 
view_end);
 
                g_signal_handler_block (calitem, cal_shell_content->priv->datepicker_range_moved_id);
                g_signal_handler_block (calitem, cal_shell_content->priv->datepicker_selection_changed_id);
@@ -302,7 +302,7 @@ e_cal_shell_content_change_view (ECalShellContent *cal_shell_content,
        cal_shell_content->priv->view_end = *view_end;
 
        cal_shell_content_update_model_and_current_view_times (
-               cal_shell_content, model, calendar->calitem, view_start_tt, view_end_tt, view_start, 
view_end);
+               cal_shell_content, model, e_calendar_get_item (calendar), view_start_tt, view_end_tt, 
view_start, view_end);
 }
 
 static void
@@ -555,7 +555,7 @@ cal_shell_content_datepicker_button_press_cb (ECalendar *calendar,
                return FALSE;
 
        if (event->type == GDK_2BUTTON_PRESS) {
-               ECalendarItem *calitem = calendar->calitem;
+               ECalendarItem *calitem = e_calendar_get_item (calendar);
                GDate sel_start, sel_end;
 
                g_date_clear (&sel_start, 1);
@@ -1275,7 +1275,7 @@ cal_shell_content_view_created (ECalBaseShellContent *cal_base_shell_content)
        g_return_if_fail (E_IS_CALENDAR (calendar));
 
        model = e_cal_base_shell_content_get_model (E_CAL_BASE_SHELL_CONTENT (cal_shell_content));
-       e_calendar_item_set_selection (calendar->calitem, &date, &date);
+       e_calendar_item_set_selection (e_calendar_get_item (calendar), &date, &date);
        e_cal_model_set_time_range (model, today, today);
 
        /* Show everything known by default in the task and memo pads */
@@ -1283,10 +1283,10 @@ cal_shell_content_view_created (ECalBaseShellContent *cal_base_shell_content)
        e_cal_model_set_time_range (cal_shell_content->priv->task_model, 0, 0);
 
        cal_shell_content->priv->datepicker_selection_changed_id =
-               g_signal_connect (calendar->calitem, "selection-changed",
+               g_signal_connect (e_calendar_get_item (calendar), "selection-changed",
                G_CALLBACK (cal_shell_content_datepicker_selection_changed_cb), cal_shell_content);
        cal_shell_content->priv->datepicker_range_moved_id =
-               g_signal_connect (calendar->calitem, "date-range-moved",
+               g_signal_connect (e_calendar_get_item (calendar), "date-range-moved",
                G_CALLBACK (cal_shell_content_datepicker_range_moved_cb), cal_shell_content);
 
        g_signal_connect_after (calendar, "button-press-event",
@@ -2141,7 +2141,7 @@ e_cal_shell_content_move_view_range (ECalShellContent *cal_shell_content,
 
        calendar = e_cal_base_shell_sidebar_get_date_navigator (E_CAL_BASE_SHELL_SIDEBAR (shell_sidebar));
        g_return_if_fail (E_IS_CALENDAR (calendar));
-       g_return_if_fail (calendar->calitem != NULL);
+       g_return_if_fail (e_calendar_get_item (calendar) != NULL);
 
        data_model = e_cal_base_shell_content_get_data_model (E_CAL_BASE_SHELL_CONTENT (cal_shell_content));
        zone = e_cal_data_model_get_timezone (data_model);
@@ -2157,7 +2157,7 @@ e_cal_shell_content_move_view_range (ECalShellContent *cal_shell_content,
                        tt = icaltime_current_time_with_zone (zone);
                        g_date_set_dmy (&date, tt.day, tt.month, tt.year);
                        /* one-day selection takes care of the view range move with left view kind */
-                       e_calendar_item_set_selection (calendar->calitem, &date, &date);
+                       e_calendar_item_set_selection (e_calendar_get_item (calendar), &date, &date);
                        break;
                case E_CALENDAR_VIEW_MOVE_TO_EXACT_DAY:
                        time_to_gdate_with_zone (&date, exact_date, zone);
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index a2df5cb..419c16d 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -346,7 +346,7 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view)
                cal_shell_view);
 
        e_calendar_item_set_get_time_callback (
-               calendar->calitem, (ECalendarItemGetTimeCallback)
+               e_calendar_get_item (calendar), (ECalendarItemGetTimeCallback)
                cal_shell_view_get_current_time, cal_shell_view, NULL);
 
        init_timezone_monitors (cal_shell_view);
@@ -706,8 +706,8 @@ cal_searching_check_candidates (ECalShellView *cal_shell_view)
                        GDate *dt;
 
                        dt = g_date_new_dmy (tt.day, tt.month, tt.year);
-                       e_calendar_item_set_selection (calendar->calitem, dt, dt);
-                       g_signal_emit_by_name (calendar->calitem, "selection-changed", 0);
+                       e_calendar_item_set_selection (e_calendar_get_item (calendar), dt, dt);
+                       g_signal_emit_by_name (e_calendar_get_item (calendar), "selection-changed", 0);
                        g_date_free (dt);
 
                        cal_view = e_cal_shell_content_get_current_calendar_view 
(cal_shell_view->priv->cal_shell_content);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]