diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-30 04:11:07 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-30 04:11:07 +0800 |
commit | d6b8b58bb45b16c1cb3a575c277ffdc77441e2df (patch) | |
tree | c80db345f4d3e05a1ee165b40c561f2649e574cb /calendar | |
parent | 5e82bdba14fba81603f3879a46b46a011db7d2e4 (diff) | |
download | gsoc2013-evolution-d6b8b58bb45b16c1cb3a575c277ffdc77441e2df.tar.gz gsoc2013-evolution-d6b8b58bb45b16c1cb3a575c277ffdc77441e2df.tar.zst gsoc2013-evolution-d6b8b58bb45b16c1cb3a575c277ffdc77441e2df.zip |
Get the calendar's memopad and taskpad working.
What's interesting here is we're actually sharing the ECalModel across views.
Instead of having the Calendar view listen to GConf for changes to the Task
and Memo models, the Calendar view fetches the models directly from the Task
and Memo views -- starting the views if it has to, although the shell really
takes care of that -- and loads the models into its own taskpad and memopad.
We couldn't do that sort of thing before with Bonobo in the way.
Big chunks of redundant code should begin falling out shortly.
svn path=/branches/kill-bonobo/; revision=36696
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/e-cal-model-memos.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-cal-model-memos.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-cal-model-tasks.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-cal-model-tasks.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 264 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.h | 6 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 259 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.h | 6 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-content.c | 24 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-view-memopad.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-view-private.c | 96 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-view-private.h | 4 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-view-taskpad.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-content.c | 59 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-content.h | 2 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-content.c | 59 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-content.h | 3 |
17 files changed, 519 insertions, 275 deletions
diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c index ffb1c8a488..07df7c7460 100644 --- a/calendar/gui/e-cal-model-memos.c +++ b/calendar/gui/e-cal-model-memos.c @@ -261,7 +261,7 @@ ecmm_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data, /** * e_cal_model_memos_new */ -ECalModelMemos * +ECalModel * e_cal_model_memos_new (void) { return g_object_new (E_TYPE_CAL_MODEL_MEMOS, NULL); diff --git a/calendar/gui/e-cal-model-memos.h b/calendar/gui/e-cal-model-memos.h index 5417c9c09b..d02e51c9f7 100644 --- a/calendar/gui/e-cal-model-memos.h +++ b/calendar/gui/e-cal-model-memos.h @@ -55,8 +55,8 @@ typedef struct { ECalModelClass parent_class; } ECalModelMemosClass; -GType e_cal_model_memos_get_type (void); -ECalModelMemos *e_cal_model_memos_new (void); +GType e_cal_model_memos_get_type (void); +ECalModel * e_cal_model_memos_new (void); G_END_DECLS diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 095cfabc4b..e4d7304c25 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -1108,7 +1108,7 @@ ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data, /** * e_cal_model_tasks_new */ -ECalModelTasks * +ECalModel * e_cal_model_tasks_new (void) { return g_object_new (E_TYPE_CAL_MODEL_TASKS, NULL); diff --git a/calendar/gui/e-cal-model-tasks.h b/calendar/gui/e-cal-model-tasks.h index 40d651e583..c71b737724 100644 --- a/calendar/gui/e-cal-model-tasks.h +++ b/calendar/gui/e-cal-model-tasks.h @@ -64,7 +64,7 @@ typedef struct { } ECalModelTasksClass; GType e_cal_model_tasks_get_type (void); -ECalModelTasks *e_cal_model_tasks_new (void); +ECalModel * e_cal_model_tasks_new (void); void e_cal_model_tasks_mark_comp_complete (ECalModelTasks *model, ECalModelComponent *comp_data); void e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model, ECalModelComponent *comp_data); diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 4c029d46f3..2929cddf9c 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -65,10 +65,12 @@ struct _ECalendarTablePrivate { gpointer shell_view; /* weak pointer */ + ECalModel *model; }; enum { PROP_0, + PROP_MODEL, PROP_SHELL_VIEW }; @@ -238,9 +240,11 @@ calendar_table_double_click_cb (ECalendarTable *cal_table, gint col, GdkEvent *event) { + ECalModel *model; ECalModelComponent *comp_data; - comp_data = e_cal_model_get_component_at (cal_table->model, row); + model = e_calendar_table_get_model (cal_table); + comp_data = e_cal_model_get_component_at (model, row); calendar_table_emit_open_component (cal_table, comp_data); } @@ -270,6 +274,7 @@ calendar_table_query_tooltip_cb (ECalendarTable *cal_table, gboolean keyboard_mode, GtkTooltip *tooltip) { + ECalModel *model; ECalModelComponent *comp_data; int row = -1, col = -1; GtkWidget *box, *l, *w; @@ -304,7 +309,8 @@ calendar_table_query_tooltip_cb (ECalendarTable *cal_table, if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter)) row = e_sorter_sorted_to_model (esm->sorter, row); - comp_data = e_cal_model_get_component_at (cal_table->model, row); + model = e_calendar_table_get_model (cal_table); + comp_data = e_cal_model_get_component_at (model, row); if (!comp_data || !comp_data->icalcomp) return FALSE; @@ -375,7 +381,7 @@ calendar_table_query_tooltip_cb (ECalendarTable *cal_table, e_cal_component_get_dtstart (new_comp, &dtstart); e_cal_component_get_due (new_comp, &dtdue); - default_zone = e_cal_model_get_timezone (cal_table->model); + default_zone = e_cal_model_get_timezone (model); if (dtstart.tzid) { zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); @@ -487,6 +493,29 @@ calendar_table_right_click_cb (ECalendarTable *cal_table, } static void +calendar_table_set_model (ECalendarTable *cal_table, + ECalModel *model) +{ + g_return_if_fail (cal_table->priv->model == NULL); + + cal_table->priv->model = g_object_ref (model); + + g_signal_connect_swapped ( + model, "row_appended", + G_CALLBACK (calendar_table_emit_user_created), cal_table); + + g_signal_connect_swapped ( + model, "cal-view-progress", + G_CALLBACK (calendar_table_model_cal_view_progress_cb), + cal_table); + + g_signal_connect_swapped ( + model, "cal-view-done", + G_CALLBACK (calendar_table_model_cal_view_done_cb), + cal_table); +} + +static void calendar_table_set_shell_view (ECalendarTable *cal_table, EShellView *shell_view) { @@ -506,6 +535,12 @@ calendar_table_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODEL: + calendar_table_set_model ( + E_CALENDAR_TABLE (object), + g_value_get_object (value)); + return; + case PROP_SHELL_VIEW: calendar_table_set_shell_view ( E_CALENDAR_TABLE (object), @@ -523,6 +558,12 @@ calendar_table_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODEL: + g_value_set_object ( + value, e_calendar_table_get_model ( + E_CALENDAR_TABLE (object))); + return; + case PROP_SHELL_VIEW: g_value_set_object ( value, e_calendar_table_get_shell_view ( @@ -536,13 +577,13 @@ calendar_table_get_property (GObject *object, static void calendar_table_dispose (GObject *object) { - ECalendarTable *cal_table; + ECalendarTablePrivate *priv; - cal_table = E_CALENDAR_TABLE (object); + priv = E_CALENDAR_TABLE_GET_PRIVATE (object); - if (cal_table->model != NULL) { - g_object_unref (cal_table->model); - cal_table->model = NULL; + if (priv->model != NULL) { + g_object_unref (priv->model); + priv->model = NULL; } /* Chain up to parent's dispose() method. */ @@ -550,75 +591,11 @@ calendar_table_dispose (GObject *object) } static void -calendar_table_class_init (ECalendarTableClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (ECalendarTablePrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = calendar_table_set_property; - object_class->get_property = calendar_table_get_property; - object_class->dispose = calendar_table_dispose; - - g_object_class_install_property ( - object_class, - PROP_SHELL_VIEW, - g_param_spec_object ( - "shell-view", - _("Shell View"), - NULL, - E_TYPE_SHELL_VIEW, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - signals[OPEN_COMPONENT] = g_signal_new ( - "open-component", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalendarTableClass, open_component), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_CAL_MODEL_COMPONENT); - - signals[POPUP_EVENT] = g_signal_new ( - "popup-event", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalendarTableClass, popup_event), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - - signals[STATUS_MESSAGE] = g_signal_new ( - "status-message", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalendarTableClass, status_message), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[USER_CREATED] = g_signal_new ( - "user-created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalendarTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); -} - -static void -calendar_table_init (ECalendarTable *cal_table) +calendar_table_constructed (GObject *object) { + ECalendarTable *cal_table; GtkWidget *widget; + ECalModel *model; ETable *table; ECell *cell, *popup_cell; ETableExtras *extras; @@ -628,25 +605,8 @@ calendar_table_init (ECalendarTable *cal_table) AtkObject *a11y; gchar *etspecfile; - cal_table->priv = E_CALENDAR_TABLE_GET_PRIVATE (cal_table); - - /* Create the model */ - - cal_table->model = (ECalModel *) e_cal_model_tasks_new (); - - g_signal_connect_swapped ( - cal_table->model, "row_appended", - G_CALLBACK (calendar_table_emit_user_created), cal_table); - - g_signal_connect_swapped ( - cal_table->model, "cal-view-progress", - G_CALLBACK (calendar_table_model_cal_view_progress_cb), - cal_table); - - g_signal_connect_swapped ( - cal_table->model, "cal-view-done", - G_CALLBACK (calendar_table_model_cal_view_done_cb), - cal_table); + cal_table = E_CALENDAR_TABLE (object); + model = e_calendar_table_get_model (cal_table); /* Create the header columns */ @@ -837,7 +797,7 @@ calendar_table_init (ECalendarTable *cal_table) etspecfile = g_build_filename ( EVOLUTION_ETSPECDIR, "e-calendar-table.etspec", NULL); widget = e_table_scrolled_new_from_spec_file ( - E_TABLE_MODEL (cal_table->model), extras, etspecfile, NULL); + E_TABLE_MODEL (model), extras, etspecfile, NULL); gtk_table_attach ( GTK_TABLE (cal_table), widget, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -865,6 +825,90 @@ calendar_table_init (ECalendarTable *cal_table) atk_object_set_name (a11y, _("Tasks")); } +static void +calendar_table_class_init (ECalendarTableClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalendarTablePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = calendar_table_set_property; + object_class->get_property = calendar_table_get_property; + object_class->dispose = calendar_table_dispose; + object_class->constructed = calendar_table_constructed; + + g_object_class_install_property ( + object_class, + PROP_MODEL, + g_param_spec_object ( + "model", + _("Model"), + NULL, + E_TYPE_CAL_MODEL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + object_class, + PROP_SHELL_VIEW, + g_param_spec_object ( + "shell-view", + _("Shell View"), + NULL, + E_TYPE_SHELL_VIEW, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + signals[OPEN_COMPONENT] = g_signal_new ( + "open-component", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ECalendarTableClass, open_component), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_CAL_MODEL_COMPONENT); + + signals[POPUP_EVENT] = g_signal_new ( + "popup-event", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ECalendarTableClass, popup_event), + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + + signals[STATUS_MESSAGE] = g_signal_new ( + "status-message", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ECalendarTableClass, status_message), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); + + signals[USER_CREATED] = g_signal_new ( + "user-created", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ECalendarTableClass, user_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); +} + +static void +calendar_table_init (ECalendarTable *cal_table) +{ + cal_table->priv = E_CALENDAR_TABLE_GET_PRIVATE (cal_table); +} + GType e_calendar_table_get_type (void) { @@ -894,19 +938,22 @@ e_calendar_table_get_type (void) /** * e_calendar_table_new: * @shell_view: an #EShellView + * @model: an #ECalModel for the table * * Returns a new #ECalendarTable. * * Returns: a new #ECalendarTable **/ GtkWidget * -e_calendar_table_new (EShellView *shell_view) +e_calendar_table_new (EShellView *shell_view, + ECalModel *model) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); return g_object_new ( E_TYPE_CALENDAR_TABLE, - "shell-view", shell_view, NULL); + "model", model, "shell-view", shell_view, NULL); } EShellView * @@ -928,10 +975,9 @@ e_calendar_table_get_shell_view (ECalendarTable *cal_table) ECalModel * e_calendar_table_get_model (ECalendarTable *cal_table) { - g_return_val_if_fail (cal_table != NULL, NULL); g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); - return cal_table->model; + return cal_table->priv->model; } @@ -975,9 +1021,11 @@ get_selected_row_cb (int model_row, gpointer data) static ECalModelComponent * get_selected_comp (ECalendarTable *cal_table) { + ECalModel *model; ETable *etable; int row; + model = e_calendar_table_get_model (cal_table); etable = e_calendar_table_get_table (cal_table); if (e_table_selected_count (etable) != 1) return NULL; @@ -988,7 +1036,7 @@ get_selected_comp (ECalendarTable *cal_table) &row); g_return_val_if_fail (row != -1, NULL); - return e_cal_model_get_component_at (cal_table->model, row); + return e_cal_model_get_component_at (model, row); } struct get_selected_uids_closure { @@ -1000,12 +1048,12 @@ struct get_selected_uids_closure { static void add_uid_cb (int model_row, gpointer data) { - struct get_selected_uids_closure *closure; + struct get_selected_uids_closure *closure = data; ECalModelComponent *comp_data; + ECalModel *model; - closure = data; - - comp_data = e_cal_model_get_component_at (closure->cal_table->model, model_row); + model = e_calendar_table_get_model (closure->cal_table); + comp_data = e_cal_model_get_component_at (model, model_row); closure->objects = g_slist_prepend (closure->objects, comp_data); } @@ -1221,6 +1269,7 @@ copy_row_cb (int model_row, gpointer data) { ECalendarTable *cal_table; ECalModelComponent *comp_data; + ECalModel *model; gchar *comp_str; icalcomponent *child; @@ -1228,7 +1277,8 @@ copy_row_cb (int model_row, gpointer data) g_return_if_fail (cal_table->tmp_vcal != NULL); - comp_data = e_cal_model_get_component_at (cal_table->model, model_row); + model = e_calendar_table_get_model (cal_table); + comp_data = e_cal_model_get_component_at (model, model_row); if (!comp_data) return; @@ -1289,6 +1339,7 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text) icalcomponent *icalcomp; char *uid; ECalComponent *comp; + ECalModel *model; ECal *client; icalcomponent_kind kind; const gchar *status_message; @@ -1311,7 +1362,8 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text) return; } - client = e_cal_model_get_default_client (cal_table->model); + model = e_calendar_table_get_model (cal_table); + client = e_cal_model_get_default_client (model); status_message = _("Updating objects"); calendar_table_emit_status_message (cal_table, status_message, -1.0); diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index edd9b2b53f..4f9bced553 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -61,9 +61,6 @@ typedef struct _ECalendarTablePrivate ECalendarTablePrivate; struct _ECalendarTable { GtkTable parent; - /* The model that we use */ - ECalModel *model; - GtkWidget *etable; /* The ECell used to view & edit dates. */ @@ -90,7 +87,8 @@ struct _ECalendarTableClass { }; GType e_calendar_table_get_type (void); -GtkWidget * e_calendar_table_new (EShellView *shell_view); +GtkWidget * e_calendar_table_new (EShellView *shell_view, + ECalModel *model); ECalModel * e_calendar_table_get_model (ECalendarTable *cal_table); ETable * e_calendar_table_get_table (ECalendarTable *cal_table); EShellView * e_calendar_table_get_shell_view (ECalendarTable *cal_table); diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index b844030264..1fc947b7ea 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -66,10 +66,12 @@ struct _EMemoTablePrivate { gpointer shell_view; /* weak pointer */ + ECalModel *model; }; enum { PROP_0, + PROP_MODEL, PROP_SHELL_VIEW }; @@ -176,9 +178,11 @@ memo_table_double_click_cb (EMemoTable *memo_table, gint col, GdkEvent *event) { + ECalModel *model; ECalModelComponent *comp_data; - comp_data = e_cal_model_get_component_at (memo_table->model, row); + model = e_memo_table_get_model (memo_table); + comp_data = e_cal_model_get_component_at (model, row); memo_table_emit_open_component (memo_table, comp_data); } @@ -208,6 +212,7 @@ memo_table_query_tooltip_cb (EMemoTable *memo_table, gboolean keyboard_mode, GtkTooltip *tooltip) { + ECalModel *model; ECalModelComponent *comp_data; int row = -1, col = -1; GtkWidget *box, *l, *w; @@ -242,7 +247,8 @@ memo_table_query_tooltip_cb (EMemoTable *memo_table, if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter)) row = e_sorter_sorted_to_model (esm->sorter, row); - comp_data = e_cal_model_get_component_at (memo_table->model, row); + model = e_memo_table_get_model (memo_table); + comp_data = e_cal_model_get_component_at (model, row); if (!comp_data || !comp_data->icalcomp) return FALSE; @@ -313,7 +319,7 @@ memo_table_query_tooltip_cb (EMemoTable *memo_table, e_cal_component_get_dtstart (new_comp, &dtstart); e_cal_component_get_due (new_comp, &dtdue); - default_zone = e_cal_model_get_timezone (memo_table->model); + default_zone = e_cal_model_get_timezone (model); if (dtstart.tzid) { zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); @@ -425,6 +431,29 @@ memo_table_right_click_cb (EMemoTable *memo_table, } static void +memo_table_set_model (EMemoTable *memo_table, + ECalModel *model) +{ + g_return_if_fail (memo_table->priv->model == NULL); + + memo_table->priv->model = g_object_ref (model); + + g_signal_connect_swapped ( + model, "row-appended", + G_CALLBACK (memo_table_emit_user_created), memo_table); + + g_signal_connect_swapped ( + model, "cal-view-progress", + G_CALLBACK (memo_table_model_cal_view_progress_cb), + memo_table); + + g_signal_connect_swapped ( + model, "cal-view-done", + G_CALLBACK (memo_table_model_cal_view_done_cb), + memo_table); +} + +static void memo_table_set_shell_view (EMemoTable *memo_table, EShellView *shell_view) { @@ -444,6 +473,12 @@ memo_table_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODEL: + memo_table_set_model ( + E_MEMO_TABLE (object), + g_value_get_object (value)); + return; + case PROP_SHELL_VIEW: memo_table_set_shell_view ( E_MEMO_TABLE (object), @@ -461,6 +496,12 @@ memo_table_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODEL: + g_value_set_object ( + value, e_memo_table_get_model ( + E_MEMO_TABLE (object))); + return; + case PROP_SHELL_VIEW: g_value_set_object ( value, e_memo_table_get_shell_view ( @@ -474,13 +515,13 @@ memo_table_get_property (GObject *object, static void memo_table_dispose (GObject *object) { - EMemoTable *memo_table; + EMemoTablePrivate *priv; - memo_table = E_MEMO_TABLE (object); + priv = E_MEMO_TABLE_GET_PRIVATE (object); - if (memo_table->model != NULL) { - g_object_unref (memo_table->model); - memo_table->model = NULL; + if (priv->model != NULL) { + g_object_unref (priv->model); + priv->model = NULL; } /* Chain up to parent's dispose() method. */ @@ -488,75 +529,11 @@ memo_table_dispose (GObject *object) } static void -memo_table_class_init (EMemoTableClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (EMemoTablePrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = memo_table_set_property; - object_class->get_property = memo_table_get_property; - object_class->dispose = memo_table_dispose; - - g_object_class_install_property ( - object_class, - PROP_SHELL_VIEW, - g_param_spec_object ( - "shell-view", - _("Shell View"), - NULL, - E_TYPE_SHELL_VIEW, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - signals[OPEN_COMPONENT] = g_signal_new ( - "open-component", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EMemoTableClass, open_component), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_CAL_MODEL_COMPONENT); - - signals[POPUP_EVENT] = g_signal_new ( - "popup-event", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EMemoTableClass, popup_event), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - - signals[STATUS_MESSAGE] = g_signal_new ( - "status-message", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EMemoTableClass, status_message), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[USER_CREATED] = g_signal_new ( - "user-created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EMemoTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); -} - -static void -memo_table_init (EMemoTable *memo_table) +memo_table_constructed (GObject *object) { + EMemoTable *memo_table; GtkWidget *widget; + ECalModel *model; ETable *table; ECell *cell, *popup_cell; ETableExtras *extras; @@ -564,25 +541,8 @@ memo_table_init (EMemoTable *memo_table) AtkObject *a11y; gchar *etspecfile; - memo_table->priv = E_MEMO_TABLE_GET_PRIVATE (memo_table); - - /* Create the model */ - - memo_table->model = (ECalModel *) e_cal_model_memos_new (); - - g_signal_connect_swapped ( - memo_table->model, "row-appended", - G_CALLBACK (memo_table_emit_user_created), memo_table); - - g_signal_connect_swapped ( - memo_table->model, "cal-view-progress", - G_CALLBACK (memo_table_model_cal_view_progress_cb), - memo_table); - - g_signal_connect_swapped ( - memo_table->model, "cal-view-done", - G_CALLBACK (memo_table_model_cal_view_done_cb), - memo_table); + memo_table = E_MEMO_TABLE (object); + model = e_memo_table_get_model (memo_table); /* Create the header columns */ @@ -632,7 +592,7 @@ memo_table_init (EMemoTable *memo_table) etspecfile = g_build_filename ( EVOLUTION_ETSPECDIR, "e-memo-table.etspec", NULL); widget = e_table_scrolled_new_from_spec_file ( - E_TABLE_MODEL (memo_table->model), extras, etspecfile, NULL); + E_TABLE_MODEL (model), extras, etspecfile, NULL); gtk_table_attach ( GTK_TABLE (memo_table), widget, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -660,6 +620,90 @@ memo_table_init (EMemoTable *memo_table) atk_object_set_name (a11y, _("Memos")); } +static void +memo_table_class_init (EMemoTableClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMemoTablePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = memo_table_set_property; + object_class->get_property = memo_table_get_property; + object_class->dispose = memo_table_dispose; + object_class->constructed = memo_table_constructed; + + g_object_class_install_property ( + object_class, + PROP_MODEL, + g_param_spec_object ( + "model", + _("Model"), + NULL, + E_TYPE_CAL_MODEL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + object_class, + PROP_SHELL_VIEW, + g_param_spec_object ( + "shell-view", + _("Shell View"), + NULL, + E_TYPE_SHELL_VIEW, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + signals[OPEN_COMPONENT] = g_signal_new ( + "open-component", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMemoTableClass, open_component), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_CAL_MODEL_COMPONENT); + + signals[POPUP_EVENT] = g_signal_new ( + "popup-event", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMemoTableClass, popup_event), + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + + signals[STATUS_MESSAGE] = g_signal_new ( + "status-message", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMemoTableClass, status_message), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); + + signals[USER_CREATED] = g_signal_new ( + "user-created", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMemoTableClass, user_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); +} + +static void +memo_table_init (EMemoTable *memo_table) +{ + memo_table->priv = E_MEMO_TABLE_GET_PRIVATE (memo_table); +} + GType e_memo_table_get_type (void) { @@ -689,19 +733,22 @@ e_memo_table_get_type (void) /** * e_memo_table_new: * @shell_view: an #EShellView + * @model: an #ECalModel for the table * * Returns a new #EMemoTable. * * Returns: a new #EMemoTable **/ GtkWidget * -e_memo_table_new (EShellView *shell_view) +e_memo_table_new (EShellView *shell_view, + ECalModel *model) { g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); return g_object_new ( E_TYPE_MEMO_TABLE, - "shell-view", shell_view, NULL); + "model", model, "shell-view", shell_view, NULL); } EShellView * @@ -726,7 +773,7 @@ e_memo_table_get_model (EMemoTable *memo_table) g_return_val_if_fail (memo_table != NULL, NULL); g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL); - return memo_table->model; + return memo_table->priv->model; } @@ -770,9 +817,11 @@ get_selected_row_cb (int model_row, gpointer data) static ECalModelComponent * get_selected_comp (EMemoTable *memo_table) { + ECalModel *model; ETable *etable; int row; + model = e_memo_table_get_model (memo_table); etable = e_memo_table_get_table (memo_table); if (e_table_selected_count (etable) != 1) return NULL; @@ -783,7 +832,7 @@ get_selected_comp (EMemoTable *memo_table) &row); g_return_val_if_fail (row != -1, NULL); - return e_cal_model_get_component_at (memo_table->model, row); + return e_cal_model_get_component_at (model, row); } struct get_selected_uids_closure { @@ -797,10 +846,12 @@ add_uid_cb (int model_row, gpointer data) { struct get_selected_uids_closure *closure; ECalModelComponent *comp_data; + ECalModel *model; closure = data; - comp_data = e_cal_model_get_component_at (closure->memo_table->model, model_row); + model = e_memo_table_get_model (closure->memo_table); + comp_data = e_cal_model_get_component_at (model, model_row); closure->objects = g_slist_prepend (closure->objects, comp_data); } @@ -941,6 +992,7 @@ copy_row_cb (int model_row, gpointer data) { EMemoTable *memo_table; ECalModelComponent *comp_data; + ECalModel *model; gchar *comp_str; icalcomponent *child; @@ -948,7 +1000,8 @@ copy_row_cb (int model_row, gpointer data) g_return_if_fail (memo_table->tmp_vcal != NULL); - comp_data = e_cal_model_get_component_at (memo_table->model, model_row); + model = e_memo_table_get_model (memo_table); + comp_data = e_cal_model_get_component_at (model, model_row); if (!comp_data) return; @@ -1010,6 +1063,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text) char *uid; ECalComponent *comp; ECal *client; + ECalModel *model; icalcomponent_kind kind; const gchar *status_message; @@ -1031,7 +1085,8 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text) return; } - client = e_cal_model_get_default_client (memo_table->model); + model = e_memo_table_get_model (memo_table); + client = e_cal_model_get_default_client (model); status_message = _("Updating objects"); memo_table_emit_status_message (memo_table, status_message, -1.0); diff --git a/calendar/gui/e-memo-table.h b/calendar/gui/e-memo-table.h index 39838b4caa..0a13006262 100644 --- a/calendar/gui/e-memo-table.h +++ b/calendar/gui/e-memo-table.h @@ -67,9 +67,6 @@ typedef struct _EMemoTablePrivate EMemoTablePrivate; struct _EMemoTable { GtkTable parent; - /* The model that we use */ - ECalModel *model; - GtkWidget *etable; /* The ECell used to view & edit dates. */ @@ -96,7 +93,8 @@ struct _EMemoTableClass { }; GType e_memo_table_get_type (void); -GtkWidget * e_memo_table_new (EShellView *shell_view); +GtkWidget * e_memo_table_new (EShellView *shell_view, + ECalModel *model); ECalModel * e_memo_table_get_model (EMemoTable *memo_table); ETable * e_memo_table_get_table (EMemoTable *memo_table); EShellView * e_memo_table_get_shell_view (EMemoTable *memo_table); diff --git a/calendar/modules/e-cal-shell-content.c b/calendar/modules/e-cal-shell-content.c index f8bd9f6ddd..865ae7de5a 100644 --- a/calendar/modules/e-cal-shell-content.c +++ b/calendar/modules/e-cal-shell-content.c @@ -304,10 +304,15 @@ cal_shell_content_constructed (GObject *object) { ECalShellContentPrivate *priv; ECalModelCalendar *cal_model; + ECalModel *memo_model; + ECalModel *task_model; EShellContent *shell_content; EShellModule *shell_module; EShellView *shell_view; + EShellWindow *shell_window; EShellViewClass *shell_view_class; + EShellContent *foreign_content; + EShellView *foreign_view; GalViewCollection *view_collection; GalViewInstance *view_instance; GtkWidget *container; @@ -324,6 +329,7 @@ cal_shell_content_constructed (GObject *object) shell_content = E_SHELL_CONTENT (object); shell_view = e_shell_content_get_shell_view (shell_content); + shell_window = e_shell_view_get_shell_window (shell_view); shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); view_collection = shell_view_class->view_collection; @@ -336,6 +342,17 @@ cal_shell_content_constructed (GObject *object) E_CAL_MODEL (cal_model), E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES); + /* We borrow the memopad and taskpad models from the memo + * and task views, loading the views if necessary. */ + + foreign_view = e_shell_window_get_shell_view (shell_window, "memos"); + foreign_content = e_shell_view_get_shell_content (foreign_view); + g_object_get (foreign_content, "model", &memo_model, NULL); + + foreign_view = e_shell_window_get_shell_view (shell_window, "tasks"); + foreign_content = e_shell_view_get_shell_content (foreign_view); + g_object_get (foreign_content, "model", &task_model, NULL); + /* Build content widgets. */ container = GTK_WIDGET (object); @@ -454,7 +471,7 @@ cal_shell_content_constructed (GObject *object) gtk_widget_show (widget); g_free (markup); - widget = e_calendar_table_new (shell_view); + widget = e_calendar_table_new (shell_view, task_model); gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); priv->task_table = g_object_ref (widget); gtk_widget_show (widget); @@ -478,7 +495,7 @@ cal_shell_content_constructed (GObject *object) gtk_widget_show (widget); g_free (markup); - widget = e_memo_table_new (shell_view); + widget = e_memo_table_new (shell_view, memo_model); gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); priv->memo_table = g_object_ref (widget); gtk_widget_show (widget); @@ -516,6 +533,9 @@ cal_shell_content_constructed (GObject *object) object); gal_view_instance_load (view_instance); priv->view_instance = view_instance; + + g_object_unref (memo_model); + g_object_unref (task_model); } static void diff --git a/calendar/modules/e-cal-shell-view-memopad.c b/calendar/modules/e-cal-shell-view-memopad.c index 5c2bf19052..7c306fd8eb 100644 --- a/calendar/modules/e-cal-shell-view-memopad.c +++ b/calendar/modules/e-cal-shell-view-memopad.c @@ -351,7 +351,6 @@ e_cal_shell_view_memopad_actions_init (ECalShellView *cal_shell_view) gtk_action_group_add_actions ( action_group, calendar_memopad_entries, G_N_ELEMENTS (calendar_memopad_entries), cal_shell_view); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); } void diff --git a/calendar/modules/e-cal-shell-view-private.c b/calendar/modules/e-cal-shell-view-private.c index 3b7bea2449..7f24eddd2e 100644 --- a/calendar/modules/e-cal-shell-view-private.c +++ b/calendar/modules/e-cal-shell-view-private.c @@ -25,6 +25,22 @@ #include "widgets/menus/gal-view-factory-etable.h" static void +cal_shell_view_process_completed_tasks (ECalShellView *cal_shell_view, + gboolean config_changed) +{ +#if 0 + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + e_calendar_table_process_completed_tasks ( + task_table, clients, config_changed); +#endif +} + +static void cal_shell_view_update_timezone (ECalShellView *cal_shell_view) { #if 0 @@ -49,10 +65,21 @@ cal_shell_view_update_timezone (ECalShellView *cal_shell_view) } static void -cal_shell_view_timezone_changed_cb (GConfClient *client, - guint id, - GConfEntry *entry, - gpointer user_data) +cal_shell_view_config_hide_completed_tasks_changed_cb (GConfClient *client, + guint id, + GConfEntry *entry, + gpointer user_data) +{ + ECalShellView *cal_shell_view = user_data; + + /* FIXME */ +} + +static void +cal_shell_view_config_timezone_changed_cb (GConfClient *client, + guint id, + GConfEntry *entry, + gpointer user_data) { ECalShellView *cal_shell_view = user_data; @@ -197,6 +224,7 @@ e_cal_shell_view_private_init (ECalShellView *cal_shell_view, ECalShellViewPrivate *priv = cal_shell_view->priv; ESourceList *source_list; GObject *object; + guint notification_id; object = G_OBJECT (shell_view_class->type_module); source_list = g_object_get_data (object, "source-list"); @@ -227,7 +255,7 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) ECalendar *mini_calendar; EMemoTable *memo_table; ECalendarTable *task_table; - guint notification; + guint id; shell_view = E_SHELL_VIEW (cal_shell_view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -249,10 +277,12 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) mini_calendar->calitem, (ECalendarItemGetTimeCallback) cal_shell_view_get_current_time, cal_shell_view, NULL); +#if 0 /* KILL-BONOBO */ g_signal_connect_swapped ( calendar, "dates-shown-changed", G_CALLBACK (e_cal_shell_view_update_sidebar), cal_shell_view); +#endif g_signal_connect_swapped ( mini_calendar, "scroll-event", @@ -291,13 +321,27 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) /* Listen for configuration changes. */ -#if 0 - notification = calendar_config_add_notification_timezone ( - cal_shell_view_timezone_changed_cb, cal_shell_view); + /* Timezone */ + id = calendar_config_add_notification_timezone ( + cal_shell_view_config_timezone_changed_cb, cal_shell_view); priv->notifications = g_list_prepend ( - priv->notifications, GUINT_TO_POINTER (notification)); + priv->notifications, GUINT_TO_POINTER (id)); cal_shell_view_update_timezone (cal_shell_view); -#endif + + /* Hide Completed Tasks (enable/units/value) */ + id = calendar_config_add_notification_hide_completed_tasks ( + cal_shell_view_config_hide_completed_tasks_changed_cb, + cal_shell_view); + priv->notifications = g_list_prepend ( + priv->notifications, GUINT_TO_POINTER (id)); + id = calendar_config_add_notification_hide_completed_tasks_units ( + cal_shell_view_config_hide_completed_tasks_changed_cb, + cal_shell_view); + priv->notifications = g_list_prepend ( + priv->notifications, GUINT_TO_POINTER (id)); + id = calendar_config_add_notification_hide_completed_tasks_value ( + cal_shell_view_config_hide_completed_tasks_changed_cb, + cal_shell_view); e_categories_register_change_listener ( G_CALLBACK (e_cal_shell_view_update_search_filter), @@ -312,6 +356,7 @@ void e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) { ECalShellViewPrivate *priv = cal_shell_view->priv; + GList *iter; DISPOSE (priv->source_list); @@ -321,26 +366,33 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) DISPOSE (priv->cal_shell_content); DISPOSE (priv->cal_shell_sidebar); - if (cal_shell_view->priv->calendar_activity != NULL) { + if (priv->calendar_activity != NULL) { /* XXX Activity is not cancellable. */ - e_activity_complete (cal_shell_view->priv->calendar_activity); - g_object_unref (cal_shell_view->priv->calendar_activity); - cal_shell_view->priv->calendar_activity = NULL; + e_activity_complete (priv->calendar_activity); + g_object_unref (priv->calendar_activity); + priv->calendar_activity = NULL; } - if (cal_shell_view->priv->memopad_activity != NULL) { + if (priv->memopad_activity != NULL) { /* XXX Activity is not cancellable. */ - e_activity_complete (cal_shell_view->priv->memopad_activity); - g_object_unref (cal_shell_view->priv->memopad_activity); - cal_shell_view->priv->memopad_activity = NULL; + e_activity_complete (priv->memopad_activity); + g_object_unref (priv->memopad_activity); + priv->memopad_activity = NULL; } - if (cal_shell_view->priv->taskpad_activity != NULL) { + if (priv->taskpad_activity != NULL) { /* XXX Activity is not cancellable. */ - e_activity_complete (cal_shell_view->priv->taskpad_activity); - g_object_unref (cal_shell_view->priv->taskpad_activity); - cal_shell_view->priv->taskpad_activity = NULL; + e_activity_complete (priv->taskpad_activity); + g_object_unref (priv->taskpad_activity); + priv->taskpad_activity = NULL; + } + + for (iter = priv->notifications; iter != NULL; iter = iter->next) { + guint notification_id = GPOINTER_TO_UINT (iter->data); + calendar_config_remove_notification (notification_id); } + g_list_free (priv->notifications); + priv->notifications = NULL; } void diff --git a/calendar/modules/e-cal-shell-view-private.h b/calendar/modules/e-cal-shell-view-private.h index f1116f9c35..66083a0903 100644 --- a/calendar/modules/e-cal-shell-view-private.h +++ b/calendar/modules/e-cal-shell-view-private.h @@ -33,6 +33,7 @@ #include "e-util/e-dialog-utils.h" #include "e-util/e-util.h" +#include "calendar/gui/calendar-config.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/e-cal-list-view.h" #include "calendar/gui/e-cal-model-tasks.h" @@ -107,6 +108,9 @@ struct _ECalShellViewPrivate { EActivity *calendar_activity; EActivity *memopad_activity; EActivity *taskpad_activity; + + /* GConf notification IDs */ + GList *notifications; }; void e_cal_shell_view_private_init diff --git a/calendar/modules/e-cal-shell-view-taskpad.c b/calendar/modules/e-cal-shell-view-taskpad.c index aa3a73cbab..082572b4c8 100644 --- a/calendar/modules/e-cal-shell-view-taskpad.c +++ b/calendar/modules/e-cal-shell-view-taskpad.c @@ -439,7 +439,6 @@ e_cal_shell_view_taskpad_actions_init (ECalShellView *cal_shell_view) gtk_action_group_add_actions ( action_group, calendar_taskpad_entries, G_N_ELEMENTS (calendar_taskpad_entries), cal_shell_view); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); } void diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c index fc245b8f44..f3d0d5bcbd 100644 --- a/calendar/modules/e-memo-shell-content.c +++ b/calendar/modules/e-memo-shell-content.c @@ -26,6 +26,7 @@ #include "e-util/gconf-bridge.h" #include "calendar/gui/calendar-config.h" +#include "calendar/gui/e-cal-model-memos.h" #include "calendar/gui/e-memo-table.h" #include "calendar/gui/e-memo-table-config.h" @@ -49,6 +50,7 @@ struct _EMemoShellContentPrivate { GtkWidget *memo_table; GtkWidget *memo_preview; + ECalModel *memo_model; EMemoTableConfig *table_config; GalViewInstance *view_instance; @@ -57,6 +59,7 @@ struct _EMemoShellContentPrivate { enum { PROP_0, + PROP_MODEL, PROP_PREVIEW_VISIBLE }; @@ -96,7 +99,7 @@ memo_shell_content_display_view_cb (EMemoShellContent *memo_shell_content, if (!GAL_IS_VIEW_ETABLE (gal_view)) return; - memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); table = e_memo_table_get_table (memo_table); gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); @@ -133,23 +136,22 @@ memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content, { ECalComponentPreview *memo_preview; EMemoTable *memo_table; - ECalModel *model; + ECalModel *memo_model; ECalModelComponent *comp_data; ECalComponent *comp; const gchar *uid; - memo_preview = E_CAL_COMPONENT_PREVIEW ( - memo_shell_content->priv->memo_preview); - memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); + memo_model = e_memo_shell_content_get_memo_model (memo_shell_content); + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content); if (e_table_selected_count (table) != 1) { e_cal_component_preview_clear (memo_preview); return; } - model = e_memo_table_get_model (memo_table); row = e_table_get_cursor_row (table); - comp_data = e_cal_model_get_component_at (model, row); + comp_data = e_cal_model_get_component_at (memo_model, row); comp = e_cal_component_new (); e_cal_component_set_icalcomponent ( @@ -170,8 +172,7 @@ memo_shell_content_selection_change_cb (EMemoShellContent *memo_shell_content, { ECalComponentPreview *memo_preview; - memo_preview = E_CAL_COMPONENT_PREVIEW ( - memo_shell_content->priv->memo_preview); + memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content); /* XXX Old code emits a "selection-changed" signal here. */ @@ -202,7 +203,7 @@ memo_shell_content_model_row_changed_cb (EMemoShellContent *memo_shell_content, if (g_strcmp0 (uid, current_uid) != 0) return; - memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); table = e_memo_table_get_table (memo_table); memo_shell_content_cursor_change_cb (memo_shell_content, 0, table); @@ -232,6 +233,12 @@ memo_shell_content_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODEL: + g_value_set_object ( + value, e_memo_shell_content_get_memo_model ( + E_MEMO_SHELL_CONTENT (object))); + return; + case PROP_PREVIEW_VISIBLE: g_value_set_boolean ( value, e_memo_shell_content_get_preview_visible ( @@ -264,6 +271,11 @@ memo_shell_content_dispose (GObject *object) priv->memo_preview = NULL; } + if (priv->memo_model != NULL) { + g_object_unref (priv->memo_model); + priv->memo_model = NULL; + } + if (priv->table_config != NULL) { g_object_unref (priv->table_config); priv->table_config = NULL; @@ -300,7 +312,6 @@ memo_shell_content_constructed (GObject *object) EShellViewClass *shell_view_class; GalViewCollection *view_collection; GalViewInstance *view_instance; - ECalModel *model; ETable *table; GConfBridge *bridge; GtkWidget *container; @@ -328,7 +339,7 @@ memo_shell_content_constructed (GObject *object) container = widget; - widget = e_memo_table_new (shell_view); + widget = e_memo_table_new (shell_view, priv->memo_model); gtk_paned_add1 (GTK_PANED (container), widget); priv->memo_table = g_object_ref (widget); gtk_widget_show (widget); @@ -356,7 +367,6 @@ memo_shell_content_constructed (GObject *object) widget = E_MEMO_TABLE (priv->memo_table)->etable; table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memo_table)); priv->table_config = e_memo_table_config_new ( E_MEMO_TABLE (priv->memo_table)); @@ -389,7 +399,7 @@ memo_shell_content_constructed (GObject *object) object); g_signal_connect_swapped ( - model, "model-row-changed", + priv->memo_model, "model-row-changed", G_CALLBACK (memo_shell_content_model_row_changed_cb), object); @@ -482,6 +492,16 @@ memo_shell_content_class_init (EMemoShellContentClass *class) g_object_class_install_property ( object_class, + PROP_MODEL, + g_param_spec_object ( + "model", + _("Model"), + _("The memo table model"), + E_TYPE_CAL_MODEL, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, PROP_PREVIEW_VISIBLE, g_param_spec_boolean ( "preview-visible", @@ -497,6 +517,8 @@ memo_shell_content_init (EMemoShellContent *memo_shell_content) memo_shell_content->priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (memo_shell_content); + memo_shell_content->priv->memo_model = e_cal_model_memos_new (); + /* Postpone widget construction until we have a shell view. */ } @@ -537,6 +559,15 @@ e_memo_shell_content_new (EShellView *shell_view) "shell-view", shell_view, NULL); } +ECalModel * +e_memo_shell_content_get_memo_model (EMemoShellContent *memo_shell_content) +{ + g_return_val_if_fail ( + E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL); + + return memo_shell_content->priv->memo_model; +} + ECalComponentPreview * e_memo_shell_content_get_memo_preview (EMemoShellContent *memo_shell_content) { diff --git a/calendar/modules/e-memo-shell-content.h b/calendar/modules/e-memo-shell-content.h index 036a04be56..9edb986cc1 100644 --- a/calendar/modules/e-memo-shell-content.h +++ b/calendar/modules/e-memo-shell-content.h @@ -73,6 +73,8 @@ struct _EMemoShellContentClass { GType e_memo_shell_content_get_type (void); GtkWidget * e_memo_shell_content_new (EShellView *shell_view); +ECalModel * e_memo_shell_content_get_memo_model + (EMemoShellContent *memo_shell_conent); ECalComponentPreview * e_memo_shell_content_get_memo_preview (EMemoShellContent *memo_shell_content); diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c index 40b8372c46..b45daedd21 100644 --- a/calendar/modules/e-task-shell-content.c +++ b/calendar/modules/e-task-shell-content.c @@ -26,6 +26,7 @@ #include "e-util/gconf-bridge.h" #include "calendar/gui/calendar-config.h" +#include "calendar/gui/e-cal-model-tasks.h" #include "calendar/gui/e-calendar-table.h" #include "calendar/gui/e-calendar-table-config.h" @@ -50,6 +51,7 @@ struct _ETaskShellContentPrivate { GtkWidget *task_table; GtkWidget *task_preview; + ECalModel *task_model; ECalendarTableConfig *table_config; GalViewInstance *view_instance; @@ -58,6 +60,7 @@ struct _ETaskShellContentPrivate { enum { PROP_0, + PROP_MODEL, PROP_PREVIEW_VISIBLE }; @@ -97,7 +100,7 @@ task_shell_content_display_view_cb (ETaskShellContent *task_shell_content, if (!GAL_IS_VIEW_ETABLE (gal_view)) return; - task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); + task_table = e_task_shell_content_get_task_table (task_shell_content); table = e_calendar_table_get_table (task_table); gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); @@ -134,23 +137,22 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content, { ECalComponentPreview *task_preview; ECalendarTable *task_table; - ECalModel *model; + ECalModel *task_model; ECalModelComponent *comp_data; ECalComponent *comp; const gchar *uid; - task_preview = E_CAL_COMPONENT_PREVIEW ( - task_shell_content->priv->task_preview); - task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); + task_model = e_task_shell_content_get_task_model (task_shell_content); + task_table = e_task_shell_content_get_task_table (task_shell_content); + task_preview = e_task_shell_content_get_task_preview (task_shell_content); if (e_table_selected_count (table) != 1) { e_cal_component_preview_clear (task_preview); return; } - model = e_calendar_table_get_model (task_table); row = e_table_get_cursor_row (table); - comp_data = e_cal_model_get_component_at (model, row); + comp_data = e_cal_model_get_component_at (task_model, row); comp = e_cal_component_new (); e_cal_component_set_icalcomponent ( @@ -171,8 +173,7 @@ task_shell_content_selection_change_cb (ETaskShellContent *task_shell_content, { ECalComponentPreview *task_preview; - task_preview = E_CAL_COMPONENT_PREVIEW ( - task_shell_content->priv->task_preview); + task_preview = e_task_shell_content_get_task_preview (task_shell_content); /* XXX Old code emits a "selection-changed" signal here. */ @@ -203,7 +204,7 @@ task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content, if (g_strcmp0 (uid, current_uid) != 0) return; - task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); + task_table = e_task_shell_content_get_task_table (task_shell_content); table = e_calendar_table_get_table (task_table); task_shell_content_cursor_change_cb (task_shell_content, 0, table); @@ -233,6 +234,12 @@ task_shell_content_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODEL: + g_value_set_object ( + value, e_task_shell_content_get_task_model ( + E_TASK_SHELL_CONTENT (object))); + return; + case PROP_PREVIEW_VISIBLE: g_value_set_boolean ( value, e_task_shell_content_get_preview_visible ( @@ -265,6 +272,11 @@ task_shell_content_dispose (GObject *object) priv->task_preview = NULL; } + if (priv->task_model != NULL) { + g_object_unref (priv->task_model); + priv->task_model = NULL; + } + if (priv->table_config != NULL) { g_object_unref (priv->table_config); priv->table_config = NULL; @@ -301,7 +313,6 @@ task_shell_content_constructed (GObject *object) EShellViewClass *shell_view_class; GalViewCollection *view_collection; GalViewInstance *view_instance; - ECalModel *model; ETable *table; GConfBridge *bridge; GtkWidget *container; @@ -329,7 +340,7 @@ task_shell_content_constructed (GObject *object) container = widget; - widget = e_calendar_table_new (shell_view); + widget = e_calendar_table_new (shell_view, priv->task_model); gtk_paned_add1 (GTK_PANED (container), widget); priv->task_table = g_object_ref (widget); gtk_widget_show (widget); @@ -357,7 +368,6 @@ task_shell_content_constructed (GObject *object) widget = E_CALENDAR_TABLE (priv->task_table)->etable; table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); - model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->task_table)); priv->table_config = e_calendar_table_config_new ( E_CALENDAR_TABLE (priv->task_table)); @@ -390,7 +400,7 @@ task_shell_content_constructed (GObject *object) object); g_signal_connect_swapped ( - model, "model-row-changed", + priv->task_model, "model-row-changed", G_CALLBACK (task_shell_content_model_row_changed_cb), object); @@ -508,6 +518,16 @@ task_shell_content_class_init (ETaskShellContentClass *class) g_object_class_install_property ( object_class, + PROP_MODEL, + g_param_spec_object ( + "model", + _("Model"), + _("The task table model"), + E_TYPE_CAL_MODEL, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, PROP_PREVIEW_VISIBLE, g_param_spec_boolean ( "preview-visible", @@ -523,6 +543,8 @@ task_shell_content_init (ETaskShellContent *task_shell_content) task_shell_content->priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (task_shell_content); + task_shell_content->priv->task_model = e_cal_model_tasks_new (); + /* Postpone widget construction until we have a shell view. */ } @@ -563,6 +585,15 @@ e_task_shell_content_new (EShellView *shell_view) "shell-view", shell_view, NULL); } +ECalModel * +e_task_shell_content_get_task_model (ETaskShellContent *task_shell_content) +{ + g_return_val_if_fail ( + E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); + + return task_shell_content->priv->task_model; +} + ECalComponentPreview * e_task_shell_content_get_task_preview (ETaskShellContent *task_shell_content) { diff --git a/calendar/modules/e-task-shell-content.h b/calendar/modules/e-task-shell-content.h index 361b289f77..e6f64f7406 100644 --- a/calendar/modules/e-task-shell-content.h +++ b/calendar/modules/e-task-shell-content.h @@ -25,6 +25,7 @@ #include <shell/e-shell-content.h> #include <shell/e-shell-view.h> +#include <calendar/gui/e-cal-model.h> #include <calendar/gui/e-calendar-table.h> #include <calendar/gui/e-cal-component-preview.h> @@ -76,6 +77,8 @@ struct _ETaskShellContentClass { GType e_task_shell_content_get_type (void); GtkWidget * e_task_shell_content_new (EShellView *shell_view); +ECalModel * e_task_shell_content_get_task_model + (ETaskShellContent *task_shell_content); ECalComponentPreview * e_task_shell_content_get_task_preview (ETaskShellContent *task_shell_content); |