diff --git a/Gtk4/CMakeLists.txt b/Gtk4/CMakeLists.txt index 6b71e84..6555617 100644 --- a/Gtk4/CMakeLists.txt +++ b/Gtk4/CMakeLists.txt @@ -68,7 +68,7 @@ compile_gresources(RESOURCE_FILE # It depends on the output RESOURCE_FILE. add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE}) -set(SOURCES src/main.cpp src/MainWin.cpp src/MainStack.cpp) +set(SOURCES src/main.cpp src/MainWin.cpp src/MainStack.cpp src/LeftPanel.cpp) # Step 4:Add the resource to compile list and compile if(WIN32) diff --git a/Gtk4/res/title.ui b/Gtk4/res/title.ui deleted file mode 100644 index b7cb142..0000000 --- a/Gtk4/res/title.ui +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - True - False - start - - - True - False - Gtk42 Desktop - - - True - True - 0 - - - - - - - - - - diff --git a/Gtk4/res/toppanel.ui b/Gtk4/res/toppanel.ui deleted file mode 100644 index 1ee1603..0000000 --- a/Gtk4/res/toppanel.ui +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - True - False - ac-adapter-symbolic - - - True - False - system-help - - - True - False - - - True - False - - - True - False - - - False - - - True - False - vertical - 5 - start - - - Change back - True - True - True - image3 - none - - - True - True - 1 - - - - - Win Settings - True - True - True - image5 - none - - - True - True - 3 - - - - - Exit mainwin - True - True - True - image4 - none - - - True - True - 5 - - - - - - - True - False - end - - - - - - - - - - - - - - - - - - True - False - 20:00 2021/2/14 - - - True - True - 5 - - - - - True - True - True - image2 - none - - - True - True - 6 - True - - - - - True - True - True - image1 - none - - - True - True - 7 - True - - - - - True - True - False - True - none - vertical - audio-volume-muted-symbolic -audio-volume-high-symbolic -audio-volume-low-symbolic -audio-volume-medium-symbolic - - - False - False - - - - - False - False - - - - - True - True - 8 - True - - - - - True - True - False - True - none - popover1 - - - - - - True - True - 9 - True - - - - diff --git a/Gtk4/res/win1.ui b/Gtk4/res/win1.ui deleted file mode 100644 index a6f5b50..0000000 --- a/Gtk4/res/win1.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - False - dialog - Gtk Ui - 2.0 - 2020-2021 Xe Corporation - github.com/daleclack - Dale - org.gtk.daleclack - - - False - vertical - 2 - - - False - end - - - False - False - 0 - - - - - - - - - diff --git a/Gtk4/src/LeftPanel.cpp b/Gtk4/src/LeftPanel.cpp new file mode 100644 index 0000000..534b100 --- /dev/null +++ b/Gtk4/src/LeftPanel.cpp @@ -0,0 +1,121 @@ +#include +#include +#include "LeftPanel.h" +// #include "game.h" +// #include "TextEditor.h" +// #include "drawing.h" +// #include "FileWindow.h" + +struct _LeftPanel{ + GtkBox parent; +}; + +G_DEFINE_TYPE(LeftPanel,left_panel,GTK_TYPE_BOX) + +static void btnvlc_clicked(GtkWidget *widget,gpointer data){ + std::thread first(system,"vlc"); + first.detach(); +} + +static void btngedit_clicked(GtkWidget *widget,gpointer data){ + std::thread second(system,"gedit"); + second.detach(); +} + +static void btnaud_clicked(GtkWidget *widget,gpointer data){ + std::thread third(system,"audacious"); + third.detach(); +} + +static void btnnote_clicked(GtkWidget *widget,gpointer data){ + std::thread fourth(system,"start notepad"); + fourth.detach(); +} + +static void btnvlc_win32(GtkWidget *widget,gpointer data){ + std::thread fifth(system,"start ..\\vlc\\vlc.exe"); + fifth.detach(); +} + +static void left_panel_init(LeftPanel * panel){} + +static void left_panel_class_init(LeftPanelClass * klass){} + +LeftPanel * left_panel_new(){ + return (LeftPanel*)g_object_new(left_panel_get_type(),NULL); +} + +// void btnfiles_clicked(GtkWidget *widget,GtkWindow *parent){ +// FileWindow * window1 = file_window_new(); +// gtk_window_set_transient_for(GTK_WINDOW(window1),parent); +// gtk_widget_show_all(GTK_WIDGET(window1)); +// } + +// 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); +// g_signal_connect_swapped(btngame,"clicked",G_CALLBACK(gtk_widget_hide),popover); +// //Text Editor(Gtk86) +// GObject *btnedit=gtk_builder_get_object(panel2,"btneditor"); +// g_signal_connect(btnedit,"clicked",G_CALLBACK(text_editor),window); +// g_signal_connect_swapped(btnedit,"clicked",G_CALLBACK(gtk_widget_hide),popover); +// //Drawing application +// GObject *btndraw=gtk_builder_get_object(panel2,"btndraw"); +// g_signal_connect(btndraw,"clicked",G_CALLBACK(drawing_main),window); +// g_signal_connect_swapped(btndraw,"clicked",G_CALLBACK(gtk_widget_hide),popover); +// //About window +// GObject *btn_about=gtk_builder_get_object(panel2,"btnabout"); +// g_signal_connect(btn_about,"clicked",G_CALLBACK(win1_init),window); +// g_signal_connect_swapped(btn_about,"clicked",G_CALLBACK(gtk_widget_hide),popover); +// //File Manager +// GObject *btnfiles=gtk_builder_get_object(panel2,"btnfiles"); +// g_signal_connect(btnfiles,"clicked",G_CALLBACK(btnfiles_clicked),window); +// g_signal_connect_swapped(btnfiles,"clicked",G_CALLBACK(gtk_widget_hide),popover); +// gtk_fixed_put(fixed,GTK_WIDGET(panel),0,25); +// g_object_unref(pixbuf); +// g_object_unref(sized); +// } diff --git a/Gtk4/src/panel2.h b/Gtk4/src/LeftPanel.h similarity index 55% rename from Gtk4/src/panel2.h rename to Gtk4/src/LeftPanel.h index f3a7bfe..eb29b07 100644 --- a/Gtk4/src/panel2.h +++ b/Gtk4/src/LeftPanel.h @@ -1,11 +1,14 @@ -#ifndef __PANEL2_H_ -#define __PANEL2_H_ +#pragma once #include -void add_leftpanel(GtkBuilder *builder,GtkFixed *fixed); +G_DECLARE_FINAL_TYPE(LeftPanel,left_panel,LEFT,PANEL,GtkBox) -void btnfiles_clicked(GtkWidget *widget,GtkWindow *parent); +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); @@ -16,5 +19,3 @@ void btnfiles_clicked(GtkWidget *widget,GtkWindow *parent); //void btnnote_clicked(GtkWidget *widget,gpointer data); //void btnvlc_win32(GtkWidget *widget,gpointer data); - -#endif diff --git a/Gtk4/src/panel2.cpp b/Gtk4/src/panel2.cpp deleted file mode 100644 index c683ba0..0000000 --- a/Gtk4/src/panel2.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include "panel2.h" -#include "win1.h" -#include "game.h" -#include "TextEditor.h" -#include "drawing.h" -#include "FileWindow.h" - -static void btnvlc_clicked(GtkWidget *widget,gpointer data){ - std::thread first(system,"vlc"); - first.detach(); -} - -static void btngedit_clicked(GtkWidget *widget,gpointer data){ - std::thread second(system,"gedit"); - second.detach(); -} - -static void btnaud_clicked(GtkWidget *widget,gpointer data){ - std::thread third(system,"audacious"); - third.detach(); -} - -static void btnnote_clicked(GtkWidget *widget,gpointer data){ - std::thread fourth(system,"start notepad"); - fourth.detach(); -} - -static void btnvlc_win32(GtkWidget *widget,gpointer data){ - std::thread fifth(system,"start ..\\vlc\\vlc.exe"); - fifth.detach(); -} - -void btnfiles_clicked(GtkWidget *widget,GtkWindow *parent){ - FileWindow * window1 = file_window_new(); - gtk_window_set_transient_for(GTK_WINDOW(window1),parent); - gtk_widget_show_all(GTK_WIDGET(window1)); -} - -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); - g_signal_connect_swapped(btngame,"clicked",G_CALLBACK(gtk_widget_hide),popover); - //Text Editor(Gtk86) - GObject *btnedit=gtk_builder_get_object(panel2,"btneditor"); - g_signal_connect(btnedit,"clicked",G_CALLBACK(text_editor),window); - g_signal_connect_swapped(btnedit,"clicked",G_CALLBACK(gtk_widget_hide),popover); - //Drawing application - GObject *btndraw=gtk_builder_get_object(panel2,"btndraw"); - g_signal_connect(btndraw,"clicked",G_CALLBACK(drawing_main),window); - g_signal_connect_swapped(btndraw,"clicked",G_CALLBACK(gtk_widget_hide),popover); - //About window - GObject *btn_about=gtk_builder_get_object(panel2,"btnabout"); - g_signal_connect(btn_about,"clicked",G_CALLBACK(win1_init),window); - g_signal_connect_swapped(btn_about,"clicked",G_CALLBACK(gtk_widget_hide),popover); - //File Manager - GObject *btnfiles=gtk_builder_get_object(panel2,"btnfiles"); - g_signal_connect(btnfiles,"clicked",G_CALLBACK(btnfiles_clicked),window); - g_signal_connect_swapped(btnfiles,"clicked",G_CALLBACK(gtk_widget_hide),popover); - gtk_fixed_put(fixed,GTK_WIDGET(panel),0,25); - g_object_unref(pixbuf); - g_object_unref(sized); -} diff --git a/Gtk4/src/win1.cpp b/Gtk4/src/win1.cpp deleted file mode 100644 index ff3a634..0000000 --- a/Gtk4/src/win1.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "win1.h" - -void win1_init(GtkWidget *widget,GtkWindow *parent){ - //"About" window - GtkBuilder *win1=gtk_builder_new_from_resource("/gtk42/win1.ui"); - GObject *window1=gtk_builder_get_object(win1,"window1"); - gtk_window_set_transient_for(GTK_WINDOW(window1),parent); - //Window icon fix for win32 platform - GdkPixbuf *logo=gdk_pixbuf_new_from_resource("/gtk42/icon.jpg",NULL); - GdkPixbuf *logo_sized=gdk_pixbuf_scale_simple(logo,100,100,GDK_INTERP_BILINEAR); - gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(window1),logo_sized); - //Add version information - char *version; - version=g_strdup_printf("2.6\nRunning Against Gtk %d.%d.%d", - gtk_get_major_version(), - gtk_get_minor_version(), - gtk_get_micro_version()); - gtk_about_dialog_set_version((GtkAboutDialog*)window1,version); - //Copyright,license and website information - gtk_about_dialog_set_copyright((GtkAboutDialog*)window1,"© 2019—2021 The Xe Project"); - gtk_about_dialog_set_license_type((GtkAboutDialog*)window1,GTK_LICENSE_GPL_3_0); - gtk_about_dialog_set_website((GtkAboutDialog*)window1,"https://github.com/daleclack/My_GtkUi"); - g_signal_connect_swapped(window1,"response",G_CALLBACK(gtk_widget_destroy),window1); - gtk_widget_show_all(GTK_WIDGET(window1)); -} diff --git a/Gtk4/src/win1.h b/Gtk4/src/win1.h deleted file mode 100644 index 723ce35..0000000 --- a/Gtk4/src/win1.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __WIN1_H_ -#define __WIN1_H_ - -#include - -void win1_init(GtkWidget *widget,GtkWindow *parent); - -#endif