aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-08-13 04:43:04 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-08-13 06:30:19 +0800
commit88aa930c58ad27858453a2109cc899f34df21056 (patch)
treea21905314aaca29dd2c17c4f4954995f6071b3c3
parent6575bf9d46f183b553885b5a47c206255f45bed6 (diff)
downloadgsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.tar
gsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.tar.gz
gsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.tar.bz2
gsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.tar.lz
gsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.tar.xz
gsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.tar.zst
gsoc2013-evolution-88aa930c58ad27858453a2109cc899f34df21056.zip
Make switching between calendar views work.
-rw-r--r--calendar/gui/gnome-cal.c127
-rw-r--r--calendar/gui/gnome-cal.h2
-rw-r--r--modules/calendar/e-cal-shell-content.c33
-rw-r--r--modules/calendar/e-cal-shell-view-private.c9
-rw-r--r--modules/calendar/e-cal-shell-view.c9
-rw-r--r--modules/calendar/e-cal-shell-view.h3
6 files changed, 91 insertions, 92 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index d288e49b7f..5bb6b81c70 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -150,6 +150,7 @@ enum {
PROP_0,
PROP_DATE_NAVIGATOR,
PROP_SHELL_SETTINGS,
+ PROP_VIEW,
PROP_WEEK_START_DAY
};
@@ -358,6 +359,12 @@ gnome_calendar_set_property (GObject *object,
g_value_get_object (value));
return;
+ case PROP_VIEW:
+ gnome_calendar_set_view (
+ GNOME_CALENDAR (object),
+ g_value_get_int (value));
+ return;
+
case PROP_WEEK_START_DAY:
gnome_calendar_set_week_start_day (
GNOME_CALENDAR (object),
@@ -387,6 +394,12 @@ gnome_calendar_get_property (GObject *object,
GNOME_CALENDAR (object)));
return;
+ case PROP_VIEW:
+ g_value_set_int (
+ value, gnome_calendar_get_view (
+ GNOME_CALENDAR (object)));
+ return;
+
case PROP_WEEK_START_DAY:
g_value_set_int (
value, gnome_calendar_get_week_start_day (
@@ -541,6 +554,18 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
g_object_class_install_property (
object_class,
+ PROP_VIEW,
+ g_param_spec_int (
+ "view",
+ "View",
+ NULL,
+ GNOME_CAL_DAY_VIEW,
+ GNOME_CAL_LIST_VIEW,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
PROP_WEEK_START_DAY,
g_param_spec_int (
"week-start-day",
@@ -1126,12 +1151,12 @@ gnome_calendar_set_search_query (GnomeCalendar *gcal,
/* Set the query on the views */
if (i == GNOME_CAL_LIST_VIEW) {
if (!priv->lview_select_daten_range) {
- e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views [i]), sexp, start, end);
+ e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views[i]), sexp, start, end);
} else {
start = priv->base_view_time;
get_times_for_views (gcal, GNOME_CAL_LIST_VIEW, &start, &end, NULL);
- e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views [i]), sexp, start, end);
+ e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views[i]), sexp, start, end);
if (priv->current_view_type == GNOME_CAL_LIST_VIEW)
gnome_calendar_update_date_navigator (gcal);
@@ -1596,7 +1621,7 @@ update_view_times (GnomeCalendar *gcal, time_t start_time)
priv->base_view_time = start_time;
- model = e_calendar_view_get_model (priv->views [priv->current_view_type]);
+ model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
get_times_for_views (gcal, priv->current_view_type, &real_start_time, &end_time, &select_time);
if (priv->current_view_type == GNOME_CAL_LIST_VIEW && !priv->lview_select_daten_range)
@@ -1605,7 +1630,7 @@ update_view_times (GnomeCalendar *gcal, time_t start_time)
e_cal_model_set_time_range (model, real_start_time, end_time);
if (select_time != 0 && select_time >= real_start_time && select_time <= end_time)
- e_calendar_view_set_selected_time_range (priv->views [priv->current_view_type], select_time, select_time);
+ e_calendar_view_set_selected_time_range (priv->views[priv->current_view_type], select_time, select_time);
}
static void
@@ -1700,44 +1725,17 @@ gnome_calendar_get_view (GnomeCalendar *gcal)
static void
set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_selected)
{
- GnomeCalendarPrivate *priv;
ECalendarView *view;
- const gchar *view_id;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- priv = gcal->priv;
-
- switch (view_type) {
- case GNOME_CAL_DAY_VIEW:
- view_id = "Day_View";
- break;
-
- case GNOME_CAL_WORK_WEEK_VIEW:
- view_id = "Work_Week_View";
- break;
-
- case GNOME_CAL_WEEK_VIEW:
- view_id = "Week_View";
- break;
-
- case GNOME_CAL_MONTH_VIEW:
- view_id = "Month_View";
- break;
-
- case GNOME_CAL_LIST_VIEW:
- view_id = "List_View";
- break;
-
- default:
- g_return_if_reached ();
- }
-
- priv->range_selected = range_selected;
- priv->current_view_type = view_type;
+ gcal->priv->range_selected = range_selected;
+ gcal->priv->current_view_type = view_type;
view = gnome_calendar_get_calendar_view (gcal, view_type);
gtk_widget_grab_focus (GTK_WIDGET (view));
+
+ g_object_notify (G_OBJECT (gcal), "view");
}
/**
@@ -1766,39 +1764,16 @@ gnome_calendar_change_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type
gnome_calendar_set_view(gcal, view_type);
}
-/* Callback used when the view collection asks us to display a particular view */
-#if 0 /* KILL-BONOBO */
-static void
-display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
+void
+gnome_calendar_display_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type)
{
- GnomeCalendar *gcal;
- GnomeCalendarPrivate *priv;
CalendarView *cal_view;
- GnomeCalendarViewType view_type;
ECalendarView *view;
gboolean preserve_day;
time_t start_time;
gint ii;
- gcal = GNOME_CALENDAR (data);
- priv = gcal->priv;
-
- if (GAL_IS_VIEW_ETABLE(view)) {
- ETable *table;
-
- view_type = GNOME_CAL_LIST_VIEW;
-
- table = e_table_scrolled_get_table (E_CAL_LIST_VIEW (priv->list_view)->table_scrolled);
- gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), table);
- } else if (IS_CALENDAR_VIEW (view)) {
- cal_view = CALENDAR_VIEW (view);
-
- view_type = calendar_view_get_view_type (cal_view);
- } else {
- g_error (G_STRLOC ": Unknown type of view for GnomeCalendar");
- return;
- }
-
view = gnome_calendar_get_calendar_view (gcal, view_type);
/* Set the view without changing the selection or updating the date
@@ -1810,7 +1785,7 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
switch (view_type) {
case GNOME_CAL_DAY_VIEW:
- if (!priv->range_selected)
+ if (!gcal->priv->range_selected)
e_day_view_set_days_shown (E_DAY_VIEW (view), 1);
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
@@ -1827,7 +1802,7 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
break;
case GNOME_CAL_MONTH_VIEW:
- if (!priv->range_selected)
+ if (!gcal->priv->range_selected)
e_week_view_set_weeks_shown (E_WEEK_VIEW (view), 6);
preserve_day = TRUE;
@@ -1835,7 +1810,7 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
break;
case GNOME_CAL_LIST_VIEW:
- if (!priv->lview_select_daten_range)
+ if (!gcal->priv->lview_select_daten_range)
gtk_widget_hide (GTK_WIDGET (gcal->priv->date_navigator));
else
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
@@ -1845,33 +1820,31 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
g_return_if_reached ();
}
- priv->current_view_type = view_type;
- E_CALENDAR_VIEW (priv->views [view_type])->in_focus = TRUE;
+ set_view (gcal, view_type, gcal->priv->range_selected);
- for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
- if (i == view_type)
+ /* XXX Move this to set_view()? */
+ E_CALENDAR_VIEW (gcal->priv->views[view_type])->in_focus = TRUE;
+ for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++) {
+ if (ii == view_type)
continue;
- E_CALENDAR_VIEW (priv->views [i])->in_focus = FALSE;
+ E_CALENDAR_VIEW (gcal->priv->views[ii])->in_focus = FALSE;
}
- gtk_widget_grab_focus (GTK_WIDGET (view));
-
/* For the week & month views we want the selection in the date
navigator to be rounded to the nearest week when the arrow buttons
are pressed to move to the previous/next month. */
- g_object_set (G_OBJECT (priv->date_navigator->calitem),
- "preserve_day_when_moving", preserve_day,
- NULL);
+ g_object_set (
+ gcal->priv->date_navigator->calitem,
+ "preserve_day_when_moving", preserve_day, NULL);
- if (!priv->base_view_time)
+ if (!gcal->priv->base_view_time)
start_time = time (NULL);
else
- start_time = priv->base_view_time;
+ start_time = gcal->priv->base_view_time;
gnome_calendar_set_selected_time_range (gcal, start_time);
}
-#endif
struct _mclient_msg {
Message header;
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index bb696d436b..a9dda216f0 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -138,6 +138,8 @@ void gnome_calendar_goto_today (GnomeCalendar *gcal);
GnomeCalendarViewType gnome_calendar_get_view (GnomeCalendar *gcal);
void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type);
+void gnome_calendar_display_view (GnomeCalendar *gcal,
+ GnomeCalendarViewType view_type);
struct _ECalendarView *gnome_calendar_get_calendar_view (GnomeCalendar *gcal,
GnomeCalendarViewType view_type);
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 4409c1fc08..eccd146ba6 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -74,7 +74,6 @@ cal_shell_content_display_view_cb (ECalShellContent *cal_shell_content,
GalView *gal_view)
{
GnomeCalendar *calendar;
- CalendarView *gal_calendar_view;
GnomeCalendarViewType view_type;
/* XXX This is confusing: we have CalendarView and ECalendarView.
@@ -99,6 +98,8 @@ cal_shell_content_display_view_cb (ECalShellContent *cal_shell_content,
view_type = calendar_view_get_view_type (
CALENDAR_VIEW (gal_view));
}
+
+ gnome_calendar_display_view (calendar, view_type);
}
static void
@@ -389,6 +390,10 @@ cal_shell_content_constructed (GObject *object)
gtk_widget_show (GTK_WIDGET (calendar_view));
}
+ e_binding_new (
+ G_OBJECT (priv->calendar), "view",
+ G_OBJECT (priv->notebook), "page");
+
container = priv->vpaned;
widget = gtk_vbox_new (FALSE, 0);
@@ -448,7 +453,8 @@ cal_shell_content_constructed (GObject *object)
view_instance, "display-view",
G_CALLBACK (cal_shell_content_display_view_cb),
object);
- gal_view_instance_load (view_instance);
+ /* XXX Actually, don't load the view instance just yet.
+ * The GtkWidget::map() callback below explains why. */
priv->view_instance = view_instance;
g_signal_connect_swapped (
@@ -469,9 +475,29 @@ cal_shell_content_constructed (GObject *object)
}
static void
+cal_shell_content_map (GtkWidget *widget)
+{
+ ECalShellContentPrivate *priv;
+ GalViewInstance *view_instance;
+
+ /* XXX Delay loading the GalViewInstance until after ECalShellView
+ * has a chance to install the sidebar's date navigator into
+ * GnomeCalendar, since loading the GalViewInstance triggers a
+ * callback in GnomeCalendar that requires the date navigator.
+ * Ordinarily we would do this at the end of constructed(), but
+ * that's too soon in this case. (This feels kind of kludgy.) */
+ priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (widget);
+ gal_view_instance_load (priv->view_instance);
+
+ /* Chain up to parent's map() method. */
+ GTK_WIDGET_CLASS (parent_class)->map (widget);
+}
+
+static void
cal_shell_content_class_init (ECalShellContentClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (ECalShellContentPrivate));
@@ -482,6 +508,9 @@ cal_shell_content_class_init (ECalShellContentClass *class)
object_class->dispose = cal_shell_content_dispose;
object_class->finalize = cal_shell_content_finalize;
object_class->constructed = cal_shell_content_constructed;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->map = cal_shell_content_map;
}
static void
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 063e7461ed..60ec3c77ab 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -368,6 +368,11 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view)
e_cal_shell_view_update_sidebar (cal_shell_view);
e_cal_shell_view_update_search_filter (cal_shell_view);
e_cal_shell_view_update_timezone (cal_shell_view);
+
+ /* Keep the toolbar view buttons in sync with the calendar. */
+ e_mutual_binding_new (
+ G_OBJECT (calendar), "view",
+ G_OBJECT (ACTION (CALENDAR_VIEW_DAY)), "current-value");
}
void
@@ -658,6 +663,7 @@ e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view)
{
EShellView *shell_view;
EShellSidebar *shell_sidebar;
+ ECalShellContent *cal_shell_content;
GnomeCalendar *calendar;
GnomeCalendarViewType view;
time_t start_time, end_time;
@@ -672,7 +678,8 @@ e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view)
shell_view = E_SHELL_VIEW (cal_shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
- calendar = e_cal_shell_view_get_calendar (cal_shell_view);
+ cal_shell_content = cal_shell_view->priv->cal_shell_content;
+ calendar = e_cal_shell_content_get_calendar (cal_shell_content);
gnome_calendar_get_visible_time_range (
calendar, &start_time, &end_time);
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index 2c977e7553..d9d21799b9 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -217,12 +217,3 @@ e_cal_shell_view_register_type (GTypeModule *type_module)
type_module, E_TYPE_SHELL_VIEW,
"ECalShellView", &type_info, 0);
}
-
-GnomeCalendar *
-e_cal_shell_view_get_calendar (ECalShellView *cal_shell_view)
-{
- g_return_val_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view), NULL);
-
- /* FIXME */
- return NULL;
-}
diff --git a/modules/calendar/e-cal-shell-view.h b/modules/calendar/e-cal-shell-view.h
index 67fa15220c..0cd7382012 100644
--- a/modules/calendar/e-cal-shell-view.h
+++ b/modules/calendar/e-cal-shell-view.h
@@ -23,8 +23,6 @@
#define E_CAL_SHELL_VIEW_H
#include <shell/e-shell-view.h>
-#include <calendar/gui/gnome-cal.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_CAL_SHELL_VIEW \
@@ -62,7 +60,6 @@ struct _ECalShellViewClass {
GType e_cal_shell_view_get_type (void);
void e_cal_shell_view_register_type (GTypeModule *type_module);
-GnomeCalendar * e_cal_shell_view_get_calendar (ECalShellView *cal_shell_view);
G_END_DECLS