diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-26 10:42:23 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-26 10:42:23 +0800 |
commit | cb78b84aecf1c011e0b013cc94a079e2dc0eabbc (patch) | |
tree | e6fbbd6a08aa152bbb79f3ebd9eee80ae6c35f7c /calendar/gui | |
parent | 9515b98403f2f7ef77dc6c51f82505fccef08c2b (diff) | |
download | gsoc2013-evolution-cb78b84aecf1c011e0b013cc94a079e2dc0eabbc.tar.gz gsoc2013-evolution-cb78b84aecf1c011e0b013cc94a079e2dc0eabbc.tar.zst gsoc2013-evolution-cb78b84aecf1c011e0b013cc94a079e2dc0eabbc.zip |
Tasks and memos progress. Hoping to merge ECalendarTable and EMemoTable,
or at least make EMemoTable derived from ECalendarTable. Possibly do the
same with other calendar/memo class pairs.
svn path=/branches/kill-bonobo/; revision=36454
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-calendar-table.c | 418 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.h | 21 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 644 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.h | 19 | ||||
-rw-r--r-- | calendar/gui/e-memos.c | 52 | ||||
-rw-r--r-- | calendar/gui/e-tasks.c | 103 |
6 files changed, 377 insertions, 880 deletions
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index ed254d0680..61c43bae26 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -71,44 +71,32 @@ struct _ECalendarTablePrivate { gpointer shell_view; /* weak pointer */ +}; - EActivity *activity; +enum { + PROP_0, + PROP_SHELL_VIEW }; -enum TargetType{ +enum { + OPEN_COMPONENT, + POPUP_EVENT, + STATUS_MESSAGE, + USER_CREATED, + LAST_SIGNAL +}; + +enum { TARGET_TYPE_VCALENDAR }; static GtkTargetEntry target_types[] = { - { "text/x-calendar", 0, TARGET_TYPE_VCALENDAR }, - { "text/calendar", 0, TARGET_TYPE_VCALENDAR } + { "text/calendar", 0, TARGET_TYPE_VCALENDAR }, + { "text/x-calendar", 0, TARGET_TYPE_VCALENDAR } }; static guint n_target_types = G_N_ELEMENTS (target_types); -static void e_calendar_table_on_double_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - ECalendarTable *cal_table); -static gint e_calendar_table_show_popup_menu (ETable *table, - GdkEvent *gdk_event, - ECalendarTable *cal_table); - -static gint e_calendar_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - ECalendarTable *cal_table); -static gboolean e_calendar_table_on_popup_menu (GtkWidget *widget, - gpointer data); - -static gint e_calendar_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - ECalendarTable *cal_table); - static struct tm e_calendar_table_get_current_time (ECellDateEdit *ecde, gpointer data); static void mark_as_complete_cb (EPopup *ep, EPopupItem *pitem, void *data); @@ -116,14 +104,9 @@ static void mark_as_complete_cb (EPopup *ep, EPopupItem *pitem, void *data); static void hide_completed_rows (ECalModel *model, GList *clients_list, char *hide_sexp, GPtrArray *comp_objects); static void show_completed_rows (ECalModel *model, GList *clients_list, char *show_sexp, GPtrArray *comp_objects); -/* Signal IDs */ -enum { - USER_CREATED, - LAST_SIGNAL -}; - static gpointer parent_class; static guint signals[LAST_SIGNAL]; +static GdkAtom clipboard_atom; /* The icons to represent the task. */ #define E_CALENDAR_MODEL_NUM_ICONS 4 @@ -132,7 +115,26 @@ static const char* icon_names[E_CALENDAR_MODEL_NUM_ICONS] = { }; static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { NULL }; -static GdkAtom clipboard_atom = GDK_NONE; +static void +calendar_table_emit_open_component (ECalendarTable *cal_table, + ECalModelComponent *comp_data) +{ + g_signal_emit (cal_table, signals[OPEN_COMPONENT], 0, comp_data); +} + +static void +calendar_table_emit_popup_event (ECalendarTable *cal_table, + GdkEvent *event) +{ + g_signal_emit (cal_table, signals[POPUP_EVENT], 0, event); +} + +static void +calendar_table_emit_status_message (ECalendarTable *cal_table, + const gchar *message) +{ + g_signal_emit (cal_table, signals[STATUS_MESSAGE], 0, message); +} static void calendar_table_emit_user_created (ECalendarTable *cal_table) @@ -140,6 +142,66 @@ calendar_table_emit_user_created (ECalendarTable *cal_table) g_signal_emit (cal_table, signals[USER_CREATED], 0); } +static gint +calendar_table_date_compare_cb (gconstpointer a, + gconstpointer b) +{ + ECellDateEditValue *dv1 = (ECellDateEditValue *) a; + ECellDateEditValue *dv2 = (ECellDateEditValue *) b; + struct icaltimetype tt; + + /* First check if either is NULL. NULL dates sort last. */ + if (!dv1 || !dv2) { + if (dv1 == dv2) + return 0; + else if (dv1) + return -1; + else + return 1; + } + + /* Copy the 2nd value and convert it to the same timezone as the + first. */ + tt = dv2->tt; + + icaltimezone_convert_time (&tt, dv2->zone, dv1->zone); + + /* Now we can compare them. */ + + return icaltime_compare (dv1->tt, tt); +} + +static void +calendar_table_double_click_cb (ECalendarTable *cal_table, + gint row, + gint col, + GdkEvent *event) +{ + ECalModelComponent *comp_data; + + comp_data = e_cal_model_get_component_at (cal_table->model, row); + calendar_table_emit_open_component (cal_table, comp_data); +} + +static gboolean +calendar_table_popup_menu_cb (ECalendarTable *cal_table) +{ + calendar_table_emit_popup_event (cal_table, NULL); + + return TRUE; +} + +static gint +calendar_table_right_click_cb (ECalendarTable *cal_table, + gint row, + gint col, + GdkEvent *event) +{ + calendar_table_emit_popup_event (cal_table, event); + + return TRUE; +} + static void calendar_table_set_shell_view (ECalendarTable *cal_table, EShellView *shell_view) @@ -199,13 +261,6 @@ calendar_table_dispose (GObject *object) cal_table->model = NULL; } - if (cal_table->priv->activity != NULL) { - /* XXX Activity is not cancellable. */ - e_activity_complete (cal_table->priv->activity); - g_object_unref (cal_table->priv->activity); - cal_table->priv->activity = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -219,16 +274,48 @@ calendar_table_class_init (ECalendarTableClass *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; - signals[USER_CREATED] = - g_signal_new ("user_created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalendarTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + 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); + + signal[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_STATUS_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_STRUCT_OFFSET (ECalendarTableClass, user_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); } @@ -236,8 +323,8 @@ calendar_table_class_init (ECalendarTableClass *class) static void calendar_table_init (ECalendarTable *cal_table) { - GtkWidget *table; - ETable *e_table; + GtkWidget *widget; + ETable *table; ECell *cell, *popup_cell; ETableExtras *extras; gint i; @@ -263,7 +350,7 @@ calendar_table_init (ECalendarTable *cal_table) * Normal string fields. */ cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), + g_object_set (cell, "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, @@ -276,7 +363,7 @@ calendar_table_init (ECalendarTable *cal_table) * Date fields. */ cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), + g_object_set (cell, "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, @@ -285,13 +372,13 @@ calendar_table_init (ECalendarTable *cal_table) popup_cell = e_cell_date_edit_new (); e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); g_object_unref (cell); + e_table_extras_add_cell (extras, "dateedit", popup_cell); cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); - e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell), - e_calendar_table_get_current_time, - cal_table, NULL); - + e_cell_date_edit_set_get_time_callback ( + E_CELL_DATE_EDIT (popup_cell), + e_calendar_table_get_current_time, cal_table, NULL); /* * Combo fields. @@ -299,7 +386,7 @@ calendar_table_init (ECalendarTable *cal_table) /* Classification field. */ cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), + g_object_set (cell, "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, @@ -416,7 +503,7 @@ calendar_table_init (ECalendarTable *cal_table) e_table_extras_add_cell (extras, "calstatus", popup_cell); e_table_extras_add_compare (extras, "date-compare", - date_compare_cb); + calendar_table_date_compare_cb); e_table_extras_add_compare (extras, "percent-compare", percent_compare_cb); e_table_extras_add_compare (extras, "priority-compare", @@ -441,34 +528,33 @@ calendar_table_init (ECalendarTable *cal_table) /* Create the table */ - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-calendar-table.etspec", - NULL); - table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (cal_table->model), - extras, - etspecfile, - NULL); + 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); + gtk_table_attach ( + GTK_TABLE (cal_table), widget, 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + cal_table->etable = widget; + gtk_widget_show (widget); g_free (etspecfile); - /* FIXME: this causes a message from GLib about 'extras' having only a floating - reference */ - /* g_object_unref (extras); */ - - cal_table->etable = table; - gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (table); - - - e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table)); - g_signal_connect (e_table, "double_click", G_CALLBACK (e_calendar_table_on_double_click), cal_table); - g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table); - g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table); - g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table); - g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), cal_table); - gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE); + table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); + g_signal_connect_swapped ( + table, "double-click", + G_CALLBACK (calendar_table_double_click), cal_table); + g_signal_connect_swapped ( + table, "popup-menu", + G_CALLBACK (calendar_table_popup_menu), cal_table); + g_signal_connect_swapped ( + table, "right-click", + G_CALLBACK (calendar_table_right_click), cal_table); + g_signal_connect_swapped ( + table, "query-tooltip", + G_CALLBACK (calendar_table_query_tooltip_cb), cal_table); + gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE); - a11y = gtk_widget_get_accessible ((GtkWidget *)e_table); + a11y = gtk_widget_get_accessible (GTK_WIDGET (table)); if (a11y) atk_object_set_name (a11y, _("Tasks")); } @@ -526,34 +612,6 @@ e_calendar_table_get_shell_view (ECalendarTable *cal_table) } static gint -date_compare_cb (gconstpointer a, gconstpointer b) -{ - ECellDateEditValue *dv1 = (ECellDateEditValue *) a; - ECellDateEditValue *dv2 = (ECellDateEditValue *) b; - struct icaltimetype tt; - - /* First check if either is NULL. NULL dates sort last. */ - if (!dv1 || !dv2) { - if (dv1 == dv2) - return 0; - else if (dv1) - return -1; - else - return 1; - } - - /* Copy the 2nd value and convert it to the same timezone as the - first. */ - tt = dv2->tt; - - icaltimezone_convert_time (&tt, dv2->zone, dv1->zone); - - /* Now we can compare them. */ - - return icaltime_compare (dv1->tt, tt); -} - -static gint percent_compare_cb (gconstpointer a, gconstpointer b) { int percent1 = GPOINTER_TO_INT (a); @@ -860,10 +918,13 @@ e_calendar_table_get_model (ECalendarTable *cal_table) ETable * e_calendar_table_get_table (ECalendarTable *cal_table) { - g_return_val_if_fail (cal_table != NULL, NULL); + ETableScrolled *table_scrolled; + g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); - return e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); + table_scrolled = E_TABLE_SCROLLED (cal_table->etable); + + return e_table_scrolled_get_table (table_scrolled); } void @@ -1352,43 +1413,6 @@ e_calendar_table_paste_clipboard (ECalendarTable *cal_table) clipboard_paste_received_cb, cal_table); } -/* Opens a task in the task editor */ -void -e_calendar_table_open_task (ECalendarTable *cal_table, ECal *client, icalcomponent *icalcomp, gboolean assign) -{ - CompEditor *tedit; - const char *uid; - guint32 flags = 0; - - uid = icalcomponent_get_uid (icalcomp); - - tedit = e_comp_editor_registry_find (comp_editor_registry, uid); - if (tedit == NULL) { - ECalComponent *comp; - - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)); - - if (assign) { - flags |= COMP_EDITOR_IS_ASSIGNED; - - if (itip_organizer_is_user (comp, client) || - !e_cal_component_has_attendees (comp)) - flags |= COMP_EDITOR_USER_ORG; - } - - tedit = task_editor_new (client, flags); - comp_editor_edit_comp (tedit, comp); - g_object_unref (comp); - - if (flags & COMP_EDITOR_IS_ASSIGNED) - task_editor_show_assignment (TASK_EDITOR (tedit)); - - e_comp_editor_registry_add (comp_editor_registry, tedit, FALSE); - } - gtk_window_present (GTK_WINDOW (tedit)); -} - /* Opens the task in the specified row */ static void open_task_by_row (ECalendarTable *cal_table, int row) @@ -1741,45 +1765,6 @@ e_calendar_table_show_popup_menu (ETable *table, return TRUE; } -static gint -e_calendar_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - ECalendarTable *cal_table) -{ - return e_calendar_table_show_popup_menu (table, event, cal_table); -} - -static gboolean -e_calendar_table_on_popup_menu (GtkWidget *widget, gpointer data) -{ - ETable *table = E_TABLE(widget); - g_return_val_if_fail(table, FALSE); - - return e_calendar_table_show_popup_menu (table, NULL, - E_CALENDAR_TABLE(data)); -} - -static gint -e_calendar_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - ECalendarTable *cal_table) -{ - if (event->keyval == GDK_Delete) { - delete_cb (NULL, NULL, cal_table); - return TRUE; - } else if ((event->keyval == GDK_o) - &&(event->state & GDK_CONTROL_MASK)) { - open_task_by_row (cal_table, row); - return TRUE; - } - - return FALSE; -} - static void hide_completed_rows (ECalModel *model, GList *clients_list, char *hide_sexp, GPtrArray *comp_objects) { @@ -1929,59 +1914,6 @@ static char *test[] = { #endif -void -e_calendar_table_set_status_message (ECalendarTable *cal_table, - const gchar *message, - gdouble percent) -{ - EActivity *activity; - EShellView *shell_view; - - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - - activity = cal_table->priv->activity; - shell_view = e_calendar_table_get_shell_view (cal_table); - - if (message == NULL || *message == '\0') { - if (activity != NULL) { - e_activity_complete (activity); - g_object_unref (activity); - cal_table->priv->activity = NULL; - } - - } else if (activity == NULL) { - activity = e_activity_new (message); - cal_able->priv->activity = activity; - e_activity_set_percent (activity, percent); - e_shell_view_add_activity (shell_view, activity); - - } else { - e_activity_set_percent (activity, percent); - e_activity_set_primary_text (activity, message); - } - - if (!message || !*message) { - if (cal_table->activity_id != 0) { - e_activity_handler_operation_finished (cal_table->activity_handler, cal_table->activity_id); - cal_table->activity_id = 0; - } - } else if (cal_table->activity_id == 0) { - cal_table->activity_id = e_activity_handler_operation_started ( - cal_table->activity_handler, message, TRUE); - } else { - - double progress; - - if (percent < 0) - progress = -1.0; - else { - progress = ((double) percent / 100); - } - - e_activity_handler_operation_progressing (cal_table->activity_handler, cal_table->activity_id, message, progress); - } -} - /** * e_calendar_table_hide_completed_tasks: * @table: A calendar table model. diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index 6647572e89..4394d24c03 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -76,16 +76,23 @@ struct _ECalendarTable { * so store it here before emitting "user_created" signal and make * it NULL just after the emit. */ ECal *user_created_cal; + + ECalendarTablePrivate *priv; }; struct _ECalendarTableClass { GtkTableClass parent_class; - /* Notification signals */ - void (* user_created) (ECalendarTable *cal_table); + /* Signals */ + void (*open_component) (ECalendarTable *cal_table, + ECalModelComponent *comp_data); + void (*popup_event) (ECalendarTable *cal_table, + GdkEvent *event); + void (*status_message) (ECalendarTable *cal_table, + const gchar *message); + void (*user_created) (ECalendarTable *cal_table); }; - GType e_calendar_table_get_type (void); GtkWidget * e_calendar_table_new (void); ECalModel * e_calendar_table_get_model (ECalendarTable *cal_table); @@ -109,14 +116,6 @@ void e_calendar_table_load_state (ECalendarTable *cal_table, void e_calendar_table_save_state (ECalendarTable *cal_table, gchar *filename); -void e_calendar_table_set_status_message - (ECalendarTable *cal_table, - const gchar *message, - gdouble percent); -void e_calendar_table_open_task (ECalendarTable *cal_table, - ECal *client, - icalcomponent *icalcomp, - gboolean assign); ECalModelComponent * e_calendar_table_get_selected_comp (ECalendarTable *cal_table); diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 8f495a000d..75b3eccd6e 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -37,7 +37,6 @@ #include <glib/gi18n.h> #include <glib/gstdio.h> #include <gdk/gdkkeysyms.h> -#include <libgnome/gnome-url.h> #include <widgets/misc/e-gui-utils.h> #include <table/e-cell-checkbox.h> #include <table/e-cell-toggle.h> @@ -65,8 +64,6 @@ struct _EMemoTablePrivate { gpointer shell_view; /* weak pointer */ - - EActivity *activity; }; enum { @@ -74,53 +71,32 @@ enum { PROP_SHELL_VIEW }; -enum TargetType{ +enum { + OPEN_COMPONENT, + POPUP_EVENT, + STATUS_MESSAGE, + USER_CREATED, + LAST_SIGNAL +}; + +enum { TARGET_TYPE_VCALENDAR }; static GtkTargetEntry target_types[] = { - { "text/x-calendar", 0, TARGET_TYPE_VCALENDAR }, - { "text/calendar", 0, TARGET_TYPE_VCALENDAR } + { "text/calendar", 0, TARGET_TYPE_VCALENDAR }, + { "text/x-calendar", 0, TARGET_TYPE_VCALENDAR } }; static guint n_target_types = G_N_ELEMENTS (target_types); - -static void e_memo_table_on_double_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - EMemoTable *memo_table); -static gint e_memo_table_show_popup_menu (ETable *table, - GdkEvent *gdk_event, - EMemoTable *memo_table); - -static gint e_memo_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - EMemoTable *memo_table); -static gboolean e_memo_table_on_popup_menu (GtkWidget *widget, - gpointer data); - -static gint e_memo_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - EMemoTable *memo_table); static struct tm e_memo_table_get_current_time (ECellDateEdit *ecde, gpointer data); static ECalModelComponent *get_selected_comp (EMemoTable *memo_table); -static void open_memo (EMemoTable *memo_table, ECalModelComponent *comp_data); - -/* Signal IDs */ -enum { - USER_CREATED, - LAST_SIGNAL -}; static gpointer parent_class; static guint signals[LAST_SIGNAL]; +static GdkAtom clipboard_atom; /* The icons to represent the task. */ #define E_MEMO_MODEL_NUM_ICONS 2 @@ -129,7 +105,26 @@ static const char* icon_names[E_MEMO_MODEL_NUM_ICONS] = { }; static GdkPixbuf* icon_pixbufs[E_MEMO_MODEL_NUM_ICONS] = { NULL }; -static GdkAtom clipboard_atom = GDK_NONE; +static void +memo_table_emit_open_component (EMemoTable *memo_table, + ECalModelComponent *comp_data) +{ + g_signal_emit (memo_table, signals[OPEN_COMPONENT], 0, comp_data); +} + +static void +memo_table_emit_popup_event (EMemoTable *memo_table, + GdkEvent *event) +{ + g_signal_emit (memo_table, signals[POPUP_EVENT], 0, event); +} + +static void +memo_table_emit_status_message (EMemoTable *memo_table, + const gchar *message) +{ + g_signal_emit (memo_table, signals[STATUS_MESSAGE], 0, message); +} static void memo_table_emit_user_created (EMemoTable *memo_table) @@ -138,7 +133,8 @@ memo_table_emit_user_created (EMemoTable *memo_table) } static gint -memo_table_date_compare_cb (gconstpointer a, gconstpointer b) +memo_table_date_compare_cb (gconstpointer a, + gconstpointer b) { ECellDateEditValue *dv1 = (ECellDateEditValue *) a; ECellDateEditValue *dv2 = (ECellDateEditValue *) b; @@ -166,6 +162,37 @@ memo_table_date_compare_cb (gconstpointer a, gconstpointer b) } static void +memo_table_double_click_cb (EMemoTable *memo_table, + gint row, + gint col, + GdkEvent *event) +{ + ECalModelComponent *comp_data; + + comp_data = e_cal_model_get_component_at (memo_table->model, row); + memo_table_emit_open_component (memo_table, comp_data); +} + +static gboolean +memo_table_popup_menu_cb (EMemoTable *memo_table) +{ + memo_table_emit_popup_event (memo_table, NULL); + + return TRUE; +} + +static gint +memo_table_right_click_cb (EMemoTable *memo_table, + gint row, + gint col, + GdkEvent *event) +{ + memo_table_emit_popup_event (memo_table, event); + + return TRUE; +} + +static void memo_table_set_shell_view (EMemoTable *memo_table, EShellView *shell_view) { @@ -224,13 +251,6 @@ memo_table_dispose (GObject *object) memo_table->model = NULL; } - if (memo_table->priv->activity != NULL) { - /* XXX Activity is not cancellable. */ - e_activity_complete (memo_table->priv->activity); - g_object_unref (memo_table->priv->activity); - memo_table->priv->activity = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -248,14 +268,44 @@ memo_table_class_init (EMemoTableClass *class) object_class->get_property = memo_table_get_property; object_class->dispose = memo_table_dispose; - signals[USER_CREATED] = - g_signal_new ("user_created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMemoTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + 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); } @@ -263,8 +313,8 @@ memo_table_class_init (EMemoTableClass *class) static void memo_table_init (EMemoTable *memo_table) { - GtkWidget *table; - ETable *e_table; + GtkWidget *widget; + ETable *table; ECell *cell, *popup_cell; ETableExtras *extras; gint i; @@ -288,33 +338,29 @@ memo_table_init (EMemoTable *memo_table) * Normal string fields. */ cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); - + g_object_set (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL); e_table_extras_add_cell (extras, "calstring", cell); /* * Date fields. */ cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); + g_object_set (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL); popup_cell = e_cell_date_edit_new (); e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); g_object_unref (cell); + e_table_extras_add_cell (extras, "dateedit", popup_cell); memo_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); - e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell), - e_memo_table_get_current_time, - memo_table, NULL); + e_cell_date_edit_set_get_time_callback ( + E_CELL_DATE_EDIT (popup_cell), + e_memo_table_get_current_time, memo_table, NULL); /* Sorting */ - e_table_extras_add_compare (extras, "date-compare", - memo_table_date_compare_cb); + e_table_extras_add_compare ( + extras, "date-compare", memo_table_date_compare_cb); /* Create pixmaps */ @@ -324,37 +370,34 @@ memo_table_init (EMemoTable *memo_table) } cell = e_cell_toggle_new (0, E_MEMO_MODEL_NUM_ICONS, icon_pixbufs); - e_table_extras_add_cell(extras, "icon", cell); - e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); + e_table_extras_add_cell (extras, "icon", cell); + e_table_extras_add_pixbuf (extras, "icon", icon_pixbufs[0]); /* Create the table */ - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-memo-table.etspec", - NULL); - table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (memo_table->model), - extras, - etspecfile, - NULL); + 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); + gtk_table_attach ( + GTK_TABLE (memo_table), widget, 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + memo_table->etable = widget; + gtk_widget_show (widget); g_free (etspecfile); - /* FIXME: this causes a message from GLib about 'extras' having only a floating - reference */ - /* g_object_unref (extras); */ - - memo_table->etable = table; - gtk_table_attach (GTK_TABLE (memo_table), table, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (table); - - - e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table)); - g_signal_connect (e_table, "double_click", G_CALLBACK (e_memo_table_on_double_click), memo_table); - g_signal_connect (e_table, "right_click", G_CALLBACK (e_memo_table_on_right_click), memo_table); - g_signal_connect (e_table, "key_press", G_CALLBACK (e_memo_table_on_key_press), memo_table); - g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_memo_table_on_popup_menu), memo_table); + table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); + g_signal_connect_swapped ( + table, "double-click", + G_CALLBACK (memo_table_double_click_cb), memo_table); + g_signal_connect_swapped ( + table, "popup_menu", + G_CALLBACK (memo_table_popup_menu_cb), memo_table); + g_signal_connect_swapped ( + table, "right-click", + G_CALLBACK (memo_table_right_click_cb), memo_table); - a11y = gtk_widget_get_accessible (GTK_WIDGET(e_table)); + a11y = gtk_widget_get_accessible (GTK_WIDGET (table)); if (a11y) atk_object_set_name (a11y, _("Memos")); } @@ -441,20 +484,13 @@ e_memo_table_get_model (EMemoTable *memo_table) ETable * e_memo_table_get_table (EMemoTable *memo_table) { - g_return_val_if_fail (memo_table != NULL, NULL); - g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL); + ETableScrolled *table_scrolled; - return e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)); -} + g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL); -void -e_memo_table_open_selected (EMemoTable *memo_table) -{ - ECalModelComponent *comp_data; + table_scrolled = E_TABLE_SCROLLED (memo_table->etable); - comp_data = get_selected_comp (memo_table); - if (comp_data != NULL) - open_memo (memo_table, comp_data); + return e_table_scrolled_get_table (table_scrolled); } /* Used from e_table_selected_row_foreach(); puts the selected row number in an @@ -479,7 +515,8 @@ get_selected_comp (EMemoTable *memo_table) ETable *etable; int row; - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)); + etable = e_memo_table_get_table (memo_table); + if (e_table_selected_count (etable) != 1) return NULL; @@ -511,30 +548,17 @@ add_uid_cb (int model_row, gpointer data) closure->objects = g_slist_prepend (closure->objects, comp_data); } -static GSList * -get_selected_objects (EMemoTable *memo_table) -{ - struct get_selected_uids_closure closure; - ETable *etable; - - closure.memo_table = memo_table; - closure.objects = NULL; - - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)); - e_table_selected_row_foreach (etable, add_uid_cb, &closure); - - return closure.objects; -} - /* Deletes all of the selected components in the table */ static void delete_selected_components (EMemoTable *memo_table) { GSList *objs, *l; + const gchar *status_message; - objs = get_selected_objects (memo_table); + objs = e_memo_table_get_selected (memo_table); - e_memo_table_set_status_message (memo_table, _("Deleting selected objects")); + status_message = _("Deleting selected objects"); + memo_table_emit_status_message (memo_table, status_message); for (l = objs; l; l = l->next) { ECalModelComponent *comp_data = (ECalModelComponent *) l->data; @@ -546,7 +570,7 @@ delete_selected_components (EMemoTable *memo_table) g_clear_error (&error); } - e_memo_table_set_status_message (memo_table, NULL); + memo_table_emit_status_message (memo_table, NULL); g_slist_free (objs); } @@ -563,7 +587,17 @@ delete_selected_components (EMemoTable *memo_table) GSList * e_memo_table_get_selected (EMemoTable *memo_table) { - return get_selected_objects(memo_table); + struct get_selected_uids_closure closure; + ETable *etable; + + closure.memo_table = memo_table; + closure.objects = NULL; + + etable = e_memo_table_get_table (memo_table); + + e_table_selected_row_foreach (etable, add_uid_cb, &closure); + + return closure.objects; } /** @@ -583,7 +617,7 @@ e_memo_table_delete_selected (EMemoTable *memo_table) g_return_if_fail (memo_table != NULL); g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)); + etable = e_memo_table_get_table (memo_table); n_selected = e_table_selected_count (etable); if (n_selected <= 0) @@ -694,7 +728,7 @@ e_memo_table_copy_clipboard (EMemoTable *memo_table) /* create temporary VCALENDAR object */ memo_table->tmp_vcal = e_cal_util_new_top_level (); - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)); + etable = e_memo_table_get_table (memo_table); e_table_selected_row_foreach (etable, copy_row_cb, memo_table); comp_str = icalcomponent_as_ical_string (memo_table->tmp_vcal); clipboard = gtk_widget_get_clipboard (GTK_WIDGET (memo_table), clipboard_atom); @@ -721,6 +755,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text) ECalComponent *comp; ECal *client; icalcomponent_kind kind; + const gchar *status_message; g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); @@ -740,7 +775,8 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text) client = e_cal_model_get_default_client (memo_table->model); - e_memo_table_set_status_message (memo_table, _("Updating objects")); + status_message = _("Updating objects"); + memo_table_emit_status_message (memo_table, _("Updating objects")); if (kind == ICAL_VCALENDAR_COMPONENT) { icalcomponent_kind child_kind; @@ -783,7 +819,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table, const gchar *text) g_object_unref (comp); } - e_memo_table_set_status_message (memo_table, NULL); + memo_table_emit_status_message (memo_table, NULL); } static void @@ -792,7 +828,7 @@ clipboard_paste_received_cb (GtkClipboard *clipboard, gpointer data) { EMemoTable *memo_table = E_MEMO_TABLE (data); - ETable *e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)); + ETable *e_table = e_memo_table_get_table (memo_table); GnomeCanvas *canvas = e_table->table_canvas; GnomeCanvasItem *item = GNOME_CANVAS (canvas)->focused_item; @@ -827,332 +863,44 @@ void e_memo_table_paste_clipboard (EMemoTable *memo_table) { GtkClipboard *clipboard; - g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - - - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (memo_table), clipboard_atom); - g_object_ref (memo_table); - - gtk_clipboard_request_contents (clipboard, - gdk_atom_intern (target_types[0].target, FALSE), - clipboard_paste_received_cb, memo_table); -} - -/* Opens a task in the task editor */ -static void -open_memo (EMemoTable *memo_table, ECalModelComponent *comp_data) -{ - CompEditor *medit; - const char *uid; - - uid = icalcomponent_get_uid (comp_data->icalcomp); - - medit = comp_editor_find_instance (uid); - if (medit == NULL) { - ECalComponent *comp; - CompEditorFlags flags = 0; - - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - - if (e_cal_component_has_organizer (comp)) - flags |= COMP_EDITOR_IS_SHARED; - - if (itip_organizer_is_user (comp, comp_data->client)) - flags |= COMP_EDITOR_USER_ORG; - - medit = memo_editor_new (comp_data->client, flags); - - comp_editor_edit_comp (medit, comp); - g_object_unref (comp); - } - - gtk_window_present (GTK_WINDOW (medit)); -} - -/* Opens the task in the specified row */ -static void -open_memo_by_row (EMemoTable *memo_table, int row) -{ - ECalModelComponent *comp_data; - - comp_data = e_cal_model_get_component_at (memo_table->model, row); - open_memo (memo_table, comp_data); -} - -static void -e_memo_table_on_double_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - EMemoTable *memo_table) -{ - open_memo_by_row (memo_table, row); -} - - -static void -e_memo_table_on_open_memo (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - ECalModelComponent *comp_data; - - comp_data = get_selected_comp (memo_table); - if (comp_data) - open_memo (memo_table, comp_data); -} -static void -e_memo_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - ECalModelComponent *comp_data; - char *filename; - char *ical_string; - - comp_data = get_selected_comp (memo_table); - if (comp_data == NULL) - return; - - filename = e_file_dialog_save (_("Save as..."), NULL); - if (filename == NULL) - return; - - ical_string = e_cal_get_component_as_string (comp_data->client, comp_data->icalcomp); - if (ical_string == NULL) { - g_warning ("Couldn't convert item to a string"); - return; - } - - e_write_file_uri (filename, ical_string); - g_free (ical_string); -} - -static void -e_memo_table_on_print_memo (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - ECalModelComponent *comp_data; - ECalComponent *comp; - - comp_data = get_selected_comp (memo_table); - if (comp_data == NULL) - return; - - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - print_comp (comp, comp_data->client, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); - - g_object_unref (comp); -} - -static void -e_memo_table_on_cut (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - - e_memo_table_cut_clipboard (memo_table); -} - -static void -e_memo_table_on_copy (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - - e_memo_table_copy_clipboard (memo_table); -} - -static void -e_memo_table_on_paste (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - - e_memo_table_paste_clipboard (memo_table); -} - -static void -e_memo_table_on_forward (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - ECalModelComponent *comp_data; - - comp_data = get_selected_comp (memo_table); - if (comp_data) { - ECalComponent *comp; - - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL, NULL, NULL); - - g_object_unref (comp); - } -} - -/* Opens the URL of the memo */ -static void -open_url_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - ECalModelComponent *comp_data; - icalproperty *prop; - - comp_data = get_selected_comp (memo_table); - if (!comp_data) - return; - - prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY); - if (!prop) - return; - - gnome_url_show (icalproperty_get_url (prop), NULL); -} - -/* Callback for the "delete tasks" menu item */ -static void -delete_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - EMemoTable *memo_table = E_MEMO_TABLE (data); - - e_memo_table_delete_selected (memo_table); -} - -static EPopupItem memos_popup_items [] = { - { E_POPUP_ITEM, "00.open", N_("_Open"), e_memo_table_on_open_memo, NULL, GTK_STOCK_OPEN, E_CAL_POPUP_SELECT_ONE }, - { E_POPUP_ITEM, "05.openweb", N_("Open _Web Page"), open_url_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_HASURL }, - { E_POPUP_ITEM, "10.saveas", N_("_Save As..."), e_memo_table_on_save_as, NULL, GTK_STOCK_SAVE_AS, E_CAL_POPUP_SELECT_ONE }, - { E_POPUP_ITEM, "20.print", N_("P_rint..."), e_memo_table_on_print_memo, NULL, GTK_STOCK_PRINT, E_CAL_POPUP_SELECT_ONE }, - - { E_POPUP_BAR, "30.bar" }, - - { E_POPUP_ITEM, "40.cut", N_("C_ut"), e_memo_table_on_cut, NULL, GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_EDITABLE }, - { E_POPUP_ITEM, "50.copy", N_("_Copy"), e_memo_table_on_copy, NULL, GTK_STOCK_COPY, 0, 0 }, - { E_POPUP_ITEM, "60.paste", N_("_Paste"), e_memo_table_on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE }, - - { E_POPUP_BAR, "70.bar" }, - - { E_POPUP_ITEM, "80.forward", N_("_Forward as iCalendar"), e_memo_table_on_forward, NULL, "mail-forward", E_CAL_POPUP_SELECT_ONE }, - - { E_POPUP_BAR, "90.bar" }, - - { E_POPUP_ITEM, "a0.delete", N_("_Delete"), delete_cb, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE }, - { E_POPUP_ITEM, "b0.deletemany", N_("_Delete Selected Memos"), delete_cb, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE }, -}; - -static void -emt_popup_free(EPopup *ep, GSList *items, void *data) -{ - g_slist_free(items); -} - -static gint -e_memo_table_show_popup_menu (ETable *table, - GdkEvent *gdk_event, - EMemoTable *memo_table) -{ - GtkMenu *menu; - GSList *selection, *l, *menus = NULL; - GPtrArray *events; - ECalPopup *ep; - ECalPopupTargetSelect *t; - int i; - - selection = get_selected_objects (memo_table); - if (!selection) - return TRUE; - - /** @HookPoint-ECalPopup: Tasks Table Context Menu - * @Id: org.gnome.evolution.tasks.table.popup - * @Class: org.gnome.evolution.calendar.popup:1.0 - * @Target: ECalPopupTargetSelect - * - * The context menu on the tasks table. - */ - ep = e_cal_popup_new("org.gnome.evolution.memos.table.popup"); - - events = g_ptr_array_new(); - for (l=selection;l;l=g_slist_next(l)) - g_ptr_array_add(events, e_cal_model_copy_component_data((ECalModelComponent *)l->data)); - g_slist_free(selection); - - t = e_cal_popup_target_new_select(ep, memo_table->model, events); - t->target.widget = (GtkWidget *)memo_table; - - for (i=0;i<sizeof(memos_popup_items)/sizeof(memos_popup_items[0]);i++) - menus = g_slist_prepend(menus, &memos_popup_items[i]); - e_popup_add_items((EPopup *)ep, menus, NULL, emt_popup_free, memo_table); - - menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); - - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, - gdk_event?gdk_event->button.time:gtk_get_current_event_time()); - - return TRUE; -} - -static gint -e_memo_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - EMemoTable *memo_table) -{ - return e_memo_table_show_popup_menu (table, event, memo_table); -} + g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); -static gboolean -e_memo_table_on_popup_menu (GtkWidget *widget, gpointer data) -{ - ETable *table = E_TABLE(widget); - g_return_val_if_fail(table, FALSE); + clipboard = gtk_widget_get_clipboard ( + GTK_WIDGET (memo_table), clipboard_atom); - return e_memo_table_show_popup_menu (table, NULL, - E_MEMO_TABLE(data)); -} - -static gint -e_memo_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - EMemoTable *memo_table) -{ - if (event->keyval == GDK_Delete) { - delete_cb (NULL, NULL, memo_table); - return TRUE; - } else if ((event->keyval == GDK_o) - &&(event->state & GDK_CONTROL_MASK)) { - open_memo_by_row (memo_table, row); - return TRUE; - } - - return FALSE; + gtk_clipboard_request_contents ( + clipboard, gdk_atom_intern (target_types[0].target, FALSE), + clipboard_paste_received_cb, g_object_ref (memo_table)); } /* Loads the state of the table (headers shown etc.) from the given file. */ void e_memo_table_load_state (EMemoTable *memo_table, - gchar *filename) + const gchar *filename) { - struct stat st; + ETable *table; g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); + g_return_if_fail (filename != NULL); - if (g_stat (filename, &st) == 0 && st.st_size > 0 - && S_ISREG (st.st_mode)) { - e_table_load_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)), filename); - } + table = e_memo_table_get_table (memo_table); + e_table_load_state (table, filename); } /* Saves the state of the table (headers shown etc.) to the given file. */ void -e_memo_table_save_state (EMemoTable *memo_table, - gchar *filename) +e_memo_table_save_state (EMemoTable *memo_table, + const gchar *filename) { + ETable *table; + g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); + g_return_if_fail (filename != NULL); - e_table_save_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (memo_table->etable)), - filename); + table = e_memo_table_get_table (memo_table); + e_table_save_state (table, filename); } /* Returns the current time, for the ECellDateEdit items. @@ -1190,31 +938,3 @@ static char *test[] = { }; #endif - -void -e_memo_table_set_status_message (EMemoTable *memo_table, - const gchar *message) -{ - EActivity *activity; - EShellView *shell_view; - - g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - - activity = memo_table->priv->activity; - shell_view = e_memo_table_get_shell_view (memo_table); - - if (message == NULL || *message == '\0') { - if (activity != NULL) { - e_activity_complete (activity); - g_object_unref (activity); - memo_table->priv->activity = NULL; - } - - } else if (activity == NULL) { - activity = e_activity_new (message); - memo_table->priv->activity = activity; - e_shell_view_add_activity (shell_view, activity); - - } else - e_activity_set_primary_text (activity, message); -} diff --git a/calendar/gui/e-memo-table.h b/calendar/gui/e-memo-table.h index 2c31ee5b02..fcd6b6ee97 100644 --- a/calendar/gui/e-memo-table.h +++ b/calendar/gui/e-memo-table.h @@ -85,17 +85,21 @@ struct _EMemoTable { struct _EMemoTableClass { GtkTableClass parent_class; - /* Notification signals */ - void (* user_created) (EMemoTable *memo_table); + /* Signals */ + void (*open_component) (EMemoTable *memo_table, + ECalModelComponent *comp_data); + void (*popup_event) (EMemoTable *memo_table, + GdkEvent *event); + void (*status_message) (EMemoTable *memo_table, + const gchar *message); + void (*user_created) (EMemoTable *memo_table); }; - GType e_memo_table_get_type (void); GtkWidget * e_memo_table_new (EShellView *shell_view); 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); -void e_memo_table_open_selected (EMemoTable *memo_table); void e_memo_table_delete_selected (EMemoTable *memo_table); GSList * e_memo_table_get_selected (EMemoTable *memo_table); @@ -107,12 +111,9 @@ void e_memo_table_paste_clipboard (EMemoTable *memo_table); /* These load and save the state of the table (headers shown etc.) to/from the given file. */ void e_memo_table_load_state (EMemoTable *memo_table, - gchar *filename); + const gchar *filename); void e_memo_table_save_state (EMemoTable *memo_table, - gchar *filename); - -void e_memo_table_set_status_message (EMemoTable *memo_table, - const gchar *message); + const gchar *filename); G_END_DECLS diff --git a/calendar/gui/e-memos.c b/calendar/gui/e-memos.c index 5e162f8a28..ed65be2e32 100644 --- a/calendar/gui/e-memos.c +++ b/calendar/gui/e-memos.c @@ -630,58 +630,6 @@ open_ecal (EMemos *memos, ECal *cal, gboolean only_if_exists, open_func of) } gboolean -e_memos_add_memo_source (EMemos *memos, ESource *source) -{ - EMemosPrivate *priv; - ECal *client; - const char *uid; - - g_return_val_if_fail (memos != NULL, FALSE); - g_return_val_if_fail (E_IS_MEMOS (memos), FALSE); - g_return_val_if_fail (E_IS_SOURCE (source), FALSE); - - priv = memos->priv; - - uid = e_source_peek_uid (source); - client = g_hash_table_lookup (priv->clients, uid); - if (client) { - /* We already have it */ - - return TRUE; - } else { - ESource *default_source; - - if (priv->default_client) { - default_source = e_cal_get_source (priv->default_client); - - /* We don't have it but the default client is it */ - if (!strcmp (e_source_peek_uid (default_source), uid)) - client = g_object_ref (priv->default_client); - } - - /* Create a new one */ - if (!client) { - client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL); - if (!client) - return FALSE; - } - } - - g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), memos); - g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), memos); - - /* add the client to internal structure */ - g_hash_table_insert (priv->clients, g_strdup (uid) , client); - priv->clients_list = g_list_prepend (priv->clients_list, client); - - g_signal_emit (memos, e_memos_signals[SOURCE_ADDED], 0, source); - - open_ecal (memos, client, FALSE, client_cal_opened_cb); - - return TRUE; -} - -gboolean e_memos_remove_memo_source (EMemos *memos, ESource *source) { EMemosPrivate *priv; diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index 732f031c1c..e32b8ca66a 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -880,57 +880,6 @@ set_status_message (ETasks *tasks, const char *message, ...) e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->tasks_view), msg_string, -1); } -/* Callback from the calendar client when an error occurs in the backend */ -static void -backend_error_cb (ECal *client, const char *message, gpointer data) -{ - ETasks *tasks; - GtkWidget *dialog; - char *urinopwd; - - tasks = E_TASKS (data); - - urinopwd = get_uri_without_password (e_cal_get_uri (client)); - - dialog = gtk_message_dialog_new ( - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Error on %s:\n %s"), - urinopwd, message); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (urinopwd); -} - -/* Callback from the calendar client when the backend dies */ -static void -backend_died_cb (ECal *client, gpointer data) -{ - ETasks *tasks; - ETasksPrivate *priv; - ESource *source; - - tasks = E_TASKS (data); - priv = tasks->priv; - - source = g_object_ref (e_cal_get_source (client)); - - priv->clients_list = g_list_remove (priv->clients_list, client); - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - g_signal_emit (tasks, e_tasks_signals[SOURCE_REMOVED], 0, source); - - e_calendar_table_set_status_message (E_CALENDAR_TABLE (e_tasks_get_calendar_table (tasks)), NULL, -1); - - e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))), - "calendar:tasks-crashed", NULL); - - g_object_unref (source); -} - /* Callback from the calendar client when the calendar is opened */ static void client_cal_opened_cb (ECal *ecal, ECalendarStatus status, ETasks *tasks) @@ -1137,58 +1086,6 @@ e_tasks_show_preview (ETasks *tasks, gboolean state) } gboolean -e_tasks_add_todo_source (ETasks *tasks, ESource *source) -{ - ETasksPrivate *priv; - ECal *client; - const char *uid; - - g_return_val_if_fail (tasks != NULL, FALSE); - g_return_val_if_fail (E_IS_TASKS (tasks), FALSE); - g_return_val_if_fail (E_IS_SOURCE (source), FALSE); - - priv = tasks->priv; - - uid = e_source_peek_uid (source); - client = g_hash_table_lookup (priv->clients, uid); - if (client) { - /* We already have it */ - - return TRUE; - } else { - ESource *default_source; - - if (priv->default_client) { - default_source = e_cal_get_source (priv->default_client); - - /* We don't have it but the default client is it */ - if (!strcmp (e_source_peek_uid (default_source), uid)) - client = g_object_ref (priv->default_client); - } - - /* Create a new one */ - if (!client) { - client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO); - if (!client) - return FALSE; - } - } - - g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), tasks); - g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), tasks); - - /* add the client to internal structure */ - g_hash_table_insert (priv->clients, g_strdup (uid) , client); - priv->clients_list = g_list_prepend (priv->clients_list, client); - - g_signal_emit (tasks, e_tasks_signals[SOURCE_ADDED], 0, source); - - open_ecal (tasks, client, FALSE, client_cal_opened_cb); - - return TRUE; -} - -gboolean e_tasks_remove_todo_source (ETasks *tasks, ESource *source) { ETasksPrivate *priv; |