Python gobject.markup_escape_text() Examples

The following are 17 code examples of gobject.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 gobject , or try the search function .
Example #1
Source File: higcontainer.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #2
Source File: overwritechooser.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def _choose(self, filepath):
    if filepath is not None:
      dirpath, filename = os.path.split(filepath)
      if dirpath:
        text_choose = (
          _('A file named "{}" already exists in "{}". ').format(
            filename, os.path.basename(dirpath)))
      else:
        text_choose = _('A file named "{}" already exists.\n').format(filename)
    else:
      text_choose = _("A file with the same name already exists.\n")
    
    text_choose += _("What would you like to do?")
    
    self._dialog_text.set_markup(
      '<span font_size="large"><b>{}</b></span>'.format(
        gobject.markup_escape_text(text_choose)))
    
    self._dialog.show_all()
    
    self._overwrite_mode = self._dialog.run()
    
    if self._overwrite_mode not in self._values:
      self._overwrite_mode = self.default_response
    
    self._dialog.hide()
    
    return self._overwrite_mode 
Example #3
Source File: operations.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def _on_label_procedure_name_changed(self, editable_label, operation):
    operation["display_name"].set_value(editable_label.label.get_text())
    
    editable_label.label.set_markup(
      "<b>{}</b>".format(gobject.markup_escape_text(editable_label.label.get_text()))) 
Example #4
Source File: preview_image.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def _set_layer_name_label(self, layer_name):
    self._label_layer_name.set_markup(
      "<i>{}</i>".format(
        gobject.markup_escape_text(layer_name.encode(pg.GTK_CHARACTER_ENCODING)))) 
Example #5
Source File: main.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def display_reset_prompt(parent=None, more_settings_shown=False):
  dialog = gtk.MessageDialog(
    parent=parent,
    type=gtk.MESSAGE_WARNING,
    flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
    buttons=gtk.BUTTONS_YES_NO)
  dialog.set_transient_for(parent)
  dialog.set_title(pg.config.PLUGIN_TITLE)
  
  dialog.set_markup(
    gobject.markup_escape_text(_("Are you sure you want to reset settings?")))
  
  if more_settings_shown:
    checkbutton_reset_operations = gtk.CheckButton(
      label=_("Remove procedures and constraints"), use_underline=False)
    dialog.vbox.pack_start(checkbutton_reset_operations, expand=False, fill=False)
  
  dialog.set_focus(dialog.get_widget_for_response(gtk.RESPONSE_NO))
  
  dialog.show_all()
  response_id = dialog.run()
  dialog.destroy()
  
  clear_operations = (
    checkbutton_reset_operations.get_active() if more_settings_shown else False)
  
  return response_id, clear_operations 
Example #6
Source File: higcontainer.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #7
Source File: higcontainer.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        """!
        Set property function
        
        @param self: this object
        @param pspec: internal
        @param value: callback
        @return AttributeError if unknown property
        """
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #8
Source File: higcontainer.py    From ntu-dsi-dcn with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #9
Source File: higcontainer.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #10
Source File: higcontainer.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #11
Source File: higcontainer.py    From royal-chaos with MIT License 5 votes vote down vote up
def do_set_property(self, pspec, value):
        """!
        Set property function
        
        @param self: this object
        @param pspec: internal
        @param value: callback
        @return AttributeError if unknown property
        """
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #12
Source File: higcontainer.py    From ns3-rdma with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #13
Source File: higcontainer.py    From 802.11ah-ns3 with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #14
Source File: higcontainer.py    From ns3-load-balance with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #15
Source File: higcontainer.py    From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if pspec.name == 'title':
            self.__title.set_markup('<span weight="bold">%s</span>' %
                                    gobject.markup_escape_text(value))
            self.__title_text = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name 
Example #16
Source File: message_label.py    From gimp-plugin-export-layers with GNU General Public License v3.0 4 votes vote down vote up
def set_text(self, text, message_type=gtk.MESSAGE_ERROR, clear_delay=None):
    """
    Set the `text` of the label. The text is displayed in bold style.
    
    If the text is too wide to fit the label or the text has multiple lines,
    ellipsize the label and display a button that displays a popup containing
    the full text when clicked. Only the first line is displayed in the label.
    
    If `message_type` is `gtk.MESSAGE_ERROR`, use the red font color.
    For other message types, use the font color assigned by the current theme.
    
    If `clear_delay` is not `None` and `message_type` is not
    `gtk.MESSAGE_ERROR`, make the message automatically disappear after the
    specified delay in milliseconds. The timer is stopped if the popup is
    displayed and restarted if the popup gets hidden.
    """
    if not text:
      self._label_text = ""
      self._popup_text_lines = []
      self._label_message.set_text(self._label_text)
      return
    
    lines = text.strip().split("\n")
    
    first_line = lines[0]
    first_line = first_line[0].upper() + first_line[1:]
    if not first_line.endswith("."):
      first_line += "."
    
    self._label_text = first_line
    self._popup_text_lines = lines[1:]
    self._message_type = message_type
    self._clear_delay = clear_delay
    
    if message_type == gtk.MESSAGE_ERROR:
      self._label_message.set_markup(
        '<span foreground="red"><b>{}</b></span>'.format(gobject.markup_escape_text(
          self._label_text.encode(pg.GTK_CHARACTER_ENCODING))))
      self._timeout_remove_strict(self._clear_delay, self.set_text)
    else:
      self._label_message.set_markup(
        "<b>{}</b>".format(gobject.markup_escape_text(
          self._label_text.encode(pg.GTK_CHARACTER_ENCODING))))
      self._timeout_add_strict(self._clear_delay, self.set_text, None) 
Example #17
Source File: operations.py    From gimp-plugin-export-layers with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, operation, pdb_procedure, *args, **kwargs):
    super().__init__(*args, **kwargs)
    
    self.set_transient()
    self.set_resizable(False)
    
    self._button_ok = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
    self._button_cancel = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
    self.set_alternative_button_order([gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL])
    
    self._button_reset = gtk.Button()
    self._button_reset.set_label(_("_Reset"))
    self.action_area.pack_start(self._button_reset, expand=False, fill=False)
    self.action_area.set_child_secondary(self._button_reset, True)
    
    self._label_procedure_name = pg.gui.EditableLabel()
    self._label_procedure_name.label.set_use_markup(True)
    self._label_procedure_name.label.set_ellipsize(pango.ELLIPSIZE_END)
    self._label_procedure_name.label.set_markup(
      "<b>{}</b>".format(gobject.markup_escape_text(operation["display_name"].value)))
    self._label_procedure_name.connect(
      "changed", self._on_label_procedure_name_changed, operation)
    
    if pdb_procedure is not None:
      self._label_procedure_short_description = gtk.Label()
      self._label_procedure_short_description.set_line_wrap(True)
      self._label_procedure_short_description.set_alignment(0.0, 0.5)
      self._label_procedure_short_description.set_label(pdb_procedure.proc_blurb)
      self._label_procedure_short_description.set_tooltip_text(pdb_procedure.proc_help)
    
    self._table_operation_arguments = gtk.Table(homogeneous=False)
    self._table_operation_arguments.set_row_spacings(self._TABLE_ROW_SPACING)
    self._table_operation_arguments.set_col_spacings(self._TABLE_COLUMN_SPACING)
    
    # Put widgets in a custom `VBox` because the action area would otherwise
    # have excessively thick borders for some reason.
    self._vbox = gtk.VBox()
    self._vbox.set_border_width(self._DIALOG_BORDER_WIDTH)
    self._vbox.set_spacing(self._DIALOG_VBOX_SPACING)
    self._vbox.pack_start(self._label_procedure_name, expand=False, fill=False)
    if pdb_procedure is not None:
      self._vbox.pack_start(
        self._label_procedure_short_description, expand=False, fill=False)
    self._vbox.pack_start(self._table_operation_arguments, expand=True, fill=True)
    
    self.vbox.pack_start(self._vbox, expand=False, fill=False)
    
    self._set_arguments(operation, pdb_procedure)
    
    self.set_focus(self._button_ok)
    
    self._button_reset.connect("clicked", self._on_button_reset_clicked, operation)
    self.connect("response", self._on_operation_edit_dialog_response)