1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_metadata.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 "dock_metadata.h"
35 #include <gtkmm/scrolledwindow.h>
38 #include <sigc++/signal.h>
39 #include <sigc++/hide.h>
40 #include <sigc++/slot.h>
41 #include "metadatatreestore.h"
42 #include "canvasview.h"
48 /* === U S I N G =========================================================== */
52 using namespace synfig;
53 using namespace studio;
55 /* === M A C R O S ========================================================= */
57 /* === G L O B A L S ======================================================= */
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 Dock_MetaData::Dock_MetaData():
64 Dock_CanvasSpecific("meta_data",_("Canvas MetaData"),Gtk::StockID("synfig-meta_data")),
65 tree_view(manage(new Gtk::TreeView()))
67 MetaDataTreeStore::Model model;
69 tree_view->append_column(_("Key"),model.key);
70 tree_view->append_column_editable(_("Data"),model.data);
71 tree_view->set_rules_hint();
73 Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
74 scrolledwindow->set_flags(Gtk::CAN_FOCUS);
75 scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
76 scrolledwindow->add(*tree_view);
77 scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
78 scrolledwindow->show();
83 Gtk::StockID("gtk-add"),
84 _("Add new MetaData entry")
85 )->signal_clicked().connect(
88 &Dock_MetaData::on_add_pressed
93 Gtk::StockID("gtk-delete"),
94 _("Remove selected MetaData entry")
95 )->signal_clicked().connect(
98 &Dock_MetaData::on_delete_pressed
103 Dock_MetaData::~Dock_MetaData()
108 Dock_MetaData::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
110 canvas_view->set_tree_model(get_name(),MetaDataTreeStore::create(canvas_view->canvas_interface()));
114 Dock_MetaData::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
118 tree_view->set_model(canvas_view->get_tree_model(get_name()));
123 tree_view->set_model(Glib::RefPtr<Gtk::TreeModel>());
129 Dock_MetaData::on_add_pressed()
131 if(get_canvas_interface())
134 if(App::dialog_entry(_("New MetaData Entry"), _("Please enter the name of the key"),key) && !key.empty())
136 get_canvas_interface()->set_meta_data(key," ");
142 Dock_MetaData::on_delete_pressed()