← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~boiko/libindicate-qt/libindicate-multiple_servers into lp:libindicate-qt

 

Gustavo Pichorim Boiko has proposed merging lp:~boiko/libindicate-qt/libindicate-multiple_servers into lp:libindicate-qt.

Requested reviews:
  Charles Kerr (charlesk)

For more details, see:
https://code.launchpad.net/~boiko/libindicate-qt/libindicate-multiple_servers/+merge/121916

Make it possible to run multiple instances of the indicator server. This including also being able to add and remove indicators from each server instance.

This commit breaks ABI as it changes the constructor of QIndicateServer and adds it as a friend class in QIndicateIndicator.
-- 
https://code.launchpad.net/~boiko/libindicate-qt/libindicate-multiple_servers/+merge/121916
Your team ayatana-commits is subscribed to branch lp:libindicate-qt.
=== modified file 'src/qindicateindicator.cpp'
--- src/qindicateindicator.cpp	2010-02-10 16:40:27 +0000
+++ src/qindicateindicator.cpp	2012-08-29 18:13:19 +0000
@@ -64,6 +64,12 @@
 {
 }
 
+IndicateIndicator* Indicator::gIndicator()
+{
+    return d->mGIndicator;
+}
+
+
 Indicator::~Indicator()
 {
     sQIndicatorFromGIndicator.remove(d->mGIndicator);

=== modified file 'src/qindicateindicator.h'
--- src/qindicateindicator.h	2010-02-10 16:34:32 +0000
+++ src/qindicateindicator.h	2012-08-29 18:13:19 +0000
@@ -31,6 +31,9 @@
 class Indicator : public QObject
 {
 Q_OBJECT
+
+    friend class Server;
+
 public:
     Indicator(QObject* parent=0);
     ~Indicator();
@@ -127,6 +130,7 @@
 
 private:
     IndicatorPrivate* const d;
+    struct _IndicateIndicator* gIndicator();
 };
 
 } // namespace

=== modified file 'src/qindicateserver.cpp'
--- src/qindicateserver.cpp	2009-09-17 12:12:33 +0000
+++ src/qindicateserver.cpp	2012-08-29 18:13:19 +0000
@@ -10,6 +10,7 @@
  */
 // Self
 #include "qindicateserver.h"
+#include "qindicateindicator.h"
 
 // Qt
 #include <QCoreApplication>
@@ -82,13 +83,19 @@
     QMetaObject::invokeMethod(qServer, "indicatorModified", Q_ARG(uint, id), Q_ARG(QString, property));
 }
 
-Server::Server(QObject* parent)
+Server::Server(QObject* parent, const QString &path)
 : QObject(parent)
 , d(new ServerPrivate)
 {
     g_type_init();
+
+    // Set the path property on object creation if given
     // indicate_server_new() does not exist!
-    d->mGServer = (IndicateServer*)g_object_new(INDICATE_TYPE_SERVER, NULL);
+    if (!path.isNull()) {
+        d->mGServer = (IndicateServer*)g_object_new(INDICATE_TYPE_SERVER, "path", path.toStdString().c_str(), NULL);
+    } else {
+        d->mGServer = (IndicateServer*)g_object_new(INDICATE_TYPE_SERVER, NULL);
+    }
 
     #define gconnect(gsignal, callback) \
         g_signal_connect(G_OBJECT(d->mGServer), gsignal, G_CALLBACK(callback), NULL)
@@ -161,6 +168,17 @@
     indicate_server_hide(d->mGServer);
 }
 
+void Server::addIndicator(Indicator *indicator)
+{
+    indicate_server_add_indicator(d->mGServer, indicator->gIndicator());
+}
+
+void Server::removeIndicator(Indicator *indicator)
+{
+    indicate_server_remove_indicator(d->mGServer, indicator->gIndicator());
+}
+
+
 };
 
 #include "qindicateserver.moc"

=== modified file 'src/qindicateserver.h'
--- src/qindicateserver.h	2009-09-14 09:27:22 +0000
+++ src/qindicateserver.h	2012-08-29 18:13:19 +0000
@@ -21,11 +21,13 @@
 {
 
 struct ServerPrivate;
+class Indicator;
+
 class Server : public QObject
 {
 Q_OBJECT
 public:
-    Server(QObject* parent=0);
+    Server(QObject* parent=0, const QString &path = QString::null);
     ~Server();
 
     void setType(const QString&);
@@ -42,6 +44,16 @@
      */
     void hide();
 
+    /**
+     * Add an indicator to this server instance
+     */
+    void addIndicator(Indicator *indicator);
+
+    /**
+     * Remove an indicator from this server instance
+     */
+    void removeIndicator(Indicator *indicator);
+
     static void setDefaultInstance(Server*);
     static Server* defaultInstance();
 


Follow ups