aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/modules/e-cal-shell-sidebar.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/modules/e-cal-shell-sidebar.c')
-rw-r--r--calendar/modules/e-cal-shell-sidebar.c147
1 files changed, 7 insertions, 140 deletions
diff --git a/calendar/modules/e-cal-shell-sidebar.c b/calendar/modules/e-cal-shell-sidebar.c
index 5d14f589f0..10d6f30c05 100644
--- a/calendar/modules/e-cal-shell-sidebar.c
+++ b/calendar/modules/e-cal-shell-sidebar.c
@@ -22,15 +22,12 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-data-server-util.h>
-#include <libedataserverui/e-source-selector.h>
-#include <e-util/e-util.h>
+#include "e-util/e-util.h"
+#include "calendar/gui/gnome-cal.h"
+#include "calendar/gui/e-calendar-selector.h"
-#include <gnome-cal.h>
-#include <e-cal-shell-view.h>
-#include <e-calendar-selector.h>
+#include "e-cal-shell-view.h"
#define E_CAL_SHELL_SIDEBAR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -48,127 +45,6 @@ enum {
static gpointer parent_class;
static void
-cal_shell_sidebar_update (EShellSidebar *shell_sidebar)
-{
- EShellView *shell_view;
- GnomeCalendar *calendar;
- GnomeCalendarViewType view;
- time_t start_time, end_time;
- struct tm start_tm, end_tm;
- struct icaltimetype start_tt, end_tt;
- icaltimezone *timezone;
- gchar buffer[512];
- gchar end_buffer[512];
-
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- calendar = e_cal_shell_view_get_calendar (
- E_CAL_SHELL_VIEW (shell_view));
-
- gnome_calendar_get_visible_time_range (
- calendar, &start_time, &end_time);
- timezone = gnome_calendar_get_timezone (calendar);
- view = gnome_calendar_get_view (calendar);
-
- start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone);
- start_tm.tm_year = start_tt.year - 1900;
- start_tm.tm_mon = start_tt.month - 1;
- start_tm.tm_mday = start_tt.day;
- start_tm.tm_hour = start_tt.hour;
- start_tm.tm_min = start_tt.minute;
- start_tm.tm_sec = start_tt.second;
- start_tm.tm_isdst = -1;
- start_tm.tm_wday = time_day_of_week (
- start_tt.day, start_tt.month - 1, start_tt.year);
-
- /* Subtract one from end_time so we don't get an extra day. */
- end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, timezone);
- end_tm.tm_year = end_tt.year - 1900;
- end_tm.tm_mon = end_tt.month - 1;
- end_tm.tm_mday = end_tt.day;
- end_tm.tm_hour = end_tt.hour;
- end_tm.tm_min = end_tt.minute;
- end_tm.tm_sec = end_tt.second;
- end_tm.tm_isdst = -1;
- end_tm.tm_wday = time_day_of_week (
- end_tt.day, end_tt.month - 1, end_tt.year);
-
- switch (view) {
- case GNOME_CAL_DAY_VIEW:
- case GNOME_CAL_WORK_WEEK_VIEW:
- case GNOME_CAL_WEEK_VIEW:
- if (start_tm.tm_year == end_tm.tm_year &&
- start_tm.tm_mon == end_tm.tm_mon &&
- start_tm.tm_mday == end_tm.tm_mday) {
- e_utf8_strftime (
- buffer, sizeof (buffer),
- _("%A %d %b %Y"), &start_tm);
- } else if (start_tm.tm_year == end_tm.tm_year) {
- e_utf8_strftime (
- buffer, sizeof (buffer),
- _("%a %d %b"), &start_tm);
- e_utf8_strftime (
- end_buffer, sizeof (end_buffer),
- _("%a %d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- } else {
- e_utf8_strftime (
- buffer, sizeof (buffer),
- _("%a %d %b %Y"), &start_tm);
- e_utf8_strftime (
- end_buffer, sizeof (end_buffer),
- _("%a %d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- }
- break;
-
- case GNOME_CAL_MONTH_VIEW:
- case GNOME_CAL_LIST_VIEW:
- if (start_tm.tm_year == end_tm.tm_year) {
- if (start_tm.tm_mon == end_tm.tm_mon) {
- e_utf8_strftime (
- buffer,
- sizeof (buffer),
- "%d", &start_tm);
- e_utf8_strftime (
- end_buffer,
- sizeof (end_buffer),
- _("%d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- } else {
- e_utf8_strftime (
- buffer,
- sizeof (buffer),
- _("%d %b"), &start_tm);
- e_utf8_strftime (
- end_buffer,
- sizeof (end_buffer),
- _("%d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- }
- } else {
- e_utf8_strftime (
- buffer, sizeof (buffer),
- _("%d %b %Y"), &start_tm);
- e_utf8_strftime (
- end_buffer, sizeof (end_buffer),
- _("%d %b %Y"), &end_tm);
- strcat (buffer, " - ");
- strcat (buffer, end_buffer);
- }
- break;
-
- default:
- g_return_if_reached ();
- }
-
- e_shell_sidebar_set_secondary_text (shell_sidebar, buffer);
-}
-
-static void
cal_shell_sidebar_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -211,10 +87,12 @@ cal_shell_sidebar_constructed (GObject *object)
ESourceList *source_list;
GtkContainer *container;
GtkWidget *widget;
- GnomeCalendar *calendar;
priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object);
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
shell_sidebar = E_SHELL_SIDEBAR (object);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
cal_shell_view = E_CAL_SHELL_VIEW (shell_view);
@@ -238,17 +116,6 @@ cal_shell_sidebar_constructed (GObject *object)
gtk_container_add (container, widget);
priv->selector = g_object_ref (widget);
gtk_widget_show (widget);
-
- /* Setup signal handlers. */
-
- calendar = e_cal_shell_view_get_calendar (cal_shell_view);
-
- g_signal_connect_swapped (
- calendar, "dates-shown-changed",
- G_CALLBACK (cal_shell_sidebar_update),
- shell_sidebar);
-
- cal_shell_sidebar_update (shell_sidebar);
}
static void