1 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
3 // This file is part of CenterIM.
5 // CenterIM 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 2 of the License, or
8 // (at your option) any later version.
10 // CenterIM 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.
15 // You should have received a copy of the GNU General Public License
16 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
23 #include <cppconsui/HorizontalListBox.h>
24 #include <cppconsui/Label.h>
25 #include <cppconsui/Window.h>
26 #include <libpurple/purple.h>
29 #define HEADER (Header::instance())
31 // Top "head"-area of the screen.
32 class Header
: public CppConsUI::Window
{
34 static Header
*instance();
37 virtual void onScreenResized() override
;
40 typedef std::multiset
<std::string
> ProtocolCount
;
41 typedef std::map
<PurpleAccount
*, CppConsUI::Label
*> Statuses
;
43 CppConsUI::HorizontalListBox
*container_
;
44 CppConsUI::Label
*request_indicator_
;
45 ProtocolCount protocol_count_
;
48 static Header
*my_instance_
;
51 virtual ~Header() override
;
52 CONSUI_DISABLE_COPY(Header
);
55 static void finalize();
56 friend class CenterIM
;
58 // Signal from the Accounts singleton.
59 void onRequestCountChange(Accounts
&accounts
, std::size_t request_count
);
61 static void account_signed_on_(PurpleAccount
*account
, gpointer data
)
63 reinterpret_cast<Header
*>(data
)->account_signed_on(account
);
65 static void account_signed_off_(PurpleAccount
*account
, gpointer data
)
67 reinterpret_cast<Header
*>(data
)->account_signed_off(account
);
69 static void account_status_changed_(
70 PurpleAccount
*account
, PurpleStatus
*old
, PurpleStatus
*cur
, gpointer data
)
72 reinterpret_cast<Header
*>(data
)->account_status_changed(account
, old
, cur
);
74 static void account_alias_changed_(
75 PurpleAccount
*account
, const char *old
, gpointer data
)
77 reinterpret_cast<Header
*>(data
)->account_alias_changed(account
, old
);
79 static void account_enabled_(PurpleAccount
*account
, gpointer data
)
81 reinterpret_cast<Header
*>(data
)->account_enabled(account
);
83 static void account_disabled_(PurpleAccount
*account
, gpointer data
)
85 reinterpret_cast<Header
*>(data
)->account_disabled(account
);
88 void account_signed_on(PurpleAccount
*account
);
89 void account_signed_off(PurpleAccount
*account
);
90 void account_status_changed(
91 PurpleAccount
*account
, PurpleStatus
*old
, PurpleStatus
*cur
);
92 void account_alias_changed(PurpleAccount
*account
, const char *old
);
93 void account_enabled(PurpleAccount
*account
);
94 void account_disabled(PurpleAccount
*account
);
99 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: