Skip to content

Commit

Permalink
Merge branch 'vala_args'.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Jul 3, 2015
2 parents 919d958 + 04f1658 commit 5cbcb14
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'c_args' : True,
'cpp_args' : True,
'cs_args' : True,
'vala_args' : True,
'link_args' : True,
'link_depends': True,
'link_with' : True,
Expand Down Expand Up @@ -299,6 +300,10 @@ def process_kwargs(self, kwargs, environment):
if not isinstance(cslist, list):
cslist = [cslist]
self.add_compiler_args('cs', cslist)
valalist = kwargs.get('vala_args', [])
if not isinstance(valalist, list):
valalist = [valalist]
self.add_compiler_args('vala', valalist)
self.link_args = kwargs.get('link_args', [])
if not isinstance(self.link_args, list):
self.link_args = [self.link_args]
Expand Down
20 changes: 20 additions & 0 deletions manual tests/7 vala composite widgets/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
project('composite', 'vala', 'c')
gnome = import('gnome')
deps = [
dependency('glib-2.0', version : '>=2.38'),
dependency('gobject-2.0'),
dependency('gtk+-3.0'),
]
res = gnome.compile_resources(
'my', 'my-resources.xml',
source_dir : '.',
)
executable(
'demo',
sources : [
'mywidget.vala',
res,
],
dependencies : deps,
vala_args : '--gresources=@0@/my-resources.xml'.format(meson.current_source_dir()),
)
6 changes: 6 additions & 0 deletions manual tests/7 vala composite widgets/my-resources.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/foo/my">
<file compressed="true" preprocess="xml-stripblanks">mywidget.ui</file>
</gresource>
</gresources>
70 changes: 70 additions & 0 deletions manual tests/7 vala composite widgets/mywidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<template class="MyWidget" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">This widget is defined with composite GtkBuilder script</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<signal name="changed" handler="on_entry_changed" object="MyWidget" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Press the button to fetch the internal entry text</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label" translatable="yes">The Button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<signal name="clicked" handler="on_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</template>
</interface>
41 changes: 41 additions & 0 deletions manual tests/7 vala composite widgets/mywidget.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Gtk;

[GtkTemplate (ui = "/org/foo/my/mywidget.ui")]
public class MyWidget : Box {
public string text {
get { return entry.text; }
set { entry.text = value; }
}

[GtkChild]
private Entry entry;

public MyWidget (string text) {
this.text = text;
}

[GtkCallback]
private void on_button_clicked (Button button) {
print ("The button was clicked with entry text: %s\n", entry.text);
}

[GtkCallback]
private void on_entry_changed (Editable editable) {
print ("The entry text changed: %s\n", entry.text);

notify_property ("text");
}
}

void main(string[] args) {
Gtk.init (ref args);
var win = new Window();
win.destroy.connect (Gtk.main_quit);

var widget = new MyWidget ("The entry text!");

win.add (widget);
win.show_all ();

Gtk.main ();
}
1 change: 1 addition & 0 deletions ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ def generate_vala_compile(self, target, outfile):
args += ['--target-glib', d.version_requirement[2:]]
args += ['--pkg', d.name]
args += vapi_src
args += target.extra_args.get('vala', [])
generated_c += [relsc]
element = NinjaBuildElement(relsc, valac.get_language() + '_COMPILER', rel_s)
element.add_item('ARGS', args)
Expand Down

0 comments on commit 5cbcb14

Please sign in to comment.