1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_metadata.cpp
3 ** \brief Template File
5 ** $Id: dock_metadata.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
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"
46 /* === U S I N G =========================================================== */
50 using namespace synfig;
51 using namespace studio;
53 /* === M A C R O S ========================================================= */
55 /* === G L O B A L S ======================================================= */
57 /* === P R O C E D U R E S ================================================= */
59 /* === M E T H O D S ======================================================= */
61 Dock_MetaData::Dock_MetaData():
62 Dock_CanvasSpecific("meta_data",_("Canvas MetaData"),Gtk::StockID("synfig-meta_data")),
63 tree_view(manage(new Gtk::TreeView()))
65 MetaDataTreeStore::Model model;
67 tree_view->append_column(_("Key"),model.key);
68 tree_view->append_column_editable(_("Data"),model.data);
69 tree_view->set_rules_hint();
71 Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
72 scrolledwindow->set_flags(Gtk::CAN_FOCUS);
73 scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
74 scrolledwindow->add(*tree_view);
75 scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
76 scrolledwindow->show();
81 Gtk::StockID("gtk-add"),
82 _("Add new MetaData entry")
83 )->signal_clicked().connect(
86 &Dock_MetaData::on_add_pressed
91 Gtk::StockID("gtk-delete"),
92 _("Remove selected MetaData entry")
93 )->signal_clicked().connect(
96 &Dock_MetaData::on_delete_pressed
101 Dock_MetaData::~Dock_MetaData()
106 Dock_MetaData::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
108 canvas_view->set_tree_model(get_name(),MetaDataTreeStore::create(canvas_view->canvas_interface()));
112 Dock_MetaData::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
116 tree_view->set_model(canvas_view->get_tree_model(get_name()));
121 tree_view->set_model(Glib::RefPtr<Gtk::TreeModel>());
127 Dock_MetaData::on_add_pressed()
129 if(get_canvas_interface())
132 if(App::dialog_entry("New MetaData Entry", "Please enter the name of the key",key) && !key.empty())
134 get_canvas_interface()->set_meta_data(key," ");
140 Dock_MetaData::on_delete_pressed()