pamac-classic/src/pamac-tray/tray-gtk.vala

68 lines
1.8 KiB
Vala
Raw Normal View History

/*
* pamac-vala
*
2017-10-10 16:29:22 -03:00
* Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
2017-01-03 05:43:19 -03:00
* Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
class GtkTrayIcon: TrayIcon {
Gtk.StatusIcon status_icon;
public override void init_status_icon () {
status_icon = new Gtk.StatusIcon ();
status_icon.visible = false;
status_icon.activate.connect (left_clicked);
status_icon.popup_menu.connect (menu_popup);
}
// Show popup menu on right button
void menu_popup (uint button, uint time) {
2019-07-06 20:28:51 -04:00
menu.popup_at_pointer (null);
}
public override void set_tooltip (string info) {
status_icon.set_tooltip_markup (info);
}
public override void set_icon (string icon) {
status_icon.set_from_icon_name (icon);
}
public override string get_icon () {
return status_icon.get_icon_name ();
}
2017-11-10 22:36:50 -03:00
public override bool get_icon_visible () {
return status_icon.visible;
}
public override void set_icon_visible (bool visible) {
if (visible) {
status_icon.visible = true;
} else {
status_icon.visible = false;
}
}
}
}
int main (string[] args) {
var tray_icon = new Pamac.GtkTrayIcon();
return tray_icon.run (args);
}