java-gobject-introspection-examples r4 - in trunk: . src/org/verbum
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection-examples r4 - in trunk: . src/org/verbum
- Date: Sat, 6 Sep 2008 19:50:23 +0000 (UTC)
Author: walters
Date: Sat Sep 6 19:50:23 2008
New Revision: 4
URL: http://svn.gnome.org/viewvc/java-gobject-introspection-examples?rev=4&view=rev
Log:
Add GooCanvasTest - tweak other tests
Added:
trunk/src/org/verbum/GooCanvasTest.java
Modified:
trunk/.classpath
trunk/src/org/verbum/GStreamerTest.java
trunk/src/org/verbum/GtkTest.java
trunk/src/org/verbum/HippoCanvasTest.java
trunk/src/org/verbum/NotifyTest.java
trunk/src/org/verbum/WebKitTest.java
Modified: trunk/.classpath
==============================================================================
--- trunk/.classpath (original)
+++ trunk/.classpath Sat Sep 6 19:50:23 2008
@@ -2,13 +2,13 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="/usr/share/java/jna.jar" sourcepath="/src/fedora/jna/devel/jna-3.0.4-svn630/src"/>
+ <classpathentry kind="lib" path="/usr/share/java/jna.jar" sourcepath="/src/fedora/jna/devel/jna-3.0.4-svn630"/>
<classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm.jar"/>
<classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm-commons.jar"/>
<classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm-analysis.jar"/>
<classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm-tree.jar"/>
- <classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm-util.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/Gtk.jar"/>
+ <classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm-util.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/GdkPixbuf.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/Atk.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/WebKit.jar"/>
@@ -24,5 +24,6 @@
<classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterJson.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterGtk.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/cairo.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/share/girepository/GooCanvas.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/src/org/verbum/GStreamerTest.java
==============================================================================
--- trunk/src/org/verbum/GStreamerTest.java (original)
+++ trunk/src/org/verbum/GStreamerTest.java Sat Sep 6 19:50:23 2008
@@ -51,7 +51,6 @@
bus.addWatch(new BusFunc() {
@Override
public Boolean callback(Bus arg0, Message msg, Pointer arg2) {
- System.out.printf("Got Message type: %d%n", msg.type);
if (msg.type == MessageType.EOS) {
System.out.println("End of stream");
loop.quit();
@@ -59,6 +58,10 @@
System.err.println("error!");
loop.quit();
+ } else if (msg.type == MessageType.STATE_CHANGED) {
+
+ } else {
+ System.err.printf("Got Message type: %d%n", msg.type);
}
return true;
}
Added: trunk/src/org/verbum/GooCanvasTest.java
==============================================================================
--- (empty file)
+++ trunk/src/org/verbum/GooCanvasTest.java Sat Sep 6 19:50:23 2008
@@ -0,0 +1,88 @@
+package org.verbum;
+
+import java.util.HashMap;
+
+import org.gnome.gir.dynamic.Gdk.Event;
+import org.gnome.gir.dynamic.GooCanvas.Canvas;
+import org.gnome.gir.dynamic.GooCanvas.Item;
+import org.gnome.gir.dynamic.GooCanvas.Rect;
+import org.gnome.gir.dynamic.GooCanvas.Text;
+import org.gnome.gir.dynamic.Gtk.AnchorType;
+import org.gnome.gir.dynamic.Gtk.GtkGlobals;
+import org.gnome.gir.dynamic.Gtk.ScrolledWindow;
+import org.gnome.gir.dynamic.Gtk.ShadowType;
+import org.gnome.gir.dynamic.Gtk.Widget;
+import org.gnome.gir.dynamic.Gtk.Window;
+import org.gnome.gir.dynamic.Gtk.WindowType;
+
+public class GooCanvasTest {
+
+ @SuppressWarnings("serial")
+ public static void main(String[] args) {
+ GtkGlobals.initCheck(null, null);
+
+ /* Create the window and widgets. */
+ Window window = new Window(WindowType.TOPLEVEL);
+ window.setDefaultSize(640, 600);
+ window.show();
+ window.connect(new Widget.DeleteEvent() {
+ @Override
+ public Boolean onDeleteEvent(Widget arg0, Event arg1) {
+ GtkGlobals.mainQuit();
+ return true;
+ }
+ });
+
+ ScrolledWindow scrolledWin = new ScrolledWindow();
+ scrolledWin.setShadowType(ShadowType.IN);
+ scrolledWin.show();
+ window.add(scrolledWin);
+
+ Canvas canvas = new Canvas();
+ canvas.setSizeRequest(600, 450);
+ canvas.setBounds(0.0, 0.0, 1000.0, 1000.0);
+ canvas.show();
+ scrolledWin.add(canvas);
+ final Item root = canvas.getRootItem();
+
+ Rect rect = new Rect(new HashMap<String,Object>() {
+ {
+ put("parent", root);
+ put("x", 100.0);
+ put("y", 100.0);
+ put("width", 400.0);
+ put("height", 400.0);
+ put("line-width", 10.0);
+ put("radius-x", 20.0);
+ put("radius-y", 10.0);
+ put("stroke-color", "yellow");
+ put("fill-color", "red");
+ }
+ });
+
+ Text text = new Text(new HashMap<String,Object>() {
+ {
+ put("parent", root);
+ put("text", "Hello World");
+ put("x", 300.0);
+ put("y", 300.0);
+ put("width", -1.0);
+ put("anchor", AnchorType.CENTER);
+ put("font", "Sans 24");
+ }
+ });
+ text.rotate(45.0, 300.0, 300.0);
+
+ /* This handles button presses in item views. We simply output a message to
+ the console. */
+ rect.connect(new Item.ButtonPressEvent() {
+ @Override
+ public Boolean onButtonPressEvent(Item arg0, Item arg1, Event arg2) {
+ System.out.printf("rect item received button press event%n");
+ return true;
+ }
+ });
+
+ GtkGlobals.main();
+ }
+}
Modified: trunk/src/org/verbum/GtkTest.java
==============================================================================
--- trunk/src/org/verbum/GtkTest.java (original)
+++ trunk/src/org/verbum/GtkTest.java Sat Sep 6 19:50:23 2008
@@ -1,9 +1,12 @@
package org.verbum;
import org.gnome.gir.dynamic.Gdk.Event;
+import org.gnome.gir.dynamic.Gdk.EventAny;
import org.gnome.gir.dynamic.Gtk.GtkGlobals;
+import org.gnome.gir.dynamic.Gtk.Label;
import org.gnome.gir.dynamic.Gtk.TextBuffer;
import org.gnome.gir.dynamic.Gtk.TextView;
+import org.gnome.gir.dynamic.Gtk.VBox;
import org.gnome.gir.dynamic.Gtk.Widget;
import org.gnome.gir.dynamic.Gtk.Window;
import org.gnome.gir.dynamic.Gtk.WindowType;
@@ -14,25 +17,26 @@
public static void main(String[] args) throws GErrorException {
GtkGlobals.initCheck(null, null);
Window w = new Window(WindowType.TOPLEVEL);
+ VBox box = new VBox();
+ w.add(box);
+ Label l = new Label("hello world");
+ box.packStart(l, false, true, 0);
TextView tv = new TextView();
final TextBuffer buf = tv.getBuffer();
buf.insertAtCursor("hello world!", -1);
- w.add(tv);
+ box.add(tv);
w.setDefaultSize(640, 480);
w.connect(new Widget.DeleteEvent() {
@Override
- public Boolean onDeleteEvent(Widget w, Event arg0) {
+ public Boolean onDeleteEvent(Widget w, Event e) {
+ e.setType(EventAny.class);
+ e.read();
+ System.out.printf("Got event type: %s%n", e.any.type);
buf.insertAtCursor("DELETE ME?! NEVER!\n", -1);
buf.insertAtCursor("(ok, try using xkill)", -1);
return true;
}
});
- try {
- w.setIconFromFile("/usr/share/pixmaps/drscheme.png");
- } catch (GErrorException e) {
- System.err.println("Failed to set icon");
- e.printStackTrace();
- }
w.showAll();
GtkGlobals.main();
}
Modified: trunk/src/org/verbum/HippoCanvasTest.java
==============================================================================
--- trunk/src/org/verbum/HippoCanvasTest.java (original)
+++ trunk/src/org/verbum/HippoCanvasTest.java Sat Sep 6 19:50:23 2008
@@ -23,6 +23,7 @@
w.connect(new Widget.DeleteEvent() {
@Override
public Boolean onDeleteEvent(Widget w, Event arg0) {
+ System.err.println("Goodbye cruel world.");
GtkGlobals.mainQuit();
return true;
}
Modified: trunk/src/org/verbum/NotifyTest.java
==============================================================================
--- trunk/src/org/verbum/NotifyTest.java (original)
+++ trunk/src/org/verbum/NotifyTest.java Sat Sep 6 19:50:23 2008
@@ -4,6 +4,7 @@
import org.gnome.gir.dynamic.Notify.ActionCallback;
import org.gnome.gir.dynamic.Notify.Notification;
import org.gnome.gir.dynamic.Notify.NotifyGlobals;
+import org.gnome.gir.dynamic.Notify.Notification.Closed;
import org.gnome.gir.gobject.MainLoop;
import com.sun.jna.Pointer;
@@ -16,17 +17,25 @@
public static void main(String[] args) {
NotifyGlobals.init("MyApp");
- MainLoop loop = new MainLoop();
+ final MainLoop loop = new MainLoop();
Notification notify = new Notification("Test Notification", MESSAGE, "gtk-info", (Widget)null);
notify.addAction("foo", "FOO", new ActionCallback() {
@Override
public void callback(Notification arg0, String arg1, Pointer arg2) {
System.out.printf("User pressed %s%n", arg1);
+ loop.quit();
}
}, null, null);
+ notify.connect(new Closed() {
+ @Override
+ public void onClosed(Notification arg0) {
+ System.out.println("User didn't FOO =(");
+ loop.quit();
+ }
+ });
notify.show(null);
loop.run();
+ System.out.flush();
}
-
}
Modified: trunk/src/org/verbum/WebKitTest.java
==============================================================================
--- trunk/src/org/verbum/WebKitTest.java (original)
+++ trunk/src/org/verbum/WebKitTest.java Sat Sep 6 19:50:23 2008
@@ -13,10 +13,21 @@
GtkGlobals.initCheck(null, null);
Window w = new Window(WindowType.TOPLEVEL);
ScrolledWindow sw = new ScrolledWindow(null, null);
+ sw.setName("SCROLLED!");
w.add(sw);
WebView wv = new WebView();
sw.add(wv);
wv.open("http://www.gnome.org");
+ wv.connect(new WebView.HoveringOverLink() {
+
+ @Override
+ public void onHoveringOverLink(WebView arg0, String arg1,
+ String arg2) {
+ System.err.printf("hovering over %s %s%n", arg1, arg2);
+
+ }
+
+ });
w.setDefaultSize(640, 480);
w.showAll();
GtkGlobals.main();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]