Skip to content

Commit

Permalink
Looking glass: Usability improvements
Browse files Browse the repository at this point in the history
- Centered window
- Don't keep window above other windows
- Remove unnecessary about dialog
- Call Melange "Looking Glass" (it makes no sense for users to
distinguish between the two), and that's what the tool is called
in the keybindings and in the panel troubleshooting menu
- Have the logs shown by default (that's why most users want to see)
  • Loading branch information
clefebvre committed Dec 17, 2024
1 parent 6029c9a commit e955be7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def do_command_line(self, command_line):
def do_startup(self):
Gtk.Application.do_startup(self)
self.lg_proxy = LookingGlassProxy()
# The status label is shown iff we are not okay
# The status label is shown if we are not okay
self.lg_proxy.connect("status-changed", self.update_status_from_proxy)

if self.window is None:
Expand Down Expand Up @@ -430,18 +430,14 @@ def inspect(self):

def construct_window(self):
self.window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
self.window.set_title("Melange")
headerbar = Gtk.HeaderBar()
headerbar.set_title("Looking Glass")
headerbar.set_subtitle("Cinnamon Troubleshooting Tool")
headerbar.set_show_close_button(True)
self.window.set_titlebar(headerbar)
self.window.set_icon_name("system-search")
self.window.set_default_size(1000, 400)
self.window.set_position(Gtk.WindowPosition.MOUSE)

# I can't think of a way to reliably detect if the window
# is active to determine if we need to present or hide
# in show(). Since the window briefly loses focus during
# shortcut press we'd be unable to detect it at that time.
# Keeping the window on top ensures the window is never
# obscured so we can just hide if visible.
self.window.set_keep_above(True)
self.window.set_position(Gtk.WindowPosition.CENTER)

self.window.connect("delete_event", self.on_delete)
self.window.connect("key-press-event", self.on_key_press)
Expand All @@ -463,18 +459,13 @@ def construct_window(self):
self.notebook.set_show_border(True)
self.notebook.set_show_tabs(True)

label = Gtk.Label(label="Melange")
label.set_markup("<u>Melange - Cinnamon Debugger</u> ")
label.show()
self.notebook.set_action_widget(label, Gtk.PackType.END)

self.pages = {}
self.custom_pages = {}
self.create_page("Logs", "log")
self.create_page("Results", "results")
self.create_page("Inspect", "inspect")
self.create_page("Windows", "windows")
self.create_page("Extensions", "extensions")
self.create_page("Log", "log")

table.attach(self.notebook, 0, num_columns, 0, 1)

Expand Down Expand Up @@ -531,7 +522,6 @@ def construct_window(self):

table.attach(box, column, column+1, 1, 2, 0, 0, 1)

# self.activate_page("results")
self.status_label.hide()
self.window.set_focus(self.command_line)

Expand All @@ -551,7 +541,6 @@ def create_action_button(self):
menu.append(self.create_menu_item('Crash Cinnamon', crash_func))
menu.append(self.create_menu_item('Reset Cinnamon Settings', self.on_reset_clicked))
menu.append(Gtk.SeparatorMenuItem())
menu.append(self.create_menu_item('About Melange', self.on_about_clicked))
menu.append(self.create_menu_item('Quit', self.on_delete))
menu.show_all()

Expand Down Expand Up @@ -579,22 +568,6 @@ def on_close_tab(self, label, content):
content.destroy()
del self.custom_pages[label]

def on_about_clicked(self, menu_item):
dialog = Gtk.MessageDialog(self.window, 0,
Gtk.MessageType.QUESTION, Gtk.ButtonsType.CLOSE)

dialog.set_title("About Melange")
dialog.set_markup("""\
<b>Melange</b> is a GTK3 alternative to the built-in javascript debugger <i>Looking Glass</i>
Pressing <i>Escape</i> while Melange has focus will hide the window.
If you want to exit Melange, use ALT+F4 or the <u>Actions</u> menu button.
If you defined a hotkey for Melange, pressing it while Melange is visible it will be hidden.""")

dialog.run()
dialog.destroy()

def on_reset_clicked(self, menu_item):
dialog = Gtk.MessageDialog(self.window, 0,
Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def get_updates(self, proxy=None):
item["tooltip"],
item["object"]])
self._changed = True
self.parent.activate_page("results")
except Exception as exc:
print(exc)

Expand Down

0 comments on commit e955be7

Please sign in to comment.