Add search function for gtk134
This commit is contained in:
parent
57c1a2394d
commit
a52d00fb38
|
@ -31,7 +31,6 @@ set(SOURCE_FILE src/main.cc src/TextEditor.cc)
|
|||
#Compile Resource
|
||||
|
||||
set(RESOURCE_LIST
|
||||
searchbar.ui
|
||||
text_menu.xml)
|
||||
|
||||
compile_gresources(RESOURCE_FILE
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkBox" id="search_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="primary-icon-name">edit-find-symbolic</property>
|
||||
<property name="primary-icon-activatable">False</property>
|
||||
<property name="primary-icon-sensitive">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -51,6 +51,7 @@ hbox(Gtk::ORIENTATION_HORIZONTAL,5)
|
|||
search_binding = Glib::Binding::bind_property(search_button.property_active(),
|
||||
searchbar.property_search_mode_enabled(),
|
||||
Glib::BINDING_BIDIRECTIONAL);
|
||||
search_entry.signal_changed().connect(sigc::mem_fun(*this, &TextEditor::search_entry_changed));
|
||||
vbox.pack_start(searchbar, Gtk::PACK_SHRINK);
|
||||
|
||||
//A InfoBar
|
||||
|
@ -158,6 +159,15 @@ void TextEditor::buffer1_changed(){
|
|||
|
||||
}
|
||||
|
||||
void TextEditor::search_entry_changed(){
|
||||
const Glib::ustring text = search_entry.get_text();
|
||||
Gtk::TextIter start, end;
|
||||
if(buffer1->begin().forward_search(text,Gtk::TEXT_SEARCH_CASE_INSENSITIVE,start,end)){
|
||||
buffer1->select_range(start,end);
|
||||
textview1.scroll_to(start);
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditor::btncopy_clicked(){
|
||||
//Get Text
|
||||
Glib::ustring text;
|
||||
|
|
|
@ -15,7 +15,6 @@ private:
|
|||
Gtk::SearchEntry search_entry;
|
||||
Glib::RefPtr<Gtk::Builder> menu_builder;
|
||||
Glib::RefPtr<Glib::Binding> search_binding;
|
||||
Gtk::Box *searchbox;
|
||||
|
||||
//Window widgets
|
||||
Gtk::Box vbox,hbox,*infobox;
|
||||
|
@ -38,6 +37,7 @@ private:
|
|||
void btnpaste_clicked();
|
||||
void btnclear_clicked();
|
||||
void buffer1_changed();
|
||||
void search_entry_changed();
|
||||
void clipboard_receive(const Glib::ustring &text);
|
||||
void infobar_response(int response);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue