static void impl_deactivate (PeasActivatable *plugin) { XplayerScreensaverPlugin *pi = XPLAYER_SCREENSAVER_PLUGIN (plugin); g_object_unref (pi->priv->settings); if (pi->priv->handler_id_playing != 0) { XplayerObject *xplayer; xplayer = g_object_get_data (G_OBJECT (plugin), "object"); g_signal_handler_disconnect (G_OBJECT (xplayer), pi->priv->handler_id_playing); pi->priv->handler_id_playing = 0; } if (pi->priv->handler_id_metadata != 0) { g_signal_handler_disconnect (G_OBJECT (pi->priv->bvw), pi->priv->handler_id_metadata); pi->priv->handler_id_metadata = 0; } if (pi->priv->inhibit_cookie != 0) { gtk_application_uninhibit (GTK_APPLICATION (pi->priv->xplayer), pi->priv->inhibit_cookie); pi->priv->inhibit_cookie = 0; } g_object_unref (pi->priv->xplayer); g_object_unref (pi->priv->bvw); }
static void xplayer_screensaver_update_from_state (XplayerObject *xplayer, XplayerScreensaverPlugin *pi) { gboolean lock_screensaver_on_audio, has_video_frames; BaconVideoWidget *bvw; bvw = BACON_VIDEO_WIDGET (xplayer_get_video_widget ((Xplayer *)(xplayer))); lock_screensaver_on_audio = g_settings_get_boolean (pi->priv->settings, "lock-screensaver-on-audio"); has_video_frames = has_video (bvw); if ((xplayer_is_playing (xplayer) != FALSE && has_video_frames) || (xplayer_is_playing (xplayer) != FALSE && !lock_screensaver_on_audio)) { if (pi->priv->inhibit_cookie == 0) { GtkWindow *window; window = xplayer_get_main_window (xplayer); pi->priv->inhibit_cookie = gtk_application_inhibit (GTK_APPLICATION (xplayer), window, GTK_APPLICATION_INHIBIT_IDLE, _("Playing a movie")); g_object_unref (window); } } else { if (pi->priv->inhibit_cookie != 0) { gtk_application_uninhibit (GTK_APPLICATION (pi->priv->xplayer), pi->priv->inhibit_cookie); pi->priv->inhibit_cookie = 0; } } }
static void shell_ready_for_quit (EShell *shell, EActivity *activity, gboolean is_last_ref) { GtkApplication *application; GList *list; if (!is_last_ref) return; application = GTK_APPLICATION (shell); /* Increment the reference count so we can safely emit * a signal without triggering the toggle reference. */ g_object_ref (activity); e_activity_set_state (activity, E_ACTIVITY_COMPLETED); g_object_remove_toggle_ref ( G_OBJECT (activity), (GToggleNotify) shell_ready_for_quit, shell); /* Finalize the activity. */ g_object_unref (activity); /* XXX Inhibiting session manager actions currently only * works on GNOME, so check that we obtained a valid * inhibit cookie before attempting to uninhibit. */ if (shell->priv->inhibit_cookie > 0) { gtk_application_uninhibit ( application, shell->priv->inhibit_cookie); shell->priv->inhibit_cookie = 0; } /* Destroy all watched windows. Note, we iterate over a -copy- * of the watched windows list because the act of destroying a * watched window will modify the watched windows list, which * would derail the iteration. */ list = g_list_copy (gtk_application_get_windows (application)); g_list_foreach (list, (GFunc) gtk_widget_destroy, NULL); g_list_free (list); if (gtk_main_level () > 0) gtk_main_quit (); }
static gboolean uninhibit (RBGPMPlugin *plugin) { GtkApplication *app; RBShell *shell; plugin->timeout_id = 0; if (plugin->cookie == 0) { rb_debug ("Was going to uninhibit session manager, but we haven't inhibited it"); return FALSE; } g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "application", &app, NULL); g_object_unref (shell); rb_debug ("uninhibiting; cookie = %u", plugin->cookie); gtk_application_uninhibit (app, plugin->cookie); plugin->cookie = 0; g_object_unref (app); return FALSE; }