summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <raof@ubuntu.com>2009-11-29 17:42:21 +1100
committerColin Guthrie <cguthrie@mandriva.org>2009-11-29 12:06:57 +0000
commitf7e2488b33bf9177047e0239f73cc92dc6549903 (patch)
tree66415e926806d086150f19ce5e8c4b0bb800285f
parent7d59faee21b2cad60245efc9461991e8c73e2e22 (diff)
Enable the PackageKit install buttons only when PackageKit is available
-rw-r--r--src/paprefs.cc23
1 files changed, 22 insertions, 1 deletions
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 <gconfmm.h>
#include <libintl.h>
#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
#include <gdk/gdkx.h>
#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::RefPtr<Gnome::Glade:
x->get_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 */