2006-04-10 [colin] 2.1.0cvs26

* src/main.c
	* src/mainwindow.c
	* src/mainwindow.h
		Implement --select
This commit is contained in:
Colin Leroy 2006-04-10 16:51:13 +00:00
parent 86f79ed425
commit 7c12a97b46
6 changed files with 79 additions and 1 deletions

View file

@ -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

View file

@ -1397,3 +1397,4 @@
( 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

View file

@ -11,7 +11,7 @@ MINOR_VERSION=1
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_VERSION=25
EXTRA_VERSION=26
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=

View file

@ -141,6 +141,7 @@ static struct RemoteCmd {
gboolean exit;
gboolean subscribe;
const gchar *subscribe_uri;
const gchar *target;
} cmd;
static void parse_cmd_opt(int argc, char *argv[]);
@ -574,6 +575,10 @@ int main(int argc, char *argv[])
send_queue();
}
if (cmd.target) {
mainwindow_jump_to(cmd.target);
}
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", _(" --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"));
@ -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;
} 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], "://")) {
@ -1051,6 +1060,10 @@ static gint prohibit_duplicate_launch(void)
}
} 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);
@ -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);
} 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);
}

View file

@ -3535,3 +3535,56 @@ void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
{
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);
}

View file

@ -207,4 +207,5 @@ gboolean mainwindow_key_pressed (GtkWidget *widget,
MainWindow *mainwindow_get_mainwindow (void);
void mainwindow_learn (MainWindow *mainwin,
gboolean is_spam);
void mainwindow_jump_to (const gchar *target);
#endif /* __MAINWINDOW_H__ */