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