Margin login window to Gtkmm4

This commit is contained in:
daleclack 2023-05-11 13:32:15 +08:00
parent fbb51c5441
commit 7017feb194
8 changed files with 131 additions and 164 deletions

View File

@ -1,6 +1,6 @@
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.0.0)
project(My_GtkUI VERSION 5.6.0)
project(My_GtkUI VERSION 6.0.0)
#Add GCR_CMake
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../GCR_CMake/macros)
@ -19,18 +19,11 @@ include_directories(src/core src/ui src/apps src/panels src/image_app
src/game24_app src/calc_app src/mine_app)
find_package (PkgConfig REQUIRED)
pkg_check_modules (GTKMM3 REQUIRED gtkmm-3.0)
include_directories (${GTKMM3_INCLUDE_DIRS})
link_directories (${GTKMM3_LIBRARY_DIRS})
pkg_check_modules (GTKMM REQUIRED gtkmm-4.0)
include_directories (${GTKMM_INCLUDE_DIRS})
link_directories (${GTKMM_LIBRARY_DIRS})
set(SOURCES src/core/main.cc src/core/MyWin.cc src/core/MyStack.cc src/cfgfile/cfgfile.cc
src/ui/MyFinder.cc src/ui/MyPrefs.cc src/ui/MyDock.cc
src/draw_app/drawing.cc src/file_app/FileWindow.cc src/game_app/Game.cc
src/game24_app/Game24.cc src/game24_app/Game24Win.cc
src/image_app/ImageApp.cc src/image_app/MyImage.cc
src/run_app/Runner.cc src/text_app/TextEditor.cc
src/calc_app/calc.cc src/calc_app/CalcApp.cc
src/mine_app/InputBox.cc src/mine_app/MineSweeper.cc src/mine_app/ScoresWin.cc)
set(SOURCES src/core/main.cc src/core/MyWin.cc src/core/MyStack.cc)
#Compile resources with GCR_CMake
@ -138,5 +131,5 @@ add_custom_command(TARGET ${PROJECT_NAME}
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore)
SET (CMAKE_EXTRA_CXX_FLAGS ${GTKMM3_CFLAGS_OTHER})
target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES} -lpthread)
SET (CMAKE_EXTRA_CXX_FLAGS ${GTKMM_CFLAGS_OTHER})
target_link_libraries (${PROJECT_NAME} ${GTKMM_LIBRARIES} -lpthread)

View File

@ -184,7 +184,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -224,7 +224,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image3</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -239,7 +239,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image2</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -254,7 +254,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image25</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -269,7 +269,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image4</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -284,7 +284,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image5</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -299,7 +299,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image6</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -314,7 +314,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image7</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -329,7 +329,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image23</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -344,7 +344,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image26</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -406,7 +406,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image21</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="always-show-image">True</property>
</object>
<packing>
@ -563,7 +563,7 @@
<property name="receives-default">True</property>
<property name="action-name">win.about</property>
<property name="image">image8</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -581,7 +581,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image10</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -597,7 +597,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image9</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -613,7 +613,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image11</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -629,7 +629,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image12</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -645,7 +645,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image13</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -661,7 +661,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image14</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -677,7 +677,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image15</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -693,7 +693,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image16</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -709,7 +709,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image17</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -725,7 +725,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image18</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -741,7 +741,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image19</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -757,7 +757,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image20</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -773,7 +773,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image22</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -789,7 +789,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image24</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>
@ -805,7 +805,7 @@
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image27</property>
<property name="relief">none</property>
<property name="has-frame">0</property>
<property name="image-position">top</property>
<property name="always-show-image">True</property>
</object>

View File

@ -1,83 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<requires lib="gtk" version="4.0"/>
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkBox" id="login_page">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="user_image">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">48</property>
<property name="icon-name">My_GtkUI</property>
<object class="GtkStackPage">
<property name="title" translatable="1">page0</property>
<property name="child">
<object class="GtkBox" id="login_page">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="user_image">
<property name="pixel-size">48</property>
<property name="icon-name">My_GtkUI</property>
</object>
</child>
<child>
<object class="GtkLabel" id="user_label">
<property name="label" translatable="1">dale</property>
</object>
</child>
<child>
<object class="GtkButton" id="btnlogin">
<property name="label" translatable="1">Login</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="user_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">dale</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnlogin">
<property name="label" translatable="yes">Login</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="relief">none</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</property>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="main_page">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<object class="GtkStackPage">
<property name="title" translatable="1">page1</property>
<property name="child">
<object class="GtkBox" id="main_page">
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</property>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>

View File

@ -5,10 +5,10 @@ MyStack::MyStack()
{
// Get Widgets
stackbuilder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/stack.ui");
stackbuilder->get_widget("main_stack", stack);
stackbuilder->get_widget("login_page", login_page);
stackbuilder->get_widget("main_page", main_page);
stackbuilder->get_widget("btnlogin", btnlogin);
stack = stackbuilder->get_widget<Gtk::Stack>("main_stack");
login_page = stackbuilder->get_widget<Gtk::Box>("login_page");
main_page = stackbuilder->get_widget<Gtk::Box>("main_page");
btnlogin = stackbuilder->get_widget<Gtk::Button>("btnlogin");
// Link Signals
btnlogin->signal_clicked().connect(sigc::mem_fun(*this, &MyStack::btnlogin_clicked));
@ -16,12 +16,12 @@ MyStack::MyStack()
void MyStack::mystack_init(Gtk::Window *window, Gtk::Image *m_back)
{
main_dock->mydock_init(window, m_back);
// main_dock->mydock_init(window, m_back);
}
void MyStack::show_prefs()
{
main_dock->btnset_clicked();
// main_dock->btnset_clicked();
}
void MyStack::logout()
@ -34,24 +34,24 @@ void MyStack::btnlogin_clicked()
stack->set_visible_child(*main_page);
}
void MyStack::set_mydock_mode(DockMode mode)
{
// main_dock->set_dock_mode(mode);
// switch (mode)
// {
// case DockMode::MODE_DOCK:
// std::cout << "dock mode" << std::endl;
// break;
// case DockMode::MODE_PANEL:
// std::cout << "panel mode" << std::endl;
// break;
// default:
// std::cout << "undefined" << std::endl;
// break;
// }
// Add Widget
main_dock = MyDock::create(mode);
main_dock->set_hexpand();
main_dock->set_vexpand();
main_page->pack_start(*main_dock);
}
// void MyStack::set_mydock_mode(DockMode mode)
// {
// // main_dock->set_dock_mode(mode);
// // switch (mode)
// // {
// // case DockMode::MODE_DOCK:
// // std::cout << "dock mode" << std::endl;
// // break;
// // case DockMode::MODE_PANEL:
// // std::cout << "panel mode" << std::endl;
// // break;
// // default:
// // std::cout << "undefined" << std::endl;
// // break;
// // }
// // Add Widget
// main_dock = MyDock::create(mode);
// main_dock->set_hexpand();
// main_dock->set_vexpand();
// main_page->pack_start(*main_dock);
// }

View File

@ -1,7 +1,7 @@
#pragma once
#include <gtkmm.h>
#include "MyDock.hh"
// #include "MyDock.hh"
class MyStack
{
@ -10,7 +10,7 @@ public:
void logout();
void mystack_init(Gtk::Window *window, Gtk::Image *m_back);
void show_prefs();
void set_mydock_mode(DockMode mode);
// void set_mydock_mode(DockMode mode);
// Main Widget
Gtk::Stack *stack;
@ -22,7 +22,7 @@ private:
Gtk::Button *btnlogin;
// Dock Widget
MyDock *main_dock;
// MyDock *main_dock;
// Signal Handlers
void btnlogin_clicked();

View File

@ -2,27 +2,27 @@
#include "winpe.xpm"
MyWin::MyWin()
: menubox(Gtk::ORIENTATION_HORIZONTAL, 0),
: menubox(Gtk::Orientation::HORIZONTAL, 0),
width(1024),
height(576)
{
// Initalize window
set_icon_name("My_GtkUI");
set_title("My GtkUI macOS Version");
get_size_config(width, height, panel_mode);
// get_size_config(width, height, panel_mode);
// Set the display mode of dock
if(panel_mode){
main_stack.set_mydock_mode(DockMode::MODE_PANEL);
}else{
main_stack.set_mydock_mode(DockMode::MODE_DOCK);
}
// if(panel_mode){
// main_stack.set_mydock_mode(DockMode::MODE_PANEL);
// }else{
// main_stack.set_mydock_mode(DockMode::MODE_DOCK);
// }
// Add background
// auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
// auto sized = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
// gtk_image_set_from_pixbuf(m_background.gobj(), sized->gobj());
m_overlay.add(m_background);
m_overlay.set_child(m_background);
// pixbuf.reset();
// sized.reset();
@ -39,21 +39,21 @@ MyWin::MyWin()
// Add context menu
auto menubuilder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/mainmenu.xml");
auto object = menubuilder->get_object("model");
auto gmenu = Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
context_menu.bind_model(gmenu);
context_menu.set_relative_to(m_overlay);
auto object = menubuilder->get_object<Gio::MenuModel>("model");
context_menu.set_menu_model(object);
context_menu.set_has_arrow(false);
context_menu.set_parent(m_overlay);
// Add Gesture for control
gesture = Gtk::GestureMultiPress::create(m_overlay);
gesture = Gtk::GestureClick::create();
m_overlay.add_controller(gesture);
gesture->set_button(GDK_BUTTON_SECONDARY);
gesture->signal_pressed().connect(sigc::mem_fun(*this, &MyWin::press));
// Initalize Stack
main_stack.mystack_init(this, &m_background);
// main_stack.mystack_init(this, &m_background);
add(m_overlay);
show_all_children();
set_child(m_overlay);
}
void MyWin::press(int n_press, double x, double y)
@ -74,7 +74,7 @@ void MyWin::back_activated()
}
void MyWin::expand_activated(){
main_stack.set_mydock_mode(DockMode::MODE_PANEL);
// main_stack.set_mydock_mode(DockMode::MODE_PANEL);
}
void MyWin::about_activated()
@ -87,7 +87,7 @@ void MyWin::about_activated()
// Version information
char *version;
version = g_strdup_printf("5.6\nRunning Against: Gtkmm %d.%d.%d",
version = g_strdup_printf("6.0\nRunning Against: Gtkmm %d.%d.%d",
GTKMM_MAJOR_VERSION,
GTKMM_MINOR_VERSION,
GTKMM_MICRO_VERSION);

View File

@ -11,10 +11,10 @@ private:
Gtk::Overlay m_overlay;
Gtk::Image m_background;
Gtk::Box menubox;
Gtk::Popover context_menu;
Gtk::PopoverMenu context_menu;
//Gesture Control
Glib::RefPtr<Gtk::GestureMultiPress> gesture;
Glib::RefPtr<Gtk::GestureClick> gesture;
void press(int n_press,double x,double y);
//Main Stack

View File

@ -2,7 +2,7 @@
int main(int argc,char ** argv){
// Create a application and window, start the application
auto app = Gtk::Application::create(argc,argv,"org.gtk.daleclack");
MyWin window;
return app->run(window);
auto app = Gtk::Application::create("org.gtk.daleclack");
// MyWin window;
return app->make_window_and_run<MyWin>(argc, argv);
}