[gnome-devel-docs] Vala samples: removed using Gtk statement and adjusted code.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Vala samples: removed using Gtk statement and adjusted code.
- Date: Thu, 12 Apr 2012 14:02:23 +0000 (UTC)
commit 58eb77f0240a29ea2828c9bc9fe764361d047f20
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Thu Apr 12 10:01:31 2012 -0400
Vala samples: removed using Gtk statement and adjusted code.
platform-demos/C/button.vala.page | 16 ++++++--------
platform-demos/C/dialog.vala.page | 16 ++++++--------
platform-demos/C/samples/button.vala | 12 ++++------
platform-demos/C/samples/dialog.vala | 31 +++++++++++++--------------
platform-demos/C/samples/window.vala | 10 +++-----
platform-demos/C/window.vala.page | 38 ++++++++++++++++-----------------
6 files changed, 56 insertions(+), 67 deletions(-)
---
diff --git a/platform-demos/C/button.vala.page b/platform-demos/C/button.vala.page
index 6db1c6d..bffac71 100644
--- a/platform-demos/C/button.vala.page
+++ b/platform-demos/C/button.vala.page
@@ -20,26 +20,24 @@
<p>A button widget connected to stdout.printf (), and a modal window.</p>
<code mime="text/x-vala" style="numbered"><![CDATA[
-using Gtk;
-
/*callback for the "clicked" signal.*/
void button_clicked_cb () {
stdout.printf ("You clicked the button!\n");
- //TODO: add a modal window
+ //TODO: add a modal window
}
int main (string[] args) {
- init (ref args);
+ Gtk.init (ref args);
- var window = new Window ();
+ var window = new Gtk.Window ();
window.title = "GNOME Button";
window.set_default_size (250,50);
- var button = new Button.with_label ("Click Me");
- window.add (button); //adds the button to the window
+ var button = new Gtk.Button.with_label ("Click Me");
+ window.add (button);
- window.window_position = WindowPosition.CENTER;
+ window.window_position = Gtk.WindowPosition.CENTER;
/* The "clicked" signal is emitted when the
button is clicked. The signal is connected to
@@ -51,7 +49,7 @@ int main (string[] args) {
The destroy signal is connected to the
main_quit method, which destroys the window
and exits the program.*/
- window.destroy.connect (main_quit);
+ window.destroy.connect (Gtk.main_quit);
window.show_all ();
diff --git a/platform-demos/C/dialog.vala.page b/platform-demos/C/dialog.vala.page
index fb40eb7..b9c18de 100644
--- a/platform-demos/C/dialog.vala.page
+++ b/platform-demos/C/dialog.vala.page
@@ -19,24 +19,22 @@
<p>A dialog with the response signal hooked up to a callback function.</p>
<code mime="text/x-vala" style="numbered"><![CDATA[
-using Gtk;
-
void on_response (int response_id) {
/*To see the int value of the ResponseType*/
print ("response is %d\n", response_id);
-
- main_quit ();
+
+ Gtk.main_quit ();
}
int main (string[] args) {
- init (ref args);
+ Gtk.init (ref args);
+
+ var dialog = new Gtk.Dialog.with_buttons ("A Gtk+ Dialog", null, 0, Gtk.Stock.OK, Gtk.ResponseType.OK, null);
+ var content_area = dialog.get_content_area () as Gtk.Container; //TODO: explain this
+ var label = new Gtk.Label ("This demonstrates a dialog with a label");
- var dialog = new Dialog.with_buttons ("A Gtk+ Dialog", null, 0, Stock.OK, ResponseType.OK, null);
- var content_area = dialog.get_content_area ();
- var label = new Label ("This demonstrates a dialog with a label");
-
content_area.add (label);
dialog.response.connect (on_response);
dialog.show_all ();
diff --git a/platform-demos/C/samples/button.vala b/platform-demos/C/samples/button.vala
index 65599fd..060fb72 100644
--- a/platform-demos/C/samples/button.vala
+++ b/platform-demos/C/samples/button.vala
@@ -1,5 +1,3 @@
-using Gtk;
-
/*callback for the "clicked" signal.*/
void button_clicked_cb () {
stdout.printf ("You clicked the button!\n");
@@ -8,16 +6,16 @@ void button_clicked_cb () {
int main (string[] args) {
- init (ref args);
+ Gtk.init (ref args);
- var window = new Window ();
+ var window = new Gtk.Window ();
window.title = "GNOME Button";
window.set_default_size (250,50);
- var button = new Button.with_label ("Click Me");
+ var button = new Gtk.Button.with_label ("Click Me");
window.add (button);
- window.window_position = WindowPosition.CENTER;
+ window.window_position = Gtk.WindowPosition.CENTER;
/* The "clicked" signal is emitted when the
button is clicked. The signal is connected to
@@ -29,7 +27,7 @@ int main (string[] args) {
The destroy signal is connected to the
main_quit method, which destroys the window
and exits the program.*/
- window.destroy.connect (main_quit);
+ window.destroy.connect (Gtk.main_quit);
window.show_all ();
diff --git a/platform-demos/C/samples/dialog.vala b/platform-demos/C/samples/dialog.vala
index 09dae91..a9dc5fb 100644
--- a/platform-demos/C/samples/dialog.vala
+++ b/platform-demos/C/samples/dialog.vala
@@ -1,24 +1,23 @@
-using Gtk;
-
void on_response (int response_id) {
- /*To see the int value of the ResponseType*/
- print ("response is %d\n", response_id);
-
- main_quit ();
+ /*To see the int value of the ResponseType*/
+ print ("response is %d\n", response_id);
+
+ Gtk.main_quit ();
}
+
int main (string[] args) {
- init (ref args);
+ Gtk.init (ref args);
- var dialog = new Dialog.with_buttons ("A Gtk+ Dialog", null, 0, Stock.OK, ResponseType.OK, null);
- var content_area = dialog.get_content_area ();
- var label = new Label ("This demonstrates a dialog with a label");
-
- content_area.add (label);
- dialog.response.connect (on_response);
- dialog.show_all ();
+ var dialog = new Gtk.Dialog.with_buttons ("A Gtk+ Dialog", null, 0, Gtk.Stock.OK, Gtk.ResponseType.OK, null);
+ var content_area = dialog.get_content_area () as Gtk.Container; //TODO: explain this
+ var label = new Gtk.Label ("This demonstrates a dialog with a label");
+
+ content_area.add (label);
+ dialog.response.connect (on_response);
+ dialog.show_all ();
- Gtk.main ();
- return 0;
+ Gtk.main ();
+ return 0;
}
diff --git a/platform-demos/C/samples/window.vala b/platform-demos/C/samples/window.vala
index 8f5ac5a..b59e67e 100644
--- a/platform-demos/C/samples/window.vala
+++ b/platform-demos/C/samples/window.vala
@@ -1,10 +1,8 @@
-using Gtk;
-
int main (string[] args) {
- init (ref args);
+ Gtk.init (ref args);
- var window = new Window ();
+ var window = new Gtk.Window ();
window.title = "Welcome to GNOME";
/*
@@ -14,11 +12,11 @@ int main (string[] args) {
*/
//window.border_width = 10;
//window.set_default_size (350, 70);
- //window.window_position = WindowPosition.CENTER;
+ //window.window_position = Gtk.WindowPosition.CENTER;
/*The destroy signal is emitted when the x
in the top right of the window is clicked.*/
- window.destroy.connect (main_quit);
+ window.destroy.connect (Gtk.main_quit);
/*The show () method only shows the widget it is called on.
If the widget has children (for example a label or a button,
diff --git a/platform-demos/C/window.vala.page b/platform-demos/C/window.vala.page
index 2cc859d..a7b3c71 100644
--- a/platform-demos/C/window.vala.page
+++ b/platform-demos/C/window.vala.page
@@ -19,36 +19,34 @@
<p>A toplevel window with destroy signal hooked up.</p>
<code mime="text/x-vala" style="numbered"><![CDATA[
-using Gtk;
-
int main (string[] args) {
- init (ref args);
+ Gtk.init (ref args);
- var window = new Window ();
- window.title = "Welcome to GNOME";
+ var window = new Gtk.Window ();
+ window.title = "Welcome to GNOME";
- /*
- The following 3 lines are included here to introduce
- you to ways you can adjust the toplevel window to suit
- your needs. Uncomment them to see what they do.
- */
- //window.border_width = 10;
- //window.set_default_size (350, 70);
- //window.window_position = WindowPosition.CENTER;
+ /*
+ The following 3 lines are included here to introduce
+ you to ways you can adjust the toplevel window to suit
+ your needs. Uncomment them to see what they do.
+ */
+ //window.border_width = 10;
+ //window.set_default_size (350, 70);
+ //window.window_position = Gtk.WindowPosition.CENTER;
- /*The destroy signal is emitted when the x
- in the top right of the window is clicked.*/
- window.destroy.connect (main_quit);
+ /*The destroy signal is emitted when the x
+ in the top right of the window is clicked.*/
+ window.destroy.connect (Gtk.main_quit);
- /*The show () method only shows the widget it is called on.
+ /*The show () method only shows the widget it is called on.
If the widget has children (for example a label or a button,
the method show_all () should be used to show the widget and
the child widgets.*/
- window.show ();
+ window.show ();
- Gtk.main ();
- return 0;
+ Gtk.main ();
+ return 0;
}
]]></code>
<p>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]