Skip to content

Commit

Permalink
Use F11 to toggle fullscreen
Browse files Browse the repository at this point in the history
Common usage. Don't customise Escape.
  • Loading branch information
cjmayo authored and DX-MON committed Dec 16, 2020
1 parent 6458690 commit 048a3f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
32 changes: 14 additions & 18 deletions fract4dgui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def __init__(self, application, userConfig, extra_paths=[]):
Gdk.KEY_Right: self.on_key_right,
Gdk.KEY_Up: self.on_key_up,
Gdk.KEY_Down: self.on_key_down,
Gdk.KEY_Escape: self.on_key_escape
}

self.window.connect('key-press-event', self.on_key_press)
Expand Down Expand Up @@ -579,9 +578,10 @@ def save_hires_image(self, *args):
fs.hide()

def get_toggle_actions(self):
return (
"ToolsExplorerAction", self.toggle_explorer
)
return [
("ToolsExplorerAction", self.toggle_explorer),
("ViewFullScreenAction", self.toggle_full_screen),
]

def get_main_actions(self):
return [
Expand All @@ -600,7 +600,7 @@ def get_main_actions(self):
("EditResetZoomAction", self.reset_zoom),
("EditPasteAction", self.paste),

("ViewFullScreenAction", self.full_screen),
# View Full Screen is a toggle, see above

("ToolsAutozoomAction", self.autozoom),
# explorer is a toggle, see above
Expand Down Expand Up @@ -640,9 +640,9 @@ def add_action(name, handler, state=None):
for name, handler in self.get_main_actions():
add_action(name, handler)

# explorer action
self.explorer_action = \
add_action(*self.get_toggle_actions(), state=GLib.Variant("b", False))
# stateful actions
self.explorer_action, self.fullscreen_action = \
[add_action(*x, state=GLib.Variant("b", False)) for x in self.get_toggle_actions()]

# actions which are only available if we're in 4D mode
self.fourd_actiongroup = Gio.SimpleActionGroup()
Expand Down Expand Up @@ -691,15 +691,10 @@ def toggle_explorer(self, action, parameter):
state = action.get_state() == GLib.Variant("b", False)
self.set_explorer_state(state)

def full_screen(self, *args):
"""Show main window full-screen."""
self.set_full_screen(True)

def on_key_escape(self, state):
self.set_full_screen(False)

def set_full_screen(self, is_full):
if is_full:
def toggle_full_screen(self, action, parameter):
"""Switch main window to/from full-screen."""
to_full = action.get_state() == GLib.Variant("b", False)
if to_full:
if not self.normal_window_size:
self.normal_window_size = self.window.get_size()

Expand All @@ -720,7 +715,6 @@ def set_full_screen(self, is_full):
self.userPrefs.set_size(geometry.width, geometry.height)

else:
print("shrinking")
if self.normal_display_size:
self.userPrefs.set_size(*self.normal_display_size)
self.normal_display_size = None
Expand All @@ -732,6 +726,8 @@ def set_full_screen(self, is_full):
self.bar.show()
self.window.unfullscreen()

self.fullscreen_action.set_state(GLib.Variant("b", to_full))

def create_status_bar(self):
self.bar = Gtk.ProgressBar()
self.bar.set_show_text(True)
Expand Down
9 changes: 1 addition & 8 deletions fract4dgui/shortcuts-gnofract4d.ui
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,7 @@
<child>
<object class="GtkShortcutsShortcut">
<property name="action-name">app.ViewFullScreenAction</property>
<property name="title" translatable="yes">Show main window full-screen</property>
<property name="visible">1</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">Escape</property>
<property name="title" translatable="yes">Quit full-screen mode</property>
<property name="title" translatable="yes">Toggle main window full-screen</property>
<property name="visible">1</property>
</object>
</child>
Expand Down
6 changes: 1 addition & 5 deletions manual/content/commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ <h2 id="KeyboardShortcuts">Keyboard Shortcuts</h2>
<td>Enter (or leave) Explorer mode.</td>
</tr>
<tr>
<td>Escape</td>
<td>Quit full-screen mode.</td>
</tr>
<tr>
<td>Ctrl+F</td>
<td>Show fractal settings controls.</td>
</tr>
Expand Down Expand Up @@ -145,7 +141,7 @@ <h2 id="KeyboardShortcuts">Keyboard Shortcuts</h2>
</tr>
<tr>
<td>F11</td>
<td>Show main window full-screen.</td>
<td>Toggle main window full-screen.</td>
</tr>
</tbody>
</table>

0 comments on commit 048a3f0

Please sign in to comment.