Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use custom icon styles + dark icon set. #638

Merged
merged 4 commits into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cola/gitcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,7 @@ def color(self, key, default):
except Exception:
r, g, b = struct.unpack(struct_layout, unhexlify(default))
return (r, g, b)

def icon_style(self):
theme = self.get('cola.iconstyle', None)
return theme
8 changes: 7 additions & 1 deletion cola/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from qtpy import QtGui

from . import gitcfg
from . import qtcompat
from . import resources
from .compat import ustr
Expand All @@ -31,9 +32,14 @@
'.cxx': 'file-code.svg',
}

cfg = gitcfg.current()
style = cfg.icon_style()

def install():
icon_dir = resources.icon_dir()
if not style or style == "light":
icon_dir = resources.icon_dir()
else:
icon_dir = resources.icon_dir(style)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny tweak: for keyword arguments, prefer doing icon_dir(style=style) at the callsite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Will do, thanks for the correction.

Copy link
Member

@davvid davvid Jan 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is really the main change that I keep coming back to as a slightly unfortunate change in the relative dependencies. Previously the icons module was more pure, and didn't import anything, and we didn't have to call into git so early (during module import) so that we can defer a few things.

Sorry it's taken so long to get back to this one, but it's become a little clearer with time. Would it be okay if we made this something that's controlled via the environment instead?

There's already precedent for a few of these in the ENVIRONMENT VARIABLES section of docs/git-cola.rst, namely GIT_COLA_SCALE which is directly related to the UI. The reason these are done via the environment is that they affect the critical startup code paths that we've tried to keep as minimal as possible.

Would it be okay if we changed the style to be a lookup of os.environ.get('GIT_COLA_ICON_THEME', 'light')? Presumably we can then make the style optional argument into a required argument, and special-case it inside of icon_dir() instead.

I may merge this soon with these changes applied locally, which hopefully won't be too much of a hassle to upgrade to.

Example .bashrc/.xsessionrc:

GIT_COLA_ICON_THEME=dark
export GIT_COLA_ICON_THEME

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just following up -- not sure if you noticed but I ended up keeping the config-driven approach, and ended up augmenting it with --icon-theme=<theme> as well as allowing GIT_COLA_ICON_THEME in the environment. The only other minor difference is that the config variable is named cola.icontheme whereas it was originally cola.iconstyle.

qtcompat.add_search_path('icons', icon_dir)


Expand Down
11 changes: 9 additions & 2 deletions cola/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ def share(*args):
return prefix('share', 'git-cola', *args)


def icon_dir():
def icon_dir(style=None):
"""Return the path to the style dir within the cola install tree."""
return share('icons')
if style:
style_dir = share('icons', style)
if os.path.isdir(style_dir):
return style_dir
else:
return share('icons')
else:
return share('icons')


def config_home(*args):
Expand Down
7 changes: 7 additions & 0 deletions share/doc/git-cola/git-cola.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ cola.fontdiff
-------------
Specifies the font to use for `git cola`'s diff display.

cola.iconstyle
--------------
Specifies the icon style to use throughout `git-cola`. The style specified
must be the name of the subdirectory containing the icons, which in turn must be
placed in the main "icons" directory. If unset, or set to "light", then the
default style will be used.

cola.inotify
------------
Set to `false` to disable file system change monitoring. Defaults to `true`,
Expand Down
118 changes: 118 additions & 0 deletions share/git-cola/icons/dark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
Git Cola Dark Icons
--------------
All icons in this directory, besides color inversion,
are unmodified original ones. All kudos and copyrights go to their
respective authors ( see original readme bellow ).

2017 Filip Danilovic

--------------------

Git Cola Icons
--------------

The following icons are based on the based on the original .png icon designs
for git-cola's File Browser by Uri Okrent.

staged.svg
modified.svg
partial.svg
upstream.svg

Copyright (C) 2011 Uri Okrent
Copyright (C) 2015-2016 David Aguilar and contributors

License: MIT


Git Logo
--------
Git Logo by Jason Long is licensed under the
Creative Commons Attribution 3.0 Unported License.
http://git-scm.com/downloads/logos

git-cola.svg is based on the original Git Logo.


Octicons
--------
The following files are from Github's
[octicons](https://github.com/github/octicons) icon set:

check.svg
circle-slash.svg
desktop-download.svg
diff.svg
ellipsis.svg
eye.svg
file-binary.svg
file-code.svg
file-directory.svg
file-media.svg
file-text.svg
file-zip.svg
fold.svg
gear.svg
git-branch.svg
git-compare.svg
git-merge.svg
link-external.svg
pencil.svg
plus.svg
primitive-dot.svg
question.svg
question-plain.svg
repo-pull.svg
repo-push.svg
repo.svg
screen-full.svg
search.svg
star.svg
sync.svg
tag.svg
telescope.svg
trashcan.svg
unfold.svg
x.svg

Copyright (C) 2012-2015 GitHub
License: [MIT](http://choosealicense.com/licenses/mit/)


Gnome High Contrast Icons
-------------------------
The following files are from the Gnome High Contrast Icon set:

zoom-fit-best.svg
zoom-in.svg
zoom-out.svg

License: LGPL v2+


Flaticon.com Icons
------------------

The following files are designed by Freepik from http://www.flaticons.com/

edit-undo.svg

License: [Flatpik Basic License](http://cdn.flaticon.com/license/license.pdf)


The following files are by Linh Pham from http://flaticons.com/

edit-copy.svg

License: [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/)


Google Icons
------------

The following files are by Google:

edit-select-all.svg
file-download.svg

License: [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/)
53 changes: 53 additions & 0 deletions share/git-cola/icons/dark/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions share/git-cola/icons/dark/circle-slash-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions share/git-cola/icons/dark/circle-slash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions share/git-cola/icons/dark/desktop-download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading