Coder Social home page Coder Social logo

Comments (2)

brackleian avatar brackleian commented on June 14, 2024

After more research, I found that the missing as_mut_ref() function actually does exist, but is called as_mut(), so all good there.

I also found the 'proper' way (using to_glib_full()) to deal with the GTK object reference count, which needs to be incremented in the set_window() function.

My current solution:

pub trait EventKeyExtra
{
	fn set_window (&mut self, &gdk::Window);
	fn set_send_event (&mut self, bool);
	fn set_time (&mut self, i32);
	fn set_state (&mut self, &gdk::ModifierType);
	fn set_keyval (&mut self, gdk::enums::key::Key);
	fn set_hardware_keycode (&mut self, u16);
	fn set_group (&mut self, u8);
}

impl EventKeyExtra for gdk::EventKey
{
	fn set_window (&mut self, win: &gdk::Window)
	{
		self.as_mut().window = win.to_glib_full();
	}

	fn set_send_event (&mut self, send_ev: bool)
	{
		self.as_mut().send_event = send_ev as i8;
	}

	fn set_time (&mut self, time: i32)
	{
		self.as_mut().time = time as u32;
	}

	fn set_state (&mut self, state: &gdk::ModifierType)
	{
		self.as_mut().state = state.bits();
	}

	fn set_keyval (&mut self, kv: gdk::enums::key::Key)
	{
		self.as_mut().keyval = kv;
	}

	fn set_hardware_keycode (&mut self, kc: u16)
	{
		self.as_mut().hardware_keycode = kc;
	}

	fn set_group (&mut self, grp: u8)
	{
		self.as_mut().group = grp;
	}
}

from gtk3-rs.

sdroege avatar sdroege commented on June 14, 2024

So seems like all is actually solved here :)

from gtk3-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.