| 1 | /* |
| 2 | * Copyright 2020-2024 Andrey Kutejko <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * For more details see the file COPYING. |
| 18 | */ |
| 19 | |
| 20 | use craterust-analyzer cargo gnome-robots 50.0.0 crate/::{ |
| 21 | controlsrust-analyzer cargo gnome-robots 50.0.0 controls/::controlsrust-analyzer cargo gnome-robots 50.0.0 controls/controls/::create_controls_listrust-analyzer cargo gnome-robots 50.0.0 controls/controls/create_controls_list()., |
| 22 | game_configrust-analyzer cargo gnome-robots 50.0.0 game_config/::{GameConfigrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#, GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#}, |
| 23 | propertiesrust-analyzer cargo gnome-robots 50.0.0 properties/::Propertiesrust-analyzer cargo gnome-robots 50.0.0 properties/Properties#, |
| 24 | themerust-analyzer cargo gnome-robots 50.0.0 theme/::Themerust-analyzer cargo gnome-robots 50.0.0 theme/Theme#, |
| 25 | themesrust-analyzer cargo gnome-robots 50.0.0 themes/, |
| 26 | }; |
| 27 | use adwrust-analyzer cargo libadwaita 0.9.1 crate/::preluderust-analyzer cargo libadwaita 0.9.1 prelude/::*; |
| 28 | use gettextrsrust-analyzer cargo gettext-rs 0.7.7 crate/::gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().; |
| 29 | use gtkrust-analyzer cargo gtk4 0.11.1 crate/::{giorust-analyzer cargo gio 0.22.2 crate/, glibrust-analyzer cargo glib 0.22.3 crate/}; |
| 30 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#; |
| 31 | |
| 32 | pub fn show_preferencesrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/show_preferences().( |
| 33 | parent_window: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<>krust-analyzer cargo gtk4 0.11.1 crate/::Windowrust-analyzer cargo gtk4 0.11.1 auto/window/Window#>, |
| 34 | game_configs: &GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#, |
| 35 | themes: &giorust-analyzer cargo gio 0.22.2 crate/::ListModelrust-analyzer cargo gio 0.22.2 auto/list_model/ListModel#, |
| 36 | settings: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#, |
| 37 | ) { |
| 38 | let window = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesDialogrust-analyzer cargo libadwaita 0.9.1 auto/preferences_dialog/PreferencesDialog#::builderrust-analyzer cargo libadwaita 0.9.1 auto/preferences_dialog/impl#[PreferencesDialog]builder().().buildrust-analyzer cargo libadwaita 0.9.1 auto/preferences_dialog/impl#[PreferencesDialogBuilder]build().(); |
| 39 | |
| 40 | /* The configuration page */ |
| 41 | let configuration_page = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesPagerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPage#::builderrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPage]builder().() |
| 42 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("Game")) |
| 43 | .icon_namerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]icon_name().("gamepad2") |
| 44 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]build().(); |
| 45 | configuration_page.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPageExt#add().(&create_game_grouprust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_game_group().(game_configs, settings)); |
| 46 | configuration_page.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPageExt#add().(&create_sound_grouprust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_sound_group().(settings)); |
| 47 | window.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_dialog/PreferencesDialogExt#add().(&configuration_page); |
| 48 | |
| 49 | /* The graphics page */ |
| 50 | let graphics_page = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesPagerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPage#::builderrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPage]builder().() |
| 51 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("Appearance")) |
| 52 | .icon_namerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]icon_name().("brush-monitor") |
| 53 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]build().(); |
| 54 | let appearance_group = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesGrouprust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroup#::builderrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/impl#[PreferencesGroup]builder().().buildrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/impl#[PreferencesGroupBuilder]build().(); |
| 55 | appearance_group.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroupExt#add().(&create_theme_pickerrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_theme_picker().(themes, settings)); |
| 56 | appearance_group.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroupExt#add().(&create_background_pickerrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_background_picker().(settings)); |
| 57 | graphics_page.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPageExt#add().(&appearance_group); |
| 58 | window.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_dialog/PreferencesDialogExt#add().(&graphics_page); |
| 59 | |
| 60 | /* The keyboard page */ |
| 61 | let keyboard_page = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesPagerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPage#::builderrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPage]builder().() |
| 62 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("Keyboard")) |
| 63 | .icon_namerust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]icon_name().("keyboard-shortcuts") |
| 64 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/impl#[PreferencesPageBuilder]build().(); |
| 65 | keyboard_page.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_page/PreferencesPageExt#add().(&create_controls_listrust-analyzer cargo gnome-robots 50.0.0 controls/controls/create_controls_list().(settings)); |
| 66 | window.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_dialog/PreferencesDialogExt#add().(&keyboard_page); |
| 67 | |
| 68 | window.presentrust-analyzer cargo libadwaita 0.9.1 auto/dialog/AdwDialogExt#present().(parent_window); |
| 69 | } |
| 70 | |
| 71 | fn create_game_grouprust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_game_group().( |
| 72 | game_configs: &GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#, |
| 73 | properties: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#, |
| 74 | ) -> adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesGrouprust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroup# { |
| 75 | let group = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesGrouprust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroup#::newrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/impl#[PreferencesGroup]new().(); |
| 76 | |
| 77 | let typemenu = create_game_config_pickerrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_game_config_picker().(game_configs, &properties.selected_configrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]selected_config().()); |
| 78 | typemenu.connect_selected_item_notifyrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRowExt#connect_selected_item_notify().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 79 | #[weak] |
| 80 | properties, |
| 81 | move |cr| { |
| 82 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(selection) = cr |
| 83 | .selected_itemrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRowExt#selected_item().() |
| 84 | .and_downcastrust-analyzer cargo glib 0.22.3 object/impl#[`Option<I>`][CastNone]and_downcast().::<glibrust-analyzer cargo glib 0.22.3 crate/::BoxedAnyObjectrust-analyzer cargo glib 0.22.3 boxed_any_object/BoxedAnyObject#>() |
| 85 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|b| b.borrowrust-analyzer cargo glib 0.22.3 boxed_any_object/impl#[BoxedAnyObject]borrow().::<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<GameConfigrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#>>().clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().()) |
| 86 | { |
| 87 | properties.set_selected_configrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]set_selected_config().(selection.namerust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#name.); |
| 88 | } |
| 89 | } |
| 90 | )); |
| 91 | group.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroupExt#add().(&typemenu); |
| 92 | |
| 93 | let safe_chkbox = adwrust-analyzer cargo libadwaita 0.9.1 crate/::SwitchRowrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/SwitchRow#::builderrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]builder().() |
| 94 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("_Use safe moves")) |
| 95 | .use_underlinerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]use_underline().(true) |
| 96 | .subtitlerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]subtitle().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().( |
| 97 | "Prevent accidental moves that result in getting killed.", |
| 98 | )) |
| 99 | .activerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]active().(properties.safe_movesrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]safe_moves().()) |
| 100 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]build().(); |
| 101 | group.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroupExt#add().(&safe_chkbox); |
| 102 | |
| 103 | let super_safe_chkbox = adwrust-analyzer cargo libadwaita 0.9.1 crate/::SwitchRowrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/SwitchRow#::builderrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]builder().() |
| 104 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("U_se super safe moves")) |
| 105 | .use_underlinerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]use_underline().(true) |
| 106 | .subtitlerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]subtitle().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("Prevents all moves that result in getting killed.")) |
| 107 | .activerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]active().(properties.super_safe_movesrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]super_safe_moves().()) |
| 108 | .sensitiverust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]sensitive().(properties.safe_movesrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]safe_moves().()) |
| 109 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]build().(); |
| 110 | group.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroupExt#add().(&super_safe_chkbox); |
| 111 | |
| 112 | super_safe_chkbox.connect_active_notifyrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]connect_active_notify().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 113 | #[weak] |
| 114 | properties, |
| 115 | move |cb| { |
| 116 | properties.set_super_safe_movesrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]set_super_safe_moves().(cb.is_activerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]is_active().()); |
| 117 | } |
| 118 | )); |
| 119 | safe_chkbox.connect_active_notifyrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]connect_active_notify().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 120 | #[weak] |
| 121 | properties, |
| 122 | move |cb| { |
| 123 | properties.set_safe_movesrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]set_safe_moves().(cb.is_activerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]is_active().()); |
| 124 | super_safe_chkbox.set_sensitiverust-analyzer cargo gtk4 0.11.1 auto/widget/WidgetExt#set_sensitive().(properties.safe_movesrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]safe_moves().()); |
| 125 | } |
| 126 | )); |
| 127 | |
| 128 | group |
| 129 | } |
| 130 | |
| 131 | fn create_sound_grouprust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_sound_group().(settings: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#) -> adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesGrouprust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroup# { |
| 132 | let group = adwrust-analyzer cargo libadwaita 0.9.1 crate/::PreferencesGrouprust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroup#::newrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/impl#[PreferencesGroup]new().(); |
| 133 | |
| 134 | let sound_chkbox = adwrust-analyzer cargo libadwaita 0.9.1 crate/::SwitchRowrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/SwitchRow#::builderrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]builder().() |
| 135 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("_Enable sounds")) |
| 136 | .use_underlinerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]use_underline().(true) |
| 137 | .subtitlerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]subtitle().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().( |
| 138 | "Play sounds for events like winning a level and dying.", |
| 139 | )) |
| 140 | .activerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]active().(settings.soundrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]sound().()) |
| 141 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRowBuilder]build().(); |
| 142 | sound_chkbox.connect_active_notifyrust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]connect_active_notify().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 143 | #[weak] |
| 144 | settings, |
| 145 | move |cb| { |
| 146 | settings.set_soundrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]set_sound().(cb.is_activerust-analyzer cargo libadwaita 0.9.1 auto/switch_row/impl#[SwitchRow]is_active().()); |
| 147 | } |
| 148 | )); |
| 149 | group.addrust-analyzer cargo libadwaita 0.9.1 auto/preferences_group/PreferencesGroupExt#add().(&sound_chkbox); |
| 150 | |
| 151 | group |
| 152 | } |
| 153 | |
| 154 | fn create_game_config_pickerrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_game_config_picker().(game_configs: &GameConfigsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#, current_config: &str) -> adwrust-analyzer cargo libadwaita 0.9.1 crate/::ComboRowrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRow# { |
| 155 | let model = giorust-analyzer cargo gio 0.22.2 crate/::ListStorerust-analyzer cargo gio 0.22.2 auto/list_store/ListStore#::newrust-analyzer cargo gio 0.22.2 list_store/impl#[ListStore]new().::<glibrust-analyzer cargo glib 0.22.3 crate/::BoxedAnyObjectrust-analyzer cargo glib 0.22.3 boxed_any_object/BoxedAnyObject#>(); |
| 156 | let mut active_index = 0; |
| 157 | for (i, config) in game_configs.game_configsrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfigs#game_configs..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 158 | model.appendrust-analyzer cargo gio 0.22.2 auto/list_store/impl#[ListStore]append().(&glibrust-analyzer cargo glib 0.22.3 crate/::BoxedAnyObjectrust-analyzer cargo glib 0.22.3 boxed_any_object/BoxedAnyObject#::newrust-analyzer cargo glib 0.22.3 boxed_any_object/impl#[BoxedAnyObject]new().(config.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().())); |
| 159 | if config.namerust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#name. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().current_config { |
| 160 | active_index = i as u32; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | adwrust-analyzer cargo libadwaita 0.9.1 crate/::ComboRowrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRow#::builderrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRow]builder().() |
| 165 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("Game Type")) |
| 166 | .modelrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]model().(&model) |
| 167 | .expressionrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]expression().(gtkrust-analyzer cargo gtk4 0.11.1 crate/::ClosureExpressionrust-analyzer cargo gtk4 0.11.1 auto/closure_expression/ClosureExpression#::newrust-analyzer cargo gtk4 0.11.1 closure_expression/impl#[ClosureExpression]new().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>( |
| 168 | &[] as &[gtkrust-analyzer cargo gtk4 0.11.1 crate/::Expressionrust-analyzer cargo gtk4 0.11.1 auto/expression/Expression#], |
| 169 | glibrust-analyzer cargo glib 0.22.3 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(|item: &glibrust-analyzer cargo glib 0.22.3 crate/::Objectrust-analyzer cargo glib 0.22.3 object/Object#| { |
| 170 | item.downcast_refrust-analyzer cargo glib 0.22.3 object/Cast#downcast_ref().::<glibrust-analyzer cargo glib 0.22.3 crate/::BoxedAnyObjectrust-analyzer cargo glib 0.22.3 boxed_any_object/BoxedAnyObject#>() |
| 171 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|b| b.borrowrust-analyzer cargo glib 0.22.3 boxed_any_object/impl#[BoxedAnyObject]borrow().::<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<GameConfigrust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#>>().display_namerust-analyzer cargo gnome-robots 50.0.0 game_config/GameConfig#display_name..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().()) |
| 172 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 173 | }), |
| 174 | )) |
| 175 | .selectedrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]selected().(active_index) |
| 176 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]build().() |
| 177 | } |
| 178 | |
| 179 | fn create_theme_pickerrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_theme_picker().(themes: &giorust-analyzer cargo gio 0.22.2 crate/::ListModelrust-analyzer cargo gio 0.22.2 auto/list_model/ListModel#, settings: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#) -> adwrust-analyzer cargo libadwaita 0.9.1 crate/::ComboRowrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRow# { |
| 180 | let index = themesrust-analyzer cargo gnome-robots 50.0.0 themes/::find_by_namerust-analyzer cargo gnome-robots 50.0.0 themes/find_by_name().(themes, &settings.themerust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]theme().()) |
| 181 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|r| r.0) |
| 182 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 183 | |
| 184 | let theme_picker = adwrust-analyzer cargo libadwaita 0.9.1 crate/::ComboRowrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRow#::builderrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRow]builder().() |
| 185 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("_Image theme:")) |
| 186 | .use_underlinerust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]use_underline().(true) |
| 187 | .modelrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]model().(themes) |
| 188 | .selectedrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]selected().(index) |
| 189 | .expressionrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]expression().(gtkrust-analyzer cargo gtk4 0.11.1 crate/::PropertyExpressionrust-analyzer cargo gtk4 0.11.1 auto/property_expression/PropertyExpression#::newrust-analyzer cargo gtk4 0.11.1 auto/property_expression/impl#[PropertyExpression]new().( |
| 190 | Themerust-analyzer cargo gnome-robots 50.0.0 theme/Theme#::static_typerust-analyzer cargo gnome-robots 50.0.0 theme/impl#[Theme][StaticType]static_type().(), |
| 191 | gtkrust-analyzer cargo gtk4 0.11.1 crate/::Expressionrust-analyzer cargo gtk4 0.11.1 auto/expression/Expression#::NONErust-analyzer cargo gtk4 0.11.1 auto/expression/impl#[Expression]NONE., |
| 192 | "name", |
| 193 | )) |
| 194 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/impl#[ComboRowBuilder]build().(); |
| 195 | |
| 196 | theme_picker.connect_selected_item_notifyrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRowExt#connect_selected_item_notify().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 197 | #[weak] |
| 198 | settings, |
| 199 | move |tp| { |
| 200 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(theme) = tp.selected_itemrust-analyzer cargo libadwaita 0.9.1 auto/combo_row/ComboRowExt#selected_item().().and_downcastrust-analyzer cargo glib 0.22.3 object/impl#[`Option<I>`][CastNone]and_downcast().::<Themerust-analyzer cargo gnome-robots 50.0.0 theme/Theme#>() { |
| 201 | settings.set_themerust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]set_theme().(&theme.namerust-analyzer cargo gnome-robots 50.0.0 theme/imp/impl#[`super::Theme`]name().()); |
| 202 | } |
| 203 | } |
| 204 | )); |
| 205 | |
| 206 | theme_picker |
| 207 | } |
| 208 | |
| 209 | fn create_background_pickerrust-analyzer cargo gnome-robots 50.0.0 properties_dialog/create_background_picker().(settings: &giorust-analyzer cargo gio 0.22.2 crate/::Settingsrust-analyzer cargo gio 0.22.2 auto/settings/Settings#) -> adwrust-analyzer cargo libadwaita 0.9.1 crate/::ActionRowrust-analyzer cargo libadwaita 0.9.1 auto/action_row/ActionRow# { |
| 210 | let color_dialog = gtkrust-analyzer cargo gtk4 0.11.1 crate/::ColorDialogrust-analyzer cargo gtk4 0.11.1 auto/color_dialog/ColorDialog#::newrust-analyzer cargo gtk4 0.11.1 auto/color_dialog/impl#[ColorDialog]new().(); |
| 211 | |
| 212 | let button = gtkrust-analyzer cargo gtk4 0.11.1 crate/::ColorDialogButtonrust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/ColorDialogButton#::builderrust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/impl#[ColorDialogButton]builder().() |
| 213 | .dialogrust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/impl#[ColorDialogButtonBuilder]dialog().(&color_dialog) |
| 214 | .rgbarust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/impl#[ColorDialogButtonBuilder]rgba().(&settings.bgcolourrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]bgcolour().()) |
| 215 | .buildrust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/impl#[ColorDialogButtonBuilder]build().(); |
| 216 | button.connect_rgba_notifyrust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/impl#[ColorDialogButton]connect_rgba_notify().(glibrust-analyzer cargo glib 0.22.3 crate/::clonerust-analyzer cargo glib-macros 0.22.2 clone!!( |
| 217 | #[weak] |
| 218 | settings, |
| 219 | move |b| { |
| 220 | settings.set_bgcolourrust-analyzer cargo gnome-robots 50.0.0 properties/impl#[`gio::Settings`][Properties]set_bgcolour().(b.rgbarust-analyzer cargo gtk4 0.11.1 auto/color_dialog_button/impl#[ColorDialogButton]rgba().()); |
| 221 | } |
| 222 | )); |
| 223 | |
| 224 | let color_row = adwrust-analyzer cargo libadwaita 0.9.1 crate/::ActionRowrust-analyzer cargo libadwaita 0.9.1 auto/action_row/ActionRow#::builderrust-analyzer cargo libadwaita 0.9.1 auto/action_row/impl#[ActionRow]builder().() |
| 225 | .titlerust-analyzer cargo libadwaita 0.9.1 auto/action_row/impl#[ActionRowBuilder]title().(gettextrust-analyzer cargo gettext-rs 0.7.7 gettext().("_Background color:")) |
| 226 | .use_underlinerust-analyzer cargo libadwaita 0.9.1 auto/action_row/impl#[ActionRowBuilder]use_underline().(true) |
| 227 | .buildrust-analyzer cargo libadwaita 0.9.1 auto/action_row/impl#[ActionRowBuilder]build().(); |
| 228 | color_row.add_suffixrust-analyzer cargo libadwaita 0.9.1 auto/action_row/ActionRowExt#add_suffix().(&button); |
| 229 | |
| 230 | color_row |
| 231 | } |