1 /* === S Y N F I G ========================================================= */
2 /*! \file widget_canvaschooser.cpp
3 ** \brief Template File
5 ** $Id: widget_canvaschooser.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "widget_canvaschooser.h"
32 #include <gtkmm/menu.h>
37 /* === U S I N G =========================================================== */
41 using namespace synfig;
42 using namespace studio;
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 /* === P R O C E D U R E S ================================================= */
50 /* === M E T H O D S ======================================================= */
52 Widget_CanvasChooser::Widget_CanvasChooser()
56 Widget_CanvasChooser::~Widget_CanvasChooser()
61 Widget_CanvasChooser::set_parent_canvas(etl::handle<synfig::Canvas> x)
68 Widget_CanvasChooser::set_value_(etl::handle<synfig::Canvas> data)
75 Widget_CanvasChooser::set_value(etl::handle<synfig::Canvas> data)
77 assert(parent_canvas);
80 canvas_menu=manage(new class Gtk::Menu());
82 synfig::Canvas::Children::iterator iter;
83 synfig::Canvas::Children &children(parent_canvas->children());
88 label=canvas->get_name().empty()?canvas->get_id():canvas->get_name();
89 canvas_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
92 for(iter=children.begin();iter!=children.end();iter++)
95 label=(*iter)->get_name().empty()?(*iter)->get_id():(*iter)->get_name();
96 canvas_menu->items().push_back(
97 Gtk::Menu_Helpers::MenuElem(
102 &Widget_CanvasChooser::set_value_
109 canvas_menu->items().push_back(
110 Gtk::Menu_Helpers::MenuElem(
112 sigc::mem_fun(*this,&Widget_CanvasChooser::chooser_menu)
115 set_menu(*canvas_menu);
121 const etl::handle<synfig::Canvas> &
122 Widget_CanvasChooser::get_value()
128 Widget_CanvasChooser::chooser_menu()
131 App::dialog_entry(_("Choose Canvas"),_("Enter the relative name of the canvas that you want"),canvas_name);
132 Canvas::Handle new_canvas;
135 new_canvas=parent_canvas->find_canvas(canvas_name);
136 set_value_(new_canvas);
138 catch(std::runtime_error x)
140 App::dialog_error_blocking(_("Error:Exception Thrown"),x.what());
145 App::dialog_error_blocking(_("Error"),_("Unknown Exception"));