[balsa/gtk3] Reuse identical code
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Reuse identical code
- Date: Mon, 19 Dec 2011 02:44:17 +0000 (UTC)
commit a38c003851d4fc640b3f9f048d1e73ff59429a53
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Dec 18 21:43:39 2011 -0500
Reuse identical code
* src/main.c (balsa_check_open_mailboxes),
(scan_mailboxes_idle_cb), (balsa_check_open_compose_window),
(real_main), (handle_remote): reuse identical code.
ChangeLog | 6 +++
src/main.c | 128 ++++++++++++++++++++++++++----------------------------------
2 files changed, 61 insertions(+), 73 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6c161fc..aed6e6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-12-18 Peter Bloomfield
+ * src/main.c (balsa_check_open_mailboxes),
+ (scan_mailboxes_idle_cb), (balsa_check_open_compose_window),
+ (real_main), (handle_remote): reuse identical code.
+
+2011-12-18 Peter Bloomfield
+
* .cvsignore: delete.
* .gitignore: add.
diff --git a/src/main.c b/src/main.c
index 73ffc3f..7c4676f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -359,6 +359,23 @@ balsa_get_stats(long *unread, long *unsent)
} else *unsent = -1;
}
+static void
+balsa_check_open_mailboxes(void)
+{
+ if (cmd_line_open_mailboxes) {
+ gchar *join;
+ gchar **urls;
+
+ join = g_strjoinv(";", cmd_line_open_mailboxes);
+ g_strfreev(cmd_line_open_mailboxes);
+ cmd_line_open_mailboxes = NULL;
+
+ urls = g_strsplit(join, ";", 20);
+ g_free(join);
+ g_idle_add((GSourceFunc) open_mailboxes_idle_cb, urls);
+ }
+}
+
/* scan_mailboxes:
this is an idle handler. Expands subtrees.
*/
@@ -388,18 +405,7 @@ scan_mailboxes_idle_cb()
if (cmd_open_unread_mailbox || balsa_app.open_unread_mailbox)
g_idle_add((GSourceFunc) initial_open_unread_mailboxes, NULL);
- if (cmd_line_open_mailboxes) {
- gchar *join;
- gchar **urls;
-
- join = g_strjoinv(";", cmd_line_open_mailboxes);
- g_strfreev(cmd_line_open_mailboxes);
- cmd_line_open_mailboxes = NULL;
-
- urls = g_strsplit(join, ";", 20);
- g_free(join);
- g_idle_add((GSourceFunc) open_mailboxes_idle_cb, urls);
- }
+ balsa_check_open_mailboxes();
if (balsa_app.remember_open_mboxes)
g_idle_add((GSourceFunc) open_mailboxes_idle_cb, NULL);
@@ -548,6 +554,39 @@ balsa_progress_set_activity(gboolean set, const gchar * text)
gdk_threads_leave();
}
+static gboolean
+balsa_check_open_compose_window(void)
+{
+ if (opt_compose_email || opt_attach_list) {
+ BalsaSendmsg *snd;
+ gchar **attach;
+
+ snd = sendmsg_window_compose();
+ snd->quit_on_close = FALSE;
+
+ if (opt_compose_email) {
+ if (g_ascii_strncasecmp(opt_compose_email, "mailto:", 7) == 0)
+ sendmsg_window_process_url(opt_compose_email + 7,
+ sendmsg_window_set_field, snd);
+ else
+ sendmsg_window_set_field(snd, "to", opt_compose_email);
+ g_free(opt_compose_email);
+ opt_compose_email = NULL;
+ }
+
+ if (opt_attach_list) {
+ for (attach = opt_attach_list; *attach; ++attach)
+ add_attachment(snd, *attach, FALSE, NULL);
+ g_strfreev(opt_attach_list);
+ opt_attach_list = NULL;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/* -------------------------- main --------------------------------- */
static int
real_main(int argc, char *argv[])
@@ -634,28 +673,8 @@ real_main(int argc, char *argv[])
libbalsa_gpgme_check_crypto_engine(GPGME_PROTOCOL_CMS);
#endif /* HAVE_GPGME */
- if (opt_compose_email || opt_attach_list) {
- BalsaSendmsg *snd;
- gchar **attach;
- gdk_threads_enter();
- snd = sendmsg_window_compose();
- gdk_threads_leave();
- if(opt_compose_email) {
- if(g_ascii_strncasecmp(opt_compose_email, "mailto:", 7) == 0)
- sendmsg_window_process_url(opt_compose_email+7,
- sendmsg_window_set_field, snd);
- else sendmsg_window_set_field(snd,"to", opt_compose_email);
- g_free(opt_compose_email);
- opt_compose_email = NULL;
- }
- if (opt_attach_list) {
- for (attach = opt_attach_list; *attach; ++attach)
- add_attachment(snd, *attach, FALSE, NULL);
- g_strfreev(opt_attach_list);
- opt_attach_list = NULL;
- }
- snd->quit_on_close = FALSE;
- }
+ balsa_check_open_compose_window();
+
gtk_widget_show(window);
g_idle_add((GSourceFunc) scan_mailboxes_idle_cb, NULL);
@@ -768,46 +787,9 @@ handle_remote(int argc, char **argv,
if (cmd_open_inbox)
initial_open_inbox();
- if (cmd_line_open_mailboxes) {
- gchar *join;
- gchar **urls;
-
- join = g_strjoinv(";", cmd_line_open_mailboxes);
- g_strfreev(cmd_line_open_mailboxes);
- cmd_line_open_mailboxes = NULL;
-
- urls = g_strsplit(join, ";", 20);
- g_free(join);
- g_idle_add((GSourceFunc) open_mailboxes_idle_cb, urls);
- }
+ balsa_check_open_mailboxes();
- if (opt_compose_email || opt_attach_list) {
- BalsaSendmsg *snd;
- gchar **attach;
-
- snd = sendmsg_window_compose();
-
- if (opt_compose_email) {
- if (g_ascii_strncasecmp(opt_compose_email, "mailto:", 7) ==
- 0)
- sendmsg_window_process_url(opt_compose_email + 7,
- sendmsg_window_set_field,
- snd);
- else
- sendmsg_window_set_field(snd, "to", opt_compose_email);
- g_free(opt_compose_email);
- opt_compose_email = NULL;
- }
-
- if (opt_attach_list) {
- for (attach = opt_attach_list; *attach; ++attach)
- add_attachment(snd, *attach, FALSE, NULL);
- g_strfreev(opt_attach_list);
- opt_attach_list = NULL;
- }
-
- snd->quit_on_close = FALSE;
- } else {
+ if (!balsa_check_open_compose_window()) {
/* Move the main window to the request's screen */
gtk_window_present(GTK_WINDOW(balsa_app.main_window));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]