Piggy 0.4.2.4 → 0.4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +15 -0
- data/INSTALL.txt +9 -4
- data/README.txt +8 -6
- data/bin/directory_diff +1 -1
- data/bin/ftp_browser +1 -1
- data/bin/piggy +1 -1
- data/lib/directory_diff.rb +8 -6
- data/lib/ftp_browser.rb +8 -6
- data/lib/icons/connect.ico +0 -0
- data/lib/icons/hide_details.ico +0 -0
- data/lib/icons/show_details.ico +0 -0
- data/lib/piggy-core/alive_check.rb +4 -4
- data/lib/piggy-core/debug.rb +4 -4
- data/lib/piggy-core/environment.rb +24 -26
- data/lib/piggy-core/exifr_adapter.rb +11 -11
- data/lib/piggy-core/file_info.rb +61 -61
- data/lib/piggy-core/ftp_adapter.rb +24 -24
- data/lib/piggy-core/htmlgen.rb +41 -45
- data/lib/piggy-core/nconvert_thumbsgen.rb +22 -22
- data/lib/piggy-core/options.rb +25 -19
- data/lib/piggy-core/options_persistence.rb +8 -8
- data/lib/piggy-core/progress.rb +7 -7
- data/lib/piggy-core/rmagick_thumbnail_page_generator.rb +14 -14
- data/lib/piggy-core/thumbnail_generator.rb +26 -26
- data/lib/piggy-core/thumbnail_page_generator.rb +234 -230
- data/lib/piggy-core/upload_info.rb +22 -22
- data/lib/piggy-core/version.rb +7 -7
- data/lib/piggy-core/winshell.rb +136 -80
- data/lib/piggy-gui/dir_chooser.rb +14 -14
- data/lib/piggy-gui/directory_diff_widget.rb +177 -160
- data/lib/piggy-gui/filtered_file_list.rb +87 -87
- data/lib/piggy-gui/fox_thumbsgen.rb +4 -4
- data/lib/piggy-gui/ftp_browser_widget.rb +211 -155
- data/lib/piggy-gui/fullscreen.rb +4 -4
- data/lib/piggy-gui/html_generation_dialog.rb +42 -115
- data/lib/piggy-gui/html_options_widget.rb +97 -0
- data/lib/piggy-gui/image_processor.rb +58 -58
- data/lib/piggy-gui/modal_dialog.rb +11 -5
- data/lib/piggy-gui/multiimagecanvas.rb +59 -59
- data/lib/piggy-gui/options_dialog.rb +170 -48
- data/lib/piggy-gui/piggy_image_browser.rb +382 -340
- data/lib/piggy-gui/pipe_log.rb +17 -17
- data/lib/piggy-gui/progress_with_dialog.rb +8 -8
- data/lib/piggy-gui/require-fox.rb +23 -8
- data/lib/piggy.rb +7 -5
- data/lib/templates/styles/basic/style.css +16 -14
- data/lib/templates/styles/black/style.css +28 -29
- data/lib/templates/styles/roundedbox/style.css +28 -31
- data/lib/templates/styles/shadow/style.css +26 -26
- data/lib/templates/styles/shadow_D9F5F3/style.css +1 -1
- data/lib/templates/styles/shadow_black/lo.jpg +0 -0
- data/lib/templates/styles/shadow_black/lu.jpg +0 -0
- data/lib/templates/styles/shadow_black/ro.jpg +0 -0
- data/lib/templates/styles/shadow_black/ru.jpg +0 -0
- data/lib/templates/styles/shadow_black/style.css +78 -0
- data/lib/templates/styles/shadow_bowers/style.css +48 -51
- data/lib/templates/styles/sylvester/sh.png +0 -0
- data/lib/templates/styles/sylvester/style.css +74 -0
- data/lib/templates/styles/sylvester/wunderkerze.jpg +0 -0
- data/test/file_info_test.rb +29 -29
- metadata +52 -38
@@ -9,172 +9,99 @@ require 'piggy-core/winshell'
|
|
9
9
|
require 'piggy-gui/require-fox'
|
10
10
|
require 'piggy-gui/modal_dialog'
|
11
11
|
require 'piggy-gui/dir_chooser'
|
12
|
+
require 'piggy-gui/html_options_widget'
|
12
13
|
|
13
14
|
# Dialog for manipulation some of Piggy's html generation parameters.
|
14
15
|
class HtmlGenerationDialog < ModalDialog
|
15
16
|
attr_reader(:options)
|
16
17
|
|
17
18
|
def initialize(owner, options = PiggyOptions.new)
|
18
|
-
title = "
|
19
|
+
title = "Generate HTML image gallery"
|
19
20
|
@options = options
|
20
21
|
@shell = WinShell.instance
|
21
22
|
super(owner, title, DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE)
|
22
|
-
|
23
|
-
initializeLayout
|
24
|
-
setDefaults
|
25
|
-
connectEvents
|
23
|
+
init_gui
|
26
24
|
end
|
27
|
-
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
|
26
|
+
def init_gui
|
27
|
+
frame = FXVerticalFrame.new(self)
|
28
|
+
contents = HtmlOptionsWidget.new(frame, @options, false)
|
29
|
+
labels = Array.new
|
30
|
+
labels.push(FXLabel.new(contents, "Title:"))
|
31
|
+
@titleField = FXTextField.new(contents, 32)
|
32
|
+
@titleField.connect(SEL_COMMAND) { |sender, sel, new_txt|
|
33
|
+
on_title_changed(fox_2_ruby(new_txt)) if (new_txt)
|
35
34
|
}
|
36
|
-
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@titleField = FXTextField.new(@contents, 32)
|
42
|
-
@labels.push(FXLabel.new(@contents, "Subdirectory:"))
|
43
|
-
@subdirField = FXTextField.new(@contents, 32)
|
44
|
-
FXLabel.new(@contents, ""); # TODO empty cell in matrix layout
|
45
|
-
@addZipCheck = FXCheckButton.new(@contents, 'Add zipfile')
|
46
|
-
FXLabel.new(@contents, ""); # TODO empty cell in matrix layout
|
47
|
-
@addSlideshowCheck = FXCheckButton.new(@contents, 'Add slideshow')
|
48
|
-
@labels.push(FXLabel.new(@contents, "Style:"))
|
49
|
-
@styleTextField = newCombobox(@contents, 32,
|
50
|
-
10,
|
51
|
-
nil, 0, COMBOBOX_INSERT_LAST)
|
52
|
-
@styleTextField.setFrameStyle(FRAME_SUNKEN|FRAME_THICK)
|
53
|
-
@styleTextField.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
|
54
|
-
@labels.push(FXLabel.new(@contents, "Image size:"))
|
55
|
-
sizeFrame = FXHorizontalFrame.new(@contents, FRAME_NONE, 0, 0, 0 , 0, 0, 0, 0, 0)
|
56
|
-
@imageWidthField = FXTextField.new(sizeFrame, 4)
|
57
|
-
FXLabel.new(sizeFrame, " x ")
|
58
|
-
@imageHeightField = FXTextField.new(sizeFrame, 4)
|
59
|
-
addOkCancelButtonsTo(@frame)
|
35
|
+
labels.push(FXLabel.new(contents, "Subdirectory:"))
|
36
|
+
@subdirField = FXTextField.new(contents, 32)
|
37
|
+
labels.each { |label| label.setLayoutHints LAYOUT_CENTER_Y }
|
38
|
+
contents.init_gui
|
39
|
+
add_ok_cancel_buttons_to(frame)
|
60
40
|
end
|
61
41
|
|
62
|
-
def
|
63
|
-
|
42
|
+
def on_title_changed(title)
|
43
|
+
title_letters = title.gsub(/\W/, '')
|
44
|
+
return unless title_letters
|
45
|
+
dir_suggestion = title_letters.slice(0..8).downcase
|
46
|
+
@subdirField.setText(ruby_2_fox(dir_suggestion))
|
64
47
|
end
|
65
48
|
|
66
|
-
def
|
67
|
-
|
68
|
-
@styleTextField.clearItems
|
69
|
-
Dir[File.join(styleDir, '*')].entries.reject { |f| f =~ /^\.+$/ }.each do
|
70
|
-
|folder|
|
71
|
-
@styleTextField.appendItem(File.basename(folder))
|
72
|
-
end
|
73
|
-
@styleTextField.setText(@options.style)
|
49
|
+
def get_subdir
|
50
|
+
return fox_2_ruby(@subdirField.getText)
|
74
51
|
end
|
75
52
|
|
76
|
-
def
|
77
|
-
|
78
|
-
@genFrameNo.setCheck(!@options.generateFramePage)
|
79
|
-
@addZipCheck.setCheck(@options.addZip?)
|
80
|
-
@addSlideshowCheck.setCheck(@options.addSlideshow?)
|
81
|
-
@imageWidthField.setText(ruby2Fox(@options.imageWidth.to_s))
|
82
|
-
@imageHeightField.setText(ruby2Fox(@options.imageHeight.to_s))
|
83
|
-
updateStylesList
|
84
|
-
end
|
85
|
-
|
86
|
-
def connectEvents
|
87
|
-
@genFrameYes.connect(SEL_COMMAND) {
|
88
|
-
@genFrameNo.setCheck false
|
89
|
-
@options.generateFramePage = true
|
90
|
-
}
|
91
|
-
@genFrameNo.connect(SEL_COMMAND) {
|
92
|
-
@genFrameYes.setCheck false
|
93
|
-
@options.generateFramePage = false
|
94
|
-
}
|
95
|
-
@addZipCheck.connect(SEL_COMMAND) { |sender, sel, ptr|
|
96
|
-
@options.addZip = ptr
|
97
|
-
}
|
98
|
-
@addSlideshowCheck.connect(SEL_COMMAND) { |sender, sel, ptr|
|
99
|
-
@options.addSlideshow = ptr
|
100
|
-
}
|
101
|
-
@styleTextField.connect(SEL_COMMAND) { |sender, sel, ptr|
|
102
|
-
@options.style = ptr
|
103
|
-
validateStyle
|
104
|
-
}
|
105
|
-
@imageWidthField.connect(SEL_COMMAND) { |sender, sel, ptr|
|
106
|
-
begin
|
107
|
-
@options.imageWidth = fox2Ruby(@imageWidthField.getText).to_i
|
108
|
-
rescue StandardError => ex
|
109
|
-
@imageWidthField.setText(ruby2Fox(@options.imageWidth.to_s))
|
110
|
-
end
|
111
|
-
}
|
112
|
-
@imageHeightField.connect(SEL_COMMAND) { |sender, sel, ptr|
|
113
|
-
begin
|
114
|
-
@options.imageHeight = fox2Ruby(@imageHeightField.getText).to_i
|
115
|
-
rescue StandardError => ex
|
116
|
-
@imageHeightField.setText(ruby2Fox(@options.imageHeight.to_s))
|
117
|
-
end
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
def getSubdir
|
122
|
-
return fox2Ruby(@subdirField.getText)
|
123
|
-
end
|
124
|
-
|
125
|
-
def getTitle
|
126
|
-
return fox2Ruby(@titleField.getText)
|
53
|
+
def get_title
|
54
|
+
return fox_2_ruby(@titleField.getText)
|
127
55
|
end
|
128
56
|
|
129
57
|
def validate
|
130
|
-
|
58
|
+
validate_output_path && validate_subdir && validate_style
|
131
59
|
end
|
132
60
|
|
133
|
-
def
|
61
|
+
def validate_output_path
|
134
62
|
unless File.directory?(@options.localDestinationPath)
|
135
|
-
|
63
|
+
warn_output_path
|
136
64
|
return false
|
137
65
|
end
|
138
66
|
return true;
|
139
67
|
end
|
140
68
|
|
141
|
-
def
|
142
|
-
subdir =
|
69
|
+
def validate_subdir
|
70
|
+
subdir = get_subdir
|
143
71
|
if subdir.empty?
|
144
|
-
|
72
|
+
warn_no_subdir_given
|
145
73
|
return false
|
146
74
|
end
|
147
|
-
|
148
|
-
if(File.directory?
|
149
|
-
|
150
|
-
return false
|
75
|
+
path_to_subdir = File.join(@options.localDestinationPath, subdir)
|
76
|
+
if(File.directory? path_to_subdir)
|
77
|
+
return yes?("Overwrite?", "#{path_to_subdir} allready exists. Overwrite?")
|
151
78
|
end
|
152
79
|
return true
|
153
80
|
end
|
154
81
|
|
155
|
-
def
|
156
|
-
|
157
|
-
unless File.directory?(
|
158
|
-
|
82
|
+
def validate_style
|
83
|
+
style_dir = File.join(PIGGY_PATH, 'templates/styles', @options.style)
|
84
|
+
unless File.directory?(style_dir)
|
85
|
+
warn_style_missing
|
159
86
|
false
|
160
87
|
else
|
161
88
|
true
|
162
89
|
end
|
163
90
|
end
|
164
91
|
|
165
|
-
def
|
92
|
+
def warn_output_path
|
166
93
|
title = "Output path does not exist"
|
167
94
|
msg = "Output path does not exist"
|
168
95
|
warn(title, msg)
|
169
96
|
end
|
170
97
|
|
171
|
-
def
|
98
|
+
def warn_no_subdir_given
|
172
99
|
title = "No subdirectory"
|
173
100
|
msg = "Specify a subdirectory first"
|
174
101
|
warn(title, msg)
|
175
102
|
end
|
176
103
|
|
177
|
-
def
|
104
|
+
def warn_style_missing
|
178
105
|
title = "Style not found"
|
179
106
|
msg = "Style missing: #{@options.style}"
|
180
107
|
warn(title, msg)
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
## $Id: options_dialog.rb 161 2006-12-23 15:41:01Z Sascha $
|
3
|
+
|
4
|
+
require 'piggy-core/options'
|
5
|
+
require 'piggy-gui/require-fox'
|
6
|
+
require 'piggy-gui/dir_chooser'
|
7
|
+
|
8
|
+
class HtmlOptionsWidget < Fox::FXMatrix
|
9
|
+
include Fox
|
10
|
+
include Responder
|
11
|
+
|
12
|
+
def initialize(parent, options, init=true)
|
13
|
+
super(parent, 2, MATRIX_BY_COLUMNS)
|
14
|
+
@options = options
|
15
|
+
init_gui if init
|
16
|
+
end
|
17
|
+
|
18
|
+
def cb_flags
|
19
|
+
ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_label_to(frame, msg)
|
23
|
+
FXLabel.new(frame, msg, :opts => JUSTIFY_LEFT|LAYOUT_CENTER_Y)
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_txt_to(frame, msg)
|
27
|
+
FXLabel.new(frame, msg, :opts => JUSTIFY_LEFT)
|
28
|
+
end
|
29
|
+
|
30
|
+
def init_gui
|
31
|
+
add_label_to(self, "Output directory:")
|
32
|
+
DirChooser.new(self, @options.localDestinationPath) { |v|
|
33
|
+
@options.localDestinationPath = v
|
34
|
+
}
|
35
|
+
add_label_to(self, "Framepage:")
|
36
|
+
gen_frame_radio_buttons = FXMatrix.new(self, 2, MATRIX_BY_COLUMNS)
|
37
|
+
gen_frame_yes = FXRadioButton.new(gen_frame_radio_buttons, "&Yes")
|
38
|
+
gen_frame_no = FXRadioButton.new(gen_frame_radio_buttons, "&No")
|
39
|
+
gen_frame_yes.setCheck(@options.generateFramePage)
|
40
|
+
gen_frame_no.setCheck(!@options.generateFramePage)
|
41
|
+
gen_frame_yes.connect(SEL_COMMAND) {
|
42
|
+
gen_frame_no.setCheck false
|
43
|
+
@options.generateFramePage = true
|
44
|
+
}
|
45
|
+
gen_frame_no.connect(SEL_COMMAND) {
|
46
|
+
gen_frame_yes.setCheck false
|
47
|
+
@options.generateFramePage = false
|
48
|
+
}
|
49
|
+
add_label_to(self, ""); # TODO empty cell in matrix layout
|
50
|
+
add_zip_check = FXCheckButton.new(self, 'Add zipfile')
|
51
|
+
add_zip_check.setCheck(@options.addZip?)
|
52
|
+
add_zip_check.connect(SEL_COMMAND) { |sender, sel, ptr|
|
53
|
+
@options.addZip = ptr
|
54
|
+
}
|
55
|
+
add_label_to(self, ""); # TODO empty cell in matrix layout
|
56
|
+
add_slideshow_check = FXCheckButton.new(self, 'Add slideshow')
|
57
|
+
add_slideshow_check.setCheck(@options.addSlideshow?)
|
58
|
+
add_slideshow_check.connect(SEL_COMMAND) { |sender, sel, ptr|
|
59
|
+
@options.addSlideshow = ptr
|
60
|
+
}
|
61
|
+
add_label_to(self, "Style:")
|
62
|
+
style_text_field = new_combobox(self, 32,
|
63
|
+
10,
|
64
|
+
nil, 0, COMBOBOX_INSERT_LAST)
|
65
|
+
style_text_field.setFrameStyle(FRAME_SUNKEN|FRAME_THICK)
|
66
|
+
style_text_field.setLayoutHints(LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)
|
67
|
+
style_text_field.clearItems
|
68
|
+
get_style_list.each { |style|
|
69
|
+
style_text_field.appendItem(style)
|
70
|
+
}
|
71
|
+
style_text_field.setText(@options.style)
|
72
|
+
style_text_field.connect(SEL_COMMAND) { |sender, sel, ptr|
|
73
|
+
@options.style = ptr
|
74
|
+
}
|
75
|
+
add_label_to(self, "Image size:")
|
76
|
+
size_frame = FXHorizontalFrame.new(self, FRAME_NONE, 0, 0, 0 , 0, 0, 0, 0, 0)
|
77
|
+
image_width_field = FXTextField.new(size_frame, 4)
|
78
|
+
add_label_to(size_frame, " x ")
|
79
|
+
image_height_field = FXTextField.new(size_frame, 4)
|
80
|
+
image_width_field.setText(ruby_2_fox(@options.imageWidth.to_s))
|
81
|
+
image_height_field.setText(ruby_2_fox(@options.imageHeight.to_s))
|
82
|
+
image_width_field.connect(SEL_COMMAND) { |sender, sel, ptr|
|
83
|
+
begin
|
84
|
+
@options.imageWidth = fox_2_ruby(image_width_field.getText).to_i
|
85
|
+
rescue StandardError => ex
|
86
|
+
image_width_field.setText(ruby_2_fox(@options.imageWidth.to_s))
|
87
|
+
end
|
88
|
+
}
|
89
|
+
image_height_field.connect(SEL_COMMAND) { |sender, sel, ptr|
|
90
|
+
begin
|
91
|
+
@options.imageHeight = fox_2_ruby(image_height_field.getText).to_i
|
92
|
+
rescue StandardError => ex
|
93
|
+
image_height_field.setText(ruby_2_fox(@options.imageHeight.to_s))
|
94
|
+
end
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
@@ -11,23 +11,23 @@ class ImageProcessor
|
|
11
11
|
@app = application
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
return
|
14
|
+
def is_supported_image_file? file
|
15
|
+
return get_image_class_for_file(file) != nil
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
img =
|
20
|
-
return
|
18
|
+
def load_icon(file, create = true)
|
19
|
+
img = get_icon_instance_for_file file
|
20
|
+
return basic_load(img, file, create)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
img =
|
25
|
-
return
|
23
|
+
def load_image(file, create = true)
|
24
|
+
img = get_image_instance_for_file file
|
25
|
+
return basic_load(img, file, create)
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def basic_load(img, rubyfile, create)
|
29
29
|
return nil if img == nil
|
30
|
-
file =
|
30
|
+
file = ruby_2_fox(rubyfile)
|
31
31
|
begin
|
32
32
|
FXFileStream.open(file, FXStreamLoad) do
|
33
33
|
|stream|
|
@@ -40,47 +40,47 @@ class ImageProcessor
|
|
40
40
|
return img
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
file =
|
43
|
+
def save_image(img, rubyfile)
|
44
|
+
file = ruby_2_fox(rubyfile)
|
45
45
|
FXFileStream.open(file, FXStreamSave) do
|
46
46
|
|stream|
|
47
47
|
img.savePixels stream
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
51
|
+
def uncreate_image(img)
|
52
52
|
img.destroy
|
53
53
|
img.release
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
imageCache.each { |i|
|
56
|
+
def destroy_all(imageCache)
|
57
|
+
imageCache.each { |i| uncreate_image(i) }
|
58
58
|
imageCache.clear
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
|
61
|
+
def garbage_image(img)
|
62
|
+
uncreate_image(img)
|
63
63
|
GC.start
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
66
|
+
def fit_image(img, maxW, maxH, quality = 1)
|
67
67
|
w = img.getWidth
|
68
68
|
h = img.getHeight
|
69
69
|
ratios = Array.new(2)
|
70
70
|
ratios[0] = maxW.to_f / w.to_f
|
71
71
|
ratios[1] = maxH.to_f / h.to_f
|
72
72
|
ratio = ratios.min
|
73
|
-
|
74
|
-
|
75
|
-
if
|
73
|
+
new_w = (w * ratio).to_i
|
74
|
+
new_h = (h * ratio).to_i
|
75
|
+
if new_w < 10 or new_h < 10
|
76
76
|
return false
|
77
77
|
end
|
78
|
-
img.scale(
|
78
|
+
img.scale(new_w, new_h, quality)
|
79
79
|
return true
|
80
80
|
end
|
81
81
|
|
82
|
-
def
|
83
|
-
|
82
|
+
def rotate_image(img, degree)
|
83
|
+
fox_degree = case degree
|
84
84
|
when 0 then 0
|
85
85
|
when 90 then 270
|
86
86
|
when 180 then 180
|
@@ -88,53 +88,53 @@ class ImageProcessor
|
|
88
88
|
else
|
89
89
|
return error('Illegal degree')
|
90
90
|
end
|
91
|
-
img.rotate(
|
91
|
+
img.rotate(fox_degree)
|
92
92
|
end
|
93
93
|
|
94
94
|
private
|
95
95
|
|
96
|
-
def
|
96
|
+
def has_extension(filename, ext)
|
97
97
|
File.basename(filename.upcase, ext.upcase) !=
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def
|
102
|
-
return FXGIFImage if
|
103
|
-
return FXBMPImage if
|
104
|
-
return FXXPMImage if
|
105
|
-
return FXPNGImage if
|
106
|
-
return FXJPGImage if
|
107
|
-
return FXPCXImage if
|
108
|
-
return FXTIFImage if
|
109
|
-
return FXTGAImage if
|
110
|
-
return FXICOImage if
|
98
|
+
File.basename(filename.upcase)
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_image_class_for_file(file)
|
102
|
+
return FXGIFImage if has_extension(file, ".gif")
|
103
|
+
return FXBMPImage if has_extension(file, ".bmp")
|
104
|
+
return FXXPMImage if has_extension(file, ".xpm")
|
105
|
+
return FXPNGImage if has_extension(file, ".png")
|
106
|
+
return FXJPGImage if has_extension(file, ".jpg")
|
107
|
+
return FXPCXImage if has_extension(file, ".pcx")
|
108
|
+
return FXTIFImage if has_extension(file, ".tif")
|
109
|
+
return FXTGAImage if has_extension(file, ".tga")
|
110
|
+
return FXICOImage if has_extension(file, ".ico")
|
111
111
|
return nil
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
115
|
-
return FXGIFIcon if
|
116
|
-
return FXBMPIcon if
|
117
|
-
return FXXPMIcon if
|
118
|
-
return FXPNGIcon if
|
119
|
-
return FXJPGIcon if
|
120
|
-
return FXPCXIcon if
|
121
|
-
return FXTIFIcon if
|
122
|
-
return FXTGAIcon if
|
123
|
-
return FXICOIcon if
|
114
|
+
def get_icon_class_for_file(file)
|
115
|
+
return FXGIFIcon if has_extension(file, ".gif")
|
116
|
+
return FXBMPIcon if has_extension(file, ".bmp")
|
117
|
+
return FXXPMIcon if has_extension(file, ".xpm")
|
118
|
+
return FXPNGIcon if has_extension(file, ".png")
|
119
|
+
return FXJPGIcon if has_extension(file, ".jpg")
|
120
|
+
return FXPCXIcon if has_extension(file, ".pcx")
|
121
|
+
return FXTIFIcon if has_extension(file, ".tif")
|
122
|
+
return FXTGAIcon if has_extension(file, ".tga")
|
123
|
+
return FXICOIcon if has_extension(file, ".ico")
|
124
124
|
return nil
|
125
125
|
end
|
126
126
|
|
127
|
-
def
|
128
|
-
|
129
|
-
return nil if !
|
130
|
-
return
|
131
|
-
|
127
|
+
def get_image_instance_for_file(file)
|
128
|
+
image_class = get_image_class_for_file file
|
129
|
+
return nil if !image_class
|
130
|
+
return image_class.new(@app, nil, IMAGE_KEEP|
|
131
|
+
IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP
|
132
132
|
)
|
133
133
|
end
|
134
134
|
|
135
|
-
def
|
136
|
-
|
137
|
-
return nil if !
|
138
|
-
return
|
135
|
+
def get_icon_instance_for_file(file)
|
136
|
+
icon_class = get_icon_class_for_file file
|
137
|
+
return nil if !icon_class
|
138
|
+
return icon_class.new(@app, nil)
|
139
139
|
end
|
140
140
|
end
|
@@ -11,16 +11,16 @@ class ModalDialog < Fox::FXDialogBox
|
|
11
11
|
|
12
12
|
def initialize(*args)
|
13
13
|
super(*args)
|
14
|
-
FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_ACCEPT, :
|
14
|
+
FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_ACCEPT, :on_cmd_accept)
|
15
15
|
end
|
16
16
|
|
17
17
|
# utility method for use in subclasses
|
18
|
-
def
|
18
|
+
def add_ok_cancel_buttons_to(frame)
|
19
19
|
FXHorizontalSeparator.new(frame, SEPARATOR_GROOVE)
|
20
20
|
buttons = FXHorizontalFrame.new(frame)
|
21
21
|
cancel = FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL)
|
22
22
|
accept = FXButton.new(buttons, "&Accept", nil, self, ID_ACCEPT,
|
23
|
-
|
23
|
+
BUTTON_NORMAL|BUTTON_INITIAL|BUTTON_DEFAULT)
|
24
24
|
buttons.setLayoutHints(LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X)
|
25
25
|
buttons.setPackingHints(PACK_UNIFORM_WIDTH)
|
26
26
|
accept.setLayoutHints(LAYOUT_RIGHT)
|
@@ -29,13 +29,13 @@ class ModalDialog < Fox::FXDialogBox
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# This is the overwrite that integrates the validation hook
|
32
|
-
def
|
32
|
+
def on_cmd_accept(p1, p2, p3)
|
33
33
|
begin
|
34
34
|
view2model
|
35
35
|
rescue Error => ex
|
36
36
|
warn(ex.to_s, "Error")
|
37
37
|
end
|
38
|
-
|
38
|
+
onCmdAccept(p1, p2, p3) if validate
|
39
39
|
end
|
40
40
|
|
41
41
|
# this method will be sent before validation
|
@@ -56,6 +56,12 @@ class ModalDialog < Fox::FXDialogBox
|
|
56
56
|
FXMessageBox::warning(self, style, title, msg)
|
57
57
|
return false
|
58
58
|
end
|
59
|
+
|
60
|
+
def yes?(title, question)
|
61
|
+
style = MBOX_YES_NO|DECOR_TITLE|DECOR_CLOSE|Placement
|
62
|
+
answer = FXMessageBox.question(self, style, title, question)
|
63
|
+
return answer == MBOX_CLICKED_YES
|
64
|
+
end
|
59
65
|
|
60
66
|
# Return a boolean
|
61
67
|
def execute(placement=Placement)
|