Skip to content

Commit 3da2ded

Browse files
esodanPhilip-Scott
authored andcommitted
Add GSVGtk support
1 parent 1c178e1 commit 3da2ded

22 files changed

+427
-79
lines changed
File renamed without changes.

data/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ deconf.set('API_VERSION', API_VERSION)
55
deconf.set('prefix', get_option('prefix'))
66
deconf.set('libdir', '${exec_prefix}/'+get_option('libdir'))
77

8-
configure_file(input : 'gtkcanvas.pc.in',
9-
output : 'gtkcanvas-@[email protected]'.format(API_VERSION),
8+
configure_file(input : 'gcav.pc.in',
9+
output : 'gcav-@[email protected]'.format(API_VERSION),
1010
configuration : deconf,
1111
install : true,
1212
install_dir : join_paths(get_option('libdir'), 'pkgconfig')

demo/Window.vala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ int main (string argv[]) {
2323
GtkClutter.init (ref argv);
2424

2525
var window = new Gtk.Window ();
26-
window.title = "GtkCanvas Demo";
26+
window.title = "GtkCanvas (Gcav) Demo";
2727

2828
window.resize (1000, 800);
2929

30-
var canvas = new GtkCanvas.Canvas (600, 400);
30+
var canvas = new Gcav.Canvas (600, 400);
3131
canvas.add_shape ("rectangle", "blue", 45.0);
3232
canvas.add_shape ("rectangle", "red", 30.0);
3333
canvas.add_shape ("circle", "green", 0.0);
34+
#if GSVGTK
35+
canvas.add_shape ("svg", "blue", 0.0);
36+
#endif
3437

3538
canvas.clicked.connect ((modifier) => {
3639
canvas.resizer.visible = false;
@@ -94,4 +97,4 @@ int main (string argv[]) {
9497
window.show_all ();
9598
Gtk.main ();
9699
return 0;
97-
}
100+
}

demo/meson.build

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ files_demo=([
22
'Window.vala'
33
])
44

5+
args = ['--vapidir='+ldir]
6+
7+
if svgdep.found()
8+
args+= ['--define=GSVGTK']
9+
endif
10+
511
executable ('gtkcanvas-demo',
612
files_demo,
7-
vala_args: [
8-
'--vapidir='+ldir
9-
],
13+
vala_args: args,
1014
dependencies : [ deps, inc_libh_dep ],
1115
link_with: lib,
1216
install: false)

docs/meson.build

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
pkgs = [
2+
'--pkg=gtk+-3.0',
3+
'--pkg=granite',
4+
'--pkg=clutter-1.0',
5+
'--pkg=clutter-gtk-1.0'
6+
]
7+
if svgdep.found ()
8+
pkgs += ['--pkg=gsvgtk-0.6']
9+
endif
10+
111
valadoc = find_program ('valadoc', required: false)
212
if valadoc.found()
313
outdir = CAMEL_CASE_NAME+'-'+API_VERSION
@@ -17,10 +27,7 @@ if valadoc.found()
1727
'--force',
1828
pkgname,
1929
pkgversion,
20-
'--pkg=gtk+-3.0',
21-
'--pkg=granite',
22-
'--pkg=clutter-1.0',
23-
'--pkg=clutter-gtk-1.0',
30+
pkgs,
2431
'--directory=@OUTDIR@',
2532
valasources],
2633
install : true,

meson.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
project('gtkcanvas', [ 'vala', 'c'], version : '0.1.0')
22

3-
PROJECT_NAME = meson.project_name()
3+
PROJECT_NAME = 'gcav'
44
API_VERSION = '0.4'
55
PROJECT_VERSION = meson.project_version()
66
VERSIONED_PROJECT_NAME = PROJECT_NAME+'-'+API_VERSION
7-
CAMEL_CASE_NAME = 'GtkCanvas'
7+
CAMEL_CASE_NAME = 'Gcav'
88
VERSIONED_CAMEL_CASE_NAME = CAMEL_CASE_NAME +'-'+ API_VERSION
99

1010
cc = meson.get_compiler('c')
@@ -17,6 +17,8 @@ deps = ([dependency('gtk+-3.0', version:'>=3.18'),
1717
m_dep
1818
])
1919

20+
svgdep = dependency('gsvgtk-0.6', version:'>=0.5.0', required: false)
21+
2022

2123
inc_rooth = include_directories ('.')
2224
inc_rooth_dep = declare_dependency (include_directories : inc_rooth)

readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ It is meant to contain the basic elements such as a basic container class, move,
1212
- clutter-gtk-1.0
1313
- granite
1414

15+
#### For SVG support
16+
17+
- gsvgtk-0.6
18+
- librsvg-2.0
19+
- gsvg-0.4
20+
- gxml-0.16
21+
1522
### To compile & run the demo
1623

1724
#### Meson Build

src/Utils/HoverAction.vala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Authored by: Alessandro Castellani <[email protected]>
2020
*/
2121

22-
internal class GtkCanvas.HoverAction : Object {
22+
internal class Gcav.HoverAction : Object {
2323
/**
2424
* Toggle the visibility of the HoverEffect()
2525
*/
@@ -42,9 +42,9 @@ internal class GtkCanvas.HoverAction : Object {
4242
bool visible = false;
4343

4444
/**
45-
* Parent CanvasItem passed on mouse enter
45+
* Parent Item passed on mouse enter
4646
*/
47-
private unowned CanvasItem item;
47+
private unowned Item item;
4848

4949
/**
5050
* HoverEffect (int border_width )
@@ -53,9 +53,9 @@ internal class GtkCanvas.HoverAction : Object {
5353

5454
/**
5555
* Initialize Class
56-
* @param CanvasItem item [hovered item from canvas]
56+
* @param Item item [hovered item from canvas]
5757
*/
58-
public HoverAction (CanvasItem item) {
58+
public HoverAction (Item item) {
5959
this.item = item;
6060
}
6161

@@ -67,4 +67,4 @@ internal class GtkCanvas.HoverAction : Object {
6767
public void toggle (bool toggle) {
6868
toggled = toggle;
6969
}
70-
}
70+
}

src/Utils/HoverEffect.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Authored by: Felipe Escoto <[email protected]>
2020
*/
2121

22-
internal class HoverEffect : Clutter.Effect {
22+
internal class Gcav.HoverEffect : Clutter.Effect {
2323
public int border_size { get; construct; }
2424
public float scale_factor { get; set; default = 1; }
2525

src/Utils/MoveAction.vala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
*/
2121

2222
/**
23-
* Manages and controls a CanvasItem's movement.
23+
* Manages and controls a Item's movement.
2424
*/
25-
internal class GtkCanvas.MoveAction : Clutter.DragAction {
25+
internal class Gcav.MoveAction : Clutter.DragAction {
2626
private int x_offset_press = 0;
2727
private int y_offset_press = 0;
2828

29-
private unowned CanvasItem item;
29+
private unowned Item item;
3030

31-
public MoveAction (CanvasItem item) {
31+
public MoveAction (Item item) {
3232
this.item = item;
3333

3434
drag_begin.connect (on_move_begin);

0 commit comments

Comments
 (0)