aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-memo-table.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-10-30 04:11:07 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-10-30 04:11:07 +0800
commitd6b8b58bb45b16c1cb3a575c277ffdc77441e2df (patch)
treec80db345f4d3e05a1ee165b40c561f2649e574cb /calendar/gui/e-memo-table.c
parent5e82bdba14fba81603f3879a46b46a011db7d2e4 (diff)
downloadgsoc2013-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/gui/e-memo-table.c')
-rw-r--r--calendar/gui/e-memo-table.c259
1 files changed, 157 insertions, 102 deletions
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);