def on_edit_account_save(self, widget=None): print "Saving..." service = self.services[self.account["service"]] is_new = "id" not in self.account if is_new: self.account["id"] = uuid.uuid1().hex for config in service["config"]: is_private = config.startswith("private:") config = config.replace("private:", "") widget = self.account_widget.ui.get_object(config) value = None for p in ["text", "active"]: if widget and hasattr(widget.props, p): value = getattr(widget.props, p) self.account[config] = value if widget and isinstance(widget, gtk.ColorButton): value = widget.get_color () self.account[config] = value if is_private and self.account.has_key(config): if not self.account[config].startswith(":KEYRING:"): self.account[config] = ":KEYRING:%s" % self.put_in_keyring( self.account["id"], config, self.account[config]) if value: if isinstance(value, gtk.gdk.Color): value = gtk.color_selection_palette_to_string( gtk.color_selection_palette_from_string(value.to_string())) self.account[config] = value if not self.verify_account(self.account): return False fn = "Create" if is_new else "Update" getattr(self.gwibber.accounts, fn)(json.dumps(self.account)) self.ui.get_object('vbox_save').hide() self.ui.get_object('vbox_create').hide() # if we just fixed a failure case, hide the infobar if self.account["id"] == self.selected_account: if hasattr(gtk, "InfoBar"): self.infobar.hide() self.selected_account = None self.populate_account_tree() # Set the autostart gsettings key so we get loaded on login state = subprocess.Popen(['gsettings', 'get', state_interface, 'run'], stdout=subprocess.PIPE) res = state.communicate()[0] if "false" in res: subprocess.call(['gsettings', 'set', state_interface, 'run', 'true']) subprocess.call(['gsettings', 'set', settings_interface, 'autostart', 'true']) return True
def account_show(self, service_id, icon=None, account=None): 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(icon) 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.ui) vbox_account.pack_start(aw, False, False) 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 = self.get_from_keyring(account["id"], config) if not value: widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("pink")) 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): widget.set_color(gtk.color_selection_palette_from_string(value)[0]) 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()
def on_edit_account_save(self, widget=None): print "Saving..." service = self.services[self.account["service"]] is_new = "id" not in self.account if is_new: self.account["id"] = uuid.uuid1().hex for config in service["config"]: is_private = config.startswith("private:") config = config.replace("private:", "") widget = self.account_widget.ui.get_object(config) value = None for p in ["text", "active", "color"]: if widget and hasattr(widget.props, p): value = getattr(widget.props, p) self.account[config] = value if is_private and self.account.has_key(config): if not self.account[config].startswith(":KEYRING:"): self.account[config] = ":KEYRING:%s" % self.put_in_keyring( self.account["id"], config, self.account[config]) if value: if isinstance(value, gtk.gdk.Color): value = gtk.color_selection_palette_to_string( gtk.color_selection_palette_from_string(value.to_string())) self.account[config] = value if not self.verify_account(self.account): return False fn = "Create" if is_new else "Update" getattr(self.gwibber.accounts, fn)(json.dumps(self.account)) self.ui.get_object('vbox_save').hide() self.ui.get_object('vbox_create').hide() # if we just fixed a failure case, hide the infobar if self.account["id"] == self.selected_account: if hasattr(gtk, "InfoBar"): self.infobar.hide() self.selected_account = None self.populate_account_tree() # Set the autostart gconf key so we get loaded on login gc = gconf.client_get_default() if gc.get("/apps/gwibber/preferences/autostart") is None: gc.set_bool("/apps/gwibber/preferences/autostart", True) return True
def openDialog(self, bgcolor): self.Dialog.show_all() #gdkColor = gtk.gdk.Color() gdkColor = gtk.color_selection_palette_from_string(bgcolor) self.walkTree.get_widget('color_selection').set_current_color( gdkColor[0]) result = self.Dialog.run() if result == gtk.RESPONSE_OK: gtkColor = self.walkTree.get_widget( 'color_selection').get_current_color() bgcolor = gtk.color_selection_palette_to_string([gtkColor]) self.Dialog.destroy() return bgcolor
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.MESSAGE_ERROR) if condition == "info": self.infobar.set_message_type(gtk.MESSAGE_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.ELLIPSIZE_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(icon) 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) 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 = self.get_from_keyring(account["id"], config) if not value: widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("pink")) 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): widget.set_color(gtk.color_selection_palette_from_string(value)[0]) 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()