diff --git a/XeRelease_Gtkmm4/CMakeLists.txt b/XeRelease_Gtkmm4/CMakeLists.txt index 426f27c..7656618 100644 --- a/XeRelease_Gtkmm4/CMakeLists.txt +++ b/XeRelease_Gtkmm4/CMakeLists.txt @@ -21,8 +21,8 @@ pkg_check_modules (GTKMM4 REQUIRED gtkmm-4.0) include_directories (${GTKMM4_INCLUDE_DIRS}) link_directories (${GTKMM4_LIBRARY_DIRS}) -set(SOURCES src/main.cc src/MyWin.cc src/MyPrefs.cc - src/xerelease.cc src/xeapi.cc) +set(SOURCES src/main.cc src/MyWin.cc src/MsgBox.cc + src/MyPrefs.cc src/xerelease.cc src/xeapi.cc) #Compile resources with GCR_CMake set(RESOURCE_LIST diff --git a/XeRelease_Gtkmm4/res/prefs.ui b/XeRelease_Gtkmm4/res/prefs.ui index e57c87d..4f34ef1 100644 --- a/XeRelease_Gtkmm4/res/prefs.ui +++ b/XeRelease_Gtkmm4/res/prefs.ui @@ -14,6 +14,29 @@ Release Configs: + + + 200 + never + 350 + + + + + horizontal + center + + + Add Item + + + + + Remove Item + + + + center diff --git a/XeRelease_Gtkmm4/src/MsgBox.cc b/XeRelease_Gtkmm4/src/MsgBox.cc new file mode 100644 index 0000000..d4f3717 --- /dev/null +++ b/XeRelease_Gtkmm4/src/MsgBox.cc @@ -0,0 +1,83 @@ +#include "MsgBox.hh" + +MsgBox::MsgBox(Gtk::Window &parent) + : vbox(Gtk::Orientation::VERTICAL, 5), + hbox(Gtk::Orientation::HORIZONTAL, 5), + btn_box(Gtk::Orientation::HORIZONTAL, 5), + btn_ok("OK") +{ + // Initalize MsgBox + set_icon_name("Xe-Release"); + set_default_size(300, 150); + // add_button("OK", Gtk::ResponseType::OK); + set_transient_for(parent); + // Add Message and icon + image.set_from_icon_name("Xe-Release"); + image.set_icon_size(Gtk::IconSize::LARGE); + image.set_size_request(64, 64); + // vbox = get_content_area(); + hbox.append(image); + hbox.append(msg_label); + + // Add message box to the main box + hbox.set_expand(); + hbox.set_halign(Gtk::Align::FILL); + hbox.set_valign(Gtk::Align::FILL); + vbox.append(hbox); + vbox.set_margin(5); + + // Add button + btn_box.append(btn_ok); + btn_box.set_halign(Gtk::Align::END); + btn_ok.set_halign(Gtk::Align::END); + btn_ok.signal_clicked().connect(sigc::mem_fun(*this, &MsgBox::on_response)); + vbox.append(btn_box); + + set_child(vbox); +} + +MsgBox::MsgBox() + : vbox(Gtk::Orientation::VERTICAL, 5), + hbox(Gtk::Orientation::HORIZONTAL, 5), + btn_box(Gtk::Orientation::HORIZONTAL, 5), + btn_ok("OK") +{ + // Initalize MsgBox + set_icon_name("Xe-Release"); + set_default_size(300, 150); + // add_button("OK", Gtk::ResponseType::OK); + // set_transient_for(parent); + // Add Message and icon + image.set_from_icon_name("Xe-Release"); + image.set_icon_size(Gtk::IconSize::LARGE); + image.set_size_request(64, 64); + // vbox = get_content_area(); + hbox.append(image); + hbox.append(msg_label); + + // Add message box to the main box + hbox.set_expand(); + hbox.set_halign(Gtk::Align::FILL); + hbox.set_valign(Gtk::Align::FILL); + vbox.append(hbox); + vbox.set_margin(5); + + // Add button + btn_box.append(btn_ok); + btn_box.set_halign(Gtk::Align::END); + btn_ok.set_halign(Gtk::Align::END); + btn_ok.signal_clicked().connect(sigc::mem_fun(*this, &MsgBox::on_response)); + vbox.append(btn_box); + + set_child(vbox); +} + +void MsgBox::Init(Glib::ustring msg) +{ + msg_label.set_label(msg); +} + +void MsgBox::on_response() +{ + hide(); +} diff --git a/XeRelease_Gtkmm4/src/MsgBox.hh b/XeRelease_Gtkmm4/src/MsgBox.hh new file mode 100644 index 0000000..ccf906f --- /dev/null +++ b/XeRelease_Gtkmm4/src/MsgBox.hh @@ -0,0 +1,21 @@ +#pragma once + +#include + +class MsgBox : public Gtk::Window +{ +public: + MsgBox(Gtk::Window &parent); + MsgBox(); + void Init(Glib::ustring msg); + +private: + // Child Widgets + Gtk::Image image; + Gtk::Label msg_label; + Gtk::Box vbox, hbox, btn_box; + Gtk::Button btn_ok; + + // Signal Handler + void on_response(); +}; diff --git a/XeRelease_Gtkmm4/src/MyPrefs.cc b/XeRelease_Gtkmm4/src/MyPrefs.cc index 5410c6c..ed06a31 100644 --- a/XeRelease_Gtkmm4/src/MyPrefs.cc +++ b/XeRelease_Gtkmm4/src/MyPrefs.cc @@ -5,6 +5,9 @@ MyPrefs::MyPrefs(BaseObjectType *cobject, const Glib::RefPtr &ref_ ref_Glade(ref_builder) { // Get Widgets + version_sw = ref_builder->get_widget("version_sw"); + btnadd = ref_builder->get_widget("btn_add"); + btnremove = ref_builder->get_widget("btn_remove"); entry_path = ref_builder->get_widget("entry_path"); btnpath = ref_builder->get_widget("btnpath"); btnok = ref_builder->get_widget("btn_ok"); @@ -211,84 +214,3 @@ void MyPrefs::dialog_response(int response_id) dialog.reset(); } -MsgBox::MsgBox(Gtk::Window &parent) - : vbox(Gtk::Orientation::VERTICAL, 5), - hbox(Gtk::Orientation::HORIZONTAL, 5), - btn_box(Gtk::Orientation::HORIZONTAL, 5), - btn_ok("OK") -{ - // Initalize MsgBox - set_icon_name("Xe-Release"); - set_default_size(300, 150); - // add_button("OK", Gtk::ResponseType::OK); - set_transient_for(parent); - // Add Message and icon - image.set_from_icon_name("Xe-Release"); - image.set_icon_size(Gtk::IconSize::LARGE); - image.set_size_request(64, 64); - // vbox = get_content_area(); - hbox.append(image); - hbox.append(msg_label); - - // Add message box to the main box - hbox.set_expand(); - hbox.set_halign(Gtk::Align::FILL); - hbox.set_valign(Gtk::Align::FILL); - vbox.append(hbox); - vbox.set_margin(5); - - // Add button - btn_box.append(btn_ok); - btn_box.set_halign(Gtk::Align::END); - btn_ok.set_halign(Gtk::Align::END); - btn_ok.signal_clicked().connect(sigc::mem_fun(*this, &MsgBox::on_response)); - vbox.append(btn_box); - - set_child(vbox); -} - -MsgBox::MsgBox() - : vbox(Gtk::Orientation::VERTICAL, 5), - hbox(Gtk::Orientation::HORIZONTAL, 5), - btn_box(Gtk::Orientation::HORIZONTAL, 5), - btn_ok("OK") -{ - // Initalize MsgBox - set_icon_name("Xe-Release"); - set_default_size(300, 150); - // add_button("OK", Gtk::ResponseType::OK); - // set_transient_for(parent); - // Add Message and icon - image.set_from_icon_name("Xe-Release"); - image.set_icon_size(Gtk::IconSize::LARGE); - image.set_size_request(64, 64); - // vbox = get_content_area(); - hbox.append(image); - hbox.append(msg_label); - - // Add message box to the main box - hbox.set_expand(); - hbox.set_halign(Gtk::Align::FILL); - hbox.set_valign(Gtk::Align::FILL); - vbox.append(hbox); - vbox.set_margin(5); - - // Add button - btn_box.append(btn_ok); - btn_box.set_halign(Gtk::Align::END); - btn_ok.set_halign(Gtk::Align::END); - btn_ok.signal_clicked().connect(sigc::mem_fun(*this, &MsgBox::on_response)); - vbox.append(btn_box); - - set_child(vbox); -} - -void MsgBox::Init(Glib::ustring msg) -{ - msg_label.set_label(msg); -} - -void MsgBox::on_response() -{ - hide(); -} diff --git a/XeRelease_Gtkmm4/src/MyPrefs.hh b/XeRelease_Gtkmm4/src/MyPrefs.hh index 80bfc29..85acbf7 100644 --- a/XeRelease_Gtkmm4/src/MyPrefs.hh +++ b/XeRelease_Gtkmm4/src/MyPrefs.hh @@ -4,28 +4,10 @@ #include #include "json_nlohmann/json.hpp" #include "config.hh" +#include "MsgBox.hh" using json = nlohmann::json; -class MsgBox : public Gtk::Window -{ -public: - MsgBox(Gtk::Window &parent); - MsgBox(); - void Init(Glib::ustring msg); - -private: - // Child Widgets - Gtk::Image image; - Gtk::Label msg_label; - Gtk::Box vbox, hbox, btn_box; - Gtk::Button btn_ok; - - // Signal Handler - void on_response(); - -}; - class MyPrefs : public Gtk::Box { public: @@ -43,6 +25,8 @@ private: Gtk::Window *parent_win; // Child widgets + Gtk::ScrolledWindow *version_sw; + Gtk::Button *btnadd, *btnremove; Gtk::Entry *entry_path; Gtk::Button *btnpath, *btnok, *btncancel; bool dark_mode;