fix bug 4058, '# in extended search description window should not be translated'
[claws.git] / src / gtk / quicksearch.c
index aeffe6a..33c883e 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2013 Colin Leroy <colin@colino.net> 
- * and the Claws Mail team
+ * Copyright (C) 1999-2018 Colin Leroy and the Claws Mail team
  *
  * 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
  *
  * 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
@@ -140,19 +139,19 @@ static void quicksearch_add_to_history(QuickSearch* quicksearch)
                                if (advsearch_has_proper_predicate(quicksearch->asearch)) {
                                        quicksearch->extended_search_strings =
                                                add_history(quicksearch->extended_search_strings,
                                if (advsearch_has_proper_predicate(quicksearch->asearch)) {
                                        quicksearch->extended_search_strings =
                                                add_history(quicksearch->extended_search_strings,
-                                                               g_strdup(search_string));
+                                                               search_string);
                                        prefs_common.summary_quicksearch_history =
                                                add_history(prefs_common.summary_quicksearch_history,
                                        prefs_common.summary_quicksearch_history =
                                                add_history(prefs_common.summary_quicksearch_history,
-                                                               g_strdup(search_string));
+                                                               search_string);
                                }
                                break;
                        default:
                                quicksearch->normal_search_strings =
                                        add_history(quicksearch->normal_search_strings,
                                }
                                break;
                        default:
                                quicksearch->normal_search_strings =
                                        add_history(quicksearch->normal_search_strings,
-                                                       g_strdup(search_string));               
+                                                       search_string);
                                prefs_common.summary_quicksearch_history =
                                        add_history(prefs_common.summary_quicksearch_history,
                                prefs_common.summary_quicksearch_history =
                                        add_history(prefs_common.summary_quicksearch_history,
-                                                       g_strdup(search_string));
+                                                       search_string);
                                break;
                }
 
                                break;
                }
 
@@ -243,15 +242,6 @@ static void quicksearch_set_popdown_strings(QuickSearch *quicksearch)
 {
        GtkWidget *search_string_entry = quicksearch->search_string_entry;
 
 {
        GtkWidget *search_string_entry = quicksearch->search_string_entry;
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       combobox_unset_popdown_strings(GTK_COMBO_BOX(search_string_entry));
-       if (prefs_common.summary_quicksearch_type == ADVANCED_SEARCH_EXTENDED)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(search_string_entry),
-                       quicksearch->extended_search_strings);  
-       else
-               combobox_set_popdown_strings(GTK_COMBO_BOX(search_string_entry),
-                       quicksearch->normal_search_strings);
-#else
        combobox_unset_popdown_strings(GTK_COMBO_BOX_TEXT(search_string_entry));        
        if (prefs_common.summary_quicksearch_type == ADVANCED_SEARCH_EXTENDED)
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(search_string_entry),
        combobox_unset_popdown_strings(GTK_COMBO_BOX_TEXT(search_string_entry));        
        if (prefs_common.summary_quicksearch_type == ADVANCED_SEARCH_EXTENDED)
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(search_string_entry),
@@ -259,7 +249,6 @@ static void quicksearch_set_popdown_strings(QuickSearch *quicksearch)
        else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(search_string_entry),
                        quicksearch->normal_search_strings);
        else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(search_string_entry),
                        quicksearch->normal_search_strings);
-#endif
 }
 
 static void update_extended_buttons (QuickSearch *quicksearch)
 }
 
 static void update_extended_buttons (QuickSearch *quicksearch)
@@ -343,7 +332,18 @@ static void searchbar_changed_cb(GtkWidget *widget, QuickSearch *qs)
 static gboolean searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
                                  QuickSearch *quicksearch)
 {
 static gboolean searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
                                  QuickSearch *quicksearch)
 {
-       if (event && (event->keyval == GDK_KEY_Escape)) {
+       if (event != NULL && (event->keyval == GDK_KEY_ISO_Left_Tab)) {
+               /* Shift+Tab moves focus "back" */
+               gtk_widget_grab_focus(quicksearch->search_type_opt);
+               return TRUE;
+       }
+       if (event != NULL && (event->keyval == GDK_KEY_Tab)) {
+               /* Just Tab moves focus "forwards" */
+               gtk_widget_grab_focus(quicksearch->clear_search);
+               return TRUE;
+       }
+
+       if (event != NULL && (event->keyval == GDK_KEY_Escape)) {
                gchar *str;
 
                quicksearch->in_typing = FALSE;
                gchar *str;
 
                quicksearch->in_typing = FALSE;
@@ -522,9 +522,9 @@ static gchar *search_descr_strings[] = {
        "|",     N_("logical OR operator"),
        "! or ~",       N_("logical NOT operator"),
        "%",     N_("case sensitive search"),
        "|",     N_("logical OR operator"),
        "! or ~",       N_("logical NOT operator"),
        "%",     N_("case sensitive search"),
-       "#",     N_("match using regular expressions instead of substring search"),
+       "&#x00023;", N_("match using regular expressions instead of substring search"),
        "",      "" ,
        "",      "" ,
-       " ",     N_("all filtering expressions are allowed, but can not be mixed "
+       " ",     N_("all filtering expressions are allowed, but cannot be mixed "
                    "through logical operators with the expressions above"),
        NULL,    NULL
 };
                    "through logical operators with the expressions above"),
        NULL,    NULL
 };
@@ -764,11 +764,7 @@ QuickSearch *quicksearch_new()
 
        gtk_widget_show(search_type);
 
 
        gtk_widget_show(search_type);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       search_string_entry = gtk_combo_box_entry_new_text ();
-#else
        search_string_entry = gtk_combo_box_text_new_with_entry ();
        search_string_entry = gtk_combo_box_text_new_with_entry ();
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(search_string_entry), -1);
 
        vbox = gtk_vbox_new(TRUE, 0);
        gtk_combo_box_set_active(GTK_COMBO_BOX(search_string_entry), -1);
 
        vbox = gtk_vbox_new(TRUE, 0);
@@ -848,13 +844,13 @@ QuickSearch *quicksearch_new()
        
        update_extended_buttons(quicksearch);
 
        
        update_extended_buttons(quicksearch);
 
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_active_bgcolor,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ACTIVE_BG],
                                           &qs_active_bgcolor);
                                           &qs_active_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_active_color,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ACTIVE],
                                           &qs_active_color);
                                           &qs_active_color);
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_error_bgcolor,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ERROR_BG],
                                           &qs_error_bgcolor);
                                           &qs_error_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_error_color,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ERROR],
                                           &qs_error_color);
 
        return quicksearch;
                                           &qs_error_color);
 
        return quicksearch;
@@ -884,6 +880,11 @@ GtkWidget *quicksearch_get_widget(QuickSearch *quicksearch)
        return quicksearch->hbox_search;
 }
 
        return quicksearch->hbox_search;
 }
 
+GtkWidget *quicksearch_get_entry(QuickSearch *quicksearch)
+{
+       return gtk_bin_get_child(GTK_BIN(quicksearch->search_string_entry));
+}
+
 void quicksearch_show(QuickSearch *quicksearch)
 {
        MainWindow *mainwin = mainwindow_get_mainwindow();
 void quicksearch_show(QuickSearch *quicksearch)
 {
        MainWindow *mainwin = mainwindow_get_mainwindow();
@@ -1004,53 +1005,6 @@ gboolean quicksearch_is_running(QuickSearch *quicksearch)
        return quicksearch->running;
 }
 
        return quicksearch->running;
 }
 
-void quicksearch_pass_key(QuickSearch *quicksearch, guint val, GdkModifierType mod)
-{
-       GtkEntry *entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN((quicksearch->search_string_entry))));
-       glong curpos = gtk_editable_get_position(GTK_EDITABLE(entry));
-       guint32 c;
-       char *str = g_strdup(gtk_entry_get_text(entry));
-       char *begin = str;
-       char *end = NULL;
-       char *new = NULL;
-       char key[7] = "";
-       gint char_len = 0;
-
-       if (gtk_editable_get_selection_bounds(GTK_EDITABLE(entry), NULL, NULL)) {
-               /* remove selection */
-               gtk_editable_delete_selection(GTK_EDITABLE(entry));
-               curpos = gtk_editable_get_position(GTK_EDITABLE(entry));
-               /* refresh string */
-               g_free(str);
-               str = g_strdup(gtk_entry_get_text(entry));
-               begin = str;
-       }
-
-       if (!(c = gdk_keyval_to_unicode(val))) {
-               g_free(str);
-               return;
-       }
-       char_len = g_unichar_to_utf8(c, key);
-       if (char_len < 0)
-               return;
-       key[char_len] = '\0';
-       if (curpos < g_utf8_strlen(str, -1)) {
-               gchar *stop = g_utf8_offset_to_pointer(begin, curpos);
-               end = g_strdup(g_utf8_offset_to_pointer(str, curpos));
-               *stop = '\0';
-               new = g_strdup_printf("%s%s%s", begin, key, end);
-               gtk_entry_set_text(entry, new);
-               g_free(end);
-       } else {
-               new = g_strdup_printf("%s%s", begin, key);
-               gtk_entry_set_text(entry, new);
-       }
-       g_free(str);
-       g_free(new);
-       gtk_editable_set_position(GTK_EDITABLE(entry), curpos+1);
-
-}
-
 gboolean quicksearch_is_in_typing(QuickSearch *quicksearch)
 {
        return quicksearch->in_typing;
 gboolean quicksearch_is_in_typing(QuickSearch *quicksearch)
 {
        return quicksearch->in_typing;