Allow the user to set the default foreground and background color
[synfig.git] / synfig-studio / trunk / src / gtkmm / dialog_color.cpp
index 5abb515..4d98e83 100644 (file)
@@ -1,20 +1,21 @@
-/* === S I N F G =========================================================== */
-/*!    \file dialog_gradient.cpp
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_color.cpp
 **     \brief Template File
 **
-**     $Id: dialog_color.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
+**     $Id$
 **
 **     \legal
-**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **
-**     This software and associated documentation
-**     are CONFIDENTIAL and PROPRIETARY property of
-**     the above-mentioned copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
 **
-**     You may not copy, print, publish, or in any
-**     other way distribute this software without
-**     a prior written agreement with
-**     the copyright holder.
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
 **     \endlegal
 */
 /* ========================================================================= */
 #include <gtkmm/frame.h>
 #include <gtkmm/table.h>
 #include <gtkmm/label.h>
-#include <sinfg/general.h>
-#include <sinfgapp/canvasinterface.h>
-#include <sinfgapp/value_desc.h>
+#include <synfig/general.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
 #include "widget_color.h"
 #include <gtkmm/spinbutton.h>
-#include <sinfgapp/main.h>
+#include <synfigapp/main.h>
 #include <sigc++/retype_return.h>
 #include <sigc++/retype.h>
 #include <sigc++/hide.h>
 #include "app.h"
 
+#include "general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
 
 using namespace std;
 using namespace etl;
-using namespace sinfg;
+using namespace synfig;
 using namespace studio;
 
 /* === M A C R O S ========================================================= */
@@ -69,6 +72,27 @@ Dialog_Color::Dialog_Color():
 {
        set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
        // Setup the buttons
+
+       Gtk::Image *icon;
+
+       Gtk::Button *set_fg_color(manage(new class Gtk::Button()));
+       icon = manage(new Gtk::Image(Gtk::StockID("synfig-set_fg_color"), Gtk::IconSize::IconSize(Gtk::ICON_SIZE_BUTTON)));
+       set_fg_color->add(*icon);
+       icon->show();
+       tooltips.set_tip(*set_fg_color, _("Set as Foreground"));
+       set_fg_color->show();
+       add_action_widget(*set_fg_color, 4);
+       set_fg_color->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Color::on_set_fg_pressed));
+
+       Gtk::Button *set_bg_color(manage(new class Gtk::Button()));
+       icon = manage(new Gtk::Image(Gtk::StockID("synfig-set_bg_color"), Gtk::IconSize::IconSize(Gtk::ICON_SIZE_BUTTON)));
+       set_bg_color->add(*icon);
+       icon->show();
+       tooltips.set_tip(*set_bg_color, _("Set as Background"));
+       set_bg_color->show();
+       add_action_widget(*set_bg_color, 3);
+       set_bg_color->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Color::on_set_bg_pressed));
+
        //Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
        //ok_button->show();
        //add_action_widget(*ok_button,2);
@@ -82,7 +106,7 @@ Dialog_Color::Dialog_Color():
        Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
        cancel_button->show();
        add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::hide_return(sigc::mem_fun(*this, &Dialog_Color::on_close_pressed)));      
+       cancel_button->signal_clicked().connect(sigc::hide_return(sigc::mem_fun(*this, &Dialog_Color::on_close_pressed)));
        signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this, &Dialog_Color::on_close_pressed)));
 
        Gtk::Table* table(manage(new Gtk::Table(2,2,false)));
@@ -91,7 +115,7 @@ Dialog_Color::Dialog_Color():
        widget_color=manage(new Widget_ColorEdit());
        widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Color::on_color_changed));
        //widget_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Dialog_Color::on_color_changed));
-       table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);   
+       table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
 
        add_accel_group(App::ui_manager()->get_accel_group());
 
@@ -128,6 +152,22 @@ Dialog_Color::on_apply_pressed()
 }
 
 void
+Dialog_Color::on_set_fg_pressed()
+{
+       busy_=true;
+       synfigapp::Main::set_foreground_color(get_color());
+       busy_=false;
+}
+
+void
+Dialog_Color::on_set_bg_pressed()
+{
+       busy_=true;
+       synfigapp::Main::set_background_color(get_color());
+       busy_=false;
+}
+
+void
 Dialog_Color::on_color_changed()
 {
        busy_=true;