1 /* === S Y N F I G ========================================================= */
2 /*! \file widget_canvaschooser.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "widget_canvaschooser.h"
33 #include <gtkmm/menu.h>
38 /* === U S I N G =========================================================== */
42 using namespace synfig;
43 using namespace studio;
45 /* === M A C R O S ========================================================= */
47 /* === G L O B A L S ======================================================= */
49 /* === P R O C E D U R E S ================================================= */
51 /* === M E T H O D S ======================================================= */
53 Widget_CanvasChooser::Widget_CanvasChooser()
57 Widget_CanvasChooser::~Widget_CanvasChooser()
62 Widget_CanvasChooser::set_parent_canvas(etl::handle<synfig::Canvas> x)
69 Widget_CanvasChooser::set_value_(etl::handle<synfig::Canvas> data)
76 Widget_CanvasChooser::set_value(etl::handle<synfig::Canvas> data)
78 assert(parent_canvas);
81 canvas_menu=manage(new class Gtk::Menu());
83 synfig::Canvas::Children::iterator iter;
84 synfig::Canvas::Children &children(parent_canvas->children());
89 label=canvas->get_name().empty()?canvas->get_id():canvas->get_name();
90 canvas_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
93 for(iter=children.begin();iter!=children.end();iter++)
96 label=(*iter)->get_name().empty()?(*iter)->get_id():(*iter)->get_name();
97 canvas_menu->items().push_back(
98 Gtk::Menu_Helpers::MenuElem(
103 &Widget_CanvasChooser::set_value_
110 canvas_menu->items().push_back(
111 Gtk::Menu_Helpers::MenuElem(
113 sigc::mem_fun(*this,&Widget_CanvasChooser::chooser_menu)
116 set_menu(*canvas_menu);
122 const etl::handle<synfig::Canvas> &
123 Widget_CanvasChooser::get_value()
129 Widget_CanvasChooser::chooser_menu()
132 App::dialog_entry(_("Choose Canvas"),_("Enter the relative name of the canvas that you want"),canvas_name);
133 Canvas::Handle new_canvas;
136 new_canvas=parent_canvas->find_canvas(canvas_name);
137 set_value_(new_canvas);
139 catch(std::runtime_error x)
141 App::dialog_error_blocking(_("Error:Exception Thrown"),x.what());
146 App::dialog_error_blocking(_("Error"),_("Unknown Exception"));