def __init__(self, selected_account=None, condition=None, message=None): self.selected_account = selected_account self.condition = condition self.message = message self.gwibber = GwibberPublic() self.services = json.loads(self.gwibber.GetServices()) self.ui = gtk.Builder() self.ui.set_translation_domain("gwibber") self.ui.add_from_file(resources.get_ui_asset("gwibber-accounts-dialog.ui")) self.ui.connect_signals(self) dialog = self.ui.get_object("accounts_dialog") dialog.resize(640,400) dialog.set_icon_from_file(resources.get_ui_asset("gwibber.svg")) dialog.show_all() if hasattr(gtk, "InfoBar"): self.alignment_infobar = self.ui.get_object("alignment_infobar") self.infobar = gtk.InfoBar() self.alignment_infobar.add(self.infobar) self.infobar.hide() # Hide the help button until we have help :) button_help = self.ui.get_object("button_help") button_help.hide() # This should check for configured accounts, and if there are any hide this self.ui.get_object('frame_new_account').hide() self.ui.get_object('vbox_save').hide() self.ui.get_object('vbox_create').hide() self.setup_account_tree() self.populate_account_tree() self.select_account()
def get_service_icon(name, size=16): theme = gtk.icon_theme_get_default() finfo = theme.lookup_icon(name, size, 0) if finfo: return finfo.get_filename() else: finfo = resources.get_ui_asset("icons/breakdance/%sx%s/%s.png" % (size,size,name)) if finfo: return finfo else: finfo = resources.get_ui_asset("icons/%sx%s/%s.png" % (size,size,name)) return finfo
def get_service_icon(name, size=16): theme = Gtk.IconTheme.get_default() finfo = theme.lookup_icon(name, size, 0) if finfo: return finfo.get_filename() else: finfo = resources.get_ui_asset("icons/breakdance/%sx%s/%s.png" % (size,size,name)) if finfo: return finfo else: finfo = resources.get_ui_asset("icons/%sx%s/%s.png" % (size,size,name)) return finfo
def set_stream(self, stream): self.selected_stream = stream self.nav_label.set_text(stream["name"]) is_search = stream["stream"] == "search" and not stream["transient"] self.search_box.set_visible(not is_search) if stream["account"]: fname = resources.get_ui_asset("icons/breakdance/16x16/%s.png" % stream["service"]) self.icon_protocol.set_from_file(fname) else: self.icon_protocol.clear() if stream["stream"]: fname = resources.get_ui_asset("icons/streams/16x16/%s.png" % stream["stream"]) self.icon_stream.set_from_file(fname) else: self.icon_stream.clear()
def on_about(self, *args): self.ui.add_from_file (resources.get_ui_asset("gwibber-about-dialog.ui")) about_dialog = self.ui.get_object("about_dialog") about_dialog.set_version(str(VERSION_NUMBER)) about_dialog.set_transient_for(self) about_dialog.connect("response", lambda *a: about_dialog.hide()) about_dialog.show_all()
def on_about(self, *args): self.ui.add_from_file( resources.get_ui_asset("gwibber-about-dialog.ui")) about_dialog = self.ui.get_object("about_dialog") about_dialog.set_version(str(VERSION_NUMBER)) about_dialog.set_transient_for(self) about_dialog.connect("response", lambda *a: about_dialog.hide()) about_dialog.show_all()
def __init__(self): self.ui = gtk.Builder() self.ui.set_translation_domain("gwibber") self.ui.add_from_file( resources.get_ui_asset("gwibber-preferences-dialog.ui")) self.ui.connect_signals(self) self.gc = gconf.client_get_default() dialog = self.ui.get_object("prefs_dialog") dialog.set_icon_from_file(resources.get_ui_asset("gwibber.svg")) self.settings = config.Preferences() setting_keys = [ "autostart", "show_notifications", "notify_mentions_only", "no_notifications", "show_fullname", "shorten_urls", "reply_append_colon", "global_retweet", "interval", "minimize_to_tray", "hide_taskbar_entry", "show_tray_icon", ] for key in setting_keys: self.settings.bind(self.ui.get_object(key), key) self.populate_settings_widgets() for key in ["theme", "urlshorter", "retweet_style"]: # Don't blow up if these values aren't set to something expected # just reset to the default and carry on try: self.settings.bind(getattr(self, key + "_selector"), key) except: config.GCONF.set_value( config.GCONF_PREFERENCES_DIR + "/" + key, self.settings.defaults[key]) self.settings.bind(getattr(self, key + "_selector"), key) dialog.show_all()
def __init__(self, data=None): gtk.InfoBar.__init__(self) self.service = microblog.util.getbus("Service") self.set_message_type(gtk.MESSAGE_ERROR) #self.set_no_show_all(True) self.account = data["error"]["account"] content_area = self.get_content_area() #if not account.has_key("service"): # icon = gtk.image_new_from_file(resources.get_ui_asset("gwibber.png")) #else: icon = gtk.image_new_from_file(resources.get_ui_asset("icons/breakdance/16x16/%s.png" % data["error"]["account"]["service"])) label = gtk.Label(data["error"]["message"]) label.set_use_markup(True) label.set_ellipsize(pango.ELLIPSIZE_END) content_area.pack_start(icon, False, False, 0) content_area.pack_start(label, True, True, 0) self.pack_start(content_area, False) close_button = gtk.Button() close_button.set_image(gtk.image_new_from_stock (gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)) close_button.set_tooltip_text(_("Close")) close_button.connect("clicked", self.on_error_close_clicked_cb) self.pack_end(close_button, False) if data["error"]["type"] == "auth": edit_button = gtk.Button() edit_button.set_image(gtk.image_new_from_stock (gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON)) edit_button.set_tooltip_text(_("Edit Account")) edit_button.connect("clicked", self.on_error_edit_clicked_cb, data["error"]["account"]["id"], data["error"]["message"]) self.pack_end(edit_button, False) retry_button = gtk.Button() retry_button.set_image(gtk.image_new_from_stock (gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)) retry_button.set_tooltip_text(_("Retry")) retry_button.connect("clicked", self.on_error_retry_clicked_cb, data["error"]["account"]["id"]) self.pack_end(retry_button, False) self.show_all()
def on_loading_started(self, *args): self.loading_spinner.set_from_animation( gtk.gdk.PixbufAnimation(resources.get_ui_asset("progress.gif")))
def setup_ui(self): self.set_title(_("Social broadcast messages")) self.set_icon_from_file(resources.get_ui_asset("gwibber.svg")) self.connect("delete-event", self.on_window_close) # Load the application menu menu_ui = self.setup_menu() self.add_accel_group(menu_ui.get_accel_group()) def on_tray_menu_popup(i, b, a): menu_ui.get_widget("/menu_tray").popup( None, None, gtk.status_icon_position_menu, b, a, self.tray_icon) self.tray_icon = gtk.status_icon_new_from_file( resources.get_ui_asset("gwibber.svg")) self.tray_icon.connect("activate", self.on_toggle_window_visibility) self.tray_icon.connect("popup-menu", on_tray_menu_popup) # Create animated loading spinner self.loading_spinner = gtk.Image() menu_spin = gtk.ImageMenuItem("") menu_spin.set_right_justified(True) menu_spin.set_sensitive(False) menu_spin.set_image(self.loading_spinner) # Force the spinner to show in newer versions of Gtk if hasattr(menu_spin, "set_always_show_image"): menu_spin.set_always_show_image(True) menubar = menu_ui.get_widget("/menubar_main") menubar.append(menu_spin) # Load the user's saved streams streams = json.loads(self.model.settings["streams"]) streams = [dict((str(k), v) for k, v in s.items()) for s in streams] # Use the multicolumn mode if there are multiple saved streams view_class = getattr( gwui, "MultiStreamUi" if len(streams) > 1 else "SingleStreamUi") self.stream_view = view_class(self.model) self.stream_view.connect("action", self.on_action) self.stream_view.connect("search", self.on_perform_search) self.stream_view.connect("stream-changed", self.on_stream_changed) self.stream_view.connect("stream-closed", self.on_stream_closed) if isinstance(self.stream_view, gwui.MultiStreamUi): self.stream_view.connect("pane-closed", self.on_pane_closed) self.input = gwui.Input() self.input.connect("submit", self.on_input_activate) self.input.connect("changed", self.on_input_changed) self.input.connect("clear", self.on_input_cleared) self.input_splitter = gtk.VPaned() self.input_splitter.pack1(self.stream_view, resize=True) self.input_splitter.pack2(self.input, resize=False) self.input_splitter.set_focus_child(self.input) self.button_send = gtk.Button(_("Send")) self.button_send.connect("clicked", self.on_button_send_clicked) self.message_target = gwui.AccountTargetBar(self.model) self.message_target.pack_end(self.button_send, False) self.message_target.connect("canceled", self.on_reply_cancel) content = gtk.VBox(spacing=5) content.pack_start(self.input_splitter, True) content.pack_start(self.message_target, False) content.set_border_width(5) layout = gtk.VBox() layout.pack_start(menubar, False) layout.pack_start(content, True) self.add(layout) # Apply the user's settings self.resize(*self.model.settings["window_size"]) self.move(*self.model.settings["window_position"]) self.input_splitter.set_position( self.model.settings["window_splitter"]) if hasattr(self.stream_view, "splitter"): self.stream_view.splitter.set_position( self.model.settings["sidebar_splitter"]) self.show_all() self.stream_view.set_state(streams) self.update_menu_availability() for stream in streams: if stream["stream"]: gobject.idle_add( lambda: self.service.UpdateIndicators(stream["stream"]))
def setup_ui(self): self.set_title(_("Social broadcast messages")) self.set_icon_from_file(resources.get_ui_asset("gwibber.svg")) self.connect("delete-event", self.on_window_close) # Load the application menu menu_ui = self.setup_menu() self.add_accel_group(menu_ui.get_accel_group()) def on_tray_menu_popup(i, b, a): menu_ui.get_widget("/menu_tray").popup(None, None, gtk.status_icon_position_menu, b, a, self.tray_icon) self.tray_icon = gtk.status_icon_new_from_file(resources.get_ui_asset("gwibber.svg")) self.tray_icon.connect("activate", self.on_toggle_window_visibility) self.tray_icon.connect("popup-menu", on_tray_menu_popup) # Create animated loading spinner self.loading_spinner = gtk.Image() menu_spin = gtk.ImageMenuItem("") menu_spin.set_right_justified(True) menu_spin.set_sensitive(False) menu_spin.set_image(self.loading_spinner) # Force the spinner to show in newer versions of Gtk if hasattr(menu_spin, "set_always_show_image"): menu_spin.set_always_show_image(True) menubar = menu_ui.get_widget("/menubar_main") menubar.append(menu_spin) # Load the user's saved streams streams = json.loads(self.model.settings["streams"]) streams = [dict((str(k), v) for k, v in s.items()) for s in streams] # Use the multicolumn mode if there are multiple saved streams view_class = getattr(gwui, "MultiStreamUi" if len(streams) > 1 else "SingleStreamUi") self.stream_view = view_class(self.model) self.stream_view.connect("action", self.on_action) self.stream_view.connect("search", self.on_perform_search) self.stream_view.connect("stream-changed", self.on_stream_changed) self.stream_view.connect("stream-closed", self.on_stream_closed) if isinstance(self.stream_view, gwui.MultiStreamUi): self.stream_view.connect("pane-closed", self.on_pane_closed) self.input = gwui.Input() self.input.connect("submit", self.on_input_activate) self.input.connect("changed", self.on_input_changed) self.input.connect("clear", self.on_input_cleared) self.input_splitter = gtk.VPaned() self.input_splitter.pack1(self.stream_view, resize=True) self.input_splitter.pack2(self.input, resize=False) self.input_splitter.set_focus_child(self.input) self.attach_image = gtk.Image() self.attach_image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) self.button_attach = gtk.Button() self.button_attach.set_image(self.attach_image) self.button_attach.set_tooltip_text(_("Upload image")) self.button_attach.connect("clicked", self.on_button_attach_clicked) self.button_send = gtk.Button(_("Send")) self.button_send.set_tooltip_text(_("Post to all enabled services")) self.button_send.connect("clicked", self.on_button_send_clicked) self.message_target = gwui.AccountTargetBar(self.model) self.message_target.pack_end(self.button_send, False) self.message_target.pack_end(self.button_attach, False) self.message_target.connect("canceled", self.on_reply_cancel) content = gtk.VBox(spacing=5) content.pack_start(self.input_splitter, True) content.pack_start(self.message_target, False) content.set_border_width(5) layout = gtk.VBox() layout.pack_start(menubar, False) layout.pack_start(content, True) self.add(layout) # Apply the user's settings self.resize(*self.model.settings["window_size"]) self.move(*self.model.settings["window_position"]) self.input_splitter.set_position(self.model.settings["window_splitter"]) if hasattr(self.stream_view, "splitter"): self.stream_view.splitter.set_position( self.model.settings["sidebar_splitter"]) self.show_all() self.stream_view.set_state(streams) self.update_menu_availability() for stream in streams: if stream["stream"]: gobject.idle_add(lambda: self.service.UpdateIndicators(stream["stream"]))
def pixbuf(path): return GdkPixbuf.Pixbuf.new_from_file(resources.get_ui_asset(path))
def pixbuf(path): return gtk.gdk.pixbuf_new_from_file(resources.get_ui_asset(path))