Giter Club home page Giter Club logo

gtk-app-icons-test's Introduction

GTK App Icons Test

This is a simple application to test how GTK+ 4.0 behaves when loading symbolic SVG icons.

Programmers usually intend for symbolic icons to be recolored to the text foreground color, thus adapting to the light/dark theme in use. But this feature is only enabled for some use cases.

Screenshot

How to make recoloring work

  • The icon filename must be *-symbolic.svg.

  • The icon must be packaged inside a .gresource file.

  • The icon must be placed in a directory called scalable/CONTEXT where CONTEXT is one of the context directories listed in the Icon Naming Specification:

    • scalable/actions/
    • scalable/animations/
    • scalable/apps/
    • scalable/categories/
    • scalable/devices/
    • scalable/emblems/
    • scalable/emotes/
    • scalable/intl/
    • scalable/mimetypes/
    • scalable/places/
    • scalable/status/
  • The .gresource file must be loaded and registered:

    resource = Gio.Resource.load(base_path + "/icons.gresource")
    Gio.resources_register(resource)
  • When using GtkApplication, the application ID is used to derive a default search path, APP_ID/icons. For instance, if the application ID is org.gtk.app_icons_test, this resource path would work:

    • /org/gtk/app_icons_test/icons/scalable/emotes/foo-symbolic.svg

    When using different paths, you need to manually tell the IconTheme to search in it:

    theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
    theme.add_resource_path("/some/random/path")

    Then this would also work:

    • /some/random/path/scalable/emotes/foo-symbolic.svg
  • If the icon has only one color, the recoloring is as expected, it is replaced by the foreground color. If it has multiple colors, they will all receive the foreground color. GTK+ understands three symbolic colors: success, warning and error. The SVG elements must have class="success", class="warning" or class="error" for these colors to be used. See the icons/real-target-symbolic.svg for an example.

Running the test application

  • make

    • This will compile the icons.gresource file.
  • ./main.py

    • This will use the default theme.
  • ./main.py light

    • This will force the use of the light theme.
  • ./main.py dark

    • This will force the use of the dark theme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.