[ekiga/ds-gtk-application] GActorMenu: Added the possibility to name menu sections.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] GActorMenu: Added the possibility to name menu sections.
- Date: Sun, 30 Nov 2014 10:28:12 +0000 (UTC)
commit b8c52d550e70c1b2b1938337ab950cbb9123afd0
Author: Damien Sandras <dsandras seconix com>
Date: Sun Nov 23 11:07:43 2014 +0100
GActorMenu: Added the possibility to name menu sections.
lib/engine/gui/gtk-core/gactor-menu.cpp | 40 ++++++++++++++++++++++--------
lib/engine/gui/gtk-core/gactor-menu.h | 5 ++++
2 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/lib/engine/gui/gtk-core/gactor-menu.cpp b/lib/engine/gui/gtk-core/gactor-menu.cpp
index 144572f..7bd5ed6 100644
--- a/lib/engine/gui/gtk-core/gactor-menu.cpp
+++ b/lib/engine/gui/gtk-core/gactor-menu.cpp
@@ -57,16 +57,13 @@ action_activated (GSimpleAction *a,
Ekiga::GActorMenu::GActorMenu (Ekiga::Actor & _obj) : obj (_obj)
{
- n = 0;
- builder = gtk_builder_new ();
-
- sync_gio_actions ();
+ ctor_init ();
+}
- conns.add (obj.action_enabled.connect (boost::bind (static_cast<void (Ekiga::GActorMenu::*)(const
std::string&)>(&Ekiga::GActorMenu::add_gio_action), this, _1)));
- conns.add (obj.action_disabled.connect (boost::bind (&Ekiga::GActorMenu::remove_gio_action, this, _1)));
- conns.add (obj.action_added.connect (boost::bind (static_cast<void (Ekiga::GActorMenu::*)(const
std::string&)>(&Ekiga::GActorMenu::add_gio_action), this, _1)));
- conns.add (obj.action_removed.connect (boost::bind (&Ekiga::GActorMenu::remove_gio_action, this, _1)));
+Ekiga::GActorMenu::GActorMenu (Ekiga::Actor & _obj, const std::string & _name) : obj (_obj), name (_name)
+{
+ ctor_init ();
}
@@ -170,9 +167,11 @@ Ekiga::GActorMenu::add_gio_action (Ekiga::ActionPtr a)
GSimpleAction *action = NULL;
/* Action is disabled or already present */
- if (!a->is_enabled ()
- || g_action_map_lookup_action (G_ACTION_MAP (g_application_get_default ()),
- a->get_name ().c_str ()))
+ if (!a->is_enabled ())
+ return;
+
+ if (g_action_map_lookup_action (G_ACTION_MAP (g_application_get_default ()),
+ a->get_name ().c_str ()))
return;
action = g_simple_action_new (a->get_name ().c_str (), NULL);
@@ -208,6 +207,9 @@ Ekiga::GActorMenu::as_xml (const std::string & id)
else
xml_content += " <section>";
+ if (!name.empty ())
+ xml_content += " <attribute name=\"label\" translatable=\"yes\">"+name+"</attribute>";
+
for (it = obj.begin(); it != obj.end(); ++it) {
xml_content +=
@@ -231,3 +233,19 @@ Ekiga::GActorMenu::build ()
std::string xml_content = "<menu id=\"menu\">" + as_xml () + "</menu>";
return "<?xml_content version=\"1.0\"?><interface>" + xml_content + "</interface>";
}
+
+
+void
+Ekiga::GActorMenu::ctor_init ()
+{
+ n = 0;
+ builder = gtk_builder_new ();
+
+ sync_gio_actions ();
+
+ conns.add (obj.action_enabled.connect (boost::bind (static_cast<void (Ekiga::GActorMenu::*)(const
std::string&)>(&Ekiga::GActorMenu::add_gio_action), this, _1)));
+ conns.add (obj.action_disabled.connect (boost::bind (&Ekiga::GActorMenu::remove_gio_action, this, _1)));
+
+ conns.add (obj.action_added.connect (boost::bind (static_cast<void (Ekiga::GActorMenu::*)(const
std::string&)>(&Ekiga::GActorMenu::add_gio_action), this, _1)));
+ conns.add (obj.action_removed.connect (boost::bind (&Ekiga::GActorMenu::remove_gio_action, this, _1)));
+}
diff --git a/lib/engine/gui/gtk-core/gactor-menu.h b/lib/engine/gui/gtk-core/gactor-menu.h
index 8a387ee..a9e1be4 100644
--- a/lib/engine/gui/gtk-core/gactor-menu.h
+++ b/lib/engine/gui/gtk-core/gactor-menu.h
@@ -73,6 +73,8 @@ namespace Ekiga {
public:
GActorMenu (Actor & obj);
+ GActorMenu (Actor & obj,
+ const std::string & name);
virtual ~GActorMenu ();
@@ -129,9 +131,12 @@ namespace Ekiga {
Actor & obj;
private:
+ void ctor_init ();
+
Ekiga::scoped_connections conns;
unsigned n;
GtkBuilder *builder;
+ std::string name;
};
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]