def available_plugins_treeview_selection_changed(self, treeview_selection): model, iter = treeview_selection.get_selected() self.xml.get_object('scrolledwindow1').get_children()[0].destroy() self.plugin_description_textview = HtmlTextView() sw = self.xml.get_object('scrolledwindow1') sw.add(self.plugin_description_textview) sw.show_all() if iter: self.plugin_name_label1.set_text(model.get_value(iter, C_NAME)) self.plugin_authors_label1.set_text(model.get_value(iter, C_AUTHORS)) self.plugin_homepage_linkbutton1.set_uri(model.get_value(iter, C_HOMEPAGE)) self.plugin_homepage_linkbutton1.set_label(model.get_value(iter, C_HOMEPAGE)) label = self.plugin_homepage_linkbutton1.get_children()[0] label.set_ellipsize(pango.ELLIPSIZE_END) self.plugin_homepage_linkbutton1.set_property('sensitive', True) desc = _(model.get_value(iter, C_DESCRIPTION)) if not desc.startswith('<body '): desc = "<body xmlns='http://www.w3.org/1999/xhtml'>" + \ desc + ' </body>' desc = desc.replace('\n', '<br/>') self.plugin_description_textview.display_html(desc, self.plugin_description_textview, None) self.plugin_description_textview.set_property('sensitive', True) else: self._clear_available_plugin_info()
def initialize_window(self): """Show the intro page""" self.html = HtmlTextView() self.html.connect("url-clicked", self.link_clicked) self.html.display_html( '<div><span style="color: red; text-decoration:underline">Welcome to</span><br/>\n' ' <img src="http://comptune.com/images/penguin5.gif" alt="penguin" height="48" width="48" /><br/>\n' ' <span style="font-size: 500%; font-family: serif">crowbar</span>\n' '</div>\n') self.sw1.add(self.html) #~ add a search comboboxentry1 and 3 buttons self.liststore1 = gtk.ListStore(str) self.comboboxentry1 = gtk.ComboBoxEntry(self.liststore1, 0) popular = ['#teamfollowback', '#tfb', '#f4f'] trending = api.GetTrendsCurrent() trends = [x.name for x in trending] for row in popular: self.liststore1.append([row]) for row in trends: self.liststore1.append([row]) # insert a horizontal box with combo and buttons self.hbox2 = gtk.HBox(homogeneous=False) self.hbox2.pack_start(self.comboboxentry1) button = gtk.Button() button.set_label('search') button.set_property('width-request', 55) button.connect('clicked', self.search_clicked, self.comboboxentry1.child.get_text) self.hbox2.pack_start(button, expand=False, fill=True) button = gtk.Button() button.set_label('friends') button.set_property('width-request', 55) button.connect('clicked', self.timeline_clicked, self.comboboxentry1.child.get_text) self.hbox2.pack_start(button, expand=False, fill=True) button = gtk.Button() button.set_label('user') button.set_property('width-request', 40) button.connect('clicked', self.user_timeline_clicked, self.comboboxentry1.child.get_text) self.hbox2.pack_start(button, expand=False, fill=True) button = gtk.Button() button.set_label('dm') button.set_property('width-request', 35) button.connect('clicked', self.dm_clicked, self.comboboxentry1.child.get_text) self.hbox2.pack_start(button, expand=False, fill=True) button = gtk.Button() button.set_label('mention') button.set_property('width-request', 70) button.connect('clicked', self.mentions_clicked, self.comboboxentry1.child.get_text) self.hbox2.pack_start(button, expand=False, fill=True) #~ testify.test(self) self.vbox1.pack_start(self.hbox2, expand=False) self.html.show_all() self.hbox2.show_all()
def __init__(self): w = gtk.Window() print(sys.getdefaultencoding()) msg1 = """<span><p>This is a <a href="http://eq2.us">TEST</a>.</p>Enjoy.</span> """ print type(msg1) htmlview = HtmlTextView() def url_cb(view, url, type_): print("url-clicked", url, type_) webbrowser.open(url) htmlview.connect("url-clicked", url_cb) w.connect("delete-event", self.window_close) w.set_property('width-request', 300) w.set_property('height-request', 200) htmlview.display_html(msg1) w.add(htmlview) w.show_all()
def __init__(self, controlState, xml): controlState.displayHeaderBar = True controlState.windowIcon = 'abouttoinstall.png' controlState.windowTitle = "Summary of installation settings" controlState.windowText = \ "Review the summary of the installation settings" htmlTextView = HtmlTextView() htmlTextView.set_wrap_mode(gtk.WRAP_NONE) context = htmlTextView.get_pango_context() initialFont = context.get_font_description() # The review uses monospace, so get the font description for that at the # same size as the default font used by the text view. metrics = context.get_metrics( pango.FontDescription('monospace, %d' % (initialFont.get_size() / pango.SCALE))) # Generate the list of tab stops from the column widths specified in # the review module. tabPosition = 0 ta = pango.TabArray(len(review.COLUMN_WIDTHS), True) for index, charWidth in enumerate(review.COLUMN_WIDTHS): tabPosition += pango.PIXELS(metrics.get_approximate_char_width() * charWidth) ta.set_tab(index, pango.TAB_LEFT, tabPosition) htmlTextView.set_tabs(ta) buf = review.produceText() htmlTextView.display_html(buf) viewPort = xml.get_widget('ReviewViewPort') assert (viewPort) for child in viewPort.get_children(): viewPort.remove(child) viewPort.add(htmlTextView) htmlTextView.show()
def html_view(self, s, dm=False): """show search results and timelines in htmlview""" # clear, add viewport & scrolling table if self.sw1.get_child() is self.html: self.sw1.remove(self.html) self.sw1.set_property("hscrollbar-policy", gtk.POLICY_NEVER) self.viewport1 = gtk.Viewport() self.sw1.add(self.viewport1) else: self.viewport1.remove(self.table1) self.table1 = gtk.Table(23, 2, False) self.table1.set_row_spacings(2) self.table1.set_col_spacings(2) self.viewport1.add(self.table1) self.pic = [] self.msg = [] t = [''] rows = 0 #display each user pic and instant message for x in s: if not dm: user = x.GetUser() else: user = api.GetUser(x.sender_screen_name) img = user.GetProfileImageUrl() usn = str(user.GetScreenName()) t[0] = x reply = usn shouts = self.getshouts(t) star = '☆' if not dm: if x.favorited: star = '★' if shouts: reply += ' @' + string.join(self.getshouts(t), ' @') self.pic.append(self.image_from_url(img, usn)) text = self.process_urls(str(x.text)) #~ (re)construct html message self.msg.append(HtmlTextView()) self.msg[rows].connect("url-clicked", self.link_clicked) h = '<span>' if not dm: h += '<a title="Favorite" href="' + star + str( x.id) + '">' + star + '</a>' h += '<span style="font-weight: bold">' + '<a href="http://twitter.com/' + usn + '">' + usn + '</a></span>: ' + text + '<br /><span style="font-size:small">' if not dm: h += x.relative_created_at + ' via ' + self.unescape( x.source) + ' | ' if dm: h += '<a href="@' + reply + '">reply</a> | <a href="☠' + str( x.id) + '" title="Delete this.">Delete</a>' elif (usn == self.me.screen_name): h += '<a href="✗' + str( x.id) + '" title="Delete this tweet.">Delete</a>' else: h += '<a href="@' + reply + '">reply</a> | <a href="☞' + str( x.id) + '">retweet</a>' h += '</span></span>' try: self.msg[rows].display_html(str(h)) except: print('Error displaying:') print(h + '\n') self.table1.attach(self.pic[rows], 0, 1, rows, rows + 1) self.table1.attach(self.msg[rows], 1, 2, rows, rows + 1) rows += 1 #~ self.table1.attach(self.html,0,2,rows,rows+2) self.blank = gtk.Label() self.blank.set_property('height-request', 100) self.table1.attach(self.blank, 0, 2, rows, rows + 2) #~ self.table1.set_property("border-width", 5) self.sw1.show_all()
def __init__(self): '''Initialize Plugins window''' self.xml = gtkgui_helpers.get_gtk_builder('plugins_window.ui') self.window = self.xml.get_object('plugins_window') self.window.set_transient_for(gajim.interface.roster.window) widgets_to_extract = ('plugins_notebook', 'plugin_name_label', 'plugin_version_label', 'plugin_authors_label', 'plugin_homepage_linkbutton', 'uninstall_plugin_button', 'configure_plugin_button', 'installed_plugins_treeview') for widget_name in widgets_to_extract: setattr(self, widget_name, self.xml.get_object(widget_name)) self.plugin_description_textview = HtmlTextView() sw = self.xml.get_object('scrolledwindow2') sw.add(self.plugin_description_textview) self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool, GdkPixbuf.Pixbuf) self.installed_plugins_treeview.set_model(self.installed_plugins_model) self.installed_plugins_treeview.set_rules_hint(True) renderer = Gtk.CellRendererText() col = Gtk.TreeViewColumn(_('Plugin')) #, renderer, text=NAME) cell = Gtk.CellRendererPixbuf() col.pack_start(cell, False) col.add_attribute(cell, 'pixbuf', ICON) col.pack_start(renderer, True) col.add_attribute(renderer, 'text', NAME) col.set_property('expand', True) self.installed_plugins_treeview.append_column(col) renderer = Gtk.CellRendererToggle() renderer.connect('toggled', self.installed_plugins_toggled_cb) col = Gtk.TreeViewColumn(_('Active'), renderer, active=ACTIVE, activatable=ACTIVATABLE) self.installed_plugins_treeview.append_column(col) self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop') # connect signal for selection change selection = self.installed_plugins_treeview.get_selection() selection.connect('changed', self.installed_plugins_treeview_selection_changed) selection.set_mode(Gtk.SelectionMode.SINGLE) self._clear_installed_plugin_info() self.fill_installed_plugins_model() root_iter = self.installed_plugins_model.get_iter_first() if root_iter: selection.select_iter(root_iter) self.xml.connect_signals(self) self.plugins_notebook.set_current_page(0) self.xml.get_object('close_button').grab_focus() self.window.show_all() gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
def on_activate(self, widget): if 'plugins' not in gajim.interface.instances: return if hasattr(self, 'page_num'): # 'Available' tab exists return self.installed_plugins_model = gajim.interface.instances[ 'plugins'].installed_plugins_model self.notebook = gajim.interface.instances['plugins'].plugins_notebook id_ = self.notebook.connect('switch-page', self.on_notebook_switch_page) self.connected_ids[id_] = self.notebook self.window = gajim.interface.instances['plugins'].window id_ = self.window.connect('destroy', self.on_win_destroy) self.connected_ids[id_] = self.window self.GTK_BUILDER_FILE_PATH = self.local_file_path('config_dialog.ui') self.xml = gtk.Builder() self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['hpaned2', 'image1']) self.hpaned = self.xml.get_object('hpaned2') self.page_num = self.notebook.append_page(self.hpaned, gtk.Label(_('Available'))) widgets_to_extract = ('plugin_name_label1', 'available_treeview', 'progressbar', 'inslall_upgrade_button', 'plugin_authors_label1', 'plugin_authors_label1', 'plugin_homepage_linkbutton1') for widget_name in widgets_to_extract: setattr(self, widget_name, self.xml.get_object(widget_name)) attr_list = pango.AttrList() attr_list.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)) self.plugin_name_label1.set_attributes(attr_list) self.available_plugins_model = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT) self.available_treeview.set_model(self.available_plugins_model) self.available_treeview.set_rules_hint(True) self.available_plugins_model.set_sort_column_id(2, gtk.SORT_ASCENDING) self.progressbar.set_property('no-show-all', True) renderer = gtk.CellRendererText() col = gtk.TreeViewColumn(_('Plugin')) cell = gtk.CellRendererPixbuf() col.pack_start(cell, False) col.add_attribute(cell, 'pixbuf', C_PIXBUF) col.pack_start(renderer, True) col.add_attribute(renderer, 'text', C_NAME) col.set_resizable(True) col.set_property('expand', True) col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) self.available_treeview.append_column(col) col = gtk.TreeViewColumn(_('Installed\nversion'), renderer, text=C_LOCAL_VERSION) self.available_treeview.append_column(col) col = gtk.TreeViewColumn(_('Available\nversion'), renderer, text=C_VERSION) col.set_property('expand', False) self.available_treeview.append_column(col) renderer = gtk.CellRendererToggle() renderer.set_property('activatable', True) renderer.connect('toggled', self.available_plugins_toggled_cb) col = gtk.TreeViewColumn(_('Install /\nUpgrade'), renderer, active=C_UPGRADE) self.available_treeview.append_column(col) if gobject.signal_lookup('error_signal', self.window) is 0: gobject.signal_new('error_signal', self.window, gobject.SIGNAL_RUN_LAST, gobject.TYPE_STRING, (gobject.TYPE_STRING,)) gobject.signal_new('plugin_downloaded', self.window, gobject.SIGNAL_RUN_LAST, gobject.TYPE_STRING, (gobject.TYPE_PYOBJECT,)) id_ = self.window.connect('error_signal', self.on_some_ftp_error) self.connected_ids[id_] = self.window id_ = self.window.connect('plugin_downloaded', self.on_plugin_downloaded) self.connected_ids[id_] = self.window selection = self.available_treeview.get_selection() selection.connect('changed', self.available_plugins_treeview_selection_changed) selection.set_mode(gtk.SELECTION_SINGLE) self._clear_available_plugin_info() self.plugin_description_textview = HtmlTextView() sw = self.xml.get_object('scrolledwindow1') sw.add(self.plugin_description_textview) self.xml.connect_signals(self) self.window.show_all()
def __init__(self, used_in_history_window=False): """ If used_in_history_window is True, then we do not show Clear menuitem in context menu """ GObject.GObject.__init__(self) self.used_in_history_window = used_in_history_window #self.fc = FuzzyClock() # no need to inherit TextView, use it as atrribute is safer self.tv = HtmlTextView() #self.tv.hyperlink_handler = self.hyperlink_handler # set properties self.tv.set_border_width(1) self.tv.set_accepts_tab(True) self.tv.set_editable(False) self.tv.set_cursor_visible(False) self.tv.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) self.tv.set_left_margin(2) self.tv.set_right_margin(2) self.handlers = {} self.images = [] self.image_cache = {} self.xep0184_marks = {} self.xep0184_shown = {} self.last_sent_message_marks = [None, None] # A pair per occupant. Key is '' in normal chat self.last_received_message_marks = {} # It's True when we scroll in the code, so we can detect scroll from user self.auto_scrolling = False # connect signals id_ = self.tv.connect('motion_notify_event', self.on_textview_motion_notify_event) self.handlers[id_] = self.tv id_ = self.tv.connect('populate_popup', self.on_textview_populate_popup) self.handlers[id_] = self.tv id_ = self.tv.connect('button_press_event', self.on_textview_button_press_event) self.handlers[id_] = self.tv id_ = self.tv.connect('draw', self.on_textview_draw) self.handlers[id_] = self.tv self.change_cursor = False self.last_time_printout = 0 #font = Pango.FontDescription(gajim.config.get('conversation_font')) #self.tv.override_font(font) buffer_ = self.tv.get_buffer() end_iter = buffer_.get_end_iter() buffer_.create_mark('end', end_iter, False) #self.tagIn = buffer_.create_tag('incoming') #color = gajim.config.get('inmsgcolor') #font = Pango.FontDescription(gajim.config.get('inmsgfont')) #self.tagIn.set_property('foreground', color) #self.tagIn.set_property('font-desc', font) #self.tagOut = buffer_.create_tag('outgoing') #color = gajim.config.get('outmsgcolor') #font = Pango.FontDescription(gajim.config.get('outmsgfont')) #self.tagOut.set_property('foreground', color) #self.tagOut.set_property('font-desc', font) #self.tagStatus = buffer_.create_tag('status') #color = gajim.config.get('statusmsgcolor') #font = Pango.FontDescription(gajim.config.get('satusmsgfont')) #self.tagStatus.set_property('foreground', color) #self.tagStatus.set_property('font-desc', font) #self.tagInText = buffer_.create_tag('incomingtxt') #color = gajim.config.get('inmsgtxtcolor') #font = Pango.FontDescription(gajim.config.get('inmsgtxtfont')) #if color: # self.tagInText.set_property('foreground', color) #self.tagInText.set_property('font-desc', font) #self.tagOutText = buffer_.create_tag('outgoingtxt') #color = gajim.config.get('outmsgtxtcolor') #if color: # font = Pango.FontDescription(gajim.config.get('outmsgtxtfont')) #self.tagOutText.set_property('foreground', color) #self.tagOutText.set_property('font-desc', font) #colors = gajim.config.get('gc_nicknames_colors') #colors = colors.split(':') #for i, color in enumerate(colors): # tagname = 'gc_nickname_color_' + str(i) # tag = buffer_.create_tag(tagname) # tag.set_property('foreground', color) #self.tagMarked = buffer_.create_tag('marked') #color = gajim.config.get('markedmsgcolor') #self.tagMarked.set_property('foreground', color) #self.tagMarked.set_property('weight', Pango.Weight.BOLD) #tag = buffer_.create_tag('time_sometimes') #tag.set_property('foreground', 'darkgrey') #Pango.SCALE_SMALL #tag.set_property('scale', 0.8333333333333) #tag.set_property('justification', Gtk.Justification.CENTER) #tag = buffer_.create_tag('small') #Pango.SCALE_SMALL #tag.set_property('scale', 0.8333333333333) #tag = buffer_.create_tag('restored_message') #color = gajim.config.get('restored_messages_color') #tag.set_property('foreground', color) #self.tv.create_tags() #tag = buffer_.create_tag('bold') #tag.set_property('weight', Pango.Weight.BOLD) #tag = buffer_.create_tag('italic') #tag.set_property('style', Pango.Style.ITALIC) #tag = buffer_.create_tag('underline') #tag.set_property('underline', Pango.Underline.SINGLE) #buffer_.create_tag('focus-out-line', justification = Gtk.Justification.CENTER) #self.displaymarking_tags = {} #tag = buffer_.create_tag('xep0184-warning') #tag.set_property('foreground', '#cc0000') #tag = buffer_.create_tag('xep0184-received') #tag.set_property('foreground', '#73d216') # One mark at the begining then 2 marks between each lines #size = gajim.config.get('max_conversation_lines') #size = 2 * size - 1 #self.marks_queue = queue.Queue(size) self.allow_focus_out_line = True # holds a mark at the end of --- line self.focus_out_end_mark = None #self.xep0184_warning_tooltip = tooltips.BaseTooltip() #self.line_tooltip = tooltips.BaseTooltip() self.smooth_id = None self.just_cleared = False size = 500 size = 2 * size - 1 self.marks_queue = queue.Queue(size)
def on_menuitem_activate(self, widget, email): self.window = gtk.Window() self.window.set_border_width(5) self.window.set_title(_("Conversation log for %s") % email) self.window.set_default_size(650,350) self.window.set_position(gtk.WIN_POS_CENTER) textview = gtk.TextView() self.textBuffer = textview.get_buffer() self.textBuffer.create_tag('highlight', background = 'yellow') scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = HtmlTextView(self.controller, self.textBuffer, scroll) self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR) self.textview.set_left_margin(6) self.textview.set_right_margin(6) self.textview.set_editable(False) self.textview.set_cursor_visible(False) scroll.add(self.textview) hbox = gtk.HBox(False, 5) saveButton = gtk.Button(stock=gtk.STOCK_SAVE) saveButton.connect("clicked", self.on_save_logs) refreshButton = gtk.Button(stock=gtk.STOCK_REFRESH) refreshButton.connect("clicked", self.on_refresh_log, email) closeButton = gtk.Button(stock=gtk.STOCK_CLOSE) closeButton.connect("clicked", lambda w: self.window.hide()) ############ Search TreeView ################### self.search_active = False self.searchStore = gtk.ListStore(str, str, str, str) self.searchTree = gtk.TreeView(self.searchStore) self.searchTree.connect("row-activated", self.set_cursor) self.searchTree.set_rules_hint(True) cell = gtk.CellRendererText() nameCol = gtk.TreeViewColumn(_("Date"), cell, text=0) dateCol = gtk.TreeViewColumn(_("Time"), cell, text=1) timeCol = gtk.TreeViewColumn(_("Name"), cell, text=2) msgCol = gtk.TreeViewColumn(_("Message"), cell, text=3) nameCol.set_resizable(True) dateCol.set_resizable(True) timeCol.set_resizable(True) msgCol.set_resizable(True) self.searchTree.append_column(nameCol) self.searchTree.append_column(dateCol) self.searchTree.append_column(timeCol) self.searchTree.append_column(msgCol) self.searchSw = gtk.ScrolledWindow() self.searchSw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.searchSw.add(self.searchTree) self.searchSw.set_size_request(100, 30) ################################################## #search box searchLabel = gtk.Label(_("Search:")) self.searchBox = gtk.Entry() self.searchBox.connect("key-press-event", self.enter_pressed) hbox.pack_end(saveButton, False, False) hbox.pack_end(refreshButton, False, False) hbox.pack_end(closeButton, False, False) hbox.pack_end(self.searchBox, False, False) hbox.pack_end(searchLabel, False, False) textRenderer = gtk.CellRendererText() column = gtk.TreeViewColumn(_("Date"), textRenderer, markup=0) self.datesListstore = gtk.ListStore(str) self.datesTree = gtk.TreeView(self.datesListstore) self.datesTree.connect("cursor-changed", self.on_dates_cursor_change) self.datesTree.append_column(column) self.datesTree.set_headers_visible(False) datesScroll = gtk.ScrolledWindow() datesScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) datesScroll.add_with_viewport(self.datesTree) datesScroll.set_size_request(150, -1) hPaned = gtk.HPaned() hPaned.pack1(datesScroll) hPaned.pack2(scroll) vbox = gtk.VBox(spacing=5) vbox.pack_start(hPaned) vbox.pack_start(hbox, False, False) vbox.pack_start(self.searchSw) vbox.pack_start(gtk.Statusbar(), False, False) self.datesStamps = {} logsCant = len(self.fill_dates_tree(email)) if not logsCant > 0: dialog.information(_("No logs were found for %s") % (email)) else: self.window.add(vbox) self.window.show_all() self.searchSw.hide_all()