Skip to content

Commit

Permalink
Merge pull request #71 from yast/huha-fixed-examples
Browse files Browse the repository at this point in the history
Fixed PackageSelector examples to actually load packages
  • Loading branch information
shundhammer authored Nov 18, 2024
2 parents 9d13842 + 8d43477 commit a40f759
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 276 deletions.
37 changes: 0 additions & 37 deletions examples/PackageSelector-10.1-stable.rb

This file was deleted.

30 changes: 0 additions & 30 deletions examples/PackageSelector-10.2.rb

This file was deleted.

26 changes: 13 additions & 13 deletions examples/PackageSelector-YOU.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# encoding: utf-8

# YOU mode
#
# PackageSelector in YOU (YaST Online Update) mode example
#
# This will load the configured repos and their content.
# No root permissions are needed.
#
module Yast
class PackageSelectorYOUClient < Client
def main
Yast.import "UI"
Yast.import "Pkg"
Pkg.SourceCreate(
"http://armstrong.suse.de/download/Code/10/update/i386.ro/",
"/"
)

if true
Pkg.TargetInit(
"/", # installed system
false
) # don't create a new RPM database
end
Pkg.TargetInitialize("/")
Pkg.TargetLoad
Pkg.SourceRestore
Pkg.SourceLoad

UI.OpenDialog(
Opt(:defaultsize),
PackageSelector(Id(:selector), Opt(:testMode, :youMode))
)
# `opt(`testMode ) ) );

UI.RunPkgSelection(Id(:selector))
UI.CloseDialog

Builtins.y2milestone("Input: %1", @input)

nil
end
end
Expand Down
8 changes: 7 additions & 1 deletion examples/PackageSelector-empty.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# encoding: utf-8

#
# Empty PackageSelector example
#
# This will NOT load the configured repos and their content,
# it just shows the bare widget.
#
module Yast
class PackageSelectorEmptyClient < Client
def main
Yast.import "UI"

UI.OpenDialog(
Opt(:defaultsize),
PackageSelector(Id(:selector), Opt(:testMode))
Expand Down
34 changes: 0 additions & 34 deletions examples/PackageSelector-multi-src.rb

This file was deleted.

34 changes: 0 additions & 34 deletions examples/PackageSelector-stable.rb

This file was deleted.

17 changes: 12 additions & 5 deletions examples/PackageSelector-update.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# encoding: utf-8

#
# PackageSelector in system update mode example
#
# This will load the configured repos and their content.
# No root permissions are needed.
#
module Yast
class PackageSelectorUpdateClient < Client
def main
Yast.import "UI"
Yast.import "Pkg"
Pkg.TargetInit(
"/", # installed system
false
) # don't create a new RPM database

Pkg.TargetInitialize("/")
Pkg.TargetLoad
Pkg.SourceRestore
Pkg.SourceLoad

UI.OpenDialog(
Opt(:defaultsize),
PackageSelector(Id(:selector), Opt(:testMode, :updateMode))
Expand Down
26 changes: 12 additions & 14 deletions examples/PackageSelector.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
# encoding: utf-8

# Package Selector example
#
# PackageSelector in standard mode example
#
# This will load the configured repos and their content.
# No root permissions are needed.
#
module Yast
class PackageSelectorClient < Client
def main
Yast.import "UI"
Yast.import "Pkg"
# Pkg::SourceCreate( "http://dist.suse.de/install/SLP/SUSE-10.1-Beta7/i386/CD1/", "" );
# Pkg::SourceCreate( "http://dist.suse.de/install/SLP/SUSE-10.0-RC4/i386/CD1/", "" );
# Pkg::SourceCreate( "file:/srv/10.1-i386/CD1/", "" );
Pkg.SourceCreate("file:/srv/10.1-i386/DVD1/", "")
# Pkg::SourceCreate( "file:/srv/sles-10-i386/CD1/", "" );

if true
Pkg.TargetInit(
"/", # installed system
false
) # don't create a new RPM database
end
Pkg.TargetInitialize("/")
Pkg.TargetLoad
Pkg.SourceRestore
Pkg.SourceLoad

UI.OpenDialog(
Opt(:defaultsize),
PackageSelector(Id(:selector), "/dev/fd0")
PackageSelector(Id(:selector))
)

@input = UI.RunPkgSelection(Id(:selector))
UI.CloseDialog

Expand Down
3 changes: 2 additions & 1 deletion examples/PatternSelector-empty.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# encoding: utf-8

# Simple example for PatternSelector
# Simple example for empty PatternSelector
# This will not load any content.
module Yast
class PatternSelectorEmptyClient < Client
def main
Expand Down
37 changes: 22 additions & 15 deletions examples/PatternSelector-solo.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
# encoding: utf-8

#
# Simple example for PatternSelector
#
# This will load the configured repos and their content.
# No root permissions are needed.
#
module Yast
class PatternSelectorSoloClient < Client
def main
Yast.import "Pkg"
Yast.import "UI"
if !UI.HasSpecialWidget(:PatternSelector)
UI.OpenDialog(
VBox(
Label("Error: This UI doesn't support the PatternSelector widget!"),
PushButton(Opt(:default), "&OK")
)
)
UI.UserInput
UI.CloseDialog

if !UI.HasSpecialWidget(:PatternSelector)
not_supported_warning
return
end


Pkg.TargetInit(
"/", # installed system
false
) # don't create a new RPM database
Pkg.TargetInitialize("/")
Pkg.TargetLoad
Pkg.SourceRestore
Pkg.SourceLoad

UI.OpenDialog(Opt(:defaultsize), PatternSelector(Id(:selector)))
@input = UI.RunPkgSelection(Id(:selector))
Expand All @@ -33,6 +29,17 @@ def main

nil
end

def not_supported_warning
UI.OpenDialog(
VBox(
Label("Error: This UI doesn't support the PatternSelector widget!"),
PushButton(Opt(:default), "&OK")
)
)
UI.UserInput
UI.CloseDialog
end
end
end

Expand Down
Loading

0 comments on commit a40f759

Please sign in to comment.