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

Remove styling #3

Merged
merged 1 commit into from May 28, 2015
Merged

Conversation

flying-sheep
Copy link

Users like to be able to select their own styles and themes.

I would never use something that diverges noticably from my system look&feel

Users like to be able to select their own styles and themes.
juancarlospaco added a commit that referenced this pull request May 28, 2015
@juancarlospaco juancarlospaco merged commit c94c62c into juancarlospaco:master May 28, 2015
@ghost
Copy link

ghost commented May 28, 2015

Thanks, we will work on more easy styling on the future... 😸 mainly for non-Qt DEs.

@flying-sheep flying-sheep deleted the patch-1 branch May 28, 2015 09:20
@flying-sheep
Copy link
Author

thank you! maybe a command line argument or environment variable will be the right approach.

and e.g. on OSX the visual style is already known, so we can detect if running there and apply a style sheet specific for OSX

@ghost
Copy link

ghost commented May 28, 2015

@flying-sheep I am thinking something like using ~/.unicodemoticons.css with a Style Sheet for Theming.

  • If no ~/.unicodemoticons.css file, write a basic default style sheet.
  • If ~/.unicodemoticons.css file, read style sheet from there and apply it.
  • Add new Option Set UI Style allows to Edit that ~/.unicodemoticons.css file.
  • The ~/.unicodemoticons.css opens with your favorite IDE/Editor/WYSIWYG-Editor.

Some friendly access for the CSS is needed anyway, on old GTK Desktops Qt5 by default looks ugly.

😃

@flying-sheep
Copy link
Author

make that $XDG_CONFIG_HOME/unicodemoticons/style.css or so and i’m all for it.

look here:

from pathlib import Path
import xdg

config_path = Path(xdg.BaseDirectory.save_config_path('unicodemoticons'))
css_path = config_path / 'style.css'

with css_path.open() as css_f:
    try:
        css = css_f.read()
    except IOError:
        css = None

if css == None:
    css = DEFAULT_CSS
    with css_path.open('w') as css_f:
        css_f.write(css)

@ghost
Copy link

ghost commented May 29, 2015

@flying-sheep I dont like style.css is obvious is the style, its like say javascript.js.
I think unicodemoticon.css is good, and why a folder if its a single file ❔
(We will use folder if we need multiple files, but its not the use case right now)

On Linux I dont have any $XDG_CONFIG_HOME,
I have $XDG_CONFIG_DIRS but those are root only and contains a list.

I am using the following, is more or less crossplatform:
style_file = os.path.join(os.path.expanduser("~"), ".unicodemoticon.css")

On Linux its /home/user/.unicodemoticon.css, always hidden file,
on Os X should be /Users/user/.unicodemoticons.css I dont have Mac anyways,
on Windows, well... it do not even support Unicode properly.

I dont have problem with pathlib since is Std Lib BuiltIn on Python3,
but I want to avoid being tied to third party xdg as much as possible.

The full function I am using right now and testing locally is:

def set_or_get_stylesheet(self, stylesheet=QSS_STYLE):
    style_file = os.path.join(os.path.expanduser("~"), ".unicodemoticon.css")
    if not os.path.isfile(style_file):
        with open(style_file, "w", encoding="utf-8") as style_file_object:
            style_file_object.write(stylesheet.strip())
    with open(style_file, "r", encoding="utf-8") as style_file_object:
        stylesheet = style_file_object.read().strip()
    return stylesheet

Thanks for Collaboration on this; Let me know what you think...
😄

@flying-sheep
Copy link
Author

On Linux I dont have any $XDG_CONFIG_HOME

the spec says that it’s ~/.config if the $XDG_CONFIG_HOME variable is not set.

and the spec is there in order to eliminate all the junk in ~:

$ ls .* | wc -l
1122

i’d love if you didn’t add to it and respect the XDG spec.

it’s also really easy to implement yourself if you don’t want to depend on pyxdg:

config_path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))

We will use folder if we need multiple files, but its not the use case right now

yeah, that was my motivation: we can also store a config file in there. and then it’s either .config/unicodemoticon/unicodemoticon.{css,js} or .config/unicodemoticon/{style.css,config.cfg} (or something else?)

@flying-sheep
Copy link
Author

oh, and to also ideally support other OSs:

if sys.platform.startswith('darwin'):
    config_path = os.path.expanduser(`~/Library/Preferences`)
else if sys.platform.startswith('win32'):
    config_path = os.getenv('APPDATA')
else:
    config_path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))

@ghost
Copy link

ghost commented May 30, 2015

Ok, will try to use that snippet this weekend, we are at ~ 7.777 Downloads / Month on UnicodEmoticons.

d-( ʘ‿ʘ )_m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants