Tab Mix Plus

Official Home of TMP
It is currently Thu May 23, 2013 9:38 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Fri Jul 04, 2008 8:06 pm 
For me all this hassle with the "warn me when closing multiple tabs" issue would be solved if the prompt window for saving or not saving a session in TabMixPlus had a "cancel" button.

If I accidentally close my window with multiple tabs a window pops up asking me if i want to save or not my session (you have to check "ask before saving" in the session tab in TMP options to see this prompt window by the way).

If this little window had a cancel button i would just click "cancel" and continue with my browsing. This would become my new "warn me when closing multiple tabs" option, but there's no cancel button, so whatever I do the browser closes, and then I have to go to session manager and restore last session with whatever number of tabs I had, and that's what I don't want to do.

So for now I'm using the firefox's built in session restore but i would very much prefer to use TMP's session manager.

Anyone know if there's a way to add a "cancel" option to TMP's "save or not save session" prompt window?

And if not where can i suggest this feature in future releases?


Top
  
 
 Post subject:
PostPosted: Fri Jul 04, 2008 8:19 pm 
rony_o wrote:
And if not where can i suggest this feature in future releases?


I've found out where thank you.


Top
  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 1:52 pm 
I found out workaround this bug. It' is TMP problem. Somehow after you deselect in options "Use firefox built in session restore feature" it changes in about:config browser.warnOnQuit to false and it doesn't allow to change for some reason.

So enable TMP session manager with bell and whistles. When disable TMP and restart FF3. Go to about:config and change browser.warnOnQuit to true. Exit about.config. Go to addons and enable TMP and restart FF3. Everything works as intended. I'm not sure why TMP does this to browser.warnOnQuit


Top
  
 
PostPosted: Thu Jul 17, 2008 3:29 am 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
After much consternation and debugging I think I have come up with a code fix for the issues we are having with not being warned on closing windows with multiple tabs open. As it has been noted, when you have multiple windows open it works as it used to but this is due to the window merging code being a separate implementation of the "Warn on Close" dialog. There has been a major design change by the Mozilla team, namely that with the built-in session restore enabled, when closing a window with multiple tabs, there will be no warning by default because the session is assumed to be saved. In light of this they have modified the structure of how things are done when shutting down the browser. This prompted a code change in TMP. onemen et. al. did a great job of reimplementing the previous functionality with one small hitch, which I will show one way of correcting. As has been previously mentioned in this thread, one workaround is to disable TMP, enable "browser.warnOnQuit" and "browser.warnOnRestart" in about:config, and then reenable TMP, but there is actually a good reason why these are disabled by TMP when enabling TMP Session Restore, namely that it fully disables the mozilla session restore so there are no conflicts.

Without further ado, here are my instructions for fixing the current dev build 0.3.6.1.080406:

original Line 227-246 of the file tabmixplus.jar\content\tabmixplus\minit\tablib.js
Code:
function TMP_closeWindow(){
  var _close = closeWindow(false,
    function () {
      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;
    });

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

}

}


modified line 227-249
Code:
function TMP_closeWindow(){
   
  var _close = warnOnClose();

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

}

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;
}

}


The best technical explanation I can come up with for why this fix works is that for whatever reason, passing the second parameter to the closeWindow() function as an anonymous function instead of a named one doesn't work.

edit: i have made the further modification of bypassing the built in FF function closewindow as it allows no way for a prompting function when there is only one window open.



Also, the easiest way I have found to modify the file without having to uncompress/recompress the jar file is the following:

1) Install the free trial of WinRAR (http://www.rarlabs.com/download.htm)

2) Go into Options, Settings, Viewer and set the following two items:
Image


3) open the tabmixplus.jar file that can be found in the extensions folder of your profile e.g. on Windows XP this would be :

C:\Documents and Settings\<Username>\Application Data\Mozilla\Firefox\Profiles\<Profile>\extensions\<Extension>\chrome\tabmixplus.jar

4) navigate to the file tabmixplus.jar\content\tabmixplus\minit\tablib.js and double click it

5) this should open the file in Windows Notepad

6) Just do a search for "function TMP_closeWindow(){" and carefully replace the above lines with the ones provided.

7) Go to File, Save and then you should get a dialog asking if you want to update the file in the archive with WinRAR

8) Just say yes and you're done


PS - oneman, i've noticed a slight typo in my digging as well that would prevent someone from disabling Warn on Close in the dialog for Window Merging:

line 252 in tabmixplus.jar\content\tabmixplus\flst\flst.js
Code:
          gPref.setBoolPref("exetnsions.tabmix.warnOnClose", false);


Last edited by clawfinger on Fri Jul 18, 2008 1:47 am, edited 5 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 17, 2008 5:13 am 
I've tried and now i get the TMP warning.
But Cancel doesn't work here. Firefox gets closed anyway.
And if browser.tabs.warnOnClose was set to true, I get a second warning. So that should be set to false, when the cancel issue is solved.


Top
  
 
 Post subject:
PostPosted: Thu Jul 17, 2008 6:20 pm 
Damn it, this bug wasn't fixed in FF 3.0.1 :(


Top
  
 
 Post subject:
PostPosted: Thu Jul 17, 2008 9:45 pm 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
Good catch on the cancel button. I am looking into a fix for the custom dialog implemented in TMP. The second dialog is most like because you still have "browser.warnOnQuit" and/or "browser.warnOnRestart" set to true. This will cause the Firefox built in session restore to kick in and the "Do you want Firefox to save your tabs for the next time it starts?" dialog to show with the "Save and Quit", "Quit" and "Cancel" buttons. This is why enabling the TMP Session Restore disables those two settings. The "browser.tabs.warnOnClose" is actually what is used to determine whether or not the custom TMP dialog is shown and should be left at true if you want to be warned (this can also be toggled via the Tabs settings panel option "warn me when closing multiple tabs."

Unfortunately, per my previous explanation, I don't think this will be "fixed" in and future version of FF as they don't consider anything broken.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 12:14 am 
clawfinger wrote:
Okay, I figure out the issue on the cancel button not working. It was a minor error on my part. I have fixed the original code that I posted. For those of you who have already made the modification, here is the quick fix:

modified line 227-229
Code:
function TMP_closeWindow(){
   
  var _close = closeWindow(false, warnOnClose);


Basically I was passing the "warnOnClose" function as it's result instead of as a function.

It doesn't work at all here with this fix


Top
  
 
 Post subject: Quick Fix
PostPosted: Fri Jul 18, 2008 12:28 am 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
Okay, I figure out the issue on the cancel button not working. It was a minor error on my part. I have fixed the original code that I posted. For those of you who have already made the modification, here is the quick fix:

modified line 229
Code:
var _close = closeWindow(false, warnOnClose);

Basically I was passing the "warnOnClose" function as it's result instead of as a function.

edit: perhaps I wasn't clear this is a modification to my original code, you can check above for the complete change, which now includes the fix for cancel not working, basically to fix the original thing that I posted if you had already edited it in, you need to make this one addition modification to the code.

edit2: i see what you mean now, once I removed the debugging code it stopped working, please hold for update :oops:

edit3: it seems the last fix I gave only applies when there is more than one window open, it seems those FF devs really didn't want any warning going up if there was only one window open even with multiple tabs.

edit4: okay, it seems there is no way around just completely bypassing the closewindow function of the original FF code as it will only check and execute the passed function if there is more than one window open. I have modified the original posting with the final code and have tried to test all possible configurations (this is all short of overloading/rewriting several other core functions that would most like introduce other incompatibilities).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 2:37 am 
Does that mean we can go back to the original code? :-(


Top
  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 6:17 am 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
no sorry, instead of reposting yet another change I made the final changed to the original posting. Basically it is the same line that needs to be modified once more:

modified line 229:

Code:
var _close = warnOnClose();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 7:29 am 
If I understand you, that would be your first code change with not working Cancel. Kind of useless warning then, because I can't avoid closing Firefox by mistake.


Top
  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 9:13 am 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
I modified the original code I posted, specifically that line that I first modified to try and fix the cancel, yet again to "var _close = warnOnClose();" which both warns and correctly cancels when you hit cancel. I was trying to avoid confusion by posting multiple versions of the same code.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 9:59 am 
clawfinger wrote:
I modified the original code I posted, specifically that line that I first modified to try and fix the cancel, yet again to "var _close = warnOnClose();" which both warns and correctly cancels when you hit cancel. I was trying to avoid confusion by posting multiple versions of the same code.

This works perfectly, thank you very much. Even the second warning mentioned above doesn't come up when I hit Close tab. :-D


Top
  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 12:35 pm 
Offline

Joined: Tue May 01, 2007 12:17 pm
Posts: 22
I wonder why there isn't a dev build released with a fix for this bug. It annoyed me for months. Previously dev builds were quite frequent.


Top
 Profile  
 
 Post subject: Fix works like a charm!
PostPosted: Sat Jul 19, 2008 4:09 pm 
Hi, I have FF 3.0.1 and Tab Mix Plus 0.3.6.1.080416 and I followed the instructions of the above post (with the WinRAR trick) and now the warning box when multiple tabs are open works like a charm! And as the above poster mentioned, we don't even need to have the 'When browser exits : Ask Before Saving' option chosen to get the multiple tabs open warning...

Great job! Thanks so much! Hopefully this will be included in the next build of Tab Mix Plus...


Top
  
 
 Post subject:
PostPosted: Sun Jul 20, 2008 2:13 pm 
clawfinger wrote:
I modified the original code I posted, specifically that line that I first modified to try and fix the cancel, yet again to "var _close = warnOnClose();" which both warns and correctly cancels when you hit cancel. I was trying to avoid confusion by posting multiple versions of the same code.
Could you post this fix/patch here? =
https://bugzilla.mozilla.org/show_bug.cgi?id=419009


Top
  
 
 Post subject: Conflict with FoxMarks
PostPosted: Tue Jul 22, 2008 4:40 am 
I replaced the code in tabmixplus.jar\content\tabmixplus\minit\tablib.js as described by clawfinger up above and it worked great:

http://tmp.garyr.net/forum/viewtopic.ph ... t=20#26832

However...

Before I replaced the TMP code above, Foxmarks "Sync on Shutdown" works when bookmarks have been changed.

After I applied the code change to tablib.js, I get the warning when multiple tabs are open and then if I click on "Close tabs", the browser SKIPS the Foxmark sync and closes. Any ideas on getting Foxmarks to Sync in that scenario?


Top
  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 3:05 pm 
Offline
Admin
User avatar

Joined: Thu Aug 04, 2005 1:12 pm
Posts: 7292
the fix from above don't do good work

it bypass very important Firefox function closeWindow

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 8:29 pm 
Offline

Joined: Mon Jan 16, 2006 8:02 pm
Posts: 10
re: mahou

The changes that I made were to the TMP code and not the FF3 code base. It is painfully apparent that this new behavior was indeed intended by the FF develops by looking at what they specifically changed in the code as well as the comments in the afore mentioned FF Bug.



re: onemen

I went through several iterations of my code change, and while it is a hack at best, I am not sure what is so important in calling the closewindow function here that bypassing it is so bad. As well you know but for others benefit, in both the FF2 and FF3 code it basically just counts the number of open windows and if told to do so closes them:

FF 2.0 closewindow() function:
Code:
function closeWindow(aClose)
{
  var windowCount = 0;
   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                      .getService(Components.interfaces.nsIWindowMediator);
  var e = wm.getEnumerator(null);
 
  while (e.hasMoreElements()) {
    var w = e.getNext();
    if (++windowCount == 2)
      break;
  }

# Closing the last window doesn't quit the application on OS X.
#ifndef XP_MACOSX
  // If we're down to the last window and someone tries to shut down, check to make sure we can!
  if (windowCount == 1 && !canQuitApplication())
    return false;
#endif

  if (aClose)   
    window.close();
 
  return true;
}


The change that was made in FF3 was the addition of a passed function (aPromptFunction) which only gets executed when multiple windows are open when the command is called:


FF 3.0 closewindow() function:
Code:
function closeWindow(aClose, aPromptFunction)
{
  var windowCount = 0;
  var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                     .getService(Components.interfaces.nsIWindowMediator);
  var e = wm.getEnumerator(null);
 
  while (e.hasMoreElements()) {
    var w = e.getNext();
    if (++windowCount == 2)
      break;
  }

# Closing the last window doesn't quit the application on OS X.
#ifndef XP_MACOSX
  // If we're down to the last window and someone tries to shut down, check to make sure we can!
  if (windowCount == 1 && !canQuitApplication())
    return false;
  else if (windowCount != 1)
#endif
    if (typeof(aPromptFunction) == "function" && !aPromptFunction())
      return false;

  if (aClose)   
    window.close();
 
  return true;
}


The way the TMP code was original written it passed the function alright but this function only got executed when multiple windows were opened per the developer change in FF3. The desired behavior on my part as well as others it seems was the FF2 behavior of being warned when multiple tabs were open even if there was only one window open. If the FF3 behavior is desired one only has to disable "Warn me when closing multiple tabs." This is where I can see your concern for completely bypassing the function as you won't even get a warning when you have multiple windows opened with at least one with multiple tabs. But this is cleared up by disabling TMP Session Store altogether as it will return functionality to FF3 defaults. All in all, I think the FF developers' code change is somewhat arbitrary. From what I read the original intention was, "if we are going to save the tabs anyways, no sense in warning the user," but why warn when multiple windows are open then?.....After thinking about it for a while, I suppose it warns when multiple windows are open because only the first window opened will get saved as without TMP there is no functionality for saving multiple windows for a session. The main reason I chose to bypass the closewindow function was that I wanted the chance to throw a warning before getting the window closed and as it stood the closewindow function only provided that functionality of there was moer than one window open. All this being said, I will try to come up with a more elegant implementation that does not complete omit the closewindow function.

-clawfinger


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

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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