1 # New device configuration UI draft
2 # Thomas Perl <thp@gpodder.org>; 2010-03-23
8 w
.set_default_size(400, 200)
10 v
.set_border_width(12)
14 sw
= gtk
.ScrolledWindow()
15 sw
.set_shadow_type(gtk
.SHADOW_IN
)
16 sw
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_AUTOMATIC
)
25 'on_sync_mark_played': bool,
26 'on_sync_delete': bool,
27 'disable_pre_sync_conversion': bool,
29 'delete_played': bool,
31 'playlist_absolute_path': bool,
32 'playlist_win_path': bool,
33 'use_scrobbler_log': bool,
34 'max_filename_length': int,
35 'custom_sync_name': str,
36 'only_sync_not_played': bool,
37 'channel_subfolders': bool,
38 'rockbox_copy_coverart': bool,
40 'purge_old_episodes': bool,
41 'delete_played_from_db': bool,
43 FOLDER
, IPOD
, MTP
= range(3)
45 def __init__(self
, type_
, name
, mountpoint
):
48 self
.mountpoint
= mountpoint
51 return '%s\n<small>%s</small>' % (self
.name
, self
.mountpoint
)
53 def get_icon(self
, images_folder
='data/images'):
54 if self
.type == self
.FOLDER
:
55 return os
.path
.join(images_folder
, 'folder.png')
56 elif self
.type == self
.IPOD
:
57 return os
.path
.join(images_folder
, 'ipod.png')
58 elif self
.type == self
.MTP
:
59 return os
.path
.join(images_folder
, 'mtp.png')
61 class DeviceList(gtk
.ListStore
):
62 C_DEVICE
, C_ICON
, C_NAME
= range(3)
65 gtk
.ListStore
.__init
__(self
, object, gtk
.gdk
.Pixbuf
, str)
67 def add_device(self
, device
):
68 pixbuf
= gtk
.gdk
.pixbuf_new_from_file(device
.get_icon())
69 self
.append((device
, pixbuf
, device
.get_markup()))
72 m
.add_device(Device(Device
.IPOD
, 'Apple iPod', '/media/ipod'))
73 m
.add_device(Device(Device
.FOLDER
, 'MP3 Player', '/media/mp3/Podcasts'))
74 m
.add_device(Device(Device
.MTP
, 'MTP Device', 'Using libmtp'))
77 tv
.set_headers_visible(False)
79 col
= gtk
.TreeViewColumn('')
81 cell
= gtk
.CellRendererPixbuf()
82 col
.pack_start(cell
, False)
83 col
.add_attribute(cell
, 'pixbuf', DeviceList
.C_ICON
)
84 cell
= gtk
.CellRendererText()
85 col
.pack_start(cell
, True)
86 col
.add_attribute(cell
, 'markup', DeviceList
.C_NAME
)
94 v
.pack_start(h
, False, False)
96 for s
in (gtk
.STOCK_ADD
, gtk
.STOCK_EDIT
, gtk
.STOCK_REMOVE
):
97 i
= gtk
.image_new_from_stock(s
, gtk
.ICON_SIZE_BUTTON
)
100 h
.pack_start(b
, False, False)
103 w
.connect('destroy', gtk
.main_quit
)