add --(on|off)line switches
authorColin Leroy <colin@colino.net>
Wed, 16 Oct 2002 08:12:34 +0000 (08:12 +0000)
committerColin Leroy <colin@colino.net>
Wed, 16 Oct 2002 08:12:34 +0000 (08:12 +0000)
ChangeLog.claws
configure.in
src/main.c
src/mainwindow.c
src/mainwindow.h

index e9b8287a5f4788415a9bd8fa16997b39b72d45f5..9452d8536eb91a93596b4c6356bc491871687f0d 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-15 [colin]     0.8.5claws39
+
+       * src/main.c
+         src/mainwindow.[ch]
+               Added --online and --offline command-line
+               switches
+
 2002-10-15 [christoph] 0.8.5claws38
 
        * src/procmime.c
index 71bbf906823dbf5eea42a42a3daaa712d2816406..976b4edf7e8bed554e13351fccd0faacbec074a3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws38
+EXTRA_VERSION=claws39
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index d2430b7728cbd5ef5b4289d705e40fcc0e00cea1..c17a3dc6e81ff7a440c0508d4c46b11bd89fef05 100644 (file)
@@ -103,6 +103,8 @@ static struct Cmd {
        gboolean status;
        gboolean send;
        gboolean crash;
+       gboolean online;
+       gboolean offline;
        gchar   *crash_params;
 } cmd;
 
@@ -356,6 +358,11 @@ int main(int argc, char *argv[])
        if (cmd.send)
                send_queue();
 
+       if (cmd.offline)
+               main_window_toggle_work_offline(mainwin, TRUE);
+       if (cmd.online)
+               main_window_toggle_work_offline(mainwin, FALSE);
+       
        gtk_main();
 
        addressbook_destroy();
@@ -414,6 +421,10 @@ static void parse_cmd_opt(int argc, char *argv[])
                        exit(0);
                } else if (!strncmp(argv[i], "--status", 8)) {
                        cmd.status = TRUE;
+               } else if (!strncmp(argv[i], "--online", 8)) {
+                       cmd.online = TRUE;
+               } else if (!strncmp(argv[i], "--offline", 9)) {
+                       cmd.offline = TRUE;
                } else if (!strncmp(argv[i], "--help", 6)) {
                        g_print(_("Usage: %s [OPTION]...\n"),
                                g_basename(argv[0]));
@@ -426,6 +437,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                        puts(_("  --receive-all          receive new messages of all accounts"));
                        puts(_("  --send                 send all queued messages"));
                        puts(_("  --status               show the total number of messages"));
+                       puts(_("  --online               switch to online mode"));
+                       puts(_("  --offline              switch to offline mode"));
                        puts(_("  --debug                debug mode"));
                        puts(_("  --help                 display this help and exit"));
                        puts(_("  --version              output version information and exit"));
@@ -653,6 +666,10 @@ static gint prohibit_duplicate_launch(void)
                g_free(compose_str);
        } else if (cmd.send) {
                fd_write(uxsock, "send\n", 5);
+       } else if (cmd.online) {
+               fd_write(uxsock, "online\n", 6);
+       } else if (cmd.offline) {
+               fd_write(uxsock, "offline\n", 7);
        } else if (cmd.status) {
                gchar buf[BUFFSIZE];
 
@@ -704,6 +721,10 @@ static void lock_socket_input_cb(gpointer data,
                open_compose_new(buf + strlen("compose") + 1, NULL);
        } else if (!strncmp(buf, "send", 4)) {
                send_queue();
+       } else if (!strncmp(buf, "online", 6)) {
+               main_window_toggle_work_offline(mainwin, FALSE);
+       } else if (!strncmp(buf, "offline", 7)) {
+               main_window_toggle_work_offline(mainwin, TRUE);
        } else if (!strncmp(buf, "status", 6)) {
                guint new, unread, total;
 
index d36245b387f379836384b209f02e8c05e5c86ce0..d1ae3bb014b9300c8ebbead560b2d8d5eca70632 100644 (file)
@@ -2993,13 +2993,17 @@ static void separate_widget_cb(MainWindow *mainwin, guint action,
        prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
 }
 
-static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
 {
-       if (GTK_CHECK_MENU_ITEM(widget)->active) {
+       if (offline)
                online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
-       } else {
-               online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);           
-       }
+       else
+               online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
+}
+
+static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
+{
+       main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
 }
 
 static void online_switch_clicked (GtkButton *btn, gpointer data) 
index 7bc9e890790a235ef1c6a75a025d8842ef3e7b99..4ee07fd7b5a666663af0b6e7f119014cdd8346fd 100644 (file)
@@ -220,4 +220,8 @@ void toolbar_set_sensitive                    (MainWindow *mainwin);
 void toolbar_set_compose_button               (MainToolbar        *toolbar, 
                                               ComposeButtonType  compose_btn_type);
 void main_window_destroy_all                  (void);
+
+void main_window_toggle_work_offline          (MainWindow        *mainwin, 
+                                               gboolean           offline);
+
 #endif /* __MAINWINDOW_H__ */