def __init__(self, pixbuf, label): gtk.EventBox.__init__(self) self.hovering = False pad = gtk.Alignment() self.pad_size = pixbuf.get_width() / 10 pad.set_padding(self.pad_size, self.pad_size, self.pad_size, self.pad_size) vbox = gtk.VBox() vbox.set_spacing(12) self.img = awn.Image() self.img.set_from_pixbuf(pixbuf) self.text = awn.Label() self.text.set_markup('<span font-size="x-large" weight="bold">' + label + '</span>') vbox.add(self.img) vbox.add(self.text) pad.add(vbox) self.add(pad) # Init transparent colormap cm = self.get_screen().get_rgba_colormap() if cm != None: self.set_colormap(cm) awn.utils_ensure_transparent_bg(self) self.init_dnd()
def add_feed_row(self, url, i): feed_vbox = gtk.VBox(False, 6) feed_items_vbox = gtk.VBox(False, 6) self.displays[url] = feed_items_vbox feed_items_vbox.set_no_show_all(True) feed_hbox = gtk.HBox(False, 6) feed_vbox.pack_start(feed_hbox, False) feed_vbox.pack_start(feed_items_vbox, False) self.widget.pack_start(feed_vbox) #Get the icon as a pixbuf pb = None if self.feeds[url].icon != '' and self.client.get_value(GROUP_DEFAULT, 'show_favicons'): pb = self.get_favicon(self.feeds[url].icon) else: pb = self.web_image #Pretty icon for button image = awn.Image() image.set_size_request(16, 16) image.set_from_pixbuf(pb) throbber = awn.OverlayThrobber() throbber.props.active = True throbber.props.scale = 1.0 image.add_overlay(throbber) self.feed_icons[url] = image self.feed_throbbers[url] = throbber #Button for opening the feed's website button = gtk.Button() button.add(image) button.set_relief(gtk.RELIEF_NONE) button.set_tooltip_text(_("Open this feed's website")) button.connect('clicked', self.feed_icon_clicked, url) button.show_all() feed_hbox.pack_start(button, False) #ToggleButton for showing/hiding the feed's items arrow = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE) label = gtk.Label(_("Loading...")) self.feed_labels[url] = label toggle_hbox = gtk.HBox(False, 3) toggle_hbox.pack_start(arrow, False) toggle_hbox.pack_start(label, False) toggle = gtk.ToggleButton() toggle.add(toggle_hbox) toggle.set_relief(gtk.RELIEF_NONE) toggle.connect('toggled', self.toggle_display, url) toggle.url = url self.toggles.append(toggle) self.feed_toggles[url] = toggle toggle.arrow = arrow toggle.web_url = '' toggle.url = url toggle.web = button toggle.position = i toggle.placeholder = None toggle.size_group = None #Drag and Drop to reorder #or drop an e.g. a web browser to go to that feed's url toggle.drag_source_set(gtk.gdk.BUTTON1_MASK, \ [("text/plain", 0, 0), ("STRING", 0, 0)], \ gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) toggle.connect('drag-begin', self.toggle_drag_begin) toggle.connect('drag-data-get', self.toggle_drag_get) toggle.connect('drag-end', self.toggle_drag_end) #If there's only one feed, show its most recent items if len(self.urls) == 1: toggle.set_active(True) #Not showing, set appropriate tooltip text else: toggle.set_tooltip_text(_("Show this feed's items")) feed_hbox.pack_start(toggle)
def __init__(self, prefs=None, applet=None): gtk.Window.__init__(self) if prefs is not None: self.prefs = prefs self.applet = prefs.applet self.set_transient_for(prefs) elif applet is not None: self.applet = applet self.google_source = None for source in self.applet.feeds.values(): if isinstance(source, classes.GoogleFeed): self.google_source = source break self.site_images = {} self.set_border_width(12) self.set_title(_("Add Feed")) self.set_icon_from_file(icon_path) #Source: label and radio buttons source_label = gtk.Label(_("Source:")) source_label.set_alignment(1.0, 0.0) source_vbox = gtk.VBox(False, 3) #Search via Google Reader pb = self.icon_theme.load_icon("system-search", 16, 0) pb = classes.get_16x16(pb) search_radio = gtk.RadioButton(None) search_radio.add(self.get_radio_hbox(pb, _("Search"))) if not self.google_source: search_radio.set_sensitive(False) search_radio.set_tooltip_text( _("You must sign in to a Google service to search for feeds.")) #Regular RSS/Atom feed try: pb = self.icon_theme.load_icon('application-rss+xml', 16, 0) pb = classes.get_16x16(pb) except: pb = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16) webfeed_radio = gtk.RadioButton(search_radio, None) webfeed_radio.add(self.get_radio_hbox(pb, _("RSS/Atom"))) #Google (Reader and Wave) pb = self.applet.get_favicon('www.google.com', True) google_radio = gtk.RadioButton(search_radio, None) google_radio.add( self.get_radio_hbox(pb, classes.GoogleFeed.title, 'www.google.com')) #Google Reader (CheckButton) pb = get_greader_icon() self.greader_check = gtk.CheckButton() self.greader_check.add( self.get_radio_hbox(pb, classes.GoogleReader.title, 'google-reader')) self.greader_check.set_active(True) self.greader_check.connect('toggled', self.check_toggled) #Google Wave pb = self.applet.get_favicon('wave.google.com', True) self.gwave_check = gtk.CheckButton() self.gwave_check.add( self.get_radio_hbox(pb, classes.GoogleWave.title, 'wave.google.com')) self.gwave_check.connect('toggled', self.check_toggled) google_vbox = gtk.VBox(False, 3) google_vbox.pack_start(self.greader_check, False) google_vbox.pack_start(self.gwave_check, False) google_vbox.show_all() self.google_align = gtk.Alignment(0.0, 0.0, 1.0, 0.0) self.google_align.set_padding(0, 0, 12, 0) self.google_align.add(google_vbox) self.google_align.set_no_show_all(True) #Reddit Inbox pb = self.applet.get_favicon('www.reddit.com', True) reddit_radio = gtk.RadioButton(search_radio, None) reddit_radio.add( self.get_radio_hbox(pb, classes.Reddit.title, 'www.reddit.com')) #Twitter Timeline and/or Replies pb = gtk.gdk.pixbuf_new_from_file_at_size(twitter_path, 16, 16) twitter_radio = gtk.RadioButton(search_radio, None) twitter_radio.add(self.get_radio_hbox(pb, _("Twitter"))) self.twitter_timeline_check = gtk.CheckButton(_("Timeline")) self.twitter_timeline_check.set_active(True) self.twitter_timeline_check.connect('toggled', self.check_toggled) self.twitter_timeline_check.show() self.twitter_replies_check = gtk.CheckButton(_("Replies")) self.twitter_replies_check.connect('toggled', self.check_toggled) self.twitter_replies_check.show() twitter_vbox = gtk.VBox(False, 3) twitter_vbox.pack_start(self.twitter_timeline_check, False) twitter_vbox.pack_start(self.twitter_replies_check, False) twitter_vbox.show_all() self.twitter_align = gtk.Alignment(0.0, 0.0, 1.0, 0.0) self.twitter_align.set_padding(0, 0, 12, 0) self.twitter_align.add(twitter_vbox) self.twitter_align.set_no_show_all(True) num = 0 for widget in (search_radio, webfeed_radio, google_radio, self.google_align, reddit_radio, twitter_radio, self.twitter_align): if isinstance(widget, gtk.RadioButton): widget.connect('toggled', self.radio_toggled) widget.num = num num += 1 source_vbox.pack_start(widget, False, False, 0) source_hbox = gtk.HBox(False, 6) source_hbox.pack_start(source_label, False, False) source_hbox.pack_start(source_vbox) #"Search for" label and entry search_label = gtk.Label(_("Search for")) search_label.set_alignment(1.0, 0.5) search_label.show() self.search_entry = gtk.Entry() self.search_entry.show() self.search_entry.connect('changed', self.entry_changed) self.search_hbox = gtk.HBox(False, 6) self.search_hbox.pack_start(search_label, False) self.search_hbox.pack_start(self.search_entry) self.search_hbox.set_no_show_all(True) #URL: label and entry url_label = gtk.Label(_("URL:")) url_label.set_alignment(1.0, 0.5) url_label.show() self.url_entry = gtk.Entry() self.url_entry.show() self.url_entry.connect('changed', self.entry_changed) self.url_hbox = gtk.HBox(False, 6) self.url_hbox.pack_start(url_label, False, False) self.url_hbox.pack_start(self.url_entry) self.url_hbox.set_no_show_all(True) #Username: label and entry user_label = gtk.Label(_("Username:"******"Password:"******"Feed search by ")) button = gtk.LinkButton(reader_url, _("Google Reader")) image.show() image_align.show() label.show() button.show() hbox = gtk.HBox() hbox.pack_start(image_align, False, False, 6) hbox.pack_start(label, False) hbox.pack_start(button, False) hbox.show() self.search_msg = gtk.HBox() self.search_msg.pack_start(hbox, True, False) self.search_msg.set_no_show_all(True) #Results VBox and ScrolledWindow for Feed Search self.results_vbox = gtk.VBox(False, 3) self.results_vbox.show() self.results_sw = gtk.ScrolledWindow() self.results_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.results_sw.add_with_viewport(self.results_vbox) self.results_sw.set_no_show_all(True) #Cancel and Add buttons cancel = gtk.Button(stock=gtk.STOCK_CLOSE) cancel.connect('clicked', self.close) self.add_button = gtk.Button(stock=gtk.STOCK_ADD) self.add_button.set_flags(gtk.CAN_DEFAULT) self.add_button.set_sensitive(False) self.add_button.set_no_show_all(True) self.add_button.connect('clicked', self.almost_add_feed) #If signed in to Google Reader self.search_button = gtk.Button(_("_Search")) image = gtk.image_new_from_icon_name('search', gtk.ICON_SIZE_BUTTON) self.search_button.set_image(image) self.search_button.set_flags(gtk.CAN_DEFAULT) self.search_button.set_sensitive(False) self.search_button.set_no_show_all(True) self.search_button.connect('clicked', self.do_search) if self.google_source is not None: self.search_button.show() self.search_hbox.show() self.search_msg.show() else: self.add_button.show() self.url_hbox.show() webfeed_radio.set_active(True) button_hbox = gtk.HBox(False, 6) button_hbox.pack_end(self.add_button, False, False) button_hbox.pack_end(self.search_button, False, False) button_hbox.pack_end(cancel, False, False) main_vbox = gtk.VBox(False, 6) main_vbox.pack_start(source_hbox, False, False) main_vbox.pack_start(self.search_hbox, False, False) main_vbox.pack_start(self.url_hbox, False, False) main_vbox.pack_start(self.user_hbox, False, False) main_vbox.pack_start(self.pass_hbox, False, False) main_vbox.pack_start(self.search_msg, False, False) main_vbox.pack_start(self.results_sw) main_vbox.pack_end(button_hbox, False, False) main_vbox.show_all() self.add(main_vbox) self.add_button.grab_default() #Make the labels the same size sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) sg.add_widget(source_label) sg.add_widget(search_label) sg.add_widget(url_label) sg.add_widget(user_label) sg.add_widget(pass_label) #Make the buttons the same size sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) sg.add_widget(cancel) sg.add_widget(self.add_button) sg.add_widget(self.search_button) self.show_all() #Update any downloaded favicons if necessary for siteid in ('www.google.com', 'google-reader', 'wave.google.com', 'www.reddit.com'): self.applet.fetch_favicon(self.fetched_favicon, siteid, siteid)
def setup_docklet(self, window_id): def hover_cb(widget, event, effects): effects.start(awn.EFFECT_HOVER) def leave_cb(widget, event, effects): effects.stop(awn.EFFECT_HOVER) docklet = awn.Applet(self.applet.get_canonical_name(), self.applet.props.uid, self.applet.props.panel_id) docklet.props.quit_on_delete = False docklet_orientation = docklet.get_pos_type() top_bottom = docklet_orientation in (gtk.POS_TOP, gtk.POS_BOTTOM) align = awn.Alignment(docklet, 1 / 3.0) align.props.offset_multiplier = 0 if top_bottom: box = gtk.HBox() else: box = gtk.VBox() box.set_spacing(10) align.props.scale = 0.3 align.add(box) for i in docklet_actions_label_icon: label, icon = docklet_actions_label_icon[i] if docklet_orientation == gtk.POS_RIGHT: label_align = gtk.Alignment(xalign=1.0) label_align.set_padding(0, 0, 0, docklet.get_offset()) elif docklet_orientation == gtk.POS_BOTTOM: label_align = gtk.Alignment(yalign=1.0) label_align.set_padding(0, docklet.get_offset(), 0, 0) elif docklet_orientation == gtk.POS_TOP: label_align = gtk.Alignment() label_align.set_padding(docklet.get_offset(), 0, 0, 0) else: label_align = gtk.Alignment() label_align.set_padding(0, 0, docklet.get_offset(), 0) # Event box event_box = gtk.EventBox() event_box.set_visible_window(False) box.pack_start(event_box, True, False) # HBox/VBox (container) if top_bottom: container = gtk.HBox() else: container = gtk.VBox() container.set_spacing(5) event_box.add(container) # Label label_label = awn.Label(label) label_align.add(label_label) if top_bottom: label_label.set_size_request(-1, docklet.get_size()) else: label_label.set_size_request(docklet.get_size(), -1) # Label left/right if docklet_orientation == gtk.POS_LEFT: container.pack_start(label_align, False, False) label_label.props.angle = 90 # Icon themed_icon = awn.ThemedIcon() themed_icon.set_info_simple(self.applet.meta["short"], docklet.props.uid, icon) pixbuf = themed_icon.get_icon_at_size( (docklet.get_size() + docklet.props.max_size) / 2, themed_icon.get_state()) image = awn.Image() image.set_from_pixbuf(pixbuf) if top_bottom: image.set_padding(0, docklet.get_offset()) else: image.set_padding(docklet.get_offset(), 0) container.pack_start(image, False, False) effects = image.get_effects() event_box.connect("enter-notify-event", hover_cb, effects) event_box.connect("leave-notify-event", leave_cb, effects) event_box.connect("button-release-event", self.apply_action_cb, i, docklet) # Label top/bottom if docklet_orientation != gtk.POS_LEFT: container.pack_start(label_align, False, False) if docklet_orientation == gtk.POS_RIGHT: label_label.props.angle = 270 docklet.add(align) gtk.Plug.__init__(docklet, long(window_id)) docklet.show_all()