Giter VIP home page Giter VIP logo

Comments (15)

bluss avatar bluss commented on May 26, 2024 2

This is actually a very simple plugin, to just toggle the GtkSettings flag. It's much neater and easier to design the user interface by adding a plugin rather than remaking the preferences and connecting different parts of the app. I'm partial to this as a solution to this issue of “Prefer Dark Theme Variant” toggle.

__kupfer_name__ = _("Prefer Dark Theme")
__description__ = ""
__version__ = "2017.1"
__author__ = ""

from gi.repository import Gtk

from kupfer import plugin_support, pretty

__kupfer_settings__ = plugin_support.PluginSettings(
    {
        "key" : "prefer_dark",
        "label": _("Prefer Dark Theme"),
        "type": bool,
        "value": True,
    },
)

def initialize_plugin(name):
    use_theme(__kupfer_settings__['prefer_dark'])
    __kupfer_settings__.connect_settings_changed_cb(on_change_theme)

def finalize_plugin(name):
    use_theme(None)

def on_change_theme(sender, key, value):
    use_theme(value)

PREFER_DARK = "gtk-application-prefer-dark-theme"

def use_theme(enabled):
    pretty.print_debug(__name__, "updating setting to", enabled)
    s = Gtk.Settings.get_default()
    if enabled is None:
        s.reset_property(PREFER_DARK)
    else:
        s.set_property(PREFER_DARK, enabled)

from kupfer.

bluss avatar bluss commented on May 26, 2024 1

Since kupfer has already named its window and widgets, it should be possible to put specific css for it in the user's gtk.css file. Some theme support is needed if themes should be able to change position/orientation of some widgets or have a theme selector in preferences.

from kupfer.

chaitanya-lakkundi avatar chaitanya-lakkundi commented on May 26, 2024 1

I have made a PR with partial support to dark theme (only using CSS).
If needed, I can make changes to incorporate any other colour theme (using colorpicker) as well.

from kupfer.

bluss avatar bluss commented on May 26, 2024

Right, this makes sense.

Educate me, I'm new to Gtk 3. Does every theme have "the dark variant" of itself? How would it be selected?

from kupfer.

ishouldbedany avatar ishouldbedany commented on May 26, 2024

I'm just a curious end user, but my understading is that you can bundle a dark variant of your theme and it will be used in applications that specifically request it (media-heavy applications, like GNOME Photos or Totem, do it). If an application requests a dark theme variant and the current theme does not have it, it falls back to the regular variant.

GNOME default theme, Elementary, and other popular community themes have dark variants.

from kupfer.

bluss avatar bluss commented on May 26, 2024

Indeed, there seems to be no more mystery than this: https://lazka.github.io/pgi-docs/index.html#Gtk-3.0/classes/Settings.html#Gtk.Settings.props.gtk_application_prefer_dark_theme

I would prefer to load a kupfer-specific gtk 3 settings.ini for this. It would solve most of the issues of user theme customization.

from kupfer.

khurshid-alam avatar khurshid-alam commented on May 26, 2024

Yes custom-theme-plugin is missing from new kupfer. In old kupfer user can choose light or dark version from preference. And I wouldn't want to depend on gtk-application-prefer-dark-theme as not every theme provide a proper dark-scheme (it theme doesn't have a dark-scheme, it will fall back to default dark-scheme which may not look good).

Here is my suggestion:

  1. Provide a dark-theme-mode in plugins/preference like before. It can be hardcoded.

  2. In addition, Kupfer should also provide ability to theme it using css. It will overwrite the default (light or dark) theme.

@chaitanya-lakkundi opened a pull-request before (#49) regarding this. I think his last couple of commits (which doesn't change the layout) are exactly what we are looking for. He commented that he would create another PR only for css-capability without changing the layout or adding anything extra.

from kupfer.

bluss avatar bluss commented on May 26, 2024

On the topic of theming, rounded corners of the window were lost in the migration to Gtk 3. It looks like the Apis for cairo regions is not properly exposed in gi, so there is no way to call shape_combine_region to have rounded corners.

from kupfer.

khurshid-alam avatar khurshid-alam commented on May 26, 2024

@bluss

Since kupfer has already named its window and widgets, it should be possible to put specific css for it in the user's gtk.css file.

Are you referring to something like this?

#kupfer {
    background: @theme_bg_color;
}

.matchview {
    border-radius: 25px;
}

#kupfer-preedit {
}

#kupfer-object-pane {
}

#kupfer-action-pane {
}

#kupfer-indirect-object-pane {
}

#kupfer-list {
}

#kupfer-list-view {
}

*:selected .matchview {
    font-size: 25px;
}

from kupfer.

bluss avatar bluss commented on May 26, 2024

I know next to nothing about css theming, but yes, those are the widget names. It should be possible to scope the rules even tighter so they only apply to windows named #kupfer or so.

Start of doc is https://kupferlauncher.github.io/Documentation/GTKTheming.html

from kupfer.

bluss avatar bluss commented on May 26, 2024

For example using window#kupfer .matchview { border-radius: 45px; }. I'm unsure myself how the nesting rules work.

from kupfer.

khurshid-alam avatar khurshid-alam commented on May 26, 2024

Yes. It would work. I am testing if it is working as intended.

Btw, is there any specific reason to set gtk requirement so high (3.22)? If it is because of themming, we can theme it for both gtk-3.18 and >=gtk-3.20.

from kupfer.

bluss avatar bluss commented on May 26, 2024

The reason given in the README was honest: With a new port, I have never tried any Gtk version other than 3.22, and thus I don't know anything more than that 3.22 works.

I've tried 3.20 by now and it seems to work fine.

from kupfer.

chaitanya-lakkundi avatar chaitanya-lakkundi commented on May 26, 2024

A very good and neat solution indeed !
Just another idea (related to the issue of changing layout ).

We can separate the view and controller by providing a separate XML file for the Layout (hbox and vbox etc. ) and then load that file using a function. In this way we can provide multiple layout functionality for the user.

A new layout would just mean creating a new xml file. We can extend the xml file to provide options to hide panes, change font size, alter height and width etc.

Please suggest your opinions on this thought.

from kupfer.

bluss avatar bluss commented on May 26, 2024

The simple toggle is in kupfer 319, it's a new plugin. Note that it can be used to prefer the GTK light theme if the global default is prefer dark, too.

Now for more specific kupfer themeing, that's a different thing.

from kupfer.

Related Issues (20)

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.