[ekiga/ds-gtk-application] UI: Pass Action by name instead of pointer in ActorMenu.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] UI: Pass Action by name instead of pointer in ActorMenu.
- Date: Sun, 23 Mar 2014 16:25:42 +0000 (UTC)
commit 9e63c9dddb9c129a7d15eadb839c071ba6fb09c1
Author: Damien Sandras <dsandras beip be>
Date: Sun Mar 23 17:20:41 2014 +0100
UI: Pass Action by name instead of pointer in ActorMenu.
This looks better, especially as we are using g_object_set_data on the
GObject.
lib/engine/gui/gtk-core/actor-menu.cpp | 13 +++++++++----
lib/engine/gui/gtk-core/actor-menu.h | 2 +-
2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/lib/engine/gui/gtk-core/actor-menu.cpp b/lib/engine/gui/gtk-core/actor-menu.cpp
index d8c74c3..efe3fe5 100644
--- a/lib/engine/gui/gtk-core/actor-menu.cpp
+++ b/lib/engine/gui/gtk-core/actor-menu.cpp
@@ -49,7 +49,7 @@ action_activated (GSimpleAction *a,
G_GNUC_UNUSED GVariant *p,
gpointer data)
{
- Ekiga::Action *action = (Ekiga::Action *) g_object_get_data (G_OBJECT (a), "action");
+ const char *action = (const char *) g_object_get_data (G_OBJECT (a), "action");
Ekiga::ActorMenu *menu = (Ekiga::ActorMenu *) data;
g_return_if_fail (action && menu);
@@ -114,7 +114,9 @@ Ekiga::ActorMenu::add_gio_action (Ekiga::ActionPtr a)
return;
action = g_simple_action_new (a->get_name ().c_str (), NULL);
- g_object_set_data (G_OBJECT (action), "action", a.get ());
+ g_object_set_data_full (G_OBJECT (action), "action",
+ g_strdup (a->get_name ().c_str ()),
+ (GDestroyNotify) g_free);
g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()),
G_ACTION (action));
g_signal_connect (action, "activate",
@@ -147,9 +149,12 @@ Ekiga::ActorMenu::get_xml_menu (const std::string & id,
void
-Ekiga::ActorMenu::activate (Ekiga::Action *action)
+Ekiga::ActorMenu::activate (const std::string & name)
{
- action->activate ();
+ ActionMap::const_iterator it = obj.actions.find (name);
+
+ if (it != obj.actions.end ())
+ it->second->activate ();
}
diff --git a/lib/engine/gui/gtk-core/actor-menu.h b/lib/engine/gui/gtk-core/actor-menu.h
index bf70603..6ac815f 100644
--- a/lib/engine/gui/gtk-core/actor-menu.h
+++ b/lib/engine/gui/gtk-core/actor-menu.h
@@ -63,7 +63,7 @@ namespace Ekiga {
ActorMenu (Actor & obj);
virtual ~ActorMenu ();
- virtual void activate (Ekiga::Action *action);
+ virtual void activate (const std::string & name);
virtual const std::string as_xml (const std::string & id = "");
static const std::string get_xml_menu (const std::string & id,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]