Example #1
0
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 gboolean
inhibit (RBGPMPlugin *plugin)
{
	RBShell *shell;
	GtkApplication *app;
	GtkWindow *window;

	plugin->timeout_id = 0;
	if (plugin->cookie != 0) {
		rb_debug ("Was going to inhibit session manager, but we already have done");
		return FALSE;
	}

	rb_debug ("inhibiting");

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell,
		      "application", &app,
		      "window", &window,
		      NULL);
	g_object_unref (shell);

	plugin->cookie = gtk_application_inhibit (app, window, GTK_APPLICATION_INHIBIT_IDLE, _("Playing"));

	g_object_unref (window);
	g_object_unref (app);
	return FALSE;
}
Example #3
0
static void
shell_prepare_for_quit (EShell *shell)
{
	GtkApplication *application;
	GList *list, *iter;

	/* Are preparations already in progress? */
	if (shell->priv->preparing_for_quit != NULL)
		return;

	application = GTK_APPLICATION (shell);

	shell->priv->inhibit_cookie = gtk_application_inhibit (
		application, NULL,
		GTK_APPLICATION_INHIBIT_SWITCH |
		GTK_APPLICATION_INHIBIT_LOGOUT |
		GTK_APPLICATION_INHIBIT_SUSPEND,
		_("Preparing to quit"));

	shell->priv->preparing_for_quit = e_activity_new ();

	e_activity_set_text (
		shell->priv->preparing_for_quit,
		_("Preparing to quit..."));

	g_object_add_toggle_ref (
		G_OBJECT (shell->priv->preparing_for_quit),
		(GToggleNotify) shell_ready_for_quit, shell);

	g_object_add_weak_pointer (
		G_OBJECT (shell->priv->preparing_for_quit),
		&shell->priv->preparing_for_quit);

	g_signal_emit (
		shell, signals[PREPARE_FOR_QUIT], 0,
		shell->priv->preparing_for_quit);

	g_object_unref (shell->priv->preparing_for_quit);

	/* Desensitize all watched windows to prevent user action. */
	list = gtk_application_get_windows (application);
	for (iter = list; iter != NULL; iter = iter->next)
		gtk_widget_set_sensitive (GTK_WIDGET (iter->data), FALSE);
}