Merge lp:~l-admin-3/eidete/fix-for-fix-for-freya into lp:eidete

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
Reviewer Review Type Date Requested Status
Tom Beckmann Pending
Review via email: mp+245502@code.launchpad.net

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 :

Might as well remove all the "using Gtk;", "using Granite;" while you're at it.

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
=== modified file 'src/Config.vala.cmake'
--- src/Config.vala.cmake 2011-12-30 00:26:42 +0000
+++ src/Config.vala.cmake 2015-01-05 22:47:30 +0000
@@ -16,11 +16,11 @@
16//16//
1717
18namespace Constants {18namespace Constants {
19public const string DATADIR = "@DATADIR@";19 public const string DATADIR = "@DATADIR@";
20public const string PKGDATADIR = "@PKGDATADIR@";20 public const string PKGDATADIR = "@PKGDATADIR@";
21public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";21 public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
22public const string RELEASE_NAME = "@RELEASE_NAME@";22 public const string RELEASE_NAME = "@RELEASE_NAME@";
23public const string VERSION = "@VERSION@";23 public const string VERSION = "@VERSION@";
24public const string VERSION_INFO = "@VERSION_INFO@";24 public const string VERSION_INFO = "@VERSION_INFO@";
25public const string PLUGINDIR = "@PLUGINDIR@";25 public const string PLUGINDIR = "@PLUGINDIR@";
26}26}
2727
=== modified file 'src/Widgets/countdown.vala'
--- src/Widgets/countdown.vala 2013-05-17 01:00:15 +0000
+++ src/Widgets/countdown.vala 2015-01-05 22:47:30 +0000
@@ -1,37 +1,31 @@
1using Gtk;1namespace Eidete.Widgets {
2using Granite;
3
4
5namespace Eidete.Widgets{
6
7 public class Countdown : Granite.Widgets.CompositedWindow {2 public class Countdown : Granite.Widgets.CompositedWindow {
83 public Gtk.Label count;
9 public Label count;
10 public int time;4 public int time;
115
12 public Countdown (){6 public Countdown (){
13 this.time = 5;7 this.time = 5;
148
15 this.set_default_size (300, 200);9 this.set_default_size (300, 200);
16 this.window_position = WindowPosition.CENTER;10 this.window_position = Gtk.WindowPosition.CENTER;
17 this.set_keep_above (true);11 this.set_keep_above (true);
18 this.stick ();12 this.stick ();
19 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;13 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
20 this.skip_pager_hint = true;14 this.skip_pager_hint = true;
21 this.skip_taskbar_hint = true;15 this.skip_taskbar_hint = true;
2216
23 var box = new Box (Orientation.VERTICAL, 0);17 var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
24 box.margin = 40;18 box.margin = 40;
25 box.margin_left = box.margin_right = 60;19 box.margin_left = box.margin_right = 60;
2620
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>");
28 title.use_markup = true;22 title.use_markup = true;
29 title.margin_bottom = 20;23 title.margin_bottom = 20;
3024
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>");
32 this.count.use_markup = true;26 this.count.use_markup = true;
3327
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>");
35 tipp.use_markup = true;29 tipp.use_markup = true;
36 tipp.margin_top = 20;30 tipp.margin_top = 20;
3731
@@ -42,38 +36,43 @@
42 this.add (box);36 this.add (box);
43 }37 }
4438
45 public override bool draw (Cairo.Context ctx){39 public override bool draw (Cairo.Context ctx) {
46 int w = this.get_allocated_width ();40 int w = this.get_allocated_width ();
47 int h = this.get_allocated_height ();41 int h = this.get_allocated_height ();
48 Granite.Drawing.Utilities.cairo_rounded_rectangle (ctx, 4, 4, w-8, h-8, 4);42
43 Granite.Drawing.Utilities.cairo_rounded_rectangle (ctx, 4, 4, w - 8, h - 8, 4);
44
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);
50 ctx.fill ();46 ctx.fill ();
47
51 return base.draw (ctx);48 return base.draw (ctx);
52 }49 }
5350
54 public void start (EideteApp app){51 public void start (EideteApp app) {
55
56 this.show_all ();52 this.show_all ();
53
57 Timeout.add (1000, () => {54 Timeout.add (1000, () => {
58 this.time --;55 this.time--;
59 count.label = "<span size='40000' color='#fbfbfb'>"+time.to_string ()+"</span>";56
60 if (time == -1){57 count.label = "<span size='40000' color='#fbfbfb'>" + time.to_string () + "</span>";
58
59 if (time == -1) {
61 this.destroy ();60 this.destroy ();
61
62 Timeout.add (100, () => { //let the countdown disappear before starting62 Timeout.add (100, () => { //let the countdown disappear before starting
63 app.record ();63 app.record ();
64 app.main_window.iconify ();64 app.main_window.iconify ();
65 app.switch_to_paused (false);65 app.switch_to_paused (false);
66 return false;66
67 });67 return false;
68 return false;68 });
69
70 return false;
69 }71 }
72
70 return true;73 return true;
71 });74 });
72 }75 }
73
74 }76 }
75
76
77}77}
7878
79
8079
=== modified file 'src/Widgets/end_dialog.vala'
--- src/Widgets/end_dialog.vala 2015-01-04 16:20:11 +0000
+++ src/Widgets/end_dialog.vala 2015-01-05 22:47:30 +0000
@@ -1,240 +1,301 @@
1using Gtk;
2
3namespace Eidete.Widgets {1namespace Eidete.Widgets {
42 public class EndDialog : Gtk.Dialog {
5 public class EndDialog : Dialog {3 private bool contractor;
64
7 private bool contractor; 5 private EideteApp app;
8 6 private Gtk.Button export;
9 private EideteApp app ;7 private Gtk.Grid grid;
10 private Button export ; 8 private Gtk.ListStore list;
11 private Grid grid; 9 private Gtk.TreeView treeview;
12 private ListStore list ; 10 private File source;
13 private TreeView treeview ;11
14 private File source ; 12 public EndDialog (EideteApp app) {
15 13 this.app = app;
16 public EndDialog (EideteApp app){14
17 this.app = app ; 15 //build_ui ();
18 //build_ui () ;16
19 this.window_position = WindowPosition.CENTER_ON_PARENT;17 this.window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
20 }18 }
2119
22 private void build_ui () {20 private void build_ui () {
23 this.get_header_bar ().get_style_context ().remove_class ("header-bar");21 this.get_header_bar ().get_style_context ().remove_class ("header-bar");
24 this.set_default_size (600, 600);22 this.set_default_size (600, 600);
25 this.set_application (app);23 this.set_application (app);
26 24
27 if (app.selectionarea != null)25 if (app.selectionarea != null)
28 app.selectionarea.destroy ();26 app.selectionarea.destroy ();
27
29 if (app.keyview != null)28 if (app.keyview != null)
30 app.keyview.destroy ();29 app.keyview.destroy ();
31 30
32 this.icon_name = "eidete";31 this.icon_name = "eidete";
3332
34 grid = new Grid ();33 grid = new Gtk.Grid ();
35 grid.margin = 12;34 grid.margin = 12;
3635
37 var content = (Gtk.Box) this.get_content_area () ;36 var content = (this.get_content_area () as Gtk.Box);
38 var title = new Label ("<span size='30000'>"+_("Recording complete")+"</span>");37
38 var title = new Gtk.Label ("<span size='30000'>" + _("Recording complete") + "</span>");
39 title.use_markup = true;39 title.use_markup = true;
40 title.halign = Align.START;40 title.halign = Gtk.Align.START;
4141
42 export = new Button.with_label (_("Save"));42 export = new Gtk.Button.with_label (_("Save"));
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);
44 export.get_style_context ().add_class ("suggested-action");
44 export.can_default = true;45 export.can_default = true;
45 export.get_style_context ().add_class ("suggested-action");46
46 this.set_default (export);47 this.set_default (export);
4748
48 var cancel = new Button.with_label (_("Cancel"));49 var cancel = new Gtk.Button.with_label (_("Cancel"));
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);
50 cancel.margin_end = 6;51 cancel.margin_end = 6;
5152
52 var bbox = new ButtonBox (Orientation.HORIZONTAL);53 var bbox = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
54 bbox.layout_style = Gtk.ButtonBoxStyle.END;
53 bbox.homogeneous = true;55 bbox.homogeneous = true;
56
54 bbox.pack_end (cancel, false, true, 0);57 bbox.pack_end (cancel, false, true, 0);
55 bbox.pack_end (export, false, true, 0);58 bbox.pack_end (export, false, true, 0);
56 bbox.layout_style = ButtonBoxStyle.END;59
5760 list = new Gtk.ListStore (2, typeof (Gdk.Pixbuf), typeof (string));
5861
59 list = new ListStore (2, typeof (Gdk.Pixbuf), typeof (string));62 treeview = new Gtk.TreeView.with_model (list);
60 treeview = new TreeView.with_model (list);
61 treeview.headers_visible = false;63 treeview.headers_visible = false;
62 treeview.hexpand = true;64 treeview.hexpand = true;
63 treeview.set_activate_on_single_click (false) ;65 treeview.set_activate_on_single_click (false);
64 treeview.row_activated.connect ( on_contract_executed) ;66 treeview.row_activated.connect (on_contract_executed);
6567
66 var cell1 = new CellRendererPixbuf ();68 var cell1 = new Gtk.CellRendererPixbuf ();
67 cell1.set_padding (5, 15);69 cell1.set_padding (5, 15);
70
68 treeview.insert_column_with_attributes (-1, "", cell1, "pixbuf", 0);71 treeview.insert_column_with_attributes (-1, "", cell1, "pixbuf", 0);
69 var cell2 = new CellRendererText ();72
73 var cell2 = new Gtk.CellRendererText ();
70 cell2.set_padding (2, 15);74 cell2.set_padding (2, 15);
75
71 treeview.insert_column_with_attributes (-1, "", cell2, "markup", 1);76 treeview.insert_column_with_attributes (-1, "", cell2, "markup", 1);
7277
73 //contractor78 // contractor
74 load_contracts () ; 79
80 load_contracts ();
7581
76 var scrolled = new Gtk.ScrolledWindow (null, null);82 var scrolled = new Gtk.ScrolledWindow (null, null);
77 scrolled.vexpand = true;83 scrolled.vexpand = true;
78 scrolled.add (treeview);84 scrolled.add (treeview);
79 85
80 grid.attach (title, 0, 0, 2, 1);86 grid.attach (title, 0, 0, 2, 1);
81 grid.attach (new Label (""), 0, 2, 1, 1);87 grid.attach (new Gtk.Label (""), 0, 2, 1, 1);
88
82 grid.attach (scrolled, 0, 4, 1, 1);89 grid.attach (scrolled, 0, 4, 1, 1);
83 grid.attach (new Label (""), 0, 5, 1, 1);90
91 grid.attach (new Gtk.Label (""), 0, 5, 1, 1);
84 grid.attach (bbox, 0, 6, 1, 1);92 grid.attach (bbox, 0, 6, 1, 1);
93
85 source = File.new_for_path (app.settings.destination);94 source = File.new_for_path (app.settings.destination);
86 95
87 if (contractor){96 if (contractor) {
88 export.clicked.connect (on_contract_executed) ;97 export.clicked.connect (on_contract_executed);
89 } else {98 } else {
90 export.clicked.connect ( () => {99 export.clicked.connect (() => {
91 save_file () ;100 save_file ();
92 this.destroy ();101
93 });102 this.destroy ();
103 });
94 }104 }
95 cancel.clicked.connect ( () => {this.destroy ();});105
106 cancel.clicked.connect (() => {
107 this.destroy ();
108 });
96109
97 content.add (grid);110 content.add (grid);
98 }111 }
99 112
100 public void display () {113 public void display () {
101 build_ui () ;114 build_ui ();
102 show_all () ;115
103 } 116 show_all ();
104 117 }
105 private void on_contract_executed () {118
106 TreePath path;119 private void on_contract_executed (){
120 Gtk.TreePath path;
121
107 treeview.get_cursor (out path, null);122 treeview.get_cursor (out path, null);
108 int index = int.parse (path.to_string ()) ;123
109 execute_command (index) ;124 int index = int.parse (path.to_string ());
125
126 execute_command (index);
127
110 this.destroy ();128 this.destroy ();
111 } 129 }
112 130
113 private void save_file () {131 private void save_file () {
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);
115 dialog.set_current_name (source.get_basename ());133 dialog.set_current_name (source.get_basename ());
116 var videos_folder = Environment.get_user_special_dir(UserDirectory.VIDEOS);134
135 var videos_folder = Environment.get_user_special_dir (UserDirectory.VIDEOS);
136
117 dialog.set_current_folder (videos_folder);137 dialog.set_current_folder (videos_folder);
118 dialog.do_overwrite_confirmation = true;138 dialog.do_overwrite_confirmation = true;
139
119 var res = dialog.run ();140 var res = dialog.run ();
120 if (res == ResponseType.OK){141
121 var destination = File.new_for_path (dialog.get_filename ());142 if (res == Gtk.ResponseType.OK) {
122 try{143 var destination = File.new_for_path (dialog.get_filename ());
123 source.copy (destination, FileCopyFlags.OVERWRITE);144
124 }catch (GLib.Error e){145 try {
125 stderr.printf ("Error: %s\n", e.message);146 source.copy (destination, FileCopyFlags.OVERWRITE);
126 }147 } catch (GLib.Error e) {
127 }148 stderr.printf ("Error: %s\n", e.message);
149 }
150 }
151
128 dialog.destroy ();152 dialog.destroy ();
129 }153 }
154
130 // Using deprecated Contractor API. Necesserary to maintain luna compatibility155 // Using deprecated Contractor API. Necesserary to maintain luna compatibility
131#if false 156#if false
132 private void execute_command_deprecated (int index) {157 private void execute_command_deprecated (int index) {
133 string cmd = contracts_dep[index].lookup ("Exec") ;158 string cmd = contracts_dep[index].lookup ("Exec");
134 try{159
135 Process.spawn_command_line_async (cmd);160 try {
136 }catch (Error e){161 Process.spawn_command_line_async (cmd);
137 print(e.message);162 } catch (Error e) {
163 print (e.message);
138 }164 }
139 }165 }
140 166
141 private HashTable<string,string>[] contracts_dep ; 167 private HashTable<string,string>[] contracts_dep;
142 168
143 private void load_contracts_deprecated () {169 private void load_contracts_deprecated () {
144 // CARL deprecated Contractor API 170 // CARL deprecated Contractor API
145 contracts_dep = Granite.Services.Contractor.get_contract (app.settings.destination, "video");171 contracts_dep = Granite.Services.Contractor.get_contract (app.settings.destination, "video");
146 if (contracts_dep == null || contracts_dep.length <= 1){172
147 warning ("You should install and/or run contractor");173 if (contracts_dep == null || contracts_dep.length <= 1)
148 contractor = false;174 warning ("You should install and/or run contractor");
149 var info = new InfoBar ();175
150 info.message_type = MessageType.WARNING;176 contractor = false;
151 info.pack_start (new Label (_("Could not contact Contractor.")));177
152 grid.attach (info, 0, 3, 2, 1);178 var info = new InfoBar ();
153 export.label = _("Save");179 info.message_type = MessageType.WARNING;
154 }else{180
155 contractor = true;181 info.pack_start (new Label (_("Could not contact Contractor.")));
156 for (var i=0;i<contracts_dep.length; i++){182
157 TreeIter it;183 grid.attach (info, 0, 3, 2, 1);
158 list.append (out it);184
159 Gdk.Pixbuf icon = null;185 export.label = _("Save");
160 try{186 } else {
161 icon = IconTheme.get_default ().load_icon (contracts_dep[i].lookup ("IconName"), 32, 0);187 contractor = true;
162 }catch (Error e){188
163 warning (e.message);189 for (var i = 0; i < contracts_dep.length; i++) {
164 }190 TreeIter it;
165 list.set (it, 0, icon, 1,191
166 "<b>"+contracts_dep[i].lookup ("Name")+"</b>\n"+contracts_dep[i].lookup ("Description"));192 list.append (out it);
167 }193
168 treeview.set_cursor (new TreePath.from_string ("0"), null, false);194 Gdk.Pixbuf icon = null;
195
196 try {
197 icon = IconTheme.get_default ().load_icon (contracts_dep[i].lookup ("IconName"), 32, 0);
198 } catch (Error e) {
199 warning (e.message);
200 }
201
202 list.set (it, 0, icon, 1,
203 "<b>" + contracts_dep[i].lookup ("Name") +
204 "</b>\n" + contracts_dep[i].lookup ("Description"));
205 }
206
207 treeview.set_cursor (new TreePath.from_string ("0"), null, false);
169 }208 }
170 }209 }
171#endif 210#endif
172 private Gee.List<Granite.Services.Contract> contracts ; 211
173 private int contracts_size = 0 ; 212 private Gee.List<Granite.Services.Contract> contracts;
174 213
175 private void execute_command (int index) {214 private int contracts_size = 0;
176 if( index == 0) 215
177 save_file () ;216 private void execute_command (int index){
178 else {217 if(index == 0) {
179 var contract = contracts.@get (index-1) ;218 save_file ();
180 try{219 } else {
181 contract.execute_with_file (source) ;220 var contract = contracts.@get (index-1);
182 }catch (Error e){221
183 warning (e.message);222 try {
184 }223 contract.execute_with_file (source);
224 } catch (Error e) {
225 warning (e.message);
226 }
185 }227 }
186
187 }228 }
188229
189 private void load_contracts () {230 private void load_contracts () {
190 contracts_size = 0 ;231 contracts_size = 0;
191 try{232
192 contracts = Granite.Services.ContractorProxy.get_contracts_by_mime ("video");233 try {
193 }catch (Error e){234 contracts = Granite.Services.ContractorProxy.get_contracts_by_mime ("video");
194 warning (e.message);235 } catch (Error e) {
195 }236 warning (e.message);
196 if (contracts != null){237 }
197238
198 contractor = true;239 if (contracts != null) {
199 foreach( var contract in contracts ) {240 contractor = true;
200 TreeIter it;241
201 list.append (out it);242 foreach (var contract in contracts) {
202 Gdk.Pixbuf icon = null;243 Gtk.TreeIter it;
203 try{244
204 icon = IconTheme.get_default ().load_icon (contract.get_icon ().to_string (), 32, 0);245 list.append (out it);
205 246
206 }catch (Error e){247 Gdk.Pixbuf icon = null;
207 warning (e.message);248
208 }249 try {
209 list.set (it, 0, icon, 1,250 icon = Gtk.IconTheme.get_default ().load_icon (contract.get_icon ().to_string (), 32, 0);
210 "<b>"+contract.get_display_name ()+"</b>\n"+contract.get_description ());251
211 contracts_size ++ ;252 } catch (Error e) {
212 }253 warning (e.message);
213 TreeIter it;254 }
214 list.insert (out it, 0);255
215 Gdk.Pixbuf icon = null;256 list.set (it, 0, icon, 1,
216 try{257 "<b>" + contract.get_display_name () + "</b>\n" +
217 icon = IconTheme.get_default ().load_icon ("document-save", 32, 0); 258 contract.get_description ());
218 }catch (Error e){259
219 warning (e.message);260 contracts_size++;
220 }261 }
221 list.set (it, 0, icon, 1,262
222 "<b>"+_("Save file")+"</b>\n"+("Save the file onto a disk"));263 Gtk.TreeIter it;
223 treeview.set_cursor (new TreePath.from_string ("0"), null, false);264
224 export.label = _("Execute");265 list.insert (out it, 0);
225 }266
226 if( contracts_size == 0 ) 267 Gdk.Pixbuf icon = null;
227 {268
228 warning ("You should install and/or run contractor");269 try {
229 contractor = false;270 icon = Gtk.IconTheme.get_default ().load_icon ("document-save", 32, 0);
230 var info = new InfoBar ();271 } catch (Error e) {
231 info.message_type = MessageType.WARNING;272 warning (e.message);
232 info.pack_start (new Label (_("Could not contact Contractor.")));273 }
233 grid.attach (info, 0, 3, 2, 1);274
234 export.label = _("Save");275 list.set (it, 0, icon, 1,
276 "<b>" + _("Save file") + "</b>\n" +
277 ("Save the file onto a disk"));
278
279 treeview.set_cursor (new Gtk.TreePath.from_string ("0"), null, false);
280
281 export.label = _("Execute");
282 }
283
284 if (contracts_size == 0) {
285 warning ("You should install and/or run contractor");
286
287 contractor = false;
288
289 var info = new Gtk.InfoBar ();
290 info.message_type = Gtk.MessageType.WARNING;
291
292 info.pack_start (new Gtk.Label (_("Could not contact Contractor.")));
293
294 grid.attach (info, 0, 3, 2, 1);
295
296 export.label = _("Save");
235 }297 }
236 }298 }
237 }299 }
238}300}
239301
240
241302
=== modified file 'src/Widgets/keyview.vala'
--- src/Widgets/keyview.vala 2015-01-04 14:30:20 +0000
+++ src/Widgets/keyview.vala 2015-01-05 22:47:30 +0000
@@ -1,119 +1,123 @@
1using Granite;
2using Gtk;
3
4
5namespace Eidete.Widgets {1namespace Eidete.Widgets {
62 public class YellowCircle : Granite.Widgets.CompositedWindow {
7 public class YellowCircle : Granite.Widgets.CompositedWindow {3 public YellowCircle (Gdk.RGBA color) {
84 this.skip_pager_hint = true;
9 public YellowCircle (Gdk.RGBA color) {5 this.skip_taskbar_hint = true;
10 this.skip_pager_hint = true;6 this.set_keep_above (true);
11 this.skip_taskbar_hint = true;7 this.stick ();
12 this.set_keep_above (true);8 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
13 this.stick ();9 this.accept_focus = false;
14 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;10
15 this.accept_focus = false;11 this.draw.connect ((ctx) => {
1612 ctx.arc (this.get_allocated_width () / 2, this.get_allocated_height () / 2,
17 this.draw.connect ( (ctx) => {13 this.get_allocated_width () / 2, 0, 6.28318);
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);
19 this.get_allocated_width () / 2, 0, 6.28318);15 ctx.fill ();
20 ctx.set_source_rgba (color.red, color.green, color.blue, color.alpha);16
21 ctx.fill ();17 return false;
22 return false;18 });
23 });19
2420 this.set_size_request (70, 70);
25 this.set_size_request (70, 70);21 this.realize ();
26 this.realize ();22 this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0);
27 this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0);23 this.show_all ();
28 this.show_all ();24 }
29 }25
3026 public new void move (int x, int y) {
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));
32 base.move (x - (int)(this.get_allocated_width ()/2), y - (int)(this.get_allocated_height ()/2));28 }
33 }29 }
34 }30
3531 public class ClickWindow : Granite.Widgets.CompositedWindow {
36 public class ClickWindow : Granite.Widgets.CompositedWindow {32 public ClickWindow (int x, int y, int button) {
37 public ClickWindow (int x, int y, int button) {33 this.skip_pager_hint = true;
38 this.skip_pager_hint = true;34 this.skip_taskbar_hint = true;
39 this.skip_taskbar_hint = true;35 this.set_keep_above (true);
40 this.set_keep_above (true);36 this.stick ();
41 this.stick ();37 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
42 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;38 this.accept_focus = false;
43 this.accept_focus = false;39
4440 string label = "";
45 string label = "";41
46 switch (button) {42 switch (button) {
47 case 1:43 case 1:
48 label = _("Left");44 label = _("Left");
49 break;45
50 case 2:46 break;
51 label = _("Middle");47 case 2:
52 break;48 label = _("Middle");
53 case 3:49
54 label = _("Right");50 break;
55 break;51 case 3:
56 default:52 label = _("Right");
57 break;53
58 }54 break;
59 var lbl = new Gtk.Label (label);55 default:
60 lbl.attributes = new Pango.AttrList ();56 break;
61 lbl.attributes.insert (new Pango.AttrFontDesc (Pango.FontDescription.from_string ("16px")));57 }
62 this.add (lbl);58
63 var css = new Gtk.CssProvider ();59 var lbl = new Gtk.Label (label);
64 try {60 lbl.attributes = new Pango.AttrList ();
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")));
66 } catch (Error e) { warning (e.message); }62
67 lbl.get_style_context ().add_provider (css, 20000);63 this.add (lbl);
6864
69 this.realize ();65 var css = new Gtk.CssProvider ();
70 this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0);66
71 this.show_all ();67 try {
72 this.move (x + 5, y + 5);68 css.load_from_data ("*{color:#fff; text-shadow:1 1 #000;}", -1);
7369 } catch (Error e) {
74 Timeout.add (10, () => {70 warning (e.message);
75 this.opacity -= 0.007;71 }
76 if (this.opacity < 0.1) //prevent flickering72
77 this.foreach ( (c) => this.remove (c) );73 lbl.get_style_context ().add_provider (css, 20000);
78 if (this.opacity <= 0) {74
79 this.destroy ();75 this.realize ();
80 return false;76 this.get_window ().input_shape_combine_region (new Cairo.Region.rectangle ({0, 0, 1, 1}), 0, 0);
81 }77 this.show_all ();
82 return true;78 this.move (x + 5, y + 5);
83 });79
84 }80 Timeout.add (10, () => {
85 }81 this.opacity -= 0.007;
8682
8783 if (this.opacity < 0.1) //prevent flickering
88 public class Key : Label {84 this.foreach ((c) => this.remove (c));
8985 if (this.opacity <= 0) {
90 public string key;86 this.destroy ();
91 public bool ctrl;87
92 public bool shift;88 return false;
93 public bool alt;89 }
94 public bool super;90
95 public bool iso_level3_shift;91 return true;
96 public int count;92 });
9793 }
98 public Key (string key, bool ctrl, bool shift, bool alt, bool super, bool iso_level3_shift){94 }
99 this.key = key;95
100 this.ctrl = ctrl;96 public class Key : Gtk.Label {
101 this.shift = shift;97 public string key;
102 this.alt = alt;98 public bool ctrl;
103 this.super = super;99 public bool shift;
104 this.iso_level3_shift = iso_level3_shift;100 public bool alt;
105 this.count = 1;101 public bool super;
106 }102 public bool iso_level3_shift;
107 }103 public int count;
108104
109105 public Key (string key, bool ctrl, bool shift, bool alt, bool super, bool iso_level3_shift){
110 public class KeyView : Granite.Widgets.CompositedWindow {106 this.key = key;
111107 this.ctrl = ctrl;
108 this.shift = shift;
109 this.alt = alt;
110 this.super = super;
111 this.iso_level3_shift = iso_level3_shift;
112 this.count = 1;
113 }
114 }
115
116
117 public class KeyView : Granite.Widgets.CompositedWindow {
112 public int key_size;118 public int key_size;
113 public int fade_duration;119 public int fade_duration;
114120
115
116
117 private bool ctrl;121 private bool ctrl;
118 private bool shift;122 private bool shift;
119 private bool alt;123 private bool alt;
@@ -194,7 +198,7 @@
194 this.screen_h = h;198 this.screen_h = h;
195 }199 }
196200
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) {
198 this.key_size = 75;202 this.key_size = 75;
199 this.fade_duration = 2000;203 this.fade_duration = 2000;
200204
@@ -204,20 +208,22 @@
204 this.resizable = false;208 this.resizable = false;
205 this.set_has_resize_grip (false);209 this.set_has_resize_grip (false);
206 this.skip_pager_hint = true;210 this.skip_pager_hint = true;
207 this.skip_taskbar_hint = true;211 this.skip_taskbar_hint = true;
208 this.accept_focus = false;212 this.accept_focus = false;
209213
210 this.type_hint = Gdk.WindowTypeHint.NOTIFICATION;214 this.type_hint = Gdk.WindowTypeHint.NOTIFICATION;
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 |
212 Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ;216 Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK;
213217
214 this.realize ();218 this.realize ();
215219
216 Cairo.RectangleInt rect = {0, 0, 1, 1};220 Cairo.RectangleInt rect = {0, 0, 1, 1};
221
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);
218223
219 this.enter_notify_event.connect ( () => {224 this.enter_notify_event.connect (() => {
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);
226
221 return true;227 return true;
222 });228 });
223229
@@ -225,7 +231,9 @@
225231
226 //setup the key background232 //setup the key background
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);
234
228 var ctx = new Cairo.Context (key_bg);235 var ctx = new Cairo.Context (key_bg);
236
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);
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);
231 ctx.fill_preserve ();239 ctx.fill_preserve ();
@@ -237,209 +245,327 @@
237 keys.pop_tail ();245 keys.pop_tail ();
238 this.queue_draw ();246 this.queue_draw ();
239 }247 }
248
240 return true;249 return true;
241 });250 });
242251
243 if (mouse_circle) {252 if (mouse_circle) {
244 this.circle = new YellowCircle (mouse_circle_color);253 this.circle = new YellowCircle (mouse_circle_color);
245 this.captured_move.connect ( (x, y) => {254 this.captured_move.connect ((x, y) => {
246 Idle.add (() => {255 Idle.add (() => {
247 this.circle.move (x, y);256 this.circle.move (x, y);
248 return false;257
249 });258 return false;
250 //debug ("Moved to %i, %i\n", x, y);259 });
251 });260
252 }261 //debug ("Moved to %i, %i\n", x, y);
253262 });
254 if (mouse)263 }
255 this.captured_mouse.connect ( (x, y, button) => {264
256 debug ("Button %i pressed at %i, %i ", button, x, y);265 if (mouse) {
257 if (button <= 3)266 this.captured_mouse.connect ((x, y, button) => {
258 Timeout.add (10, () => { new ClickWindow (x, y, button); return false; });267 debug ("Button %i pressed at %i, %i ", button, x, y);
259 });268
260269 if (button <= 3) {
261 if (keyboard)270 Timeout.add (10, () => {
262 this.captured.connect ( (keyvalue, released) => {271 new ClickWindow (x, y, button);
263 Idle.add (() => {272
264 handle_key_event (keyvalue, released);273 return false;
265 return false;274 });
266 });275 }
267 });276 });
277 }
278
279 if (keyboard) {
280 this.captured.connect ((keyvalue, released) => {
281 Idle.add (() => {
282 handle_key_event (keyvalue, released);
283
284 return false;
285 });
286 });
287 }
268 }288 }
269289
270 void handle_key_event (string keyvalue, bool released) {290 void handle_key_event (string keyvalue, bool released) {
271 if (released){291 if (released) {
272 switch (keyvalue){292 switch (keyvalue) {
273 case "Control_L":293 case "Control_L":
274 case "Control_R":294 case "Control_R":
275 this.ctrl = false;295 this.ctrl = false;
276 this.queue_draw ();296 this.queue_draw ();
277 break;297
278 case "Shift_L":298 break;
279 case "Shift_R":299 case "Shift_L":
280 this.shift = false;300 case "Shift_R":
281 this.queue_draw ();301 this.shift = false;
282 break;302 this.queue_draw ();
283 case "Alt_L":303
284 case "Alt_R":304 break;
285 this.alt = false;305 case "Alt_L":
286 this.queue_draw ();306 case "Alt_R":
287 break;307 this.alt = false;
288 case "Super_L":308 this.queue_draw ();
289 case "Super_R":309
290 this.super = false;310 break;
291 this.queue_draw ();311 case "Super_L":
292 return;312 case "Super_R":
293 case "ISO_Level3_Shift":313 this.super = false;
294 this.iso_level3_shift = false;314 this.queue_draw ();
295 this.queue_draw ();315
296 return;316 return;
297 }317 case "ISO_Level3_Shift":
298 }else{318 this.iso_level3_shift = false;
299 string res = keyvalue;319 this.queue_draw ();
300 switch (res){320
301 case "Control_L":321 return;
302 case "Control_R":322 }
303 this.ctrl = true;323 } else {
304 this.queue_draw ();324 string res = keyvalue;
305 return;325
306 case "Shift_L":326 switch (res) {
307 case "Shift_R":327 case "Control_L":
308 this.shift = true;328 case "Control_R":
309 this.queue_draw ();329 this.ctrl = true;
310 return;330 this.queue_draw ();
311 case "Alt_L":331
312 case "Alt_R":332 return;
313 this.alt = true;333 case "Shift_L":
314 this.queue_draw ();334 case "Shift_R":
315 return;335 this.shift = true;
316 case "Super_L":336 this.queue_draw ();
317 case "Super_R":337
318 this.super = true;338 return;
319 this.queue_draw ();339 case "Alt_L":
320 return;340 case "Alt_R":
321 case "ISO_Level3_Shift":341 this.alt = true;
322 this.iso_level3_shift = true;342 this.queue_draw ();
323 this.queue_draw ();343
324 return;344 return;
325 case "Escape":345 case "Super_L":
326 res = "Esc"; break;346 case "Super_R":
327 case "Return":347 this.super = true;
328 res = "⏎"; break;348 this.queue_draw ();
329 case "Delete":349
330 res = "Del"; break;350 return;
331 case "Insert":351 case "ISO_Level3_Shift":
332 res = "Ins"; break;352 this.iso_level3_shift = true;
333 case "comma":353 this.queue_draw ();
334 res = ","; break;354
335 case "period":355 return;
336 res = "."; break;356 case "Escape":
337 case "minus":357 res = "Esc";
338 res = "-"; break;358
339 case "plus":359 break;
340 res = "+"; break;360 case "Return":
341 case "Tab":361 res = "⏎";
342 res = "Tab"; break;362
343 case "BackSpace":363 break;
344 res = "⌫"; break;364 case "Delete":
345 case "Left":365 res = "Del";
346 res = "◄"; break;366
347 case "Right":367 break;
348 res = "►"; break;368 case "Insert":
349 case "Up":369 res = "Ins";
350 res = "▲"; break;370
351 case "Down":371 break;
352 res = "▼"; break;372 case "comma":
353 case "space":373 res = ",";
354 res = " "; break;374
355 case "backslash":375 break;
356 res = "\\"; break;376 case "period":
357 case "bracketleft":377 res = ".";
358 res = "["; break;378
359 case "bracketright":379 break;
360 res = "]"; break;380 case "minus":
361 case "braceleft":381 res = "-";
362 res = "{"; break;382
363 case "braceright":383 break;
364 res = "}"; break;384 case "plus":
365 case "apostrophe":385 res = "+";
366 res = "'"; break;386
367 case "asciitilde":387 break;
368 res = "~"; break;388 case "Tab":
369 case "grave":389 res = "Tab";
370 res = "`"; break;390
371 case "bar":391 break;
372 res = "|"; break;392 case "BackSpace":
373 case "ampersand":393 res = "⌫";
374 res = "&"; break;394
375 case "parenleft":395 break;
376 res = "("; break;396 case "Left":
377 case "parenright":397 res = "◄";
378 res = ")"; break;398
379 case "less":399 break;
380 res = "<"; break;400 case "Right":
381 case "greater":401 res = "►";
382 res = ">"; break;402
383 case "equal":403 break;
384 res = "="; break;404 case "Up":
385 case "exclam":405 res = "▲";
386 res = "!"; break;406
387 case "quotedbl":407 break;
388 res = "\""; break;408 case "Down":
389 case "numbersign":409 res = "▼";
390 res = "\""; break;410
391 case "dollar":411 break;
392 res = "$"; break;412 case "space":
393 case "slash":413 res = " ";
394 res = "/"; break;414
395 case "asterisk":415 break;
396 res = "*"; break;416 case "backslash":
397 case "colon":417 res = "\\";
398 res = ":"; break;418
399 case "semicolon":419 break;
400 res = ";"; break;420 case "bracketleft":
401 case "underscore":421 res = "[";
402 res = "_"; break;422
403 case "Next":423 break;
404 res = "Pg▲"; break;424 case "bracketright":
405 case "Prior":425 res = "]";
406 res = "Pg▼"; break;426
407 case "asciicircum":427 break;
408 res = "^"; break;428 case "braceleft":
409 case "at":429 res = "{";
410 res = "@"; break;430
411 case "question":431 break;
412 res = "?"; break;432 case "braceright":
413 default:433 res = "}";
414 if (keyvalue.length > 9)434
415 res = keyvalue.substring (0, 9);435 break;
416 break;436 case "apostrophe":
417 }437 res = "'";
418438
419 if ((!keys.is_empty ()) &&439 break;
440 case "asciitilde":
441 res = "~";
442
443 break;
444 case "grave":
445 res = "`";
446
447 break;
448 case "bar":
449 res = "|";
450
451 break;
452 case "ampersand":
453 res = "&";
454
455 break;
456 case "parenleft":
457 res = "(";
458
459 break;
460 case "parenright":
461 res = ")";
462
463 break;
464 case "less":
465 res = "<";
466
467 break;
468 case "greater":
469 res = ">";
470
471 break;
472 case "equal":
473 res = "=";
474
475 break;
476 case "exclam":
477 res = "!";
478
479 break;
480 case "quotedbl":
481 res = "\"";
482
483 break;
484 case "numbersign":
485 res = "\"";
486
487 break;
488 case "dollar":
489 res = "$";
490
491 break;
492 case "slash":
493 res = "/";
494
495 break;
496 case "asterisk":
497 res = "*";
498
499 break;
500 case "colon":
501 res = ":";
502
503 break;
504 case "semicolon":
505 res = ";";
506
507 break;
508 case "underscore":
509 res = "_";
510
511 break;
512 case "Next":
513 res = "Pg▲";
514
515 break;
516 case "Prior":
517 res = "Pg▼";
518
519 break;
520 case "asciicircum":
521 res = "^";
522
523 break;
524 case "at":
525 res = "@";
526
527 break;
528 case "question":
529 res = "?";
530
531 break;
532 default:
533 if (keyvalue.length > 9)
534 res = keyvalue.substring (0, 9);
535
536 break;
537 }
538
539 if ((!keys.is_empty ()) &&
420 (keys.peek_head ().key == res) &&540 (keys.peek_head ().key == res) &&
421 (keys.peek_head ().ctrl == ctrl) &&541 (keys.peek_head ().ctrl == ctrl) &&
422 (keys.peek_head ().shift == shift) &&542 (keys.peek_head ().shift == shift) &&
423 (keys.peek_head ().alt == alt) &&543 (keys.peek_head ().alt == alt) &&
424 (keys.peek_head ().iso_level3_shift == iso_level3_shift)){544 (keys.peek_head ().iso_level3_shift == iso_level3_shift)) {
425 keys.peek_head ().count ++;545 keys.peek_head ().count++;
426 this.queue_draw ();546
427 }else{547 this.queue_draw ();
428 var key = new Key (res, ctrl, shift, alt, super, iso_level3_shift);548 } else {
429 if (!released){549 var key = new Key(res, ctrl, shift, alt, super, iso_level3_shift);
430 keys.push_head (key);550
431 if (keys.length+2 > (screen_h / key_size))551 if (!released) {
432 keys.pop_tail ();552 keys.push_head (key);
433 this.queue_draw ();553
434 }554 if (keys.length + 2 > (screen_h / key_size))
555 keys.pop_tail ();
556
557 this.queue_draw ();
558 }
559 }
435 }560 }
436 }
437 }561 }
438562
439 public void capture (){563 public void capture () {
440 try{564 try {
441 Thread.create<void*> (this.intercept_key_thread, true);565 Thread.create<void*> (this.intercept_key_thread, true);
442 }catch (ThreadError e){stderr.printf (e.message);}566 } catch (ThreadError e) {
567 stderr.printf (e.message);
568 }
443 }569 }
444 }570 }
445}571}
446572
=== modified file 'src/Widgets/selectionarea.vala'
--- src/Widgets/selectionarea.vala 2015-01-04 14:53:16 +0000
+++ src/Widgets/selectionarea.vala 2015-01-05 22:47:30 +0000
@@ -1,43 +1,41 @@
1using Gtk;1namespace Eidete.Widgets {
2using Granite;2 public class SelectionArea : Granite.Widgets.CompositedWindow {
3
4
5namespace Eidete.Widgets{
6
7 public class SelectionArea : Granite.Widgets.CompositedWindow{
8
9 private int[,] pos;3 private int[,] pos;
10 public bool discrete;4 public bool discrete;
11 public bool not_visible;5 public bool not_visible;
12 6
13 public int x;7 public int x;
14 public int y;8 public int y;
15 public int w;9 public int w;
16 public int h;10 public int h;
17 11
18 public SelectionArea (){12 public SelectionArea () {
19 this.stick ();13 this.stick ();
20 this.resizable = true;14 this.resizable = true;
21 this.set_has_resize_grip (false);15 this.set_has_resize_grip (false);
22 this.set_default_geometry (640, 480);16 this.set_default_geometry (640, 480);
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 |
24 Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ;18 Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK;
25 this.skip_taskbar_hint = true;19 this.skip_taskbar_hint = true;
26 this.skip_pager_hint = true;20 this.skip_pager_hint = true;
27 this.not_visible = false;21 this.not_visible = false;
28 22
29 this.button_press_event.connect ( (e) => {23 this.button_press_event.connect ((e) => {
30 Gdk.WindowEdge [] dir = {Gdk.WindowEdge.NORTH_WEST,24 Gdk.WindowEdge [] dir = {Gdk.WindowEdge.NORTH_WEST,
31 Gdk.WindowEdge.NORTH,Gdk.WindowEdge.NORTH_EAST,25 Gdk.WindowEdge.NORTH,Gdk.WindowEdge.NORTH_EAST,
32 Gdk.WindowEdge.EAST,Gdk.WindowEdge.SOUTH_EAST,Gdk.WindowEdge.SOUTH,26 Gdk.WindowEdge.EAST,Gdk.WindowEdge.SOUTH_EAST,Gdk.WindowEdge.SOUTH,
33 Gdk.WindowEdge.SOUTH_WEST,Gdk.WindowEdge.WEST};27 Gdk.WindowEdge.SOUTH_WEST,Gdk.WindowEdge.WEST};
34 for (var i=0;i<8;i++){28
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++) {
30 if (in_quad (pos[i,0] - 12, pos[i,1] - 10, 24, 24, (int)e.x, (int)e.y)) {
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);
32
37 return false;33 return false;
38 }34 }
39 }35 }
36
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);
38
41 return false;39 return false;
42 });40 });
4341
@@ -49,19 +47,18 @@
49 // if coordinate + width/height is out of the screen, then47 // if coordinate + width/height is out of the screen, then
50 // adjust coordinates to keep width and height (and aspect48 // adjust coordinates to keep width and height (and aspect
51 // ratio) intact49 // ratio) intact
52 if( e.x < 0 || e.x > screen_width ) {50
51 if (e.x < 0 || e.x > screen_width) {
53 x = 0;52 x = 0;
54 } else if( e.x + e.width > screen_width53 } else if (e.x + e.width > screen_width && e.width < screen_width) {
55 && e.width < screen_width ) {
56 x = screen_width - e.width;54 x = screen_width - e.width;
57 } else {55 } else {
58 x = e.x;56 x = e.x;
59 }57 }
60 58
61 if( e.y < 0 ) {59 if (e.y < 0) {
62 y = 0;60 y = 0;
63 } else if( e.y + e.height >= screen_height61 } else if (e.y + e.height >= screen_height && e.height < screen_height) {
64 && e.height < screen_height ) {
65 y = screen_height - e.height - 1;62 y = screen_height - e.height - 1;
66 } else {63 } else {
67 y = e.y;64 y = e.y;
@@ -69,95 +66,100 @@
6966
70 // just in case an edge is still outside of the screen67 // just in case an edge is still outside of the screen
71 // we'll modify the width/height if thats the case68 // we'll modify the width/height if thats the case
72 if( x + e.width > screen_width ) {69
70 if (x + e.width > screen_width) {
73 w = screen_width - x;71 w = screen_width - x;
74 } else {72 } else {
75 w = e.width;73 w = e.width;
76 }74 }
7775
78 if( y + e.height > screen_height ) {76 if (y + e.height > screen_height) {
79 h = screen_height - y;77 h = screen_height - y;
80 } else {78 } else {
81 h = e.height;79 h = e.height;
82 }80 }
83 81
84 geometry_changed (x, y, w, h);82 geometry_changed (x, y, w, h);
83
85 return false;84 return false;
86 });85 });
87 86
88 this.destroy.connect ( () => {87 this.destroy.connect (() => {
89 this.not_visible = true;88 this.not_visible = true;
90 });89 });
91 }90 }
92 91
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) {
94 return ((x>qx) && (x<(qx+qw)) && (y>qy) && (y<qy+qh));93 return ((x > qx) && (x < (qx + qw)) && (y > qy) && (y < qy + qh));
95 }94 }
96 95
97 public override bool draw (Cairo.Context ctx){96 public override bool draw (Cairo.Context ctx) {
98 int w = this.get_allocated_width ();97 int w = this.get_allocated_width ();
99 int h = this.get_allocated_height ();98 int h = this.get_allocated_height ();
100 int r = 16;99 int r = 16;
101 if (!discrete){100
101 if (!discrete) {
102 pos = {{1, 1}, // upper left102 pos = {{1, 1}, // upper left
103 {w/2, 1}, // upper midpoint103 {w / 2, 1}, // upper midpoint
104 {w-1, 1}, // upper right104 {w - 1, 1}, // upper right
105 {w-1, h/2}, // right midpoint105 {w - 1, h / 2}, // right midpoint
106 {w-1, h-1}, // lower right106 {w - 1, h - 1}, // lower right
107 {w/2, h-1}, // lower midpoint107 {w / 2, h - 1}, // lower midpoint
108 {1, h-1}, // lower left108 {1, h - 1}, // lower left
109 {1, h/2}}; // left midpoint109 {1, h / 2}}; // left midpoint
110110
111
112 ctx.rectangle (0, 0, w, h);111 ctx.rectangle (0, 0, w, h);
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);
114 ctx.fill ();113 ctx.fill ();
115 114
116 for (var i=0;i<8;i++){115 for (var i = 0; i < 8; i++) {
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);
118 ctx.set_source_rgb (0.7, 0.7, 0.7);117 ctx.set_source_rgb (0.7, 0.7, 0.7);
119 ctx.fill ();118 ctx.fill ();
120 }119 }
120
121 ctx.rectangle (0, 0, w, h);121 ctx.rectangle (0, 0, w, h);
122 ctx.set_source_rgb (1.0, 1.0, 1.0);122 ctx.set_source_rgb (1.0, 1.0, 1.0);
123 ctx.set_line_width (1.0);123 ctx.set_line_width (1.0);
124 ctx.stroke ();124 ctx.stroke ();
125 }else{125 } else {
126 ctx.rectangle (0, 0, w, h);126 ctx.rectangle (0, 0, w, h);
127 ctx.set_source_rgb (0.8, 0.0, 0.0);127 ctx.set_source_rgb (0.8, 0.0, 0.0);
128 ctx.set_line_width (3.0);128 ctx.set_line_width (3.0);
129 ctx.stroke ();129 ctx.stroke ();
130 }130 }
131
131 return base.draw (ctx);132 return base.draw (ctx);
132 }133 }
133 134
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);
135 136
136 public void to_discrete (){137 public void to_discrete () {
137 if (!this.is_composited ()){138 if (!this.is_composited ()) {
138 this.destroy ();139 this.destroy ();
140
139 return;141 return;
140 }142 }
143
141 this.discrete = true;144 this.discrete = true;
142 this.set_keep_above (true);145 this.set_keep_above (true);
143 this.queue_draw ();146 this.queue_draw ();
144 this.resize (w+6, h+6);147 this.resize (w + 6, h + 6);
145 this.move (x-2, y-2);148 this.move (x - 2, y - 2);
146 this.deletable = false;149 this.deletable = false;
147 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;150 this.type_hint = Gdk.WindowTypeHint.SPLASHSCREEN;
148 this.accept_focus = false;151 this.accept_focus = false;
149 152
150 this.realize ();153 this.realize ();
151 154
152 Cairo.RectangleInt rect = {0, 0, 1, 1};155 Cairo.RectangleInt rect = {0, 0, 1, 1};
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);
154 157
155 this.enter_notify_event.connect ( () => {158 this.enter_notify_event.connect (() => {
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);
160
157 return true;161 return true;
158 });162 });
159 }163 }
160 }164 }
161}165}
162
163
164166
=== modified file 'src/desktop_launcher.vala'
--- src/desktop_launcher.vala 2012-06-07 04:40:05 +0000
+++ src/desktop_launcher.vala 2015-01-05 22:47:30 +0000
@@ -1,8 +1,7 @@
1namespace DesktopLauncher {1namespace DesktopLauncher {
2 /* Translatable launcher (.desktop) strings to be added to */2 // Translatable launcher (.desktop) strings to be added to
3 /* template (.pot) file. These strings MUST reflect any */3 // template (.pot) file. These strings MUST reflect any
4 /* changes in these launcher keys in .desktop file. */4 // changes in these launcher keys in .desktop file.
5 public const string COMMENT = N_("Record screencasts");5 public const string COMMENT = N_("Record screencasts");
6 public const string GENERIC_NAME = N_("Screencaster");6 public const string GENERIC_NAME = N_("Screencaster");
7
8}7}
98
=== modified file 'src/eidete.vala'
--- src/eidete.vala 2015-01-04 16:20:11 +0000
+++ src/eidete.vala 2015-01-05 22:47:30 +0000
@@ -1,37 +1,33 @@
11namespace Eidete {
2using Gst;2 class LLabel : Gtk.Label {
3using Granite;3 public LLabel (string label) {
4using Gtk;4 this.set_halign (Gtk.Align.START);
5
6
7namespace Eidete{
8
9 class LLabel : Label{
10 public LLabel (string label){
11 this.set_halign (Align.START);
12 this.label = label;5 this.label = label;
13 }6 }
14 public LLabel.indent (string label){7
8 public LLabel.indent (string label) {
15 this (label);9 this (label);
16 this.margin_left = 10;10 this.margin_left = 10;
17 }11 }
18 public LLabel.markup (string label){12
13 public LLabel.markup (string label) {
19 this (label);14 this (label);
20 this.use_markup = true;15 this.use_markup = true;
21 }16 }
22 public LLabel.right (string label){17
23 this.set_halign (Align.END);18 public LLabel.right (string label) {
19 this.set_halign (Gtk.Align.END);
24 this.label = label;20 this.label = label;
25 }21 }
26 public LLabel.right_with_markup (string label){22
27 this.set_halign (Align.END);23 public LLabel.right_with_markup (string label) {
24 this.set_halign (Gtk.Align.END);
28 this.use_markup = true;25 this.use_markup = true;
29 this.label = label;26 this.label = label;
30 }27 }
31 }28 }
3229
3330 public struct Settings {
34 public struct Settings{
35 public int sx;31 public int sx;
36 public int sy;32 public int sy;
37 public int ex;33 public int ex;
@@ -45,9 +41,8 @@
45 public string destination;41 public string destination;
46 }42 }
4743
48 public class EideteApp : Granite.Application{44 public class EideteApp : Granite.Application {
4945 construct {
50 construct{
51 program_name = "Eidete";46 program_name = "Eidete";
52 exec_name = "eidete";47 exec_name = "eidete";
5348
@@ -67,23 +62,23 @@
67 help_url = "https://code.launchpad.net/eidete";62 help_url = "https://code.launchpad.net/eidete";
68 translate_url = "https://translations.launchpad.net/eidete";63 translate_url = "https://translations.launchpad.net/eidete";
6964
70 about_authors = {"Tom Beckmann <tombeckmann@online.de>"};65 about_authors = { "Tom Beckmann <tombeckmann@online.de>" };
71 about_documenters = {"Tom Beckmann <tombeckmann@online.de>"};66 about_documenters = { "Tom Beckmann <tombeckmann@online.de>" };
72 about_artists = {"Harvey Cabaguio", "Sergey 'shnatsel' Davidoff"};67 about_artists = { "Harvey Cabaguio", "Sergey 'shnatsel' Davidoff" };
73 about_comments = "Development release (all features not implemented)";68 about_comments = "Development release (all features not implemented)";
74 about_translators = "";69 about_translators = "";
75 about_license_type = License.GPL_3_0;70 about_license_type = Gtk.License.GPL_3_0;
76 }71 }
7772
78 public dynamic Pipeline pipeline;73 public dynamic Gst.Pipeline pipeline;
7974
80 public Window main_window;75 public Gtk.Window main_window;
81 public Eidete.Widgets.KeyView keyview;76 public Eidete.Widgets.KeyView keyview;
82 public Eidete.Widgets.SelectionArea selectionarea;77 public Eidete.Widgets.SelectionArea selectionarea;
83 private Gtk.Stack tabs;78 private Gtk.Stack tabs;
84 private Grid pause_grid;79 private Gtk.Grid pause_grid;
85 private Gtk.Grid main_box ;80 private Gtk.Grid main_box;
86 private Gtk.StackSwitcher stack_switcher ;81 private Gtk.StackSwitcher stack_switcher;
87 public Wnck.Window win;82 public Wnck.Window win;
88 public Gdk.Screen screen;83 public Gdk.Screen screen;
89 public Gdk.Rectangle monitor_rec;84 public Gdk.Rectangle monitor_rec;
@@ -96,17 +91,16 @@
96 public Gst.Bin videobin;91 public Gst.Bin videobin;
97 public Gst.Bin audiobin;92 public Gst.Bin audiobin;
9893
99 public EideteApp (){94 public EideteApp () {
100 }95 }
10196
102 public void start_and_build () {97 public void start_and_build () {
103
104 Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;98 Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
10599
106 this.main_window = new Window ();100 this.main_window = new Gtk.Window ();
107 this.main_window.icon_name = exec_name;101 this.main_window.icon_name = exec_name;
108 this.main_window.set_application (this);102 this.main_window.set_application (this);
109 this.main_window.window_position = WindowPosition.CENTER;103 this.main_window.window_position = Gtk.WindowPosition.CENTER;
110 this.main_window.set_resizable (false);104 this.main_window.set_resizable (false);
111105
112 /* Use CSD */106 /* Use CSD */
@@ -114,90 +108,94 @@
114 header.title = program_name;108 header.title = program_name;
115 header.set_show_close_button (true);109 header.set_show_close_button (true);
116 header.get_style_context ().remove_class ("header-bar");110 header.get_style_context ().remove_class ("header-bar");
111
117 this.main_window.set_titlebar (header);112 this.main_window.set_titlebar (header);
118113
119 if (!this.main_window.is_composited ()){114 if (!this.main_window.is_composited ()){
120 warning ("Compositing is not supported. No transparency available.");115 warning ("Compositing is not supported. No transparency available.");
121 }116 }
122117
123
124 /*118 /*
125 UI119 UI
126 */120 */
127121
128 tabs = new Gtk.Stack ();122 tabs = new Gtk.Stack ();
129123
130 var grid = new Grid ();124 var grid = new Gtk.Grid ();
131 grid.column_spacing = 12;125 grid.column_spacing = 12;
132 grid.row_spacing = 6;126 grid.row_spacing = 6;
133 grid.hexpand = false;127 grid.hexpand = false;
134128
135 var monitors_combo = new ComboBoxText ();129 var monitors_combo = new Gtk.ComboBoxText ();
136 monitors_combo.hexpand = true;130 monitors_combo.hexpand = true;
137 for (var i=0;i<Gdk.Screen.get_default ().get_n_monitors (); i++)131
132 for (var i = 0; i < Gdk.Screen.get_default ().get_n_monitors (); i++) {
138 // TODO proper translation here133 // TODO proper translation here
139 monitors_combo.append (i.to_string (), _("Monitor")+" "+(i+1).to_string ());134 monitors_combo.append (i.to_string (), _("Monitor")+" "+(i+1).to_string ());
135 }
136
140 monitors_combo.active = 0;137 monitors_combo.active = 0;
138
141 if (Gdk.Screen.get_default ().get_n_monitors () == 1)139 if (Gdk.Screen.get_default ().get_n_monitors () == 1)
142 monitors_combo.set_sensitive (false);140 monitors_combo.set_sensitive (false);
143141
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);
145 width.max_length = 4;143 width.max_length = 4;
146 width.margin_left = 1;144 width.margin_left = 1;
147145
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);
149 height.max_length = 4;147 height.max_length = 4;
150 height.margin_left = 1;148 height.margin_left = 1;
151 width.set_sensitive (false);149 width.set_sensitive (false);
152 height.set_sensitive (false);150 height.set_sensitive (false);
153 width.halign = Align.START;151 width.halign = Gtk.Align.START;
154 height.halign = Align.START;152 height.halign = Gtk.Align.START;
155153
156 var recordingarea_combo = new ComboBoxText ();154 var recordingarea_combo = new Gtk.ComboBoxText ();
157 recordingarea_combo.append ("full", _("Fullscreen"));155 recordingarea_combo.append ("full", _("Fullscreen"));
158 recordingarea_combo.append ("custom", _("Custom"));156 recordingarea_combo.append ("custom", _("Custom"));
159 recordingarea_combo.active = 0;157 recordingarea_combo.active = 0;
160158
161 var use_comp_sounds = new CheckButton ();159 var use_comp_sounds = new Gtk.CheckButton ();
162 use_comp_sounds.halign = Align.START;160 use_comp_sounds.halign = Gtk.Align.START;
163 use_comp_sounds.set_sensitive (false);161 use_comp_sounds.set_sensitive (false);
164162
165 var use_audio = new CheckButton ();163 var use_audio = new Gtk.CheckButton ();
166 use_audio.halign = Align.START;164 use_audio.halign =Gtk. Align.START;
167165
168 var audio_source = new ComboBoxText ();166 var audio_source = new Gtk.ComboBoxText ();
169 audio_source.append ("0", _("Default"));167 audio_source.append ("0", _("Default"));
170 audio_source.active = 0;168 audio_source.active = 0;
171 audio_source.hexpand = true;169 audio_source.hexpand = true;
172 audio_source.set_sensitive (false);170 audio_source.set_sensitive (false);
173171
174 var audio_box = new Box (Orientation.HORIZONTAL, 0);172 var audio_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
175 audio_box.pack_start (use_audio, false, true, 0);173 audio_box.pack_start (use_audio, false, true, 0);
176 audio_box.pack_start (audio_source, true, true, 0);174 audio_box.pack_start (audio_source, true, true, 0);
177175
178 var sound = new LLabel.markup ("<b>"+_("Sound")+"</b>");176 var sound = new LLabel.markup ("<b>" + _("Sound") + "</b>");
179 sound.margin_top = 18;177 sound.margin_top = 18;
180178
181 var video = new LLabel.markup ("<b>"+_("Video")+"</b>");179 var video = new LLabel.markup ("<b>" + _("Video") + "</b>");
182 video.margin_top = 12;180 video.margin_top = 12;
183181
184 var keyboard = new LLabel.markup ("<b>"+_("Keyboard")+"</b>");182 var keyboard = new LLabel.markup ("<b>" + _("Keyboard") + "</b>");
185 keyboard.margin_top = 18;183 keyboard.margin_top = 18;
186184
187 var mouse = new LLabel.markup ("<b>"+_("Mouse")+"</b>");185 var mouse = new LLabel.markup ("<b>" + _("Mouse") + "</b>");
188 mouse.margin_top = 12;186 mouse.margin_top = 12;
189187
190 var start_bt = new Button.with_label (_("Start Recording"));188 var start_bt = new Gtk.Button.with_label (_("Start Recording"));
191 start_bt.can_default = true;189 start_bt.can_default = true;
192 start_bt.get_style_context ().add_class ("noundo");190 start_bt.get_style_context ().add_class ("noundo");
193 start_bt.get_style_context ().add_class ("suggested-action");191 start_bt.get_style_context ().add_class ("suggested-action");
194 192
195 var cancel_bt = new Button.with_label (_("Cancel"));193 var cancel_bt = new Gtk.Button.with_label (_("Cancel"));
196194
197 var about_bt = new Button.with_label (_("About"));195 var about_bt = new Gtk.Button.with_label (_("About"));
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);
199197
200 var buttons = new Box (Orientation.HORIZONTAL, 5);198 var buttons = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5);
201 buttons.homogeneous = true;199 buttons.homogeneous = true;
202 buttons.pack_start (about_bt, false, true, 0);200 buttons.pack_start (about_bt, false, true, 0);
203 buttons.pack_start (cancel_bt, false, true, 0);201 buttons.pack_start (cancel_bt, false, true, 0);
@@ -206,48 +204,48 @@
206204
207 this.main_window.set_default (start_bt);205 this.main_window.set_default (start_bt);
208206
209 grid.attach ((sound), 0, 0, 1, 1);207 grid.attach (sound, 0, 0, 1, 1);
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);
211 grid.attach (use_comp_sounds, 1, 1, 1, 1);209 grid.attach (use_comp_sounds, 1, 1, 1, 1);
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);
213 grid.attach (audio_box, 1, 2, 1, 1);211 grid.attach (audio_box, 1, 2, 1, 1);
214 grid.attach ((video), 0, 3, 2, 1);212 grid.attach ((video), 0, 3, 2, 1);
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);
216 grid.attach (monitors_combo, 1, 4, 1, 1);214 grid.attach (monitors_combo, 1, 4, 1, 1);
217 grid.attach (new LLabel.right (_("Recording Area")+":"), 0, 5, 1, 1);215 grid.attach (new LLabel.right (_("Recording Area") + ":"), 0, 5, 1, 1);
218 grid.attach (recordingarea_combo, 1, 5, 1, 1);216 grid.attach (recordingarea_combo, 1, 5, 1, 1);
219 grid.attach (new LLabel.right (_("Width")+":"), 0, 6, 1, 1);217 grid.attach (new LLabel.right (_("Width") + ":"), 0, 6, 1, 1);
220 grid.attach (width, 1, 6, 1, 1);218 grid.attach (width, 1, 6, 1, 1);
221 grid.attach (new LLabel.right (_("Height")+":"), 0, 7, 1, 1);219 grid.attach (new LLabel.right (_("Height") + ":"), 0, 7, 1, 1);
222 grid.attach (height, 1, 7, 1, 1);220 grid.attach (height, 1, 7, 1, 1);
223 grid.attach (buttons, 0, 8, 2, 1);221 grid.attach (buttons, 0, 8, 2, 1);
224222
225 //grid2223 //grid2
226 var grid2 = new Grid ();224 var grid2 = new Gtk.Grid ();
227225
228 var use_keyview = new Gtk.CheckButton ();226 var use_keyview = new Gtk.CheckButton ();
229 use_keyview.halign = Gtk.Align.START;227 use_keyview.halign = Gtk.Align.START;
230228
231 var use_clickview = new Gtk.CheckButton ();229 var use_clickview = new Gtk.CheckButton ();
232 use_clickview.halign = Gtk.Align.START;230 use_clickview.halign = Gtk.Align.START;
233231
234 var use_circle = new Gtk.CheckButton ();232 var use_circle = new Gtk.CheckButton ();
235 use_circle.halign = Gtk.Align.START;233 use_circle.halign = Gtk.Align.START;
236234
237 var circle_color = new Gtk.ColorButton ();235 var circle_color = new Gtk.ColorButton ();
238236
239 var circle_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);237 var circle_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
240 circle_box.pack_start (use_circle, false);238 circle_box.pack_start (use_circle, false);
241 circle_box.pack_start (circle_color);239 circle_box.pack_start (circle_color);
242240
243 //grid2.attach (new LLabel241 //grid2.attach (new LLabel
244 grid2.attach ((keyboard), 0, 0, 1, 1);242 grid2.attach ((keyboard), 0, 0, 1, 1);
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);
246 grid2.attach (use_keyview, 1, 1, 1, 1);244 grid2.attach (use_keyview, 1, 1, 1, 1);
247 grid2.attach ((mouse), 0, 2, 1, 1);245 grid2.attach ((mouse), 0, 2, 1, 1);
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);
249 grid2.attach (use_clickview, 1, 3, 1, 1);247 grid2.attach (use_clickview, 1, 3, 1, 1);
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);
251 grid2.attach (circle_box, 1, 4, 1, 1);249 grid2.attach (circle_box, 1, 4, 1, 1);
252 grid2.column_spacing = 12;250 grid2.column_spacing = 12;
253 grid2.row_spacing = 6;251 grid2.row_spacing = 6;
@@ -260,7 +258,7 @@
260 stack_switcher = new Gtk.StackSwitcher ();258 stack_switcher = new Gtk.StackSwitcher ();
261 stack_switcher.stack = tabs;259 stack_switcher.stack = tabs;
262 stack_switcher.halign = Gtk.Align.CENTER;260 stack_switcher.halign = Gtk.Align.CENTER;
263 build_pause_ui () ;261 build_pause_ui ();
264 pause_grid.show_all();262 pause_grid.show_all();
265 pause_grid.hide();263 pause_grid.hide();
266 pause_grid.no_show_all = true;264 pause_grid.no_show_all = true;
@@ -278,15 +276,15 @@
278 Events276 Events
279 */277 */
280278
281 about_bt.clicked.connect ( () => {279 about_bt.clicked.connect (() => {
282 this.show_about (this.main_window);280 this.show_about (this.main_window);
283 });281 });
284282
285 cancel_bt.clicked.connect ( () => {283 cancel_bt.clicked.connect (() => {
286 this.main_window.destroy ();284 this.main_window.destroy ();
287 });285 });
288286
289 start_bt.clicked.connect ( () => {287 start_bt.clicked.connect (() => {
290 var count = new Eidete.Widgets.Countdown ();288 var count = new Eidete.Widgets.Countdown ();
291 this.main_window.iconify ();289 this.main_window.iconify ();
292 count.start (this);290 count.start (this);
@@ -294,9 +292,11 @@
294292
295 this.screen = Gdk.Screen.get_default();293 this.screen = Gdk.Screen.get_default();
296 settings.monitor = 0;294 settings.monitor = 0;
297 monitors_combo.changed.connect ( () => {295 monitors_combo.changed.connect (() => {
298 settings.monitor = int.parse (monitors_combo.active_id);296 settings.monitor = int.parse (monitors_combo.active_id);
297
299 this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec);298 this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec);
299
300 settings.sx = this.monitor_rec.x;300 settings.sx = this.monitor_rec.x;
301 settings.sy = this.monitor_rec.y;301 settings.sy = this.monitor_rec.y;
302 settings.ex = settings.sx + this.monitor_rec.width - 1;302 settings.ex = settings.sx + this.monitor_rec.width - 1;
@@ -304,69 +304,88 @@
304 });304 });
305305
306 settings.monitor = int.parse (monitors_combo.active_id);306 settings.monitor = int.parse (monitors_combo.active_id);
307
307 this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec);308 this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec);
309
308 settings.sx = this.monitor_rec.x;310 settings.sx = this.monitor_rec.x;
309 settings.sy = this.monitor_rec.y;311 settings.sy = this.monitor_rec.y;
310 settings.ex = settings.sx + this.monitor_rec.width - 1;312 settings.ex = settings.sx + this.monitor_rec.width - 1;
311 settings.ey = settings.sy + this.monitor_rec.height - 1;313 settings.ey = settings.sy + this.monitor_rec.height - 1;
312314
313 recordingarea_combo.changed.connect ( () => {315 recordingarea_combo.changed.connect (() => {
314 if (recordingarea_combo.active_id != "full"){316 if (recordingarea_combo.active_id != "full"){
315 selectionarea = new Eidete.Widgets.SelectionArea ();317 selectionarea = new Eidete.Widgets.SelectionArea ();
316 selectionarea.show_all ();318 selectionarea.show_all ();
317 width.set_sensitive (true);319 width.set_sensitive (true);
318 height.set_sensitive (true);320 height.set_sensitive (true);
319 selectionarea.geometry_changed.connect ( (x, y, w, h) => {321 selectionarea.geometry_changed.connect ((x, y, w, h) => {
320 if (!typing_size){322 if (!typing_size){
321 width.value = (int)w;323 width.value = (int)w;
322 height.value = (int)h;324 height.value = (int)h;
323 settings.sx = x;325 settings.sx = x;
324 settings.sy = y;326 settings.sy = y;
325 settings.ex = settings.sx+w-1;327 settings.ex = settings.sx + w-1;
326 settings.ey = settings.sy+h-1;328 settings.ey = settings.sy + h-1;
327 }329 }
328 });330 });
329 selectionarea.focus_in_event.connect( (ev) => {331
332 selectionarea.focus_in_event.connect((ev) => {
330 if (this.recording){333 if (this.recording){
331 this.main_window.deiconify();334 this.main_window.deiconify();
332 this.main_window.present();335 this.main_window.present();
333 }336 }
337
334 return false;338 return false;
335 });339 });
336 }else{340 } else {
337 selectionarea.destroy ();341 selectionarea.destroy ();
338 settings.monitor = int.parse (monitors_combo.active_id);342 settings.monitor = int.parse (monitors_combo.active_id);
343
339 this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec);344 this.screen.get_monitor_geometry(settings.monitor, out this.monitor_rec);
345
340 settings.sx = this.monitor_rec.x;346 settings.sx = this.monitor_rec.x;
341 settings.sy = this.monitor_rec.y;347 settings.sy = this.monitor_rec.y;
342 settings.ex = settings.sx + this.monitor_rec.width - 1;348 settings.ex = settings.sx + this.monitor_rec.width - 1;
343 settings.ey = settings.sy + this.monitor_rec.height - 1;349 settings.ey = settings.sy + this.monitor_rec.height - 1;
350
344 width.set_sensitive (false);351 width.set_sensitive (false);
345 height.set_sensitive (false);352 height.set_sensitive (false);
346 }353 }
347 });354 });
348355
349 width.key_release_event.connect ( (e) => {356 width.key_release_event.connect ((e) => {
350 selectionarea.resize ((int)width.value, (int)height.value);357 selectionarea.resize ((int)width.value, (int)height.value);
351 typing_size = true;358 typing_size = true;
352 return false;359
353 });360 return false;
354 width.focus_out_event.connect ( (e) => {typing_size = false;return false;});361 });
355 height.key_release_event.connect ( (e) => {362
356 selectionarea.resize ((int)width.value, (int)height.value);363 width.focus_out_event.connect ((e) => {
357 typing_size = true;364 typing_size = false;
358 return false;365
359 });366 return false;
360 height.focus_out_event.connect ( (e) => {typing_size = false;return false;});367 });
368
369 height.key_release_event.connect ((e) => {
370 selectionarea.resize ((int)width.value, (int)height.value);
371 typing_size = true;
372
373 return false;
374 });
375
376 height.focus_out_event.connect ((e) => {
377 typing_size = false;
378
379 return false;
380 });
361381
362 settings.audio = false;382 settings.audio = false;
363 use_audio.toggled.connect ( () => {383 use_audio.toggled.connect (() => {
364 settings.audio = use_audio.active;384 settings.audio = use_audio.active;
365 audio_source.set_sensitive (use_audio.active);385 audio_source.set_sensitive (use_audio.active);
366 });386 });
367387
368388 Gdk.Screen.get_default ().monitors_changed.connect (() => {
369 Gdk.Screen.get_default ().monitors_changed.connect ( () => {
370 if (Gdk.Screen.get_default ().get_n_monitors () > 1)389 if (Gdk.Screen.get_default ().get_n_monitors () > 1)
371 monitors_combo.set_sensitive (true);390 monitors_combo.set_sensitive (true);
372 else391 else
@@ -374,84 +393,92 @@
374 });393 });
375394
376 settings.keyview = false;395 settings.keyview = false;
377 use_keyview.toggled.connect ( () => {396 use_keyview.toggled.connect (() => {
378 settings.keyview = use_keyview.active;397 settings.keyview = use_keyview.active;
379 });398 });
380399
381 settings.clickview = false;400 settings.clickview = false;
382 use_clickview.toggled.connect ( () => {401 use_clickview.toggled.connect (() => {
383 settings.clickview = use_clickview.active;402 settings.clickview = use_clickview.active;
384 });403 });
385404
386 settings.mouse_circle = false;405 settings.mouse_circle = false;
387 use_circle.toggled.connect ( () => {406 use_circle.toggled.connect (() => {
388 settings.mouse_circle = use_circle.active;407 settings.mouse_circle = use_circle.active;
389 });408 });
390409
391 settings.mouse_circle_color = {1, 1, 0, 0.3};410 settings.mouse_circle_color = {1, 1, 0, 0.3};
392 circle_color.use_alpha = true;411 circle_color.use_alpha = true;
393 circle_color.rgba = settings.mouse_circle_color;412 circle_color.rgba = settings.mouse_circle_color;
394 circle_color.color_set.connect ( () => {413 circle_color.color_set.connect (() => {
395 settings.mouse_circle_color = circle_color.rgba;414 settings.mouse_circle_color = circle_color.rgba;
396 });415 });
397416
398 settings.destination = GLib.Environment.get_tmp_dir ()+417 settings.destination = GLib.Environment.get_tmp_dir () +
399 "/screencast"+new GLib.DateTime.now_local ().to_unix ().to_string ()+".webm";418 "/screencast" + new GLib.DateTime.now_local ().to_unix ().to_string () + ".webm";
400419
401 ulong handle = 0;420 ulong handle = 0;
402 handle = Wnck.Screen.get_default().active_window_changed.connect ( () => {421 handle = Wnck.Screen.get_default().active_window_changed.connect (() => {
403 this.win = Wnck.Screen.get_default().get_active_window ();422 this.win = Wnck.Screen.get_default().get_active_window ();
404 this.win.state_changed.connect ( (changed_s, new_s) => {423 this.win.state_changed.connect ( (changed_s, new_s) => {
405 if (recording && (new_s == 0)){424 if (recording && (new_s == 0)) {
406 pipeline.set_state (State.PAUSED);425 pipeline.set_state (Gst.State.PAUSED);
407 this.recording = false;426 this.recording = false;
408 switch_to_paused (true);427 switch_to_paused (true);
409 }428 }
410 });429 });
411 Wnck.Screen.get_default ().disconnect (handle);430
412 });431 Wnck.Screen.get_default ().disconnect (handle);
413432 });
414 this.main_window.focus_in_event.connect ( (ev) => {433
415 if (this.selectionarea != null && !this.selectionarea.not_visible){434 this.main_window.focus_in_event.connect ((ev) => {
416 this.selectionarea.present ();435 if (this.selectionarea != null && !this.selectionarea.not_visible){
417 this.main_window.present ();436 this.selectionarea.present ();
418 }437 this.main_window.present ();
419 return false;438 }
420 });439
440 return false;
441 });
442
421/* disabled for now until mutter supports it better443/* disabled for now until mutter supports it better
422 this.main_window.visibility_notify_event.connect ( (ev) => {444 this.main_window.visibility_notify_event.connect ((ev) => {
423 if (this.recording && ev.state == 0){445 if (this.recording && ev.state == 0){
424 debug ("pausing recording");446 debug ("pausing recording");
447
425 pipeline.set_state (State.PAUSED);448 pipeline.set_state (State.PAUSED);
426 this.recording = false;449 this.recording = false;
427 switch_to_paused (true);450 switch_to_paused (true);
428 }451 }
452
429 return false;453 return false;
430 });454 });
431*/455*/
432456
433 this.main_window.destroy.connect ( () => {457 this.main_window.destroy.connect (() => {
434 if ( recording ) {458 if (recording) {
435 finish_recording ();459 finish_recording ();
436 }460 }
437 });461 });
438462
439 Granite.Services.Logger.initialize ("Eidete");463 Granite.Services.Logger.initialize ("Eidete");
440 Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG;464 Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG;
441 uint major ;465
442 uint minor ;466 uint major;
443 uint micro ;467 uint minor;
444 uint nano ;468 uint micro;
445 Gst.version (out major, out minor, out micro, out nano) ;469 uint nano;
446 message ("GStreamer version: %u.%u.%u.%u", major, minor, micro, nano ) ;470
471 Gst.version (out major, out minor, out micro, out nano);
472
473 message ("GStreamer version: %u.%u.%u.%u", major, minor, micro, nano );
447 }474 }
448475
449 public override void activate (){476 public override void activate () {
450 if (this.get_windows ().length () == 0){477 if (this.get_windows ().length () == 0) {
451 this.start_and_build ();478 this.start_and_build ();
452 }else{479 } else {
453 if (pause_rec)480 if (pause_rec)
454 this.main_window.present ();481 this.main_window.present ();
455 else if (finish_rec) {482 else if (finish_rec) {
456 finish_recording ();483 finish_recording ();
457 }484 }
@@ -459,47 +486,44 @@
459 }486 }
460487
461 private void build_pause_ui (){488 private void build_pause_ui (){
462489 pause_grid = new Gtk.Grid ();
463 pause_grid = new Grid ();
464 pause_grid.margin = 12;490 pause_grid.margin = 12;
465 //this.main_window.title = _("Recording paused");491 //this.main_window.title = _("Recording paused");
466492
467493 var img_text_grid = new Gtk.Grid ();
468 var img_text_grid = new Grid ();494 var text_grid = new Gtk.Grid ();
469495
470 var text_grid = new Grid ();496 var title = new LLabel.markup ("<span weight='bold' size='larger'>" + _("Recording paused") + "</span>");
471497 title.valign = Gtk.Align.START;
472 var title = new LLabel.markup ("<span weight='bold' size='larger'>"+_("Recording paused")+"</span>");
473 title.valign = Align.START;
474498
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"));
476 info.valign = Align.START;500 info.valign = Gtk.Align.START;
477 info.margin_top = 6;501 info.margin_top = 6;
478502
479 var buttons = new Box (Orientation.HORIZONTAL, 0);503 var buttons = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
480 buttons.homogeneous = true;504 buttons.homogeneous = true;
481 buttons.spacing = 6;505 buttons.spacing = 6;
482 buttons.margin_top = 24;506 buttons.margin_top = 24;
483507
484 var continue_bt = new Button.with_label (_("Continue"));508 var continue_bt = new Gtk.Button.with_label (_("Continue"));
485 continue_bt.set_tooltip_text (_("Continue recording"));509 continue_bt.set_tooltip_text (_("Continue recording"));
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);
487511
488 var stop_bt = new Button.with_label (_("Finish"));512 var stop_bt = new Gtk.Button.with_label (_("Finish"));
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"));
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);
491 stop_bt.get_style_context ().add_class ("suggested-action");515 stop_bt.get_style_context ().add_class ("suggested-action");
492516
493 var cancel_bt = new Button.with_label (_("Cancel"));517 var cancel_bt = new Gtk.Button.with_label (_("Cancel"));
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"));
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);
496520
497 buttons.pack_end (stop_bt, false, true, 0);521 buttons.pack_end (stop_bt, false, true, 0);
498 buttons.pack_end (continue_bt, false, true, 0);522 buttons.pack_end (continue_bt, false, true, 0);
499 buttons.pack_end (cancel_bt, false, true, 0);523 buttons.pack_end (cancel_bt, false, true, 0);
500524
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);
502 img.valign = Align.START;526 img.valign = Gtk.Align.START;
503 img.margin_right = 12;527 img.margin_right = 12;
504528
505 text_grid.attach (title, 0, 0, 1, 1);529 text_grid.attach (title, 0, 0, 1, 1);
@@ -511,25 +535,26 @@
511 pause_grid.attach (img_text_grid, 0, 0, 1, 1);535 pause_grid.attach (img_text_grid, 0, 0, 1, 1);
512 pause_grid.attach (buttons, 0, 2, 1, 1);536 pause_grid.attach (buttons, 0, 2, 1, 1);
513537
514
515 stop_bt.can_default = true;538 stop_bt.can_default = true;
516 this.main_window.set_default (stop_bt);539 this.main_window.set_default (stop_bt);
517540
518 /*541 /*
519 Events542 Events
520 */543 */
521 cancel_bt.clicked.connect ( () => {544
545 cancel_bt.clicked.connect (() => {
522 this.main_window.destroy ();546 this.main_window.destroy ();
523 });547 });
524548
525 stop_bt.clicked.connect ( () => {549 stop_bt.clicked.connect (() => {
526 finish_recording ();550 finish_recording ();
527 });551 });
528552
529 continue_bt.clicked.connect ( () => {553 continue_bt.clicked.connect (() => {
530 this.main_window.iconify ();554 this.main_window.iconify ();
531 this.pipeline.set_state (State.PLAYING);555 this.pipeline.set_state (Gst.State.PLAYING);
532 this.recording = true;556 this.recording = true;
557
533 switch_to_paused (false);558 switch_to_paused (false);
534 });559 });
535 }560 }
@@ -542,79 +567,92 @@
542 this.main_window.deiconify ();567 this.main_window.deiconify ();
543 this.main_window.present ();568 this.main_window.present ();
544 }569 }
570
545 return false;571 return false;
546 });572 });
547 keyview.place (settings.ex,573
548 settings.sy,574 keyview.place (settings.ex, settings.sy, settings.ey - settings.sy);
549 settings.ey - settings.sy);
550 keyview.show_all ();575 keyview.show_all ();
551 }576 }
552577
553 pipeline = new Pipeline ("screencast-pipe");578 pipeline = new Gst.Pipeline ("screencast-pipe");
554579
555 #if GSTREAMER_0_10_IS_DEFINED580#if GSTREAMER_0_10_IS_DEFINED
556 dynamic Element muxer = ElementFactory.make ("webmmux", "mux");581 dynamic Element muxer = Gst.ElementFactory.make ("webmmux", "mux");
557 dynamic Element sink = ElementFactory.make ("filesink", "sink");582 dynamic Element sink = Gst.ElementFactory.make ("filesink", "sink");
558 #else583#else
559 var muxer = ElementFactory.make ("webmmux", "mux");584 var muxer = Gst.ElementFactory.make ("webmmux", "mux");
560 var sink = ElementFactory.make ("filesink", "sink");585 var sink = Gst.ElementFactory.make ("filesink", "sink");
561 #endif586#endif
587
562 //video bin588 //video bin
563 this.videobin = new Gst.Bin ("video");589 this.videobin = new Gst.Bin ("video");
590
564 try {591 try {
565 #if GSTREAMER_0_10_IS_DEFINED592#if GSTREAMER_0_10_IS_DEFINED
566 videobin = (Gst.Bin)parse_bin_from_description (593 videobin = (Gst.Bin)Gst.parse_bin_from_description (
567 "ximagesrc name=\"videosrc\" ! video/x-raw-rgb, framerate=15/1 !594 "ximagesrc name=\"videosrc\" ! video/x-raw-rgb, framerate=15/1 !
568 ffmpegcolorspace ! vp8enc name=\"encoder\" ! queue", true);595 ffmpegcolorspace ! vp8enc name=\"encoder\" ! queue", true);
569 #else596#else
570 videobin = (Gst.Bin)parse_bin_from_description (597 videobin = (Gst.Bin)Gst.parse_bin_from_description (
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);
572 #endif599#endif
573 }catch (Error e){ stderr.printf ("Error: %s\n", e.message);}600 } catch (Error e) {
601 stderr.printf ("Error: %s\n", e.message);
602 }
574603
575 //audio bin604 //audio bin
576 this.audiobin = new Gst.Bin ("audio");605 this.audiobin = new Gst.Bin ("audio");
577 try{
578 audiobin = (Gst.Bin)parse_bin_from_description ("pulsesrc name=\"audiosrc\" !
579 audioconvert ! audioresample ! audiorate ! vorbisenc ! queue", true);
580 }catch (Error e){ stderr.printf ("Error: %s\n", e.message);}
581606
607 try {
608 audiobin = (Gst.Bin)Gst.parse_bin_from_description ("pulsesrc name=\"audiosrc\" !
609 audioconvert ! audioresample ! audiorate ! vorbisenc ! queue", true);
610 } catch (Error e) {
611 stderr.printf ("Error: %s\n", e.message);
612 }
582613
583 string cores;614 string cores;
584 try{615
616 try {
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);
586 }catch (Error e){warning (e.message);}618 } catch (Error e) {
619 warning (e.message);
620 }
587621
588 //configure622 //configure
589 assert( sink != null ) ;623 assert( sink != null );
590 sink.set ("location", settings.destination);624 sink.set ("location", settings.destination);
591 var src = videobin.get_by_name ("videosrc") ;625
592 assert (src != null) ;626 var src = videobin.get_by_name ("videosrc");
627
628 assert (src != null);
629
593 src.set ("startx", this.settings.sx);630 src.set ("startx", this.settings.sx);
594 src.set ("starty", this.settings.sy);631 src.set ("starty", this.settings.sy);
595 src.set ("endx", this.settings.ex);632 src.set ("endx", this.settings.ex);
596 src.set ("endy", this.settings.ey);633 src.set ("endy", this.settings.ey);
597 src.set ("use-damage", false);634 src.set ("use-damage", false);
598 src.set ("screen-num", this.settings.monitor);635 src.set ("screen-num", this.settings.monitor);
599636
600 //videobin.get_by_name ("encoder").set ("mode", 1);637 //videobin.get_by_name ("encoder").set ("mode", 1);
601 var encoder = videobin.get_by_name ("encoder") ;638 var encoder = videobin.get_by_name ("encoder");
602 assert (encoder != null) ;639
603 #if GSTREAMER_0_10_IS_DEFINED640 assert (encoder != null);
641
642#if GSTREAMER_0_10_IS_DEFINED
604 encoder.set ("quality", 8.0);643 encoder.set ("quality", 8.0);
605 encoder.set ("speed", 6);644 encoder.set ("speed", 6);
606 encoder.set ("max-keyframe-distance", 150);645 encoder.set ("max-keyframe-distance", 150);
607 #else646#else
608 // From these values see https://mail.gnome.org/archives/commits-list/2012-September/msg08183.html647 // From these values see https://mail.gnome.org/archives/commits-list/2012-September/msg08183.html
609 encoder.set ("min_quantizer", 13);648 encoder.set ("min_quantizer", 13);
610 encoder.set ("max_quantizer", 13);649 encoder.set ("max_quantizer", 13);
611 encoder.set ("cpu-used", 5);650 encoder.set ("cpu-used", 5);
612 encoder.set ("deadline", 1000000);651 encoder.set ("deadline", 1000000);
613 #endif652#endif
614 encoder.set ("threads", int.parse (cores.substring (2)));653 encoder.set ("threads", int.parse (cores.substring (2)));
615654
616655 if (pipeline == null || muxer == null || sink == null || videobin == null || audiobin == null){
617 if (pipeline==null||muxer==null||sink==null||videobin==null||audiobin==null){
618 stderr.printf ("Error: Elements weren't made correctly!\n");656 stderr.printf ("Error: Elements weren't made correctly!\n");
619 }657 }
620658
@@ -623,61 +661,75 @@
623 else661 else
624 pipeline.add_many (videobin, muxer, sink);662 pipeline.add_many (videobin, muxer, sink);
625663
626664 var video_pad = videobin.get_static_pad ("src");
627 var video_pad = videobin.get_static_pad ("src") ;665
628 assert (video_pad != null ) ;666 assert (video_pad != null );
629 #if GSTREAMER_0_10_IS_DEFINED667
630 var m = muxer.get_request_pad ("video_%d") ;668#if GSTREAMER_0_10_IS_DEFINED
631 #else669 var m = muxer.get_request_pad ("video_%d");
632 var m = muxer.get_request_pad ("video_%u") ;670#else
633 #endif671 var m = muxer.get_request_pad ("video_%u");
634 assert (m != null ) ;672#endif
673
674 assert (m != null);
675
635 video_pad.link(m);676 video_pad.link(m);
636 if (settings.audio){677
637 #if GSTREAMER_0_10_IS_DEFINED678 if (settings.audio) {
679#if GSTREAMER_0_10_IS_DEFINED
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"));
639 #else681#else
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"));
641 #endif683#endif
642 }684 }
685
643 muxer.link (sink);686 muxer.link (sink);
644 #if GSTREAMER_0_10_IS_DEFINED687#if GSTREAMER_0_10_IS_DEFINED
645 pipeline.get_bus ().add_watch (bus_message_cb);688 pipeline.get_bus ().add_watch (bus_message_cb);
646 #else689#else
647 pipeline.get_bus ().add_watch (Priority.DEFAULT, bus_message_cb);690 pipeline.get_bus ().add_watch (Priority.DEFAULT, bus_message_cb);
648 #endif691#endif
649 pipeline.set_state (State.READY);692
693 pipeline.set_state (Gst.State.READY);
650694
651 if (selectionarea != null)695 if (selectionarea != null)
652 selectionarea.to_discrete ();696 selectionarea.to_discrete ();
653697
654 pipeline.set_state (State.PLAYING);698 pipeline.set_state (Gst.State.PLAYING);
655 this.recording = true;699 this.recording = true;
656 }700 }
657701
658 public void finish_recording () {702 public void finish_recording () {
659 if ( ! this.recording ) {703 if (!this.recording) {
660 debug ("resuming recording\n");704 debug ("resuming recording\n");
661 this.pipeline.set_state(State.PLAYING);705
706 this.pipeline.set_state(Gst.State.PLAYING);
662 this.recording = true;707 this.recording = true;
663 }708 }
664 pipeline.send_event (new Event.eos());709
710 pipeline.send_event (new Gst.Event.eos ());
665 }711 }
666712
667 private bool bus_message_cb (Gst.Bus bus, Message msg){713 private bool bus_message_cb (Gst.Bus bus, Gst.Message msg) {
668 switch (msg.type){714 switch (msg.type) {
669 case Gst.MessageType.ERROR:715 case Gst.MessageType.ERROR:
670 GLib.Error err; string debug;716 GLib.Error err;
717
718 string debug;
719
671 msg.parse_error (out err, out debug);720 msg.parse_error (out err, out debug);
672721
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]"
674 .printf (err.message, debug), true);723 .printf (err.message, debug), true);
675 stderr.printf ("Error: %s\n", debug);724 stderr.printf ("Error: %s\n", debug);
676 pipeline.set_state (State.NULL);725 pipeline.set_state (Gst.State.NULL);
726
677 break;727 break;
678 case Gst.MessageType.EOS:728 case Gst.MessageType.EOS:
679 debug ("received EOS\n");729 debug ("received EOS\n");
680 pipeline.set_state (State.NULL);730
731 pipeline.set_state (Gst.State.NULL);
732
681 this.recording = false;733 this.recording = false;
682734
683 var end = new Eidete.Widgets.EndDialog (this);735 var end = new Eidete.Widgets.EndDialog (this);
@@ -688,27 +740,30 @@
688 default:740 default:
689 break;741 break;
690 }742 }
743
691 return true;744 return true;
692 }745 }
693746
694 //only visuals747 //only visuals
695 public void switch_to_paused (bool to_normal){748 public void switch_to_paused (bool to_normal) {
696749 if (to_normal) {
697 if (to_normal){
698 this.main_window.title = _("Recording paused");750 this.main_window.title = _("Recording paused");
699 tabs.hide () ;751
700 stack_switcher.hide () ;752 tabs.hide ();
701 pause_grid.show () ;753 stack_switcher.hide ();
754 pause_grid.show ();
755
702 this.main_window.icon_name = "eidete";756 this.main_window.icon_name = "eidete";
703 this.app_icon = "eidete";757 this.app_icon = "eidete";
704758 } else {
705 }else{
706 this.main_window.title = _("Pause recording");759 this.main_window.title = _("Pause recording");
760
707 if (tabs.visible) {761 if (tabs.visible) {
708 tabs.hide () ;762 tabs.hide ();
709 stack_switcher.hide () ;763 stack_switcher.hide ();
710 pause_grid.show () ;764 pause_grid.show ();
711 }765 }
766
712 this.main_window.icon_name = "media-playback-pause";767 this.main_window.icon_name = "media-playback-pause";
713 this.app_icon = "media-playback-pause";768 this.app_icon = "media-playback-pause";
714 769
@@ -744,17 +799,19 @@
744static const OptionEntry[] entries = {799static const OptionEntry[] entries = {
745 {"pause", 'n', 0, OptionArg.NONE, ref pause_rec, N_("Pause Recording"), ""},800 {"pause", 'n', 0, OptionArg.NONE, ref pause_rec, N_("Pause Recording"), ""},
746 {"finish", 'n', 0, OptionArg.NONE, ref finish_rec, N_("Finish Recording"), ""},801 {"finish", 'n', 0, OptionArg.NONE, ref finish_rec, N_("Finish Recording"), ""},
747 { null }802 {null}
748};803};
749804
750
751public static int main (string [] args) {805public static int main (string [] args) {
752 var context = new OptionContext ("ctx");806 var context = new OptionContext ("ctx");
753 context.add_main_entries (entries, "eidete");807 context.add_main_entries (entries, "eidete");
754 context.add_group (Gtk.get_option_group (true));808 context.add_group (Gtk.get_option_group (true));
755 try{809
810 try {
756 context.parse (ref args);811 context.parse (ref args);
757 }catch (Error e){ error ("Error: "+e.message);}812 } catch (Error e) {
813 error ("Error: " + e.message);
814 }
758815
759 Gst.init (ref args);816 Gst.init (ref args);
760817
761818
=== modified file 'src/keycapture.c'
--- src/keycapture.c 2015-01-04 14:30:20 +0000
+++ src/keycapture.c 2015-01-05 22:47:30 +0000
@@ -4,12 +4,14 @@
4#include <X11/Xlib.h>4#include <X11/Xlib.h>
5#include <X11/XKBlib.h>5#include <X11/XKBlib.h>
6#include <X11/extensions/record.h> //libxtst-dev, Xtst6#include <X11/extensions/record.h> //libxtst-dev, Xtst
7
7#ifdef GSTREAMER_0_10_IS_DEFINED8#ifdef GSTREAMER_0_10_IS_DEFINED
8#include <gstreamer-0.10/gst/gst.h>9 #include <gstreamer-0.10/gst/gst.h>
9#include <gstreamer-0.10/gst/gstinterface.h>10 #include <gstreamer-0.10/gst/gstinterface.h>
10#else11#else
11#include <gstreamer-1.0/gst/gst.h>12 #include <gstreamer-1.0/gst/gst.h>
12#endif13#endif
14
13/*15/*
14GList *list_devices (){16GList *list_devices (){
15 GstElement *pulsesrc = gst_element_factory_make ("pulsesrc", "src");17 GstElement *pulsesrc = gst_element_factory_make ("pulsesrc", "src");
@@ -24,32 +26,30 @@
24void key_pressed_cb(XPointer arg, XRecordInterceptData *d) {26void key_pressed_cb(XPointer arg, XRecordInterceptData *d) {
25 if (d->category != XRecordFromServer) return;27 if (d->category != XRecordFromServer) return;
2628
27 xEvent* event = (xEvent*)d->data;29 xEvent* event = (xEvent*)d->data;
28 30
29 unsigned char type = ((unsigned char*)d->data)[0] & 0x7F;31 unsigned char type = ((unsigned char*)d->data)[0] & 0x7F;
30 unsigned char detail = ((unsigned char*)d->data)[1];32 unsigned char detail = ((unsigned char*)d->data)[1];
31 unsigned int shiftlevel = 0;33 unsigned int shiftlevel = 0;
3234
33 if( event->u.keyButtonPointer.state == 0 ||35 if(event->u.keyButtonPointer.state == 0 || event->u.keyButtonPointer.state == 1 )
34 event->u.keyButtonPointer.state == 1 ) {36 shiftlevel = event->u.keyButtonPointer.state;
35 shiftlevel = event->u.keyButtonPointer.state;37
36 }
37
38 switch (type) {38 switch (type) {
39 case KeyPress:39 case KeyPress:
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);
41 break;41 break;
42 case KeyRelease:42 case KeyRelease:
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);
44 break;44 break;
45 case ButtonPress:45 case ButtonPress:
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);
47 break;47 break;
48 case MotionNotify:48 case MotionNotify:
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);
50 break;50 break;
51 default:51 default:
52 break;52 break;
53 }53 }
5454
55 XRecordFreeData (d);55 XRecordFreeData (d);
@@ -59,23 +59,27 @@
59 XRecordClientSpec rcs;59 XRecordClientSpec rcs;
60 XRecordRange* rr;60 XRecordRange* rr;
61 dpy = XOpenDisplay (0);61 dpy = XOpenDisplay (0);
62 62
63 XKeysymToString (XkbKeycodeToKeysym (dpy, 11, 1, 0));63 XKeysymToString (XkbKeycodeToKeysym (dpy, 11, 1, 0));
64 64
65 if (!(rr = XRecordAllocRange())) {65 if (!(rr = XRecordAllocRange())) {
66 fprintf(stderr, "XRecordAllocRange error\n");66 fprintf(stderr, "XRecordAllocRange error\n");
67 }67 }
68
68 rr->device_events.first = KeyPress;69 rr->device_events.first = KeyPress;
69 rr->device_events.last = MotionNotify;70 rr->device_events.last = MotionNotify;
70 rcs = XRecordAllClients;71 rcs = XRecordAllClients;
71 72
72 if (!(rc = XRecordCreateContext(dpy, 0, &rcs, 1, &rr, 1))) {73 if (!(rc = XRecordCreateContext(dpy, 0, &rcs, 1, &rr, 1))) {
73 fprintf(stderr, "XRecordCreateContext error\n");74 fprintf(stderr, "XRecordCreateContext error\n");
74 }75 }
76
75 XFree(rr);77 XFree(rr);
78
76 if (!XRecordEnableContext(dpy, rc, key_pressed_cb, data)) {79 if (!XRecordEnableContext(dpy, rc, key_pressed_cb, data)) {
77 fprintf(stderr, "XRecordEnableContext error\n");80 fprintf(stderr, "XRecordEnableContext error\n");
78 }81 }
82
79 return 0;83 return 0;
80}84}
8185
8286
=== modified file 'src/videobin_uploader.vala'
--- src/videobin_uploader.vala 2015-01-04 11:44:37 +0000
+++ src/videobin_uploader.vala 2015-01-05 22:47:30 +0000
@@ -1,64 +1,70 @@
1using Gtk;1public class Uploader : Gtk.Window {
22 class LLabel : Gtk.Label {
3public class Uploader : Window{3 public LLabel (string label) {
4 4 this.set_halign (Gtk.Align.START);
5 class LLabel : Label{
6 public LLabel (string label){
7 this.set_halign (Align.START);
8 this.label = label;5 this.label = label;
9 }6 }
10 public LLabel.indent (string label){7
8 public LLabel.indent (string label) {
11 this (label);9 this (label);
12 this.margin_left = 10;10 this.margin_left = 10;
13 }11 }
14 public LLabel.markup (string label){12
13 public LLabel.markup (string label) {
15 this (label);14 this (label);
16 this.use_markup = true;15 this.use_markup = true;
17 }16 }
18 public LLabel.right (string label){17
19 this.set_halign (Align.END);18 public LLabel.right (string label) {
19 this.set_halign (Gtk.Align.END);
20 this.label = label;20 this.label = label;
21 }21 }
22 public LLabel.right_with_markup (string label){22
23 this.set_halign (Align.END);23 public LLabel.right_with_markup (string label) {
24 this.set_halign (Gtk.Align.END);
24 this.use_markup = true;25 this.use_markup = true;
25 this.label = label;26 this.label = label;
26 }27 }
27 }28 }
28 29
29 30 public Uploader (File file) {
30 public Uploader (File file){
31 this.title = "Upload to videobin.org";31 this.title = "Upload to videobin.org";
32 this.set_default_size (300, 1);32 this.set_default_size (300, -1);
33 this.window_position = WindowPosition.CENTER;33 this.window_position = Gtk.WindowPosition.CENTER;
34 34
35 var grid = new Grid ();35 var grid = new Gtk.Grid ();
36 grid.margin = 12;36 grid.margin = 12;
37 grid.column_spacing = 12;37 grid.column_spacing = 12;
38 grid.row_spacing = 5;38 grid.row_spacing = 5;
39 39
40 var title = new Entry ();40 var title = new Gtk.Entry ();
41 title.placeholder_text = _("Optional") ;41 title.placeholder_text = _("Optional");
42 var description = new Entry ();42
43 description.placeholder_text = _("Optional") ;43 var description = new Gtk.Entry ();
44 var email = new Entry ();44 description.placeholder_text = _("Optional");
45 email.placeholder_text = _("Optional") ;45
46 var img = new Image.from_icon_name ("videobin", IconSize.DIALOG);46 var email = new Gtk.Entry ();
47 47 email.placeholder_text = _("Optional");
48 var upload_button = new Button.with_label (_("Upload"));48
49 var img = new Gtk.Image.from_icon_name ("videobin", Gtk.IconSize.DIALOG);
50
51 var upload_button = new Gtk.Button.with_label (_("Upload"));
49 upload_button.get_style_context ().add_class ("suggested-action");52 upload_button.get_style_context ().add_class ("suggested-action");
50 var cancel = new Button.from_stock (Stock.CANCEL);53
54 var cancel = new Gtk.Button.from_stock (Gtk.Stock.CANCEL);
51 cancel.margin_end = 6;55 cancel.margin_end = 6;
52 56
53 var bbox = new Box (Orientation.HORIZONTAL, 0);57 var bbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
54 bbox.pack_end (upload_button, false, true, 0);58 bbox.pack_end (upload_button, false, true, 0);
55 bbox.pack_end (cancel, false, true, 0);59 bbox.pack_end (cancel, false, true, 0);
56 60
57 email.set_tooltip_text (_("Your email address for relocating your videos"));61 email.set_tooltip_text (_("Your email address for relocating your videos"));
58 upload_button.image = new Image.from_icon_name ("mail-reply-sender", IconSize.BUTTON);62
63 upload_button.image = new Gtk.Image.from_icon_name ("mail-reply-sender", Gtk.IconSize.BUTTON);
59 upload_button.can_default = true;64 upload_button.can_default = true;
65
60 this.set_default (upload_button);66 this.set_default (upload_button);
61 67
62 grid.attach (img, 0, 0, 1, 2);68 grid.attach (img, 0, 0, 1, 2);
63 grid.attach (new LLabel ("Title"), 1, 0, 1, 1);69 grid.attach (new LLabel ("Title"), 1, 0, 1, 1);
64 grid.attach (title, 2, 0, 1, 1);70 grid.attach (title, 2, 0, 1, 1);
@@ -67,55 +73,66 @@
67 grid.attach (new LLabel ("Description"), 1, 2, 1, 1);73 grid.attach (new LLabel ("Description"), 1, 2, 1, 1);
68 grid.attach (description, 2, 2, 1, 1);74 grid.attach (description, 2, 2, 1, 1);
69 grid.attach (bbox, 0, 3, 3, 1);75 grid.attach (bbox, 0, 3, 3, 1);
70 76
71 this.add (grid);77 this.add (grid);
72 this.destroy.connect (Gtk.main_quit);78 this.destroy.connect (Gtk.main_quit);
73 79
74 cancel.clicked.connect (Gtk.main_quit);80 cancel.clicked.connect (Gtk.main_quit);
75 81
76 upload_button.clicked.connect ( () => {82 upload_button.clicked.connect (() => {
77 string url;83 string url;
78 string path = file.get_path() ;84 string path = file.get_path();
79 if( path.has_prefix ("'") && path.has_suffix ("'"))85
80 path = path.substring (1, path.length-2) ;86 if (path.has_prefix ("'") && path.has_suffix ("'"))
81 string command = "curl -F\"api=1\" -F\"videoFile=@"+path+"\" ";87 path = path.substring (1, path.length-2);
88
89 string command = "curl -F\"api=1\" -F\"videoFile=@" + path + "\" ";
90
82 if (email.text != "")91 if (email.text != "")
83 command += "-F\"email="+email.text+"\" ";92 command += "-F\"email=%s\" ".printf (email.text);
93
84 if (title.text != "")94 if (title.text != "")
85 command += "-F\"title="+title.text+"\" ";95 command += "-F\"title=%s\" ".printf (title.text);
96
86 if (description.text != "")97 if (description.text != "")
87 command += "-F\"description="+description.text+"\" ";98 command += "-F\"description=%s\" ".printf (description.text);
99
88 command += "http://videobin.org/add";100 command += "http://videobin.org/add";
89 try{101
102 try {
90 Process.spawn_command_line_sync (command, out url);103 Process.spawn_command_line_sync (command, out url);
91 }catch (Error e){error (e.message);}104 } catch (Error e) {
92 try{105 error (e.message);
93 if( url == null || url == "" ) 106 }
94 {107
95 warning( "The upload has failed. Command: %s", command) ;108 try {
96 }109 if (url == null || url == "") {
97 else110 warning("The upload has failed. Command: %s", command);
98 Process.spawn_command_line_async ("sensible-browser "+url);111 } else {
99 }catch (Error e){error (e.message);}112 Process.spawn_command_line_async ("sensible-browser " + url);
113 }
114 } catch (Error e) {
115 error (e.message);
116 }
117
100 Gtk.main_quit ();118 Gtk.main_quit ();
101 });119 });
102 }120 }
103
104}121}
105122
106public static void main (string [] args){123public static void main (string [] args) {
107 Gtk.init (ref args);124 Gtk.init (ref args);
108 if( args.length<=1) 125
109 {126 if (args.length <= 1) {
110 warning ("You must provide a valid file path" ) ;127 warning ("You must provide a valid file path");
128 } else {
129 var path = args[1];
130 var file = File.new_for_path (path);
131
132 var dialog = new Uploader (file);
133 dialog.show_all ();
134
135 Gtk.main ();
111 }136 }
112 else
113 {
114 var path = args[1] ;
115 var file = File.new_for_path (path);
116 var dialog = new Uploader (file);
117 dialog.show_all ();
118 Gtk.main ();
119 }
120}137}
121138

Subscribers

People subscribed via source and target branches