Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / gtkmm / keyframetree.cpp
index f4af223..14af5ab 100644 (file)
@@ -2,10 +2,11 @@
 /*!    \file keyframetree.cpp
 **     \brief Template File
 **
-**     $Id: keyframetree.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) 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
@@ -34,6 +35,8 @@
 #include <gtkmm/treemodelsort.h>
 #include <ETL/misc>
 
+#include "general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -54,24 +57,21 @@ using namespace studio;
 KeyframeTree::KeyframeTree()
 {
        const KeyframeTreeStore::Model model;
-       
+
        {
                Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time")) );
 
                cell_renderer_time = Gtk::manage( new CellRenderer_Time() );
                column->pack_start(*cell_renderer_time,true);
                column->add_attribute(cell_renderer_time->property_time(), model.time);
-               
                cell_renderer_time->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_time));
 
                column->set_reorderable();
                column->set_resizable();
                column->set_clickable();
-               //column->set_sort_column_id(COLUMNID_TIME);
-               column->set_sort_column_id(model.time);
+               column->set_sort_column(model.time);
 
                append_column(*column);
-               //column->clicked();
        }
        {
                Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Length")) );
@@ -79,42 +79,34 @@ KeyframeTree::KeyframeTree()
                cell_renderer_time_delta = Gtk::manage( new CellRenderer_Time() );
                column->pack_start(*cell_renderer_time_delta,true);
                column->add_attribute(cell_renderer_time_delta->property_time(), model.time_delta);
-               
                cell_renderer_time_delta->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_time_delta));
 
                column->set_reorderable();
                column->set_resizable();
-
-               column->set_sort_column_id(model.time_delta);
-
                column->set_clickable(false);
+               // column->set_sort_column(model.time_delta);
 
                append_column(*column);
-               //column->clicked();
        }
        {
                Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
 
                Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
                column->pack_start(*cell_renderer_jump,true);
-               
-               cell_renderer_jump->property_text()="(JMP)";
+               cell_renderer_jump->property_text()=_("(JMP)");
                cell_renderer_jump->property_foreground()="#003a7f";
-               
+
                column->set_reorderable();
                column->set_resizable();
-               
-               column->set_sort_column_id(COLUMNID_JUMP);
-
                column->set_clickable(false);
+               column->set_sort_column(COLUMNID_JUMP); // without this, (JMP) needs a double click?!
 
                append_column(*column);
-               //column->clicked();
        }
-       //append_column_editable(_("Description"),model.description);
+       // append_column_editable(_("Description"),model.description);
        {
                Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Description")) );
-               
+
                cell_renderer_description=Gtk::manage(new Gtk::CellRendererText());
                column->pack_start(*cell_renderer_description,true);
                column->add_attribute(cell_renderer_description->property_text(), model.description);
@@ -123,8 +115,7 @@ KeyframeTree::KeyframeTree()
                column->set_reorderable();
                column->set_resizable();
                column->set_clickable();
-               //column->set_sort_column_id(COLUMNID_DESCRIPTION);
-               column->set_sort_column_id(model.description);
+               column->set_sort_column(model.description);
 
                append_column(*column);
        }
@@ -134,14 +125,15 @@ KeyframeTree::KeyframeTree()
 
        // This makes things easier to read.
        set_rules_hint();
-               
+
        // Make us more sensitive to several events
        add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
 }
 
 KeyframeTree::~KeyframeTree()
 {
-       synfig::info("KeyframeTree::~KeyframeTree(): deleted");
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("KeyframeTree::~KeyframeTree(): Deleted");
 }
 
 void
@@ -156,18 +148,18 @@ KeyframeTree::set_model(Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store)
 {
        keyframe_tree_store_=keyframe_tree_store;
        KeyframeTreeStore::Model model;
-       
+
        if(true)
        {
                Glib::RefPtr<Gtk::TreeModelSort> sorted_store(Gtk::TreeModelSort::create(keyframe_tree_store_));
                sorted_store->set_default_sort_func(sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
-               sorted_store->set_sort_func(model.time.index(),sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
-               sorted_store->set_sort_column_id(model.time.index(), Gtk::SORT_ASCENDING);
+               sorted_store->set_sort_func(model.time,                 sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
+               sorted_store->set_sort_func(model.description,  sigc::ptr_fun(&studio::KeyframeTreeStore::description_sorter));
                Gtk::TreeView::set_model(sorted_store);
        }
        else
                Gtk::TreeView::set_model(keyframe_tree_store);
-       
+
        keyframe_tree_store_->canvas_interface()->signal_rend_desc_changed().connect(
                sigc::mem_fun(
                        *this,
@@ -182,7 +174,7 @@ void
 KeyframeTree::set_editable(bool x)
 {
        editable_=x;
-       
+
        if(editable_)
        {
                cell_renderer_time->property_editable()=true;
@@ -201,9 +193,9 @@ void
 KeyframeTree::on_edited_time(const Glib::ustring&path_string,synfig::Time time)
 {
        Gtk::TreePath path(path_string);
-       
+
        const Gtk::TreeRow row(*(get_model()->get_iter(path)));
-       
+
        synfig::Keyframe keyframe(row[model.keyframe]);
        if(time!=keyframe.get_time())
        {
@@ -218,9 +210,9 @@ void
 KeyframeTree::on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time)
 {
        Gtk::TreePath path(path_string);
-       
+
        const Gtk::TreeRow row(*(get_model()->get_iter(path)));
-       
+
        if(row)row[model.time_delta]=time;
 }
 
@@ -228,9 +220,9 @@ void
 KeyframeTree::on_edited_description(const Glib::ustring&path_string,const Glib::ustring &desc)
 {
        Gtk::TreePath path(path_string);
-       
+
        const Gtk::TreeRow row = *(get_model()->get_iter(path));
-       
+
        const synfig::String description(desc);
        synfig::Keyframe keyframe(row[model.keyframe]);
        if(description!=keyframe.get_description())
@@ -262,7 +254,7 @@ KeyframeTree::on_event(GdkEvent *event)
                                )
                        ) break;
                        const Gtk::TreeRow row = *(get_model()->get_iter(path));
-                       
+
                        signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
                        if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
                        {
@@ -283,14 +275,14 @@ KeyframeTree::on_event(GdkEvent *event)
                                )
                        ) break;
                        const Gtk::TreeRow row = *(get_model()->get_iter(path));
-                       
+
                        {
                                keyframe_tree_store_->canvas_interface()->set_time(row[model.time]);
                                return true;
                        }
                }
                break;
-               
+
        case GDK_BUTTON_RELEASE:
                break;
        default: