Graphical package manager for pacman based on pamac 5.x.x
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tray-gtk.vala 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * pamac-vala
  3. *
  4. * Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
  5. * Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a get of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. namespace Pamac {
  21. class GtkTrayIcon: TrayIcon {
  22. Gtk.StatusIcon status_icon;
  23. public override void init_status_icon () {
  24. status_icon = new Gtk.StatusIcon ();
  25. status_icon.visible = false;
  26. status_icon.activate.connect (left_clicked);
  27. status_icon.popup_menu.connect (menu_popup);
  28. }
  29. // Show popup menu on right button
  30. void menu_popup (uint button, uint time) {
  31. menu.popup_at_pointer (null);
  32. }
  33. public override void set_tooltip (string info) {
  34. status_icon.set_tooltip_markup (info);
  35. }
  36. public override void set_icon (string icon) {
  37. status_icon.set_from_icon_name (icon);
  38. }
  39. public override string get_icon () {
  40. return status_icon.get_icon_name ();
  41. }
  42. public override bool get_icon_visible () {
  43. return status_icon.visible;
  44. }
  45. public override void set_icon_visible (bool visible) {
  46. if (visible) {
  47. status_icon.visible = true;
  48. } else {
  49. status_icon.visible = false;
  50. }
  51. }
  52. }
  53. }
  54. int main (string[] args) {
  55. var tray_icon = new Pamac.GtkTrayIcon();
  56. return tray_icon.run (args);
  57. }