[california/wip/732029-gtk-312] Fix more focus/Gtk.Popover closing issues



commit 2fe9ef5447619dcf9ddcb61b1e2822b7f57b06cb
Author: Jim Nelson <jim yorba org>
Date:   Wed Jul 23 15:18:50 2014 -0700

    Fix more focus/Gtk.Popover closing issues

 src/toolkit/toolkit-deck-window.vala         |   36 ++++++++++++++++++++++---
 src/toolkit/toolkit-rotating-button-box.vala |    3 ++
 2 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/src/toolkit/toolkit-deck-window.vala b/src/toolkit/toolkit-deck-window.vala
index 25adc40..60877ce 100644
--- a/src/toolkit/toolkit-deck-window.vala
+++ b/src/toolkit/toolkit-deck-window.vala
@@ -18,18 +18,21 @@ public class DeckWindow : Gtk.Popover {
      */
     public signal void dismiss(bool user_request, bool final);
     
-    private bool preserve_modal;
+    private bool preserve_mode;
+    private bool forcing_mode = false;
     
     public DeckWindow(Gtk.Widget rel_to, Gdk.Point? for_location, Deck? starter_deck) {
         Object (relative_to: rel_to);
         
-        preserve_modal = modal;
+        preserve_mode = modal;
         
         // treat "closed" signal as dismissal by user request
         closed.connect(() => {
             dismiss(true, true);
         });
         
+        notify["modal"].connect(on_modal_changed);
+        
         this.deck = starter_deck ?? new Deck();
         
         if (for_location != null) {
@@ -42,6 +45,10 @@ public class DeckWindow : Gtk.Popover {
         // those operations can prematurely close the Popover.  Catching these signals allow for
         // DeckWindow to go modeless during the operation and not close.  (RotatingButtonBox has a
         // similar issue.)
+        //
+        // TODO: This is fixed in GTK+ 3.13.6.  When 3.14 is baseline requirement, this code can
+        // be removed.
+        deck.notify["transition-running"].connect(on_transition_running_changed);
         deck.adding_removing_cards.connect(on_adding_removing_cards);
         deck.added_removed_cards.connect(on_added_removed_cards);
         deck.dismiss.connect(on_deck_dismissed);
@@ -55,16 +62,35 @@ public class DeckWindow : Gtk.Popover {
     }
     
     ~DeckWindow() {
+        deck.notify["transition-running"].disconnect(on_transition_running_changed);
+        deck.adding_removing_cards.disconnect(on_adding_removing_cards);
+        deck.added_removed_cards.disconnect(on_added_removed_cards);
         deck.dismiss.disconnect(on_deck_dismissed);
     }
     
+    // if the modal value changes, preserve it (unless it's changing because we're forcing it to
+    // go modal/modeless during transitions we're attempting to work around)
+    private void on_modal_changed() {
+        if (!forcing_mode)
+            preserve_mode = modal;
+    }
+    
+    private void force_mode(bool modal) {
+        forcing_mode = true;
+        this.modal = modal;
+        forcing_mode = false;
+    }
+    
+    private void on_transition_running_changed() {
+        force_mode(deck.transition_running ? false : preserve_mode);
+    }
+    
     private void on_adding_removing_cards() {
-        preserve_modal = modal;
-        modal = false;
+        force_mode(false);
     }
     
     private void on_added_removed_cards() {
-        modal = preserve_modal;
+        force_mode(preserve_mode);
     }
     
     private void on_deck_dismissed(bool user_request, bool final) {
diff --git a/src/toolkit/toolkit-rotating-button-box.vala b/src/toolkit/toolkit-rotating-button-box.vala
index 716463d..3cf1e9f 100644
--- a/src/toolkit/toolkit-rotating-button-box.vala
+++ b/src/toolkit/toolkit-rotating-button-box.vala
@@ -51,6 +51,9 @@ public class RotatingButtonBox : Gtk.Stack {
     // changes from one button box to another, triggering a situation in GtkWidget where the
     // Popover thinks it has lost focus ... this hacks around the problem by setting the popover
     // to modeless until the transition is complete
+    //
+    // TODO: This is fixed in GTK+ 3.13.6.  When 3.14 is baseline requirement, this code can
+    // be removed.
     private void on_transition_running() {
         if (transition_running && parent_popover == null) {
             // set to modeless to hack around problem


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]