| 1 |
/* Copyright (C) 2012 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <gtkmm/entry.h> |
| 18 |
|
| 19 |
_DEFS(gtkmm,gtk) |
| 20 |
_PINCLUDE(gtkmm/private/entry_p.h) |
| 21 |
|
| 22 |
namespace Gtk |
| 23 |
{ |
| 24 |
|
| 25 |
/** This is a subclass of Gtk::Entry that has |
| 26 |
* been tailored for use as a search entry. |
| 27 |
* |
| 28 |
* It will show an inactive symbolic "find" icon when the |
| 29 |
* search entry is empty, and a symbolic "clear" icon when |
| 30 |
* there is text. Clicking on the "clear" icon will empty |
| 31 |
* the search entry. |
| 32 |
* |
| 33 |
* Note that the search/clear icon is shown using a secondary |
| 34 |
* icon, and thus does not work if you are using the secondary |
| 35 |
* icon position for some other purpose. |
| 36 |
* |
| 37 |
* To make filtering appear more reactive, it is a good idea to |
| 38 |
* not react to every change in the entry text immediately, but |
| 39 |
* only after a short delay. To support this, Gtk::SearchEntry |
| 40 |
* emits the signal_search_changed() signal which can |
| 41 |
* be used instead of the Gtk::Editable::signal_changed() signal. |
| 42 |
* |
| 43 |
* The signal_previous_match(), signal_next_match() |
| 44 |
* and signal_stop_search() signals can be uesd to implement |
| 45 |
* moving between search results and ending the search. |
| 46 |
* |
| 47 |
* Often, Gtk::SearchEntry will be fed events by means of being |
| 48 |
* placed inside a Gtk::SearchBar. If that is not the case, |
| 49 |
* you can use handle_event() to pass events. |
| 50 |
* |
| 51 |
* @ingroup Widgets |
| 52 |
* @newin{3,6} |
| 53 |
*/ |
| 54 |
class GTKMM_API SearchEntry |
| 55 |
: public Entry |
| 56 |
{ |
| 57 |
_CLASS_GTKOBJECT(SearchEntry, GtkSearchEntry, GTK_SEARCH_ENTRY, Gtk::Entry, GtkEntry, , , GTKMM_API) |
| 58 |
public: |
| 59 |
|
| 60 |
_CTOR_DEFAULT |
| 61 |
|
| 62 |
//TODO: Use Gdk::EventKey, if we ever use Gdk::Event elsewhere in the API: |
| 63 |
//We use GdkEventKey* rather than GdkEvent*. See GTK+ bug https://bugzilla.gnome.org/show_bug.cgi?id=709544 |
| 64 |
#m4 _CONVERSION(`GdkEventKey*',`GdkEvent*',`(($2)($3))') |
| 65 |
_WRAP_METHOD(bool handle_event(GdkEventKey* gdk_event), gtk_search_entry_handle_event) |
| 66 |
|
| 67 |
//TODO: Remove no_default_handler when we can break ABI: |
| 68 |
_WRAP_SIGNAL(void search_changed(), "search-changed", no_default_handler) |
| 69 |
// Although next-match, previous-match and stop-search are keybinding signals, |
| 70 |
// applications shall connect to them. |
| 71 |
_WRAP_SIGNAL(void next_match(), "next-match", no_default_handler) |
| 72 |
_WRAP_SIGNAL(void previous_match(), "previous-match", no_default_handler) |
| 73 |
_WRAP_SIGNAL(void stop_search(), "stop-search", no_default_handler) |
| 74 |
|
| 75 |
// Gtk::SearchEntry has no properties nor vfuncs as of 3.16. |
| 76 |
}; |
| 77 |
|
| 78 |
} /* namespace Gtk */ |