~ubuntu-branches/ubuntu/vivid/gpodder/vivid-proposed

« back to all changes in this revision

Viewing changes to src/gpodder/gtkui/main.py

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2014-03-20 21:41:43 UTC
  • mfrom: (5.2.30 sid)
  • Revision ID: package-import@ubuntu.com-20140320214143-f8ogn4hu7s9j7c43
Tags: 3.6.1-1
* New upstream release (Closes: #742191)
  - Fixes YouTube integration bug.
  - Use LC_ALL=C during manpage generation.
  - Add prefix to path in desktop file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
2
#
3
3
# gPodder - A media aggregator and podcast client
4
 
# Copyright (c) 2005-2013 Thomas Perl and the gPodder Team
 
4
# Copyright (c) 2005-2014 Thomas Perl and the gPodder Team
5
5
#
6
6
# gPodder is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
140
140
        self.episode_columns_menu = None
141
141
        self.config.add_observer(self.on_config_changed)
142
142
 
143
 
        self.sw_shownotes = gtk.ScrolledWindow()
144
 
        self.sw_shownotes.set_shadow_type(gtk.SHADOW_IN)
145
 
        self.sw_shownotes.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
143
        self.shownotes_pane = gtk.HBox()
 
144
        if shownotes.have_webkit and self.config.enable_html_shownotes:
 
145
            self.shownotes_object = shownotes.gPodderShownotesHTML(self.shownotes_pane)
 
146
        else:
 
147
            self.shownotes_object = shownotes.gPodderShownotesText(self.shownotes_pane)
146
148
 
147
149
        # Vertical paned for the episode list and shownotes
148
150
        self.vpaned = gtk.VPaned()
150
152
        self.vbox_episode_list.reparent(self.vpaned)
151
153
        self.vpaned.child_set_property(self.vbox_episode_list, 'resize', True)
152
154
        self.vpaned.child_set_property(self.vbox_episode_list, 'shrink', False)
153
 
        self.vpaned.pack2(self.sw_shownotes, resize=False, shrink=False)
 
155
        self.vpaned.pack2(self.shownotes_pane, resize=False, shrink=False)
154
156
        self.vpaned.show()
155
157
 
156
158
        # Minimum height for both episode list and shownotes
157
159
        self.vbox_episode_list.set_size_request(-1, 100)
158
 
        self.sw_shownotes.set_size_request(-1, 100)
 
160
        self.shownotes_pane.set_size_request(-1, 100)
159
161
 
160
162
        self.config.connect_gtk_paned('ui.gtk.state.main_window.episode_list_size',
161
163
                self.vpaned)
162
164
        paned.add2(self.vpaned)
163
165
 
164
 
        if self.config.enable_html_shownotes and shownotes.have_webkit:
165
 
            self.shownotes_object = shownotes.gPodderShownotesHTML(self.sw_shownotes)
166
 
        else:
167
 
            self.shownotes_object = shownotes.gPodderShownotesText(self.sw_shownotes)
168
 
 
169
 
        self.sw_shownotes.hide()
170
166
 
171
167
        self.new_episodes_window = None
172
168
 
191
187
        self.download_status_model = DownloadStatusModel()
192
188
        self.download_queue_manager = download.DownloadQueueManager(self.config)
193
189
 
194
 
        self.itemShowAllEpisodes.set_active(self.config.podcast_list_view_all)
195
190
        self.itemShowToolbar.set_active(self.config.show_toolbar)
196
191
        self.itemShowDescription.set_active(self.config.episode_list_descriptions)
197
192
 
200
195
        self.config.connect_gtk_spinbutton('limit_rate_value', self.spinLimitDownloads)
201
196
        self.config.connect_gtk_togglebutton('limit_rate', self.cbLimitDownloads)
202
197
 
203
 
        self.config.connect_gtk_togglebutton('podcast_list_sections', self.item_podcast_sections)
204
 
 
205
198
        # When the amount of maximum downloads changes, notify the queue manager
206
199
        changed_cb = lambda spinbutton: self.download_queue_manager.spawn_threads()
207
200
        self.spinMaxDownloads.connect('value-changed', changed_cb)
272
265
            self.update_podcast_list_model(updated_urls)
273
266
 
274
267
        # Do the initial sync with the web service
275
 
        util.idle_add(self.mygpo_client.flush, True)
 
268
        if self.mygpo_client.can_access_webservice():
 
269
            util.idle_add(self.mygpo_client.flush, True)
276
270
 
277
271
        # First-time users should be asked if they want to see the OPML
278
272
        if not self.channels:
886
880
                if self.hbox_search_episodes.get_property('visible'):
887
881
                    self.hide_episode_search()
888
882
                else:
889
 
                    self.sw_shownotes.hide()
 
883
                    self.shownotes_object.hide_pane()
890
884
            elif event.state & gtk.gdk.CONTROL_MASK:
891
885
                # Don't handle type-ahead when control is pressed (so shortcuts
892
886
                # with the Ctrl key still work, e.g. Ctrl+A, ...)
919
913
    def on_episode_list_selection_changed(self, selection):
920
914
        # Update the toolbar buttons
921
915
        self.play_or_download()
922
 
 
923
 
        rows = selection.count_selected_rows()
924
 
        if rows != 1:
925
 
            self.shownotes_object.set_episode(None)
926
 
        elif self.sw_shownotes.get_property('visible'):
927
 
            episode = self.get_selected_episodes()[0]
928
 
            self.shownotes_object.set_episode(episode)
 
916
        # and the shownotes
 
917
        self.shownotes_object.set_episodes(self.get_selected_episodes())
929
918
 
930
919
    def init_download_list_treeview(self):
931
920
        # enable multiple selection support
1513
1502
 
1514
1503
            menu = gtk.Menu()
1515
1504
 
1516
 
            item = gtk.ImageMenuItem(_('Episode details'))
1517
 
            item.set_image(gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU))
1518
 
            if len(selected_tasks) == 1:
1519
 
                row_reference, task = selected_tasks[0]
1520
 
                episode = task.episode
1521
 
                item.connect('activate', lambda item: self.show_episode_shownotes(episode))
1522
 
            else:
1523
 
                item.set_sensitive(False)
1524
 
            menu.append(item)
1525
 
            menu.append(gtk.SeparatorMenuItem())
1526
1505
            if can_force:
1527
1506
                menu.append(make_menu_item(_('Start download now'), gtk.STOCK_GO_DOWN, selected_tasks, download.DownloadTask.QUEUED, True, True))
1528
1507
            else:
1810
1789
            # Single item, add episode information menu item
1811
1790
            item = gtk.ImageMenuItem(_('Episode details'))
1812
1791
            item.set_image(gtk.image_new_from_stock( gtk.STOCK_INFO, gtk.ICON_SIZE_MENU))
1813
 
            item.connect('activate', lambda w: self.show_episode_shownotes(episodes[0]))
 
1792
            item.connect('activate', self.on_shownotes_selected_episodes)
1814
1793
            menu.append(item)
1815
1794
 
1816
1795
            menu.show_all()
1955
1934
        self.db.commit()
1956
1935
 
1957
1936
        # Flush updated episode status
1958
 
        self.mygpo_client.flush()
 
1937
        if self.mygpo_client.can_access_webservice():
 
1938
            self.mygpo_client.flush()
1959
1939
 
1960
1940
    def playback_episodes(self, episodes):
1961
1941
        # We need to create a list, because we run through it more than once
2627
2607
                    episodes_status_update.append(episode)
2628
2608
 
2629
2609
            # Notify the web service about the status update + upload
2630
 
            self.mygpo_client.on_delete(episodes_status_update)
2631
 
            self.mygpo_client.flush()
 
2610
            if self.mygpo_client.can_access_webservice():
 
2611
                self.mygpo_client.on_delete(episodes_status_update)
 
2612
                self.mygpo_client.flush()
2632
2613
 
2633
2614
            if callback is None:
2634
2615
                util.idle_add(finish_deletion, episode_urls, channel_urls)
2676
2657
        gPodderEpisodeSelector(self.gPodder, title = _('Delete episodes'), instructions = instructions, \
2677
2658
                                episodes = episodes, selected = selected, columns = columns, \
2678
2659
                                stock_ok_button = gtk.STOCK_DELETE, callback = self.delete_episode_list, \
2679
 
                                selection_buttons = selection_buttons, _config=self.config, \
2680
 
                                show_episode_shownotes=self.show_episode_shownotes)
 
2660
                                selection_buttons = selection_buttons, _config=self.config)
2681
2661
 
2682
2662
    def on_selected_episodes_status_changed(self):
2683
2663
        # The order of the updates here is important! When "All episodes" is
2791
2771
            if not episode.was_downloaded(and_exists=True):
2792
2772
                task_exists = False
2793
2773
                for task in self.download_tasks_seen:
2794
 
                    if episode.url == task.url and task.status not in (task.DOWNLOADING, task.QUEUED):
2795
 
                        self.download_queue_manager.add_task(task, force_start)
2796
 
                        enable_update = True
 
2774
                    if episode.url == task.url:
2797
2775
                        task_exists = True
2798
 
                        continue
 
2776
                        if task.status not in (task.DOWNLOADING, task.QUEUED):
 
2777
                            self.download_queue_manager.add_task(task, force_start)
 
2778
                            enable_update = True
 
2779
                            continue
2799
2780
 
2800
2781
                if task_exists:
2801
2782
                    continue
2822
2803
            self.enable_download_list_update()
2823
2804
 
2824
2805
        # Flush updated episode status
2825
 
        self.mygpo_client.flush()
 
2806
        if self.mygpo_client.can_access_webservice():
 
2807
            self.mygpo_client.flush()
2826
2808
 
2827
2809
    def cancel_task_list(self, tasks):
2828
2810
        if not tasks:
2873
2855
                remove_action=_('Mark as old'), \
2874
2856
                remove_finished=self.episode_new_status_changed, \
2875
2857
                _config=self.config, \
2876
 
                show_notification=False, \
2877
 
                show_episode_shownotes=self.show_episode_shownotes)
 
2858
                show_notification=False)
2878
2859
 
2879
2860
    def on_itemDownloadAllNew_activate(self, widget, *args):
2880
2861
        if not self.offer_new_episodes():
2889
2870
        """This will be called after the sync process is finished"""
2890
2871
        self.db.commit()
2891
2872
 
2892
 
    def on_itemShowAllEpisodes_activate(self, widget):
2893
 
        self.config.podcast_list_view_all = widget.get_active()
2894
 
 
2895
2873
    def on_itemShowToolbar_activate(self, widget):
2896
2874
        self.config.show_toolbar = self.itemShowToolbar.get_active()
2897
2875
 
3312
3290
 
3313
3291
    def on_shownotes_selected_episodes(self, widget):
3314
3292
        episodes = self.get_selected_episodes()
3315
 
        if episodes:
3316
 
            episode = episodes.pop(0)
3317
 
            if episode is not None:
3318
 
                self.show_episode_shownotes(episode)
3319
 
        else:
3320
 
            self.show_message(_('Please select an episode from the episode list to display shownotes.'), _('No episode selected'), widget=self.treeAvailable)
 
3293
        self.shownotes_object.toggle_pane_visibility(episodes)
3321
3294
 
3322
3295
    def on_download_selected_episodes(self, widget):
3323
3296
        episodes = self.get_selected_episodes()
3329
3302
        """Double-click/enter action handler for treeAvailable"""
3330
3303
        self.on_shownotes_selected_episodes(widget)
3331
3304
 
3332
 
    def show_episode_shownotes(self, episode):
3333
 
        self.shownotes_object.set_episode(episode)
3334
 
 
3335
3305
    def restart_auto_update_timer(self):
3336
3306
        if self._auto_update_timer_source_id is not None:
3337
3307
            logger.debug('Removing existing auto update timer.')
3355
3325
        self.update_feed_cache()
3356
3326
 
3357
3327
        # Ask web service for sub changes (if enabled)
3358
 
        self.mygpo_client.flush()
 
3328
        if self.mygpo_client.can_access_webservice():
 
3329
            self.mygpo_client.flush()
3359
3330
 
3360
3331
        return True
3361
3332