From 7509d7c96029106a2e132d31cdf036140ef8887a Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 29 Sep 2016 02:59:40 +0200 Subject: [PATCH] Code polish --- src/dorkbox/systemTray/SystemTrayMenuAction.java | 6 +++--- src/dorkbox/systemTray/linux/GtkMenu.java | 6 +++--- src/dorkbox/systemTray/linux/GtkMenuEntry.java | 16 ++++++++-------- .../systemTray/linux/GtkMenuEntryItem.java | 4 ++-- .../systemTray/linux/GtkMenuEntryStatus.java | 4 ++-- src/dorkbox/systemTray/linux/jna/Gtk.java | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/dorkbox/systemTray/SystemTrayMenuAction.java b/src/dorkbox/systemTray/SystemTrayMenuAction.java index 4001524..ea7fb96 100644 --- a/src/dorkbox/systemTray/SystemTrayMenuAction.java +++ b/src/dorkbox/systemTray/SystemTrayMenuAction.java @@ -22,8 +22,8 @@ interface SystemTrayMenuAction { * (GtkStatusIcon/AppIndicator based). * * @param systemTray this is the parent, system tray object - * @param parentMenu this is the parent menu of this menu entry - * @param menuEntry this is the menu entry that was clicked + * @param parent this is the parent menu of this menu entry + * @param entry this is the menu entry that was clicked */ - void onClick(SystemTray systemTray, Menu parentMenu, final MenuEntry menuEntry); + void onClick(SystemTray systemTray, Menu parent, final MenuEntry entry); } diff --git a/src/dorkbox/systemTray/linux/GtkMenu.java b/src/dorkbox/systemTray/linux/GtkMenu.java index b822bab..8da7f56 100644 --- a/src/dorkbox/systemTray/linux/GtkMenu.java +++ b/src/dorkbox/systemTray/linux/GtkMenu.java @@ -27,12 +27,12 @@ import dorkbox.systemTray.linux.jna.Gobject; import dorkbox.systemTray.linux.jna.Gtk; class GtkMenu extends Menu { + // must ONLY be created at the end of delete! volatile Pointer _native; // called on dispatch - GtkMenu(SystemTray systemTray, GtkMenu parentMenu) { - super(systemTray, parentMenu); -// this._native = Gtk.gtk_menu_new(); + GtkMenu(SystemTray systemTray, GtkMenu parent) { + super(systemTray, parent); } diff --git a/src/dorkbox/systemTray/linux/GtkMenuEntry.java b/src/dorkbox/systemTray/linux/GtkMenuEntry.java index 4b7b0c2..99ee6a9 100644 --- a/src/dorkbox/systemTray/linux/GtkMenuEntry.java +++ b/src/dorkbox/systemTray/linux/GtkMenuEntry.java @@ -30,7 +30,7 @@ abstract class GtkMenuEntry implements MenuEntry { private final int id = Menu.MENU_ID_COUNTER.getAndIncrement(); - private final GtkMenu parentMenu; + private final GtkMenu parent; final Pointer _native; // this have to be volatile, because they can be changed from any thread @@ -40,14 +40,14 @@ class GtkMenuEntry implements MenuEntry { * called from inside dispatch thread. ONLY creates the menu item, but DOES NOT attach it! * this is a FLOATING reference. See: https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#floating-ref */ - GtkMenuEntry(final GtkMenu parentMenu, final Pointer menuItem) { - this.parentMenu = parentMenu; + GtkMenuEntry(final GtkMenu parent, final Pointer menuItem) { + this.parent = parent; this._native = menuItem; } public Menu getParent() { - return parentMenu; + return parent; } /** @@ -148,16 +148,16 @@ class GtkMenuEntry implements MenuEntry { */ public final void remove() { - Gtk.gtk_container_remove(parentMenu._native, _native); - Gtk.gtk_menu_shell_deactivate(parentMenu._native, _native); + Gtk.gtk_container_remove(parent._native, _native); + Gtk.gtk_menu_shell_deactivate(parent._native, _native); removePrivate(); Gtk.gtk_widget_destroy(_native); // have to rebuild the menu now... - parentMenu.deleteMenu(); - parentMenu.createMenu(); + parent.deleteMenu(); + parent.createMenu(); } // called when this item is removed. Necessary to cleanup/remove itself diff --git a/src/dorkbox/systemTray/linux/GtkMenuEntryItem.java b/src/dorkbox/systemTray/linux/GtkMenuEntryItem.java index 329babc..7f9e242 100644 --- a/src/dorkbox/systemTray/linux/GtkMenuEntryItem.java +++ b/src/dorkbox/systemTray/linux/GtkMenuEntryItem.java @@ -43,8 +43,8 @@ class GtkMenuEntryItem extends GtkMenuEntry implements GCallback { * called from inside dispatch thread. ONLY creates the menu item, but DOES NOT attach it! * this is a FLOATING reference. See: https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#floating-ref */ - GtkMenuEntryItem(final GtkMenu parentMenu, final SystemTrayMenuAction callback) { - super(parentMenu, Gtk.gtk_image_menu_item_new_with_label("")); + GtkMenuEntryItem(final GtkMenu parent, final SystemTrayMenuAction callback) { + super(parent, Gtk.gtk_image_menu_item_new_with_label("")); this.callback = callback; diff --git a/src/dorkbox/systemTray/linux/GtkMenuEntryStatus.java b/src/dorkbox/systemTray/linux/GtkMenuEntryStatus.java index 9fd371b..632970c 100644 --- a/src/dorkbox/systemTray/linux/GtkMenuEntryStatus.java +++ b/src/dorkbox/systemTray/linux/GtkMenuEntryStatus.java @@ -29,8 +29,8 @@ class GtkMenuEntryStatus extends GtkMenuEntryItem { * called from inside dispatch thread. ONLY creates the menu item, but DOES NOT attach it! * this is a FLOATING reference. See: https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#floating-ref */ - GtkMenuEntryStatus(final GtkMenu parentMenu, final String text) { - super(parentMenu, null); + GtkMenuEntryStatus(final GtkMenu parent, final String text) { + super(parent, null); setText(text); } diff --git a/src/dorkbox/systemTray/linux/jna/Gtk.java b/src/dorkbox/systemTray/linux/jna/Gtk.java index 33725f4..3284ee7 100644 --- a/src/dorkbox/systemTray/linux/jna/Gtk.java +++ b/src/dorkbox/systemTray/linux/jna/Gtk.java @@ -383,11 +383,11 @@ class Gtk { * @param callback will never be null. */ public static - void proxyClick(final Menu parentMenu, final MenuEntry menuEntry, final SystemTrayMenuAction callback) { + void proxyClick(final Menu parent, final MenuEntry menuEntry, final SystemTrayMenuAction callback) { Gtk.isDispatch = true; try { - callback.onClick(parentMenu.getSystemTray(), parentMenu, menuEntry); + callback.onClick(parent.getSystemTray(), parent, menuEntry); } catch (Throwable throwable) { SystemTray.logger.error("Error calling menu entry {} click event.", menuEntry.getText(), throwable); }