Skip to content

Commit

Permalink
Better manage the "report a bug" action, so it exists and is suggested…
Browse files Browse the repository at this point in the history
...to the user when the window initialisation process fails, regardless of whether or not it's a beta version of the app
  • Loading branch information
maoschanz committed May 26, 2021
1 parent 9deb16a commit 90ce77e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def _build_actions(self):
"""Add all app-wide actions."""
self.add_action_simple('new_window', self.on_new_window, ['<Ctrl>n'])
self.add_action_simple('settings', self.on_prefs, None)
if self.is_beta():
self.add_action_simple('report_bug', self.on_report, None)
self.add_action_simple('report_bug', self.on_report, None)
self.add_action_simple('shortcuts', self.on_shortcuts, \
['<Ctrl>question', '<Ctrl>F1'])

Expand Down
1 change: 0 additions & 1 deletion src/ui/app-menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@
<item>
<attribute name="label" translatable="yes">Report a bug</attribute>
<attribute name="action">app.report_bug</attribute>
<attribute name="hidden-when">action-missing</attribute>
<attribute name="verb-icon">dialog-error-symbolic</attribute>
</item>
</section>
Expand Down
15 changes: 0 additions & 15 deletions src/ui/win-menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Report a bug</attribute>
<attribute name="action">app.report_bug</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
Expand Down Expand Up @@ -166,11 +161,6 @@
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Report a bug</attribute>
<attribute name="action">app.report_bug</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
Expand Down Expand Up @@ -216,11 +206,6 @@
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Report a bug</attribute>
<attribute name="action">app.report_bug</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<object class="GtkLabel" id="info_label">
<property name="visible">True</property>
<property name="wrap">True</property>
<property name="label" translatable="yes">Error starting the application, please report this bug.</property>
<property name="label" translatable="yes">Loading…</property>
</object>
</child>
</object>
Expand Down
19 changes: 10 additions & 9 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Import libs
import os
import os, traceback
from gi.repository import Gtk, Gdk, Gio, GdkPixbuf, GLib

# Import tools
Expand Down Expand Up @@ -118,7 +118,9 @@ def init_window_content(self, gfile, get_cb):
popovers, the tools, their options, and a new image. Depending on the
parameters, the new image can be imported from the clipboard, loaded
from a GioFile, or (else) it can be a blank image."""
self.tools = None
self.prompt_action(_("Error starting the application, please report this bug."))

self.tools = {}
self.minimap = DrMinimap(self, None)
self.options_manager = DrOptionsManager(self)
self.saving_manager = DrSavingManager(self)
Expand Down Expand Up @@ -231,14 +233,13 @@ def _enable_first_tool(self):
def _load_tool(self, tool_id, tool_class, disabled_tools, dev):
"""Given its id and its python class, this method tries to load a tool,
and show an error message if the tool initialization failed."""
if dev: # Simplest way to get an error stack
self.tools[tool_id] = tool_class(self)
elif tool_id not in disabled_tools:
if tool_id not in disabled_tools:
try:
self.tools[tool_id] = tool_class(self)
except:
except Exception as err:
# Context: an error message
self.prompt_message(True, _("Failed to load tool: %s") % tool_id)
self.prompt_action(_("Failed to load tool: %s") % tool_id)
traceback.print_exc()

def _build_tool_rows(self):
"""Adds each tool's button to the side pane."""
Expand Down Expand Up @@ -708,10 +709,10 @@ def prompt_message(self, show, label):
self.info_action.set_visible(False)
if show:
self.info_label.set_label(label)
if show or self.gsettings.get_boolean('devel-only') and label != "":
if show and self.gsettings.get_boolean('devel-only') and label != "":
print('Drawing: ' + label)

def prompt_action(self, message, action_name, action_label):
def prompt_action(self, message, action_name='app.report_bug', action_label=_("Report a bug")):
"""Update the content of the info bar, including its actionable button
which is set as visible."""
self.prompt_message(True, message)
Expand Down

0 comments on commit 90ce77e

Please sign in to comment.