mirror of https://github.com/daleclack/My_GtkUi
Add dock
This commit is contained in:
parent
b74138df04
commit
6c501e9108
|
@ -27,7 +27,8 @@ set(RESOURCE_LIST
|
|||
flos.png
|
||||
menubar.xml
|
||||
style.css
|
||||
reset.css)
|
||||
reset.css
|
||||
dock.ui)
|
||||
|
||||
compile_gresources(RESOURCE_FILE
|
||||
XML_OUT
|
||||
|
@ -41,7 +42,7 @@ compile_gresources(RESOURCE_FILE
|
|||
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
|
||||
|
||||
#SOURCE FILES LIST
|
||||
set(SOURCES src/core/main.cpp src/core/MainWin.cpp)
|
||||
set(SOURCES src/core/main.cpp src/core/MainWin.cpp src/core/MyDock.cpp)
|
||||
|
||||
#For win32 platform,use rc resource and .ico icon
|
||||
if(WIN32)
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkBox" id="main_dock">
|
||||
<!-- <property name="homogeneous">1</property> -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label"> </property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="focusable">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="has-frame">0</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="icon-name">vlc</property>
|
||||
<property name="pixel-size">48</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label"> </property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -8,5 +8,9 @@
|
|||
|
||||
/*Style for menubar*/
|
||||
menubar{
|
||||
background-color:#FFFA;
|
||||
background-color: alpha(white,0.7);
|
||||
}
|
||||
|
||||
box{
|
||||
background-color: alpha(white,0.7);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "MainWin.h"
|
||||
#include "MyDock.h"
|
||||
#include <ctime>
|
||||
|
||||
struct _MainWin
|
||||
|
@ -23,6 +24,8 @@ static gboolean label_timer(gpointer data)
|
|||
sprintf(buf, "%d:%d %d/%d/%d", local->tm_hour,
|
||||
local->tm_min, local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
|
||||
gtk_label_set_label(GTK_LABEL(data), buf);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void main_win_init(MainWin *win)
|
||||
|
@ -71,6 +74,9 @@ static void main_win_init(MainWin *win)
|
|||
gtk_widget_set_margin_top(time_label, 3);
|
||||
gtk_overlay_add_overlay(GTK_OVERLAY(win->overlay), time_label);
|
||||
|
||||
//Add a dock
|
||||
add_dock(win->overlay, provider);
|
||||
|
||||
// Add widgets
|
||||
gtk_overlay_set_child(GTK_OVERLAY(win->overlay), win->background);
|
||||
gtk_window_set_child(GTK_WINDOW(win), win->overlay);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "MyDock.h"
|
||||
|
||||
void add_dock(GtkWidget * overlay, GtkStyleProvider * provider){
|
||||
GtkWidget * dock_box;
|
||||
//Get Widget
|
||||
GtkBuilder * builder = gtk_builder_new_from_resource("/org/gtk/daleclack/dock.ui");
|
||||
dock_box = (GtkWidget*)gtk_builder_get_object(builder,"main_dock");
|
||||
|
||||
//Put the dock on the overlay
|
||||
gtk_widget_set_halign(dock_box,GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign(dock_box,GTK_ALIGN_END);
|
||||
gtk_overlay_add_overlay(GTK_OVERLAY(overlay),dock_box);
|
||||
|
||||
//Set Style
|
||||
gtk_style_context_add_provider(gtk_widget_get_style_context(dock_box), provider, G_MAXINT);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void add_dock(GtkWidget * overlay, GtkStyleProvider * provider);
|
Loading…
Reference in New Issue