From 2febb125d6abd0e9f485a13ae99281112a97416a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 12 Aug 2009 11:37:59 -0400 Subject: Get the backup-restore plugin working. --- plugins/backup-restore/Makefile.am | 8 +-- plugins/backup-restore/backup-restore.c | 76 +++++++++++++++++----- .../org-gnome-backup-restore.eplug.xml | 39 +++++------ .../backup-restore/org-gnome-backup-restore.xml | 21 ------ 4 files changed, 78 insertions(+), 66 deletions(-) delete mode 100644 plugins/backup-restore/org-gnome-backup-restore.xml (limited to 'plugins/backup-restore') diff --git a/plugins/backup-restore/Makefile.am b/plugins/backup-restore/Makefile.am index c1792abb64..bc27b1d7a3 100644 --- a/plugins/backup-restore/Makefile.am +++ b/plugins/backup-restore/Makefile.am @@ -1,11 +1,12 @@ AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/widgets \ -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ -DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \ -DPREFIX=\""$(prefix)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATADIR=\""$(datadir)"\" \ -DLIBDIR=\""$(libdir)"\" \ - -I$(top_srcdir) \ $(EVOLUTION_CALENDAR_CFLAGS) \ $(SHELL_CFLAGS) \ $(E_UTIL_CFLAGS) @@ -15,7 +16,7 @@ AM_CPPFLAGS = \ error_DATA = org-gnome-backup-restore.error errordir = $(privdatadir)/errors -plugin_DATA = org-gnome-backup-restore.eplug org-gnome-backup-restore.xml +plugin_DATA = org-gnome-backup-restore.eplug plugin_LTLIBRARIES = liborg-gnome-backup-restore.la liborg_gnome_backup_restore_la_SOURCES = backup-restore.c @@ -35,8 +36,7 @@ endif EXTRA_DIST = \ org-gnome-backup-restore.eplug.xml \ - org-gnome-backup-restore.error.xml \ - org-gnome-backup-restore.xml + org-gnome-backup-restore.error.xml BUILT_SOURCES = org-gnome-backup-restore.eplug \ org-gnome-backup-restore.error diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c index 79221d4573..8aa41e5fe7 100644 --- a/plugins/backup-restore/backup-restore.c +++ b/plugins/backup-restore/backup-restore.c @@ -33,15 +33,16 @@ #include #include #include -#include "shell/es-menu.h" #include "mail/em-config.h" #include "mail/em-account-editor.h" #include "e-util/e-error.h" #include "e-util/e-util.h" #include "e-util/e-dialog-utils.h" +#include "shell/e-shell-window.h" + +gboolean e_plugin_ui_init (GtkUIManager *ui_manager, + EShellWindow *shell_window); -void org_gnome_backup_restore_backup (EPlugin *ep, ESMenuTargetShell *target); -void org_gnome_backup_restore_restore (EPlugin *ep, ESMenuTargetShell *target); GtkWidget * backup_restore_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data); void backup_restore_commit (EPlugin *ep, EMConfigTargetAccount *target); void backup_restore_abort (EPlugin *ep, EMConfigTargetAccount *target); @@ -130,18 +131,19 @@ epbr_perform_pre_backup_checks (gchar * dir) } void -org_gnome_backup_restore_backup (EPlugin *ep, ESMenuTargetShell *target) +action_settings_backup_cb (GtkAction *action, + EShellWindow *shell_window) { GtkWidget *dlg; GtkWidget *vbox; + GtkWindow *parent; gint response; - dlg = e_file_get_save_filesel(target->target.widget, _("Select name of the Evolution backup file"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE); + parent = GTK_WINDOW (shell_window); -/* dlg = gtk_file_chooser_dialog_new (_("Select name of the Evolution backup file"), GTK_WINDOW (target->target.widget), */ -/* GTK_FILE_CHOOSER_ACTION_SAVE, */ -/* GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, */ -/* GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL); */ + dlg = e_file_get_save_filesel ( + parent, _("Select name of the Evolution backup file"), + NULL, GTK_FILE_CHOOSER_ACTION_SAVE); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlg), "evolution-backup.tar.gz"); @@ -164,7 +166,9 @@ org_gnome_backup_restore_backup (EPlugin *ep, ESMenuTargetShell *target) if (epbr_perform_pre_backup_checks (dir)) { - mask = dialog_prompt_user (GTK_WINDOW (target->target.widget), _("_Restart Evolution after backup"), "org.gnome.backup-restore:backup-confirm", NULL); + mask = dialog_prompt_user ( + parent, _("_Restart Evolution after backup"), + "org.gnome.backup-restore:backup-confirm", NULL); if (mask & BR_OK) backup (filename, (mask & BR_START) ? TRUE: FALSE); } else { @@ -181,18 +185,20 @@ org_gnome_backup_restore_backup (EPlugin *ep, ESMenuTargetShell *target) } void -org_gnome_backup_restore_restore (EPlugin *ep, ESMenuTargetShell *target) +action_settings_restore_cb (GtkAction *action, + EShellWindow *shell_window) { GtkWidget *dlg; GtkWidget *vbox; + GtkWindow *parent; gint response; - dlg = e_file_get_save_filesel(target->target.widget, _("Select name of the Evolution backup file to restore"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN); + parent = GTK_WINDOW (shell_window); -/* dlg = gtk_file_chooser_dialog_new (_("Select Evolution backup file to restore"), GTK_WINDOW (target->target.widget), */ -/* GTK_FILE_CHOOSER_ACTION_OPEN, */ -/* GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, */ -/* GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); */ + dlg = e_file_get_save_filesel ( + parent, + _("Select name of the Evolution backup file to restore"), + NULL, GTK_FILE_CHOOSER_ACTION_OPEN); vbox = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox); @@ -211,11 +217,13 @@ org_gnome_backup_restore_restore (EPlugin *ep, ESMenuTargetShell *target) if (sanity_check (filename)) { guint32 mask; - mask = dialog_prompt_user (GTK_WINDOW (target->target.widget), _("_Restart Evolution after restore"), "org.gnome.backup-restore:restore-confirm", NULL); + mask = dialog_prompt_user ( + parent, _("_Restart Evolution after restore"), + "org.gnome.backup-restore:restore-confirm", NULL); if (mask & BR_OK) restore (filename, mask & BR_START); } else { - e_error_run (GTK_WINDOW (target->target.widget), "org.gnome.backup-restore:invalid-backup", NULL); + e_error_run (parent, "org.gnome.backup-restore:invalid-backup", NULL); } g_free (filename); @@ -331,3 +339,35 @@ backup_restore_abort (EPlugin *ep, EMConfigTargetAccount *target) /* Nothing really */ } +static GtkActionEntry entries[] = { + + { "settings-backup", + NULL, + N_("_Backup Settings..."), + NULL, + N_("Backup Evolution data and settings to an archive file"), + G_CALLBACK (action_settings_backup_cb) }, + + { "settings-restore", + NULL, + N_("R_estore Settings..."), + NULL, + N_("Restore Evolution data and settings from an archive file"), + G_CALLBACK (action_settings_restore_cb) } +}; + +gboolean +e_plugin_ui_init (GtkUIManager *ui_manager, + EShellWindow *shell_window) +{ + GtkActionGroup *action_group; + + action_group = e_shell_window_get_action_group (shell_window, "shell"); + + /* Add actions to the "shell" action group. */ + gtk_action_group_add_actions ( + action_group, entries, + G_N_ELEMENTS (entries), shell_window); + + return TRUE; +} diff --git a/plugins/backup-restore/org-gnome-backup-restore.eplug.xml b/plugins/backup-restore/org-gnome-backup-restore.eplug.xml index 2ed7222adc..6d92cf48ae 100644 --- a/plugins/backup-restore/org-gnome-backup-restore.eplug.xml +++ b/plugins/backup-restore/org-gnome-backup-restore.eplug.xml @@ -9,31 +9,24 @@ <_description>Backup and restore your Evolution data and settings. - - - - - - - - + + + + + + + + + + + + + + + + - - - - - diff --git a/plugins/backup-restore/org-gnome-backup-restore.xml b/plugins/backup-restore/org-gnome-backup-restore.xml deleted file mode 100644 index e546ce5581..0000000000 --- a/plugins/backup-restore/org-gnome-backup-restore.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - -- cgit From 672adf12a0923437e90d08ab7925bd9329fcce0d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 16 Aug 2009 11:25:08 -0400 Subject: Fix compiler warnings and deprecated GTK+ API usage. --- plugins/backup-restore/backup-restore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/backup-restore') diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c index 8aa41e5fe7..560fa5c63c 100644 --- a/plugins/backup-restore/backup-restore.c +++ b/plugins/backup-restore/backup-restore.c @@ -130,7 +130,7 @@ epbr_perform_pre_backup_checks (gchar * dir) #endif } -void +static void action_settings_backup_cb (GtkAction *action, EShellWindow *shell_window) { @@ -184,7 +184,7 @@ action_settings_backup_cb (GtkAction *action, gtk_widget_destroy (dlg); } -void +static void action_settings_restore_cb (GtkAction *action, EShellWindow *shell_window) { -- cgit From de528db6c18b7ecee83bb8b52850d935c1244ebf Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 18 Aug 2009 10:00:23 -0400 Subject: BugĀ 567260 - Migrate from GnomeDruid to GtkAssistant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/backup-restore/backup-restore.c | 112 +++++++++++---------- .../org-gnome-backup-restore.eplug.xml | 2 +- 2 files changed, 61 insertions(+), 53 deletions(-) (limited to 'plugins/backup-restore') diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c index 560fa5c63c..6df2763698 100644 --- a/plugins/backup-restore/backup-restore.c +++ b/plugins/backup-restore/backup-restore.c @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include "mail/em-config.h" #include "mail/em-account-editor.h" #include "e-util/e-error.h" @@ -105,7 +103,7 @@ dialog_prompt_user(GtkWindow *parent, const gchar *string, const gchar *tag, con /* We should hardcode this to true */ gtk_toggle_button_set_active ((GtkToggleButton *)check, TRUE); gtk_container_set_border_width((GtkContainer *)check, 12); - gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 0); + gtk_box_pack_start ((GtkBox *)gtk_dialog_get_content_area ((GtkDialog *) mbox), check, TRUE, TRUE, 0); gtk_widget_show (check); button = gtk_dialog_run ((GtkDialog *) mbox); @@ -235,77 +233,74 @@ action_settings_restore_cb (GtkAction *action, } static void -check_toggled (GtkToggleButton *button, GnomeDruid *druid) +check_toggled (GtkToggleButton *button, GtkAssistant *assistant) { - GtkWidget *box = g_object_get_data ((GObject *)button, "box"); - gboolean state = gtk_toggle_button_get_active ((GtkToggleButton *)button); - gchar *prevfile = g_object_get_data ((GObject *)druid, "restore-file"); + GtkWidget *box = g_object_get_data ((GObject *)button, "box"); + gboolean state = gtk_toggle_button_get_active ((GtkToggleButton *)button); gtk_widget_set_sensitive (box, state); - gnome_druid_set_show_finish (druid, state); - if (state && !prevfile) - gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, TRUE); - else - gnome_druid_set_buttons_sensitive (druid, TRUE, TRUE, TRUE, TRUE); - g_object_set_data ((GObject *)druid, "restore", GINT_TO_POINTER (state?1:0)); + g_object_set_data ((GObject *)assistant, "restore", GINT_TO_POINTER (state?1:0)); + e_config_target_changed ((EConfig *) g_object_get_data ((GObject *)assistant, "restore-config"), E_CONFIG_TARGET_CHANGED_STATE); } static void -restore_wizard (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data) +file_changed (GtkFileChooser *chooser, GtkAssistant *assistant) { - gboolean state = GPOINTER_TO_INT(g_object_get_data((GObject *)druid, "restore")) ? TRUE:FALSE; - gchar *file = g_object_get_data ((GObject *)druid, "restore-file"); + gchar *file = NULL, *prevfile = NULL; + gchar *uri = NULL; - if (state) { - if (!file ||!sanity_check (file)) { - e_error_run ((GtkWindow *)druid, "org.gnome.backup-restore:invalid-backup", NULL); - } else - restore (file, TRUE); + uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (chooser)); + e_file_update_save_path (uri, TRUE); - } + file = gtk_file_chooser_get_filename (chooser); + prevfile = g_object_get_data ((GObject *)assistant, "restore-file"); + g_object_set_data ((GObject *)assistant, "restore-file", file); + g_free (prevfile); + + e_config_target_changed ((EConfig *) g_object_get_data ((GObject *)assistant, "restore-config"), E_CONFIG_TARGET_CHANGED_STATE); } -static void -file_changed (GtkFileChooser *chooser, GnomeDruid *druid) +static gboolean +backup_restore_check (EConfig *ec, const gchar *pageid, gpointer data) { - gchar *file = NULL, *prevfile=NULL; - gchar *uri = NULL; + GtkAssistant *assistant = data; + gint do_restore; + gchar *file; - uri = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER (chooser)); - e_file_update_save_path(uri, TRUE); + g_return_val_if_fail (data != NULL, FALSE); + g_return_val_if_fail (GTK_IS_ASSISTANT (data), FALSE); - file = gtk_file_chooser_get_filename (chooser); - prevfile = g_object_get_data ((GObject *)druid, "restore-file"); - g_object_set_data ((GObject *)druid, "restore-file", file); - g_free (prevfile); - if (file) { - gnome_druid_set_buttons_sensitive (druid, TRUE, TRUE, TRUE, TRUE); - } else - gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, TRUE); + do_restore = GPOINTER_TO_INT (g_object_get_data ((GObject *)assistant, "restore")); + file = g_object_get_data ((GObject *)assistant, "restore-file"); + e_config_set_page_is_finish (ec, "0.startup_page.10.backup_restore", do_restore); + + return !do_restore || file; } + GtkWidget * backup_restore_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data) { - GtkWidget *page; - GtkWidget *box, *hbox, *label, *cbox, *button; + GtkWidget *page, *hbox, *label, *cbox, *button; + GtkAssistant *assistant = GTK_ASSISTANT (hook_data->parent); + + page = gtk_vbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (page), 12); - page = gnome_druid_page_standard_new_with_vals (_("Restore from backup"), NULL, NULL); hbox = gtk_hbox_new (FALSE, 6); label = gtk_label_new (_("You can restore Evolution from your backup. It can restore all the Mails, Calendars, Tasks, Memos, Contacts. It also restores all your personal settings, mail filters etc.")); gtk_label_set_line_wrap ((GtkLabel *)label, TRUE); gtk_label_set_single_line_mode ((GtkLabel *)label, FALSE); gtk_box_pack_start ((GtkBox *)hbox, label, FALSE, FALSE, 6); - box = gtk_vbox_new (FALSE, 6); - gtk_box_pack_start ((GtkBox *)box, hbox, FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)page, hbox, FALSE, FALSE, 0); hbox = gtk_hbox_new (FALSE, 6); cbox = gtk_check_button_new_with_mnemonic (_("_Restore Evolution from the backup file")); - g_signal_connect (cbox, "toggled", G_CALLBACK (check_toggled), hook_data->parent); + g_signal_connect (cbox, "toggled", G_CALLBACK (check_toggled), assistant); gtk_box_pack_start ((GtkBox *)hbox, cbox, FALSE, FALSE, 6); - gtk_box_pack_start ((GtkBox *)box, hbox, FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)page, hbox, FALSE, FALSE, 0); hbox = gtk_hbox_new (FALSE, 6); g_object_set_data ((GObject *)cbox, "box", hbox); @@ -313,24 +308,37 @@ backup_restore_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data) gtk_box_pack_start ((GtkBox *)hbox, label, FALSE, FALSE, 12); button = gtk_file_chooser_button_new (_("Choose a file to restore"), GTK_FILE_CHOOSER_ACTION_OPEN); - g_signal_connect (button, "selection-changed", G_CALLBACK (file_changed), hook_data->parent); + g_signal_connect (button, "selection-changed", G_CALLBACK (file_changed), assistant); gtk_file_chooser_button_set_width_chars ((GtkFileChooserButton *)button, 20); gtk_box_pack_start ((GtkBox *)hbox, button, FALSE, FALSE, 0); - gtk_box_pack_start ((GtkBox *)box, hbox, FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)page, hbox, FALSE, FALSE, 0); gtk_widget_set_sensitive (hbox, FALSE); - gtk_container_add ((GtkContainer *) GNOME_DRUID_PAGE_STANDARD (page)->vbox, box); - gtk_widget_show_all (box); - gnome_druid_append_page (GNOME_DRUID (hook_data->parent), GNOME_DRUID_PAGE (page)); - g_object_set_data ((GObject *)hook_data->parent, "restore", GINT_TO_POINTER (FALSE)); - g_signal_connect (page, "finish", G_CALLBACK (restore_wizard), NULL); + gtk_assistant_append_page (assistant, page); + gtk_assistant_set_page_title (assistant, page, _("Restore from backup")); + gtk_widget_show_all (page); + + g_object_set_data ((GObject *)assistant, "restore", GINT_TO_POINTER (FALSE)); + g_object_set_data ((GObject *)assistant, "restore-config", hook_data->config); + + e_config_add_page_check (hook_data->config, "0.startup_page.10.backup_restore", backup_restore_check, assistant); + return GTK_WIDGET (page); } void backup_restore_commit (EPlugin *ep, EMConfigTargetAccount *target) { - /* Nothing really */ - printf("commit\n"); + GtkWidget *assistant = target->target.config->widget; + gboolean state = GPOINTER_TO_INT (g_object_get_data ((GObject *)assistant, "restore")) ? TRUE : FALSE; + gchar *file = g_object_get_data ((GObject *)assistant, "restore-file"); + + if (state) { + if (!file || !sanity_check (file)) { + e_error_run ((GtkWindow *)assistant, "org.gnome.backup-restore:invalid-backup", NULL); + } else { + restore (file, TRUE); + } + } } void diff --git a/plugins/backup-restore/org-gnome-backup-restore.eplug.xml b/plugins/backup-restore/org-gnome-backup-restore.eplug.xml index 6d92cf48ae..c78b376296 100644 --- a/plugins/backup-restore/org-gnome-backup-restore.eplug.xml +++ b/plugins/backup-restore/org-gnome-backup-restore.eplug.xml @@ -24,7 +24,7 @@ - + -- cgit From 520d90a9cc9fb24551a28116c81ab6b963cac5c9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 28 Aug 2009 08:09:02 -0400 Subject: Build with -Wl,--no-undefined and fix linker errors. --- plugins/backup-restore/Makefile.am | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins/backup-restore') diff --git a/plugins/backup-restore/Makefile.am b/plugins/backup-restore/Makefile.am index bc27b1d7a3..b848d3c51b 100644 --- a/plugins/backup-restore/Makefile.am +++ b/plugins/backup-restore/Makefile.am @@ -21,12 +21,15 @@ plugin_LTLIBRARIES = liborg-gnome-backup-restore.la liborg_gnome_backup_restore_la_SOURCES = backup-restore.c liborg_gnome_backup_restore_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) -liborg_gnome_backup_restore_la_LIBADD = \ - $(top_builddir)/e-util/libeutil.la +liborg_gnome_backup_restore_la_LIBADD = \ + $(SHELL_LIBS) \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/shell/libeshell.la privlibexec_PROGRAMS = evolution-backup evolution_backup_SOURCES = backup.c -evolution_backup_LDADD = $(SHELL_LIBS) \ +evolution_backup_LDADD = \ + $(SHELL_LIBS) \ $(top_builddir)/e-util/libeutil.la if OS_WIN32 -- cgit