~ubuntu-branches/ubuntu/precise/unity-2d/precise-updates

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/placeentry.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-08-11 21:22:18 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20110811212218-vjwi8txoyl6g7upb
Tags: 4.0.0-0ubuntu1
* New upstream release:
  - [launcher] Impossible to keep KDE Apps in Launcher (LP: #741129)
  - [dash] Background should be blurred (LP: #823326)
  - No 'safely remove' option is present in the unity menu when a usb disk
    is inserted (LP: #660010)
  - Quicklist item "Keep In Launcher" should be "Keep in launcher" as design
    (LP: #795422)
  - [launcher] ESC doesn't dismiss launcher when activated with Alt+F1
    (LP: #812792)
  - [dash] Background wallpaper shifted when using a non compositing window
    manager (LP: #823295)
  - [launcher] Bottom gradient appears too early (LP: #823877)
  - mute/unmute sound when user clicks on sound applet using scroll button
    or middle mouse button (LP: #609860)
  - Secondary activate (i.e. middle click) support for indicators advanced
    usage (LP: #812933)
  - Unused GConfItemQmlWrapper dep found (LP: #821880)
* debian/control:
  - bump libunity-core-4.0-dev, libnux-1.0-dev
  - recommends lenses and not places anymore. Adding music lens

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "launchermenu.h"
23
23
 
24
24
// libunity-2d
 
25
#include <dashclient.h>
25
26
#include <debug_p.h>
26
27
 
27
28
#include <QDBusMetaType>
28
29
#include <QAction>
29
30
#include <QDebug>
30
 
#include <QDBusServiceWatcher>
31
 
#include <QDBusConnectionInterface>
32
 
#include <QDBusReply>
33
31
 
34
32
// Marshall the RendererInfoStruct data into a D-Bus argument
35
33
QDBusArgument &operator<<(QDBusArgument &argument, const RendererInfoStruct &r)
146
144
static const char* UNITY_PLACE_ENTRY_INTERFACE = "com.canonical.Unity.PlaceEntry";
147
145
static const char* SECTION_PROPERTY = "section";
148
146
 
149
 
static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
150
 
static const char* DASH_DBUS_PATH = "/Dash";
151
 
static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
152
 
 
153
147
PlaceEntry::PlaceEntry(QObject* parent) :
154
148
    LauncherItem(parent),
155
149
    m_position(0),
163
157
    m_entryResultsModel(NULL),
164
158
    m_globalGroupsModel(NULL),
165
159
    m_globalResultsModel(NULL),
166
 
    m_dbusIface(NULL),
167
 
    m_dashDbusIface(NULL),
168
 
    m_dashActive(false)
 
160
    m_dbusIface(NULL)
169
161
{
170
162
    qDBusRegisterMetaType<RendererInfoStruct>();
171
163
    qDBusRegisterMetaType<PlaceEntryInfoStruct>();
172
164
    qDBusRegisterMetaType<QList<PlaceEntryInfoStruct> >();
173
165
    qDBusRegisterMetaType<QHash<QString, QString>>();
174
166
 
175
 
    /* Check if the dash is already up and running by asking the bus instead of
176
 
       trying to create an instance of the interface. Creating an instance would
177
 
       cause D-Bus to activate the dash and we don’t want this to happen, the
178
 
       dash should be started on demand only. */
179
 
    QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
180
 
    QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(DASH_DBUS_SERVICE);
181
 
    if (reply.isValid() && reply.value()) {
182
 
        connectToDash();
183
 
    } else {
184
 
        /* The dash is not running: monitor its registration on the bus so we
185
 
           can connect to it when it comes up. */
186
 
        QDBusServiceWatcher* watcher = new QDBusServiceWatcher(DASH_DBUS_SERVICE,
187
 
                                                               QDBusConnection::sessionBus(),
188
 
                                                               QDBusServiceWatcher::WatchForRegistration,
189
 
                                                               this);
190
 
        connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));
191
 
    }
 
167
    connect(DashClient::instance(), SIGNAL(activePageChanged(const QString&)),
 
168
        SLOT(slotActivePageChanged(const QString&)));
192
169
}
193
170
 
194
171
PlaceEntry::PlaceEntry(const PlaceEntry& other) :
752
729
    Q_EMIT globalRendererHintsChanged();
753
730
}
754
731
 
755
 
void
756
 
PlaceEntry::connectToDash()
757
 
{
758
 
    if (m_dashDbusIface != NULL) {
759
 
        return;
760
 
    }
761
 
 
762
 
    m_dashDbusIface = new QDBusInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE,
763
 
                                         QDBusConnection::sessionBus(), this);
764
 
    connect(m_dashDbusIface, SIGNAL(activeChanged(bool)),
765
 
            SLOT(slotDashActiveChanged(bool)));
766
 
    connect(m_dashDbusIface, SIGNAL(activePlaceEntryChanged(const QString&)),
767
 
            SLOT(slotDashActivePlaceEntryChanged(const QString&)));
768
 
 
769
 
    QVariant value = m_dashDbusIface->property("active");
770
 
    if (value.isValid()) {
771
 
        m_dashActive = value.toBool();
772
 
    } else {
773
 
        UQ_WARNING << "Fetching Dash.active property failed";
774
 
    }
775
 
    value = m_dashDbusIface->property("activePlaceEntry");
776
 
    if (value.isValid()) {
777
 
        m_dashActivePlaceEntry = value.toString();
778
 
    } else {
779
 
        UQ_WARNING << "Fetching Dash.activePlaceEntry property failed";
780
 
    }
781
 
 
782
 
    updateActiveState();
783
 
}
784
 
 
785
 
void
786
 
PlaceEntry::slotDashActiveChanged(bool value)
787
 
{
788
 
    if (m_dashActive != value) {
789
 
        m_dashActive = value;
790
 
        updateActiveState();
791
 
    }
792
 
}
793
 
 
794
 
void
795
 
PlaceEntry::slotDashActivePlaceEntryChanged(const QString& entry)
796
 
{
797
 
    if (m_dashActivePlaceEntry != entry) {
798
 
        m_dashActivePlaceEntry = entry;
799
 
        updateActiveState();
800
 
    }
801
 
}
802
 
 
803
 
void
804
 
PlaceEntry::updateActiveState()
 
732
 
 
733
void
 
734
PlaceEntry::slotActivePageChanged(const QString& page)
805
735
{
806
736
    bool active = false;
807
 
    if (m_dashActive && !m_dbusObjectPath.isEmpty() && (m_dashActivePlaceEntry == m_dbusObjectPath)) {
 
737
    if (!m_dbusObjectPath.isEmpty() && page == m_dbusObjectPath) {
808
738
        active = true;
809
739
    }
810
740
 
827
757
        startRemotePlaceOnDemand();
828
758
    }
829
759
 
830
 
    QDBusInterface iface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE);
831
 
    iface.asyncCall(QLatin1String("activatePlaceEntry"), m_fileName, m_groupName, section);
 
760
    if (m_active) {
 
761
        DashClient::instance()->setActivePage(QString());
 
762
    } else {
 
763
        /* FIXME: DashClient::setActivePage has changed but PlaceEntry is deprecated anyway */
 
764
        //DashClient::instance()->setActivePage(m_dbusObjectPath, m_fileName, m_groupName, section);
 
765
    }
832
766
}
833
767
 
834
768
void