Elements. Build native projects for any modern development platform, using the language(s) of your choice. Oxygene (Object Pascal), C#, Swift, Java, Go. | RemObjects Software

Basic Linux Gtk App

Language: Iodine, Platform: Island, Category: GUI
https://github.com/remobjects/ElementsSamples/tree/master/Iodine/Island/GUI/Basic Linux Gtk App

  • BasicGtkApp
    • References
      • atk
      • cairo
      • gc
      • gdk
      • glib
      • gtk
      • Island
      • pango
      • rtl
      • Swift
    • Source Files
    • Other Files

Program.java

package BasicGtkApp;

// based on https://developer.gnome.org/gtk3/stable/gtk-getting-started.html

import atk.*;
import gobject.*;
import gio.*;
import gtk.*;

/*
  !!! Please note: in order to run this sample, you need to manually copy it to a Linux PC or VM with an active GUI, and run it.
  !!!
  !!! GUI applications cannot be run via SSH or CrossBox 2, and they are also not supported on "Bash on Windows".
*/

class Program {

	static GtkWindow *window;

	static void clicked(GtkApplication app, Void *userdata)
	{
		var dialog = (GtkDialog *)gtk_message_dialog_new(null,
														 GtkDialogFlags.GTK_DIALOG_DESTROY_WITH_PARENT,
														 GtkMessageType.GTK_MESSAGE_INFO,
														 GtkButtonsType.GTK_BUTTONS_OK,
														 "Hello World!");
		gtk_dialog_run(dialog);
		gtk_widget_destroy(dialog);
	}

	static void activate(GtkApplication *app, Void *userdata)
	{
		window = (GtkWindow *)gtk_application_window_new(app);
		gtk_window_set_title(window, "RemObjects Elements - Island GTK Sample");
		gtk_window_set_default_size(window, 200, 200);

		var button_box = gtk_button_box_new(GtkOrientation.GTK_ORIENTATION_HORIZONTAL);
		gtk_container_add(window, button_box);

		var button = gtk_button_new_with_label("Hello World");
		g_signal_connect_data((glib.gpointer)button, "clicked", (glib.GVoidFunc)((void *)(clicked)), null, null, (GConnectFlags)0);
		gtk_container_add((GtkContainer *)button_box, button);
		gtk_widget_show_all(window);
	}

	static Int32 Main(String[] args)
	{
		var app = gtk_application_new ("org.gtk.example", gio.GApplicationFlags.G_APPLICATION_FLAGS_NONE);
		g_signal_connect_data((glib.gpointer)app, "activate", (glib.GVoidFunc)((void *)(activate)), null, null, (GConnectFlags)0);
		var status = g_application_run (app, ExternalCalls.nargs, ExternalCalls.args);
		g_object_unref((glib.gpointer)app);
		return status;
	}
}