Python gi.repository.GLib.markup_escape_text() Examples

The following are 5 code examples of gi.repository.GLib.markup_escape_text(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.GLib , or try the search function .
Example #1
Source File: completions.py    From vimiv with MIT License 6 votes vote down vote up
def generate_commandlist(self):
        """Generate a list of internal vimiv commands and store it."""
        commands = [cmd.name for cmd in self._app["commandline"].commands
                    if not cmd.is_hidden]
        aliases = list(self._app["commandline"].commands.aliases.keys())
        all_commands = sorted(commands + aliases)
        infodict = read_info_from_man()
        for command in all_commands:
            if command in infodict:
                info = infodict[command]
            elif command in aliases:
                info = "Alias to %s" % (
                    self._app["commandline"].commands.aliases[command])
            else:
                info = ""
            info = "<i>" + GLib.markup_escape_text(info) + "</i>"
            self._liststores["internal"][0].append([command, info]) 
Example #2
Source File: gtk_ui.py    From python-gui with Apache License 2.0 5 votes vote down vote up
def _get_pango_text(self, text):
        rv = self._pango_text_cache.get(text, None)
        if rv is None:
            rv = GLib.markup_escape_text(text or '')
            self._pango_text_cache[text] = rv
        return rv 
Example #3
Source File: context.py    From runsqlrun with MIT License 5 votes vote down vote up
def on_connection_changed(self, worksheet):
        markup = '<small>Connected to</small>\n'
        if worksheet.connection is not None:
            conn = worksheet.connection.get_label()
        else:
            conn = 'Not connected.'
        markup += '<b>{}</b>'.format(GLib.markup_escape_text(conn))
        self.lbl_conn.set_markup(markup)

        # update schema
        self.browser_model.clear()
        if worksheet.connection:
            worksheet.connection.schema.connect(
                'changed', self._update_browser) 
Example #4
Source File: gutil.py    From bcloud with GNU General Public License v3.0 5 votes vote down vote up
def escape(tooltip):
    '''Escape special characters in tooltip text'''
    return GLib.markup_escape_text(tooltip) 
Example #5
Source File: alttoolbar_plugins.py    From alternative-toolbar with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, plugin, switch_callback):
        super(PluginListRow, self).__init__()

        self.plugin = plugin
        self._refresh = False

        self._switch_callback = switch_callback

        label1 = Gtk.Label()
        escape = GLib.markup_escape_text(plugin.get_name())
        label1.set_markup("<b>" + escape + "</b>")
        label1.set_ellipsize(Pango.EllipsizeMode.END)
        label1.props.halign = Gtk.Align.START
        label1.set_has_tooltip(True)
        label1.props.margin_top = 5
        label1.connect('query-tooltip', self._display_tooltip)
        label2 = Gtk.Label(plugin.get_description())
        label2.set_ellipsize(Pango.EllipsizeMode.END)
        label2.props.halign = Gtk.Align.START
        label2.set_has_tooltip(True)
        label2.connect('query-tooltip', self._display_tooltip)
        label2.props.margin_bottom = 5

        switch = Gtk.Switch.new()
        self._switch = switch
        switch.props.valign = Gtk.Align.CENTER

        sensitive = False

        try:
            if plugin.is_available():
                sensitive = True
            switch.set_active(plugin.is_loaded())
        except:
            pass

        box = Gtk.Box()
        box.set_orientation(Gtk.Orientation.VERTICAL)
        box.pack_start(label1, True, False, 0)
        box.pack_start(label2, True, False, 1)

        outerbox = Gtk.Box()
        outerbox.set_orientation(Gtk.Orientation.HORIZONTAL)
        outerbox.pack_start(Gtk.Label("  "), False, False, 0)
        outerbox.pack_start(box, False, False, 1)
        outerbox.pack_end(switch, False, False, 3)

        self.add(outerbox)
        self.outerbox = outerbox

        if not sensitive:
            self.add_error()

        switch.connect('notify::active', self._switch_changed)