Format the code

This commit is contained in:
daleclack 2022-07-24 18:00:51 +08:00
parent 6003ea642a
commit 21cf6827b4
3 changed files with 19 additions and 13 deletions

View File

@ -18,7 +18,8 @@ TextEditor::TextEditor()
// Load window config from json file
int width = 800, height = 450;
std::ifstream json_file("config.json");
if(json_file.is_open()){
if (json_file.is_open())
{
json data = json::parse(json_file);
width = data["width"];
height = data["height"];
@ -100,7 +101,8 @@ TextEditor::TextEditor()
infobar.hide();
}
bool TextEditor::window_delete_event(GdkEventAny *event){
bool TextEditor::window_delete_event(GdkEventAny *event)
{
// Create json raw data
json data = json::parse(R"({
"width":800,
@ -114,7 +116,8 @@ bool TextEditor::window_delete_event(GdkEventAny *event){
// Output json data to file
std::fstream outfile;
outfile.open("config.json", std::ios_base::out);
if(outfile.is_open()){
if (outfile.is_open())
{
outfile << data;
}
outfile.close();

View File

@ -2,18 +2,20 @@
#include <gtkmm.h>
class TextEditor : public Gtk::ApplicationWindow{
class TextEditor : public Gtk::ApplicationWindow
{
public:
TextEditor();
private:
//Header widgets
// Header widgets
Gtk::HeaderBar header;
Gtk::MenuButton menubtn;
Gtk::Popover popover;
Gtk::ToggleButton search_button;
Glib::RefPtr<Gtk::Builder> menu_builder;
//SearchBar
// SearchBar
Gtk::SearchBar searchbar;
Gtk::SearchEntry search_entry;
Gtk::Box searchbox;
@ -21,20 +23,20 @@ private:
Glib::RefPtr<Glib::Binding> search_binding;
Gtk::TextIter curr_iter_up, curr_iter_down;
//Window widgets
Gtk::Box vbox,hbox,*infobox;
Gtk::ScrolledWindow sw1,sw2;
// Window widgets
Gtk::Box vbox, hbox, *infobox;
Gtk::ScrolledWindow sw1, sw2;
Glib::RefPtr<Gtk::TextBuffer> buffer1;
Gtk::TextView textview1;
Gtk::InfoBar infobar;
Gtk::Label label1;
//File Dialog
// File Dialog
Glib::RefPtr<Gtk::FileChooserNative> dialog;
Glib::ustring curr_filename;
bool file_opened;
//Signal Handlers
// Signal Handlers
bool window_delete_event(GdkEventAny *event);
// File Operation functions

View File

@ -1,7 +1,8 @@
#include "TextEditor.hh"
int main(int argc,char **argv){
auto app = Gtk::Application::create(argc,argv,"org.gtk.daleclack");
int main(int argc, char **argv)
{
auto app = Gtk::Application::create(argc, argv, "org.gtk.daleclack");
TextEditor textwin;
return app->run(textwin);
}