def set_flattr_button(flattr, payment_url, widget_image, widget_button): if not flattr.api_reachable() or not payment_url: widget_image.hide() widget_button.hide() return False elif not flattr.has_token(): badge = IMAGE_FLATTR_GREY button_text = _('Sign in') return False flattrs, flattred = flattr.get_thing_info(payment_url) can_flattr_this = False if flattred: badge = IMAGE_FLATTRED button_text = _('Flattred') else: badge = IMAGE_FLATTR button_text = _('Flattr this') can_flattr_this = True widget_button.set_label(button_text) widget_button.set_sensitive(can_flattr_this) widget_button.show() draw.draw_flattr_button(widget_image, badge, flattrs) widget_image.show() return can_flattr_this
def set_flattr_button(cls, url, token, widget_image, widget_button): if not url: widget_image.hide() widget_button.hide() return False flattr_possible = False flattrs, flattred = cls.get_thing_info(url) if flattred is None or not token: badge = IMAGE_FLATTR_GREY button_text = _('Sign in') tooltip_text = _('Please sign in') elif flattred: badge = IMAGE_FLATTRED button_text = _('Flattred') tooltip_text = _('Already flattred') else: badge = IMAGE_FLATTR button_text = _('Flattr this') flattr_possible = True tooltip_text = _('Flattr this') widget_button.set_label(button_text) widget_button.set_sensitive(flattr_possible) widget_button.show() draw.draw_flattr_button(widget_image, badge, flattrs) tooltips = gtk.Tooltips() tooltips.set_tip(widget_image, tooltip_text, tip_private=None) widget_image.show() return flattr_possible