Change Menu to buttons

This commit is contained in:
daleclack 2022-01-22 18:16:24 +08:00
parent 387c9e1809
commit bf9370f7cb
6 changed files with 434 additions and 257 deletions

View File

@ -32,6 +32,7 @@ set(SOURCES src/core/main.cc src/core/MyWin.cc) #src/core/winconf.cc src/core/My
set(RESOURCE_LIST
menubar.xml
icons/16x16/actions/My_GtkUI.png
icons/48x48/actions/My_GtkUI.png)
compile_gresources(RESOURCE_FILE

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>

View File

@ -1,254 +1,371 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="model">
<submenu>
<attribute name='label'>File</attribute>
<section>
<item>
<attribute name="label">New Filder Window</attribute>
</item>
<item>
<attribute name="label">New Folder</attribute>
</item>
<item>
<attribute name="label">New Smart Folder</attribute>
</item>
<item>
<attribute name="label">New Burn Folder</attribute>
</item>
<item>
<attribute name="label">Open</attribute>
</item>
<item>
<attribute name="label">Open With</attribute>
</item>
<item>
<attribute name="label">Print</attribute>
</item>
<item>
<attribute name="label">Close Window</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Get Info</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Duplicate</attribute>
</item>
<item>
<attribute name="label">Make alias</attribute>
</item>
<item>
<attribute name="label">Show Original</attribute>
</item>
<item>
<attribute name="label">Add to Sidebar</attribute>
</item>
<item>
<attribute name="label">Create archive</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Move to Trash</attribute>
</item>
<item>
<attribute name="label">Eject</attribute>
</item>
<item>
<attribute name="label">Burn Disc...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Find...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Color Label:</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label'>Edit</attribute>
<section>
<item>
<attribute name="label">Undo</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Cut</attribute>
</item>
<item>
<attribute name="label">Copy</attribute>
</item>
<item>
<attribute name="label">Paste</attribute>
</item>
<item>
<attribute name="label">Select All</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Show Clipboard</attribute>
</item>
<item>
<attribute name="label">Special Characters...</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label'>Show</attribute>
<section>
<item>
<attribute name="label">As Icons</attribute>
</item>
<item>
<attribute name="label">As List</attribute>
</item>
<item>
<attribute name="label">As Columns</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Clean Up</attribute>
</item>
<submenu>
<attribute name="label">Arrange by</attribute>
<item>
<attribute name="label">Name</attribute>
</item>
<item>
<attribute name="label">Date Modified</attribute>
</item>
<item>
<attribute name="label">Date Created</attribute>
</item>
<item>
<attribute name="label">Size</attribute>
</item>
<item>
<attribute name="label">Kind</attribute>
</item>
<item>
<attribute name="label">Label</attribute>
</item>
</submenu>
</section>
<section>
<item>
<attribute name="label">Hide Toolbar</attribute>
</item>
<item>
<attribute name="label">Customize Toolbar</attribute>
</item>
<item>
<attribute name="label">Hide Status Bar</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Show View Options</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label'>Go to</attribute>
<section>
<item>
<attribute name="label">Back</attribute>
</item>
<item>
<attribute name="label">Forward</attribute>
</item>
<item>
<attribute name="label">Enclosing Folder</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Computer</attribute>
</item>
<item>
<attribute name="label">Home</attribute>
</item>
<item>
<attribute name="label">Network</attribute>
</item>
<submenu>
<attribute name="label">iDisk</attribute>
<item>
<attribute name="label">My iDisk</attribute>
</item>
<item>
<attribute name="label">Other User's iDisk</attribute>
</item>
<item>
<attribute name="label">Other User's Public Folder</attribute>
</item>
</submenu>
<item>
<attribute name="label">Applications</attribute>
</item>
<item>
<attribute name="label">Utilities</attribute>
</item>
</section>
<section>
<submenu>
<attribute name="label">Recent Folders</attribute>
<section>
<item>
<attribute name="label">(None)</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Clear Menu</attribute>
</item>
</section>
</submenu>
</section>
<section>
<item>
<attribute name="label">Go to Folder...</attribute>
</item>
<item>
<attribute name="label">Connect to Server...</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label'>windows</attribute>
<section>
<item>
<attribute name="label">Minimize</attribute>
</item>
<item>
<attribute name="label">Zoom</attribute>
</item>
<item>
<attribute name="label">Cycle Through Windows</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Bring All to Front</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label'>Help</attribute>
<menu id="main_menu">
<section>
<item>
<attribute name="label">About</attribute>
<attribute name="label">About My GtkUI mac version</attribute>
</item>
</submenu>
<item>
<attribute name="label">Software Update...</attribute>
</item>
<item>
<attribute name="label">My GtkUI Update...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">System Preferences...</attribute>
</item>
<submenu>
<attribute name="label">Dock</attribute>
<section>
<item>
<attribute name="label">Turn Hiding On</attribute>
</item>
<item>
<attribute name="label">Turn Magnification On</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Position On Left</attribute>
</item>
<item>
<attribute name="label">Position On Bottom</attribute>
</item>
<item>
<attribute name="label">Position On Right</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label">Location</attribute>
<section>
<item>
<attribute name="label">Automatic</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Network Preferences...</attribute>
</item>
</section>
</submenu>
</section>
<section>
<submenu>
<attribute name="label">Recent Items</attribute>
<section>
<item>
<attribute name="label">(None)</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Clear Menu</attribute>
</item>
</section>
</submenu>
</section>
<section>
<item>
<attribute name="label">Force Quit...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Sleep</attribute>
</item>
<item>
<attribute name="label">Restart...</attribute>
</item>
<item>
<attribute name="label">Shut Down...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Login Out dale...</attribute>
</item>
</section>
</menu>
<menu id="title_menu">
<section>
<item>
<attribute name="label">About MyFinder</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Preferences...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Empty Trash...</attribute>
</item>
<item>
<attribute name="label">Secure Empty Trash</attribute>
</item>
</section>
<section>
<submenu>
<attribute name="label">Services</attribute>
</submenu>
</section>
<section>
<item>
<attribute name="label">Hide MyFinder</attribute>
</item>
<item>
<attribute name="label">Hide Others</attribute>
</item>
<item>
<attribute name="label">Show All</attribute>
</item>
</section>
</menu>
<menu id="menu_file">
<section>
<item>
<attribute name="label">New Filder Window</attribute>
</item>
<item>
<attribute name="label">New Folder</attribute>
</item>
<item>
<attribute name="label">New Smart Folder</attribute>
</item>
<item>
<attribute name="label">New Burn Folder</attribute>
</item>
<item>
<attribute name="label">Open</attribute>
</item>
<item>
<attribute name="label">Open With</attribute>
</item>
<item>
<attribute name="label">Print</attribute>
</item>
<item>
<attribute name="label">Close Window</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Get Info</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Duplicate</attribute>
</item>
<item>
<attribute name="label">Make alias</attribute>
</item>
<item>
<attribute name="label">Show Original</attribute>
</item>
<item>
<attribute name="label">Add to Sidebar</attribute>
</item>
<item>
<attribute name="label">Create archive</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Move to Trash</attribute>
</item>
<item>
<attribute name="label">Eject</attribute>
</item>
<item>
<attribute name="label">Burn Disc...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Find...</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Color Label:</attribute>
</item>
</section>
</menu>
<menu id="menu_edit">
<section>
<item>
<attribute name="label">Undo</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Cut</attribute>
</item>
<item>
<attribute name="label">Copy</attribute>
</item>
<item>
<attribute name="label">Paste</attribute>
</item>
<item>
<attribute name="label">Select All</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Show Clipboard</attribute>
</item>
<item>
<attribute name="label">Special Characters...</attribute>
</item>
</section>
</menu>
<menu id="menu_show">
<section>
<item>
<attribute name="label">As Icons</attribute>
</item>
<item>
<attribute name="label">As List</attribute>
</item>
<item>
<attribute name="label">As Columns</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Clean Up</attribute>
</item>
<submenu>
<attribute name="label">Arrange by</attribute>
<item>
<attribute name="label">Name</attribute>
</item>
<item>
<attribute name="label">Date Modified</attribute>
</item>
<item>
<attribute name="label">Date Created</attribute>
</item>
<item>
<attribute name="label">Size</attribute>
</item>
<item>
<attribute name="label">Kind</attribute>
</item>
<item>
<attribute name="label">Label</attribute>
</item>
</submenu>
</section>
<section>
<item>
<attribute name="label">Hide Toolbar</attribute>
</item>
<item>
<attribute name="label">Customize Toolbar</attribute>
</item>
<item>
<attribute name="label">Hide Status Bar</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Show View Options</attribute>
</item>
</section>
</menu>
<menu id="menu_goto">
<section>
<item>
<attribute name="label">Back</attribute>
</item>
<item>
<attribute name="label">Forward</attribute>
</item>
<item>
<attribute name="label">Enclosing Folder</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Computer</attribute>
</item>
<item>
<attribute name="label">Home</attribute>
</item>
<item>
<attribute name="label">Network</attribute>
</item>
<submenu>
<attribute name="label">iDisk</attribute>
<item>
<attribute name="label">My iDisk</attribute>
</item>
<item>
<attribute name="label">Other User's iDisk</attribute>
</item>
<item>
<attribute name="label">Other User's Public Folder</attribute>
</item>
</submenu>
<item>
<attribute name="label">Applications</attribute>
</item>
<item>
<attribute name="label">Utilities</attribute>
</item>
</section>
<section>
<submenu>
<attribute name="label">Recent Folders</attribute>
<section>
<item>
<attribute name="label">(None)</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Clear Menu</attribute>
</item>
</section>
</submenu>
</section>
<section>
<item>
<attribute name="label">Go to Folder...</attribute>
</item>
<item>
<attribute name="label">Connect to Server...</attribute>
</item>
</section>
</menu>
<menu id="menu_win">
<section>
<item>
<attribute name="label">Minimize</attribute>
</item>
<item>
<attribute name="label">Zoom</attribute>
</item>
<item>
<attribute name="label">Cycle Through Windows</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Bring All to Front</attribute>
</item>
</section>
</menu>
<menu id="menu_help">
<item>
<attribute name="label">About</attribute>
</item>
</menu>
</interface>

View File

@ -1,7 +1,9 @@
#include "MyWin.hh"
#include "winpe.xpm"
MyWin::MyWin(){
MyWin::MyWin()
:menubox(Gtk::ORIENTATION_HORIZONTAL,0)
{
//Initalize window
set_default_size(1024,576);
set_icon_name("My_GtkUI");
@ -15,14 +17,67 @@ MyWin::MyWin(){
//Add a menubar
auto menubuilder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/menubar.xml");
auto object = menubuilder->get_object("model");
auto gmenu = Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
menubar = Gtk::make_managed<Gtk::MenuBar>(gmenu);
menubar->set_halign(Gtk::ALIGN_FILL);
menubar->set_valign(Gtk::ALIGN_START);
m_overlay.add_overlay(*menubar);
//Add widgets to menubox
btnlogo.set_image_from_icon_name("My_GtkUI",Gtk::ICON_SIZE_BUTTON);
btnlogo.set_relief(Gtk::RELIEF_NONE);
btnlogo.set_use_popover(false);
btnlogo.set_menu_model(get_menu(menubuilder,"main_menu"));
menubox.pack_start(btnlogo,Gtk::PACK_SHRINK);
btntitle.set_label("MyFinder");
btntitle.set_relief(Gtk::RELIEF_NONE);
btntitle.set_use_popover(false);
btntitle.set_menu_model(get_menu(menubuilder,"title_menu"));
menubox.pack_start(btntitle,Gtk::PACK_SHRINK);
btnfile.set_label("File");
btnfile.set_relief(Gtk::RELIEF_NONE);
btnfile.set_use_popover(false);
btnfile.set_menu_model(get_menu(menubuilder,"menu_file"));
menubox.pack_start(btnfile,Gtk::PACK_SHRINK);
btnedit.set_label("Edit");
btnedit.set_relief(Gtk::RELIEF_NONE);
btnedit.set_use_popover(false);
btnedit.set_menu_model(get_menu(menubuilder,"menu_edit"));
menubox.pack_start(btnedit,Gtk::PACK_SHRINK);
btnshow.set_label("Show");
btnshow.set_relief(Gtk::RELIEF_NONE);
btnshow.set_use_popover(false);
btnshow.set_menu_model(get_menu(menubuilder,"menu_show"));
menubox.pack_start(btnshow,Gtk::PACK_SHRINK);
btngoto.set_label("Go to");
btngoto.set_relief(Gtk::RELIEF_NONE);
btngoto.set_use_popover(false);
btngoto.set_menu_model(get_menu(menubuilder,"menu_goto"));
menubox.pack_start(btngoto,Gtk::PACK_SHRINK);
btnwin.set_label("Windows");
btnwin.set_relief(Gtk::RELIEF_NONE);
btnwin.set_use_popover(false);
btnwin.set_menu_model(get_menu(menubuilder,"menu_win"));
menubox.pack_start(btnwin,Gtk::PACK_SHRINK);
btnhelp.set_label("Help");
btnhelp.set_relief(Gtk::RELIEF_NONE);
btnhelp.set_use_popover(false);
btnhelp.set_menu_model(get_menu(menubuilder,"menu_help"));
menubox.pack_start(btnhelp,Gtk::PACK_SHRINK);
//Add menu to window
menubox.set_halign(Gtk::ALIGN_FILL);
menubox.set_valign(Gtk::ALIGN_START);
m_overlay.add_overlay(menubox);
add(m_overlay);
show_all_children();
}
Glib::RefPtr<Gio::Menu> MyWin::get_menu(Glib::RefPtr<Gtk::Builder> &builder, const Glib::ustring &id){
auto object = builder->get_object(id);
auto gmenu = Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
return gmenu;
}

View File

@ -9,5 +9,10 @@ private:
//Child widgets
Gtk::Overlay m_overlay;
Gtk::Image m_background;
Gtk::MenuBar * menubar;
Gtk::Box menubox;
Gtk::MenuButton btnlogo, btntitle, btnfile, btnedit, btnshow,
btngoto, btnwin, btnhelp;
//Get Menu
Glib::RefPtr<Gio::Menu> get_menu(Glib::RefPtr<Gtk::Builder> &builder, const Glib::ustring &id);
};