//------------------------------------------------------------------------------
void ListModelWrapper::set_value_impl(const iterator& row, int column, const Glib::ValueBase& value)
{
  if (!*_tm)
    return;

  bec::NodeId node(node_for_iter(row));

  if ( node.is_valid() )
  {
    const GType type = *(_columns.types() + column);
    column = _columns.ui2bec(column);

    if ( column < 0 )
    {
      if ( !_fake_column_value_setter.empty() )
        _fake_column_value_setter(row, column, type, value);
    }
    else
    {
      switch ( type )
      {
      case G_TYPE_BOOLEAN:
        {
          Glib::Value<bool>   v;
          v.init(value.gobj());
          lmwdprint("LMW::set_value_impl:%s node %s, column %i, value %i\n", _name.c_str(), node.repr().c_str(), column, v.get());
          (*_tm)->set_field(node, column, (ssize_t)v.get());
          break;
        }
      case G_TYPE_INT:
      case G_TYPE_UINT:
        {
          Glib::Value<ssize_t>   v;
          v.init(value.gobj());
          lmwdprint("LMW::set_value_impl: node %s, column %i, value %i\n", node.repr().c_str(), column, v.get());
          (*_tm)->set_field(node, column, v.get());
          break;
        }
      case G_TYPE_FLOAT:
      case G_TYPE_DOUBLE:
        {
          Glib::Value<double>  v;
          v.init(value.gobj());
          (*_tm)->set_field(node, column, v.get());
          break;
        }
      case G_TYPE_STRING:
        {
          Glib::Value<std::string>   v;
          v.init(value.gobj());
          (*_tm)->set_field(node, column, v.get());
          lmwdprint("LMW::set_value: %s '%s'\n", _name.c_str(), v.get().c_str());
          break;
        }
      default:
        break;
      }
    }
  }
}
//--------------------------------------------------------------------------------
void DbMySQLTableEditorIndexPage::set_value(const Gtk::TreeModel::iterator& iter, int column, GType type, const Glib::ValueBase& value)
{
  bec::IndexColumnsListBE *columns_be = _be->get_indexes()->get_columns();
  bec::NodeId node(_indexes_columns_model->node_for_iter(iter));

  if ( node.is_valid() )
  {
    switch ( column )
    {
      case -2:
      {
        Glib::Value<std::string>   v;
        v.init(value.gobj());
    
        columns_be->set_field(node, ::bec::IndexColumnsListBE::Descending, v.get() == "ASC" ? 0 : 1);
        break;
      }
      case -8:
      {
        Glib::Value<bool>   v;
        v.init(value.gobj());
        columns_be->set_column_enabled(node, v.get());
        recreate_order_model();
        break;
      }
    }
  }
}
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);
}
Beispiel #4
0
bool GstUtils::get_structure_field(const Structure& structure, const Glib::ustring& fieldname, RefPtr<const Caps>& value)
{
	Glib::ValueBase base;
	structure.get_field(fieldname, base);

	if (!GST_VALUE_HOLDS_CAPS(base.gobj()))
		return false;

	value = Glib::wrap(const_cast<GstCaps*>(gst_value_get_caps(base.gobj())), true);
	return true;
}
Beispiel #5
0
void display_caps(const Glib::RefPtr<Gst::Caps> &caps,
                  const Glib::RefPtr<Gtk::TreeStore> &model, const Gtk::TreeModelColumn<Glib::ustring> &col_name,
                  const Gtk::TreeModelColumn<Glib::ustring> &col_value, const Gtk::TreeModel::Row& parent_row)
{
    std::string caps_str;

    if (!caps)
        caps_str = _("UNKNOWN");
    else if (caps->is_any() || caps->empty())
        caps_str = caps->to_string();

    if (!caps_str.empty())
    {
        APPEND_SUB_ROW(caps_str, "", parent_row);
    }

    for (guint i = 0; i < caps->size(); i++)
    {
        Gst::Structure structure = caps->get_structure(i);
        auto row = APPEND_SUB_ROW (structure.get_name(), "", parent_row);
        for (int j = 0; j < structure.size(); j++)
        {
            Glib::ustring field_name = structure.get_nth_field_name(j);
            Glib::ValueBase base;

            structure.get_field(field_name, base);
            APPEND_SUB_ROW (field_name, gst_value_serialize(base.gobj()), row);
        }
    }
}
//------------------------------------------------------------------------------
void TreeModelWrapper::get_icon_value(const iterator& iter, int column, const bec::NodeId& node,
                                      Glib::ValueBase& value) const {
  if (!tm())
    return;

  static ImageCache* pixbufs = ImageCache::get_instance();
  static Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
  GValue* gval = value.gobj();

  g_value_init(gval, GDK_TYPE_PIXBUF);

  bec::IconId icon_id = tm()->get_field_icon(node, column, get_icon_size());
  if (icon_id != 0) {
    Glib::RefPtr<Gdk::Pixbuf> pixbuf = pixbufs->image(icon_id);

    if (pixbuf)
      g_value_set_object(gval, pixbuf->gobj());
    else {
      if (tm()->is_expandable(node)) {
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = icon_theme->load_icon("folder", 16, (Gtk::IconLookupFlags)0);

        if (pixbuf)
          g_value_set_object(gval, pixbuf->gobj());
      }
    }
  } else {
    if (tm()->is_expandable(node)) {
      Glib::RefPtr<Gdk::Pixbuf> pixbuf = icon_theme->load_icon("folder", 16, (Gtk::IconLookupFlags)0);

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

	if(column==model.data.index())
	{
		synfig::String key((Glib::ustring)(*iter)[model.key]);
		g_value_init(value.gobj(),G_TYPE_STRING);
		g_value_set_string(value.gobj(),get_canvas()->get_meta_data(key).c_str());
		return;
	}
	else
		Gtk::TreeStore::get_value_vfunc(iter,column,value);
}
Beispiel #8
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 ListModelWrapper::get_icon_value(const iterator& iter, int column, const bec::NodeId &node, Glib::ValueBase& value) const
{
  if (!*_tm)
    return;

  static ImageCache       *pixbufs      =  ImageCache::get_instance();
  static Glib::RefPtr<Gtk::IconTheme> icon_theme= Gtk::IconTheme::get_default();
  GValue *gval = value.gobj();

  bec::IconId               icon_id = (*_tm)->get_field_icon(node, column, get_icon_size());

  g_value_init(gval, GDK_TYPE_PIXBUF);
  if (icon_id != 0)
  {
    Glib::RefPtr<Gdk::Pixbuf>  pixbuf = pixbufs->image(icon_id);

    if ( pixbuf )
    {
      g_value_set_object(gval, pixbuf->gobj());
    }
  }
}
Beispiel #10
0
ObjectNodeInfo GstUtils::parse_caps(const RefPtr<Caps>& caps)
{
	Glib::ustring caps_str;

	bool finish = true;

	if (!caps || caps->empty())
		caps_str = "EMPTY";
	else if (caps->is_any())
		caps_str = "ANY";
	else finish = false;

	if (finish)
		return ObjectNodeInfo(caps_str);

	ObjectNodeInfo ret;

	for (guint i = 0; i < caps->size(); i++)
	{
		Structure structure = caps->get_structure(i);
		ObjectNodeInfo obj;

		for (int j = 0; j < structure.size(); j++)
		{
			Glib::ustring field_name = structure.get_nth_field_name(j);
			Glib::ValueBase base;

			structure.get_field(field_name, base);
			obj.insert(field_name, ObjectNodeInfo(gst_value_serialize(base.gobj())));
		}
		ret.insert(structure.get_name(), obj);
	}


	return ret;
}
Beispiel #11
0
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);
}