Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #746 from pbor/backport-0.15
Browse files Browse the repository at this point in the history
Backport stuff for 0.15
  • Loading branch information
sdroege committed Apr 24, 2022
2 parents 807522a + 80d2076 commit 7bc2398
Show file tree
Hide file tree
Showing 25 changed files with 127 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:

gvsbuild:
name: build GTK binaries with gvsbuild
runs-on: windows-latest
runs-on: windows-2019

env:
# git revision of gvsbuild we use for to build GTK and the other dependencies
gvsbuildref: ce4c9de92dc3487d15b8f5ecc200705f951b6ae8
gvsbuildref: 861244f84a04da49172c23646d9e23885094cab4

# bump this number if you want to force a rebuild of gvsbuild with the same revision
gvsbuildupdate: 1
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:

build:
name: build gtk-rs on Windows
runs-on: windows-latest
runs-on: windows-2019
needs: gvsbuild

strategy:
Expand Down
4 changes: 2 additions & 2 deletions atk/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
2 changes: 2 additions & 0 deletions atk/sys/tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl Results {
}

#[test]
#[cfg(target_os = "linux")]
fn cross_validate_constants_with_c() {
let mut c_constants: Vec<(String, String)> = Vec::new();

Expand Down Expand Up @@ -150,6 +151,7 @@ fn cross_validate_constants_with_c() {
}

#[test]
#[cfg(target_os = "linux")]
fn cross_validate_layout_with_c() {
let mut c_layouts = Vec::new();

Expand Down
4 changes: 2 additions & 2 deletions atk/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
4 changes: 2 additions & 2 deletions gdk/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
2 changes: 2 additions & 0 deletions gdk/sys/tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl Results {
}

#[test]
#[cfg(target_os = "linux")]
fn cross_validate_constants_with_c() {
let mut c_constants: Vec<(String, String)> = Vec::new();

Expand Down Expand Up @@ -150,6 +151,7 @@ fn cross_validate_constants_with_c() {
}

#[test]
#[cfg(target_os = "linux")]
fn cross_validate_layout_with_c() {
let mut c_layouts = Vec::new();

Expand Down
4 changes: 2 additions & 2 deletions gdk/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
2 changes: 1 addition & 1 deletion gdkwayland/src/wayland_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl WaylandWindow {
let window = from_glib_borrow(window);
let handle: Borrowed<glib::GString> = from_glib_borrow(handle);
let callback: &P = &*(user_data as *mut _);
(*callback)(&window, &handle.as_str());
(*callback)(&window, handle.as_str());
}
unsafe extern "C" fn destroy_notify<P: Fn(&WaylandWindow, &str) + 'static>(
data: glib::ffi::gpointer,
Expand Down
4 changes: 2 additions & 2 deletions gdkx11/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
2 changes: 2 additions & 0 deletions gdkx11/src/auto/x11_app_launch_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ glib::wrapper! {
}
}

impl X11AppLaunchContext {}

impl fmt::Display for X11AppLaunchContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11AppLaunchContext")
Expand Down
2 changes: 2 additions & 0 deletions gdkx11/src/auto/x11_device_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ glib::wrapper! {
}
}

impl X11DeviceCore {}

impl fmt::Display for X11DeviceCore {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11DeviceCore")
Expand Down
2 changes: 2 additions & 0 deletions gdkx11/src/auto/x11_display_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ glib::wrapper! {
}
}

impl X11DisplayManager {}

impl fmt::Display for X11DisplayManager {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11DisplayManager")
Expand Down
2 changes: 2 additions & 0 deletions gdkx11/src/auto/x11_drag_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ glib::wrapper! {
}
}

impl X11DragContext {}

impl fmt::Display for X11DragContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11DragContext")
Expand Down
2 changes: 2 additions & 0 deletions gdkx11/src/auto/x11_visual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ glib::wrapper! {
}
}

impl X11Visual {}

impl fmt::Display for X11Visual {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11Visual")
Expand Down
2 changes: 2 additions & 0 deletions gdkx11/src/auto/x11gl_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ glib::wrapper! {
}
}

impl X11GLContext {}

impl fmt::Display for X11GLContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("X11GLContext")
Expand Down
4 changes: 2 additions & 2 deletions gdkx11/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
2 changes: 1 addition & 1 deletion gir-files
4 changes: 2 additions & 2 deletions gtk/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
2 changes: 1 addition & 1 deletion gtk/src/stack_switcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<O: IsA<StackSwitcher>> StackSwitcherExtManual for O {
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&StackSwitcher::from_glib_borrow(this).unsafe_cast_ref())
f(StackSwitcher::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
Expand Down
83 changes: 83 additions & 0 deletions gtk/src/subclass/entry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::subclass::prelude::*;
use glib::translate::*;
use glib::Cast;

use super::widget::WidgetImpl;
use crate::Entry;
use crate::Widget;

pub trait EntryImpl: EntryImplExt + WidgetImpl {
fn populate_popup(&self, entry: &Self::Type, popup: &Widget) {
self.parent_populate_popup(entry, popup)
}

fn activate(&self, entry: &Self::Type) {
self.parent_activate(entry)
}
}

pub trait EntryImplExt: ObjectSubclass {
fn parent_populate_popup(&self, entry: &Self::Type, popup: &Widget);
fn parent_activate(&self, entry: &Self::Type);
}

impl<T: EntryImpl> EntryImplExt for T {
fn parent_populate_popup(&self, entry: &Self::Type, popup: &Widget) {
unsafe {
let data = T::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkEntryClass;
if let Some(f) = (*parent_class).populate_popup {
f(
entry.unsafe_cast_ref::<Entry>().to_glib_none().0,
popup.to_glib_none().0,
)
}
}
}

fn parent_activate(&self, entry: &Self::Type) {
unsafe {
let data = T::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkEntryClass;
if let Some(f) = (*parent_class).activate {
f(entry.unsafe_cast_ref::<Entry>().to_glib_none().0)
}
}
}
}

unsafe impl<T: EntryImpl> IsSubclassable<T> for Entry {
fn class_init(class: &mut glib::Class<Self>) {
Self::parent_class_init::<T>(class);

if !crate::rt::is_initialized() {
panic!("GTK has to be initialized first");
}

let klass = class.as_mut();
klass.populate_popup = Some(entry_populate_popup::<T>);
klass.activate = Some(entry_activate::<T>);
}
}

unsafe extern "C" fn entry_populate_popup<T: EntryImpl>(
ptr: *mut ffi::GtkEntry,
popupptr: *mut ffi::GtkWidget,
) {
let instance = &*(ptr as *mut T::Instance);
let imp = instance.imp();
let wrap: Borrowed<Entry> = from_glib_borrow(ptr);
let popup: Borrowed<Widget> = from_glib_borrow(popupptr);

imp.populate_popup(wrap.unsafe_cast_ref(), &popup)
}

unsafe extern "C" fn entry_activate<T: EntryImpl>(ptr: *mut ffi::GtkEntry) {
let instance = &*(ptr as *mut T::Instance);
let imp = instance.imp();
let wrap: Borrowed<Entry> = from_glib_borrow(ptr);

imp.activate(wrap.unsafe_cast_ref())
}
2 changes: 2 additions & 0 deletions gtk/src/subclass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod cell_renderer_toggle;
pub mod container;
pub mod dialog;
pub mod drawing_area;
pub mod entry;
pub mod event_box;
pub mod fixed;
pub mod header_bar;
Expand Down Expand Up @@ -56,6 +57,7 @@ pub mod prelude {
pub use super::container::{ContainerClassSubclassExt, ContainerImpl, ContainerImplExt};
pub use super::dialog::{DialogImpl, DialogImplExt};
pub use super::drawing_area::DrawingAreaImpl;
pub use super::entry::{EntryImpl, EntryImplExt};
pub use super::event_box::EventBoxImpl;
pub use super::fixed::FixedImpl;
pub use super::header_bar::HeaderBarImpl;
Expand Down
2 changes: 2 additions & 0 deletions gtk/sys/tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl Results {
}

#[test]
#[cfg(target_os = "linux")]
fn cross_validate_constants_with_c() {
let mut c_constants: Vec<(String, String)> = Vec::new();

Expand Down Expand Up @@ -150,6 +151,7 @@ fn cross_validate_constants_with_c() {
}

#[test]
#[cfg(target_os = "linux")]
fn cross_validate_layout_with_c() {
let mut c_layouts = Vec::new();

Expand Down
4 changes: 2 additions & 2 deletions gtk/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
from gir-files (https://github.com/gtk-rs/gir-files @ 68003b4b40e5)
Generated by gir (https://github.com/gtk-rs/gir @ c8a7a13d2c4d)
from gir-files (https://github.com/gtk-rs/gir-files @ 75db22efb234)
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
edition = "2021"

0 comments on commit 7bc2398

Please sign in to comment.