~elementary-pantheon/switchboard-plug-startup-applications/trunk

« back to all changes in this revision

Viewing changes to src/Widgets/Editor.vala

  • Committer: Julien Spautz
  • Date: 2014-04-05 14:03:46 UTC
  • Revision ID: spautz.julien@gmail.com-20140405140346-w6w51lt3im1a0f4n
remove now unused files, update cmakelists.txt to use gtk+ 3.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***
2
 
    Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
3
 
 
4
 
    This program or library is free software; you can redistribute it
5
 
    and/or modify it under the terms of the GNU Lesser General Public
6
 
    License as published by the Free Software Foundation; either
7
 
    version 3 of the License, or (at your option) any later version.
8
 
 
9
 
    This library is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
 
    Lesser General Public License for more details.
13
 
 
14
 
    You should have received a copy of the GNU Lesser General
15
 
    Public License along with this library; if not, write to the
16
 
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 
    Boston, MA 02110-1301 USA.
18
 
***/
19
 
 
20
 
public class Pantheon.Startup.Widgets.Editor : Gtk.Grid {
21
 
 
22
 
    public string icon { get; set; }
23
 
 
24
 
    public new string name {
25
 
        get { return name_entry.text; }
26
 
        set { name_entry.text = value; }
27
 
    }
28
 
 
29
 
    public string comment {
30
 
        get { return comment_entry.text; }
31
 
        set { comment_entry.text = value; }
32
 
    }
33
 
 
34
 
    public string command {
35
 
        get { return command_entry.text; }
36
 
        set { command_entry.text = value; }
37
 
    }
38
 
    
39
 
    public bool revive {
40
 
        get; set;
41
 
    }
42
 
    
43
 
    Backend.KeyFile key_file;
44
 
    
45
 
    Gtk.Entry name_entry;
46
 
    Gtk.Entry comment_entry;
47
 
    Gtk.Entry command_entry;
48
 
    
49
 
    public Editor () {
50
 
        var name_label = new Gtk.Label (_("Name:"));
51
 
        name_label.halign = Gtk.Align.END;
52
 
        name_entry = new Gtk.Entry ();
53
 
        name_entry.placeholder_text = _("Application name");
54
 
        name_entry.width_request = 300;
55
 
        name_entry.valign = Gtk.Align.END;
56
 
        
57
 
        var comment_label = new Gtk.Label (_("Description:"));
58
 
        comment_label.halign = Gtk.Align.END;
59
 
        comment_entry = new Gtk.Entry ();
60
 
        comment_entry.placeholder_text = _("Short description");
61
 
 
62
 
        var command_label = new Gtk.Label (_("Command:"));
63
 
        command_label.halign = Gtk.Align.END;
64
 
        command_entry = new Gtk.Entry ();
65
 
        command_entry.placeholder_text = _("Command to execute");
66
 
        
67
 
        this.attach (name_label, 0, 0, 1, 1);
68
 
        this.attach (name_entry, 1, 0, 1, 1);
69
 
        this.attach (comment_label, 0, 1, 1, 1);
70
 
        this.attach (comment_entry, 1, 1, 1, 1);
71
 
        this.attach (command_label, 0, 2, 1, 1);
72
 
        this.attach (command_entry, 1, 2, 1, 1);
73
 
        
74
 
        row_spacing = 6;
75
 
        column_spacing = 6;
76
 
        margin = 12;
77
 
        halign = Gtk.Align.CENTER;
78
 
        
79
 
        name_entry.notify["text"].connect (() => {
80
 
            key_file.name = name_entry.text;
81
 
            key_file.write_to_file ();
82
 
        });
83
 
        
84
 
        comment_entry.notify["text"].connect (() => {
85
 
            key_file.comment = comment_entry.text;
86
 
            key_file.write_to_file ();
87
 
        });
88
 
        
89
 
        command_entry.notify["text"].connect (() => {
90
 
            key_file.command = command_entry.text;
91
 
            key_file.write_to_file ();
92
 
        });
93
 
    }
94
 
    
95
 
    public void load_key_file (Backend.KeyFile key_file) {
96
 
        this.key_file = key_file;
97
 
 
98
 
        name_entry.text = key_file.name;
99
 
        comment_entry.text = key_file.comment;
100
 
        command_entry.text = key_file.command;
101
 
    }
102
 
}
 
 
b'\\ No newline at end of file'