Code polish

This commit is contained in:
nathan 2016-09-29 02:59:40 +02:00
parent 8d564675f8
commit 7509d7c960
6 changed files with 20 additions and 20 deletions

View File

@ -22,8 +22,8 @@ interface SystemTrayMenuAction {
* (GtkStatusIcon/AppIndicator based). * (GtkStatusIcon/AppIndicator based).
* *
* @param systemTray this is the parent, system tray object * @param systemTray this is the parent, system tray object
* @param parentMenu this is the parent menu of this menu entry * @param parent this is the parent menu of this menu entry
* @param menuEntry this is the menu entry that was clicked * @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);
} }

View File

@ -27,12 +27,12 @@ import dorkbox.systemTray.linux.jna.Gobject;
import dorkbox.systemTray.linux.jna.Gtk; import dorkbox.systemTray.linux.jna.Gtk;
class GtkMenu extends Menu { class GtkMenu extends Menu {
// must ONLY be created at the end of delete!
volatile Pointer _native; volatile Pointer _native;
// called on dispatch // called on dispatch
GtkMenu(SystemTray systemTray, GtkMenu parentMenu) { GtkMenu(SystemTray systemTray, GtkMenu parent) {
super(systemTray, parentMenu); super(systemTray, parent);
// this._native = Gtk.gtk_menu_new();
} }

View File

@ -30,7 +30,7 @@ abstract
class GtkMenuEntry implements MenuEntry { class GtkMenuEntry implements MenuEntry {
private final int id = Menu.MENU_ID_COUNTER.getAndIncrement(); private final int id = Menu.MENU_ID_COUNTER.getAndIncrement();
private final GtkMenu parentMenu; private final GtkMenu parent;
final Pointer _native; final Pointer _native;
// this have to be volatile, because they can be changed from any thread // 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! * 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 * 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) { GtkMenuEntry(final GtkMenu parent, final Pointer menuItem) {
this.parentMenu = parentMenu; this.parent = parent;
this._native = menuItem; this._native = menuItem;
} }
public public
Menu getParent() { Menu getParent() {
return parentMenu; return parent;
} }
/** /**
@ -148,16 +148,16 @@ class GtkMenuEntry implements MenuEntry {
*/ */
public final public final
void remove() { void remove() {
Gtk.gtk_container_remove(parentMenu._native, _native); Gtk.gtk_container_remove(parent._native, _native);
Gtk.gtk_menu_shell_deactivate(parentMenu._native, _native); Gtk.gtk_menu_shell_deactivate(parent._native, _native);
removePrivate(); removePrivate();
Gtk.gtk_widget_destroy(_native); Gtk.gtk_widget_destroy(_native);
// have to rebuild the menu now... // have to rebuild the menu now...
parentMenu.deleteMenu(); parent.deleteMenu();
parentMenu.createMenu(); parent.createMenu();
} }
// called when this item is removed. Necessary to cleanup/remove itself // called when this item is removed. Necessary to cleanup/remove itself

View File

@ -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! * 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 * 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) { GtkMenuEntryItem(final GtkMenu parent, final SystemTrayMenuAction callback) {
super(parentMenu, Gtk.gtk_image_menu_item_new_with_label("")); super(parent, Gtk.gtk_image_menu_item_new_with_label(""));
this.callback = callback; this.callback = callback;

View File

@ -29,8 +29,8 @@ class GtkMenuEntryStatus extends GtkMenuEntryItem {
* called from inside dispatch thread. ONLY creates the menu item, but DOES NOT attach it! * 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 * 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) { GtkMenuEntryStatus(final GtkMenu parent, final String text) {
super(parentMenu, null); super(parent, null);
setText(text); setText(text);
} }

View File

@ -383,11 +383,11 @@ class Gtk {
* @param callback will never be null. * @param callback will never be null.
*/ */
public static 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; Gtk.isDispatch = true;
try { try {
callback.onClick(parentMenu.getSystemTray(), parentMenu, menuEntry); callback.onClick(parent.getSystemTray(), parent, menuEntry);
} catch (Throwable throwable) { } catch (Throwable throwable) {
SystemTray.logger.error("Error calling menu entry {} click event.", menuEntry.getText(), throwable); SystemTray.logger.error("Error calling menu entry {} click event.", menuEntry.getText(), throwable);
} }