Undo tab close #1668
base: master
Are you sure you want to change the base?
Undo tab close #1668
Conversation
de7f198
to
fac4114
Compare
I'm not sure the case change is the right thing to do.. |
src/fe-gtk/maingui.c
Outdated
{ | ||
_last_chan.server = sess->server; | ||
memcpy(_last_chan.channel, sess->channel, CHANLEN); | ||
memcpy(_last_chan.key, sess->channelkey, 64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g_strlcpy()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@TingPing I tried without success to match Ctrl+Shift+T. The event will always have the code of the uppercase letter, while the stored value will always be lowercase. What do you suggest? |
src/fe-gtk/maingui.c
Outdated
server *server; | ||
char channel[CHANLEN]; | ||
char key[64]; | ||
} _last_chan = { 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to use a GQueue
and store a few previous channels rather than a single one. Also don't start variables with _
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is what I intended to do, as I wrote in the description of the pull req. I need some advice of where it should be stored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not in the maingui. I don't really know the ideal spot but for example the lastact feature in fkeys.c
shoved a list in hexchat.c
, don't know how awful that location is too.
Will have to look into it, just doesn't sound correct, keys are case sensitive in my mind. |
(Note: Haven't actually tested your code, and don't have HC in front of me to test atm.) By ignoring the case completely, aren't you allowing the reverse to happen? i.e. CtrlShiftT will end up triggering shortcuts defined for CtrlT ? I think instead of ignoring completely you want to check if the keyval is uppercase, then see if there's a corresponding shortcut for Shiftcorresponding lowercase and trigger it, else ignore it. |
BTW I wrote this a while ago (just realized it doesn't handle keys :P): https://github.com/TingPing/plugins/blob/master/HexChat/undoclose.py |
@Arnavion I have tested it here, it will only work for Ctrl+Shift+T. I guess you wanted to check if this change would mess with new tab when user has Caps-lock turned on right? |
I have updated patch 2 implementing it as a GQueue as suggested. Still missing the right place to store the pointer to that queue. It will leak some memory when you close the application with channel information stored. |
Updated patch to to avoid adding channels to the queue while hexchat is quitting. |
Another update, use g_new/g_free instead of calloc/free. I am thinking about having this list global, in hexchat.c. Does this solution have a chance to go in? What about the fix for accelerators? |
New version of patch, the only difference is that we now clear closed channels when hexchat is quitting. I tried making the queue global, but did not like the result. Take a look https://gist.github.com/etrunko/a2dafb25c0ca49175c2b57b6f7011de9 I am much happier with current version, and I think it is ready for inclusion, comments appreciated. |
ping?! |
b0da17a
to
c639c4e
Compare
+1 |
Hi, another rebase of the code is up. Please take a look. It has been long time since any project developers replied to this pull request. I don't see any difficulties in having these patches merged, as the code is not intrusive, and I have been using it since I started working on it, but it is getting kind of painful to keep it out of the tree. As it happens with many other different open source projects out there, this kind of attitude unresponsiveness helps keeping people away from contributing and eventually using the project, unfortunately. |
Since you're disallowing reopening a channel tab if its server tab has been closed (since you check Note that TingPing's script that he linked above does allow it. I think doing it the same way is the better approach, i.e., store just network + channel + key in the queue, and connect to the network if an existing connection is unavailable. |
return; | ||
|
||
chan = g_queue_pop_head(&closed_channels); | ||
if (is_server (chan->server)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little suboptimal to silently ignore the undo command if this is false. The user will have no idea why nothing happened, and if they press it again expecting it didn't go through the first time, it might reopen a completely different tab.
Hello there, I had not touched this until recently when I upgraded my distro and noticed this feature did not work anymore. @Arnavion regarding scoping of the queue, I tried to do it with this new patch, but I lose the global behavior. https://gist.github.com/etrunko/c6a38e5b84227e06e092a16e7df5fe67 For instance if I have more than one server connected, and close a channel in one server, then focus on another channel of a different server, it will not restore the closed tab. I need to focus again on that other server and hit Ctrl+Shift+Tab to get that channel back open. My idea is to reopen the last channel closed, independently of which server is focused, so I think it makes more sense to keep it global, but if you don't like the static declaration, I could easily put it under another struct, not sure which one though. Because there is no such thing as a maingui struct, I thought it would not make sense to do it like that. Finally as for making this code work as the plugin one, I will take a look on the python bindings for the "command" function to see what it does. |
934e5e1
to
973ece0
Compare
Updated branch with a commit adding shortcut for tab closing. Recent versions have disabled it somehow. |
They can already run the command |
Well, for me it is something intrinsic to any GUI application which has tabs, such as web browsers, terminal emulators and chat applications. All of them support I wonder what really holds this change to be merged as is, and as I had already asked before, please provide me with pointers about what should be improved/changed to get this code in, so I can get rid of maintaining a separate branch and building manually. |
If a new accelerator that involves the shift + another key (such as "<Shift>A") is added, key press event will never match that accelerator, because the key value will be the one corresponding capital letter, while the stored value will be the lowercase letter, as a result of the call to gkt_accelerator_parse(). Signed-off-by: Eduardo Lima (Etrunko) <[email protected]>
Signed-off-by: Eduardo Lima (Etrunko) <[email protected]>
In recent versions the Ctrl+w shortcut for closing tabs has stopped working, probably due to some changes in Gtk+ (currently running fedora 26). So we add the shortcut back again. Signed-off-by: Eduardo Lima (Etrunko) <[email protected]>
Signed-off-by: Eduardo Lima (Etrunko) <[email protected]>
I always find it annoying when I close a channel tab by mistake and then have to join it again manually. Especially when the channel you just closed has long or weird name.
This request implements the action of undo tab close, as found in most web browsers today, by pressing CTRL+Shift+T.
The first patch fixes a small issue with key event handling. I think no one else had this problem before because there are no accelerators with the shift key.
The second one implements the feature for Gtk gui and it is a _draft_. The goal is to have a stack of recently closed channels, and not be restricted by only one channel. I would appreciate some advise of the best place to store such stack, if in a global variable or as a member of a data struct.
Comments appreciated.