~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to frontend/linux/linux_utilities/active_label.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "active_label.h"
 
2
 
 
3
//--------------------------------------------------------------------------------
 
4
ActiveLabel::ActiveLabel(const Glib::ustring& text, const sigc::slot<void> &close_callback)
 
5
            : _close_callback(close_callback)
 
6
            , _label("\342\234\225")
 
7
            , _text_label(text)
 
8
{
 
9
  _evbox.add(_label);
 
10
  _evbox.signal_event().connect(sigc::mem_fun(this, &ActiveLabel::handle_event));
 
11
 
 
12
  _text_label_eventbox.add(_text_label);
 
13
 
 
14
  pack_start(_text_label_eventbox);
 
15
  pack_start(_evbox);
 
16
 
 
17
  _evbox.show_all();
 
18
  _label.show();
 
19
  show_all();
 
20
 
 
21
  signal_button_press_event().connect(sigc::mem_fun(this, &ActiveLabel::button_press_slot));
 
22
 
 
23
  #if GTK_VERSION_GE(2,20)
 
24
  _spinner.hide();
 
25
  #endif
 
26
}
 
27
 
 
28
//--------------------------------------------------------------------------------
 
29
bool ActiveLabel::handle_event(GdkEvent* e)
 
30
{
 
31
  switch (e->type)
 
32
  {
 
33
    case GDK_BUTTON_RELEASE:
 
34
      {
 
35
        GdkEventButton *evb = (GdkEventButton*)e;
 
36
        if (evb->button == 1)
 
37
          _close_callback();
 
38
        break;
 
39
      }
 
40
    default:
 
41
      break;
 
42
  }
 
43
 
 
44
  return false;
 
45
}
 
46
 
 
47
//--------------------------------------------------------------------------------
 
48
void ActiveLabel::set_text(const std::string& lbl)
 
49
{
 
50
  _text_label.set_text(lbl);
 
51
}
 
52
 
 
53
//--------------------------------------------------------------------------------
 
54
bool ActiveLabel::button_press_slot(GdkEventButton* evb)
 
55
{
 
56
  if (evb->button == 3 && !_menu.empty())
 
57
    _menu.popup_at(0, evb->x, evb->y);
 
58
  return false;
 
59
}
 
60
 
 
61
//--------------------------------------------------------------------------------
 
62
void ActiveLabel::start_busy()
 
63
{
 
64
#if GTK_VERSION_GE(2,20)
 
65
  _label.hide();
 
66
  _evbox.remove();
 
67
  _spinner.show();
 
68
  _evbox.add(_spinner);
 
69
  _spinner.start();
 
70
#endif
 
71
}
 
72
 
 
73
//--------------------------------------------------------------------------------
 
74
void ActiveLabel::stop_busy()
 
75
{
 
76
#if GTK_VERSION_GE(2,20)
 
77
  _spinner.hide();
 
78
  _evbox.remove();
 
79
  _label.show();
 
80
  _evbox.add(_label);
 
81
  _spinner.stop();
 
82
#endif
 
83
}