This was a particularly messy merge. Watch out for regressions! Conflicts: ChangeLog NEWS a11y/ChangeLog a11y/widgets/ea-combo-button.c a11y/widgets/ea-combo-button.h a11y/widgets/ea-widgets.c addressbook/ChangeLog addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in addressbook/gui/component/addressbook-component.c addressbook/gui/component/addressbook-component.h addressbook/gui/component/addressbook-config.c addressbook/gui/component/addressbook-migrate.h addressbook/gui/component/addressbook-view.c addressbook/gui/component/addressbook-view.h addressbook/gui/component/addressbook.h addressbook/gui/component/autocompletion-config.c addressbook/gui/component/autocompletion-config.h addressbook/gui/component/component-factory.c addressbook/gui/component/e-book-shell-module-migrate.c addressbook/gui/component/ldap-config.glade addressbook/gui/contact-editor/Makefile.am addressbook/gui/contact-editor/contact-editor.glade addressbook/gui/contact-editor/e-contact-editor-address.c addressbook/gui/contact-editor/e-contact-editor-address.h addressbook/gui/contact-editor/e-contact-editor-im.c addressbook/gui/contact-editor/e-contact-editor-im.h addressbook/gui/contact-editor/e-contact-editor.c addressbook/gui/contact-editor/e-contact-editor.h addressbook/gui/contact-editor/eab-editor.c addressbook/gui/contact-editor/eab-editor.h addressbook/gui/contact-editor/test-editor.c addressbook/gui/contact-list-editor/Makefile.am addressbook/gui/widgets/Makefile.am addressbook/gui/widgets/e-addressbook-model.c addressbook/gui/widgets/e-addressbook-model.h addressbook/gui/widgets/e-addressbook-reflow-adapter.c addressbook/gui/widgets/e-addressbook-view.c addressbook/gui/widgets/e-addressbook-view.h addressbook/gui/widgets/e-minicard-view.c addressbook/gui/widgets/eab-contact-display.c addressbook/gui/widgets/eab-gui-util.c addressbook/gui/widgets/eab-menu.c addressbook/gui/widgets/eab-menu.h addressbook/gui/widgets/eab-popup-control.c addressbook/gui/widgets/eab-popup-control.h addressbook/gui/widgets/eab-popup.c addressbook/gui/widgets/eab-popup.h addressbook/gui/widgets/eab-vcard-control.c addressbook/gui/widgets/eab-vcard-control.h addressbook/gui/widgets/gal-view-minicard.c addressbook/gui/widgets/gal-view-minicard.h addressbook/printing/e-contact-print-style-editor.c addressbook/printing/e-contact-print-style-editor.h addressbook/printing/e-contact-print.glade addressbook/printing/test-contact-print-style-editor.c addressbook/tools/evolution-addressbook-export.c addressbook/util/Makefile.am calendar/ChangeLog calendar/gui/Makefile.am calendar/gui/apps_evolution_calendar.schemas.in calendar/gui/calendar-component.c calendar/gui/calendar-component.h calendar/gui/calendar-config.c calendar/gui/comp-editor-factory.c calendar/gui/comp-editor-factory.h calendar/gui/comp-util.c calendar/gui/comp-util.h calendar/gui/control-factory.c calendar/gui/control-factory.h calendar/gui/dialogs/alarm-dialog.c calendar/gui/dialogs/cal-prefs-dialog.c calendar/gui/dialogs/cal-prefs-dialog.glade calendar/gui/dialogs/cal-prefs-dialog.h calendar/gui/dialogs/comp-editor.c calendar/gui/dialogs/comp-editor.h calendar/gui/dialogs/event-editor.c calendar/gui/dialogs/event-page.c calendar/gui/dialogs/memo-editor.c calendar/gui/dialogs/memo-page.c calendar/gui/dialogs/recurrence-page.c calendar/gui/dialogs/task-details-page.c calendar/gui/dialogs/task-details-page.glade calendar/gui/dialogs/task-editor.c calendar/gui/dialogs/task-page.c calendar/gui/e-cal-component-memo-preview.c calendar/gui/e-cal-component-memo-preview.h calendar/gui/e-cal-component-preview.c calendar/gui/e-cal-component-preview.h calendar/gui/e-cal-event.h calendar/gui/e-cal-model.c calendar/gui/e-cal-popup.c calendar/gui/e-calendar-table.c calendar/gui/e-calendar-view.c calendar/gui/e-day-view.c calendar/gui/e-itip-control.c calendar/gui/e-memo-table.c calendar/gui/e-memos.c calendar/gui/e-memos.h calendar/gui/e-tasks.c calendar/gui/e-tasks.h calendar/gui/e-week-view.c calendar/gui/gnome-cal.c calendar/gui/goto.c calendar/gui/itip-bonobo-control.c calendar/gui/itip-bonobo-control.h calendar/gui/itip-utils.c calendar/gui/itip-utils.h calendar/gui/main.c calendar/gui/memos-component.c calendar/gui/memos-control.c calendar/gui/memos-control.h calendar/gui/migration.c calendar/gui/migration.h calendar/gui/tasks-component.c calendar/gui/tasks-control.c calendar/importers/main.c composer/ChangeLog composer/e-composer-actions.c composer/e-composer-private.c composer/e-msg-composer.c composer/e-msg-composer.h composer/evolution-composer.ui configure.in doc/reference/shell/eshell-overrides.txt e-util/ChangeLog e-util/Makefile.am e-util/e-corba-utils.c e-util/e-corba-utils.h e-util/e-gui-utils.c e-util/e-gui-utils.h e-util/e-logger.c e-util/e-non-intrusive-error-dialog.c e-util/e-non-intrusive-error-dialog.h e-util/e-plugin-ui.c e-util/e-util-labels.c e-util/e-util-labels.h e-util/e-util.c e-util/e-util.h filter/ChangeLog filter/filter-option.c help/C/evolution.xml help/ChangeLog help/Makefile.am help/cs/cs.po help/de/de.po help/es/es.po help/eu/figures/Screenshot-Free-Busy.png help/eu/figures/evo_blink.png help/eu/figures/evo_dialog-info.png help/eu/figures/evo_dialog-warning.png help/eu/figures/evo_email_a.png help/eu/figures/evo_flag_follow_up_a.png help/eu/figures/evo_proxyadd_a.png help/eu/figures/evo_shd_memo_a.png help/eu/figures/exchange-delegation.png help/eu/figures/exchange-identity.png help/eu/figures/exchange-receive-options.png help/eu/figures/exchange-receive.png help/eu/figures/exchg-identity.png help/eu/figures/exchng-identity.png help/eu/figures/exchng-rec-mail.png help/eu/figures/exchng-rec-option.png help/eu/figures/exchng-rec-options.png help/eu/figures/free_busy.png help/eu/figures/full-1.png help/eu/figures/full-2.png help/eu/figures/full-3.png help/eu/figures/full-4.png help/eu/figures/full-5.png help/eu/figures/full-6.png help/eu/figures/full-7.png help/eu/figures/mail-druid-pic.png help/eu/figures/mail-inbox.png help/eu/figures/mail-threaded.png help/eu/figures/mainwindow-pic.png help/eu/figures/minus.png help/eu/figures/plus.png help/eu/figures/proxy-cal.png help/eu/figures/proxy-login.png help/eu/figures/schedule.png help/eu/figures/stock_search.png help/eu/figures/sub-others-folder.png help/eu/figures/sub-pub-fold.png help/eu/figures/vfolder-createrule-fig.png help/quickref/Makefile.am mail/ChangeLog mail/Makefile.am mail/default/Makefile.am mail/e-mail-shell-module-migrate.c mail/e-searching-tokenizer.c mail/em-account-editor.c mail/em-account-prefs.h mail/em-composer-prefs.c mail/em-composer-prefs.h mail/em-composer-utils.c mail/em-filter-folder-element.c mail/em-folder-browser.c mail/em-folder-selection-button.h mail/em-folder-selector.c mail/em-folder-tree-model.c mail/em-folder-tree-model.h mail/em-folder-tree.c mail/em-folder-tree.h mail/em-folder-utils.c mail/em-folder-utils.h mail/em-folder-view.c mail/em-format-html-display.c mail/em-format-html-print.c mail/em-format-html-print.h mail/em-format-html.c mail/em-format-quote.h mail/em-format.c mail/em-format.h mail/em-html-stream.h mail/em-mailer-prefs.c mail/em-mailer-prefs.h mail/em-message-browser.c mail/em-message-browser.h mail/em-migrate.h mail/em-network-prefs.h mail/em-popup.c mail/em-search-context.h mail/em-subscribe-editor.c mail/em-utils.c mail/em-utils.h mail/filtertypes.xml mail/mail-component-factory.c mail/mail-component.c mail/mail-config-factory.c mail/mail-config-factory.h mail/mail-config.c mail/mail-config.glade mail/mail-crypto.c mail/mail-crypto.h mail/mail-dialogs.glade mail/mail-folder-cache.c mail/mail-mt.c mail/mail-send-recv.c mail/mail-send-recv.h mail/mail-session.c mail/mail-session.h mail/mail-types.h mail/mail-vfolder.c mail/message-list.c mail/message-tag-followup.c mail/searchtypes.xml mail/vfoldertypes.xml plugins/attachment-reminder/Makefile.am plugins/audio-inline/org-gnome-audio-inline.eplug.xml plugins/caldav/ChangeLog plugins/caldav/caldav-source.c plugins/calendar-http/ChangeLog plugins/calendar-weather/ChangeLog plugins/calendar-weather/calendar-weather.c plugins/email-custom-header/ChangeLog plugins/email-custom-header/email-custom-header.c plugins/exchange-operations/ChangeLog plugins/google-account-setup/ChangeLog plugins/google-account-setup/Makefile.am plugins/google-account-setup/google-contacts-source.c plugins/google-account-setup/google-source.c plugins/import-ics-attachments/ChangeLog plugins/import-ics-attachments/Makefile.am plugins/import-ics-attachments/icsimporter.c plugins/itip-formatter/ChangeLog plugins/itip-formatter/itip-view.c plugins/mail-account-disable/ChangeLog plugins/mail-account-disable/mail-account-disable.c plugins/mail-notification/ChangeLog plugins/mail-notification/mail-notification.c plugins/mail-to-meeting/ChangeLog plugins/mail-to-task/ChangeLog plugins/mark-all-read/mark-all-read.c plugins/publish-calendar/ChangeLog plugins/publish-calendar/publish-format-fb.c plugins/publish-calendar/publish-format-ical.c plugins/save-attachments/ChangeLog plugins/save-attachments/Makefile.am plugins/save-attachments/save-attachments.c plugins/select-one-source/ChangeLog plugins/select-one-source/Makefile.am plugins/select-one-source/select-one-source.c plugins/startup-wizard/ChangeLog plugins/startup-wizard/startup-wizard.c plugins/webdav-account-setup/ChangeLog plugins/webdav-account-setup/Makefile.am plugins/webdav-account-setup/webdav-contacts-source.c po/ChangeLog po/POTFILES.in po/ar.po po/bg.po po/bn_IN.po po/ca.po po/cs.po po/da.po po/de.po po/el.po po/en_GB.po po/es.po po/et.po po/fr.po po/gl.po po/gu.po po/hi.po po/hu.po po/it.po po/ja.po po/kn.po po/ko.po po/lt.po po/ml.po po/mr.po po/nb.po po/nl.po po/pa.po po/pl.po po/pt.po po/ru.po po/sl.po po/sr.po po/sr@latin.po po/sv.po po/ta.po po/te.po po/th.po po/tr.po po/zh_HK.po po/zh_TW.po shell/ChangeLog shell/Evolution-Component.idl shell/Makefile.am shell/apps_evolution_shell.schemas.in shell/e-component-registry.c shell/e-component-registry.h shell/e-component-view.c shell/e-component-view.h shell/e-corba-config-page.c shell/e-corba-config-page.h shell/e-shell-constants.h shell/e-shell-importer.c shell/e-shell-importer.h shell/e-shell-nm.c shell/e-shell-settings-dialog.c shell/e-shell-settings-dialog.h shell/e-shell-view.c shell/e-shell-view.h shell/e-shell-window-commands.c shell/e-shell-window-commands.h shell/e-shell-window.c shell/e-shell-window.h shell/e-shell.c shell/e-shell.h shell/e-sidebar.c shell/e-sidebar.h shell/e-user-creatable-items-handler.c shell/e-user-creatable-items-handler.h shell/es-menu.c shell/es-menu.h shell/evolution-component.c shell/evolution-component.h shell/evolution-config-control.c shell/evolution-config-control.h shell/evolution-listener.c shell/evolution-listener.h shell/evolution-shell-component-utils.c shell/evolution-shell-component-utils.h shell/importer/evolution-importer-client.c shell/importer/evolution-importer-client.h shell/importer/evolution-importer-listener.c shell/importer/evolution-importer-listener.h shell/importer/evolution-importer.c shell/importer/evolution-importer.h shell/importer/evolution-intelligent-importer.c shell/importer/evolution-intelligent-importer.h shell/importer/import.glade shell/importer/intelligent.c shell/importer/intelligent.h shell/main.c shell/shell.error.xml shell/test/evolution-test-component.c shell/test/evolution-test-component.h smime/ChangeLog smime/lib/Makefile.am ui/Makefile.am ui/evolution-addressbook.xml ui/evolution-calendar.xml widgets/ChangeLog widgets/menus/gal-view-menus.c widgets/menus/gal-view-menus.h widgets/misc/ChangeLog widgets/misc/Makefile.am widgets/misc/e-activity-handler.c widgets/misc/e-activity-handler.h widgets/misc/e-attachment-bar.c widgets/misc/e-attachment-bar.h widgets/misc/e-attachment.c widgets/misc/e-attachment.h widgets/misc/e-calendar-item.c widgets/misc/e-charset-picker.c widgets/misc/e-combo-button.c widgets/misc/e-combo-button.h widgets/misc/e-config-page.c widgets/misc/e-config-page.h widgets/misc/e-dropdown-button.c widgets/misc/e-dropdown-button.h widgets/misc/e-filter-bar.h widgets/misc/e-info-label.c widgets/misc/e-info-label.h widgets/misc/e-multi-config-dialog.c widgets/misc/e-multi-config-dialog.h widgets/misc/e-online-button.c widgets/misc/e-search-bar.c widgets/misc/e-search-bar.h widgets/misc/e-signature-combo-box.c widgets/misc/e-signature-combo-box.h widgets/misc/e-signature-editor.c widgets/misc/e-signature-editor.h widgets/misc/e-task-bar.c widgets/misc/e-task-bar.h widgets/misc/e-task-widget.c widgets/misc/e-task-widget.h widgets/misc/test-dropdown-button.c widgets/misc/test-info-label.c widgets/misc/test-multi-config-dialog.c widgets/table/ChangeLog widgets/table/e-cell-date.c widgets/table/e-table-group-container.c widgets/table/e-table-group-leaf.c widgets/table/e-table-group.c widgets/table/e-table-group.h widgets/table/e-table.c widgets/table/e-table.h
776 lines
22 KiB
C
776 lines
22 KiB
C
/*
|
|
* 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
|
|
* version 2 of the License, or (at your option) version 3.
|
|
*
|
|
* 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
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
|
*
|
|
*
|
|
* Authors:
|
|
* Iain Holmes <iain@ximian.com>
|
|
*
|
|
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
|
*
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <glade/glade.h>
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <libgnomeui/gnome-druid.h>
|
|
#include <libgnomeui/gnome-druid-page-edge.h>
|
|
#include <libgnomeui/gnome-druid-page-standard.h>
|
|
|
|
#include "misc/e-gui-utils.h"
|
|
|
|
#include "e-util/e-dialog-utils.h"
|
|
#include "e-util/e-error.h"
|
|
#include "e-util/e-icon-factory.h"
|
|
#include "e-util/e-import.h"
|
|
#include "e-util/e-util-private.h"
|
|
|
|
#include "e-shell.h"
|
|
#include "e-shell-window.h"
|
|
|
|
#include "e-shell-importer.h"
|
|
|
|
typedef struct _ImportDialogFilePage {
|
|
GtkWidget *vbox;
|
|
GtkWidget *filename;
|
|
GtkWidget *filetype;
|
|
|
|
EImportTargetURI *target;
|
|
EImportImporter *importer;
|
|
} ImportDialogFilePage;
|
|
|
|
typedef struct _ImportDialogDestPage {
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *control;
|
|
} ImportDialogDestPage;
|
|
|
|
typedef struct _ImportDialogTypePage {
|
|
GtkWidget *vbox;
|
|
GtkWidget *intelligent;
|
|
GtkWidget *file;
|
|
} ImportDialogTypePage;
|
|
|
|
typedef struct _ImportDialogImporterPage {
|
|
GtkWidget *vbox;
|
|
|
|
GSList *importers;
|
|
GSList *current;
|
|
EImportTargetHome *target;
|
|
} ImportDialogImporterPage;
|
|
|
|
typedef struct _ImportData {
|
|
EShellWindow *window;
|
|
|
|
GladeXML *wizard;
|
|
GtkWidget *dialog;
|
|
GtkWidget *druid;
|
|
ImportDialogFilePage *filepage;
|
|
ImportDialogDestPage *destpage;
|
|
ImportDialogTypePage *typepage;
|
|
ImportDialogImporterPage *importerpage;
|
|
|
|
GtkWidget *filedialog;
|
|
GtkWidget *typedialog;
|
|
GtkWidget *destdialog;
|
|
GtkWidget *intelligent;
|
|
GnomeDruidPageEdge *start;
|
|
GnomeDruidPageEdge *finish;
|
|
GtkWidget *vbox;
|
|
|
|
EImport *import;
|
|
|
|
/* Used for importing phase of operation */
|
|
EImportTarget *import_target;
|
|
EImportImporter *import_importer;
|
|
GtkWidget *import_dialog;
|
|
GtkWidget *import_label;
|
|
GtkWidget *import_progress;
|
|
} ImportData;
|
|
|
|
/*#define IMPORTER_DEBUG*/
|
|
|
|
#ifdef IMPORTER_DEBUG
|
|
#define IN g_print ("=====> %s (%d)\n", G_STRFUNC, __LINE__)
|
|
#define OUT g_print ("<==== %s (%d)\n", G_STRFUNC, __LINE__)
|
|
#else
|
|
#define IN
|
|
#define OUT
|
|
#endif
|
|
|
|
static struct {
|
|
char *name;
|
|
char *text;
|
|
} info[] = {
|
|
{ "type_html",
|
|
N_("Choose the type of importer to run:")
|
|
},
|
|
{ "file_html",
|
|
N_("Choose the file that you want to import into Evolution, "
|
|
"and select what type of file it is from the list.")
|
|
},
|
|
{ "dest_html",
|
|
N_("Choose the destination for this import")
|
|
},
|
|
{ "intelligent_html",
|
|
N_("Please select the information that you would like to import:")
|
|
},
|
|
{ "nodata_html",
|
|
N_("Evolution checked for settings to import from the following\n"
|
|
"applications: Pine, Netscape, Elm, iCalendar. No importable\n"
|
|
"settings found. If you would like to\n"
|
|
"try again, please click the \"Back\" button.\n")
|
|
}
|
|
};
|
|
#define num_info (sizeof (info) / sizeof (info[0]))
|
|
|
|
static GtkWidget *
|
|
create_help (const char *name)
|
|
{
|
|
GtkWidget *label;
|
|
int i;
|
|
|
|
for (i = 0; i < num_info; i++) {
|
|
if (!strcmp (name, info[i].name))
|
|
break;
|
|
}
|
|
|
|
if (i >= num_info)
|
|
g_warning ("i > num_info\n");
|
|
|
|
|
|
label = gtk_label_new(i < num_info ? _(info[i].text): NULL);
|
|
gtk_widget_show (label);
|
|
gtk_label_set_line_wrap((GtkLabel *)label, TRUE);
|
|
|
|
return label;
|
|
}
|
|
|
|
/* Importing functions */
|
|
|
|
static void
|
|
filename_changed (GtkWidget *widget,
|
|
ImportData *data)
|
|
{
|
|
ImportDialogFilePage *page;
|
|
const char *filename;
|
|
int fileok;
|
|
|
|
page = data->filepage;
|
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
|
|
|
|
fileok = filename && filename[0] && g_file_test(filename, G_FILE_TEST_IS_REGULAR);
|
|
if (fileok) {
|
|
GtkTreeIter iter;
|
|
GtkTreeModel *model;
|
|
gboolean valid;
|
|
GSList *l;
|
|
EImportImporter *first = NULL;
|
|
int i=0, firstitem=0;
|
|
|
|
g_free(page->target->uri_src);
|
|
page->target->uri_src = g_filename_to_uri(filename, NULL, NULL);
|
|
|
|
l = e_import_get_importers(data->import, (EImportTarget *)page->target);
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype));
|
|
valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
while (valid) {
|
|
gpointer eii = NULL;
|
|
|
|
gtk_tree_model_get (model, &iter, 2, &eii, -1);
|
|
|
|
if (g_slist_find (l, eii) != NULL) {
|
|
if (first == NULL) {
|
|
firstitem = i;
|
|
first = eii;
|
|
}
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, TRUE, -1);
|
|
fileok = TRUE;
|
|
} else {
|
|
if (page->importer == eii)
|
|
page->importer = NULL;
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, FALSE, -1);
|
|
}
|
|
i++;
|
|
valid = gtk_tree_model_iter_next (model, &iter);
|
|
}
|
|
g_slist_free(l);
|
|
|
|
if (page->importer == NULL && first) {
|
|
page->importer = first;
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (page->filetype), firstitem);
|
|
}
|
|
fileok = first != NULL;
|
|
} else {
|
|
GtkTreeIter iter;
|
|
GtkTreeModel *model;
|
|
gboolean valid;
|
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype));
|
|
for (valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
valid;
|
|
valid = gtk_tree_model_iter_next (model, &iter)) {
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, FALSE, -1);
|
|
}
|
|
}
|
|
|
|
gnome_druid_set_buttons_sensitive(GNOME_DRUID (data->druid), TRUE, fileok, TRUE, FALSE);
|
|
}
|
|
|
|
static void
|
|
filetype_changed_cb (GtkWidget *combobox, ImportData *data)
|
|
{
|
|
GtkTreeIter iter;
|
|
|
|
g_return_if_fail (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &iter));
|
|
|
|
gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (combobox)), &iter, 2, &data->filepage->importer, -1);
|
|
filename_changed (data->filepage->filename, data);
|
|
}
|
|
|
|
static ImportDialogFilePage *
|
|
importer_file_page_new (ImportData *data)
|
|
{
|
|
ImportDialogFilePage *page;
|
|
GtkWidget *table, *label;
|
|
GtkCellRenderer *cell;
|
|
GtkListStore *store;
|
|
int row = 0;
|
|
|
|
page = g_new0 (ImportDialogFilePage, 1);
|
|
|
|
page->vbox = gtk_vbox_new (FALSE, 5);
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 8);
|
|
gtk_box_pack_start (GTK_BOX (page->vbox), table, TRUE, TRUE, 0);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("F_ilename:"));
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
GTK_FILL, 0, 0, 0);
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
|
|
|
|
page->filename = gtk_file_chooser_button_new (_("Select a file"), GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
g_signal_connect (GTK_FILE_CHOOSER_BUTTON (page->filename), "selection-changed", G_CALLBACK (filename_changed), data);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), page->filename, 1, 2,
|
|
row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(label), page->filename);
|
|
|
|
row++;
|
|
|
|
label = gtk_label_new_with_mnemonic (_("File _type:"));
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
|
|
GTK_FILL, 0, 0, 0);
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
|
|
|
|
store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER);
|
|
page->filetype = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
|
g_object_unref (store);
|
|
|
|
gtk_cell_layout_clear (GTK_CELL_LAYOUT (page->filetype));
|
|
|
|
cell = gtk_cell_renderer_text_new ();
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (page->filetype), cell, TRUE);
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (page->filetype), cell,
|
|
"text", 0,
|
|
"sensitive", 1,
|
|
NULL);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), page->filetype, 1, 2,
|
|
row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
|
|
gtk_label_set_mnemonic_widget(GTK_LABEL(label), page->filetype);
|
|
|
|
gtk_widget_show_all (table);
|
|
|
|
return page;
|
|
}
|
|
|
|
static ImportDialogDestPage *
|
|
importer_dest_page_new (ImportData *data)
|
|
{
|
|
ImportDialogDestPage *page;
|
|
|
|
page = g_new0 (ImportDialogDestPage, 1);
|
|
|
|
page->vbox = gtk_vbox_new (FALSE, 5);
|
|
|
|
return page;
|
|
}
|
|
|
|
static ImportDialogTypePage *
|
|
importer_type_page_new (ImportData *data)
|
|
{
|
|
ImportDialogTypePage *page;
|
|
|
|
page = g_new0 (ImportDialogTypePage, 1);
|
|
|
|
page->vbox = gtk_vbox_new (FALSE, 5);
|
|
page->intelligent = gtk_radio_button_new_with_mnemonic (NULL,
|
|
_("Import data and settings from _older programs"));
|
|
gtk_box_pack_start (GTK_BOX (page->vbox), page->intelligent, FALSE, FALSE, 0);
|
|
page->file = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (page->intelligent),
|
|
_("Import a _single file"));
|
|
gtk_box_pack_start (GTK_BOX (page->vbox), page->file, FALSE, FALSE, 0);
|
|
gtk_widget_show_all (page->vbox);
|
|
return page;
|
|
}
|
|
|
|
static ImportDialogImporterPage *
|
|
importer_importer_page_new (ImportData *data)
|
|
{
|
|
ImportDialogImporterPage *page;
|
|
GtkWidget *sep;
|
|
|
|
page = g_new0 (ImportDialogImporterPage, 1);
|
|
|
|
page->vbox = gtk_vbox_new (FALSE, 5);
|
|
gtk_container_set_border_width (GTK_CONTAINER (page->vbox), 4);
|
|
|
|
sep = gtk_hseparator_new ();
|
|
gtk_box_pack_start (GTK_BOX (page->vbox), sep, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (page->vbox);
|
|
|
|
return page;
|
|
}
|
|
|
|
static gboolean
|
|
prepare_intelligent_page (GnomeDruidPage *dpage,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
GSList *l;
|
|
GtkWidget *table;
|
|
int row;
|
|
ImportDialogImporterPage *page = data->importerpage;
|
|
|
|
if (page->target != NULL)
|
|
return FALSE;
|
|
|
|
page->target = e_import_target_new_home(data->import, g_get_home_dir());
|
|
|
|
if (data->importerpage->importers)
|
|
g_slist_free(data->importerpage->importers);
|
|
l = data->importerpage->importers = e_import_get_importers(data->import, (EImportTarget *)page->target);
|
|
|
|
if (l == NULL) {
|
|
gtk_box_pack_start(GTK_BOX (data->importerpage->vbox), create_help("nodata_html"), FALSE, TRUE, 0);
|
|
gnome_druid_set_buttons_sensitive(druid, TRUE, FALSE, TRUE, FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
table = gtk_table_new(g_slist_length(l), 2, FALSE);
|
|
row = 0;
|
|
for (;l;l=l->next) {
|
|
EImportImporter *eii = l->data;
|
|
char *str;
|
|
GtkWidget *w, *label;
|
|
|
|
w = e_import_get_widget(data->import, (EImportTarget *)page->target, eii);
|
|
|
|
str = g_strdup_printf(_("From %s:"), eii->name);
|
|
label = gtk_label_new(str);
|
|
gtk_widget_show(label);
|
|
g_free(str);
|
|
|
|
gtk_misc_set_alignment((GtkMisc *)label, 0, .5);
|
|
|
|
gtk_table_attach((GtkTable *)table, label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
|
|
if (w)
|
|
gtk_table_attach((GtkTable *)table, w, 1, 2, row, row+1, GTK_FILL, 0, 3, 0);
|
|
row++;
|
|
}
|
|
|
|
gtk_widget_show(table);
|
|
gtk_box_pack_start((GtkBox *)data->importerpage->vbox, table, FALSE, FALSE, 0);
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static void
|
|
import_druid_cancel (GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
gtk_widget_destroy (GTK_WIDGET (data->dialog));
|
|
}
|
|
|
|
static gboolean
|
|
import_druid_esc (GnomeDruid *druid,
|
|
GdkEventKey *event,
|
|
ImportData *data)
|
|
{
|
|
if (event->keyval == GDK_Escape) {
|
|
gtk_widget_destroy (GTK_WIDGET (data->dialog));
|
|
return TRUE;
|
|
} else
|
|
return FALSE;
|
|
}
|
|
|
|
static void
|
|
import_druid_weak_notify (void *blah,
|
|
GObject *where_the_object_was)
|
|
{
|
|
ImportData *data = (ImportData *) blah;
|
|
|
|
if (data->importerpage->target)
|
|
e_import_target_free(data->import, data->importerpage->target);
|
|
g_slist_free(data->importerpage->importers);
|
|
|
|
if (data->filepage->target)
|
|
e_import_target_free(data->import, data->filepage->target);
|
|
|
|
g_object_unref(data->import);
|
|
|
|
g_object_unref(data->wizard);
|
|
g_free(data);
|
|
}
|
|
|
|
static void
|
|
import_status(EImport *import, const char *what, int pc, void *d)
|
|
{
|
|
ImportData *data = d;
|
|
|
|
gtk_progress_bar_set_fraction((GtkProgressBar *)data->import_progress, (gfloat)(pc/100.0));
|
|
gtk_progress_bar_set_text((GtkProgressBar *)data->import_progress, what);
|
|
}
|
|
|
|
static void
|
|
import_dialog_response(GtkDialog *d, guint button, ImportData *data)
|
|
{
|
|
if (button == GTK_RESPONSE_CANCEL)
|
|
e_import_cancel(data->import, data->import_target, data->import_importer);
|
|
}
|
|
|
|
static void
|
|
import_done(EImport *ei, void *d)
|
|
{
|
|
ImportData *data = d;
|
|
|
|
gtk_widget_destroy(data->import_dialog);
|
|
gtk_widget_destroy(data->dialog);
|
|
}
|
|
|
|
static void
|
|
import_intelligent_done(EImport *ei, void *d)
|
|
{
|
|
ImportData *data = d;
|
|
|
|
if (data->importerpage->current
|
|
&& (data->importerpage->current = data->importerpage->current->next)) {
|
|
import_status(ei, "", 0, d);
|
|
data->import_importer = data->importerpage->current->data;
|
|
e_import_import(data->import, (EImportTarget *)data->importerpage->target, data->import_importer, import_status, import_intelligent_done, data);
|
|
} else
|
|
import_done(ei, d);
|
|
}
|
|
|
|
static void
|
|
import_druid_finish (GnomeDruidPage *page,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
EImportCompleteFunc done = NULL;
|
|
char *msg = NULL;
|
|
|
|
if (gtk_toggle_button_get_active((GtkToggleButton *)data->typepage->intelligent)) {
|
|
data->importerpage->current = data->importerpage->importers;
|
|
if (data->importerpage->current) {
|
|
data->import_target = (EImportTarget *)data->importerpage->target;
|
|
data->import_importer = data->importerpage->current->data;
|
|
done = import_intelligent_done;
|
|
msg = g_strdup_printf(_("Importing data."));
|
|
}
|
|
} else {
|
|
if (data->filepage->importer) {
|
|
data->import_importer = data->filepage->importer;
|
|
data->import_target = (EImportTarget *)data->filepage->target;
|
|
done = import_done;
|
|
msg = g_strdup_printf(_("Importing `%s'"), data->filepage->target->uri_src);
|
|
}
|
|
}
|
|
|
|
if (done) {
|
|
data->import_dialog = e_error_new(NULL, "shell:importing", msg, NULL);
|
|
g_signal_connect(data->import_dialog, "response", G_CALLBACK(import_dialog_response), data);
|
|
data->import_label = gtk_label_new(_("Please wait"));
|
|
data->import_progress = gtk_progress_bar_new();
|
|
gtk_box_pack_start(GTK_BOX(((GtkDialog *)data->import_dialog)->vbox), data->import_label, FALSE, FALSE, 0);
|
|
gtk_box_pack_start(GTK_BOX(((GtkDialog *)data->import_dialog)->vbox), data->import_progress, FALSE, FALSE, 0);
|
|
gtk_widget_show_all(data->import_dialog);
|
|
|
|
e_import_import(data->import, data->import_target, data->import_importer, import_status, import_done, data);
|
|
} else {
|
|
gtk_widget_destroy(data->dialog);
|
|
}
|
|
|
|
g_free(msg);
|
|
}
|
|
|
|
static gboolean
|
|
prepare_file_page (GnomeDruidPage *dpage,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
GSList *importers, *imp;
|
|
GtkListStore *store;
|
|
ImportDialogFilePage *page = data->filepage;
|
|
|
|
if (page->target != NULL) {
|
|
filename_changed(data->filepage->filename, data);
|
|
return FALSE;
|
|
}
|
|
|
|
page->target = e_import_target_new_uri(data->import, NULL, NULL);
|
|
importers = e_import_get_importers (data->import, (EImportTarget *)page->target);
|
|
|
|
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (page->filetype)));
|
|
gtk_list_store_clear (store);
|
|
|
|
for (imp = importers; imp; imp = imp->next) {
|
|
GtkTreeIter iter;
|
|
EImportImporter *eii = imp->data;
|
|
|
|
gtk_list_store_append (store, &iter);
|
|
gtk_list_store_set (
|
|
store, &iter,
|
|
0, eii->name,
|
|
1, TRUE,
|
|
2, eii,
|
|
-1);
|
|
}
|
|
|
|
g_slist_free (importers);
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (page->filetype), 0);
|
|
|
|
filename_changed (data->filepage->filename, data);
|
|
|
|
g_signal_connect (page->filetype, "changed", G_CALLBACK (filetype_changed_cb), data);
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static gboolean
|
|
next_file_page (GnomeDruidPage *page,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
/* We dont sensitise the next button if we're not already usable */
|
|
return FALSE;
|
|
}
|
|
|
|
static gboolean
|
|
prepare_dest_page (GnomeDruidPage *dpage,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
ImportDialogDestPage *page = data->destpage;
|
|
|
|
if (page->control)
|
|
gtk_container_remove((GtkContainer *)page->vbox, page->control);
|
|
|
|
page->control = e_import_get_widget(data->import, (EImportTarget *)data->filepage->target, data->filepage->importer);
|
|
if (page->control == NULL) {
|
|
/* Coding error, not needed for translators */
|
|
page->control = gtk_label_new("** PLUGIN ERROR ** No settings for importer");
|
|
gtk_widget_show(page->control);
|
|
}
|
|
|
|
gtk_box_pack_start((GtkBox *)data->destpage->vbox, page->control, TRUE, TRUE, 0);
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static gboolean
|
|
next_dest_page (GnomeDruidPage *page,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
gnome_druid_set_page (druid, GNOME_DRUID_PAGE (data->finish));
|
|
return TRUE;
|
|
}
|
|
|
|
static gboolean
|
|
next_type_page (GnomeDruidPage *page,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->typepage->intelligent))) {
|
|
gnome_druid_set_page (druid, GNOME_DRUID_PAGE (data->intelligent));
|
|
} else {
|
|
gnome_druid_set_page (druid, GNOME_DRUID_PAGE (data->filedialog));
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static gboolean
|
|
back_finish_page (GnomeDruidPage *page,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->typepage->intelligent))) {
|
|
gnome_druid_set_page (druid, GNOME_DRUID_PAGE (data->intelligent));
|
|
} else {
|
|
gnome_druid_set_page (druid, GNOME_DRUID_PAGE (data->destdialog));
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static gboolean
|
|
back_intelligent_page (GnomeDruidPage *page,
|
|
GnomeDruid *druid,
|
|
ImportData *data)
|
|
{
|
|
gnome_druid_set_page (druid, GNOME_DRUID_PAGE (data->typedialog));
|
|
return TRUE;
|
|
}
|
|
|
|
static void
|
|
dialog_weak_notify (void *data,
|
|
GObject *where_the_dialog_was)
|
|
{
|
|
gboolean *dialog_open = (gboolean *) data;
|
|
|
|
*dialog_open = FALSE;
|
|
}
|
|
|
|
void
|
|
e_shell_importer_start_import (EShellWindow *shell_window)
|
|
{
|
|
ImportData *data = g_new0 (ImportData, 1);
|
|
GtkWidget *html;
|
|
static gboolean dialog_open = FALSE;
|
|
GdkPixbuf *icon;
|
|
char *gladefile;
|
|
|
|
if (dialog_open) {
|
|
return;
|
|
}
|
|
|
|
data->import = e_import_new("org.gnome.evolution.shell.importer");
|
|
|
|
icon = e_icon_factory_get_icon ("stock_mail-import", E_ICON_SIZE_DIALOG);
|
|
|
|
dialog_open = TRUE;
|
|
data->window = shell_window;
|
|
|
|
gladefile = g_build_filename (EVOLUTION_GLADEDIR, "import.glade", NULL);
|
|
data->wizard = glade_xml_new (gladefile, NULL, NULL);
|
|
g_free (gladefile);
|
|
data->dialog = glade_xml_get_widget (data->wizard, "importwizard");
|
|
gtk_window_set_default_size (GTK_WINDOW (data->dialog), 480, 320);
|
|
gtk_window_set_wmclass (GTK_WINDOW (data->dialog), "importdruid",
|
|
"Evolution:shell");
|
|
e_dialog_set_transient_for (GTK_WINDOW (data->dialog), GTK_WIDGET (shell_window));
|
|
g_object_weak_ref ((GObject *)data->dialog, dialog_weak_notify, &dialog_open);
|
|
|
|
data->druid = glade_xml_get_widget (data->wizard, "druid1");
|
|
g_signal_connect (data->druid, "cancel",
|
|
G_CALLBACK (import_druid_cancel), data);
|
|
g_signal_connect (data->druid, "key_press_event",
|
|
G_CALLBACK (import_druid_esc), data);
|
|
|
|
gtk_button_set_use_underline ((GtkButton *)((GnomeDruid *)data->druid)->finish, TRUE);
|
|
gtk_button_set_label((GtkButton *)((GnomeDruid *)data->druid)->finish, _("_Import"));
|
|
|
|
/* Start page */
|
|
data->start = GNOME_DRUID_PAGE_EDGE (glade_xml_get_widget (data->wizard, "page0"));
|
|
gnome_druid_page_edge_set_logo (data->start, icon);
|
|
|
|
/* Intelligent or direct import page */
|
|
data->typedialog = glade_xml_get_widget (data->wizard, "page1");
|
|
gnome_druid_page_standard_set_logo (GNOME_DRUID_PAGE_STANDARD (data->typedialog), icon);
|
|
g_signal_connect (data->typedialog, "next",
|
|
G_CALLBACK (next_type_page), data);
|
|
data->typepage = importer_type_page_new (data);
|
|
html = create_help ("type_html");
|
|
gtk_box_pack_start (GTK_BOX (data->typepage->vbox), html, FALSE, TRUE, 0);
|
|
gtk_box_reorder_child (GTK_BOX (data->typepage->vbox), html, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (data->typedialog)->vbox), data->typepage->vbox, TRUE, TRUE, 0);
|
|
|
|
/* Intelligent importer source page */
|
|
data->intelligent = glade_xml_get_widget (data->wizard, "page2-intelligent");
|
|
gnome_druid_page_standard_set_logo (GNOME_DRUID_PAGE_STANDARD (data->intelligent), icon);
|
|
g_signal_connect (data->intelligent, "back",
|
|
G_CALLBACK (back_intelligent_page), data);
|
|
g_signal_connect_after (data->intelligent, "prepare",
|
|
G_CALLBACK (prepare_intelligent_page), data);
|
|
|
|
data->importerpage = importer_importer_page_new (data);
|
|
html = create_help ("intelligent_html");
|
|
gtk_box_pack_start (GTK_BOX (data->importerpage->vbox), html, FALSE, TRUE, 0);
|
|
gtk_box_reorder_child (GTK_BOX (data->importerpage->vbox), html, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (data->intelligent)->vbox), data->importerpage->vbox, TRUE, TRUE, 0);
|
|
|
|
|
|
/* File selection and file type page */
|
|
data->filedialog = glade_xml_get_widget (data->wizard, "page2-file");
|
|
gnome_druid_page_standard_set_logo (GNOME_DRUID_PAGE_STANDARD (data->filedialog), icon);
|
|
g_signal_connect_after (data->filedialog, "prepare",
|
|
G_CALLBACK (prepare_file_page), data);
|
|
g_signal_connect (data->filedialog, "next",
|
|
G_CALLBACK (next_file_page), data);
|
|
data->filepage = importer_file_page_new (data);
|
|
|
|
html = create_help ("file_html");
|
|
gtk_box_pack_start (GTK_BOX (data->filepage->vbox), html, FALSE, TRUE, 0);
|
|
gtk_box_reorder_child (GTK_BOX (data->filepage->vbox), html, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (data->filedialog)->vbox), data->filepage->vbox, TRUE, TRUE, 0);
|
|
|
|
/* File destination page */
|
|
data->destdialog = glade_xml_get_widget (data->wizard, "page3-file");
|
|
g_signal_connect_after (data->destdialog, "prepare",
|
|
G_CALLBACK (prepare_dest_page), data);
|
|
g_signal_connect (data->destdialog, "next",
|
|
G_CALLBACK (next_dest_page), data);
|
|
|
|
data->destpage = importer_dest_page_new (data);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (data->destdialog)->vbox), data->destpage->vbox, TRUE, TRUE, 0);
|
|
|
|
/* Finish page */
|
|
data->finish = GNOME_DRUID_PAGE_EDGE (glade_xml_get_widget (data->wizard, "page4"));
|
|
gnome_druid_page_edge_set_logo (data->finish, icon);
|
|
g_signal_connect (data->finish, "back",
|
|
G_CALLBACK (back_finish_page), data);
|
|
|
|
g_signal_connect (data->finish, "finish",
|
|
G_CALLBACK (import_druid_finish), data);
|
|
|
|
g_object_weak_ref ((GObject *)data->dialog, import_druid_weak_notify, data);
|
|
|
|
g_object_unref (icon);
|
|
|
|
gtk_widget_show_all (data->dialog);
|
|
}
|