1 /* === S Y N F I G ========================================================= */
2 /*! \file dialog_color.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "dialog_color.h"
33 #include "widget_color.h"
34 #include <synfig/general.h>
35 #include <synfigapp/main.h>
36 #include <gtkmm/button.h>
43 /* === U S I N G =========================================================== */
47 using namespace synfig;
48 using namespace studio;
50 /* === M A C R O S ========================================================= */
52 /* === G L O B A L S ======================================================= */
54 /* === P R O C E D U R E S ================================================= */
56 /* === M E T H O D S ======================================================= */
58 Dialog_Color::Dialog_Color():
59 Dialog(_("Colors"), false, true),
60 dialog_settings(this, "color"),
63 set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
65 create_color_edit_widget();
66 create_set_color_button("synfig-set_fg_color", _("Set as Foreground"), 0,
67 sigc::mem_fun(*this, &Dialog_Color::on_set_fg_pressed));
68 create_set_color_button("synfig-set_bg_color", _("Set as Background"), 1,
69 sigc::mem_fun(*this, &Dialog_Color::on_set_bg_pressed));
70 create_close_button();
72 add_accel_group(App::ui_manager()->get_accel_group());
76 Dialog_Color::~Dialog_Color()
81 Dialog_Color::create_color_edit_widget()
83 color_edit_widget = manage(new Widget_ColorEdit());
84 color_edit_widget->signal_value_changed().connect(sigc::mem_fun(*this,
85 &studio::Dialog_Color::on_color_changed));
86 get_vbox()->pack_start(*color_edit_widget);
90 Dialog_Color::create_set_color_button(const char *stock_id,
91 const Glib::ustring& tip_text, int index,
92 const sigc::slot0<void>& callback)
94 Gtk::Button *set_color_button = manage(new Gtk::Button());
95 Gtk::Image *set_color_icon = manage(new Gtk::Image(Gtk::StockID(stock_id),
96 Gtk::IconSize::IconSize(Gtk::ICON_SIZE_BUTTON)));
97 set_color_button->add(*set_color_icon);
98 set_color_icon->show();
99 tooltips.set_tip(*set_color_button, tip_text);
100 set_color_button->show();
101 add_action_widget(*set_color_button, index);
102 set_color_button->signal_clicked().connect(callback);
106 Dialog_Color::create_close_button()
108 Gtk::Button *close_button(manage(new Gtk::Button(Gtk::StockID("gtk-close"))));
109 close_button->show();
110 add_action_widget(*close_button, 2);
111 close_button->signal_clicked().connect(sigc::hide_return(sigc::mem_fun(*this,
112 &Dialog_Color::on_close_pressed)));
113 signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this,
114 &Dialog_Color::on_close_pressed)));
118 Dialog_Color::on_color_changed()
121 signal_edited_(get_color());
126 Dialog_Color::on_set_fg_pressed()
129 synfigapp::Main::set_foreground_color(get_color());
134 Dialog_Color::on_set_bg_pressed()
137 synfigapp::Main::set_background_color(get_color());
142 Dialog_Color::on_close_pressed()
152 Dialog_Color::reset()
154 signal_edited_.clear();