0.8.8claws58
authorChristoph Hohmann <reboot@gmx.ch>
Mon, 6 Jan 2003 21:16:17 +0000 (21:16 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Mon, 6 Jan 2003 21:16:17 +0000 (21:16 +0000)
* src/quote_fmt.c
* src/summaryview.[ch]
* src/gtk/Makefile.am
* src/gtk/description_window.[ch]       ** NEW **
        use a generic window to display syntax descriptions
        currently used in quote_fmt and summaryview (new description
        for extended quick search)

patch by Ivan Francolin Martinez (ivanfm@users.sourceforge.net)

ChangeLog.claws
configure.in
src/gtk/Makefile.am
src/gtk/description_window.c [new file with mode: 0644]
src/gtk/description_window.h [new file with mode: 0644]
src/quote_fmt.c
src/summaryview.c
src/summaryview.h

index 3fda0e0..6b5331e 100644 (file)
@@ -1,3 +1,13 @@
+2003-01-06 [Ivan Francolin Martinez (ivanfm@users.sourceforge.net)]    0.8.8claws58
+
+       * src/quote_fmt.c
+       * src/summaryview.[ch]
+       * src/gtk/Makefile.am
+       * src/gtk/description_window.[ch]       ** NEW **
+               use a generic window to display syntax descriptions
+               currently used in quote_fmt and summaryview (new description
+               for extended quick search)
+
 2003-01-06 [paul]      0.8.8claws57
 
        * sync with 0.8.8cvs1
index 1dd4354..69a4302 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws57
+EXTRA_VERSION=claws58
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 67abeb8..fce036f 100644 (file)
@@ -1,6 +1,7 @@
 noinst_LTLIBRARIES = libsylpheedgtk.la
 
 libsylpheedgtk_la_SOURCES = \
+       description_window.h description_window.c \
        gtkshruler.c gtkshruler.h \
        gtksctree.c gtksctree.h \
        gtkstext.c gtkstext.h \
diff --git a/src/gtk/description_window.c b/src/gtk/description_window.c
new file mode 100644 (file)
index 0000000..de7a598
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "intl.h"
+#include "manage_window.h"
+#include "description_window.h"
+#include "../gtkutils.h"
+
+static void description_create                 (DescriptionWindow *dwindow);
+static void description_window_key_pressed     (GtkWidget *widget,
+                                                GdkEventKey *event,
+                                                gpointer data);
+
+void description_window_create(DescriptionWindow *dwindow)
+{
+       if (!dwindow->window)
+               description_create(dwindow);
+
+       manage_window_set_transient(GTK_WINDOW(dwindow->window));
+       gtk_widget_show(dwindow->window);
+       gtk_main();
+       gtk_widget_hide(dwindow->window);
+}
+
+static void description_create(DescriptionWindow * dwindow)
+{
+       GtkWidget *vbox;
+       GtkWidget *table;
+       GtkWidget *hbbox;
+       GtkWidget *ok_btn;
+       GtkWidget *scrolledwin;
+       int i;
+       int sz;
+
+       dwindow->window = gtk_window_new(GTK_WINDOW_DIALOG);
+       gtk_widget_set_usize(dwindow->window,400,450);
+       
+       gtk_window_set_title(GTK_WINDOW(dwindow->window),
+                            gettext(dwindow->title));
+       gtk_container_set_border_width(GTK_CONTAINER(dwindow->window), 8);
+       gtk_window_set_position(GTK_WINDOW(dwindow->window), GTK_WIN_POS_CENTER);
+       gtk_window_set_modal(GTK_WINDOW(dwindow->window), TRUE);
+       gtk_window_set_policy(GTK_WINDOW(dwindow->window), FALSE, FALSE, FALSE);
+
+       /* Check number of lines to be show */
+       sz = 0;
+       for (i = 0; dwindow->symbol_table[i] != NULL; i = i + dwindow->columns) {
+               sz++;
+       }
+       
+       scrolledwin = gtk_scrolled_window_new(NULL, NULL);
+       gtk_widget_show(scrolledwin);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+       
+       table = gtk_table_new(sz, dwindow->columns, FALSE);
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwin), table);
+       gtk_container_set_border_width(GTK_CONTAINER(table), 4);
+
+       gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+
+       for(i = 0; dwindow->symbol_table[i] != NULL; i = i + dwindow->columns) {
+               if(dwindow->symbol_table[i][0] != '\0') {
+                       GtkWidget *label;
+
+                       label = gtk_label_new(dwindow->symbol_table[i]);
+                       gtk_misc_set_alignment (GTK_MISC(label), 0, 0);
+                       gtk_table_attach(GTK_TABLE(table), label,
+                                        0, 1, i, i+1,
+                                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
+                                        0, 0);
+                                        
+                       label = gtk_label_new(gettext(dwindow->symbol_table[i+1]));
+                       gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+                       gtk_misc_set_alignment (GTK_MISC(label), 0, 0);
+                       gtk_table_attach(GTK_TABLE(table), label,
+                                        1, 2, i, i+1,
+                                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
+                                        0, 0);
+               } else {
+                       GtkWidget *separator;
+                       
+                       separator = gtk_hseparator_new();
+                       gtk_table_attach(GTK_TABLE(table), separator,
+                                        0, 2, i, i+1,
+                                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
+                                        0, 4);
+               }
+       }
+
+       gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
+                               NULL, NULL, NULL, NULL);
+       gtk_widget_show(hbbox);
+
+       vbox = gtk_vbox_new(FALSE, 0);
+       gtk_widget_show(vbox);
+       gtk_container_add(GTK_CONTAINER(dwindow->window), vbox);
+       gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scrolledwin),
+                          TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbbox),
+                          FALSE, FALSE, 3);
+                          
+/* OLD CODE
+       gtk_table_attach_defaults(GTK_TABLE(table), hbbox,
+                                 1, 2, i, i+1);
+*/
+       gtk_widget_grab_default(ok_btn);
+       gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
+                          GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+       gtk_signal_connect
+               (GTK_OBJECT(dwindow->window), "key_press_event",
+                GTK_SIGNAL_FUNC(description_window_key_pressed),
+                NULL);
+       gtk_signal_connect(GTK_OBJECT(dwindow->window), "delete_event",
+                          GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+
+       gtk_widget_show_all(table);
+}
+
+static void description_window_key_pressed(GtkWidget *widget,
+                                          GdkEventKey *event,
+                                          gpointer data)
+{
+       if (event && event->keyval == GDK_Escape)
+               gtk_main_quit();
+}
+
diff --git a/src/gtk/description_window.h b/src/gtk/description_window.h
new file mode 100644 (file)
index 0000000..9c3f7eb
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _DESCRIPTION_WINDOW_H
+#define _DESCRIPTION_WINDOW_H
+
+typedef struct _DescriptionWindow DescriptionWindow;
+
+struct _DescriptionWindow
+{
+       GtkWidget       * window;
+       /** Number of columns for each line of data **/
+       int               columns;
+       /** title of the window **/
+       gchar           * title;
+       /** points to the table of strings to be show in the window */
+       gchar           ** symbol_table;
+};
+
+void description_window_create(DescriptionWindow *dwindow);
+
+#endif /* _DESCRIPTION_WINDOW_H */
index ee7b6c7..3ac7d9a 100644 (file)
 
 #include "intl.h"
 #include "manage_window.h"
+#include "description_window.h"
 #include "gtkutils.h"
 
-static GtkWidget *quote_desc_win;
 
-static void quote_fmt_quote_description_create         (void);
-static void quote_fmt_quote_description_key_pressed    (GtkWidget *widget,
-                                                        GdkEventKey *event,
-                                                        gpointer data);
-
-static gchar *symbol_table[][2] =
-{
-       {"%D{fmt}",     N_("Customize date format (see man strftime)")}, /* date expression */
-       {"%d",          N_("Date")}, /* date */
-       {"%f",          N_("From")}, /* from */
-       {"%N",          N_("Full Name of Sender")}, /* full name */
-       {"%F",          N_("First Name of Sender")}, /* first name */
-       {"%L",          N_("Last Name of Sender")}, /* last name */
-       {"%I",          N_("Initials of Sender")}, /* initial of sender */
-       {"%s",          N_("Subject")}, /* subject */ 
-       {"%t",          N_("To")}, /* to */ 
-       {"%c",          N_("Cc")}, /* cc */ 
-       {"%n",          N_("Newsgroups")}, /* newsgroups */ 
-       {"%r",          N_("References")}, /* references */ 
-       {"%i",          N_("Message-ID")}, /* message-id */ 
-       {"%M",          N_("Message body")}, /* message */ 
-       {"%Q",          N_("Quoted message body")}, /* quoted message */ 
-       {"%m",          N_("Message body without signature")}, /* message with no signature */ 
-       {"%q",          N_("Quoted message body without signature")}, /* quoted message with no signature */ 
-       {"",            NULL},
-       {"?x{expr}",    N_("Insert expr if x is set\nx is one of the characters above after %")},
-       {"",            NULL},
-       {"\\%",         N_("Literal %")},
-       {"\\\\",        N_("Literal backslash")},
-       {"\\?",         N_("Literal question mark")},
-       {"\\|",         N_("Literal pipe")},
-       {"\\{",         N_("Literal opening curly brace")},
-       {"\\}",         N_("Literal closing curly brace")},
-       {"",            NULL},
-       {"|f{file}",    N_("Insert File")},
-       {"|p{command}", N_("Insert program output")}, /* insert program output */ 
-       {NULL,NULL},
+/*
+ * Strings describing quote format strings
+ * 
+ * When adding new lines, remember to put 2 strings for each line
+ */
+static gchar *quote_desc_strings[] = {
+       "%D{fmt}",      N_("Customize date format (see man strftime)"), /* date expression */
+       "%d",           N_("Date"), /* date */
+       "%f",           N_("From"), /* from */
+       "%N",           N_("Full Name of Sender"), /* full name */
+       "%F",           N_("First Name of Sender"), /* first name */
+       "%L",           N_("Last Name of Sender"), /* last name */
+       "%I",           N_("Initials of Sender"), /* initial of sender */
+       "%s",           N_("Subject"), /* subject */ 
+       "%t",           N_("To"), /* to */ 
+       "%c",           N_("Cc"), /* cc */ 
+       "%n",           N_("Newsgroups"), /* newsgroups */ 
+       "%r",           N_("References"), /* references */ 
+       "%i",           N_("Message-ID"), /* message-id */ 
+       "%M",           N_("Message body"), /* message */ 
+       "%Q",           N_("Quoted message body"), /* quoted message */ 
+       "%m",           N_("Message body without signature"), /* message with no signature */ 
+       "%q",           N_("Quoted message body without signature"), /* quoted message with no signature */ 
+       "",             NULL,
+       "?x{expr}",     N_("Insert expr if x is set\nx is one of the characters above after %"),
+       "",             NULL,
+       "\\%",          N_("Literal %"),
+       "\\\\",         N_("Literal backslash"),
+       "\\?",          N_("Literal question mark"),
+       "\\|",          N_("Literal pipe"),
+       "\\{",          N_("Literal opening curly brace"),
+       "\\}",          N_("Literal closing curly brace"),
+       "",             NULL,
+       "|f{file}",     N_("Insert File"),
+       "|p{command}",  N_("Insert program output"), /* insert program output */ 
+       NULL,NULL
 };
 
-void quote_fmt_quote_description(void)
-{
-       if (!quote_desc_win)
-               quote_fmt_quote_description_create();
-
-       manage_window_set_transient(GTK_WINDOW(quote_desc_win));
-       gtk_widget_show(quote_desc_win);
-       gtk_main();
-       gtk_widget_hide(quote_desc_win);
-}
-
-static void quote_fmt_quote_description_create(void)
-{
-       GtkWidget *table;
-       GtkWidget *hbbox;
-       GtkWidget *ok_btn;
-       int i;
-
-       quote_desc_win = gtk_window_new(GTK_WINDOW_DIALOG);
-       gtk_window_set_title(GTK_WINDOW(quote_desc_win),
-                            _("Description of symbols"));
-       gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
-       gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
-       gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, FALSE, FALSE);
-
-       table = gtk_table_new(sizeof(symbol_table), 2, FALSE);
-       gtk_container_add(GTK_CONTAINER(quote_desc_win), table);
-       gtk_table_set_col_spacings(GTK_TABLE(table), 10);
-
-       for(i = 0; symbol_table[i][0] != NULL; i++) {
-               if(symbol_table[i][0][0] != '\0') {
-                       GtkWidget *label;
-
-                       label = gtk_label_new(symbol_table[i][0]);
-                       gtk_misc_set_alignment (GTK_MISC(label), 0, 0);
-                       gtk_table_attach(GTK_TABLE(table), label,
-                                        0, 1, i, i+1,
-                                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                                        0, 0);
-                       label = gtk_label_new(gettext(symbol_table[i][1]));
-                       gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
-                       gtk_misc_set_alignment (GTK_MISC(label), 0, 0);
-                       gtk_table_attach(GTK_TABLE(table), label,
-                                        1, 2, i, i+1,
-                                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                                        0, 0);
-               } else {
-                       GtkWidget *separator;
-                       
-                       separator = gtk_hseparator_new();
-                       gtk_table_attach(GTK_TABLE(table), separator,
-                                        0, 2, i, i+1,
-                                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                                        0, 4);
-               }
-       }
-
-       gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
-                               NULL, NULL, NULL, NULL);
-       gtk_table_attach_defaults(GTK_TABLE(table), hbbox,
-                                 1, 2, i, i+1);
-
-       gtk_widget_grab_default(ok_btn);
-       gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
-                          GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
-       gtk_signal_connect
-               (GTK_OBJECT(quote_desc_win), "key_press_event",
-                GTK_SIGNAL_FUNC(quote_fmt_quote_description_key_pressed),
-                NULL);
-       gtk_signal_connect(GTK_OBJECT(quote_desc_win), "delete_event",
-                          GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+static DescriptionWindow quote_desc_win = { 
+        NULL, 
+        2,
+        N_("Description of symbols"),
+        quote_desc_strings
+};
 
-       gtk_widget_show_all(table);
-}
 
-static void quote_fmt_quote_description_key_pressed(GtkWidget *widget,
-                                               GdkEventKey *event,
-                                               gpointer data)
+void quote_fmt_quote_description(void)
 {
-       if (event && event->keyval == GDK_Escape)
-               gtk_main_quit();
+       description_window_create(&quote_desc_win);
 }
 
index ccbcff3..132fa97 100644 (file)
@@ -86,6 +86,7 @@
 #include "matcher.h"
 #include "matcher_parser.h"
 #include "hooks.h"
+#include "description_window.h"
 
 #define SUMMARY_COL_MARK_WIDTH         10
 #define SUMMARY_COL_UNREAD_WIDTH       13
@@ -467,6 +468,64 @@ static const gchar *const col_label[N_SUMMARY_COLS] = {
        N_("L")         /* S_COL_LOCKED  */
 };
 
+/*
+ * Strings describing how to use Extended Search
+ * 
+ * When adding new lines, remember to put 2 strings for each line
+ */
+static gchar *search_descr_strings[] = {
+       "a",     N_("all messages"),
+       "ag #",  N_("messages whose age is greather than #"),
+       "al #",  N_("messages whose age is greather than #"),
+       "b S",   N_("messages which contain S in the message body"),
+       "B S",   N_("messages which contain S in the whole message"),
+       "c S",   N_("messages carbon-copied to S"),
+       "C S",   N_("message is either to: or cc: to S"),
+       "D",     N_("deleted messages"), /** how I can filter deleted messages **/
+       "e S",   N_("messages which contain S in the Sender field"),
+       "E S",   N_("true if execute \"S\" succeeds"),
+       "f S",   N_("messages originating from user S"),
+       "F",     N_("forwarded messages"),
+       "h S",   N_("messages which contain header S"),
+       "i S",   N_("messages which contain S in Message-Id header"),
+       "I S",   N_("messages which contain S in inreplyto header"),
+       "L",     N_("locked messages"),
+       "n S",   N_("messages which are in newsgroup S"),
+       "N",     N_("new messages"),
+       "O",     N_("old messages"),
+       "r",     N_("messages which have been replied to"),
+       "R",     N_("read messages"),
+       "s S",   N_("messages which contain S in subject"),
+       "se #",  N_("messages whose score is equal to #"),
+       "sg #",  N_("messages whose score is greater than #"),
+       "sl #",  N_("messages whose score is lower than #"),
+       "Se #",  N_("messages whose size is equal to #"),
+       "Sg #",  N_("messages whose size is greater than #"),
+       "Ss #",  N_("messages whose size is smaller than #"),
+       "t S",   N_("messages which have been sent to S"),
+       "T",     N_("marked marked"),
+       "U",     N_("unread messages"),
+       "x S",   N_("messages which contain S in References header"),
+       "y S",   N_("messages which contain S in X-Label header"),
+        "",     "" ,
+       "&",     N_("logical AND operator"),
+       "|",     N_("logical OR operator"),
+       "! or ~",       N_("logical NOT operator"),
+       "%",     N_("case sensitive search"),
+       NULL,    NULL 
+};
+static DescriptionWindow search_descr = {
+       NULL, 
+       2,
+       N_("Extended Search symbols"),
+       search_descr_strings
+};
+       
+static void search_description_cb (GtkWidget *widget) {
+       description_window_create(&search_descr);
+};
+
 SummaryView *summary_create(void)
 {
        SummaryView *summaryview;
@@ -486,6 +545,8 @@ SummaryView *summary_create(void)
        GtkWidget *search_type_opt;
        GtkWidget *search_type;
        GtkWidget *search_string;
+       GtkWidget *search_hbbox;
+       GtkWidget *search_description;
        GtkWidget *menuitem;
        GtkWidget *toggle_search;
        GtkTooltips *search_tip;
@@ -590,6 +651,12 @@ SummaryView *summary_create(void)
        
        gtk_box_pack_start(GTK_BOX(hbox_search), search_string, FALSE, FALSE, 2);
        
+       gtkut_button_set_create(&search_hbbox, &search_description, _("Extended Symbols"),
+                               NULL, NULL, NULL, NULL);
+       gtk_signal_connect(GTK_OBJECT(search_description), "clicked",
+                          GTK_SIGNAL_FUNC(search_description_cb), NULL);
+       gtk_box_pack_start(GTK_BOX(hbox_search), search_hbbox, FALSE, FALSE, 2);
+                               
        gtk_widget_show(search_string);
        gtk_widget_show(hbox_search);
 
@@ -633,6 +700,7 @@ SummaryView *summary_create(void)
        summaryview->search_type_opt = search_type_opt;
        summaryview->search_type = search_type;
        summaryview->search_string = search_string;
+       summaryview->search_description = search_description;
        summaryview->msginfo_update_callback_id =
                hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, summary_update_msg, (gpointer) summaryview);
 
@@ -4725,6 +4793,13 @@ static void summary_searchtype_changed(GtkMenuItem *widget, gpointer data)
                                   GTK_OBJECT(GTK_MENU_ITEM(gtk_menu_get_active(
                                   GTK_MENU(sw->search_type))))));
 
+       /* Show extended search description button, only when Extended is selected */
+       if (prefs_common.summary_quicksearch_type == S_SEARCH_EXTENDED) {
+               gtk_widget_show(sw->search_description);
+       } else {
+               gtk_widget_hide(sw->search_description);
+       }
+
        if (gtk_entry_get_text(GTK_ENTRY(sw->search_string)))
                summary_show(sw, sw->folder_item);
 }
index 0c3f293..c8d7706 100644 (file)
@@ -108,6 +108,7 @@ struct _SummaryView
        GtkWidget *search_type_opt;
        GtkWidget *search_type;
        GtkWidget *search_string;
+       GtkWidget *search_description;
 
        GtkItemFactory *popupfactory;