java-gobject-introspection-examples r11 - in trunk: . src/org/verbum
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection-examples r11 - in trunk: . src/org/verbum
- Date: Fri, 28 Nov 2008 02:36:24 +0000 (UTC)
Author: walters
Date: Fri Nov 28 02:36:23 2008
New Revision: 11
URL: http://svn.gnome.org/viewvc/java-gobject-introspection-examples?rev=11&view=rev
Log:
Adjust for JGIR API changes
Added:
trunk/src/org/verbum/RecentTest.java
Modified:
trunk/.classpath
trunk/src/org/verbum/GConfTest.java
trunk/src/org/verbum/GStreamerTest.java
trunk/src/org/verbum/GtkSourceViewTest.java
trunk/src/org/verbum/GtkTest.java
trunk/src/org/verbum/GvfsMonitorTest.java
trunk/src/org/verbum/HelloClutter.java
trunk/src/org/verbum/NotifyTest.java
Modified: trunk/.classpath
==============================================================================
--- trunk/.classpath (original)
+++ trunk/.classpath Fri Nov 28 02:36:23 2008
@@ -8,26 +8,29 @@
<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 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/GdkPixbuf-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gtk-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Atk-1.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gio-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gdk-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Notify-0.4.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Vte-1.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Gst-0.10.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterCairo-0.8.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Clutter-0.8.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterJson-0.8.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/ClutterGtk-0.8.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/cairo-1.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/GooCanvas-0.10.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/GnomeKeyring-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/GConf-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/Soup-2.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/WebKit-1.0.jar"/>
- <classpathentry kind="lib" path="/src/build/gi/share/girepository/GtkSource-2.2.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/GdkPixbuf-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Gtk-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Atk-1.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Gio-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Gdk-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Notify-0.4.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Vte-1.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Gst-0.10.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/ClutterCairo-0.8.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/ClutterJson-0.8.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/GtkClutter-0.8.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/cairo-1.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/GooCanvas-0.10.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/GnomeKeyring-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/GConf-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Soup-2.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/WebKit-1.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/GtkSource-2.2.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Clutter-0.8.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Pango-1.0.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/Avahi-0.6.jar"/>
+ <classpathentry kind="lib" path="/src/build/gi/lib64/girepository/AvahiCore-0.6.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jgir"/>
<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 Fri Nov 28 02:36:23 2008
@@ -13,8 +13,6 @@
import org.gnome.gir.dynamic.Gtk.WindowType;
import org.gnome.gir.gobject.GErrorException;
-import com.sun.jna.Pointer;
-
public class GConfTest {
public static void main(String...args) throws GErrorException {
@@ -23,7 +21,7 @@
Window w = new Window(WindowType.TOPLEVEL);
w.setSizeRequest(320, 240);
- final Client client = GConfGlobals.clientGetDefault();
+ final Client client = Client.getDefault();
boolean bg = client.getBool("/desktop/gnome/background/draw_background");
@@ -34,8 +32,7 @@
client.notifyAdd("/desktop/gnome/background/draw_background",
new ClientNotifyFunc() {
@Override
- public void callback(Client arg0, int arg1, Entry arg2,
- Pointer arg3) {
+ public void callback(Client arg0, int arg1, Entry arg2) {
boolean bg;
try {
bg = client.getBool("/desktop/gnome/background/draw_background");
@@ -46,7 +43,7 @@
label.setText("drawing background:" + bg);
}
- }, null, null);
+ });
w.connect(new Widget.DeleteEvent() {
@Override
Modified: trunk/src/org/verbum/GStreamerTest.java
==============================================================================
--- trunk/src/org/verbum/GStreamerTest.java (original)
+++ trunk/src/org/verbum/GStreamerTest.java Fri Nov 28 02:36:23 2008
@@ -3,6 +3,7 @@
import org.gnome.gir.dynamic.Gst.Bus;
import org.gnome.gir.dynamic.Gst.BusFunc;
import org.gnome.gir.dynamic.Gst.Element;
+import org.gnome.gir.dynamic.Gst.ElementFactory;
import org.gnome.gir.dynamic.Gst.GstGlobals;
import org.gnome.gir.dynamic.Gst.Message;
import org.gnome.gir.dynamic.Gst.MessageType;
@@ -12,8 +13,6 @@
import org.gnome.gir.dynamic.Gst.Element.PadAdded;
import org.gnome.gir.gobject.MainLoop;
-import com.sun.jna.Pointer;
-
public class GStreamerTest {
public static void main(String...args) {
@@ -27,11 +26,11 @@
final Bus bus;
pipeline = new Pipeline("audio-player");
- source = GstGlobals.elementFactoryMake("filesrc", "file-source");
- demuxer = GstGlobals.elementFactoryMake("oggdemux", "ogg-demuxer");
- decoder = GstGlobals.elementFactoryMake("vorbisdec", "vorbis-decoder");
- conv = GstGlobals.elementFactoryMake("audioconvert", "converter");
- sink = GstGlobals.elementFactoryMake("autoaudiosink", "audio-output");
+ source = ElementFactory.make("filesrc", "file-source");
+ demuxer = ElementFactory.make("oggdemux", "ogg-demuxer");
+ decoder = ElementFactory.make("vorbisdec", "vorbis-decoder");
+ conv = ElementFactory.make("audioconvert", "converter");
+ sink = ElementFactory.make("autoaudiosink", "audio-output");
if (pipeline == null || source == null ||
demuxer == null || decoder == null ||
@@ -50,7 +49,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) {
if (msg.type == MessageType.EOS) {
System.out.println("End of stream");
loop.quit();
@@ -65,7 +64,7 @@
}
return true;
}
- }, null);
+ });
/* we add all elements into the pipeline */
/* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */
Modified: trunk/src/org/verbum/GtkSourceViewTest.java
==============================================================================
--- trunk/src/org/verbum/GtkSourceViewTest.java (original)
+++ trunk/src/org/verbum/GtkSourceViewTest.java Fri Nov 28 02:36:23 2008
@@ -22,12 +22,12 @@
/* The GtkSourceView specific bits */
SourceBuffer buffer = new SourceBuffer();
- SourceLanguageManager mgr = GtkSourceGlobals.languageManagerGetDefault();
+ SourceLanguageManager mgr = SourceLanguageManager.getDefault();
SourceLanguage lang = mgr.getLanguage("python");
assert lang != null;
buffer.setLanguage(lang);
buffer.setHighlightSyntax(true);
- SourceView view = new SourceView(buffer);
+ SourceView view = SourceView.newWithBuffer(buffer);
view.setShowLineNumbers(true);
sw.add(view);
Modified: trunk/src/org/verbum/GtkTest.java
==============================================================================
--- trunk/src/org/verbum/GtkTest.java (original)
+++ trunk/src/org/verbum/GtkTest.java Fri Nov 28 02:36:23 2008
@@ -1,7 +1,12 @@
package org.verbum;
+import java.util.concurrent.TimeUnit;
+
import org.gnome.gir.dynamic.Gdk.Event;
import org.gnome.gir.dynamic.Gdk.EventAny;
+import org.gnome.gir.dynamic.GdkPixbuf.GdkPixbufGlobals;
+import org.gnome.gir.dynamic.GdkPixbuf.Pixbuf;
+import org.gnome.gir.dynamic.GdkPixbuf.PixbufLoader;
import org.gnome.gir.dynamic.Gtk.GtkGlobals;
import org.gnome.gir.dynamic.Gtk.Label;
import org.gnome.gir.dynamic.Gtk.TextBuffer;
@@ -13,12 +18,13 @@
import org.gnome.gir.dynamic.Gtk.WindowType;
import org.gnome.gir.gobject.GErrorException;
import org.gnome.gir.gobject.GObject;
+import org.gnome.gir.gobject.MainLoop;
public class GtkTest {
public static void main(String[] args) throws GErrorException {
GtkGlobals.initCheck(null, null);
- Window w = new Window(WindowType.TOPLEVEL);
+ final Window w = new Window(WindowType.TOPLEVEL);
VBox box = new VBox();
w.add(box);
Label l = new Label("hello world");
@@ -47,6 +53,16 @@
w.showAll();
w.setIconFromFile("/usr/share/icons/abiword_48.png");
+
+ MainLoop.getDefault().invokeLater(3, TimeUnit.SECONDS, new Runnable() {
+ public void run() {
+ try {
+ w.setIconFromFile("/nonexistent");
+ } catch (GErrorException e) {
+ e.printStackTrace();
+ }
+ }
+ });
GtkGlobals.main();
}
Modified: trunk/src/org/verbum/GvfsMonitorTest.java
==============================================================================
--- trunk/src/org/verbum/GvfsMonitorTest.java (original)
+++ trunk/src/org/verbum/GvfsMonitorTest.java Fri Nov 28 02:36:23 2008
@@ -1,19 +1,27 @@
package org.verbum;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
import org.gnome.gir.dynamic.Gio.File;
+import org.gnome.gir.dynamic.Gio.FileIcon;
import org.gnome.gir.dynamic.Gio.FileMonitor;
import org.gnome.gir.dynamic.Gio.FileMonitorEvent;
import org.gnome.gir.dynamic.Gio.FileMonitorFlags;
import org.gnome.gir.dynamic.Gio.GioGlobals;
+import org.gnome.gir.dynamic.Gio.LoadableIcon;
+import org.gnome.gir.gobject.GErrorException;
import org.gnome.gir.gobject.GObjectGlobals;
import org.gnome.gir.gobject.MainLoop;
public class GvfsMonitorTest {
- public static void main(String...args) {
+ public static void main(final String...args) throws IOException, GErrorException {
GObjectGlobals.init();
- File f = GioGlobals.fileNewForCommandlineArg(args[0]);
+ java.io.File tmp = java.io.File.createTempFile("gvfstest", "test");
+
+ File f = GioGlobals.fileNewForPath(tmp.toString());
FileMonitor fm = f.monitorFile((int) FileMonitorFlags.WATCH_MOUNTS, null);
System.err.printf("Returned File stub: %s%n", f);
@@ -49,6 +57,23 @@
}
}
});
+
+ FileIcon icon = new FileIcon(GioGlobals.fileNewForPath("doesnotexist"));
+ icon.load(24, null, null);
+
+ /*
+ MainLoop.getDefault().invokeLater(5, TimeUnit.SECONDS, new Runnable() {
+ @Override
+ public void run() {
+ java.io.File tmp = new java.io.File(args[0], "tmp");
+ try {
+ tmp.createNewFile();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ tmp.delete();
+ }
+ }); */
new MainLoop().run();
}
Modified: trunk/src/org/verbum/HelloClutter.java
==============================================================================
--- trunk/src/org/verbum/HelloClutter.java (original)
+++ trunk/src/org/verbum/HelloClutter.java Fri Nov 28 02:36:23 2008
@@ -2,6 +2,7 @@
import org.gnome.gir.dynamic.Clutter.ClutterGlobals;
import org.gnome.gir.dynamic.Clutter.Color;
+import org.gnome.gir.dynamic.Clutter.Entry;
import org.gnome.gir.dynamic.Clutter.Rectangle;
import org.gnome.gir.dynamic.Clutter.RotateAxis;
import org.gnome.gir.dynamic.Clutter.Stage;
@@ -23,6 +24,8 @@
}
public void onNewFrame(Timeline timeline, int frameNumber) {
+ System.err.printf("frame: %s angle: %s colorCount: %s%n", frameNumber,
+ rotationAngle, colorChangeCount);
rotationAngle += 1;
if (rotationAngle > 360)
rotationAngle = 0;
@@ -30,6 +33,7 @@
rect.setRotation(RotateAxis.X_AXIS, (double)rotationAngle, 0, 0, 0);
colorChangeCount += 1;
+
if (colorChangeCount > 100)
colorChangeCount = 0;
@@ -50,22 +54,33 @@
Color stageColor = color(0, 0, 0, 0xff);
Color actorColor = color(0xff, 0xff, 0xff, 0x99);
- Stage stage = (Stage)ClutterGlobals.stageGetDefault();
+ Stage stage = (Stage)Stage.getDefault();
stage.setSize(200, 200);
stage.setColor(stageColor);
- Rectangle rect = new Rectangle(actorColor);
- rect.setSize(70, 70);
- rect.setPosition(50, 100);
+ System.out.printf("F5: %s", ClutterGlobals.Constants.F5);
+
+ Rectangle rect = Rectangle.newWithColor(actorColor);
+ rect.setSize(50, 50);
+ rect.setPosition(100, 100);
stage.addActor(rect);
- rect.show();
- Timeline timeline = new Timeline(10 /* frames */, 120 /* frames per second */);
+ Timeline timeline = new Timeline(60 /* frames */, 30 /* frames per second */);
timeline.connect(new TimelineDelegate(rect));
timeline.setLoop(true);
timeline.start();
-
- stage.show();
+ /*
+ Entry e = new Entry();
+ e.setReactive(true);
+ e.setColor(actorColor);
+ e.setText("testing");
+ e.setSize(50, 200);
+ e.setPosition(0, 0);
+ stage.addActor(e);
+
+ stage.setKeyFocus(e);
+ */
+ stage.showAll();
ClutterGlobals.main();
}
Modified: trunk/src/org/verbum/NotifyTest.java
==============================================================================
--- trunk/src/org/verbum/NotifyTest.java (original)
+++ trunk/src/org/verbum/NotifyTest.java Fri Nov 28 02:36:23 2008
@@ -25,12 +25,13 @@
@Override
public void callback(Notification arg0, String arg1, Pointer arg2) {
System.out.printf("User pressed %s%n", arg1);
- loop.quit();
- }
- }, null, null);
+ throw new RuntimeException("oops");
+ //loop.quit();
+ }
+ });
notify.connect(new Closed() {
@Override
- public void onClosed(Notification arg0) {
+ public void onClosed(Notification arg0, int x) {
System.out.println("User didn't FOO =(");
loop.quit();
}
Added: trunk/src/org/verbum/RecentTest.java
==============================================================================
--- (empty file)
+++ trunk/src/org/verbum/RecentTest.java Fri Nov 28 02:36:23 2008
@@ -0,0 +1,25 @@
+package org.verbum;
+
+import java.util.List;
+
+import org.gnome.gir.dynamic.Gtk.GtkGlobals;
+import org.gnome.gir.dynamic.Gtk.RecentInfo;
+import org.gnome.gir.dynamic.Gtk.RecentManager;
+import org.gnome.gir.gobject.GErrorException;
+
+import com.sun.jna.Pointer;
+
+public class RecentTest {
+
+ public static void main(String[] args) throws GErrorException {
+ GtkGlobals.initCheck(null, null);
+
+ RecentManager mgr = RecentManager.getDefault();
+ List<Pointer> recent = mgr.getItems().copy();
+ Pointer first = recent.get(0);
+ RecentInfo info = new RecentInfo();
+ info.setPointer(first);
+ System.out.printf("uri=%s added=%s%n", info.getUri(), info.getAdded());
+
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]