[ekiga/ds-gtk-application] Engine: Added GTK+ (GIO) representation for Actors and their Actions.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] Engine: Added GTK+ (GIO) representation for Actors and their Actions.
- Date: Tue, 4 Mar 2014 19:32:45 +0000 (UTC)
commit 1eb7d5ccda47470e27333615b8955ef16be08392
Author: Damien Sandras <dsandras beip be>
Date: Mon Mar 3 20:33:43 2014 +0100
Engine: Added GTK+ (GIO) representation for Actors and their Actions.
lib/Makefile.am | 4 +-
lib/engine/gui/gtk-core/actor-menu.cpp | 179 ++++++++++++++++++++++++++++++++
lib/engine/gui/gtk-core/actor-menu.h | 95 +++++++++++++++++
3 files changed, 276 insertions(+), 2 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index be4571d..d0813e5 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -360,8 +360,8 @@ libekiga_la_SOURCES += \
engine/gui/gtk-core/menu-builder-gtk.cpp \
engine/gui/gtk-core/form-dialog-gtk.h \
engine/gui/gtk-core/form-dialog-gtk.cpp \
- engine/gui/gtk-core/live-object-menu.h \
- engine/gui/gtk-core/live-object-menu.cpp \
+ engine/gui/gtk-core/actor-menu.h \
+ engine/gui/gtk-core/actor-menu.cpp \
engine/gui/gtk-core/optional-buttons-gtk.h \
engine/gui/gtk-core/optional-buttons-gtk.cpp \
engine/gui/gtk-core/codecsbox.cpp \
diff --git a/lib/engine/gui/gtk-core/actor-menu.cpp b/lib/engine/gui/gtk-core/actor-menu.cpp
new file mode 100644
index 0000000..205ab23
--- /dev/null
+++ b/lib/engine/gui/gtk-core/actor-menu.cpp
@@ -0,0 +1,179 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 Damien Sandras <dsandras seconix com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * live-object-menu.cpp - description
+ * -------------------------------------
+ * begin : written in 2014 by Damien Sandras
+ * copyright : (c) 2014 by Damien Sandras
+ * description : A live object menu implementation
+ *
+ */
+
+#include <gio/gio.h>
+#include <string>
+
+#include "action.h"
+#include "contact-core.h"
+#include "live-object-menu.h"
+
+
+static void
+action_activated (GSimpleAction *a,
+ G_GNUC_UNUSED GVariant *p,
+ gpointer data)
+{
+ Ekiga::Action *action = (Ekiga::Action *) g_object_get_data (G_OBJECT (a), "action");
+ Ekiga::ActorMenu *menu = (Ekiga::ActorMenu *) data;
+
+ g_return_if_fail (action && menu);
+ menu->activate (action);
+}
+
+
+Ekiga::ActorMenu::ActorMenu (const Ekiga::Actor & _obj) : obj (_obj)
+{
+ GSimpleAction *action = NULL;
+ ActionMap::const_iterator it;
+
+ for (it = obj.actions.begin(); it != obj.actions.end(); ++it) {
+
+ if (!g_action_map_lookup_action (G_ACTION_MAP (g_application_get_default ()),
+ it->first.c_str ())) {
+
+ action = g_simple_action_new (it->first.c_str (), NULL);
+ g_object_set_data (G_OBJECT (action), "action", it->second.get ());
+ g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()),
+ G_ACTION (action));
+ g_signal_connect (action, "activate",
+ G_CALLBACK (action_activated),
+ (gpointer) this);
+ g_object_unref (action);
+
+ std::cout << "Added action " << it->first << std::endl << std::flush;
+ }
+ }
+}
+
+
+Ekiga::ActorMenu::~ActorMenu ()
+{
+ ActionMap::const_iterator it;
+
+ for (it = obj.actions.begin(); it != obj.actions.end(); ++it)
+ g_action_map_remove_action (G_ACTION_MAP (g_application_get_default ()),
+ it->first.c_str ());
+}
+
+
+const std::string
+Ekiga::ActorMenu::get_xml_menu (const std::string & id,
+ const std::string & content,
+ bool full)
+{
+ std::string xml_content = "<menu id=\"" + id + "\">" + content + "</menu>";
+
+ if (full)
+ return "<?xml_content version=\"1.0\"?><interface>" + xml_content + "</interface>";
+
+ return xml_content;
+}
+
+
+void
+Ekiga::ActorMenu::activate (Ekiga::Action *action)
+{
+ action->activate ();
+}
+
+
+const std::string
+Ekiga::ActorMenu::as_xml ()
+{
+ ActionMap::const_iterator it;
+
+ std::string xml_content =
+ " <section>";
+
+ for (it = obj.actions.begin(); it != obj.actions.end(); ++it) {
+
+ xml_content +=
+ " <item>"
+ " <attribute name=\"label\" translatable=\"yes\">"+it->second->get_description ()+"</attribute>"
+ " <attribute name=\"action\">win."+it->second->get_name ()+"</attribute>"
+ " </item>";
+ }
+
+ xml_content +=
+ " </section>";
+
+ return xml_content;
+}
+
+
+Ekiga::ContactActorMenu::ContactActorMenu (const Ekiga::Actor & _obj) : ActorMenu (_obj)
+{
+}
+
+
+void
+Ekiga::ContactActorMenu::set_data (Ekiga::ContactPtr _contact,
+ const std::string & _uri)
+{
+ contact = _contact;
+ uri = _uri;
+}
+
+
+const std::string
+Ekiga::ContactActorMenu::as_xml ()
+{
+ ActionMap::const_iterator it;
+
+ std::string xml_content =
+ " <section>";
+
+ for (it = obj.actions.begin(); it != obj.actions.end(); ++it) {
+
+ Ekiga::ContactAction *action = dynamic_cast<Ekiga::ContactAction *> (it->second.get ());
+
+ if (action && action->can_run_with_data (contact, uri)) {
+ action->set_data (contact, uri);
+ xml_content +=
+ " <item>"
+ " <attribute name=\"label\" translatable=\"yes\">"+it->second->get_description
()+"</attribute>"
+ " <attribute name=\"action\">win."+it->second->get_name ()+"</attribute>"
+ " </item>";
+ }
+ }
+
+ xml_content +=
+ " </section>";
+
+ return xml_content;
+}
diff --git a/lib/engine/gui/gtk-core/actor-menu.h b/lib/engine/gui/gtk-core/actor-menu.h
new file mode 100644
index 0000000..376e445
--- /dev/null
+++ b/lib/engine/gui/gtk-core/actor-menu.h
@@ -0,0 +1,95 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 Damien Sandras <dsandras seconix com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * live-object-menu.h - description
+ * ----------------------------------
+ * begin : written in 2014 by Damien Sandras
+ * copyright : (c) 2014 by Damien Sandras
+ * description : A live object menu definition
+ *
+ */
+
+#ifndef __LIVE_OBJECT_MENU_H__
+#define __LIVE_OBJECT_MENU_H__
+
+#include "action.h"
+#include "contact-action.h"
+
+namespace Ekiga {
+
+ /* ActorMenu
+ *
+ * We will have one ActorMenu per UI object displaying a Actor.
+ *
+ * Each Actor object exposes Action objects. Those actions are actions
+ * specific to the Actor. They can be triggered, for example, by the
+ * various ActorMenu associated with the different views of the
+ * Actor.
+ *
+ * However, even though we can have several ActorMenu for the same
+ * Actor (one per UI view), we need to register the associated actions
+ * only once.
+ */
+ class ActorMenu
+ {
+ public:
+
+ ActorMenu (const Actor & obj);
+
+ ~ActorMenu ();
+
+ virtual void activate (Ekiga::Action *action);
+ virtual const std::string as_xml ();
+
+ static const std::string get_xml_menu (const std::string & id,
+ const std::string & content,
+ bool full);
+
+ protected:
+ const Actor & obj;
+ };
+
+ class ContactActorMenu : public ActorMenu
+ {
+ public:
+
+ ContactActorMenu (const Actor & obj);
+
+ void set_data (ContactPtr _contact,
+ const std::string & _uri);
+
+ const std::string as_xml ();
+
+ protected:
+ ContactPtr contact;
+ std::string uri;
+ };
+}
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]