Merge lp:~l-admin-3/evnc/automatic-cleanup-branch into lp:evnc
- automatic-cleanup-branch
- Merge into trunk-1
Proposed by
Marcus Wichelmann
Status: | Needs review |
---|---|
Proposed branch: | lp:~l-admin-3/evnc/automatic-cleanup-branch |
Merge into: | lp:evnc |
Diff against target: |
2035 lines (+978/-950) 11 files modified
src/Dialogs/ConnectDialog.vala (+103/-103) src/Dialogs/PreferencesDialog.vala (+140/-128) src/MainWindow.vala (+71/-71) src/SettingsManager.vala (+58/-58) src/Widgets/BookmarksMenu.vala (+87/-87) src/Widgets/Information.vala (+46/-45) src/Widgets/MainView.vala (+49/-48) src/Widgets/Notebook.vala (+27/-27) src/Widgets/TitleBar.vala (+125/-122) src/Widgets/VncConnection.vala (+208/-197) src/evnc.vala (+64/-64) |
To merge this branch: | bzr merge lp:~l-admin-3/evnc/automatic-cleanup-branch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marcus Wichelmann | Pending | ||
Review via email:
|
Commit message
Automatic code cleanup
Description of the change
Here are some code cleanups. ;)
To post a comment you must log in.
Unmerged revisions
- 59. By Marcus Wichelmann
-
Automatic code cleanup
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Dialogs/ConnectDialog.vala' |
2 | --- src/Dialogs/ConnectDialog.vala 2014-11-01 00:02:58 +0000 |
3 | +++ src/Dialogs/ConnectDialog.vala 2015-07-09 18:17:15 +0000 |
4 | @@ -17,107 +17,107 @@ |
5 | */ |
6 | |
7 | namespace evnc.Dialogs { |
8 | - public class ConnectDialog : Gtk.Dialog { |
9 | - private Gtk.Box box; |
10 | - |
11 | - private Gtk.Grid grid_input; |
12 | - |
13 | - private Gtk.Label label_host; |
14 | - public Gtk.Entry entry_host; |
15 | - |
16 | - private Gtk.Label label_port; |
17 | - public Gtk.Entry entry_port; |
18 | - |
19 | - private Gtk.Label label_user; |
20 | - public Gtk.Entry entry_user; |
21 | - |
22 | - public Gtk.CheckButton btn_bookmark; |
23 | - public Gtk.Entry entry_bookmark; |
24 | - |
25 | - private Gtk.Button btn_connect; |
26 | - |
27 | - public ConnectDialog () { |
28 | - this.title = _("Connection set-up"); |
29 | - this.resizable = false; |
30 | - this.set_modal (true); |
31 | - |
32 | - setup_ui (); |
33 | - |
34 | - connect_events (); |
35 | - |
36 | - this.show_all (); |
37 | - } |
38 | - |
39 | - private void setup_ui () { |
40 | - box = this.get_content_area () as Gtk.Box; |
41 | - |
42 | - grid_input = new Gtk.Grid (); |
43 | - grid_input.margin = 12; |
44 | - grid_input.column_spacing = 12; |
45 | - |
46 | - label_host = new Gtk.Label (_("Hostname:")); |
47 | - label_port = new Gtk.Label (_("Port:")); |
48 | - label_user = new Gtk.Label (_("Username:")); |
49 | - |
50 | - label_host.hexpand = true; |
51 | - label_port.hexpand = true; |
52 | - label_user.hexpand = true; |
53 | - label_host.halign = Gtk.Align.END; |
54 | - label_port.halign = Gtk.Align.END; |
55 | - label_user.halign = Gtk.Align.END; |
56 | - |
57 | - grid_input.attach (label_host, 0, 0, 1, 1); |
58 | - grid_input.attach (label_port, 0, 1, 1, 1); |
59 | - grid_input.attach (label_user, 0, 2, 1, 1); |
60 | - |
61 | - entry_host = new Gtk.Entry (); |
62 | - entry_port = new Gtk.Entry (); |
63 | - entry_user = new Gtk.Entry (); |
64 | - |
65 | - entry_host.set_hexpand (true); |
66 | - entry_port.set_hexpand (true); |
67 | - entry_user.set_hexpand (true); |
68 | - |
69 | - entry_host.set_placeholder_text (_("e.g.: joe-pc")); |
70 | - entry_port.set_placeholder_text (_("e.g.: 5900")); |
71 | - entry_user.set_placeholder_text (_("e.g.: joe")); |
72 | - |
73 | - entry_port.set_text ("5900"); |
74 | - |
75 | - grid_input.attach (entry_host, 1, 0, 1, 1); |
76 | - grid_input.attach (entry_port, 1, 1, 1, 1); |
77 | - grid_input.attach (entry_user, 1, 2, 1, 1); |
78 | - |
79 | - btn_bookmark = new Gtk.CheckButton.with_label (_("New Bookmark:")); |
80 | - btn_bookmark.set_margin_top (6); |
81 | - entry_bookmark = new Gtk.Entry (); |
82 | - entry_bookmark.set_margin_top (6); |
83 | - entry_bookmark.set_hexpand (true); |
84 | - entry_bookmark.sensitive = false; |
85 | - entry_bookmark.set_placeholder_text (_("optional")); |
86 | - |
87 | - grid_input.attach (btn_bookmark, 0, 3, 1, 1); |
88 | - grid_input.attach (entry_bookmark, 1, 3, 1, 1); |
89 | - grid_input.row_spacing = 12; |
90 | - |
91 | - box.pack_start (grid_input); |
92 | - |
93 | - this.add_button (_("Cancel"), Gtk.ResponseType.CLOSE); |
94 | - |
95 | - btn_connect = this.add_button (_("Connect"), Gtk.ResponseType.APPLY) as Gtk.Button; |
96 | - btn_connect.get_style_context ().add_class ("suggested-action"); |
97 | - } |
98 | - |
99 | - private void connect_events () { |
100 | - btn_bookmark.toggled.connect (() => { |
101 | - if (btn_bookmark.active) { |
102 | - btn_connect.label = _("Save and connect"); |
103 | - entry_bookmark.sensitive = true; |
104 | - } else { |
105 | - btn_connect.label = _("Connect"); |
106 | - entry_bookmark.sensitive = false; |
107 | - } |
108 | - }); |
109 | - } |
110 | - } |
111 | + public class ConnectDialog : Gtk.Dialog { |
112 | + private Gtk.Box box; |
113 | + |
114 | + private Gtk.Grid grid_input; |
115 | + |
116 | + private Gtk.Label label_host; |
117 | + public Gtk.Entry entry_host; |
118 | + |
119 | + private Gtk.Label label_port; |
120 | + public Gtk.Entry entry_port; |
121 | + |
122 | + private Gtk.Label label_user; |
123 | + public Gtk.Entry entry_user; |
124 | + |
125 | + public Gtk.CheckButton btn_bookmark; |
126 | + public Gtk.Entry entry_bookmark; |
127 | + |
128 | + private Gtk.Button btn_connect; |
129 | + |
130 | + public ConnectDialog () { |
131 | + this.title = _ ("Connection set-up"); |
132 | + this.resizable = false; |
133 | + this.set_modal (true); |
134 | + |
135 | + setup_ui (); |
136 | + |
137 | + connect_events (); |
138 | + |
139 | + this.show_all (); |
140 | + } |
141 | + |
142 | + private void setup_ui () { |
143 | + box = this.get_content_area () as Gtk.Box; |
144 | + |
145 | + grid_input = new Gtk.Grid (); |
146 | + grid_input.margin = 12; |
147 | + grid_input.column_spacing = 12; |
148 | + |
149 | + label_host = new Gtk.Label (_ ("Hostname:")); |
150 | + label_port = new Gtk.Label (_ ("Port:")); |
151 | + label_user = new Gtk.Label (_ ("Username:")); |
152 | + |
153 | + label_host.hexpand = true; |
154 | + label_port.hexpand = true; |
155 | + label_user.hexpand = true; |
156 | + label_host.halign = Gtk.Align.END; |
157 | + label_port.halign = Gtk.Align.END; |
158 | + label_user.halign = Gtk.Align.END; |
159 | + |
160 | + grid_input.attach (label_host, 0, 0, 1, 1); |
161 | + grid_input.attach (label_port, 0, 1, 1, 1); |
162 | + grid_input.attach (label_user, 0, 2, 1, 1); |
163 | + |
164 | + entry_host = new Gtk.Entry (); |
165 | + entry_port = new Gtk.Entry (); |
166 | + entry_user = new Gtk.Entry (); |
167 | + |
168 | + entry_host.set_hexpand (true); |
169 | + entry_port.set_hexpand (true); |
170 | + entry_user.set_hexpand (true); |
171 | + |
172 | + entry_host.set_placeholder_text (_ ("e.g.: joe-pc")); |
173 | + entry_port.set_placeholder_text (_ ("e.g.: 5900")); |
174 | + entry_user.set_placeholder_text (_ ("e.g.: joe")); |
175 | + |
176 | + entry_port.set_text ("5900"); |
177 | + |
178 | + grid_input.attach (entry_host, 1, 0, 1, 1); |
179 | + grid_input.attach (entry_port, 1, 1, 1, 1); |
180 | + grid_input.attach (entry_user, 1, 2, 1, 1); |
181 | + |
182 | + btn_bookmark = new Gtk.CheckButton.with_label (_ ("New Bookmark:")); |
183 | + btn_bookmark.set_margin_top (6); |
184 | + entry_bookmark = new Gtk.Entry (); |
185 | + entry_bookmark.set_margin_top (6); |
186 | + entry_bookmark.set_hexpand (true); |
187 | + entry_bookmark.sensitive = false; |
188 | + entry_bookmark.set_placeholder_text (_ ("optional")); |
189 | + |
190 | + grid_input.attach (btn_bookmark, 0, 3, 1, 1); |
191 | + grid_input.attach (entry_bookmark, 1, 3, 1, 1); |
192 | + grid_input.row_spacing = 12; |
193 | + |
194 | + box.pack_start (grid_input); |
195 | + |
196 | + this.add_button (_ ("Cancel"), Gtk.ResponseType.CLOSE); |
197 | + |
198 | + btn_connect = this.add_button (_ ("Connect"), Gtk.ResponseType.APPLY) as Gtk.Button; |
199 | + btn_connect.get_style_context ().add_class ("suggested-action"); |
200 | + } |
201 | + |
202 | + private void connect_events () { |
203 | + btn_bookmark.toggled.connect (() => { |
204 | + if (btn_bookmark.active) { |
205 | + btn_connect.label = _ ("Save and connect"); |
206 | + entry_bookmark.sensitive = true; |
207 | + } else { |
208 | + btn_connect.label = _ ("Connect"); |
209 | + entry_bookmark.sensitive = false; |
210 | + } |
211 | + }); |
212 | + } |
213 | + } |
214 | } |
215 | \ No newline at end of file |
216 | |
217 | === modified file 'src/Dialogs/PreferencesDialog.vala' |
218 | --- src/Dialogs/PreferencesDialog.vala 2014-10-31 16:31:48 +0000 |
219 | +++ src/Dialogs/PreferencesDialog.vala 2015-07-09 18:17:15 +0000 |
220 | @@ -17,132 +17,144 @@ |
221 | */ |
222 | |
223 | namespace evnc.Dialogs { |
224 | - public class PreferencesDialog : Gtk.Dialog { |
225 | - private SettingsManager options; |
226 | - |
227 | - private Gtk.Box box; |
228 | - |
229 | - private Gtk.Grid main_grid; |
230 | - |
231 | - private Gtk.Switch switch_save_new_servers; |
232 | - private Gtk.Switch switch_pointer_local; |
233 | - private Gtk.Switch switch_use_dark_theme; |
234 | - private Gtk.Switch switch_lossy_encoding; |
235 | - private Gtk.ComboBoxText combo_color_depth; |
236 | - |
237 | - public PreferencesDialog () { |
238 | - options = new SettingsManager (); |
239 | - |
240 | - this.title = _("Preferences"); |
241 | - this.border_width = 5; |
242 | - this.resizable = false; |
243 | - this.set_modal (true); |
244 | - |
245 | - setup_ui (); |
246 | - |
247 | - connect_events (); |
248 | - |
249 | - options.settings.bind("save-new-servers", switch_save_new_servers, "active", SettingsBindFlags.DEFAULT); |
250 | - options.settings.bind("pointer-local", switch_pointer_local, "active", SettingsBindFlags.DEFAULT); |
251 | - options.settings.bind("use-dark-theme", switch_use_dark_theme, "active", SettingsBindFlags.DEFAULT); |
252 | - options.settings.bind("lossy-encoding", switch_lossy_encoding, "active", SettingsBindFlags.DEFAULT); |
253 | - |
254 | - var new_value = 0; |
255 | - switch (options.color_depth) { |
256 | - case "default": |
257 | - new_value = 0; |
258 | - break; |
259 | - case "full": |
260 | - new_value = 1; |
261 | - break; |
262 | - case "medium": |
263 | - new_value = 2; |
264 | - break; |
265 | - case "low": |
266 | - new_value = 3; |
267 | - break; |
268 | - case "ultra low": |
269 | - new_value = 4; |
270 | - break; |
271 | - } |
272 | - combo_color_depth.set_active (new_value); |
273 | - |
274 | - this.show_all (); |
275 | - } |
276 | - |
277 | - private void setup_ui () { |
278 | - box = this.get_content_area () as Gtk.Box; |
279 | - |
280 | - main_grid = new Gtk.Grid (); |
281 | - main_grid.margin = 12; |
282 | - main_grid.column_spacing = 12; |
283 | - main_grid.row_spacing = 12; |
284 | - |
285 | - main_grid.attach (new AlignLabel (_("Save new servers:")), 0, 0, 1, 1); |
286 | - switch_save_new_servers = new Gtk.Switch (); |
287 | - switch_save_new_servers.halign = Gtk.Align.START; |
288 | - main_grid.attach (switch_save_new_servers, 1, 0, 1, 1); |
289 | - |
290 | - main_grid.attach (new AlignLabel (_("Use the local pointer:")), 0, 1, 1, 1); |
291 | - switch_pointer_local = new Gtk.Switch (); |
292 | - switch_pointer_local.halign = Gtk.Align.START; |
293 | - main_grid.attach (switch_pointer_local, 1, 1, 1, 1); |
294 | - |
295 | - main_grid.attach (new AlignLabel (_("Use the dark theme:")), 0, 2, 1, 1); |
296 | - switch_use_dark_theme = new Gtk.Switch (); |
297 | - switch_use_dark_theme.halign = Gtk.Align.START; |
298 | - main_grid.attach (switch_use_dark_theme, 1, 2, 1, 1); |
299 | - |
300 | - main_grid.attach (new AlignLabel (_("Use the lossy encoding:")), 0, 3, 1, 1); |
301 | - switch_lossy_encoding = new Gtk.Switch (); |
302 | - switch_lossy_encoding.halign = Gtk.Align.START; |
303 | - main_grid.attach (switch_lossy_encoding, 1, 3, 1, 1); |
304 | - |
305 | - main_grid.attach (new AlignLabel (_("Color depth:")), 0, 4, 1, 1); |
306 | - combo_color_depth = new Gtk.ComboBoxText (); |
307 | - combo_color_depth.append_text (_("Server configuration")); |
308 | - combo_color_depth.append_text (_("True quality (24bit)")); |
309 | - combo_color_depth.append_text (_("High quality (16bit)")); |
310 | - combo_color_depth.append_text (_("Low quality (8bit)")); |
311 | - combo_color_depth.append_text (_("Ultra low quality (3bit)")); |
312 | - main_grid.attach (combo_color_depth, 1, 4, 1, 1); |
313 | - |
314 | - box.pack_start (main_grid); |
315 | - |
316 | - this.add_button (_("Close"), Gtk.ResponseType.CLOSE); |
317 | - } |
318 | - |
319 | - private void connect_events () { |
320 | - combo_color_depth.changed.connect (() => { |
321 | - var new_value = "default"; |
322 | - switch (combo_color_depth.get_active ()) { |
323 | - case 0: |
324 | - new_value = "default"; |
325 | - break; |
326 | - case 1: |
327 | - new_value = "full"; |
328 | - break; |
329 | - case 2: |
330 | - new_value = "medium"; |
331 | - break; |
332 | - case 3: |
333 | - new_value = "low"; |
334 | - break; |
335 | - case 4: |
336 | - new_value = "ultra low"; |
337 | - break; |
338 | - } |
339 | - options.color_depth = new_value; |
340 | - }); |
341 | - } |
342 | - } |
343 | - |
344 | - public class AlignLabel : Gtk.Label |
345 | - { |
346 | - public AlignLabel (string text) { |
347 | - this.hexpand = true; |
348 | - this.halign = Gtk.Align.END; |
349 | - this.label = text; |
350 | - } |
351 | - } |
352 | + public class PreferencesDialog : Gtk.Dialog { |
353 | + private SettingsManager options; |
354 | + |
355 | + private Gtk.Box box; |
356 | + |
357 | + private Gtk.Grid main_grid; |
358 | + |
359 | + private Gtk.Switch switch_save_new_servers; |
360 | + private Gtk.Switch switch_pointer_local; |
361 | + private Gtk.Switch switch_use_dark_theme; |
362 | + private Gtk.Switch switch_lossy_encoding; |
363 | + private Gtk.ComboBoxText combo_color_depth; |
364 | + |
365 | + public PreferencesDialog () { |
366 | + options = new SettingsManager (); |
367 | + |
368 | + this.title = _ ("Preferences"); |
369 | + this.border_width = 5; |
370 | + this.resizable = false; |
371 | + this.set_modal (true); |
372 | + |
373 | + setup_ui (); |
374 | + |
375 | + connect_events (); |
376 | + |
377 | + options.settings.bind ("save-new-servers", switch_save_new_servers, "active", SettingsBindFlags.DEFAULT); |
378 | + options.settings.bind ("pointer-local", switch_pointer_local, "active", SettingsBindFlags.DEFAULT); |
379 | + options.settings.bind ("use-dark-theme", switch_use_dark_theme, "active", SettingsBindFlags.DEFAULT); |
380 | + options.settings.bind ("lossy-encoding", switch_lossy_encoding, "active", SettingsBindFlags.DEFAULT); |
381 | + |
382 | + var new_value = 0; |
383 | + |
384 | + switch (options.color_depth) { |
385 | + case "default": |
386 | + new_value = 0; |
387 | + break; |
388 | + |
389 | + case "full": |
390 | + new_value = 1; |
391 | + break; |
392 | + |
393 | + case "medium": |
394 | + new_value = 2; |
395 | + break; |
396 | + |
397 | + case "low": |
398 | + new_value = 3; |
399 | + break; |
400 | + |
401 | + case "ultra low": |
402 | + new_value = 4; |
403 | + break; |
404 | + } |
405 | + |
406 | + combo_color_depth.set_active (new_value); |
407 | + |
408 | + this.show_all (); |
409 | + } |
410 | + |
411 | + private void setup_ui () { |
412 | + box = this.get_content_area () as Gtk.Box; |
413 | + |
414 | + main_grid = new Gtk.Grid (); |
415 | + main_grid.margin = 12; |
416 | + main_grid.column_spacing = 12; |
417 | + main_grid.row_spacing = 12; |
418 | + |
419 | + main_grid.attach (new AlignLabel (_ ("Save new servers:")), 0, 0, 1, 1); |
420 | + switch_save_new_servers = new Gtk.Switch (); |
421 | + switch_save_new_servers.halign = Gtk.Align.START; |
422 | + main_grid.attach (switch_save_new_servers, 1, 0, 1, 1); |
423 | + |
424 | + main_grid.attach (new AlignLabel (_ ("Use the local pointer:")), 0, 1, 1, 1); |
425 | + switch_pointer_local = new Gtk.Switch (); |
426 | + switch_pointer_local.halign = Gtk.Align.START; |
427 | + main_grid.attach (switch_pointer_local, 1, 1, 1, 1); |
428 | + |
429 | + main_grid.attach (new AlignLabel (_ ("Use the dark theme:")), 0, 2, 1, 1); |
430 | + switch_use_dark_theme = new Gtk.Switch (); |
431 | + switch_use_dark_theme.halign = Gtk.Align.START; |
432 | + main_grid.attach (switch_use_dark_theme, 1, 2, 1, 1); |
433 | + |
434 | + main_grid.attach (new AlignLabel (_ ("Use the lossy encoding:")), 0, 3, 1, 1); |
435 | + switch_lossy_encoding = new Gtk.Switch (); |
436 | + switch_lossy_encoding.halign = Gtk.Align.START; |
437 | + main_grid.attach (switch_lossy_encoding, 1, 3, 1, 1); |
438 | + |
439 | + main_grid.attach (new AlignLabel (_ ("Color depth:")), 0, 4, 1, 1); |
440 | + combo_color_depth = new Gtk.ComboBoxText (); |
441 | + combo_color_depth.append_text (_ ("Server configuration")); |
442 | + combo_color_depth.append_text (_ ("True quality (24bit)")); |
443 | + combo_color_depth.append_text (_ ("High quality (16bit)")); |
444 | + combo_color_depth.append_text (_ ("Low quality (8bit)")); |
445 | + combo_color_depth.append_text (_ ("Ultra low quality (3bit)")); |
446 | + main_grid.attach (combo_color_depth, 1, 4, 1, 1); |
447 | + |
448 | + box.pack_start (main_grid); |
449 | + |
450 | + this.add_button (_ ("Close"), Gtk.ResponseType.CLOSE); |
451 | + } |
452 | + |
453 | + private void connect_events () { |
454 | + combo_color_depth.changed.connect (() => { |
455 | + var new_value = "default"; |
456 | + |
457 | + switch (combo_color_depth.get_active ()) { |
458 | + case 0: |
459 | + new_value = "default"; |
460 | + break; |
461 | + |
462 | + case 1: |
463 | + new_value = "full"; |
464 | + break; |
465 | + |
466 | + case 2: |
467 | + new_value = "medium"; |
468 | + break; |
469 | + |
470 | + case 3: |
471 | + new_value = "low"; |
472 | + break; |
473 | + |
474 | + case 4: |
475 | + new_value = "ultra low"; |
476 | + break; |
477 | + } |
478 | + |
479 | + options.color_depth = new_value; |
480 | + }); |
481 | + } |
482 | + } |
483 | + |
484 | + public class AlignLabel : Gtk.Label |
485 | + { |
486 | + public AlignLabel (string text) { |
487 | + this.hexpand = true; |
488 | + this.halign = Gtk.Align.END; |
489 | + this.label = text; |
490 | + } |
491 | + } |
492 | } |
493 | \ No newline at end of file |
494 | |
495 | === modified file 'src/MainWindow.vala' |
496 | --- src/MainWindow.vala 2014-10-31 16:31:48 +0000 |
497 | +++ src/MainWindow.vala 2015-07-09 18:17:15 +0000 |
498 | @@ -17,75 +17,75 @@ |
499 | */ |
500 | |
501 | namespace evnc { |
502 | - public class MainWindow : Gtk.Window { |
503 | - // App |
504 | - public evncApp app; |
505 | - |
506 | - // Settings |
507 | - private SettingsManager options; |
508 | - |
509 | - // Container |
510 | - private Gtk.Box box; |
511 | - private Widgets.TitleBar titlebar; |
512 | - private Widgets.Information information; |
513 | - private Widgets.MainView mainview; |
514 | - |
515 | - public MainWindow (evncApp app) { |
516 | - this.app = app; |
517 | - this.set_application (app); |
518 | - |
519 | - options = new SettingsManager (); |
520 | - |
521 | - // Change the theme |
522 | - Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = options.use_dark_theme; |
523 | - options.on_use_dark_theme_changed.connect ((val) => { |
524 | - Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = val; |
525 | - }); |
526 | - |
527 | - // Window propterties |
528 | - this.set_size_request (900, 650); |
529 | - this.set_has_resize_grip (false); |
530 | - this.window_position = Gtk.WindowPosition.CENTER; |
531 | - |
532 | - // Draw UI |
533 | - setup_ui (); |
534 | - this.show_all (); |
535 | - } |
536 | - |
537 | - private void setup_ui () { |
538 | - box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
539 | - |
540 | - titlebar = new Widgets.TitleBar (this); |
541 | - |
542 | - this.set_titlebar (titlebar); |
543 | - box.pack_start (titlebar, false, true); |
544 | - |
545 | - information = new Widgets.Information (); |
546 | - box.pack_start (information, false, true); |
547 | - |
548 | - mainview = new Widgets.MainView (); |
549 | - box.pack_start (mainview, true, true); |
550 | - |
551 | - this.add (box); |
552 | - |
553 | - titlebar.on_connect_request.connect (mainview.notebook.add_connection); |
554 | - titlebar.on_take_screenshot_clicked.connect (() => { |
555 | - (mainview.notebook.current as Widgets.VncConnection).take_screenshot (); |
556 | - }); |
557 | - |
558 | - mainview.on_show_connect_dialog_request.connect (titlebar.show_connect_dialog); |
559 | - mainview.on_open_bookmarks_request.connect (() => { |
560 | - titlebar.bookmarksmenu.popup (null, null, null, 0, Gtk.get_current_event_time ()); |
561 | - }); |
562 | - mainview.notebook.on_connection_message.connect (information.show_text); |
563 | - mainview.notebook.tab_added.connect (() => { |
564 | - titlebar.btn_screenshot.set_sensitive (true); |
565 | - }); |
566 | - mainview.notebook.tab_removed.connect (() => { |
567 | - if (mainview.notebook.n_tabs == 0) { |
568 | - titlebar.btn_screenshot.set_sensitive (false); |
569 | - } |
570 | - }); |
571 | - } |
572 | - } |
573 | + public class MainWindow : Gtk.Window { |
574 | + // App |
575 | + public evncApp app; |
576 | + |
577 | + // Settings |
578 | + private SettingsManager options; |
579 | + |
580 | + // Container |
581 | + private Gtk.Box box; |
582 | + private Widgets.TitleBar titlebar; |
583 | + private Widgets.Information information; |
584 | + private Widgets.MainView mainview; |
585 | + |
586 | + public MainWindow (evncApp app) { |
587 | + this.app = app; |
588 | + this.set_application (app); |
589 | + |
590 | + options = new SettingsManager (); |
591 | + |
592 | + // Change the theme |
593 | + Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = options.use_dark_theme; |
594 | + options.on_use_dark_theme_changed.connect ((val) => { |
595 | + Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = val; |
596 | + }); |
597 | + |
598 | + // Window propterties |
599 | + this.set_size_request (900, 650); |
600 | + this.set_has_resize_grip (false); |
601 | + this.window_position = Gtk.WindowPosition.CENTER; |
602 | + |
603 | + // Draw UI |
604 | + setup_ui (); |
605 | + this.show_all (); |
606 | + } |
607 | + |
608 | + private void setup_ui () { |
609 | + box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
610 | + |
611 | + titlebar = new Widgets.TitleBar (this); |
612 | + |
613 | + this.set_titlebar (titlebar); |
614 | + box.pack_start (titlebar, false, true); |
615 | + |
616 | + information = new Widgets.Information (); |
617 | + box.pack_start (information, false, true); |
618 | + |
619 | + mainview = new Widgets.MainView (); |
620 | + box.pack_start (mainview, true, true); |
621 | + |
622 | + this.add (box); |
623 | + |
624 | + titlebar.on_connect_request.connect (mainview.notebook.add_connection); |
625 | + titlebar.on_take_screenshot_clicked.connect (() => { |
626 | + (mainview.notebook.current as Widgets.VncConnection).take_screenshot (); |
627 | + }); |
628 | + |
629 | + mainview.on_show_connect_dialog_request.connect (titlebar.show_connect_dialog); |
630 | + mainview.on_open_bookmarks_request.connect (() => { |
631 | + titlebar.bookmarksmenu.popup (null, null, null, 0, Gtk.get_current_event_time ()); |
632 | + }); |
633 | + mainview.notebook.on_connection_message.connect (information.show_text); |
634 | + mainview.notebook.tab_added.connect (() => { |
635 | + titlebar.btn_screenshot.set_sensitive (true); |
636 | + }); |
637 | + mainview.notebook.tab_removed.connect (() => { |
638 | + if (mainview.notebook.n_tabs == 0) { |
639 | + titlebar.btn_screenshot.set_sensitive (false); |
640 | + } |
641 | + }); |
642 | + } |
643 | + } |
644 | } |
645 | \ No newline at end of file |
646 | |
647 | === modified file 'src/SettingsManager.vala' |
648 | --- src/SettingsManager.vala 2014-10-31 16:31:48 +0000 |
649 | +++ src/SettingsManager.vala 2015-07-09 18:17:15 +0000 |
650 | @@ -1,60 +1,60 @@ |
651 | namespace evnc { |
652 | - public class SettingsManager : Object { |
653 | - // Path |
654 | - static const string SETTINGS_PATH = "org.pantheon.evnc"; |
655 | - |
656 | - // Keys |
657 | - static const string BOOKMARK_LIST_KEY = "bookmark-list"; |
658 | - static const string SAVE_NEW_SERVERS_KEY = "save-new-servers"; |
659 | - static const string POINTER_LOCAL_KEY = "pointer-local"; |
660 | - static const string USE_DARK_THEME_KEY = "use-dark-theme"; |
661 | - static const string DISPLAY_MODE_KEY = "display-mode"; |
662 | - static const string READONLY_KEY = "readonly"; |
663 | - static const string LOSSY_ENCODING_KEY = "lossy-encoding"; |
664 | - static const string COLOR_DEPTH_KEY = "color-depth"; |
665 | - |
666 | - // Fields |
667 | - public string[] bookmark_list { get; set; } |
668 | - public bool save_new_servers { get; set; default = false; } |
669 | - public bool pointer_local { get; set; default = true; } |
670 | - public bool use_dark_theme { get; set; default = false; } |
671 | - public int display_mode { get; set; default = 0; } |
672 | - public bool readonly { get; set; default = false; } |
673 | - public bool lossy_encoding { get; set; default = false; } |
674 | - public string color_depth { get; set; default = "default"; } |
675 | - |
676 | - // Events |
677 | - public signal void on_pointer_local_changed (bool new_value); |
678 | - public signal void on_use_dark_theme_changed (bool new_value); |
679 | - public signal void on_display_mode_changed (int new_value); |
680 | - |
681 | - // Settings object |
682 | - public Settings? settings = null; |
683 | - |
684 | - public SettingsManager () { |
685 | - // Connect |
686 | - this.settings = new Settings (SETTINGS_PATH); |
687 | - |
688 | - |
689 | - this.settings.bind (BOOKMARK_LIST_KEY, this, "bookmark-list", SettingsBindFlags.DEFAULT); |
690 | - this.settings.bind (SAVE_NEW_SERVERS_KEY, this, "save-new-servers", SettingsBindFlags.DEFAULT); |
691 | - this.settings.bind (POINTER_LOCAL_KEY, this, "pointer-local", SettingsBindFlags.DEFAULT); |
692 | - this.settings.bind (USE_DARK_THEME_KEY, this, "use-dark-theme", SettingsBindFlags.DEFAULT); |
693 | - this.settings.bind (DISPLAY_MODE_KEY, this, "display-mode", SettingsBindFlags.DEFAULT); |
694 | - this.settings.bind (READONLY_KEY, this, "readonly", SettingsBindFlags.DEFAULT); |
695 | - this.settings.bind (LOSSY_ENCODING_KEY, this, "lossy-encoding", SettingsBindFlags.DEFAULT); |
696 | - this.settings.bind (COLOR_DEPTH_KEY, this, "color-depth", SettingsBindFlags.DEFAULT); |
697 | - |
698 | - // Connect events |
699 | - this.settings.changed[POINTER_LOCAL_KEY].connect (() => { |
700 | - this.on_pointer_local_changed (pointer_local); |
701 | - }); |
702 | - this.settings.changed[USE_DARK_THEME_KEY].connect (() => { |
703 | - this.on_use_dark_theme_changed (use_dark_theme); |
704 | - }); |
705 | - this.settings.changed[DISPLAY_MODE_KEY].connect (() => { |
706 | - this.on_display_mode_changed (display_mode); |
707 | - }); |
708 | - } |
709 | - } |
710 | + public class SettingsManager : Object { |
711 | + // Path |
712 | + static const string SETTINGS_PATH = "org.pantheon.evnc"; |
713 | + |
714 | + // Keys |
715 | + static const string BOOKMARK_LIST_KEY = "bookmark-list"; |
716 | + static const string SAVE_NEW_SERVERS_KEY = "save-new-servers"; |
717 | + static const string POINTER_LOCAL_KEY = "pointer-local"; |
718 | + static const string USE_DARK_THEME_KEY = "use-dark-theme"; |
719 | + static const string DISPLAY_MODE_KEY = "display-mode"; |
720 | + static const string READONLY_KEY = "readonly"; |
721 | + static const string LOSSY_ENCODING_KEY = "lossy-encoding"; |
722 | + static const string COLOR_DEPTH_KEY = "color-depth"; |
723 | + |
724 | + // Fields |
725 | + public string[] bookmark_list { get; set; } |
726 | + public bool save_new_servers { get; set; default = false; } |
727 | + public bool pointer_local { get; set; default = true; } |
728 | + public bool use_dark_theme { get; set; default = false; } |
729 | + public int display_mode { get; set; default = 0; } |
730 | + public bool readonly { get; set; default = false; } |
731 | + public bool lossy_encoding { get; set; default = false; } |
732 | + public string color_depth { get; set; default = "default"; } |
733 | + |
734 | + // Events |
735 | + public signal void on_pointer_local_changed (bool new_value); |
736 | + public signal void on_use_dark_theme_changed (bool new_value); |
737 | + public signal void on_display_mode_changed (int new_value); |
738 | + |
739 | + // Settings object |
740 | + public Settings ? settings = null; |
741 | + |
742 | + public SettingsManager () { |
743 | + // Connect |
744 | + this.settings = new Settings (SETTINGS_PATH); |
745 | + |
746 | + |
747 | + this.settings.bind (BOOKMARK_LIST_KEY, this, "bookmark-list", SettingsBindFlags.DEFAULT); |
748 | + this.settings.bind (SAVE_NEW_SERVERS_KEY, this, "save-new-servers", SettingsBindFlags.DEFAULT); |
749 | + this.settings.bind (POINTER_LOCAL_KEY, this, "pointer-local", SettingsBindFlags.DEFAULT); |
750 | + this.settings.bind (USE_DARK_THEME_KEY, this, "use-dark-theme", SettingsBindFlags.DEFAULT); |
751 | + this.settings.bind (DISPLAY_MODE_KEY, this, "display-mode", SettingsBindFlags.DEFAULT); |
752 | + this.settings.bind (READONLY_KEY, this, "readonly", SettingsBindFlags.DEFAULT); |
753 | + this.settings.bind (LOSSY_ENCODING_KEY, this, "lossy-encoding", SettingsBindFlags.DEFAULT); |
754 | + this.settings.bind (COLOR_DEPTH_KEY, this, "color-depth", SettingsBindFlags.DEFAULT); |
755 | + |
756 | + // Connect events |
757 | + this.settings.changed[POINTER_LOCAL_KEY].connect (() => { |
758 | + this.on_pointer_local_changed (pointer_local); |
759 | + }); |
760 | + this.settings.changed[USE_DARK_THEME_KEY].connect (() => { |
761 | + this.on_use_dark_theme_changed (use_dark_theme); |
762 | + }); |
763 | + this.settings.changed[DISPLAY_MODE_KEY].connect (() => { |
764 | + this.on_display_mode_changed (display_mode); |
765 | + }); |
766 | + } |
767 | + } |
768 | } |
769 | \ No newline at end of file |
770 | |
771 | === modified file 'src/Widgets/BookmarksMenu.vala' |
772 | --- src/Widgets/BookmarksMenu.vala 2014-11-01 00:02:58 +0000 |
773 | +++ src/Widgets/BookmarksMenu.vala 2015-07-09 18:17:15 +0000 |
774 | @@ -17,91 +17,91 @@ |
775 | */ |
776 | |
777 | namespace evnc.Widgets { |
778 | - public class BookmarksMenu : Gtk.Menu { |
779 | - public signal void on_bookmark_selected (string host, string port, string user); |
780 | - public signal void on_new_bookmark_clicked (); |
781 | - |
782 | - private SettingsManager options; |
783 | - |
784 | - public BookmarksMenu () { |
785 | - options = new SettingsManager (); |
786 | - |
787 | - update_menu (); |
788 | - } |
789 | - |
790 | - private void update_menu () { |
791 | - foreach (Gtk.Widget item in this.get_children ()) { |
792 | - this.remove(item); |
793 | - } |
794 | - |
795 | - for (int i = 0; i < options.bookmark_list.length; i++) { |
796 | - var parameters = options.bookmark_list[i].split ("|"); |
797 | - |
798 | - // Parameteranzahl korrekt? |
799 | - if (parameters.length >= 4) { |
800 | - var item = new Gtk.MenuItem.with_label (parameters[0]); |
801 | - var item_sub_menu = new Gtk.Menu (); |
802 | - var item_open = new Gtk.MenuItem.with_label (_("Connect")); |
803 | - var item_remove = new Gtk.MenuItem.with_label (_("Remove")); |
804 | - |
805 | - // FIXME: I need the current iterator for the signals. |
806 | - var index = i; |
807 | - |
808 | - item_open.activate.connect (() => { |
809 | - on_bookmark_selected (parameters[1], parameters[2], parameters[3]); |
810 | - }); |
811 | - |
812 | - item_remove.activate.connect (() => { |
813 | - var bookmarks_new = new string[options.bookmark_list.length - 1]; |
814 | - var count = 0; |
815 | - |
816 | - for (int b = 0; b < options.bookmark_list.length; b++) { |
817 | - if (b != index) { |
818 | - bookmarks_new[count] = options.bookmark_list[b]; |
819 | - count++; |
820 | - } |
821 | - } |
822 | - |
823 | - options.bookmark_list = bookmarks_new; |
824 | - update_menu (); |
825 | - }); |
826 | - |
827 | - item_sub_menu.add (item_open); |
828 | - item_sub_menu.add (item_remove); |
829 | - |
830 | - item.submenu = item_sub_menu; |
831 | - |
832 | - this.add (item); |
833 | - } |
834 | - } |
835 | - |
836 | - if (options.bookmark_list.length > 0) { |
837 | - this.add (new Gtk.SeparatorMenuItem ()); |
838 | - } |
839 | - |
840 | - var create_item = new Gtk.MenuItem.with_label (_("Add new bookmark")); |
841 | - create_item.activate.connect (() => { |
842 | - on_new_bookmark_clicked (); |
843 | - }); |
844 | - |
845 | - this.add (create_item); |
846 | - this.show_all (); |
847 | - } |
848 | - |
849 | - public void add_bookmark (string new_bookmark) { |
850 | - var bookmarks_new = new string[options.bookmark_list.length + 1]; |
851 | - var count = 1; |
852 | - |
853 | - bookmarks_new[0] = new_bookmark; |
854 | - |
855 | - for (int i = 0; i < options.bookmark_list.length; i++) { |
856 | - bookmarks_new[count] = options.bookmark_list[i]; |
857 | - count++; |
858 | - } |
859 | - |
860 | - options.bookmark_list = bookmarks_new; |
861 | - |
862 | - update_menu (); |
863 | - } |
864 | - } |
865 | + public class BookmarksMenu : Gtk.Menu { |
866 | + public signal void on_bookmark_selected (string host, string port, string user); |
867 | + public signal void on_new_bookmark_clicked (); |
868 | + |
869 | + private SettingsManager options; |
870 | + |
871 | + public BookmarksMenu () { |
872 | + options = new SettingsManager (); |
873 | + |
874 | + update_menu (); |
875 | + } |
876 | + |
877 | + private void update_menu () { |
878 | + foreach (Gtk.Widget item in this.get_children ()) { |
879 | + this.remove (item); |
880 | + } |
881 | + |
882 | + for (int i = 0; i < options.bookmark_list.length; i++) { |
883 | + var parameters = options.bookmark_list[i].split ("|"); |
884 | + |
885 | + // Parameteranzahl korrekt? |
886 | + if (parameters.length >= 4) { |
887 | + var item = new Gtk.MenuItem.with_label (parameters[0]); |
888 | + var item_sub_menu = new Gtk.Menu (); |
889 | + var item_open = new Gtk.MenuItem.with_label (_ ("Connect")); |
890 | + var item_remove = new Gtk.MenuItem.with_label (_ ("Remove")); |
891 | + |
892 | + // FIXME: I need the current iterator for the signals. |
893 | + var index = i; |
894 | + |
895 | + item_open.activate.connect (() => { |
896 | + on_bookmark_selected (parameters[1], parameters[2], parameters[3]); |
897 | + }); |
898 | + |
899 | + item_remove.activate.connect (() => { |
900 | + var bookmarks_new = new string[options.bookmark_list.length - 1]; |
901 | + var count = 0; |
902 | + |
903 | + for (int b = 0; b < options.bookmark_list.length; b++) { |
904 | + if (b != index) { |
905 | + bookmarks_new[count] = options.bookmark_list[b]; |
906 | + count++; |
907 | + } |
908 | + } |
909 | + |
910 | + options.bookmark_list = bookmarks_new; |
911 | + update_menu (); |
912 | + }); |
913 | + |
914 | + item_sub_menu.add (item_open); |
915 | + item_sub_menu.add (item_remove); |
916 | + |
917 | + item.submenu = item_sub_menu; |
918 | + |
919 | + this.add (item); |
920 | + } |
921 | + } |
922 | + |
923 | + if (options.bookmark_list.length > 0) { |
924 | + this.add (new Gtk.SeparatorMenuItem ()); |
925 | + } |
926 | + |
927 | + var create_item = new Gtk.MenuItem.with_label (_ ("Add new bookmark")); |
928 | + create_item.activate.connect (() => { |
929 | + on_new_bookmark_clicked (); |
930 | + }); |
931 | + |
932 | + this.add (create_item); |
933 | + this.show_all (); |
934 | + } |
935 | + |
936 | + public void add_bookmark (string new_bookmark) { |
937 | + var bookmarks_new = new string[options.bookmark_list.length + 1]; |
938 | + var count = 1; |
939 | + |
940 | + bookmarks_new[0] = new_bookmark; |
941 | + |
942 | + for (int i = 0; i < options.bookmark_list.length; i++) { |
943 | + bookmarks_new[count] = options.bookmark_list[i]; |
944 | + count++; |
945 | + } |
946 | + |
947 | + options.bookmark_list = bookmarks_new; |
948 | + |
949 | + update_menu (); |
950 | + } |
951 | + } |
952 | } |
953 | \ No newline at end of file |
954 | |
955 | === modified file 'src/Widgets/Information.vala' |
956 | --- src/Widgets/Information.vala 2014-10-31 16:31:48 +0000 |
957 | +++ src/Widgets/Information.vala 2015-07-09 18:17:15 +0000 |
958 | @@ -17,49 +17,50 @@ |
959 | */ |
960 | |
961 | namespace evnc.Widgets { |
962 | - public class Information : Gtk.InfoBar { |
963 | - public Information () { |
964 | - // Hide the bar |
965 | - this.set_no_show_all (true); |
966 | - this.set_visible (false); |
967 | - } |
968 | - |
969 | - public void show_text (Gtk.MessageType info_type, string info_message) { |
970 | - this.set_no_show_all (false); |
971 | - this.set_visible (true); |
972 | - |
973 | - // Remove old objects |
974 | - ((Gtk.Box)this.get_content_area ()).get_children ().foreach ((widg) => { |
975 | - if (widg != null) |
976 | - widg.destroy (); |
977 | - }); |
978 | - |
979 | - this.set_message_type (info_type); |
980 | - |
981 | - var info_label = new Gtk.Label (info_message); |
982 | - info_label.ellipsize = Pango.EllipsizeMode.END; |
983 | - info_label.use_markup = true; |
984 | - info_label.set_markup (info_message); |
985 | - |
986 | - var info_container = this.get_content_area () as Gtk.Box; |
987 | - info_container.orientation = Gtk.Orientation.HORIZONTAL; |
988 | - info_container.pack_start (info_label, false, false, 0); |
989 | - |
990 | - this.set_show_close_button (true); |
991 | - |
992 | - // Close Event |
993 | - this.response.connect (() => { |
994 | - this.set_no_show_all (true); |
995 | - this.set_visible (false); |
996 | - }); |
997 | - |
998 | - this.show_all (); |
999 | - |
1000 | - Timeout.add (5000, () => { |
1001 | - this.set_no_show_all (true); |
1002 | - this.set_visible (false); |
1003 | - return false; |
1004 | - }, Priority.DEFAULT); |
1005 | - } |
1006 | - } |
1007 | + public class Information : Gtk.InfoBar { |
1008 | + public Information () { |
1009 | + // Hide the bar |
1010 | + this.set_no_show_all (true); |
1011 | + this.set_visible (false); |
1012 | + } |
1013 | + |
1014 | + public void show_text (Gtk.MessageType info_type, string info_message) { |
1015 | + this.set_no_show_all (false); |
1016 | + this.set_visible (true); |
1017 | + |
1018 | + // Remove old objects |
1019 | + ((Gtk.Box)this.get_content_area ()).get_children ().foreach ((widg) => { |
1020 | + if (widg != null) { |
1021 | + widg.destroy (); |
1022 | + } |
1023 | + }); |
1024 | + |
1025 | + this.set_message_type (info_type); |
1026 | + |
1027 | + var info_label = new Gtk.Label (info_message); |
1028 | + info_label.ellipsize = Pango.EllipsizeMode.END; |
1029 | + info_label.use_markup = true; |
1030 | + info_label.set_markup (info_message); |
1031 | + |
1032 | + var info_container = this.get_content_area () as Gtk.Box; |
1033 | + info_container.orientation = Gtk.Orientation.HORIZONTAL; |
1034 | + info_container.pack_start (info_label, false, false, 0); |
1035 | + |
1036 | + this.set_show_close_button (true); |
1037 | + |
1038 | + // Close Event |
1039 | + this.response.connect (() => { |
1040 | + this.set_no_show_all (true); |
1041 | + this.set_visible (false); |
1042 | + }); |
1043 | + |
1044 | + this.show_all (); |
1045 | + |
1046 | + Timeout.add (5000, () => { |
1047 | + this.set_no_show_all (true); |
1048 | + this.set_visible (false); |
1049 | + return false; |
1050 | + }, Priority.DEFAULT); |
1051 | + } |
1052 | + } |
1053 | } |
1054 | \ No newline at end of file |
1055 | |
1056 | === modified file 'src/Widgets/MainView.vala' |
1057 | --- src/Widgets/MainView.vala 2014-11-01 17:23:58 +0000 |
1058 | +++ src/Widgets/MainView.vala 2015-07-09 18:17:15 +0000 |
1059 | @@ -17,52 +17,53 @@ |
1060 | */ |
1061 | |
1062 | namespace evnc.Widgets { |
1063 | - public class MainView : Gtk.Stack { |
1064 | - public signal void on_show_connect_dialog_request (bool save_as_bookmark); |
1065 | - public signal void on_open_bookmarks_request (); |
1066 | - |
1067 | - private SettingsManager options; |
1068 | - |
1069 | - private Granite.Widgets.Welcome welcome; |
1070 | - |
1071 | - public Widgets.Notebook notebook; |
1072 | - |
1073 | - public MainView () { |
1074 | - options = new SettingsManager (); |
1075 | - |
1076 | - welcome = new Granite.Widgets.Welcome (_("Connect to a VNC-Server"), _("Create a new connection or choose one of your bookmarks.")); |
1077 | - welcome.append ("add", _("New Connection"), _("Enter hostname, port and your credentials.")); |
1078 | - welcome.append ("help-about", _("Open Bookmarks"), _("Choose a server from your bookmarks.")); |
1079 | - welcome.activated.connect ((index) => { |
1080 | - if (index == 0) { |
1081 | - on_show_connect_dialog_request (options.save_new_servers); |
1082 | - } else if (index == 1) { |
1083 | - on_open_bookmarks_request (); |
1084 | - } |
1085 | - }); |
1086 | - |
1087 | - this.add_named (welcome, "welcome"); |
1088 | - |
1089 | - notebook = new Widgets.Notebook (); |
1090 | - notebook.tab_added.connect (() => { |
1091 | - this.transition_duration = 1200; |
1092 | - this.transition_type = Gtk.StackTransitionType.OVER_LEFT; |
1093 | - this.set_visible_child_name ("notebook"); |
1094 | - }); |
1095 | - notebook.tab_removed.connect (() => { |
1096 | - if (notebook.n_tabs == 0) { |
1097 | - this.transition_duration = 400; |
1098 | - this.transition_type = Gtk.StackTransitionType.CROSSFADE; |
1099 | - this.set_visible_child_name ("welcome"); |
1100 | - } |
1101 | - }); |
1102 | - notebook.new_tab_requested.connect (() => { |
1103 | - on_show_connect_dialog_request (options.save_new_servers); |
1104 | - }); |
1105 | - |
1106 | - this.add_named (notebook, "notebook"); |
1107 | - this.show_all (); |
1108 | - this.set_visible_child_name ("welcome"); |
1109 | - } |
1110 | - } |
1111 | + public class MainView : Gtk.Stack { |
1112 | + public signal void on_show_connect_dialog_request (bool save_as_bookmark); |
1113 | + public signal void on_open_bookmarks_request (); |
1114 | + |
1115 | + private SettingsManager options; |
1116 | + |
1117 | + private Granite.Widgets.Welcome welcome; |
1118 | + |
1119 | + public Widgets.Notebook notebook; |
1120 | + |
1121 | + public MainView () { |
1122 | + options = new SettingsManager (); |
1123 | + |
1124 | + welcome = new Granite.Widgets.Welcome (_ ("Connect to a VNC-Server"), |
1125 | + _ ("Create a new connection or choose one of your bookmarks.")); |
1126 | + welcome.append ("add", _ ("New Connection"), _ ("Enter hostname, port and your credentials.")); |
1127 | + welcome.append ("help-about", _ ("Open Bookmarks"), _ ("Choose a server from your bookmarks.")); |
1128 | + welcome.activated.connect ((index) => { |
1129 | + if (index == 0) { |
1130 | + on_show_connect_dialog_request (options.save_new_servers); |
1131 | + } else if (index == 1) { |
1132 | + on_open_bookmarks_request (); |
1133 | + } |
1134 | + }); |
1135 | + |
1136 | + this.add_named (welcome, "welcome"); |
1137 | + |
1138 | + notebook = new Widgets.Notebook (); |
1139 | + notebook.tab_added.connect (() => { |
1140 | + this.transition_duration = 1200; |
1141 | + this.transition_type = Gtk.StackTransitionType.OVER_LEFT; |
1142 | + this.set_visible_child_name ("notebook"); |
1143 | + }); |
1144 | + notebook.tab_removed.connect (() => { |
1145 | + if (notebook.n_tabs == 0) { |
1146 | + this.transition_duration = 400; |
1147 | + this.transition_type = Gtk.StackTransitionType.CROSSFADE; |
1148 | + this.set_visible_child_name ("welcome"); |
1149 | + } |
1150 | + }); |
1151 | + notebook.new_tab_requested.connect (() => { |
1152 | + on_show_connect_dialog_request (options.save_new_servers); |
1153 | + }); |
1154 | + |
1155 | + this.add_named (notebook, "notebook"); |
1156 | + this.show_all (); |
1157 | + this.set_visible_child_name ("welcome"); |
1158 | + } |
1159 | + } |
1160 | } |
1161 | \ No newline at end of file |
1162 | |
1163 | === modified file 'src/Widgets/Notebook.vala' |
1164 | --- src/Widgets/Notebook.vala 2014-11-01 00:02:58 +0000 |
1165 | +++ src/Widgets/Notebook.vala 2015-07-09 18:17:15 +0000 |
1166 | @@ -17,31 +17,31 @@ |
1167 | */ |
1168 | |
1169 | namespace evnc.Widgets { |
1170 | - public class Notebook : Granite.Widgets.DynamicNotebook { |
1171 | - public signal void on_connection_message (Gtk.MessageType info_type, string info_message); |
1172 | - |
1173 | - public Notebook () { |
1174 | - this.allow_drag = true; |
1175 | - this.show_all (); |
1176 | - this.tab_removed.connect ((tab) => { |
1177 | - (tab as Widgets.VncConnection).display.close (); |
1178 | - }); |
1179 | - } |
1180 | - |
1181 | - public void add_connection (string host, string port, string user) { |
1182 | - var connection = new Widgets.VncConnection (host, port, user); |
1183 | - connection.display.vnc_auth_failure.connect (() => { |
1184 | - on_connection_message (Gtk.MessageType.ERROR, _("Authentification failed. Wrong username or password?")); |
1185 | - }); |
1186 | - connection.display.vnc_auth_unsupported.connect (() => { |
1187 | - on_connection_message (Gtk.MessageType.ERROR, _("Authentification not supported!")); |
1188 | - }); |
1189 | - connection.on_save_screenshot_exception.connect ((message) => { |
1190 | - on_connection_message (Gtk.MessageType.ERROR, message); |
1191 | - }); |
1192 | - |
1193 | - this.insert_tab (connection, -1 ); |
1194 | - this.current = connection; |
1195 | - } |
1196 | - } |
1197 | + public class Notebook : Granite.Widgets.DynamicNotebook { |
1198 | + public signal void on_connection_message (Gtk.MessageType info_type, string info_message); |
1199 | + |
1200 | + public Notebook () { |
1201 | + this.allow_drag = true; |
1202 | + this.show_all (); |
1203 | + this.tab_removed.connect ((tab) => { |
1204 | + (tab as Widgets.VncConnection).display.close (); |
1205 | + }); |
1206 | + } |
1207 | + |
1208 | + public void add_connection (string host, string port, string user) { |
1209 | + var connection = new Widgets.VncConnection (host, port, user); |
1210 | + connection.display.vnc_auth_failure.connect (() => { |
1211 | + on_connection_message (Gtk.MessageType.ERROR, _ ("Authentification failed. Wrong username or password?")); |
1212 | + }); |
1213 | + connection.display.vnc_auth_unsupported.connect (() => { |
1214 | + on_connection_message (Gtk.MessageType.ERROR, _ ("Authentification not supported!")); |
1215 | + }); |
1216 | + connection.on_save_screenshot_exception.connect ((message) => { |
1217 | + on_connection_message (Gtk.MessageType.ERROR, message); |
1218 | + }); |
1219 | + |
1220 | + this.insert_tab (connection, -1 ); |
1221 | + this.current = connection; |
1222 | + } |
1223 | + } |
1224 | } |
1225 | \ No newline at end of file |
1226 | |
1227 | === modified file 'src/Widgets/TitleBar.vala' |
1228 | --- src/Widgets/TitleBar.vala 2014-11-01 17:23:58 +0000 |
1229 | +++ src/Widgets/TitleBar.vala 2015-07-09 18:17:15 +0000 |
1230 | @@ -17,126 +17,129 @@ |
1231 | */ |
1232 | |
1233 | namespace evnc.Widgets { |
1234 | - public class TitleBar : Gtk.HeaderBar { |
1235 | - public signal void on_take_screenshot_clicked (); |
1236 | - public signal void on_connect_request (string host, string port, string user); |
1237 | - |
1238 | - private SettingsManager options; |
1239 | - |
1240 | - private Granite.Widgets.ModeButton display_mode; |
1241 | - |
1242 | - public Gtk.ToolButton btn_screenshot; |
1243 | - |
1244 | - private Gtk.ToggleToolButton btn_readonly; |
1245 | - |
1246 | - private Gtk.MenuToolButton btn_connect; |
1247 | - public Widgets.BookmarksMenu bookmarksmenu; |
1248 | - |
1249 | - private Gtk.Menu main_menu; |
1250 | - private Gtk.MenuItem preferences_item; |
1251 | - private Granite.Widgets.AppMenu app_menu; |
1252 | - |
1253 | - public TitleBar (MainWindow parent) { |
1254 | - options = new SettingsManager (); |
1255 | - |
1256 | - this.get_style_context ().add_class ("primary-toolbar"); |
1257 | - this.show_close_button = true; |
1258 | - this.set_title (_("VNC-Client")); |
1259 | - |
1260 | - display_mode = new Granite.Widgets.ModeButton (); |
1261 | - display_mode.set_margin_top (4); |
1262 | - display_mode.set_margin_bottom (4); |
1263 | - display_mode.append_icon ("zoom-fit-best-symbolic", Gtk.IconSize.BUTTON); |
1264 | - display_mode.append_icon ("zoom-original-symbolic", Gtk.IconSize.BUTTON); |
1265 | - // FIXME: Using settings.bind only, won't work if you click on the buttons. |
1266 | - display_mode.mode_changed.connect (() =>{ |
1267 | - options.display_mode = display_mode.selected; |
1268 | - }); |
1269 | - options.settings.bind("display-mode", display_mode, "selected", SettingsBindFlags.DEFAULT); |
1270 | - |
1271 | - |
1272 | - this.pack_start (display_mode); |
1273 | - |
1274 | - btn_screenshot = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("camera-photo", Gtk.IconSize.SMALL_TOOLBAR), null); |
1275 | - btn_screenshot.set_tooltip_text (_("Take Screenshot")); |
1276 | - btn_screenshot.set_sensitive (false); |
1277 | - btn_screenshot.clicked.connect (() => { |
1278 | - on_take_screenshot_clicked (); |
1279 | - }); |
1280 | - |
1281 | - this.pack_start (btn_screenshot); |
1282 | - |
1283 | - btn_readonly = new Gtk.ToggleToolButton (); |
1284 | - btn_readonly.set_icon_name("locked"); |
1285 | - btn_readonly.set_tooltip_text (_("Input Lock")); |
1286 | - options.settings.bind("readonly", btn_readonly, "active", SettingsBindFlags.DEFAULT); |
1287 | - |
1288 | - this.pack_start (btn_readonly); |
1289 | - |
1290 | - preferences_item = new Gtk.MenuItem.with_label (_("Preferences")); |
1291 | - preferences_item.activate.connect (() => { |
1292 | - var dialog = new Dialogs.PreferencesDialog (); |
1293 | - dialog.response.connect ((source, response_id) => { |
1294 | - dialog.destroy (); |
1295 | - }); |
1296 | - }); |
1297 | - |
1298 | - main_menu = new Gtk.Menu (); |
1299 | - main_menu.add (preferences_item); |
1300 | - |
1301 | - app_menu = parent.app.create_appmenu (main_menu); |
1302 | - |
1303 | - this.pack_end (app_menu); |
1304 | - |
1305 | - btn_connect = new Gtk.MenuToolButton (new Gtk.Image.from_icon_name ("user-bookmarks", Gtk.IconSize.SMALL_TOOLBAR), null); |
1306 | - btn_connect.set_tooltip_text (_("Server list")); |
1307 | - btn_connect.clicked.connect (() => { |
1308 | - show_connect_dialog (options.save_new_servers); |
1309 | - }); |
1310 | - |
1311 | - this.pack_end (btn_connect); |
1312 | - |
1313 | - bookmarksmenu = new Widgets.BookmarksMenu (); |
1314 | - bookmarksmenu.on_bookmark_selected.connect ((host, port, user) => { |
1315 | - on_connect_request (host, port, user); |
1316 | - }); |
1317 | - bookmarksmenu.on_new_bookmark_clicked.connect (() => { |
1318 | - show_connect_dialog (true); |
1319 | - }); |
1320 | - btn_connect.set_menu (bookmarksmenu); |
1321 | - } |
1322 | - |
1323 | - public void show_connect_dialog (bool save_as_bookmark) { |
1324 | - var dialog = new Dialogs.ConnectDialog (); |
1325 | - dialog.btn_bookmark.set_active (save_as_bookmark); |
1326 | - dialog.response.connect ((source, response_id) => { |
1327 | - switch (response_id) { |
1328 | - case Gtk.ResponseType.CLOSE: |
1329 | - dialog.destroy (); |
1330 | - break; |
1331 | - case Gtk.ResponseType.APPLY: |
1332 | - on_connect_request (dialog.entry_host.text, dialog.entry_port.text, dialog.entry_user.text); |
1333 | - |
1334 | - if (dialog.btn_bookmark.active) { |
1335 | - var new_bookmark = ""; |
1336 | - |
1337 | - if (dialog.entry_bookmark.text == "") { |
1338 | - if (dialog.entry_user.text != "") { |
1339 | - new_bookmark += dialog.entry_user.text + "@"; |
1340 | - } |
1341 | - new_bookmark += dialog.entry_host.text + ":" + dialog.entry_port.text; |
1342 | - } else { |
1343 | - new_bookmark += dialog.entry_bookmark.text.replace ("|", "/"); |
1344 | - } |
1345 | - |
1346 | - new_bookmark += "|" + dialog.entry_host.text + "|" + dialog.entry_port.text + "|" + dialog.entry_user.text; |
1347 | - bookmarksmenu.add_bookmark (new_bookmark); |
1348 | - } |
1349 | - |
1350 | - dialog.destroy (); |
1351 | - break; |
1352 | - } |
1353 | - }); |
1354 | - } |
1355 | - } |
1356 | + public class TitleBar : Gtk.HeaderBar { |
1357 | + public signal void on_take_screenshot_clicked (); |
1358 | + public signal void on_connect_request (string host, string port, string user); |
1359 | + |
1360 | + private SettingsManager options; |
1361 | + |
1362 | + private Granite.Widgets.ModeButton display_mode; |
1363 | + |
1364 | + public Gtk.ToolButton btn_screenshot; |
1365 | + |
1366 | + private Gtk.ToggleToolButton btn_readonly; |
1367 | + |
1368 | + private Gtk.MenuToolButton btn_connect; |
1369 | + public Widgets.BookmarksMenu bookmarksmenu; |
1370 | + |
1371 | + private Gtk.Menu main_menu; |
1372 | + private Gtk.MenuItem preferences_item; |
1373 | + private Granite.Widgets.AppMenu app_menu; |
1374 | + |
1375 | + public TitleBar (MainWindow parent) { |
1376 | + options = new SettingsManager (); |
1377 | + |
1378 | + this.get_style_context ().add_class ("primary-toolbar"); |
1379 | + this.show_close_button = true; |
1380 | + this.set_title (_ ("VNC-Client")); |
1381 | + |
1382 | + display_mode = new Granite.Widgets.ModeButton (); |
1383 | + display_mode.set_margin_top (4); |
1384 | + display_mode.set_margin_bottom (4); |
1385 | + display_mode.append_icon ("zoom-fit-best-symbolic", Gtk.IconSize.BUTTON); |
1386 | + display_mode.append_icon ("zoom-original-symbolic", Gtk.IconSize.BUTTON); |
1387 | + // FIXME: Using settings.bind only, won't work if you click on the buttons. |
1388 | + display_mode.mode_changed.connect (() => { |
1389 | + options.display_mode = display_mode.selected; |
1390 | + }); |
1391 | + options.settings.bind ("display-mode", display_mode, "selected", SettingsBindFlags.DEFAULT); |
1392 | + |
1393 | + |
1394 | + this.pack_start (display_mode); |
1395 | + |
1396 | + btn_screenshot = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("camera-photo", Gtk.IconSize.SMALL_TOOLBAR), null); |
1397 | + btn_screenshot.set_tooltip_text (_ ("Take Screenshot")); |
1398 | + btn_screenshot.set_sensitive (false); |
1399 | + btn_screenshot.clicked.connect (() => { |
1400 | + on_take_screenshot_clicked (); |
1401 | + }); |
1402 | + |
1403 | + this.pack_start (btn_screenshot); |
1404 | + |
1405 | + btn_readonly = new Gtk.ToggleToolButton (); |
1406 | + btn_readonly.set_icon_name ("locked"); |
1407 | + btn_readonly.set_tooltip_text (_ ("Input Lock")); |
1408 | + options.settings.bind ("readonly", btn_readonly, "active", SettingsBindFlags.DEFAULT); |
1409 | + |
1410 | + this.pack_start (btn_readonly); |
1411 | + |
1412 | + preferences_item = new Gtk.MenuItem.with_label (_ ("Preferences")); |
1413 | + preferences_item.activate.connect (() => { |
1414 | + var dialog = new Dialogs.PreferencesDialog (); |
1415 | + dialog.response.connect ((source, response_id) => { |
1416 | + dialog.destroy (); |
1417 | + }); |
1418 | + }); |
1419 | + |
1420 | + main_menu = new Gtk.Menu (); |
1421 | + main_menu.add (preferences_item); |
1422 | + |
1423 | + app_menu = parent.app.create_appmenu (main_menu); |
1424 | + |
1425 | + this.pack_end (app_menu); |
1426 | + |
1427 | + btn_connect = new Gtk.MenuToolButton (new Gtk.Image.from_icon_name ("user-bookmarks", Gtk.IconSize.SMALL_TOOLBAR), |
1428 | + null); |
1429 | + btn_connect.set_tooltip_text (_ ("Server list")); |
1430 | + btn_connect.clicked.connect (() => { |
1431 | + show_connect_dialog (options.save_new_servers); |
1432 | + }); |
1433 | + |
1434 | + this.pack_end (btn_connect); |
1435 | + |
1436 | + bookmarksmenu = new Widgets.BookmarksMenu (); |
1437 | + bookmarksmenu.on_bookmark_selected.connect ((host, port, user) => { |
1438 | + on_connect_request (host, port, user); |
1439 | + }); |
1440 | + bookmarksmenu.on_new_bookmark_clicked.connect (() => { |
1441 | + show_connect_dialog (true); |
1442 | + }); |
1443 | + btn_connect.set_menu (bookmarksmenu); |
1444 | + } |
1445 | + |
1446 | + public void show_connect_dialog (bool save_as_bookmark) { |
1447 | + var dialog = new Dialogs.ConnectDialog (); |
1448 | + dialog.btn_bookmark.set_active (save_as_bookmark); |
1449 | + dialog.response.connect ((source, response_id) => { |
1450 | + switch (response_id) { |
1451 | + case Gtk.ResponseType.CLOSE: |
1452 | + dialog.destroy (); |
1453 | + break; |
1454 | + |
1455 | + case Gtk.ResponseType.APPLY: |
1456 | + on_connect_request (dialog.entry_host.text, dialog.entry_port.text, dialog.entry_user.text); |
1457 | + |
1458 | + if (dialog.btn_bookmark.active) { |
1459 | + var new_bookmark = ""; |
1460 | + |
1461 | + if (dialog.entry_bookmark.text == "") { |
1462 | + if (dialog.entry_user.text != "") { |
1463 | + new_bookmark += dialog.entry_user.text + "@"; |
1464 | + } |
1465 | + |
1466 | + new_bookmark += dialog.entry_host.text + ":" + dialog.entry_port.text; |
1467 | + } else { |
1468 | + new_bookmark += dialog.entry_bookmark.text.replace ("|", "/"); |
1469 | + } |
1470 | + |
1471 | + new_bookmark += "|" + dialog.entry_host.text + "|" + dialog.entry_port.text + "|" + dialog.entry_user.text; |
1472 | + bookmarksmenu.add_bookmark (new_bookmark); |
1473 | + } |
1474 | + |
1475 | + dialog.destroy (); |
1476 | + break; |
1477 | + } |
1478 | + }); |
1479 | + } |
1480 | + } |
1481 | } |
1482 | \ No newline at end of file |
1483 | |
1484 | === modified file 'src/Widgets/VncConnection.vala' |
1485 | --- src/Widgets/VncConnection.vala 2014-11-01 00:02:58 +0000 |
1486 | +++ src/Widgets/VncConnection.vala 2015-07-09 18:17:15 +0000 |
1487 | @@ -17,201 +17,212 @@ |
1488 | */ |
1489 | |
1490 | namespace evnc.Widgets { |
1491 | - public class VncConnection : Granite.Widgets.Tab { |
1492 | - public signal void on_save_screenshot_exception (string message); |
1493 | - |
1494 | - public string host; |
1495 | - public string port; |
1496 | - public string user; |
1497 | - public string desc; |
1498 | - |
1499 | - private SettingsManager options; |
1500 | - |
1501 | - private Gtk.Grid grid; |
1502 | - |
1503 | - private Gtk.ScrolledWindow scrolledwindow; |
1504 | - |
1505 | - private Gtk.Viewport viewport; |
1506 | - |
1507 | - public Vnc.Display display; |
1508 | - |
1509 | - public VncConnection (string host, string port, string user) { |
1510 | - desc = _("Connecting..."); |
1511 | - this.label = desc; |
1512 | - |
1513 | - options = new SettingsManager (); |
1514 | - options.on_display_mode_changed.connect ((val) => { |
1515 | - set_size_mode (val); |
1516 | - }); |
1517 | - |
1518 | - grid = new Gtk.Grid (); |
1519 | - scrolledwindow = new Gtk.ScrolledWindow (null, null); |
1520 | - viewport = new Gtk.Viewport (null, null); |
1521 | - display = new Vnc.Display (); |
1522 | - |
1523 | - viewport.add (display); |
1524 | - scrolledwindow.add (viewport); |
1525 | - grid.attach (scrolledwindow, 0, 0, 1, 1); |
1526 | - |
1527 | - scrolledwindow.set_hexpand (true); |
1528 | - scrolledwindow.set_vexpand (true); |
1529 | - scrolledwindow.draw.connect (() => { |
1530 | - if (options.display_mode == 0) { |
1531 | - update_view_border (); |
1532 | - } |
1533 | - |
1534 | - return false; |
1535 | - }); |
1536 | - |
1537 | - var bg_color = Gdk.RGBA(); |
1538 | - bg_color.red = 0; |
1539 | - bg_color.green = 0; |
1540 | - bg_color.blue = 0; |
1541 | - bg_color.alpha = 1; |
1542 | - scrolledwindow.override_background_color (Gtk.StateFlags.NORMAL, bg_color); |
1543 | - |
1544 | - this.page = grid; |
1545 | - |
1546 | - display.set_credential (Vnc.DisplayCredential.USERNAME, user); |
1547 | - display.set_credential (Vnc.DisplayCredential.CLIENTNAME, "evnc"); |
1548 | - display.set_pointer_grab (true); |
1549 | - display.set_keyboard_grab (true); |
1550 | - display.set_pointer_local (options.pointer_local); |
1551 | - display.set_lossy_encoding (options.lossy_encoding); |
1552 | - display.vnc_disconnected.connect (() => { |
1553 | - this.close (); |
1554 | - }); |
1555 | - display.vnc_connected.connect (() => { |
1556 | - desc = _("Logging in..."); |
1557 | - this.label = desc; |
1558 | - }); |
1559 | - display.vnc_initialized.connect (() => { |
1560 | - desc = ""; |
1561 | - if (user != "") { |
1562 | - desc += user + "@"; |
1563 | - } |
1564 | - desc += host + ":" + port; |
1565 | - this.label = desc; |
1566 | - }); |
1567 | - display.vnc_auth_credential.connect ((cred) => { |
1568 | - var input_box = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, |
1569 | - Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, _("Password required!")); |
1570 | - input_box.title = _("Connect to:") + " " + host; |
1571 | - |
1572 | - var pass_entry = new Gtk.Entry (); |
1573 | - pass_entry.set_size_request (400, 0); |
1574 | - pass_entry.set_visibility (false); |
1575 | - pass_entry.caps_lock_warning = true; |
1576 | - pass_entry.set_placeholder_text (_("Password")); |
1577 | - pass_entry.margin_start = 12; |
1578 | - pass_entry.margin_end = 12; |
1579 | - |
1580 | - input_box.get_content_area ().pack_end (pass_entry, true, false, 0); |
1581 | - input_box.show_all (); |
1582 | - |
1583 | - if (input_box.run () == Gtk.ResponseType.OK) { |
1584 | - display.set_credential (Vnc.DisplayCredential.PASSWORD, pass_entry.get_text ()); |
1585 | - } else { |
1586 | - this.close (); |
1587 | - } |
1588 | - |
1589 | - input_box.destroy (); |
1590 | - }); |
1591 | - |
1592 | - set_color_depth (options.color_depth); |
1593 | - options.settings.bind("readonly", display, "read_only", SettingsBindFlags.DEFAULT); |
1594 | - |
1595 | - if (display.open_host (host, port)) { |
1596 | - this.host = host; |
1597 | - this.port = port; |
1598 | - this.user = user; |
1599 | - } |
1600 | - |
1601 | - set_size_mode (options.display_mode); |
1602 | - } |
1603 | - |
1604 | - public void take_screenshot () { |
1605 | - var img = display.get_pixbuf (); |
1606 | - |
1607 | - var save_dialog = new Gtk.FileChooserDialog (_("Save the screenshot"), null, Gtk.FileChooserAction.SAVE, |
1608 | - _("Cancel"), Gtk.ResponseType.CANCEL, _("Save"), Gtk.ResponseType.ACCEPT); |
1609 | - |
1610 | - var file_filter = new Gtk.FileFilter (); |
1611 | - file_filter.add_mime_type ("image/jpeg"); |
1612 | - |
1613 | - save_dialog.set_filter (file_filter); |
1614 | - |
1615 | - var preview_image = new Gtk.Image (); |
1616 | - preview_image.set_from_pixbuf (img.scale_simple (150, (int)(((float)150 / (float)img.width) * img.height), Gdk.InterpType.BILINEAR)); |
1617 | - |
1618 | - save_dialog.set_preview_widget (preview_image); |
1619 | - |
1620 | - preview_image.show (); |
1621 | - |
1622 | - if (save_dialog.run () == Gtk.ResponseType.ACCEPT) { |
1623 | - try { |
1624 | - img.save (save_dialog.get_filename (), "jpeg"); |
1625 | - } catch (Error ex) { |
1626 | - on_save_screenshot_exception (ex.message); |
1627 | - } |
1628 | - } |
1629 | - |
1630 | - save_dialog.close (); |
1631 | - save_dialog.destroy (); |
1632 | - } |
1633 | - |
1634 | - private void update_view_border () { |
1635 | - if (scrolledwindow.get_allocated_width () > 0 && scrolledwindow.get_allocated_height () > 0 && display.width > 0 && display.height > 0) { |
1636 | - if (((float)scrolledwindow.get_allocated_width () / (float)display.width) * (float)display.height > scrolledwindow.get_allocated_height ()) { |
1637 | - int border_size = (int)(((float)scrolledwindow.get_allocated_width () - (((float)scrolledwindow.get_allocated_height () / (float)display.height) * (float)display.width)) / 2); |
1638 | - viewport.margin_start = border_size; |
1639 | - viewport.margin_end = border_size; |
1640 | - viewport.margin_top = 0; |
1641 | - viewport.margin_bottom = 0; |
1642 | - } else { |
1643 | - int border_size = (int)(((float)scrolledwindow.get_allocated_height () - (((float)scrolledwindow.get_allocated_width () / (float)display.width) * (float)display.height)) / 2); |
1644 | - viewport.margin_start = 0; |
1645 | - viewport.margin_end = 0; |
1646 | - viewport.margin_top = border_size; |
1647 | - viewport.margin_bottom = border_size; |
1648 | - } |
1649 | - } |
1650 | - } |
1651 | - |
1652 | - private void set_size_mode (int val) { |
1653 | - if (val == 0) { |
1654 | - display.force_size = false; |
1655 | - display.scaling = true; |
1656 | - display.set_size_request (0, 0); |
1657 | - |
1658 | - update_view_border (); |
1659 | - } else { |
1660 | - viewport.margin = 0; |
1661 | - |
1662 | - display.force_size = true; |
1663 | - display.scaling = false; |
1664 | - display.set_size_request (display.width, display.height); |
1665 | - } |
1666 | - } |
1667 | - |
1668 | - private void set_color_depth (string val) { |
1669 | - switch (val) { |
1670 | - case "default": |
1671 | - display.set_depth (Vnc.DisplayDepthColor.DEFAULT); |
1672 | - break; |
1673 | - case "full": |
1674 | - display.set_depth (Vnc.DisplayDepthColor.FULL); |
1675 | - break; |
1676 | - case "medium": |
1677 | - display.set_depth (Vnc.DisplayDepthColor.MEDIUM); |
1678 | - break; |
1679 | - case "low": |
1680 | - display.set_depth (Vnc.DisplayDepthColor.LOW); |
1681 | - break; |
1682 | - case "ultra low": |
1683 | - display.set_depth (Vnc.DisplayDepthColor.ULTRA_LOW); |
1684 | - break; |
1685 | - } |
1686 | - } |
1687 | - } |
1688 | + public class VncConnection : Granite.Widgets.Tab { |
1689 | + public signal void on_save_screenshot_exception (string message); |
1690 | + |
1691 | + public string host; |
1692 | + public string port; |
1693 | + public string user; |
1694 | + public string desc; |
1695 | + |
1696 | + private SettingsManager options; |
1697 | + |
1698 | + private Gtk.Grid grid; |
1699 | + |
1700 | + private Gtk.ScrolledWindow scrolledwindow; |
1701 | + |
1702 | + private Gtk.Viewport viewport; |
1703 | + |
1704 | + public Vnc.Display display; |
1705 | + |
1706 | + public VncConnection (string host, string port, string user) { |
1707 | + desc = _ ("Connecting..."); |
1708 | + this.label = desc; |
1709 | + |
1710 | + options = new SettingsManager (); |
1711 | + options.on_display_mode_changed.connect ((val) => { |
1712 | + set_size_mode (val); |
1713 | + }); |
1714 | + |
1715 | + grid = new Gtk.Grid (); |
1716 | + scrolledwindow = new Gtk.ScrolledWindow (null, null); |
1717 | + viewport = new Gtk.Viewport (null, null); |
1718 | + display = new Vnc.Display (); |
1719 | + |
1720 | + viewport.add (display); |
1721 | + scrolledwindow.add (viewport); |
1722 | + grid.attach (scrolledwindow, 0, 0, 1, 1); |
1723 | + |
1724 | + scrolledwindow.set_hexpand (true); |
1725 | + scrolledwindow.set_vexpand (true); |
1726 | + scrolledwindow.draw.connect (() => { |
1727 | + if (options.display_mode == 0) { |
1728 | + update_view_border (); |
1729 | + } |
1730 | + |
1731 | + return false; |
1732 | + }); |
1733 | + |
1734 | + var bg_color = Gdk.RGBA (); |
1735 | + bg_color.red = 0; |
1736 | + bg_color.green = 0; |
1737 | + bg_color.blue = 0; |
1738 | + bg_color.alpha = 1; |
1739 | + scrolledwindow.override_background_color (Gtk.StateFlags.NORMAL, bg_color); |
1740 | + |
1741 | + this.page = grid; |
1742 | + |
1743 | + display.set_credential (Vnc.DisplayCredential.USERNAME, user); |
1744 | + display.set_credential (Vnc.DisplayCredential.CLIENTNAME, "evnc"); |
1745 | + display.set_pointer_grab (true); |
1746 | + display.set_keyboard_grab (true); |
1747 | + display.set_pointer_local (options.pointer_local); |
1748 | + display.set_lossy_encoding (options.lossy_encoding); |
1749 | + display.vnc_disconnected.connect (() => { |
1750 | + this.close (); |
1751 | + }); |
1752 | + display.vnc_connected.connect (() => { |
1753 | + desc = _ ("Logging in..."); |
1754 | + this.label = desc; |
1755 | + }); |
1756 | + display.vnc_initialized.connect (() => { |
1757 | + desc = ""; |
1758 | + |
1759 | + if (user != "") { |
1760 | + desc += user + "@"; |
1761 | + } |
1762 | + |
1763 | + desc += host + ":" + port; |
1764 | + this.label = desc; |
1765 | + }); |
1766 | + display.vnc_auth_credential.connect ((cred) => { |
1767 | + var input_box = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, |
1768 | + Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, _ ("Password required!")); |
1769 | + input_box.title = _ ("Connect to:") + " " + host; |
1770 | + |
1771 | + var pass_entry = new Gtk.Entry (); |
1772 | + pass_entry.set_size_request (400, 0); |
1773 | + pass_entry.set_visibility (false); |
1774 | + pass_entry.caps_lock_warning = true; |
1775 | + pass_entry.set_placeholder_text (_ ("Password")); |
1776 | + pass_entry.margin_start = 12; |
1777 | + pass_entry.margin_end = 12; |
1778 | + |
1779 | + input_box.get_content_area ().pack_end (pass_entry, true, false, 0); |
1780 | + input_box.show_all (); |
1781 | + |
1782 | + if (input_box.run () == Gtk.ResponseType.OK) { |
1783 | + display.set_credential (Vnc.DisplayCredential.PASSWORD, pass_entry.get_text ()); |
1784 | + } else { |
1785 | + this.close (); |
1786 | + } |
1787 | + |
1788 | + input_box.destroy (); |
1789 | + }); |
1790 | + |
1791 | + set_color_depth (options.color_depth); |
1792 | + options.settings.bind ("readonly", display, "read_only", SettingsBindFlags.DEFAULT); |
1793 | + |
1794 | + if (display.open_host (host, port)) { |
1795 | + this.host = host; |
1796 | + this.port = port; |
1797 | + this.user = user; |
1798 | + } |
1799 | + |
1800 | + set_size_mode (options.display_mode); |
1801 | + } |
1802 | + |
1803 | + public void take_screenshot () { |
1804 | + var img = display.get_pixbuf (); |
1805 | + |
1806 | + var save_dialog = new Gtk.FileChooserDialog (_ ("Save the screenshot"), null, Gtk.FileChooserAction.SAVE, |
1807 | + _ ("Cancel"), Gtk.ResponseType.CANCEL, _ ("Save"), Gtk.ResponseType.ACCEPT); |
1808 | + |
1809 | + var file_filter = new Gtk.FileFilter (); |
1810 | + file_filter.add_mime_type ("image/jpeg"); |
1811 | + |
1812 | + save_dialog.set_filter (file_filter); |
1813 | + |
1814 | + var preview_image = new Gtk.Image (); |
1815 | + preview_image.set_from_pixbuf (img.scale_simple (150, (int) (((float)150 / (float)img.width) * img.height), |
1816 | + Gdk.InterpType.BILINEAR)); |
1817 | + |
1818 | + save_dialog.set_preview_widget (preview_image); |
1819 | + |
1820 | + preview_image.show (); |
1821 | + |
1822 | + if (save_dialog.run () == Gtk.ResponseType.ACCEPT) { |
1823 | + try { |
1824 | + img.save (save_dialog.get_filename (), "jpeg"); |
1825 | + } catch (Error ex) { |
1826 | + on_save_screenshot_exception (ex.message); |
1827 | + } |
1828 | + } |
1829 | + |
1830 | + save_dialog.close (); |
1831 | + save_dialog.destroy (); |
1832 | + } |
1833 | + |
1834 | + private void update_view_border () { |
1835 | + if (scrolledwindow.get_allocated_width () > 0 && scrolledwindow.get_allocated_height () > 0 && display.width > 0 && |
1836 | + display.height > 0) { |
1837 | + if (((float)scrolledwindow.get_allocated_width () / (float)display.width) * (float)display.height > |
1838 | + scrolledwindow.get_allocated_height ()) { |
1839 | + int border_size = (int) (((float)scrolledwindow.get_allocated_width () - (((float) |
1840 | + scrolledwindow.get_allocated_height () / (float)display.height) * (float)display.width)) / 2); |
1841 | + viewport.margin_start = border_size; |
1842 | + viewport.margin_end = border_size; |
1843 | + viewport.margin_top = 0; |
1844 | + viewport.margin_bottom = 0; |
1845 | + } else { |
1846 | + int border_size = (int) (((float)scrolledwindow.get_allocated_height () - (((float) |
1847 | + scrolledwindow.get_allocated_width () / (float)display.width) * (float)display.height)) / 2); |
1848 | + viewport.margin_start = 0; |
1849 | + viewport.margin_end = 0; |
1850 | + viewport.margin_top = border_size; |
1851 | + viewport.margin_bottom = border_size; |
1852 | + } |
1853 | + } |
1854 | + } |
1855 | + |
1856 | + private void set_size_mode (int val) { |
1857 | + if (val == 0) { |
1858 | + display.force_size = false; |
1859 | + display.scaling = true; |
1860 | + display.set_size_request (0, 0); |
1861 | + |
1862 | + update_view_border (); |
1863 | + } else { |
1864 | + viewport.margin = 0; |
1865 | + |
1866 | + display.force_size = true; |
1867 | + display.scaling = false; |
1868 | + display.set_size_request (display.width, display.height); |
1869 | + } |
1870 | + } |
1871 | + |
1872 | + private void set_color_depth (string val) { |
1873 | + switch (val) { |
1874 | + case "default": |
1875 | + display.set_depth (Vnc.DisplayDepthColor.DEFAULT); |
1876 | + break; |
1877 | + |
1878 | + case "full": |
1879 | + display.set_depth (Vnc.DisplayDepthColor.FULL); |
1880 | + break; |
1881 | + |
1882 | + case "medium": |
1883 | + display.set_depth (Vnc.DisplayDepthColor.MEDIUM); |
1884 | + break; |
1885 | + |
1886 | + case "low": |
1887 | + display.set_depth (Vnc.DisplayDepthColor.LOW); |
1888 | + break; |
1889 | + |
1890 | + case "ultra low": |
1891 | + display.set_depth (Vnc.DisplayDepthColor.ULTRA_LOW); |
1892 | + break; |
1893 | + } |
1894 | + } |
1895 | + } |
1896 | } |
1897 | \ No newline at end of file |
1898 | |
1899 | === modified file 'src/evnc.vala' |
1900 | --- src/evnc.vala 2014-11-04 14:36:04 +0000 |
1901 | +++ src/evnc.vala 2015-07-09 18:17:15 +0000 |
1902 | @@ -17,68 +17,68 @@ |
1903 | */ |
1904 | |
1905 | namespace evnc { |
1906 | - public class evncApp : Granite.Application { |
1907 | - public MainWindow window; |
1908 | - |
1909 | - construct { |
1910 | - // App-Properties |
1911 | - program_name = "VNC-Client"; |
1912 | - exec_name = "evnc"; |
1913 | - |
1914 | - build_data_dir = Constants.DATADIR; |
1915 | - build_pkg_data_dir = Constants.PKGDATADIR; |
1916 | - build_release_name = Constants.RELEASE_NAME; |
1917 | - build_version = Constants.VERSION; |
1918 | - build_version_info = Constants.VERSION_INFO; |
1919 | - |
1920 | - app_years = "2014"; |
1921 | - app_icon = "evnc"; |
1922 | - app_launcher = "evnc.desktop"; |
1923 | - application_id = "net.launchpad.evnc"; |
1924 | - main_url = "https://code.launchpad.net/evnc"; |
1925 | - bug_url = "https://bugs.launchpad.net/evnc"; |
1926 | - help_url = "https://code.launchpad.net/evnc"; |
1927 | - translate_url = "https://translations.launchpad.net/evnc"; |
1928 | - about_authors = { "Marcus Wichelmann <admin@marcusw.de>" }; |
1929 | - about_documenters = { "Marcus Wichelmann <admin@marcusw.de>" }; |
1930 | - about_artists = { "Marcus Wichelmann <admin@marcusw.de>" }; |
1931 | - about_comments = "A VNC-Viewer for elementary OS"; |
1932 | - about_translators = "Launchpad Translators"; |
1933 | - } |
1934 | - |
1935 | - public evncApp () { |
1936 | - // Translations |
1937 | - Intl.setlocale (LocaleCategory.ALL, ""); |
1938 | - string langpack_dir = Path.build_filename (Constants.INSTALL_PREFIX, "share", "locale"); |
1939 | - Intl.bindtextdomain (Constants.GETTEXT_PACKAGE, langpack_dir); |
1940 | - Intl.bind_textdomain_codeset (Constants.GETTEXT_PACKAGE, "UTF-8"); |
1941 | - Intl.textdomain (Constants.GETTEXT_PACKAGE); |
1942 | - |
1943 | - // Debug service |
1944 | - Granite.Services.Logger.initialize ("evnc"); |
1945 | - Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; |
1946 | - |
1947 | - //Vnc.util_set_debug (true); |
1948 | - //Granite.Services.Logger.notification (Vnc.util_get_version_string ()); |
1949 | - } |
1950 | - |
1951 | - public override void activate () { |
1952 | - if (get_windows () == null) { |
1953 | - window = new MainWindow (this); |
1954 | - window.show_all (); |
1955 | - } else { |
1956 | - window.present (); |
1957 | - } |
1958 | - } |
1959 | - |
1960 | - public override void open (File [] files, string hint) { |
1961 | - // Do nothing |
1962 | - } |
1963 | - |
1964 | - public static void main (string [] args) { |
1965 | - // Instantiate and run |
1966 | - var app = new evnc.evncApp (); |
1967 | - app.run (args); |
1968 | - } |
1969 | - } |
1970 | + public class evncApp : Granite.Application { |
1971 | + public MainWindow window; |
1972 | + |
1973 | + construct { |
1974 | + // App-Properties |
1975 | + program_name = "VNC-Client"; |
1976 | + exec_name = "evnc"; |
1977 | + |
1978 | + build_data_dir = Constants.DATADIR; |
1979 | + build_pkg_data_dir = Constants.PKGDATADIR; |
1980 | + build_release_name = Constants.RELEASE_NAME; |
1981 | + build_version = Constants.VERSION; |
1982 | + build_version_info = Constants.VERSION_INFO; |
1983 | + |
1984 | + app_years = "2014"; |
1985 | + app_icon = "evnc"; |
1986 | + app_launcher = "evnc.desktop"; |
1987 | + application_id = "net.launchpad.evnc"; |
1988 | + main_url = "https://code.launchpad.net/evnc"; |
1989 | + bug_url = "https://bugs.launchpad.net/evnc"; |
1990 | + help_url = "https://code.launchpad.net/evnc"; |
1991 | + translate_url = "https://translations.launchpad.net/evnc"; |
1992 | + about_authors = { "Marcus Wichelmann <admin@marcusw.de>" }; |
1993 | + about_documenters = { "Marcus Wichelmann <admin@marcusw.de>" }; |
1994 | + about_artists = { "Marcus Wichelmann <admin@marcusw.de>" }; |
1995 | + about_comments = "A VNC-Viewer for elementary OS"; |
1996 | + about_translators = "Launchpad Translators"; |
1997 | + } |
1998 | + |
1999 | + public evncApp () { |
2000 | + // Translations |
2001 | + Intl.setlocale (LocaleCategory.ALL, ""); |
2002 | + string langpack_dir = Path.build_filename (Constants.INSTALL_PREFIX, "share", "locale"); |
2003 | + Intl.bindtextdomain (Constants.GETTEXT_PACKAGE, langpack_dir); |
2004 | + Intl.bind_textdomain_codeset (Constants.GETTEXT_PACKAGE, "UTF-8"); |
2005 | + Intl.textdomain (Constants.GETTEXT_PACKAGE); |
2006 | + |
2007 | + // Debug service |
2008 | + Granite.Services.Logger.initialize ("evnc"); |
2009 | + Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; |
2010 | + |
2011 | + //Vnc.util_set_debug (true); |
2012 | + //Granite.Services.Logger.notification (Vnc.util_get_version_string ()); |
2013 | + } |
2014 | + |
2015 | + public override void activate () { |
2016 | + if (get_windows () == null) { |
2017 | + window = new MainWindow (this); |
2018 | + window.show_all (); |
2019 | + } else { |
2020 | + window.present (); |
2021 | + } |
2022 | + } |
2023 | + |
2024 | + public override void open (File [] files, string hint) { |
2025 | + // Do nothing |
2026 | + } |
2027 | + |
2028 | + public static void main (string [] args) { |
2029 | + // Instantiate and run |
2030 | + var app = new evnc.evncApp (); |
2031 | + app.run (args); |
2032 | + } |
2033 | + } |
2034 | } |
2035 | \ No newline at end of file |