/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/preferences_ui.js

  • Committer: Gustav Hartvigsson
  • Date: 2014-06-13 21:51:09 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140613215109-1o4421hhbm8ztbei
* Changes a thing in the about dialoug.
* Changed the style of the close button in the prefs dialoug.
* Added, for future use, style.js...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of GPump, a Pump.io client.
 
2
 *
 
3
 * GPump (THE SOFTWARE) is made available under the terms and conditions of the
 
4
 * GNU Lesser General Public Licence 3.0. A copy of the licence can be read
 
5
 * in the file lgpl-3.0.txt in the root of this project.
 
6
 */
 
7
 
 
8
const Gtk = imports.gi.Gtk;
 
9
const Lang = imports.lang;
 
10
const _ = imports.gettext.gettext;
 
11
 
 
12
const SettingsData = imports.settings_data;
 
13
 
 
14
const PreferencesUI = Lang.Class ({
 
15
  Name: "PrefrencesUI",
 
16
  Extends: Gtk.Dialog,
 
17
  
 
18
  _init: function () {
 
19
    this.parent ({
 
20
      use_header_bar: true,
 
21
      modal: true,
 
22
      title: _("GPump preferences")
 
23
    });
 
24
    
 
25
    this._prepare_header_bar ();
 
26
    this._prepare_list_box ();
 
27
    
 
28
    this.set_property ('resizable', false);
 
29
    
 
30
    this.show_all ();
 
31
  },
 
32
  
 
33
  _prepare_header_bar: function () {
 
34
    
 
35
    this.headerbar = this.get_header_bar ();
 
36
    this.headerbar.set_show_close_button (false);
 
37
    this.headerbar.pack_end ((this.close_btn = new Gtk.Button ({
 
38
      label: _("close")
 
39
    })));
 
40
    
 
41
    /* Install a custom style */
 
42
    let special_btn_style_ctx = this.close_btn.get_style_context ();
 
43
    special_btn_style_ctx.add_class ("suggested-action");
 
44
    
 
45
    this.close_btn.connect ('clicked', Lang.bind (this, function () {
 
46
      this.destroy ();
 
47
    }));
 
48
    
 
49
  },
 
50
  
 
51
  _prepare_list_box: function () {
 
52
    /*this.get_content_area ().pack_start ()),
 
53
                                         true, true, 25);*/
 
54
    this.get_content_area ().set_center_widget (
 
55
                                          (this.list_box = new Gtk.ListBox ({
 
56
      width_request: 400,
 
57
      margin: 50,
 
58
      selection_mode: Gtk.SelectionMode.NONE
 
59
    })));
 
60
    
 
61
    let settings_object = SettingsData.get_settings ();
 
62
    
 
63
    /*************************** Use dark setting *****************************/
 
64
    let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
 
65
    
 
66
    this.use_dark_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
 
67
    
 
68
    this.list_box.add (this.use_dark_hbox);
 
69
    
 
70
    this.use_dark_hbox.pack_start ((new Gtk.Label ({
 
71
                                                     label: _("Use dark theme")
 
72
                                                   })),
 
73
                                   false, false, 3);
 
74
    this.use_dark_hbox.pack_end ((this.use_dark_reset =
 
75
                                 new Gtk.Button ({
 
76
                                   image: edit_clear_icon})),
 
77
                                 false, false, 3);
 
78
    this.use_dark_hbox.pack_end ((this.use_dark_switch = new Gtk.Switch ()),
 
79
                                 false, false, 3);
 
80
    
 
81
    this.use_dark_switch.set_active (
 
82
      settings_object.get_setting("main.use_dark").data
 
83
    );
 
84
    
 
85
    /*************************** Privacy settings *****************************/
 
86
    this.list_box.add ((new Gtk.Label ({label: _("Privacy settings")})));
 
87
    
 
88
    /************************ show full name setting **************************/
 
89
    let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
 
90
    
 
91
    this.show_full_name_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
 
92
    
 
93
    this.list_box.add (this.show_full_name_hbox);
 
94
    
 
95
    this.show_full_name_hbox.pack_start ((new Gtk.Label ({
 
96
                                                     label: _("Show full name")
 
97
                                                   })),
 
98
                                   false, false, 3);
 
99
    this.show_full_name_hbox.pack_end ((this.show_full_name_reset =
 
100
                                 new Gtk.Button ({
 
101
                                   image: edit_clear_icon})),
 
102
                                 false, false, 3);
 
103
    this.show_full_name_hbox.pack_end (
 
104
                               (this.show_full_name_switch = new Gtk.Switch ()),
 
105
                                 false, false, 3);
 
106
    this.show_full_name_switch.set_active (
 
107
      settings_object.get_setting ("main.privacy.show_full_name").data
 
108
    );
 
109
    
 
110
    /*********************** only show avatar setting **************************/
 
111
    let edit_clear_icon = new Gtk.Image ({icon_name: 'edit-clear'});
 
112
    
 
113
    this.only_show_avatar_hbox = Gtk.Box.new (Gtk.Orientation.HORIZONTAL, 5);
 
114
    
 
115
    this.list_box.add (this.only_show_avatar_hbox);
 
116
    
 
117
    this.only_show_avatar_hbox.pack_start ((new Gtk.Label ({
 
118
                                                    label: _("Only show avatar")
 
119
                                                   })),
 
120
                                   false, false, 3);
 
121
    this.only_show_avatar_hbox.pack_end ((this.only_show_avatar_reset =
 
122
                                 new Gtk.Button ({
 
123
                                   image: edit_clear_icon})),
 
124
                                 false, false, 3);
 
125
    this.only_show_avatar_hbox.pack_end (
 
126
                             (this.only_show_avatar_switch = new Gtk.Switch ()),
 
127
                                 false, false, 3);
 
128
    this.only_show_avatar_switch.set_active (
 
129
      settings_object.get_setting ("main.privacy.only_show_avatar").data
 
130
    );
 
131
    
 
132
    /* Spacer */
 
133
    //this.list_box.add ((new Gtk.Label ()));
 
134
    
 
135
    /* Reset all settings */
 
136
    this.list_box.add ((this.reset_all_btn = new Gtk.Button ({
 
137
      label: _("Reset all settings"),
 
138
      margin_left: 50,
 
139
      margin_right: 50,
 
140
      margin_top: 20
 
141
    })));
 
142
  }
 
143
  
 
144
  
 
145
});