Add LeftPanel

This commit is contained in:
daleclack 2021-10-24 15:00:01 +08:00
parent 15c9665da2
commit b25f6cda3b
9 changed files with 409 additions and 319 deletions

View File

@ -55,7 +55,8 @@ set(RESOURCE_LIST
gnome-fs-directory.png
gnome-fs-regular.png
STRIPBLANKS appmenu.xml
STRIPBLANKS stack.ui)
STRIPBLANKS stack.ui
STRIPBLANKS leftpanel.ui)
compile_gresources(RESOURCE_FILE
XML_OUT

16
Gtk4/res/image_label.ui Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">label</property>
</object>
</child>
</object>
</interface>

View File

@ -1,284 +1,347 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-about</property>
</object>
<requires lib="gtk" version="4.0"/>
<object class="GtkPopover" id="popover1">
<property name="width-request">300</property>
<property name="width-request">320</property>
<property name="height-request">400</property>
<property name="can-focus">False</property>
<child>
<property name="valign">start</property>
<property name="has-arrow">0</property>
<property name="child">
<object class="GtkNotebook">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="tab-pos">left</property>
<property name="enable-popup">True</property>
<property name="enable-popup">1</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="btnaud">
<property name="label" translatable="yes">audacious</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkBox">
<property name="visible">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="btnaud">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">audacious</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">audacious</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btngedit">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">gedit</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Gedit Text Editor</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btnvlc">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">vlc</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">VLC Media Player</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btngedit">
<property name="label" translatable="yes">Gedit Text Editor</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image2</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
</property>
<property name="tab">
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="yes">Applications (Linux)</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnvlc">
<property name="label" translatable="yes">VLC Media Player</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image1</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>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Applications (Linux)</property>
</object>
<packing>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="btn_vlc">
<property name="label" translatable="yes">VLC Media Player</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</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">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_note">
<property name="label" translatable="yes">Notepad</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</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>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<object class="GtkNotebookPage">
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Applications (Win32)</property>
<property name="child">
<object class="GtkBox">
<property name="visible">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="btn_vlc">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">vlc</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">VLC Media Player</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btn_note">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">gedit</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Notepad</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</property>
<property name="tab">
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="yes">Applications (Win32)</property>
</object>
</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="btnabout">
<property name="label" translatable="yes">About</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image3</property>
<property name="relief">none</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnfiles">
<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="relief">none</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btndraw">
<property name="label" translatable="yes">Drawing App</property>
<property name="visible">True</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="GtkButton" id="btngame">
<property name="label" translatable="yes">Guess Game</property>
<property name="visible">True</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">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btneditor">
<property name="label" translatable="yes">Simple Text Editor</property>
<property name="visible">True</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">4</property>
</packing>
</child>
</object>
<packing>
<object class="GtkNotebookPage">
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">General Apps</property>
<property name="child">
<object class="GtkBox">
<property name="visible">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="btnabout">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">mygtkui_about</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">About</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btndraw">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">drawing_app</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Drawing App</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btnfiles">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">file-app</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">File Manager</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btngame">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">game</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Guess Game</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btnrun">
<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">Run</property>
</object>
</child>
<child>
<object class="GtkButton" id="btneditor">
<property name="visible">1</property>
<property name="focusable">1</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage">
<property name="pixel-size">16</property>
<property name="icon-name">gedit</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Simple Text Editor</property>
<property name="hexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
<property name="tab">
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="yes">General Apps</property>
</object>
</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
</child>
</property>
</object>
<object class="GtkButtonBox" id="left_panel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<template class="LeftPanel" parent="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<property name="layout-style">start</property>
<child>
<object class="GtkMenuButton" id="btnstart">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="focus-on-click">False</property>
<property name="receives-default">True</property>
<property name="relief">none</property>
<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="has-frame">0</property>
<property name="direction">right</property>
<property name="popover">popover1</property>
<child>
<object class="GtkImage" id="btn_image">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">start-here</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="non-homogeneous">True</property>
</packing>
</child>
<child>
<placeholder/>
@ -286,5 +349,5 @@
<child>
<placeholder/>
</child>
</object>
</template>
</interface>

View File

@ -1,6 +1,7 @@
#include <cstdlib>
#include <thread>
#include "LeftPanel.h"
#include "MainWin.h"
// #include "game.h"
// #include "TextEditor.h"
// #include "drawing.h"
@ -8,6 +9,20 @@
struct _LeftPanel{
GtkBox parent;
GtkWindow * parent_win;
GtkWidget * popover1;
GtkWidget * btnstart;
GtkWidget * btnaud;
GtkWidget * btngedit;
GtkWidget * btnvlc;
GtkWidget * btn_vlc;
GtkWidget * btn_note;
GtkWidget * btnabout;
GtkWidget * btnfiles;
GtkWidget * btndraw;
GtkWidget * btngame;
GtkWidget * btnrun;
GtkWidget * btneditor;
};
G_DEFINE_TYPE(LeftPanel,left_panel,GTK_TYPE_BOX)
@ -37,9 +52,49 @@ static void btnvlc_win32(GtkWidget *widget,gpointer data){
fifth.detach();
}
static void left_panel_init(LeftPanel * panel){}
void left_panel_set_parent(LeftPanel * self,GtkWindow * parent_win1){
self->parent_win = parent_win1;
}
static void left_panel_class_init(LeftPanelClass * klass){}
static void left_panel_init(LeftPanel * panel){
gtk_widget_init_template(GTK_WIDGET(panel));
//Set Image for start button
gtk_menu_button_set_label(GTK_MENU_BUTTON(panel->btnstart),"Start");
//Connect Signals
g_signal_connect(panel->btnaud,"clicked",G_CALLBACK(btnaud_clicked),NULL);
g_signal_connect_swapped(panel->btnaud,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
g_signal_connect(panel->btnvlc,"clicked",G_CALLBACK(btnvlc_clicked),NULL);
g_signal_connect_swapped(panel->btnvlc,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
g_signal_connect(panel->btngedit,"clicked",G_CALLBACK(btngedit_clicked),NULL);
g_signal_connect_swapped(panel->btngedit,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
g_signal_connect(panel->btn_note,"clicked",G_CALLBACK(btnnote_clicked),NULL);
g_signal_connect_swapped(panel->btn_note,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
g_signal_connect(panel->btn_vlc,"clicked",G_CALLBACK(btnvlc_win32),NULL);
g_signal_connect_swapped(panel->btn_vlc,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
g_signal_connect(panel->btnabout,"clicked",G_CALLBACK(btnabout_clicked),panel->parent_win);
g_signal_connect_swapped(panel->btnabout,"clicked",G_CALLBACK(gtk_popover_popdown),panel->popover1);
}
static void left_panel_class_init(LeftPanelClass * klass){
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(klass),
"/org/gtk/daleclack/leftpanel.ui");
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,popover1);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnstart);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnaud);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btngedit);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnvlc);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btn_vlc);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btn_note);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnabout);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btndraw);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnfiles);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btngame);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btnrun);
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(klass),LeftPanel,btneditor);
}
LeftPanel * left_panel_new(){
return (LeftPanel*)g_object_new(left_panel_get_type(),NULL);
@ -52,49 +107,6 @@ LeftPanel * left_panel_new(){
// }
// void add_leftpanel(GtkBuilder *builder,GtkFixed *fixed){
// //Get Left panel
// GtkBuilder *panel2=gtk_builder_new_from_resource("/gtk42/leftpanel.ui");
// GObject *panel=gtk_builder_get_object(panel2,"left_panel");
// //Set start button and image
// GObject *btn_image=gtk_builder_get_object(panel2,"btn_image");
// GdkPixbuf *pixbuf=gdk_pixbuf_new_from_resource("/gtk42/icon.png",NULL);
// GdkPixbuf *sized=gdk_pixbuf_scale_simple(pixbuf,40,40,GDK_INTERP_BILINEAR);
// gtk_image_set_from_pixbuf(GTK_IMAGE(btn_image),sized);
// //Get popover window
// GObject *popover=gtk_builder_get_object(panel2,"popover1");
// //Button image
// GtkWidget *img_vlc=gtk_image_new_from_resource("/gtk42/vlc.png");
// GtkWidget *img_aud=gtk_image_new_from_resource("/gtk42/audacious.png");
// GtkWidget *img_gedit=gtk_image_new_from_resource("/gtk42/gedit.png");
// //Audacious bin exec
// GObject *btn_audacious=gtk_builder_get_object(panel2,"btnaud");
// gtk_button_set_image(GTK_BUTTON(btn_audacious),img_aud);
// g_signal_connect(btn_audacious,"clicked",G_CALLBACK(btnaud_clicked),NULL);
// g_signal_connect_swapped(btn_audacious,"clicked",G_CALLBACK(gtk_widget_hide),popover);
// //vlc exec button for linux
// GObject *btnvlc=gtk_builder_get_object(panel2,"btnvlc");
// GObject *img_vlc1=gtk_builder_get_object(panel2,"image1");
// gtk_image_set_from_resource(GTK_IMAGE(img_vlc1),"/gtk42/vlc.png");
// g_signal_connect(btnvlc,"clicked",G_CALLBACK(btnvlc_clicked),NULL);
// g_signal_connect_swapped(btnvlc,"clicked",G_CALLBACK(gtk_widget_hide),popover);
// //Start Gedit Text Editor
// GObject *btngedit=gtk_builder_get_object(panel2,"btngedit");
// GObject *img_gedit1=gtk_builder_get_object(panel2,"image2");
// gtk_image_set_from_resource(GTK_IMAGE(img_gedit1),"/gtk42/gedit.png");
// g_signal_connect(btngedit,"clicked",G_CALLBACK(btngedit_clicked),NULL);
// g_signal_connect_swapped(btngedit,"clicked",G_CALLBACK(gtk_widget_hide),popover);
// //Notepad on windows
// GObject *btnnote=gtk_builder_get_object(panel2,"btn_note");
// gtk_button_set_image(GTK_BUTTON(btnnote),img_gedit);
// g_signal_connect(btnnote,"clicked",G_CALLBACK(btnnote_clicked),NULL);
// g_signal_connect_swapped(btnnote,"clicked",G_CALLBACK(gtk_widget_hide),popover);
// //VLC on windows
// GObject *btn_vlc=gtk_builder_get_object(panel2,"btn_vlc");
// gtk_button_set_image(GTK_BUTTON(btn_vlc),img_vlc);
// g_signal_connect(btn_vlc,"clicked",G_CALLBACK(btnvlc_win32),NULL);
// g_signal_connect_swapped(btn_vlc,"clicked",G_CALLBACK(gtk_widget_hide),popover);
// //Get main window
// GObject *window=gtk_builder_get_object(builder,"window");
// //Gtk31 application
// GObject *btngame=gtk_builder_get_object(panel2,"btngame");
// g_signal_connect(btngame,"clicked",G_CALLBACK(gamemain),window);

View File

@ -6,16 +6,4 @@ G_DECLARE_FINAL_TYPE(LeftPanel,left_panel,LEFT,PANEL,GtkBox)
LeftPanel * left_panel_new();
// void add_leftpanel(GtkBuilder *builder,GtkFixed *fixed);
// void btnfiles_clicked(GtkWidget *widget,GtkWindow *parent);
//void btnvlc_clicked(GtkWidget *widget,gpointer data);
//void btngedit_clicked(GtkWidget *widget,gpointer data);
//void btnaud_clicked(GtkWidget *widget,gpointer data);
//void btnnote_clicked(GtkWidget *widget,gpointer data);
//void btnvlc_win32(GtkWidget *widget,gpointer data);
void left_panel_set_parent(LeftPanel * self,GtkWindow * parent_win1);

View File

@ -1,4 +1,5 @@
#include "MainStack.h"
#include "LeftPanel.h"
static gboolean change_time(gpointer data){
//Get local time
@ -19,7 +20,7 @@ static void stack_login(GtkWidget *widget,GtkStack * stack){
gtk_stack_set_visible_child_name(stack,"main_page");
}
GtkWidget * create_main_stack(GtkWidget * left_box,GMenuModel * model){
GtkWidget * create_main_stack(MainWin * win,GMenuModel * model){
GtkBuilder * stack_builder;
stack_builder = gtk_builder_new_from_resource("/org/gtk/daleclack/stack.ui");
@ -42,7 +43,10 @@ GtkWidget * create_main_stack(GtkWidget * left_box,GMenuModel * model){
gtk_menu_button_set_popover(GTK_MENU_BUTTON(menubtn),popover);
//Box for LeftPanel
left_box = (GtkWidget*)gtk_builder_get_object(stack_builder,"leftbox");
GtkWidget * left_box = (GtkWidget*)gtk_builder_get_object(stack_builder,"leftbox");
LeftPanel * panel = left_panel_new();
left_panel_set_parent(panel,GTK_WINDOW(win));
gtk_box_append(GTK_BOX(left_box),GTK_WIDGET(panel));
return main_stack;
}

View File

@ -2,5 +2,6 @@
#include <gtk/gtk.h>
#include <ctime>
#include "MainWin.h"
GtkWidget * create_main_stack(GtkWidget * left_box,GMenuModel * model);
GtkWidget * create_main_stack(MainWin * win,GMenuModel * model);

View File

@ -17,7 +17,6 @@ struct _MainWin{
GtkGesture * gesture;
GtkWidget * popover;
GtkWidget * stack;
GtkWidget * leftbox;
int width,height;
BackMode back_mode;
};
@ -143,7 +142,7 @@ static void about_activated(GSimpleAction * action, GVariant * parmeter, gpointe
"program-name","My_GtkUI",
"version",version,
"copyright", "©2019—2021 The Xe Project",
"comments", "A program that simulates desktop",
"comments", "A program that simulates desktop (Gtk4 Version)",
"authors",authors,
"license-type",GTK_LICENSE_GPL_3_0,
"logo-icon-name","My_GtkUI",
@ -152,6 +151,10 @@ static void about_activated(GSimpleAction * action, GVariant * parmeter, gpointe
g_free(version);
}
void btnabout_clicked(GtkWidget * widget,gpointer data){
about_activated(NULL,NULL,data);
}
static void gesture_pressed(GtkGestureClick *self,int n_press,double x,double y,MainWin * win){
//When third button is pressed, show popover menu
GdkRectangle rect;
@ -207,7 +210,7 @@ static void main_win_init(MainWin * win){
gtk_widget_add_controller(win->overlay,GTK_EVENT_CONTROLLER(win->gesture));
//Add Main Page
win->stack = create_main_stack(win->leftbox,model);
win->stack = create_main_stack(win,model);
gtk_widget_set_halign(GTK_WIDGET(win->stack),GTK_ALIGN_FILL);
gtk_widget_set_valign(GTK_WIDGET(win->stack),GTK_ALIGN_FILL);
gtk_overlay_add_overlay(GTK_OVERLAY(win->overlay),GTK_WIDGET(win->stack));

View File

@ -5,3 +5,5 @@
G_DECLARE_FINAL_TYPE(MainWin,main_win,MAIN,WIN,GtkApplicationWindow)
MainWin * main_win_new(GtkApplication *app);
void btnabout_clicked(GtkWidget * widget,gpointer data);