0

I'm trying to bind the RGBA property of a ColorDialogButton in a GTK4 application in rust. However, Glib always throws me some variation of 'rgba' on class 'GtkColorDialogButton' has type 'GdkRGBA' which is not compatible with type 's' of key 'color'.

In the gschema file I've tried changing the type to tuples, arrays, dictionaries, tuples of floats, tuples of integers and variant but the error occurs and the widget is not bound correctly.

How can I create a type that accepts GtkRGBA?

Rust example:

use gtk::{
    self,
    gio::Settings,
    glib::{self},
    prelude::*,
    Application, ApplicationWindow, ColorDialogButton,
};

const APP_ID: &str = "org.Waytrogen.Waytrogen";

fn main() -> glib::ExitCode {
    // Create a new application
    let app = Application::builder().application_id(APP_ID).build();

    app.connect_activate(build_ui);

    // Run the application
    app.run()
}

fn build_ui(app: &Application) {
    let window = ApplicationWindow::builder()
        .application(app)
        .title("Waytrogen")
        .build();

    window.present();

    let settings = Settings::new(APP_ID);

    let color_dialog_button = ColorDialogButton::builder().build();
    settings.bind("color", &color_dialog_button, "rgba").build();
}

gschema example:

<?xml version="1.0" encoding="utf-8"?>
<schemalist>
    <schema id="org.Waytrogen.Waytrogen" path="/org/Waytrogen/Waytrogen/">
        <key name="color" type="s">
            <default>"rgb(255,255,255)"</default>
            <summary>Last set swaybg solid color</summary>
        </key>
    </schema>
</schemalist>
1
  • 1
    There is no color datatype in a GSchema file. I would recommend using a String (for example a HEX String) and then parsing the actual gdk4::RGBA from that string. Commented Jan 1 at 18:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.