~tualatrix/ubuntu-tweak/arb-packaging

« back to all changes in this revision

Viewing changes to src/modules/icons.py

  • Committer: TualatriX
  • Date: 2009-10-22 14:14:56 UTC
  • Revision ID: git-v1:455f01496d7149fb9832dabdf1bf0eef506a0101
WIP, make most things works

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
# Ubuntu Tweak - PyGTK based desktop configure tool
4
 
#
5
 
# Copyright (C) 2007-2008 TualatriX <tualatrix@gmail.com>
6
 
#
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.
11
 
#
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.
16
 
#
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
20
 
 
21
 
import pygtk
22
 
pygtk.require("2.0")
23
 
import gtk
24
 
import gconf
25
 
 
26
 
from tweak import TweakModule
27
 
from common.consts import *
28
 
from common.factory import WidgetFactory
29
 
 
30
 
computer_icon = \
31
 
{
32
 
    "label" : _('Show "Computer" icon on desktop'),
33
 
    "rename" : _('Rename'),
34
 
    "visible" : "computer_icon_visible",
35
 
    "name" : "computer_icon_name",
36
 
    "icon" : "gnome-fs-client"
37
 
}
38
 
 
39
 
home_icon = \
40
 
{
41
 
    "label" : _('Show "Home Folder" icon on desktop'),
42
 
    "rename" : _('Rename'),
43
 
    "visible" : "home_icon_visible",
44
 
    "name" : "home_icon_name",
45
 
    "icon" : "gnome-fs-home"
46
 
}
47
 
    
48
 
trash_icon = \
49
 
{
50
 
    "label" : _('Show "Trash" icon on desktop'),
51
 
    "rename" : _('Rename'),
52
 
    "visible" : "trash_icon_visible",
53
 
    "name" : "trash_icon_name",
54
 
    "icon" : "gnome-fs-trash-empty"
55
 
}
56
 
 
57
 
desktop_icon = (computer_icon, home_icon, trash_icon)
58
 
 
59
 
class DesktopIcon(gtk.VBox):
60
 
    def __init__(self, item):
61
 
        gtk.VBox.__init__(self)
62
 
 
63
 
        self.show_button = WidgetFactory.create("GconfCheckButton", 
64
 
                                                label = item["label"], 
65
 
                                                key = item["visible"])
66
 
        self.show_button.connect('toggled', self.colleague_changed)
67
 
        self.pack_start(self.show_button, False, False, 0)
68
 
 
69
 
        self.show_hbox = gtk.HBox(False, 10)
70
 
        self.pack_start(self.show_hbox, False, False, 0)
71
 
 
72
 
        if not self.show_button.get_active():
73
 
            self.show_hbox.set_sensitive(False)
74
 
 
75
 
        icon = gtk.image_new_from_icon_name(item["icon"], gtk.ICON_SIZE_DIALOG)
76
 
        self.show_hbox.pack_start(icon, False, False, 0)
77
 
 
78
 
        self.rename_button = WidgetFactory.create("StrGconfCheckButton", 
79
 
                                                  label = item["rename"], 
80
 
                                                  key = item["name"])
81
 
        self.rename_button.connect('toggled', self.colleague_changed)
82
 
        vbox = gtk.VBox(False, 5)
83
 
        self.show_hbox.pack_start(vbox, False, False, 0)
84
 
        vbox.pack_start(self.rename_button, False, False, 0)
85
 
 
86
 
        self.entry = WidgetFactory.create("GconfEntry", key = item["name"])
87
 
        self.entry.connect('focus-out-event', self.entry_focus_out)
88
 
        if not self.rename_button.get_active():
89
 
            self.entry.set_sensitive(False)
90
 
        vbox.pack_start(self.entry, False, False, 0)
91
 
 
92
 
    def entry_focus_out(self, widget, event):
93
 
        self.entry.get_gsetting().set_string(self.entry.get_text())
94
 
 
95
 
    def colleague_changed(self, widget):
96
 
        self.show_hbox.set_sensitive(self.show_button.get_active())
97
 
        active = self.rename_button.get_active()
98
 
        if active:
99
 
            self.entry.set_sensitive(True)
100
 
            self.entry.grab_focus()
101
 
        else:
102
 
            self.entry.set_sensitive(False)
103
 
            self.entry.get_gsetting().unset()
104
 
            self.entry.set_text(_("Unset"))
105
 
 
106
 
class Icon(TweakModule):
107
 
    __title__ = _('Desktop Icon settings')
108
 
    __desc__ = _('Change your desktop icons behavir')
109
 
    __icon__ = 'user-desktop'
110
 
    __url__ = 'http://ubuntu-tweak.com'
111
 
    __category__ = 'desktop'
112
 
 
113
 
    def __init__(self):
114
 
        TweakModule.__init__(self)
115
 
 
116
 
        for item in desktop_icon:
117
 
            self.add_start(DesktopIcon(item), False, False, 0)
118
 
 
119
 
        button = WidgetFactory.create("GconfCheckButton", 
120
 
                                      label = _("Show \"Network\" icon on desktop"), 
121
 
                                      key = "network_icon_visible")
122
 
        self.add_start(button, False, False, 0)
123
 
 
124
 
        button = WidgetFactory.create("GconfCheckButton", 
125
 
                                      label = _("Show mounted volumes on desktop"),
126
 
                                      key = "volumes_visible")
127
 
        self.add_start(button, False, False, 0)
128
 
 
129
 
        button = WidgetFactory.create("GconfCheckButton",
130
 
                                      label = _('Use "Home Folder" as desktop (Logout for changes to take effect)'),
131
 
                                      key = "desktop_is_home_dir")
132
 
        self.add_start(button, False, False, 0)