diff --git a/Gtk3/gtk28/config_1 b/Gtk3/gtk28/config_1 index be29a96..833796e 100644 --- a/Gtk3/gtk28/config_1 +++ b/Gtk3/gtk28/config_1 @@ -1 +1 @@ -default config \ No newline at end of file +default config1 \ No newline at end of file diff --git a/Gtk3/gtk28/config_2 b/Gtk3/gtk28/config_2 index be29a96..12111be 100644 --- a/Gtk3/gtk28/config_2 +++ b/Gtk3/gtk28/config_2 @@ -1 +1 @@ -default config \ No newline at end of file +default config2 \ No newline at end of file diff --git a/Gtk3/gtk28/gtk28.depend b/Gtk3/gtk28/gtk28.depend index b98f4b4..44bd3c6 100644 --- a/Gtk3/gtk28/gtk28.depend +++ b/Gtk3/gtk28/gtk28.depend @@ -30,13 +30,13 @@ 1606780433 /root/cpp50/winpe.xpm -1608874721 source:/root/gtk28/gtkwin.cpp +1608950527 source:/root/gtk28/gtkwin.cpp "gtkwin.h" "test.h" "winpe.xpm" "360.xpm" -1608645795 /root/gtk28/gtkwin.h +1608949828 /root/gtk28/gtkwin.h 1608874688 /root/gtk28/test.h diff --git a/Gtk3/gtk28/gtk28.layout b/Gtk3/gtk28/gtk28.layout index 8c21422..b292e52 100644 --- a/Gtk3/gtk28/gtk28.layout +++ b/Gtk3/gtk28/gtk28.layout @@ -2,56 +2,42 @@ + + + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/Gtk3/gtk28/gtkwin.cpp b/Gtk3/gtk28/gtkwin.cpp index e57476a..3d84270 100644 --- a/Gtk3/gtk28/gtkwin.cpp +++ b/Gtk3/gtk28/gtkwin.cpp @@ -31,10 +31,15 @@ void Winlayout::init(){ Icon background; background.get_image(winpe,400,300); put(background.img1,0,0); + + Combobox combo1; + combo1.init(100,50); + put(combo1.combo,150,70); + GtkBtn button1; button1.init("Test",100,50); - button1.signal_clicked(print,NULL); - put(button1.button,150,100); + button1.signal_clicked(print,(gpointer)combo1.combo); + put(button1.button,150,170); } //Initalize GtkHeader @@ -135,3 +140,15 @@ void GtkWin::show_all(){ void HBox::pack_start(GtkWidget *child,gboolean expand,gboolean full,gint padding){ gtk_box_pack_start(GTK_BOX(hbox),child,expand,full,padding); } + +void Combobox::append_item(const gchar *str){ + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),str); +} + +void Combobox::init(int width,int height){ + combo=gtk_combo_box_text_new(); + gtk_widget_set_size_request(combo,width,height); + append_item("config_1"); + append_item("config_2"); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0); +} diff --git a/Gtk3/gtk28/gtkwin.h b/Gtk3/gtk28/gtkwin.h index 209b93d..f7c5fa8 100644 --- a/Gtk3/gtk28/gtkwin.h +++ b/Gtk3/gtk28/gtkwin.h @@ -76,3 +76,10 @@ class HBox{ GtkWidget *hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); void pack_start(GtkWidget *child,gboolean expand,gboolean full,gint padding); }; + +class Combobox{ + public: + GtkWidget *combo; + void append_item(const gchar *str); + void init(int width,int height); +}; diff --git a/Gtk3/gtk28/test.cpp b/Gtk3/gtk28/test.cpp index 10e4473..71d30a5 100644 --- a/Gtk3/gtk28/test.cpp +++ b/Gtk3/gtk28/test.cpp @@ -5,8 +5,16 @@ #include "gtkwin.h" void print(GtkWidget *widget,gpointer data){ + const gchar *filename; + int id=gtk_combo_box_get_active(GTK_COMBO_BOX(data)); + switch(id){ + case 0: + filename="config_1";break; + case 1: + filename="config_2";break; + } char str[57]; - freopen("config","r",stdin); + freopen(filename,"r",stdin); fgets(str,57,stdin); MsgBox("Test",str); fclose(stdin);