summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to 'portato')
-rw-r--r--portato/backend/__init__.py5
-rw-r--r--portato/backend/package.py2
-rw-r--r--portato/backend/system_interface.py2
-rw-r--r--portato/constants.py2
-rw-r--r--portato/gui/gtk/__init__.py20
-rw-r--r--portato/gui/gtk/basic.py94
-rw-r--r--portato/gui/gtk/splash.py49
-rw-r--r--portato/gui/gtk/windows.py104
-rw-r--r--portato/gui/templates/portato.glade58
9 files changed, 241 insertions, 95 deletions
diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py
index c3de443..d1d61e8 100644
--- a/portato/backend/__init__.py
+++ b/portato/backend/__init__.py
@@ -16,14 +16,13 @@ from system_interface import SystemInterface
SYSTEM = "portage" # the name of the current system
_sys = None # the SystemInterface-instance
-class SystemWrapper (object, SystemInterface):
+class SystemWrapper (SystemInterface):
"""This is a wrapper to the different system interfaces, allowing the direct import via C{from portato.backend import system}.
With this wrapper a change of the system is propagated to all imports."""
def __getattribute__ (self, name):
"""Just pass all attribute accesses directly to _sys."""
- global _sys
- return eval ("_sys.%s" % name)
+ return getattr(_sys, name)
def set_system (new_sys):
"""Sets the current system to a new one.
diff --git a/portato/backend/package.py b/portato/backend/package.py
index 72cd671..ef0be11 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -13,7 +13,7 @@
from portato.backend import system
import flags
-class Package:
+class Package (object):
"""This is a class abstracting a normal package which can be installed."""
def __init__ (self, cpv):
diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py
index 3ce401c..4e9618b 100644
--- a/portato/backend/system_interface.py
+++ b/portato/backend/system_interface.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-class SystemInterface:
+class SystemInterface (object):
def split_cpv (self, cpv):
"""Splits a cpv into all its parts.
diff --git a/portato/constants.py b/portato/constants.py
index 80e7452..c21b0a5 100644
--- a/portato/constants.py
+++ b/portato/constants.py
@@ -32,6 +32,8 @@ These should be set during the installation.
@type ICON_DIR: string
@var APP_ICON: the path of the application icon
@type APP_ICON: string
+@var LOCALE_DIR: the path to the directory where the locale files (*.mo) are stored.
+@type LOCALE_DIR: string
@var FRONTENDS: the list of frontends which are installed
@type FRONTENDS: string[]
@var STD_FRONTEND: the frontend uses as the default, i.e. if no other one is given on the cmdline
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 <necoro@necoro.net>
-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 <necoro@necoro.net>
+
+# 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 <necoro@necoro.net>
+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("<b><big>Portato %s ...</big></b>" % 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 <necoro@necoro.net>
# 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</property>
</widget>
</child>
</widget>
+ <widget class="GtkWindow" id="SplashScreen">
+ <property name="width_request">300</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="resizable">False</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_SPLASHSCREEN</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="skip_pager_hint">True</property>
+ <property name="urgency_hint">True</property>
+ <property name="focus_on_map">False</property>
+ <property name="decorated">False</property>
+ <property name="deletable">False</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="top_padding">20</property>
+ <property name="bottom_padding">20</property>
+ <property name="left_padding">20</property>
+ <property name="right_padding">20</property>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="stock">gtk-missing-image</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="generalLabel">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label">label</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="descrLabel">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label">label</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>