Skip to content

Commit

Permalink
Podcast dialog: Section changing and Flattr bug (bug 1636)
Browse files Browse the repository at this point in the history
The Flattr integration was causing the dialog to re-appear if
it is closed to quickly, because of its asynchronous nature,
so it has been ripped out for now.

Also, the section changing wasn't working, so instead of having
a comboboxentry, we now have a combo box and a button that will
open a text entry dialog and allow a new section name to be
entered. This will arguably also improve the user experience.
  • Loading branch information
thp committed Jul 31, 2012
1 parent f07c75f commit aa42c01
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 111 deletions.
133 changes: 43 additions & 90 deletions share/gpodder/ui/gtk/gpodderchannel.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-requires gtk+ 2.24 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="gPodderChannel">
<property name="can_focus">False</property>
Expand Down Expand Up @@ -59,7 +59,7 @@
<property name="can_focus">False</property>
<property name="border_width">10</property>
<property name="n_rows">5</property>
<property name="n_columns">3</property>
<property name="n_columns">4</property>
<property name="column_spacing">5</property>
<property name="row_spacing">10</property>
<child>
Expand All @@ -72,7 +72,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
Expand All @@ -89,7 +89,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="right_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
Expand All @@ -108,29 +108,6 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkComboBoxEntry" id="combo_section">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="text_column">0</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry2">
<property name="can_focus">False</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
</child>
</object>
<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>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property>
Expand All @@ -148,7 +125,7 @@
</child>
</object>
<packing>
<property name="right_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
Expand All @@ -165,7 +142,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
Expand All @@ -188,6 +165,43 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_add_section">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="on_button_add_section_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
</object>
</child>
</object>
<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">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combo_section">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<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">GTK_FILL</property>
</packing>
</child>
</object>
</child>
<child type="tab">
Expand Down Expand Up @@ -416,67 +430,6 @@
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator_flattr">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_flattr">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Flattr&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hboxFlattr">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="flattr_button">
<property name="label" translatable="yes">Flattr this</property>
<property name="visible">True</property>
<signal name="clicked" handler="on_flattr_button_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">start</property>
</packing>
</child>
<child>
<object class="GtkImage" id="flattr_image">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">start</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">start</property>
<property name="position">8</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
Expand Down
42 changes: 21 additions & 21 deletions src/gpodder/gtkui/desktop/channel.py
Expand Up @@ -25,7 +25,6 @@
_ = gpodder.gettext

from gpodder import util
from gpodder.gtkui import flattr

from gpodder.gtkui.interface.common import BuilderWidget

Expand All @@ -39,11 +38,17 @@ def new(self):
self.labelURL.set_text(self.channel.url)
self.cbSkipFeedUpdate.set_active(self.channel.pause_subscription)

self.combo_section.child.set_text(self.channel.section)
self.section_list = gtk.ListStore(str)
for section in sorted(self.sections):
active_index = 0
for index, section in enumerate(sorted(self.sections)):
self.section_list.append([section])
if section == self.channel.section:
active_index = index
self.combo_section.set_model(self.section_list)
cell_renderer = gtk.CellRendererText()
self.combo_section.pack_start(cell_renderer)
self.combo_section.add_attribute(cell_renderer, 'text', 0)
self.combo_section.set_active(active_index)

self.LabelDownloadTo.set_text( self.channel.save_dir)
self.LabelWebsite.set_text( self.channel.link)
Expand Down Expand Up @@ -75,7 +80,18 @@ def new(self):
self.imgCoverEventBox.connect('button-press-event',
self.on_cover_popup_menu)

self.set_flattr_information()
def on_button_add_section_clicked(self, widget):
text = self.show_text_edit_dialog(_('Add section'), _('New section:'),
affirmative_text=gtk.STOCK_ADD)

if text is not None:
for index, (section,) in enumerate(self.section_list):
if text == section:
self.combo_section.set_active(index)
return

self.section_list.append([text])
self.combo_section.set_active(len(self.section_list)-1)

def on_cover_popup_menu(self, widget, event):
if event.button != 3:
Expand Down Expand Up @@ -163,7 +179,7 @@ def on_btnOK_clicked(self, widget, *args):
self.clear_cover_cache(self.channel.url)
self.cover_downloader.request_cover(self.channel)

new_section = self.combo_section.child.get_text().strip()
new_section = self.section_list[self.combo_section.get_active()][0]
if self.channel.section != new_section:
self.channel.section = new_section
section_changed = True
Expand All @@ -177,19 +193,3 @@ def on_btnOK_clicked(self, widget, *args):
self.update_podcast_list_model(selected=True,
sections_changed=section_changed)

def set_flattr_information(self):
if self.channel.payment_url:
self.flattr_possible = flattr.set_flattr_button(self._flattr,
self.channel.payment_url, self._config.flattr.token,
self.flattr_image, self.flattr_button)
self.flattr_image.set_visible(True)
self.flattr_button.set_visible(True)
else:
self.flattr_image.set_visible(False)
self.flattr_button.set_visible(False)

def on_flattr_button_clicked(self, widget):
if self.flattr_possible:
success, message = self._flattr.flattr_url(self.channel.payment_url)
self.show_message(message, title=_('Flattr status'), important=not success)
self.set_flattr_information()

0 comments on commit aa42c01

Please sign in to comment.