1 /* === S Y N F I G ========================================================= */
2 /*! \file widget_filename.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include <gtkmm/entry.h>
34 #include <gtkmm/button.h>
35 #include "widget_filename.h"
37 #include "canvasview.h"
43 /* === U S I N G =========================================================== */
46 //using namespace etl;
47 //using namespace synfig;
48 using namespace studio;
50 /* === M A C R O S ========================================================= */
52 /* === G L O B A L S ======================================================= */
54 /* === P R O C E D U R E S ================================================= */
56 /* === M E T H O D S ======================================================= */
58 Widget_Filename::Widget_Filename()
60 entry_filename=manage(new Gtk::Entry());
61 button_choose=manage(new Gtk::Button(_("Find")));
63 pack_start(*entry_filename);
64 pack_start(*button_choose);
65 entry_filename->show();
66 button_choose->show();
68 button_choose->signal_clicked().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_button_choose_pressed));
69 //entry_filename->signal_value_changed().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
70 entry_filename->signal_activate().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
73 Widget_Filename::~Widget_Filename()
78 Widget_Filename::set_has_frame(bool x)
80 entry_filename->set_has_frame(x);
85 Widget_Filename::set_value(const std::string &data)
87 entry_filename->set_text(data);
91 Widget_Filename::get_value() const
95 return entry_filename->get_text();
99 throw string("Caught unknown exception");
104 Widget_Filename::on_value_changed()
106 signal_value_changed()();
110 Widget_Filename::on_button_choose_pressed()
112 string filename=entry_filename->get_text();
116 filename = etl::absolute_path(
117 etl::dirname(App::get_selected_canvas_view()->get_canvas()->get_file_name()) +
118 ETL_DIRECTORY_SEPARATOR +
120 if(App::dialog_open_file(_("Choose File"), filename, MISC_DIR_PREFERENCE))
121 entry_filename->set_text(filename);