Merge lp:~l-admin-3/eidete/fix-for-fix-for-freya into lp:eidete
- fix-for-fix-for-freya
- Merge into trunk
Proposed by
Marcus Wichelmann
Status: | Merged |
---|---|
Merged at revision: | 178 |
Proposed branch: | lp:~l-admin-3/eidete/fix-for-fix-for-freya |
Merge into: | lp:eidete |
Diff against target: |
2978 lines (+1206/-941) 9 files modified
src/Config.vala.cmake (+7/-7) src/Widgets/countdown.vala (+30/-31) src/Widgets/end_dialog.vala (+231/-170) src/Widgets/keyview.vala (+433/-307) src/Widgets/selectionarea.vala (+65/-63) src/desktop_launcher.vala (+3/-4) src/eidete.vala (+317/-260) src/keycapture.c (+33/-29) src/videobin_uploader.vala (+87/-70) |
To merge this branch: | bzr merge lp:~l-admin-3/eidete/fix-for-fix-for-freya |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tom Beckmann | Pending | ||
Review via email: mp+245502@code.launchpad.net |
Commit message
Description of the change
I've corrected the style of the whole code and maked it more consistent.
To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote : | # |
- 196. By Marcus Wichelmann
-
All using-statements removed.
- 197. By Marcus Wichelmann
-
some spaces removed.
- 198. By Marcus Wichelmann
-
Loaded patch by ~tombeckmann
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Config.vala.cmake' |
2 | --- src/Config.vala.cmake 2011-12-30 00:26:42 +0000 |
3 | +++ src/Config.vala.cmake 2015-01-05 22:47:30 +0000 |
4 | @@ -16,11 +16,11 @@ |
5 | // |
6 | |
7 | namespace Constants { |
8 | -public const string DATADIR = "@DATADIR@"; |
9 | -public const string PKGDATADIR = "@PKGDATADIR@"; |
10 | -public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; |
11 | -public const string RELEASE_NAME = "@RELEASE_NAME@"; |
12 | -public const string VERSION = "@VERSION@"; |
13 | -public const string VERSION_INFO = "@VERSION_INFO@"; |
14 | -public const string PLUGINDIR = "@PLUGINDIR@"; |
15 | + public const string DATADIR = "@DATADIR@"; |
16 | + public const string PKGDATADIR = "@PKGDATADIR@"; |
17 | + public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; |
18 | + public const string RELEASE_NAME = "@RELEASE_NAME@"; |
19 | + public const string VERSION = "@VERSION@"; |
20 | + public const string VERSION_INFO = "@VERSION_INFO@"; |
21 | + public const string PLUGINDIR = "@PLUGINDIR@"; |
22 | } |
23 | |
24 | === modified file 'src/Widgets/countdown.vala' |
25 | --- src/Widgets/countdown.vala 2013-05-17 01:00:15 +0000 |
26 | +++ src/Widgets/countdown.vala 2015-01-05 22:47:30 +0000 |
27 | @@ -1,37 +1,31 @@ |
28 | -using Gtk; |
29 | -using Granite; |
30 | - |
31 | - |
32 | -namespace Eidete.Widgets{ |
33 | - |
34 | +namespace Eidete.Widgets { |
35 | public class Countdown : Granite.Widgets.CompositedWindow { |
36 | - |
37 | - public Label count; |
38 | + public Gtk.Label count; |
39 | public int time; |
40 | |
41 | public Countdown (){ |
42 | this.time = 5; |
43 | |
44 | this.set_default_size (300, 200); |
45 | - this.window_position = WindowPosition.CENTER; |
46 | + this.window_position = Gtk.WindowPosition.CENTER; |
47 | this.set_keep_above (true); |
48 | this.stick (); |
49 | this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN; |
50 | this.skip_pager_hint = true; |
51 | this.skip_taskbar_hint = true; |
52 | |
53 | - var box = new Box (Orientation.VERTICAL, 0); |
54 | + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
55 | box.margin = 40; |
56 | box.margin_left = box.margin_right = 60; |
57 | |
58 | - var title = new Label ("<span size='20000' color='#fbfbfb'>"+_("Recording starts in")+"…"+"</span>"); |
59 | + var title = new Gtk.Label ("<span size='20000' color='#fbfbfb'>" + _("Recording starts in") + "…" + "</span>"); |
60 | title.use_markup = true; |
61 | title.margin_bottom = 20; |
62 | |
63 | - this.count = new Label ("<span size='40000' color='#fbfbfb'>"+time.to_string ()+"</span>"); |
64 | + this.count = new Gtk.Label ("<span size='40000' color='#fbfbfb'>" + time.to_string () + "</span>"); |
65 | this.count.use_markup = true; |
66 | |
67 | - var tipp = new Label("<span size='10000' color='#fbfbfb' font-style='italic'>"+_("Focus Eidete to stop recording")+"</span>"); |
68 | + var tipp = new Gtk.Label("<span size='10000' color='#fbfbfb' font-style='italic'>" + _("Focus Eidete to stop recording") + "</span>"); |
69 | tipp.use_markup = true; |
70 | tipp.margin_top = 20; |
71 | |
72 | @@ -42,38 +36,43 @@ |
73 | this.add (box); |
74 | } |
75 | |
76 | - public override bool draw (Cairo.Context ctx){ |
77 | - int w = this.get_allocated_width (); |
78 | + public override bool draw (Cairo.Context ctx) { |
79 | + int w = this.get_allocated_width (); |
80 | int h = this.get_allocated_height (); |
81 | - Granite.Drawing.Utilities.cairo_rounded_rectangle (ctx, 4, 4, w-8, h-8, 4); |
82 | + |
83 | + Granite.Drawing.Utilities.cairo_rounded_rectangle (ctx, 4, 4, w - 8, h - 8, 4); |
84 | + |
85 | ctx.set_source_rgba (0.1, 0.1, 0.1, 0.8); |
86 | ctx.fill (); |
87 | + |
88 | return base.draw (ctx); |
89 | } |
90 | |
91 | - public void start (EideteApp app){ |
92 | - |
93 | + public void start (EideteApp app) { |
94 | this.show_all (); |
95 | + |
96 | Timeout.add (1000, () => { |
97 | - this.time --; |
98 | - count.label = "<span size='40000' color='#fbfbfb'>"+time.to_string ()+"</span>"; |
99 | - if (time == -1){ |
100 | + this.time--; |
101 | + |
102 | + count.label = "<span size='40000' color='#fbfbfb'>" + time.to_string () + "</span>"; |
103 | + |
104 | + if (time == -1) { |
105 | this.destroy (); |
106 | + |
107 | Timeout.add (100, () => { //let the countdown disappear before starting |
108 | - app.record (); |
109 | - app.main_window.iconify (); |
110 | - app.switch_to_paused (false); |
111 | - return false; |
112 | - }); |
113 | - return false; |
114 | + app.record (); |
115 | + app.main_window.iconify (); |
116 | + app.switch_to_paused (false); |
117 | + |
118 | + return false; |
119 | + }); |
120 | + |
121 | + return false; |
122 | } |
123 | + |
124 | return true; |
125 | }); |
126 | } |
127 | - |
128 | } |
129 | - |
130 | - |
131 | } |
132 | |
133 | - |
134 | |
135 | === modified file 'src/Widgets/end_dialog.vala' |
136 | --- src/Widgets/end_dialog.vala 2015-01-04 16:20:11 +0000 |
137 | +++ src/Widgets/end_dialog.vala 2015-01-05 22:47:30 +0000 |
138 | @@ -1,240 +1,301 @@ |
139 | -using Gtk; |
140 | - |
141 | namespace Eidete.Widgets { |
142 | - |
143 | - public class EndDialog : Dialog { |
144 | - |
145 | - private bool contractor; |
146 | - |
147 | - private EideteApp app ; |
148 | - private Button export ; |
149 | - private Grid grid; |
150 | - private ListStore list ; |
151 | - private TreeView treeview ; |
152 | - private File source ; |
153 | - |
154 | - public EndDialog (EideteApp app){ |
155 | - this.app = app ; |
156 | - //build_ui () ; |
157 | - this.window_position = WindowPosition.CENTER_ON_PARENT; |
158 | + public class EndDialog : Gtk.Dialog { |
159 | + private bool contractor; |
160 | + |
161 | + private EideteApp app; |
162 | + private Gtk.Button export; |
163 | + private Gtk.Grid grid; |
164 | + private Gtk.ListStore list; |
165 | + private Gtk.TreeView treeview; |
166 | + private File source; |
167 | + |
168 | + public EndDialog (EideteApp app) { |
169 | + this.app = app; |
170 | + |
171 | + //build_ui (); |
172 | + |
173 | + this.window_position = Gtk.WindowPosition.CENTER_ON_PARENT; |
174 | } |
175 | |
176 | private void build_ui () { |
177 | this.get_header_bar ().get_style_context ().remove_class ("header-bar"); |
178 | this.set_default_size (600, 600); |
179 | this.set_application (app); |
180 | - |
181 | + |
182 | if (app.selectionarea != null) |
183 | - app.selectionarea.destroy (); |
184 | + app.selectionarea.destroy (); |
185 | + |
186 | if (app.keyview != null) |
187 | - app.keyview.destroy (); |
188 | - |
189 | + app.keyview.destroy (); |
190 | + |
191 | this.icon_name = "eidete"; |
192 | |
193 | - grid = new Grid (); |
194 | + grid = new Gtk.Grid (); |
195 | grid.margin = 12; |
196 | |
197 | - var content = (Gtk.Box) this.get_content_area () ; |
198 | - var title = new Label ("<span size='30000'>"+_("Recording complete")+"</span>"); |
199 | + var content = (this.get_content_area () as Gtk.Box); |
200 | + |
201 | + var title = new Gtk.Label ("<span size='30000'>" + _("Recording complete") + "</span>"); |
202 | title.use_markup = true; |
203 | - title.halign = Align.START; |
204 | + title.halign = Gtk.Align.START; |
205 | |
206 | - export = new Button.with_label (_("Save")); |
207 | - export.image = new Image.from_stock (Stock.SAVE, IconSize.BUTTON); |
208 | + export = new Gtk.Button.with_label (_("Save")); |
209 | + export.image = new Gtk.Image.from_stock (Gtk.Stock.SAVE, Gtk.IconSize.BUTTON); |
210 | + export.get_style_context ().add_class ("suggested-action"); |
211 | export.can_default = true; |
212 | - export.get_style_context ().add_class ("suggested-action"); |
213 | + |
214 | this.set_default (export); |
215 | |
216 | - var cancel = new Button.with_label (_("Cancel")); |
217 | - cancel.image = new Image.from_stock (Stock.DELETE, IconSize.BUTTON); |
218 | + var cancel = new Gtk.Button.with_label (_("Cancel")); |
219 | + cancel.image = new Gtk.Image.from_stock (Gtk.Stock.DELETE, Gtk.IconSize.BUTTON); |
220 | cancel.margin_end = 6; |
221 | |
222 | - var bbox = new ButtonBox (Orientation.HORIZONTAL); |
223 | + var bbox = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); |
224 | + bbox.layout_style = Gtk.ButtonBoxStyle.END; |
225 | bbox.homogeneous = true; |
226 | + |
227 | bbox.pack_end (cancel, false, true, 0); |
228 | bbox.pack_end (export, false, true, 0); |
229 | - bbox.layout_style = ButtonBoxStyle.END; |
230 | - |
231 | - |
232 | - list = new ListStore (2, typeof (Gdk.Pixbuf), typeof (string)); |
233 | - treeview = new TreeView.with_model (list); |
234 | + |
235 | + list = new Gtk.ListStore (2, typeof (Gdk.Pixbuf), typeof (string)); |
236 | + |
237 | + treeview = new Gtk.TreeView.with_model (list); |
238 | treeview.headers_visible = false; |
239 | treeview.hexpand = true; |
240 | - treeview.set_activate_on_single_click (false) ; |
241 | - treeview.row_activated.connect ( on_contract_executed) ; |
242 | + treeview.set_activate_on_single_click (false); |
243 | + treeview.row_activated.connect (on_contract_executed); |
244 | |
245 | - var cell1 = new CellRendererPixbuf (); |
246 | + var cell1 = new Gtk.CellRendererPixbuf (); |
247 | cell1.set_padding (5, 15); |
248 | + |
249 | treeview.insert_column_with_attributes (-1, "", cell1, "pixbuf", 0); |
250 | - var cell2 = new CellRendererText (); |
251 | + |
252 | + var cell2 = new Gtk.CellRendererText (); |
253 | cell2.set_padding (2, 15); |
254 | + |
255 | treeview.insert_column_with_attributes (-1, "", cell2, "markup", 1); |
256 | |
257 | - //contractor |
258 | - load_contracts () ; |
259 | + // contractor |
260 | + |
261 | + load_contracts (); |
262 | |
263 | var scrolled = new Gtk.ScrolledWindow (null, null); |
264 | scrolled.vexpand = true; |
265 | scrolled.add (treeview); |
266 | - |
267 | + |
268 | grid.attach (title, 0, 0, 2, 1); |
269 | - grid.attach (new Label (""), 0, 2, 1, 1); |
270 | + grid.attach (new Gtk.Label (""), 0, 2, 1, 1); |
271 | + |
272 | grid.attach (scrolled, 0, 4, 1, 1); |
273 | - grid.attach (new Label (""), 0, 5, 1, 1); |
274 | + |
275 | + grid.attach (new Gtk.Label (""), 0, 5, 1, 1); |
276 | grid.attach (bbox, 0, 6, 1, 1); |
277 | + |
278 | source = File.new_for_path (app.settings.destination); |
279 | - |
280 | - if (contractor){ |
281 | - export.clicked.connect (on_contract_executed) ; |
282 | + |
283 | + if (contractor) { |
284 | + export.clicked.connect (on_contract_executed); |
285 | } else { |
286 | - export.clicked.connect ( () => { |
287 | - save_file () ; |
288 | - this.destroy (); |
289 | - }); |
290 | + export.clicked.connect (() => { |
291 | + save_file (); |
292 | + |
293 | + this.destroy (); |
294 | + }); |
295 | } |
296 | - cancel.clicked.connect ( () => {this.destroy ();}); |
297 | + |
298 | + cancel.clicked.connect (() => { |
299 | + this.destroy (); |
300 | + }); |
301 | |
302 | content.add (grid); |
303 | } |
304 | - |
305 | - public void display () { |
306 | - build_ui () ; |
307 | - show_all () ; |
308 | - } |
309 | - |
310 | - private void on_contract_executed () { |
311 | - TreePath path; |
312 | + |
313 | + public void display () { |
314 | + build_ui (); |
315 | + |
316 | + show_all (); |
317 | + } |
318 | + |
319 | + private void on_contract_executed (){ |
320 | + Gtk.TreePath path; |
321 | + |
322 | treeview.get_cursor (out path, null); |
323 | - int index = int.parse (path.to_string ()) ; |
324 | - execute_command (index) ; |
325 | + |
326 | + int index = int.parse (path.to_string ()); |
327 | + |
328 | + execute_command (index); |
329 | + |
330 | this.destroy (); |
331 | - } |
332 | - |
333 | + } |
334 | + |
335 | private void save_file () { |
336 | - var dialog = new FileChooserDialog (_("Save"), null, FileChooserAction.SAVE, Stock.OK, ResponseType.OK); |
337 | + var dialog = new Gtk.FileChooserDialog (_("Save"), null, Gtk.FileChooserAction.SAVE, Gtk.Stock.OK, Gtk.ResponseType.OK); |
338 | dialog.set_current_name (source.get_basename ()); |
339 | - var videos_folder = Environment.get_user_special_dir(UserDirectory.VIDEOS); |
340 | + |
341 | + var videos_folder = Environment.get_user_special_dir (UserDirectory.VIDEOS); |
342 | + |
343 | dialog.set_current_folder (videos_folder); |
344 | dialog.do_overwrite_confirmation = true; |
345 | + |
346 | var res = dialog.run (); |
347 | - if (res == ResponseType.OK){ |
348 | - var destination = File.new_for_path (dialog.get_filename ()); |
349 | - try{ |
350 | - source.copy (destination, FileCopyFlags.OVERWRITE); |
351 | - }catch (GLib.Error e){ |
352 | - stderr.printf ("Error: %s\n", e.message); |
353 | - } |
354 | - } |
355 | + |
356 | + if (res == Gtk.ResponseType.OK) { |
357 | + var destination = File.new_for_path (dialog.get_filename ()); |
358 | + |
359 | + try { |
360 | + source.copy (destination, FileCopyFlags.OVERWRITE); |
361 | + } catch (GLib.Error e) { |
362 | + stderr.printf ("Error: %s\n", e.message); |
363 | + } |
364 | + } |
365 | + |
366 | dialog.destroy (); |
367 | } |
368 | + |
369 | // Using deprecated Contractor API. Necesserary to maintain luna compatibility |
370 | -#if false |
371 | +#if false |
372 | private void execute_command_deprecated (int index) { |
373 | - string cmd = contracts_dep[index].lookup ("Exec") ; |
374 | - try{ |
375 | - Process.spawn_command_line_async (cmd); |
376 | - }catch (Error e){ |
377 | - print(e.message); |
378 | + string cmd = contracts_dep[index].lookup ("Exec"); |
379 | + |
380 | + try { |
381 | + Process.spawn_command_line_async (cmd); |
382 | + } catch (Error e) { |
383 | + print (e.message); |
384 | } |
385 | } |
386 | - |
387 | - private HashTable<string,string>[] contracts_dep ; |
388 | - |
389 | + |
390 | + private HashTable<string,string>[] contracts_dep; |
391 | + |
392 | private void load_contracts_deprecated () { |
393 | - // CARL deprecated Contractor API |
394 | + // CARL deprecated Contractor API |
395 | contracts_dep = Granite.Services.Contractor.get_contract (app.settings.destination, "video"); |
396 | - if (contracts_dep == null || contracts_dep.length <= 1){ |
397 | - warning ("You should install and/or run contractor"); |
398 | - contractor = false; |
399 | - var info = new InfoBar (); |
400 | - info.message_type = MessageType.WARNING; |
401 | - info.pack_start (new Label (_("Could not contact Contractor."))); |
402 | - grid.attach (info, 0, 3, 2, 1); |
403 | - export.label = _("Save"); |
404 | - }else{ |
405 | - contractor = true; |
406 | - for (var i=0;i<contracts_dep.length; i++){ |
407 | - TreeIter it; |
408 | - list.append (out it); |
409 | - Gdk.Pixbuf icon = null; |
410 | - try{ |
411 | - icon = IconTheme.get_default ().load_icon (contracts_dep[i].lookup ("IconName"), 32, 0); |
412 | - }catch (Error e){ |
413 | - warning (e.message); |
414 | - } |
415 | - list.set (it, 0, icon, 1, |
416 | - "<b>"+contracts_dep[i].lookup ("Name")+"</b>\n"+contracts_dep[i].lookup ("Description")); |
417 | - } |
418 | - treeview.set_cursor (new TreePath.from_string ("0"), null, false); |
419 | + |
420 | + if (contracts_dep == null || contracts_dep.length <= 1) |
421 | + warning ("You should install and/or run contractor"); |
422 | + |
423 | + contractor = false; |
424 | + |
425 | + var info = new InfoBar (); |
426 | + info.message_type = MessageType.WARNING; |
427 | + |
428 | + info.pack_start (new Label (_("Could not contact Contractor."))); |
429 | + |
430 | + grid.attach (info, 0, 3, 2, 1); |
431 | + |
432 | + export.label = _("Save"); |
433 | + } else { |
434 | + contractor = true; |
435 | + |
436 | + for (var i = 0; i < contracts_dep.length; i++) { |
437 | + TreeIter it; |
438 | + |
439 | + list.append (out it); |
440 | + |
441 | + Gdk.Pixbuf icon = null; |
442 | + |
443 | + try { |
444 | + icon = IconTheme.get_default ().load_icon (contracts_dep[i].lookup ("IconName"), 32, 0); |
445 | + } catch (Error e) { |
446 | + warning (e.message); |
447 | + } |
448 | + |
449 | + list.set (it, 0, icon, 1, |
450 | + "<b>" + contracts_dep[i].lookup ("Name") + |
451 | + "</b>\n" + contracts_dep[i].lookup ("Description")); |
452 | + } |
453 | + |
454 | + treeview.set_cursor (new TreePath.from_string ("0"), null, false); |
455 | } |
456 | } |
457 | -#endif |
458 | - private Gee.List<Granite.Services.Contract> contracts ; |
459 | - private int contracts_size = 0 ; |
460 | - |
461 | - private void execute_command (int index) { |
462 | - if( index == 0) |
463 | - save_file () ; |
464 | - else { |
465 | - var contract = contracts.@get (index-1) ; |
466 | - try{ |
467 | - contract.execute_with_file (source) ; |
468 | - }catch (Error e){ |
469 | - warning (e.message); |
470 | - } |
471 | +#endif |
472 | + |
473 | + private Gee.List<Granite.Services.Contract> contracts; |
474 | + |
475 | + private int contracts_size = 0; |
476 | + |
477 | + private void execute_command (int index){ |
478 | + if(index == 0) { |
479 | + save_file (); |
480 | + } else { |
481 | + var contract = contracts.@get (index-1); |
482 | + |
483 | + try { |
484 | + contract.execute_with_file (source); |
485 | + } catch (Error e) { |
486 | + warning (e.message); |
487 | + } |
488 | } |
489 | - |
490 | } |
491 | |
492 | private void load_contracts () { |
493 | - contracts_size = 0 ; |
494 | - try{ |
495 | - contracts = Granite.Services.ContractorProxy.get_contracts_by_mime ("video"); |
496 | - }catch (Error e){ |
497 | - warning (e.message); |
498 | - } |
499 | - if (contracts != null){ |
500 | - |
501 | - contractor = true; |
502 | - foreach( var contract in contracts ) { |
503 | - TreeIter it; |
504 | - list.append (out it); |
505 | - Gdk.Pixbuf icon = null; |
506 | - try{ |
507 | - icon = IconTheme.get_default ().load_icon (contract.get_icon ().to_string (), 32, 0); |
508 | - |
509 | - }catch (Error e){ |
510 | - warning (e.message); |
511 | - } |
512 | - list.set (it, 0, icon, 1, |
513 | - "<b>"+contract.get_display_name ()+"</b>\n"+contract.get_description ()); |
514 | - contracts_size ++ ; |
515 | - } |
516 | - TreeIter it; |
517 | - list.insert (out it, 0); |
518 | - Gdk.Pixbuf icon = null; |
519 | - try{ |
520 | - icon = IconTheme.get_default ().load_icon ("document-save", 32, 0); |
521 | - }catch (Error e){ |
522 | - warning (e.message); |
523 | - } |
524 | - list.set (it, 0, icon, 1, |
525 | - "<b>"+_("Save file")+"</b>\n"+("Save the file onto a disk")); |
526 | - treeview.set_cursor (new TreePath.from_string ("0"), null, false); |
527 | - export.label = _("Execute"); |
528 | - } |
529 | - if( contracts_size == 0 ) |
530 | - { |
531 | - warning ("You should install and/or run contractor"); |
532 | - contractor = false; |
533 | - var info = new InfoBar (); |
534 | - info.message_type = MessageType.WARNING; |
535 | - info.pack_start (new Label (_("Could not contact Contractor."))); |
536 | - grid.attach (info, 0, 3, 2, 1); |
537 | - export.label = _("Save"); |
538 | + contracts_size = 0; |
539 | + |
540 | + try { |
541 | + contracts = Granite.Services.ContractorProxy.get_contracts_by_mime ("video"); |
542 | + } catch (Error e) { |
543 | + warning (e.message); |
544 | + } |
545 | + |
546 | + if (contracts != null) { |
547 | + contractor = true; |
548 | + |
549 | + foreach (var contract in contracts) { |
550 | + Gtk.TreeIter it; |
551 | + |
552 | + list.append (out it); |
553 | + |
554 | + Gdk.Pixbuf icon = null; |
555 | + |
556 | + try { |
557 | + icon = Gtk.IconTheme.get_default ().load_icon (contract.get_icon ().to_string (), 32, 0); |
558 | + |
559 | + } catch (Error e) { |
560 | + warning (e.message); |
561 | + } |
562 | + |
563 | + list.set (it, 0, icon, 1, |
564 | + "<b>" + contract.get_display_name () + "</b>\n" + |
565 | + contract.get_description ()); |
566 | + |
567 | + contracts_size++; |
568 | + } |
569 | + |
570 | + Gtk.TreeIter it; |
571 | + |
572 | + list.insert (out it, 0); |
573 | + |
574 | + Gdk.Pixbuf icon = null; |
575 | + |
576 | + try { |
577 | + icon = Gtk.IconTheme.get_default ().load_icon ("document-save", 32, 0); |
578 | + } catch (Error e) { |
579 | + warning (e.message); |
580 | + } |
581 | + |
582 | + list.set (it, 0, icon, 1, |
583 | + "<b>" + _("Save file") + "</b>\n" + |
584 | + ("Save the file onto a disk")); |
585 | + |
586 | + treeview.set_cursor (new Gtk.TreePath.from_string ("0"), null, false); |
587 | + |
588 | + export.label = _("Execute"); |
589 | + } |
590 | + |
591 | + if (contracts_size == 0) { |
592 | + warning ("You should install and/or run contractor"); |
593 | + |
594 | + contractor = false; |
595 | + |
596 | + var info = new Gtk.InfoBar (); |
597 | + info.message_type = Gtk.MessageType.WARNING; |
598 | + |
599 | + info.pack_start (new Gtk.Label (_("Could not contact Contractor."))); |
600 | + |
601 | + grid.attach (info, 0, 3, 2, 1); |
602 | + |
603 | + export.label = _("Save"); |
604 | } |
605 | } |
606 | } |
607 | } |
608 | |
609 | - |
610 | |
611 | === modified file 'src/Widgets/keyview.vala' |
612 | --- src/Widgets/keyview.vala 2015-01-04 14:30:20 +0000 |
613 | +++ src/Widgets/keyview.vala 2015-01-05 22:47:30 +0000 |
614 | @@ -1,119 +1,123 @@ |
615 | -using Granite; |
616 | -using Gtk; |
617 | - |
618 | - |
619 | namespace Eidete.Widgets { |
620 | - |
621 | - public class YellowCircle : Granite.Widgets.CompositedWindow { |
622 | - |
623 | - public YellowCircle (Gdk.RGBA color) { |
624 | - this.skip_pager_hint = true; |
625 | - this.skip_taskbar_hint = true; |
626 | - this.set_keep_above (true); |
627 | - this.stick (); |
628 | - this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN; |
629 | - this.accept_focus = false; |
630 | - |
631 | - this.draw.connect ( (ctx) => { |
632 | - ctx.arc (this.get_allocated_width () / 2, this.get_allocated_height () / 2, |
633 | - this.get_allocated_width () / 2, 0, 6.28318); |
634 | - ctx.set_source_rgba (color.red, color.green, color.blue, color.alpha); |
635 | - ctx.fill (); |
636 | - return false; |
637 | - }); |
638 | - |
639 | - this.set_size_request (70, 70); |
640 | - this.realize (); |
641 | - this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0); |
642 | - this.show_all (); |
643 | - } |
644 | - |
645 | - public new void move (int x, int y) { |
646 | - base.move (x - (int)(this.get_allocated_width ()/2), y - (int)(this.get_allocated_height ()/2)); |
647 | - } |
648 | - } |
649 | - |
650 | - public class ClickWindow : Granite.Widgets.CompositedWindow { |
651 | - public ClickWindow (int x, int y, int button) { |
652 | - this.skip_pager_hint = true; |
653 | - this.skip_taskbar_hint = true; |
654 | - this.set_keep_above (true); |
655 | - this.stick (); |
656 | - this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN; |
657 | - this.accept_focus = false; |
658 | - |
659 | - string label = ""; |
660 | - switch (button) { |
661 | - case 1: |
662 | - label = _("Left"); |
663 | - break; |
664 | - case 2: |
665 | - label = _("Middle"); |
666 | - break; |
667 | - case 3: |
668 | - label = _("Right"); |
669 | - break; |
670 | - default: |
671 | - break; |
672 | - } |
673 | - var lbl = new Gtk.Label (label); |
674 | - lbl.attributes = new Pango.AttrList (); |
675 | - lbl.attributes.insert (new Pango.AttrFontDesc (Pango.FontDescription.from_string ("16px"))); |
676 | - this.add (lbl); |
677 | - var css = new Gtk.CssProvider (); |
678 | - try { |
679 | - css.load_from_data ("*{color:#fff; text-shadow:1 1 #000;}", -1); |
680 | - } catch (Error e) { warning (e.message); } |
681 | - lbl.get_style_context ().add_provider (css, 20000); |
682 | - |
683 | - this.realize (); |
684 | - this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0); |
685 | - this.show_all (); |
686 | - this.move (x + 5, y + 5); |
687 | - |
688 | - Timeout.add (10, () => { |
689 | - this.opacity -= 0.007; |
690 | - if (this.opacity < 0.1) //prevent flickering |
691 | - this.foreach ( (c) => this.remove (c) ); |
692 | - if (this.opacity <= 0) { |
693 | - this.destroy (); |
694 | - return false; |
695 | - } |
696 | - return true; |
697 | - }); |
698 | - } |
699 | - } |
700 | - |
701 | - |
702 | - public class Key : Label { |
703 | - |
704 | - public string key; |
705 | - public bool ctrl; |
706 | - public bool shift; |
707 | - public bool alt; |
708 | - public bool super; |
709 | - public bool iso_level3_shift; |
710 | - public int count; |
711 | - |
712 | - public Key (string key, bool ctrl, bool shift, bool alt, bool super, bool iso_level3_shift){ |
713 | - this.key = key; |
714 | - this.ctrl = ctrl; |
715 | - this.shift = shift; |
716 | - this.alt = alt; |
717 | - this.super = super; |
718 | - this.iso_level3_shift = iso_level3_shift; |
719 | - this.count = 1; |
720 | - } |
721 | - } |
722 | - |
723 | - |
724 | - public class KeyView : Granite.Widgets.CompositedWindow { |
725 | - |
726 | + public class YellowCircle : Granite.Widgets.CompositedWindow { |
727 | + public YellowCircle (Gdk.RGBA color) { |
728 | + this.skip_pager_hint = true; |
729 | + this.skip_taskbar_hint = true; |
730 | + this.set_keep_above (true); |
731 | + this.stick (); |
732 | + this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN; |
733 | + this.accept_focus = false; |
734 | + |
735 | + this.draw.connect ((ctx) => { |
736 | + ctx.arc (this.get_allocated_width () / 2, this.get_allocated_height () / 2, |
737 | + this.get_allocated_width () / 2, 0, 6.28318); |
738 | + ctx.set_source_rgba (color.red, color.green, color.blue, color.alpha); |
739 | + ctx.fill (); |
740 | + |
741 | + return false; |
742 | + }); |
743 | + |
744 | + this.set_size_request (70, 70); |
745 | + this.realize (); |
746 | + this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0); |
747 | + this.show_all (); |
748 | + } |
749 | + |
750 | + public new void move (int x, int y) { |
751 | + base.move (x - (int)(this.get_allocated_width () / 2), y - (int)(this.get_allocated_height () / 2)); |
752 | + } |
753 | + } |
754 | + |
755 | + public class ClickWindow : Granite.Widgets.CompositedWindow { |
756 | + public ClickWindow (int x, int y, int button) { |
757 | + this.skip_pager_hint = true; |
758 | + this.skip_taskbar_hint = true; |
759 | + this.set_keep_above (true); |
760 | + this.stick (); |
761 | + this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN; |
762 | + this.accept_focus = false; |
763 | + |
764 | + string label = ""; |
765 | + |
766 | + switch (button) { |
767 | + case 1: |
768 | + label = _("Left"); |
769 | + |
770 | + break; |
771 | + case 2: |
772 | + label = _("Middle"); |
773 | + |
774 | + break; |
775 | + case 3: |
776 | + label = _("Right"); |
777 | + |
778 | + break; |
779 | + default: |
780 | + break; |
781 | + } |
782 | + |
783 | + var lbl = new Gtk.Label (label); |
784 | + lbl.attributes = new Pango.AttrList (); |
785 | + lbl.attributes.insert (new Pango.AttrFontDesc (Pango.FontDescription.from_string ("16px"))); |
786 | + |
787 | + this.add (lbl); |
788 | + |
789 | + var css = new Gtk.CssProvider (); |
790 | + |
791 | + try { |
792 | + css.load_from_data ("*{color:#fff; text-shadow:1 1 #000;}", -1); |
793 | + } catch (Error e) { |
794 | + warning (e.message); |
795 | + } |
796 | + |
797 | + lbl.get_style_context ().add_provider (css, 20000); |
798 | + |
799 | + this.realize (); |
800 | + this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0); |
801 | + this.show_all (); |
802 | + this.move (x + 5, y + 5); |
803 | + |
804 | + Timeout.add (10, () => { |
805 | + this.opacity -= 0.007; |
806 | + |
807 | + if (this.opacity < 0.1) //prevent flickering |
808 | + this.foreach ((c) => this.remove (c)); |
809 | + if (this.opacity <= 0) { |
810 | + this.destroy (); |
811 | + |
812 | + return false; |
813 | + } |
814 | + |
815 | + return true; |
816 | + }); |
817 | + } |
818 | + } |
819 | + |
820 | + public class Key : Gtk.Label { |
821 | + public string key; |
822 | + public bool ctrl; |
823 | + public bool shift; |
824 | + public bool alt; |
825 | + public bool super; |
826 | + public bool iso_level3_shift; |
827 | + public int count; |
828 | + |
829 | + public Key (string key, bool ctrl, bool shift, bool alt, bool super, bool iso_level3_shift){ |
830 | + this.key = key; |
831 | + this.ctrl = ctrl; |
832 | + this.shift = shift; |
833 | + this.alt = alt; |
834 | + this.super = super; |
835 | + this.iso_level3_shift = iso_level3_shift; |
836 | + this.count = 1; |
837 | + } |
838 | + } |
839 | + |
840 | + |
841 | + public class KeyView : Granite.Widgets.CompositedWindow { |
842 | public int key_size; |
843 | public int fade_duration; |
844 | |
845 | - |
846 | - |
847 | private bool ctrl; |
848 | private bool shift; |
849 | private bool alt; |
850 | @@ -194,7 +198,7 @@ |
851 | this.screen_h = h; |
852 | } |
853 | |
854 | - public KeyView (bool keyboard, bool mouse, bool mouse_circle, Gdk.RGBA mouse_circle_color){ |
855 | + public KeyView (bool keyboard, bool mouse, bool mouse_circle, Gdk.RGBA mouse_circle_color) { |
856 | this.key_size = 75; |
857 | this.fade_duration = 2000; |
858 | |
859 | @@ -204,20 +208,22 @@ |
860 | this.resizable = false; |
861 | this.set_has_resize_grip (false); |
862 | this.skip_pager_hint = true; |
863 | - this.skip_taskbar_hint = true; |
864 | - this.accept_focus = false; |
865 | + this.skip_taskbar_hint = true; |
866 | + this.accept_focus = false; |
867 | |
868 | - this.type_hint = Gdk.WindowTypeHint.NOTIFICATION; |
869 | - this.events = Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.BUTTON1_MOTION_MASK | |
870 | - Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ; |
871 | + this.type_hint = Gdk.WindowTypeHint.NOTIFICATION; |
872 | + this.events = Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.BUTTON1_MOTION_MASK | |
873 | + Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK; |
874 | |
875 | this.realize (); |
876 | |
877 | Cairo.RectangleInt rect = {0, 0, 1, 1}; |
878 | + |
879 | this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle (rect), 0, 0); |
880 | |
881 | - this.enter_notify_event.connect ( () => { |
882 | + this.enter_notify_event.connect (() => { |
883 | this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle (rect), 0, 0); |
884 | + |
885 | return true; |
886 | }); |
887 | |
888 | @@ -225,7 +231,9 @@ |
889 | |
890 | //setup the key background |
891 | key_bg = new Cairo.ImageSurface (Cairo.Format.ARGB32, key_size, key_size); |
892 | + |
893 | var ctx = new Cairo.Context (key_bg); |
894 | + |
895 | Granite.Drawing.Utilities.cairo_rounded_rectangle (ctx, 5, 5, key_size-10, key_size-10, 5); |
896 | ctx.set_source_rgba (0.2, 0.2, 0.2, 0.7); |
897 | ctx.fill_preserve (); |
898 | @@ -237,209 +245,327 @@ |
899 | keys.pop_tail (); |
900 | this.queue_draw (); |
901 | } |
902 | + |
903 | return true; |
904 | }); |
905 | |
906 | if (mouse_circle) { |
907 | - this.circle = new YellowCircle (mouse_circle_color); |
908 | - this.captured_move.connect ( (x, y) => { |
909 | - Idle.add (() => { |
910 | - this.circle.move (x, y); |
911 | - return false; |
912 | - }); |
913 | - //debug ("Moved to %i, %i\n", x, y); |
914 | - }); |
915 | - } |
916 | - |
917 | - if (mouse) |
918 | - this.captured_mouse.connect ( (x, y, button) => { |
919 | - debug ("Button %i pressed at %i, %i ", button, x, y); |
920 | - if (button <= 3) |
921 | - Timeout.add (10, () => { new ClickWindow (x, y, button); return false; }); |
922 | - }); |
923 | - |
924 | - if (keyboard) |
925 | - this.captured.connect ( (keyvalue, released) => { |
926 | - Idle.add (() => { |
927 | - handle_key_event (keyvalue, released); |
928 | - return false; |
929 | - }); |
930 | - }); |
931 | + this.circle = new YellowCircle (mouse_circle_color); |
932 | + this.captured_move.connect ((x, y) => { |
933 | + Idle.add (() => { |
934 | + this.circle.move (x, y); |
935 | + |
936 | + return false; |
937 | + }); |
938 | + |
939 | + //debug ("Moved to %i, %i\n", x, y); |
940 | + }); |
941 | + } |
942 | + |
943 | + if (mouse) { |
944 | + this.captured_mouse.connect ((x, y, button) => { |
945 | + debug ("Button %i pressed at %i, %i ", button, x, y); |
946 | + |
947 | + if (button <= 3) { |
948 | + Timeout.add (10, () => { |
949 | + new ClickWindow (x, y, button); |
950 | + |
951 | + return false; |
952 | + }); |
953 | + } |
954 | + }); |
955 | + } |
956 | + |
957 | + if (keyboard) { |
958 | + this.captured.connect ((keyvalue, released) => { |
959 | + Idle.add (() => { |
960 | + handle_key_event (keyvalue, released); |
961 | + |
962 | + return false; |
963 | + }); |
964 | + }); |
965 | + } |
966 | } |
967 | |
968 | void handle_key_event (string keyvalue, bool released) { |
969 | - if (released){ |
970 | - switch (keyvalue){ |
971 | - case "Control_L": |
972 | - case "Control_R": |
973 | - this.ctrl = false; |
974 | - this.queue_draw (); |
975 | - break; |
976 | - case "Shift_L": |
977 | - case "Shift_R": |
978 | - this.shift = false; |
979 | - this.queue_draw (); |
980 | - break; |
981 | - case "Alt_L": |
982 | - case "Alt_R": |
983 | - this.alt = false; |
984 | - this.queue_draw (); |
985 | - break; |
986 | - case "Super_L": |
987 | - case "Super_R": |
988 | - this.super = false; |
989 | - this.queue_draw (); |
990 | - return; |
991 | - case "ISO_Level3_Shift": |
992 | - this.iso_level3_shift = false; |
993 | - this.queue_draw (); |
994 | - return; |
995 | - } |
996 | - }else{ |
997 | - string res = keyvalue; |
998 | - switch (res){ |
999 | - case "Control_L": |
1000 | - case "Control_R": |
1001 | - this.ctrl = true; |
1002 | - this.queue_draw (); |
1003 | - return; |
1004 | - case "Shift_L": |
1005 | - case "Shift_R": |
1006 | - this.shift = true; |
1007 | - this.queue_draw (); |
1008 | - return; |
1009 | - case "Alt_L": |
1010 | - case "Alt_R": |
1011 | - this.alt = true; |
1012 | - this.queue_draw (); |
1013 | - return; |
1014 | - case "Super_L": |
1015 | - case "Super_R": |
1016 | - this.super = true; |
1017 | - this.queue_draw (); |
1018 | - return; |
1019 | - case "ISO_Level3_Shift": |
1020 | - this.iso_level3_shift = true; |
1021 | - this.queue_draw (); |
1022 | - return; |
1023 | - case "Escape": |
1024 | - res = "Esc"; break; |
1025 | - case "Return": |
1026 | - res = "⏎"; break; |
1027 | - case "Delete": |
1028 | - res = "Del"; break; |
1029 | - case "Insert": |
1030 | - res = "Ins"; break; |
1031 | - case "comma": |
1032 | - res = ","; break; |
1033 | - case "period": |
1034 | - res = "."; break; |
1035 | - case "minus": |
1036 | - res = "-"; break; |
1037 | - case "plus": |
1038 | - res = "+"; break; |
1039 | - case "Tab": |
1040 | - res = "Tab"; break; |
1041 | - case "BackSpace": |
1042 | - res = "⌫"; break; |
1043 | - case "Left": |
1044 | - res = "◄"; break; |
1045 | - case "Right": |
1046 | - res = "►"; break; |
1047 | - case "Up": |
1048 | - res = "▲"; break; |
1049 | - case "Down": |
1050 | - res = "▼"; break; |
1051 | - case "space": |
1052 | - res = " "; break; |
1053 | - case "backslash": |
1054 | - res = "\\"; break; |
1055 | - case "bracketleft": |
1056 | - res = "["; break; |
1057 | - case "bracketright": |
1058 | - res = "]"; break; |
1059 | - case "braceleft": |
1060 | - res = "{"; break; |
1061 | - case "braceright": |
1062 | - res = "}"; break; |
1063 | - case "apostrophe": |
1064 | - res = "'"; break; |
1065 | - case "asciitilde": |
1066 | - res = "~"; break; |
1067 | - case "grave": |
1068 | - res = "`"; break; |
1069 | - case "bar": |
1070 | - res = "|"; break; |
1071 | - case "ampersand": |
1072 | - res = "&"; break; |
1073 | - case "parenleft": |
1074 | - res = "("; break; |
1075 | - case "parenright": |
1076 | - res = ")"; break; |
1077 | - case "less": |
1078 | - res = "<"; break; |
1079 | - case "greater": |
1080 | - res = ">"; break; |
1081 | - case "equal": |
1082 | - res = "="; break; |
1083 | - case "exclam": |
1084 | - res = "!"; break; |
1085 | - case "quotedbl": |
1086 | - res = "\""; break; |
1087 | - case "numbersign": |
1088 | - res = "\""; break; |
1089 | - case "dollar": |
1090 | - res = "$"; break; |
1091 | - case "slash": |
1092 | - res = "/"; break; |
1093 | - case "asterisk": |
1094 | - res = "*"; break; |
1095 | - case "colon": |
1096 | - res = ":"; break; |
1097 | - case "semicolon": |
1098 | - res = ";"; break; |
1099 | - case "underscore": |
1100 | - res = "_"; break; |
1101 | - case "Next": |
1102 | - res = "Pg▲"; break; |
1103 | - case "Prior": |
1104 | - res = "Pg▼"; break; |
1105 | - case "asciicircum": |
1106 | - res = "^"; break; |
1107 | - case "at": |
1108 | - res = "@"; break; |
1109 | - case "question": |
1110 | - res = "?"; break; |
1111 | - default: |
1112 | - if (keyvalue.length > 9) |
1113 | - res = keyvalue.substring (0, 9); |
1114 | - break; |
1115 | - } |
1116 | - |
1117 | - if ((!keys.is_empty ()) && |
1118 | + if (released) { |
1119 | + switch (keyvalue) { |
1120 | + case "Control_L": |
1121 | + case "Control_R": |
1122 | + this.ctrl = false; |
1123 | + this.queue_draw (); |
1124 | + |
1125 | + break; |
1126 | + case "Shift_L": |
1127 | + case "Shift_R": |
1128 | + this.shift = false; |
1129 | + this.queue_draw (); |
1130 | + |
1131 | + break; |
1132 | + case "Alt_L": |
1133 | + case "Alt_R": |
1134 | + this.alt = false; |
1135 | + this.queue_draw (); |
1136 | + |
1137 | + break; |
1138 | + case "Super_L": |
1139 | + case "Super_R": |
1140 | + this.super = false; |
1141 | + this.queue_draw (); |
1142 | + |
1143 | + return; |
1144 | + case "ISO_Level3_Shift": |
1145 | + this.iso_level3_shift = false; |
1146 | + this.queue_draw (); |
1147 | + |
1148 | + return; |
1149 | + } |
1150 | + } else { |
1151 | + string res = keyvalue; |
1152 | + |
1153 | + switch (res) { |
1154 | + case "Control_L": |
1155 | + case "Control_R": |
1156 | + this.ctrl = true; |
1157 | + this.queue_draw (); |
1158 | + |
1159 | + return; |
1160 | + case "Shift_L": |
1161 | + case "Shift_R": |
1162 | + this.shift = true; |
1163 | + this.queue_draw (); |
1164 | + |
1165 | + return; |
1166 | + case "Alt_L": |
1167 | + case "Alt_R": |
1168 | + this.alt = true; |
1169 | + this.queue_draw (); |
1170 | + |
1171 | + return; |
1172 | + case "Super_L": |
1173 | + case "Super_R": |
1174 | + this.super = true; |
1175 | + this.queue_draw (); |
1176 | + |
1177 | + return; |
1178 | + case "ISO_Level3_Shift": |
1179 | + this.iso_level3_shift = true; |
1180 | + this.queue_draw (); |
1181 | + |
1182 | + return; |
1183 | + case "Escape": |
1184 | + res = "Esc"; |
1185 | + |
1186 | + break; |
1187 | + case "Return": |
1188 | + res = "⏎"; |
1189 | + |
1190 | + break; |
1191 | + case "Delete": |
1192 | + res = "Del"; |
1193 | + |
1194 | + break; |
1195 | + case "Insert": |
1196 | + res = "Ins"; |
1197 | + |
1198 | + break; |
1199 | + case "comma": |
1200 | + res = ","; |
1201 | + |
1202 | + break; |
1203 | + case "period": |
1204 | + res = "."; |
1205 | + |
1206 | + break; |
1207 | + case "minus": |
1208 | + res = "-"; |
1209 | + |
1210 | + break; |
1211 | + case "plus": |
1212 | + res = "+"; |
1213 | + |
1214 | + break; |
1215 | + case "Tab": |
1216 | + res = "Tab"; |
1217 | + |
1218 | + break; |
1219 | + case "BackSpace": |
1220 | + res = "⌫"; |
1221 | + |
1222 | + break; |
1223 | + case "Left": |
1224 | + res = "◄"; |
1225 | + |
1226 | + break; |
1227 | + case "Right": |
1228 | + res = "►"; |
1229 | + |
1230 | + break; |
1231 | + case "Up": |
1232 | + res = "▲"; |
1233 | + |
1234 | + break; |
1235 | + case "Down": |
1236 | + res = "▼"; |
1237 | + |
1238 | + break; |
1239 | + case "space": |
1240 | + res = " "; |
1241 | + |
1242 | + break; |
1243 | + case "backslash": |
1244 | + res = "\\"; |
1245 | + |
1246 | + break; |
1247 | + case "bracketleft": |
1248 | + res = "["; |
1249 | + |
1250 | + break; |
1251 | + case "bracketright": |
1252 | + res = "]"; |
1253 | + |
1254 | + break; |
1255 | + case "braceleft": |
1256 | + res = "{"; |
1257 | + |
1258 | + break; |
1259 | + case "braceright": |
1260 | + res = "}"; |
1261 | + |
1262 | + break; |
1263 | + case "apostrophe": |
1264 | + res = "'"; |
1265 | + |
1266 | + break; |
1267 | + case "asciitilde": |
1268 | + res = "~"; |
1269 | + |
1270 | + break; |
1271 | + case "grave": |
1272 | + res = "`"; |
1273 | + |
1274 | + break; |
1275 | + case "bar": |
1276 | + res = "|"; |
1277 | + |
1278 | + break; |
1279 | + case "ampersand": |
1280 | + res = "&"; |
1281 | + |
1282 | + break; |
1283 | + case "parenleft": |
1284 | + res = "("; |
1285 | + |
1286 | + break; |
1287 | + case "parenright": |
1288 | + res = ")"; |
1289 | + |
1290 | + break; |
1291 | + case "less": |
1292 | + res = "<"; |
1293 | + |
1294 | + break; |
1295 | + case "greater": |
1296 | + res = ">"; |
1297 | + |
1298 | + break; |
1299 | + case "equal": |
1300 | + res = "="; |
1301 | + |
1302 | + break; |
1303 | + case "exclam": |
1304 | + res = "!"; |
1305 | + |
1306 | + break; |
1307 | + case "quotedbl": |
1308 | + res = "\""; |
1309 | + |
1310 | + break; |
1311 | + case "numbersign": |
1312 | + res = "\""; |
1313 | + |
1314 | + break; |
1315 | + case "dollar": |
1316 | + res = "$"; |
1317 | + |
1318 | + break; |
1319 | + case "slash": |
1320 | + res = "/"; |
1321 | + |
1322 | + break; |
1323 | + case "asterisk": |
1324 | + res = "*"; |
1325 | + |
1326 | + break; |
1327 | + case "colon": |
1328 | + res = ":"; |
1329 | + |
1330 | + break; |
1331 | + case "semicolon": |
1332 | + res = ";"; |
1333 | + |
1334 | + break; |
1335 | + case "underscore": |
1336 | + res = "_"; |
1337 | + |
1338 | + break; |
1339 | + case "Next": |
1340 | + res = "Pg▲"; |
1341 | + |
1342 | + break; |
1343 | + case "Prior": |
1344 | + res = "Pg▼"; |
1345 | + |
1346 | + break; |
1347 | + case "asciicircum": |
1348 | + res = "^"; |
1349 | + |
1350 | + break; |
1351 | + case "at": |
1352 | + res = "@"; |
1353 | + |
1354 | + break; |
1355 | + case "question": |
1356 | + res = "?"; |
1357 | + |
1358 | + break; |
1359 | + default: |
1360 | + if (keyvalue.length > 9) |
1361 | + res = keyvalue.substring (0, 9); |
1362 | + |
1363 | + break; |
1364 | + } |
1365 | + |
1366 | + if ((!keys.is_empty ()) && |
1367 | (keys.peek_head ().key == res) && |
1368 | (keys.peek_head ().ctrl == ctrl) && |
1369 | (keys.peek_head ().shift == shift) && |
1370 | (keys.peek_head ().alt == alt) && |
1371 | - (keys.peek_head ().iso_level3_shift == iso_level3_shift)){ |
1372 | - keys.peek_head ().count ++; |
1373 | - this.queue_draw (); |
1374 | - }else{ |
1375 | - var key = new Key (res, ctrl, shift, alt, super, iso_level3_shift); |
1376 | - if (!released){ |
1377 | - keys.push_head (key); |
1378 | - if (keys.length+2 > (screen_h / key_size)) |
1379 | - keys.pop_tail (); |
1380 | - this.queue_draw (); |
1381 | - } |
1382 | + (keys.peek_head ().iso_level3_shift == iso_level3_shift)) { |
1383 | + keys.peek_head ().count++; |
1384 | + |
1385 | + this.queue_draw (); |
1386 | + } else { |
1387 | + var key = new Key(res, ctrl, shift, alt, super, iso_level3_shift); |
1388 | + |
1389 | + if (!released) { |
1390 | + keys.push_head (key); |
1391 | + |
1392 | + if (keys.length + 2 > (screen_h / key_size)) |
1393 | + keys.pop_tail (); |
1394 | + |
1395 | + this.queue_draw (); |
1396 | + } |
1397 | + } |
1398 | } |
1399 | - } |
1400 | } |
1401 | |
1402 | - public void capture (){ |
1403 | - try{ |
1404 | + public void capture () { |
1405 | + try { |
1406 | Thread.create<void*> (this.intercept_key_thread, true); |
1407 | - }catch (ThreadError e){stderr.printf (e.message);} |
1408 | + } catch (ThreadError e) { |
1409 | + stderr.printf (e.message); |
1410 | + } |
1411 | } |
1412 | } |
1413 | } |
1414 | |
1415 | === modified file 'src/Widgets/selectionarea.vala' |
1416 | --- src/Widgets/selectionarea.vala 2015-01-04 14:53:16 +0000 |
1417 | +++ src/Widgets/selectionarea.vala 2015-01-05 22:47:30 +0000 |
1418 | @@ -1,43 +1,41 @@ |
1419 | -using Gtk; |
1420 | -using Granite; |
1421 | - |
1422 | - |
1423 | -namespace Eidete.Widgets{ |
1424 | - |
1425 | - public class SelectionArea : Granite.Widgets.CompositedWindow{ |
1426 | - |
1427 | +namespace Eidete.Widgets { |
1428 | + public class SelectionArea : Granite.Widgets.CompositedWindow { |
1429 | private int[,] pos; |
1430 | public bool discrete; |
1431 | public bool not_visible; |
1432 | - |
1433 | + |
1434 | public int x; |
1435 | public int y; |
1436 | public int w; |
1437 | public int h; |
1438 | - |
1439 | - public SelectionArea (){ |
1440 | + |
1441 | + public SelectionArea () { |
1442 | this.stick (); |
1443 | this.resizable = true; |
1444 | this.set_has_resize_grip (false); |
1445 | this.set_default_geometry (640, 480); |
1446 | - this.events = Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.BUTTON1_MOTION_MASK | |
1447 | - Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ; |
1448 | + this.events = Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.BUTTON1_MOTION_MASK | |
1449 | + Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK; |
1450 | this.skip_taskbar_hint = true; |
1451 | this.skip_pager_hint = true; |
1452 | this.not_visible = false; |
1453 | - |
1454 | - this.button_press_event.connect ( (e) => { |
1455 | + |
1456 | + this.button_press_event.connect ((e) => { |
1457 | Gdk.WindowEdge [] dir = {Gdk.WindowEdge.NORTH_WEST, |
1458 | - Gdk.WindowEdge.NORTH,Gdk.WindowEdge.NORTH_EAST, |
1459 | - Gdk.WindowEdge.EAST,Gdk.WindowEdge.SOUTH_EAST,Gdk.WindowEdge.SOUTH, |
1460 | - Gdk.WindowEdge.SOUTH_WEST,Gdk.WindowEdge.WEST}; |
1461 | - for (var i=0;i<8;i++){ |
1462 | - if (in_quad (pos[i,0]-12, pos[i,1]-10, 24, 24, (int)e.x, (int)e.y)){ |
1463 | + Gdk.WindowEdge.NORTH,Gdk.WindowEdge.NORTH_EAST, |
1464 | + Gdk.WindowEdge.EAST,Gdk.WindowEdge.SOUTH_EAST,Gdk.WindowEdge.SOUTH, |
1465 | + Gdk.WindowEdge.SOUTH_WEST,Gdk.WindowEdge.WEST}; |
1466 | + |
1467 | + for (var i = 0; i < 8; i++) { |
1468 | + if (in_quad (pos[i,0] - 12, pos[i,1] - 10, 24, 24, (int)e.x, (int)e.y)) { |
1469 | this.begin_resize_drag (dir[i], (int)e.button, (int)e.x_root, (int)e.y_root, e.time); |
1470 | + |
1471 | return false; |
1472 | } |
1473 | } |
1474 | + |
1475 | this.begin_move_drag ((int)e.button, (int)e.x_root, (int)e.y_root, e.time); |
1476 | + |
1477 | return false; |
1478 | }); |
1479 | |
1480 | @@ -49,19 +47,18 @@ |
1481 | // if coordinate + width/height is out of the screen, then |
1482 | // adjust coordinates to keep width and height (and aspect |
1483 | // ratio) intact |
1484 | - if( e.x < 0 || e.x > screen_width ) { |
1485 | + |
1486 | + if (e.x < 0 || e.x > screen_width) { |
1487 | x = 0; |
1488 | - } else if( e.x + e.width > screen_width |
1489 | - && e.width < screen_width ) { |
1490 | + } else if (e.x + e.width > screen_width && e.width < screen_width) { |
1491 | x = screen_width - e.width; |
1492 | } else { |
1493 | x = e.x; |
1494 | } |
1495 | - |
1496 | - if( e.y < 0 ) { |
1497 | + |
1498 | + if (e.y < 0) { |
1499 | y = 0; |
1500 | - } else if( e.y + e.height >= screen_height |
1501 | - && e.height < screen_height ) { |
1502 | + } else if (e.y + e.height >= screen_height && e.height < screen_height) { |
1503 | y = screen_height - e.height - 1; |
1504 | } else { |
1505 | y = e.y; |
1506 | @@ -69,95 +66,100 @@ |
1507 | |
1508 | // just in case an edge is still outside of the screen |
1509 | // we'll modify the width/height if thats the case |
1510 | - if( x + e.width > screen_width ) { |
1511 | + |
1512 | + if (x + e.width > screen_width) { |
1513 | w = screen_width - x; |
1514 | } else { |
1515 | w = e.width; |
1516 | } |
1517 | |
1518 | - if( y + e.height > screen_height ) { |
1519 | + if (y + e.height > screen_height) { |
1520 | h = screen_height - y; |
1521 | } else { |
1522 | h = e.height; |
1523 | } |
1524 | - |
1525 | + |
1526 | geometry_changed (x, y, w, h); |
1527 | + |
1528 | return false; |
1529 | }); |
1530 | - |
1531 | - this.destroy.connect ( () => { |
1532 | + |
1533 | + this.destroy.connect (() => { |
1534 | this.not_visible = true; |
1535 | }); |
1536 | } |
1537 | - |
1538 | - private bool in_quad (int qx, int qy, int qh, int qw, int x, int y){ |
1539 | - return ((x>qx) && (x<(qx+qw)) && (y>qy) && (y<qy+qh)); |
1540 | + |
1541 | + private bool in_quad (int qx, int qy, int qh, int qw, int x, int y) { |
1542 | + return ((x > qx) && (x < (qx + qw)) && (y > qy) && (y < qy + qh)); |
1543 | } |
1544 | - |
1545 | - public override bool draw (Cairo.Context ctx){ |
1546 | - int w = this.get_allocated_width (); |
1547 | + |
1548 | + public override bool draw (Cairo.Context ctx) { |
1549 | + int w = this.get_allocated_width (); |
1550 | int h = this.get_allocated_height (); |
1551 | int r = 16; |
1552 | - if (!discrete){ |
1553 | + |
1554 | + if (!discrete) { |
1555 | pos = {{1, 1}, // upper left |
1556 | - {w/2, 1}, // upper midpoint |
1557 | - {w-1, 1}, // upper right |
1558 | - {w-1, h/2}, // right midpoint |
1559 | - {w-1, h-1}, // lower right |
1560 | - {w/2, h-1}, // lower midpoint |
1561 | - {1, h-1}, // lower left |
1562 | - {1, h/2}}; // left midpoint |
1563 | + {w / 2, 1}, // upper midpoint |
1564 | + {w - 1, 1}, // upper right |
1565 | + {w - 1, h / 2}, // right midpoint |
1566 | + {w - 1, h - 1}, // lower right |
1567 | + {w / 2, h - 1}, // lower midpoint |
1568 | + {1, h - 1}, // lower left |
1569 | + {1, h / 2}}; // left midpoint |
1570 | |
1571 | - |
1572 | ctx.rectangle (0, 0, w, h); |
1573 | ctx.set_source_rgba (0.1, 0.1, 0.1, 0.2); |
1574 | ctx.fill (); |
1575 | - |
1576 | - for (var i=0;i<8;i++){ |
1577 | - ctx.arc (pos[i,0], pos[i,1], r, 0.0, 2*3.14); |
1578 | + |
1579 | + for (var i = 0; i < 8; i++) { |
1580 | + ctx.arc (pos[i,0], pos[i,1], r, 0.0, 2 * 3.14); |
1581 | ctx.set_source_rgb (0.7, 0.7, 0.7); |
1582 | ctx.fill (); |
1583 | } |
1584 | + |
1585 | ctx.rectangle (0, 0, w, h); |
1586 | ctx.set_source_rgb (1.0, 1.0, 1.0); |
1587 | ctx.set_line_width (1.0); |
1588 | ctx.stroke (); |
1589 | - }else{ |
1590 | + } else { |
1591 | ctx.rectangle (0, 0, w, h); |
1592 | ctx.set_source_rgb (0.8, 0.0, 0.0); |
1593 | ctx.set_line_width (3.0); |
1594 | ctx.stroke (); |
1595 | } |
1596 | + |
1597 | return base.draw (ctx); |
1598 | } |
1599 | - |
1600 | + |
1601 | public signal void geometry_changed (int x, int y, int width, int height); |
1602 | - |
1603 | - public void to_discrete (){ |
1604 | - if (!this.is_composited ()){ |
1605 | + |
1606 | + public void to_discrete () { |
1607 | + if (!this.is_composited ()) { |
1608 | this.destroy (); |
1609 | + |
1610 | return; |
1611 | } |
1612 | + |
1613 | this.discrete = true; |
1614 | this.set_keep_above (true); |
1615 | this.queue_draw (); |
1616 | - this.resize (w+6, h+6); |
1617 | - this.move (x-2, y-2); |
1618 | + this.resize (w + 6, h + 6); |
1619 | + this.move (x - 2, y - 2); |
1620 | this.deletable = false; |
1621 | this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN; |
1622 | this.accept_focus = false; |
1623 | - |
1624 | + |
1625 | this.realize (); |
1626 | - |
1627 | + |
1628 | Cairo.RectangleInt rect = {0, 0, 1, 1}; |
1629 | this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle (rect), 0, 0); |
1630 | - |
1631 | - this.enter_notify_event.connect ( () => { |
1632 | + |
1633 | + this.enter_notify_event.connect (() => { |
1634 | this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle (rect), 0, 0); |
1635 | + |
1636 | return true; |
1637 | }); |
1638 | } |
1639 | } |
1640 | } |
1641 | - |
1642 | - |
1643 | |
1644 | === modified file 'src/desktop_launcher.vala' |
1645 | --- src/desktop_launcher.vala 2012-06-07 04:40:05 +0000 |
1646 | +++ src/desktop_launcher.vala 2015-01-05 22:47:30 +0000 |
1647 | @@ -1,8 +1,7 @@ |
1648 | namespace DesktopLauncher { |
1649 | - /* Translatable launcher (.desktop) strings to be added to */ |
1650 | - /* template (.pot) file. These strings MUST reflect any */ |
1651 | - /* changes in these launcher keys in .desktop file. */ |
1652 | + // Translatable launcher (.desktop) strings to be added to |
1653 | + // template (.pot) file. These strings MUST reflect any |
1654 | + // changes in these launcher keys in .desktop file. |
1655 | public const string COMMENT = N_("Record screencasts"); |
1656 | public const string GENERIC_NAME = N_("Screencaster"); |
1657 | - |
1658 | } |
1659 | |
1660 | === modified file 'src/eidete.vala' |
1661 | --- src/eidete.vala 2015-01-04 16:20:11 +0000 |
1662 | +++ src/eidete.vala 2015-01-05 22:47:30 +0000 |
1663 | @@ -1,37 +1,33 @@ |
1664 | - |
1665 | -using Gst; |
1666 | -using Granite; |
1667 | -using Gtk; |
1668 | - |
1669 | - |
1670 | -namespace Eidete{ |
1671 | - |
1672 | - class LLabel : Label{ |
1673 | - public LLabel (string label){ |
1674 | - this.set_halign (Align.START); |
1675 | +namespace Eidete { |
1676 | + class LLabel : Gtk.Label { |
1677 | + public LLabel (string label) { |
1678 | + this.set_halign (Gtk.Align.START); |
1679 | this.label = label; |
1680 | } |
1681 | - public LLabel.indent (string label){ |
1682 | + |
1683 | + public LLabel.indent (string label) { |
1684 | this (label); |
1685 | this.margin_left = 10; |
1686 | } |
1687 | - public LLabel.markup (string label){ |
1688 | + |
1689 | + public LLabel.markup (string label) { |
1690 | this (label); |
1691 | this.use_markup = true; |
1692 | } |
1693 | - public LLabel.right (string label){ |
1694 | - this.set_halign (Align.END); |
1695 | + |
1696 | + public LLabel.right (string label) { |
1697 | + this.set_halign (Gtk.Align.END); |
1698 | this.label = label; |
1699 | } |
1700 | - public LLabel.right_with_markup (string label){ |
1701 | - this.set_halign (Align.END); |
1702 | + |
1703 | + public LLabel.right_with_markup (string label) { |
1704 | + this.set_halign (Gtk.Align.END); |
1705 | this.use_markup = true; |
1706 | this.label = label; |
1707 | } |
1708 | } |
1709 | |
1710 | - |
1711 | - public struct Settings{ |
1712 | + public struct Settings { |
1713 | public int sx; |
1714 | public int sy; |
1715 | public int ex; |
1716 | @@ -45,9 +41,8 @@ |
1717 | public string destination; |
1718 | } |
1719 | |
1720 | - public class EideteApp : Granite.Application{ |
1721 | - |
1722 | - construct{ |
1723 | + public class EideteApp : Granite.Application { |
1724 | + construct { |
1725 | program_name = "Eidete"; |
1726 | exec_name = "eidete"; |
1727 | |
1728 | @@ -67,23 +62,23 @@ |
1729 | help_url = "https://code.launchpad.net/eidete"; |
1730 | translate_url = "https://translations.launchpad.net/eidete"; |
1731 | |
1732 | - about_authors = {"Tom Beckmann <tombeckmann@online.de>"}; |
1733 | - about_documenters = {"Tom Beckmann <tombeckmann@online.de>"}; |
1734 | - about_artists = {"Harvey Cabaguio", "Sergey 'shnatsel' Davidoff"}; |
1735 | + about_authors = { "Tom Beckmann <tombeckmann@online.de>" }; |
1736 | + about_documenters = { "Tom Beckmann <tombeckmann@online.de>" }; |
1737 | + about_artists = { "Harvey Cabaguio", "Sergey 'shnatsel' Davidoff" }; |
1738 | about_comments = "Development release (all features not implemented)"; |
1739 | about_translators = ""; |
1740 | - about_license_type = License.GPL_3_0; |
1741 | + about_license_type = Gtk.License.GPL_3_0; |
1742 | } |
1743 | |
1744 | - public dynamic Pipeline pipeline; |
1745 | + public dynamic Gst.Pipeline pipeline; |
1746 | |
1747 | - public Window main_window; |
1748 | + public Gtk.Window main_window; |
1749 | public Eidete.Widgets.KeyView keyview; |
1750 | public Eidete.Widgets.SelectionArea selectionarea; |
1751 | private Gtk.Stack tabs; |
1752 | - private Grid pause_grid; |
1753 | - private Gtk.Grid main_box ; |
1754 | - private Gtk.StackSwitcher stack_switcher ; |
1755 | + private Gtk.Grid pause_grid; |
1756 | + private Gtk.Grid main_box; |
1757 | + private Gtk.StackSwitcher stack_switcher; |
1758 | public Wnck.Window win; |
1759 | public Gdk.Screen screen; |
1760 | public Gdk.Rectangle monitor_rec; |
1761 | @@ -96,17 +91,16 @@ |
1762 | public Gst.Bin videobin; |
1763 | public Gst.Bin audiobin; |
1764 | |
1765 | - public EideteApp (){ |
1766 | + public EideteApp () { |
1767 | } |
1768 | |
1769 | public void start_and_build () { |
1770 | - |
1771 | Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true; |
1772 | |
1773 | - this.main_window = new Window (); |
1774 | + this.main_window = new Gtk.Window (); |
1775 | this.main_window.icon_name = exec_name; |
1776 | this.main_window.set_application (this); |
1777 | - this.main_window.window_position = WindowPosition.CENTER; |
1778 | + this.main_window.window_position = Gtk.WindowPosition.CENTER; |
1779 | this.main_window.set_resizable (false); |
1780 | |
1781 | /* Use CSD */ |
1782 | @@ -114,90 +108,94 @@ |
1783 | header.title = program_name; |
1784 | header.set_show_close_button (true); |
1785 | header.get_style_context ().remove_class ("header-bar"); |
1786 | + |
1787 | this.main_window.set_titlebar (header); |
1788 | |
1789 | if (!this.main_window.is_composited ()){ |
1790 | warning ("Compositing is not supported. No transparency available."); |
1791 | } |
1792 | |
1793 | - |
1794 | /* |
1795 | UI |
1796 | */ |
1797 | |
1798 | tabs = new Gtk.Stack (); |
1799 | |
1800 | - var grid = new Grid (); |
1801 | + var grid = new Gtk.Grid (); |
1802 | grid.column_spacing = 12; |
1803 | grid.row_spacing = 6; |
1804 | grid.hexpand = false; |
1805 | |
1806 | - var monitors_combo = new ComboBoxText (); |
1807 | + var monitors_combo = new Gtk.ComboBoxText (); |
1808 | monitors_combo.hexpand = true; |
1809 | - for (var i=0;i<Gdk.Screen.get_default ().get_n_monitors (); i++) |
1810 | + |
1811 | + for (var i = 0; i < Gdk.Screen.get_default ().get_n_monitors (); i++) { |
1812 | // TODO proper translation here |
1813 | monitors_combo.append (i.to_string (), _("Monitor")+" "+(i+1).to_string ()); |
1814 | + } |
1815 | + |
1816 | monitors_combo.active = 0; |
1817 | + |
1818 | if (Gdk.Screen.get_default ().get_n_monitors () == 1) |
1819 | monitors_combo.set_sensitive (false); |
1820 | |
1821 | - var width = new SpinButton.with_range (50, Gdk.Screen.get_default ().get_width (), 1); |
1822 | + var width = new Gtk.SpinButton.with_range (50, Gdk.Screen.get_default ().get_width (), 1); |
1823 | width.max_length = 4; |
1824 | width.margin_left = 1; |
1825 | |
1826 | - var height = new SpinButton.with_range (50, Gdk.Screen.get_default ().get_height (), 1); |
1827 | + var height = new Gtk.SpinButton.with_range (50, Gdk.Screen.get_default ().get_height (), 1); |
1828 | height.max_length = 4; |
1829 | height.margin_left = 1; |
1830 | width.set_sensitive (false); |
1831 | height.set_sensitive (false); |
1832 | - width.halign = Align.START; |
1833 | - height.halign = Align.START; |
1834 | + width.halign = Gtk.Align.START; |
1835 | + height.halign = Gtk.Align.START; |
1836 | |
1837 | - var recordingarea_combo = new ComboBoxText (); |
1838 | + var recordingarea_combo = new Gtk.ComboBoxText (); |
1839 | recordingarea_combo.append ("full", _("Fullscreen")); |
1840 | recordingarea_combo.append ("custom", _("Custom")); |
1841 | recordingarea_combo.active = 0; |
1842 | |
1843 | - var use_comp_sounds = new CheckButton (); |
1844 | - use_comp_sounds.halign = Align.START; |
1845 | + var use_comp_sounds = new Gtk.CheckButton (); |
1846 | + use_comp_sounds.halign = Gtk.Align.START; |
1847 | use_comp_sounds.set_sensitive (false); |
1848 | |
1849 | - var use_audio = new CheckButton (); |
1850 | - use_audio.halign = Align.START; |
1851 | + var use_audio = new Gtk.CheckButton (); |
1852 | + use_audio.halign =Gtk. Align.START; |
1853 | |
1854 | - var audio_source = new ComboBoxText (); |
1855 | + var audio_source = new Gtk.ComboBoxText (); |
1856 | audio_source.append ("0", _("Default")); |
1857 | audio_source.active = 0; |
1858 | audio_source.hexpand = true; |
1859 | audio_source.set_sensitive (false); |
1860 | |
1861 | - var audio_box = new Box (Orientation.HORIZONTAL, 0); |
1862 | + var audio_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
1863 | audio_box.pack_start (use_audio, false, true, 0); |
1864 | audio_box.pack_start (audio_source, true, true, 0); |
1865 | |
1866 | - var sound = new LLabel.markup ("<b>"+_("Sound")+"</b>"); |
1867 | + var sound = new LLabel.markup ("<b>" + _("Sound") + "</b>"); |
1868 | sound.margin_top = 18; |
1869 | |
1870 | - var video = new LLabel.markup ("<b>"+_("Video")+"</b>"); |
1871 | + var video = new LLabel.markup ("<b>" + _("Video") + "</b>"); |
1872 | video.margin_top = 12; |
1873 | |
1874 | - var keyboard = new LLabel.markup ("<b>"+_("Keyboard")+"</b>"); |
1875 | + var keyboard = new LLabel.markup ("<b>" + _("Keyboard") + "</b>"); |
1876 | keyboard.margin_top = 18; |
1877 | |
1878 | - var mouse = new LLabel.markup ("<b>"+_("Mouse")+"</b>"); |
1879 | + var mouse = new LLabel.markup ("<b>" + _("Mouse") + "</b>"); |
1880 | mouse.margin_top = 12; |
1881 | |
1882 | - var start_bt = new Button.with_label (_("Start Recording")); |
1883 | + var start_bt = new Gtk.Button.with_label (_("Start Recording")); |
1884 | start_bt.can_default = true; |
1885 | start_bt.get_style_context ().add_class ("noundo"); |
1886 | start_bt.get_style_context ().add_class ("suggested-action"); |
1887 | |
1888 | - var cancel_bt = new Button.with_label (_("Cancel")); |
1889 | - |
1890 | - var about_bt = new Button.with_label (_("About")); |
1891 | - about_bt.image = new Image.from_stock (Stock.ABOUT, IconSize.BUTTON); |
1892 | - |
1893 | - var buttons = new Box (Orientation.HORIZONTAL, 5); |
1894 | + var cancel_bt = new Gtk.Button.with_label (_("Cancel")); |
1895 | + |
1896 | + var about_bt = new Gtk.Button.with_label (_("About")); |
1897 | + about_bt.image = new Gtk.Image.from_stock (Gtk.Stock.ABOUT, Gtk.IconSize.BUTTON); |
1898 | + |
1899 | + var buttons = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5); |
1900 | buttons.homogeneous = true; |
1901 | buttons.pack_start (about_bt, false, true, 0); |
1902 | buttons.pack_start (cancel_bt, false, true, 0); |
1903 | @@ -206,48 +204,48 @@ |
1904 | |
1905 | this.main_window.set_default (start_bt); |
1906 | |
1907 | - grid.attach ((sound), 0, 0, 1, 1); |
1908 | - grid.attach (new LLabel.right (_("Record Computer Sounds")+":"), 0, 1, 1, 1); |
1909 | + grid.attach (sound, 0, 0, 1, 1); |
1910 | + grid.attach (new LLabel.right (_("Record Computer Sounds") + ":"), 0, 1, 1, 1); |
1911 | grid.attach (use_comp_sounds, 1, 1, 1, 1); |
1912 | - grid.attach (new LLabel.right (_("Record from Microphone")+":"), 0, 2, 1, 1); |
1913 | + grid.attach (new LLabel.right (_("Record from Microphone") + ":"), 0, 2, 1, 1); |
1914 | grid.attach (audio_box, 1, 2, 1, 1); |
1915 | grid.attach ((video), 0, 3, 2, 1); |
1916 | - grid.attach (new LLabel.right (" "+_("Record from Monitor")+":"), 0, 4, 1, 1); |
1917 | + grid.attach (new LLabel.right (" " + _("Record from Monitor") + ":"), 0, 4, 1, 1); |
1918 | grid.attach (monitors_combo, 1, 4, 1, 1); |
1919 | - grid.attach (new LLabel.right (_("Recording Area")+":"), 0, 5, 1, 1); |
1920 | + grid.attach (new LLabel.right (_("Recording Area") + ":"), 0, 5, 1, 1); |
1921 | grid.attach (recordingarea_combo, 1, 5, 1, 1); |
1922 | - grid.attach (new LLabel.right (_("Width")+":"), 0, 6, 1, 1); |
1923 | + grid.attach (new LLabel.right (_("Width") + ":"), 0, 6, 1, 1); |
1924 | grid.attach (width, 1, 6, 1, 1); |
1925 | - grid.attach (new LLabel.right (_("Height")+":"), 0, 7, 1, 1); |
1926 | + grid.attach (new LLabel.right (_("Height") + ":"), 0, 7, 1, 1); |
1927 | grid.attach (height, 1, 7, 1, 1); |
1928 | grid.attach (buttons, 0, 8, 2, 1); |
1929 | |
1930 | //grid2 |
1931 | - var grid2 = new Grid (); |
1932 | - |
1933 | - var use_keyview = new Gtk.CheckButton (); |
1934 | - use_keyview.halign = Gtk.Align.START; |
1935 | - |
1936 | - var use_clickview = new Gtk.CheckButton (); |
1937 | - use_clickview.halign = Gtk.Align.START; |
1938 | - |
1939 | - var use_circle = new Gtk.CheckButton (); |
1940 | - use_circle.halign = Gtk.Align.START; |
1941 | - |
1942 | - var circle_color = new Gtk.ColorButton (); |
1943 | - |
1944 | - var circle_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
1945 | + var grid2 = new Gtk.Grid (); |
1946 | + |
1947 | + var use_keyview = new Gtk.CheckButton (); |
1948 | + use_keyview.halign = Gtk.Align.START; |
1949 | + |
1950 | + var use_clickview = new Gtk.CheckButton (); |
1951 | + use_clickview.halign = Gtk.Align.START; |
1952 | + |
1953 | + var use_circle = new Gtk.CheckButton (); |
1954 | + use_circle.halign = Gtk.Align.START; |
1955 | + |
1956 | + var circle_color = new Gtk.ColorButton (); |
1957 | + |
1958 | + var circle_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
1959 | circle_box.pack_start (use_circle, false); |
1960 | circle_box.pack_start (circle_color); |
1961 | |
1962 | //grid2.attach (new LLabel |
1963 | grid2.attach ((keyboard), 0, 0, 1, 1); |
1964 | - grid2.attach (new LLabel.right (_("Pressed keys on screen")+":"), 0, 1, 1, 1); |
1965 | + grid2.attach (new LLabel.right (_("Pressed keys on screen") + ":"), 0, 1, 1, 1); |
1966 | grid2.attach (use_keyview, 1, 1, 1, 1); |
1967 | grid2.attach ((mouse), 0, 2, 1, 1); |
1968 | - grid2.attach (new LLabel.right (_("Mouse clicks on screen")+":"), 0, 3, 1, 1); |
1969 | + grid2.attach (new LLabel.right (_("Mouse clicks on screen") + ":"), 0, 3, 1, 1); |
1970 | grid2.attach (use_clickview, 1, 3, 1, 1); |
1971 | - grid2.attach (new LLabel.right (_("Circle around the cursor")+":"), 0, 4, 1, 1); |
1972 | + grid2.attach (new LLabel.right (_("Circle around the cursor") + ":"), 0, 4, 1, 1); |
1973 | grid2.attach (circle_box, 1, 4, 1, 1); |
1974 | grid2.column_spacing = 12; |
1975 | grid2.row_spacing = 6; |
1976 | @@ -260,7 +258,7 @@ |
1977 | stack_switcher = new Gtk.StackSwitcher (); |
1978 | stack_switcher.stack = tabs; |
1979 | stack_switcher.halign = Gtk.Align.CENTER; |
1980 | - build_pause_ui () ; |
1981 | + build_pause_ui (); |
1982 | pause_grid.show_all(); |
1983 | pause_grid.hide(); |
1984 | pause_grid.no_show_all = true; |
1985 | @@ -278,15 +276,15 @@ |
1986 | Events |
1987 | */ |
1988 | |
1989 | - about_bt.clicked.connect ( () => { |
1990 | + about_bt.clicked.connect (() => { |
1991 | this.show_about (this.main_window); |
1992 | }); |
1993 | |
1994 | - cancel_bt.clicked.connect ( () => { |
1995 | + cancel_bt.clicked.connect (() => { |
1996 | this.main_window.destroy (); |
1997 | }); |
1998 | |
1999 | - start_bt.clicked.connect ( () => { |
2000 | + start_bt.clicked.connect (() => { |
2001 | var count = new Eidete.Widgets.Countdown (); |
2002 | this.main_window.iconify (); |
2003 | count.start (this); |
2004 | @@ -294,9 +292,11 @@ |
2005 | |
2006 | this.screen = Gdk.Screen.get_default(); |
2007 | settings.monitor = 0; |
2008 | - monitors_combo.changed.connect ( () => { |
2009 | + monitors_combo.changed.connect (() => { |
2010 | settings.monitor = int.parse (monitors_combo.active_id); |
2011 | + |
2012 | this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec); |
2013 | + |
2014 | settings.sx = this.monitor_rec.x; |
2015 | settings.sy = this.monitor_rec.y; |
2016 | settings.ex = settings.sx + this.monitor_rec.width - 1; |
2017 | @@ -304,69 +304,88 @@ |
2018 | }); |
2019 | |
2020 | settings.monitor = int.parse (monitors_combo.active_id); |
2021 | + |
2022 | this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec); |
2023 | + |
2024 | settings.sx = this.monitor_rec.x; |
2025 | settings.sy = this.monitor_rec.y; |
2026 | settings.ex = settings.sx + this.monitor_rec.width - 1; |
2027 | settings.ey = settings.sy + this.monitor_rec.height - 1; |
2028 | |
2029 | - recordingarea_combo.changed.connect ( () => { |
2030 | + recordingarea_combo.changed.connect (() => { |
2031 | if (recordingarea_combo.active_id != "full"){ |
2032 | selectionarea = new Eidete.Widgets.SelectionArea (); |
2033 | selectionarea.show_all (); |
2034 | width.set_sensitive (true); |
2035 | height.set_sensitive (true); |
2036 | - selectionarea.geometry_changed.connect ( (x, y, w, h) => { |
2037 | + selectionarea.geometry_changed.connect ((x, y, w, h) => { |
2038 | if (!typing_size){ |
2039 | width.value = (int)w; |
2040 | height.value = (int)h; |
2041 | settings.sx = x; |
2042 | settings.sy = y; |
2043 | - settings.ex = settings.sx+w-1; |
2044 | - settings.ey = settings.sy+h-1; |
2045 | + settings.ex = settings.sx + w-1; |
2046 | + settings.ey = settings.sy + h-1; |
2047 | } |
2048 | }); |
2049 | - selectionarea.focus_in_event.connect( (ev) => { |
2050 | + |
2051 | + selectionarea.focus_in_event.connect((ev) => { |
2052 | if (this.recording){ |
2053 | this.main_window.deiconify(); |
2054 | this.main_window.present(); |
2055 | } |
2056 | + |
2057 | return false; |
2058 | }); |
2059 | - }else{ |
2060 | + } else { |
2061 | selectionarea.destroy (); |
2062 | settings.monitor = int.parse (monitors_combo.active_id); |
2063 | + |
2064 | this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec); |
2065 | + |
2066 | settings.sx = this.monitor_rec.x; |
2067 | settings.sy = this.monitor_rec.y; |
2068 | settings.ex = settings.sx + this.monitor_rec.width - 1; |
2069 | settings.ey = settings.sy + this.monitor_rec.height - 1; |
2070 | + |
2071 | width.set_sensitive (false); |
2072 | height.set_sensitive (false); |
2073 | } |
2074 | }); |
2075 | |
2076 | - width.key_release_event.connect ( (e) => { |
2077 | - selectionarea.resize ((int)width.value, (int)height.value); |
2078 | - typing_size = true; |
2079 | - return false; |
2080 | - }); |
2081 | - width.focus_out_event.connect ( (e) => {typing_size = false;return false;}); |
2082 | - height.key_release_event.connect ( (e) => { |
2083 | - selectionarea.resize ((int)width.value, (int)height.value); |
2084 | - typing_size = true; |
2085 | - return false; |
2086 | - }); |
2087 | - height.focus_out_event.connect ( (e) => {typing_size = false;return false;}); |
2088 | + width.key_release_event.connect ((e) => { |
2089 | + selectionarea.resize ((int)width.value, (int)height.value); |
2090 | + typing_size = true; |
2091 | + |
2092 | + return false; |
2093 | + }); |
2094 | + |
2095 | + width.focus_out_event.connect ((e) => { |
2096 | + typing_size = false; |
2097 | + |
2098 | + return false; |
2099 | + }); |
2100 | + |
2101 | + height.key_release_event.connect ((e) => { |
2102 | + selectionarea.resize ((int)width.value, (int)height.value); |
2103 | + typing_size = true; |
2104 | + |
2105 | + return false; |
2106 | + }); |
2107 | + |
2108 | + height.focus_out_event.connect ((e) => { |
2109 | + typing_size = false; |
2110 | + |
2111 | + return false; |
2112 | + }); |
2113 | |
2114 | settings.audio = false; |
2115 | - use_audio.toggled.connect ( () => { |
2116 | + use_audio.toggled.connect (() => { |
2117 | settings.audio = use_audio.active; |
2118 | audio_source.set_sensitive (use_audio.active); |
2119 | }); |
2120 | |
2121 | - |
2122 | - Gdk.Screen.get_default ().monitors_changed.connect ( () => { |
2123 | + Gdk.Screen.get_default ().monitors_changed.connect (() => { |
2124 | if (Gdk.Screen.get_default ().get_n_monitors () > 1) |
2125 | monitors_combo.set_sensitive (true); |
2126 | else |
2127 | @@ -374,84 +393,92 @@ |
2128 | }); |
2129 | |
2130 | settings.keyview = false; |
2131 | - use_keyview.toggled.connect ( () => { |
2132 | + use_keyview.toggled.connect (() => { |
2133 | settings.keyview = use_keyview.active; |
2134 | }); |
2135 | |
2136 | settings.clickview = false; |
2137 | - use_clickview.toggled.connect ( () => { |
2138 | - settings.clickview = use_clickview.active; |
2139 | + use_clickview.toggled.connect (() => { |
2140 | + settings.clickview = use_clickview.active; |
2141 | }); |
2142 | |
2143 | settings.mouse_circle = false; |
2144 | - use_circle.toggled.connect ( () => { |
2145 | - settings.mouse_circle = use_circle.active; |
2146 | + use_circle.toggled.connect (() => { |
2147 | + settings.mouse_circle = use_circle.active; |
2148 | }); |
2149 | |
2150 | settings.mouse_circle_color = {1, 1, 0, 0.3}; |
2151 | circle_color.use_alpha = true; |
2152 | circle_color.rgba = settings.mouse_circle_color; |
2153 | - circle_color.color_set.connect ( () => { |
2154 | - settings.mouse_circle_color = circle_color.rgba; |
2155 | - }); |
2156 | - |
2157 | - settings.destination = GLib.Environment.get_tmp_dir ()+ |
2158 | - "/screencast"+new GLib.DateTime.now_local ().to_unix ().to_string ()+".webm"; |
2159 | - |
2160 | - ulong handle = 0; |
2161 | - handle = Wnck.Screen.get_default().active_window_changed.connect ( () => { |
2162 | - this.win = Wnck.Screen.get_default().get_active_window (); |
2163 | - this.win.state_changed.connect ( (changed_s, new_s) => { |
2164 | - if (recording && (new_s == 0)){ |
2165 | - pipeline.set_state (State.PAUSED); |
2166 | - this.recording = false; |
2167 | - switch_to_paused (true); |
2168 | - } |
2169 | - }); |
2170 | - Wnck.Screen.get_default ().disconnect (handle); |
2171 | - }); |
2172 | - |
2173 | - this.main_window.focus_in_event.connect ( (ev) => { |
2174 | - if (this.selectionarea != null && !this.selectionarea.not_visible){ |
2175 | - this.selectionarea.present (); |
2176 | - this.main_window.present (); |
2177 | - } |
2178 | - return false; |
2179 | - }); |
2180 | + circle_color.color_set.connect (() => { |
2181 | + settings.mouse_circle_color = circle_color.rgba; |
2182 | + }); |
2183 | + |
2184 | + settings.destination = GLib.Environment.get_tmp_dir () + |
2185 | + "/screencast" + new GLib.DateTime.now_local ().to_unix ().to_string () + ".webm"; |
2186 | + |
2187 | + ulong handle = 0; |
2188 | + handle = Wnck.Screen.get_default().active_window_changed.connect (() => { |
2189 | + this.win = Wnck.Screen.get_default().get_active_window (); |
2190 | + this.win.state_changed.connect ( (changed_s, new_s) => { |
2191 | + if (recording && (new_s == 0)) { |
2192 | + pipeline.set_state (Gst.State.PAUSED); |
2193 | + this.recording = false; |
2194 | + switch_to_paused (true); |
2195 | + } |
2196 | + }); |
2197 | + |
2198 | + Wnck.Screen.get_default ().disconnect (handle); |
2199 | + }); |
2200 | + |
2201 | + this.main_window.focus_in_event.connect ((ev) => { |
2202 | + if (this.selectionarea != null && !this.selectionarea.not_visible){ |
2203 | + this.selectionarea.present (); |
2204 | + this.main_window.present (); |
2205 | + } |
2206 | + |
2207 | + return false; |
2208 | + }); |
2209 | + |
2210 | /* disabled for now until mutter supports it better |
2211 | - this.main_window.visibility_notify_event.connect ( (ev) => { |
2212 | + this.main_window.visibility_notify_event.connect ((ev) => { |
2213 | if (this.recording && ev.state == 0){ |
2214 | debug ("pausing recording"); |
2215 | + |
2216 | pipeline.set_state (State.PAUSED); |
2217 | this.recording = false; |
2218 | switch_to_paused (true); |
2219 | } |
2220 | + |
2221 | return false; |
2222 | }); |
2223 | */ |
2224 | |
2225 | - this.main_window.destroy.connect ( () => { |
2226 | - if ( recording ) { |
2227 | + this.main_window.destroy.connect (() => { |
2228 | + if (recording) { |
2229 | finish_recording (); |
2230 | } |
2231 | }); |
2232 | |
2233 | Granite.Services.Logger.initialize ("Eidete"); |
2234 | Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; |
2235 | - uint major ; |
2236 | - uint minor ; |
2237 | - uint micro ; |
2238 | - uint nano ; |
2239 | - Gst.version (out major, out minor, out micro, out nano) ; |
2240 | - message ("GStreamer version: %u.%u.%u.%u", major, minor, micro, nano ) ; |
2241 | + |
2242 | + uint major; |
2243 | + uint minor; |
2244 | + uint micro; |
2245 | + uint nano; |
2246 | + |
2247 | + Gst.version (out major, out minor, out micro, out nano); |
2248 | + |
2249 | + message ("GStreamer version: %u.%u.%u.%u", major, minor, micro, nano ); |
2250 | } |
2251 | |
2252 | - public override void activate (){ |
2253 | - if (this.get_windows ().length () == 0){ |
2254 | + public override void activate () { |
2255 | + if (this.get_windows ().length () == 0) { |
2256 | this.start_and_build (); |
2257 | - }else{ |
2258 | - if (pause_rec) |
2259 | - this.main_window.present (); |
2260 | + } else { |
2261 | + if (pause_rec) |
2262 | + this.main_window.present (); |
2263 | else if (finish_rec) { |
2264 | finish_recording (); |
2265 | } |
2266 | @@ -459,47 +486,44 @@ |
2267 | } |
2268 | |
2269 | private void build_pause_ui (){ |
2270 | - |
2271 | - pause_grid = new Grid (); |
2272 | + pause_grid = new Gtk.Grid (); |
2273 | pause_grid.margin = 12; |
2274 | //this.main_window.title = _("Recording paused"); |
2275 | |
2276 | - |
2277 | - var img_text_grid = new Grid (); |
2278 | - |
2279 | - var text_grid = new Grid (); |
2280 | - |
2281 | - var title = new LLabel.markup ("<span weight='bold' size='larger'>"+_("Recording paused")+"</span>"); |
2282 | - title.valign = Align.START; |
2283 | + var img_text_grid = new Gtk.Grid (); |
2284 | + var text_grid = new Gtk.Grid (); |
2285 | + |
2286 | + var title = new LLabel.markup ("<span weight='bold' size='larger'>" + _("Recording paused") + "</span>"); |
2287 | + title.valign = Gtk.Align.START; |
2288 | |
2289 | var info = new LLabel (_("You can continue or finish the recording now")); |
2290 | - info.valign = Align.START; |
2291 | + info.valign = Gtk.Align.START; |
2292 | info.margin_top = 6; |
2293 | |
2294 | - var buttons = new Box (Orientation.HORIZONTAL, 0); |
2295 | + var buttons = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
2296 | buttons.homogeneous = true; |
2297 | buttons.spacing = 6; |
2298 | buttons.margin_top = 24; |
2299 | |
2300 | - var continue_bt = new Button.with_label (_("Continue")); |
2301 | + var continue_bt = new Gtk.Button.with_label (_("Continue")); |
2302 | continue_bt.set_tooltip_text (_("Continue recording")); |
2303 | - continue_bt.image = new Image.from_stock (Stock.MEDIA_RECORD, IconSize.BUTTON); |
2304 | + continue_bt.image = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_RECORD, Gtk.IconSize.BUTTON); |
2305 | |
2306 | - var stop_bt = new Button.with_label (_("Finish")); |
2307 | + var stop_bt = new Gtk.Button.with_label (_("Finish")); |
2308 | stop_bt.set_tooltip_text (_("Stop the recording and save the file")); |
2309 | - stop_bt.image = new Image.from_stock (Stock.APPLY, IconSize.BUTTON); |
2310 | + stop_bt.image = new Gtk.Image.from_stock (Gtk.Stock.APPLY, Gtk.IconSize.BUTTON); |
2311 | stop_bt.get_style_context ().add_class ("suggested-action"); |
2312 | |
2313 | - var cancel_bt = new Button.with_label (_("Cancel")); |
2314 | + var cancel_bt = new Gtk.Button.with_label (_("Cancel")); |
2315 | cancel_bt.set_tooltip_text (_("Cancel the recording without saving the file")); |
2316 | - cancel_bt.image = new Image.from_stock (Stock.DELETE, IconSize.BUTTON); |
2317 | + cancel_bt.image = new Gtk.Image.from_stock (Gtk.Stock.DELETE, Gtk.IconSize.BUTTON); |
2318 | |
2319 | buttons.pack_end (stop_bt, false, true, 0); |
2320 | buttons.pack_end (continue_bt, false, true, 0); |
2321 | buttons.pack_end (cancel_bt, false, true, 0); |
2322 | |
2323 | - var img = new Image.from_stock (Stock.MEDIA_PAUSE, IconSize.DIALOG); |
2324 | - img.valign = Align.START; |
2325 | + var img = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_PAUSE, Gtk.IconSize.DIALOG); |
2326 | + img.valign = Gtk.Align.START; |
2327 | img.margin_right = 12; |
2328 | |
2329 | text_grid.attach (title, 0, 0, 1, 1); |
2330 | @@ -511,25 +535,26 @@ |
2331 | pause_grid.attach (img_text_grid, 0, 0, 1, 1); |
2332 | pause_grid.attach (buttons, 0, 2, 1, 1); |
2333 | |
2334 | - |
2335 | stop_bt.can_default = true; |
2336 | this.main_window.set_default (stop_bt); |
2337 | |
2338 | /* |
2339 | Events |
2340 | */ |
2341 | - cancel_bt.clicked.connect ( () => { |
2342 | + |
2343 | + cancel_bt.clicked.connect (() => { |
2344 | this.main_window.destroy (); |
2345 | }); |
2346 | |
2347 | - stop_bt.clicked.connect ( () => { |
2348 | + stop_bt.clicked.connect (() => { |
2349 | finish_recording (); |
2350 | }); |
2351 | |
2352 | - continue_bt.clicked.connect ( () => { |
2353 | + continue_bt.clicked.connect (() => { |
2354 | this.main_window.iconify (); |
2355 | - this.pipeline.set_state (State.PLAYING); |
2356 | + this.pipeline.set_state (Gst.State.PLAYING); |
2357 | this.recording = true; |
2358 | + |
2359 | switch_to_paused (false); |
2360 | }); |
2361 | } |
2362 | @@ -542,79 +567,92 @@ |
2363 | this.main_window.deiconify (); |
2364 | this.main_window.present (); |
2365 | } |
2366 | + |
2367 | return false; |
2368 | }); |
2369 | - keyview.place (settings.ex, |
2370 | - settings.sy, |
2371 | - settings.ey - settings.sy); |
2372 | + |
2373 | + keyview.place (settings.ex, settings.sy, settings.ey - settings.sy); |
2374 | keyview.show_all (); |
2375 | } |
2376 | |
2377 | - pipeline = new Pipeline ("screencast-pipe"); |
2378 | - |
2379 | - #if GSTREAMER_0_10_IS_DEFINED |
2380 | - dynamic Element muxer = ElementFactory.make ("webmmux", "mux"); |
2381 | - dynamic Element sink = ElementFactory.make ("filesink", "sink"); |
2382 | - #else |
2383 | - var muxer = ElementFactory.make ("webmmux", "mux"); |
2384 | - var sink = ElementFactory.make ("filesink", "sink"); |
2385 | - #endif |
2386 | + pipeline = new Gst.Pipeline ("screencast-pipe"); |
2387 | + |
2388 | +#if GSTREAMER_0_10_IS_DEFINED |
2389 | + dynamic Element muxer = Gst.ElementFactory.make ("webmmux", "mux"); |
2390 | + dynamic Element sink = Gst.ElementFactory.make ("filesink", "sink"); |
2391 | +#else |
2392 | + var muxer = Gst.ElementFactory.make ("webmmux", "mux"); |
2393 | + var sink = Gst.ElementFactory.make ("filesink", "sink"); |
2394 | +#endif |
2395 | + |
2396 | //video bin |
2397 | this.videobin = new Gst.Bin ("video"); |
2398 | + |
2399 | try { |
2400 | - #if GSTREAMER_0_10_IS_DEFINED |
2401 | - videobin = (Gst.Bin)parse_bin_from_description ( |
2402 | - "ximagesrc name=\"videosrc\" ! video/x-raw-rgb, framerate=15/1 ! |
2403 | - ffmpegcolorspace ! vp8enc name=\"encoder\" ! queue", true); |
2404 | - #else |
2405 | - videobin = (Gst.Bin)parse_bin_from_description ( |
2406 | - "ximagesrc name=\"videosrc\" ! video/x-raw, framerate=24/1 ! videoconvert ! vp8enc name=\"encoder\" ! queue", true); |
2407 | - #endif |
2408 | - }catch (Error e){ stderr.printf ("Error: %s\n", e.message);} |
2409 | +#if GSTREAMER_0_10_IS_DEFINED |
2410 | + videobin = (Gst.Bin)Gst.parse_bin_from_description ( |
2411 | + "ximagesrc name=\"videosrc\" ! video/x-raw-rgb, framerate=15/1 ! |
2412 | + ffmpegcolorspace ! vp8enc name=\"encoder\" ! queue", true); |
2413 | +#else |
2414 | + videobin = (Gst.Bin)Gst.parse_bin_from_description ( |
2415 | + "ximagesrc name=\"videosrc\" ! video/x-raw, framerate=24/1 ! videoconvert ! vp8enc name=\"encoder\" ! queue", true); |
2416 | +#endif |
2417 | + } catch (Error e) { |
2418 | + stderr.printf ("Error: %s\n", e.message); |
2419 | + } |
2420 | |
2421 | //audio bin |
2422 | this.audiobin = new Gst.Bin ("audio"); |
2423 | - try{ |
2424 | - audiobin = (Gst.Bin)parse_bin_from_description ("pulsesrc name=\"audiosrc\" ! |
2425 | - audioconvert ! audioresample ! audiorate ! vorbisenc ! queue", true); |
2426 | - }catch (Error e){ stderr.printf ("Error: %s\n", e.message);} |
2427 | |
2428 | + try { |
2429 | + audiobin = (Gst.Bin)Gst.parse_bin_from_description ("pulsesrc name=\"audiosrc\" ! |
2430 | + audioconvert ! audioresample ! audiorate ! vorbisenc ! queue", true); |
2431 | + } catch (Error e) { |
2432 | + stderr.printf ("Error: %s\n", e.message); |
2433 | + } |
2434 | |
2435 | string cores; |
2436 | - try{ |
2437 | + |
2438 | + try { |
2439 | Process.spawn_command_line_sync ("cat /sys/devices/system/cpu/online", out cores); |
2440 | - }catch (Error e){warning (e.message);} |
2441 | + } catch (Error e) { |
2442 | + warning (e.message); |
2443 | + } |
2444 | |
2445 | //configure |
2446 | - assert( sink != null ) ; |
2447 | + assert( sink != null ); |
2448 | sink.set ("location", settings.destination); |
2449 | - var src = videobin.get_by_name ("videosrc") ; |
2450 | - assert (src != null) ; |
2451 | + |
2452 | + var src = videobin.get_by_name ("videosrc"); |
2453 | + |
2454 | + assert (src != null); |
2455 | + |
2456 | src.set ("startx", this.settings.sx); |
2457 | src.set ("starty", this.settings.sy); |
2458 | - src.set ("endx", this.settings.ex); |
2459 | + src.set ("endx", this.settings.ex); |
2460 | src.set ("endy", this.settings.ey); |
2461 | src.set ("use-damage", false); |
2462 | src.set ("screen-num", this.settings.monitor); |
2463 | |
2464 | //videobin.get_by_name ("encoder").set ("mode", 1); |
2465 | - var encoder = videobin.get_by_name ("encoder") ; |
2466 | - assert (encoder != null) ; |
2467 | - #if GSTREAMER_0_10_IS_DEFINED |
2468 | + var encoder = videobin.get_by_name ("encoder"); |
2469 | + |
2470 | + assert (encoder != null); |
2471 | + |
2472 | +#if GSTREAMER_0_10_IS_DEFINED |
2473 | encoder.set ("quality", 8.0); |
2474 | encoder.set ("speed", 6); |
2475 | encoder.set ("max-keyframe-distance", 150); |
2476 | - #else |
2477 | +#else |
2478 | // From these values see https://mail.gnome.org/archives/commits-list/2012-September/msg08183.html |
2479 | encoder.set ("min_quantizer", 13); |
2480 | encoder.set ("max_quantizer", 13); |
2481 | encoder.set ("cpu-used", 5); |
2482 | encoder.set ("deadline", 1000000); |
2483 | - #endif |
2484 | +#endif |
2485 | encoder.set ("threads", int.parse (cores.substring (2))); |
2486 | |
2487 | - |
2488 | - if (pipeline==null||muxer==null||sink==null||videobin==null||audiobin==null){ |
2489 | + if (pipeline == null || muxer == null || sink == null || videobin == null || audiobin == null){ |
2490 | stderr.printf ("Error: Elements weren't made correctly!\n"); |
2491 | } |
2492 | |
2493 | @@ -623,61 +661,75 @@ |
2494 | else |
2495 | pipeline.add_many (videobin, muxer, sink); |
2496 | |
2497 | - |
2498 | - var video_pad = videobin.get_static_pad ("src") ; |
2499 | - assert (video_pad != null ) ; |
2500 | - #if GSTREAMER_0_10_IS_DEFINED |
2501 | - var m = muxer.get_request_pad ("video_%d") ; |
2502 | - #else |
2503 | - var m = muxer.get_request_pad ("video_%u") ; |
2504 | - #endif |
2505 | - assert (m != null ) ; |
2506 | + var video_pad = videobin.get_static_pad ("src"); |
2507 | + |
2508 | + assert (video_pad != null ); |
2509 | + |
2510 | +#if GSTREAMER_0_10_IS_DEFINED |
2511 | + var m = muxer.get_request_pad ("video_%d"); |
2512 | +#else |
2513 | + var m = muxer.get_request_pad ("video_%u"); |
2514 | +#endif |
2515 | + |
2516 | + assert (m != null); |
2517 | + |
2518 | video_pad.link(m); |
2519 | - if (settings.audio){ |
2520 | - #if GSTREAMER_0_10_IS_DEFINED |
2521 | + |
2522 | + if (settings.audio) { |
2523 | +#if GSTREAMER_0_10_IS_DEFINED |
2524 | audiobin.get_static_pad ("src").link (muxer.get_request_pad ("audio_%d")); |
2525 | - #else |
2526 | +#else |
2527 | audiobin.get_static_pad ("src").link (muxer.get_request_pad ("audio_%u")); |
2528 | - #endif |
2529 | +#endif |
2530 | } |
2531 | + |
2532 | muxer.link (sink); |
2533 | - #if GSTREAMER_0_10_IS_DEFINED |
2534 | +#if GSTREAMER_0_10_IS_DEFINED |
2535 | pipeline.get_bus ().add_watch (bus_message_cb); |
2536 | - #else |
2537 | +#else |
2538 | pipeline.get_bus ().add_watch (Priority.DEFAULT, bus_message_cb); |
2539 | - #endif |
2540 | - pipeline.set_state (State.READY); |
2541 | +#endif |
2542 | + |
2543 | + pipeline.set_state (Gst.State.READY); |
2544 | |
2545 | if (selectionarea != null) |
2546 | selectionarea.to_discrete (); |
2547 | |
2548 | - pipeline.set_state (State.PLAYING); |
2549 | + pipeline.set_state (Gst.State.PLAYING); |
2550 | this.recording = true; |
2551 | } |
2552 | |
2553 | public void finish_recording () { |
2554 | - if ( ! this.recording ) { |
2555 | + if (!this.recording) { |
2556 | debug ("resuming recording\n"); |
2557 | - this.pipeline.set_state(State.PLAYING); |
2558 | + |
2559 | + this.pipeline.set_state(Gst.State.PLAYING); |
2560 | this.recording = true; |
2561 | } |
2562 | - pipeline.send_event (new Event.eos()); |
2563 | + |
2564 | + pipeline.send_event (new Gst.Event.eos ()); |
2565 | } |
2566 | |
2567 | - private bool bus_message_cb (Gst.Bus bus, Message msg){ |
2568 | - switch (msg.type){ |
2569 | + private bool bus_message_cb (Gst.Bus bus, Gst.Message msg) { |
2570 | + switch (msg.type) { |
2571 | case Gst.MessageType.ERROR: |
2572 | - GLib.Error err; string debug; |
2573 | + GLib.Error err; |
2574 | + |
2575 | + string debug; |
2576 | + |
2577 | msg.parse_error (out err, out debug); |
2578 | |
2579 | display_error ("Eidete encountered a gstreamer error while recording, creating a screencast is not possible:\n%s\n\n[%s]" |
2580 | .printf (err.message, debug), true); |
2581 | stderr.printf ("Error: %s\n", debug); |
2582 | - pipeline.set_state (State.NULL); |
2583 | + pipeline.set_state (Gst.State.NULL); |
2584 | + |
2585 | break; |
2586 | case Gst.MessageType.EOS: |
2587 | debug ("received EOS\n"); |
2588 | - pipeline.set_state (State.NULL); |
2589 | + |
2590 | + pipeline.set_state (Gst.State.NULL); |
2591 | + |
2592 | this.recording = false; |
2593 | |
2594 | var end = new Eidete.Widgets.EndDialog (this); |
2595 | @@ -688,27 +740,30 @@ |
2596 | default: |
2597 | break; |
2598 | } |
2599 | + |
2600 | return true; |
2601 | } |
2602 | |
2603 | //only visuals |
2604 | - public void switch_to_paused (bool to_normal){ |
2605 | - |
2606 | - if (to_normal){ |
2607 | + public void switch_to_paused (bool to_normal) { |
2608 | + if (to_normal) { |
2609 | this.main_window.title = _("Recording paused"); |
2610 | - tabs.hide () ; |
2611 | - stack_switcher.hide () ; |
2612 | - pause_grid.show () ; |
2613 | + |
2614 | + tabs.hide (); |
2615 | + stack_switcher.hide (); |
2616 | + pause_grid.show (); |
2617 | + |
2618 | this.main_window.icon_name = "eidete"; |
2619 | this.app_icon = "eidete"; |
2620 | - |
2621 | - }else{ |
2622 | + } else { |
2623 | this.main_window.title = _("Pause recording"); |
2624 | + |
2625 | if (tabs.visible) { |
2626 | - tabs.hide () ; |
2627 | - stack_switcher.hide () ; |
2628 | - pause_grid.show () ; |
2629 | + tabs.hide (); |
2630 | + stack_switcher.hide (); |
2631 | + pause_grid.show (); |
2632 | } |
2633 | + |
2634 | this.main_window.icon_name = "media-playback-pause"; |
2635 | this.app_icon = "media-playback-pause"; |
2636 | |
2637 | @@ -744,17 +799,19 @@ |
2638 | static const OptionEntry[] entries = { |
2639 | {"pause", 'n', 0, OptionArg.NONE, ref pause_rec, N_("Pause Recording"), ""}, |
2640 | {"finish", 'n', 0, OptionArg.NONE, ref finish_rec, N_("Finish Recording"), ""}, |
2641 | - { null } |
2642 | + {null} |
2643 | }; |
2644 | |
2645 | - |
2646 | public static int main (string [] args) { |
2647 | var context = new OptionContext ("ctx"); |
2648 | context.add_main_entries (entries, "eidete"); |
2649 | context.add_group (Gtk.get_option_group (true)); |
2650 | - try{ |
2651 | + |
2652 | + try { |
2653 | context.parse (ref args); |
2654 | - }catch (Error e){ error ("Error: "+e.message);} |
2655 | + } catch (Error e) { |
2656 | + error ("Error: " + e.message); |
2657 | + } |
2658 | |
2659 | Gst.init (ref args); |
2660 | |
2661 | |
2662 | === modified file 'src/keycapture.c' |
2663 | --- src/keycapture.c 2015-01-04 14:30:20 +0000 |
2664 | +++ src/keycapture.c 2015-01-05 22:47:30 +0000 |
2665 | @@ -4,12 +4,14 @@ |
2666 | #include <X11/Xlib.h> |
2667 | #include <X11/XKBlib.h> |
2668 | #include <X11/extensions/record.h> //libxtst-dev, Xtst |
2669 | + |
2670 | #ifdef GSTREAMER_0_10_IS_DEFINED |
2671 | -#include <gstreamer-0.10/gst/gst.h> |
2672 | -#include <gstreamer-0.10/gst/gstinterface.h> |
2673 | + #include <gstreamer-0.10/gst/gst.h> |
2674 | + #include <gstreamer-0.10/gst/gstinterface.h> |
2675 | #else |
2676 | -#include <gstreamer-1.0/gst/gst.h> |
2677 | + #include <gstreamer-1.0/gst/gst.h> |
2678 | #endif |
2679 | + |
2680 | /* |
2681 | GList *list_devices (){ |
2682 | GstElement *pulsesrc = gst_element_factory_make ("pulsesrc", "src"); |
2683 | @@ -24,32 +26,30 @@ |
2684 | void key_pressed_cb(XPointer arg, XRecordInterceptData *d) { |
2685 | if (d->category != XRecordFromServer) return; |
2686 | |
2687 | - xEvent* event = (xEvent*)d->data; |
2688 | - |
2689 | + xEvent* event = (xEvent*)d->data; |
2690 | + |
2691 | unsigned char type = ((unsigned char*)d->data)[0] & 0x7F; |
2692 | unsigned char detail = ((unsigned char*)d->data)[1]; |
2693 | - unsigned int shiftlevel = 0; |
2694 | - |
2695 | - if( event->u.keyButtonPointer.state == 0 || |
2696 | - event->u.keyButtonPointer.state == 1 ) { |
2697 | - shiftlevel = event->u.keyButtonPointer.state; |
2698 | - } |
2699 | - |
2700 | + unsigned int shiftlevel = 0; |
2701 | + |
2702 | + if(event->u.keyButtonPointer.state == 0 || event->u.keyButtonPointer.state == 1 ) |
2703 | + shiftlevel = event->u.keyButtonPointer.state; |
2704 | + |
2705 | switch (type) { |
2706 | - case KeyPress: |
2707 | - g_signal_emit_by_name (arg, "captured", XKeysymToString (XkbKeycodeToKeysym (dpy, detail, 0, shiftlevel)), FALSE); |
2708 | - break; |
2709 | - case KeyRelease: |
2710 | - g_signal_emit_by_name (arg, "captured", XKeysymToString (XkbKeycodeToKeysym (dpy, detail, 0, shiftlevel)), TRUE); |
2711 | - break; |
2712 | - case ButtonPress: |
2713 | - g_signal_emit_by_name (arg, "captured-mouse", event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY, event->u.u.detail); |
2714 | - break; |
2715 | - case MotionNotify: |
2716 | - g_signal_emit_by_name (arg, "captured-move", event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY); |
2717 | - break; |
2718 | - default: |
2719 | - break; |
2720 | + case KeyPress: |
2721 | + g_signal_emit_by_name (arg, "captured", XKeysymToString (XkbKeycodeToKeysym (dpy, detail, 0, shiftlevel)), FALSE); |
2722 | + break; |
2723 | + case KeyRelease: |
2724 | + g_signal_emit_by_name (arg, "captured", XKeysymToString (XkbKeycodeToKeysym (dpy, detail, 0, shiftlevel)), TRUE); |
2725 | + break; |
2726 | + case ButtonPress: |
2727 | + g_signal_emit_by_name (arg, "captured-mouse", event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY, event->u.u.detail); |
2728 | + break; |
2729 | + case MotionNotify: |
2730 | + g_signal_emit_by_name (arg, "captured-move", event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY); |
2731 | + break; |
2732 | + default: |
2733 | + break; |
2734 | } |
2735 | |
2736 | XRecordFreeData (d); |
2737 | @@ -59,23 +59,27 @@ |
2738 | XRecordClientSpec rcs; |
2739 | XRecordRange* rr; |
2740 | dpy = XOpenDisplay (0); |
2741 | - |
2742 | + |
2743 | XKeysymToString (XkbKeycodeToKeysym (dpy, 11, 1, 0)); |
2744 | - |
2745 | + |
2746 | if (!(rr = XRecordAllocRange())) { |
2747 | fprintf(stderr, "XRecordAllocRange error\n"); |
2748 | } |
2749 | + |
2750 | rr->device_events.first = KeyPress; |
2751 | rr->device_events.last = MotionNotify; |
2752 | rcs = XRecordAllClients; |
2753 | - |
2754 | + |
2755 | if (!(rc = XRecordCreateContext(dpy, 0, &rcs, 1, &rr, 1))) { |
2756 | fprintf(stderr, "XRecordCreateContext error\n"); |
2757 | } |
2758 | + |
2759 | XFree(rr); |
2760 | + |
2761 | if (!XRecordEnableContext(dpy, rc, key_pressed_cb, data)) { |
2762 | fprintf(stderr, "XRecordEnableContext error\n"); |
2763 | } |
2764 | + |
2765 | return 0; |
2766 | } |
2767 | |
2768 | |
2769 | === modified file 'src/videobin_uploader.vala' |
2770 | --- src/videobin_uploader.vala 2015-01-04 11:44:37 +0000 |
2771 | +++ src/videobin_uploader.vala 2015-01-05 22:47:30 +0000 |
2772 | @@ -1,64 +1,70 @@ |
2773 | -using Gtk; |
2774 | - |
2775 | -public class Uploader : Window{ |
2776 | - |
2777 | - class LLabel : Label{ |
2778 | - public LLabel (string label){ |
2779 | - this.set_halign (Align.START); |
2780 | +public class Uploader : Gtk.Window { |
2781 | + class LLabel : Gtk.Label { |
2782 | + public LLabel (string label) { |
2783 | + this.set_halign (Gtk.Align.START); |
2784 | this.label = label; |
2785 | } |
2786 | - public LLabel.indent (string label){ |
2787 | + |
2788 | + public LLabel.indent (string label) { |
2789 | this (label); |
2790 | this.margin_left = 10; |
2791 | } |
2792 | - public LLabel.markup (string label){ |
2793 | + |
2794 | + public LLabel.markup (string label) { |
2795 | this (label); |
2796 | this.use_markup = true; |
2797 | } |
2798 | - public LLabel.right (string label){ |
2799 | - this.set_halign (Align.END); |
2800 | + |
2801 | + public LLabel.right (string label) { |
2802 | + this.set_halign (Gtk.Align.END); |
2803 | this.label = label; |
2804 | } |
2805 | - public LLabel.right_with_markup (string label){ |
2806 | - this.set_halign (Align.END); |
2807 | + |
2808 | + public LLabel.right_with_markup (string label) { |
2809 | + this.set_halign (Gtk.Align.END); |
2810 | this.use_markup = true; |
2811 | this.label = label; |
2812 | } |
2813 | } |
2814 | - |
2815 | - |
2816 | - public Uploader (File file){ |
2817 | + |
2818 | + public Uploader (File file) { |
2819 | this.title = "Upload to videobin.org"; |
2820 | - this.set_default_size (300, 1); |
2821 | - this.window_position = WindowPosition.CENTER; |
2822 | - |
2823 | - var grid = new Grid (); |
2824 | + this.set_default_size (300, -1); |
2825 | + this.window_position = Gtk.WindowPosition.CENTER; |
2826 | + |
2827 | + var grid = new Gtk.Grid (); |
2828 | grid.margin = 12; |
2829 | grid.column_spacing = 12; |
2830 | grid.row_spacing = 5; |
2831 | - |
2832 | - var title = new Entry (); |
2833 | - title.placeholder_text = _("Optional") ; |
2834 | - var description = new Entry (); |
2835 | - description.placeholder_text = _("Optional") ; |
2836 | - var email = new Entry (); |
2837 | - email.placeholder_text = _("Optional") ; |
2838 | - var img = new Image.from_icon_name ("videobin", IconSize.DIALOG); |
2839 | - |
2840 | - var upload_button = new Button.with_label (_("Upload")); |
2841 | + |
2842 | + var title = new Gtk.Entry (); |
2843 | + title.placeholder_text = _("Optional"); |
2844 | + |
2845 | + var description = new Gtk.Entry (); |
2846 | + description.placeholder_text = _("Optional"); |
2847 | + |
2848 | + var email = new Gtk.Entry (); |
2849 | + email.placeholder_text = _("Optional"); |
2850 | + |
2851 | + var img = new Gtk.Image.from_icon_name ("videobin", Gtk.IconSize.DIALOG); |
2852 | + |
2853 | + var upload_button = new Gtk.Button.with_label (_("Upload")); |
2854 | upload_button.get_style_context ().add_class ("suggested-action"); |
2855 | - var cancel = new Button.from_stock (Stock.CANCEL); |
2856 | + |
2857 | + var cancel = new Gtk.Button.from_stock (Gtk.Stock.CANCEL); |
2858 | cancel.margin_end = 6; |
2859 | - |
2860 | - var bbox = new Box (Orientation.HORIZONTAL, 0); |
2861 | + |
2862 | + var bbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
2863 | bbox.pack_end (upload_button, false, true, 0); |
2864 | bbox.pack_end (cancel, false, true, 0); |
2865 | - |
2866 | + |
2867 | email.set_tooltip_text (_("Your email address for relocating your videos")); |
2868 | - upload_button.image = new Image.from_icon_name ("mail-reply-sender", IconSize.BUTTON); |
2869 | + |
2870 | + upload_button.image = new Gtk.Image.from_icon_name ("mail-reply-sender", Gtk.IconSize.BUTTON); |
2871 | upload_button.can_default = true; |
2872 | + |
2873 | this.set_default (upload_button); |
2874 | - |
2875 | + |
2876 | grid.attach (img, 0, 0, 1, 2); |
2877 | grid.attach (new LLabel ("Title"), 1, 0, 1, 1); |
2878 | grid.attach (title, 2, 0, 1, 1); |
2879 | @@ -67,55 +73,66 @@ |
2880 | grid.attach (new LLabel ("Description"), 1, 2, 1, 1); |
2881 | grid.attach (description, 2, 2, 1, 1); |
2882 | grid.attach (bbox, 0, 3, 3, 1); |
2883 | - |
2884 | + |
2885 | this.add (grid); |
2886 | this.destroy.connect (Gtk.main_quit); |
2887 | - |
2888 | + |
2889 | cancel.clicked.connect (Gtk.main_quit); |
2890 | - |
2891 | - upload_button.clicked.connect ( () => { |
2892 | + |
2893 | + upload_button.clicked.connect (() => { |
2894 | string url; |
2895 | - string path = file.get_path() ; |
2896 | - if( path.has_prefix ("'") && path.has_suffix ("'")) |
2897 | - path = path.substring (1, path.length-2) ; |
2898 | - string command = "curl -F\"api=1\" -F\"videoFile=@"+path+"\" "; |
2899 | + string path = file.get_path(); |
2900 | + |
2901 | + if (path.has_prefix ("'") && path.has_suffix ("'")) |
2902 | + path = path.substring (1, path.length-2); |
2903 | + |
2904 | + string command = "curl -F\"api=1\" -F\"videoFile=@" + path + "\" "; |
2905 | + |
2906 | if (email.text != "") |
2907 | - command += "-F\"email="+email.text+"\" "; |
2908 | + command += "-F\"email=%s\" ".printf (email.text); |
2909 | + |
2910 | if (title.text != "") |
2911 | - command += "-F\"title="+title.text+"\" "; |
2912 | + command += "-F\"title=%s\" ".printf (title.text); |
2913 | + |
2914 | if (description.text != "") |
2915 | - command += "-F\"description="+description.text+"\" "; |
2916 | + command += "-F\"description=%s\" ".printf (description.text); |
2917 | + |
2918 | command += "http://videobin.org/add"; |
2919 | - try{ |
2920 | + |
2921 | + try { |
2922 | Process.spawn_command_line_sync (command, out url); |
2923 | - }catch (Error e){error (e.message);} |
2924 | - try{ |
2925 | - if( url == null || url == "" ) |
2926 | - { |
2927 | - warning( "The upload has failed. Command: %s", command) ; |
2928 | - } |
2929 | - else |
2930 | - Process.spawn_command_line_async ("sensible-browser "+url); |
2931 | - }catch (Error e){error (e.message);} |
2932 | + } catch (Error e) { |
2933 | + error (e.message); |
2934 | + } |
2935 | + |
2936 | + try { |
2937 | + if (url == null || url == "") { |
2938 | + warning("The upload has failed. Command: %s", command); |
2939 | + } else { |
2940 | + Process.spawn_command_line_async ("sensible-browser " + url); |
2941 | + } |
2942 | + } catch (Error e) { |
2943 | + error (e.message); |
2944 | + } |
2945 | + |
2946 | Gtk.main_quit (); |
2947 | }); |
2948 | } |
2949 | - |
2950 | } |
2951 | |
2952 | -public static void main (string [] args){ |
2953 | +public static void main (string [] args) { |
2954 | Gtk.init (ref args); |
2955 | - if( args.length<=1) |
2956 | - { |
2957 | - warning ("You must provide a valid file path" ) ; |
2958 | + |
2959 | + if (args.length <= 1) { |
2960 | + warning ("You must provide a valid file path"); |
2961 | + } else { |
2962 | + var path = args[1]; |
2963 | + var file = File.new_for_path (path); |
2964 | + |
2965 | + var dialog = new Uploader (file); |
2966 | + dialog.show_all (); |
2967 | + |
2968 | + Gtk.main (); |
2969 | } |
2970 | - else |
2971 | - { |
2972 | - var path = args[1] ; |
2973 | - var file = File.new_for_path (path); |
2974 | - var dialog = new Uploader (file); |
2975 | - dialog.show_all (); |
2976 | - Gtk.main (); |
2977 | - } |
2978 | } |
2979 |
Might as well remove all the "using Gtk;", "using Granite;" while you're at it.