VnMod, VnGui:
- Las opciones para abrir los formularios del módulo ya no se generan en VnGui, se indican en el fichero de descripción del menú con la acción open-form y como target el nombre del módulo. - Las otras acciones de los módulos se definen en las hijas de VnMod.
This commit is contained in:
parent
8fd996579f
commit
8c29ca63f9
|
@ -23,7 +23,7 @@ anjuta_datadir = $(templatedir)/data
|
|||
anjuta_data_DATA = \
|
||||
hedera/data/Makefile.am.tpl \
|
||||
hedera/data/form.glade \
|
||||
hedera/data/mod-menu.glade.tpl \
|
||||
hedera/data/mod-menu.xml.tpl \
|
||||
hedera/data/mod.xml.tpl
|
||||
|
||||
anjuta_sqldir = $(templatedir)/sql/mod
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<directory source="data">
|
||||
<file source="form.glade" destination="[+FormName+].glade"/>
|
||||
<file source="mod.xml.tpl" destination="[+Name+].xml"/>
|
||||
<file source="mod-menu.glade.tpl" destination="[+Name+]-menu.glade"/>
|
||||
<file source="mod-menu.xml.tpl" destination="[+Name+]-menu.xml"/>
|
||||
<file source="Makefile.am.tpl" destination="Makefile.am"/>
|
||||
</directory>
|
||||
<directory source="sql">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
[+NameCLower+]_data_DATA = \
|
||||
[+Name+].xml \
|
||||
[+Name+]-menu.glade \
|
||||
[+Name+]-menu.xml \
|
||||
[+FormName+].glade
|
||||
|
||||
EXTRA_DIST = $([+NameCLower+]_data_DATA)
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
<menu id='menu'>
|
||||
<item>
|
||||
<attribute name='label' translatable='yes'>[+FormClassName+]</attribute>
|
||||
<attribute name='action'>win.open-[+FormName+]</attribute>
|
||||
<attribute name='accel'></attribute>
|
||||
<attribute name='action'>win.open-form</attribute>
|
||||
<attribute name='target'>[+FormName+]</attribute>
|
||||
<attribute name='accel'>F1</attribute>
|
||||
</item>
|
||||
</menu>
|
||||
</interface>
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
<form
|
||||
translatable="yes"
|
||||
name="[+FormName+]"
|
||||
icon="gtk-find-and-replace"
|
||||
action-name="open-[+FormName+]">
|
||||
icon="gtk-find-and-replace">
|
||||
[+FormClassName+]
|
||||
</form>
|
||||
</form-group>
|
||||
</module>
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
src/[+Name+].vala
|
||||
src/[+FormName+].vala
|
||||
data/[+FormName+].glade
|
||||
[type: gettext/glade]data/[+Name+]-menu.xml
|
||||
[type: gettext/glade]data/[+Name+].xml
|
||||
data/[+Name+]-menu.glade
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
libhedera (1.0-11) stable; urgency=low
|
||||
libhedera (1.0-13) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
<section>
|
||||
<item>
|
||||
<attribute name='label' translatable='yes'>Consulter</attribute>
|
||||
<attribute name='action'>win.open-consulter</attribute>
|
||||
<attribute name='accel'>F1</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name='label' translatable='yes'>Consulter action</attribute>
|
||||
<attribute name='action'>win.example-action</attribute>
|
||||
<attribute name='action'>win.open-form</attribute>
|
||||
<attribute name='target'>consulter</attribute>
|
||||
<attribute name='accel'>F12</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
<form
|
||||
translatable="yes"
|
||||
name="consulter"
|
||||
icon="system-run"
|
||||
action-name="open-consulter">Consulter</form>
|
||||
icon="system-run">
|
||||
Consulter
|
||||
</form>
|
||||
</form-group>
|
||||
</module>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<!ELEMENT module (library|action-group|form-group)*>
|
||||
<!ELEMENT module (library|form-group)*>
|
||||
<!ELEMENT library (#PCDATA)>
|
||||
<!ELEMENT action-group (action)*>
|
||||
<!ELEMENT action EMPTY>
|
||||
<!ELEMENT form-group (form)*>
|
||||
<!ELEMENT form (#PCDATA)>
|
||||
|
||||
|
@ -9,13 +7,8 @@
|
|||
translatable (yes|no) #IMPLIED
|
||||
name CDATA #REQUIRED
|
||||
>
|
||||
<!ATTLIST action
|
||||
name CDATA #REQUIRED
|
||||
activate CDATA #REQUIRED
|
||||
>
|
||||
<!ATTLIST form
|
||||
translatable (yes|no) #IMPLIED
|
||||
name CDATA #REQUIRED
|
||||
icon CDATA #IMPLIED
|
||||
action-name CDATA #IMPLIED
|
||||
>
|
||||
|
|
146
vn/vn-gui.c
146
vn/vn-gui.c
|
@ -84,11 +84,11 @@ void vn_gui_on_open_activated (GSimpleAction * a, GVariant * v, gpointer obj);
|
|||
void vn_gui_on_about_activated (GSimpleAction * a, GVariant * v, gpointer obj);
|
||||
void vn_gui_on_exit_activated (GSimpleAction * a, GVariant * v, gpointer obj);
|
||||
void vn_gui_on_close_tab_activated (GSimpleAction * a, GVariant * v, gpointer obj);
|
||||
void vn_gui_on_open_form_activated (GSimpleAction * action, GVariant * v, gpointer obj);
|
||||
|
||||
static void vn_gui_reconnect (VnGui * obj);
|
||||
static void vn_gui_on_conn_error (DbConn * conn, const GError * error, VnGui * obj);
|
||||
static void vn_gui_on_conn_status_changed (DbConn * conn, DbConnStatus status, VnGui * obj);
|
||||
void vn_gui_on_open_form_activated (GSimpleAction * action, GVariant * v, gpointer obj);
|
||||
void vn_gui_on_window_destroyed (GtkWindow * widget, VnWindow * window);
|
||||
void vn_gui_on_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window);
|
||||
|
||||
|
@ -108,6 +108,11 @@ static const GActionEntry win_entries[] =
|
|||
{"close", vn_gui_on_close_tab_activated}
|
||||
};
|
||||
|
||||
static const GActionEntry open_action[] =
|
||||
{
|
||||
{"open-form", vn_gui_on_open_form_activated, "s"}
|
||||
};
|
||||
|
||||
/**
|
||||
* vn_gui_new:
|
||||
* @app: a #GtkApplication
|
||||
|
@ -284,13 +289,18 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
|
|||
|
||||
if (module)
|
||||
{
|
||||
//TODO Get the type of the module
|
||||
// gchar * c_name = g_strdelimit (g_strdup (mod_name), "-. ", '_');
|
||||
GType mod_type = VN_TYPE_MOD;
|
||||
VnModGetTypeFunc mod_get_type_func;
|
||||
gchar * c_name = g_strdelimit (g_strdup (mod_name), "-. ", '_'),
|
||||
* symbol_name = g_strdup_printf ("vn_%s_get_type", c_name);
|
||||
|
||||
g_module_make_resident (module);
|
||||
|
||||
// symbol_name = g_strdup_printf ("vn_%s_get_type", c_name);
|
||||
if (g_module_symbol (module, symbol_name, (gpointer) &mod_get_type_func)
|
||||
&& g_type_is_a (mod_get_type_func (), VN_TYPE_MOD))
|
||||
mod_type = mod_get_type_func ();
|
||||
|
||||
mod = g_object_new (VN_TYPE_MOD
|
||||
mod = g_object_new (mod_type
|
||||
,"name" ,mod_name
|
||||
,"data-dir" ,dir
|
||||
,"module" ,module
|
||||
|
@ -299,7 +309,8 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
|
|||
,NULL
|
||||
);
|
||||
|
||||
// g_free (c_name);
|
||||
g_free (c_name);
|
||||
g_free (symbol_name);
|
||||
}
|
||||
else
|
||||
g_warning ("VnGui: Can't load module %s: %s", mod_name, g_module_error ());
|
||||
|
@ -308,106 +319,6 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
|
|||
|
||||
if (mod)
|
||||
{
|
||||
GType type;
|
||||
gulong len, n;
|
||||
gchar * c_name;
|
||||
gchar * title_strip;
|
||||
GdomeDOMString * name;
|
||||
GdomeDOMString * icon;
|
||||
GdomeDOMString * action_name;
|
||||
GdomeDOMString * title;
|
||||
gchar * symbol_name;
|
||||
GtkTreeIter parent_iter;
|
||||
GtkTreeIter * iter;
|
||||
VnFormGetTypeFunc mod_get_type_func;
|
||||
GActionEntry * mod_actions;
|
||||
GdomeDOMString * icon_str = S("icon"),
|
||||
* action_name_str = S("action-name");
|
||||
|
||||
// Creating folder to put forms inside
|
||||
|
||||
text_dom = vn_mod_get_text_domain (mod);
|
||||
gtk_tree_store_append (obj->tree, &parent_iter, NULL);
|
||||
gtk_tree_store_set (obj->tree, &parent_iter
|
||||
,COL_ICON ,"gtk-directory"
|
||||
,COL_TITLE ,g_dgettext (text_dom, mod_title_strip)
|
||||
,COL_TYPE ,G_TYPE_NONE
|
||||
,COL_NAME ,NULL
|
||||
,-1
|
||||
);
|
||||
|
||||
len = gdome_nl_length (nl, &e);
|
||||
mod_actions = g_new0 (GActionEntry, len + 1);
|
||||
|
||||
for (n = 0; n < len; n++)
|
||||
{
|
||||
// Getting form info
|
||||
|
||||
el = (GdomeElement *) gdome_nl_item (nl, n, &e);
|
||||
icon = gdome_el_getAttribute (el, icon_str, &e);
|
||||
action_name = gdome_el_getAttribute (el, action_name_str, &e);
|
||||
|
||||
name = gdome_el_getAttribute (el, name_str, &e);
|
||||
c_name = g_strdelimit (g_strdup (name->str), "-. ", '_');
|
||||
|
||||
node = gdome_el_firstChild (el, &e);
|
||||
title = gdome_n_nodeValue (node, &e);
|
||||
title_strip = g_strstrip (g_strdup (g_dgettext (text_dom, title->str)));
|
||||
|
||||
gdome_n_unref (node, &e);
|
||||
gdome_el_unref (el, &e);
|
||||
|
||||
// Loading form action entries
|
||||
|
||||
symbol_name = g_strdup_printf ("vn_%s_get_type", c_name);
|
||||
|
||||
if (g_module_symbol (module, symbol_name, (gpointer) &mod_get_type_func))
|
||||
{
|
||||
type = mod_get_type_func ();
|
||||
|
||||
if (g_type_is_a (type, VN_TYPE_FORM))
|
||||
{
|
||||
iter = g_new (GtkTreeIter, 1);
|
||||
gtk_tree_store_append (obj->tree, iter, &parent_iter);
|
||||
gtk_tree_store_set (obj->tree, iter
|
||||
,COL_NAME ,name->str
|
||||
,COL_ICON ,icon->str
|
||||
,COL_TITLE ,title_strip
|
||||
,COL_TYPE ,type
|
||||
,COL_MODULE ,mod
|
||||
,-1
|
||||
);
|
||||
g_hash_table_replace (obj->forms, g_strdup (name->str), iter);
|
||||
|
||||
if (g_strcmp0 ("", action_name->str))
|
||||
{
|
||||
mod_actions[n].name = g_strdup (action_name->str);
|
||||
mod_actions[n].activate = vn_gui_on_open_form_activated;
|
||||
mod_actions[n].state = g_strconcat ("\"", name->str, "\"", NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
g_warning ("VnGui: %s isn't a VnForm", g_type_name (type));
|
||||
}
|
||||
else
|
||||
g_warning ("VnGui: Error loading form: %s", g_module_error ());
|
||||
|
||||
g_free (c_name);
|
||||
g_free (title_strip);
|
||||
g_free (symbol_name);
|
||||
gdome_str_unref (name);
|
||||
gdome_str_unref (icon);
|
||||
gdome_str_unref (action_name);
|
||||
gdome_str_unref (title);
|
||||
}
|
||||
|
||||
vn_mod_set_action_entries (mod, mod_actions);
|
||||
obj->modules = g_slist_prepend (obj->modules, mod);
|
||||
|
||||
gdome_str_unref (icon_str);
|
||||
gdome_str_unref (action_name_str);
|
||||
}
|
||||
/* {
|
||||
gulong len, n;
|
||||
GtkTreeIter parent_iter;
|
||||
GdomeDOMString * icon_str = S("icon");
|
||||
|
@ -430,7 +341,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
|
|||
{
|
||||
gchar * c_name, * title_strip, * symbol_name;
|
||||
GdomeDOMString * icon, * name, * title;
|
||||
VnFormGetTypeFunc mod_get_type_func;
|
||||
VnFormGetTypeFunc form_get_type_func;
|
||||
|
||||
el = (GdomeElement *) gdome_nl_item (nl, n, &e);
|
||||
icon = gdome_el_getAttribute (el, icon_str, &e);
|
||||
|
@ -447,9 +358,9 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
|
|||
|
||||
symbol_name = g_strdup_printf ("vn_%s_get_type", c_name);
|
||||
|
||||
if (g_module_symbol (module, symbol_name, (gpointer) &mod_get_type_func))
|
||||
if (g_module_symbol (module, symbol_name, (gpointer) &form_get_type_func))
|
||||
{
|
||||
GType type = mod_get_type_func ();
|
||||
GType type = form_get_type_func ();
|
||||
|
||||
if (g_type_is_a (type, VN_TYPE_FORM))
|
||||
{
|
||||
|
@ -484,7 +395,6 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
|
|||
|
||||
gdome_str_unref (icon_str);
|
||||
}
|
||||
*/
|
||||
|
||||
g_free (mod_title_strip);
|
||||
g_free (mod_name);
|
||||
|
@ -601,13 +511,16 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
|
|||
|
||||
// Loading the modules actions
|
||||
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (window->widget),
|
||||
open_action, G_N_ELEMENTS (open_action), window);
|
||||
|
||||
for (n = obj->modules; n; n = n->next)
|
||||
{
|
||||
gint size;
|
||||
VnMod * mod = VN_MOD (n->data);
|
||||
const GActionEntry * actions = vn_mod_get_actions (mod, &size);
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (window->widget),
|
||||
vn_mod_get_action_entries (VN_MOD (n->data)), -1, window);
|
||||
/*gint size;
|
||||
const GActionEntry * actions = vn_mod_get_actions (VN_MOD (n->data), &size);
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (window->widget), actions, size, window);*/
|
||||
actions, size, mod);
|
||||
}
|
||||
|
||||
vn_gui_set_menu_accels (obj, obj->main_menu, TRUE);
|
||||
|
@ -622,7 +535,7 @@ g_action_map_add_action_entries (G_ACTION_MAP (window->widget), actions, size, w
|
|||
static void vn_gui_show_error (VnGui * obj, const GError * error)
|
||||
{
|
||||
GtkWidget * dialog;
|
||||
GtkWindow * window = obj->active_window->widget;
|
||||
GtkWindow * window = obj->active_window ? obj->active_window->widget : NULL;
|
||||
|
||||
if (error && error->code == DB_CONN_ERROR_LOST)
|
||||
dialog = gtk_message_dialog_new (window
|
||||
|
@ -910,8 +823,7 @@ void vn_gui_on_page_added (GtkNotebook * notebook, GtkWidget * page, guint num,
|
|||
void vn_gui_on_open_form_activated (GSimpleAction * a, GVariant * p, gpointer obj)
|
||||
{
|
||||
VnWindow * window = obj;
|
||||
vn_gui_open_form_at_window (window->obj,
|
||||
g_variant_get_string (g_action_get_state (G_ACTION (a)), NULL), window);
|
||||
vn_gui_open_form_at_window (window->obj, g_variant_get_string (p, NULL), window);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
45
vn/vn-mod.c
45
vn/vn-mod.c
|
@ -109,35 +109,6 @@ GMenuModel * vn_mod_get_menu_model (VnMod * obj)
|
|||
return menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* vn_mod_set_action_entries:
|
||||
* @obj: a #VnMod
|
||||
* @actions: a #GActionEntry array
|
||||
*
|
||||
* Sets the actions for the menu displayed for @obj.
|
||||
**/
|
||||
void vn_mod_set_action_entries (VnMod * obj, GActionEntry * actions)
|
||||
{
|
||||
g_return_if_fail (VN_IS_MOD (obj));
|
||||
|
||||
obj->priv->actions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* vn_mod_get_action_entries:
|
||||
* @obj: a #VnMod
|
||||
*
|
||||
* Returns the actions for the menu displayed for @obj.
|
||||
*
|
||||
* Return value:(transfer none): a #GActionEntry
|
||||
**/
|
||||
const GActionEntry * vn_mod_get_action_entries (VnMod * obj)
|
||||
{
|
||||
g_return_if_fail (VN_IS_MOD (obj));
|
||||
|
||||
return obj->priv->actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* vn_mod_get_actions: (virtual get_actions):
|
||||
* @obj: a #VnMod
|
||||
|
@ -160,21 +131,6 @@ const GActionEntry * vn_mod_get_actions (VnMod * obj, gint * size)
|
|||
return VN_MOD_GET_CLASS (obj)->get_actions (obj, size);
|
||||
}
|
||||
|
||||
static void vn_mod_free_action_entry (VnMod * obj)
|
||||
{
|
||||
gint i;
|
||||
GActionEntry * actions = obj->priv->actions;
|
||||
|
||||
if (actions)
|
||||
for (i = 0; actions[i].name != NULL; i++)
|
||||
{
|
||||
g_free ((gchar *) actions[i].name);
|
||||
g_free ((gchar *) actions[i].state);
|
||||
}
|
||||
|
||||
g_free (actions);
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
|
||||
|
||||
enum
|
||||
|
@ -268,7 +224,6 @@ static void vn_mod_finalize (VnMod * obj)
|
|||
g_free (obj->priv->name);
|
||||
g_free (obj->priv->data_dir);
|
||||
g_free (obj->priv->text_domain);
|
||||
vn_mod_free_action_entry (obj);
|
||||
G_OBJECT_CLASS (vn_mod_parent_class)->finalize (G_OBJECT (obj));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ const gchar * vn_mod_get_text_domain (VnMod * obj);
|
|||
const gchar * vn_mod_get_data_dir (VnMod * obj);
|
||||
const gchar * vn_mod_get_title (VnMod * obj);
|
||||
GMenuModel * vn_mod_get_menu_model (VnMod * obj);
|
||||
const GActionEntry * vn_mod_get_open_action ();
|
||||
const GActionEntry * vn_mod_get_actions (VnMod * obj, int * size);
|
||||
void vn_mod_set_action_entries (VnMod * obj, GActionEntry * actions);
|
||||
const GActionEntry * vn_mod_get_action_entries (VnMod * obj);
|
||||
|
||||
#endif
|
Reference in New Issue