1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00
PySolFC/pysollib/pysolgtk/toolbar.py
skomoroh 1a2ebe7884 * refactored menubar and toolbar imports
* refactored pysolrandom.py; added WHRandom generator
* bugfixes


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@215 39dd0a4e-7c14-0410-91b3-c4f2d318f732
2007-12-28 08:38:51 +00:00

165 lines
4.2 KiB
Python

## vim:ts=4:et:nowrap
##
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
##
## 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 2 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; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
## Markus F.X.J. Oberhumer
## <markus.oberhumer@jk.uni-linz.ac.at>
## http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html
##
##---------------------------------------------------------------------------##
# imports
import os, re, sys
import gtk
from gtk import gdk
# PySol imports
# /***********************************************************************
# //
# ************************************************************************/
class PysolToolbarTk:
def __init__(self, top, menubar, dir, size=0, relief=0, compound=None):
self.top = top
self.menubar = menubar
self.dir = dir
self.side = -1
ui_info = '''
<ui>
<toolbar name='toolbar'>
<toolitem action='newgame'/>
<toolitem action='restart'/>
<separator/>
<toolitem action='open'/>
<toolitem action='save'/>
<separator/>
<toolitem action='undo'/>
<toolitem action='redo'/>
<toolitem action='shuffle'/>
<toolitem action='autodrop'/>
<toolitem action='pause'/>
<separator/>
<toolitem action='stats'/>
<toolitem action='rules'/>
<separator/>
<toolitem action='quit'/>
</toolbar>
</ui>
'''
ui_manager = self.top.ui_manager # created in menubar.py
ui_manager_id = ui_manager.add_ui_from_string(ui_info)
toolbar = ui_manager.get_widget("/toolbar")
self.toolbar = toolbar
toolbar.set_tooltips(True)
toolbar.set_style(gtk.TOOLBAR_ICONS)
self._attached = False
#
# wrappers
#
def _busy(self):
return not (self.side and self.game and not self.game.busy and self.menubar)
def destroy(self):
self.toolbar.destroy()
#
# public methods
#
def getSide(self):
return self.side
def getSize(self):
return 0
def hide(self, resize=1):
self.show(0, resize)
def show(self, side=1, resize=1):
if self.side == side:
return 0
self.side = side
if not side:
# hide
self.toolbar.hide()
return 1
# show
if side == 1:
# top
x, y = 1, 1
elif side == 2:
# bottom
x, y = 1, 3
elif side == 3:
# left
x, y = 0, 2
else:
# right
x, y = 2, 2
# set orient
if side in (1, 2):
orient = gtk.ORIENTATION_HORIZONTAL
else:
orient = gtk.ORIENTATION_VERTICAL
self.toolbar.set_orientation(orient)
if self._attached:
self.top.table.remove(self.toolbar)
row_span, column_span = 1, 1
self.top.table.attach(self.toolbar,
x, x+1, y, y+1,
gtk.FILL, gtk.FILL,
0, 0)
self.toolbar.show()
self._attached = True
return 1
def setCursor(self, cursor):
if self.side:
if self.toolbar.window:
self.toolbar.window.set_cursor(gdk.Cursor(v))
def setRelief(self, relief):
# FIXME
pass
def updateText(self, **kw):
# FIXME
pass
def config(self, w, v):
# FIXME
pass