From f72b66987a36c532fb42d850aeb6457ad533a37b Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Wed, 19 Apr 2006 17:28:39 +0000 Subject: [PATCH] 2006-04-19 [colin] 2.1.1cvs15 * src/compose.c * src/compose.h * src/gtk/gtkaspell.c * src/gtk/gtkaspell.h Put back Options menu in Spelling/ * src/gtk/quicksearch.c Don't search, and show error, if the advanced search has a syntax error --- ChangeLog | 11 ++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/compose.c | 47 ++++++++++++++++++++++++++++++++++++++++++- src/compose.h | 1 + src/gtk/gtkaspell.c | 24 +++++++++++++++++----- src/gtk/gtkaspell.h | 5 ++++- src/gtk/quicksearch.c | 30 ++++++++++++++++++--------- 8 files changed, 103 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index e623e2ac7..4629bf575 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-04-19 [colin] 2.1.1cvs15 + + * src/compose.c + * src/compose.h + * src/gtk/gtkaspell.c + * src/gtk/gtkaspell.h + Put back Options menu in Spelling/ + * src/gtk/quicksearch.c + Don't search, and show error, if the + advanced search has a syntax error + 2006-04-18 [colin] 2.1.1cvs14 * src/textview.c diff --git a/PATCHSETS b/PATCHSETS index bffdd01c8..ab6dafa68 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1436,3 +1436,4 @@ ( cvs diff -u -r 1.382.2.264 -r 1.382.2.265 src/compose.c; cvs diff -u -r 1.179.2.105 -r 1.179.2.106 src/imap.c; cvs diff -u -r 1.105.2.52 -r 1.105.2.53 src/prefs_account.c; cvs diff -u -r 1.49.2.18 -r 1.49.2.19 src/prefs_account.h; cvs diff -u -r 1.150.2.60 -r 1.150.2.61 src/procmsg.c; ) > 2.1.1cvs12.patchset ( cvs diff -u -r 1.1.4.15 -r 1.1.4.16 src/gtk/gtksctree.c; ) > 2.1.1cvs13.patchset ( cvs diff -u -r 1.96.2.111 -r 1.96.2.112 src/textview.c; ) > 2.1.1cvs14.patchset +( cvs diff -u -r 1.382.2.265 -r 1.382.2.266 src/compose.c; cvs diff -u -r 1.50.2.23 -r 1.50.2.24 src/compose.h; cvs diff -u -r 1.9.2.38 -r 1.9.2.39 src/gtk/gtkaspell.c; cvs diff -u -r 1.5.2.5 -r 1.5.2.6 src/gtk/gtkaspell.h; cvs diff -u -r 1.1.2.39 -r 1.1.2.40 src/gtk/quicksearch.c; ) > 2.1.1cvs15.patchset diff --git a/configure.ac b/configure.ac index 83e79327a..dc42e1af6 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=1 MICRO_VERSION=1 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=14 +EXTRA_VERSION=15 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/compose.c b/src/compose.c index 7e7569990..1a4fc5a8f 100644 --- a/src/compose.c +++ b/src/compose.c @@ -646,6 +646,9 @@ static GtkItemFactoryEntry compose_entries[] = NULL, compose_check_backwards , 0, NULL}, {N_("/_Spelling/_Forward to next misspelled word"), NULL, compose_check_forwards_go, 0, NULL}, + {N_("/_Spelling/---"), NULL, NULL, 0, ""}, + {N_("/_Spelling/Options"), + NULL, NULL, 0, ""}, #endif {N_("/_Options"), NULL, NULL, 0, ""}, {N_("/_Options/Privacy System"), NULL, NULL, 0, ""}, @@ -5561,6 +5564,45 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event, return FALSE; } +#if USE_ASPELL +static void compose_spell_menu_changed(void *data) +{ + Compose *compose = (Compose *)data; + GSList *items; + GtkWidget *menuitem; + GtkWidget *parent_item; + GtkMenu *menu = gtk_menu_new(); + GtkItemFactory *ifactory = gtk_item_factory_from_widget(compose->menubar); + GSList *spell_menu; + + parent_item = gtk_item_factory_get_item(ifactory, + "/Spelling/Options"); + + /* setting the submenu removes /Spelling/Options from the factory + * so we need to save it */ + + if (parent_item == NULL) { + parent_item = compose->aspell_options_menu; + gtk_menu_item_remove_submenu(GTK_MENU_ITEM(parent_item)); + } else + compose->aspell_options_menu = parent_item; + + spell_menu = gtkaspell_make_config_menu(compose->gtkaspell); + + spell_menu = g_slist_reverse(spell_menu); + for (items = spell_menu; + items; items = items->next) { + menuitem = GTK_MENU_ITEM(items->data); + gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), GTK_WIDGET(menuitem)); + gtk_widget_show(GTK_WIDGET(menuitem)); + } + g_slist_free(spell_menu); + + gtk_menu_item_set_submenu(GTK_MENU_ITEM(parent_item), GTK_WIDGET(menu)); + +} +#endif + static Compose *compose_create(PrefsAccount *account, ComposeMode mode, gboolean batch) { @@ -5886,7 +5928,9 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode, prefs_common.recheck_when_changing_dict, prefs_common.use_alternate, GTK_TEXT_VIEW(text), - GTK_WINDOW(compose->window)); + GTK_WINDOW(compose->window), + compose_spell_menu_changed, + compose); if (!gtkaspell) { alertpanel_error(_("Spell checker could not " "be started.\n%s"), @@ -5906,6 +5950,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode, } } compose->gtkaspell = gtkaspell; + compose_spell_menu_changed(compose); #endif compose_select_account(compose, account, TRUE); diff --git a/src/compose.h b/src/compose.h index 29cce3410..2f5e46e9d 100644 --- a/src/compose.h +++ b/src/compose.h @@ -208,6 +208,7 @@ struct _Compose #if USE_ASPELL /* GNU/aspell spell checker */ GtkAspell *gtkaspell; + GtkWidget *aspell_options_menu; #endif /* Priority */ diff --git a/src/gtk/gtkaspell.c b/src/gtk/gtkaspell.c index 354d0d785..f22f8a0e8 100644 --- a/src/gtk/gtkaspell.c +++ b/src/gtk/gtkaspell.c @@ -136,6 +136,8 @@ struct _GtkAspell GtkTextView *gtktext; GdkColor highlight; GtkAccelGroup *accel_group; + void (*menu_changed_cb)(void *data); + void *menu_changed_data; }; typedef AspellConfig GtkAspellConfig; @@ -206,7 +208,7 @@ static void toggle_check_while_typing_cb (GtkWidget *w, /* Menu creation */ static GSList* make_sug_menu (GtkAspell *gtkaspell); static GSList * populate_submenu (GtkAspell *gtkaspell); -static GSList* make_config_menu (GtkAspell *gtkaspell); +GSList* gtkaspell_make_config_menu (GtkAspell *gtkaspell); static void set_menu_pos (GtkMenu *menu, gint *x, gint *y, @@ -377,7 +379,9 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path, gboolean recheck_when_changing_dict, gboolean use_alternate, GtkTextView *gtktext, - GtkWindow *parent_win) + GtkWindow *parent_win, + void (*spell_menu_cb)(void *data), + void *data) { Dictionary *dict; GtkAspell *gtkaspell; @@ -424,7 +428,9 @@ GtkAspell *gtkaspell_new(const gchar *dictionary_path, gtkaspell->suggestions_list = NULL; gtkaspell->use_alternate = use_alternate; gtkaspell->parent_window = GTK_WIDGET(parent_win); - + gtkaspell->menu_changed_cb = spell_menu_cb; + gtkaspell->menu_changed_data = data; + allocate_color(gtkaspell, misspelled_color); g_signal_connect_after(G_OBJECT(buffer), "insert-text", @@ -562,7 +568,7 @@ static void button_press_intercept_cb(GtkTextView *gtktext, } } if (!spell_menu) - spell_menu = make_config_menu(gtkaspell); + spell_menu = gtkaspell_make_config_menu(gtkaspell); spell_menu = g_slist_reverse(spell_menu); for (items = spell_menu; @@ -808,6 +814,8 @@ static void set_sug_mode_cb(GtkMenuItem *w, GtkAspell *gtkaspell) set_real_sug_mode(gtkaspell, themode); g_free(themode); + if (gtkaspell->menu_changed_cb) + gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); } static void set_real_sug_mode(GtkAspell *gtkaspell, const char *themode) @@ -1610,6 +1618,8 @@ static void toggle_check_while_typing_cb(GtkWidget *w, gpointer data) if (!gtkaspell->check_while_typing) gtkaspell_uncheck_all(gtkaspell); + if (gtkaspell->menu_changed_cb) + gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); } static GSList *create_empty_dictionary_list(void) @@ -2173,7 +2183,7 @@ static GSList *populate_submenu(GtkAspell *gtkaspell) return list; } -static GSList *make_config_menu(GtkAspell *gtkaspell) +GSList *gtkaspell_make_config_menu(GtkAspell *gtkaspell) { return populate_submenu(gtkaspell); } @@ -2288,6 +2298,8 @@ static void change_dict_cb(GtkWidget *w, GtkAspell *gtkaspell) if (gtkaspell->recheck_when_changing_dict) { gtkaspell_highlight_all(gtkaspell); } + if (gtkaspell->menu_changed_cb) + gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); } static void switch_to_alternate_cb(GtkWidget *w, @@ -2295,6 +2307,8 @@ static void switch_to_alternate_cb(GtkWidget *w, { GtkAspell *gtkaspell = (GtkAspell *) data; use_alternate_dict(gtkaspell); + if (gtkaspell->menu_changed_cb) + gtkaspell->menu_changed_cb(gtkaspell->menu_changed_data); } /* Misc. helper functions */ diff --git a/src/gtk/gtkaspell.h b/src/gtk/gtkaspell.h index 59add9bbc..e92e9a457 100644 --- a/src/gtk/gtkaspell.h +++ b/src/gtk/gtkaspell.h @@ -58,7 +58,9 @@ GtkAspell* gtkaspell_new (const gchar *dictionary_path, gboolean recheck_when_changing_dict, gboolean use_alternate, GtkTextView *gtktext, - GtkWindow *parent_win); + GtkWindow *parent_win, + void (*spell_menu_cb)(void *data), + void *data); void gtkaspell_delete (GtkAspell *gtkaspell); @@ -98,6 +100,7 @@ void gtkaspell_sugmode_option_menu_set (GtkOptionMenu *optmenu, gint sugmode); gint gtkaspell_get_sugmode_from_option_menu (GtkOptionMenu *optmenu); +GSList* gtkaspell_make_config_menu (GtkAspell *gtkaspell); #endif /* USE_ASPELL */ #endif /* __GTKASPELL_H__ */ diff --git a/src/gtk/quicksearch.c b/src/gtk/quicksearch.c index dde8b5c0a..6837e3182 100644 --- a/src/gtk/quicksearch.c +++ b/src/gtk/quicksearch.c @@ -282,7 +282,7 @@ static gchar *search_descr_strings[] = { "T", N_("marked messages"), "U", N_("unread messages"), "x S", N_("messages which contain S in References header"), - "X cmd", N_("messages returning 0 when passed to command"), + "X \"cmd args\"", N_("messages returning 0 when passed to command - %F is message file"), "y S", N_("messages which contain S in X-Label header"), "", "" , "&", N_("logical AND operator"), @@ -550,44 +550,54 @@ void quicksearch_set(QuickSearch *quicksearch, QuickSearchType type, gboolean quicksearch_is_active(QuickSearch *quicksearch) { - return quicksearch->active; + return quicksearch->active && (quicksearch->matcher_list != NULL); } static void quicksearch_set_active(QuickSearch *quicksearch, gboolean active) { static GdkColor yellow; + static GdkColor red; static GdkColor black; - static gboolean yellow_initialised = FALSE; + static gboolean colors_initialised = FALSE; + gboolean error = FALSE; - if (!yellow_initialised) { + if (!colors_initialised) { gdk_color_parse("#f5f6be", &yellow); gdk_color_parse("#000000", &black); - yellow_initialised = gdk_colormap_alloc_color( + gdk_color_parse("#ff7070", &red); + colors_initialised = gdk_colormap_alloc_color( gdk_colormap_get_system(), &yellow, FALSE, TRUE); - yellow_initialised &= gdk_colormap_alloc_color( + colors_initialised &= gdk_colormap_alloc_color( gdk_colormap_get_system(), &black, FALSE, TRUE); - + colors_initialised &= gdk_colormap_alloc_color( + gdk_colormap_get_system(), &red, FALSE, TRUE); } + quicksearch->active = active; + if (active && quicksearch->matcher_list == NULL) + error = TRUE; + if (active) { gtk_widget_set_sensitive(quicksearch->clear_search, TRUE); - if (yellow_initialised) + if (colors_initialised) { gtk_widget_modify_base( GTK_COMBO(quicksearch->search_string_entry)->entry, - GTK_STATE_NORMAL, &yellow); + GTK_STATE_NORMAL, error ? &red : &yellow); gtk_widget_modify_text( GTK_COMBO(quicksearch->search_string_entry)->entry, GTK_STATE_NORMAL, &black); + } } else { gtk_widget_set_sensitive(quicksearch->clear_search, FALSE); - if (yellow_initialised) + if (colors_initialised) { gtk_widget_modify_base( GTK_COMBO(quicksearch->search_string_entry)->entry, GTK_STATE_NORMAL, NULL); gtk_widget_modify_text( GTK_COMBO(quicksearch->search_string_entry)->entry, GTK_STATE_NORMAL, NULL); + } } if (!active) { -- 2.25.1