forked from dorkbox/SystemTray
Code polish
This commit is contained in:
parent
bf3cb8de11
commit
8d564675f8
@ -183,13 +183,16 @@ class GtkMenu extends Menu {
|
|||||||
// To work around this issue, we destroy then recreate the menu every time something is changed.
|
// To work around this issue, we destroy then recreate the menu every time something is changed.
|
||||||
deleteMenu();
|
deleteMenu();
|
||||||
|
|
||||||
menuEntry = new GtkMenuEntryItem(GtkMenu.this, menuText, imagePath, callback);
|
menuEntry = new GtkMenuEntryItem(GtkMenu.this, callback);
|
||||||
|
menuEntry.setText(menuText);
|
||||||
|
menuEntry.setImage(imagePath);
|
||||||
menuEntries.add(menuEntry);
|
menuEntries.add(menuEntry);
|
||||||
|
|
||||||
if (menuText.equals("AAAAAAAA")) {
|
if (menuText.equals("AAAAAAAA")) {
|
||||||
// GtkMenu subMenu = new GtkMenu();
|
Gtk.gtk_widget_set_sensitive(((GtkMenuEntryItem) menuEntry)._native, Gtk.TRUE);
|
||||||
// subMenu.addMenuEntry("asdasdasd", null, null, null);
|
GtkMenu subMenu = new GtkMenu(getSystemTray(), GtkMenu.this);
|
||||||
// Gtk.gtk_menu_item_set_submenu(((GtkMenuEntryItem) menuEntry).nativeMenuItem, subMenu.nativeMenu);
|
subMenu.addMenuEntry("asdasdasd", null, null, null);
|
||||||
|
Gtk.gtk_menu_item_set_submenu(((GtkMenuEntryItem) menuEntry)._native, subMenu._native);
|
||||||
}
|
}
|
||||||
|
|
||||||
createMenu();
|
createMenu();
|
||||||
|
@ -43,17 +43,15 @@ 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 String label, final File image, final SystemTrayMenuAction callback) {
|
GtkMenuEntryItem(final GtkMenu parentMenu, final SystemTrayMenuAction callback) {
|
||||||
super(parentMenu, Gtk.gtk_image_menu_item_new_with_label(""));
|
super(parentMenu, Gtk.gtk_image_menu_item_new_with_label(""));
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
setText(label);
|
|
||||||
|
|
||||||
if (transparentIcon == null) {
|
if (transparentIcon == null) {
|
||||||
transparentIcon = ImageUtils.getTransparentImage(ImageUtils.ENTRY_SIZE);
|
transparentIcon = ImageUtils.getTransparentImage(ImageUtils.ENTRY_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
setImage_(image);
|
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
Gtk.gtk_widget_set_sensitive(_native, Gtk.TRUE);
|
Gtk.gtk_widget_set_sensitive(_native, Gtk.TRUE);
|
||||||
nativeLong = Gobject.g_signal_connect_object(_native, "activate", this, null, 0);
|
nativeLong = Gobject.g_signal_connect_object(_native, "activate", this, null, 0);
|
||||||
|
@ -29,8 +29,9 @@ 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 label) {
|
GtkMenuEntryStatus(final GtkMenu parentMenu, final String text) {
|
||||||
super(parentMenu, label, null, null);
|
super(parentMenu, null);
|
||||||
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// called in the GTK thread
|
// called in the GTK thread
|
||||||
|
Loading…
Reference in New Issue
Block a user