Home Download Buy Blog Forum Support

Sidebar icons in themes

Sidebar icons in themes

Postby jbrooksuk on Mon May 05, 2014 2:52 pm

I've taken a bit of time to figure out how sidebar icons are working in Sublime for the Soda theme, so I'm copying the content here to be of general use.

This is now a feature of Sublime Text Dev 3062. In the default theme, icons are stored in an `icons` directory. https://dl.dropboxusercontent.com/u/7323096/icons.zip

From there, the `sublime-theme` file includes this:

Code: Select all
{
    "class": "icon_file_type",
    // layer0.texture is filled in by code with the relevant icon name
    "layer0.opacity": 1.0,
    "content_margin": [8, 8]
},
{
    "class": "icon_folder",
    "layer0.texture": "Theme - Default/icons/folder.png",
    "layer0.opacity": 1.0,
    "content_margin": [8, 8]
},
{
    "class": "icon_folder",
    "parents":
    [
        { "class": "tree_row", "attributes": ["expanded"] }
    ],
    "layer0.texture": "Theme - Default/icons/folder_open.png",
},
{
    "class": "icon_folder_loading",
    "layer0.texture":
    {
        "keyframes":
        [
            "Theme - Default/icons/spinner7.png",
            "Theme - Default/icons/spinner6.png",
            "Theme - Default/icons/spinner5.png",
            "Theme - Default/icons/spinner4.png",
            "Theme - Default/icons/spinner3.png",
            "Theme - Default/icons/spinner2.png",
            "Theme - Default/icons/spinner1.png",
            "Theme - Default/icons/spinner.png",
        ],
        "loop": true,
        "frame_time": 0.075,
    },

    "layer0.opacity": 1.0,
    "content_margin": [8, 8]
},


Adding this to Soda should be straight forward now.
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sidebar icons in themes

Postby jbrooksuk on Mon May 05, 2014 2:59 pm

More!

There are also three files in the "Theme - Default" directory.

  • Icon (Markup).tmPreferences
  • Icon (Source).tmPreferences
  • Icon (Text).tmPreferences

These look like this:

Icon (Markup).tmPreferences:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>text.html, text.xml</string>
    <key>settings</key>
    <dict>
        <key>icon</key>
        <string>file_type_markup</string>
    </dict>
</dict>
</plist>


Icon (Source).tmPreferences
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>source</string>
    <key>settings</key>
    <dict>
        <key>icon</key>
        <string>file_type_source</string>
    </dict>
</dict>
</plist>


Icon (Text).tmPreferences
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>text</string>
    <key>settings</key>
    <dict>
        <key>icon</key>
        <string>file_type_text</string>
    </dict>
</dict>
</plist>


These seem to dictate what icon should be displayed based on the source.
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sidebar icons in themes

Postby jbrooksuk on Mon May 05, 2014 3:02 pm

I can't find any reference to a preference to turn icons off either, but that may be hidden?
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sidebar icons in themes

Postby gregor.hoch on Mon May 05, 2014 4:20 pm

This looks great! Does the new API allow plugins to change the icons? This could be used to color files and folders based on git status like in Atom (new, modified etc):
https://f.cloud.github.com/assets/67137 ... 33ad23.png
gregor.hoch
 
Posts: 144
Joined: Sat Oct 01, 2011 7:54 pm

Re: Sidebar icons in themes

Postby jbrooksuk on Mon May 05, 2014 4:22 pm

gregor.hoch wrote:This looks great! Does the new API allow plugins to change the icons? This could be used to color files and folders based on git status like in Atom (new, modified etc):
https://f.cloud.github.com/assets/67137 ... 33ad23.png

Unfortunately I'm unable to find any API that would allow this. The docs don't show it and there don't seem to be references in any of the default plugin files.
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sidebar icons in themes

Postby facelessuser on Mon May 05, 2014 4:53 pm

So, this only applies to the files under the folders? Or is there a way to make the icons appear for open files?

Image
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: Sidebar icons in themes

Postby jbrooksuk on Mon May 05, 2014 4:56 pm

facelessuser wrote:So, this only applies to the files under the folders? Or is there a way to make the icons appear for open files?


The icon files I've linked to don't show anyway of changing the icon when open, that's not to mean there isn't, but the default theme doesn't do this.
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sidebar icons in themes

Postby facelessuser on Mon May 05, 2014 4:59 pm

Cool. Well I at least have things looking normal again. I will have work on custom icons later and dig into understanding the full extent of what we can do now. In general it appears fairly limited, but still cool. It is a shame that the file options are all bundled under Default.sublime-plugin. I thought they could be overridden in the theme, but that doesn't appear to be so. You can override the icons in the theme, just not file association. Oh well, I need to get some work done now.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: Sidebar icons in themes

Postby jbrooksuk on Mon May 05, 2014 5:01 pm

facelessuser wrote:It is a shame that the file options are all bundled under Default.sublime-plugin. I thought they could be overridden in the theme, but that doesn't appear to be so. You can override the icons in the theme, just not file association. Oh well, I need to get some work done now.

Can you not use the scope to do so, like the Icon (Markup).tmPreferences stuff?
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sidebar icons in themes

Postby facelessuser on Mon May 05, 2014 5:08 pm

Maybe. There might be some dynamics at work here that I don't understand yet.

I tired to just copy the files to the theme, and then alter the scope, but no dice.

I plan on trying to create my own file types as well, maybe Icons (something).tmPreferences and use a different icon name in it. I may try this later today.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: applejosh, Google [Bot] and 22 guests