~elementary-apps/pantheon-mail/native-load-more

« back to all changes in this revision

Viewing changes to src/client/components/main-window.vala

  • Committer: RabbitBot
  • Author(s): Daniel Foré
  • Date: 2016-02-23 16:09:00 UTC
  • mfrom: (1978.1.2 pantheon-mail)
  • Revision ID: rabbitbot-20160223160900-10z6na3iqhdvv9bj
Main Window:
* Always pack statusbar with the folder list
* Remove extra boxes
* Use vala-style properties
* Move main toolbar to the layout creation method

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 */
6
6
 
7
7
public class MainWindow : Gtk.ApplicationWindow {
8
 
    private const int MESSAGE_LIST_WIDTH = 250;
9
 
    private const int FOLDER_LIST_WIDTH = 100;
10
8
    private const int STATUS_BAR_HEIGHT = 18;
11
9
 
12
10
    /// Fired when the shift key is pressed or released.
29
27
 
30
28
    private Gtk.ScrolledWindow conversation_list_scrolled;
31
29
    private MonitoredSpinner spinner = new MonitoredSpinner();
32
 
    private Gtk.Box folder_box;
33
 
    private Gtk.Box conversation_box;
34
30
    private Geary.AggregateProgressMonitor progress_monitor = new Geary.AggregateProgressMonitor();
35
31
    private Geary.ProgressMonitor? conversation_monitor_progress = null;
36
32
    private Geary.ProgressMonitor? folder_progress = null;
82
78
        Geary.Engine.instance.account_available.connect(on_account_available);
83
79
        Geary.Engine.instance.account_unavailable.connect(on_account_unavailable);
84
80
 
85
 
        // Toolbar.
86
 
        main_toolbar = new MainToolbar();
87
 
        main_toolbar.show_close_button = true;
88
 
        set_titlebar(main_toolbar);
89
 
        title = GearyApplication.NAME;
90
 
 
91
81
        create_layout();
92
82
        on_change_orientation();
93
83
    }
137
127
        return base.window_state_event(event);
138
128
    }
139
129
 
140
 
    private void create_layout() {
141
 
        Gtk.Box main_layout = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
 
130
    private void create_layout () {
 
131
        main_toolbar = new MainToolbar ();
 
132
        main_toolbar.show_close_button = true;
 
133
        set_titlebar (main_toolbar);
 
134
        title = GearyApplication.NAME;
142
135
 
143
136
        // folder list
144
 
        Gtk.ScrolledWindow folder_list_scrolled = new Gtk.ScrolledWindow(null, null);
145
 
        folder_list_scrolled.set_size_request(FOLDER_LIST_WIDTH, -1);
146
 
        folder_list_scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
147
 
        folder_list_scrolled.add(folder_list);
148
 
        folder_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
149
 
        folder_box.get_style_context().add_class(Gtk.STYLE_CLASS_SIDEBAR);
150
 
        folder_box.pack_start(folder_list_scrolled, true, true);
 
137
        Gtk.ScrolledWindow folder_list_scrolled = new Gtk.ScrolledWindow (null, null);
 
138
        folder_list_scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;
 
139
        folder_list_scrolled.width_request = 100;
 
140
        folder_list_scrolled.add (folder_list);
 
141
 
 
142
        spinner.height_request = STATUS_BAR_HEIGHT - 2;
 
143
 
 
144
        status_bar.height_request = STATUS_BAR_HEIGHT;
 
145
        status_bar.margin = 3;
 
146
        status_bar.add (spinner);
 
147
 
 
148
        Gtk.Box folder_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
 
149
        folder_box.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
 
150
        folder_box.pack_start (folder_list_scrolled, true, true);
 
151
        folder_box.pack_start (status_bar, false, false);
151
152
 
152
153
        // message list
153
 
        conversation_list_scrolled = new Gtk.ScrolledWindow(null, null);
154
 
        conversation_list_scrolled.set_size_request(MESSAGE_LIST_WIDTH, -1);
155
 
        conversation_list_scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
156
 
        conversation_list_scrolled.add(conversation_list_view);
157
 
        conversation_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
158
 
        conversation_box.pack_start(conversation_list_scrolled, true, true);
159
 
 
160
 
        // Three-pane display.
161
 
        status_bar.set_size_request(-1, STATUS_BAR_HEIGHT);
162
 
        status_bar.set_border_width(2);
163
 
        spinner.set_size_request(STATUS_BAR_HEIGHT - 2, -1);
164
 
        status_bar.add(spinner);
 
154
        conversation_list_scrolled = new Gtk.ScrolledWindow (null, null);
 
155
        conversation_list_scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;
 
156
        conversation_list_scrolled.width_request = 250;
 
157
        conversation_list_scrolled.add (conversation_list_view);
165
158
 
166
159
        // Folder list to the left of everything.
167
 
        folder_paned.pack1(folder_box, false, false);
168
 
        folder_paned.pack2(conversation_box, true, false);
 
160
        folder_paned.pack1 (folder_box, false, false);
 
161
        folder_paned.pack2 (conversation_list_scrolled, true, false);
169
162
 
170
163
        // Message list left of message viewer.
171
 
        conversations_paned.pack1(folder_paned, true, false);
172
 
        conversations_paned.pack2(conversation_viewer, true, true);
173
 
 
174
 
        main_layout.pack_end(conversations_paned, true, true, 0);
175
 
 
176
 
        add(main_layout);
 
164
        conversations_paned.pack1 (folder_paned, true, false);
 
165
        conversations_paned.pack2 (conversation_viewer, true, true);
 
166
        conversations_paned.expand = true;
 
167
 
 
168
        add (conversations_paned);
177
169
    }
178
170
 
179
171
    // Returns true when there's a conversation list scrollbar visible, i.e. the list is tall
260
252
 
261
253
    private void on_change_orientation() {
262
254
        bool horizontal = GearyApplication.instance.config.folder_list_pane_horizontal;
263
 
        bool initial = true;
264
 
 
265
 
        if (status_bar.parent != null) {
266
 
            status_bar.parent.remove(status_bar);
267
 
            initial = false;
268
 
        }
269
255
 
270
256
        GLib.Settings.unbind(folder_paned, "position");
271
 
        folder_paned.orientation = horizontal ? Gtk.Orientation.HORIZONTAL :
272
 
            Gtk.Orientation.VERTICAL;
273
 
 
274
 
        int folder_list_width =
275
 
            GearyApplication.instance.config.folder_list_pane_position_horizontal;
276
 
        if (horizontal) {
277
 
            if (!initial)
278
 
                conversations_paned.position += folder_list_width;
279
 
            folder_box.pack_start(status_bar, false, false);
280
 
        } else {
281
 
            if (!initial)
282
 
                conversations_paned.position -= folder_list_width;
283
 
            conversation_box.pack_start(status_bar, false, false);
284
 
        }
 
257
        folder_paned.orientation = horizontal ? Gtk.Orientation.HORIZONTAL : Gtk.Orientation.VERTICAL;
285
258
 
286
259
        GearyApplication.instance.config.bind(
287
260
            horizontal ? Configuration.FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY
288
 
            : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
289
 
            folder_paned, "position");
 
261
            : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY, folder_paned, "position");
290
262
    }
291
263
}
292
264