|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="image.vala" xml:lang="pt-BR">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">Image (Vala)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.vala#display-widgets"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-05-03" status="draft"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Tiffany Antopolski</name>
|
|
Packit |
1470ea |
<email its:translate="no">tiffany.antopolski@gmail.com</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>A widget displaying an image</desc>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Rafael Ferreira</mal:name>
|
|
Packit |
1470ea |
<mal:email>rafael.f.f1@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2013</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Image</title>
|
|
Packit |
1470ea |
<media type="image" mime="image/png" src="media/image.png"/>
|
|
Packit |
1470ea |
This GtkApplication displays an image file from the current directory.
|
|
Packit |
1470ea |
<note>
|
|
Packit |
1470ea |
If the image file isn't loaded successfully, the image will contain a "broken image" icon. The <file>filename.png</file> needs to be in the current directory for this code to work. Use your favorite picture!
|
|
Packit |
1470ea |
</note>
|
|
Packit |
1470ea |
public class MyWindow : Gtk.ApplicationWindow {
|
|
Packit |
1470ea |
internal MyWindow (MyApplication app) {
|
|
Packit |
1470ea |
Object (application: app, title: "Welcome to GNOME");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var image = new Gtk.Image ();
|
|
Packit |
1470ea |
image.set_from_file ("gnome-image.png");
|
|
Packit |
1470ea |
this.add (image);
|
|
Packit |
1470ea |
this.set_default_size (300, 300);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
new MyWindow (this).show_all ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyApplication () {
|
|
Packit |
1470ea |
Object (application_id: "org.example.MyApplication");
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public int main (string[] args) {
|
|
Packit |
1470ea |
return new MyApplication ().run (args);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
In this sample we used the following:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Application.html">GtkApplication</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.ApplicationWindow.html">GtkApplicationWindow</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Image.html">GtkImage</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</page>
|