Zim

[FEATURE Req.] pyroom-like fullscreen mode

Bug #1001137 reported by Andreas Hilboll
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Zim
Fix Released
Undecided
Unassigned

Bug Description

PyRoom (http://pyroom.org/) is a nice full screen editor, e.g. there's nothing in the UI except for the text being written, with a nice and large margin around it. The keyword is "distraction-free editor" (http://en.wikipedia.org/wiki/Distraction-free_editor):

   In computing, a full-screen writing program[1] or distraction-free editor[2][3][4] is a text editor that occupies the full display with the purpose of isolating the writer from the operating system (OS) and other applications. In this way one should be able to focus on the writing alone, with no distractions from the OS and a cluttered interface.[5][6][2][7] Often distraction-free editors feature a dark background and a text field, which is only about one third the width of the screen. The font is then in a brighter colour like green. However, most distraction-free editors include customisable user interfaces.[8] Some editors support rich text editing.

It would love it if zim would get a full-screen mode like this, with configurable colors/fonts (sepearetely configurable from the 'regular' editor appearance).

I'd be willing to try implementig it. I do know Python, but I've never done UI programming in Python before ...

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 1001137] [NEW] [FEATURE Req.] pyroom-like fullscreen mode

See this discussion: https://lists.launchpad.net/zim-wiki/msg01100.html

Quick fix: just go to "Tools -> Custom" and put pyroom there. That way
you can edit any zim page in pyroom.

Would welcome a plugin for this. Basically showing pyroom + zim
navigation control. But for me personally this low prio. Definitely
need a good mock-up that describes look and controls.

-- Jaap

Revision history for this message
DavidM (milarupa) wrote :

I would also like a distraction-free writing option within Zim. A couple of tweaks would be enough for me:

1. Hide the toolbar in fullscreen.

2. Don't use the whole width of the screen in fullscreen. In current screens, that results in very wide lines. Better use the central part of the screen, as most distraction-free editors do.

Other improvements could be added later, but these two would be good enough for a starter.

Currently I have a custom button to open the current Zim page in Focuswriter (gottcode.org/focuswriter). I think it would be a good look to inspire from (toolbar appears on moving mouse to the top of the screen).

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 1001137] Re: [FEATURE Req.] pyroom-like fullscreen mode

On Fri, Nov 30, 2012 at 2:26 PM, DavidM <email address hidden> wrote:

> I would also like a distraction-free writing option within Zim. A couple
> of tweaks would be enough for me:
>
> 1. Hide the toolbar in fullscreen.
>

Go to fullscreen and de-select "View" -> "Toolbar". Zim should remember
settings for normal and fullscreen usages separately. (Just keep in mind
fullscreen is not the same as maximize.)

You can even turn off the menu bar in fullscreen by editing the config file
".zim/state.conf" in the notebook. But I've hidden that as it didn't same a
sane option to expose by default.

> 2. Don't use the whole width of the screen in fullscreen. In current
> screens, that results in very wide lines. Better use the central part of
> the screen, as most distraction-free editors do.
>

What would be reasonable default values for the page width and height?

>
> Other improvements could be added later, but these two would be good
> enough for a starter.
>
> Currently I have a custom button to open the current Zim page in
> Focuswriter (gottcode.org/focuswriter). I think it would be a good look
> to inspire from (toolbar appears on moving mouse to the top of the
> screen).
>

Revision history for this message
DavidM (milarupa) wrote :

Thanks! Actually I had already hidden the toolbar (that's what happens when you report on an application without having a copy of the application itself in front of you). So the menubar would be the only thing left to hide. I think that it's really important to distraction-free environments to hide everything. A simple X button to leave fullscreen when you hover top right corner would be enough for me anyway, or even ESC key (but that may have a problem of discoverability).

Regarding writing area width: fullscreen editors usually let you customize that, but I think it would be OK to leave that for a second round of improvements. I guess that the default width would depend a lot on screen resolution and aspect ratio. One half of the screen would look great in a widescreen monitor, but not that good on a 4:3 one. My taste is 850 px, a bit wider than default in Focuswriter.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Implementation notes:
* Can use TextView.set_border_window_size() to set left, right, top and
bottom margins for pageview
* Would need to hook size_allocate to adjust margins to enforce max size
and try to keep position stable
* At least on windows, need better detection when full screen is exited and
reverse to normal state - is there a signal for window size changed ?

(Check pyroom code for example how to get screensize)

Behavior:
* Need preference for maximum page size as percentage of screen (not widget
allocation)
* Keep widget near center of screen, but allow side panes to "bump" it
towards one side

Bonus:
* Also apply pyroom themes to zim widgets

Open:
* max size could be enforced regardless of window size, or only in
fullscreen mode
   - if always, default would be 100%
   - if only in fullscreen maybe default to e.g. 80% in Y and 60% in X
* can we revert back to default theme after havinf applied custom colors ?
   - if not, maybe put it in a plugin and document restart to revert
* if colors are changed, do it always or only for fullscreen ?
   - depends on whether we can revert, otherwise switching between states
not possible

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Attached a plugin that
1/ allows hiding the menubar
2/ sets a maximum width for the pageview

Please test and let me know if it works for you in the next week - if so I may still put it in the upcoming release.

To test it, just drop this file in the source folder under zim/plugins or install in ~/.local/lib/python2.7/site-packages/zim/plugins. Then go to the preferences dialog to enable it.

For usage following keyboard navigation is useful:
<F11> to toggle fullscreen mode
<F9> to toggle side pane visibility
Shift<f9> to show all side panes
<Ctrl><Space> optionally to temporarily access the index and hide it again

Of course all other keybindings keep working, but less discoverable when the menubar is hidden.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Btw. also working on color scheme for at least the pageview (coloring side panes etc would be nice but harder). Have it more or less working, but needs more polish to make it switchable between window states.

Revision history for this message
Vlastimil Ott (vlastimil-e-ott) wrote :

You made my day! :-) Thank you.

It works except the main menu - still stays on the screen (yes, checkbox for hiding activated). No errors reported with Zim -D

DEBUG: Action: toggle_fullscreen
DEBUG: Fullscreen changed: True
DEBUG: Action: toggle_toolbar
DEBUG: Action: toggle_statusbar
DEBUG: Action: set_pathbar_none
DEBUG: Action: toggle_fullscreen
DEBUG: Fullscreen changed: False
DEBUG: Action: toggle_toolbar
DEBUG: Action: toggle_statusbar
DEBUG: Action: set_pathbar_recent

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Hmm, will need to test that -- running Ubuntu Unity, so I never see the menubar anyway..

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Attached a teaser with dark color scheme :)

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Attached an update that correctly turns off the menubar

Revision history for this message
Vlastimil Ott (vlastimil-e-ott) wrote :

Sorry, can't see any change.

Dark color - super.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

On Sat, Dec 1, 2012 at 1:39 PM, Vlastimil Ott <email address hidden> wrote:

> Sorry, can't see any change.
>

Try restarting zim - tested it under XFCE and works for me

-- Jaap

Revision history for this message
DavidM (milarupa) wrote :

That screenshot looks great.

Sadly, I can't seem to be able to test it. It won't let me enable the checkbox in preferences. I guess it's an Ubuntu thing, since Ubuntu 12.10, I get warnings to report Zim problems all the time, but Zim neither closes nor does anything wrong. This is the first time the Zim has an actual problem.

Revision history for this message
Vlastimil Ott (vlastimil-e-ott) wrote :

Jaap> I did. I'm using Xfce, Xubuntu 12.10 but the main menu bar still stays on the screen.

DavidM> Cannot confirm (Ubuntu/Xubuntu and Zim user for years)

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

@vlastimil: Can you check for errors with "zim -D" ? And you are toggling
full screen with <F11>, right ?

@davidm: what do you mean by it doesn't allow enabling the checkbox? What
error do you get?

P.S. I'm still on Ubuntu 12.04, if 12.10 triggers new issues I have not
seen them yet.

Revision history for this message
DavidM (milarupa) wrote :

Jaap: I click on the checkbox, the checkbox doesn't get checked. An apport window tells me that Zim has stopped unexpectedly, but Zim is actually working. This is the apport traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/zim/gui/preferencesdialog.py", line 374, in <lambda>
    cellrenderer.connect('toggled', lambda o, p: model.do_toggle_path(p))
  File "/usr/lib/python2.7/dist-packages/zim/gui/preferencesdialog.py", line 361, in do_toggle_path
    self.ui.load_plugin(klass.plugin_key)
  File "/usr/lib/python2.7/dist-packages/zim/gui/__init__.py", line 546, in load_plugin
    plugin.finalize_ui(self)
  File "/usr/lib/python2.7/dist-packages/zim/plugins/__init__.py", line 230, in decoratedfinalize
    origfinalize(self, ui, *arg, **kwarg)
  File "/home/david/.local/lib/python2.7/site-packages/zim/plugins/distractionfree.py", line 34, in finalize_ui
    self.connectto(self.ui.mainwindow.pageview.view, 'size-allocate')
AttributeError: 'DistractionFreePlugin' object has no attribute 'connectto'
DEBUG: Loading description for "Distraction Free Editing"

By the way, I didn't say before how impressed I am that Jaap wrote a plugin less than 24h after my suggestion. :)

Revision history for this message
Vlastimil Ott (vlastimil-e-ott) wrote :
Download full text (6.7 KiB)

Jaap, yes I press F11 (F9 for toggling panels). I posted output from debugging mode already, there is not any error. Here the full log (start, F11, F11, quit):

$ ps aux|grep zim
1000 5122 0.0 0.0 13728 888 pts/5 S+ 18:38 0:00 grep --color=auto zim
18:38:28 plastique@opavak:~$ zim -D
INFO: This is zim 0.57
DEBUG: Python version is sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
DEBUG: Platform is posix
DEBUG: No bzr version-info found
DEBUG: Not running from a source dir
DEBUG: Set XDG_DATA_HOME to /home/plastique/.local/share
DEBUG: Set XDG_DATA_DIRS to [<Dir: /usr/share/xubuntu>, <Dir: /usr/local/share>, <Dir: /usr/share>, <Dir: /usr/share>]
DEBUG: Set XDG_CONFIG_HOME to /home/plastique/.config
DEBUG: Set XDG_CONFIG_DIRS to [<Dir: /etc/xdg/xdg-xubuntu>, <Dir: /etc/xdg>, <Dir: /etc/xdg>]
DEBUG: Set XDG_CACHE_HOME to /home/plastique/.cache
DEBUG: Running command: gui
DEBUG: Loading config from: /home/plastique/Dropbox/minimum/liberix/notebook.zim
DEBUG: Loading config from: /home/plastique/Dropbox/minimum/poznamky/notebook.zim
DEBUG: Loading config from: /home/plastique/Dropbox/minimum/podnikani/notebook.zim
DEBUG: Loading config from: /home/plastique/Dropbox/minimum/wordpress/notebook.zim
DEBUG: Wrote /home/plastique/.config/zim/notebooks.list
INFO: Opening default notebook
DEBUG: Remote call from 5123: <RemoteMethodCall: 5123: zim.ipc.Server(None).ping((), {})>
DEBUG: Starting server by spawning new process
INFO: Spawning: ['/usr/bin/python', '/usr/bin/zim', '--ipc-server-main', '/tmp/zim-plastique/zim-server-socket', '10'] (cwd: None)
DEBUG: Process started with PID: 5125
DEBUG: Remote call from 5123: <RemoteMethodCall: 5123: zim.ipc.Server(None).ping((), {})>
INFO: Server starting 5125 at /tmp/zim-plastique/zim-server-socket
DEBUG: Remote call from 5123: <RemoteMethodCall: 5123: zim.ipc.Server(None).ping((), {})>
DEBUG: Remote call returned to 5123: ('ACK', 5125)
DEBUG: Remote call from 5123: <RemoteMethodCall: 5123: zim.ipc.Server(None).has_object((<RemoteObject: zim.gui.GtkInterface(file:///home/plastique/Dropbox/minimum/podnikani)>,), {})>
DEBUG: Remote call returned to 5123: False
DEBUG: Remote call from 5123: <RemoteMethodCall: 5123: zim.ipc.Server(None).init_object((<RemoteObject: zim.gui.GtkInterface(file:///home/plastique/Dropbox/minimum/podnikani)>,), {})>
DEBUG: Loading config from: <ConfigFile: /home/plastique/.config/zim/preferences.conf>
DEBUG: Loaded plugin "automount" (<AutomountPlugin object at 0x25a68c0 (zim+plugins+PluginClass at 0x20a8aa0)>)
DEBUG: Gtk version is (2, 24, 13)
DEBUG: Pygtk version is (2, 24, 0)
DEBUG: Loading config from: <ConfigFile: /home/plastique/.config/zim/style.conf>
DEBUG: Opening notebook: file:///home/plastique/Dropbox/minimum/podnikani
DEBUG: Loading config from: /home/plastique/Dropbox/minimum/podnikani/notebook.zim
DEBUG: Cache dir: /home/plastique/Dropbox/minimum/podnikani/.zim
DEBUG: Index database file: /home/plastique/Dropbox/minimum/podnikani/.zim/index.db
DEBUG: Loading config from: /home/plastique/Dropbox/minimum/podnikani/.zim/state.conf
DEBUG: Loaded plugin "arithmetic" (<ArithmeticPlugin object at 0x26671e0 (zim+plugins+PluginClass at 0x2...

Read more...

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

You may be running an older version of zim - upgrading to 0.57 should fix
this. (See the about window if not sure)

-- Jaap

On Sat, Dec 1, 2012 at 6:37 PM, DavidM <email address hidden> wrote:

> Jaap: I click on the checkbox, the checkbox doesn't get checked. An
> apport window tells me that Zim has stopped unexpectedly, but Zim is
> actually working. This is the apport traceback:
>
>
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/zim/gui/preferencesdialog.py",
> line 374, in <lambda>
> cellrenderer.connect('toggled', lambda o, p: model.do_toggle_path(p))
> File "/usr/lib/python2.7/dist-packages/zim/gui/preferencesdialog.py",
> line 361, in do_toggle_path
> self.ui.load_plugin(klass.plugin_key)
> File "/usr/lib/python2.7/dist-packages/zim/gui/__init__.py", line 546,
> in load_plugin
> plugin.finalize_ui(self)
> File "/usr/lib/python2.7/dist-packages/zim/plugins/__init__.py", line
> 230, in decoratedfinalize
> origfinalize(self, ui, *arg, **kwarg)
> File
> "/home/david/.local/lib/python2.7/site-packages/zim/plugins/distractionfree.py",
> line 34, in finalize_ui
> self.connectto(self.ui.mainwindow.pageview.view, 'size-allocate')
> AttributeError: 'DistractionFreePlugin' object has no attribute 'connectto'
> DEBUG: Loading description for "Distraction Free Editing"
>
>
> By the way, I didn't say before how impressed I am that Jaap wrote a
> plugin less than 24h after my suggestion. :)
>
> --
> You received this bug notification because you are subscribed to Zim.
> https://bugs.launchpad.net/bugs/1001137
>
> Title:
> [FEATURE Req.] pyroom-like fullscreen mode
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zim/+bug/1001137/+subscriptions
>

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

On Sat, Dec 1, 2012 at 6:40 PM, Vlastimil Ott <email address hidden> wrote:

> Jaap, yes I press F11 (F9 for toggling panels). I posted output from
> debugging mode already, there is not any error. Here the full log
> (start, F11, F11, quit):
>
>
upgrading to 12.10 as we speak - see if I an reproduce this.

-- Jaap

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

OK, turns out I was stupid to tested with a preset config - attached the version that actually works...

Btw. on 12.10 no, no new issues as far as I can tell

Revision history for this message
Jean-Baptiste Holcroft (jibecfed) wrote :

I tried this plugin with bzr extract but the menubar option is only taken into account when you restart zim.
Whatever how you configure the plugin, only the configuration on zim load is taken.
Despite this little bug, it looks to work fine !

Revision history for this message
Vlastimil Ott (vlastimil-e-ott) wrote :

It works for me without complications, menu bar gets hidden when pressing F11. Well done, thank you

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Committed final version (for now) in rev620. This version does have
preferences for the colors as well, has preferences for all the widgets
that can be hidden in fullscreen, and turns of panes when switching to
fullscreen (but you can turn them back on with F6)

I needed to make small changes to two other classes as well to make this
plugin work as it is, so can't post the final version here as a seperate
plugin.

Changed in zim:
status: New → Fix Committed
Revision history for this message
Rui Nibau (ruinibau) wrote :

Hi Jaap, hi all.

Tried the distarctionfree plugin at rev620 on fullscreen mode. Works quite well. Great job Jaap.

Just a little strange behavior : when i switch back to windowed mode, the background-color of the page is not the original background-color (#fff). If i close and reopen zim, everything's turns fine again.

Here's the output running zin -D when i turn the fullscreen mode on and off:

[rnb@localhost zim]$ DEBUG: Action: toggle_fullscreen
DEBUG: Fullscreen changed: True
DEBUG: Action: toggle_toolbar
DEBUG: Action: toggle_statusbar
DEBUG: Parse RC: >>>
style "zim-colors"
{
 base[NORMAL] = "#babdb6"
 text[NORMAL] = "#2e3436"
 bg[NORMAL] = "#2e3436"
}
widget "*.zim-pageview" style "zim-colors"
<<<
DEBUG: Action: toggle_panes
DEBUG: Action: toggle_fullscreen
DEBUG: Fullscreen changed: False
DEBUG: Action: toggle_toolbar
DEBUG: Action: toggle_statusbar
DEBUG: Parse RC: >>>
style "zim-colors"
{
 base[NORMAL] = "#ededed"
 text[NORMAL] = "#313739"
 bg[NORMAL] = "#ededed"
}
widget "*.zim-pageview" style "zim-colors"
<<<
DEBUG: Action: toggle_panes

This last set of style rules is read from gtk.Entry, but zim page is a gtk.TextView widget ; reading it from gtk.textView gives the correct background-color when i come out from fullscreen mode.

Patch attached.

regards

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

On Mon, Dec 3, 2012 at 11:26 PM, Rui Nibau <email address hidden>wrote:

> This last set of style rules is read from gtk.Entry, but zim page is a
> gtk.TextView widget ; reading it from gtk.textView gives the correct
> background-color when i come out from fullscreen mode.
>
> Patch attached.
>

How naive of me to think that all widgets have same theming :)

Btw. this is exactly the reason why I decided to only set colors on the
textview and not on all widgets - can't get it right without re-setting all
theming rules in detail.

-- Jaap

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Fix released in zim 0.58

Changed in zim:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.