Depercate gtk132

This commit is contained in:
daleclack 2022-07-04 17:08:28 +08:00
parent 5bb72e6ba7
commit 73e9a2b25e
4 changed files with 57 additions and 1 deletions

View File

@ -31,6 +31,7 @@ set(SOURCE_FILE src/main.cc src/TextEditor.cc)
#Compile Resource
set(RESOURCE_LIST
searchbar.ui
text_menu.xml)
compile_gresources(RESOURCE_FILE

View File

@ -0,0 +1,36 @@
<?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>

View File

@ -17,7 +17,9 @@ hbox(Gtk::ORIENTATION_HORIZONTAL,5)
header.set_decoration_layout("close,minimize,maximize:menu");
header.set_show_close_button();
menubtn.set_image_from_icon_name("open-menu");
search_button.set_image_from_icon_name("find");
header.pack_end(menubtn);
header.pack_end(search_button);
header.set_title("Simple Text Editor");
set_titlebar(header);
@ -44,6 +46,16 @@ hbox(Gtk::ORIENTATION_HORIZONTAL,5)
add_action("text_paste",sigc::mem_fun(*this,&TextEditor::btnpaste_clicked));
add_action("text_clear",sigc::mem_fun(*this,&TextEditor::btnclear_clicked));
//Add searchbar
searchbar_builder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/searchbar.ui");
searchbar_builder->get_widget("searchbar",searchbar);
searchbar_builder->get_widget("searchentry",search_entry);
searchbar_builder->get_widget("search_box",searchbox);
Glib::Binding::bind_property(search_button.property_active(),
searchbar->property_search_mode_enabled(),
Glib::BINDING_BIDIRECTIONAL);
vbox.pack_start(*searchbox);
//A InfoBar
infobar.add_button("OK",Gtk::RESPONSE_OK);
infobar.signal_response().connect(sigc::mem_fun(*this,&TextEditor::infobar_response));

View File

@ -10,7 +10,11 @@ private:
Gtk::HeaderBar header;
Gtk::MenuButton menubtn;
Gtk::Popover popover;
Glib::RefPtr<Gtk::Builder> menu_builder;
Gtk::ToggleButton search_button;
Gtk::SearchBar *searchbar;
Gtk::SearchEntry *search_entry;
Glib::RefPtr<Gtk::Builder> menu_builder, searchbar_builder;
Gtk::Box *searchbox;
//Window widgets
Gtk::Box vbox,hbox,*infobox;
@ -19,8 +23,11 @@ private:
Gtk::TextView textview1;
Gtk::InfoBar infobar;
Gtk::Label label1;
//File Dialog
Glib::RefPtr<Gtk::FileChooserNative> dialog;
Glib::ustring curr_filename;
//Signal Handlers
void btnopen_clicked();
void opendialog_response(int response);