Tab Mix Plus

Official Home of TMP
It is currently Mon May 20, 2013 11:54 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Thu Jul 24, 2008 8:52 pm 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
How's this, it still calls closewindow() but basically just ignores the result and uses the result of our custom warnOnClose() function instead to return to WindowIsClosing(). It's sort of redundant but I can understand the desire to keep the original call for future compatibility etc.:

Code:
function TMP_closeWindow(){
   
  var _close = closeWindow(false);
 
  var _canClose = warnOnClose();

  if (_canClose) {
     var isRestartApp = TMP_closeWindow.caller.caller.name == "restartApp";
     SessionManager.deinit(numberOfWindows() == 1, !isRestartApp);
  }
  return _canClose;
 
}

function warnOnClose(){
  var pref = "extensions.tabmix.warnAboutClosingTabs.timeout";
  var startTime = new Date().valueOf();
  var oldTime = gPref.prefHasUserValue(pref) ? gPref.getCharPref(pref) : 0;
  var _canClose = getBrowser().warnAboutClosingTabs("All_onExit");
  gPref.setCharPref(pref, oldTime*1 + (new Date().valueOf() - startTime));
  return _canClose;
}

}


edit: on a related note, I can't seem to get the TMP_closeWindow.caller.caller.name == "restartApp" to trigger through causing a restart (enabling/disabling an extension is the only way I can think of off hand)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 4:44 am 
Offline
Admin
User avatar

Joined: Thu Aug 04, 2005 1:12 pm
Posts: 7288
i'm planing a new code that add confirm alet for closing tabs on last window
even if user save the session.

just for now try this
Code:
function TMP_closeWindow(){
   
  if (!closeWindow(false))
     return false;
 
  var pref = "extensions.tabmix.warnAboutClosingTabs.timeout";
  var startTime = new Date().valueOf();
  var oldTime = gPref.prefHasUserValue(pref) ? gPref.getCharPref(pref) : 0;
  var _canClose = getBrowser().warnAboutClosingTabs("All_onExit");
  gPref.setCharPref(pref, oldTime*1 + (new Date().valueOf() - startTime));

  if (_canClose) {
     var isRestartApp = TMP_closeWindow.caller.caller.name == "restartApp";
     SessionManager.deinit(numberOfWindows() == 1, !isRestartApp);
  }
  return _canClose;
 
}


_________________
Tab Mix Plus 0.4.1.0
latest Dev-Build
Forum RSS, Troubleshooting


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 7:12 am 
So i've finally three hacked builds with warn working :-)
And we'll have a working build.
Thank you both.


Top
  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 9:51 am 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
Nicely done onemen,

This is indeed why you write the extension, and I just hack together something quick and dirty to try and get it to do what I want ;-)/

-clawfinger

PS- for those of you following this thread and interested in applying this fix, make sure you keep the second '}' after the code onemen so graciously has given us as the final short term fix.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 10:52 am 
Offline
Admin
User avatar

Joined: Thu Aug 04, 2005 1:12 pm
Posts: 7288
more updated version of the function

Code:
function TMP_closeWindow(){
  if (!closeWindow(false))
     return false;

  var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
           getService(Ci.nsIWindowMediator);
  var windowcount = 0;
  var pagecount = 0;
  var browserEnum = wm.getEnumerator("navigator:browser");
  while (browserEnum.hasMoreElements()) {
     windowcount++;

     var browser = browserEnum.getNext();
     var tabbrowser = browser.document.getElementById("content");
     if (tabbrowser)
        pagecount += tabbrowser.browsers.length;
  }

  var quitType = arguments.callee.caller.caller.name;
  var showPrompt = true;
  if (/^Mac/.test(navigator.platform) || pagecount < 2)
     showPrompt = false;
  else {
     try {
       var sessionWillBeSaved = gPref.getIntPref("browser.startup.page") == 3 ||
                                gPref.getBoolPref("browser.sessionstore.resume_session_once");
       if (sessionWillBeSaved || !gPref.getBoolPref("browser.warnOnQuit"))
          showPrompt = false;
       // its can't be restart here, restart don't call closeWindow
       else if (quitType == "restart")
          showPrompt = gPref.getBoolPref("browser.warnOnRestart");
       else
          showPrompt = gPref.getBoolPref("browser.tabs.warnOnClose");
     } catch (ex) {}
  }

  var _canClose = true;
  // we only show warnAboutClose if firefox didn't do it already
  // if showPrompt is true then prompt was shown by firefox code from BrowserGlue.prototype._onQuitRequest
  if (!showPrompt) {
      var pref = "extensions.tabmix.warnAboutClosingTabs.timeout";
      var startTime = new Date().valueOf();
      var oldTime = gPref.prefHasUserValue(pref) ? gPref.getCharPref(pref) : 0;
      _canClose = getBrowser().warnAboutClosingTabs("All_onExit");
      gPref.setCharPref(pref, oldTime*1 + (new Date().valueOf() - startTime));
  }

  if (_canClose) {
     var isRestartApp = quitType == "restartApp";
     SessionManager.deinit(numberOfWindows() == 1, !isRestartApp);
  }
  return _canClose;

}


there is still no confirm dialog on File > Exit or when using restart, but i'm not think that we need the confirm dialog on those cases.

maybe i will add a new pref so user can choose if they like to see this dialog when closing the last window when session will be save ?

_________________
Tab Mix Plus 0.4.1.0
latest Dev-Build
Forum RSS, Troubleshooting


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 29, 2008 5:18 am 
Warn works now with dev-build 0.3.7pre.080728 :-)


Top
  
 
 Post subject:
PostPosted: Tue Jul 29, 2008 10:22 pm 
Yeah the new dev-build took care of this issue, great developer team, great extension...


Top
  
 
PostPosted: Sat Sep 06, 2008 9:40 pm 
I just wanted to say that there is still no confirmation when the quit shortcut, cmd-q, is used to close firefox 3 on OS X. I do however get the confirmation popup when i try closing via the red close on the upper right of the window.


Top
  
 
PostPosted: Sun Sep 07, 2008 2:02 am 
Offline
Admin
User avatar

Joined: Thu Aug 04, 2005 1:12 pm
Posts: 7288
Anonymous wrote:
I just wanted to say that there is still no confirmation when the quit shortcut, cmd-q, is used to close firefox 3 on OS X. I do however get the confirmation popup when i try closing via the red close on the upper right of the window.


this is by design.
when the user quit the application we don't want to ask for confirmation on each window

_________________
Tab Mix Plus 0.4.1.0
latest Dev-Build
Forum RSS, Troubleshooting


Top
 Profile  
 
PostPosted: Sun Sep 07, 2008 2:56 pm 
onemen wrote:
Anonymous wrote:
I just wanted to say that there is still no confirmation when the quit shortcut, cmd-q, is used to close firefox 3 on OS X. I do however get the confirmation popup when i try closing via the red close on the upper right of the window.


this is by design.
when the user quit the application we don't want to ask for confirmation on each window


I actually liked having a confirmation when using the quit shortcut/hotkey as sometimes I'll press it accidentally when switching between apps using Cmd-tabbing or if intended to hit Cmd-W but hit Cmd-Q instead. As I'm primarily a notebook user, I prefer and am actually more efficient using the keyboard and shortcuts than using trackpad/mouse. In addition, due to the nature of OSX, firefox isn't actually closed unless one uses the quit command as closing the window via the red close button only closes the browser window, but the browser itself is still running.

I also tend to keep multiple windows open and would rather be warned (or have the option to be warned) if they are going to be closed.


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group