Add menubar

This commit is contained in:
daleclack 2022-01-20 23:00:29 +08:00
parent 563971ccc0
commit 387c9e1809
12 changed files with 1390 additions and 0 deletions

1
.gitignore vendored
View File

@ -23,6 +23,7 @@ Makefile
#backup files #backup files
*.*~ *.*~
*.mp3
#Gresource prebuild file #Gresource prebuild file
*/src/resources.cpp */src/resources.cpp

3
Gtkmm3_Mac/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}

67
Gtkmm3_Mac/CMakeLists.txt Normal file
View File

@ -0,0 +1,67 @@
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.0.0)
project(My_GtkUI VERSION 3.5.0)
#Add GCR_CMake
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../GCR_CMake/macros)
include(GlibCompileResourcesSupport)
include(CTest)
enable_testing()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
include_directories(.)
include_directories(..)
include_directories(src/core src/apps src/panels src/image_app)
find_package (PkgConfig REQUIRED)
pkg_check_modules (GTKMM3 REQUIRED gtkmm-3.0)
include_directories (${GTKMM3_INCLUDE_DIRS})
link_directories (${GTKMM3_LIBRARY_DIRS})
set(SOURCES src/core/main.cc src/core/MyWin.cc) #src/core/winconf.cc src/core/MyStack.cc
# src/panels/LeftPanel.cc src/panels/TopPanel.cc
# src/draw_app/drawing.cc src/file_app/FileWindow.cc src/game_app/Game.cc
# src/image_app/ImageApp.cc src/image_app/MyImage.cc
# src/run_app/Runner.cc src/text_app/TextEditor.cc)
#Compile resources with GCR_CMake
set(RESOURCE_LIST
menubar.xml
icons/48x48/actions/My_GtkUI.png)
compile_gresources(RESOURCE_FILE
XML_OUT
TYPE EMBED_C
RESOURCES ${RESOURCE_LIST}
PREFIX "/org/gtk/daleclack"
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.
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
#For win32 platform,use rc resource and .ico icon
if(WIN32)
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(app_WINRC icon.rc)
set_property(SOURCE icon.rc APPEND PROPERTY
OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/icon.ico
)
add_executable(My_GtkUI WIN32 ${app_WINRC} ${SOURCES} ${RESOURCE_FILE})
else()
add_executable(My_GtkUI ${SOURCES} ${RESOURCE_FILE})
endif(WIN32)
#Add command to generate .gitignore
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)

BIN
Gtkmm3_Mac/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

1
Gtkmm3_Mac/icon.rc Normal file
View File

@ -0,0 +1 @@
MAINICON ICON "Icon.ico"

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

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

254
Gtkmm3_Mac/res/menubar.xml Normal file
View File

@ -0,0 +1,254 @@
<?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>
<item>
<attribute name="label">About</attribute>
</item>
</submenu>
</menu>
</interface>

View File

@ -0,0 +1,28 @@
#include "MyWin.hh"
#include "winpe.xpm"
MyWin::MyWin(){
//Initalize window
set_default_size(1024,576);
set_icon_name("My_GtkUI");
set_title("My GtkUI macOS Version");
//Add background
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
auto sized = pixbuf->scale_simple(1024,576,Gdk::INTERP_BILINEAR);
gtk_image_set_from_pixbuf(m_background.gobj(),sized->gobj());
m_overlay.add(m_background);
//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(m_overlay);
show_all_children();
}

View File

@ -0,0 +1,13 @@
#pragma once
#include <gtkmm.h>
class MyWin : public Gtk::ApplicationWindow{
public:
MyWin();
private:
//Child widgets
Gtk::Overlay m_overlay;
Gtk::Image m_background;
Gtk::MenuBar * menubar;
};

View File

@ -0,0 +1,8 @@
#include "MyWin.hh"
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);
}

1014
Gtkmm3_Mac/winpe.xpm Normal file

File diff suppressed because it is too large Load Diff