Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 479672c

Browse files
committed
Generate WidgetPath
1 parent e29c59d commit 479672c

File tree

8 files changed

+335
-48
lines changed

8 files changed

+335
-48
lines changed

Gir.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ generate = [
223223
"Gtk.Viewport",
224224
"Gtk.VolumeButton",
225225
"Gtk.WidgetHelpType",
226+
"Gtk.WidgetPath",
226227
"Gtk.WindowGroup",
227228
"Gtk.WindowPosition",
228229
"Gtk.WindowType",
@@ -1802,6 +1803,10 @@ status = "generate"
18021803
[[object.function]]
18031804
name = "style_get_property"
18041805
ignore = true
1806+
[[object.function]]
1807+
name = "get_path"
1808+
[object.function.return]
1809+
nullable = false
18051810
[[object.signal]]
18061811
name = "button-press-event"
18071812
inhibit = true

src/auto/container.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use Adjustment;
66
use Buildable;
77
use ResizeMode;
88
use Widget;
9+
use WidgetPath;
910
use cairo;
1011
use ffi;
1112
use glib;
@@ -68,7 +69,7 @@ pub trait ContainerExt {
6869

6970
fn get_focus_vadjustment(&self) -> Option<Adjustment>;
7071

71-
//fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> /*Ignored*/Option<WidgetPath>;
72+
fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath>;
7273

7374
#[cfg_attr(feature = "v3_12", deprecated)]
7475
fn get_resize_mode(&self) -> ResizeMode;
@@ -207,9 +208,11 @@ impl<O: IsA<Container> + IsA<glib::object::Object>> ContainerExt for O {
207208
}
208209
}
209210

210-
//fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> /*Ignored*/Option<WidgetPath> {
211-
// unsafe { TODO: call ffi::gtk_container_get_path_for_child() }
212-
//}
211+
fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath> {
212+
unsafe {
213+
from_glib_full(ffi::gtk_container_get_path_for_child(self.to_glib_none().0, child.to_glib_none().0))
214+
}
215+
}
213216

214217
fn get_resize_mode(&self) -> ResizeMode {
215218
unsafe {

src/auto/icon_info.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ ef40528)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -68,20 +68,20 @@ pub trait IconInfoExt {
6868
fn load_icon(&self) -> Result<gdk_pixbuf::Pixbuf, Error>;
6969

7070
#[cfg(any(feature = "v3_8", feature = "dox"))]
71-
fn load_icon_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cancellable: P, callback: Q);
71+
fn load_icon_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<gdk_pixbuf::Pixbuf, Error>) + Send + 'static>(&self, cancellable: P, callback: Q);
7272

7373
#[cfg(any(feature = "v3_10", feature = "dox"))]
7474
fn load_surface<'a, P: Into<Option<&'a gdk::Window>>>(&self, for_window: P) -> Result<cairo::Surface, Error>;
7575

7676
fn load_symbolic<'a, 'b, 'c, P: Into<Option<&'a gdk::RGBA>>, Q: Into<Option<&'b gdk::RGBA>>, R: Into<Option<&'c gdk::RGBA>>>(&self, fg: &gdk::RGBA, success_color: P, warning_color: Q, error_color: R) -> Result<(gdk_pixbuf::Pixbuf, bool), Error>;
7777

7878
#[cfg(any(feature = "v3_8", feature = "dox"))]
79-
fn load_symbolic_async<'a, 'b, 'c, 'd, P: Into<Option<&'a gdk::RGBA>>, Q: Into<Option<&'b gdk::RGBA>>, R: Into<Option<&'c gdk::RGBA>>, S: Into<Option<&'d gio::Cancellable>>, T: FnOnce(Result<bool, Error>) + Send + 'static>(&self, fg: &gdk::RGBA, success_color: P, warning_color: Q, error_color: R, cancellable: S, callback: T);
79+
fn load_symbolic_async<'a, 'b, 'c, 'd, P: Into<Option<&'a gdk::RGBA>>, Q: Into<Option<&'b gdk::RGBA>>, R: Into<Option<&'c gdk::RGBA>>, S: Into<Option<&'d gio::Cancellable>>, T: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), Error>) + Send + 'static>(&self, fg: &gdk::RGBA, success_color: P, warning_color: Q, error_color: R, cancellable: S, callback: T);
8080

8181
fn load_symbolic_for_context(&self, context: &StyleContext) -> Result<(gdk_pixbuf::Pixbuf, bool), Error>;
8282

8383
#[cfg(any(feature = "v3_8", feature = "dox"))]
84-
fn load_symbolic_for_context_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<bool, Error>) + Send + 'static>(&self, context: &StyleContext, cancellable: P, callback: Q);
84+
fn load_symbolic_for_context_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), Error>) + Send + 'static>(&self, context: &StyleContext, cancellable: P, callback: Q);
8585

8686
#[cfg_attr(feature = "v3_14", deprecated)]
8787
fn set_raw_coordinates(&self, raw_coordinates: bool);
@@ -153,15 +153,15 @@ impl<O: IsA<IconInfo>> IconInfoExt for O {
153153
}
154154

155155
#[cfg(any(feature = "v3_8", feature = "dox"))]
156-
fn load_icon_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cancellable: P, callback: Q) {
156+
fn load_icon_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<gdk_pixbuf::Pixbuf, Error>) + Send + 'static>(&self, cancellable: P, callback: Q) {
157157
let cancellable = cancellable.into();
158158
let cancellable = cancellable.to_glib_none();
159159
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
160-
unsafe extern "C" fn load_icon_async_trampoline<Q: FnOnce(Result<(), Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
160+
unsafe extern "C" fn load_icon_async_trampoline<Q: FnOnce(Result<gdk_pixbuf::Pixbuf, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
161161
{
162162
let mut error = ptr::null_mut();
163-
let _ = ffi::gtk_icon_info_load_icon_finish(_source_object as *mut _, res, &mut error);
164-
let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) };
163+
let ret = ffi::gtk_icon_info_load_icon_finish(_source_object as *mut _, res, &mut error);
164+
let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) };
165165
let callback: Box<Box<Q>> = Box::from_raw(user_data as *mut _);
166166
callback(result);
167167
}
@@ -198,7 +198,7 @@ impl<O: IsA<IconInfo>> IconInfoExt for O {
198198
}
199199

200200
#[cfg(any(feature = "v3_8", feature = "dox"))]
201-
fn load_symbolic_async<'a, 'b, 'c, 'd, P: Into<Option<&'a gdk::RGBA>>, Q: Into<Option<&'b gdk::RGBA>>, R: Into<Option<&'c gdk::RGBA>>, S: Into<Option<&'d gio::Cancellable>>, T: FnOnce(Result<bool, Error>) + Send + 'static>(&self, fg: &gdk::RGBA, success_color: P, warning_color: Q, error_color: R, cancellable: S, callback: T) {
201+
fn load_symbolic_async<'a, 'b, 'c, 'd, P: Into<Option<&'a gdk::RGBA>>, Q: Into<Option<&'b gdk::RGBA>>, R: Into<Option<&'c gdk::RGBA>>, S: Into<Option<&'d gio::Cancellable>>, T: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), Error>) + Send + 'static>(&self, fg: &gdk::RGBA, success_color: P, warning_color: Q, error_color: R, cancellable: S, callback: T) {
202202
let success_color = success_color.into();
203203
let success_color = success_color.to_glib_none();
204204
let warning_color = warning_color.into();
@@ -208,12 +208,12 @@ impl<O: IsA<IconInfo>> IconInfoExt for O {
208208
let cancellable = cancellable.into();
209209
let cancellable = cancellable.to_glib_none();
210210
let user_data: Box<Box<T>> = Box::new(Box::new(callback));
211-
unsafe extern "C" fn load_symbolic_async_trampoline<T: FnOnce(Result<bool, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
211+
unsafe extern "C" fn load_symbolic_async_trampoline<T: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
212212
{
213213
let mut error = ptr::null_mut();
214214
let mut was_symbolic = mem::uninitialized();
215-
let _ = ffi::gtk_icon_info_load_symbolic_finish(_source_object as *mut _, res, &mut was_symbolic, &mut error);
216-
let result = if error.is_null() { Ok(from_glib(was_symbolic)) } else { Err(from_glib_full(error)) };
215+
let ret = ffi::gtk_icon_info_load_symbolic_finish(_source_object as *mut _, res, &mut was_symbolic, &mut error);
216+
let result = if error.is_null() { Ok((from_glib_full(ret), from_glib(was_symbolic))) } else { Err(from_glib_full(error)) };
217217
let callback: Box<Box<T>> = Box::from_raw(user_data as *mut _);
218218
callback(result);
219219
}
@@ -233,16 +233,16 @@ impl<O: IsA<IconInfo>> IconInfoExt for O {
233233
}
234234

235235
#[cfg(any(feature = "v3_8", feature = "dox"))]
236-
fn load_symbolic_for_context_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<bool, Error>) + Send + 'static>(&self, context: &StyleContext, cancellable: P, callback: Q) {
236+
fn load_symbolic_for_context_async<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), Error>) + Send + 'static>(&self, context: &StyleContext, cancellable: P, callback: Q) {
237237
let cancellable = cancellable.into();
238238
let cancellable = cancellable.to_glib_none();
239239
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
240-
unsafe extern "C" fn load_symbolic_for_context_async_trampoline<Q: FnOnce(Result<bool, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
240+
unsafe extern "C" fn load_symbolic_for_context_async_trampoline<Q: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
241241
{
242242
let mut error = ptr::null_mut();
243243
let mut was_symbolic = mem::uninitialized();
244-
let _ = ffi::gtk_icon_info_load_symbolic_for_context_finish(_source_object as *mut _, res, &mut was_symbolic, &mut error);
245-
let result = if error.is_null() { Ok(from_glib(was_symbolic)) } else { Err(from_glib_full(error)) };
244+
let ret = ffi::gtk_icon_info_load_symbolic_for_context_finish(_source_object as *mut _, res, &mut was_symbolic, &mut error);
245+
let result = if error.is_null() { Ok((from_glib_full(ret), from_glib(was_symbolic))) } else { Err(from_glib_full(error)) };
246246
let callback: Box<Box<Q>> = Box::from_raw(user_data as *mut _);
247247
callback(result);
248248
}

src/auto/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ bd67955+)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -885,6 +885,9 @@ pub use self::tree_path::TreePath;
885885
mod tree_row_reference;
886886
pub use self::tree_row_reference::TreeRowReference;
887887

888+
mod widget_path;
889+
pub use self::widget_path::WidgetPath;
890+
888891
mod enums;
889892
pub use self::enums::Align;
890893
pub use self::enums::ArrowType;

src/auto/style_context.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ bd67955+)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -13,6 +13,7 @@ use StateType;
1313
use StyleContextPrintFlags;
1414
use StyleProvider;
1515
use TextDirection;
16+
use WidgetPath;
1617
use ffi;
1718
use gdk;
1819
use glib;
@@ -113,7 +114,7 @@ pub trait StyleContextExt {
113114

114115
fn get_parent(&self) -> Option<StyleContext>;
115116

116-
//fn get_path(&self) -> /*Ignored*/Option<WidgetPath>;
117+
fn get_path(&self) -> Option<WidgetPath>;
117118

118119
#[cfg(any(feature = "v3_10", feature = "dox"))]
119120
fn get_scale(&self) -> i32;
@@ -184,7 +185,7 @@ pub trait StyleContextExt {
184185

185186
fn set_parent<'a, P: Into<Option<&'a StyleContext>>>(&self, parent: P);
186187

187-
//fn set_path(&self, path: /*Ignored*/&mut WidgetPath);
188+
fn set_path(&self, path: &WidgetPath);
188189

189190
#[cfg(any(feature = "v3_10", feature = "dox"))]
190191
fn set_scale(&self, scale: i32);
@@ -317,9 +318,11 @@ impl<O: IsA<StyleContext> + IsA<glib::object::Object>> StyleContextExt for O {
317318
}
318319
}
319320

320-
//fn get_path(&self) -> /*Ignored*/Option<WidgetPath> {
321-
// unsafe { TODO: call ffi::gtk_style_context_get_path() }
322-
//}
321+
fn get_path(&self) -> Option<WidgetPath> {
322+
unsafe {
323+
from_glib_none(ffi::gtk_style_context_get_path(self.to_glib_none().0))
324+
}
325+
}
323326

324327
#[cfg(any(feature = "v3_10", feature = "dox"))]
325328
fn get_scale(&self) -> i32 {
@@ -487,9 +490,11 @@ impl<O: IsA<StyleContext> + IsA<glib::object::Object>> StyleContextExt for O {
487490
}
488491
}
489492

490-
//fn set_path(&self, path: /*Ignored*/&mut WidgetPath) {
491-
// unsafe { TODO: call ffi::gtk_style_context_set_path() }
492-
//}
493+
fn set_path(&self, path: &WidgetPath) {
494+
unsafe {
495+
ffi::gtk_style_context_set_path(self.to_glib_none().0, path.to_glib_none().0);
496+
}
497+
}
493498

494499
#[cfg(any(feature = "v3_10", feature = "dox"))]
495500
fn set_scale(&self, scale: i32) {

src/auto/style_provider.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ bd67955+)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

5+
use IconFactory;
6+
use StyleProperties;
7+
use WidgetPath;
58
use ffi;
69
use glib::object::IsA;
710
use glib::translate::*;
@@ -19,25 +22,29 @@ glib_wrapper! {
1922
}
2023

2124
pub trait StyleProviderExt {
22-
//#[cfg_attr(feature = "v3_8", deprecated)]
23-
//fn get_icon_factory(&self, path: /*Ignored*/&mut WidgetPath) -> Option<IconFactory>;
25+
#[cfg_attr(feature = "v3_8", deprecated)]
26+
fn get_icon_factory(&self, path: &WidgetPath) -> Option<IconFactory>;
2427

25-
//#[cfg_attr(feature = "v3_8", deprecated)]
26-
//fn get_style(&self, path: /*Ignored*/&mut WidgetPath) -> Option<StyleProperties>;
28+
#[cfg_attr(feature = "v3_8", deprecated)]
29+
fn get_style(&self, path: &WidgetPath) -> Option<StyleProperties>;
2730

28-
//fn get_style_property<P: IsA</*Ignored*/glib::ParamSpec>>(&self, path: /*Ignored*/&mut WidgetPath, state: StateFlags, pspec: &P) -> Option<glib::Value>;
31+
//fn get_style_property<P: IsA</*Ignored*/glib::ParamSpec>>(&self, path: &WidgetPath, state: StateFlags, pspec: &P) -> Option<glib::Value>;
2932
}
3033

3134
impl<O: IsA<StyleProvider>> StyleProviderExt for O {
32-
//fn get_icon_factory(&self, path: /*Ignored*/&mut WidgetPath) -> Option<IconFactory> {
33-
// unsafe { TODO: call ffi::gtk_style_provider_get_icon_factory() }
34-
//}
35+
fn get_icon_factory(&self, path: &WidgetPath) -> Option<IconFactory> {
36+
unsafe {
37+
from_glib_none(ffi::gtk_style_provider_get_icon_factory(self.to_glib_none().0, path.to_glib_none().0))
38+
}
39+
}
3540

36-
//fn get_style(&self, path: /*Ignored*/&mut WidgetPath) -> Option<StyleProperties> {
37-
// unsafe { TODO: call ffi::gtk_style_provider_get_style() }
38-
//}
41+
fn get_style(&self, path: &WidgetPath) -> Option<StyleProperties> {
42+
unsafe {
43+
from_glib_full(ffi::gtk_style_provider_get_style(self.to_glib_none().0, path.to_glib_none().0))
44+
}
45+
}
3946

40-
//fn get_style_property<P: IsA</*Ignored*/glib::ParamSpec>>(&self, path: /*Ignored*/&mut WidgetPath, state: StateFlags, pspec: &P) -> Option<glib::Value> {
47+
//fn get_style_property<P: IsA</*Ignored*/glib::ParamSpec>>(&self, path: &WidgetPath, state: StateFlags, pspec: &P) -> Option<glib::Value> {
4148
// unsafe { TODO: call ffi::gtk_style_provider_get_style_property() }
4249
//}
4350
}

src/auto/widget.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ bd67955+)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -21,6 +21,7 @@ use TargetList;
2121
use TextDirection;
2222
use Tooltip;
2323
use WidgetHelpType;
24+
use WidgetPath;
2425
use Window;
2526
use cairo;
2627
use cairo_ffi;
@@ -289,7 +290,7 @@ pub trait WidgetExt {
289290

290291
fn get_parent_window(&self) -> Option<gdk::Window>;
291292

292-
//fn get_path(&self) -> /*Ignored*/Option<WidgetPath>;
293+
fn get_path(&self) -> WidgetPath;
293294

294295
fn get_preferred_height(&self) -> (i32, i32);
295296

@@ -1432,9 +1433,11 @@ impl<O: IsA<Widget> + IsA<glib::object::Object> + glib::object::ObjectExt> Widge
14321433
}
14331434
}
14341435

1435-
//fn get_path(&self) -> /*Ignored*/Option<WidgetPath> {
1436-
// unsafe { TODO: call ffi::gtk_widget_get_path() }
1437-
//}
1436+
fn get_path(&self) -> WidgetPath {
1437+
unsafe {
1438+
from_glib_none(ffi::gtk_widget_get_path(self.to_glib_none().0))
1439+
}
1440+
}
14381441

14391442
fn get_preferred_height(&self) -> (i32, i32) {
14401443
unsafe {

0 commit comments

Comments
 (0)