Merge branch 'glib-2-58' into 'main'
Forward to glib-2-58 See merge request World/Phosh/squeekboard!621
This commit is contained in:
		@ -82,7 +82,7 @@ build_reference:
 | 
				
			|||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - apt-get -y install cargo
 | 
					    - apt-get -y install cargo
 | 
				
			||||||
    - cd _build
 | 
					    - cd _build
 | 
				
			||||||
    - ../cargo.sh doc --no-deps --document-private-items --features 'glib_v0_14,zbus_v1_5,clap_v4'
 | 
					    - ../cargo.sh doc --no-deps --document-private-items --features 'zbus_v1_5,clap_v4'
 | 
				
			||||||
  except:
 | 
					  except:
 | 
				
			||||||
    variables:
 | 
					    variables:
 | 
				
			||||||
      - $PKG_ONLY == "1"
 | 
					      - $PKG_ONLY == "1"
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,6 @@ name = "find_orphan_layouts"
 | 
				
			|||||||
path = "@path@/examples/find_orphan_layouts.rs"
 | 
					path = "@path@/examples/find_orphan_layouts.rs"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[features]
 | 
					[features]
 | 
				
			||||||
glib_v0_14 = []
 | 
					 | 
				
			||||||
zbus_v1_5 = []
 | 
					zbus_v1_5 = []
 | 
				
			||||||
clap_v4 = []
 | 
					clap_v4 = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -98,7 +98,7 @@ cargo_toml_base = configure_file(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
cargo_patch = []
 | 
					cargo_patch = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cargo_build_flags += ['--features', 'glib_v0_14,zbus_v1_5,clap_v4']
 | 
					cargo_build_flags += ['--features', 'zbus_v1_5,clap_v4']
 | 
				
			||||||
cargo_deps = files('Cargo.deps')
 | 
					cargo_deps = files('Cargo.deps')
 | 
				
			||||||
cargo_lock = files('Cargo.lock')
 | 
					cargo_lock = files('Cargo.lock')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,3 @@
 | 
				
			|||||||
#[macro_use]
 | 
					 | 
				
			||||||
extern crate clap;
 | 
					extern crate clap;
 | 
				
			||||||
extern crate rs;
 | 
					extern crate rs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -177,7 +177,7 @@ fn render_button_at_position(
 | 
				
			|||||||
    pressed: keyboard::PressType,
 | 
					    pressed: keyboard::PressType,
 | 
				
			||||||
    locked: LockedStyle,
 | 
					    locked: LockedStyle,
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
    cr.save();
 | 
					    cr.save().unwrap();
 | 
				
			||||||
    cr.translate(position.x, position.y);
 | 
					    cr.translate(position.x, position.y);
 | 
				
			||||||
    cr.rectangle(
 | 
					    cr.rectangle(
 | 
				
			||||||
        0.0, 0.0,
 | 
					        0.0, 0.0,
 | 
				
			||||||
@ -220,7 +220,7 @@ fn render_button_at_position(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cr.restore();
 | 
					    cr.restore().unwrap();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn with_button_context<R, F: FnOnce(&c::GtkStyleContext) -> R>(
 | 
					fn with_button_context<R, F: FnOnce(&c::GtkStyleContext) -> R>(
 | 
				
			||||||
 | 
				
			|||||||
@ -166,8 +166,6 @@ mod c {
 | 
				
			|||||||
                ControlFlow::Continue
 | 
					                ControlFlow::Continue
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
        ctx.release();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// A single iteration of the UI loop.
 | 
					    /// A single iteration of the UI loop.
 | 
				
			||||||
 | 
				
			|||||||
@ -108,10 +108,7 @@ mod variants {
 | 
				
			|||||||
fn get_settings(schema_name: &str) -> Option<gio::Settings> {
 | 
					fn get_settings(schema_name: &str) -> Option<gio::Settings> {
 | 
				
			||||||
    let mut error_handler = logging::Print{};
 | 
					    let mut error_handler = logging::Print{};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
    let ss = gio::SettingsSchemaSource::default();
 | 
					    let ss = gio::SettingsSchemaSource::default();
 | 
				
			||||||
    #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
    let ss = gio::SettingsSchemaSource::get_default();
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    ss.or_warn(
 | 
					    ss.or_warn(
 | 
				
			||||||
            &mut error_handler,
 | 
					            &mut error_handler,
 | 
				
			||||||
@ -134,17 +131,14 @@ fn set_layout(kind: &str, name: &str) {
 | 
				
			|||||||
    if let Some(settings) = settings {
 | 
					    if let Some(settings) = settings {
 | 
				
			||||||
        let kind = String::from(kind);
 | 
					        let kind = String::from(kind);
 | 
				
			||||||
        let name = String::from(name);
 | 
					        let name = String::from(name);
 | 
				
			||||||
        #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
        let inputs = settings.value("sources");
 | 
					        let inputs = settings.value("sources");
 | 
				
			||||||
        #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
        let inputs = settings.get_value("sources").unwrap();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let current = (kind.clone(), name.clone());
 | 
					        let current = (kind.clone(), name.clone());
 | 
				
			||||||
        let inputs = variants::get_tuples(inputs).into_iter()
 | 
					        let inputs = variants::get_tuples(inputs).into_iter()
 | 
				
			||||||
            .filter(|t| t != ¤t);
 | 
					            .filter(|t| t != ¤t);
 | 
				
			||||||
        let inputs = vec![(kind, name)].into_iter()
 | 
					        let inputs = vec![(kind, name)].into_iter()
 | 
				
			||||||
            .chain(inputs).collect();
 | 
					            .chain(inputs).collect();
 | 
				
			||||||
        settings.set_value(
 | 
					        let _ = settings.set_value(
 | 
				
			||||||
            "sources",
 | 
					            "sources",
 | 
				
			||||||
            &variants::ArrayPairString(inputs).to_variant(),
 | 
					            &variants::ArrayPairString(inputs).to_variant(),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@ -246,10 +240,7 @@ pub fn show(
 | 
				
			|||||||
    let settings = get_settings("org.gnome.desktop.input-sources");
 | 
					    let settings = get_settings("org.gnome.desktop.input-sources");
 | 
				
			||||||
    let inputs = settings
 | 
					    let inputs = settings
 | 
				
			||||||
        .map(|settings| {
 | 
					        .map(|settings| {
 | 
				
			||||||
            #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
            let inputs = settings.value("sources");
 | 
					            let inputs = settings.value("sources");
 | 
				
			||||||
            #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
            let inputs = settings.get_value("sources").unwrap();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            variants::get_tuples(inputs)
 | 
					            variants::get_tuples(inputs)
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
@ -282,16 +273,10 @@ pub fn show(
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let model: gio::Menu = {
 | 
					    let model: gio::Menu = {
 | 
				
			||||||
        #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            let builder = gtk::Builder::from_resource("/sm/puri/squeekboard/popover.ui");
 | 
					            let builder = gtk::Builder::from_resource("/sm/puri/squeekboard/popover.ui");
 | 
				
			||||||
            builder.object("app-menu").unwrap()
 | 
					            builder.object("app-menu").unwrap()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            let builder = gtk::Builder::new_from_resource("/sm/puri/squeekboard/popover.ui");
 | 
					 | 
				
			||||||
            builder.get_object("app-menu").unwrap()
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (tr, l) in human_names.iter().rev() {
 | 
					    for (tr, l) in human_names.iter().rev() {
 | 
				
			||||||
@ -300,10 +285,7 @@ pub fn show(
 | 
				
			|||||||
        model.prepend_item (&item);
 | 
					        model.prepend_item (&item);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
    let menu = gtk::Popover::from_model(Some(&window), &model);
 | 
					    let menu = gtk::Popover::from_model(Some(&window), &model);
 | 
				
			||||||
    #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
    let menu = gtk::Popover::new_from_model(Some(&window), &model);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    menu.set_pointing_to(>k::Rectangle::new (
 | 
					    menu.set_pointing_to(>k::Rectangle::new (
 | 
				
			||||||
        position.x.ceil() as i32,
 | 
					        position.x.ceil() as i32,
 | 
				
			||||||
 | 
				
			|||||||
@ -41,10 +41,7 @@ pub mod c {
 | 
				
			|||||||
    fn squeek_load_style() -> *const gtk_sys::GtkCssProvider {
 | 
					    fn squeek_load_style() -> *const gtk_sys::GtkCssProvider {
 | 
				
			||||||
        unsafe { gtk::set_initialized() };
 | 
					        unsafe { gtk::set_initialized() };
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
        let theme = gtk::Settings::default();
 | 
					        let theme = gtk::Settings::default();
 | 
				
			||||||
        #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
        let theme = gtk::Settings::get_default();
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        let theme = theme.map(|settings| get_theme_name(&settings));
 | 
					        let theme = theme.map(|settings| get_theme_name(&settings));
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -98,22 +95,16 @@ fn get_theme_name(settings: >k::Settings) -> GtkTheme {
 | 
				
			|||||||
            e
 | 
					            e
 | 
				
			||||||
        }).ok();
 | 
					        }).ok();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
    let prop = |s: >k::Settings, name| {
 | 
					    let prop = |s: >k::Settings, name| {
 | 
				
			||||||
        if s.has_property(name, None) {
 | 
					        if s.has_property(name, None) {
 | 
				
			||||||
            return Ok(s.property_value(name));
 | 
					            return Ok(s.property_value(name));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err("Key not found in settings");
 | 
					        return Err("Key not found in settings");
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
    let prop = |s: >k::Settings, name| s.get_property(name);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[cfg(feature = "glib_v0_14")]
 | 
					 | 
				
			||||||
    fn check<T, E: std::fmt::Display>(v: Result<T, E>) -> Option<T> {
 | 
					    fn check<T, E: std::fmt::Display>(v: Result<T, E>) -> Option<T> {
 | 
				
			||||||
        v.or_print(logging::Problem::Surprise, "Key not of expected type")
 | 
					        v.or_print(logging::Problem::Surprise, "Key not of expected type")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #[cfg(not(feature = "glib_v0_14"))]
 | 
					 | 
				
			||||||
    fn check<T>(v: Option<T>) -> Option<T> { v }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    match env_theme {
 | 
					    match env_theme {
 | 
				
			||||||
        Some(theme) => theme,
 | 
					        Some(theme) => theme,
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user