~jeremywootten/pantheon-files/fix-1604300-merge-find-functionalities-part2

« back to all changes in this revision

Viewing changes to src/View/Widgets/PermissionButton.vala

  • Committer: RabbitBot
  • Author(s): Daniel Foré
  • Date: 2016-12-23 19:26:49 UTC
  • mfrom: (2407.1.1 pantheon-files)
  • Revision ID: rabbitbot-20161223192649-v3gsod24nl31bkqy
PropertiesWindow.vala:
* Name the permission buttons so we don't have to do janky get stuff to use them
* organize construct_perm_panel
* use keylabel
* Reduce three similar methods to permission_button_toggle

Add Widgets/PermissionButton.vala

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* Copyright (c) 2016 elementary LLC. (http://launchpad.net/pantheon-files)
 
3
*
 
4
* This program is free software; you can redistribute it and/or
 
5
* modify it under the terms of the GNU General Public
 
6
* License as published by the Free Software Foundation; either
 
7
* version 2 of the License, or (at your option) any later version.
 
8
*
 
9
* This program 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
* General Public License for more details.
 
13
*
 
14
* You should have received a copy of the GNU General Public
 
15
* License along with this program; if not, write to the
 
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
* Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
public class PermissionButton : Gtk.Box {
 
21
    public Gtk.ToggleButton btn_read;
 
22
    public Gtk.ToggleButton btn_write;
 
23
    public Gtk.ToggleButton btn_exe;
 
24
 
 
25
    public Marlin.View.PropertiesWindow.PermissionType permission_type { get; construct; }
 
26
 
 
27
    public enum Value {
 
28
        READ,
 
29
        WRITE,
 
30
        EXE
 
31
    }
 
32
 
 
33
    public PermissionButton (Marlin.View.PropertiesWindow.PermissionType permission_type) {
 
34
        Object (permission_type: permission_type);
 
35
    }
 
36
 
 
37
    construct {
 
38
        btn_read = new Gtk.ToggleButton.with_label (_("Read"));
 
39
        btn_read.set_data ("permissiontype", permission_type);
 
40
        btn_read.set_data ("permissionvalue", Value.READ);
 
41
 
 
42
        btn_write = new Gtk.ToggleButton.with_label (_("Write"));
 
43
        btn_write.set_data ("permissiontype", permission_type);
 
44
        btn_write.set_data ("permissionvalue", Value.WRITE);
 
45
 
 
46
        btn_exe = new Gtk.ToggleButton.with_label (_("Execute"));
 
47
        btn_exe.set_data ("permissiontype", permission_type);
 
48
        btn_exe.set_data ("permissionvalue", Value.EXE);
 
49
 
 
50
        homogeneous = true;
 
51
        get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED);
 
52
        add (btn_read);
 
53
        add (btn_write);
 
54
        add (btn_exe);
 
55
    }
 
56
}