Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gdk4-macos bindings #1909

Merged
merged 8 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- ".github/workflows/CI.yml"
- "examples/**"
- "gdk4/**"
- "gdk4-macos/**"
- "gdk4-wayland/**"
- "gdk4-win32/**"
- "gdk4-x11/**"
Expand All @@ -17,6 +18,7 @@ on:
- ".github/workflows/CI.yml"
- "examples/**"
- "gdk4/**"
- "gdk4-macos/**"
- "gdk4-wayland/**"
- "gdk4-win32/**"
- "gdk4-x11/**"
Expand Down Expand Up @@ -166,6 +168,7 @@ jobs:
- { name: "gtk4", is_macros_crate: false }
- { name: "gdk4", is_macros_crate: false }
- { name: "gsk4", is_macros_crate: false }
- { name: "gdk4-macos", is_macros_crate: false }
- { name: "gdk4-x11", is_macros_crate: false }
- { name: "gdk4-wayland", is_macros_crate: false }
- { name: "gdk4-win32", is_macros_crate: false }
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- ".github/workflows/docs.yml"
- "gdk4/**"
- "gdk4-macos/**"
- "gdk4-wayland/**"
- "gdk4-win32/**"
- "gdk4-x11/**"
Expand All @@ -17,6 +18,7 @@ on:
paths:
- ".github/workflows/docs.yml"
- "gdk4/**"
- "gdk4-macos/**"
- "gdk4-wayland/**"
- "gdk4-win32/**"
- "gdk4-x11/**"
Expand Down Expand Up @@ -83,6 +85,7 @@ jobs:
-p gdk4-x11 -p gdk4-x11-sys
-p gsk4 -p gsk4-sys
-p gtk4 -p gtk4-sys
-p gdk4-macos -p gdk4-macos-sys
-p gtk4-macros
--all-features
--no-deps
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
paths:
- ".github/workflows/macos.yml"
- "gdk4/**"
- "gdk4-macos/**"
- "gsk4/**"
- "gtk4/**"
- "gtk4-macros/**"
pull_request:
paths:
- ".github/workflows/macos.yml"
- "gdk4/**"
- "gdk4-macos/**"
- "gsk4/**"
- "gtk4/**"
- "gtk4-macros/**"
Expand Down Expand Up @@ -52,3 +54,19 @@ jobs:
# with:
# command: test
# args: --features v4_8,xml_validation

- name: Build gdk4-macos
uses: actions-rs/cargo@v1
with:
command: build
args: --features v4_8 --manifest-path ./gdk4-macos/Cargo.toml
- name: Clippy gdk4-macos
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features v4_8 --manifest-path ./gdk4-macos/Cargo.toml
- name: Tests gdk4-macos
uses: actions-rs/cargo@v1
with:
command: test
args: --features v4_8 --manifest-path ./gdk4-macos/Cargo.toml
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ members = [
"gdk4-wayland/sys",
"gdk4-win32",
"gdk4-win32/sys",
"gdk4-macos",
"gdk4-macos/sys",
"gsk4",
"gsk4/sys",
"gtk4",
Expand Down Expand Up @@ -58,6 +60,7 @@ libc = "0.2"
pango-sys = {git = "https://github.com/gtk-rs/gtk-rs-core", version = "0.21", branch = "main", features = ["v1_46"]}
pango = {git = "https://github.com/gtk-rs/gtk-rs-core", version = "0.21", branch = "main", features = ["v1_46"]}
gir-format-check = "^0.1"
gdk4-macos-sys = {path = "gdk4-macos/sys", version = "0.10"}
gdk4-x11-sys = {path = "gdk4-x11/sys", version = "0.10"}
gdk4-wayland-sys = {path = "gdk4-wayland/sys", version = "0.10"}
gdk4-win32-sys = {path = "gdk4-win32/sys", version = "0.10"}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ A group of crates that aims to provide complete [GTK](https://gtk.org/) 4 bindin

- [GTK](./gtk4)
- [GDK](./gdk4): An intermediate layer which isolates GTK from the details of the windowing system.
- [GDK Macos](./gdk4-macos): Macos backend specific functions.
- [GDK Wayland](./gdk4-wayland): Wayland backend specific functions.
- [GDK Win32](./gdk4-win32): Windows backend specific functions.
- [GDK X11](./gdk4-x11): X backend specific functions.
Expand Down
1 change: 1 addition & 0 deletions gdk4-macos/COPYRIGHT
32 changes: 32 additions & 0 deletions gdk4-macos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "gdk4-macos"
description = "Rust bindings of the GDK4 macos library"
documentation = "https://gtk-rs.org/gtk4-rs/stable/latest/docs/gdk4_macos/"
keywords = ["gdk4", "gdk4-macos", "gtk-rs", "gnome", "GUI"]
readme = "README.md"
authors.workspace = true
categories.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[features]
v4_8 = ["gdk4-macos-sys/v4_8"]

[dependencies]
gdk4-macos-sys.workspace = true
gdk.workspace = true
gio.workspace = true
glib.workspace = true
libc.workspace = true

[dev-dependencies]
gir-format-check.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
39 changes: 39 additions & 0 deletions gdk4-macos/Gir.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[options]
girs_directories = ["../gir-files"]
library = "GdkMacos"
version = "4.0"
min_cfg_version = "4.0.0"
target_path = "."
work_mode = "normal"
use_gi_docgen = true
single_version_file = true
generate_safety_asserts = true
deprecate_by_min_version = true
trust_return_value_nullability = true

generate = [
"GdkMacos.MacosDevice",
"GdkMacos.MacosDisplay",
"GdkMacos.MacosGLContext",
"GdkMacos.MacosKeymap",
"GdkMacos.MacosSeat",
"GdkMacos.MacosSurface",
]

manual = [
"Gdk.Device",
"Gdk.Display",
"Gdk.DrawContext",
"Gdk.GLContext",
"Gdk.Monitor",
"Gdk.Rectangle",
"Gdk.Seat",
"Gdk.Surface",
]

[[object]]
name = "GdkMacos.MacosMonitor"
status = "generate"
[[object.function]]
name = "get_geometry"
ignore = true # The function does not exists
1 change: 1 addition & 0 deletions gdk4-macos/LICENSE
58 changes: 58 additions & 0 deletions gdk4-macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Rust GDK 4 Macos bindings

The project website is [here](https://gtk-rs.org/).

Rust bindings of GDK 4's Macos backend,
part of [gtk4-rs](https://github.com/gtk-rs/gtk4-rs/).

GDK is an intermediate layer that isolates GTK from the details of the windowing system.
GDK Macos contains functions specific to the Macos backend.

## Minimum supported Rust version

Currently, the minimum supported Rust version is `1.80`.

## Documentation

- The Rust API [Stable](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gdk4_macos)/[Development](https://gtk-rs.org/gtk4-rs/git/docs/gdk4_macos/)
- [The C API](https://docs.gtk.org/gdk4-macos/)
- [GTK Installation instructions](https://www.gtk.org/docs/installations/)

## Using

We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs),
as [demonstrated here](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/index.html#library-versions).

If you want to track the bleeding edge, use the git dependency instead:

```toml
[dependencies]
gdk-wayland = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gdk4-wayland" }
```

Avoid mixing versioned and git crates like this:

```toml
# This will not compile
[dependencies]
gdk-macos = {version = "0.1", package = "gdk4-macos"}
gdk-wayland = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gdk4-wayland" }
```

### Features

| Feature | Description |
| --- | ----------- |
| `v4_8` | Enable the new APIs part of GTK 4.8 |

### See Also

- [glib](https://crates.io/crates/glib)
- [gio](https://crates.io/crates/gio)
- [gsk4](https://crates.io/crates/gsk4)
- [gdk4](https://crates.io/crates/gdk4)
- [gtk4](https://crates.io/crates/gtk4)

## License

The Rust bindings of __gdk4-macos__ are available under the MIT License, please refer to it.
16 changes: 16 additions & 0 deletions gdk4-macos/src/auto/macos_device.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;

glib::wrapper! {
#[doc(alias = "GdkMacosDevice")]
pub struct MacosDevice(Object<ffi::GdkMacosDevice, ffi::GdkMacosDeviceClass>) @extends gdk::Device;

match fn {
type_ => || ffi::gdk_macos_device_get_type(),
}
}

impl MacosDevice {}
16 changes: 16 additions & 0 deletions gdk4-macos/src/auto/macos_display.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;

glib::wrapper! {
#[doc(alias = "GdkMacosDisplay")]
pub struct MacosDisplay(Object<ffi::GdkMacosDisplay, ffi::GdkMacosDisplayClass>) @extends gdk::Display;

match fn {
type_ => || ffi::gdk_macos_display_get_type(),
}
}

impl MacosDisplay {}
16 changes: 16 additions & 0 deletions gdk4-macos/src/auto/macos_gl_context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;

glib::wrapper! {
#[doc(alias = "GdkMacosGLContext")]
pub struct MacosGLContext(Object<ffi::GdkMacosGLContext, ffi::GdkMacosGLContextClass>) @extends gdk::GLContext, gdk::DrawContext;

match fn {
type_ => || ffi::gdk_macos_gl_context_get_type(),
}
}

impl MacosGLContext {}
16 changes: 16 additions & 0 deletions gdk4-macos/src/auto/macos_keymap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;

glib::wrapper! {
#[doc(alias = "GdkMacosKeymap")]
pub struct MacosKeymap(Object<ffi::GdkMacosKeymap, ffi::GdkMacosKeymapClass>);

match fn {
type_ => || ffi::gdk_macos_keymap_get_type(),
}
}

impl MacosKeymap {}
31 changes: 31 additions & 0 deletions gdk4-macos/src/auto/macos_monitor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;
use glib::{prelude::*, translate::*};

glib::wrapper! {
#[doc(alias = "GdkMacosMonitor")]
pub struct MacosMonitor(Object<ffi::GdkMacosMonitor, ffi::GdkMacosMonitorClass>) @extends gdk::Monitor;

match fn {
type_ => || ffi::gdk_macos_monitor_get_type(),
}
}

impl MacosMonitor {
#[doc(alias = "gdk_macos_monitor_get_workarea")]
#[doc(alias = "get_workarea")]
pub fn workarea(monitor: &impl IsA<gdk::Monitor>) -> gdk::Rectangle {
assert_initialized_main_thread!();
unsafe {
let mut geometry = gdk::Rectangle::uninitialized();
ffi::gdk_macos_monitor_get_workarea(
monitor.as_ref().to_glib_none().0,
geometry.to_glib_none_mut().0,
);

Check warning on line 27 in gdk4-macos/src/auto/macos_monitor.rs

View workflow job for this annotation

GitHub Actions / build

unresolved link to `crate::gdk::prelude::MonitorExtManual::scale_factor`
geometry
}
}
}
16 changes: 16 additions & 0 deletions gdk4-macos/src/auto/macos_seat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;

glib::wrapper! {
#[doc(alias = "GdkMacosSeat")]
pub struct MacosSeat(Object<ffi::GdkMacosSeat, ffi::GdkMacosSeatClass>) @extends gdk::Seat;

match fn {
type_ => || ffi::gdk_macos_seat_get_type(),
}
}

impl MacosSeat {}
Loading
Loading