gtk | DEPRECATED , use https
kandi X-RAY | gtk Summary
kandi X-RAY | gtk Summary
Project site | Online documentation. Rust bindings and wrappers for GLib, GDK 3, GTK+ 3 and Cairo.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gtk
gtk Key Features
gtk Examples and Code Snippets
Community Discussions
Trending Discussions on gtk
QUESTION
I'm sure there's an easy way to do this but I don't know what it is. I have a very basic gtk::{Application, ApplicationWindow, DrawingArea};
setup. I want the DrawingArea::connect_draw
closure to be triggered repeatedly on a timer, so it updates according to some changing state. (It would also be cool if it could be actively triggered by other threads, but a timer is fine.)
So far everything I've found that would work on a timer fails because it would mean moving the ApplicationWindow
to another thread. (fails with NonNull cannot be shared between threads safely
) What I have currently triggers redraw on generic events, so if I click my mouse on the window it will redraw, but not do so automatically.
That code is below, but please show me how to make this work?
...ANSWER
Answered 2022-Mar-28 at 18:48Okay, I eventually made it work, after stumbling onto gtk-rs: how to update view from another thread . The key is to stash window in a thread-local global (TBH I don't really understand what that means but it works), and then access it through a static function.
I had to modify the linked answer a bit because of scope disagreements between my channel and my window. Eventually I just decided to deal with them separately.
I strongly suspect this is not the right way to do this, but at least it runs.
QUESTION
I am trying to make a tree view in Gtk3 such that each row has the size of two rows of text. The following is a minimal working example:
...ANSWER
Answered 2022-Mar-25 at 15:01set_fixed_height_form_font
works in Gtk2, but behaves differently in Gtk3.
My solution (in the OCaml interface, as originally posted), was to compute the height explicitly following cell_renderer_text.get_size:
QUESTION
In Rhythmbox (GNOME's music player), when it's playing music, you can open the notifications panel and control the music playback from there. Here's a screenshot. The playback controls are bordered in orange; they have a little music note icon:
This is what I want to make; the media playback controls. Note that, while it is in the notifications panel, it's not technically a notification, because it never pops up on the screen, and you can't make it go away. In the screenshot, you can see the actual notification, which I don't want to make, below the controls.
I know that there's a Gio.Notification
, but it's not quite what I need (unless I'm very much mistaken). I searched in Gio
, Gdk
, and Gtk
, but I didn't find anything. I also searched, among other things, [gtk] media control
and [gtk] media notification
on Stack Overflow, but I didn't find anything there either.
Thanks to the help of BobMorane, I've now figured out that Rhythmbox uses libnotify
for its player controls. I know how to create actions using Notify.Notification
, and I can make them have images, etc., but what I still haven't figured out is how to:
- Make the notification so that it can't be closed;
- Make it so that the action buttons are next to the icon and text, not under;
- Keep the notification on top of all the others in the notifications panel.
Using Python's help()
function to look at gi.repository.Notify.Notification
, the only methods I see that seem to have potential are add_action()
(particularly its user_data
parameter) and set_hint()
(and its variants). Could these be used to achieve my goal?
How do I make a media-control "notification" in Gtk with Python, as explained above?
...ANSWER
Answered 2022-Mar-09 at 21:22I think the technology used by Rhytmbox to acheive this is MPRIS (Media Player Remote Interfacing Specification). As they say on their we page:
The Media Player Remote Interfacing Specification (MPRIS) is a standard D-Bus interface which aims to provide a common programmatic API for controlling media players.
It provides a mechanism for discovery, querying and basic playback control of compliant media players, as well as a tracklist interface which is used to add context to the active media item.
In Rhythmbox, this is implemented as a core plug-in. The code is pretty complicated, but basically implements the MPRIS specification. This implementation then exposes some information and controls out to other applications which want to control the Rhythmbox, like the Gnome Shell in your case. If you deactivate the MPRIS plug-in, the "notification player" will no longer work.
In GNOME Shell, you can see they have their own MPRIS module as well (https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/mpris.js), which is used to:
- Respond to player notifications and display information (album art, title, buttons, etc).
- Send notifications to the player (ex.: pause the song).
In this module, the formatting of the buttons and all that stuff comes into life as well. This means that on your part (the player's designer), you should have no UI formatting to do (you don't have control over this, GNOME Shell has). What you need to do is expose what is needed by the GNOME Shell by implementing the MPRIS interfaces.
(As a side note: the calendar.js
file is the one implementing the notification list, and you can see it uses MPRIS "notifications", which it puts on top of standard notifications.)
There exist Python libraries to do so, such as Mopidy-MPRIS, bit their support for the GNOME Shell seems not to be working at the moment. You may have to look for D-Bus related libraries on FreeDesktop.org. There exists many bindings, with some in Python.
I hope this points you in the right direction.
QUESTION
This should be a no-brainer but I just can't seem to figure it out. If I build a Gtk.PopoverMenu:
...ANSWER
Answered 2022-Feb-21 at 17:33To set the parent of the PopoverMenu
, just use its set_parent()
method to set the parent to any widget:
QUESTION
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 events.
https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtkeventbox
So it seems that click handlers should now be attached to widgets directly. However I can't find any clear documentation or examples on how to do this.
If someone could give me an example of attaching a click listener to a gtk4::Box
it would be much appreciated.
ANSWER
Answered 2022-Jan-25 at 19:06You can do this using gtk::GestureClick
like shown in this example.
Here is a full example (click somewhere inside the window as the box is not actually visible):
QUESTION
i write a code for calculator in gtk3 c the code is total numbers, in i write 1+1+1+1 the result is 3+1 i want to fix to 4 calcul result
in i write sprintf(result,"%d%s",temp,rest); the result for 1+1+1+1 is 3+1 i want to result 4 i check for sprintf(result,"%d",temp); is not correct.
the code of application :
...ANSWER
Answered 2022-Jan-21 at 18:03First of all, if you remove all the unrelated code from your example, we get this MCVE:
QUESTION
Is there a way in gtk to make an eye icon on the right of an entry to show a password? I know there is a way to make a checkbox under an entry to show the password, but I want the button to be inside the entry, not outside. To put it simply:
What i'm looking for is this: show password icon
...and not this: show password checkbox
(I'm sorry that I cant embed the image. The site says I need 10 reputation first. I actually used to have almost 300 untill I got banned from a dislike attack. Please think before you dislike because it literally only takes ~20 to permenantly ban a year-long user. If anyone has enough reputation to edit the question and add the images in, please do)
...ANSWER
Answered 2022-Jan-08 at 20:02You can put an icon to Gtk.Entry with the set_icon_from_
functions, for example set_icon_from_name
.
So you need to set the icon to for example to the view-reveal-symbolic.symbolic
icon, make it clickable with set_icon_activatable
and then in the signal handler for the icon-press
event you need to set_visibility to either hide or show the text (and also change the icon to something like view-conceal-symbolic.symbolic
).
So the Gtk.Entry code could look like this
QUESTION
I'm trying to draw on a window with Gtkmm for C++, cairo::context, gdk::pixbuf. I've noticed that for some widths (in my example 298), instead of my image, I get some horizontal black lines (alternated with white stripes).
For other widths (in my example 300) I get a normal image. (I'm just drawing a yellow background in my example).
What am I doing wrong ? How can I obtain to draw correctly for any image width ?
I'm finding this behavior both on :
windows 10 / msys2 / gcc11.2 / std=c++20
opensuse 15.2 / gcc 11.2.1 / std=c++17
and on both I have library versions:
-I/usr/include/gtkmm-3.0 -L/usr/lib64 -I/usr/lib64/glibmm-2.4/include -I/usr/include/glibmm-2.4 -I/usr/lib64/glib-2.0/include -I/usr/include/glib-2.0 -I/usr/include/sigc++-2.0/ -I/usr/lib64/sigc++-2.0/include -I/usr/include/giomm-2.4 -I/usr/lib64/giomm-2.4/include -I/usr/include/gdkmm-3.0 -I/usr/lib64/gdkmm-3.0/include -I/usr/lib64/pangomm-1.4/include -I/usr/include/gtk-3.0/ -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairomm-1.0 -I/usr/include/cairomm-1.0/cairomm -I/usr/lib64/cairomm-1.0/include -I/usr/include/freetype2 -I/usr/lib64/gtkmm-3.0/include -I/usr/include/pangomm-1.4 -I/usr/include/harfbuzz -I/usr/include/atkmm-1.6 -I/usr/include/atk-1.0 -I/usr/lib64/atkmm-1.6/include -LC:/programs/msys64/mingw64/bin -lgtkmm-3.0 -lglibmm-2.4 -I/usr/include/sigc++-2.0 -lsigc-2.0 -lgdkmm-3.0 -latkmm-1.6 -lcairomm-1.0
Here's my code:
...ANSWER
Answered 2022-Jan-07 at 11:30I'm used to the fact that image rows are often (not always) stored with a certain alignment. Whenever I see an image that appears erroneously in stripes, the row alignment is the first thing I would check.
With this suspicion in mind, I look for some gdkmm (or Gdk) doc. Instead I found a comment in the Gdk source code.
QUESTION
On Windows package org.eclipse.swt.win32.win32.x86_64
is used, while for Linux build it's org.eclipse.swt.gtk.linux.x86_64
.
If nothing is specified in
module-info.java
, error message isjava: package org.eclipse.swt does not exist
If in
...module-info.java
both are specified:
ANSWER
Answered 2021-Dec-16 at 18:27It's a bug 559162 in SWT. Their Automatic-Module-Name in the SWT jar files manifest is impractical.
I suggest to stick to module-less builds (without module-info.java) until this gets fixed.
QUESTION
I am trying to add items to the context menu of a TextView in GtkSharp (version 3.22.25.128). The context menu normally has the entries Cut/Copy/Paste/Delete/Separator/Select All/Insert Emoji. I am trying to add several more entries to the menu, starting with a separator.
To do this I am adding a handler to the PopulateMenu event, like so:
...ANSWER
Answered 2021-Dec-10 at 16:25In PopulatePopup, you must set the Visible flag of items you are adding to "true" to get them to appear as expected.
This handler works as expected:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gtk
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page