void
MetaDataTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
{
	if(column>=get_n_columns_vfunc())
	{
		g_warning("MetaDataTreeStore::set_value_impl: Bad column (%d)",column);
		return;
	}

	if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
	{
		g_warning("MetaDataTreeStore::set_value_impl: Bad value type");
		return;
	}

	if(column==model.data.index())
	{
		Glib::Value<Glib::ustring> x;
		g_value_init(x.gobj(),model.data.type());
		g_value_copy(value.gobj(),x.gobj());

		synfig::String key((Glib::ustring)(*iter)[model.key]);
		synfig::String new_data(x.get());

		get_canvas_interface()->set_meta_data(key,new_data);
	}
	else
		Gtk::TreeStore::set_value_impl(iter,column, value);
}
Exemple #2
0
 Panel::Panel (workspace::PanelManager& panelManager
              ,Gdl::DockItem& dockItem
              ,const gchar* longName
              ,const gchar* stockID)
   : panelManager_(panelManager)
   , dockItem_(dockItem)
   , panelBar_(*this, stockID)
   {
     // Set dockItems long-name property
     Glib::Value<std::string> val;
     val.init(val.value_type());
     val.set(longName);
     g_object_set_property (G_OBJECT (dockItem.gobj()), "long-name", val.gobj());
     
     /* Set the grip handle */
     GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP(
       gdl_dock_item_get_grip(dockItem.gobj()));
     gdl_dock_item_grip_show_handle(grip);
     gdl_dock_item_grip_set_label(grip, ((Widget&)panelBar_).gobj());
     //gdl_dock_item_grip_set_cursor_type(grip, GDK_LEFT_PTR);
     
     /* Set up the panel body */
     // Add this panel's container to the DockItem
     dockItem.add((Gtk::Widget&)*this);
     
     /* Connect the signals */
     dockItem.signal_hide().connect(
         sigc::mem_fun(*this, &Panel::on_item_hidden));
     
     dockItem.show();
   }
Exemple #3
0
void
ChildrenTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
{
	if(column>=get_n_columns_vfunc())
	{
		g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
		return;
	}

	if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
	{
		g_warning("LayerTreeStore::set_value_impl: Bad value type");
		return;
	}

	try
	{
		if(column==model.value.index())
		{
			Glib::Value<synfig::ValueBase> x;
			g_value_init(x.gobj(),model.value.type());
			g_value_copy(value.gobj(),x.gobj());

			synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
			if(value_desc)
			{
				canvas_interface()->change_value(value_desc,x.get());
				row_changed(get_path(*iter),*iter);
			}

			return;
		}
		else
			CanvasTreeStore::set_value_impl(iter,column, value);
	}
	catch(std::exception x)
	{
		g_warning("%s", x.what());
	}
}
void
CanvasTreeStore::get_value_vfunc(const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
{
	if(column==model.value.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<synfig::ValueBase> x;
		g_value_init(x.gobj(),x.value_type());

		if(!value_desc)
		{
			x.set(ValueBase());
		}
		else
		if(value_desc.is_const())
			x.set(value_desc.get_value());
		else
		if(value_desc.is_value_node())
			switch(value_desc.get_value_type())
			{
			case ValueBase::TYPE_BONE:
			{
				Time time(canvas_interface()->get_time());
				Bone bone((*(value_desc.get_value_node()))(time).get(Bone()));
				String display(String(bone.get_name()));
				ValueNode_Bone::ConstHandle parent(bone.get_parent());
				if (!parent->is_root())
					display += " --> " + String((*parent->get_link("name"))(time).get(String()));
				x.set(display);
				break;
			}
			case ValueBase::TYPE_BONE_WEIGHT_PAIR:
			{
				Time time(canvas_interface()->get_time());
				BoneWeightPair bone_weight_pair((*(value_desc.get_value_node()))(time).get(BoneWeightPair()));
				x.set(bone_weight_pair.get_string());
				break;
			}
			case ValueBase::TYPE_SEGMENT:
			case ValueBase::TYPE_LIST:
			case ValueBase::TYPE_BLINEPOINT:
				x.set(ValueBase::type_local_name(value_desc.get_value_type()));
				break;
			default:
				x.set((*value_desc.get_value_node())(canvas_interface()->get_time()));
				break;
			}
		else
		{
			synfig::error(__FILE__":%d: Unable to figure out value",__LINE__);
			return;
		}

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.is_value_node.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());

		x.set(value_desc && value_desc.is_value_node());

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.is_shared.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());

		x.set(value_desc.is_value_node() && value_desc.get_value_node()->rcount()>1);

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.is_exported.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());

		x.set(value_desc.is_value_node() && value_desc.get_value_node()->is_exported());

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.is_canvas.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());

		x.set(!value_desc && (Canvas::Handle)(*iter)[model.canvas]);

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.id.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<Glib::ustring> x;
		g_value_init(x.gobj(),x.value_type());

		if(value_desc && value_desc.is_value_node())
			x.set(value_desc.get_value_node()->get_id());
		else if(!value_desc && Canvas::Handle((*iter)[model.canvas]))
			x.set(Canvas::Handle((*iter)[model.canvas])->get_id());
		else
			return Gtk::TreeStore::get_value_vfunc(iter,column,value);

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.is_editable.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());

		x.set(!value_desc.is_value_node() || synfigapp::is_editable(value_desc.get_value_node()));

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.type.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
		String stype, lname;

		Glib::Value<Glib::ustring> x;
		g_value_init(x.gobj(),x.value_type());

		// Set the type
		if(!value_desc)
		{
			if((*iter)[model.is_canvas])
				x.set(_("Canvas"));
		}
		else
		{
			stype=ValueBase::type_local_name(value_desc.get_value_type());
			if(!value_desc.is_const())
				stype+=" (" + value_desc.get_value_node()->get_local_name() + ")";
		}
		x.set(stype.c_str());
		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.label.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);

		Glib::Value<Glib::ustring> x;
		g_value_init(x.gobj(),x.value_type());

		// Set the type
		if(!value_desc)
		{
			Canvas::Handle canvas((*iter)[model.canvas]);
			if(canvas)
			{
				if(!canvas->get_id().empty())
					x.set(canvas->get_id());
				else if(!canvas->get_name().empty())
					x.set(canvas->get_name());
				else
					x.set(_("[Unnamed]"));
				// todo: what are the previous 6 lines for if we're going to overwrite it here?
				x.set(_("Canvas"));
			}
			return Gtk::TreeStore::get_value_vfunc(iter,column,value);
		}
		else
		{
			ValueNode::Handle value_node=value_desc.get_value_node();

			// Setup the row's label
			if(value_node->get_id().empty())
				x.set(Glib::ustring((*iter)[model.name]));
			else if(Glib::ustring((*iter)[model.name]).empty())
				x.set(value_node->get_id());
			else
				x.set(Glib::ustring((*iter)[model.name])+" ("+value_node->get_id()+')');
		}

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.icon.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
		if(!value_desc)
			return Gtk::TreeStore::get_value_vfunc(iter,column,value);

		Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
		g_value_init(x.gobj(),x.value_type());

		x.set(get_tree_pixbuf(value_desc.get_value_type()));

		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.interpolation_icon.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
		if(!value_desc)
			return Gtk::TreeStore::get_value_vfunc(iter,column,value);
		
		Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
		g_value_init(x.gobj(),x.value_type());
		
		x.set(get_interpolation_pixbuf(value_desc.get_interpolation()));
		
		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
		
	}
	else
	if(column==model.is_static.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
		
		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());
		
		x.set(value_desc.get_static());
		
		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
	if(column==model.interpolation_icon_visible.index())
	{
		synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
		
		Glib::Value<bool> x;
		g_value_init(x.gobj(),x.value_type());
	
		bool is_visible((!value_desc.get_static())
						&& (value_desc.get_interpolation()!=INTERPOLATION_UNDEFINED)
						&& (value_desc.get_interpolation()!=INTERPOLATION_MANUAL)
						&& (value_desc.get_interpolation()!=INTERPOLATION_NIL));
		x.set(is_visible);
		g_value_init(value.gobj(),x.value_type());
		g_value_copy(x.gobj(),value.gobj());
	}
	else
		Gtk::TreeStore::get_value_vfunc(iter,column,value);
}