Re: Send a message using Gio::Dbus
- From: Yoann LE BARS <yoann le-bars net>
- To: "gtkmm-list gnome org" <gtkmm-list gnome org>
- Subject: Re: Send a message using Gio::Dbus
- Date: Fri, 08 Mar 2013 03:40:59 +0100
Hello everybody out there!
On 03/07/2013 8:41 p.m., Andrew Potter wrote:
Try Glib::RefPtr<Gio::DBus::Proxy> proxy
= Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SESSION,
"org.gnome.ScreenSaver",
"/org/gnome/ScreenSaver",
"org.gnome.ScreenSaver");
Thank you, it was of some help.
But…
I have taken a look to VLC code, especially on inhibiting code. It
appears that to not getting any trouble, I would rather connect to
["org.gnome.SessionManager", "org/gnome/SessionManager",
"org.gnome.SessionManager"], which leads to this:
Glib::RefPtr<Gio::DBus::Proxy> proxy
= Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SESSION,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager");
Then, I have found GNOME Session documentation
(<http://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html>).
The part concerning the "Inhibit" method
(<http://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html#org.gnome.SessionManager.Inhibit>)
indicates it takes more arguments than I thought, which are:
- application ID;
- Top-level XId;
- the reason for inhibition;
- flags, for what I ask it should be set such as: 4 | 8.
This leads to the following:
void Interface::Fenetre::inhibitScreenSaver() {
/* Application Id. */
Glib::Variant<Glib::ustring> app_name =
Glib::Variant<Glib::ustring>::create("Tutorial4");
/* Window XId. */
Glib::Variant<guint> toplevel_xid =
Glib::Variant<guint>::create(GDK_WINDOW_XID(get_window()->gobj()));
/* Reason for inhibition. */
Glib::Variant<Glib::ustring> reason =
Glib::Variant<Glib::ustring>::create("Full-screen animation");
/* Flags. */
Glib::Variant<guint> flag =
Glib::Variant<guint>::create(4 | 8);
/* Vector containing the message. */
std::vector<Glib::VariantBase> vec;
vec.push_back(app_name);
vec.push_back(toplevel_xid);
vec.push_back(reason);
vec.push_back(flag);
/* Bundling the message. */
Glib::VariantContainerBase bundle =
Glib::VariantContainerBase::create_tuple(vec);
result = proxy->call_sync("Inhibit", bundle);
}
Uninhibiting part of the manual
(<http://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html#org.gnome.SessionManager.Uninhibit>)
does not show anything special, which leads to this code:
void Interface::Fenetre::uninhibitScreenSaver() {
proxy->call_sync("Uninhibit", result);
}
I have tried and test it, it works as expected: I have waited for some
time in full-screen mode, the screen never turned black. When switching
back to windowed mode, after a while, the screen turned black. No error
message appeared. This is good!
I guess I am starting to get it and to understand D-Bus messages.
But…
I want my application to be usable on any D-Bus using system.
Looking into VLC, on environments using specifications from
Freedesktop.org (such as KDE or Gnome <= 2.26), I should connect to
["org.freedesktop.PowerManagement", "org/freedesktop/PowerManagement",
"org.freedesktop.PowerManagement"], and use method "Inhibit" with the
following arguments:
- application ID ;
- reason for suspending.
To un-inhibit, the method is call "UnInhibit" and as argument simply
take the cookie obtained when inhibiting.
So, what I need is to determined which bus is available. Unfortunately,
I did not find out how it is done in VLC. Does someone know how to get
available buses?
Regards.
Yoann
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]