java-gobject-introspection-examples r8 - in trunk: . src/org/verbum
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection-examples r8 - in trunk: . src/org/verbum
- Date: Tue, 16 Sep 2008 19:44:57 +0000 (UTC)
Author: walters
Date: Tue Sep 16 19:44:56 2008
New Revision: 8
URL: http://svn.gnome.org/viewvc/java-gobject-introspection-examples?rev=8&view=rev
Log:
Add some more examples, various tweaks
Added:
trunk/src/org/verbum/GtkSourceViewTest.java
trunk/src/org/verbum/HelloClutter.java
trunk/src/org/verbum/VteTest.java
Modified:
trunk/.classpath
trunk/src/org/verbum/GConfTest.java
trunk/src/org/verbum/GStreamerTest.java
trunk/src/org/verbum/GooCanvasTest.java
trunk/src/org/verbum/GtkTest.java
trunk/src/org/verbum/HippoCanvasTest.java
trunk/src/org/verbum/NotifyTest.java
trunk/src/org/verbum/SoupTest.java
Modified: trunk/.classpath
==============================================================================
--- trunk/.classpath (original)
+++ trunk/.classpath Tue Sep 16 19:44:56 2008
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry excluding="org/verbum/SoupTest.java" 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.orig/src"/>
<classpathentry kind="lib" path="/usr/share/java/objectweb-asm/asm.jar"/>
@@ -10,14 +10,15 @@
<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/Gio.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gdk.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/share/girepository/Atk.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/HippoCanvas.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gdk.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/share/girepository/Vte.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/java-gobject-introspection"/>
<classpathentry kind="lib" path="/src/build/gi/share/java/jgir.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gst.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/Notify.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gst.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterCairo.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/Clutter.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterJson.jar"/>
@@ -28,5 +29,6 @@
<classpathentry kind="lib" path="/src/build/gi/share/girepository/GConf.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/Soup.jar"/>
<classpathentry kind="lib" path="/src/build/gi/share/girepository/WebKit.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/share/girepository/GtkSource.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/src/org/verbum/GConfTest.java
==============================================================================
--- trunk/src/org/verbum/GConfTest.java (original)
+++ trunk/src/org/verbum/GConfTest.java Tue Sep 16 19:44:56 2008
@@ -19,7 +19,6 @@
public static void main(String...args) throws GErrorException {
GtkGlobals.init(null, null);
- GConfGlobals.init(null, null);
Window w = new Window(WindowType.TOPLEVEL);
w.setSizeRequest(320, 240);
@@ -35,7 +34,7 @@
client.notifyAdd("/desktop/gnome/background/draw_background",
new ClientNotifyFunc() {
@Override
- public void callback(Client arg0, Integer arg1, Entry arg2,
+ public void callback(Client arg0, int arg1, Entry arg2,
Pointer arg3) {
boolean bg;
try {
@@ -51,7 +50,7 @@
w.connect(new Widget.DeleteEvent() {
@Override
- public Boolean onDeleteEvent(Widget arg0, Event arg1) {
+ public boolean onDeleteEvent(Widget arg0, Event arg1) {
GtkGlobals.mainQuit();
return true;
}
Modified: trunk/src/org/verbum/GStreamerTest.java
==============================================================================
--- trunk/src/org/verbum/GStreamerTest.java (original)
+++ trunk/src/org/verbum/GStreamerTest.java Tue Sep 16 19:44:56 2008
@@ -50,7 +50,7 @@
bus = pipeline.getBus();
bus.addWatch(new BusFunc() {
@Override
- public Boolean callback(Bus arg0, Message msg, Pointer arg2) {
+ public boolean callback(Bus arg0, Message msg, Pointer arg2) {
if (msg.type == MessageType.EOS) {
System.out.println("End of stream");
loop.quit();
Modified: trunk/src/org/verbum/GooCanvasTest.java
==============================================================================
--- trunk/src/org/verbum/GooCanvasTest.java (original)
+++ trunk/src/org/verbum/GooCanvasTest.java Tue Sep 16 19:44:56 2008
@@ -27,7 +27,7 @@
window.show();
window.connect(new Widget.DeleteEvent() {
@Override
- public Boolean onDeleteEvent(Widget arg0, Event arg1) {
+ public boolean onDeleteEvent(Widget arg0, Event arg1) {
GtkGlobals.mainQuit();
return true;
}
@@ -77,7 +77,7 @@
the console. */
rect.connect(new Item.ButtonPressEvent() {
@Override
- public Boolean onButtonPressEvent(Item arg0, Item arg1, Event arg2) {
+ public boolean onButtonPressEvent(Item arg0, Item arg1, Event arg2) {
System.out.printf("rect item received button press event%n");
return true;
}
Added: trunk/src/org/verbum/GtkSourceViewTest.java
==============================================================================
--- (empty file)
+++ trunk/src/org/verbum/GtkSourceViewTest.java Tue Sep 16 19:44:56 2008
@@ -0,0 +1,46 @@
+package org.verbum;
+
+import org.gnome.gir.dynamic.Gdk.Event;
+import org.gnome.gir.dynamic.Gtk.GtkGlobals;
+import org.gnome.gir.dynamic.Gtk.ScrolledWindow;
+import org.gnome.gir.dynamic.Gtk.Widget;
+import org.gnome.gir.dynamic.Gtk.Window;
+import org.gnome.gir.dynamic.Gtk.WindowType;
+import org.gnome.gir.dynamic.GtkSource.Buffer;
+import org.gnome.gir.dynamic.GtkSource.GtkSourceGlobals;
+import org.gnome.gir.dynamic.GtkSource.Language;
+import org.gnome.gir.dynamic.GtkSource.LanguageManager;
+import org.gnome.gir.dynamic.GtkSource.View;
+
+public class GtkSourceViewTest {
+ public static void main(String[] args) {
+ /* GTK+ boilerplate */
+ GtkGlobals.initCheck(null, null);
+ Window w = new Window(WindowType.TOPLEVEL);
+ ScrolledWindow sw = new ScrolledWindow(null, null);
+ w.add(sw);
+
+ /* The GtkSourceView specific bits */
+ Buffer buffer = new Buffer();
+ LanguageManager mgr = GtkSourceGlobals.languageManagerGetDefault();
+ Language lang = mgr.getLanguage("python");
+ assert lang != null;
+ buffer.setLanguage(lang);
+ buffer.setHighlightSyntax(true);
+ View view = new View(buffer);
+ view.setShowLineNumbers(true);
+ sw.add(view);
+
+ /* GTK+ boilerplate */
+ w.connect(new Widget.DeleteEvent() {
+ @Override
+ public boolean onDeleteEvent(Widget arg0, Event arg1) {
+ GtkGlobals.mainQuit();
+ return true;
+ }
+ });
+ w.setDefaultSize(640, 480);
+ w.showAll();
+ GtkGlobals.main();
+ }
+}
Modified: trunk/src/org/verbum/GtkTest.java
==============================================================================
--- trunk/src/org/verbum/GtkTest.java (original)
+++ trunk/src/org/verbum/GtkTest.java Tue Sep 16 19:44:56 2008
@@ -2,6 +2,7 @@
import org.gnome.gir.dynamic.Gdk.Event;
import org.gnome.gir.dynamic.Gdk.EventAny;
+import org.gnome.gir.dynamic.Gtk.AboutDialog;
import org.gnome.gir.dynamic.Gtk.GtkGlobals;
import org.gnome.gir.dynamic.Gtk.Label;
import org.gnome.gir.dynamic.Gtk.TextBuffer;
@@ -21,7 +22,7 @@
VBox box = new VBox();
w.add(box);
Label l = new Label("hello world");
- box.packStart(l, false, true, 0);
+ box.packStartDefaults(l);
TextView tv = new TextView();
final TextBuffer buf = tv.getBuffer();
buf.insertAtCursor("hello world!", -1);
@@ -29,7 +30,7 @@
w.setDefaultSize(640, 480);
w.connect(new Widget.DeleteEvent() {
@Override
- public Boolean onDeleteEvent(Widget w, Event e) {
+ public boolean onDeleteEvent(Widget w, Event e) {
e.setType(EventAny.class);
e.read();
System.out.printf("Got event type: %s%n", e.any.type);
@@ -42,6 +43,8 @@
buf.getStartIter(iter);
iter.forwardChars(5);
buf.insert(iter, " TO THE WHOLE ", -1);
+ AboutDialog ad = new AboutDialog();
+ ad.getName();
w.showAll();
w.setIconFromFile("/usr/share/icons/abiword_48.png");
Added: trunk/src/org/verbum/HelloClutter.java
==============================================================================
--- (empty file)
+++ trunk/src/org/verbum/HelloClutter.java Tue Sep 16 19:44:56 2008
@@ -0,0 +1,72 @@
+package org.verbum;
+
+import org.gnome.gir.dynamic.Clutter.ClutterGlobals;
+import org.gnome.gir.dynamic.Clutter.Color;
+import org.gnome.gir.dynamic.Clutter.Rectangle;
+import org.gnome.gir.dynamic.Clutter.RotateAxis;
+import org.gnome.gir.dynamic.Clutter.Stage;
+import org.gnome.gir.dynamic.Clutter.Timeline;
+import org.gnome.gir.gobject.GObjectGlobals;
+
+public class HelloClutter {
+ public static Color color(int r, int g, int b, int a) {
+ return new Color((byte)r, (byte)g, (byte)b, (byte)a);
+ }
+
+ private static class TimelineDelegate implements Timeline.NewFrame {
+ Rectangle rect;
+ int rotationAngle = 0;
+ int colorChangeCount = 0;
+
+ public TimelineDelegate(Rectangle rect) {
+ this.rect = rect;
+ }
+
+ public void onNewFrame(Timeline timeline, int frameNumber) {
+ rotationAngle += 1;
+ if (rotationAngle > 360)
+ rotationAngle = 0;
+
+ rect.setRotation(RotateAxis.X_AXIS, (double)rotationAngle, 0, 0, 0);
+
+ colorChangeCount += 1;
+ if (colorChangeCount > 100)
+ colorChangeCount = 0;
+
+ if (colorChangeCount == 0) {
+ Color rectColor = color(0xff, 0xff, 0xff, 0x99);
+ rect.setColor(rectColor);
+ } else if (colorChangeCount == 50) {
+ Color rectColor = color(0x10, 0x40, 0x90, 0xff);
+ rect.setColor(rectColor);
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ GObjectGlobals.init();
+ ClutterGlobals.init(null, null);
+
+ Color stageColor = color(0, 0, 0, 0xff);
+ Color actorColor = color(0xff, 0xff, 0xff, 0x99);
+
+ Stage stage = (Stage)ClutterGlobals.stageGetDefault();
+ stage.setSize(200, 200);
+ stage.setColor(stageColor);
+
+ Rectangle rect = new Rectangle(actorColor);
+ rect.setSize(70, 70);
+ rect.setPosition(50, 100);
+ stage.addActor(rect);
+ rect.show();
+
+ Timeline timeline = new Timeline(10 /* frames */, 120 /* frames per second */);
+ timeline.connect(new TimelineDelegate(rect));
+ timeline.setLoop(true);
+ timeline.start();
+
+ stage.show();
+
+ ClutterGlobals.main();
+ }
+}
\ No newline at end of file
Modified: trunk/src/org/verbum/HippoCanvasTest.java
==============================================================================
--- trunk/src/org/verbum/HippoCanvasTest.java (original)
+++ trunk/src/org/verbum/HippoCanvasTest.java Tue Sep 16 19:44:56 2008
@@ -22,7 +22,7 @@
w.connect(new Widget.DeleteEvent() {
@Override
- public Boolean onDeleteEvent(Widget w, Event arg0) {
+ 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 Tue Sep 16 19:44:56 2008
@@ -5,6 +5,7 @@
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.GErrorException;
import org.gnome.gir.gobject.MainLoop;
import com.sun.jna.Pointer;
@@ -34,7 +35,12 @@
loop.quit();
}
});
- notify.show(null);
+ try {
+ notify.show();
+ } catch (GErrorException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
loop.run();
System.out.flush();
}
Modified: trunk/src/org/verbum/SoupTest.java
==============================================================================
--- trunk/src/org/verbum/SoupTest.java (original)
+++ trunk/src/org/verbum/SoupTest.java Tue Sep 16 19:44:56 2008
@@ -7,6 +7,7 @@
import java.io.IOException;
import java.util.HashMap;
+import org.gnome.gir.dynamic.Soup.Buffer;
import org.gnome.gir.dynamic.Soup.ClientContext;
import org.gnome.gir.dynamic.Soup.MemoryUse;
import org.gnome.gir.dynamic.Soup.Message;
@@ -60,12 +61,12 @@
byte[] buf = new byte[8192];
Memory cBuf = new Memory(8192);
int count;
- MessageBody body = (MessageBody) msg.get("response-body");
+ MessageBody body = msg.getResponseBody();
while (true) {
count = f.read(buf);
cBuf.write(0, buf, 0, count);
if (count > 0)
- body.append(MemoryUse.COPY, cBuf.getPointer(0), (long)count);
+ Buffer b
}
} else /* msg->method == SOUP_METHOD_HEAD */ {
String length;
Added: trunk/src/org/verbum/VteTest.java
==============================================================================
--- (empty file)
+++ trunk/src/org/verbum/VteTest.java Tue Sep 16 19:44:56 2008
@@ -0,0 +1,37 @@
+package org.verbum;
+
+import org.gnome.gir.dynamic.Gdk.Event;
+import org.gnome.gir.dynamic.Gtk.GtkGlobals;
+import org.gnome.gir.dynamic.Gtk.Widget;
+import org.gnome.gir.dynamic.Gtk.Window;
+import org.gnome.gir.dynamic.Gtk.WindowType;
+import org.gnome.gir.dynamic.Vte.Terminal;
+
+public class VteTest {
+ public static void main(String[] args) {
+ /* GTK+ boilerplate */
+ GtkGlobals.initCheck(null, null);
+ Window w = new Window(WindowType.TOPLEVEL);
+
+ /* The Vte specific bits */
+ Terminal term = new Terminal();
+ term.setEmulation("xterm");
+ term.setAllowBold(true);
+ term.setMouseAutohide(true);
+ w.add(term);
+
+ //term.forkCommand(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
+
+ /* GTK+ boilerplate */
+ w.connect(new Widget.DeleteEvent() {
+ @Override
+ public boolean onDeleteEvent(Widget arg0, Event arg1) {
+ GtkGlobals.mainQuit();
+ return true;
+ }
+ });
+ w.setDefaultSize(640, 480);
+ w.showAll();
+ GtkGlobals.main();
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]