Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,20 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gsk_1render_1node_1unref)
}
#endif

#ifndef NO_gtk_1actionable_1set_1action_1name
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1actionable_1set_1action_1name)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1)
{
jbyte *lparg1=NULL;
GTK4_NATIVE_ENTER(env, that, gtk_1actionable_1set_1action_1name_FUNC);
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
gtk_actionable_set_action_name((GtkActionable *)arg0, (const char *)lparg1);
fail:
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1actionable_1set_1action_1name_FUNC);
}
#endif

#ifndef NO_gtk_1box_1append
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1box_1append)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
Expand Down Expand Up @@ -2260,6 +2274,22 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1picture_1set_1paintable)
}
#endif

#ifndef NO_gtk_1popover_1menu_1add_1child
JNIEXPORT jboolean JNICALL GTK4_NATIVE(gtk_1popover_1menu_1add_1child)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jbyteArray arg2)
{
jbyte *lparg2=NULL;
jboolean rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1popover_1menu_1add_1child_FUNC);
if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
rc = (jboolean)gtk_popover_menu_add_child((GtkPopoverMenu *)arg0, (GtkWidget *)arg1, (const char *)lparg2);
fail:
if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1popover_1menu_1add_1child_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1popover_1menu_1bar_1new_1from_1model
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1popover_1menu_1bar_1new_1from_1model)
(JNIEnv *env, jclass that, jlong arg0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ typedef enum {
gdk_1toplevel_1size_1set_1size_FUNC,
gsk_1render_1node_1draw_FUNC,
gsk_1render_1node_1unref_FUNC,
gtk_1actionable_1set_1action_1name_FUNC,
gtk_1box_1append_FUNC,
gtk_1box_1insert_1child_1after_FUNC,
gtk_1box_1prepend_FUNC,
Expand Down Expand Up @@ -185,6 +186,7 @@ typedef enum {
gtk_1picture_1new_FUNC,
gtk_1picture_1set_1can_1shrink_FUNC,
gtk_1picture_1set_1paintable_FUNC,
gtk_1popover_1menu_1add_1child_FUNC,
gtk_1popover_1menu_1bar_1new_1from_1model_FUNC,
gtk_1popover_1menu_1get_1menu_1model_FUNC,
gtk_1popover_1menu_1new_1from_1model_1full_FUNC,
Expand Down
14 changes: 14 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -11984,6 +11984,20 @@ JNIEXPORT void JNICALL OS_NATIVE(g_1menu_1item_1set_1attribute)
}
#endif

#ifndef NO_g_1menu_1item_1set_1attribute_1value
JNIEXPORT void JNICALL OS_NATIVE(g_1menu_1item_1set_1attribute_1value)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1, jlong arg2)
{
jbyte *lparg1=NULL;
OS_NATIVE_ENTER(env, that, g_1menu_1item_1set_1attribute_1value_FUNC);
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
g_menu_item_set_attribute_value((GMenuItem *)arg0, (const gchar *)lparg1, (GVariant *)arg2);
fail:
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
OS_NATIVE_EXIT(env, that, g_1menu_1item_1set_1attribute_1value_FUNC);
}
#endif

#ifndef NO_g_1menu_1item_1set_1label
JNIEXPORT void JNICALL OS_NATIVE(g_1menu_1item_1set_1label)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ typedef enum {
g_1menu_1item_1new_1section_FUNC,
g_1menu_1item_1new_1submenu_FUNC,
g_1menu_1item_1set_1attribute_FUNC,
g_1menu_1item_1set_1attribute_1value_FUNC,
g_1menu_1item_1set_1label_FUNC,
g_1menu_1item_1set_1submenu_FUNC,
g_1menu_1new_FUNC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,12 @@ public static final native long g_dbus_proxy_new_for_bus_sync(int bus_type, int
* @param data cast=(const gchar *)
*/
public static final native void g_menu_item_set_attribute(long menu_item, byte[] attribute, byte[] format_string, long data);
/**
* @param menu_item cast=(GMenuItem *)
* @param attribute cast=(const gchar *)
* @param value cast=(GVariant *)
*/
public static final native void g_menu_item_set_attribute_value(long menu_item, byte[] attribute, long value);

/* GSimpleActionGroup */
public static final native long g_simple_action_group_new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public class GTK4 {
*/
public static final native void gtk_rgb_to_hsv(float r, float g, float b, float[] h, float[] s, float[] v);

/* GtkActionable */
/**
* @param actionable cast=(GtkActionable *)
* @param action_name cast=(const char *)
*/
public static final native void gtk_actionable_set_action_name(long actionable, byte[] action_name);

/* GtkBox */
/**
* @param box cast=(GtkBox *)
Expand Down Expand Up @@ -588,6 +595,12 @@ public class GTK4 {
public static final native void gtk_text_set_tabs(long entry, long tabs);

/* GtkPopoverMenu */
/**
* @param popover cast=(GtkPopoverMenu *)
* @param child cast=(GtkWidget *)
* @param id cast=(const char *)
*/
public static final native boolean gtk_popover_menu_add_child(long popover, long child, byte[] id);
/**
* @param model cast=(GMenuModel *)
* @param flags cast=(GtkPopoverMenuFlags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,9 @@ long gtk_map (long widget) {
* The POP_UP GtkPopoverMenu has been mapped. Its handle IS the GtkPopoverMenu,
* and nested GtkPopoverMenu children for any CASCADE submenus already exist in
* its widget tree. Connect SHOW/HIDE signals for those nested submenus now.
* Also inject any custom icon widgets into the popover.
*/
injectCustomMenuIcons();
connectCascadeSubMenuSignals(this, handle);
}
}
Expand All @@ -886,6 +888,7 @@ private void connectDropDownMenuSignals() {
display.addWidget(popover, menuItem.menu);
OS.g_signal_connect_closure_by_id(popover, display.signalIds[SHOW], 0, display.getClosure(SHOW), false);
OS.g_signal_connect_closure_by_id(popover, display.signalIds[HIDE], 0, display.getClosure(HIDE), false);
menuItem.menu.injectCustomMenuIcons();
/*
* Also connect SHOW/HIDE signals for nested CASCADE submenus.
*/
Expand Down Expand Up @@ -917,13 +920,23 @@ private void connectCascadeSubMenuSignals(Menu menu, long parentPopoverHandle) {
display.addWidget(nestedPopover, item.menu);
OS.g_signal_connect_closure_by_id(nestedPopover, display.signalIds[SHOW], 0, display.getClosure(SHOW), false);
OS.g_signal_connect_closure_by_id(nestedPopover, display.signalIds[HIDE], 0, display.getClosure(HIDE), false);
item.menu.injectCustomMenuIcons();
// Recurse to handle further nested CASCADE submenus
connectCascadeSubMenuSignals(item.menu);
}
}
}
}

void injectCustomMenuIcons() {
if (items == null) return;
for (MenuItem item : items) {
if ((item.style & SWT.SEPARATOR) == 0 && item.customWidgetHandle != 0) {
item.injectCustomWidgetGTK4();
}
}
}

private long findNestedPopoverForModel(long parentWidget, long targetModel) {
if (parentWidget == 0 || targetModel == 0) return 0;
long child = GTK4.gtk_widget_get_first_child(parentWidget);
Expand Down Expand Up @@ -985,6 +998,7 @@ long gtk_show (long widget) {
sendEvent (SWT.Show);
/* Retry cascade submenu signal hookup once the DROP_DOWN popover is shown. */
if (GTK.GTK4 && (style & SWT.DROP_DOWN) != 0 && popoverHandle != 0) {
injectCustomMenuIcons();
connectCascadeSubMenuSignals(this, popoverHandle);
}
if (OS.ubuntu_menu_proxy_get() != 0) {
Expand Down
Loading
Loading