Skip to content

Commit f377bf4

Browse files
committed
Fix diagnostic dialog selection, loading missing directories
1 parent 7a8c4ca commit f377bf4

File tree

3 files changed

+81
-66
lines changed

3 files changed

+81
-66
lines changed

menulibre/MenulibreApplication.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,30 @@ def menu_load_failure(self):
308308
Gtk.ButtonsType.CLOSE, primary)
309309
dialog.format_secondary_markup(secondary)
310310

311-
try:
312-
box = dialog.get_children()[0]
313-
box = box.get_children()[0]
314-
box = box.get_children()[1]
315-
label = box.get_children()[1]
311+
label = self.find_secondary_label(dialog)
312+
if label is not None:
316313
label.set_selectable(True)
317-
except AttributeError:
318-
pass
319314

320315
dialog.run()
321316
sys.exit(1)
322317

318+
def find_secondary_label(self, container = None):
319+
try:
320+
children = container.get_children()
321+
if len(children) == 0:
322+
return None
323+
if isinstance(children[0], Gtk.Label):
324+
return children[1]
325+
for child in children:
326+
label = self.find_secondary_label(child)
327+
if label is not None:
328+
return label
329+
except AttributeError:
330+
pass
331+
except IndexError:
332+
pass
333+
return None
334+
323335
def configure_application_window(self, builder, app):
324336
"""Glade is currently unable to create a GtkApplicationWindow. This
325337
function takes the GtkWindow from the UI file and reparents the

menulibre/util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,12 @@ def getMenuDiagnostics():
225225
menu_dirs.append(os.path.join(path, 'menus'))
226226
menus = []
227227
for menu_dir in menu_dirs:
228-
for filename in os.listdir(menu_dir):
229-
if filename.endswith(".menu"):
230-
menus.append(os.path.join(menu_dir, filename))
228+
try:
229+
for filename in os.listdir(menu_dir):
230+
if filename.endswith(".menu"):
231+
menus.append(os.path.join(menu_dir, filename))
232+
except FileNotFoundError:
233+
pass
231234
menus.sort()
232235

233236
diagnostics["MENUS"] = ", ".join(menus)

0 commit comments

Comments
 (0)