# -*- coding: utf-8 -*-
#
# File: portato/gui/gtk/windows.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 pygtk
pygtk.require("2.0")
import gtk
import gtk.glade
import gobject
# our backend stuff
from portato.helper import *
from portato.constants import CONFIG_LOCATION, VERSION, DATA_DIR, APP_ICON
from portato.backend import flags, system
from portato.backend.exceptions import *
# plugins
from portato import plugin
# more GUI stuff
from portato.gui.gui_helper import Database, Config, EmergeQueue
from dialogs import *
from wrapper import GtkTree, GtkConsole
from usetips import UseTips
# other
import types
GLADE_FILE = DATA_DIR+"portato.glade"
class Window:
def __init__ (self):
self.tree = gtk.glade.XML(GLADE_FILE, root = 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 create_popup (self, name):
popupTree = gtk.glade.XML(GLADE_FILE, root = name)
popupTree.signal_autoconnect(self)
return popupTree.get_widget(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 AboutWindow (AbstractDialog):
"""A window showing the "about"-informations."""
def __init__ (self, parent, plugins):
"""Constructor.
@param parent: the parent window
@type parent: gtk.Window"""
AbstractDialog.__init__(self, parent)
img = self.tree.get_widget("portatoImage")
img.set_from_file(APP_ICON)
hlabel = self.tree.get_widget("highAboutLabel")
hlabel.set_markup("""
<big><b>Portato v.%s</b></big>
A Portage-GUI""" % VERSION)
llabel = self.tree.get_widget("lowAboutLabel")
llabel.set_markup("""This software is licensed under the terms of the GPLv2.
Copyright (C) 2006-2007 René 'Necoro' Neumann <necoro@necoro.net>
Icon created by P4R4D0X
""")
view = self.tree.get_widget("pluginList")
store = gtk.ListStore(str,str)
view.set_model(store)
cell = gtk.CellRendererText()
col = gtk.T
|