X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Ftoolbox.cpp;h=9dddf7920b2d2a5a95c710b8073ab1699e9db31a;hb=8f8a2139a0a6f405a4186dc05a4c1eca787794e4;hp=2aea790bd752130c5df7f2b41a71084dca2c7d76;hpb=2c43cbfff01496919316f600ee76112be551392d;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/toolbox.cpp b/synfig-studio/trunk/src/gtkmm/toolbox.cpp index 2aea790..9dddf79 100644 --- a/synfig-studio/trunk/src/gtkmm/toolbox.cpp +++ b/synfig-studio/trunk/src/gtkmm/toolbox.cpp @@ -1,18 +1,22 @@ -/*! ======================================================================== -** Sinfg -** Template File -** $Id: toolbox.cpp,v 1.3 2005/01/13 20:23:01 darco Exp $ +/* === S Y N F I G ========================================================= */ +/*! \file toolbox.cpp +** \brief writeme ** -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** $Id$ ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** 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 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. +** +** 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 ** ** === N O T E S =========================================================== ** @@ -72,13 +76,13 @@ #include "widget_defaults.h" -#include +#include #endif using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; using namespace studio; using namespace SigC; @@ -86,7 +90,7 @@ using namespace SigC; #define GRAB_HINT_DATA(y,default) { \ String x; \ - if(sinfgapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \ + if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \ { \ set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str())); \ } else {\ @@ -155,7 +159,7 @@ close_selected_instance() } instance->safe_close(); - + //assert(instance.unique()); } @@ -192,37 +196,36 @@ Toolbox::Toolbox(): { GRAB_HINT_DATA( "toolbox", -#ifdef __APPLE__ +//#ifdef __APPLE__ Gdk::WINDOW_TYPE_HINT_NORMAL -#else - Gdk::WINDOW_TYPE_HINT_UTILITY -#endif +//#else +// Gdk::WINDOW_TYPE_HINT_UTILITY +//#endif ); - set_keep_below(true); set_keep_above(false); set_role("toolbox"); recent_files_menu= manage(new class Gtk::Menu()); - + Gtk::Menu *filemenu =manage(new class Gtk::Menu()); dock_dialogs=manage(new class Gtk::Menu()); dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem("Canvases, History",sigc::ptr_fun(_create_stock_dialog1))); - dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem("Layers, Children , Params",sigc::ptr_fun(_create_stock_dialog2))); + dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem("Layers, Children, Params",sigc::ptr_fun(_create_stock_dialog2))); dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); - + filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::NEW, - sigc::ptr_fun(&studio::App::new_instance))); + sigc::ptr_fun(&studio::App::new_instance))); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::OPEN, - sigc::ptr_fun(&studio::App::dialog_open))); + sigc::ptr_fun(&studio::App::dialog_open))); filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Open Recent"),*recent_files_menu)); - - filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("sinfg-saveall"), + + filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-saveall"), sigc::ptr_fun(&studio::App::dialog_not_implemented))); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CLOSE, sigc::ptr_fun(close_selected_instance))); @@ -244,41 +247,41 @@ Toolbox::Toolbox(): filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Setup..."), sigc::ptr_fun(&studio::App::show_setup))); - filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); + filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(Gtk::Stock::QUIT), - sigc::ptr_fun(studio::App::quit))); - + sigc::ptr_fun(studio::App::quit))); + Gtk::Menu *helpmenu = manage(new class Gtk::Menu()); helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::HELP, - sigc::ptr_fun(studio::App::dialog_not_implemented))); - helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); - helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("sinfg-about"), - sigc::ptr_fun(studio::App::dialog_about))); - + sigc::ptr_fun(studio::App::dialog_not_implemented))); + helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); + helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-about"), + sigc::ptr_fun(studio::App::dialog_about))); + Gtk::MenuBar *menubar1 = manage(new class Gtk::MenuBar()); menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem("_File",*filemenu)); menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem("_Help",*helpmenu)); - + menubar1->show(); - + Gtk::Image *icon; - + ADD_TOOLBOX_BUTTON(button_new,"gtk-new","New"); ADD_TOOLBOX_BUTTON(button_open,"gtk-open","Open"); ADD_TOOLBOX_BUTTON(button_save,"gtk-save","Save"); ADD_TOOLBOX_BUTTON(button_saveas,"gtk-save-as","SaveAs"); - ADD_TOOLBOX_BUTTON(button_save_all,"sinfg-saveall","Save All"); + ADD_TOOLBOX_BUTTON(button_save_all,"synfig-saveall","Save All"); TOOLBOX_BUTTON(button_undo,"gtk-undo","Undo"); TOOLBOX_BUTTON(button_redo,"gtk-redo","Redo"); - ADD_TOOLBOX_BUTTON(button_about,"sinfg-about","About Sinfg Studio"); - ADD_TOOLBOX_BUTTON(button_color,"sinfg-color","Color Dialog"); - - TOOLBOX_BUTTON(button_rotoscope_bline,"sinfg-rotoscope_bline",_("Old Rotoscope BLine")); - TOOLBOX_BUTTON(button_rotoscope_polygon,"sinfg-rotoscope_polygon",_("Rotoscope Polygon")); - TOOLBOX_BUTTON(button_eyedrop,"sinfg-eyedrop",_("Eyedrop Tool")); - TOOLBOX_BUTTON(button_rotoscope,"sinfg-rotoscope_bline",_("Rotoscope 2")); - + ADD_TOOLBOX_BUTTON(button_about,"synfig-about","About Synfig Studio"); + ADD_TOOLBOX_BUTTON(button_color,"synfig-color","Color Dialog"); + + TOOLBOX_BUTTON(button_rotoscope_bline,"synfig-rotoscope_bline",_("Old Rotoscope BLine")); + TOOLBOX_BUTTON(button_rotoscope_polygon,"synfig-rotoscope_polygon",_("Rotoscope Polygon")); + TOOLBOX_BUTTON(button_eyedrop,"synfig-eyedrop",_("Eyedrop Tool")); + TOOLBOX_BUTTON(button_rotoscope,"synfig-rotoscope_bline",_("Rotoscope 2")); + button_about->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_about)); @@ -311,7 +314,7 @@ Toolbox::Toolbox(): handle_tools->show(); handle_tools->set_handle_position(Gtk::POS_TOP); handle_tools->set_snap_edge(Gtk::POS_TOP); - + Widget_Defaults* widget_defaults(manage(new Widget_Defaults())); widget_defaults->show(); Gtk::HandleBox* handle_defaults(manage(new Gtk::HandleBox())); @@ -319,7 +322,7 @@ Toolbox::Toolbox(): handle_defaults->show(); handle_defaults->set_handle_position(Gtk::POS_TOP); handle_defaults->set_snap_edge(Gtk::POS_TOP); - + // Create the toplevel table Gtk::Table *table1 = manage(new class Gtk::Table(1, 2, false)); table1->set_row_spacings(0); @@ -330,9 +333,9 @@ Toolbox::Toolbox(): table1->attach(*handle_tools, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0); table1->attach(*handle_defaults, 0, 1, 4, 5, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0); table1->show_all(); - - - + + + // Set the parameters for this window add(*table1); set_title("Synfig Studio"); @@ -342,7 +345,7 @@ Toolbox::Toolbox(): set_resizable(false); - + App::signal_instance_selected().connect( sigc::hide( sigc::mem_fun(*this,&studio::Toolbox::update_undo_redo) @@ -354,11 +357,11 @@ Toolbox::Toolbox(): ); button_undo->set_sensitive(false); - button_redo->set_sensitive(false); + button_redo->set_sensitive(false); button_rotoscope_bline->set_sensitive(false); button_rotoscope->set_sensitive(false); - button_rotoscope_polygon->set_sensitive(false); - button_eyedrop->set_sensitive(false); + button_rotoscope_polygon->set_sensitive(false); + button_eyedrop->set_sensitive(false); std::list listTargets; @@ -368,15 +371,15 @@ Toolbox::Toolbox(): drag_dest_set(listTargets); signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::Toolbox::on_drop_drag_data_received) ); - + App::dock_manager->signal_dockable_registered().connect(sigc::mem_fun(*this,&Toolbox::dockable_registered)); - + changing_state_=false; - + add_accel_group(App::ui_manager()->get_accel_group()); - - App::signal_present_all().connect(sigc::mem_fun(*this,&Toolbox::present)); + + App::signal_present_all().connect(sigc::mem_fun0(*this,&Toolbox::present)); } Toolbox::~Toolbox() @@ -393,15 +396,15 @@ Toolbox::~Toolbox() void Toolbox::set_active_state(const String& statename) { - std::map::iterator iter; + std::map::iterator iter; changing_state_=true; - - sinfgapp::Main::set_state(statename); - + + synfigapp::Main::set_state(statename); + try { - + for(iter=state_button_map.begin();iter!=state_button_map.end();++iter) { if(iter->first==statename) @@ -425,7 +428,7 @@ Toolbox::set_active_state(const String& statename) } void -Toolbox::change_state(const sinfg::String& statename) +Toolbox::change_state(const synfig::String& statename) { etl::handle canvas_view(studio::App::get_selected_canvas_view()); if(canvas_view) @@ -434,14 +437,14 @@ Toolbox::change_state(const sinfg::String& statename) { return; } - + if(state_button_map.count(statename)) { state_button_map[statename]->clicked(); } else { - sinfg::error("Unknown state \"%s\"",statename.c_str()); + synfig::error("Unknown state \"%s\"",statename.c_str()); } } } @@ -452,7 +455,7 @@ Toolbox::change_state_(const Smach::state_base *state) if(changing_state_) return; changing_state_=true; - + try { etl::handle canvas_view(studio::App::get_selected_canvas_view()); @@ -460,7 +463,7 @@ Toolbox::change_state_(const Smach::state_base *state) { if(state->get_name()==String("normal")) { - canvas_view->get_smach().egress(); + canvas_view->get_smach().egress(); } else { @@ -475,7 +478,7 @@ Toolbox::change_state_(const Smach::state_base *state) changing_state_=false; throw; } - + changing_state_=false; } @@ -487,63 +490,63 @@ Toolbox::add_state(const Smach::state_base *state) assert(state); String name=state->get_name(); - + Gtk::ToggleButton* button; button=manage(new class Gtk::ToggleButton()); - icon=manage(new Gtk::Image(Gtk::StockID("sinfg-"+name),Gtk::IconSize(4))); + icon=manage(new Gtk::Image(Gtk::StockID("synfig-"+name),Gtk::IconSize(4))); button->add(*icon); tooltips.set_tip(*button,name); icon->show(); button->show(); - - + + int row=state_button_map.size()/4; int col=state_button_map.size()%4; tool_table->attach(*button,col,col+1,row,row+1, Gtk::SHRINK, Gtk::SHRINK, 0, 0); - + state_button_map[name]=button; - + button->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this,&studio::Toolbox::change_state_), state ) ); - - + + refresh(); } void Toolbox::update_undo_redo() -{ +{ etl::handle instance=App::get_selected_instance(); if(instance) { button_undo->set_sensitive(instance->get_undo_status()); - button_redo->set_sensitive(instance->get_redo_status()); + button_redo->set_sensitive(instance->get_redo_status()); } - + // This should probably go elsewhere, but it should // work fine here with no troubles. // These next several lines just adjust the rotoscope buttons // so that they are only clickable when they should be. if(instance && App::get_selected_canvas_view()) { - std::map::iterator iter; - + std::map::iterator iter; + for(iter=state_button_map.begin();iter!=state_button_map.end();++iter) iter->second->set_sensitive(true); } else { - std::map::iterator iter; - + std::map::iterator iter; + for(iter=state_button_map.begin();iter!=state_button_map.end();++iter) iter->second->set_sensitive(false); } @@ -560,10 +563,10 @@ Toolbox::update_undo_redo() void Toolbox::on_recent_files_changed() -{ +{ while(recent_files_menu->get_children().size()) recent_files_menu->remove(**recent_files_menu->get_children().begin()); - + list::const_iterator iter; // Check to see if the file is already on the list. // If it is, then remove it from the list @@ -571,7 +574,7 @@ Toolbox::on_recent_files_changed() recent_files_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(basename(*iter), sigc::hide_return(sigc::bind(sigc::ptr_fun(&App::open),*iter)) )); - + // HACK show(); } @@ -581,48 +584,48 @@ Toolbox::on_drop_drag_data_received(const Glib::RefPtr& contex { // We will make this true once we have a solid drop bool success(false); - + if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8)) { - sinfg::String selection_data((gchar *)(selection_data_.get_data())); + synfig::String selection_data((gchar *)(selection_data_.get_data())); // For some reason, GTK hands us a list of URL's seperated // by not only Carrage-Returns, but also Line-Feeds. // Line-Feeds will mess us up. Remove all the line-feeds. - while(selection_data.find_first_of('\r')!=sinfg::String::npos) + while(selection_data.find_first_of('\r')!=synfig::String::npos) selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r')); std::stringstream stream(selection_data); while(stream) { - sinfg::String filename,URI; + synfig::String filename,URI; getline(stream,filename); - + // If we don't have a filename, move on. if(filename.empty()) continue; - + // Make sure this URL is of the "file://" type. URI=String(filename.begin(),filename.begin()+sizeof("file://")-1); if(URI!="file://") { - sinfg::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str()); + synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str()); continue; } - + // Strip the "file://" part from the filename - filename=sinfg::String(filename.begin()+sizeof("file://")-1,filename.end()); - - sinfg::info("Attempting to open "+filename); + filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end()); + + synfig::info("Attempting to open "+filename); if(App::open(filename)) success=true; else - sinfg::error("Drop failed: Unable to open "+filename); + synfig::error("Drop failed: Unable to open "+filename); } } else - sinfg::error("Drop failed: bad selection data"); + synfig::error("Drop failed: bad selection data"); // Finish the drag context->drag_finish(success, false, time);