static void impl_deactivate (TotemPlugin *plugin, TotemObject *totem) { TotemMediaPlayerKeysPlugin *pi = TOTEM_MEDIA_PLAYER_KEYS_PLUGIN (plugin); GtkWindow *window; if (pi->media_player_keys_proxy != NULL) { dbus_g_proxy_call (pi->media_player_keys_proxy, "ReleaseMediaPlayerKeys", NULL, G_TYPE_STRING, "Totem", G_TYPE_INVALID, G_TYPE_INVALID); g_object_unref (pi->media_player_keys_proxy); pi->media_player_keys_proxy = NULL; } if (pi->handler_id != 0) { window = totem_get_main_window (totem); if (window == NULL) return; g_signal_handler_disconnect (G_OBJECT (window), pi->handler_id); g_object_unref (window); } }
static void impl_activate (PeasActivatable *plugin) { TotemMediaPlayerKeysPlugin *pi = TOTEM_MEDIA_PLAYER_KEYS_PLUGIN (plugin); TotemObject *totem; GtkWindow *window; pi->priv->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, "org.gnome.SettingsDaemon", G_BUS_NAME_WATCHER_FLAGS_NONE, (GBusNameAppearedCallback) name_appeared_cb, (GBusNameVanishedCallback) name_vanished_cb, g_object_ref (pi), (GDestroyNotify) g_object_unref); totem = g_object_get_data (G_OBJECT (plugin), "object"); window = totem_get_main_window (totem); pi->priv->handler_id = g_signal_connect (G_OBJECT (window), "focus-in-event", G_CALLBACK (on_window_focus_in_event), pi); g_object_unref (G_OBJECT (window)); }
static void impl_deactivate (PeasActivatable *plugin) { TotemMediaPlayerKeysPlugin *pi = TOTEM_MEDIA_PLAYER_KEYS_PLUGIN (plugin); GtkWindow *window; if (pi->priv->cancellable_init) { g_cancellable_cancel (pi->priv->cancellable_init); } if (pi->priv->cancellable) { g_cancellable_cancel (pi->priv->cancellable); } if (pi->priv->proxy != NULL) { g_object_unref (pi->priv->proxy); pi->priv->proxy = NULL; } if (pi->priv->handler_id != 0) { TotemObject *totem; totem = g_object_get_data (G_OBJECT (plugin), "object"); window = totem_get_main_window (totem); if (window == NULL) return; g_signal_handler_disconnect (G_OBJECT (window), pi->priv->handler_id); g_object_unref (window); pi->priv->handler_id = 0; } if (pi->priv->watch_id != 0) { g_bus_unwatch_name (pi->priv->watch_id); pi->priv->watch_id = 0; } }
static gboolean impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error) { TotemMediaPlayerKeysPlugin *pi = TOTEM_MEDIA_PLAYER_KEYS_PLUGIN (plugin); DBusGConnection *connection; GError *err = NULL; GtkWindow *window; connection = dbus_g_bus_get (DBUS_BUS_SESSION, &err); if (connection == NULL) { g_warning ("Error connecting to D-Bus: %s", err->message); return FALSE; } /* Try the mate-settings-daemon version, * then the mate-control-center version of things */ pi->media_player_keys_proxy = dbus_g_proxy_new_for_name_owner (connection, "org.mate.SettingsDaemon", "/org/mate/SettingsDaemon/MediaKeys", "org.mate.SettingsDaemon.MediaKeys", NULL); if (pi->media_player_keys_proxy == NULL) { pi->media_player_keys_proxy = dbus_g_proxy_new_for_name_owner (connection, "org.mate.SettingsDaemon", "/org/mate/SettingsDaemon", "org.mate.SettingsDaemon", &err); } dbus_g_connection_unref (connection); if (err != NULL) { gboolean daemon_not_running; g_warning ("Failed to create dbus proxy for org.mate.SettingsDaemon: %s", err->message); daemon_not_running = (err->code == DBUS_GERROR_NAME_HAS_NO_OWNER); g_error_free (err); /* don't popup error if settings-daemon is not running, * ie when starting totem not under MATE desktop */ return daemon_not_running; } else { g_signal_connect_object (pi->media_player_keys_proxy, "destroy", G_CALLBACK (proxy_destroy), pi, 0); } dbus_g_proxy_call (pi->media_player_keys_proxy, "GrabMediaPlayerKeys", NULL, G_TYPE_STRING, "Totem", G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_INVALID); dbus_g_object_register_marshaller (totem_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal (pi->media_player_keys_proxy, "MediaPlayerKeyPressed", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal (pi->media_player_keys_proxy, "MediaPlayerKeyPressed", G_CALLBACK (on_media_player_key_pressed), totem, NULL); window = totem_get_main_window (totem); pi->handler_id = g_signal_connect (G_OBJECT (window), "focus-in-event", G_CALLBACK (on_window_focus_in_event), pi); g_object_unref (G_OBJECT (window)); return TRUE; }