Action entries del menú de formularios pasados a VnMod y aceleradores quitados de la definicion del modulo

This commit is contained in:
Alejandro T. Colombini Gómez 2014-05-22 12:54:00 +02:00
parent 2805237c3c
commit 15948e9158
5 changed files with 66 additions and 24 deletions

View File

@ -11,8 +11,7 @@
translatable="yes"
name="consulter"
icon="system-run"
action-name="open-consulter"
accel="F1">Consulter</form>
action-name="open-consulter">Consulter</form>
</form-group>
</module>

View File

@ -18,5 +18,4 @@
name CDATA #REQUIRED
icon CDATA #IMPLIED
action-name CDATA #IMPLIED
accel CDATA #IMPLIED
>

View File

@ -359,7 +359,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
g_hash_table_replace (obj->forms, g_strdup (name->str), iter);
if (g_strcmp0 ("", action_name->str))
{//TODO Free this somewhere!
{
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);
@ -380,8 +380,8 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
gdome_str_unref (title);
}
obj->mod_actions = g_slist_prepend (obj->mod_actions, mod_actions);
obj->modules = g_slist_prepend (obj->modules, g_object_ref (mod));
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);
@ -392,7 +392,6 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
gdome_str_unref (name_str);
gdome_str_unref (mod_title);
gdome_nl_unref (nl, &e);
// gdome_nl_unref (action_nl, &e);
}
static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNotebook * notebook)
@ -419,8 +418,7 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
,"has-subtitle", TRUE
,"title", gtk_window_get_title (widget)
,NULL);
gtk_window_set_titlebar (widget,
GTK_WIDGET (window->header));
gtk_window_set_titlebar (widget, GTK_WIDGET (window->header));
button = gtk_menu_button_new ();
g_action_map_add_action_entries (G_ACTION_MAP (window->widget),
@ -438,12 +436,9 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
// Loading the modules actions
for (n = obj->mod_actions; n; n = n->next)
{
GActionEntry * entries = n->data;
for (n = obj->modules; n; n = n->next)
g_action_map_add_action_entries (G_ACTION_MAP (window->widget),
entries, -1, window);
}
vn_mod_get_action_entries (VN_MOD (n->data)), -1, window);
gtk_widget_show_all (GTK_WIDGET (widget));
return window;
@ -857,8 +852,6 @@ void vn_gui_open (VnGui * obj)
obj->main_menu = gtk_builder_get (builder, "win-menu");
section = gtk_builder_get (builder, "modules");
obj->modules = g_slist_reverse (obj->modules);
for (n = obj->modules; n; n = n->next)
{
VnMod * mod = VN_MOD (n->data);
@ -1317,6 +1310,8 @@ static void vn_gui_set_property (VnGui * obj, guint id,
}
}
obj->modules = g_slist_reverse (obj->modules);
break;
}
default:
@ -1355,7 +1350,7 @@ static void vn_gui_init (VnGui * obj)
obj->data_dirs = NULL;
obj->config_file = NULL;
obj->main_menu = NULL;
obj->mod_actions = NULL;
// obj->mod_actions = NULL;
obj->modules = NULL;
obj->forms = g_hash_table_new_full (
@ -1379,7 +1374,7 @@ static void vn_gui_finalize (VnGui * obj)
db_conn_close (obj->conn, FALSE);
g_hash_table_unref (obj->forms);
g_slist_free_full (obj->mod_actions, g_free);
// g_slist_free_full (obj->mod_actions, g_free);
g_slist_free_full (obj->modules, g_object_unref);
g_clear_object (&obj->conn);
g_clear_object (&obj->tree);

View File

@ -23,6 +23,7 @@ struct _VnModPrivate
gchar * data_dir;
gchar * text_domain;
GModule * module;
GActionEntry * actions;
};
G_DEFINE_TYPE (VnMod, vn_mod, G_TYPE_OBJECT);
@ -95,6 +96,50 @@ 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;
}
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
@ -163,6 +208,7 @@ static void vn_mod_init (VnMod * obj)
obj->priv->data_dir = NULL;
obj->priv->module = NULL;
obj->priv->text_domain = NULL;
obj->priv->actions = NULL;
}
static void vn_mod_finalize (VnMod * obj)
@ -170,6 +216,7 @@ 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));
}

View File

@ -53,5 +53,7 @@ const gchar * vn_mod_get_name (VnMod * obj);
const gchar * vn_mod_get_text_domain (VnMod * obj);
const gchar * vn_mod_get_data_dir (VnMod * obj);
GMenuModel * vn_mod_get_menu_model (VnMod * obj);
void vn_mod_set_action_entries (VnMod * obj, GActionEntry * actions);
const GActionEntry * vn_mod_get_action_entries (VnMod * obj);
#endif