Skip to content

Commit

Permalink
remove the warning at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
maoschanz committed Dec 2, 2019
1 parent 0be6bd0 commit ad94736
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(
'drawing',
version: '0.4.8',
version: '0.4.9',
meson_version: '>= 0.45.0',
)

Expand Down
6 changes: 6 additions & 0 deletions src/ui/app-menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
<attribute name="action">win.open</attribute>
<attribute name="verb-icon">document-open-symbolic</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Reload file</attribute>
<attribute name="action">win.reload_file</attribute>
<attribute name="hidden-when">action-missing</attribute>
<attribute name="verb-icon">view-refresh-symbolic</attribute>
</item>
</section>
<section>
<item>
Expand Down
5 changes: 5 additions & 0 deletions src/ui/win-menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
<!-- </section> -->
<section>
<!-- <attribute name="label" translatable="yes">Development features</attribute> -->
<item>
<attribute name="label" translatable="yes">Reload file</attribute>
<attribute name="action">win.reload_file</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Refresh</attribute>
<attribute name="action">win.restore_pixbuf</attribute>
Expand Down
21 changes: 15 additions & 6 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def add_all_win_actions(self):
self.add_action_boolean('toggle_preview', False, self.action_toggle_preview)
self.app.set_accels_for_action('win.toggle_preview', ['<Ctrl>m'])
self.add_action_boolean('show_labels', self._settings.get_boolean( \
'show-labels'), self.on_show_labels_changed)
'show-labels'), self.on_show_labels_action_changed)
self.app.set_accels_for_action('win.show_labels', ['F9'])

self.add_action_simple('go_up', self.action_go_up, ['<Ctrl>Up'])
Expand Down Expand Up @@ -415,6 +415,7 @@ def add_all_win_actions(self):
self.app.add_action_boolean('use_editor', editor, self.action_use_editor)

if self._settings.get_boolean('devel-only'):
self.add_action_simple('reload_file', self.action_reload, None)
self.add_action_simple('restore_pixbuf', self.action_restore, None)
self.add_action_simple('rebuild_from_histo', self.action_rebuild, None)
self.add_action_simple('get_values', self.action_getvalues, None)
Expand Down Expand Up @@ -666,13 +667,16 @@ def set_tools_labels_visibility(self, visible):
for tool_id in self.tools:
self.tools[tool_id].label_widget.set_visible(visible)
nb_tools = len(self.tools)
parent_box = self.tools_flowbox.get_parent()
if visible:
self.tools_flowbox.set_min_children_per_line(nb_tools)
self.tools_nonscrollable_box.remove(self.tools_flowbox)
self.tools_scrollable_box.add(self.tools_flowbox)
if parent_box == self.tools_nonscrollable_box:
self.tools_nonscrollable_box.remove(self.tools_flowbox)
self.tools_scrollable_box.add(self.tools_flowbox)
else:
self.tools_scrollable_box.remove(self.tools_flowbox)
self.tools_nonscrollable_box.add(self.tools_flowbox)
if parent_box == self.tools_scrollable_box:
self.tools_scrollable_box.remove(self.tools_flowbox)
self.tools_nonscrollable_box.add(self.tools_flowbox)
nb_min = int( (nb_tools+(nb_tools % 3))/3 ) - 1
self.tools_flowbox.set_min_children_per_line(nb_min)
self.tools_flowbox.set_max_children_per_line(nb_tools)
Expand All @@ -681,7 +685,7 @@ def on_show_labels_setting_changed(self, *args):
# TODO https://lazka.github.io/pgi-docs/Gio-2.0/classes/Settings.html#Gio.Settings.create_action
self.set_tools_labels_visibility(self._settings.get_boolean('show-labels'))

def on_show_labels_changed(self, *args):
def on_show_labels_action_changed(self, *args):
show_labels = not args[0].get_state()
self._settings.set_boolean('show-labels', show_labels)
args[0].set_state(GLib.Variant.new_boolean(show_labels))
Expand Down Expand Up @@ -764,6 +768,11 @@ def get_active_image(self):
def get_file_path(self):
return self.get_active_image().get_file_path()

def action_reload(self, *args):
gfile = self.get_active_image().gfile
if gfile is not None:
self.try_load_file(gfile)

def action_open(self, *args):
"""Handle the result of an "open" file chooser dialog, and open it in
the current tab, or in a new one, or in a new window. The decision is
Expand Down

0 comments on commit ad94736

Please sign in to comment.