aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/exporter.h (renamed from include/datetime/service.h)16
-rw-r--r--src/exporter.cpp (renamed from src/service.cpp)24
-rw-r--r--src/main.cpp6
-rw-r--r--src/planner-eds.cpp2
4 files changed, 27 insertions, 21 deletions
diff --git a/include/datetime/service.h b/include/datetime/exporter.h
index c7171b7..a32b941 100644
--- a/include/datetime/service.h
+++ b/include/datetime/exporter.h
@@ -20,6 +20,7 @@
#ifndef INDICATOR_DATETIME_EXPORTER_H
#define INDICATOR_DATETIME_EXPORTER_H
+#include <datetime/actions.h>
#include <datetime/menu.h>
#include <core/signal.h>
@@ -36,15 +37,16 @@ namespace datetime {
/**
* \brief Exports actions and menus to DBus.
*/
-class Service
+class Exporter
{
public:
- Service() =default;
- ~Service();
+ Exporter() =default;
+ ~Exporter();
core::Signal<> name_lost;
- void publish (GActionGroup* actions, std::vector<std::shared_ptr<Menu>>& menus);
+ void publish(std::shared_ptr<Actions>& actions,
+ std::vector<std::shared_ptr<Menu>>& menus);
private:
static void on_bus_acquired(GDBusConnection*, const gchar *name, gpointer gthis);
@@ -57,12 +59,12 @@ private:
guint m_own_id = 0;
guint m_exported_actions_id = 0;
GDBusConnection * m_dbus_connection = nullptr;
- GActionGroup* m_actions = nullptr;
+ std::shared_ptr<Actions> m_actions;
std::vector<std::shared_ptr<Menu>> m_menus;
// we've got raw pointers and gsignal tags in here, so disable copying
- Service(const Service&) =delete;
- Service& operator=(const Service&) =delete;
+ Exporter(const Exporter&) =delete;
+ Exporter& operator=(const Exporter&) =delete;
};
} // namespace datetime
diff --git a/src/service.cpp b/src/exporter.cpp
index 0671c61..aa021f3 100644
--- a/src/service.cpp
+++ b/src/exporter.cpp
@@ -17,8 +17,8 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#include <datetime/service.h>
#include <datetime/dbus-shared.h>
+#include <datetime/exporter.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -31,7 +31,7 @@ namespace datetime {
****
***/
-Service::~Service()
+Exporter::~Exporter()
{
if (m_dbus_connection != nullptr)
{
@@ -53,20 +53,23 @@ Service::~Service()
***/
void
-Service::on_bus_acquired(GDBusConnection* connection, const gchar* name, gpointer gthis)
+Exporter::on_bus_acquired(GDBusConnection* connection, const gchar* name, gpointer gthis)
{
g_debug("bus acquired: %s", name);
- static_cast<Service*>(gthis)->on_bus_acquired(connection, name);
+ static_cast<Exporter*>(gthis)->on_bus_acquired(connection, name);
}
void
-Service::on_bus_acquired(GDBusConnection* connection, const gchar* /*name*/)
+Exporter::on_bus_acquired(GDBusConnection* connection, const gchar* /*name*/)
{
m_dbus_connection = static_cast<GDBusConnection*>(g_object_ref(G_OBJECT(connection)));
// export the actions
GError * error = nullptr;
- const auto id = g_dbus_connection_export_action_group(m_dbus_connection, BUS_PATH, m_actions, &error);
+ const auto id = g_dbus_connection_export_action_group(m_dbus_connection,
+ BUS_PATH,
+ m_actions->action_group(),
+ &error);
if (id)
{
m_exported_actions_id = id;
@@ -99,14 +102,14 @@ Service::on_bus_acquired(GDBusConnection* connection, const gchar* /*name*/)
***/
void
-Service::on_name_lost(GDBusConnection* connection, const gchar* name, gpointer gthis)
+Exporter::on_name_lost(GDBusConnection* connection, const gchar* name, gpointer gthis)
{
g_debug("name lost: %s", name);
- static_cast<Service*>(gthis)->on_name_lost(connection, name);
+ static_cast<Exporter*>(gthis)->on_name_lost(connection, name);
}
void
-Service::on_name_lost(GDBusConnection* /*connection*/, const gchar* /*name*/)
+Exporter::on_name_lost(GDBusConnection* /*connection*/, const gchar* /*name*/)
{
name_lost();
}
@@ -116,7 +119,8 @@ Service::on_name_lost(GDBusConnection* /*connection*/, const gchar* /*name*/)
***/
void
-Service::publish(GActionGroup* actions, std::vector<std::shared_ptr<Menu>>& menus)
+Exporter::publish(std::shared_ptr<Actions>& actions,
+ std::vector<std::shared_ptr<Menu>>& menus)
{
m_actions = actions;
m_menus = menus;
diff --git a/src/main.cpp b/src/main.cpp
index 6a56163..50d5241 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -38,7 +38,7 @@ main(int /*argc*/, char** /*argv*/)
// It can be removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is fixed.
g_type_ensure(G_TYPE_DBUS_CONNECTION);
- // init i18n
+ // boilerplate i18n
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
textdomain(GETTEXT_PACKAGE);
@@ -47,7 +47,7 @@ main(int /*argc*/, char** /*argv*/)
if(!notify_init("indicator-datetime-service"))
g_critical("libnotify initialization failed");
- // build the state and menu factory
+ // build the state and actions for the MenuFactory to use
std::shared_ptr<State> state(new LiveState);
std::shared_ptr<Actions> actions(new LiveActions(state));
MenuFactory factory(actions, state);
@@ -56,7 +56,7 @@ main(int /*argc*/, char** /*argv*/)
std::vector<std::shared_ptr<Menu>> menus;
menus.push_back(factory.buildMenu(Menu::Desktop));
- // export them
+ // export them & run until we lose the busname
auto loop = g_main_loop_new(nullptr, false);
Exporter exporter;
exporter.name_lost.connect([loop](){
diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp
index 275a29e..b3f751a 100644
--- a/src/planner-eds.cpp
+++ b/src/planner-eds.cpp
@@ -48,7 +48,7 @@ public:
e_source_registry_new(m_cancellable, on_source_registry_ready, this);
m_owner.time.changed().connect([this](const DateTime& dt) {
- g_message("planner's datetime property changed to %s; calling rebuildSoon()", g_date_time_format(dt.get(), "%F %T"));
+ g_message("planner's datetime property changed to %s; calling rebuildSoon()", dt.format("%F %T").c_str());
rebuildSoon();
});