2022-10-02 23:06:56 +02:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
|
#include "../defines.h"
|
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
2023-08-17 12:59:37 +02:00
|
|
|
#include "../widgets/WrapperWidget.h"
|
2023-10-31 22:37:11 +01:00
|
|
|
#include "../views/AndroidLayout.h"
|
2023-08-17 12:59:37 +02:00
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
#include "../generated_headers/android_view_ViewGroup.h"
|
|
|
|
|
#include "../generated_headers/android_view_View.h"
|
|
|
|
|
|
2023-08-17 12:59:37 +02:00
|
|
|
JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1addView(JNIEnv *env, jobject this, jlong widget, jlong child, jint index, jobject layout_params)
|
|
|
|
|
{
|
2022-10-02 23:06:56 +02:00
|
|
|
if(layout_params) {
|
|
|
|
|
/*
|
2023-08-17 12:59:37 +02:00
|
|
|
GtkWidget *_child = gtk_widget_get_parent(GTK_WIDGET(_PTR(child)));
|
|
|
|
|
jint child_width = -1;
|
|
|
|
|
jint child_height = -1;
|
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
jint child_width = _GET_INT_FIELD(layout_params, "width");
|
|
|
|
|
jint child_height = _GET_INT_FIELD(layout_params, "height");
|
|
|
|
|
|
|
|
|
|
jint child_gravity = _GET_INT_FIELD(layout_params, "gravity");
|
|
|
|
|
|
|
|
|
|
if(child_width > 0)
|
|
|
|
|
g_object_set(G_OBJECT(_child), "width-request", child_width, NULL);
|
|
|
|
|
if(child_height > 0)
|
|
|
|
|
g_object_set(G_OBJECT(_child), "height-request", child_height, NULL);
|
|
|
|
|
|
|
|
|
|
if(child_gravity != -1) {
|
|
|
|
|
printf(":::-: setting child gravity: %d", child_gravity);
|
|
|
|
|
Java_android_view_View_setGravity(env, child, child_gravity);
|
|
|
|
|
}*/
|
|
|
|
|
}
|
2023-09-01 13:49:42 +02:00
|
|
|
GtkWidget *parent = _PTR(widget);
|
|
|
|
|
GtkWidget *iter = gtk_widget_get_first_child(parent);
|
|
|
|
|
for(int i = 0; i < index; i++) {
|
|
|
|
|
iter = gtk_widget_get_next_sibling(iter);
|
|
|
|
|
if(iter == NULL)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_insert_before(gtk_widget_get_parent(GTK_WIDGET(_PTR(child))), parent, iter);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 12:59:37 +02:00
|
|
|
JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1removeView(JNIEnv *env, jobject this, jlong widget, jlong child)
|
2022-10-02 23:06:56 +02:00
|
|
|
{
|
2023-09-01 13:49:42 +02:00
|
|
|
gtk_widget_unparent(gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|