-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
Conversation
These icons are the color inverted original ones ( otherwise umodified ) Signed-off-by: Filip Danilović <filip@openmailbox.org>
Signed-off-by: Filip Danilović <filip@openmailbox.org>
Custom icon theme consists of a subdirectory of the main "icons" dir containing all icons existing in the original theme, using the same names and same file format (svg) Theme is set, as usual, with git config: git config (--global) cola.iconstyle style_name Where "style_name" is the exact name of the dir containing the icons. If the specified style doesn't exist, is set to "light", or not set at all, original icons will be used. Signed-off-by: Filip Danilović <filip@openmailbox.org>
Signed-off-by: Filip Danilović <filip@openmailbox.org>
if not style or style == "light": | ||
icon_dir = resources.icon_dir() | ||
else: | ||
icon_dir = resources.icon_dir(style) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
Awesome, this is pretty cool. I'm currently in the middle of switching ISPs so I have spotty internet access until next week, but I'll try to take a look soon so that we can move forward with this topic. I like several aspects of this idea:
I like the idea of allowing I have an idea that we could also use to generalize |
Thanks. No problem & no rush.
It would indeed. I guess I was leaning towards "style" because of "light" vs. "dark". Seemed more fitting...
+1 👍 There's one issue with custom icons, and that is if you specify an existing directory which has only a partial set, or no icons at all, Cola will start, but there will be missing icons ( or none at all ). |
* cofi89/dark-icons: setup: install dark icon set Add ability to load custom icons doc: document cola.iconstyle Add dark icon style Signed-off-by: David Aguilar <davvid@gmail.com>
Control the git-cola icon theme using the GIT_COLA_ICON_THEME environment variable. Related-to: #638 Signed-off-by: David Aguilar <davvid@gmail.com>
Related-to: #638 Signed-off-by: David Aguilar <davvid@gmail.com>
Related-to: #638 Signed-off-by: David Aguilar <davvid@gmail.com>
Allow `--icon-theme=<theme>` to override the icon theme. Add back the original config-based theme setting as well, since there is relatively little overhead to doing so. Related-to: #638 Signed-off-by: David Aguilar <davvid@gmail.com>
Regarding having a directory with a partial set of icons -- I think we can fix that by allowing e.g. git config --add cola.icontheme /path/to/custom/icons
git config --add cola.icontheme dark ... and then in cola we just need to call I'll try implementing that shortly. |
Allow cola.icontheme and GIT_COLA_ICON_THEME to contain multiple values. This allows for partial icon theme overriding by specifying a partial theme before specifying a fallback theme. Related-to: git-cola#638 Signed-off-by: David Aguilar <davvid@gmail.com>
Hey @davvid, Awesome job, esp. on the addition of the cmd line parameter. Thank you very much for accepting and much improving this! 👍 😃 Now, while this is perfectly fine as-is ( IMO atleast ), I'd like to mention/talk about one tidbit I left out originally to keep PR on topic: AFAIK, raster images render faster and ( when downsized ) are certanly going to end up much smaller in file size, thus reducing start-up time, however small and negligible the impact may be ( atleast on modern machines with SSD's )...? In short, is there a reason not to downsize the default icons to, say 32-48px ( which should also cover for HiDPI ), and convert them to png? |
Oh, there's not a reason for them to be as large as they are, that's just what's specified at the top of the file. A lot of the icons came from github's "octicons" icon set. What I really like about them is how tiny they are -- many of them are only ~300 bytes. svg is nice because it's resolution-independent. On Linux, at least, the icons are reasonably sized since Qt just scales it down to the size of the button. If we could just edit the svg text and size them down that would be okay, as long as the embedded paths are still valid. Are you seeing cases where the icons are too large when rendered by the app? I'd be interested in fixing those. We did have an open issue about the icons getting larger on OS X after switching to svg icons, and in that issue #550 there's additional notes about some things that were tried. I would like to avoid pngs. We had png icons in the past and they were ugly, but maybe there's something we can do app-side. What kinda issues are you sseing? My main test machines these days are a HiDPI linux laptop and a non-hidpi linux desktop, so I appreciate help from other angles. |
No, actually I haven't run into any issues per se, I'm just curious as to your thoughts, for the (primary) reason I'll get to later, and 'cause the size seems to be a bit unnecessarily large, which makes me think it makes Cola slower to start, due to resizing overhead and vector vs. raster, though it's nothing I've tested extensively/have any hard data on. But, I've had some issues with Inkscape color inversion preparing this PR, which made all svg's unrenderable by Cola/QT, so before finding/fixing the cause I converted them to XX*48 png's, ran a
Nope, I beleive that paths need to be changed as well ( not 100% sure, but AFAIK, it's either still gonna render at original size, or not at all ). And the other reason for asking about png vs svg I've mentioned, is that I've had this idea to make a set for Cola based on Faenza action icons, however I suck at vector graphics ( raster as well, though not as badly ). 😄 def merge():
return icon('git-merge') # Returns either png or svg So you can just drop a correctly named icons into "icons" dir, and have it JustWork™, regardless of image format. |
Hi David,
This being my first time playing with Cola source likelly means that there are better ways to do this.
But anyway, what I did here is hopefully good, works in my somewhat limited testing, and is in short:
In detail, custom icons:
cola.iconstyle style_name
, where "style_name" coresponds to the name of the subdir containing the iconscola.iconstyle
is unset, or "style_name" doesn't match any subdir in "icons", or "style_name" == "light", fallback to the default iconsWhat's missing:
Tested and working on:
In action:
....References: #568