using Gtk 4.0; using Adw 1; template $BzInstallControls: Box { hexpand: bind $invert_boolean(template.wide) as ; Stack stack { visible: bind $is_not_empty_page(stack.visible-child-name) as ; transition-type: crossfade; visible-child-name: bind try { $get_visible_page(template.entry-group as <$BzEntryGroup>.installable, template.entry-group as <$BzEntryGroup>.removable, template.state as <$BzStateInfo>.available-updates, template.tracker as <$BzTransactionEntryTracker>.active as ) as , $get_visible_page(template.entry-group as <$BzEntryGroup>.installable, template.entry-group as <$BzEntryGroup>.removable, template.state as <$BzStateInfo>.available-updates, false ) as }; hexpand: bind $invert_boolean(template.wide) as ; valign: center; StackPage install { name: "install"; child: $BgeWdgtRenderer animated_button { margin-top: 3; margin-bottom: 3; resource: "/io/github/kolunmi/Bazaar/bz-install-controls.wdgt"; reference: bind template.tracker as <$BzTransactionEntryTracker>; state: bind try { $get_install_btn_state( template.tracker as <$BzTransactionEntryTracker>.status as <$BzTransactionEntryStatus>, template.tracker as <$BzTransactionEntryTracker>.active as , template.tracker as <$BzTransactionEntryTracker>.pending as , template.tracker as <$BzTransactionEntryTracker>.progress as ) as , $install_btn_state_fallback() as }; notify::state => $on_tracker_state_changed() swapped; hexpand: bind $invert_boolean(template.wide) as ; halign: bind $choose_int(template.wide, 2, 0) as ; }; } StackPage open { name: "open"; child: Box { spacing: bind $choose_int(template.wide, 10, 8) as ; homogeneous: bind $invert_boolean(template.wide) as ; halign: bind $choose_int(template.wide, 2, 0) as ; valign: center; margin-top: 3; margin-bottom: 3; Button open_button { styles [ "pill", ] visible: bind $invert_boolean($is_blocked(template.state as <$BzStateInfo>.parental-blocked-ids, template.entry-group as <$BzEntryGroup>) as ) as ; hexpand: bind $invert_boolean(template.wide) as ; label: _("_Open"); use-underline: true; sensitive: bind $invert_boolean($is_zero(template.entry-group as <$BzEntryGroup>.removable-and-available) as ) as ; clicked => $run_cb(template); } Button { styles [ "destructive-action", "circular", ] width-request: bind $choose_int(template.wide, 45, -1) as ; hexpand: bind $invert_boolean(template.wide) as ; tooltip-text: _("Uninstall Application"); sensitive: bind $invert_boolean($is_zero(template.entry-group as <$BzEntryGroup>.removable-and-available) as ) as ; clicked => $remove_cb(template); child: Box { halign: center; hexpand: true; Label { visible: bind $invert_boolean(template.wide) as ; label: _("_Remove"); use-underline: true; } Image { visible: bind template.wide as ; icon-name: "user-trash-symbolic"; } }; } }; } StackPage update { name: "update"; child: Box { spacing: bind $choose_int(template.wide, 10, 8) as ; homogeneous: bind $invert_boolean(template.wide) as ; halign: bind $choose_int(template.wide, 2, 0) as ; valign: center; margin-top: 3; margin-bottom: 3; Button update_button { styles [ "pill", "suggested-action" ] hexpand: bind $invert_boolean(template.wide) as ; label: _("Update"); clicked => $update_cb(template); } Button { styles [ "destructive-action", "circular", ] width-request: bind $choose_int(template.wide, 45, -1) as ; hexpand: bind $invert_boolean(template.wide) as ; tooltip-text: _("Uninstall Application"); sensitive: bind $invert_boolean($is_zero(template.entry-group as <$BzEntryGroup>.removable-and-available) as ) as ; clicked => $remove_cb(template); child: Box { halign: center; hexpand: true; Label { visible: bind $invert_boolean(template.wide) as ; label: _("Remove"); } Image { visible: bind template.wide as ; icon-name: "user-trash-symbolic"; } }; } }; } StackPage empty { name: "empty"; child: Adw.Bin {}; } } }