2006-04-10 [colin] 2.1.0cvs26
authorColin Leroy <colin@colino.net>
Mon, 10 Apr 2006 16:51:13 +0000 (16:51 +0000)
committerColin Leroy <colin@colino.net>
Mon, 10 Apr 2006 16:51:13 +0000 (16:51 +0000)
* src/main.c
* src/mainwindow.c
* src/mainwindow.h
Implement --select

ChangeLog
PATCHSETS
configure.ac
src/main.c
src/mainwindow.c
src/mainwindow.h

index 8859e81f31b00cc1b8e50144d6c26733e376170e..f519ae67e0a4df4ea1900b001019bb0dac562556 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-10 [colin]     2.1.0cvs26
+
+       * src/main.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+               Implement --select
+
 2006-04-10 [colin]     2.1.0cvs25
 
        * manual/plugins.xml
 2006-04-10 [colin]     2.1.0cvs25
 
        * manual/plugins.xml
index 45f875be4ab0c1e0e0d75c1439254856785a85ec..d8c65392cde63356bb15611f97f8fd1ea8979cc2 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.100.2.37 -r 1.100.2.38 AUTHORS;  cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/gtk/authors.h;  ) > 2.1.0cvs23.patchset
 ( cvs diff -u -r 1.204.2.81 -r 1.204.2.82 src/prefs_common.c;  ) > 2.1.0cvs24.patchset
 ( cvs diff -u -r 1.1.2.8 -r 1.1.2.9 manual/plugins.xml;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 manual/fr/plugins.xml;  ) > 2.1.0cvs25.patchset
 ( cvs diff -u -r 1.100.2.37 -r 1.100.2.38 AUTHORS;  cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/gtk/authors.h;  ) > 2.1.0cvs23.patchset
 ( cvs diff -u -r 1.204.2.81 -r 1.204.2.82 src/prefs_common.c;  ) > 2.1.0cvs24.patchset
 ( cvs diff -u -r 1.1.2.8 -r 1.1.2.9 manual/plugins.xml;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 manual/fr/plugins.xml;  ) > 2.1.0cvs25.patchset
+( cvs diff -u -r 1.115.2.78 -r 1.115.2.79 src/main.c;  cvs diff -u -r 1.274.2.106 -r 1.274.2.107 src/mainwindow.c;  cvs diff -u -r 1.39.2.15 -r 1.39.2.16 src/mainwindow.h;  ) > 2.1.0cvs26.patchset
index 551cafcff40438418d8f048bd67e17d4bde63d21..fbb2184f046eca2d41e9f4c20a9e6fcadcc01e51 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=1
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=25
+EXTRA_VERSION=26
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index ed2f3e9e82ff5cd0936b42ea1a8261e98dc953a2..8c009ec07e8a343eb2f1f0573f89de0db28c5090 100644 (file)
@@ -141,6 +141,7 @@ static struct RemoteCmd {
        gboolean exit;
        gboolean subscribe;
        const gchar *subscribe_uri;
        gboolean exit;
        gboolean subscribe;
        const gchar *subscribe_uri;
+       const gchar *target;
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
@@ -574,6 +575,10 @@ int main(int argc, char *argv[])
                send_queue();
        }
        
                send_queue();
        }
        
+       if (cmd.target) {
+               mainwindow_jump_to(cmd.target);
+       }
+
        gtk_main();
 
        exit_sylpheed(mainwin);
        gtk_main();
 
        exit_sylpheed(mainwin);
@@ -764,6 +769,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                        g_print("%s\n", _("  --status [folder]...   show the total number of messages"));
                        g_print("%s\n", _("  --status-full [folder]...\n"
                               "                         show the status of each folder"));
                        g_print("%s\n", _("  --status [folder]...   show the total number of messages"));
                        g_print("%s\n", _("  --status-full [folder]...\n"
                               "                         show the status of each folder"));
+                       g_print("%s\n", _("  --select folder[/msg]  jumps to the specified folder/message\n" 
+                                         "                         folder is a folder id like '#mh/Mailbox/inbox'"));
                        g_print("%s\n", _("  --online               switch to online mode"));
                        g_print("%s\n", _("  --offline              switch to offline mode"));
                        g_print("%s\n", _("  --exit                 exit Sylpheed-Claws"));
                        g_print("%s\n", _("  --online               switch to online mode"));
                        g_print("%s\n", _("  --offline              switch to offline mode"));
                        g_print("%s\n", _("  --exit                 exit Sylpheed-Claws"));
@@ -783,6 +790,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                        exit(0);
                } else if (!strncmp(argv[i], "--exit", 6)) {
                        cmd.exit = TRUE;
                        exit(0);
                } else if (!strncmp(argv[i], "--exit", 6)) {
                        cmd.exit = TRUE;
+               } else if (!strncmp(argv[i], "--select", 8) && i+1 < argc) {
+                       cmd.target = argv[i+1];
                } else if (i == 1 && argc == 2) {
                        /* only one parameter. Do something intelligent about it */
                        if (strstr(argv[i], "@") && !strstr(argv[i], "://")) {
                } else if (i == 1 && argc == 2) {
                        /* only one parameter. Do something intelligent about it */
                        if (strstr(argv[i], "@") && !strstr(argv[i], "://")) {
@@ -1051,6 +1060,10 @@ static gint prohibit_duplicate_launch(void)
                }
        } else if (cmd.exit) {
                fd_write_all(uxsock, "exit\n", 5);
                }
        } else if (cmd.exit) {
                fd_write_all(uxsock, "exit\n", 5);
+       } else if (cmd.target) {
+               gchar *str = g_strdup_printf("select %s\n", cmd.target);
+               fd_write_all(uxsock, str, strlen(str));
+               g_free(str);
        } else
                fd_write_all(uxsock, "popup\n", 6);
 
        } else
                fd_write_all(uxsock, "popup\n", 6);
 
@@ -1162,6 +1175,9 @@ static void lock_socket_input_cb(gpointer data,
                fd_write_all(sock, ".\n", 2);
                g_free(status);
                if (folders) g_ptr_array_free(folders, TRUE);
                fd_write_all(sock, ".\n", 2);
                g_free(status);
                if (folders) g_ptr_array_free(folders, TRUE);
+       } else if (!strncmp(buf, "select ", 7)) {
+               const gchar *target = buf+7;
+               mainwindow_jump_to(target);
        } else if (!strncmp(buf, "exit", 4)) {
                app_will_exit(NULL, mainwin);
        }
        } else if (!strncmp(buf, "exit", 4)) {
                app_will_exit(NULL, mainwin);
        }
index 136452e2a6355149dfcccf6487e0f393f5efad22..8373c7433b2b292f1699e68078d6747d77cb4636 100644 (file)
@@ -3535,3 +3535,56 @@ void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
 {
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
 }
 {
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
 }
+
+void mainwindow_jump_to(const gchar *target)
+{
+       gchar *tmp = NULL;
+       gchar *p = NULL;
+       FolderItem *item = NULL;
+       gchar *msg = NULL;
+       MainWindow *mainwin = mainwindow_get_mainwindow();
+       
+       if (!target)
+               return;
+               
+       if (!mainwin) {
+               printf(_("not initialized\n"));
+               return;
+       }
+
+       tmp = g_strdup(target);
+       
+       if ((p = strstr(tmp, "\r")) != NULL)
+               *p = '\0';
+       if ((p = strstr(tmp, "\n")) != NULL)
+               *p = '\0';
+
+       if ((item = folder_find_item_from_identifier(tmp))) {
+               printf(_("selecting folder '%s'\n"), tmp);
+               folderview_select(mainwin->folderview, item);
+               main_window_popup(mainwin);
+               g_free(tmp);
+               return;
+       }
+       
+       msg = strrchr(tmp, G_DIR_SEPARATOR);
+       if (msg) {
+               *msg++ = '\0';
+               if ((item = folder_find_item_from_identifier(tmp))) {
+                       printf(_("selecting folder '%s'\n"), tmp);
+                       folderview_select(mainwin->folderview, item);
+               } 
+               if (item && msg && atoi(msg)) {
+                       printf(_("selecting message %d\n"), atoi(msg));
+                       summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
+                       summary_display_msg_selected(mainwin->summaryview, FALSE);
+                       main_window_popup(mainwin);
+                       g_free(tmp);
+                       return;
+               } 
+       }
+       
+       printf("'%s' not found\n", tmp);
+       
+       g_free(tmp);
+}
index 1341d5058fd542b8331130fbdd4eb75ead814a0a..552afa5504682b4a1aba6ed1d7950e4bc224a7f8 100644 (file)
@@ -207,4 +207,5 @@ gboolean mainwindow_key_pressed                   (GtkWidget         *widget,
 MainWindow *mainwindow_get_mainwindow        (void);
 void mainwindow_learn                        (MainWindow *mainwin,
                                               gboolean is_spam);
 MainWindow *mainwindow_get_mainwindow        (void);
 void mainwindow_learn                        (MainWindow *mainwin,
                                               gboolean is_spam);
+void mainwindow_jump_to                              (const gchar       *target);
 #endif /* __MAINWINDOW_H__ */
 #endif /* __MAINWINDOW_H__ */