3
# Ubuntu Tweak - PyGTK based desktop configure 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
27
from tweak import TweakModule
28
from common.config import TweakSettings
29
from common.factory import WidgetFactory
30
from common.utils import get_icon_with_name
31
from common.widgets import ListPack
32
from common.widgets.dialogs import ErrorDialog, QuestionDialog
34
class Gnome(TweakModule):
35
__title__ = _('GNOME Settings')
36
__desc__ = _('A lot of GNOME settings about panel and others')
37
__icon__ = ['gnome-desktop-config', 'control-center2']
38
__category__ = 'desktop'
41
TweakModule.__init__(self)
43
self.__setting = TweakSettings()
45
changeicon_hbox = self.create_change_icon_hbox()
47
box = ListPack(_("Panel and Menu"), (
48
WidgetFactory.create("GconfCheckButton",
49
label = _("Display warning when removing a panel"),
50
key = "confirm_panel_remove"),
51
WidgetFactory.create("GconfCheckButton",
52
label = _("Complete lockdown of all panels"),
54
WidgetFactory.create("GconfCheckButton",
55
label = _("Enable panel animations"),
56
key = "enable_animations"),
57
WidgetFactory.create("GconfCheckButton",
58
label = _("Show Input Method menu on the context menu"),
59
key = "show_input_method_menu"),
60
WidgetFactory.create("GconfCheckButton",
61
label = _("Show Unicode Method menu on the context menu"),
62
key = "show_unicode_menu"),
66
self.add_start(box, False, False, 0)
68
box = ListPack(_("Screensaver"), (
69
WidgetFactory.create("GconfCheckButton",
70
label = _("Enable user switching when screen is locked."),
71
key = "user_switch_enabled"),
73
self.add_start(box, False, False, 0)
75
self.recently_used = gtk.CheckButton(_('Enable system-wide "Recently Documents" list'))
76
self.recently_used.connect('toggled', self.colleague_changed)
77
self.recently_used.set_active(self.get_state())
78
box = ListPack(_("History"), (
81
self.add_start(box, False, False, 0)
83
def create_change_icon_hbox(self):
84
hbox = gtk.HBox(False, 10)
85
label = gtk.Label(_('Click the button to change the menu logo'))
86
label.set_alignment(0, 0.5)
87
hbox.pack_start(label, False, False, 0)
90
button.connect('clicked', self.on_change_icon_clicked)
91
image = gtk.image_new_from_pixbuf(get_icon_with_name('start-here', 24))
92
button.set_image(image)
93
hbox.pack_end(button, False, False, 0)
97
def on_change_icon_clicked(self, widget):
98
dialog = gtk.FileChooserDialog(_('Choose a new logo'),action = gtk.FILE_CHOOSER_ACTION_OPEN, buttons = (gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
99
filter = gtk.FileFilter()
100
filter.set_name(_("PNG image (*.png)"))
101
filter.add_mime_type("image/png")
102
dialog.set_current_folder(os.path.expanduser('~'))
103
dialog.add_filter(filter)
105
dest = os.path.expanduser('~/.icons/%s/24x24/places/start-here.png' % self.__setting.get_icon_theme())
106
revert_button = dialog.action_area.get_children()[-1]
107
if not os.path.exists(dest):
108
revert_button.set_sensitive(False)
111
response = dialog.run()
112
if response == gtk.RESPONSE_ACCEPT:
113
filename = dialog.get_filename()
116
pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
117
w, h = pixbuf.get_width(), pixbuf.get_height()
118
if w != 24 or h != 24:
119
ErrorDialog(_("The size isn't suitable for the panel.\nIt should be 24x24.")).launch()
121
os.system('mkdir -p %s' % os.path.dirname(dest))
122
os.system('cp %s %s' % (filename, dest))
124
image = gtk.image_new_from_file(dest)
125
widget.set_image(image)
127
elif response == gtk.RESPONSE_DELETE_EVENT:
129
image = gtk.image_new_from_pixbuf(get_icon_with_name('start-here', 24))
130
widget.set_image(image)
136
dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
137
if dialog.run() == gtk.RESPONSE_YES:
138
os.system('killall gnome-panel')
143
file = os.path.join(os.path.expanduser("~"), ".recently-used.xbel")
144
if os.path.exists(file):
145
if os.path.isdir(file):
147
elif os.path.isfile(file):
152
def colleague_changed(self, widget):
153
enabled = self.recently_used.get_active()
154
file = os.path.expanduser("~/.recently-used.xbel")
156
os.system('rm -r %s' % file)
157
os.system('touch %s' % file)
159
os.system('rm -r %s' % file)
160
os.system('mkdir %s' % file)