#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------#
# Name:GimpSplasher                                                     #
# Version 3.1.1                                                         #
# Copyright (C) 2026 Ken Dotson - <lxgator[AT]gmail[DOT]com>            #
#                                                                       #
# 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 copy of the GNU General Public License     #
# along with this program. If not, see <http://www.gnu.org/licenses/>.  #
#-----------------------------------------------------------------------#

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

def __init__(self):
        """Initialize the window"""
        Gtk.Window.__init__(self, title='GimpSplasher')
        self.set_icon_from_file('/usr/share/icons/hicolor/48x48/apps/gimpsplasher.png')
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_border_width(10)

# Check if either directory exists
if os.path.exists(os.path.expanduser("~/.config/GIMP/3.0/")):
    directory = os.path.expanduser("~/.config/GIMP/3.0/")
else:
    directory = os.path.expanduser("~/.config/GIMP/2.10/")

if os.path.exists(directory):
    # Execute /usr/share/gimpsplasher/Main.py
    os.system("python3 /usr/share/gimpsplasher/gimpsplasher.py 2>/dev/null")
else:
    # Display message and exit dialog
    dialog = Gtk.MessageDialog(
        transient_for=None,
        flags=0,
        message_type=Gtk.MessageType.WARNING,
        buttons=Gtk.ButtonsType.OK,
        text="Important",
    )
    dialog.format_secondary_text(
        "Start Gimp first to run the GimpSplasher application."
    )

    dialog.run()
    dialog.destroy()
