Skip to content

Add the key "sidebarwidth" (or something similar) to the Preferences of Preview #101

@ralf3u

Description

@ralf3u

The value of the key sidebarwidth
The value of the key sidebarwidth is a number, like 80.

The unit of the value
First I was for percentage as unit, later I was for pixel as unit because it is more accurate (the numbers of width are in general bigger than 100), and finally today I'm again for percentage as unit. The reason for the percentage as unit: If one want to change many times the position of the splitter between for example 20% sidebar width and 70% sidebar width, then with the shortcut "Open sidebar width prompt" it is easier and faster to type 20 and 70 (for percentage) than 1600 and 600 (for pixel). So, till this end of this report I use the percentage as unit of the value of the key sidebarwidth.

The meaning of the value of the key sidebarwidth
The number is the percentage of the sidebar width compared to the whole width. The whole width is editor width plus sidebar width, what makes 100%. So, if for example the value of the sidebarwidth is 25, it means 75% editor width while sidebar width is 25%.

Default of the value of the key sidebarwidth
After the installation of the plugin Preview, the default value of the key sidebarwidth should be maybe around 30. So, this would mean 30% sidebar width and 70% editor width.

Usage of the value of the key sidebarwidth
The value of the key sidebarwith is used ONLY for the three shortcuts "Toggle Sidebar with sidebarwidth", "Toggle sidebar visibility and focus with sidebarwidth", and "Toggle between editor&sidebar and sidebar with sidebarwidth". So, the value of the key sidebarwidth will not be used for the shortcut "Toggle between editor and sidebar with sidebarwidth" even if the name ends with "with sidebarwidth" – the name of that shortcut is for showing the users that the four shortcuts should be used as group.

Content of the tooltip of the key sidebarwidth
Type a number between 0 and 100. The number is the percentage of the sidebar width compared to the whole width – the whole width is editor width plus sidebar width, what makes 100%. The value of the key sidebarwith is used only for the three shortcuts "Toggle Sidebar with sidebarwidth", "Toggle sidebar visibility and focus with sidebarwidth", and "Toggle between editor&sidebar and sidebar with sidebarwidth".

Three ways of changing the value of the key sidebarwidth
Users can change the value of the key sidebarwidth through

  1. the Preferences of the plugin Preview,
  2. the context-menu by selecting the item "Sidebar width..." (see issue number 94), and
  3. the shortcut "Open sidebar width prompt" (see issue number 98).

Changing the position of the splitter with the mouse
If users are changing the position of the splitter with the mouse, then it has no influence on the value of the key sidebarwidth.

List of shortcuts names that could be part of Preview

  • Toggle sidebar visibility and focus (the shortcut already exist in the current version of Preview)
  • Toggle Sidebar with sidebarwidth
  • Toggle sidebar visibility and focus with sidebarwidth
  • Toggle between editor&sidebar and sidebar with sidebarwidth
  • Toggle between editor and sidebar with sidebarwidth

Reason of the existence of the shortcut "Toggle sidebar visibility and focus"
If a user is changing the position of the splitter with the mouse for exapmle 20% sidebbar width to 65% sidebar width, and then if the shortcut "Toggle sidebar visibility and focus" is pressed 2x, the splitter will appear with 65% sidebar width.
If a user is changing the position of the splitter with the mouse, and then if the shortcut "Toggle sidebar visibility and focus with sidebarwidth" is pressed 2x, the splitter will appear with the value of the key sidebarwidth (so, if the value of the key sidebarwidth is 22, then the splitter will appear with 22% sidebar width).
Same situation for the Geany-shortcut "Toggle Sidebar" vs. "Toggle Sidebar with sidebarwidth". So, users who like to change the position of the splitter with the mouse can still use the Geany-shortcut "Toggle Sidebar" and the Preview-shortcut "Toggle sidebar visibility and focus". Users who want to use the two shortcuts "Toggle between editor&sidebar and sidebar with sidebarwidth" and "Toggle between editor and sidebar with sidebarwidth" should use the four shortcuts that ends with "with sidebarwidth".

Converting the value of the key sidebarwidth
The value of the key sidebarwidth must be converted to pixel width of the editor because of the following code:

gtk_paned_set_position(GTK_PANED(paned), y))

y= pixel width of the editor. To get this number this need to be done:
a= 100 minus value of the key sidebarwidth. The result is editor width in percentage.
To convert the editor width in percentage to editor width in pixel:
y= (a /100) * (whole width in pixel, so editor width in pixel + sidebar width in pixel).
For more information, see "A concept of IF-conditions for the four shortcuts" in #88 (comment).

Version
Preview 0.2.4+r47.g4c5faec

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions