2002-03-26 17:22:02 +00:00
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
|
|
|
/* gnome-settings-screensaver.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Written by Jacob Berkman <jacob@ximian.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
declare a global GConfClient. (main): unref the global GConfClient.
2005-10-16 Rodrigo Moya <rodrigo@novell.com>
* factory.c: declare a global GConfClient.
(main): unref the global GConfClient.
* gnome-settings-daemon.[ch] (gnome_settings_daemon_get_conf_client):
new function to use the same GConfClient everywhere.
(gnome_settings_daemon_new): use the global GConfClient.
* gnome-settings-accessibility-keyboard.c (set_server_from_gconf,
ax_response_callback, set_gconf_from_server):
* gnome-settings-gtk1theme.c (apply_settings):
* gnome-settings-keybindings.c (bindings_get_entry):
* gnome-settings-keyboard.c (numlock_get_gconf_state,
numlock_set_gconf_state, apply_settings):
* gnome-settings-keyboard-xkb.c (apply_xkb_settings,
gnome_settings_keyboard_xkb_sysconfig_changed_response,
gnome_settings_keyboard_xkb_analyze_sysconfig,
gnome_settings_chk_file_list):
* gnome-settings-screensaver.c (key_toggled_cb,
really_start_screensaver):
* gnome-settings-sound.c (apply_settings):
* gnome-settings-xmodmap.c (check_button_callback,
gnome_settings_load_modmap_files, remove_button_clicked_callback,
load_button_clicked_callback, gnome_settings_modmap_dialog_call):
* gnome-settings-xsettings.c (xft_callback):
use the global GConfClient.
* gnome-settings-keyboard-xkb.c (gnome_settings_keyboard_xkb_load):
don't get another GConfClient when we're getting one passed!
2005-10-17 14:53:19 +00:00
|
|
|
#include "gnome-settings-daemon.h"
|
2002-03-26 17:22:02 +00:00
|
|
|
#include "gnome-settings-screensaver.h"
|
|
|
|
|
2005-05-22 15:46:45 +00:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
2002-03-26 17:22:02 +00:00
|
|
|
#include <gtk/gtkcheckbutton.h>
|
|
|
|
#include <gtk/gtkbox.h>
|
|
|
|
#include <gtk/gtkmessagedialog.h>
|
|
|
|
|
|
|
|
#define START_SCREENSAVER_KEY "/apps/gnome_settings_daemon/screensaver/start_screensaver"
|
|
|
|
#define SHOW_STARTUP_ERRORS_KEY "/apps/gnome_settings_daemon/screensaver/show_startup_errors"
|
|
|
|
#define XSCREENSAVER_COMMAND "xscreensaver -nosplash"
|
2005-07-25 11:55:59 +00:00
|
|
|
#define GSCREENSAVER_COMMAND "gnome-screensaver"
|
2002-03-26 17:22:02 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gnome_settings_screensaver_init (GConfClient *client)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* do nothing.
|
|
|
|
*
|
2005-07-25 11:55:59 +00:00
|
|
|
* with gnome-screensaver, all settings are loaded internally
|
|
|
|
* from gconf at startup
|
|
|
|
*
|
|
|
|
* with xscreensaver, our settings only apply to startup, and
|
|
|
|
* the screensaver settings are all in xscreensaver and not
|
|
|
|
* gconf.
|
2002-03-26 17:22:02 +00:00
|
|
|
*
|
|
|
|
* we could have xscreensaver-demo run gconftool-2 directly,
|
|
|
|
* and start / stop xscreensaver here
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
key_toggled_cb (GtkWidget *toggle, gpointer data)
|
|
|
|
{
|
|
|
|
GConfClient *client;
|
|
|
|
|
declare a global GConfClient. (main): unref the global GConfClient.
2005-10-16 Rodrigo Moya <rodrigo@novell.com>
* factory.c: declare a global GConfClient.
(main): unref the global GConfClient.
* gnome-settings-daemon.[ch] (gnome_settings_daemon_get_conf_client):
new function to use the same GConfClient everywhere.
(gnome_settings_daemon_new): use the global GConfClient.
* gnome-settings-accessibility-keyboard.c (set_server_from_gconf,
ax_response_callback, set_gconf_from_server):
* gnome-settings-gtk1theme.c (apply_settings):
* gnome-settings-keybindings.c (bindings_get_entry):
* gnome-settings-keyboard.c (numlock_get_gconf_state,
numlock_set_gconf_state, apply_settings):
* gnome-settings-keyboard-xkb.c (apply_xkb_settings,
gnome_settings_keyboard_xkb_sysconfig_changed_response,
gnome_settings_keyboard_xkb_analyze_sysconfig,
gnome_settings_chk_file_list):
* gnome-settings-screensaver.c (key_toggled_cb,
really_start_screensaver):
* gnome-settings-sound.c (apply_settings):
* gnome-settings-xmodmap.c (check_button_callback,
gnome_settings_load_modmap_files, remove_button_clicked_callback,
load_button_clicked_callback, gnome_settings_modmap_dialog_call):
* gnome-settings-xsettings.c (xft_callback):
use the global GConfClient.
* gnome-settings-keyboard-xkb.c (gnome_settings_keyboard_xkb_load):
don't get another GConfClient when we're getting one passed!
2005-10-17 14:53:19 +00:00
|
|
|
client = gnome_settings_daemon_get_conf_client ();
|
2002-03-26 17:22:02 +00:00
|
|
|
gconf_client_set_bool (client,
|
|
|
|
SHOW_STARTUP_ERRORS_KEY,
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle))
|
|
|
|
? 0 : 1,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2005-10-15 21:56:43 +00:00
|
|
|
static gboolean
|
|
|
|
really_start_screensaver (gpointer user_data)
|
2002-03-26 17:22:02 +00:00
|
|
|
{
|
|
|
|
GError *gerr = NULL;
|
2005-10-15 21:56:43 +00:00
|
|
|
gboolean use_gscreensaver = FALSE;
|
2002-03-26 17:22:02 +00:00
|
|
|
gboolean show_error;
|
|
|
|
GtkWidget *dialog, *toggle;
|
2005-07-25 11:55:59 +00:00
|
|
|
gchar *ss_command;
|
2005-10-15 21:56:43 +00:00
|
|
|
GConfClient *client;
|
2002-03-26 17:22:02 +00:00
|
|
|
|
2005-07-25 11:55:59 +00:00
|
|
|
if ((ss_command = g_find_program_in_path ("gnome-screensaver")))
|
|
|
|
use_gscreensaver = TRUE;
|
|
|
|
else {
|
|
|
|
if (!(ss_command = g_find_program_in_path ("xscreensaver")))
|
2005-10-15 21:56:43 +00:00
|
|
|
return FALSE;
|
2005-07-25 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (ss_command);
|
|
|
|
if (use_gscreensaver)
|
|
|
|
ss_command = GSCREENSAVER_COMMAND;
|
|
|
|
else
|
|
|
|
ss_command = XSCREENSAVER_COMMAND;
|
|
|
|
|
|
|
|
if (g_spawn_command_line_async (ss_command, &gerr))
|
2005-10-15 21:56:43 +00:00
|
|
|
return FALSE;
|
2002-03-26 17:22:02 +00:00
|
|
|
|
declare a global GConfClient. (main): unref the global GConfClient.
2005-10-16 Rodrigo Moya <rodrigo@novell.com>
* factory.c: declare a global GConfClient.
(main): unref the global GConfClient.
* gnome-settings-daemon.[ch] (gnome_settings_daemon_get_conf_client):
new function to use the same GConfClient everywhere.
(gnome_settings_daemon_new): use the global GConfClient.
* gnome-settings-accessibility-keyboard.c (set_server_from_gconf,
ax_response_callback, set_gconf_from_server):
* gnome-settings-gtk1theme.c (apply_settings):
* gnome-settings-keybindings.c (bindings_get_entry):
* gnome-settings-keyboard.c (numlock_get_gconf_state,
numlock_set_gconf_state, apply_settings):
* gnome-settings-keyboard-xkb.c (apply_xkb_settings,
gnome_settings_keyboard_xkb_sysconfig_changed_response,
gnome_settings_keyboard_xkb_analyze_sysconfig,
gnome_settings_chk_file_list):
* gnome-settings-screensaver.c (key_toggled_cb,
really_start_screensaver):
* gnome-settings-sound.c (apply_settings):
* gnome-settings-xmodmap.c (check_button_callback,
gnome_settings_load_modmap_files, remove_button_clicked_callback,
load_button_clicked_callback, gnome_settings_modmap_dialog_call):
* gnome-settings-xsettings.c (xft_callback):
use the global GConfClient.
* gnome-settings-keyboard-xkb.c (gnome_settings_keyboard_xkb_load):
don't get another GConfClient when we're getting one passed!
2005-10-17 14:53:19 +00:00
|
|
|
client = gnome_settings_daemon_get_conf_client ();
|
2002-03-26 17:22:02 +00:00
|
|
|
show_error = gconf_client_get_bool (client, SHOW_STARTUP_ERRORS_KEY, NULL);
|
|
|
|
if (!show_error) {
|
|
|
|
g_error_free (gerr);
|
2005-10-15 21:56:43 +00:00
|
|
|
return FALSE;
|
2002-03-26 17:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new (NULL,
|
|
|
|
0,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_OK,
|
2002-04-30 09:45:05 +00:00
|
|
|
_("There was an error starting up the screensaver:\n\n"
|
2002-03-26 17:22:02 +00:00
|
|
|
"%s\n\n"
|
2002-04-30 09:45:05 +00:00
|
|
|
"Screensaver functionality will not work in this session."),
|
2002-03-26 17:22:02 +00:00
|
|
|
gerr->message);
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
toggle = gtk_check_button_new_with_mnemonic (
|
2002-04-30 09:45:05 +00:00
|
|
|
_("_Do not show this message again"));
|
2002-03-26 17:22:02 +00:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
|
|
|
if (gconf_client_key_is_writable (client, SHOW_STARTUP_ERRORS_KEY, NULL))
|
|
|
|
g_signal_connect (toggle, "toggled",
|
|
|
|
G_CALLBACK (key_toggled_cb),
|
|
|
|
NULL);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (toggle, FALSE);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
|
|
|
|
toggle,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
2005-10-15 21:56:43 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnome_settings_screensaver_load (GConfClient *client)
|
|
|
|
{
|
|
|
|
gboolean start_screensaver;
|
|
|
|
|
|
|
|
start_screensaver = gconf_client_get_bool (client, START_SCREENSAVER_KEY, NULL);
|
|
|
|
|
|
|
|
if (!start_screensaver)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_timeout_add (25000, (GSourceFunc) really_start_screensaver, NULL);
|
2002-03-26 17:22:02 +00:00
|
|
|
}
|
|
|
|
|