~ubuntu-branches/ubuntu/jaunty/gdesklets/jaunty-updates

« back to all changes in this revision

Viewing changes to config/ConfigDialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Deng Xiyue
  • Date: 2008-09-02 22:00:17 UTC
  • mfrom: (2.1.18 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080902220017-m66bj19l0ll8x7yh
Tags: 0.36-5
* Redo 40_dont_update_mime.diff to use a more compact syntax by 
  Loïc Minier's suggestion.  Thanks lool.
* Regenerate 70_relibtoolize.diff accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from ConfigBoolean import ConfigBoolean
2
2
from ConfigButton import ConfigButton
3
3
from ConfigColor import ConfigColor
 
4
from ConfigDate import ConfigDate
4
5
from ConfigEnum import ConfigEnum
5
6
from ConfigFloat import ConfigFloat
6
7
from ConfigFont import ConfigFont
 
8
from ConfigInfo import ConfigInfo
7
9
from ConfigInteger import ConfigInteger
 
10
from ConfigList import ConfigList
 
11
from ConfigRadio import ConfigRadio
8
12
from ConfigString import ConfigString
9
13
from ConfigTitle import ConfigTitle
10
14
from ConfigUnit import ConfigUnit
17
21
 
18
22
import gtk
19
23
import gobject
20
 
 
 
24
import os
 
25
import os.path
21
26
 
22
27
 
23
28
class ConfigDialog(HIGDialog):
30
35
    __ITEM_TABLE = {"boolean": ConfigBoolean,
31
36
                    "button": ConfigButton,
32
37
                    "color": ConfigColor,
 
38
                    "date": ConfigDate,
33
39
                    "enum": ConfigEnum,
34
40
                    "float": ConfigFloat,
35
41
                    "font": ConfigFont,
 
42
                    "info": ConfigInfo,
36
43
                    "integer": ConfigInteger,
 
44
                    "list": ConfigList,
 
45
                    "radio": ConfigRadio,
37
46
                    "string": ConfigString,
38
47
                    "title": ConfigTitle,
39
48
                    "unit": ConfigUnit,
44
53
                    }
45
54
 
46
55
 
47
 
    def __init__(self):
 
56
    def __init__(self, path):
48
57
 
49
58
        # the instantiated items
50
59
        self.__children = []
60
69
        # a banner
61
70
        self.__banner = None
62
71
 
 
72
        self.__path = path
63
73
 
64
74
        HIGDialog.__init__(self, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE),
65
75
                           self_destroy = False)
189
199
        ebox.show()
190
200
 
191
201
        if (len(widgets) == 2):
 
202
 
192
203
            page.attach(widgets[0], 0, 1, page_lines - 1, page_lines,
193
 
                        gtk.FILL, 0, indent, 3)
 
204
                        gtk.FILL, gtk.FILL, indent, 3)
194
205
            ebox.add(widgets[1])
195
206
            page.attach(ebox, 1, 2, page_lines - 1, page_lines,
196
 
                        gtk.EXPAND | gtk.FILL, 0, 0, 3)
 
207
                        gtk.EXPAND | gtk.FILL, 0, indent, 3)
197
208
 
198
209
        else:
199
210
            ebox.add(widgets[0])
237
248
                    self.vbox.pack_start(align, False, False, 0)
238
249
 
239
250
                label = settings.get("label", "")
240
 
                tab = gtk.Label(label)
 
251
                tab = gtk.HBox(False, 0)
 
252
                tab.set_border_width(2)
 
253
 
 
254
                labelbox = gtk.Label(label)
 
255
 
 
256
                tab.pack_end(labelbox, True, True, 3)
 
257
 
 
258
                image = gtk.Image()
 
259
                icon = settings.get("icon", "")
 
260
                if (icon):
 
261
                    icon = os.path.join(self.__path, icon)
 
262
 
 
263
                # scale down images that are higher than the label
 
264
                if os.path.exists(icon):
 
265
                    (labelx, labely) = labelbox.size_request()
 
266
                    pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.realpath(icon))
 
267
                    icon_width = pixbuf.get_width()
 
268
                    icon_height = pixbuf.get_height()
 
269
                    if (icon_height > labely):
 
270
                        icon_aspectratio = float(icon_width) / icon_height
 
271
                        icon_height = labely
 
272
                        icon_width = int(icon_aspectratio * icon_height)
 
273
                    scaled_buf = pixbuf.scale_simple(icon_width,icon_height,gtk.gdk.INTERP_BILINEAR)
 
274
                    image.set_from_pixbuf(scaled_buf)
 
275
                    tab.pack_start(image, False, False, 3)
 
276
                    image.show()
 
277
 
 
278
                labelbox.show() 
241
279
                tab.show()
242
280
                box = gtk.VBox()
243
281
                box.set_property("border-width", 12)
259
297
                configitem = self.__create_config_item(itype, settings)
260
298
                if (not configitem): continue
261
299
 
262
 
                widgets = configitem.get_widgets()
 
300
                if (itype == "radio"): widgets = configitem.get_widgets(item_list)
 
301
                else: widgets = configitem.get_widgets()
 
302
 
263
303
                if (itype not in ("title", "button")):
264
304
                    configitem.set_prop_from_string("bind", settings["bind"])
265
305
                if (itype == "enum"): configitem.set_prop("items", item_list)
 
306
                if (itype == "list"): configitem.set_prop("items", item_list)
 
307
                if (itype == "radio"): configitem.set_prop("items", item_list)
266
308
                for k, v in settings.items():
267
309
                    configitem.set_prop_from_string(k, v)
268
310