Create a new Document tab in the Settings Dialog and move the preferred X and Y sizes...
[synfig.git] / synfig-studio / trunk / src / gtkmm / dialog_setup.cpp
index 88ca532..62ab267 100644 (file)
@@ -6,7 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
+**     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
 #include <gtkmm/notebook.h>
 #include <gtkmm/spinbutton.h>
 #include "widget_enum.h"
+#include "autorecover.h"
 
 #include <ETL/stringf>
 #include <ETL/misc>
+#include "general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -58,6 +61,14 @@ using namespace studio;
 
 /* === M E T H O D S ======================================================= */
 
+static void
+attach_label(Gtk::Table *table, String str, guint col, guint xpadding, guint ypadding)
+{
+       Gtk::Label* label(manage(new Gtk::Label((str + ":").c_str())));
+       label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
+       table->attach(*label, 0, 1, col, col+1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+}
+
 Dialog_Setup::Dialog_Setup():
        Dialog(_("Synfig Studio Setup"),false,true),
        adj_gamma_r(2.2,0.1,3.0,0.025,0.025,0.025),
@@ -66,8 +77,14 @@ Dialog_Setup::Dialog_Setup():
        adj_recent_files(15,1,50,1,1,1),
        adj_undo_depth(100,10,5000,1,1,1),
        toggle_use_colorspace_gamma(_("Visually Linear Color Selection")),
-       toggle_single_threaded(_("Use Only a Single Thread"))
-{
+#ifdef SINGLE_THREADED
+       toggle_single_threaded(_("Use Only a Single Thread")),
+#endif
+       toggle_restrict_radius_ducks(_("Restrict Real-Valued Ducks to Top Right Quadrant")),
+       adj_pref_x_size(480,1,10000,1,10,10),
+       adj_pref_y_size(270,1,10000,1,10,10)
+       
+       {
        // Setup the buttons
 
        Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
@@ -126,29 +143,28 @@ Dialog_Setup::Dialog_Setup():
        Gtk::Table *misc_table=manage(new Gtk::Table(2,2,false));
        notebook->append_page(*misc_table,_("Misc."));
 
+       int xpadding(8), ypadding(8);
+
        // Misc - Timestamp
        timestamp_menu=manage(new class Gtk::Menu());
-       misc_table->attach(*manage(new Gtk::Label(_("Timestamp"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-#define ADD_TIMESTAMP(desc,x)  \
-       timestamp_menu->items().push_back(      \
-               Gtk::Menu_Helpers::MenuElem(    \
-                       desc,   \
-                       sigc::bind(     \
-                               sigc::mem_fun(  \
-                                       *this,  \
-                                       &studio::Dialog_Setup::set_time_format  \
-                               ),      \
-                               x       \
-                       )       \
-               )       \
-       );
-       ADD_TIMESTAMP("HH:MM:SS.FF",Time::FORMAT_VIDEO);
-       ADD_TIMESTAMP("(HHh MMm SSs) FFf",Time::FORMAT_NORMAL);
-       ADD_TIMESTAMP("(HHhMMmSSs)FFf",Time::FORMAT_NORMAL|Time::FORMAT_NOSPACES);
-       ADD_TIMESTAMP("HHh MMm SSs FFf",Time::FORMAT_NORMAL|Time::FORMAT_FULL);
-       ADD_TIMESTAMP("HHhMMmSSsFFf",Time::FORMAT_NORMAL|Time::FORMAT_NOSPACES|Time::FORMAT_FULL);
+       attach_label(misc_table, _("Timestamp"), 0, xpadding, ypadding);
+       misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+#define ADD_TIMESTAMP(desc,x)                                                                  \
+       timestamp_menu->items().push_back(                                                      \
+               Gtk::Menu_Helpers::MenuElem(                                                    \
+                       desc,                                                                                           \
+                       sigc::bind(                                                                                     \
+                               sigc::mem_fun(                                                                  \
+                                       *this,                                                                          \
+                                       &studio::Dialog_Setup::set_time_format),        \
+                               x)));
+       ADD_TIMESTAMP("HH:MM:SS.FF",            Time::FORMAT_VIDEO      );
+       ADD_TIMESTAMP("(HHh MMm SSs) FFf",      Time::FORMAT_NORMAL     );
+       ADD_TIMESTAMP("(HHhMMmSSs)FFf",         Time::FORMAT_NORMAL     | Time::FORMAT_NOSPACES );
+       ADD_TIMESTAMP("HHh MMm SSs FFf",        Time::FORMAT_NORMAL     | Time::FORMAT_FULL             );
+       ADD_TIMESTAMP("HHhMMmSSsFFf",           Time::FORMAT_NORMAL     | Time::FORMAT_NOSPACES | Time::FORMAT_FULL);
+       ADD_TIMESTAMP("FFf",                            Time::FORMAT_FRAMES );
 
        timestamp_optionmenu.set_menu(*timestamp_menu);
 
@@ -169,21 +185,50 @@ Dialog_Setup::Dialog_Setup():
                widget_enum=manage(new Widget_Enum());
                widget_enum->set_param_desc(param_desc);
 
-               misc_table->attach(*manage(new Gtk::Label(_("Unit System"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-               misc_table->attach(*widget_enum, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+               attach_label(misc_table, _("Unit System"), 1, xpadding, ypadding);
+               misc_table->attach(*widget_enum, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
        }
 
        // Misc - recent files
        Gtk::SpinButton* recent_files_spinbutton(manage(new Gtk::SpinButton(adj_recent_files,1,0)));
-       misc_table->attach(*manage(new Gtk::Label(_("Recent Files"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       misc_table->attach(*recent_files_spinbutton, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach_label(misc_table, _("Recent Files"), 2, xpadding, ypadding);
+       misc_table->attach(*recent_files_spinbutton, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
 
        // Misc - use_colorspace_gamma
-       misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
 
+#ifdef SINGLE_THREADED
        // Misc - single_threaded
-       misc_table->attach(toggle_single_threaded, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       misc_table->attach(toggle_single_threaded, 0, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+#endif
 
+       // Misc - auto backup interval
+       attach_label(misc_table, _("Auto Backup Interval (0 to disable)"), 3, xpadding, ypadding);
+       misc_table->attach(auto_backup_interval, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Misc - restrict_radius_ducks
+       misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Misc - browser_command
+       attach_label(misc_table, _("Browser Command"), 4, xpadding, ypadding);
+       misc_table->attach(textbox_browser_command, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Document
+       Gtk::Table *document_table=manage(new Gtk::Table(2,2,false));
+       notebook->append_page(*document_table,_("Document"));
+
+       // Document - New Document X size
+       Gtk::SpinButton* pref_x_size_spinbutton(manage(new Gtk::SpinButton(adj_pref_x_size,1,0)));
+       attach_label(document_table,_("New Document X size"),0, xpadding, ypadding);
+       document_table->attach(*pref_x_size_spinbutton, 1, 2, 0, 1,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding); 
+       tooltips_.set_tip(*pref_x_size_spinbutton,_("Width in pixels of the new created document"));
+       
+       // Document - New Document Y size
+       Gtk::SpinButton* pref_y_size_spinbutton(manage(new Gtk::SpinButton(adj_pref_y_size,1,0)));
+       attach_label(document_table,_("New Document Y size"),1, xpadding, ypadding);
+       document_table->attach(*pref_y_size_spinbutton, 1, 2, 1, 2,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding); 
+       tooltips_.set_tip(*pref_y_size_spinbutton,_("High in pixels of the new created document"));
+       
        show_all_children();
 }
 
@@ -211,11 +256,28 @@ Dialog_Setup::on_apply_pressed()
        // Set the use_colorspace_gamma flag
        App::use_colorspace_gamma=toggle_use_colorspace_gamma.get_active();
 
+#ifdef SINGLE_THREADED
        // Set the single_threaded flag
        App::single_threaded=toggle_single_threaded.get_active();
+#endif
+
+       // Set the auto backup interval
+       App::auto_recover->set_timeout(auto_backup_interval.get_value() * 1000);
 
        App::distance_system=Distance::System(widget_enum->get_value());
 
+       // Set the restrict_radius_ducks flag
+       App::restrict_radius_ducks=toggle_restrict_radius_ducks.get_active();
+
+       // Set the browser_command textbox
+       App::browser_command=textbox_browser_command.get_text();
+
+       // Set the preferred new Document x dimension
+       App::preferred_x_size=int(adj_pref_x_size.get_value());
+
+       // Set the preferred new Document y dimension
+       App::preferred_y_size=int(adj_pref_y_size.get_value());
+
        App::save_settings();
 }
 
@@ -264,7 +326,7 @@ void
 Dialog_Setup::refresh()
 {
        // Refresh the temporary gamma; do this before adjusting the sliders,
-       // or variables will be used before their initialisation.
+       // or variables will be used before their initialization.
        gamma_pattern.set_gamma_r(App::gamma.get_gamma_r());
        gamma_pattern.set_gamma_g(App::gamma.get_gamma_g());
        gamma_pattern.set_gamma_b(App::gamma.get_gamma_b());
@@ -289,8 +351,26 @@ Dialog_Setup::refresh()
        // Refresh the status of the use_colorspace_gamma flag
        toggle_use_colorspace_gamma.set_active(App::use_colorspace_gamma);
 
+#ifdef SINGLE_THREADED
        // Refresh the status of the single_threaded flag
        toggle_single_threaded.set_active(App::single_threaded);
+#endif
+
+       // Refresh the value of the auto backup interval
+       auto_backup_interval.set_value(App::auto_recover->get_timeout() / 1000);
+
+       // Refresh the status of the restrict_radius_ducks flag
+       toggle_restrict_radius_ducks.set_active(App::restrict_radius_ducks);
+
+       // Refresh the browser_command textbox
+       textbox_browser_command.set_text(App::browser_command);
+
+       // Refresh the preferred new Document X dimension
+       adj_pref_x_size.set_value(App::preferred_x_size);
+       
+       // Refresh the preferred new Document Y dimension
+       adj_pref_y_size.set_value(App::preferred_y_size);
+
 }
 
 GammaPattern::GammaPattern():
@@ -499,22 +579,23 @@ BlackLevelSelector::on_event(GdkEvent *event)
 
 
 void
-Dialog_Setup::set_time_format(Time::Format x)
+Dialog_Setup::set_time_format(synfig::Time::Format x)
 {
        time_format=x;
-       if(x<=Time::FORMAT_VIDEO)
+       if (x <= Time::FORMAT_VIDEO)
                timestamp_optionmenu.set_history(0);
+       else if (x == (Time::FORMAT_NORMAL))
+               timestamp_optionmenu.set_history(1);
+       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES))
+               timestamp_optionmenu.set_history(2);
+       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_FULL))
+               timestamp_optionmenu.set_history(3);
+       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES | Time::FORMAT_FULL))
+               timestamp_optionmenu.set_history(4);
+       else if (x == (Time::FORMAT_FRAMES))
+               timestamp_optionmenu.set_history(5);
        else
-       {
-               if(x==(Time::FORMAT_NOSPACES|Time::FORMAT_FULL))
-                       timestamp_optionmenu.set_history(4);
-               else if(x==(Time::FORMAT_FULL))
-                       timestamp_optionmenu.set_history(3);
-               else if(x==(Time::FORMAT_NOSPACES))
-                       timestamp_optionmenu.set_history(2);
-               else
-                       timestamp_optionmenu.set_history(1);
-       }
+               timestamp_optionmenu.set_history(1);
 }