Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / gtkmm / cellrenderer_value.cpp
index a9f931b..802a178 100644 (file)
@@ -2,10 +2,11 @@
 /*!    \file cellrenderer_value.cpp
 **     \brief Template File
 **
-**     $Id: cellrenderer_value.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
+**     $Id$
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -54,6 +55,8 @@
 #include "dialog_color.h"
 #include <gtkmm/textview.h>
 
+#include "general.h"
+
 #endif
 
 using namespace synfig;
@@ -65,11 +68,6 @@ using namespace studio;
 
 #define DIGITS         15
 
-#define use_colorspace_gamma() App::use_colorspace_gamma
-#define colorspace_gamma()     (2.2f)
-#define gamma_in(x)            pow((float)x,1.0f/colorspace_gamma())
-#define gamma_out(x)   pow((float)x,colorspace_gamma())
-
 /* === G L O B A L S ======================================================= */
 
 class studio::ValueBase_Entry : public Gtk::EventBox, public Gtk::CellEditable
@@ -104,18 +102,18 @@ public:
 
                //set_flags(Gtk::CAN_FOCUS);
                //set_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
-               
+
                /*
                set_events(//(Gdk::ALL_EVENTS_MASK)
-               ~(      Gdk::EXPOSURE_MASK      
-                       | Gdk::ENTER_NOTIFY_MASK        
-                       | Gdk::LEAVE_NOTIFY_MASK        
-                       | Gdk::FOCUS_CHANGE_MASK        
-                       | Gdk::STRUCTURE_MASK   
-                       | Gdk::PROPERTY_CHANGE_MASK     
-                       | Gdk::VISIBILITY_NOTIFY_MASK   
-                       | Gdk::PROXIMITY_IN_MASK        
-                       | Gdk::PROXIMITY_OUT_MASK       
+               ~(      Gdk::EXPOSURE_MASK
+                       | Gdk::ENTER_NOTIFY_MASK
+                       | Gdk::LEAVE_NOTIFY_MASK
+                       | Gdk::FOCUS_CHANGE_MASK
+                       | Gdk::STRUCTURE_MASK
+                       | Gdk::PROPERTY_CHANGE_MASK
+                       | Gdk::VISIBILITY_NOTIFY_MASK
+                       | Gdk::PROXIMITY_IN_MASK
+                       | Gdk::PROXIMITY_OUT_MASK
                        | Gdk::SUBSTRUCTURE_MASK
                )
                );
@@ -124,14 +122,13 @@ public:
                //signal_remove_widget().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
 
                show_all_children();
-               
+
                //signal_show().connect(sigc::mem_fun(*this, &ValueBase_Entry::grab_focus));
        }
        ~ValueBase_Entry()
        {
-               DEBUGPOINT();
        }
-       
+
        void on_editing_done()
        {
                hide();
@@ -154,7 +151,7 @@ public:
                if(parent)parent->grab_focus();
                Gtk::CellEditable::on_remove_widget();
        }
-       void start_editing_vfunc(GdkEvent *event)
+       void start_editing_vfunc(GdkEvent */*event*/)
        {
                valuewidget->signal_activate().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::editing_done));
                show();
@@ -199,13 +196,16 @@ public:
                if(valuewidget)
                        valuewidget->set_param_desc(data);
        }
-       
+
        const synfig::ValueBase &get_value()
        {
                if(valuewidget)
                        return valuewidget->get_value();
-               return synfig::ValueBase();
+
+               warning("%s:%d this code shouldn't be reached", __FILE__, __LINE__);
+               return *(new synfig::ValueBase());
        }
+
        const Glib::ustring &get_path()
        {
                return path;
@@ -241,13 +241,13 @@ bool get_paragraph(synfig::String& text)
        entry.set_activates_default(true);
        dialog.get_vbox()->pack_start(entry);
 */
-       
+
        dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
        dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
        dialog.set_default_response(Gtk::RESPONSE_OK);
-       
+
        //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
-       
+
        dialog.show();
 
        if(dialog.run()!=Gtk::RESPONSE_OK)
@@ -270,7 +270,7 @@ CellRenderer_ValueBase::CellRenderer_ValueBase():
        CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
        value_entry=new ValueBase_Entry();
        value_entry->hide();
-       
+
        Pango::AttrList attr_list;
        {
                Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
@@ -279,14 +279,15 @@ CellRenderer_ValueBase::CellRenderer_ValueBase():
                attr_list.change(pango_size);
        }
        property_attributes()=attr_list;
-       
+
        property_foreground()=Glib::ustring("#7f7f7f");
-       property_inconsistant()=false;
+       property_inconsistent()=false;
 }
 
 CellRenderer_ValueBase::~CellRenderer_ValueBase()
 {
-//     synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): deleted");
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted");
 }
 
 void
@@ -294,14 +295,14 @@ CellRenderer_ValueBase::string_edited_(const Glib::ustring&path,const Glib::ustr
 {
        ValueBase old_value=property_value_.get_value();
        ValueBase value;
-       
+
        if(old_value.get_type()==ValueBase::TYPE_TIME)
        {
                value=ValueBase(Time((String)str,get_canvas()->rend_desc().get_frame_rate()));
        }
-       else 
+       else
                value=ValueBase((String)str);
-       
+
        if(old_value!=value)
                signal_edited_(path,value);
 }
@@ -367,7 +368,7 @@ CellRenderer_ValueBase::render_vfunc(
                        property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
                        std::list<synfig::ParamDesc::EnumData> enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
                        std::list<synfig::ParamDesc::EnumData>::iterator iter;
-                                               
+
                        for(iter=enum_list.begin();iter!=enum_list.end();iter++)
                                if(iter->value==data.get(int()))
                                {
@@ -375,7 +376,7 @@ CellRenderer_ValueBase::render_vfunc(
                                        break;
                                }
                }
-                       
+
                break;
        case ValueBase::TYPE_VECTOR:
                {
@@ -386,9 +387,9 @@ CellRenderer_ValueBase::render_vfunc(
                        property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
                }
                break;
-       
+
        case ValueBase::TYPE_STRING:
-       
+
                if(data.get_type()==ValueBase::TYPE_STRING)
                {
                        if(!data.get(synfig::String()).empty())
@@ -401,7 +402,7 @@ CellRenderer_ValueBase::render_vfunc(
                if(data.get(etl::handle<synfig::Canvas>()))
                {
                        if(data.get(etl::handle<synfig::Canvas>())->is_inline())
-                               property_text()="<Inline Canvas>";
+                               property_text()=_("<Inline Canvas>");
                        else
                                property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
                }
@@ -417,7 +418,7 @@ CellRenderer_ValueBase::render_vfunc(
        case ValueBase::TYPE_BOOL:
                {
                        widget.get_style()->paint_check(
-                               Glib::RefPtr<Gdk::Window>::cast_static(window), state, 
+                               Glib::RefPtr<Gdk::Window>::cast_static(window), state,
                                data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
                                ca, widget, "cellcheck",
                                ca.get_x()/* + x_offset + cell_xpad*/,
@@ -445,7 +446,7 @@ CellRenderer_ValueBase::render_vfunc(
                break;
        default:
                property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
-               break;  
+               break;
        }
        CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
 }
@@ -495,17 +496,17 @@ CellRenderer_ValueBase::color_edited(synfig::Color color, Glib::ustring path)
 
 Gtk::CellEditable*
 CellRenderer_ValueBase::start_editing_vfunc(
-       GdkEvent* event,
+       GdkEvent* event __attribute__ ((unused)),
        Gtk::Widget& widget,
        const Glib::ustring& path,
-       const Gdk::Rectangle& background_area,
-       const Gdk::Rectangle& cell_area,
-       Gtk::CellRendererState flags)
+       const Gdk::Rectangle& background_area __attribute__ ((unused)),
+       const Gdk::Rectangle& cell_area __attribute__ ((unused)),
+       Gtk::CellRendererState flags __attribute__ ((unused)))
 {
        // If we aren't editable, then there is nothing to do
        if(!property_editable())
                return 0;
-               
+
        ValueBase data=property_value_.get_value();
 
        switch(data.get_type())
@@ -516,7 +517,7 @@ CellRenderer_ValueBase::start_editing_vfunc(
        //case ValueBase::TYPE_TIME:
        //      property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format()|Time::FORMAT_FULL);
        //      return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
-               
+
        case ValueBase::TYPE_GRADIENT:
                App::dialog_gradient->reset();
                App::dialog_gradient->set_gradient(data.get(Gradient()));
@@ -527,7 +528,7 @@ CellRenderer_ValueBase::start_editing_vfunc(
                        )
                );
                App::dialog_gradient->present();
-       
+
                return NULL;
 
        case ValueBase::TYPE_COLOR:
@@ -540,7 +541,7 @@ CellRenderer_ValueBase::start_editing_vfunc(
                        )
                );
                App::dialog_color->present();
-       
+
                return NULL;
        case ValueBase::TYPE_STRING:
                if(get_param_desc().get_hint()=="paragraph")
@@ -548,13 +549,11 @@ CellRenderer_ValueBase::start_editing_vfunc(
                        synfig::String string;
                        string=data.get(string);
                        if(get_paragraph(string))
-                       {
                                signal_edited_(path,ValueBase(string));
-                       }                       
                        return NULL;
                }
-               if(get_param_desc().get_hint()!="filename")
-                       return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+               // if(get_param_desc().get_hint()!="filename")
+                       // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
        default:
                {
                        assert(get_canvas());
@@ -582,8 +581,8 @@ CellRenderer_ValueBase::on_value_editing_done()
 
                if(old_value!=value)
                        signal_edited_(value_entry->get_path(),value);
-               
+
                //delete value_entry;
                //value_entry=0;
-       }       
+       }
 }