Skip to content

Commit 9ccd225

Browse files
Merge pull request gtk-rs#630 from EPashkin/widget_path
Generate WidgetPath
2 parents 661924f + eb7025e commit 9ccd225

File tree

7 files changed

+315
-28
lines changed

7 files changed

+315
-28
lines changed

Gir.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ generate = [
220220
"Gtk.Viewport",
221221
"Gtk.VolumeButton",
222222
"Gtk.WidgetHelpType",
223+
"Gtk.WidgetPath",
223224
"Gtk.WindowGroup",
224225
"Gtk.WindowPosition",
225226
"Gtk.WindowType",
@@ -1814,6 +1815,10 @@ status = "generate"
18141815
[[object.function]]
18151816
name = "style_get_property"
18161817
ignore = true
1818+
[[object.function]]
1819+
name = "get_path"
1820+
[object.function.return]
1821+
nullable = false
18171822
[[object.signal]]
18181823
name = "button-press-event"
18191824
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/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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*/&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*/&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: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
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*/&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*/&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*/&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*/&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*/&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*/&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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)