Exemple #1
0
    def __init__(self, window, pluginHelper, query):
        self._window = window
        self.pluginHelper = pluginHelper
        self.pluginHelper.registerSearcher(self)
        self.query = query
        self.files = {}
        self.numMatches = 0
        self.numLines = 0
        self.wasCancelled = False
        self.searchProcess = None
        self._collapseAll = False  # if true, new nodes will be displayed collapsed

        self._createResultPanel()
        self._updateSummary()

        # searchSummary = "<span size=\"smaller\" foreground=\"#585858\">searching for </span><span size=\"smaller\"><i>%s</i></span><span size=\"smaller\" foreground=\"#585858\"> in </span><span size=\"smaller\"><i>%s</i></span>" % (query.text, query.directory)
        searchSummary = (
            '<span size="smaller">'
            + _("searching for <i>%(keywords)s</i> in <i>%(folder)s</i>")
            % {
                "keywords": escapeMarkup(query.text),
                "folder": escapeMarkup(gobject.filename_display_name(query.directory)),
            }
            + "</span>"
        )
        self.treeStore.append(None, [searchSummary, "", 0])

        self.searchProcess = SearchProcess(query, self)
        self._updateSummary()
Exemple #2
0
    def __init__(self, window, pluginHelper, query):
        self._window = window
        self.pluginHelper = pluginHelper
        self.pluginHelper.registerSearcher(self)
        self.query = query
        self.files = {}
        self.numMatches = 0
        self.numLines = 0
        self.wasCancelled = False
        self.searchProcess = None
        self._collapseAll = False  # if true, new nodes will be displayed collapsed

        self._createResultPanel()
        self._updateSummary()

        #searchSummary = "<span size=\"smaller\" foreground=\"#585858\">searching for </span><span size=\"smaller\"><i>%s</i></span><span size=\"smaller\" foreground=\"#585858\"> in </span><span size=\"smaller\"><i>%s</i></span>" % (query.text, query.directory)
        searchSummary = "<span size=\"smaller\">" + _(
            "searching for <i>%(keywords)s</i> in <i>%(folder)s</i>") % {
                'keywords': escapeMarkup(query.text),
                'folder': escapeMarkup(
                    gobject.filename_display_name(query.directory))
            } + "</span>"
        self.treeStore.append(None, [searchSummary, '', 0])

        self.searchProcess = SearchProcess(query, self)
        self._updateSummary()
Exemple #3
0
    def tags_win_update(self, window, tags, entries, entries_names):
        current_tag = tags[self.tagnum]
        tag = tagpy.FileRef(current_tag['fullpath']).tag()
        # Update interface:
        for entry, entry_name in zip(entries, entries_names):
            # Only retrieve info from the file if the info hasn't changed
            if not current_tag[entry_name + "-changed"]:
                current_tag[entry_name] = getattr(tag, entry_name, '')
            tag_value = current_tag[entry_name]
            if tag_value == 0:
                tag_value = ''
            entry.set_text(str(tag_value).strip())

            # Revert text color if this tag wasn't changed by the user
            if not current_tag[entry_name + "-changed"]:
                self.tags_win_entry_revert_color(entry)

        self.curr_mpdpath = gobject.filename_display_name(current_tag['mpdpath'])
        filename = self.curr_mpdpath
        if not self.use_mpdpaths:
            filename = os.path.basename(filename)
        self.filelabel.set_text(filename)
        entries[0].grab_focus()
        window.set_title(_("Edit Tags - %s of %s") %
                    (self.tagnum+1, len(tags)))
        self.tags_win_set_sensitive(window.action_area)
Exemple #4
0
    def tags_win_update(self, window, tags, entries, entries_names):
        current_tag = tags[self.tagnum]
        tag = tagpy.FileRef(current_tag['fullpath']).tag()
        # Update interface:
        for entry, entry_name in zip(entries, entries_names):
            # Only retrieve info from the file if the info hasn't changed
            if not current_tag[entry_name + "-changed"]:
                current_tag[entry_name] = getattr(tag, entry_name, '')
            tag_value = current_tag[entry_name]
            if tag_value == 0:
                tag_value = ''
            entry.set_text(str(tag_value).strip())

            # Revert text color if this tag wasn't changed by the user
            if not current_tag[entry_name + "-changed"]:
                self.tags_win_entry_revert_color(entry)

        self.curr_mpdpath = gobject.filename_display_name(
            current_tag['mpdpath'])
        filename = self.curr_mpdpath
        if not self.use_mpdpaths:
            filename = os.path.basename(filename)
        self.filelabel.set_text(filename)
        entries[0].grab_focus()
        window.set_title(
            _("Edit Tags") + " - " + str(self.tagnum + 1) + " " + _("of") +
            " " + str(len(tags)))
        self.tags_win_set_sensitive(window.action_area)
Exemple #5
0
def get_filename(self):
    """Shortcut to get a properly-encoded filename from a file chooser"""
    filename = self.file_chooser.get_filename()
    if filename and gtk.gtk_version >= (2, 10, 0):
        return gobject.filename_display_name(filename)
    else:
        return filename
Exemple #6
0
def get_preview_filename(self):
    '''Shortcut to get a properly-encoded preview filename'''
    filename = self.file_chooser.get_preview_filename()
    if filename and gtk.gtk_version >= (2, 10, 0):
        return gobject.filename_display_name(filename)
    else:
        return filename
Exemple #7
0
def get_preview_filename(self):
    '''Shortcut to get a properly-encoded preview filename'''
    filename = self.file_chooser.get_preview_filename()
    if filename and gtk.gtk_version >= (2, 10, 0):
        return gobject.filename_display_name(filename)
    else:
        return filename
 def get_short_description (self):
     utf8_rel_path = gobject.filename_display_name (self.rel_path)
     if self.event == dirmonitor.CREATED:
         return _("File '%s' created") % utf8_rel_path
     elif self.event == dirmonitor.DELETED:
         return _("File '%s' deleted") % utf8_rel_path
     elif self.event == dirmonitor.CHANGED:
         return _("File '%s' changed") % utf8_rel_path
Exemple #9
0
def get_display_path_for_bytestring(filepath):
    """Return a unicode path for display for bytestring @filepath

	Will use glib's filename decoding functions, and will
	format nicely (denote home by ~/ etc)
	"""
    desc = gobject.filename_display_name(filepath)
    homedir = os.path.expanduser("~/")
    if desc.startswith(homedir) and homedir != desc:
        desc = desc.replace(homedir, "~/", 1)
    return desc
Exemple #10
0
def get_display_path_for_bytestring(filepath):
	"""Return a unicode path for display for bytestring @filepath

	Will use glib's filename decoding functions, and will
	format nicely (denote home by ~/ etc)
	"""
	desc = gobject.filename_display_name(filepath)
	homedir = os.path.expanduser("~/")
	if desc.startswith(homedir) and homedir != desc:
		desc = desc.replace(homedir, "~/", 1)
	return desc
Exemple #11
0
 def get_short_description (self):
     utf8_rel_path = gobject.filename_display_name (self.rel_path)
     if os.path.isdir(self.rel_path):
         filetype = _("Directory")
     elif os.path.islink(self.rel_path):
         filetype = _("Link")
     else:
         filetype = _("File")
     if self.event == dirmonitor.CREATED:
         return _("%s '%s' created") % (filetype, utf8_rel_path)
     elif self.event == dirmonitor.DELETED:
         return _("%s '%s' deleted") % (filetype, utf8_rel_path)
     elif self.event == dirmonitor.CHANGED:
         return _("%s '%s' changed") % (filetype, utf8_rel_path)
Exemple #12
0
    def _addResultFile(self, filename):
        dispFilename = filename
        # remove leading search directory part if present:
        if dispFilename.startswith(self.query.directory):
            dispFilename = dispFilename[len(self.query.directory):]
            dispFilename.lstrip("/")
        dispFilename = gobject.filename_display_name(dispFilename)

        (directory, file) = os.path.split(dispFilename)
        if directory:
            directory = os.path.normpath(directory) + "/"

        line = "%s<b>%s</b>" % (escapeMarkup(directory), escapeMarkup(file))
        it = self.treeStore.append(None, [line, filename, 0])
        return it
    def _addResultFile (self, filename):
        dispFilename = filename
        # remove leading search directory part if present:
        if dispFilename.startswith(self.query.directory):
            dispFilename = dispFilename[ len(self.query.directory): ]
            dispFilename.lstrip("/")
        dispFilename = gobject.filename_display_name(dispFilename)

        (directory, file) = os.path.split( dispFilename )
        if directory:
            directory = os.path.normpath(directory) + "/"

        line = "%s<b>%s</b>" % (escapeMarkup(directory), escapeMarkup(file))
        it = self.treeStore.append(None, [line, filename, 0])
        return it
    def __init__ (self, window, pluginHelper, query):
        self._window = window
        self.pluginHelper = pluginHelper
        self.pluginHelper.registerSearcher(self)
        self.query = query
        self.files = {}
        self.numMatches = 0
        self.numLines = 0
        self.wasCancelled = False

        self._createResultPanel()
        self._updateSummary()

        #searchSummary = "<span size=\"smaller\" foreground=\"#585858\">searching for </span><span size=\"smaller\"><i>%s</i></span><span size=\"smaller\" foreground=\"#585858\"> in </span><span size=\"smaller\"><i>%s</i></span>" % (query.text, query.directory)
        searchSummary = "<span size=\"smaller\">searching for <i>%s</i> in <i>%s</i></span>" % (
            escapeMarkup(query.text), escapeMarkup(gobject.filename_display_name(query.directory)))
        self.treeStore.append(None, [searchSummary, '', 0])

        self.searchProcess = SearchProcess(query, self)
    def __init__ (self, window, pluginHelper, query):
        self._window = window
        self.pluginHelper = pluginHelper
        self.pluginHelper.registerSearcher(self)
        self.query = query
        self.files = {}
        self.numMatches = 0
        self.numLines = 0
        self.wasCancelled = False

        self._createResultPanel()
        self._updateSummary()

        #searchSummary = "<span size=\"smaller\" foreground=\"#585858\">searching for </span><span size=\"smaller\"><i>%s</i></span><span size=\"smaller\" foreground=\"#585858\"> in </span><span size=\"smaller\"><i>%s</i></span>" % (query.text, query.directory)
        searchSummary = "<span size=\"smaller\">searching for <i>%s</i> in <i>%s</i></span>" % (
            escapeMarkup(query.text), escapeMarkup(gobject.filename_display_name(query.directory)))
        self.treeStore.append(None, [searchSummary, '', 0])

        self.searchProcess = SearchProcess(query, self)
Exemple #16
0
 def filename_for_display(self):
     """
     Returns the filename in a suitable for display form.
     """
     return gobject.filename_display_name(unquote_filename(self.filename))
Exemple #17
0
	def get_text_representation(self):
		return gobject.filename_display_name(self.object)
 def filename_for_display(self):
     """
     Returns the filename in a suitable for display form.
     """
     return gobject.filename_display_name(
             unquote_filename(self.filename))
Exemple #19
0
 def get_text_representation(self):
     return gobject.filename_display_name(self.object)