[gnome-devel-docs] Vala statusbar example.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Vala statusbar example.
- Date: Tue, 8 May 2012 21:12:38 +0000 (UTC)
commit 8f3f74f285c62c694b7f32cbc127db614807d81f
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Tue May 8 17:12:05 2012 -0400
Vala statusbar example.
platform-demos/C/media/statusbar.png | Bin 0 -> 8642 bytes
platform-demos/C/samples/statusbar | Bin 0 -> 17035 bytes
platform-demos/C/samples/statusbar.vala | 65 +++++++++++++++++++++++++++++++
platform-demos/C/statusbar.vala.page | 32 +++++++++++++++
4 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/media/statusbar.png b/platform-demos/C/media/statusbar.png
new file mode 100644
index 0000000..338adc5
Binary files /dev/null and b/platform-demos/C/media/statusbar.png differ
diff --git a/platform-demos/C/samples/statusbar b/platform-demos/C/samples/statusbar
new file mode 100755
index 0000000..cf33826
Binary files /dev/null and b/platform-demos/C/samples/statusbar differ
diff --git a/platform-demos/C/samples/statusbar.vala b/platform-demos/C/samples/statusbar.vala
new file mode 100644
index 0000000..9c3fdaf
--- /dev/null
+++ b/platform-demos/C/samples/statusbar.vala
@@ -0,0 +1,65 @@
+public class MyWindow : Gtk.ApplicationWindow {
+
+ Gtk.Statusbar statusbar;
+ uint context_id;
+
+ internal MyWindow (MyApplication app) {
+ Object (application: app, title: "Statusbar Example");
+
+ statusbar = new Gtk.Statusbar ();
+ context_id = statusbar.get_context_id ("example");
+
+ statusbar.push (context_id, "Waiting for you do to something...");
+
+ //set the default size of the window
+ this.set_default_size (200, 100);
+
+ var grid = new Gtk.Grid ();
+ var label = new Gtk.Label ("Press any key or ");
+
+ grid.attach (label, 1, 1, 1, 1);
+ label.show ();
+
+ var button = new Gtk.Button.with_label ("click me.");
+ grid.attach_next_to (button, label, Gtk.PositionType.RIGHT, 1, 1);
+ button.show ();
+
+ grid.attach (statusbar, 1, 2, 2, 1);
+ statusbar.show ();
+
+ grid.set_column_spacing (5);
+ grid.set_column_homogeneous (true);
+ grid.set_row_homogeneous (true);
+
+ this.add (grid);
+ grid.show ();
+
+ button.clicked.connect(button_clicked_cb);
+ }
+
+ /* Since the key-press-event is a signal emitted the window, we don't need to connect it
+ to a callback function. We can just override key_press_event. */
+ protected override bool key_press_event (Gdk.EventKey event) {
+ statusbar.push (context_id, Gdk.keyval_name(event.keyval) + " key was pressed.");
+ return true;
+ }
+
+ void button_clicked_cb (Gtk.Button button) {
+ statusbar.push (context_id, "You clicked the button.");
+ }
+
+}
+
+public class MyApplication : Gtk.Application {
+ protected override void activate () {
+ new MyWindow (this).show ();
+ }
+
+ internal MyApplication () {
+ Object (application_id: "org.example.status");
+ }
+}
+
+public int main (string[] args) {
+ return new MyApplication ().run (args);
+}
diff --git a/platform-demos/C/statusbar.vala.page b/platform-demos/C/statusbar.vala.page
new file mode 100644
index 0000000..0c484e7
--- /dev/null
+++ b/platform-demos/C/statusbar.vala.page
@@ -0,0 +1,32 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="statusbar.vala">
+ <info>
+ <link type="guide" xref="beginner.vala#display-widgets"/>
+ <link type="seealso" xref="grid.vala"/>
+ <link type="seealso" xref="button.vala"/>
+ <link type="seealso" xref="label.vala"/>
+ <revision version="0.1" date="2012-05-08" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Tiffany Antopolski</name>
+ <email>tiffany antopolski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>Report messages of minor importance to the user</desc>
+ </info>
+
+ <title>Statusbar</title>
+ <media type="image" mime="image/png" src="media/statusbar.png"/>
+ <p>This statusbar tells you what's going on.</p>
+
+<code mime="text/x-vala" style="numbered"><xi:include href="samples/statusbar.vala" parse="text"><xi:fallback/></xi:include></code>
+<p>
+ In this sample we used the following:
+</p>
+<list>
+ <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Statusbar">Gtk.Statusbar</link></p></item>
+</list>
+</page>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]