From 3484095c16bf58e9d8a27cf14bbd971a5b504c38 Mon Sep 17 00:00:00 2001 From: dooglus Date: Fri, 4 Apr 2008 18:37:40 +0000 Subject: [PATCH] Add App::dialog_paragraph() to allow editing of paragraphs of text. git-svn-id: http://svn.voria.com/code@1958 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/app.cpp | 38 +++++++++++++++++++++++++++++++++-- synfig-studio/trunk/src/gtkmm/app.h | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index feb0c02..9a07be5 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -2184,8 +2185,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); @@ -2194,11 +2195,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(); @@ -2210,8 +2213,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 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) diff --git a/synfig-studio/trunk/src/gtkmm/app.h b/synfig-studio/trunk/src/gtkmm/app.h index f3d7338..cc04a06 100644 --- a/synfig-studio/trunk/src/gtkmm/app.h +++ b/synfig-studio/trunk/src/gtkmm/app.h @@ -331,6 +331,7 @@ public: static void dialog_warning_blocking(const std::string &title, const std::string &message); static bool dialog_entry(const std::string &title, const std::string &message,std::string &text); + static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text); static bool dialog_yes_no(const std::string &title, const std::string &message); -- 2.7.4