~fabiozaramella/eidete/eidete

« back to all changes in this revision

Viewing changes to src/Widgets/end_dialog.vala

  • Committer: Tom Beckmann
  • Date: 2011-12-30 00:26:42 UTC
  • Revision ID: tombeckmann@online.de-20111230002642-5y3jy4zrrqnfaju4
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using Gtk;
 
2
 
 
3
 
 
4
namespace Eidete.Widgets {
 
5
        
 
6
        public class EndDialog : Window {
 
7
                public EndDialog (EideteApp app){
 
8
                        var grid = new Grid ();
 
9
                        grid.margin = 12;
 
10
                        
 
11
                        var title = new Label ("<span size='30000'>Recording done</span>");
 
12
                        title.use_markup = true;
 
13
                        title.halign = Align.START;
 
14
                        var sub_title = new Label ("<span size='15000'>And now?</span>");
 
15
                        sub_title.use_markup = true;
 
16
                        sub_title.halign = Align.START;
 
17
                        
 
18
                        var save = new Button.from_stock (Stock.SAVE);
 
19
                        save.set_halign (Align.END);
 
20
                        
 
21
                        var trash = new Button.with_label ("Trash it");
 
22
                        trash.image = new Image.from_stock (Stock.DELETE, IconSize.BUTTON);
 
23
                        trash.set_halign (Align.START);
 
24
                        
 
25
                        grid.attach (title, 0, 0, 2, 1);
 
26
                        grid.attach (sub_title, 0, 1, 2, 1);
 
27
                        grid.attach (new Label (""), 0, 2, 1, 1);
 
28
                        grid.attach (save, 0, 3, 1, 1);
 
29
                        grid.attach (trash, 1, 3, 1, 1);
 
30
                        
 
31
                        
 
32
                        save.clicked.connect ( () => {
 
33
                                var filter = new FileFilter ();
 
34
                                filter.add_mime_type ("video/webm");
 
35
                                var file = new FileChooserDialog ("Choose destination", this, 
 
36
                                     FileChooserAction.SAVE, Stock.CANCEL, ResponseType.CANCEL, Stock.OK, ResponseType.OK);
 
37
                                file.filter = filter;
 
38
                                file.do_overwrite_confirmation = true;
 
39
                                file.set_current_name ("Untitled.webm");
 
40
                                var res = file.run ();
 
41
                                if (res == ResponseType.OK){
 
42
                                        this.save (app.settings.destination, file.get_filename ());
 
43
                                        file.destroy ();
 
44
                                        this.destroy ();
 
45
                                }else{
 
46
                                        file.destroy ();
 
47
                                }
 
48
                        });
 
49
                        
 
50
                        trash.clicked.connect ( () => {this.destroy ();});
 
51
                        
 
52
                        this.add (grid);
 
53
                        this.destroy.connect (Gtk.main_quit);
 
54
                }
 
55
                
 
56
                
 
57
                private void save (string tmp, string dest){
 
58
                        var source      = File.new_for_path (tmp);
 
59
                        var destination = File.new_for_path (dest);
 
60
                        try{
 
61
                                source.copy (destination, FileCopyFlags.NONE);
 
62
                        }catch (GLib.Error e){stderr.printf ("Error: %s\n", e.message);}
 
63
                }
 
64
        }
 
65
        
 
66
}
 
67
 
 
68