diff --git a/anjuta/Makefile.am b/anjuta/Makefile.am
index 6c4eb27..344a7be 100644
--- a/anjuta/Makefile.am
+++ b/anjuta/Makefile.am
@@ -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
diff --git a/anjuta/hedera.wiz b/anjuta/hedera.wiz
index 0e582c6..904b47e 100644
--- a/anjuta/hedera.wiz
+++ b/anjuta/hedera.wiz
@@ -76,7 +76,7 @@
-
+
diff --git a/anjuta/hedera/data/Makefile.am.tpl b/anjuta/hedera/data/Makefile.am.tpl
index b311281..eb1e1b0 100644
--- a/anjuta/hedera/data/Makefile.am.tpl
+++ b/anjuta/hedera/data/Makefile.am.tpl
@@ -4,7 +4,7 @@
[+NameCLower+]_data_DATA = \
[+Name+].xml \
- [+Name+]-menu.glade \
+ [+Name+]-menu.xml \
[+FormName+].glade
EXTRA_DIST = $([+NameCLower+]_data_DATA)
diff --git a/anjuta/hedera/data/mod-menu.xml.tpl b/anjuta/hedera/data/mod-menu.xml.tpl
index a4eef45..f0969ea 100644
--- a/anjuta/hedera/data/mod-menu.xml.tpl
+++ b/anjuta/hedera/data/mod-menu.xml.tpl
@@ -4,8 +4,9 @@
diff --git a/anjuta/hedera/data/mod.xml.tpl b/anjuta/hedera/data/mod.xml.tpl
index 5f6afc7..ef072ac 100644
--- a/anjuta/hedera/data/mod.xml.tpl
+++ b/anjuta/hedera/data/mod.xml.tpl
@@ -6,10 +6,8 @@
-
diff --git a/anjuta/hedera/po/POTFILES.in.tpl b/anjuta/hedera/po/POTFILES.in.tpl
index ad39bd2..2701ca6 100644
--- a/anjuta/hedera/po/POTFILES.in.tpl
+++ b/anjuta/hedera/po/POTFILES.in.tpl
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 3c2aa05..85f6205 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-libhedera (1.0-11) stable; urgency=low
+libhedera (1.0-13) stable; urgency=low
* Initial Release.
diff --git a/module/data/example-menu.xml b/module/data/example-menu.xml
index bf9cc46..c274a55 100644
--- a/module/data/example-menu.xml
+++ b/module/data/example-menu.xml
@@ -4,14 +4,9 @@
-
Consulter
- win.open-consulter
- F1
-
-
-
- -
- Consulter action
- win.example-action
+ win.open-form
+ consulter
+ F12
diff --git a/module/data/example.xml b/module/data/example.xml
index e4aefb1..c04bd13 100644
--- a/module/data/example.xml
+++ b/module/data/example.xml
@@ -5,7 +5,8 @@
+ icon="system-run">
+ Consulter
+
diff --git a/vn/schema/module.dtd b/vn/schema/module.dtd
index 1c418e9..43065f4 100644
--- a/vn/schema/module.dtd
+++ b/vn/schema/module.dtd
@@ -1,7 +1,5 @@
-
+
-
-
@@ -9,13 +7,8 @@
translatable (yes|no) #IMPLIED
name CDATA #REQUIRED
>
-
diff --git a/vn/vn-gui.c b/vn/vn-gui.c
index 11f22b8..eb6bf0a 100644
--- a/vn/vn-gui.c
+++ b/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);
}
/*
diff --git a/vn/vn-mod.c b/vn/vn-mod.c
index b728fe0..3e31cf4 100644
--- a/vn/vn-mod.c
+++ b/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));
}
diff --git a/vn/vn-mod.h b/vn/vn-mod.h
index 6375d2f..cb90656 100644
--- a/vn/vn-mod.h
+++ b/vn/vn-mod.h
@@ -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
\ No newline at end of file