Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

SWT/Devel/Gtk/PI

< SWT‎ | Devel‎ | Gtk
Revision as of 15:03, 6 August 2015 by Unnamed Poltroon (Talk) (Created page with "= About SWT PI development = PI as in aPI means Program Interface. This is a means to write java code that makes native C Gtk calls. This is particularly useful for testing...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

About SWT PI development

PI as in aPI means Program Interface.

This is a means to write java code that makes native C Gtk calls. This is particularly useful for testing GTK code without the entire SWT framework running concurrently.

An example snippet would be:

 public class Snippet1 {
 public static void main (String [] args) {
   OS.gtk_init_check(new long[0], new long[0]);
     /* create a new window */
     long window = OS.gtk_window_new(OS.GTK_WINDOW_TOPLEVEL);
     OS.gtk_window_set_title(window, OS.ascii("GTK Menu Test"));
     long menu = OS.gtk_menu_new();
     long root_menu = OS.gtk_image_menu_item_new_with_label(OS.ascii("Root Menu"));
     OS.gtk_widget_show(root_menu);
     for(int i = 0; i < 3; i++) {
       String buf = "Test-undermenu -" + i;
       long menu_items = OS.gtk_image_menu_item_new_with_label(OS.ascii(buf));
       OS.gtk_menu_shell_insert(menu, menu_items, i);
       OS.gtk_widget_show(menu_items);
     }
     /* Now we specify that we want our newly created "menu" to be the menu for the "root menu" */
     OS.gtk_menu_item_set_submenu(root_menu, menu);
     /* Create a menu-bar to hold the menus and add it to our main window*/
     long menu_bar = OS.gtk_menu_bar_new();
     OS.gtk_container_add(window, menu_bar);
     OS.gtk_widget_show(menu_bar);
     OS.gtk_menu_shell_insert(menu_bar, root_menu, 0);
     OS.gtk_widget_show(window);
     OS.gtk_main ();
 }
 }

Back to the top