/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_print_command.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_print_command.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 6984 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Command to print an editor content"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: "Etienne Amodeo"
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_PRINT_COMMAND
11
12 inherit
13
14 TEXT_OBSERVER
15 redefine
16 on_text_loaded, on_text_edited
17 end
18
19 EB_TOOLBARABLE_AND_MENUABLE_COMMAND
20 redefine
21 tooltext
22 end
23
24 EB_SHARED_WINDOW_MANAGER
25 export
26 {NONE} all
27 end
28
29 SHARED_WORKBENCH
30 export
31 {NONE} all
32 end
33
34 EB_SHARED_PREFERENCES
35 export
36 {NONE} all
37 end
38
39 SHARED_EDITOR_FONT
40 export
41 {NONE} all
42 end
43
44 EB_RECYCLABLE
45
46 create
47 make
48
49 feature -- Initialization
50
51 make (a_dev_win: EB_DEVELOPMENT_WINDOW) is
52 -- Create a formatter associated with `a_manager'.
53 do
54 -- create accelerator.make_with_key_combination (
55 -- create {EV_KEY}.make_with_code ({EV_KEY_CONSTANTS}.Key_p),
56 -- True, False, False)
57 -- accelerator.actions.extend (~execute)
58 dev_window := a_dev_win
59 if
60 a_dev_win.is_empty
61 then
62 disable_sensitive
63 else
64 enable_sensitive
65 end
66 end
67
68 feature -- Access
69
70 dev_window: EB_DEVELOPMENT_WINDOW
71 -- development window to which this command is related
72
73 feature -- Execution
74
75 execute is
76 -- Save a file with the chosen name.
77 local
78 printer: EB_PRINTER
79 l_txt_gen: EB_PRINTER_TEXT_GENERATOR
80 do
81 create l_txt_gen.make (dev_window.editors_manager.current_editor)
82 if not dev_window.is_empty then
83 create printer.make
84 printer.set_text (l_txt_gen.text_for_printing)
85 printer.set_window (dev_window.window)
86 printer.set_job_name (dev_window.stone.history_name)
87 if not use_external_editor then
88 printer.ask_and_print
89 else
90 printer.set_external_command (external_editor)
91 printer.print_via_command
92 end
93 end
94 end
95
96 feature {NONE} -- Implementation
97
98 menu_name: STRING is
99 -- Name as it appears in the menu (with & symbol).
100 do
101 Result := Interface_names.m_Print
102 end
103
104 pixmap: EV_PIXMAP is
105 -- Pixmaps representing the command.
106 do
107 Result := pixmaps.icon_pixmaps.general_print_icon
108 end
109
110 pixel_buffer: EV_PIXEL_BUFFER is
111 -- Pixel buffer representing the command.
112 do
113 -- Currently there is no pixel buffer for this command.
114 end
115
116 tooltip: STRING is
117 -- Tooltip for the toolbar button.
118 do
119 Result := Interface_names.f_Print
120 end
121
122 tooltext: STRING is
123 -- Text for the toolbar button.
124 do
125 Result := Interface_names.b_Print
126 end
127
128 description: STRING is
129 -- Tooltip for the toolbar button.
130 do
131 Result := Interface_names.e_Print
132 end
133
134 name: STRING is "Print"
135 -- Name of the command. Used to store the command in the
136 -- preferences.
137
138 on_text_edited (directly_edited: BOOLEAN) is
139 -- Nothing.
140 do
141 --enable_sensitive
142 end
143
144 on_text_loaded is
145 -- Update the command sensitivity.
146 do
147 if dev_window.is_empty then
148 disable_sensitive
149 else
150 enable_sensitive
151 end
152 end
153
154 feature -- Recyclable
155
156 recycle is
157 -- Recycle
158 do
159 dev_window := Void
160 end
161
162 feature {NONE} -- implementation
163
164 saved: BOOLEAN
165
166 save_to_file (a_text: STRING; a_filename: STRING) is
167 -- Save `a_text' in `a_filename'.
168 require
169 a_text_not_void: a_text /= Void
170 a_filename_not_void: a_filename /= Void
171 local
172 char: CHARACTER
173 new_file: PLAIN_TEXT_FILE
174 wd: EV_WARNING_DIALOG
175 do
176 saved := False
177 if not a_filename.is_empty then
178 create new_file.make (a_filename)
179 if new_file.exists and then not new_file.is_plain then
180 create wd.make_with_text (Warning_messages.w_Not_a_plain_file (new_file.name))
181 wd.show_modal_to_window (dev_window.window)
182 elseif new_file.exists and then not new_file.is_writable then
183 create wd.make_with_text (Warning_messages.w_Not_writable (new_file.name))
184 wd.show_modal_to_window (dev_window.window)
185 elseif not new_file.exists and then not new_file.is_creatable then
186 create wd.make_with_text (Warning_messages.w_Not_creatable (new_file.name))
187 wd.show_modal_to_window (dev_window.window)
188 else
189 new_file.create_read_write
190 if not a_text.is_empty then
191 new_file.put_string (a_text)
192 char := a_text.item (a_text.count)
193 if char /= '%N' and then char /= '%R' then
194 -- Add a carriage return like vi
195 -- if there's none at the end
196 new_file.put_new_line
197 end
198 end
199 new_file.add_permission ("u", "wr")
200 new_file.close
201 saved := True
202 end
203 end
204 end
205
206 enable_toolbar_items is
207 -- make toolbar items sensitive
208 do
209 from
210 managed_toolbar_items.start
211 until
212 managed_toolbar_items.exhausted
213 loop
214 managed_toolbar_items.item.enable_sensitive
215 managed_toolbar_items.forth
216 end
217 end
218
219 disable_toolbar_items is
220 -- make toolbar items insensitive
221 do
222 from
223 managed_toolbar_items.start
224 until
225 managed_toolbar_items.exhausted
226 loop
227 managed_toolbar_items.item.disable_sensitive
228 managed_toolbar_items.forth
229 end
230 end
231
232 feature {NONE} -- Implementation
233
234 use_external_editor: BOOLEAN is
235 -- Should we use an external editor to print?
236 do
237 Result := preferences.misc_data.use_external_editor
238 end
239
240 external_editor: STRING is
241 -- Command line to invoke to use an external editor to print.
242 do
243 Result := preferences.misc_data.print_shell_command
244 end
245
246 feature {NONE} -- Externals
247
248 generate_temp_name: STRING is
249 -- Generate a temporary file name.
250 local
251 prefix_name: STRING
252 a: ANY
253 p: POINTER
254 do
255 prefix_name := "bench_"
256 a := prefix_name.to_c
257 p := tempnam (default_pointer, $a)
258
259 create Result.make (0)
260 Result.from_c (p)
261 end
262
263 tempnam (d,p: POINTER): POINTER is
264 external
265 "C | <stdio.h>"
266 end
267
268 indexing
269 copyright: "Copyright (c) 1984-2006, Eiffel Software"
270 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
271 licensing_options: "http://www.eiffel.com/licensing"
272 copying: "[
273 This file is part of Eiffel Software's Eiffel Development Environment.
274
275 Eiffel Software's Eiffel Development Environment is free
276 software; you can redistribute it and/or modify it under
277 the terms of the GNU General Public License as published
278 by the Free Software Foundation, version 2 of the License
279 (available at the URL listed under "license" above).
280
281 Eiffel Software's Eiffel Development Environment is
282 distributed in the hope that it will be useful, but
283 WITHOUT ANY WARRANTY; without even the implied warranty
284 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
285 See the GNU General Public License for more details.
286
287 You should have received a copy of the GNU General Public
288 License along with Eiffel Software's Eiffel Development
289 Environment; if not, write to the Free Software Foundation,
290 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
291 ]"
292 source: "[
293 Eiffel Software
294 356 Storke Road, Goleta, CA 93117 USA
295 Telephone 805-685-1006, Fax 805-685-6869
296 Website http://www.eiffel.com
297 Customer support http://support.eiffel.com
298 ]"
299
300 end -- class EB_PRINT_COMMAND

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23