Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-media-player-keys.c File Reference
#include "config.h"
#include "ev-media-player-keys.h"
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
+ Include dependency graph for ev-media-player-keys.c:

Go to the source code of this file.

Data Structures

struct  _EvMediaPlayerKeys
 
struct  _EvMediaPlayerKeysClass
 

Macros

#define SD_NAME   "org.gnome.SettingsDaemon"
 
#define SD_OBJECT_PATH   "/org/gnome/SettingsDaemon/MediaKeys"
 
#define SD_INTERFACE   "org.gnome.SettingsDaemon.MediaKeys"
 

Enumerations

enum  { KEY_PRESSED, LAST_SIGNAL }
 

Functions

static void ev_media_player_keys_finalize (GObject *object)
 
static void ev_media_player_keys_class_init (EvMediaPlayerKeysClass *klass)
 
static void ev_media_player_keys_update_has_name_owner (EvMediaPlayerKeys *keys)
 
static void ev_media_player_keys_grab_keys (EvMediaPlayerKeys *keys)
 
static void ev_media_player_keys_release_keys (EvMediaPlayerKeys *keys)
 
static void media_player_key_pressed_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name, GVariant *parameters, gpointer user_data)
 
static void mediakeys_name_owner_changed (GObject *object, GParamSpec *pspec, gpointer user_data)
 
static void mediakeys_service_appeared_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 
static void ev_media_player_keys_init (EvMediaPlayerKeys *keys)
 
void ev_media_player_keys_focused (EvMediaPlayerKeys *keys)
 
EvMediaPlayerKeysev_media_player_keys_new (void)
 

Variables

static guint signals [LAST_SIGNAL]
 

Macro Definition Documentation

#define SD_INTERFACE   "org.gnome.SettingsDaemon.MediaKeys"

Definition at line 33 of file ev-media-player-keys.c.

#define SD_NAME   "org.gnome.SettingsDaemon"

Definition at line 31 of file ev-media-player-keys.c.

#define SD_OBJECT_PATH   "/org/gnome/SettingsDaemon/MediaKeys"

Definition at line 32 of file ev-media-player-keys.c.

Enumeration Type Documentation

anonymous enum
Enumerator
KEY_PRESSED 
LAST_SIGNAL 

Definition at line 35 of file ev-media-player-keys.c.

35  {
38 };

Function Documentation

static void ev_media_player_keys_class_init ( EvMediaPlayerKeysClass klass)
static

Definition at line 64 of file ev-media-player-keys.c.

65 {
66  GObjectClass *object_class = G_OBJECT_CLASS (klass);
67 
68  object_class->finalize = ev_media_player_keys_finalize;
69 
71  g_signal_new ("key_pressed",
73  G_SIGNAL_RUN_LAST,
74  G_STRUCT_OFFSET (EvMediaPlayerKeysClass, key_pressed),
75  NULL, NULL,
76  g_cclosure_marshal_VOID__STRING,
77  G_TYPE_NONE,
78  1, G_TYPE_STRING);
79 }
static void ev_media_player_keys_finalize ( GObject *  object)
static

Definition at line 214 of file ev-media-player-keys.c.

215 {
216  EvMediaPlayerKeys *keys = EV_MEDIA_PLAYER_KEYS (object);
217 
218  if (keys->proxy != NULL) {
220  g_object_unref (keys->proxy);
221  keys->proxy = NULL;
222  keys->has_name_owner = FALSE;
223  }
224 
225  G_OBJECT_CLASS (ev_media_player_keys_parent_class)->finalize (object);
226 }

+ Here is the caller graph for this function:

void ev_media_player_keys_focused ( EvMediaPlayerKeys keys)

Definition at line 205 of file ev-media-player-keys.c.

206 {
207  if (keys->proxy == NULL)
208  return;
209 
211 }

+ Here is the caller graph for this function:

static void ev_media_player_keys_grab_keys ( EvMediaPlayerKeys keys)
static

Definition at line 97 of file ev-media-player-keys.c.

98 {
99  if (!keys->has_name_owner)
100  return;
101 
102  /*
103  * The uint as second argument is time. We give a very low value so that
104  * if a media player is there it gets higher priority on the keys (0 is
105  * a special value having maximum priority).
106  */
107  g_dbus_proxy_call (keys->proxy,
108  "GrabMediaPlayerKeys",
109  g_variant_new ("(su)", "Evince", 1),
110  G_DBUS_CALL_FLAGS_NO_AUTO_START,
111  -1,
112  NULL, NULL, NULL);
113 }

+ Here is the caller graph for this function:

static void ev_media_player_keys_init ( EvMediaPlayerKeys keys)
static

Definition at line 191 of file ev-media-player-keys.c.

192 {
193  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
194  G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
195  NULL,
196  SD_NAME,
198  SD_INTERFACE,
199  NULL,
201  keys);
202 }
EvMediaPlayerKeys* ev_media_player_keys_new ( void  )

Definition at line 229 of file ev-media-player-keys.c.

230 {
231  return g_object_new (EV_TYPE_MEDIA_PLAYER_KEYS, NULL);
232 }
static void ev_media_player_keys_release_keys ( EvMediaPlayerKeys keys)
static

Definition at line 116 of file ev-media-player-keys.c.

117 {
118  if (!keys->has_name_owner)
119  return;
120 
121  g_dbus_proxy_call (keys->proxy,
122  "ReleaseMediaPlayerKeys",
123  g_variant_new ("(s)", "Evince"),
124  G_DBUS_CALL_FLAGS_NO_AUTO_START,
125  -1,
126  NULL, NULL, NULL);
127 }

+ Here is the caller graph for this function:

static void ev_media_player_keys_update_has_name_owner ( EvMediaPlayerKeys keys)
static

Definition at line 82 of file ev-media-player-keys.c.

83 {
84  gchar *name_owner;
85 
86  if (!keys->proxy) {
87  keys->has_name_owner = FALSE;
88  return;
89  }
90 
91  name_owner = g_dbus_proxy_get_name_owner (keys->proxy);
92  keys->has_name_owner = (name_owner != NULL);
93  g_free (name_owner);
94 }

+ Here is the caller graph for this function:

static void media_player_key_pressed_cb ( GDBusProxy *  proxy,
gchar *  sender_name,
gchar *  signal_name,
GVariant *  parameters,
gpointer  user_data 
)
static

Definition at line 130 of file ev-media-player-keys.c.

135 {
136  const char *application, *key;
137 
138  if (g_strcmp0 (sender_name, SD_NAME) != 0)
139  return;
140 
141  if (g_strcmp0 (signal_name, "MediaPlayerKeyPressed") != 0)
142  return;
143 
144  if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(ss)")))
145  return;
146 
147  g_variant_get (parameters, "(&s&s)", &application, &key);
148 
149  if (strcmp ("Evince", application) == 0) {
150  g_signal_emit (user_data, signals[KEY_PRESSED], 0, key);
151  }
152 }

+ Here is the caller graph for this function:

static void mediakeys_name_owner_changed ( GObject *  object,
GParamSpec *  pspec,
gpointer  user_data 
)
static

Definition at line 155 of file ev-media-player-keys.c.

158 {
159  EvMediaPlayerKeys *keys = EV_MEDIA_PLAYER_KEYS (user_data);
160 
162 }

+ Here is the caller graph for this function:

static void mediakeys_service_appeared_cb ( GObject *  source_object,
GAsyncResult *  res,
gpointer  user_data 
)
static

Definition at line 165 of file ev-media-player-keys.c.

168 {
169  EvMediaPlayerKeys *keys = EV_MEDIA_PLAYER_KEYS (user_data);
170  GDBusProxy *proxy;
171 
172  proxy = g_dbus_proxy_new_for_bus_finish (res, NULL);
173 
174  if (proxy == NULL) {
175  return;
176  }
177 
178  g_signal_connect (proxy, "g-signal",
179  G_CALLBACK (media_player_key_pressed_cb),
180  keys);
181  g_signal_connect (proxy, "notify::g-name-owner",
182  G_CALLBACK (mediakeys_name_owner_changed),
183  keys);
184 
185  keys->proxy = proxy;
188 }

+ Here is the caller graph for this function:

Variable Documentation

guint signals[LAST_SIGNAL]
static

Definition at line 57 of file ev-media-player-keys.c.