source: libi4uc/i4ucbottompanel.vala @ 4bb5472a2eb8e6ac900bccd22139a7b37843ef48

Revision 4bb5472a2eb8e6ac900bccd22139a7b37843ef48, 2.3 KB checked in by Matias De la Puente <mfpuente.ar@…>, 3 years ago (diff)

Documents: Move document preferences to side panel

  • Property mode set to 100644
Line 
1/* i4ucbottompanel.vala
2 *
3 * Copyright (C) 2010  Matias De la Puente
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author:
19 *      Matias De la Puente <mfpuente.ar@gmail.com>
20 */
21using Gtk;
22using Gee;
23
24public class I4uc.BottomPanel : Gtk.VBox, PagesPanelIface
25{
26        private Notebook _notebook = new Notebook ();
27        private ArrayList<PageIface> _pages = new ArrayList<PageIface> ();
28        private Page _current_page;
29       
30        public PageIface current_page { get { return _current_page; } }
31       
32        public BottomPanel ()
33        {
34                _notebook.tab_pos = PositionType.BOTTOM;
35                _notebook.switch_page.connect ((panel, page, page_num) => {
36                        _current_page = (_notebook.get_nth_page ((int)page_num) as Page);
37                        this.page_changed (_current_page);
38                });
39                _notebook.page_added.connect ((panel, page, page_num) => {
40                        _pages.add (page as Page);
41                        this.page_added (page as Page);
42                });
43                _notebook.page_removed.connect ((panel, page, page_num) => {
44                        _pages.remove (page as Page);
45                        this.page_removed (page as Page);
46                        if (_notebook.get_n_pages () == 0)
47                        {
48                                _current_page = null;
49                                this.page_changed (_current_page);
50                        }
51                });
52               
53                pack_start (_notebook, true, true, 0);
54        }
55
56        public void add_page (PageIface page)
57        {
58                _notebook.append_page (page as Page, (page as Page).tab_label);
59        }
60       
61        public void insert_page (PageIface page, int position)
62        {
63                _notebook.insert_page (page as Page, (page as Page).tab_label, position);
64        }
65       
66        public void remove_page (PageIface page)
67        {
68                _notebook.remove_page (_notebook.page_num (page as Page));
69        }
70       
71        public void show_page (PageIface page)
72        {
73                _notebook.set_current_page (_notebook.page_num (page as Page));
74                (page as Page).grab_focus ();
75        }
76       
77        public Gee.List<PageIface> list_pages ()
78        {
79                return _pages.read_only_view;
80        }
81}
Note: See TracBrowser for help on using the repository browser.