Merge lp:~ken-vandine/gwibber/status_bar into lp:gwibber

Proposed by Ken VanDine
Status: Merged
Merged at revision: 1279
Proposed branch: lp:~ken-vandine/gwibber/status_bar
Merge into: lp:gwibber
Diff against target: 166 lines (+127/-0)
3 files modified
client/Makefile.am (+1/-0)
client/gwibber-client.vala (+33/-0)
client/status-bar.vala (+93/-0)
To merge this branch: bzr merge lp:~ken-vandine/gwibber/status_bar
Reviewer Review Type Date Requested Status
David Klasinc (community) Approve
Review via email: mp+93336@code.launchpad.net

Description of the change

Adds new StatusBar widget.

To post a comment you must log in.
Revision history for this message
David Klasinc (bigwhale) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/Makefile.am'
2--- client/Makefile.am 2011-08-30 17:57:21 +0000
3+++ client/Makefile.am 2012-02-16 06:09:17 +0000
4@@ -16,6 +16,7 @@
5 public-item.vala \
6 messages-item.vala \
7 stream-entry.vala \
8+ status-bar.vala \
9 tab-bar.vala \
10 tab-bar-item.vala \
11 tab-bar-widgets.vala
12
13=== modified file 'client/gwibber-client.vala'
14--- client/gwibber-client.vala 2012-02-13 22:20:12 +0000
15+++ client/gwibber-client.vala 2012-02-16 06:09:17 +0000
16@@ -19,12 +19,14 @@
17 public class Client : Gtk.Window
18 {
19 private Gwibber.Streams streams_service;
20+ private Gwibber.Service _service;
21 private GLib.Settings state_settings;
22 public Gee.HashMap <string, Dee.Model?> streams_map;
23 public Gee.HashMap <string, TabBarItem?> items_map;
24 public TabBar tabbar;
25 public GwibberGtk.StreamView view;
26 public Gtk.UIManager manager;
27+ private StatusBar _status_bar;
28 private int _sort_order = 1;
29
30 public int sort_order {
31@@ -87,6 +89,37 @@
32 tabbar = new TabBar ();
33
34 var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
35+
36+ _status_bar = new StatusBar ();
37+ /* We don't need this yet
38+ _status_bar.add_button (Gtk.Stock.OK, Gtk.ResponseType.OK);
39+ _status_bar.response.connect((r) => {
40+ _status_bar.showing = false;
41+ });
42+ */
43+ main_box.pack_end (_status_bar, false, false, 0);
44+ _status_bar.notify["showing"].connect (()=>
45+ {
46+ debug ("StatusBar showing changed");
47+ });
48+
49+ _service = new Gwibber.Service ();
50+ _service.loading_started.connect((source) => {
51+ debug ("Loading started");
52+ if (!_status_bar.showing)
53+ {
54+ _status_bar.reset ();
55+ _status_bar.set_message_type (Gtk.MessageType.OTHER);
56+ _status_bar.message = _("Refreshing");
57+ _status_bar.showing = true;
58+ }
59+ });
60+ _service.loading_complete.connect((source) => {
61+ debug ("Loading completed");
62+ if (_status_bar.showing)
63+ _status_bar.showing = false;
64+ });
65+
66 main_box.pack_end (tabbar, true, true, 0);
67 add (main_box);
68
69
70=== added file 'client/status-bar.vala'
71--- client/status-bar.vala 1970-01-01 00:00:00 +0000
72+++ client/status-bar.vala 2012-02-16 06:09:17 +0000
73@@ -0,0 +1,93 @@
74+/*
75+ * Copyright (C) 2011 Canonical Ltd.
76+ *
77+ * This program is free software: you can redistribute it and/or modify it
78+ * under the terms of the GNU General Public License version 3, as published
79+ * by the Free Software Foundation.
80+ *
81+ * This program is distributed in the hope that it will be useful, but
82+ * WITHOUT ANY WARRANTY; without even the implied warranties of
83+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
84+ * PURPOSE. See the GNU General Public License for more details.
85+ *
86+ * You should have received a copy of the GNU General Public License along
87+ * with this program. If not, see <http://www.gnu.org/licenses/>.
88+ *
89+ * Authored by Ken VanDine <ken@vandine.org>
90+ */
91+
92+public class StatusBar : Gtk.InfoBar
93+{
94+ private string _message;
95+ private Gtk.Label _message_label;
96+ private Gtk.Container _content_area;
97+
98+ private Gwibber.Service _service;
99+
100+ private bool _showing = false;
101+
102+ public bool showing {
103+ get {
104+ return _showing;
105+ }
106+ set {
107+ _showing = value;
108+ if (_showing)
109+ {
110+ show ();
111+ queue_draw ();
112+ }
113+ else
114+ {
115+ hide ();
116+ queue_draw ();
117+ }
118+ }
119+ }
120+
121+ public string message {
122+ get {
123+ return _message;
124+ }
125+ set {
126+ if (_message != value)
127+ {
128+ _message = value;
129+ _message_label.set_markup ("<b>" + _message + "</b>");
130+ }
131+ }
132+ }
133+
134+ public StatusBar ()
135+ {
136+ Object ();
137+ }
138+
139+ construct
140+ {
141+ _message = "";
142+ set_no_show_all (true);
143+ set_message_type (Gtk.MessageType.OTHER);
144+ _content_area = get_content_area () as Gtk.Container;
145+ _message_label = new Gtk.Label (message);
146+ _message_label.set_alignment (0.0f, 0.5f);
147+ _message_label.set_use_markup (true);
148+ _content_area.add (_message_label);
149+ _message_label.show ();
150+
151+ notify["showing"].connect (()=>
152+ {
153+ });
154+ }
155+
156+ public void reset ()
157+ {
158+ message = "";
159+ var _action_area = get_action_area () as Gtk.Container;
160+ foreach (var _w in _action_area.get_children ())
161+ {
162+ if (_w is Gtk.Widget)
163+ _w.destroy ();
164+ }
165+ }
166+}