source: gtkfrontend/utils.vala @ ca7bf5bd0f7f4c5cb982e2f0ef47984754733854

Revision ca7bf5bd0f7f4c5cb982e2f0ef47984754733854, 2.7 KB checked in by Matias De la Puente <mfpuente.ar@…>, 2 years ago (diff)

GtkFrontend?: Move 'tab images' from Utils to TabImages?

  • Property mode set to 100644
Line 
1/* utils.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
24namespace I4uc.GtkFrontend.Utils
25{
26        public HBox create_hbox (string title, SizeGroup size_group, VBox vbox)
27        {
28                var hbox = new HBox (false, 0);
29                var label = new Label (title);
30                label.xalign = 1;
31                size_group.add_widget (label);
32               
33                hbox.pack_start (label, false, false, 5);
34                vbox.pack_start (hbox, false, false, 5);
35
36                return hbox;
37        }
38       
39        public Button create_close_button ()
40        {
41                var close_button = new Button ();
42                close_button.relief = ReliefStyle.NONE;
43                close_button.focus_on_click = false;
44                var style = new RcStyle ();
45                style.xthickness = style.ythickness = 0;
46                close_button.modify_style (style);
47                close_button.add (new Image.from_stock (Gtk.STOCK_CLOSE, IconSize.MENU));
48                return close_button;
49        }
50       
51        public void add_vbox_label (VBox vbox, string label_text, Widget widget)
52        {
53                var label = new Label (label_text);
54                label.xalign = 0;
55                vbox.pack_start (label, false, false, 0);
56                vbox.pack_start (widget, false, false, 0);
57        }
58       
59        public I4uc.Core.PagePosition to_page_position (PositionType position_type)
60        {
61                var page_position = I4uc.Core.PagePosition.TOP;
62                switch (position_type)
63                {
64                        case PositionType.BOTTOM: page_position = I4uc.Core.PagePosition.BOTTOM; break;
65                        case PositionType.LEFT: page_position = I4uc.Core.PagePosition.LEFT; break;
66                        case PositionType.RIGHT: page_position = I4uc.Core.PagePosition.RIGHT; break;
67                        case PositionType.TOP: page_position = I4uc.Core.PagePosition.TOP; break;
68                }
69                return page_position;
70        }
71       
72        public PositionType from_page_position (I4uc.Core.PagePosition page_position)
73        {
74                var position_type = PositionType.TOP;
75                switch (page_position)
76                {
77                        case I4uc.Core.PagePosition.BOTTOM: position_type = PositionType.BOTTOM; break;
78                        case I4uc.Core.PagePosition.LEFT: position_type = PositionType.LEFT; break;
79                        case I4uc.Core.PagePosition.RIGHT: position_type = PositionType.RIGHT; break;
80                        case I4uc.Core.PagePosition.TOP: position_type = PositionType.TOP; break;
81                }
82                return position_type;
83        }
84}
Note: See TracBrowser for help on using the repository browser.