From a6a5cace4864c37b7a820c89540f85069d842521 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Fri, 10 Aug 2007 02:22:40 +0000 Subject: add splash screen --- portato/gui/gtk/__init__.py | 20 ++++--- portato/gui/gtk/basic.py | 94 ++++++++++++++++++++++++++++++++ portato/gui/gtk/splash.py | 49 +++++++++++++++++ portato/gui/gtk/windows.py | 104 +++++++----------------------------- portato/gui/templates/portato.glade | 58 ++++++++++++++++++++ 5 files changed, 235 insertions(+), 90 deletions(-) create mode 100644 portato/gui/gtk/basic.py create mode 100644 portato/gui/gtk/splash.py (limited to 'portato/gui') diff --git a/portato/gui/gtk/__init__.py b/portato/gui/gtk/__init__.py index 41161d6..0714f39 100644 --- a/portato/gui/gtk/__init__.py +++ b/portato/gui/gtk/__init__.py @@ -10,21 +10,29 @@ # # Written by René 'Necoro' Neumann -import gtk -from portato import plugin -from portato.backend import system -from windows import MainWindow, SearchWindow, EbuildWindow +from gettext import lgettext as _ + from exception_handling import register_ex_handler def run (): + from splash import SplashScreen try: - m = MainWindow() + s = SplashScreen(_("Loading Portage")) register_ex_handler() + s.show() + from windows import MainWindow + m = MainWindow(s) + s.hide() m.main() except KeyboardInterrupt: pass -def show_ebuild (pkg): +def show_ebuild (pkg): + import gtk + from portato import plugin + from portato.backend import system + from windows import SearchWindow, EbuildWindow + plugin.load_plugins("gtk") register_ex_handler() diff --git a/portato/gui/gtk/basic.py b/portato/gui/gtk/basic.py new file mode 100644 index 0000000..882e40a --- /dev/null +++ b/portato/gui/gtk/basic.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# +# File: portato/gui/gtk/basic.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2007 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann + +# gtk stuff +import gtk +import gtk.glade +import gobject + +from portato.constants import DATA_DIR, APP_ICON, APP, LOCALE_DIR + +gtk.glade.bindtextdomain (APP, LOCALE_DIR) +gtk.glade.textdomain (APP) +GLADE_FILE = DATA_DIR+"portato.glade" + +class Window (object): + def __init__ (self): + self.tree = self.get_tree(self.__class__.__name__) + self.tree.signal_autoconnect(self) + self.window = self.tree.get_widget(self.__class__.__name__) + self.window.set_icon_from_file(APP_ICON) + + @staticmethod + def watch_cursor (func): + """This is a decorator for functions being so time consuming, that it is appropriate to show the watch-cursor. + @attention: this function relies on the gtk.Window-Object being stored as self.window""" + def wrapper (self, *args, **kwargs): + ret = None + def cb_idle(): + try: + ret = func(self, *args, **kwargs) + finally: + self.window.window.set_cursor(None) + return False + + watch = gtk.gdk.Cursor(gtk.gdk.WATCH) + self.window.window.set_cursor(watch) + gobject.idle_add(cb_idle) + return ret + + wrapper.__dict__ = func.__dict__ + wrapper.__name__ = func.__name__ + wrapper.__doc__ = func.__doc__ + return wrapper + + def get_tree (self, name): + return gtk.glade.XML(GLADE_FILE, name) + +class AbstractDialog (Window): + """A class all our dialogs get derived from. It sets useful default vars and automatically handles the ESC-Button.""" + + def __init__ (self, parent): + """Constructor. + + @param parent: the parent window + @type parent: gtk.Window""" + + Window.__init__(self) + + # set parent + self.window.set_transient_for(parent) + + # catch the ESC-key + self.window.connect("key-press-event", self.cb_key_pressed) + + def cb_key_pressed (self, widget, event): + """Closes the window if ESC is pressed.""" + keyname = gtk.gdk.keyval_name(event.keyval) + if keyname == "Escape": + self.close() + return True + else: + return False + + def close (self, *args): + self.window.destroy() + +class Popup (object): + + def __init__ (self, name, parent): + self.tree = gtk.glade.XML(GLADE_FILE, root = name) + self.tree.signal_autoconnect(parent) + self._popup = self.tree.get_widget(name) + + def popup (self, *args): + self._popup.popup(*args) diff --git a/portato/gui/gtk/splash.py b/portato/gui/gtk/splash.py new file mode 100644 index 0000000..aa4a3ea --- /dev/null +++ b/portato/gui/gtk/splash.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# +# File: portato/gui/gtk/splash.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2007 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann +import gtk +import gobject +from gettext import lgettext as _ + +from portato.constants import VERSION, APP_ICON +from basic import Window + +class SplashScreen (Window): + + def __init__ (self, startStr = ""): + Window.__init__(self) + + self.image = self.tree.get_widget("image") + self.genLabel = self.tree.get_widget("generalLabel") + self.descrLabel = self.tree.get_widget("descrLabel") + + self.image.set_from_file(APP_ICON) + self.genLabel.set_label("Portato %s ..." % VERSION) + + self.set_descr(startStr) + + def set_descr (self, string): + self.descrLabel.set_label(_("... is starting up: %s") % string) + self.do_iteration() + + def do_iteration (self): + while gtk.events_pending(): + gtk.main_iteration() + + def show (self): + self.window.show_all() + self.do_iteration() + + def hide (self): + self.window.hide() + self.do_iteration() + + __call__ = set_descr diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 5d61f92..74f7058 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -11,14 +11,17 @@ # Written by René 'Necoro' Neumann # gtk stuff -import pygtk import gtk -import gtk.glade import gobject +# other +import types, logging +from subprocess import Popen +from gettext import lgettext as _ + # our backend stuff from portato.helper import * -from portato.constants import CONFIG_LOCATION, VERSION, DATA_DIR, APP_ICON, APP, LOCALE_DIR +from portato.constants import CONFIG_LOCATION, VERSION, APP_ICON from portato.backend import flags, system from portato.backend.exceptions import * @@ -27,89 +30,12 @@ from portato import plugin # more GUI stuff from portato.gui.gui_helper import Database, Config, EmergeQueue +from basic import Window, AbstractDialog, Popup from dialogs import * from wrapper import GtkTree, GtkConsole from usetips import UseTips from exception_handling import GtkThread -# other -import types, logging -from subprocess import Popen -from gettext import lgettext as _ - -gtk.glade.bindtextdomain (APP, LOCALE_DIR) -gtk.glade.textdomain (APP) -GLADE_FILE = DATA_DIR+"portato.glade" - -class Window: - def __init__ (self): - self.tree = self.get_tree(self.__class__.__name__) - self.tree.signal_autoconnect(self) - self.window = self.tree.get_widget(self.__class__.__name__) - self.window.set_icon_from_file(APP_ICON) - - @staticmethod - def watch_cursor (func): - """This is a decorator for functions being so time consuming, that it is appropriate to show the watch-cursor. - @attention: this function relies on the gtk.Window-Object being stored as self.window""" - def wrapper (self, *args, **kwargs): - ret = None - def cb_idle(): - try: - ret = func(self, *args, **kwargs) - finally: - self.window.window.set_cursor(None) - return False - - watch = gtk.gdk.Cursor(gtk.gdk.WATCH) - self.window.window.set_cursor(watch) - gobject.idle_add(cb_idle) - return ret - return wrapper - - def get_tree (self, name): - return gtk.glade.XML(GLADE_FILE, name) - -class Popup: - - def __init__ (self, name, parent): - self.tree = gtk.glade.XML(GLADE_FILE, root = name) - self.tree.signal_autoconnect(parent) - self._popup = self.tree.get_widget(name) - - def popup (self, *args): - self._popup.popup(*args) - - -class AbstractDialog (Window): - """A class all our dialogs get derived from. It sets useful default vars and automatically handles the ESC-Button.""" - - def __init__ (self, parent): - """Constructor. - - @param parent: the parent window - @type parent: gtk.Window""" - - Window.__init__(self) - - # set parent - self.window.set_transient_for(parent) - - # catch the ESC-key - self.window.connect("key-press-event", self.cb_key_pressed) - - def cb_key_pressed (self, widget, event): - """Closes the window if ESC is pressed.""" - keyname = gtk.gdk.keyval_name(event.keyval) - if keyname == "Escape": - self.close() - return True - else: - return False - - def close (self, *args): - self.window.destroy() - class AboutWindow (AbstractDialog): """A window showing the "about"-informations.""" @@ -935,9 +861,12 @@ class MainWindow (Window): QUEUE_PAGE = 1 CONSOLE_PAGE = 2 - def __init__ (self): + def __init__ (self, splash = None): """Build up window""" + if splash is None: + splash = lambda x: True + # the title self.main_title = "Portato (%s)" % VERSION @@ -958,10 +887,12 @@ class MainWindow (Window): self.logWindow = LogWindow(self.window) # package db + splash(_("Creating Database")) self.db = Database() self.db.populate() # config + splash(_("Loading Config")) try: self.cfg = Config(CONFIG_LOCATION) except IOError, e: @@ -972,6 +903,8 @@ class MainWindow (Window): gtk.link_button_set_uri_hook(lambda btn, x: Popen([self.cfg.get("browserCmd", section = "GUI"), btn.get_uri()])) # set plugins and plugin-menu + splash(_("Loading Plugins")) + plugin.load_plugins("gtk") menus = plugin.get_plugin_queue().get_plugin_menus() if menus: @@ -983,6 +916,8 @@ class MainWindow (Window): item.connect("activate", m.call) pluginMenu.append(item) + splash(_("Finishing startup")) + # set vpaned position vpaned = self.tree.get_widget("vpaned") vpaned.set_position(int(mHeight/2)) @@ -1006,7 +941,7 @@ class MainWindow (Window): # notebook self.notebook = self.tree.get_widget("notebook") - self.window.show_all() + #self.window.show_all() # table self.packageTable = PackageTable(self) @@ -1040,7 +975,8 @@ class MainWindow (Window): self.queue = EmergeQueue(console = self.console, tree = self.queueTree, db = self.db, title_update = self.title_update, threadClass = GtkThread) self.window.maximize() - + self.window.show_all() + def show_package (self, *args, **kwargs): self.packageTable.update(*args, **kwargs) self.notebook.set_current_page(self.PKG_PAGE) diff --git a/portato/gui/templates/portato.glade b/portato/gui/templates/portato.glade index 31d5805..fe57c9a 100644 --- a/portato/gui/templates/portato.glade +++ b/portato/gui/templates/portato.glade @@ -1805,4 +1805,62 @@ uses code from: Daniel J. Popowich + + 300 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + GTK_WIN_POS_CENTER_ALWAYS + GDK_WINDOW_TYPE_HINT_SPLASHSCREEN + True + True + True + False + False + False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 20 + 20 + 20 + 20 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-missing-image + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + label + True + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + label + True + + + 2 + + + + + + + -- cgit v1.2.3-54-g00ecf