source: gtkfrontend/utils.vala @ dfe49c76fe79c726339d9cad8d91dc6242eb2959

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

Another massive code rework

+ Models, presenters and view interfaces were moved from libi4uc to libi4uccore.
+ Models, presenters and view interfaces are now in I4uc.Core namespace.
+ Views were moved from libi4uc to gtkfrontend.
+ Views are now in I4uc.GtkFrontend? namespace.
+ src/main.vala was moved to gtksourceview.
+ All the 'i4uc' prefix in source files were removed.
+ Presenters were renamed to Logic (It's shorter).
+ View interfaces were renamed to just View.
+ Side pages are now just pages.

  • 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 const string[] stock_items =
27        {
28                STOCK_EXECUTE,
29                STOCK_DIALOG_ERROR,
30                STOCK_FILE,
31                STOCK_NEW,
32                STOCK_MISSING_IMAGE,
33                "i4uc-programmer-icon",
34                STOCK_DIALOG_WARNING
35        };
36       
37        public HBox create_hbox (string title, SizeGroup size_group, VBox vbox)
38        {
39                var hbox = new HBox (false, 0);
40                var label = new Label (title);
41                label.xalign = 1;
42                size_group.add_widget (label);
43               
44                hbox.pack_start (label, false, false, 5);
45                vbox.pack_start (hbox, false, false, 5);
46
47                return hbox;
48        }
49       
50        public Button create_close_button ()
51        {
52                var close_button = new Button ();
53                close_button.relief = ReliefStyle.NONE;
54                close_button.focus_on_click = false;
55                var style = new RcStyle ();
56                style.xthickness = style.ythickness = 0;
57                close_button.modify_style (style);
58                close_button.add (new Image.from_stock (Gtk.STOCK_CLOSE, IconSize.MENU));
59                return close_button;
60        }
61       
62        public void add_vbox_label (VBox vbox, string label_text, Widget widget)
63        {
64                var label = new Label (label_text);
65                label.xalign = 0;
66                vbox.pack_start (label, false, false, 0);
67                vbox.pack_start (widget, false, false, 0);
68        }
69       
70        public I4uc.Core.TabImage get_tab_image_from_stock_item (string stock_item)
71        {
72                int i = 0;
73                foreach (var item in stock_items)
74                {
75                        if (item == stock_item)
76                                return (I4uc.Core.TabImage)i;
77                        i++;
78                }
79                return I4uc.Core.TabImage.NONE;
80        }
81       
82        public I4uc.Core.PagePosition to_page_position (PositionType position_type)
83        {
84                var page_position = I4uc.Core.PagePosition.TOP;
85                switch (position_type)
86                {
87                        case PositionType.BOTTOM: page_position = I4uc.Core.PagePosition.BOTTOM; break;
88                        case PositionType.LEFT: page_position = I4uc.Core.PagePosition.LEFT; break;
89                        case PositionType.RIGHT: page_position = I4uc.Core.PagePosition.RIGHT; break;
90                        case PositionType.TOP: page_position = I4uc.Core.PagePosition.TOP; break;
91                }
92                return page_position;
93        }
94       
95        public PositionType from_page_position (I4uc.Core.PagePosition page_position)
96        {
97                var position_type = PositionType.TOP;
98                switch (page_position)
99                {
100                        case I4uc.Core.PagePosition.BOTTOM: position_type = PositionType.BOTTOM; break;
101                        case I4uc.Core.PagePosition.LEFT: position_type = PositionType.LEFT; break;
102                        case I4uc.Core.PagePosition.RIGHT: position_type = PositionType.RIGHT; break;
103                        case I4uc.Core.PagePosition.TOP: position_type = PositionType.TOP; break;
104                }
105                return position_type;
106        }
107}
Note: See TracBrowser for help on using the repository browser.