[gnome-devel-docs] Vala toolbar example: redesigned fullscreen callback.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Vala toolbar example: redesigned fullscreen callback.
- Date: Thu, 31 May 2012 14:00:18 +0000 (UTC)
commit bc2e94e55d8bc2cd5e456d44c901ac59a68516d3
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Thu May 31 09:35:49 2012 -0400
Vala toolbar example: redesigned fullscreen callback.
platform-demos/C/samples/toolbar.vala | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/platform-demos/C/samples/toolbar.vala b/platform-demos/C/samples/toolbar.vala
index 6918048..01e62e5 100644
--- a/platform-demos/C/samples/toolbar.vala
+++ b/platform-demos/C/samples/toolbar.vala
@@ -1,6 +1,6 @@
/* This is the Window */
class MyWindow : Gtk.ApplicationWindow {
-
+
/* Instance variables belonging to the window */
Gtk.Toolbar toolbar;
Gtk.ToolButton new_button;
@@ -8,9 +8,8 @@ class MyWindow : Gtk.ApplicationWindow {
Gtk.ToolButton undo_button;
Gtk.ToolButton fullscreen_button;
Gtk.ToolButton leave_fullscreen_button;
- bool window_is_fullscreen = false;
- /* Contstructor */
+ /* Contstructor */
internal MyWindow (MyApplication app) {
Object (application: app, title: "Toolbar Example");
@@ -38,8 +37,7 @@ class MyWindow : Gtk.ApplicationWindow {
/* This function creates the toolbar, its ToolButtons,
* and assigns the actions names to the ToolButtons.*/
void create_toolbar () {
-
- toolbar = new Gtk.Toolbar ();
+ toolbar = new Gtk.Toolbar ();
toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
new_button = new Gtk.ToolButton.from_stock (Gtk.Stock.NEW);
@@ -48,13 +46,13 @@ class MyWindow : Gtk.ApplicationWindow {
new_button.show ();
new_button.action_name = "app.new";
- open_button = new Gtk.ToolButton.from_stock (Gtk.Stock.OPEN);
- open_button.is_important = true;
- toolbar.add (open_button);
+ open_button = new Gtk.ToolButton.from_stock (Gtk.Stock.OPEN);
+ open_button.is_important = true;
+ toolbar.add (open_button);
open_button.show ();
open_button.action_name = "app.open";
- undo_button = new Gtk.ToolButton.from_stock (Gtk.Stock.UNDO);
+ undo_button = new Gtk.ToolButton.from_stock (Gtk.Stock.UNDO);
undo_button.is_important = true;
toolbar.add (undo_button);
undo_button.show ();
@@ -65,7 +63,7 @@ class MyWindow : Gtk.ApplicationWindow {
toolbar.add (fullscreen_button);
fullscreen_button.show ();
fullscreen_button.action_name = "win.fullscreen";
-
+
leave_fullscreen_button = new Gtk.ToolButton.from_stock (Gtk.Stock.LEAVE_FULLSCREEN)
;
leave_fullscreen_button.is_important = true;
@@ -79,15 +77,13 @@ class MyWindow : Gtk.ApplicationWindow {
}
void fullscreen_callback () {
- if (window_is_fullscreen) {
+ if ((this.get_window ().get_state () & Gdk.WindowState.FULLSCREEN) != 0) {
this.unfullscreen ();
- window_is_fullscreen = false;
leave_fullscreen_button.hide ();
fullscreen_button.show ();
}
else {
this.fullscreen ();
- window_is_fullscreen = true;
fullscreen_button.hide ();
leave_fullscreen_button.show ();
}
@@ -102,7 +98,7 @@ class MyApplication : Gtk.Application {
protected override void startup () {
base.startup ();
-
+
/* Create the "new" action and add it to the app*/
var new_action = new SimpleAction ("new", null);
new_action.activate.connect (new_callback);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]