Add a star tool. For drawing stars.
[synfig.git] / synfig-studio / trunk / src / gtkmm / app.cpp
index 1aa798c..0d5fa82 100644 (file)
@@ -54,6 +54,7 @@
 #include <gtkmm/inputdialog.h>
 #include <gtkmm/accelmap.h>
 #include <gtkmm/uimanager.h>
+#include <gtkmm/textview.h>
 
 #include <gtk/gtk.h>
 
@@ -88,6 +89,8 @@
 #include "state_rectangle.h"
 #include "state_smoothmove.h"
 #include "state_scale.h"
+#include "state_star.h"
+#include "state_text.h"
 #include "state_width.h"
 #include "state_rotate.h"
 #include "state_zoom.h"
@@ -1017,6 +1020,9 @@ init_ui_manager()
        ACCEL("<Actions>//state-width",       "<Mod1>t");
        ACCEL("<Actions>//state-mirror",      "<Mod1>m");
 
+       ACCEL("<Actions>//state-text",        "<Mod1>x");
+       ACCEL("<Actions>//state-star",        "<Mod1>q");
+
        ACCEL("<Actions>//canvas-zoom-fit","<Control><Shift>z");
 
 #undef ACCEL
@@ -1194,6 +1200,9 @@ App::App(int *argc, char ***argv):
                state_manager->add_state(&state_eyedrop);
                state_manager->add_state(&state_zoom);
 
+               state_manager->add_state(&state_text);
+               state_manager->add_state(&state_star);
+
                // Disabled by default - it doesn't work properly?
                if(getenv("SYNFIG_ENABLE_WIDTH"    )) state_manager->add_state(&state_width);
 
@@ -1778,7 +1787,7 @@ static OPENFILENAME ofn={};
 bool
 App::dialog_open_file(const std::string &title, std::string &filename, std::string preference)
 {
-       info("App::dialog_open_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
+       // info("App::dialog_open_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
 
 #ifdef USE_WIN32_FILE_DIALOGS
        static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ;
@@ -1904,7 +1913,7 @@ App::dialog_open_file(const std::string &title, std::string &filename, std::stri
 bool
 App::dialog_save_file(const std::string &title, std::string &filename, std::string preference)
 {
-       info("App::dialog_save_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
+       // info("App::dialog_save_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
 
 #if USE_WIN32_FILE_DIALOGS
        static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ;
@@ -1967,7 +1976,8 @@ App::dialog_save_file(const std::string &title, std::string &filename, std::stri
        {
                file_type_enum = manage(new Widget_Enum());
                file_type_enum->set_param_desc(ParamDesc().set_hint("enum")
-                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_08, "0.61.08", strprintf("0.61.08 (%s)", _("current")))
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_09, "0.61.09", strprintf("0.61.09 (%s)", _("current")))
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_08, "0.61.08", "0.61.08")
                                                                           .add_enum_value(synfig::RELEASE_VERSION_0_61_07, "0.61.07", "0.61.07")
                                                                           .add_enum_value(synfig::RELEASE_VERSION_0_61_06, "0.61.06", strprintf("0.61.06 %s", _("and older"))));
                file_type_enum->set_value(RELEASE_VERSION_END-1); // default to the most recent version
@@ -2183,8 +2193,8 @@ App::dialog_entry(const std::string &title, const std::string &message,std::stri
        Gtk::Dialog dialog(
                title,          // Title
                true,           // Modal
-               true            // use_separator
-       );
+               true);          // use_separator
+
        Gtk::Label label(message);
        label.show();
        dialog.get_vbox()->pack_start(label);
@@ -2193,11 +2203,13 @@ App::dialog_entry(const std::string &title, const std::string &message,std::stri
        entry.set_text(text);
        entry.show();
        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);
+
        entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
        dialog.show();
 
@@ -2209,8 +2221,39 @@ App::dialog_entry(const std::string &title, const std::string &message,std::stri
        return true;
 }
 
+bool
+App::dialog_paragraph(const std::string &title, const std::string &message,std::string &text)
+{
+       Gtk::Dialog dialog(
+               title,          // Title
+               true,           // Modal
+               true);          // use_separator
 
+       Gtk::Label label(message);
+       label.show();
+       dialog.get_vbox()->pack_start(label);
 
+       Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
+       text_buffer->set_text(text);
+       Gtk::TextView text_view(text_buffer);
+       text_view.show();
+
+       dialog.get_vbox()->pack_start(text_view);
+
+       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)
+               return false;
+
+       text=text_buffer->get_text();
+
+       return true;
+}
 
 bool
 App::open(std::string filename)