From f7e2488b33bf9177047e0239f73cc92dc6549903 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Sun, 29 Nov 2009 17:42:21 +1100 Subject: Enable the PackageKit install buttons only when PackageKit is available --- src/paprefs.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/paprefs.cc b/src/paprefs.cc index f711e17..a45092c 100644 --- a/src/paprefs.cc +++ b/src/paprefs.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #define PA_GCONF_ROOT "/system/pulseaudio" @@ -92,6 +93,7 @@ public: void readFromGConf(); + void checkForPackageKit(); void checkForModules(); void writeToGConfRemoteAccess(); @@ -108,6 +110,7 @@ public: void installFiles(const char *a, const char *b); bool + packageKitAvailable, rtpRecvAvailable, rtpSendAvailable, zeroconfPublishAvailable, @@ -145,6 +148,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("rtpSpeakerRadioButton", rtpSpeakerRadioButton); x->get_widget("rtpNullSinkRadioButton", rtpNullSinkRadioButton); + checkForPackageKit(); checkForModules(); gconf = Gnome::Conf::Client::get_default_client(); @@ -288,7 +292,7 @@ void MainWindow::onChangeUpnp() { } void MainWindow::showInstallButton(Gtk::Button *button, bool available) { - if (available) + if (available || !packageKitAvailable) button->hide(); else button->show(); @@ -629,6 +633,23 @@ void MainWindow::checkForModules() { g_find_program_in_path("rygel"); } +void MainWindow::checkForPackageKit() { + + DBusError err; + dbus_error_init(&err); + DBusConnection *sessionBus = dbus_bus_get(DBUS_BUS_SESSION, &err); + + if(dbus_error_is_set(&err)) { + g_warning("Error connecting to DBus: %s", err.message); + packageKitAvailable = FALSE; + } else { + packageKitAvailable = dbus_bus_name_has_owner(sessionBus, "org.freedesktop.PackageKit", NULL); + dbus_connection_unref(sessionBus); + } + dbus_error_free(&err); +} + + int main(int argc, char *argv[]) { /* Initialize the i18n stuff */ -- cgit