[gnome-clocks/wip/headerbar: 2/2] Fix crash
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/wip/headerbar: 2/2] Fix crash
- Date: Fri, 8 Mar 2013 14:11:49 +0000 (UTC)
commit 20c34964b128b8d495ad10c785509e69f6465d00
Author: Stefano Facchini <stefano facchini gmail com>
Date: Fri Mar 8 15:14:09 2013 +0100
Fix crash
src/widgets.vala | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/widgets.vala b/src/widgets.vala
index b9027a9..182b15a 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -28,6 +28,8 @@ public class Toolbar : Gd.HeaderBar {
private List<Gtk.Widget> buttons;
private Gd.StackSwitcher stack_switcher;
+ private bool realized = false;
+
[CCode (notify = false)]
public Mode mode {
get {
@@ -35,7 +37,7 @@ public class Toolbar : Gd.HeaderBar {
}
set {
- if (_mode != value) {
+ if (_mode != value && realized) {
_mode = value;
custom_title = (_mode == Mode.NORMAL) ? stack_switcher : null;
@@ -53,12 +55,19 @@ public class Toolbar : Gd.HeaderBar {
private Mode _mode;
+ construct {
+ stack_switcher = new Gd.StackSwitcher ();
+ realize.connect (() => {
+ realized = true;
+ custom_title = stack_switcher;
+ });
+ unrealize.connect (() => {
+ realized = false;
+ });
+ }
+
public void set_stack (Gd.Stack stack) {
- if (stack_switcher == null) {
- stack_switcher = new Gd.StackSwitcher ();
- }
stack_switcher.set_stack (stack);
- custom_title = stack_switcher;
}
public Gtk.Button add_button (string? icon_name, string? label, bool should_pack_start) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]