Merge branch 'akagogo_svg' into genete_master
authorCarlos Lopez <carlos@pcnuevo.(none)>
Mon, 27 Jul 2009 15:04:14 +0000 (17:04 +0200)
committerCarlos Lopez <carlos@pcnuevo.(none)>
Mon, 27 Jul 2009 15:04:14 +0000 (17:04 +0200)
17 files changed:
.gitignore
synfig-core/trunk/Makefile.am
synfig-core/trunk/build_tools/Makefile.am [new file with mode: 0644]
synfig-core/trunk/build_tools/autorevision.sh [new file with mode: 0644]
synfig-core/trunk/configure.ac
synfig-core/trunk/src/tool/main.cpp
synfig-studio/trunk/build_tools/autorevision.sh
synfig-studio/trunk/src/gtkmm/Makefile.am
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/canvasview.h
synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp
synfig-studio/trunk/src/gtkmm/dock_timetrack.h
synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp [new file with mode: 0644]
synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h [new file with mode: 0644]
synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp
synfig-studio/trunk/src/synfigapp/actions/keyframesetdelta.cpp
synfig-studio/trunk/synfigstudio-cph-monitor [new file with mode: 0755]

index 36dc72b..e990be0 100644 (file)
@@ -64,6 +64,7 @@ synfig-core/trunk/src/synfig/proto/nodebase.h
 synfig-core/trunk/src/tool/synfig
 synfig-core/trunk/synfig.pc.in
 
+synfig-core/trunk/autorevision.h
 synfig-core/trunk/m4/codeset.m4
 synfig-core/trunk/m4/gettext.m4
 synfig-core/trunk/m4/glibc2.m4
index bb201ca..22ad14d 100644 (file)
@@ -43,6 +43,7 @@ MAINTAINERCLEANFILES = \
 
 SUBDIRS = \
        libltdl \
+       build_tools \
        src \
        examples \
        po
diff --git a/synfig-core/trunk/build_tools/Makefile.am b/synfig-core/trunk/build_tools/Makefile.am
new file mode 100644 (file)
index 0000000..29b053f
--- /dev/null
@@ -0,0 +1,8 @@
+dist_noinst_SCRIPTS = autorevision.sh
+
+all-local:
+       sh $(srcdir)/autorevision.sh "$(top_srcdir)" "$(top_builddir)"
+
+clean-local:
+       -rm -f $(top_builddir)/autorevision.h
+
diff --git a/synfig-core/trunk/build_tools/autorevision.sh b/synfig-core/trunk/build_tools/autorevision.sh
new file mode 100644 (file)
index 0000000..c8f4cf2
--- /dev/null
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+# Copyright 2008 Paul Wise
+# Copyright 2009 Konstantin Dmitriev
+#
+# 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.
+
+get_git_id(){
+       export SCM=git
+       export REVISION_ID=`cd "$1"; git log --no-color -1 | head -n 1 | cut -f 2 -d ' '`
+       export BRANCH="`cd "$1"; git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
+       if ( echo $BRANCH | egrep origin/master > /dev/null ); then
+               #give a priority to master branch
+               BRANCH='master'
+       else
+               BRANCH=`echo $BRANCH | cut -d ' ' -f 1`
+               BRANCH=${BRANCH##*/}
+       fi
+       export REVISION=`git show --pretty=format:%ci HEAD |  head -c 10 | tr -d '-'`
+       export COMPARE=`git rev-parse --git-dir`
+       # The extra * at the end is for Modified
+       #REVISION="$REVISION"`cd "$1"; [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"`
+}
+
+get_git_svn_id(){
+       export SCM=git-svn
+       export REVISION=`cd "$1"; git svn find-rev HEAD`
+       export COMPARE="$1/.git/"
+       if [ x = "x$REVISION" ] ; then
+               # The extra M at the end is for Modified
+               export REVISION=`cd "$1"; git svn find-rev \`git rev-list --max-count=1 --grep='git-svn-id: ' HEAD\``M
+       else
+               export REVISION="$REVISION"`cd "$1"; git diff --quiet HEAD || echo M`
+       fi
+}
+
+get_svn_id(){
+       export SCM=svn
+       export REVISION=`cd "$1"; svnversion || svn info | sed -n 's/^Revision: \(.*\)/\1/p'`
+}
+
+
+HEADER="$2/autorevision.h"
+SCM=none
+
+
+if [ ! -f "$HEADER" ] ; then
+       touch -t 197001010101 "$HEADER"
+fi
+
+
+# Extract the revision from SVN/git/etc
+if git rev-parse --git-dir > /dev/null  2>&1 ; then
+       get_git_id "."
+elif [ -d "$1/.git/svn" ] ; then
+       get_git_svn_id "$1"
+elif [ -d "$1/../.git/svn" ] ; then
+       get_git_svn_id "$1/.."
+elif [ -d "$1/../../.git/svn" ] ; then
+       get_git_svn_id "$1/../.."
+elif [ -d "$1/.svn" ] ; then
+       COMPARE="$1/.svn"
+       get_svn_id "$1"
+elif [ -d "$1/_svn" ] ; then
+       COMPARE="$1/_svn"
+       get_svn_id "$1"
+fi
+
+
+# Allow overriding both REVISION and DEVEL_VERSION
+if [ -f "$2/autorevision.conf" ] ; then
+       SCM=manual
+       . "$2/autorevision.conf"
+fi
+
+
+# Abort if the header is newer
+if [ "$COMPARE" -ot "$HEADER" ] ; then exit; fi
+
+# Set the development version string
+if [ x = "x$DEVEL_VERSION" ] ; then
+       if [ x != "x$REVISION" ] ; then
+               if [ $SCM = svn ] ; then
+                       DEVEL_VERSION="SVN r$REVISION"
+               elif [ $SCM = git-svn ] ; then
+                       DEVEL_VERSION="SVN r$REVISION (via git)"
+               elif [ $SCM = git ] ; then
+                       DEVEL_VERSION="Revision: ${REVISION}\\\\nBranch: ${BRANCH}\\\\nRevision ID: ${REVISION_ID}"
+               elif [ $SCM = manual ] ; then
+                       DEVEL_VERSION="$REVISION (manually configured)"
+               fi
+       fi
+fi
+
+
+# Output the header
+if [ x != "x$DEVEL_VERSION" ] ; then
+       printf "#define DEVEL_VERSION \"$DEVEL_VERSION\"\n" > "$HEADER"
+fi
index c75e817..3f1b7b6 100644 (file)
@@ -651,6 +651,7 @@ synfigincludedir=$includedir/synfig-$API_VERSION
 AC_SUBST(synfigincludedir)
 
 AC_CONFIG_FILES([synfig-config
+build_tools/Makefile
 synfig.pc
 doxygen.cfg
 Makefile
index 38a7c64..fbf64b0 100644 (file)
@@ -50,6 +50,7 @@
 #include <synfig/paramdesc.h>
 #include <synfig/main.h>
 #include <synfig/guid.h>
+#include <autorevision.h>
 #endif
 
 using namespace std;
@@ -396,6 +397,9 @@ int process_global_flags(arg_list_t &arg_list)
                if(*iter == "--info")
                {
                        cout<<PACKAGE"-"VERSION<<endl;
+                       #ifdef DEVEL_VERSION
+                               cout<<endl<<DEVEL_VERSION<<endl<<endl;
+                       #endif
                        cout<<"Compiled on "__DATE__ /* " at "__TIME__ */;
 #ifdef __GNUC__
                        cout<<" with GCC "<<__VERSION__;
@@ -406,7 +410,6 @@ int process_global_flags(arg_list_t &arg_list)
 #ifdef __TCPLUSPLUS__
                        cout<<" with Borland Turbo C++ "<<(__TCPLUSPLUS__>>8)<<'.'<<((__TCPLUSPLUS__&255)>>4)<<'.'<<(__TCPLUSPLUS__&15);
 #endif
-
                        cout<<endl<<SYNFIG_COPYRIGHT<<endl;
                        cout<<endl;
                        return SYNFIGTOOL_HELP;
index 3de1b2b..d8a5c8b 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 # Copyright 2008 Paul Wise
+# Copyright 2009 Konstantin Dmitriev
 #
 # This package is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 # General Public License for more details.
 
+get_git_id(){
+       export SCM=git
+       export REVISION_ID=`cd "$1"; git log --no-color -1 | head -n 1 | cut -f 2 -d ' '`
+       export BRANCH="`cd "$1"; git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
+       if ( echo $BRANCH | egrep origin/master > /dev/null ); then
+               #give a priority to master branch
+               BRANCH='master'
+       else
+               BRANCH=`echo $BRANCH | cut -d ' ' -f 1`
+               BRANCH=${BRANCH##*/}
+       fi
+       export REVISION=`git show --pretty=format:%ci HEAD |  head -c 10 | tr -d '-'`
+       export COMPARE=`git rev-parse --git-dir`
+       # The extra * at the end is for Modified
+       #REVISION="$REVISION"`cd "$1"; [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"`
+}
 
 get_git_svn_id(){
        export SCM=git-svn
@@ -41,7 +58,9 @@ fi
 
 
 # Extract the revision from SVN/git/etc
-if [ -d "$1/.git/svn" ] ; then
+if git rev-parse --git-dir > /dev/null  2>&1 ; then
+       get_git_id "."
+elif [ -d "$1/.git/svn" ] ; then
        get_git_svn_id "$1"
 elif [ -d "$1/../.git/svn" ] ; then
        get_git_svn_id "$1/.."
@@ -66,7 +85,6 @@ fi
 # Abort if the header is newer
 if [ "$COMPARE" -ot "$HEADER" ] ; then exit; fi
 
-
 # Set the development version string
 if [ x = "x$DEVEL_VERSION" ] ; then
        if [ x != "x$REVISION" ] ; then
@@ -74,6 +92,8 @@ if [ x = "x$DEVEL_VERSION" ] ; then
                        DEVEL_VERSION="SVN r$REVISION"
                elif [ $SCM = git-svn ] ; then
                        DEVEL_VERSION="SVN r$REVISION (via git)"
+               elif [ $SCM = git ] ; then
+                       DEVEL_VERSION="Revision: ${REVISION}\\\\nBranch: ${BRANCH}\\\\nRevision ID: ${REVISION_ID}"
                elif [ $SCM = manual ] ; then
                        DEVEL_VERSION="$REVISION (manually configured)"
                fi
@@ -83,6 +103,6 @@ fi
 
 # Output the header
 if [ x != "x$DEVEL_VERSION" ] ; then
-       echo "#define SHOW_EXTRA_INFO" > "$HEADER"
-       echo "#define DEVEL_VERSION \"$DEVEL_VERSION\"" >> "$HEADER"
+       printf "#define SHOW_EXTRA_INFO\n" > "$HEADER"
+       printf "#define DEVEL_VERSION \"$DEVEL_VERSION\"\n" >> "$HEADER"
 fi
index 1be3e71..c5cc73d 100644 (file)
@@ -138,7 +138,8 @@ WIDGET_HH = \
        widget_value.h \
        widget_vector.h \
        widget_waypoint.h \
-       widget_waypointmodel.h
+       widget_waypointmodel.h \
+       widget_keyframe_list.h
 
 WIDGET_CC = \
        widget_canvaschooser.cpp \
@@ -157,7 +158,8 @@ WIDGET_CC = \
        widget_value.cpp \
        widget_vector.cpp \
        widget_waypoint.cpp \
-       widget_waypointmodel.cpp
+       widget_waypointmodel.cpp \
+       widget_keyframe_list.cpp
 
 
 STATE_HH = \
index a76b1a0..53a6ccc 100644 (file)
@@ -690,6 +690,7 @@ CanvasView::CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigap
        statusbar                               (manage(new class Gtk::Statusbar())),
 
        timeslider                              (new Widget_Timeslider),
+       widget_kf_list                  (new Widget_Keyframe_List),
 
        ui_interface_                   (new CanvasViewUIInterface(this)),
        selection_manager_              (new CanvasViewSelectionManager(this)),
@@ -966,6 +967,10 @@ CanvasView::create_time_bar()
        timeslider->set_time_adjustment(&time_adjustment());
        timeslider->set_bounds_adjustment(&time_window_adjustment());
        //layout_table->attach(*timeslider, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
+       //Setup the keyframe list widget
+       widget_kf_list->set_time_adjustment(&time_adjustment());
+       widget_kf_list->set_canvas_interface(canvas_interface());
+       widget_kf_list->show();
 
        tooltips.set_tip(*time_window_scroll,_("Moves the time window"));
        tooltips.set_tip(*timeslider,_("Changes the current time"));
@@ -1033,16 +1038,26 @@ CanvasView::create_time_bar()
        keyframedial->show();
        keyframebutton=keyframedial->get_lock_button();
 
-       timebar = manage(new class Gtk::Table(5, 4, false));
+       timebar = Gtk::manage(new class Gtk::Table(5, 4, false));
+
+       //Adjust both widgets to be the same as the
+       int header_height = 0;
+       if(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"))
+               header_height = atoi(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"));
+       if (header_height < 3)
+               header_height = 24;
+       timeslider->set_size_request(-1,header_height-header_height/3+1);
+       widget_kf_list->set_size_request(-1,header_height/3+1);
 
        //Attach widgets to the timebar
-       timebar->attach(*manage(disp_audio), 1, 5, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-       timebar->attach(*framedial, 0, 1, 2, 3,Gtk::SHRINK, Gtk::SHRINK);
-       timebar->attach(*current_time_widget, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       timebar->attach(*timeslider, 1, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       //timebar->attach(*manage(disp_audio), 1, 5, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       timebar->attach(*current_time_widget, 0, 1, 0, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       timebar->attach(*framedial, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+       timebar->attach(*timeslider, 1, 3, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::SHRINK);
+       timebar->attach(*widget_kf_list, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
        timebar->attach(*time_window_scroll, 1, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-       timebar->attach(*keyframedial, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
-       timebar->attach(*animatebutton, 4, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
+       timebar->attach(*keyframedial, 3, 4, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
+       timebar->attach(*animatebutton, 4, 5, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
        //timebar->attach(*keyframebutton, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
 
        timebar->show();
index a33fb26..cddcbe2 100644 (file)
@@ -70,6 +70,7 @@
 #include "framedial.h"
 #include "toggleducksdial.h"
 #include "resolutiondial.h"
+#include "widget_keyframe_list.h"
 
 #include "duckmatic.h"
 #include <gtkmm/scale.h>
@@ -294,6 +295,9 @@ private:
        //! Time slider class. Same than the Time track panel
        std::auto_ptr<Widget_Timeslider> timeslider;
 
+       //!Keyframe list slider
+       std::auto_ptr<Widget_Keyframe_List> widget_kf_list;
+
        std::list<sigc::connection> duck_changed_connections;
 
 /*     DEBUGPOINT_CLASS(8);
index a0f7fca..7a6139a 100644 (file)
@@ -43,6 +43,7 @@
 #include "layerparamtreestore.h"
 #include "workarea.h"
 #include "widget_timeslider.h"
+#include "widget_keyframe_list.h"
 #include "layerparamtreestore.h"
 #include "general.h"
 #include <synfig/timepointcollect.h>
@@ -405,14 +406,17 @@ Dock_Timetrack::Dock_Timetrack():
 {
        table_=0;
        widget_timeslider_= new Widget_Timeslider();
+       widget_kf_list_= new Widget_Keyframe_List();
 
        int header_height = 0;
        if(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"))
                header_height = atoi(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"));
        if (header_height < 3)
-               header_height = 22;
+               header_height = 24;
+
+       widget_timeslider_->set_size_request(-1,header_height-header_height/3+1);
+       widget_kf_list_->set_size_request(-1,header_height/3+1);
 
-       widget_timeslider_->set_size_request(-1,header_height);
        hscrollbar_=new Gtk::HScrollbar();
        vscrollbar_=new Gtk::VScrollbar();
 }
@@ -423,6 +427,7 @@ Dock_Timetrack::~Dock_Timetrack()
        delete hscrollbar_;
        delete vscrollbar_;
        delete widget_timeslider_;
+       delete widget_kf_list_;
 }
 
 void
@@ -493,17 +498,22 @@ Dock_Timetrack::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_v
 
                assert(tree_view);
 
+
                widget_timeslider_->set_time_adjustment(&canvas_view->time_adjustment());
                widget_timeslider_->set_bounds_adjustment(&canvas_view->time_window_adjustment());
                widget_timeslider_->set_global_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
 
+               widget_kf_list_->set_time_adjustment(&canvas_view->time_adjustment());
+               widget_kf_list_->set_canvas_interface(canvas_view->canvas_interface());
+
                vscrollbar_->set_adjustment(*tree_view->get_vadjustment());
                hscrollbar_->set_adjustment(canvas_view->time_window_adjustment());
-               table_=new Gtk::Table(2,2);
-               table_->attach(*widget_timeslider_, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*tree_view, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-               table_->attach(*hscrollbar_, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*vscrollbar_, 1, 2, 0, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
+               table_=new Gtk::Table(2,3);
+               table_->attach(*widget_timeslider_, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*widget_kf_list_, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*tree_view, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+               table_->attach(*hscrollbar_, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*vscrollbar_, 1, 2, 0, 3, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
                add(*table_);
 
                //add(*last_widget_curves_);
index d103d9a..9da19fd 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2009 Carlos López
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
 
 namespace studio {
 class Widget_Timeslider;
+class Widget_Keyframe_List;
 
 class Dock_Timetrack : public Dock_CanvasSpecific
 {
        Gtk::HScrollbar* hscrollbar_;
        Gtk::VScrollbar* vscrollbar_;
        Widget_Timeslider* widget_timeslider_;
+       Widget_Keyframe_List* widget_kf_list_;
        Gtk::Table* table_;
 
 protected:
@@ -59,7 +62,7 @@ public:
 
        Dock_Timetrack();
        ~Dock_Timetrack();
-}; // END of Dock_Keyframes
+}; // END of Dock_Timetrack
 
 }; // END of namespace studio
 
diff --git a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp
new file mode 100644 (file)
index 0000000..ace2b98
--- /dev/null
@@ -0,0 +1,425 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_keyframe_list.cpp
+**     \brief A custom widget to manage keyframes in the timeline.
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2009 Carlos López
+**
+**     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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "widget_keyframe_list.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <synfig/exception.h>
+#include <ETL/misc>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+
+/* === M A C R O S ========================================================= */
+#define WIDGET_KEYFRAME_LIST_DEFAULT_FPS 24.0
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Keyframe_List::Widget_Keyframe_List():
+       adj_default(0,0,2,1/WIDGET_KEYFRAME_LIST_DEFAULT_FPS,10/WIDGET_KEYFRAME_LIST_DEFAULT_FPS),
+       kf_list_(&default_kf_list_),
+       time_ratio("4f", WIDGET_KEYFRAME_LIST_DEFAULT_FPS)
+{
+       adj_timescale=0;
+       editable_=true;
+       fps=WIDGET_KEYFRAME_LIST_DEFAULT_FPS;
+       set_size_request(-1,64);
+       //!This signal is called when the widget need to be redrawn
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Keyframe_List::redraw));
+       //! The widget respond to mouse button press and release and to
+       //! left button motion
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK /*| Gdk::BUTTON3_MOTION_MASK*/);
+       add_events(Gdk::POINTER_MOTION_MASK);
+       set_time_adjustment(&adj_default);
+       queue_draw();
+}
+
+Widget_Keyframe_List::~Widget_Keyframe_List()
+{
+}
+
+bool
+Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/)
+{
+
+       const int h(get_height());
+       const int w(get_width());
+
+       //!Boundaries of the drawing area in time units.
+       synfig::Time top(adj_timescale->get_upper());
+       synfig::Time bottom(adj_timescale->get_lower());
+
+       //! The graphic context
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+       //! A rectangle that defines the drawing area.
+       Gdk::Rectangle area(0,0,w,h);
+
+       //! draw a background
+       gc->set_rgb_fg_color(Gdk::Color("#9d9d9d"));
+       get_window()->draw_rectangle(gc, true, 0, 0, w, h);
+
+       if(!editable_)
+       {
+               return true; //needs fixing!
+       }
+       //!Returns if there are not keyframes to draw.
+       if (kf_list_->empty()) return false;
+
+       //!Loop all the keyframes
+       synfig::KeyframeList::iterator iter,selected_iter;
+       bool show_selected(false);
+       for(iter=kf_list_->begin();iter!=kf_list_->end();iter++)
+       {
+               //!do not draw keyframes out of the widget boundaries
+               if (iter->get_time()>top || iter->get_time()<bottom)
+                       continue;
+               //! If the keyframe is not the selected one
+               if(*iter!=selected_kf)
+               {
+                       const int x((int)((float)(iter->get_time()-bottom) * (w/(top-bottom)) ) );
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_NORMAL,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2+1, 0, h, h );
+               }
+               else
+               {
+                       selected_iter=iter;
+                       show_selected=true;
+               }
+       }
+
+       // we do this so that we can be sure that
+       // the selected keyframe is shown on top
+       if(show_selected)
+       {
+               // If not dragging just show the selected keyframe
+               if (!dragging_)
+               {
+                       int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2+1, 0, h, h );
+               }
+               // If dragging then show the selected as insensitive and the
+               // dragged as selected
+               else
+               {
+                       int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_INSENSITIVE,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2, 0, h, h );
+                       x=(int)((float)(dragging_kf_time-bottom) * (w/(top-bottom)) ) ;
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2+1, 0, h, h );
+               }
+       }
+       return true;
+}
+
+
+void
+Widget_Keyframe_List::set_kf_list(synfig::KeyframeList* x)
+{
+       kf_list_=x;
+       set_selected_keyframe(selected_none);
+       selected_=false;
+       dragging_=false;
+}
+
+void
+Widget_Keyframe_List::set_selected_keyframe(const synfig::Keyframe &x)
+{
+       selected_kf=x;
+       selected_=true;
+       dragging_kf_time=selected_kf.get_time();
+       //signal_keyframe_selected_(selected_kf);
+       dragging_=false;
+       queue_draw();
+}
+
+bool
+Widget_Keyframe_List::perform_move_kf(bool delta=false)
+{
+       if(!selected_)
+               return false;
+       if(dragging_kf_time == selected_kf.get_time())
+               return false; // change this checking if not sticked to integer frames
+       Time selected_kf_time(selected_kf.get_time());
+       Time prev, next;
+       kf_list_->find_prev_next(selected_kf_time, prev, next);
+       // Not possible to set delta to the first keyframe
+       // perform normal movement
+       // As suggested by Zelgadis it is better to not perform anything.
+       if (prev==Time::begin() && delta==true)
+       {
+               synfig::info(_("Not possible to ALT-drag the first keyframe"));
+               return false;
+       }
+       if(!delta)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
+                       if(!action)
+                       return false;
+                       selected_kf.set_time(dragging_kf_time);
+                       action->set_param("canvas",canvas_interface_->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface_);
+                       action->set_param("keyframe",selected_kf);
+                       try
+                       {
+                               canvas_interface_->get_instance()->perform_action(action);
+                       }
+                       catch(...)
+                       {
+                               return false;
+                       }
+               }
+       else
+               {
+                       Keyframe prev_kf(*kf_list_->find_prev(selected_kf_time));
+                       Time prev_kf_time(prev_kf.get_time());
+                       if (prev_kf_time >= dragging_kf_time) //Not allowed
+                       {
+                               synfig::warning(_("Delta set not allowed"));
+                               synfig::info(_("Widget_Keyframe_List::perform_move_kf(%i)::prev_kf_time=%s"), delta, prev_kf_time.get_string().c_str());
+                               synfig::info(_("Widget_Keyframe_List::perform_move_kf(%i)::dragging_kf_time=%s"), delta, dragging_kf_time.get_string().c_str());
+                               return false;
+                       }
+                       else
+                       {
+                               Time old_delta_time(selected_kf_time-prev_kf_time);
+                               Time new_delta_time(dragging_kf_time-prev_kf_time);
+                               Time change_delta(new_delta_time-old_delta_time);
+                               synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
+                               if(!action)
+                                       return false;
+                               action->set_param("canvas",canvas_interface_->get_canvas());
+                               action->set_param("canvas_interface",canvas_interface_);
+                               action->set_param("keyframe",prev_kf);
+                               action->set_param("delta",change_delta);
+                               canvas_interface_->get_instance()->perform_action(action);
+                       }
+               }
+       queue_draw();
+       return true;
+}
+
+bool
+Widget_Keyframe_List::on_event(GdkEvent *event)
+{
+       const int x(static_cast<int>(event->button.x));
+       //const int y(static_cast<int>(event->button.y));
+       //!Boundaries of the drawing area in time units.
+       synfig::Time top(adj_timescale->get_upper());
+       synfig::Time bottom(adj_timescale->get_lower());
+       //!pos is the [0,1] relative horizontal place on the widget
+       float pos((float)x/(get_width()));
+       if(pos<0.0f)pos=0.0f;
+       if(pos>1.0f)pos=1.0f;
+       //! The time where the event x is
+       synfig::Time t((float)(bottom+pos*(top-bottom)));
+       //Do not respond mouse events if the list is empty
+       if(!kf_list_->size())
+               return true;
+
+       //! here the guts of the event
+       switch(event->type)
+       {
+       case GDK_MOTION_NOTIFY:
+               if(editable_)
+               {
+                       // here is captured mouse motion
+                       // AND left or right mouse button pressed
+                       if (event->motion.state & (GDK_BUTTON1_MASK /*| GDK_BUTTON3_MASK*/))
+                       {
+                               // stick to integer frames. It can be optional in the future
+                               if(fps) t = floor(t*fps + 0.5)/fps;
+                               dragging_kf_time=t;
+                               dragging_=true;
+                               queue_draw();
+                               return true;
+                       }
+                       // here is captured mouse motion
+                       // AND NOT left or right mouse button pressed
+                       else
+                       {
+                               Glib::ustring ttip="";
+                               synfig::Time p_t,n_t;
+                               kf_list_->find_prev_next(t, p_t, n_t);
+                               if( (p_t==Time::begin()         &&      n_t==Time::end())
+                               ||
+                               ((t-p_t)>time_ratio     && (n_t-t)>time_ratio)
+                               )
+                               {
+                                       ttip = _("Click and drag keyframes");
+                               }
+                               else if ((t-p_t)<(n_t-t))
+                               {
+                                       synfig::Keyframe kf(*kf_list_->find_prev(t));
+                                       synfig::String kf_name(kf.get_description().c_str());
+                                       ttip = kf_name.c_str();
+                               }
+                               else
+                               {
+                                       synfig::Keyframe kf(*kf_list_->find_next(t));
+                                       synfig::String kf_name(kf.get_description().c_str());
+                                       ttip = kf_name.c_str();
+                               }
+                               tooltips.set_tip(*this, ttip);
+                               dragging_=false;
+                               queue_draw();
+                               return true;
+                       }
+               }
+               break;
+       case GDK_BUTTON_PRESS:
+               changed_=false;
+               dragging_=false;
+               if(event->button.button==1 /*|| event->button.button==3*/)
+               {
+                       if(editable_)
+                       {
+                               synfig::Time prev_t,next_t;
+                               kf_list_->find_prev_next(t, prev_t, next_t);
+                               if( (prev_t==Time::begin()      &&      next_t==Time::end())
+                               ||
+                               ((t-prev_t)>time_ratio  && (next_t-t)>time_ratio)
+                               )
+                               {
+                                       set_selected_keyframe(selected_none);
+                                       selected_=false;
+                                       queue_draw();
+                               }
+                               else if ((t-prev_t)<(next_t-t))
+                               {
+                                       set_selected_keyframe(*(kf_list_->find_prev(t)));
+                                       queue_draw();
+                                       selected_=true;
+                               }
+                               else
+                               {
+                                       set_selected_keyframe(*(kf_list_->find_next(t)));
+                                       queue_draw();
+                                       selected_=true;
+                               }
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+
+               break;
+       case GDK_BUTTON_RELEASE:
+               if(editable_ && (event->button.button==1 /*|| event->button.button==3*/))
+               {
+                       // stick to integer frames.
+                       if(fps) t = floor(t*fps + 0.5)/fps;
+                       bool stat=false;
+                       if(dragging_)
+                               {
+                                       //if (event->button.button==3)
+                                       if(event->button.state & GDK_MOD1_MASK)
+                                       {
+                                               stat=perform_move_kf(true);
+                                       }
+                                       else
+                                       {
+                                               stat=perform_move_kf(false);
+                                       }
+                               }
+                       dragging_=false;
+                       return stat;
+               }
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+
+void Widget_Keyframe_List::set_time_adjustment(Gtk::Adjustment *x)
+{
+       //disconnect old connections
+       time_value_change.disconnect();
+       time_other_change.disconnect();
+
+       //connect update function to new adjustment
+       adj_timescale = x;
+
+       if(x)
+       {
+               time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
+               time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
+       }
+}
+
+void
+Widget_Keyframe_List::set_fps(float d)
+{
+       if(fps != d)
+       {
+               fps = d;
+               //update everything since we need to redraw already
+               queue_draw();
+       }
+}
+
+void
+Widget_Keyframe_List::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
+{
+       canvas_interface_=h;
+       // Store the values used fomr the canvas interface.
+       if (canvas_interface_)
+       {
+               set_fps(canvas_interface_->get_canvas()->rend_desc().get_frame_rate());
+               set_kf_list(&canvas_interface_->get_canvas()->keyframe_list());
+       }
+}
+
+
diff --git a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h
new file mode 100644 (file)
index 0000000..1e41770
--- /dev/null
@@ -0,0 +1,150 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_keyframe_list.h
+**     \brief A custom widget to manage keyframes in the timeline.
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2009 Carlos López
+**
+**     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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
+#define __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/tooltips.h>
+#include <synfig/keyframe.h>
+#include <sigc++/connection.h>
+#include <synfigapp/canvasinterface.h>
+
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace studio {
+
+class Widget_Keyframe_List : public Gtk::DrawingArea
+{
+       //! Tooltips class. It is deprecated since gtkmm 2.12
+       //! replace with Tooltip class or use the own tooltip widget's members
+       Gtk::Tooltips tooltips;
+
+       //! The canvas interface being watched
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       //! Time adjustment window
+       Gtk::Adjustment adj_default;
+       Gtk::Adjustment *adj_timescale;
+
+       //!The list of keyframes to be drawn on the widget and moved with mouse
+       synfig::KeyframeList default_kf_list_;
+       mutable synfig::KeyframeList* kf_list_;
+
+       //! The frames per second of the canvas
+       float fps;
+
+       //! Time radius to click a keyframe
+       synfig::Time time_ratio;
+
+       //!True if it is editable. Keyframes can be moved.
+       bool editable_;
+
+       //!True if a keyframe is being dragged.
+       bool dragging_;
+
+       //!True if a keyframe has been moved
+       bool changed_;
+
+       //!Holds the selected keyframe of the keyframe list
+       synfig::Keyframe selected_kf;
+       synfig::Keyframe selected_none;
+       bool selected_;
+
+       //!The time of the selected keyframe
+       synfig::Time selected_kf_time;
+
+       //!The time of the selected keyframe during draging
+       synfig::Time dragging_kf_time;
+
+       //!Connectors for handling the signals of the time adjustment
+       sigc::connection time_value_change;
+       sigc::connection time_other_change;
+
+public:
+
+       //!Default constructor
+       Widget_Keyframe_List();
+
+       //!Destructror
+       ~Widget_Keyframe_List();
+
+       //!Loads a new keyframe list on the widget.
+       void set_kf_list(synfig::KeyframeList* x);
+
+       //!Member for private data.
+       synfig::KeyframeList* get_kf_list()const { return kf_list_; }
+
+       //!Member for private data
+       void set_editable(bool x=true) { editable_=x; }
+
+       //!Member for private data
+       bool get_editable()const { return editable_; }
+
+
+       //!Store the selected keyframe value
+       void set_selected_keyframe(const synfig::Keyframe &x);
+
+       //!Returns the selected keyframe
+       const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
+
+       //! Set the time adjustment and proper connects its change signals
+       void set_time_adjustment(Gtk::Adjustment *x);
+
+       //! Set the fps
+       void set_fps(float x);
+
+       //! Set the canvas interface
+       void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
+
+       //! Performs the keyframe movement. Returns true if it was sucessful
+       //! @return true: if success otherwise false
+       //! |delta=false: permorm normal move. true: perform delta movement
+       bool perform_move_kf(bool delta);
+
+
+
+/* ======================= EVENTS HANDLERS ===========================*/
+       //!Redraw event. Should draw all the keyframes +  the selected + the dragged
+       bool redraw(GdkEventExpose*bleh=NULL);
+
+       //!Mouse event handler.
+       bool on_event(GdkEvent *event);
+}; // END of class Keyframe_List
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
index ba57435..ed5d63c 100644 (file)
@@ -576,7 +576,17 @@ bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
 
                        //gc->set_rgb_fg_color(Gdk::Color("#000000"));
                        layout->set_text(timecode);
-                       window->draw_layout(gc,xpx+2,heightsmall,layout);
+                       Pango::AttrList attr_list;
+                       // Aproximately a font size of 8 pixels.
+                       // Pango::SCALE = 1024
+                       // create_attr_size waits a number in 1000th of pixels.
+                       // Should be user customizable in the future. Now it is fixed to 10
+                       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10));
+                       pango_size.set_start_index(0);
+                       pango_size.set_end_index(64);
+                       attr_list.change(pango_size);
+                       layout->set_attributes(attr_list);
+                       window->draw_layout(gc,xpx+2,0,layout);
                }else
                {
                        window->draw_line(gc,xpx,0,xpx,heightsmall);
index 97898c3..6cd262a 100644 (file)
@@ -178,7 +178,10 @@ Action::KeyframeSetDelta::perform()
 
 //     Time location(keyframe.get_time());
        Time location(get_canvas()->keyframe_list().find(keyframe)->get_time());
-       Time delta(delta);
+//     This line sets delta to 0s regardless to any previous value of delta.
+//     I think it was here for symmetry to the undo() operation.
+//     It was causing that the Set delta operation was faulty. Now works!
+//     Time delta(delta);
 
        get_canvas()->keyframe_list().insert_time(location,delta);
 
diff --git a/synfig-studio/trunk/synfigstudio-cph-monitor b/synfig-studio/trunk/synfigstudio-cph-monitor
new file mode 100755 (executable)
index 0000000..6dcc2bc
--- /dev/null
@@ -0,0 +1,163 @@
+#!/bin/bash
+
+# Synfig Crash Monitor script
+# Copyright (c) 2009 Konstantin Dmitriev
+#      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.
+
+set -e
+trap writelog INT
+
+init()
+{
+echo "SynfigStudio Crash Monitor is a tool to collect statistics about synfig crashes."
+echo "All information is collected locally in ~/.synfig/cph directory."
+echo
+STARTED=0
+RUNTIME=0
+VERSION=''
+RELEASE=''
+BRANCH=''
+REVISION_ID=''
+CRASH=0
+[ ! -d ~/.synfig/cph ] && mkdir -p ~/.synfig/cph || true
+
+# Detect if crash monitor is already started
+PDIR=${0%`basename $0`}
+LCK_FILE=~/.synfig/cph/`basename $0`.lck
+if [ -f "${LCK_FILE}" ]; then
+       MYPID=`head -n 1 "${LCK_FILE}"`
+       if ! ( ps -p ${MYPID} | grep ${MYPID} >/dev/null ); then
+               # The process is not running
+               # Echo current PID into lock file
+               echo $$ > "${LCK_FILE}"
+       else
+               echo "`basename $0` is already running [${MYPID}]. Aborting."
+               sleep 5
+               exit 0
+       fi
+else
+       # The process is not running
+       # Echo current PID into lock file
+       echo $$ > "${LCK_FILE}"
+fi
+echo `date +%H:%M` "Synfig Crash Monitor started."
+}
+
+writelog()
+{
+       if [[ $STARTED != 0 ]]; then
+               if [[ $CRASH == 0 ]]; then
+                       echo `date +%H:%M` "Synfig exited normally. Session time: $RUNTIME."
+               else
+                       echo `date +%H:%M` "Crash detected. Version $VERSION.$RELEASE.$BRANCH, session time: $RUNTIME."
+               fi
+               if [ -e ~/.synfig/cph/log ]; then
+                       #check if dump needed
+                       CURRENTDATE=`date +%Y-%m-%d`
+                       LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
+                       LOGMODDATE=${LOGMODDATE%% *}
+                       if [[ $LOGMODDATE != $CURRENTDATE ]]; then
+                               dumpstats
+                       fi
+               fi
+               #write log
+               echo $VERSION/$BRANCH/$RELEASE/$REVISION_ID $RUNTIME $CRASH >> ~/.synfig/cph/log
+               CRASH=0
+               RUNTIME=0
+       else
+               echo
+       fi
+}
+
+dumpstats()
+{
+       echo `date +%H:%M` 'Dumping stats for previous session...'
+       LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
+       LOGMODDATE=${LOGMODDATE%% *}
+       #get versions
+       VERSIONS=''
+       while read LINE; do
+               FOUND=0
+               for VER in $VERSIONS; do
+                       if [[ $VER == ${LINE%% *} ]]; then
+                               FOUND=1
+                               break
+                       fi
+               done
+               [[ $FOUND == 0 ]] && VERSIONS="$VERSIONS ${LINE%% *}"
+       done < ~/.synfig/cph/log
+       echo "   Logged versions: ${VERSIONS}"
+       for VER in $VERSIONS; do
+               #generating random record ID
+               ID=$( echo `date` `ps` | md5sum | md5sum )
+               ID="${ID:2:16}"
+               #summarizing time and counting crashes
+               CRASHCOUNT=0
+               TIMECOUNT=0
+               while read LINE; do
+                       if [[ ${LINE%% *} == $VER ]]; then
+                               TIMECOUNT=`expr $TIMECOUNT + $(echo $LINE| cut -f 2 -d ' ')` || true
+                               CRASHCOUNT=`expr $CRASHCOUNT + $(echo $LINE| cut -f 3 -d ' ')` || true
+                       fi
+               done < ~/.synfig/cph/log
+               echo "   $LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT"
+               echo "$LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT" >> ~/.synfig/cph/stats
+       done
+       rm -f ~/.synfig/cph/log
+       echo '   Done.'
+}
+
+mainloop()
+{
+       while true; do
+               if ( ps --no-headers -f -Csynfigstudio |egrep "^`whoami`" > /dev/null ) ; then
+                       #synfigstudio process exist
+                       if [[ $STARTED == 0 ]]; then
+                               STARTED=1
+                               RUNTIME=0
+                               #get version
+                               P=$(ps --no-headers -f -Csynfigstudio |egrep "^`whoami`" | tr -s ' '| cut -d ' ' -f 8)
+                               echo 
+                               if [ ! -e $P ]; then
+                                       P=`which $P`
+                               fi
+                               P=`dirname $P`
+                               VERSION=`$P/synfig --info|head -n 1|cut -d '-' -f 2`
+                               RELEASE=`$P/synfig --info|egrep "Revision:"|cut -d ' ' -f 2`
+                               BRANCH=`$P/synfig --info|egrep "Branch:"|cut -d ' ' -f 2-3`
+                               REVISION_ID=`$P/synfig --info|egrep "Revision ID:"|cut -d ' ' -f 3`
+                               if [[ $BRANCH == '(no branch)' ]]; then
+                                       BRANCH=$REVISION_ID
+                               fi
+                               echo `date +%H:%M` "Synfig $VERSION.$RELEASE.$BRANCH.$REVISION_ID started."
+                               echo `date +%H:%M` "Assuming Synfig installed in $P."
+                       else
+                               let RUNTIME=$RUNTIME+1
+                       fi
+               else
+                       #no synfigstudio process exist
+                       if [[ $STARTED == 1 ]]; then
+                               #detect crash
+                               if [ -e ~/.synfig/fifo ]; then
+                                       CRASH=1
+                               fi
+                               writelog
+                               CRASH=0
+                               STARTED=0
+                       fi
+               fi
+               sleep 1
+       done
+}
+
+
+init
+mainloop