Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ba2fbc5
add generated action interface
vhdirk Jun 5, 2018
b5c5f62
regenerate
vhdirk Jun 5, 2018
8d98d7e
regenerate
vhdirk Jun 6, 2018
0cca102
regenerate
vhdirk Jun 6, 2018
6dbde18
regenerate
vhdirk Jun 6, 2018
1d7e28b
regenerate
vhdirk Jun 7, 2018
78bf080
regenerate
vhdirk Jun 7, 2018
9bd5cf6
regenerate
vhdirk Jun 7, 2018
05c3fa0
regenerate
vhdirk Jun 7, 2018
37ce756
regenerate
vhdirk Jun 7, 2018
6636cdd
regenerate
vhdirk Jun 8, 2018
7449416
regenerate (with content spliced from external file)
vhdirk Jun 8, 2018
b0b95ca
regenerate
vhdirk Jun 8, 2018
f95bc9b
regenerate
vhdirk Jun 9, 2018
ef34802
regenerate
vhdirk Jun 9, 2018
6864579
Implement minimal test for the GAction interface
sdroege Jun 10, 2018
098d616
regenerate
vhdirk Jun 10, 2018
e95da27
regenerate
vhdirk Jun 10, 2018
6c05000
rebase on master
vhdirk Jun 16, 2018
4ceca27
wip: proper test for gaction
vhdirk Jun 16, 2018
70ffb58
add gaction to glib_wrapper list
vhdirk Jun 17, 2018
2a306dc
wip: beef up gaction test
vhdirk Jun 21, 2018
d40cea4
fix simpleaction unit test
vhdirk Jun 21, 2018
7f2258d
extend simpleaction unit test some more
vhdirk Jun 22, 2018
aac248a
wip: simpleaction test
vhdirk Jun 22, 2018
318448a
wip: simpleaction test
vhdirk Jun 22, 2018
f16ac62
invert did_run assertion
vhdirk Jun 23, 2018
c4ee724
invert get_property(enabled) assertion
vhdirk Jun 23, 2018
081094a
wip: ownership of pointers
vhdirk Jun 24, 2018
ae4f36b
fix argument for activate signal
vhdirk Jun 24, 2018
6555dfc
regenerate
vhdirk Jun 27, 2018
ba0ac33
is this a good way to implement those free functions?
vhdirk Jun 30, 2018
058d458
second try for destroy function
vhdirk Jun 30, 2018
d9aedf1
regenerate
vhdirk Jul 1, 2018
ca2a3ab
regenerate
vhdirk Jul 1, 2018
254a53a
regenerate
vhdirk Jul 2, 2018
961a40b
Fix lib after removal of 'free' module
vhdirk Jul 2, 2018
95ced4c
remove new GParamSpec properties for now
vhdirk Jul 3, 2018
d976bfb
regenerate
vhdirk Jul 3, 2018
500da22
regenerate
vhdirk Jul 3, 2018
0bc5673
regenerate
vhdirk Jul 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gir_Gio.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ min_cfg_version = "2.32"
target_path = "./gio-subclass"
work_mode = "subclass"

generate = []
generate = [
"Gio.Action"
]

manual = [
"GLib.Bytes",
Expand Down
271 changes: 271 additions & 0 deletions gio-subclass/src/auto/action.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 3733792+)
// from gir-files (https://github.com/gtk-rs/gir-files @ 47c69e6)
// DO NOT EDIT

#[allow(unused_imports)]
use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double,
c_short, c_ushort, c_long, c_ulong,
c_void, size_t, ssize_t, intptr_t, uintptr_t, time_t, FILE};

#[allow(unused_imports)]
use glib_ffi::{gboolean, gconstpointer, gpointer, GType};

#[cfg(any(feature = "v2_38", feature = "dox"))]
use Error;
use gio;
use gio_ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

use gobject_subclass::anyimpl::*;
use gobject_subclass::object::*;


pub trait ActionImpl: AnyImpl + 'static {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs to be ObjectImpl. The docs say that GAction requires GObject (this should also be machine-readable from the gir file)

Copy link
Collaborator Author

@vhdirk vhdirk Jun 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. For interfaces I did not expect there to be requirements as such

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does pose a problem though. ObjectImpl is generic over T, but ActionImpl isn't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could we make it generic over T or does that break everything then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll probably break a lot, but I don't see any other option? Though I'm not sure what traits T should be bound to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have to be bound to ObjectImpl. Let's worry about that in a separate PR


fn activate(&self, action: &gio::Action, parameter: Option<&glib::Variant>);

fn change_state(&self, action: &gio::Action, value: &glib::Variant);

fn get_enabled(&self, action: &gio::Action) -> bool;

fn get_name(&self, action: &gio::Action) -> Option<String>;

fn get_parameter_type(&self, action: &gio::Action) -> Option<glib::VariantType>;

fn get_state(&self, action: &gio::Action) -> Option<glib::Variant>;

fn get_state_hint(&self, action: &gio::Action) -> Option<glib::Variant>;

fn get_state_type(&self, action: &gio::Action) -> Option<glib::VariantType>;

}

any_impl!(ActionImpl);

pub trait ActionImplStatic<T: ObjectType>: 'static {
fn get_impl<'a>(&self, imp: &'a T::ImplType) -> &'a ActionImpl;
}

struct ActionStatic<T: ObjectType>{
imp_static: *const ActionImplStatic<T>
}


unsafe extern "C" fn action_activate<T: ObjectType>
(gptr: *mut gio_ffi::GAction, parameter: *mut glib_ffi::GVariant)
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
imp.activate(&wrap, (if parameter.is_null() { None } else { Some(from_glib_borrow(parameter)) }).as_ref());
}

unsafe extern "C" fn action_change_state<T: ObjectType>
(gptr: *mut gio_ffi::GAction, value: *mut glib_ffi::GVariant)
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
imp.change_state(&wrap, &from_glib_none(value));
}

unsafe extern "C" fn action_get_enabled<T: ObjectType>
(gptr: *mut gio_ffi::GAction) -> gboolean
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
let rs_ret = imp.get_enabled(&wrap);
rs_ret.to_glib()
}

unsafe extern "C" fn action_get_name<T: ObjectType>
(gptr: *mut gio_ffi::GAction) -> *const c_char
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
let rs_ret = imp.get_name(&wrap);

match rs_ret {
Some(t_ret) => {
let ret = t_ret.to_glib_full();
unsafe extern "C" fn destroy_ret(p: glib_ffi::gpointer){
String::from_glib_full(p as *const c_char);
};
gobject_ffi::g_object_set_qdata_full(gptr as *mut gobject_ffi::GObject,
glib_ffi::g_quark_from_string("rs_action_get_name_ret".to_glib_none().0),
ret as *mut c_void,
Some(destroy_ret)
);
ret
},
None => ptr::null()
}
}

unsafe extern "C" fn action_get_parameter_type<T: ObjectType>
(gptr: *mut gio_ffi::GAction) -> *const glib_ffi::GVariantType
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
let rs_ret = imp.get_parameter_type(&wrap);

match rs_ret {
Some(t_ret) => {
let ret = t_ret.to_glib_full();
unsafe extern "C" fn destroy_ret(p: glib_ffi::gpointer){
glib::VariantType::from_glib_full(p as *const glib_ffi::GVariantType);
};
gobject_ffi::g_object_set_qdata_full(gptr as *mut gobject_ffi::GObject,
glib_ffi::g_quark_from_string("rs_action_get_parameter_type_ret".to_glib_none().0),
ret as *mut c_void,
Some(destroy_ret)
);
ret
},
None => ptr::null()
}
}

unsafe extern "C" fn action_get_state<T: ObjectType>
(gptr: *mut gio_ffi::GAction) -> *mut glib_ffi::GVariant
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
let rs_ret = imp.get_state(&wrap);
match rs_ret { Some(t_ret) => t_ret.to_glib_full(), None => ptr::null_mut()}
}

unsafe extern "C" fn action_get_state_hint<T: ObjectType>
(gptr: *mut gio_ffi::GAction) -> *mut glib_ffi::GVariant
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
let rs_ret = imp.get_state_hint(&wrap);
match rs_ret { Some(t_ret) => t_ret.to_glib_full(), None => ptr::null_mut()}
}

unsafe extern "C" fn action_get_state_type<T: ObjectType>
(gptr: *mut gio_ffi::GAction) -> *const glib_ffi::GVariantType
{
floating_reference_guard!(gptr);
let klass = &**(gptr as *const *const ClassStruct<T>);
let interface_static = klass.get_interface_static(gio_ffi::g_action_get_type())
as *const ActionStatic<T>;
let instance = &*(gptr as *const T::InstanceStructType);
let imp = instance.get_impl();
let imp = (*(*interface_static).imp_static).get_impl(imp);
let wrap = from_glib_borrow(gptr);
let rs_ret = imp.get_state_type(&wrap);

match rs_ret {
Some(t_ret) => {
let ret = t_ret.to_glib_full();
unsafe extern "C" fn destroy_ret(p: glib_ffi::gpointer){
glib::VariantType::from_glib_full(p as *const glib_ffi::GVariantType);
};
gobject_ffi::g_object_set_qdata_full(gptr as *mut gobject_ffi::GObject,
glib_ffi::g_quark_from_string("rs_action_get_state_type_ret".to_glib_none().0),
ret as *mut c_void,
Some(destroy_ret)
);
ret
},
None => ptr::null()
}
}

unsafe extern "C" fn action_init<T: ObjectType>(
iface: glib_ffi::gpointer,
iface_data: glib_ffi::gpointer
) {
let action_iface = &mut *(iface as *mut gio_ffi::GActionInterface);
let iface_type = (*(iface as *const gobject_ffi::GTypeInterface)).g_type;
let type_ = (*(iface as *const gobject_ffi::GTypeInterface)).g_instance_type;
let klass = &mut *(gobject_ffi::g_type_class_ref(type_) as *mut ClassStruct<T>);
let interfaces_static = &mut *(klass.interfaces_static as *mut Vec<_>);
interfaces_static.push((iface_type, iface_data));
action_iface.activate = Some(action_activate::<T>);
action_iface.change_state = Some(action_change_state::<T>);
action_iface.get_enabled = Some(action_get_enabled::<T>);
action_iface.get_name = Some(action_get_name::<T>);
action_iface.get_parameter_type = Some(action_get_parameter_type::<T>);
action_iface.get_state = Some(action_get_state::<T>);
action_iface.get_state_hint = Some(action_get_state_hint::<T>);
action_iface.get_state_type = Some(action_get_state_type::<T>);
}

pub fn register_action<T: ObjectType, I: ActionImplStatic<T>>(
_: &TypeInitToken,
type_: glib::Type,
imp: &I,
) {

unsafe {
let imp = imp as &ActionImplStatic<T> as *const ActionImplStatic<T>;
let interface_static = Box::new(ActionStatic {
imp_static: imp,
});
let iface_info = gobject_ffi::GInterfaceInfo {
interface_init: Some(action_init::<T>),
interface_finalize: None,
interface_data: Box::into_raw(interface_static) as glib_ffi::gpointer,
};
gobject_ffi::g_type_add_interface_static(
type_.to_glib(),
gio_ffi::g_action_get_type(),
&iface_info,
);
}

}
20 changes: 10 additions & 10 deletions gio-subclass/src/auto/application.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ cf72ed8+)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 3733792+)
// from gir-files (https://github.com/gtk-rs/gir-files @ 47c69e6)
// DO NOT EDIT

Expand Down Expand Up @@ -306,7 +306,6 @@ unsafe impl<T: ObjectType + glib::IsA<gio::Application>> ApplicationBase for T {

pub type ApplicationClass = ClassStruct<Application>;

// FIXME: Boilerplate
unsafe impl ObjectClassExt<Application> for ApplicationClass {}
unsafe impl ApplicationClassExt<Application> for ApplicationClass {}

Expand Down Expand Up @@ -392,7 +391,7 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.activate(&wrap)
imp.activate(&wrap);
}

unsafe extern "C" fn application_after_emit<T: ApplicationBase>
Expand All @@ -404,7 +403,7 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.after_emit(&wrap, &from_glib_none(platform_data))
imp.after_emit(&wrap, &from_glib_none(platform_data));
}

unsafe extern "C" fn application_before_emit<T: ApplicationBase>
Expand All @@ -416,7 +415,7 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.before_emit(&wrap, &from_glib_none(platform_data))
imp.before_emit(&wrap, &from_glib_none(platform_data));
}

unsafe extern "C" fn application_command_line<T: ApplicationBase>
Expand All @@ -428,7 +427,8 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.command_line(&wrap, &from_glib_none(command_line))
let rs_ret = imp.command_line(&wrap, &from_glib_none(command_line));
rs_ret
}
unsafe extern "C" fn application_local_command_line<T: ApplicationBase>(
ptr: *mut gio_ffi::GApplication,
Expand Down Expand Up @@ -480,7 +480,7 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.quit_mainloop(&wrap)
imp.quit_mainloop(&wrap);
}

unsafe extern "C" fn application_run_mainloop<T: ApplicationBase>
Expand All @@ -492,7 +492,7 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.run_mainloop(&wrap)
imp.run_mainloop(&wrap);
}

unsafe extern "C" fn application_shutdown<T: ApplicationBase>
Expand All @@ -504,7 +504,7 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.shutdown(&wrap)
imp.shutdown(&wrap);
}

unsafe extern "C" fn application_startup<T: ApplicationBase>
Expand All @@ -516,5 +516,5 @@ where
let application = &*(gptr as *mut T::InstanceStructType);
let wrap: T = from_glib_borrow(gptr as *mut T::InstanceStructType);
let imp = application.get_impl();
imp.startup(&wrap)
imp.startup(&wrap);
}
4 changes: 3 additions & 1 deletion gio-subclass/src/auto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ cf72ed8+)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 3733792+)
// from gir-files (https://github.com/gtk-rs/gir-files @ 47c69e6)
// DO NOT EDIT


pub mod action;

pub mod application;
1 change: 1 addition & 0 deletions gio-subclass/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ extern crate gobject_subclass;

mod auto;
pub use auto::application;
pub use auto::action;
Loading