Added JNA libraries
This commit is contained in:
parent
5cccdb692e
commit
c4edf9bd63
|
@ -0,0 +1,135 @@
|
|||
package dorkbox.util.jna.linux;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import dorkbox.util.Keep;
|
||||
import dorkbox.util.jna.linux.Gobject.GObjectClassStruct;
|
||||
import dorkbox.util.jna.linux.Gobject.GObjectStruct;
|
||||
|
||||
/* bindings for libappindicator 0.1 */
|
||||
public interface AppIndicator extends Library {
|
||||
public static AppIndicator INSTANCE = (AppIndicator) Native.loadLibrary("appindicator", AppIndicator.class);
|
||||
|
||||
|
||||
public static final int CATEGORY_APPLICATION_STATUS = 0;
|
||||
public static final int CATEGORY_COMMUNICATIONS = 1;
|
||||
public static final int CATEGORY_SYSTEM_SERVICES = 2;
|
||||
public static final int CATEGORY_HARDWARE = 3;
|
||||
public static final int CATEGORY_OTHER = 4;
|
||||
|
||||
public static final int STATUS_PASSIVE = 0;
|
||||
public static final int STATUS_ACTIVE = 1;
|
||||
public static final int STATUS_ATTENTION = 2;
|
||||
|
||||
@dorkbox.util.Keep
|
||||
public interface Fallback extends Callback {
|
||||
public Pointer callback(AppIndicatorInstanceStruct self);
|
||||
}
|
||||
|
||||
@Keep
|
||||
public interface Unfallback extends Callback {
|
||||
public void callback(AppIndicatorInstanceStruct self, Pointer status_icon);
|
||||
}
|
||||
|
||||
@Keep
|
||||
public class AppIndicatorClassStruct extends Structure {
|
||||
public class ByReference extends AppIndicatorClassStruct implements Structure.ByReference {}
|
||||
|
||||
public GObjectClassStruct parent_class;
|
||||
|
||||
public Pointer new_icon;
|
||||
public Pointer new_attention_icon;
|
||||
public Pointer new_status;
|
||||
public Pointer new_icon_theme;
|
||||
public Pointer new_label;
|
||||
public Pointer connection_changed;
|
||||
public Pointer scroll_event;
|
||||
public Pointer app_indicator_reserved_ats;
|
||||
public Fallback fallback;
|
||||
public Pointer unfallback;
|
||||
public Pointer app_indicator_reserved_1;
|
||||
public Pointer app_indicator_reserved_2;
|
||||
public Pointer app_indicator_reserved_3;
|
||||
public Pointer app_indicator_reserved_4;
|
||||
public Pointer app_indicator_reserved_5;
|
||||
public Pointer app_indicator_reserved_6;
|
||||
|
||||
public AppIndicatorClassStruct() {}
|
||||
public AppIndicatorClassStruct(Pointer p) {
|
||||
super(p);
|
||||
useMemory(p);
|
||||
read();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("parent_class",
|
||||
"new_icon",
|
||||
"new_attention_icon",
|
||||
"new_status",
|
||||
"new_icon_theme",
|
||||
"new_label",
|
||||
"connection_changed",
|
||||
"scroll_event",
|
||||
"app_indicator_reserved_ats",
|
||||
"fallback",
|
||||
"unfallback",
|
||||
"app_indicator_reserved_1",
|
||||
"app_indicator_reserved_2",
|
||||
"app_indicator_reserved_3",
|
||||
"app_indicator_reserved_4",
|
||||
"app_indicator_reserved_5",
|
||||
"app_indicator_reserved_6");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public class AppIndicatorInstanceStruct extends Structure {
|
||||
public GObjectStruct parent;
|
||||
public Pointer priv;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("parent",
|
||||
"priv");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AppIndicatorInstanceStruct app_indicator_new(String id, String icon_name, int category);
|
||||
public AppIndicatorInstanceStruct app_indicator_new_with_path(String id, String icon_name, int category, String icon_theme_path);
|
||||
public void app_indicator_set_status(AppIndicatorInstanceStruct self, int status);
|
||||
public void app_indicator_set_attention_icon(AppIndicatorInstanceStruct self, String icon_name);
|
||||
public void app_indicator_set_attention_icon_full(AppIndicatorInstanceStruct self, String name, String icon_desc);
|
||||
public void app_indicator_set_menu(AppIndicatorInstanceStruct self, Pointer menu);
|
||||
public void app_indicator_set_icon(AppIndicatorInstanceStruct self, String icon_name);
|
||||
public void app_indicator_set_icon_full(AppIndicatorInstanceStruct self, String icon_name, String icon_desc);
|
||||
public void app_indicator_set_label(AppIndicatorInstanceStruct self, String label, String guide);
|
||||
public void app_indicator_set_icon_theme_path(AppIndicatorInstanceStruct self, String icon_theme_path);
|
||||
public void app_indicator_set_ordering_index(AppIndicatorInstanceStruct self, int ordering_index);
|
||||
public void app_indicator_set_secondary_active_target(AppIndicatorInstanceStruct self, Pointer menuitem);
|
||||
|
||||
public String app_indicator_get_id(AppIndicatorInstanceStruct self);
|
||||
public int app_indicator_get_category(AppIndicatorInstanceStruct self);
|
||||
public int app_indicator_get_status(AppIndicatorInstanceStruct self);
|
||||
|
||||
public String app_indicator_get_icon(AppIndicatorInstanceStruct self);
|
||||
public String app_indicator_get_icon_desc(AppIndicatorInstanceStruct self);
|
||||
public String app_indicator_get_icon_theme_path(AppIndicatorInstanceStruct self);
|
||||
public String app_indicator_get_attention_icon(AppIndicatorInstanceStruct self);
|
||||
|
||||
public Pointer app_indicator_get_menu(AppIndicatorInstanceStruct self);
|
||||
public String app_indicator_get_label(AppIndicatorInstanceStruct self);
|
||||
public String app_indicator_get_label_guide(AppIndicatorInstanceStruct self);
|
||||
public int app_indicator_get_ordering_index(AppIndicatorInstanceStruct self);
|
||||
public Pointer app_indicator_get_secondary_active_target(AppIndicatorInstanceStruct self);
|
||||
|
||||
public void app_indicator_build_menu_from_desktop(AppIndicatorInstanceStruct self, String desktop_file, String destkop_profile);
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package dorkbox.util.jna.linux;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import dorkbox.util.Keep;
|
||||
import dorkbox.util.jna.linux.Gtk.GdkEventButton;
|
||||
|
||||
public interface Gobject extends Library {
|
||||
public static final Gobject INSTANCE = (Gobject) Native.loadLibrary("gobject-2.0", Gobject.class);
|
||||
|
||||
@Keep
|
||||
public class GTypeClassStruct extends Structure {
|
||||
public class ByValue extends GTypeClassStruct implements Structure.ByValue {}
|
||||
public class ByReference extends GTypeClassStruct implements Structure.ByReference {}
|
||||
|
||||
public NativeLong g_type;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("g_type");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public class GTypeInstanceStruct extends Structure {
|
||||
public class ByValue extends GTypeInstanceStruct implements Structure.ByValue {}
|
||||
public class ByReference extends GTypeInstanceStruct implements Structure.ByReference {}
|
||||
|
||||
public Pointer g_class;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("g_class");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public class GObjectStruct extends Structure {
|
||||
public class ByValue extends GObjectStruct implements Structure.ByValue {}
|
||||
public class ByReference extends GObjectStruct implements Structure.ByReference {}
|
||||
|
||||
public GTypeInstanceStruct g_type_instance;
|
||||
public int ref_count;
|
||||
public Pointer qdata;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("g_type_instance",
|
||||
"ref_count",
|
||||
"qdata");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public class GObjectClassStruct extends Structure {
|
||||
public class ByValue extends GObjectClassStruct implements Structure.ByValue {}
|
||||
public class ByReference extends GObjectClassStruct implements Structure.ByReference {}
|
||||
|
||||
public GTypeClassStruct g_type_class;
|
||||
public Pointer construct_properties;
|
||||
public Pointer constructor;
|
||||
public Pointer set_property;
|
||||
public Pointer get_property;
|
||||
public Pointer dispose;
|
||||
public Pointer finalize;
|
||||
public Pointer dispatch_properties_changed;
|
||||
public Pointer notify;
|
||||
public Pointer constructed;
|
||||
public NativeLong flags;
|
||||
public Pointer dummy1;
|
||||
public Pointer dummy2;
|
||||
public Pointer dummy3;
|
||||
public Pointer dummy4;
|
||||
public Pointer dummy5;
|
||||
public Pointer dummy6;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("g_type_class",
|
||||
"construct_properties",
|
||||
"constructor",
|
||||
"set_property",
|
||||
"get_property",
|
||||
"dispose",
|
||||
"finalize",
|
||||
"dispatch_properties_changed",
|
||||
"notify",
|
||||
"constructed",
|
||||
"flags",
|
||||
"dummy1",
|
||||
"dummy2",
|
||||
"dummy3",
|
||||
"dummy4",
|
||||
"dummy5",
|
||||
"dummy6");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public interface GCallback extends Callback {
|
||||
public void callback(Pointer instance, Pointer data);
|
||||
}
|
||||
|
||||
@Keep
|
||||
public interface GEventCallback extends Callback {
|
||||
public void callback(Pointer instance, GdkEventButton event);
|
||||
}
|
||||
|
||||
|
||||
@Keep
|
||||
public class xyPointer extends Structure {
|
||||
public int value;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("value");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public interface GPositionCallback extends Callback {
|
||||
public void callback(Pointer menu, xyPointer x, xyPointer y, Pointer push_in_bool, Pointer user_data);
|
||||
}
|
||||
|
||||
|
||||
public void g_object_unref(Pointer object);
|
||||
public void g_signal_connect_data(Pointer instance, String detailed_signal, Callback c_handler,
|
||||
Pointer data, Pointer destroy_data, int connect_flags);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package dorkbox.util.jna.linux;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
public interface Gtk extends Library {
|
||||
public static final Gtk INSTANCE = (Gtk) Native.loadLibrary("gtk-x11-2.0", Gtk.class);
|
||||
|
||||
public static final int FALSE = 0;
|
||||
public static final int TRUE = 1;
|
||||
|
||||
|
||||
public static class GdkEventButton extends Structure {
|
||||
public int type;
|
||||
public Pointer window;
|
||||
public int send_event;
|
||||
public int time;
|
||||
public double x;
|
||||
public double y;
|
||||
public Pointer axes;
|
||||
public int state;
|
||||
public int button;
|
||||
public Pointer device;
|
||||
public double x_root;
|
||||
public double y_root;
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("type",
|
||||
"window",
|
||||
"send_event",
|
||||
"time",
|
||||
"x",
|
||||
"y",
|
||||
"axes",
|
||||
"state",
|
||||
"button",
|
||||
"device",
|
||||
"x_root",
|
||||
"y_root");
|
||||
}
|
||||
}
|
||||
|
||||
public void gtk_init(int argc, String[] argv);
|
||||
public void gtk_main();
|
||||
|
||||
public Pointer gtk_menu_new();
|
||||
public Pointer gtk_menu_item_new_with_label(String label);
|
||||
|
||||
public Pointer gtk_status_icon_new();
|
||||
public void gtk_status_icon_set_from_file(Pointer widget, String lablel);
|
||||
|
||||
public void gtk_status_icon_set_visible(Pointer widget, boolean visible);
|
||||
public void gtk_status_icon_set_tooltip(Pointer widget, String tooltipText);
|
||||
|
||||
public void gtk_menu_item_set_label(Pointer menu_item, String label);
|
||||
public void gtk_menu_shell_append(Pointer menu_shell, Pointer child);
|
||||
public void gtk_widget_set_sensitive(Pointer widget, int sesitive);
|
||||
|
||||
public void gtk_widget_show(Pointer widget);
|
||||
public void gtk_widget_show_all(Pointer widget);
|
||||
public void gtk_widget_destroy(Pointer widget);
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package dorkbox.util.jna.linux;
|
||||
|
||||
|
||||
|
||||
public class GtkSupport {
|
||||
public static final boolean isSupported;
|
||||
public static final boolean usesSwtMainLoop;
|
||||
|
||||
static {
|
||||
if (Gtk.INSTANCE != null && AppIndicator.INSTANCE != null && Gobject.INSTANCE != null) {
|
||||
isSupported = true;
|
||||
|
||||
boolean hasSwt = false;
|
||||
try {
|
||||
Class<?> swtClass = Class.forName("org.eclipse.swt.widgets.Display");
|
||||
if (swtClass != null) {
|
||||
hasSwt = true;
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
// swt already init's gtk.
|
||||
if (!hasSwt) {
|
||||
Gtk.INSTANCE.gtk_init(0, null);
|
||||
usesSwtMainLoop = false;
|
||||
} else {
|
||||
usesSwtMainLoop = true;
|
||||
}
|
||||
} else {
|
||||
isSupported = false;
|
||||
usesSwtMainLoop = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
// placeholder to init GTK
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue