diff options
Diffstat (limited to 'calendar')
47 files changed, 2602 insertions, 2296 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 0651f0253f..7cf356add8 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -47,29 +47,19 @@ etspec_DATA = \ privsolib_LTLIBRARIES = libcal-gui.la # Removed from SOURCES -# cal-search-bar.c +# cal-search-bar.c # cal-search-bar.h -# calendar-commands.c -# calendar-commands.h -# comp-editor-factory.c -# comp-editor-factory.h -# e-calendar-view.c -# e-calendar-view.h -# e-calendar-table.c -# e-calendar-table.h -# e-memos.c -# e-memos.h -# e-tasks.c -# e-tasks.h -# gnome-cal.c -# gnome-cal.h # main.c # migration.c # migration.h -# tasks-control.c -# tasks-control.h libcal_gui_la_SOURCES = \ + e-calendar-view.c \ + e-calendar-view.h \ + e-calendar-table.c \ + e-calendar-table.h \ + gnome-cal.c \ + gnome-cal.h \ calendar-config.c \ calendar-config.h \ calendar-config-keys.h \ @@ -79,8 +69,6 @@ libcal_gui_la_SOURCES = \ calendar-view-factory.h \ comp-util.c \ comp-util.h \ - control-factory.c \ - control-factory.h \ e-alarm-list.c \ e-alarm-list.h \ e-cal-component-preview.c \ @@ -108,6 +96,8 @@ libcal_gui_la_SOURCES = \ e-cal-model-memos.h \ e-calendar-table-config.c \ e-calendar-table-config.h \ + e-calendar-selector.c \ + e-calendar-selector.h \ e-cell-date-edit-config.c \ e-cell-date-edit-config.h \ e-cell-date-edit-text.h \ @@ -145,6 +135,8 @@ libcal_gui_la_SOURCES = \ e-meeting-types.h \ e-meeting-utils.c \ e-meeting-utils.h \ + e-memo-preview.c \ + e-memo-preview.h \ e-memo-table.c \ e-memo-table.h \ e-memo-table-config.c \ @@ -184,9 +176,6 @@ libcal_gui_la_SOURCES = \ weekday-picker.c \ weekday-picker.h -# REMOVED -# $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la - libcal_gui_la_LIBADD = \ $(WIN32_BOOTSTRAP_LIBS) \ $(top_builddir)/widgets/menus/libmenus.la \ @@ -198,6 +187,7 @@ libcal_gui_la_LIBADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/a11y/calendar/libevolution-calendar-a11y.la $(LIBSOUP_LIBS) \ $(CAMEL_LIBS) \ $(EVOLUTION_CALENDAR_LIBS) diff --git a/calendar/gui/calendar-view-factory.c b/calendar/gui/calendar-view-factory.c index ce76578563..b3f88dd43f 100644 --- a/calendar/gui/calendar-view-factory.c +++ b/calendar/gui/calendar-view-factory.c @@ -181,7 +181,7 @@ calendar_view_factory_new_view (GalViewFactory *factory, const char *name) * * Return value: The same value as @cal_view_factory. **/ -CalendarViewFactory * +GalViewFactory * calendar_view_factory_construct (CalendarViewFactory *cal_view_factory, GnomeCalendarViewType view_type) { @@ -194,7 +194,7 @@ calendar_view_factory_construct (CalendarViewFactory *cal_view_factory, priv->view_type = view_type; - return cal_view_factory; + return GAL_VIEW_FACTORY (cal_view_factory); } /** @@ -205,7 +205,7 @@ calendar_view_factory_construct (CalendarViewFactory *cal_view_factory, * * Return value: A newly-created calendar view factory. **/ -CalendarViewFactory * +GalViewFactory * calendar_view_factory_new (GnomeCalendarViewType view_type) { CalendarViewFactory *cal_view_factory; diff --git a/calendar/gui/calendar-view-factory.h b/calendar/gui/calendar-view-factory.h index 779e59809c..2f5b6f86de 100644 --- a/calendar/gui/calendar-view-factory.h +++ b/calendar/gui/calendar-view-factory.h @@ -57,10 +57,10 @@ typedef struct { GType calendar_view_factory_get_type (void); -CalendarViewFactory *calendar_view_factory_construct (CalendarViewFactory *cal_view_factory, +GalViewFactory *calendar_view_factory_construct (CalendarViewFactory *cal_view_factory, GnomeCalendarViewType view_type); -CalendarViewFactory *calendar_view_factory_new (GnomeCalendarViewType view_type); +GalViewFactory *calendar_view_factory_new (GnomeCalendarViewType view_type); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 430b559948..14d20b1b86 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -274,6 +274,7 @@ struct _drop_data { static void drop_action(CompEditor *editor, GdkDragContext *context, guint32 action, GtkSelectionData *selection, guint info, guint time) { +#if 0 /* KILL-BONOBO */ char *tmp, *str, **urls; CamelMimePart *mime_part; CamelStream *stream; @@ -460,6 +461,7 @@ drop_action(CompEditor *editor, GdkDragContext *context, guint32 action, GtkSele printf("Drag finished, success %d delete %d\n", success, delete); gtk_drag_finish(context, success, delete, time); +#endif } static void diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 6534a562f0..5556ff8618 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -58,7 +58,6 @@ #include "dialogs/recur-comp.h" #include "comp-util.h" #include "itip-utils.h" -#include "calendar-commands.h" #include "calendar-config.h" #include "goto.h" #include "misc.h" diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 61c43bae26..ff245aad2a 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -33,20 +33,17 @@ #include <sys/stat.h> #include <unistd.h> -#include <glib.h> #include <glib/gi18n.h> #include <glib/gstdio.h> -#include <gnome.h> -#include <gtk/gtktooltip.h> -#include <misc/e-gui-utils.h> +#include <widgets/misc/e-gui-utils.h> #include <table/e-cell-checkbox.h> #include <table/e-cell-toggle.h> #include <table/e-cell-text.h> #include <table/e-cell-combo.h> #include <e-util/e-dialog-utils.h> #include <e-util/e-util-private.h> -#include <misc/e-cell-date-edit.h> -#include <misc/e-cell-percent.h> +#include <widgets/misc/e-cell-date-edit.h> +#include <widgets/misc/e-cell-percent.h> #include <libecal/e-cal-time-util.h> #include <libedataserver/e-time-utils.h> @@ -58,11 +55,9 @@ #include "e-calendar-table.h" #include "e-calendar-view.h" #include "e-cell-date-edit-text.h" -#include "e-comp-editor-registry.h" #include "print.h" #include <e-util/e-icon-factory.h> #include "e-cal-popup.h" -#include "e-tasks.h" #include "misc.h" #define E_CALENDAR_TABLE_GET_PRIVATE(obj) \ @@ -97,12 +92,7 @@ static GtkTargetEntry target_types[] = { static guint n_target_types = G_N_ELEMENTS (target_types); -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); - -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); +static struct tm e_calendar_table_get_current_time (ECellDateEdit *ecde, gpointer data); static gpointer parent_class; static guint signals[LAST_SIGNAL]; @@ -171,6 +161,69 @@ calendar_table_date_compare_cb (gconstpointer a, return icaltime_compare (dv1->tt, tt); } +static gint +calendar_table_percent_compare_cb (gconstpointer a, + gconstpointer b) +{ + int percent1 = GPOINTER_TO_INT (a); + int percent2 = GPOINTER_TO_INT (b); + + return (percent1 < percent2) ? -1 : (percent1 > percent2); +} + +static gint +calendar_table_priority_compare_cb (gconstpointer a, + gconstpointer b) +{ + int priority1, priority2; + + priority1 = e_cal_util_priority_from_string ((const char*) a); + priority2 = e_cal_util_priority_from_string ((const char*) b); + + /* We change undefined priorities so they appear after 'Low'. */ + if (priority1 <= 0) + priority1 = 10; + if (priority2 <= 0) + priority2 = 10; + + /* We'll just use the ordering of the priority values. */ + return (priority1 < priority2) ? -1 : (priority1 > priority2); +} + +static gint +calendar_table_status_compare_cb (gconstpointer a, + gconstpointer b) +{ + const gchar *string_a = a; + const gchar *string_b = b; + gint status_a = -2; + gint status_b = -2; + + if (string_a == NULL || *string_a == '\0') + status_a = -1; + else if (!g_utf8_collate (string_a, _("Not Started"))) + status_a = 0; + else if (!g_utf8_collate (string_a, _("In Progress"))) + status_a = 1; + else if (!g_utf8_collate (string_a, _("Completed"))) + status_a = 2; + else if (!g_utf8_collate (string_a, _("Canceled"))) + status_a = 3; + + if (string_b == NULL || *string_b == '\0') + status_b = -1; + else if (!g_utf8_collate (string_b, _("Not Started"))) + status_b = 0; + else if (!g_utf8_collate (string_b, _("In Progress"))) + status_b = 1; + else if (!g_utf8_collate (string_b, _("Completed"))) + status_b = 2; + else if (!g_utf8_collate (string_b, _("Canceled"))) + status_b = 3; + + return (status_a < status_b) ? -1 : (status_a > status_b); +} + static void calendar_table_double_click_cb (ECalendarTable *cal_table, gint row, @@ -184,6 +237,209 @@ calendar_table_double_click_cb (ECalendarTable *cal_table, } static gboolean +calendar_table_query_tooltip_cb (ECalendarTable *cal_table, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip) +{ + ECalModelComponent *comp_data; + int row = -1, col = -1; + GtkWidget *box, *l, *w; + GtkStyle *style = gtk_widget_get_default_style (); + char *tmp; + const char *str; + GString *tmp2; + char buff[1001]; + gboolean free_text = FALSE; + ECalComponent *new_comp; + ECalComponentOrganizer organizer; + ECalComponentDateTime dtstart, dtdue; + icalcomponent *clone; + icaltimezone *zone, *default_zone; + GSList *desc, *p; + int len; + ETable *etable; + ESelectionModel *esm; + struct tm tmp_tm; + + if (keyboard_mode) + return FALSE; + + etable = e_calendar_table_get_table (cal_table); + e_table_get_mouse_over_cell (etable, x, y, &row, &col); + if (row == -1 || !etable) + return FALSE; + + /* Respect sorting option; the 'e_table_get_mouse_over_cell' + * returns sorted row, not the model one. */ + esm = e_table_get_selection_model (etable); + 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); + if (!comp_data || !comp_data->icalcomp) + return FALSE; + + new_comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + if (!e_cal_component_set_icalcomponent (new_comp, clone)) { + g_object_unref (new_comp); + return FALSE; + } + + box = gtk_vbox_new (FALSE, 0); + + str = e_calendar_view_get_icalcomponent_summary ( + comp_data->client, comp_data->icalcomp, &free_text); + if (!(str && *str)) { + if (free_text) + g_free ((char *)str); + free_text = FALSE; + str = _("* No Summary *"); + } + + l = gtk_label_new (NULL); + tmp = g_markup_printf_escaped ("<b>%s</b>", str); + gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); + gtk_label_set_markup (GTK_LABEL (l), tmp); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + w = gtk_event_box_new (); + + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); + gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); + g_free (tmp); + + if (free_text) + g_free ((char *)str); + free_text = FALSE; + + w = gtk_event_box_new (); + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); + + l = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); + w = l; + + e_cal_component_get_organizer (new_comp, &organizer); + if (organizer.cn) { + char *ptr ; + ptr = strchr( organizer.value, ':'); + + if (ptr) { + ptr++; + /* To Translators: It will display "Organizer: NameOfTheUser <email@ofuser.com>" */ + tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); + } else { + /* With SunOne accounts, there may be no ':' in organiser.value */ + tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); + } + + l = gtk_label_new (tmp); + gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + g_free (tmp); + } + + 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); + + if (dtstart.tzid) { + zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); + if (!zone) + e_cal_get_timezone ( + comp_data->client, dtstart.tzid, &zone, NULL); + if (!zone) + zone = default_zone; + } else { + zone = NULL; + } + + tmp2 = g_string_new (""); + + if (dtstart.value) { + buff[0] = 0; + + tmp_tm = icaltimetype_to_tm_with_zone ( + dtstart.value, zone, default_zone); + e_time_format_date_and_time ( + &tmp_tm, calendar_config_get_24_hour_format (), + FALSE, FALSE, buff, 1000); + + if (buff [0]) { + g_string_append (tmp2, _("Start: ")); + g_string_append (tmp2, buff); + } + } + + if (dtdue.value) { + buff[0] = 0; + + tmp_tm = icaltimetype_to_tm_with_zone ( + dtdue.value, zone, default_zone); + e_time_format_date_and_time ( + &tmp_tm, calendar_config_get_24_hour_format (), + FALSE, FALSE, buff, 1000); + + if (buff [0]) { + if (tmp2->len) + g_string_append (tmp2, "; "); + + g_string_append (tmp2, _("Due: ")); + g_string_append (tmp2, buff); + } + } + + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + } + + g_string_free (tmp2, TRUE); + + e_cal_component_free_datetime (&dtstart); + e_cal_component_free_datetime (&dtdue); + + tmp2 = g_string_new (""); + e_cal_component_get_description_list (new_comp, &desc); + for (len = 0, p = desc; p != NULL; p = p->next) { + ECalComponentText *text = p->data; + + if (text->value != NULL) { + len += strlen (text->value); + g_string_append (tmp2, text->value); + if (len > 1024) { + g_string_set_size (tmp2, 1020); + g_string_append (tmp2, "..."); + break; + } + } + } + e_cal_component_free_text_list (desc); + + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); + } + + g_string_free (tmp2, TRUE); + + gtk_widget_show_all (box); + gtk_tooltip_set_custom (tooltip, box); + + g_object_unref (new_comp); + + return TRUE; +} +static gboolean calendar_table_popup_menu_cb (ECalendarTable *cal_table) { calendar_table_emit_popup_event (cal_table, NULL); @@ -288,7 +544,7 @@ calendar_table_class_init (ECalendarTableClass *class) G_TYPE_NONE, 1, E_TYPE_CAL_MODEL_COMPONENT); - signal[POPUP_EVENT] = g_signal_new ( + signals[POPUP_EVENT] = g_signal_new ( "popup-event", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, @@ -296,7 +552,7 @@ calendar_table_class_init (ECalendarTableClass *class) NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATUS_SCOPE); + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); signals[STATUS_MESSAGE] = g_signal_new ( "status-message", @@ -311,7 +567,7 @@ calendar_table_class_init (ECalendarTableClass *class) signals[USER_CREATED] = g_signal_new ( "user-created", G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (ECalendarTableClass, user_created), NULL, NULL, g_cclosure_marshal_VOID__VOID, @@ -331,7 +587,7 @@ calendar_table_init (ECalendarTable *cal_table) GdkPixbuf *pixbuf; GList *strings; AtkObject *a11y; - char *etspecfile; + gchar *etspecfile; cal_table->priv = E_CALENDAR_TABLE_GET_PRIVATE (cal_table); @@ -505,11 +761,11 @@ calendar_table_init (ECalendarTable *cal_table) e_table_extras_add_compare (extras, "date-compare", calendar_table_date_compare_cb); e_table_extras_add_compare (extras, "percent-compare", - percent_compare_cb); + calendar_table_percent_compare_cb); e_table_extras_add_compare (extras, "priority-compare", - priority_compare_cb); + calendar_table_priority_compare_cb); e_table_extras_add_compare (extras, "status-compare", - status_compare_cb); + calendar_table_status_compare_cb); /* Create pixmaps */ @@ -542,16 +798,16 @@ calendar_table_init (ECalendarTable *cal_table) 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_CALLBACK (calendar_table_double_click_cb), cal_table); + g_signal_connect_swapped ( + table, "query-tooltip", + G_CALLBACK (calendar_table_query_tooltip_cb), cal_table); g_signal_connect_swapped ( table, "popup-menu", - G_CALLBACK (calendar_table_popup_menu), cal_table); + G_CALLBACK (calendar_table_popup_menu_cb), 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); + G_CALLBACK (calendar_table_right_click_cb), cal_table); gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE); a11y = gtk_widget_get_accessible (GTK_WIDGET (table)); @@ -611,283 +867,6 @@ e_calendar_table_get_shell_view (ECalendarTable *cal_table) return cal_table->priv->shell_view; } -static gint -percent_compare_cb (gconstpointer a, gconstpointer b) -{ - int percent1 = GPOINTER_TO_INT (a); - int percent2 = GPOINTER_TO_INT (b); - int retval; - - if (percent1 > percent2) - retval = 1; - else if (percent1 < percent2) - retval = -1; - else - retval = 0; - - return retval; -} - -static gint -priority_compare_cb (gconstpointer a, gconstpointer b) -{ - int priority1, priority2; - - priority1 = e_cal_util_priority_from_string ((const char*) a); - priority2 = e_cal_util_priority_from_string ((const char*) b); - - /* We change undefined priorities so they appear after 'Low'. */ - if (priority1 <= 0) - priority1 = 10; - if (priority2 <= 0) - priority2 = 10; - - /* We'll just use the ordering of the priority values. */ - if (priority1 < priority2) - return -1; - else if (priority1 > priority2) - return 1; - else - return 0; -} - -static gint -status_from_string (const char *str) -{ - int status = -2; - - if (!str || !str[0]) - status = -1; - else if (!g_utf8_collate (str, _("Not Started"))) - status = 0; - else if (!g_utf8_collate (str, _("In Progress"))) - status = 1; - else if (!g_utf8_collate (str, _("Completed"))) - status = 2; - else if (!g_utf8_collate (str, _("Canceled"))) - status = 3; - - return status; -} - -static gint -status_compare_cb (gconstpointer a, gconstpointer b) -{ - int sa = status_from_string ((const char *)a); - int sb = status_from_string ((const char *)b); - - if (sa < sb) - return -1; - else if (sa > sb) - return 1; - - return 0; -} - -static void -get_time_as_text (struct icaltimetype *tt, icaltimezone *f_zone, icaltimezone *t_zone, char *buff, int buff_len) -{ - struct tm tmp_tm; - - buff [0] = 0; - - tmp_tm = icaltimetype_to_tm_with_zone (tt, f_zone, t_zone); - e_time_format_date_and_time (&tmp_tm, - calendar_config_get_24_hour_format (), - FALSE, FALSE, - buff, buff_len); -} - -static gboolean -query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data) -{ - ECalendarTable *cal_table; - ECalModelComponent *comp; - int row = -1, col = -1; - GtkWidget *box, *l, *w; - GtkStyle *style = gtk_widget_get_default_style (); - char *tmp; - const char *str; - GString *tmp2; - char buff[1001]; - gboolean free_text = FALSE; - ECalComponent *new_comp; - ECalComponentOrganizer organizer; - ECalComponentDateTime dtstart, dtdue; - icaltimezone *zone, *default_zone; - GSList *desc, *p; - int len; - ETable *etable; - ESelectionModel *esm; - - if (keyboard_mode) - return FALSE; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_CALENDAR_TABLE (user_data), FALSE); - g_return_val_if_fail (tooltip != NULL, FALSE); - - cal_table = E_CALENDAR_TABLE (user_data); - - etable = e_calendar_table_get_table (cal_table); - e_table_get_mouse_over_cell (etable, x, y, &row, &col); - if (row == -1 || !etable) - return FALSE; - - /* respect sorting option, the 'e_table_get_mouse_over_cell' returns sorted row, not the model one */ - esm = e_table_get_selection_model (etable); - if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter)) - row = e_sorter_sorted_to_model (esm->sorter, row); - - comp = e_cal_model_get_component_at (cal_table->model, row); - if (!comp || !comp->icalcomp) - return FALSE; - - new_comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (comp->icalcomp))) { - g_object_unref (new_comp); - return FALSE; - } - - box = gtk_vbox_new (FALSE, 0); - - str = e_calendar_view_get_icalcomponent_summary (comp->client, comp->icalcomp, &free_text); - if (!(str && *str)) { - if (free_text) - g_free ((char *)str); - free_text = FALSE; - str = _("* No Summary *"); - } - - l = gtk_label_new (NULL); - tmp = g_markup_printf_escaped ("<b>%s</b>", str); - gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); - gtk_label_set_markup (GTK_LABEL (l), tmp); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - w = gtk_event_box_new (); - - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); - gtk_container_add (GTK_CONTAINER (w), l); - gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); - g_free (tmp); - - if (free_text) - g_free ((char *)str); - free_text = FALSE; - - w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); - - l = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (w), l); - gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); - w = l; - - e_cal_component_get_organizer (new_comp, &organizer); - if (organizer.cn) { - char *ptr ; - ptr = strchr( organizer.value, ':'); - - if (ptr) { - ptr++; - /* To Translators: It will display "Organiser: NameOfTheUser <email@ofuser.com>" */ - tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); - } else { - /* With SunOne accounts, there may be no ':' in organiser.value */ - tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); - } - - l = gtk_label_new (tmp); - gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - g_free (tmp); - } - - 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); - - if (dtstart.tzid) { - zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); - if (!zone) - e_cal_get_timezone (comp->client, dtstart.tzid, &zone, NULL); - if (!zone) - zone = default_zone; - } else { - zone = NULL; - } - - tmp2 = g_string_new (""); - - if (dtstart.value) { - get_time_as_text (dtstart.value, zone, default_zone, buff, 1000); - - if (buff [0]) { - g_string_append (tmp2, _("Start: ")); - g_string_append (tmp2, buff); - } - } - - if (dtdue.value) { - get_time_as_text (dtdue.value, zone, default_zone, buff, 1000); - - if (buff [0]) { - if (tmp2->len) - g_string_append (tmp2, "; "); - - g_string_append (tmp2, _("Due: ")); - g_string_append (tmp2, buff); - } - } - - if (tmp2->len) { - l = gtk_label_new (tmp2->str); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - } - - g_string_free (tmp2, TRUE); - - e_cal_component_free_datetime (&dtstart); - e_cal_component_free_datetime (&dtdue); - - tmp2 = g_string_new (""); - e_cal_component_get_description_list (new_comp, &desc); - for (len = 0, p = desc; p != NULL; p = p->next) { - ECalComponentText *text = p->data; - - if (text->value != NULL) { - len += strlen (text->value); - g_string_append (tmp2, text->value); - if (len > 1024) { - g_string_set_size (tmp2, 1020); - g_string_append (tmp2, "..."); - break; - } - } - } - e_cal_component_free_text_list (desc); - - if (tmp2->len) { - l = gtk_label_new (tmp2->str); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - } - - g_string_free (tmp2, TRUE); - - gtk_widget_show_all (box); - gtk_tooltip_set_custom (tooltip, box); - - g_object_unref (new_comp); - - return TRUE; -} - - /** * e_calendar_table_get_model: * @cal_table: A calendar table. @@ -927,33 +906,6 @@ e_calendar_table_get_table (ECalendarTable *cal_table) return e_table_scrolled_get_table (table_scrolled); } -void -e_calendar_table_open_selected (ECalendarTable *cal_table) -{ - ECalModelComponent *comp_data; - icalproperty *prop; - - comp_data = e_calendar_table_get_selected_comp (cal_table); - prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); - if (comp_data != NULL) - e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, prop ? TRUE : FALSE); -} - -/** - * e_calendar_table_complete_selected: - * @cal_table: A calendar table - * - * Marks the selected items as completed - **/ -void -e_calendar_table_complete_selected (ECalendarTable *cal_table) -{ - g_return_if_fail (cal_table != NULL); - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - - mark_as_complete_cb (NULL, NULL, cal_table); -} - /* Used from e_table_selected_row_foreach(); puts the selected row number in an * int pointed to by the closure data. */ @@ -975,7 +927,7 @@ e_calendar_table_get_selected_comp (ECalendarTable *cal_table) ETable *etable; int row; - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); + etable = e_calendar_table_get_table (cal_table); if (e_table_selected_count (etable) != 1) return NULL; @@ -1007,30 +959,17 @@ add_uid_cb (int model_row, gpointer data) closure->objects = g_slist_prepend (closure->objects, comp_data); } -static GSList * -get_selected_objects (ECalendarTable *cal_table) -{ - struct get_selected_uids_closure closure; - ETable *etable; - - closure.cal_table = cal_table; - closure.objects = NULL; - - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_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 (ECalendarTable *cal_table) { GSList *objs, *l; + const gchar *status_message; - objs = get_selected_objects (cal_table); + objs = e_calendar_table_get_selected (cal_table); - e_calendar_table_set_status_message (cal_table, _("Deleting selected objects"), -1); + status_message = _("Deleting selected objects"); + calendar_table_emit_status_message (cal_table, status_message); for (l = objs; l; l = l->next) { ECalModelComponent *comp_data = (ECalModelComponent *) l->data; @@ -1042,7 +981,7 @@ delete_selected_components (ECalendarTable *cal_table) g_clear_error (&error); } - e_calendar_table_set_status_message (cal_table, NULL, -1); + calendar_table_emit_status_message (cal_table, NULL); g_slist_free (objs); } @@ -1106,7 +1045,7 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table) g_return_if_fail (cal_table != NULL); g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); + etable = e_calendar_table_get_table (cal_table); n_selected = e_table_selected_count (etable); if (n_selected <= 0) @@ -1178,7 +1117,16 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table) GSList * e_calendar_table_get_selected (ECalendarTable *cal_table) { - return get_selected_objects(cal_table); + struct get_selected_uids_closure closure; + ETable *etable; + + closure.cal_table = cal_table; + closure.objects = NULL; + + etable = e_calendar_table_get_table (cal_table); + e_table_selected_row_foreach (etable, add_uid_cb, &closure); + + return closure.objects; } /** @@ -1265,14 +1213,13 @@ e_calendar_table_copy_clipboard (ECalendarTable *cal_table) /* create temporary VCALENDAR object */ cal_table->tmp_vcal = e_cal_util_new_top_level (); - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); + etable = e_calendar_table_get_table (cal_table); e_table_selected_row_foreach (etable, copy_row_cb, cal_table); comp_str = icalcomponent_as_ical_string (cal_table->tmp_vcal); clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_table), clipboard_atom); if (!gtk_clipboard_set_with_data(clipboard, target_types, n_target_types, clipboard_get_calendar_cb, NULL, comp_str)) { - /* do not free this pointer, it owns libical */ /* g_free (comp_str); */ } else { @@ -1293,6 +1240,7 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text) ECalComponent *comp; ECal *client; icalcomponent_kind kind; + const gchar *status_message; g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); @@ -1314,7 +1262,8 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text) client = e_cal_model_get_default_client (cal_table->model); - e_calendar_table_set_status_message (cal_table, _("Updating objects"), -1); + status_message = _("Updating objects"); + calendar_table_emit_status_message (cal_table, _("Updating objects")); if (kind == ICAL_VCALENDAR_COMPONENT) { icalcomponent_kind child_kind; @@ -1359,7 +1308,7 @@ clipboard_get_calendar_data (ECalendarTable *cal_table, const gchar *text) g_object_unref (comp); } - e_calendar_table_set_status_message (cal_table, NULL, -1); + calendar_table_emit_status_message (cal_table, NULL); } static void @@ -1368,7 +1317,7 @@ clipboard_paste_received_cb (GtkClipboard *clipboard, gpointer data) { ECalendarTable *cal_table = E_CALENDAR_TABLE (data); - ETable *e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); + ETable *e_table = e_calendar_table_get_table (cal_table); GnomeCanvas *canvas = e_table->table_canvas; GnomeCanvasItem *item = GNOME_CANVAS (canvas)->focused_item; @@ -1403,366 +1352,15 @@ void e_calendar_table_paste_clipboard (ECalendarTable *cal_table) { GtkClipboard *clipboard; - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_table), clipboard_atom); - g_object_ref (cal_table); - - gtk_clipboard_request_contents (clipboard, - gdk_atom_intern (target_types[0].target, FALSE), - clipboard_paste_received_cb, cal_table); -} - -/* Opens the task in the specified row */ -static void -open_task_by_row (ECalendarTable *cal_table, int row) -{ - ECalModelComponent *comp_data; - icalproperty *prop; - - comp_data = e_cal_model_get_component_at (cal_table->model, row); - prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); - e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, prop ? TRUE : FALSE); -} - -static void -e_calendar_table_on_double_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - ECalendarTable *cal_table) -{ - open_task_by_row (cal_table, row); -} - -/* popup menu callbacks */ - -static void -e_calendar_table_on_open_task (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ECalModelComponent *comp_data; - icalproperty *prop; - - comp_data = e_calendar_table_get_selected_comp (cal_table); - prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); - if (comp_data) - e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, prop ? TRUE : FALSE); -} - -static void -e_calendar_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ECalModelComponent *comp_data; - char *filename; - char *ical_string; - comp_data = e_calendar_table_get_selected_comp (cal_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_calendar_table_on_print_task (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ECalModelComponent *comp_data; - ECalComponent *comp; - - comp_data = e_calendar_table_get_selected_comp (cal_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_calendar_table_on_cut (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - - e_calendar_table_cut_clipboard (cal_table); -} - -static void -e_calendar_table_on_copy (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - - e_calendar_table_copy_clipboard (cal_table); -} - -static void -e_calendar_table_on_paste (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - - e_calendar_table_paste_clipboard (cal_table); -} - -static void -e_calendar_table_on_assign (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ECalModelComponent *comp_data; - - comp_data = e_calendar_table_get_selected_comp (cal_table); - if (comp_data) - e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, TRUE); -} - -static void -e_calendar_table_on_forward (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ECalModelComponent *comp_data; - - comp_data = e_calendar_table_get_selected_comp (cal_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); - } -} - -struct AffectedComponents { - ECalendarTable *cal_table; - GSList *components; /* contains pointers to ECalModelComponent */ -}; - -/** - * get_selected_components_cb - * Helper function to fill list of selected components in ECalendarTable. - * This function is called from e_table_selected_row_foreach. - **/ -static void -get_selected_components_cb (int model_row, gpointer data) -{ - struct AffectedComponents *ac = (struct AffectedComponents *) data; - - if (!ac || !ac->cal_table) - return; - - ac->components = g_slist_prepend (ac->components, e_cal_model_get_component_at (E_CAL_MODEL (ac->cal_table->model), model_row)); -} - -/** - * do_for_selected_components - * Calls function func for all selected components in cal_table. - * - * @param cal_table Table with selected components of our interest - * @param func Function to be called on each selected component from cal_table. - * The first parameter of this function is a pointer to ECalModelComponent and - * the second parameter of this function is pointer to cal_table - **/ -static void -do_for_selected_components (ECalendarTable *cal_table, GFunc func) -{ - ETable *etable; - struct AffectedComponents ac; - - g_return_if_fail (cal_table != NULL); - - ac.cal_table = cal_table; - ac.components = NULL; - - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); - e_table_selected_row_foreach (etable, get_selected_components_cb, &ac); - - g_slist_foreach (ac.components, func, cal_table); - g_slist_free (ac.components); -} - -/** - * mark_comp_complete_cb - * Function used in call to @ref do_for_selected_components to mark each component as complete - **/ -static void -mark_comp_complete_cb (gpointer data, gpointer user_data) -{ - ECalendarTable *cal_table; - ECalModelComponent *comp_data; - - comp_data = (ECalModelComponent *) data; - cal_table = E_CALENDAR_TABLE (user_data); - - e_cal_model_tasks_mark_comp_complete (E_CAL_MODEL_TASKS (cal_table->model), comp_data); -} - -/** - * mark_comp_incomplete_cb - * Function used in call to @ref do_for_selected_components to mark each component as incomplete - **/ -static void -mark_comp_incomplete_cb (gpointer data, gpointer user_data) -{ - ECalendarTable *cal_table; - ECalModelComponent *comp_data; - - comp_data = (ECalModelComponent *) data; - cal_table = E_CALENDAR_TABLE (user_data); - - e_cal_model_tasks_mark_comp_incomplete (E_CAL_MODEL_TASKS (cal_table->model), comp_data); -} - -/* Callback used for the "mark tasks as incomplete" menu item */ -static void -mark_as_incomplete_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - do_for_selected_components (data, mark_comp_incomplete_cb); -} - -/* Callback used for the "mark tasks as complete" menu item */ -static void -mark_as_complete_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - do_for_selected_components (data, mark_comp_complete_cb); -} - -/* Opens the URL of the task */ -static void -open_url_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ECalModelComponent *comp_data; - icalproperty *prop; - - comp_data = e_calendar_table_get_selected_comp (cal_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); -} - -/* Opens a new task editor */ -static void -on_new_task (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - ETasks *tasks = g_object_get_data (G_OBJECT (cal_table), "tasks"); - - if (!tasks) - return; - - e_tasks_new_task (tasks); - -} - -/* Callback for the "delete tasks" menu item */ -static void -delete_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - ECalendarTable *cal_table = data; - - e_calendar_table_delete_selected (cal_table); -} - -static EPopupItem tasks_popup_items [] = { - { E_POPUP_ITEM, "00.newtask", N_("New _Task"), on_new_task, NULL, "stock_task", 0, 0}, - { E_POPUP_BAR, "01.bar" }, - - { E_POPUP_ITEM, "03.open", N_("_Open"), e_calendar_table_on_open_task, 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_calendar_table_on_save_as, NULL, GTK_STOCK_SAVE_AS, E_CAL_POPUP_SELECT_ONE }, - { E_POPUP_ITEM, "20.print", N_("P_rint..."), e_calendar_table_on_print_task, NULL, GTK_STOCK_PRINT, E_CAL_POPUP_SELECT_ONE }, - - { E_POPUP_BAR, "30.bar" }, - - { E_POPUP_ITEM, "40.cut", N_("C_ut"), e_calendar_table_on_cut, NULL, GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_EDITABLE }, - { E_POPUP_ITEM, "50.copy", N_("_Copy"), e_calendar_table_on_copy, NULL, GTK_STOCK_COPY, 0, 0 }, - { E_POPUP_ITEM, "60.paste", N_("_Paste"), e_calendar_table_on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE }, - - { E_POPUP_BAR, "70.bar" }, - - { E_POPUP_ITEM, "80.assign", N_("_Assign Task"), e_calendar_table_on_assign, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_ASSIGNABLE }, - { E_POPUP_ITEM, "90.forward", N_("_Forward as iCalendar"), e_calendar_table_on_forward, NULL, "mail-forward", E_CAL_POPUP_SELECT_ONE }, - { E_POPUP_ITEM, "a0.markonecomplete", N_("_Mark as Complete"), mark_as_complete_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTCOMPLETE}, - { E_POPUP_ITEM, "b0.markmanycomplete", N_("_Mark Selected Tasks as Complete"), mark_as_complete_cb, NULL, NULL, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTCOMPLETE }, - { E_POPUP_ITEM, "c0.markoneincomplete", N_("_Mark as Incomplete"), mark_as_incomplete_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_COMPLETE}, - { E_POPUP_ITEM, "d0.markmanyincomplete", N_("_Mark Selected Tasks as Incomplete"), mark_as_incomplete_cb, NULL, NULL, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_COMPLETE }, - - { E_POPUP_BAR, "e0.bar" }, - - { E_POPUP_ITEM, "f0.delete", N_("_Delete"), delete_cb, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE }, - { E_POPUP_ITEM, "g0.deletemany", N_("_Delete Selected Tasks"), delete_cb, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE }, -}; - -static void -ect_popup_free(EPopup *ep, GSList *items, void *data) -{ - g_slist_free(items); -} - -static gint -e_calendar_table_show_popup_menu (ETable *table, - GdkEvent *gdk_event, - ECalendarTable *cal_table) -{ - GtkMenu *menu; - GSList *selection, *l, *menus = NULL; - GPtrArray *events; - ECalPopup *ep; - ECalPopupTargetSelect *t; - int i; - - selection = get_selected_objects (cal_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.tasks.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, cal_table->model, events); - t->target.widget = (GtkWidget *)cal_table; - - for (i=0;i<sizeof(tasks_popup_items)/sizeof(tasks_popup_items[0]);i++) - menus = g_slist_prepend(menus, &tasks_popup_items[i]); - e_popup_add_items((EPopup *)ep, menus, NULL, ect_popup_free, cal_table); - - menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); + g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - 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()); + clipboard = gtk_widget_get_clipboard ( + GTK_WIDGET (cal_table), clipboard_atom); - return TRUE; + gtk_clipboard_request_contents ( + clipboard, gdk_atom_intern (target_types[0].target, FALSE), + clipboard_paste_received_cb, g_object_ref (cal_table)); } static void @@ -1853,29 +1451,31 @@ show_completed_rows (ECalModel *model, GList *clients_list, char *show_sexp, GPt /* Loads the state of the table (headers shown etc.) from the given file. */ void -e_calendar_table_load_state (ECalendarTable *cal_table, - gchar *filename) +e_calendar_table_load_state (ECalendarTable *cal_table, + const gchar *filename) { - struct stat st; + ETable *table; g_return_if_fail (E_IS_CALENDAR_TABLE (cal_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 (cal_table->etable)), filename); - } + table = e_calendar_table_get_table (cal_table); + e_table_load_state (table, filename); } /* Saves the state of the table (headers shown etc.) to the given file. */ void -e_calendar_table_save_state (ECalendarTable *cal_table, - gchar *filename) +e_calendar_table_save_state (ECalendarTable *cal_table, + const gchar *filename) { + ETable *table; + g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); + g_return_if_fail (filename != NULL); - e_table_save_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)), - filename); + table = e_calendar_table_get_table (cal_table); + e_table_save_state (table, filename); } /* Returns the current time, for the ECellDateEdit items. @@ -1905,15 +1505,6 @@ e_calendar_table_get_current_time (ECellDateEdit *ecde, gpointer data) return tmp_tm; } - -#ifdef TRANSLATORS_ONLY - -static char *test[] = { - N_("Click to add a task") -}; - -#endif - /** * 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 4394d24c03..c1828347f0 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -24,8 +24,8 @@ #define _E_CALENDAR_TABLE_H_ #include <shell/e-shell-view.h> -#include <table/e-table-scrolled.h> -#include <misc/e-cell-date-edit.h> +#include <widgets/table/e-table-scrolled.h> +#include <widgets/misc/e-cell-date-edit.h> #include "e-cal-model.h" /* @@ -94,13 +94,10 @@ struct _ECalendarTableClass { }; GType e_calendar_table_get_type (void); -GtkWidget * e_calendar_table_new (void); +GtkWidget * e_calendar_table_new (EShellView *shell_view); 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); -void e_calendar_table_open_selected (ECalendarTable *cal_table); -void e_calendar_table_complete_selected - (ECalendarTable *cal_table); void e_calendar_table_delete_selected(ECalendarTable *cal_table); GSList * e_calendar_table_get_selected (ECalendarTable *cal_table); @@ -112,9 +109,9 @@ void e_calendar_table_paste_clipboard(ECalendarTable *cal_table); /* These load and save the state of the table (headers shown etc.) to/from the given file. */ void e_calendar_table_load_state (ECalendarTable *cal_table, - gchar *filename); + const gchar *filename); void e_calendar_table_save_state (ECalendarTable *cal_table, - gchar *filename); + const gchar *filename); ECalModelComponent * e_calendar_table_get_selected_comp diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index b1c34bf8d4..346e1e9db5 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -41,12 +41,10 @@ #include "common/authentication.h" #include "calendar-commands.h" -#include "calendar-component.h" #include "calendar-config.h" #include "comp-util.h" #include "e-cal-model-calendar.h" #include "e-calendar-view.h" -#include "e-comp-editor-registry.h" #include "itip-utils.h" #include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" @@ -68,10 +66,6 @@ struct _ECalendarViewPrivate { /* The calendar model we are monitoring */ ECalModel *model; - /* Current activity (for the EActivityHandler, i.e. the status bar). */ - EActivityHandler *activity_handler; - guint activity_id; - /* The default category */ char *default_category; }; @@ -542,55 +536,6 @@ e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24 e_cal_model_set_use_24_hour_format (cal_view->priv->model, use_24_hour); } -void -e_calendar_view_set_activity_handler (ECalendarView *cal_view, EActivityHandler *activity_handler) -{ - ECalendarViewPrivate *priv; - - g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - - priv = cal_view->priv; - - priv->activity_handler = activity_handler; -} - -void -e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, int percent) -{ - ECalendarViewPrivate *priv; - - g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - - priv = cal_view->priv; - - if (!priv->activity_handler) - return; - - if (!message || !*message) { - if (priv->activity_id != 0) { - e_activity_handler_operation_finished (priv->activity_handler, priv->activity_id); - priv->activity_id = 0; - } - } else if (priv->activity_id == 0) { - char *client_id = g_strdup_printf ("%p", cal_view); - - priv->activity_id = e_activity_handler_operation_started ( - priv->activity_handler, client_id, message, TRUE); - - g_free (client_id); - } else { - double progress; - - if (percent < 0) - progress = -1.0; - else { - progress = ((double) percent / 100); - } - - e_activity_handler_operation_progressing (priv->activity_handler, priv->activity_id, message, progress); - } -} - GList * e_calendar_view_get_selected_events (ECalendarView *cal_view) { @@ -661,7 +606,9 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view) if (!selected) return; +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, _("Deleting selected objects"), -1); +#endif e_calendar_view_copy_clipboard (cal_view); for (l = selected; l != NULL; l = l->next) { @@ -706,7 +653,9 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view) g_object_unref (comp); } +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, NULL, -1); +#endif g_list_free (selected); } @@ -791,7 +740,9 @@ clipboard_get_text_cb (GtkClipboard *clipboard, const gchar *text, ECalendarView if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPONENT) return; +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, _("Updating objects"), -1); +#endif e_calendar_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end); if ((selected_time_end - selected_time_start) == 60 * 60 * 24) @@ -837,7 +788,9 @@ clipboard_get_text_cb (GtkClipboard *clipboard, const gchar *text, ECalendarView e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, in_top_canvas); } +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, NULL, -1); +#endif } void @@ -1174,7 +1127,7 @@ on_goto_today (EPopup *ep, EPopupItem *pitem, void *data) { ECalendarView *cal_view = data; - calendar_goto_today (cal_view->priv->calendar); + gnome_calendar_goto_today (cal_view->priv->calendar); } static void @@ -1199,9 +1152,11 @@ on_edit_appointment (EPopup *ep, EPopupItem *pitem, void *data) static void on_print (EPopup *ep, EPopupItem *pitem, void *data) { +#if 0 /* KILL-BONOBO */ ECalendarView *cal_view = data; calendar_command_print (cal_view->priv->calendar, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); +#endif } static void @@ -1334,16 +1289,20 @@ transfer_selected_items (ECalendarView *cal_view, gboolean remove_item) return; } +#if 0 /* KILL-BONOBO */ /* process all selected events */ if (remove_item) e_calendar_view_set_status_message (cal_view, _("Moving items"), -1); else e_calendar_view_set_status_message (cal_view, _("Copying items"), -1); +#endif for (l = selected; l != NULL; l = l->next) transfer_item_to ((ECalendarViewEvent *) l->data, dest_client, remove_item); +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, NULL, -1); +#endif /* free memory */ g_object_unref (destination_source); @@ -1969,7 +1928,7 @@ open_event_with_flags (ECalendarView *cal_view, ECal *client, icalcomponent *ica uid = icalcomponent_get_uid (icalcomp); - ce = e_comp_editor_registry_find (comp_editor_registry, uid); + ce = comp_editor_find_instance (uid); if (!ce) { ce = event_editor_new (client, flags); @@ -1981,8 +1940,6 @@ open_event_with_flags (ECalendarView *cal_view, ECal *client, icalcomponent *ica if (flags & COMP_EDITOR_MEETING) event_editor_show_meeting (EVENT_EDITOR (ce)); - e_comp_editor_registry_add (comp_editor_registry, ce, FALSE); - g_object_unref (comp); } diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index f1fb84cd3c..33ee6aa5e6 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -57,7 +57,6 @@ #include "print.h" #include "comp-util.h" #include "itip-utils.h" -#include "calendar-commands.h" #include "calendar-config.h" #include "goto.h" #include "e-cal-model-calendar.h" diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 75b3eccd6e..d85c10a28b 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -4,7 +4,6 @@ * Authors : * Damon Chaplin <damon@ximian.com> * Rodrigo Moya <rodrigo@ximian.com> - * Nathan Owens <pianocomp81@yahoo.com> * * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * @@ -25,7 +24,7 @@ /* * EMemoTable - displays the ECalComponent objects in a table (an ETable). - * Used for memos. + * Used for calendar events and tasks. */ #ifdef HAVE_CONFIG_H @@ -36,15 +35,17 @@ #include <unistd.h> #include <glib/gi18n.h> #include <glib/gstdio.h> -#include <gdk/gdkkeysyms.h> #include <widgets/misc/e-gui-utils.h> #include <table/e-cell-checkbox.h> #include <table/e-cell-toggle.h> #include <table/e-cell-text.h> #include <table/e-cell-combo.h> #include <e-util/e-dialog-utils.h> +#include <e-util/e-util-private.h> #include <widgets/misc/e-cell-date-edit.h> #include <widgets/misc/e-cell-percent.h> +#include <libecal/e-cal-time-util.h> +#include <libedataserver/e-time-utils.h> #include "calendar-config.h" #include "dialogs/delete-comp.h" @@ -52,11 +53,12 @@ #include "dialogs/memo-editor.h" #include "e-cal-model-memos.h" #include "e-memo-table.h" +#include "e-calendar-view.h" #include "e-cell-date-edit-text.h" #include "print.h" #include <e-util/e-icon-factory.h> -#include <e-util/e-util-private.h> #include "e-cal-popup.h" +#include "misc.h" #define E_MEMO_TABLE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -92,8 +94,6 @@ static guint n_target_types = G_N_ELEMENTS (target_types); static struct tm e_memo_table_get_current_time (ECellDateEdit *ecde, gpointer data); -static ECalModelComponent *get_selected_comp (EMemoTable *memo_table); - static gpointer parent_class; static guint signals[LAST_SIGNAL]; static GdkAtom clipboard_atom; @@ -174,6 +174,210 @@ memo_table_double_click_cb (EMemoTable *memo_table, } static gboolean +memo_table_query_tooltip_cb (EMemoTable *memo_table, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip) +{ + ECalModelComponent *comp_data; + int row = -1, col = -1; + GtkWidget *box, *l, *w; + GtkStyle *style = gtk_widget_get_default_style (); + char *tmp; + const char *str; + GString *tmp2; + char buff[1001]; + gboolean free_text = FALSE; + ECalComponent *new_comp; + ECalComponentOrganizer organizer; + ECalComponentDateTime dtstart, dtdue; + icalcomponent *clone; + icaltimezone *zone, *default_zone; + GSList *desc, *p; + int len; + ETable *etable; + ESelectionModel *esm; + struct tm tmp_tm; + + if (keyboard_mode) + return FALSE; + + etable = e_memo_table_get_table (memo_table); + e_table_get_mouse_over_cell (etable, x, y, &row, &col); + if (row == -1 || !etable) + return FALSE; + + /* Respect sorting option; the 'e_table_get_mouse_over_cell' + * returns sorted row, not the model one. */ + esm = e_table_get_selection_model (etable); + 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); + if (!comp_data || !comp_data->icalcomp) + return FALSE; + + new_comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + if (!e_cal_component_set_icalcomponent (new_comp, clone)) { + g_object_unref (new_comp); + return FALSE; + } + + box = gtk_vbox_new (FALSE, 0); + + str = e_calendar_view_get_icalcomponent_summary ( + comp_data->client, comp_data->icalcomp, &free_text); + if (!(str && *str)) { + if (free_text) + g_free ((char *)str); + free_text = FALSE; + str = _("* No Summary *"); + } + + l = gtk_label_new (NULL); + tmp = g_markup_printf_escaped ("<b>%s</b>", str); + gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); + gtk_label_set_markup (GTK_LABEL (l), tmp); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + w = gtk_event_box_new (); + + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); + gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); + g_free (tmp); + + if (free_text) + g_free ((char *)str); + free_text = FALSE; + + w = gtk_event_box_new (); + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); + + l = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); + w = l; + + e_cal_component_get_organizer (new_comp, &organizer); + if (organizer.cn) { + char *ptr ; + ptr = strchr( organizer.value, ':'); + + if (ptr) { + ptr++; + /* To Translators: It will display "Organizer: NameOfTheUser <email@ofuser.com>" */ + tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); + } else { + /* With SunOne accounts, there may be no ':' in organiser.value */ + tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); + } + + l = gtk_label_new (tmp); + gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + g_free (tmp); + } + + 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); + + if (dtstart.tzid) { + zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); + if (!zone) + e_cal_get_timezone ( + comp_data->client, dtstart.tzid, &zone, NULL); + if (!zone) + zone = default_zone; + } else { + zone = NULL; + } + + tmp2 = g_string_new (""); + + if (dtstart.value) { + buff[0] = 0; + + tmp_tm = icaltimetype_to_tm_with_zone ( + dtstart.value, zone, default_zone); + e_time_format_date_and_time ( + &tmp_tm, calendar_config_get_24_hour_format (), + FALSE, FALSE, buff, 1000); + + if (buff [0]) { + g_string_append (tmp2, _("Start: ")); + g_string_append (tmp2, buff); + } + } + + if (dtdue.value) { + buff[0] = 0; + + tmp_tm = icaltimetype_to_tm_with_zone ( + dtdue.value, zone, default_zone); + e_time_format_date_and_time ( + &tmp_tm, calendar_config_get_24_hour_format (), + FALSE, FALSE, buff, 1000); + + if (buff [0]) { + if (tmp2->len) + g_string_append (tmp2, "; "); + + g_string_append (tmp2, _("Due: ")); + g_string_append (tmp2, buff); + } + } + + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + } + + g_string_free (tmp2, TRUE); + + e_cal_component_free_datetime (&dtstart); + e_cal_component_free_datetime (&dtdue); + + tmp2 = g_string_new (""); + e_cal_component_get_description_list (new_comp, &desc); + for (len = 0, p = desc; p != NULL; p = p->next) { + ECalComponentText *text = p->data; + + if (text->value != NULL) { + len += strlen (text->value); + g_string_append (tmp2, text->value); + if (len > 1024) { + g_string_set_size (tmp2, 1020); + g_string_append (tmp2, "..."); + break; + } + } + } + e_cal_component_free_text_list (desc); + + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); + } + + g_string_free (tmp2, TRUE); + + gtk_widget_show_all (box); + gtk_tooltip_set_custom (tooltip, box); + + g_object_unref (new_comp); + + return TRUE; +} + +static gboolean memo_table_popup_menu_cb (EMemoTable *memo_table) { memo_table_emit_popup_event (memo_table, NULL); @@ -268,6 +472,17 @@ memo_table_class_init (EMemoTableClass *class) 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), @@ -391,11 +606,15 @@ memo_table_init (EMemoTable *memo_table) table, "double-click", G_CALLBACK (memo_table_double_click_cb), memo_table); g_signal_connect_swapped ( - table, "popup_menu", + table, "query-tooltip", + G_CALLBACK (memo_table_query_tooltip_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); + gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE); a11y = gtk_widget_get_accessible (GTK_WIDGET (table)); if (a11y) @@ -516,7 +735,6 @@ get_selected_comp (EMemoTable *memo_table) int row; etable = e_memo_table_get_table (memo_table); - if (e_table_selected_count (etable) != 1) return NULL; @@ -576,31 +794,6 @@ delete_selected_components (EMemoTable *memo_table) } /** - * e_memo_table_get_selected: - * @memo_table: - * - * Get the currently selected ECalModelComponent's on the table. - * - * Return value: A GSList of the components, which should be - * g_slist_free'd when finished with. - **/ -GSList * -e_memo_table_get_selected (EMemoTable *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; -} - -/** * e_memo_table_delete_selected: * @memo_table: A memo table. * @@ -645,6 +838,30 @@ e_memo_table_delete_selected (EMemoTable *memo_table) } /** + * e_memo_table_get_selected: + * @memo_table: + * + * Get the currently selected ECalModelComponent's on the table. + * + * Return value: A GSList of the components, which should be + * g_slist_free'd when finished with. + **/ +GSList * +e_memo_table_get_selected (EMemoTable *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; +} + +/** * e_memo_table_cut_clipboard: * @memo_table: A calendar table. * @@ -659,6 +876,26 @@ e_memo_table_cut_clipboard (EMemoTable *memo_table) delete_selected_components (memo_table); } +static void +clipboard_get_calendar_cb (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + guint info, + gpointer data) +{ + gchar *comp_str = (gchar *) data; + + switch (info) { + case TARGET_TYPE_VCALENDAR: + gtk_selection_data_set (selection_data, + gdk_atom_intern (target_types[info].target, FALSE), 8, + (const guchar *) comp_str, + (gint) strlen (comp_str)); + break; + default: + break; + } +} + /* callback for e_table_selected_row_foreach */ static void copy_row_cb (int model_row, gpointer data) @@ -690,26 +927,6 @@ copy_row_cb (int model_row, gpointer data) g_free (comp_str); } -static void -clipboard_get_calendar_cb (GtkClipboard *clipboard, - GtkSelectionData *selection_data, - guint info, - gpointer data) -{ - gchar *comp_str = (gchar *) data; - - switch (info) { - case TARGET_TYPE_VCALENDAR: - gtk_selection_data_set (selection_data, - gdk_atom_intern (target_types[info].target, FALSE), 8, - (const guchar *) comp_str, - (gint) strlen (comp_str)); - break; - default: - break; - } -} - /** * e_memo_table_copy_clipboard: * @memo_table: A calendar table. @@ -929,12 +1146,3 @@ e_memo_table_get_current_time (ECellDateEdit *ecde, gpointer data) return tmp_tm; } - - -#ifdef TRANSLATORS_ONLY - -static char *test[] = { - N_("Click to add a memo") -}; - -#endif diff --git a/calendar/gui/e-memo-table.h b/calendar/gui/e-memo-table.h index fcd6b6ee97..536c545633 100644 --- a/calendar/gui/e-memo-table.h +++ b/calendar/gui/e-memo-table.h @@ -1,5 +1,4 @@ /* - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -16,7 +15,6 @@ * * Authors: * Damon Chaplin <damon@ximian.com> - * Nathan Owens <pianocomp81@yahoo.com> * * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * @@ -74,11 +72,6 @@ struct _EMemoTable { /* Fields used for cut/copy/paste */ icalcomponent *tmp_vcal; - /* We should know which calendar has been used to create object, - * so store it here before emitting "user_created" signal and make - * it NULL just after the emit. */ - ECal *user_created_cal; - EMemoTablePrivate *priv; }; diff --git a/calendar/gui/e-memos.c b/calendar/gui/e-memos.c index ed65be2e32..99e9fb2e18 100644 --- a/calendar/gui/e-memos.c +++ b/calendar/gui/e-memos.c @@ -151,10 +151,6 @@ set_timezone (EMemos *memos) e_cal_set_default_timezone (client, zone, NULL); } - if (priv->default_client && e_cal_get_load_state (priv->default_client) == E_CAL_LOAD_LOADED) - /* FIXME Error checking */ - e_cal_set_default_timezone (priv->default_client, zone, NULL); - if (priv->preview) e_cal_component_memo_preview_set_default_timezone (E_CAL_COMPONENT_MEMO_PREVIEW (priv->preview), zone); } @@ -437,21 +433,9 @@ e_memos_init (EMemos *memos) priv->view_menus = NULL; priv->current_uid = NULL; priv->sexp = g_strdup ("#t"); - priv->default_client = NULL; update_view (memos); } -GtkWidget * -e_memos_new (void) -{ - EMemos *memos; - - memos = g_object_new (e_memos_get_type (), NULL); - - return GTK_WIDGET (memos); -} - - static void e_memos_destroy (GtkObject *object) { @@ -505,195 +489,6 @@ e_memos_destroy (GtkObject *object) (* GTK_OBJECT_CLASS (e_memos_parent_class)->destroy) (object); } -static void -set_status_message (EMemos *memos, const char *message, ...) -{ - EMemosPrivate *priv; - va_list args; - char sz[2048], *msg_string = NULL; - - if (message) { - va_start (args, message); - vsnprintf (sz, sizeof sz, message, args); - va_end (args); - msg_string = sz; - } - - priv = memos->priv; - - e_memo_table_set_status_message (E_MEMO_TABLE (priv->memos_view), msg_string); -} - -/* Callback from the calendar client when the calendar is opened */ -static void -client_cal_opened_cb (ECal *ecal, ECalendarStatus status, EMemos *memos) -{ - ECalModel *model; - ESource *source; - EMemosPrivate *priv; - - priv = memos->priv; - - source = e_cal_get_source (ecal); - - switch (status) { - case E_CALENDAR_STATUS_OK : - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL); - - set_status_message (memos, _("Loading memos")); - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)); - e_cal_model_add_client (model, ecal); - - set_timezone (memos); - set_status_message (memos, NULL); - break; - case E_CALENDAR_STATUS_BUSY : - break; - case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: - e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (memos))), "calendar:prompt-no-contents-offline-memos", NULL); - break; - default : - /* Make sure the source doesn't disappear on us */ - g_object_ref (source); - - priv->clients_list = g_list_remove (priv->clients_list, ecal); - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, memos); - - /* Do this last because it unrefs the client */ - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source); - - set_status_message (memos, NULL); - g_object_unref (source); - - break; - } -} - -static void -default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, EMemos *memos) -{ - ECalModel *model; - ESource *source; - EMemosPrivate *priv; - - priv = memos->priv; - - source = e_cal_get_source (ecal); - - switch (status) { - case E_CALENDAR_STATUS_OK : - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, default_client_cal_opened_cb, NULL); - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)); - - set_timezone (memos); - e_cal_model_set_default_client (model, ecal); - set_status_message (memos, NULL); - break; - case E_CALENDAR_STATUS_BUSY: - break; - default : - /* Make sure the source doesn't disappear on us */ - g_object_ref (source); - - priv->clients_list = g_list_remove (priv->clients_list, ecal); - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, memos); - - /* Do this last because it unrefs the client */ - g_hash_table_remove (priv->clients, e_source_peek_uid (source)); - - g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source); - - set_status_message (memos, NULL); - g_object_unref (priv->default_client); - priv->default_client = NULL; - g_object_unref (source); - - break; - } -} - -typedef void (*open_func) (ECal *, ECalendarStatus, EMemos *); - -static gboolean -open_ecal (EMemos *memos, ECal *cal, gboolean only_if_exists, open_func of) -{ - set_status_message (memos, _("Opening memos at %s"), e_cal_get_uri (cal)); - - g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (of), memos); - e_cal_open_async (cal, only_if_exists); - - return TRUE; -} - -gboolean -e_memos_remove_memo_source (EMemos *memos, ESource *source) -{ - EMemosPrivate *priv; - ECal *client; - ECalModel *model; - 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) - return TRUE; - - - priv->clients_list = g_list_remove (priv->clients_list, client); - g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, memos); - - model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view)); - e_cal_model_remove_client (model, client); - - g_hash_table_remove (priv->clients, uid); - - - g_signal_emit (memos, e_memos_signals[SOURCE_REMOVED], 0, source); - - return TRUE; -} - -gboolean -e_memos_set_default_source (EMemos *memos, ESource *source) -{ - EMemosPrivate *priv; - ECal *ecal; - - 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; - - ecal = g_hash_table_lookup (priv->clients, e_source_peek_uid (source)); - - if (priv->default_client) - g_object_unref (priv->default_client); - - if (ecal) { - priv->default_client = g_object_ref (ecal); - } else { - priv->default_client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL); - if (!priv->default_client) - return FALSE; - } - - open_ecal (memos, priv->default_client, FALSE, default_client_cal_opened_cb); - - return TRUE; -} - ECal * e_memos_get_default_client (EMemos *memos) { diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index e32b8ca66a..7860217045 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -1263,126 +1263,6 @@ e_tasks_delete_completed (ETasks *tasks) g_free (sexp); } -/* Callback used from the view collection when we need to display a new view */ -static void -display_view_cb (GalViewInstance *instance, GalView *view, gpointer data) -{ - ETasks *tasks; - - tasks = E_TASKS (data); - - if (GAL_IS_VIEW_ETABLE (view)) { - gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), e_table_scrolled_get_table (E_TABLE_SCROLLED (E_CALENDAR_TABLE (tasks->priv->tasks_view)->etable))); - } - - gtk_paned_set_position ((GtkPaned *)tasks->priv->paned, calendar_config_get_task_vpane_pos ()); -} - -/** - * e_tasks_setup_view_menus: - * @tasks: A tasks widget. - * @uic: UI controller to use for the menus. - * - * Sets up the #GalView menus for a tasks control. This function should be - * called from the Bonobo control activation callback for this tasks control. - * Also, the menus should be discarded using e_tasks_discard_view_menus(). - **/ -void -e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic) -{ - ETasksPrivate *priv; - GalViewFactory *factory; - ETableSpecification *spec; - char *dir0, *dir1, *filename; - static GalViewCollection *collection = NULL; - - g_return_if_fail (tasks != NULL); - g_return_if_fail (E_IS_TASKS (tasks)); - g_return_if_fail (uic != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); - - priv = tasks->priv; - - g_return_if_fail (priv->view_instance == NULL); - - g_return_if_fail (priv->view_instance == NULL); - g_return_if_fail (priv->view_menus == NULL); - - /* Create the view instance */ - - if (collection == NULL) { - collection = gal_view_collection_new (); - - gal_view_collection_set_title (collection, _("Tasks")); - - dir0 = g_build_filename (EVOLUTION_GALVIEWSDIR, - "tasks", - NULL); - dir1 = g_build_filename (tasks_component_peek_base_directory (tasks_component_peek ()), - "tasks", "views", NULL); - gal_view_collection_set_storage_directories (collection, - dir0, - dir1); - g_free (dir1); - g_free (dir0); - - /* Create the views */ - - spec = e_table_specification_new (); - filename = g_build_filename (EVOLUTION_ETSPECDIR, - "e-calendar-table.etspec", - NULL); - if (!e_table_specification_load_from_file (spec, filename)) - g_error ("Unable to load ETable specification file " - "for tasks"); - g_free (filename); - - factory = gal_view_factory_etable_new (spec); - g_object_unref (spec); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); - - /* Load the collection and create the menus */ - - gal_view_collection_load (collection); - } - - priv->view_instance = gal_view_instance_new (collection, NULL); - - priv->view_menus = gal_view_menus_new (priv->view_instance); - gal_view_menus_apply (priv->view_menus, uic, NULL); - g_signal_connect (priv->view_instance, "display_view", G_CALLBACK (display_view_cb), tasks); - display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), tasks); -} - -/** - * e_tasks_discard_view_menus: - * @tasks: A tasks widget. - * - * Discards the #GalView menus used by a tasks control. This function should be - * called from the Bonobo control deactivation callback for this tasks control. - * The menus should have been set up with e_tasks_setup_view_menus(). - **/ -void -e_tasks_discard_view_menus (ETasks *tasks) -{ - ETasksPrivate *priv; - - g_return_if_fail (tasks != NULL); - g_return_if_fail (E_IS_TASKS (tasks)); - - priv = tasks->priv; - - g_return_if_fail (priv->view_instance != NULL); - g_return_if_fail (priv->view_menus != NULL); - - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - - g_object_unref (priv->view_menus); - priv->view_menus = NULL; -} - void e_tasks_open_task_id (ETasks *tasks, const char *src_uid, diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 67dc931c68..0e1a424a57 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -55,7 +55,6 @@ #include "comp-util.h" #include "itip-utils.h" #include <libecal/e-cal-time-util.h> -#include "calendar-commands.h" #include "calendar-config.h" #include "print.h" #include "goto.h" diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index b20781186f..1fc02bd1ac 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -47,6 +47,7 @@ #include <libecal/e-cal-time-util.h> #include <widgets/menus/gal-view-factory-etable.h> #include <widgets/menus/gal-view-etable.h> +#include <widgets/menus/gal-view-instance.h> #include <widgets/menus/gal-define-views-dialog.h> #include "e-util/e-error.h" #include "e-util/e-util-private.h" @@ -67,8 +68,7 @@ #include "e-calendar-table-config.h" #include "e-memo-table-config.h" #include "gnome-cal.h" -#include "cal-search-bar.h" -#include "calendar-commands.h" +/*#include "cal-search-bar.h"*/ #include "calendar-config.h" #include "calendar-view.h" #include "calendar-view-factory.h" @@ -84,6 +84,8 @@ /* Private part of the GnomeCalendar structure */ struct _GnomeCalendarPrivate { + gpointer shell_view; /* weak pointer */ + /* The clients for display */ GHashTable *clients[E_CAL_SOURCE_TYPE_LAST]; @@ -119,9 +121,6 @@ struct _GnomeCalendarPrivate { GtkWidget *month_view; GtkWidget *list_view; - /* Activity */ - EActivityHandler *activity_handler; - /* plugin menu managers */ ECalMenu *calendar_menu; ECalMenu *taskpad_menu; @@ -158,7 +157,6 @@ struct _GnomeCalendarPrivate { /* View instance and menus for the control */ GalViewInstance *view_instance; - GalViewMenus *view_menus; /* Our current week start */ int week_start; @@ -182,7 +180,10 @@ struct _GnomeCalendarPrivate { ECal *user_created_cal; }; -/* Signal IDs */ +enum { + PROP_0, + PROP_SHELL_VIEW +}; enum { DATES_SHOWN_CHANGED, @@ -276,14 +277,77 @@ message_push (Message *msg) G_DEFINE_TYPE (GnomeCalendar, gnome_calendar, GTK_TYPE_VBOX) +static void +calendar_set_shell_view (GnomeCalendar *calendar, + EShellView *shell_view) +{ + g_return_if_fail (calendar->priv->shell_view == NULL); + + calendar->priv->shell_view = shell_view; + + g_object_add_weak_pointer ( + G_OBJECT (shell_view), + &calendar->priv->shell_view); +} + +static void +calendar_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + calendar_set_shell_view ( + GNOME_CALENDAR (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, gnome_calendar_get_shell_view ( + GNOME_CALENDAR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + /* Class initialization function for the gnome calendar */ static void gnome_calendar_class_init (GnomeCalendarClass *class) { - GtkObjectClass *object_class; + GObjectClass *object_class; + GtkObjectClass *gtk_object_class; GtkBindingSet *binding_set; - object_class = (GtkObjectClass *) class; + object_class = G_OBJECT_CLASS (class); + object_class->set_property = calendar_set_property; + object_class->get_property = calendar_get_property; + + gtk_object_class = (GtkObjectClass *) class; + + 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)); gnome_calendar_signals[DATES_SHOWN_CHANGED] = g_signal_new ("dates_shown_changed", @@ -396,7 +460,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) 1, G_TYPE_INT); - object_class->destroy = gnome_calendar_destroy; + gtk_object_class->destroy = gnome_calendar_destroy; class->dates_shown_changed = NULL; class->calendar_selection_changed = NULL; @@ -942,6 +1006,7 @@ update_query (GnomeCalendar *gcal) static void set_search_query (GnomeCalendar *gcal, const char *sexp) { +#if 0 /* KILL-BONOBO */ GnomeCalendarPrivate *priv; int i; time_t start, end; @@ -984,6 +1049,7 @@ set_search_query (GnomeCalendar *gcal, const char *sexp) /* Set the query on the task pad */ update_todo_view (gcal); +#endif } /* Returns the current time, for the ECalendarItem. */ @@ -1006,6 +1072,7 @@ get_current_time (ECalendarItem *calitem, gpointer data) return tmp_tm; } +#if 0 /* KILL-BONOBO */ /* Callback used when the sexp changes in the calendar search bar */ static void search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer data) @@ -1048,6 +1115,7 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category, model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)); e_cal_model_set_default_category (model, category); } +#endif static void view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal) @@ -1055,7 +1123,6 @@ view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal) g_signal_emit (gcal, gnome_calendar_signals[CALENDAR_SELECTION_CHANGED], 0); } - /** * gnome_calendar_emit_user_created_signal * Emits "user_created" signal on a gcal and use calendar as a store where was event created. @@ -1514,7 +1581,9 @@ categories_changed_cb (gpointer object, gpointer user_data) cat_list = g_list_remove (cat_list, cat_list->data); } +#if 0 /* KILL-BONOBO */ cal_search_bar_set_categories ((CalSearchBar *)priv->search_bar, cat_array); +#endif g_ptr_array_free (cat_array, TRUE); } @@ -1523,6 +1592,7 @@ categories_changed_cb (gpointer object, gpointer user_data) static void view_progress_cb (ECalModel *model, const char *message, int percent, ECalSourceType type, GnomeCalendar *gcal) { +#if 0 /* KILL-BONOBO */ if (type == E_CAL_SOURCE_TYPE_EVENT) { e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), message, percent); } else if (type == E_CAL_SOURCE_TYPE_TODO) { @@ -1530,11 +1600,13 @@ view_progress_cb (ECalModel *model, const char *message, int percent, ECalSource } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) { e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), message); } +#endif } static void view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, GnomeCalendar *gcal) { +#if 0 /* KILL-BONOBO */ if (type == E_CAL_SOURCE_TYPE_EVENT) { e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), NULL, -1); } else if (type == E_CAL_SOURCE_TYPE_TODO) { @@ -1542,7 +1614,7 @@ view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, Gno } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) { e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), NULL); } - +#endif } GtkWidget * @@ -1568,12 +1640,14 @@ setup_widgets (GnomeCalendar *gcal) priv = gcal->priv; +#if 0 /* KILL-BONOBO */ priv->search_bar = cal_search_bar_new (CAL_SEARCH_CALENDAR_DEFAULT); g_signal_connect (priv->search_bar, "sexp_changed", G_CALLBACK (search_bar_sexp_changed_cb), gcal); g_signal_connect (priv->search_bar, "category_changed", G_CALLBACK (search_bar_category_changed_cb), gcal); categories_changed_cb (NULL, gcal); +#endif gtk_widget_show (priv->search_bar); gtk_box_pack_start (GTK_BOX (gcal), priv->search_bar, FALSE, FALSE, 6); @@ -1633,22 +1707,26 @@ setup_widgets (GnomeCalendar *gcal) g_free (tmp); gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0); +#if 0 /* KILL-BONOBO */ priv->todo = e_calendar_table_new (); priv->todo_config = e_calendar_table_config_new (E_CALENDAR_TABLE (priv->todo)); gtk_paned_pack1 (GTK_PANED (priv->vpane), vbox, FALSE, TRUE); gtk_box_pack_end ((GtkBox *)vbox, priv->todo, TRUE, TRUE, 0); +#endif gtk_widget_show (priv->todo); gtk_widget_show (label); gtk_widget_show (vbox); gtk_widget_show (sep); +#if 0 /* KILL-BONOBO */ filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()), "TaskPad", NULL); e_calendar_table_load_state (E_CALENDAR_TABLE (priv->todo), filename); update_todo_view (gcal); g_free (filename); +#endif etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo)); g_signal_connect (etable->table_canvas, "focus_in_event", @@ -1757,6 +1835,7 @@ setup_widgets (GnomeCalendar *gcal) gtk_widget_show (GTK_WIDGET (priv->views[i])); } +#if 0 /* KILL-BONOBO */ /* Memo view */ vbox = gtk_vbox_new (FALSE, 0); label = gtk_label_new (NULL); @@ -1768,14 +1847,17 @@ setup_widgets (GnomeCalendar *gcal) priv->memo_config = e_memo_table_config_new (E_MEMO_TABLE (priv->memo)); gtk_paned_pack2 (GTK_PANED (priv->vpane), vbox, TRUE, TRUE); gtk_box_pack_end ((GtkBox *)vbox, priv->memo, TRUE, TRUE, 0); +#endif gtk_widget_show (priv->memo); gtk_widget_show (label); gtk_widget_show (vbox); +#if 0 /* KILL-BONOBO */ filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()), "MemoPad", NULL); e_memo_table_load_state (E_MEMO_TABLE (priv->memo), filename); +#endif update_memo_view (gcal); g_free (filename); @@ -1828,7 +1910,6 @@ gnome_calendar_init (GnomeCalendar *gcal) priv->memo_sexp = g_strdup ("#t"); priv->view_instance = NULL; - priv->view_menus = NULL; priv->visible_start = -1; priv->visible_end = -1; @@ -1891,17 +1972,21 @@ gnome_calendar_destroy (GtkObject *object) g_list_free (priv->notifications); priv->notifications = NULL; +#if 0 /* KILL-BONOBO */ /* Save the TaskPad layout. */ filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()), "TaskPad", NULL); e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename); g_free (filename); +#endif +#if 0 /* KILL-BONOBO */ /* Save the MemoPad layout. */ filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()), "MemoPad", NULL); e_memo_table_save_state (E_MEMO_TABLE (priv->memo), filename); g_free (filename); +#endif if (priv->dn_queries) { for (l = priv->dn_queries; l != NULL; l = l->next) { @@ -1944,11 +2029,6 @@ gnome_calendar_destroy (GtkObject *object) priv->update_marcus_bains_line_timeout = 0; } - if (priv->view_menus) { - g_object_unref (priv->view_menus); - priv->view_menus = NULL; - } - if (priv->calendar_menu) { g_object_unref (priv->calendar_menu); priv->calendar_menu = NULL; @@ -2403,6 +2483,7 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data) } +#if 0 /* KILL-BONOBO */ /** * gnome_calendar_setup_view_menus: * @gcal: A calendar. @@ -2494,33 +2575,7 @@ gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic) g_signal_connect (priv->view_instance, "display_view", G_CALLBACK (display_view_cb), gcal); display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), gcal); } - -/** - * gnome_calendar_discard_view_menus: - * @gcal: A calendar. - * - * Discards the #GalView menus used by a calendar. This function should be - * called from the Bonobo control deactivation callback for this calendar. The - * menus should have been set up with gnome_calendar_setup_view_menus(). - **/ -void -gnome_calendar_discard_view_menus (GnomeCalendar *gcal) -{ - GnomeCalendarPrivate *priv; - - g_return_if_fail (gcal != NULL); - - priv = gcal->priv; - - g_return_if_fail (priv->view_instance != NULL); - g_return_if_fail (priv->view_menus != NULL); - - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - - g_object_unref (priv->view_menus); - priv->view_menus = NULL; -} +#endif /* This is copied/moved from gal-view-instance, only the calendar uses this for a popup menu */ static void @@ -2716,6 +2771,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) source = e_cal_get_source (ecal); state = e_cal_get_load_state (ecal); +#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT: e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); @@ -2728,6 +2784,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) default: break; } +#endif if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED && source_type == E_CAL_SOURCE_TYPE_EVENT) auth_cal_forget_password (ecal); @@ -2775,6 +2832,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL); +#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT : msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal)); @@ -2810,6 +2868,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) default: g_return_if_reached (); } +#endif } static void @@ -2826,6 +2885,7 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar source = e_cal_get_source (ecal); state = e_cal_get_load_state (ecal); +#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT: e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); @@ -2839,6 +2899,7 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar default: break; } +#endif switch (status) { case E_CALENDAR_STATUS_OK: @@ -2906,6 +2967,7 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of zone = calendar_config_get_icaltimezone (); e_cal_set_default_timezone (cal, zone, NULL); +#if 0 /* KILL-BONOBO */ msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal)); switch (e_cal_get_source_type (cal)) { case E_CAL_SOURCE_TYPE_EVENT : @@ -2923,6 +2985,7 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of } g_free (msg); +#endif g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (of), gcal); e_cal_open_async (cal, only_if_exists); @@ -2977,6 +3040,7 @@ backend_died_cb (ECal *ecal, gpointer data) priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal); g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source)); +#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT: id = "calendar:calendar-crashed"; @@ -3004,6 +3068,7 @@ backend_died_cb (ECal *ecal, gpointer data) default: g_return_if_reached (); } +#endif g_object_unref (source); @@ -3024,11 +3089,15 @@ gnome_calendar_construct (GnomeCalendar *gcal) } GtkWidget * -gnome_calendar_new (void) +gnome_calendar_new (EShellView *shell_view) { GnomeCalendar *gcal; - gcal = g_object_new (gnome_calendar_get_type (), NULL); + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + gcal = g_object_new ( + GNOME_TYPE_CALENDAR, + "shell-view", shell_view, NULL); if (!gnome_calendar_construct (gcal)) { g_message (G_STRLOC ": Could not construct the calendar GUI"); @@ -3039,33 +3108,12 @@ gnome_calendar_new (void) return GTK_WIDGET (gcal); } -void -gnome_calendar_set_activity_handler (GnomeCalendar *cal, EActivityHandler *activity_handler) -{ - GnomeCalendarPrivate *priv; - int i; - - g_return_if_fail (cal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (cal)); - - priv = cal->priv; - - priv->activity_handler = activity_handler; - - for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) - e_calendar_view_set_activity_handler (priv->views[i], activity_handler); - - e_calendar_table_set_activity_handler (E_CALENDAR_TABLE (priv->todo), activity_handler); -} - -void -gnome_calendar_set_ui_component (GnomeCalendar *gcal, - BonoboUIComponent *ui_component) +EShellView * +gnome_calendar_get_shell_view (GnomeCalendar *calendar) { - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component)); + g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL); - e_search_bar_set_ui_component (E_SEARCH_BAR (gcal->priv->search_bar), ui_component); + return calendar->priv->shell_view; } /** @@ -3370,8 +3418,10 @@ gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend) comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomp); +#if 0 /* KILL-BONOBO */ category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar)); e_cal_component_set_categories (comp, category); +#endif dt.value = &itt; dt.tzid = icaltimezone_get_tzid (e_cal_model_get_timezone (model)); @@ -3860,7 +3910,9 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) " (make-time \"%s\"))", start, end); +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Purging"), -1); +#endif /* FIXME Confirm expunge */ for (l = priv->clients_list[E_CAL_SOURCE_TYPE_EVENT]; l != NULL; l = l->next) { @@ -3918,7 +3970,9 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) g_list_free (objects); } +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); +#endif g_free (sexp); g_free (start); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 92fe7c476d..6d06f2666b 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -27,6 +27,7 @@ #include <time.h> #include <gtk/gtk.h> +#include <shell/e-shell-view.h> #include <bonobo/bonobo-ui-component.h> #include <misc/e-calendar.h> #include <libecal/e-cal.h> @@ -105,7 +106,8 @@ struct _GnomeCalendarClass { GType gnome_calendar_get_type (void); GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal); -GtkWidget *gnome_calendar_new (void); +GtkWidget *gnome_calendar_new (EShellView *shell_view); +EShellView * gnome_calendar_get_shell_view (GnomeCalendar *calendar); void gnome_calendar_set_ui_component (GnomeCalendar *cal, BonoboUIComponent *ui_component); diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c index 877f40e3c8..fe10894a21 100644 --- a/calendar/gui/goto.c +++ b/calendar/gui/goto.c @@ -13,7 +13,6 @@ #include <libgnomeui/gnome-dialog.h> #include <glade/glade.h> #include "e-util/e-util-private.h" -#include "calendar-commands.h" #include "calendar-config.h" #include "tag-calendar.h" #include "goto.h" diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 616e1edbe7..b70225bbe6 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -1098,6 +1098,7 @@ append_cal_attachments (EMsgComposer *composer, ECalComponent *comp, GSList *attach_list) { +#if 0 /* KILL-BONOBO */ struct CalMimeAttach *mime_attach; GSList *l; @@ -1130,12 +1131,14 @@ append_cal_attachments (EMsgComposer *composer, g_free (mime_attach->description); g_free (mime_attach->encoded_data); } +#endif } gboolean itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, ECal *client, icalcomponent *zones, GSList *attachments_list, GList *users) { +#if 0 /* KILL-BONOBO */ EMsgComposer *composer; EComposerHeaderTable *table; EDestination **destinations; @@ -1183,9 +1186,11 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, table = e_msg_composer_get_header_table (composer); em_composer_utils_setup_default_callbacks (composer); +#if 0 /* KILL-BONOBO */ e_composer_header_table_set_subject (table, subject); e_composer_header_table_set_account_name (table, from); e_composer_header_table_set_destinations_to (table, destinations); +#endif e_destination_freev (destinations); @@ -1252,6 +1257,9 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, g_free (ical_string); return retval; +#endif + + return FALSE; } gboolean @@ -1262,6 +1270,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method, icalcomponent *zones, GSList *attachments_list) { +#if 0 /* KILL-BONOBO */ EMsgComposer *composer; EComposerHeaderTable *table; EDestination **destinations; @@ -1291,9 +1300,11 @@ reply_to_calendar_comp (ECalComponentItipMethod method, table = e_msg_composer_get_header_table (composer); em_composer_utils_setup_default_callbacks (composer); +#if 0 /* KILL-BONOBO */ e_composer_header_table_set_subject (table, subject); e_composer_header_table_set_account_name (table, from); e_composer_header_table_set_destinations_to (table, destinations); +#endif e_destination_freev (destinations); @@ -1416,6 +1427,9 @@ reply_to_calendar_comp (ECalComponentItipMethod method, g_free (subject); g_free (ical_string); return retval; +#endif + + return FALSE; } gboolean diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index fb3bb451d9..310e8d4351 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -77,10 +77,6 @@ typedef struct _MemosComponentView GtkWidget *source_selector; - BonoboControl *view_control; - BonoboControl *sidebar_control; - BonoboControl *statusbar_control; - GList *notifications; } MemosComponentView; @@ -90,8 +86,6 @@ struct _MemosComponentPrivate { ESourceList *source_list; GSList *source_selection; - GList *views; - ECal *create_ecal; GList *notifications; @@ -133,7 +127,7 @@ is_in_uids (GSList *uids, ESource *source) } static void -update_uris_for_selection (MemosComponentView *component_view) +source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *component_view) { GSList *selection, *l, *uids_selected = NULL; @@ -161,215 +155,6 @@ update_uris_for_selection (MemosComponentView *component_view) g_slist_free (uids_selected); } -static void -update_uri_for_primary_selection (MemosComponentView *component_view) -{ - ESource *source; - EMemoTable *cal_table; - ETable *etable; - - source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!source) - return; - - /* Set the default */ - e_memos_set_default_source (component_view->memos, source); - - cal_table = e_memos_get_calendar_table (component_view->memos); - etable = e_memo_table_get_table (cal_table); - - memos_control_sensitize_commands (component_view->view_control, component_view->memos, e_table_selected_count (etable)); - - /* Save the selection for next time we start up */ - calendar_config_set_primary_memos (e_source_peek_uid (source)); -} - -static void -update_selection (MemosComponentView *component_view) -{ - GSList *selection, *uids_selected, *l; - - d(g_message("memos-component.c: update_selection called");) - - /* Get the selection in gconf */ - uids_selected = calendar_config_get_memos_selected (); - - /* Remove any that aren't there any more */ - selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - - for (l = selection; l; l = l->next) { - ESource *source = l->data; - - if (!is_in_uids (uids_selected, source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - } - - e_source_selector_free_selection (selection); - - /* Make sure the whole selection is there */ - for (l = uids_selected; l; l = l->next) { - char *uid = l->data; - ESource *source; - - source = e_source_list_peek_source_by_uid (component_view->source_list, uid); - if (source) - e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - - g_free (uid); - } - g_slist_free (uids_selected); -} - -static void -update_primary_selection (MemosComponentView *component_view) -{ - ESource *source = NULL; - char *uid; - - uid = calendar_config_get_primary_memos (); - if (uid) { - source = e_source_list_peek_source_by_uid (component_view->source_list, uid); - g_free (uid); - } - - if (source) { - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source); - } else { - /* Try to create a default if there isn't one */ - source = e_source_list_peek_source_any (component_view->source_list); - if (source) - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source); - } - -} - - -/* Callbacks. */ -/* TODO: doesn't work! */ -static void -copy_memo_list_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - MemosComponentView *component_view = data; - ESource *selected_source; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!selected_source) - return; - - copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source, E_CAL_SOURCE_TYPE_JOURNAL); -} - -static void -delete_memo_list_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - MemosComponentView *component_view = data; - ESource *selected_source; - ECal *cal; - char *uri; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!selected_source) - return; - - if (e_error_run((GtkWindow *)gtk_widget_get_toplevel(ep->target->widget), - "calendar:prompt-delete-memo-list", e_source_peek_name(selected_source)) != GTK_RESPONSE_YES) - return; - - /* first, ask the backend to remove the memo list */ - uri = e_source_get_uri (selected_source); - cal = e_cal_model_get_client_for_uri ( - e_memo_table_get_model (E_MEMO_TABLE (e_memos_get_calendar_table (component_view->memos))), - uri); - if (!cal) - cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL); - g_free (uri); - if (cal) { - if (e_cal_remove (cal, NULL)) { - if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector), - selected_source)) { - e_memos_remove_memo_source (component_view->memos, selected_source); - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), - selected_source); - } - - e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); - e_source_list_sync (component_view->source_list, NULL); - } - } -} - -static EPopupItem emc_source_popups[] = { - { E_POPUP_ITEM, "10.new", N_("_New Memo List"), new_memo_list_cb, NULL, "stock_notes", 0, 0 }, - { E_POPUP_ITEM, "15.copy", N_("_Copy..."), copy_memo_list_cb, NULL, "edit-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY }, - - { E_POPUP_BAR, "20.bar" }, - { E_POPUP_ITEM, "20.delete", N_("_Delete"), delete_memo_list_cb, NULL, "edit-delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY }, - - { E_POPUP_BAR, "99.bar" }, - { E_POPUP_ITEM, "99.properties", N_("_Properties"), edit_memo_list_cb, NULL, "document-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY }, -}; - -static void -emc_source_popup_free(EPopup *ep, GSList *list, void *data) -{ - g_slist_free(list); -} - -static gboolean -popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, MemosComponentView *component_view) -{ - ECalPopup *ep; - ECalPopupTargetSource *t; - GSList *menus = NULL; - int i; - GtkMenu *menu; - - /** @HookPoint-ECalPopup: Memos Source Selector Context Menu - * @Id: org.gnome.evolution.memos.source.popup - * @Class: org.gnome.evolution.calendar.popup:1.0 - * @Target: ECalPopupTargetSource - * - * The context menu on the source selector in the memos window. - */ - ep = e_cal_popup_new("org.gnome.evolution.memos.source.popup"); - t = e_cal_popup_target_new_source(ep, selector); - t->target.widget = (GtkWidget *)component_view->memos; - - for (i=0;i<sizeof(emc_source_popups)/sizeof(emc_source_popups[0]);i++) - menus = g_slist_prepend(menus, &emc_source_popups[i]); - - e_popup_add_items((EPopup *)ep, menus, NULL,emc_source_popup_free, component_view); - - menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time()); - - return TRUE; -} - -static void -source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *component_view) -{ - update_uris_for_selection (component_view); -} - -static void -primary_source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *component_view) -{ - update_uri_for_primary_selection (component_view); -} - -static void -source_added_cb (EMemos *memos, ESource *source, MemosComponentView *component_view) -{ - e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source); -} - -static void -source_removed_cb (EMemos *memos, ESource *source, MemosComponentView *component_view) -{ - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); -} - /* Evolution::Component CORBA methods */ static void @@ -715,25 +500,6 @@ create_new_memo (MemosComponent *memo_component, gboolean is_assigned, MemosComp return TRUE; } -static void -create_local_item_cb (EUserCreatableItemsHandler *handler, const char *item_type_name, void *data) -{ - MemosComponent *memos_component = data; - MemosComponentPrivate *priv; - MemosComponentView *component_view = NULL; - GList *l; - - priv = memos_component->priv; - - if (strcmp (item_type_name, CREATE_MEMO_ID) == 0) { - create_new_memo (memos_component, FALSE, component_view); - } else if (strcmp (item_type_name, CREATE_SHARED_MEMO_ID) == 0) { - create_new_memo (memos_component, TRUE, component_view); - } else if (strcmp (item_type_name, CREATE_MEMO_LIST_ID) == 0) { - calendar_setup_new_memo_list (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (component_view->memos)))); - } -} - static MemosComponentView * create_component_view (MemosComponent *memos_component) { @@ -752,36 +518,16 @@ create_component_view (MemosComponent *memos_component) g_signal_connect (component_view->source_selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), memos_component); - /* Create main view */ - component_view->view_control = memos_control_new (); - if (!component_view->view_control) { - /* FIXME free memory */ - - return NULL; - } - component_view->memos = (EMemos *) bonobo_control_get_widget (component_view->view_control); component_view->table = e_memo_table_get_table (e_memos_get_calendar_table (component_view->memos)); component_view->model = E_TABLE_MODEL (e_memo_table_get_model (e_memos_get_calendar_table (component_view->memos))); - /* This signal is thrown if backends die - we update the selector */ - g_signal_connect (component_view->memos, "source_added", - G_CALLBACK (source_added_cb), component_view); - g_signal_connect (component_view->memos, "source_removed", - G_CALLBACK (source_removed_cb), component_view); - /* connect after setting the initial selections, or we'll get unwanted calls to calendar_control_sensitize_calendar_commands */ g_signal_connect (component_view->source_selector, "selection_changed", G_CALLBACK (source_selection_changed_cb), component_view); g_signal_connect (component_view->source_selector, "primary_selection_changed", G_CALLBACK (primary_source_selection_changed_cb), component_view); - g_signal_connect (component_view->source_selector, "popup_event", - G_CALLBACK (popup_event_cb), component_view); - - /* Load the selection from the last run */ - update_selection (component_view); - update_primary_selection (component_view); return component_view; } @@ -804,29 +550,6 @@ destroy_component_view (MemosComponentView *component_view) g_free (component_view); } -static void -impl_requestCreateItem (PortableServer_Servant servant, - const CORBA_char *item_type_name, - CORBA_Environment *ev) -{ - MemosComponent *memos_component = MEMOS_COMPONENT (bonobo_object_from_servant (servant)); - - if (strcmp (item_type_name, CREATE_MEMO_ID) == 0) { - if (!create_new_memo (memos_component, FALSE, NULL)) - bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed); - } - else if (strcmp (item_type_name, CREATE_MEMO_LIST_ID) == 0) { - /* FIXME Should we use the last opened window? */ - calendar_setup_new_memo_list (NULL); - } else if (strcmp (item_type_name, CREATE_SHARED_MEMO_ID) == 0) { - if (!create_new_memo (memos_component, TRUE, NULL)) - bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed); - } - else { - bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType); - } -} - /* GObject methods. */ static void @@ -857,17 +580,3 @@ impl_dispose (GObject *object) (* G_OBJECT_CLASS (parent_class)->dispose) (object); } - -static void -memos_component_class_init (MemosComponentClass *klass) -{ - POA_GNOME_Evolution_Component__epv *epv = &klass->epv; - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - epv->upgradeFromVersion = impl_upgradeFromVersion; - epv->requestCreateItem = impl_requestCreateItem; - - object_class->dispose = impl_dispose; -} diff --git a/calendar/gui/print.c b/calendar/gui/print.c index e68ec84a84..97e4734427 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -44,7 +44,6 @@ #include <e-util/e-print.h> #include <libecal/e-cal-time-util.h> #include <libecal/e-cal-component.h> -#include "calendar-commands.h" #include "calendar-config.h" #include "e-cal-model.h" #include "e-day-view.h" diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 83e65d4966..020b586fc8 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -373,12 +373,6 @@ primary_source_selection_changed_cb (ESourceSelector *selector, TasksComponentVi } static void -source_added_cb (ETasks *tasks, ESource *source, TasksComponentView *component_view) -{ - e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source); -} - -static void source_removed_cb (ETasks *tasks, ESource *source, TasksComponentView *component_view) { e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); @@ -811,8 +805,6 @@ create_component_view (TasksComponent *tasks_component) component_view->model = E_TABLE_MODEL (e_calendar_table_get_model (e_tasks_get_calendar_table (component_view->tasks))); /* This signal is thrown if backends die - we update the selector */ - g_signal_connect (component_view->tasks, "source_added", - G_CALLBACK (source_added_cb), component_view); g_signal_connect (component_view->tasks, "source_removed", G_CALLBACK (source_removed_cb), component_view); diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index fbd1f6676a..ff5a78226c 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -73,45 +73,6 @@ static void tasks_control_forward_cmd (BonoboUIComponent *uic, gpointer data, const char *path); -BonoboControl * -tasks_control_new (void) -{ - BonoboControl *control; - GtkWidget *tasks; - - tasks = e_tasks_new (); - if (!tasks) - return NULL; - gtk_widget_show (tasks); - - control = bonobo_control_new (tasks); - if (!control) { - gtk_widget_destroy (tasks); - g_message ("control_factory_fn(): could not create the control!"); - return NULL; - } - - g_signal_connect (control, "activate", G_CALLBACK (tasks_control_activate_cb), tasks); - - return control; -} - - -static void -tasks_control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - ETasks *tasks; - - tasks = E_TASKS (user_data); - - if (activate) - tasks_control_activate (control, tasks); - else - tasks_control_deactivate (control, tasks); -} - struct _tasks_sensitize_item { char *command; guint32 enable; @@ -362,40 +323,3 @@ tasks_control_purge_cmd (BonoboUIComponent *uic, if (confirm_purge (tasks)) e_tasks_delete_completed (tasks); } - -static void -tasks_control_assign_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - ECalendarTable *cal_table; - ECalModelComponent *comp_data; - - tasks = E_TASKS (data); - cal_table = e_tasks_get_calendar_table (tasks); - comp_data = e_calendar_table_get_selected_comp (cal_table); - if (comp_data) - e_calendar_table_open_task (cal_table, comp_data->client, comp_data->icalcomp, TRUE); -} - -static void -tasks_control_forward_cmd (BonoboUIComponent *uic, - gpointer data, - const char *path) -{ - ETasks *tasks; - ECalendarTable *cal_table; - ECalModelComponent *comp_data; - - tasks = E_TASKS (data); - cal_table = e_tasks_get_calendar_table (tasks); - comp_data = e_calendar_table_get_selected_comp (cal_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); - } -} diff --git a/calendar/modules/e-cal-shell-content.c b/calendar/modules/e-cal-shell-content.c new file mode 100644 index 0000000000..66113d073a --- /dev/null +++ b/calendar/modules/e-cal-shell-content.c @@ -0,0 +1,163 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-cal-shell-content.h" + +#include <glib/gi18n.h> + +#include "e-util/gconf-bridge.h" + +#include "calendar/gui/calendar-config.h" + +#include "widgets/menus/gal-view-etable.h" + +#define E_CAL_SHELL_CONTENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_SHELL_CONTENT, ECalShellContentPrivate)) + +struct _ECalShellContentPrivate { + gint dummy; +}; + +enum { + PROP_0 +}; + +static gpointer parent_class; + +static void +cal_shell_content_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_shell_content_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_shell_content_dispose (GObject *object) +{ + ECalShellContentPrivate *priv; + + priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +cal_shell_content_finalize (GObject *object) +{ + ECalShellContentPrivate *priv; + + priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +cal_shell_content_constructed (GObject *object) +{ + ECalShellContentPrivate *priv; + + priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + +} + +static void +cal_shell_content_class_init (ECalShellContentClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalShellContentPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = cal_shell_content_set_property; + object_class->get_property = cal_shell_content_get_property; + object_class->dispose = cal_shell_content_dispose; + object_class->finalize = cal_shell_content_finalize; + object_class->constructed = cal_shell_content_constructed; +} + +static void +cal_shell_content_init (ECalShellContent *cal_shell_content) +{ + cal_shell_content->priv = + E_CAL_SHELL_CONTENT_GET_PRIVATE (cal_shell_content); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_cal_shell_content_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ECalShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) cal_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ECalShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) cal_shell_content_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_CONTENT, "ECalShellContent", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_cal_shell_content_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_CAL_SHELL_CONTENT, + "shell-view", shell_view, NULL); +} diff --git a/calendar/modules/e-cal-shell-content.h b/calendar/modules/e-cal-shell-content.h new file mode 100644 index 0000000000..18317c3652 --- /dev/null +++ b/calendar/modules/e-cal-shell-content.h @@ -0,0 +1,71 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-cal-shell-content.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_CAL_SHELL_CONTENT_H +#define E_CAL_SHELL_CONTENT_H + +#include <shell/e-shell-content.h> +#include <shell/e-shell-view.h> + +#include <widgets/menus/gal-view-instance.h> + +/* Standard GObject macros */ +#define E_TYPE_CAL_SHELL_CONTENT \ + (e_cal_shell_content_get_type ()) +#define E_CAL_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CAL_SHELL_CONTENT, ECalShellContent)) +#define E_CAL_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CAL_SHELL_CONTENT, ECalShellContentClass)) +#define E_IS_CAL_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CAL_SHELL_CONTENT)) +#define E_IS_CAL_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CAL_SHELL_CONTENT)) +#define E_CAL_SHELL_CONTENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CAL_SHELL_CONTENT, ECalShellContentClass)) + +G_BEGIN_DECLS + +typedef struct _ECalShellContent ECalShellContent; +typedef struct _ECalShellContentClass ECalShellContentClass; +typedef struct _ECalShellContentPrivate ECalShellContentPrivate; + +struct _ECalShellContent { + EShellContent parent; + ECalShellContentPrivate *priv; +}; + +struct _ECalShellContentClass { + EShellContentClass parent_class; +}; + +GType e_cal_shell_content_get_type (void); +GtkWidget * e_cal_shell_content_new (EShellView *shell_view); +GalViewInstance * + e_cal_shell_content_get_view_instance + (ECalShellContent *cal_shell_content); + +G_END_DECLS + +#endif /* E_CAL_SHELL_CONTENT_H */ diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c index 7df23a92f3..e05bcda600 100644 --- a/calendar/modules/e-cal-shell-module.c +++ b/calendar/modules/e-cal-shell-module.c @@ -25,12 +25,13 @@ #include <libedataserver/e-source-list.h> #include <libedataserver/e-source-group.h> -#include <e-shell.h> -#include <e-shell-module.h> -#include <e-shell-window.h> +#include "shell/e-shell.h" +#include "shell/e-shell-module.h" +#include "shell/e-shell-window.h" -#include <calendar-config.h> -#include <e-cal-shell-view.h> +#include "calendar/gui/calendar-config.h" + +#include "e-cal-shell-view.h" #define MODULE_NAME "calendar" #define MODULE_ALIASES "" diff --git a/calendar/modules/e-cal-shell-sidebar.c b/calendar/modules/e-cal-shell-sidebar.c index 5d14f589f0..10d6f30c05 100644 --- a/calendar/modules/e-cal-shell-sidebar.c +++ b/calendar/modules/e-cal-shell-sidebar.c @@ -22,15 +22,12 @@ #include <string.h> #include <glib/gi18n.h> -#include <libecal/e-cal-time-util.h> -#include <libedataserver/e-data-server-util.h> -#include <libedataserverui/e-source-selector.h> -#include <e-util/e-util.h> +#include "e-util/e-util.h" +#include "calendar/gui/gnome-cal.h" +#include "calendar/gui/e-calendar-selector.h" -#include <gnome-cal.h> -#include <e-cal-shell-view.h> -#include <e-calendar-selector.h> +#include "e-cal-shell-view.h" #define E_CAL_SHELL_SIDEBAR_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -48,127 +45,6 @@ enum { static gpointer parent_class; static void -cal_shell_sidebar_update (EShellSidebar *shell_sidebar) -{ - EShellView *shell_view; - GnomeCalendar *calendar; - GnomeCalendarViewType view; - time_t start_time, end_time; - struct tm start_tm, end_tm; - struct icaltimetype start_tt, end_tt; - icaltimezone *timezone; - gchar buffer[512]; - gchar end_buffer[512]; - - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - calendar = e_cal_shell_view_get_calendar ( - E_CAL_SHELL_VIEW (shell_view)); - - gnome_calendar_get_visible_time_range ( - calendar, &start_time, &end_time); - timezone = gnome_calendar_get_timezone (calendar); - view = gnome_calendar_get_view (calendar); - - start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); - start_tm.tm_year = start_tt.year - 1900; - start_tm.tm_mon = start_tt.month - 1; - start_tm.tm_mday = start_tt.day; - start_tm.tm_hour = start_tt.hour; - start_tm.tm_min = start_tt.minute; - start_tm.tm_sec = start_tt.second; - start_tm.tm_isdst = -1; - start_tm.tm_wday = time_day_of_week ( - start_tt.day, start_tt.month - 1, start_tt.year); - - /* Subtract one from end_time so we don't get an extra day. */ - end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, timezone); - end_tm.tm_year = end_tt.year - 1900; - end_tm.tm_mon = end_tt.month - 1; - end_tm.tm_mday = end_tt.day; - end_tm.tm_hour = end_tt.hour; - end_tm.tm_min = end_tt.minute; - end_tm.tm_sec = end_tt.second; - end_tm.tm_isdst = -1; - end_tm.tm_wday = time_day_of_week ( - end_tt.day, end_tt.month - 1, end_tt.year); - - switch (view) { - case GNOME_CAL_DAY_VIEW: - case GNOME_CAL_WORK_WEEK_VIEW: - case GNOME_CAL_WEEK_VIEW: - if (start_tm.tm_year == end_tm.tm_year && - start_tm.tm_mon == end_tm.tm_mon && - start_tm.tm_mday == end_tm.tm_mday) { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%A %d %b %Y"), &start_tm); - } else if (start_tm.tm_year == end_tm.tm_year) { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%a %d %b"), &start_tm); - e_utf8_strftime ( - end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%a %d %b %Y"), &start_tm); - e_utf8_strftime ( - end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - - case GNOME_CAL_MONTH_VIEW: - case GNOME_CAL_LIST_VIEW: - if (start_tm.tm_year == end_tm.tm_year) { - if (start_tm.tm_mon == end_tm.tm_mon) { - e_utf8_strftime ( - buffer, - sizeof (buffer), - "%d", &start_tm); - e_utf8_strftime ( - end_buffer, - sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime ( - buffer, - sizeof (buffer), - _("%d %b"), &start_tm); - e_utf8_strftime ( - end_buffer, - sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - } else { - e_utf8_strftime ( - buffer, sizeof (buffer), - _("%d %b %Y"), &start_tm); - e_utf8_strftime ( - end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - - default: - g_return_if_reached (); - } - - e_shell_sidebar_set_secondary_text (shell_sidebar, buffer); -} - -static void cal_shell_sidebar_get_property (GObject *object, guint property_id, GValue *value, @@ -211,10 +87,12 @@ cal_shell_sidebar_constructed (GObject *object) ESourceList *source_list; GtkContainer *container; GtkWidget *widget; - GnomeCalendar *calendar; priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); cal_shell_view = E_CAL_SHELL_VIEW (shell_view); @@ -238,17 +116,6 @@ cal_shell_sidebar_constructed (GObject *object) gtk_container_add (container, widget); priv->selector = g_object_ref (widget); gtk_widget_show (widget); - - /* Setup signal handlers. */ - - calendar = e_cal_shell_view_get_calendar (cal_shell_view); - - g_signal_connect_swapped ( - calendar, "dates-shown-changed", - G_CALLBACK (cal_shell_sidebar_update), - shell_sidebar); - - cal_shell_sidebar_update (shell_sidebar); } static void diff --git a/calendar/modules/e-cal-shell-sidebar.h b/calendar/modules/e-cal-shell-sidebar.h index 89eaee7613..b22805b60c 100644 --- a/calendar/modules/e-cal-shell-sidebar.h +++ b/calendar/modules/e-cal-shell-sidebar.h @@ -21,8 +21,8 @@ #ifndef E_CAL_SHELL_SIDEBAR_H #define E_CAL_SHELL_SIDEBAR_H -#include <e-shell-sidebar.h> -#include <e-shell-view.h> +#include <shell/e-shell-sidebar.h> +#include <shell/e-shell-view.h> /* Standard GObject macros */ #define E_TYPE_CAL_SHELL_SIDEBAR \ diff --git a/calendar/modules/e-cal-shell-view-actions.h b/calendar/modules/e-cal-shell-view-actions.h index 9d935e4263..c74f4c23e5 100644 --- a/calendar/modules/e-cal-shell-view-actions.h +++ b/calendar/modules/e-cal-shell-view-actions.h @@ -23,8 +23,58 @@ #include <shell/e-shell-window-actions.h> +/* Calendar Actions */ +#define E_SHELL_WINDOW_ACTION_CALENDAR_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-copy") +#define E_SHELL_WINDOW_ACTION_CALENDAR_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-delete") +#define E_SHELL_WINDOW_ACTION_CALENDAR_GO_BACK(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-go-back") +#define E_SHELL_WINDOW_ACTION_CALENDAR_GO_FORWARD(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-go-forward") +#define E_SHELL_WINDOW_ACTION_CALENDAR_GO_TODAY(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-go-today") +#define E_SHELL_WINDOW_ACTION_CALENDAR_JUMP_TO(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-jump-to") +#define E_SHELL_WINDOW_ACTION_CALENDAR_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-new") +#define E_SHELL_WINDOW_ACTION_CALENDAR_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-print") +#define E_SHELL_WINDOW_ACTION_CALENDAR_PRINT_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-print-preview") +#define E_SHELL_WINDOW_ACTION_CALENDAR_PROPERTIES(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-properties") +#define E_SHELL_WINDOW_ACTION_CALENDAR_PURGE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-purge") +#define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_DAY(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-view-day") +#define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_LIST(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-view-list") +#define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_MONTH(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-view-month") +#define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_WEEK(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-view-week") +#define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_WORKWEEK(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-view-workweek") + +/* Event Actions */ +#define E_SHELL_WINDOW_ACTION_EVENT_CLIPBOARD_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-clipboard-copy") +#define E_SHELL_WINDOW_ACTION_EVENT_CLIPBOARD_CUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-clipboard-cut") +#define E_SHELL_WINDOW_ACTION_EVENT_CLIPBOARD_PASTE(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-clipboard-paste") +#define E_SHELL_WINDOW_ACTION_EVENT_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-delete") +#define E_SHELL_WINDOW_ACTION_EVENT_DELETE_OCCURRENCE(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-delete-occurrence") +#define E_SHELL_WINDOW_ACTION_EVENT_DELETE_OCCURRENCE_ALL(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-delete-occurrence-all") +#define E_SHELL_WINDOW_ACTION_EVENT_OPEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "event-open") + /* Action Groups */ #define E_SHELL_WINDOW_ACTION_GROUP_CALS(window) \ - E_SHELL_WINDOW_ACTION_GROUP ((window), "cals") + E_SHELL_WINDOW_ACTION_GROUP ((window), "calendars") #endif /* E_CAL_SHELL_VIEW_ACTIONS_H */ diff --git a/calendar/modules/e-cal-shell-view-private.c b/calendar/modules/e-cal-shell-view-private.c index 262e31497c..97aada4a89 100644 --- a/calendar/modules/e-cal-shell-view-private.c +++ b/calendar/modules/e-cal-shell-view-private.c @@ -20,6 +20,75 @@ #include "e-cal-shell-view-private.h" +#include "calendar/gui/calendar-view-factory.h" +#include "widgets/menus/gal-view-factory-etable.h" + +static void +cal_shell_view_load_view_collection (EShellViewClass *shell_view_class) +{ + GalViewCollection *collection; + GalViewFactory *factory; + ETableSpecification *spec; + const gchar *base_dir; + gchar *filename; + + collection = shell_view_class->view_collection; + + base_dir = EVOLUTION_ETSPECDIR; + spec = e_table_specification_new (); + filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL); + if (!e_table_specification_load_from_file (spec, filename)) + g_critical ("Unable to load ETable specification file " + "for calendars"); + g_free (filename); + + factory = calendar_view_factory_new (GNOME_CAL_DAY_VIEW); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + + factory = calendar_view_factory_new (GNOME_CAL_WORK_WEEK_VIEW); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + + factory = calendar_view_factory_new (GNOME_CAL_WEEK_VIEW); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + + factory = calendar_view_factory_new (GNOME_CAL_MONTH_VIEW); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + + factory = gal_view_factory_etable_new (spec); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + g_object_unref (spec); + + gal_view_collection_load (collection); +} + +static void +cal_shell_view_notify_view_id_cb (ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + GalViewInstance *view_instance; + const gchar *view_id; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + view_instance = + e_cal_shell_content_get_view_instance (cal_shell_content); + view_id = e_shell_view_get_view_id (E_SHELL_VIEW (cal_shell_view)); + + /* A NULL view ID implies we're in a custom view. But you can + * only get to a custom view via the "Define Views" dialog, which + * would have already modified the view instance appropriately. + * Furthermore, there's no way to refer to a custom view by ID + * anyway, since custom views have no IDs. */ + if (view_id == NULL) + return; + + gal_view_instance_set_current_view_id (view_instance, view_id); +} + void e_cal_shell_view_private_init (ECalShellView *cal_shell_view, EShellViewClass *shell_view_class) @@ -34,6 +103,13 @@ e_cal_shell_view_private_init (ECalShellView *cal_shell_view, priv->source_list = g_object_ref (source_list); priv->calendar_actions = gtk_action_group_new ("calendars"); + + if (!gal_view_collection_loaded (shell_view_class->view_collection)) + cal_shell_view_load_view_collection (shell_view_class); + + g_signal_connect ( + cal_shell_view, "notify::view-id", + G_CALLBACK (cal_shell_view_notify_view_id_cb), NULL); } void @@ -43,6 +119,7 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellView *shell_view; + GnomeCalendar *calendar; shell_view = E_SHELL_VIEW (cal_shell_view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -51,6 +128,16 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) /* Cache these to avoid lots of awkward casting. */ priv->cal_shell_content = g_object_ref (shell_content); priv->cal_shell_sidebar = g_object_ref (shell_sidebar); + + calendar = e_cal_shell_view_get_calendar (cal_shell_view); + + g_signal_connect_swapped ( + calendar, "dates-shown-changed", + G_CALLBACK (e_cal_shell_view_sidebar_update), + cal_shell_view); + + e_shell_view_update_actions (shell_view); + e_cal_shell_view_sidebar_update (cal_shell_view); } void @@ -64,10 +151,170 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) DISPOSE (priv->cal_shell_content); DISPOSE (priv->cal_shell_sidebar); + + if (cal_shell_view->priv->activity != NULL) { + /* XXX Activity is not cancellable. */ + e_activity_complete (cal_shell_view->priv->activity); + g_object_unref (cal_shell_view->priv->activity); + cal_shell_view->priv->activity = NULL; + } } void e_cal_shell_view_private_finalize (ECalShellView *cal_shell_view) { - ECalShellViewPrivate *priv = cal_shell_view->priv; + /* XXX Nothing to do? */ } + +void +e_cal_shell_view_set_status_message (ECalShellView *cal_shell_view, + const gchar *status_message) +{ + EActivity *activity; + EShellView *shell_view; + + g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view)); + + activity = cal_shell_view->priv->activity; + shell_view = E_SHELL_VIEW (cal_shell_view); + + if (status_message == NULL || *status_message == '\0') { + if (activity != NULL) { + e_activity_complete (activity); + g_object_unref (activity); + activity = NULL; + } + + } else if (activity == NULL) { + activity = e_activity_new (status_message); + e_shell_view_add_activity (shell_view, activity); + + } else + e_activity_set_primary_text (activity, status_message); + + cal_shell_view->priv->activity = activity; +} + +void +e_cal_shell_view_sidebar_update (ECalShellView *cal_shell_view) +{ + EShellView *shell_view; + EShellSidebar *shell_sidebar; + GnomeCalendar *calendar; + GnomeCalendarViewType view; + time_t start_time, end_time; + struct tm start_tm, end_tm; + struct icaltimetype start_tt, end_tt; + icaltimezone *timezone; + gchar buffer[512]; + gchar end_buffer[512]; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + calendar = e_cal_shell_view_get_calendar (cal_shell_view); + + gnome_calendar_get_visible_time_range ( + calendar, &start_time, &end_time); + timezone = gnome_calendar_get_timezone (calendar); + view = gnome_calendar_get_view (calendar); + + start_tt = icaltime_from_timet_with_zone (start_time, FALSE, timezone); + start_tm.tm_year = start_tt.year - 1900; + start_tm.tm_mon = start_tt.month - 1; + start_tm.tm_mday = start_tt.day; + start_tm.tm_hour = start_tt.hour; + start_tm.tm_min = start_tt.minute; + start_tm.tm_sec = start_tt.second; + start_tm.tm_isdst = -1; + start_tm.tm_wday = time_day_of_week ( + start_tt.day, start_tt.month - 1, start_tt.year); + + /* Subtract one from end_time so we don't get an extra day. */ + end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, timezone); + end_tm.tm_year = end_tt.year - 1900; + end_tm.tm_mon = end_tt.month - 1; + end_tm.tm_mday = end_tt.day; + end_tm.tm_hour = end_tt.hour; + end_tm.tm_min = end_tt.minute; + end_tm.tm_sec = end_tt.second; + end_tm.tm_isdst = -1; + end_tm.tm_wday = time_day_of_week ( + end_tt.day, end_tt.month - 1, end_tt.year); + + switch (view) { + case GNOME_CAL_DAY_VIEW: + case GNOME_CAL_WORK_WEEK_VIEW: + case GNOME_CAL_WEEK_VIEW: + if (start_tm.tm_year == end_tm.tm_year && + start_tm.tm_mon == end_tm.tm_mon && + start_tm.tm_mday == end_tm.tm_mday) { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%A %d %b %Y"), &start_tm); + } else if (start_tm.tm_year == end_tm.tm_year) { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%a %d %b"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%a %d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } else { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%a %d %b %Y"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%a %d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + break; + + case GNOME_CAL_MONTH_VIEW: + case GNOME_CAL_LIST_VIEW: + if (start_tm.tm_year == end_tm.tm_year) { + if (start_tm.tm_mon == end_tm.tm_mon) { + e_utf8_strftime ( + buffer, + sizeof (buffer), + "%d", &start_tm); + e_utf8_strftime ( + end_buffer, + sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } else { + e_utf8_strftime ( + buffer, + sizeof (buffer), + _("%d %b"), &start_tm); + e_utf8_strftime ( + end_buffer, + sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + } else { + e_utf8_strftime ( + buffer, sizeof (buffer), + _("%d %b %Y"), &start_tm); + e_utf8_strftime ( + end_buffer, sizeof (end_buffer), + _("%d %b %Y"), &end_tm); + strcat (buffer, " - "); + strcat (buffer, end_buffer); + } + break; + + default: + g_return_if_reached (); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, buffer); +} + diff --git a/calendar/modules/e-cal-shell-view-private.h b/calendar/modules/e-cal-shell-view-private.h index d80d0d2f27..645b514bf4 100644 --- a/calendar/modules/e-cal-shell-view-private.h +++ b/calendar/modules/e-cal-shell-view-private.h @@ -23,15 +23,20 @@ #include "e-cal-shell-view.h" +#include <string.h> #include <glib/gi18n.h> +#include <libecal/e-cal-time-util.h> +#include <libedataserver/e-data-server-util.h> -#include <e-util/e-util.h> -#include <shell/e-shell-content.h> +#include "e-util/e-util.h" -#include <gnome-cal.h> -#include <e-cal-shell-content.h> -#include <e-cal-shell-sidebar.h> -#include <e-cal-shell-view-actions.h> +#include "shell/e-shell-content.h" + +#include "calendar/gui/gnome-cal.h" + +#include "e-cal-shell-content.h" +#include "e-cal-shell-sidebar.h" +#include "e-cal-shell-view-actions.h" #define E_CAL_SHELL_VIEW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -49,6 +54,9 @@ if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ } G_STMT_END +/* ETable Specifications */ +#define ETSPEC_FILENAME "e-calendar-table.etspec" + G_BEGIN_DECLS struct _ECalShellViewPrivate { @@ -64,6 +72,8 @@ struct _ECalShellViewPrivate { /* These are just for convenience. */ ECalShellContent *cal_shell_content; ECalShellSidebar *cal_shell_sidebar; + + EActivity *activity; }; void e_cal_shell_view_private_init @@ -80,6 +90,11 @@ void e_cal_shell_view_private_finalize void e_cal_shell_view_actions_init (ECalShellView *cal_shell_view); +void e_cal_shell_view_set_status_message + (ECalShellView *cal_shell_view, + const gchar *status_message); +void e_cal_shell_view_sidebar_update + (ECalShellView *cal_shell_view); G_END_DECLS diff --git a/calendar/modules/e-cal-shell-view.c b/calendar/modules/e-cal-shell-view.c index 67d32de362..3c4eaaf0d1 100644 --- a/calendar/modules/e-cal-shell-view.c +++ b/calendar/modules/e-cal-shell-view.c @@ -73,17 +73,16 @@ cal_shell_view_constructed (GObject *object) } static void -cal_shell_view_changed (EShellView *shell_view) +cal_shell_view_update_actions (EShellView *shell_view) { ECalShellViewPrivate *priv; - GtkActionGroup *action_group; - gboolean visible; + EShellWindow *shell_window; priv = E_CAL_SHELL_VIEW_GET_PRIVATE (shell_view); - action_group = priv->calendar_actions; - visible = e_shell_view_is_active (shell_view); - gtk_action_group_set_visible (action_group, visible); + shell_window = e_shell_view_get_shell_window (shell_view); + + /* FIXME */ } static void @@ -105,10 +104,11 @@ cal_shell_view_class_init (ECalShellView *class, shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = N_("Cals"); shell_view_class->icon_name = "evolution-cals"; + shell_view_class->ui_definition = "evolution-calendars.ui"; shell_view_class->search_options = "/calendar-search-options"; shell_view_class->type_module = type_module; shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new; - shell_view_class->changed = cal_shell_view_changed; + shell_view_class->update_actions = cal_shell_view_update_actions; g_object_class_install_property ( object_class, diff --git a/calendar/modules/e-cal-shell-view.h b/calendar/modules/e-cal-shell-view.h index 404446f22b..9e21d9dc93 100644 --- a/calendar/modules/e-cal-shell-view.h +++ b/calendar/modules/e-cal-shell-view.h @@ -21,8 +21,8 @@ #ifndef E_CAL_SHELL_VIEW_H #define E_CAL_SHELL_VIEW_H -#include <gnome-cal.h> -#include <e-shell-view.h> +#include <shell/e-shell-view.h> +#include <calendar/gui/gnome-cal.h> #include <libedataserver/e-source-list.h> /* Standard GObject macros */ diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c index a7b50fc967..52055f5146 100644 --- a/calendar/modules/e-memo-shell-content.c +++ b/calendar/modules/e-memo-shell-content.c @@ -313,20 +313,6 @@ memo_shell_content_constructed (GObject *object) shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); view_collection = shell_view_class->view_collection; - /* Load the view instance. */ - - view_instance = gal_view_instance_new (view_collection, NULL); - g_signal_connect_swapped ( - view_instance, "changed", - G_CALLBACK (memo_shell_content_changed_cb), - object); - g_signal_connect_swapped ( - view_instance, "display-view", - G_CALLBACK (memo_shell_content_display_view_cb), - object); - gal_view_instance_load (view_instance); - priv->view_instance = view_instance; - /* Build content widgets. */ container = GTK_WIDGET (object); @@ -402,6 +388,20 @@ memo_shell_content_constructed (GObject *object) G_CALLBACK (memo_shell_content_model_row_changed_cb), object); + /* Load the view instance. */ + + view_instance = gal_view_instance_new (view_collection, NULL); + g_signal_connect_swapped ( + view_instance, "changed", + G_CALLBACK (memo_shell_content_changed_cb), + object); + g_signal_connect_swapped ( + view_instance, "display-view", + G_CALLBACK (memo_shell_content_display_view_cb), + object); + gal_view_instance_load (view_instance); + priv->view_instance = view_instance; + /* Bind GObject properties to GConf keys. */ bridge = gconf_bridge_get (); diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c index fe8c8fe35a..cf2a9af325 100644 --- a/calendar/modules/e-memo-shell-module.c +++ b/calendar/modules/e-memo-shell-module.c @@ -29,8 +29,11 @@ #include "shell/e-shell-module.h" #include "shell/e-shell-window.h" +#include "calendar/common/authentication.h" #include "calendar/gui/calendar-config.h" +#include "calendar/gui/comp-util.h" #include "calendar/gui/dialogs/calendar-setup.h" +#include "calendar/gui/dialogs/memo-editor.h" #include "e-memo-shell-view.h" @@ -194,22 +197,83 @@ memo_module_ensure_sources (EShellModule *shell_module) } static void -action_memo_new_cb (GtkAction *action, - EShellWindow *shell_window) +memo_module_cal_opened_cb (ECal *cal, + ECalendarStatus status, + GtkAction *action) { + ECalComponent *comp; + CompEditor *editor; + CompEditorFlags flags = 0; + const gchar *action_name; + + /* XXX Handle errors better. */ + if (status != E_CALENDAR_STATUS_OK) + return; + + action_name = gtk_action_get_name (action); + + flags |= COMP_EDITOR_NEW_ITEM; + if (strcmp (action_name, "memo-shared-new") == 0) { + flags |= COMP_EDITOR_IS_SHARED; + flags |= COMP_EDITOR_USER_ORG; + } + + editor = memo_editor_new (cal, flags); + comp = cal_comp_memo_new_with_defaults (cal); + comp_editor_edit_comp (editor, comp); + + gtk_window_present (GTK_WINDOW (editor)); + + g_object_unref (comp); + g_object_unref (cal); } static void -action_memo_shared_new_cb (GtkAction *action, - EShellWindow *shell_window) +action_memo_new_cb (GtkAction *action, + EShellWindow *shell_window) { + ECal *cal = NULL; + ECalSourceType source_type; + ESourceList *source_list; + gchar *uid; + + /* This callback is used for both memos and shared memos. */ + + source_type = E_CAL_SOURCE_TYPE_JOURNAL; + + if (!e_cal_get_sources (&source_list, source_type, NULL)) { + g_warning ("Could not get memo sources from GConf!"); + return; + } + + uid = calendar_config_get_primary_memos (); + + if (uid != NULL) { + ESource *source; + + source = e_source_list_peek_source_by_uid (source_list, uid); + if (source != NULL) + cal = auth_new_cal_from_source (source, source_type); + g_free (uid); + } + + if (cal == NULL) + cal = auth_new_cal_from_default (source_type); + + g_return_if_fail (cal != NULL); + + g_signal_connect ( + cal, "cal-opened", + G_CALLBACK (memo_module_cal_opened_cb), action); + + e_cal_open_async (cal, FALSE); } static void action_memo_list_new_cb (GtkAction *action, EShellWindow *shell_window) { - calendar_setup_new_memo_list (NULL); + calendar_setup_new_memo_list (GTK_WINDOW (shell_window)); } static GtkActionEntry item_entries[] = { @@ -217,16 +281,16 @@ static GtkActionEntry item_entries[] = { { "memo-new", "stock_insert-note", N_("Mem_o"), /* XXX Need C_() here */ - "<Control>o", + "<Shift><Control>o", N_("Create a new memo"), G_CALLBACK (action_memo_new_cb) }, { "memo-shared-new", "stock_insert-note", N_("_Shared Memo"), - "<Control>h", + "<Shift><Control>h", N_("Create a new shared memo"), - G_CALLBACK (action_memo_shared_new_cb) } + G_CALLBACK (action_memo_new_cb) } }; static GtkActionEntry source_entries[] = { diff --git a/calendar/modules/e-memo-shell-sidebar.c b/calendar/modules/e-memo-shell-sidebar.c index 23ab9491fa..21948b87ed 100644 --- a/calendar/modules/e-memo-shell-sidebar.c +++ b/calendar/modules/e-memo-shell-sidebar.c @@ -20,9 +20,15 @@ #include "e-memo-shell-sidebar.h" +#include <string.h> #include <glib/gi18n.h> +#include <libecal/e-cal.h> +#include "e-util/e-error.h" +#include "calendar/common/authentication.h" +#include "calendar/gui/calendar-config.h" #include "calendar/gui/e-calendar-selector.h" +#include "calendar/gui/misc.h" #include "e-memo-shell-view.h" @@ -32,6 +38,9 @@ struct _EMemoShellSidebarPrivate { GtkWidget *selector; + + /* UID -> Client */ + GHashTable *client_table; }; enum { @@ -39,47 +48,181 @@ enum { PROP_SELECTOR }; +enum { + CLIENT_ADDED, + CLIENT_REMOVED, + STATUS_MESSAGE, + LAST_SIGNAL +}; + static gpointer parent_class; +static guint signals[LAST_SIGNAL]; + +static void +memo_shell_sidebar_emit_client_added (EMemoShellSidebar *memo_shell_sidebar, + ECal *client) +{ + guint signal_id = signals[CLIENT_ADDED]; + + g_signal_emit (memo_shell_sidebar, signal_id, 0, client); +} + +static void +memo_shell_sidebar_emit_client_removed (EMemoShellSidebar *memo_shell_sidebar, + ECal *client) +{ + guint signal_id = signals[CLIENT_REMOVED]; + + g_signal_emit (memo_shell_sidebar, signal_id, 0, client); +} + +static void +memo_shell_sidebar_emit_status_message (EMemoShellSidebar *memo_shell_sidebar, + const gchar *status_message) +{ + guint signal_id = signals[STATUS_MESSAGE]; + + g_signal_emit (memo_shell_sidebar, signal_id, 0, status_message); +} + +static void +memo_shell_sidebar_update_timezone (EMemoShellSidebar *memo_shell_sidebar) +{ + /* FIXME */ +} -#if 0 /* MOVE THIS TO EMemoShellView */ static void -memo_shell_sidebar_update (EShellSidebar *shell_sidebar) +memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, + ECal *client) { EShellView *shell_view; - EMemos *memos; - ETable *table; - ECalModel *model; - EMemoTable *memo_table; - GString *string; - const gchar *format; - gint n_rows; - gint n_selected; + EShellWindow *shell_window; + EShellSidebar *shell_sidebar; + GHashTable *client_table; + ESource *source; + const gchar *uid; + + client_table = memo_shell_sidebar->priv->client_table; + shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - memos = e_memo_shell_view_get_memos (E_MEMO_SHELL_VIEW (shell_view)); - memo_table = e_memos_get_calendar_table (memos); - model = e_memo_table_get_model (memo_table); - table = e_memo_table_get_table (memo_table); + shell_window = e_shell_view_get_shell_window (shell_view); - n_rows = e_table_model_get_row_count (model); - n_selected = e_table_selected_count (table); + source = e_cal_get_source (client); + uid = e_source_peek_uid (source); - string = g_string_sized_new (64); + g_object_ref (source); - format = ngettext ("%d memo", "%d memos", n_rows); - g_string_append_printf (string, format, n_rows); + g_hash_table_remove (client_table, uid); + memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL); - if (n_selected > 0) { - format = _("%d selected"); - g_string_append_len (string, ", ", 2); - g_string_append_printf (string, format, n_selected); + e_error_run ( + GTK_WINDOW (shell_window), + "calendar:memos-crashed", NULL); + + g_object_unref (source); +} + +static void +memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar, + const gchar *message, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + EShellSidebar *shell_sidebar; + GtkWidget *dialog; + const gchar *uri; + gchar *uri_no_passwd; + + shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_window = e_shell_view_get_shell_window (shell_view); + + uri = e_cal_get_uri (client); + uri_no_passwd = get_uri_without_password (uri); + + dialog = gtk_message_dialog_new ( + GTK_WINDOW (shell_window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + _("Error on %s\n%s"), + uri_no_passwd, message); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + + g_free (uri_no_passwd); +} + +static void +memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, + ECalendarStatus status, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + EShellSidebar *shell_sidebar; + ESource *source; + + source = e_cal_get_source (client); + + shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_window = e_shell_view_get_shell_window (shell_view); + + switch (status) { + case E_CALENDAR_STATUS_OK: + g_signal_handlers_disconnect_matched ( + client, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, + memo_shell_sidebar_client_opened_cb, NULL); + + memo_shell_sidebar_emit_status_message ( + memo_shell_sidebar, _("Loading memos")); + memo_shell_sidebar_emit_client_added ( + memo_shell_sidebar, client); + memo_shell_sidebar_emit_status_message ( + memo_shell_sidebar, NULL); + break; + + case E_CALENDAR_STATUS_BUSY: + break; + + case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: + e_error_run ( + GTK_WINDOW (shell_window), + "calendar:prompt-no-contents-offline-memos", + NULL); + break; + + default: + memo_shell_sidebar_emit_client_removed ( + memo_shell_sidebar, client); + break; } +} + +static void +memo_shell_sidebar_selection_changed_cb (EMemoShellSidebar *memo_shell_sidebar, + ESourceSelector *selector) +{ + /* FIXME */ +} - e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); +static void +memo_shell_sidebar_primary_selection_changed_cb (EMemoShellSidebar *memo_shell_sidebar, + ESourceSelector *selector) +{ + ESource *source; + const gchar *uid; - g_string_free (string, TRUE); + source = e_source_selector_peek_primary_selection (selector); + if (source == NULL) + return; + + uid = e_source_peek_uid (source); + calendar_config_set_primary_memos (uid); } -#endif static void memo_shell_sidebar_get_property (GObject *object, @@ -110,23 +253,45 @@ memo_shell_sidebar_dispose (GObject *object) priv->selector = NULL; } + g_hash_table_remove_all (priv->client_table); + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } static void +memo_shell_sidebar_finalize (GObject *object) +{ + EMemoShellSidebarPrivate *priv; + + priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); + + g_hash_table_destroy (priv->client_table); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void memo_shell_sidebar_constructed (GObject *object) { EMemoShellSidebarPrivate *priv; EShellView *shell_view; EShellSidebar *shell_sidebar; EMemoShellView *memo_shell_view; + ESourceSelector *selector; ESourceList *source_list; + ESource *source; GtkContainer *container; GtkWidget *widget; + GSList *list, *iter; + gchar *uid; priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (object); + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); memo_shell_view = E_MEMO_SHELL_VIEW (shell_view); @@ -151,38 +316,78 @@ memo_shell_sidebar_constructed (GObject *object) priv->selector = g_object_ref (widget); gtk_widget_show (widget); -#if 0 /* MOVE THIS TO EMemoShellView */ + g_signal_connect_swapped ( + widget, "selection-changed", + G_CALLBACK (memo_shell_sidebar_selection_changed_cb), + object); - /* Setup signal handlers. */ + g_signal_connect_swapped ( + widget, "primary-selection-changed", + G_CALLBACK (memo_shell_sidebar_primary_selection_changed_cb), + object); - memos = e_memo_shell_view_get_memos (memo_shell_view); - memo_table = e_memos_get_calendar_table (memos); - model = e_memo_table_get_model (memo_table); - table = e_memo_table_get_table (memo_table); + /* Restore the primary selection from the last session. */ - g_signal_connect_swapped ( - model, "model-changed", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); + selector = E_SOURCE_SELECTOR (priv->selector); + uid = calendar_config_get_primary_memos (); + source = NULL; - g_signal_connect_swapped ( - model, "model-rows-deleted", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); + if (uid != NULL) + source = e_source_list_peek_source_by_uid (source_list, uid); + if (source == NULL) + source = e_source_list_peek_source_any (source_list); + if (source != NULL) + e_source_selector_set_primary_selection (selector, source); - g_signal_connect_swapped ( - model, "model-rows-inserted", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); + g_free (uid); - g_signal_connect_swapped ( - model, "selection-change", - G_CALLBACK (memo_shell_sidebar_update), - shell_sidebar); + /* Restore the selected sources from last session. */ + + list = calendar_config_get_memos_selected (); + for (iter = list; iter != NULL; iter = iter->next) { + uid = iter->data; + source = e_source_list_peek_source_by_uid (source_list, uid); + g_free (uid); - memo_shell_sidebar_update (shell_sidebar); + if (source == NULL) + continue; -#endif + e_source_selector_select_source ( + E_SOURCE_SELECTOR (priv->selector), source); + } + g_slist_free (list); +} + +static void +memo_shell_sidebar_client_added (EMemoShellSidebar *memo_shell_sidebar, + ECal *client) +{ + memo_shell_sidebar_update_timezone (memo_shell_sidebar); +} + +static void +memo_shell_sidebar_client_removed (EMemoShellSidebar *memo_shell_sidebar, + ECal *client) +{ + ESourceSelector *selector; + GHashTable *client_table; + ESource *source; + const gchar *uid; + + selector = E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); + client_table = memo_shell_sidebar->priv->client_table; + + g_signal_handlers_disconnect_matched ( + client, G_SIGNAL_MATCH_DATA, 0, 0, + NULL, NULL, memo_shell_sidebar); + + source = e_cal_get_source (client); + e_source_selector_unselect_source (selector, source); + + uid = e_source_peek_uid (source); + g_hash_table_remove (client_table, uid); + + memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL); } static void @@ -196,8 +401,12 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) object_class = G_OBJECT_CLASS (class); object_class->get_property = memo_shell_sidebar_get_property; object_class->dispose = memo_shell_sidebar_dispose; + object_class->finalize = memo_shell_sidebar_finalize; object_class->constructed = memo_shell_sidebar_constructed; + class->client_added = memo_shell_sidebar_client_added; + class->client_removed = memo_shell_sidebar_client_removed; + g_object_class_install_property ( object_class, PROP_SELECTOR, @@ -207,14 +416,53 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) _("This widget displays groups of memo lists"), E_TYPE_SOURCE_SELECTOR, G_PARAM_READABLE)); + + signals[CLIENT_ADDED] = g_signal_new ( + "client-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EMemoShellSidebarClass, client_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_CAL); + + signals[CLIENT_REMOVED] = g_signal_new ( + "client-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EMemoShellSidebarClass, client_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_CAL); + + signals[STATUS_MESSAGE] = g_signal_new ( + "status-message", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EMemoShellSidebarClass, status_message), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); } static void memo_shell_sidebar_init (EMemoShellSidebar *memo_shell_sidebar) { + GHashTable *client_table; + + client_table = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_object_unref); + memo_shell_sidebar->priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (memo_shell_sidebar); + memo_shell_sidebar->priv->client_table = client_table; + /* Postpone widget construction until we have a shell view. */ } @@ -263,3 +511,79 @@ e_memo_shell_sidebar_get_selector (EMemoShellSidebar *memo_shell_sidebar) return E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); } + +void +e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, + ESource *source) +{ + ESourceSelector *selector; + GHashTable *client_table; + ECal *client; + const gchar *uid; + const gchar *uri; + gchar *message; + + g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + client_table = memo_shell_sidebar->priv->client_table; + selector = E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); + + uid = e_source_peek_uid (source); + client = g_hash_table_lookup (client_table, uid); + + if (client != NULL) + return; + + client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL); + g_return_if_fail (client != NULL); + + g_signal_connect_swapped ( + client, "backend-died", + G_CALLBACK (memo_shell_sidebar_backend_died_cb), + memo_shell_sidebar); + + g_signal_connect_swapped ( + client, "backend-error", + G_CALLBACK (memo_shell_sidebar_backend_error_cb), + memo_shell_sidebar); + + g_hash_table_insert (client_table, g_strdup (uid), client); + e_source_selector_select_source (selector, source); + + uri = e_cal_get_uri (client); + message = g_strdup_printf (_("Opening memos at %s"), uri); + memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message); + g_free (message); + + g_signal_connect_swapped ( + client, "cal-opened", + G_CALLBACK (memo_shell_sidebar_client_opened_cb), + memo_shell_sidebar); + + e_cal_open_async (client, FALSE); +} + +void +e_memo_shell_sidebar_remove_source (EMemoShellSidebar *memo_shell_sidebar, + ESource *source) +{ + ESourceSelector *selector; + GHashTable *client_table; + ECal *client; + const gchar *uid; + + g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + client_table = memo_shell_sidebar->priv->client_table; + selector = E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); + + uid = e_source_peek_uid (source); + client = g_hash_table_lookup (client_table, uid); + + if (client == NULL) + return; + + memo_shell_sidebar_emit_client_removed (memo_shell_sidebar, client); +} diff --git a/calendar/modules/e-memo-shell-sidebar.h b/calendar/modules/e-memo-shell-sidebar.h index 47985d3402..106f9dc15d 100644 --- a/calendar/modules/e-memo-shell-sidebar.h +++ b/calendar/modules/e-memo-shell-sidebar.h @@ -21,6 +21,7 @@ #ifndef E_MEMO_SHELL_SIDEBAR_H #define E_MEMO_SHELL_SIDEBAR_H +#include <libecal/e-cal.h> #include <libedataserverui/e-source-selector.h> #include <shell/e-shell-sidebar.h> @@ -58,6 +59,14 @@ struct _EMemoShellSidebar { struct _EMemoShellSidebarClass { EShellSidebarClass parent_class; + + /* Signals */ + void (*client_added) (EMemoShellSidebar *memo_shell_sidebar, + ECal *client); + void (*client_removed) (EMemoShellSidebar *memo_shell_sidebar, + ECal *client); + void (*status_message) (EMemoShellSidebar *memo_shell_sidebar, + const gchar *status_message); }; GType e_memo_shell_sidebar_get_type (void); @@ -65,6 +74,11 @@ GtkWidget * e_memo_shell_sidebar_new (EShellView *shell_view); ESourceSelector * e_memo_shell_sidebar_get_selector (EMemoShellSidebar *memo_shell_sidebar); +void e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, + ESource *source); +void e_memo_shell_sidebar_remove_source + (EMemoShellSidebar *memo_shell_sidebar, + ESource *source); G_END_DECLS diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c index 29dacabafc..6b6bac4fab 100644 --- a/calendar/modules/e-memo-shell-view-actions.c +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -20,10 +20,6 @@ #include "e-memo-shell-view-private.h" -#include "e-util/gconf-bridge.h" - -#include "calendar/gui/print.h" - static void action_memo_clipboard_copy_cb (GtkAction *action, EMemoShellView *memo_shell_view) @@ -114,14 +110,92 @@ static void action_memo_list_copy_cb (GtkAction *action, EMemoShellView *memo_shell_view) { - /* FIXME */ + EMemoShellSidebar *memo_shell_sidebar; + EShellWindow *shell_window; + EShellView *shell_view; + ESourceSelector *selector; + ESource *source; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar; + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (source == NULL); + + copy_source_dialog ( + GTK_WINDOW (shell_window), + source, E_CAL_SOURCE_TYPE_JOURNAL); } static void action_memo_list_delete_cb (GtkAction *action, EMemoShellView *memo_shell_view) { - /* FIXME */ + EMemoShellContent *memo_shell_content; + EMemoShellSidebar *memo_shell_sidebar; + EShellWindow *shell_window; + EShellView *shell_view; + EMemoTable *memo_table; + ECal *client; + ECalModel *model; + ESourceSelector *selector; + ESourceGroup *source_group; + ESourceList *source_list; + ESource *source; + gint response; + gchar *uri; + GError *error = NULL; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + model = e_memo_table_get_model (memo_table); + + memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar; + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (source == NULL); + + /* Ask for confirmation. */ + response = e_error_run ( + GTK_WINDOW (shell_window), + "calendar:prompt-delete-memo-list", + e_source_peek_name (source)); + if (response != GTK_RESPONSE_YES) + return; + + uri = e_source_get_uri (source); + client = e_cal_model_get_client_for_uri (model, uri); + if (client == NULL) + client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL); + g_free (uri); + + g_return_if_fail (client != NULL); + + if (!e_cal_remove (client, &error)) { + g_warning ("%s", error->message); + g_error_free (error); + return; + } + + if (e_source_selector_source_is_selected (selector, source)) { + e_memo_shell_sidebar_remove_source ( + memo_shell_sidebar, source); + e_source_selector_unselect_source (selector, source); + } + + source_group = e_source_peek_group (source); + e_source_group_remove_source (source_group, source); + + source_list = memo_shell_view->priv->source_list; + if (!e_source_list_sync (source_list, &error)) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void @@ -192,6 +266,13 @@ action_memo_list_properties_cb (GtkAction *action, } static void +action_memo_new_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + /* FIXME */ +} + +static void action_memo_open_cb (GtkAction *action, EMemoShellView *memo_shell_view) { @@ -357,7 +438,7 @@ static GtkActionEntry memo_entries[] = { { "memo-forward", "mail-forward", N_("_Forward as iCalendar"), - NULL, + "<Control>f", NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_memo_forward_cb) }, @@ -403,15 +484,22 @@ static GtkActionEntry memo_entries[] = { NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_memo_list_properties_cb) }, - { "memo-open", + { "memo-new", + "stock_insert-note", + N_("New _Memo"), NULL, - N_("Open Memo"), + N_("Create a new memo"), + G_CALLBACK (action_memo_new_cb) }, + + { "memo-open", + GTK_STOCK_OPEN, + N_("_Open Memo"), "<Control>o", N_("View the selected memo"), G_CALLBACK (action_memo_open_cb) }, { "memo-open-url", - NULL, + "applications-internet", N_("Open _Web Page"), NULL, NULL, /* XXX Add a tooltip! */ @@ -443,6 +531,30 @@ static GtkToggleActionEntry memo_toggle_entries[] = { TRUE } }; +static GtkRadioActionEntry memo_search_entries[] = { + + { "memo-search-any-field-contains", + NULL, + N_("Any field contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MEMO_SEARCH_ANY_FIELD_CONTAINS }, + + { "memo-search-description-contains", + NULL, + N_("Description contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MEMO_SEARCH_DESCRIPTION_CONTAINS }, + + { "memo-search-summary-contains", + NULL, + N_("Summary contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MEMO_SEARCH_SUMMARY_CONTAINS } +}; + void e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) { @@ -451,6 +563,7 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) GtkActionGroup *action_group; GtkUIManager *manager; GConfBridge *bridge; + GtkAction *action; GObject *object; const gchar *domain; const gchar *key; @@ -460,8 +573,6 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; - e_load_ui_definition (manager, "evolution-memos.ui"); - action_group = memo_shell_view->priv->memo_actions; gtk_action_group_set_translation_domain (action_group, domain); gtk_action_group_add_actions ( @@ -470,6 +581,11 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) gtk_action_group_add_toggle_actions ( action_group, memo_toggle_entries, G_N_ELEMENTS (memo_toggle_entries), memo_shell_view); + gtk_action_group_add_radio_actions ( + action_group, memo_search_entries, + G_N_ELEMENTS (memo_search_entries), + MEMO_SEARCH_SUMMARY_CONTAINS, + NULL, NULL); gtk_ui_manager_insert_action_group (manager, action_group, 0); /* Bind GObject properties to GConf keys. */ @@ -479,58 +595,9 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) object = G_OBJECT (ACTION (MEMO_PREVIEW)); key = "/apps/evolution/calendar/display/show_memo_preview"; gconf_bridge_bind_property (bridge, key, object, "active"); -} - -void -e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view) -{ - EMemoShellContent *memo_shell_content; - ECal *client; - ETable *table; - ECalModel *model; - EMemoTable *memo_table; - EShellView *shell_view; - EShellWindow *shell_window; - GtkAction *action; - const gchar *label; - gboolean read_only = TRUE; - gboolean sensitive; - gint n_selected; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - memo_shell_content = memo_shell_view->priv->memo_shell_content; - memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); - - model = e_memo_table_get_model (memo_table); - client = e_cal_model_get_default_client (model); - - table = e_memo_table_get_table (memo_table); - n_selected = e_table_selected_count (table); - - if (client != NULL) - e_cal_is_read_only (client, &read_only, NULL); - - action = ACTION (MEMO_OPEN); - sensitive = (n_selected == 1); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (MEMO_CLIPBOARD_COPY); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (MEMO_CLIPBOARD_CUT); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); - action = ACTION (MEMO_CLIPBOARD_PASTE); - sensitive = !read_only; - gtk_action_set_sensitive (action, sensitive); + /* Fine tuning. */ action = ACTION (MEMO_DELETE); - sensitive = (n_selected > 0) && !read_only; - gtk_action_set_sensitive (action, sensitive); - label = ngettext ("Delete Memo", "Delete Memos", n_selected); - g_object_set (action, "label", label, NULL); + g_object_set (action, "short-label", _("Delete"), NULL); } diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c index 076ed3fc5d..8d8a8e110d 100644 --- a/calendar/modules/e-memo-shell-view-private.c +++ b/calendar/modules/e-memo-shell-view-private.c @@ -20,174 +20,78 @@ #include "e-memo-shell-view-private.h" -#include <widgets/menus/gal-view-factory-etable.h> +#include "widgets/menus/gal-view-factory-etable.h" static void -memo_shell_view_backend_died_cb (EMemoShellView *memo_shell_view, - ECal *client) +memo_shell_view_table_popup_event_cb (EShellView *shell_view, + GdkEventButton *event) { - EShellView *shell_view; - EShellWindow *shell_window; - GHashTable *client_table; - ESource *source; - const gchar *uid; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - source = e_cal_get_source (client); - uid = e_source_peek_uid (source); - - g_object_ref (source); - - g_hash_table_remove (client_table, uid); - e_memo_shell_view_set_status_message (memo_shell_view, NULL); - - e_error_run ( - GTK_WINDOW (shell_window), - "calendar:memos-crashed", NULL); + const gchar *widget_path; - g_object_unref (source); + widget_path = "/memo-popup"; + e_shell_view_show_popup_menu (shell_view, widget_path, event); } static void -memo_shell_view_backend_error_cb (EMemoShellView *memo_shell_view, - const gchar *message, - ECal *client) +memo_shell_view_table_user_created_cb (EMemoShellView *memo_shell_view, + EMemoTable *memo_table) { - EShellView *shell_view; - EShellWindow *shell_window; - GtkWidget *dialog; - const gchar *uri; - gchar *uri_no_passwd; - - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - uri = e_cal_get_uri (client); - uri_no_passwd = get_uri_without_password (uri); + EMemoShellSidebar *memo_shell_sidebar; + ECalModel *model; + ECal *client; + ESource *source; - dialog = gtk_message_dialog_new ( - GTK_WINDOW (shell_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error on %s:\n%s"), - uri_no_passwd, message); + /* This is the "Click to Add" handler. */ - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + model = e_memo_table_get_model (memo_table); + client = e_cal_model_get_default_client (model); + source = e_cal_get_source (client); - g_free (uri_no_passwd); + memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar; + e_memo_shell_sidebar_add_source (memo_shell_sidebar, source); } static void -memo_shell_view_client_opened_cb (EMemoShellView *memo_shell_view, - ECalendarStatus status, - ECal *client) +memo_shell_view_selector_client_added_cb (EMemoShellView *memo_shell_view, + ECal *client) { - /* FIXME */ -} - -static gboolean -memo_shell_view_add_source (EMemoShellView *memo_shell_view, - ESource *source) -{ - GHashTable *client_table; - ECal *default_client; - ECal *client; - const gchar *uid; - const gchar *uri; - gchar *status_message; - - client_table = memo_shell_view->priv->client_table; - default_client = memo_shell_view->priv->default_client; - - uid = e_source_peek_uid (source); - client = g_hash_table_lookup (client_table, uid); - - if (client != NULL) - return TRUE; - - if (default_client != NULL) { - ESource *default_source; - const gchar *default_uid; - - default_source = e_cal_get_source (default_client); - default_uid = e_source_peek_uid (default_source); - - if (strcmp (uid, default_uid) == 0) - client = g_object_ref (default_client); - } - - if (client == NULL) - client = auth_new_cal_from_source ( - source, E_CAL_SOURCE_TYPE_JOURNAL); - - if (client == NULL) - return FALSE; - - g_signal_connect_swapped ( - client, "backend-died", - G_CALLBACK (memo_shell_view_backend_died_cb), - memo_shell_view); - - g_signal_connect_swapped ( - client, "backend-error", - G_CALLBACK (memo_shell_view_backend_error_cb), - memo_shell_view); - - g_hash_table_insert (client_table, g_strdup (uid), client); - - uri = e_cal_get_uri (client); - - status_message = g_strdup_printf (_("Opening memos at %s"), uri); - e_memo_shell_view_set_status_message (memo_shell_view, status_message); - g_free (status_message); - - g_signal_connect_swapped ( - client, "cal-opened", - G_CALLBACK (memo_shell_view_client_opened_cb), - memo_shell_view); + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ECalModel *model; - e_cal_open_async (client, FALSE); + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + model = e_memo_table_get_model (memo_table); - return TRUE; + e_cal_model_add_client (model, client); } static void -memo_shell_view_table_popup_event_cb (EMemoShellView *memo_shell_view, - GdkEvent *event) +memo_shell_view_selector_client_removed_cb (EMemoShellView *memo_shell_view, + ECal *client) { - EShellView *shell_view; - EShellWindow *shell_window; - const gchar *widget_path; + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ECalModel *model; - shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - widget_path = "/memo-popup"; + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + model = e_memo_table_get_model (memo_table); - e_memo_shell_view_actions_update (memo_shell_view); - e_shell_window_show_popup_menu (shell_window, widget_path, event); + e_cal_model_remove_client (model, client); } -static void -memo_shell_view_table_user_created_cb (EMemoShellView *memo_shell_view, - EMemoTable *memo_table) +static gboolean +memo_shell_view_selector_popup_event_cb (EShellView *shell_view, + ESource *primary_source, + GdkEventButton *event) { - ECal *client; - ESource *source; - - if (memo_table->user_created_cal != NULL) - client = memo_table->user_created_cal; - else { - ECalModel *model; + const gchar *widget_path; - model = e_memo_table_get_model (memo_table); - client = e_cal_model_get_default_client (model); - } + widget_path = "/memo-list-popup"; + e_shell_view_show_popup_menu (shell_view, widget_path, event); - source = e_cal_get_source (client); - memo_shell_view_add_source (memo_shell_view, source); + return TRUE; } static void @@ -246,21 +150,14 @@ e_memo_shell_view_private_init (EMemoShellView *memo_shell_view, { EMemoShellViewPrivate *priv = memo_shell_view->priv; ESourceList *source_list; - GHashTable *client_table; GObject *object; object = G_OBJECT (shell_view_class->type_module); source_list = g_object_get_data (object, "source-list"); g_return_if_fail (E_IS_SOURCE_LIST (source_list)); - client_table = g_hash_table_new_full ( - g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) g_object_unref); - priv->source_list = g_object_ref (source_list); priv->memo_actions = gtk_action_group_new ("memos"); - priv->client_table = client_table; if (!gal_view_collection_loaded (shell_view_class->view_collection)) memo_shell_view_load_view_collection (shell_view_class); @@ -274,10 +171,15 @@ void e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) { EMemoShellViewPrivate *priv = memo_shell_view->priv; + EMemoShellContent *memo_shell_content; + EMemoShellSidebar *memo_shell_sidebar; EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellView *shell_view; EMemoTable *memo_table; + ECalModel *model; + ETable *table; + ESourceSelector *selector; shell_view = E_SHELL_VIEW (memo_shell_view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -287,8 +189,18 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) priv->memo_shell_content = g_object_ref (shell_content); priv->memo_shell_sidebar = g_object_ref (shell_sidebar); - memo_table = e_memo_shell_content_get_memo_table ( - priv->memo_shell_content); + memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + model = e_memo_table_get_model (memo_table); + table = e_memo_table_get_table (memo_table); + + memo_shell_sidebar = E_MEMO_SHELL_SIDEBAR (shell_sidebar); + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); + + g_signal_connect_swapped ( + shell_sidebar, "status-message", + G_CALLBACK (e_memo_shell_view_set_status_message), + memo_shell_view); g_signal_connect_swapped ( memo_table, "open-component", @@ -310,7 +222,48 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) G_CALLBACK (memo_shell_view_table_user_created_cb), memo_shell_view); - e_memo_shell_view_actions_update (memo_shell_view); + g_signal_connect_swapped ( + model, "model-changed", + G_CALLBACK (e_memo_shell_view_sidebar_update), + memo_shell_view); + + g_signal_connect_swapped ( + model, "model-rows-deleted", + G_CALLBACK (e_memo_shell_view_sidebar_update), + memo_shell_view); + + g_signal_connect_swapped ( + model, "model-rows-inserted", + G_CALLBACK (e_memo_shell_view_sidebar_update), + memo_shell_view); + + g_signal_connect_swapped ( + table, "selection-change", + G_CALLBACK (e_memo_shell_view_sidebar_update), + memo_shell_view); + + g_signal_connect_swapped ( + shell_sidebar, "client-added", + G_CALLBACK (memo_shell_view_selector_client_added_cb), + memo_shell_view); + + g_signal_connect_swapped ( + shell_sidebar, "client-removed", + G_CALLBACK (memo_shell_view_selector_client_removed_cb), + memo_shell_view); + + g_signal_connect_swapped ( + selector, "popup-event", + G_CALLBACK (memo_shell_view_selector_popup_event_cb), + memo_shell_view); + + g_signal_connect_swapped ( + selector, "primary-selection-changed", + G_CALLBACK (e_shell_view_update_actions), + memo_shell_view); + + e_memo_shell_view_actions_init (memo_shell_view); + e_memo_shell_view_sidebar_update (memo_shell_view); } void @@ -325,9 +278,6 @@ e_memo_shell_view_private_dispose (EMemoShellView *memo_shell_view) DISPOSE (priv->memo_shell_content); DISPOSE (priv->memo_shell_sidebar); - g_hash_table_remove_all (priv->client_table); - DISPOSE (priv->default_client); - if (memo_shell_view->priv->activity != NULL) { /* XXX Activity is not cancellable. */ e_activity_complete (memo_shell_view->priv->activity); @@ -339,9 +289,7 @@ e_memo_shell_view_private_dispose (EMemoShellView *memo_shell_view) void e_memo_shell_view_private_finalize (EMemoShellView *memo_shell_view) { - EMemoShellViewPrivate *priv = memo_shell_view->priv; - - g_hash_table_destroy (priv->client_table); + /* XXX Nothing to do? */ } void @@ -410,3 +358,45 @@ e_memo_shell_view_set_status_message (EMemoShellView *memo_shell_view, memo_shell_view->priv->activity = activity; } + +void +e_memo_shell_view_sidebar_update (EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + EMemoTable *memo_table; + ECalModel *model; + ETable *table; + GString *string; + const gchar *format; + gint n_rows; + gint n_selected; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + + model = e_memo_table_get_model (memo_table); + table = e_memo_table_get_table (memo_table); + + n_rows = e_table_model_row_count (E_TABLE_MODEL (model)); + n_selected = e_table_selected_count (table); + + string = g_string_sized_new (64); + + format = ngettext ("%d memo", "%d memos", n_rows); + g_string_append_printf (string, format, n_rows); + + if (n_selected > 0) { + format = _("%d selected"); + g_string_append_len (string, ", ", 2); + g_string_append_printf (string, format, n_selected); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); + + g_string_free (string, TRUE); +} diff --git a/calendar/modules/e-memo-shell-view-private.h b/calendar/modules/e-memo-shell-view-private.h index 7d8958eae7..fd30a14898 100644 --- a/calendar/modules/e-memo-shell-view-private.h +++ b/calendar/modules/e-memo-shell-view-private.h @@ -29,12 +29,13 @@ #include "e-util/e-dialog-utils.h" #include "e-util/e-error.h" #include "e-util/e-util.h" +#include "e-util/gconf-bridge.h" -#include "calendar/common/authentication.h" -#include "calendar/gui/misc.h" #include "calendar/gui/e-calendar-selector.h" #include "calendar/gui/e-memo-preview.h" +#include "calendar/gui/print.h" #include "calendar/gui/dialogs/calendar-setup.h" +#include "calendar/gui/dialogs/copy-source-dialog.h" #include "calendar/gui/dialogs/memo-editor.h" #include "e-memo-shell-content.h" @@ -62,6 +63,13 @@ G_BEGIN_DECLS +/* List these in the order to be displayed. */ +enum { + MEMO_SEARCH_SUMMARY_CONTAINS, + MEMO_SEARCH_DESCRIPTION_CONTAINS, + MEMO_SEARCH_ANY_FIELD_CONTAINS +}; + struct _EMemoShellViewPrivate { /*** Module Data ***/ @@ -78,10 +86,6 @@ struct _EMemoShellViewPrivate { EMemoShellContent *memo_shell_content; EMemoShellSidebar *memo_shell_sidebar; - /* UID -> Client */ - GHashTable *client_table; - ECal *default_client; - EActivity *activity; }; @@ -99,14 +103,14 @@ void e_memo_shell_view_private_finalize void e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view); -void e_memo_shell_view_actions_update - (EMemoShellView *memo_shell_view); void e_memo_shell_view_open_memo (EMemoShellView *memo_shell_view, ECalModelComponent *comp_data); void e_memo_shell_view_set_status_message (EMemoShellView *memo_shell_view, const gchar *status_message); +void e_memo_shell_view_sidebar_update + (EMemoShellView *memo_shell_view); G_END_DECLS diff --git a/calendar/modules/e-memo-shell-view.c b/calendar/modules/e-memo-shell-view.c index f50c877c9a..806389a96f 100644 --- a/calendar/modules/e-memo-shell-view.c +++ b/calendar/modules/e-memo-shell-view.c @@ -73,17 +73,58 @@ memo_shell_view_constructed (GObject *object) } static void -memo_shell_view_changed (EShellView *shell_view) +memo_shell_view_update_actions (EShellView *shell_view) { EMemoShellViewPrivate *priv; - GtkActionGroup *action_group; - gboolean visible; + EMemoShellContent *memo_shell_content; + EShellWindow *shell_window; + ECal *client; + ETable *table; + ECalModel *model; + EMemoTable *memo_table; + GtkAction *action; + const gchar *label; + gboolean read_only = TRUE; + gboolean sensitive; + gint n_selected; priv = E_MEMO_SHELL_VIEW_GET_PRIVATE (shell_view); - action_group = priv->memo_actions; - visible = e_shell_view_is_active (shell_view); - gtk_action_group_set_visible (action_group, visible); + shell_window = e_shell_view_get_shell_window (shell_view); + + memo_shell_content = priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + + model = e_memo_table_get_model (memo_table); + client = e_cal_model_get_default_client (model); + + table = e_memo_table_get_table (memo_table); + n_selected = e_table_selected_count (table); + + if (client != NULL) + e_cal_is_read_only (client, &read_only, NULL); + + action = ACTION (MEMO_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_CUT); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_CLIPBOARD_PASTE); + sensitive = !read_only; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (MEMO_DELETE); + sensitive = (n_selected > 0) && !read_only; + gtk_action_set_sensitive (action, sensitive); + label = ngettext ("Delete Memo", "Delete Memos", n_selected); + g_object_set (action, "label", label, NULL); } static void @@ -105,11 +146,12 @@ memo_shell_view_class_init (EMemoShellView *class, shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = N_("Memos"); shell_view_class->icon_name = "evolution-memos"; + shell_view_class->ui_definition = "evolution-memos.ui"; shell_view_class->search_options = "/memo-search-options"; shell_view_class->type_module = type_module; shell_view_class->new_shell_content = e_memo_shell_content_new; shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new; - shell_view_class->changed = memo_shell_view_changed; + shell_view_class->update_actions = memo_shell_view_update_actions; g_object_class_install_property ( object_class, diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c index 8f7e45f175..299994af6d 100644 --- a/calendar/modules/e-task-shell-content.c +++ b/calendar/modules/e-task-shell-content.c @@ -90,15 +90,13 @@ task_shell_content_display_view_cb (ETaskShellContent *task_shell_content, GalView *gal_view) { ECalendarTable *task_table; - ETableScrolled *table_scrolled; ETable *table; if (!GAL_IS_VIEW_ETABLE (gal_view)) return; task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); - table_scrolled = E_TABLE_SCROLLED (task_table->etable); - table = e_table_scrolled_get_table (table_scrolled); + table = e_task_table_get_table (task_table); gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); } @@ -184,7 +182,6 @@ task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content, { ECalModelComponent *comp_data; ETaskTable *task_table; - ETableScrolled *table_scrolled; ETable *table; const gchar *current_uid; const gchar *uid; @@ -202,8 +199,7 @@ task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content, return; task_table = E_TASK_TABLE (task_shell_content->priv->task_table); - table_scrolled = E_TABLE_SCROLLED (task_table->etable); - table = e_table_scrolled_get_table (table_scrolled); + table = e_task_table_get_table (task_table); task_shell_content_cursor_change_cb (task_shell_content, 0, table); } @@ -317,20 +313,6 @@ task_shell_content_constructed (GObject *object) shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); view_collection = shell_view_class->view_collection; - /* Load the view instance. */ - - view_instance = gal_view_instance_new (view_collection, NULL); - g_signal_connect_swapped ( - view_instance, "changed", - G_CALLBACK (task_shell_content_changed_cb), - object); - g_signal_connect_swapped ( - view_instance, "display-view", - G_CALLBACK (task_shell_content_display_view_cb), - object); - gal_view_instance_load (view_instance); - priv->view_instance = view_instance; - /* Build content widgets. */ container = GTK_WIDGET (object); @@ -406,6 +388,20 @@ task_shell_content_constructed (GObject *object) G_CALLBACK (task_shell_content_model_row_changed_cb), object); + /* Load the view instance. */ + + view_instance = gal_view_instance_new (view_collection, NULL); + g_signal_connect_swapped ( + view_instance, "changed", + G_CALLBACK (task_shell_content_changed_cb), + object); + g_signal_connect_swapped ( + view_instance, "display-view", + G_CALLBACK (task_shell_content_display_view_cb), + object); + gal_view_instance_load (view_instance); + priv->view_instance = view_instance; + /* Bind GObject properties to GConf keys. */ bridge = gconf_bridge_get (); diff --git a/calendar/modules/e-task-shell-sidebar.c b/calendar/modules/e-task-shell-sidebar.c index b3d0c487bc..77cca13288 100644 --- a/calendar/modules/e-task-shell-sidebar.c +++ b/calendar/modules/e-task-shell-sidebar.c @@ -41,46 +41,6 @@ enum { static gpointer parent_class; -#if 0 /* MOVE THIS TO ETaskShellView */ -static void -task_shell_sidebar_update (EShellSidebar *shell_sidebar) -{ - EShellView *shell_view; - ETasks *tasks; - ETable *table; - ECalModel *model; - ECalendarTable *cal_table; - GString *string; - const gchar *format; - gint n_rows; - gint n_selected; - - shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - tasks = e_task_shell_view_get_tasks (E_TASK_SHELL_VIEW (shell_view)); - cal_table = e_tasks_get_calendar_table (tasks); - model = e_calendar_table_get_model (cal_table); - table = e_calendar_table_get_table (cal_table); - - n_rows = e_table_model_get_row_count (model); - n_selected = e_table_selected_count (table); - - string = g_string_sized_new (64); - - format = ngettext ("%d task", "%d tasks", n_rows); - g_string_append_printf (string, format, n_rows); - - if (n_selected > 0) { - format = _("%d selected"); - g_string_append_len (string, ", ", 2); - g_string_append_printf (string, format, n_selected); - } - - e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); - - g_string_free (string, TRUE); -} -#endif - static void task_shell_sidebar_get_property (GObject *object, guint property_id, @@ -127,6 +87,9 @@ task_shell_sidebar_constructed (GObject *object) priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); task_shell_view = E_TASK_SHELL_VIEW (shell_view); @@ -150,39 +113,6 @@ task_shell_sidebar_constructed (GObject *object) gtk_container_add (container, widget); priv->selector = g_object_ref (widget); gtk_widget_show (widget); - -#if 0 /* MOVE THIS TO ETaskShellView */ - - /* Setup signal handlers. */ - - tasks = e_task_shell_view_get_tasks (task_shell_view); - cal_table = e_tasks_get_calendar_table (tasks); - model = e_calendar_table_get_model (cal_table); - table = e_calendar_table_get_table (cal_table); - - g_signal_connect_swapped ( - model, "model-changed", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "model-rows-deleted", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "model-rows-inserted", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - g_signal_connect_swapped ( - model, "selection-change", - G_CALLBACK (task_shell_sidebar_update), - shell_sidebar); - - task_shell_sidebar_update (shell_sidebar); - -#endif } static void @@ -255,11 +185,11 @@ e_task_shell_sidebar_new (EShellView *shell_view) "shell-view", shell_view, NULL); } -GtkWidget * +ESourceSelector * e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar) { g_return_val_if_fail ( E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar), NULL); - return task_shell_sidebar->priv->selector; + return E_SOURCE_SELECTOR (task_shell_sidebar->priv->selector); } diff --git a/calendar/modules/e-task-shell-sidebar.h b/calendar/modules/e-task-shell-sidebar.h index 2d992dbc82..411b8588c2 100644 --- a/calendar/modules/e-task-shell-sidebar.h +++ b/calendar/modules/e-task-shell-sidebar.h @@ -21,6 +21,8 @@ #ifndef E_TASK_SHELL_SIDEBAR_H #define E_TASK_SHELL_SIDEBAR_H +#include <libedataserverui/e-source-selector.h> + #include <shell/e-shell-sidebar.h> #include <shell/e-shell-view.h> @@ -60,7 +62,8 @@ struct _ETaskShellSidebarClass { GType e_task_shell_sidebar_get_type (void); GtkWidget * e_task_shell_sidebar_new (EShellView *shell_view); -GtkWidget * e_task_shell_sidebar_get_selector +ESourceSelector * + e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar); G_END_DECLS diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c index 2668522aee..a29944280f 100644 --- a/calendar/modules/e-task-shell-view-actions.c +++ b/calendar/modules/e-task-shell-view-actions.c @@ -24,6 +24,23 @@ static void action_task_assign_cb (GtkAction *action, ETaskShellView *task_shell_view) { + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModelComponent *comp_data; + GSList *list; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the first selected task. */ + e_task_shell_view_open_task (task_shell_view, comp_data); + + /* FIXME Need to actually assign the task. */ } static void @@ -87,6 +104,29 @@ static void action_task_forward_cb (GtkAction *action, ETaskShellView *task_shell_view) { + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + ECalComponentItipMethod method; + GSList *list; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only forward the first selected task. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + method = E_CAL_COMPONENT_METHOD_PUBLISH; + e_cal_component_set_icalcomponent (comp, clone); + itip_send_comp (method, comp, comp_data->client, NULL, NULL, NULL); + g_object_unref (comp); } static void @@ -110,6 +150,40 @@ action_task_list_new_cb (GtkAction *action, } static void +action_task_list_print_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ETable *table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + table = e_task_table_get_table (task_table); + + print_table ( + table, _("Print Tasks"), _("Tasks"), + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); +} + +static void +action_task_list_print_preview_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ETable *table; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + table = e_task_table_get_table (task_table); + + print_table ( + table, _("Print Tasks"), _("Tasks"), + GTK_PRINT_OPERATION_ACTION_PREVIEW); +} + +static void action_task_list_properties_cb (GtkAction *action, ETaskShellView *task_shell_view) { @@ -119,6 +193,50 @@ static void action_task_mark_complete_cb (GtkAction *action, ETaskShellView *task_shell_view) { + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModel *model; + GSList *list, *iter; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + list = e_task_table_get_selected (task_table); + model = e_task_table_get_model (task_table); + + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + e_cal_model_tasks_mark_comp_complete (model, comp_data); + } + + g_slist_free (list); +} + +static void +action_task_mark_incomplete_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModel *model; + GSList *list, *iter; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + list = e_task_table_get_selected (task_table); + model = e_task_table_get_model (task_table); + + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + e_cal_model_tasks_mark_comp_incomplete (model, comp_data); + } + + g_slist_free (list); +} + +static void +action_task_new_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ } static void @@ -130,10 +248,46 @@ action_task_open_cb (GtkAction *action, task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); + e_task_table_open_selected (task_table); } static void +action_task_open_url_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModelComponent *comp_data; + icalproperty *prop; + GdkScreen *screen; + const gchar *uri; + GSList *list; + GError *error = NULL; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + + /* XXX We only open the URI of the first selected task. */ + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + g_return_if_fail (prop == NULL); + + screen = gtk_widget_get_screen (GTK_WIDGET (task_shell_view)); + uri = icalproperty_get_url (prop); + gtk_show_uri (screen, uri, GDK_CURRENT_TIME, &error); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } +} + +static void action_task_preview_cb (GtkToggleAction *action, ETaskShellView *task_shell_view) { @@ -151,38 +305,69 @@ action_task_print_cb (GtkAction *action, { ETaskShellContent *task_shell_content; ETaskTable *task_table; - ETable *table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + GtkPrintOperationAction print_action; + GSList *list; task_shell_content = task_shell_view->priv->task_shell_content; - task_table = e_task_shell_content_get_task_table (task_shell_content); - table = e_task_table_get_table (task_table); + task_table = e_memo_shell_content_get_task_table (task_shell_content); + + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only print the first selected task. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + e_cal_component_set_icalcomponent (comp, clone); + print_comp (comp, comp_data->client, print_action); + g_object_unref (comp); +} - print_table ( - table, _("Print Tasks"), _("Tasks"), - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); +static void +action_task_purge_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ } static void -action_task_print_preview_cb (GtkAction *action, - ETaskShellView *task_shell_view) +action_task_save_as_cb (GtkAction *action, + ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; ETaskTable *task_table; - ETable *table; + ECalModelComponent *comp_data; + GSList *list; + gchar *filename; + gchar *string; task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); - table = e_task_table_get_table (task_table); - print_table ( - table, _("Print Tasks"), _("Tasks"), - GTK_PRINT_OPERATION_ACTION_PREVIEW); -} + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); -static void -action_task_purge_cb (GtkAction *action, - ETaskShellView *task_shell_view) -{ + filename = e_file_dialog_save (_("Save as..."), NULL); + if (filename == NULL) + return; + + string = e_cal_component_as_string ( + comp_data->client, comp_data->icalcomp); + if (string == NULL) { + g_warning ("Could not convert task to a string"); + return; + } + + e_write_file_uri (filename, string); + + g_free (filename); + g_free (string); } static GtkActionEntry task_entries[] = { @@ -217,7 +402,7 @@ static GtkActionEntry task_entries[] = { { "task-delete", GTK_STOCK_DELETE, - NULL, + N_("Delete Task"), NULL, N_("Delete selected tasks"), G_CALLBACK (action_task_delete_cb) }, @@ -250,6 +435,20 @@ static GtkActionEntry task_entries[] = { N_("Create a new task list"), G_CALLBACK (action_task_list_new_cb) }, + { "task-list-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print the list of tasks"), + G_CALLBACK (action_task_list_print_cb) }, + + { "task-list-print-preview", + GTK_STOCK_PRINT_PREVIEW, + NULL, + NULL, + N_("Preview the list of tasks to be printed"), + G_CALLBACK (action_task_list_print_preview_cb) }, + { "task-list-properties", GTK_STOCK_PROPERTIES, NULL, @@ -259,38 +458,52 @@ static GtkActionEntry task_entries[] = { { "task-mark-complete", NULL, - N_("Mar_k as Complete"), + N_("_Mark as Complete"), "<Control>k", N_("Mark selected tasks as complete"), G_CALLBACK (action_task_mark_complete_cb) }, - { "task-open", + { "task-new", + "stock_task", + N_("New _Task"), NULL, + N_("Create a new task"), + G_CALLBACK (action_task_new_cb) }, + + { "task-open", + GTK_STOCK_OPEN, N_("_Open Task"), "<Control>o", N_("View the selected task"), G_CALLBACK (action_task_open_cb) }, + { "task-open-url", + "applications-internet", + N_("Open _Web Page"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_open_url_cb) }, + { "task-print", GTK_STOCK_PRINT, NULL, NULL, - N_("Print the list of tasks"), + N_("Print the selected task"), G_CALLBACK (action_task_print_cb) }, - { "task-print-preview", - GTK_STOCK_PRINT_PREVIEW, - NULL, - NULL, - N_("Preview the list of tasks to be printed"), - G_CALLBACK (action_task_print_preview_cb) }, - { "task-purge", NULL, N_("Purg_e"), "<Control>e", N_("Delete completed tasks"), - G_CALLBACK (action_task_purge_cb) } + G_CALLBACK (action_task_purge_cb) }, + + { "task-save-as", + GTK_STOCK_SAVE_AS, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_save_as_cb) } }; static GtkToggleActionEntry task_toggle_entries[] = { @@ -311,7 +524,11 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) EShellWindow *shell_window; GtkActionGroup *action_group; GtkUIManager *manager; + GConfBridge *bridge; + GtkAction *action; + GObject *object; const gchar *domain; + const gchar *key; shell_view = E_SHELL_VIEW (task_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -329,4 +546,71 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) action_group, task_toggle_entries, G_N_ELEMENTS (task_toggle_entries), task_shell_view); gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (ACTION (TASK_PREVIEW)); + key = "/apps/evolution/calendar/display/show_task_preview"; + gconf_bridge_bind_property (bridge, key, object, "active"); + + /* Fine tuning. */ + + action = ACTION (TASK_DELETE); + g_object_set (action, "short-label", _("Delete"), NULL); +} + +void +e_task_shell_view_actions_update (ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + ECal *client; + ETable *table; + ECalModel *model; + ETaskTable *task_table; + EShellView *shell_view; + EShellWindow *shell_window; + GtkAction *action; + const gchar *label; + gboolean read_only = TRUE; + gboolean sensitive; + gint n_selected; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + model = e_task_table_get_model (task_table); + client = e_cal_model_get_default_client (model); + + table = e_task_table_get_table (task_table); + n_selected = e_table_selected_count (table); + + if (client != NULL) + e_cal_is_read_only (client, &read_only, NULL); + + action = ACTION (TASK_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_CLIPBOARD_CUT); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_CLIPBOARD_PASTE); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_DELETE); + sensitive = (n_selected > 0) && !read_only; + gtk_action_set_sensitive (action, sensitive); + label = ngettext ("Delete Task", "Delete Tasks", n_selected); + g_object_set (action, "label", label, NULL); } diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c index b16ac80edb..8e573f538d 100644 --- a/calendar/modules/e-task-shell-view-private.c +++ b/calendar/modules/e-task-shell-view-private.c @@ -92,6 +92,8 @@ static gboolean task_shell_view_add_source (ETaskShellView *task_shell_view, ESource *source) { + ETaskShellSidebar *task_shell_sidebar; + ESourceSelector *selector; GHashTable *client_table; ECal *default_client; ECal *client; @@ -144,6 +146,10 @@ task_shell_view_add_source (ETaskShellView *task_shell_view, e_task_shell_view_set_status_message (task_shell_view, status_message); g_free (status_message); + task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + e_source_selector_select_source (selector, source); + g_signal_connect_swapped ( client, "cal-opened", G_CALLBACK (task_shell_view_client_opened_cb), @@ -156,18 +162,16 @@ task_shell_view_add_source (ETaskShellView *task_shell_view, static void task_shell_view_table_popup_event_cb (ETaskShellView *task_shell_view, - GdkEvent *event) + GdkEventButton *event) { EShellView *shell_view; - EShellWindow *shell_window; const gchar *widget_path; shell_view = E_SHELL_VIEW (task_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); widget_path = "/task-popup"; e_task_shell_view_actions_update (task_shell_view); - e_shell_window_show_popup_menu (shell_window, widget_path, event); + e_shell_view_show_popup_menu (shell_view, widget_path, event); } static void @@ -274,10 +278,13 @@ void e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) { ETaskShellViewPrivate *priv = task_shell_view->priv; + ETaskShellContent *task_shell_content; EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellView *shell_view; ETaskTable *task_table; + ECalModel *model; + ETable *table; shell_view = E_SHELL_VIEW (task_shell_view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -287,8 +294,10 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) priv->task_shell_content = g_object_ref (shell_content); priv->task_shell_sidebar = g_object_ref (shell_sidebar); - task_table = e_task_shell_content_get_task_table ( - priv->task_shell_content); + task_shell_content = E_TASK_SHELL_CONTENT (shell_content); + task_table = e_task_shell_content_get_task_table (task_shell_content); + model = e_task_table_get_model (task_table); + table = e_task_table_get_table (task_table); g_signal_connect_swapped ( task_table, "open-component", @@ -310,7 +319,28 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) G_CALLBACK (task_shell_view_table_user_created_cb), task_shell_view); - e_task_shell_view_actions_update (task_shell_view); + g_signal_connect_swapped ( + model, "model-changed", + G_CALLBACK (e_task_shell_view_sidebar_update), + task_shell_view); + + g_signal_connect_swapped ( + model, "model-rows-deleted", + G_CALLBACK (e_task_shell_view_sidebar_update), + task_shell_view); + + g_signal_connect_swapped ( + model, "model-rows-inserted", + G_CALLBACK (e_task_shell_view_sidebar_update), + task_shell_view); + + g_signal_connect_swapped ( + table, "selection-change", + G_CALLBACK (e_task_shell_view_sidebar_update), + task_shell_view); + + e_task_shell_view_actions_init (task_shell_view); + e_task_shell_view_sidebar_update (task_shell_view); } void @@ -352,6 +382,7 @@ e_task_shell_view_open_task (ETaskShellView *task_shell_view, CompEditorFlags flags = 0; ECalComponent *comp; icalcomponent *clone; + icalproperty *prop; const gchar *uid; g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view)); @@ -367,14 +398,24 @@ e_task_shell_view_open_task (ETaskShellView *task_shell_view, clone = icalcomponent_new_clone (comp_data->icalcomp); e_cal_component_set_icalcomponent (comp, clone); - /* FIXME Do special stuff if task is assigned. */ + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); + if (prop != NULL) + flags |= COMP_EDITOR_IS_ASSIGNED; + + if (itip_organizer_is_user (comp, comp_data->client)) + flags |= COMP_EDITOR_USER_ORG; + + if (!itip_organizer_has_attendees (comp)) + flags |= COMP_EDITOR_USER_ORG; editor = task_editor_new (comp_data->client, flags); comp_editor_edit_comp (editor, comp); g_object_ref (comp); - /* FIXME More special stuff here... */ + if (flags & COMP_EDITOR_IS_ASSIGNED) + task_editor_show_assignment (TASK_EDITOR (editor)); exit: gtk_window_present (GTK_WINDOW (editor)); @@ -408,3 +449,45 @@ e_task_shell_view_set_status_message (ETaskShellView *task_shell_view, task_shell_view->priv->activity = activity; } + +void +e_task_shell_view_sidebar_update (ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + EShellView *shell_view; + EShellSidebar *shell_sidebar; + ETaskTable *task_table; + ECalModel *model; + ETable *table; + GString *string; + const gchar *format; + gint n_rows; + gint n_selected; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + model = e_task_table_get_model (task_table); + table = e_task_table_get_table (task_table); + + n_rows = e_table_model_row_count (E_TABLE_MODEL (model)); + n_selected = e_table_selected_count (table); + + string = g_string_sized_new (64); + + format = ngettext ("%d task", "%d tasks", n_rows); + g_string_append_printf (string, format, n_rows); + + if (n_selected > 0) { + format = _("%d selected"); + g_string_append_len (string, ", ", 2); + g_string_append_printf (string, format, n_selected); + } + + e_shell_sidebar_set_secondary_text (shell_sidebar, string->str); + + g_string_free (string, TRUE); +} diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h index ac6accfbcf..bad511ca20 100644 --- a/calendar/modules/e-task-shell-view-private.h +++ b/calendar/modules/e-task-shell-view-private.h @@ -107,6 +107,8 @@ void e_task_shell_view_open_task void e_task_shell_view_set_status_message (ETaskShellView *task_shell_view, const gchar *status_message); +void e_task_shell_view_sidebar_update + (ETaskShellView *task_shell_view); G_END_DECLS diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c index 6b85d1ed45..8ef3c3a9f4 100644 --- a/calendar/modules/e-task-shell-view.c +++ b/calendar/modules/e-task-shell-view.c @@ -73,20 +73,6 @@ task_shell_view_constructed (GObject *object) } static void -task_shell_view_changed (EShellView *shell_view) -{ - ETaskShellViewPrivate *priv; - GtkActionGroup *action_group; - gboolean visible; - - priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view); - - action_group = priv->task_actions; - visible = e_shell_view_is_active (shell_view); - gtk_action_group_set_visible (action_group, visible); -} - -static void task_shell_view_class_init (ETaskShellView *class, GTypeModule *type_module) { @@ -105,10 +91,10 @@ task_shell_view_class_init (ETaskShellView *class, shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = N_("Tasks"); shell_view_class->icon_name = "evolution-tasks"; + shell_view_class->ui_definition = "evolution-tasks.ui"; shell_view_class->search_options = "/task-search-options"; shell_view_class->type_module = type_module; shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new; - shell_view_class->changed = task_shell_view_changed; g_object_class_install_property ( object_class, |