[gnome-devel-docs] Added parameters to callback functions
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Added parameters to callback functions
- Date: Thu, 7 Jun 2012 03:28:04 +0000 (UTC)
commit 0521a8021579482d21dc98e60633df7d4a070167
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Wed Jun 6 23:27:25 2012 -0400
Added parameters to callback functions
platform-demos/C/samples/aboutdialog.vala | 4 +-
platform-demos/C/samples/button.vala | 2 +-
platform-demos/C/samples/gmenu.vala | 4 +--
platform-demos/C/samples/messagedialog.vala | 12 ++++----
platform-demos/C/samples/messagedialog_old.vala | 28 --------------------
platform-demos/C/samples/statusbar.vala | 7 +---
platform-demos/C/samples/switch.vala | 8 ++---
.../C/samples/treeview_simple_liststore.vala | 13 ++++-----
8 files changed, 21 insertions(+), 57 deletions(-)
---
diff --git a/platform-demos/C/samples/aboutdialog.vala b/platform-demos/C/samples/aboutdialog.vala
index 5892002..d28b974 100644
--- a/platform-demos/C/samples/aboutdialog.vala
+++ b/platform-demos/C/samples/aboutdialog.vala
@@ -12,10 +12,10 @@ public class Window : Gtk.ApplicationWindow {
this.show_all ();
}
- /* This is the callback function connected to the 'activate' signal
+ /* This is the callback function connected to the 'activate' signal
* of the SimpleAction about_action.
*/
- void about_cb () {
+ void about_cb (SimpleAction simple, Variant? parameter) {
string[] authors = { "GNOME Documentation Team", null };
string[] documenters = { "GNOME Documentation Team", null };
diff --git a/platform-demos/C/samples/button.vala b/platform-demos/C/samples/button.vala
index 77d20a8..7dc4171 100644
--- a/platform-demos/C/samples/button.vala
+++ b/platform-demos/C/samples/button.vala
@@ -14,7 +14,7 @@ public class MyWindow : Gtk.ApplicationWindow {
this.add (button);
}
- /* The callback function connected to the
+ /* The callback function connected to the
* 'clicked' signal of the button.
*/
void reverse_label (Gtk.Button button) {
diff --git a/platform-demos/C/samples/gmenu.vala b/platform-demos/C/samples/gmenu.vala
index 3c2d07e..e23ec88 100644
--- a/platform-demos/C/samples/gmenu.vala
+++ b/platform-demos/C/samples/gmenu.vala
@@ -19,7 +19,7 @@ public class Window : Gtk.ApplicationWindow {
}
/* Signal handler for 'activate' signal of the SimpleAction. */
- void about_cb () {
+ void about_cb (SimpleAction simple, Variant? parameter) {
print ("This does nothing. It is only a demonstration.\n");
}
}
@@ -52,8 +52,6 @@ public class Application : Gtk.Application {
//quit_action.activate.connect (this.quit);
this.add_action (quit_action);
}
-
-
}
/* main function creates Application and runs it. */
diff --git a/platform-demos/C/samples/messagedialog.vala b/platform-demos/C/samples/messagedialog.vala
index 3c6cf47..ddab941 100644
--- a/platform-demos/C/samples/messagedialog.vala
+++ b/platform-demos/C/samples/messagedialog.vala
@@ -29,15 +29,15 @@ public class Window : Gtk.ApplicationWindow {
dialog.destroy();
}
- void message () {
+ void message (SimpleAction simple, Variant? parameter) {
var messagedialog = new Gtk.MessageDialog (this,
- Gtk.DialogFlags.MODAL,
- Gtk.MessageType.WARNING,
- Gtk.ButtonsType.OK_CANCEL,
- "This action will cause the universe to stop existing.");
+ Gtk.DialogFlags.MODAL,
+ Gtk.MessageType.WARNING,
+ Gtk.ButtonsType.OK_CANCEL,
+ "This action will cause the universe to stop existing.");
messagedialog.response.connect (dialog_response);
- messagedialog.show ();
+ messagedialog.show ();
}
}
diff --git a/platform-demos/C/samples/statusbar.vala b/platform-demos/C/samples/statusbar.vala
index 4ae729d..8ee5071 100644
--- a/platform-demos/C/samples/statusbar.vala
+++ b/platform-demos/C/samples/statusbar.vala
@@ -8,12 +8,10 @@ public class MyWindow : Gtk.ApplicationWindow {
statusbar = new Gtk.Statusbar ();
context_id = statusbar.get_context_id ("example");
-
statusbar.push (context_id, "Waiting for you to do 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 ");
@@ -37,9 +35,9 @@ public class MyWindow : Gtk.ApplicationWindow {
button.clicked.connect(button_clicked_cb);
}
- /* Since the key-press-event is a signal received by the window, we don't need to connect
+ /* Since the key-press-event is a signal received by the window, we don't need to connect
the window to a callback function. We can just override key_press_event. */
- protected override bool key_press_event (Gdk.EventKey event) {
+ protected override bool key_press_event (Gdk.EventKey event) {
statusbar.push (context_id, Gdk.keyval_name(event.keyval) + " key was pressed.");
return true;
}
@@ -47,7 +45,6 @@ public class MyWindow : Gtk.ApplicationWindow {
void button_clicked_cb (Gtk.Button button) {
statusbar.push (context_id, "You clicked the button.");
}
-
}
public class MyApplication : Gtk.Application {
diff --git a/platform-demos/C/samples/switch.vala b/platform-demos/C/samples/switch.vala
index 6df42b7..a62cdd2 100644
--- a/platform-demos/C/samples/switch.vala
+++ b/platform-demos/C/samples/switch.vala
@@ -1,7 +1,5 @@
class MyWindow : Gtk.ApplicationWindow {
- Gtk.Switch switcher;
-
internal MyWindow (MyApplication app) {
Object (application: app, title: "Switch Example");
@@ -9,7 +7,7 @@ class MyWindow : Gtk.ApplicationWindow {
this.border_width = 10;
var label = new Gtk.Label ("Title");
- switcher = new Gtk.Switch ();
+ var switcher = new Gtk.Switch ();
switcher.set_active (true);
@@ -23,8 +21,8 @@ class MyWindow : Gtk.ApplicationWindow {
this.add (grid);
}
- void switcher_cb () {
- if (switcher.get_active())
+ void switcher_cb (Object switcher, ParamSpec pspec) {
+ if ((switcher as Gtk.Switch).get_active())
this.set_title ("Switch Example");
else
this.set_title ("");
diff --git a/platform-demos/C/samples/treeview_simple_liststore.vala b/platform-demos/C/samples/treeview_simple_liststore.vala
index 1c0cc32..7e77895 100644
--- a/platform-demos/C/samples/treeview_simple_liststore.vala
+++ b/platform-demos/C/samples/treeview_simple_liststore.vala
@@ -2,7 +2,7 @@ public class PhoneBookEntry {
public string firstname;
public string lastname;
public string phone;
-
+
public PhoneBookEntry (string f, string l, string p) {
this.firstname = f;
this.lastname = l;
@@ -12,7 +12,6 @@ public class PhoneBookEntry {
class TreeViewSimpleListStore : Gtk.ApplicationWindow {
- Gtk.TreeSelection selection;
Gtk.Label label;
PhoneBookEntry[] phonebook = {
@@ -43,12 +42,12 @@ class TreeViewSimpleListStore : Gtk.ApplicationWindow {
label = new Gtk.Label ("");
var grid = new Gtk.Grid ();
-
+
grid.attach (view, 0, 0, 1, 1);
grid.attach (label, 0, 1, 1, 1);
this.add (grid);
-
- selection = view.get_selection ();
+
+ var selection = view.get_selection ();
selection.changed.connect (this.on_changed);
}
@@ -60,7 +59,7 @@ class TreeViewSimpleListStore : Gtk.ApplicationWindow {
var cell = new Gtk.CellRendererText ();
- /* 'weight' refers to font boldness.
+ /* 'weight' refers to font boldness.
* 400 is normal.
* 700 is bold.
*/
@@ -91,7 +90,7 @@ class TreeViewSimpleListStore : Gtk.ApplicationWindow {
}
}
- void on_changed () {
+ void on_changed (Gtk.TreeSelection selection) {
Gtk.TreeModel model;
Gtk.TreeIter iter;
string name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]