ui/gtk/window.c

changeset 763
258ec399fbe6
parent 727
de40bc4811b1
child 764
5ff4b9c0cf96
equal deleted inserted replaced
762:9452eccfc0f0 763:258ec399fbe6
75 // delay exit handler 75 // delay exit handler
76 g_idle_add(ui_window_destroy, data); 76 g_idle_add(ui_window_destroy, data);
77 } 77 }
78 78
79 static gboolean ui_window_close_request(UiObject *obj) { 79 static gboolean ui_window_close_request(UiObject *obj) {
80 if(obj->widget) {
81 void *appwindow = g_object_get_data(G_OBJECT(obj->widget), "ui.appwindow");
82 if(appwindow) {
83 int width = 0;
84 int height = 0;
85 #if GTK_CHECK_VERSION(4, 10, 0)
86 graphene_rect_t bounds;
87 if(gtk_widget_compute_bounds(obj->widget, obj->widget, &bounds)) {
88 width = bounds.size.width;
89 height = bounds.size.height;
90 }
91 #elif GTK_CHECK_VERSION(4, 0, 0)
92 GtkAllocation alloc;
93 gtk_widget_get_allocation(GTK_WIDGET(obj->widget), &alloc);
94 width = alloc.width;
95 height = alloc.height;
96 #else
97 gtk_window_get_size(GTK_WINDOW(obj->widget), &width, &height);
98 #endif
99 if(width > 0 && height > 0) {
100 char width_str[32];
101 char height_str[32];
102 snprintf(width_str, 32, "%d", width);
103 snprintf(height_str, 32, "%d", height);
104 ui_set_property("ui.window.width", width_str);
105 ui_set_property("ui.window.height", height_str);
106 }
107 }
108 }
109
80 uic_context_prepare_close(obj->ctx); 110 uic_context_prepare_close(obj->ctx);
81 obj->ref--; 111 obj->ref--;
82 if(obj->ref > 0) { 112 if(obj->ref > 0) {
83 #if GTK_CHECK_VERSION(2, 18, 0) 113 #if GTK_CHECK_VERSION(2, 18, 0)
84 gtk_widget_set_visible(obj->widget, FALSE); 114 gtk_widget_set_visible(obj->widget, FALSE);
118 obj->ctx->action_map = G_ACTION_MAP(obj->widget); 148 obj->ctx->action_map = G_ACTION_MAP(obj->widget);
119 #endif 149 #endif
120 150
121 if(title != NULL) { 151 if(title != NULL) {
122 gtk_window_set_title(GTK_WINDOW(obj->widget), title); 152 gtk_window_set_title(GTK_WINDOW(obj->widget), title);
153 }
154
155 if(!simple) {
156 g_object_set_data(G_OBJECT(obj->widget), "ui.appwindow", obj);
123 } 157 }
124 158
125 const char *width = ui_get_property("ui.window.width"); 159 const char *width = ui_get_property("ui.window.width");
126 const char *height = ui_get_property("ui.window.height"); 160 const char *height = ui_get_property("ui.window.height");
127 if(width && height) { 161 if(width && height) {

mercurial