3
# Ubuntu Tweak - PyGTK based desktop configuration tool
5
# Copyright (C) 2007-2008 TualatriX <tualatrix@gmail.com>
7
# Ubuntu Tweak is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# Ubuntu Tweak is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Ubuntu Tweak; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28
from ubuntutweak import system
29
from ubuntutweak.modules import TweakModule
30
from ubuntutweak.ui import ListPack, TablePack
31
from ubuntutweak.ui.dialogs import ErrorDialog, QuestionDialog, WarningDialog
33
from ubuntutweak.common.config import TweakSettings
34
from ubuntutweak.common.factory import WidgetFactory
35
from ubuntutweak.utils import icon
36
from ubuntutweak.conf.gconfsetting import GconfSetting
38
log = logging.getLogger("Gnome")
40
class Gnome(TweakModule):
41
__title__ = _('GNOME Settings')
42
__desc__ = _('A lot of GNOME settings for panels, menus and other desktop elements')
43
__icon__ = ['gnome-desktop-config', 'control-center2']
44
__category__ = 'desktop'
45
__desktop__ = ['gnome', 'une']
48
TweakModule.__init__(self)
50
self.__setting = TweakSettings()
52
changeicon_hbox = self.create_change_icon_hbox()
54
box = TablePack(_("Panel Settings"), (
55
WidgetFactory.create("GconfCheckButton",
56
label=_("Display warning when removing a panel"),
58
key="confirm_panel_remove"),
59
WidgetFactory.create("GconfCheckButton",
60
label=_("Complete lockdown of all panels"),
63
WidgetFactory.create("GconfCheckButton",
64
label=_("Enable panel animations"),
66
key="enable_animations"),
67
WidgetFactory.create('GconfComboBox',
68
label=_('Me Menu Setting'),
69
key='/system/indicator/me/display',
70
texts=[_("Don't Display"), _('Display user name'), _('Display real name')],
74
self.add_start(box, False, False, 0)
76
box = ListPack(_("Menu Settings"), (
77
WidgetFactory.create("GconfCheckButton",
78
label=_("Show Input Method menu in the context menu"),
80
key="show_input_method_menu"),
81
WidgetFactory.create("GconfCheckButton",
82
label=_("Show Unicode Control Character menu in the context menu"),
84
key="show_unicode_menu"),
85
WidgetFactory.create("GconfCheckButton",
86
label=_('Show icons in menus'),
88
key='/desktop/gnome/interface/menus_have_icons'),
89
WidgetFactory.create("GconfCheckButton",
90
label=_('Show icons on buttons'),
92
key='/desktop/gnome/interface/buttons_have_icons'),
95
self.add_start(box, False, False, 0)
97
box = ListPack(_("Screensaver"), (
98
WidgetFactory.create("GconfCheckButton",
99
label=_("Enable user switching whilst screen is locked."),
101
key="user_switch_enabled"),
103
self.add_start(box, False, False, 0)
105
current_terminal_profile_key = GconfSetting('/apps/gnome-terminal/global/default_profile')
106
current_terminal_profile = current_terminal_profile_key.get_value()
107
default_show_menubar_key = '/apps/gnome-terminal/profiles/%s/default_show_menubar' % current_terminal_profile
108
box = ListPack(_("Terminal"), (
109
WidgetFactory.create("GconfCheckButton",
110
label=_("Display menubar when Terminal starts up (for current profile)"),
112
key=default_show_menubar_key),
114
self.add_start(box, False, False, 0)
116
self.recently_used = gtk.CheckButton(_('Enable system-wide "Recent Documents" list'))
117
self.recently_used.connect('toggled', self.colleague_changed)
118
self.recently_used.set_active(self.get_state())
119
box = ListPack(_("History"), (
122
self.add_start(box, False, False, 0)
124
def create_change_icon_hbox(self):
125
hbox = gtk.HBox(False, 10)
126
label = gtk.Label(_('Click this button to change the menu logo image'))
127
label.set_alignment(0, 0.5)
128
hbox.pack_start(label, False, False, 0)
130
button = gtk.Button()
131
button.connect('clicked', self.on_change_icon_clicked)
132
image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here'))
133
button.set_image(image)
134
hbox.pack_end(button, False, False, 0)
138
def on_change_icon_clicked(self, widget):
139
dialog = gtk.FileChooserDialog(_('Choose a new logo image'),
140
action=gtk.FILE_CHOOSER_ACTION_OPEN,
141
buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
142
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
143
gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
144
filter = gtk.FileFilter()
145
filter.set_name(_("PNG images with 24x24 size or SVG images"))
146
filter.add_pattern('*.png')
147
filter.add_pattern('*.svg')
148
dialog.set_current_folder(os.path.expanduser('~'))
149
dialog.add_filter(filter)
151
if system.CODENAME == 'karmic':
152
dest = os.path.expanduser('~/.icons/%s/places/24/start-here' % self.__setting.get_icon_theme())
154
dest = os.path.expanduser('~/.icons/%s/apps/24/start-here' % self.__setting.get_icon_theme())
156
revert_button = dialog.action_area.get_children()[-1]
158
HAVE_ICON = os.path.exists(dest + '.png') or os.path.exists(dest + '.svg')
161
revert_button.set_sensitive(False)
164
response = dialog.run()
166
if response == gtk.RESPONSE_ACCEPT:
167
filename = dialog.get_filename()
171
ext = os.path.splitext(filename)[1]
172
log.debug('The select file name is: %s' % ext)
173
pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
174
w, h = pixbuf.get_width(), pixbuf.get_height()
177
if ext == '.png' and (w != 24 or h != 24):
178
ErrorDialog(_("This image size isn't suitable for the panel.\nIt should measure 24x24.")).launch()
181
os.system('mkdir -p %s' % os.path.dirname(dest))
182
os.system('cp %s %s' % (filename, dest))
185
pixbuf = pixbuf.scale_simple(24, 24, gtk.gdk.INTERP_BILINEAR)
186
image = gtk.image_new_from_pixbuf(pixbuf)
187
widget.set_image(image)
188
elif response == gtk.RESPONSE_DELETE_EVENT:
190
for dest in glob.glob(dest + '*'):
192
image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here', force_reload=True))
193
widget.set_image(image)
198
dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
199
if dialog.run() == gtk.RESPONSE_YES:
200
os.system('killall gnome-panel')
205
file = os.path.join(os.path.expanduser("~"), ".recently-used.xbel")
206
if os.path.exists(file):
207
if os.path.isdir(file):
209
elif os.path.isfile(file):
214
def colleague_changed(self, widget):
215
enabled = self.recently_used.get_active()
216
file = os.path.expanduser("~/.recently-used.xbel")
218
os.system('rm -r %s' % file)
219
os.system('touch %s' % file)
221
dialog = WarningDialog(_('Disabling "Recent Documents" may break other software, for example the history feature in VMware Player.'),
223
if dialog.run() == gtk.RESPONSE_YES:
224
os.system('rm -r %s' % file)
225
os.system('mkdir %s' % file)
227
widget.set_active(True)