diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-08-25 02:12:16 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-08-25 02:12:16 +0200 |
commit | 767536eb10f6a8a863221866f3496ee1c8293789 (patch) | |
tree | 410aac8ec9131bc61cc03ee0aacdce7db84b0c5b /src | |
parent | 9130bb7fe0c223d57f432bcabd3ce55fcc3f10d4 (diff) |
implement basic packagekit support
Diffstat (limited to 'src')
-rw-r--r-- | src/paprefs.cc | 139 | ||||
-rw-r--r-- | src/paprefs.glade | 267 |
2 files changed, 355 insertions, 51 deletions
diff --git a/src/paprefs.cc b/src/paprefs.cc index de100f1..0e4cf83 100644 --- a/src/paprefs.cc +++ b/src/paprefs.cc @@ -27,6 +27,8 @@ #include <libglademm.h> #include <gconfmm.h> #include <libintl.h> +#include <dbus/dbus-glib.h> +#include <gdk/gdkx.h> #define PA_GCONF_ROOT "/system/pulseaudio" #define PA_GCONF_PATH_MODULES PA_GCONF_ROOT"/modules" @@ -36,7 +38,15 @@ public: MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x); static MainWindow* create(); - Gtk::Button *closeButton; + Gtk::Button + *closeButton, + *zeroconfDiscoverInstallButton, + *zeroconfRaopDiscoverInstallButton, + *remoteInstallButton, + *zeroconfPublishInstallButton, + *upnpInstallButton, + *rtpRecvInstallButton, + *rtpSendInstallButton; Gtk::CheckButton *remoteAccessCheckButton, @@ -72,6 +82,14 @@ public: void onChangeCombine(); void onChangeUpnp(); + void onZeroconfDiscoverInstallButtonClicked(); + void onZeroconfRaopDiscoverInstallButtonClicked(); + void onRemoteInstallButtonClicked(); + void onZeroconfPublishInstallButtonClicked(); + void upnpInstallButtonClicked(); + void rtpRecvInstallButtonClicked(); + void rtpSendInstallButtonClicked(); + void readFromGConf(); void checkForModules(); @@ -86,6 +104,8 @@ public: void onGConfChange(const Glib::ustring& key, const Gnome::Conf::Value& value); + void installFiles(const char *a, const char *b); + bool rtpRecvAvailable, rtpSendAvailable, @@ -100,6 +120,13 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade: Gtk::Window(cobject), ignoreChanges(true) { x->get_widget("closeButton", closeButton); + x->get_widget("zeroconfDiscoverInstallButton", zeroconfDiscoverInstallButton); + x->get_widget("zeroconfRaopDiscoverInstallButton", zeroconfRaopDiscoverInstallButton); + x->get_widget("remoteInstallButton", remoteInstallButton); + x->get_widget("zeroconfPublishInstallButton", zeroconfPublishInstallButton); + x->get_widget("upnpInstallButton", upnpInstallButton); + x->get_widget("rtpRecvInstallButton", rtpRecvInstallButton); + x->get_widget("rtpSendInstallButton", rtpSendInstallButton); x->get_widget("remoteAccessCheckButton", remoteAccessCheckButton); x->get_widget("zeroconfDiscoverCheckButton", zeroconfDiscoverCheckButton); @@ -147,6 +174,14 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade: upnpMediaServerCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onChangeUpnp)); upnpNullSinkCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onChangeUpnp)); + + zeroconfDiscoverInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onZeroconfDiscoverInstallButtonClicked)); + zeroconfRaopDiscoverInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onZeroconfRaopDiscoverInstallButtonClicked)); + remoteInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onRemoteInstallButtonClicked)); + zeroconfPublishInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onZeroconfPublishInstallButtonClicked)); + upnpInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::upnpInstallButtonClicked)); + rtpRecvInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::rtpRecvInstallButtonClicked)); + rtpSendInstallButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::rtpSendInstallButtonClicked)); } MainWindow* MainWindow::create() { @@ -181,6 +216,41 @@ 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(); } void MainWindow::onChangeRemoteAccess() { @@ -243,6 +313,68 @@ void MainWindow::onChangeUpnp() { writeToGConfUPnP(); } +void MainWindow::installFiles(const char *a, const char *b = NULL) { + DBusGConnection *connection; + DBusGProxy *proxy; + gboolean ret; + GError *error = NULL; + const gchar *packages[] = {a, b, NULL}; + + connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + + proxy = dbus_g_proxy_new_for_name(connection, + "org.freedesktop.PackageKit", + "/org/freedesktop/PackageKit", + "org.freedesktop.PackageKit.Modify"); + + ret = dbus_g_proxy_call( + proxy, "InstallProvideFiles", &error, + G_TYPE_UINT, GDK_WINDOW_XID(get_window()->gobj()), + G_TYPE_STRV, packages, + G_TYPE_STRING, "show-confirm-search,hide-finished", + G_TYPE_INVALID, G_TYPE_INVALID); + + if (!ret) { + g_warning("Installation failed: %s", error->message); + g_error_free(error); + } + + g_object_unref(proxy); + dbus_g_connection_unref(connection); + + checkForModules(); + updateSensitive(); +} + +void MainWindow::onZeroconfDiscoverInstallButtonClicked() { + installFiles(MODULESDIR "module-zeroconf-discover" SHREXT); +} + +void MainWindow::onZeroconfRaopDiscoverInstallButtonClicked() { + installFiles(MODULESDIR "module-raop-discover" SHREXT); +} + +void MainWindow::onRemoteInstallButtonClicked() { + installFiles(MODULESDIR "module-esound-protocol-tcp" SHREXT, + MODULESDIR "module-native-protocol-tcp" SHREXT); +} + +void MainWindow::onZeroconfPublishInstallButtonClicked() { + installFiles(MODULESDIR "module-zeroconf-publish" SHREXT); +} + +void MainWindow::upnpInstallButtonClicked() { + installFiles("/usr/bin/rygel", MODULESDIR "module-rygel-media-server" SHREXT); +} + +void MainWindow::rtpRecvInstallButtonClicked() { + installFiles(MODULESDIR "module-rtp-recv" SHREXT); +} + +void MainWindow::rtpSendInstallButtonClicked() { + installFiles(MODULESDIR "module-rtp-send" SHREXT); +} + void MainWindow::writeToGConfCombine() { Gnome::Conf::ChangeSet changeSet; changeSet.set(PA_GCONF_PATH_MODULES"/combine/locked", true); @@ -512,9 +644,8 @@ void MainWindow::checkForModules() { rtpSendAvailable = access(MODULESDIR "module-rtp-send" SHREXT, F_OK) == 0; upnpAvailable = - access(MODULESDIR "module-rygel-media-server" SHREXT, F_OK) == 0// && - // g_find_program_in_path("rygel") - ; + access(MODULESDIR "module-rygel-media-server" SHREXT, F_OK) == 0 && + g_find_program_in_path("rygel"); } int main(int argc, char *argv[]) { diff --git a/src/paprefs.glade b/src/paprefs.glade index d570a4c..b2567de 100644 --- a/src/paprefs.glade +++ b/src/paprefs.glade @@ -24,14 +24,39 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <widget class="GtkCheckButton" id="zeroconfDiscoverCheckButton"> - <property name="label" translatable="yes">Make discoverable _PulseAudio network sound devices available locally</property> + <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="zeroconfDiscoverCheckButton"> + <property name="label" translatable="yes">Make discoverable _PulseAudio network sound devices available locally</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="zeroconfDiscoverInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> @@ -40,14 +65,39 @@ </packing> </child> <child> - <widget class="GtkCheckButton" id="zeroconfRaopDiscoverCheckButton"> - <property name="label" translatable="yes">Make discoverable Apple A_irTunes sound devices available locally</property> + <widget class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="zeroconfRaopDiscoverCheckButton"> + <property name="label" translatable="yes">Make discoverable Apple A_irTunes sound devices available locally</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="zeroconfRaopDiscoverInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> @@ -91,13 +141,38 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <widget class="GtkCheckButton" id="remoteAccessCheckButton"> - <property name="label" translatable="yes">Enable _network access to local sound devices</property> + <widget class="GtkHBox" id="hbox3"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="remoteAccessCheckButton"> + <property name="label" translatable="yes">Enable _network access to local sound devices</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="remoteInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> @@ -115,17 +190,40 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <widget class="GtkCheckButton" id="zeroconfBrowseCheckButton"> - <property name="label" translatable="yes">Allow other machines on the LAN to _discover local sound devices</property> + <widget class="GtkHBox" id="hbox4"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="zeroconfBrowseCheckButton"> + <property name="label" translatable="yes">Allow other machines on the LAN to _discover local sound devices</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="zeroconfPublishInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> - <property name="expand">False</property> - <property name="fill">False</property> <property name="position">0</property> </packing> </child> @@ -154,14 +252,39 @@ </packing> </child> <child> - <widget class="GtkCheckButton" id="upnpMediaServerCheckButton"> - <property name="label" translatable="yes">Make local sound devices available as DLNA/_UPnP Media Server</property> + <widget class="GtkHBox" id="hbox5"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="upnpMediaServerCheckButton"> + <property name="label" translatable="yes">Make local sound devices available as DLNA/_UPnP Media Server</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="upnpInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> @@ -227,13 +350,38 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <widget class="GtkCheckButton" id="rtpReceiveCheckButton"> - <property name="label" translatable="yes">Enable Multicast/RTP re_ceiver</property> + <widget class="GtkHBox" id="hbox6"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="rtpReceiveCheckButton"> + <property name="label" translatable="yes">Enable Multicast/RTP re_ceiver</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="rtpRecvInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> @@ -242,13 +390,38 @@ </packing> </child> <child> - <widget class="GtkCheckButton" id="rtpSendCheckButton"> - <property name="label" translatable="yes">Enable Multicast/RTP s_ender</property> + <widget class="GtkHBox" id="hbox7"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <child> + <widget class="GtkCheckButton" id="rtpSendCheckButton"> + <property name="label" translatable="yes">Enable Multicast/RTP s_ender</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="rtpSendInstallButton"> + <property name="label" translatable="yes">Install...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> |