This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GObject refactoring and some minor cleanups
Make all `GObject` descendants use `glib::object`. Convert other pointer types to use `From/ToGlibPtr`. Move everything out of the `widgets` module. Add `prelude` that will reexport any traits defined in the crate.
- Loading branch information
Showing
44 changed files
with
2,143 additions
and
2,395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2013-2015, The Rust-GNOME Project Developers. | ||
// See the COPYRIGHT file at the top-level directory of this distribution. | ||
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> | ||
|
||
//! Application launching — Startup notification for applications | ||
|
||
use glib::translate::*; | ||
use glib::types::{StaticType, Type}; | ||
use object::Object; | ||
use screen::Screen; | ||
use ffi; | ||
|
||
// FIXME: should inherit from GAppLaunchContext | ||
pub type AppLaunchContext = Object<ffi::C_GdkAppLaunchContext>; | ||
|
||
impl StaticType for AppLaunchContext { | ||
fn static_type() -> Type { unsafe { from_glib(ffi::gdk_app_launch_context_get_type()) } } | ||
} | ||
|
||
impl AppLaunchContext { | ||
pub fn set_screen(&self, screen: &Screen) { | ||
unsafe { | ||
ffi::gdk_app_launch_context_set_screen(self.to_glib_none().0, screen.to_glib_none().0) | ||
} | ||
} | ||
|
||
pub fn set_desktop(&self, desktop: i32) { | ||
unsafe { ffi::gdk_app_launch_context_set_desktop(self.to_glib_none().0, desktop) } | ||
} | ||
|
||
pub fn set_timestamp(&self, timestamp: u32) { | ||
unsafe { ffi::gdk_app_launch_context_set_timestamp(self.to_glib_none().0, timestamp) } | ||
} | ||
|
||
/*pub fn set_icon(&self, icon: GIO::Icon) { | ||
unsafe { ffi::gdk_app_launch_context_set_timestamp(self.to_glib_none().0, icon.to_glib_none().0) } | ||
}*/ | ||
|
||
pub fn set_icon_name(&self, icon_name: &str) { | ||
unsafe { | ||
ffi::gdk_app_launch_context_set_icon_name(self.to_glib_none().0, | ||
icon_name.to_glib_none().0) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2013-2015, The Rust-GNOME Project Developers. | ||
// See the COPYRIGHT file at the top-level directory of this distribution. | ||
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> | ||
|
||
use ffi; | ||
use glib::translate::*; | ||
|
||
#[allow(raw_pointer_derive)] | ||
#[derive(Copy, Clone, PartialEq, Eq)] | ||
pub struct Atom(ffi::C_GdkAtom); | ||
|
||
pub const NONE: Atom = Atom(0 as *mut _); | ||
|
||
impl Atom { | ||
pub fn intern(atom_name: &str) -> Atom { | ||
unsafe { Atom(ffi::gdk_atom_intern(atom_name.to_glib_none().0, false.to_glib())) } | ||
} | ||
|
||
pub fn name(&self) -> String { | ||
unsafe { from_glib_full(ffi::gdk_atom_name(self.0)) } | ||
} | ||
} | ||
|
||
impl<'a> ToGlibPtr<'a, ffi::C_GdkAtom> for Atom { | ||
type Storage = (); | ||
|
||
#[inline] | ||
fn to_glib_none(&self) -> Stash<'a, ffi::C_GdkAtom, Atom> { | ||
Stash(self.0, ()) | ||
} | ||
} | ||
|
||
impl FromGlibPtr<ffi::C_GdkAtom> for Atom { | ||
#[inline] | ||
unsafe fn from_glib_none(ptr: ffi::C_GdkAtom) -> Atom { Atom(ptr) } | ||
#[inline] | ||
unsafe fn from_glib_full(_: ffi::C_GdkAtom) -> Atom { unimplemented!() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2013-2015, The Rust-GNOME Project Developers. | ||
// See the COPYRIGHT file at the top-level directory of this distribution. | ||
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> | ||
|
||
//! Cursors — Standard and pixmap cursors | ||
|
||
use glib::translate::*; | ||
use glib::types; | ||
use display::Display; | ||
use object::Object; | ||
use pixbuf::Pixbuf; | ||
use ffi; | ||
|
||
pub type Type = ffi::enums::CursorType; | ||
|
||
pub type Cursor = Object<ffi::C_GdkCursor>; | ||
|
||
impl types::StaticType for Cursor { | ||
fn static_type() -> types::Type { unsafe { from_glib(ffi::gdk_cursor_get_type()) } } | ||
} | ||
|
||
impl Cursor { | ||
pub fn new(cursor_type: Type) -> Cursor { | ||
unsafe { from_glib_full(ffi::gdk_cursor_new(cursor_type)) } | ||
} | ||
|
||
pub fn new_from_pixbuf(display: &Display, pixbuf: &Pixbuf, x: i32, y: i32) -> Cursor { | ||
unsafe { | ||
from_glib_full( | ||
ffi::gdk_cursor_new_from_pixbuf(display.to_glib_none().0, | ||
pixbuf.to_glib_none().0, x, y)) | ||
} | ||
} | ||
|
||
pub fn new_from_name(display: &Display, name: &str) -> Option<Cursor> { | ||
unsafe { | ||
from_glib_full(ffi::gdk_cursor_new_from_name(display.to_glib_none().0, | ||
name.to_glib_none().0)) | ||
} | ||
} | ||
|
||
pub fn new_for_display(display: &Display, cursor_type: Type) -> Cursor { | ||
unsafe { | ||
from_glib_full(ffi::gdk_cursor_new_for_display(display.to_glib_none().0, cursor_type)) | ||
} | ||
} | ||
|
||
pub fn get_display(&self) -> Display { | ||
unsafe { from_glib_none(ffi::gdk_cursor_get_display(self.to_glib_none().0)) } | ||
} | ||
|
||
pub fn get_image(&self) -> Option<Pixbuf> { | ||
unsafe { from_glib_full(ffi::gdk_cursor_get_image(self.to_glib_none().0)) } | ||
} | ||
|
||
pub fn get_cursor_type(&self) -> Type { | ||
unsafe { ffi::gdk_cursor_get_cursor_type(self.to_glib_none().0) } | ||
} | ||
} |
Oops, something went wrong.