File paprefs-packagekit.patch of Package paprefs
diff --git a/src/paprefs.cc b/src/paprefs.cc
index 0e4cf83..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();
@@ -104,9 +106,11 @@ public:
void onGConfChange(const Glib::ustring& key, const Gnome::Conf::Value& value);
+ void showInstallButton(Gtk::Button *button, bool available);
void installFiles(const char *a, const char *b);
bool
+ packageKitAvailable,
rtpRecvAvailable,
rtpSendAvailable,
zeroconfPublishAvailable,
@@ -144,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();
@@ -217,40 +222,13 @@ void MainWindow::updateSensitive() {
upnpMediaServerCheckButton->set_sensitive(upnpAvailable);
upnpNullSinkCheckButton->set_sensitive(upnpAvailable && upnpMediaServerCheckButton->get_active());
- if (zeroconfDiscoverAvailable)
- zeroconfDiscoverInstallButton->hide();
- else
- zeroconfDiscoverInstallButton->show();
-
- if (zeroconfRaopDiscoverAvailable)
- zeroconfRaopDiscoverInstallButton->hide();
- else
- zeroconfRaopDiscoverInstallButton->show();
-
- if (remoteAvailable)
- remoteInstallButton->hide();
- else
- remoteInstallButton->show();
-
- if (zeroconfPublishAvailable)
- zeroconfPublishInstallButton->hide();
- else
- zeroconfPublishInstallButton->show();
-
- if (upnpAvailable)
- upnpInstallButton->hide();
- else
- upnpInstallButton->show();
-
- if (rtpRecvAvailable)
- rtpRecvInstallButton->hide();
- else
- rtpRecvInstallButton->show();
-
- if (rtpSendAvailable)
- rtpSendInstallButton->hide();
- else
- rtpSendInstallButton->show();
+ showInstallButton(zeroconfDiscoverInstallButton, zeroconfDiscoverAvailable);
+ showInstallButton(zeroconfRaopDiscoverInstallButton, zeroconfRaopDiscoverAvailable);
+ showInstallButton(remoteInstallButton, remoteAvailable);
+ showInstallButton(zeroconfPublishInstallButton, zeroconfPublishAvailable);
+ showInstallButton(upnpInstallButton, upnpAvailable);
+ showInstallButton(rtpRecvInstallButton, rtpRecvAvailable);
+ showInstallButton(rtpSendInstallButton, rtpSendAvailable);
}
void MainWindow::onChangeRemoteAccess() {
@@ -313,6 +291,13 @@ void MainWindow::onChangeUpnp() {
writeToGConfUPnP();
}
+void MainWindow::showInstallButton(Gtk::Button *button, bool available) {
+ if (available || !packageKitAvailable)
+ button->hide();
+ else
+ button->show();
+}
+
void MainWindow::installFiles(const char *a, const char *b = NULL) {
DBusGConnection *connection;
DBusGProxy *proxy;
@@ -648,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 */