From 753c60fc67a0a56a5f119c14ffa54ea9af95c208 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 9 Nov 2010 08:48:33 -0500 Subject: Drop backward-compatibility cruft. --- plugins/backup-restore/backup.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index 555eebe2d8..9334de3b20 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -709,9 +709,6 @@ main (gint argc, gchar **argv) GTK_RESPONSE_REJECT, NULL); -#if !GTK_CHECK_VERSION(2,90,7) - g_object_set (progress_dialog, "has-separator", FALSE, NULL); -#endif gtk_container_set_border_width (GTK_CONTAINER (progress_dialog), 12); action_area = gtk_dialog_get_action_area ( -- cgit v1.2.3 From 8a186c3588d3598857c36e2122fa68d01eba30fd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- plugins/backup-restore/backup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index 9334de3b20..aa792169f2 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -560,8 +560,8 @@ static gboolean pbar_update (gpointer data) { if (!complete) { - gtk_progress_bar_pulse ((GtkProgressBar *)pbar); - gtk_progress_bar_set_text ((GtkProgressBar *)pbar, txt); + gtk_progress_bar_pulse ((GtkProgressBar *) pbar); + gtk_progress_bar_set_text ((GtkProgressBar *) pbar, txt); return TRUE; } @@ -589,7 +589,7 @@ idle_cb (gpointer data) { if (gui_arg) { /* Show progress dialog */ - gtk_progress_bar_pulse ((GtkProgressBar *)pbar); + gtk_progress_bar_pulse ((GtkProgressBar *) pbar); g_timeout_add (50, pbar_update, NULL); } -- cgit v1.2.3 From 41337195f36e4795d7976df4e07a11ff336cd89c Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 16 May 2011 16:53:03 -0400 Subject: Bug 650223 - evolution-backup does not terminate without --gui Use g_io_scheduler_push_job() instead of g_thread_create(). When the operation is finished, call gtk_main_quit() from the main thread using g_io_scheduler_job_send_to_mainloop(). Also, check for cancellation with a GCancellable instead of a boolean. Note: We really should be using GLib's process spawning API instead of system(), but that's a job for another day. --- plugins/backup-restore/backup.c | 129 +++++++++++++++++++++++++--------------- 1 file changed, 81 insertions(+), 48 deletions(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index aa792169f2..9b862309ee 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -72,7 +72,6 @@ static gint result = 0; static GtkWidget *progress_dialog; static GtkWidget *pbar; static gchar *txt = NULL; -static gboolean complete = FALSE; static GOptionEntry options[] = { { "backup", '\0', 0, G_OPTION_ARG_NONE, &backup_op, @@ -93,7 +92,6 @@ static GOptionEntry options[] = { #define d(x) #define print_and_run(x) G_STMT_START { g_message ("%s", x); system (x); } G_STMT_END -#define CANCEL(x) if (x) return; static gboolean check (const gchar *filename, gboolean *is_new_format); @@ -277,7 +275,8 @@ write_dir_file (void) } static void -backup (const gchar *filename) +backup (const gchar *filename, + GCancellable *cancellable) { gchar *command; gchar *quotedfname; @@ -285,14 +284,18 @@ backup (const gchar *filename) g_return_if_fail (filename && *filename); quotedfname = g_shell_quote (filename); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Shutting down Evolution"); /* FIXME Will the versioned setting always work? */ run_cmd (EVOLUTION " --quit"); run_cmd ("rm $DATADIR/.running"); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Backing Evolution accounts and settings"); run_cmd ("gconftool-2 --dump " GCONF_DIR " > " EVOLUTION_DIR GCONF_DUMP_FILE); @@ -300,7 +303,9 @@ backup (const gchar *filename) write_dir_file (); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Backing Evolution data (Mails, Contacts, Calendar, Tasks, Memos)"); /* FIXME stay on this file system ,other options?" */ @@ -318,10 +323,10 @@ backup (const gchar *filename) if (restart_arg) { - CANCEL (complete); - txt = _("Restarting Evolution"); - complete=TRUE; + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Restarting Evolution"); run_cmd (EVOLUTION); } @@ -379,7 +384,8 @@ get_dir_level (const gchar *dir) } static void -restore (const gchar *filename) +restore (const gchar *filename, + GCancellable *cancellable) { gchar *command; gchar *quotedfname; @@ -394,18 +400,24 @@ restore (const gchar *filename) quotedfname = g_shell_quote (filename); + if (g_cancellable_is_cancelled (cancellable)) + return; + /* FIXME Will the versioned setting always work? */ - CANCEL (complete); txt = _("Shutting down Evolution"); run_cmd (EVOLUTION " --quit"); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Back up current Evolution data"); run_cmd ("mv $DATADIR $DATADIR_old"); run_cmd ("mv $CONFIGDIR $CONFIGDIR_old"); run_cmd ("mv $HOME/.camel_certs $HOME/.camel_certs_old"); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Extracting files from back up"); if (is_new_format) { @@ -462,7 +474,9 @@ restore (const gchar *filename) g_free (quotedfname); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Loading Evolution settings"); if (is_new_format) { @@ -477,7 +491,9 @@ restore (const gchar *filename) run_cmd ("rm " "$HOME/.evolution/" GCONF_DUMP_FILE); } - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Removing temporary back up files"); run_cmd ("rm -rf $DATADIR_old"); run_cmd ("rm -rf $CONFIGDIR_old"); @@ -487,14 +503,17 @@ restore (const gchar *filename) if (!is_new_format) run_cmd ("rm -rf $HOME/.evolution_old"); - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Ensuring local sources"); end: if (restart_arg) { - CANCEL (complete); + if (g_cancellable_is_cancelled (cancellable)) + return; + txt = _("Restarting Evolution"); - complete=TRUE; run_cmd (EVOLUTION); } } @@ -557,52 +576,48 @@ check (const gchar *filename, gboolean *is_new_format) } static gboolean -pbar_update (gpointer data) +pbar_update (GCancellable *cancellable) { - if (!complete) { - gtk_progress_bar_pulse ((GtkProgressBar *) pbar); - gtk_progress_bar_set_text ((GtkProgressBar *) pbar, txt); - return TRUE; - } + gtk_progress_bar_pulse ((GtkProgressBar *) pbar); + gtk_progress_bar_set_text ((GtkProgressBar *) pbar, txt); - gtk_main_quit (); - return FALSE; + /* Return TRUE to reschedule the timeout. */ + return !g_cancellable_is_cancelled (cancellable); } -static gpointer -thread_start (gpointer data) +static gboolean +finish_job (gpointer user_data) { - if (backup_op) - backup (bk_file); - else if (restore_op) - restore (res_file); - else if (check_op) - check (chk_file, NULL); - - complete = TRUE; + gtk_main_quit (); - return GINT_TO_POINTER (result); + return FALSE; } static gboolean -idle_cb (gpointer data) +start_job (GIOSchedulerJob *job, + GCancellable *cancellable, + gpointer user_data) { - if (gui_arg) { - /* Show progress dialog */ - gtk_progress_bar_pulse ((GtkProgressBar *) pbar); - g_timeout_add (50, pbar_update, NULL); - } + if (backup_op) + backup (bk_file, cancellable); + else if (restore_op) + restore (res_file, cancellable); + else if (check_op) + check (chk_file, NULL); /* not cancellable */ - g_thread_create (thread_start, NULL, FALSE, NULL); + g_io_scheduler_job_send_to_mainloop_async ( + job, finish_job, NULL, (GDestroyNotify) NULL); return FALSE; } static void -dlg_response (GtkWidget *dlg, gint response, gpointer data) +dlg_response (GtkWidget *dlg, + gint response, + GCancellable *cancellable) { /* We will cancel only backup/restore operations and not the check operation */ - complete = TRUE; + g_cancellable_cancel (cancellable); /* If the response is not of delete_event then destroy the event */ if (response != GTK_RESPONSE_NONE) @@ -632,6 +647,7 @@ dlg_response (GtkWidget *dlg, gint response, gpointer data) gint main (gint argc, gchar **argv) { + GCancellable *cancellable; gchar *file = NULL, *oper = NULL; gint i; GError *error = NULL; @@ -691,6 +707,8 @@ main (gint argc, gchar **argv) } } + cancellable = g_cancellable_new (); + if (gui_arg && !check_op) { GtkWidget *widget, *container; GtkWidget *action_area; @@ -789,7 +807,9 @@ main (gint argc, gchar **argv) gtk_table_attach (GTK_TABLE (container), pbar, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_window_set_default_size ((GtkWindow *) progress_dialog, 450, 120); - g_signal_connect (progress_dialog, "response", G_CALLBACK(dlg_response), NULL); + g_signal_connect ( + progress_dialog, "response", + G_CALLBACK (dlg_response), cancellable); gtk_widget_show_all (progress_dialog); } else if (check_op) { /* For sanity we don't need gui */ @@ -797,8 +817,21 @@ main (gint argc, gchar **argv) exit (result == 0 ? 0 : 1); } - g_idle_add (idle_cb, NULL); + if (gui_arg) + g_timeout_add_full ( + G_PRIORITY_DEFAULT, 50, + (GSourceFunc) pbar_update, + g_object_ref (cancellable), + (GDestroyNotify) g_object_unref); + + g_io_scheduler_push_job ( + start_job, NULL, + (GDestroyNotify) NULL, + G_PRIORITY_DEFAULT, cancellable); + gtk_main (); + g_object_unref (cancellable); + return result; } -- cgit v1.2.3 From 394e580dfdb04342c2e457ced400908e4dd5c88e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 28 May 2011 10:18:56 -0400 Subject: Including directly is rarely needed. --- plugins/backup-restore/backup.c | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index 9b862309ee..928998f585 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From 92918048787abb85749313147e06724426662b00 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 17 Jun 2011 12:23:00 +0200 Subject: Bug #650223 - Do not wait on evolution's exit when done with backup/restore --- plugins/backup-restore/backup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index 928998f585..f813b2ca55 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -247,6 +247,12 @@ run_cmd (const gchar *cmd) print_and_run (cmd); } +static void +run_evolution_no_wait (void) +{ + g_spawn_command_line_async (EVOLUTION, NULL); +} + static void write_dir_file (void) { @@ -326,7 +332,7 @@ backup (const gchar *filename, return; txt = _("Restarting Evolution"); - run_cmd (EVOLUTION); + run_evolution_no_wait (); } } @@ -513,7 +519,7 @@ restore (const gchar *filename, return; txt = _("Restarting Evolution"); - run_cmd (EVOLUTION); + run_evolution_no_wait (); } } -- cgit v1.2.3 From fcbbdfbd18e15b4ee8322a0217cf03a689a5e033 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- plugins/backup-restore/backup.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index f813b2ca55..370608ac2a 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -95,7 +95,9 @@ static GOptionEntry options[] = { static gboolean check (const gchar *filename, gboolean *is_new_format); static GString * -replace_string (const gchar *text, const gchar *find, const gchar *replace) +replace_string (const gchar *text, + const gchar *find, + const gchar *replace) { const gchar *p, *next; GString *str; @@ -183,7 +185,9 @@ replace_variables (const gchar *str) } static void -replace_in_file (const gchar *filename, const gchar *find, const gchar *replace) +replace_in_file (const gchar *filename, + const gchar *find, + const gchar *replace) { gchar *content = NULL; GError *error = NULL; @@ -338,7 +342,9 @@ backup (const gchar *filename, } static void -extract_backup_dirs (const gchar *filename, gchar **data_dir, gchar **config_dir) +extract_backup_dirs (const gchar *filename, + gchar **data_dir, + gchar **config_dir) { GKeyFile *key_file; GError *error = NULL; @@ -524,7 +530,8 @@ restore (const gchar *filename, } static gboolean -check (const gchar *filename, gboolean *is_new_format) +check (const gchar *filename, + gboolean *is_new_format) { gchar *command; gchar *quotedfname; @@ -650,7 +657,8 @@ dlg_response (GtkWidget *dlg, } gint -main (gint argc, gchar **argv) +main (gint argc, + gchar **argv) { GCancellable *cancellable; gchar *file = NULL, *oper = NULL; @@ -674,7 +682,7 @@ main (gint argc, gchar **argv) p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy"); if (p_SetProcessDEPPolicy) - (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); + (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); } #endif #endif @@ -770,7 +778,7 @@ main (gint argc, gchar **argv) txt2 = _("Please wait while Evolution is restoring your data."); } else { /* do not translate these two, it's just a fallback when something goes wrong, - we should never get here anyway. */ + * we should never get here anyway. */ txt = "Oops, doing nothing..."; txt2 = "Should not be here now, really..."; } -- cgit v1.2.3 From 6b1663a63d6d49fa9a74420a61c126a3f7ab390a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 30 Sep 2011 10:19:39 -0400 Subject: backup-restore cleanups. --- plugins/backup-restore/backup.c | 181 ++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 61 deletions(-) (limited to 'plugins/backup-restore/backup.c') diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index 370608ac2a..a234a9cf7f 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -90,7 +90,8 @@ static GOptionEntry options[] = { #define d(x) -#define print_and_run(x) G_STMT_START { g_message ("%s", x); system (x); } G_STMT_END +#define print_and_run(x) \ + G_STMT_START { g_message ("%s", x); system (x); } G_STMT_END static gboolean check (const gchar *filename, gboolean *is_new_format); @@ -308,7 +309,9 @@ backup (const gchar *filename, txt = _("Backing Evolution accounts and settings"); run_cmd ("gconftool-2 --dump " GCONF_DIR " > " EVOLUTION_DIR GCONF_DUMP_FILE); - replace_in_file (EVOLUTION_DIR GCONF_DUMP_FILE, e_get_user_data_dir (), EVOUSERDATADIR_MAGIC); + replace_in_file ( + EVOLUTION_DIR GCONF_DUMP_FILE, + e_get_user_data_dir (), EVOUSERDATADIR_MAGIC); write_dir_file (); @@ -321,7 +324,10 @@ backup (const gchar *filename, /* FIXME compression type?" */ /* FIXME date/time stamp?" */ /* FIXME backup location?" */ - command = g_strdup_printf ("cd $HOME && tar chf - $STRIPDATADIR $STRIPCONFIGDIR .camel_certs " EVOLUTION_DIR_FILE " | gzip > %s", quotedfname); + command = g_strdup_printf ( + "cd $HOME && tar chf - $STRIPDATADIR " + "$STRIPCONFIGDIR .camel_certs " EVOLUTION_DIR_FILE " | " + "gzip > %s", quotedfname); run_cmd (command); g_free (command); g_free (quotedfname); @@ -435,7 +441,9 @@ restore (const gchar *filename, GString *dir_fn; gchar *data_dir = NULL, *config_dir = NULL; - command = g_strdup_printf ("cd $TMP && tar xzf %s " EVOLUTION_DIR_FILE, quotedfname); + command = g_strdup_printf ( + "cd $TMP && tar xzf %s " + EVOLUTION_DIR_FILE, quotedfname); run_cmd (command); g_free (command); @@ -461,15 +469,20 @@ restore (const gchar *filename, g_mkdir_with_parents (e_get_user_data_dir (), 0700); g_mkdir_with_parents (e_get_user_config_dir (), 0700); - command = g_strdup_printf ("cd $DATADIR && tar xzf %s %s --strip-components=%d", quotedfname, data_dir, get_dir_level (data_dir)); + command = g_strdup_printf ( + "cd $DATADIR && tar xzf %s %s --strip-components=%d", + quotedfname, data_dir, get_dir_level (data_dir)); run_cmd (command); g_free (command); - command = g_strdup_printf ("cd $CONFIGDIR && tar xzf %s %s --strip-components=%d", quotedfname, config_dir, get_dir_level (config_dir)); + command = g_strdup_printf ( + "cd $CONFIGDIR && tar xzf %s %s --strip-components=%d", + quotedfname, config_dir, get_dir_level (config_dir)); run_cmd (command); g_free (command); - command = g_strdup_printf ("cd $HOME && tar xzf %s .camel_certs", quotedfname); + command = g_strdup_printf ( + "cd $HOME && tar xzf %s .camel_certs", quotedfname); run_cmd (command); g_free (command); @@ -478,7 +491,8 @@ restore (const gchar *filename, } else { run_cmd ("mv $HOME/.evolution $HOME/.evolution_old"); - command = g_strdup_printf ("cd $HOME && gzip -cd %s | tar xf -", quotedfname); + command = g_strdup_printf ( + "cd $HOME && gzip -cd %s | tar xf -", quotedfname); run_cmd (command); g_free (command); } @@ -492,14 +506,33 @@ restore (const gchar *filename, if (is_new_format) { /* new format has it in DATADIR... */ - replace_in_file (EVOLUTION_DIR GCONF_DUMP_FILE, EVOUSERDATADIR_MAGIC, e_get_user_data_dir ()); + replace_in_file ( + EVOLUTION_DIR GCONF_DUMP_FILE, + EVOUSERDATADIR_MAGIC, e_get_user_data_dir ()); run_cmd ("gconftool-2 --load " EVOLUTION_DIR GCONF_DUMP_FILE); run_cmd ("rm " EVOLUTION_DIR GCONF_DUMP_FILE); } else { + gchar *gconf_dump_file; + /* ... old format in ~/.evolution */ - replace_in_file ("$HOME/.evolution/" GCONF_DUMP_FILE, EVOUSERDATADIR_MAGIC, e_get_user_data_dir ()); - run_cmd ("gconftool-2 --load " "$HOME/.evolution/" GCONF_DUMP_FILE); - run_cmd ("rm " "$HOME/.evolution/" GCONF_DUMP_FILE); + gconf_dump_file = g_build_filename ( + "$HOME", ".evolution", GCONF_DUMP_FILE, NULL); + + replace_in_file ( + gconf_dump_file, + EVOUSERDATADIR_MAGIC, + e_get_user_data_dir ()); + + command = g_strconcat ( + "gconftool-2 --load ", gconf_dump_file, NULL); + run_cmd (command); + g_free (command); + + command = g_strconcat ("rm ", gconf_dump_file, NULL); + run_cmd (command); + g_free (command); + + g_free (gconf_dump_file); } if (g_cancellable_is_cancelled (cancellable)) @@ -519,7 +552,7 @@ restore (const gchar *filename, txt = _("Ensuring local sources"); - end: +end: if (restart_arg) { if (g_cancellable_is_cancelled (cancellable)) return; @@ -662,7 +695,8 @@ main (gint argc, { GCancellable *cancellable; gchar *file = NULL, *oper = NULL; - gint i; + const gchar *title = NULL; + gint ii; GError *error = NULL; #ifdef G_OS_WIN32 @@ -671,18 +705,26 @@ main (gint argc, typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName); t_SetDllDirectoryA p_SetDllDirectoryA; - p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetDllDirectoryA"); - if (p_SetDllDirectoryA) - (*p_SetDllDirectoryA) (""); + p_SetDllDirectoryA = GetProcAddress ( + GetModuleHandle ("kernel32.dll"), + "SetDllDirectoryA"); + + if (p_SetDllDirectoryA != NULL) + p_SetDllDirectoryA (""); } #ifndef _WIN64 { typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags); t_SetProcessDEPPolicy p_SetProcessDEPPolicy; - p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy"); + p_SetProcessDEPPolicy = GetProcAddress ( + GetModuleHandle ("kernel32.dll"), + "SetProcessDEPPolicy"); + if (p_SetProcessDEPPolicy) - (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); + p_SetProcessDEPPolicy ( + PROCESS_DEP_ENABLE | + PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); } #endif #endif @@ -691,31 +733,32 @@ main (gint argc, bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - g_thread_init (NULL); - gtk_init_with_args ( - &argc, &argv, NULL, options, (gchar *) GETTEXT_PACKAGE, &error); + &argc, &argv, NULL, options, GETTEXT_PACKAGE, &error); + if (error != NULL) { g_printerr ("%s\n", error->message); g_error_free (error); - exit (1); + exit (EXIT_FAILURE); } - if (opt_remaining) { - for (i = 0; i < g_strv_length (opt_remaining); i++) { + if (opt_remaining != NULL) { + for (ii = 0; ii < g_strv_length (opt_remaining); ii++) { if (backup_op) { + title = _("Evolution Back Up"); oper = _("Backing up to the folder %s"); - d(g_message ("Backing up to the folder %s", (gchar *) opt_remaining[i])); - bk_file = g_strdup ((gchar *) opt_remaining[i]); + d(g_message ("Backing up to the folder %s", (gchar *) opt_remaining[ii])); + bk_file = g_strdup ((gchar *) opt_remaining[ii]); file = bk_file; } else if (restore_op) { + title = _("Evolution Restore"); oper = _("Restoring from the folder %s"); - d(g_message ("Restoring from the folder %s", (gchar *) opt_remaining[i])); - res_file = g_strdup ((gchar *) opt_remaining[i]); + d(g_message ("Restoring from the folder %s", (gchar *) opt_remaining[ii])); + res_file = g_strdup ((gchar *) opt_remaining[ii]); file = res_file; } else if (check_op) { - d(g_message ("Checking %s", (gchar *) opt_remaining[i])); - chk_file = g_strdup ((gchar *) opt_remaining[i]); + d(g_message ("Checking %s", (gchar *) opt_remaining[ii])); + chk_file = g_strdup ((gchar *) opt_remaining[ii]); } } } @@ -732,15 +775,19 @@ main (gint argc, gtk_window_set_default_icon_name ("evolution"); - /* Backup / Restore only can have GUI. We should restrict the rest */ - progress_dialog = gtk_dialog_new_with_buttons (backup_op ? _("Evolution Back up"): _("Evolution Restore"), - NULL, - GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, - NULL); + /* Backup / Restore only can have GUI. + * We should restrict the rest. */ + progress_dialog = gtk_dialog_new_with_buttons ( + title, NULL, + GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + NULL); - gtk_container_set_border_width (GTK_CONTAINER (progress_dialog), 12); + gtk_container_set_border_width ( + GTK_CONTAINER (progress_dialog), 12); + gtk_window_set_default_size ( + GTK_WINDOW (progress_dialog), 450, 120); action_area = gtk_dialog_get_action_area ( GTK_DIALOG (progress_dialog)); @@ -764,11 +811,14 @@ main (gint argc, gtk_box_pack_start ( GTK_BOX (content_area), container, FALSE, TRUE, 0); - widget = gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_DIALOG); + widget = gtk_image_new_from_stock ( + GTK_STOCK_COPY, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (container), widget, 0, 1, 0, 3, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach ( + GTK_TABLE (container), widget, 0, 1, 0, 3, + GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); if (backup_op) { txt = _("Backing up Evolution Data"); @@ -777,53 +827,62 @@ main (gint argc, txt = _("Restoring Evolution Data"); txt2 = _("Please wait while Evolution is restoring your data."); } else { - /* do not translate these two, it's just a fallback when something goes wrong, - * we should never get here anyway. */ - txt = "Oops, doing nothing..."; - txt2 = "Should not be here now, really..."; + g_return_val_if_reached (EXIT_FAILURE); } - markup = g_strconcat ("", txt, "", NULL); - widget = gtk_label_new (NULL); + markup = g_markup_printf_escaped ("%s", txt); + widget = gtk_label_new (markup); gtk_label_set_line_wrap (GTK_LABEL (widget), FALSE); - gtk_label_set_markup (GTK_LABEL (widget), markup); + gtk_label_set_use_markup (GTK_LABEL (widget), TRUE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0); gtk_widget_show (widget); g_free (markup); - gtk_table_attach (GTK_TABLE (container), widget, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach ( + GTK_TABLE (container), widget, 1, 2, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - markup = g_strconcat (txt2, " ", _("This may take a while depending on the amount of data in your account."), NULL); - widget = gtk_label_new (NULL); + markup = g_strconcat ( + txt2, " ", _("This may take a while depending " + "on the amount of data in your account."), NULL); + widget = gtk_label_new (markup); gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); - gtk_label_set_markup (GTK_LABEL (widget), markup); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); gtk_widget_show (widget); g_free (markup); - gtk_table_attach (GTK_TABLE (container), widget, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach ( + GTK_TABLE (container), widget, 1, 2, 1, 2, + GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); pbar = gtk_progress_bar_new (); - if (str) { - markup = g_strconcat ("", str, "", NULL); - widget = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (widget), markup); + if (str != NULL) { + markup = g_markup_printf_escaped ("%s", str); + widget = gtk_label_new (markup); + gtk_label_set_use_markup (GTK_LABEL (widget), TRUE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_free (markup); g_free (str); - gtk_table_attach (GTK_TABLE (container), widget, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + + gtk_table_attach ( + GTK_TABLE (container), widget, 1, 2, 2, 3, + GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_table_set_row_spacing (GTK_TABLE (container), 2, 6); - gtk_table_attach (GTK_TABLE (container), pbar, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach ( + GTK_TABLE (container), pbar, 1, 2, 3, 4, + GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); } else - gtk_table_attach (GTK_TABLE (container), pbar, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach ( + GTK_TABLE (container), pbar, 1, 2, 2, 3, + GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_window_set_default_size ((GtkWindow *) progress_dialog, 450, 120); g_signal_connect ( progress_dialog, "response", G_CALLBACK (dlg_response), cancellable); gtk_widget_show_all (progress_dialog); + } else if (check_op) { /* For sanity we don't need gui */ check (chk_file, NULL); -- cgit v1.2.3