bindings/vala: Fix deprecated syntax
* s/weak/unowned in gegl-0.0.vapi, babl-0.0.vapi
2 files changed, 41 insertions(+), 41 deletions(-)
bindings/vala/gegl-0.0.vapi: Add Path, Buffer.linear_open,
Buffer.linear_close
1 files changed, 38 insertions(+), 0 deletions(-)
I also join a vala version of the gegl-paint example.
gegl-paint: gegl-paint-source
gcc -o gegl-paint gegl-paint.c gegl-view.c `pkg-config --libs --cflags
gegl` `pkg-config --libs --cflags gtk+-2.0`
gegl-paint-source: gegl-paint.vala gegl-view.vala
valac -C gegl-paint.vala gegl-view.vala --pkg=gtk+-2.0 --vapidir=../vapi
--pkg=gegl-0.1 --pkg=babl-0.1 --thread
Regards.
Damien
From d8a9ea7c9bce0cf602e2a9a9794941d3ae1e5e45 Mon Sep 17 00:00:00 2001
From: Damien de Lemeny <[email protected]>
Date: Fri, 21 May 2010 10:48:03 +0200
Subject: [PATCH 1/2] bindings/vala: Fix deprecated syntax
* s/weak/unowned in gegl-0.0.vapi, babl-0.0.vapi
---
bindings/vala/babl-0.0.vapi | 2 +-
bindings/vala/gegl-0.0.vapi | 80 +++++++++++++++++++++---------------------
2 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/bindings/vala/babl-0.0.vapi b/bindings/vala/babl-0.0.vapi
index cc531ac..b76c39d 100644
--- a/bindings/vala/babl-0.0.vapi
+++ b/bindings/vala/babl-0.0.vapi
@@ -15,5 +15,5 @@ namespace Babl {
[CCode (cheader_filename = "babl/babl.h")]
public static void destroy ();
[CCode (cheader_filename = "babl/babl.h")]
- public static weak Babl.Format format (string name);
+ public static unowned Babl.Format format (string name);
}
diff --git a/bindings/vala/gegl-0.0.vapi b/bindings/vala/gegl-0.0.vapi
index 8aa7510..8693a21 100644
--- a/bindings/vala/gegl-0.0.vapi
+++ b/bindings/vala/gegl-0.0.vapi
@@ -26,48 +26,48 @@ namespace Gegl {
public void set_rectangle (Gegl.Rectangle rectangle);
public bool work (out double progress);
[NoAccessorMethod]
- public weak int chunksize { get; construct; }
+ public unowned int chunksize { get; construct; }
[NoAccessorMethod]
- public weak Gegl.Node node { set construct; }
+ public unowned Gegl.Node node { set construct; }
[NoAccessorMethod]
- public weak double progress { get; set; }
+ public unowned double progress { get; set; }
}
[CCode (cheader_filename = "gegl.h")]
public class Node : GLib.Object, Gegl.Visitable {
public Node ();
public Node.from_file (string path);
public Node.from_xml (string xmldata, string path_root);
- public weak Gegl.Node new_child (...);
- public weak Gegl.Node create_child (string operation);
- public weak Gegl.Node adopt_child (Gegl.Node child);
- public weak Gegl.Node add_child (Gegl.Node child);
- public weak Gegl.Node remove_child (Gegl.Node child);
+ public unowned Gegl.Node new_child (...);
+ public unowned Gegl.Node create_child (string operation);
+ public unowned Gegl.Node adopt_child (Gegl.Node child);
+ public unowned Gegl.Node add_child (Gegl.Node child);
+ public unowned Gegl.Node remove_child (Gegl.Node child);
public bool connect_from (string input_pad_name, Gegl.Node source, string output_pad_name);
public bool connect_to (string output_pad_name, Gegl.Node sink, string input_pad_name);
public void link (Gegl.Node sink);
public void link_many (...);
public bool disconnect (string input_pad);
- public weak GLib.SList<Gegl.Node> get_children ();
- public int get_consumers (string output_pad, out weak Gegl.Node nodes, string pads);
- public weak string get_operation ();
- public weak Gegl.Node get_input_proxy (string pad_name);
- public weak Gegl.Node get_output_proxy (string pad_name);
- public weak Gegl.Node get_parent ();
- public weak Gegl.Node get_producer (string input_pad_name, string output_pad_name);
- public weak Gegl.Node detect (int x, int y);
+ public unowned GLib.SList<Gegl.Node> get_children ();
+ public int get_consumers (string output_pad, out unowned Gegl.Node nodes, string pads);
+ public unowned string get_operation ();
+ public unowned Gegl.Node get_input_proxy (string pad_name);
+ public unowned Gegl.Node get_output_proxy (string pad_name);
+ public unowned Gegl.Node get_parent ();
+ public unowned Gegl.Node get_producer (string input_pad_name, string output_pad_name);
+ public unowned Gegl.Node detect (int x, int y);
public Gegl.Rectangle get_bounding_box ();
public void blit (double scale, Gegl.Rectangle roi, void* format, void* destination_buf, int rowstride, Gegl.BlitFlags flags);
public void process ();
- public weak GLib.ParamSpec find_property (string property_name);
+ public unowned GLib.ParamSpec find_property (string property_name);
public void get (...);
public void set (...);
public void get_property (string property_name, GLib.Value value);
public void set_property (string property_name, GLib.Value value);
- public weak string to_xml (string path_root);
+ public unowned string to_xml (string path_root);
[NoAccessorMethod]
- public weak string name { get; set construct; }
+ public unowned string name { get; set construct; }
[NoAccessorMethod]
- public weak string operation { get; set construct; }
+ public unowned string operation { get; set construct; }
public signal void computed (Gegl.Rectangle p0);
public signal void invalidated (Gegl.Rectangle p0);
}
@@ -81,46 +81,46 @@ namespace Gegl {
public void get (double scale, Gegl.Rectangle rect, void* format, void* dest, int rowstride);
public Gegl.Rectangle get_extent ();
public static Gegl.Interpolation interpolation_from_string (string str);
- public static weak Gegl.Buffer load (string path);
+ public static unowned Gegl.Buffer load (string path);
public Buffer (Gegl.Rectangle? extent, void* format);
- public static weak Gegl.Buffer open (string path);
+ public static unowned Gegl.Buffer open (string path);
public void sample (double x, double y, double scale, void* dest, void* format, Gegl.Interpolation interpolation);
public void sample_cleanup ();
public void save (string path, Gegl.Rectangle roi);
public void set (Gegl.Rectangle rect, void* format, void* src, int rowstride);
public bool set_extent (Gegl.Rectangle extent);
[NoAccessorMethod]
- public weak int abyss_height { get; construct; }
+ public unowned int abyss_height { get; construct; }
[NoAccessorMethod]
- public weak int abyss_width { get; construct; }
+ public unowned int abyss_width { get; construct; }
[NoAccessorMethod]
- public weak int abyss_x { get; construct; }
+ public unowned int abyss_x { get; construct; }
[NoAccessorMethod]
- public weak int abyss_y { get; construct; }
+ public unowned int abyss_y { get; construct; }
[NoAccessorMethod]
- public weak void* format { get; set construct; }
+ public unowned void* format { get; set construct; }
[NoAccessorMethod]
- public weak int height { get; set construct; }
+ public unowned int height { get; set construct; }
[NoAccessorMethod]
- public weak string path { get; set construct; }
+ public unowned string path { get; set construct; }
[NoAccessorMethod]
- public weak int pixels { get; }
+ public unowned int pixels { get; }
[NoAccessorMethod]
- public weak int px_size { get; }
+ public unowned int px_size { get; }
[NoAccessorMethod]
- public weak int shift_x { get; construct; }
+ public unowned int shift_x { get; construct; }
[NoAccessorMethod]
- public weak int shift_y { get; construct; }
+ public unowned int shift_y { get; construct; }
[NoAccessorMethod]
- public weak int tile_height { get; construct; }
+ public unowned int tile_height { get; construct; }
[NoAccessorMethod]
- public weak int tile_width { get; construct; }
+ public unowned int tile_width { get; construct; }
[NoAccessorMethod]
- public weak int width { get; set construct; }
+ public unowned int width { get; set construct; }
[NoAccessorMethod]
- public weak int x { get; set construct; }
+ public unowned int x { get; set construct; }
[NoAccessorMethod]
- public weak int y { get; set construct; }
+ public unowned int y { get; set construct; }
public signal void changed (Gegl.Rectangle p0);
}
[CCode (cheader_filename = "gegl.h")]
@@ -150,11 +150,11 @@ namespace Gegl {
public const int MICRO_VERSION;
public const int MINOR_VERSION;
[CCode (cheader_filename = "gegl.h")]
- public static weak GLib.Object config ();
+ public static unowned GLib.Object config ();
[CCode (cheader_filename = "gegl.h")]
public static void exit ();
[CCode (cheader_filename = "gegl.h")]
public static void get_version (int major, int minor, int micro);
[CCode (cheader_filename = "gegl.h")]
- public static void init ([CCode (array_length_pos = 0.9)] ref weak string[] argv);
+ public static void init ([CCode (array_length_pos = 0.9)] ref unowned string[] argv);
}
--
1.6.3.3
From 4d18d9fdd1bb2e32091679f4f75f3adc7ec0665b Mon Sep 17 00:00:00 2001
From: Damien de Lemeny <[email protected]>
Date: Fri, 21 May 2010 10:51:55 +0200
Subject: [PATCH 2/2] bindings/vala/gegl-0.0.vapi: Add Path, Buffer.linear_open, Buffer.linear_close
---
bindings/vala/gegl-0.0.vapi | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/bindings/vala/gegl-0.0.vapi b/bindings/vala/gegl-0.0.vapi
index 8693a21..52ba130 100644
--- a/bindings/vala/gegl-0.0.vapi
+++ b/bindings/vala/gegl-0.0.vapi
@@ -72,6 +72,42 @@ namespace Gegl {
public signal void invalidated (Gegl.Rectangle p0);
}
[CCode (cheader_filename = "gegl.h")]
+ public struct Point {
+ public float x;
+ public float y;
+ }
+ [CCode (cheader_filename = "gegl.h")]
+ public struct PathItem {
+ public char type;
+ public Point point[4];
+ }
+ [CCode (cheader_filename = "gegl.h")]
+ public class Path : GLib.Object {
+ public Path ();
+ public Path.from_string (string instructions);
+ public bool is_empty ();
+ public int get_n_nodes ();
+ public double get_length ();
+ public bool get_node (int index, out unowned Gegl.PathItem node);
+ public unowned string to_string ();
+ public double closest_point (double x, double y,
+ double on_path_x, double on_path_y,
+ int node_pos_before);
+ public void calc (double pos, double x, double y);
+ public void calc_values (double num_samples, double xs, double ys);
+ public void get_bounds (out double min_x, out double max_x,
+ out double min_y, out double max_y);
+ public void clear ();
+ public void insert_node (int pos, Gegl.PathItem node);
+ public void replace_node (int pos, Gegl.PathItem node);
+ public void remove_node (int pos);
+ public void parse_string (string instructions);
+ public void append (...);
+ public void freeze ();
+ public void thaw ();
+ public void add_type (int items, string description);
+ }
+ [CCode (cheader_filename = "gegl.h")]
public class Buffer : GLib.Object {
public void copy (Gegl.Rectangle src_rect, Gegl.Buffer dst, Gegl.Rectangle dst_rect);
public Gegl.Buffer create_sub_buffer (Gegl.Rectangle extent);
@@ -88,6 +124,8 @@ namespace Gegl {
public void sample_cleanup ();
public void save (string path, Gegl.Rectangle roi);
public void set (Gegl.Rectangle rect, void* format, void* src, int rowstride);
+ public void* linear_open(Gegl.Rectangle? extent, int? rowstride, Babl.Format format);
+ public void linear_close(void* linear);
public bool set_extent (Gegl.Rectangle extent);
[NoAccessorMethod]
public unowned int abyss_height { get; construct; }
--
1.6.3.3
public class View : Gtk.DrawingArea
{
private weak Gegl.Node _node;
public weak Gegl.Node node
{
get{ return _node;}
set
{
_node = (Gegl.Node)value;
_node.computed.connect((rect)=>
{
int x = (int)(this.scale * rect.x - this.x);
int y = (int)(this.scale * rect.y - this.y);
int w = (int)Math.ceil(this.scale * rect.width + 1);
int h = (int)Math.ceil(this.scale * rect.height + 1);
this.queue_draw_area (x,y,w,h);
}
);
this._node.invalidated.connect((rect)=>this.repaint());
this.repaint();
}
}
private uint monitor_id;
private Gegl.Processor processor;
/* Fields */
public int x {get; set; default = 0;}
public int y {get; set; default = 0;}
private int screen_x;
private int screen_y;
private int orig_x;
private int orig_y;
private int start_buf_x;
private int start_buf_y;
private int prev_x;
private int prev_y;
private double _scale=1.0;
public double scale
{
get{return _scale;}
construct set
{
if (value > 100) {_scale = double.MAX+1;}
if (value < 0) {_scale = double.MIN -1;}
}
}
private double prev_scale;
private bool drag_started;
public bool block {get; set; default = false;}
public View(Gegl.Node node)
{
this.node = node;
this.set_size_request (300, 200);
this.add_events (Gdk.EventMask.BUTTON_PRESS_MASK
| Gdk.EventMask.BUTTON_RELEASE_MASK
| Gdk.EventMask.POINTER_MOTION_MASK);
}
public override bool button_press_event(Gdk.EventButton event)
{
int x = (int)event.x;
int y = (int)event.y;
this.screen_x = x;
this.screen_y = y;
this.orig_x = this.x;
this.orig_y = this.y;
this.start_buf_x = (int)((this.x + x)/this.scale);
this.start_buf_y = (int)((this.y + y)/this.scale);
this.prev_x = x;
this.prev_y = y;
x = (int)(x / this.scale + this.x);
y = (int)(y / this.scale + this.y);
Gegl.Node detected = this.node.detect ((int)((this.x + event.x)/this.scale),
(int)((this.y + event.y)/this.scale));
if (detected != null)
{
this.detected(detected);
}
this.drag_started = true;
return false;
}
public override bool button_release_event(Gdk.EventButton event)
{
this.drag_started = false;
return false;
}
public override bool motion_notify_event(Gdk.EventMotion event)
{
int x = (int)event.x;
int y = (int)event.y;
if (!this.drag_started) {return false;}
if ((event.state & Gdk.ModifierType.BUTTON2_MASK) != 0)
{
int diff_x = x - this.prev_x;
int diff_y = y - this.prev_y;
this.x -= diff_x;
this.y -= diff_y;
this.get_window().scroll(diff_x, diff_y);
}
this.prev_x = x;
this.prev_y = y;
return true;
}
public override bool expose_event (Gdk.EventExpose event)
{
if (this.node == null) {return false;}
Gdk.Rectangle[] rectangles;
event.region.get_rectangles(out rectangles);
foreach (var rectangle in rectangles)
{
Gegl.Rectangle roi = Gegl.Rectangle();
roi.x = this.x + rectangle.x;
roi.y = this.y + rectangle.y;
roi.width = rectangle.width;
roi.height = rectangle.height;
uchar[] buf = new uchar[roi.width*roi.height*3];
//uchar *buf = (uchar*)malloc (roi.width * roi.height * 3);
this.node.blit(this.scale,
roi,
Babl.format ("R'G'B' u8"),
(void*)buf,
Gegl.AUTO_ROWSTRIDE,
Gegl.BlitFlags.CACHE|
(this.block?0:Gegl.BlitFlags.DIRTY));
Gdk.draw_rgb_image(this.get_window(),
this.get_style().black_gc,
rectangle.x, rectangle.y,
rectangle.width, rectangle.height,
Gdk.RgbDither.NONE,
buf, roi.width*3);
}
return false;
}
public void repaint()
{
Gegl.Rectangle roi = Gegl.Rectangle();
roi.x = (int)(this.x / this.scale);
roi.y = (int)(this.y / this.scale);
roi.width = (int)Math.ceil(this.allocation.width / this.scale+1);
roi.height = (int)Math.ceil(this.allocation.height / this.scale+1);
if (this.monitor_id == 0)
{
this.monitor_id = Idle.add_full(Priority.LOW,task_monitor);
if (this.processor == null)
{
if (this.node != null)
{
this.processor = new Gegl.Processor(node, roi);
}
}
}
if (this.processor != null)
{
processor.set_rectangle(roi);
}
}
private bool task_monitor ()
{
if (this.processor == null)
{
return false;
}
if (this.processor.work(null))
{
return true;
}
this.monitor_id = 0;
return false;
}
public signal void detected(Gegl.Node node);
}
const double LINEWIDTH = 60.0;
const double HARDNESS = 0.2;
const string COLOR = "rgba(0.0,0.0,0.0,0.4)";
Gegl.Node n_gegl;
weak Gegl.Node n_out;
weak Gegl.Node n_top;
weak Gegl.Node n_over;
weak Gegl.Node n_stroke;
bool pen_down = false;
Gegl.Path vector;
Gegl.Buffer buffer;
public bool press (Gdk.EventButton event)
{
if (event.button == 1)
{
vector = new Gegl.Path();
n_over = n_gegl.new_child("operation","gegl:over");
n_stroke = n_gegl.new_child("operation","gegl:path",
"d", vector,
"fill-opacity", 0.0,
"stroke", new Gegl.Color(COLOR),
"stroke-width", LINEWIDTH,
"stroke-hardness", HARDNESS);
n_top.link_many(n_over, n_out);
n_stroke.connect_to("output", n_over, "aux");
vector.append('M', event.x, event.y);
pen_down = true;
return true;
}
return false;
}
public bool motion (Gdk.EventMotion event)
{
if ((event.state & Gdk.ModifierType.BUTTON1_MASK) !=0)
{
if (!pen_down)
{
return true;
}
vector.append('L',event.x,event.y);
return true;
}
return false;
}
public bool release (Gdk.EventButton event)
{
if (event.button == 1)
{
double x0,x1,y0,y1;
Gegl.Processor processor;
Gegl.Node writebuf;
Gegl.Rectangle roi = Gegl.Rectangle();
vector.get_bounds (out x0, out x1, out y0, out y1);
roi.x = (int)(x0 - LINEWIDTH);
roi.y = (int)(y0 - LINEWIDTH);
roi.width = (int)(x1 -x0 + LINEWIDTH * 2);
roi.height = (int)(y1 -y0 + LINEWIDTH * 2);
writebuf = n_gegl.new_child("operation", "gegl:write-buffer",
"buffer", buffer);
n_over.link_many(writebuf);
processor = new Gegl.Processor(writebuf, roi);
while (processor.work(null));
n_top.link_many(n_out);
n_over = null;
n_stroke = null;
pen_down = false;
return true;
}
return false;
}
static int main (string[] args)
{
Gtk.init (ref args);
Gegl.init (ref args);
Log.set_always_fatal (GLib.LogLevelFlags.LEVEL_CRITICAL);
// Setting up main window
Gtk.Window window = new Gtk.Window ();
window.title = "GPaint";
window.destroy.connect (Gtk.main_quit);
Gegl.Rectangle rect = {0,0,512,512};
void* buf;
buffer = new Gegl.Buffer(rect, Babl.format ("RGBA float"));
buf = buffer.linear_open (null, null, Babl.format("Y' u8"));
Memory.set (buf, 255, 512*512);
buffer.linear_close (buf);
n_gegl = new Gegl.Node ();
Gegl.Node loadbuf = n_gegl.new_child ("operation","gegl:buffer-source",
"buffer",buffer);
n_out = n_gegl.new_child ("operation", "gegl:nop");
loadbuf.link_many (n_out);
n_top = loadbuf;
var view = new View (n_out);
view.button_press_event.connect (press);
view.motion_notify_event.connect (motion);
view.button_release_event.connect (release);
view.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK);
window.add (view);
window.show_all ();
Gtk.main ();
n_gegl = null;
buffer = null;
loadbuf = null;
view = null;
Gegl.exit ();
return 0;
}
_______________________________________________
Gegl-developer mailing list
[email protected]
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer