Skip to content

Instantly share code, notes, and snippets.

@itzexor
Created February 22, 2019 00:59
Show Gist options
  • Save itzexor/7cb1a7f10ec844de13b9958cbeab7a3c to your computer and use it in GitHub Desktop.
Save itzexor/7cb1a7f10ec844de13b9958cbeab7a3c to your computer and use it in GitHub Desktop.
muffin-debug@cobinja.de
const Applet = imports.ui.applet;
const PopupMenu = imports.ui.popupMenu;
const Meta = imports.gi.Meta;
const TOPICS = [
[Meta.DebugTopic.VERBOSE, "Verbose"],
[Meta.DebugTopic.COMPOSITOR, "Compositor"],
[Meta.DebugTopic.EDGE_RESISTANCE, "Edge Resistance"],
[Meta.DebugTopic.ERRORS, "Errors"],
[Meta.DebugTopic.EVENTS, "Events"],
[Meta.DebugTopic.FOCUS, "Focus"],
[Meta.DebugTopic.GEOMETRY, "Geometry"],
[Meta.DebugTopic.GROUPS, "Groups"],
[Meta.DebugTopic.KEYBINDINGS, "Keybindings"],
[Meta.DebugTopic.PING, "Ping"],
[Meta.DebugTopic.PLACEMENT, "Placement"],
[Meta.DebugTopic.PREFS, "Preferences"],
[Meta.DebugTopic.RESIZING, "Resizing"],
[Meta.DebugTopic.SM, "Session Management"],
[Meta.DebugTopic.SHAPES, "Shapes"],
[Meta.DebugTopic.STACK, "Stack"],
[Meta.DebugTopic.STARTUP, "Startup"],
[Meta.DebugTopic.SYNC, "Sync"],
[Meta.DebugTopic.THEMES, "Themes"],
[Meta.DebugTopic.WINDOW_OPS, "Window Operations"],
[Meta.DebugTopic.WINDOW_STATE, "Window State"],
[Meta.DebugTopic.WORKAREA, "Work Area"],
[Meta.DebugTopic.XINERAMA, "Xinerama"]
];
class MyApplet extends Applet.IconApplet {
constructor(metadata, orientation, panel_height) {
super(orientation, panel_height);
this.set_applet_icon_symbolic_name("video-display-symbolic");
this.set_applet_tooltip("Muffin Debug Topics");
this.menuManager = new PopupMenu.PopupMenuManager(this);
this.menu = new Applet.AppletPopupMenu(this, orientation);
this.menuManager.addMenu(this.menu);
this.freeze = false;
this.menuItems = TOPICS.map(topic => {
let mi = new PopupMenu.PopupSwitchMenuItem(topic[1], false);
mi.topic = topic[0];
mi.connect('toggled', (item, state) => this.onItemToggled(item, state));
this.menu.addMenuItem(mi);
if (topic[0] === Meta.DebugTopic.VERBOSE)
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
return mi;
});
}
on_applet_clicked(event) {
this.menu.toggle();
}
onItemToggled(item, state) {
if (this.freeze)
return;
if (item.topic === Meta.DebugTopic.VERBOSE) {
this.freeze = true;
Meta.set_verbose(state);
this.menuItems.forEach(mi => mi.setToggleState(state));
this.freeze = false;
} else {
Meta[`${state ? 'add' : 'remove'}_verbose_topic`](item.topic);
}
}
}
function main(metadata, orientation, panel_height) {
return new MyApplet(metadata, orientation, panel_height);
}
{
"uuid": "muffin-debug@cobinja.de",
"name": "Muffin Debug Topics",
"description": "This applet toggles muffin debug topics",
"dangerous": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment