From ecf6a6c6c67c873e749b30563253ff68e6f05515 Mon Sep 17 00:00:00 2001 From: daleclack Date: Wed, 23 Dec 2020 21:07:43 +0800 Subject: [PATCH] Update gtk28 --- Gtk3/gtk28/config | 1 + Gtk3/gtk28/gtk28.depend | 10 ++++++---- Gtk3/gtk28/gtkwin.cpp | 6 ++++++ Gtk3/gtk28/gtkwin.h | 7 +++++++ Gtk3/gtk28/test.cpp | 7 ++++++- Gtk3/gtk28/test.h | 6 +++++- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Gtk3/gtk28/config b/Gtk3/gtk28/config index e69de29..be29a96 100644 --- a/Gtk3/gtk28/config +++ b/Gtk3/gtk28/config @@ -0,0 +1 @@ +default config \ No newline at end of file diff --git a/Gtk3/gtk28/gtk28.depend b/Gtk3/gtk28/gtk28.depend index 7b92689..da65538 100644 --- a/Gtk3/gtk28/gtk28.depend +++ b/Gtk3/gtk28/gtk28.depend @@ -5,23 +5,25 @@ 1608375016 /root/cpp50/gtkclass.h -1608632226 source:/root/cpp50/gtkwin.cpp +1608645959 source:/root/cpp50/gtkwin.cpp "gtkwin.h" "test.h" "winpe.xpm" "360.xpm" -1608631524 /root/cpp50/gtkwin.h +1608645795 /root/cpp50/gtkwin.h 1608434422 source:/root/cpp50/main.cpp "gtkwin.h" -1608611669 source:/root/cpp50/test.cpp +1608632300 source:/root/cpp50/test.cpp "test.h" + "360.xpm" + "gtkwin.h" -1608631234 /root/cpp50/test.h +1608728677 /root/cpp50/test.h 1608125195 /root/cpp50/360.xpm diff --git a/Gtk3/gtk28/gtkwin.cpp b/Gtk3/gtk28/gtkwin.cpp index 3265c4b..adaed4d 100644 --- a/Gtk3/gtk28/gtkwin.cpp +++ b/Gtk3/gtk28/gtkwin.cpp @@ -3,6 +3,7 @@ #include "winpe.xpm" #include "360.xpm" +//Get a GtkImage from xpm.data void Icon::get_image(const gchar **str,int width,int height){ pixbuf=gdk_pixbuf_new_from_xpm_data(str); sized=gdk_pixbuf_scale_simple(pixbuf,width,height,GDK_INTERP_BILINEAR); @@ -36,6 +37,7 @@ void Winlayout::init(){ put(button1.button,150,100); } +//Initalize GtkHeader void WinHeader::init(GtkWidget *window){ MenuBar menubar; menubar.menu_init(window); @@ -44,14 +46,17 @@ void WinHeader::init(GtkWidget *window){ pack_start(menubar.menubar); } +//pack widgets on GtkHeader void WinHeader::pack_start(GtkWidget *child){ gtk_header_bar_pack_start(_header,child); } +//Append item to GtkMenuBar void MenuBar::menubar_append(Menuitem child){ gtk_menu_shell_append(GTK_MENU_SHELL(menubar),child.menuitem); } +//Initalize the menu void MenuBar::menu_init(GtkWidget *window){ Menuitem menuitem2; Menu menu; @@ -74,6 +79,7 @@ void MenuBar::menu_init(GtkWidget *window){ menu.menu_append(menuitem2); } +//append item to GtkMenu void Menu::menu_append(Menuitem child){ gtk_menu_shell_append(GTK_MENU_SHELL(menu),child.menuitem); } diff --git a/Gtk3/gtk28/gtkwin.h b/Gtk3/gtk28/gtkwin.h index 583b186..209b93d 100644 --- a/Gtk3/gtk28/gtkwin.h +++ b/Gtk3/gtk28/gtkwin.h @@ -1,6 +1,8 @@ #include typedef void(*pfun)(GtkWidget *,gpointer);//define a pointer to function + +//Convert xpm data to a GtkImage class Icon{ GdkPixbuf *sized; public: @@ -25,6 +27,7 @@ class Winlayout{ void init(); }; +//GtkHeaderbar class class WinHeader{ public: GtkWidget *header=gtk_header_bar_new(); @@ -33,12 +36,14 @@ class WinHeader{ void pack_start(GtkWidget *child); }; +//GtkMenuitem class class Menuitem{ public: GtkWidget *menuitem; void menuitem_init(const gchar *str,pfun func,gpointer data); }; +//GtkMenuBar class class MenuBar{ public: GtkWidget *menubar=gtk_menu_bar_new(); @@ -46,6 +51,7 @@ class MenuBar{ void menu_init(GtkWidget *window); }; +//GtkMenu class class Menu{ public: GtkWidget *menu; @@ -64,6 +70,7 @@ class GtkWin{ void show_all(); }; +//GtkHBox class (Not the deprecated GtkHbox) class HBox{ public: GtkWidget *hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); diff --git a/Gtk3/gtk28/test.cpp b/Gtk3/gtk28/test.cpp index 9b5b115..0ba35f9 100644 --- a/Gtk3/gtk28/test.cpp +++ b/Gtk3/gtk28/test.cpp @@ -21,6 +21,10 @@ void about_activate(GtkWidget *widget,gpointer data){ } void config_activate(GtkWidget *widget,gpointer data){ + InputBox("config"); +} + +void InputBox(const char *filename){ const gchar *str; int response; GtkWidget *dialog=gtk_dialog_new(); @@ -35,6 +39,7 @@ void config_activate(GtkWidget *widget,gpointer data){ GtkContainer *_content_area=GTK_CONTAINER(content_area); GtkWidget *label=gtk_label_new("Input config"); GtkWidget *entry=gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(entry),"default config"); gtk_container_add(_content_area,label); gtk_container_add(_content_area,entry); @@ -42,7 +47,7 @@ void config_activate(GtkWidget *widget,gpointer data){ response=gtk_dialog_run(dialog1); if(response==GTK_RESPONSE_OK){ str=gtk_entry_get_text(GTK_ENTRY(entry)); - freopen("config","w",stdout); + freopen(filename,"w",stdout); g_print(str); fclose(stdout); gtk_widget_destroy(dialog); diff --git a/Gtk3/gtk28/test.h b/Gtk3/gtk28/test.h index 35e0b61..79968b5 100644 --- a/Gtk3/gtk28/test.h +++ b/Gtk3/gtk28/test.h @@ -6,6 +6,10 @@ void quit(GtkWidget *widget,gpointer data); void config_activate(GtkWidget *widget,gpointer data); -void about_activate(GtkWidget *widget,gpointer data); +void InputBox(const char *filename); void MsgBox(const gchar *msg); + +void config_activate(GtkWidget *widget,gpointer data); + +void about_activate(GtkWidget *widget,gpointer data);