Skip to content

Conversation

techee
Copy link
Member

@techee techee commented Aug 14, 2025

This PR enables DnD for sidebar tabs so the order of tabs can be customized by users. The order is saved into a config file and restored after Geany relaunch. Eventually, I'd like to something like this for the messages window too, see below.

I tried to be careful and eliminate all uses of stored indices referring to individual tabs in Geany (basically affecting only the Symbols and Documents tabs). I did the same for geany-plugins (I'll open a separate PR for this) which most of the time did the right thing already.

The current limitation is that tab order has to be remembered and saved somehow - the only "unique" identifier of a tab I could think of is the tab name so the sequence of tab names determines the order of tabs. This works most of the time but when plugins use identical tab names (the biggest offenders are various project management plugins adding the "Project" tab), the order isn't deterministic for these.

If we wanted, we could solve this problem by deprecating direct use of geany_data->main_widgets->sidebar_notebook which plugins could access through a new API which could look something like this:

ui_add_tab(const gchar *unique_id, gint placement, GtkWidget *widget);
ui_remove_tab(GtkWidget *widget);
ui_make_tab_active(GtkWidget *widget);

Such an API would cover all current uses present inside geany-plugins from what I have seen. Plugins would be responsible for providing a sufficiently unique string unique_id that would be used for determining the order of the tabs. The idea behind the placement argument is that I'd like to do something similar for the messages window as well and plugins could determine the initial placement here (SIDEBAR, MSGWINDOW). In addition, I've been thinking it would even be possible for users to drag and drop tabs between the sidebar window and the messages window (should work using gtk_notebook_set_group_name()) so the sidebar and the messages window would become interchangeable for users.

Alternatively, we could just leave it as it is and just discourage plugin developers from directly using tab indices.

Thoughts?

techee added 7 commits August 14, 2025 19:40
This won't work if sidebar pages are made reorderable.
This is a preparation to remove gtk_notebook_get_nth_page() which
refer to hard-coded indices of Symbols and Documents tabs.
When made reorderable, these won't be valid any more.
Unfortunately, the initialization sequence inside libmain:

sidebar_init();
load_settings();	/* load keyfile */

has to be preserved because load_settings() accesses sidebar tabs which
have to be initialized before. But we can do the tab reordering only
after we load settings from the config file so it has to be done
manually after load_settings();
@techee
Copy link
Member Author

techee commented Aug 14, 2025

For the g-p changes, see geany/geany-plugins#1505.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant