From 0a8d0291db7a6944e05a9e5c1a34fed74f219bde Mon Sep 17 00:00:00 2001 From: daleclack Date: Wed, 2 Feb 2022 11:33:44 +0800 Subject: [PATCH] Add page for gtk123 --- Gtkmm3/gtk123_backprefs2/CMakeLists.txt | 5 +- .../gtk123_backprefs2/res/folder-images.svg | 36 +++++++ Gtkmm3/gtk123_backprefs2/res/folder.svg | 35 +++++++ .../res/icons/16x16/actions/list-add.svg | 13 +++ .../res/icons/16x16/actions/list-remove.svg | 8 ++ Gtkmm3/gtk123_backprefs2/res/image_file.svg | 6 ++ Gtkmm3/gtk123_backprefs2/res/prefs_stack.ui | 98 +++++++++++++++++++ Gtkmm3/gtk123_backprefs2/res/stack.ui | 12 --- Gtkmm3/gtk123_backprefs2/src/MyPrefs.cc | 30 +++++- Gtkmm3/gtk123_backprefs2/src/MyPrefs.hh | 5 +- 10 files changed, 230 insertions(+), 18 deletions(-) create mode 100644 Gtkmm3/gtk123_backprefs2/res/folder-images.svg create mode 100644 Gtkmm3/gtk123_backprefs2/res/folder.svg create mode 100644 Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-add.svg create mode 100644 Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-remove.svg create mode 100644 Gtkmm3/gtk123_backprefs2/res/image_file.svg create mode 100644 Gtkmm3/gtk123_backprefs2/res/prefs_stack.ui delete mode 100644 Gtkmm3/gtk123_backprefs2/res/stack.ui diff --git a/Gtkmm3/gtk123_backprefs2/CMakeLists.txt b/Gtkmm3/gtk123_backprefs2/CMakeLists.txt index f67ef29..c55d4aa 100644 --- a/Gtkmm3/gtk123_backprefs2/CMakeLists.txt +++ b/Gtkmm3/gtk123_backprefs2/CMakeLists.txt @@ -27,14 +27,15 @@ set(RESOURCE_LIST icons/16x16/actions/list-remove.svg folder.svg folder-images.svg - image_file.svg) + image_file.svg + prefs_stack.ui) compile_gresources(RESOURCE_FILE XML_OUT TYPE EMBED_C RESOURCES ${RESOURCE_LIST} PREFIX "/org/gtk/daleclack" - SOURCE_DIR ${PROJECT_SOURCE_DIR}/../default_res) + SOURCE_DIR ${PROJECT_SOURCE_DIR}/res) # Add a custom target to the makefile. Now make builds our resource file. # It depends on the output RESOURCE_FILE. diff --git a/Gtkmm3/gtk123_backprefs2/res/folder-images.svg b/Gtkmm3/gtk123_backprefs2/res/folder-images.svg new file mode 100644 index 0000000..fb2d906 --- /dev/null +++ b/Gtkmm3/gtk123_backprefs2/res/folder-images.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gtkmm3/gtk123_backprefs2/res/folder.svg b/Gtkmm3/gtk123_backprefs2/res/folder.svg new file mode 100644 index 0000000..e83bb59 --- /dev/null +++ b/Gtkmm3/gtk123_backprefs2/res/folder.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-add.svg b/Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-add.svg new file mode 100644 index 0000000..f76d5bb --- /dev/null +++ b/Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-add.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-remove.svg b/Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-remove.svg new file mode 100644 index 0000000..d4f208c --- /dev/null +++ b/Gtkmm3/gtk123_backprefs2/res/icons/16x16/actions/list-remove.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/Gtkmm3/gtk123_backprefs2/res/image_file.svg b/Gtkmm3/gtk123_backprefs2/res/image_file.svg new file mode 100644 index 0000000..092f227 --- /dev/null +++ b/Gtkmm3/gtk123_backprefs2/res/image_file.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/Gtkmm3/gtk123_backprefs2/res/prefs_stack.ui b/Gtkmm3/gtk123_backprefs2/res/prefs_stack.ui new file mode 100644 index 0000000..7e27515 --- /dev/null +++ b/Gtkmm3/gtk123_backprefs2/res/prefs_stack.ui @@ -0,0 +1,98 @@ + + + + + + True + False + True + True + vertical + + + True + False + center + main_stack + + + False + True + 0 + + + + + True + False + + + True + False + vertical + + + + + + + + + + + + page0 + Background Preferences + + + + + + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + page1 + Window Size Config + 1 + + + + + False + True + 1 + + + + + + + diff --git a/Gtkmm3/gtk123_backprefs2/res/stack.ui b/Gtkmm3/gtk123_backprefs2/res/stack.ui deleted file mode 100644 index 6111dc1..0000000 --- a/Gtkmm3/gtk123_backprefs2/res/stack.ui +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - True - False - - - - - diff --git a/Gtkmm3/gtk123_backprefs2/src/MyPrefs.cc b/Gtkmm3/gtk123_backprefs2/src/MyPrefs.cc index 777cad3..ca52bec 100644 --- a/Gtkmm3/gtk123_backprefs2/src/MyPrefs.cc +++ b/Gtkmm3/gtk123_backprefs2/src/MyPrefs.cc @@ -3,7 +3,6 @@ #include "../Gtk4/img7.xpm" #include "image_types.hh" #include -#include MyPrefs::MyPrefs() : main_box(Gtk::ORIENTATION_VERTICAL, 10), @@ -89,11 +88,20 @@ MyPrefs::MyPrefs() // Add Main Box to window const int margin_value = 15; + main_box.set_hexpand(); + main_box.set_vexpand(); main_box.set_margin_top(margin_value); main_box.set_margin_bottom(margin_value); main_box.set_margin_start(margin_value); main_box.set_margin_end(margin_value); - add(main_box); + + //Get Widgets for multi pages + stackbuilder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/prefs_stack.ui"); + stackbuilder->get_widget("stack_box",stack_box); + stackbuilder->get_widget("back_page",back_page); + + back_page->pack_start(main_box); + add(*stack_box); show_all_children(); } @@ -199,6 +207,22 @@ int MyPrefs::sort_func(const Gtk::TreeModel::iterator &a, const Gtk::TreeModel:: } } +bool MyPrefs::icasecompare(const std::string &a, const std::string &b) +{ + if (a.length() == b.length()) + { + return std::equal(a.begin(), a.end(), b.begin(), + [](char a, char b) + { + return tolower(a) == tolower(b); + }); + } + else + { + return false; + } +} + void MyPrefs::update_images_view(std::string &folder_path) { // Unselect everything @@ -235,7 +259,7 @@ void MyPrefs::update_images_view(std::string &folder_path) for (int i = 0; supported_globs[i] != NULL; i++) { std::string glob = std::string(supported_globs[i]); - if (glob == pattern) + if (icasecompare(glob, pattern)) { file_valid = true; break; diff --git a/Gtkmm3/gtk123_backprefs2/src/MyPrefs.hh b/Gtkmm3/gtk123_backprefs2/src/MyPrefs.hh index 6508a22..f2a57b5 100644 --- a/Gtkmm3/gtk123_backprefs2/src/MyPrefs.hh +++ b/Gtkmm3/gtk123_backprefs2/src/MyPrefs.hh @@ -1,6 +1,7 @@ #pragma once #include +#include class MyPrefs : public Gtk::Window { @@ -34,10 +35,11 @@ private: // Widget for parent window Gtk::Image *background1; + //Page switcher and another page Glib::RefPtr stackbuilder; + Gtk::Box *stack_box, *back_page; // Child Widgets - Gtk::Stack *stack; Gtk::TreeView folders_view, images_view; Gtk::ScrolledWindow sw_folders, sw_images; Gtk::Box main_box, views_box, btnbox; @@ -50,6 +52,7 @@ private: // Sort for ListStore int sort_func(const Gtk::TreeModel::iterator &a, const Gtk::TreeModel::iterator &b); + bool icasecompare(const std::string &a, const std::string &b); // Signal Handlers void btnadd_clicked();