77 lines
2.3 KiB
C
77 lines
2.3 KiB
C
/*
|
|
* Copyright (C) 2013 - Juan Ferrer Toribio
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "db-model-holder.h"
|
|
|
|
/**
|
|
* SECTION: db-model-holder
|
|
* @Short_description: interface for objects that use a model
|
|
* @Title: DbModelHolder
|
|
* @See_also: #DbModel
|
|
*
|
|
* This interface should be implemented from any class that uses a #DbModel as
|
|
* data source. This interface offers a #DbModel as a virtual property that has
|
|
* to be overwritten by the classes implementing it, as well as the
|
|
* db_model_holder_get_model() and db_model_holder_set_model() methods.
|
|
**/
|
|
|
|
G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_OBJECT);
|
|
|
|
/**
|
|
* db_model_holder_get_model:
|
|
* @self: a #DbModelHolder
|
|
*
|
|
* Gets the model used by holder.
|
|
*
|
|
* Return value:(transfer none): the #DbModel
|
|
**/
|
|
DbModel * db_model_holder_get_model (DbModelHolder * self)
|
|
{
|
|
g_return_val_if_fail (DB_IS_MODEL_HOLDER (self), NULL);
|
|
|
|
return DB_MODEL_HOLDER_GET_INTERFACE (self)->get_model (self);
|
|
}
|
|
|
|
/**
|
|
* db_model_holder_set_model:
|
|
* @self: a #DbModelHolder
|
|
* @model:(allow-none): the #DbModel
|
|
*
|
|
* Sets the model used by holder. If @model is NULL, then it will unset the
|
|
* model.
|
|
**/
|
|
void db_model_holder_set_model (DbModelHolder * self, DbModel * model)
|
|
{
|
|
g_return_if_fail (DB_IS_MODEL_HOLDER (self));
|
|
g_return_if_fail (DB_IS_MODEL (model));
|
|
|
|
DB_MODEL_HOLDER_GET_INTERFACE (self)->set_model (self, model);
|
|
}
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
|
|
|
static void db_model_holder_default_init (DbModelHolderInterface * iface)
|
|
{
|
|
g_object_interface_install_property (iface,
|
|
g_param_spec_object ("data-model"
|
|
,_("Model")
|
|
,_("The model used by the holder")
|
|
,DB_TYPE_MODEL
|
|
,G_PARAM_READWRITE
|
|
));
|
|
}
|