1 # -*- coding: latin-1; -*-
3 # PgWorksheet - PostgreSQL Front End
4 # http://pgworksheet.projects.postgresql.org/
6 # Copyright © 2004-2005 Henri Michelon & CML http://www.e-cml.org/
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details (read LICENSE.txt).
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # $Id: __init__.py,v 1.8 2005/06/10 15:14:34 hmichelon Exp $
30 """Return TRUE is we run under Microsoft Windows"""
31 return sys
.platform
== "win32"
34 def get_user_encoding():
36 return "ISO-8859-1" #"UTF-8"
38 enc
= os
.environ
['MM_CHARSET']
42 enc
= os
.environ
['LANG']
45 enc
= os
.environ
['LC_LANG']
48 enc
= os
.environ
['LC_ALL']
51 parts
= string
.split(enc
, '.')
57 def set_proportional(buffer):
58 """Change the font of a widget to proportional"""
59 tagname
= 'font-' + str(buffer)
61 font
= buffer.create_tag(tagname
)
63 font
.set_property('font', 'Courier New 10')
65 font
.set_property('family', 'monospace')
66 buffer.apply_tag(font
, buffer.get_start_iter(), buffer.get_end_iter())
67 except TypeError: # tag already exists
68 buffer.apply_tag_by_name(tagname
, buffer.get_start_iter(), buffer.get_end_iter())
71 def get_user_configdir():
72 """Return the directory where the configuration file is stored"""
75 return os
.environ
['USERPROFILE']
78 return os
.environ
['ALLUSERSPROFILE']
80 return os
.environ
['SYSTEMROOT']
82 return os
.environ
['HOME']
85 def get_config_path():
86 return os
.path
.join(get_user_configdir(), '.pgworksheet')
93 class GObjectContainer(gobject
.GObject
):
94 def __init__(self
, data
):
95 gobject
.GObject
.__init
__(self
)
96 self
.set_data("key", data
)
99 return self
.get_data("key")
102 self
.set_data("key", data
)