comparison gtk4/dw.c @ 2275:51cb73faab6e

GTK4: Implement dw_window_from_id().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 01 Feb 2021 21:22:31 +0000
parents b0bdd54bb2e8
children d7f0254f7d1e
comparison
equal deleted inserted replaced
2274:b0bdd54bb2e8 2275:51cb73faab6e
3268 * handle: Handle to the parent window. 3268 * handle: Handle to the parent window.
3269 * id: Integer ID of the child. 3269 * id: Integer ID of the child.
3270 */ 3270 */
3271 HWND API dw_window_from_id(HWND handle, int id) 3271 HWND API dw_window_from_id(HWND handle, int id)
3272 { 3272 {
3273 /* TODO: Figure out how to do this in GTK4 without GtkContainer */ 3273 if(handle && GTK_WIDGET(handle) && id)
3274 #if GTK3 3274 {
3275 GList *orig = NULL, *list = NULL; 3275 GtkWidget *widget = gtk_widget_get_first_child(GTK_WIDGET(handle));
3276 3276
3277 if(handle && GTK_IS_CONTAINER(handle)) 3277 while(widget)
3278 { 3278 {
3279 orig = list = gtk_container_get_children(GTK_CONTAINER(handle)); 3279 if(id == GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_id")))
3280 } 3280 return widget;
3281 while(list) 3281 widget = gtk_widget_get_next_sibling(GTK_WIDGET(widget));
3282 { 3282 }
3283 if(GTK_IS_WIDGET(list->data)) 3283 }
3284 { 3284 return 0;
3285 if(id == GPOINTER_TO_INT(g_object_get_data(G_OBJECT(list->data), "_dw_id")))
3286 {
3287 HWND ret = (HWND)list->data;
3288 g_list_free(orig);
3289 return ret;
3290 }
3291 }
3292 list = list->next;
3293 }
3294 if(orig)
3295 g_list_free(orig);
3296 #endif
3297 return 0L;
3298 } 3285 }
3299 3286
3300 /* 3287 /*
3301 * Adds text to an MLE box and returns the current point. 3288 * Adds text to an MLE box and returns the current point.
3302 * Parameters: 3289 * Parameters: