File: active_label.cpp

package info (click to toggle)
mysql-workbench 5.2.40%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 53,880 kB
  • sloc: cpp: 419,850; yacc: 74,784; xml: 54,510; python: 31,455; sh: 9,423; ansic: 4,736; makefile: 2,442; php: 529; java: 237
file content (83 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "active_label.h"

//--------------------------------------------------------------------------------
ActiveLabel::ActiveLabel(const Glib::ustring& text, const sigc::slot<void> &close_callback)
            : _close_callback(close_callback)
            , _label("\342\234\225")
            , _text_label(text)
{
  _evbox.add(_label);
  _evbox.signal_event().connect(sigc::mem_fun(this, &ActiveLabel::handle_event));

  _text_label_eventbox.add(_text_label);

  pack_start(_text_label_eventbox);
  pack_start(_evbox);

  _evbox.show_all();
  _label.show();
  show_all();

  signal_button_press_event().connect(sigc::mem_fun(this, &ActiveLabel::button_press_slot));

  #if GTK_VERSION_GE(2,20)
  _spinner.hide();
  #endif
}

//--------------------------------------------------------------------------------
bool ActiveLabel::handle_event(GdkEvent* e)
{
  switch (e->type)
  {
    case GDK_BUTTON_RELEASE:
      {
        GdkEventButton *evb = (GdkEventButton*)e;
        if (evb->button == 1)
          _close_callback();
        break;
      }
    default:
      break;
  }

  return false;
}

//--------------------------------------------------------------------------------
void ActiveLabel::set_text(const std::string& lbl)
{
  _text_label.set_text(lbl);
}

//--------------------------------------------------------------------------------
bool ActiveLabel::button_press_slot(GdkEventButton* evb)
{
  if (evb->button == 3 && !_menu.empty())
    _menu.popup_at(0, evb->x, evb->y);
  return false;
}

//--------------------------------------------------------------------------------
void ActiveLabel::start_busy()
{
#if GTK_VERSION_GE(2,20)
  _label.hide();
  _evbox.remove();
  _spinner.show();
  _evbox.add(_spinner);
  _spinner.start();
#endif
}

//--------------------------------------------------------------------------------
void ActiveLabel::stop_busy()
{
#if GTK_VERSION_GE(2,20)
  _spinner.hide();
  _evbox.remove();
  _label.show();
  _evbox.add(_label);
  _spinner.stop();
#endif
}