def __init__(self, account=None, dialog=None): """Creates the account pane for configuring identi.ca accounts""" Gtk.VBox.__init__( self, False, 20 ) self.ui = Gtk.Builder() self.ui.set_translation_domain ("gwibber") self.ui.add_from_file (resources.get_ui_asset("gwibber-accounts-identica.ui")) self.ui.connect_signals(self) self.vbox_settings = self.ui.get_object("vbox_settings") self.pack_start(self.vbox_settings, False, False, 0) self.show_all() self.account = account or {} self.dialog = dialog self.window = dialog.dialog self.url_prefix = "https://identi.ca" has_secret_key = False if self.account.has_key("id") and self.account.has_key("access_token") \ and self.account.has_key("secret_token") and self.account.has_key("username"): if self.account["secret_token"] and self.account["access_token"]: has_secret_key = get_from_keyring(self.account['id'], 'secret_token') is not None try: if has_secret_key: self.ui.get_object("hbox_statusnet_auth").hide() self.ui.get_object("statusnet_auth_done_label").set_label(_("%s has been authorized by %s") % (self.account["username"])) self.ui.get_object("hbox_statusnet_auth_done").show() else: self.ui.get_object("hbox_statusnet_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object('vbox_create').hide() except: self.ui.get_object("hbox_statusnet_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object("vbox_create").hide()
def populate_account_tree(self): self.account_store.clear() accounts = json.loads(self.gwibber.GetAccounts()) for account in accounts: try: icon = self.get_icon(account["service"]) if account.has_key("site_display_name"): name = account["site_display_name"] else: name = "%s (%s)" % (self.services[account["service"]]["name"], account["username"]) private_fields = [f.split(":")[-1] for f in self.services[account["service"]]["config"] if ":" in f] color = None for f in private_fields: if not account.has_key(f) or account[f] is None: account[f] = ":KEYRING:MISSING" if account[f].startswith(":KEYRING:"): value = keyring.get_from_keyring(account["id"], f) if value is None or account[f] == ":KEYRING:MISSING": color = "pink" if account["id"] not in self.selected_account: self.selected_account.append (account["id"]) self.condition = "error" self.account_store.append(None, [name, icon, account, color]) except: pass self.select_account()
def __init__(self, account=None, dialog=None): """Creates the account pane for configuring facebook accounts""" Gtk.VBox.__init__( self, False, 20 ) self.ui = Gtk.Builder() self.ui.set_translation_domain ("gwibber") self.ui.add_from_file (resources.get_ui_asset("gwibber-accounts-facebook.ui")) self.ui.connect_signals(self) self.vbox_settings = self.ui.get_object("vbox_settings") self.pack_start(self.vbox_settings, False, False, 0) self.show_all() if account: self.account = account else: self.account = {} self.dialog = dialog self.window = dialog.dialog has_access_token = False if self.account.has_key("id"): has_secret_key = get_from_keyring(self.account['id'], 'secret_token') is not None try: if self.account["access_token"] and self.account["username"] and has_access_token and not self.dialog.condition: self.ui.get_object("hbox_facebook_auth").hide() self.ui.get_object("fb_auth_done_label").set_label(_("%s has been authorized by Facebook") % str(self.account["username"])) self.ui.get_object("hbox_facebook_auth_done").show() else: self.ui.get_object("hbox_facebook_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object('vbox_create').hide() except: self.ui.get_object("hbox_facebook_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object("vbox_create").hide()
def __init__(self, account=None, dialog=None): """Creates the account pane for configuring Twitter accounts""" Gtk.VBox.__init__(self, False, 20) self.ui = Gtk.Builder() self.ui.set_translation_domain("gwibber") self.ui.add_from_file(resources.get_ui_asset("gwibber-accounts-twitter.ui")) self.ui.connect_signals(self) self.vbox_settings = self.ui.get_object("vbox_settings") self.pack_start(self.vbox_settings, True, True, 0) self.show_all() self.account = account or {} self.dialog = dialog self.window = dialog.dialog has_secret_key = False if self.account.has_key("id"): has_secret_key = get_from_keyring(self.account["id"], "secret_token") is not None try: if ( self.account.has_key("access_token") and self.account.has_key("secret_token") and self.account.has_key("username") and has_secret_key and not self.dialog.condition ): self.ui.get_object("hbox_twitter_auth").hide() self.ui.get_object("twitter_auth_done_label").set_label( _("%s has been authorized by Twitter") % self.account["username"] ) self.ui.get_object("hbox_twitter_auth_done").show() else: self.ui.get_object("hbox_twitter_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object("vbox_create").hide() except: self.ui.get_object("hbox_twitter_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object("vbox_create").hide()
def account_show(self, service_id, icon=None, account=None, condition=None, message=None): if hasattr(Gtk, "InfoBar"): if condition == "error": self.infobar.set_message_type(Gtk.MessageType.ERROR) if condition == "info": self.infobar.set_message_type(Gtk.MessageType.INFO) if message and condition: if hasattr(self, "infobar_content_area"): for child in self.infobar_content_area.get_children(): child.destroy() self.infobar_content_area = self.infobar.get_content_area() message_label = Gtk.Label(message) message_label.set_use_markup(True) message_label.set_ellipsize(Pango.EllipsizeMode.END) self.infobar_content_area.add(message_label) self.infobar.show_all() else: self.infobar.hide() vbox_account = self.ui.get_object('vbox_account') for child in vbox_account.get_children(): child.destroy() self.ui.get_object('vbox_details').show() self.ui.get_object('vbox_account').show() self.ui.get_object('frame_new_account').hide() service = self.services[service_id] self.ui.get_object('label_name').set_label(service["name"]) if icon: self.ui.get_object('image_type').set_from_pixbuf(self.get_icon(service_id)) if service_id in globals(): if not account: account = {"service": service_id} is_new = True else: is_new = False aw = globals()[service_id].AccountWidget(account, self) vbox_account.pack_start(aw, False, False, 0) vbox_account.show() if "color" not in account: account["color"] = service["color"] for config in service["config"]: is_private = config.startswith("private:") config = config.replace("private:", "") if config in account: value = account[config] widget = aw.ui.get_object(config) if isinstance(widget, Gtk.Entry): if is_private and account[config].startswith(":KEYRING:"): value = keyring.get_from_keyring(account["id"], config) if not value: widget.modify_base(Gtk.StateType.NORMAL, Gdk.Color.parse("pink")[1]) if value: widget.set_text(value) widget.connect("changed", self.on_edit_account) elif isinstance(widget, Gtk.CheckButton): widget.set_active(value) widget.connect("toggled", self.on_edit_account) elif isinstance(widget, Gtk.ColorButton): parsed, color = Gdk.Color.parse(value) widget.set_color(color) widget.connect("color-set", self.on_edit_account) self.account = account self.account_widget = aw if not is_new: self.ui.get_object('vbox_create').hide()