196 lines
4.7 KiB
C
196 lines
4.7 KiB
C
/*
|
|
* Copyright (C) 2012 - 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 "vn-mod.h"
|
|
|
|
struct _VnModPrivate
|
|
{
|
|
gchar * name;
|
|
gchar * data_dir;
|
|
gchar * text_domain;
|
|
gchar * ui;
|
|
GModule * module;
|
|
GtkActionGroup * actions;
|
|
};
|
|
|
|
G_DEFINE_TYPE (VnMod, vn_mod, G_TYPE_OBJECT);
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
|
|
|
|
/**
|
|
* vn_mod_activate:
|
|
* @obj: the #VnMod
|
|
*
|
|
* Activates the module.
|
|
* Virtual: activate
|
|
**/
|
|
void vn_mod_activate (VnMod * obj)
|
|
{
|
|
g_return_if_fail (VN_IS_MOD (obj));
|
|
|
|
VN_MOD_GET_CLASS (obj)->activate (obj);
|
|
}
|
|
|
|
const gchar * vn_mod_get_name (VnMod * obj)
|
|
{
|
|
g_return_val_if_fail (VN_IS_MOD (obj), NULL);
|
|
|
|
return obj->priv->name;
|
|
}
|
|
|
|
const gchar * vn_mod_get_text_domain (VnMod * obj)
|
|
{
|
|
g_return_val_if_fail (VN_IS_MOD (obj), NULL);
|
|
|
|
return obj->priv->text_domain;
|
|
}
|
|
|
|
const gchar * vn_mod_get_data_dir (VnMod * obj)
|
|
{
|
|
g_return_val_if_fail (VN_IS_MOD (obj), NULL);
|
|
|
|
return obj->priv->data_dir;
|
|
}
|
|
|
|
const gchar * vn_mod_get_ui (VnMod * obj)
|
|
{
|
|
g_return_val_if_fail (VN_IS_MOD (obj), NULL);
|
|
|
|
return obj->priv->ui;
|
|
}
|
|
|
|
void vn_mod_set_ui (VnMod * obj, gchar * ui)
|
|
{
|
|
g_return_if_fail (VN_IS_MOD (obj));
|
|
|
|
g_free (obj->priv->ui);
|
|
obj->priv->ui = ui;
|
|
}
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
|
|
|
|
enum
|
|
{
|
|
PROP_NAME = 1
|
|
,PROP_DATA_DIR
|
|
,PROP_MODULE
|
|
,PROP_TEXT_DOMAIN
|
|
};
|
|
|
|
static void vn_mod_set_property (VnMod * obj, guint id,
|
|
const GValue * value, GParamSpec * pspec)
|
|
{
|
|
switch (id)
|
|
{
|
|
case PROP_NAME:
|
|
obj->priv->name = g_value_dup_string (value);
|
|
obj->priv->text_domain = g_strdup_printf ("hedera-%s", obj->priv->name);
|
|
bindtextdomain (obj->priv->text_domain, _HEDERA_LOCALE_DIR);
|
|
break;
|
|
case PROP_DATA_DIR:
|
|
obj->priv->data_dir = g_value_dup_string (value);
|
|
break;
|
|
case PROP_MODULE:
|
|
obj->priv->module = g_value_get_pointer (value);
|
|
break;
|
|
default:
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
|
}
|
|
}
|
|
|
|
static void vn_mod_get_property (VnMod * obj, guint id,
|
|
GValue * value, GParamSpec * pspec)
|
|
{
|
|
switch (id)
|
|
{
|
|
case PROP_NAME:
|
|
g_value_set_string (value, obj->priv->name);
|
|
break;
|
|
case PROP_DATA_DIR:
|
|
g_value_set_string (value, obj->priv->data_dir);
|
|
break;
|
|
case PROP_MODULE:
|
|
g_value_set_pointer (value, obj->priv->module);
|
|
break;
|
|
case PROP_TEXT_DOMAIN:
|
|
g_value_set_string (value, obj->priv->text_domain);
|
|
break;
|
|
default:
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
|
}
|
|
}
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
|
|
|
static void vn_mod_init (VnMod * obj)
|
|
{
|
|
obj->priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, VN_TYPE_MOD, VnModPrivate);
|
|
obj->priv->name = NULL;
|
|
obj->priv->data_dir = NULL;
|
|
obj->priv->module = NULL;
|
|
obj->priv->text_domain = NULL;
|
|
obj->priv->ui = NULL;
|
|
obj->priv->actions = NULL;
|
|
}
|
|
|
|
static void vn_mod_finalize (VnMod * obj)
|
|
{
|
|
g_free (obj->priv->name);
|
|
g_free (obj->priv->data_dir);
|
|
g_free (obj->priv->text_domain);
|
|
g_free (obj->priv->ui);
|
|
g_object_unref (obj->priv->actions);
|
|
G_OBJECT_CLASS (vn_mod_parent_class)->finalize (G_OBJECT (obj));
|
|
}
|
|
|
|
static void vn_mod_class_init (VnModClass * k)
|
|
{
|
|
GObjectClass * klass = G_OBJECT_CLASS (k);
|
|
klass->finalize = (GObjectFinalizeFunc) vn_mod_finalize;
|
|
klass->set_property = (GObjectSetPropertyFunc) vn_mod_set_property;
|
|
klass->get_property = (GObjectGetPropertyFunc) vn_mod_get_property;
|
|
g_type_class_add_private (klass, sizeof (VnModPrivate));
|
|
|
|
g_object_class_install_property (klass, PROP_NAME,
|
|
g_param_spec_string ("name"
|
|
,"Name"
|
|
,"The module name"
|
|
,NULL
|
|
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE
|
|
));
|
|
g_object_class_install_property (klass, PROP_DATA_DIR,
|
|
g_param_spec_string ("data-dir"
|
|
,"Data directory"
|
|
,"The directory in which the data of the module is allocated"
|
|
,NULL
|
|
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE
|
|
));
|
|
g_object_class_install_property (klass, PROP_MODULE,
|
|
g_param_spec_pointer ("module"
|
|
,"Module"
|
|
,"The GModule"
|
|
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE
|
|
));
|
|
g_object_class_install_property (klass, PROP_TEXT_DOMAIN,
|
|
g_param_spec_string ("text-domain"
|
|
,"Text domain"
|
|
,"The domain in wich the module is"
|
|
,NULL
|
|
,G_PARAM_READABLE
|
|
));
|
|
}
|