Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / gtkmm / widget_time.cpp
index 634d880..2467c70 100644 (file)
@@ -1,20 +1,23 @@
-/* === S I N F G =========================================================== */
+/* === S Y N F I G ========================================================= */
 /*!    \file widget_time.cpp
 **     \brief Template File
 **
-**     $Id: widget_time.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
+**     $Id$
 **
 **     \legal
-**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
+**  Copyright (c) 2008 Paul Wise
 **
-**     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 "widget_time.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 ========================================================= */
 
-#if ! defined(_)
-#define _(x)   (x)
-#endif
-
 /* === G L O B A L S ======================================================= */
 
 /* === P R O C E D U R E S ================================================= */
@@ -74,13 +75,13 @@ Widget_Time::refresh_text()
 
 
 void
-Widget_Time::set_value(const sinfg::Time &data)
+Widget_Time::set_value(const synfig::Time &data)
 {
        time_=data;
        refresh_text();
 }
 
-sinfg::Time
+synfig::Time
 Widget_Time::get_value() const
 {
        return time_;
@@ -102,7 +103,7 @@ Widget_Time::refresh_value()
                if(abs(newtime-time_)>=0.001)
                {
                        time_=newtime;
-                       refresh_text();         
+                       refresh_text();
                        signal_value_changed()();
                }
        }
@@ -116,17 +117,17 @@ bool
 Widget_Time::on_event(GdkEvent* event)
 {
        const Time scroll_amount(0.25);
-       
+
        switch(event->type)
        {
        case GDK_SCROLL:
-               if(event->scroll.direction==GDK_SCROLL_DOWN)
+               if(event->scroll.direction==GDK_SCROLL_DOWN || event->scroll.direction==GDK_SCROLL_LEFT)
                {
                        time_-=scroll_amount;
                        refresh_text();
                        signal_value_changed()();
                }
-               else if(event->scroll.direction==GDK_SCROLL_UP)
+               else if(event->scroll.direction==GDK_SCROLL_UP || event->scroll.direction==GDK_SCROLL_RIGHT)
                {
                        time_+=scroll_amount;
                        refresh_text();
@@ -134,10 +135,16 @@ Widget_Time::on_event(GdkEvent* event)
                }
                return true;
                break;
+       case GDK_BUTTON_PRESS:
+       case GDK_2BUTTON_PRESS:
+       case GDK_3BUTTON_PRESS:
+               if (!has_focus())
+                       grab_focus();
+               break;
        default:
                break;
        }
-       
+
        return Gtk::Entry::on_event(event);
 }
 
@@ -145,13 +152,16 @@ bool
 Widget_Time::on_focus_out_event(GdkEventFocus* event)
 {
        refresh_value();
-       refresh_text();         
+       refresh_text();
        return Gtk::Entry::on_focus_out_event(event);
 }
 
 bool
 Widget_Time::on_focus_in_event(GdkEventFocus* event)
 {
-       set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
+       // if defined, show the full time format "0h 0m 5s 0f" when the time widget gets focus
+       if (getenv("SYNFIG_SHOW_FULL_TIME_ON_FOCUS"))
+               set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
+
        return Gtk::Entry::on_focus_in_event(event);
 }