#!/usr/bin/env python3

import os
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AyatanaAppIndicator3', '0.1')
from gi.repository import Gtk, AyatanaAppIndicator3

APPINDICATOR_ID = "GimpSplasher"

def script1(widget):
    os.popen("/usr/bin/gimpsplasher")

def script2(widget):
    os.popen("/usr/share/gimpsplasher/chooser.py")

def script3(widget):
    os.popen("/usr/share/gimpsplasher/remove.py")

def script4(widget):
    os.popen("/usr/share/gimpsplasher/delete.py")

def script5(widget):
    os.popen("/usr/share/gimpsplasher/reset/reset")

def script6(widget):
    os.popen("pkill -f /usr/share/gimpsplasher/GimpSplasher")


def build_menu():
    menu = Gtk.Menu()
    items = [
        ("🏞️ Menu", script1, "Main Menu"),
        ("✳️ Choose", script2, "Choose Splashes"),
        ("💥️ Installed", script3, "Installed Splashes"),
        ("⛔️ Remove", script4, "Delete All Splashes"),
        ("♻️ Reset", script5, "Reset to Default"),
        ("❌️ Quit", script6, "Quit GimpSplasher"),

    ]

    for label, callback, tip in items:
        item = Gtk.MenuItem(label=label)
        item.connect('activate', callback)
        item.set_tooltip_text(tip)
        menu.append(item)

    menu.show_all()
    return menu

indicator = AyatanaAppIndicator3.Indicator.new(
    APPINDICATOR_ID,
    "/usr/share/icons/hicolor/48x48/apps/gimpsplasher.png",
    AyatanaAppIndicator3.IndicatorCategory.APPLICATION_STATUS
)

indicator.set_status(AyatanaAppIndicator3.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())

Gtk.main()


