Example #1
0
    def status(self):
        """Return the status for the entry's path."""

        model = cola.model()
        unmerged = utils.add_parents(set(model.unmerged))
        modified = utils.add_parents(set(model.modified))
        staged = utils.add_parents(set(model.staged))
        untracked = utils.add_parents(set(model.untracked))
        upstream_changed = utils.add_parents(set(model.upstream_changed))

        if self.path in unmerged:
            return (resources.icon('modified.png'), qtutils.tr('Unmerged'))
        if self.path in modified and self.path in staged:
            return (resources.icon('partial.png'),
                    qtutils.tr('Partially Staged'))
        if self.path in modified:
            return (resources.icon('modified.png'), qtutils.tr('Modified'))
        if self.path in staged:
            return (resources.icon('staged.png'), qtutils.tr('Staged'))
        if self.path in upstream_changed:
            return (resources.icon('upstream.png'),
                    qtutils.tr('Changed Upstream'))
        if self.path in untracked:
            return (None, '?')
        return (None, '')
Example #2
0
def icon_file(filename, staged=False, untracked=False):
    """Returns a file path representing a corresponding file path."""
    if staged:
        if core.exists(filename):
            ifile = resources.icon('staged-item.png')
        else:
            ifile = resources.icon('removed.png')
    elif untracked:
        ifile = resources.icon('untracked.png')
    else:
        ifile = utils.file_icon(filename)
    return ifile
Example #3
0
def file_icon(filename):
    """
    Returns the full path to an icon file corresponding to
    filename"s contents.
    """
    exists = core.exists(filename)
    return (resources.icon(ident_file_type(filename, exists)), exists)
Example #4
0
 def do(self):
     if not self.model.undoable():
         return
     s = selection.selection()
     if s.staged:
         items_to_undo = s.staged
     else:
         items_to_undo = s.modified
     if items_to_undo:
         if not Interaction.confirm(
                 N_('Revert Unstaged Changes?'),
                 N_('This operation drops unstaged changes.\n'
                    'These changes cannot be recovered.'),
                 N_('Revert the unstaged changes?'),
                 N_('Revert Unstaged Changes'),
                 default=True,
                 icon=resources.icon('undo.svg')):
             return
         args = []
         if not s.staged and self.model.amending():
             args.append(self.model.head)
         do(Checkout, args + ['--'] + items_to_undo)
     else:
         msg = N_('No files selected for checkout from HEAD.')
         Interaction.log(msg)
Example #5
0
def create_treeitem(filename, staged=False, deleted=False, untracked=False):
    """Given a filename, return a TreeWidgetItem for a status widget

    "staged", "deleted, and "untracked" control which icon is used.

    """
    icon_name = icons.status(filename, deleted, staged, untracked)
    return TreeWidgetItem(filename, resources.icon(icon_name), deleted=deleted)
Example #6
0
def create_treeitem(filename, staged=False, untracked=False, check=True):
    """Given a filename, return a QListWidgetItem suitable
    for adding to a QListWidget.  "staged" and "untracked"
    controls whether to use the appropriate icons."""
    if check:
        ifile = icon_file(filename, staged=staged, untracked=untracked)
    else:
        ifile = resources.icon('staged.png')
    return create_treewidget_item(filename, ifile)
Example #7
0
 def default_pixmap_as_bytes(self):
     xres = self.imgsize
     pixmap = QtGui.QPixmap(resources.icon('git.svg'))
     pixmap = pixmap.scaledToHeight(xres, Qt.SmoothTransformation)
     byte_array = QtCore.QByteArray()
     buf = QtCore.QBuffer(byte_array)
     buf.open(QtCore.QIODevice.WriteOnly)
     pixmap.save(buf, 'PNG')
     buf.close()
     return byte_array
Example #8
0
def create_treeitem(filename, staged=False, deleted=False, untracked=False):
    """Given a filename, return a TreeListItem suitable for adding to a
    QListWidget.  "staged", "deleted, and "untracked" control whether to use
    the appropriate icons."""
    if deleted:
        icon_name = 'removed.png'
    elif staged:
        icon_name = 'staged-item.png'
    elif untracked:
        icon_name = 'untracked.png'
    else:
        icon_name = icon_name_for_filename(filename)
    return TreeWidgetItem(filename, resources.icon(icon_name), deleted=deleted)
Example #9
0
    def do(self):
        files = self.filenames
        if not files:
            return

        title = N_('Delete Files?')
        msg = N_('The following files will be deleted:') + '\n\n'
        msg += file_summary(files)
        info_txt = N_('Delete %d file(s)?') % len(files)
        ok_txt = N_('Delete Files')

        if not Interaction.confirm(title, msg, info_txt, ok_txt,
                                   default=True,
                                   icon=resources.icon('remove.svg')):
            return

        return RemoveFiles.do(self)
Example #10
0
def information(title, message=None, details=None, informative_text=None):
    """Show information with the provided title and message."""
    if message is None:
        message = title
    mbox = QtGui.QMessageBox(active_window())
    mbox.setStandardButtons(QtGui.QMessageBox.Close)
    mbox.setDefaultButton(QtGui.QMessageBox.Close)
    mbox.setWindowTitle(title)
    mbox.setWindowModality(Qt.WindowModal)
    mbox.setTextFormat(Qt.PlainText)
    mbox.setText(message)
    if informative_text:
        mbox.setInformativeText(informative_text)
    if details:
        mbox.setDetailedText(details)
    # Render git.svg into a 1-inch wide pixmap
    pixmap = QtGui.QPixmap(resources.icon('git.svg'))
    xres = pixmap.physicalDpiX()
    pixmap = pixmap.scaledToHeight(xres, Qt.SmoothTransformation)
    mbox.setIconPixmap(pixmap)
    mbox.exec_()
Example #11
0
 def __init__(self):
     ConfirmAction.__init__(self)
     self.model = main.model()
     self.icon = resources.icon('undo.svg')
Example #12
0
def file_icon(filename):
    """
    Returns the full path to an icon file corresponding to
    filename"s contents.
    """
    return resources.icon(ident_file_type(filename))
Example #13
0
def icon(basename):
    """Given a basename returns a QIcon from the corresponding cola icon."""
    return QtGui.QIcon(resources.icon(basename))
Example #14
0
def icon_from_filename(filename):
    icon_name = icon_name_for_filename(filename)
    return cached_icon_from_path(resources.icon(icon_name))