> it should use signals rather than riddling the code with additional calls 
> every time a document is opened. Something like :document-new and 
> :document-open

My concern was that: having the sort function called from a one-call-per-file 
function means that the sort function would be called everytime a file is 
opened, even in a batch operation when it should only be called once.  But your 
suggestion made me examine the `document_open_file()` function again, and I got 
an idea after I checked the call to `g_idle_add()`.  It turns out we could have 
a function that connects to "document-open", and use that function to connect 
another function to the "idle" event through `g_idle_add()`.  This other 
function which would initiate the sorting of tabs would only be connected to 
the event once in every session.

I chose not to also connect to "document-new" as it would affect the function 
of `Next to current` or `check_tab_beside`.

> should use Stash for new settings!

I just followed how other things were arranged, but I'll see how that can 
necessarily be done.

> why not a plugin?

I'm still a beginner when it comes to hacking the UI of Geany, and I can only 
guess if something like this can be turned into a plugin unless I already see 
the working product.   Directly modifying Geany first for a feature like this 
was easier.   I also only started writing this casually.   I never expected it 
to become complex, although it's already starting to become more simplified.

As I examined it right now, `show_tab_bar_popup_menu()` doesn't even create any 
hooks or signals that would allow plugins to create their own menu items.   I 
can consider converting this to a plugin if it's necessary, but personally I'd 
prefer that it becomes part of Geany and not a plugin, since it directly 
affects the main behavior of the UI, and not just something that alters the 
content of the document, or adds another tab in the sidebar.  If this is 
created as a plugin, the plugin would possibly require to be highly adaptive to 
changes in the UI code.

> more generically, why? I mean, what is the motivation behind sorting the tabs 
> by file name, what problem does it solve?

It doesn't exactly solve anything, but just like many other features in Geany 
it makes using the editor more convenient.  It is convenient to have the tabs 
arranged properly.  One thing: it makes using the shortcut keys when moving 
from one document to another less confusing.  You get to have an idea what 
follows another filename even if the current tab is in the end of the screen.  
You know that pressing a single key or twice would make you get to other 
document you wanted.

Sometimes when the documents list is opened, you would expect that the one that 
follows a file would be the one that's next in the list, but when the tabs are 
not arranged like how the documents are arranged in the list, using the 
shortcut key would make you jump to another file instead.  It's confusing to 
see the selected file suddenly jump from top to bottom or the other way around 
in the documents list.

Grouping is another thing.  You would want to have x.c and x.h adjacent to each 
other, so that you could easily switch to them either with a mouse or with a 
shortcut key.

> so, would be a once-only switch to the Documents sidebar, or a contextual 
> popup showing the same as the Documents popup be better?

That wouldn't help anything about the notebook tabs which we use.  There's a 
reason why people keep it visible and use it to traverse documents, even if the 
documents list is already there.


---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1144#issuecomment-234739288

Reply via email to