Add more for menu

This commit is contained in:
daleclack 2022-01-14 19:50:55 +08:00
parent ef35bbe1f4
commit ed04950c54
7 changed files with 254 additions and 17 deletions

View File

@ -22,11 +22,182 @@
<property name="visible">1</property> <property name="visible">1</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkSeparator"> <object class="GtkButton">
<property name="visible">1</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="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">32</property>
<property name="icon-name">7zFM</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1"> 7-zip File Manager</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</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="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">32</property>
<property name="icon-name">file-manager</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1"> File Manager</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</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="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">32</property>
<property name="icon-name">glade</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1"> Glade</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</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="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">32</property>
<property name="icon-name">qemu-launcher</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1"> QEMU</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</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="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">32</property>
<property name="icon-name">qqmusic</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1"> QQMusic</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</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="GtkBox">
<property name="visible">1</property>
<child>
<object class="GtkImage">
<property name="visible">1</property>
<property name="pixel-size">32</property>
<property name="icon-name">visual-studio-code</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="1"> Visual Studio Code</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator" id="prim_separator">
<property name="visible">1</property> <property name="visible">1</property>
<property name="vexpand">1</property> <property name="vexpand">1</property>
</object> </object>
</child> </child>
<child>
<object class="GtkSeparator"/>
</child>
<child> <child>
<object class="GtkButton" id="btn_program"> <object class="GtkButton" id="btn_program">
<property name="focusable">1</property> <property name="focusable">1</property>
@ -362,22 +533,64 @@
<property name="visible">1</property> <property name="visible">1</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<placeholder/> <object class="GtkImage" id="user_image">
<property name="halign">center</property>
<property name="visible">1</property>
<property name="icon-name">My_GtkUI</property>
<property name="pixel-size">48</property>
</object>
</child> </child>
<child> <child>
<object class="GtkSeparator"> <object class="GtkButton" id="user_button">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="label">dale</property>
</object>
</child>
<child>
<object class="GtkButton" id="btnmusic">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="label">FlMusic</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="label">Computer</property>
</object>
</child>
<child>
<object class="GtkSeparator" id="ext_separator">
<property name="visible">1</property> <property name="visible">1</property>
<property name="vexpand">1</property> <property name="vexpand">1</property>
</object> </object>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">1</property>
<property name="halign">center</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<property name="label">Run</property>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">1</property> <property name="visible">1</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="valign">end</property> <property name="valign">end</property>
<child>
<placeholder/>
</child>
<child> <child>
<object class="GtkButton" id="btnshut"> <object class="GtkButton" id="btnshut">
<property name="visible">1</property> <property name="visible">1</property>
@ -389,6 +602,9 @@
<property name="has-frame">0</property> <property name="has-frame">0</property>
</object> </object>
</child> </child>
<child>
<object class="GtkSeparator"/>
</child>
<child> <child>
<object class="GtkMenuButton"> <object class="GtkMenuButton">
<property name="visible">1</property> <property name="visible">1</property>
@ -407,7 +623,6 @@
<child> <child>
<object class="GtkSeparator"> <object class="GtkSeparator">
<property name="visible">1</property> <property name="visible">1</property>
<property name="width-request">10</property>
</object> </object>
</child> </child>
</object> </object>
@ -415,7 +630,6 @@
<child> <child>
<object class="GtkSeparator"> <object class="GtkSeparator">
<property name="visible">1</property> <property name="visible">1</property>
<property name="height-request">10</property>
</object> </object>
</child> </child>
</object> </object>

View File

@ -14,3 +14,7 @@ menubar{
box{ box{
background-color: alpha(white,0.7); background-color: alpha(white,0.7);
} }
separator{
background-color:white;
}

View File

@ -7,6 +7,7 @@ struct _MainWin
GtkApplicationWindow parent_instance; GtkApplicationWindow parent_instance;
GtkWidget *overlay; GtkWidget *overlay;
GtkWidget *background; GtkWidget *background;
GtkStyleProvider *provider;
}; };
G_DEFINE_TYPE(MainWin, main_win, GTK_TYPE_APPLICATION_WINDOW) G_DEFINE_TYPE(MainWin, main_win, GTK_TYPE_APPLICATION_WINDOW)
@ -56,9 +57,9 @@ static void main_win_init(MainWin *win)
gtk_overlay_add_overlay(GTK_OVERLAY(win->overlay), menubar); gtk_overlay_add_overlay(GTK_OVERLAY(win->overlay), menubar);
// Apply Style for menubar // Apply Style for menubar
GtkStyleProvider *provider = GTK_STYLE_PROVIDER(gtk_css_provider_new()); win->provider = GTK_STYLE_PROVIDER(gtk_css_provider_new());
gtk_css_provider_load_from_resource(GTK_CSS_PROVIDER(provider), "/org/gtk/daleclack/style.css"); gtk_css_provider_load_from_resource(GTK_CSS_PROVIDER(win->provider), "/org/gtk/daleclack/style.css");
gtk_style_context_add_provider(gtk_widget_get_style_context(menubar), provider, G_MAXINT); gtk_style_context_add_provider(gtk_widget_get_style_context(menubar), win->provider, G_MAXINT);
// Add Label for time // Add Label for time
GtkWidget *time_label = gtk_label_new("12:21 2022/1/9"); GtkWidget *time_label = gtk_label_new("12:21 2022/1/9");
@ -75,7 +76,7 @@ static void main_win_init(MainWin *win)
gtk_overlay_add_overlay(GTK_OVERLAY(win->overlay), time_label); gtk_overlay_add_overlay(GTK_OVERLAY(win->overlay), time_label);
//Add a dock //Add a dock
add_dock(win, provider); add_dock(win);
// Add widgets // Add widgets
gtk_overlay_set_child(GTK_OVERLAY(win->overlay), win->background); gtk_overlay_set_child(GTK_OVERLAY(win->overlay), win->background);
@ -91,5 +92,11 @@ MainWin *main_win_new(GtkApplication *app)
GtkOverlay *main_win_get_overlay(MainWin * win){ GtkOverlay *main_win_get_overlay(MainWin * win){
//Get the Overlay of the window
return GTK_OVERLAY(win->overlay); return GTK_OVERLAY(win->overlay);
} }
GtkStyleProvider *main_win_get_style(MainWin * win){
//Get Style Provider
return win->provider;
}

View File

@ -7,3 +7,5 @@ G_DECLARE_FINAL_TYPE(MainWin,main_win,MAIN,WIN,GtkApplicationWindow)
MainWin * main_win_new(GtkApplication * app); MainWin * main_win_new(GtkApplication * app);
GtkOverlay * main_win_get_overlay(MainWin * win); GtkOverlay * main_win_get_overlay(MainWin * win);
GtkStyleProvider * main_win_get_style(MainWin * win);

View File

@ -1,7 +1,7 @@
#include "MyDock.h" #include "MyDock.h"
#include "Start.h" #include "Start.h"
void add_dock(MainWin * win, GtkStyleProvider * provider){ void add_dock(MainWin * win){
GtkWidget * dock_box, * main_box; GtkWidget * dock_box, * main_box;
//Create a box for layout //Create a box for layout
@ -25,5 +25,6 @@ void add_dock(MainWin * win, GtkStyleProvider * provider){
gtk_box_append(GTK_BOX(main_box),space); gtk_box_append(GTK_BOX(main_box),space);
//Set Style //Set Style
gtk_style_context_add_provider(gtk_widget_get_style_context(dock_box), provider, G_MAXINT); gtk_style_context_add_provider(gtk_widget_get_style_context(dock_box),
main_win_get_style(win), G_MAXINT);
} }

View File

@ -3,4 +3,4 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "MainWin.h" #include "MainWin.h"
void add_dock(MainWin * win, GtkStyleProvider * provider); void add_dock(MainWin * win);

View File

@ -28,6 +28,15 @@ void add_start(MainWin * win, GtkBox * box){
GtkWidget * btnshut = (GtkWidget*)gtk_builder_get_object(startbuilder,"btnshut"); GtkWidget * btnshut = (GtkWidget*)gtk_builder_get_object(startbuilder,"btnshut");
g_signal_connect_swapped(btnshut,"clicked",G_CALLBACK(gtk_window_destroy),win); g_signal_connect_swapped(btnshut,"clicked",G_CALLBACK(gtk_window_destroy),win);
//Add Style for separator
GtkWidget * prim_separator, * ext_separator;
prim_separator = (GtkWidget*)gtk_builder_get_object(startbuilder,"prim_separator");
ext_separator = (GtkWidget*)gtk_builder_get_object(startbuilder,"ext_separator");
gtk_style_context_add_provider(gtk_widget_get_style_context(prim_separator),
main_win_get_style(win), G_MAXINT);
gtk_style_context_add_provider(gtk_widget_get_style_context(ext_separator),
main_win_get_style(win), G_MAXINT);
//Pack widgets //Pack widgets
gtk_box_prepend(box,menu_btn); gtk_box_prepend(box,menu_btn);
gtk_box_prepend(box,label); gtk_box_prepend(box,label);