Rust bindings for GTK+, Cairo, GtkSourceView and other GLib-compatible libraries
Questions tagged [gtk-rs]
94 questions
7
votes
3 answers
How to move data into multiple Rust closures?
I have a two widgets in a simple GTK app:
extern crate gdk;
extern crate gtk;
use super::desktop_entry::DesktopEntry;
use gdk::enums::key;
use gtk::prelude::*;
pub fn launch_ui(_desktop_entries: Vec) {
gtk::init().unwrap();
…

Ilia
- 147
- 1
- 7
6
votes
1 answer
gtk-rs: how to update view from another thread
I am creating a UI application with gtk-rs. In that application, I have to spawn a thread to continuously communicate with another process. Sometimes, I have to update the UI based on what happens in that thread. But, I'm not sure how to do this…

QuinnFreedman
- 2,242
- 2
- 25
- 42
6
votes
1 answer
Type must satisfy the static lifetime
I'm trying to increase the structure of a Rust and GTK-RS application, but I cannot figure out how to deal with event connections. I see that the problem is in wrong lifetime, but I do not really understand how it could be…

eirenikos
- 2,296
- 25
- 25
4
votes
1 answer
How do I use mouse button events with gtk4-rs?
I'm trying to capture up a right click event on a TreeView I have in my application using Rust and gtk4-rs. I don't see a specific EventController for mouse buttons events. I do see EventControllers for things like keyboard presses and motion…

Aaron Cirillo
- 55
- 1
- 6
4
votes
1 answer
Connect to custom GTK signals defined in Glade file
I want to connect a handler to a custom signal. In my glade file I have a window with some buttons. The window is loaded like this in Rust:
let glade_src = include_str!("views/window.glade");
let builder =…

Michael
- 2,528
- 3
- 21
- 54
4
votes
2 answers
Why does cloning data inside a closure not prevent the error "closure may outlive the current function"?
I built a GTK application with gtk-rs. When I build the main window, I want to use some dynamic parameters such as window height. I created a struct which contains all such settings and want to use this as an input parameter for the function…

Natjo
- 2,005
- 29
- 75
3
votes
2 answers
Set GTK Application Title
I've created a GTK 4 app using Gtk-rs. In all the tutorials and documentation I read through to create it, I saw that I should make the application_id something unique such as "org.rk.Counter", which is what I have chosen. Unfortunately, that shows…

Ricky Kresslein
- 372
- 1
- 13
3
votes
0 answers
.pack_start() not working with gtk-rs Box
In the following code using gtk-rs I continuously get the error "method cannot be called on gtk4::Box due to unsatisfied trait bounds" for "hbox.pack_start". I have seen this method working in other gtk-rs applications and in the documentation, so…

Ricky Kresslein
- 372
- 1
- 13
3
votes
1 answer
Making a clickable box in GTK4
How can I make a gtk4::Box clickable in gtk_rs?
In GTK3 it seems that using an EventBox was the way to achieve this, however in GTK4:
Stop using GtkEventBox
GtkEventBox is no longer needed and has been removed.
All widgets receive all…

JShorthouse
- 1,450
- 13
- 28
3
votes
0 answers
How to bundle a Gtk-rs and rusqlite program for Windows from Linux?
I have a Rust program that depends on libgtk3 and sqlite3 and I would like to generate an installer/executable for x86 Windows. I do not have access to a Windows machine so I need to bundle it from my primary development platform, x86 Linux.
How…

noconst
- 639
- 4
- 15
3
votes
1 answer
How to right justify numeric data in list store / tree view using gtk-rs
I have been recently learning making simple GUIs with gtk-rs but have run into an issue where numeric data is left justified in the list store / tree view and I want to have it right justified.
The code below is a modification from here:…

Jman
- 187
- 1
- 3
- 12
3
votes
1 answer
How to listen for the clipboard "owner-change" event in gtk-rs?
I am writing a application based on gtk::Clipboard in using the gtk-rs crate. I have already initialized a Clipboard like this:
let clipboard = gtk::Clipboard::get(&gdk::SELECTION_PRIMARY);
It is able to print the selected text by using…

H.D. Lin
- 33
- 3
3
votes
1 answer
Gtk::SpinButton get_value_as_int gives step_increment as result
I'm struggling with a SpinButton in Rust using Relm. (Disclaimer, I'm a noob with Rust and GTK)
#![feature(proc_macro)]
extern crate gtk;
use chrono::{NaiveTime, Duration};
use gtk::prelude::*;
use gtk::{
WidgetExt,
ContainerExt,
…

Geob-o-matic
- 5,940
- 4
- 35
- 41
3
votes
1 answer
How do we convert a Rust string to a gtk::type::String?
I'm trying to create a ComboBox, especially the model for it:
let type_in_col = &[gtk::Type::String];
let list_model = ListStore::new(type_in_col);
list_model.insert_with_values(None, &[0], &[""]);
list_model.insert_with_values(None, &[0],…

Geob-o-matic
- 5,940
- 4
- 35
- 41
2
votes
1 answer
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 application.
Things I have tried to solve this:
Create a…

C. Dautermann
- 109
- 1
- 10