Questions tagged [gtk-rs]

Rust bindings for GTK+, Cairo, GtkSourceView and other GLib-compatible libraries

94 questions
0
votes
1 answer

Gtk-rs: Set label within glib::timeout_add

I'm new to rust and having trouble with the scope of objects/variables in GTK. I have the following code, which works, but I need to set a label in the GTK Window to the text of the variable watch_text. Here is the code: use…
Ricky Kresslein
  • 372
  • 1
  • 13
0
votes
1 answer

How do I get the selected state of a gtk::RadioButton in Rust?

In Python's Gtk module, you can use Gtk.RadioButton.get_active() to get whether the radio button is checked or not. However, I can't find any such method in Rust's equivalent, gtk::RadioButton. When I try to use RadioButton.active(), I get an error…
Sylvester Kruin
  • 3,294
  • 5
  • 16
  • 39
0
votes
1 answer

In gtk-rs, how do I get the current screen that a gtk::Window is (mostly) on?

What I'm trying to accomplish is to calculate the dpi (or, in my case, the dpmm) of the screen that my application is mostly on. So far as I know, the modern way to do that is to call gdk::Monitor::get_height_mm and gdk::Monitor::get_width_mm. So,…
Savanni D'Gerinel
  • 2,379
  • 17
  • 27
0
votes
0 answers

Gtk-rs Error: Failed to load module "appmenu-gtk-module"

When I try to run my gtk-rs project it shows this error: Failed to load module "appmenu-gtk-module" and also this error: Failed to register: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown My toml…
gearDev
  • 29
  • 1
  • 8
0
votes
0 answers

Gtk-rs crashes gnomne session on async data fetch and assigning it to label on button click event

Async data fetching from this rest api and setting it to as label in gtk-rs makes gnome-session crash. To reproduce: create a new cargo project create svg files named home.svg and about.svg create a css file named main.css #left_pane { …
Aniket Prajapati
  • 373
  • 3
  • 19
0
votes
1 answer

gtk-rs: how to listen for keyboard events

I am using gtk-rs and want to be able to detect when any key is pressed. From some searching online, it seems like the way to do that in C is with gtk_widget_add_events and then g_signal_connect. This answer has a good explanation. In Rust, I can…
QuinnFreedman
  • 2,242
  • 2
  • 25
  • 42
0
votes
0 answers

Gtk Widgets returning None even when they hold data

I have a filechoosernative and a comboboxtext in my UI. Now I am trying to extract data from those two inside callbacks but they are returning me None even though they clearly have data set by the user. Why is this happening? Excerpt from…
noconst
  • 639
  • 4
  • 15
0
votes
1 answer

Rust Gtk set GtkImage from pixbuf using glade file

I'm trying to load an image from a scaled pixbuf to an existing GtkImage widget from Glade with Rust. I've read all the Gtk-rs documentations regarding this topic, and it should work based on that. However there is always a problem when trying to…
swanux
  • 67
  • 7
0
votes
1 answer

How to handle unrecoverable errors in a thread in Gtk-rs?

I'm writing a Gtk-rs application. I have a background thread sending events to the main Gtk thread through a MPSC channel. What should I do with unrecoverable errors inside this background thread? I don't want to handle them (To panic! or Not to…
Matteo Nardi
  • 199
  • 2
  • 7
0
votes
0 answers

How to store the signal ID from DrawingArea::connect_draw?

I want to refresh a DrawingArea each time I call the draw() function. I have read Update drawing function of a DrawingArea, so I know that I need to disconnect the old drawing signal before connecting a new one. DrawingArea has the method…
0
votes
0 answers

Create custom shaped Cairo::Region

Looking through the documentation of cairo::Region I can't find any functions allowing me to create not rectangle shaped regions. Did I miss something or is this simply not possible?
Natjo
  • 2,005
  • 29
  • 75
0
votes
1 answer

gtk/cairo: Only show custom shaped drawing

I want to only display a cairo drawing inside a drawingArea, but for some reason there is always a colored rectangle shaped background around the drawing. How can I get rid of this? I especially don't want to set it only as transparent (since I…
Natjo
  • 2,005
  • 29
  • 75
0
votes
1 answer

How to create a suggested rounded button in Gtk-rs?

How does one create a round and suggested/destructive button in Gtk? I have already tried using get_style_context() but it seems that I can only use it once. Is there a "CSS way" to achieve this? pub fn make_rounded_button(label: &str) ->…
noconst
  • 639
  • 4
  • 15
0
votes
0 answers

Gtk-rs application crashes at window.show_all() function

My Gtk-rs application crashes whenever I try calling the show_all() function. In a simple application window, I have added a headerbar and a label. If I compile without adding the headerbar, the window works and shows the label as intended. However…
noconst
  • 639
  • 4
  • 15
0
votes
1 answer

How do I add action buttons to a FileChooserDialog?

When I try to show a file chooser dialog, it is missing the action buttons: let dialog = FileChooserDialog::new(Some("Open File"), Some(&window), FileChooserAction::Open); dialog.run(); I found another way from another project: let dialog =…
鸿则_
  • 314
  • 1
  • 14