-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from bailuk/stage
Release (0.5.0)
- Loading branch information
Showing
30 changed files
with
272 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,9 @@ nb-configuration.xml | |
## OS X | ||
.DS_Store | ||
|
||
## nix-shell | ||
/shell.nix | ||
|
||
# Development | ||
todo/ | ||
/ci/qemu/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Development environment with nix-shell | ||
{ pkgs ? import <nixpkgs> {} | ||
}: | ||
pkgs.mkShell { | ||
name="java-gtk"; | ||
buildInputs = [ | ||
pkgs.git | ||
pkgs.jdk21_headless # Non headless is linked against gtk3 and does therefore not work | ||
pkgs.gtk4 | ||
]; | ||
shellHook = '' | ||
LD_LIBRARY_PATH=${pkgs.gtk4.outPath}/lib | ||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.glib.out.outPath}/lib | ||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.gdk-pixbuf.outPath}/lib | ||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.cairo.outPath}/lib | ||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.pango.out.outPath}/lib | ||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.libadwaita.outPath}/lib | ||
export LD_LIBRARY_PATH | ||
echo "./gradlew generate && ./gradlew build && ./gradlew run" | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package examples.dnd; | ||
|
||
import ch.bailu.gtk.gdk.GdkConstants; | ||
import ch.bailu.gtk.gio.ApplicationFlags; | ||
import ch.bailu.gtk.gio.File; | ||
import ch.bailu.gtk.gtk.Application; | ||
import ch.bailu.gtk.gtk.ApplicationWindow; | ||
import ch.bailu.gtk.gtk.DropTarget; | ||
import ch.bailu.gtk.gtk.Label; | ||
import ch.bailu.gtk.type.Str; | ||
import ch.bailu.gtk.type.Strs; | ||
|
||
/** | ||
* https://docs.gtk.org/gtk4/drag-and-drop.html | ||
*/ | ||
public class DragAndDrop { | ||
public final static Str ID = new Str("org.gtk.example.dnd"); | ||
|
||
public static void main(String[] args) { | ||
|
||
var app = new Application(ID, ApplicationFlags.FLAGS_NONE); | ||
app.onActivate(() -> { | ||
// Get and initialize application window | ||
var window = new ApplicationWindow(app); | ||
window.setTitle("Drag and drop demo"); | ||
window.setDefaultSize(400,300); | ||
|
||
// Create a label to display dropped files | ||
var label = new Label("Drop files here"); | ||
label.setHexpand(true); | ||
label.setVexpand(true); | ||
|
||
// Crate drop target | ||
var target = new DropTarget(File.getTypeID(), GdkConstants.ACTION_ALL); | ||
target.onDrop((value, x, y) -> { | ||
System.out.println("dropped"); | ||
var file = new File(value.getObject().cast()); | ||
label.setText(file.getBasename()); | ||
return true; | ||
}); | ||
|
||
// Make the label a drop target | ||
label.addController(target); | ||
|
||
// Compose and display | ||
window.setChild(label); | ||
window.show(); | ||
}); | ||
|
||
|
||
System.exit(app.run(args.length, new Strs(args))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
java-gtk/src/main/java/ch/bailu/gtk/lib/bridge/GResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ch.bailu.gtk.lib.bridge; | ||
|
||
import java.io.IOException; | ||
|
||
import ch.bailu.gtk.gio.Resource; | ||
import ch.bailu.gtk.lib.util.JavaResource; | ||
import ch.bailu.gtk.type.Bytes; | ||
import ch.bailu.gtk.type.exception.AllocationError; | ||
|
||
public class GResource { | ||
|
||
/** | ||
* Load a gresource bundle from java resources path and register it | ||
* See {@link ch.bailu.gtk.gio.Resource} for documentation on how to generate | ||
* gresource bundles. | ||
* | ||
* @param path absolute path to gresource: "/gresource/app.gresource" | ||
*/ | ||
public static void loadAndRegister(String path) { | ||
try (var stream = (new JavaResource(path).asStream())) { | ||
var bytes = new Bytes(stream.readAllBytes()); | ||
var resource = Resource.newFromDataResource(ch.bailu.gtk.glib.Bytes.newStaticBytes(bytes, bytes.getLength())); | ||
resource.register(); | ||
} catch (IOException | AllocationError e) { | ||
System.err.println("Load gresource failed for '" + path + "'"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.