Fix MyDock Module

This commit is contained in:
daleclack 2023-05-12 16:11:31 +08:00
parent 8fcee10f63
commit e5216e1249
6 changed files with 398 additions and 396 deletions

View File

@ -23,7 +23,8 @@ pkg_check_modules (GTKMM REQUIRED gtkmm-4.0)
include_directories (${GTKMM_INCLUDE_DIRS}) include_directories (${GTKMM_INCLUDE_DIRS})
link_directories (${GTKMM_LIBRARY_DIRS}) link_directories (${GTKMM_LIBRARY_DIRS})
set(SOURCES src/core/main.cc src/core/MyWin.cc src/core/MyStack.cc) set(SOURCES src/core/main.cc src/core/MyWin.cc src/core/MyStack.cc
src/ui/MyDock.cc src/ui/MyFinder.cc)
#Compile resources with GCR_CMake #Compile resources with GCR_CMake

View File

@ -34,24 +34,24 @@ void MyStack::btnlogin_clicked()
stack->set_visible_child(*main_page); stack->set_visible_child(*main_page);
} }
// void MyStack::set_mydock_mode(DockMode mode) void MyStack::set_mydock_mode(DockMode mode)
{
// main_dock->set_dock_mode(mode);
// switch (mode)
// { // {
// // main_dock->set_dock_mode(mode); // case DockMode::MODE_DOCK:
// // switch (mode) // std::cout << "dock mode" << std::endl;
// // { // break;
// // case DockMode::MODE_DOCK: // case DockMode::MODE_PANEL:
// // std::cout << "dock mode" << std::endl; // std::cout << "panel mode" << std::endl;
// // break; // break;
// // case DockMode::MODE_PANEL: // default:
// // std::cout << "panel mode" << std::endl; // std::cout << "undefined" << std::endl;
// // break; // 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->append(*main_dock);
// } // }
// Add Widget
main_dock = MyDock::create(mode);
main_dock->set_hexpand();
main_dock->set_vexpand();
main_page->append(*main_dock);
}

View File

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

View File

@ -11,52 +11,52 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
launchpad_shown(false) launchpad_shown(false)
{ {
// Get Widgets // Get Widgets
ref_builder->get_widget("finder_box", finder_box); finder_box = ref_builder->get_widget<Gtk::Box>("finder_box");
ref_builder->get_widget("dock_box", dock_box); dock_box = ref_builder->get_widget<Gtk::Box>("dock_box");
ref_builder->get_widget("dock_left", dock_left); dock_left = ref_builder->get_widget<Gtk::Box>("dock_left");
ref_builder->get_widget("dock_right", dock_right); dock_right = ref_builder->get_widget<Gtk::Box>("dock_right");
ref_builder->get_widget("dock_bottom", dock_bottom); dock_bottom = ref_builder->get_widget<Gtk::Box>("dock_bottom");
ref_builder->get_widget("icons_box", icons_box); icons_box = ref_builder->get_widget<Gtk::Box>("icons_box");
ref_builder->get_widget("btnlaunch", btnlaunch); btnlaunch = ref_builder->get_widget<Gtk::Button>("btnlaunch");
ref_builder->get_widget("btndraw", btndraw); btndraw = ref_builder->get_widget<Gtk::Button>("btndraw");
ref_builder->get_widget("btnfiles", btnfiles); btnfiles = ref_builder->get_widget<Gtk::Button>("btnfiles");
ref_builder->get_widget("btngame", btngame); btngame = ref_builder->get_widget<Gtk::Button>("btngame");
ref_builder->get_widget("btnedit", btnedit); btnedit = ref_builder->get_widget<Gtk::Button>("btnedit");
ref_builder->get_widget("btnimage", btnimage); btnimage = ref_builder->get_widget<Gtk::Button>("btnimage");
ref_builder->get_widget("btnset", btnset); btnset = ref_builder->get_widget<Gtk::Button>("btnset");
ref_builder->get_widget("btngame24", btngame24); btngame24 = ref_builder->get_widget<Gtk::Button>("btngame24");
ref_builder->get_widget("btncalc", btncalc); btncalc = ref_builder->get_widget<Gtk::Button>("btncalc");
ref_builder->get_widget("btnmine", btnmine); btnmine = ref_builder->get_widget<Gtk::Button>("btnmine");
ref_builder->get_widget("separator_start", separator_start); separator_start = ref_builder->get_widget<Gtk::Separator>("separator_start");
ref_builder->get_widget("separator_2", separator_2); separator_2 = ref_builder->get_widget<Gtk::Separator>("separator_2");
ref_builder->get_widget("separator_3", separator_3); separator_3 = ref_builder->get_widget<Gtk::Separator>("separator_3");
ref_builder->get_widget("separator_end", separator_end); separator_end = ref_builder->get_widget<Gtk::Separator>("separator_end");
ref_builder->get_widget("icons_sw", icons_sw); icons_sw = ref_builder->get_widget<Gtk::ScrolledWindow>("icons_sw");
ref_builder->get_widget("launchpad_stack", launchpad_stack); launchpad_stack = ref_builder->get_widget<Gtk::Stack>("launchpad_stack");
ref_builder->get_widget("default_page", default_page); default_page = ref_builder->get_widget<Gtk::Grid>("default_page");
ref_builder->get_widget("launchpad_page", launchpad_page); launchpad_page = ref_builder->get_widget<Gtk::Grid>("launchpad_page");
ref_builder->get_widget("apps_grid", apps_grid); apps_grid = ref_builder->get_widget<Gtk::Grid>("apps_grid");
ref_builder->get_widget("padaud", padaud); padaud = ref_builder->get_widget<Gtk::Button>("padaud");
ref_builder->get_widget("padgedit", padgedit); padgedit = ref_builder->get_widget<Gtk::Button>("padgedit");
ref_builder->get_widget("padvlc", padvlc); padvlc = ref_builder->get_widget<Gtk::Button>("padvlc");
ref_builder->get_widget("padnote", padnote); padnote = ref_builder->get_widget<Gtk::Button>("padnote");
ref_builder->get_widget("padvlc_win32", padvlc_win32); padvlc_win32 = ref_builder->get_widget<Gtk::Button>("padvlc_win32");
ref_builder->get_widget("padset", padset); padset = ref_builder->get_widget<Gtk::Button>("padset");
ref_builder->get_widget("paddraw", paddraw); paddraw = ref_builder->get_widget<Gtk::Button>("paddraw");
ref_builder->get_widget("padfile", padfile); padfile = ref_builder->get_widget<Gtk::Button>("padfile");
ref_builder->get_widget("paddraw", paddraw); paddraw = ref_builder->get_widget<Gtk::Button>("paddraw");
ref_builder->get_widget("padgame", padgame); padgame = ref_builder->get_widget<Gtk::Button>("padgame");
ref_builder->get_widget("padimage", padimage); padimage = ref_builder->get_widget<Gtk::Button>("padimage");
ref_builder->get_widget("padedit", padedit); padedit = ref_builder->get_widget<Gtk::Button>("padedit");
ref_builder->get_widget("padrun", padrun); padrun = ref_builder->get_widget<Gtk::Button>("padrun");
ref_builder->get_widget("padgame24", padgame24); padgame24 = ref_builder->get_widget<Gtk::Button>("padgame24");
ref_builder->get_widget("padcalc", padcalc); padcalc = ref_builder->get_widget<Gtk::Button>("padcalc");
ref_builder->get_widget("padmine", padmine); padmine = ref_builder->get_widget<Gtk::Button>("padmine");
// Create window // // Create window
game_win = Game::create(); // game_win = Game::create();
game24_win = Game24Win::create(); // game24_win = Game24Win::create();
calc_win = CalcApp::create(); // calc_win = CalcApp::create();
// Link signals // Link signals
@ -67,7 +67,7 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
padvlc->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padvlc_clicked)); padvlc->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padvlc_clicked));
padnote->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padnote_clicked)); padnote->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padnote_clicked));
padvlc_win32->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padvlc_win32_clicked)); padvlc_win32->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padvlc_win32_clicked));
padrun->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnrun_clicked)); // padrun->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnrun_clicked));
/* /*
These functions contain a icon on the dock These functions contain a icon on the dock
@ -76,45 +76,45 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
last 1 or 2 signals for the window last 1 or 2 signals for the window
*/ */
btnset->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnset_clicked)); // btnset->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnset_clicked));
padset->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padset_clicked)); // padset->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padset_clicked));
prefs_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::prefs_win_closed)); // prefs_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::prefs_win_closed));
btndraw->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btndraw_clicked)); // btndraw->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btndraw_clicked));
paddraw->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::paddraw_clicked)); // paddraw->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::paddraw_clicked));
draw_app.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::draw_win_closed)); // draw_app.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::draw_win_closed));
draw_app.signal_hide().connect(sigc::mem_fun(*this, &MyDock::draw_win_hide)); // draw_app.signal_hide().connect(sigc::mem_fun(*this, &MyDock::draw_win_hide));
btnfiles->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnfile_clicked)); // btnfiles->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnfile_clicked));
padfile->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padfile_clicked)); // padfile->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padfile_clicked));
file_app.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::file_win_closed)); // file_app.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::file_win_closed));
btngame->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btngame_clicked)); // btngame->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btngame_clicked));
padgame->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padgame_clicked)); // padgame->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padgame_clicked));
game_win->signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::game_win_closed)); // game_win->signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::game_win_closed));
game_win->signal_hide().connect(sigc::mem_fun(*this, &MyDock::game_win_hide)); // game_win->signal_hide().connect(sigc::mem_fun(*this, &MyDock::game_win_hide));
btngame24->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btngame24_clicked)); // btngame24->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btngame24_clicked));
padgame24->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padgame24_clicked)); // padgame24->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padgame24_clicked));
game24_win->signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::game24_win_closed)); // game24_win->signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::game24_win_closed));
game24_win->signal_hide().connect(sigc::mem_fun(*this, &MyDock::game24_win_hide)); // game24_win->signal_hide().connect(sigc::mem_fun(*this, &MyDock::game24_win_hide));
btncalc->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btncalc_clicked)); // btncalc->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btncalc_clicked));
padcalc->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padcalc_clicked)); // padcalc->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padcalc_clicked));
calc_win->signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::calc_win_closed)); // calc_win->signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::calc_win_closed));
calc_win->signal_hide().connect(sigc::mem_fun(*this, &MyDock::calc_win_hide)); // calc_win->signal_hide().connect(sigc::mem_fun(*this, &MyDock::calc_win_hide));
btnimage->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnimage_clicked)); // btnimage->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnimage_clicked));
padimage->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padimage_clicked)); // padimage->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padimage_clicked));
image_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::image_win_closed)); // image_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::image_win_closed));
btnedit->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnedit_clicked)); // btnedit->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnedit_clicked));
padedit->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padedit_clicked)); // padedit->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padedit_clicked));
editor_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::editor_win_closed)); // editor_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::editor_win_closed));
btnmine->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnmine_clicked)); // btnmine->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::btnmine_clicked));
padmine->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padmine_clicked)); // padmine->signal_clicked().connect(sigc::mem_fun(*this, &MyDock::padmine_clicked));
mine_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::mine_win_closed)); // mine_win.signal_delete_event().connect(sigc::mem_fun(*this, &MyDock::mine_win_closed));
// Add Finder // Add Finder
finder_box->append(finder); finder_box->append(finder);
@ -129,7 +129,8 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
// Set dock position // Set dock position
// The dock can be positioned at the left, right and the bottom of the window // The dock can be positioned at the left, right and the bottom of the window
auto dock_pos = prefs_win.get_dock_pos(); // auto dock_pos = prefs_win.get_dock_pos();
auto dock_pos = DockPos::POS_LEFT;
switch (dock_pos) switch (dock_pos)
{ {
case DockPos::POS_LEFT: case DockPos::POS_LEFT:
@ -168,18 +169,18 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
case DockMode::MODE_PANEL: case DockMode::MODE_PANEL:
if(dock_pos == DockPos::POS_BOTTOM){ if(dock_pos == DockPos::POS_BOTTOM){
dock_box->set_hexpand(); dock_box->set_hexpand();
dock_box->set_halign(Gtk::ALIGN_FILL); dock_box->set_halign(Gtk::Align::FILL);
icons_sw->set_hexpand(); icons_sw->set_hexpand();
}else{ }else{
dock_box->set_vexpand(); dock_box->set_vexpand();
dock_box->set_valign(Gtk::ALIGN_FILL); dock_box->set_valign(Gtk::Align::FILL);
icons_sw->set_vexpand(); icons_sw->set_vexpand();
} }
// std::cout << "panel mode" << std::endl; // std::cout << "panel mode" << std::endl;
break; break;
} }
show_all_children(); // show_all_children();
} }
// void MyDock::set_dock_mode(DockMode mode){ // void MyDock::set_dock_mode(DockMode mode){
@ -189,7 +190,7 @@ MyDock::MyDock(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_Gl
// break; // break;
// case DockMode::MODE_PANEL: // case DockMode::MODE_PANEL:
// set_vexpand(); // set_vexpand();
// set_valign(Gtk::ALIGN_FILL); // set_valign(Gtk::Align::FILL);
// break; // break;
// } // }
// } // }
@ -219,8 +220,8 @@ void MyDock::btnlaunch_clicked()
void MyDock::mydock_init(Gtk::Window *window, Gtk::Image *background1) void MyDock::mydock_init(Gtk::Window *window, Gtk::Image *background1)
{ {
// Initalize Preference window // Initalize Preference window
prefs_win.set_background(background1); // prefs_win.set_background(background1);
prefs_win.set_transient_for(*window); // prefs_win.set_transient_for(*window);
parent_win = window; parent_win = window;
} }
@ -258,7 +259,7 @@ void MyDock::padvlc_clicked()
void MyDock::padvlc_win32_clicked() void MyDock::padvlc_win32_clicked()
{ {
// Start vlc on windows // Start vlc on windows
std::thread fourth(system, "start notepad"); std::thread fourth(system, "start ..\\vlc\\vlc.exe");
fourth.detach(); fourth.detach();
btnlaunch_clicked(); btnlaunch_clicked();
} }
@ -266,279 +267,279 @@ void MyDock::padvlc_win32_clicked()
void MyDock::padnote_clicked() void MyDock::padnote_clicked()
{ {
// Start Notepad on windows // Start Notepad on windows
std::thread fifth(system, "start ..\\vlc\\vlc.exe"); std::thread fifth(system, "start notepad");
fifth.detach(); fifth.detach();
btnlaunch_clicked(); btnlaunch_clicked();
} }
bool MyDock::prefs_win_closed(GdkEventAny *event) // bool MyDock::prefs_win_closed(GdkEventAny *event)
{ // {
// Handle the "closed" signal of preference window // // Handle the "closed" signal of preference window
btnset->set_image_from_icon_name("my_prefs", Gtk::ICON_SIZE_DIALOG); // btnset->set_image_from_icon_name("my_prefs", Gtk::ICON_SIZE_DIALOG);
prefs_win.hide(); // prefs_win.hide();
return true; // return true;
} // }
void MyDock::btnset_clicked() // void MyDock::btnset_clicked()
{ // {
// Show settings window (preferences) // // Show settings window (preferences)
btnset->set_image_from_icon_name("my_prefs_running", Gtk::ICON_SIZE_DIALOG); // btnset->set_image_from_icon_name("my_prefs_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(prefs_win); // window_ctrl(prefs_win);
} // }
void MyDock::padset_clicked() // void MyDock::padset_clicked()
{ // {
// Function for button on launchpad // // Function for button on launchpad
btnset->set_image_from_icon_name("my_prefs_running", Gtk::ICON_SIZE_DIALOG); // btnset->set_image_from_icon_name("my_prefs_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(prefs_win, false); // window_ctrl(prefs_win, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handlers for drawing app window // // Signal Handlers for drawing app window
bool MyDock::draw_win_closed(GdkEventAny *event) // bool MyDock::draw_win_closed(GdkEventAny *event)
{ // {
btndraw->set_image_from_icon_name("drawing_app", Gtk::ICON_SIZE_DIALOG); // btndraw->set_image_from_icon_name("drawing_app", Gtk::ICON_SIZE_DIALOG);
draw_app.hide(); // draw_app.hide();
return true; // return true;
} // }
void MyDock::draw_win_hide() // void MyDock::draw_win_hide()
{ // {
btndraw->set_image_from_icon_name("drawing_app", Gtk::ICON_SIZE_DIALOG); // btndraw->set_image_from_icon_name("drawing_app", Gtk::ICON_SIZE_DIALOG);
draw_app.hide(); // draw_app.hide();
} // }
void MyDock::btndraw_clicked() // void MyDock::btndraw_clicked()
{ // {
btndraw->set_image_from_icon_name("drawing_app_running", Gtk::ICON_SIZE_DIALOG); // btndraw->set_image_from_icon_name("drawing_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(draw_app); // window_ctrl(draw_app);
} // }
void MyDock::paddraw_clicked() // void MyDock::paddraw_clicked()
{ // {
btndraw->set_image_from_icon_name("drawing_app_running", Gtk::ICON_SIZE_DIALOG); // btndraw->set_image_from_icon_name("drawing_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(draw_app, false); // window_ctrl(draw_app, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handlers for file window // // Signal Handlers for file window
bool MyDock::file_win_closed(GdkEventAny *event) // bool MyDock::file_win_closed(GdkEventAny *event)
{ // {
btnfiles->set_image_from_icon_name("file-app", Gtk::ICON_SIZE_DIALOG); // btnfiles->set_image_from_icon_name("file-app", Gtk::ICON_SIZE_DIALOG);
file_app.hide(); // file_app.hide();
return true; // return true;
} // }
void MyDock::btnfile_clicked() // void MyDock::btnfile_clicked()
{ // {
btnfiles->set_image_from_icon_name("file-app_running", Gtk::ICON_SIZE_DIALOG); // btnfiles->set_image_from_icon_name("file-app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(file_app); // window_ctrl(file_app);
} // }
void MyDock::padfile_clicked() // void MyDock::padfile_clicked()
{ // {
btnfiles->set_image_from_icon_name("file-app_running", Gtk::ICON_SIZE_DIALOG); // btnfiles->set_image_from_icon_name("file-app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(file_app, false); // window_ctrl(file_app, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handlers for game window // Signal Handlers for game window
bool MyDock::game_win_closed(GdkEventAny *event) // bool MyDock::game_win_closed(GdkEventAny *event)
{ // {
btngame->set_image_from_icon_name("game", Gtk::ICON_SIZE_DIALOG); // btngame->set_image_from_icon_name("game", Gtk::ICON_SIZE_DIALOG);
game_win->hide(); // game_win->hide();
return true; // return true;
} // }
void MyDock::game_win_hide() // void MyDock::game_win_hide()
{ // {
btngame->set_image_from_icon_name("game", Gtk::ICON_SIZE_DIALOG); // btngame->set_image_from_icon_name("game", Gtk::ICON_SIZE_DIALOG);
game_win->hide(); // game_win->hide();
} // }
void MyDock::btngame_clicked() // void MyDock::btngame_clicked()
{ // {
btngame->set_image_from_icon_name("game_running", Gtk::ICON_SIZE_DIALOG); // btngame->set_image_from_icon_name("game_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(*game_win); // window_ctrl(*game_win);
} // }
void MyDock::padgame_clicked() // void MyDock::padgame_clicked()
{ // {
btngame->set_image_from_icon_name("game_running", Gtk::ICON_SIZE_DIALOG); // btngame->set_image_from_icon_name("game_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(*game_win, false); // window_ctrl(*game_win, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handlers for game24 window // Signal Handlers for game24 window
bool MyDock::game24_win_closed(GdkEventAny *event) // bool MyDock::game24_win_closed(GdkEventAny *event)
{ // {
btngame24->set_image_from_icon_name("24game", Gtk::ICON_SIZE_DIALOG); // btngame24->set_image_from_icon_name("24game", Gtk::ICON_SIZE_DIALOG);
game24_win->hide(); // game24_win->hide();
return true; // return true;
} // }
void MyDock::btngame24_clicked() // void MyDock::btngame24_clicked()
{ // {
btngame24->set_image_from_icon_name("24game_running", Gtk::ICON_SIZE_DIALOG); // btngame24->set_image_from_icon_name("24game_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(*game24_win); // window_ctrl(*game24_win);
} // }
void MyDock::padgame24_clicked() // void MyDock::padgame24_clicked()
{ // {
btngame24->set_image_from_icon_name("24game_running", Gtk::ICON_SIZE_DIALOG); // btngame24->set_image_from_icon_name("24game_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(*game24_win, false); // window_ctrl(*game24_win, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
void MyDock::game24_win_hide() // void MyDock::game24_win_hide()
{ // {
btngame24->set_image_from_icon_name("24game", Gtk::ICON_SIZE_DIALOG); // btngame24->set_image_from_icon_name("24game", Gtk::ICON_SIZE_DIALOG);
game24_win->hide(); // game24_win->hide();
} // }
// Signal Handlers for Calc App // Signal Handlers for Calc App
bool MyDock::calc_win_closed(GdkEventAny *event) // bool MyDock::calc_win_closed(GdkEventAny *event)
{ // {
btncalc->set_image_from_icon_name("calcapp", Gtk::ICON_SIZE_DIALOG); // btncalc->set_image_from_icon_name("calcapp", Gtk::ICON_SIZE_DIALOG);
calc_win->hide(); // calc_win->hide();
return true; // return true;
} // }
void MyDock::btncalc_clicked() // void MyDock::btncalc_clicked()
{ // {
btncalc->set_image_from_icon_name("calcapp_running", Gtk::ICON_SIZE_DIALOG); // btncalc->set_image_from_icon_name("calcapp_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(*calc_win); // window_ctrl(*calc_win);
} // }
void MyDock::padcalc_clicked() // void MyDock::padcalc_clicked()
{ // {
btncalc->set_image_from_icon_name("calcapp_running", Gtk::ICON_SIZE_DIALOG); // btncalc->set_image_from_icon_name("calcapp_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(*calc_win); // window_ctrl(*calc_win);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
void MyDock::calc_win_hide() // void MyDock::calc_win_hide()
{ // {
btncalc->set_image_from_icon_name("calcapp", Gtk::ICON_SIZE_DIALOG); // btncalc->set_image_from_icon_name("calcapp", Gtk::ICON_SIZE_DIALOG);
calc_win->hide(); // calc_win->hide();
} // }
// Signal Handlers for image app window // Signal Handlers for image app window
bool MyDock::image_win_closed(GdkEventAny *event) // bool MyDock::image_win_closed(GdkEventAny *event)
{ // {
btnimage->set_image_from_icon_name("image_app", Gtk::ICON_SIZE_DIALOG); // btnimage->set_image_from_icon_name("image_app", Gtk::ICON_SIZE_DIALOG);
image_win.hide(); // image_win.hide();
return true; // return true;
} // }
void MyDock::btnimage_clicked() // void MyDock::btnimage_clicked()
{ // {
btnimage->set_image_from_icon_name("image_app_running", Gtk::ICON_SIZE_DIALOG); // btnimage->set_image_from_icon_name("image_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(image_win); // window_ctrl(image_win);
} // }
void MyDock::padimage_clicked() // void MyDock::padimage_clicked()
{ // {
btnimage->set_image_from_icon_name("image_app_running", Gtk::ICON_SIZE_DIALOG); // btnimage->set_image_from_icon_name("image_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(image_win, false); // window_ctrl(image_win, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handlers for editor window // // Signal Handlers for editor window
bool MyDock::editor_win_closed(GdkEventAny *event) // bool MyDock::editor_win_closed(GdkEventAny *event)
{ // {
btnedit->set_image_from_icon_name("my_textedit", Gtk::ICON_SIZE_DIALOG); // btnedit->set_image_from_icon_name("my_textedit", Gtk::ICON_SIZE_DIALOG);
editor_win.hide(); // editor_win.hide();
return true; // return true;
} // }
void MyDock::btnedit_clicked() // void MyDock::btnedit_clicked()
{ // {
btnedit->set_image_from_icon_name("my_textedit_running", Gtk::ICON_SIZE_DIALOG); // btnedit->set_image_from_icon_name("my_textedit_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(editor_win); // window_ctrl(editor_win);
} // }
void MyDock::padedit_clicked() // void MyDock::padedit_clicked()
{ // {
btnedit->set_image_from_icon_name("my_textedit_running", Gtk::ICON_SIZE_DIALOG); // btnedit->set_image_from_icon_name("my_textedit_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(editor_win, false); // window_ctrl(editor_win, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handler for minesweeper window // Signal Handler for minesweeper window
bool MyDock::mine_win_closed(GdkEventAny *event) // bool MyDock::mine_win_closed(GdkEventAny *event)
{ // {
btnmine->set_image_from_icon_name("mines_app", Gtk::ICON_SIZE_DIALOG); // btnmine->set_image_from_icon_name("mines_app", Gtk::ICON_SIZE_DIALOG);
mine_win.hide(); // mine_win.hide();
return true; // return true;
} // }
void MyDock::btnmine_clicked() // void MyDock::btnmine_clicked()
{ // {
btnmine->set_image_from_icon_name("mines_app_running", Gtk::ICON_SIZE_DIALOG); // btnmine->set_image_from_icon_name("mines_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(mine_win); // window_ctrl(mine_win);
} // }
void MyDock::padmine_clicked() // void MyDock::padmine_clicked()
{ // {
btnmine->set_image_from_icon_name("mines_app_running", Gtk::ICON_SIZE_DIALOG); // btnmine->set_image_from_icon_name("mines_app_running", Gtk::ICON_SIZE_DIALOG);
window_ctrl(mine_win, false); // window_ctrl(mine_win, false);
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
// Signal Handler for run window // Signal Handler for run window
void MyDock::btnrun_clicked() // void MyDock::btnrun_clicked()
{ // {
runner1.show(); // runner1.show();
btnlaunch_clicked(); // btnlaunch_clicked();
} // }
void MyDock::window_ctrl(Gtk::Window &window, bool on_dock) // void MyDock::window_ctrl(Gtk::Window &window, bool on_dock)
{ // {
// Get the GdkWindow object to get the state of a window // // Get the GdkWindow object to get the state of a window
auto gdk_win = window.get_window(); // auto gdk_win = window.get_window();
if (gdk_win) // if (gdk_win)
{ // {
/* // /*
The State of GdkWindow (GdkSurface for Gtk4) // The State of GdkWindow (GdkSurface for Gtk4)
Gdk::WINDOW_STATE_WITHDRAWN: The window is not shown // Gdk::WINDOW_STATE_WITHDRAWN: The window is not shown
Gdk::WINDOW_STATE_ICONIFIED: The window is minimized // Gdk::WINDOW_STATE_ICONIFIED: The window is minimized
the default mode for first launch // the default mode for first launch
*/ // */
auto state = gdk_win->get_state(); // auto state = gdk_win->get_state();
switch (state) // switch (state)
{ // {
case Gdk::WINDOW_STATE_WITHDRAWN: // case Gdk::WINDOW_STATE_WITHDRAWN:
window.present(); // window.present();
break; // break;
case Gdk::WINDOW_STATE_ICONIFIED: // case Gdk::WINDOW_STATE_ICONIFIED:
window.set_transient_for(*parent_win); // window.set_transient_for(*parent_win);
window.deiconify(); // window.deiconify();
break; // break;
default: // default:
if (on_dock) // if (on_dock)
{ // {
window.unset_transient_for(); // window.unset_transient_for();
window.iconify(); // window.iconify();
break; // break;
} // }
} // }
} // }
else // else
{ // {
window.set_transient_for(*parent_win); // window.set_transient_for(*parent_win);
window.present(); // window.present();
} // }
} // }
MyDock *MyDock::create(DockMode mode) MyDock *MyDock::create(DockMode mode)
{ {
@ -547,7 +548,7 @@ MyDock *MyDock::create(DockMode mode)
mode1 = mode; mode1 = mode;
// Get Widget // Get Widget
auto builder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/mydock.ui"); auto builder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/mydock.ui");
builder->get_widget_derived("main_box", dock); dock = Gtk::Builder::get_widget_derived<MyDock>(builder, "main_box");
// switch (mode) // switch (mode)
// { // {

View File

@ -3,15 +3,15 @@
#include <gtkmm.h> #include <gtkmm.h>
#include "MyFinder.hh" #include "MyFinder.hh"
#include "MyPrefs.hh" #include "MyPrefs.hh"
#include "drawing.hh" // #include "drawing.hh"
#include "FileWindow.hh" // #include "FileWindow.hh"
#include "Game.hh" // #include "Game.hh"
#include "ImageApp.hh" // #include "ImageApp.hh"
#include "Runner.hh" // #include "Runner.hh"
#include "TextEditor.hh" // #include "TextEditor.hh"
#include "Game24Win.hh" // #include "Game24Win.hh"
#include "CalcApp.hh" // #include "CalcApp.hh"
#include "MineSweeper.hh" // #include "MineSweeper.hh"
class MyDock : public Gtk::Box class MyDock : public Gtk::Box
{ {
@ -41,68 +41,68 @@ private:
*padimage, *padnote, *padedit, *padvlc, *padvlc_win32, *padrun, *padgame24, *padmine; *padimage, *padnote, *padedit, *padvlc, *padvlc_win32, *padrun, *padgame24, *padmine;
Gtk::Label label1; Gtk::Label label1;
// Window Preferences // // Window Preferences
MyPrefs prefs_win; // MyPrefs prefs_win;
bool prefs_win_closed(GdkEventAny *event); // bool prefs_win_closed(GdkEventAny *event);
void padset_clicked(); // void padset_clicked();
// Drawing Window // // Drawing Window
Drawing draw_app; // Drawing draw_app;
bool draw_win_closed(GdkEventAny *event); // bool draw_win_closed(GdkEventAny *event);
void btndraw_clicked(); // void btndraw_clicked();
void paddraw_clicked(); // void paddraw_clicked();
void draw_win_hide(); // void draw_win_hide();
// Finder // // Finder
FileWindow file_app; // FileWindow file_app;
bool file_win_closed(GdkEventAny *event); // bool file_win_closed(GdkEventAny *event);
void btnfile_clicked(); // void btnfile_clicked();
void padfile_clicked(); // void padfile_clicked();
// Calculator App // // Calculator App
CalcApp *calc_win; // CalcApp *calc_win;
bool calc_win_closed(GdkEventAny *event); // bool calc_win_closed(GdkEventAny *event);
void calc_win_hide(); // void calc_win_hide();
void btncalc_clicked(); // void btncalc_clicked();
void padcalc_clicked(); // void padcalc_clicked();
// Guess Game // // Guess Game
Game *game_win; // Game *game_win;
bool game_win_closed(GdkEventAny *event); // bool game_win_closed(GdkEventAny *event);
void game_win_hide(); // void game_win_hide();
void btngame_clicked(); // void btngame_clicked();
void padgame_clicked(); // void padgame_clicked();
// 24-Game // // 24-Game
Game24Win *game24_win; // Game24Win *game24_win;
bool game24_win_closed(GdkEventAny *event); // bool game24_win_closed(GdkEventAny *event);
void game24_win_hide(); // void game24_win_hide();
void btngame24_clicked(); // void btngame24_clicked();
void padgame24_clicked(); // void padgame24_clicked();
// Image Viewer // // Image Viewer
ImageApp image_win; // ImageApp image_win;
bool image_win_closed(GdkEventAny *event); // bool image_win_closed(GdkEventAny *event);
void btnimage_clicked(); // void btnimage_clicked();
void padimage_clicked(); // void padimage_clicked();
// Text Editor // // Text Editor
TextEditor editor_win; // TextEditor editor_win;
bool editor_win_closed(GdkEventAny *event); // bool editor_win_closed(GdkEventAny *event);
void btnedit_clicked(); // void btnedit_clicked();
void padedit_clicked(); // void padedit_clicked();
// MineSweeper // // MineSweeper
MineSweeper mine_win; // MineSweeper mine_win;
bool mine_win_closed(GdkEventAny *event); // bool mine_win_closed(GdkEventAny *event);
void btnmine_clicked(); // void btnmine_clicked();
void padmine_clicked(); // void padmine_clicked();
// A Simple Runner // // A Simple Runner
GtkRunner runner1; // GtkRunner runner1;
// Window Control // // Window Control
void window_ctrl(Gtk::Window &window, bool on_dock = true); // void window_ctrl(Gtk::Window &window, bool on_dock = true);
// Other // Other
Gtk::Window *parent_win; Gtk::Window *parent_win;
@ -117,5 +117,5 @@ private:
void padvlc_clicked(); void padvlc_clicked();
void padvlc_win32_clicked(); void padvlc_win32_clicked();
void padnote_clicked(); void padnote_clicked();
void btnrun_clicked(); // void btnrun_clicked();
}; };

View File

@ -56,7 +56,7 @@ MyFinder::MyFinder()
append(btnhelp); append(btnhelp);
// Add menu to window // Add menu to window
set_halign(Gtk::ALIGN_FILL); set_halign(Gtk::Align::FILL);
set_valign(Gtk::Align::START); set_valign(Gtk::Align::START);
// Add a timer // Add a timer