diff options
Diffstat (limited to 'modules/calendar')
-rw-r--r-- | modules/calendar/Makefile.am | 1 | ||||
-rw-r--r-- | modules/calendar/e-cal-attachment-handler.c | 6 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-backend.c | 4 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-content.c | 10 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-migrate.c | 555 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-sidebar.c | 48 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-actions.c | 56 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-private.c | 7 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view.c | 6 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-backend.c | 4 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-content.c | 8 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-migrate.c | 2 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-sidebar.c | 44 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-backend.c | 4 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-content.c | 8 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-migrate.c | 495 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-sidebar.c | 44 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-actions.c | 5 |
18 files changed, 214 insertions, 1093 deletions
diff --git a/modules/calendar/Makefile.am b/modules/calendar/Makefile.am index bbabb6cfb2..0beb1285fa 100644 --- a/modules/calendar/Makefile.am +++ b/modules/calendar/Makefile.am @@ -7,6 +7,7 @@ libevolution_module_calendar_la_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/widgets \ -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ + $(CAMEL_CFLAGS) \ $(GNOME_PLATFORM_CFLAGS) \ $(EVOLUTION_CALENDAR_CFLAGS) diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c index b532af85e5..ce88a18267 100644 --- a/modules/calendar/e-cal-attachment-handler.c +++ b/modules/calendar/e-cal-attachment-handler.c @@ -24,7 +24,7 @@ #include <glib/gi18n.h> #include <libical/ical.h> #include <libecal/e-cal.h> -#include <camel/camel-stream-mem.h> +#include <camel/camel.h> #include <libedataserverui/e-source-selector.h> #include "calendar/common/authentication.h" @@ -79,9 +79,9 @@ attachment_handler_get_component (EAttachment *attachment) buffer = g_byte_array_new (); stream = camel_stream_mem_new (); camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer); - wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part)); + wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part)); camel_data_wrapper_decode_to_stream (wrapper, stream); - camel_object_unref (stream); + g_object_unref (stream); component = e_cal_util_parse_ics_string ((gchar *) buffer->data); diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c index 278190eefa..e1f682357c 100644 --- a/modules/calendar/e-cal-shell-backend.c +++ b/modules/calendar/e-cal-shell-backend.c @@ -783,8 +783,8 @@ cal_shell_backend_class_init (ECalShellBackendClass *class) PROP_SOURCE_LIST, g_param_spec_object ( "source-list", - _("Source List"), - _("The registry of calendars"), + "Source List", + "The registry of calendars", E_TYPE_SOURCE_LIST, G_PARAM_READABLE)); } diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c index 99fb717c90..a51a072f66 100644 --- a/modules/calendar/e-cal-shell-content.c +++ b/modules/calendar/e-cal-shell-content.c @@ -200,11 +200,15 @@ e_cal_shell_content_save_state (ECalShellContent *cal_shell_content) priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (cal_shell_content); - if (priv->task_table) - cal_shell_content_save_table_state (E_SHELL_CONTENT (cal_shell_content), E_TABLE (priv->task_table)); + if (priv->task_table != NULL) + cal_shell_content_save_table_state ( + E_SHELL_CONTENT (cal_shell_content), + E_TABLE (priv->task_table)); if (priv->memo_table != NULL) - cal_shell_content_save_table_state (E_SHELL_CONTENT (cal_shell_content), E_TABLE (priv->memo_table)); + cal_shell_content_save_table_state ( + E_SHELL_CONTENT (cal_shell_content), + E_TABLE (priv->memo_table)); } static void diff --git a/modules/calendar/e-cal-shell-migrate.c b/modules/calendar/e-cal-shell-migrate.c index f307522a9b..c7511f69f8 100644 --- a/modules/calendar/e-cal-shell-migrate.c +++ b/modules/calendar/e-cal-shell-migrate.c @@ -36,8 +36,6 @@ #include <libedataserver/e-source-list.h> #include <libedataserver/e-xml-hash-utils.h> -#include "e-util/e-bconf-map.h" -#include "e-util/e-folder-map.h" #include "e-util/e-util-private.h" #include "calendar/gui/calendar-config.h" #include "calendar/gui/calendar-config-keys.h" @@ -49,427 +47,6 @@ #define BAD_CONTACTS_BASE_URI "contact://" #define PERSONAL_RELATIVE_URI "system" -static e_gconf_map_t calendar_display_map[] = { - /* /Calendar/Display */ - { "Timezone", "calendar/display/timezone", E_GCONF_MAP_STRING }, - { "Use24HourFormat", "calendar/display/use_24hour_format", E_GCONF_MAP_BOOL }, - { "WeekStartDay", "calendar/display/week_start_day", E_GCONF_MAP_INT }, - { "DayStartHour", "calendar/display/day_start_hour", E_GCONF_MAP_INT }, - { "DayStartMinute", "calendar/display/day_start_minute", E_GCONF_MAP_INT }, - { "DayEndHour", "calendar/display/day_end_hour", E_GCONF_MAP_INT }, - { "DayEndMinute", "calendar/display/day_end_minute", E_GCONF_MAP_INT }, - { "TimeDivisions", "calendar/display/time_divisions", E_GCONF_MAP_INT }, - { "View", "calendar/display/default_view", E_GCONF_MAP_INT }, - { "HPanePosition", "calendar/display/hpane_position", E_GCONF_MAP_FLOAT }, - { "VPanePosition", "calendar/display/vpane_position", E_GCONF_MAP_FLOAT }, - { "MonthHPanePosition", "calendar/display/month_hpane_position", E_GCONF_MAP_FLOAT }, - { "MonthVPanePosition", "calendar/display/month_vpane_position", E_GCONF_MAP_FLOAT }, - { "CompressWeekend", "calendar/display/compress_weekend", E_GCONF_MAP_BOOL }, - { "ShowEventEndTime", "calendar/display/show_event_end", E_GCONF_MAP_BOOL }, - { "WorkingDays", "calendar/display/working_days", E_GCONF_MAP_INT }, - { NULL }, -}; - -static e_gconf_map_t calendar_other_map[] = { - /* /Calendar/Other */ - { "ConfirmDelete", "calendar/prompts/confirm_delete", E_GCONF_MAP_BOOL }, - { "ConfirmExpunge", "calendar/prompts/confirm_purge", E_GCONF_MAP_BOOL }, - { "UseDefaultReminder", "calendar/other/use_default_reminder", E_GCONF_MAP_BOOL }, - { "DefaultReminderInterval", "calendar/other/default_reminder_interval", E_GCONF_MAP_INT }, - { "DefaultReminderUnits", "calendar/other/default_reminder_units", E_GCONF_MAP_STRING }, - { NULL }, -}; - -static e_gconf_map_t calendar_datenavigator_map[] = { - /* /Calendar/DateNavigator */ - { "ShowWeekNumbers", "calendar/display/show_week_numbers", E_GCONF_MAP_BOOL }, - { NULL }, -}; - -static e_gconf_map_t calendar_alarmnotify_map[] = { - /* /Calendar/AlarmNotify */ - { "LastNotificationTime", "calendar/notify/last_notification_time", E_GCONF_MAP_INT }, - { "CalendarToLoad%i", "calendar/notify/calendars", E_GCONF_MAP_STRING|E_GCONF_MAP_LIST }, - { "BlessedProgram%i", "calendar/notify/programs", E_GCONF_MAP_STRING|E_GCONF_MAP_LIST }, - { NULL }, -}; - -static e_gconf_map_list_t calendar_remap_list[] = { - - { "/Calendar/Display", calendar_display_map }, - { "/Calendar/Other/Map", calendar_other_map }, - { "/Calendar/DateNavigator", calendar_datenavigator_map }, - { "/Calendar/AlarmNotify", calendar_alarmnotify_map }, - - { NULL }, -}; - -static GtkWidget *window; -static GtkLabel *label; -static GtkProgressBar *progress; - -#ifndef G_OS_WIN32 - -/* No previous versions have been available on Win32, so don't - * bother with upgrade support from 1.x on Win32. - */ - -static void -setup_progress_dialog (void) -{ - GtkWidget *vbox, *hbox, *w; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *) window, _("Migrating...")); - gtk_window_set_modal ((GtkWindow *) window, TRUE); - gtk_container_set_border_width ((GtkContainer *) window, 6); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_widget_show (vbox); - gtk_container_add ((GtkContainer *) window, vbox); - - w = gtk_label_new (_("The location and hierarchy of the Evolution calendar " - "folders has changed since Evolution 1.x.\n\nPlease be " - "patient while Evolution migrates your folders...")); - - gtk_label_set_line_wrap ((GtkLabel *) w, TRUE); - gtk_widget_show (w); - gtk_box_pack_start ((GtkBox *) vbox, w, TRUE, TRUE, 0); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_widget_show (hbox); - gtk_box_pack_start ((GtkBox *) vbox, hbox, TRUE, TRUE, 0); - - label = (GtkLabel *) gtk_label_new (""); - gtk_widget_show ((GtkWidget *) label); - gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) label, TRUE, TRUE, 0); - - progress = (GtkProgressBar *) gtk_progress_bar_new (); - gtk_widget_show ((GtkWidget *) progress); - gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) progress, TRUE, TRUE, 0); - - gtk_widget_show (window); -} - -static void -dialog_close (void) -{ - gtk_widget_destroy ((GtkWidget *) window); -} - -static void -dialog_set_folder_name (const gchar *folder_name) -{ - gchar *text; - - text = g_strdup_printf (_("Migrating '%s':"), folder_name); - gtk_label_set_text (label, text); - g_free (text); - - gtk_progress_bar_set_fraction (progress, 0.0); - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static void -dialog_set_progress (double percent) -{ - gchar text[5]; - - snprintf (text, sizeof (text), "%d%%", (gint) (percent * 100.0f)); - - gtk_progress_bar_set_fraction (progress, percent); - gtk_progress_bar_set_text (progress, text); - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static gboolean -check_for_conflict (ESourceGroup *group, gchar *name) -{ - GSList *sources; - GSList *s; - - sources = e_source_group_peek_sources (group); - - for (s = sources; s; s = s->next) { - ESource *source = E_SOURCE (s->data); - - if (!strcmp (e_source_peek_name (source), name)) - return TRUE; - } - - return FALSE; -} - -static gchar * -get_source_name (ESourceGroup *group, const gchar *path) -{ - gchar **p = g_strsplit (path, "/", 0); - gint i, j, starting_index; - gint num_elements; - gboolean conflict; - GString *s = g_string_new (NULL); - - for (i = 0; p[i]; i ++); - - num_elements = i; - i--; - - /* p[i] is now the last path element */ - - /* check if it conflicts */ - starting_index = i; - do { - for (j = starting_index; j < num_elements; j += 2) { - if (j != starting_index) - g_string_append_c (s, '_'); - g_string_append (s, p[j]); - } - - conflict = check_for_conflict (group, s->str); - - /* if there was a conflict back up 2 levels (skipping the /subfolder/ element) */ - if (conflict) - starting_index -= 2; - - /* we always break out if we can't go any further, - regardless of whether or not we conflict. */ - if (starting_index < 0) - break; - - } while (conflict); - g_strfreev (p); - - return g_string_free (s, FALSE); -} - -static gboolean -migrate_ical (ECal *old_ecal, ECal *new_ecal) -{ - GList *l, *objects; - gint num_added = 0; - gint num_objects; - gboolean retval = TRUE; - - /* both ecals are loaded, start the actual migration */ - if (!e_cal_get_object_list (old_ecal, "#t", &objects, NULL)) - return FALSE; - - num_objects = g_list_length (objects); - for (l = objects; l; l = l->next) { - icalcomponent *ical_comp = l->data; - GError *error = NULL; - - if (!e_cal_create_object (new_ecal, ical_comp, NULL, &error)) { - g_warning ("Migration of object failed: %s", error->message); - retval = FALSE; - } - - g_clear_error (&error); - - num_added ++; - dialog_set_progress ((double)num_added / num_objects); - } - - g_list_foreach (objects, (GFunc) icalcomponent_free, NULL); - g_list_free (objects); - - return retval; -} - -static gboolean -migrate_ical_folder_to_source (gchar *old_path, ESource *new_source, ECalSourceType type) -{ - ECal *old_ecal = NULL, *new_ecal = NULL; - ESource *old_source; - ESourceGroup *group; - gchar *old_uri = g_strdup_printf ("file://%s", old_path); - GError *error = NULL; - gboolean retval = FALSE; - - group = e_source_group_new ("", old_uri); - old_source = e_source_new ("", ""); - e_source_group_add_source (group, old_source, -1); - - dialog_set_folder_name (e_source_peek_name (new_source)); - - if (!(old_ecal = e_cal_new (old_source, type))) { - g_warning ("could not find a backend for '%s'", e_source_get_uri (old_source)); - goto finish; - } - if (!e_cal_open (old_ecal, FALSE, &error)) { - g_warning ("failed to load source ecal for migration: '%s' (%s)", error->message, - e_source_get_uri (old_source)); - goto finish; - } - - if (!(new_ecal = e_cal_new (new_source, type))) { - g_warning ("could not find a backend for '%s'", e_source_get_uri (new_source)); - goto finish; - } - if (!e_cal_open (new_ecal, FALSE, &error)) { - g_warning ("failed to load destination ecal for migration: '%s' (%s)", error->message, - e_source_get_uri (new_source)); - goto finish; - } - - retval = migrate_ical (old_ecal, new_ecal); - -finish: - g_clear_error (&error); - if (old_ecal) - g_object_unref (old_ecal); - g_object_unref (group); - if (new_ecal) - g_object_unref (new_ecal); - g_free (old_uri); - - return retval; -} - -static gboolean -migrate_ical_folder (gchar *old_path, ESourceGroup *dest_group, gchar *source_name, ECalSourceType type) -{ - ESource *new_source; - gboolean retval; - - new_source = e_source_new (source_name, source_name); - e_source_set_relative_uri (new_source, e_source_peek_uid (new_source)); - e_source_group_add_source (dest_group, new_source, -1); - - retval = migrate_ical_folder_to_source (old_path, new_source, type); - - g_object_unref (new_source); - - return retval; -} - -#endif /* !G_OS_WIN32 */ - -#ifndef G_OS_WIN32 - -static void -migrate_pilot_db_key (const gchar *key, gpointer user_data) -{ - EXmlHash *xmlhash = user_data; - - e_xmlhash_add (xmlhash, key, ""); -} - -static void -migrate_pilot_data (const gchar *component, const gchar *conduit, const gchar *old_path, const gchar *new_path) -{ - gchar *changelog, *map; - const gchar *dent; - const gchar *ext; - gchar *filename; - GDir *dir; - - if (!(dir = g_dir_open (old_path, 0, NULL))) - return; - - map = g_alloca (12 + strlen (conduit)); - sprintf (map, "pilot-map-%s-", conduit); - - changelog = g_alloca (24 + strlen (conduit)); - sprintf (changelog, "pilot-sync-evolution-%s-", conduit); - - while ((dent = g_dir_read_name (dir))) { - if (!strncmp (dent, map, strlen (map)) && - ((ext = strrchr (dent, '.')) && !strcmp (ext, ".xml"))) { - /* pilot map file - src and dest file formats are identical */ - guchar inbuf[4096]; - gsize nread, nwritten; - gint fd0, fd1; - gssize n; - - filename = g_build_filename (old_path, dent, NULL); - if ((fd0 = g_open (filename, O_RDONLY|O_BINARY, 0)) == -1) { - g_free (filename); - continue; - } - - g_free (filename); - filename = g_build_filename (new_path, dent, NULL); - if ((fd1 = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) == -1) { - g_free (filename); - close (fd0); - continue; - } - - do { - do { - n = read (fd0, inbuf, sizeof (inbuf)); - } while (n == -1 && errno == EINTR); - - if (n < 1) - break; - - nread = n; - nwritten = 0; - do { - do { - n = write (fd1, inbuf + nwritten, nread - nwritten); - } while (n == -1 && errno == EINTR); - - if (n > 0) - nwritten += n; - } while (nwritten < nread && n != -1); - - if (n == -1) - break; - } while (1); - - if (n != -1) - n = fsync (fd1); - - if (n == -1) { - g_warning ("Failed to migrate %s: %s", dent, strerror (errno)); - g_unlink (filename); - } - - close (fd0); - close (fd1); - g_free (filename); - } else if (!strncmp (dent, changelog, strlen (changelog)) && - ((ext = strrchr (dent, '.')) && !strcmp (ext, ".db"))) { - /* src and dest formats differ, src format is db3 while dest format is xml */ - EXmlHash *xmlhash; - EDbHash *dbhash; - struct stat st; - - filename = g_build_filename (old_path, dent, NULL); - if (g_stat (filename, &st) == -1) { - g_free (filename); - continue; - } - - dbhash = e_dbhash_new (filename); - g_free (filename); - - filename = g_strdup_printf ("%s/%s.ics-%s", new_path, component, dent); - if (g_stat (filename, &st) != -1) - g_unlink (filename); - xmlhash = e_xmlhash_new (filename); - g_free (filename); - - e_dbhash_foreach_key (dbhash, migrate_pilot_db_key, xmlhash); - - e_dbhash_destroy (dbhash); - - e_xmlhash_write (xmlhash); - e_xmlhash_destroy (xmlhash); - } - } - - g_dir_close (dir); -} - -#endif - static ESourceGroup * create_calendar_contact_source (ESourceList *source_list) { @@ -624,7 +201,6 @@ e_cal_shell_backend_migrate (EShellBackend *shell_backend, ESourceList *source_list; ECalEvent *ece; ECalEventTargetBackend *target; - gboolean retval = FALSE; g_object_get (shell_backend, "source-list", &source_list, NULL); @@ -635,133 +211,6 @@ e_cal_shell_backend_migrate (EShellBackend *shell_backend, shell_backend, source_list, &on_this_computer, &personal_source, &on_the_web, &contacts); -#ifndef G_OS_WIN32 - if (major == 1) { - xmlDocPtr config_doc = NULL; - gchar *conf_file; - struct stat st; - - conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL); - if (lstat (conf_file, &st) == 0 && S_ISREG (st.st_mode)) - config_doc = xmlParseFile (conf_file); - g_free (conf_file); - - if (config_doc && minor <= 2) { - GConfClient *gconf; - gint res = 0; - - /* move bonobo config to gconf */ - gconf = gconf_client_get_default (); - - res = e_bconf_import (gconf, config_doc, calendar_remap_list); - - g_object_unref (gconf); - - xmlFreeDoc(config_doc); - - if (res != 0) { - /* FIXME: set proper domain/code */ - g_set_error(error, 0, 0, _("Unable to migrate old settings from evolution/config.xmldb")); - goto fail; - } - } - - if (minor <= 4) { - GSList *migration_dirs, *l; - gchar *path, *local_cal_folder; - - setup_progress_dialog (); - - path = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); - migration_dirs = e_folder_map_local_folders (path, "calendar"); - local_cal_folder = g_build_filename (path, "Calendar", NULL); - g_free (path); - - if (personal_source) - migrate_ical_folder_to_source (local_cal_folder, personal_source, E_CAL_SOURCE_TYPE_EVENT); - - for (l = migration_dirs; l; l = l->next) { - gchar *source_name; - - if (personal_source && !strcmp ((gchar *)l->data, local_cal_folder)) - continue; - - source_name = get_source_name (on_this_computer, (gchar *)l->data); - - if (!migrate_ical_folder (l->data, on_this_computer, source_name, E_CAL_SOURCE_TYPE_EVENT)) { - /* FIXME: domain/code */ - g_set_error(error, 0, 0, _("Unable to migrate calendar '%s'"), source_name); - g_free(source_name); - goto fail; - } - - g_free (source_name); - } - - g_free (local_cal_folder); - - dialog_close (); - } - - if (minor <= 4 || (minor == 5 && micro < 5)) { - GConfClient *gconf; - GConfValue *gconf_val; - gint i; - const gchar *keys[] = { - CALENDAR_CONFIG_HPANE_POS, - CALENDAR_CONFIG_VPANE_POS, - CALENDAR_CONFIG_MONTH_HPANE_POS, - CALENDAR_CONFIG_MONTH_VPANE_POS, - NULL - }; - - gconf = gconf_client_get_default (); - - for (i = 0; keys[i]; i++) { - gconf_val = gconf_client_get (gconf, keys[i], NULL); - if (gconf_val) { - if (gconf_val->type != GCONF_VALUE_INT) - gconf_client_unset (gconf, keys[i], NULL); - gconf_value_free (gconf_val); - } - } - - g_object_unref (gconf); - } - - if (minor < 5 || (minor == 5 && micro <= 10)) { - gchar *old_path, *new_path; - - old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Calendar", NULL); - new_path = g_build_filename (e_shell_backend_get_data_dir (shell_backend), - "local", "system", NULL); - migrate_pilot_data ("calendar", "calendar", old_path, new_path); - g_free (new_path); - g_free (old_path); - } - - /* we only need to do this next step if people ran - older versions of 1.5. We need to clear out the - absolute URI's that were assigned to ESources - during one phase of development, as they take - precedent over relative uris (but aren't updated - when editing an ESource). */ - if (minor == 5 && micro <= 11) { - GSList *g; - for (g = e_source_list_peek_groups (source_list); g; g = g->next) { - ESourceGroup *group = g->data; - GSList *s; - - for (s = e_source_group_peek_sources (group); s; s = s->next) { - ESource *source = s->data; - e_source_set_absolute_uri (source, NULL); - } - } - } - - } -#endif /* !G_OS_WIN32 */ - e_source_list_sync (source_list, NULL); /** @Event: component.migration @@ -778,8 +227,6 @@ e_cal_shell_backend_migrate (EShellBackend *shell_backend, target = e_cal_event_target_new_module (ece, shell_backend, source_list, 0); e_event_emit ((EEvent *) ece, "module.migration", (EEventTarget *) target); - retval = TRUE; -fail: if (on_this_computer) g_object_unref (on_this_computer); if (on_the_web) @@ -789,6 +236,6 @@ fail: if (personal_source) g_object_unref (personal_source); - return retval; + return TRUE; } diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 4545c88c3a..9491d3fee2 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -278,9 +278,15 @@ static void cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar, ESource *source) { + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + ECalShellContent *cal_shell_content; ECalSourceType source_type; GHashTable *client_table; + ECalModel *model; ECal *client; + icaltimezone *timezone; const gchar *uid; source_type = E_CAL_SOURCE_TYPE_EVENT; @@ -305,7 +311,17 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar, G_CALLBACK (cal_shell_sidebar_default_opened_cb), cal_shell_sidebar); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (e_cal_shell_content_get_model (E_CAL_SHELL_CONTENT (e_shell_view_get_shell_content (e_shell_sidebar_get_shell_view (E_SHELL_SIDEBAR (cal_shell_sidebar)))))), NULL); + /* FIXME Sidebar should not be accessing the EShellContent. + * This probably needs to be moved to ECalShellView. */ + shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_content = e_shell_view_get_shell_content (shell_view); + + cal_shell_content = E_CAL_SHELL_CONTENT (shell_content); + model = e_cal_shell_content_get_model (cal_shell_content); + timezone = e_cal_model_get_timezone (model); + + e_cal_set_default_timezone (client, timezone, NULL); e_cal_open_async (client, FALSE); } @@ -771,8 +787,8 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) PROP_DATE_NAVIGATOR, g_param_spec_object ( "date-navigator", - _("Date Navigator Widget"), - _("This widget displays a miniature calendar"), + "Date Navigator Widget", + "This widget displays a miniature calendar", E_TYPE_CALENDAR, G_PARAM_READABLE)); @@ -781,8 +797,8 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - _("Default Calendar Client"), - _("Default client for calendar operations"), + "Default Calendar Client", + "Default client for calendar operations", E_TYPE_CAL, G_PARAM_READABLE)); @@ -791,8 +807,8 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) PROP_SELECTOR, g_param_spec_object ( "selector", - _("Source Selector Widget"), - _("This widget displays groups of calendars"), + "Source Selector Widget", + "This widget displays groups of calendars", E_TYPE_SOURCE_SELECTOR, G_PARAM_READABLE)); @@ -926,11 +942,17 @@ void e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, ESource *source) { + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + ECalShellContent *cal_shell_content; ECalSourceType source_type; ESourceSelector *selector; GHashTable *client_table; + ECalModel *model; ECal *default_client; ECal *client; + icaltimezone *timezone; const gchar *uid; const gchar *uri; gchar *message; @@ -989,7 +1011,17 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, G_CALLBACK (cal_shell_sidebar_client_opened_cb), cal_shell_sidebar); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (e_cal_shell_content_get_model (E_CAL_SHELL_CONTENT (e_shell_view_get_shell_content (e_shell_sidebar_get_shell_view (E_SHELL_SIDEBAR (cal_shell_sidebar)))))), NULL); + /* FIXME Sidebar should not be accessing the EShellContent. + * This probably needs to be moved to ECalShellView. */ + shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_content = e_shell_view_get_shell_content (shell_view); + + cal_shell_content = E_CAL_SHELL_CONTENT (shell_content); + model = e_cal_shell_content_get_model (cal_shell_content); + timezone = e_cal_model_get_timezone (model); + + e_cal_set_default_timezone (client, timezone, NULL); e_cal_open_async (client, FALSE); } diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index 9510f066ef..19812751d8 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -512,7 +512,7 @@ action_event_copy_cb (GtkAction *action, if (selected->data) { ECalendarViewEvent *event = selected->data; - if (event && event->comp_data && event->comp_data->client) + if (is_comp_data_valid (event) && event->comp_data->client) source_source = e_cal_get_source (event->comp_data->client); } @@ -577,6 +577,10 @@ action_event_delegate_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; clone = icalcomponent_new_clone (event->comp_data->icalcomp); @@ -707,6 +711,10 @@ action_event_forward_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -774,7 +782,7 @@ action_event_move_cb (GtkAction *action, if (selected->data) { ECalendarViewEvent *event = selected->data; - if (event && event->comp_data && event->comp_data->client) + if (is_comp_data_valid (event) && event->comp_data->client) source_source = e_cal_get_source (event->comp_data->client); } @@ -863,6 +871,10 @@ action_event_occurrence_movable_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -961,6 +973,10 @@ action_event_print_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -1000,6 +1016,10 @@ action_event_reply_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -1040,6 +1060,10 @@ action_event_reply_all_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -1090,6 +1114,10 @@ action_event_save_as_cb (GtkAction *action, g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -1148,6 +1176,10 @@ edit_event_as (ECalShellView *cal_shell_view, gboolean as_meeting) g_return_if_fail (g_list_length (selected) == 1); event = selected->data; + + if (!is_comp_data_valid (event)) + return; + client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; @@ -1216,6 +1248,26 @@ quit_calendar_cb (GtkAction *action, } static void +quit_calendar_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GdkEvent *event; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + /* Synthesize a delete_event on this window. */ + event = gdk_event_new (GDK_DELETE); + event->any.window = g_object_ref (gtk_widget_get_window (GTK_WIDGET (shell_window))); + event->any.send_event = TRUE; + gtk_main_do_event (event); + gdk_event_free (event); + +} + +static void action_event_schedule_appointment_cb (GtkAction *action, ECalShellView *cal_shell_view) { diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 43b8ae61cd..11b6ec243d 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -690,6 +690,10 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) if (priv->cal_shell_content) e_cal_shell_content_save_state (priv->cal_shell_content); + /* Calling calendar's save state from here, because it is too late in its dispose */ + if (priv->cal_shell_content) + e_cal_shell_content_save_state (priv->cal_shell_content); + DISPOSE (priv->cal_shell_backend); DISPOSE (priv->cal_shell_content); DISPOSE (priv->cal_shell_sidebar); @@ -834,6 +838,9 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, g_return_if_fail (event != NULL); g_return_if_fail (E_IS_CAL (destination_client)); + if (!is_comp_data_valid (event)) + return; + icalcomp_event = event->comp_data->icalcomp; uid = icalcomponent_get_uid (icalcomp_event); diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c index c4f52de83a..218bd7d4da 100644 --- a/modules/calendar/e-cal-shell-view.c +++ b/modules/calendar/e-cal-shell-view.c @@ -341,7 +341,7 @@ cal_shell_view_update_actions (EShellView *shell_view) gboolean user_org = FALSE; gboolean read_only = TRUE; - if (!event || !event->comp_data) + if (!is_comp_data_valid (event)) continue; client = event->comp_data->client; @@ -497,6 +497,10 @@ cal_shell_view_class_init (ECalShellViewClass *class, shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new; shell_view_class->execute_search = cal_shell_view_execute_search; shell_view_class->update_actions = cal_shell_view_update_actions; + + if (e_shell_get_express_mode(e_shell_get_default())) + shell_view_class->construct_searchbar = NULL; + } static void diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c index b0635b6e38..a51a5fc98e 100644 --- a/modules/calendar/e-memo-shell-backend.c +++ b/modules/calendar/e-memo-shell-backend.c @@ -584,8 +584,8 @@ memo_shell_backend_class_init (EMemoShellBackendClass *class) PROP_SOURCE_LIST, g_param_spec_object ( "source-list", - _("Source List"), - _("The registry of memo lists"), + "Source List", + "The registry of memo lists", E_TYPE_SOURCE_LIST, G_PARAM_READABLE)); } diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c index d56a6105d1..279f063035 100644 --- a/modules/calendar/e-memo-shell-content.c +++ b/modules/calendar/e-memo-shell-content.c @@ -604,8 +604,8 @@ memo_shell_content_class_init (EMemoShellContentClass *class) PROP_MODEL, g_param_spec_object ( "model", - _("Model"), - _("The memo table model"), + "Model", + "The memo table model", E_TYPE_CAL_MODEL, G_PARAM_READABLE)); @@ -614,8 +614,8 @@ memo_shell_content_class_init (EMemoShellContentClass *class) PROP_PREVIEW_VISIBLE, g_param_spec_boolean ( "preview-visible", - _("Preview is Visible"), - _("Whether the preview pane is visible"), + "Preview is Visible", + "Whether the preview pane is visible", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); diff --git a/modules/calendar/e-memo-shell-migrate.c b/modules/calendar/e-memo-shell-migrate.c index 3c52672063..771a889845 100644 --- a/modules/calendar/e-memo-shell-migrate.c +++ b/modules/calendar/e-memo-shell-migrate.c @@ -23,7 +23,7 @@ #include <string.h> #include <glib/gi18n.h> -#include <camel/camel-url.h> +#include <camel/camel.h> #include <libedataserver/e-account.h> #include <libedataserver/e-account-list.h> #include <libedataserver/e-source.h> diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index 3e14f6a9c0..416759213e 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -272,9 +272,15 @@ static void memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, ESource *source) { + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + EMemoShellContent *memo_shell_content; ECalSourceType source_type; GHashTable *client_table; + ECalModel *model; ECal *client; + icaltimezone *timezone; const gchar *uid; source_type = E_CAL_SOURCE_TYPE_JOURNAL; @@ -299,7 +305,17 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, G_CALLBACK (memo_shell_sidebar_default_opened_cb), memo_shell_sidebar); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (e_memo_shell_content_get_memo_model (E_MEMO_SHELL_CONTENT (e_shell_view_get_shell_content (e_shell_sidebar_get_shell_view (E_SHELL_SIDEBAR (memo_shell_sidebar)))))), NULL); + /* FIXME Sidebar should not be accessing the EShellContent. + * This probably needs to be moved to EMemoShellView. */ + shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_content = e_shell_view_get_shell_content (shell_view); + + memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); + model = e_memo_shell_content_get_memo_model (memo_shell_content); + timezone = e_cal_model_get_timezone (model); + + e_cal_set_default_timezone (client, timezone, NULL); e_cal_open_async (client, FALSE); } @@ -676,8 +692,8 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - _("Default Memo Client"), - _("Default client for memo operations"), + "Default Memo Client", + "Default client for memo operations", E_TYPE_CAL, G_PARAM_READABLE)); @@ -686,8 +702,8 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) PROP_SELECTOR, g_param_spec_object ( "selector", - _("Source Selector Widget"), - _("This widget displays groups of memo lists"), + "Source Selector Widget", + "This widget displays groups of memo lists", E_TYPE_SOURCE_SELECTOR, G_PARAM_READABLE)); @@ -813,11 +829,17 @@ void e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, ESource *source) { + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + EMemoShellContent *memo_shell_content; ECalSourceType source_type; ESourceSelector *selector; GHashTable *client_table; + ECalModel *model; ECal *default_client; ECal *client; + icaltimezone *timezone; const gchar *uid; const gchar *uri; gchar *message; @@ -876,7 +898,17 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, G_CALLBACK (memo_shell_sidebar_client_opened_cb), memo_shell_sidebar); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (e_memo_shell_content_get_memo_model (E_MEMO_SHELL_CONTENT (e_shell_view_get_shell_content (e_shell_sidebar_get_shell_view (E_SHELL_SIDEBAR (memo_shell_sidebar)))))), NULL); + /* FIXME Sidebar should not be accessing the EShellContent. + * This probably needs to be moved to EMemoShellView. */ + shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_content = e_shell_view_get_shell_content (shell_view); + + memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); + model = e_memo_shell_content_get_memo_model (memo_shell_content); + timezone = e_cal_model_get_timezone (model); + + e_cal_set_default_timezone (client, timezone, NULL); e_cal_open_async (client, FALSE); } diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c index e428c9413e..c5f0a9927a 100644 --- a/modules/calendar/e-task-shell-backend.c +++ b/modules/calendar/e-task-shell-backend.c @@ -594,8 +594,8 @@ task_shell_backend_class_init (ETaskShellBackendClass *class) PROP_SOURCE_LIST, g_param_spec_object ( "source-list", - _("Source List"), - _("The registry of task lists"), + "Source List", + "The registry of task lists", E_TYPE_SOURCE_LIST, G_PARAM_READABLE)); } diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c index 910b4da48e..fdbfa758a4 100644 --- a/modules/calendar/e-task-shell-content.c +++ b/modules/calendar/e-task-shell-content.c @@ -626,8 +626,8 @@ task_shell_content_class_init (ETaskShellContentClass *class) PROP_MODEL, g_param_spec_object ( "model", - _("Model"), - _("The task table model"), + "Model", + "The task table model", E_TYPE_CAL_MODEL, G_PARAM_READABLE)); @@ -636,8 +636,8 @@ task_shell_content_class_init (ETaskShellContentClass *class) PROP_PREVIEW_VISIBLE, g_param_spec_boolean ( "preview-visible", - _("Preview is Visible"), - _("Whether the preview pane is visible"), + "Preview is Visible", + "Whether the preview pane is visible", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); diff --git a/modules/calendar/e-task-shell-migrate.c b/modules/calendar/e-task-shell-migrate.c index 3c3210b472..9fe9870c73 100644 --- a/modules/calendar/e-task-shell-migrate.c +++ b/modules/calendar/e-task-shell-migrate.c @@ -37,8 +37,6 @@ #include <libedataserver/e-xml-hash-utils.h> #include <libedataserver/e-xml-utils.h> -#include "e-util/e-bconf-map.h" -#include "e-util/e-folder-map.h" #include "e-util/e-util-private.h" #include "calendar/gui/calendar-config.h" #include "calendar/gui/calendar-config-keys.h" @@ -47,396 +45,6 @@ #define WEBCAL_BASE_URI "webcal://" #define PERSONAL_RELATIVE_URI "system" -static e_gconf_map_t calendar_tasks_map[] = { - /* /Calendar/Tasks */ - { "HideCompletedTasks", "calendar/tasks/hide_completed", E_GCONF_MAP_BOOL }, - { "HideCompletedTasksUnits", "calendar/tasks/hide_completed_units", E_GCONF_MAP_STRING }, - { "HideCompletedTasksValue", "calendar/tasks/hide_completed_value", E_GCONF_MAP_INT }, - { NULL }, -}; - -static e_gconf_map_t calendar_tasks_colours_map[] = { - /* /Calendar/Tasks/Colors */ - { "TasksDueToday", "calendar/tasks/colors/due_today", E_GCONF_MAP_STRING }, - { "TasksOverDue", "calendar/tasks/colors/overdue", E_GCONF_MAP_STRING }, - { "TasksDueToday", "calendar/tasks/colors/due_today", E_GCONF_MAP_STRING }, - { NULL }, -}; - -static e_gconf_map_list_t task_remap_list[] = { - - { "/Calendar/Tasks", calendar_tasks_map }, - { "/Calendar/Tasks/Colors", calendar_tasks_colours_map }, - - { NULL }, -}; - -static GtkWidget *window; -static GtkLabel *label; -static GtkProgressBar *progress; - -#ifndef G_OS_WIN32 - -/* No previous versions have been available on Win32, so don't - * bother with upgrade support from 1.x on Win32. - */ - -static void -setup_progress_dialog (void) -{ - GtkWidget *vbox, *hbox, *w; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *) window, _("Migrating...")); - gtk_window_set_modal ((GtkWindow *) window, TRUE); - gtk_container_set_border_width ((GtkContainer *) window, 6); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_widget_show (vbox); - gtk_container_add ((GtkContainer *) window, vbox); - - w = gtk_label_new (_("The location and hierarchy of the Evolution task " - "folders has changed since Evolution 1.x.\n\nPlease be " - "patient while Evolution migrates your folders...")); - - gtk_label_set_line_wrap ((GtkLabel *) w, TRUE); - gtk_widget_show (w); - gtk_box_pack_start ((GtkBox *) vbox, w, TRUE, TRUE, 0); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_widget_show (hbox); - gtk_box_pack_start ((GtkBox *) vbox, hbox, TRUE, TRUE, 0); - - label = (GtkLabel *) gtk_label_new (""); - gtk_widget_show ((GtkWidget *) label); - gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) label, TRUE, TRUE, 0); - - progress = (GtkProgressBar *) gtk_progress_bar_new (); - gtk_widget_show ((GtkWidget *) progress); - gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) progress, TRUE, TRUE, 0); - - gtk_widget_show (window); -} - -static void -dialog_close (void) -{ - gtk_widget_destroy ((GtkWidget *) window); -} - -static void -dialog_set_folder_name (const gchar *folder_name) -{ - gchar *text; - - text = g_strdup_printf (_("Migrating '%s':"), folder_name); - gtk_label_set_text (label, text); - g_free (text); - - gtk_progress_bar_set_fraction (progress, 0.0); - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static void -dialog_set_progress (double percent) -{ - gchar text[5]; - - snprintf (text, sizeof (text), "%d%%", (gint) (percent * 100.0f)); - - gtk_progress_bar_set_fraction (progress, percent); - gtk_progress_bar_set_text (progress, text); - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static gboolean -check_for_conflict (ESourceGroup *group, gchar *name) -{ - GSList *sources; - GSList *s; - - sources = e_source_group_peek_sources (group); - - for (s = sources; s; s = s->next) { - ESource *source = E_SOURCE (s->data); - - if (!strcmp (e_source_peek_name (source), name)) - return TRUE; - } - - return FALSE; -} - -static gchar * -get_source_name (ESourceGroup *group, const gchar *path) -{ - gchar **p = g_strsplit (path, "/", 0); - gint i, j, starting_index; - gint num_elements; - gboolean conflict; - GString *s = g_string_new (NULL); - - for (i = 0; p[i]; i ++); - - num_elements = i; - i--; - - /* p[i] is now the last path element */ - - /* check if it conflicts */ - starting_index = i; - do { - for (j = starting_index; j < num_elements; j += 2) { - if (j != starting_index) - g_string_append_c (s, '_'); - g_string_append (s, p[j]); - } - - conflict = check_for_conflict (group, s->str); - - /* if there was a conflict back up 2 levels (skipping the /subfolder/ element) */ - if (conflict) - starting_index -= 2; - - /* we always break out if we can't go any further, - regardless of whether or not we conflict. */ - if (starting_index < 0) - break; - - } while (conflict); - g_strfreev (p); - - return g_string_free (s, FALSE); -} - -static gboolean -migrate_ical (ECal *old_ecal, ECal *new_ecal) -{ - GList *l, *objects; - gint num_added = 0; - gint num_objects; - gboolean retval = TRUE; - - /* both ecals are loaded, start the actual migration */ - if (!e_cal_get_object_list (old_ecal, "#t", &objects, NULL)) - return FALSE; - - num_objects = g_list_length (objects); - for (l = objects; l; l = l->next) { - icalcomponent *ical_comp = l->data; - GError *error = NULL; - - if (!e_cal_create_object (new_ecal, ical_comp, NULL, &error)) { - g_warning ("Migration of object failed: %s", error->message); - retval = FALSE; - } - - g_clear_error (&error); - - num_added ++; - dialog_set_progress ((double)num_added / num_objects); - } - - g_list_foreach (objects, (GFunc) icalcomponent_free, NULL); - g_list_free (objects); - - return retval; -} - -static gboolean -migrate_ical_folder_to_source (gchar *old_path, ESource *new_source, ECalSourceType type) -{ - ECal *old_ecal = NULL, *new_ecal = NULL; - ESource *old_source; - ESourceGroup *group; - gchar *old_uri = g_strdup_printf ("file://%s", old_path); - GError *error = NULL; - gboolean retval = FALSE; - - group = e_source_group_new ("", old_uri); - old_source = e_source_new ("", ""); - e_source_group_add_source (group, old_source, -1); - - dialog_set_folder_name (e_source_peek_name (new_source)); - - if (!(old_ecal = e_cal_new (old_source, type))) { - g_warning ("could not find a backend for '%s'", e_source_get_uri (old_source)); - goto finish; - } - if (!e_cal_open (old_ecal, FALSE, &error)) { - g_warning ("failed to load source ecal for migration: '%s' (%s)", error->message, - e_source_get_uri (old_source)); - goto finish; - } - - if (!(new_ecal = e_cal_new (new_source, type))) { - g_warning ("could not find a backend for '%s'", e_source_get_uri (new_source)); - goto finish; - } - if (!e_cal_open (new_ecal, FALSE, &error)) { - g_warning ("failed to load destination ecal for migration: '%s' (%s)", error->message, - e_source_get_uri (new_source)); - goto finish; - } - - retval = migrate_ical (old_ecal, new_ecal); - -finish: - g_clear_error (&error); - if (old_ecal) - g_object_unref (old_ecal); - g_object_unref (group); - if (new_ecal) - g_object_unref (new_ecal); - g_free (old_uri); - - return retval; -} - -static gboolean -migrate_ical_folder (gchar *old_path, ESourceGroup *dest_group, gchar *source_name, ECalSourceType type) -{ - ESource *new_source; - gboolean retval; - - new_source = e_source_new (source_name, source_name); - e_source_set_relative_uri (new_source, e_source_peek_uid (new_source)); - e_source_group_add_source (dest_group, new_source, -1); - - retval = migrate_ical_folder_to_source (old_path, new_source, type); - - g_object_unref (new_source); - - return retval; -} - -#endif /* !G_OS_WIN32 */ - -#ifndef G_OS_WIN32 - -static void -migrate_pilot_db_key (const gchar *key, gpointer user_data) -{ - EXmlHash *xmlhash = user_data; - - e_xmlhash_add (xmlhash, key, ""); -} - -static void -migrate_pilot_data (const gchar *component, const gchar *conduit, const gchar *old_path, const gchar *new_path) -{ - gchar *changelog, *map; - const gchar *dent; - const gchar *ext; - gchar *filename; - GDir *dir; - - if (!(dir = g_dir_open (old_path, 0, NULL))) - return; - - map = g_alloca (12 + strlen (conduit)); - sprintf (map, "pilot-map-%s-", conduit); - - changelog = g_alloca (24 + strlen (conduit)); - sprintf (changelog, "pilot-sync-evolution-%s-", conduit); - - while ((dent = g_dir_read_name (dir))) { - if (!strncmp (dent, map, strlen (map)) && - ((ext = strrchr (dent, '.')) && !strcmp (ext, ".xml"))) { - /* pilot map file - src and dest file formats are identical */ - guchar inbuf[4096]; - gsize nread, nwritten; - gint fd0, fd1; - gssize n; - - filename = g_build_filename (old_path, dent, NULL); - if ((fd0 = g_open (filename, O_RDONLY|O_BINARY, 0)) == -1) { - g_free (filename); - continue; - } - - g_free (filename); - filename = g_build_filename (new_path, dent, NULL); - if ((fd1 = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) == -1) { - g_free (filename); - close (fd0); - continue; - } - - do { - do { - n = read (fd0, inbuf, sizeof (inbuf)); - } while (n == -1 && errno == EINTR); - - if (n < 1) - break; - - nread = n; - nwritten = 0; - do { - do { - n = write (fd1, inbuf + nwritten, nread - nwritten); - } while (n == -1 && errno == EINTR); - - if (n > 0) - nwritten += n; - } while (nwritten < nread && n != -1); - - if (n == -1) - break; - } while (1); - - if (n != -1) - n = fsync (fd1); - - if (n == -1) { - g_warning ("Failed to migrate %s: %s", dent, strerror (errno)); - g_unlink (filename); - } - - close (fd0); - close (fd1); - g_free (filename); - } else if (!strncmp (dent, changelog, strlen (changelog)) && - ((ext = strrchr (dent, '.')) && !strcmp (ext, ".db"))) { - /* src and dest formats differ, src format is db3 while dest format is xml */ - EXmlHash *xmlhash; - EDbHash *dbhash; - struct stat st; - - filename = g_build_filename (old_path, dent, NULL); - if (g_stat (filename, &st) == -1) { - g_free (filename); - continue; - } - - dbhash = e_dbhash_new (filename); - g_free (filename); - - filename = g_strdup_printf ("%s/%s.ics-%s", new_path, component, dent); - if (g_stat (filename, &st) != -1) - g_unlink (filename); - xmlhash = e_xmlhash_new (filename); - g_free (filename); - - e_dbhash_foreach_key (dbhash, migrate_pilot_db_key, xmlhash); - - e_dbhash_destroy (dbhash); - - e_xmlhash_write (xmlhash); - e_xmlhash_destroy (xmlhash); - } - } - - g_dir_close (dir); -} - -#endif - static void create_task_sources (EShellBackend *shell_backend, ESourceList *source_list, @@ -553,7 +161,6 @@ e_task_shell_backend_migrate (EShellBackend *shell_backend, ESourceGroup *on_the_web = NULL; ESource *personal_source = NULL; ESourceList *source_list; - gboolean retval = FALSE; g_object_get (shell_backend, "source-list", &source_list, NULL); @@ -564,106 +171,8 @@ e_task_shell_backend_migrate (EShellBackend *shell_backend, shell_backend, source_list, &on_this_computer, &on_the_web, &personal_source); -#ifndef G_OS_WIN32 - if (major == 1) { - xmlDocPtr config_doc = NULL; - gchar *conf_file; - - conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL); - if (g_file_test (conf_file, G_FILE_TEST_IS_REGULAR)) - config_doc = e_xml_parse_file (conf_file); - g_free (conf_file); - - if (config_doc && minor <= 2) { - GConfClient *gconf; - gint res = 0; - - /* move bonobo config to gconf */ - gconf = gconf_client_get_default (); - - res = e_bconf_import (gconf, config_doc, task_remap_list); - - g_object_unref (gconf); - - xmlFreeDoc(config_doc); - - if (res != 0) { - g_set_error(error, 0, 0, _("Unable to migrate old settings from evolution/config.xmldb")); - goto fail; - } - } - - if (minor <= 4) { - GSList *migration_dirs, *l; - gchar *path, *local_task_folder; - - setup_progress_dialog (); - - path = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); - migration_dirs = e_folder_map_local_folders (path, "tasks"); - local_task_folder = g_build_filename (path, "Tasks", NULL); - g_free (path); - - if (personal_source) - migrate_ical_folder_to_source (local_task_folder, personal_source, E_CAL_SOURCE_TYPE_TODO); - - for (l = migration_dirs; l; l = l->next) { - gchar *source_name; - - if (personal_source && !strcmp ((gchar *)l->data, local_task_folder)) - continue; - - source_name = get_source_name (on_this_computer, (gchar *)l->data); - - if (!migrate_ical_folder (l->data, on_this_computer, source_name, E_CAL_SOURCE_TYPE_TODO)) { - /* FIXME: domain/code */ - g_set_error(error, 0, 0, _("Unable to migrate tasks '%s'"), source_name); - g_free(source_name); - goto fail; - } - - g_free (source_name); - } - - g_free (local_task_folder); - - dialog_close (); - } - - if (minor < 5 || (minor == 5 && micro <= 10)) { - gchar *old_path, *new_path; - - old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Tasks", NULL); - new_path = g_build_filename (e_shell_backend_get_data_dir (shell_backend), - "local", "system", NULL); - migrate_pilot_data ("tasks", "todo", old_path, new_path); - g_free (new_path); - g_free (old_path); - } - - /* we only need to do this next step if people ran - older versions of 1.5. We need to clear out the - absolute URI's that were assigned to ESources - during one phase of development, as they take - precedent over relative uris (but aren't updated - when editing an ESource). */ - if (minor == 5 && micro <= 11) { - GSList *g; - for (g = e_source_list_peek_groups (source_list); g; g = g->next) { - ESourceGroup *group = g->data; - GSList *s; - - for (s = e_source_group_peek_sources (group); s; s = s->next) { - ESource *source = s->data; - e_source_set_absolute_uri (source, NULL); - } - } - } - } -#endif /* !G_OS_WIN32 */ e_source_list_sync (source_list, NULL); - retval = TRUE; -fail: + if (on_this_computer) g_object_unref (on_this_computer); if (on_the_web) @@ -671,5 +180,5 @@ fail: if (personal_source) g_object_unref (personal_source); - return retval; + return TRUE; } diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index 87127ba634..07eb43bdbf 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -272,9 +272,15 @@ static void task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar, ESource *source) { + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + ETaskShellContent *task_shell_content; ECalSourceType source_type; GHashTable *client_table; + ECalModel *model; ECal *client; + icaltimezone *timezone; const gchar *uid; source_type = E_CAL_SOURCE_TYPE_TODO; @@ -299,7 +305,17 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar, G_CALLBACK (task_shell_sidebar_default_opened_cb), task_shell_sidebar); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (e_task_shell_content_get_task_model (E_TASK_SHELL_CONTENT (e_shell_view_get_shell_content (e_shell_sidebar_get_shell_view (E_SHELL_SIDEBAR (task_shell_sidebar)))))), NULL); + /* FIXME Sidebar should not be accessing the EShellContent. + * This probably needs to be moved to ETaskShellView. */ + shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_content = e_shell_view_get_shell_content (shell_view); + + task_shell_content = E_TASK_SHELL_CONTENT (shell_content); + model = e_task_shell_content_get_task_model (task_shell_content); + timezone = e_cal_model_get_timezone (model); + + e_cal_set_default_timezone (client, timezone, NULL); e_cal_open_async (client, FALSE); } @@ -676,8 +692,8 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - _("Default Task Client"), - _("Default client for task operations"), + "Default Task Client", + "Default client for task operations", E_TYPE_CAL, G_PARAM_READABLE)); @@ -686,8 +702,8 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) PROP_SELECTOR, g_param_spec_object ( "selector", - _("Source Selector Widget"), - _("This widget displays groups of task lists"), + "Source Selector Widget", + "This widget displays groups of task lists", E_TYPE_SOURCE_SELECTOR, G_PARAM_READABLE)); @@ -813,11 +829,17 @@ void e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, ESource *source) { + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + ETaskShellContent *task_shell_content; ECalSourceType source_type; ESourceSelector *selector; GHashTable *client_table; + ECalModel *model; ECal *default_client; ECal *client; + icaltimezone *timezone; const gchar *uid; const gchar *uri; gchar *message; @@ -876,7 +898,17 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, G_CALLBACK (task_shell_sidebar_client_opened_cb), task_shell_sidebar); - e_cal_set_default_timezone (client, e_cal_model_get_timezone (e_task_shell_content_get_task_model (E_TASK_SHELL_CONTENT (e_shell_view_get_shell_content (e_shell_sidebar_get_shell_view (E_SHELL_SIDEBAR (task_shell_sidebar)))))), NULL); + /* FIXME Sidebar should not be accessing the EShellContent. + * This probably needs to be moved to ETaskShellView. */ + shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_content = e_shell_view_get_shell_content (shell_view); + + task_shell_content = E_TASK_SHELL_CONTENT (shell_content); + model = e_task_shell_content_get_task_model (task_shell_content); + timezone = e_cal_model_get_timezone (model); + + e_cal_set_default_timezone (client, timezone, NULL); e_cal_open_async (client, FALSE); } diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c index 310200d6a7..5372299956 100644 --- a/modules/calendar/e-task-shell-view-actions.c +++ b/modules/calendar/e-task-shell-view-actions.c @@ -541,6 +541,7 @@ action_task_purge_cb (GtkAction *action, { EShellView *shell_view; EShellWindow *shell_window; + GtkWidget *content_area; GtkWidget *dialog; GtkWidget *widget; gboolean active; @@ -565,9 +566,9 @@ action_task_purge_cb (GtkAction *action, gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); widget = gtk_check_button_new_with_label (_("Do not ask me again")); - gtk_box_pack_start ( - GTK_BOX (GTK_DIALOG (dialog)->vbox), widget, TRUE, TRUE, 6); + gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 6); gtk_widget_show (widget); response = gtk_dialog_run (GTK_DIALOG (dialog)); |