Add a menu

This commit is contained in:
daleclack 2022-01-12 22:51:01 +08:00
parent 656d8af366
commit fae2d64e0f
6 changed files with 320 additions and 379 deletions

View File

@ -53,7 +53,7 @@ compile_gresources(RESOURCE_FILE
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE}) add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
#SOURCE FILES LIST #SOURCE FILES LIST
set(SOURCES src/core/main.cpp src/core/MainWin.cpp src/core/MyDock.cpp) set(SOURCES src/core/main.cpp src/core/MainWin.cpp src/core/MyDock.cpp src/core/Start.cpp)
#For win32 platform,use rc resource and .ico icon #For win32 platform,use rc resource and .ico icon
if(WIN32) if(WIN32)

View File

@ -3,11 +3,6 @@
<requires lib="gtk" version="4.0"/> <requires lib="gtk" version="4.0"/>
<object class="GtkBox" id="main_dock"> <object class="GtkBox" id="main_dock">
<!-- <property name="homogeneous">1</property> --> <!-- <property name="homogeneous">1</property> -->
<child>
<object class="GtkLabel">
<property name="label"> </property>
</object>
</child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton">
<property name="focusable">1</property> <property name="focusable">1</property>

View File

@ -1,422 +1,345 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface> <interface>
<requires lib="gtk+" version="3.24"/> <requires lib="gtk" version="4.0"/>
<object class="GtkImage" id="image1"> <object class="GtkPopover" id="main_menu">
<property name="visible">True</property> <property name="has-arrow">0</property>
<property name="can-focus">False</property> <property name="child">
<property name="icon-name">7zFM</property> <object class="GtkBox" id="start_box">
</object> <property name="visible">1</property>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">baidunetdisk</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">qqmusic</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">visual-studio-code</property>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">qq</property>
</object>
<object class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">file-manager</property>
</object>
<object class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">qemu-launcher</property>
</object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">glade</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="yalign">0.5</property>
</object>
<object class="GtkBox" id="start_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox" id="program_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkStack" id="stack_program"> <object class="GtkBox" id="program_box">
<property name="visible">True</property> <property name="visible">1</property>
<property name="can-focus">False</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox" id="begin_box"> <object class="GtkStack" id="stack_program">
<property name="visible">True</property> <property name="visible">1</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<placeholder/> <object class="GtkStackPage">
<property name="title" translatable="1">page0</property>
<property name="child">
<object class="GtkBox" id="begin_box">
<property name="visible">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSeparator">
<property name="visible">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton" id="btn_program">
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">16</property>
<property name="icon-name">arrow-right</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1">All Programs</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child> </child>
<child> <child>
<placeholder/> <object class="GtkStackPage">
</child> <property name="title" translatable="1">page1</property>
<child> <property name="child">
<placeholder/> <object class="GtkBox" id="main_box">
<property name="visible">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">7-Zip File Manager</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">1</property>
<property name="icon-name">7zFM</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">BaiduNetDisk</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">1</property>
<property name="icon-name">baidunetdisk</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">File Manager</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image6">
<property name="visible">1</property>
<property name="icon-name">file-manager</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">Glade</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image8">
<property name="visible">1</property>
<property name="icon-name">glade</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">QEMU</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image7">
<property name="visible">1</property>
<property name="icon-name">qemu-launcher</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">QQ</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image5">
<property name="visible">1</property>
<property name="icon-name">qq</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">QQMusic</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image3">
<property name="visible">1</property>
<property name="icon-name">qqmusic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">Visual Studio Code</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="halign">start</property>
<property name="has-frame">0</property>
<child>
<object class="GtkImage" id="image4">
<property name="visible">1</property>
<property name="icon-name">visual-studio-code</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkButton" id="btn_back">
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">16</property>
<property name="icon-name">arrow-left</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1">Back</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child> </child>
</object> </object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkBox" id="main_box"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">1</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkButton"> <object class="GtkSearchEntry">
<property name="label" translatable="yes">7-Zip File Manager</property> <property name="visible">1</property>
<property name="visible">True</property> <property name="focusable">1</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton">
<property name="label" translatable="yes">BaiduNetDisk</property> <property name="visible">1</property>
<property name="visible">True</property> <property name="focusable">1</property>
<property name="can-focus">True</property> <property name="receives-default">1</property>
<property name="receives-default">True</property> <property name="has-frame">0</property>
<property name="halign">start</property> <child>
<property name="image">image2</property> <object class="GtkImage" id="image9">
<property name="relief">none</property> <property name="visible">1</property>
<property name="always-show-image">True</property> <property name="icon-name">edit-find-symbolic</property>
</object>
</child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">File Manager</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image6</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Glade</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image8</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">QEMU</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image7</property>
<property name="relief">none</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">QQ</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image5</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">QQMusic</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image3</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Visual Studio Code</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="image">image4</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkSeparator"> <object class="GtkSeparator">
<property name="visible">True</property> <property name="visible">1</property>
<property name="can-focus">False</property> <property name="width-request">5</property>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="btn_program"> <object class="GtkBox" id="controls_box">
<property name="label" translatable="yes">All Programs</property> <property name="visible">1</property>
<property name="visible">True</property> <property name="orientation">vertical</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>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkSearchEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="primary-icon-name">edit-find-symbolic</property>
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image9</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="width-request">5</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="controls_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">end</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkSeparator">
<property name="label" translatable="yes">Shutdown</property> <property name="visible">1</property>
<property name="visible">True</property> <property name="vexpand">1</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-end">5</property>
<property name="relief">none</property>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkMenuButton"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">1</property>
<property name="can-focus">True</property> <property name="halign">start</property>
<property name="focus-on-click">False</property> <property name="valign">end</property>
<property name="receives-default">True</property>
<property name="margin-start">5</property>
<property name="relief">none</property>
<property name="direction">right</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="label" translatable="1">Shutdown</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="margin-end">5</property>
<property name="margin-end">5</property>
<property name="has-frame">0</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="focus-on-click">0</property>
<property name="receives-default">1</property>
<property name="margin-start">5</property>
<property name="margin-start">5</property>
<property name="has-frame">0</property>
<property name="direction">right</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">1</property>
<property name="width-request">10</property>
</object>
</child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkSeparator"> <object class="GtkSeparator">
<property name="width-request">10</property> <property name="visible">1</property>
<property name="visible">True</property> <property name="height-request">10</property>
<property name="can-focus">False</property>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="height-request">10</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child> </child>
</object> </object>
<packing> </property>
<property name="expand">False</property> </object>
<property name="fill">True</property> <object class="GtkMenuButton" id="menu_btn">
<property name="position">2</property> <property name="visible">1</property>
</packing> <property name="focusable">1</property>
<property name="focus-on-click">0</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="direction">up</property>
<property name="popover">main_menu</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">48</property>
<property name="icon-name">My_GtkUI</property>
<property name="pixel-size">48</property>
</object>
</child> </child>
</object> </object>
</interface> </interface>

View File

@ -1,4 +1,5 @@
#include "MyDock.h" #include "MyDock.h"
#include "Start.h"
void add_dock(GtkWidget * overlay, GtkStyleProvider * provider){ void add_dock(GtkWidget * overlay, GtkStyleProvider * provider){
GtkWidget * dock_box; GtkWidget * dock_box;
@ -6,6 +7,9 @@ void add_dock(GtkWidget * overlay, GtkStyleProvider * provider){
GtkBuilder * builder = gtk_builder_new_from_resource("/org/gtk/daleclack/dock.ui"); GtkBuilder * builder = gtk_builder_new_from_resource("/org/gtk/daleclack/dock.ui");
dock_box = (GtkWidget*)gtk_builder_get_object(builder,"main_dock"); dock_box = (GtkWidget*)gtk_builder_get_object(builder,"main_dock");
//Add a start
add_start(GTK_BOX(dock_box));
//Put the dock on the overlay //Put the dock on the overlay
gtk_widget_set_halign(dock_box,GTK_ALIGN_CENTER); gtk_widget_set_halign(dock_box,GTK_ALIGN_CENTER);
gtk_widget_set_valign(dock_box,GTK_ALIGN_END); gtk_widget_set_valign(dock_box,GTK_ALIGN_END);

View File

@ -0,0 +1,14 @@
#include "Start.h"
void add_start(GtkBox * box){
//Create a builder for menu
GtkBuilder * startbuilder = gtk_builder_new_from_resource("/org/gtk/daleclack/start.ui");
//Get Widgets
GtkWidget * menu_btn = (GtkWidget*)gtk_builder_get_object(startbuilder,"menu_btn");
GtkWidget * label = gtk_label_new(" ");
//Pack widgets
gtk_box_prepend(box,menu_btn);
gtk_box_prepend(box,label);
}

View File

@ -0,0 +1,5 @@
#pragma once
#include <gtk/gtk.h>
void add_start(GtkBox * box);