[gnome-devel-docs] Vala ProgressBar redesign, and new video.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Vala ProgressBar redesign, and new video.
- Date: Sun, 17 Jun 2012 02:36:57 +0000 (UTC)
commit df8e5e563f241018c10c736bbc8b41aa73eee71c
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Sat Jun 16 22:35:22 2012 -0400
Vala ProgressBar redesign, and new video.
platform-demos/C/media/progressbar_fill.ogv | Bin 0 -> 19513 bytes
platform-demos/C/progressbar.vala.page | 16 +-------
platform-demos/C/samples/progressbar.vala | 54 +++++++++++----------------
platform-demos/Makefile.am | 1 +
4 files changed, 25 insertions(+), 46 deletions(-)
---
diff --git a/platform-demos/C/media/progressbar_fill.ogv b/platform-demos/C/media/progressbar_fill.ogv
new file mode 100644
index 0000000..df53494
Binary files /dev/null and b/platform-demos/C/media/progressbar_fill.ogv differ
diff --git a/platform-demos/C/progressbar.vala.page b/platform-demos/C/progressbar.vala.page
index 72f919d..0370e27 100644
--- a/platform-demos/C/progressbar.vala.page
+++ b/platform-demos/C/progressbar.vala.page
@@ -17,18 +17,8 @@
</info>
<title>ProgressBar</title>
- <media type="video" mime="application/ogv" src="media/progressbar.ogv">
- <tt:tt xmlns:tt="http://www.w3.org/ns/ttml">
- <tt:body>
- <tt:div begin="0s" end="6s">
- <tt:p>
- Pressing any key stops and starts this ProgressBar.
- </tt:p>
- </tt:div>
- </tt:body>
- </tt:tt>
- </media>
- <p>This ProgressBar is stopped and started by pressing any key.</p>
+ <media type="video" mime="application/ogv" src="media/progressbar_fill.ogv" />
+ <p>This ProgressBar "fills in" by a fraction of the bar until it is full.</p>
<code mime="text/x-vala" style="numbered"><xi:include href="samples/progressbar.vala" parse="text"><xi:fallback/></xi:include></code>
<p>
@@ -37,7 +27,5 @@
<list>
<item><p><link href="http://www.valadoc.org/gtk+-3.0/Gtk.ProgressBar.html">Gtk.ProgressBar</link></p></item>
<item><p><link href="http://www.valadoc.org/glib-2.0/GLib.Timeout.html">GLib.Timeout</link></p></item>
- <item><p><link href="http://www.valadoc.org/glib-2.0/GLib.Source.html">GLib.Source</link></p></item>
- <item><p><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Widget.key_press_event.html">Gtk.Widget.key_press_event</link></p></item>
</list>
</page>
diff --git a/platform-demos/C/samples/progressbar.vala b/platform-demos/C/samples/progressbar.vala
index 7033517..7ad6941 100644
--- a/platform-demos/C/samples/progressbar.vala
+++ b/platform-demos/C/samples/progressbar.vala
@@ -1,44 +1,34 @@
-public class MyWindow : Gtk.ApplicationWindow {
+public class MyApplication : Gtk.Application {
Gtk.ProgressBar progress_bar;
- uint source_id;
-
- internal MyWindow (MyApplication app) {
- Object (application: app, title: "ProgressBar Example");
- this.set_default_size (220, 20);
-
- progress_bar = new Gtk.ProgressBar ();
- this.add (progress_bar);
- progress_bar.show ();
- source_id = GLib.Timeout.add (100, pulse);
- }
+ protected override void activate () {
+ var window = new Gtk.ApplicationWindow (this);
+ window.set_title ("ProgressBar Example");
+ window.set_position (Gtk.WindowPosition.CENTER);
+ window.set_default_size (220, 20);
- protected override bool key_press_event (Gdk.EventKey event) {
- if (source_id == 0)
- source_id = GLib.Timeout.add (100, pulse);
- else {
- GLib.Source.remove (source_id);
- source_id = 0;
- }
- return true;
- }
+ progress_bar = new Gtk.ProgressBar ();
+ window.add (progress_bar);
+ window.show_all ();
- bool pulse () {
- progress_bar.pulse ();
- return true;
+ double fraction = 0.0;
+ progress_bar.set_fraction (fraction);
+ GLib.Timeout.add (500, fill);
+ this.quit ();
}
-}
-public class MyApplication : Gtk.Application {
+ bool fill () {
+ double fraction = progress_bar.get_fraction ();
+ fraction += 0.1; //increase by 10%
- protected override void activate () {
- MyWindow window = new MyWindow (this);
- window.show ();
- }
+ progress_bar.set_fraction (fraction);
- internal MyApplication () {
- Object (application_id: "org.example.ProgressBar");
+ /* This function is only called by GLib.Timeout.add while it returns true; */
+ if (fraction < 1.0)
+ return true;
+ else progress_bar.set_fraction (0.0);
+ return true;
}
}
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index 0a2e4ef..45add53 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -150,6 +150,7 @@ DOC_FIGURES = \
media/photo-wall.png \
media/photo-wall-focused.png \
media/progressbar.ogv \
+ media/progressbar_fill.ogv \
media/radiobutton.png \
media/radiobuttontravel.png \
media/record-collection.png \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]