Update gtk41

This commit is contained in:
daleclack 2021-02-11 08:56:47 +08:00
parent 5a89260798
commit e092956d3a
3 changed files with 28 additions and 2 deletions

View File

@ -33,7 +33,15 @@
<property name="show-close-button">True</property> <property name="show-close-button">True</property>
<property name="decoration-layout">close,minimize,maximize:icon</property> <property name="decoration-layout">close,minimize,maximize:icon</property>
<child> <child>
<placeholder/> <object class="GtkButton" id="btnsize">
<property name="label" translatable="yes">Win size</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child> </child>
</object> </object>
</child> </child>

View File

@ -26,7 +26,16 @@
</object> </object>
</child> </child>
<child type="titlebar"> <child type="titlebar">
<placeholder/> <object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">gtk41</property>
<property name="show-close-button">True</property>
<property name="decoration-layout">close,minimize,maximize:icon</property>
<child>
<placeholder/>
</child>
</object>
</child> </child>
</object> </object>
</interface> </interface>

View File

@ -1,6 +1,12 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "res/winpe.xpm" #include "res/winpe.xpm"
void get_winsize(GtkWidget *widget,GtkWindow *window){
gint width,height;
gtk_window_get_size(window,&width,&height);
g_print("%d %d\n",width,height);
}
gboolean window_resize(GtkWidget *widget,GdkEvent *event,GtkBuilder *builder){ gboolean window_resize(GtkWidget *widget,GdkEvent *event,GtkBuilder *builder){
//Get window size //Get window size
gint width,height; gint width,height;
@ -22,6 +28,9 @@ static void gtkmain(GtkApplication *app,gpointer user_data){
GtkBuilder *builder=gtk_builder_new_from_file("res/window.ui"); GtkBuilder *builder=gtk_builder_new_from_file("res/window.ui");
GObject *window=gtk_builder_get_object(builder,"window"); GObject *window=gtk_builder_get_object(builder,"window");
gtk_application_add_window(app,GTK_WINDOW(window)); gtk_application_add_window(app,GTK_WINDOW(window));
//Get window size
GObject *btnsize=gtk_builder_get_object(builder,"btnsize");
g_signal_connect(btnsize,"clicked",G_CALLBACK(get_winsize),window);
gtk_widget_show_all(GTK_WIDGET(window)); gtk_widget_show_all(GTK_WIDGET(window));
g_signal_connect(window,"window-state-event",G_CALLBACK(window_resize),builder); g_signal_connect(window,"window-state-event",G_CALLBACK(window_resize),builder);
} }