~elementary-apps/cable/pastebin

« back to all changes in this revision

Viewing changes to src/Widgets/TopicBar.vala

  • Committer: eduardgotwig at gmail
  • Author(s): Julien Spautz
  • Date: 2013-08-12 16:44:37 UTC
  • mfrom: (79.1.37 model-view)
  • Revision ID: eduardgotwig@gmail.com-20130812164437-wlojp66wpptckn96
Merged  lp:~julien-spautz/cable/model-view 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***
 
2
    Copyright (C) 2013 Cable Developers
 
3
 
 
4
    This program or library is free software; you can redistribute it
 
5
    and/or modify it under the terms of the GNU Lesser General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 3 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
12
    Lesser General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Lesser General
 
15
    Public License along with this library; if not, write to the
 
16
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301 USA.
 
18
***/
 
19
 
 
20
public class Cable.Widgets.Topic : Gtk.InfoBar {
 
21
 
 
22
    /**
 
23
     * The actual topic.
 
24
     */
 
25
    public string topic {
 
26
       get { return topic_label.label; }
 
27
       set {
 
28
            if (value != "") {
 
29
                var new_topic = Utils.parse_string_to_markup (value);
 
30
                topic_label.set_markup (new_topic);
 
31
                topic_label.set_tooltip_text (new_topic);
 
32
                no_show_all = false;
 
33
                show_all ();
 
34
            } else {
 
35
                visible = false;
 
36
                no_show_all = true;
 
37
            }
 
38
       }
 
39
    }
 
40
    
 
41
    Gtk.Button arrow_button;
 
42
    Gtk.Arrow arrow;
 
43
    Gtk.Label topic_label;
 
44
    Gtk.Grid grid; 
 
45
        
 
46
    public Topic () {
 
47
        arrow_button = new Gtk.Button ();
 
48
        arrow = new Gtk.Arrow (Gtk.ArrowType.RIGHT, Gtk.ShadowType.ETCHED_IN);
 
49
        arrow_button.valign = Gtk.Align.START;
 
50
        arrow_button.relief = Gtk.ReliefStyle.NONE;
 
51
        arrow_button.add (arrow);
 
52
        
 
53
        topic_label = new Gtk.Label ("");
 
54
        topic_label.hexpand = true;
 
55
        topic_label.margin_left = 12;
 
56
        topic_label.margin_right = 12;
 
57
        topic_label.ellipsize = Pango.EllipsizeMode.END;
 
58
        topic_label.wrap_mode = Pango.WrapMode.WORD;
 
59
        
 
60
        grid = new Gtk.Grid ();
 
61
        grid.attach (arrow_button, 0, 0, 1, 1);
 
62
        grid.attach (topic_label, 1, 0, 1, 1);
 
63
 
 
64
        (get_content_area () as Gtk.Container).add (grid);
 
65
        no_show_all = true;
 
66
        
 
67
        arrow_button.clicked.connect (() => {
 
68
            topic_label.wrap = !topic_label.wrap;
 
69
            arrow.arrow_type = (topic_label.wrap) ? Gtk.ArrowType.DOWN : Gtk.ArrowType.RIGHT;
 
70
        });
 
71
    }
 
72
}