diff options
Diffstat (limited to 'calendar/gui')
-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 |
8 files changed, 324 insertions, 221 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); |