Skip to content

Commit 90ce77e

Browse files
committed
Better manage the "report a bug" action, so it exists and is suggested…
...to the user when the window initialisation process fails, regardless of whether or not it's a beta version of the app
1 parent 9deb16a commit 90ce77e

File tree

5 files changed

+12
-28
lines changed

5 files changed

+12
-28
lines changed

src/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def _build_actions(self):
8484
"""Add all app-wide actions."""
8585
self.add_action_simple('new_window', self.on_new_window, ['<Ctrl>n'])
8686
self.add_action_simple('settings', self.on_prefs, None)
87-
if self.is_beta():
88-
self.add_action_simple('report_bug', self.on_report, None)
87+
self.add_action_simple('report_bug', self.on_report, None)
8988
self.add_action_simple('shortcuts', self.on_shortcuts, \
9089
['<Ctrl>question', '<Ctrl>F1'])
9190

src/ui/app-menus.ui

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@
435435
<item>
436436
<attribute name="label" translatable="yes">Report a bug</attribute>
437437
<attribute name="action">app.report_bug</attribute>
438-
<attribute name="hidden-when">action-missing</attribute>
439438
<attribute name="verb-icon">dialog-error-symbolic</attribute>
440439
</item>
441440
</section>

src/ui/win-menus.ui

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@
9191
</item>
9292
</section>
9393
<section>
94-
<item>
95-
<attribute name="label" translatable="yes">Report a bug</attribute>
96-
<attribute name="action">app.report_bug</attribute>
97-
<attribute name="hidden-when">action-missing</attribute>
98-
</item>
9994
<item>
10095
<attribute name="label" translatable="yes">Shortcuts</attribute>
10196
<attribute name="action">app.shortcuts</attribute>
@@ -166,11 +161,6 @@
166161
</item>
167162
</section>
168163
<section>
169-
<item>
170-
<attribute name="label" translatable="yes">Report a bug</attribute>
171-
<attribute name="action">app.report_bug</attribute>
172-
<attribute name="hidden-when">action-missing</attribute>
173-
</item>
174164
<item>
175165
<attribute name="label" translatable="yes">Shortcuts</attribute>
176166
<attribute name="action">app.shortcuts</attribute>
@@ -216,11 +206,6 @@
216206
</item>
217207
</section>
218208
<section>
219-
<item>
220-
<attribute name="label" translatable="yes">Report a bug</attribute>
221-
<attribute name="action">app.report_bug</attribute>
222-
<attribute name="hidden-when">action-missing</attribute>
223-
</item>
224209
<item>
225210
<attribute name="label" translatable="yes">Shortcuts</attribute>
226211
<attribute name="action">app.shortcuts</attribute>

src/ui/window.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<object class="GtkLabel" id="info_label">
4242
<property name="visible">True</property>
4343
<property name="wrap">True</property>
44-
<property name="label" translatable="yes">Error starting the application, please report this bug.</property>
44+
<property name="label" translatable="yes">Loading…</property>
4545
</object>
4646
</child>
4747
</object>

src/window.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
# Import libs
19-
import os
19+
import os, traceback
2020
from gi.repository import Gtk, Gdk, Gio, GdkPixbuf, GLib
2121

2222
# Import tools
@@ -118,7 +118,9 @@ def init_window_content(self, gfile, get_cb):
118118
popovers, the tools, their options, and a new image. Depending on the
119119
parameters, the new image can be imported from the clipboard, loaded
120120
from a GioFile, or (else) it can be a blank image."""
121-
self.tools = None
121+
self.prompt_action(_("Error starting the application, please report this bug."))
122+
123+
self.tools = {}
122124
self.minimap = DrMinimap(self, None)
123125
self.options_manager = DrOptionsManager(self)
124126
self.saving_manager = DrSavingManager(self)
@@ -231,14 +233,13 @@ def _enable_first_tool(self):
231233
def _load_tool(self, tool_id, tool_class, disabled_tools, dev):
232234
"""Given its id and its python class, this method tries to load a tool,
233235
and show an error message if the tool initialization failed."""
234-
if dev: # Simplest way to get an error stack
235-
self.tools[tool_id] = tool_class(self)
236-
elif tool_id not in disabled_tools:
236+
if tool_id not in disabled_tools:
237237
try:
238238
self.tools[tool_id] = tool_class(self)
239-
except:
239+
except Exception as err:
240240
# Context: an error message
241-
self.prompt_message(True, _("Failed to load tool: %s") % tool_id)
241+
self.prompt_action(_("Failed to load tool: %s") % tool_id)
242+
traceback.print_exc()
242243

243244
def _build_tool_rows(self):
244245
"""Adds each tool's button to the side pane."""
@@ -708,10 +709,10 @@ def prompt_message(self, show, label):
708709
self.info_action.set_visible(False)
709710
if show:
710711
self.info_label.set_label(label)
711-
if show or self.gsettings.get_boolean('devel-only') and label != "":
712+
if show and self.gsettings.get_boolean('devel-only') and label != "":
712713
print('Drawing: ' + label)
713714

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

0 commit comments

Comments
 (0)