Skip to content

Commit

Permalink
Merge pull request #330 from cwh42/removepopupicons
Browse files Browse the repository at this point in the history
Removed more icons from other dialogs (bnc#875201)
  • Loading branch information
cwh42 committed Jan 27, 2015
2 parents d8b5c22 + ce3ba38 commit f96373d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 164 deletions.
8 changes: 1 addition & 7 deletions library/packages/src/modules/PackageCallbacks.rb
Expand Up @@ -54,7 +54,6 @@ def main
Yast.import "CommandLine"
Yast.import "String"
Yast.import "Report"
Yast.import "Icon"
Yast.import "Wizard"
Yast.import "Progress"
Yast.import "FileUtils"
Expand Down Expand Up @@ -292,12 +291,7 @@ def LayoutPopup(message, button_box, vertical_size, info_on)
dialog_layout = VBox(
HSpacing(50), # enforce width
VSpacing(0.1),
HBox(
# maybe more icon types could be used
# "info, "warning", "error"
Icon.Image("warning", "margin_right" => 2),
Left(Label(message))
),
Left(Label(message)),
VSpacing(0.1),
HBox(
HSpacing(0.6),
Expand Down
13 changes: 6 additions & 7 deletions library/wizard/src/modules/Confirm.rb
Expand Up @@ -41,7 +41,6 @@ def main

textdomain "base"

Yast.import "Icon"
Yast.import "Label"
Yast.import "Mode"
Yast.import "Popup"
Expand All @@ -55,20 +54,20 @@ def main

# Confirm hardware detection (only in manual installation)
# @param [String] class hardware class (network cards)
# @param [String] icon_name name of the icon. If nil, generic hardware icon will be used
# @param [String] icon_name deprecated
# @return true on continue
def Detection(class_, icon_name)
if !icon_name.nil?
Builtins.y2warning(-1, "Parameter 'icon_name' is deprecated.")
end

return true if Linuxrc.manual != true

# L3: no interaction in AY, just re-probe (bnc#568653)
return true if Mode.autoinst == true || Mode.autoupgrade == true

return true if Arch.s390

icon_name = "yast-hardware" if icon_name.nil?

icon = Icon.Image(icon_name, {})

result = Ops.get(@detection_cache, class_)
if !result.nil?
Builtins.y2milestone(
Expand Down Expand Up @@ -107,7 +106,7 @@ def Detection(class_, icon_name)
HVCenter(
Label(_("YaST will detect the following hardware:"))
),
HVCenter(HBox(icon, HSpacing(0.5), Heading(class_))),
HVCenter(Heading(class_)),
VSpacing(0.5)
)
)
Expand Down
155 changes: 6 additions & 149 deletions library/wizard/src/modules/Progress.rb
Expand Up @@ -139,14 +139,6 @@ def main
# stack with the running progresses
# the top of the stack is the end of the list
@progress_stack = []

@global_invisible_icons_definition = []
@global_visible_icons_definition = []

@use_icons_in_progress = false
@has_icon_progress_bar = false

@last_highlighted_icon = -1
end

def IsRunning
Expand Down Expand Up @@ -326,78 +318,6 @@ def MarkId(i)
Id(Builtins.sformat("mark_stage_%1", i))
end

def IconId(i)
Builtins.sformat("mark_icon_%1", i)
end

def FallbackIconInvisible
Ops.add(Directory.icondir, "32x32/apps/yast-sudo.png")
end

def FallbackIconVisible
Ops.add(Directory.icondir, "32x32/apps/yast-scripts.png")
end

def NormalizeIconPath(one_icon, visible)
if one_icon.nil? || one_icon == ""
one_icon = visible ? FallbackIconVisible() : FallbackIconInvisible()
end

if !Builtins.regexpmatch(one_icon, ".[pP][nN][gG]$") &&
!Builtins.regexpmatch(one_icon, ".[jJ][pP][gG]$")
one_icon = Ops.add(one_icon, ".png")
end

# relative path (to Directory::icondir)
if Builtins.regexpmatch(one_icon, "/") &&
!Builtins.regexpmatch(one_icon, "^/")
one_icon = Ops.add(Directory.icondir, one_icon)
# hopefully you know what you do
# just image name
elsif !Builtins.regexpmatch(one_icon, "/")
one_icon = Ops.add(Ops.add(Directory.icondir, "32x32/apps/"), one_icon)
end

if !FileUtils.Exists(one_icon)
Builtins.y2error("Image %1 doesn't exist, using fallback", one_icon)
one_icon = visible ? FallbackIconVisible() : FallbackIconInvisible()
end

one_icon
end

def GenerateIdleIcons(number_of_stages)
display_info = UI.GetDisplayInfo
can_display_images = Ops.get_boolean(
display_info,
"HasImageSupport",
false
) == true

return Empty() if !can_display_images

ret = HBox(HSpacing(2))
i = -1

number_of_stages = Ops.subtract(number_of_stages, 1)

while Ops.less_than(i, number_of_stages)
i = Ops.add(i, 1)

one_icon = NormalizeIconPath(
Ops.get(@global_visible_icons_definition, i),
false
)
ret = Builtins.add(
ret,
Image(Id(IconId(i)), Opt(:disabled), one_icon, "[X]")
)
ret = Builtins.add(ret, HSpacing(2))
end

deep_copy(ret)
end

# New complex progress bar with stages.
# @param [String] window_title title of the window
# @param [String] progress_title title of the progress bar. Pass at least " "
Expand Down Expand Up @@ -503,21 +423,10 @@ def New(window_title, progress_title, length, stg, tits, help_text)
bar = Builtins.add(bar, Left(HBox(HSquash(items))))

if 0 != @steps
progress_icons = Empty()
if @use_icons_in_progress == true
Builtins.y2milestone("Using icons in progress")
progress_icons = GenerateIdleIcons(length)
@has_icon_progress_bar = true
else
Builtins.y2milestone("No progress icons defined")
@has_icon_progress_bar = false
end

bar = Builtins.add(
bar,
VBox(
VStretch(),
progress_icons,
ReplacePoint(Id(:subprogress_replace_point), Empty()),
ReplacePoint(
Id(:progress_replace_point),
Expand Down Expand Up @@ -666,45 +575,20 @@ def SubprogressTitle(title)
nil
end

# Function adds icon-support to progress dialog.
# Parameters are the same as for Progress::New() function with one parameter added.
#
# @deprecated Use {#New} instead.
# Obsolete function adding icon-support to progress dialog.
# We don't use icons in popups any more.
# @param [String] window_title
# @param [String] progress_title
# @param [Fixnum] length
# @param [Array<String>] stg
# @param [Array] tits
# @param [String] help_textmap
#
# @param [Array<Array<String>>] icons_definition
#
#
# **Structure:**
#
# icons_definition = $[
# [ // first 'visible'
# "/path/to/icon-highlighted.png"
# "/path/to/another-icon-highlighted.png",
# ]
# [ // then 'invisible'
# "/path/to/icon-gryscale.png",
# nil, // fallback icon will be used
# ],
# ]
#
# @see Function Progress::New()
def NewProgressIcons(window_title, progress_title, length, stg, tits, help_textmap, icons_definition)
stg = deep_copy(stg)
tits = deep_copy(tits)
icons_definition = deep_copy(icons_definition)
@global_visible_icons_definition = Ops.get(icons_definition, 0, [])
@global_invisible_icons_definition = Ops.get(icons_definition, 1, [])

@use_icons_in_progress = true
def NewProgressIcons(window_title, progress_title, length, stg, tits, help_textmap, _icons_definition)
Builtins.y2warning(-1, "#{__method__} is deprecated. Use Progess::New instead!")
New(window_title, progress_title, length, stg, tits, help_textmap)
@use_icons_in_progress = false

nil
end

# Create simple progress bar with no stages, only with progress bar.
Expand All @@ -718,30 +602,6 @@ def Simple(window_title, progress_title, length, help_text)
nil
end

# Highlights a progress icon (changes the dimmed one
# into a normal one).
#
# @param integer current step ID
def HighlightProgressIcon(step_id)
if @has_icon_progress_bar
@last_highlighted_icon = -1 if @last_highlighted_icon.nil?

# some steps might have been skipped, change all (not changed yet)
# icons one by one
while Ops.less_than(@last_highlighted_icon, step_id)
@last_highlighted_icon = Ops.add(@last_highlighted_icon, 1)

icon_id = IconId(@last_highlighted_icon)

if UI.WidgetExists(Id(icon_id)) == true
UI.ChangeWidget(Id(icon_id), :Enabled, true)
end
end
end

nil
end

# Uses current_step
def UpdateProgressBar
if Ops.greater_than(@current_step, @steps)
Expand All @@ -756,10 +616,7 @@ def UpdateProgressBar

progress_value = @current_step

# do not change icons in a nested progress
if StackSize() == 0
HighlightProgressIcon(@current_step)
else
if StackSize() != 0
# recalculate the progress bar value according to the parent progress
prev_state = TopState()
prev_step = Ops.get_integer(prev_state, "current_step", 0)
Expand Down
6 changes: 6 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jan 27 11:51:54 UTC 2015 - cwh@suse.com

- Removed more icons from other dialogs (bnc#875201)
- 3.1.119

-------------------------------------------------------------------
Thu Jan 22 13:21:45 UTC 2015 - jsrain@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 3.1.118
Version: 3.1.119
Release: 0
URL: https://github.com/yast/yast-yast2

Expand Down

0 comments on commit f96373d

Please sign in to comment.