Remove Bluetooth UI, make Bluetooth detection automatic

Remove the preferences UI for bluetooth sending, make
sure Bluetooth support is automatically activated when
the necessary tools are available.

Keep advanced configuration options for Bluetooth.
This commit is contained in:
Thomas Perl 2008-11-19 20:50:38 +01:00
parent 03d1029c35
commit 6d96263c51
5 changed files with 20 additions and 442 deletions

View File

@ -4261,403 +4261,6 @@ MTP-based player</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table13">
<property name="border_width">10</property>
<property name="visible">True</property>
<property name="n_rows">8</property>
<property name="n_columns">4</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkImage" id="image2929">
<property name="visible">True</property>
<property name="icon_size">6</property>
<property name="icon_name">bluetooth</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">4</property>
<property name="x_padding">6</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label115">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Bluetooth Support&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">4</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="bluetooth_enabled">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable Bluetooth support</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="bluetooth_ask_always">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Ask for device when sending</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator17">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="bluetooth_ask_never">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Always send to</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">bluetooth_ask_always</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="bluetooth_device_name">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Nokia N800&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="bluetooth_select_device">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_bluetooth_select_device_clicked" last_modification_time="Wed, 16 Jan 2008 12:24:17 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment23">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox36">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image2930">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label118">
<property name="visible">True</property>
<property name="label" translatable="yes">Select device</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label116">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;File Conversion Script&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">4</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="bluetooth_use_converter">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use converter:</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="bluetooth_converter">
<property name="visible">True</property>
<property name="title" translatable="yes">Select A Converter Script</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
<property name="local_only">True</property>
<property name="show_hidden">False</property>
<property name="do_overwrite_confirmation">False</property>
<property name="width_chars">-1</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkImage" id="image2931">
<property name="visible">True</property>
<property name="icon_size">6</property>
<property name="icon_name">text-x-script</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image2928">
<property name="visible">True</property>
<property name="icon_size">3</property>
<property name="icon_name">bluetooth</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label114">
<property name="visible">True</property>
<property name="label" translatable="yes">Bluetooth</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table12">
<property name="border_width">10</property>

View File

@ -83,10 +83,7 @@ gPodderSettings = {
'on_quit_ask': (bool, True),
# Bluetooth-related settings
'bluetooth_enabled': (bool, False),
'bluetooth_ask_always': (bool, True),
'bluetooth_ask_never': (bool, False),
'bluetooth_device_name': (str, 'No device'),
'bluetooth_use_device_address': (bool, False),
'bluetooth_device_address': (str, '00:00:00:00:00:00'),
'bluetooth_use_converter': (bool, False),
'bluetooth_converter': (str, ''),

View File

@ -876,10 +876,10 @@ class gPodder(GladeWidget):
episode = self.active_channel.find_episode(url)
filename = episode.local_filename()
if gl.config.bluetooth_ask_always:
device = None
else:
if gl.config.bluetooth_use_device_address:
device = gl.config.bluetooth_device_address
else:
device = None
destfile = os.path.join(gl.tempdir, util.sanitize_filename(episode.sync_filename()))
(base, ext) = os.path.splitext(filename)
@ -1001,7 +1001,7 @@ class gPodder(GladeWidget):
item.set_image(gtk.image_new_from_stock(gtk.STOCK_SAVE_AS, gtk.ICON_SIZE_MENU))
item.connect( 'activate', lambda w: self.for_each_selected_episode_url(self.save_episode_as_file))
menu.append(self.set_finger_friendly(item))
if gl.config.bluetooth_enabled:
if gl.bluetooth_available:
item = gtk.ImageMenuItem(_('Send via bluetooth'))
item.set_image(gtk.image_new_from_icon_name('bluetooth', gtk.ICON_SIZE_MENU))
item.connect('activate', lambda w: self.copy_episode_bluetooth(episode_url))
@ -2742,7 +2742,6 @@ class gPodderProperties(GladeWidget):
self.callback_finished = None
if gpodder.interface == gpodder.MAEMO:
self.table13.hide_all() # bluetooth
self.table5.hide_all() # player
self.gPodderProperties.fullscreen()
@ -2767,11 +2766,6 @@ class gPodderProperties(GladeWidget):
gl.config.connect_gtk_togglebutton('minimize_to_tray', self.minimize_to_tray)
gl.config.connect_gtk_togglebutton('enable_notifications', self.enable_notifications)
gl.config.connect_gtk_togglebutton('start_iconified', self.start_iconified)
gl.config.connect_gtk_togglebutton('bluetooth_enabled', self.bluetooth_enabled)
gl.config.connect_gtk_togglebutton('bluetooth_ask_always', self.bluetooth_ask_always)
gl.config.connect_gtk_togglebutton('bluetooth_ask_never', self.bluetooth_ask_never)
gl.config.connect_gtk_togglebutton('bluetooth_use_converter', self.bluetooth_use_converter)
gl.config.connect_gtk_filechooser( 'bluetooth_converter', self.bluetooth_converter, is_for_files=True)
gl.config.connect_gtk_togglebutton('ipod_write_gtkpod_extended', self.ipod_write_gtkpod_extended)
gl.config.connect_gtk_togglebutton('mp3_player_delete_played', self.delete_episodes_marked_played)
@ -2782,7 +2776,6 @@ class gPodderProperties(GladeWidget):
self.iPodMountpoint.set_label( gl.config.ipod_mount)
self.filesystemMountpoint.set_label( gl.config.mp3_player_folder)
self.bluetooth_device_name.set_markup('<b>%s</b>'%gl.config.bluetooth_device_name)
self.chooserDownloadTo.set_current_folder(gl.downloaddir)
self.on_sync_delete.set_sensitive(not self.delete_episodes_marked_played.get_active())
@ -2846,36 +2839,6 @@ class gPodderProperties(GladeWidget):
else:
self.iPodMountpoint.set_label( ipod.mount_point)
def on_bluetooth_select_device_clicked(self, widget):
# Stupid GTK doesn't provide us with a method to directly
# edit the text of a gtk.Button without "destroying" the
# image on it, so we dig into the button's widget tree and
# get the gtk.Image and gtk.Label and edit the label directly.
alignment = self.bluetooth_select_device.get_child()
hbox = alignment.get_child()
(image, label) = hbox.get_children()
old_text = label.get_text()
label.set_text(_('Searching...'))
self.bluetooth_select_device.set_sensitive(False)
while gtk.events_pending():
gtk.main_iteration(False)
# FIXME: Make bluetooth device discovery threaded, so
# the GUI doesn't freeze while we are searching for devices
found = False
for name, address in util.discover_bluetooth_devices():
if self.show_confirmation('Use this device as your bluetooth device?', name):
gl.config.bluetooth_device_name = name
gl.config.bluetooth_device_address = address
self.bluetooth_device_name.set_markup('<b>%s</b>'%gl.config.bluetooth_device_name)
found = True
break
if not found:
self.show_message('No more devices found', 'Scan finished')
self.bluetooth_select_device.set_sensitive(True)
label.set_text(old_text)
def find_active_audio_app(self):
model = self.comboAudioPlayerApp.get_model()
iter = model.get_iter_first()

View File

@ -117,6 +117,8 @@ class gPodderLib(object):
if self.config.videoplayer == 'unspecified':
self.config.videoplayer = self.config.player
self.bluetooth_available = util.bluetooth_available()
self.gpodder_dir = gpodder_dir
not db.setup({ 'database': os.path.join(gpodder_dir, 'database.sqlite'), 'gl': self })

View File

@ -764,6 +764,19 @@ def discover_bluetooth_devices():
return # <= empty generator
def bluetooth_available():
"""
Returns True or False depending on the availability
of bluetooth functionality on the system.
"""
if find_command('bluetooth-sendto'):
return True
elif find_command('gnome-obex-send'):
return True
else:
return False
def bluetooth_send_file(filename, device=None, callback_finished=None):
"""
Sends a file via bluetooth using gnome-obex send.