File: utils_fe.h

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 (76 lines) | stat: -rw-r--r-- 2,448 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
#ifndef __SQLIDE_UTILS_FE_H__
#define __SQLIDE_UTILS_FE_H__


#include "linux_utilities/image_cache.h"
#include "grt/icon_manager.h"
#include <gtkmm.h>

/*
#define WIDGET2(xml, name, var)\
(xml).get(#name, &var);

#define WIDGET_(xml, name)\
(xml).get(#name, &_ ## name);

#define WIDGET(xml, name)\
WIDGET2 (xml, name, name);

#define WIDGET_DEF2(xml, type, name, var)\
Gtk::type *var(NULL);\
WIDGET2 (xml, name, var)

#define WIDGET_DEF(xml, type, name)\
WIDGET_DEF2 (xml, type, name, name)

#define WIDGET_SIGNAL2(widget, signal, callback_member)\
  widget->signal_ ## signal().connect(sigc::mem_fun(this, &CLASS_NAME::callback_member));\

#define WIDGET_SIGNAL(widget, name, signal)\
  WIDGET_SIGNAL2 (widget, signal, on_ ## name ## _ ## signal)

#define WIDGET_SIGNAL_DEF(xml, type, name, signal)\
{\
  WIDGET_DEF2 (xml, type, name, w)\
  WIDGET_SIGNAL (w, name, signal)\
}
*/

static void set_tool_button_icon(Glib::RefPtr<Gtk::Builder> &xml, const std::string &button_name, const std::string &icon_filename);
static void set_tool_button_icon(Gtk::ToolButton *button, const std::string &icon_filename);

static void set_tool_button_icon(Glib::RefPtr<Gtk::Builder> &xml, const std::string &button_name, const std::string &icon_filename)
{
  Gtk::ToolButton *button;
  xml->get_widget(button_name, button);
  set_tool_button_icon(button, icon_filename);
}

static void set_tool_button_icon(Gtk::ToolButton *button, const std::string &icon_filename)
{
  bec::IconManager *icon_man= bec::IconManager::get_instance();
  bec::IconId btn_icon= icon_man->get_icon_id(icon_filename);
  ImageCache *image_cache= ImageCache::get_instance();
  Glib::RefPtr<Gdk::Pixbuf> pixbuf= image_cache->image(btn_icon);
  Gtk::Image *image= Gtk::manage(new Gtk::Image(pixbuf));
  image->show();
#if GTK_VERSION_GT(2,10)
  std::string tooltip_text= button->get_tooltip_text();
  if (tooltip_text.empty())
    button->set_tooltip_text(button->get_label());
#endif
  button->set_homogeneous(false);
  button->set_icon_widget(*image);
}

static void set_button_icon(Gtk::Button *button, const std::string &icon_filename)
{
  bec::IconManager *icon_man= bec::IconManager::get_instance();
  bec::IconId btn_icon= icon_man->get_icon_id(icon_filename);
  ImageCache *image_cache= ImageCache::get_instance();
  Gtk::Image *image= Gtk::manage(new Gtk::Image(image_cache->image(btn_icon)));
  button->set_image(*image);
  button->show_all();
}

#endif // __SQLIDE_UTILS_FE_H__