summaryrefslogtreecommitdiffstats
path: root/splashscreen.py
blob: e5adcfe3e32381da78d3e51646ddfd1a859a643e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#
# splashscreen.py: a quick splashscreen window that displays during ipl
#
# Matt Wilson <msw@redhat.com>
#
# Copyright 2001 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import os
os.environ["PYGTK_DISABLE_THREADS"] = "1"
os.environ["PYGTK_FATAL_EXCEPTIONS"] = "1"
#os.environ["GNOME_DISABLE_CRASH_DIALOG"] = "1"

from gtk import *
from gtk import _root_window
from flags import flags
import GDK
import GdkImlib

splashwindow = None

def splashScreenShow(configFileData):
    #set the background to a dark gray
    if flags.setupFilesystems:
        path = ("/usr/X11R6/bin/xsetroot",)
        args = ("-solid", "gray45")

        child = os.fork ()
        if (child == 0):
            os.execv (path[0], path + args)
        try:
            pid, status = os.waitpid(child, 0)
        except OSError, (errno, msg):
            print __name__, "waitpid:", msg

    root = _root_window ()
    cursor = cursor_new (GDK.LEFT_PTR)
    root.set_cursor (cursor)

    def load_image(file):
        try:
#            im = GdkImlib.Image("/usr/share/anaconda/pixmaps/" + file)
            im = GdkImlib.Image("/usr/share/anaconda/" + file)
        except:
            try:
                im = GdkImlib.Image("" + file)
            except:
                im = None
                print "Unable to load", file

        return im

    global splashwindow
    
    width = screen_width()
    im = None

    # If the xserver is running at 800x600 res or higher, use the
    # 800x600 splash screen.
    if width >= 800:
#        im = load_image('first.png')
        image = configFileData["Splashscreen"]

        im = load_image(image)
    else:
        im = load_image('pixmaps/first-lowres.png')
                        
    if im:
        im.render ()
        splashwindow = GtkWindow ()
        splashwindow.set_position (WIN_POS_CENTER)
        box = GtkEventBox ()
        pix = im.make_pixmap ()
        style = box.get_style ().copy ()
        style.bg[STATE_NORMAL] = style.white
        box.set_style (style)
        box.add (pix)
        splashwindow.add (box)
        box.show_all()
        splashwindow.show_now()
        gdk_flush ()
        while events_pending ():
            mainiteration (FALSE)

def splashScreenPop():
    global splashwindow
    if splashwindow:
        splashwindow.destroy ()