CEBL  2.1
StatusBar.cpp
Go to the documentation of this file.
1 
6 #include "StatusBar.hpp"
7 #include <iostream>
8 
10 {
11  status_bar = gtk_statusbar_new();
12  this->setWidgetContainer(status_bar);
13  this->show();
14  this->volatile_msg = false;
15  this->timed_msg = false;
16 }
17 
19 {
20 
21 }
22 
25 {
26  if(id.message_id > 0)
27  {
28  gtk_statusbar_remove(GTK_STATUSBAR(status_bar), id.context_id, id.message_id);
29  id.message_id = -1;
30  }
31 }
32 
35 {
36  this->volatile_msg = false;
37  this->timed_msg = false;
38 
39  if(id_stack.empty())
40  return;
41  int id = id_stack.top().context_id;
42  id_stack.pop();
43  gtk_statusbar_pop(GTK_STATUSBAR(status_bar),id);
44 }
45 
47 gint StatusBar::timedPop(gpointer parent)
48 {
49  StatusBar* bar = (StatusBar*)parent;
50  if(bar->timed_msg)
51  {
52  bar->pop();
53  bar->volatile_msg = false;
54  bar->timed_msg = false;
55  }
56  return false;
57 }
58 
60 StatusID StatusBar::push(string message)
61 {
62  if(this->volatile_msg)
63  {
64  this->pop();
65  this->volatile_msg = false;
66  this->timed_msg = false;
67  }
68 
69  int cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), message.c_str());
70  int mid = gtk_statusbar_push(GTK_STATUSBAR(status_bar), cid, message.c_str());
71 
72  StatusID id;
73  id.context_id = cid;
74  id.message_id = mid;
75 
76  id_stack.push(id);
77  gtk_main_iteration();
78 
79  return id;
80 }
81 
84 {
85  StatusID id = push(message);
86  this->volatile_msg = true;
87  return id;
88 }
89 
91 // ms is number of milliseconds to wait, 2000 by default
92 StatusID StatusBar::pushTimed(string message,int ms)
93 {
94  StatusID id = pushVolatile(message);
95  timed_msg = true;
96  g_timeout_add(ms, timedPop, this);
97  return id;
98 }
99 
100 
101