~enso-os/+junk/welcome

« back to all changes in this revision

Viewing changes to src/View/FlowBoxItem.vala

  • Committer: Nick Wilkins
  • Date: 2018-04-24 11:14:07 UTC
  • Revision ID: nickawilkins@hotmail.com-20180424111407-scsa09pln2hi0gac
inital commit of welcome

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
/*-
 
3
 * Copyright (c) 2014-2017 elementary LLC. (https://elementary.io)
 
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
 * Authored by: Corentin Noël <corentin@elementary.io>
 
19
 */
 
20
 
 
21
 
 
22
public class Welcome.FlowBoxItem : Gtk.FlowBoxChild {
 
23
    private Gtk.Label name_label;
 
24
    private Gtk.Grid themed_grid;
 
25
    public string s_title;
 
26
    private string s_icon_name;
 
27
 
 
28
    public FlowBoxItem (string title, string icon) {
 
29
                s_title = title;
 
30
        var display_image = new Gtk.Image ();
 
31
        display_image.icon_size = Gtk.IconSize.DIALOG;
 
32
        display_image.valign = Gtk.Align.CENTER;
 
33
        display_image.halign = Gtk.Align.END;
 
34
        display_image.margin_end = 12;
 
35
 
 
36
        name_label = new Gtk.Label (null);
 
37
        name_label.wrap = true;
 
38
        //name_label.max_width_chars = 5;
 
39
 
 
40
        var grid = new Gtk.Grid ();
 
41
        grid.orientation = Gtk.Orientation.HORIZONTAL;
 
42
        //grid.column_spacing = 6;
 
43
        grid.halign = Gtk.Align.CENTER;
 
44
        grid.valign = Gtk.Align.CENTER;
 
45
        //grid.margin_top = 32;
 
46
        grid.margin_end = 16;
 
47
        //grid.margin_bottom = 32;
 
48
        grid.margin_start = 16;
 
49
        grid.add (display_image);
 
50
        grid.add (name_label);
 
51
 
 
52
        var expanded_grid = new Gtk.Grid ();
 
53
        expanded_grid.expand = true;
 
54
        expanded_grid.margin = 12;
 
55
 
 
56
        themed_grid = new Gtk.Grid ();
 
57
        themed_grid.get_style_context ().add_class ("options");
 
58
        themed_grid.attach (grid, 0, 0, 1, 1);
 
59
        themed_grid.attach (expanded_grid, 0, 0, 1, 1);
 
60
        themed_grid.margin = 5;
 
61
 
 
62
        child = themed_grid;
 
63
 
 
64
        //tooltip_text = app_category.summary ?? "";
 
65
        
 
66
                display_image.icon_name = icon;
 
67
                ((Gtk.Misc) name_label).xalign = 0;
 
68
                name_label.halign = Gtk.Align.START;
 
69
                name_label.label = title;
 
70
                
 
71
        /*} else {
 
72
            display_image.destroy ();
 
73
            name_label.justify = Gtk.Justification.CENTER;
 
74
        }*/
 
75
 
 
76
        show_all ();
 
77
    }
 
78
 
 
79
    construct {
 
80
        
 
81
    }
 
82
}