107 questions
0
votes
0
answers
21
views
How to implement Gtk 4 Rust file drag and drop?
I have been trying to implement a simple drag and drop application in Gtk 4 Rust but I am unable to implement a working version. I can see connect_accept getting triggered, but no matter the result, ...
0
votes
0
answers
17
views
gtk4-rs dispose_template dispose doesn't dispose non-bound widgets
Dispose tempalte disposes only bound widgets. Is there a way to dispose all children graph?
Here are the details.
Object implementation:
#[derived_properties]
impl ObjectImpl for MyWidget {
...
0
votes
1
answer
51
views
How to Create a File Tree in GTK-RS/Relm4?
I've been struggling with this for a while, and I've almost got it- but not quite. This is what I have so far:
pub fn load_folder_view(state: &mut State) {
let path = state.current_folder_path....
0
votes
0
answers
70
views
Having issue centering child in gtk4
I'm trying to develop a widget in gtk4 as follows:
let container = Box::new(Orientation::Horizontal, 0);
let workspace_num = Label::new(Some("11"));
let workspace_num_box = gtk4::Box::new(...
0
votes
0
answers
72
views
fitting picture to the display in gtk-rs
Right now I have some simple code that looks like this:
let window = gtk4::ApplicationWindow::new(application);
window.set_default_size(1920, 1080);
let file = <setup for a functional path>;
...
0
votes
0
answers
48
views
How can I create a GVariant type that accepts GtkRGB?
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' ...
0
votes
0
answers
75
views
RefCell being set to None when moved to a thread
I followed this post and I was able to successfully the channels and global resources. However, when I invoke the sender thread it says that the RefCell that contains my sender and global resource is ...
0
votes
1
answer
57
views
how to deal with "the trait bound `ObjectImplRef<imp::Window>: IsA<gtk4::Window>` is not satisfied" in gtk4-rs?
I use gtk4-rs to build a gui program. the 1st parameter of the select_folder function shows an error: "the trait bound ObjectImplRef<imp::Window>: IsA<gtk4::Window> is not satisfied&...
0
votes
1
answer
49
views
How to modify a pixbuf when mouse is pressed in GTK-rs?
I'm trying to modify a pixbuf when the left mouse button is clicked but I don't think it's being modified. The modify_pixel function simply takes a specific pixel from the pixbuf and modifies it.
fn ...
0
votes
1
answer
854
views
pango.pc not found even though PKG_CONFIG_PATH environment variable is configured
RHEL 9.4 does not have the PKG_CONFIG_PATH environment variable configured even though pkg-config is installed. Therefore, cargo cannot build pango-sys because the pango.pc file is needed. Setting the ...
1
vote
0
answers
120
views
gtk-rs render to aribtrary wayland surface
I am trying to implement a wayland lockscreen using the ext-session-lock-v1 protocol.
However, due to the protocols design, the UI has to be rendered on custom pre-designated surfaces assigned for the ...
0
votes
1
answer
357
views
How can I connect signals from an UI file via `gtk4::Builder`?
I'm trying to connect the signal from this UI file:
<interface>
<object class="GtkApplicationWindow" id="appwin1">
<child>
<object class="...
0
votes
1
answer
94
views
Rust and GTK Text Editor: Troubleshooting Undo and Redo Operations with Shared Data
I have been working hard on my own text editor as a way to learn Rust. But even with the help of ChatGPT and the entirety of Stack Overflow already asked questions I have reached a roadblock.
I cant ...
0
votes
1
answer
934
views
(gtk4-rs) How to remove titlebar from window
I recently started using GTK4 with gtk-rs for an application I am creating. I don't like the way the default titlebar ever looks, and I want to remove it. I want to keep the other decorations, such as ...
0
votes
1
answer
192
views
How to calculate size of gtk4-rs widget with custom function
I have custom subclass of gtk::Box, I need to make it calculate width based on parent(50% for example) and height using aspect ratio that needs to be specified.
I tried implementing size_allocate ...
0
votes
1
answer
439
views
Rendering SVG icons in GTK4 apps on Windows
I wonder what is necessary to render theme aware icons in gtk-rs (GTK4) on Windows. I added icons to resources and can successfully render PNG files. Drop-in replacement with SVG does not render ...
0
votes
0
answers
127
views
How to get all items from a GtkComboBoxText in GTK4 (Rust, GTK-Rs)?
What I wanna do is set the selected item in ComboboxText. I know that should be done using set_active() method, but that requires a position (index). All I have is the selected value (string).
So I ...
0
votes
0
answers
58
views
How to create a generic function that supports multiple Widget types in Rust / GTK-rs?
In nutshell, I wanna create this func (not valid Rust):
fn foo<T: IsA<CheckButton> | T: IsA<ToggleButton>>(...) {
...
widget.is_active() // where widget is either a ...
3
votes
3
answers
271
views
how to get the state of a grouped gtk.CheckButton using Action
I'm trying to get the state of a gtk.CheckButton using Action since gtk docs says:
When the code must keep track of the state of a group of radio buttons, it is recommended to keep track of such ...
2
votes
1
answer
486
views
How do I create a `glib::MainContext::channel()` outside of the `connect_activate()` and then pass it in?
I am new to rust and GTK. I'd like to create a glib::MainContext::channel() pair prior to initializing my gtk::Application. I believe this can be thought of exactly like a std::sync::mpsc. And while I ...
1
vote
3
answers
127
views
How do you limit the number of GtkColumnView rows
I'm trying to reduce the load time of a ColumnView widget with lots of rows. quoting from
gtk list widget documentation:
While it is not a problem for short lists to instantiate widgets for every ...
0
votes
1
answer
125
views
Render on click on the GLArea (Glium backend)
I want to perform a render on click event on the GLArea. The problem is that when I call the drawing method from the event handler, the "canvas" does not change.
There is the my_draw_func() ...
0
votes
1
answer
564
views
Binding property from within custom GTK widget, `self` does not implement ObjectType despite being a widget [duplicate]
I'm using gtk-rs with GTK4. I have a custom widget representing a row in a GtkListView widget. My custom widget (MyRow) is defined exactly as done in the book (see https://github.com/gtk-rs/gtk4-rs/...
0
votes
1
answer
94
views
get contents from an entry box in gtk-rs with a button
I was trying to make a button that would get the contents of an entry box and print it to the terminal but I couldn't really find anything that helped. Could anyone help me?
I looked for solutions but ...
0
votes
1
answer
279
views
How to set the GTK4 tooltip delay in gtk-rs?
I can do like
let button = Button::builder().label("Click me..!")
.tooltip_text("You have to click this..!")
.margin_top(...
0
votes
1
answer
298
views
How to write custom Container in gtk-rs?
How can I write a custom Container in gtk-rs for GTK-3? I use gtk-rs 0.15.0 (to be compatible with the last GTK-3 compatible version of webkit2gtk). I couldn't find any reasonable documentation.
...
0
votes
1
answer
122
views
Get Parent From gtk-rs CompositeTemplate
How do I get the parent of a CompositeTemplate in gtk-rs?
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(resource = "/org/bil4x4/gnote/tree_view")]
pub struct ...
-3
votes
1
answer
746
views
How do I convert a Vector of Strings to [&str] [duplicate]
I have a vector of strings and a method that is accepting [&str]. When I provide the strings as string literals everything works however when I try to build the same vector dynamically using ...
0
votes
1
answer
78
views
Triggering code after the window has been shown
I'm using gtk-rs. I want to trigger some code after the window has been shown (has displayed on the screen):
window.connect_show(clone!(@weak window => move |_| {
let command = format!("...
0
votes
0
answers
360
views
How to properly use IconTheme with gtk-rs
I am having some trouble loading additional icons into a IconTheme. At the moment my code is adding the path which is showing correctly with search_path() however it always returns false when I check ...
1
vote
1
answer
431
views
Updating UI elements from a async loop
What is the standard method for updating UI elements from a loop calling a web request in Rust using gtk-rs? I am having trouble updating a label in a UI element to display some data from a web ...
0
votes
1
answer
187
views
value moved into closure here, in previous iteration of loop when setting value
I am trying to write a small app in gtk-rs that takes an input and checks if it is correct against a value and displays an error if it is not. I am struggling with handling the code to display the ...
0
votes
2
answers
750
views
gtk-rs Set maximum size of window
Is it possible to set the maximum size for a window in gtk-rs? When reading the documentation I can find lots of options to set the minimum window size and the default window size however I can not ...
0
votes
1
answer
214
views
How do I set the width of buttons when using stack switcher in gtk-rs
I am using gtk-rs to build an application and currently I am having some trouble adjusting the width of the buttons when using StackSwitcher. I have tried using CSS for this as the gtk-rs book seems ...
0
votes
1
answer
361
views
gtk-rs getting user input from button press
I am have a gtk-rs application where a Gtk::Entry is used to get user input when the user hits a submit button. Everything compiles and runs however I can not get the user input outside of the method ...
0
votes
1
answer
635
views
What is the gtk-rs design pattern for changing the widgets on a page?
I am using gtk-rs to build a small application and I am struggling with the concept of changing the widgets displayed on a page. So far I have been working through this guide but I have not found the ...
1
vote
1
answer
613
views
GTK-rs getting input from GTK::Entry
I have a small gtk-rs application where I am trying to display an input field and get the input from the user. At the moment I can't get the input from the input field when the user clicks the button. ...
0
votes
1
answer
189
views
How can I remove the duplication in this Rust code?
This working Rust code repeats itself somewhat:
fn append_column(tree: &TreeView, attribute: &str, id: i32) {
let column = TreeViewColumn::new();
match attribute {
"text&...
0
votes
1
answer
424
views
gtk-rs - rust - Use struct method as a callback function to a signal
I'm struggling to pass a method as a callback function, when calling connect_activate() on a gtk::Application, as shown in the code below. I've made a closure to avoid troubles concerning the &...
0
votes
1
answer
274
views
gtk-rs: Does a gtk4 widget hold a reference to its callbacks while a gtk3 widget doesn't?
I am porting a working gtk-rs application from gtk3 to gtk4. The following code is a reduced self-contained example to demonstrate the Problem. The code is for gtk3 with the changes required for gtk4 ...
1
vote
0
answers
249
views
Using SVG as css-background in GTK-rs
I have recently started working with gtk-rs for the first time and I'm trying to use an svg file defined in a css file as the background for a box. All my css on my other elements load in perfectly ...
1
vote
0
answers
621
views
Cannot build gtk4-rs based cargo, build fails with linking error "LINK : fatal error LNK1181: cannot open input file 'gobject-2.0.lib'"
I am trying to build a hello world project to see if gtk4-rs is working correctly, which always fails at creating the binaries. The rest of the build seems to fine (tried to run cargo clean and cargo ...
1
vote
1
answer
261
views
Making channels constructioned in a function last the lifetime of the program in Rust
I'm trying to write a basic multithreaded application using gtk3-rs, where the main thread sends a message to a child thread when a button is clicked, and the child thread sends a message back in ...
2
votes
1
answer
258
views
how to share information globally in gtk-rs Application
I am trying to build an Application in Rust with gtk-rs. When the user creates a new project the path to the project root needs to be stored in some way so that it is accessible to all of the ...
1
vote
1
answer
689
views
How to store Rust object without Default in GObject
I am basically following the gtk-rs book to create a simple app. I have the following rust struct, which I want to display in a ListView. This struct is basically read-only and should not be edited, ...
0
votes
1
answer
212
views
Update the values of child objects at runtime
How I can update child widget of gtk::Grid (gtk::Label in example) in runtime?
In example code after change value SpinButton, I add recreated Grid (fn grid()) with updated childs (I don't want remove ...
0
votes
1
answer
552
views
Gtk-rs pass window as value
New to Rust and I'm trying to build a simple Rust GUI using gtk-rs following the docs here. What I'm wondering is whether it's possible to pass around the window that gets built in the build_ui ...
-1
votes
1
answer
303
views
Trying to call gtk main loop in gtk-rs
I'm trying to make a simple window with gtk4-rs
i honestly can't find documentation for how to call the main gtk loop
use gtk::prelude::*;
fn main() {
// call gtk::init() to initialize gtk.
...
0
votes
1
answer
1k
views
Error LNK1181: cannot open input file 'gobject-2.0.lib'
I am trying to build a gtk-4 GUI application with the Rust in VScode, but I am unable to because I can't build my project. What could be the problem? How do I fix it?
Here's the error
fatal error ...
0
votes
1
answer
183
views
libadwaita-rs 1.1 missing check_template_children
I'm trying to use libadwaita 1.1 in my Gtk-rs (GTK 4) application in order to access the new PreferenceGroup suffix feature introduced in 1.1. However, when I update my Cargo.toml to use libadwaita 0....