gtk-rs / gdk Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
Home Page: http://gtk-rs.org/
License: Other
DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
Home Page: http://gtk-rs.org/
License: Other
When I run cargo build
(no options or anything) I get:
error[E0046]: not all trait items implemented, missing: `set_geometry_hints`
--> src/window.rs:174:1
|
151 | fn set_geometry_hints(&self, geometry: &gdk_sys::GdkGeometry, geom_mask: WindowHints);
| -------------------------------------------------------------------------------------- `set_geometry_hints` from trait
...
174 | impl<O: IsA<Window>> WindowExtManual for O {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `set_geometry_hints` in implementation
error: aborting due to previous error
The error produced is
Compiling gdk v0.1.2
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:61:5: 65:6 error: duplicate method [E0201]
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:61 pub fn get_vendor_id(&self) -> Option<String> {
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:62 unsafe {
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:63 from_glib_none(ffi::gdk_device_get_vendor_id(self.to_glib_none().0))
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:64 }
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:65 }
cargo/registry/src/github.com-0a35038f75765ae4/gdk-0.1.2/src/device.rs:61:5: 65:6 help: run `rustc --explain E0201` to see a detailed explanation
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `gdk`.
After looking at the source there looks of what could be a copy and paste error starting in Line 54 of Device and Line 61 with both get_vendor_id
configured with the same gtk version.
versions rustc: 1.2.0 gtk: 3.16.6 gdm: 3.16.2
using the gdm crate from crates.io
I'm want get XID from Window/DrawingArea
It's possible? (need for libvlc)
It seems strange that downcast
should consume self when we pass by reference elsewhere. Should the handler instead be passed event: gdk::Event
to make proper use of your Boxed
smart pointer?
fn handler(event: &mut gdk::Event) {
use gdk::EventType::*;
match event.get_event_type() {
ButtonPress | ButtonRelease |
DoubleButtonPress | TripleButtonPress => {
let event = event.clone().downcast::<gdk::EventButton>().unwrap();
I have added in 2e14ec9 the possibility to use the create_surface
without passing a GdkWindow
.
From what I understand, somehow glib::IsA
doesn't seem to work correctly with an Option<gdk::Window>
as I keep getting
402 | let new_surface = pixbuf.create_surface(self.get_zoom() as i32, None).unwrap();
| ^^^^
| |
| expected reference, found enum `std::option::Option`
| help: consider borrowing here: `&None`
using gdk::NONE_WINDOW
doesn't seem to help neither. Removing the use of glib::IsA
in the patch linked above makes my code pass the build and works.
After reading a bit about the use of glib::IsA
https://github.com/gtk-rs/glib/blob/e003445cfa3d32f057b355524e4c832b5273129f/src/object.rs#L76
It seems that I shouldn't have used that in that patch as gdk::Window
doesn't implement the ToGlibPtr
Am I missing something or should I send a patch to remove the use of IsA
already?
Hi all,
I'm trying to port some of the logic of devilspie2 into a project written in rust.
https://git.savannah.gnu.org/cgit/devilspie2.git/tree/src/devilspie2.c#n136
unsafe {
let _default_display = gdk_sys::gdk_display_get_default();
let _default_screen = gdk_sys::gdk_display_get_screen(_default_display, 0);
OR
let _default_screen = gdk_sys::gdk_screen_get_default();
let _windows = gdk_sys::gdk_screen_get_window_stack(_default_screen);
// glib_sys::g_list_foreach (_windows, Some(call_from_c(), ptr::null_mut());
}
...
(process:15885): Gdk-CRITICAL **: 17:59:10.729: gdk_display_get_screen: assertion 'GDK_IS_DISPLAY (display)' failed
(process:15885): Gdk-CRITICAL **: 17:59:10.730: gdk_screen_get_window_stack: assertion 'GDK_IS_SCREEN (screen)' failed
...
I tried something like "export DISPLAY=:0" but I'm out of ideas.
Rectangle
has implementation of trait FromGlibPtr
that contains panic!()
in "full" branch.
Implementation mostly unused as Rectangle
returned by out.
Only use is converting ffi-struct field in EventExpose
.
Converting ffi-struct field IMHO legal usage and we can't disallow it, but panic!()
better removed.
I see 2 way to fix:
From<*const ffi::GdkRectangle>
for Rectangle
FromGlibNonePtr
traitFirst currently only needed changes in gdk and maybe in user crates.
Second need change almost all crates.
Both seems don't affect Gir
.
@GuillaumeGomez, what you think?
PS. This issue also applied for other records that converting by direct copy ("direct" records: PangoRectange
, maybe GdkRGBA
, ...)
Seems most gdk classes that currently done manual way can be generated now, it add signals support.
Also better generate Monitor and possibly Sink to have full Gdk screen management.
GDK offers a number of methods for interfacing with Cairo surfaces. I'd like to see these added, because they can be useful for loading images to render to Cairo surfaces (i.e. gdk_cairo_set_source_pixbuf()
). Where would be the best place to add these? Should they be a part of rust-gnome/gdk or would they be better in rust-gnome/cairo?
I've ported some vala code to rust and noticed that the rust code panics at gdk::Seat::grab()
.
Am I using the rust bindings wrong or is this a bug?
Vala:
https://github.com/jangernert/FeedReader/blob/master/src/Widgets/ArticleView.vala#L597
WIP Rust:
https://gitlab.com/news-flash/news_flash_gtk/blob/master/src/article_view/mod.rs#L501
Backtrace:
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
5: std::panicking::begin_panic
at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/panicking.rs:412
6: gdk::auto::seat::Seat::grab::prepare_func_func
at ./<::std::macros::panic macros>:3
7: <unknown>
8: gdk::auto::seat::Seat::grab
at /home/jeanluc/.cargo/registry/src/github.com-1ecc6299db9ec823/gdk-0.10.0/src/auto/seat.rs:99
9: news_flash_gtk::article_view::ArticleView::new_webview::{{closure}}
at src/article_view/mod.rs:501
10: gtk::auto::widget::button_press_event_trampoline
at /home/jeanluc/.cargo/registry/src/github.com-1ecc6299db9ec823/gtk-0.6.0/src/auto/widget.rs:3106
11: <unknown>
12: g_closure_invoke
13: <unknown>
14: g_signal_emit_valist
15: g_signal_emit
16: <unknown>
17: <unknown>
18: gtk_main_do_event
19: <unknown>
20: <unknown>
21: g_main_context_dispatch
22: <unknown>
23: g_main_context_iteration
24: g_application_run
25: <O as gio::application::ApplicationExtManual>::run
at /home/jeanluc/.cargo/registry/src/github.com-1ecc6299db9ec823/gio-0.6.0/src/application.rs:23
26: news_flash_gtk::main
at src/main.rs:72
27: std::rt::lang_start::{{closure}}
at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/rt.rs:64
28: std::panicking::try::do_call
at src/libstd/rt.rs:49
at src/libstd/panicking.rs:297
29: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:92
30: std::rt::lang_start_internal
at src/libstd/panicking.rs:276
at src/libstd/panic.rs:388
at src/libstd/rt.rs:48
31: std::rt::lang_start
at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/rt.rs:64
32: main
33: __libc_start_main
34: _start
relevant crate versions:
[dependencies]
cairo-rs = "0.6"
gtk = { version = "0.6", features = ["v3_22_30"] }
gio = { version = "0.6", features = ["v2_56"] }
gdk = { version = "0.10", features = ["v3_22"] }
gdk-pixbuf = "0.6"
pango = "0.6"
webkit2gtk = { version = "0.6", features = ["v2_16"] }
glib = "0.7"
Any more information I can provide to figure out what's the issue here?
Although @gkoz's object reform PR improved the handling of wrapped types, it resulted in the generated rustdoc pages not showing the documentation for associated methods (look at the documentation page for Pixbuf
for an example). This is probably a rustdoc problem, but is there anything we can do to make the docs visible?
Hello! I can not find the api about key map, is it missing?
You can do event.as_ref().button
but a convenience method would be nice
My projects have been targetting Rust 1.13 as a minimum build version and I recently ran into a problem building gdk (through the glib and gtk dependencies) for my GUI program:
Running `rustc /root/.cargo/git/checkouts/gdk-0e2106e2e12a0cc1/8b3342528ee9c85bf5ecf97c788b2cc3d531e7d8/src/lib.rs --crate-name gdk --crate-type lib -g --cfg feature=\"v3_6\" --cfg feature=\"pango\" --cfg feature=\"v3_16\" --cfg feature=\"v3_12\" --cfg feature=\"v3_14\" --cfg feature=\"v3_8\" --cfg feature=\"gdk-pixbuf\" --cfg feature=\"v3_18\" --cfg feature=\"v3_10\" --cfg feature=\"gio\" --cfg feature=\"v3_20\" --cfg feature=\"cairo-rs\" --cfg feature=\"gdk-sys\" -C metadata=1f87422b5add9ed8 -C extra-filename=-1f87422b5add9ed8 --out-dir /builds/susurrus/gattii/target/debug/deps --emit=dep-info,link -L dependency=/builds/susurrus/gattii/target/debug/deps --extern bitflags=/builds/susurrus/gattii/target/debug/deps/libbitflags-1efefdc447eb53f2.rlib --extern glib_sys=/builds/susurrus/gattii/target/debug/deps/libglib_sys-8f1dec70df9c8640.rlib --extern cairo=/builds/susurrus/gattii/target/debug/deps/libcairo-77d84e4bc57ccadc.rlib --extern pango=/builds/susurrus/gattii/target/debug/deps/libpango-7d1db9e45a06c17d.rlib --extern gdk_sys=/builds/susurrus/gattii/target/debug/deps/libgdk_sys-cd0070267421ce7b.rlib --extern libc=/builds/susurrus/gattii/target/debug/deps/liblibc-e1db4c5f3a4f3c2f.rlib --extern gdk_pixbuf=/builds/susurrus/gattii/target/debug/deps/libgdk_pixbuf-06be090bf3460918.rlib --extern gio=/builds/susurrus/gattii/target/debug/deps/libgio-f3f1e1d7dd69eae8.rlib --extern glib=/builds/susurrus/gattii/target/debug/deps/libglib-05904638e40d7bdc.rlib --cap-lints allow -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu`
error[E0252]: a type named `EventMask` has already been imported in this module
--> /root/.cargo/git/checkouts/gdk-0e2106e2e12a0cc1/8b3342528ee9c85bf5ecf97c788b2cc3d531e7d8/src/lib.rs:136:9
|
24 | pub use auto::*;
| -------- previous import of `EventMask` here
...
136 | pub use ffi::GdkEventMask as EventMask;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ already imported
error[E0252]: a type named `WindowHints` has already been imported in this module
--> /root/.cargo/git/checkouts/gdk-0e2106e2e12a0cc1/8b3342528ee9c85bf5ecf97c788b2cc3d531e7d8/src/lib.rs:151:9
|
24 | pub use auto::*;
| -------- previous import of `WindowHints` here
...
151 | pub use ffi::GdkWindowHints as WindowHints;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ already imported
error[E0252]: a type named `DragAction` has already been imported in this module
--> /root/.cargo/git/checkouts/gdk-0e2106e2e12a0cc1/8b3342528ee9c85bf5ecf97c788b2cc3d531e7d8/src/lib.rs:134:9
|
24 | pub use auto::*;
| -------- previous import of `DragAction` here
...
134 | pub use ffi::GdkDragAction as DragAction;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ already imported
error: aborting due to 3 previous errors
error: Could not compile `gdk`.
These failures occur on x86_64-unknown-linux-gnu
, x86_64-pc-windows-gnu
, and i686-pc-windows-gnu
only for 1.13. The same codebase for nightly and stable (currently 1.15.1) builds succeed.
I guess my first question is this an actual bug, either with our code of 1.13. And secondly, what is the oldest Rust supported by gtk-rs and friends as the README doesn't specify anything?
I noticed the various functions related to gdk_key_map_*
and gdk_keyval_*
as described in https://developer.gnome.org/gdk3/stable/gdk3-Keyboard-Handling.html are missing. Is anyone working on this? Is this something I might be able to add in a PR?
Per the discussion in that chat room
the gdk_button & gdk_event are exposed through the -sys crate only and should be part of the public API
Quoting ebassi
There are a couple of defines that should be in the public API; like GDK_BUTTON_* and GDK_EVENT_PROPAGATE|STOP
It's not exported in lib.rs
.
All gdk_pixbuf_save_* routines are missing from ffi.
No idea how I should get the scroll direction without resorting to gdk_sys here.
http://gtk-rs.org/docs/gdk/struct.EventScroll.html
https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#GdkEventScroll
Version:0.13.1
When I run cargo doc --open, also under Gdk there is no struct called Monitor
Many event objects are missing properties in rust compared to the gdk implementation.
Example: gdk motion event has a device property and gtk-rs motion event does not.
Were these properties left out for a specific reason?
I recently encountered this thanks to the addition of gdk::PixbufLoader
in #11. PixbufLoader
's function loader_write(&self, buf: &[u8], error: &mut Error)
requires passing a GError
(in the form of gdk::glib::Error
). In the GDK documentation, the function is looking for a double pointer to memory for an error object, which presumably is only populated when false
is returned. In the Rust version, however, we have to pass a fully-instantiated Error
struct, which can currently only be created with new_literal(domain: u32, code: i32, message: &str)
. However, because GQuark
s don't appear to be bridged yet, I cannot successfully create Error
s because I have no way of determining the domain, and thus cannot write data to PixbufLoader
s.
It seems to me that the real problem is that the original double-pointer function signature is not reproduced in a Rustic way. Does anyone have any suggestions? Thanks!
In the interest of full disclosure, I'm a beginner at all of this, so I might just be missing something obvious.
In Cargo.toml
, the gdk-sys
dependency is listed as
gdk-sys = "^0"
Doesn't this mean that it's pulled from crates.io rather than from the local copy in the repository? Is that what we want? Is there some way to say, "Depend on the copy of gdk-sys
provided in the repository"?
The relevant use case is: edit gdk-sys
locally, adding new ffi bindings, then build gdk
and discover that it's using the version from crates.io. I know that this can be overridden locally, but if there's a way to change the default behavior, that seems more ergonomic to me.
Hi, how can I set this parameter for the ApplicationWindow instance ?
Also, same question for NET_WM_STRUT_PARTIAL and _NET_WM_STRUT(CARDINAL).
Thank you
We have the following goals for the high level APIs like these getters:
glib::translate
for guidance (example of returning a window). It seems likely that most pointers carried by the events are nullable, so the type would be wrapped in Option
(the helper functions can handle that).lib.rs
among the others. In particular,
GdkRectangle
is currently exposed as cairo::RectangleInt
;&str
or Option<&str>
or Cow<str>
depending on our assumptions, new helper functions will be needed for that.u32
with assertions (gtk-rs/gtk#246, we don't have a settled style for that yet).EventProperty
at all yet because the properties story is not clear.GDK documentation: https://developer.gnome.org/gdk3/stable/gdk3-Events.html#gdk-event-request-motions
GTK 3.8 and onwards will always compress motion events, unless gdk_window_set_event_compression() is used to disable compression. gdk_event_request_motions() is the recommended way of decompressing the events in a handler, but it seems that the binding for it is missing. An alternative is the gdk_window_get_device_position() function, which does have a binding, but EventMotion doesn't seem to provide a .get_device() method on the Rust side.
Sometimes one needs the position relative to the root of the screen rather than the widget.
pub fn get_root_position(&self) -> (f64, f64) {
let x = self.as_ref().x_root;
let y = self.as_ref().y_root;
(x, y)
}
Is there a method to get the title from a given gdk::Window ?
Like the reverse of what this method does: http://gtk-rs.org/docs/gdk/trait.WindowExt.html#tymethod.set_title
Platform specific APIs seem to be missing from this project, although they are found in the gir files: https://github.com/gtk-rs/gir-files/blob/master/GdkX11-3.0.gir
Is there a way to access them besides manually referencing the extern
functions?
We should look at adding some structure to the crate's types organization. I don't like putting everything into the top-level namespace.
For example, the pixbufs stuff should stay in the pixbuf
module. There we might also want to drop the Pixbuf
prefix from most types (e.g. PixbufLoader
-> pixbuf::Loader
). I'm torn on the latter proposition though because renaming the classes may confuse people who read the official gnome docs. And this policy should be applied uniformly across the project.
Key has no method and we end up with e.g. keyval_to_unicode(ev.get_keyval())
instead of ev.get_keyval().to_unicode()
.
Some discussion here: #21
get_presentation_time
& get_predicted_presentation_time
can both return 0
when the value is not available.
In Rust, returning None
in this case would make it clear that the value shouldn't be used as is. I tried changing the signature to return an Option
using Gir's nullable = true
, but it didn't work.
What do you think about this change? If you agree, I'll open a PR.
Is there a Gir-way to handle this or should I use a manual implementation?
Line 41 in sourcefile mainwindow.rs enables moving window by pressing mousebutton over the headerbar in the window. When running the program in shell and moving the window I get this message:
gtk_container_propagate_draw: assertion '_gtk_widget_get_parent (child) == GTK_WIDGET (container)' failed
https://developer.gnome.org/gtk3/stable/GtkHeaderBar.html
(using headerbar with set_titlebar)
For these reasons, GtkHeaderBar is the natural choice for use as the custom titlebar widget of a GtkWindow (see gtk_window_set_titlebar()), as it gives features typical of titlebars while allowing the addition of child widgets.
https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-set-titlebar
(set-titlebar api)
In gtk refrences it seems that set-titlebar should accept any type of GtkWidget
I am new to rust, gtk, open source and linux programming so excuse stupid misstakes I have made.
example code below
moving_window_error.zip
Hello, I would like to be able to use the signals of GdkScreen as described in the documentation. I would implement them, but I am not sure how to do that. Maybe you can help me?
Currently, some methods are implemented as part of the ContextExt which shouldn't be the case.
The PixbufExt isn't loaded on prelude either.
Currently the event_mask
field has type i32
. The EventMask
struct exists and can be built as a bitfield, and then converted using .bits()
, yielding an u32
which then needs to be cast in order to be used in the event_mask
field. This is somewhat unwieldy, and it would likely be preferable to just have the WindowAttr
struct contain the EventMask
.
As far as I can tell, this crate is missing bindings to the GDK_SELECTION_CLIPBOARD
, GDK_SELECTION_PRIMARY
, and GDK_SELECTION_SECONDARY
constants. These constants are necessary to implement cut/copy/paste with GTK.
Hi, I've been looking around, and I've been having trouble figuring out if GdkPixbufLoader has been implemented. Is there any chance that it might be implemented in the future, or has it already been done and am I just looking in the wrong place? Thanks a lot!
I'm not sure if there is something I need to do before using list_axes(&self)
, but it always returns an empty Vec
.
I find this confusing since calling get_n_axes(&self)
it will return 3
. And additionally, calling get_axes(&self)
will return AXIS_FLAG_X | AXIS_FLAG_Y | AXIS_FLAG_PRESSURE
.
Is list_axes
misbehaving or am I misusing it?
This applies to a lof of the functions in that file. I've been trying to copy some C code and it's converted basically to the following Rust example:
let icon = gtk::DrawingArea::new();
icon.connect_draw(|w, c| {
let style_context = w.get_style_context().unwrap();
let foreground = style_context.get_color(w.get_state_flags());
c.set_source_rgba (&foreground);
});
Unfortunately this doesn't compile because of both the missing get_color()
(tracked in gtk-rs/gtk#454), but also because the equivalent of gdk_cairo_set_source_rgba()
isn't available. It's implemented in gdk::cairo_interaction
and I would think it'd be usable since the c
argument to the closure is a cairo::Context
. Is there something I'm missing here?
I should note that if you call c.get_clip_rectangle()
within the callback it will compile successfully, so I'm wondering if there's a compiler bug that is allowing Context
to have two set_source_rgba
functions implemented on it and silently ignores the duplicate one?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.