[Xfce4-commits] [apps/xfce4-screensaver] 420/425: Convert tabs to spaces for src/*.{c, h}
noreply at xfce.org
noreply at xfce.org
Mon Oct 15 01:54:27 CEST 2018
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screensaver.
commit 8695d5732c8f2ddb7e6370ac324f7a5d78dd3f36
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sun Oct 14 08:25:56 2018 -0400
Convert tabs to spaces for src/*.{c,h}
---
src/copy-theme-dialog.c | 761 ++++----
src/copy-theme-dialog.h | 24 +-
src/gs-auth-bsdauth.c | 58 +-
src/gs-auth-helper.c | 238 +--
src/gs-auth-pam.c | 1222 ++++++------
src/gs-auth-pwent.c | 254 +--
src/gs-auth.h | 20 +-
src/gs-debug.c | 148 +-
src/gs-debug.h | 10 +-
src/gs-fade.c | 1141 ++++++------
src/gs-fade.h | 38 +-
src/gs-grab-x11.c | 632 +++----
src/gs-grab.h | 34 +-
src/gs-job.c | 708 +++----
src/gs-job.h | 16 +-
src/gs-listener-dbus.c | 3511 +++++++++++++++++------------------
src/gs-listener-dbus.h | 34 +-
src/gs-lock-plug.c | 2537 ++++++++++++-------------
src/gs-lock-plug.h | 42 +-
src/gs-manager.c | 2382 ++++++++++++------------
src/gs-manager.h | 112 +-
src/gs-monitor.c | 534 +++---
src/gs-monitor.h | 18 +-
src/gs-prefs.c | 638 +++----
src/gs-prefs.h | 49 +-
src/gs-theme-manager.c | 444 ++---
src/gs-theme-manager.h | 10 +-
src/gs-visual-gl.c | 118 +-
src/gs-visual-gl.h | 2 +-
src/gs-watcher-x11.c | 850 +++++----
src/gs-watcher.h | 32 +-
src/gs-window-x11.c | 3261 ++++++++++++++++----------------
src/gs-window.h | 104 +-
src/setuid.c | 380 ++--
src/setuid.h | 2 +-
src/subprocs.c | 138 +-
src/subprocs.h | 6 +-
src/test-fade.c | 121 +-
src/test-passwd.c | 364 ++--
src/test-watcher.c | 60 +-
src/test-window.c | 156 +-
src/xfce-bg.c | 3229 ++++++++++++++++----------------
src/xfce-bg.h | 60 +-
src/xfce-desktop-utils.c | 28 +-
src/xfce-desktop-utils.h | 6 +-
src/xfce-rr-private.h | 46 +-
src/xfce-rr.c | 925 ++++-----
src/xfce-rr.h | 60 +-
src/xfce4-screensaver-command.c | 822 ++++----
src/xfce4-screensaver-dialog.c | 885 ++++-----
src/xfce4-screensaver-gl-helper.c | 68 +-
src/xfce4-screensaver-preferences.c | 2305 +++++++++++------------
src/xfce4-screensaver.c | 183 +-
src/xfce4-screensaver.h | 2 +-
src/xfcekbd-config-private.h | 16 +-
src/xfcekbd-desktop-config.c | 368 ++--
src/xfcekbd-desktop-config.h | 58 +-
src/xfcekbd-indicator-config.c | 419 +++--
src/xfcekbd-indicator-config.h | 55 +-
src/xfcekbd-indicator.c | 1173 ++++++------
src/xfcekbd-indicator.h | 31 +-
src/xfcekbd-keyboard-config.c | 314 ++--
src/xfcekbd-keyboard-config.h | 36 +-
63 files changed, 16162 insertions(+), 16136 deletions(-)
diff --git a/src/copy-theme-dialog.c b/src/copy-theme-dialog.c
index 6868169..1fb0aa8 100644
--- a/src/copy-theme-dialog.c
+++ b/src/copy-theme-dialog.c
@@ -36,10 +36,12 @@ copy_theme_dialog_class_init (CopyThemeDialogClass *klass);
static void
copy_theme_dialog_init (CopyThemeDialog *dlg);
static void
-add_file_to_dialog (gpointer data, gpointer user_data);
+add_file_to_dialog (gpointer data,
+ gpointer user_data);
static void
-single_copy_complete (GObject *source_object, GAsyncResult *res,
- gpointer user_data);
+single_copy_complete (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data);
static void
copy_theme_dialog_copy_next (CopyThemeDialog *dialog);
static void
@@ -49,7 +51,8 @@ copy_theme_dialog_finalize (GObject *obj);
static void
copy_theme_dialog_update_num_files (CopyThemeDialog *dlg);
static void
-copy_theme_dialog_response (GtkDialog *dialog, gint response_id);
+copy_theme_dialog_response (GtkDialog *dialog,
+ gint response_id);
static void
eel_gtk_label_make_bold (GtkLabel *label);
static void
@@ -69,18 +72,18 @@ enum
struct _CopyThemeDialogPrivate
{
- GtkWidget *progress;
- GtkWidget *status;
- GtkWidget *current;
- GtkWidget *from;
- GtkWidget *to;
-
- GFile *theme_dir;
- GSList *all_files, *file;
- GSList *all_basenames, *basename;
- guint index;
- guint total_files;
- GCancellable *cancellable;
+ GtkWidget *progress;
+ GtkWidget *status;
+ GtkWidget *current;
+ GtkWidget *from;
+ GtkWidget *to;
+
+ GFile *theme_dir;
+ GSList *all_files, *file;
+ GSList *all_basenames, *basename;
+ guint index;
+ guint total_files;
+ GCancellable *cancellable;
};
guint signals[SIGNAL_COUNT] = {0, 0};
@@ -88,311 +91,313 @@ guint signals[SIGNAL_COUNT] = {0, 0};
GType
copy_theme_dialog_get_type (void)
{
- static GType copy_theme_dialog_type = 0;
-
- if (!copy_theme_dialog_type)
- {
- static GTypeInfo copy_theme_dialog_info =
- {
- sizeof (CopyThemeDialogClass),
- NULL, /* GBaseInitFunc */
- NULL, /* GBaseFinalizeFunc */
- (GClassInitFunc) copy_theme_dialog_class_init,
- NULL, /* GClassFinalizeFunc */
- NULL, /* data */
- sizeof (CopyThemeDialog),
- 0, /* n_preallocs */
- (GInstanceInitFunc) copy_theme_dialog_init,
- NULL
- };
-
- copy_theme_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
- "CopyThemeDialog",
- ©_theme_dialog_info,
- 0);
- }
-
- return copy_theme_dialog_type;
+ static GType copy_theme_dialog_type = 0;
+
+ if (!copy_theme_dialog_type)
+ {
+ static GTypeInfo copy_theme_dialog_info =
+ {
+ sizeof (CopyThemeDialogClass),
+ NULL, /* GBaseInitFunc */
+ NULL, /* GBaseFinalizeFunc */
+ (GClassInitFunc) copy_theme_dialog_class_init,
+ NULL, /* GClassFinalizeFunc */
+ NULL, /* data */
+ sizeof (CopyThemeDialog),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) copy_theme_dialog_init,
+ NULL
+ };
+
+ copy_theme_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
+ "CopyThemeDialog",
+ ©_theme_dialog_info,
+ 0);
+ }
+
+ return copy_theme_dialog_type;
}
static void
copy_theme_dialog_class_init (CopyThemeDialogClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GObject 2.58 */
- g_type_class_add_private (klass, sizeof (CopyThemeDialogPrivate));
- G_GNUC_END_IGNORE_DEPRECATIONS
-
- klass->cancelled = copy_theme_dialog_cancel;
- object_class->finalize = copy_theme_dialog_finalize;
-
- GTK_DIALOG_CLASS (klass)->response = copy_theme_dialog_response;
-
- signals[CANCELLED] = g_signal_new ("cancelled",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CopyThemeDialogClass, cancelled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[COMPLETE] = g_signal_new ("complete",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CopyThemeDialogClass, complete),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- parent_class = g_type_class_peek_parent (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GObject 2.58 */
+ g_type_class_add_private (klass, sizeof (CopyThemeDialogPrivate));
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
+ klass->cancelled = copy_theme_dialog_cancel;
+ object_class->finalize = copy_theme_dialog_finalize;
+
+ GTK_DIALOG_CLASS (klass)->response = copy_theme_dialog_response;
+
+ signals[CANCELLED] = g_signal_new ("cancelled",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (CopyThemeDialogClass, cancelled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[COMPLETE] = g_signal_new ("complete",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (CopyThemeDialogClass, complete),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ parent_class = g_type_class_peek_parent (klass);
}
GtkWidget*
copy_theme_dialog_new (GList *files)
{
- GtkWidget *dialog;
- CopyThemeDialogPrivate *priv;
+ GtkWidget *dialog;
+ CopyThemeDialogPrivate *priv;
- dialog = GTK_WIDGET (g_object_new (COPY_THEME_DIALOG_TYPE, NULL));
- priv = COPY_THEME_DIALOG (dialog)->priv;
- priv->index = 0;
- priv->total_files = 0;
- priv->all_files = NULL;
- priv->all_basenames = NULL;
+ dialog = GTK_WIDGET (g_object_new (COPY_THEME_DIALOG_TYPE, NULL));
+ priv = COPY_THEME_DIALOG (dialog)->priv;
+ priv->index = 0;
+ priv->total_files = 0;
+ priv->all_files = NULL;
+ priv->all_basenames = NULL;
- g_list_foreach (files, add_file_to_dialog, dialog);
+ g_list_foreach (files, add_file_to_dialog, dialog);
- priv->file = priv->all_files;
- priv->basename = priv->all_basenames;
+ priv->file = priv->all_files;
+ priv->basename = priv->all_basenames;
- return dialog;
+ return dialog;
}
static gboolean
copy_finished (CopyThemeDialog *dialog)
{
- return (g_cancellable_is_cancelled (dialog->priv->cancellable) ||
- dialog->priv->file == NULL);
+ return (g_cancellable_is_cancelled (dialog->priv->cancellable) ||
+ dialog->priv->file == NULL);
}
static void
copy_theme_dialog_init (CopyThemeDialog *dlg)
{
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *progress_vbox;
- GtkWidget *grid;
- GtkWidget *label;
- GtkWidget *dialog_vbox;
- char *markup;
- gchar *theme_dir_path;
-
- dlg->priv = G_TYPE_INSTANCE_GET_PRIVATE (dlg, COPY_THEME_DIALOG_TYPE,
- CopyThemeDialogPrivate);
-
- /* Find and, if needed, create the directory for storing themes */
- theme_dir_path = g_build_filename (g_get_user_data_dir (),
- "applications", "screensavers",
- NULL);
- dlg->priv->theme_dir = g_file_new_for_path (theme_dir_path);
- g_mkdir_with_parents (theme_dir_path, S_IRWXU);
- g_free (theme_dir_path);
-
- /* For cancelling async I/O operations */
- dlg->priv->cancellable = g_cancellable_new ();
-
- /* GUI settings */
- dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox),
- 4);
- gtk_box_set_spacing (GTK_BOX (dialog_vbox), 4);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
-
- dlg->priv->status = gtk_label_new ("");
- markup = g_strdup_printf ("<big><b>%s</b></big>", _("Copying files"));
- gtk_label_set_markup (GTK_LABEL (dlg->priv->status), markup);
- g_free (markup);
-
- gtk_widget_set_halign (dlg->priv->status, GTK_ALIGN_START);
- gtk_widget_set_valign (dlg->priv->status, GTK_ALIGN_START);
- gtk_box_pack_start (GTK_BOX (vbox), dlg->priv->status, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
-
- grid = gtk_grid_new ();
- gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
- gtk_grid_set_column_spacing (GTK_GRID (grid), 4);
- gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
-
- create_titled_label (GTK_GRID (grid), 0,
- &label,
- &dlg->priv->from);
- gtk_label_set_text (GTK_LABEL (label), _("From:"));
- create_titled_label (GTK_GRID (grid), 1,
- &label,
- &dlg->priv->to);
- gtk_label_set_text (GTK_LABEL (label), _("To:"));
-
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (grid), FALSE, FALSE, 0);
-
- progress_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_set_homogeneous (GTK_BOX (progress_vbox), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), progress_vbox, FALSE, FALSE, 0);
-
- dlg->priv->progress = gtk_progress_bar_new ();
- gtk_box_pack_start (GTK_BOX (progress_vbox),
- dlg->priv->progress, FALSE, FALSE, 0);
-
- dlg->priv->current = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (progress_vbox),
- dlg->priv->current, FALSE, FALSE, 0);
- gtk_widget_set_halign (dlg->priv->current, GTK_ALIGN_START);
-
- gtk_dialog_add_button (GTK_DIALOG (dlg),
- _("_Cancel"), GTK_RESPONSE_CANCEL);
-
- gtk_window_set_title (GTK_WINDOW (dlg),
- _("Copying themes"));
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 6);
-
- gtk_widget_show_all (dialog_vbox);
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *progress_vbox;
+ GtkWidget *grid;
+ GtkWidget *label;
+ GtkWidget *dialog_vbox;
+ char *markup;
+ gchar *theme_dir_path;
+
+ dlg->priv = G_TYPE_INSTANCE_GET_PRIVATE (dlg, COPY_THEME_DIALOG_TYPE,
+ CopyThemeDialogPrivate);
+
+ /* Find and, if needed, create the directory for storing themes */
+ theme_dir_path = g_build_filename (g_get_user_data_dir (),
+ "applications", "screensavers",
+ NULL);
+ dlg->priv->theme_dir = g_file_new_for_path (theme_dir_path);
+ g_mkdir_with_parents (theme_dir_path, S_IRWXU);
+ g_free (theme_dir_path);
+
+ /* For cancelling async I/O operations */
+ dlg->priv->cancellable = g_cancellable_new ();
+
+ /* GUI settings */
+ dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
+
+ gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox),
+ 4);
+ gtk_box_set_spacing (GTK_BOX (dialog_vbox), 4);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+
+ dlg->priv->status = gtk_label_new ("");
+ markup = g_strdup_printf ("<big><b>%s</b></big>", _("Copying files"));
+ gtk_label_set_markup (GTK_LABEL (dlg->priv->status), markup);
+ g_free (markup);
+
+ gtk_widget_set_halign (dlg->priv->status, GTK_ALIGN_START);
+ gtk_widget_set_valign (dlg->priv->status, GTK_ALIGN_START);
+ gtk_box_pack_start (GTK_BOX (vbox), dlg->priv->status, FALSE, FALSE, 0);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 4);
+ gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
+
+ create_titled_label (GTK_GRID (grid), 0,
+ &label,
+ &dlg->priv->from);
+ gtk_label_set_text (GTK_LABEL (label), _("From:"));
+ create_titled_label (GTK_GRID (grid), 1,
+ &label,
+ &dlg->priv->to);
+ gtk_label_set_text (GTK_LABEL (label), _("To:"));
+
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (grid), FALSE, FALSE, 0);
+
+ progress_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_set_homogeneous (GTK_BOX (progress_vbox), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox), progress_vbox, FALSE, FALSE, 0);
+
+ dlg->priv->progress = gtk_progress_bar_new ();
+ gtk_box_pack_start (GTK_BOX (progress_vbox),
+ dlg->priv->progress, FALSE, FALSE, 0);
+
+ dlg->priv->current = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (progress_vbox),
+ dlg->priv->current, FALSE, FALSE, 0);
+ gtk_widget_set_halign (dlg->priv->current, GTK_ALIGN_START);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ _("_Cancel"), GTK_RESPONSE_CANCEL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg),
+ _("Copying themes"));
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 6);
+
+ gtk_widget_show_all (dialog_vbox);
}
static void
-add_file_to_dialog (gpointer data, gpointer user_data)
+add_file_to_dialog (gpointer data,
+ gpointer user_data)
{
- CopyThemeDialogPrivate *priv;
- GFile *file;
- gchar *basename = NULL, *raw_basename;
-
- priv = COPY_THEME_DIALOG (user_data)->priv;
- file = G_FILE (data);
-
- raw_basename = g_file_get_basename (file);
- if (g_str_has_suffix (raw_basename, ".desktop"))
- {
- /* FIXME: validate key file? */
- basename = g_strndup (raw_basename,
- /* 8 = strlen (".desktop") */
- strlen (raw_basename) - 8);
- }
- g_free (raw_basename);
-
- if (basename)
- {
- g_object_ref (file);
- priv->all_files = g_slist_append (priv->all_files, file);
- priv->all_basenames = g_slist_append (priv->all_basenames, basename);
- priv->total_files++;
- }
-
- else
- {
- GtkWidget *dialog;
- gchar *uri;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (user_data),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Invalid screensaver theme"));
- uri = g_file_get_uri (file);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("%s does not appear to be a valid screensaver theme."),
- uri);
- g_free (uri);
- gtk_window_set_title (GTK_WINDOW (dialog), "");
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver");
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
+ CopyThemeDialogPrivate *priv;
+ GFile *file;
+ gchar *basename = NULL, *raw_basename;
+
+ priv = COPY_THEME_DIALOG (user_data)->priv;
+ file = G_FILE (data);
+
+ raw_basename = g_file_get_basename (file);
+ if (g_str_has_suffix (raw_basename, ".desktop"))
+ {
+ /* FIXME: validate key file? */
+ basename = g_strndup (raw_basename,
+ /* 8 = strlen (".desktop") */
+ strlen (raw_basename) - 8);
+ }
+ g_free (raw_basename);
+
+ if (basename)
+ {
+ g_object_ref (file);
+ priv->all_files = g_slist_append (priv->all_files, file);
+ priv->all_basenames = g_slist_append (priv->all_basenames, basename);
+ priv->total_files++;
+ }
+
+ else
+ {
+ GtkWidget *dialog;
+ gchar *uri;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (user_data),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Invalid screensaver theme"));
+ uri = g_file_get_uri (file);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("%s does not appear to be a valid screensaver theme."),
+ uri);
+ g_free (uri);
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver");
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
}
static void
-single_copy_complete (GObject *source_object, GAsyncResult *res,
- gpointer user_data)
+single_copy_complete (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- GError *error = NULL;
- gboolean should_continue = FALSE;
- CopyThemeDialog *dialog = COPY_THEME_DIALOG (user_data);
-
- if (g_file_copy_finish (G_FILE (source_object), res, &error))
- {
- should_continue = TRUE;
- }
-
- else
- {
- /* If the file already exists, generate a new random name
- * and try again.
- **/
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
- {
- GFile *file, *destination;
- gchar *basename, *full_basename;
- g_error_free (error);
-
- file = G_FILE (dialog->priv->file->data);
- basename = (gchar *) (dialog->priv->basename->data);
-
- g_return_if_fail (file != NULL);
- g_return_if_fail (basename != NULL);
-
- full_basename = g_strdup_printf ("%s-%u.desktop",
- basename,
- g_random_int ());
- destination = g_file_get_child (dialog->priv->theme_dir,
- full_basename);
- g_free (full_basename);
-
- g_file_copy_async (file, destination, G_FILE_COPY_NONE,
- G_PRIORITY_DEFAULT,
- dialog->priv->cancellable,
- NULL, NULL,
- single_copy_complete, dialog);
- }
-
- else
- {
- if (g_error_matches (error, G_IO_ERROR,
- G_IO_ERROR_CANCELLED))
- {
- /* User has cancelled the theme copy */
- g_signal_emit (G_OBJECT (dialog),
- signals[CANCELLED],
- 0, NULL);
- }
-
- else
- {
- /* Some other error occurred, ignore and
- * try to copy remaining files
- **/
- should_continue = TRUE;
- }
-
- g_error_free (error);
- }
- }
-
- /* Update informational widgets and, if needed, signal
- * copy completion.
- **/
- if (should_continue)
- {
- dialog->priv->index++;
- dialog->priv->file = dialog->priv->file->next;
- dialog->priv->basename = dialog->priv->basename->next;
- copy_theme_dialog_update_num_files (dialog);
- copy_theme_dialog_copy_next (dialog);
- }
+ GError *error = NULL;
+ gboolean should_continue = FALSE;
+ CopyThemeDialog *dialog = COPY_THEME_DIALOG (user_data);
+
+ if (g_file_copy_finish (G_FILE (source_object), res, &error))
+ {
+ should_continue = TRUE;
+ }
+
+ else
+ {
+ /* If the file already exists, generate a new random name
+ * and try again.
+ **/
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+ {
+ GFile *file, *destination;
+ gchar *basename, *full_basename;
+ g_error_free (error);
+
+ file = G_FILE (dialog->priv->file->data);
+ basename = (gchar *) (dialog->priv->basename->data);
+
+ g_return_if_fail (file != NULL);
+ g_return_if_fail (basename != NULL);
+
+ full_basename = g_strdup_printf ("%s-%u.desktop",
+ basename,
+ g_random_int ());
+ destination = g_file_get_child (dialog->priv->theme_dir,
+ full_basename);
+ g_free (full_basename);
+
+ g_file_copy_async (file, destination, G_FILE_COPY_NONE,
+ G_PRIORITY_DEFAULT,
+ dialog->priv->cancellable,
+ NULL, NULL,
+ single_copy_complete, dialog);
+ }
+
+ else
+ {
+ if (g_error_matches (error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED))
+ {
+ /* User has cancelled the theme copy */
+ g_signal_emit (G_OBJECT (dialog),
+ signals[CANCELLED],
+ 0, NULL);
+ }
+
+ else
+ {
+ /* Some other error occurred, ignore and
+ * try to copy remaining files
+ **/
+ should_continue = TRUE;
+ }
+
+ g_error_free (error);
+ }
+ }
+
+ /* Update informational widgets and, if needed, signal
+ * copy completion.
+ **/
+ if (should_continue)
+ {
+ dialog->priv->index++;
+ dialog->priv->file = dialog->priv->file->next;
+ dialog->priv->basename = dialog->priv->basename->next;
+ copy_theme_dialog_update_num_files (dialog);
+ copy_theme_dialog_copy_next (dialog);
+ }
}
/* Try to copy the theme file to the user's screensaver directory.
@@ -403,97 +408,97 @@ single_copy_complete (GObject *source_object, GAsyncResult *res,
static void
copy_theme_dialog_copy_next (CopyThemeDialog *dialog)
{
- GFile *file, *destination;
- gchar *basename, *full_basename;
+ GFile *file, *destination;
+ gchar *basename, *full_basename;
- if (copy_finished (dialog))
- {
- g_signal_emit (G_OBJECT (dialog), signals[COMPLETE],
- 0, NULL);
- return;
- }
+ if (copy_finished (dialog))
+ {
+ g_signal_emit (G_OBJECT (dialog), signals[COMPLETE],
+ 0, NULL);
+ return;
+ }
- file = G_FILE (dialog->priv->file->data);
- basename = (gchar *) (dialog->priv->basename->data);
+ file = G_FILE (dialog->priv->file->data);
+ basename = (gchar *) (dialog->priv->basename->data);
- g_return_if_fail (file != NULL);
- g_return_if_fail (basename != NULL);
+ g_return_if_fail (file != NULL);
+ g_return_if_fail (basename != NULL);
- full_basename = g_strdup_printf ("%s.desktop", basename);
- destination = g_file_get_child (dialog->priv->theme_dir, full_basename);
- g_free (full_basename);
+ full_basename = g_strdup_printf ("%s.desktop", basename);
+ destination = g_file_get_child (dialog->priv->theme_dir, full_basename);
+ g_free (full_basename);
- g_file_copy_async (file, destination, G_FILE_COPY_NONE,
- G_PRIORITY_DEFAULT, dialog->priv->cancellable,
- NULL, NULL, single_copy_complete, dialog);
+ g_file_copy_async (file, destination, G_FILE_COPY_NONE,
+ G_PRIORITY_DEFAULT, dialog->priv->cancellable,
+ NULL, NULL, single_copy_complete, dialog);
}
static gboolean
timeout_display_dialog (gpointer data)
{
- if (IS_COPY_THEME_DIALOG (data))
- {
- CopyThemeDialog *dialog = COPY_THEME_DIALOG (data);
- if (!copy_finished (dialog))
- {
- gtk_widget_show (GTK_WIDGET (dialog));
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (copy_theme_dialog_response),
- dialog);
- }
- }
- return FALSE;
+ if (IS_COPY_THEME_DIALOG (data))
+ {
+ CopyThemeDialog *dialog = COPY_THEME_DIALOG (data);
+ if (!copy_finished (dialog))
+ {
+ gtk_widget_show (GTK_WIDGET (dialog));
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (copy_theme_dialog_response),
+ dialog);
+ }
+ }
+ return FALSE;
}
void
copy_theme_dialog_begin (CopyThemeDialog *dialog)
{
- gtk_widget_hide (GTK_WIDGET (dialog));
+ gtk_widget_hide (GTK_WIDGET (dialog));
- /* If the copy operation takes more than half a second to
- * complete, display the dialog.
- **/
- g_timeout_add (500, timeout_display_dialog, dialog);
+ /* If the copy operation takes more than half a second to
+ * complete, display the dialog.
+ **/
+ g_timeout_add (500, timeout_display_dialog, dialog);
- copy_theme_dialog_copy_next (dialog);
+ copy_theme_dialog_copy_next (dialog);
}
static void
copy_theme_dialog_cancel (CopyThemeDialog *dialog)
{
- g_cancellable_cancel (dialog->priv->cancellable);
+ g_cancellable_cancel (dialog->priv->cancellable);
}
static void
copy_theme_dialog_finalize (GObject *obj)
{
- CopyThemeDialog *dlg = COPY_THEME_DIALOG (obj);
+ CopyThemeDialog *dlg = COPY_THEME_DIALOG (obj);
- g_object_unref (dlg->priv->theme_dir);
- g_slist_foreach (dlg->priv->all_files, (GFunc) (g_object_unref), NULL);
- g_slist_free (dlg->priv->all_files);
- g_slist_foreach (dlg->priv->all_basenames, (GFunc) (g_free), NULL);
- g_slist_free (dlg->priv->all_basenames);
- g_object_unref (dlg->priv->cancellable);
+ g_object_unref (dlg->priv->theme_dir);
+ g_slist_foreach (dlg->priv->all_files, (GFunc) (g_object_unref), NULL);
+ g_slist_free (dlg->priv->all_files);
+ g_slist_foreach (dlg->priv->all_basenames, (GFunc) (g_free), NULL);
+ g_slist_free (dlg->priv->all_basenames);
+ g_object_unref (dlg->priv->cancellable);
- if (parent_class->finalize)
- parent_class->finalize (G_OBJECT (dlg));
+ if (parent_class->finalize)
+ parent_class->finalize (G_OBJECT (dlg));
}
static void
copy_theme_dialog_update_num_files (CopyThemeDialog *dlg)
{
- gchar *str = g_strdup_printf (_("Copying file: %u of %u"),
- dlg->priv->index, dlg->priv->total_files);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (dlg->priv->progress), str);
- g_free (str);
+ gchar *str = g_strdup_printf (_("Copying file: %u of %u"),
+ dlg->priv->index, dlg->priv->total_files);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (dlg->priv->progress), str);
+ g_free (str);
}
static void
copy_theme_dialog_response (GtkDialog *dialog, gint response_id)
{
- g_cancellable_cancel (COPY_THEME_DIALOG (dialog)->priv->cancellable);
+ g_cancellable_cancel (COPY_THEME_DIALOG (dialog)->priv->cancellable);
}
/**
@@ -505,26 +510,26 @@ copy_theme_dialog_response (GtkDialog *dialog, gint response_id)
static void
eel_gtk_label_make_bold (GtkLabel *label)
{
- PangoFontDescription *font_desc;
- PangoAttrList *attrlist;
- PangoAttribute *attr;
-
- font_desc = pango_font_description_new ();
- attrlist = pango_attr_list_new();
-
- pango_font_description_set_weight (font_desc,
- PANGO_WEIGHT_BOLD);
- attr = pango_attr_font_desc_new(font_desc);
- pango_font_description_free (font_desc);
- pango_attr_list_insert (attrlist, attr);
-
- /* This will only affect the weight of the font, the rest is
- * from the current state of the widget, which comes from the
- * theme or user prefs, since the font desc only has the
- * weight flag turned on.
- */
- gtk_label_set_attributes (label, attrlist);
- pango_attr_list_unref (attrlist);
+ PangoFontDescription *font_desc;
+ PangoAttrList *attrlist;
+ PangoAttribute *attr;
+
+ font_desc = pango_font_description_new ();
+ attrlist = pango_attr_list_new();
+
+ pango_font_description_set_weight (font_desc,
+ PANGO_WEIGHT_BOLD);
+ attr = pango_attr_font_desc_new(font_desc);
+ pango_font_description_free (font_desc);
+ pango_attr_list_insert (attrlist, attr);
+
+ /* This will only affect the weight of the font, the rest is
+ * from the current state of the widget, which comes from the
+ * theme or user prefs, since the font desc only has the
+ * weight flag turned on.
+ */
+ gtk_label_set_attributes (label, attrlist);
+ pango_attr_list_unref (attrlist);
}
/* from caja */
@@ -534,21 +539,21 @@ create_titled_label (GtkGrid *grid,
GtkWidget **title_widget,
GtkWidget **label_text_widget)
{
- *title_widget = gtk_label_new ("");
- eel_gtk_label_make_bold (GTK_LABEL (*title_widget));
- gtk_widget_set_halign (*title_widget, GTK_ALIGN_END);
- gtk_widget_set_valign (*title_widget, GTK_ALIGN_START);
-
- gtk_grid_attach (grid, *title_widget,
- 0, row, 1, 1);
- gtk_widget_show (*title_widget);
-
- *label_text_widget = gtk_label_new ("");
- gtk_label_set_ellipsize (GTK_LABEL (*label_text_widget), PANGO_ELLIPSIZE_END);
- gtk_widget_set_hexpand (*label_text_widget, TRUE);
- gtk_grid_attach (grid, *label_text_widget,
- 1, row, 1, 1);
- gtk_widget_show (*label_text_widget);
- gtk_widget_set_halign (*label_text_widget, GTK_ALIGN_START);
- gtk_widget_set_valign (*label_text_widget, GTK_ALIGN_START);
+ *title_widget = gtk_label_new ("");
+ eel_gtk_label_make_bold (GTK_LABEL (*title_widget));
+ gtk_widget_set_halign (*title_widget, GTK_ALIGN_END);
+ gtk_widget_set_valign (*title_widget, GTK_ALIGN_START);
+
+ gtk_grid_attach (grid, *title_widget,
+ 0, row, 1, 1);
+ gtk_widget_show (*title_widget);
+
+ *label_text_widget = gtk_label_new ("");
+ gtk_label_set_ellipsize (GTK_LABEL (*label_text_widget), PANGO_ELLIPSIZE_END);
+ gtk_widget_set_hexpand (*label_text_widget, TRUE);
+ gtk_grid_attach (grid, *label_text_widget,
+ 1, row, 1, 1);
+ gtk_widget_show (*label_text_widget);
+ gtk_widget_set_halign (*label_text_widget, GTK_ALIGN_START);
+ gtk_widget_set_valign (*label_text_widget, GTK_ALIGN_START);
}
diff --git a/src/copy-theme-dialog.h b/src/copy-theme-dialog.h
index 4f18546..b76751f 100644
--- a/src/copy-theme-dialog.h
+++ b/src/copy-theme-dialog.h
@@ -24,32 +24,32 @@
G_BEGIN_DECLS
-#define COPY_THEME_DIALOG_TYPE copy_theme_dialog_get_type ()
+#define COPY_THEME_DIALOG_TYPE copy_theme_dialog_get_type ()
#define COPY_THEME_DIALOG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, COPY_THEME_DIALOG_TYPE, CopyThemeDialog)
#define COPY_THEME_DIALOG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, COPY_THEME_DIALOG_TYPE, CopyThemeDialogClass)
#define IS_COPY_THEME_DIALOG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, COPY_THEME_DIALOG_TYPE)
-typedef struct _CopyThemeDialog CopyThemeDialog;
-typedef struct _CopyThemeDialogClass CopyThemeDialogClass;
-typedef struct _CopyThemeDialogPrivate CopyThemeDialogPrivate;
+typedef struct _CopyThemeDialog CopyThemeDialog;
+typedef struct _CopyThemeDialogClass CopyThemeDialogClass;
+typedef struct _CopyThemeDialogPrivate CopyThemeDialogPrivate;
struct _CopyThemeDialog
{
- GtkDialog dialog;
- CopyThemeDialogPrivate *priv;
+ GtkDialog dialog;
+ CopyThemeDialogPrivate *priv;
};
struct _CopyThemeDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
- void (*cancelled) (CopyThemeDialog *dialog);
- void (*complete) (CopyThemeDialog *dialog);
+ void (*cancelled) (CopyThemeDialog *dialog);
+ void (*complete) (CopyThemeDialog *dialog);
};
-GType copy_theme_dialog_get_type (void);
-GtkWidget *copy_theme_dialog_new (GList *files);
-void copy_theme_dialog_begin (CopyThemeDialog *dialog);
+GType copy_theme_dialog_get_type (void);
+GtkWidget *copy_theme_dialog_new (GList *files);
+void copy_theme_dialog_begin (CopyThemeDialog *dialog);
G_END_DECLS
diff --git a/src/gs-auth-bsdauth.c b/src/gs-auth-bsdauth.c
index 386e4d0..3085c93 100644
--- a/src/gs-auth-bsdauth.c
+++ b/src/gs-auth-bsdauth.c
@@ -42,62 +42,62 @@ static gboolean verbose_enabled = FALSE;
GQuark
gs_auth_error_quark (void)
{
- static GQuark quark = 0;
- if (! quark) {
- quark = g_quark_from_static_string ("gs_auth_error");
- }
+ static GQuark quark = 0;
+ if (! quark) {
+ quark = g_quark_from_static_string ("gs_auth_error");
+ }
- return quark;
+ return quark;
}
void
gs_auth_set_verbose (gboolean enabled)
{
- verbose_enabled = enabled;
+ verbose_enabled = enabled;
}
gboolean
gs_auth_get_verbose (void)
{
- return verbose_enabled;
+ return verbose_enabled;
}
gboolean
-gs_auth_verify_user (const char *username,
- const char *display,
- GSAuthMessageFunc func,
- gpointer data,
- GError **error)
+gs_auth_verify_user (const char *username,
+ const char *display,
+ GSAuthMessageFunc func,
+ gpointer data,
+ GError **error)
{
- int res;
- char *password;
+ int res;
+ char *password;
- /* ask for the password for user */
- if (func != NULL) {
- func (GS_AUTH_MESSAGE_PROMPT_ECHO_OFF,
- "Password: ",
- &password,
- data);
- }
+ /* ask for the password for user */
+ if (func != NULL) {
+ func (GS_AUTH_MESSAGE_PROMPT_ECHO_OFF,
+ "Password: ",
+ &password,
+ data);
+ }
- if (password == NULL) {
- return FALSE;
- }
+ if (password == NULL) {
+ return FALSE;
+ }
- /* authenticate */
- res = auth_userokay((char *)username, NULL, "auth-xfce4-screensaver", password);
+ /* authenticate */
+ res = auth_userokay((char *)username, NULL, "auth-xfce4-screensaver", password);
- return res;
+ return res;
}
gboolean
gs_auth_init (void)
{
- return TRUE;
+ return TRUE;
}
gboolean
gs_auth_priv_init (void)
{
- return TRUE;
+ return TRUE;
}
diff --git a/src/gs-auth-helper.c b/src/gs-auth-helper.c
index 2e62e76..c699726 100644
--- a/src/gs-auth-helper.c
+++ b/src/gs-auth-helper.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* written by Olaf Kirch <okir at suse.de>
* xscreensaver, Copyright (c) 1993-2004 Jamie Zawinski <jwz at jwz.org>
@@ -55,25 +55,25 @@ static gboolean verbose_enabled = FALSE;
GQuark
gs_auth_error_quark (void)
{
- static GQuark quark = 0;
- if (! quark)
- {
- quark = g_quark_from_static_string ("gs_auth_error");
- }
+ static GQuark quark = 0;
+ if (! quark)
+ {
+ quark = g_quark_from_static_string ("gs_auth_error");
+ }
- return quark;
+ return quark;
}
void
gs_auth_set_verbose (gboolean enabled)
{
- verbose_enabled = enabled;
+ verbose_enabled = enabled;
}
gboolean
gs_auth_get_verbose (void)
{
- return verbose_enabled;
+ return verbose_enabled;
}
static gboolean
@@ -81,133 +81,133 @@ ext_run (const char *user,
const char *typed_passwd,
gboolean verbose)
{
- int pfd[2], status;
- pid_t pid;
-
- if (pipe (pfd) < 0)
- {
- return 0;
- }
-
- if (verbose)
- {
- g_message ("ext_run (%s, %s)",
- PASSWD_HELPER_PROGRAM, user);
- }
-
- block_sigchld ();
-
- if ((pid = fork ()) < 0)
- {
- close (pfd [0]);
- close (pfd [1]);
- return FALSE;
- }
-
- if (pid == 0)
- {
- close (pfd [1]);
- if (pfd [0] != 0)
- {
- dup2 (pfd [0], 0);
- }
-
- /* Helper is invoked as helper service-name [user] */
- execlp (PASSWD_HELPER_PROGRAM, PASSWD_HELPER_PROGRAM, "xfce4-screensaver", user, NULL);
- if (verbose)
- {
- g_message ("%s: %s", PASSWD_HELPER_PROGRAM, g_strerror (errno));
- }
-
- exit (1);
- }
-
- close (pfd [0]);
-
- /* Write out password to helper process */
- if (!typed_passwd)
- {
- typed_passwd = "";
- }
- write (pfd [1], typed_passwd, strlen (typed_passwd));
- close (pfd [1]);
-
- while (waitpid (pid, &status, 0) < 0)
- {
- if (errno == EINTR)
- {
- continue;
- }
-
- if (verbose)
- {
- g_message ("ext_run: waitpid failed: %s\n",
- g_strerror (errno));
- }
-
- unblock_sigchld ();
- return FALSE;
- }
-
- unblock_sigchld ();
-
- if (! WIFEXITED (status) || WEXITSTATUS (status) != 0)
- {
- return FALSE;
- }
-
- return TRUE;
+ int pfd[2], status;
+ pid_t pid;
+
+ if (pipe (pfd) < 0)
+ {
+ return 0;
+ }
+
+ if (verbose)
+ {
+ g_message ("ext_run (%s, %s)",
+ PASSWD_HELPER_PROGRAM, user);
+ }
+
+ block_sigchld ();
+
+ if ((pid = fork ()) < 0)
+ {
+ close (pfd [0]);
+ close (pfd [1]);
+ return FALSE;
+ }
+
+ if (pid == 0)
+ {
+ close (pfd [1]);
+ if (pfd [0] != 0)
+ {
+ dup2 (pfd [0], 0);
+ }
+
+ /* Helper is invoked as helper service-name [user] */
+ execlp (PASSWD_HELPER_PROGRAM, PASSWD_HELPER_PROGRAM, "xfce4-screensaver", user, NULL);
+ if (verbose)
+ {
+ g_message ("%s: %s", PASSWD_HELPER_PROGRAM, g_strerror (errno));
+ }
+
+ exit (1);
+ }
+
+ close (pfd [0]);
+
+ /* Write out password to helper process */
+ if (!typed_passwd)
+ {
+ typed_passwd = "";
+ }
+ write (pfd [1], typed_passwd, strlen (typed_passwd));
+ close (pfd [1]);
+
+ while (waitpid (pid, &status, 0) < 0)
+ {
+ if (errno == EINTR)
+ {
+ continue;
+ }
+
+ if (verbose)
+ {
+ g_message ("ext_run: waitpid failed: %s\n",
+ g_strerror (errno));
+ }
+
+ unblock_sigchld ();
+ return FALSE;
+ }
+
+ unblock_sigchld ();
+
+ if (! WIFEXITED (status) || WEXITSTATUS (status) != 0)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
}
gboolean
-gs_auth_verify_user (const char *username,
- const char *display,
- GSAuthMessageFunc func,
- gpointer data,
- GError **error)
+gs_auth_verify_user (const char *username,
+ const char *display,
+ GSAuthMessageFunc func,
+ gpointer data,
+ GError **error)
{
- gboolean res = FALSE;
- char *password;
+ gboolean res = FALSE;
+ char *password;
- password = NULL;
+ password = NULL;
- /* ask for the password for user */
- if (func != NULL)
- {
- func (GS_AUTH_MESSAGE_PROMPT_ECHO_OFF,
- "Password: ",
- &password,
- data);
- }
+ /* ask for the password for user */
+ if (func != NULL)
+ {
+ func (GS_AUTH_MESSAGE_PROMPT_ECHO_OFF,
+ "Password: ",
+ &password,
+ data);
+ }
- if (password == NULL)
- {
- return FALSE;
- }
+ if (password == NULL)
+ {
+ return FALSE;
+ }
- res = ext_run (username, password, gs_auth_get_verbose ());
+ res = ext_run (username, password, gs_auth_get_verbose ());
- return res;
+ return res;
}
gboolean
gs_auth_init (void)
{
- return TRUE;
+ return TRUE;
}
gboolean
gs_auth_priv_init (void)
{
- /* Make sure the passwd helper exists */
- if (g_access (PASSWD_HELPER_PROGRAM, X_OK) < 0)
- {
- g_warning ("%s does not exist. "
- "password authentication via "
- "external helper will not work.",
- PASSWD_HELPER_PROGRAM);
- return FALSE;
- }
-
- return TRUE;
+ /* Make sure the passwd helper exists */
+ if (g_access (PASSWD_HELPER_PROGRAM, X_OK) < 0)
+ {
+ g_warning ("%s does not exist. "
+ "password authentication via "
+ "external helper will not work.",
+ PASSWD_HELPER_PROGRAM);
+ return FALSE;
+ }
+
+ return TRUE;
}
diff --git a/src/gs-auth-pam.c b/src/gs-auth-pam.c
index 9484dd8..4299370 100644
--- a/src/gs-auth-pam.c
+++ b/src/gs-auth-pam.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
* Copyright (C) 2006 Ray Strode <rstrode at redhat.com>
@@ -82,20 +82,20 @@ static gboolean did_we_ask_for_password = FALSE;
struct pam_closure
{
- const char *username;
- GSAuthMessageFunc cb_func;
- gpointer cb_data;
- int signal_fd;
- int result;
+ const char *username;
+ GSAuthMessageFunc cb_func;
+ gpointer cb_data;
+ int signal_fd;
+ int result;
};
typedef struct
{
- struct pam_closure *closure;
- GSAuthMessageStyle style;
- const char *msg;
- char **resp;
- gboolean should_interrupt_stack;
+ struct pam_closure *closure;
+ GSAuthMessageStyle style;
+ const char *msg;
+ char **resp;
+ gboolean should_interrupt_stack;
} GsAuthMessageHandlerData;
static GCond message_handled_condition;
@@ -104,158 +104,158 @@ static GMutex message_handler_mutex;
GQuark
gs_auth_error_quark (void)
{
- static GQuark quark = 0;
- if (! quark)
- {
- quark = g_quark_from_static_string ("gs_auth_error");
- }
+ static GQuark quark = 0;
+ if (! quark)
+ {
+ quark = g_quark_from_static_string ("gs_auth_error");
+ }
- return quark;
+ return quark;
}
void
gs_auth_set_verbose (gboolean enabled)
{
- verbose_enabled = enabled;
+ verbose_enabled = enabled;
}
gboolean
gs_auth_get_verbose (void)
{
- return verbose_enabled;
+ return verbose_enabled;
}
static GSAuthMessageStyle
pam_style_to_gs_style (int pam_style)
{
- GSAuthMessageStyle style;
-
- switch (pam_style)
- {
- case PAM_PROMPT_ECHO_ON:
- style = GS_AUTH_MESSAGE_PROMPT_ECHO_ON;
- break;
- case PAM_PROMPT_ECHO_OFF:
- style = GS_AUTH_MESSAGE_PROMPT_ECHO_OFF;
- break;
- case PAM_ERROR_MSG:
- style = GS_AUTH_MESSAGE_ERROR_MSG;
- break;
- case PAM_TEXT_INFO:
- style = GS_AUTH_MESSAGE_TEXT_INFO;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- return style;
+ GSAuthMessageStyle style;
+
+ switch (pam_style)
+ {
+ case PAM_PROMPT_ECHO_ON:
+ style = GS_AUTH_MESSAGE_PROMPT_ECHO_ON;
+ break;
+ case PAM_PROMPT_ECHO_OFF:
+ style = GS_AUTH_MESSAGE_PROMPT_ECHO_OFF;
+ break;
+ case PAM_ERROR_MSG:
+ style = GS_AUTH_MESSAGE_ERROR_MSG;
+ break;
+ case PAM_TEXT_INFO:
+ style = GS_AUTH_MESSAGE_TEXT_INFO;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return style;
}
static gboolean
-auth_message_handler (GSAuthMessageStyle style,
- const char *msg,
- char **response,
- gpointer data)
+auth_message_handler (GSAuthMessageStyle style,
+ const char *msg,
+ char **response,
+ gpointer data)
{
- gboolean ret;
-
- ret = TRUE;
- *response = NULL;
-
- switch (style)
- {
- case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
- break;
- case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
- if (msg != NULL && g_str_has_prefix (msg, _("Password:")))
- {
- did_we_ask_for_password = TRUE;
- }
- break;
- case GS_AUTH_MESSAGE_ERROR_MSG:
- break;
- case GS_AUTH_MESSAGE_TEXT_INFO:
- break;
- default:
- g_assert_not_reached ();
- }
-
- return ret;
+ gboolean ret;
+
+ ret = TRUE;
+ *response = NULL;
+
+ switch (style)
+ {
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
+ break;
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
+ if (msg != NULL && g_str_has_prefix (msg, _("Password:")))
+ {
+ did_we_ask_for_password = TRUE;
+ }
+ break;
+ case GS_AUTH_MESSAGE_ERROR_MSG:
+ break;
+ case GS_AUTH_MESSAGE_TEXT_INFO:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ return ret;
}
static gboolean
gs_auth_queued_message_handler (GsAuthMessageHandlerData *data)
{
- gboolean res;
+ gboolean res;
- if (gs_auth_get_verbose ())
- {
- g_message ("Waiting for lock");
- }
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Waiting for lock");
+ }
- g_mutex_lock (&message_handler_mutex);
+ g_mutex_lock (&message_handler_mutex);
- if (gs_auth_get_verbose ())
- {
- g_message ("Waiting for response");
- }
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Waiting for response");
+ }
- res = data->closure->cb_func (data->style,
- data->msg,
- data->resp,
- data->closure->cb_data);
+ res = data->closure->cb_func (data->style,
+ data->msg,
+ data->resp,
+ data->closure->cb_data);
- data->should_interrupt_stack = res == FALSE;
+ data->should_interrupt_stack = res == FALSE;
- g_cond_signal (&message_handled_condition);
- g_mutex_unlock (&message_handler_mutex);
+ g_cond_signal (&message_handled_condition);
+ g_mutex_unlock (&message_handler_mutex);
- if (gs_auth_get_verbose ())
- {
- g_message ("Got response");
- }
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Got response");
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-gs_auth_run_message_handler (struct pam_closure *c,
- GSAuthMessageStyle style,
- const char *msg,
- char **resp)
+gs_auth_run_message_handler (struct pam_closure *c,
+ GSAuthMessageStyle style,
+ const char *msg,
+ char **resp)
{
- GsAuthMessageHandlerData data;
+ GsAuthMessageHandlerData data;
- data.closure = c;
- data.style = style;
- data.msg = msg;
- data.resp = resp;
- data.should_interrupt_stack = TRUE;
+ data.closure = c;
+ data.style = style;
+ data.msg = msg;
+ data.resp = resp;
+ data.should_interrupt_stack = TRUE;
- g_mutex_lock (&message_handler_mutex);
+ g_mutex_lock (&message_handler_mutex);
- /* Queue the callback in the gui (the main) thread
- */
- g_idle_add ((GSourceFunc) gs_auth_queued_message_handler, &data);
+ /* Queue the callback in the gui (the main) thread
+ */
+ g_idle_add ((GSourceFunc) gs_auth_queued_message_handler, &data);
- if (gs_auth_get_verbose ())
- {
- g_message ("Waiting for respose to message style %d: '%s'", style, msg);
- }
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Waiting for respose to message style %d: '%s'", style, msg);
+ }
- /* Wait for the response
- */
- g_cond_wait (&message_handled_condition,
- &message_handler_mutex);
- g_mutex_unlock (&message_handler_mutex);
+ /* Wait for the response
+ */
+ g_cond_wait (&message_handled_condition,
+ &message_handler_mutex);
+ g_mutex_unlock (&message_handler_mutex);
- if (gs_auth_get_verbose ())
- {
- g_message ("Got respose to message style %d: interrupt:%d", style, data.should_interrupt_stack);
- }
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Got respose to message style %d: interrupt:%d", style, data.should_interrupt_stack);
+ }
- return data.should_interrupt_stack == FALSE;
+ return data.should_interrupt_stack == FALSE;
}
static int
@@ -264,123 +264,123 @@ pam_conversation (int nmsgs,
struct pam_response **resp,
void *closure)
{
- int replies = 0;
- struct pam_response *reply = NULL;
- struct pam_closure *c = (struct pam_closure *) closure;
- gboolean res;
- int ret;
-
- reply = (struct pam_response *) calloc (nmsgs, sizeof (*reply));
-
- if (reply == NULL)
- {
- return PAM_CONV_ERR;
- }
-
- res = TRUE;
- ret = PAM_SUCCESS;
-
- for (replies = 0; replies < nmsgs && ret == PAM_SUCCESS; replies++)
- {
- GSAuthMessageStyle style;
- char *utf8_msg;
-
- style = pam_style_to_gs_style (msg [replies]->msg_style);
-
- utf8_msg = g_locale_to_utf8 (msg [replies]->msg,
- -1,
- NULL,
- NULL,
- NULL);
-
- /* if we couldn't convert text from locale then
- * assume utf-8 and hope for the best */
- if (utf8_msg == NULL)
- {
- char *p;
- char *q;
-
- utf8_msg = g_strdup (msg [replies]->msg);
-
- p = utf8_msg;
- while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q))
- {
- *q = '?';
- p = q + 1;
- }
- }
-
- /* handle message locally first */
- auth_message_handler (style,
- utf8_msg,
- &reply [replies].resp,
- NULL);
-
- if (c->cb_func != NULL)
- {
- if (gs_auth_get_verbose ())
- {
- g_message ("Handling message style %d: '%s'", style, utf8_msg);
- }
-
- /* blocks until the gui responds
- */
- res = gs_auth_run_message_handler (c,
- style,
- utf8_msg,
- &reply [replies].resp);
-
- if (gs_auth_get_verbose ())
- {
- g_message ("Msg handler returned %d", res);
- }
-
- /* If the handler returns FALSE - interrupt the PAM stack */
- if (res)
- {
- reply [replies].resp_retcode = PAM_SUCCESS;
- }
- else
- {
- int i;
- for (i = 0; i <= replies; i++)
- {
- free (reply [i].resp);
- }
- free (reply);
- reply = NULL;
- ret = PAM_CONV_ERR;
- }
- }
-
- g_free (utf8_msg);
- }
-
- *resp = reply;
-
- return ret;
+ int replies = 0;
+ struct pam_response *reply = NULL;
+ struct pam_closure *c = (struct pam_closure *) closure;
+ gboolean res;
+ int ret;
+
+ reply = (struct pam_response *) calloc (nmsgs, sizeof (*reply));
+
+ if (reply == NULL)
+ {
+ return PAM_CONV_ERR;
+ }
+
+ res = TRUE;
+ ret = PAM_SUCCESS;
+
+ for (replies = 0; replies < nmsgs && ret == PAM_SUCCESS; replies++)
+ {
+ GSAuthMessageStyle style;
+ char *utf8_msg;
+
+ style = pam_style_to_gs_style (msg [replies]->msg_style);
+
+ utf8_msg = g_locale_to_utf8 (msg [replies]->msg,
+ -1,
+ NULL,
+ NULL,
+ NULL);
+
+ /* if we couldn't convert text from locale then
+ * assume utf-8 and hope for the best */
+ if (utf8_msg == NULL)
+ {
+ char *p;
+ char *q;
+
+ utf8_msg = g_strdup (msg [replies]->msg);
+
+ p = utf8_msg;
+ while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q))
+ {
+ *q = '?';
+ p = q + 1;
+ }
+ }
+
+ /* handle message locally first */
+ auth_message_handler (style,
+ utf8_msg,
+ &reply [replies].resp,
+ NULL);
+
+ if (c->cb_func != NULL)
+ {
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Handling message style %d: '%s'", style, utf8_msg);
+ }
+
+ /* blocks until the gui responds
+ */
+ res = gs_auth_run_message_handler (c,
+ style,
+ utf8_msg,
+ &reply [replies].resp);
+
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("Msg handler returned %d", res);
+ }
+
+ /* If the handler returns FALSE - interrupt the PAM stack */
+ if (res)
+ {
+ reply [replies].resp_retcode = PAM_SUCCESS;
+ }
+ else
+ {
+ int i;
+ for (i = 0; i <= replies; i++)
+ {
+ free (reply [i].resp);
+ }
+ free (reply);
+ reply = NULL;
+ ret = PAM_CONV_ERR;
+ }
+ }
+
+ g_free (utf8_msg);
+ }
+
+ *resp = reply;
+
+ return ret;
}
static gboolean
close_pam_handle (int status)
{
- if (pam_handle != NULL)
- {
- int status2;
+ if (pam_handle != NULL)
+ {
+ int status2;
- status2 = pam_end (pam_handle, status);
- pam_handle = NULL;
+ status2 = pam_end (pam_handle, status);
+ pam_handle = NULL;
- if (gs_auth_get_verbose ())
- {
- g_message (" pam_end (...) ==> %d (%s)",
- status2,
- (status2 == PAM_SUCCESS ? "Success" : "Failure"));
- }
- }
+ if (gs_auth_get_verbose ())
+ {
+ g_message (" pam_end (...) ==> %d (%s)",
+ status2,
+ (status2 == PAM_SUCCESS ? "Success" : "Failure"));
+ }
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
@@ -389,444 +389,444 @@ create_pam_handle (const char *username,
struct pam_conv *conv,
int *status_code)
{
- int status;
- const char *service = PAM_SERVICE_NAME;
- char *disp;
- gboolean ret;
-
- if (pam_handle != NULL)
- {
- g_warning ("create_pam_handle: Stale pam handle around, cleaning up");
- close_pam_handle (PAM_SUCCESS);
- }
-
- /* init things */
- pam_handle = NULL;
- status = -1;
- disp = NULL;
- ret = TRUE;
-
- /* Initialize a PAM session for the user */
- if ((status = pam_start (service, username, conv, &pam_handle)) != PAM_SUCCESS)
- {
- pam_handle = NULL;
- g_warning (_("Unable to establish service %s: %s\n"),
- service,
- PAM_STRERROR (NULL, status));
-
- if (status_code != NULL)
- {
- *status_code = status;
- }
-
- ret = FALSE;
- goto out;
- }
-
- if (gs_auth_get_verbose ())
- {
- g_message ("pam_start (\"%s\", \"%s\", ...) ==> %d (%s)",
- service,
- username,
- status,
- PAM_STRERROR (pam_handle, status));
- }
-
- disp = g_strdup (display);
- if (disp == NULL)
- {
- disp = g_strdup (":0.0");
- }
-
- if ((status = pam_set_item (pam_handle, PAM_TTY, disp)) != PAM_SUCCESS)
- {
- g_warning (_("Can't set PAM_TTY=%s"), display);
-
- if (status_code != NULL)
- {
- *status_code = status;
- }
-
- ret = FALSE;
- goto out;
- }
-
- ret = TRUE;
- g_cond_init (&message_handled_condition);
- g_mutex_init (&message_handler_mutex);
+ int status;
+ const char *service = PAM_SERVICE_NAME;
+ char *disp;
+ gboolean ret;
+
+ if (pam_handle != NULL)
+ {
+ g_warning ("create_pam_handle: Stale pam handle around, cleaning up");
+ close_pam_handle (PAM_SUCCESS);
+ }
+
+ /* init things */
+ pam_handle = NULL;
+ status = -1;
+ disp = NULL;
+ ret = TRUE;
+
+ /* Initialize a PAM session for the user */
+ if ((status = pam_start (service, username, conv, &pam_handle)) != PAM_SUCCESS)
+ {
+ pam_handle = NULL;
+ g_warning (_("Unable to establish service %s: %s\n"),
+ service,
+ PAM_STRERROR (NULL, status));
+
+ if (status_code != NULL)
+ {
+ *status_code = status;
+ }
+
+ ret = FALSE;
+ goto out;
+ }
+
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("pam_start (\"%s\", \"%s\", ...) ==> %d (%s)",
+ service,
+ username,
+ status,
+ PAM_STRERROR (pam_handle, status));
+ }
+
+ disp = g_strdup (display);
+ if (disp == NULL)
+ {
+ disp = g_strdup (":0.0");
+ }
+
+ if ((status = pam_set_item (pam_handle, PAM_TTY, disp)) != PAM_SUCCESS)
+ {
+ g_warning (_("Can't set PAM_TTY=%s"), display);
+
+ if (status_code != NULL)
+ {
+ *status_code = status;
+ }
+
+ ret = FALSE;
+ goto out;
+ }
+
+ ret = TRUE;
+ g_cond_init (&message_handled_condition);
+ g_mutex_init (&message_handler_mutex);
out:
- if (status_code != NULL)
- {
- *status_code = status;
- }
+ if (status_code != NULL)
+ {
+ *status_code = status;
+ }
- g_free (disp);
+ g_free (disp);
- return ret;
+ return ret;
}
static void
set_pam_error (GError **error,
int status)
{
- if (status == PAM_AUTH_ERR || status == PAM_USER_UNKNOWN)
- {
- char *msg;
-
- if (did_we_ask_for_password)
- {
- msg = g_strdup (_("Incorrect password."));
- }
- else
- {
- msg = g_strdup (_("Authentication failed."));
- }
-
- g_set_error (error,
- GS_AUTH_ERROR,
- GS_AUTH_ERROR_AUTH_ERROR,
- "%s",
- msg);
- g_free (msg);
- }
- else if (status == PAM_PERM_DENIED)
- {
- g_set_error (error,
- GS_AUTH_ERROR,
- GS_AUTH_ERROR_AUTH_DENIED,
- "%s",
- _("Not permitted to gain access at this time."));
- }
- else if (status == PAM_ACCT_EXPIRED)
- {
- g_set_error (error,
- GS_AUTH_ERROR,
- GS_AUTH_ERROR_AUTH_DENIED,
- "%s",
- _("No longer permitted to access the system."));
- }
+ if (status == PAM_AUTH_ERR || status == PAM_USER_UNKNOWN)
+ {
+ char *msg;
+
+ if (did_we_ask_for_password)
+ {
+ msg = g_strdup (_("Incorrect password."));
+ }
+ else
+ {
+ msg = g_strdup (_("Authentication failed."));
+ }
+
+ g_set_error (error,
+ GS_AUTH_ERROR,
+ GS_AUTH_ERROR_AUTH_ERROR,
+ "%s",
+ msg);
+ g_free (msg);
+ }
+ else if (status == PAM_PERM_DENIED)
+ {
+ g_set_error (error,
+ GS_AUTH_ERROR,
+ GS_AUTH_ERROR_AUTH_DENIED,
+ "%s",
+ _("Not permitted to gain access at this time."));
+ }
+ else if (status == PAM_ACCT_EXPIRED)
+ {
+ g_set_error (error,
+ GS_AUTH_ERROR,
+ GS_AUTH_ERROR_AUTH_DENIED,
+ "%s",
+ _("No longer permitted to access the system."));
+ }
}
static int
gs_auth_thread_func (int auth_operation_fd)
{
- static const int flags = 0;
- int status;
- int status2;
- struct timespec timeout;
- sigset_t set;
- const void *p;
-
- timeout.tv_sec = 0;
- timeout.tv_nsec = 1;
-
- set = block_sigchld ();
-
- status = pam_authenticate (pam_handle, flags);
-
- sigtimedwait (&set, NULL, &timeout);
- unblock_sigchld ();
-
- if (gs_auth_get_verbose ())
- {
- g_message (" pam_authenticate (...) ==> %d (%s)",
- status,
- PAM_STRERROR (pam_handle, status));
- }
-
- if (status != PAM_SUCCESS)
- {
- goto done;
- }
-
- if ((status = pam_get_item (pam_handle, PAM_USER, &p)) != PAM_SUCCESS)
- {
- /* is not really an auth problem, but it will
- pretty much look as such, it shouldn't really
- happen */
- goto done;
- }
-
- /* We don't actually care if the account modules fail or succeed,
- * but we need to run them anyway because certain pam modules
- * depend on side effects of the account modules getting run.
- */
- status2 = pam_acct_mgmt (pam_handle, 0);
-
- if (gs_auth_get_verbose ())
- {
- g_message ("pam_acct_mgmt (...) ==> %d (%s)\n",
- status2,
- PAM_STRERROR (pam_handle, status2));
- }
-
- /* FIXME: should we handle these? */
- switch (status2)
- {
- case PAM_SUCCESS:
- break;
- case PAM_NEW_AUTHTOK_REQD:
- break;
- case PAM_AUTHINFO_UNAVAIL:
- break;
- case PAM_ACCT_EXPIRED:
- break;
- case PAM_PERM_DENIED:
- break;
- default :
- break;
- }
-
- /* Each time we successfully authenticate, refresh credentials,
- for Kerberos/AFS/DCE/etc. If this fails, just ignore that
- failure and blunder along; it shouldn't matter.
-
- Note: this used to be PAM_REFRESH_CRED instead of
- PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss at ee.washington.edu>
- says that the Linux PAM library ignores that one, and only refreshes
- credentials when using PAM_REINITIALIZE_CRED.
- */
- status2 = pam_setcred (pam_handle, PAM_REINITIALIZE_CRED);
- if (gs_auth_get_verbose ())
- {
- g_message (" pam_setcred (...) ==> %d (%s)",
- status2,
- PAM_STRERROR (pam_handle, status2));
- }
+ static const int flags = 0;
+ int status;
+ int status2;
+ struct timespec timeout;
+ sigset_t set;
+ const void *p;
+
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 1;
+
+ set = block_sigchld ();
+
+ status = pam_authenticate (pam_handle, flags);
+
+ sigtimedwait (&set, NULL, &timeout);
+ unblock_sigchld ();
+
+ if (gs_auth_get_verbose ())
+ {
+ g_message (" pam_authenticate (...) ==> %d (%s)",
+ status,
+ PAM_STRERROR (pam_handle, status));
+ }
+
+ if (status != PAM_SUCCESS)
+ {
+ goto done;
+ }
+
+ if ((status = pam_get_item (pam_handle, PAM_USER, &p)) != PAM_SUCCESS)
+ {
+ /* is not really an auth problem, but it will
+ pretty much look as such, it shouldn't really
+ happen */
+ goto done;
+ }
+
+ /* We don't actually care if the account modules fail or succeed,
+ * but we need to run them anyway because certain pam modules
+ * depend on side effects of the account modules getting run.
+ */
+ status2 = pam_acct_mgmt (pam_handle, 0);
+
+ if (gs_auth_get_verbose ())
+ {
+ g_message ("pam_acct_mgmt (...) ==> %d (%s)\n",
+ status2,
+ PAM_STRERROR (pam_handle, status2));
+ }
+
+ /* FIXME: should we handle these? */
+ switch (status2)
+ {
+ case PAM_SUCCESS:
+ break;
+ case PAM_NEW_AUTHTOK_REQD:
+ break;
+ case PAM_AUTHINFO_UNAVAIL:
+ break;
+ case PAM_ACCT_EXPIRED:
+ break;
+ case PAM_PERM_DENIED:
+ break;
+ default :
+ break;
+ }
+
+ /* Each time we successfully authenticate, refresh credentials,
+ for Kerberos/AFS/DCE/etc. If this fails, just ignore that
+ failure and blunder along; it shouldn't matter.
+
+ Note: this used to be PAM_REFRESH_CRED instead of
+ PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss at ee.washington.edu>
+ says that the Linux PAM library ignores that one, and only refreshes
+ credentials when using PAM_REINITIALIZE_CRED.
+ */
+ status2 = pam_setcred (pam_handle, PAM_REINITIALIZE_CRED);
+ if (gs_auth_get_verbose ())
+ {
+ g_message (" pam_setcred (...) ==> %d (%s)",
+ status2,
+ PAM_STRERROR (pam_handle, status2));
+ }
done:
- /* we're done, close the fd and wake up the main
- * loop
- */
- close (auth_operation_fd);
+ /* we're done, close the fd and wake up the main
+ * loop
+ */
+ close (auth_operation_fd);
- return status;
+ return status;
}
static gboolean
-gs_auth_loop_quit (GIOChannel *source,
- GIOCondition condition,
- gboolean *thread_done)
+gs_auth_loop_quit (GIOChannel *source,
+ GIOCondition condition,
+ gboolean *thread_done)
{
- *thread_done = TRUE;
- gtk_main_quit ();
- return FALSE;
+ *thread_done = TRUE;
+ gtk_main_quit ();
+ return FALSE;
}
static gboolean
gs_auth_pam_verify_user (pam_handle_t *handle,
int *status)
{
- GThread *auth_thread;
- GIOChannel *channel;
- guint watch_id;
- int auth_operation_fds[2];
- int auth_status;
- gboolean thread_done;
-
- channel = NULL;
- watch_id = 0;
- auth_status = PAM_AUTH_ERR;
-
- /* This pipe gives us a set of fds we can hook into
- * the event loop to be notified when our helper thread
- * is ready to be reaped.
- */
- if (pipe (auth_operation_fds) < 0)
- {
- goto out;
- }
-
- if (fcntl (auth_operation_fds[0], F_SETFD, FD_CLOEXEC) < 0)
- {
- close (auth_operation_fds[0]);
- close (auth_operation_fds[1]);
- goto out;
- }
-
- if (fcntl (auth_operation_fds[1], F_SETFD, FD_CLOEXEC) < 0)
- {
- close (auth_operation_fds[0]);
- close (auth_operation_fds[1]);
- goto out;
- }
-
- channel = g_io_channel_unix_new (auth_operation_fds[0]);
-
- /* we use a recursive main loop to process ui events
- * while we wait on a thread to handle the blocking parts
- * of pam authentication.
- */
- thread_done = FALSE;
- watch_id = g_io_add_watch (channel, G_IO_ERR | G_IO_HUP,
- (GIOFunc) gs_auth_loop_quit, &thread_done);
-
- auth_thread = g_thread_new ("auththread",
- (GThreadFunc) gs_auth_thread_func,
- GINT_TO_POINTER (auth_operation_fds[1]));
-
- if (auth_thread == NULL)
- {
- goto out;
- }
-
- gtk_main ();
-
- /* if the event loop was quit before the thread is done then we can't
- * reap the thread without blocking on it finishing. The
- * thread may not ever finish though if the pam module is blocking.
- *
- * The only time the event loop is going to stop when the thread isn't
- * done, however, is if the dialog quits early (from, e.g., "cancel"),
- * so we can just exit. An alternative option would be to switch to
- * using pthreads directly and calling pthread_cancel.
- */
- if (!thread_done)
- {
- raise (SIGTERM);
- }
-
- auth_status = GPOINTER_TO_INT (g_thread_join (auth_thread));
+ GThread *auth_thread;
+ GIOChannel *channel;
+ guint watch_id;
+ int auth_operation_fds[2];
+ int auth_status;
+ gboolean thread_done;
+
+ channel = NULL;
+ watch_id = 0;
+ auth_status = PAM_AUTH_ERR;
+
+ /* This pipe gives us a set of fds we can hook into
+ * the event loop to be notified when our helper thread
+ * is ready to be reaped.
+ */
+ if (pipe (auth_operation_fds) < 0)
+ {
+ goto out;
+ }
+
+ if (fcntl (auth_operation_fds[0], F_SETFD, FD_CLOEXEC) < 0)
+ {
+ close (auth_operation_fds[0]);
+ close (auth_operation_fds[1]);
+ goto out;
+ }
+
+ if (fcntl (auth_operation_fds[1], F_SETFD, FD_CLOEXEC) < 0)
+ {
+ close (auth_operation_fds[0]);
+ close (auth_operation_fds[1]);
+ goto out;
+ }
+
+ channel = g_io_channel_unix_new (auth_operation_fds[0]);
+
+ /* we use a recursive main loop to process ui events
+ * while we wait on a thread to handle the blocking parts
+ * of pam authentication.
+ */
+ thread_done = FALSE;
+ watch_id = g_io_add_watch (channel, G_IO_ERR | G_IO_HUP,
+ (GIOFunc) gs_auth_loop_quit, &thread_done);
+
+ auth_thread = g_thread_new ("auththread",
+ (GThreadFunc) gs_auth_thread_func,
+ GINT_TO_POINTER (auth_operation_fds[1]));
+
+ if (auth_thread == NULL)
+ {
+ goto out;
+ }
+
+ gtk_main ();
+
+ /* if the event loop was quit before the thread is done then we can't
+ * reap the thread without blocking on it finishing. The
+ * thread may not ever finish though if the pam module is blocking.
+ *
+ * The only time the event loop is going to stop when the thread isn't
+ * done, however, is if the dialog quits early (from, e.g., "cancel"),
+ * so we can just exit. An alternative option would be to switch to
+ * using pthreads directly and calling pthread_cancel.
+ */
+ if (!thread_done)
+ {
+ raise (SIGTERM);
+ }
+
+ auth_status = GPOINTER_TO_INT (g_thread_join (auth_thread));
out:
- if (watch_id != 0)
- {
- //g_source_remove (watch_id);
- watch_id = 0;
- }
-
- if (channel != NULL)
- {
- g_io_channel_unref (channel);
- }
-
- if (status)
- {
- *status = auth_status;
- }
-
- return auth_status == PAM_SUCCESS;
+ if (watch_id != 0)
+ {
+ //g_source_remove (watch_id);
+ watch_id = 0;
+ }
+
+ if (channel != NULL)
+ {
+ g_io_channel_unref (channel);
+ }
+
+ if (status)
+ {
+ *status = auth_status;
+ }
+
+ return auth_status == PAM_SUCCESS;
}
gboolean
-gs_auth_verify_user (const char *username,
- const char *display,
- GSAuthMessageFunc func,
- gpointer data,
- GError **error)
+gs_auth_verify_user (const char *username,
+ const char *display,
+ GSAuthMessageFunc func,
+ gpointer data,
+ GError **error)
{
- int status = -1;
- struct pam_conv conv;
- struct pam_closure c;
- struct passwd *pwent;
+ int status = -1;
+ struct pam_conv conv;
+ struct pam_closure c;
+ struct passwd *pwent;
- pwent = getpwnam (username);
- if (pwent == NULL)
- {
- return FALSE;
- }
+ pwent = getpwnam (username);
+ if (pwent == NULL)
+ {
+ return FALSE;
+ }
- c.username = username;
- c.cb_func = func;
- c.cb_data = data;
+ c.username = username;
+ c.cb_func = func;
+ c.cb_data = data;
- conv.conv = &pam_conversation;
- conv.appdata_ptr = (void *) &c;
+ conv.conv = &pam_conversation;
+ conv.appdata_ptr = (void *) &c;
- /* Initialize PAM. */
- create_pam_handle (username, display, &conv, &status);
- if (status != PAM_SUCCESS)
- {
- goto done;
- }
+ /* Initialize PAM. */
+ create_pam_handle (username, display, &conv, &status);
+ if (status != PAM_SUCCESS)
+ {
+ goto done;
+ }
- pam_set_item (pam_handle, PAM_USER_PROMPT, _("Username:"));
+ pam_set_item (pam_handle, PAM_USER_PROMPT, _("Username:"));
- PAM_NO_DELAY(pam_handle);
+ PAM_NO_DELAY(pam_handle);
- did_we_ask_for_password = FALSE;
- if (! gs_auth_pam_verify_user (pam_handle, &status))
- {
- goto done;
- }
+ did_we_ask_for_password = FALSE;
+ if (! gs_auth_pam_verify_user (pam_handle, &status))
+ {
+ goto done;
+ }
done:
- if (status != PAM_SUCCESS)
- {
- set_pam_error (error, status);
- }
+ if (status != PAM_SUCCESS)
+ {
+ set_pam_error (error, status);
+ }
- close_pam_handle (status);
+ close_pam_handle (status);
- return (status == PAM_SUCCESS ? TRUE : FALSE);
+ return (status == PAM_SUCCESS ? TRUE : FALSE);
}
gboolean
gs_auth_init (void)
{
- return TRUE;
+ return TRUE;
}
gboolean
gs_auth_priv_init (void)
{
- /* We have nothing to do at init-time.
- However, we might as well do some error checking.
- If "/etc/pam.d" exists and is a directory, but "/etc/pam.d/xlock"
- does not exist, warn that PAM probably isn't going to work.
-
- This is a priv-init instead of a non-priv init in case the directory
- is unreadable or something (don't know if that actually happens.)
- */
- const char dir [] = "/etc/pam.d";
- const char file [] = "/etc/pam.d/" PAM_SERVICE_NAME;
- const char file2 [] = "/etc/pam.conf";
- struct stat st;
-
- if (g_stat (dir, &st) == 0 && st.st_mode & S_IFDIR)
- {
- if (g_stat (file, &st) != 0)
- {
- g_warning ("%s does not exist.\n"
- "Authentication via PAM is unlikely to work.",
- file);
- }
- }
- else if (g_stat (file2, &st) == 0)
- {
- FILE *f = g_fopen (file2, "r");
- if (f)
- {
- gboolean ok = FALSE;
- char buf[255];
- while (fgets (buf, sizeof(buf), f))
- {
- if (strstr (buf, PAM_SERVICE_NAME))
- {
- ok = TRUE;
- break;
- }
- }
-
- fclose (f);
- if (!ok)
- {
- g_warning ("%s does not list the `%s' service.\n"
- "Authentication via PAM is unlikely to work.",
- file2, PAM_SERVICE_NAME);
- }
- }
- /* else warn about file2 existing but being unreadable? */
- }
- else
- {
- g_warning ("Neither %s nor %s exist.\n"
- "Authentication via PAM is unlikely to work.",
- file2, file);
- }
-
- /* Return true anyway, just in case. */
- return TRUE;
+ /* We have nothing to do at init-time.
+ However, we might as well do some error checking.
+ If "/etc/pam.d" exists and is a directory, but "/etc/pam.d/xlock"
+ does not exist, warn that PAM probably isn't going to work.
+
+ This is a priv-init instead of a non-priv init in case the directory
+ is unreadable or something (don't know if that actually happens.)
+ */
+ const char dir [] = "/etc/pam.d";
+ const char file [] = "/etc/pam.d/" PAM_SERVICE_NAME;
+ const char file2 [] = "/etc/pam.conf";
+ struct stat st;
+
+ if (g_stat (dir, &st) == 0 && st.st_mode & S_IFDIR)
+ {
+ if (g_stat (file, &st) != 0)
+ {
+ g_warning ("%s does not exist.\n"
+ "Authentication via PAM is unlikely to work.",
+ file);
+ }
+ }
+ else if (g_stat (file2, &st) == 0)
+ {
+ FILE *f = g_fopen (file2, "r");
+ if (f)
+ {
+ gboolean ok = FALSE;
+ char buf[255];
+ while (fgets (buf, sizeof(buf), f))
+ {
+ if (strstr (buf, PAM_SERVICE_NAME))
+ {
+ ok = TRUE;
+ break;
+ }
+ }
+
+ fclose (f);
+ if (!ok)
+ {
+ g_warning ("%s does not list the `%s' service.\n"
+ "Authentication via PAM is unlikely to work.",
+ file2, PAM_SERVICE_NAME);
+ }
+ }
+ /* else warn about file2 existing but being unreadable? */
+ }
+ else
+ {
+ g_warning ("Neither %s nor %s exist.\n"
+ "Authentication via PAM is unlikely to work.",
+ file2, file);
+ }
+
+ /* Return true anyway, just in case. */
+ return TRUE;
}
diff --git a/src/gs-auth-pwent.c b/src/gs-auth-pwent.c
index 7237412..64d616b 100644
--- a/src/gs-auth-pwent.c
+++ b/src/gs-auth-pwent.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (c) 1993-1998 Jamie Zawinski <jwz at jwz.org>
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
@@ -47,7 +47,7 @@
#include <glib.h>
#include <libxfce4util/libxfce4util.h>
-#if defined(HAVE_SHADOW_PASSWD) /* passwds live in /etc/shadow */
+#if defined(HAVE_SHADOW_PASSWD) /* passwds live in /etc/shadow */
# include <shadow.h>
# define PWTYPE struct spwd *
@@ -95,96 +95,96 @@ static char *encrypted_user_passwd = NULL;
GQuark
gs_auth_error_quark (void)
{
- static GQuark quark = 0;
- if (! quark)
- {
- quark = g_quark_from_static_string ("gs_auth_error");
- }
+ static GQuark quark = 0;
+ if (! quark)
+ {
+ quark = g_quark_from_static_string ("gs_auth_error");
+ }
- return quark;
+ return quark;
}
void
gs_auth_set_verbose (gboolean enabled)
{
- verbose_enabled = enabled;
+ verbose_enabled = enabled;
}
gboolean
gs_auth_get_verbose (void)
{
- return verbose_enabled;
+ return verbose_enabled;
}
static gboolean
passwd_known (const char *pw)
{
- return (pw &&
- pw[0] != '*' && /* This would be sensible... */
- strlen (pw) > 4); /* ...but this is what Solaris does. */
+ return (pw &&
+ pw[0] != '*' && /* This would be sensible... */
+ strlen (pw) > 4); /* ...but this is what Solaris does. */
}
static char *
get_encrypted_passwd (const char *user)
{
- char *result = NULL;
+ char *result = NULL;
#ifdef PWTYPE
- if (user && *user && !result)
- {
- /* First check the shadow passwords. */
- PWTYPE p = GETPW ((char *) user);
- if (p && passwd_known (p->PWPSLOT))
- {
- result = g_strdup (p->PWPSLOT);
- }
- }
+ if (user && *user && !result)
+ {
+ /* First check the shadow passwords. */
+ PWTYPE p = GETPW ((char *) user);
+ if (p && passwd_known (p->PWPSLOT))
+ {
+ result = g_strdup (p->PWPSLOT);
+ }
+ }
#endif /* PWTYPE */
- if (user && *user && !result)
- {
- /* Check non-shadow passwords too. */
- struct passwd *p = getpwnam (user);
- if (p && passwd_known (p->pw_passwd))
- {
- result = g_strdup (p->pw_passwd);
- }
- }
-
- /* The manual for passwd(4) on HPUX 10.10 says:
-
- Password aging is put in effect for a particular user if his
- encrypted password in the password file is followed by a comma and
- a nonnull string of characters from the above alphabet. This
- string defines the "age" needed to implement password aging.
-
- So this means that passwd->pw_passwd isn't simply a string of cyphertext,
- it might have trailing junk. So, if there is a comma in the string, and
- that comma is beyond position 13, terminate the string before the comma.
- */
- if (result && strlen (result) > 13)
- {
- char *s = strchr (result + 13, ',');
- if (s)
- {
- *s = 0;
- }
- }
+ if (user && *user && !result)
+ {
+ /* Check non-shadow passwords too. */
+ struct passwd *p = getpwnam (user);
+ if (p && passwd_known (p->pw_passwd))
+ {
+ result = g_strdup (p->pw_passwd);
+ }
+ }
+
+ /* The manual for passwd(4) on HPUX 10.10 says:
+
+ Password aging is put in effect for a particular user if his
+ encrypted password in the password file is followed by a comma and
+ a nonnull string of characters from the above alphabet. This
+ string defines the "age" needed to implement password aging.
+
+ So this means that passwd->pw_passwd isn't simply a string of cyphertext,
+ it might have trailing junk. So, if there is a comma in the string, and
+ that comma is beyond position 13, terminate the string before the comma.
+ */
+ if (result && strlen (result) > 13)
+ {
+ char *s = strchr (result + 13, ',');
+ if (s)
+ {
+ *s = 0;
+ }
+ }
#if !defined(HAVE_PAM) && !defined(HAVE_BSDAUTH)
- /* We only issue this warning if not compiled with support for PAM,
- or bsd_auth(3). If we're using PAM, it's not unheard of that
- normal pwent passwords would be unavailable. */
+ /* We only issue this warning if not compiled with support for PAM,
+ or bsd_auth(3). If we're using PAM, it's not unheard of that
+ normal pwent passwords would be unavailable. */
- if (!result)
- {
- g_warning ("Couldn't get password of \"%s\"",
- (user ? user : "(null)"));
- }
+ if (!result)
+ {
+ g_warning ("Couldn't get password of \"%s\"",
+ (user ? user : "(null)"));
+ }
#endif /* !HAVE_PAM */
- return result;
+ return result;
}
/* This has to be called before we've changed our effective user ID,
@@ -196,96 +196,96 @@ get_encrypted_passwd (const char *user)
gboolean
gs_auth_priv_init (void)
{
- const char *u;
+ const char *u;
- u = g_get_user_name ();
+ u = g_get_user_name ();
- encrypted_user_passwd = get_encrypted_passwd (u);
+ encrypted_user_passwd = get_encrypted_passwd (u);
- if (encrypted_user_passwd != NULL)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
+ if (encrypted_user_passwd != NULL)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
gboolean
gs_auth_init (void)
{
- if (encrypted_user_passwd != NULL)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
+ if (encrypted_user_passwd != NULL)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
static gboolean
passwds_match (const char *cleartext,
const char *ciphertext)
{
- char *s = NULL; /* note that on some systems, crypt() may return null */
+ char *s = NULL; /* note that on some systems, crypt() may return null */
- s = (char *) crypt (cleartext, ciphertext);
- if (s && !strcmp (s, ciphertext))
- {
- return TRUE;
- }
+ s = (char *) crypt (cleartext, ciphertext);
+ if (s && !strcmp (s, ciphertext))
+ {
+ return TRUE;
+ }
#ifdef HAVE_BIGCRYPT
- /* There seems to be no way to tell at runtime if an HP machine is in
- "trusted" mode, and thereby, which of crypt() or bigcrypt() we should
- be calling to compare passwords. So call them both, and see which
- one works. */
+ /* There seems to be no way to tell at runtime if an HP machine is in
+ "trusted" mode, and thereby, which of crypt() or bigcrypt() we should
+ be calling to compare passwords. So call them both, and see which
+ one works. */
- s = (char *) bigcrypt (cleartext, ciphertext);
- if (s && !strcmp (s, ciphertext))
- {
- return TRUE;
- }
+ s = (char *) bigcrypt (cleartext, ciphertext);
+ if (s && !strcmp (s, ciphertext))
+ {
+ return TRUE;
+ }
#endif /* HAVE_BIGCRYPT */
- return FALSE;
+ return FALSE;
}
gboolean
-gs_auth_verify_user (const char *username,
- const char *display,
- GSAuthMessageFunc func,
- gpointer data,
- GError **error)
+gs_auth_verify_user (const char *username,
+ const char *display,
+ GSAuthMessageFunc func,
+ gpointer data,
+ GError **error)
{
- char *password;
-
- password = NULL;
-
- /* ask for the password for user */
- if (func != NULL)
- {
- func (GS_AUTH_MESSAGE_PROMPT_ECHO_OFF,
- "Password: ",
- &password,
- data);
- }
-
- if (password == NULL)
- {
- return FALSE;
- }
-
- if (encrypted_user_passwd && passwds_match (password, encrypted_user_passwd))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
+ char *password;
+
+ password = NULL;
+
+ /* ask for the password for user */
+ if (func != NULL)
+ {
+ func (GS_AUTH_MESSAGE_PROMPT_ECHO_OFF,
+ "Password: ",
+ &password,
+ data);
+ }
+
+ if (password == NULL)
+ {
+ return FALSE;
+ }
+
+ if (encrypted_user_passwd && passwds_match (password, encrypted_user_passwd))
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
diff --git a/src/gs-auth.h b/src/gs-auth.h
index 480a56a..954b377 100644
--- a/src/gs-auth.h
+++ b/src/gs-auth.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
*
@@ -42,10 +42,10 @@ typedef enum
GS_AUTH_ERROR_AUTH_DENIED
} GSAuthError;
-typedef gboolean (* GSAuthMessageFunc) (GSAuthMessageStyle style,
- const char *msg,
- char **response,
- gpointer data);
+typedef gboolean (* GSAuthMessageFunc) (GSAuthMessageStyle style,
+ const char *msg,
+ char **response,
+ gpointer data);
#define GS_AUTH_ERROR gs_auth_error_quark ()
@@ -56,11 +56,11 @@ gboolean gs_auth_get_verbose (void);
gboolean gs_auth_priv_init (void);
gboolean gs_auth_init (void);
-gboolean gs_auth_verify_user (const char *username,
- const char *display,
- GSAuthMessageFunc func,
- gpointer data,
- GError **error);
+gboolean gs_auth_verify_user (const char *username,
+ const char *display,
+ GSAuthMessageFunc func,
+ gpointer data,
+ GError **error);
G_END_DECLS
diff --git a/src/gs-debug.c b/src/gs-debug.c
index 23ced42..a4a0f5a 100644
--- a/src/gs-debug.c
+++ b/src/gs-debug.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -47,83 +47,83 @@ gs_debug_real (const char *func,
const int line,
const char *format, ...)
{
- va_list args;
- char buffer [1025];
- char *str_time;
- time_t the_time;
+ va_list args;
+ char buffer [1025];
+ char *str_time;
+ time_t the_time;
- if (debugging == FALSE)
- return;
+ if (debugging == FALSE)
+ return;
- va_start (args, format);
+ va_start (args, format);
- g_vsnprintf (buffer, 1024, format, args);
+ g_vsnprintf (buffer, 1024, format, args);
- va_end (args);
+ va_end (args);
- time (&the_time);
- str_time = g_new0 (char, 255);
- strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
+ time (&the_time);
+ str_time = g_new0 (char, 255);
+ strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
- fprintf ((debug_out ? debug_out : stderr),
- "[%s] %s:%d (%s):\t %s\n",
- func, file, line, str_time, buffer);
+ fprintf ((debug_out ? debug_out : stderr),
+ "[%s] %s:%d (%s):\t %s\n",
+ func, file, line, str_time, buffer);
- if (debug_out)
- fflush (debug_out);
+ if (debug_out)
+ fflush (debug_out);
- g_free (str_time);
+ g_free (str_time);
}
gboolean
gs_debug_enabled (void)
{
- return debugging;
+ return debugging;
}
void
gs_debug_init (gboolean debug,
gboolean to_file)
{
- /* return if already initialized */
- if (debugging == TRUE)
- {
- return;
- }
+ /* return if already initialized */
+ if (debugging == TRUE)
+ {
+ return;
+ }
- debugging = debug;
+ debugging = debug;
- if (debug && to_file)
- {
- const char path [50] = "xfce4_screensaver_debug_XXXXXX";
- int fd;
+ if (debug && to_file)
+ {
+ const char path [50] = "xfce4_screensaver_debug_XXXXXX";
+ int fd;
- fd = g_file_open_tmp (path, NULL, NULL);
+ fd = g_file_open_tmp (path, NULL, NULL);
- if (fd >= 0)
- {
- debug_out = fdopen (fd, "a");
- }
- }
+ if (fd >= 0)
+ {
+ debug_out = fdopen (fd, "a");
+ }
+ }
- gs_debug ("Debugging %s", (debug) ? "enabled" : "disabled");
+ gs_debug ("Debugging %s", (debug) ? "enabled" : "disabled");
}
void
gs_debug_shutdown (void)
{
- if (! debugging)
- return;
+ if (! debugging)
+ return;
- gs_debug ("Shutting down debugging");
+ gs_debug ("Shutting down debugging");
- debugging = FALSE;
+ debugging = FALSE;
- if (debug_out != NULL)
- {
- fclose (debug_out);
- debug_out = NULL;
- }
+ if (debug_out != NULL)
+ {
+ fclose (debug_out);
+ debug_out = NULL;
+ }
}
void
@@ -132,32 +132,32 @@ _gs_profile_log (const char *func,
const char *format,
...)
{
- va_list args;
- char *str;
- char *formatted;
-
- if (format == NULL)
- {
- formatted = g_strdup ("");
- }
- else
- {
- va_start (args, format);
- formatted = g_strdup_vprintf (format, args);
- va_end (args);
- }
-
- if (func != NULL)
- {
- str = g_strdup_printf ("MARK: %s %s: %s %s", g_get_prgname(), func, note ? note : "", formatted);
- }
- else
- {
- str = g_strdup_printf ("MARK: %s: %s %s", g_get_prgname(), note ? note : "", formatted);
- }
-
- g_free (formatted);
-
- g_access (str, F_OK);
- g_free (str);
+ va_list args;
+ char *str;
+ char *formatted;
+
+ if (format == NULL)
+ {
+ formatted = g_strdup ("");
+ }
+ else
+ {
+ va_start (args, format);
+ formatted = g_strdup_vprintf (format, args);
+ va_end (args);
+ }
+
+ if (func != NULL)
+ {
+ str = g_strdup_printf ("MARK: %s %s: %s %s", g_get_prgname(), func, note ? note : "", formatted);
+ }
+ else
+ {
+ str = g_strdup_printf ("MARK: %s: %s %s", g_get_prgname(), note ? note : "", formatted);
+ }
+
+ g_free (formatted);
+
+ g_access (str, F_OK);
+ g_free (str);
}
diff --git a/src/gs-debug.h b/src/gs-debug.h
index 7bddd51..d0b12b7 100644
--- a/src/gs-debug.h
+++ b/src/gs-debug.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -61,10 +61,10 @@ void gs_debug_real (const char *func,
#define gs_profile_msg(...)
#endif
-void _gs_profile_log (const char *func,
- const char *note,
- const char *format,
- ...) G_GNUC_PRINTF (3, 4);
+void _gs_profile_log (const char *func,
+ const char *note,
+ const char *format,
+ ...) G_GNUC_PRINTF (3, 4);
G_END_DECLS
diff --git a/src/gs-fade.c b/src/gs-fade.c
index 574c7fa..db68f25 100644
--- a/src/gs-fade.c
+++ b/src/gs-fade.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2009 William Jon McCann <mccann at jhu.edu>
* Copyright (C) 2009 Red Hat, Inc.
@@ -42,7 +42,6 @@
#include "gs-debug.h"
-
#include "xfce-rr.h"
/* XFree86 4.x+ Gamma fading */
@@ -58,49 +57,49 @@
static void gs_fade_class_init (GSFadeClass *klass);
static void gs_fade_init (GSFade *fade);
-static void gs_fade_finalize (GObject *object);
+static void gs_fade_finalize (GObject *object);
struct GSGammaInfo
{
- int size;
- unsigned short *r;
- unsigned short *g;
- unsigned short *b;
+ int size;
+ unsigned short *r;
+ unsigned short *g;
+ unsigned short *b;
};
struct GSFadeScreenPrivate
{
- int fade_type;
- int num_ramps;
- /* one per crtc in randr mode */
- struct GSGammaInfo *info;
- /* one per screen in theory */
- XfceRRScreen *rrscreen;
+ int fade_type;
+ int num_ramps;
+ /* one per crtc in randr mode */
+ struct GSGammaInfo *info;
+ /* one per screen in theory */
+ XfceRRScreen *rrscreen;
#ifdef HAVE_XF86VMODE_GAMMA
- /* one per screen also */
- XF86VidModeGamma vmg;
+ /* one per screen also */
+ XF86VidModeGamma vmg;
#endif /* HAVE_XF86VMODE_GAMMA */
- gboolean (*fade_setup) (GSFade *fade);
- gboolean (*fade_set_alpha_gamma) (GSFade *fade,
- gdouble alpha);
- void (*fade_finish) (GSFade *fade);
+ gboolean (*fade_setup) (GSFade *fade);
+ gboolean (*fade_set_alpha_gamma) (GSFade *fade,
+ gdouble alpha);
+ void (*fade_finish) (GSFade *fade);
};
struct GSFadePrivate
{
- guint enabled : 1;
- guint active : 1;
+ guint enabled : 1;
+ guint active : 1;
- guint timeout;
+ guint timeout;
- guint step;
- guint num_steps;
- guint timer_id;
+ guint step;
+ guint num_steps;
+ guint timer_id;
- gdouble alpha_per_iter;
- gdouble current_alpha;
+ gdouble alpha_per_iter;
+ gdouble current_alpha;
- struct GSFadeScreenPrivate screen_priv;
+ struct GSFadeScreenPrivate screen_priv;
};
enum
@@ -137,9 +136,9 @@ static int
ignore_all_errors_ehandler (Display *dpy,
XErrorEvent *error)
{
- error_handler_hit = TRUE;
+ error_handler_hit = TRUE;
- return 0;
+ return 0;
}
static Bool
@@ -147,103 +146,103 @@ safe_XF86VidModeQueryVersion (Display *dpy,
int *majP,
int *minP)
{
- Bool result;
- XErrorHandler old_handler;
+ Bool result;
+ XErrorHandler old_handler;
- XSync (dpy, False);
- error_handler_hit = FALSE;
- old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
+ XSync (dpy, False);
+ error_handler_hit = FALSE;
+ old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
- result = XF86VidModeQueryVersion (dpy, majP, minP);
+ result = XF86VidModeQueryVersion (dpy, majP, minP);
- XSync (dpy, False);
- XSetErrorHandler (old_handler);
- XSync (dpy, False);
+ XSync (dpy, False);
+ XSetErrorHandler (old_handler);
+ XSync (dpy, False);
- return (error_handler_hit
- ? False
- : result);
+ return (error_handler_hit
+ ? False
+ : result);
}
static gboolean
-xf86_whack_gamma (int screen,
+xf86_whack_gamma (int screen,
struct GSFadeScreenPrivate *screen_priv,
- float ratio)
-{
- Bool status;
- struct GSGammaInfo *gamma_info;
-
- gamma_info = screen_priv->info;
-
- if (!gamma_info)
- return FALSE;
-
- if (ratio < 0)
- {
- ratio = 0;
- }
- if (ratio > 1)
- {
- ratio = 1;
- }
-
- if (gamma_info->size == 0)
- {
- /* we only have a gamma number, not a ramp. */
-
- XF86VidModeGamma g2;
-
- g2.red = screen_priv->vmg.red * ratio;
- g2.green = screen_priv->vmg.green * ratio;
- g2.blue = screen_priv->vmg.blue * ratio;
-
- if (g2.red < XF86_MIN_GAMMA)
- {
- g2.red = XF86_MIN_GAMMA;
- }
- if (g2.green < XF86_MIN_GAMMA)
- {
- g2.green = XF86_MIN_GAMMA;
- }
- if (g2.blue < XF86_MIN_GAMMA)
- {
- g2.blue = XF86_MIN_GAMMA;
- }
-
- status = XF86VidModeSetGamma (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), screen, &g2);
- }
- else
- {
+ float ratio)
+{
+ Bool status;
+ struct GSGammaInfo *gamma_info;
+
+ gamma_info = screen_priv->info;
+
+ if (!gamma_info)
+ return FALSE;
+
+ if (ratio < 0)
+ {
+ ratio = 0;
+ }
+ if (ratio > 1)
+ {
+ ratio = 1;
+ }
+
+ if (gamma_info->size == 0)
+ {
+ /* we only have a gamma number, not a ramp. */
+
+ XF86VidModeGamma g2;
+
+ g2.red = screen_priv->vmg.red * ratio;
+ g2.green = screen_priv->vmg.green * ratio;
+ g2.blue = screen_priv->vmg.blue * ratio;
+
+ if (g2.red < XF86_MIN_GAMMA)
+ {
+ g2.red = XF86_MIN_GAMMA;
+ }
+ if (g2.green < XF86_MIN_GAMMA)
+ {
+ g2.green = XF86_MIN_GAMMA;
+ }
+ if (g2.blue < XF86_MIN_GAMMA)
+ {
+ g2.blue = XF86_MIN_GAMMA;
+ }
+
+ status = XF86VidModeSetGamma (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), screen, &g2);
+ }
+ else
+ {
# ifdef HAVE_XF86VMODE_GAMMA_RAMP
- unsigned short *r, *g, *b;
- int i;
+ unsigned short *r, *g, *b;
+ int i;
- r = g_new0 (unsigned short, gamma_info->size);
- g = g_new0 (unsigned short, gamma_info->size);
- b = g_new0 (unsigned short, gamma_info->size);
+ r = g_new0 (unsigned short, gamma_info->size);
+ g = g_new0 (unsigned short, gamma_info->size);
+ b = g_new0 (unsigned short, gamma_info->size);
- for (i = 0; i < gamma_info->size; i++)
- {
- r[i] = gamma_info->r[i] * ratio;
- g[i] = gamma_info->g[i] * ratio;
- b[i] = gamma_info->b[i] * ratio;
- }
+ for (i = 0; i < gamma_info->size; i++)
+ {
+ r[i] = gamma_info->r[i] * ratio;
+ g[i] = gamma_info->g[i] * ratio;
+ b[i] = gamma_info->b[i] * ratio;
+ }
- status = XF86VidModeSetGammaRamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), screen, gamma_info->size, r, g, b);
+ status = XF86VidModeSetGammaRamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), screen, gamma_info->size, r, g, b);
- g_free (r);
- g_free (g);
- g_free (b);
+ g_free (r);
+ g_free (g);
+ g_free (b);
# else /* !HAVE_XF86VMODE_GAMMA_RAMP */
- abort ();
+ abort ();
# endif /* !HAVE_XF86VMODE_GAMMA_RAMP */
- }
+ }
- gdk_display_flush (gdk_display_get_default());
+ gdk_display_flush (gdk_display_get_default());
- return status;
+ return status;
}
#endif /* HAVE_XF86VMODE_GAMMA */
@@ -260,684 +259,684 @@ xf86_whack_gamma (int screen,
gboolean
gs_fade_get_enabled (GSFade *fade)
{
- g_return_val_if_fail (GS_IS_FADE (fade), FALSE);
+ g_return_val_if_fail (GS_IS_FADE (fade), FALSE);
- return fade->priv->enabled;
+ return fade->priv->enabled;
}
void
-gs_fade_set_enabled (GSFade *fade,
- gboolean enabled)
+gs_fade_set_enabled (GSFade *fade,
+ gboolean enabled)
{
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- if (fade->priv->enabled != enabled)
- {
- fade->priv->enabled = enabled;
- }
+ if (fade->priv->enabled != enabled)
+ {
+ fade->priv->enabled = enabled;
+ }
}
#ifdef HAVE_XF86VMODE_GAMMA
static gboolean
gamma_fade_setup (GSFade *fade)
{
- gboolean res;
- struct GSFadeScreenPrivate *screen_priv;
+ gboolean res;
+ struct GSFadeScreenPrivate *screen_priv;
- screen_priv = &fade->priv->screen_priv;
+ screen_priv = &fade->priv->screen_priv;
- if (screen_priv->info)
- return TRUE;
+ if (screen_priv->info)
+ return TRUE;
# ifndef HAVE_XF86VMODE_GAMMA_RAMP
- if (FADE_TYPE_GAMMA_RAMP == screen_priv->fade_type)
- {
- /* server is newer than client! */
- screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
- }
+ if (FADE_TYPE_GAMMA_RAMP == screen_priv->fade_type)
+ {
+ /* server is newer than client! */
+ screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
+ }
# endif
# ifdef HAVE_XF86VMODE_GAMMA_RAMP
- screen_priv->info = g_new0(struct GSGammaInfo, 1);
- screen_priv->num_ramps = 1;
-
- if (FADE_TYPE_GAMMA_RAMP == screen_priv->fade_type)
- {
- /* have ramps */
-
-
- res = XF86VidModeGetGammaRampSize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
- &screen_priv->info->size);
- if (!res || screen_priv->info->size <= 0)
- {
- screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
- goto test_number;
- }
-
- screen_priv->info->r = g_new0 (unsigned short, screen_priv->info->size);
- screen_priv->info->g = g_new0 (unsigned short, screen_priv->info->size);
- screen_priv->info->b = g_new0 (unsigned short, screen_priv->info->size);
-
- if (! (screen_priv->info->r && screen_priv->info->g && screen_priv->info->b))
- {
- screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
- goto test_number;
- }
-
- res = XF86VidModeGetGammaRamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
- screen_priv->info->size,
- screen_priv->info->r,
- screen_priv->info->g,
- screen_priv->info->b);
- if (! res)
- {
- screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
- goto test_number;
- }
- gs_debug ("Initialized gamma ramp fade");
- }
+ screen_priv->info = g_new0(struct GSGammaInfo, 1);
+ screen_priv->num_ramps = 1;
+
+ if (FADE_TYPE_GAMMA_RAMP == screen_priv->fade_type)
+ {
+ /* have ramps */
+
+
+ res = XF86VidModeGetGammaRampSize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
+ &screen_priv->info->size);
+ if (!res || screen_priv->info->size <= 0)
+ {
+ screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
+ goto test_number;
+ }
+
+ screen_priv->info->r = g_new0 (unsigned short, screen_priv->info->size);
+ screen_priv->info->g = g_new0 (unsigned short, screen_priv->info->size);
+ screen_priv->info->b = g_new0 (unsigned short, screen_priv->info->size);
+
+ if (! (screen_priv->info->r && screen_priv->info->g && screen_priv->info->b))
+ {
+ screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
+ goto test_number;
+ }
+
+ res = XF86VidModeGetGammaRamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
+ screen_priv->info->size,
+ screen_priv->info->r,
+ screen_priv->info->g,
+ screen_priv->info->b);
+ if (! res)
+ {
+ screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
+ goto test_number;
+ }
+ gs_debug ("Initialized gamma ramp fade");
+ }
# endif /* HAVE_XF86VMODE_GAMMA_RAMP */
test_number:
- if (FADE_TYPE_GAMMA_NUMBER == screen_priv->fade_type)
- {
- /* only have gamma parameter, not ramps. */
-
- res = XF86VidModeGetGamma (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
- &screen_priv->vmg);
- if (! res)
- {
- screen_priv->fade_type = FADE_TYPE_NONE;
- goto test_none;
- }
- gs_debug ("Initialized gamma fade: %f %f %f",
- screen_priv->vmg.red,
- screen_priv->vmg.green,
- screen_priv->vmg.blue);
- }
+ if (FADE_TYPE_GAMMA_NUMBER == screen_priv->fade_type)
+ {
+ /* only have gamma parameter, not ramps. */
+
+ res = XF86VidModeGetGamma (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
+ &screen_priv->vmg);
+ if (! res)
+ {
+ screen_priv->fade_type = FADE_TYPE_NONE;
+ goto test_none;
+ }
+ gs_debug ("Initialized gamma fade: %f %f %f",
+ screen_priv->vmg.red,
+ screen_priv->vmg.green,
+ screen_priv->vmg.blue);
+ }
test_none:
- if (FADE_TYPE_NONE == screen_priv->fade_type)
- {
- goto FAIL;
- }
+ if (FADE_TYPE_NONE == screen_priv->fade_type)
+ {
+ goto FAIL;
+ }
- return TRUE;
+ return TRUE;
FAIL:
- return FALSE;
+ return FALSE;
}
#endif /* HAVE_XF86VMODE_GAMMA */
static void
screen_fade_finish (GSFade *fade)
{
- struct GSFadeScreenPrivate *screen_priv;
- int i;
- screen_priv = &fade->priv->screen_priv;
-
- if (!screen_priv->info)
- return;
-
- for (i = 0; i < screen_priv->num_ramps; i++)
- {
- if (screen_priv->info[i].r)
- g_free (screen_priv->info[i].r);
- if (screen_priv->info[i].g)
- g_free (screen_priv->info[i].g);
- if (screen_priv->info[i].b)
- g_free (screen_priv->info[i].b);
- }
-
- g_free (screen_priv->info);
- screen_priv->info = NULL;
- screen_priv->num_ramps = 0;
+ struct GSFadeScreenPrivate *screen_priv;
+ int i;
+ screen_priv = &fade->priv->screen_priv;
+
+ if (!screen_priv->info)
+ return;
+
+ for (i = 0; i < screen_priv->num_ramps; i++)
+ {
+ if (screen_priv->info[i].r)
+ g_free (screen_priv->info[i].r);
+ if (screen_priv->info[i].g)
+ g_free (screen_priv->info[i].g);
+ if (screen_priv->info[i].b)
+ g_free (screen_priv->info[i].b);
+ }
+
+ g_free (screen_priv->info);
+ screen_priv->info = NULL;
+ screen_priv->num_ramps = 0;
}
#ifdef HAVE_XF86VMODE_GAMMA
static gboolean
-gamma_fade_set_alpha_gamma (GSFade *fade,
- gdouble alpha)
+gamma_fade_set_alpha_gamma (GSFade *fade,
+ gdouble alpha)
{
- struct GSFadeScreenPrivate *screen_priv;
- int screen_idx = GDK_SCREEN_XNUMBER (gdk_screen_get_default ());
+ struct GSFadeScreenPrivate *screen_priv;
+ int screen_idx = GDK_SCREEN_XNUMBER (gdk_screen_get_default ());
- screen_priv = &fade->priv->screen_priv;
- xf86_whack_gamma (screen_idx, screen_priv, alpha);
+ screen_priv = &fade->priv->screen_priv;
+ xf86_whack_gamma (screen_idx, screen_priv, alpha);
- return TRUE;
+ return TRUE;
}
#endif /* HAVE_XF86VMODE_GAMMA */
static void
check_gamma_extension (GSFade *fade)
{
- struct GSFadeScreenPrivate *screen_priv;
+ struct GSFadeScreenPrivate *screen_priv;
#ifdef HAVE_XF86VMODE_GAMMA
- int event;
- int error;
- int major;
- int minor;
- gboolean res;
+ int event;
+ int error;
+ int major;
+ int minor;
+ gboolean res;
#endif /* HAVE_XF86VMODE_GAMMA */
- screen_priv = &fade->priv->screen_priv;
+ screen_priv = &fade->priv->screen_priv;
#ifdef HAVE_XF86VMODE_GAMMA
- res = XF86VidModeQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &event, &error);
- if (! res)
- goto fade_none;
-
- res = safe_XF86VidModeQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor);
- if (! res)
- goto fade_none;
-
- if (major < XF86_VIDMODE_GAMMA_MIN_MAJOR ||
- (major == XF86_VIDMODE_GAMMA_MIN_MAJOR &&
- minor < XF86_VIDMODE_GAMMA_MIN_MINOR))
- goto fade_none;
-
- screen_priv->fade_setup = gamma_fade_setup;
- screen_priv->fade_finish = screen_fade_finish;
- screen_priv->fade_set_alpha_gamma = gamma_fade_set_alpha_gamma;
-
- if (major < XF86_VIDMODE_GAMMA_RAMP_MIN_MAJOR ||
- (major == XF86_VIDMODE_GAMMA_RAMP_MIN_MAJOR &&
- minor < XF86_VIDMODE_GAMMA_RAMP_MIN_MINOR))
- {
- screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
- return;
- }
-
- /* Copacetic */
- screen_priv->fade_type = FADE_TYPE_GAMMA_RAMP;
- return;
+ res = XF86VidModeQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &event, &error);
+ if (! res)
+ goto fade_none;
+
+ res = safe_XF86VidModeQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor);
+ if (! res)
+ goto fade_none;
+
+ if (major < XF86_VIDMODE_GAMMA_MIN_MAJOR ||
+ (major == XF86_VIDMODE_GAMMA_MIN_MAJOR &&
+ minor < XF86_VIDMODE_GAMMA_MIN_MINOR))
+ goto fade_none;
+
+ screen_priv->fade_setup = gamma_fade_setup;
+ screen_priv->fade_finish = screen_fade_finish;
+ screen_priv->fade_set_alpha_gamma = gamma_fade_set_alpha_gamma;
+
+ if (major < XF86_VIDMODE_GAMMA_RAMP_MIN_MAJOR ||
+ (major == XF86_VIDMODE_GAMMA_RAMP_MIN_MAJOR &&
+ minor < XF86_VIDMODE_GAMMA_RAMP_MIN_MINOR))
+ {
+ screen_priv->fade_type = FADE_TYPE_GAMMA_NUMBER;
+ return;
+ }
+
+ /* Copacetic */
+ screen_priv->fade_type = FADE_TYPE_GAMMA_RAMP;
+ return;
fade_none:
#endif
- screen_priv->fade_type = FADE_TYPE_NONE;
+ screen_priv->fade_type = FADE_TYPE_NONE;
}
/* Xrandr support */
static gboolean xrandr_fade_setup (GSFade *fade)
{
- struct GSFadeScreenPrivate *screen_priv;
- XfceRRCrtc *crtc;
- XfceRRCrtc **crtcs;
- int crtc_count = 0;
- struct GSGammaInfo *info;
- gboolean res;
-
- screen_priv = &fade->priv->screen_priv;
-
- if (screen_priv->info)
- return TRUE;
-
- /* refresh the screen info */
- xfce_rr_screen_refresh (screen_priv->rrscreen, NULL);
-
- crtcs = xfce_rr_screen_list_crtcs (screen_priv->rrscreen);
- while (*crtcs)
- {
- crtc_count++;
- crtcs++;
- };
-
- screen_priv->info = g_new0 (struct GSGammaInfo, crtc_count);
- screen_priv->num_ramps = crtc_count;
-
- crtc_count = 0;
- crtcs = xfce_rr_screen_list_crtcs (screen_priv->rrscreen);
- while (*crtcs)
- {
- crtc = *crtcs;
-
- info = &screen_priv->info[crtc_count];
-
- /* if no mode ignore crtc */
- if (!xfce_rr_crtc_get_current_mode (crtc))
- {
- info->size = 0;
- info->r = NULL;
- info->g = NULL;
- info->b = NULL;
- }
- else
- {
- res = xfce_rr_crtc_get_gamma (crtc, &info->size,
- &info->r, &info->g,
- &info->b);
- if (res == FALSE)
- goto fail;
- }
-
- crtcs++;
- crtc_count++;
- }
- return TRUE;
+ struct GSFadeScreenPrivate *screen_priv;
+ XfceRRCrtc *crtc;
+ XfceRRCrtc **crtcs;
+ int crtc_count = 0;
+ struct GSGammaInfo *info;
+ gboolean res;
+
+ screen_priv = &fade->priv->screen_priv;
+
+ if (screen_priv->info)
+ return TRUE;
+
+ /* refresh the screen info */
+ xfce_rr_screen_refresh (screen_priv->rrscreen, NULL);
+
+ crtcs = xfce_rr_screen_list_crtcs (screen_priv->rrscreen);
+ while (*crtcs)
+ {
+ crtc_count++;
+ crtcs++;
+ };
+
+ screen_priv->info = g_new0 (struct GSGammaInfo, crtc_count);
+ screen_priv->num_ramps = crtc_count;
+
+ crtc_count = 0;
+ crtcs = xfce_rr_screen_list_crtcs (screen_priv->rrscreen);
+ while (*crtcs)
+ {
+ crtc = *crtcs;
+
+ info = &screen_priv->info[crtc_count];
+
+ /* if no mode ignore crtc */
+ if (!xfce_rr_crtc_get_current_mode (crtc))
+ {
+ info->size = 0;
+ info->r = NULL;
+ info->g = NULL;
+ info->b = NULL;
+ }
+ else
+ {
+ res = xfce_rr_crtc_get_gamma (crtc, &info->size,
+ &info->r, &info->g,
+ &info->b);
+ if (res == FALSE)
+ goto fail;
+ }
+
+ crtcs++;
+ crtc_count++;
+ }
+ return TRUE;
fail:
- return FALSE;
+ return FALSE;
}
-static void xrandr_crtc_whack_gamma (XfceRRCrtc *crtc,
+static void xrandr_crtc_whack_gamma (XfceRRCrtc *crtc,
struct GSGammaInfo *gamma_info,
- float ratio)
-{
- unsigned short *r, *g, *b;
- int i;
-
- if (gamma_info->size == 0)
- return;
-
- if (ratio < 0)
- {
- ratio = 0;
- }
- if (ratio > 1)
- {
- ratio = 1;
- }
-
- r = g_new0 (unsigned short, gamma_info->size);
- g = g_new0 (unsigned short, gamma_info->size);
- b = g_new0 (unsigned short, gamma_info->size);
-
- for (i = 0; i < gamma_info->size; i++)
- {
- r[i] = gamma_info->r[i] * ratio;
- g[i] = gamma_info->g[i] * ratio;
- b[i] = gamma_info->b[i] * ratio;
- }
-
- xfce_rr_crtc_set_gamma (crtc, gamma_info->size,
- r, g, b);
- g_free (r);
- g_free (g);
- g_free (b);
+ float ratio)
+{
+ unsigned short *r, *g, *b;
+ int i;
+
+ if (gamma_info->size == 0)
+ return;
+
+ if (ratio < 0)
+ {
+ ratio = 0;
+ }
+ if (ratio > 1)
+ {
+ ratio = 1;
+ }
+
+ r = g_new0 (unsigned short, gamma_info->size);
+ g = g_new0 (unsigned short, gamma_info->size);
+ b = g_new0 (unsigned short, gamma_info->size);
+
+ for (i = 0; i < gamma_info->size; i++)
+ {
+ r[i] = gamma_info->r[i] * ratio;
+ g[i] = gamma_info->g[i] * ratio;
+ b[i] = gamma_info->b[i] * ratio;
+ }
+
+ xfce_rr_crtc_set_gamma (crtc, gamma_info->size,
+ r, g, b);
+ g_free (r);
+ g_free (g);
+ g_free (b);
}
-static gboolean xrandr_fade_set_alpha_gamma (GSFade *fade,
- gdouble alpha)
+static gboolean xrandr_fade_set_alpha_gamma (GSFade *fade,
+ gdouble alpha)
{
- struct GSFadeScreenPrivate *screen_priv;
- struct GSGammaInfo *info;
- XfceRRCrtc **crtcs;
- int i;
+ struct GSFadeScreenPrivate *screen_priv;
+ struct GSGammaInfo *info;
+ XfceRRCrtc **crtcs;
+ int i;
- screen_priv = &fade->priv->screen_priv;
+ screen_priv = &fade->priv->screen_priv;
- if (!screen_priv->info)
- return FALSE;
+ if (!screen_priv->info)
+ return FALSE;
- crtcs = xfce_rr_screen_list_crtcs (screen_priv->rrscreen);
- i = 0;
+ crtcs = xfce_rr_screen_list_crtcs (screen_priv->rrscreen);
+ i = 0;
- while (*crtcs)
- {
- info = &screen_priv->info[i];
- xrandr_crtc_whack_gamma (*crtcs, info, alpha);
- i++;
- crtcs++;
- }
- return TRUE;
+ while (*crtcs)
+ {
+ info = &screen_priv->info[i];
+ xrandr_crtc_whack_gamma (*crtcs, info, alpha);
+ i++;
+ crtcs++;
+ }
+ return TRUE;
}
static void
check_randr_extension (GSFade *fade)
{
- GdkDisplay *display = gdk_display_get_default ();
- GdkScreen *screen = gdk_display_get_default_screen (display);
- struct GSFadeScreenPrivate *screen_priv;
+ GdkDisplay *display = gdk_display_get_default ();
+ GdkScreen *screen = gdk_display_get_default_screen (display);
+ struct GSFadeScreenPrivate *screen_priv;
- screen_priv = &fade->priv->screen_priv;
+ screen_priv = &fade->priv->screen_priv;
- screen_priv->rrscreen = xfce_rr_screen_new (screen,
- NULL);
- if (!screen_priv->rrscreen)
- {
- screen_priv->fade_type = FADE_TYPE_NONE;
- return;
- }
+ screen_priv->rrscreen = xfce_rr_screen_new (screen,
+ NULL);
+ if (!screen_priv->rrscreen)
+ {
+ screen_priv->fade_type = FADE_TYPE_NONE;
+ return;
+ }
- screen_priv->fade_type = FADE_TYPE_XRANDR;
- screen_priv->fade_setup = xrandr_fade_setup;
- screen_priv->fade_finish = screen_fade_finish;
- screen_priv->fade_set_alpha_gamma = xrandr_fade_set_alpha_gamma;
+ screen_priv->fade_type = FADE_TYPE_XRANDR;
+ screen_priv->fade_setup = xrandr_fade_setup;
+ screen_priv->fade_finish = screen_fade_finish;
+ screen_priv->fade_set_alpha_gamma = xrandr_fade_set_alpha_gamma;
}
static gboolean
-gs_fade_set_alpha (GSFade *fade,
- gdouble alpha)
-{
- gboolean ret = FALSE;
-
- switch (fade->priv->screen_priv.fade_type)
- {
- case FADE_TYPE_GAMMA_RAMP:
- case FADE_TYPE_GAMMA_NUMBER:
- case FADE_TYPE_XRANDR:
- ret = fade->priv->screen_priv.fade_set_alpha_gamma (fade, alpha);
- break;
- case FADE_TYPE_NONE:
- ret = FALSE;
- break;
- default:
- g_warning ("Unknown fade type");
- ret = FALSE;
- break;
- }
-
- return ret;
+gs_fade_set_alpha (GSFade *fade,
+ gdouble alpha)
+{
+ gboolean ret = FALSE;
+
+ switch (fade->priv->screen_priv.fade_type)
+ {
+ case FADE_TYPE_GAMMA_RAMP:
+ case FADE_TYPE_GAMMA_NUMBER:
+ case FADE_TYPE_XRANDR:
+ ret = fade->priv->screen_priv.fade_set_alpha_gamma (fade, alpha);
+ break;
+ case FADE_TYPE_NONE:
+ ret = FALSE;
+ break;
+ default:
+ g_warning ("Unknown fade type");
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
}
static gboolean
gs_fade_out_iter (GSFade *fade)
{
- gboolean ret;
+ gboolean ret;
- if (fade->priv->current_alpha < 0.01)
- {
- return FALSE;
- }
+ if (fade->priv->current_alpha < 0.01)
+ {
+ return FALSE;
+ }
- fade->priv->current_alpha -= fade->priv->alpha_per_iter;
+ fade->priv->current_alpha -= fade->priv->alpha_per_iter;
- ret = gs_fade_set_alpha (fade, fade->priv->current_alpha);
+ ret = gs_fade_set_alpha (fade, fade->priv->current_alpha);
- return ret;
+ return ret;
}
static gboolean
gs_fade_stop (GSFade *fade)
{
- if (fade->priv->timer_id > 0)
- {
- g_source_remove (fade->priv->timer_id);
- fade->priv->timer_id = 0;
- }
+ if (fade->priv->timer_id > 0)
+ {
+ g_source_remove (fade->priv->timer_id);
+ fade->priv->timer_id = 0;
+ }
- fade->priv->step = 0;
- fade->priv->active = FALSE;
+ fade->priv->step = 0;
+ fade->priv->active = FALSE;
- return TRUE;
+ return TRUE;
}
void
gs_fade_finish (GSFade *fade)
{
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- if (! fade->priv->active)
- {
- return;
- }
+ if (! fade->priv->active)
+ {
+ return;
+ }
- gs_fade_stop (fade);
+ gs_fade_stop (fade);
- g_signal_emit (fade, signals [FADED], 0);
+ g_signal_emit (fade, signals [FADED], 0);
- fade->priv->active = FALSE;
+ fade->priv->active = FALSE;
}
static gboolean
fade_out_timer (GSFade *fade)
{
- gboolean res;
+ gboolean res;
- res = gs_fade_out_iter (fade);
+ res = gs_fade_out_iter (fade);
- /* if failed then fade is complete */
- if (! res)
- {
- gs_fade_finish (fade);
- return FALSE;
- }
+ /* if failed then fade is complete */
+ if (! res)
+ {
+ gs_fade_finish (fade);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gs_fade_get_active (GSFade *fade)
{
- g_return_val_if_fail (GS_IS_FADE (fade), FALSE);
+ g_return_val_if_fail (GS_IS_FADE (fade), FALSE);
- return fade->priv->active;
+ return fade->priv->active;
}
static void
-gs_fade_set_timeout (GSFade *fade,
- guint timeout)
+gs_fade_set_timeout (GSFade *fade,
+ guint timeout)
{
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- fade->priv->timeout = timeout;
+ fade->priv->timeout = timeout;
}
static void
gs_fade_start (GSFade *fade,
guint timeout)
{
- guint steps_per_sec = 60;
- guint msecs_per_step;
- gboolean active_fade, res;
+ guint steps_per_sec = 60;
+ guint msecs_per_step;
+ gboolean active_fade, res;
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE)
- {
- res = fade->priv->screen_priv.fade_setup (fade);
- if (res == FALSE)
- return;
- }
+ if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE)
+ {
+ res = fade->priv->screen_priv.fade_setup (fade);
+ if (res == FALSE)
+ return;
+ }
- if (fade->priv->timer_id > 0)
- {
- gs_fade_stop (fade);
- }
+ if (fade->priv->timer_id > 0)
+ {
+ gs_fade_stop (fade);
+ }
- fade->priv->active = TRUE;
+ fade->priv->active = TRUE;
- gs_fade_set_timeout (fade, timeout);
+ gs_fade_set_timeout (fade, timeout);
- active_fade = FALSE;
- if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE)
- active_fade = TRUE;
+ active_fade = FALSE;
+ if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE)
+ active_fade = TRUE;
- if (active_fade)
- {
- guint num_steps;
+ if (active_fade)
+ {
+ guint num_steps;
- num_steps = (fade->priv->timeout / 1000) * steps_per_sec;
- msecs_per_step = 1000 / steps_per_sec;
- fade->priv->alpha_per_iter = 1.0 / (gdouble)num_steps;
+ num_steps = (fade->priv->timeout / 1000) * steps_per_sec;
+ msecs_per_step = 1000 / steps_per_sec;
+ fade->priv->alpha_per_iter = 1.0 / (gdouble)num_steps;
- fade->priv->timer_id = g_timeout_add (msecs_per_step, (GSourceFunc)fade_out_timer, fade);
- }
- else
- {
- gs_fade_finish (fade);
- }
+ fade->priv->timer_id = g_timeout_add (msecs_per_step, (GSourceFunc)fade_out_timer, fade);
+ }
+ else
+ {
+ gs_fade_finish (fade);
+ }
}
typedef struct
{
- GSFadeDoneFunc done_cb;
- gpointer data;
+ GSFadeDoneFunc done_cb;
+ gpointer data;
} FadedCallbackData;
static void
gs_fade_async_callback (GSFade *fade,
FadedCallbackData *cdata)
{
- g_signal_handlers_disconnect_by_func (fade,
- gs_fade_async_callback,
- cdata);
+ g_signal_handlers_disconnect_by_func (fade,
+ gs_fade_async_callback,
+ cdata);
- if (cdata->done_cb)
- {
- cdata->done_cb (fade, cdata->data);
- }
+ if (cdata->done_cb)
+ {
+ cdata->done_cb (fade, cdata->data);
+ }
- g_free (cdata);
+ g_free (cdata);
}
void
-gs_fade_async (GSFade *fade,
- guint timeout,
- GSFadeDoneFunc func,
- gpointer data)
+gs_fade_async (GSFade *fade,
+ guint timeout,
+ GSFadeDoneFunc func,
+ gpointer data)
{
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- /* if fade is active then pause it */
- if (fade->priv->active)
- {
- gs_fade_stop (fade);
- }
+ /* if fade is active then pause it */
+ if (fade->priv->active)
+ {
+ gs_fade_stop (fade);
+ }
- if (func)
- {
- FadedCallbackData *cb_data;
+ if (func)
+ {
+ FadedCallbackData *cb_data;
- cb_data = g_new0 (FadedCallbackData, 1);
- cb_data->done_cb = func;
- cb_data->data = data;
+ cb_data = g_new0 (FadedCallbackData, 1);
+ cb_data->done_cb = func;
+ cb_data->data = data;
- g_signal_connect (fade, "faded",
- G_CALLBACK (gs_fade_async_callback),
- cb_data);
- }
+ g_signal_connect (fade, "faded",
+ G_CALLBACK (gs_fade_async_callback),
+ cb_data);
+ }
- gs_fade_start (fade, timeout);
+ gs_fade_start (fade, timeout);
}
static void
gs_fade_sync_callback (GSFade *fade,
int *flag)
{
- *flag = TRUE;
- g_signal_handlers_disconnect_by_func (fade,
- gs_fade_sync_callback,
- flag);
+ *flag = TRUE;
+ g_signal_handlers_disconnect_by_func (fade,
+ gs_fade_sync_callback,
+ flag);
}
void
-gs_fade_sync (GSFade *fade,
- guint timeout)
+gs_fade_sync (GSFade *fade,
+ guint timeout)
{
- int flag = FALSE;
+ int flag = FALSE;
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- /* if fade is active then pause it */
- if (fade->priv->active)
- {
- gs_fade_stop (fade);
- }
+ /* if fade is active then pause it */
+ if (fade->priv->active)
+ {
+ gs_fade_stop (fade);
+ }
- g_signal_connect (fade, "faded",
- G_CALLBACK (gs_fade_sync_callback),
- &flag);
+ g_signal_connect (fade, "faded",
+ G_CALLBACK (gs_fade_sync_callback),
+ &flag);
- gs_fade_start (fade, timeout);
+ gs_fade_start (fade, timeout);
- while (! flag)
- {
- gtk_main_iteration ();
- }
+ while (! flag)
+ {
+ gtk_main_iteration ();
+ }
}
void
gs_fade_reset (GSFade *fade)
{
- g_return_if_fail (GS_IS_FADE (fade));
+ g_return_if_fail (GS_IS_FADE (fade));
- gs_debug ("Resetting fade");
+ gs_debug ("Resetting fade");
- if (fade->priv->active)
- {
- gs_fade_stop (fade);
- }
+ if (fade->priv->active)
+ {
+ gs_fade_stop (fade);
+ }
- fade->priv->current_alpha = 1.0;
+ fade->priv->current_alpha = 1.0;
- gs_fade_set_alpha (fade, fade->priv->current_alpha);
+ gs_fade_set_alpha (fade, fade->priv->current_alpha);
- if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE)
- fade->priv->screen_priv.fade_finish (fade);
+ if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE)
+ fade->priv->screen_priv.fade_finish (fade);
}
static void
gs_fade_class_init (GSFadeClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_fade_finalize;
+ object_class->finalize = gs_fade_finalize;
- signals [FADED] =
- g_signal_new ("faded",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSFadeClass, faded),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0, G_TYPE_NONE);
+ signals [FADED] =
+ g_signal_new ("faded",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSFadeClass, faded),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0, G_TYPE_NONE);
}
static void
gs_fade_init (GSFade *fade)
{
- fade->priv = gs_fade_get_instance_private (fade);
+ fade->priv = gs_fade_get_instance_private (fade);
- fade->priv->timeout = 1000;
- fade->priv->current_alpha = 1.0;
+ fade->priv->timeout = 1000;
+ fade->priv->current_alpha = 1.0;
- check_randr_extension (fade);
- if (!fade->priv->screen_priv.fade_type)
- check_gamma_extension (fade);
- gs_debug ("Fade type: %d", fade->priv->screen_priv.fade_type);
+ check_randr_extension (fade);
+ if (!fade->priv->screen_priv.fade_type)
+ check_gamma_extension (fade);
+ gs_debug ("Fade type: %d", fade->priv->screen_priv.fade_type);
}
static void
gs_fade_finalize (GObject *object)
{
- GSFade *fade;
+ GSFade *fade;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_FADE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_FADE (object));
- fade = GS_FADE (object);
+ fade = GS_FADE (object);
- g_return_if_fail (fade->priv != NULL);
+ g_return_if_fail (fade->priv != NULL);
- fade->priv->screen_priv.fade_finish(fade);
+ fade->priv->screen_priv.fade_finish(fade);
- if (fade->priv->screen_priv.rrscreen)
- g_object_unref (fade->priv->screen_priv.rrscreen);
- fade->priv->screen_priv.rrscreen = NULL;
+ if (fade->priv->screen_priv.rrscreen)
+ g_object_unref (fade->priv->screen_priv.rrscreen);
+ fade->priv->screen_priv.rrscreen = NULL;
- G_OBJECT_CLASS (gs_fade_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_fade_parent_class)->finalize (object);
}
GSFade *
gs_fade_new (void)
{
- if (fade_object)
- {
- g_object_ref (fade_object);
- }
- else
- {
- fade_object = g_object_new (GS_TYPE_FADE, NULL);
- g_object_add_weak_pointer (fade_object,
- (gpointer *) &fade_object);
- }
-
- return GS_FADE (fade_object);
+ if (fade_object)
+ {
+ g_object_ref (fade_object);
+ }
+ else
+ {
+ fade_object = g_object_new (GS_TYPE_FADE, NULL);
+ g_object_add_weak_pointer (fade_object,
+ (gpointer *) &fade_object);
+ }
+
+ return GS_FADE (fade_object);
}
diff --git a/src/gs-fade.h b/src/gs-fade.h
index 83a8f4a..f8157bd 100644
--- a/src/gs-fade.h
+++ b/src/gs-fade.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -39,40 +39,40 @@ typedef struct GSFadePrivate GSFadePrivate;
typedef struct
{
- GObject parent;
- GSFadePrivate *priv;
+ GObject parent;
+ GSFadePrivate *priv;
} GSFade;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* faded) (GSFade *fade);
+ void (* faded) (GSFade *fade);
} GSFadeClass;
-typedef void (* GSFadeDoneFunc) (GSFade *fade,
- gpointer data);
+typedef void (* GSFadeDoneFunc) (GSFade *fade,
+ gpointer data);
GType gs_fade_get_type (void);
GSFade * gs_fade_new (void);
-void gs_fade_async (GSFade *fade,
- guint timeout,
- GSFadeDoneFunc done_cb,
- gpointer data);
-void gs_fade_sync (GSFade *fade,
- guint timeout);
+void gs_fade_async (GSFade *fade,
+ guint timeout,
+ GSFadeDoneFunc done_cb,
+ gpointer data);
+void gs_fade_sync (GSFade *fade,
+ guint timeout);
-void gs_fade_finish (GSFade *fade);
-void gs_fade_reset (GSFade *fade);
+void gs_fade_finish (GSFade *fade);
+void gs_fade_reset (GSFade *fade);
-gboolean gs_fade_get_active (GSFade *fade);
+gboolean gs_fade_get_active (GSFade *fade);
-gboolean gs_fade_get_enabled (GSFade *fade);
-void gs_fade_set_enabled (GSFade *fade,
- gboolean enabled);
+gboolean gs_fade_get_enabled (GSFade *fade);
+void gs_fade_set_enabled (GSFade *fade,
+ gboolean enabled);
G_END_DECLS
diff --git a/src/gs-grab-x11.c b/src/gs-grab-x11.c
index c4d08c4..8bcdbfc 100644
--- a/src/gs-grab-x11.c
+++ b/src/gs-grab-x11.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -45,12 +45,12 @@ static gpointer grab_object = NULL;
struct GSGrabPrivate
{
- GdkWindow *grab_window;
- GdkDisplay *grab_display;
- guint no_pointer_grab : 1;
- guint hide_cursor : 1;
+ GdkWindow *grab_window;
+ GdkDisplay *grab_display;
+ guint no_pointer_grab : 1;
+ guint hide_cursor : 1;
- GtkWidget *invisible;
+ GtkWidget *invisible;
};
G_DEFINE_TYPE_WITH_PRIVATE (GSGrab, gs_grab, G_TYPE_OBJECT)
@@ -58,27 +58,27 @@ G_DEFINE_TYPE_WITH_PRIVATE (GSGrab, gs_grab, G_TYPE_OBJECT)
static const char *
grab_string (int status)
{
- switch (status)
- {
- case GDK_GRAB_SUCCESS:
- return "GrabSuccess";
- case GDK_GRAB_ALREADY_GRABBED:
- return "AlreadyGrabbed";
- case GDK_GRAB_INVALID_TIME:
- return "GrabInvalidTime";
- case GDK_GRAB_NOT_VIEWABLE:
- return "GrabNotViewable";
- case GDK_GRAB_FROZEN:
- return "GrabFrozen";
- case GDK_GRAB_FAILED:
- return "GrabFailed";
- default:
- {
- static char foo [255];
- sprintf (foo, "unknown status: %d", status);
- return foo;
- }
- }
+ switch (status)
+ {
+ case GDK_GRAB_SUCCESS:
+ return "GrabSuccess";
+ case GDK_GRAB_ALREADY_GRABBED:
+ return "AlreadyGrabbed";
+ case GDK_GRAB_INVALID_TIME:
+ return "GrabInvalidTime";
+ case GDK_GRAB_NOT_VIEWABLE:
+ return "GrabNotViewable";
+ case GDK_GRAB_FROZEN:
+ return "GrabFrozen";
+ case GDK_GRAB_FAILED:
+ return "GrabFailed";
+ default:
+ {
+ static char foo [255];
+ sprintf (foo, "unknown status: %d", status);
+ return foo;
+ }
+ }
}
#ifdef HAVE_XF86MISCSETGRABKEYSSTATE
@@ -95,58 +95,58 @@ grab_string (int status)
Ctrl-Alt-F1) but I wish it did. Maybe it will someday.
*/
static void
-xorg_lock_smasher_set_active (GSGrab *grab,
- gboolean active)
+xorg_lock_smasher_set_active (GSGrab *grab,
+ gboolean active)
{
- int status, event, error;
- GdkDisplay *display;
+ int status, event, error;
+ GdkDisplay *display;
- display = gdk_display_get_default();
+ display = gdk_display_get_default();
- if (!XF86MiscQueryExtension (GDK_DISPLAY_XDISPLAY (display), &event, &error))
- {
- gs_debug ("No XFree86-Misc extension present");
- return;
- }
+ if (!XF86MiscQueryExtension (GDK_DISPLAY_XDISPLAY (display), &event, &error))
+ {
+ gs_debug ("No XFree86-Misc extension present");
+ return;
+ }
- if (active)
- {
- gs_debug ("Enabling the x.org grab smasher");
- }
- else
- {
- gs_debug ("Disabling the x.org grab smasher");
- }
+ if (active)
+ {
+ gs_debug ("Enabling the x.org grab smasher");
+ }
+ else
+ {
+ gs_debug ("Disabling the x.org grab smasher");
+ }
- gdk_x11_display_error_trap_push (display);
+ gdk_x11_display_error_trap_push (display);
- status = XF86MiscSetGrabKeysState (GDK_DISPLAY_XDISPLAY (display), active);
+ status = XF86MiscSetGrabKeysState (GDK_DISPLAY_XDISPLAY (display), active);
- gdk_display_sync (display);
- error = gdk_x11_display_error_trap_pop (display);
+ gdk_display_sync (display);
+ error = gdk_x11_display_error_trap_pop (display);
- if (active && status == MiscExtGrabStateAlready)
- {
- /* shut up, consider this success */
- status = MiscExtGrabStateSuccess;
- }
+ if (active && status == MiscExtGrabStateAlready)
+ {
+ /* shut up, consider this success */
+ status = MiscExtGrabStateSuccess;
+ }
if (error == Success) {
- gs_debug ("XF86MiscSetGrabKeysState(%s) returned %s\n",
- active ? "on" : "off",
- (status == MiscExtGrabStateSuccess ? "MiscExtGrabStateSuccess" :
- status == MiscExtGrabStateLocked ? "MiscExtGrabStateLocked" :
- status == MiscExtGrabStateAlready ? "MiscExtGrabStateAlready" :
- "unknown value"));
+ gs_debug ("XF86MiscSetGrabKeysState(%s) returned %s\n",
+ active ? "on" : "off",
+ (status == MiscExtGrabStateSuccess ? "MiscExtGrabStateSuccess" :
+ status == MiscExtGrabStateLocked ? "MiscExtGrabStateLocked" :
+ status == MiscExtGrabStateAlready ? "MiscExtGrabStateAlready" :
+ "unknown value"));
} else {
- gs_debug ("XF86MiscSetGrabKeysState(%s) failed with error code %d\n",
- active ? "on" : "off", error);
+ gs_debug ("XF86MiscSetGrabKeysState(%s) failed with error code %d\n",
+ active ? "on" : "off", error);
}
}
#else
static void
-xorg_lock_smasher_set_active (GSGrab *grab,
- gboolean active)
+xorg_lock_smasher_set_active (GSGrab *grab,
+ gboolean active)
{
}
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
@@ -156,7 +156,7 @@ prepare_window_grab_cb (GdkSeat *seat,
GdkWindow *window,
gpointer user_data)
{
- gdk_window_show_unraised (window);
+ gdk_window_show_unraised (window);
}
static int
@@ -166,103 +166,103 @@ gs_grab_get (GSGrab *grab,
gboolean no_pointer_grab,
gboolean hide_cursor)
{
- GdkGrabStatus status;
- GdkSeat *seat;
- GdkSeatCapabilities caps;
- GdkCursor *cursor;
-
- g_return_val_if_fail (window != NULL, FALSE);
- g_return_val_if_fail (display != NULL, FALSE);
-
- cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
-
- gs_debug ("Grabbing devices for window=%X", (guint32) GDK_WINDOW_XID (window));
-
- seat = gdk_display_get_default_seat (display);
- if (!no_pointer_grab)
- caps = GDK_SEAT_CAPABILITY_ALL;
- else
- caps = GDK_SEAT_CAPABILITY_KEYBOARD;
-
- status = gdk_seat_grab (seat, window,
- caps, TRUE,
- (hide_cursor ? cursor : NULL),
- NULL,
- prepare_window_grab_cb,
- NULL);
-
- /* make it release grabbed pointer if requested and if any;
- time between grabbing and ungrabbing is minimal as grab was already
- completed once */
- if (status == GDK_GRAB_SUCCESS && no_pointer_grab &&
- gdk_display_device_is_grabbed (display, gdk_seat_get_pointer (seat)))
- {
- gs_grab_release (grab, FALSE);
- gs_debug ("Regrabbing keyboard");
- status = gdk_seat_grab (seat, window,
- caps, TRUE,
- (hide_cursor ? cursor : NULL),
- NULL, NULL, NULL);
- }
-
- if (status == GDK_GRAB_SUCCESS)
- {
- if (grab->priv->grab_window != NULL)
- {
- g_object_remove_weak_pointer (G_OBJECT (grab->priv->grab_window),
- (gpointer *) &grab->priv->grab_window);
- }
- grab->priv->grab_window = window;
-
- g_object_add_weak_pointer (G_OBJECT (grab->priv->grab_window),
- (gpointer *) &grab->priv->grab_window);
-
- grab->priv->grab_display = display;
- grab->priv->no_pointer_grab = no_pointer_grab;
- grab->priv->hide_cursor = hide_cursor;
- }
-
- g_object_unref (G_OBJECT (cursor));
-
- return status;
+ GdkGrabStatus status;
+ GdkSeat *seat;
+ GdkSeatCapabilities caps;
+ GdkCursor *cursor;
+
+ g_return_val_if_fail (window != NULL, FALSE);
+ g_return_val_if_fail (display != NULL, FALSE);
+
+ cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
+
+ gs_debug ("Grabbing devices for window=%X", (guint32) GDK_WINDOW_XID (window));
+
+ seat = gdk_display_get_default_seat (display);
+ if (!no_pointer_grab)
+ caps = GDK_SEAT_CAPABILITY_ALL;
+ else
+ caps = GDK_SEAT_CAPABILITY_KEYBOARD;
+
+ status = gdk_seat_grab (seat, window,
+ caps, TRUE,
+ (hide_cursor ? cursor : NULL),
+ NULL,
+ prepare_window_grab_cb,
+ NULL);
+
+ /* make it release grabbed pointer if requested and if any;
+ time between grabbing and ungrabbing is minimal as grab was already
+ completed once */
+ if (status == GDK_GRAB_SUCCESS && no_pointer_grab &&
+ gdk_display_device_is_grabbed (display, gdk_seat_get_pointer (seat)))
+ {
+ gs_grab_release (grab, FALSE);
+ gs_debug ("Regrabbing keyboard");
+ status = gdk_seat_grab (seat, window,
+ caps, TRUE,
+ (hide_cursor ? cursor : NULL),
+ NULL, NULL, NULL);
+ }
+
+ if (status == GDK_GRAB_SUCCESS)
+ {
+ if (grab->priv->grab_window != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (grab->priv->grab_window),
+ (gpointer *) &grab->priv->grab_window);
+ }
+ grab->priv->grab_window = window;
+
+ g_object_add_weak_pointer (G_OBJECT (grab->priv->grab_window),
+ (gpointer *) &grab->priv->grab_window);
+
+ grab->priv->grab_display = display;
+ grab->priv->no_pointer_grab = no_pointer_grab;
+ grab->priv->hide_cursor = hide_cursor;
+ }
+
+ g_object_unref (G_OBJECT (cursor));
+
+ return status;
}
void
gs_grab_reset (GSGrab *grab)
{
- if (grab->priv->grab_window != NULL)
- {
- g_object_remove_weak_pointer (G_OBJECT (grab->priv->grab_window),
- (gpointer *) &grab->priv->grab_window);
- }
- grab->priv->grab_window = NULL;
- grab->priv->grab_display = NULL;
+ if (grab->priv->grab_window != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (grab->priv->grab_window),
+ (gpointer *) &grab->priv->grab_window);
+ }
+ grab->priv->grab_window = NULL;
+ grab->priv->grab_display = NULL;
}
void
gs_grab_release (GSGrab *grab, gboolean flush)
{
- GdkDisplay *display;
- GdkSeat *seat;
+ GdkDisplay *display;
+ GdkSeat *seat;
- display = gdk_display_get_default ();
- seat = gdk_display_get_default_seat (display);
+ display = gdk_display_get_default ();
+ seat = gdk_display_get_default_seat (display);
- gs_debug ("Ungrabbing devices");
+ gs_debug ("Ungrabbing devices");
- gdk_seat_ungrab (seat);
+ gdk_seat_ungrab (seat);
- gs_grab_reset (grab);
+ gs_grab_reset (grab);
- /* FIXME: decide when this is good and when not */
- if (flush)
- {
- /* FIXME: is it right to enable this? */
- xorg_lock_smasher_set_active (grab, TRUE);
+ /* FIXME: decide when this is good and when not */
+ if (flush)
+ {
+ /* FIXME: is it right to enable this? */
+ xorg_lock_smasher_set_active (grab, TRUE);
- gdk_display_sync (display);
- gdk_display_flush (display);
- }
+ gdk_display_sync (display);
+ gdk_display_flush (display);
+ }
}
static gboolean
@@ -272,87 +272,87 @@ gs_grab_move (GSGrab *grab,
gboolean no_pointer_grab,
gboolean hide_cursor)
{
- int result;
- GdkWindow *old_window;
- GdkDisplay *old_display;
- gboolean old_hide_cursor;
-
- if (grab->priv->grab_window == window &&
- grab->priv->no_pointer_grab == no_pointer_grab)
- {
- gs_debug ("Window %X is already grabbed, skipping",
- (guint32) GDK_WINDOW_XID (grab->priv->grab_window));
- return TRUE;
- }
-
- if (grab->priv->grab_window != NULL)
- {
- gs_debug ("Moving devices grab from %X to %X",
- (guint32) GDK_WINDOW_XID (grab->priv->grab_window),
- (guint32) GDK_WINDOW_XID (window));
- }
- else
- {
- gs_debug ("Getting devices grab on %X",
- (guint32) GDK_WINDOW_XID (window));
-
- }
-
- gs_debug ("*** doing X server grab");
- gdk_x11_display_grab (display);
-
- old_window = grab->priv->grab_window;
- old_display = grab->priv->grab_display;
- old_hide_cursor = grab->priv->hide_cursor;
-
- if (old_window)
- {
- gs_grab_release (grab, FALSE);
- }
-
- result = gs_grab_get (grab, window, display,
- no_pointer_grab, hide_cursor);
-
- if (result != GDK_GRAB_SUCCESS)
- {
- g_usleep (G_USEC_PER_SEC);
- result = gs_grab_get (grab, window, display,
- no_pointer_grab, hide_cursor);
- }
-
- if ((result != GDK_GRAB_SUCCESS) && old_window)
- {
- int old_result;
-
- gs_debug ("Could not grab devices for new window. Resuming previous grab.");
- old_result = gs_grab_get (grab, old_window, old_display,
- no_pointer_grab, old_hide_cursor);
- if (old_result != GDK_GRAB_SUCCESS)
- gs_debug ("Could not grab devices for old window");
- }
-
- gs_debug ("*** releasing X server grab");
- gdk_x11_display_ungrab (display);
- gdk_display_flush (display);
-
- return (result == GDK_GRAB_SUCCESS);
+ int result;
+ GdkWindow *old_window;
+ GdkDisplay *old_display;
+ gboolean old_hide_cursor;
+
+ if (grab->priv->grab_window == window &&
+ grab->priv->no_pointer_grab == no_pointer_grab)
+ {
+ gs_debug ("Window %X is already grabbed, skipping",
+ (guint32) GDK_WINDOW_XID (grab->priv->grab_window));
+ return TRUE;
+ }
+
+ if (grab->priv->grab_window != NULL)
+ {
+ gs_debug ("Moving devices grab from %X to %X",
+ (guint32) GDK_WINDOW_XID (grab->priv->grab_window),
+ (guint32) GDK_WINDOW_XID (window));
+ }
+ else
+ {
+ gs_debug ("Getting devices grab on %X",
+ (guint32) GDK_WINDOW_XID (window));
+
+ }
+
+ gs_debug ("*** doing X server grab");
+ gdk_x11_display_grab (display);
+
+ old_window = grab->priv->grab_window;
+ old_display = grab->priv->grab_display;
+ old_hide_cursor = grab->priv->hide_cursor;
+
+ if (old_window)
+ {
+ gs_grab_release (grab, FALSE);
+ }
+
+ result = gs_grab_get (grab, window, display,
+ no_pointer_grab, hide_cursor);
+
+ if (result != GDK_GRAB_SUCCESS)
+ {
+ g_usleep (G_USEC_PER_SEC);
+ result = gs_grab_get (grab, window, display,
+ no_pointer_grab, hide_cursor);
+ }
+
+ if ((result != GDK_GRAB_SUCCESS) && old_window)
+ {
+ int old_result;
+
+ gs_debug ("Could not grab devices for new window. Resuming previous grab.");
+ old_result = gs_grab_get (grab, old_window, old_display,
+ no_pointer_grab, old_hide_cursor);
+ if (old_result != GDK_GRAB_SUCCESS)
+ gs_debug ("Could not grab devices for old window");
+ }
+
+ gs_debug ("*** releasing X server grab");
+ gdk_x11_display_ungrab (display);
+ gdk_display_flush (display);
+
+ return (result == GDK_GRAB_SUCCESS);
}
static void
gs_grab_nuke_focus (GdkDisplay *display)
{
- Window focus = 0;
- int rev = 0;
+ Window focus = 0;
+ int rev = 0;
- gs_debug ("Nuking focus");
+ gs_debug ("Nuking focus");
- gdk_x11_display_error_trap_push (display);
+ gdk_x11_display_error_trap_push (display);
- XGetInputFocus (GDK_DISPLAY_XDISPLAY (display), &focus, &rev);
- XSetInputFocus (GDK_DISPLAY_XDISPLAY (display), None,
- RevertToNone, CurrentTime);
+ XGetInputFocus (GDK_DISPLAY_XDISPLAY (display), &focus, &rev);
+ XSetInputFocus (GDK_DISPLAY_XDISPLAY (display), None,
+ RevertToNone, CurrentTime);
- gdk_x11_display_error_trap_pop_ignored (display);
+ gdk_x11_display_error_trap_pop_ignored (display);
}
gboolean
@@ -362,86 +362,86 @@ gs_grab_grab_window (GSGrab *grab,
gboolean no_pointer_grab,
gboolean hide_cursor)
{
- gboolean status = FALSE;
- int i;
- int retries = 12;
-
- for (i = 0; i < retries; i++)
- {
- status = gs_grab_get (grab, window, display,
- no_pointer_grab, hide_cursor);
- if (status == GDK_GRAB_SUCCESS)
- {
- break;
- }
- else if (i == (int) (retries / 2))
- {
- /* try nuking focus in the middle */
- gs_grab_nuke_focus (display);
- }
-
- /* else, wait a second and try to grab again */
- g_usleep (G_USEC_PER_SEC);
- }
-
- if (status != GDK_GRAB_SUCCESS)
- {
- gs_debug ("Couldn't grab devices! (%s)",
- grab_string (status));
-
- /* do not blank without a devices grab */
- return FALSE;
- }
-
- /* grab is good, go ahead and blank */
- return TRUE;
+ gboolean status = FALSE;
+ int i;
+ int retries = 12;
+
+ for (i = 0; i < retries; i++)
+ {
+ status = gs_grab_get (grab, window, display,
+ no_pointer_grab, hide_cursor);
+ if (status == GDK_GRAB_SUCCESS)
+ {
+ break;
+ }
+ else if (i == (int) (retries / 2))
+ {
+ /* try nuking focus in the middle */
+ gs_grab_nuke_focus (display);
+ }
+
+ /* else, wait a second and try to grab again */
+ g_usleep (G_USEC_PER_SEC);
+ }
+
+ if (status != GDK_GRAB_SUCCESS)
+ {
+ gs_debug ("Couldn't grab devices! (%s)",
+ grab_string (status));
+
+ /* do not blank without a devices grab */
+ return FALSE;
+ }
+
+ /* grab is good, go ahead and blank */
+ return TRUE;
}
/* this is used to grab devices to the root */
gboolean
-gs_grab_grab_root (GSGrab *grab,
- gboolean no_pointer_grab,
- gboolean hide_cursor)
+gs_grab_grab_root (GSGrab *grab,
+ gboolean no_pointer_grab,
+ gboolean hide_cursor)
{
- GdkDisplay *display;
- GdkWindow *root;
- GdkScreen *screen;
- GdkDevice *device;
- gboolean res;
+ GdkDisplay *display;
+ GdkWindow *root;
+ GdkScreen *screen;
+ GdkDevice *device;
+ gboolean res;
- gs_debug ("Grabbing the root window");
+ gs_debug ("Grabbing the root window");
- display = gdk_display_get_default ();
- device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
- gdk_device_get_position (device, &screen, NULL, NULL);
- root = gdk_screen_get_root_window (screen);
+ display = gdk_display_get_default ();
+ device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
+ gdk_device_get_position (device, &screen, NULL, NULL);
+ root = gdk_screen_get_root_window (screen);
- res = gs_grab_grab_window (grab, root, display,
- no_pointer_grab, hide_cursor);
+ res = gs_grab_grab_window (grab, root, display,
+ no_pointer_grab, hide_cursor);
- return res;
+ return res;
}
/* this is used to grab devices to an offscreen window */
gboolean
-gs_grab_grab_offscreen (GSGrab *grab,
- gboolean no_pointer_grab,
- gboolean hide_cursor)
+gs_grab_grab_offscreen (GSGrab *grab,
+ gboolean no_pointer_grab,
+ gboolean hide_cursor)
{
- GdkWindow *window;
- GdkDisplay *display;
- GdkScreen *screen;
- gboolean res;
+ GdkWindow *window;
+ GdkDisplay *display;
+ GdkScreen *screen;
+ gboolean res;
- gs_debug ("Grabbing an offscreen window");
+ gs_debug ("Grabbing an offscreen window");
- window = gtk_widget_get_window (GTK_WIDGET (grab->priv->invisible));
- screen = gtk_invisible_get_screen (GTK_INVISIBLE (grab->priv->invisible));
- display = gdk_screen_get_display (screen);
- res = gs_grab_grab_window (grab, window, display,
- no_pointer_grab, hide_cursor);
+ window = gtk_widget_get_window (GTK_WIDGET (grab->priv->invisible));
+ screen = gtk_invisible_get_screen (GTK_INVISIBLE (grab->priv->invisible));
+ display = gdk_screen_get_display (screen);
+ res = gs_grab_grab_window (grab, window, display,
+ no_pointer_grab, hide_cursor);
- return res;
+ return res;
}
/* this is similar to gs_grab_grab_window but doesn't fail */
@@ -452,69 +452,69 @@ gs_grab_move_to_window (GSGrab *grab,
gboolean no_pointer_grab,
gboolean hide_cursor)
{
- gboolean result = FALSE;
+ gboolean result = FALSE;
- g_return_if_fail (GS_IS_GRAB (grab));
+ g_return_if_fail (GS_IS_GRAB (grab));
- xorg_lock_smasher_set_active (grab, FALSE);
+ xorg_lock_smasher_set_active (grab, FALSE);
- while (!result)
- {
- result = gs_grab_move (grab, window, display,
- no_pointer_grab, hide_cursor);
- gdk_display_flush (display);
- }
+ while (!result)
+ {
+ result = gs_grab_move (grab, window, display,
+ no_pointer_grab, hide_cursor);
+ gdk_display_flush (display);
+ }
}
static void
gs_grab_class_init (GSGrabClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_grab_finalize;
+ object_class->finalize = gs_grab_finalize;
}
static void
gs_grab_init (GSGrab *grab)
{
- grab->priv = gs_grab_get_instance_private (grab);
+ grab->priv = gs_grab_get_instance_private (grab);
- grab->priv->no_pointer_grab = FALSE;
- grab->priv->hide_cursor = FALSE;
- grab->priv->invisible = gtk_invisible_new ();
- gtk_widget_show (grab->priv->invisible);
+ grab->priv->no_pointer_grab = FALSE;
+ grab->priv->hide_cursor = FALSE;
+ grab->priv->invisible = gtk_invisible_new ();
+ gtk_widget_show (grab->priv->invisible);
}
static void
gs_grab_finalize (GObject *object)
{
- GSGrab *grab;
+ GSGrab *grab;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_GRAB (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_GRAB (object));
- grab = GS_GRAB (object);
+ grab = GS_GRAB (object);
- g_return_if_fail (grab->priv != NULL);
+ g_return_if_fail (grab->priv != NULL);
- gtk_widget_destroy (grab->priv->invisible);
+ gtk_widget_destroy (grab->priv->invisible);
- G_OBJECT_CLASS (gs_grab_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_grab_parent_class)->finalize (object);
}
GSGrab *
gs_grab_new (void)
{
- if (grab_object)
- {
- g_object_ref (grab_object);
- }
- else
- {
- grab_object = g_object_new (GS_TYPE_GRAB, NULL);
- g_object_add_weak_pointer (grab_object,
- (gpointer *) &grab_object);
- }
-
- return GS_GRAB (grab_object);
+ if (grab_object)
+ {
+ g_object_ref (grab_object);
+ }
+ else
+ {
+ grab_object = g_object_new (GS_TYPE_GRAB, NULL);
+ g_object_add_weak_pointer (grab_object,
+ (gpointer *) &grab_object);
+ }
+
+ return GS_GRAB (grab_object);
}
diff --git a/src/gs-grab.h b/src/gs-grab.h
index 7c4086c..a339069 100644
--- a/src/gs-grab.h
+++ b/src/gs-grab.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -39,13 +39,13 @@ typedef struct GSGrabPrivate GSGrabPrivate;
typedef struct
{
- GObject parent;
- GSGrabPrivate *priv;
+ GObject parent;
+ GSGrabPrivate *priv;
} GSGrab;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
} GSGrabClass;
@@ -53,8 +53,8 @@ GType gs_grab_get_type (void);
GSGrab * gs_grab_new (void);
-void gs_grab_release (GSGrab *grab,
- gboolean flush);
+void gs_grab_release (GSGrab *grab,
+ gboolean flush);
gboolean gs_grab_grab_window (GSGrab *grab,
GdkWindow *window,
@@ -62,20 +62,20 @@ gboolean gs_grab_grab_window (GSGrab *grab,
gboolean no_pointer_grab,
gboolean hide_cursor);
-gboolean gs_grab_grab_root (GSGrab *grab,
- gboolean no_pointer_grab,
- gboolean hide_cursor);
-gboolean gs_grab_grab_offscreen (GSGrab *grab,
- gboolean no_pointer_grab,
- gboolean hide_cursor);
-
-void gs_grab_move_to_window (GSGrab *grab,
- GdkWindow *window,
- GdkDisplay *display,
+gboolean gs_grab_grab_root (GSGrab *grab,
gboolean no_pointer_grab,
gboolean hide_cursor);
+gboolean gs_grab_grab_offscreen (GSGrab *grab,
+ gboolean no_pointer_grab,
+ gboolean hide_cursor);
+
+void gs_grab_move_to_window (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean no_pointer_grab,
+ gboolean hide_cursor);
-void gs_grab_reset (GSGrab *grab);
+void gs_grab_reset (GSGrab *grab);
G_END_DECLS
diff --git a/src/gs-job.c b/src/gs-job.c
index c15f6bd..d0444e5 100644
--- a/src/gs-job.c
+++ b/src/gs-job.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -59,13 +59,13 @@ typedef enum
struct GSJobPrivate
{
- GtkWidget *widget;
+ GtkWidget *widget;
- GSJobStatus status;
- gint pid;
- guint watch_id;
+ GSJobStatus status;
+ gint pid;
+ guint watch_id;
- char *command;
+ char *command;
};
G_DEFINE_TYPE_WITH_PRIVATE (GSJob, gs_job, G_TYPE_OBJECT)
@@ -73,233 +73,233 @@ G_DEFINE_TYPE_WITH_PRIVATE (GSJob, gs_job, G_TYPE_OBJECT)
static char *
widget_get_id_string (GtkWidget *widget)
{
- char *id = NULL;
+ char *id = NULL;
- g_return_val_if_fail (widget != NULL, NULL);
+ g_return_val_if_fail (widget != NULL, NULL);
- id = g_strdup_printf ("0x%X",
- (guint32)GDK_WINDOW_XID (gtk_widget_get_window (widget)));
- return id;
+ id = g_strdup_printf ("0x%X",
+ (guint32)GDK_WINDOW_XID (gtk_widget_get_window (widget)));
+ return id;
}
static void
gs_job_class_init (GSJobClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_job_finalize;
+ object_class->finalize = gs_job_finalize;
}
static void
gs_job_init (GSJob *job)
{
- job->priv = gs_job_get_instance_private (job);
+ job->priv = gs_job_get_instance_private (job);
}
/* adapted from gspawn.c */
static int
wait_on_child (int pid)
{
- int status;
+ int status;
wait_again:
- if (waitpid (pid, &status, 0) < 0)
- {
- if (errno == EINTR)
- {
- goto wait_again;
- }
- else if (errno == ECHILD)
- {
- ; /* do nothing, child already reaped */
- }
- else
- {
- gs_debug ("waitpid () should not fail in 'GSJob'");
- }
- }
-
- return status;
+ if (waitpid (pid, &status, 0) < 0)
+ {
+ if (errno == EINTR)
+ {
+ goto wait_again;
+ }
+ else if (errno == ECHILD)
+ {
+ ; /* do nothing, child already reaped */
+ }
+ else
+ {
+ gs_debug ("waitpid () should not fail in 'GSJob'");
+ }
+ }
+
+ return status;
}
static void
gs_job_died (GSJob *job)
{
- if (job->priv->pid > 0)
- {
- int exit_status;
-
- gs_debug ("Waiting on process %d", job->priv->pid);
- exit_status = wait_on_child (job->priv->pid);
-
- job->priv->status = GS_JOB_DEAD;
-
- if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0))
- {
- gs_debug ("Wait on child process failed");
- }
- else
- {
- /* exited normally */
- }
- }
- g_spawn_close_pid (job->priv->pid);
- job->priv->pid = 0;
-
- gs_debug ("Job died");
+ if (job->priv->pid > 0)
+ {
+ int exit_status;
+
+ gs_debug ("Waiting on process %d", job->priv->pid);
+ exit_status = wait_on_child (job->priv->pid);
+
+ job->priv->status = GS_JOB_DEAD;
+
+ if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0))
+ {
+ gs_debug ("Wait on child process failed");
+ }
+ else
+ {
+ /* exited normally */
+ }
+ }
+ g_spawn_close_pid (job->priv->pid);
+ job->priv->pid = 0;
+
+ gs_debug ("Job died");
}
static void
gs_job_finalize (GObject *object)
{
- GSJob *job;
+ GSJob *job;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_JOB (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_JOB (object));
- job = GS_JOB (object);
+ job = GS_JOB (object);
- g_return_if_fail (job->priv != NULL);
+ g_return_if_fail (job->priv != NULL);
- if (job->priv->pid > 0)
- {
- signal_pid (job->priv->pid, SIGTERM);
- gs_job_died (job);
- }
+ if (job->priv->pid > 0)
+ {
+ signal_pid (job->priv->pid, SIGTERM);
+ gs_job_died (job);
+ }
- g_free (job->priv->command);
- job->priv->command = NULL;
+ g_free (job->priv->command);
+ job->priv->command = NULL;
- G_OBJECT_CLASS (gs_job_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_job_parent_class)->finalize (object);
}
void
gs_job_set_widget (GSJob *job,
GtkWidget *widget)
{
- g_return_if_fail (job != NULL);
- g_return_if_fail (GS_IS_JOB (job));
-
- if (widget != job->priv->widget)
- {
- job->priv->widget = widget;
-
- /* restart job */
- if (gs_job_is_running (job))
- {
- gs_job_stop (job);
- gs_job_start (job);
- }
- }
+ g_return_if_fail (job != NULL);
+ g_return_if_fail (GS_IS_JOB (job));
+
+ if (widget != job->priv->widget)
+ {
+ job->priv->widget = widget;
+
+ /* restart job */
+ if (gs_job_is_running (job))
+ {
+ gs_job_stop (job);
+ gs_job_start (job);
+ }
+ }
}
gboolean
gs_job_set_command (GSJob *job,
const char *command)
{
- g_return_val_if_fail (GS_IS_JOB (job), FALSE);
+ g_return_val_if_fail (GS_IS_JOB (job), FALSE);
- gs_debug ("Setting command for job: '%s'",
- command != NULL ? command : "NULL");
+ gs_debug ("Setting command for job: '%s'",
+ command != NULL ? command : "NULL");
- g_free (job->priv->command);
- job->priv->command = g_strdup (command);
+ g_free (job->priv->command);
+ job->priv->command = g_strdup (command);
- return TRUE;
+ return TRUE;
}
GSJob *
gs_job_new (void)
{
- GObject *job;
+ GObject *job;
- job = g_object_new (GS_TYPE_JOB, NULL);
+ job = g_object_new (GS_TYPE_JOB, NULL);
- return GS_JOB (job);
+ return GS_JOB (job);
}
GSJob *
-gs_job_new_for_widget (GtkWidget *widget)
+gs_job_new_for_widget (GtkWidget *widget)
{
- GObject *job;
+ GObject *job;
- job = g_object_new (GS_TYPE_JOB, NULL);
+ job = g_object_new (GS_TYPE_JOB, NULL);
- gs_job_set_widget (GS_JOB (job), widget);
+ gs_job_set_widget (GS_JOB (job), widget);
- return GS_JOB (job);
+ return GS_JOB (job);
}
static void
nice_process (int pid,
int nice_level)
{
- g_return_if_fail (pid > 0);
+ g_return_if_fail (pid > 0);
- if (nice_level == 0)
- {
- return;
- }
+ if (nice_level == 0)
+ {
+ return;
+ }
#if defined(HAVE_SETPRIORITY) && defined(PRIO_PROCESS)
- gs_debug ("Setting child process priority to: %d", nice_level);
- if (setpriority (PRIO_PROCESS, pid, nice_level) != 0)
- {
- gs_debug ("setpriority(PRIO_PROCESS, %lu, %d) failed",
- (unsigned long) pid, nice_level);
- }
+ gs_debug ("Setting child process priority to: %d", nice_level);
+ if (setpriority (PRIO_PROCESS, pid, nice_level) != 0)
+ {
+ gs_debug ("setpriority(PRIO_PROCESS, %lu, %d) failed",
+ (unsigned long) pid, nice_level);
+ }
#else
- gs_debug ("don't know how to change process priority on this system.");
+ gs_debug ("don't know how to change process priority on this system.");
#endif
}
static GPtrArray *
get_env_vars (GtkWidget *widget)
{
- GPtrArray *env;
- const gchar *display_name;
- gchar *str;
- int i;
- static const char *allowed_env_vars [] =
- {
- "PATH",
- "SESSION_MANAGER",
- "XAUTHORITY",
- "XAUTHLOCALHOSTNAME",
- "LANG",
- "LANGUAGE",
- "DBUS_SESSION_BUS_ADDRESS"
- };
-
- env = g_ptr_array_new ();
-
- display_name = gdk_display_get_name (gtk_widget_get_display (widget));
- g_ptr_array_add (env, g_strdup_printf ("DISPLAY=%s", display_name));
-
- g_ptr_array_add (env, g_strdup_printf ("HOME=%s",
- g_get_home_dir ()));
-
- for (i = 0; i < G_N_ELEMENTS (allowed_env_vars); i++)
- {
- const char *var;
- const char *val;
- var = allowed_env_vars [i];
- val = g_getenv (var);
- if (val != NULL)
- {
- g_ptr_array_add (env, g_strdup_printf ("%s=%s",
- var,
- val));
- }
- }
-
- str = widget_get_id_string (widget);
- g_ptr_array_add (env, g_strdup_printf ("XSCREENSAVER_WINDOW=%s", str));
- g_free (str);
-
- g_ptr_array_add (env, NULL);
-
- return env;
+ GPtrArray *env;
+ const gchar *display_name;
+ gchar *str;
+ int i;
+ static const char *allowed_env_vars [] =
+ {
+ "PATH",
+ "SESSION_MANAGER",
+ "XAUTHORITY",
+ "XAUTHLOCALHOSTNAME",
+ "LANG",
+ "LANGUAGE",
+ "DBUS_SESSION_BUS_ADDRESS"
+ };
+
+ env = g_ptr_array_new ();
+
+ display_name = gdk_display_get_name (gtk_widget_get_display (widget));
+ g_ptr_array_add (env, g_strdup_printf ("DISPLAY=%s", display_name));
+
+ g_ptr_array_add (env, g_strdup_printf ("HOME=%s",
+ g_get_home_dir ()));
+
+ for (i = 0; i < G_N_ELEMENTS (allowed_env_vars); i++)
+ {
+ const char *var;
+ const char *val;
+ var = allowed_env_vars [i];
+ val = g_getenv (var);
+ if (val != NULL)
+ {
+ g_ptr_array_add (env, g_strdup_printf ("%s=%s",
+ var,
+ val));
+ }
+ }
+
+ str = widget_get_id_string (widget);
+ g_ptr_array_add (env, g_strdup_printf ("XSCREENSAVER_WINDOW=%s", str));
+ g_free (str);
+
+ g_ptr_array_add (env, NULL);
+
+ return env;
}
static gboolean
@@ -310,87 +310,87 @@ spawn_on_widget (GtkWidget *widget,
gpointer user_data,
guint *watch_id)
{
- char **argv;
- GPtrArray *env;
- gboolean result;
- GIOChannel *channel;
- GError *error = NULL;
- int standard_error;
- int child_pid;
- int id;
- int i;
-
- if (command == NULL)
- {
- return FALSE;
- }
-
- if (! g_shell_parse_argv (command, NULL, &argv, &error))
- {
- gs_debug ("Could not parse command: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- env = get_env_vars (widget);
-
- error = NULL;
- result = g_spawn_async_with_pipes (NULL,
- argv,
- (char **)env->pdata,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL,
- NULL,
- &child_pid,
- NULL,
- NULL,
- &standard_error,
- &error);
-
- for (i = 0; i < env->len; i++)
- {
- g_free (g_ptr_array_index (env, i));
- }
- g_ptr_array_free (env, TRUE);
-
- if (! result)
- {
- gs_debug ("Could not start command '%s': %s", command, error->message);
- g_error_free (error);
- g_strfreev (argv);
- return FALSE;
- }
-
- g_strfreev (argv);
-
- nice_process (child_pid, 10);
-
- if (pid != NULL)
- {
- *pid = child_pid;
- }
- else
- {
- g_spawn_close_pid (child_pid);
- }
-
- channel = g_io_channel_unix_new (standard_error);
- g_io_channel_set_close_on_unref (channel, TRUE);
- g_io_channel_set_flags (channel,
- g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
- NULL);
- id = g_io_add_watch (channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- watch_func,
- user_data);
- if (watch_id != NULL)
- {
- *watch_id = id;
- }
-
- g_io_channel_unref (channel);
-
- return result;
+ char **argv;
+ GPtrArray *env;
+ gboolean result;
+ GIOChannel *channel;
+ GError *error = NULL;
+ int standard_error;
+ int child_pid;
+ int id;
+ int i;
+
+ if (command == NULL)
+ {
+ return FALSE;
+ }
+
+ if (! g_shell_parse_argv (command, NULL, &argv, &error))
+ {
+ gs_debug ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ env = get_env_vars (widget);
+
+ error = NULL;
+ result = g_spawn_async_with_pipes (NULL,
+ argv,
+ (char **)env->pdata,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL,
+ NULL,
+ &child_pid,
+ NULL,
+ NULL,
+ &standard_error,
+ &error);
+
+ for (i = 0; i < env->len; i++)
+ {
+ g_free (g_ptr_array_index (env, i));
+ }
+ g_ptr_array_free (env, TRUE);
+
+ if (! result)
+ {
+ gs_debug ("Could not start command '%s': %s", command, error->message);
+ g_error_free (error);
+ g_strfreev (argv);
+ return FALSE;
+ }
+
+ g_strfreev (argv);
+
+ nice_process (child_pid, 10);
+
+ if (pid != NULL)
+ {
+ *pid = child_pid;
+ }
+ else
+ {
+ g_spawn_close_pid (child_pid);
+ }
+
+ channel = g_io_channel_unix_new (standard_error);
+ g_io_channel_set_close_on_unref (channel, TRUE);
+ g_io_channel_set_flags (channel,
+ g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
+ NULL);
+ id = g_io_add_watch (channel,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ watch_func,
+ user_data);
+ if (watch_id != NULL)
+ {
+ *watch_id = id;
+ }
+
+ g_io_channel_unref (channel);
+
+ return result;
}
static gboolean
@@ -398,166 +398,166 @@ command_watch (GIOChannel *source,
GIOCondition condition,
GSJob *job)
{
- GIOStatus status;
- GError *error = NULL;
- gboolean done = FALSE;
-
- g_return_val_if_fail (job != NULL, FALSE);
-
- if (condition & G_IO_IN)
- {
- char *str;
-
- status = g_io_channel_read_line (source, &str, NULL, NULL, &error);
-
- if (status == G_IO_STATUS_NORMAL)
- {
- gs_debug ("command output: %s", str);
-
- }
- else if (status == G_IO_STATUS_EOF)
- {
- done = TRUE;
-
- }
- else if (error != NULL)
- {
- gs_debug ("command error: %s", error->message);
- g_error_free (error);
- }
-
- g_free (str);
- }
- else if (condition & G_IO_HUP)
- {
- done = TRUE;
- }
-
- if (done)
- {
- gs_job_died (job);
-
- job->priv->watch_id = 0;
- return FALSE;
- }
-
- return TRUE;
+ GIOStatus status;
+ GError *error = NULL;
+ gboolean done = FALSE;
+
+ g_return_val_if_fail (job != NULL, FALSE);
+
+ if (condition & G_IO_IN)
+ {
+ char *str;
+
+ status = g_io_channel_read_line (source, &str, NULL, NULL, &error);
+
+ if (status == G_IO_STATUS_NORMAL)
+ {
+ gs_debug ("command output: %s", str);
+
+ }
+ else if (status == G_IO_STATUS_EOF)
+ {
+ done = TRUE;
+
+ }
+ else if (error != NULL)
+ {
+ gs_debug ("command error: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_free (str);
+ }
+ else if (condition & G_IO_HUP)
+ {
+ done = TRUE;
+ }
+
+ if (done)
+ {
+ gs_job_died (job);
+
+ job->priv->watch_id = 0;
+ return FALSE;
+ }
+
+ return TRUE;
}
gboolean
gs_job_is_running (GSJob *job)
{
- gboolean running;
+ gboolean running;
- g_return_val_if_fail (GS_IS_JOB (job), FALSE);
+ g_return_val_if_fail (GS_IS_JOB (job), FALSE);
- running = (job->priv->pid > 0);
+ running = (job->priv->pid > 0);
- return running;
+ return running;
}
gboolean
gs_job_start (GSJob *job)
{
- gboolean result;
-
- g_return_val_if_fail (job != NULL, FALSE);
- g_return_val_if_fail (GS_IS_JOB (job), FALSE);
-
- gs_debug ("starting job");
-
- if (job->priv->pid != 0)
- {
- gs_debug ("Cannot restart active job.");
- return FALSE;
- }
-
- if (job->priv->widget == NULL)
- {
- gs_debug ("Could not start job: screensaver window is not set.");
- return FALSE;
- }
-
- if (job->priv->command == NULL)
- {
- /* no warning here because a NULL command is interpreted
- as a no-op job */
- gs_debug ("No command set for job.");
- return FALSE;
- }
-
- result = spawn_on_widget (job->priv->widget,
- job->priv->command,
- &job->priv->pid,
- (GIOFunc)command_watch,
- job,
- &job->priv->watch_id);
-
- if (result)
- {
- job->priv->status = GS_JOB_RUNNING;
- }
-
- return result;
+ gboolean result;
+
+ g_return_val_if_fail (job != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_JOB (job), FALSE);
+
+ gs_debug ("starting job");
+
+ if (job->priv->pid != 0)
+ {
+ gs_debug ("Cannot restart active job.");
+ return FALSE;
+ }
+
+ if (job->priv->widget == NULL)
+ {
+ gs_debug ("Could not start job: screensaver window is not set.");
+ return FALSE;
+ }
+
+ if (job->priv->command == NULL)
+ {
+ /* no warning here because a NULL command is interpreted
+ as a no-op job */
+ gs_debug ("No command set for job.");
+ return FALSE;
+ }
+
+ result = spawn_on_widget (job->priv->widget,
+ job->priv->command,
+ &job->priv->pid,
+ (GIOFunc)command_watch,
+ job,
+ &job->priv->watch_id);
+
+ if (result)
+ {
+ job->priv->status = GS_JOB_RUNNING;
+ }
+
+ return result;
}
static void
remove_command_watch (GSJob *job)
{
- if (job->priv->watch_id != 0)
- {
- g_source_remove (job->priv->watch_id);
- job->priv->watch_id = 0;
- }
+ if (job->priv->watch_id != 0)
+ {
+ g_source_remove (job->priv->watch_id);
+ job->priv->watch_id = 0;
+ }
}
gboolean
gs_job_stop (GSJob *job)
{
- g_return_val_if_fail (job != NULL, FALSE);
- g_return_val_if_fail (GS_IS_JOB (job), FALSE);
+ g_return_val_if_fail (job != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_JOB (job), FALSE);
- gs_debug ("stopping job");
+ gs_debug ("stopping job");
- if (job->priv->pid == 0)
- {
- gs_debug ("Could not stop job: pid not defined");
- return FALSE;
- }
+ if (job->priv->pid == 0)
+ {
+ gs_debug ("Could not stop job: pid not defined");
+ return FALSE;
+ }
- if (job->priv->status == GS_JOB_STOPPED)
- {
- gs_job_suspend (job, FALSE);
- }
+ if (job->priv->status == GS_JOB_STOPPED)
+ {
+ gs_job_suspend (job, FALSE);
+ }
- remove_command_watch (job);
+ remove_command_watch (job);
- signal_pid (job->priv->pid, SIGTERM);
+ signal_pid (job->priv->pid, SIGTERM);
- job->priv->status = GS_JOB_KILLED;
+ job->priv->status = GS_JOB_KILLED;
- gs_job_died (job);
+ gs_job_died (job);
- return TRUE;
+ return TRUE;
}
gboolean
-gs_job_suspend (GSJob *job,
- gboolean suspend)
+gs_job_suspend (GSJob *job,
+ gboolean suspend)
{
- g_return_val_if_fail (job != NULL, FALSE);
- g_return_val_if_fail (GS_IS_JOB (job), FALSE);
+ g_return_val_if_fail (job != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_JOB (job), FALSE);
- gs_debug ("suspending job");
+ gs_debug ("suspending job");
- if (job->priv->pid == 0)
- {
- return FALSE;
- }
+ if (job->priv->pid == 0)
+ {
+ return FALSE;
+ }
- signal_pid (job->priv->pid, (suspend ? SIGSTOP : SIGCONT));
+ signal_pid (job->priv->pid, (suspend ? SIGSTOP : SIGCONT));
- job->priv->status = (suspend ? GS_JOB_STOPPED : GS_JOB_RUNNING);
+ job->priv->status = (suspend ? GS_JOB_STOPPED : GS_JOB_RUNNING);
- return TRUE;
+ return TRUE;
}
diff --git a/src/gs-job.h b/src/gs-job.h
index b154017..fd23b43 100644
--- a/src/gs-job.h
+++ b/src/gs-job.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -38,13 +38,13 @@ typedef struct GSJobPrivate GSJobPrivate;
typedef struct
{
- GObject parent;
- GSJobPrivate *priv;
+ GObject parent;
+ GSJobPrivate *priv;
} GSJob;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
} GSJobClass;
GType gs_job_get_type (void);
@@ -56,13 +56,13 @@ gboolean gs_job_is_running (GSJob *job);
gboolean gs_job_start (GSJob *job);
gboolean gs_job_stop (GSJob *job);
gboolean gs_job_suspend (GSJob *job,
- gboolean suspend);
+ gboolean suspend);
void gs_job_set_widget (GSJob *job,
- GtkWidget *widget);
+ GtkWidget *widget);
-gboolean gs_job_set_command (GSJob *job,
- const char *command);
+gboolean gs_job_set_command (GSJob *job,
+ const char *command);
G_END_DECLS
diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index 78ee369..3bf6116 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -46,11 +46,11 @@ static void gs_listener_init (GSListener *listen
static void gs_listener_finalize (GObject *object);
static void gs_listener_unregister_handler (DBusConnection *connection,
- void *data);
+ void *data);
static DBusHandlerResult gs_listener_message_handler (DBusConnection *connection,
- DBusMessage *message,
- void *user_data);
+ DBusMessage *message,
+ void *user_data);
#define GS_LISTENER_SERVICE "org.xfce.ScreenSaver"
#define GS_LISTENER_PATH "/org/xfce/ScreenSaver"
@@ -80,35 +80,35 @@ static DBusHandlerResult gs_listener_message_handler (DBusConnection *connec
struct GSListenerPrivate
{
- DBusConnection *connection;
- DBusConnection *system_connection;
+ DBusConnection *connection;
+ DBusConnection *system_connection;
- guint session_idle : 1;
- guint active : 1;
- guint activation_enabled : 1;
- guint throttled : 1;
- GHashTable *inhibitors;
- GHashTable *throttlers;
- time_t active_start;
- time_t session_idle_start;
- char *session_id;
+ guint session_idle : 1;
+ guint active : 1;
+ guint activation_enabled : 1;
+ guint throttled : 1;
+ GHashTable *inhibitors;
+ GHashTable *throttlers;
+ time_t active_start;
+ time_t session_idle_start;
+ char *session_id;
#ifdef WITH_SYSTEMD
- gboolean have_systemd;
+ gboolean have_systemd;
#endif
- guint32 ck_throttle_cookie;
+ guint32 ck_throttle_cookie;
};
typedef struct
{
- int entry_type;
- char *application;
- char *reason;
- char *connection;
- guint32 cookie;
- guint32 foreign_cookie;
- GTimeVal since;
+ int entry_type;
+ char *application;
+ char *reason;
+ char *connection;
+ guint32 cookie;
+ guint32 foreign_cookie;
+ GTimeVal since;
} GSListenerRefEntry;
enum
@@ -153,23 +153,23 @@ G_DEFINE_TYPE_WITH_PRIVATE (GSListener, gs_listener, G_TYPE_OBJECT)
GQuark
gs_listener_error_quark (void)
{
- static GQuark quark = 0;
- if (!quark)
- {
- quark = g_quark_from_static_string ("gs_listener_error");
- }
+ static GQuark quark = 0;
+ if (!quark)
+ {
+ quark = g_quark_from_static_string ("gs_listener_error");
+ }
- return quark;
+ return quark;
}
static void
gs_listener_ref_entry_free (GSListenerRefEntry *entry)
{
- g_free (entry->connection);
- g_free (entry->application);
- g_free (entry->reason);
- g_free (entry);
- entry = NULL;
+ g_free (entry->connection);
+ g_free (entry->application);
+ g_free (entry->reason);
+ g_free (entry);
+ entry = NULL;
}
static void
@@ -182,27 +182,27 @@ static gboolean
send_dbus_message (DBusConnection *connection,
DBusMessage *message)
{
- gboolean is_connected;
- gboolean sent;
+ gboolean is_connected;
+ gboolean sent;
- g_return_val_if_fail (message != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
- if (! connection)
- {
- gs_debug ("There is no valid connection to the message bus");
- return FALSE;
- }
+ if (!connection)
+ {
+ gs_debug ("There is no valid connection to the message bus");
+ return FALSE;
+ }
- is_connected = dbus_connection_get_is_connected (connection);
- if (! is_connected)
- {
- gs_debug ("Not connected to the message bus");
- return FALSE;
- }
+ is_connected = dbus_connection_get_is_connected (connection);
+ if (!is_connected)
+ {
+ gs_debug ("Not connected to the message bus");
+ return FALSE;
+ }
- sent = dbus_connection_send (connection, message, NULL);
+ sent = dbus_connection_send (connection, message, NULL);
- return sent;
+ return sent;
}
static void
@@ -210,78 +210,78 @@ send_dbus_boolean_signal (GSListener *listener,
const char *name,
gboolean value)
{
- DBusMessage *message;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessageIter iter;
- g_return_if_fail (listener != NULL);
+ g_return_if_fail (listener != NULL);
- message = dbus_message_new_signal (GS_LISTENER_PATH,
- GS_LISTENER_SERVICE,
- name);
+ message = dbus_message_new_signal (GS_LISTENER_PATH,
+ GS_LISTENER_SERVICE,
+ name);
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &value);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &value);
- if (! send_dbus_message (listener->priv->connection, message))
- {
- gs_debug ("Could not send %s signal", name);
- }
+ if (! send_dbus_message (listener->priv->connection, message))
+ {
+ gs_debug ("Could not send %s signal", name);
+ }
- dbus_message_unref (message);
+ dbus_message_unref (message);
}
static void
gs_listener_send_signal_active_changed (GSListener *listener)
{
- g_return_if_fail (listener != NULL);
+ g_return_if_fail (listener != NULL);
- gs_debug ("Sending the ActiveChanged(%s) signal on the session bus",
- listener->priv->active ? "TRUE" : "FALSE");
+ gs_debug ("Sending the ActiveChanged(%s) signal on the session bus",
+ listener->priv->active ? "TRUE" : "FALSE");
- send_dbus_boolean_signal (listener, "ActiveChanged", listener->priv->active);
+ send_dbus_boolean_signal (listener, "ActiveChanged", listener->priv->active);
}
static const char *
get_name_for_entry_type (int entry_type)
{
- const char *name;
-
- switch (entry_type)
- {
- case REF_ENTRY_TYPE_INHIBIT:
- name = "inhibitor";
- break;
- case REF_ENTRY_TYPE_THROTTLE:
- name = "throttler";
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- return name;
+ const char *name;
+
+ switch (entry_type)
+ {
+ case REF_ENTRY_TYPE_INHIBIT:
+ name = "inhibitor";
+ break;
+ case REF_ENTRY_TYPE_THROTTLE:
+ name = "throttler";
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return name;
}
static GHashTable *
-get_hash_for_entry_type (GSListener *listener,
- int entry_type)
-{
- GHashTable *hash;
-
- switch (entry_type)
- {
- case REF_ENTRY_TYPE_INHIBIT:
- hash = listener->priv->inhibitors;
- break;
- case REF_ENTRY_TYPE_THROTTLE:
- hash = listener->priv->throttlers;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- return hash;
+get_hash_for_entry_type (GSListener *listener,
+ int entry_type)
+{
+ GHashTable *hash;
+
+ switch (entry_type)
+ {
+ case REF_ENTRY_TYPE_INHIBIT:
+ hash = listener->priv->inhibitors;
+ break;
+ case REF_ENTRY_TYPE_THROTTLE:
+ hash = listener->priv->throttlers;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return hash;
}
static void
@@ -289,283 +289,283 @@ list_ref_entry (gpointer key,
gpointer value,
gpointer user_data)
{
- GSListenerRefEntry *entry;
+ GSListenerRefEntry *entry;
- entry = (GSListenerRefEntry *)value;
+ entry = (GSListenerRefEntry *)value;
- gs_debug ("%s: %s for reason: %s",
- get_name_for_entry_type (entry->entry_type),
- entry->application,
- entry->reason);
+ gs_debug ("%s: %s for reason: %s",
+ get_name_for_entry_type (entry->entry_type),
+ entry->application,
+ entry->reason);
}
static gboolean
listener_ref_entry_is_present (GSListener *listener,
int entry_type)
{
- guint n_entries;
- gboolean is_set;
- GHashTable *hash;
+ guint n_entries;
+ gboolean is_set;
+ GHashTable *hash;
- hash = get_hash_for_entry_type (listener, entry_type);
+ hash = get_hash_for_entry_type (listener, entry_type);
- /* if we aren't inhibited then activate */
- n_entries = 0;
- if (hash != NULL)
- {
- n_entries = g_hash_table_size (hash);
+ /* if we aren't inhibited then activate */
+ n_entries = 0;
+ if (hash != NULL)
+ {
+ n_entries = g_hash_table_size (hash);
- g_hash_table_foreach (hash, list_ref_entry, NULL);
- }
+ g_hash_table_foreach (hash, list_ref_entry, NULL);
+ }
- is_set = (n_entries > 0);
+ is_set = (n_entries > 0);
- return is_set;
+ return is_set;
}
static gboolean
listener_check_activation (GSListener *listener)
{
- gboolean inhibited;
- gboolean res;
+ gboolean inhibited;
+ gboolean res;
- gs_debug ("Checking for activation");
+ gs_debug ("Checking for activation");
- if (! listener->priv->activation_enabled)
- {
- return TRUE;
- }
+ if (! listener->priv->activation_enabled)
+ {
+ return TRUE;
+ }
- if (! listener->priv->session_idle)
- {
- return TRUE;
- }
+ if (! listener->priv->session_idle)
+ {
+ return TRUE;
+ }
- /* if we aren't inhibited then activate */
- inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
+ /* if we aren't inhibited then activate */
+ inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
- res = FALSE;
- if (! inhibited)
- {
- gs_debug ("Trying to activate");
- res = gs_listener_set_active (listener, TRUE);
- }
+ res = FALSE;
+ if (! inhibited)
+ {
+ gs_debug ("Trying to activate");
+ res = gs_listener_set_active (listener, TRUE);
+ }
- return res;
+ return res;
}
static void
gs_listener_set_throttle (GSListener *listener,
gboolean throttled)
{
- g_return_if_fail (GS_IS_LISTENER (listener));
+ g_return_if_fail (GS_IS_LISTENER (listener));
- if (listener->priv->throttled != throttled)
- {
- gs_debug ("Changing throttle status: %d", throttled);
+ if (listener->priv->throttled != throttled)
+ {
+ gs_debug ("Changing throttle status: %d", throttled);
- listener->priv->throttled = throttled;
+ listener->priv->throttled = throttled;
- g_signal_emit (listener, signals [THROTTLE_CHANGED], 0, throttled);
- }
+ g_signal_emit (listener, signals [THROTTLE_CHANGED], 0, throttled);
+ }
}
static gboolean
listener_check_throttle (GSListener *listener)
{
- gboolean throttled;
+ gboolean throttled;
- gs_debug ("Checking for throttle");
+ gs_debug ("Checking for throttle");
- throttled = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_THROTTLE);
+ throttled = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_THROTTLE);
- if (throttled != listener->priv->throttled)
- {
- gs_listener_set_throttle (listener, throttled);
- }
+ if (throttled != listener->priv->throttled)
+ {
+ gs_listener_set_throttle (listener, throttled);
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
listener_set_session_idle_internal (GSListener *listener,
gboolean idle)
{
- listener->priv->session_idle = idle;
+ listener->priv->session_idle = idle;
- if (idle)
- {
- listener->priv->session_idle_start = time (NULL);
- }
- else
- {
- listener->priv->session_idle_start = 0;
- }
+ if (idle)
+ {
+ listener->priv->session_idle_start = time (NULL);
+ }
+ else
+ {
+ listener->priv->session_idle_start = 0;
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
listener_set_active_internal (GSListener *listener,
gboolean active)
{
- listener->priv->active = active;
+ listener->priv->active = active;
- /* if idle not in sync with active, change it */
- if (listener->priv->session_idle != active)
- {
- listener_set_session_idle_internal (listener, active);
- }
+ /* if idle not in sync with active, change it */
+ if (listener->priv->session_idle != active)
+ {
+ listener_set_session_idle_internal (listener, active);
+ }
- if (active)
- {
- listener->priv->active_start = time (NULL);
- }
- else
- {
- listener->priv->active_start = 0;
- }
+ if (active)
+ {
+ listener->priv->active_start = time (NULL);
+ }
+ else
+ {
+ listener->priv->active_start = 0;
+ }
- gs_listener_send_signal_active_changed (listener);
+ gs_listener_send_signal_active_changed (listener);
- return TRUE;
+ return TRUE;
}
gboolean
gs_listener_set_active (GSListener *listener,
gboolean active)
{
- gboolean res;
+ gboolean res;
- g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
+ g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
- if (listener->priv->active == active)
- {
- gs_debug ("Trying to set active state when already: %s",
- active ? "active" : "inactive");
- return FALSE;
- }
+ if (listener->priv->active == active)
+ {
+ gs_debug ("Trying to set active state when already: %s",
+ active ? "active" : "inactive");
+ return FALSE;
+ }
- res = FALSE;
- g_signal_emit (listener, signals [ACTIVE_CHANGED], 0, active, &res);
- if (! res)
- {
- /* if the signal is not handled then we haven't changed state */
- gs_debug ("Active-changed signal not handled");
+ res = FALSE;
+ g_signal_emit (listener, signals [ACTIVE_CHANGED], 0, active, &res);
+ if (! res)
+ {
+ /* if the signal is not handled then we haven't changed state */
+ gs_debug ("Active-changed signal not handled");
- /* clear the idle state */
- if (active)
- {
- listener_set_session_idle_internal (listener, FALSE);
- }
+ /* clear the idle state */
+ if (active)
+ {
+ listener_set_session_idle_internal (listener, FALSE);
+ }
- return FALSE;
- }
+ return FALSE;
+ }
- listener_set_active_internal (listener, active);
+ listener_set_active_internal (listener, active);
- return TRUE;
+ return TRUE;
}
gboolean
gs_listener_set_session_idle (GSListener *listener,
gboolean idle)
{
- gboolean res;
-
- g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
-
- gs_debug ("Setting session idle: %d", idle);
+ gboolean res;
- if (listener->priv->session_idle == idle)
- {
- gs_debug ("Trying to set idle state when already %s",
- idle ? "idle" : "not idle");
- return FALSE;
- }
+ g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
- if (idle)
- {
- gboolean inhibited;
+ gs_debug ("Setting session idle: %d", idle);
- inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
+ if (listener->priv->session_idle == idle)
+ {
+ gs_debug ("Trying to set idle state when already %s",
+ idle ? "idle" : "not idle");
+ return FALSE;
+ }
- /* if we are inhibited then do nothing */
- if (inhibited)
- {
- return FALSE;
- }
- }
+ if (idle)
+ {
+ gboolean inhibited;
- listener->priv->session_idle = idle;
- res = listener_check_activation (listener);
+ inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
- /* if activation fails then don't set idle */
- if (res)
- {
- listener_set_session_idle_internal (listener, idle);
- }
- else
- {
- gs_debug ("Idle activation failed");
- listener->priv->session_idle = !idle;
- }
-
- return res;
+ /* if we are inhibited then do nothing */
+ if (inhibited)
+ {
+ return FALSE;
+ }
+ }
+
+ listener->priv->session_idle = idle;
+ res = listener_check_activation (listener);
+
+ /* if activation fails then don't set idle */
+ if (res)
+ {
+ listener_set_session_idle_internal (listener, idle);
+ }
+ else
+ {
+ gs_debug ("Idle activation failed");
+ listener->priv->session_idle = !idle;
+ }
+
+ return res;
}
gboolean
gs_listener_get_activation_enabled (GSListener *listener)
{
- g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
+ g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
- return listener->priv->activation_enabled;
+ return listener->priv->activation_enabled;
}
gboolean
gs_listener_is_inhibited (GSListener *listener)
{
- gboolean inhibited;
+ gboolean inhibited;
- g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
+ g_return_val_if_fail (GS_IS_LISTENER (listener), FALSE);
- inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
+ inhibited = listener_ref_entry_is_present (listener, REF_ENTRY_TYPE_INHIBIT);
- return inhibited;
+ return inhibited;
}
void
gs_listener_set_activation_enabled (GSListener *listener,
gboolean enabled)
{
- g_return_if_fail (GS_IS_LISTENER (listener));
+ g_return_if_fail (GS_IS_LISTENER (listener));
- if (listener->priv->activation_enabled != enabled)
- {
- listener->priv->activation_enabled = enabled;
- }
+ if (listener->priv->activation_enabled != enabled)
+ {
+ listener->priv->activation_enabled = enabled;
+ }
}
static dbus_bool_t
-listener_property_set_bool (GSListener *listener,
- guint prop_id,
- dbus_bool_t value)
+listener_property_set_bool (GSListener *listener,
+ guint prop_id,
+ dbus_bool_t value)
{
- dbus_bool_t ret;
+ dbus_bool_t ret;
- ret = FALSE;
+ ret = FALSE;
- switch (prop_id)
- {
- case PROP_ACTIVE:
- gs_listener_set_active (listener, value);
- ret = TRUE;
- break;
- default:
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_ACTIVE:
+ gs_listener_set_active (listener, value);
+ ret = TRUE;
+ break;
+ default:
+ break;
+ }
- return ret;
+ return ret;
}
static void
@@ -574,26 +574,26 @@ raise_error (DBusConnection *connection,
const char *error_name,
char *format, ...)
{
- char buf[512];
- DBusMessage *reply;
-
- va_list args;
- va_start (args, format);
- vsnprintf (buf, sizeof (buf), format, args);
- va_end (args);
-
- gs_debug (buf);
- reply = dbus_message_new_error (in_reply_to, error_name, buf);
- if (reply == NULL)
- {
- g_error ("No memory");
- }
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
+ char buf[512];
+ DBusMessage *reply;
+
+ va_list args;
+ va_start (args, format);
+ vsnprintf (buf, sizeof (buf), format, args);
+ va_end (args);
+
+ gs_debug (buf);
+ reply = dbus_message_new_error (in_reply_to, error_name, buf);
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
}
static void
@@ -601,159 +601,159 @@ raise_syntax (DBusConnection *connection,
DBusMessage *in_reply_to,
const char *method_name)
{
- raise_error (connection, in_reply_to,
- GS_LISTENER_SERVICE ".SyntaxError",
- "There is a syntax error in the invocation of the method %s",
- method_name);
+ raise_error (connection, in_reply_to,
+ GS_LISTENER_SERVICE ".SyntaxError",
+ "There is a syntax error in the invocation of the method %s",
+ method_name);
}
static guint32
generate_cookie (void)
{
- guint32 cookie;
+ guint32 cookie;
- cookie = (guint32)g_random_int_range (1, G_MAXINT32);
+ cookie = (guint32)g_random_int_range (1, G_MAXINT32);
- return cookie;
+ return cookie;
}
static guint32
listener_generate_unique_key (GSListener *listener,
int entry_type)
{
- guint32 cookie;
- GHashTable *hash;
+ guint32 cookie;
+ GHashTable *hash;
- hash = get_hash_for_entry_type (listener, entry_type);
+ hash = get_hash_for_entry_type (listener, entry_type);
- do
- {
- cookie = generate_cookie ();
- }
- while (g_hash_table_lookup (hash, &cookie) != NULL);
+ do
+ {
+ cookie = generate_cookie ();
+ }
+ while (g_hash_table_lookup (hash, &cookie) != NULL);
- return cookie;
+ return cookie;
}
static void
listener_ref_entry_check (GSListener *listener,
int entry_type)
{
- switch (entry_type)
- {
- case REF_ENTRY_TYPE_INHIBIT:
- listener_check_activation (listener);
- break;
- case REF_ENTRY_TYPE_THROTTLE:
- listener_check_throttle (listener);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
+ switch (entry_type)
+ {
+ case REF_ENTRY_TYPE_INHIBIT:
+ listener_check_activation (listener);
+ break;
+ case REF_ENTRY_TYPE_THROTTLE:
+ listener_check_throttle (listener);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
}
static void
add_session_inhibit (GSListener *listener,
GSListenerRefEntry *entry)
{
- DBusMessage *message;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter reply_iter;
- DBusError error;
- guint xid;
- guint flags;
-
- g_return_if_fail (listener != NULL);
-
- dbus_error_init (&error);
-
- message = dbus_message_new_method_call (SESSION_NAME,
- SESSION_PATH,
- SESSION_INTERFACE,
- "Inhibit");
- if (message == NULL)
- {
- gs_debug ("Couldn't allocate the dbus message");
- return;
- }
-
- dbus_message_iter_init_append (message, &iter);
- xid = 0;
- flags = 8;
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &entry->application);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &xid);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &entry->reason);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
-
- /* FIXME: use async? */
- reply = dbus_connection_send_with_reply_and_block (listener->priv->connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
-
- if (dbus_error_is_set (&error))
- {
- gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
- dbus_error_free (&error);
- return;
- }
-
- dbus_message_iter_init (reply, &reply_iter);
- dbus_message_iter_get_basic (&reply_iter, &entry->foreign_cookie);
-
- dbus_message_unref (reply);
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter reply_iter;
+ DBusError error;
+ guint xid;
+ guint flags;
+
+ g_return_if_fail (listener != NULL);
+
+ dbus_error_init (&error);
+
+ message = dbus_message_new_method_call (SESSION_NAME,
+ SESSION_PATH,
+ SESSION_INTERFACE,
+ "Inhibit");
+ if (message == NULL)
+ {
+ gs_debug ("Couldn't allocate the dbus message");
+ return;
+ }
+
+ dbus_message_iter_init_append (message, &iter);
+ xid = 0;
+ flags = 8;
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &entry->application);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &xid);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &entry->reason);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
+
+ /* FIXME: use async? */
+ reply = dbus_connection_send_with_reply_and_block (listener->priv->connection,
+ message,
+ -1,
+ &error);
+ dbus_message_unref (message);
+
+ if (dbus_error_is_set (&error))
+ {
+ gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
+ dbus_error_free (&error);
+ return;
+ }
+
+ dbus_message_iter_init (reply, &reply_iter);
+ dbus_message_iter_get_basic (&reply_iter, &entry->foreign_cookie);
+
+ dbus_message_unref (reply);
}
static void
remove_session_inhibit (GSListener *listener,
GSListenerRefEntry *entry)
{
- DBusMessage *message;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusError error;
-
- g_return_if_fail (listener != NULL);
-
- if (entry->foreign_cookie == 0)
- {
- gs_debug ("Can't remove inhibitor from session: Session cookie not set");
- return;
- }
-
- dbus_error_init (&error);
-
- message = dbus_message_new_method_call (SESSION_NAME,
- SESSION_PATH,
- SESSION_INTERFACE,
- "Uninhibit");
- if (message == NULL)
- {
- gs_debug ("Couldn't allocate the dbus message");
- return;
- }
-
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &entry->foreign_cookie);
-
- /* FIXME: use async? */
- reply = dbus_connection_send_with_reply_and_block (listener->priv->connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
-
- if (dbus_error_is_set (&error))
- {
- gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
- dbus_error_free (&error);
- return;
- }
-
- dbus_message_unref (reply);
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusError error;
+
+ g_return_if_fail (listener != NULL);
+
+ if (entry->foreign_cookie == 0)
+ {
+ gs_debug ("Can't remove inhibitor from session: Session cookie not set");
+ return;
+ }
+
+ dbus_error_init (&error);
+
+ message = dbus_message_new_method_call (SESSION_NAME,
+ SESSION_PATH,
+ SESSION_INTERFACE,
+ "Uninhibit");
+ if (message == NULL)
+ {
+ gs_debug ("Couldn't allocate the dbus message");
+ return;
+ }
+
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &entry->foreign_cookie);
+
+ /* FIXME: use async? */
+ reply = dbus_connection_send_with_reply_and_block (listener->priv->connection,
+ message,
+ -1,
+ &error);
+ dbus_message_unref (message);
+
+ if (dbus_error_is_set (&error))
+ {
+ gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
+ dbus_error_free (&error);
+ return;
+ }
+
+ dbus_message_unref (reply);
}
static void
@@ -761,24 +761,24 @@ listener_add_ref_entry (GSListener *listener,
int entry_type,
GSListenerRefEntry *entry)
{
- GHashTable *hash;
+ GHashTable *hash;
- gs_debug ("adding %s from %s for reason '%s' on connection %s",
- get_name_for_entry_type (entry_type),
- entry->application,
- entry->reason,
- entry->connection);
+ gs_debug ("adding %s from %s for reason '%s' on connection %s",
+ get_name_for_entry_type (entry_type),
+ entry->application,
+ entry->reason,
+ entry->connection);
- hash = get_hash_for_entry_type (listener, entry_type);
- g_hash_table_insert (hash, &entry->cookie, entry);
+ hash = get_hash_for_entry_type (listener, entry_type);
+ g_hash_table_insert (hash, &entry->cookie, entry);
- if (entry_type == REF_ENTRY_TYPE_INHIBIT)
- {
- /* proxy inhibit over to xfce session */
- add_session_inhibit (listener, entry);
- }
+ if (entry_type == REF_ENTRY_TYPE_INHIBIT)
+ {
+ /* proxy inhibit over to xfce session */
+ add_session_inhibit (listener, entry);
+ }
- listener_ref_entry_check (listener, entry_type);
+ listener_ref_entry_check (listener, entry_type);
}
static gboolean
@@ -786,44 +786,44 @@ listener_remove_ref_entry (GSListener *listener,
int entry_type,
guint32 cookie)
{
- GHashTable *hash;
- gboolean removed;
- GSListenerRefEntry *entry;
+ GHashTable *hash;
+ gboolean removed;
+ GSListenerRefEntry *entry;
- removed = FALSE;
+ removed = FALSE;
- hash = get_hash_for_entry_type (listener, entry_type);
+ hash = get_hash_for_entry_type (listener, entry_type);
- entry = g_hash_table_lookup (hash, &cookie);
- if (entry == NULL)
- {
- goto out;
- }
+ entry = g_hash_table_lookup (hash, &cookie);
+ if (entry == NULL)
+ {
+ goto out;
+ }
- gs_debug ("removing %s from %s for reason '%s' on connection %s",
- get_name_for_entry_type (entry_type),
- entry->application,
- entry->reason,
- entry->connection);
+ gs_debug ("removing %s from %s for reason '%s' on connection %s",
+ get_name_for_entry_type (entry_type),
+ entry->application,
+ entry->reason,
+ entry->connection);
- if (entry_type == REF_ENTRY_TYPE_INHIBIT)
- {
- /* remove inhibit from xfce session */
- remove_session_inhibit (listener, entry);
- }
+ if (entry_type == REF_ENTRY_TYPE_INHIBIT)
+ {
+ /* remove inhibit from xfce session */
+ remove_session_inhibit (listener, entry);
+ }
- removed = g_hash_table_remove (hash, &cookie);
+ removed = g_hash_table_remove (hash, &cookie);
out:
- if (removed)
- {
- listener_ref_entry_check (listener, entry_type);
- }
- else
- {
- gs_debug ("Cookie %u was not in the list!", cookie);
- }
-
- return removed;
+ if (removed)
+ {
+ listener_ref_entry_check (listener, entry_type);
+ }
+ else
+ {
+ gs_debug ("Cookie %u was not in the list!", cookie);
+ }
+
+ return removed;
}
static void
@@ -831,20 +831,20 @@ accumulate_ref_entry (gpointer key,
GSListenerRefEntry *entry,
DBusMessageIter *iter)
{
- char *description;
- char *time;
+ char *description;
+ char *time;
- time = g_time_val_to_iso8601 (&entry->since);
+ time = g_time_val_to_iso8601 (&entry->since);
- description = g_strdup_printf ("Application=\"%s\"; Since=\"%s\"; Reason=\"%s\";",
- entry->application,
- time,
- entry->reason);
+ description = g_strdup_printf ("Application=\"%s\"; Since=\"%s\"; Reason=\"%s\";",
+ entry->application,
+ time,
+ entry->reason);
- dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &description);
+ dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &description);
- g_free (description);
- g_free (time);
+ g_free (description);
+ g_free (time);
}
static DBusHandlerResult
@@ -853,42 +853,42 @@ listener_dbus_get_ref_entries (GSListener *listener,
DBusConnection *connection,
DBusMessage *message)
{
- DBusMessage *reply;
- GHashTable *hash;
- DBusMessageIter iter;
- DBusMessageIter iter_array;
+ DBusMessage *reply;
+ GHashTable *hash;
+ DBusMessageIter iter;
+ DBusMessageIter iter_array;
- hash = get_hash_for_entry_type (listener, entry_type);
+ hash = get_hash_for_entry_type (listener, entry_type);
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- {
- g_error ("No memory");
- }
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
- dbus_message_iter_init_append (reply, &iter);
- dbus_message_iter_open_container (&iter,
- DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING,
- &iter_array);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_array);
- if (hash != NULL)
- {
- g_hash_table_foreach (hash,
- (GHFunc)accumulate_ref_entry,
- &iter_array);
- }
+ if (hash != NULL)
+ {
+ g_hash_table_foreach (hash,
+ (GHFunc)accumulate_ref_entry,
+ &iter_array);
+ }
- dbus_message_iter_close_container (&iter, &iter_array);
+ dbus_message_iter_close_container (&iter, &iter_array);
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
- dbus_message_unref (reply);
+ dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
#ifdef WITH_CONSOLE_KIT
@@ -899,23 +899,23 @@ listener_add_ck_ref_entry (GSListener *listener,
DBusMessage *message,
guint32 *cookiep)
{
- GSListenerRefEntry *entry;
+ GSListenerRefEntry *entry;
- entry = g_new0 (GSListenerRefEntry, 1);
- entry->entry_type = entry_type;
- entry->connection = g_strdup (dbus_message_get_sender (message));
- entry->cookie = listener_generate_unique_key (listener, entry_type);
- entry->application = g_strdup ("ConsoleKit");
- entry->reason = g_strdup ("Session is not active");
- g_get_current_time (&entry->since);
+ entry = g_new0 (GSListenerRefEntry, 1);
+ entry->entry_type = entry_type;
+ entry->connection = g_strdup (dbus_message_get_sender (message));
+ entry->cookie = listener_generate_unique_key (listener, entry_type);
+ entry->application = g_strdup ("ConsoleKit");
+ entry->reason = g_strdup ("Session is not active");
+ g_get_current_time (&entry->since);
- /* takes ownership of entry */
- listener_add_ref_entry (listener, entry_type, entry);
+ /* takes ownership of entry */
+ listener_add_ref_entry (listener, entry_type, entry);
- if (cookiep != NULL)
- {
- *cookiep = entry->cookie;
- }
+ if (cookiep != NULL)
+ {
+ *cookiep = entry->cookie;
+ }
}
static void
@@ -923,7 +923,7 @@ listener_remove_ck_ref_entry (GSListener *listener,
int entry_type,
guint32 cookie)
{
- listener_remove_ref_entry (listener, entry_type, cookie);
+ listener_remove_ref_entry (listener, entry_type, cookie);
}
#endif
@@ -933,62 +933,62 @@ listener_dbus_add_ref_entry (GSListener *listener,
DBusConnection *connection,
DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- const char *application;
- const char *reason;
- GSListenerRefEntry *entry;
- DBusMessageIter iter;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &application,
- DBUS_TYPE_STRING, &reason,
- DBUS_TYPE_INVALID))
- {
- if (entry_type == REF_ENTRY_TYPE_INHIBIT)
- {
- raise_syntax (connection, message, "Inhibit");
- }
- else if (entry_type == REF_ENTRY_TYPE_THROTTLE)
- {
- raise_syntax (connection, message, "Throttle");
- }
- else
- {
- g_assert_not_reached ();
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- {
- g_error ("No memory");
- }
-
- entry = g_new0 (GSListenerRefEntry, 1);
- entry->entry_type = entry_type;
- entry->connection = g_strdup (dbus_message_get_sender (message));
- entry->cookie = listener_generate_unique_key (listener, entry_type);
- entry->application = g_strdup (application);
- entry->reason = g_strdup (reason);
- g_get_current_time (&entry->since);
-
- listener_add_ref_entry (listener, entry_type, entry);
-
- dbus_message_iter_init_append (reply, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &entry->cookie);
-
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ const char *application;
+ const char *reason;
+ GSListenerRefEntry *entry;
+ DBusMessageIter iter;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &application,
+ DBUS_TYPE_STRING, &reason,
+ DBUS_TYPE_INVALID))
+ {
+ if (entry_type == REF_ENTRY_TYPE_INHIBIT)
+ {
+ raise_syntax (connection, message, "Inhibit");
+ }
+ else if (entry_type == REF_ENTRY_TYPE_THROTTLE)
+ {
+ raise_syntax (connection, message, "Throttle");
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+
+ entry = g_new0 (GSListenerRefEntry, 1);
+ entry->entry_type = entry_type;
+ entry->connection = g_strdup (dbus_message_get_sender (message));
+ entry->cookie = listener_generate_unique_key (listener, entry_type);
+ entry->application = g_strdup (application);
+ entry->reason = g_strdup (reason);
+ g_get_current_time (&entry->since);
+
+ listener_add_ref_entry (listener, entry_type, entry);
+
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &entry->cookie);
+
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -997,123 +997,123 @@ listener_dbus_remove_ref_entry (GSListener *listener,
DBusConnection *connection,
DBusMessage *message)
{
- DBusMessage *reply;
- DBusError error;
- guint32 cookie;
-
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_UINT32, &cookie,
- DBUS_TYPE_INVALID))
- {
- if (entry_type == REF_ENTRY_TYPE_INHIBIT)
- {
- raise_syntax (connection, message, "UnInhibit");
- }
- else if (entry_type == REF_ENTRY_TYPE_THROTTLE)
- {
- raise_syntax (connection, message, "UnThrottle");
- }
- else
- {
- g_assert_not_reached ();
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- g_error ("No memory");
-
- /* FIXME: check sender is from same connection as entry */
- dbus_message_get_sender (message);
-
- listener_remove_ref_entry (listener, entry_type, cookie);
-
- /* FIXME: Pointless? */
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ DBusError error;
+ guint32 cookie;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_UINT32, &cookie,
+ DBUS_TYPE_INVALID))
+ {
+ if (entry_type == REF_ENTRY_TYPE_INHIBIT)
+ {
+ raise_syntax (connection, message, "UnInhibit");
+ }
+ else if (entry_type == REF_ENTRY_TYPE_THROTTLE)
+ {
+ raise_syntax (connection, message, "UnThrottle");
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ g_error ("No memory");
+
+ /* FIXME: check sender is from same connection as entry */
+ dbus_message_get_sender (message);
+
+ listener_remove_ref_entry (listener, entry_type, cookie);
+
+ /* FIXME: Pointless? */
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static gboolean
listener_ref_entry_remove_for_connection (GSListener *listener,
- int entry_type,
- const char *connection)
-{
- gboolean removed;
- GHashTable *hash;
- GHashTableIter iter;
- GSListenerRefEntry *entry;
-
- if (connection == NULL)
- return FALSE;
-
- hash = get_hash_for_entry_type (listener, entry_type);
-
- removed = FALSE;
- g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry))
- {
- if (entry->connection != NULL &&
- strcmp (connection, entry->connection) == 0)
- {
- gs_debug ("removing %s from %s for reason '%s' on connection %s",
- get_name_for_entry_type (entry->entry_type),
- entry->application,
- entry->reason,
- entry->connection);
-
- if (entry->entry_type == REF_ENTRY_TYPE_INHIBIT)
- {
- /* remove inhibit from xfce session */
- remove_session_inhibit (listener, entry);
- }
-
- g_hash_table_iter_remove (&iter);
- removed = TRUE;
- }
- }
-
- return removed;
+ int entry_type,
+ const char *connection)
+{
+ gboolean removed;
+ GHashTable *hash;
+ GHashTableIter iter;
+ GSListenerRefEntry *entry;
+
+ if (connection == NULL)
+ return FALSE;
+
+ hash = get_hash_for_entry_type (listener, entry_type);
+
+ removed = FALSE;
+ g_hash_table_iter_init (&iter, hash);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry))
+ {
+ if (entry->connection != NULL &&
+ strcmp (connection, entry->connection) == 0)
+ {
+ gs_debug ("removing %s from %s for reason '%s' on connection %s",
+ get_name_for_entry_type (entry->entry_type),
+ entry->application,
+ entry->reason,
+ entry->connection);
+
+ if (entry->entry_type == REF_ENTRY_TYPE_INHIBIT)
+ {
+ /* remove inhibit from xfce session */
+ remove_session_inhibit (listener, entry);
+ }
+
+ g_hash_table_iter_remove (&iter);
+ removed = TRUE;
+ }
+ }
+
+ return removed;
}
static void
listener_service_deleted (GSListener *listener,
DBusMessage *message)
{
- const char *old_service_name;
- const char *new_service_name;
- gboolean removed;
-
- if (! dbus_message_get_args (message, NULL,
- DBUS_TYPE_STRING, &old_service_name,
- DBUS_TYPE_STRING, &new_service_name,
- DBUS_TYPE_INVALID))
- {
- g_error ("Invalid NameOwnerChanged signal from bus!");
- return;
- }
-
- gs_debug ("DBUS service deleted: %s", new_service_name);
-
- removed = listener_ref_entry_remove_for_connection (listener, REF_ENTRY_TYPE_THROTTLE, new_service_name);
- if (removed)
- {
- listener_ref_entry_check (listener, REF_ENTRY_TYPE_THROTTLE);
- }
-
- removed = listener_ref_entry_remove_for_connection (listener, REF_ENTRY_TYPE_INHIBIT, new_service_name);
- if (removed)
- {
- listener_ref_entry_check (listener, REF_ENTRY_TYPE_INHIBIT);
- }
+ const char *old_service_name;
+ const char *new_service_name;
+ gboolean removed;
+
+ if (! dbus_message_get_args (message, NULL,
+ DBUS_TYPE_STRING, &old_service_name,
+ DBUS_TYPE_STRING, &new_service_name,
+ DBUS_TYPE_INVALID))
+ {
+ g_error ("Invalid NameOwnerChanged signal from bus!");
+ return;
+ }
+
+ gs_debug ("DBUS service deleted: %s", new_service_name);
+
+ removed = listener_ref_entry_remove_for_connection (listener, REF_ENTRY_TYPE_THROTTLE, new_service_name);
+ if (removed)
+ {
+ listener_ref_entry_check (listener, REF_ENTRY_TYPE_THROTTLE);
+ }
+
+ removed = listener_ref_entry_remove_for_connection (listener, REF_ENTRY_TYPE_INHIBIT, new_service_name);
+ if (removed)
+ {
+ listener_ref_entry_check (listener, REF_ENTRY_TYPE_INHIBIT);
+ }
}
@@ -1122,27 +1122,27 @@ raise_property_type_error (DBusConnection *connection,
DBusMessage *in_reply_to,
const char *device_id)
{
- char buf [512];
- DBusMessage *reply;
-
- snprintf (buf, 511,
- "Type mismatch setting property with id %s",
- device_id);
- gs_debug (buf);
-
- reply = dbus_message_new_error (in_reply_to,
- TYPE_MISMATCH_ERROR,
- buf);
- if (reply == NULL)
- {
- g_error ("No memory");
- }
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
+ char buf [512];
+ DBusMessage *reply;
+
+ snprintf (buf, 511,
+ "Type mismatch setting property with id %s",
+ device_id);
+ gs_debug (buf);
+
+ reply = dbus_message_new_error (in_reply_to,
+ TYPE_MISMATCH_ERROR,
+ buf);
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
}
static DBusHandlerResult
@@ -1151,53 +1151,53 @@ listener_set_property (GSListener *listener,
DBusMessage *message,
guint prop_id)
{
- const char *path;
- int type;
- gboolean rc;
- DBusMessageIter iter;
- DBusMessage *reply;
-
- path = dbus_message_get_path (message);
-
- dbus_message_iter_init (message, &iter);
- type = dbus_message_iter_get_arg_type (&iter);
- rc = FALSE;
-
- switch (type)
- {
- case DBUS_TYPE_BOOLEAN:
- {
- dbus_bool_t v;
- dbus_message_iter_get_basic (&iter, &v);
- rc = listener_property_set_bool (listener, prop_id, v);
- break;
- }
- default:
- gs_debug ("Unsupported property type %d", type);
- break;
- }
-
- if (! rc)
- {
- raise_property_type_error (connection, message, path);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- reply = dbus_message_new_method_return (message);
-
- if (reply == NULL)
- {
- g_error ("No memory");
- }
-
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ const char *path;
+ int type;
+ gboolean rc;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+
+ path = dbus_message_get_path (message);
+
+ dbus_message_iter_init (message, &iter);
+ type = dbus_message_iter_get_arg_type (&iter);
+ rc = FALSE;
+
+ switch (type)
+ {
+ case DBUS_TYPE_BOOLEAN:
+ {
+ dbus_bool_t v;
+ dbus_message_iter_get_basic (&iter, &v);
+ rc = listener_property_set_bool (listener, prop_id, v);
+ break;
+ }
+ default:
+ gs_debug ("Unsupported property type %d", type);
+ break;
+ }
+
+ if (! rc)
+ {
+ raise_property_type_error (connection, message, path);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return (message);
+
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -1206,38 +1206,38 @@ listener_get_property (GSListener *listener,
DBusMessage *message,
guint prop_id)
{
- DBusMessageIter iter;
- DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessage *reply;
- reply = dbus_message_new_method_return (message);
+ reply = dbus_message_new_method_return (message);
- dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_init_append (reply, &iter);
- if (reply == NULL)
- g_error ("No memory");
+ if (reply == NULL)
+ g_error ("No memory");
- switch (prop_id)
- {
- case PROP_ACTIVE:
- {
- dbus_bool_t b;
- b = listener->priv->active;
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &b);
- }
- break;
- default:
- gs_debug ("Unsupported property id %u", prop_id);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_ACTIVE:
+ {
+ dbus_bool_t b;
+ b = listener->priv->active;
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &b);
+ }
+ break;
+ default:
+ gs_debug ("Unsupported property id %u", prop_id);
+ break;
+ }
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
- dbus_message_unref (reply);
+ dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -1245,56 +1245,56 @@ listener_get_active_time (GSListener *listener,
DBusConnection *connection,
DBusMessage *message)
{
- DBusMessageIter iter;
- DBusMessage *reply;
- dbus_uint32_t secs;
-
- reply = dbus_message_new_method_return (message);
-
- dbus_message_iter_init_append (reply, &iter);
-
- if (reply == NULL)
- {
- g_error ("No memory");
- }
-
- if (listener->priv->active)
- {
- time_t now = time (NULL);
-
- if (now < listener->priv->active_start)
- {
- /* shouldn't happen */
- gs_debug ("Active start time is in the future");
- secs = 0;
- }
- else if (listener->priv->active_start <= 0)
- {
- /* shouldn't happen */
- gs_debug ("Active start time was not set");
- secs = 0;
- }
- else
- {
- secs = now - listener->priv->active_start;
- }
- }
- else
- {
- secs = 0;
- }
-
- gs_debug ("Returning screensaver active for %u seconds", secs);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &secs);
-
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ dbus_uint32_t secs;
+
+ reply = dbus_message_new_method_return (message);
+
+ dbus_message_iter_init_append (reply, &iter);
+
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+
+ if (listener->priv->active)
+ {
+ time_t now = time (NULL);
+
+ if (now < listener->priv->active_start)
+ {
+ /* shouldn't happen */
+ gs_debug ("Active start time is in the future");
+ secs = 0;
+ }
+ else if (listener->priv->active_start <= 0)
+ {
+ /* shouldn't happen */
+ gs_debug ("Active start time was not set");
+ secs = 0;
+ }
+ else
+ {
+ secs = now - listener->priv->active_start;
+ }
+ }
+ else
+ {
+ secs = 0;
+ }
+
+ gs_debug ("Returning screensaver active for %u seconds", secs);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &secs);
+
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -1302,49 +1302,49 @@ listener_show_message (GSListener *listener,
DBusConnection *connection,
DBusMessage *message)
{
- DBusMessageIter iter;
- DBusMessage *reply;
- DBusError error;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError error;
- reply = dbus_message_new_method_return (message);
+ reply = dbus_message_new_method_return (message);
- dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_init_append (reply, &iter);
- if (reply == NULL)
- {
- g_error ("No memory");
- }
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
- if (listener->priv->active)
- {
- char *summary;
- char *body;
- char *icon;
+ if (listener->priv->active)
+ {
+ char *summary;
+ char *body;
+ char *icon;
- /* if we're not active we ignore the request */
+ /* if we're not active we ignore the request */
- dbus_error_init (&error);
- if (! dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &summary,
- DBUS_TYPE_STRING, &body,
- DBUS_TYPE_STRING, &icon,
- DBUS_TYPE_INVALID))
- {
- raise_syntax (connection, message, "ShowMessage");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &summary,
+ DBUS_TYPE_STRING, &body,
+ DBUS_TYPE_STRING, &icon,
+ DBUS_TYPE_INVALID))
+ {
+ raise_syntax (connection, message, "ShowMessage");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
- g_signal_emit (listener, signals [SHOW_MESSAGE], 0, summary, body, icon);
- }
+ g_signal_emit (listener, signals [SHOW_MESSAGE], 0, summary, body, icon);
+ }
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
- dbus_message_unref (reply);
+ dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -1352,91 +1352,91 @@ do_introspect (DBusConnection *connection,
DBusMessage *message,
dbus_bool_t local_interface)
{
- DBusMessage *reply;
- GString *xml;
- char *xml_string;
-
- /* standard header */
- xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
- "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
- "<node>\n"
- " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
- " <method name=\"Introspect\">\n"
- " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
- " </method>\n"
- " </interface>\n");
-
- /* ScreenSaver interface */
- xml = g_string_append (xml,
- " <interface name=\"org.xfce.ScreenSaver\">\n"
- " <method name=\"Lock\">\n"
- " </method>\n"
- " <method name=\"Cycle\">\n"
- " </method>\n"
- " <method name=\"SimulateUserActivity\">\n"
- " </method>\n"
- " <method name=\"Inhibit\">\n"
- " <arg name=\"application_name\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"reason\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"cookie\" direction=\"out\" type=\"u\"/>\n"
- " </method>\n"
- " <method name=\"UnInhibit\">\n"
- " <arg name=\"cookie\" direction=\"in\" type=\"u\"/>\n"
- " </method>\n"
- " <method name=\"GetInhibitors\">\n"
- " <arg name=\"list\" direction=\"out\" type=\"as\"/>\n"
- " </method>\n"
- " <method name=\"Throttle\">\n"
- " <arg name=\"application_name\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"reason\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"cookie\" direction=\"out\" type=\"u\"/>\n"
- " </method>\n"
- " <method name=\"UnThrottle\">\n"
- " <arg name=\"cookie\" direction=\"in\" type=\"u\"/>\n"
- " </method>\n"
- " <method name=\"GetActive\">\n"
- " <arg name=\"value\" direction=\"out\" type=\"b\"/>\n"
- " </method>\n"
- " <method name=\"GetActiveTime\">\n"
- " <arg name=\"seconds\" direction=\"out\" type=\"u\"/>\n"
- " </method>\n"
- " <method name=\"SetActive\">\n"
- " <arg name=\"value\" direction=\"in\" type=\"b\"/>\n"
- " </method>\n"
- " <method name=\"ShowMessage\">\n"
- " <arg name=\"summary\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"body\" direction=\"in\" type=\"s\"/>\n"
- " <arg name=\"icon\" direction=\"in\" type=\"s\"/>\n"
- " </method>\n"
- " <signal name=\"ActiveChanged\">\n"
- " <arg name=\"new_value\" type=\"b\"/>\n"
- " </signal>\n"
- " </interface>\n");
-
- reply = dbus_message_new_method_return (message);
-
- xml = g_string_append (xml, "</node>\n");
- xml_string = g_string_free (xml, FALSE);
-
- dbus_message_append_args (reply,
- DBUS_TYPE_STRING, &xml_string,
- DBUS_TYPE_INVALID);
-
- g_free (xml_string);
-
- if (reply == NULL)
- {
- g_error ("No memory");
- }
-
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ DBusMessage *reply;
+ GString *xml;
+ char *xml_string;
+
+ /* standard header */
+ xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+ "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+ "<node>\n"
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+ " <method name=\"Introspect\">\n"
+ " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
+ " </method>\n"
+ " </interface>\n");
+
+ /* ScreenSaver interface */
+ xml = g_string_append (xml,
+ " <interface name=\"org.xfce.ScreenSaver\">\n"
+ " <method name=\"Lock\">\n"
+ " </method>\n"
+ " <method name=\"Cycle\">\n"
+ " </method>\n"
+ " <method name=\"SimulateUserActivity\">\n"
+ " </method>\n"
+ " <method name=\"Inhibit\">\n"
+ " <arg name=\"application_name\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"reason\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"cookie\" direction=\"out\" type=\"u\"/>\n"
+ " </method>\n"
+ " <method name=\"UnInhibit\">\n"
+ " <arg name=\"cookie\" direction=\"in\" type=\"u\"/>\n"
+ " </method>\n"
+ " <method name=\"GetInhibitors\">\n"
+ " <arg name=\"list\" direction=\"out\" type=\"as\"/>\n"
+ " </method>\n"
+ " <method name=\"Throttle\">\n"
+ " <arg name=\"application_name\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"reason\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"cookie\" direction=\"out\" type=\"u\"/>\n"
+ " </method>\n"
+ " <method name=\"UnThrottle\">\n"
+ " <arg name=\"cookie\" direction=\"in\" type=\"u\"/>\n"
+ " </method>\n"
+ " <method name=\"GetActive\">\n"
+ " <arg name=\"value\" direction=\"out\" type=\"b\"/>\n"
+ " </method>\n"
+ " <method name=\"GetActiveTime\">\n"
+ " <arg name=\"seconds\" direction=\"out\" type=\"u\"/>\n"
+ " </method>\n"
+ " <method name=\"SetActive\">\n"
+ " <arg name=\"value\" direction=\"in\" type=\"b\"/>\n"
+ " </method>\n"
+ " <method name=\"ShowMessage\">\n"
+ " <arg name=\"summary\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"body\" direction=\"in\" type=\"s\"/>\n"
+ " <arg name=\"icon\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
+ " <signal name=\"ActiveChanged\">\n"
+ " <arg name=\"new_value\" type=\"b\"/>\n"
+ " </signal>\n"
+ " </interface>\n");
+
+ reply = dbus_message_new_method_return (message);
+
+ xml = g_string_append (xml, "</node>\n");
+ xml_string = g_string_free (xml, FALSE);
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &xml_string,
+ DBUS_TYPE_INVALID);
+
+ g_free (xml_string);
+
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -1445,170 +1445,170 @@ listener_dbus_handle_session_message (DBusConnection *connection,
void *user_data,
dbus_bool_t local_interface)
{
- GSListener *listener = GS_LISTENER (user_data);
+ GSListener *listener = GS_LISTENER (user_data);
#if 0
- g_message ("obj_path=%s interface=%s method=%s destination=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message),
- dbus_message_get_destination (message));
+ g_message ("obj_path=%s interface=%s method=%s destination=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message),
+ dbus_message_get_destination (message));
#endif
- g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Lock"))
- {
- g_signal_emit (listener, signals [LOCK], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Quit"))
- {
- g_signal_emit (listener, signals [QUIT], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Cycle"))
- {
- g_signal_emit (listener, signals [CYCLE], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Inhibit"))
- {
- return listener_dbus_add_ref_entry (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "UnInhibit"))
- {
- return listener_dbus_remove_ref_entry (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetInhibitors"))
- {
- return listener_dbus_get_ref_entries (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Throttle"))
- {
- return listener_dbus_add_ref_entry (listener, REF_ENTRY_TYPE_THROTTLE, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "UnThrottle"))
- {
- return listener_dbus_remove_ref_entry (listener, REF_ENTRY_TYPE_THROTTLE, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "SetActive"))
- {
- return listener_set_property (listener, connection, message, PROP_ACTIVE);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetActive"))
- {
- return listener_get_property (listener, connection, message, PROP_ACTIVE);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetActiveTime"))
- {
- return listener_get_active_time (listener, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "ShowMessage"))
- {
- return listener_show_message (listener, connection, message);
- }
- if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "SimulateUserActivity"))
- {
- g_signal_emit (listener, signals [SIMULATE_USER_ACTIVITY], 0);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect"))
- {
- return do_introspect (connection, message, local_interface);
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+ g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Lock"))
+ {
+ g_signal_emit (listener, signals [LOCK], 0);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Quit"))
+ {
+ g_signal_emit (listener, signals [QUIT], 0);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Cycle"))
+ {
+ g_signal_emit (listener, signals [CYCLE], 0);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Inhibit"))
+ {
+ return listener_dbus_add_ref_entry (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "UnInhibit"))
+ {
+ return listener_dbus_remove_ref_entry (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetInhibitors"))
+ {
+ return listener_dbus_get_ref_entries (listener, REF_ENTRY_TYPE_INHIBIT, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Throttle"))
+ {
+ return listener_dbus_add_ref_entry (listener, REF_ENTRY_TYPE_THROTTLE, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "UnThrottle"))
+ {
+ return listener_dbus_remove_ref_entry (listener, REF_ENTRY_TYPE_THROTTLE, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "SetActive"))
+ {
+ return listener_set_property (listener, connection, message, PROP_ACTIVE);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetActive"))
+ {
+ return listener_get_property (listener, connection, message, PROP_ACTIVE);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "GetActiveTime"))
+ {
+ return listener_get_active_time (listener, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "ShowMessage"))
+ {
+ return listener_show_message (listener, connection, message);
+ }
+ if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "SimulateUserActivity"))
+ {
+ g_signal_emit (listener, signals [SIMULATE_USER_ACTIVITY], 0);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect"))
+ {
+ return do_introspect (connection, message, local_interface);
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static gboolean
_listener_message_path_is_our_session (GSListener *listener,
DBusMessage *message)
{
- const char *ssid;
+ const char *ssid;
- ssid = dbus_message_get_path (message);
+ ssid = dbus_message_get_path (message);
- if (ssid == NULL)
- return FALSE;
+ if (ssid == NULL)
+ return FALSE;
- if (listener->priv->session_id == NULL)
- return FALSE;
+ if (listener->priv->session_id == NULL)
+ return FALSE;
- if (strcmp (ssid, listener->priv->session_id) == 0)
- return TRUE;
+ if (strcmp (ssid, listener->priv->session_id) == 0)
+ return TRUE;
- return FALSE;
+ return FALSE;
}
#ifdef WITH_SYSTEMD
static gboolean
properties_changed_match (DBusMessage *message,
- const char *property)
+ const char *property)
{
- DBusMessageIter iter, sub, sub2;
+ DBusMessageIter iter, sub, sub2;
- /* Checks whether a certain property is listed in the
- * specified PropertiesChanged message */
+ /* Checks whether a certain property is listed in the
+ * specified PropertiesChanged message */
- if (!dbus_message_iter_init (message, &iter))
- goto failure;
+ if (!dbus_message_iter_init (message, &iter))
+ goto failure;
- /* Jump over interface name */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
- goto failure;
+ /* Jump over interface name */
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
+ goto failure;
- dbus_message_iter_next (&iter);
+ dbus_message_iter_next (&iter);
- /* First, iterate through the changed properties array */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY ||
- dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_DICT_ENTRY)
- goto failure;
+ /* First, iterate through the changed properties array */
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY ||
+ dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_DICT_ENTRY)
+ goto failure;
- dbus_message_iter_recurse (&iter, &sub);
- while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) {
- const char *name;
+ dbus_message_iter_recurse (&iter, &sub);
+ while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) {
+ const char *name;
- if (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_DICT_ENTRY)
- goto failure;
+ if (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_DICT_ENTRY)
+ goto failure;
- dbus_message_iter_recurse (&sub, &sub2);
- dbus_message_iter_get_basic (&sub2, &name);
+ dbus_message_iter_recurse (&sub, &sub2);
+ dbus_message_iter_get_basic (&sub2, &name);
- if (strcmp (name, property) == 0)
- return TRUE;
+ if (strcmp (name, property) == 0)
+ return TRUE;
- dbus_message_iter_next (&sub);
- }
+ dbus_message_iter_next (&sub);
+ }
- dbus_message_iter_next (&iter);
+ dbus_message_iter_next (&iter);
- /* Second, iterate through the invalidated properties array */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY ||
- dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_STRING)
- goto failure;
+ /* Second, iterate through the invalidated properties array */
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY ||
+ dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_STRING)
+ goto failure;
- dbus_message_iter_recurse (&iter, &sub);
- while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) {
- const char *name;
+ dbus_message_iter_recurse (&iter, &sub);
+ while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) {
+ const char *name;
- if (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_STRING)
- goto failure;
+ if (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_STRING)
+ goto failure;
- dbus_message_iter_get_basic (&sub, &name);
+ dbus_message_iter_get_basic (&sub, &name);
- if (strcmp (name, property) == 0)
- return TRUE;
+ if (strcmp (name, property) == 0)
+ return TRUE;
- dbus_message_iter_next (&sub);
- }
+ dbus_message_iter_next (&sub);
+ }
- return FALSE;
+ return FALSE;
failure:
- gs_debug ("Failed to decode PropertiesChanged message.");
- return FALSE;
+ gs_debug ("Failed to decode PropertiesChanged message.");
+ return FALSE;
}
#endif
@@ -1618,179 +1618,179 @@ listener_dbus_handle_system_message (DBusConnection *connection,
void *user_data,
dbus_bool_t local_interface)
{
- GSListener *listener = GS_LISTENER (user_data);
+ GSListener *listener = GS_LISTENER (user_data);
- g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+ g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+ g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
#if 1
- gs_debug ("obj_path=%s interface=%s method=%s destination=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message),
- dbus_message_get_destination (message));
+ gs_debug ("obj_path=%s interface=%s method=%s destination=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message),
+ dbus_message_get_destination (message));
#endif
#ifdef WITH_SYSTEMD
- if (listener->priv->have_systemd) {
-
- if (dbus_message_is_signal (message, SYSTEMD_LOGIND_SESSION_INTERFACE, "Unlock")) {
- if (_listener_message_path_is_our_session (listener, message)) {
- gs_debug ("systemd requested session unlock");
- gs_listener_set_active (listener, FALSE);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal (message, SYSTEMD_LOGIND_SESSION_INTERFACE, "Lock")) {
- if (_listener_message_path_is_our_session (listener, message)) {
- gs_debug ("systemd requested session lock");
- g_signal_emit (listener, signals [LOCK], 0);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal (message, DBUS_INTERFACE_PROPERTIES, "PropertiesChanged")) {
-
- if (_listener_message_path_is_our_session (listener, message)) {
-
- if (properties_changed_match (message, "Active")) {
- gboolean new_active;
-
- /* Instead of going via the
- * bus to read the new
- * property state, let's
- * shortcut this and ask
- * directly the low-level
- * information */
-
- new_active = sd_session_is_active (listener->priv->session_id) != 0;
- if (new_active)
- g_signal_emit (listener, signals [SIMULATE_USER_ACTIVITY], 0);
- }
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+ if (listener->priv->have_systemd) {
+
+ if (dbus_message_is_signal (message, SYSTEMD_LOGIND_SESSION_INTERFACE, "Unlock")) {
+ if (_listener_message_path_is_our_session (listener, message)) {
+ gs_debug ("systemd requested session unlock");
+ gs_listener_set_active (listener, FALSE);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal (message, SYSTEMD_LOGIND_SESSION_INTERFACE, "Lock")) {
+ if (_listener_message_path_is_our_session (listener, message)) {
+ gs_debug ("systemd requested session lock");
+ g_signal_emit (listener, signals [LOCK], 0);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal (message, DBUS_INTERFACE_PROPERTIES, "PropertiesChanged")) {
+
+ if (_listener_message_path_is_our_session (listener, message)) {
+
+ if (properties_changed_match (message, "Active")) {
+ gboolean new_active;
+
+ /* Instead of going via the
+ * bus to read the new
+ * property state, let's
+ * shortcut this and ask
+ * directly the low-level
+ * information */
+
+ new_active = sd_session_is_active (listener->priv->session_id) != 0;
+ if (new_active)
+ g_signal_emit (listener, signals [SIMULATE_USER_ACTIVITY], 0);
+ }
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
#endif
#ifdef WITH_CONSOLE_KIT
- if (dbus_message_is_signal (message, HAL_DEVICE_INTERFACE, "Condition"))
- {
- DBusError error;
- const char *event;
- const char *keyname;
-
- dbus_error_init (&error);
- if (dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &event,
- DBUS_TYPE_STRING, &keyname,
- DBUS_TYPE_INVALID))
- {
- if ((event && strcmp (event, "ButtonPressed") == 0) &&
- (keyname && strcmp (keyname, "coffee") == 0))
- {
- gs_debug ("Coffee key was pressed - locking");
- g_signal_emit (listener, signals [LOCK], 0);
- }
- }
-
- if (dbus_error_is_set (&error))
- {
- dbus_error_free (&error);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
-
- else if (dbus_message_is_signal (message, CK_SESSION_INTERFACE, "Unlock"))
- {
- if (_listener_message_path_is_our_session (listener, message))
- {
- gs_debug ("Console kit requested session unlock");
- gs_listener_set_active (listener, FALSE);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else if (dbus_message_is_signal (message, CK_SESSION_INTERFACE, "Lock"))
- {
- if (_listener_message_path_is_our_session (listener, message))
- {
- gs_debug ("ConsoleKit requested session lock");
- g_signal_emit (listener, signals [LOCK], 0);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else if (dbus_message_is_signal (message, CK_SESSION_INTERFACE, "ActiveChanged"))
- {
- /* NB that `ActiveChanged' refers to the active
- * session in ConsoleKit terminology - ie which
- * session is currently displayed on the screen.
- * xfce4-screensaver uses `active' to mean `is the
- * screensaver active' (ie, is the screen locked) but
- * that's not what we're referring to here.
- */
-
- if (_listener_message_path_is_our_session (listener, message))
- {
- DBusError error;
- dbus_bool_t new_active;
-
- dbus_error_init (&error);
- if (dbus_message_get_args (message, &error,
- DBUS_TYPE_BOOLEAN, &new_active,
- DBUS_TYPE_INVALID))
- {
- gs_debug ("ConsoleKit notified ActiveChanged %d", new_active);
-
- /* when we aren't active add an implicit throttle from CK
- * when we become active remove the throttle and poke the lock */
- if (new_active)
- {
- if (listener->priv->ck_throttle_cookie != 0)
- {
- listener_remove_ck_ref_entry (listener,
- REF_ENTRY_TYPE_THROTTLE,
- listener->priv->ck_throttle_cookie);
- listener->priv->ck_throttle_cookie = 0;
- }
-
- g_signal_emit (listener, signals [SIMULATE_USER_ACTIVITY], 0);
- }
- else
- {
- if (listener->priv->ck_throttle_cookie != 0)
- {
- g_warning ("ConsoleKit throttle already set");
- listener_remove_ck_ref_entry (listener,
- REF_ENTRY_TYPE_THROTTLE,
- listener->priv->ck_throttle_cookie);
- listener->priv->ck_throttle_cookie = 0;
- }
-
- listener_add_ck_ref_entry (listener,
- REF_ENTRY_TYPE_THROTTLE,
- connection,
- message,
- &listener->priv->ck_throttle_cookie);
- }
- }
-
- if (dbus_error_is_set (&error))
- {
- dbus_error_free (&error);
- }
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ if (dbus_message_is_signal (message, HAL_DEVICE_INTERFACE, "Condition"))
+ {
+ DBusError error;
+ const char *event;
+ const char *keyname;
+
+ dbus_error_init (&error);
+ if (dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &event,
+ DBUS_TYPE_STRING, &keyname,
+ DBUS_TYPE_INVALID))
+ {
+ if ((event && strcmp (event, "ButtonPressed") == 0) &&
+ (keyname && strcmp (keyname, "coffee") == 0))
+ {
+ gs_debug ("Coffee key was pressed - locking");
+ g_signal_emit (listener, signals [LOCK], 0);
+ }
+ }
+
+ if (dbus_error_is_set (&error))
+ {
+ dbus_error_free (&error);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+
+ else if (dbus_message_is_signal (message, CK_SESSION_INTERFACE, "Unlock"))
+ {
+ if (_listener_message_path_is_our_session (listener, message))
+ {
+ gs_debug ("Console kit requested session unlock");
+ gs_listener_set_active (listener, FALSE);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else if (dbus_message_is_signal (message, CK_SESSION_INTERFACE, "Lock"))
+ {
+ if (_listener_message_path_is_our_session (listener, message))
+ {
+ gs_debug ("ConsoleKit requested session lock");
+ g_signal_emit (listener, signals [LOCK], 0);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else if (dbus_message_is_signal (message, CK_SESSION_INTERFACE, "ActiveChanged"))
+ {
+ /* NB that `ActiveChanged' refers to the active
+ * session in ConsoleKit terminology - ie which
+ * session is currently displayed on the screen.
+ * xfce4-screensaver uses `active' to mean `is the
+ * screensaver active' (ie, is the screen locked) but
+ * that's not what we're referring to here.
+ */
+
+ if (_listener_message_path_is_our_session (listener, message))
+ {
+ DBusError error;
+ dbus_bool_t new_active;
+
+ dbus_error_init (&error);
+ if (dbus_message_get_args (message, &error,
+ DBUS_TYPE_BOOLEAN, &new_active,
+ DBUS_TYPE_INVALID))
+ {
+ gs_debug ("ConsoleKit notified ActiveChanged %d", new_active);
+
+ /* when we aren't active add an implicit throttle from CK
+ * when we become active remove the throttle and poke the lock */
+ if (new_active)
+ {
+ if (listener->priv->ck_throttle_cookie != 0)
+ {
+ listener_remove_ck_ref_entry (listener,
+ REF_ENTRY_TYPE_THROTTLE,
+ listener->priv->ck_throttle_cookie);
+ listener->priv->ck_throttle_cookie = 0;
+ }
+
+ g_signal_emit (listener, signals [SIMULATE_USER_ACTIVITY], 0);
+ }
+ else
+ {
+ if (listener->priv->ck_throttle_cookie != 0)
+ {
+ g_warning ("ConsoleKit throttle already set");
+ listener_remove_ck_ref_entry (listener,
+ REF_ENTRY_TYPE_THROTTLE,
+ listener->priv->ck_throttle_cookie);
+ listener->priv->ck_throttle_cookie = 0;
+ }
+
+ listener_add_ck_ref_entry (listener,
+ REF_ENTRY_TYPE_THROTTLE,
+ connection,
+ message,
+ &listener->priv->ck_throttle_cookie);
+ }
+ }
+
+ if (dbus_error_is_set (&error))
+ {
+ dbus_error_free (&error);
+ }
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
#endif
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static DBusHandlerResult
@@ -1798,112 +1798,112 @@ gs_listener_message_handler (DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
- g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+ g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+ g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
#if 0
- g_message ("obj_path=%s interface=%s method=%s destination=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message),
- dbus_message_get_destination (message));
+ g_message ("obj_path=%s interface=%s method=%s destination=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message),
+ dbus_message_get_destination (message));
#endif
- if (dbus_message_is_method_call (message, "org.freedesktop.DBus", "AddMatch"))
- {
- DBusMessage *reply;
-
- reply = dbus_message_new_method_return (message);
-
- if (reply == NULL)
- {
- g_error ("No memory");
- }
-
- if (! dbus_connection_send (connection, reply, NULL))
- {
- g_error ("No memory");
- }
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") &&
- strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0)
- {
- dbus_connection_unref (connection);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else
- {
- return listener_dbus_handle_session_message (connection, message, user_data, TRUE);
- }
+ if (dbus_message_is_method_call (message, "org.freedesktop.DBus", "AddMatch"))
+ {
+ DBusMessage *reply;
+
+ reply = dbus_message_new_method_return (message);
+
+ if (reply == NULL)
+ {
+ g_error ("No memory");
+ }
+
+ if (! dbus_connection_send (connection, reply, NULL))
+ {
+ g_error ("No memory");
+ }
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") &&
+ strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0)
+ {
+ dbus_connection_unref (connection);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else
+ {
+ return listener_dbus_handle_session_message (connection, message, user_data, TRUE);
+ }
}
static gboolean
gs_listener_dbus_init (GSListener *listener)
{
- DBusError error;
-
- dbus_error_init (&error);
-
- if (listener->priv->connection == NULL)
- {
- listener->priv->connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
- if (listener->priv->connection == NULL)
- {
- if (dbus_error_is_set (&error))
- {
- gs_debug ("couldn't connect to session bus: %s",
- error.message);
- dbus_error_free (&error);
- }
- return FALSE;
- }
-
- dbus_connection_setup_with_g_main (listener->priv->connection, NULL);
- dbus_connection_set_exit_on_disconnect (listener->priv->connection, FALSE);
- }
-
- if (listener->priv->system_connection == NULL)
- {
- listener->priv->system_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
- if (listener->priv->system_connection == NULL)
- {
- if (dbus_error_is_set (&error))
- {
- gs_debug ("couldn't connect to system bus: %s",
- error.message);
- dbus_error_free (&error);
- }
- return FALSE;
- }
-
- dbus_connection_setup_with_g_main (listener->priv->system_connection, NULL);
- dbus_connection_set_exit_on_disconnect (listener->priv->system_connection, FALSE);
- }
-
- return TRUE;
+ DBusError error;
+
+ dbus_error_init (&error);
+
+ if (listener->priv->connection == NULL)
+ {
+ listener->priv->connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
+ if (listener->priv->connection == NULL)
+ {
+ if (dbus_error_is_set (&error))
+ {
+ gs_debug ("couldn't connect to session bus: %s",
+ error.message);
+ dbus_error_free (&error);
+ }
+ return FALSE;
+ }
+
+ dbus_connection_setup_with_g_main (listener->priv->connection, NULL);
+ dbus_connection_set_exit_on_disconnect (listener->priv->connection, FALSE);
+ }
+
+ if (listener->priv->system_connection == NULL)
+ {
+ listener->priv->system_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (listener->priv->system_connection == NULL)
+ {
+ if (dbus_error_is_set (&error))
+ {
+ gs_debug ("couldn't connect to system bus: %s",
+ error.message);
+ dbus_error_free (&error);
+ }
+ return FALSE;
+ }
+
+ dbus_connection_setup_with_g_main (listener->priv->system_connection, NULL);
+ dbus_connection_set_exit_on_disconnect (listener->priv->system_connection, FALSE);
+ }
+
+ return TRUE;
}
static gboolean
reinit_dbus (GSListener *listener)
{
- gboolean initialized;
- gboolean try_again;
+ gboolean initialized;
+ gboolean try_again;
- initialized = gs_listener_dbus_init (listener);
+ initialized = gs_listener_dbus_init (listener);
- /* if we didn't initialize then try again */
- /* FIXME: Should we keep trying forever? If we fail more than
- once or twice then the session bus may have died. The
- problem is that if it is restarted it will likely have a
- different bus address and we won't be able to find it */
- try_again = !initialized;
+ /* if we didn't initialize then try again */
+ /* FIXME: Should we keep trying forever? If we fail more than
+ once or twice then the session bus may have died. The
+ problem is that if it is restarted it will likely have a
+ different bus address and we won't be able to find it */
+ try_again = !initialized;
- return try_again;
+ return try_again;
}
static DBusHandlerResult
@@ -1911,46 +1911,46 @@ listener_dbus_filter_function (DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
- GSListener *listener = GS_LISTENER (user_data);
- const char *path;
-
- path = dbus_message_get_path (message);
-
- /*
- g_message ("obj_path=%s interface=%s method=%s",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
- */
-
- if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
- && strcmp (path, DBUS_PATH_LOCAL) == 0)
- {
-
- g_message ("Got disconnected from the session message bus; "
- "retrying to reconnect every 10 seconds");
-
- dbus_connection_unref (connection);
- listener->priv->connection = NULL;
-
- g_timeout_add (10000, (GSourceFunc)reinit_dbus, listener);
- }
- else if (dbus_message_is_signal (message,
- DBUS_INTERFACE_DBUS,
- "NameOwnerChanged"))
- {
-
- if (listener->priv->inhibitors != NULL)
- {
- listener_service_deleted (listener, message);
- }
- }
- else
- {
- return listener_dbus_handle_session_message (connection, message, user_data, FALSE);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ GSListener *listener = GS_LISTENER (user_data);
+ const char *path;
+
+ path = dbus_message_get_path (message);
+
+ /*
+ g_message ("obj_path=%s interface=%s method=%s",
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
+ */
+
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
+ && strcmp (path, DBUS_PATH_LOCAL) == 0)
+ {
+
+ g_message ("Got disconnected from the session message bus; "
+ "retrying to reconnect every 10 seconds");
+
+ dbus_connection_unref (connection);
+ listener->priv->connection = NULL;
+
+ g_timeout_add (10000, (GSourceFunc)reinit_dbus, listener);
+ }
+ else if (dbus_message_is_signal (message,
+ DBUS_INTERFACE_DBUS,
+ "NameOwnerChanged"))
+ {
+
+ if (listener->priv->inhibitors != NULL)
+ {
+ listener_service_deleted (listener, message);
+ }
+ }
+ else
+ {
+ return listener_dbus_handle_session_message (connection, message, user_data, FALSE);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -1958,507 +1958,506 @@ listener_dbus_system_filter_function (DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
- GSListener *listener = GS_LISTENER (user_data);
- const char *path;
+ GSListener *listener = GS_LISTENER (user_data);
+ const char *path;
- path = dbus_message_get_path (message);
+ path = dbus_message_get_path (message);
- if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
- && strcmp (path, DBUS_PATH_LOCAL) == 0)
- {
+ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
+ && strcmp (path, DBUS_PATH_LOCAL) == 0)
+ {
- g_message ("Got disconnected from the system message bus; "
- "retrying to reconnect every 10 seconds");
+ g_message ("Got disconnected from the system message bus; "
+ "retrying to reconnect every 10 seconds");
- dbus_connection_unref (connection);
- listener->priv->system_connection = NULL;
+ dbus_connection_unref (connection);
+ listener->priv->system_connection = NULL;
- g_timeout_add (10000, (GSourceFunc)reinit_dbus, listener);
- }
- else
- {
- return listener_dbus_handle_system_message (connection, message, user_data, FALSE);
- }
+ g_timeout_add (10000, (GSourceFunc)reinit_dbus, listener);
+ }
+ else
+ {
+ return listener_dbus_handle_system_message (connection, message, user_data, FALSE);
+ }
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static void
-gs_listener_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GSListener *self;
-
- self = GS_LISTENER (object);
-
- switch (prop_id)
- {
- case PROP_ACTIVE:
- gs_listener_set_active (self, g_value_get_boolean (value));
- break;
- case PROP_SESSION_IDLE:
- gs_listener_set_session_idle (self, g_value_get_boolean (value));
- break;
- case PROP_ACTIVATION_ENABLED:
- gs_listener_set_activation_enabled (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gs_listener_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GSListener *self;
+
+ self = GS_LISTENER (object);
+
+ switch (prop_id)
+ {
+ case PROP_ACTIVE:
+ gs_listener_set_active (self, g_value_get_boolean (value));
+ break;
+ case PROP_SESSION_IDLE:
+ gs_listener_set_session_idle (self, g_value_get_boolean (value));
+ break;
+ case PROP_ACTIVATION_ENABLED:
+ gs_listener_set_activation_enabled (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gs_listener_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GSListener *self;
-
- self = GS_LISTENER (object);
-
- switch (prop_id)
- {
- case PROP_ACTIVE:
- g_value_set_boolean (value, self->priv->active);
- break;
- case PROP_SESSION_IDLE:
- g_value_set_boolean (value, self->priv->session_idle);
- break;
- case PROP_ACTIVATION_ENABLED:
- g_value_set_boolean (value, self->priv->activation_enabled);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gs_listener_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GSListener *self;
+
+ self = GS_LISTENER (object);
+
+ switch (prop_id)
+ {
+ case PROP_ACTIVE:
+ g_value_set_boolean (value, self->priv->active);
+ break;
+ case PROP_SESSION_IDLE:
+ g_value_set_boolean (value, self->priv->session_idle);
+ break;
+ case PROP_ACTIVATION_ENABLED:
+ g_value_set_boolean (value, self->priv->activation_enabled);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gs_listener_class_init (GSListenerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gs_listener_finalize;
- object_class->get_property = gs_listener_get_property;
- object_class->set_property = gs_listener_set_property;
-
- signals [LOCK] =
- g_signal_new ("lock",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, lock),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [QUIT] =
- g_signal_new ("quit",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, quit),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [CYCLE] =
- g_signal_new ("cycle",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, cycle),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [SIMULATE_USER_ACTIVITY] =
- g_signal_new ("simulate-user-activity",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, simulate_user_activity),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [ACTIVE_CHANGED] =
- g_signal_new ("active-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, active_changed),
- NULL,
- NULL,
- gs_marshal_BOOLEAN__BOOLEAN,
- G_TYPE_BOOLEAN,
- 1,
- G_TYPE_BOOLEAN);
- signals [THROTTLE_CHANGED] =
- g_signal_new ("throttle-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, throttle_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1,
- G_TYPE_BOOLEAN);
- signals [SHOW_MESSAGE] =
- g_signal_new ("show-message",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSListenerClass, show_message),
- NULL,
- NULL,
- gs_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE,
- 3,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- g_object_class_install_property (object_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_ACTIVATION_ENABLED,
- g_param_spec_boolean ("activation-enabled",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gs_listener_finalize;
+ object_class->get_property = gs_listener_get_property;
+ object_class->set_property = gs_listener_set_property;
+
+ signals [LOCK] =
+ g_signal_new ("lock",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, lock),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [QUIT] =
+ g_signal_new ("quit",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, quit),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [CYCLE] =
+ g_signal_new ("cycle",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, cycle),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [SIMULATE_USER_ACTIVITY] =
+ g_signal_new ("simulate-user-activity",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, simulate_user_activity),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [ACTIVE_CHANGED] =
+ g_signal_new ("active-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, active_changed),
+ NULL,
+ NULL,
+ gs_marshal_BOOLEAN__BOOLEAN,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_BOOLEAN);
+ signals [THROTTLE_CHANGED] =
+ g_signal_new ("throttle-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, throttle_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
+ signals [SHOW_MESSAGE] =
+ g_signal_new ("show-message",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerClass, show_message),
+ NULL,
+ NULL,
+ gs_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE,
+ 3,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ g_object_class_install_property (object_class,
+ PROP_ACTIVE,
+ g_param_spec_boolean ("active",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_ACTIVATION_ENABLED,
+ g_param_spec_boolean ("activation-enabled",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
}
-
static gboolean
screensaver_is_running (DBusConnection *connection)
{
- DBusError error;
- gboolean exists;
+ DBusError error;
+ gboolean exists;
- g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (connection != NULL, FALSE);
- dbus_error_init (&error);
- exists = dbus_bus_name_has_owner (connection, GS_LISTENER_SERVICE, &error);
- if (dbus_error_is_set (&error))
- {
- dbus_error_free (&error);
- }
+ dbus_error_init (&error);
+ exists = dbus_bus_name_has_owner (connection, GS_LISTENER_SERVICE, &error);
+ if (dbus_error_is_set (&error))
+ {
+ dbus_error_free (&error);
+ }
- return exists;
+ return exists;
}
gboolean
-gs_listener_acquire (GSListener *listener,
- GError **error)
-{
- int acquired;
- DBusError buserror;
- gboolean is_connected;
-
- g_return_val_if_fail (listener != NULL, FALSE);
-
- if (! listener->priv->connection)
- {
- g_set_error (error,
- GS_LISTENER_ERROR,
- GS_LISTENER_ERROR_ACQUISITION_FAILURE,
- "%s",
- _("failed to register with the message bus"));
- return FALSE;
- }
-
- is_connected = dbus_connection_get_is_connected (listener->priv->connection);
- if (! is_connected)
- {
- g_set_error (error,
- GS_LISTENER_ERROR,
- GS_LISTENER_ERROR_ACQUISITION_FAILURE,
- "%s",
- _("not connected to the message bus"));
- return FALSE;
- }
-
- if (screensaver_is_running (listener->priv->connection))
- {
- g_set_error (error,
- GS_LISTENER_ERROR,
- GS_LISTENER_ERROR_ACQUISITION_FAILURE,
- "%s",
- _("screensaver already running in this session"));
- return FALSE;
- }
-
- dbus_error_init (&buserror);
-
- if (dbus_connection_register_object_path (listener->priv->connection,
- GS_LISTENER_PATH,
- &gs_listener_vtable,
- listener) == FALSE)
- {
- g_critical ("out of memory registering object path");
- return FALSE;
- }
-
- acquired = dbus_bus_request_name (listener->priv->connection,
- GS_LISTENER_SERVICE,
- DBUS_NAME_FLAG_DO_NOT_QUEUE,
- &buserror);
- if (dbus_error_is_set (&buserror))
- {
- g_set_error (error,
- GS_LISTENER_ERROR,
- GS_LISTENER_ERROR_ACQUISITION_FAILURE,
- "%s",
- buserror.message);
- }
- if (acquired == DBUS_REQUEST_NAME_REPLY_EXISTS) {
- g_set_error (error,
- GS_LISTENER_ERROR,
- GS_LISTENER_ERROR_ACQUISITION_FAILURE,
- "%s",
- _("screensaver already running in this session"));
- return FALSE;
+gs_listener_acquire (GSListener *listener,
+ GError **error)
+{
+ int acquired;
+ DBusError buserror;
+ gboolean is_connected;
+
+ g_return_val_if_fail (listener != NULL, FALSE);
+
+ if (! listener->priv->connection)
+ {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ _("failed to register with the message bus"));
+ return FALSE;
+ }
+
+ is_connected = dbus_connection_get_is_connected (listener->priv->connection);
+ if (! is_connected)
+ {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ _("not connected to the message bus"));
+ return FALSE;
+ }
+
+ if (screensaver_is_running (listener->priv->connection))
+ {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ _("screensaver already running in this session"));
+ return FALSE;
+ }
+
+ dbus_error_init (&buserror);
+
+ if (dbus_connection_register_object_path (listener->priv->connection,
+ GS_LISTENER_PATH,
+ &gs_listener_vtable,
+ listener) == FALSE)
+ {
+ g_critical ("out of memory registering object path");
+ return FALSE;
+ }
+
+ acquired = dbus_bus_request_name (listener->priv->connection,
+ GS_LISTENER_SERVICE,
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ &buserror);
+ if (dbus_error_is_set (&buserror))
+ {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ buserror.message);
+ }
+ if (acquired == DBUS_REQUEST_NAME_REPLY_EXISTS) {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ _("screensaver already running in this session"));
+ return FALSE;
}
- dbus_error_free (&buserror);
+ dbus_error_free (&buserror);
- dbus_connection_add_filter (listener->priv->connection, listener_dbus_filter_function, listener, NULL);
+ dbus_connection_add_filter (listener->priv->connection, listener_dbus_filter_function, listener, NULL);
- dbus_bus_add_match (listener->priv->connection,
- "type='signal'"
- ",interface='"DBUS_INTERFACE_DBUS"'"
- ",sender='"DBUS_SERVICE_DBUS"'"
- ",member='NameOwnerChanged'",
- NULL);
+ dbus_bus_add_match (listener->priv->connection,
+ "type='signal'"
+ ",interface='"DBUS_INTERFACE_DBUS"'"
+ ",sender='"DBUS_SERVICE_DBUS"'"
+ ",member='NameOwnerChanged'",
+ NULL);
- if (listener->priv->system_connection != NULL)
- {
- dbus_connection_add_filter (listener->priv->system_connection,
- listener_dbus_system_filter_function,
- listener,
- NULL);
+ if (listener->priv->system_connection != NULL)
+ {
+ dbus_connection_add_filter (listener->priv->system_connection,
+ listener_dbus_system_filter_function,
+ listener,
+ NULL);
#ifdef WITH_SYSTEMD
- if (listener->priv->have_systemd) {
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",sender='"SYSTEMD_LOGIND_SERVICE"'"
- ",interface='"SYSTEMD_LOGIND_SESSION_INTERFACE"'"
- ",member='Unlock'",
- NULL);
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",sender='"SYSTEMD_LOGIND_SERVICE"'"
- ",interface='"SYSTEMD_LOGIND_SESSION_INTERFACE"'"
- ",member='Lock'",
- NULL);
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",sender='"SYSTEMD_LOGIND_SERVICE"'"
- ",interface='"DBUS_INTERFACE_PROPERTIES"'"
- ",member='PropertiesChanged'",
- NULL);
-
- return (acquired != -1);
- }
+ if (listener->priv->have_systemd) {
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",sender='"SYSTEMD_LOGIND_SERVICE"'"
+ ",interface='"SYSTEMD_LOGIND_SESSION_INTERFACE"'"
+ ",member='Unlock'",
+ NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",sender='"SYSTEMD_LOGIND_SERVICE"'"
+ ",interface='"SYSTEMD_LOGIND_SESSION_INTERFACE"'"
+ ",member='Lock'",
+ NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",sender='"SYSTEMD_LOGIND_SERVICE"'"
+ ",interface='"DBUS_INTERFACE_PROPERTIES"'"
+ ",member='PropertiesChanged'",
+ NULL);
+
+ return (acquired != -1);
+ }
#endif
#ifdef WITH_CONSOLE_KIT
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",interface='"HAL_DEVICE_INTERFACE"'"
- ",member='Condition'",
- NULL);
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",interface='"CK_SESSION_INTERFACE"'"
- ",member='Unlock'",
- NULL);
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",interface='"CK_SESSION_INTERFACE"'"
- ",member='Lock'",
- NULL);
- dbus_bus_add_match (listener->priv->system_connection,
- "type='signal'"
- ",interface='"CK_SESSION_INTERFACE"'"
- ",member='ActiveChanged'",
- NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",interface='"HAL_DEVICE_INTERFACE"'"
+ ",member='Condition'",
+ NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",interface='"CK_SESSION_INTERFACE"'"
+ ",member='Unlock'",
+ NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",interface='"CK_SESSION_INTERFACE"'"
+ ",member='Lock'",
+ NULL);
+ dbus_bus_add_match (listener->priv->system_connection,
+ "type='signal'"
+ ",interface='"CK_SESSION_INTERFACE"'"
+ ",member='ActiveChanged'",
+ NULL);
#endif
- }
+ }
- return (acquired != -1);
+ return (acquired != -1);
}
static char *
query_session_id (GSListener *listener)
{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter reply_iter;
- char *ssid;
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusError error;
+ DBusMessageIter reply_iter;
+ char *ssid;
- if (listener->priv->system_connection == NULL)
- {
- gs_debug ("No connection to the system bus");
- return NULL;
- }
+ if (listener->priv->system_connection == NULL)
+ {
+ gs_debug ("No connection to the system bus");
+ return NULL;
+ }
- ssid = NULL;
+ ssid = NULL;
- dbus_error_init (&error);
+ dbus_error_init (&error);
#ifdef WITH_SYSTEMD
- if (listener->priv->have_systemd) {
- dbus_uint32_t pid = getpid();
-
- message = dbus_message_new_method_call (SYSTEMD_LOGIND_SERVICE,
- SYSTEMD_LOGIND_PATH,
- SYSTEMD_LOGIND_INTERFACE,
- "GetSessionByPID");
- if (message == NULL)
- {
- gs_debug ("Couldn't allocate the dbus message");
- return NULL;
- }
-
- if (dbus_message_append_args (message,
- DBUS_TYPE_UINT32,
- &pid, DBUS_TYPE_INVALID) == FALSE)
- {
- gs_debug ("Couldn't add args to the dbus message");
- return NULL;
- }
-
- /* FIXME: use async? */
- reply = dbus_connection_send_with_reply_and_block (listener->priv->system_connection,
- message,
- -1, &error);
- dbus_message_unref (message);
-
- if (dbus_error_is_set (&error))
- {
- gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
- dbus_error_free (&error);
- return NULL;
- }
-
- dbus_message_iter_init (reply, &reply_iter);
- dbus_message_iter_get_basic (&reply_iter, &ssid);
-
- dbus_message_unref (reply);
-
- return g_strdup (ssid);
- }
+ if (listener->priv->have_systemd) {
+ dbus_uint32_t pid = getpid();
+
+ message = dbus_message_new_method_call (SYSTEMD_LOGIND_SERVICE,
+ SYSTEMD_LOGIND_PATH,
+ SYSTEMD_LOGIND_INTERFACE,
+ "GetSessionByPID");
+ if (message == NULL)
+ {
+ gs_debug ("Couldn't allocate the dbus message");
+ return NULL;
+ }
+
+ if (dbus_message_append_args (message,
+ DBUS_TYPE_UINT32,
+ &pid, DBUS_TYPE_INVALID) == FALSE)
+ {
+ gs_debug ("Couldn't add args to the dbus message");
+ return NULL;
+ }
+
+ /* FIXME: use async? */
+ reply = dbus_connection_send_with_reply_and_block (listener->priv->system_connection,
+ message,
+ -1, &error);
+ dbus_message_unref (message);
+
+ if (dbus_error_is_set (&error))
+ {
+ gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
+ dbus_error_free (&error);
+ return NULL;
+ }
+
+ dbus_message_iter_init (reply, &reply_iter);
+ dbus_message_iter_get_basic (&reply_iter, &ssid);
+
+ dbus_message_unref (reply);
+
+ return g_strdup (ssid);
+ }
#endif
#ifdef WITH_CONSOLE_KIT
- message = dbus_message_new_method_call (CK_NAME, CK_MANAGER_PATH, CK_MANAGER_INTERFACE, "GetCurrentSession");
- if (message == NULL)
- {
- gs_debug ("Couldn't allocate the dbus message");
- return NULL;
- }
-
- /* FIXME: use async? */
- reply = dbus_connection_send_with_reply_and_block (listener->priv->system_connection,
- message,
- -1, &error);
- dbus_message_unref (message);
-
- if (dbus_error_is_set (&error))
- {
- gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
- dbus_error_free (&error);
- return NULL;
- }
-
- dbus_message_iter_init (reply, &reply_iter);
- dbus_message_iter_get_basic (&reply_iter, &ssid);
-
- dbus_message_unref (reply);
-
- return g_strdup (ssid);
+ message = dbus_message_new_method_call (CK_NAME, CK_MANAGER_PATH, CK_MANAGER_INTERFACE, "GetCurrentSession");
+ if (message == NULL)
+ {
+ gs_debug ("Couldn't allocate the dbus message");
+ return NULL;
+ }
+
+ /* FIXME: use async? */
+ reply = dbus_connection_send_with_reply_and_block (listener->priv->system_connection,
+ message,
+ -1, &error);
+ dbus_message_unref (message);
+
+ if (dbus_error_is_set (&error))
+ {
+ gs_debug ("%s raised:\n %s\n\n", error.name, error.message);
+ dbus_error_free (&error);
+ return NULL;
+ }
+
+ dbus_message_iter_init (reply, &reply_iter);
+ dbus_message_iter_get_basic (&reply_iter, &ssid);
+
+ dbus_message_unref (reply);
+
+ return g_strdup (ssid);
#else
- return NULL;
+ return NULL;
#endif
}
static void
init_session_id (GSListener *listener)
{
- g_free (listener->priv->session_id);
- listener->priv->session_id = query_session_id (listener);
- gs_debug ("Got session-id: %s", listener->priv->session_id);
+ g_free (listener->priv->session_id);
+ listener->priv->session_id = query_session_id (listener);
+ gs_debug ("Got session-id: %s", listener->priv->session_id);
}
static void
gs_listener_init (GSListener *listener)
{
- listener->priv = gs_listener_get_instance_private (listener);
+ listener->priv = gs_listener_get_instance_private (listener);
#ifdef WITH_SYSTEMD
- /* check if logind is running */
- listener->priv->have_systemd = (access("/run/systemd/seats/", F_OK) >= 0);
+ /* check if logind is running */
+ listener->priv->have_systemd = (access("/run/systemd/seats/", F_OK) >= 0);
#endif
- gs_listener_dbus_init (listener);
+ gs_listener_dbus_init (listener);
- init_session_id (listener);
+ init_session_id (listener);
- listener->priv->inhibitors = g_hash_table_new_full (g_int_hash,
- g_int_equal,
- NULL,
- (GDestroyNotify)gs_listener_ref_entry_free);
- listener->priv->throttlers = g_hash_table_new_full (g_int_hash,
- g_int_equal,
- NULL,
- (GDestroyNotify)gs_listener_ref_entry_free);
+ listener->priv->inhibitors = g_hash_table_new_full (g_int_hash,
+ g_int_equal,
+ NULL,
+ (GDestroyNotify)gs_listener_ref_entry_free);
+ listener->priv->throttlers = g_hash_table_new_full (g_int_hash,
+ g_int_equal,
+ NULL,
+ (GDestroyNotify)gs_listener_ref_entry_free);
}
static void
gs_listener_finalize (GObject *object)
{
- GSListener *listener;
+ GSListener *listener;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_LISTENER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_LISTENER (object));
- listener = GS_LISTENER (object);
+ listener = GS_LISTENER (object);
- g_return_if_fail (listener->priv != NULL);
+ g_return_if_fail (listener->priv != NULL);
- if (listener->priv->inhibitors)
- {
- g_hash_table_destroy (listener->priv->inhibitors);
- }
+ if (listener->priv->inhibitors)
+ {
+ g_hash_table_destroy (listener->priv->inhibitors);
+ }
- if (listener->priv->throttlers)
- {
- g_hash_table_destroy (listener->priv->throttlers);
- }
+ if (listener->priv->throttlers)
+ {
+ g_hash_table_destroy (listener->priv->throttlers);
+ }
- g_free (listener->priv->session_id);
+ g_free (listener->priv->session_id);
- G_OBJECT_CLASS (gs_listener_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_listener_parent_class)->finalize (object);
}
GSListener *
gs_listener_new (void)
{
- GSListener *listener;
+ GSListener *listener;
- listener = g_object_new (GS_TYPE_LISTENER, NULL);
+ listener = g_object_new (GS_TYPE_LISTENER, NULL);
- return GS_LISTENER (listener);
+ return GS_LISTENER (listener);
}
diff --git a/src/gs-listener-dbus.h b/src/gs-listener-dbus.h
index f86e75e..acbf18c 100644
--- a/src/gs-listener-dbus.h
+++ b/src/gs-listener-dbus.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -38,26 +38,26 @@ typedef struct GSListenerPrivate GSListenerPrivate;
typedef struct
{
- GObject parent;
- GSListenerPrivate *priv;
+ GObject parent;
+ GSListenerPrivate *priv;
} GSListener;
typedef struct
{
- GObjectClass parent_class;
-
- void (* lock) (GSListener *listener);
- void (* cycle) (GSListener *listener);
- void (* quit) (GSListener *listener);
- void (* simulate_user_activity) (GSListener *listener);
- gboolean (* active_changed) (GSListener *listener,
- gboolean active);
- void (* throttle_changed) (GSListener *listener,
- gboolean throttled);
- void (* show_message) (GSListener *listener,
- const char *summary,
- const char *body,
- const char *icon);
+ GObjectClass parent_class;
+
+ void (* lock) (GSListener *listener);
+ void (* cycle) (GSListener *listener);
+ void (* quit) (GSListener *listener);
+ void (* simulate_user_activity) (GSListener *listener);
+ gboolean (* active_changed) (GSListener *listener,
+ gboolean active);
+ void (* throttle_changed) (GSListener *listener,
+ gboolean throttled);
+ void (* show_message) (GSListener *listener,
+ const char *summary,
+ const char *body,
+ const char *icon);
} GSListenerClass;
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 381ee87..4988ffe 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -70,51 +70,51 @@ static void redraw_background (GSLockPlug *plug);
struct GSLockPlugPrivate
{
- GtkWidget *vbox;
- GtkWidget *auth_action_area;
+ GtkWidget *vbox;
+ GtkWidget *auth_action_area;
- GtkWidget *auth_face_image;
- GtkWidget *auth_datetime_label;
- GtkWidget *auth_realname_label;
- GtkWidget *auth_username_label;
- GtkWidget *auth_prompt_label;
- GtkWidget *auth_prompt_entry;
- GtkWidget *auth_prompt_box;
- GtkWidget *auth_capslock_label;
- GtkWidget *auth_message_label;
- GtkWidget *status_message_label;
- GtkWidget *background_image;
+ GtkWidget *auth_face_image;
+ GtkWidget *auth_datetime_label;
+ GtkWidget *auth_realname_label;
+ GtkWidget *auth_username_label;
+ GtkWidget *auth_prompt_label;
+ GtkWidget *auth_prompt_entry;
+ GtkWidget *auth_prompt_box;
+ GtkWidget *auth_capslock_label;
+ GtkWidget *auth_message_label;
+ GtkWidget *status_message_label;
+ GtkWidget *background_image;
- GtkWidget *auth_unlock_button;
- GtkWidget *auth_switch_button;
- GtkWidget *auth_cancel_button;
- GtkWidget *auth_logout_button;
+ GtkWidget *auth_unlock_button;
+ GtkWidget *auth_switch_button;
+ GtkWidget *auth_cancel_button;
+ GtkWidget *auth_logout_button;
- GtkWidget *auth_prompt_kbd_layout_indicator;
+ GtkWidget *auth_prompt_kbd_layout_indicator;
- gboolean caps_lock_on;
- gboolean switch_enabled;
- gboolean logout_enabled;
- char *logout_command;
- char *status_message;
+ gboolean caps_lock_on;
+ gboolean switch_enabled;
+ gboolean logout_enabled;
+ char *logout_command;
+ char *status_message;
- guint timeout;
+ guint timeout;
- guint datetime_timeout_id;
- guint cancel_timeout_id;
- guint auth_check_idle_id;
- guint response_idle_id;
+ guint datetime_timeout_id;
+ guint cancel_timeout_id;
+ guint auth_check_idle_id;
+ guint response_idle_id;
- gint monitor_index;
+ gint monitor_index;
- GList *key_events;
+ GList *key_events;
};
typedef struct _ResponseData ResponseData;
struct _ResponseData
{
- gint response_id;
+ gint response_id;
};
@@ -143,123 +143,123 @@ static void
gs_lock_plug_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
- GSLockPlug *plug;
+ GSLockPlug *plug;
- if (GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->style_set)
- {
- GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->style_set (widget, previous_style);
- }
+ if (GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->style_set)
+ {
+ GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->style_set (widget, previous_style);
+ }
- plug = GS_LOCK_PLUG (widget);
+ plug = GS_LOCK_PLUG (widget);
- if (! plug->priv->vbox)
- {
- return;
- }
+ if (! plug->priv->vbox)
+ {
+ return;
+ }
- gtk_container_set_border_width (GTK_CONTAINER (plug->priv->vbox), 12);
- gtk_box_set_spacing (GTK_BOX (plug->priv->vbox), 12);
+ gtk_container_set_border_width (GTK_CONTAINER (plug->priv->vbox), 12);
+ gtk_box_set_spacing (GTK_BOX (plug->priv->vbox), 12);
- gtk_container_set_border_width (GTK_CONTAINER (plug->priv->auth_action_area), 0);
- gtk_box_set_spacing (GTK_BOX (plug->priv->auth_action_area), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (plug->priv->auth_action_area), 0);
+ gtk_box_set_spacing (GTK_BOX (plug->priv->auth_action_area), 5);
}
static gboolean
process_is_running (const char * name)
{
- int num_processes;
- gchar *command = g_strdup_printf ("pidof %s | wc -l", name);
- FILE *fp = popen(command, "r");
+ int num_processes;
+ gchar *command = g_strdup_printf ("pidof %s | wc -l", name);
+ FILE *fp = popen(command, "r");
- if (fscanf(fp, "%d", &num_processes) != 1)
- num_processes = 0;
+ if (fscanf(fp, "%d", &num_processes) != 1)
+ num_processes = 0;
- pclose(fp);
- g_free (command);
+ pclose(fp);
+ g_free (command);
- if (num_processes > 0) {
- return TRUE;
- } else {
- return FALSE;
- }
+ if (num_processes > 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
static void
do_user_switch (GSLockPlug *plug)
{
- GError *error;
- gboolean res;
- char *command;
-
- if (process_is_running ("mdm"))
- {
- /* MDM */
- command = g_strdup_printf ("%s %s",
- MDM_FLEXISERVER_COMMAND,
- MDM_FLEXISERVER_ARGS);
-
- error = NULL;
- res = xfce_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
- command,
- &error);
-
- g_free (command);
-
- if (! res)
- {
- gs_debug ("Unable to start MDM greeter: %s", error->message);
- g_error_free (error);
- }
- }
- else if (process_is_running ("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary"))
- {
- /* GDM */
- command = g_strdup_printf ("%s %s",
- GDM_FLEXISERVER_COMMAND,
- GDM_FLEXISERVER_ARGS);
-
- error = NULL;
- res = xfce_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
- command,
- &error);
-
- g_free (command);
-
- if (! res) {
- gs_debug ("Unable to start GDM greeter: %s", error->message);
- g_error_free (error);
- }
- }
- else if (g_getenv ("XDG_SEAT_PATH") != NULL)
- {
- /* LightDM */
- GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START;
- GDBusProxy *proxy = NULL;
-
- error = NULL;
- proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
- flags,
- NULL,
- "org.freedesktop.DisplayManager",
- g_getenv ("XDG_SEAT_PATH"),
- "org.freedesktop.DisplayManager.Seat",
- NULL,
- &error);
- if (proxy != NULL) {
- g_dbus_proxy_call_sync (proxy,
- "SwitchToGreeter",
- g_variant_new ("()"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- NULL);
- g_object_unref (proxy);
- }
- else {
- gs_debug ("Unable to start LightDM greeter: %s", error->message);
- g_error_free (error);
- }
- }
+ GError *error;
+ gboolean res;
+ char *command;
+
+ if (process_is_running ("mdm"))
+ {
+ /* MDM */
+ command = g_strdup_printf ("%s %s",
+ MDM_FLEXISERVER_COMMAND,
+ MDM_FLEXISERVER_ARGS);
+
+ error = NULL;
+ res = xfce_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
+ command,
+ &error);
+
+ g_free (command);
+
+ if (! res)
+ {
+ gs_debug ("Unable to start MDM greeter: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ else if (process_is_running ("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary"))
+ {
+ /* GDM */
+ command = g_strdup_printf ("%s %s",
+ GDM_FLEXISERVER_COMMAND,
+ GDM_FLEXISERVER_ARGS);
+
+ error = NULL;
+ res = xfce_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
+ command,
+ &error);
+
+ g_free (command);
+
+ if (! res) {
+ gs_debug ("Unable to start GDM greeter: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ else if (g_getenv ("XDG_SEAT_PATH") != NULL)
+ {
+ /* LightDM */
+ GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START;
+ GDBusProxy *proxy = NULL;
+
+ error = NULL;
+ proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
+ flags,
+ NULL,
+ "org.freedesktop.DisplayManager",
+ g_getenv ("XDG_SEAT_PATH"),
+ "org.freedesktop.DisplayManager.Seat",
+ NULL,
+ &error);
+ if (proxy != NULL) {
+ g_dbus_proxy_call_sync (proxy,
+ "SwitchToGreeter",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL);
+ g_object_unref (proxy);
+ }
+ else {
+ gs_debug ("Unable to start LightDM greeter: %s", error->message);
+ g_error_free (error);
+ }
+ }
}
@@ -267,133 +267,133 @@ static void
set_status_text (GSLockPlug *plug,
const char *text)
{
- if (plug->priv->auth_message_label != NULL)
- {
- gtk_label_set_text (GTK_LABEL (plug->priv->auth_message_label), text);
- if (g_utf8_strlen (text, 1) == 0) {
- gtk_widget_hide (GTK_WIDGET (plug->priv->auth_message_label));
- } else {
- gtk_widget_show (GTK_WIDGET (plug->priv->auth_message_label));
- }
- }
+ if (plug->priv->auth_message_label != NULL)
+ {
+ gtk_label_set_text (GTK_LABEL (plug->priv->auth_message_label), text);
+ if (g_utf8_strlen (text, 1) == 0) {
+ gtk_widget_hide (GTK_WIDGET (plug->priv->auth_message_label));
+ } else {
+ gtk_widget_show (GTK_WIDGET (plug->priv->auth_message_label));
+ }
+ }
}
static void
date_time_update (GSLockPlug *plug)
{
- GDateTime *datetime;
- gchar *datetime_format;
- gchar *str;
+ GDateTime *datetime;
+ gchar *datetime_format;
+ gchar *str;
- datetime = g_date_time_new_now_local ();
- datetime_format = g_date_time_format (datetime, _("%A, %B %e %H:%M"));
+ datetime = g_date_time_new_now_local ();
+ datetime_format = g_date_time_format (datetime, _("%A, %B %e %H:%M"));
- str = g_strdup_printf ("<b>%s</b>", datetime_format);
- gtk_label_set_markup (GTK_LABEL (plug->priv->auth_datetime_label), str);
- g_free (str);
+ str = g_strdup_printf ("<b>%s</b>", datetime_format);
+ gtk_label_set_markup (GTK_LABEL (plug->priv->auth_datetime_label), str);
+ g_free (str);
- g_free (datetime_format);
- g_date_time_unref (datetime);
+ g_free (datetime_format);
+ g_date_time_unref (datetime);
}
void
gs_lock_plug_set_sensitive (GSLockPlug *plug,
gboolean sensitive)
{
- g_return_if_fail (GS_IS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_IS_LOCK_PLUG (plug));
- gtk_widget_set_sensitive (plug->priv->auth_prompt_entry, sensitive);
- gtk_widget_set_sensitive (plug->priv->auth_action_area, sensitive);
+ gtk_widget_set_sensitive (plug->priv->auth_prompt_entry, sensitive);
+ gtk_widget_set_sensitive (plug->priv->auth_action_area, sensitive);
}
static void
remove_datetime_timeout (GSLockPlug *plug)
{
- if (plug->priv->datetime_timeout_id > 0)
- {
- g_source_remove (plug->priv->datetime_timeout_id);
- plug->priv->datetime_timeout_id = 0;
- }
+ if (plug->priv->datetime_timeout_id > 0)
+ {
+ g_source_remove (plug->priv->datetime_timeout_id);
+ plug->priv->datetime_timeout_id = 0;
+ }
}
static void
remove_cancel_timeout (GSLockPlug *plug)
{
- if (plug->priv->cancel_timeout_id > 0)
- {
- g_source_remove (plug->priv->cancel_timeout_id);
- plug->priv->cancel_timeout_id = 0;
- }
+ if (plug->priv->cancel_timeout_id > 0)
+ {
+ g_source_remove (plug->priv->cancel_timeout_id);
+ plug->priv->cancel_timeout_id = 0;
+ }
}
static void
remove_response_idle (GSLockPlug *plug)
{
- if (plug->priv->response_idle_id > 0)
- {
- g_source_remove (plug->priv->response_idle_id);
- plug->priv->response_idle_id = 0;
- }
+ if (plug->priv->response_idle_id > 0)
+ {
+ g_source_remove (plug->priv->response_idle_id);
+ plug->priv->response_idle_id = 0;
+ }
}
static void
gs_lock_plug_response (GSLockPlug *plug,
gint response_id)
{
- int new_response;
+ int new_response;
- new_response = response_id;
+ new_response = response_id;
- g_return_if_fail (GS_IS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_IS_LOCK_PLUG (plug));
- /* Act only on response IDs we recognize */
- if (!(response_id == GS_LOCK_PLUG_RESPONSE_OK
- || response_id == GS_LOCK_PLUG_RESPONSE_CANCEL))
- {
- return;
- }
+ /* Act only on response IDs we recognize */
+ if (!(response_id == GS_LOCK_PLUG_RESPONSE_OK
+ || response_id == GS_LOCK_PLUG_RESPONSE_CANCEL))
+ {
+ return;
+ }
- remove_cancel_timeout (plug);
- remove_response_idle (plug);
+ remove_cancel_timeout (plug);
+ remove_response_idle (plug);
- if (response_id == GS_LOCK_PLUG_RESPONSE_CANCEL)
- {
- gtk_entry_set_text (GTK_ENTRY (plug->priv->auth_prompt_entry), "");
- }
+ if (response_id == GS_LOCK_PLUG_RESPONSE_CANCEL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (plug->priv->auth_prompt_entry), "");
+ }
- g_signal_emit (plug,
- lock_plug_signals [RESPONSE],
- 0,
- new_response);
+ g_signal_emit (plug,
+ lock_plug_signals [RESPONSE],
+ 0,
+ new_response);
}
static gboolean
response_cancel_idle_cb (GSLockPlug *plug)
{
- plug->priv->response_idle_id = 0;
+ plug->priv->response_idle_id = 0;
- gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
+ gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
- return FALSE;
+ return FALSE;
}
static gboolean
dialog_timed_out (GSLockPlug *plug)
{
- gs_lock_plug_set_sensitive (plug, FALSE);
- set_status_text (plug, _("Time has expired."));
+ gs_lock_plug_set_sensitive (plug, FALSE);
+ set_status_text (plug, _("Time has expired."));
- if (plug->priv->response_idle_id != 0)
- {
- g_warning ("Response idle ID already set but shouldn't be");
- }
+ if (plug->priv->response_idle_id != 0)
+ {
+ g_warning ("Response idle ID already set but shouldn't be");
+ }
- remove_response_idle (plug);
+ remove_response_idle (plug);
- plug->priv->response_idle_id = g_timeout_add (2000,
- (GSourceFunc)response_cancel_idle_cb,
- plug);
- return FALSE;
+ plug->priv->response_idle_id = g_timeout_add (2000,
+ (GSourceFunc)response_cancel_idle_cb,
+ plug);
+ return FALSE;
}
@@ -402,260 +402,262 @@ capslock_update (GSLockPlug *plug,
gboolean is_on)
{
- plug->priv->caps_lock_on = is_on;
+ plug->priv->caps_lock_on = is_on;
- if (plug->priv->auth_capslock_label == NULL)
- {
- return;
- }
+ if (plug->priv->auth_capslock_label == NULL)
+ {
+ return;
+ }
- if (is_on)
- {
- gtk_widget_show (GTK_WIDGET (plug->priv->auth_capslock_label));
- }
- else
- {
- gtk_widget_hide (GTK_WIDGET (plug->priv->auth_capslock_label));
- }
+ if (is_on)
+ {
+ gtk_widget_show (GTK_WIDGET (plug->priv->auth_capslock_label));
+ }
+ else
+ {
+ gtk_widget_hide (GTK_WIDGET (plug->priv->auth_capslock_label));
+ }
}
static gboolean
is_capslock_on (void)
{
- GdkKeymap *keymap;
- gboolean res;
+ GdkKeymap *keymap;
+ gboolean res;
- res = FALSE;
+ res = FALSE;
- keymap = gdk_keymap_get_for_display (gdk_display_get_default());;
- if (keymap != NULL) {
- res = gdk_keymap_get_caps_lock_state (keymap);
- }
+ keymap = gdk_keymap_get_for_display (gdk_display_get_default());;
+ if (keymap != NULL) {
+ res = gdk_keymap_get_caps_lock_state (keymap);
+ }
- return res;
+ return res;
}
static void
restart_cancel_timeout (GSLockPlug *plug)
{
- remove_cancel_timeout (plug);
+ remove_cancel_timeout (plug);
- plug->priv->cancel_timeout_id = g_timeout_add (plug->priv->timeout,
- (GSourceFunc)dialog_timed_out,
- plug);
+ plug->priv->cancel_timeout_id = g_timeout_add (plug->priv->timeout,
+ (GSourceFunc)dialog_timed_out,
+ plug);
}
void
-gs_lock_plug_get_text (GSLockPlug *plug,
- char **text)
+gs_lock_plug_get_text (GSLockPlug *plug,
+ char **text)
{
- const char *typed_text;
- char *null_text;
- char *local_text;
+ const char *typed_text;
+ char *null_text;
+ char *local_text;
- typed_text = gtk_entry_get_text (GTK_ENTRY (plug->priv->auth_prompt_entry));
- local_text = g_locale_from_utf8 (typed_text, strlen (typed_text), NULL, NULL, NULL);
+ typed_text = gtk_entry_get_text (GTK_ENTRY (plug->priv->auth_prompt_entry));
+ local_text = g_locale_from_utf8 (typed_text, strlen (typed_text), NULL, NULL, NULL);
- null_text = g_strnfill (strlen (typed_text) + 1, '\b');
- gtk_entry_set_text (GTK_ENTRY (plug->priv->auth_prompt_entry), null_text);
- gtk_entry_set_text (GTK_ENTRY (plug->priv->auth_prompt_entry), "");
- g_free (null_text);
+ null_text = g_strnfill (strlen (typed_text) + 1, '\b');
+ gtk_entry_set_text (GTK_ENTRY (plug->priv->auth_prompt_entry), null_text);
+ gtk_entry_set_text (GTK_ENTRY (plug->priv->auth_prompt_entry), "");
+ g_free (null_text);
- if (text != NULL)
- {
- *text = local_text;
- }
- else
- {
- g_free (local_text);
- }
+ if (text != NULL)
+ {
+ *text = local_text;
+ }
+ else
+ {
+ g_free (local_text);
+ }
}
typedef struct
{
- GSLockPlug *plug;
- gint response_id;
- GMainLoop *loop;
- gboolean destroyed;
+ GSLockPlug *plug;
+ gint response_id;
+ GMainLoop *loop;
+ gboolean destroyed;
} RunInfo;
static void
shutdown_loop (RunInfo *ri)
{
- if (g_main_loop_is_running (ri->loop))
- g_main_loop_quit (ri->loop);
+ if (g_main_loop_is_running (ri->loop))
+ g_main_loop_quit (ri->loop);
}
static void
run_unmap_handler (GSLockPlug *plug,
- gpointer data)
+ gpointer data)
{
- RunInfo *ri = data;
+ RunInfo *ri = data;
- shutdown_loop (ri);
+ shutdown_loop (ri);
}
static void
run_response_handler (GSLockPlug *plug,
- gint response_id,
- gpointer data)
+ gint response_id,
+ gpointer data)
{
- RunInfo *ri;
+ RunInfo *ri;
- ri = data;
+ ri = data;
- ri->response_id = response_id;
+ ri->response_id = response_id;
- shutdown_loop (ri);
+ shutdown_loop (ri);
}
static gint
-run_delete_handler (GSLockPlug *plug,
+run_delete_handler (GSLockPlug *plug,
GdkEventAny *event,
- gpointer data)
+ gpointer data)
{
- RunInfo *ri = data;
+ RunInfo *ri = data;
- shutdown_loop (ri);
+ shutdown_loop (ri);
- return TRUE; /* Do not destroy */
+ return TRUE; /* Do not destroy */
}
static void
run_destroy_handler (GSLockPlug *plug,
- gpointer data)
+ gpointer data)
{
- RunInfo *ri = data;
+ RunInfo *ri = data;
- /* shutdown_loop will be called by run_unmap_handler */
- ri->destroyed = TRUE;
+ /* shutdown_loop will be called by run_unmap_handler */
+ ri->destroyed = TRUE;
}
static void
-run_keymap_handler (GdkKeymap *keymap,
+run_keymap_handler (GdkKeymap *keymap,
GSLockPlug *plug)
{
- capslock_update (plug, is_capslock_on ());
+ capslock_update (plug, is_capslock_on ());
}
/* adapted from GTK+ gtkdialog.c */
int
gs_lock_plug_run (GSLockPlug *plug)
{
- RunInfo ri = { NULL, GTK_RESPONSE_NONE, NULL, FALSE };
- gboolean was_modal;
- gulong response_handler;
- gulong unmap_handler;
- gulong destroy_handler;
- gulong delete_handler;
- gulong keymap_handler;
- GdkKeymap *keymap;
-
- g_return_val_if_fail (GS_IS_LOCK_PLUG (plug), -1);
-
- g_object_ref (plug);
-
- was_modal = gtk_window_get_modal (GTK_WINDOW (plug));
- if (!was_modal)
- {
- gtk_window_set_modal (GTK_WINDOW (plug), TRUE);
- }
-
- if (!gtk_widget_get_visible (GTK_WIDGET (plug)))
- {
- gtk_widget_show (GTK_WIDGET (plug));
- }
-
- keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (plug)));
-
- keymap_handler =
- g_signal_connect (keymap,
- "state-changed",
- G_CALLBACK (run_keymap_handler),
- plug);
-
- response_handler =
- g_signal_connect (plug,
- "response",
- G_CALLBACK (run_response_handler),
- &ri);
-
- unmap_handler =
- g_signal_connect (plug,
- "unmap",
- G_CALLBACK (run_unmap_handler),
- &ri);
-
- delete_handler =
- g_signal_connect (plug,
- "delete_event",
- G_CALLBACK (run_delete_handler),
- &ri);
-
- destroy_handler =
- g_signal_connect (plug,
- "destroy",
- G_CALLBACK (run_destroy_handler),
- &ri);
-
- ri.loop = g_main_loop_new (NULL, FALSE);
-
- g_main_loop_run (ri.loop);
-
- g_main_loop_unref (ri.loop);
-
- ri.loop = NULL;
-
- if (!ri.destroyed)
- {
- if (! was_modal)
- {
- gtk_window_set_modal (GTK_WINDOW (plug), FALSE);
- }
+ RunInfo ri = { NULL, GTK_RESPONSE_NONE, NULL, FALSE };
+ gboolean was_modal;
+ gulong response_handler;
+ gulong unmap_handler;
+ gulong destroy_handler;
+ gulong delete_handler;
+ gulong keymap_handler;
+ GdkKeymap *keymap;
+
+ g_return_val_if_fail (GS_IS_LOCK_PLUG (plug), -1);
+
+ g_object_ref (plug);
+
+ was_modal = gtk_window_get_modal (GTK_WINDOW (plug));
+ if (!was_modal)
+ {
+ gtk_window_set_modal (GTK_WINDOW (plug), TRUE);
+ }
+
+ if (!gtk_widget_get_visible (GTK_WIDGET (plug)))
+ {
+ gtk_widget_show (GTK_WIDGET (plug));
+ }
+
+ keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (plug)));
+
+ keymap_handler =
+ g_signal_connect (keymap,
+ "state-changed",
+ G_CALLBACK (run_keymap_handler),
+ plug);
+
+ response_handler =
+ g_signal_connect (plug,
+ "response",
+ G_CALLBACK (run_response_handler),
+ &ri);
+
+ unmap_handler =
+ g_signal_connect (plug,
+ "unmap",
+ G_CALLBACK (run_unmap_handler),
+ &ri);
+
+ delete_handler =
+ g_signal_connect (plug,
+ "delete_event",
+ G_CALLBACK (run_delete_handler),
+ &ri);
+
+ destroy_handler =
+ g_signal_connect (plug,
+ "destroy",
+ G_CALLBACK (run_destroy_handler),
+ &ri);
+
+ ri.loop = g_main_loop_new (NULL, FALSE);
+
+ g_main_loop_run (ri.loop);
+
+ g_main_loop_unref (ri.loop);
+
+ ri.loop = NULL;
+
+ if (!ri.destroyed)
+ {
+ if (!was_modal)
+ {
+ gtk_window_set_modal (GTK_WINDOW (plug), FALSE);
+ }
- g_signal_handler_disconnect (plug, response_handler);
- g_signal_handler_disconnect (plug, unmap_handler);
- g_signal_handler_disconnect (plug, delete_handler);
- g_signal_handler_disconnect (plug, destroy_handler);
- g_signal_handler_disconnect (keymap, keymap_handler);
- }
+ g_signal_handler_disconnect (plug, response_handler);
+ g_signal_handler_disconnect (plug, unmap_handler);
+ g_signal_handler_disconnect (plug, delete_handler);
+ g_signal_handler_disconnect (plug, destroy_handler);
+ g_signal_handler_disconnect (keymap, keymap_handler);
+ }
- g_object_unref (plug);
+ g_object_unref (plug);
- return ri.response_id;
+ return ri.response_id;
}
static gboolean
set_face_image (GSLockPlug *plug)
{
- GdkPixbuf *pixbuf = NULL;
- const char *homedir;
- char *path;
- GError *error = NULL;
+ GdkPixbuf *pixbuf = NULL;
+ const char *homedir;
+ char *path;
+ GError *error = NULL;
- homedir = g_get_home_dir ();
- path = g_build_filename (homedir, ".face", NULL);
+ homedir = g_get_home_dir ();
+ path = g_build_filename (homedir, ".face", NULL);
- pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 80, 80, FALSE, &error);
+ pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 80, 80, FALSE, &error);
- g_free (path);
+ g_free (path);
- if (pixbuf == NULL)
- {
- g_warning ("Could not load the user avatar: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
+ if (pixbuf == NULL)
+ {
+ g_warning ("Could not load the user avatar: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
- gtk_image_set_from_pixbuf (GTK_IMAGE (plug->priv->auth_face_image), pixbuf);
- g_object_unref (pixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (plug->priv->auth_face_image), pixbuf);
+ g_object_unref (pixbuf);
- return TRUE;
+ return TRUE;
}
#if !GTK_CHECK_VERSION (3, 23, 0)
static void
-gs_lock_plug_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width)
+gs_lock_plug_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
gint scale;
@@ -667,7 +669,10 @@ gs_lock_plug_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *
}
static void
-gs_lock_plug_get_preferred_height_for_width (GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height)
+gs_lock_plug_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
gint scale;
@@ -682,154 +687,154 @@ gs_lock_plug_get_preferred_height_for_width (GtkWidget *widget, gint width, gint
static void
gs_lock_plug_show (GtkWidget *widget)
{
- GSLockPlug *plug = GS_LOCK_PLUG (widget);
+ GSLockPlug *plug = GS_LOCK_PLUG (widget);
- gs_profile_start (NULL);
+ gs_profile_start (NULL);
- gs_profile_start ("parent");
- if (GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->show)
- {
- GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->show (widget);
- }
+ gs_profile_start ("parent");
+ if (GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->show)
+ {
+ GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->show (widget);
+ }
- gs_profile_end ("parent");
+ gs_profile_end ("parent");
- if (plug->priv->auth_face_image)
- {
- set_face_image (plug);
- }
+ if (plug->priv->auth_face_image)
+ {
+ set_face_image (plug);
+ }
- capslock_update (plug, is_capslock_on ());
+ capslock_update (plug, is_capslock_on ());
- restart_cancel_timeout (plug);
+ restart_cancel_timeout (plug);
- gs_profile_end (NULL);
+ gs_profile_end (NULL);
}
static void
gs_lock_plug_hide (GtkWidget *widget)
{
- if (GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->hide)
- {
- GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->hide (widget);
- }
+ if (GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->hide)
+ {
+ GTK_WIDGET_CLASS (gs_lock_plug_parent_class)->hide (widget);
+ }
}
static void
queue_key_event (GSLockPlug *plug,
GdkEventKey *event)
{
- GdkEvent *saved_event;
+ GdkEvent *saved_event;
- saved_event = gdk_event_copy ((GdkEvent *)event);
- plug->priv->key_events = g_list_prepend (plug->priv->key_events,
- saved_event);
+ saved_event = gdk_event_copy ((GdkEvent *)event);
+ plug->priv->key_events = g_list_prepend (plug->priv->key_events,
+ saved_event);
}
static void
forward_key_events (GSLockPlug *plug)
{
- plug->priv->key_events = g_list_reverse (plug->priv->key_events);
- while (plug->priv->key_events != NULL)
- {
- GdkEventKey *event = plug->priv->key_events->data;
+ plug->priv->key_events = g_list_reverse (plug->priv->key_events);
+ while (plug->priv->key_events != NULL)
+ {
+ GdkEventKey *event = plug->priv->key_events->data;
- gtk_window_propagate_key_event (GTK_WINDOW (plug), event);
+ gtk_window_propagate_key_event (GTK_WINDOW (plug), event);
- gdk_event_free ((GdkEvent *)event);
+ gdk_event_free ((GdkEvent *)event);
- plug->priv->key_events = g_list_delete_link (plug->priv->key_events,
- plug->priv->key_events);
- }
+ plug->priv->key_events = g_list_delete_link (plug->priv->key_events,
+ plug->priv->key_events);
+ }
}
static void
gs_lock_plug_set_logout_enabled (GSLockPlug *plug,
gboolean logout_enabled)
{
- g_return_if_fail (GS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_LOCK_PLUG (plug));
- if (plug->priv->logout_enabled == logout_enabled)
- {
- return;
- }
+ if (plug->priv->logout_enabled == logout_enabled)
+ {
+ return;
+ }
- plug->priv->logout_enabled = logout_enabled;
- g_object_notify (G_OBJECT (plug), "logout-enabled");
+ plug->priv->logout_enabled = logout_enabled;
+ g_object_notify (G_OBJECT (plug), "logout-enabled");
- if (plug->priv->auth_logout_button == NULL)
- {
- return;
- }
+ if (plug->priv->auth_logout_button == NULL)
+ {
+ return;
+ }
- if (logout_enabled)
- {
- gtk_widget_show (plug->priv->auth_logout_button);
- }
- else
- {
- gtk_widget_hide (plug->priv->auth_logout_button);
- }
+ if (logout_enabled)
+ {
+ gtk_widget_show (plug->priv->auth_logout_button);
+ }
+ else
+ {
+ gtk_widget_hide (plug->priv->auth_logout_button);
+ }
}
static void
gs_lock_plug_set_monitor_index (GSLockPlug *plug,
gint monitor_index)
{
- g_return_if_fail (GS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_LOCK_PLUG (plug));
- if (plug->priv->monitor_index == monitor_index)
- {
- return;
- }
+ if (plug->priv->monitor_index == monitor_index)
+ {
+ return;
+ }
- plug->priv->monitor_index = monitor_index;
- g_object_notify (G_OBJECT (plug), "monitor-index");
+ plug->priv->monitor_index = monitor_index;
+ g_object_notify (G_OBJECT (plug), "monitor-index");
- redraw_background (plug);
+ redraw_background (plug);
}
static void
gs_lock_plug_set_logout_command (GSLockPlug *plug,
const char *command)
{
- g_return_if_fail (GS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_LOCK_PLUG (plug));
- g_free (plug->priv->logout_command);
+ g_free (plug->priv->logout_command);
- if (command)
- {
- plug->priv->logout_command = g_strdup (command);
- }
- else
- {
- plug->priv->logout_command = NULL;
- }
+ if (command)
+ {
+ plug->priv->logout_command = g_strdup (command);
+ }
+ else
+ {
+ plug->priv->logout_command = NULL;
+ }
}
static void
gs_lock_plug_set_status_message (GSLockPlug *plug,
const char *status_message)
{
- g_return_if_fail (GS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_LOCK_PLUG (plug));
- g_free (plug->priv->status_message);
- plug->priv->status_message = g_strdup (status_message);
+ g_free (plug->priv->status_message);
+ plug->priv->status_message = g_strdup (status_message);
- if (plug->priv->status_message_label)
- {
- if (plug->priv->status_message)
- {
- gtk_label_set_text (GTK_LABEL (plug->priv->status_message_label),
- plug->priv->status_message);
- gtk_widget_show (plug->priv->status_message_label);
- }
- else
- {
- gtk_widget_hide (plug->priv->status_message_label);
- }
- }
+ if (plug->priv->status_message_label)
+ {
+ if (plug->priv->status_message)
+ {
+ gtk_label_set_text (GTK_LABEL (plug->priv->status_message_label),
+ plug->priv->status_message);
+ gtk_widget_show (plug->priv->status_message_label);
+ }
+ else
+ {
+ gtk_widget_hide (plug->priv->status_message_label);
+ }
+ }
}
static void
@@ -838,293 +843,293 @@ gs_lock_plug_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GSLockPlug *self;
-
- self = GS_LOCK_PLUG (object);
-
- switch (prop_id)
- {
- case PROP_LOGOUT_ENABLED:
- g_value_set_boolean (value, self->priv->logout_enabled);
- break;
- case PROP_LOGOUT_COMMAND:
- g_value_set_string (value, self->priv->logout_command);
- break;
- case PROP_SWITCH_ENABLED:
- g_value_set_boolean (value, self->priv->switch_enabled);
- break;
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, self->priv->status_message);
- break;
- case PROP_MONITOR_INDEX:
- g_value_set_int (value, self->priv->monitor_index);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSLockPlug *self;
+
+ self = GS_LOCK_PLUG (object);
+
+ switch (prop_id)
+ {
+ case PROP_LOGOUT_ENABLED:
+ g_value_set_boolean (value, self->priv->logout_enabled);
+ break;
+ case PROP_LOGOUT_COMMAND:
+ g_value_set_string (value, self->priv->logout_command);
+ break;
+ case PROP_SWITCH_ENABLED:
+ g_value_set_boolean (value, self->priv->switch_enabled);
+ break;
+ case PROP_STATUS_MESSAGE:
+ g_value_set_string (value, self->priv->status_message);
+ break;
+ case PROP_MONITOR_INDEX:
+ g_value_set_int (value, self->priv->monitor_index);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gs_lock_plug_set_switch_enabled (GSLockPlug *plug,
gboolean switch_enabled)
{
- g_return_if_fail (GS_LOCK_PLUG (plug));
-
- if (plug->priv->switch_enabled == switch_enabled)
- {
- return;
- }
-
- plug->priv->switch_enabled = switch_enabled;
- g_object_notify (G_OBJECT (plug), "switch-enabled");
-
- if (plug->priv->auth_switch_button == NULL)
- {
- return;
- }
-
- if (switch_enabled)
- {
- if (process_is_running ("mdm"))
- {
- /* MDM */
- gtk_widget_show (plug->priv->auth_switch_button);
- }
- else if (process_is_running ("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary"))
- {
- /* GDM */
- gtk_widget_show (plug->priv->auth_switch_button);
- }
- else if (g_getenv ("XDG_SEAT_PATH") != NULL)
- {
- /* LightDM */
- gtk_widget_show (plug->priv->auth_switch_button);
- }
- else
- {
- gs_debug ("Warning: Unknown DM for switch button");
- gtk_widget_hide (plug->priv->auth_switch_button);
- }
- }
- else
- {
- gtk_widget_hide (plug->priv->auth_switch_button);
- }
+ g_return_if_fail (GS_LOCK_PLUG (plug));
+
+ if (plug->priv->switch_enabled == switch_enabled)
+ {
+ return;
+ }
+
+ plug->priv->switch_enabled = switch_enabled;
+ g_object_notify (G_OBJECT (plug), "switch-enabled");
+
+ if (plug->priv->auth_switch_button == NULL)
+ {
+ return;
+ }
+
+ if (switch_enabled)
+ {
+ if (process_is_running ("mdm"))
+ {
+ /* MDM */
+ gtk_widget_show (plug->priv->auth_switch_button);
+ }
+ else if (process_is_running ("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary"))
+ {
+ /* GDM */
+ gtk_widget_show (plug->priv->auth_switch_button);
+ }
+ else if (g_getenv ("XDG_SEAT_PATH") != NULL)
+ {
+ /* LightDM */
+ gtk_widget_show (plug->priv->auth_switch_button);
+ }
+ else
+ {
+ gs_debug ("Warning: Unknown DM for switch button");
+ gtk_widget_hide (plug->priv->auth_switch_button);
+ }
+ }
+ else
+ {
+ gtk_widget_hide (plug->priv->auth_switch_button);
+ }
}
static void
-gs_lock_plug_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GSLockPlug *self;
-
- self = GS_LOCK_PLUG (object);
-
- switch (prop_id)
- {
- case PROP_LOGOUT_ENABLED:
- gs_lock_plug_set_logout_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_LOGOUT_COMMAND:
- gs_lock_plug_set_logout_command (self, g_value_get_string (value));
- break;
- case PROP_STATUS_MESSAGE:
- gs_lock_plug_set_status_message (self, g_value_get_string (value));
- break;
- case PROP_SWITCH_ENABLED:
- gs_lock_plug_set_switch_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_MONITOR_INDEX:
- gs_lock_plug_set_monitor_index (self, g_value_get_int (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gs_lock_plug_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GSLockPlug *self;
+
+ self = GS_LOCK_PLUG (object);
+
+ switch (prop_id)
+ {
+ case PROP_LOGOUT_ENABLED:
+ gs_lock_plug_set_logout_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_LOGOUT_COMMAND:
+ gs_lock_plug_set_logout_command (self, g_value_get_string (value));
+ break;
+ case PROP_STATUS_MESSAGE:
+ gs_lock_plug_set_status_message (self, g_value_get_string (value));
+ break;
+ case PROP_SWITCH_ENABLED:
+ gs_lock_plug_set_switch_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_MONITOR_INDEX:
+ gs_lock_plug_set_monitor_index (self, g_value_get_int (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gs_lock_plug_close (GSLockPlug *plug)
{
- /* Synthesize delete_event to close dialog. */
+ /* Synthesize delete_event to close dialog. */
- GtkWidget *widget = GTK_WIDGET (plug);
- GdkEvent *event;
+ GtkWidget *widget = GTK_WIDGET (plug);
+ GdkEvent *event;
- event = gdk_event_new (GDK_DELETE);
- event->any.window = g_object_ref (gtk_widget_get_window(widget));
- event->any.send_event = TRUE;
+ event = gdk_event_new (GDK_DELETE);
+ event->any.window = g_object_ref (gtk_widget_get_window(widget));
+ event->any.send_event = TRUE;
- gtk_main_do_event (event);
- gdk_event_free (event);
+ gtk_main_do_event (event);
+ gdk_event_free (event);
}
static void
gs_lock_plug_class_init (GSLockPlugClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkBindingSet *binding_set;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkBindingSet *binding_set;
- object_class->finalize = gs_lock_plug_finalize;
- object_class->get_property = gs_lock_plug_get_property;
- object_class->set_property = gs_lock_plug_set_property;
+ object_class->finalize = gs_lock_plug_finalize;
+ object_class->get_property = gs_lock_plug_get_property;
+ object_class->set_property = gs_lock_plug_set_property;
- widget_class->style_set = gs_lock_plug_style_set;
- widget_class->show = gs_lock_plug_show;
- widget_class->hide = gs_lock_plug_hide;
+ widget_class->style_set = gs_lock_plug_style_set;
+ widget_class->show = gs_lock_plug_show;
+ widget_class->hide = gs_lock_plug_hide;
#if !GTK_CHECK_VERSION (3, 23, 0)
- widget_class->get_preferred_width = gs_lock_plug_get_preferred_width;
- widget_class->get_preferred_height_for_width = gs_lock_plug_get_preferred_height_for_width;
+ widget_class->get_preferred_width = gs_lock_plug_get_preferred_width;
+ widget_class->get_preferred_height_for_width = gs_lock_plug_get_preferred_height_for_width;
#endif
- klass->close = gs_lock_plug_close;
-
- lock_plug_signals [RESPONSE] = g_signal_new ("response",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSLockPlugClass, response),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
- lock_plug_signals [CLOSE] = g_signal_new ("close",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GSLockPlugClass, close),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_object_class_install_property (object_class,
- PROP_LOGOUT_ENABLED,
- g_param_spec_boolean ("logout-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOGOUT_COMMAND,
- g_param_spec_string ("logout-command",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_STATUS_MESSAGE,
- g_param_spec_string ("status-message",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SWITCH_ENABLED,
- g_param_spec_boolean ("switch-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_MONITOR_INDEX,
- g_param_spec_int ("monitor-index",
- NULL,
- NULL,
- 0,
- 200,
- 0,
- G_PARAM_READWRITE));
-
- binding_set = gtk_binding_set_by_class (klass);
-
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
- "close", 0);
+ klass->close = gs_lock_plug_close;
+
+ lock_plug_signals [RESPONSE] = g_signal_new ("response",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSLockPlugClass, response),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+ lock_plug_signals [CLOSE] = g_signal_new ("close",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GSLockPlugClass, close),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_ENABLED,
+ g_param_spec_boolean ("logout-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_COMMAND,
+ g_param_spec_string ("logout-command",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_STATUS_MESSAGE,
+ g_param_spec_string ("status-message",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SWITCH_ENABLED,
+ g_param_spec_boolean ("switch-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_MONITOR_INDEX,
+ g_param_spec_int ("monitor-index",
+ NULL,
+ NULL,
+ 0,
+ 200,
+ 0,
+ G_PARAM_READWRITE));
+
+ binding_set = gtk_binding_set_by_class (klass);
+
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
+ "close", 0);
}
static void
clear_clipboards (GSLockPlug *plug)
{
- GtkClipboard *clipboard;
+ GtkClipboard *clipboard;
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (plug), GDK_SELECTION_PRIMARY);
- gtk_clipboard_clear (clipboard);
- gtk_clipboard_set_text (clipboard, "", -1);
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (plug), GDK_SELECTION_CLIPBOARD);
- gtk_clipboard_clear (clipboard);
- gtk_clipboard_set_text (clipboard, "", -1);
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (plug), GDK_SELECTION_PRIMARY);
+ gtk_clipboard_clear (clipboard);
+ gtk_clipboard_set_text (clipboard, "", -1);
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (plug), GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_clear (clipboard);
+ gtk_clipboard_set_text (clipboard, "", -1);
}
static void
logout_button_clicked (GtkButton *button,
GSLockPlug *plug)
{
- char **argv = NULL;
- GError *error = NULL;
- gboolean res;
+ char **argv = NULL;
+ GError *error = NULL;
+ gboolean res;
- if (! plug->priv->logout_command)
- {
- return;
- }
+ if (! plug->priv->logout_command)
+ {
+ return;
+ }
- res = g_shell_parse_argv (plug->priv->logout_command, NULL, &argv, &error);
+ res = g_shell_parse_argv (plug->priv->logout_command, NULL, &argv, &error);
- if (! res)
- {
- g_warning ("Could not parse logout command: %s", error->message);
- g_error_free (error);
- return;
- }
+ if (! res)
+ {
+ g_warning ("Could not parse logout command: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- g_spawn_async (g_get_home_dir (),
- argv,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- NULL,
- &error);
+ g_spawn_async (g_get_home_dir (),
+ argv,
+ NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ NULL,
+ &error);
- g_strfreev (argv);
+ g_strfreev (argv);
- if (error)
- {
- g_warning ("Could not run logout command: %s", error->message);
- g_error_free (error);
- }
+ if (error)
+ {
+ g_warning ("Could not run logout command: %s", error->message);
+ g_error_free (error);
+ }
}
void
gs_lock_plug_set_busy (GSLockPlug *plug)
{
- GdkDisplay *display;
- GdkCursor *cursor;
- GtkWidget *top_level;
+ GdkDisplay *display;
+ GdkCursor *cursor;
+ GtkWidget *top_level;
- top_level = gtk_widget_get_toplevel (GTK_WIDGET (plug));
+ top_level = gtk_widget_get_toplevel (GTK_WIDGET (plug));
- display = gtk_widget_get_display (GTK_WIDGET (plug));
- cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
+ display = gtk_widget_get_display (GTK_WIDGET (plug));
+ cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
- gdk_window_set_cursor (gtk_widget_get_window (top_level), cursor);
- g_object_unref (cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (top_level), cursor);
+ g_object_unref (cursor);
}
void
gs_lock_plug_set_ready (GSLockPlug *plug)
{
- GdkDisplay *display;
- GdkCursor *cursor;
- GtkWidget *top_level;
+ GdkDisplay *display;
+ GdkCursor *cursor;
+ GtkWidget *top_level;
- top_level = gtk_widget_get_toplevel (GTK_WIDGET (plug));
+ top_level = gtk_widget_get_toplevel (GTK_WIDGET (plug));
- display = gtk_widget_get_display (GTK_WIDGET (plug));
- cursor = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);
- gdk_window_set_cursor (gtk_widget_get_window (top_level), cursor);
- g_object_unref (cursor);
+ display = gtk_widget_get_display (GTK_WIDGET (plug));
+ cursor = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);
+ gdk_window_set_cursor (gtk_widget_get_window (top_level), cursor);
+ g_object_unref (cursor);
}
void
@@ -1132,59 +1137,59 @@ gs_lock_plug_enable_prompt (GSLockPlug *plug,
const char *message,
gboolean visible)
{
- g_return_if_fail (GS_IS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_IS_LOCK_PLUG (plug));
- gs_debug ("Setting prompt to: %s", message);
+ gs_debug ("Setting prompt to: %s", message);
- gtk_widget_set_sensitive (plug->priv->auth_unlock_button, TRUE);
- gtk_widget_show (plug->priv->auth_unlock_button);
- gtk_widget_grab_default (plug->priv->auth_unlock_button);
+ gtk_widget_set_sensitive (plug->priv->auth_unlock_button, TRUE);
+ gtk_widget_show (plug->priv->auth_unlock_button);
+ gtk_widget_grab_default (plug->priv->auth_unlock_button);
- gtk_label_set_text(GTK_LABEL(plug->priv->auth_prompt_label), message);
- if (g_utf8_strlen(message, -1) == 0) {
- gtk_widget_hide (GTK_WIDGET (plug->priv->auth_prompt_label));
- } else {
- gtk_widget_show (GTK_WIDGET (plug->priv->auth_prompt_label));
- }
+ gtk_label_set_text(GTK_LABEL(plug->priv->auth_prompt_label), message);
+ if (g_utf8_strlen(message, -1) == 0) {
+ gtk_widget_hide (GTK_WIDGET (plug->priv->auth_prompt_label));
+ } else {
+ gtk_widget_show (GTK_WIDGET (plug->priv->auth_prompt_label));
+ }
- gtk_entry_set_visibility (GTK_ENTRY (plug->priv->auth_prompt_entry), visible);
- gtk_widget_set_sensitive (plug->priv->auth_prompt_entry, TRUE);
- gtk_widget_show (plug->priv->auth_prompt_entry);
+ gtk_entry_set_visibility (GTK_ENTRY (plug->priv->auth_prompt_entry), visible);
+ gtk_widget_set_sensitive (plug->priv->auth_prompt_entry, TRUE);
+ gtk_widget_show (plug->priv->auth_prompt_entry);
- if (! gtk_widget_has_focus (plug->priv->auth_prompt_entry))
- {
- gtk_widget_grab_focus (plug->priv->auth_prompt_entry);
- }
+ if (! gtk_widget_has_focus (plug->priv->auth_prompt_entry))
+ {
+ gtk_widget_grab_focus (plug->priv->auth_prompt_entry);
+ }
- /* were there any key events sent to the plug while the
- * entry wasnt ready? If so, forward them along
- */
- forward_key_events (plug);
+ /* were there any key events sent to the plug while the
+ * entry wasnt ready? If so, forward them along
+ */
+ forward_key_events (plug);
- restart_cancel_timeout (plug);
+ restart_cancel_timeout (plug);
}
void
gs_lock_plug_disable_prompt (GSLockPlug *plug)
{
- g_return_if_fail (GS_IS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_IS_LOCK_PLUG (plug));
- /* gtk_widget_hide (plug->priv->auth_prompt_entry); */
- /* gtk_widget_hide (plug->priv->auth_prompt_label); */
- gtk_widget_set_sensitive (plug->priv->auth_unlock_button, FALSE);
- gtk_widget_set_sensitive (plug->priv->auth_prompt_entry, FALSE);
- /* gtk_widget_hide (plug->priv->auth_unlock_button); */
+ /* gtk_widget_hide (plug->priv->auth_prompt_entry); */
+ /* gtk_widget_hide (plug->priv->auth_prompt_label); */
+ gtk_widget_set_sensitive (plug->priv->auth_unlock_button, FALSE);
+ gtk_widget_set_sensitive (plug->priv->auth_prompt_entry, FALSE);
+ /* gtk_widget_hide (plug->priv->auth_unlock_button); */
- gtk_widget_grab_default (plug->priv->auth_cancel_button);
+ gtk_widget_grab_default (plug->priv->auth_cancel_button);
}
void
gs_lock_plug_show_message (GSLockPlug *plug,
const char *message)
{
- g_return_if_fail (GS_IS_LOCK_PLUG (plug));
+ g_return_if_fail (GS_IS_LOCK_PLUG (plug));
- set_status_text (plug, message ? message : "");
+ set_status_text (plug, message ? message : "");
}
/* button press handler used to inhibit popup menu */
@@ -1192,12 +1197,12 @@ static gint
entry_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
- {
- return TRUE;
- }
+ if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+ {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static gint
@@ -1205,25 +1210,25 @@ entry_key_press (GtkWidget *widget,
GdkEventKey *event,
GSLockPlug *plug)
{
- restart_cancel_timeout (plug);
+ restart_cancel_timeout (plug);
- /* if the input widget is visible and ready for input
- * then just carry on as usual
- */
- if (gtk_widget_get_visible (plug->priv->auth_prompt_entry) &&
- gtk_widget_is_sensitive (plug->priv->auth_prompt_entry))
- {
- return FALSE;
- }
+ /* if the input widget is visible and ready for input
+ * then just carry on as usual
+ */
+ if (gtk_widget_get_visible (plug->priv->auth_prompt_entry) &&
+ gtk_widget_is_sensitive (plug->priv->auth_prompt_entry))
+ {
+ return FALSE;
+ }
- if (strcmp (event->string, "") == 0)
- {
- return FALSE;
- }
+ if (strcmp (event->string, "") == 0)
+ {
+ return FALSE;
+ }
- queue_key_event (plug, event);
+ queue_key_event (plug, event);
- return TRUE;
+ return TRUE;
}
/* adapted from gtk_dialog_add_button */
@@ -1232,511 +1237,509 @@ gs_lock_plug_add_button (GSLockPlug *plug,
GtkWidget *action_area,
const gchar *button_text)
{
- GtkWidget *button;
+ GtkWidget *button;
- g_return_val_if_fail (GS_IS_LOCK_PLUG (plug), NULL);
- g_return_val_if_fail (button_text != NULL, NULL);
+ g_return_val_if_fail (GS_IS_LOCK_PLUG (plug), NULL);
+ g_return_val_if_fail (button_text != NULL, NULL);
- button = gtk_button_new_with_label (button_text);
+ button = gtk_button_new_with_label (button_text);
- gtk_widget_set_can_default (button, TRUE);
+ gtk_widget_set_can_default (button, TRUE);
- gtk_widget_show (button);
+ gtk_widget_show (button);
- gtk_box_pack_end (GTK_BOX (action_area),
- button,
- FALSE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (action_area),
+ button,
+ FALSE, TRUE, 0);
- return button;
+ return button;
}
static char *
get_user_display_name (void)
{
- const char *name;
- char *utf8_name;
+ const char *name;
+ char *utf8_name;
- name = g_get_real_name ();
+ name = g_get_real_name ();
- if (name == NULL || g_strcmp0 (name, "") == 0 ||
- g_strcmp0 (name, "Unknown") == 0)
- {
- name = g_get_user_name ();
- }
+ if (name == NULL || g_strcmp0 (name, "") == 0 ||
+ g_strcmp0 (name, "Unknown") == 0)
+ {
+ name = g_get_user_name ();
+ }
- utf8_name = NULL;
+ utf8_name = NULL;
- if (name != NULL)
- {
- utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
- }
+ if (name != NULL)
+ {
+ utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
+ }
- return utf8_name;
+ return utf8_name;
}
static char *
get_user_name (void)
{
- const char *name;
- char *utf8_name;
+ const char *name;
+ char *utf8_name;
- name = g_get_user_name ();
+ name = g_get_user_name ();
- utf8_name = NULL;
- if (name != NULL)
- {
- utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
- }
+ utf8_name = NULL;
+ if (name != NULL)
+ {
+ utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
+ }
- return utf8_name;
+ return utf8_name;
}
static void
create_page_one_buttons (GSLockPlug *plug)
{
+ gs_profile_start ("page one buttons");
- gs_profile_start ("page one buttons");
-
- plug->priv->auth_switch_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
- plug->priv->auth_action_area,
- _("S_witch User..."));
- gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (plug->priv->auth_action_area),
- plug->priv->auth_switch_button,
- TRUE);
- gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_switch_button), FALSE);
- gtk_widget_set_no_show_all (plug->priv->auth_switch_button, TRUE);
+ plug->priv->auth_switch_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
+ plug->priv->auth_action_area,
+ _("S_witch User..."));
+ gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (plug->priv->auth_action_area),
+ plug->priv->auth_switch_button,
+ TRUE);
+ gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_switch_button), FALSE);
+ gtk_widget_set_no_show_all (plug->priv->auth_switch_button, TRUE);
- plug->priv->auth_logout_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
- plug->priv->auth_action_area,
- _("Log _Out"));
- gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_logout_button), FALSE);
- gtk_widget_set_no_show_all (plug->priv->auth_logout_button, TRUE);
+ plug->priv->auth_logout_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
+ plug->priv->auth_action_area,
+ _("Log _Out"));
+ gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_logout_button), FALSE);
+ gtk_widget_set_no_show_all (plug->priv->auth_logout_button, TRUE);
- plug->priv->auth_cancel_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
- plug->priv->auth_action_area,
- _("_Cancel"));
- gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_cancel_button), FALSE);
+ plug->priv->auth_cancel_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
+ plug->priv->auth_action_area,
+ _("_Cancel"));
+ gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_cancel_button), FALSE);
- plug->priv->auth_unlock_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
- plug->priv->auth_action_area,
- _("_Unlock"));
- gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_unlock_button), FALSE);
+ plug->priv->auth_unlock_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
+ plug->priv->auth_action_area,
+ _("_Unlock"));
+ gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_unlock_button), FALSE);
- gtk_window_set_default (GTK_WINDOW (plug), plug->priv->auth_unlock_button);
+ gtk_window_set_default (GTK_WINDOW (plug), plug->priv->auth_unlock_button);
- gs_profile_end ("page one buttons");
+ gs_profile_end ("page one buttons");
}
/* adapted from MDM */
static char *
expand_string (const char *text)
{
- GString *str;
- const char *p;
- char *username;
- int i;
- int n_chars;
- struct utsname name;
-
- str = g_string_sized_new (strlen (text));
-
- p = text;
- n_chars = g_utf8_strlen (text, -1);
- i = 0;
-
- while (i < n_chars)
- {
- gunichar ch;
-
- ch = g_utf8_get_char (p);
-
- /* Backslash commands */
- if (ch == '\\')
- {
- p = g_utf8_next_char (p);
- i++;
- ch = g_utf8_get_char (p);
-
- if (i >= n_chars || ch == '\0')
- {
- g_warning ("Unescaped \\ at end of text\n");
- goto bail;
- }
- else if (ch == 'n')
- {
- g_string_append_unichar (str, '\n');
- }
- else
- {
- g_string_append_unichar (str, ch);
- }
- }
- else if (ch == '%')
- {
- p = g_utf8_next_char (p);
- i++;
- ch = g_utf8_get_char (p);
-
- if (i >= n_chars || ch == '\0')
- {
- g_warning ("Unescaped %% at end of text\n");
- goto bail;
- }
-
- switch (ch)
- {
- case '%':
- g_string_append (str, "%");
- break;
- case 'c':
- /* clock */
- break;
- case 'd':
- /* display */
- g_string_append (str, g_getenv ("DISPLAY"));
- break;
- case 'h':
- /* hostname */
- g_string_append (str, g_get_host_name ());
- break;
- case 'm':
- /* machine name */
- uname (&name);
- g_string_append (str, name.machine);
- break;
- case 'n':
- /* nodename */
- uname (&name);
- g_string_append (str, name.nodename);
- break;
- case 'r':
- /* release */
- uname (&name);
- g_string_append (str, name.release);
- break;
- case 'R':
- /* Real name */
- username = get_user_display_name ();
- g_string_append (str, username);
- g_free (username);
- break;
- case 's':
- /* system name */
- uname (&name);
- g_string_append (str, name.sysname);
- break;
- case 'U':
- /* Username */
- username = get_user_name ();
- g_string_append (str, username);
- g_free (username);
- break;
- default:
- if (ch < 127)
- {
- g_warning ("unknown escape code %%%c in text\n", (char)ch);
- }
- else
- {
- g_warning ("unknown escape code %%(U%x) in text\n", (int)ch);
- }
- }
- }
- else
- {
- g_string_append_unichar (str, ch);
- }
- p = g_utf8_next_char (p);
- i++;
- }
+ GString *str;
+ const char *p;
+ char *username;
+ int i;
+ int n_chars;
+ struct utsname name;
+
+ str = g_string_sized_new (strlen (text));
+
+ p = text;
+ n_chars = g_utf8_strlen (text, -1);
+ i = 0;
+
+ while (i < n_chars)
+ {
+ gunichar ch;
+
+ ch = g_utf8_get_char (p);
+
+ /* Backslash commands */
+ if (ch == '\\')
+ {
+ p = g_utf8_next_char (p);
+ i++;
+ ch = g_utf8_get_char (p);
+
+ if (i >= n_chars || ch == '\0')
+ {
+ g_warning ("Unescaped \\ at end of text\n");
+ goto bail;
+ }
+ else if (ch == 'n')
+ {
+ g_string_append_unichar (str, '\n');
+ }
+ else
+ {
+ g_string_append_unichar (str, ch);
+ }
+ }
+ else if (ch == '%')
+ {
+ p = g_utf8_next_char (p);
+ i++;
+ ch = g_utf8_get_char (p);
+
+ if (i >= n_chars || ch == '\0')
+ {
+ g_warning ("Unescaped %% at end of text\n");
+ goto bail;
+ }
+
+ switch (ch)
+ {
+ case '%':
+ g_string_append (str, "%");
+ break;
+ case 'c':
+ /* clock */
+ break;
+ case 'd':
+ /* display */
+ g_string_append (str, g_getenv ("DISPLAY"));
+ break;
+ case 'h':
+ /* hostname */
+ g_string_append (str, g_get_host_name ());
+ break;
+ case 'm':
+ /* machine name */
+ uname (&name);
+ g_string_append (str, name.machine);
+ break;
+ case 'n':
+ /* nodename */
+ uname (&name);
+ g_string_append (str, name.nodename);
+ break;
+ case 'r':
+ /* release */
+ uname (&name);
+ g_string_append (str, name.release);
+ break;
+ case 'R':
+ /* Real name */
+ username = get_user_display_name ();
+ g_string_append (str, username);
+ g_free (username);
+ break;
+ case 's':
+ /* system name */
+ uname (&name);
+ g_string_append (str, name.sysname);
+ break;
+ case 'U':
+ /* Username */
+ username = get_user_name ();
+ g_string_append (str, username);
+ g_free (username);
+ break;
+ default:
+ if (ch < 127)
+ {
+ g_warning ("unknown escape code %%%c in text\n", (char)ch);
+ }
+ else
+ {
+ g_warning ("unknown escape code %%(U%x) in text\n", (int)ch);
+ }
+ }
+ }
+ else
+ {
+ g_string_append_unichar (str, ch);
+ }
+ p = g_utf8_next_char (p);
+ i++;
+ }
bail:
- return g_string_free (str, FALSE);
+ return g_string_free (str, FALSE);
}
static void
expand_string_for_label (GtkWidget *label)
{
- const char *template;
- char *str;
+ const char *template;
+ char *str;
- template = gtk_label_get_label (GTK_LABEL (label));
- str = expand_string (template);
- gtk_label_set_label (GTK_LABEL (label), str);
- g_free (str);
+ template = gtk_label_get_label (GTK_LABEL (label));
+ str = expand_string (template);
+ gtk_label_set_label (GTK_LABEL (label), str);
+ g_free (str);
}
static void
create_page_one (GSLockPlug *plug)
{
- GtkWidget *vbox;
- GtkWidget *vbox2;
- GtkWidget *hbox;
- char *str;
+ GtkWidget *vbox;
+ GtkWidget *vbox2;
+ GtkWidget *hbox;
+ char *str;
- gs_profile_start ("page one");
+ gs_profile_start ("page one");
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- gtk_widget_set_halign (GTK_WIDGET (vbox),
- GTK_ALIGN_CENTER);
- gtk_widget_set_valign (GTK_WIDGET (vbox),
- GTK_ALIGN_CENTER);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+ gtk_widget_set_halign (GTK_WIDGET (vbox),
+ GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (GTK_WIDGET (vbox),
+ GTK_ALIGN_CENTER);
- vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
- plug->priv->auth_face_image = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (vbox), plug->priv->auth_face_image, TRUE, TRUE, 0);
- gtk_widget_set_halign (plug->priv->auth_face_image, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (plug->priv->auth_face_image, GTK_ALIGN_END);
+ plug->priv->auth_face_image = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (vbox), plug->priv->auth_face_image, TRUE, TRUE, 0);
+ gtk_widget_set_halign (plug->priv->auth_face_image, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (plug->priv->auth_face_image, GTK_ALIGN_END);
- vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
- str = g_strdup ("<span size=\"x-large\">%R</span>");
- plug->priv->auth_realname_label = gtk_label_new (str);
- g_free (str);
- expand_string_for_label (plug->priv->auth_realname_label);
- gtk_label_set_xalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
- gtk_label_set_yalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
- gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_realname_label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_realname_label, FALSE, FALSE, 0);
+ str = g_strdup ("<span size=\"x-large\">%R</span>");
+ plug->priv->auth_realname_label = gtk_label_new (str);
+ g_free (str);
+ expand_string_for_label (plug->priv->auth_realname_label);
+ gtk_label_set_xalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
+ gtk_label_set_yalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
+ gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_realname_label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_realname_label, FALSE, FALSE, 0);
- /* To translators: This expands to USERNAME on HOSTNAME */
- str = g_strdup_printf ("<span size=\"small\">%s</span>", _("%U on %h"));
- plug->priv->auth_username_label = gtk_label_new (str);
- g_free (str);
- expand_string_for_label (plug->priv->auth_username_label);
- gtk_label_set_xalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
- gtk_label_set_yalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
- gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_username_label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_username_label, FALSE, FALSE, 0);
+ /* To translators: This expands to USERNAME on HOSTNAME */
+ str = g_strdup_printf ("<span size=\"small\">%s</span>", _("%U on %h"));
+ plug->priv->auth_username_label = gtk_label_new (str);
+ g_free (str);
+ expand_string_for_label (plug->priv->auth_username_label);
+ gtk_label_set_xalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
+ gtk_label_set_yalign (GTK_LABEL (plug->priv->auth_realname_label), 0.5);
+ gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_username_label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_username_label, FALSE, FALSE, 0);
- vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0);
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0);
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
- plug->priv->auth_prompt_label = gtk_label_new (_("Please enter your password."));
- gtk_box_pack_start (GTK_BOX (hbox), plug->priv->auth_prompt_label, FALSE, FALSE, 0);
+ plug->priv->auth_prompt_label = gtk_label_new (_("Please enter your password."));
+ gtk_box_pack_start (GTK_BOX (hbox), plug->priv->auth_prompt_label, FALSE, FALSE, 0);
- plug->priv->auth_prompt_entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), plug->priv->auth_prompt_entry, TRUE, TRUE, 0);
+ plug->priv->auth_prompt_entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), plug->priv->auth_prompt_entry, TRUE, TRUE, 0);
- gtk_label_set_mnemonic_widget (GTK_LABEL (plug->priv->auth_prompt_label),
- plug->priv->auth_prompt_entry);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (plug->priv->auth_prompt_label),
+ plug->priv->auth_prompt_entry);
- /* Status text */
+ /* Status text */
- plug->priv->auth_message_label = gtk_label_new (NULL);
- gtk_box_pack_start (GTK_BOX (vbox), plug->priv->auth_message_label,
- FALSE, FALSE, 0);
- /* Buttons */
- plug->priv->auth_action_area = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+ plug->priv->auth_message_label = gtk_label_new (NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), plug->priv->auth_message_label,
+ FALSE, FALSE, 0);
+ /* Buttons */
+ plug->priv->auth_action_area = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (plug->priv->auth_action_area),
- GTK_BUTTONBOX_END);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (plug->priv->auth_action_area),
+ GTK_BUTTONBOX_END);
- gtk_box_pack_end (GTK_BOX (vbox), plug->priv->auth_action_area,
- FALSE, TRUE, 0);
- gtk_widget_show (plug->priv->auth_action_area);
+ gtk_box_pack_end (GTK_BOX (vbox), plug->priv->auth_action_area,
+ FALSE, TRUE, 0);
+ gtk_widget_show (plug->priv->auth_action_area);
- create_page_one_buttons (plug);
+ create_page_one_buttons (plug);
- gs_profile_end ("page one");
+ gs_profile_end ("page one");
}
static void
unlock_button_clicked (GtkButton *button,
GSLockPlug *plug)
{
- gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_OK);
+ gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_OK);
}
static void
cancel_button_clicked (GtkButton *button,
GSLockPlug *plug)
{
- gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
+ gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
}
static void
switch_user_button_clicked (GtkButton *button,
GSLockPlug *plug)
{
+ remove_response_idle (plug);
- remove_response_idle (plug);
+ gs_lock_plug_set_sensitive (plug, FALSE);
- gs_lock_plug_set_sensitive (plug, FALSE);
+ plug->priv->response_idle_id = g_timeout_add (2000,
+ (GSourceFunc)response_cancel_idle_cb,
+ plug);
- plug->priv->response_idle_id = g_timeout_add (2000,
- (GSourceFunc)response_cancel_idle_cb,
- plug);
-
- gs_lock_plug_set_busy (plug);
- do_user_switch (plug);
+ gs_lock_plug_set_busy (plug);
+ do_user_switch (plug);
}
static void
get_draw_dimensions(GSLockPlug *plug,
- XfceBG *bg,
- gint *screen_width,
- gint *screen_height,
- gint *monitor_width,
- gint *monitor_height)
-{
- GdkWindow *window;
- GdkDisplay *display;
- GdkScreen *screen;
- GdkMonitor *monitor;
- GdkRectangle geometry;
- gint scale;
-
- window = gtk_widget_get_window (GTK_WIDGET(plug));
- if (window != NULL) {
- display = gdk_window_get_display(window);
- } else {
- display = gdk_display_get_default();
- }
- screen = gdk_display_get_default_screen(display);
- scale = gdk_window_get_scale_factor(gdk_screen_get_root_window(screen));
-
- monitor = gdk_display_get_monitor (display, plug->priv->monitor_index);
- if (!monitor)
- {
- if (window != NULL)
- monitor = gdk_display_get_monitor_at_window(display, window);
- else
- monitor = gdk_display_get_primary_monitor(display);
-
- if (!monitor)
- monitor = gdk_display_get_monitor (display, 0);
- }
-
- xfce_bg_load_from_preferences(bg, monitor);
-
- gdk_monitor_get_geometry(monitor, &geometry);
- *monitor_width = geometry.width / scale;
- *monitor_height = geometry.height / scale;
- *screen_width = WidthOfScreen(gdk_x11_screen_get_xscreen(screen)) / scale;
- *screen_height = HeightOfScreen(gdk_x11_screen_get_xscreen(screen)) / scale;
+ XfceBG *bg,
+ gint *screen_width,
+ gint *screen_height,
+ gint *monitor_width,
+ gint *monitor_height)
+{
+ GdkWindow *window;
+ GdkDisplay *display;
+ GdkScreen *screen;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
+ gint scale;
+
+ window = gtk_widget_get_window (GTK_WIDGET(plug));
+ if (window != NULL) {
+ display = gdk_window_get_display(window);
+ } else {
+ display = gdk_display_get_default();
+ }
+ screen = gdk_display_get_default_screen(display);
+ scale = gdk_window_get_scale_factor(gdk_screen_get_root_window(screen));
+
+ monitor = gdk_display_get_monitor (display, plug->priv->monitor_index);
+ if (!monitor)
+ {
+ if (window != NULL)
+ monitor = gdk_display_get_monitor_at_window(display, window);
+ else
+ monitor = gdk_display_get_primary_monitor(display);
+
+ if (!monitor)
+ monitor = gdk_display_get_monitor (display, 0);
+ }
+
+ xfce_bg_load_from_preferences(bg, monitor);
+
+ gdk_monitor_get_geometry(monitor, &geometry);
+ *monitor_width = geometry.width / scale;
+ *monitor_height = geometry.height / scale;
+ *screen_width = WidthOfScreen(gdk_x11_screen_get_xscreen(screen)) / scale;
+ *screen_height = HeightOfScreen(gdk_x11_screen_get_xscreen(screen)) / scale;
}
static void
redraw_background (GSLockPlug *plug)
{
- XfceBG *bg;
- GdkPixbuf *pixbuf;
- gint screen_width, screen_height, monitor_width, monitor_height;
+ XfceBG *bg;
+ GdkPixbuf *pixbuf;
+ gint screen_width, screen_height, monitor_width, monitor_height;
- bg = xfce_bg_new();
- get_draw_dimensions(plug, bg, &screen_width, &screen_height, &monitor_width, &monitor_height);
- pixbuf = xfce_bg_get_pixbuf(bg, screen_width, screen_height, monitor_width, monitor_height);
- gtk_image_set_from_pixbuf(GTK_IMAGE(plug->priv->background_image), pixbuf);
+ bg = xfce_bg_new();
+ get_draw_dimensions(plug, bg, &screen_width, &screen_height, &monitor_width, &monitor_height);
+ pixbuf = xfce_bg_get_pixbuf(bg, screen_width, screen_height, monitor_width, monitor_height);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(plug->priv->background_image), pixbuf);
}
static gboolean
load_theme (GSLockPlug *plug)
{
- char *theme;
- char *filename;
- char *gtkbuilder;
- char *css;
- GtkBuilder *builder;
- GtkWidget *lock_overlay;
- GtkWidget *lock_panel;
- GtkWidget *lock_dialog;
- GError *error=NULL;
-
- theme = g_strdup("default");
-
- filename = g_strdup_printf ("lock-dialog-%s.ui", theme);
- gtkbuilder = g_build_filename (GTKBUILDERDIR, filename, NULL);
- g_free (filename);
- if (! g_file_test (gtkbuilder, G_FILE_TEST_IS_REGULAR))
- {
- g_free (gtkbuilder);
- g_free (theme);
- return FALSE;
- }
-
- filename = g_strdup_printf ("lock-dialog-%s.css", theme);
- g_free (theme);
-
- css = g_build_filename (GTKBUILDERDIR, filename, NULL);
- g_free (filename);
- if (g_file_test (css, G_FILE_TEST_IS_REGULAR))
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.24 */
- GtkCssProvider *style_provider = gtk_css_provider_get_default ();
- G_GNUC_END_IGNORE_DEPRECATIONS
- gtk_css_provider_load_from_path (style_provider, css, NULL);
- }
- g_free (css);
-
- builder = gtk_builder_new();
- if (!gtk_builder_add_from_file (builder,gtkbuilder,&error))
- {
- g_warning ("Couldn't load builder file '%s': %s", gtkbuilder, error->message);
- g_error_free(error);
- g_free (gtkbuilder);
- return FALSE;
- }
- g_free (gtkbuilder);
-
- lock_overlay = GTK_WIDGET(gtk_builder_get_object(builder, "lock-overlay"));
- lock_panel = GTK_WIDGET(gtk_builder_get_object(builder, "lock-panel"));
- lock_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "lock-dialog"));
-
- gtk_widget_set_halign(GTK_WIDGET(lock_panel), GTK_ALIGN_FILL);
- gtk_widget_set_valign(GTK_WIDGET(lock_panel), GTK_ALIGN_START);
- gtk_overlay_add_overlay(GTK_OVERLAY(lock_overlay), GTK_WIDGET(lock_panel));
-
- gtk_widget_set_halign(GTK_WIDGET(lock_dialog), GTK_ALIGN_CENTER);
- gtk_widget_set_valign(GTK_WIDGET(lock_dialog), GTK_ALIGN_CENTER);
- gtk_overlay_add_overlay(GTK_OVERLAY(lock_overlay), GTK_WIDGET(lock_dialog));
-
- gtk_container_add(GTK_CONTAINER(plug), lock_overlay);
-
- plug->priv->vbox = NULL;
-
- plug->priv->auth_face_image = GTK_WIDGET (gtk_builder_get_object(builder, "auth-face-image"));
- plug->priv->auth_action_area = GTK_WIDGET (gtk_builder_get_object(builder, "auth-action-area"));
- plug->priv->auth_datetime_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-date-time-label"));
- plug->priv->auth_realname_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-realname-label"));
- plug->priv->auth_username_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-hostname-label"));
- plug->priv->auth_prompt_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-label"));
- plug->priv->auth_prompt_entry = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-entry"));
- plug->priv->auth_prompt_box = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-box"));
- plug->priv->auth_capslock_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-capslock-label"));
- plug->priv->auth_message_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-status-label"));
- plug->priv->auth_unlock_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-unlock-button"));
- plug->priv->auth_cancel_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-cancel-button"));
- plug->priv->auth_logout_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-logout-button"));
- plug->priv->auth_switch_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-switch-button"));
- plug->priv->background_image = GTK_WIDGET (gtk_builder_get_object(builder, "lock-image"));
-
- /* Placeholder for the keyboard indicator */
- plug->priv->auth_prompt_kbd_layout_indicator = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-kbd-layout-indicator"));
- if (plug->priv->auth_logout_button != NULL)
- {
- gtk_widget_set_no_show_all (plug->priv->auth_logout_button, TRUE);
- }
- if (plug->priv->auth_switch_button != NULL)
- {
- gtk_widget_set_no_show_all (plug->priv->auth_switch_button, TRUE);
- }
-
- redraw_background (plug);
-
- date_time_update (plug);
- gtk_widget_show_all (lock_dialog);
-
- plug->priv->status_message_label = GTK_WIDGET (gtk_builder_get_object(builder, "status-message-label"));
-
- return TRUE;
+ char *theme;
+ char *filename;
+ char *gtkbuilder;
+ char *css;
+ GtkBuilder *builder;
+ GtkWidget *lock_overlay;
+ GtkWidget *lock_panel;
+ GtkWidget *lock_dialog;
+ GError *error=NULL;
+
+ theme = g_strdup("default");
+
+ filename = g_strdup_printf ("lock-dialog-%s.ui", theme);
+ gtkbuilder = g_build_filename (GTKBUILDERDIR, filename, NULL);
+ g_free (filename);
+ if (! g_file_test (gtkbuilder, G_FILE_TEST_IS_REGULAR))
+ {
+ g_free (gtkbuilder);
+ g_free (theme);
+ return FALSE;
+ }
+
+ filename = g_strdup_printf ("lock-dialog-%s.css", theme);
+ g_free (theme);
+
+ css = g_build_filename (GTKBUILDERDIR, filename, NULL);
+ g_free (filename);
+ if (g_file_test (css, G_FILE_TEST_IS_REGULAR))
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.24 */
+ GtkCssProvider *style_provider = gtk_css_provider_get_default ();
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ gtk_css_provider_load_from_path (style_provider, css, NULL);
+ }
+ g_free (css);
+
+ builder = gtk_builder_new();
+ if (!gtk_builder_add_from_file (builder,gtkbuilder,&error))
+ {
+ g_warning ("Couldn't load builder file '%s': %s", gtkbuilder, error->message);
+ g_error_free(error);
+ g_free (gtkbuilder);
+ return FALSE;
+ }
+ g_free (gtkbuilder);
+
+ lock_overlay = GTK_WIDGET(gtk_builder_get_object(builder, "lock-overlay"));
+ lock_panel = GTK_WIDGET(gtk_builder_get_object(builder, "lock-panel"));
+ lock_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "lock-dialog"));
+
+ gtk_widget_set_halign(GTK_WIDGET(lock_panel), GTK_ALIGN_FILL);
+ gtk_widget_set_valign(GTK_WIDGET(lock_panel), GTK_ALIGN_START);
+ gtk_overlay_add_overlay(GTK_OVERLAY(lock_overlay), GTK_WIDGET(lock_panel));
+
+ gtk_widget_set_halign(GTK_WIDGET(lock_dialog), GTK_ALIGN_CENTER);
+ gtk_widget_set_valign(GTK_WIDGET(lock_dialog), GTK_ALIGN_CENTER);
+ gtk_overlay_add_overlay(GTK_OVERLAY(lock_overlay), GTK_WIDGET(lock_dialog));
+
+ gtk_container_add(GTK_CONTAINER(plug), lock_overlay);
+
+ plug->priv->vbox = NULL;
+
+ plug->priv->auth_face_image = GTK_WIDGET (gtk_builder_get_object(builder, "auth-face-image"));
+ plug->priv->auth_action_area = GTK_WIDGET (gtk_builder_get_object(builder, "auth-action-area"));
+ plug->priv->auth_datetime_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-date-time-label"));
+ plug->priv->auth_realname_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-realname-label"));
+ plug->priv->auth_username_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-hostname-label"));
+ plug->priv->auth_prompt_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-label"));
+ plug->priv->auth_prompt_entry = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-entry"));
+ plug->priv->auth_prompt_box = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-box"));
+ plug->priv->auth_capslock_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-capslock-label"));
+ plug->priv->auth_message_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-status-label"));
+ plug->priv->auth_unlock_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-unlock-button"));
+ plug->priv->auth_cancel_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-cancel-button"));
+ plug->priv->auth_logout_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-logout-button"));
+ plug->priv->auth_switch_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-switch-button"));
+ plug->priv->background_image = GTK_WIDGET (gtk_builder_get_object(builder, "lock-image"));
+
+ /* Placeholder for the keyboard indicator */
+ plug->priv->auth_prompt_kbd_layout_indicator = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-kbd-layout-indicator"));
+ if (plug->priv->auth_logout_button != NULL)
+ {
+ gtk_widget_set_no_show_all (plug->priv->auth_logout_button, TRUE);
+ }
+ if (plug->priv->auth_switch_button != NULL)
+ {
+ gtk_widget_set_no_show_all (plug->priv->auth_switch_button, TRUE);
+ }
+
+ redraw_background (plug);
+
+ date_time_update (plug);
+ gtk_widget_show_all (lock_dialog);
+
+ plug->priv->status_message_label = GTK_WIDGET (gtk_builder_get_object(builder, "status-message-label"));
+
+ return TRUE;
}
static int
@@ -1744,181 +1747,181 @@ delete_handler (GSLockPlug *plug,
GdkEventAny *event,
gpointer data)
{
- gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
+ gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
- return TRUE; /* Do not destroy */
+ return TRUE; /* Do not destroy */
}
static void
gs_lock_plug_init (GSLockPlug *plug)
{
- gs_profile_start (NULL);
+ gs_profile_start (NULL);
- plug->priv = gs_lock_plug_get_instance_private (plug);
+ plug->priv = gs_lock_plug_get_instance_private (plug);
- clear_clipboards (plug);
+ clear_clipboards (plug);
- GtkStyleContext *context;
+ GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET (plug));
- gtk_style_context_add_class (context, "lock-dialog");
+ context = gtk_widget_get_style_context (GTK_WIDGET (plug));
+ gtk_style_context_add_class (context, "lock-dialog");
- if (! load_theme (plug))
- {
- gs_debug ("Unable to load theme!");
+ if (!load_theme (plug))
+ {
+ gs_debug ("Unable to load theme!");
- plug->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (plug), plug->priv->vbox);
+ plug->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_add (GTK_CONTAINER (plug), plug->priv->vbox);
- /* Page 1 */
+ /* Page 1 */
- create_page_one (plug);
+ create_page_one (plug);
- date_time_update (plug);
- gtk_widget_show_all (plug->priv->vbox);
- }
- plug->priv->datetime_timeout_id = g_timeout_add_seconds (60, (GSourceFunc) date_time_update, plug);
+ date_time_update (plug);
+ gtk_widget_show_all (plug->priv->vbox);
+ }
+ plug->priv->datetime_timeout_id = g_timeout_add_seconds (60, (GSourceFunc) date_time_update, plug);
- /* Layout indicator */
+ /* Layout indicator */
#ifdef WITH_KBD_LAYOUT_INDICATOR
- if (plug->priv->auth_prompt_kbd_layout_indicator != NULL)
- {
- XklEngine *engine;
-
- engine = xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
- if (xkl_engine_get_num_groups (engine) > 1)
- {
- GtkWidget *layout_indicator;
-
- layout_indicator = xfcekbd_indicator_new ();
- xfcekbd_indicator_set_parent_tooltips (XFCEKBD_INDICATOR (layout_indicator), TRUE);
- gtk_box_pack_start (GTK_BOX (plug->priv->auth_prompt_kbd_layout_indicator),
- layout_indicator,
- FALSE,
- FALSE,
- 6);
-
- gtk_widget_show_all (layout_indicator);
- gtk_widget_show (plug->priv->auth_prompt_kbd_layout_indicator);
- }
- else
- {
- gtk_widget_hide (plug->priv->auth_prompt_kbd_layout_indicator);
- }
-
- g_object_unref (engine);
- }
+ if (plug->priv->auth_prompt_kbd_layout_indicator != NULL)
+ {
+ XklEngine *engine;
+
+ engine = xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+ if (xkl_engine_get_num_groups (engine) > 1)
+ {
+ GtkWidget *layout_indicator;
+
+ layout_indicator = xfcekbd_indicator_new ();
+ xfcekbd_indicator_set_parent_tooltips (XFCEKBD_INDICATOR (layout_indicator), TRUE);
+ gtk_box_pack_start (GTK_BOX (plug->priv->auth_prompt_kbd_layout_indicator),
+ layout_indicator,
+ FALSE,
+ FALSE,
+ 6);
+
+ gtk_widget_show_all (layout_indicator);
+ gtk_widget_show (plug->priv->auth_prompt_kbd_layout_indicator);
+ }
+ else
+ {
+ gtk_widget_hide (plug->priv->auth_prompt_kbd_layout_indicator);
+ }
+
+ g_object_unref (engine);
+ }
#endif
- if (plug->priv->auth_switch_button != NULL)
- {
- if (plug->priv->switch_enabled)
- {
- gtk_widget_show_all (plug->priv->auth_switch_button);
- }
- else
- {
- gtk_widget_hide (plug->priv->auth_switch_button);
- }
- }
-
- gtk_widget_grab_default (plug->priv->auth_unlock_button);
-
- if (plug->priv->auth_username_label != NULL)
- {
- expand_string_for_label (plug->priv->auth_username_label);
- }
-
- if (plug->priv->auth_realname_label != NULL)
- {
- expand_string_for_label (plug->priv->auth_realname_label);
- }
-
- if (! plug->priv->logout_enabled || ! plug->priv->logout_command)
- {
- if (plug->priv->auth_logout_button != NULL)
- {
- gtk_widget_hide (plug->priv->auth_logout_button);
- }
- }
-
- plug->priv->timeout = DIALOG_TIMEOUT_MSEC;
-
- g_signal_connect (plug, "key_press_event",
- G_CALLBACK (entry_key_press), plug);
-
- /* button press handler used to inhibit popup menu */
- g_signal_connect (plug->priv->auth_prompt_entry, "button_press_event",
- G_CALLBACK (entry_button_press), NULL);
- gtk_entry_set_activates_default (GTK_ENTRY (plug->priv->auth_prompt_entry), TRUE);
- gtk_entry_set_visibility (GTK_ENTRY (plug->priv->auth_prompt_entry), FALSE);
-
- g_signal_connect (plug->priv->auth_unlock_button, "clicked",
- G_CALLBACK (unlock_button_clicked), plug);
-
- g_signal_connect (plug->priv->auth_cancel_button, "clicked",
- G_CALLBACK (cancel_button_clicked), plug);
-
- if (plug->priv->status_message_label)
- {
- if (plug->priv->status_message)
- {
- gtk_label_set_text (GTK_LABEL (plug->priv->status_message_label),
- plug->priv->status_message);
- gtk_widget_show (plug->priv->status_message_label);
- }
- else
- {
- gtk_widget_hide (plug->priv->status_message_label);
- }
- }
-
- if (plug->priv->auth_switch_button != NULL)
- {
- g_signal_connect (plug->priv->auth_switch_button, "clicked",
- G_CALLBACK (switch_user_button_clicked), plug);
- }
-
- if (plug->priv->auth_logout_button != NULL)
- {
- g_signal_connect (plug->priv->auth_logout_button, "clicked",
- G_CALLBACK (logout_button_clicked), plug);
- }
-
- g_signal_connect (plug, "delete_event", G_CALLBACK (delete_handler), NULL);
-
- gs_profile_end (NULL);
+ if (plug->priv->auth_switch_button != NULL)
+ {
+ if (plug->priv->switch_enabled)
+ {
+ gtk_widget_show_all (plug->priv->auth_switch_button);
+ }
+ else
+ {
+ gtk_widget_hide (plug->priv->auth_switch_button);
+ }
+ }
+
+ gtk_widget_grab_default (plug->priv->auth_unlock_button);
+
+ if (plug->priv->auth_username_label != NULL)
+ {
+ expand_string_for_label (plug->priv->auth_username_label);
+ }
+
+ if (plug->priv->auth_realname_label != NULL)
+ {
+ expand_string_for_label (plug->priv->auth_realname_label);
+ }
+
+ if (! plug->priv->logout_enabled || ! plug->priv->logout_command)
+ {
+ if (plug->priv->auth_logout_button != NULL)
+ {
+ gtk_widget_hide (plug->priv->auth_logout_button);
+ }
+ }
+
+ plug->priv->timeout = DIALOG_TIMEOUT_MSEC;
+
+ g_signal_connect (plug, "key_press_event",
+ G_CALLBACK (entry_key_press), plug);
+
+ /* button press handler used to inhibit popup menu */
+ g_signal_connect (plug->priv->auth_prompt_entry, "button_press_event",
+ G_CALLBACK (entry_button_press), NULL);
+ gtk_entry_set_activates_default (GTK_ENTRY (plug->priv->auth_prompt_entry), TRUE);
+ gtk_entry_set_visibility (GTK_ENTRY (plug->priv->auth_prompt_entry), FALSE);
+
+ g_signal_connect (plug->priv->auth_unlock_button, "clicked",
+ G_CALLBACK (unlock_button_clicked), plug);
+
+ g_signal_connect (plug->priv->auth_cancel_button, "clicked",
+ G_CALLBACK (cancel_button_clicked), plug);
+
+ if (plug->priv->status_message_label)
+ {
+ if (plug->priv->status_message)
+ {
+ gtk_label_set_text (GTK_LABEL (plug->priv->status_message_label),
+ plug->priv->status_message);
+ gtk_widget_show (plug->priv->status_message_label);
+ }
+ else
+ {
+ gtk_widget_hide (plug->priv->status_message_label);
+ }
+ }
+
+ if (plug->priv->auth_switch_button != NULL)
+ {
+ g_signal_connect (plug->priv->auth_switch_button, "clicked",
+ G_CALLBACK (switch_user_button_clicked), plug);
+ }
+
+ if (plug->priv->auth_logout_button != NULL)
+ {
+ g_signal_connect (plug->priv->auth_logout_button, "clicked",
+ G_CALLBACK (logout_button_clicked), plug);
+ }
+
+ g_signal_connect (plug, "delete_event", G_CALLBACK (delete_handler), NULL);
+
+ gs_profile_end (NULL);
}
static void
gs_lock_plug_finalize (GObject *object)
{
- GSLockPlug *plug;
+ GSLockPlug *plug;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_LOCK_PLUG (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_LOCK_PLUG (object));
- plug = GS_LOCK_PLUG (object);
+ plug = GS_LOCK_PLUG (object);
- g_return_if_fail (plug->priv != NULL);
+ g_return_if_fail (plug->priv != NULL);
- g_free (plug->priv->logout_command);
+ g_free (plug->priv->logout_command);
- remove_response_idle (plug);
- remove_cancel_timeout (plug);
- remove_datetime_timeout (plug);
+ remove_response_idle (plug);
+ remove_cancel_timeout (plug);
+ remove_datetime_timeout (plug);
- G_OBJECT_CLASS (gs_lock_plug_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_lock_plug_parent_class)->finalize (object);
}
GtkWidget *
gs_lock_plug_new (void)
{
- GtkWidget *result;
+ GtkWidget *result;
- result = g_object_new (GS_TYPE_LOCK_PLUG, NULL);
+ result = g_object_new (GS_TYPE_LOCK_PLUG, NULL);
- gtk_window_set_focus_on_map (GTK_WINDOW (result), TRUE);
+ gtk_window_set_focus_on_map (GTK_WINDOW (result), TRUE);
- return result;
+ return result;
}
diff --git a/src/gs-lock-plug.h b/src/gs-lock-plug.h
index 818c8e6..bf64a18 100644
--- a/src/gs-lock-plug.h
+++ b/src/gs-lock-plug.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -45,39 +45,39 @@ typedef struct GSLockPlugPrivate GSLockPlugPrivate;
typedef struct
{
- GtkPlug parent;
+ GtkPlug parent;
- GSLockPlugPrivate *priv;
+ GSLockPlugPrivate *priv;
} GSLockPlug;
typedef struct
{
- GtkPlugClass parent_class;
+ GtkPlugClass parent_class;
- void (* response) (GSLockPlug *plug, gint response_id);
+ void (* response) (GSLockPlug *plug, gint response_id);
- /* Keybinding signals */
- void (* close) (GSLockPlug *plug);
+ /* Keybinding signals */
+ void (* close) (GSLockPlug *plug);
} GSLockPlugClass;
GType gs_lock_plug_get_type (void);
GtkWidget * gs_lock_plug_new (void);
-int gs_lock_plug_run (GSLockPlug *plug);
-void gs_lock_plug_set_sensitive (GSLockPlug *plug,
- gboolean sensitive);
-void gs_lock_plug_enable_prompt (GSLockPlug *plug,
- const char *message,
- gboolean visible);
-void gs_lock_plug_disable_prompt (GSLockPlug *plug);
-void gs_lock_plug_set_busy (GSLockPlug *plug);
-void gs_lock_plug_set_ready (GSLockPlug *plug);
-
-void gs_lock_plug_get_text (GSLockPlug *plug,
- char **text);
-void gs_lock_plug_show_message (GSLockPlug *plug,
- const char *message);
+int gs_lock_plug_run (GSLockPlug *plug);
+void gs_lock_plug_set_sensitive (GSLockPlug *plug,
+ gboolean sensitive);
+void gs_lock_plug_enable_prompt (GSLockPlug *plug,
+ const char *message,
+ gboolean visible);
+void gs_lock_plug_disable_prompt (GSLockPlug *plug);
+void gs_lock_plug_set_busy (GSLockPlug *plug);
+void gs_lock_plug_set_ready (GSLockPlug *plug);
+
+void gs_lock_plug_get_text (GSLockPlug *plug,
+ char **text);
+void gs_lock_plug_show_message (GSLockPlug *plug,
+ const char *message);
G_END_DECLS
diff --git a/src/gs-manager.c b/src/gs-manager.c
index ad1c8ba..39644f9 100644
--- a/src/gs-manager.c
+++ b/src/gs-manager.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2008 William Jon McCann <mccann at jhu.edu>
*
@@ -47,45 +47,45 @@ static void gs_manager_finalize (GObject *object);
struct GSManagerPrivate
{
- GSList *windows;
- GHashTable *jobs;
+ GSList *windows;
+ GHashTable *jobs;
- GSThemeManager *theme_manager;
- XfceBG *bg;
+ GSThemeManager *theme_manager;
+ XfceBG *bg;
- /* Policy */
- glong lock_timeout;
- glong cycle_timeout;
- glong logout_timeout;
+ /* Policy */
+ glong lock_timeout;
+ glong cycle_timeout;
+ glong logout_timeout;
- guint lock_enabled : 1;
- guint logout_enabled : 1;
- guint keyboard_enabled : 1;
- guint user_switch_enabled : 1;
- guint throttled : 1;
+ guint lock_enabled : 1;
+ guint logout_enabled : 1;
+ guint keyboard_enabled : 1;
+ guint user_switch_enabled : 1;
+ guint throttled : 1;
- char *logout_command;
- char *keyboard_command;
+ char *logout_command;
+ char *keyboard_command;
- char *status_message;
+ char *status_message;
- /* State */
- guint active : 1;
- guint lock_active : 1;
+ /* State */
+ guint active : 1;
+ guint lock_active : 1;
- guint fading : 1;
- guint dialog_up : 1;
+ guint fading : 1;
+ guint dialog_up : 1;
- time_t activate_time;
+ time_t activate_time;
- guint lock_timeout_id;
- guint cycle_timeout_id;
+ guint lock_timeout_id;
+ guint cycle_timeout_id;
- GSList *themes;
- GSSaverMode saver_mode;
- GSGrab *grab;
- GSFade *fade;
- guint unfade_idle_id;
+ GSList *themes;
+ GSSaverMode saver_mode;
+ GSGrab *grab;
+ GSFade *fade;
+ guint unfade_idle_id;
};
enum
@@ -125,159 +125,159 @@ manager_add_job_for_window (GSManager *manager,
GSWindow *window,
GSJob *job)
{
- if (manager->priv->jobs == NULL)
- {
- return;
- }
+ if (manager->priv->jobs == NULL)
+ {
+ return;
+ }
- g_hash_table_insert (manager->priv->jobs, window, job);
+ g_hash_table_insert (manager->priv->jobs, window, job);
}
static const char *
select_theme (GSManager *manager)
{
- const char *theme = NULL;
+ const char *theme = NULL;
- g_return_val_if_fail (manager != NULL, NULL);
- g_return_val_if_fail (GS_IS_MANAGER (manager), NULL);
+ g_return_val_if_fail (manager != NULL, NULL);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), NULL);
- if (manager->priv->saver_mode == GS_MODE_BLANK_ONLY)
- {
- return NULL;
- }
+ if (manager->priv->saver_mode == GS_MODE_BLANK_ONLY)
+ {
+ return NULL;
+ }
- if (manager->priv->themes)
- {
- int number = 0;
+ if (manager->priv->themes)
+ {
+ int number = 0;
- if (manager->priv->saver_mode == GS_MODE_RANDOM)
- {
- g_random_set_seed (time (NULL));
- number = g_random_int_range (0, g_slist_length (manager->priv->themes));
- }
- theme = g_slist_nth_data (manager->priv->themes, number);
- }
+ if (manager->priv->saver_mode == GS_MODE_RANDOM)
+ {
+ g_random_set_seed (time (NULL));
+ number = g_random_int_range (0, g_slist_length (manager->priv->themes));
+ }
+ theme = g_slist_nth_data (manager->priv->themes, number);
+ }
- return theme;
+ return theme;
}
static GSJob *
lookup_job_for_window (GSManager *manager,
GSWindow *window)
{
- GSJob *job;
+ GSJob *job;
- if (manager->priv->jobs == NULL)
- {
- return NULL;
- }
+ if (manager->priv->jobs == NULL)
+ {
+ return NULL;
+ }
- job = g_hash_table_lookup (manager->priv->jobs, window);
+ job = g_hash_table_lookup (manager->priv->jobs, window);
- return job;
+ return job;
}
static void
manager_maybe_stop_job_for_window (GSManager *manager,
GSWindow *window)
{
- GSJob *job;
+ GSJob *job;
- job = lookup_job_for_window (manager, window);
+ job = lookup_job_for_window (manager, window);
- if (job == NULL)
- {
- gs_debug ("Job not found for window");
- return;
- }
+ if (job == NULL)
+ {
+ gs_debug ("Job not found for window");
+ return;
+ }
- gs_job_stop (job);
+ gs_job_stop (job);
}
static void
manager_maybe_start_job_for_window (GSManager *manager,
GSWindow *window)
{
- GSJob *job;
-
- job = lookup_job_for_window (manager, window);
-
- if (job == NULL)
- {
- gs_debug ("Job not found for window");
- return;
- }
-
- if (! manager->priv->dialog_up)
- {
- if (! manager->priv->throttled)
- {
- if (! gs_job_is_running (job))
- {
- if (! gs_window_is_obscured (window))
- {
- gs_debug ("Starting job for window");
- gs_job_start (job);
- }
- else
- {
- gs_debug ("Window is obscured deferring start of job");
- }
- }
- else
- {
- gs_debug ("Not starting job because job is running");
- }
- }
- else
- {
- gs_debug ("Not starting job because throttled");
- }
- }
- else
- {
- gs_debug ("Not starting job because dialog is up");
- }
+ GSJob *job;
+
+ job = lookup_job_for_window (manager, window);
+
+ if (job == NULL)
+ {
+ gs_debug ("Job not found for window");
+ return;
+ }
+
+ if (! manager->priv->dialog_up)
+ {
+ if (! manager->priv->throttled)
+ {
+ if (! gs_job_is_running (job))
+ {
+ if (! gs_window_is_obscured (window))
+ {
+ gs_debug ("Starting job for window");
+ gs_job_start (job);
+ }
+ else
+ {
+ gs_debug ("Window is obscured deferring start of job");
+ }
+ }
+ else
+ {
+ gs_debug ("Not starting job because job is running");
+ }
+ }
+ else
+ {
+ gs_debug ("Not starting job because throttled");
+ }
+ }
+ else
+ {
+ gs_debug ("Not starting job because dialog is up");
+ }
}
static void
manager_select_theme_for_job (GSManager *manager,
GSJob *job)
{
- const char *theme;
+ const char *theme;
- theme = select_theme (manager);
+ theme = select_theme (manager);
- if (theme != NULL)
- {
- GSThemeInfo *info;
- const char *command;
+ if (theme != NULL)
+ {
+ GSThemeInfo *info;
+ const char *command;
- command = NULL;
+ command = NULL;
- info = gs_theme_manager_lookup_theme_info (manager->priv->theme_manager, theme);
- if (info != NULL)
- {
- command = gs_theme_info_get_exec (info);
- }
- else
- {
- gs_debug ("Could not find information for theme: %s",
- theme);
- }
+ info = gs_theme_manager_lookup_theme_info (manager->priv->theme_manager, theme);
+ if (info != NULL)
+ {
+ command = gs_theme_info_get_exec (info);
+ }
+ else
+ {
+ gs_debug ("Could not find information for theme: %s",
+ theme);
+ }
- gs_job_set_command (job, command);
+ gs_job_set_command (job, command);
- if (info != NULL)
- {
- gs_theme_info_unref (info);
- }
- }
- else
- {
- gs_job_set_command (job, NULL);
- }
+ if (info != NULL)
+ {
+ gs_theme_info_unref (info);
+ }
+ }
+ else
+ {
+ gs_job_set_command (job, NULL);
+ }
}
static void
@@ -285,18 +285,18 @@ cycle_job (GSWindow *window,
GSJob *job,
GSManager *manager)
{
- gs_job_stop (job);
- manager_select_theme_for_job (manager, job);
- manager_maybe_start_job_for_window (manager, window);
+ gs_job_stop (job);
+ manager_select_theme_for_job (manager, job);
+ manager_maybe_start_job_for_window (manager, window);
}
static void
manager_cycle_jobs (GSManager *manager)
{
- if (manager->priv->jobs != NULL)
- {
- g_hash_table_foreach (manager->priv->jobs, (GHFunc) cycle_job, manager);
- }
+ if (manager->priv->jobs != NULL)
+ {
+ g_hash_table_foreach (manager->priv->jobs, (GHFunc) cycle_job, manager);
+ }
}
static void
@@ -304,23 +304,23 @@ throttle_job (GSWindow *window,
GSJob *job,
GSManager *manager)
{
- if (manager->priv->throttled)
- {
- gs_job_stop (job);
- }
- else
- {
- manager_maybe_start_job_for_window (manager, window);
- }
+ if (manager->priv->throttled)
+ {
+ gs_job_stop (job);
+ }
+ else
+ {
+ manager_maybe_start_job_for_window (manager, window);
+ }
}
static void
manager_throttle_jobs (GSManager *manager)
{
- if (manager->priv->jobs != NULL)
- {
- g_hash_table_foreach (manager->priv->jobs, (GHFunc) throttle_job, manager);
- }
+ if (manager->priv->jobs != NULL)
+ {
+ g_hash_table_foreach (manager->priv->jobs, (GHFunc) throttle_job, manager);
+ }
}
static void
@@ -328,23 +328,23 @@ resume_job (GSWindow *window,
GSJob *job,
GSManager *manager)
{
- if (gs_job_is_running (job))
- {
- gs_job_suspend (job, FALSE);
- }
- else
- {
- manager_maybe_start_job_for_window (manager, window);
- }
+ if (gs_job_is_running (job))
+ {
+ gs_job_suspend (job, FALSE);
+ }
+ else
+ {
+ manager_maybe_start_job_for_window (manager, window);
+ }
}
static void
manager_resume_jobs (GSManager *manager)
{
- if (manager->priv->jobs != NULL)
- {
- g_hash_table_foreach (manager->priv->jobs, (GHFunc) resume_job, manager);
- }
+ if (manager->priv->jobs != NULL)
+ {
+ g_hash_table_foreach (manager->priv->jobs, (GHFunc) resume_job, manager);
+ }
}
static void
@@ -352,790 +352,790 @@ suspend_job (GSWindow *window,
GSJob *job,
GSManager *manager)
{
- gs_job_suspend (job, TRUE);
+ gs_job_suspend (job, TRUE);
}
static void
manager_suspend_jobs (GSManager *manager)
{
- if (manager->priv->jobs != NULL)
- {
- g_hash_table_foreach (manager->priv->jobs, (GHFunc) suspend_job, manager);
- }
+ if (manager->priv->jobs != NULL)
+ {
+ g_hash_table_foreach (manager->priv->jobs, (GHFunc) suspend_job, manager);
+ }
}
static void
manager_stop_jobs (GSManager *manager)
{
- if (manager->priv->jobs != NULL)
- {
- g_hash_table_destroy (manager->priv->jobs);
+ if (manager->priv->jobs != NULL)
+ {
+ g_hash_table_destroy (manager->priv->jobs);
- }
- manager->priv->jobs = NULL;
+ }
+ manager->priv->jobs = NULL;
}
void
gs_manager_set_mode (GSManager *manager,
GSSaverMode mode)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- manager->priv->saver_mode = mode;
+ manager->priv->saver_mode = mode;
}
static void
free_themes (GSManager *manager)
{
- if (manager->priv->themes)
- {
- g_slist_foreach (manager->priv->themes, (GFunc)g_free, NULL);
- g_slist_free (manager->priv->themes);
- }
+ if (manager->priv->themes)
+ {
+ g_slist_foreach (manager->priv->themes, (GFunc)g_free, NULL);
+ g_slist_free (manager->priv->themes);
+ }
}
void
gs_manager_set_themes (GSManager *manager,
GSList *themes)
{
- GSList *l;
+ GSList *l;
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- free_themes (manager);
- manager->priv->themes = NULL;
+ free_themes (manager);
+ manager->priv->themes = NULL;
- for (l = themes; l; l = l->next)
- {
- manager->priv->themes = g_slist_append (manager->priv->themes, g_strdup (l->data));
- }
+ for (l = themes; l; l = l->next)
+ {
+ manager->priv->themes = g_slist_append (manager->priv->themes, g_strdup (l->data));
+ }
}
void
gs_manager_set_throttled (GSManager *manager,
gboolean throttled)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->throttled != throttled)
- {
- GSList *l;
+ if (manager->priv->throttled != throttled)
+ {
+ GSList *l;
- manager->priv->throttled = throttled;
+ manager->priv->throttled = throttled;
- if (! manager->priv->dialog_up)
- {
+ if (! manager->priv->dialog_up)
+ {
- manager_throttle_jobs (manager);
+ manager_throttle_jobs (manager);
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_clear (l->data);
- }
- }
- }
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_clear (l->data);
+ }
+ }
+ }
}
void
gs_manager_get_lock_active (GSManager *manager,
gboolean *lock_active)
{
- if (lock_active != NULL)
- {
- *lock_active = FALSE;
- }
+ if (lock_active != NULL)
+ {
+ *lock_active = FALSE;
+ }
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (lock_active != NULL)
- {
- *lock_active = manager->priv->lock_active;
- }
+ if (lock_active != NULL)
+ {
+ *lock_active = manager->priv->lock_active;
+ }
}
void
gs_manager_set_lock_active (GSManager *manager,
gboolean lock_active)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- gs_debug ("Setting lock active: %d", lock_active);
+ gs_debug ("Setting lock active: %d", lock_active);
- if (manager->priv->lock_active != lock_active)
- {
- GSList *l;
+ if (manager->priv->lock_active != lock_active)
+ {
+ GSList *l;
- manager->priv->lock_active = lock_active;
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_lock_enabled (l->data, lock_active);
- }
- }
+ manager->priv->lock_active = lock_active;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_lock_enabled (l->data, lock_active);
+ }
+ }
}
void
gs_manager_get_lock_enabled (GSManager *manager,
gboolean *lock_enabled)
{
- if (lock_enabled != NULL)
- {
- *lock_enabled = FALSE;
- }
+ if (lock_enabled != NULL)
+ {
+ *lock_enabled = FALSE;
+ }
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (lock_enabled != NULL)
- {
- *lock_enabled = manager->priv->lock_enabled;
- }
+ if (lock_enabled != NULL)
+ {
+ *lock_enabled = manager->priv->lock_enabled;
+ }
}
void
gs_manager_set_lock_enabled (GSManager *manager,
gboolean lock_enabled)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->lock_enabled != lock_enabled)
- {
- manager->priv->lock_enabled = lock_enabled;
- }
+ if (manager->priv->lock_enabled != lock_enabled)
+ {
+ manager->priv->lock_enabled = lock_enabled;
+ }
}
void
gs_manager_set_logout_enabled (GSManager *manager,
gboolean logout_enabled)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->logout_enabled != logout_enabled)
- {
- GSList *l;
+ if (manager->priv->logout_enabled != logout_enabled)
+ {
+ GSList *l;
- manager->priv->logout_enabled = logout_enabled;
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_logout_enabled (l->data, logout_enabled);
- }
- }
+ manager->priv->logout_enabled = logout_enabled;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_logout_enabled (l->data, logout_enabled);
+ }
+ }
}
void
gs_manager_set_keyboard_enabled (GSManager *manager,
gboolean enabled)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->keyboard_enabled != enabled)
- {
- GSList *l;
+ if (manager->priv->keyboard_enabled != enabled)
+ {
+ GSList *l;
- manager->priv->keyboard_enabled = enabled;
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_keyboard_enabled (l->data, enabled);
- }
- }
+ manager->priv->keyboard_enabled = enabled;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_keyboard_enabled (l->data, enabled);
+ }
+ }
}
void
gs_manager_set_user_switch_enabled (GSManager *manager,
gboolean user_switch_enabled)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->user_switch_enabled != user_switch_enabled)
- {
- GSList *l;
+ if (manager->priv->user_switch_enabled != user_switch_enabled)
+ {
+ GSList *l;
- manager->priv->user_switch_enabled = user_switch_enabled;
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_user_switch_enabled (l->data, user_switch_enabled);
- }
- }
+ manager->priv->user_switch_enabled = user_switch_enabled;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_user_switch_enabled (l->data, user_switch_enabled);
+ }
+ }
}
static gboolean
activate_lock_timeout (GSManager *manager)
{
- if (manager->priv->lock_enabled)
- {
- gs_manager_set_lock_active (manager, TRUE);
- }
+ if (manager->priv->lock_enabled)
+ {
+ gs_manager_set_lock_active (manager, TRUE);
+ }
- manager->priv->lock_timeout_id = 0;
+ manager->priv->lock_timeout_id = 0;
- return FALSE;
+ return FALSE;
}
static void
remove_lock_timer (GSManager *manager)
{
- if (manager->priv->lock_timeout_id != 0)
- {
- g_source_remove (manager->priv->lock_timeout_id);
- manager->priv->lock_timeout_id = 0;
- }
+ if (manager->priv->lock_timeout_id != 0)
+ {
+ g_source_remove (manager->priv->lock_timeout_id);
+ manager->priv->lock_timeout_id = 0;
+ }
}
static void
add_lock_timer (GSManager *manager,
glong timeout)
{
- manager->priv->lock_timeout_id = g_timeout_add (timeout,
- (GSourceFunc)activate_lock_timeout,
- manager);
+ manager->priv->lock_timeout_id = g_timeout_add (timeout,
+ (GSourceFunc)activate_lock_timeout,
+ manager);
}
void
gs_manager_set_lock_timeout (GSManager *manager,
glong lock_timeout)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->lock_timeout != lock_timeout)
- {
+ if (manager->priv->lock_timeout != lock_timeout)
+ {
- manager->priv->lock_timeout = lock_timeout;
+ manager->priv->lock_timeout = lock_timeout;
- if (manager->priv->active
- && ! manager->priv->lock_active
- && (lock_timeout >= 0))
- {
+ if (manager->priv->active
+ && ! manager->priv->lock_active
+ && (lock_timeout >= 0))
+ {
- glong elapsed = (time (NULL) - manager->priv->activate_time) * 1000;
+ glong elapsed = (time (NULL) - manager->priv->activate_time) * 1000;
- remove_lock_timer (manager);
+ remove_lock_timer (manager);
- if (elapsed >= lock_timeout)
- {
- activate_lock_timeout (manager);
- }
- else
- {
- add_lock_timer (manager, lock_timeout - elapsed);
- }
- }
- }
+ if (elapsed >= lock_timeout)
+ {
+ activate_lock_timeout (manager);
+ }
+ else
+ {
+ add_lock_timer (manager, lock_timeout - elapsed);
+ }
+ }
+ }
}
void
gs_manager_set_logout_timeout (GSManager *manager,
glong logout_timeout)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->logout_timeout != logout_timeout)
- {
- GSList *l;
+ if (manager->priv->logout_timeout != logout_timeout)
+ {
+ GSList *l;
- manager->priv->logout_timeout = logout_timeout;
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_logout_timeout (l->data, logout_timeout);
- }
- }
+ manager->priv->logout_timeout = logout_timeout;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_logout_timeout (l->data, logout_timeout);
+ }
+ }
}
void
gs_manager_set_logout_command (GSManager *manager,
const char *command)
{
- GSList *l;
+ GSList *l;
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- g_free (manager->priv->logout_command);
+ g_free (manager->priv->logout_command);
- if (command)
- {
- manager->priv->logout_command = g_strdup (command);
- }
- else
- {
- manager->priv->logout_command = NULL;
- }
+ if (command)
+ {
+ manager->priv->logout_command = g_strdup (command);
+ }
+ else
+ {
+ manager->priv->logout_command = NULL;
+ }
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_logout_command (l->data, manager->priv->logout_command);
- }
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_logout_command (l->data, manager->priv->logout_command);
+ }
}
void
gs_manager_set_keyboard_command (GSManager *manager,
const char *command)
{
- GSList *l;
+ GSList *l;
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- g_free (manager->priv->keyboard_command);
+ g_free (manager->priv->keyboard_command);
- if (command)
- {
- manager->priv->keyboard_command = g_strdup (command);
- }
- else
- {
- manager->priv->keyboard_command = NULL;
- }
+ if (command)
+ {
+ manager->priv->keyboard_command = g_strdup (command);
+ }
+ else
+ {
+ manager->priv->keyboard_command = NULL;
+ }
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_keyboard_command (l->data, manager->priv->keyboard_command);
- }
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_keyboard_command (l->data, manager->priv->keyboard_command);
+ }
}
void
gs_manager_set_status_message (GSManager *manager,
const char *status_message)
{
- GSList *l;
+ GSList *l;
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- g_free (manager->priv->status_message);
+ g_free (manager->priv->status_message);
- manager->priv->status_message = g_strdup (status_message);
+ manager->priv->status_message = g_strdup (status_message);
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_set_status_message (l->data, manager->priv->status_message);
- }
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_set_status_message (l->data, manager->priv->status_message);
+ }
}
gboolean
gs_manager_cycle (GSManager *manager)
{
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
- gs_debug ("cycling jobs");
+ gs_debug ("cycling jobs");
- if (! manager->priv->active)
- {
- return FALSE;
- }
+ if (! manager->priv->active)
+ {
+ return FALSE;
+ }
- if (manager->priv->dialog_up)
- {
- return FALSE;
- }
+ if (manager->priv->dialog_up)
+ {
+ return FALSE;
+ }
- if (manager->priv->throttled)
- {
- return FALSE;
- }
+ if (manager->priv->throttled)
+ {
+ return FALSE;
+ }
- manager_cycle_jobs (manager);
+ manager_cycle_jobs (manager);
- return TRUE;
+ return TRUE;
}
static gboolean
cycle_timeout (GSManager *manager)
{
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
- if (! manager->priv->dialog_up)
- {
- gs_manager_cycle (manager);
- }
+ if (! manager->priv->dialog_up)
+ {
+ gs_manager_cycle (manager);
+ }
- return TRUE;
+ return TRUE;
}
static void
remove_cycle_timer (GSManager *manager)
{
- if (manager->priv->cycle_timeout_id != 0)
- {
- g_source_remove (manager->priv->cycle_timeout_id);
- manager->priv->cycle_timeout_id = 0;
- }
+ if (manager->priv->cycle_timeout_id != 0)
+ {
+ g_source_remove (manager->priv->cycle_timeout_id);
+ manager->priv->cycle_timeout_id = 0;
+ }
}
static void
add_cycle_timer (GSManager *manager,
glong timeout)
{
- manager->priv->cycle_timeout_id = g_timeout_add (timeout,
- (GSourceFunc)cycle_timeout,
- manager);
+ manager->priv->cycle_timeout_id = g_timeout_add (timeout,
+ (GSourceFunc)cycle_timeout,
+ manager);
}
void
gs_manager_set_cycle_timeout (GSManager *manager,
glong cycle_timeout)
{
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->cycle_timeout != cycle_timeout)
- {
+ if (manager->priv->cycle_timeout != cycle_timeout)
+ {
- manager->priv->cycle_timeout = cycle_timeout;
+ manager->priv->cycle_timeout = cycle_timeout;
- if (manager->priv->active && (cycle_timeout >= 0))
- {
- glong timeout;
- glong elapsed = (time (NULL) - manager->priv->activate_time) * 1000;
+ if (manager->priv->active && (cycle_timeout >= 0))
+ {
+ glong timeout;
+ glong elapsed = (time (NULL) - manager->priv->activate_time) * 1000;
- remove_cycle_timer (manager);
+ remove_cycle_timer (manager);
- if (elapsed >= cycle_timeout)
- {
- timeout = 0;
- }
- else
- {
- timeout = cycle_timeout - elapsed;
- }
+ if (elapsed >= cycle_timeout)
+ {
+ timeout = 0;
+ }
+ else
+ {
+ timeout = cycle_timeout - elapsed;
+ }
- add_cycle_timer (manager, timeout);
+ add_cycle_timer (manager, timeout);
- }
- }
+ }
+ }
}
static void
-gs_manager_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GSManager *self;
-
- self = GS_MANAGER (object);
-
- switch (prop_id)
- {
- case PROP_THROTTLED:
- gs_manager_set_throttled (self, g_value_get_boolean (value));
- break;
- case PROP_LOCK_ENABLED:
- gs_manager_set_lock_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_LOCK_TIMEOUT:
- gs_manager_set_lock_timeout (self, g_value_get_long (value));
- break;
- case PROP_LOGOUT_ENABLED:
- gs_manager_set_logout_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_KEYBOARD_ENABLED:
- gs_manager_set_keyboard_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_USER_SWITCH_ENABLED:
- gs_manager_set_user_switch_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_LOGOUT_TIMEOUT:
- gs_manager_set_logout_timeout (self, g_value_get_long (value));
- break;
- case PROP_LOGOUT_COMMAND:
- gs_manager_set_logout_command (self, g_value_get_string (value));
- break;
- case PROP_KEYBOARD_COMMAND:
- gs_manager_set_keyboard_command (self, g_value_get_string (value));
- break;
- case PROP_STATUS_MESSAGE:
- gs_manager_set_status_message (self, g_value_get_string (value));
- break;
- case PROP_CYCLE_TIMEOUT:
- gs_manager_set_cycle_timeout (self, g_value_get_long (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gs_manager_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GSManager *self;
+
+ self = GS_MANAGER (object);
+
+ switch (prop_id)
+ {
+ case PROP_THROTTLED:
+ gs_manager_set_throttled (self, g_value_get_boolean (value));
+ break;
+ case PROP_LOCK_ENABLED:
+ gs_manager_set_lock_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_LOCK_TIMEOUT:
+ gs_manager_set_lock_timeout (self, g_value_get_long (value));
+ break;
+ case PROP_LOGOUT_ENABLED:
+ gs_manager_set_logout_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_KEYBOARD_ENABLED:
+ gs_manager_set_keyboard_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_USER_SWITCH_ENABLED:
+ gs_manager_set_user_switch_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_LOGOUT_TIMEOUT:
+ gs_manager_set_logout_timeout (self, g_value_get_long (value));
+ break;
+ case PROP_LOGOUT_COMMAND:
+ gs_manager_set_logout_command (self, g_value_get_string (value));
+ break;
+ case PROP_KEYBOARD_COMMAND:
+ gs_manager_set_keyboard_command (self, g_value_get_string (value));
+ break;
+ case PROP_STATUS_MESSAGE:
+ gs_manager_set_status_message (self, g_value_get_string (value));
+ break;
+ case PROP_CYCLE_TIMEOUT:
+ gs_manager_set_cycle_timeout (self, g_value_get_long (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gs_manager_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GSManager *self;
-
- self = GS_MANAGER (object);
-
- switch (prop_id)
- {
- case PROP_THROTTLED:
- g_value_set_boolean (value, self->priv->throttled);
- break;
- case PROP_LOCK_ENABLED:
- g_value_set_boolean (value, self->priv->lock_enabled);
- break;
- case PROP_LOCK_TIMEOUT:
- g_value_set_long (value, self->priv->lock_timeout);
- break;
- case PROP_LOGOUT_ENABLED:
- g_value_set_boolean (value, self->priv->logout_enabled);
- break;
- case PROP_KEYBOARD_ENABLED:
- g_value_set_boolean (value, self->priv->keyboard_enabled);
- break;
- case PROP_USER_SWITCH_ENABLED:
- g_value_set_boolean (value, self->priv->user_switch_enabled);
- break;
- case PROP_LOGOUT_TIMEOUT:
- g_value_set_long (value, self->priv->logout_timeout);
- break;
- case PROP_LOGOUT_COMMAND:
- g_value_set_string (value, self->priv->logout_command);
- break;
- case PROP_KEYBOARD_COMMAND:
- g_value_set_string (value, self->priv->keyboard_command);
- break;
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, self->priv->status_message);
- break;
- case PROP_CYCLE_TIMEOUT:
- g_value_set_long (value, self->priv->cycle_timeout);
- break;
- case PROP_ACTIVE:
- g_value_set_boolean (value, self->priv->active);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gs_manager_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GSManager *self;
+
+ self = GS_MANAGER (object);
+
+ switch (prop_id)
+ {
+ case PROP_THROTTLED:
+ g_value_set_boolean (value, self->priv->throttled);
+ break;
+ case PROP_LOCK_ENABLED:
+ g_value_set_boolean (value, self->priv->lock_enabled);
+ break;
+ case PROP_LOCK_TIMEOUT:
+ g_value_set_long (value, self->priv->lock_timeout);
+ break;
+ case PROP_LOGOUT_ENABLED:
+ g_value_set_boolean (value, self->priv->logout_enabled);
+ break;
+ case PROP_KEYBOARD_ENABLED:
+ g_value_set_boolean (value, self->priv->keyboard_enabled);
+ break;
+ case PROP_USER_SWITCH_ENABLED:
+ g_value_set_boolean (value, self->priv->user_switch_enabled);
+ break;
+ case PROP_LOGOUT_TIMEOUT:
+ g_value_set_long (value, self->priv->logout_timeout);
+ break;
+ case PROP_LOGOUT_COMMAND:
+ g_value_set_string (value, self->priv->logout_command);
+ break;
+ case PROP_KEYBOARD_COMMAND:
+ g_value_set_string (value, self->priv->keyboard_command);
+ break;
+ case PROP_STATUS_MESSAGE:
+ g_value_set_string (value, self->priv->status_message);
+ break;
+ case PROP_CYCLE_TIMEOUT:
+ g_value_set_long (value, self->priv->cycle_timeout);
+ break;
+ case PROP_ACTIVE:
+ g_value_set_boolean (value, self->priv->active);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gs_manager_class_init (GSManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gs_manager_finalize;
- object_class->get_property = gs_manager_get_property;
- object_class->set_property = gs_manager_set_property;
-
- signals [ACTIVATED] =
- g_signal_new ("activated",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSManagerClass, activated),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [DEACTIVATED] =
- g_signal_new ("deactivated",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSManagerClass, deactivated),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [AUTH_REQUEST_BEGIN] =
- g_signal_new ("auth-request-begin",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSManagerClass, auth_request_begin),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [AUTH_REQUEST_END] =
- g_signal_new ("auth-request-end",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSManagerClass, auth_request_end),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READABLE));
- g_object_class_install_property (object_class,
- PROP_LOCK_ENABLED,
- g_param_spec_boolean ("lock-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOCK_TIMEOUT,
- g_param_spec_long ("lock-timeout",
- NULL,
- NULL,
- -1,
- G_MAXLONG,
- 0,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOGOUT_ENABLED,
- g_param_spec_boolean ("logout-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_USER_SWITCH_ENABLED,
- g_param_spec_boolean ("user-switch-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_LOGOUT_TIMEOUT,
- g_param_spec_long ("logout-timeout",
- NULL,
- NULL,
- -1,
- G_MAXLONG,
- 0,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOGOUT_COMMAND,
- g_param_spec_string ("logout-command",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_CYCLE_TIMEOUT,
- g_param_spec_long ("cycle-timeout",
- NULL,
- NULL,
- 10000,
- G_MAXLONG,
- 300000,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_THROTTLED,
- g_param_spec_boolean ("throttled",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gs_manager_finalize;
+ object_class->get_property = gs_manager_get_property;
+ object_class->set_property = gs_manager_set_property;
+
+ signals [ACTIVATED] =
+ g_signal_new ("activated",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSManagerClass, activated),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [DEACTIVATED] =
+ g_signal_new ("deactivated",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSManagerClass, deactivated),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [AUTH_REQUEST_BEGIN] =
+ g_signal_new ("auth-request-begin",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSManagerClass, auth_request_begin),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals [AUTH_REQUEST_END] =
+ g_signal_new ("auth-request-end",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSManagerClass, auth_request_end),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_object_class_install_property (object_class,
+ PROP_ACTIVE,
+ g_param_spec_boolean ("active",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_LOCK_ENABLED,
+ g_param_spec_boolean ("lock-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOCK_TIMEOUT,
+ g_param_spec_long ("lock-timeout",
+ NULL,
+ NULL,
+ -1,
+ G_MAXLONG,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_ENABLED,
+ g_param_spec_boolean ("logout-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_USER_SWITCH_ENABLED,
+ g_param_spec_boolean ("user-switch-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_TIMEOUT,
+ g_param_spec_long ("logout-timeout",
+ NULL,
+ NULL,
+ -1,
+ G_MAXLONG,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_COMMAND,
+ g_param_spec_string ("logout-command",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_CYCLE_TIMEOUT,
+ g_param_spec_long ("cycle-timeout",
+ NULL,
+ NULL,
+ 10000,
+ G_MAXLONG,
+ 300000,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_THROTTLED,
+ g_param_spec_boolean ("throttled",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
}
static void
-on_bg_changed (XfceBG *bg,
+on_bg_changed (XfceBG *bg,
GSManager *manager)
{
- gs_debug ("background changed");
+ gs_debug ("background changed");
}
static void
gs_manager_init (GSManager *manager)
{
- manager->priv = gs_manager_get_instance_private (manager);
+ manager->priv = gs_manager_get_instance_private (manager);
- manager->priv->fade = gs_fade_new ();
- manager->priv->grab = gs_grab_new ();
- manager->priv->theme_manager = gs_theme_manager_new ();
+ manager->priv->fade = gs_fade_new ();
+ manager->priv->grab = gs_grab_new ();
+ manager->priv->theme_manager = gs_theme_manager_new ();
- manager->priv->bg = xfce_bg_new ();
+ manager->priv->bg = xfce_bg_new ();
- g_signal_connect (manager->priv->bg,
- "changed",
- G_CALLBACK (on_bg_changed),
- manager);
+ g_signal_connect (manager->priv->bg,
+ "changed",
+ G_CALLBACK (on_bg_changed),
+ manager);
- xfce_bg_load_from_preferences (manager->priv->bg, NULL);
+ xfce_bg_load_from_preferences (manager->priv->bg, NULL);
}
static void
remove_timers (GSManager *manager)
{
- remove_lock_timer (manager);
- remove_cycle_timer (manager);
+ remove_lock_timer (manager);
+ remove_cycle_timer (manager);
}
static void
remove_unfade_idle (GSManager *manager)
{
- if (manager->priv->unfade_idle_id > 0)
- {
- g_source_remove (manager->priv->unfade_idle_id);
- manager->priv->unfade_idle_id = 0;
- }
+ if (manager->priv->unfade_idle_id > 0)
+ {
+ g_source_remove (manager->priv->unfade_idle_id);
+ manager->priv->unfade_idle_id = 0;
+ }
}
static gboolean
window_deactivated_idle (GSManager *manager)
{
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
- /* don't deactivate directly but only emit a signal
- so that we let the parent deactivate */
- g_signal_emit (manager, signals [DEACTIVATED], 0);
+ /* don't deactivate directly but only emit a signal
+ so that we let the parent deactivate */
+ g_signal_emit (manager, signals [DEACTIVATED], 0);
- return FALSE;
+ return FALSE;
}
static void
window_deactivated_cb (GSWindow *window,
GSManager *manager)
{
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
- g_idle_add ((GSourceFunc)window_deactivated_idle, manager);
+ g_idle_add ((GSourceFunc)window_deactivated_idle, manager);
}
static GSWindow *
find_window_at_pointer (GSManager *manager)
{
- GdkDisplay *display;
- GdkDevice *device;
- GdkMonitor *monitor;
- int x, y;
- GSWindow *window;
- GSList *l;
-
- display = gdk_display_get_default ();
-
- device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
- gdk_device_get_position (device, NULL, &x, &y);
- monitor = gdk_display_get_monitor_at_point (display, x, y);
-
- /* Find the gs-window that is on that monitor */
- window = NULL;
- for (l = manager->priv->windows; l; l = l->next)
- {
- GSWindow *win = GS_WINDOW (l->data);
- if (gs_window_get_display (win) == display &&
- gs_window_get_monitor (win) == monitor)
- {
- window = win;
- }
- }
-
- if (window == NULL)
- {
- gs_debug ("WARNING: Could not find the GSWindow for display %s",
- gdk_display_get_name (display));
- /* take the first one */
- window = manager->priv->windows->data;
- }
- else
- {
- gs_debug ("Requesting unlock for display %s",
- gdk_display_get_name (display));
- }
-
- return window;
+ GdkDisplay *display;
+ GdkDevice *device;
+ GdkMonitor *monitor;
+ int x, y;
+ GSWindow *window;
+ GSList *l;
+
+ display = gdk_display_get_default ();
+
+ device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
+ gdk_device_get_position (device, NULL, &x, &y);
+ monitor = gdk_display_get_monitor_at_point (display, x, y);
+
+ /* Find the gs-window that is on that monitor */
+ window = NULL;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ GSWindow *win = GS_WINDOW (l->data);
+ if (gs_window_get_display (win) == display &&
+ gs_window_get_monitor (win) == monitor)
+ {
+ window = win;
+ }
+ }
+
+ if (window == NULL)
+ {
+ gs_debug ("WARNING: Could not find the GSWindow for display %s",
+ gdk_display_get_name (display));
+ /* take the first one */
+ window = manager->priv->windows->data;
+ }
+ else
+ {
+ gs_debug ("Requesting unlock for display %s",
+ gdk_display_get_name (display));
+ }
+
+ return window;
}
void
@@ -1144,46 +1144,46 @@ gs_manager_show_message (GSManager *manager,
const char *body,
const char *icon)
{
- GSWindow *window;
+ GSWindow *window;
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GS_IS_MANAGER (manager));
- /* Find the GSWindow that contains the pointer */
- window = find_window_at_pointer (manager);
- gs_window_show_message (window, summary, body, icon);
+ /* Find the GSWindow that contains the pointer */
+ window = find_window_at_pointer (manager);
+ gs_window_show_message (window, summary, body, icon);
- gs_manager_request_unlock (manager);
+ gs_manager_request_unlock (manager);
}
static gboolean
manager_maybe_grab_window (GSManager *manager,
GSWindow *window)
{
- GdkDisplay *display;
- GdkDevice *device;
- GdkMonitor *monitor;
- int x, y;
- gboolean grabbed;
-
- display = gdk_display_get_default ();
- device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
- gdk_device_get_position (device, NULL, &x, &y);
- monitor = gdk_display_get_monitor_at_point (display, x, y);
-
- gdk_display_flush (display);
- grabbed = FALSE;
- if (gs_window_get_display (window) == display &&
- gs_window_get_monitor (window) == monitor)
- {
- gs_debug ("Initiate grab move to %p", window);
- gs_grab_move_to_window (manager->priv->grab,
- gs_window_get_gdk_window (window),
- gs_window_get_display (window),
- FALSE, FALSE);
- grabbed = TRUE;
- }
-
- return grabbed;
+ GdkDisplay *display;
+ GdkDevice *device;
+ GdkMonitor *monitor;
+ int x, y;
+ gboolean grabbed;
+
+ display = gdk_display_get_default ();
+ device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
+ gdk_device_get_position (device, NULL, &x, &y);
+ monitor = gdk_display_get_monitor_at_point (display, x, y);
+
+ gdk_display_flush (display);
+ grabbed = FALSE;
+ if (gs_window_get_display (window) == display &&
+ gs_window_get_monitor (window) == monitor)
+ {
+ gs_debug ("Initiate grab move to %p", window);
+ gs_grab_move_to_window (manager->priv->grab,
+ gs_window_get_gdk_window (window),
+ gs_window_get_display (window),
+ FALSE, FALSE);
+ grabbed = TRUE;
+ }
+
+ return grabbed;
}
static void
@@ -1191,44 +1191,44 @@ window_grab_broken_cb (GSWindow *window,
GdkEventGrabBroken *event,
GSManager *manager)
{
- GdkDisplay *display;
- GdkSeat *seat;
- GdkDevice *device;
-
- display = gdk_window_get_display (gs_window_get_gdk_window (window));
- seat = gdk_display_get_default_seat (display);
-
- if (event->keyboard)
- {
- gs_debug ("KEYBOARD GRAB BROKEN!");
- device = gdk_seat_get_pointer (seat);
- if (!gdk_display_device_is_grabbed (display, device))
- gs_grab_reset (manager->priv->grab);
- }
- else
- {
- gs_debug ("POINTER GRAB BROKEN!");
- device = gdk_seat_get_keyboard (seat);
- if (!gdk_display_device_is_grabbed (display, device))
- gs_grab_reset (manager->priv->grab);
- }
+ GdkDisplay *display;
+ GdkSeat *seat;
+ GdkDevice *device;
+
+ display = gdk_window_get_display (gs_window_get_gdk_window (window));
+ seat = gdk_display_get_default_seat (display);
+
+ if (event->keyboard)
+ {
+ gs_debug ("KEYBOARD GRAB BROKEN!");
+ device = gdk_seat_get_pointer (seat);
+ if (!gdk_display_device_is_grabbed (display, device))
+ gs_grab_reset (manager->priv->grab);
+ }
+ else
+ {
+ gs_debug ("POINTER GRAB BROKEN!");
+ device = gdk_seat_get_keyboard (seat);
+ if (!gdk_display_device_is_grabbed (display, device))
+ gs_grab_reset (manager->priv->grab);
+ }
}
static gboolean
unfade_idle (GSManager *manager)
{
- gs_debug ("resetting fade");
- gs_fade_reset (manager->priv->fade);
- manager->priv->unfade_idle_id = 0;
- return FALSE;
+ gs_debug ("resetting fade");
+ gs_fade_reset (manager->priv->fade);
+ manager->priv->unfade_idle_id = 0;
+ return FALSE;
}
static void
add_unfade_idle (GSManager *manager)
{
- remove_unfade_idle (manager);
- manager->priv->unfade_idle_id = g_timeout_add (500, (GSourceFunc)unfade_idle, manager);
+ remove_unfade_idle (manager);
+ manager->priv->unfade_idle_id = g_timeout_add (500, (GSourceFunc)unfade_idle, manager);
}
static gboolean
@@ -1236,96 +1236,96 @@ window_map_event_cb (GSWindow *window,
GdkEvent *event,
GSManager *manager)
{
- gs_debug ("Handling window map_event event");
+ gs_debug ("Handling window map_event event");
- manager_maybe_grab_window (manager, window);
+ manager_maybe_grab_window (manager, window);
- manager_maybe_start_job_for_window (manager, window);
+ manager_maybe_start_job_for_window (manager, window);
- return FALSE;
+ return FALSE;
}
static void
window_map_cb (GSWindow *window,
GSManager *manager)
{
- gs_debug ("Handling window map event");
+ gs_debug ("Handling window map event");
}
static void
window_unmap_cb (GSWindow *window,
GSManager *manager)
{
- gs_debug ("window unmapped!");
+ gs_debug ("window unmapped!");
}
static void
apply_background_to_window (GSManager *manager,
GSWindow *window)
{
- cairo_surface_t *surface;
- GdkMonitor *monitor;
- GdkRectangle geometry;
- int width, m_width;
- int height, m_height;
-
- monitor = gs_window_get_monitor (window);
-
- xfce_bg_load_from_preferences (manager->priv->bg, monitor);
-
- if (manager->priv->bg == NULL)
- {
- gs_debug ("No background available");
- gs_window_set_background_surface (window, NULL);
- }
-
- gdk_monitor_get_geometry (monitor, &geometry);
- m_width = geometry.width;
- m_height = geometry.height;
- gtk_widget_get_preferred_width (GTK_WIDGET (window), &width, NULL);
- gtk_widget_get_preferred_height (GTK_WIDGET (window), &height, NULL);
- gs_debug ("Creating background (Screen: w:%d h:%d, Monitor: w:%d h: %d)", width, height, m_width, m_height);
- surface = xfce_bg_create_surface (manager->priv->bg,
- gs_window_get_gdk_window (window),
- width,
- height,
- m_width,
- m_height);
- gs_window_set_background_surface (window, surface);
- cairo_surface_destroy (surface);
+ cairo_surface_t *surface;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
+ int width, m_width;
+ int height, m_height;
+
+ monitor = gs_window_get_monitor (window);
+
+ xfce_bg_load_from_preferences (manager->priv->bg, monitor);
+
+ if (manager->priv->bg == NULL)
+ {
+ gs_debug ("No background available");
+ gs_window_set_background_surface (window, NULL);
+ }
+
+ gdk_monitor_get_geometry (monitor, &geometry);
+ m_width = geometry.width;
+ m_height = geometry.height;
+ gtk_widget_get_preferred_width (GTK_WIDGET (window), &width, NULL);
+ gtk_widget_get_preferred_height (GTK_WIDGET (window), &height, NULL);
+ gs_debug ("Creating background (Screen: w:%d h:%d, Monitor: w:%d h: %d)", width, height, m_width, m_height);
+ surface = xfce_bg_create_surface (manager->priv->bg,
+ gs_window_get_gdk_window (window),
+ width,
+ height,
+ m_width,
+ m_height);
+ gs_window_set_background_surface (window, surface);
+ cairo_surface_destroy (surface);
}
static void
manager_show_window (GSManager *manager,
GSWindow *window)
{
- GSJob *job;
+ GSJob *job;
- apply_background_to_window (manager, window);
+ apply_background_to_window (manager, window);
- job = gs_job_new_for_widget (gs_window_get_drawing_area (window));
+ job = gs_job_new_for_widget (gs_window_get_drawing_area (window));
- manager_select_theme_for_job (manager, job);
- manager_add_job_for_window (manager, window, job);
+ manager_select_theme_for_job (manager, job);
+ manager_add_job_for_window (manager, window, job);
- manager->priv->activate_time = time (NULL);
+ manager->priv->activate_time = time (NULL);
- if (manager->priv->lock_timeout >= 0)
- {
- remove_lock_timer (manager);
- add_lock_timer (manager, manager->priv->lock_timeout);
- }
+ if (manager->priv->lock_timeout >= 0)
+ {
+ remove_lock_timer (manager);
+ add_lock_timer (manager, manager->priv->lock_timeout);
+ }
- if (manager->priv->cycle_timeout >= 10000)
- {
- remove_cycle_timer (manager);
- add_cycle_timer (manager, manager->priv->cycle_timeout);
- }
+ if (manager->priv->cycle_timeout >= 10000)
+ {
+ remove_cycle_timer (manager);
+ add_cycle_timer (manager, manager->priv->cycle_timeout);
+ }
- add_unfade_idle (manager);
+ add_unfade_idle (manager);
- /* FIXME: only emit signal once */
- g_signal_emit (manager, signals [ACTIVATED], 0);
+ /* FIXME: only emit signal once */
+ g_signal_emit (manager, signals [ACTIVATED], 0);
}
static void
@@ -1333,13 +1333,13 @@ window_show_cb (GSWindow *window,
GSManager *manager)
{
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
- g_return_if_fail (window != NULL);
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GS_IS_WINDOW (window));
- gs_debug ("Handling window show");
- manager_show_window (manager, window);
+ gs_debug ("Handling window show");
+ manager_show_window (manager, window);
}
static void
@@ -1347,14 +1347,14 @@ maybe_set_window_throttle (GSManager *manager,
GSWindow *window,
gboolean throttled)
{
- if (throttled)
- {
- manager_maybe_stop_job_for_window (manager, window);
- }
- else
- {
- manager_maybe_start_job_for_window (manager, window);
- }
+ if (throttled)
+ {
+ manager_maybe_stop_job_for_window (manager, window);
+ }
+ else
+ {
+ manager_maybe_start_job_for_window (manager, window);
+ }
}
static void
@@ -1362,90 +1362,90 @@ window_obscured_cb (GSWindow *window,
GParamSpec *pspec,
GSManager *manager)
{
- gboolean obscured;
+ gboolean obscured;
- obscured = gs_window_is_obscured (window);
- gs_debug ("Handling window obscured: %s", obscured ? "obscured" : "unobscured");
+ obscured = gs_window_is_obscured (window);
+ gs_debug ("Handling window obscured: %s", obscured ? "obscured" : "unobscured");
- maybe_set_window_throttle (manager, window, obscured);
+ maybe_set_window_throttle (manager, window, obscured);
- if (! obscured)
- {
- gs_manager_request_unlock (manager);
- }
+ if (! obscured)
+ {
+ gs_manager_request_unlock (manager);
+ }
}
static void
handle_window_dialog_up (GSManager *manager,
GSWindow *window)
{
- GSList *l;
+ GSList *l;
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
- gs_debug ("Handling dialog up");
+ gs_debug ("Handling dialog up");
- g_signal_emit (manager, signals [AUTH_REQUEST_BEGIN], 0);
+ g_signal_emit (manager, signals [AUTH_REQUEST_BEGIN], 0);
- manager->priv->dialog_up = TRUE;
- /* make all other windows insensitive to not get events */
- for (l = manager->priv->windows; l; l = l->next)
- {
- if (l->data != window)
- {
- gtk_widget_set_sensitive (GTK_WIDGET (l->data), FALSE);
- }
- }
+ manager->priv->dialog_up = TRUE;
+ /* make all other windows insensitive to not get events */
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ if (l->data != window)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (l->data), FALSE);
+ }
+ }
- /* move devices grab so that dialog can be used;
- release the pointer grab while dialog is up so that
- the dialog can be used. We'll regrab it when the dialog goes down */
- gs_debug ("Initiate pointer-less grab move to %p", window);
- gs_grab_move_to_window (manager->priv->grab,
- gs_window_get_gdk_window (window),
- gs_window_get_display (window),
- TRUE, FALSE);
+ /* move devices grab so that dialog can be used;
+ release the pointer grab while dialog is up so that
+ the dialog can be used. We'll regrab it when the dialog goes down */
+ gs_debug ("Initiate pointer-less grab move to %p", window);
+ gs_grab_move_to_window (manager->priv->grab,
+ gs_window_get_gdk_window (window),
+ gs_window_get_display (window),
+ TRUE, FALSE);
- if (! manager->priv->throttled)
- {
- gs_debug ("Suspending jobs");
+ if (! manager->priv->throttled)
+ {
+ gs_debug ("Suspending jobs");
- manager_suspend_jobs (manager);
- }
+ manager_suspend_jobs (manager);
+ }
}
static void
handle_window_dialog_down (GSManager *manager,
GSWindow *window)
{
- GSList *l;
+ GSList *l;
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
- gs_debug ("Handling dialog down");
+ gs_debug ("Handling dialog down");
- /* regrab pointer */
- gs_grab_move_to_window (manager->priv->grab,
- gs_window_get_gdk_window (window),
- gs_window_get_display (window),
- FALSE, FALSE);
+ /* regrab pointer */
+ gs_grab_move_to_window (manager->priv->grab,
+ gs_window_get_gdk_window (window),
+ gs_window_get_display (window),
+ FALSE, FALSE);
- /* make all windows sensitive to get events */
- for (l = manager->priv->windows; l; l = l->next)
- {
- gtk_widget_set_sensitive (GTK_WIDGET (l->data), TRUE);
- }
+ /* make all windows sensitive to get events */
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (l->data), TRUE);
+ }
- manager->priv->dialog_up = FALSE;
+ manager->priv->dialog_up = FALSE;
- if (! manager->priv->throttled)
- {
- manager_resume_jobs (manager);
- }
+ if (! manager->priv->throttled)
+ {
+ manager_resume_jobs (manager);
+ }
- g_signal_emit (manager, signals [AUTH_REQUEST_END], 0);
+ g_signal_emit (manager, signals [AUTH_REQUEST_END], 0);
}
static void
@@ -1453,109 +1453,109 @@ window_dialog_up_changed_cb (GSWindow *window,
GParamSpec *pspec,
GSManager *manager)
{
- gboolean up;
+ gboolean up;
- up = gs_window_is_dialog_up (window);
- gs_debug ("Handling window dialog up changed: %s", up ? "up" : "down");
- if (up)
- {
- handle_window_dialog_up (manager, window);
- }
- else
- {
- handle_window_dialog_down (manager, window);
- }
+ up = gs_window_is_dialog_up (window);
+ gs_debug ("Handling window dialog up changed: %s", up ? "up" : "down");
+ if (up)
+ {
+ handle_window_dialog_up (manager, window);
+ }
+ else
+ {
+ handle_window_dialog_down (manager, window);
+ }
}
static gboolean
window_activity_cb (GSWindow *window,
GSManager *manager)
{
- gboolean handled;
+ gboolean handled;
- handled = gs_manager_request_unlock (manager);
+ handled = gs_manager_request_unlock (manager);
- return handled;
+ return handled;
}
static void
disconnect_window_signals (GSManager *manager,
GSWindow *window)
{
- g_signal_handlers_disconnect_by_func (window, window_deactivated_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_activity_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_show_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_map_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_map_event_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_obscured_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_dialog_up_changed_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_unmap_cb, manager);
- g_signal_handlers_disconnect_by_func (window, window_grab_broken_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_deactivated_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_activity_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_show_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_map_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_map_event_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_obscured_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_dialog_up_changed_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_unmap_cb, manager);
+ g_signal_handlers_disconnect_by_func (window, window_grab_broken_cb, manager);
}
static void
window_destroyed_cb (GtkWindow *window,
GSManager *manager)
{
- disconnect_window_signals (manager, GS_WINDOW (window));
+ disconnect_window_signals (manager, GS_WINDOW (window));
}
static void
connect_window_signals (GSManager *manager,
GSWindow *window)
{
- g_signal_connect_object (window, "destroy",
- G_CALLBACK (window_destroyed_cb), manager, 0);
- g_signal_connect_object (window, "activity",
- G_CALLBACK (window_activity_cb), manager, 0);
- g_signal_connect_object (window, "deactivated",
- G_CALLBACK (window_deactivated_cb), manager, 0);
- g_signal_connect_object (window, "show",
- G_CALLBACK (window_show_cb), manager, G_CONNECT_AFTER);
- g_signal_connect_object (window, "map",
- G_CALLBACK (window_map_cb), manager, G_CONNECT_AFTER);
- g_signal_connect_object (window, "map_event",
- G_CALLBACK (window_map_event_cb), manager, G_CONNECT_AFTER);
- g_signal_connect_object (window, "notify::obscured",
- G_CALLBACK (window_obscured_cb), manager, G_CONNECT_AFTER);
- g_signal_connect_object (window, "notify::dialog-up",
- G_CALLBACK (window_dialog_up_changed_cb), manager, 0);
- g_signal_connect_object (window, "unmap",
- G_CALLBACK (window_unmap_cb), manager, G_CONNECT_AFTER);
- g_signal_connect_object (window, "grab_broken_event",
- G_CALLBACK (window_grab_broken_cb), manager, G_CONNECT_AFTER);
+ g_signal_connect_object (window, "destroy",
+ G_CALLBACK (window_destroyed_cb), manager, 0);
+ g_signal_connect_object (window, "activity",
+ G_CALLBACK (window_activity_cb), manager, 0);
+ g_signal_connect_object (window, "deactivated",
+ G_CALLBACK (window_deactivated_cb), manager, 0);
+ g_signal_connect_object (window, "show",
+ G_CALLBACK (window_show_cb), manager, G_CONNECT_AFTER);
+ g_signal_connect_object (window, "map",
+ G_CALLBACK (window_map_cb), manager, G_CONNECT_AFTER);
+ g_signal_connect_object (window, "map_event",
+ G_CALLBACK (window_map_event_cb), manager, G_CONNECT_AFTER);
+ g_signal_connect_object (window, "notify::obscured",
+ G_CALLBACK (window_obscured_cb), manager, G_CONNECT_AFTER);
+ g_signal_connect_object (window, "notify::dialog-up",
+ G_CALLBACK (window_dialog_up_changed_cb), manager, 0);
+ g_signal_connect_object (window, "unmap",
+ G_CALLBACK (window_unmap_cb), manager, G_CONNECT_AFTER);
+ g_signal_connect_object (window, "grab_broken_event",
+ G_CALLBACK (window_grab_broken_cb), manager, G_CONNECT_AFTER);
}
static void
gs_manager_create_window_for_monitor (GSManager *manager,
GdkMonitor *monitor)
{
- GSWindow *window;
- GdkRectangle rect;
+ GSWindow *window;
+ GdkRectangle rect;
- gdk_monitor_get_geometry (monitor, &rect);
+ gdk_monitor_get_geometry (monitor, &rect);
- gs_debug ("Creating a window [%d,%d] (%dx%d)",
- rect.x, rect.y, rect.width, rect.height);
+ gs_debug ("Creating a window [%d,%d] (%dx%d)",
+ rect.x, rect.y, rect.width, rect.height);
- window = gs_window_new (monitor, manager->priv->lock_active);
+ window = gs_window_new (monitor, manager->priv->lock_active);
- gs_window_set_user_switch_enabled (window, manager->priv->user_switch_enabled);
- gs_window_set_logout_enabled (window, manager->priv->logout_enabled);
- gs_window_set_logout_timeout (window, manager->priv->logout_timeout);
- gs_window_set_logout_command (window, manager->priv->logout_command);
- gs_window_set_keyboard_enabled (window, manager->priv->keyboard_enabled);
- gs_window_set_keyboard_command (window, manager->priv->keyboard_command);
- gs_window_set_status_message (window, manager->priv->status_message);
+ gs_window_set_user_switch_enabled (window, manager->priv->user_switch_enabled);
+ gs_window_set_logout_enabled (window, manager->priv->logout_enabled);
+ gs_window_set_logout_timeout (window, manager->priv->logout_timeout);
+ gs_window_set_logout_command (window, manager->priv->logout_command);
+ gs_window_set_keyboard_enabled (window, manager->priv->keyboard_enabled);
+ gs_window_set_keyboard_command (window, manager->priv->keyboard_command);
+ gs_window_set_status_message (window, manager->priv->status_message);
- connect_window_signals (manager, window);
+ connect_window_signals (manager, window);
- manager->priv->windows = g_slist_append (manager->priv->windows, window);
+ manager->priv->windows = g_slist_append (manager->priv->windows, window);
- if (manager->priv->active && !manager->priv->fading)
- {
- gtk_widget_show (GTK_WIDGET (window));
- }
+ if (manager->priv->active && !manager->priv->fading)
+ {
+ gtk_widget_show (GTK_WIDGET (window));
+ }
}
static void
@@ -1563,29 +1563,29 @@ on_display_monitor_added (GdkDisplay *display,
GdkMonitor *monitor,
GSManager *manager)
{
- GSList *l;
- int n_monitors;
+ GSList *l;
+ int n_monitors;
- n_monitors = gdk_display_get_n_monitors (display);
+ n_monitors = gdk_display_get_n_monitors (display);
- gs_debug ("Monitor added on display %s, now there are %d",
- gdk_display_get_name (display), n_monitors);
+ gs_debug ("Monitor added on display %s, now there are %d",
+ gdk_display_get_name (display), n_monitors);
- /* Tear down the unlock dialog in case we want to move it
- * to the new monitor
- */
- l = manager->priv->windows;
- while (l != NULL)
- {
- gs_window_cancel_unlock_request (GS_WINDOW (l->data));
- l = l->next;
- }
+ /* Tear down the unlock dialog in case we want to move it
+ * to the new monitor
+ */
+ l = manager->priv->windows;
+ while (l != NULL)
+ {
+ gs_window_cancel_unlock_request (GS_WINDOW (l->data));
+ l = l->next;
+ }
- /* add a new window */
- gs_manager_create_window_for_monitor (manager, monitor);
+ /* add a new window */
+ gs_manager_create_window_for_monitor (manager, monitor);
- /* and put unlock dialog up whereever it's supposed to be */
- gs_manager_request_unlock (manager);
+ /* and put unlock dialog up whereever it's supposed to be */
+ gs_manager_request_unlock (manager);
}
static void
@@ -1593,368 +1593,368 @@ on_display_monitor_removed (GdkDisplay *display,
GdkMonitor *monitor,
GSManager *manager)
{
- GSList *l;
- int n_monitors;
+ GSList *l;
+ int n_monitors;
- n_monitors = gdk_display_get_n_monitors (display);
+ n_monitors = gdk_display_get_n_monitors (display);
- gs_debug ("Monitor removed on display %s, now there are %d",
- gdk_display_get_name (display), n_monitors);
+ gs_debug ("Monitor removed on display %s, now there are %d",
+ gdk_display_get_name (display), n_monitors);
- gdk_x11_grab_server ();
+ gdk_x11_grab_server ();
- /* remove the now extra window */
- l = manager->priv->windows;
- while (l != NULL)
- {
- GdkDisplay *this_display;
- GdkMonitor *this_monitor;
- GSList *next = l->next;
+ /* remove the now extra window */
+ l = manager->priv->windows;
+ while (l != NULL)
+ {
+ GdkDisplay *this_display;
+ GdkMonitor *this_monitor;
+ GSList *next = l->next;
- this_display = gs_window_get_display (GS_WINDOW (l->data));
- this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
- if (this_display == display && this_monitor == monitor)
- {
- manager_maybe_stop_job_for_window (manager,
- GS_WINDOW (l->data));
- g_hash_table_remove (manager->priv->jobs, l->data);
- gs_window_destroy (GS_WINDOW (l->data));
- manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
- }
- l = next;
- }
+ this_display = gs_window_get_display (GS_WINDOW (l->data));
+ this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
+ if (this_display == display && this_monitor == monitor)
+ {
+ manager_maybe_stop_job_for_window (manager,
+ GS_WINDOW (l->data));
+ g_hash_table_remove (manager->priv->jobs, l->data);
+ gs_window_destroy (GS_WINDOW (l->data));
+ manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
+ }
+ l = next;
+ }
- gdk_display_flush (display);
- gdk_x11_ungrab_server ();
+ gdk_display_flush (display);
+ gdk_x11_ungrab_server ();
}
static void
gs_manager_destroy_windows (GSManager *manager)
{
- GdkDisplay *display;
- GSList *l;
+ GdkDisplay *display;
+ GSList *l;
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
- if (manager->priv->windows == NULL)
- {
- return;
- }
+ if (manager->priv->windows == NULL)
+ {
+ return;
+ }
- display = gdk_display_get_default ();
+ display = gdk_display_get_default ();
- g_signal_handlers_disconnect_by_func (display,
- on_display_monitor_removed,
- manager);
- g_signal_handlers_disconnect_by_func (display,
- on_display_monitor_added,
- manager);
+ g_signal_handlers_disconnect_by_func (display,
+ on_display_monitor_removed,
+ manager);
+ g_signal_handlers_disconnect_by_func (display,
+ on_display_monitor_added,
+ manager);
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_destroy (l->data);
- }
- g_slist_free (manager->priv->windows);
- manager->priv->windows = NULL;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_destroy (l->data);
+ }
+ g_slist_free (manager->priv->windows);
+ manager->priv->windows = NULL;
}
static void
gs_manager_finalize (GObject *object)
{
- GSManager *manager;
+ GSManager *manager;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_MANAGER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_MANAGER (object));
- manager = GS_MANAGER (object);
+ manager = GS_MANAGER (object);
- g_return_if_fail (manager->priv != NULL);
+ g_return_if_fail (manager->priv != NULL);
- if (manager->priv->bg != NULL)
- {
- g_object_unref (manager->priv->bg);
- }
+ if (manager->priv->bg != NULL)
+ {
+ g_object_unref (manager->priv->bg);
+ }
- free_themes (manager);
- g_free (manager->priv->logout_command);
- g_free (manager->priv->keyboard_command);
- g_free (manager->priv->status_message);
+ free_themes (manager);
+ g_free (manager->priv->logout_command);
+ g_free (manager->priv->keyboard_command);
+ g_free (manager->priv->status_message);
- remove_unfade_idle (manager);
- remove_timers (manager);
+ remove_unfade_idle (manager);
+ remove_timers (manager);
- gs_grab_release (manager->priv->grab, TRUE);
+ gs_grab_release (manager->priv->grab, TRUE);
- manager_stop_jobs (manager);
+ manager_stop_jobs (manager);
- gs_manager_destroy_windows (manager);
+ gs_manager_destroy_windows (manager);
- manager->priv->active = FALSE;
- manager->priv->activate_time = 0;
- manager->priv->lock_enabled = FALSE;
+ manager->priv->active = FALSE;
+ manager->priv->activate_time = 0;
+ manager->priv->lock_enabled = FALSE;
- g_object_unref (manager->priv->fade);
- g_object_unref (manager->priv->grab);
- g_object_unref (manager->priv->theme_manager);
+ g_object_unref (manager->priv->fade);
+ g_object_unref (manager->priv->grab);
+ g_object_unref (manager->priv->theme_manager);
- G_OBJECT_CLASS (gs_manager_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_manager_parent_class)->finalize (object);
}
static void
gs_manager_create_windows_for_display (GSManager *manager,
GdkDisplay *display)
{
- int n_monitors;
- int i;
+ int n_monitors;
+ int i;
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
- g_return_if_fail (GDK_IS_DISPLAY (display));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (GDK_IS_DISPLAY (display));
- g_object_ref (manager);
- g_object_ref (display);
+ g_object_ref (manager);
+ g_object_ref (display);
- n_monitors = gdk_display_get_n_monitors (display);
+ n_monitors = gdk_display_get_n_monitors (display);
- gs_debug ("Creating %d windows for display %s",
- n_monitors, gdk_display_get_name (display));
+ gs_debug ("Creating %d windows for display %s",
+ n_monitors, gdk_display_get_name (display));
- for (i = 0; i < n_monitors; i++)
- {
- GdkMonitor *mon = gdk_display_get_monitor (display, i);
- gs_manager_create_window_for_monitor (manager, mon);
- }
+ for (i = 0; i < n_monitors; i++)
+ {
+ GdkMonitor *mon = gdk_display_get_monitor (display, i);
+ gs_manager_create_window_for_monitor (manager, mon);
+ }
- g_object_unref (display);
- g_object_unref (manager);
+ g_object_unref (display);
+ g_object_unref (manager);
}
static void
gs_manager_create_windows (GSManager *manager)
{
- GdkDisplay *display;
+ GdkDisplay *display;
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GS_IS_MANAGER (manager));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GS_IS_MANAGER (manager));
- g_assert (manager->priv->windows == NULL);
+ g_assert (manager->priv->windows == NULL);
- display = gdk_display_get_default ();
- g_signal_connect (display, "monitor-added",
- G_CALLBACK (on_display_monitor_added),
- manager);
- g_signal_connect (display, "monitor-removed",
- G_CALLBACK (on_display_monitor_removed),
- manager);
+ display = gdk_display_get_default ();
+ g_signal_connect (display, "monitor-added",
+ G_CALLBACK (on_display_monitor_added),
+ manager);
+ g_signal_connect (display, "monitor-removed",
+ G_CALLBACK (on_display_monitor_removed),
+ manager);
- gs_manager_create_windows_for_display (manager, display);
+ gs_manager_create_windows_for_display (manager, display);
}
GSManager *
gs_manager_new (void)
{
- GObject *manager;
+ GObject *manager;
- manager = g_object_new (GS_TYPE_MANAGER, NULL);
+ manager = g_object_new (GS_TYPE_MANAGER, NULL);
- return GS_MANAGER (manager);
+ return GS_MANAGER (manager);
}
static void
show_windows (GSList *windows)
{
- GSList *l;
+ GSList *l;
- for (l = windows; l; l = l->next)
- {
- gtk_widget_show (GTK_WIDGET (l->data));
- }
+ for (l = windows; l; l = l->next)
+ {
+ gtk_widget_show (GTK_WIDGET (l->data));
+ }
}
static void
remove_job (GSJob *job)
{
- if (job == NULL)
- {
- return;
- }
+ if (job == NULL)
+ {
+ return;
+ }
- gs_job_stop (job);
- g_object_unref (job);
+ gs_job_stop (job);
+ g_object_unref (job);
}
static void
fade_done_cb (GSFade *fade,
GSManager *manager)
{
- gs_debug ("fade completed, showing windows");
- show_windows (manager->priv->windows);
- manager->priv->fading = FALSE;
+ gs_debug ("fade completed, showing windows");
+ show_windows (manager->priv->windows);
+ manager->priv->fading = FALSE;
}
static gboolean
gs_manager_activate (GSManager *manager)
{
- gboolean do_fade;
- gboolean res;
-
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
-
- if (manager->priv->active)
- {
- gs_debug ("Trying to activate manager when already active");
- return FALSE;
- }
-
- res = gs_grab_grab_root (manager->priv->grab, FALSE, FALSE);
- if (! res)
- {
- return FALSE;
- }
-
- if (manager->priv->windows == NULL)
- {
- gs_manager_create_windows (GS_MANAGER (manager));
- }
-
- manager->priv->jobs = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- (GDestroyNotify)remove_job);
-
- manager->priv->active = TRUE;
-
- /* fade to black and show windows */
- do_fade = FALSE;
- if (do_fade)
- {
- manager->priv->fading = TRUE;
- gs_debug ("fading out");
- gs_fade_async (manager->priv->fade,
- FADE_TIMEOUT,
- (GSFadeDoneFunc)fade_done_cb,
- manager);
-
- while (manager->priv->fading)
- {
- gtk_main_iteration ();
- }
- }
- else
- {
- show_windows (manager->priv->windows);
- }
-
- return TRUE;
+ gboolean do_fade;
+ gboolean res;
+
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+
+ if (manager->priv->active)
+ {
+ gs_debug ("Trying to activate manager when already active");
+ return FALSE;
+ }
+
+ res = gs_grab_grab_root (manager->priv->grab, FALSE, FALSE);
+ if (! res)
+ {
+ return FALSE;
+ }
+
+ if (manager->priv->windows == NULL)
+ {
+ gs_manager_create_windows (GS_MANAGER (manager));
+ }
+
+ manager->priv->jobs = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ (GDestroyNotify)remove_job);
+
+ manager->priv->active = TRUE;
+
+ /* fade to black and show windows */
+ do_fade = FALSE;
+ if (do_fade)
+ {
+ manager->priv->fading = TRUE;
+ gs_debug ("fading out");
+ gs_fade_async (manager->priv->fade,
+ FADE_TIMEOUT,
+ (GSFadeDoneFunc)fade_done_cb,
+ manager);
+
+ while (manager->priv->fading)
+ {
+ gtk_main_iteration ();
+ }
+ }
+ else
+ {
+ show_windows (manager->priv->windows);
+ }
+
+ return TRUE;
}
static gboolean
gs_manager_deactivate (GSManager *manager)
{
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
- if (! manager->priv->active)
- {
- gs_debug ("Trying to deactivate a screensaver that is not active");
- return FALSE;
- }
+ if (! manager->priv->active)
+ {
+ gs_debug ("Trying to deactivate a screensaver that is not active");
+ return FALSE;
+ }
- remove_unfade_idle (manager);
- gs_fade_reset (manager->priv->fade);
- remove_timers (manager);
+ remove_unfade_idle (manager);
+ gs_fade_reset (manager->priv->fade);
+ remove_timers (manager);
- gs_grab_release (manager->priv->grab, TRUE);
+ gs_grab_release (manager->priv->grab, TRUE);
- manager_stop_jobs (manager);
+ manager_stop_jobs (manager);
- gs_manager_destroy_windows (manager);
+ gs_manager_destroy_windows (manager);
- /* reset state */
- manager->priv->active = FALSE;
- manager->priv->activate_time = 0;
- manager->priv->lock_active = FALSE;
- manager->priv->dialog_up = FALSE;
- manager->priv->fading = FALSE;
+ /* reset state */
+ manager->priv->active = FALSE;
+ manager->priv->activate_time = 0;
+ manager->priv->lock_active = FALSE;
+ manager->priv->dialog_up = FALSE;
+ manager->priv->fading = FALSE;
- return TRUE;
+ return TRUE;
}
gboolean
gs_manager_set_active (GSManager *manager,
gboolean active)
{
- gboolean res;
+ gboolean res;
- if (active)
- {
- res = gs_manager_activate (manager);
- }
- else
- {
- res = gs_manager_deactivate (manager);
- }
+ if (active)
+ {
+ res = gs_manager_activate (manager);
+ }
+ else
+ {
+ res = gs_manager_deactivate (manager);
+ }
- return res;
+ return res;
}
gboolean
gs_manager_get_active (GSManager *manager)
{
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
- return manager->priv->active;
+ return manager->priv->active;
}
gboolean
gs_manager_request_unlock (GSManager *manager)
{
- GSWindow *window;
-
- g_return_val_if_fail (manager != NULL, FALSE);
- g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
-
- if (! manager->priv->active)
- {
- gs_debug ("Request unlock but manager is not active");
- return FALSE;
- }
-
- if (manager->priv->dialog_up)
- {
- gs_debug ("Request unlock but dialog is already up");
- return FALSE;
- }
-
- if (manager->priv->fading)
- {
- gs_debug ("Request unlock so finishing fade");
- gs_fade_finish (manager->priv->fade);
- }
-
- if (manager->priv->windows == NULL)
- {
- gs_debug ("We don't have any windows!");
- return FALSE;
- }
-
- /* Find the GSWindow that contains the pointer */
- window = find_window_at_pointer (manager);
+ GSWindow *window;
+
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (GS_IS_MANAGER (manager), FALSE);
+
+ if (! manager->priv->active)
+ {
+ gs_debug ("Request unlock but manager is not active");
+ return FALSE;
+ }
+
+ if (manager->priv->dialog_up)
+ {
+ gs_debug ("Request unlock but dialog is already up");
+ return FALSE;
+ }
+
+ if (manager->priv->fading)
+ {
+ gs_debug ("Request unlock so finishing fade");
+ gs_fade_finish (manager->priv->fade);
+ }
+
+ if (manager->priv->windows == NULL)
+ {
+ gs_debug ("We don't have any windows!");
+ return FALSE;
+ }
+
+ /* Find the GSWindow that contains the pointer */
+ window = find_window_at_pointer (manager);
apply_background_to_window (manager, window);
- gs_window_request_unlock (window);
+ gs_window_request_unlock (window);
- return TRUE;
+ return TRUE;
}
void
gs_manager_cancel_unlock_request (GSManager *manager)
{
- GSList *l;
- for (l = manager->priv->windows; l; l = l->next)
- {
- gs_window_cancel_unlock_request (l->data);
- }
+ GSList *l;
+ for (l = manager->priv->windows; l; l = l->next)
+ {
+ gs_window_cancel_unlock_request (l->data);
+ }
}
diff --git a/src/gs-manager.h b/src/gs-manager.h
index 4e537fe..26d7e2b 100644
--- a/src/gs-manager.h
+++ b/src/gs-manager.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -38,69 +38,69 @@ typedef struct GSManagerPrivate GSManagerPrivate;
typedef struct
{
- GObject parent;
- GSManagerPrivate *priv;
+ GObject parent;
+ GSManagerPrivate *priv;
} GSManager;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* activated) (GSManager *manager);
- void (* deactivated) (GSManager *manager);
- void (* auth_request_begin) (GSManager *manager);
- void (* auth_request_end) (GSManager *manager);
+ void (* activated) (GSManager *manager);
+ void (* deactivated) (GSManager *manager);
+ void (* auth_request_begin) (GSManager *manager);
+ void (* auth_request_end) (GSManager *manager);
} GSManagerClass;
-GType gs_manager_get_type (void);
-
-GSManager * gs_manager_new (void);
-
-gboolean gs_manager_set_active (GSManager *manager,
- gboolean active);
-gboolean gs_manager_get_active (GSManager *manager);
-
-gboolean gs_manager_cycle (GSManager *manager);
-
-void gs_manager_get_lock_active (GSManager *manager,
- gboolean *lock_active);
-void gs_manager_set_lock_active (GSManager *manager,
- gboolean lock_active);
-void gs_manager_set_keyboard_enabled (GSManager *manager,
- gboolean enabled);
-void gs_manager_set_keyboard_command (GSManager *manager,
- const char *command);
-void gs_manager_set_status_message (GSManager *manager,
- const char *message);
-void gs_manager_get_lock_enabled (GSManager *manager,
- gboolean *lock_enabled);
-void gs_manager_set_lock_enabled (GSManager *manager,
- gboolean lock_enabled);
-void gs_manager_set_lock_timeout (GSManager *manager,
- glong lock_timeout);
-void gs_manager_set_logout_enabled (GSManager *manager,
- gboolean logout_enabled);
-void gs_manager_set_user_switch_enabled (GSManager *manager,
- gboolean user_switch_enabled);
-void gs_manager_set_logout_timeout (GSManager *manager,
- glong logout_timeout);
-void gs_manager_set_logout_command (GSManager *manager,
- const char *command);
-void gs_manager_set_throttled (GSManager *manager,
- gboolean lock_enabled);
-void gs_manager_set_cycle_timeout (GSManager *manager,
- glong cycle_timeout);
-void gs_manager_set_themes (GSManager *manager,
- GSList *themes);
-void gs_manager_set_mode (GSManager *manager,
- GSSaverMode mode);
-void gs_manager_show_message (GSManager *manager,
- const char *summary,
- const char *body,
- const char *icon);
-gboolean gs_manager_request_unlock (GSManager *manager);
-void gs_manager_cancel_unlock_request (GSManager *manager);
+GType gs_manager_get_type (void);
+
+GSManager * gs_manager_new (void);
+
+gboolean gs_manager_set_active (GSManager *manager,
+ gboolean active);
+gboolean gs_manager_get_active (GSManager *manager);
+
+gboolean gs_manager_cycle (GSManager *manager);
+
+void gs_manager_get_lock_active (GSManager *manager,
+ gboolean *lock_active);
+void gs_manager_set_lock_active (GSManager *manager,
+ gboolean lock_active);
+void gs_manager_set_keyboard_enabled (GSManager *manager,
+ gboolean enabled);
+void gs_manager_set_keyboard_command (GSManager *manager,
+ const char *command);
+void gs_manager_set_status_message (GSManager *manager,
+ const char *message);
+void gs_manager_get_lock_enabled (GSManager *manager,
+ gboolean *lock_enabled);
+void gs_manager_set_lock_enabled (GSManager *manager,
+ gboolean lock_enabled);
+void gs_manager_set_lock_timeout (GSManager *manager,
+ glong lock_timeout);
+void gs_manager_set_logout_enabled (GSManager *manager,
+ gboolean logout_enabled);
+void gs_manager_set_user_switch_enabled (GSManager *manager,
+ gboolean user_switch_enabled);
+void gs_manager_set_logout_timeout (GSManager *manager,
+ glong logout_timeout);
+void gs_manager_set_logout_command (GSManager *manager,
+ const char *command);
+void gs_manager_set_throttled (GSManager *manager,
+ gboolean lock_enabled);
+void gs_manager_set_cycle_timeout (GSManager *manager,
+ glong cycle_timeout);
+void gs_manager_set_themes (GSManager *manager,
+ GSList *themes);
+void gs_manager_set_mode (GSManager *manager,
+ GSSaverMode mode);
+void gs_manager_show_message (GSManager *manager,
+ const char *summary,
+ const char *body,
+ const char *icon);
+gboolean gs_manager_request_unlock (GSManager *manager);
+void gs_manager_cancel_unlock_request (GSManager *manager);
G_END_DECLS
diff --git a/src/gs-monitor.c b/src/gs-monitor.c
index ca5fa81..d9a3551 100644
--- a/src/gs-monitor.c
+++ b/src/gs-monitor.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -48,13 +48,13 @@ static void gs_monitor_init(GSMonitor* monitor);
static void gs_monitor_finalize(GObject* object);
struct GSMonitorPrivate {
- GSWatcher* watcher;
- GSListener* listener;
- GSManager* manager;
- GSPrefs* prefs;
- GSFade* fade;
- GSGrab* grab;
- guint release_grab_id;
+ GSWatcher* watcher;
+ GSListener* listener;
+ GSManager* manager;
+ GSPrefs* prefs;
+ GSFade* fade;
+ GSGrab* grab;
+ guint release_grab_id;
};
#define FADE_TIMEOUT 10000
@@ -63,409 +63,409 @@ G_DEFINE_TYPE_WITH_PRIVATE(GSMonitor, gs_monitor, G_TYPE_OBJECT)
static void gs_monitor_class_init(GSMonitorClass* klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS(klass);
+ GObjectClass* object_class = G_OBJECT_CLASS(klass);
- object_class->finalize = gs_monitor_finalize;
+ object_class->finalize = gs_monitor_finalize;
}
static void manager_activated_cb(GSManager* manager, GSMonitor* monitor)
{
- /* Nothing */
+ /* Nothing */
}
static void manager_deactivated_cb(GSManager* manager, GSMonitor* monitor)
{
- gs_listener_set_active (monitor->priv->listener, FALSE);
+ gs_listener_set_active (monitor->priv->listener, FALSE);
}
static gboolean watcher_idle_cb(GSWatcher* watcher, gboolean is_idle, GSMonitor* monitor)
{
- gboolean res;
+ gboolean res;
- gs_debug ("Idle signal detected: %d", is_idle);
+ gs_debug ("Idle signal detected: %d", is_idle);
- res = gs_listener_set_session_idle(monitor->priv->listener, is_idle);
+ res = gs_listener_set_session_idle(monitor->priv->listener, is_idle);
- return res;
+ return res;
}
static gboolean release_grab_timeout(GSMonitor* monitor)
{
- gboolean manager_active;
+ gboolean manager_active;
- manager_active = gs_manager_get_active(monitor->priv->manager);
+ manager_active = gs_manager_get_active(monitor->priv->manager);
- if (! manager_active)
- {
- gs_grab_release(monitor->priv->grab, TRUE);
- }
+ if (! manager_active)
+ {
+ gs_grab_release(monitor->priv->grab, TRUE);
+ }
- monitor->priv->release_grab_id = 0;
- return FALSE;
+ monitor->priv->release_grab_id = 0;
+ return FALSE;
}
static gboolean watcher_idle_notice_cb(GSWatcher* watcher, gboolean in_effect, GSMonitor* monitor)
{
- gboolean activation_enabled;
- gboolean inhibited;
- gboolean handled;
-
- gs_debug("Idle notice signal detected: %d", in_effect);
-
- /* only fade if screensaver can activate */
- activation_enabled = gs_listener_get_activation_enabled(monitor->priv->listener);
- inhibited = gs_listener_is_inhibited(monitor->priv->listener);
-
- handled = FALSE;
-
- if (in_effect)
- {
- if (activation_enabled && ! inhibited)
- {
- /* start slow fade */
- if (gs_grab_grab_offscreen(monitor->priv->grab, FALSE, FALSE))
- {
- gs_fade_async(monitor->priv->fade, FADE_TIMEOUT, NULL, NULL);
- }
- else
- {
- gs_debug("Could not grab the keyboard so not performing idle warning fade-out");
- }
-
- handled = TRUE;
- }
- }
- else
- {
- gboolean manager_active;
-
- manager_active = gs_manager_get_active(monitor->priv->manager);
- /* cancel the fade unless manager was activated */
- if (! manager_active)
- {
- gs_debug("manager not active, performing fade cancellation");
- gs_fade_reset(monitor->priv->fade);
-
- /* don't release the grab immediately to prevent typing passwords into windows */
- if (monitor->priv->release_grab_id != 0)
- {
- g_source_remove(monitor->priv->release_grab_id);
- }
-
- monitor->priv->release_grab_id = g_timeout_add(1000, (GSourceFunc) release_grab_timeout, monitor);
- }
- else
- {
- gs_debug("manager active, skipping fade cancellation");
- }
-
- handled = TRUE;
- }
-
- return handled;
+ gboolean activation_enabled;
+ gboolean inhibited;
+ gboolean handled;
+
+ gs_debug("Idle notice signal detected: %d", in_effect);
+
+ /* only fade if screensaver can activate */
+ activation_enabled = gs_listener_get_activation_enabled(monitor->priv->listener);
+ inhibited = gs_listener_is_inhibited(monitor->priv->listener);
+
+ handled = FALSE;
+
+ if (in_effect)
+ {
+ if (activation_enabled && ! inhibited)
+ {
+ /* start slow fade */
+ if (gs_grab_grab_offscreen(monitor->priv->grab, FALSE, FALSE))
+ {
+ gs_fade_async(monitor->priv->fade, FADE_TIMEOUT, NULL, NULL);
+ }
+ else
+ {
+ gs_debug("Could not grab the keyboard so not performing idle warning fade-out");
+ }
+
+ handled = TRUE;
+ }
+ }
+ else
+ {
+ gboolean manager_active;
+
+ manager_active = gs_manager_get_active(monitor->priv->manager);
+ /* cancel the fade unless manager was activated */
+ if (! manager_active)
+ {
+ gs_debug("manager not active, performing fade cancellation");
+ gs_fade_reset(monitor->priv->fade);
+
+ /* don't release the grab immediately to prevent typing passwords into windows */
+ if (monitor->priv->release_grab_id != 0)
+ {
+ g_source_remove(monitor->priv->release_grab_id);
+ }
+
+ monitor->priv->release_grab_id = g_timeout_add(1000, (GSourceFunc) release_grab_timeout, monitor);
+ }
+ else
+ {
+ gs_debug("manager active, skipping fade cancellation");
+ }
+
+ handled = TRUE;
+ }
+
+ return handled;
}
static void gs_monitor_lock_screen(GSMonitor* monitor)
{
- gboolean res;
- gboolean locked;
- gboolean active;
-
- /* set lock flag before trying to activate screensaver
- in case something tries to react to the ActiveChanged signal */
- gs_manager_get_lock_active(monitor->priv->manager, &locked);
- gs_manager_set_lock_active(monitor->priv->manager, TRUE);
- active = gs_manager_get_active(monitor->priv->manager);
-
- if (!active) {
- res = gs_listener_set_active(monitor->priv->listener, TRUE);
-
- if (!res)
- {
- /* if we've failed then restore lock status */
- gs_manager_set_lock_active(monitor->priv->manager, locked);
- gs_debug("Unable to lock the screen");
- }
- }
+ gboolean res;
+ gboolean locked;
+ gboolean active;
+
+ /* set lock flag before trying to activate screensaver
+ in case something tries to react to the ActiveChanged signal */
+ gs_manager_get_lock_active(monitor->priv->manager, &locked);
+ gs_manager_set_lock_active(monitor->priv->manager, TRUE);
+ active = gs_manager_get_active(monitor->priv->manager);
+
+ if (!active) {
+ res = gs_listener_set_active(monitor->priv->listener, TRUE);
+
+ if (!res)
+ {
+ /* if we've failed then restore lock status */
+ gs_manager_set_lock_active(monitor->priv->manager, locked);
+ gs_debug("Unable to lock the screen");
+ }
+ }
}
static void gs_monitor_simulate_user_activity(GSMonitor* monitor)
{
- Display *display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
- XScreenSaverSuspend (display, TRUE);
- XSync (display, FALSE);
- XScreenSaverSuspend (display, FALSE);
- XSync (display, FALSE);
-
- /* request that the manager unlock -
- will pop up a dialog if necessary */
- gs_manager_request_unlock(monitor->priv->manager);
+ Display *display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
+ XScreenSaverSuspend (display, TRUE);
+ XSync (display, FALSE);
+ XScreenSaverSuspend (display, FALSE);
+ XSync (display, FALSE);
+
+ /* request that the manager unlock -
+ will pop up a dialog if necessary */
+ gs_manager_request_unlock(monitor->priv->manager);
}
static void listener_lock_cb(GSListener* listener, GSMonitor* monitor)
{
- if (monitor->priv->prefs->lock_enabled)
- {
- gs_monitor_lock_screen(monitor);
- }
- else
- {
- gs_debug("Locking disabled by the administrator");
- }
+ if (monitor->priv->prefs->lock_enabled)
+ {
+ gs_monitor_lock_screen(monitor);
+ }
+ else
+ {
+ gs_debug("Locking disabled by the administrator");
+ }
}
static void listener_quit_cb(GSListener* listener, GSMonitor* monitor)
{
- gs_listener_set_active(monitor->priv->listener, FALSE);
- xfce4_screensaver_quit();
+ gs_listener_set_active(monitor->priv->listener, FALSE);
+ xfce4_screensaver_quit();
}
static void listener_cycle_cb(GSListener* listener, GSMonitor* monitor)
{
- gs_manager_cycle(monitor->priv->manager);
+ gs_manager_cycle(monitor->priv->manager);
}
static void listener_show_message_cb(GSListener* listener, const char* summary, const char* body, const char* icon, GSMonitor* monitor)
{
- gs_manager_show_message(monitor->priv->manager, summary, body, icon);
+ gs_manager_show_message(monitor->priv->manager, summary, body, icon);
}
static gboolean listener_active_changed_cb(GSListener* listener, gboolean active, GSMonitor* monitor)
{
- gboolean res;
- gboolean ret;
- gboolean idle_watch_enabled;
+ gboolean res;
+ gboolean ret;
+ gboolean idle_watch_enabled;
- res = gs_manager_set_active(monitor->priv->manager, active);
+ res = gs_manager_set_active(monitor->priv->manager, active);
- if (! res)
- {
- gs_debug("Unable to set manager active: %d", active);
- ret = FALSE;
- goto done;
- }
+ if (! res)
+ {
+ gs_debug("Unable to set manager active: %d", active);
+ ret = FALSE;
+ goto done;
+ }
- ret = TRUE;
+ ret = TRUE;
- done:
+ done:
- idle_watch_enabled = gs_watcher_get_enabled(monitor->priv->watcher);
+ idle_watch_enabled = gs_watcher_get_enabled(monitor->priv->watcher);
- if (ret && idle_watch_enabled)
- {
- res = gs_watcher_set_active(monitor->priv->watcher, !active);
+ if (ret && idle_watch_enabled)
+ {
+ res = gs_watcher_set_active(monitor->priv->watcher, !active);
- if (!res)
- {
- gs_debug("Unable to set the idle watcher active: %d", !active);
- }
- }
+ if (!res)
+ {
+ gs_debug("Unable to set the idle watcher active: %d", !active);
+ }
+ }
- return ret;
+ return ret;
}
static void listener_throttle_changed_cb(GSListener* listener, gboolean throttled, GSMonitor* monitor)
{
- gs_manager_set_throttled(monitor->priv->manager, throttled);
+ gs_manager_set_throttled(monitor->priv->manager, throttled);
}
static void listener_simulate_user_activity_cb(GSListener* listener, GSMonitor* monitor)
{
- gs_monitor_simulate_user_activity(monitor);
+ gs_monitor_simulate_user_activity(monitor);
}
static void _gs_monitor_update_from_prefs(GSMonitor* monitor, GSPrefs* prefs)
{
- gboolean idle_detection_enabled;
- gboolean idle_detection_active;
- gboolean activate_watch;
- gboolean manager_active;
- gboolean lock_enabled;
- gboolean user_switch_enabled;
-
- lock_enabled = monitor->priv->prefs->lock_enabled;
- user_switch_enabled = monitor->priv->prefs->user_switch_enabled;
-
- gs_manager_set_lock_enabled(monitor->priv->manager, lock_enabled);
- gs_manager_set_lock_timeout(monitor->priv->manager, monitor->priv->prefs->lock_timeout);
- gs_manager_set_logout_enabled(monitor->priv->manager, monitor->priv->prefs->logout_enabled);
- gs_manager_set_user_switch_enabled(monitor->priv->manager, user_switch_enabled);
- gs_manager_set_keyboard_enabled(monitor->priv->manager, monitor->priv->prefs->keyboard_enabled);
- gs_manager_set_logout_timeout(monitor->priv->manager, monitor->priv->prefs->logout_timeout);
- gs_manager_set_logout_command(monitor->priv->manager, monitor->priv->prefs->logout_command);
- gs_manager_set_keyboard_command(monitor->priv->manager, monitor->priv->prefs->keyboard_command);
- gs_manager_set_cycle_timeout(monitor->priv->manager, monitor->priv->prefs->cycle);
- gs_manager_set_mode(monitor->priv->manager, monitor->priv->prefs->mode);
- gs_manager_set_themes(monitor->priv->manager, monitor->priv->prefs->themes);
-
- /* enable activation when allowed */
- gs_listener_set_activation_enabled(monitor->priv->listener, monitor->priv->prefs->idle_activation_enabled);
-
- /* idle detection always enabled */
- idle_detection_enabled = TRUE;
-
- gs_watcher_set_enabled(monitor->priv->watcher, idle_detection_enabled);
-
- /* in the case where idle detection is reenabled we may need to
- activate the watcher too */
-
- manager_active = gs_manager_get_active(monitor->priv->manager);
- idle_detection_active = gs_watcher_get_active(monitor->priv->watcher);
-
- activate_watch = (! manager_active && ! idle_detection_active && idle_detection_enabled);
-
- if (activate_watch)
- {
- gs_watcher_set_active(monitor->priv->watcher, TRUE);
- }
-
- if (monitor->priv->prefs->status_message_enabled)
- {
- char* text;
- g_object_get(monitor->priv->watcher, "status-message", &text, NULL);
- gs_manager_set_status_message(monitor->priv->manager, text);
- g_free(text);
- }
- else
- {
- gs_manager_set_status_message(monitor->priv->manager, NULL);
- }
+ gboolean idle_detection_enabled;
+ gboolean idle_detection_active;
+ gboolean activate_watch;
+ gboolean manager_active;
+ gboolean lock_enabled;
+ gboolean user_switch_enabled;
+
+ lock_enabled = monitor->priv->prefs->lock_enabled;
+ user_switch_enabled = monitor->priv->prefs->user_switch_enabled;
+
+ gs_manager_set_lock_enabled(monitor->priv->manager, lock_enabled);
+ gs_manager_set_lock_timeout(monitor->priv->manager, monitor->priv->prefs->lock_timeout);
+ gs_manager_set_logout_enabled(monitor->priv->manager, monitor->priv->prefs->logout_enabled);
+ gs_manager_set_user_switch_enabled(monitor->priv->manager, user_switch_enabled);
+ gs_manager_set_keyboard_enabled(monitor->priv->manager, monitor->priv->prefs->keyboard_enabled);
+ gs_manager_set_logout_timeout(monitor->priv->manager, monitor->priv->prefs->logout_timeout);
+ gs_manager_set_logout_command(monitor->priv->manager, monitor->priv->prefs->logout_command);
+ gs_manager_set_keyboard_command(monitor->priv->manager, monitor->priv->prefs->keyboard_command);
+ gs_manager_set_cycle_timeout(monitor->priv->manager, monitor->priv->prefs->cycle);
+ gs_manager_set_mode(monitor->priv->manager, monitor->priv->prefs->mode);
+ gs_manager_set_themes(monitor->priv->manager, monitor->priv->prefs->themes);
+
+ /* enable activation when allowed */
+ gs_listener_set_activation_enabled(monitor->priv->listener, monitor->priv->prefs->idle_activation_enabled);
+
+ /* idle detection always enabled */
+ idle_detection_enabled = TRUE;
+
+ gs_watcher_set_enabled(monitor->priv->watcher, idle_detection_enabled);
+
+ /* in the case where idle detection is reenabled we may need to
+ activate the watcher too */
+
+ manager_active = gs_manager_get_active(monitor->priv->manager);
+ idle_detection_active = gs_watcher_get_active(monitor->priv->watcher);
+
+ activate_watch = (! manager_active && ! idle_detection_active && idle_detection_enabled);
+
+ if (activate_watch)
+ {
+ gs_watcher_set_active(monitor->priv->watcher, TRUE);
+ }
+
+ if (monitor->priv->prefs->status_message_enabled)
+ {
+ char* text;
+ g_object_get(monitor->priv->watcher, "status-message", &text, NULL);
+ gs_manager_set_status_message(monitor->priv->manager, text);
+ g_free(text);
+ }
+ else
+ {
+ gs_manager_set_status_message(monitor->priv->manager, NULL);
+ }
}
static void disconnect_listener_signals(GSMonitor* monitor)
{
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_lock_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_quit_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_cycle_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_active_changed_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_throttle_changed_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_simulate_user_activity_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_show_message_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_lock_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_quit_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_cycle_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_active_changed_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_throttle_changed_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_simulate_user_activity_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_show_message_cb, monitor);
}
static void connect_listener_signals(GSMonitor* monitor)
{
- g_signal_connect(monitor->priv->listener, "lock", G_CALLBACK(listener_lock_cb), monitor);
- g_signal_connect(monitor->priv->listener, "quit", G_CALLBACK(listener_quit_cb), monitor);
- g_signal_connect(monitor->priv->listener, "cycle", G_CALLBACK(listener_cycle_cb), monitor);
- g_signal_connect(monitor->priv->listener, "active-changed", G_CALLBACK(listener_active_changed_cb), monitor);
- g_signal_connect(monitor->priv->listener, "throttle-changed", G_CALLBACK(listener_throttle_changed_cb), monitor);
- g_signal_connect(monitor->priv->listener, "simulate-user-activity", G_CALLBACK(listener_simulate_user_activity_cb), monitor);
- g_signal_connect(monitor->priv->listener, "show-message", G_CALLBACK(listener_show_message_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "lock", G_CALLBACK(listener_lock_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "quit", G_CALLBACK(listener_quit_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "cycle", G_CALLBACK(listener_cycle_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "active-changed", G_CALLBACK(listener_active_changed_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "throttle-changed", G_CALLBACK(listener_throttle_changed_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "simulate-user-activity", G_CALLBACK(listener_simulate_user_activity_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "show-message", G_CALLBACK(listener_show_message_cb), monitor);
}
static void on_watcher_status_message_changed(GSWatcher* watcher, GParamSpec* pspec, GSMonitor* monitor)
{
- char* text;
- g_object_get(watcher, "status-message", &text, NULL);
- gs_manager_set_status_message(monitor->priv->manager, text);
- g_free(text);
+ char* text;
+ g_object_get(watcher, "status-message", &text, NULL);
+ gs_manager_set_status_message(monitor->priv->manager, text);
+ g_free(text);
}
static void disconnect_watcher_signals(GSMonitor *monitor)
{
- g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_notice_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->watcher, on_watcher_status_message_changed, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_notice_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->watcher, on_watcher_status_message_changed, monitor);
}
static void connect_watcher_signals(GSMonitor *monitor)
{
- g_signal_connect(monitor->priv->watcher, "idle-changed", G_CALLBACK(watcher_idle_cb), monitor);
- g_signal_connect(monitor->priv->watcher, "idle-notice-changed", G_CALLBACK(watcher_idle_notice_cb), monitor);
- g_signal_connect(monitor->priv->watcher, "notify::status-message", G_CALLBACK(on_watcher_status_message_changed), monitor);
+ g_signal_connect(monitor->priv->watcher, "idle-changed", G_CALLBACK(watcher_idle_cb), monitor);
+ g_signal_connect(monitor->priv->watcher, "idle-notice-changed", G_CALLBACK(watcher_idle_notice_cb), monitor);
+ g_signal_connect(monitor->priv->watcher, "notify::status-message", G_CALLBACK(on_watcher_status_message_changed), monitor);
}
static void disconnect_manager_signals(GSMonitor* monitor)
{
- g_signal_handlers_disconnect_by_func(monitor->priv->manager, manager_activated_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->manager, manager_deactivated_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->manager, manager_activated_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->manager, manager_deactivated_cb, monitor);
}
static void connect_manager_signals(GSMonitor* monitor)
{
- g_signal_connect(monitor->priv->manager, "activated", G_CALLBACK(manager_activated_cb), monitor);
- g_signal_connect(monitor->priv->manager, "deactivated", G_CALLBACK(manager_deactivated_cb), monitor);
+ g_signal_connect(monitor->priv->manager, "activated", G_CALLBACK(manager_activated_cb), monitor);
+ g_signal_connect(monitor->priv->manager, "deactivated", G_CALLBACK(manager_deactivated_cb), monitor);
}
static void disconnect_prefs_signals(GSMonitor* monitor)
{
- g_signal_handlers_disconnect_by_func(monitor->priv->prefs, _gs_monitor_update_from_prefs, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->prefs, _gs_monitor_update_from_prefs, monitor);
}
static void connect_prefs_signals(GSMonitor* monitor)
{
- g_signal_connect_swapped(monitor->priv->prefs, "changed", G_CALLBACK(_gs_monitor_update_from_prefs), monitor);
+ g_signal_connect_swapped(monitor->priv->prefs, "changed", G_CALLBACK(_gs_monitor_update_from_prefs), monitor);
}
static void gs_monitor_init(GSMonitor* monitor)
{
- monitor->priv = gs_monitor_get_instance_private (monitor);
+ monitor->priv = gs_monitor_get_instance_private (monitor);
- monitor->priv->prefs = gs_prefs_new();
- connect_prefs_signals(monitor);
+ monitor->priv->prefs = gs_prefs_new();
+ connect_prefs_signals(monitor);
- monitor->priv->listener = gs_listener_new();
- connect_listener_signals(monitor);
+ monitor->priv->listener = gs_listener_new();
+ connect_listener_signals(monitor);
- monitor->priv->fade = gs_fade_new();
- monitor->priv->grab = gs_grab_new();
+ monitor->priv->fade = gs_fade_new();
+ monitor->priv->grab = gs_grab_new();
- monitor->priv->watcher = gs_watcher_new();
- connect_watcher_signals(monitor);
+ monitor->priv->watcher = gs_watcher_new();
+ connect_watcher_signals(monitor);
- monitor->priv->manager = gs_manager_new();
- connect_manager_signals(monitor);
+ monitor->priv->manager = gs_manager_new();
+ connect_manager_signals(monitor);
- _gs_monitor_update_from_prefs(monitor, monitor->priv->prefs);
+ _gs_monitor_update_from_prefs(monitor, monitor->priv->prefs);
}
static void gs_monitor_finalize(GObject* object)
{
- GSMonitor* monitor;
+ GSMonitor* monitor;
- g_return_if_fail(object != NULL);
- g_return_if_fail(GS_IS_MONITOR(object));
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GS_IS_MONITOR(object));
- monitor = GS_MONITOR(object);
+ monitor = GS_MONITOR(object);
- g_return_if_fail(monitor->priv != NULL);
+ g_return_if_fail(monitor->priv != NULL);
- disconnect_watcher_signals(monitor);
- disconnect_listener_signals(monitor);
- disconnect_manager_signals(monitor);
- disconnect_prefs_signals(monitor);
+ disconnect_watcher_signals(monitor);
+ disconnect_listener_signals(monitor);
+ disconnect_manager_signals(monitor);
+ disconnect_prefs_signals(monitor);
- g_object_unref(monitor->priv->fade);
- g_object_unref(monitor->priv->grab);
- g_object_unref(monitor->priv->watcher);
- g_object_unref(monitor->priv->listener);
- g_object_unref(monitor->priv->manager);
- g_object_unref(monitor->priv->prefs);
+ g_object_unref(monitor->priv->fade);
+ g_object_unref(monitor->priv->grab);
+ g_object_unref(monitor->priv->watcher);
+ g_object_unref(monitor->priv->listener);
+ g_object_unref(monitor->priv->manager);
+ g_object_unref(monitor->priv->prefs);
- G_OBJECT_CLASS(gs_monitor_parent_class)->finalize(object);
+ G_OBJECT_CLASS(gs_monitor_parent_class)->finalize(object);
}
GSMonitor* gs_monitor_new(void)
{
- GSMonitor* monitor;
+ GSMonitor* monitor;
- monitor = g_object_new(GS_TYPE_MONITOR, NULL);
+ monitor = g_object_new(GS_TYPE_MONITOR, NULL);
- return GS_MONITOR(monitor);
+ return GS_MONITOR(monitor);
}
gboolean gs_monitor_start(GSMonitor* monitor, GError** error)
{
- g_return_val_if_fail(GS_IS_MONITOR(monitor), FALSE);
+ g_return_val_if_fail(GS_IS_MONITOR(monitor), FALSE);
- if (!gs_listener_acquire(monitor->priv->listener, error))
- {
- return FALSE;
- }
+ if (!gs_listener_acquire(monitor->priv->listener, error))
+ {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
diff --git a/src/gs-monitor.h b/src/gs-monitor.h
index de8053e..f73745c 100644
--- a/src/gs-monitor.h
+++ b/src/gs-monitor.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -38,22 +38,22 @@ typedef struct GSMonitorPrivate GSMonitorPrivate;
typedef struct
{
- GObject parent;
- GSMonitorPrivate *priv;
+ GObject parent;
+ GSMonitorPrivate *priv;
} GSMonitor;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
} GSMonitorClass;
-GType gs_monitor_get_type (void);
+GType gs_monitor_get_type (void);
GSMonitor * gs_monitor_new (void);
-gboolean gs_monitor_start (GSMonitor *monitor,
- GError **error);
-void gs_monitor_set_lock_enabled (GSMonitor *monitor,
- gboolean lock_enabled);
+gboolean gs_monitor_start (GSMonitor *monitor,
+ GError **error);
+void gs_monitor_set_lock_enabled (GSMonitor *monitor,
+ gboolean lock_enabled);
G_END_DECLS
#endif /* __GS_MONITOR_H */
diff --git a/src/gs-prefs.c b/src/gs-prefs.c
index d3db9cd..d5c8205 100644
--- a/src/gs-prefs.c
+++ b/src/gs-prefs.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -38,7 +38,7 @@ static void gs_prefs_finalize (GObject *object);
struct GSPrefsPrivate
{
- XfconfChannel *channel;
+ XfconfChannel *channel;
};
enum
@@ -57,480 +57,480 @@ static guint signals [LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE_WITH_PRIVATE (GSPrefs, gs_prefs, G_TYPE_OBJECT)
static void
-gs_prefs_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gs_prefs_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- switch (prop_id)
- {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gs_prefs_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gs_prefs_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- switch (prop_id)
- {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gs_prefs_class_init (GSPrefsClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gs_prefs_finalize;
- object_class->get_property = gs_prefs_get_property;
- object_class->set_property = gs_prefs_set_property;
-
-
- signals [CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSPrefsClass, changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gs_prefs_finalize;
+ object_class->get_property = gs_prefs_get_property;
+ object_class->set_property = gs_prefs_set_property;
+
+
+ signals [CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSPrefsClass, changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
_gs_prefs_set_timeout (GSPrefs *prefs,
int value)
{
- if (value < 1)
- value = 10;
+ if (value < 1)
+ value = 10;
- /* pick a reasonable large number for the
- upper bound */
- if (value > 480)
- value = 480;
+ /* pick a reasonable large number for the
+ upper bound */
+ if (value > 480)
+ value = 480;
- prefs->timeout = value * 60000;
+ prefs->timeout = value * 60000;
}
static void
_gs_prefs_set_power_timeout (GSPrefs *prefs,
int value)
{
- if (value < 1)
- value = 60;
+ if (value < 1)
+ value = 60;
- /* pick a reasonable large number for the
- upper bound */
- if (value > 480)
- value = 480;
+ /* pick a reasonable large number for the
+ upper bound */
+ if (value > 480)
+ value = 480;
- /* this value is in seconds - others are in minutes */
- prefs->power_timeout = value * 1000;
+ /* this value is in seconds - others are in minutes */
+ prefs->power_timeout = value * 1000;
}
static void
_gs_prefs_set_lock_timeout (GSPrefs *prefs,
int value)
{
- if (value < 0)
- value = 0;
+ if (value < 0)
+ value = 0;
- /* pick a reasonable large number for the
- upper bound */
- if (value > 480)
- value = 480;
+ /* pick a reasonable large number for the
+ upper bound */
+ if (value > 480)
+ value = 480;
- prefs->lock_timeout = value * 60000;
+ prefs->lock_timeout = value * 60000;
}
static void
_gs_prefs_set_cycle_timeout (GSPrefs *prefs,
int value)
{
- if (value < 1)
- value = 1;
+ if (value < 1)
+ value = 1;
- /* pick a reasonable large number for the
- upper bound */
- if (value > 480)
- value = 480;
+ /* pick a reasonable large number for the
+ upper bound */
+ if (value > 480)
+ value = 480;
- prefs->cycle = value * 60000;
+ prefs->cycle = value * 60000;
}
static void
_gs_prefs_set_mode (GSPrefs *prefs,
- gint mode)
+ gint mode)
{
- prefs->mode = mode;
+ prefs->mode = mode;
}
static void
-_gs_prefs_set_themes (GSPrefs *prefs,
- gchar **values)
+_gs_prefs_set_themes (GSPrefs *prefs,
+ gchar **values)
{
- guint i;
- if (prefs->themes)
- {
- g_slist_foreach (prefs->themes, (GFunc)g_free, NULL);
- g_slist_free (prefs->themes);
- }
-
- if (values == NULL)
- return;
-
- /* take ownership of the list */
- prefs->themes = NULL;
+ guint i;
+ if (prefs->themes)
+ {
+ g_slist_foreach (prefs->themes, (GFunc)g_free, NULL);
+ g_slist_free (prefs->themes);
+ }
+
+ if (values == NULL)
+ return;
+
+ /* take ownership of the list */
+ prefs->themes = NULL;
for (i=0; values[i] != NULL; i++)
- prefs->themes = g_slist_append (prefs->themes, g_strdup (values[i]));
+ prefs->themes = g_slist_append (prefs->themes, g_strdup (values[i]));
}
static void
-_gs_prefs_set_idle_activation_enabled (GSPrefs *prefs,
- gboolean value)
+_gs_prefs_set_idle_activation_enabled (GSPrefs *prefs,
+ gboolean value)
{
- prefs->idle_activation_enabled = value;
+ prefs->idle_activation_enabled = value;
}
static void
-_gs_prefs_set_lock_enabled (GSPrefs *prefs,
- gboolean value)
+_gs_prefs_set_lock_enabled (GSPrefs *prefs,
+ gboolean value)
{
- prefs->lock_enabled = value;
+ prefs->lock_enabled = value;
}
static void
-_gs_prefs_set_keyboard_enabled (GSPrefs *prefs,
- gboolean value)
+_gs_prefs_set_keyboard_enabled (GSPrefs *prefs,
+ gboolean value)
{
- prefs->keyboard_enabled = value;
+ prefs->keyboard_enabled = value;
}
static void
_gs_prefs_set_keyboard_command (GSPrefs *prefs,
const char *value)
{
- g_free (prefs->keyboard_command);
- prefs->keyboard_command = NULL;
+ g_free (prefs->keyboard_command);
+ prefs->keyboard_command = NULL;
- if (value)
- {
- /* FIXME: check command */
+ if (value)
+ {
+ /* FIXME: check command */
- prefs->keyboard_command = g_strdup (value);
- }
+ prefs->keyboard_command = g_strdup (value);
+ }
}
static void
_gs_prefs_set_status_message_enabled (GSPrefs *prefs,
gboolean enabled)
{
- prefs->status_message_enabled = enabled;
+ prefs->status_message_enabled = enabled;
}
static void
-_gs_prefs_set_logout_enabled (GSPrefs *prefs,
- gboolean value)
+_gs_prefs_set_logout_enabled (GSPrefs *prefs,
+ gboolean value)
{
- prefs->logout_enabled = value;
+ prefs->logout_enabled = value;
}
static void
_gs_prefs_set_logout_command (GSPrefs *prefs,
const char *value)
{
- g_free (prefs->logout_command);
- prefs->logout_command = NULL;
+ g_free (prefs->logout_command);
+ prefs->logout_command = NULL;
- if (value)
- {
- /* FIXME: check command */
+ if (value)
+ {
+ /* FIXME: check command */
- prefs->logout_command = g_strdup (value);
- }
+ prefs->logout_command = g_strdup (value);
+ }
}
static void
_gs_prefs_set_logout_timeout (GSPrefs *prefs,
int value)
{
- if (value < 0)
- value = 0;
+ if (value < 0)
+ value = 0;
- /* pick a reasonable large number for the
- upper bound */
- if (value > 480)
- value = 480;
+ /* pick a reasonable large number for the
+ upper bound */
+ if (value > 480)
+ value = 480;
- prefs->logout_timeout = value * 60000;
+ prefs->logout_timeout = value * 60000;
}
static void
-_gs_prefs_set_user_switch_enabled (GSPrefs *prefs,
- gboolean value)
+_gs_prefs_set_user_switch_enabled (GSPrefs *prefs,
+ gboolean value)
{
- prefs->user_switch_enabled = value;
+ prefs->user_switch_enabled = value;
}
static void
gs_prefs_load_from_settings (GSPrefs *prefs)
{
- glong value;
- gboolean bvalue;
- char *string;
- gchar **strv;
- gint mode;
+ glong value;
+ gboolean bvalue;
+ char *string;
+ gchar **strv;
+ gint mode;
- bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_IDLE_ACTIVATION_ENABLED, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
- _gs_prefs_set_idle_activation_enabled (prefs, bvalue);
+ bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_IDLE_ACTIVATION_ENABLED, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
+ _gs_prefs_set_idle_activation_enabled (prefs, bvalue);
- bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_LOCK_ENABLED, DEFAULT_KEY_LOCK_ENABLED);
- _gs_prefs_set_lock_enabled (prefs, bvalue);
+ bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_LOCK_ENABLED, DEFAULT_KEY_LOCK_ENABLED);
+ _gs_prefs_set_lock_enabled (prefs, bvalue);
- value = xfconf_channel_get_int (prefs->priv->channel, KEY_IDLE_DELAY, DEFAULT_KEY_IDLE_DELAY);
- _gs_prefs_set_timeout (prefs, value);
+ value = xfconf_channel_get_int (prefs->priv->channel, KEY_IDLE_DELAY, DEFAULT_KEY_IDLE_DELAY);
+ _gs_prefs_set_timeout (prefs, value);
- value = xfconf_channel_get_int (prefs->priv->channel, KEY_POWER_DELAY, DEFAULT_KEY_POWER_DELAY);
- _gs_prefs_set_power_timeout (prefs, value);
+ value = xfconf_channel_get_int (prefs->priv->channel, KEY_POWER_DELAY, DEFAULT_KEY_POWER_DELAY);
+ _gs_prefs_set_power_timeout (prefs, value);
- value = xfconf_channel_get_int (prefs->priv->channel, KEY_LOCK_DELAY, DEFAULT_KEY_LOCK_DELAY);
- _gs_prefs_set_lock_timeout (prefs, value);
+ value = xfconf_channel_get_int (prefs->priv->channel, KEY_LOCK_DELAY, DEFAULT_KEY_LOCK_DELAY);
+ _gs_prefs_set_lock_timeout (prefs, value);
- value = xfconf_channel_get_int (prefs->priv->channel, KEY_CYCLE_DELAY, DEFAULT_KEY_CYCLE_DELAY);
- _gs_prefs_set_cycle_timeout (prefs, value);
+ value = xfconf_channel_get_int (prefs->priv->channel, KEY_CYCLE_DELAY, DEFAULT_KEY_CYCLE_DELAY);
+ _gs_prefs_set_cycle_timeout (prefs, value);
- mode = xfconf_channel_get_int (prefs->priv->channel, KEY_MODE, DEFAULT_KEY_MODE);
- _gs_prefs_set_mode (prefs, mode);
+ mode = xfconf_channel_get_int (prefs->priv->channel, KEY_MODE, DEFAULT_KEY_MODE);
+ _gs_prefs_set_mode (prefs, mode);
- strv = xfconf_channel_get_string_list (prefs->priv->channel, KEY_THEMES);
- _gs_prefs_set_themes (prefs, strv);
- g_strfreev (strv);
+ strv = xfconf_channel_get_string_list (prefs->priv->channel, KEY_THEMES);
+ _gs_prefs_set_themes (prefs, strv);
+ g_strfreev (strv);
- /* Embedded keyboard options */
+ /* Embedded keyboard options */
- bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_KEYBOARD_ENABLED, DEFAULT_KEY_KEYBOARD_ENABLED);
- _gs_prefs_set_keyboard_enabled (prefs, bvalue);
+ bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_KEYBOARD_ENABLED, DEFAULT_KEY_KEYBOARD_ENABLED);
+ _gs_prefs_set_keyboard_enabled (prefs, bvalue);
- string = xfconf_channel_get_string (prefs->priv->channel, KEY_KEYBOARD_COMMAND, DEFAULT_KEY_KEYBOARD_COMMAND);
- _gs_prefs_set_keyboard_command (prefs, string);
- g_free (string);
+ string = xfconf_channel_get_string (prefs->priv->channel, KEY_KEYBOARD_COMMAND, DEFAULT_KEY_KEYBOARD_COMMAND);
+ _gs_prefs_set_keyboard_command (prefs, string);
+ g_free (string);
- bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_STATUS_MESSAGE_ENABLED, DEFAULT_KEY_STATUS_MESSAGE_ENABLED);
- _gs_prefs_set_status_message_enabled (prefs, bvalue);
+ bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_STATUS_MESSAGE_ENABLED, DEFAULT_KEY_STATUS_MESSAGE_ENABLED);
+ _gs_prefs_set_status_message_enabled (prefs, bvalue);
- /* Logout options */
+ /* Logout options */
- bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_LOGOUT_ENABLED, DEFAULT_KEY_LOGOUT_ENABLED);
- _gs_prefs_set_logout_enabled (prefs, bvalue);
+ bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_LOGOUT_ENABLED, DEFAULT_KEY_LOGOUT_ENABLED);
+ _gs_prefs_set_logout_enabled (prefs, bvalue);
- string = xfconf_channel_get_string (prefs->priv->channel, KEY_LOGOUT_COMMAND, DEFAULT_KEY_LOGOUT_COMMAND);
- _gs_prefs_set_logout_command (prefs, string);
- g_free (string);
+ string = xfconf_channel_get_string (prefs->priv->channel, KEY_LOGOUT_COMMAND, DEFAULT_KEY_LOGOUT_COMMAND);
+ _gs_prefs_set_logout_command (prefs, string);
+ g_free (string);
- value = xfconf_channel_get_int (prefs->priv->channel, KEY_LOGOUT_DELAY, DEFAULT_KEY_LOGOUT_DELAY);
- _gs_prefs_set_logout_timeout (prefs, value);
+ value = xfconf_channel_get_int (prefs->priv->channel, KEY_LOGOUT_DELAY, DEFAULT_KEY_LOGOUT_DELAY);
+ _gs_prefs_set_logout_timeout (prefs, value);
- /* User switching options */
+ /* User switching options */
- bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_USER_SWITCH_ENABLED, DEFAULT_KEY_USER_SWITCH_ENABLED);
- _gs_prefs_set_user_switch_enabled (prefs, bvalue);
+ bvalue = xfconf_channel_get_bool (prefs->priv->channel, KEY_USER_SWITCH_ENABLED, DEFAULT_KEY_USER_SWITCH_ENABLED);
+ _gs_prefs_set_user_switch_enabled (prefs, bvalue);
}
static void
key_changed_cb (XfconfChannel *channel,
- gchar *property,
- GValue *value,
- GSPrefs *prefs)
+ gchar *property,
+ GValue *value,
+ GSPrefs *prefs)
{
- g_warning("key changed!");
- if (strcmp (property, KEY_MODE) == 0)
- {
- gint mode;
-
- mode = xfconf_channel_get_int (channel, property, DEFAULT_KEY_MODE);
- _gs_prefs_set_mode (prefs, mode);
- }
- else if (strcmp (property, KEY_THEMES) == 0)
- {
- gchar **strv = NULL;
-
- strv = xfconf_channel_get_string_list (channel, property);
- _gs_prefs_set_themes (prefs, strv);
- g_strfreev (strv);
- }
- else if (strcmp (property, KEY_IDLE_DELAY) == 0)
- {
- int delay;
-
- delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_IDLE_DELAY);
- _gs_prefs_set_timeout (prefs, delay);
- }
- else if (strcmp (property, KEY_POWER_DELAY) == 0)
- {
- int delay;
-
- delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_POWER_DELAY);
- _gs_prefs_set_power_timeout (prefs, delay);
- }
- else if (strcmp (property, KEY_LOCK_DELAY) == 0)
- {
- int delay;
-
- delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_LOCK_DELAY);
- _gs_prefs_set_lock_timeout (prefs, delay);
- }
- else if (strcmp (property, KEY_IDLE_ACTIVATION_ENABLED) == 0)
- {
- gboolean enabled;
-
- enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
- _gs_prefs_set_idle_activation_enabled (prefs, enabled);
- }
- else if (strcmp (property, KEY_LOCK_ENABLED) == 0)
- {
- gboolean enabled;
-
- enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_LOCK_ENABLED);
- _gs_prefs_set_lock_enabled (prefs, enabled);
- }
- else if (strcmp (property, KEY_CYCLE_DELAY) == 0)
- {
- int delay;
-
- delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_CYCLE_DELAY);
- _gs_prefs_set_cycle_timeout (prefs, delay);
- }
- else if (strcmp (property, KEY_KEYBOARD_ENABLED) == 0)
- {
- gboolean enabled;
-
- enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_KEYBOARD_ENABLED);
- _gs_prefs_set_keyboard_enabled (prefs, enabled);
- }
- else if (strcmp (property, KEY_KEYBOARD_COMMAND) == 0)
- {
- char *command;
-
- command = xfconf_channel_get_string (channel, property, DEFAULT_KEY_KEYBOARD_COMMAND);
- _gs_prefs_set_keyboard_command (prefs, command);
- g_free (command);
- }
- else if (strcmp (property, KEY_STATUS_MESSAGE_ENABLED) == 0)
- {
- gboolean enabled;
-
- enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_STATUS_MESSAGE_ENABLED);
- _gs_prefs_set_status_message_enabled (prefs, enabled);
- }
- else if (strcmp (property, KEY_LOGOUT_ENABLED) == 0)
- {
- gboolean enabled;
-
- enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_LOGOUT_ENABLED);
- _gs_prefs_set_logout_enabled (prefs, enabled);
- }
- else if (strcmp (property, KEY_LOGOUT_DELAY) == 0)
- {
- int delay;
-
- delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_LOGOUT_DELAY);
- _gs_prefs_set_logout_timeout (prefs, delay);
- }
- else if (strcmp (property, KEY_LOGOUT_COMMAND) == 0)
- {
- char *command;
- command = xfconf_channel_get_string (channel, property, DEFAULT_KEY_LOGOUT_COMMAND);
- _gs_prefs_set_logout_command (prefs, command);
- g_free (command);
- }
- else if (strcmp (property, KEY_USER_SWITCH_ENABLED) == 0)
- {
- gboolean enabled;
-
- enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_USER_SWITCH_ENABLED);
- _gs_prefs_set_user_switch_enabled (prefs, enabled);
-
- }
- else
- {
- g_warning ("Config key not handled: %s", property);
- }
-
- g_signal_emit (prefs, signals [CHANGED], 0);
+ g_warning("key changed!");
+ if (strcmp (property, KEY_MODE) == 0)
+ {
+ gint mode;
+
+ mode = xfconf_channel_get_int (channel, property, DEFAULT_KEY_MODE);
+ _gs_prefs_set_mode (prefs, mode);
+ }
+ else if (strcmp (property, KEY_THEMES) == 0)
+ {
+ gchar **strv = NULL;
+
+ strv = xfconf_channel_get_string_list (channel, property);
+ _gs_prefs_set_themes (prefs, strv);
+ g_strfreev (strv);
+ }
+ else if (strcmp (property, KEY_IDLE_DELAY) == 0)
+ {
+ int delay;
+
+ delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_IDLE_DELAY);
+ _gs_prefs_set_timeout (prefs, delay);
+ }
+ else if (strcmp (property, KEY_POWER_DELAY) == 0)
+ {
+ int delay;
+
+ delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_POWER_DELAY);
+ _gs_prefs_set_power_timeout (prefs, delay);
+ }
+ else if (strcmp (property, KEY_LOCK_DELAY) == 0)
+ {
+ int delay;
+
+ delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_LOCK_DELAY);
+ _gs_prefs_set_lock_timeout (prefs, delay);
+ }
+ else if (strcmp (property, KEY_IDLE_ACTIVATION_ENABLED) == 0)
+ {
+ gboolean enabled;
+
+ enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
+ _gs_prefs_set_idle_activation_enabled (prefs, enabled);
+ }
+ else if (strcmp (property, KEY_LOCK_ENABLED) == 0)
+ {
+ gboolean enabled;
+
+ enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_LOCK_ENABLED);
+ _gs_prefs_set_lock_enabled (prefs, enabled);
+ }
+ else if (strcmp (property, KEY_CYCLE_DELAY) == 0)
+ {
+ int delay;
+
+ delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_CYCLE_DELAY);
+ _gs_prefs_set_cycle_timeout (prefs, delay);
+ }
+ else if (strcmp (property, KEY_KEYBOARD_ENABLED) == 0)
+ {
+ gboolean enabled;
+
+ enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_KEYBOARD_ENABLED);
+ _gs_prefs_set_keyboard_enabled (prefs, enabled);
+ }
+ else if (strcmp (property, KEY_KEYBOARD_COMMAND) == 0)
+ {
+ char *command;
+
+ command = xfconf_channel_get_string (channel, property, DEFAULT_KEY_KEYBOARD_COMMAND);
+ _gs_prefs_set_keyboard_command (prefs, command);
+ g_free (command);
+ }
+ else if (strcmp (property, KEY_STATUS_MESSAGE_ENABLED) == 0)
+ {
+ gboolean enabled;
+
+ enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_STATUS_MESSAGE_ENABLED);
+ _gs_prefs_set_status_message_enabled (prefs, enabled);
+ }
+ else if (strcmp (property, KEY_LOGOUT_ENABLED) == 0)
+ {
+ gboolean enabled;
+
+ enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_LOGOUT_ENABLED);
+ _gs_prefs_set_logout_enabled (prefs, enabled);
+ }
+ else if (strcmp (property, KEY_LOGOUT_DELAY) == 0)
+ {
+ int delay;
+
+ delay = xfconf_channel_get_int (channel, property, DEFAULT_KEY_LOGOUT_DELAY);
+ _gs_prefs_set_logout_timeout (prefs, delay);
+ }
+ else if (strcmp (property, KEY_LOGOUT_COMMAND) == 0)
+ {
+ char *command;
+ command = xfconf_channel_get_string (channel, property, DEFAULT_KEY_LOGOUT_COMMAND);
+ _gs_prefs_set_logout_command (prefs, command);
+ g_free (command);
+ }
+ else if (strcmp (property, KEY_USER_SWITCH_ENABLED) == 0)
+ {
+ gboolean enabled;
+
+ enabled = xfconf_channel_get_bool (channel, property, DEFAULT_KEY_USER_SWITCH_ENABLED);
+ _gs_prefs_set_user_switch_enabled (prefs, enabled);
+
+ }
+ else
+ {
+ g_warning ("Config key not handled: %s", property);
+ }
+
+ g_signal_emit (prefs, signals [CHANGED], 0);
}
static void
gs_prefs_init (GSPrefs *prefs)
{
- prefs->priv = gs_prefs_get_instance_private (prefs);
+ prefs->priv = gs_prefs_get_instance_private (prefs);
- prefs->priv->channel = xfconf_channel_get (SETTINGS_XFCONF_CHANNEL);
- g_signal_connect (prefs->priv->channel,
- "property-changed",
- G_CALLBACK (key_changed_cb),
- prefs);
+ prefs->priv->channel = xfconf_channel_get (SETTINGS_XFCONF_CHANNEL);
+ g_signal_connect (prefs->priv->channel,
+ "property-changed",
+ G_CALLBACK (key_changed_cb),
+ prefs);
- prefs->idle_activation_enabled = TRUE;
- prefs->lock_enabled = TRUE;
- prefs->logout_enabled = FALSE;
- prefs->user_switch_enabled = FALSE;
+ prefs->idle_activation_enabled = TRUE;
+ prefs->lock_enabled = TRUE;
+ prefs->logout_enabled = FALSE;
+ prefs->user_switch_enabled = FALSE;
- prefs->timeout = 600000;
- prefs->power_timeout = 60000;
- prefs->lock_timeout = 0;
- prefs->logout_timeout = 14400000;
- prefs->cycle = 600000;
+ prefs->timeout = 600000;
+ prefs->power_timeout = 60000;
+ prefs->lock_timeout = 0;
+ prefs->logout_timeout = 14400000;
+ prefs->cycle = 600000;
- prefs->mode = GS_MODE_SINGLE;
+ prefs->mode = GS_MODE_SINGLE;
- gs_prefs_load_from_settings (prefs);
+ gs_prefs_load_from_settings (prefs);
}
static void
gs_prefs_finalize (GObject *object)
{
- GSPrefs *prefs;
+ GSPrefs *prefs;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_PREFS (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_PREFS (object));
- prefs = GS_PREFS (object);
+ prefs = GS_PREFS (object);
- g_return_if_fail (prefs->priv != NULL);
+ g_return_if_fail (prefs->priv != NULL);
- if (prefs->priv->channel)
- {
- g_object_unref (prefs->priv->channel);
- prefs->priv->channel = NULL;
- }
+ if (prefs->priv->channel)
+ {
+ g_object_unref (prefs->priv->channel);
+ prefs->priv->channel = NULL;
+ }
- if (prefs->themes)
- {
- g_slist_foreach (prefs->themes, (GFunc)g_free, NULL);
- g_slist_free (prefs->themes);
- }
+ if (prefs->themes)
+ {
+ g_slist_foreach (prefs->themes, (GFunc)g_free, NULL);
+ g_slist_free (prefs->themes);
+ }
- g_free (prefs->logout_command);
- g_free (prefs->keyboard_command);
+ g_free (prefs->logout_command);
+ g_free (prefs->keyboard_command);
- G_OBJECT_CLASS (gs_prefs_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_prefs_parent_class)->finalize (object);
}
GSPrefs *
gs_prefs_new (void)
{
- GObject *prefs;
+ GObject *prefs;
- prefs = g_object_new (GS_TYPE_PREFS, NULL);
+ prefs = g_object_new (GS_TYPE_PREFS, NULL);
- return GS_PREFS (prefs);
+ return GS_PREFS (prefs);
}
diff --git a/src/gs-prefs.h b/src/gs-prefs.h
index f004e8f..a89b18c 100644
--- a/src/gs-prefs.h
+++ b/src/gs-prefs.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -166,35 +166,34 @@ typedef struct GSPrefsPrivate GSPrefsPrivate;
typedef struct
{
- GObject parent;
-
- GSPrefsPrivate *priv;
-
- guint idle_activation_enabled : 1; /* whether to activate when idle */
-guint lock_enabled : 1; /* whether to lock when active */
-guint logout_enabled : 1; /* Whether to offer the logout option */
-guint user_switch_enabled : 1; /* Whether to offer the user switch option */
-guint keyboard_enabled : 1; /* Whether to try to embed a keyboard */
-guint status_message_enabled : 1; /* show the status message in the lock */
-
-guint power_timeout; /* how much idle time before power management */
-guint timeout; /* how much idle time before activation */
-guint lock_timeout; /* how long after activation locking starts */
-guint logout_timeout; /* how long until the logout option appears */
-guint cycle; /* how long each theme should run */
-
-char *logout_command; /* command to use to logout */
-char *keyboard_command; /* command to use to embed a keyboard */
-
-GSList *themes; /* the screensaver themes to run */
-GSSaverMode mode; /* theme selection mode */
+ GObject parent;
+
+ GSPrefsPrivate *priv;
+
+ guint idle_activation_enabled : 1; /* whether to activate when idle */
+ guint lock_enabled : 1; /* whether to lock when active */
+ guint logout_enabled : 1; /* Whether to offer the logout option */
+ guint user_switch_enabled : 1; /* Whether to offer the user switch option */
+ guint keyboard_enabled : 1; /* Whether to try to embed a keyboard */
+ guint status_message_enabled : 1; /* show the status message in the lock */
+ guint power_timeout; /* how much idle time before power management */
+ guint timeout; /* how much idle time before activation */
+ guint lock_timeout; /* how long after activation locking starts */
+ guint logout_timeout; /* how long until the logout option appears */
+ guint cycle; /* how long each theme should run */
+
+ char *logout_command; /* command to use to logout */
+ char *keyboard_command; /* command to use to embed a keyboard */
+
+ GSList *themes; /* the screensaver themes to run */
+ GSSaverMode mode; /* theme selection mode */
} GSPrefs;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* changed) (GSPrefs *prefs);
+ void (* changed) (GSPrefs *prefs);
} GSPrefsClass;
GType gs_prefs_get_type (void);
diff --git a/src/gs-theme-manager.c b/src/gs-theme-manager.c
index f8f63b5..1bc55fd 100644
--- a/src/gs-theme-manager.c
+++ b/src/gs-theme-manager.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
*
@@ -42,15 +42,15 @@ static void gs_theme_manager_finalize (GObject *object);
struct _GSThemeInfo
{
- char *name;
- char *exec;
- char *file_id;
- guint refcount;
+ char *name;
+ char *exec;
+ char *file_id;
+ guint refcount;
};
struct GSThemeManagerPrivate
{
- GarconMenu *menu;
+ GarconMenu *menu;
};
G_DEFINE_TYPE_WITH_PRIVATE (GSThemeManager, gs_theme_manager, G_TYPE_OBJECT)
@@ -59,363 +59,363 @@ static gpointer theme_manager_object = NULL;
static const char *known_engine_locations [] =
{
- SAVERDIR,
+ SAVERDIR,
#ifdef XSCREENSAVER_HACK_DIR
- XSCREENSAVER_HACK_DIR,
+ XSCREENSAVER_HACK_DIR,
#endif
- LIBEXECDIR "/xscreensaver",
- "/usr/libexec/xscreensaver",
- "/usr/lib/xscreensaver",
- NULL
+ LIBEXECDIR "/xscreensaver",
+ "/usr/libexec/xscreensaver",
+ "/usr/lib/xscreensaver",
+ NULL
};
/* Returns the full path to the queried command */
static char *
find_command (const char *command)
{
- int i;
-
- if (g_path_is_absolute (command))
- {
- char *dirname;
-
- dirname = g_path_get_dirname (command);
- for (i = 0; known_engine_locations [i]; i++)
- {
- if (strcmp (dirname, known_engine_locations [i]) == 0)
- {
- if (g_file_test (command, G_FILE_TEST_IS_EXECUTABLE)
- && ! g_file_test (command, G_FILE_TEST_IS_DIR))
- {
- g_free (dirname);
- return g_strdup (command);
- }
- }
- }
- g_free (dirname);
- }
- else
- {
- for (i = 0; known_engine_locations [i]; i++)
- {
- char *path;
-
- path = g_build_filename (known_engine_locations [i], command, NULL);
-
- if (g_file_test (path, G_FILE_TEST_IS_EXECUTABLE)
- && ! g_file_test (path, G_FILE_TEST_IS_DIR))
- {
- return path;
- }
-
- g_free (path);
- }
- }
-
- return NULL;
+ int i;
+
+ if (g_path_is_absolute (command))
+ {
+ char *dirname;
+
+ dirname = g_path_get_dirname (command);
+ for (i = 0; known_engine_locations [i]; i++)
+ {
+ if (strcmp (dirname, known_engine_locations [i]) == 0)
+ {
+ if (g_file_test (command, G_FILE_TEST_IS_EXECUTABLE)
+ && ! g_file_test (command, G_FILE_TEST_IS_DIR))
+ {
+ g_free (dirname);
+ return g_strdup (command);
+ }
+ }
+ }
+ g_free (dirname);
+ }
+ else
+ {
+ for (i = 0; known_engine_locations [i]; i++)
+ {
+ char *path;
+
+ path = g_build_filename (known_engine_locations [i], command, NULL);
+
+ if (g_file_test (path, G_FILE_TEST_IS_EXECUTABLE)
+ && ! g_file_test (path, G_FILE_TEST_IS_DIR))
+ {
+ return path;
+ }
+
+ g_free (path);
+ }
+ }
+
+ return NULL;
}
static gboolean
check_command (const char *command)
{
- char *path;
- char **argv;
+ char *path;
+ char **argv;
- g_return_val_if_fail (command != NULL, FALSE);
+ g_return_val_if_fail (command != NULL, FALSE);
- g_shell_parse_argv (command, NULL, &argv, NULL);
- path = find_command (argv [0]);
- g_strfreev (argv);
+ g_shell_parse_argv (command, NULL, &argv, NULL);
+ path = find_command (argv [0]);
+ g_strfreev (argv);
- if (path != NULL)
- {
- g_free (path);
- return TRUE;
- }
+ if (path != NULL)
+ {
+ g_free (path);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
add_known_engine_locations_to_path (void)
{
- static gboolean already_added;
- int i;
- GString *str;
-
- /* We only want to add the items to the path once */
- if (already_added)
- {
- return;
- }
-
- already_added = TRUE;
-
- /* TODO: set a default PATH ? */
-
- str = g_string_new (g_getenv ("PATH"));
- for (i = 0; known_engine_locations [i]; i++)
- {
- /* TODO: check that permissions are safe */
- if (g_file_test (known_engine_locations [i], G_FILE_TEST_IS_DIR))
- {
- g_string_append_printf (str, ":%s", known_engine_locations [i]);
- }
- }
-
- g_setenv ("PATH", str->str, TRUE);
- g_string_free (str, TRUE);
+ static gboolean already_added;
+ int i;
+ GString *str;
+
+ /* We only want to add the items to the path once */
+ if (already_added)
+ {
+ return;
+ }
+
+ already_added = TRUE;
+
+ /* TODO: set a default PATH ? */
+
+ str = g_string_new (g_getenv ("PATH"));
+ for (i = 0; known_engine_locations [i]; i++)
+ {
+ /* TODO: check that permissions are safe */
+ if (g_file_test (known_engine_locations [i], G_FILE_TEST_IS_DIR))
+ {
+ g_string_append_printf (str, ":%s", known_engine_locations [i]);
+ }
+ }
+
+ g_setenv ("PATH", str->str, TRUE);
+ g_string_free (str, TRUE);
}
GSThemeInfo *
gs_theme_info_ref (GSThemeInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
- g_return_val_if_fail (info->refcount > 0, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info->refcount > 0, NULL);
- info->refcount++;
+ info->refcount++;
- return info;
+ return info;
}
void
gs_theme_info_unref (GSThemeInfo *info)
{
- g_return_if_fail (info != NULL);
- g_return_if_fail (info->refcount > 0);
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (info->refcount > 0);
- if (--info->refcount == 0)
- {
- g_free (info->name);
- g_free (info->exec);
- g_free (info->file_id);
+ if (--info->refcount == 0)
+ {
+ g_free (info->name);
+ g_free (info->exec);
+ g_free (info->file_id);
- g_free (info);
- }
+ g_free (info);
+ }
}
const char *
gs_theme_info_get_id (GSThemeInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->file_id;
+ return info->file_id;
}
const char *
gs_theme_info_get_name (GSThemeInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->name;
+ return info->name;
}
const char *
gs_theme_info_get_exec (GSThemeInfo *info)
{
- const char *exec;
+ const char *exec;
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- if (check_command (info->exec))
- {
- exec = info->exec;
- }
- else
- {
- exec = NULL;
- }
+ if (check_command (info->exec))
+ {
+ exec = info->exec;
+ }
+ else
+ {
+ exec = NULL;
+ }
- return exec;
+ return exec;
}
static GSThemeInfo *
gs_theme_info_new_from_garcon_menu_item(GarconMenuItem *item)
{
- GSThemeInfo *info;
- const char *str;
- char *pos;
-
- info = g_new0 (GSThemeInfo, 1);
-
- info->refcount = 1;
- info->name = g_strdup (garcon_menu_item_get_name (item));
- info->exec = g_strdup (garcon_menu_item_get_command (item));
-
- /* remove the .desktop suffix */
- str = garcon_menu_item_get_desktop_id (item);
- pos = g_strrstr (str, ".desktop");
- if (pos)
- {
- info->file_id = g_strndup (str, pos - str);
- }
- else
- {
- info->file_id = g_strdup (str);
- }
-
- return info;
+ GSThemeInfo *info;
+ const char *str;
+ char *pos;
+
+ info = g_new0 (GSThemeInfo, 1);
+
+ info->refcount = 1;
+ info->name = g_strdup (garcon_menu_item_get_name (item));
+ info->exec = g_strdup (garcon_menu_item_get_command (item));
+
+ /* remove the .desktop suffix */
+ str = garcon_menu_item_get_desktop_id (item);
+ pos = g_strrstr (str, ".desktop");
+ if (pos)
+ {
+ info->file_id = g_strndup (str, pos - str);
+ }
+ else
+ {
+ info->file_id = g_strdup (str);
+ }
+
+ return info;
}
static GSThemeInfo *
find_info_for_id (GarconMenu *menu,
const char *id)
{
- GSThemeInfo *info;
- GList *items;
- GList *l;
+ GSThemeInfo *info;
+ GList *items;
+ GList *l;
- items = garcon_menu_get_items (menu);
+ items = garcon_menu_get_items (menu);
- info = NULL;
+ info = NULL;
- for (l = items; l; l = l->next)
- {
- if (info == NULL)
- {
- GarconMenuItem *item = l->data;
- const char *file_id;
+ for (l = items; l; l = l->next)
+ {
+ if (info == NULL)
+ {
+ GarconMenuItem *item = l->data;
+ const char *file_id;
- file_id = garcon_menu_item_get_desktop_id (item);
- if (file_id && id && strcmp (file_id, id) == 0)
- {
- info = gs_theme_info_new_from_garcon_menu_item (item);
- }
- }
- }
+ file_id = garcon_menu_item_get_desktop_id (item);
+ if (file_id && id && strcmp (file_id, id) == 0)
+ {
+ info = gs_theme_info_new_from_garcon_menu_item (item);
+ }
+ }
+ }
- g_list_free (items);
+ g_list_free (items);
- return info;
+ return info;
}
GSThemeInfo *
gs_theme_manager_lookup_theme_info (GSThemeManager *theme_manager,
const char *name)
{
- GSThemeInfo *info;
- char *id;
+ GSThemeInfo *info;
+ char *id;
- g_return_val_if_fail (GS_IS_THEME_MANAGER (theme_manager), NULL);
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (GS_IS_THEME_MANAGER (theme_manager), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- id = g_strdup_printf ("%s.desktop", name);
- info = find_info_for_id (theme_manager->priv->menu, id);
- g_free (id);
+ id = g_strdup_printf ("%s.desktop", name);
+ info = find_info_for_id (theme_manager->priv->menu, id);
+ g_free (id);
- return info;
+ return info;
}
static void
theme_prepend_item (GSList **parent_list,
GarconMenuItem *item)
{
- GSThemeInfo *info;
+ GSThemeInfo *info;
- info = gs_theme_info_new_from_garcon_menu_item (item);
+ info = gs_theme_info_new_from_garcon_menu_item (item);
- *parent_list = g_slist_prepend (*parent_list, info);
+ *parent_list = g_slist_prepend (*parent_list, info);
}
static void
make_theme_list (GSList **parent_list,
GarconMenu *menu)
{
- GList *items;
- GList *l;
+ GList *items;
+ GList *l;
- items = garcon_menu_get_items (menu);
+ items = garcon_menu_get_items (menu);
- for (l = items; l; l = l->next)
- {
- theme_prepend_item (parent_list, l->data);
- }
+ for (l = items; l; l = l->next)
+ {
+ theme_prepend_item (parent_list, l->data);
+ }
- g_list_free (items);
+ g_list_free (items);
- *parent_list = g_slist_reverse (*parent_list);
+ *parent_list = g_slist_reverse (*parent_list);
}
GSList *
gs_theme_manager_get_info_list (GSThemeManager *theme_manager)
{
- GSList *l = NULL;
+ GSList *l = NULL;
- g_return_val_if_fail (GS_IS_THEME_MANAGER (theme_manager), NULL);
+ g_return_val_if_fail (GS_IS_THEME_MANAGER (theme_manager), NULL);
- make_theme_list (&l, theme_manager->priv->menu);
+ make_theme_list (&l, theme_manager->priv->menu);
- return l;
+ return l;
}
static void
gs_theme_manager_class_init (GSThemeManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_theme_manager_finalize;
+ object_class->finalize = gs_theme_manager_finalize;
}
static GarconMenu *
get_themes_menu (void)
{
- GarconMenu *menu = NULL;
- gchar *menu_file = g_strconcat(SYSCONFDIR, "/xdg/menus/xfce4-screensavers.menu", NULL);
+ GarconMenu *menu = NULL;
+ gchar *menu_file = g_strconcat(SYSCONFDIR, "/xdg/menus/xfce4-screensavers.menu", NULL);
- /* we only need to add the locations to the path once
- and since this is only run once we'll do it here */
- add_known_engine_locations_to_path ();
+ /* we only need to add the locations to the path once
+ and since this is only run once we'll do it here */
+ add_known_engine_locations_to_path ();
- menu = garcon_menu_new_for_path (menu_file);
- if (!garcon_menu_load (menu, NULL, NULL))
- {
- g_warning("Failed to load menu.");
- }
+ menu = garcon_menu_new_for_path (menu_file);
+ if (!garcon_menu_load (menu, NULL, NULL))
+ {
+ g_warning("Failed to load menu.");
+ }
- return menu;
+ return menu;
}
static void
gs_theme_manager_init (GSThemeManager *theme_manager)
{
- theme_manager->priv = gs_theme_manager_get_instance_private (theme_manager);
+ theme_manager->priv = gs_theme_manager_get_instance_private (theme_manager);
- theme_manager->priv->menu = get_themes_menu ();
+ theme_manager->priv->menu = get_themes_menu ();
}
static void
gs_theme_manager_finalize (GObject *object)
{
- GSThemeManager *theme_manager;
+ GSThemeManager *theme_manager;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_THEME_MANAGER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_THEME_MANAGER (object));
- theme_manager = GS_THEME_MANAGER (object);
+ theme_manager = GS_THEME_MANAGER (object);
- g_return_if_fail (theme_manager->priv != NULL);
+ g_return_if_fail (theme_manager->priv != NULL);
- if (theme_manager->priv->menu != NULL)
- {
- g_object_unref (G_OBJECT(theme_manager->priv->menu));
- }
+ if (theme_manager->priv->menu != NULL)
+ {
+ g_object_unref (G_OBJECT(theme_manager->priv->menu));
+ }
- G_OBJECT_CLASS (gs_theme_manager_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_theme_manager_parent_class)->finalize (object);
}
GSThemeManager *
gs_theme_manager_new (void)
{
- if (theme_manager_object)
- {
- g_object_ref (theme_manager_object);
- }
- else
- {
- theme_manager_object = g_object_new (GS_TYPE_THEME_MANAGER, NULL);
- g_object_add_weak_pointer (theme_manager_object,
- (gpointer *) &theme_manager_object);
- }
-
- return GS_THEME_MANAGER (theme_manager_object);
+ if (theme_manager_object)
+ {
+ g_object_ref (theme_manager_object);
+ }
+ else
+ {
+ theme_manager_object = g_object_new (GS_TYPE_THEME_MANAGER, NULL);
+ g_object_add_weak_pointer (theme_manager_object,
+ (gpointer *) &theme_manager_object);
+ }
+
+ return GS_THEME_MANAGER (theme_manager_object);
}
diff --git a/src/gs-theme-manager.h b/src/gs-theme-manager.h
index 5c03189..bfdff22 100644
--- a/src/gs-theme-manager.h
+++ b/src/gs-theme-manager.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
*
@@ -38,13 +38,13 @@ typedef struct GSThemeManagerPrivate GSThemeManagerPrivate;
typedef struct
{
- GObject parent;
- GSThemeManagerPrivate *priv;
+ GObject parent;
+ GSThemeManagerPrivate *priv;
} GSThemeManager;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
} GSThemeManagerClass;
typedef struct _GSThemeInfo GSThemeInfo;
@@ -55,7 +55,7 @@ GSThemeManager *gs_theme_manager_new (void);
GSList *gs_theme_manager_get_info_list (GSThemeManager *manager);
GSThemeInfo *gs_theme_manager_lookup_theme_info (GSThemeManager *manager,
- const char *theme);
+ const char *theme);
GSThemeInfo *gs_theme_info_ref (GSThemeInfo *info);
void gs_theme_info_unref (GSThemeInfo *info);
const char *gs_theme_info_get_id (GSThemeInfo *info);
diff --git a/src/gs-visual-gl.c b/src/gs-visual-gl.c
index 2ba8fc3..867d525 100644
--- a/src/gs-visual-gl.c
+++ b/src/gs-visual-gl.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
* Copyright (C) 1999, 2000, 2003 Jamie Zawinski <jwz at jwz.org>
@@ -40,12 +40,12 @@
GdkVisual *
gs_visual_gl_get_best_for_display (GdkDisplay *display)
{
- GdkVisual *visual;
+ GdkVisual *visual;
#ifdef HAVE_LIBGL
- Display *xdisplay;
- GdkScreen *screen;
- int screen_num;
- int i;
+ Display *xdisplay;
+ GdkScreen *screen;
+ int screen_num;
+ int i;
# define R GLX_RED_SIZE
# define G GLX_GREEN_SIZE
@@ -55,60 +55,60 @@ gs_visual_gl_get_best_for_display (GdkDisplay *display)
# define DB GLX_DOUBLEBUFFER
# define ST GLX_STENCIL_SIZE
- static int attrs [][20] =
- {
- { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, DB, ST,1, 0 }, /* rgb double, stencil */
- { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, DB, ST,1, 0 },
- { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, DB, ST,1, 0 },
- { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, DB, 0 }, /* rgb double */
- { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, DB, 0 },
- { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, DB, 0 },
- { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, 0 }, /* rgb single */
- { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, 0 },
- { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, 0 },
- { I, 8, D, 8, DB, 0 }, /* cmap double */
- { I, 4, D, 4, DB, 0 },
- { I, 8, D, 8, 0 }, /* cmap single */
- { I, 4, D, 4, 0 },
- { GLX_RGBA, R, 1, G, 1, B, 1, D, 1, 0 } /* monochrome */
- };
-
- g_return_val_if_fail (display != NULL, NULL);
-
- xdisplay = GDK_DISPLAY_XDISPLAY (display);
- screen = gdk_display_get_default_screen (display);
- screen_num = GDK_SCREEN_XNUMBER (screen);
-
- gdk_x11_display_error_trap_push (display);
-
- visual = NULL;
- for (i = 0; i < G_N_ELEMENTS (attrs); i++)
- {
- XVisualInfo *vi;
-
- vi = glXChooseVisual (xdisplay, screen_num, attrs [i]);
-
- if (vi != NULL)
- {
- VisualID vid;
-
- vid = XVisualIDFromVisual (vi->visual);
-
- visual = gdk_x11_screen_lookup_visual (screen, vid);
-
- XFree (vi);
-
- if (visual != NULL)
- {
- break;
- }
- }
- }
-
- gdk_x11_display_error_trap_pop_ignored (display);
+ static int attrs [][20] =
+ {
+ { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, DB, ST,1, 0 }, /* rgb double, stencil */
+ { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, DB, ST,1, 0 },
+ { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, DB, ST,1, 0 },
+ { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, DB, 0 }, /* rgb double */
+ { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, DB, 0 },
+ { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, DB, 0 },
+ { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, 0 }, /* rgb single */
+ { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, 0 },
+ { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, 0 },
+ { I, 8, D, 8, DB, 0 }, /* cmap double */
+ { I, 4, D, 4, DB, 0 },
+ { I, 8, D, 8, 0 }, /* cmap single */
+ { I, 4, D, 4, 0 },
+ { GLX_RGBA, R, 1, G, 1, B, 1, D, 1, 0 } /* monochrome */
+ };
+
+ g_return_val_if_fail (display != NULL, NULL);
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+ screen = gdk_display_get_default_screen (display);
+ screen_num = GDK_SCREEN_XNUMBER (screen);
+
+ gdk_x11_display_error_trap_push (display);
+
+ visual = NULL;
+ for (i = 0; i < G_N_ELEMENTS (attrs); i++)
+ {
+ XVisualInfo *vi;
+
+ vi = glXChooseVisual (xdisplay, screen_num, attrs [i]);
+
+ if (vi != NULL)
+ {
+ VisualID vid;
+
+ vid = XVisualIDFromVisual (vi->visual);
+
+ visual = gdk_x11_screen_lookup_visual (screen, vid);
+
+ XFree (vi);
+
+ if (visual != NULL)
+ {
+ break;
+ }
+ }
+ }
+
+ gdk_x11_display_error_trap_pop_ignored (display);
#else
- visual = NULL;
+ visual = NULL;
#endif /* HAVE_LIBGL */
- return visual;
+ return visual;
}
diff --git a/src/gs-visual-gl.h b/src/gs-visual-gl.h
index 4b1493a..1b4fe56 100644
--- a/src/gs-visual-gl.h
+++ b/src/gs-visual-gl.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
*
diff --git a/src/gs-watcher-x11.c b/src/gs-watcher-x11.c
index eac7859..3cfaad1 100644
--- a/src/gs-watcher-x11.c
+++ b/src/gs-watcher-x11.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
* Copyright (C) 2008 Red Hat, Inc.
@@ -45,20 +45,20 @@ static gboolean watchdog_timer (GSWatcher *watcher);
struct GSWatcherPrivate
{
- /* settings */
- guint enabled : 1;
- guint delta_notice_timeout;
+ /* settings */
+ guint enabled : 1;
+ guint delta_notice_timeout;
- /* state */
- guint active : 1;
- guint idle : 1;
- guint idle_notice : 1;
+ /* state */
+ guint active : 1;
+ guint idle : 1;
+ guint idle_notice : 1;
- guint idle_id;
- char *status_message;
+ guint idle_id;
+ char *status_message;
- DBusGProxy *presence_proxy;
- guint watchdog_timer_id;
+ DBusGProxy *presence_proxy;
+ guint watchdog_timer_id;
};
enum
@@ -81,20 +81,20 @@ G_DEFINE_TYPE_WITH_PRIVATE (GSWatcher, gs_watcher, G_TYPE_OBJECT)
static void
remove_watchdog_timer (GSWatcher *watcher)
{
- if (watcher->priv->watchdog_timer_id != 0)
- {
- g_source_remove (watcher->priv->watchdog_timer_id);
- watcher->priv->watchdog_timer_id = 0;
- }
+ if (watcher->priv->watchdog_timer_id != 0)
+ {
+ g_source_remove (watcher->priv->watchdog_timer_id);
+ watcher->priv->watchdog_timer_id = 0;
+ }
}
static void
add_watchdog_timer (GSWatcher *watcher,
glong timeout)
{
- watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
- (GSourceFunc)watchdog_timer,
- watcher);
+ watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
+ (GSourceFunc)watchdog_timer,
+ watcher);
}
static void
@@ -103,477 +103,475 @@ gs_watcher_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GSWatcher *self;
-
- self = GS_WATCHER (object);
-
- switch (prop_id)
- {
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, self->priv->status_message);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSWatcher *self;
+
+ self = GS_WATCHER (object);
+
+ switch (prop_id)
+ {
+ case PROP_STATUS_MESSAGE:
+ g_value_set_string (value, self->priv->status_message);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
set_status_text (GSWatcher *watcher,
const char *text)
{
- g_free (watcher->priv->status_message);
+ g_free (watcher->priv->status_message);
- watcher->priv->status_message = g_strdup (text);
- g_object_notify (G_OBJECT (watcher), "status-message");
+ watcher->priv->status_message = g_strdup (text);
+ g_object_notify (G_OBJECT (watcher), "status-message");
}
static void
-gs_watcher_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gs_watcher_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GSWatcher *self;
-
- self = GS_WATCHER (object);
-
- switch (prop_id)
- {
- case PROP_STATUS_MESSAGE:
- set_status_text (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSWatcher *self;
+
+ self = GS_WATCHER (object);
+
+ switch (prop_id)
+ {
+ case PROP_STATUS_MESSAGE:
+ set_status_text (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gs_watcher_class_init (GSWatcherClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gs_watcher_finalize;
- object_class->get_property = gs_watcher_get_property;
- object_class->set_property = gs_watcher_set_property;
-
- g_object_class_install_property (object_class,
- PROP_STATUS_MESSAGE,
- g_param_spec_string ("status-message",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- signals [IDLE_CHANGED] =
- g_signal_new ("idle-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSWatcherClass, idle_changed),
- NULL,
- NULL,
- gs_marshal_BOOLEAN__BOOLEAN,
- G_TYPE_BOOLEAN,
- 1, G_TYPE_BOOLEAN);
- signals [IDLE_NOTICE_CHANGED] =
- g_signal_new ("idle-notice-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed),
- NULL,
- NULL,
- gs_marshal_BOOLEAN__BOOLEAN,
- G_TYPE_BOOLEAN,
- 1, G_TYPE_BOOLEAN);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gs_watcher_finalize;
+ object_class->get_property = gs_watcher_get_property;
+ object_class->set_property = gs_watcher_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_STATUS_MESSAGE,
+ g_param_spec_string ("status-message",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ signals [IDLE_CHANGED] =
+ g_signal_new ("idle-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSWatcherClass, idle_changed),
+ NULL,
+ NULL,
+ gs_marshal_BOOLEAN__BOOLEAN,
+ G_TYPE_BOOLEAN,
+ 1, G_TYPE_BOOLEAN);
+ signals [IDLE_NOTICE_CHANGED] =
+ g_signal_new ("idle-notice-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed),
+ NULL,
+ NULL,
+ gs_marshal_BOOLEAN__BOOLEAN,
+ G_TYPE_BOOLEAN,
+ 1, G_TYPE_BOOLEAN);
}
static gboolean
_gs_watcher_set_session_idle_notice (GSWatcher *watcher,
gboolean in_effect)
{
- gboolean res;
-
- res = FALSE;
-
- if (in_effect != watcher->priv->idle_notice)
- {
-
- g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
- if (res)
- {
- gs_debug ("Changing idle notice state: %d", in_effect);
-
- watcher->priv->idle_notice = in_effect;
- }
- else
- {
- gs_debug ("Idle notice signal not handled: %d", in_effect);
- }
- }
-
- return res;
+ gboolean res;
+
+ res = FALSE;
+
+ if (in_effect != watcher->priv->idle_notice)
+ {
+ g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
+ if (res)
+ {
+ gs_debug ("Changing idle notice state: %d", in_effect);
+
+ watcher->priv->idle_notice = in_effect;
+ }
+ else
+ {
+ gs_debug ("Idle notice signal not handled: %d", in_effect);
+ }
+ }
+
+ return res;
}
static gboolean
_gs_watcher_set_session_idle (GSWatcher *watcher,
gboolean is_idle)
{
- gboolean res;
-
- res = FALSE;
-
- if (is_idle != watcher->priv->idle)
- {
-
- g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
- if (res)
- {
- gs_debug ("Changing idle state: %d", is_idle);
-
- watcher->priv->idle = is_idle;
- }
- else
- {
- gs_debug ("Idle changed signal not handled: %d", is_idle);
- }
- }
-
- return res;
+ gboolean res;
+
+ res = FALSE;
+
+ if (is_idle != watcher->priv->idle)
+ {
+ g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
+ if (res)
+ {
+ gs_debug ("Changing idle state: %d", is_idle);
+
+ watcher->priv->idle = is_idle;
+ }
+ else
+ {
+ gs_debug ("Idle changed signal not handled: %d", is_idle);
+ }
+ }
+
+ return res;
}
gboolean
gs_watcher_get_active (GSWatcher *watcher)
{
- gboolean active;
+ gboolean active;
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
+ g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
- active = watcher->priv->active;
+ active = watcher->priv->active;
- return active;
+ return active;
}
static void
_gs_watcher_reset_state (GSWatcher *watcher)
{
- watcher->priv->idle = FALSE;
- watcher->priv->idle_notice = FALSE;
+ watcher->priv->idle = FALSE;
+ watcher->priv->idle_notice = FALSE;
}
static gboolean
_gs_watcher_set_active_internal (GSWatcher *watcher,
gboolean active)
{
- if (active != watcher->priv->active)
- {
- /* reset state */
- _gs_watcher_reset_state (watcher);
+ if (active != watcher->priv->active)
+ {
+ /* reset state */
+ _gs_watcher_reset_state (watcher);
- watcher->priv->active = active;
- }
+ watcher->priv->active = active;
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gs_watcher_set_active (GSWatcher *watcher,
gboolean active)
{
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
+ g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
- gs_debug ("turning watcher: %s", active ? "ON" : "OFF");
+ gs_debug ("turning watcher: %s", active ? "ON" : "OFF");
- if (watcher->priv->active == active)
- {
- gs_debug ("Idle detection is already %s",
- active ? "active" : "inactive");
- return FALSE;
- }
+ if (watcher->priv->active == active)
+ {
+ gs_debug ("Idle detection is already %s",
+ active ? "active" : "inactive");
+ return FALSE;
+ }
- if (! watcher->priv->enabled)
- {
- gs_debug ("Idle detection is disabled, cannot activate");
- return FALSE;
- }
+ if (! watcher->priv->enabled)
+ {
+ gs_debug ("Idle detection is disabled, cannot activate");
+ return FALSE;
+ }
- return _gs_watcher_set_active_internal (watcher, active);
+ return _gs_watcher_set_active_internal (watcher, active);
}
gboolean
gs_watcher_set_enabled (GSWatcher *watcher,
gboolean enabled)
{
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
+ g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
- if (watcher->priv->enabled != enabled)
- {
- gboolean is_active = gs_watcher_get_active (watcher);
+ if (watcher->priv->enabled != enabled)
+ {
+ gboolean is_active = gs_watcher_get_active (watcher);
- watcher->priv->enabled = enabled;
+ watcher->priv->enabled = enabled;
- /* if we are disabling the watcher and we are
- active shut it down */
- if (! enabled && is_active)
- {
- _gs_watcher_set_active_internal (watcher, FALSE);
- }
- }
+ /* if we are disabling the watcher and we are
+ active shut it down */
+ if (! enabled && is_active)
+ {
+ _gs_watcher_set_active_internal (watcher, FALSE);
+ }
+ }
- return TRUE;
+ return TRUE;
}
gboolean
gs_watcher_get_enabled (GSWatcher *watcher)
{
- gboolean enabled;
+ gboolean enabled;
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
+ g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
- enabled = watcher->priv->enabled;
+ enabled = watcher->priv->enabled;
- return enabled;
+ return enabled;
}
static gboolean
on_idle_timeout (GSWatcher *watcher)
{
- gboolean res;
+ gboolean res;
- res = _gs_watcher_set_session_idle (watcher, TRUE);
+ res = _gs_watcher_set_session_idle (watcher, TRUE);
- _gs_watcher_set_session_idle_notice (watcher, FALSE);
+ _gs_watcher_set_session_idle_notice (watcher, FALSE);
- /* try again if we failed i guess */
- return !res;
+ /* try again if we failed i guess */
+ return !res;
}
static void
set_status (GSWatcher *watcher,
guint status)
{
- gboolean is_idle;
-
- if (! watcher->priv->active)
- {
- gs_debug ("GSWatcher: not active, ignoring status changes");
- return;
- }
-
- is_idle = (status == 3);
-
- if (!is_idle && !watcher->priv->idle_notice)
- {
- /* no change in idleness */
- return;
- }
-
- if (is_idle)
- {
- _gs_watcher_set_session_idle_notice (watcher, is_idle);
- /* queue an activation */
- if (watcher->priv->idle_id > 0)
- {
- g_source_remove (watcher->priv->idle_id);
- }
- watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
- (GSourceFunc)on_idle_timeout,
- watcher);
- }
- else
- {
- /* cancel notice too */
- if (watcher->priv->idle_id > 0)
- {
- g_source_remove (watcher->priv->idle_id);
- watcher->priv->idle_id = 0;
- }
- _gs_watcher_set_session_idle (watcher, FALSE);
- _gs_watcher_set_session_idle_notice (watcher, FALSE);
- }
+ gboolean is_idle;
+
+ if (! watcher->priv->active)
+ {
+ gs_debug ("GSWatcher: not active, ignoring status changes");
+ return;
+ }
+
+ is_idle = (status == 3);
+
+ if (!is_idle && !watcher->priv->idle_notice)
+ {
+ /* no change in idleness */
+ return;
+ }
+
+ if (is_idle)
+ {
+ _gs_watcher_set_session_idle_notice (watcher, is_idle);
+ /* queue an activation */
+ if (watcher->priv->idle_id > 0)
+ {
+ g_source_remove (watcher->priv->idle_id);
+ }
+ watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
+ (GSourceFunc)on_idle_timeout,
+ watcher);
+ }
+ else
+ {
+ /* cancel notice too */
+ if (watcher->priv->idle_id > 0)
+ {
+ g_source_remove (watcher->priv->idle_id);
+ watcher->priv->idle_id = 0;
+ }
+ _gs_watcher_set_session_idle (watcher, FALSE);
+ _gs_watcher_set_session_idle_notice (watcher, FALSE);
+ }
}
static void
-on_presence_status_changed (DBusGProxy *presence_proxy,
- guint status,
- GSWatcher *watcher)
+on_presence_status_changed (DBusGProxy *presence_proxy,
+ guint status,
+ GSWatcher *watcher)
{
- set_status (watcher, status);
+ set_status (watcher, status);
}
static void
-on_presence_status_text_changed (DBusGProxy *presence_proxy,
- const char *status_text,
- GSWatcher *watcher)
+on_presence_status_text_changed (DBusGProxy *presence_proxy,
+ const char *status_text,
+ GSWatcher *watcher)
{
- set_status_text (watcher, status_text);
+ set_status_text (watcher, status_text);
}
static gboolean
connect_presence_watcher (GSWatcher *watcher)
{
- DBusGConnection *bus;
- GError *error;
- gboolean ret;
-
- ret = FALSE;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (bus == NULL)
- {
- g_warning ("Unable to get session bus: %s", error->message);
- g_error_free (error);
- goto done;
- }
-
- error = NULL;
- watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
- "org.gnome.SessionManager",
- "/org/gnome/SessionManager/Presence",
- "org.gnome.SessionManager.Presence",
- &error);
- if (watcher->priv->presence_proxy != NULL)
- {
- DBusGProxy *proxy;
-
- dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
- "StatusChanged",
- G_TYPE_UINT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
- "StatusChanged",
- G_CALLBACK (on_presence_status_changed),
- watcher,
- NULL);
- dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
- "StatusTextChanged",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
- "StatusTextChanged",
- G_CALLBACK (on_presence_status_text_changed),
- watcher,
- NULL);
-
- proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
- "org.freedesktop.DBus.Properties",
- "/org/gnome/SessionManager/Presence");
- if (proxy != NULL)
- {
- guint status;
- const char *status_text;
- GValue value = { 0, };
-
- status = 0;
- status_text = NULL;
-
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Get",
- &error,
- G_TYPE_STRING, "org.gnome.SessionManager.Presence",
- G_TYPE_STRING, "status",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID);
-
- if (error != NULL)
- {
- g_warning ("Couldn't get presence status: %s", error->message);
- g_error_free (error);
- goto done;
- }
- else
- {
- status = g_value_get_uint (&value);
- }
-
- g_value_unset (&value);
-
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Get",
- &error,
- G_TYPE_STRING, "org.gnome.SessionManager.Presence",
- G_TYPE_STRING, "status-text",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID);
-
- if (error != NULL)
- {
- g_warning ("Couldn't get presence status text: %s", error->message);
- g_error_free (error);
- }
- else
- {
- status_text = g_value_get_string (&value);
- }
-
- set_status (watcher, status);
- set_status_text (watcher, status_text);
- }
- }
- else
- {
- g_warning ("Failed to get session presence proxy: %s", error->message);
- g_error_free (error);
- goto done;
- }
-
- ret = TRUE;
+ DBusGConnection *bus;
+ GError *error;
+ gboolean ret;
+
+ ret = FALSE;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (bus == NULL)
+ {
+ g_warning ("Unable to get session bus: %s", error->message);
+ g_error_free (error);
+ goto done;
+ }
+
+ error = NULL;
+ watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager/Presence",
+ "org.gnome.SessionManager.Presence",
+ &error);
+ if (watcher->priv->presence_proxy != NULL)
+ {
+ DBusGProxy *proxy;
+
+ dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
+ "StatusChanged",
+ G_TYPE_UINT,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
+ "StatusChanged",
+ G_CALLBACK (on_presence_status_changed),
+ watcher,
+ NULL);
+ dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
+ "StatusTextChanged",
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
+ "StatusTextChanged",
+ G_CALLBACK (on_presence_status_text_changed),
+ watcher,
+ NULL);
+
+ proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
+ "org.freedesktop.DBus.Properties",
+ "/org/gnome/SessionManager/Presence");
+ if (proxy != NULL)
+ {
+ guint status;
+ const char *status_text;
+ GValue value = { 0, };
+
+ status = 0;
+ status_text = NULL;
+
+ error = NULL;
+ dbus_g_proxy_call (proxy,
+ "Get",
+ &error,
+ G_TYPE_STRING, "org.gnome.SessionManager.Presence",
+ G_TYPE_STRING, "status",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value,
+ G_TYPE_INVALID);
+
+ if (error != NULL)
+ {
+ g_warning ("Couldn't get presence status: %s", error->message);
+ g_error_free (error);
+ goto done;
+ }
+ else
+ {
+ status = g_value_get_uint (&value);
+ }
+
+ g_value_unset (&value);
+
+ error = NULL;
+ dbus_g_proxy_call (proxy,
+ "Get",
+ &error,
+ G_TYPE_STRING, "org.gnome.SessionManager.Presence",
+ G_TYPE_STRING, "status-text",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &value,
+ G_TYPE_INVALID);
+
+ if (error != NULL)
+ {
+ g_warning ("Couldn't get presence status text: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ status_text = g_value_get_string (&value);
+ }
+
+ set_status (watcher, status);
+ set_status_text (watcher, status_text);
+ }
+ }
+ else
+ {
+ g_warning ("Failed to get session presence proxy: %s", error->message);
+ g_error_free (error);
+ goto done;
+ }
+
+ ret = TRUE;
done:
- return ret;
+ return ret;
}
static void
gs_watcher_init (GSWatcher *watcher)
{
- watcher->priv = gs_watcher_get_instance_private (watcher);
+ watcher->priv = gs_watcher_get_instance_private (watcher);
- watcher->priv->enabled = TRUE;
- watcher->priv->active = FALSE;
+ watcher->priv->enabled = TRUE;
+ watcher->priv->active = FALSE;
- connect_presence_watcher (watcher);
+ connect_presence_watcher (watcher);
- /* time before idle signal to send notice signal */
- watcher->priv->delta_notice_timeout = 10000;
+ /* time before idle signal to send notice signal */
+ watcher->priv->delta_notice_timeout = 10000;
- add_watchdog_timer (watcher, 600000);
+ add_watchdog_timer (watcher, 600000);
}
static void
gs_watcher_finalize (GObject *object)
{
- GSWatcher *watcher;
+ GSWatcher *watcher;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_WATCHER (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_WATCHER (object));
- watcher = GS_WATCHER (object);
+ watcher = GS_WATCHER (object);
- g_return_if_fail (watcher->priv != NULL);
+ g_return_if_fail (watcher->priv != NULL);
- remove_watchdog_timer (watcher);
+ remove_watchdog_timer (watcher);
- if (watcher->priv->idle_id > 0)
- {
- g_source_remove (watcher->priv->idle_id);
- watcher->priv->idle_id = 0;
- }
+ if (watcher->priv->idle_id > 0)
+ {
+ g_source_remove (watcher->priv->idle_id);
+ watcher->priv->idle_id = 0;
+ }
- watcher->priv->active = FALSE;
+ watcher->priv->active = FALSE;
- if (watcher->priv->presence_proxy != NULL)
- {
- g_object_unref (watcher->priv->presence_proxy);
- }
+ if (watcher->priv->presence_proxy != NULL)
+ {
+ g_object_unref (watcher->priv->presence_proxy);
+ }
- g_free (watcher->priv->status_message);
+ g_free (watcher->priv->status_message);
- G_OBJECT_CLASS (gs_watcher_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_watcher_parent_class)->finalize (object);
}
/* Figuring out what the appropriate XSetScreenSaver() parameters are
@@ -583,64 +581,64 @@ static void
disable_builtin_screensaver (GSWatcher *watcher,
gboolean unblank_screen)
{
- int current_server_timeout, current_server_interval;
- int current_prefer_blank, current_allow_exp;
- int desired_server_timeout, desired_server_interval;
- int desired_prefer_blank, desired_allow_exp;
-
- XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- ¤t_server_timeout,
- ¤t_server_interval,
- ¤t_prefer_blank,
- ¤t_allow_exp);
-
- desired_server_timeout = current_server_timeout;
- desired_server_interval = current_server_interval;
- desired_prefer_blank = current_prefer_blank;
- desired_allow_exp = current_allow_exp;
-
- desired_server_interval = 0;
-
- /* I suspect (but am not sure) that DontAllowExposures might have
- something to do with powering off the monitor as well, at least
- on some systems that don't support XDPMS? Who know... */
- desired_allow_exp = AllowExposures;
-
- /* When we're not using an extension, set the server-side timeout to 0,
- so that the server never gets involved with screen blanking, and we
- do it all ourselves. (However, when we *are* using an extension,
- we tell the server when to notify us, and rather than blanking the
- screen, the server will send us an X event telling us to blank.)
- */
- desired_server_timeout = 0;
-
- if (desired_server_timeout != current_server_timeout
- || desired_server_interval != current_server_interval
- || desired_prefer_blank != current_prefer_blank
- || desired_allow_exp != current_allow_exp)
- {
-
- gs_debug ("disabling server builtin screensaver:"
- " (xset s %d %d; xset s %s; xset s %s)",
- desired_server_timeout,
- desired_server_interval,
- (desired_prefer_blank ? "blank" : "noblank"),
- (desired_allow_exp ? "expose" : "noexpose"));
-
- XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- desired_server_timeout,
- desired_server_interval,
- desired_prefer_blank,
- desired_allow_exp);
-
- XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), FALSE);
- }
-
- if (unblank_screen)
- {
- /* Turn off the server builtin saver if it is now running. */
- XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), ScreenSaverReset);
- }
+ int current_server_timeout, current_server_interval;
+ int current_prefer_blank, current_allow_exp;
+ int desired_server_timeout, desired_server_interval;
+ int desired_prefer_blank, desired_allow_exp;
+
+ XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ ¤t_server_timeout,
+ ¤t_server_interval,
+ ¤t_prefer_blank,
+ ¤t_allow_exp);
+
+ desired_server_timeout = current_server_timeout;
+ desired_server_interval = current_server_interval;
+ desired_prefer_blank = current_prefer_blank;
+ desired_allow_exp = current_allow_exp;
+
+ desired_server_interval = 0;
+
+ /* I suspect (but am not sure) that DontAllowExposures might have
+ something to do with powering off the monitor as well, at least
+ on some systems that don't support XDPMS? Who know... */
+ desired_allow_exp = AllowExposures;
+
+ /* When we're not using an extension, set the server-side timeout to 0,
+ so that the server never gets involved with screen blanking, and we
+ do it all ourselves. (However, when we *are* using an extension,
+ we tell the server when to notify us, and rather than blanking the
+ screen, the server will send us an X event telling us to blank.)
+ */
+ desired_server_timeout = 0;
+
+ if (desired_server_timeout != current_server_timeout
+ || desired_server_interval != current_server_interval
+ || desired_prefer_blank != current_prefer_blank
+ || desired_allow_exp != current_allow_exp)
+ {
+
+ gs_debug ("disabling server builtin screensaver:"
+ " (xset s %d %d; xset s %s; xset s %s)",
+ desired_server_timeout,
+ desired_server_interval,
+ (desired_prefer_blank ? "blank" : "noblank"),
+ (desired_allow_exp ? "expose" : "noexpose"));
+
+ XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ desired_server_timeout,
+ desired_server_interval,
+ desired_prefer_blank,
+ desired_allow_exp);
+
+ XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), FALSE);
+ }
+
+ if (unblank_screen)
+ {
+ /* Turn off the server builtin saver if it is now running. */
+ XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), ScreenSaverReset);
+ }
}
@@ -660,18 +658,18 @@ static gboolean
watchdog_timer (GSWatcher *watcher)
{
- disable_builtin_screensaver (watcher, FALSE);
+ disable_builtin_screensaver (watcher, FALSE);
- return TRUE;
+ return TRUE;
}
GSWatcher *
gs_watcher_new (void)
{
- GSWatcher *watcher;
+ GSWatcher *watcher;
- watcher = g_object_new (GS_TYPE_WATCHER,
- NULL);
+ watcher = g_object_new (GS_TYPE_WATCHER,
+ NULL);
- return GS_WATCHER (watcher);
+ return GS_WATCHER (watcher);
}
diff --git a/src/gs-watcher.h b/src/gs-watcher.h
index e844fe1..4f23f40 100644
--- a/src/gs-watcher.h
+++ b/src/gs-watcher.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -38,29 +38,29 @@ typedef struct GSWatcherPrivate GSWatcherPrivate;
typedef struct
{
- GObject parent;
- GSWatcherPrivate *priv;
+ GObject parent;
+ GSWatcherPrivate *priv;
} GSWatcher;
typedef struct
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- gboolean (* idle_changed) (GSWatcher *watcher,
- gboolean is_idle);
- gboolean (* idle_notice_changed) (GSWatcher *watcher,
- gboolean in_effect);
+ gboolean (* idle_changed) (GSWatcher *watcher,
+ gboolean is_idle);
+ gboolean (* idle_notice_changed) (GSWatcher *watcher,
+ gboolean in_effect);
} GSWatcherClass;
-GType gs_watcher_get_type (void);
+GType gs_watcher_get_type (void);
-GSWatcher * gs_watcher_new (void);
-gboolean gs_watcher_set_enabled (GSWatcher *watcher,
- gboolean enabled);
-gboolean gs_watcher_get_enabled (GSWatcher *watcher);
-gboolean gs_watcher_set_active (GSWatcher *watcher,
- gboolean active);
-gboolean gs_watcher_get_active (GSWatcher *watcher);
+GSWatcher * gs_watcher_new (void);
+gboolean gs_watcher_set_enabled (GSWatcher *watcher,
+ gboolean enabled);
+gboolean gs_watcher_get_enabled (GSWatcher *watcher);
+gboolean gs_watcher_set_active (GSWatcher *watcher,
+ gboolean active);
+gboolean gs_watcher_get_active (GSWatcher *watcher);
G_END_DECLS
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c
index 7c066f1..c3f0031 100644
--- a/src/gs-window-x11.c
+++ b/src/gs-window-x11.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2008 William Jon McCann <mccann at jhu.edu>
*
@@ -41,13 +41,13 @@
#include <X11/extensions/shape.h>
#endif
-static void gs_window_class_init (GSWindowClass *klass);
-static void gs_window_init (GSWindow *window);
-static void gs_window_finalize (GObject *object);
+static void gs_window_class_init (GSWindowClass *klass);
+static void gs_window_init (GSWindow *window);
+static void gs_window_finalize (GObject *object);
-static gboolean popup_dialog_idle (GSWindow *window);
-static void gs_window_dialog_finish (GSWindow *window);
-static void remove_command_watches (GSWindow *window);
+static gboolean popup_dialog_idle (GSWindow *window);
+static void gs_window_dialog_finish (GSWindow *window);
+static void remove_command_watches (GSWindow *window);
enum
{
@@ -60,59 +60,59 @@ enum
struct GSWindowPrivate
{
- GdkMonitor *monitor;
+ GdkMonitor *monitor;
- GdkRectangle geometry;
- guint obscured : 1;
- guint dialog_up : 1;
+ GdkRectangle geometry;
+ guint obscured : 1;
+ guint dialog_up : 1;
+
+ guint lock_enabled : 1;
+ guint user_switch_enabled : 1;
+ guint logout_enabled : 1;
+ guint keyboard_enabled : 1;
+
+ guint64 logout_timeout;
+ char *logout_command;
+ char *keyboard_command;
+ char *status_message;
- guint lock_enabled : 1;
- guint user_switch_enabled : 1;
- guint logout_enabled : 1;
- guint keyboard_enabled : 1;
+ GtkWidget *vbox;
+ GtkWidget *drawing_area;
+ GtkWidget *lock_box;
+ GtkWidget *lock_socket;
+ GtkWidget *keyboard_socket;
+ GtkWidget *info_bar;
+ GtkWidget *info_content;
- guint64 logout_timeout;
- char *logout_command;
- char *keyboard_command;
- char *status_message;
+ cairo_surface_t *background_surface;
- GtkWidget *vbox;
- GtkWidget *drawing_area;
- GtkWidget *lock_box;
- GtkWidget *lock_socket;
- GtkWidget *keyboard_socket;
- GtkWidget *info_bar;
- GtkWidget *info_content;
+ guint popup_dialog_idle_id;
- cairo_surface_t *background_surface;
+ guint dialog_map_signal_id;
+ guint dialog_unmap_signal_id;
+ guint dialog_response_signal_id;
- guint popup_dialog_idle_id;
+ guint watchdog_timer_id;
+ guint info_bar_timer_id;
- guint dialog_map_signal_id;
- guint dialog_unmap_signal_id;
- guint dialog_response_signal_id;
+ gint lock_pid;
+ gint lock_watch_id;
+ gint dialog_response;
+ gboolean dialog_quit_requested;
+ gboolean dialog_shake_in_progress;
- guint watchdog_timer_id;
- guint info_bar_timer_id;
+ gint keyboard_pid;
+ gint keyboard_watch_id;
- gint lock_pid;
- gint lock_watch_id;
- gint dialog_response;
- gboolean dialog_quit_requested;
- gboolean dialog_shake_in_progress;
+ GList *key_events;
- gint keyboard_pid;
- gint keyboard_watch_id;
+ gdouble last_x;
+ gdouble last_y;
- GList *key_events;
-
- gdouble last_x;
- gdouble last_y;
-
- GTimer *timer;
+ GTimer *timer;
#ifdef HAVE_SHAPE_EXT
- int shape_event_base;
+ int shape_event_base;
#endif
};
@@ -146,220 +146,220 @@ static void
set_invisible_cursor (GdkWindow *window,
gboolean invisible)
{
- GdkDisplay *display;
- GdkCursor *cursor = NULL;
+ GdkDisplay *display;
+ GdkCursor *cursor = NULL;
- if (invisible)
- {
- display = gdk_window_get_display (window);
- cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
- }
+ if (invisible)
+ {
+ display = gdk_window_get_display (window);
+ cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
+ }
- gdk_window_set_cursor (window, cursor);
+ gdk_window_set_cursor (window, cursor);
- if (cursor)
- {
- g_object_unref (cursor);
- }
+ if (cursor)
+ {
+ g_object_unref (cursor);
+ }
}
/* derived from tomboy */
static void
gs_window_override_user_time (GSWindow *window)
{
- guint32 ev_time = gtk_get_current_event_time ();
+ guint32 ev_time = gtk_get_current_event_time ();
- if (ev_time == 0)
- {
- gint ev_mask = gtk_widget_get_events (GTK_WIDGET (window));
- if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK))
- {
- gtk_widget_add_events (GTK_WIDGET (window),
- GDK_PROPERTY_CHANGE_MASK);
- }
+ if (ev_time == 0)
+ {
+ gint ev_mask = gtk_widget_get_events (GTK_WIDGET (window));
+ if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK))
+ {
+ gtk_widget_add_events (GTK_WIDGET (window),
+ GDK_PROPERTY_CHANGE_MASK);
+ }
- /*
- * NOTE: Last resort for D-BUS or other non-interactive
- * openings. Causes roundtrip to server. Lame.
- */
- ev_time = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)));
- }
+ /*
+ * NOTE: Last resort for D-BUS or other non-interactive
+ * openings. Causes roundtrip to server. Lame.
+ */
+ ev_time = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)));
+ }
- gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)), ev_time);
+ gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)), ev_time);
}
static void
clear_children (Window window)
{
- Window root;
- Window parent;
- Window *children;
- unsigned int n_children;
- int status;
+ Window root;
+ Window parent;
+ Window *children;
+ unsigned int n_children;
+ int status;
- children = NULL;
- status = XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), window, &root, &parent, &children, &n_children);
+ children = NULL;
+ status = XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), window, &root, &parent, &children, &n_children);
- if (status == 0)
- {
- if (children)
- {
- XFree (children);
- }
- return;
- }
+ if (status == 0)
+ {
+ if (children)
+ {
+ XFree (children);
+ }
+ return;
+ }
- if (children)
- {
- while (n_children)
- {
- Window child;
+ if (children)
+ {
+ while (n_children)
+ {
+ Window child;
- child = children [--n_children];
+ child = children [--n_children];
- XClearWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), child);
+ XClearWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), child);
- clear_children (child);
- }
+ clear_children (child);
+ }
- XFree (children);
- }
+ XFree (children);
+ }
}
static void
widget_clear_all_children (GtkWidget *widget)
{
- GdkWindow *w;
- GdkDisplay *display;
+ GdkWindow *w;
+ GdkDisplay *display;
- gs_debug ("Clearing all child windows");
- display = gtk_widget_get_display (widget);
+ gs_debug ("Clearing all child windows");
+ display = gtk_widget_get_display (widget);
- gdk_x11_display_error_trap_push (display);
+ gdk_x11_display_error_trap_push (display);
- w = gtk_widget_get_window (widget);
+ w = gtk_widget_get_window (widget);
- clear_children (GDK_WINDOW_XID (w));
+ clear_children (GDK_WINDOW_XID (w));
- gdk_x11_display_error_trap_pop_ignored (display);
+ gdk_x11_display_error_trap_pop_ignored (display);
}
void
gs_window_set_background_surface (GSWindow *window,
cairo_surface_t *surface)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- if (window->priv->background_surface != NULL)
- {
- cairo_surface_destroy (window->priv->background_surface);
- }
- window->priv->background_surface = NULL;
+ if (window->priv->background_surface != NULL)
+ {
+ cairo_surface_destroy (window->priv->background_surface);
+ }
+ window->priv->background_surface = NULL;
- if (surface != NULL)
- {
- window->priv->background_surface = cairo_surface_reference (surface);
- }
+ if (surface != NULL)
+ {
+ window->priv->background_surface = cairo_surface_reference (surface);
+ }
- gtk_widget_queue_draw (GTK_WIDGET (window));
+ gtk_widget_queue_draw (GTK_WIDGET (window));
}
void
gs_window_clear (GSWindow *window)
{
- GdkDisplay *display;
- g_return_if_fail (GS_IS_WINDOW (window));
+ GdkDisplay *display;
+ g_return_if_fail (GS_IS_WINDOW (window));
- gs_debug ("Clearing widgets");
+ gs_debug ("Clearing widgets");
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- {
- gtk_widget_queue_draw (GTK_WIDGET (window));
- /* If a screensaver theme adds child windows
- we need to clear them too */
- widget_clear_all_children (GTK_WIDGET (window));
- }
+ if (gtk_widget_get_realized (GTK_WIDGET (window)))
+ {
+ gtk_widget_queue_draw (GTK_WIDGET (window));
+ /* If a screensaver theme adds child windows
+ we need to clear them too */
+ widget_clear_all_children (GTK_WIDGET (window));
+ }
- if (gtk_widget_get_realized (window->priv->drawing_area))
- {
- gtk_widget_queue_draw (window->priv->drawing_area);
- widget_clear_all_children (window->priv->drawing_area);
- }
+ if (gtk_widget_get_realized (window->priv->drawing_area))
+ {
+ gtk_widget_queue_draw (window->priv->drawing_area);
+ widget_clear_all_children (window->priv->drawing_area);
+ }
- display = gtk_widget_get_display (GTK_WIDGET(window));
- gdk_display_flush (display);
+ display = gtk_widget_get_display (GTK_WIDGET(window));
+ gdk_display_flush (display);
}
static cairo_region_t *
get_outside_region (GSWindow *window)
{
- GdkDisplay *display;
- int i;
- int num_monitors;
- cairo_region_t *region;
+ GdkDisplay *display;
+ int i;
+ int num_monitors;
+ cairo_region_t *region;
- display = gtk_widget_get_display (GTK_WIDGET (window));
+ display = gtk_widget_get_display (GTK_WIDGET (window));
- region = cairo_region_create ();
+ region = cairo_region_create ();
- num_monitors = gdk_display_get_n_monitors (display);
- for (i = 0; i < num_monitors; i++)
- {
- GdkMonitor *mon = gdk_display_get_monitor (display, i);
+ num_monitors = gdk_display_get_n_monitors (display);
+ for (i = 0; i < num_monitors; i++)
+ {
+ GdkMonitor *mon = gdk_display_get_monitor (display, i);
- if (mon != window->priv->monitor)
- {
- GdkRectangle geometry;
- cairo_rectangle_int_t rectangle;
+ if (mon != window->priv->monitor)
+ {
+ GdkRectangle geometry;
+ cairo_rectangle_int_t rectangle;
- gdk_monitor_get_geometry (mon, &geometry);
- rectangle.x = geometry.x;
- rectangle.y = geometry.y;
- rectangle.width = geometry.width;
- rectangle.height = geometry.height;
- cairo_region_union_rectangle (region, &rectangle);
- }
- else
- {
- break;
- }
- }
+ gdk_monitor_get_geometry (mon, &geometry);
+ rectangle.x = geometry.x;
+ rectangle.y = geometry.y;
+ rectangle.width = geometry.width;
+ rectangle.height = geometry.height;
+ cairo_region_union_rectangle (region, &rectangle);
+ }
+ else
+ {
+ break;
+ }
+ }
- return region;
+ return region;
}
static void
update_geometry (GSWindow *window)
{
- GdkRectangle geometry;
- cairo_region_t *outside_region;
- cairo_region_t *monitor_region;
+ GdkRectangle geometry;
+ cairo_region_t *outside_region;
+ cairo_region_t *monitor_region;
- outside_region = get_outside_region (window);
+ outside_region = get_outside_region (window);
- gdk_monitor_get_geometry (window->priv->monitor, &geometry);
- gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",
- geometry.x,
- geometry.y,
- geometry.width,
- geometry.height);
- monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
- cairo_region_subtract (monitor_region, outside_region);
- cairo_region_destroy (outside_region);
+ gdk_monitor_get_geometry (window->priv->monitor, &geometry);
+ gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",
+ geometry.x,
+ geometry.y,
+ geometry.width,
+ geometry.height);
+ monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
+ cairo_region_subtract (monitor_region, outside_region);
+ cairo_region_destroy (outside_region);
- cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
- cairo_region_destroy (monitor_region);
+ cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
+ cairo_region_destroy (monitor_region);
- gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",
- geometry.x,
- geometry.y,
- geometry.width,
- geometry.height);
+ gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",
+ geometry.x,
+ geometry.y,
+ geometry.width,
+ geometry.height);
- window->priv->geometry.x = geometry.x;
- window->priv->geometry.y = geometry.y;
- window->priv->geometry.width = geometry.width;
- window->priv->geometry.height = geometry.height;
+ window->priv->geometry.x = geometry.x;
+ window->priv->geometry.y = geometry.y;
+ window->priv->geometry.width = geometry.width;
+ window->priv->geometry.height = geometry.height;
}
static void
@@ -367,8 +367,8 @@ monitor_geometry_notify (GdkMonitor *monitor,
GParamSpec *pspec,
GSWindow *window)
{
- gs_debug ("Got monitor geometry notify signal");
- gtk_widget_queue_resize (GTK_WIDGET (window));
+ gs_debug ("Got monitor geometry notify signal");
+ gtk_widget_queue_resize (GTK_WIDGET (window));
}
/* copied from panel-toplevel.c */
@@ -377,91 +377,91 @@ gs_window_move_resize_window (GSWindow *window,
gboolean move,
gboolean resize)
{
- GtkWidget *widget;
- GdkWindow *gdkwindow;
-
- widget = GTK_WIDGET (window);
- gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
-
- g_assert (gtk_widget_get_realized (widget));
-
- gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",
- window->priv->geometry.x,
- window->priv->geometry.y,
- window->priv->geometry.width,
- window->priv->geometry.height);
-
- if (move && resize)
- {
- gdk_window_move_resize (gdkwindow,
- window->priv->geometry.x,
- window->priv->geometry.y,
- window->priv->geometry.width,
- window->priv->geometry.height);
- }
- else if (move)
- {
- gdk_window_move (gdkwindow,
- window->priv->geometry.x,
- window->priv->geometry.y);
- }
- else if (resize)
- {
- gdk_window_resize (gdkwindow,
- window->priv->geometry.width,
- window->priv->geometry.height);
- }
+ GtkWidget *widget;
+ GdkWindow *gdkwindow;
+
+ widget = GTK_WIDGET (window);
+ gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
+
+ g_assert (gtk_widget_get_realized (widget));
+
+ gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",
+ window->priv->geometry.x,
+ window->priv->geometry.y,
+ window->priv->geometry.width,
+ window->priv->geometry.height);
+
+ if (move && resize)
+ {
+ gdk_window_move_resize (gdkwindow,
+ window->priv->geometry.x,
+ window->priv->geometry.y,
+ window->priv->geometry.width,
+ window->priv->geometry.height);
+ }
+ else if (move)
+ {
+ gdk_window_move (gdkwindow,
+ window->priv->geometry.x,
+ window->priv->geometry.y);
+ }
+ else if (resize)
+ {
+ gdk_window_resize (gdkwindow,
+ window->priv->geometry.width,
+ window->priv->geometry.height);
+ }
}
static void
gs_window_real_unrealize (GtkWidget *widget)
{
- GdkMonitor *monitor = GS_WINDOW (widget)->priv->monitor;
+ GdkMonitor *monitor = GS_WINDOW (widget)->priv->monitor;
- g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,
- widget);
+ g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,
+ widget);
- if (GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize)
- {
- GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize (widget);
- }
+ if (GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize)
+ {
+ GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize (widget);
+ }
}
/* copied from gdk */
extern char **environ;
static gchar **
-spawn_make_environment_for_display (GdkDisplay *display,
- gchar **envp)
+spawn_make_environment_for_display (GdkDisplay *display,
+ gchar **envp)
{
- gchar **retval = NULL;
- const gchar *display_name;
- gint display_index = -1;
- gint i, env_len;
+ gchar **retval = NULL;
+ const gchar *display_name;
+ gint display_index = -1;
+ gint i, env_len;
- g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- if (envp == NULL)
- envp = environ;
+ if (envp == NULL)
+ envp = environ;
- for (env_len = 0; envp[env_len]; env_len++)
- if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
- display_index = env_len;
+ for (env_len = 0; envp[env_len]; env_len++)
+ if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
+ display_index = env_len;
- retval = g_new (char *, env_len + 1);
- retval[env_len] = NULL;
+ retval = g_new (char *, env_len + 1);
+ retval[env_len] = NULL;
- display_name = gdk_display_get_name (display);
+ display_name = gdk_display_get_name (display);
- for (i = 0; i < env_len; i++)
- if (i == display_index)
- retval[i] = g_strconcat ("DISPLAY=", display_name, NULL);
- else
- retval[i] = g_strdup (envp[i]);
+ for (i = 0; i < env_len; i++)
+ if (i == display_index)
+ retval[i] = g_strconcat ("DISPLAY=", display_name, NULL);
+ else
+ retval[i] = g_strdup (envp[i]);
- g_assert (i == env_len);
+ g_assert (i == env_len);
- return retval;
+ return retval;
}
static gboolean
@@ -472,125 +472,125 @@ spawn_command_line_on_display_sync (GdkDisplay *display,
int *exit_status,
GError **error)
{
- char **argv = NULL;
- char **envp = NULL;
- gboolean retval;
+ char **argv = NULL;
+ char **envp = NULL;
+ gboolean retval;
- g_return_val_if_fail (command_line != NULL, FALSE);
+ g_return_val_if_fail (command_line != NULL, FALSE);
- if (! g_shell_parse_argv (command_line, NULL, &argv, error))
- {
- return FALSE;
- }
+ if (! g_shell_parse_argv (command_line, NULL, &argv, error))
+ {
+ return FALSE;
+ }
- envp = spawn_make_environment_for_display (display, NULL);
+ envp = spawn_make_environment_for_display (display, NULL);
- retval = g_spawn_sync (NULL,
- argv,
- envp,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- standard_output,
- standard_error,
- exit_status,
- error);
+ retval = g_spawn_sync (NULL,
+ argv,
+ envp,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ standard_output,
+ standard_error,
+ exit_status,
+ error);
- g_strfreev (argv);
- g_strfreev (envp);
+ g_strfreev (argv);
+ g_strfreev (envp);
- return retval;
+ return retval;
}
static GdkVisual *
get_best_visual_for_display (GdkDisplay *display)
{
- GdkScreen *screen;
- char *command;
- char *std_output;
- int exit_status;
- GError *error;
- unsigned long v;
- char c;
- GdkVisual *visual;
- gboolean res;
-
- visual = NULL;
- screen = gdk_display_get_default_screen (display);
-
- command = g_build_filename (LIBEXECDIR, "xfce4-screensaver-gl-helper", NULL);
-
- error = NULL;
- std_output = NULL;
- res = spawn_command_line_on_display_sync (display,
- command,
- &std_output,
- NULL,
- &exit_status,
- &error);
- if (! res)
- {
- gs_debug ("Could not run command '%s': %s", command, error->message);
- g_error_free (error);
- goto out;
- }
-
- if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
- {
- if (v != 0)
- {
- VisualID visual_id;
-
- visual_id = (VisualID) v;
- visual = gdk_x11_screen_lookup_visual (screen, visual_id);
-
- gs_debug ("Found best GL visual for display %s: 0x%x",
- gdk_display_get_name (display),
- (unsigned int) visual_id);
- }
- }
+ GdkScreen *screen;
+ char *command;
+ char *std_output;
+ int exit_status;
+ GError *error;
+ unsigned long v;
+ char c;
+ GdkVisual *visual;
+ gboolean res;
+
+ visual = NULL;
+ screen = gdk_display_get_default_screen (display);
+
+ command = g_build_filename (LIBEXECDIR, "xfce4-screensaver-gl-helper", NULL);
+
+ error = NULL;
+ std_output = NULL;
+ res = spawn_command_line_on_display_sync (display,
+ command,
+ &std_output,
+ NULL,
+ &exit_status,
+ &error);
+ if (! res)
+ {
+ gs_debug ("Could not run command '%s': %s", command, error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
+ {
+ if (v != 0)
+ {
+ VisualID visual_id;
+
+ visual_id = (VisualID) v;
+ visual = gdk_x11_screen_lookup_visual (screen, visual_id);
+
+ gs_debug ("Found best GL visual for display %s: 0x%x",
+ gdk_display_get_name (display),
+ (unsigned int) visual_id);
+ }
+ }
out:
- g_free (std_output);
- g_free (command);
+ g_free (std_output);
+ g_free (command);
- return g_object_ref (visual);
+ return g_object_ref (visual);
}
static void
widget_set_best_visual (GtkWidget *widget)
{
- GdkVisual *visual;
+ GdkVisual *visual;
- g_return_if_fail (widget != NULL);
+ g_return_if_fail (widget != NULL);
- visual = get_best_visual_for_display (gtk_widget_get_display (widget));
- if (visual != NULL)
- {
- gtk_widget_set_visual (widget, visual);
- g_object_unref (visual);
- }
+ visual = get_best_visual_for_display (gtk_widget_get_display (widget));
+ if (visual != NULL)
+ {
+ gtk_widget_set_visual (widget, visual);
+ g_object_unref (visual);
+ }
}
static void
gs_window_real_realize (GtkWidget *widget)
{
- GdkMonitor *monitor = GS_WINDOW (widget)->priv->monitor;
+ GdkMonitor *monitor = GS_WINDOW (widget)->priv->monitor;
- widget_set_best_visual (widget);
+ widget_set_best_visual (widget);
- if (GTK_WIDGET_CLASS (gs_window_parent_class)->realize)
- {
- GTK_WIDGET_CLASS (gs_window_parent_class)->realize (widget);
- }
+ if (GTK_WIDGET_CLASS (gs_window_parent_class)->realize)
+ {
+ GTK_WIDGET_CLASS (gs_window_parent_class)->realize (widget);
+ }
- gs_window_override_user_time (GS_WINDOW (widget));
+ gs_window_override_user_time (GS_WINDOW (widget));
- gs_window_move_resize_window (GS_WINDOW (widget), TRUE, TRUE);
+ gs_window_move_resize_window (GS_WINDOW (widget), TRUE, TRUE);
- g_signal_connect (monitor,
- "notify::geometry",
- G_CALLBACK (monitor_geometry_notify),
- widget);
+ g_signal_connect (monitor,
+ "notify::geometry",
+ G_CALLBACK (monitor_geometry_notify),
+ widget);
}
/* every so often we should raise the window in case
@@ -598,101 +598,101 @@ gs_window_real_realize (GtkWidget *widget)
static gboolean
watchdog_timer (GSWindow *window)
{
- GtkWidget *widget = GTK_WIDGET (window);
+ GtkWidget *widget = GTK_WIDGET (window);
- gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME);
+ gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME);
- return TRUE;
+ return TRUE;
}
static void
remove_watchdog_timer (GSWindow *window)
{
- if (window->priv->watchdog_timer_id != 0)
- {
- g_source_remove (window->priv->watchdog_timer_id);
- window->priv->watchdog_timer_id = 0;
- }
+ if (window->priv->watchdog_timer_id != 0)
+ {
+ g_source_remove (window->priv->watchdog_timer_id);
+ window->priv->watchdog_timer_id = 0;
+ }
}
static void
add_watchdog_timer (GSWindow *window,
glong timeout)
{
- window->priv->watchdog_timer_id = g_timeout_add (timeout,
- (GSourceFunc)watchdog_timer,
- window);
+ window->priv->watchdog_timer_id = g_timeout_add (timeout,
+ (GSourceFunc)watchdog_timer,
+ window);
}
static void
remove_popup_dialog_idle (GSWindow *window)
{
- if (window->priv->popup_dialog_idle_id != 0)
- {
- g_source_remove (window->priv->popup_dialog_idle_id);
- window->priv->popup_dialog_idle_id = 0;
- }
+ if (window->priv->popup_dialog_idle_id != 0)
+ {
+ g_source_remove (window->priv->popup_dialog_idle_id);
+ window->priv->popup_dialog_idle_id = 0;
+ }
}
static void
add_popup_dialog_idle (GSWindow *window)
{
- window->priv->popup_dialog_idle_id = g_idle_add ((GSourceFunc)popup_dialog_idle, window);
+ window->priv->popup_dialog_idle_id = g_idle_add ((GSourceFunc)popup_dialog_idle, window);
}
static gboolean
emit_deactivated_idle (GSWindow *window)
{
- g_signal_emit (window, signals [DEACTIVATED], 0);
+ g_signal_emit (window, signals [DEACTIVATED], 0);
- return FALSE;
+ return FALSE;
}
static void
add_emit_deactivated_idle (GSWindow *window)
{
- g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
+ g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
}
static void
gs_window_raise (GSWindow *window)
{
- GdkWindow *win;
+ GdkWindow *win;
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- gs_debug ("Raising screensaver window");
+ gs_debug ("Raising screensaver window");
- win = gtk_widget_get_window (GTK_WIDGET (window));
+ win = gtk_widget_get_window (GTK_WIDGET (window));
- gdk_window_raise (win);
+ gdk_window_raise (win);
}
static gboolean
x11_window_is_ours (Window window)
{
- GdkWindow *gwindow;
- gboolean ret;
+ GdkWindow *gwindow;
+ gboolean ret;
- ret = FALSE;
+ ret = FALSE;
- gwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (), window);
- if (gwindow && (window != GDK_ROOT_WINDOW ()))
- {
- ret = TRUE;
- }
+ gwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (), window);
+ if (gwindow && (window != GDK_ROOT_WINDOW ()))
+ {
+ ret = TRUE;
+ }
- return ret;
+ return ret;
}
#ifdef HAVE_SHAPE_EXT
static void
unshape_window (GSWindow *window)
{
- gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)),
- NULL,
- 0,
- 0);
+ gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)),
+ NULL,
+ 0,
+ 0);
}
#endif
@@ -700,57 +700,57 @@ static void
gs_window_xevent (GSWindow *window,
GdkXEvent *xevent)
{
- XEvent *ev;
-
- ev = xevent;
-
- /* MapNotify is used to tell us when new windows are mapped.
- ConfigureNofify is used to tell us when windows are raised. */
- switch (ev->xany.type)
- {
- case MapNotify:
- {
- XMapEvent *xme = &ev->xmap;
-
- if (! x11_window_is_ours (xme->window))
- {
- gs_window_raise (window);
- }
- else
- {
- gs_debug ("not raising our windows");
- }
-
- break;
- }
- case ConfigureNotify:
- {
- XConfigureEvent *xce = &ev->xconfigure;
-
- if (! x11_window_is_ours (xce->window))
- {
- gs_window_raise (window);
- }
- else
- {
- gs_debug ("not raising our windows");
- }
-
- break;
- }
- default:
- /* extension events */
+ XEvent *ev;
+
+ ev = xevent;
+
+ /* MapNotify is used to tell us when new windows are mapped.
+ ConfigureNofify is used to tell us when windows are raised. */
+ switch (ev->xany.type)
+ {
+ case MapNotify:
+ {
+ XMapEvent *xme = &ev->xmap;
+
+ if (! x11_window_is_ours (xme->window))
+ {
+ gs_window_raise (window);
+ }
+ else
+ {
+ gs_debug ("not raising our windows");
+ }
+
+ break;
+ }
+ case ConfigureNotify:
+ {
+ XConfigureEvent *xce = &ev->xconfigure;
+
+ if (! x11_window_is_ours (xce->window))
+ {
+ gs_window_raise (window);
+ }
+ else
+ {
+ gs_debug ("not raising our windows");
+ }
+
+ break;
+ }
+ default:
+ /* extension events */
#ifdef HAVE_SHAPE_EXT
- if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify))
- {
- /*XShapeEvent *xse = (XShapeEvent *) ev;*/
- unshape_window (window);
- gs_debug ("Window was reshaped!");
- }
+ if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify))
+ {
+ /*XShapeEvent *xse = (XShapeEvent *) ev;*/
+ unshape_window (window);
+ gs_debug ("Window was reshaped!");
+ }
#endif
- break;
- }
+ break;
+ }
}
@@ -759,49 +759,49 @@ xevent_filter (GdkXEvent *xevent,
GdkEvent *event,
GSWindow *window)
{
- gs_window_xevent (window, xevent);
+ gs_window_xevent (window, xevent);
- return GDK_FILTER_CONTINUE;
+ return GDK_FILTER_CONTINUE;
}
static void
select_popup_events (void)
{
- XWindowAttributes attr;
- unsigned long events;
- GdkDisplay *display;
+ XWindowAttributes attr;
+ unsigned long events;
+ GdkDisplay *display;
- display = gdk_display_get_default ();
+ display = gdk_display_get_default ();
- gdk_x11_display_error_trap_push (display);
+ gdk_x11_display_error_trap_push (display);
- memset (&attr, 0, sizeof (attr));
- XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (display), GDK_ROOT_WINDOW (), &attr);
+ memset (&attr, 0, sizeof (attr));
+ XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (display), GDK_ROOT_WINDOW (), &attr);
- events = SubstructureNotifyMask | attr.your_event_mask;
- XSelectInput (GDK_DISPLAY_XDISPLAY (display), GDK_ROOT_WINDOW (), events);
+ events = SubstructureNotifyMask | attr.your_event_mask;
+ XSelectInput (GDK_DISPLAY_XDISPLAY (display), GDK_ROOT_WINDOW (), events);
- gdk_x11_display_error_trap_pop_ignored (display);
+ gdk_x11_display_error_trap_pop_ignored (display);
}
static void
window_select_shape_events (GSWindow *window)
{
#ifdef HAVE_SHAPE_EXT
- unsigned long events;
- int shape_error_base;
- GdkDisplay *display;
+ unsigned long events;
+ int shape_error_base;
+ GdkDisplay *display;
- display = gtk_widget_get_display (GTK_WIDGET(window));
+ display = gtk_widget_get_display (GTK_WIDGET(window));
- gdk_x11_display_error_trap_push (display);
+ gdk_x11_display_error_trap_push (display);
- if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &window->priv->shape_event_base, &shape_error_base)) {
- events = ShapeNotifyMask;
- XShapeSelectInput (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))), events);
- }
+ if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display), &window->priv->shape_event_base, &shape_error_base)) {
+ events = ShapeNotifyMask;
+ XShapeSelectInput (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))), events);
+ }
- gdk_x11_display_error_trap_pop_ignored (display);
+ gdk_x11_display_error_trap_pop_ignored (display);
#endif
}
@@ -809,50 +809,50 @@ static gboolean
gs_window_real_draw (GtkWidget *widget,
cairo_t *cr)
{
- GSWindow *window = GS_WINDOW (widget);
- cairo_surface_t *bg_surface = window->priv->background_surface;
+ GSWindow *window = GS_WINDOW (widget);
+ cairo_surface_t *bg_surface = window->priv->background_surface;
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- if (bg_surface != NULL)
- {
- cairo_set_source_surface (cr, bg_surface, 0, 0);
- }
- else
- {
- cairo_set_source_rgb (cr, 0, 0, 0);
- }
- cairo_paint (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ if (bg_surface != NULL)
+ {
+ cairo_set_source_surface (cr, bg_surface, 0, 0);
+ }
+ else
+ {
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ }
+ cairo_paint (cr);
- return FALSE;
+ return FALSE;
}
static void
gs_window_real_show (GtkWidget *widget)
{
- GSWindow *window;
+ GSWindow *window;
- if (GTK_WIDGET_CLASS (gs_window_parent_class)->show)
- {
- GTK_WIDGET_CLASS (gs_window_parent_class)->show (widget);
- }
+ if (GTK_WIDGET_CLASS (gs_window_parent_class)->show)
+ {
+ GTK_WIDGET_CLASS (gs_window_parent_class)->show (widget);
+ }
- gs_window_clear (GS_WINDOW (widget));
+ gs_window_clear (GS_WINDOW (widget));
- set_invisible_cursor (gtk_widget_get_window (widget), TRUE);
+ set_invisible_cursor (gtk_widget_get_window (widget), TRUE);
- window = GS_WINDOW (widget);
- if (window->priv->timer)
- {
- g_timer_destroy (window->priv->timer);
- }
- window->priv->timer = g_timer_new ();
+ window = GS_WINDOW (widget);
+ if (window->priv->timer)
+ {
+ g_timer_destroy (window->priv->timer);
+ }
+ window->priv->timer = g_timer_new ();
- remove_watchdog_timer (window);
- add_watchdog_timer (window, 30000);
+ remove_watchdog_timer (window);
+ add_watchdog_timer (window, 30000);
- select_popup_events ();
- window_select_shape_events (window);
- gdk_window_add_filter (NULL, (GdkFilterFunc)xevent_filter, window);
+ select_popup_events ();
+ window_select_shape_events (window);
+ gdk_window_add_filter (NULL, (GdkFilterFunc)xevent_filter, window);
}
static void
@@ -861,67 +861,67 @@ set_info_text_and_icon (GSWindow *window,
const char *primary_text,
const char *secondary_text)
{
- GtkWidget *content_area;
- GtkWidget *hbox_content;
- GtkWidget *image;
- GtkWidget *vbox;
- gchar *primary_markup;
- gchar *secondary_markup;
- GtkWidget *primary_label;
- GtkWidget *secondary_label;
-
- hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
- gtk_widget_show (hbox_content);
-
- image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0);
- gtk_widget_set_valign (image, GTK_ALIGN_START);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox_content), vbox, FALSE, FALSE, 0);
-
- primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
- primary_label = gtk_label_new (primary_markup);
- g_free (primary_markup);
- gtk_widget_show (primary_label);
- gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
- gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
- gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
-
- if (secondary_text != NULL)
- {
- secondary_markup = g_strdup_printf ("<small>%s</small>",
- secondary_text);
- secondary_label = gtk_label_new (secondary_markup);
- g_free (secondary_markup);
- gtk_widget_show (secondary_label);
- gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
- gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
- gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
- }
-
- /* remove old content */
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (window->priv->info_bar));
- if (window->priv->info_content != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (content_area), window->priv->info_content);
- }
- gtk_box_pack_start (GTK_BOX (content_area),
- hbox_content,
- TRUE, FALSE, 0);
- window->priv->info_content = hbox_content;
+ GtkWidget *content_area;
+ GtkWidget *hbox_content;
+ GtkWidget *image;
+ GtkWidget *vbox;
+ gchar *primary_markup;
+ gchar *secondary_markup;
+ GtkWidget *primary_label;
+ GtkWidget *secondary_label;
+
+ hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
+ gtk_widget_show (hbox_content);
+
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
+ gtk_widget_show (image);
+ gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0);
+ gtk_widget_set_valign (image, GTK_ALIGN_START);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox_content), vbox, FALSE, FALSE, 0);
+
+ primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
+ primary_label = gtk_label_new (primary_markup);
+ g_free (primary_markup);
+ gtk_widget_show (primary_label);
+ gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
+ gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
+ gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
+
+ if (secondary_text != NULL)
+ {
+ secondary_markup = g_strdup_printf ("<small>%s</small>",
+ secondary_text);
+ secondary_label = gtk_label_new (secondary_markup);
+ g_free (secondary_markup);
+ gtk_widget_show (secondary_label);
+ gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
+ gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
+ gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
+ }
+
+ /* remove old content */
+ content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (window->priv->info_bar));
+ if (window->priv->info_content != NULL)
+ {
+ gtk_container_remove (GTK_CONTAINER (content_area), window->priv->info_content);
+ }
+ gtk_box_pack_start (GTK_BOX (content_area),
+ hbox_content,
+ TRUE, FALSE, 0);
+ window->priv->info_content = hbox_content;
}
static gboolean
info_bar_timeout (GSWindow *window)
{
- window->priv->info_bar_timer_id = 0;
- gtk_widget_hide (window->priv->info_bar);
- return FALSE;
+ window->priv->info_bar_timer_id = 0;
+ gtk_widget_hide (window->priv->info_bar);
+ return FALSE;
}
void
@@ -930,73 +930,73 @@ gs_window_show_message (GSWindow *window,
const char *body,
const char *icon)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- set_info_text_and_icon (window,
- icon,
- summary,
- body);
- gtk_widget_show (window->priv->info_bar);
+ set_info_text_and_icon (window,
+ icon,
+ summary,
+ body);
+ gtk_widget_show (window->priv->info_bar);
- if (window->priv->info_bar_timer_id > 0)
- {
- g_source_remove (window->priv->info_bar_timer_id);
- }
+ if (window->priv->info_bar_timer_id > 0)
+ {
+ g_source_remove (window->priv->info_bar_timer_id);
+ }
- window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS,
- (GSourceFunc)info_bar_timeout,
- window);
+ window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS,
+ (GSourceFunc)info_bar_timeout,
+ window);
}
void
gs_window_show (GSWindow *window)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- gtk_widget_show (GTK_WIDGET (window));
+ gtk_widget_show (GTK_WIDGET (window));
}
static void
gs_window_real_hide (GtkWidget *widget)
{
- GSWindow *window;
+ GSWindow *window;
- window = GS_WINDOW (widget);
+ window = GS_WINDOW (widget);
- gdk_window_remove_filter (NULL, (GdkFilterFunc)xevent_filter, window);
+ gdk_window_remove_filter (NULL, (GdkFilterFunc)xevent_filter, window);
- remove_watchdog_timer (window);
+ remove_watchdog_timer (window);
- if (GTK_WIDGET_CLASS (gs_window_parent_class)->hide)
- {
- GTK_WIDGET_CLASS (gs_window_parent_class)->hide (widget);
- }
+ if (GTK_WIDGET_CLASS (gs_window_parent_class)->hide)
+ {
+ GTK_WIDGET_CLASS (gs_window_parent_class)->hide (widget);
+ }
}
void
gs_window_destroy (GSWindow *window)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- gs_window_cancel_unlock_request (window);
+ gs_window_cancel_unlock_request (window);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_widget_destroy (GTK_WIDGET (window));
}
GdkWindow *
gs_window_get_gdk_window (GSWindow *window)
{
- g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
- return gtk_widget_get_window (GTK_WIDGET (window));
+ return gtk_widget_get_window (GTK_WIDGET (window));
}
GtkWidget *
gs_window_get_drawing_area (GSWindow *window)
{
- g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
- return window->priv->drawing_area;
+ return window->priv->drawing_area;
}
/* just for debugging */
@@ -1005,47 +1005,47 @@ error_watch (GIOChannel *source,
GIOCondition condition,
gpointer data)
{
- gboolean finished = FALSE;
-
- if (condition & G_IO_IN)
- {
- GIOStatus status;
- GError *error = NULL;
- char *line;
-
- line = NULL;
- status = g_io_channel_read_line (source, &line, NULL, NULL, &error);
-
- switch (status)
- {
- case G_IO_STATUS_NORMAL:
- gs_debug ("command error output: %s", line);
- break;
- case G_IO_STATUS_EOF:
- finished = TRUE;
- break;
- case G_IO_STATUS_ERROR:
- finished = TRUE;
- gs_debug ("Error reading from child: %s\n", error->message);
- g_error_free (error);
- return FALSE;
- case G_IO_STATUS_AGAIN:
- default:
- break;
- }
- g_free (line);
- }
- else if (condition & G_IO_HUP)
- {
- finished = TRUE;
- }
-
- if (finished)
- {
- return FALSE;
- }
-
- return TRUE;
+ gboolean finished = FALSE;
+
+ if (condition & G_IO_IN)
+ {
+ GIOStatus status;
+ GError *error = NULL;
+ char *line;
+
+ line = NULL;
+ status = g_io_channel_read_line (source, &line, NULL, NULL, &error);
+
+ switch (status)
+ {
+ case G_IO_STATUS_NORMAL:
+ gs_debug ("command error output: %s", line);
+ break;
+ case G_IO_STATUS_EOF:
+ finished = TRUE;
+ break;
+ case G_IO_STATUS_ERROR:
+ finished = TRUE;
+ gs_debug ("Error reading from child: %s\n", error->message);
+ g_error_free (error);
+ return FALSE;
+ case G_IO_STATUS_AGAIN:
+ default:
+ break;
+ }
+ g_free (line);
+ }
+ else if (condition & G_IO_HUP)
+ {
+ finished = TRUE;
+ }
+
+ if (finished)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
@@ -1056,274 +1056,274 @@ spawn_on_window (GSWindow *window,
gpointer user_data,
gint *watch_id)
{
- int argc;
- char **argv;
- char **envp;
- GError *error;
- gboolean result;
- GIOChannel *channel;
- int standard_output;
- int standard_error;
- int child_pid;
- int id;
-
- error = NULL;
- if (! g_shell_parse_argv (command, &argc, &argv, &error))
- {
- gs_debug ("Could not parse command: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- error = NULL;
- envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)), NULL);
- result = g_spawn_async_with_pipes (NULL,
- argv,
- envp,
- G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- &child_pid,
- NULL,
- &standard_output,
- &standard_error,
- &error);
-
- if (! result)
- {
- gs_debug ("Could not start command '%s': %s", command, error->message);
- g_error_free (error);
- g_strfreev (argv);
- return FALSE;
- }
-
- if (pid != NULL)
- {
- *pid = child_pid;
- }
- else
- {
- g_spawn_close_pid (child_pid);
- }
-
- /* output channel */
- channel = g_io_channel_unix_new (standard_output);
- g_io_channel_set_close_on_unref (channel, TRUE);
- g_io_channel_set_flags (channel,
- g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
- NULL);
- id = g_io_add_watch (channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- watch_func,
- user_data);
- if (watch_id != NULL)
- {
- *watch_id = id;
- }
- g_io_channel_unref (channel);
-
- /* error channel */
- channel = g_io_channel_unix_new (standard_error);
- g_io_channel_set_close_on_unref (channel, TRUE);
- g_io_channel_set_flags (channel,
- g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
- NULL);
- id = g_io_add_watch (channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- error_watch,
- NULL);
- g_io_channel_unref (channel);
-
- g_strfreev (argv);
- g_strfreev (envp);
-
- return result;
+ int argc;
+ char **argv;
+ char **envp;
+ GError *error;
+ gboolean result;
+ GIOChannel *channel;
+ int standard_output;
+ int standard_error;
+ int child_pid;
+ int id;
+
+ error = NULL;
+ if (! g_shell_parse_argv (command, &argc, &argv, &error))
+ {
+ gs_debug ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ error = NULL;
+ envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)), NULL);
+ result = g_spawn_async_with_pipes (NULL,
+ argv,
+ envp,
+ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ &child_pid,
+ NULL,
+ &standard_output,
+ &standard_error,
+ &error);
+
+ if (! result)
+ {
+ gs_debug ("Could not start command '%s': %s", command, error->message);
+ g_error_free (error);
+ g_strfreev (argv);
+ return FALSE;
+ }
+
+ if (pid != NULL)
+ {
+ *pid = child_pid;
+ }
+ else
+ {
+ g_spawn_close_pid (child_pid);
+ }
+
+ /* output channel */
+ channel = g_io_channel_unix_new (standard_output);
+ g_io_channel_set_close_on_unref (channel, TRUE);
+ g_io_channel_set_flags (channel,
+ g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
+ NULL);
+ id = g_io_add_watch (channel,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ watch_func,
+ user_data);
+ if (watch_id != NULL)
+ {
+ *watch_id = id;
+ }
+ g_io_channel_unref (channel);
+
+ /* error channel */
+ channel = g_io_channel_unix_new (standard_error);
+ g_io_channel_set_close_on_unref (channel, TRUE);
+ g_io_channel_set_flags (channel,
+ g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
+ NULL);
+ id = g_io_add_watch (channel,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ error_watch,
+ NULL);
+ g_io_channel_unref (channel);
+
+ g_strfreev (argv);
+ g_strfreev (envp);
+
+ return result;
}
static void
lock_plug_added (GtkWidget *widget,
GSWindow *window)
{
- gtk_widget_show (widget);
+ gtk_widget_show (widget);
}
static gboolean
lock_plug_removed (GtkWidget *widget,
GSWindow *window)
{
- gtk_widget_hide (widget);
- gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->lock_box));
- window->priv->lock_box = NULL;
+ gtk_widget_hide (widget);
+ gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->lock_box));
+ window->priv->lock_box = NULL;
- return TRUE;
+ return TRUE;
}
static void
keyboard_plug_added (GtkWidget *widget,
GSWindow *window)
{
- gtk_widget_show (widget);
+ gtk_widget_show (widget);
}
static gboolean
keyboard_plug_removed (GtkWidget *widget,
GSWindow *window)
{
- gtk_widget_hide (widget);
- gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->keyboard_socket));
+ gtk_widget_hide (widget);
+ gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->keyboard_socket));
- return TRUE;
+ return TRUE;
}
static void
keyboard_socket_destroyed (GtkWidget *widget,
GSWindow *window)
{
- g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window);
- g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window);
- g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window);
+ g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window);
+ g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window);
+ g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window);
- window->priv->keyboard_socket = NULL;
+ window->priv->keyboard_socket = NULL;
}
static void
forward_key_events (GSWindow *window)
{
- window->priv->key_events = g_list_reverse (window->priv->key_events);
+ window->priv->key_events = g_list_reverse (window->priv->key_events);
- while (window->priv->key_events != NULL)
- {
- GdkEventKey *event = window->priv->key_events->data;
+ while (window->priv->key_events != NULL)
+ {
+ GdkEventKey *event = window->priv->key_events->data;
- gtk_window_propagate_key_event (GTK_WINDOW (window), event);
+ gtk_window_propagate_key_event (GTK_WINDOW (window), event);
- gdk_event_free ((GdkEvent *)event);
- window->priv->key_events = g_list_delete_link (window->priv->key_events,
- window->priv->key_events);
- }
+ gdk_event_free ((GdkEvent *)event);
+ window->priv->key_events = g_list_delete_link (window->priv->key_events,
+ window->priv->key_events);
+ }
}
static void
remove_key_events (GSWindow *window)
{
- window->priv->key_events = g_list_reverse (window->priv->key_events);
+ window->priv->key_events = g_list_reverse (window->priv->key_events);
- while (window->priv->key_events)
- {
- GdkEventKey *event = window->priv->key_events->data;
+ while (window->priv->key_events)
+ {
+ GdkEventKey *event = window->priv->key_events->data;
- gdk_event_free ((GdkEvent *)event);
- window->priv->key_events = g_list_delete_link (window->priv->key_events,
- window->priv->key_events);
- }
+ gdk_event_free ((GdkEvent *)event);
+ window->priv->key_events = g_list_delete_link (window->priv->key_events,
+ window->priv->key_events);
+ }
}
static void
lock_socket_show (GtkWidget *widget,
GSWindow *window)
{
- gtk_widget_child_focus (window->priv->lock_socket, GTK_DIR_TAB_FORWARD);
+ gtk_widget_child_focus (window->priv->lock_socket, GTK_DIR_TAB_FORWARD);
- /* send queued events to the dialog */
- forward_key_events (window);
+ /* send queued events to the dialog */
+ forward_key_events (window);
}
static void
lock_socket_destroyed (GtkWidget *widget,
GSWindow *window)
{
- g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window);
- g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window);
- g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window);
- g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window);
+ g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window);
+ g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window);
+ g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window);
+ g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window);
- window->priv->lock_socket = NULL;
+ window->priv->lock_socket = NULL;
}
static void
create_keyboard_socket (GSWindow *window,
guint32 id)
{
- int height;
+ int height;
- height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (GTK_WIDGET (window))))) / 4;
+ height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (GTK_WIDGET (window))))) / 4;
- window->priv->keyboard_socket = gtk_socket_new ();
- gtk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
+ window->priv->keyboard_socket = gtk_socket_new ();
+ gtk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
- g_signal_connect (window->priv->keyboard_socket, "destroy",
- G_CALLBACK (keyboard_socket_destroyed), window);
- g_signal_connect (window->priv->keyboard_socket, "plug_added",
- G_CALLBACK (keyboard_plug_added), window);
- g_signal_connect (window->priv->keyboard_socket, "plug_removed",
- G_CALLBACK (keyboard_plug_removed), window);
- gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->keyboard_socket, FALSE, FALSE, 0);
- gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket), id);
+ g_signal_connect (window->priv->keyboard_socket, "destroy",
+ G_CALLBACK (keyboard_socket_destroyed), window);
+ g_signal_connect (window->priv->keyboard_socket, "plug_added",
+ G_CALLBACK (keyboard_plug_added), window);
+ g_signal_connect (window->priv->keyboard_socket, "plug_removed",
+ G_CALLBACK (keyboard_plug_removed), window);
+ gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->keyboard_socket, FALSE, FALSE, 0);
+ gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket), id);
}
/* adapted from gspawn.c */
static int
wait_on_child (int pid)
{
- int status;
+ int status;
wait_again:
- if (waitpid (pid, &status, 0) < 0)
- {
- if (errno == EINTR)
- {
- goto wait_again;
- }
- else if (errno == ECHILD)
- {
- ; /* do nothing, child already reaped */
- }
- else
- {
- gs_debug ("waitpid () should not fail in 'GSWindow'");
- }
- }
-
- return status;
+ if (waitpid (pid, &status, 0) < 0)
+ {
+ if (errno == EINTR)
+ {
+ goto wait_again;
+ }
+ else if (errno == ECHILD)
+ {
+ ; /* do nothing, child already reaped */
+ }
+ else
+ {
+ gs_debug ("waitpid () should not fail in 'GSWindow'");
+ }
+ }
+
+ return status;
}
static void
kill_keyboard_command (GSWindow *window)
{
- if (window->priv->keyboard_pid > 0)
- {
- signal_pid (window->priv->keyboard_pid, SIGTERM);
- }
+ if (window->priv->keyboard_pid > 0)
+ {
+ signal_pid (window->priv->keyboard_pid, SIGTERM);
+ }
}
static void
kill_dialog_command (GSWindow *window)
{
- /* If a dialog is up we need to signal it
- and wait on it */
- if (window->priv->lock_pid > 0)
- {
- signal_pid (window->priv->lock_pid, SIGTERM);
- }
+ /* If a dialog is up we need to signal it
+ and wait on it */
+ if (window->priv->lock_pid > 0)
+ {
+ signal_pid (window->priv->lock_pid, SIGTERM);
+ }
}
static void
keyboard_command_finish (GSWindow *window)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- /* send a signal just in case */
- kill_keyboard_command (window);
+ /* send a signal just in case */
+ kill_keyboard_command (window);
- gs_debug ("Keyboard finished");
+ gs_debug ("Keyboard finished");
- if (window->priv->keyboard_pid > 0)
- {
- wait_on_child (window->priv->keyboard_pid);
+ if (window->priv->keyboard_pid > 0)
+ {
+ wait_on_child (window->priv->keyboard_pid);
- g_spawn_close_pid (window->priv->keyboard_pid);
- window->priv->keyboard_pid = 0;
- }
+ g_spawn_close_pid (window->priv->keyboard_pid);
+ window->priv->keyboard_pid = 0;
+ }
}
static gboolean
@@ -1331,238 +1331,238 @@ keyboard_command_watch (GIOChannel *source,
GIOCondition condition,
GSWindow *window)
{
- gboolean finished = FALSE;
-
- g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
-
- if (condition & G_IO_IN)
- {
- GIOStatus status;
- GError *error = NULL;
- char *line;
-
- line = NULL;
- status = g_io_channel_read_line (source, &line, NULL, NULL, &error);
-
- switch (status)
- {
- case G_IO_STATUS_NORMAL:
- {
- guint32 id;
- char c;
- gs_debug ("keyboard command output: %s", line);
- if (1 == sscanf (line, " %" G_GUINT32_FORMAT " %c", &id, &c))
- {
- create_keyboard_socket (window, id);
- }
- }
- break;
- case G_IO_STATUS_EOF:
- finished = TRUE;
- break;
- case G_IO_STATUS_ERROR:
- finished = TRUE;
- gs_debug ("Error reading from child: %s\n", error->message);
- g_error_free (error);
- return FALSE;
- case G_IO_STATUS_AGAIN:
- default:
- break;
- }
-
- g_free (line);
- }
- else if (condition & G_IO_HUP)
- {
- finished = TRUE;
- }
-
- if (finished)
- {
- window->priv->keyboard_watch_id = 0;
- keyboard_command_finish (window);
- return FALSE;
- }
-
- return TRUE;
+ gboolean finished = FALSE;
+
+ g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
+
+ if (condition & G_IO_IN)
+ {
+ GIOStatus status;
+ GError *error = NULL;
+ char *line;
+
+ line = NULL;
+ status = g_io_channel_read_line (source, &line, NULL, NULL, &error);
+
+ switch (status)
+ {
+ case G_IO_STATUS_NORMAL:
+ {
+ guint32 id;
+ char c;
+ gs_debug ("keyboard command output: %s", line);
+ if (1 == sscanf (line, " %" G_GUINT32_FORMAT " %c", &id, &c))
+ {
+ create_keyboard_socket (window, id);
+ }
+ }
+ break;
+ case G_IO_STATUS_EOF:
+ finished = TRUE;
+ break;
+ case G_IO_STATUS_ERROR:
+ finished = TRUE;
+ gs_debug ("Error reading from child: %s\n", error->message);
+ g_error_free (error);
+ return FALSE;
+ case G_IO_STATUS_AGAIN:
+ default:
+ break;
+ }
+
+ g_free (line);
+ }
+ else if (condition & G_IO_HUP)
+ {
+ finished = TRUE;
+ }
+
+ if (finished)
+ {
+ window->priv->keyboard_watch_id = 0;
+ keyboard_command_finish (window);
+ return FALSE;
+ }
+
+ return TRUE;
}
static void
embed_keyboard (GSWindow *window)
{
- gboolean res;
+ gboolean res;
- if (! window->priv->keyboard_enabled
- || window->priv->keyboard_command == NULL)
- return;
+ if (! window->priv->keyboard_enabled
+ || window->priv->keyboard_command == NULL)
+ return;
- gs_debug ("Adding embedded keyboard widget");
+ gs_debug ("Adding embedded keyboard widget");
- /* FIXME: verify command is safe */
+ /* FIXME: verify command is safe */
- gs_debug ("Running command: %s", window->priv->keyboard_command);
+ gs_debug ("Running command: %s", window->priv->keyboard_command);
- res = spawn_on_window (window,
- window->priv->keyboard_command,
- &window->priv->keyboard_pid,
- (GIOFunc)keyboard_command_watch,
- window,
- &window->priv->keyboard_watch_id);
- if (! res)
- {
- gs_debug ("Could not start command: %s", window->priv->keyboard_command);
- }
+ res = spawn_on_window (window,
+ window->priv->keyboard_command,
+ &window->priv->keyboard_pid,
+ (GIOFunc)keyboard_command_watch,
+ window,
+ &window->priv->keyboard_watch_id);
+ if (! res)
+ {
+ gs_debug ("Could not start command: %s", window->priv->keyboard_command);
+ }
}
static void
create_lock_socket (GSWindow *window,
guint32 id)
{
- window->priv->lock_socket = gtk_socket_new ();
- window->priv->lock_box = gtk_grid_new ();
- gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box),
- GTK_ALIGN_CENTER);
- gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box),
- GTK_ALIGN_CENTER);
- gtk_widget_show (window->priv->lock_box);
- gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->lock_box, TRUE, TRUE, 0);
+ window->priv->lock_socket = gtk_socket_new ();
+ window->priv->lock_box = gtk_grid_new ();
+ gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box),
+ GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box),
+ GTK_ALIGN_CENTER);
+ gtk_widget_show (window->priv->lock_box);
+ gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->lock_box, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (window->priv->lock_box), window->priv->lock_socket);
+ gtk_container_add (GTK_CONTAINER (window->priv->lock_box), window->priv->lock_socket);
- g_signal_connect (window->priv->lock_socket, "show",
- G_CALLBACK (lock_socket_show), window);
- g_signal_connect (window->priv->lock_socket, "destroy",
- G_CALLBACK (lock_socket_destroyed), window);
- g_signal_connect (window->priv->lock_socket, "plug_added",
- G_CALLBACK (lock_plug_added), window);
- g_signal_connect (window->priv->lock_socket, "plug_removed",
- G_CALLBACK (lock_plug_removed), window);
+ g_signal_connect (window->priv->lock_socket, "show",
+ G_CALLBACK (lock_socket_show), window);
+ g_signal_connect (window->priv->lock_socket, "destroy",
+ G_CALLBACK (lock_socket_destroyed), window);
+ g_signal_connect (window->priv->lock_socket, "plug_added",
+ G_CALLBACK (lock_plug_added), window);
+ g_signal_connect (window->priv->lock_socket, "plug_removed",
+ G_CALLBACK (lock_plug_removed), window);
- gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket), id);
+ gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket), id);
- if (window->priv->keyboard_enabled)
- {
- embed_keyboard (window);
- }
+ if (window->priv->keyboard_enabled)
+ {
+ embed_keyboard (window);
+ }
}
static void
gs_window_dialog_finish (GSWindow *window)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- gs_debug ("Dialog finished");
+ gs_debug ("Dialog finished");
- /* make sure we finish the keyboard thing too */
- keyboard_command_finish (window);
+ /* make sure we finish the keyboard thing too */
+ keyboard_command_finish (window);
- /* send a signal just in case */
- kill_dialog_command (window);
+ /* send a signal just in case */
+ kill_dialog_command (window);
- if (window->priv->lock_pid > 0)
- {
- wait_on_child (window->priv->lock_pid);
+ if (window->priv->lock_pid > 0)
+ {
+ wait_on_child (window->priv->lock_pid);
- g_spawn_close_pid (window->priv->lock_pid);
- window->priv->lock_pid = 0;
- }
+ g_spawn_close_pid (window->priv->lock_pid);
+ window->priv->lock_pid = 0;
+ }
- /* remove events for the case were we failed to show socket */
- remove_key_events (window);
+ /* remove events for the case were we failed to show socket */
+ remove_key_events (window);
}
static void
maybe_kill_dialog (GSWindow *window)
{
- if (!window->priv->dialog_shake_in_progress
- && window->priv->dialog_quit_requested
- && window->priv->lock_pid > 0)
- {
- kill (window->priv->lock_pid, SIGTERM);
- }
+ if (!window->priv->dialog_shake_in_progress
+ && window->priv->dialog_quit_requested
+ && window->priv->lock_pid > 0)
+ {
+ kill (window->priv->lock_pid, SIGTERM);
+ }
}
/* very rudimentary animation for indicating an auth failure */
static void
shake_dialog (GSWindow *window)
{
- int i;
- guint start, end;
+ int i;
+ guint start, end;
- window->priv->dialog_shake_in_progress = TRUE;
+ window->priv->dialog_shake_in_progress = TRUE;
- for (i = 0; i < 8; i++)
- {
- if (i % 2 == 0)
- {
- start = 30;
- end = 0;
- }
- else
- {
- start = 0;
- end = 30;
- }
+ for (i = 0; i < 8; i++)
+ {
+ if (i % 2 == 0)
+ {
+ start = 30;
+ end = 0;
+ }
+ else
+ {
+ start = 0;
+ end = 30;
+ }
- if (! window->priv->lock_box)
- {
- break;
- }
+ if (! window->priv->lock_box)
+ {
+ break;
+ }
- gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box),
- start);
- gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box),
- end);
+ gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box),
+ start);
+ gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box),
+ end);
- while (gtk_events_pending ())
- {
- gtk_main_iteration ();
- }
+ while (gtk_events_pending ())
+ {
+ gtk_main_iteration ();
+ }
- g_usleep (10000);
- }
+ g_usleep (10000);
+ }
- window->priv->dialog_shake_in_progress = FALSE;
- maybe_kill_dialog (window);
+ window->priv->dialog_shake_in_progress = FALSE;
+ maybe_kill_dialog (window);
}
static void
window_set_dialog_up (GSWindow *window,
gboolean dialog_up)
{
- if (window->priv->dialog_up == dialog_up)
- {
- return;
- }
+ if (window->priv->dialog_up == dialog_up)
+ {
+ return;
+ }
- window->priv->dialog_up = dialog_up;
- g_object_notify (G_OBJECT (window), "dialog-up");
+ window->priv->dialog_up = dialog_up;
+ g_object_notify (G_OBJECT (window), "dialog-up");
}
static void
popdown_dialog (GSWindow *window)
{
- gs_window_dialog_finish (window);
+ gs_window_dialog_finish (window);
- gtk_widget_show (window->priv->drawing_area);
+ gtk_widget_show (window->priv->drawing_area);
- gs_window_clear (window);
- set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)), TRUE);
+ gs_window_clear (window);
+ set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)), TRUE);
- window_set_dialog_up (window, FALSE);
+ window_set_dialog_up (window, FALSE);
- /* reset the pointer positions */
- window->priv->last_x = -1;
- window->priv->last_y = -1;
+ /* reset the pointer positions */
+ window->priv->last_x = -1;
+ window->priv->last_y = -1;
- if (window->priv->lock_box != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->lock_box));
- window->priv->lock_box = NULL;
- }
+ if (window->priv->lock_box != NULL)
+ {
+ gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->lock_box));
+ window->priv->lock_box = NULL;
+ }
- remove_popup_dialog_idle (window);
- remove_command_watches (window);
+ remove_popup_dialog_idle (window);
+ remove_command_watches (window);
}
static gboolean
@@ -1570,443 +1570,442 @@ lock_command_watch (GIOChannel *source,
GIOCondition condition,
GSWindow *window)
{
- gboolean finished = FALSE;
-
- g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
-
- if (condition & G_IO_IN)
- {
- GIOStatus status;
- GError *error = NULL;
- char *line;
-
- line = NULL;
- status = g_io_channel_read_line (source, &line, NULL, NULL, &error);
-
- switch (status)
- {
- case G_IO_STATUS_NORMAL:
- gs_debug ("command output: %s", line);
-
- if (strstr (line, "WINDOW ID=") != NULL)
- {
- guint32 id;
- char c;
- if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT " %c", &id, &c))
- {
- create_lock_socket (window, id);
- }
- }
- else if (strstr (line, "NOTICE=") != NULL)
- {
- if (strstr (line, "NOTICE=AUTH FAILED") != NULL)
- {
- shake_dialog (window);
- }
- }
- else if (strstr (line, "RESPONSE=") != NULL)
- {
- if (strstr (line, "RESPONSE=OK") != NULL)
- {
- gs_debug ("Got OK response");
- window->priv->dialog_response = DIALOG_RESPONSE_OK;
- }
- else
- {
- gs_debug ("Got CANCEL response");
- window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
- }
- finished = TRUE;
- }
- else if (strstr (line, "REQUEST QUIT") != NULL)
- {
- gs_debug ("Got request for quit");
- window->priv->dialog_quit_requested = TRUE;
- maybe_kill_dialog (window);
- }
- break;
- case G_IO_STATUS_EOF:
- finished = TRUE;
- break;
- case G_IO_STATUS_ERROR:
- finished = TRUE;
- gs_debug ("Error reading from child: %s\n", error->message);
- g_error_free (error);
- return FALSE;
- case G_IO_STATUS_AGAIN:
- default:
- break;
- }
-
- g_free (line);
- }
- else if (condition & G_IO_HUP)
- {
- finished = TRUE;
- }
-
- if (finished)
- {
- popdown_dialog (window);
-
- if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
- {
- add_emit_deactivated_idle (window);
- }
-
- window->priv->lock_watch_id = 0;
-
- return FALSE;
- }
-
- return TRUE;
+ gboolean finished = FALSE;
+
+ g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
+
+ if (condition & G_IO_IN)
+ {
+ GIOStatus status;
+ GError *error = NULL;
+ char *line;
+
+ line = NULL;
+ status = g_io_channel_read_line (source, &line, NULL, NULL, &error);
+
+ switch (status)
+ {
+ case G_IO_STATUS_NORMAL:
+ gs_debug ("command output: %s", line);
+
+ if (strstr (line, "WINDOW ID=") != NULL)
+ {
+ guint32 id;
+ char c;
+ if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT " %c", &id, &c))
+ {
+ create_lock_socket (window, id);
+ }
+ }
+ else if (strstr (line, "NOTICE=") != NULL)
+ {
+ if (strstr (line, "NOTICE=AUTH FAILED") != NULL)
+ {
+ shake_dialog (window);
+ }
+ }
+ else if (strstr (line, "RESPONSE=") != NULL)
+ {
+ if (strstr (line, "RESPONSE=OK") != NULL)
+ {
+ gs_debug ("Got OK response");
+ window->priv->dialog_response = DIALOG_RESPONSE_OK;
+ }
+ else
+ {
+ gs_debug ("Got CANCEL response");
+ window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
+ }
+ finished = TRUE;
+ }
+ else if (strstr (line, "REQUEST QUIT") != NULL)
+ {
+ gs_debug ("Got request for quit");
+ window->priv->dialog_quit_requested = TRUE;
+ maybe_kill_dialog (window);
+ }
+ break;
+ case G_IO_STATUS_EOF:
+ finished = TRUE;
+ break;
+ case G_IO_STATUS_ERROR:
+ finished = TRUE;
+ gs_debug ("Error reading from child: %s\n", error->message);
+ g_error_free (error);
+ return FALSE;
+ case G_IO_STATUS_AGAIN:
+ default:
+ break;
+ }
+
+ g_free (line);
+ }
+ else if (condition & G_IO_HUP)
+ {
+ finished = TRUE;
+ }
+
+ if (finished)
+ {
+ popdown_dialog (window);
+
+ if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
+ {
+ add_emit_deactivated_idle (window);
+ }
+
+ window->priv->lock_watch_id = 0;
+
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
is_logout_enabled (GSWindow *window)
{
- double elapsed;
+ double elapsed;
- if (! window->priv->logout_enabled)
- {
- return FALSE;
- }
+ if (! window->priv->logout_enabled)
+ {
+ return FALSE;
+ }
- if (! window->priv->logout_command)
- {
- return FALSE;
- }
+ if (! window->priv->logout_command)
+ {
+ return FALSE;
+ }
- elapsed = g_timer_elapsed (window->priv->timer, NULL);
+ elapsed = g_timer_elapsed (window->priv->timer, NULL);
- if (window->priv->logout_timeout < (elapsed * 1000))
- {
- return TRUE;
- }
+ if (window->priv->logout_timeout < (elapsed * 1000))
+ {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
is_user_switch_enabled (GSWindow *window)
{
- return window->priv->user_switch_enabled;
+ return window->priv->user_switch_enabled;
}
static gint
get_monitor_index (GSWindow *window)
{
- GdkDisplay *display = gs_window_get_display (window);
- GdkMonitor *monitor;
- gint idx;
+ GdkDisplay *display = gs_window_get_display (window);
+ GdkMonitor *monitor;
+ gint idx;
- for (idx = 0; idx < gdk_display_get_n_monitors (display); idx++) {
- monitor = gdk_display_get_monitor (display, idx);
- if (g_strcmp0 (gdk_monitor_get_model (monitor), gdk_monitor_get_model (window->priv->monitor)) == 0) {
- return idx;
- }
- }
+ for (idx = 0; idx < gdk_display_get_n_monitors (display); idx++) {
+ monitor = gdk_display_get_monitor (display, idx);
+ if (g_strcmp0 (gdk_monitor_get_model (monitor), gdk_monitor_get_model (window->priv->monitor)) == 0) {
+ return idx;
+ }
+ }
- return 0;
+ return 0;
}
static void
popup_dialog (GSWindow *window)
{
- gboolean result;
- char *tmp;
- GString *command;
+ gboolean result;
+ char *tmp;
+ GString *command;
- gs_debug ("Popping up dialog");
+ gs_debug ("Popping up dialog");
- tmp = g_build_filename (LIBEXECDIR, "xfce4-screensaver-dialog", NULL);
- command = g_string_new (tmp);
- g_free (tmp);
+ tmp = g_build_filename (LIBEXECDIR, "xfce4-screensaver-dialog", NULL);
+ command = g_string_new (tmp);
+ g_free (tmp);
- g_string_append_printf(command, " --monitor='%i'", get_monitor_index (window));
- g_string_append_printf(command, " --height='%i'", window->priv->geometry.height);
- g_string_append_printf(command, " --width='%i'", window->priv->geometry.width);
+ g_string_append_printf(command, " --monitor='%i'", get_monitor_index (window));
+ g_string_append_printf(command, " --height='%i'", window->priv->geometry.height);
+ g_string_append_printf(command, " --width='%i'", window->priv->geometry.width);
- if (is_logout_enabled(window))
- {
- command = g_string_append (command, " --enable-logout");
- g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
- }
+ if (is_logout_enabled(window))
+ {
+ command = g_string_append (command, " --enable-logout");
+ g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
+ }
- if (window->priv->status_message)
- {
- char *quoted;
+ if (window->priv->status_message)
+ {
+ char *quoted;
- quoted = g_shell_quote (window->priv->status_message);
- g_string_append_printf (command, " --status-message=%s", quoted);
- g_free (quoted);
- }
+ quoted = g_shell_quote (window->priv->status_message);
+ g_string_append_printf (command, " --status-message=%s", quoted);
+ g_free (quoted);
+ }
- if (is_user_switch_enabled (window))
- {
- command = g_string_append (command, " --enable-switch");
- }
+ if (is_user_switch_enabled (window))
+ {
+ command = g_string_append (command, " --enable-switch");
+ }
- if (gs_debug_enabled ())
- {
- command = g_string_append (command, " --verbose");
- }
+ if (gs_debug_enabled ())
+ {
+ command = g_string_append (command, " --verbose");
+ }
- gtk_widget_hide (window->priv->drawing_area);
+ gtk_widget_hide (window->priv->drawing_area);
- gtk_widget_queue_draw (GTK_WIDGET (window));
- set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)), FALSE);
+ gtk_widget_queue_draw (GTK_WIDGET (window));
+ set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)), FALSE);
- window->priv->dialog_quit_requested = FALSE;
- window->priv->dialog_shake_in_progress = FALSE;
+ window->priv->dialog_quit_requested = FALSE;
+ window->priv->dialog_shake_in_progress = FALSE;
- result = spawn_on_window (window,
- command->str,
- &window->priv->lock_pid,
- (GIOFunc)lock_command_watch,
- window,
- &window->priv->lock_watch_id);
- if (! result)
- {
- gs_debug ("Could not start command: %s", command->str);
- }
+ result = spawn_on_window (window,
+ command->str,
+ &window->priv->lock_pid,
+ (GIOFunc)lock_command_watch,
+ window,
+ &window->priv->lock_watch_id);
+ if (! result)
+ {
+ gs_debug ("Could not start command: %s", command->str);
+ }
- g_string_free (command, TRUE);
+ g_string_free (command, TRUE);
}
static gboolean
popup_dialog_idle (GSWindow *window)
{
- popup_dialog (window);
+ popup_dialog (window);
- window->priv->popup_dialog_idle_id = 0;
+ window->priv->popup_dialog_idle_id = 0;
- return FALSE;
+ return FALSE;
}
void
gs_window_request_unlock (GSWindow *window)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- gs_debug ("Requesting unlock");
+ gs_debug ("Requesting unlock");
- if (! gtk_widget_get_visible (GTK_WIDGET (window)))
- {
- gs_debug ("Request unlock but window is not visible!");
- return;
- }
+ if (! gtk_widget_get_visible (GTK_WIDGET (window)))
+ {
+ gs_debug ("Request unlock but window is not visible!");
+ return;
+ }
- if (window->priv->lock_watch_id > 0)
- {
- return;
- }
+ if (window->priv->lock_watch_id > 0)
+ {
+ return;
+ }
- if (! window->priv->lock_enabled)
- {
- add_emit_deactivated_idle (window);
+ if (! window->priv->lock_enabled)
+ {
+ add_emit_deactivated_idle (window);
- return;
- }
+ return;
+ }
- if (window->priv->popup_dialog_idle_id == 0)
- {
- add_popup_dialog_idle (window);
- }
+ if (window->priv->popup_dialog_idle_id == 0)
+ {
+ add_popup_dialog_idle (window);
+ }
- window_set_dialog_up (window, TRUE);
+ window_set_dialog_up (window, TRUE);
}
void
gs_window_cancel_unlock_request (GSWindow *window)
{
- /* FIXME: This is a bit of a hammer approach...
- * Maybe we should send a delete-event to
- * the plug?
- */
- g_return_if_fail (GS_IS_WINDOW (window));
+ /* FIXME: This is a bit of a hammer approach...
+ * Maybe we should send a delete-event to the plug?
+ */
+ g_return_if_fail (GS_IS_WINDOW (window));
- popdown_dialog (window);
+ popdown_dialog (window);
}
void
gs_window_set_lock_enabled (GSWindow *window,
gboolean lock_enabled)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- if (window->priv->lock_enabled == lock_enabled)
- {
- return;
- }
+ if (window->priv->lock_enabled == lock_enabled)
+ {
+ return;
+ }
- window->priv->lock_enabled = lock_enabled;
- g_object_notify (G_OBJECT (window), "lock-enabled");
+ window->priv->lock_enabled = lock_enabled;
+ g_object_notify (G_OBJECT (window), "lock-enabled");
}
GdkDisplay *
gs_window_get_display (GSWindow *window)
{
- g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
- return gtk_widget_get_display (GTK_WIDGET (window));
+ return gtk_widget_get_display (GTK_WIDGET (window));
}
void
gs_window_set_keyboard_enabled (GSWindow *window,
gboolean enabled)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- window->priv->keyboard_enabled = enabled;
+ window->priv->keyboard_enabled = enabled;
}
void
gs_window_set_keyboard_command (GSWindow *window,
const char *command)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- g_free (window->priv->keyboard_command);
+ g_free (window->priv->keyboard_command);
- if (command != NULL)
- {
- window->priv->keyboard_command = g_strdup (command);
- }
- else
- {
- window->priv->keyboard_command = NULL;
- }
+ if (command != NULL)
+ {
+ window->priv->keyboard_command = g_strdup (command);
+ }
+ else
+ {
+ window->priv->keyboard_command = NULL;
+ }
}
void
gs_window_set_logout_enabled (GSWindow *window,
gboolean logout_enabled)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- window->priv->logout_enabled = logout_enabled;
+ window->priv->logout_enabled = logout_enabled;
}
void
gs_window_set_user_switch_enabled (GSWindow *window,
gboolean user_switch_enabled)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- window->priv->user_switch_enabled = user_switch_enabled;
+ window->priv->user_switch_enabled = user_switch_enabled;
}
void
gs_window_set_logout_timeout (GSWindow *window,
glong logout_timeout)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- if (logout_timeout < 0)
- {
- window->priv->logout_timeout = 0;
- }
- else
- {
- window->priv->logout_timeout = logout_timeout;
- }
+ if (logout_timeout < 0)
+ {
+ window->priv->logout_timeout = 0;
+ }
+ else
+ {
+ window->priv->logout_timeout = logout_timeout;
+ }
}
void
gs_window_set_logout_command (GSWindow *window,
const char *command)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- g_free (window->priv->logout_command);
+ g_free (window->priv->logout_command);
- if (command)
- {
- window->priv->logout_command = g_strdup (command);
- }
- else
- {
- window->priv->logout_command = NULL;
- }
+ if (command)
+ {
+ window->priv->logout_command = g_strdup (command);
+ }
+ else
+ {
+ window->priv->logout_command = NULL;
+ }
}
void
gs_window_set_status_message (GSWindow *window,
const char *status_message)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- g_free (window->priv->status_message);
- window->priv->status_message = g_strdup (status_message);
+ g_free (window->priv->status_message);
+ window->priv->status_message = g_strdup (status_message);
}
void
gs_window_set_monitor (GSWindow *window,
GdkMonitor *monitor)
{
- g_return_if_fail (GS_IS_WINDOW (window));
+ g_return_if_fail (GS_IS_WINDOW (window));
- if (window->priv->monitor == monitor)
- {
- return;
- }
+ if (window->priv->monitor == monitor)
+ {
+ return;
+ }
- window->priv->monitor = monitor;
+ window->priv->monitor = monitor;
- gtk_widget_queue_resize (GTK_WIDGET (window));
+ gtk_widget_queue_resize (GTK_WIDGET (window));
- g_object_notify (G_OBJECT (window), "monitor");
+ g_object_notify (G_OBJECT (window), "monitor");
}
GdkMonitor *
gs_window_get_monitor (GSWindow *window)
{
- g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
- return window->priv->monitor;
+ return window->priv->monitor;
}
static void
-gs_window_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GSWindow *self;
-
- self = GS_WINDOW (object);
-
- switch (prop_id)
- {
- case PROP_LOCK_ENABLED:
- gs_window_set_lock_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_KEYBOARD_ENABLED:
- gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_KEYBOARD_COMMAND:
- gs_window_set_keyboard_command (self, g_value_get_string (value));
- break;
- case PROP_LOGOUT_ENABLED:
- gs_window_set_logout_enabled (self, g_value_get_boolean (value));
- break;
- case PROP_LOGOUT_COMMAND:
- gs_window_set_logout_command (self, g_value_get_string (value));
- break;
- case PROP_STATUS_MESSAGE:
- gs_window_set_status_message (self, g_value_get_string (value));
- break;
- case PROP_LOGOUT_TIMEOUT:
- gs_window_set_logout_timeout (self, g_value_get_long (value));
- break;
- case PROP_MONITOR:
- gs_window_set_monitor (self, g_value_get_pointer (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gs_window_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GSWindow *self;
+
+ self = GS_WINDOW (object);
+
+ switch (prop_id)
+ {
+ case PROP_LOCK_ENABLED:
+ gs_window_set_lock_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_KEYBOARD_ENABLED:
+ gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_KEYBOARD_COMMAND:
+ gs_window_set_keyboard_command (self, g_value_get_string (value));
+ break;
+ case PROP_LOGOUT_ENABLED:
+ gs_window_set_logout_enabled (self, g_value_get_boolean (value));
+ break;
+ case PROP_LOGOUT_COMMAND:
+ gs_window_set_logout_command (self, g_value_get_string (value));
+ break;
+ case PROP_STATUS_MESSAGE:
+ gs_window_set_status_message (self, g_value_get_string (value));
+ break;
+ case PROP_LOGOUT_TIMEOUT:
+ gs_window_set_logout_timeout (self, g_value_get_long (value));
+ break;
+ case PROP_MONITOR:
+ gs_window_set_monitor (self, g_value_get_pointer (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
@@ -2015,227 +2014,227 @@ gs_window_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GSWindow *self;
-
- self = GS_WINDOW (object);
-
- switch (prop_id)
- {
- case PROP_LOCK_ENABLED:
- g_value_set_boolean (value, self->priv->lock_enabled);
- break;
- case PROP_KEYBOARD_ENABLED:
- g_value_set_boolean (value, self->priv->keyboard_enabled);
- break;
- case PROP_KEYBOARD_COMMAND:
- g_value_set_string (value, self->priv->keyboard_command);
- break;
- case PROP_LOGOUT_ENABLED:
- g_value_set_boolean (value, self->priv->logout_enabled);
- break;
- case PROP_LOGOUT_COMMAND:
- g_value_set_string (value, self->priv->logout_command);
- break;
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, self->priv->status_message);
- break;
- case PROP_LOGOUT_TIMEOUT:
- g_value_set_long (value, self->priv->logout_timeout);
- break;
- case PROP_MONITOR:
- g_value_set_pointer (value, (gpointer) self->priv->monitor);
- break;
- case PROP_OBSCURED:
- g_value_set_boolean (value, self->priv->obscured);
- break;
- case PROP_DIALOG_UP:
- g_value_set_boolean (value, self->priv->dialog_up);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSWindow *self;
+
+ self = GS_WINDOW (object);
+
+ switch (prop_id)
+ {
+ case PROP_LOCK_ENABLED:
+ g_value_set_boolean (value, self->priv->lock_enabled);
+ break;
+ case PROP_KEYBOARD_ENABLED:
+ g_value_set_boolean (value, self->priv->keyboard_enabled);
+ break;
+ case PROP_KEYBOARD_COMMAND:
+ g_value_set_string (value, self->priv->keyboard_command);
+ break;
+ case PROP_LOGOUT_ENABLED:
+ g_value_set_boolean (value, self->priv->logout_enabled);
+ break;
+ case PROP_LOGOUT_COMMAND:
+ g_value_set_string (value, self->priv->logout_command);
+ break;
+ case PROP_STATUS_MESSAGE:
+ g_value_set_string (value, self->priv->status_message);
+ break;
+ case PROP_LOGOUT_TIMEOUT:
+ g_value_set_long (value, self->priv->logout_timeout);
+ break;
+ case PROP_MONITOR:
+ g_value_set_pointer (value, (gpointer) self->priv->monitor);
+ break;
+ case PROP_OBSCURED:
+ g_value_set_boolean (value, self->priv->obscured);
+ break;
+ case PROP_DIALOG_UP:
+ g_value_set_boolean (value, self->priv->dialog_up);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
queue_key_event (GSWindow *window,
GdkEventKey *event)
{
- /* Eat the first return, enter, escape, or space */
- if (window->priv->key_events == NULL
- && (event->keyval == GDK_KEY_Return
- || event->keyval == GDK_KEY_KP_Enter
- || event->keyval == GDK_KEY_Escape
- || event->keyval == GDK_KEY_space))
- {
- return;
- }
-
- /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
- something is wrong */
- /* Don't queue keys that may cause focus navigation in the dialog */
- if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS
- && event->keyval != GDK_KEY_Tab
- && event->keyval != GDK_KEY_Up
- && event->keyval != GDK_KEY_Down)
- {
- window->priv->key_events = g_list_prepend (window->priv->key_events,
- gdk_event_copy ((GdkEvent *)event));
- }
+ /* Eat the first return, enter, escape, or space */
+ if (window->priv->key_events == NULL
+ && (event->keyval == GDK_KEY_Return
+ || event->keyval == GDK_KEY_KP_Enter
+ || event->keyval == GDK_KEY_Escape
+ || event->keyval == GDK_KEY_space))
+ {
+ return;
+ }
+
+ /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
+ something is wrong */
+ /* Don't queue keys that may cause focus navigation in the dialog */
+ if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS
+ && event->keyval != GDK_KEY_Tab
+ && event->keyval != GDK_KEY_Up
+ && event->keyval != GDK_KEY_Down)
+ {
+ window->priv->key_events = g_list_prepend (window->priv->key_events,
+ gdk_event_copy ((GdkEvent *)event));
+ }
}
static gboolean
maybe_handle_activity (GSWindow *window)
{
- gboolean handled;
+ gboolean handled;
- handled = FALSE;
+ handled = FALSE;
- /* if we already have a socket then don't bother */
- if (! window->priv->lock_socket
- && gtk_widget_get_sensitive (GTK_WIDGET (window)))
- {
- g_signal_emit (window, signals [ACTIVITY], 0, &handled);
- }
+ /* if we already have a socket then don't bother */
+ if (! window->priv->lock_socket
+ && gtk_widget_get_sensitive (GTK_WIDGET (window)))
+ {
+ g_signal_emit (window, signals [ACTIVITY], 0, &handled);
+ }
- return handled;
+ return handled;
}
static gboolean
gs_window_real_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
- /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
+ /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
- /* Ignore brightness keys */
- if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
- {
- gs_debug ("Ignoring brightness keys");
- return TRUE;
- }
+ /* Ignore brightness keys */
+ if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
+ {
+ gs_debug ("Ignoring brightness keys");
+ return TRUE;
+ }
- maybe_handle_activity (GS_WINDOW (widget));
+ maybe_handle_activity (GS_WINDOW (widget));
- queue_key_event (GS_WINDOW (widget), event);
+ queue_key_event (GS_WINDOW (widget), event);
- if (GTK_WIDGET_CLASS (gs_window_parent_class)->key_press_event)
- {
- GTK_WIDGET_CLASS (gs_window_parent_class)->key_press_event (widget, event);
- }
+ if (GTK_WIDGET_CLASS (gs_window_parent_class)->key_press_event)
+ {
+ GTK_WIDGET_CLASS (gs_window_parent_class)->key_press_event (widget, event);
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
gs_window_real_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event)
{
- GSWindow *window;
- gdouble distance;
- gdouble min_distance;
- gdouble min_percentage = 0.1;
- GdkDisplay *display;
- GdkScreen *screen;
+ GSWindow *window;
+ gdouble distance;
+ gdouble min_distance;
+ gdouble min_percentage = 0.1;
+ GdkDisplay *display;
+ GdkScreen *screen;
- window = GS_WINDOW (widget);
+ window = GS_WINDOW (widget);
- display = gs_window_get_display (window);
- screen = gdk_display_get_default_screen (display);
- min_distance = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) * min_percentage;
+ display = gs_window_get_display (window);
+ screen = gdk_display_get_default_screen (display);
+ min_distance = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) * min_percentage;
- /* if the last position was not set then don't detect motion */
- if (window->priv->last_x < 0 || window->priv->last_y < 0)
- {
- window->priv->last_x = event->x;
- window->priv->last_y = event->y;
+ /* if the last position was not set then don't detect motion */
+ if (window->priv->last_x < 0 || window->priv->last_y < 0)
+ {
+ window->priv->last_x = event->x;
+ window->priv->last_y = event->y;
- return FALSE;
- }
+ return FALSE;
+ }
- /* just an approximate distance */
- distance = MAX (ABS (window->priv->last_x - event->x),
- ABS (window->priv->last_y - event->y));
+ /* just an approximate distance */
+ distance = MAX (ABS (window->priv->last_x - event->x),
+ ABS (window->priv->last_y - event->y));
- if (distance > min_distance)
- {
- maybe_handle_activity (window);
+ if (distance > min_distance)
+ {
+ maybe_handle_activity (window);
- window->priv->last_x = -1;
- window->priv->last_y = -1;
- }
+ window->priv->last_x = -1;
+ window->priv->last_y = -1;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
gs_window_real_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
- GSWindow *window;
+ GSWindow *window;
- window = GS_WINDOW (widget);
- maybe_handle_activity (window);
+ window = GS_WINDOW (widget);
+ maybe_handle_activity (window);
- return FALSE;
+ return FALSE;
}
static gboolean
gs_window_real_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
- GSWindow *window;
+ GSWindow *window;
- window = GS_WINDOW (widget);
- maybe_handle_activity (window);
+ window = GS_WINDOW (widget);
+ maybe_handle_activity (window);
- return FALSE;
+ return FALSE;
}
static void
gs_window_real_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GSWindow *window;
- GtkBin *bin;
- GtkWidget *child;
- GdkRectangle old_geometry;
- int position_changed = FALSE;
- int size_changed = FALSE;
+ GSWindow *window;
+ GtkBin *bin;
+ GtkWidget *child;
+ GdkRectangle old_geometry;
+ int position_changed = FALSE;
+ int size_changed = FALSE;
- window = GS_WINDOW (widget);
- bin = GTK_BIN (widget);
- child = gtk_bin_get_child (bin);
+ window = GS_WINDOW (widget);
+ bin = GTK_BIN (widget);
+ child = gtk_bin_get_child (bin);
- if (child && gtk_widget_get_visible (child))
- {
- gtk_widget_get_preferred_size (child, requisition, NULL);
- }
+ if (child && gtk_widget_get_visible (child))
+ {
+ gtk_widget_get_preferred_size (child, requisition, NULL);
+ }
- old_geometry = window->priv->geometry;
+ old_geometry = window->priv->geometry;
- update_geometry (window);
+ update_geometry (window);
- requisition->width = window->priv->geometry.width;
- requisition->height = window->priv->geometry.height;
+ requisition->width = window->priv->geometry.width;
+ requisition->height = window->priv->geometry.height;
- if (! gtk_widget_get_realized (widget))
- {
- return;
- }
+ if (! gtk_widget_get_realized (widget))
+ {
+ return;
+ }
- if (old_geometry.width != window->priv->geometry.width ||
- old_geometry.height != window->priv->geometry.height)
- {
- size_changed = TRUE;
- }
+ if (old_geometry.width != window->priv->geometry.width ||
+ old_geometry.height != window->priv->geometry.height)
+ {
+ size_changed = TRUE;
+ }
- if (old_geometry.x != window->priv->geometry.x ||
- old_geometry.y != window->priv->geometry.y)
- {
- position_changed = TRUE;
- }
+ if (old_geometry.x != window->priv->geometry.x ||
+ old_geometry.y != window->priv->geometry.y)
+ {
+ position_changed = TRUE;
+ }
- gs_window_move_resize_window (window, position_changed, size_changed);
+ gs_window_move_resize_window (window, position_changed, size_changed);
}
static void
@@ -2243,9 +2242,9 @@ gs_window_real_get_preferred_width (GtkWidget *widget,
gint *minimal_width,
gint *natural_width)
{
- GtkRequisition requisition;
- gs_window_real_size_request (widget, &requisition);
- *minimal_width = *natural_width = requisition.width;
+ GtkRequisition requisition;
+ gs_window_real_size_request (widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
}
static void
@@ -2253,344 +2252,344 @@ gs_window_real_get_preferred_height (GtkWidget *widget,
gint *minimal_height,
gint *natural_height)
{
- GtkRequisition requisition;
- gs_window_real_size_request (widget, &requisition);
- *minimal_height = *natural_height = requisition.height;
+ GtkRequisition requisition;
+ gs_window_real_size_request (widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
}
static gboolean
gs_window_real_grab_broken (GtkWidget *widget,
GdkEventGrabBroken *event)
{
- if (event->grab_window != NULL)
- {
- gs_debug ("Grab broken on window %X %s, new grab on window %X",
- (guint32) GDK_WINDOW_XID (event->window),
- event->keyboard ? "keyboard" : "pointer",
- (guint32) GDK_WINDOW_XID (event->grab_window));
- }
- else
- {
- gs_debug ("Grab broken on window %X %s, new grab is outside application",
- (guint32) GDK_WINDOW_XID (event->window),
- event->keyboard ? "keyboard" : "pointer");
- }
+ if (event->grab_window != NULL)
+ {
+ gs_debug ("Grab broken on window %X %s, new grab on window %X",
+ (guint32) GDK_WINDOW_XID (event->window),
+ event->keyboard ? "keyboard" : "pointer",
+ (guint32) GDK_WINDOW_XID (event->grab_window));
+ }
+ else
+ {
+ gs_debug ("Grab broken on window %X %s, new grab is outside application",
+ (guint32) GDK_WINDOW_XID (event->window),
+ event->keyboard ? "keyboard" : "pointer");
+ }
- return FALSE;
+ return FALSE;
}
gboolean
gs_window_is_obscured (GSWindow *window)
{
- g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
- return window->priv->obscured;
+ return window->priv->obscured;
}
gboolean
gs_window_is_dialog_up (GSWindow *window)
{
- g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (GS_IS_WINDOW (window), FALSE);
- return window->priv->dialog_up;
+ return window->priv->dialog_up;
}
static void
window_set_obscured (GSWindow *window,
gboolean obscured)
{
- if (window->priv->obscured == obscured)
- {
- return;
- }
+ if (window->priv->obscured == obscured)
+ {
+ return;
+ }
- window->priv->obscured = obscured;
- g_object_notify (G_OBJECT (window), "obscured");
+ window->priv->obscured = obscured;
+ g_object_notify (G_OBJECT (window), "obscured");
}
static gboolean
gs_window_real_visibility_notify_event (GtkWidget *widget,
GdkEventVisibility *event)
{
- switch (event->state)
- {
- case GDK_VISIBILITY_FULLY_OBSCURED:
- window_set_obscured (GS_WINDOW (widget), TRUE);
- break;
- case GDK_VISIBILITY_PARTIAL:
- break;
- case GDK_VISIBILITY_UNOBSCURED:
- window_set_obscured (GS_WINDOW (widget), FALSE);
- break;
- default:
- break;
- }
+ switch (event->state)
+ {
+ case GDK_VISIBILITY_FULLY_OBSCURED:
+ window_set_obscured (GS_WINDOW (widget), TRUE);
+ break;
+ case GDK_VISIBILITY_PARTIAL:
+ break;
+ case GDK_VISIBILITY_UNOBSCURED:
+ window_set_obscured (GS_WINDOW (widget), FALSE);
+ break;
+ default:
+ break;
+ }
- return FALSE;
+ return FALSE;
}
static void
gs_window_class_init (GSWindowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = gs_window_finalize;
- object_class->get_property = gs_window_get_property;
- object_class->set_property = gs_window_set_property;
-
- widget_class->show = gs_window_real_show;
- widget_class->hide = gs_window_real_hide;
- widget_class->draw = gs_window_real_draw;
- widget_class->realize = gs_window_real_realize;
- widget_class->unrealize = gs_window_real_unrealize;
- widget_class->key_press_event = gs_window_real_key_press_event;
- widget_class->motion_notify_event = gs_window_real_motion_notify_event;
- widget_class->button_press_event = gs_window_real_button_press_event;
- widget_class->scroll_event = gs_window_real_scroll_event;
- widget_class->get_preferred_width = gs_window_real_get_preferred_width;
- widget_class->get_preferred_height = gs_window_real_get_preferred_height;
- widget_class->grab_broken_event = gs_window_real_grab_broken;
- widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
-
- signals [ACTIVITY] =
- g_signal_new ("activity",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSWindowClass, activity),
- NULL,
- NULL,
- gs_marshal_BOOLEAN__VOID,
- G_TYPE_BOOLEAN,
- 0);
- signals [DEACTIVATED] =
- g_signal_new ("deactivated",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSWindowClass, deactivated),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_OBSCURED,
- g_param_spec_boolean ("obscured",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READABLE));
- g_object_class_install_property (object_class,
- PROP_DIALOG_UP,
- g_param_spec_boolean ("dialog-up",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READABLE));
- g_object_class_install_property (object_class,
- PROP_LOCK_ENABLED,
- g_param_spec_boolean ("lock-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOGOUT_ENABLED,
- g_param_spec_boolean ("logout-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOGOUT_TIMEOUT,
- g_param_spec_long ("logout-timeout",
- NULL,
- NULL,
- -1,
- G_MAXLONG,
- 0,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LOGOUT_COMMAND,
- g_param_spec_string ("logout-command",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_STATUS_MESSAGE,
- g_param_spec_string ("status-message",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_KEYBOARD_ENABLED,
- g_param_spec_boolean ("keyboard-enabled",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_KEYBOARD_COMMAND,
- g_param_spec_string ("keyboard-command",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_MONITOR,
- g_param_spec_pointer ("monitor",
- "Gdk monitor",
- "The monitor (in terms of Gdk) which the window is on",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gs_window_finalize;
+ object_class->get_property = gs_window_get_property;
+ object_class->set_property = gs_window_set_property;
+
+ widget_class->show = gs_window_real_show;
+ widget_class->hide = gs_window_real_hide;
+ widget_class->draw = gs_window_real_draw;
+ widget_class->realize = gs_window_real_realize;
+ widget_class->unrealize = gs_window_real_unrealize;
+ widget_class->key_press_event = gs_window_real_key_press_event;
+ widget_class->motion_notify_event = gs_window_real_motion_notify_event;
+ widget_class->button_press_event = gs_window_real_button_press_event;
+ widget_class->scroll_event = gs_window_real_scroll_event;
+ widget_class->get_preferred_width = gs_window_real_get_preferred_width;
+ widget_class->get_preferred_height = gs_window_real_get_preferred_height;
+ widget_class->grab_broken_event = gs_window_real_grab_broken;
+ widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
+
+ signals [ACTIVITY] =
+ g_signal_new ("activity",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSWindowClass, activity),
+ NULL,
+ NULL,
+ gs_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN,
+ 0);
+ signals [DEACTIVATED] =
+ g_signal_new ("deactivated",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSWindowClass, deactivated),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_object_class_install_property (object_class,
+ PROP_OBSCURED,
+ g_param_spec_boolean ("obscured",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_DIALOG_UP,
+ g_param_spec_boolean ("dialog-up",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_LOCK_ENABLED,
+ g_param_spec_boolean ("lock-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_ENABLED,
+ g_param_spec_boolean ("logout-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_TIMEOUT,
+ g_param_spec_long ("logout-timeout",
+ NULL,
+ NULL,
+ -1,
+ G_MAXLONG,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LOGOUT_COMMAND,
+ g_param_spec_string ("logout-command",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_STATUS_MESSAGE,
+ g_param_spec_string ("status-message",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_KEYBOARD_ENABLED,
+ g_param_spec_boolean ("keyboard-enabled",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_KEYBOARD_COMMAND,
+ g_param_spec_string ("keyboard-command",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_MONITOR,
+ g_param_spec_pointer ("monitor",
+ "Gdk monitor",
+ "The monitor (in terms of Gdk) which the window is on",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
create_info_bar (GSWindow *window)
{
- window->priv->info_bar = gtk_info_bar_new ();
- gtk_widget_set_no_show_all (window->priv->info_bar, TRUE);
- gtk_box_pack_end (GTK_BOX (window->priv->vbox), window->priv->info_bar, FALSE, FALSE, 0);
+ window->priv->info_bar = gtk_info_bar_new ();
+ gtk_widget_set_no_show_all (window->priv->info_bar, TRUE);
+ gtk_box_pack_end (GTK_BOX (window->priv->vbox), window->priv->info_bar, FALSE, FALSE, 0);
}
static gboolean
on_drawing_area_draw (GtkWidget *widget,
cairo_t *cr)
{
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_paint (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
- return FALSE;
+ return FALSE;
}
static void
gs_window_init (GSWindow *window)
{
- window->priv = gs_window_get_instance_private (window);
+ window->priv = gs_window_get_instance_private (window);
- window->priv->geometry.x = -1;
- window->priv->geometry.y = -1;
- window->priv->geometry.width = -1;
- window->priv->geometry.height = -1;
+ window->priv->geometry.x = -1;
+ window->priv->geometry.y = -1;
+ window->priv->geometry.width = -1;
+ window->priv->geometry.height = -1;
- window->priv->last_x = -1;
- window->priv->last_y = -1;
+ window->priv->last_x = -1;
+ window->priv->last_y = -1;
- gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
+ gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE);
- gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE);
+ gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE);
- gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
+ gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
- gtk_window_fullscreen (GTK_WINDOW (window));
+ gtk_window_fullscreen (GTK_WINDOW (window));
- gtk_widget_set_events (GTK_WIDGET (window),
- gtk_widget_get_events (GTK_WIDGET (window))
- | GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_KEY_PRESS_MASK
- | GDK_KEY_RELEASE_MASK
- | GDK_EXPOSURE_MASK
- | GDK_VISIBILITY_NOTIFY_MASK
- | GDK_ENTER_NOTIFY_MASK
- | GDK_LEAVE_NOTIFY_MASK);
+ gtk_widget_set_events (GTK_WIDGET (window),
+ gtk_widget_get_events (GTK_WIDGET (window))
+ | GDK_POINTER_MOTION_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_KEY_PRESS_MASK
+ | GDK_KEY_RELEASE_MASK
+ | GDK_EXPOSURE_MASK
+ | GDK_VISIBILITY_NOTIFY_MASK
+ | GDK_ENTER_NOTIFY_MASK
+ | GDK_LEAVE_NOTIFY_MASK);
- window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- gtk_widget_show (window->priv->vbox);
- gtk_container_add (GTK_CONTAINER (window), window->priv->vbox);
+ window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+ gtk_widget_show (window->priv->vbox);
+ gtk_container_add (GTK_CONTAINER (window), window->priv->vbox);
- window->priv->drawing_area = gtk_drawing_area_new ();
- gtk_widget_show (window->priv->drawing_area);
- gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE);
- gtk_box_pack_start (GTK_BOX (window->priv->vbox),
- window->priv->drawing_area, TRUE, TRUE, 0);
- g_signal_connect (window->priv->drawing_area,
- "draw",
- G_CALLBACK (on_drawing_area_draw),
- NULL);
- create_info_bar (window);
+ window->priv->drawing_area = gtk_drawing_area_new ();
+ gtk_widget_show (window->priv->drawing_area);
+ gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE);
+ gtk_box_pack_start (GTK_BOX (window->priv->vbox),
+ window->priv->drawing_area, TRUE, TRUE, 0);
+ g_signal_connect (window->priv->drawing_area,
+ "draw",
+ G_CALLBACK (on_drawing_area_draw),
+ NULL);
+ create_info_bar (window);
}
static void
remove_command_watches (GSWindow *window)
{
- if (window->priv->lock_watch_id != 0)
- {
- g_source_remove (window->priv->lock_watch_id);
- window->priv->lock_watch_id = 0;
- }
- if (window->priv->keyboard_watch_id != 0)
- {
- g_source_remove (window->priv->keyboard_watch_id);
- window->priv->keyboard_watch_id = 0;
- }
+ if (window->priv->lock_watch_id != 0)
+ {
+ g_source_remove (window->priv->lock_watch_id);
+ window->priv->lock_watch_id = 0;
+ }
+ if (window->priv->keyboard_watch_id != 0)
+ {
+ g_source_remove (window->priv->keyboard_watch_id);
+ window->priv->keyboard_watch_id = 0;
+ }
}
static void
gs_window_finalize (GObject *object)
{
- GSWindow *window;
+ GSWindow *window;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_WINDOW (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_WINDOW (object));
- window = GS_WINDOW (object);
+ window = GS_WINDOW (object);
- g_return_if_fail (window->priv != NULL);
+ g_return_if_fail (window->priv != NULL);
- g_free (window->priv->logout_command);
- g_free (window->priv->keyboard_command);
+ g_free (window->priv->logout_command);
+ g_free (window->priv->keyboard_command);
- if (window->priv->info_bar_timer_id > 0)
- {
- g_source_remove (window->priv->info_bar_timer_id);
- window->priv->info_bar_timer_id = 0;
- }
+ if (window->priv->info_bar_timer_id > 0)
+ {
+ g_source_remove (window->priv->info_bar_timer_id);
+ window->priv->info_bar_timer_id = 0;
+ }
- remove_watchdog_timer (window);
- remove_popup_dialog_idle (window);
+ remove_watchdog_timer (window);
+ remove_popup_dialog_idle (window);
- if (window->priv->timer)
- {
- g_timer_destroy (window->priv->timer);
- }
+ if (window->priv->timer)
+ {
+ g_timer_destroy (window->priv->timer);
+ }
- remove_key_events (window);
+ remove_key_events (window);
- remove_command_watches (window);
+ remove_command_watches (window);
- gs_window_dialog_finish (window);
+ gs_window_dialog_finish (window);
- if (window->priv->background_surface)
- {
- cairo_surface_destroy (window->priv->background_surface);
- }
+ if (window->priv->background_surface)
+ {
+ cairo_surface_destroy (window->priv->background_surface);
+ }
- G_OBJECT_CLASS (gs_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_window_parent_class)->finalize (object);
}
GSWindow *
gs_window_new (GdkMonitor *monitor,
- gboolean lock_enabled)
+ gboolean lock_enabled)
{
- GObject *result;
- GdkDisplay *display = gdk_monitor_get_display (monitor);
- GdkScreen *screen = gdk_display_get_default_screen (display);
+ GObject *result;
+ GdkDisplay *display = gdk_monitor_get_display (monitor);
+ GdkScreen *screen = gdk_display_get_default_screen (display);
- result = g_object_new (GS_TYPE_WINDOW,
- "type", GTK_WINDOW_POPUP,
- "screen", screen,
- "monitor", monitor,
- "lock-enabled", lock_enabled,
- "app-paintable", TRUE,
- NULL);
+ result = g_object_new (GS_TYPE_WINDOW,
+ "type", GTK_WINDOW_POPUP,
+ "screen", screen,
+ "monitor", monitor,
+ "lock-enabled", lock_enabled,
+ "app-paintable", TRUE,
+ NULL);
- return GS_WINDOW (result);
+ return GS_WINDOW (result);
}
diff --git a/src/gs-window.h b/src/gs-window.h
index 33bad7f..97c2f56 100644
--- a/src/gs-window.h
+++ b/src/gs-window.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
@@ -39,65 +39,65 @@ typedef struct GSWindowPrivate GSWindowPrivate;
typedef struct
{
- GtkWindow window;
+ GtkWindow window;
- GSWindowPrivate *priv;
+ GSWindowPrivate *priv;
} GSWindow;
typedef struct
{
- GtkWindowClass parent_class;
+ GtkWindowClass parent_class;
- gboolean (* activity) (GSWindow *window);
- void (* deactivated) (GSWindow *window);
- void (* dialog_up) (GSWindow *window);
- void (* dialog_down) (GSWindow *window);
+ gboolean (* activity) (GSWindow *window);
+ void (* deactivated) (GSWindow *window);
+ void (* dialog_up) (GSWindow *window);
+ void (* dialog_down) (GSWindow *window);
} GSWindowClass;
-GType gs_window_get_type (void);
-
-gboolean gs_window_is_obscured (GSWindow *window);
-gboolean gs_window_is_dialog_up (GSWindow *window);
-
-GdkDisplay * gs_window_get_display (GSWindow *window);
-
-void gs_window_set_monitor (GSWindow *window,
- GdkMonitor *monitor);
-GdkMonitor * gs_window_get_monitor (GSWindow *window);
-
-void gs_window_set_background_surface (GSWindow *window,
- cairo_surface_t *surface);
-void gs_window_set_lock_enabled (GSWindow *window,
- gboolean lock_enabled);
-void gs_window_set_logout_enabled (GSWindow *window,
- gboolean logout_enabled);
-void gs_window_set_keyboard_enabled (GSWindow *window,
- gboolean enabled);
-void gs_window_set_keyboard_command (GSWindow *window,
- const char *command);
-void gs_window_set_user_switch_enabled (GSWindow *window,
- gboolean user_switch_enabled);
-void gs_window_set_logout_timeout (GSWindow *window,
- glong timeout);
-void gs_window_set_logout_command (GSWindow *window,
- const char *command);
-void gs_window_set_status_message (GSWindow *window,
- const char *status_message);
-void gs_window_show_message (GSWindow *window,
- const char *summary,
- const char *body,
- const char *icon);
-
-void gs_window_request_unlock (GSWindow *window);
-void gs_window_cancel_unlock_request (GSWindow *window);
-
-GSWindow * gs_window_new (GdkMonitor *monitor,
- gboolean lock_enabled);
-void gs_window_show (GSWindow *window);
-void gs_window_destroy (GSWindow *window);
-GdkWindow * gs_window_get_gdk_window (GSWindow *window);
-GtkWidget * gs_window_get_drawing_area (GSWindow *window);
-void gs_window_clear (GSWindow *window);
+GType gs_window_get_type (void);
+
+gboolean gs_window_is_obscured (GSWindow *window);
+gboolean gs_window_is_dialog_up (GSWindow *window);
+
+GdkDisplay *gs_window_get_display (GSWindow *window);
+
+void gs_window_set_monitor (GSWindow *window,
+ GdkMonitor *monitor);
+GdkMonitor *gs_window_get_monitor (GSWindow *window);
+
+void gs_window_set_background_surface (GSWindow *window,
+ cairo_surface_t *surface);
+void gs_window_set_lock_enabled (GSWindow *window,
+ gboolean lock_enabled);
+void gs_window_set_logout_enabled (GSWindow *window,
+ gboolean logout_enabled);
+void gs_window_set_keyboard_enabled (GSWindow *window,
+ gboolean enabled);
+void gs_window_set_keyboard_command (GSWindow *window,
+ const char *command);
+void gs_window_set_user_switch_enabled (GSWindow *window,
+ gboolean user_switch_enabled);
+void gs_window_set_logout_timeout (GSWindow *window,
+ glong timeout);
+void gs_window_set_logout_command (GSWindow *window,
+ const char *command);
+void gs_window_set_status_message (GSWindow *window,
+ const char *status_message);
+void gs_window_show_message (GSWindow *window,
+ const char *summary,
+ const char *body,
+ const char *icon);
+
+void gs_window_request_unlock (GSWindow *window);
+void gs_window_cancel_unlock_request (GSWindow *window);
+
+GSWindow * gs_window_new (GdkMonitor *monitor,
+ gboolean lock_enabled);
+void gs_window_show (GSWindow *window);
+void gs_window_destroy (GSWindow *window);
+GdkWindow * gs_window_get_gdk_window (GSWindow *window);
+GtkWidget * gs_window_get_drawing_area (GSWindow *window);
+void gs_window_clear (GSWindow *window);
G_END_DECLS
diff --git a/src/setuid.c b/src/setuid.c
index 0a065d9..c4763e9 100644
--- a/src/setuid.c
+++ b/src/setuid.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* setuid.c --- management of runtime privileges.
*
@@ -23,8 +23,8 @@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
-#include <pwd.h> /* for getpwnam() and struct passwd */
-#include <grp.h> /* for getgrgid() and struct group */
+#include <pwd.h> /* for getpwnam() and struct passwd */
+#include <grp.h> /* for getgrgid() and struct group */
#include <glib.h>
#include "setuid.h"
@@ -33,126 +33,126 @@ static char *
uid_gid_string (uid_t uid,
gid_t gid)
{
- static char *buf;
- struct passwd *p = NULL;
- struct group *g = NULL;
+ static char *buf;
+ struct passwd *p = NULL;
+ struct group *g = NULL;
- p = getpwuid (uid);
- g = getgrgid (gid);
+ p = getpwuid (uid);
+ g = getgrgid (gid);
- buf = g_strdup_printf ("%s/%s (%ld/%ld)",
- (p && p->pw_name ? p->pw_name : "???"),
- (g && g->gr_name ? g->gr_name : "???"),
- (long) uid, (long) gid);
+ buf = g_strdup_printf ("%s/%s (%ld/%ld)",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) uid, (long) gid);
- return buf;
+ return buf;
}
static gboolean
-set_ids_by_number (uid_t uid,
- gid_t gid,
- char **message_ret)
+set_ids_by_number (uid_t uid,
+ gid_t gid,
+ char **message_ret)
{
- int uid_errno = 0;
- int gid_errno = 0;
- int sgs_errno = 0;
- struct passwd *p = getpwuid (uid);
- struct group *g = getgrgid (gid);
-
- if (message_ret)
- *message_ret = NULL;
-
- /* Rumor has it that some implementations of of setuid() do nothing
- when called with -1; therefore, if the "nobody" user has a uid of
- -1, then that would be Really Bad. Rumor further has it that such
- systems really ought to be using -2 for "nobody", since that works.
- So, if we get a uid (or gid, for good measure) of -1, switch to -2
- instead. Note that this must be done after we've looked up the
- user/group names with getpwuid(-1) and/or getgrgid(-1).
- */
- if (gid == (gid_t) -1) gid = (gid_t) -2;
- if (uid == (uid_t) -1) uid = (uid_t) -2;
-
- errno = 0;
- if (setgroups (1, &gid) < 0)
- sgs_errno = errno ? errno : -1;
-
- errno = 0;
- if (setgid (gid) != 0)
- gid_errno = errno ? errno : -1;
-
- errno = 0;
- if (setuid (uid) != 0)
- uid_errno = errno ? errno : -1;
-
- if (uid_errno == 0 && gid_errno == 0 && sgs_errno == 0)
- {
- static char *reason;
- reason = g_strdup_printf ("changed uid/gid to %s/%s (%ld/%ld).",
- (p && p->pw_name ? p->pw_name : "???"),
- (g && g->gr_name ? g->gr_name : "???"),
- (long) uid, (long) gid);
- if (message_ret)
- *message_ret = g_strdup (reason);
-
- g_free (reason);
-
- return TRUE;
- }
- else
- {
- char *reason = NULL;
-
- if (sgs_errno)
- {
- reason = g_strdup_printf ("couldn't setgroups to %s (%ld)",
- (g && g->gr_name ? g->gr_name : "???"),
- (long) gid);
- if (sgs_errno == -1)
- fprintf (stderr, "%s: unknown error\n", reason);
- else
- {
- errno = sgs_errno;
- perror (reason);
- }
- g_free (reason);
- reason = NULL;
- }
-
- if (gid_errno)
- {
- reason = g_strdup_printf ("couldn't set gid to %s (%ld)",
- (g && g->gr_name ? g->gr_name : "???"),
- (long) gid);
- if (gid_errno == -1)
- fprintf (stderr, "%s: unknown error\n", reason);
- else
- {
- errno = gid_errno;
- perror (reason);
- }
- g_free (reason);
- reason = NULL;
- }
-
- if (uid_errno)
- {
- reason = g_strdup_printf ("couldn't set uid to %s (%ld)",
- (p && p->pw_name ? p->pw_name : "???"),
- (long) uid);
- if (uid_errno == -1)
- fprintf (stderr, "%s: unknown error\n", reason);
- else
- {
- errno = uid_errno;
- perror (reason);
- }
- g_free (reason);
- reason = NULL;
- }
- return FALSE;
- }
- return FALSE;
+ int uid_errno = 0;
+ int gid_errno = 0;
+ int sgs_errno = 0;
+ struct passwd *p = getpwuid (uid);
+ struct group *g = getgrgid (gid);
+
+ if (message_ret)
+ *message_ret = NULL;
+
+ /* Rumor has it that some implementations of of setuid() do nothing
+ when called with -1; therefore, if the "nobody" user has a uid of
+ -1, then that would be Really Bad. Rumor further has it that such
+ systems really ought to be using -2 for "nobody", since that works.
+ So, if we get a uid (or gid, for good measure) of -1, switch to -2
+ instead. Note that this must be done after we've looked up the
+ user/group names with getpwuid(-1) and/or getgrgid(-1).
+ */
+ if (gid == (gid_t) -1) gid = (gid_t) -2;
+ if (uid == (uid_t) -1) uid = (uid_t) -2;
+
+ errno = 0;
+ if (setgroups (1, &gid) < 0)
+ sgs_errno = errno ? errno : -1;
+
+ errno = 0;
+ if (setgid (gid) != 0)
+ gid_errno = errno ? errno : -1;
+
+ errno = 0;
+ if (setuid (uid) != 0)
+ uid_errno = errno ? errno : -1;
+
+ if (uid_errno == 0 && gid_errno == 0 && sgs_errno == 0)
+ {
+ static char *reason;
+ reason = g_strdup_printf ("changed uid/gid to %s/%s (%ld/%ld).",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) uid, (long) gid);
+ if (message_ret)
+ *message_ret = g_strdup (reason);
+
+ g_free (reason);
+
+ return TRUE;
+ }
+ else
+ {
+ char *reason = NULL;
+
+ if (sgs_errno)
+ {
+ reason = g_strdup_printf ("couldn't setgroups to %s (%ld)",
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) gid);
+ if (sgs_errno == -1)
+ fprintf (stderr, "%s: unknown error\n", reason);
+ else
+ {
+ errno = sgs_errno;
+ perror (reason);
+ }
+ g_free (reason);
+ reason = NULL;
+ }
+
+ if (gid_errno)
+ {
+ reason = g_strdup_printf ("couldn't set gid to %s (%ld)",
+ (g && g->gr_name ? g->gr_name : "???"),
+ (long) gid);
+ if (gid_errno == -1)
+ fprintf (stderr, "%s: unknown error\n", reason);
+ else
+ {
+ errno = gid_errno;
+ perror (reason);
+ }
+ g_free (reason);
+ reason = NULL;
+ }
+
+ if (uid_errno)
+ {
+ reason = g_strdup_printf ("couldn't set uid to %s (%ld)",
+ (p && p->pw_name ? p->pw_name : "???"),
+ (long) uid);
+ if (uid_errno == -1)
+ fprintf (stderr, "%s: unknown error\n", reason);
+ else
+ {
+ errno = uid_errno;
+ perror (reason);
+ }
+ g_free (reason);
+ reason = NULL;
+ }
+ return FALSE;
+ }
+ return FALSE;
}
@@ -174,83 +174,83 @@ hack_uid (char **nolock_reason,
char **orig_uid,
char **uid_message)
{
- char *reason;
- gboolean ret;
-
- ret = TRUE;
- reason = NULL;
-
- if (nolock_reason != NULL)
- {
- *nolock_reason = NULL;
- }
- if (orig_uid != NULL)
- {
- *orig_uid = NULL;
- }
- if (uid_message != NULL)
- {
- *uid_message = NULL;
- }
-
- /* Discard privileges, and set the effective user/group ids to the
- real user/group ids. That is, give up our "chmod +s" rights.
- */
- {
- uid_t euid = geteuid ();
- gid_t egid = getegid ();
- uid_t uid = getuid ();
- gid_t gid = getgid ();
-
- if (orig_uid != NULL)
- {
- *orig_uid = uid_gid_string (euid, egid);
- }
-
- if (uid != euid || gid != egid)
- {
+ char *reason;
+ gboolean ret;
+
+ ret = TRUE;
+ reason = NULL;
+
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = NULL;
+ }
+ if (orig_uid != NULL)
+ {
+ *orig_uid = NULL;
+ }
+ if (uid_message != NULL)
+ {
+ *uid_message = NULL;
+ }
+
+ /* Discard privileges, and set the effective user/group ids to the
+ real user/group ids. That is, give up our "chmod +s" rights.
+ */
+ {
+ uid_t euid = geteuid ();
+ gid_t egid = getegid ();
+ uid_t uid = getuid ();
+ gid_t gid = getgid ();
+
+ if (orig_uid != NULL)
+ {
+ *orig_uid = uid_gid_string (euid, egid);
+ }
+
+ if (uid != euid || gid != egid)
+ {
#ifdef HAVE_BSDAUTH /* we need to setgid auth to run the bsd_auth(3) login_* helpers */
- struct group *authg = getgrnam("auth");
- if (!authg || !authg->gr_name || !*authg->gr_name) {
- reason = g_strdup ("no such group as \"auth\" for bsdauth.");
- ret = FALSE;
- goto out;
- }
- gid = authg->gr_gid;
+ struct group *authg = getgrnam("auth");
+ if (!authg || !authg->gr_name || !*authg->gr_name) {
+ reason = g_strdup ("no such group as \"auth\" for bsdauth.");
+ ret = FALSE;
+ goto out;
+ }
+ gid = authg->gr_gid;
#endif /* !HAVE_BSDAUTH */
- if (! set_ids_by_number (uid, gid, uid_message))
- {
- reason = g_strdup ("unable to discard privileges.");
-
- ret = FALSE;
- goto out;
- }
- }
- }
-
-
- /* Locking can't work when running as root, because we have no way of
- knowing what the user id of the logged in user is (so we don't know
- whose password to prompt for.)
-
- *** WARNING: DO NOT DISABLE THIS CODE!
- If you do so, you will open a security hole. See the sections
- of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
- and "USING XDM".
- */
- if (getuid () == (uid_t) 0)
- {
- reason = g_strdup ("running as root");
- ret = FALSE;
- goto out;
- }
+ if (! set_ids_by_number (uid, gid, uid_message))
+ {
+ reason = g_strdup ("unable to discard privileges.");
+
+ ret = FALSE;
+ goto out;
+ }
+ }
+ }
+
+
+ /* Locking can't work when running as root, because we have no way of
+ knowing what the user id of the logged in user is (so we don't know
+ whose password to prompt for.)
+
+ *** WARNING: DO NOT DISABLE THIS CODE!
+ If you do so, you will open a security hole. See the sections
+ of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+ and "USING XDM".
+ */
+ if (getuid () == (uid_t) 0)
+ {
+ reason = g_strdup ("running as root");
+ ret = FALSE;
+ goto out;
+ }
out:
- if (nolock_reason != NULL)
- {
- *nolock_reason = g_strdup (reason);
- }
- g_free (reason);
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup (reason);
+ }
+ g_free (reason);
- return ret;
+ return ret;
}
diff --git a/src/setuid.h b/src/setuid.h
index 89b0b8e..00d9fab 100644
--- a/src/setuid.h
+++ b/src/setuid.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* xscreensaver, Copyright (c) 1993-2004 Jamie Zawinski <jwz at jwz.org>
*
diff --git a/src/subprocs.c b/src/subprocs.c
index 757daf8..caa1a26 100644
--- a/src/subprocs.c
+++ b/src/subprocs.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* subprocs.c --- choosing, spawning, and killing screenhacks.
*
@@ -25,18 +25,18 @@
# include <errno.h>
#endif
-#include <sys/time.h> /* sys/resource.h needs this for timeval */
-# include <sys/wait.h> /* for waitpid() and associated macros */
+#include <sys/time.h> /* sys/resource.h needs this for timeval */
+# include <sys/wait.h> /* for waitpid() and associated macros */
#ifdef VMS
# include <processes.h>
-# include <unixio.h> /* for close */
-# include <unixlib.h> /* for getpid */
+# include <unixio.h> /* for close */
+# include <unixlib.h> /* for getpid */
# define pid_t int
# define fork vfork
#endif /* VMS */
-#include <signal.h> /* for the signal names */
+#include <signal.h> /* for the signal names */
#include <glib.h>
#include "subprocs.h"
@@ -59,19 +59,19 @@ int
block_sigchld (void)
{
#ifdef HAVE_SIGACTION
- sigset_t child_set;
- sigemptyset (&child_set);
- sigaddset (&child_set, SIGCHLD);
- sigaddset (&child_set, SIGPIPE);
- sigprocmask (SIG_BLOCK, &child_set, 0);
+ sigset_t child_set;
+ sigemptyset (&child_set);
+ sigaddset (&child_set, SIGCHLD);
+ sigaddset (&child_set, SIGPIPE);
+ sigprocmask (SIG_BLOCK, &child_set, 0);
#endif /* HAVE_SIGACTION */
- block_sigchld_handler++;
+ block_sigchld_handler++;
#ifdef HAVE_SIGACTION
- return child_set;
+ return child_set;
#else /* !HAVE_SIGACTION */
- return 0;
+ return 0;
#endif /* !HAVE_SIGACTION */
}
@@ -79,51 +79,51 @@ void
unblock_sigchld (void)
{
#ifdef HAVE_SIGACTION
- sigset_t child_set;
- sigemptyset (&child_set);
- sigaddset (&child_set, SIGCHLD);
- sigaddset (&child_set, SIGPIPE);
- sigprocmask (SIG_UNBLOCK, &child_set, 0);
+ sigset_t child_set;
+ sigemptyset (&child_set);
+ sigaddset (&child_set, SIGCHLD);
+ sigaddset (&child_set, SIGPIPE);
+ sigprocmask (SIG_UNBLOCK, &child_set, 0);
#endif /* HAVE_SIGACTION */
- block_sigchld_handler--;
+ block_sigchld_handler--;
}
int
-signal_pid (int pid,
- int signal)
+signal_pid (int pid,
+ int signal)
{
- int status = -1;
- gboolean verbose = TRUE;
+ int status = -1;
+ gboolean verbose = TRUE;
- if (block_sigchld_handler)
- /* This function should not be called from the signal handler. */
- abort();
+ if (block_sigchld_handler)
+ /* This function should not be called from the signal handler. */
+ abort();
- block_sigchld (); /* we control the horizontal... */
+ block_sigchld (); /* we control the horizontal... */
- status = kill (pid, signal);
+ status = kill (pid, signal);
- if (verbose && status < 0)
- {
- if (errno == ESRCH)
- g_message ("Child process %lu was already dead.",
- (unsigned long) pid);
- else
- {
- char buf [1024];
- snprintf (buf, sizeof (buf), "Couldn't kill child process %lu",
- (unsigned long) pid);
- perror (buf);
- }
- }
+ if (verbose && status < 0)
+ {
+ if (errno == ESRCH)
+ g_message ("Child process %lu was already dead.",
+ (unsigned long) pid);
+ else
+ {
+ char buf [1024];
+ snprintf (buf, sizeof (buf), "Couldn't kill child process %lu",
+ (unsigned long) pid);
+ perror (buf);
+ }
+ }
- unblock_sigchld ();
+ unblock_sigchld ();
- if (block_sigchld_handler < 0)
- abort ();
+ if (block_sigchld_handler < 0)
+ abort ();
- return status;
+ return status;
}
#ifndef VMS
@@ -132,35 +132,35 @@ void
await_dying_children (int pid,
gboolean debug)
{
- while (1)
- {
- int wait_status = 0;
- pid_t kid;
-
- errno = 0;
- kid = waitpid (-1, &wait_status, WNOHANG|WUNTRACED);
-
- if (debug)
- {
- if (kid < 0 && errno)
- g_message ("waitpid(%d) ==> %ld (%d)", pid, (long) kid, errno);
- else if (kid != 0)
- g_message ("waitpid(%d) ==> %ld", pid, (long) kid);
- }
-
- /* 0 means no more children to reap.
- -1 means error -- except "interrupted system call" isn't a "real"
- error, so if we get that, we should just try again. */
- if (kid < 0 && errno != EINTR)
- break;
- }
+ while (1)
+ {
+ int wait_status = 0;
+ pid_t kid;
+
+ errno = 0;
+ kid = waitpid (-1, &wait_status, WNOHANG|WUNTRACED);
+
+ if (debug)
+ {
+ if (kid < 0 && errno)
+ g_message ("waitpid(%d) ==> %ld (%d)", pid, (long) kid, errno);
+ else if (kid != 0)
+ g_message ("waitpid(%d) ==> %ld", pid, (long) kid);
+ }
+
+ /* 0 means no more children to reap.
+ -1 means error -- except "interrupted system call" isn't a "real"
+ error, so if we get that, we should just try again. */
+ if (kid < 0 && errno != EINTR)
+ break;
+ }
}
#else /* VMS */
static void await_dying_children (saver_info *si)
{
- return;
+ return;
}
#endif /* VMS */
diff --git a/src/subprocs.h b/src/subprocs.h
index a3acf22..4aed9b1 100644
--- a/src/subprocs.h
+++ b/src/subprocs.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* subprocs.c --- choosing, spawning, and killing screenhacks.
*
@@ -30,8 +30,8 @@ int
#endif /* !HAVE_SIGACTION */
block_sigchld (void);
-int signal_pid (int pid,
- int signal);
+int signal_pid (int pid,
+ int signal);
void await_dying_children (int pid,
gboolean debug);
diff --git a/src/test-fade.c b/src/test-fade.c
index a6773fd..ef8963b 100644
--- a/src/test-fade.c
+++ b/src/test-fade.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -47,88 +47,87 @@
static void
test_fade (void)
{
- GSFade *fade;
- int reps = 2;
- int delay = 2;
+ GSFade *fade;
+ int reps = 2;
+ int delay = 2;
- fade = gs_fade_new ();
+ fade = gs_fade_new ();
- while (reps-- > 0)
- {
+ while (reps-- > 0)
+ {
+ g_print ("fading out...");
+ gs_fade_sync (fade, 1000);
+ g_print ("done.\n");
- g_print ("fading out...");
- gs_fade_sync (fade, 1000);
- g_print ("done.\n");
+ g_print ("fading in...");
+ gs_fade_reset (fade);
+ g_print ("done.\n");
- g_print ("fading in...");
- gs_fade_reset (fade);
- g_print ("done.\n");
+ if (delay)
+ {
+ sleep (delay);
+ }
+ }
- if (delay)
- {
- sleep (delay);
- }
- }
-
- g_object_unref (fade);
+ g_object_unref (fade);
}
int
main (int argc,
char **argv)
{
- GError *error = NULL;
- int op, event, err;
+ GError *error = NULL;
+ int op, event, err;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- if (error)
- {
- fprintf (stderr, "%s\n", error->message);
- exit (1);
- }
-
- if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- fprintf (stderr, "%s", error->message);
- g_error_free (error);
- exit (1);
- }
-
- if (! XQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XF86_VIDMODE_NAME, &op, &event, &err))
- {
- g_message ("no " XF86_VIDMODE_NAME " extension");
- }
- else
- {
+ if (error)
+ {
+ fprintf (stderr, "%s\n", error->message);
+ exit (1);
+ }
+
+ if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
+ {
+ fprintf (stderr, "%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ if (! XQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XF86_VIDMODE_NAME, &op, &event, &err))
+ {
+ g_message ("no " XF86_VIDMODE_NAME " extension");
+ }
+ else
+ {
# ifdef HAVE_XF86VMODE_GAMMA
- int major;
- int minor;
-
- if (! XF86VidModeQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor))
- {
- g_message ("unable to get " XF86_VIDMODE_NAME " version");
- }
- else
- {
- g_message (XF86_VIDMODE_NAME " version %d.%d", major, minor);
- }
+ int major;
+ int minor;
+
+ if (! XF86VidModeQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor))
+ {
+ g_message ("unable to get " XF86_VIDMODE_NAME " version");
+ }
+ else
+ {
+ g_message (XF86_VIDMODE_NAME " version %d.%d", major, minor);
+ }
# else /* !HAVE_XF86VMODE_GAMMA */
- g_message ("no support for display's " XF86_VIDMODE_NAME " extension");
+ g_message ("no support for display's " XF86_VIDMODE_NAME " extension");
# endif /* !HAVE_XF86VMODE_GAMMA */
- }
+ }
- gs_debug_init (TRUE, FALSE);
+ gs_debug_init (TRUE, FALSE);
- test_fade ();
+ test_fade ();
- gs_debug_shutdown ();
+ gs_debug_shutdown ();
- return 0;
+ return 0;
}
diff --git a/src/test-passwd.c b/src/test-passwd.c
index dfd1d72..96f23c2 100644
--- a/src/test-passwd.c
+++ b/src/test-passwd.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -43,33 +43,33 @@
static gboolean
privileged_initialization (void)
{
- gboolean ret;
- char *nolock_reason;
- char *orig_uid;
- char *uid_message;
+ gboolean ret;
+ char *nolock_reason;
+ char *orig_uid;
+ char *uid_message;
#ifndef NO_LOCKING
- /* before hack_uid () for proper permissions */
- gs_auth_priv_init ();
+ /* before hack_uid () for proper permissions */
+ gs_auth_priv_init ();
#endif /* NO_LOCKING */
- ret = hack_uid (&nolock_reason,
- &orig_uid,
- &uid_message);
- if (nolock_reason)
- {
- g_warning ("Locking disabled: %s", nolock_reason);
- }
- if (uid_message && gs_auth_get_verbose ())
- {
- g_print ("Modified UID: %s", uid_message);
- }
-
- g_free (nolock_reason);
- g_free (orig_uid);
- g_free (uid_message);
-
- return ret;
+ ret = hack_uid (&nolock_reason,
+ &orig_uid,
+ &uid_message);
+ if (nolock_reason)
+ {
+ g_warning ("Locking disabled: %s", nolock_reason);
+ }
+ if (uid_message && gs_auth_get_verbose ())
+ {
+ g_print ("Modified UID: %s", uid_message);
+ }
+
+ g_free (nolock_reason);
+ g_free (orig_uid);
+ g_free (uid_message);
+
+ return ret;
}
@@ -78,206 +78,206 @@ privileged_initialization (void)
static gboolean
lock_initialization (char **nolock_reason)
{
- if (nolock_reason)
- {
- *nolock_reason = NULL;
- }
+ if (nolock_reason)
+ {
+ *nolock_reason = NULL;
+ }
#ifdef NO_LOCKING
- if (nolock_reason)
- {
- *nolock_reason = g_strdup ("not compiled with locking support");
- }
- return FALSE;
+ if (nolock_reason)
+ {
+ *nolock_reason = g_strdup ("not compiled with locking support");
+ }
+ return FALSE;
#else /* !NO_LOCKING */
- /* Finish initializing locking, now that we're out of privileged code. */
- if (! gs_auth_init ())
- {
- if (nolock_reason)
- {
- *nolock_reason = g_strdup ("error getting password");
- }
- return FALSE;
- }
-
- /* If locking is currently enabled, but the environment indicates that
- we have been launched as MDM's "Background" program, then disable
- locking just in case.
- */
- if (getenv ("RUNNING_UNDER_MDM"))
- {
- if (nolock_reason)
- {
- *nolock_reason = g_strdup ("running under MDM");
- }
- return FALSE;
- }
-
- /* If the server is XDarwin (MacOS X) then disable locking.
- (X grabs only affect X programs, so you can use Command-Tab
- to bring any other Mac program to the front, e.g., Terminal.)
- */
- {
- gboolean macos = FALSE;
+ /* Finish initializing locking, now that we're out of privileged code. */
+ if (! gs_auth_init ())
+ {
+ if (nolock_reason)
+ {
+ *nolock_reason = g_strdup ("error getting password");
+ }
+ return FALSE;
+ }
+
+ /* If locking is currently enabled, but the environment indicates that
+ we have been launched as MDM's "Background" program, then disable
+ locking just in case.
+ */
+ if (getenv ("RUNNING_UNDER_MDM"))
+ {
+ if (nolock_reason)
+ {
+ *nolock_reason = g_strdup ("running under MDM");
+ }
+ return FALSE;
+ }
+
+ /* If the server is XDarwin (MacOS X) then disable locking.
+ (X grabs only affect X programs, so you can use Command-Tab
+ to bring any other Mac program to the front, e.g., Terminal.)
+ */
+ {
+ gboolean macos = FALSE;
#ifdef __APPLE__
- /* Disable locking if *running* on Apple hardware, since we have no
- reliable way to determine whether the server is running on MacOS.
- Hopefully __APPLE__ means "MacOS" and not "Linux on Mac hardware"
- but I'm not really sure about that.
- */
- macos = TRUE;
+ /* Disable locking if *running* on Apple hardware, since we have no
+ reliable way to determine whether the server is running on MacOS.
+ Hopefully __APPLE__ means "MacOS" and not "Linux on Mac hardware"
+ but I'm not really sure about that.
+ */
+ macos = TRUE;
#endif
- if (macos)
- {
- if (nolock_reason)
- {
- *nolock_reason = g_strdup ("Cannot lock securely on MacOS X");
- }
- return FALSE;
- }
- }
+ if (macos)
+ {
+ if (nolock_reason)
+ {
+ *nolock_reason = g_strdup ("Cannot lock securely on MacOS X");
+ }
+ return FALSE;
+ }
+ }
#endif /* NO_LOCKING */
- return TRUE;
+ return TRUE;
}
static char *
request_password (const char *prompt)
{
- char buf [255];
- char *pass;
- char *password;
- struct termios ts0;
- struct termios ts1;
+ char buf [255];
+ char *pass;
+ char *password;
+ struct termios ts0;
+ struct termios ts1;
- tcgetattr (fileno (stdin), &ts0);
- ts1 = ts0;
- ts1.c_lflag &= ~ECHO;
+ tcgetattr (fileno (stdin), &ts0);
+ ts1 = ts0;
+ ts1.c_lflag &= ~ECHO;
- printf ("%s", prompt);
+ printf ("%s", prompt);
- if (tcsetattr (fileno (stdin), TCSAFLUSH, &ts1) != 0)
- {
- fprintf (stderr, "Could not set terminal attributes\n");
- exit (1);
- }
+ if (tcsetattr (fileno (stdin), TCSAFLUSH, &ts1) != 0)
+ {
+ fprintf (stderr, "Could not set terminal attributes\n");
+ exit (1);
+ }
- pass = fgets (buf, sizeof (buf) - 1, stdin);
+ pass = fgets (buf, sizeof (buf) - 1, stdin);
- tcsetattr (fileno (stdin), TCSANOW, &ts0);
+ tcsetattr (fileno (stdin), TCSANOW, &ts0);
- if (!pass || !*pass)
- {
- exit (0);
- }
+ if (!pass || !*pass)
+ {
+ exit (0);
+ }
- if (pass [strlen (pass) - 1] == '\n')
- {
- pass [strlen (pass) - 1] = 0;
- }
+ if (pass [strlen (pass) - 1] == '\n')
+ {
+ pass [strlen (pass) - 1] = 0;
+ }
- password = g_strdup (pass);
+ password = g_strdup (pass);
- memset (pass, '\b', strlen (pass));
+ memset (pass, '\b', strlen (pass));
- return password;
+ return password;
}
static gboolean
-auth_message_handler (GSAuthMessageStyle style,
- const char *msg,
- char **response,
- gpointer data)
+auth_message_handler (GSAuthMessageStyle style,
+ const char *msg,
+ char **response,
+ gpointer data)
{
- gboolean ret;
-
- g_message ("Got message style %d: '%s'", style, msg);
-
- ret = TRUE;
-
- switch (style)
- {
- case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
- break;
- case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
- {
- char *password;
- password = request_password (msg);
- *response = password;
- }
- break;
- case GS_AUTH_MESSAGE_ERROR_MSG:
- break;
- case GS_AUTH_MESSAGE_TEXT_INFO:
- break;
- default:
- g_assert_not_reached ();
- }
-
- return ret;
+ gboolean ret;
+
+ g_message ("Got message style %d: '%s'", style, msg);
+
+ ret = TRUE;
+
+ switch (style)
+ {
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
+ break;
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
+ {
+ char *password;
+ password = request_password (msg);
+ *response = password;
+ }
+ break;
+ case GS_AUTH_MESSAGE_ERROR_MSG:
+ break;
+ case GS_AUTH_MESSAGE_TEXT_INFO:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ return ret;
}
int
main (int argc,
char **argv)
{
- GError *error = NULL;
- gboolean verbose = TRUE;
- char *nolock_reason = NULL;
+ GError *error = NULL;
+ gboolean verbose = TRUE;
+ char *nolock_reason = NULL;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- gs_auth_set_verbose (verbose);
- if (! privileged_initialization ())
- {
- exit (1);
- }
-
- if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- fprintf (stderr, "%s", error->message);
- g_error_free (error);
- exit (1);
- }
-
- if (! lock_initialization (&nolock_reason))
- {
- if (nolock_reason)
- {
- g_warning ("Screen locking disabled: %s", nolock_reason);
- g_free (nolock_reason);
- }
-
- exit (1);
- }
+ gs_auth_set_verbose (verbose);
+ if (! privileged_initialization ())
+ {
+ exit (1);
+ }
+
+ if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
+ {
+ fprintf (stderr, "%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ if (! lock_initialization (&nolock_reason))
+ {
+ if (nolock_reason)
+ {
+ g_warning ("Screen locking disabled: %s", nolock_reason);
+ g_free (nolock_reason);
+ }
+
+ exit (1);
+ }
again:
- error = NULL;
-
- if (gs_auth_verify_user (g_get_user_name (), g_getenv ("DISPLAY"), auth_message_handler, NULL, &error))
- {
- printf ("Correct!\n");
- }
- else
- {
- if (error != NULL)
- {
- fprintf (stderr, "ERROR: %s\n", error->message);
- g_error_free (error);
- }
- printf ("Incorrect\n");
- goto again;
- }
-
- return 0;
+ error = NULL;
+
+ if (gs_auth_verify_user (g_get_user_name (), g_getenv ("DISPLAY"), auth_message_handler, NULL, &error))
+ {
+ printf ("Correct!\n");
+ }
+ else
+ {
+ if (error != NULL)
+ {
+ fprintf (stderr, "ERROR: %s\n", error->message);
+ g_error_free (error);
+ }
+ printf ("Incorrect\n");
+ goto again;
+ }
+
+ return 0;
}
diff --git a/src/test-watcher.c b/src/test-watcher.c
index 4f49886..afeb660 100644
--- a/src/test-watcher.c
+++ b/src/test-watcher.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -36,10 +36,10 @@ watcher_idle_cb (GSWatcher *watcher,
gboolean is_idle,
gpointer data)
{
- g_message ("Idle status changed: %s", is_idle ? "idle" : "not idle");
+ g_message ("Idle status changed: %s", is_idle ? "idle" : "not idle");
- /* return FALSE so that the idle watcher continues */
- return FALSE;
+ /* return FALSE so that the idle watcher continues */
+ return FALSE;
}
static gboolean
@@ -47,60 +47,60 @@ watcher_idle_notice_cb (GSWatcher *watcher,
gboolean is_idle,
gpointer data)
{
- g_message ("Idle notice status changed: %s", is_idle ? "idle" : "not idle");
+ g_message ("Idle notice status changed: %s", is_idle ? "idle" : "not idle");
- return TRUE;
+ return TRUE;
}
static void
connect_watcher_signals (GSWatcher *watcher)
{
- g_signal_connect (watcher, "idle-changed",
- G_CALLBACK (watcher_idle_cb), NULL);
- g_signal_connect (watcher, "idle-notice-changed",
- G_CALLBACK (watcher_idle_notice_cb), NULL);
+ g_signal_connect (watcher, "idle-changed",
+ G_CALLBACK (watcher_idle_cb), NULL);
+ g_signal_connect (watcher, "idle-notice-changed",
+ G_CALLBACK (watcher_idle_notice_cb), NULL);
}
static void
test_watcher (void)
{
- GSWatcher *watcher;
+ GSWatcher *watcher;
- watcher = gs_watcher_new ();
- gs_watcher_set_enabled (watcher, TRUE);
- gs_watcher_set_active (watcher, TRUE);
+ watcher = gs_watcher_new ();
+ gs_watcher_set_enabled (watcher, TRUE);
+ gs_watcher_set_active (watcher, TRUE);
- connect_watcher_signals (watcher);
+ connect_watcher_signals (watcher);
}
int
main (int argc,
char **argv)
{
- GError *error = NULL;
+ GError *error = NULL;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- fprintf (stderr, "%s", error->message);
- g_error_free (error);
- exit (1);
- }
+ if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
+ {
+ fprintf (stderr, "%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
- gs_debug_init (TRUE, FALSE);
+ gs_debug_init (TRUE, FALSE);
- test_watcher ();
+ test_watcher ();
- gtk_main ();
+ gtk_main ();
- gs_debug_shutdown ();
+ gs_debug_shutdown ();
- return 0;
+ return 0;
}
diff --git a/src/test-window.c b/src/test-window.c
index 234e34b..580f0ce 100644
--- a/src/test-window.c
+++ b/src/test-window.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -35,145 +35,145 @@
static GSGrab *grab = NULL;
static void
-window_deactivated_cb (GSWindow *window,
- gpointer data)
+window_deactivated_cb (GSWindow *window,
+ gpointer data)
{
- gs_window_destroy (window);
+ gs_window_destroy (window);
}
static void
-window_dialog_up_cb (GSWindow *window,
- gpointer data)
+window_dialog_up_cb (GSWindow *window,
+ gpointer data)
{
}
static void
-window_dialog_down_cb (GSWindow *window,
- gpointer data)
+window_dialog_down_cb (GSWindow *window,
+ gpointer data)
{
}
static void
-window_show_cb (GSWindow *window,
- gpointer data)
+window_show_cb (GSWindow *window,
+ gpointer data)
{
- /* move devices grab so that dialog can be used */
- gs_grab_move_to_window (grab,
- gs_window_get_gdk_window (window),
- gs_window_get_display (window),
- TRUE, FALSE);
+ /* move devices grab so that dialog can be used */
+ gs_grab_move_to_window (grab,
+ gs_window_get_gdk_window (window),
+ gs_window_get_display (window),
+ TRUE, FALSE);
}
static gboolean
-window_activity_cb (GSWindow *window,
- gpointer data)
+window_activity_cb (GSWindow *window,
+ gpointer data)
{
- gs_window_request_unlock (window);
+ gs_window_request_unlock (window);
- return TRUE;
+ return TRUE;
}
static void
disconnect_window_signals (GSWindow *window)
{
- gpointer data;
-
- data = NULL;
- g_signal_handlers_disconnect_by_func (window, window_activity_cb, data);
- g_signal_handlers_disconnect_by_func (window, window_deactivated_cb, data);
- g_signal_handlers_disconnect_by_func (window, window_dialog_up_cb, data);
- g_signal_handlers_disconnect_by_func (window, window_dialog_down_cb, data);
- g_signal_handlers_disconnect_by_func (window, window_show_cb, data);
+ gpointer data;
+
+ data = NULL;
+ g_signal_handlers_disconnect_by_func (window, window_activity_cb, data);
+ g_signal_handlers_disconnect_by_func (window, window_deactivated_cb, data);
+ g_signal_handlers_disconnect_by_func (window, window_dialog_up_cb, data);
+ g_signal_handlers_disconnect_by_func (window, window_dialog_down_cb, data);
+ g_signal_handlers_disconnect_by_func (window, window_show_cb, data);
}
static void
window_destroyed_cb (GtkWindow *window,
gpointer data)
{
- disconnect_window_signals (GS_WINDOW (window));
- gs_grab_release (grab, TRUE);
- gtk_main_quit ();
+ disconnect_window_signals (GS_WINDOW (window));
+ gs_grab_release (grab, TRUE);
+ gtk_main_quit ();
}
static void
connect_window_signals (GSWindow *window)
{
- gpointer data;
-
- data = NULL;
-
- g_signal_connect_object (window, "activity",
- G_CALLBACK (window_activity_cb), data, 0);
- g_signal_connect_object (window, "destroy",
- G_CALLBACK (window_destroyed_cb), data, 0);
- g_signal_connect_object (window, "deactivated",
- G_CALLBACK (window_deactivated_cb), data, 0);
- g_signal_connect_object (window, "dialog-up",
- G_CALLBACK (window_dialog_up_cb), data, 0);
- g_signal_connect_object (window, "dialog-down",
- G_CALLBACK (window_dialog_down_cb), data, 0);
- g_signal_connect_object (window, "show",
- G_CALLBACK (window_show_cb), data, 0);
+ gpointer data;
+
+ data = NULL;
+
+ g_signal_connect_object (window, "activity",
+ G_CALLBACK (window_activity_cb), data, 0);
+ g_signal_connect_object (window, "destroy",
+ G_CALLBACK (window_destroyed_cb), data, 0);
+ g_signal_connect_object (window, "deactivated",
+ G_CALLBACK (window_deactivated_cb), data, 0);
+ g_signal_connect_object (window, "dialog-up",
+ G_CALLBACK (window_dialog_up_cb), data, 0);
+ g_signal_connect_object (window, "dialog-down",
+ G_CALLBACK (window_dialog_down_cb), data, 0);
+ g_signal_connect_object (window, "show",
+ G_CALLBACK (window_show_cb), data, 0);
}
static void
test_window (void)
{
- GSWindow *window;
- gboolean lock_active;
- gboolean user_switch_enabled;
- GdkDisplay *display;
- GdkMonitor *monitor;
+ GSWindow *window;
+ gboolean lock_active;
+ gboolean user_switch_enabled;
+ GdkDisplay *display;
+ GdkMonitor *monitor;
- lock_active = TRUE;
- user_switch_enabled = TRUE;
- display = gdk_display_get_default ();
- monitor = gdk_display_get_primary_monitor (display);
+ lock_active = TRUE;
+ user_switch_enabled = TRUE;
+ display = gdk_display_get_default ();
+ monitor = gdk_display_get_primary_monitor (display);
- window = gs_window_new (monitor, lock_active);
+ window = gs_window_new (monitor, lock_active);
- gs_window_set_user_switch_enabled (window, user_switch_enabled);
+ gs_window_set_user_switch_enabled (window, user_switch_enabled);
- connect_window_signals (window);
+ connect_window_signals (window);
- gs_window_show (window);
+ gs_window_show (window);
}
int
main (int argc,
char **argv)
{
- GError *error = NULL;
+ GError *error = NULL;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- fprintf (stderr, "%s", error->message);
- g_error_free (error);
- exit (1);
- }
+ if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
+ {
+ fprintf (stderr, "%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
- gs_debug_init (TRUE, FALSE);
+ gs_debug_init (TRUE, FALSE);
- grab = gs_grab_new ();
+ grab = gs_grab_new ();
- test_window ();
+ test_window ();
- /* safety valve in case we can't authenticate */
- g_timeout_add (30000, (GSourceFunc)gtk_main_quit, NULL);
+ /* safety valve in case we can't authenticate */
+ g_timeout_add (30000, (GSourceFunc)gtk_main_quit, NULL);
- gtk_main ();
+ gtk_main ();
- g_object_unref (grab);
+ g_object_unref (grab);
- gs_debug_shutdown ();
+ gs_debug_shutdown ();
- return 0;
+ return 0;
}
diff --git a/src/xfce-bg.c b/src/xfce-bg.c
index 71af4a3..1ad3d84 100644
--- a/src/xfce-bg.c
+++ b/src/xfce-bg.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
xfcebg.c: Object for the desktop background.
@@ -25,7 +25,7 @@ Derived from eel-background.c and eel-gdk-pixbuf-extensions.c by
Darin Adler <darin at eazel.com> and Ramiro Estrugo <ramiro at eazel.com>
Authors: Soren Sandmann <sandmann at redhat.com>
- Jasmine Hassan <jasmine.aura at gmail.com>
+ Jasmine Hassan <jasmine.aura at gmail.com>
*/
@@ -59,19 +59,19 @@ typedef struct _SlideShow SlideShow;
typedef struct _Slide Slide;
struct _Slide {
- double duration; /* in seconds */
- gboolean fixed;
+ double duration; /* in seconds */
+ gboolean fixed;
- GSList* file1;
- GSList* file2; /* NULL if fixed is TRUE */
+ GSList *file1;
+ GSList *file2; /* NULL if fixed is TRUE */
};
typedef struct _FileSize FileSize;
struct _FileSize {
- gint width;
- gint height;
+ gint width;
+ gint height;
- char* file;
+ char *file;
};
/* This is the size of the GdkRGB dither matrix, in order to avoid
@@ -86,37 +86,37 @@ typedef struct FileCacheEntry FileCacheEntry;
* Implementation of the XfceBG class
*/
struct _XfceBG {
- GObject parent_instance;
- char *filename;
- XfceBGPlacement placement;
- XfceBGColorType color_type;
- GdkRGBA primary;
- GdkRGBA secondary;
- gboolean is_enabled;
-
- GFileMonitor* file_monitor;
-
- guint changed_id;
- guint transitioned_id;
- guint blow_caches_id;
-
- /* Cached information, only access through cache accessor functions */
- SlideShow* slideshow;
- time_t file_mtime;
- GdkPixbuf* pixbuf_cache;
- int timeout_id;
-
- GList* file_cache;
+ GObject parent_instance;
+ char *filename;
+ XfceBGPlacement placement;
+ XfceBGColorType color_type;
+ GdkRGBA primary;
+ GdkRGBA secondary;
+ gboolean is_enabled;
+
+ GFileMonitor *file_monitor;
+
+ guint changed_id;
+ guint transitioned_id;
+ guint blow_caches_id;
+
+ /* Cached information, only access through cache accessor functions */
+ SlideShow *slideshow;
+ time_t file_mtime;
+ GdkPixbuf *pixbuf_cache;
+ int timeout_id;
+
+ GList *file_cache;
};
struct _XfceBGClass {
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
enum {
- CHANGED,
- TRANSITIONED,
- N_SIGNALS
+ CHANGED,
+ TRANSITIONED,
+ N_SIGNALS
};
static guint signals[N_SIGNALS] = {0};
@@ -124,354 +124,354 @@ static guint signals[N_SIGNALS] = {0};
G_DEFINE_TYPE(XfceBG, xfce_bg, G_TYPE_OBJECT)
/* Pixbuf utils */
-static GdkPixbuf *pixbuf_scale_to_fit (GdkPixbuf *src,
- int max_width,
- int max_height);
-static GdkPixbuf *pixbuf_scale_to_min (GdkPixbuf *src,
- int min_width,
- int min_height);
-
-static void pixbuf_draw_gradient (GdkPixbuf *pixbuf,
- gboolean horizontal,
- GdkRGBA *c1,
- GdkRGBA *c2,
- GdkRectangle *rect);
-
-static void pixbuf_tile (GdkPixbuf *src,
- GdkPixbuf *dest);
-static void pixbuf_blend (GdkPixbuf *src,
- GdkPixbuf *dest,
- int src_x,
- int src_y,
- int width,
- int height,
- int dest_x,
- int dest_y,
- double alpha);
+static GdkPixbuf * pixbuf_scale_to_fit (GdkPixbuf *src,
+ int max_width,
+ int max_height);
+static GdkPixbuf * pixbuf_scale_to_min (GdkPixbuf *src,
+ int min_width,
+ int min_height);
+
+static void pixbuf_draw_gradient (GdkPixbuf *pixbuf,
+ gboolean horizontal,
+ GdkRGBA *c1,
+ GdkRGBA *c2,
+ GdkRectangle *rect);
+
+static void pixbuf_tile (GdkPixbuf *src,
+ GdkPixbuf *dest);
+static void pixbuf_blend (GdkPixbuf *src,
+ GdkPixbuf *dest,
+ int src_x,
+ int src_y,
+ int width,
+ int height,
+ int dest_x,
+ int dest_y,
+ double alpha);
/* Cache */
-static GdkPixbuf *get_pixbuf_for_size (XfceBG *bg,
- gint num_monitor,
- int width,
- int height);
-static void clear_cache (XfceBG *bg);
-static gboolean is_different (XfceBG *bg,
- const char *filename);
-static time_t get_mtime (const char *filename);
-static SlideShow * get_as_slideshow (XfceBG *bg,
- const char *filename);
-static Slide * get_current_slide (SlideShow *show,
- double *alpha);
-
-static SlideShow *read_slideshow_file (const char *filename,
- GError **err);
-static SlideShow *slideshow_ref (SlideShow *show);
-static void slideshow_unref (SlideShow *show);
-
-static FileSize *find_best_size (GSList *sizes,
- gint width,
- gint height);
-
-static void xfce_bg_set_color(XfceBG *bg,
- XfceBGColorType type,
- GdkRGBA *primary,
- GdkRGBA *secondary);
-
-static void xfce_bg_load_from_xfconf (XfceBG *bg,
- XfconfChannel *channel,
- GdkMonitor *monitor);
-
-static cairo_surface_t * xfce_bg_create_surface_scale (XfceBG *bg,
- GdkWindow *window,
- int screen_width,
- int screen_height,
- int monitor_width,
- int monitor_height,
- int scale);
-
-static void xfce_bg_set_placement (XfceBG *bg,
- XfceBGPlacement placement);
-
-static void xfce_bg_set_filename (XfceBG *bg,
- const char *filename);
-
-static void color_from_array(XfconfChannel *channel,
- const gchar *property,
- GdkRGBA *colorp)
-{
- gdouble r, g, b, a;
-
- /* If all else fails use black */
- gdk_rgba_parse (colorp, "#000000");
-
- if (!xfconf_channel_has_property (channel, property))
- return;
-
- xfconf_channel_get_array(channel,
- property,
- G_TYPE_DOUBLE, &r,
- G_TYPE_DOUBLE, &g,
- G_TYPE_DOUBLE, &b,
- G_TYPE_DOUBLE, &a,
- G_TYPE_INVALID);
-
- colorp->red = r;
- colorp->green = g;
- colorp->blue = b;
- colorp->alpha = a;
+static GdkPixbuf * get_pixbuf_for_size (XfceBG *bg,
+ gint num_monitor,
+ int width,
+ int height);
+static void clear_cache (XfceBG *bg);
+static gboolean is_different (XfceBG *bg,
+ const char *filename);
+static time_t get_mtime (const char *filename);
+static SlideShow * get_as_slideshow (XfceBG *bg,
+ const char *filename);
+static Slide * get_current_slide (SlideShow *show,
+ double *alpha);
+
+static SlideShow * read_slideshow_file (const char *filename,
+ GError **err);
+static SlideShow * slideshow_ref (SlideShow *show);
+static void slideshow_unref (SlideShow *show);
+
+static FileSize * find_best_size (GSList *sizes,
+ gint width,
+ gint height);
+
+static void xfce_bg_set_color (XfceBG *bg,
+ XfceBGColorType type,
+ GdkRGBA *primary,
+ GdkRGBA *secondary);
+
+static void xfce_bg_load_from_xfconf (XfceBG *bg,
+ XfconfChannel *channel,
+ GdkMonitor *monitor);
+
+static cairo_surface_t * xfce_bg_create_surface_scale (XfceBG *bg,
+ GdkWindow *window,
+ int screen_width,
+ int screen_height,
+ int monitor_width,
+ int monitor_height,
+ int scale);
+
+static void xfce_bg_set_placement (XfceBG *bg,
+ XfceBGPlacement placement);
+
+static void xfce_bg_set_filename (XfceBG *bg,
+ const char *filename);
+
+static void color_from_array (XfconfChannel *channel,
+ const gchar *property,
+ GdkRGBA *colorp)
+{
+ gdouble r, g, b, a;
+
+ /* If all else fails use black */
+ gdk_rgba_parse (colorp, "#000000");
+
+ if (!xfconf_channel_has_property (channel, property))
+ return;
+
+ xfconf_channel_get_array(channel,
+ property,
+ G_TYPE_DOUBLE, &r,
+ G_TYPE_DOUBLE, &g,
+ G_TYPE_DOUBLE, &b,
+ G_TYPE_DOUBLE, &a,
+ G_TYPE_INVALID);
+
+ colorp->red = r;
+ colorp->green = g;
+ colorp->blue = b;
+ colorp->alpha = a;
}
static gboolean
do_changed (XfceBG *bg)
{
- bg->changed_id = 0;
+ bg->changed_id = 0;
- g_signal_emit (G_OBJECT (bg), signals[CHANGED], 0);
+ g_signal_emit (G_OBJECT (bg), signals[CHANGED], 0);
- return FALSE;
+ return FALSE;
}
static void
queue_changed (XfceBG *bg)
{
- if (bg->changed_id > 0) {
- g_source_remove (bg->changed_id);
- }
+ if (bg->changed_id > 0) {
+ g_source_remove (bg->changed_id);
+ }
- bg->changed_id = g_timeout_add_full (G_PRIORITY_LOW,
- 100,
- (GSourceFunc)do_changed,
- bg,
- NULL);
+ bg->changed_id = g_timeout_add_full (G_PRIORITY_LOW,
+ 100,
+ (GSourceFunc)do_changed,
+ bg,
+ NULL);
}
static gboolean
do_transitioned (XfceBG *bg)
{
- bg->transitioned_id = 0;
+ bg->transitioned_id = 0;
- if (bg->pixbuf_cache) {
- g_object_unref (bg->pixbuf_cache);
- bg->pixbuf_cache = NULL;
- }
+ if (bg->pixbuf_cache) {
+ g_object_unref (bg->pixbuf_cache);
+ bg->pixbuf_cache = NULL;
+ }
- g_signal_emit (G_OBJECT (bg), signals[TRANSITIONED], 0);
+ g_signal_emit (G_OBJECT (bg), signals[TRANSITIONED], 0);
- return FALSE;
+ return FALSE;
}
static void
queue_transitioned (XfceBG *bg)
{
- if (bg->transitioned_id > 0) {
- g_source_remove (bg->transitioned_id);
- }
+ if (bg->transitioned_id > 0) {
+ g_source_remove (bg->transitioned_id);
+ }
- bg->transitioned_id = g_timeout_add_full (G_PRIORITY_LOW,
- 100,
- (GSourceFunc)do_transitioned,
- bg,
- NULL);
+ bg->transitioned_id = g_timeout_add_full (G_PRIORITY_LOW,
+ 100,
+ (GSourceFunc)do_transitioned,
+ bg,
+ NULL);
}
/* This function loads the user's preferences */
void
-xfce_bg_load_from_preferences (XfceBG *bg,
- GdkMonitor *monitor)
+xfce_bg_load_from_preferences (XfceBG *bg,
+ GdkMonitor *monitor)
{
- XfconfChannel *channel;
+ XfconfChannel *channel;
- channel = xfconf_channel_get ("xfce4-desktop");
- xfce_bg_load_from_xfconf (bg, channel, monitor);
+ channel = xfconf_channel_get ("xfce4-desktop");
+ xfce_bg_load_from_xfconf (bg, channel, monitor);
- /* Queue change to force background redraw */
- queue_changed (bg);
+ /* Queue change to force background redraw */
+ queue_changed (bg);
}
static gboolean
xfce_bg_check_property_prefix (XfconfChannel *channel,
- gchar *prefix)
-{
- gchar *property;
-
- property = g_strconcat (prefix, "/last-image", NULL);
- if (xfconf_channel_has_property (channel, property)) {
- g_free (property);
- return TRUE;
- }
- g_free (property);
-
- property = g_strconcat (prefix, "/image-path", NULL);
- if (xfconf_channel_has_property (channel, property)) {
- g_free (property);
- return TRUE;
- }
- g_free (property);
-
- property = g_strconcat (prefix, "/image-style", NULL);
- if (xfconf_channel_has_property (channel, property)) {
- g_free (property);
- return TRUE;
- }
- g_free (property);
-
- property = g_strconcat (prefix, "/rgba1", NULL);
- if (xfconf_channel_has_property (channel, property)) {
- g_free (property);
- return TRUE;
- }
- g_free (property);
-
- property = g_strconcat (prefix, "/rgba2", NULL);
- if (xfconf_channel_has_property (channel, property)) {
- g_free (property);
- return TRUE;
- }
- g_free (property);
-
- property = g_strconcat (prefix, "/color-style", NULL);
- if (xfconf_channel_has_property (channel, property)) {
- g_free (property);
- return TRUE;
- }
- g_free (property);
-
- return FALSE;
+ gchar *prefix)
+{
+ gchar *property;
+
+ property = g_strconcat (prefix, "/last-image", NULL);
+ if (xfconf_channel_has_property (channel, property)) {
+ g_free (property);
+ return TRUE;
+ }
+ g_free (property);
+
+ property = g_strconcat (prefix, "/image-path", NULL);
+ if (xfconf_channel_has_property (channel, property)) {
+ g_free (property);
+ return TRUE;
+ }
+ g_free (property);
+
+ property = g_strconcat (prefix, "/image-style", NULL);
+ if (xfconf_channel_has_property (channel, property)) {
+ g_free (property);
+ return TRUE;
+ }
+ g_free (property);
+
+ property = g_strconcat (prefix, "/rgba1", NULL);
+ if (xfconf_channel_has_property (channel, property)) {
+ g_free (property);
+ return TRUE;
+ }
+ g_free (property);
+
+ property = g_strconcat (prefix, "/rgba2", NULL);
+ if (xfconf_channel_has_property (channel, property)) {
+ g_free (property);
+ return TRUE;
+ }
+ g_free (property);
+
+ property = g_strconcat (prefix, "/color-style", NULL);
+ if (xfconf_channel_has_property (channel, property)) {
+ g_free (property);
+ return TRUE;
+ }
+ g_free (property);
+
+ return FALSE;
}
static gchar*
xfce_bg_get_property_prefix (XfconfChannel *channel,
- const gchar *monitor_name)
-{
- gchar *prefix;
-
- /* Check for workspace usage */
- prefix = g_strconcat("/backdrop/screen0/monitor", monitor_name, "/workspace0", NULL);
- if (xfce_bg_check_property_prefix (channel, prefix))
- {
- return prefix;
- }
- g_free(prefix);
-
- /* Check for non-workspace usage */
- prefix = g_strconcat("/backdrop/screen0/monitor", monitor_name, NULL);
- if (xfce_bg_check_property_prefix (channel, prefix))
- {
- return prefix;
- }
- g_free(prefix);
-
- /* Check defaults */
- prefix = g_strdup("/backdrop/screen0/monitor0/workspace0");
- if (xfce_bg_check_property_prefix (channel, prefix))
- {
- return prefix;
- }
- g_free(prefix);
-
- prefix = g_strdup("/backdrop/screen0/monitor0");
- return prefix;
+ const gchar *monitor_name)
+{
+ gchar *prefix;
+
+ /* Check for workspace usage */
+ prefix = g_strconcat("/backdrop/screen0/monitor", monitor_name, "/workspace0", NULL);
+ if (xfce_bg_check_property_prefix (channel, prefix))
+ {
+ return prefix;
+ }
+ g_free(prefix);
+
+ /* Check for non-workspace usage */
+ prefix = g_strconcat("/backdrop/screen0/monitor", monitor_name, NULL);
+ if (xfce_bg_check_property_prefix (channel, prefix))
+ {
+ return prefix;
+ }
+ g_free(prefix);
+
+ /* Check defaults */
+ prefix = g_strdup("/backdrop/screen0/monitor0/workspace0");
+ if (xfce_bg_check_property_prefix (channel, prefix))
+ {
+ return prefix;
+ }
+ g_free(prefix);
+
+ prefix = g_strdup("/backdrop/screen0/monitor0");
+ return prefix;
}
static void
xfce_bg_load_from_xfconf (XfceBG *bg,
- XfconfChannel *channel,
- GdkMonitor *monitor)
-{
- char *tmp;
- char *filename;
- XfceBGColorType ctype;
- GdkRGBA c1, c2;
- XfceBGPlacement placement;
- GdkMonitor *mon;
- const gchar *monitor_name;
- gchar *prop_prefix;
- gchar *property;
-
- g_return_if_fail(XFCE_IS_BG(bg));
- //g_return_if_fail (G_IS_SETTINGS (settings));
-
- if (monitor == NULL)
- {
- GdkDisplay *display = gdk_display_get_default();
- mon = gdk_display_get_primary_monitor(display);
- if (mon == NULL)
- {
- mon = gdk_display_get_monitor(display, 0);
- }
- }
- else
- {
- mon = monitor;
- }
-
- monitor_name = gdk_monitor_get_model(mon);
- prop_prefix = xfce_bg_get_property_prefix (channel, monitor_name);
-
- property = g_strconcat(prop_prefix, "/image-style", NULL);
- placement = xfconf_channel_get_int(channel, property, XFCE_BG_PLACEMENT_NONE);
- bg->is_enabled = placement != XFCE_BG_PLACEMENT_NONE;
-
- /* Filename */
- g_free(property);
- property = g_strconcat(prop_prefix, "/last-image", NULL);
- if (!xfconf_channel_has_property (channel, property)) {
- g_free(property);
- property = g_strconcat(prop_prefix, "/image-path", NULL);
- }
- filename = NULL;
- tmp = xfconf_channel_get_string(channel, property, XFCE_BG_FALLBACK_IMG);
- if (tmp && *tmp != '\0') {
- /* FIXME: UTF-8 checks should go away.
- * picture-filename is of type string, which can only be used for
- * UTF-8 strings, and some filenames are not, dependending on the
- * locale used.
- * It would be better (and simpler) to change to a URI instead,
- * as URIs are UTF-8 encoded strings.
- */
- if (g_utf8_validate (tmp, -1, NULL) &&
- g_file_test (tmp, G_FILE_TEST_EXISTS)) {
- filename = g_strdup (tmp);
- } else {
- filename = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL);
- }
-
- /* Fallback to default BG if the filename set is non-existent */
- if (filename != NULL && !g_file_test (filename, G_FILE_TEST_EXISTS)) {
- g_free (filename);
- filename = g_strdup(XFCE_BG_FALLBACK_IMG);
-
- //* Check if default background exists, also */
- if (filename != NULL && !g_file_test (filename, G_FILE_TEST_EXISTS)) {
- g_free (filename);
- filename = NULL;
- }
- }
- }
- g_free (tmp);
-
- /* Colors */
- g_free(property);
- property = g_strconcat(prop_prefix, "/workspace0/rgba1", NULL);
- color_from_array(channel, property, &c1);
-
- g_free(property);
- property = g_strconcat(prop_prefix, "/workspace0/rgba2", NULL);
- color_from_array(channel, property, &c2);
-
- /* Color type */
- g_free(property);
- property = g_strconcat(prop_prefix, "/workspace0/color-style", NULL);
- ctype = xfconf_channel_get_int(channel, property, XFCE_BG_COLOR_SOLID);
-
- g_free(property);
-
- xfce_bg_set_color (bg, ctype, &c1, &c2);
- xfce_bg_set_placement (bg, placement);
- xfce_bg_set_filename (bg, filename);
-
- if (filename != NULL)
- g_free (filename);
+ XfconfChannel *channel,
+ GdkMonitor *monitor)
+{
+ char *tmp;
+ char *filename;
+ XfceBGColorType ctype;
+ GdkRGBA c1, c2;
+ XfceBGPlacement placement;
+ GdkMonitor *mon;
+ const gchar *monitor_name;
+ gchar *prop_prefix;
+ gchar *property;
+
+ g_return_if_fail(XFCE_IS_BG(bg));
+ //g_return_if_fail (G_IS_SETTINGS (settings));
+
+ if (monitor == NULL)
+ {
+ GdkDisplay *display = gdk_display_get_default();
+ mon = gdk_display_get_primary_monitor(display);
+ if (mon == NULL)
+ {
+ mon = gdk_display_get_monitor(display, 0);
+ }
+ }
+ else
+ {
+ mon = monitor;
+ }
+
+ monitor_name = gdk_monitor_get_model(mon);
+ prop_prefix = xfce_bg_get_property_prefix (channel, monitor_name);
+
+ property = g_strconcat(prop_prefix, "/image-style", NULL);
+ placement = xfconf_channel_get_int(channel, property, XFCE_BG_PLACEMENT_NONE);
+ bg->is_enabled = placement != XFCE_BG_PLACEMENT_NONE;
+
+ /* Filename */
+ g_free(property);
+ property = g_strconcat(prop_prefix, "/last-image", NULL);
+ if (!xfconf_channel_has_property (channel, property)) {
+ g_free(property);
+ property = g_strconcat(prop_prefix, "/image-path", NULL);
+ }
+ filename = NULL;
+ tmp = xfconf_channel_get_string(channel, property, XFCE_BG_FALLBACK_IMG);
+ if (tmp && *tmp != '\0') {
+ /* FIXME: UTF-8 checks should go away.
+ * picture-filename is of type string, which can only be used for
+ * UTF-8 strings, and some filenames are not, dependending on the
+ * locale used.
+ * It would be better (and simpler) to change to a URI instead,
+ * as URIs are UTF-8 encoded strings.
+ */
+ if (g_utf8_validate (tmp, -1, NULL) &&
+ g_file_test (tmp, G_FILE_TEST_EXISTS)) {
+ filename = g_strdup (tmp);
+ } else {
+ filename = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL);
+ }
+
+ /* Fallback to default BG if the filename set is non-existent */
+ if (filename != NULL && !g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ g_free (filename);
+ filename = g_strdup(XFCE_BG_FALLBACK_IMG);
+
+ //* Check if default background exists, also */
+ if (filename != NULL && !g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ g_free (filename);
+ filename = NULL;
+ }
+ }
+ }
+ g_free (tmp);
+
+ /* Colors */
+ g_free(property);
+ property = g_strconcat(prop_prefix, "/workspace0/rgba1", NULL);
+ color_from_array(channel, property, &c1);
+
+ g_free(property);
+ property = g_strconcat(prop_prefix, "/workspace0/rgba2", NULL);
+ color_from_array(channel, property, &c2);
+
+ /* Color type */
+ g_free(property);
+ property = g_strconcat(prop_prefix, "/workspace0/color-style", NULL);
+ ctype = xfconf_channel_get_int(channel, property, XFCE_BG_COLOR_SOLID);
+
+ g_free(property);
+
+ xfce_bg_set_color (bg, ctype, &c1, &c2);
+ xfce_bg_set_placement (bg, placement);
+ xfce_bg_set_filename (bg, filename);
+
+ if (filename != NULL)
+ g_free (filename);
}
static void
@@ -482,532 +482,536 @@ xfce_bg_init (XfceBG *bg)
static void
xfce_bg_dispose (GObject *object)
{
- XfceBG *bg = XFCE_BG (object);
+ XfceBG *bg = XFCE_BG (object);
- if (bg->file_monitor) {
- g_object_unref (bg->file_monitor);
- bg->file_monitor = NULL;
- }
+ if (bg->file_monitor) {
+ g_object_unref (bg->file_monitor);
+ bg->file_monitor = NULL;
+ }
- clear_cache (bg);
+ clear_cache (bg);
- G_OBJECT_CLASS (xfce_bg_parent_class)->dispose (object);
+ G_OBJECT_CLASS (xfce_bg_parent_class)->dispose (object);
}
static void
xfce_bg_finalize (GObject *object)
{
- XfceBG *bg = XFCE_BG (object);
+ XfceBG *bg = XFCE_BG (object);
- if (bg->changed_id != 0) {
- g_source_remove (bg->changed_id);
- bg->changed_id = 0;
- }
+ if (bg->changed_id != 0) {
+ g_source_remove (bg->changed_id);
+ bg->changed_id = 0;
+ }
- if (bg->transitioned_id != 0) {
- g_source_remove (bg->transitioned_id);
- bg->transitioned_id = 0;
- }
+ if (bg->transitioned_id != 0) {
+ g_source_remove (bg->transitioned_id);
+ bg->transitioned_id = 0;
+ }
- if (bg->blow_caches_id != 0) {
- g_source_remove (bg->blow_caches_id);
- bg->blow_caches_id = 0;
- }
+ if (bg->blow_caches_id != 0) {
+ g_source_remove (bg->blow_caches_id);
+ bg->blow_caches_id = 0;
+ }
- g_free (bg->filename);
- bg->filename = NULL;
+ g_free (bg->filename);
+ bg->filename = NULL;
- G_OBJECT_CLASS (xfce_bg_parent_class)->finalize (object);
+ G_OBJECT_CLASS (xfce_bg_parent_class)->finalize (object);
}
static void
xfce_bg_class_init (XfceBGClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = xfce_bg_dispose;
- object_class->finalize = xfce_bg_finalize;
+ object_class->dispose = xfce_bg_dispose;
+ object_class->finalize = xfce_bg_finalize;
- signals[CHANGED] = g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ signals[CHANGED] = g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
- signals[TRANSITIONED] = g_signal_new ("transitioned",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ signals[TRANSITIONED] = g_signal_new ("transitioned",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
XfceBG *
xfce_bg_new (void)
{
- return g_object_new (XFCE_TYPE_BG, NULL);
+ return g_object_new (XFCE_TYPE_BG, NULL);
}
static void
-xfce_bg_set_color (XfceBG *bg,
- XfceBGColorType type,
- GdkRGBA *primary,
- GdkRGBA *secondary)
+xfce_bg_set_color (XfceBG *bg,
+ XfceBGColorType type,
+ GdkRGBA *primary,
+ GdkRGBA *secondary)
{
- g_return_if_fail (bg != NULL);
- g_return_if_fail (primary != NULL);
+ g_return_if_fail (bg != NULL);
+ g_return_if_fail (primary != NULL);
- if (bg->color_type != type ||
- !gdk_rgba_equal (&bg->primary, primary) ||
- (secondary && !gdk_rgba_equal (&bg->secondary, secondary))) {
- bg->color_type = type;
- bg->primary = *primary;
- if (secondary) {
- bg->secondary = *secondary;
- }
+ if (bg->color_type != type ||
+ !gdk_rgba_equal (&bg->primary, primary) ||
+ (secondary && !gdk_rgba_equal (&bg->secondary, secondary)))
+ {
+ bg->color_type = type;
+ bg->primary = *primary;
+ if (secondary) {
+ bg->secondary = *secondary;
+ }
- queue_changed (bg);
- }
+ queue_changed (bg);
+ }
}
static void
-xfce_bg_set_placement (XfceBG *bg,
- XfceBGPlacement placement)
+xfce_bg_set_placement (XfceBG *bg,
+ XfceBGPlacement placement)
{
- g_return_if_fail (bg != NULL);
+ g_return_if_fail (bg != NULL);
- if (bg->placement != placement) {
- bg->placement = placement;
+ if (bg->placement != placement) {
+ bg->placement = placement;
- queue_changed (bg);
- }
+ queue_changed (bg);
+ }
}
static inline gchar *
get_wallpaper_cache_dir ()
{
- return g_build_filename (g_get_user_cache_dir(), XFCE_BG_CACHE_DIR, NULL);
+ return g_build_filename (g_get_user_cache_dir(), XFCE_BG_CACHE_DIR, NULL);
}
static inline gchar *
-get_wallpaper_cache_prefix_name (gint num_monitor,
- XfceBGPlacement placement,
- gint width,
- gint height)
+get_wallpaper_cache_prefix_name (gint num_monitor,
+ XfceBGPlacement placement,
+ gint width,
+ gint height)
{
- return g_strdup_printf ("%i_%i_%i_%i", num_monitor, (gint) placement, width, height);
+ return g_strdup_printf ("%i_%i_%i_%i", num_monitor, (gint) placement, width, height);
}
static char *
-get_wallpaper_cache_filename (const char *filename,
- gint num_monitor,
- XfceBGPlacement placement,
- gint width,
- gint height)
+get_wallpaper_cache_filename (const char *filename,
+ gint num_monitor,
+ XfceBGPlacement placement,
+ gint width,
+ gint height)
{
- gchar *cache_filename;
- gchar *cache_prefix_name;
- gchar *md5_filename;
- gchar *cache_basename;
- gchar *cache_dir;
+ gchar *cache_filename;
+ gchar *cache_prefix_name;
+ gchar *md5_filename;
+ gchar *cache_basename;
+ gchar *cache_dir;
- md5_filename = g_compute_checksum_for_data (G_CHECKSUM_MD5, (const guchar *) filename,
- strlen (filename));
- cache_prefix_name = get_wallpaper_cache_prefix_name (num_monitor, placement, width, height);
- cache_basename = g_strdup_printf ("%s_%s", cache_prefix_name, md5_filename);
- cache_dir = get_wallpaper_cache_dir ();
- cache_filename = g_build_filename (cache_dir, cache_basename, NULL);
+ md5_filename = g_compute_checksum_for_data (G_CHECKSUM_MD5, (const guchar *) filename,
+ strlen (filename));
+ cache_prefix_name = get_wallpaper_cache_prefix_name (num_monitor, placement, width, height);
+ cache_basename = g_strdup_printf ("%s_%s", cache_prefix_name, md5_filename);
+ cache_dir = get_wallpaper_cache_dir ();
+ cache_filename = g_build_filename (cache_dir, cache_basename, NULL);
- g_free (cache_prefix_name);
- g_free (md5_filename);
- g_free (cache_basename);
- g_free (cache_dir);
+ g_free (cache_prefix_name);
+ g_free (md5_filename);
+ g_free (cache_basename);
+ g_free (cache_dir);
- return cache_filename;
+ return cache_filename;
}
static void
cleanup_cache_for_monitor (gchar *cache_dir,
- gint num_monitor)
+ gint num_monitor)
{
- GDir *g_cache_dir;
- gchar *monitor_prefix;
- const gchar *file;
+ GDir *g_cache_dir;
+ gchar *monitor_prefix;
+ const gchar *file;
- g_cache_dir = g_dir_open (cache_dir, 0, NULL);
- monitor_prefix = g_strdup_printf ("%i_", num_monitor);
+ g_cache_dir = g_dir_open (cache_dir, 0, NULL);
+ monitor_prefix = g_strdup_printf ("%i_", num_monitor);
- file = g_dir_read_name (g_cache_dir);
- while (file != NULL) {
- gchar *path = g_build_filename (cache_dir, file, NULL);
+ file = g_dir_read_name (g_cache_dir);
+ while (file != NULL) {
+ gchar *path = g_build_filename (cache_dir, file, NULL);
- /* purge files with same monitor id */
- if (g_str_has_prefix (file, monitor_prefix) &&
- g_file_test (path, G_FILE_TEST_IS_REGULAR))
- g_unlink (path);
+ /* purge files with same monitor id */
+ if (g_str_has_prefix (file, monitor_prefix) &&
+ g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ g_unlink (path);
- g_free (path);
+ g_free (path);
- file = g_dir_read_name (g_cache_dir);
- }
+ file = g_dir_read_name (g_cache_dir);
+ }
- g_free (monitor_prefix);
- g_dir_close (g_cache_dir);
+ g_free (monitor_prefix);
+ g_dir_close (g_cache_dir);
}
static gboolean
cache_file_is_valid (const char *filename,
- const char *cache_filename)
+ const char *cache_filename)
{
- time_t mtime;
- time_t cache_mtime;
+ time_t mtime;
+ time_t cache_mtime;
- if (!g_file_test (cache_filename, G_FILE_TEST_IS_REGULAR))
- return FALSE;
+ if (!g_file_test (cache_filename, G_FILE_TEST_IS_REGULAR))
+ return FALSE;
- mtime = get_mtime (filename);
- cache_mtime = get_mtime (cache_filename);
+ mtime = get_mtime (filename);
+ cache_mtime = get_mtime (cache_filename);
- return (mtime < cache_mtime);
+ return (mtime < cache_mtime);
}
static void
-refresh_cache_file (XfceBG *bg,
- GdkPixbuf *new_pixbuf,
- gint num_monitor,
- gint width,
- gint height)
+refresh_cache_file (XfceBG *bg,
+ GdkPixbuf *new_pixbuf,
+ gint num_monitor,
+ gint width,
+ gint height)
{
- gchar *cache_filename;
- gchar *cache_dir;
- GdkPixbufFormat *format;
- gchar *format_name;
+ gchar *cache_filename;
+ gchar *cache_dir;
+ GdkPixbufFormat *format;
+ gchar *format_name;
- if ((num_monitor == -1) || (width <= 300) || (height <= 300))
- return;
+ if ((num_monitor == -1) || (width <= 300) || (height <= 300))
+ return;
- cache_filename = get_wallpaper_cache_filename (bg->filename, num_monitor,
- bg->placement, width, height);
- cache_dir = get_wallpaper_cache_dir ();
+ cache_filename = get_wallpaper_cache_filename (bg->filename, num_monitor,
+ bg->placement, width, height);
+ cache_dir = get_wallpaper_cache_dir ();
- /* Only refresh scaled file on disk if useful (and don't cache slideshow) */
- if (!cache_file_is_valid (bg->filename, cache_filename)) {
- format = gdk_pixbuf_get_file_info (bg->filename, NULL, NULL);
+ /* Only refresh scaled file on disk if useful (and don't cache slideshow) */
+ if (!cache_file_is_valid (bg->filename, cache_filename)) {
+ format = gdk_pixbuf_get_file_info (bg->filename, NULL, NULL);
- if (format != NULL) {
- if (!g_file_test (cache_dir, G_FILE_TEST_IS_DIR)) {
- g_mkdir_with_parents (cache_dir, 0700);
- } else {
- cleanup_cache_for_monitor (cache_dir, num_monitor);
- }
+ if (format != NULL) {
+ if (!g_file_test (cache_dir, G_FILE_TEST_IS_DIR)) {
+ g_mkdir_with_parents (cache_dir, 0700);
+ } else {
+ cleanup_cache_for_monitor (cache_dir, num_monitor);
+ }
- format_name = gdk_pixbuf_format_get_name (format);
+ format_name = gdk_pixbuf_format_get_name (format);
- if (strcmp (format_name, "jpeg") == 0)
- gdk_pixbuf_save (new_pixbuf, cache_filename, format_name,
- NULL, "quality", "100", NULL);
- else
- gdk_pixbuf_save (new_pixbuf, cache_filename, format_name,
- NULL, NULL);
+ if (strcmp (format_name, "jpeg") == 0)
+ gdk_pixbuf_save (new_pixbuf, cache_filename, format_name,
+ NULL, "quality", "100", NULL);
+ else
+ gdk_pixbuf_save (new_pixbuf, cache_filename, format_name,
+ NULL, NULL);
- g_free (format_name);
- }
- }
+ g_free (format_name);
+ }
+ }
- g_free (cache_filename);
- g_free (cache_dir);
+ g_free (cache_filename);
+ g_free (cache_dir);
}
static void
-file_changed (GFileMonitor *file_monitor,
- GFile *child,
- GFile *other_file,
- GFileMonitorEvent event_type,
- gpointer user_data)
+file_changed (GFileMonitor *file_monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
{
- XfceBG *bg = XFCE_BG (user_data);
+ XfceBG *bg = XFCE_BG (user_data);
- clear_cache (bg);
- queue_changed (bg);
+ clear_cache (bg);
+ queue_changed (bg);
}
static void
-xfce_bg_set_filename (XfceBG *bg,
- const char *filename)
+xfce_bg_set_filename (XfceBG *bg,
+ const char *filename)
{
- g_return_if_fail (bg != NULL);
+ g_return_if_fail (bg != NULL);
- if (is_different (bg, filename)) {
- g_free (bg->filename);
+ if (is_different (bg, filename)) {
+ g_free (bg->filename);
- bg->filename = g_strdup (filename);
- bg->file_mtime = get_mtime (bg->filename);
+ bg->filename = g_strdup (filename);
+ bg->file_mtime = get_mtime (bg->filename);
- if (bg->file_monitor) {
- g_object_unref (bg->file_monitor);
- bg->file_monitor = NULL;
- }
+ if (bg->file_monitor) {
+ g_object_unref (bg->file_monitor);
+ bg->file_monitor = NULL;
+ }
- if (bg->filename) {
- GFile *f = g_file_new_for_path (bg->filename);
+ if (bg->filename) {
+ GFile *f = g_file_new_for_path (bg->filename);
- bg->file_monitor = g_file_monitor_file (f, 0, NULL, NULL);
- g_signal_connect (bg->file_monitor, "changed",
- G_CALLBACK (file_changed), bg);
+ bg->file_monitor = g_file_monitor_file (f, 0, NULL, NULL);
+ g_signal_connect (bg->file_monitor, "changed",
+ G_CALLBACK (file_changed), bg);
- g_object_unref (f);
- }
+ g_object_unref (f);
+ }
- clear_cache (bg);
+ clear_cache (bg);
- queue_changed (bg);
- }
+ queue_changed (bg);
+ }
}
static void
draw_color_area (XfceBG *bg,
- GdkPixbuf *dest,
- GdkRectangle *rect)
+ GdkPixbuf *dest,
+ GdkRectangle *rect)
{
- guint32 pixel;
- GdkRectangle extent;
+ guint32 pixel;
+ GdkRectangle extent;
- extent.x = 0;
- extent.y = 0;
- extent.width = gdk_pixbuf_get_width (dest);
- extent.height = gdk_pixbuf_get_height (dest);
+ extent.x = 0;
+ extent.y = 0;
+ extent.width = gdk_pixbuf_get_width (dest);
+ extent.height = gdk_pixbuf_get_height (dest);
- gdk_rectangle_intersect (rect, &extent, rect);
+ gdk_rectangle_intersect (rect, &extent, rect);
- switch (bg->color_type) {
- case XFCE_BG_COLOR_SOLID:
- /* not really a big deal to ignore the area of interest */
- pixel = ((guint) (bg->primary.red * 0xff) << 24) |
- ((guint) (bg->primary.green * 0xff) << 16) |
- ((guint) (bg->primary.blue * 0xff) << 8) |
- (0xff);
+ switch (bg->color_type) {
+ case XFCE_BG_COLOR_SOLID:
+ /* not really a big deal to ignore the area of interest */
+ pixel = ((guint) (bg->primary.red * 0xff) << 24) |
+ ((guint) (bg->primary.green * 0xff) << 16) |
+ ((guint) (bg->primary.blue * 0xff) << 8) |
+ (0xff);
- gdk_pixbuf_fill (dest, pixel);
- break;
+ gdk_pixbuf_fill (dest, pixel);
+ break;
- case XFCE_BG_COLOR_H_GRADIENT:
- pixbuf_draw_gradient (dest, TRUE, &(bg->primary), &(bg->secondary), rect);
- break;
+ case XFCE_BG_COLOR_H_GRADIENT:
+ pixbuf_draw_gradient (dest, TRUE, &(bg->primary), &(bg->secondary), rect);
+ break;
- case XFCE_BG_COLOR_V_GRADIENT:
- pixbuf_draw_gradient (dest, FALSE, &(bg->primary), &(bg->secondary), rect);
- break;
+ case XFCE_BG_COLOR_V_GRADIENT:
+ pixbuf_draw_gradient (dest, FALSE, &(bg->primary), &(bg->secondary), rect);
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
}
static void
draw_color (XfceBG *bg,
- GdkPixbuf *dest)
+ GdkPixbuf *dest)
{
- GdkRectangle rect;
+ GdkRectangle rect;
- rect.x = 0;
- rect.y = 0;
- rect.width = gdk_pixbuf_get_width (dest);
- rect.height = gdk_pixbuf_get_height (dest);
- draw_color_area (bg, dest, &rect);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = gdk_pixbuf_get_width (dest);
+ rect.height = gdk_pixbuf_get_height (dest);
+ draw_color_area (bg, dest, &rect);
}
static GdkPixbuf *
pixbuf_clip_to_fit (GdkPixbuf *src,
- int max_width,
- int max_height)
+ int max_width,
+ int max_height)
{
- int src_width, src_height;
- int w, h;
- int src_x, src_y;
- GdkPixbuf *pixbuf;
+ int src_width, src_height;
+ int w, h;
+ int src_x, src_y;
+ GdkPixbuf *pixbuf;
- src_width = gdk_pixbuf_get_width (src);
- src_height = gdk_pixbuf_get_height (src);
+ src_width = gdk_pixbuf_get_width (src);
+ src_height = gdk_pixbuf_get_height (src);
- if (src_width < max_width && src_height < max_height)
- return g_object_ref (src);
+ if (src_width < max_width && src_height < max_height)
+ return g_object_ref (src);
- w = MIN(src_width, max_width);
- h = MIN(src_height, max_height);
+ w = MIN(src_width, max_width);
+ h = MIN(src_height, max_height);
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- gdk_pixbuf_get_has_alpha (src),
- 8, w, h);
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ gdk_pixbuf_get_has_alpha (src),
+ 8, w, h);
- src_x = (src_width - w) / 2;
- src_y = (src_height - h) / 2;
- gdk_pixbuf_copy_area (src,
- src_x, src_y,
- w, h,
- pixbuf,
- 0, 0);
- return pixbuf;
+ src_x = (src_width - w) / 2;
+ src_y = (src_height - h) / 2;
+ gdk_pixbuf_copy_area (src,
+ src_x, src_y,
+ w, h,
+ pixbuf,
+ 0, 0);
+ return pixbuf;
}
static GdkPixbuf *
get_scaled_pixbuf (XfceBGPlacement placement,
- GdkPixbuf *pixbuf,
- int width, int height,
- int *x, int *y,
- int *w, int *h)
+ GdkPixbuf *pixbuf,
+ int width,
+ int height,
+ int *x,
+ int *y,
+ int *w,
+ int *h)
{
- GdkPixbuf *new;
+ GdkPixbuf *new;
#if 0
- g_print ("original_width: %d %d\n",
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
+ g_print ("original_width: %d %d\n",
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
#endif
- switch (placement) {
- case XFCE_BG_PLACEMENT_SPANNED:
- new = pixbuf_scale_to_fit (pixbuf, width, height);
- break;
- case XFCE_BG_PLACEMENT_ZOOMED:
- new = pixbuf_scale_to_min (pixbuf, width, height);
- break;
+ switch (placement) {
+ case XFCE_BG_PLACEMENT_SPANNED:
+ new = pixbuf_scale_to_fit (pixbuf, width, height);
+ break;
+ case XFCE_BG_PLACEMENT_ZOOMED:
+ new = pixbuf_scale_to_min (pixbuf, width, height);
+ break;
- case XFCE_BG_PLACEMENT_FILL_SCREEN:
- new = gdk_pixbuf_scale_simple (pixbuf, width, height,
- GDK_INTERP_BILINEAR);
- break;
+ case XFCE_BG_PLACEMENT_FILL_SCREEN:
+ new = gdk_pixbuf_scale_simple (pixbuf, width, height,
+ GDK_INTERP_BILINEAR);
+ break;
- case XFCE_BG_PLACEMENT_SCALED:
- new = pixbuf_scale_to_fit (pixbuf, width, height);
- break;
+ case XFCE_BG_PLACEMENT_SCALED:
+ new = pixbuf_scale_to_fit (pixbuf, width, height);
+ break;
- case XFCE_BG_PLACEMENT_CENTERED:
- case XFCE_BG_PLACEMENT_TILED:
- default:
- new = pixbuf_clip_to_fit (pixbuf, width, height);
- break;
- }
+ case XFCE_BG_PLACEMENT_CENTERED:
+ case XFCE_BG_PLACEMENT_TILED:
+ default:
+ new = pixbuf_clip_to_fit (pixbuf, width, height);
+ break;
+ }
- *w = gdk_pixbuf_get_width (new);
- *h = gdk_pixbuf_get_height (new);
- *x = (width - *w) / 2;
- *y = (height - *h) / 2;
+ *w = gdk_pixbuf_get_width (new);
+ *h = gdk_pixbuf_get_height (new);
+ *x = (width - *w) / 2;
+ *y = (height - *h) / 2;
- return new;
+ return new;
}
static void
-draw_image_area (XfceBG *bg,
- gint num_monitor,
- GdkPixbuf *pixbuf,
- GdkPixbuf *dest,
- GdkRectangle *area)
-{
- int dest_width = area->width;
- int dest_height = area->height;
- int x, y, w, h;
- GdkPixbuf *scaled;
-
- if (!pixbuf)
- return;
-
- scaled = get_scaled_pixbuf (bg->placement, pixbuf, dest_width, dest_height, &x, &y, &w, &h);
-
- switch (bg->placement) {
- case XFCE_BG_PLACEMENT_TILED:
- pixbuf_tile (scaled, dest);
- break;
- case XFCE_BG_PLACEMENT_ZOOMED:
- case XFCE_BG_PLACEMENT_CENTERED:
- case XFCE_BG_PLACEMENT_FILL_SCREEN:
- case XFCE_BG_PLACEMENT_SCALED:
- pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
- break;
- case XFCE_BG_PLACEMENT_SPANNED:
- pixbuf_blend (scaled, dest, 0, 0, w, h, x, y, 1.0);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- refresh_cache_file (bg, scaled, num_monitor, dest_width, dest_height);
-
- g_object_unref (scaled);
+draw_image_area (XfceBG *bg,
+ gint num_monitor,
+ GdkPixbuf *pixbuf,
+ GdkPixbuf *dest,
+ GdkRectangle *area)
+{
+ int dest_width = area->width;
+ int dest_height = area->height;
+ int x, y, w, h;
+ GdkPixbuf *scaled;
+
+ if (!pixbuf)
+ return;
+
+ scaled = get_scaled_pixbuf (bg->placement, pixbuf, dest_width, dest_height, &x, &y, &w, &h);
+
+ switch (bg->placement) {
+ case XFCE_BG_PLACEMENT_TILED:
+ pixbuf_tile (scaled, dest);
+ break;
+ case XFCE_BG_PLACEMENT_ZOOMED:
+ case XFCE_BG_PLACEMENT_CENTERED:
+ case XFCE_BG_PLACEMENT_FILL_SCREEN:
+ case XFCE_BG_PLACEMENT_SCALED:
+ pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
+ break;
+ case XFCE_BG_PLACEMENT_SPANNED:
+ pixbuf_blend (scaled, dest, 0, 0, w, h, x, y, 1.0);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ refresh_cache_file (bg, scaled, num_monitor, dest_width, dest_height);
+
+ g_object_unref (scaled);
}
static void
draw_once (XfceBG *bg,
- GdkPixbuf *dest)
+ GdkPixbuf *dest)
{
- GdkRectangle rect;
- GdkPixbuf *pixbuf;
- gint monitor;
+ GdkRectangle rect;
+ GdkPixbuf *pixbuf;
+ gint monitor;
- monitor = -1;
+ monitor = -1;
- rect.x = 0;
- rect.y = 0;
- rect.width = gdk_pixbuf_get_width (dest);
- rect.height = gdk_pixbuf_get_height (dest);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = gdk_pixbuf_get_width (dest);
+ rect.height = gdk_pixbuf_get_height (dest);
- pixbuf = get_pixbuf_for_size (bg, monitor, rect.width, rect.height);
- if (pixbuf) {
- draw_image_area (bg, monitor, pixbuf, dest, &rect);
+ pixbuf = get_pixbuf_for_size (bg, monitor, rect.width, rect.height);
+ if (pixbuf) {
+ draw_image_area (bg, monitor, pixbuf, dest, &rect);
- g_object_unref (pixbuf);
- }
+ g_object_unref (pixbuf);
+ }
}
static void
-xfce_bg_draw (XfceBG *bg,
- GdkPixbuf *dest)
+xfce_bg_draw (XfceBG *bg,
+ GdkPixbuf *dest)
{
- if (!bg)
- return;
+ if (!bg)
+ return;
- draw_color (bg, dest);
- if (bg->filename) {
- draw_once (bg, dest);
- }
+ draw_color (bg, dest);
+ if (bg->filename) {
+ draw_once (bg, dest);
+ }
}
static void
xfce_bg_get_pixmap_size (XfceBG *bg,
- int width,
- int height,
- int *pixmap_width,
- int *pixmap_height)
+ int width,
+ int height,
+ int *pixmap_width,
+ int *pixmap_height)
{
- int dummy;
+ int dummy;
- if (!pixmap_width)
- pixmap_width = &dummy;
- if (!pixmap_height)
- pixmap_height = &dummy;
+ if (!pixmap_width)
+ pixmap_width = &dummy;
+ if (!pixmap_height)
+ pixmap_height = &dummy;
- *pixmap_width = width;
- *pixmap_height = height;
+ *pixmap_width = width;
+ *pixmap_height = height;
- if (!bg->filename) {
- switch (bg->color_type) {
- case XFCE_BG_COLOR_SOLID:
- case XFCE_BG_COLOR_TRANSPARENT:
- *pixmap_width = 1;
- *pixmap_height = 1;
- break;
+ if (!bg->filename) {
+ switch (bg->color_type) {
+ case XFCE_BG_COLOR_SOLID:
+ case XFCE_BG_COLOR_TRANSPARENT:
+ *pixmap_width = 1;
+ *pixmap_height = 1;
+ break;
- case XFCE_BG_COLOR_H_GRADIENT:
- case XFCE_BG_COLOR_V_GRADIENT:
- break;
- }
+ case XFCE_BG_COLOR_H_GRADIENT:
+ case XFCE_BG_COLOR_V_GRADIENT:
+ break;
+ }
- return;
- }
+ return;
+ }
}
/**
@@ -1020,50 +1024,50 @@ xfce_bg_get_pixmap_size (XfceBG *bg,
* Create a surface that can be set as background for @window.
**/
cairo_surface_t *
-xfce_bg_create_surface (XfceBG *bg,
- GdkWindow *window,
- int screen_width,
- int screen_height,
- int monitor_width,
- int monitor_height)
-{
- return xfce_bg_create_surface_scale (bg,
- window,
- screen_width,
- screen_height,
- monitor_width,
- monitor_height,
- 1);
+xfce_bg_create_surface (XfceBG *bg,
+ GdkWindow *window,
+ int screen_width,
+ int screen_height,
+ int monitor_width,
+ int monitor_height)
+{
+ return xfce_bg_create_surface_scale (bg,
+ window,
+ screen_width,
+ screen_height,
+ monitor_width,
+ monitor_height,
+ 1);
}
GdkPixbuf *
xfce_bg_get_pixbuf(XfceBG *bg,
- int screen_width,
- int screen_height,
- int monitor_width,
- int monitor_height)
+ int screen_width,
+ int screen_height,
+ int monitor_width,
+ int monitor_height)
{
- GdkPixbuf *pixbuf;
- gint width;
- gint height;
+ GdkPixbuf *pixbuf;
+ gint width;
+ gint height;
- if (bg->placement == XFCE_BG_PLACEMENT_SPANNED)
- {
- width = screen_width;
- height = screen_height;
- }
- else
- {
- width = monitor_width;
- height = monitor_height;
- }
+ if (bg->placement == XFCE_BG_PLACEMENT_SPANNED)
+ {
+ width = screen_width;
+ height = screen_height;
+ }
+ else
+ {
+ width = monitor_width;
+ height = monitor_height;
+ }
- pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
- width, height);
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
+ width, height);
- xfce_bg_draw(bg, pixbuf);
+ xfce_bg_draw(bg, pixbuf);
- return pixbuf;
+ return pixbuf;
}
/**
@@ -1077,463 +1081,466 @@ xfce_bg_get_pixbuf(XfceBG *bg,
* Create a scaled surface that can be set as background for @window.
**/
static cairo_surface_t *
-xfce_bg_create_surface_scale (XfceBG *bg,
- GdkWindow *window,
- int screen_width,
- int screen_height,
- int monitor_width,
- int monitor_height,
- int scale)
+xfce_bg_create_surface_scale (XfceBG *bg,
+ GdkWindow *window,
+ int screen_width,
+ int screen_height,
+ int monitor_width,
+ int monitor_height,
+ int scale)
{
- int pm_width, pm_height;
- int width, height;
+ int pm_width, pm_height;
+ int width, height;
- cairo_surface_t *surface;
- cairo_t *cr;
+ cairo_surface_t *surface;
+ cairo_t *cr;
- g_return_val_if_fail (bg != NULL, NULL);
- g_return_val_if_fail (window != NULL, NULL);
+ g_return_val_if_fail (bg != NULL, NULL);
+ g_return_val_if_fail (window != NULL, NULL);
- if (bg->placement == XFCE_BG_PLACEMENT_SPANNED) {
- width = screen_width;
- height = screen_height;
- } else {
- width = monitor_width;
- height = monitor_height;
- }
+ if (bg->placement == XFCE_BG_PLACEMENT_SPANNED) {
+ width = screen_width;
+ height = screen_height;
+ } else {
+ width = monitor_width;
+ height = monitor_height;
+ }
- if (bg->pixbuf_cache &&
- (gdk_pixbuf_get_width(bg->pixbuf_cache) != width ||
- gdk_pixbuf_get_height(bg->pixbuf_cache) != height))
- {
- g_object_unref(bg->pixbuf_cache);
- bg->pixbuf_cache = NULL;
- }
+ if (bg->pixbuf_cache &&
+ (gdk_pixbuf_get_width(bg->pixbuf_cache) != width ||
+ gdk_pixbuf_get_height(bg->pixbuf_cache) != height))
+ {
+ g_object_unref(bg->pixbuf_cache);
+ bg->pixbuf_cache = NULL;
+ }
- xfce_bg_get_pixmap_size (bg, width, height, &pm_width, &pm_height);
+ xfce_bg_get_pixmap_size (bg, width, height, &pm_width, &pm_height);
- surface = gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR,
- pm_width, pm_height);
+ surface = gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR,
+ pm_width, pm_height);
- cr = cairo_create (surface);
- cairo_scale (cr, (double)scale, (double)scale);
+ cr = cairo_create (surface);
+ cairo_scale (cr, (double)scale, (double)scale);
- if (!bg->filename && bg->color_type == XFCE_BG_COLOR_SOLID) {
- gdk_cairo_set_source_rgba (cr, &(bg->primary));
- }
- else
- {
- GdkPixbuf *pixbuf = xfce_bg_get_pixbuf(bg, screen_width, screen_height, monitor_width, monitor_height);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- g_object_unref (pixbuf);
- }
+ if (!bg->filename && bg->color_type == XFCE_BG_COLOR_SOLID) {
+ gdk_cairo_set_source_rgba (cr, &(bg->primary));
+ }
+ else
+ {
+ GdkPixbuf *pixbuf = xfce_bg_get_pixbuf(bg, screen_width, screen_height, monitor_width, monitor_height);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ g_object_unref (pixbuf);
+ }
- cairo_paint (cr);
+ cairo_paint (cr);
- cairo_destroy (cr);
+ cairo_destroy (cr);
- return surface;
+ return surface;
}
/* Implementation of the pixbuf cache */
struct _SlideShow
{
- gint ref_count;
- double start_time;
- double total_duration;
+ gint ref_count;
+ double start_time;
+ double total_duration;
- GQueue *slides;
+ GQueue *slides;
- gboolean has_multiple_sizes;
+ gboolean has_multiple_sizes;
- /* used during parsing */
- struct tm start_tm;
- GQueue *stack;
+ /* used during parsing */
+ struct tm start_tm;
+ GQueue *stack;
};
-
static double
now (void)
{
- GTimeVal tv;
+ GTimeVal tv;
- g_get_current_time (&tv);
+ g_get_current_time (&tv);
- return (double)tv.tv_sec + (tv.tv_usec / 1000000.0);
+ return (double)tv.tv_sec + (tv.tv_usec / 1000000.0);
}
static Slide *
get_current_slide (SlideShow *show,
- double *alpha)
+ double *alpha)
{
- double delta = fmod (now() - show->start_time, show->total_duration);
- GList *list;
- double elapsed;
- int i;
+ double delta = fmod (now() - show->start_time, show->total_duration);
+ GList *list;
+ double elapsed;
+ int i;
- if (delta < 0)
- delta += show->total_duration;
+ if (delta < 0)
+ delta += show->total_duration;
- elapsed = 0;
- i = 0;
- for (list = show->slides->head; list != NULL; list = list->next) {
- Slide *slide = list->data;
+ elapsed = 0;
+ i = 0;
+ for (list = show->slides->head; list != NULL; list = list->next) {
+ Slide *slide = list->data;
- if (elapsed + slide->duration > delta) {
- if (alpha)
- *alpha = (delta - elapsed) / (double)slide->duration;
- return slide;
- }
+ if (elapsed + slide->duration > delta) {
+ if (alpha)
+ *alpha = (delta - elapsed) / (double)slide->duration;
+ return slide;
+ }
- i++;
- elapsed += slide->duration;
- }
+ i++;
+ elapsed += slide->duration;
+ }
- /* this should never happen since we have slides and we should always
- * find a current slide for the elapsed time since beginning -- we're
- * looping with fmod() */
- g_assert_not_reached ();
+ /* this should never happen since we have slides and we should always
+ * find a current slide for the elapsed time since beginning -- we're
+ * looping with fmod() */
+ g_assert_not_reached ();
- return NULL;
+ return NULL;
}
static GdkPixbuf *
blend (GdkPixbuf *p1,
GdkPixbuf *p2,
- double alpha)
+ double alpha)
{
- GdkPixbuf *result = gdk_pixbuf_copy (p1);
- GdkPixbuf *tmp;
+ GdkPixbuf *result = gdk_pixbuf_copy (p1);
+ GdkPixbuf *tmp;
- if (gdk_pixbuf_get_width (p2) != gdk_pixbuf_get_width (p1) ||
+ if (gdk_pixbuf_get_width (p2) != gdk_pixbuf_get_width (p1) ||
gdk_pixbuf_get_height (p2) != gdk_pixbuf_get_height (p1)) {
- tmp = gdk_pixbuf_scale_simple (p2,
- gdk_pixbuf_get_width (p1),
- gdk_pixbuf_get_height (p1),
- GDK_INTERP_BILINEAR);
- }
+ tmp = gdk_pixbuf_scale_simple (p2,
+ gdk_pixbuf_get_width (p1),
+ gdk_pixbuf_get_height (p1),
+ GDK_INTERP_BILINEAR);
+ }
else {
- tmp = g_object_ref (p2);
- }
+ tmp = g_object_ref (p2);
+ }
- pixbuf_blend (tmp, result, 0, 0, -1, -1, 0, 0, alpha);
+ pixbuf_blend (tmp, result, 0, 0, -1, -1, 0, 0, alpha);
- g_object_unref (tmp);
+ g_object_unref (tmp);
- return result;
+ return result;
}
-typedef enum {
- PIXBUF,
- SLIDESHOW,
- THUMBNAIL
+typedef enum {
+ PIXBUF,
+ SLIDESHOW,
+ THUMBNAIL
} FileType;
struct FileCacheEntry
{
- FileType type;
- char *filename;
- union {
- GdkPixbuf *pixbuf;
- SlideShow *slideshow;
- GdkPixbuf *thumbnail;
- } u;
+ FileType type;
+ char *filename;
+ union {
+ GdkPixbuf *pixbuf;
+ SlideShow *slideshow;
+ GdkPixbuf *thumbnail;
+ } u;
};
static void
file_cache_entry_delete (FileCacheEntry *ent)
{
- g_free (ent->filename);
+ g_free (ent->filename);
- switch (ent->type) {
- case PIXBUF:
- g_object_unref (ent->u.pixbuf);
- break;
- case SLIDESHOW:
- slideshow_unref (ent->u.slideshow);
- break;
- case THUMBNAIL:
- g_object_unref (ent->u.thumbnail);
- break;
- }
+ switch (ent->type) {
+ case PIXBUF:
+ g_object_unref (ent->u.pixbuf);
+ break;
+ case SLIDESHOW:
+ slideshow_unref (ent->u.slideshow);
+ break;
+ case THUMBNAIL:
+ g_object_unref (ent->u.thumbnail);
+ break;
+ }
- g_free (ent);
+ g_free (ent);
}
static void
bound_cache (XfceBG *bg)
{
while (g_list_length (bg->file_cache) >= CACHE_SIZE) {
- GList *last_link = g_list_last (bg->file_cache);
- FileCacheEntry *ent = last_link->data;
+ GList *last_link = g_list_last (bg->file_cache);
+ FileCacheEntry *ent = last_link->data;
- file_cache_entry_delete (ent);
+ file_cache_entry_delete (ent);
- bg->file_cache = g_list_delete_link (bg->file_cache, last_link);
+ bg->file_cache = g_list_delete_link (bg->file_cache, last_link);
}
}
static const FileCacheEntry *
-file_cache_lookup (XfceBG *bg, FileType type, const char *filename)
+file_cache_lookup (XfceBG *bg,
+ FileType type,
+ const char *filename)
{
- GList *list;
+ GList *list;
- for (list = bg->file_cache; list != NULL; list = list->next) {
- FileCacheEntry *ent = list->data;
+ for (list = bg->file_cache; list != NULL; list = list->next) {
+ FileCacheEntry *ent = list->data;
- if (ent && ent->type == type &&
- strcmp (ent->filename, filename) == 0) {
- return ent;
- }
- }
+ if (ent && ent->type == type &&
+ strcmp (ent->filename, filename) == 0) {
+ return ent;
+ }
+ }
- return NULL;
+ return NULL;
}
static FileCacheEntry *
-file_cache_entry_new (XfceBG *bg,
- FileType type,
- const char *filename)
+file_cache_entry_new (XfceBG *bg,
+ FileType type,
+ const char *filename)
{
- FileCacheEntry *ent = g_new0 (FileCacheEntry, 1);
+ FileCacheEntry *ent = g_new0 (FileCacheEntry, 1);
- g_assert (!file_cache_lookup (bg, type, filename));
+ g_assert (!file_cache_lookup (bg, type, filename));
- ent->type = type;
- ent->filename = g_strdup (filename);
+ ent->type = type;
+ ent->filename = g_strdup (filename);
- bg->file_cache = g_list_prepend (bg->file_cache, ent);
+ bg->file_cache = g_list_prepend (bg->file_cache, ent);
- bound_cache (bg);
+ bound_cache (bg);
- return ent;
+ return ent;
}
static void
-file_cache_add_pixbuf (XfceBG *bg,
- const char *filename,
- GdkPixbuf *pixbuf)
+file_cache_add_pixbuf (XfceBG *bg,
+ const char *filename,
+ GdkPixbuf *pixbuf)
{
- FileCacheEntry *ent = file_cache_entry_new (bg, PIXBUF, filename);
- ent->u.pixbuf = g_object_ref (pixbuf);
+ FileCacheEntry *ent = file_cache_entry_new (bg, PIXBUF, filename);
+ ent->u.pixbuf = g_object_ref (pixbuf);
}
static void
-file_cache_add_slide_show (XfceBG *bg,
- const char *filename,
- SlideShow *show)
+file_cache_add_slide_show (XfceBG *bg,
+ const char *filename,
+ SlideShow *show)
{
- FileCacheEntry *ent = file_cache_entry_new (bg, SLIDESHOW, filename);
- ent->u.slideshow = slideshow_ref (show);
+ FileCacheEntry *ent = file_cache_entry_new (bg, SLIDESHOW, filename);
+ ent->u.slideshow = slideshow_ref (show);
}
static GdkPixbuf *
load_from_cache_file (XfceBG *bg,
- const char *filename,
- gint num_monitor,
- gint best_width,
- gint best_height)
+ const char *filename,
+ gint num_monitor,
+ gint best_width,
+ gint best_height)
{
- GdkPixbuf *pixbuf = NULL;
- gchar *cache_filename;
+ GdkPixbuf *pixbuf = NULL;
+ gchar *cache_filename;
- cache_filename = get_wallpaper_cache_filename (filename, num_monitor, bg->placement,
- best_width, best_height);
+ cache_filename = get_wallpaper_cache_filename (filename, num_monitor, bg->placement,
+ best_width, best_height);
- if (cache_file_is_valid (filename, cache_filename))
- pixbuf = gdk_pixbuf_new_from_file (cache_filename, NULL);
+ if (cache_file_is_valid (filename, cache_filename))
+ pixbuf = gdk_pixbuf_new_from_file (cache_filename, NULL);
- g_free (cache_filename);
+ g_free (cache_filename);
- return pixbuf;
+ return pixbuf;
}
static GdkPixbuf *
-get_as_pixbuf_for_size (XfceBG *bg,
- const char *filename,
- gint monitor,
- gint best_width,
- gint best_height)
-{
- const FileCacheEntry *ent;
- if ((ent = file_cache_lookup (bg, PIXBUF, filename))) {
- return g_object_ref (ent->u.pixbuf);
- } else {
- GdkPixbufFormat *format;
- GdkPixbuf *pixbuf = NULL;
- gchar *tmp = NULL;
- GdkPixbuf *tmp_pixbuf;
-
- /* Try to hit local cache first if relevant */
- if (monitor != -1)
- pixbuf = load_from_cache_file (bg, filename, monitor,
- best_width, best_height);
-
- if (!pixbuf) {
- /* If scalable choose maximum size */
- format = gdk_pixbuf_get_file_info (filename, NULL, NULL);
- if (format != NULL)
- tmp = gdk_pixbuf_format_get_name (format);
-
- if (g_strcmp0 (tmp, "svg") == 0 &&
- (best_width > 0 && best_height > 0) &&
- (bg->placement == XFCE_BG_PLACEMENT_FILL_SCREEN ||
- bg->placement == XFCE_BG_PLACEMENT_SCALED ||
- bg->placement == XFCE_BG_PLACEMENT_ZOOMED))
- {
- pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
- best_width,
- best_height, NULL);
- } else {
- pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
- }
-
- if (tmp != NULL)
- g_free (tmp);
- }
-
- if (pixbuf) {
- tmp_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
- g_object_unref (pixbuf);
- pixbuf = tmp_pixbuf;
- file_cache_add_pixbuf (bg, filename, pixbuf);
- }
-
- return pixbuf;
- }
+get_as_pixbuf_for_size (XfceBG *bg,
+ const char *filename,
+ gint monitor,
+ gint best_width,
+ gint best_height)
+{
+ const FileCacheEntry *ent;
+
+ if ((ent = file_cache_lookup (bg, PIXBUF, filename))) {
+ return g_object_ref (ent->u.pixbuf);
+ } else {
+ GdkPixbufFormat *format;
+ GdkPixbuf *pixbuf = NULL;
+ gchar *tmp = NULL;
+ GdkPixbuf *tmp_pixbuf;
+
+ /* Try to hit local cache first if relevant */
+ if (monitor != -1)
+ pixbuf = load_from_cache_file (bg, filename, monitor,
+ best_width, best_height);
+
+ if (!pixbuf) {
+ /* If scalable choose maximum size */
+ format = gdk_pixbuf_get_file_info (filename, NULL, NULL);
+ if (format != NULL)
+ tmp = gdk_pixbuf_format_get_name (format);
+
+ if (g_strcmp0 (tmp, "svg") == 0 &&
+ (best_width > 0 && best_height > 0) &&
+ (bg->placement == XFCE_BG_PLACEMENT_FILL_SCREEN ||
+ bg->placement == XFCE_BG_PLACEMENT_SCALED ||
+ bg->placement == XFCE_BG_PLACEMENT_ZOOMED))
+ {
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
+ best_width,
+ best_height, NULL);
+ } else {
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ }
+
+ if (tmp != NULL)
+ g_free (tmp);
+ }
+
+ if (pixbuf) {
+ tmp_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
+ g_object_unref (pixbuf);
+ pixbuf = tmp_pixbuf;
+ file_cache_add_pixbuf (bg, filename, pixbuf);
+ }
+
+ return pixbuf;
+ }
}
static SlideShow *
-get_as_slideshow (XfceBG *bg, const char *filename)
+get_as_slideshow (XfceBG *bg,
+ const char *filename)
{
- const FileCacheEntry *ent;
- if ((ent = file_cache_lookup (bg, SLIDESHOW, filename))) {
- return slideshow_ref (ent->u.slideshow);
- }
- else {
- SlideShow *show = read_slideshow_file (filename, NULL);
+ const FileCacheEntry *ent;
+ if ((ent = file_cache_lookup (bg, SLIDESHOW, filename))) {
+ return slideshow_ref (ent->u.slideshow);
+ }
+ else {
+ SlideShow *show = read_slideshow_file (filename, NULL);
- if (show)
- file_cache_add_slide_show (bg, filename, show);
+ if (show)
+ file_cache_add_slide_show (bg, filename, show);
- return show;
- }
+ return show;
+ }
}
static gboolean
blow_expensive_caches (gpointer data)
{
- XfceBG *bg = data;
- GList *list;
+ XfceBG *bg = data;
+ GList *list;
- bg->blow_caches_id = 0;
+ bg->blow_caches_id = 0;
- if (bg->file_cache) {
- for (list = bg->file_cache; list != NULL; list = list->next) {
- FileCacheEntry *ent = list->data;
+ if (bg->file_cache) {
+ for (list = bg->file_cache; list != NULL; list = list->next) {
+ FileCacheEntry *ent = list->data;
- if (ent->type == PIXBUF) {
- file_cache_entry_delete (ent);
- bg->file_cache = g_list_delete_link (bg->file_cache,
- list);
- }
- }
- }
+ if (ent->type == PIXBUF) {
+ file_cache_entry_delete (ent);
+ bg->file_cache = g_list_delete_link (bg->file_cache,
+ list);
+ }
+ }
+ }
- if (bg->pixbuf_cache) {
- g_object_unref (bg->pixbuf_cache);
- bg->pixbuf_cache = NULL;
- }
+ if (bg->pixbuf_cache) {
+ g_object_unref (bg->pixbuf_cache);
+ bg->pixbuf_cache = NULL;
+ }
- return FALSE;
+ return FALSE;
}
static void
blow_expensive_caches_in_idle (XfceBG *bg)
{
- if (bg->blow_caches_id == 0) {
- bg->blow_caches_id =
- g_idle_add (blow_expensive_caches,
- bg);
- }
+ if (bg->blow_caches_id == 0) {
+ bg->blow_caches_id =
+ g_idle_add (blow_expensive_caches,
+ bg);
+ }
}
static gboolean
on_timeout (gpointer data)
{
- XfceBG *bg = data;
+ XfceBG *bg = data;
- bg->timeout_id = 0;
+ bg->timeout_id = 0;
- queue_transitioned (bg);
+ queue_transitioned (bg);
- return FALSE;
+ return FALSE;
}
static double
get_slide_timeout (Slide *slide)
{
- double timeout;
- if (slide->fixed) {
- timeout = slide->duration;
- } else {
- /* Maybe the number of steps should be configurable? */
-
- /* In the worst case we will do a fade from 0 to 256, which mean
- * we will never use more than 255 steps, however in most cases
- * the first and last value are similar and users can't percieve
- * changes in pixel values as small as 1/255th. So, lets not waste
- * CPU cycles on transitioning to often.
- *
- * 64 steps is enough for each step to be just detectable in a 16bit
- * color mode in the worst case, so we'll use this as an approximation
- * of whats detectable.
- */
- timeout = slide->duration / 64.0;
- }
- return timeout;
+ double timeout;
+ if (slide->fixed) {
+ timeout = slide->duration;
+ } else {
+ /* Maybe the number of steps should be configurable? */
+
+ /* In the worst case we will do a fade from 0 to 256, which mean
+ * we will never use more than 255 steps, however in most cases
+ * the first and last value are similar and users can't percieve
+ * changes in pixel values as small as 1/255th. So, lets not waste
+ * CPU cycles on transitioning to often.
+ *
+ * 64 steps is enough for each step to be just detectable in a 16bit
+ * color mode in the worst case, so we'll use this as an approximation
+ * of whats detectable.
+ */
+ timeout = slide->duration / 64.0;
+ }
+ return timeout;
}
static void
ensure_timeout (XfceBG *bg,
- Slide *slide)
+ Slide *slide)
{
- if (!bg->timeout_id) {
- double timeout = get_slide_timeout (slide);
+ if (!bg->timeout_id) {
+ double timeout = get_slide_timeout (slide);
- /* G_MAXUINT means "only one slide" */
- if (timeout < G_MAXUINT) {
- bg->timeout_id = g_timeout_add_full (
- G_PRIORITY_LOW,
- timeout * 1000, on_timeout, bg, NULL);
- }
+ /* G_MAXUINT means "only one slide" */
+ if (timeout < G_MAXUINT) {
+ bg->timeout_id = g_timeout_add_full (
+ G_PRIORITY_LOW,
+ timeout * 1000, on_timeout, bg, NULL);
+ }
- }
+ }
}
static time_t
get_mtime (const char *filename)
{
- GFile *file;
- GFileInfo *info;
- time_t mtime;
+ GFile *file;
+ GFileInfo *info;
+ time_t mtime;
- mtime = (time_t)-1;
+ mtime = (time_t)-1;
- if (filename) {
- file = g_file_new_for_path (filename);
- info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED,
- G_FILE_QUERY_INFO_NONE, NULL, NULL);
- if (info) {
- mtime = g_file_info_get_attribute_uint64 (info,
- G_FILE_ATTRIBUTE_TIME_MODIFIED);
- g_object_unref (info);
- }
- g_object_unref (file);
- }
+ if (filename) {
+ file = g_file_new_for_path (filename);
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (info) {
+ mtime = g_file_info_get_attribute_uint64 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ g_object_unref (info);
+ }
+ g_object_unref (file);
+ }
- return mtime;
+ return mtime;
}
/*
@@ -1545,731 +1552,741 @@ get_mtime (const char *filename)
* width is closer to the given width.
*/
static FileSize *
-find_best_size (GSList *sizes, gint width, gint height)
+find_best_size (GSList *sizes,
+ gint width,
+ gint height)
{
- GSList *s;
- gdouble a, d, distance;
- FileSize *best = NULL;
- gint pass;
+ GSList *s;
+ gdouble a, d, distance;
+ FileSize *best = NULL;
+ gint pass;
- a = width/(gdouble)height;
- distance = 10000.0;
+ a = width/(gdouble)height;
+ distance = 10000.0;
- for (pass = 0; pass < 2; pass++) {
- for (s = sizes; s; s = s->next) {
- FileSize *size = s->data;
+ for (pass = 0; pass < 2; pass++) {
+ for (s = sizes; s; s = s->next) {
+ FileSize *size = s->data;
- if (pass == 0 && (size->width < width || size->height < height))
- continue;
+ if (pass == 0 && (size->width < width || size->height < height))
+ continue;
- d = fabs (a - size->width/(gdouble)size->height);
- if (d < distance) {
- distance = d;
- best = size;
- }
- else if (d == distance) {
- if (abs (size->width - width) < abs (best->width - width)) {
- best = size;
- }
- }
- }
+ d = fabs (a - size->width/(gdouble)size->height);
+ if (d < distance) {
+ distance = d;
+ best = size;
+ }
+ else if (d == distance) {
+ if (abs (size->width - width) < abs (best->width - width)) {
+ best = size;
+ }
+ }
+ }
- if (best)
- break;
- }
+ if (best)
+ break;
+ }
- return best;
+ return best;
}
static GdkPixbuf *
get_pixbuf_for_size (XfceBG *bg,
- gint monitor,
- gint best_width,
- gint best_height)
-{
- guint time_until_next_change;
- gboolean hit_cache = FALSE;
-
- /* only hit the cache if the aspect ratio matches */
- if (bg->pixbuf_cache) {
- int width, height;
- width = gdk_pixbuf_get_width (bg->pixbuf_cache);
- height = gdk_pixbuf_get_height (bg->pixbuf_cache);
- hit_cache = 0.2 > fabs ((best_width / (double)best_height) - (width / (double)height));
- if (!hit_cache) {
- g_object_unref (bg->pixbuf_cache);
- bg->pixbuf_cache = NULL;
- }
- }
-
- if (!hit_cache && bg->filename) {
- bg->file_mtime = get_mtime (bg->filename);
-
- bg->pixbuf_cache = get_as_pixbuf_for_size (bg, bg->filename, monitor,
- best_width, best_height);
- time_until_next_change = G_MAXUINT;
- if (!bg->pixbuf_cache) {
- SlideShow *show = get_as_slideshow (bg, bg->filename);
-
- if (show) {
- double alpha;
- Slide *slide;
-
- slideshow_ref (show);
-
- slide = get_current_slide (show, &alpha);
- time_until_next_change = (guint)get_slide_timeout (slide);
- if (slide->fixed) {
- FileSize *size = find_best_size (slide->file1,
- best_width, best_height);
- bg->pixbuf_cache =
- get_as_pixbuf_for_size (bg, size->file, monitor,
- best_width, best_height);
- } else {
- FileSize *size;
- GdkPixbuf *p1, *p2;
-
- size = find_best_size (slide->file1,
- best_width, best_height);
- p1 = get_as_pixbuf_for_size (bg, size->file, monitor,
- best_width, best_height);
-
- size = find_best_size (slide->file2,
- best_width, best_height);
- p2 = get_as_pixbuf_for_size (bg, size->file, monitor,
- best_width, best_height);
-
- if (p1 && p2)
- bg->pixbuf_cache = blend (p1, p2, alpha);
- if (p1)
- g_object_unref (p1);
- if (p2)
- g_object_unref (p2);
- }
-
- ensure_timeout (bg, slide);
-
- slideshow_unref (show);
- }
- }
-
- /* If the next slideshow step is a long time away then
- we blow away the expensive stuff (large pixbufs) from
- the cache */
- if (time_until_next_change > KEEP_EXPENSIVE_CACHE_SECS)
- blow_expensive_caches_in_idle (bg);
- }
-
- if (bg->pixbuf_cache)
- g_object_ref (bg->pixbuf_cache);
-
- return bg->pixbuf_cache;
+ gint monitor,
+ gint best_width,
+ gint best_height)
+{
+ guint time_until_next_change;
+ gboolean hit_cache = FALSE;
+
+ /* only hit the cache if the aspect ratio matches */
+ if (bg->pixbuf_cache) {
+ int width, height;
+ width = gdk_pixbuf_get_width (bg->pixbuf_cache);
+ height = gdk_pixbuf_get_height (bg->pixbuf_cache);
+ hit_cache = 0.2 > fabs ((best_width / (double)best_height) - (width / (double)height));
+ if (!hit_cache) {
+ g_object_unref (bg->pixbuf_cache);
+ bg->pixbuf_cache = NULL;
+ }
+ }
+
+ if (!hit_cache && bg->filename) {
+ bg->file_mtime = get_mtime (bg->filename);
+
+ bg->pixbuf_cache = get_as_pixbuf_for_size (bg, bg->filename, monitor,
+ best_width, best_height);
+ time_until_next_change = G_MAXUINT;
+ if (!bg->pixbuf_cache) {
+ SlideShow *show = get_as_slideshow (bg, bg->filename);
+
+ if (show) {
+ double alpha;
+ Slide *slide;
+
+ slideshow_ref (show);
+
+ slide = get_current_slide (show, &alpha);
+ time_until_next_change = (guint)get_slide_timeout (slide);
+ if (slide->fixed) {
+ FileSize *size = find_best_size (slide->file1,
+ best_width, best_height);
+ bg->pixbuf_cache =
+ get_as_pixbuf_for_size (bg, size->file, monitor,
+ best_width, best_height);
+ } else {
+ FileSize *size;
+ GdkPixbuf *p1, *p2;
+
+ size = find_best_size (slide->file1,
+ best_width, best_height);
+ p1 = get_as_pixbuf_for_size (bg, size->file, monitor,
+ best_width, best_height);
+
+ size = find_best_size (slide->file2,
+ best_width, best_height);
+ p2 = get_as_pixbuf_for_size (bg, size->file, monitor,
+ best_width, best_height);
+
+ if (p1 && p2)
+ bg->pixbuf_cache = blend (p1, p2, alpha);
+ if (p1)
+ g_object_unref (p1);
+ if (p2)
+ g_object_unref (p2);
+ }
+
+ ensure_timeout (bg, slide);
+
+ slideshow_unref (show);
+ }
+ }
+
+ /* If the next slideshow step is a long time away then
+ we blow away the expensive stuff (large pixbufs) from
+ the cache */
+ if (time_until_next_change > KEEP_EXPENSIVE_CACHE_SECS)
+ blow_expensive_caches_in_idle (bg);
+ }
+
+ if (bg->pixbuf_cache)
+ g_object_ref (bg->pixbuf_cache);
+
+ return bg->pixbuf_cache;
}
static gboolean
-is_different (XfceBG *bg,
- const char *filename)
+is_different (XfceBG *bg,
+ const char *filename)
{
- if (!filename && bg->filename) {
- return TRUE;
- }
- else if (filename && !bg->filename) {
- return TRUE;
- }
- else if (!filename && !bg->filename) {
- return FALSE;
- }
- else {
- time_t mtime = get_mtime (filename);
+ if (!filename && bg->filename) {
+ return TRUE;
+ }
+ else if (filename && !bg->filename) {
+ return TRUE;
+ }
+ else if (!filename && !bg->filename) {
+ return FALSE;
+ }
+ else {
+ time_t mtime = get_mtime (filename);
- if (mtime != bg->file_mtime)
- return TRUE;
+ if (mtime != bg->file_mtime)
+ return TRUE;
- if (strcmp (filename, bg->filename) != 0)
- return TRUE;
+ if (strcmp (filename, bg->filename) != 0)
+ return TRUE;
- return FALSE;
- }
+ return FALSE;
+ }
}
static void
clear_cache (XfceBG *bg)
{
- GList *list;
+ GList *list;
- if (bg->file_cache) {
- for (list = bg->file_cache; list != NULL; list = list->next) {
- FileCacheEntry *ent = list->data;
+ if (bg->file_cache) {
+ for (list = bg->file_cache; list != NULL; list = list->next) {
+ FileCacheEntry *ent = list->data;
- file_cache_entry_delete (ent);
- }
- g_list_free (bg->file_cache);
- bg->file_cache = NULL;
- }
+ file_cache_entry_delete (ent);
+ }
+ g_list_free (bg->file_cache);
+ bg->file_cache = NULL;
+ }
- if (bg->pixbuf_cache) {
- g_object_unref (bg->pixbuf_cache);
+ if (bg->pixbuf_cache) {
+ g_object_unref (bg->pixbuf_cache);
- bg->pixbuf_cache = NULL;
- }
+ bg->pixbuf_cache = NULL;
+ }
- if (bg->timeout_id) {
- g_source_remove (bg->timeout_id);
+ if (bg->timeout_id) {
+ g_source_remove (bg->timeout_id);
- bg->timeout_id = 0;
- }
+ bg->timeout_id = 0;
+ }
}
static GdkPixbuf *
-pixbuf_scale_to_fit (GdkPixbuf *src, int max_width, int max_height)
+pixbuf_scale_to_fit (GdkPixbuf *src,
+ int max_width,
+ int max_height)
{
- double factor;
- int src_width, src_height;
- int new_width, new_height;
+ double factor;
+ int src_width, src_height;
+ int new_width, new_height;
- src_width = gdk_pixbuf_get_width (src);
- src_height = gdk_pixbuf_get_height (src);
+ src_width = gdk_pixbuf_get_width (src);
+ src_height = gdk_pixbuf_get_height (src);
- factor = MIN (max_width / (double) src_width, max_height / (double) src_height);
+ factor = MIN (max_width / (double) src_width, max_height / (double) src_height);
- new_width = floor (src_width * factor + 0.5);
- new_height = floor (src_height * factor + 0.5);
+ new_width = floor (src_width * factor + 0.5);
+ new_height = floor (src_height * factor + 0.5);
- return gdk_pixbuf_scale_simple (src, new_width, new_height, GDK_INTERP_BILINEAR);
+ return gdk_pixbuf_scale_simple (src, new_width, new_height, GDK_INTERP_BILINEAR);
}
static GdkPixbuf *
-pixbuf_scale_to_min (GdkPixbuf *src, int min_width, int min_height)
+pixbuf_scale_to_min (GdkPixbuf *src,
+ int min_width,
+ int min_height)
{
- double factor;
- int src_width, src_height;
- int new_width, new_height;
- GdkPixbuf *dest;
+ double factor;
+ int src_width, src_height;
+ int new_width, new_height;
+ GdkPixbuf *dest;
- src_width = gdk_pixbuf_get_width (src);
- src_height = gdk_pixbuf_get_height (src);
+ src_width = gdk_pixbuf_get_width (src);
+ src_height = gdk_pixbuf_get_height (src);
- factor = MAX (min_width / (double) src_width, min_height / (double) src_height);
+ factor = MAX (min_width / (double) src_width, min_height / (double) src_height);
- new_width = floor (src_width * factor + 0.5);
- new_height = floor (src_height * factor + 0.5);
+ new_width = floor (src_width * factor + 0.5);
+ new_height = floor (src_height * factor + 0.5);
- dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- gdk_pixbuf_get_has_alpha (src),
- 8, min_width, min_height);
- if (!dest)
- return NULL;
+ dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ gdk_pixbuf_get_has_alpha (src),
+ 8, min_width, min_height);
+ if (!dest)
+ return NULL;
- /* crop the result */
- gdk_pixbuf_scale (src, dest,
- 0, 0,
- min_width, min_height,
- (new_width - min_width) / -2,
- (new_height - min_height) / -2,
- factor,
- factor,
- GDK_INTERP_BILINEAR);
- return dest;
+ /* crop the result */
+ gdk_pixbuf_scale (src, dest,
+ 0, 0,
+ min_width, min_height,
+ (new_width - min_width) / -2,
+ (new_height - min_height) / -2,
+ factor,
+ factor,
+ GDK_INTERP_BILINEAR);
+ return dest;
}
static guchar *
create_gradient (const GdkRGBA *primary,
- const GdkRGBA *secondary,
- int n_pixels)
+ const GdkRGBA *secondary,
+ int n_pixels)
{
- guchar *result = g_malloc (n_pixels * 3);
- int i;
+ guchar *result = g_malloc (n_pixels * 3);
+ int i;
- for (i = 0; i < n_pixels; ++i) {
- double ratio = (i + 0.5) / n_pixels;
+ for (i = 0; i < n_pixels; ++i) {
+ double ratio = (i + 0.5) / n_pixels;
- result[3 * i + 0] = (guchar) ((primary->red * (1 - ratio) + secondary->red * ratio) * 0x100);
- result[3 * i + 1] = (guchar) ((primary->green * (1 - ratio) + secondary->green * ratio) * 0x100);
- result[3 * i + 2] = (guchar) ((primary->blue * (1 - ratio) + secondary->blue * ratio) * 0x100);
- }
+ result[3 * i + 0] = (guchar) ((primary->red * (1 - ratio) + secondary->red * ratio) * 0x100);
+ result[3 * i + 1] = (guchar) ((primary->green * (1 - ratio) + secondary->green * ratio) * 0x100);
+ result[3 * i + 2] = (guchar) ((primary->blue * (1 - ratio) + secondary->blue * ratio) * 0x100);
+ }
- return result;
+ return result;
}
static void
pixbuf_draw_gradient (GdkPixbuf *pixbuf,
- gboolean horizontal,
- GdkRGBA *primary,
- GdkRGBA *secondary,
- GdkRectangle *rect)
-{
- int width;
- int height;
- int rowstride;
- guchar *dst;
- int n_channels = 3;
-
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- width = rect->width;
- height = rect->height;
- dst = gdk_pixbuf_get_pixels (pixbuf) + rect->x * n_channels + rowstride * rect->y;
-
- if (horizontal) {
- guchar *gradient = create_gradient (primary, secondary, width);
- int copy_bytes_per_row = width * n_channels;
- int i;
-
- for (i = 0; i < height; i++) {
- guchar *d;
- d = dst + rowstride * i;
- memcpy (d, gradient, copy_bytes_per_row);
- }
- g_free (gradient);
- } else {
- guchar *gb, *gradient;
- int i;
-
- gradient = create_gradient (primary, secondary, height);
- for (i = 0; i < height; i++) {
- int j;
- guchar *d;
-
- d = dst + rowstride * i;
- gb = gradient + n_channels * i;
- for (j = width; j > 0; j--) {
- int k;
-
- for (k = 0; k < n_channels; k++) {
- *(d++) = gb[k];
- }
- }
- }
-
- g_free (gradient);
- }
+ gboolean horizontal,
+ GdkRGBA *primary,
+ GdkRGBA *secondary,
+ GdkRectangle *rect)
+{
+ int width;
+ int height;
+ int rowstride;
+ guchar *dst;
+ int n_channels = 3;
+
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ width = rect->width;
+ height = rect->height;
+ dst = gdk_pixbuf_get_pixels (pixbuf) + rect->x * n_channels + rowstride * rect->y;
+
+ if (horizontal) {
+ guchar *gradient = create_gradient (primary, secondary, width);
+ int copy_bytes_per_row = width * n_channels;
+ int i;
+
+ for (i = 0; i < height; i++) {
+ guchar *d;
+ d = dst + rowstride * i;
+ memcpy (d, gradient, copy_bytes_per_row);
+ }
+ g_free (gradient);
+ } else {
+ guchar *gb, *gradient;
+ int i;
+
+ gradient = create_gradient (primary, secondary, height);
+ for (i = 0; i < height; i++) {
+ int j;
+ guchar *d;
+
+ d = dst + rowstride * i;
+ gb = gradient + n_channels * i;
+ for (j = width; j > 0; j--) {
+ int k;
+
+ for (k = 0; k < n_channels; k++) {
+ *(d++) = gb[k];
+ }
+ }
+ }
+
+ g_free (gradient);
+ }
}
static void
pixbuf_blend (GdkPixbuf *src,
- GdkPixbuf *dest,
- int src_x,
- int src_y,
- int src_width,
- int src_height,
- int dest_x,
- int dest_y,
- double alpha)
+ GdkPixbuf *dest,
+ int src_x,
+ int src_y,
+ int src_width,
+ int src_height,
+ int dest_x,
+ int dest_y,
+ double alpha)
{
- int dest_width = gdk_pixbuf_get_width (dest);
- int dest_height = gdk_pixbuf_get_height (dest);
- int offset_x = dest_x - src_x;
- int offset_y = dest_y - src_y;
+ int dest_width = gdk_pixbuf_get_width (dest);
+ int dest_height = gdk_pixbuf_get_height (dest);
+ int offset_x = dest_x - src_x;
+ int offset_y = dest_y - src_y;
- if (src_width < 0)
- src_width = gdk_pixbuf_get_width (src);
+ if (src_width < 0)
+ src_width = gdk_pixbuf_get_width (src);
- if (src_height < 0)
- src_height = gdk_pixbuf_get_height (src);
+ if (src_height < 0)
+ src_height = gdk_pixbuf_get_height (src);
- if (dest_x < 0)
- dest_x = 0;
+ if (dest_x < 0)
+ dest_x = 0;
- if (dest_y < 0)
- dest_y = 0;
+ if (dest_y < 0)
+ dest_y = 0;
- if (dest_x + src_width > dest_width) {
- src_width = dest_width - dest_x;
- }
+ if (dest_x + src_width > dest_width) {
+ src_width = dest_width - dest_x;
+ }
- if (dest_y + src_height > dest_height) {
- src_height = dest_height - dest_y;
- }
+ if (dest_y + src_height > dest_height) {
+ src_height = dest_height - dest_y;
+ }
- gdk_pixbuf_composite (src, dest,
- dest_x, dest_y,
- src_width, src_height,
- offset_x, offset_y,
- 1, 1, GDK_INTERP_NEAREST,
- alpha * 0xFF + 0.5);
+ gdk_pixbuf_composite (src, dest,
+ dest_x, dest_y,
+ src_width, src_height,
+ offset_x, offset_y,
+ 1, 1, GDK_INTERP_NEAREST,
+ alpha * 0xFF + 0.5);
}
static void
-pixbuf_tile (GdkPixbuf *src, GdkPixbuf *dest)
+pixbuf_tile (GdkPixbuf *src,
+ GdkPixbuf *dest)
{
- int x, y;
- int tile_width, tile_height;
- int dest_width = gdk_pixbuf_get_width (dest);
- int dest_height = gdk_pixbuf_get_height (dest);
+ int x, y;
+ int tile_width, tile_height;
+ int dest_width = gdk_pixbuf_get_width (dest);
+ int dest_height = gdk_pixbuf_get_height (dest);
- tile_width = gdk_pixbuf_get_width (src);
- tile_height = gdk_pixbuf_get_height (src);
+ tile_width = gdk_pixbuf_get_width (src);
+ tile_height = gdk_pixbuf_get_height (src);
- for (y = 0; y < dest_height; y += tile_height) {
- for (x = 0; x < dest_width; x += tile_width) {
- pixbuf_blend (src, dest, 0, 0,
- tile_width, tile_height, x, y, 1.0);
- }
- }
+ for (y = 0; y < dest_height; y += tile_height) {
+ for (x = 0; x < dest_width; x += tile_width) {
+ pixbuf_blend (src, dest, 0, 0,
+ tile_width, tile_height, x, y, 1.0);
+ }
+ }
}
-static gboolean stack_is (SlideShow *parser, const char *s1, ...);
+static gboolean stack_is (SlideShow *parser,
+ const char *s1,
+ ...);
/* Parser for fading background */
static void
-handle_start_element (GMarkupParseContext *context,
- const gchar *name,
- const gchar **attr_names,
- const gchar **attr_values,
- gpointer user_data,
- GError **err)
-{
- SlideShow *parser = user_data;
- gint i;
-
- if (strcmp (name, "static") == 0 || strcmp (name, "transition") == 0) {
- Slide *slide = g_new0 (Slide, 1);
-
- if (strcmp (name, "static") == 0)
- slide->fixed = TRUE;
-
- g_queue_push_tail (parser->slides, slide);
- }
- else if (strcmp (name, "size") == 0) {
- Slide *slide = parser->slides->tail->data;
- FileSize *size = g_new0 (FileSize, 1);
- for (i = 0; attr_names[i]; i++) {
- if (strcmp (attr_names[i], "width") == 0)
- size->width = atoi (attr_values[i]);
- else if (strcmp (attr_names[i], "height") == 0)
- size->height = atoi (attr_values[i]);
- }
- if (parser->stack->tail &&
- (strcmp (parser->stack->tail->data, "file") == 0 ||
- strcmp (parser->stack->tail->data, "from") == 0)) {
- slide->file1 = g_slist_prepend (slide->file1, size);
- }
- else if (parser->stack->tail &&
- strcmp (parser->stack->tail->data, "to") == 0) {
- slide->file2 = g_slist_prepend (slide->file2, size);
- }
- }
- g_queue_push_tail (parser->stack, g_strdup (name));
+handle_start_element (GMarkupParseContext *context,
+ const gchar *name,
+ const gchar **attr_names,
+ const gchar **attr_values,
+ gpointer user_data,
+ GError **err)
+{
+ SlideShow *parser = user_data;
+ gint i;
+
+ if (strcmp (name, "static") == 0 || strcmp (name, "transition") == 0) {
+ Slide *slide = g_new0 (Slide, 1);
+
+ if (strcmp (name, "static") == 0)
+ slide->fixed = TRUE;
+
+ g_queue_push_tail (parser->slides, slide);
+ }
+ else if (strcmp (name, "size") == 0) {
+ Slide *slide = parser->slides->tail->data;
+ FileSize *size = g_new0 (FileSize, 1);
+ for (i = 0; attr_names[i]; i++) {
+ if (strcmp (attr_names[i], "width") == 0)
+ size->width = atoi (attr_values[i]);
+ else if (strcmp (attr_names[i], "height") == 0)
+ size->height = atoi (attr_values[i]);
+ }
+ if (parser->stack->tail &&
+ (strcmp (parser->stack->tail->data, "file") == 0 ||
+ strcmp (parser->stack->tail->data, "from") == 0)) {
+ slide->file1 = g_slist_prepend (slide->file1, size);
+ }
+ else if (parser->stack->tail &&
+ strcmp (parser->stack->tail->data, "to") == 0) {
+ slide->file2 = g_slist_prepend (slide->file2, size);
+ }
+ }
+ g_queue_push_tail (parser->stack, g_strdup (name));
}
static void
-handle_end_element (GMarkupParseContext *context,
- const gchar *name,
- gpointer user_data,
- GError **err)
+handle_end_element (GMarkupParseContext *context,
+ const gchar *name,
+ gpointer user_data,
+ GError **err)
{
- SlideShow *parser = user_data;
+ SlideShow *parser = user_data;
- g_free (g_queue_pop_tail (parser->stack));
+ g_free (g_queue_pop_tail (parser->stack));
}
static gboolean
-stack_is (SlideShow *parser,
- const char *s1,
- ...)
+stack_is (SlideShow *parser,
+ const char *s1,
+ ...)
{
- GList *stack = NULL;
- const char *s;
- GList *l1, *l2;
- va_list args;
+ GList *stack = NULL;
+ const char *s;
+ GList *l1, *l2;
+ va_list args;
- stack = g_list_prepend (stack, (gpointer)s1);
+ stack = g_list_prepend (stack, (gpointer)s1);
- va_start (args, s1);
+ va_start (args, s1);
- s = va_arg (args, const char *);
- while (s) {
- stack = g_list_prepend (stack, (gpointer)s);
- s = va_arg (args, const char *);
- }
+ s = va_arg (args, const char *);
+ while (s) {
+ stack = g_list_prepend (stack, (gpointer)s);
+ s = va_arg (args, const char *);
+ }
- va_end (args);
+ va_end (args);
- l1 = stack;
- l2 = parser->stack->head;
+ l1 = stack;
+ l2 = parser->stack->head;
- while (l1 && l2) {
- if (strcmp (l1->data, l2->data) != 0) {
- g_list_free (stack);
- return FALSE;
- }
+ while (l1 && l2) {
+ if (strcmp (l1->data, l2->data) != 0) {
+ g_list_free (stack);
+ return FALSE;
+ }
- l1 = l1->next;
- l2 = l2->next;
- }
+ l1 = l1->next;
+ l2 = l2->next;
+ }
- g_list_free (stack);
+ g_list_free (stack);
- return (!l1 && !l2);
+ return (!l1 && !l2);
}
static int
parse_int (const char *text)
{
- return strtol (text, NULL, 0);
+ return strtol (text, NULL, 0);
}
static void
-handle_text (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **err)
-{
- SlideShow *parser = user_data;
- FileSize *fs;
- gint i;
-
- g_return_if_fail (parser != NULL);
- g_return_if_fail (parser->slides != NULL);
-
- Slide *slide = parser->slides->tail ? parser->slides->tail->data : NULL;
-
- if (stack_is (parser, "year", "starttime", "background", NULL)) {
- parser->start_tm.tm_year = parse_int (text) - 1900;
- }
- else if (stack_is (parser, "month", "starttime", "background", NULL)) {
- parser->start_tm.tm_mon = parse_int (text) - 1;
- }
- else if (stack_is (parser, "day", "starttime", "background", NULL)) {
- parser->start_tm.tm_mday = parse_int (text);
- }
- else if (stack_is (parser, "hour", "starttime", "background", NULL)) {
- parser->start_tm.tm_hour = parse_int (text) - 1;
- }
- else if (stack_is (parser, "minute", "starttime", "background", NULL)) {
- parser->start_tm.tm_min = parse_int (text);
- }
- else if (stack_is (parser, "second", "starttime", "background", NULL)) {
- parser->start_tm.tm_sec = parse_int (text);
- }
- else if (stack_is (parser, "duration", "static", "background", NULL) ||
- stack_is (parser, "duration", "transition", "background", NULL)) {
- g_return_if_fail (slide != NULL);
-
- slide->duration = g_strtod (text, NULL);
- parser->total_duration += slide->duration;
- }
- else if (stack_is (parser, "file", "static", "background", NULL) ||
- stack_is (parser, "from", "transition", "background", NULL)) {
- g_return_if_fail (slide != NULL);
-
- for (i = 0; text[i]; i++) {
- if (!g_ascii_isspace (text[i]))
- break;
- }
- if (text[i] == 0)
- return;
- fs = g_new (FileSize, 1);
- fs->width = -1;
- fs->height = -1;
- fs->file = g_strdup (text);
- slide->file1 = g_slist_prepend (slide->file1, fs);
- if (slide->file1->next != NULL)
- parser->has_multiple_sizes = TRUE;
- }
- else if (stack_is (parser, "size", "file", "static", "background", NULL) ||
- stack_is (parser, "size", "from", "transition", "background", NULL)) {
- g_return_if_fail (slide != NULL);
-
- fs = slide->file1->data;
- fs->file = g_strdup (text);
- if (slide->file1->next != NULL)
- parser->has_multiple_sizes = TRUE;
- }
- else if (stack_is (parser, "to", "transition", "background", NULL)) {
- g_return_if_fail (slide != NULL);
-
- for (i = 0; text[i]; i++) {
- if (!g_ascii_isspace (text[i]))
- break;
- }
- if (text[i] == 0)
- return;
- fs = g_new (FileSize, 1);
- fs->width = -1;
- fs->height = -1;
- fs->file = g_strdup (text);
- slide->file2 = g_slist_prepend (slide->file2, fs);
- if (slide->file2->next != NULL)
- parser->has_multiple_sizes = TRUE;
- }
- else if (stack_is (parser, "size", "to", "transition", "background", NULL)) {
- g_return_if_fail (slide != NULL);
-
- fs = slide->file2->data;
- fs->file = g_strdup (text);
- if (slide->file2->next != NULL)
- parser->has_multiple_sizes = TRUE;
- }
+handle_text (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **err)
+{
+ SlideShow *parser = user_data;
+ FileSize *fs;
+ gint i;
+
+ g_return_if_fail (parser != NULL);
+ g_return_if_fail (parser->slides != NULL);
+
+ Slide *slide = parser->slides->tail ? parser->slides->tail->data : NULL;
+
+ if (stack_is (parser, "year", "starttime", "background", NULL)) {
+ parser->start_tm.tm_year = parse_int (text) - 1900;
+ }
+ else if (stack_is (parser, "month", "starttime", "background", NULL)) {
+ parser->start_tm.tm_mon = parse_int (text) - 1;
+ }
+ else if (stack_is (parser, "day", "starttime", "background", NULL)) {
+ parser->start_tm.tm_mday = parse_int (text);
+ }
+ else if (stack_is (parser, "hour", "starttime", "background", NULL)) {
+ parser->start_tm.tm_hour = parse_int (text) - 1;
+ }
+ else if (stack_is (parser, "minute", "starttime", "background", NULL)) {
+ parser->start_tm.tm_min = parse_int (text);
+ }
+ else if (stack_is (parser, "second", "starttime", "background", NULL)) {
+ parser->start_tm.tm_sec = parse_int (text);
+ }
+ else if (stack_is (parser, "duration", "static", "background", NULL) ||
+ stack_is (parser, "duration", "transition", "background", NULL)) {
+ g_return_if_fail (slide != NULL);
+
+ slide->duration = g_strtod (text, NULL);
+ parser->total_duration += slide->duration;
+ }
+ else if (stack_is (parser, "file", "static", "background", NULL) ||
+ stack_is (parser, "from", "transition", "background", NULL)) {
+ g_return_if_fail (slide != NULL);
+
+ for (i = 0; text[i]; i++) {
+ if (!g_ascii_isspace (text[i]))
+ break;
+ }
+ if (text[i] == 0)
+ return;
+ fs = g_new (FileSize, 1);
+ fs->width = -1;
+ fs->height = -1;
+ fs->file = g_strdup (text);
+ slide->file1 = g_slist_prepend (slide->file1, fs);
+ if (slide->file1->next != NULL)
+ parser->has_multiple_sizes = TRUE;
+ }
+ else if (stack_is (parser, "size", "file", "static", "background", NULL) ||
+ stack_is (parser, "size", "from", "transition", "background", NULL)) {
+ g_return_if_fail (slide != NULL);
+
+ fs = slide->file1->data;
+ fs->file = g_strdup (text);
+ if (slide->file1->next != NULL)
+ parser->has_multiple_sizes = TRUE;
+ }
+ else if (stack_is (parser, "to", "transition", "background", NULL)) {
+ g_return_if_fail (slide != NULL);
+
+ for (i = 0; text[i]; i++) {
+ if (!g_ascii_isspace (text[i]))
+ break;
+ }
+ if (text[i] == 0)
+ return;
+ fs = g_new (FileSize, 1);
+ fs->width = -1;
+ fs->height = -1;
+ fs->file = g_strdup (text);
+ slide->file2 = g_slist_prepend (slide->file2, fs);
+ if (slide->file2->next != NULL)
+ parser->has_multiple_sizes = TRUE;
+ }
+ else if (stack_is (parser, "size", "to", "transition", "background", NULL)) {
+ g_return_if_fail (slide != NULL);
+
+ fs = slide->file2->data;
+ fs->file = g_strdup (text);
+ if (slide->file2->next != NULL)
+ parser->has_multiple_sizes = TRUE;
+ }
}
static SlideShow *
slideshow_ref (SlideShow *show)
{
- show->ref_count++;
- return show;
+ show->ref_count++;
+ return show;
}
static void
slideshow_unref (SlideShow *show)
{
- GList *list;
- GSList *slist;
- FileSize *size;
+ GList *list;
+ GSList *slist;
+ FileSize *size;
- show->ref_count--;
- if (show->ref_count > 0)
- return;
+ show->ref_count--;
+ if (show->ref_count > 0)
+ return;
- for (list = show->slides->head; list != NULL; list = list->next) {
- Slide *slide = list->data;
+ for (list = show->slides->head; list != NULL; list = list->next) {
+ Slide *slide = list->data;
- for (slist = slide->file1; slist != NULL; slist = slist->next) {
- size = slist->data;
- g_free (size->file);
- g_free (size);
- }
- g_slist_free (slide->file1);
+ for (slist = slide->file1; slist != NULL; slist = slist->next) {
+ size = slist->data;
+ g_free (size->file);
+ g_free (size);
+ }
+ g_slist_free (slide->file1);
- for (slist = slide->file2; slist != NULL; slist = slist->next) {
- size = slist->data;
- g_free (size->file);
- g_free (size);
- }
- g_slist_free (slide->file2);
+ for (slist = slide->file2; slist != NULL; slist = slist->next) {
+ size = slist->data;
+ g_free (size->file);
+ g_free (size);
+ }
+ g_slist_free (slide->file2);
- g_free (slide);
- }
+ g_free (slide);
+ }
- g_queue_free (show->slides);
+ g_queue_free (show->slides);
- g_list_foreach (show->stack->head, (GFunc) g_free, NULL);
- g_queue_free (show->stack);
+ g_list_foreach (show->stack->head, (GFunc) g_free, NULL);
+ g_queue_free (show->stack);
- g_free (show);
+ g_free (show);
}
static void
dump_bg (SlideShow *show)
{
#if 0
- GList *list;
- GSList *slist;
-
- for (list = show->slides->head; list != NULL; list = list->next)
- {
- Slide *slide = list->data;
-
- g_print ("\nSlide: %s\n", slide->fixed? "fixed" : "transition");
- g_print ("duration: %f\n", slide->duration);
- g_print ("File1:\n");
- for (slist = slide->file1; slist != NULL; slist = slist->next) {
- FileSize *size = slist->data;
- g_print ("\t%s (%dx%d)\n",
- size->file, size->width, size->height);
- }
- g_print ("File2:\n");
- for (slist = slide->file2; slist != NULL; slist = slist->next) {
- FileSize *size = slist->data;
- g_print ("\t%s (%dx%d)\n",
- size->file, size->width, size->height);
- }
- }
+ GList *list;
+ GSList *slist;
+
+ for (list = show->slides->head; list != NULL; list = list->next)
+ {
+ Slide *slide = list->data;
+
+ g_print ("\nSlide: %s\n", slide->fixed? "fixed" : "transition");
+ g_print ("duration: %f\n", slide->duration);
+ g_print ("File1:\n");
+ for (slist = slide->file1; slist != NULL; slist = slist->next) {
+ FileSize *size = slist->data;
+ g_print ("\t%s (%dx%d)\n",
+ size->file, size->width, size->height);
+ }
+ g_print ("File2:\n");
+ for (slist = slide->file2; slist != NULL; slist = slist->next) {
+ FileSize *size = slist->data;
+ g_print ("\t%s (%dx%d)\n",
+ size->file, size->width, size->height);
+ }
+ }
#endif
}
static void
-threadsafe_localtime (time_t time, struct tm *tm)
+threadsafe_localtime (time_t time,
+ struct tm *tm)
{
- struct tm *res;
+ struct tm *res;
- G_LOCK_DEFINE_STATIC (localtime_mutex);
+ G_LOCK_DEFINE_STATIC (localtime_mutex);
- G_LOCK (localtime_mutex);
+ G_LOCK (localtime_mutex);
- res = localtime (&time);
- if (tm) {
- *tm = *res;
- }
+ res = localtime (&time);
+ if (tm) {
+ *tm = *res;
+ }
- G_UNLOCK (localtime_mutex);
+ G_UNLOCK (localtime_mutex);
}
static SlideShow *
-read_slideshow_file (const char *filename,
- GError **err)
-{
- GMarkupParser parser = {
- handle_start_element,
- handle_end_element,
- handle_text,
- NULL, /* passthrough */
- NULL, /* error */
- };
-
- GFile *file;
- char *contents = NULL;
- gsize len;
- SlideShow *show = NULL;
- GMarkupParseContext *context = NULL;
- time_t t;
-
- if (!filename)
- return NULL;
-
- file = g_file_new_for_path (filename);
- if (!g_file_load_contents (file, NULL, &contents, &len, NULL, NULL)) {
- g_object_unref (file);
- return NULL;
- }
- g_object_unref (file);
-
- show = g_new0 (SlideShow, 1);
- show->ref_count = 1;
- threadsafe_localtime ((time_t)0, &show->start_tm);
- show->stack = g_queue_new ();
- show->slides = g_queue_new ();
-
- context = g_markup_parse_context_new (&parser, 0, show, NULL);
-
- if (!g_markup_parse_context_parse (context, contents, len, err)) {
- slideshow_unref (show);
- show = NULL;
- }
-
-
- if (show) {
- if (!g_markup_parse_context_end_parse (context, err)) {
- slideshow_unref (show);
- show = NULL;
- }
- }
-
- g_markup_parse_context_free (context);
-
- if (show) {
- int len;
-
- t = mktime (&show->start_tm);
-
- show->start_time = (double)t;
-
- dump_bg (show);
-
- len = g_queue_get_length (show->slides);
-
- /* no slides, that's not a slideshow */
- if (len == 0) {
- slideshow_unref (show);
- show = NULL;
- /* one slide, there's no transition */
- } else if (len == 1) {
- Slide *slide = show->slides->head->data;
- slide->duration = show->total_duration = G_MAXUINT;
- }
- }
-
- g_free (contents);
-
- return show;
+read_slideshow_file (const char *filename,
+ GError **err)
+{
+ GMarkupParser parser = {
+ handle_start_element,
+ handle_end_element,
+ handle_text,
+ NULL, /* passthrough */
+ NULL, /* error */
+ };
+
+ GFile *file;
+ char *contents = NULL;
+ gsize len;
+ SlideShow *show = NULL;
+ GMarkupParseContext *context = NULL;
+ time_t t;
+
+ if (!filename)
+ return NULL;
+
+ file = g_file_new_for_path (filename);
+ if (!g_file_load_contents (file, NULL, &contents, &len, NULL, NULL)) {
+ g_object_unref (file);
+ return NULL;
+ }
+ g_object_unref (file);
+
+ show = g_new0 (SlideShow, 1);
+ show->ref_count = 1;
+ threadsafe_localtime ((time_t)0, &show->start_tm);
+ show->stack = g_queue_new ();
+ show->slides = g_queue_new ();
+
+ context = g_markup_parse_context_new (&parser, 0, show, NULL);
+
+ if (!g_markup_parse_context_parse (context, contents, len, err)) {
+ slideshow_unref (show);
+ show = NULL;
+ }
+
+
+ if (show) {
+ if (!g_markup_parse_context_end_parse (context, err)) {
+ slideshow_unref (show);
+ show = NULL;
+ }
+ }
+
+ g_markup_parse_context_free (context);
+
+ if (show) {
+ int len;
+
+ t = mktime (&show->start_tm);
+
+ show->start_time = (double)t;
+
+ dump_bg (show);
+
+ len = g_queue_get_length (show->slides);
+
+ /* no slides, that's not a slideshow */
+ if (len == 0) {
+ slideshow_unref (show);
+ show = NULL;
+ /* one slide, there's no transition */
+ } else if (len == 1) {
+ Slide *slide = show->slides->head->data;
+ slide->duration = show->total_duration = G_MAXUINT;
+ }
+ }
+
+ g_free (contents);
+
+ return show;
}
diff --git a/src/xfce-bg.h b/src/xfce-bg.h
index 74fd847..e51492e 100644
--- a/src/xfce-bg.h
+++ b/src/xfce-bg.h
@@ -19,7 +19,7 @@
Boston, MA 02110-1301, USA.
Authors: Soren Sandmann <sandmann at redhat.com>
- Jasmine Hassan <jasmine.aura at gmail.com>
+ Jasmine Hassan <jasmine.aura at gmail.com>
*/
#ifndef __XFCE_BG_H__
@@ -39,29 +39,29 @@ G_BEGIN_DECLS
#define XFCE_BG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_BG, XfceBGClass))
/* whether to draw the desktop bg */
-#define XFCE_BG_KEY_DRAW_BACKGROUND "draw-background"
+#define XFCE_BG_KEY_DRAW_BACKGROUND "draw-background"
/* whether Thunar or xfce-settings-daemon draw the desktop */
-#define XFCE_BG_KEY_SHOW_DESKTOP "show-desktop-icons"
+#define XFCE_BG_KEY_SHOW_DESKTOP "show-desktop-icons"
/* whether to fade when changing background (By Thunar/m-s-d) */
-#define XFCE_BG_KEY_BACKGROUND_FADE "background-fade"
+#define XFCE_BG_KEY_BACKGROUND_FADE "background-fade"
-#define XFCE_BG_KEY_PRIMARY_COLOR "primary-color"
-#define XFCE_BG_KEY_SECONDARY_COLOR "secondary-color"
-#define XFCE_BG_KEY_COLOR_TYPE "color-shading-type"
-#define XFCE_BG_KEY_PICTURE_PLACEMENT "picture-options"
-#define XFCE_BG_KEY_PICTURE_OPACITY "picture-opacity"
-#define XFCE_BG_KEY_PICTURE_FILENAME "picture-filename"
+#define XFCE_BG_KEY_PRIMARY_COLOR "primary-color"
+#define XFCE_BG_KEY_SECONDARY_COLOR "secondary-color"
+#define XFCE_BG_KEY_COLOR_TYPE "color-shading-type"
+#define XFCE_BG_KEY_PICTURE_PLACEMENT "picture-options"
+#define XFCE_BG_KEY_PICTURE_OPACITY "picture-opacity"
+#define XFCE_BG_KEY_PICTURE_FILENAME "picture-filename"
typedef struct _XfceBG XfceBG;
typedef struct _XfceBGClass XfceBGClass;
typedef enum {
- XFCE_BG_COLOR_SOLID,
- XFCE_BG_COLOR_H_GRADIENT,
- XFCE_BG_COLOR_V_GRADIENT,
- XFCE_BG_COLOR_TRANSPARENT
+ XFCE_BG_COLOR_SOLID,
+ XFCE_BG_COLOR_H_GRADIENT,
+ XFCE_BG_COLOR_V_GRADIENT,
+ XFCE_BG_COLOR_TRANSPARENT
} XfceBGColorType;
typedef enum {
@@ -74,24 +74,24 @@ typedef enum {
XFCE_BG_PLACEMENT_SPANNED
} XfceBGPlacement;
-GType xfce_bg_get_type (void);
-XfceBG * xfce_bg_new (void);
-void xfce_bg_load_from_preferences (XfceBG *bg,
- GdkMonitor *monitor);
+GType xfce_bg_get_type (void);
+XfceBG * xfce_bg_new (void);
+void xfce_bg_load_from_preferences (XfceBG *bg,
+ GdkMonitor *monitor);
/* Drawing and thumbnailing */
-cairo_surface_t *xfce_bg_create_surface (XfceBG *bg,
- GdkWindow *window,
- int screen_width,
- int screen_height,
- int monitor_width,
- int monitor_height);
-
-GdkPixbuf *xfce_bg_get_pixbuf(XfceBG *bg,
- int screen_width,
- int screen_height,
- int monitor_width,
- int monitor_height);
+cairo_surface_t * xfce_bg_create_surface (XfceBG *bg,
+ GdkWindow *window,
+ int screen_width,
+ int screen_height,
+ int monitor_width,
+ int monitor_height);
+
+GdkPixbuf * xfce_bg_get_pixbuf (XfceBG *bg,
+ int screen_width,
+ int screen_height,
+ int monitor_width,
+ int monitor_height);
G_END_DECLS
diff --git a/src/xfce-desktop-utils.c b/src/xfce-desktop-utils.c
index 1e631f2..bb2d5e9 100644
--- a/src/xfce-desktop-utils.c
+++ b/src/xfce-desktop-utils.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/* xfce-desktop-utils.c - Utilities for the Xfce Desktop
Copyright (C) 1998 Tom Tromey
@@ -53,20 +53,22 @@
* Since: 1.7.1
**/
gboolean
-xfce_gdk_spawn_command_line_on_screen (GdkScreen *screen, const gchar *command, GError **error)
+xfce_gdk_spawn_command_line_on_screen (GdkScreen *screen,
+ const gchar *command,
+ GError **error)
{
- GAppInfo *appinfo = NULL;
- GdkAppLaunchContext *context = NULL;
- gboolean res = FALSE;
+ GAppInfo *appinfo = NULL;
+ GdkAppLaunchContext *context = NULL;
+ gboolean res = FALSE;
- appinfo = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NONE, error);
+ appinfo = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NONE, error);
- if (appinfo) {
- context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
- res = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), error);
- g_object_unref (context);
- g_object_unref (appinfo);
- }
+ if (appinfo) {
+ context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
+ res = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), error);
+ g_object_unref (context);
+ g_object_unref (appinfo);
+ }
- return res;
+ return res;
}
diff --git a/src/xfce-desktop-utils.h b/src/xfce-desktop-utils.h
index 5c3b7f4..838eb70 100644
--- a/src/xfce-desktop-utils.h
+++ b/src/xfce-desktop-utils.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/* xfce-ditem.h - Utilities for the Xfce Desktop
Copyright (C) 1998 Tom Tromey
@@ -32,7 +32,9 @@
G_BEGIN_DECLS
/* replace gdk_spawn_command_line_on_screen, not available in GTK3 */
-gboolean xfce_gdk_spawn_command_line_on_screen (GdkScreen *screen, const gchar *command, GError **error);
+gboolean xfce_gdk_spawn_command_line_on_screen (GdkScreen *screen,
+ const gchar *command,
+ GError **error);
G_END_DECLS
diff --git a/src/xfce-rr-private.h b/src/xfce-rr-private.h
index 4cbfdc1..697a385 100644
--- a/src/xfce-rr-private.h
+++ b/src/xfce-rr-private.h
@@ -12,35 +12,35 @@ typedef struct ScreenInfo ScreenInfo;
struct ScreenInfo
{
#ifdef HAVE_RANDR
- XRRScreenResources *resources;
- RROutput primary;
+ XRRScreenResources *resources;
+ RROutput primary;
#endif
- XfceRROutput **outputs;
- XfceRRCrtc **crtcs;
- XfceRRMode **modes;
- XfceRRMode **clone_modes;
- XfceRRScreen *screen;
- int min_width;
- int max_width;
- int min_height;
- int max_height;
+ XfceRROutput **outputs;
+ XfceRRCrtc **crtcs;
+ XfceRRMode **modes;
+ XfceRRMode **clone_modes;
+ XfceRRScreen *screen;
+ int min_width;
+ int max_width;
+ int min_height;
+ int max_height;
};
struct XfceRRScreenPrivate
{
- GdkScreen *gdk_screen;
- GdkWindow *gdk_root;
- Display *xdisplay;
- Screen *xscreen;
- ScreenInfo *info;
- Window xroot;
-
- int randr_event_base;
- int rr_major_version;
- int rr_minor_version;
-
- Atom connector_type_atom;
+ GdkScreen *gdk_screen;
+ GdkWindow *gdk_root;
+ Display *xdisplay;
+ Screen *xscreen;
+ ScreenInfo *info;
+ Window xroot;
+
+ int randr_event_base;
+ int rr_major_version;
+ int rr_minor_version;
+
+ Atom connector_type_atom;
};
#endif
diff --git a/src/xfce-rr.c b/src/xfce-rr.c
index b6c5e8e..0c811a6 100644
--- a/src/xfce-rr.c
+++ b/src/xfce-rr.c
@@ -47,12 +47,12 @@ typedef int RROutput;
typedef int RRCrtc;
typedef int RRMode;
typedef int Rotation;
-#define RR_Rotate_0 1
-#define RR_Rotate_90 2
-#define RR_Rotate_180 4
-#define RR_Rotate_270 8
-#define RR_Reflect_X 16
-#define RR_Reflect_Y 32
+#define RR_Rotate_0 1
+#define RR_Rotate_90 2
+#define RR_Rotate_180 4
+#define RR_Rotate_270 8
+#define RR_Reflect_X 16
+#define RR_Reflect_Y 32
#endif
enum {
@@ -70,107 +70,116 @@ gint screen_signals[SCREEN_SIGNAL_LAST];
struct XfceRROutput
{
- ScreenInfo * info;
- RROutput id;
-
- char * name;
- XfceRRCrtc * current_crtc;
- gboolean connected;
- gulong width_mm;
- gulong height_mm;
- XfceRRCrtc ** possible_crtcs;
- XfceRROutput ** clones;
- XfceRRMode ** modes;
- int n_preferred;
- guint8 * edid_data;
- int edid_size;
- char * connector_type;
+ ScreenInfo *info;
+ RROutput id;
+
+ char *name;
+ XfceRRCrtc *current_crtc;
+ gboolean connected;
+ gulong width_mm;
+ gulong height_mm;
+ XfceRRCrtc **possible_crtcs;
+ XfceRROutput **clones;
+ XfceRRMode **modes;
+ int n_preferred;
+ guint8 *edid_data;
+ int edid_size;
+ char *connector_type;
};
struct XfceRROutputWrap
{
- RROutput id;
+ RROutput id;
};
struct XfceRRCrtc
{
- ScreenInfo * info;
- RRCrtc id;
-
- XfceRRMode * current_mode;
- XfceRROutput ** current_outputs;
- XfceRROutput ** possible_outputs;
- int x;
- int y;
-
- XfceRRRotation current_rotation;
- XfceRRRotation rotations;
- int gamma_size;
+ ScreenInfo *info;
+ RRCrtc id;
+
+ XfceRRMode *current_mode;
+ XfceRROutput **current_outputs;
+ XfceRROutput **possible_outputs;
+ int x;
+ int y;
+
+ XfceRRRotation current_rotation;
+ XfceRRRotation rotations;
+ int gamma_size;
};
struct XfceRRMode
{
- ScreenInfo * info;
- RRMode id;
- char * name;
- int width;
- int height;
- int freq; /* in mHz */
+ ScreenInfo *info;
+ RRMode id;
+ char *name;
+ int width;
+ int height;
+ int freq; /* in mHz */
};
/* XfceRRCrtc */
-static XfceRRCrtc * crtc_new (ScreenInfo *info,
- RRCrtc id);
-static XfceRRCrtc * crtc_copy (const XfceRRCrtc *from);
-static void crtc_free (XfceRRCrtc *crtc);
+static XfceRRCrtc * crtc_new (ScreenInfo *info,
+ RRCrtc id);
+static XfceRRCrtc * crtc_copy (const XfceRRCrtc *from);
+static void crtc_free (XfceRRCrtc *crtc);
#ifdef HAVE_RANDR
-static gboolean crtc_initialize (XfceRRCrtc *crtc,
- XRRScreenResources *res,
- GError **error);
+static gboolean crtc_initialize (XfceRRCrtc *crtc,
+ XRRScreenResources *res,
+ GError **error);
#endif
/* XfceRROutput */
-static XfceRROutput *output_new (ScreenInfo *info,
- RROutput id);
+static XfceRROutput * output_new (ScreenInfo *info,
+ RROutput id);
#ifdef HAVE_RANDR
-static gboolean output_initialize (XfceRROutput *output,
- XRRScreenResources *res,
- GError **error);
+static gboolean output_initialize (XfceRROutput *output,
+ XRRScreenResources *res,
+ GError **error);
#endif
-static XfceRROutput *output_copy (const XfceRROutput *from);
-static void output_free (XfceRROutput *output);
+static XfceRROutput * output_copy (const XfceRROutput *from);
+static void output_free (XfceRROutput *output);
/* XfceRRMode */
-static XfceRRMode * mode_new (ScreenInfo *info,
- RRMode id);
+static XfceRRMode * mode_new (ScreenInfo *info,
+ RRMode id);
#ifdef HAVE_RANDR
-static void mode_initialize (XfceRRMode *mode,
- XRRModeInfo *info);
+static void mode_initialize (XfceRRMode *mode,
+ XRRModeInfo *info);
#endif
-static XfceRRMode * mode_copy (const XfceRRMode *from);
-static void mode_free (XfceRRMode *mode);
+static XfceRRMode * mode_copy (const XfceRRMode *from);
+static void mode_free (XfceRRMode *mode);
+
+static guint xfce_rr_mode_get_width (XfceRRMode *mode);
+static guint xfce_rr_mode_get_height (XfceRRMode *mode);
+
+static XfceRRMode ** xfce_rr_output_list_modes (XfceRROutput *output);
+
+static void xfce_rr_screen_get_ranges (XfceRRScreen *screen,
+ int *min_width,
+ int *max_width,
+ int *min_height,
+ int *max_height);
+
+static void xfce_rr_screen_finalize (GObject *gobject);
+static void xfce_rr_screen_set_property (GObject *gobject,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *property);
+static void xfce_rr_screen_get_property (GObject *gobject,
+ guint property_id,
+ GValue *value,
+ GParamSpec *property);
+static gboolean xfce_rr_screen_initable_init (GInitable *initable,
+ GCancellable *canc,
+ GError **error);
+static void xfce_rr_screen_initable_iface_init (GInitableIface *iface);
-static guint xfce_rr_mode_get_width (XfceRRMode *mode);
-static guint xfce_rr_mode_get_height (XfceRRMode *mode);
-
-static XfceRRMode **xfce_rr_output_list_modes (XfceRROutput *output);
-
-static void xfce_rr_screen_get_ranges (XfceRRScreen *screen,
- int *min_width,
- int *max_width,
- int *min_height,
- int *max_height);
-
-static void xfce_rr_screen_finalize (GObject*);
-static void xfce_rr_screen_set_property (GObject*, guint, const GValue*, GParamSpec*);
-static void xfce_rr_screen_get_property (GObject*, guint, GValue*, GParamSpec*);
-static gboolean xfce_rr_screen_initable_init (GInitable*, GCancellable*, GError**);
-static void xfce_rr_screen_initable_iface_init (GInitableIface *iface);
G_DEFINE_TYPE_WITH_CODE (XfceRRScreen, xfce_rr_screen, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, xfce_rr_screen_initable_iface_init))
@@ -196,7 +205,8 @@ xfce_rr_error_quark (void)
/* Screen */
static XfceRROutput *
-xfce_rr_output_by_id (ScreenInfo *info, RROutput id)
+xfce_rr_output_by_id (ScreenInfo *info,
+ RROutput id)
{
XfceRROutput **output;
@@ -204,15 +214,16 @@ xfce_rr_output_by_id (ScreenInfo *info, RROutput id)
for (output = info->outputs; *output; ++output)
{
- if ((*output)->id == id)
- return *output;
+ if ((*output)->id == id)
+ return *output;
}
return NULL;
}
static XfceRRCrtc *
-crtc_by_id (ScreenInfo *info, RRCrtc id)
+crtc_by_id (ScreenInfo *info,
+ RRCrtc id)
{
XfceRRCrtc **crtc;
@@ -221,15 +232,16 @@ crtc_by_id (ScreenInfo *info, RRCrtc id)
for (crtc = info->crtcs; *crtc; ++crtc)
{
- if ((*crtc)->id == id)
- return *crtc;
+ if ((*crtc)->id == id)
+ return *crtc;
}
return NULL;
}
static XfceRRMode *
-mode_by_id (ScreenInfo *info, RRMode id)
+mode_by_id (ScreenInfo *info,
+ RRMode id)
{
XfceRRMode **mode;
@@ -237,8 +249,8 @@ mode_by_id (ScreenInfo *info, RRMode id)
for (mode = info->modes; *mode; ++mode)
{
- if ((*mode)->id == id)
- return *mode;
+ if ((*mode)->id == id)
+ return *mode;
}
return NULL;
@@ -248,67 +260,68 @@ static void
screen_info_free (ScreenInfo *info)
{
XfceRROutput **output;
- XfceRRCrtc **crtc;
- XfceRRMode **mode;
+ XfceRRCrtc **crtc;
+ XfceRRMode **mode;
g_assert (info != NULL);
#ifdef HAVE_RANDR
if (info->resources)
{
- XRRFreeScreenResources (info->resources);
+ XRRFreeScreenResources (info->resources);
- info->resources = NULL;
+ info->resources = NULL;
}
#endif
if (info->outputs)
{
- for (output = info->outputs; *output; ++output)
- output_free (*output);
- g_free (info->outputs);
+ for (output = info->outputs; *output; ++output)
+ output_free (*output);
+ g_free (info->outputs);
}
if (info->crtcs)
{
- for (crtc = info->crtcs; *crtc; ++crtc)
- crtc_free (*crtc);
- g_free (info->crtcs);
+ for (crtc = info->crtcs; *crtc; ++crtc)
+ crtc_free (*crtc);
+ g_free (info->crtcs);
}
if (info->modes)
{
- for (mode = info->modes; *mode; ++mode)
- mode_free (*mode);
- g_free (info->modes);
+ for (mode = info->modes; *mode; ++mode)
+ mode_free (*mode);
+ g_free (info->modes);
}
if (info->clone_modes)
{
- /* The modes themselves were freed above */
- g_free (info->clone_modes);
+ /* The modes themselves were freed above */
+ g_free (info->clone_modes);
}
g_free (info);
}
static gboolean
-has_similar_mode (XfceRROutput *output, XfceRRMode *mode)
+has_similar_mode (XfceRROutput *output,
+ XfceRRMode *mode)
{
- int i;
+ int i;
XfceRRMode **modes = xfce_rr_output_list_modes (output);
- int width = xfce_rr_mode_get_width (mode);
- int height = xfce_rr_mode_get_height (mode);
+ int width = xfce_rr_mode_get_width (mode);
+ int height = xfce_rr_mode_get_height (mode);
for (i = 0; modes[i] != NULL; ++i)
{
- XfceRRMode *m = modes[i];
+ XfceRRMode *m = modes[i];
- if (xfce_rr_mode_get_width (m) == width &&
- xfce_rr_mode_get_height (m) == height)
- {
- return TRUE;
- }
+ if (xfce_rr_mode_get_width (m) == width &&
+ xfce_rr_mode_get_height (m) == height)
+ {
+ return TRUE;
+ }
}
return FALSE;
@@ -322,38 +335,38 @@ gather_clone_modes (ScreenInfo *info)
for (i = 0; info->outputs[i] != NULL; ++i)
{
- int j;
- XfceRROutput *output1, *output2;
-
- output1 = info->outputs[i];
-
- if (!output1->connected)
- continue;
-
- for (j = 0; output1->modes[j] != NULL; ++j)
- {
- XfceRRMode *mode = output1->modes[j];
- gboolean valid;
- int k;
-
- valid = TRUE;
- for (k = 0; info->outputs[k] != NULL; ++k)
- {
- output2 = info->outputs[k];
-
- if (!output2->connected)
- continue;
-
- if (!has_similar_mode (output2, mode))
- {
- valid = FALSE;
- break;
- }
- }
-
- if (valid)
- g_ptr_array_add (result, mode);
- }
+ int j;
+ XfceRROutput *output1, *output2;
+
+ output1 = info->outputs[i];
+
+ if (!output1->connected)
+ continue;
+
+ for (j = 0; output1->modes[j] != NULL; ++j)
+ {
+ XfceRRMode *mode = output1->modes[j];
+ gboolean valid;
+ int k;
+
+ valid = TRUE;
+ for (k = 0; info->outputs[k] != NULL; ++k)
+ {
+ output2 = info->outputs[k];
+
+ if (!output2->connected)
+ continue;
+
+ if (!has_similar_mode (output2, mode))
+ {
+ valid = FALSE;
+ break;
+ }
+ }
+
+ if (valid)
+ g_ptr_array_add (result, mode);
+ }
}
g_ptr_array_add (result, NULL);
@@ -363,13 +376,13 @@ gather_clone_modes (ScreenInfo *info)
#ifdef HAVE_RANDR
static gboolean
-fill_screen_info_from_resources (ScreenInfo *info,
- XRRScreenResources *resources,
- GError **error)
+fill_screen_info_from_resources (ScreenInfo *info,
+ XRRScreenResources *resources,
+ GError **error)
{
- int i;
- GPtrArray *a;
- XfceRRCrtc **crtc;
+ int i;
+ GPtrArray *a;
+ XfceRRCrtc **crtc;
XfceRROutput **output;
info->resources = resources;
@@ -380,9 +393,9 @@ fill_screen_info_from_resources (ScreenInfo *info,
a = g_ptr_array_new ();
for (i = 0; i < resources->ncrtc; ++i)
{
- XfceRRCrtc *crtc = crtc_new (info, resources->crtcs[i]);
+ XfceRRCrtc *crtc = crtc_new (info, resources->crtcs[i]);
- g_ptr_array_add (a, crtc);
+ g_ptr_array_add (a, crtc);
}
g_ptr_array_add (a, NULL);
info->crtcs = (XfceRRCrtc **)g_ptr_array_free (a, FALSE);
@@ -390,9 +403,9 @@ fill_screen_info_from_resources (ScreenInfo *info,
a = g_ptr_array_new ();
for (i = 0; i < resources->noutput; ++i)
{
- XfceRROutput *output = output_new (info, resources->outputs[i]);
+ XfceRROutput *output = output_new (info, resources->outputs[i]);
- g_ptr_array_add (a, output);
+ g_ptr_array_add (a, output);
}
g_ptr_array_add (a, NULL);
info->outputs = (XfceRROutput **)g_ptr_array_free (a, FALSE);
@@ -400,9 +413,9 @@ fill_screen_info_from_resources (ScreenInfo *info,
a = g_ptr_array_new ();
for (i = 0; i < resources->nmode; ++i)
{
- XfceRRMode *mode = mode_new (info, resources->modes[i].id);
+ XfceRRMode *mode = mode_new (info, resources->modes[i].id);
- g_ptr_array_add (a, mode);
+ g_ptr_array_add (a, mode);
}
g_ptr_array_add (a, NULL);
info->modes = (XfceRRMode **)g_ptr_array_free (a, FALSE);
@@ -410,21 +423,21 @@ fill_screen_info_from_resources (ScreenInfo *info,
/* Initialize */
for (crtc = info->crtcs; *crtc; ++crtc)
{
- if (!crtc_initialize (*crtc, resources, error))
- return FALSE;
+ if (!crtc_initialize (*crtc, resources, error))
+ return FALSE;
}
for (output = info->outputs; *output; ++output)
{
- if (!output_initialize (*output, resources, error))
- return FALSE;
+ if (!output_initialize (*output, resources, error))
+ return FALSE;
}
for (i = 0; i < resources->nmode; ++i)
{
- XfceRRMode *mode = mode_by_id (info, resources->modes[i].id);
+ XfceRRMode *mode = mode_by_id (info, resources->modes[i].id);
- mode_initialize (mode, &(resources->modes[i]));
+ mode_initialize (mode, &(resources->modes[i]));
}
gather_clone_modes (info);
@@ -434,15 +447,15 @@ fill_screen_info_from_resources (ScreenInfo *info,
#endif /* HAVE_RANDR */
static gboolean
-fill_out_screen_info (Display *xdisplay,
- Window xroot,
- ScreenInfo *info,
- gboolean needs_reprobe,
- GError **error)
+fill_out_screen_info (Display *xdisplay,
+ Window xroot,
+ ScreenInfo *info,
+ gboolean needs_reprobe,
+ GError **error)
{
#ifdef HAVE_RANDR
XRRScreenResources *resources;
- GdkDisplay *display;
+ GdkDisplay *display;
g_assert (xdisplay != NULL);
g_assert (info != NULL);
@@ -456,15 +469,15 @@ fill_out_screen_info (Display *xdisplay,
if (resources)
{
- if (!fill_screen_info_from_resources (info, resources, error))
- return FALSE;
+ if (!fill_screen_info_from_resources (info, resources, error))
+ return FALSE;
}
else
{
- g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
- /* Translators: a CRTC is a CRT Controller (this is X terminology). */
- _("could not get the screen resources (CRTCs, outputs, modes)"));
- return FALSE;
+ g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
+ /* Translators: a CRTC is a CRT Controller (this is X terminology). */
+ _("could not get the screen resources (CRTCs, outputs, modes)"));
+ return FALSE;
}
/* Then update the screen size range. We do this after XRRGetScreenResources() so that
@@ -472,39 +485,39 @@ fill_out_screen_info (Display *xdisplay,
*/
if (needs_reprobe) {
- gboolean success;
-
- display = gdk_display_get_default ();
- gdk_x11_display_error_trap_push (display);
- success = XRRGetScreenSizeRange (xdisplay, xroot,
- &(info->min_width),
- &(info->min_height),
- &(info->max_width),
- &(info->max_height));
- gdk_display_flush (display);
- if (gdk_x11_display_error_trap_pop (display)) {
- g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_UNKNOWN,
- _("unhandled X error while getting the range of screen sizes"));
- return FALSE;
- }
-
- if (!success) {
- g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
- _("could not get the range of screen sizes"));
+ gboolean success;
+
+ display = gdk_display_get_default ();
+ gdk_x11_display_error_trap_push (display);
+ success = XRRGetScreenSizeRange (xdisplay, xroot,
+ &(info->min_width),
+ &(info->min_height),
+ &(info->max_width),
+ &(info->max_height));
+ gdk_display_flush (display);
+ if (gdk_x11_display_error_trap_pop (display)) {
+ g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_UNKNOWN,
+ _("unhandled X error while getting the range of screen sizes"));
return FALSE;
}
+
+ if (!success) {
+ g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
+ _("could not get the range of screen sizes"));
+ return FALSE;
+ }
}
else
{
xfce_rr_screen_get_ranges (info->screen,
- &(info->min_width),
- &(info->max_width),
- &(info->min_height),
- &(info->max_height));
+ &(info->min_width),
+ &(info->max_width),
+ &(info->min_height),
+ &(info->max_height));
}
info->primary = None;
- display = gdk_display_get_default ();
+ display = gdk_display_get_default ();
gdk_x11_display_error_trap_push (display);
info->primary = XRRGetOutputPrimary (xdisplay, xroot);
gdk_x11_display_error_trap_pop_ignored (display);
@@ -516,9 +529,11 @@ fill_out_screen_info (Display *xdisplay,
}
static ScreenInfo *
-screen_info_new (XfceRRScreen *screen, gboolean needs_reprobe, GError **error)
+screen_info_new (XfceRRScreen *screen,
+ gboolean needs_reprobe,
+ GError **error)
{
- ScreenInfo *info = g_new0 (ScreenInfo, 1);
+ ScreenInfo *info = g_new0 (ScreenInfo, 1);
XfceRRScreenPrivate *priv;
g_assert (screen != NULL);
@@ -532,30 +547,33 @@ screen_info_new (XfceRRScreen *screen, gboolean needs_reprobe, GError **error)
if (fill_out_screen_info (priv->xdisplay, priv->xroot, info, needs_reprobe, error))
{
- return info;
+ return info;
}
else
{
- screen_info_free (info);
- return NULL;
+ screen_info_free (info);
+ return NULL;
}
}
static gboolean
-screen_update (XfceRRScreen *screen, gboolean force_callback, gboolean needs_reprobe, GError **error)
+screen_update (XfceRRScreen *screen,
+ gboolean force_callback,
+ gboolean needs_reprobe,
+ GError **error)
{
ScreenInfo *info;
- gboolean changed = FALSE;
+ gboolean changed = FALSE;
g_assert (screen != NULL);
info = screen_info_new (screen, needs_reprobe, error);
if (!info)
- return FALSE;
+ return FALSE;
#ifdef HAVE_RANDR
if (info->resources->configTimestamp != screen->priv->info->resources->configTimestamp)
- changed = TRUE;
+ changed = TRUE;
#endif
screen_info_free (screen->priv->info);
@@ -563,63 +581,63 @@ screen_update (XfceRRScreen *screen, gboolean force_callback, gboolean needs_rep
screen->priv->info = info;
if (changed || force_callback)
- g_signal_emit (G_OBJECT (screen), screen_signals[SCREEN_CHANGED], 0);
+ g_signal_emit (G_OBJECT (screen), screen_signals[SCREEN_CHANGED], 0);
return changed;
}
static GdkFilterReturn
screen_on_event (GdkXEvent *xevent,
- GdkEvent *event,
- gpointer data)
+ GdkEvent *event,
+ gpointer data)
{
#ifdef HAVE_RANDR
- XfceRRScreen *screen = data;
+ XfceRRScreen *screen = data;
XfceRRScreenPrivate *priv = screen->priv;
- XEvent *e = xevent;
- int event_num;
+ XEvent *e = xevent;
+ int event_num;
if (!e)
- return GDK_FILTER_CONTINUE;
+ return GDK_FILTER_CONTINUE;
event_num = e->type - priv->randr_event_base;
if (event_num == RRScreenChangeNotify) {
- /* We don't reprobe the hardware; we just fetch the X server's latest
- * state. The server already knows the new state of the outputs; that's
- * why it sent us an event!
- */
+ /* We don't reprobe the hardware; we just fetch the X server's latest
+ * state. The server already knows the new state of the outputs; that's
+ * why it sent us an event!
+ */
screen_update (screen, TRUE, FALSE, NULL); /* NULL-GError */
#if 0
- /* Enable this code to get a dialog showing the RANDR timestamps, for debugging purposes */
- {
- GtkWidget *dialog;
- XRRScreenChangeNotifyEvent *rr_event;
- static int dialog_num;
-
- rr_event = (XRRScreenChangeNotifyEvent *) e;
-
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- "RRScreenChangeNotify timestamps (%d):\n"
- "event change: %u\n"
- "event config: %u\n"
- "event serial: %lu\n"
- "----------------------"
- "screen change: %u\n"
- "screen config: %u\n",
- dialog_num++,
- (guint32) rr_event->timestamp,
- (guint32) rr_event->config_timestamp,
- rr_event->serial,
- (guint32) priv->info->resources->timestamp,
- (guint32) priv->info->resources->configTimestamp);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- }
+ /* Enable this code to get a dialog showing the RANDR timestamps, for debugging purposes */
+ {
+ GtkWidget *dialog;
+ XRRScreenChangeNotifyEvent *rr_event;
+ static int dialog_num;
+
+ rr_event = (XRRScreenChangeNotifyEvent *) e;
+
+ dialog = gtk_message_dialog_new (NULL,
+ 0,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ "RRScreenChangeNotify timestamps (%d):\n"
+ "event change: %u\n"
+ "event config: %u\n"
+ "event serial: %lu\n"
+ "----------------------"
+ "screen change: %u\n"
+ "screen config: %u\n",
+ dialog_num++,
+ (guint32) rr_event->timestamp,
+ (guint32) rr_event->config_timestamp,
+ rr_event->serial,
+ (guint32) priv->info->resources->timestamp,
+ (guint32) priv->info->resources->configTimestamp);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+ }
#endif
}
#if 0
@@ -639,23 +657,23 @@ screen_on_event (GdkXEvent *xevent,
*/
else if (event_num == RRNotify)
{
- /* Other RandR events */
-
- XRRNotifyEvent *event = (XRRNotifyEvent *)e;
-
- /* Here we can distinguish between RRNotify events supported
- * since RandR 1.2 such as RRNotify_OutputProperty. For now, we
- * don't have anything special to do for particular subevent types, so
- * we leave this as an empty switch().
- */
- switch (event->subtype)
- {
- default:
- break;
- }
-
- /* No need to reprobe hardware here */
- screen_update (screen, TRUE, FALSE, NULL); /* NULL-GError */
+ /* Other RandR events */
+
+ XRRNotifyEvent *event = (XRRNotifyEvent *)e;
+
+ /* Here we can distinguish between RRNotify events supported
+ * since RandR 1.2 such as RRNotify_OutputProperty. For now, we
+ * don't have anything special to do for particular subevent types, so
+ * we leave this as an empty switch().
+ */
+ switch (event->subtype)
+ {
+ default:
+ break;
+ }
+
+ /* No need to reprobe hardware here */
+ screen_update (screen, TRUE, FALSE, NULL); /* NULL-GError */
}
#endif
@@ -666,14 +684,15 @@ screen_on_event (GdkXEvent *xevent,
}
static gboolean
-xfce_rr_screen_initable_init (GInitable *initable, GCancellable *canc, GError **error)
-
+xfce_rr_screen_initable_init (GInitable *initable,
+ GCancellable *canc,
+ GError **error)
{
- XfceRRScreen *self = XFCE_RR_SCREEN (initable);
+ XfceRRScreen *self = XFCE_RR_SCREEN (initable);
XfceRRScreenPrivate *priv = self->priv;
- Display *dpy = GDK_SCREEN_XDISPLAY (self->priv->gdk_screen);
- int event_base;
- int ignore;
+ Display *dpy = GDK_SCREEN_XDISPLAY (self->priv->gdk_screen);
+ int event_base;
+ int ignore;
priv->connector_type_atom = XInternAtom (dpy, "ConnectorType", FALSE);
@@ -692,15 +711,15 @@ xfce_rr_screen_initable_init (GInitable *initable, GCancellable *canc, GError **
priv->info = screen_info_new (self, TRUE, error);
if (!priv->info) {
- return FALSE;
- }
+ return FALSE;
+ }
XRRSelectInput (priv->xdisplay,
- priv->xroot,
- RRScreenChangeNotifyMask);
+ priv->xroot,
+ RRScreenChangeNotifyMask);
gdk_x11_register_standard_event_type (gdk_screen_get_display (priv->gdk_screen),
- event_base,
- RRNotify + 1);
+ event_base,
+ RRNotify + 1);
gdk_window_add_filter (priv->gdk_root, screen_on_event, self);
return TRUE;
@@ -708,10 +727,10 @@ xfce_rr_screen_initable_init (GInitable *initable, GCancellable *canc, GError **
else
{
#endif /* HAVE_RANDR */
- g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_NO_RANDR_EXTENSION,
- _("RANDR extension is not present"));
+ g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_NO_RANDR_EXTENSION,
+ _("RANDR extension is not present"));
- return FALSE;
+ return FALSE;
#ifdef HAVE_RANDR
}
@@ -725,53 +744,59 @@ xfce_rr_screen_initable_iface_init (GInitableIface *iface)
}
void
- xfce_rr_screen_finalize (GObject *gobject)
+xfce_rr_screen_finalize (GObject *gobject)
{
XfceRRScreen *screen = XFCE_RR_SCREEN (gobject);
gdk_window_remove_filter (screen->priv->gdk_root, screen_on_event, screen);
if (screen->priv->info)
- screen_info_free (screen->priv->info);
+ screen_info_free (screen->priv->info);
G_OBJECT_CLASS (xfce_rr_screen_parent_class)->finalize (gobject);
}
void
-xfce_rr_screen_set_property (GObject *gobject, guint property_id, const GValue *value, GParamSpec *property)
+xfce_rr_screen_set_property (GObject *gobject,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *property)
{
- XfceRRScreen *self = XFCE_RR_SCREEN (gobject);
+ XfceRRScreen *self = XFCE_RR_SCREEN (gobject);
XfceRRScreenPrivate *priv = self->priv;
switch (property_id)
{
- case SCREEN_PROP_GDK_SCREEN:
- priv->gdk_screen = g_value_get_object (value);
- priv->gdk_root = gdk_screen_get_root_window (priv->gdk_screen);
- priv->xroot = GDK_WINDOW_XID (priv->gdk_root);
- priv->xdisplay = GDK_SCREEN_XDISPLAY (priv->gdk_screen);
- priv->xscreen = gdk_x11_screen_get_xscreen (priv->gdk_screen);
- return;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
- return;
+ case SCREEN_PROP_GDK_SCREEN:
+ priv->gdk_screen = g_value_get_object (value);
+ priv->gdk_root = gdk_screen_get_root_window (priv->gdk_screen);
+ priv->xroot = GDK_WINDOW_XID (priv->gdk_root);
+ priv->xdisplay = GDK_SCREEN_XDISPLAY (priv->gdk_screen);
+ priv->xscreen = gdk_x11_screen_get_xscreen (priv->gdk_screen);
+ return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
+ return;
}
}
void
-xfce_rr_screen_get_property (GObject *gobject, guint property_id, GValue *value, GParamSpec *property)
+xfce_rr_screen_get_property (GObject *gobject,
+ guint property_id,
+ GValue *value,
+ GParamSpec *property)
{
- XfceRRScreen *self = XFCE_RR_SCREEN (gobject);
+ XfceRRScreen *self = XFCE_RR_SCREEN (gobject);
XfceRRScreenPrivate *priv = self->priv;
switch (property_id)
{
- case SCREEN_PROP_GDK_SCREEN:
- g_value_set_object (value, priv->gdk_screen);
- return;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
- return;
+ case SCREEN_PROP_GDK_SCREEN:
+ g_value_set_object (value, priv->gdk_screen);
+ return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
+ return;
}
}
@@ -795,8 +820,7 @@ xfce_rr_screen_class_init (XfceRRScreenClass *klass)
"GDK Screen",
"The GDK Screen represented by this XfceRRScreen",
GDK_TYPE_SCREEN,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)
- );
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
screen_signals[SCREEN_CHANGED] = g_signal_new("changed",
G_TYPE_FROM_CLASS (gobject_class),
@@ -836,8 +860,8 @@ xfce_rr_screen_init (XfceRRScreen *self)
* for instance if the driver does not support Xrandr 1.2
*/
XfceRRScreen *
-xfce_rr_screen_new (GdkScreen *screen,
- GError **error)
+xfce_rr_screen_new (GdkScreen *screen,
+ GError **error)
{
//bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -856,10 +880,10 @@ xfce_rr_screen_new (GdkScreen *screen,
*/
static void
xfce_rr_screen_get_ranges (XfceRRScreen *screen,
- int *min_width,
- int *max_width,
- int *min_height,
- int *max_height)
+ int *min_width,
+ int *max_width,
+ int *min_height,
+ int *max_height)
{
XfceRRScreenPrivate *priv;
@@ -868,16 +892,16 @@ xfce_rr_screen_get_ranges (XfceRRScreen *screen,
priv = screen->priv;
if (min_width)
- *min_width = priv->info->min_width;
+ *min_width = priv->info->min_width;
if (max_width)
- *max_width = priv->info->max_width;
+ *max_width = priv->info->max_width;
if (min_height)
- *min_height = priv->info->min_height;
+ *min_height = priv->info->min_height;
if (max_height)
- *max_height = priv->info->max_height;
+ *max_height = priv->info->max_height;
}
static gboolean
@@ -885,47 +909,47 @@ force_timestamp_update (XfceRRScreen *screen)
{
#ifdef HAVE_RANDR
XfceRRScreenPrivate *priv = screen->priv;
- XfceRRCrtc *crtc;
- XRRCrtcInfo *current_info;
- GdkDisplay *display;
- Status status;
- gboolean timestamp_updated;
+ XfceRRCrtc *crtc;
+ XRRCrtcInfo *current_info;
+ GdkDisplay *display;
+ Status status;
+ gboolean timestamp_updated;
timestamp_updated = FALSE;
crtc = priv->info->crtcs[0];
if (crtc == NULL)
- goto out;
+ goto out;
current_info = XRRGetCrtcInfo (priv->xdisplay,
- priv->info->resources,
- crtc->id);
+ priv->info->resources,
+ crtc->id);
if (current_info == NULL)
- goto out;
+ goto out;
- display = gdk_display_get_default ();
+ display = gdk_display_get_default ();
gdk_x11_display_error_trap_push (display);
status = XRRSetCrtcConfig (priv->xdisplay,
- priv->info->resources,
- crtc->id,
- current_info->timestamp,
- current_info->x,
- current_info->y,
- current_info->mode,
- current_info->rotation,
- current_info->outputs,
- current_info->noutput);
+ priv->info->resources,
+ crtc->id,
+ current_info->timestamp,
+ current_info->x,
+ current_info->y,
+ current_info->mode,
+ current_info->rotation,
+ current_info->outputs,
+ current_info->noutput);
XRRFreeCrtcInfo (current_info);
gdk_display_flush (display);
if (gdk_x11_display_error_trap_pop (display))
- goto out;
+ goto out;
if (status == RRSetConfigSuccess)
- timestamp_updated = TRUE;
+ timestamp_updated = TRUE;
out:
return timestamp_updated;
#else
@@ -947,8 +971,8 @@ out:
* configuration.
*/
gboolean
-xfce_rr_screen_refresh (XfceRRScreen *screen,
- GError **error)
+xfce_rr_screen_refresh (XfceRRScreen *screen,
+ GError **error)
{
gboolean refreshed;
@@ -982,7 +1006,8 @@ xfce_rr_screen_list_crtcs (XfceRRScreen *screen)
/* XfceRROutput */
static XfceRROutput *
-output_new (ScreenInfo *info, RROutput id)
+output_new (ScreenInfo *info,
+ RROutput id)
{
XfceRROutput *output = g_slice_new0 (XfceRROutput);
@@ -993,33 +1018,33 @@ output_new (ScreenInfo *info, RROutput id)
}
static guint8 *
-get_property (Display *dpy,
- RROutput output,
- Atom atom,
- int *len)
+get_property (Display *dpy,
+ RROutput output,
+ Atom atom,
+ int *len)
{
#ifdef HAVE_RANDR
unsigned char *prop;
- int actual_format;
- unsigned long nitems, bytes_after;
- Atom actual_type;
- guint8 *result;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+ Atom actual_type;
+ guint8 *result;
XRRGetOutputProperty (dpy, output, atom,
- 0, 100, False, False,
- AnyPropertyType,
- &actual_type, &actual_format,
- &nitems, &bytes_after, &prop);
+ 0, 100, False, False,
+ AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &prop);
if (actual_type == XA_INTEGER && actual_format == 8)
{
- result = g_memdup (prop, nitems);
- if (len)
- *len = nitems;
+ result = g_memdup (prop, nitems);
+ if (len)
+ *len = nitems;
}
else
{
- result = NULL;
+ result = NULL;
}
XFree (prop);
@@ -1033,26 +1058,26 @@ get_property (Display *dpy,
static guint8 *
read_edid_data (XfceRROutput *output, int *len)
{
- Atom edid_atom;
+ Atom edid_atom;
guint8 *result;
edid_atom = XInternAtom (DISPLAY (output), "EDID", FALSE);
result = get_property (DISPLAY (output),
- output->id, edid_atom, len);
+ output->id, edid_atom, len);
if (!result)
{
- edid_atom = XInternAtom (DISPLAY (output), "EDID_DATA", FALSE);
- result = get_property (DISPLAY (output),
- output->id, edid_atom, len);
+ edid_atom = XInternAtom (DISPLAY (output), "EDID_DATA", FALSE);
+ result = get_property (DISPLAY (output),
+ output->id, edid_atom, len);
}
if (result)
{
- if (*len % 128 == 0)
- return result;
- else
- g_free (result);
+ if (*len % 128 == 0)
+ return result;
+ else
+ g_free (result);
}
return NULL;
@@ -1062,32 +1087,32 @@ static char *
get_connector_type_string (XfceRROutput *output)
{
#ifdef HAVE_RANDR
- char *result;
- unsigned char *prop;
- int actual_format;
- unsigned long nitems, bytes_after;
- Atom actual_type;
- Atom connector_type;
- char *connector_type_str;
+ char *result;
+ unsigned char *prop;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+ Atom actual_type;
+ Atom connector_type;
+ char *connector_type_str;
result = NULL;
if (XRRGetOutputProperty (DISPLAY (output), output->id, output->info->screen->priv->connector_type_atom,
- 0, 100, False, False,
- AnyPropertyType,
- &actual_type, &actual_format,
- &nitems, &bytes_after, &prop) != Success)
- return NULL;
+ 0, 100, False, False,
+ AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &prop) != Success)
+ return NULL;
if (!(actual_type == XA_ATOM && actual_format == 32 && nitems == 1))
- goto out;
+ goto out;
connector_type = *((Atom *) prop);
connector_type_str = XGetAtomName (DISPLAY (output), connector_type);
if (connector_type_str) {
- result = g_strdup (connector_type_str); /* so the caller can g_free() it */
- XFree (connector_type_str);
+ result = g_strdup (connector_type_str); /* so the caller can g_free() it */
+ XFree (connector_type_str);
}
out:
@@ -1102,12 +1127,13 @@ out:
#ifdef HAVE_RANDR
static gboolean
-output_initialize (XfceRROutput *output, XRRScreenResources *res, GError **error)
+output_initialize (XfceRROutput *output,
+ XRRScreenResources *res,
+ GError **error)
{
- XRROutputInfo *info = XRRGetOutputInfo (
- DISPLAY (output), res, output->id);
- GPtrArray *a;
- int i;
+ XRROutputInfo *info = XRRGetOutputInfo (DISPLAY (output), res, output->id);
+ GPtrArray *a;
+ int i;
#if 0
g_print ("Output %lx Timestamp: %u\n", output->id, (guint32)info->timestamp);
@@ -1115,12 +1141,12 @@ output_initialize (XfceRROutput *output, XRRScreenResources *res, GError **error
if (!info || !output->info)
{
- /* FIXME: see the comment in crtc_initialize() */
- /* Translators: here, an "output" is a video output */
- g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
- _("could not get information about output %d"),
- (int) output->id);
- return FALSE;
+ /* FIXME: see the comment in crtc_initialize() */
+ /* Translators: here, an "output" is a video output */
+ g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
+ _("could not get information about output %d"),
+ (int) output->id);
+ return FALSE;
}
output->name = g_strdup (info->name); /* FIXME: what is nameLen used for? */
@@ -1135,10 +1161,10 @@ output_initialize (XfceRROutput *output, XRRScreenResources *res, GError **error
for (i = 0; i < info->ncrtc; ++i)
{
- XfceRRCrtc *crtc = crtc_by_id (output->info, info->crtcs[i]);
+ XfceRRCrtc *crtc = crtc_by_id (output->info, info->crtcs[i]);
- if (crtc)
- g_ptr_array_add (a, crtc);
+ if (crtc)
+ g_ptr_array_add (a, crtc);
}
g_ptr_array_add (a, NULL);
output->possible_crtcs = (XfceRRCrtc **)g_ptr_array_free (a, FALSE);
@@ -1147,10 +1173,10 @@ output_initialize (XfceRROutput *output, XRRScreenResources *res, GError **error
a = g_ptr_array_new ();
for (i = 0; i < info->nclone; ++i)
{
- XfceRROutput *xfce_rr_output = xfce_rr_output_by_id (output->info, info->clones[i]);
+ XfceRROutput *xfce_rr_output = xfce_rr_output_by_id (output->info, info->clones[i]);
- if (xfce_rr_output)
- g_ptr_array_add (a, xfce_rr_output);
+ if (xfce_rr_output)
+ g_ptr_array_add (a, xfce_rr_output);
}
g_ptr_array_add (a, NULL);
output->clones = (XfceRROutput **)g_ptr_array_free (a, FALSE);
@@ -1159,10 +1185,10 @@ output_initialize (XfceRROutput *output, XRRScreenResources *res, GError **error
a = g_ptr_array_new ();
for (i = 0; i < info->nmode; ++i)
{
- XfceRRMode *mode = mode_by_id (output->info, info->modes[i]);
+ XfceRRMode *mode = mode_by_id (output->info, info->modes[i]);
- if (mode)
- g_ptr_array_add (a, mode);
+ if (mode)
+ g_ptr_array_add (a, mode);
}
g_ptr_array_add (a, NULL);
output->modes = (XfceRRMode **)g_ptr_array_free (a, FALSE);
@@ -1181,11 +1207,11 @@ output_initialize (XfceRROutput *output, XRRScreenResources *res, GError **error
static XfceRROutput*
output_copy (const XfceRROutput *from)
{
- GPtrArray *array;
- XfceRRCrtc **p_crtc;
+ GPtrArray *array;
+ XfceRRCrtc **p_crtc;
XfceRROutput **p_output;
- XfceRRMode **p_mode;
- XfceRROutput *output = g_slice_new0 (XfceRROutput);
+ XfceRRMode **p_mode;
+ XfceRROutput *output = g_slice_new0 (XfceRROutput);
output->id = from->id;
output->info = from->info;
@@ -1269,13 +1295,13 @@ static const RotationMap rotation_map[] =
static XfceRRRotation
xfce_rr_rotation_from_xrotation (Rotation r)
{
- int i;
+ int i;
XfceRRRotation result = 0;
for (i = 0; i < G_N_ELEMENTS (rotation_map); ++i)
{
- if (r & rotation_map[i].xrot)
- result |= rotation_map[i].rot;
+ if (r & rotation_map[i].xrot)
+ result |= rotation_map[i].rot;
}
return result;
@@ -1309,8 +1335,8 @@ static XfceRRCrtc *
crtc_copy (const XfceRRCrtc *from)
{
XfceRROutput **p_output;
- GPtrArray *array;
- XfceRRCrtc *to = g_slice_new0 (XfceRRCrtc);
+ GPtrArray *array;
+ XfceRRCrtc *to = g_slice_new0 (XfceRRCrtc);
to->info = from->info;
to->id = from->id;
@@ -1340,13 +1366,13 @@ crtc_copy (const XfceRRCrtc *from)
#ifdef HAVE_RANDR
static gboolean
-crtc_initialize (XfceRRCrtc *crtc,
- XRRScreenResources *res,
- GError **error)
+crtc_initialize (XfceRRCrtc *crtc,
+ XRRScreenResources *res,
+ GError **error)
{
XRRCrtcInfo *info = XRRGetCrtcInfo (DISPLAY (crtc), res, crtc->id);
- GPtrArray *a;
- int i;
+ GPtrArray *a;
+ int i;
#if 0
g_print ("CRTC %lx Timestamp: %u\n", crtc->id, (guint32)info->timestamp);
@@ -1354,16 +1380,16 @@ crtc_initialize (XfceRRCrtc *crtc,
if (!info)
{
- /* FIXME: We need to reaquire the screen resources */
- /* FIXME: can we actually catch BadRRCrtc, and does it make sense to emit that? */
-
- /* Translators: CRTC is a CRT Controller (this is X terminology).
- * It is *very* unlikely that you'll ever get this error, so it is
- * only listed for completeness. */
- g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
- _("could not get information about CRTC %d"),
- (int) crtc->id);
- return FALSE;
+ /* FIXME: We need to reaquire the screen resources */
+ /* FIXME: can we actually catch BadRRCrtc, and does it make sense to emit that? */
+
+ /* Translators: CRTC is a CRT Controller (this is X terminology).
+ * It is *very* unlikely that you'll ever get this error, so it is
+ * only listed for completeness. */
+ g_set_error (error, XFCE_RR_ERROR, XFCE_RR_ERROR_RANDR_ERROR,
+ _("could not get information about CRTC %d"),
+ (int) crtc->id);
+ return FALSE;
}
/* XfceRRMode */
@@ -1376,10 +1402,10 @@ crtc_initialize (XfceRRCrtc *crtc,
a = g_ptr_array_new ();
for (i = 0; i < info->noutput; ++i)
{
- XfceRROutput *output = xfce_rr_output_by_id (crtc->info, info->outputs[i]);
+ XfceRROutput *output = xfce_rr_output_by_id (crtc->info, info->outputs[i]);
- if (output)
- g_ptr_array_add (a, output);
+ if (output)
+ g_ptr_array_add (a, output);
}
g_ptr_array_add (a, NULL);
crtc->current_outputs = (XfceRROutput **)g_ptr_array_free (a, FALSE);
@@ -1388,10 +1414,10 @@ crtc_initialize (XfceRRCrtc *crtc,
a = g_ptr_array_new ();
for (i = 0; i < info->npossible; ++i)
{
- XfceRROutput *output = xfce_rr_output_by_id (crtc->info, info->possible[i]);
+ XfceRROutput *output = xfce_rr_output_by_id (crtc->info, info->possible[i]);
- if (output)
- g_ptr_array_add (a, output);
+ if (output)
+ g_ptr_array_add (a, output);
}
g_ptr_array_add (a, NULL);
crtc->possible_outputs = (XfceRROutput **)g_ptr_array_free (a, FALSE);
@@ -1445,7 +1471,8 @@ xfce_rr_mode_get_height (XfceRRMode *mode)
#ifdef HAVE_RANDR
static void
-mode_initialize (XfceRRMode *mode, XRRModeInfo *info)
+mode_initialize (XfceRRMode *mode,
+ XRRModeInfo *info)
{
g_assert (mode != NULL);
g_assert (info != NULL);
@@ -1480,13 +1507,13 @@ mode_free (XfceRRMode *mode)
}
void
-xfce_rr_crtc_set_gamma (XfceRRCrtc *crtc, int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue)
+xfce_rr_crtc_set_gamma (XfceRRCrtc *crtc, int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue)
{
#ifdef HAVE_RANDR
- int copy_size;
+ int copy_size;
XRRCrtcGamma *gamma;
g_return_if_fail (crtc != NULL);
@@ -1495,7 +1522,7 @@ xfce_rr_crtc_set_gamma (XfceRRCrtc *crtc, int size,
g_return_if_fail (blue != NULL);
if (size != crtc->gamma_size)
- return;
+ return;
gamma = XRRAllocGamma (crtc->gamma_size);
@@ -1520,45 +1547,47 @@ xfce_rr_crtc_set_gamma (XfceRRCrtc *crtc, int size,
* Returns: %TRUE for success
*/
gboolean
-xfce_rr_crtc_get_gamma (XfceRRCrtc *crtc, int *size,
- unsigned short **red, unsigned short **green,
- unsigned short **blue)
+xfce_rr_crtc_get_gamma (XfceRRCrtc *crtc,
+ int *size,
+ unsigned short **red,
+ unsigned short **green,
+ unsigned short **blue)
{
#ifdef HAVE_RANDR
- int copy_size;
+ int copy_size;
unsigned short *r, *g, *b;
- XRRCrtcGamma *gamma;
+ XRRCrtcGamma *gamma;
g_return_val_if_fail (crtc != NULL, FALSE);
gamma = XRRGetCrtcGamma (DISPLAY (crtc), crtc->id);
if (!gamma)
- return FALSE;
+ return FALSE;
copy_size = crtc->gamma_size * sizeof (unsigned short);
if (red) {
- r = g_new0 (unsigned short, crtc->gamma_size);
- memcpy (r, gamma->red, copy_size);
- *red = r;
+ r = g_new0 (unsigned short, crtc->gamma_size);
+ memcpy (r, gamma->red, copy_size);
+ *red = r;
}
if (green) {
- g = g_new0 (unsigned short, crtc->gamma_size);
- memcpy (g, gamma->green, copy_size);
- *green = g;
+ g = g_new0 (unsigned short, crtc->gamma_size);
+ memcpy (g, gamma->green, copy_size);
+ *green = g;
}
if (blue) {
- b = g_new0 (unsigned short, crtc->gamma_size);
- memcpy (b, gamma->blue, copy_size);
- *blue = b;
+ b = g_new0 (unsigned short, crtc->gamma_size);
+ memcpy (b, gamma->blue, copy_size);
+ *blue = b;
}
XRRFreeGamma (gamma);
if (size)
- *size = crtc->gamma_size;
+ *size = crtc->gamma_size;
return TRUE;
#else
diff --git a/src/xfce-rr.h b/src/xfce-rr.h
index bef84f1..e7bac0f 100644
--- a/src/xfce-rr.h
+++ b/src/xfce-rr.h
@@ -39,17 +39,17 @@ typedef struct {
typedef struct {
GObjectClass parent_class;
- void (* changed) (void);
+ void (* changed) (void);
} XfceRRScreenClass;
typedef enum
{
- XFCE_RR_ROTATION_0 = (1 << 0),
- XFCE_RR_ROTATION_90 = (1 << 1),
- XFCE_RR_ROTATION_180 = (1 << 2),
- XFCE_RR_ROTATION_270 = (1 << 3),
- XFCE_RR_REFLECT_X = (1 << 4),
- XFCE_RR_REFLECT_Y = (1 << 5)
+ XFCE_RR_ROTATION_0 = (1 << 0),
+ XFCE_RR_ROTATION_90 = (1 << 1),
+ XFCE_RR_ROTATION_180 = (1 << 2),
+ XFCE_RR_ROTATION_270 = (1 << 3),
+ XFCE_RR_REFLECT_X = (1 << 4),
+ XFCE_RR_REFLECT_Y = (1 << 5)
} XfceRRRotation;
/* Error codes */
@@ -59,12 +59,12 @@ typedef enum
GQuark xfce_rr_error_quark (void);
typedef enum {
- XFCE_RR_ERROR_UNKNOWN, /* generic "fail" */
- XFCE_RR_ERROR_NO_RANDR_EXTENSION, /* RANDR extension is not present */
- XFCE_RR_ERROR_RANDR_ERROR, /* generic/undescribed error from the underlying XRR API */
- XFCE_RR_ERROR_BOUNDS_ERROR, /* requested bounds of a CRTC are outside the maximum size */
- XFCE_RR_ERROR_CRTC_ASSIGNMENT, /* could not assign CRTCs to outputs */
- XFCE_RR_ERROR_NO_MATCHING_CONFIG, /* none of the saved configurations matched the current configuration */
+ XFCE_RR_ERROR_UNKNOWN, /* generic "fail" */
+ XFCE_RR_ERROR_NO_RANDR_EXTENSION, /* RANDR extension is not present */
+ XFCE_RR_ERROR_RANDR_ERROR, /* generic/undescribed error from the underlying XRR API */
+ XFCE_RR_ERROR_BOUNDS_ERROR, /* requested bounds of a CRTC are outside the maximum size */
+ XFCE_RR_ERROR_CRTC_ASSIGNMENT, /* could not assign CRTCs to outputs */
+ XFCE_RR_ERROR_NO_MATCHING_CONFIG, /* none of the saved configurations matched the current configuration */
} XfceRRError;
#define XFCE_RR_CONNECTOR_TYPE_PANEL "Panel" /* This is a laptop's built-in LCD */
@@ -86,23 +86,23 @@ GType xfce_rr_crtc_get_type (void);
GType xfce_rr_mode_get_type (void);
/* XfceRRScreen */
-XfceRRScreen * xfce_rr_screen_new (GdkScreen *screen,
- GError **error);
-XfceRRCrtc ** xfce_rr_screen_list_crtcs (XfceRRScreen *screen);
-gboolean xfce_rr_screen_refresh (XfceRRScreen *screen,
- GError **error);
+XfceRRScreen * xfce_rr_screen_new (GdkScreen *screen,
+ GError **error);
+XfceRRCrtc ** xfce_rr_screen_list_crtcs (XfceRRScreen *screen);
+gboolean xfce_rr_screen_refresh (XfceRRScreen *screen,
+ GError **error);
/* XfceRRCrtc */
-XfceRRMode * xfce_rr_crtc_get_current_mode (XfceRRCrtc *crtc);
-
-gboolean xfce_rr_crtc_get_gamma (XfceRRCrtc *crtc,
- int *size,
- unsigned short **red,
- unsigned short **green,
- unsigned short **blue);
-void xfce_rr_crtc_set_gamma (XfceRRCrtc *crtc,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue);
+XfceRRMode * xfce_rr_crtc_get_current_mode (XfceRRCrtc *crtc);
+
+gboolean xfce_rr_crtc_get_gamma (XfceRRCrtc *crtc,
+ int *size,
+ unsigned short **red,
+ unsigned short **green,
+ unsigned short **blue);
+void xfce_rr_crtc_set_gamma (XfceRRCrtc *crtc,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue);
#endif /* XFCE_RR_H */
diff --git a/src/xfce4-screensaver-command.c b/src/xfce4-screensaver-command.c
index 66b217d..afd2f12 100644
--- a/src/xfce4-screensaver-command.c
+++ b/src/xfce4-screensaver-command.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -37,72 +37,72 @@
#define GS_PATH "/org/xfce/ScreenSaver"
#define GS_INTERFACE "org.xfce.ScreenSaver"
-static gboolean do_quit = FALSE;
-static gboolean do_lock = FALSE;
-static gboolean do_cycle = FALSE;
-static gboolean do_activate = FALSE;
-static gboolean do_deactivate = FALSE;
-static gboolean do_version = FALSE;
-static gboolean do_poke = FALSE;
-static gboolean do_inhibit = FALSE;
+static gboolean do_quit = FALSE;
+static gboolean do_lock = FALSE;
+static gboolean do_cycle = FALSE;
+static gboolean do_activate = FALSE;
+static gboolean do_deactivate = FALSE;
+static gboolean do_version = FALSE;
+static gboolean do_poke = FALSE;
+static gboolean do_inhibit = FALSE;
-static gboolean do_query = FALSE;
-static gboolean do_time = FALSE;
+static gboolean do_query = FALSE;
+static gboolean do_time = FALSE;
static char *inhibit_reason = NULL;
static char *inhibit_application = NULL;
static GOptionEntry entries [] =
{
- {
- "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
- N_("Causes the screensaver to exit gracefully"), NULL
- },
- {
- "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
- N_("Query the state of the screensaver"), NULL
- },
- {
- "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
- N_("Query the length of time the screensaver has been active"), NULL
- },
- {
- "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
- N_("Tells the running screensaver process to lock the screen immediately"), NULL
- },
- {
- "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
- N_("If the screensaver is active then switch to another graphics demo"), NULL
- },
- {
- "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
- N_("Turn the screensaver on (blank the screen)"), NULL
- },
- {
- "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
- N_("If the screensaver is active then deactivate it (un-blank the screen)"), NULL
- },
- {
- "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
- N_("Poke the running screensaver to simulate user activity"), NULL
- },
- {
- "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
- N_("Inhibit the screensaver from activating. Command blocks while inhibit is active."), NULL
- },
- {
- "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
- N_("The calling application that is inhibiting the screensaver"), NULL
- },
- {
- "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
- N_("The reason for inhibiting the screensaver"), NULL
- },
- {
- "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
- N_("Version of this application"), NULL
- },
- { NULL }
+ {
+ "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
+ N_("Causes the screensaver to exit gracefully"), NULL
+ },
+ {
+ "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
+ N_("Query the state of the screensaver"), NULL
+ },
+ {
+ "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
+ N_("Query the length of time the screensaver has been active"), NULL
+ },
+ {
+ "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
+ N_("Tells the running screensaver process to lock the screen immediately"), NULL
+ },
+ {
+ "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
+ N_("If the screensaver is active then switch to another graphics demo"), NULL
+ },
+ {
+ "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
+ N_("Turn the screensaver on (blank the screen)"), NULL
+ },
+ {
+ "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
+ N_("If the screensaver is active then deactivate it (un-blank the screen)"), NULL
+ },
+ {
+ "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
+ N_("Poke the running screensaver to simulate user activity"), NULL
+ },
+ {
+ "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
+ N_("Inhibit the screensaver from activating. Command blocks while inhibit is active."), NULL
+ },
+ {
+ "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
+ N_("The calling application that is inhibiting the screensaver"), NULL
+ },
+ {
+ "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
+ N_("The reason for inhibiting the screensaver"), NULL
+ },
+ {
+ "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
+ N_("Version of this application"), NULL
+ },
+ { NULL }
};
static GMainLoop *loop = NULL;
@@ -110,17 +110,17 @@ static GMainLoop *loop = NULL;
static gboolean
screensaver_is_running (DBusConnection *connection)
{
- DBusError error;
- gboolean exists;
+ DBusError error;
+ gboolean exists;
- g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (connection != NULL, FALSE);
- dbus_error_init (&error);
- exists = dbus_bus_name_has_owner (connection, GS_SERVICE, &error);
- if (dbus_error_is_set (&error))
- dbus_error_free (&error);
+ dbus_error_init (&error);
+ exists = dbus_bus_name_has_owner (connection, GS_SERVICE, &error);
+ if (dbus_error_is_set (&error))
+ dbus_error_free (&error);
- return exists;
+ return exists;
}
static DBusMessage *
@@ -128,41 +128,41 @@ screensaver_send_message_inhibit (DBusConnection *connection,
const char *application,
const char *reason)
{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusError error;
+ DBusMessageIter iter;
- g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (connection != NULL, NULL);
- dbus_error_init (&error);
+ dbus_error_init (&error);
- message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, "Inhibit");
- if (message == NULL)
- {
- g_warning ("Couldn't allocate the dbus message");
- return NULL;
- }
+ message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, "Inhibit");
+ if (message == NULL)
+ {
+ g_warning ("Couldn't allocate the dbus message");
+ return NULL;
+ }
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &application);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &reason);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &application);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &reason);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1, &error);
- if (dbus_error_is_set (&error))
- {
- g_warning ("%s raised:\n %s\n\n", error.name, error.message);
- reply = NULL;
- }
+ reply = dbus_connection_send_with_reply_and_block (connection,
+ message,
+ -1, &error);
+ if (dbus_error_is_set (&error))
+ {
+ g_warning ("%s raised:\n %s\n\n", error.name, error.message);
+ reply = NULL;
+ }
- dbus_connection_flush (connection);
+ dbus_connection_flush (connection);
- dbus_message_unref (message);
- dbus_error_free (&error);
+ dbus_message_unref (message);
+ dbus_error_free (&error);
- return reply;
+ return reply;
}
static DBusMessage *
@@ -170,41 +170,41 @@ screensaver_send_message_bool (DBusConnection *connection,
const char *name,
gboolean value)
{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusError error;
+ DBusMessageIter iter;
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- dbus_error_init (&error);
+ dbus_error_init (&error);
- message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, name);
- if (message == NULL)
- {
- g_warning ("Couldn't allocate the dbus message");
- return NULL;
- }
+ message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, name);
+ if (message == NULL)
+ {
+ g_warning ("Couldn't allocate the dbus message");
+ return NULL;
+ }
- dbus_message_iter_init_append (message, &iter);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &value);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &value);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1, &error);
- if (dbus_error_is_set (&error))
- {
- g_warning ("%s raised:\n %s\n\n", error.name, error.message);
- reply = NULL;
- }
+ reply = dbus_connection_send_with_reply_and_block (connection,
+ message,
+ -1, &error);
+ if (dbus_error_is_set (&error))
+ {
+ g_warning ("%s raised:\n %s\n\n", error.name, error.message);
+ reply = NULL;
+ }
- dbus_connection_flush (connection);
+ dbus_connection_flush (connection);
- dbus_message_unref (message);
- dbus_error_free (&error);
+ dbus_message_unref (message);
+ dbus_error_free (&error);
- return reply;
+ return reply;
}
static DBusMessage *
@@ -212,333 +212,333 @@ screensaver_send_message_void (DBusConnection *connection,
const char *name,
gboolean expect_reply)
{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- dbus_error_init (&error);
-
- message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, name);
- if (message == NULL)
- {
- g_warning ("Couldn't allocate the dbus message");
- return NULL;
- }
-
- if (! expect_reply)
- {
- if (!dbus_connection_send (connection, message, NULL))
- g_warning ("could not send message");
- reply = NULL;
- }
- else
- {
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1, &error);
- if (dbus_error_is_set (&error))
- {
- g_warning ("%s raised:\n %s\n\n", error.name, error.message);
- reply = NULL;
- }
- }
- dbus_connection_flush (connection);
-
- dbus_message_unref (message);
- dbus_error_free (&error);
-
- return reply;
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusError error;
+
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ dbus_error_init (&error);
+
+ message = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, name);
+ if (message == NULL)
+ {
+ g_warning ("Couldn't allocate the dbus message");
+ return NULL;
+ }
+
+ if (! expect_reply)
+ {
+ if (!dbus_connection_send (connection, message, NULL))
+ g_warning ("could not send message");
+ reply = NULL;
+ }
+ else
+ {
+ reply = dbus_connection_send_with_reply_and_block (connection,
+ message,
+ -1, &error);
+ if (dbus_error_is_set (&error))
+ {
+ g_warning ("%s raised:\n %s\n\n", error.name, error.message);
+ reply = NULL;
+ }
+ }
+ dbus_connection_flush (connection);
+
+ dbus_message_unref (message);
+ dbus_error_free (&error);
+
+ return reply;
}
static char **
get_string_from_iter (DBusMessageIter *iter,
int *num_elements)
{
- int count;
- char **buffer;
-
- if (num_elements != NULL)
- {
- *num_elements = 0;
- }
-
- count = 0;
- buffer = (char **)malloc (sizeof (char *) * 8);
-
- if (buffer == NULL)
- {
- goto oom;
- }
-
- buffer[0] = NULL;
- while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING)
- {
- const char *value;
- char *str;
-
- if ((count % 8) == 0 && count != 0)
- {
- buffer = realloc (buffer, sizeof (char *) * (count + 8));
- if (buffer == NULL)
- {
- goto oom;
- }
- }
-
- dbus_message_iter_get_basic (iter, &value);
- str = strdup (value);
- if (str == NULL)
- {
- goto oom;
- }
-
- buffer[count] = str;
-
- dbus_message_iter_next (iter);
- count++;
- }
-
- if ((count % 8) == 0)
- {
- buffer = realloc (buffer, sizeof (char *) * (count + 1));
- if (buffer == NULL)
- {
- goto oom;
- }
- }
-
- buffer[count] = NULL;
- if (num_elements != NULL)
- {
- *num_elements = count;
- }
- return buffer;
+ int count;
+ char **buffer;
+
+ if (num_elements != NULL)
+ {
+ *num_elements = 0;
+ }
+
+ count = 0;
+ buffer = (char **)malloc (sizeof (char *) * 8);
+
+ if (buffer == NULL)
+ {
+ goto oom;
+ }
+
+ buffer[0] = NULL;
+ while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING)
+ {
+ const char *value;
+ char *str;
+
+ if ((count % 8) == 0 && count != 0)
+ {
+ buffer = realloc (buffer, sizeof (char *) * (count + 8));
+ if (buffer == NULL)
+ {
+ goto oom;
+ }
+ }
+
+ dbus_message_iter_get_basic (iter, &value);
+ str = strdup (value);
+ if (str == NULL)
+ {
+ goto oom;
+ }
+
+ buffer[count] = str;
+
+ dbus_message_iter_next (iter);
+ count++;
+ }
+
+ if ((count % 8) == 0)
+ {
+ buffer = realloc (buffer, sizeof (char *) * (count + 1));
+ if (buffer == NULL)
+ {
+ goto oom;
+ }
+ }
+
+ buffer[count] = NULL;
+ if (num_elements != NULL)
+ {
+ *num_elements = count;
+ }
+ return buffer;
oom:
- g_debug ("%s %d : error allocating memory\n", __FILE__, __LINE__);
- return NULL;
+ g_debug ("%s %d : error allocating memory\n", __FILE__, __LINE__);
+ return NULL;
}
static gboolean
do_command (DBusConnection *connection)
{
- DBusMessage *reply;
-
- if (do_quit)
- {
- reply = screensaver_send_message_void (connection, "Quit", FALSE);
- goto done;
- }
-
- if (do_query)
- {
- DBusMessageIter iter;
- DBusMessageIter array;
- dbus_bool_t v;
-
- reply = screensaver_send_message_void (connection, "GetActive", TRUE);
- if (! reply)
- {
- g_message ("Did not receive a reply from the screensaver.");
- goto done;
- }
-
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &v);
- g_print (_("The screensaver is %s\n"), v ? _("active") : _("inactive"));
-
- dbus_message_unref (reply);
-
- reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE);
- if (! reply)
- {
- g_message ("Did not receive a reply from screensaver.");
- goto done;
- }
-
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_recurse (&iter, &array);
-
- if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID)
- {
- g_print (_("The screensaver is not inhibited\n"));
- }
- else
- {
- char **inhibitors;
- int i;
- int num;
-
- g_print (_("The screensaver is being inhibited by:\n"));
- inhibitors = get_string_from_iter (&array, &num);
- for (i = 0; i < num; i++)
- {
- g_print ("\t%s\n", inhibitors[i]);
- }
- g_strfreev (inhibitors);
- }
-
- dbus_message_unref (reply);
- }
-
- if (do_time)
- {
- DBusMessageIter iter;
- dbus_bool_t v;
- dbus_int32_t t;
-
- reply = screensaver_send_message_void (connection, "GetActive", TRUE);
- if (! reply)
- {
- g_message ("Did not receive a reply from the screensaver.");
- goto done;
- }
-
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &v);
- dbus_message_unref (reply);
-
- if (v)
- {
-
- reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &t);
- g_print (_("The screensaver has been active for %d seconds.\n"), t);
-
- dbus_message_unref (reply);
- }
- else
- {
- g_print (_("The screensaver is not currently active.\n"));
- }
- }
-
- if (do_lock)
- {
- reply = screensaver_send_message_void (connection, "Lock", FALSE);
- }
-
- if (do_cycle)
- {
- reply = screensaver_send_message_void (connection, "Cycle", FALSE);
- }
-
- if (do_poke)
- {
- reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE);
- }
-
- if (do_activate)
- {
- reply = screensaver_send_message_bool (connection, "SetActive", TRUE);
- if (! reply)
- {
- g_message ("Did not receive a reply from the screensaver.");
- goto done;
- }
- dbus_message_unref (reply);
- }
-
- if (do_deactivate)
- {
- reply = screensaver_send_message_bool (connection, "SetActive", FALSE);
- if (! reply)
- {
- g_message ("Did not receive a reply from the screensaver.");
- goto done;
- }
- dbus_message_unref (reply);
- }
-
- if (do_inhibit)
- {
- reply = screensaver_send_message_inhibit (connection,
- inhibit_application ? inhibit_application : "Unknown",
- inhibit_reason ? inhibit_reason : "Unknown");
- if (! reply)
- {
- g_message ("Did not receive a reply from the screensaver.");
- goto done;
- }
- dbus_message_unref (reply);
-
- return FALSE;
- }
+ DBusMessage *reply;
+
+ if (do_quit)
+ {
+ reply = screensaver_send_message_void (connection, "Quit", FALSE);
+ goto done;
+ }
+
+ if (do_query)
+ {
+ DBusMessageIter iter;
+ DBusMessageIter array;
+ dbus_bool_t v;
+
+ reply = screensaver_send_message_void (connection, "GetActive", TRUE);
+ if (! reply)
+ {
+ g_message ("Did not receive a reply from the screensaver.");
+ goto done;
+ }
+
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_get_basic (&iter, &v);
+ g_print (_("The screensaver is %s\n"), v ? _("active") : _("inactive"));
+
+ dbus_message_unref (reply);
+
+ reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE);
+ if (! reply)
+ {
+ g_message ("Did not receive a reply from screensaver.");
+ goto done;
+ }
+
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_recurse (&iter, &array);
+
+ if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID)
+ {
+ g_print (_("The screensaver is not inhibited\n"));
+ }
+ else
+ {
+ char **inhibitors;
+ int i;
+ int num;
+
+ g_print (_("The screensaver is being inhibited by:\n"));
+ inhibitors = get_string_from_iter (&array, &num);
+ for (i = 0; i < num; i++)
+ {
+ g_print ("\t%s\n", inhibitors[i]);
+ }
+ g_strfreev (inhibitors);
+ }
+
+ dbus_message_unref (reply);
+ }
+
+ if (do_time)
+ {
+ DBusMessageIter iter;
+ dbus_bool_t v;
+ dbus_int32_t t;
+
+ reply = screensaver_send_message_void (connection, "GetActive", TRUE);
+ if (! reply)
+ {
+ g_message ("Did not receive a reply from the screensaver.");
+ goto done;
+ }
+
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_get_basic (&iter, &v);
+ dbus_message_unref (reply);
+
+ if (v)
+ {
+
+ reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE);
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_get_basic (&iter, &t);
+ g_print (_("The screensaver has been active for %d seconds.\n"), t);
+
+ dbus_message_unref (reply);
+ }
+ else
+ {
+ g_print (_("The screensaver is not currently active.\n"));
+ }
+ }
+
+ if (do_lock)
+ {
+ reply = screensaver_send_message_void (connection, "Lock", FALSE);
+ }
+
+ if (do_cycle)
+ {
+ reply = screensaver_send_message_void (connection, "Cycle", FALSE);
+ }
+
+ if (do_poke)
+ {
+ reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE);
+ }
+
+ if (do_activate)
+ {
+ reply = screensaver_send_message_bool (connection, "SetActive", TRUE);
+ if (! reply)
+ {
+ g_message ("Did not receive a reply from the screensaver.");
+ goto done;
+ }
+ dbus_message_unref (reply);
+ }
+
+ if (do_deactivate)
+ {
+ reply = screensaver_send_message_bool (connection, "SetActive", FALSE);
+ if (! reply)
+ {
+ g_message ("Did not receive a reply from the screensaver.");
+ goto done;
+ }
+ dbus_message_unref (reply);
+ }
+
+ if (do_inhibit)
+ {
+ reply = screensaver_send_message_inhibit (connection,
+ inhibit_application ? inhibit_application : "Unknown",
+ inhibit_reason ? inhibit_reason : "Unknown");
+ if (! reply)
+ {
+ g_message ("Did not receive a reply from the screensaver.");
+ goto done;
+ }
+ dbus_message_unref (reply);
+
+ return FALSE;
+ }
done:
- g_main_loop_quit (loop);
+ g_main_loop_quit (loop);
- return FALSE;
+ return FALSE;
}
int
main (int argc,
char **argv)
{
- DBusConnection *connection;
- DBusError dbus_error;
- GOptionContext *context;
- gboolean retval;
- GError *error = NULL;
+ DBusConnection *connection;
+ DBusError dbus_error;
+ GOptionContext *context;
+ gboolean retval;
+ GError *error = NULL;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- g_set_prgname (argv[0]);
+ g_set_prgname (argv[0]);
- if (setlocale (LC_ALL, "") == NULL)
- g_warning ("Locale not understood by C library, internationalization will not work\n");
+ if (setlocale (LC_ALL, "") == NULL)
+ g_warning ("Locale not understood by C library, internationalization will not work\n");
- context = g_option_context_new (NULL);
- g_option_context_add_main_entries (context, entries, NULL);
- retval = g_option_context_parse (context, &argc, &argv, &error);
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+ retval = g_option_context_parse (context, &argc, &argv, &error);
- g_option_context_free (context);
+ g_option_context_free (context);
- if (! retval)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- exit (1);
- }
+ if (!retval)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
- if (do_version)
- {
- g_print ("%s %s\n", argv [0], VERSION);
- exit (1);
- }
+ if (do_version)
+ {
+ g_print ("%s %s\n", argv [0], VERSION);
+ exit (1);
+ }
- dbus_error_init (&dbus_error);
- connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
- if (! connection)
- {
- g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
- dbus_error_free (&dbus_error);
- exit (1);
- }
+ dbus_error_init (&dbus_error);
+ connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
+ if (!connection)
+ {
+ g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
+ dbus_error_free (&dbus_error);
+ exit (1);
+ }
- dbus_connection_setup_with_g_main (connection, NULL);
+ dbus_connection_setup_with_g_main (connection, NULL);
- if (! screensaver_is_running (connection))
- {
- g_message ("Screensaver is not running!");
- exit (1);
- }
+ if (!screensaver_is_running (connection))
+ {
+ g_message ("Screensaver is not running!");
+ exit (1);
+ }
- g_idle_add ((GSourceFunc)do_command, connection);
+ g_idle_add ((GSourceFunc)do_command, connection);
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
+ loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (loop);
- return 0;
+ return 0;
}
diff --git a/src/xfce4-screensaver-dialog.c b/src/xfce4-screensaver-dialog.c
index 6517d87..55c33e6 100644
--- a/src/xfce4-screensaver-dialog.c
+++ b/src/xfce4-screensaver-dialog.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -59,373 +59,380 @@ static char* away_message = NULL;
static gint monitor_index = 0;
static GOptionEntry entries[] = {
- {"verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, N_("Show debugging output"), NULL},
- {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
- {"enable-logout", 0, 0, G_OPTION_ARG_NONE, &enable_logout, N_("Show the logout button"), NULL},
- {"logout-command", 0, 0, G_OPTION_ARG_STRING, &logout_command, N_("Command to invoke from the logout button"), NULL},
- {"enable-switch", 0, 0, G_OPTION_ARG_NONE, &enable_switch, N_("Show the switch user button"), NULL},
- {"status-message", 0, 0, G_OPTION_ARG_STRING, &status_message, N_("Message to show in the dialog"), N_("MESSAGE")},
- {"away-message", 0, 0, G_OPTION_ARG_STRING, &away_message, N_("Not used"), N_("MESSAGE")},
- {"height", 0, 0, G_OPTION_ARG_INT, &dialog_height, N_("Monitor height"), NULL},
- {"width", 0, 0, G_OPTION_ARG_INT, &dialog_width, N_("Monitor width"), NULL},
- {"monitor", 0, 0, G_OPTION_ARG_INT, &monitor_index, N_("Monitor index"), NULL},
- {NULL}
+ {"verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, N_("Show debugging output"), NULL},
+ {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
+ {"enable-logout", 0, 0, G_OPTION_ARG_NONE, &enable_logout, N_("Show the logout button"), NULL},
+ {"logout-command", 0, 0, G_OPTION_ARG_STRING, &logout_command, N_("Command to invoke from the logout button"), NULL},
+ {"enable-switch", 0, 0, G_OPTION_ARG_NONE, &enable_switch, N_("Show the switch user button"), NULL},
+ {"status-message", 0, 0, G_OPTION_ARG_STRING, &status_message, N_("Message to show in the dialog"), N_("MESSAGE")},
+ {"away-message", 0, 0, G_OPTION_ARG_STRING, &away_message, N_("Not used"), N_("MESSAGE")},
+ {"height", 0, 0, G_OPTION_ARG_INT, &dialog_height, N_("Monitor height"), NULL},
+ {"width", 0, 0, G_OPTION_ARG_INT, &dialog_width, N_("Monitor width"), NULL},
+ {"monitor", 0, 0, G_OPTION_ARG_INT, &monitor_index, N_("Monitor index"), NULL},
+ {NULL}
};
static char* get_id_string(GtkWidget* widget)
{
- char* id = NULL;
+ char* id = NULL;
- g_return_val_if_fail(widget != NULL, NULL);
- g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
+ g_return_val_if_fail(widget != NULL, NULL);
+ g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
- id = g_strdup_printf("%" G_GUINT32_FORMAT, (guint32) GDK_WINDOW_XID(gtk_widget_get_window(widget)));
- return id;
+ id = g_strdup_printf("%" G_GUINT32_FORMAT, (guint32) GDK_WINDOW_XID(gtk_widget_get_window(widget)));
+ return id;
}
static gboolean print_id(GtkWidget* widget)
{
- char* id;
+ char* id;
- gs_profile_start(NULL);
+ gs_profile_start(NULL);
- id = get_id_string(widget);
- printf("WINDOW ID=%s\n", id);
- fflush(stdout);
+ id = get_id_string(widget);
+ printf("WINDOW ID=%s\n", id);
+ fflush(stdout);
- gs_profile_end(NULL);
+ gs_profile_end(NULL);
- g_free(id);
+ g_free(id);
- return FALSE;
+ return FALSE;
}
static void response_cancel(void)
{
- printf("RESPONSE=CANCEL\n");
- fflush(stdout);
+ printf("RESPONSE=CANCEL\n");
+ fflush(stdout);
}
static void response_ok(void)
{
- printf("RESPONSE=OK\n");
- fflush(stdout);
+ printf("RESPONSE=OK\n");
+ fflush(stdout);
}
static gboolean quit_response_ok(void)
{
- response_ok();
- gtk_main_quit();
- return FALSE;
+ response_ok();
+ gtk_main_quit();
+ return FALSE;
}
static gboolean quit_response_cancel(void)
{
- response_cancel();
- gtk_main_quit();
- return FALSE;
+ response_cancel();
+ gtk_main_quit();
+ return FALSE;
}
static void response_lock_init_failed(void)
{
- /* if we fail to lock then we should drop the dialog */
- response_ok();
+ /* if we fail to lock then we should drop the dialog */
+ response_ok();
}
-static char* request_response(GSLockPlug* plug, const char* prompt, gboolean visible)
+static char* request_response(GSLockPlug* plug,
+ const char* prompt,
+ gboolean visible)
{
- int response;
- char* text;
+ int response;
+ char* text;
- gs_lock_plug_set_sensitive(plug, TRUE);
- gs_lock_plug_enable_prompt(plug, prompt, visible);
- response = gs_lock_plug_run(plug);
+ gs_lock_plug_set_sensitive(plug, TRUE);
+ gs_lock_plug_enable_prompt(plug, prompt, visible);
+ response = gs_lock_plug_run(plug);
- gs_debug ("got response: %d", response);
+ gs_debug ("got response: %d", response);
- text = NULL;
+ text = NULL;
- if (response == GS_LOCK_PLUG_RESPONSE_OK)
- {
- gs_lock_plug_get_text(plug, &text);
- }
+ if (response == GS_LOCK_PLUG_RESPONSE_OK)
+ {
+ gs_lock_plug_get_text(plug, &text);
+ }
- gs_lock_plug_disable_prompt(plug);
+ gs_lock_plug_disable_prompt(plug);
- return text;
+ return text;
}
/* Adapted from MDM2 daemon/verify-pam.c on 2006-06-13 */
static const char* maybe_translate_message(const char* msg)
{
- char* s;
- const char* ret;
- static GHashTable* hash = NULL;
-
- if (hash == NULL)
- {
- /* Here we come with some fairly standard messages so that
- we have as much as possible translated. Should really be
- translated in pam I suppose. This way we can "change"
- some of these messages to be more sane. */
- hash = g_hash_table_new (g_str_hash, g_str_equal);
- /* login: is whacked always translate to Username: */
- g_hash_table_insert(hash, "login:", _("Please enter your username."));
- g_hash_table_insert(hash, "Username:", _("Please enter your username."));
- g_hash_table_insert(hash, "username:", _("Please enter your username."));
- g_hash_table_insert(hash, "Password:", "");
- g_hash_table_insert(hash, "password:", "");
- g_hash_table_insert(hash, "You are required to change your password immediately (password aged)", _("You are required to change your password immediately (password aged)"));
- g_hash_table_insert(hash, "You are required to change your password immediately (root enforced)", _("You are required to change your password immediately (root enforced)"));
- g_hash_table_insert(hash, "Your account has expired; please contact your system administrator", _("Your account has expired; please contact your system administrator"));
- g_hash_table_insert(hash, "No password supplied", _("No password supplied."));
- g_hash_table_insert(hash, "Password unchanged", _("Password unchanged."));
- g_hash_table_insert(hash, "Can not get username", _("Can not get username."));
- g_hash_table_insert(hash, "Retype new UNIX password:", _("Retype your new password."));
- g_hash_table_insert(hash, "Enter new UNIX password:", _("Enter your new password."));
- g_hash_table_insert(hash, "(current) UNIX password:", _("Enter your current password:"));
- g_hash_table_insert(hash, "Error while changing NIS password.", _("Error while changing NIS password."));
- g_hash_table_insert(hash, "You must choose a longer password", _("You must choose a longer password."));
- g_hash_table_insert(hash, "Password has been already used. Choose another.", _("Password has been already used. Choose another."));
- g_hash_table_insert(hash, "You must wait longer to change your password", _("You must wait longer to change your password."));
- g_hash_table_insert(hash, "Sorry, passwords do not match", _("Sorry, passwords do not match."));
- /* FIXME: what about messages which have some variables in them, perhaps try to do those as well */
- }
-
- s = g_strstrip(g_strdup(msg));
- ret = g_hash_table_lookup(hash, s);
- g_free(s);
-
- if (ret != NULL)
- {
- return ret;
- }
- else
- {
- return msg;
- }
+ char *s;
+ const char *ret;
+ static GHashTable *hash = NULL;
+
+ if (hash == NULL)
+ {
+ /* Here we come with some fairly standard messages so that
+ we have as much as possible translated. Should really be
+ translated in pam I suppose. This way we can "change"
+ some of these messages to be more sane. */
+ hash = g_hash_table_new (g_str_hash, g_str_equal);
+ /* login: is whacked always translate to Username: */
+ g_hash_table_insert(hash, "login:", _("Please enter your username."));
+ g_hash_table_insert(hash, "Username:", _("Please enter your username."));
+ g_hash_table_insert(hash, "username:", _("Please enter your username."));
+ g_hash_table_insert(hash, "Password:", "");
+ g_hash_table_insert(hash, "password:", "");
+ g_hash_table_insert(hash, "You are required to change your password immediately (password aged)", _("You are required to change your password immediately (password aged)"));
+ g_hash_table_insert(hash, "You are required to change your password immediately (root enforced)", _("You are required to change your password immediately (root enforced)"));
+ g_hash_table_insert(hash, "Your account has expired; please contact your system administrator", _("Your account has expired; please contact your system administrator"));
+ g_hash_table_insert(hash, "No password supplied", _("No password supplied."));
+ g_hash_table_insert(hash, "Password unchanged", _("Password unchanged."));
+ g_hash_table_insert(hash, "Can not get username", _("Can not get username."));
+ g_hash_table_insert(hash, "Retype new UNIX password:", _("Retype your new password."));
+ g_hash_table_insert(hash, "Enter new UNIX password:", _("Enter your new password."));
+ g_hash_table_insert(hash, "(current) UNIX password:", _("Enter your current password:"));
+ g_hash_table_insert(hash, "Error while changing NIS password.", _("Error while changing NIS password."));
+ g_hash_table_insert(hash, "You must choose a longer password", _("You must choose a longer password."));
+ g_hash_table_insert(hash, "Password has been already used. Choose another.", _("Password has been already used. Choose another."));
+ g_hash_table_insert(hash, "You must wait longer to change your password", _("You must wait longer to change your password."));
+ g_hash_table_insert(hash, "Sorry, passwords do not match", _("Sorry, passwords do not match."));
+ /* FIXME: what about messages which have some variables in them, perhaps try to do those as well */
+ }
+
+ s = g_strstrip(g_strdup(msg));
+ ret = g_hash_table_lookup(hash, s);
+ g_free(s);
+
+ if (ret != NULL)
+ {
+ return ret;
+ }
+ else
+ {
+ return msg;
+ }
}
-static gboolean auth_message_handler(GSAuthMessageStyle style, const char* msg, char** response, gpointer data)
+static gboolean auth_message_handler(GSAuthMessageStyle style,
+ const char *msg,
+ char **response,
+ gpointer data)
{
- gboolean ret;
- GSLockPlug* plug;
- const char* message;
-
- plug = GS_LOCK_PLUG(data);
-
- gs_profile_start(NULL);
- gs_debug("Got message style %d: '%s'", style, msg);
-
- gtk_widget_show(GTK_WIDGET(plug));
- gs_lock_plug_set_ready(plug);
-
- ret = TRUE;
- *response = NULL;
- message = maybe_translate_message(msg);
-
- switch (style)
- {
- case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
- if (msg != NULL)
- {
- char *resp;
- resp = request_response(plug, message, TRUE);
- *response = resp;
- }
- break;
- case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
- if (msg != NULL)
- {
- char *resp;
- resp = request_response(plug, message, FALSE);
- *response = resp;
- }
- break;
- case GS_AUTH_MESSAGE_ERROR_MSG:
- gs_lock_plug_show_message(plug, message);
- break;
- case GS_AUTH_MESSAGE_TEXT_INFO:
- gs_lock_plug_show_message(plug, message);
- break;
- default:
- g_assert_not_reached();
- }
-
- if (*response == NULL)
- {
- gs_debug("Got no response");
- ret = FALSE;
- }
- else
- {
- gs_lock_plug_show_message(plug, _("Checking..."));
- gs_lock_plug_set_sensitive(plug, FALSE);
- }
-
- /* we may have pending events that should be processed before continuing back into PAM */
- while (gtk_events_pending())
- {
- gtk_main_iteration();
- }
-
- gs_lock_plug_set_busy(plug);
- gs_profile_end(NULL);
-
- return ret;
+ gboolean ret;
+ GSLockPlug *plug;
+ const char *message;
+
+ plug = GS_LOCK_PLUG(data);
+
+ gs_profile_start(NULL);
+ gs_debug("Got message style %d: '%s'", style, msg);
+
+ gtk_widget_show(GTK_WIDGET(plug));
+ gs_lock_plug_set_ready(plug);
+
+ ret = TRUE;
+ *response = NULL;
+ message = maybe_translate_message(msg);
+
+ switch (style)
+ {
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
+ if (msg != NULL)
+ {
+ char *resp;
+ resp = request_response(plug, message, TRUE);
+ *response = resp;
+ }
+ break;
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
+ if (msg != NULL)
+ {
+ char *resp;
+ resp = request_response(plug, message, FALSE);
+ *response = resp;
+ }
+ break;
+ case GS_AUTH_MESSAGE_ERROR_MSG:
+ gs_lock_plug_show_message(plug, message);
+ break;
+ case GS_AUTH_MESSAGE_TEXT_INFO:
+ gs_lock_plug_show_message(plug, message);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ if (*response == NULL)
+ {
+ gs_debug("Got no response");
+ ret = FALSE;
+ }
+ else
+ {
+ gs_lock_plug_show_message(plug, _("Checking..."));
+ gs_lock_plug_set_sensitive(plug, FALSE);
+ }
+
+ /* we may have pending events that should be processed before continuing back into PAM */
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ gs_lock_plug_set_busy(plug);
+ gs_profile_end(NULL);
+
+ return ret;
}
static gboolean reset_idle_cb(GSLockPlug* plug)
{
- gs_lock_plug_set_sensitive(plug, TRUE);
- gs_lock_plug_show_message(plug, NULL);
+ gs_lock_plug_set_sensitive(plug, TRUE);
+ gs_lock_plug_show_message(plug, NULL);
- return FALSE;
+ return FALSE;
}
static gboolean do_auth_check(GSLockPlug* plug)
{
- GError* error;
- gboolean res;
-
- error = NULL;
-
- gs_lock_plug_disable_prompt(plug);
- gs_lock_plug_set_busy(plug);
- res = gs_auth_verify_user(g_get_user_name(), g_getenv("DISPLAY"), auth_message_handler, plug, &error);
-
- gs_debug("Verify user returned: %s", res ? "TRUE" : "FALSE");
-
- if (! res)
- {
- if (error != NULL)
- {
- gs_debug("Verify user returned error: %s", error->message);
- gs_lock_plug_show_message(plug, error->message);
- }
- else
- {
- gs_lock_plug_show_message(plug, _("Authentication failed."));
- }
-
- printf("NOTICE=AUTH FAILED\n");
- fflush(stdout);
-
- if (error != NULL)
- {
- g_error_free(error);
- }
- }
-
- return res;
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+
+ gs_lock_plug_disable_prompt(plug);
+ gs_lock_plug_set_busy(plug);
+ res = gs_auth_verify_user(g_get_user_name(), g_getenv("DISPLAY"), auth_message_handler, plug, &error);
+
+ gs_debug("Verify user returned: %s", res ? "TRUE" : "FALSE");
+
+ if (! res)
+ {
+ if (error != NULL)
+ {
+ gs_debug("Verify user returned error: %s", error->message);
+ gs_lock_plug_show_message(plug, error->message);
+ }
+ else
+ {
+ gs_lock_plug_show_message(plug, _("Authentication failed."));
+ }
+
+ printf("NOTICE=AUTH FAILED\n");
+ fflush(stdout);
+
+ if (error != NULL)
+ {
+ g_error_free(error);
+ }
+ }
+
+ return res;
}
-static void response_cb(GSLockPlug* plug, gint response_id)
+static void response_cb(GSLockPlug *plug,
+ gint response_id)
{
- if ((response_id == GS_LOCK_PLUG_RESPONSE_CANCEL) || (response_id == GTK_RESPONSE_DELETE_EVENT))
- {
- quit_response_cancel();
- }
+ if ((response_id == GS_LOCK_PLUG_RESPONSE_CANCEL) || (response_id == GTK_RESPONSE_DELETE_EVENT))
+ {
+ quit_response_cancel();
+ }
}
static gboolean response_request_quit(void)
{
- printf("REQUEST QUIT\n");
- fflush(stdout);
- return FALSE;
+ printf("REQUEST QUIT\n");
+ fflush(stdout);
+ return FALSE;
}
static gboolean quit_timeout_cb(gpointer data)
{
- gtk_main_quit();
- return FALSE;
+ gtk_main_quit();
+ return FALSE;
}
static gboolean auth_check_idle(GSLockPlug* plug)
{
- gboolean res;
- gboolean again;
- static guint loop_counter = 0;
-
- again = TRUE;
- res = do_auth_check(plug);
-
- if (res)
- {
- again = FALSE;
- g_idle_add((GSourceFunc) quit_response_ok, NULL);
- }
- else
- {
- loop_counter++;
-
- if (loop_counter < MAX_FAILURES)
- {
- gs_debug ("Authentication failed, retrying (%u)", loop_counter);
- g_timeout_add (3000, (GSourceFunc) reset_idle_cb, plug);
- }
- else
- {
- gs_debug ("Authentication failed, quitting (max failures)");
- again = FALSE;
- /* Don't quit immediately, but rather request that xfce4-screensaver
- * terminates us after it has finished the dialog shake. Time out
- * after 5 seconds and quit anyway if this doesn't happen though */
- g_idle_add((GSourceFunc) response_request_quit, NULL);
- g_timeout_add(5000, (GSourceFunc) quit_timeout_cb, NULL);
- }
- }
-
- return again;
+ gboolean res;
+ gboolean again;
+ static guint loop_counter = 0;
+
+ again = TRUE;
+ res = do_auth_check(plug);
+
+ if (res)
+ {
+ again = FALSE;
+ g_idle_add((GSourceFunc) quit_response_ok, NULL);
+ }
+ else
+ {
+ loop_counter++;
+
+ if (loop_counter < MAX_FAILURES)
+ {
+ gs_debug ("Authentication failed, retrying (%u)", loop_counter);
+ g_timeout_add (3000, (GSourceFunc) reset_idle_cb, plug);
+ }
+ else
+ {
+ gs_debug ("Authentication failed, quitting (max failures)");
+ again = FALSE;
+ /* Don't quit immediately, but rather request that xfce4-screensaver
+ * terminates us after it has finished the dialog shake. Time out
+ * after 5 seconds and quit anyway if this doesn't happen though */
+ g_idle_add((GSourceFunc) response_request_quit, NULL);
+ g_timeout_add(5000, (GSourceFunc) quit_timeout_cb, NULL);
+ }
+ }
+
+ return again;
}
-static void show_cb(GtkWidget* widget, gpointer data)
+static void show_cb(GtkWidget *widget,
+ gpointer data)
{
- print_id(widget);
+ print_id(widget);
}
static gboolean popup_dialog_idle(void)
{
- GtkWidget* widget;
+ GtkWidget *widget;
- gs_profile_start(NULL);
+ gs_profile_start(NULL);
- widget = gs_lock_plug_new();
+ widget = gs_lock_plug_new();
- if (enable_logout)
- {
- g_object_set(widget, "logout-enabled", TRUE, NULL);
- }
+ if (enable_logout)
+ {
+ g_object_set(widget, "logout-enabled", TRUE, NULL);
+ }
- if (logout_command)
- {
- g_object_set(widget, "logout-command", logout_command, NULL);
- }
+ if (logout_command)
+ {
+ g_object_set(widget, "logout-command", logout_command, NULL);
+ }
- if (enable_switch)
- {
- g_object_set(widget, "switch-enabled", TRUE, NULL);
- }
+ if (enable_switch)
+ {
+ g_object_set(widget, "switch-enabled", TRUE, NULL);
+ }
- if (status_message)
- {
- g_object_set(widget, "status-message", status_message, NULL);
- }
+ if (status_message)
+ {
+ g_object_set(widget, "status-message", status_message, NULL);
+ }
- g_object_set(widget, "monitor-index", monitor_index, NULL);
+ g_object_set(widget, "monitor-index", monitor_index, NULL);
- gtk_widget_set_size_request(widget, dialog_width, dialog_height);
+ gtk_widget_set_size_request(widget, dialog_width, dialog_height);
- g_signal_connect(GS_LOCK_PLUG(widget), "response", G_CALLBACK(response_cb), NULL);
- g_signal_connect(widget, "show", G_CALLBACK(show_cb), NULL);
+ g_signal_connect(GS_LOCK_PLUG(widget), "response", G_CALLBACK(response_cb), NULL);
+ g_signal_connect(widget, "show", G_CALLBACK(show_cb), NULL);
- gtk_widget_realize(widget);
+ gtk_widget_realize(widget);
- g_idle_add((GSourceFunc) auth_check_idle, widget);
+ g_idle_add((GSourceFunc) auth_check_idle, widget);
- gs_profile_end(NULL);
+ gs_profile_end(NULL);
- return FALSE;
+ return FALSE;
}
@@ -437,39 +444,41 @@ static gboolean popup_dialog_idle(void)
If the executable is setuid root, then these initializations
are run as root, before discarding privileges.
*/
-static gboolean privileged_initialization(int* argc, char** argv, gboolean verbose)
+static gboolean privileged_initialization(int *argc,
+ char **argv,
+ gboolean verbose)
{
- gboolean ret;
- char* nolock_reason;
- char* orig_uid;
- char* uid_message;
+ gboolean ret;
+ char *nolock_reason;
+ char *orig_uid;
+ char *uid_message;
- gs_profile_start(NULL);
+ gs_profile_start(NULL);
- #ifndef NO_LOCKING
- /* before hack_uid () for proper permissions */
- gs_auth_priv_init();
- #endif /* NO_LOCKING */
+ #ifndef NO_LOCKING
+ /* before hack_uid () for proper permissions */
+ gs_auth_priv_init();
+ #endif /* NO_LOCKING */
- ret = hack_uid(&nolock_reason, &orig_uid, &uid_message);
+ ret = hack_uid(&nolock_reason, &orig_uid, &uid_message);
- if (nolock_reason)
- {
- g_debug("Locking disabled: %s", nolock_reason);
- }
+ if (nolock_reason)
+ {
+ g_debug("Locking disabled: %s", nolock_reason);
+ }
- if (uid_message && verbose)
- {
- g_print("Modified UID: %s", uid_message);
- }
+ if (uid_message && verbose)
+ {
+ g_print("Modified UID: %s", uid_message);
+ }
- g_free(nolock_reason);
- g_free(orig_uid);
- g_free(uid_message);
+ g_free(nolock_reason);
+ g_free(orig_uid);
+ g_free(uid_message);
- gs_profile_end(NULL);
+ gs_profile_end(NULL);
- return ret;
+ return ret;
}
@@ -479,148 +488,152 @@ static gboolean privileged_initialization(int* argc, char** argv, gboolean verbo
*
* Figure out what locking mechanisms are supported.
*/
-static gboolean lock_initialization (int* argc, char** argv, char** nolock_reason, gboolean verbose)
+static gboolean lock_initialization (int *argc,
+ char **argv,
+ char **nolock_reason,
+ gboolean verbose)
{
- if (nolock_reason != NULL)
- {
- *nolock_reason = NULL;
- }
-
- #ifdef NO_LOCKING
-
- if (nolock_reason != NULL)
- {
- *nolock_reason = g_strdup("not compiled with locking support");
- }
-
- return FALSE;
- #else /* !NO_LOCKING */
-
- /* Finish initializing locking, now that we're out of privileged code. */
- if (!gs_auth_init())
- {
- if (nolock_reason != NULL)
- {
- *nolock_reason = g_strdup("error getting password");
- }
-
- return FALSE;
- }
-
- /* If locking is currently enabled, but the environment indicates that
- * we have been launched as MDM's "Background" program, then disable
- * locking just in case.
- */
- if (getenv("RUNNING_UNDER_MDM"))
- {
- if (nolock_reason != NULL)
- {
- *nolock_reason = g_strdup("running under MDM");
- }
-
- return FALSE;
- }
-
- /* If the server is XDarwin (MacOS X) then disable locking.
- * (X grabs only affect X programs, so you can use Command-Tab
- * to bring any other Mac program to the front, e.g., Terminal.)
- */
- {
- gboolean macos = FALSE;
-
- #ifdef __APPLE__
- /* Disable locking if *running* on Apple hardware, since we have no
- * reliable way to determine whether the server is running on MacOS.
- * Hopefully __APPLE__ means "MacOS" and not "Linux on Mac hardware"
- * but I'm not really sure about that.
- */
- macos = TRUE;
- #endif /* __APPLE__ */
-
- if (macos)
- {
- if (nolock_reason != NULL)
- {
- *nolock_reason = g_strdup("Cannot lock securely on MacOS X");
- }
-
- return FALSE;
- }
- }
-
- #endif /* NO_LOCKING */
-
- return TRUE;
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = NULL;
+ }
+
+ #ifdef NO_LOCKING
+
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup("not compiled with locking support");
+ }
+
+ return FALSE;
+ #else /* !NO_LOCKING */
+
+ /* Finish initializing locking, now that we're out of privileged code. */
+ if (!gs_auth_init())
+ {
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup("error getting password");
+ }
+
+ return FALSE;
+ }
+
+ /* If locking is currently enabled, but the environment indicates that
+ * we have been launched as MDM's "Background" program, then disable
+ * locking just in case.
+ */
+ if (getenv("RUNNING_UNDER_MDM"))
+ {
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup("running under MDM");
+ }
+
+ return FALSE;
+ }
+
+ /* If the server is XDarwin (MacOS X) then disable locking.
+ * (X grabs only affect X programs, so you can use Command-Tab
+ * to bring any other Mac program to the front, e.g., Terminal.)
+ */
+ {
+ gboolean macos = FALSE;
+
+ #ifdef __APPLE__
+ /* Disable locking if *running* on Apple hardware, since we have no
+ * reliable way to determine whether the server is running on MacOS.
+ * Hopefully __APPLE__ means "MacOS" and not "Linux on Mac hardware"
+ * but I'm not really sure about that.
+ */
+ macos = TRUE;
+ #endif /* __APPLE__ */
+
+ if (macos)
+ {
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup("Cannot lock securely on MacOS X");
+ }
+
+ return FALSE;
+ }
+ }
+
+ #endif /* NO_LOCKING */
+
+ return TRUE;
}
-int main(int argc, char** argv)
+int main(int argc,
+ char **argv)
{
- GError* error = NULL;
- char* nolock_reason = NULL;
-
- #ifdef ENABLE_NLS
- bindtextdomain(GETTEXT_PACKAGE, XFCELOCALEDIR);
- #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- #endif
- textdomain(GETTEXT_PACKAGE);
- #endif
-
- gs_profile_start(NULL);
-
- if (!privileged_initialization(&argc, argv, verbose))
- {
- response_lock_init_failed();
- exit(1);
- }
-
- error = NULL;
-
- if (!gtk_init_with_args(&argc, &argv, NULL, entries, NULL, &error))
- {
- if (error != NULL)
- {
- fprintf(stderr, "%s", error->message);
- g_error_free(error);
- }
-
- exit(1);
- }
-
- if (!xfconf_init(&error))
- {
- g_error("Failed to connect to xfconf daemon: %s.", error->message);
- g_error_free(error);
-
- exit(1);
- }
-
- if (show_version)
- {
- g_print("%s %s\n", argv[0], VERSION);
- exit(1);
- }
-
- if (!lock_initialization(&argc, argv, &nolock_reason, verbose))
- {
- if (nolock_reason != NULL)
- {
- g_debug ("Screen locking disabled: %s", nolock_reason);
- g_free (nolock_reason);
- }
-
- response_lock_init_failed();
- exit (1);
- }
-
- gs_debug_init(verbose, FALSE);
-
- g_idle_add((GSourceFunc) popup_dialog_idle, NULL);
-
- gtk_main();
-
- gs_profile_end(NULL);
- gs_debug_shutdown();
-
- return 0;
+ GError *error = NULL;
+ char *nolock_reason = NULL;
+
+ #ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, XFCELOCALEDIR);
+ #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ #endif
+ textdomain(GETTEXT_PACKAGE);
+ #endif
+
+ gs_profile_start(NULL);
+
+ if (!privileged_initialization(&argc, argv, verbose))
+ {
+ response_lock_init_failed();
+ exit(1);
+ }
+
+ error = NULL;
+
+ if (!gtk_init_with_args(&argc, &argv, NULL, entries, NULL, &error))
+ {
+ if (error != NULL)
+ {
+ fprintf(stderr, "%s", error->message);
+ g_error_free(error);
+ }
+
+ exit(1);
+ }
+
+ if (!xfconf_init(&error))
+ {
+ g_error("Failed to connect to xfconf daemon: %s.", error->message);
+ g_error_free(error);
+
+ exit(1);
+ }
+
+ if (show_version)
+ {
+ g_print("%s %s\n", argv[0], VERSION);
+ exit(1);
+ }
+
+ if (!lock_initialization(&argc, argv, &nolock_reason, verbose))
+ {
+ if (nolock_reason != NULL)
+ {
+ g_debug ("Screen locking disabled: %s", nolock_reason);
+ g_free (nolock_reason);
+ }
+
+ response_lock_init_failed();
+ exit (1);
+ }
+
+ gs_debug_init(verbose, FALSE);
+
+ g_idle_add((GSourceFunc) popup_dialog_idle, NULL);
+
+ gtk_main();
+
+ gs_profile_end(NULL);
+ gs_debug_shutdown();
+
+ return 0;
}
diff --git a/src/xfce4-screensaver-gl-helper.c b/src/xfce4-screensaver-gl-helper.c
index 5656ab1..49ffd90 100644
--- a/src/xfce4-screensaver-gl-helper.c
+++ b/src/xfce4-screensaver-gl-helper.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
*
@@ -34,46 +34,46 @@ int
main (int argc,
char **argv)
{
- GdkDisplay *display;
- GdkVisual *visual;
- Visual *xvisual;
- GError *error = NULL;
+ GdkDisplay *display;
+ GdkVisual *visual;
+ Visual *xvisual;
+ GError *error = NULL;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- g_set_prgname (argv[0]);
- if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- if (error != NULL)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- else
- {
- g_warning ("Unable to initialize GTK+");
- }
- exit (1);
- }
+ g_set_prgname (argv[0]);
+ if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
+ {
+ if (error != NULL)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ g_warning ("Unable to initialize GTK+");
+ }
+ exit (1);
+ }
- display = gdk_display_get_default ();
- visual = gs_visual_gl_get_best_for_display (display);
+ display = gdk_display_get_default ();
+ visual = gs_visual_gl_get_best_for_display (display);
- if (visual != NULL)
- {
- xvisual = gdk_x11_visual_get_xvisual (visual);
- printf ("0x%x\n", (unsigned int) XVisualIDFromVisual (xvisual));
- }
- else
- {
- printf ("none\n");
- }
+ if (visual != NULL)
+ {
+ xvisual = gdk_x11_visual_get_xvisual (visual);
+ printf ("0x%x\n", (unsigned int) XVisualIDFromVisual (xvisual));
+ }
+ else
+ {
+ printf ("none\n");
+ }
- return 0;
+ return 0;
}
diff --git a/src/xfce4-screensaver-preferences.c b/src/xfce4-screensaver-preferences.c
index 4cfd1d8..2866beb 100644
--- a/src/xfce4-screensaver-preferences.c
+++ b/src/xfce4-screensaver-preferences.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -69,8 +69,8 @@ enum
static GtkTargetEntry drop_types [] =
{
- { "text/uri-list", 0, TARGET_URI_LIST },
- { "_NETSCAPE_URL", 0, TARGET_NS_URL }
+ { "text/uri-list", 0, TARGET_URI_LIST },
+ { "_NETSCAPE_URL", 0, TARGET_NS_URL }
};
static GtkBuilder *builder = NULL;
@@ -81,222 +81,227 @@ static XfconfChannel *screensaver_channel = NULL;
static gint32
config_get_activate_delay (gboolean *is_writable)
{
- gint32 delay;
+ gint32 delay;
- if (is_writable)
- {
- *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
- KEY_IDLE_DELAY);
- }
+ if (is_writable)
+ {
+ *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
+ KEY_IDLE_DELAY);
+ }
- delay = xfconf_channel_get_int (screensaver_channel, KEY_IDLE_DELAY, DEFAULT_KEY_IDLE_DELAY);
+ delay = xfconf_channel_get_int (screensaver_channel, KEY_IDLE_DELAY, DEFAULT_KEY_IDLE_DELAY);
- if (delay < 1)
- {
- delay = 1;
- }
+ if (delay < 1)
+ {
+ delay = 1;
+ }
- return delay;
+ return delay;
}
static void
config_set_activate_delay (gint32 timeout)
{
- xfconf_channel_set_int (screensaver_channel, KEY_IDLE_DELAY, timeout);
+ xfconf_channel_set_int (screensaver_channel, KEY_IDLE_DELAY, timeout);
}
static int
config_get_mode (gboolean *is_writable)
{
- int mode;
+ int mode;
- if (is_writable)
- {
- *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
- KEY_MODE);
- }
+ if (is_writable)
+ {
+ *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
+ KEY_MODE);
+ }
- mode = xfconf_channel_get_int (screensaver_channel, KEY_MODE, DEFAULT_KEY_MODE);
+ mode = xfconf_channel_get_int (screensaver_channel, KEY_MODE, DEFAULT_KEY_MODE);
- return mode;
+ return mode;
}
static void
config_set_mode (int mode)
{
- xfconf_channel_set_int (screensaver_channel, KEY_MODE, mode);
+ xfconf_channel_set_int (screensaver_channel, KEY_MODE, mode);
}
static char *
config_get_theme (gboolean *is_writable)
{
- char *name;
- int mode;
-
- if (is_writable)
- {
- gboolean can_write_theme = TRUE;
- gboolean can_write_mode = TRUE;
-
- can_write_theme = !xfconf_channel_is_property_locked (screensaver_channel,
- KEY_THEMES);
- can_write_mode = !xfconf_channel_is_property_locked (screensaver_channel,
- KEY_MODE);
- *is_writable = can_write_theme && can_write_mode;
- }
-
- mode = config_get_mode (NULL);
-
- name = NULL;
- if (mode == GS_MODE_BLANK_ONLY)
- {
- name = g_strdup ("__blank-only");
- }
- else if (mode == GS_MODE_RANDOM)
- {
- name = g_strdup ("__random");
- }
- else
- {
- gchar **strv;
- strv = xfconf_channel_get_string_list (screensaver_channel,
- KEY_THEMES);
- if (strv != NULL) {
- name = g_strdup (strv[0]);
- }
- else
- {
- /* TODO: handle error */
- /* default to blank */
- name = g_strdup ("__blank-only");
- }
-
- g_strfreev (strv);
- }
-
- return name;
+ char *name;
+ int mode;
+
+ if (is_writable)
+ {
+ gboolean can_write_theme = TRUE;
+ gboolean can_write_mode = TRUE;
+
+ can_write_theme = !xfconf_channel_is_property_locked (screensaver_channel,
+ KEY_THEMES);
+ can_write_mode = !xfconf_channel_is_property_locked (screensaver_channel,
+ KEY_MODE);
+ *is_writable = can_write_theme && can_write_mode;
+ }
+
+ mode = config_get_mode (NULL);
+
+ name = NULL;
+ if (mode == GS_MODE_BLANK_ONLY)
+ {
+ name = g_strdup ("__blank-only");
+ }
+ else if (mode == GS_MODE_RANDOM)
+ {
+ name = g_strdup ("__random");
+ }
+ else
+ {
+ gchar **strv;
+ strv = xfconf_channel_get_string_list (screensaver_channel,
+ KEY_THEMES);
+ if (strv != NULL) {
+ name = g_strdup (strv[0]);
+ }
+ else
+ {
+ /* TODO: handle error */
+ /* default to blank */
+ name = g_strdup ("__blank-only");
+ }
+
+ g_strfreev (strv);
+ }
+
+ return name;
}
static gchar **
get_all_theme_ids (GSThemeManager *theme_manager)
{
- gchar **ids = NULL;
- GSList *entries;
- GSList *l;
- guint idx = 0;
-
- entries = gs_theme_manager_get_info_list (theme_manager);
- ids = g_new0 (gchar *, g_slist_length (entries) + 1);
- for (l = entries; l; l = l->next)
- {
- GSThemeInfo *info = l->data;
-
- ids[idx++] = g_strdup (gs_theme_info_get_id (info));
- gs_theme_info_unref (info);
- }
- g_slist_free (entries);
-
- return ids;
+ gchar **ids = NULL;
+ GSList *entries;
+ GSList *l;
+ guint idx = 0;
+
+ entries = gs_theme_manager_get_info_list (theme_manager);
+ ids = g_new0 (gchar *, g_slist_length (entries) + 1);
+ for (l = entries; l; l = l->next)
+ {
+ GSThemeInfo *info = l->data;
+
+ ids[idx++] = g_strdup (gs_theme_info_get_id (info));
+ gs_theme_info_unref (info);
+ }
+ g_slist_free (entries);
+
+ return ids;
}
static void
config_set_theme (const char *theme_id)
{
- gchar **strv = NULL;
- int mode;
-
- if (theme_id && strcmp (theme_id, "__blank-only") == 0)
- {
- mode = GS_MODE_BLANK_ONLY;
- }
- else if (theme_id && strcmp (theme_id, "__random") == 0)
- {
- mode = GS_MODE_RANDOM;
-
- /* set the themes key to contain all available screensavers */
- strv = get_all_theme_ids (theme_manager);
- }
- else
- {
- mode = GS_MODE_SINGLE;
- strv = g_strsplit (theme_id, "%%%", 1);
- }
-
- config_set_mode (mode);
-
- xfconf_channel_set_string_list (screensaver_channel,
- KEY_THEMES,
- (const gchar * const*) strv);
-
- g_strfreev (strv);
-
+ gchar **strv = NULL;
+ int mode;
+
+ if (theme_id && strcmp (theme_id, "__blank-only") == 0)
+ {
+ mode = GS_MODE_BLANK_ONLY;
+ }
+ else if (theme_id && strcmp (theme_id, "__random") == 0)
+ {
+ mode = GS_MODE_RANDOM;
+
+ /* set the themes key to contain all available screensavers */
+ strv = get_all_theme_ids (theme_manager);
+ }
+ else
+ {
+ mode = GS_MODE_SINGLE;
+ strv = g_strsplit (theme_id, "%%%", 1);
+ }
+
+ config_set_mode (mode);
+
+ xfconf_channel_set_string_list (screensaver_channel,
+ KEY_THEMES,
+ (const gchar * const*) strv);
+
+ g_strfreev (strv);
}
static gboolean
config_get_enabled (gboolean *is_writable)
{
- int enabled;
+ int enabled;
- if (is_writable)
- {
- *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
- KEY_LOCK_ENABLED);
- }
+ if (is_writable)
+ {
+ *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
+ KEY_LOCK_ENABLED);
+ }
- enabled = xfconf_channel_get_bool (screensaver_channel, KEY_IDLE_ACTIVATION_ENABLED, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
+ enabled = xfconf_channel_get_bool (screensaver_channel,
+ KEY_IDLE_ACTIVATION_ENABLED,
+ DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
- return enabled;
+ return enabled;
}
static void
config_set_enabled (gboolean enabled)
{
- xfconf_channel_set_bool (screensaver_channel, KEY_IDLE_ACTIVATION_ENABLED, enabled);
+ xfconf_channel_set_bool (screensaver_channel,
+ KEY_IDLE_ACTIVATION_ENABLED,
+ enabled);
}
static gboolean
config_get_lock (gboolean *is_writable)
{
- gboolean lock;
+ gboolean lock;
- if (is_writable)
- {
- *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
- KEY_LOCK_ENABLED);
- }
+ if (is_writable)
+ {
+ *is_writable = !xfconf_channel_is_property_locked (screensaver_channel,
+ KEY_LOCK_ENABLED);
+ }
- lock = xfconf_channel_get_bool (screensaver_channel, KEY_LOCK_ENABLED, DEFAULT_KEY_LOCK_ENABLED);
+ lock = xfconf_channel_get_bool (screensaver_channel,
+ KEY_LOCK_ENABLED,
+ DEFAULT_KEY_LOCK_ENABLED);
- return lock;
+ return lock;
}
static void
config_set_lock (gboolean lock)
{
- xfconf_channel_set_bool (screensaver_channel, KEY_LOCK_ENABLED, lock);
+ xfconf_channel_set_bool (screensaver_channel, KEY_LOCK_ENABLED, lock);
}
static void
job_set_theme (GSJob *job,
const char *theme)
{
- GSThemeInfo *info;
- const char *command;
+ GSThemeInfo *info;
+ const char *command;
- command = NULL;
+ command = NULL;
- info = gs_theme_manager_lookup_theme_info (theme_manager, theme);
- if (info != NULL)
- {
- command = gs_theme_info_get_exec (info);
- }
+ info = gs_theme_manager_lookup_theme_info (theme_manager, theme);
+ if (info != NULL)
+ {
+ command = gs_theme_info_get_exec (info);
+ }
- gs_job_set_command (job, command);
+ gs_job_set_command (job, command);
- if (info != NULL)
- {
- gs_theme_info_unref (info);
- }
+ if (info != NULL)
+ {
+ gs_theme_info_unref (info);
+ }
}
static gboolean
@@ -304,14 +309,14 @@ preview_on_draw (GtkWidget *widget,
cairo_t *cr,
gpointer data)
{
- if (job == NULL || !gs_job_is_running (job))
- {
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_paint (cr);
- }
-
- return FALSE;
+ if (job == NULL || !gs_job_is_running (job))
+ {
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+ }
+
+ return FALSE;
}
static void
@@ -319,71 +324,71 @@ preview_set_theme (GtkWidget *widget,
const char *theme,
const char *name)
{
- GtkWidget *label;
- char *markup;
+ GtkWidget *label;
+ char *markup;
- if (job != NULL)
- {
- gs_job_stop (job);
- }
+ if (job != NULL)
+ {
+ gs_job_stop (job);
+ }
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
- label = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_theme_label"));
- markup = g_markup_printf_escaped ("<i>%s</i>", name);
- gtk_label_set_markup (GTK_LABEL (label), markup);
- g_free (markup);
+ label = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_theme_label"));
+ markup = g_markup_printf_escaped ("<i>%s</i>", name);
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ g_free (markup);
- if ((theme && strcmp (theme, "__blank-only") == 0))
- {
+ if ((theme && strcmp (theme, "__blank-only") == 0))
+ {
- }
- else if (theme && strcmp (theme, "__random") == 0)
- {
- gchar **themes;
+ }
+ else if (theme && strcmp (theme, "__random") == 0)
+ {
+ gchar **themes;
- themes = get_all_theme_ids (theme_manager);
- if (themes != NULL)
- {
- gint32 i;
+ themes = get_all_theme_ids (theme_manager);
+ if (themes != NULL)
+ {
+ gint32 i;
- i = g_random_int_range (0, g_strv_length (themes));
+ i = g_random_int_range (0, g_strv_length (themes));
job_set_theme (job, themes[i]);
g_strfreev (themes);
- gs_job_start (job);
- }
- }
- else
- {
- job_set_theme (job, theme);
- gs_job_start (job);
- }
+ gs_job_start (job);
+ }
+ }
+ else
+ {
+ job_set_theme (job, theme);
+ gs_job_start (job);
+ }
}
static void
help_display (void)
{
- GError *error;
-
- error = NULL;
- gtk_show_uri_on_window (NULL,
- "help:xfce-user-guide/prefs-screensaver",
- GDK_CURRENT_TIME,
- &error);
-
- if (error != NULL)
- {
- GtkWidget *d;
-
- d = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "%s", error->message);
- gtk_dialog_run (GTK_DIALOG (d));
- gtk_widget_destroy (d);
- g_error_free (error);
- }
+ GError *error;
+
+ error = NULL;
+ gtk_show_uri_on_window (NULL,
+ "help:xfce-user-guide/prefs-screensaver",
+ GDK_CURRENT_TIME,
+ &error);
+
+ if (error != NULL)
+ {
+ GtkWidget *d;
+
+ d = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (d));
+ gtk_widget_destroy (d);
+ g_error_free (error);
+ }
}
@@ -392,170 +397,170 @@ response_cb (GtkWidget *widget,
int response_id)
{
- if (response_id == GTK_RESPONSE_HELP)
- {
- help_display ();
- }
- else if (response_id == GTK_RESPONSE_REJECT)
- {
- GError *error;
- gboolean res;
-
- error = NULL;
-
- res = xfce_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
- GPM_COMMAND,
- &error);
- if (! res)
- {
- g_warning ("Unable to start power management preferences: %s", error->message);
- g_error_free (error);
- }
- }
- else
- {
- gtk_widget_destroy (widget);
- gtk_main_quit ();
- }
+ if (response_id == GTK_RESPONSE_HELP)
+ {
+ help_display ();
+ }
+ else if (response_id == GTK_RESPONSE_REJECT)
+ {
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+
+ res = xfce_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
+ GPM_COMMAND,
+ &error);
+ if (! res)
+ {
+ g_warning ("Unable to start power management preferences: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ else
+ {
+ gtk_widget_destroy (widget);
+ gtk_main_quit ();
+ }
}
static GSList *
get_theme_info_list (void)
{
- return gs_theme_manager_get_info_list (theme_manager);
+ return gs_theme_manager_get_info_list (theme_manager);
}
static void
populate_model (GtkTreeStore *store)
{
- GtkTreeIter iter;
- GSList *themes = NULL;
- GSList *l;
-
- gtk_tree_store_append (store, &iter, NULL);
- gtk_tree_store_set (store, &iter,
- NAME_COLUMN, _("Blank screen"),
- ID_COLUMN, "__blank-only",
- -1);
-
- gtk_tree_store_append (store, &iter, NULL);
- gtk_tree_store_set (store, &iter,
- NAME_COLUMN, _("Random"),
- ID_COLUMN, "__random",
- -1);
-
- gtk_tree_store_append (store, &iter, NULL);
- gtk_tree_store_set (store, &iter,
- NAME_COLUMN, NULL,
- ID_COLUMN, "__separator",
- -1);
-
- themes = get_theme_info_list ();
-
- if (themes == NULL)
- {
- return;
- }
-
- for (l = themes; l; l = l->next)
- {
- const char *name;
- const char *id;
- GSThemeInfo *info = l->data;
-
- if (info == NULL)
- {
- continue;
- }
-
- name = gs_theme_info_get_name (info);
- id = gs_theme_info_get_id (info);
-
- gtk_tree_store_append (store, &iter, NULL);
- gtk_tree_store_set (store, &iter,
- NAME_COLUMN, name,
- ID_COLUMN, id,
- -1);
-
- gs_theme_info_unref (info);
- }
-
- g_slist_free (themes);
+ GtkTreeIter iter;
+ GSList *themes = NULL;
+ GSList *l;
+
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store, &iter,
+ NAME_COLUMN, _("Blank screen"),
+ ID_COLUMN, "__blank-only",
+ -1);
+
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store, &iter,
+ NAME_COLUMN, _("Random"),
+ ID_COLUMN, "__random",
+ -1);
+
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store, &iter,
+ NAME_COLUMN, NULL,
+ ID_COLUMN, "__separator",
+ -1);
+
+ themes = get_theme_info_list ();
+
+ if (themes == NULL)
+ {
+ return;
+ }
+
+ for (l = themes; l; l = l->next)
+ {
+ const char *name;
+ const char *id;
+ GSThemeInfo *info = l->data;
+
+ if (info == NULL)
+ {
+ continue;
+ }
+
+ name = gs_theme_info_get_name (info);
+ id = gs_theme_info_get_id (info);
+
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store, &iter,
+ NAME_COLUMN, name,
+ ID_COLUMN, id,
+ -1);
+
+ gs_theme_info_unref (info);
+ }
+
+ g_slist_free (themes);
}
static void
tree_selection_previous (GtkTreeSelection *selection)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreePath *path;
-
- if (! gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return;
- }
-
- path = gtk_tree_model_get_path (model, &iter);
- if (gtk_tree_path_prev (path))
- {
- gtk_tree_selection_select_path (selection, path);
- }
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+
+ if (! gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ return;
+ }
+
+ path = gtk_tree_model_get_path (model, &iter);
+ if (gtk_tree_path_prev (path))
+ {
+ gtk_tree_selection_select_path (selection, path);
+ }
}
static void
tree_selection_next (GtkTreeSelection *selection)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreePath *path;
-
- if (! gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return;
- }
-
- path = gtk_tree_model_get_path (model, &iter);
- gtk_tree_path_next (path);
- gtk_tree_selection_select_path (selection, path);
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+
+ if (! gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ return;
+ }
+
+ path = gtk_tree_model_get_path (model, &iter);
+ gtk_tree_path_next (path);
+ gtk_tree_selection_select_path (selection, path);
}
static void
tree_selection_changed_cb (GtkTreeSelection *selection,
GtkWidget *preview)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- char *theme;
- char *name;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ char *theme;
+ char *name;
- if (! gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return;
- }
+ if (! gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ return;
+ }
- gtk_tree_model_get (model, &iter, ID_COLUMN, &theme, NAME_COLUMN, &name, -1);
+ gtk_tree_model_get (model, &iter, ID_COLUMN, &theme, NAME_COLUMN, &name, -1);
- if (theme == NULL)
- {
- g_free (name);
- return;
- }
+ if (theme == NULL)
+ {
+ g_free (name);
+ return;
+ }
- preview_set_theme (preview, theme, name);
- config_set_theme (theme);
+ preview_set_theme (preview, theme, name);
+ config_set_theme (theme);
- g_free (theme);
- g_free (name);
+ g_free (theme);
+ g_free (name);
}
static void
activate_delay_value_changed_cb (GtkRange *range,
gpointer user_data)
{
- gdouble value;
+ gdouble value;
- value = gtk_range_get_value (range);
- config_set_activate_delay ((gint32)value);
+ value = gtk_range_get_value (range);
+ config_set_activate_delay ((gint32)value);
}
static int
@@ -564,51 +569,50 @@ compare_theme_names (char *name_a,
char *id_a,
char *id_b)
{
-
- if (id_a == NULL)
- {
- return 1;
- }
- else if (id_b == NULL)
- {
- return -1;
- }
-
- if (strcmp (id_a, "__blank-only") == 0)
- {
- return -1;
- }
- else if (strcmp (id_b, "__blank-only") == 0)
- {
- return 1;
- }
- else if (strcmp (id_a, "__random") == 0)
- {
- return -1;
- }
- else if (strcmp (id_b, "__random") == 0)
- {
- return 1;
- }
- else if (strcmp (id_a, "__separator") == 0)
- {
- return -1;
- }
- else if (strcmp (id_b, "__separator") == 0)
- {
- return 1;
- }
-
- if (name_a == NULL)
- {
- return 1;
- }
- else if (name_b == NULL)
- {
- return -1;
- }
-
- return g_utf8_collate (name_a, name_b);
+ if (id_a == NULL)
+ {
+ return 1;
+ }
+ else if (id_b == NULL)
+ {
+ return -1;
+ }
+
+ if (strcmp (id_a, "__blank-only") == 0)
+ {
+ return -1;
+ }
+ else if (strcmp (id_b, "__blank-only") == 0)
+ {
+ return 1;
+ }
+ else if (strcmp (id_a, "__random") == 0)
+ {
+ return -1;
+ }
+ else if (strcmp (id_b, "__random") == 0)
+ {
+ return 1;
+ }
+ else if (strcmp (id_a, "__separator") == 0)
+ {
+ return -1;
+ }
+ else if (strcmp (id_b, "__separator") == 0)
+ {
+ return 1;
+ }
+
+ if (name_a == NULL)
+ {
+ return 1;
+ }
+ else if (name_b == NULL)
+ {
+ return -1;
+ }
+
+ return g_utf8_collate (name_a, name_b);
}
static int
@@ -617,25 +621,25 @@ compare_theme (GtkTreeModel *model,
GtkTreeIter *b,
gpointer user_data)
{
- char *name_a;
- char *name_b;
- char *id_a;
- char *id_b;
- int result;
+ char *name_a;
+ char *name_b;
+ char *id_a;
+ char *id_b;
+ int result;
- gtk_tree_model_get (model, a, NAME_COLUMN, &name_a, -1);
- gtk_tree_model_get (model, b, NAME_COLUMN, &name_b, -1);
- gtk_tree_model_get (model, a, ID_COLUMN, &id_a, -1);
- gtk_tree_model_get (model, b, ID_COLUMN, &id_b, -1);
+ gtk_tree_model_get (model, a, NAME_COLUMN, &name_a, -1);
+ gtk_tree_model_get (model, b, NAME_COLUMN, &name_b, -1);
+ gtk_tree_model_get (model, a, ID_COLUMN, &id_a, -1);
+ gtk_tree_model_get (model, b, ID_COLUMN, &id_b, -1);
- result = compare_theme_names (name_a, name_b, id_a, id_b);
+ result = compare_theme_names (name_a, name_b, id_a, id_b);
- g_free (name_a);
- g_free (name_b);
- g_free (id_a);
- g_free (id_b);
+ g_free (name_a);
+ g_free (name_b);
+ g_free (id_a);
+ g_free (id_b);
- return result;
+ return result;
}
static gboolean
@@ -643,164 +647,166 @@ separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- int column = GPOINTER_TO_INT (data);
- char *text;
+ int column = GPOINTER_TO_INT (data);
+ char *text;
- gtk_tree_model_get (model, iter, column, &text, -1);
+ gtk_tree_model_get (model, iter, column, &text, -1);
- if (text != NULL && strcmp (text, "__separator") == 0)
- {
- return TRUE;
- }
+ if (text != NULL && strcmp (text, "__separator") == 0)
+ {
+ return TRUE;
+ }
- g_free (text);
+ g_free (text);
- return FALSE;
+ return FALSE;
}
static void
setup_treeview (GtkWidget *tree,
GtkWidget *preview)
{
- GtkTreeStore *store;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeSelection *select;
-
- store = gtk_tree_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_STRING);
- populate_model (store);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (tree),
- GTK_TREE_MODEL (store));
-
- g_object_unref (store);
-
- g_object_set (tree, "show-expanders", FALSE, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Name", renderer,
- "text", NAME_COLUMN,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-
- gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN);
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
- NAME_COLUMN,
- compare_theme,
- NULL, NULL);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
- NAME_COLUMN,
- GTK_SORT_ASCENDING);
-
- gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (tree),
- separator_func,
- GINT_TO_POINTER (ID_COLUMN),
- NULL);
-
- select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
- gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
- g_signal_connect (G_OBJECT (select), "changed",
- G_CALLBACK (tree_selection_changed_cb),
- preview);
+ GtkTreeStore *store;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *select;
+
+ store = gtk_tree_store_new (N_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+ populate_model (store);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (tree),
+ GTK_TREE_MODEL (store));
+
+ g_object_unref (store);
+
+ g_object_set (tree, "show-expanders", FALSE, NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Name", renderer,
+ "text", NAME_COLUMN,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+ gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN);
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+ NAME_COLUMN,
+ compare_theme,
+ NULL, NULL);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ NAME_COLUMN,
+ GTK_SORT_ASCENDING);
+
+ gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (tree),
+ separator_func,
+ GINT_TO_POINTER (ID_COLUMN),
+ NULL);
+
+ select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
+ g_signal_connect (G_OBJECT (select), "changed",
+ G_CALLBACK (tree_selection_changed_cb),
+ preview);
}
static void
setup_treeview_selection (GtkWidget *tree)
{
- char *theme;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path = NULL;
- gboolean is_writable;
-
- theme = config_get_theme (&is_writable);
-
- if (! is_writable)
- {
- gtk_widget_set_sensitive (tree, FALSE);
- }
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
-
- if (theme && gtk_tree_model_get_iter_first (model, &iter))
- {
-
- do
- {
- char *id;
- gboolean found;
-
- gtk_tree_model_get (model, &iter,
- ID_COLUMN, &id, -1);
- found = (id && strcmp (id, theme) == 0);
- g_free (id);
-
- if (found)
- {
- path = gtk_tree_model_get_path (model, &iter);
- break;
- }
-
- }
- while (gtk_tree_model_iter_next (model, &iter));
- }
-
- if (path)
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree),
- path,
- NULL,
- FALSE);
-
- gtk_tree_path_free (path);
- }
-
- g_free (theme);
+ char *theme;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path = NULL;
+ gboolean is_writable;
+
+ theme = config_get_theme (&is_writable);
+
+ if (! is_writable)
+ {
+ gtk_widget_set_sensitive (tree, FALSE);
+ }
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+ if (theme && gtk_tree_model_get_iter_first (model, &iter))
+ {
+
+ do
+ {
+ char *id;
+ gboolean found;
+
+ gtk_tree_model_get (model, &iter,
+ ID_COLUMN, &id, -1);
+ found = (id && strcmp (id, theme) == 0);
+ g_free (id);
+
+ if (found)
+ {
+ path = gtk_tree_model_get_path (model, &iter);
+ break;
+ }
+
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
+ }
+
+ if (path)
+ {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree),
+ path,
+ NULL,
+ FALSE);
+
+ gtk_tree_path_free (path);
+ }
+
+ g_free (theme);
}
static void
reload_themes (void)
{
- GtkWidget *treeview;
- GtkTreeModel *model;
+ GtkWidget *treeview;
+ GtkTreeModel *model;
- treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- gtk_tree_store_clear (GTK_TREE_STORE (model));
- populate_model (GTK_TREE_STORE (model));
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
+ gtk_tree_store_clear (GTK_TREE_STORE (model));
+ populate_model (GTK_TREE_STORE (model));
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
- GTK_TREE_MODEL (model));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+ GTK_TREE_MODEL (model));
}
static void
-theme_copy_complete_cb (GtkWidget *dialog, gpointer user_data)
+theme_copy_complete_cb (GtkWidget *dialog,
+ gpointer user_data)
{
- reload_themes ();
- gtk_widget_destroy (dialog);
+ reload_themes ();
+ gtk_widget_destroy (dialog);
}
static void
-theme_installer_run (GtkWidget *prefs_dialog, GList *files)
+theme_installer_run (GtkWidget *prefs_dialog,
+ GList *files)
{
- GtkWidget *copy_dialog;
+ GtkWidget *copy_dialog;
- copy_dialog = copy_theme_dialog_new (files);
- g_list_foreach (files, (GFunc) (g_object_unref), NULL);
- g_list_free (files);
+ copy_dialog = copy_theme_dialog_new (files);
+ g_list_foreach (files, (GFunc) (g_object_unref), NULL);
+ g_list_free (files);
- gtk_window_set_transient_for (GTK_WINDOW (copy_dialog),
- GTK_WINDOW (prefs_dialog));
- gtk_window_set_icon_name (GTK_WINDOW (copy_dialog),
- "preferences-desktop-screensaver");
+ gtk_window_set_transient_for (GTK_WINDOW (copy_dialog),
+ GTK_WINDOW (prefs_dialog));
+ gtk_window_set_icon_name (GTK_WINDOW (copy_dialog),
+ "preferences-desktop-screensaver");
- g_signal_connect (copy_dialog, "complete",
- G_CALLBACK (theme_copy_complete_cb), NULL);
+ g_signal_connect (copy_dialog, "complete",
+ G_CALLBACK (theme_copy_complete_cb), NULL);
- copy_theme_dialog_begin (COPY_THEME_DIALOG (copy_dialog));
+ copy_theme_dialog_begin (COPY_THEME_DIALOG (copy_dialog));
}
/* Callback issued during drag movements */
@@ -812,7 +818,7 @@ drag_motion_cb (GtkWidget *widget,
guint time,
gpointer data)
{
- return FALSE;
+ return FALSE;
}
/* Callback issued during drag leaves */
@@ -822,7 +828,7 @@ drag_leave_cb (GtkWidget *widget,
guint time,
gpointer data)
{
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
}
/* GIO has no version of xfce_vfs_uri_list_parse(), so copy from XfceVFS
@@ -831,58 +837,58 @@ drag_leave_cb (GtkWidget *widget,
static GList *
uri_list_parse (const gchar *uri_list)
{
- const gchar *p, *q;
- gchar *retval;
- GFile *file;
- GList *result = NULL;
-
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- p = uri_list;
-
- /* We don't actually try to validate the URI according to RFC
- * 2396, or even check for allowed characters - we just ignore
- * comments and trim whitespace off the ends. We also
- * allow LF delimination as well as the specified CRLF.
- */
- while (p != NULL)
- {
- if (*p != '#')
- {
- while (g_ascii_isspace (*p))
- p++;
-
- q = p;
- while ((*q != '\0')
- && (*q != '\n')
- && (*q != '\r'))
- q++;
-
- if (q > p)
- {
- q--;
- while (q > p
- && g_ascii_isspace (*q))
- q--;
-
- retval = g_malloc (q - p + 2);
- strncpy (retval, p, q - p + 1);
- retval[q - p + 1] = '\0';
-
- file = g_file_new_for_uri (retval);
-
- g_free (retval);
-
- if (file != NULL)
- result = g_list_prepend (result, file);
- }
- }
- p = strchr (p, '\n');
- if (p != NULL)
- p++;
- }
-
- return g_list_reverse (result);
+ const gchar *p, *q;
+ gchar *retval;
+ GFile *file;
+ GList *result = NULL;
+
+ g_return_val_if_fail (uri_list != NULL, NULL);
+
+ p = uri_list;
+
+ /* We don't actually try to validate the URI according to RFC
+ * 2396, or even check for allowed characters - we just ignore
+ * comments and trim whitespace off the ends. We also
+ * allow LF delimination as well as the specified CRLF.
+ */
+ while (p != NULL)
+ {
+ if (*p != '#')
+ {
+ while (g_ascii_isspace (*p))
+ p++;
+
+ q = p;
+ while ((*q != '\0')
+ && (*q != '\n')
+ && (*q != '\r'))
+ q++;
+
+ if (q > p)
+ {
+ q--;
+ while (q > p
+ && g_ascii_isspace (*q))
+ q--;
+
+ retval = g_malloc (q - p + 2);
+ strncpy (retval, p, q - p + 1);
+ retval[q - p + 1] = '\0';
+
+ file = g_file_new_for_uri (retval);
+
+ g_free (retval);
+
+ if (file != NULL)
+ result = g_list_prepend (result, file);
+ }
+ }
+ p = strchr (p, '\n');
+ if (p != NULL)
+ p++;
+ }
+
+ return g_list_reverse (result);
}
/* Callback issued on actual drops. Attempts to load the file dropped. */
@@ -896,279 +902,278 @@ drag_data_received_cb (GtkWidget *widget,
guint time,
gpointer data)
{
- GList *files;
+ GList *files;
- if (!(info == TARGET_URI_LIST || info == TARGET_NS_URL))
- return;
+ if (!(info == TARGET_URI_LIST || info == TARGET_NS_URL))
+ return;
- files = uri_list_parse ((char *) gtk_selection_data_get_data (selection_data));
- if (files != NULL)
- {
- GtkWidget *prefs_dialog;
+ files = uri_list_parse ((char *) gtk_selection_data_get_data (selection_data));
+ if (files != NULL)
+ {
+ GtkWidget *prefs_dialog;
- prefs_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
- theme_installer_run (prefs_dialog, files);
- }
+ prefs_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
+ theme_installer_run (prefs_dialog, files);
+ }
}
/* Adapted from totem_time_to_string_text */
static char *
time_to_string_text (long time)
{
- char *secs, *mins, *hours, *string;
- int sec, min, hour;
-
- int n, inc_len, len_minutes;
-
- sec = time % 60;
- time = time - sec;
- min = (time % (60 * 60)) / 60;
- time = time - (min * 60);
- hour = time / (60 * 60);
-
- hours = g_strdup_printf (ngettext ("%d hour",
- "%d hours", hour), hour);
-
- mins = g_strdup_printf (ngettext ("%d minute",
- "%d minutes", min), min);
-
- secs = g_strdup_printf (ngettext ("%d second",
- "%d seconds", sec), sec);
-
- inc_len = strlen (g_strdup_printf (_("%s %s"),
- g_strdup_printf (ngettext ("%d hour",
- "%d hours", 1), 1),
- g_strdup_printf (ngettext ("%d minute",
- "%d minutes", 59), 59))) - 1;
-
- len_minutes = 0;
-
- for (n = 2; n < 60; n++)
- {
- if (n < 10)
- {
- if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
- "%d minutes", n), n), NULL)) - 2) > len_minutes)
-
- len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
- "%d minutes", n), n), NULL)) - 2;
- }
- else
- {
- if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
- "%d minutes", n), n), NULL)) - 3) > len_minutes)
-
- len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
- "%d minutes", n), n), NULL)) - 3;
- }
- }
-
- if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
- "%d minutes", 1), 1), NULL)) - 2) > len_minutes)
-
- len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
- "%d minutes", 1), 1), NULL)) - 2;
-
- if (len_minutes < 1)
- len_minutes = 1;
-
- if (hour > 0)
- {
- if (sec > 0)
- {
- /* hour:minutes:seconds */
- string = g_strdup_printf (_("%s %s %s"), hours, mins, secs);
- }
- else if (min > 0)
- {
- /* hour:minutes */
- string = g_strdup_printf (_("%s %s"), hours, mins);
- }
- else
- {
- /* hour */
- string = g_strdup_printf (_("%s"), hours);
- }
- }
- else if (min > 0)
- {
- if (sec > 0)
- {
- /* minutes:seconds */
- string = g_strdup_printf (_("%s %s"), mins, secs);
- }
- else
- {
- /* minutes */
- string = g_strdup_printf (_("%s"), mins);
-
- if (min < 10)
- {
- if (min == 1)
- while (strlen (string) != (len_minutes + inc_len + 3))
- {
- if (strlen (string) % 2 == 0)
- string = g_strconcat (string, " ", NULL);
- else
- string = g_strconcat (" " , string, NULL);
- }
- else
- while (strlen (string) != (len_minutes + inc_len))
- {
- if (strlen (string) % 2 == 0)
- string = g_strconcat (string, " ", NULL);
- else
- string = g_strconcat (" " , string, NULL);
- }
- }
- else
- {
- while (strlen (string) != (len_minutes + inc_len - 1))
- {
- if (strlen (string) % 2 == 0)
- string = g_strconcat (string, " ", NULL);
- else
- string = g_strconcat (" " , string, NULL);
- }
- }
- }
- }
- else
- {
- /* seconds */
- string = g_strdup_printf (_("%s"), secs);
- }
-
- g_free (hours);
- g_free (mins);
- g_free (secs);
-
- return string;
+ char *secs, *mins, *hours, *string;
+ int sec, min, hour;
+ int n, inc_len, len_minutes;
+
+ sec = time % 60;
+ time = time - sec;
+ min = (time % (60 * 60)) / 60;
+ time = time - (min * 60);
+ hour = time / (60 * 60);
+
+ hours = g_strdup_printf (ngettext ("%d hour",
+ "%d hours", hour), hour);
+
+ mins = g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", min), min);
+
+ secs = g_strdup_printf (ngettext ("%d second",
+ "%d seconds", sec), sec);
+
+ inc_len = strlen (g_strdup_printf (_("%s %s"),
+ g_strdup_printf (ngettext ("%d hour",
+ "%d hours", 1), 1),
+ g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", 59), 59))) - 1;
+
+ len_minutes = 0;
+
+ for (n = 2; n < 60; n++)
+ {
+ if (n < 10)
+ {
+ if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", n), n), NULL)) - 2) > len_minutes)
+
+ len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", n), n), NULL)) - 2;
+ }
+ else
+ {
+ if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", n), n), NULL)) - 3) > len_minutes)
+
+ len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", n), n), NULL)) - 3;
+ }
+ }
+
+ if ((strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", 1), 1), NULL)) - 2) > len_minutes)
+
+ len_minutes = strlen (g_str_to_ascii (g_strdup_printf (ngettext ("%d minute",
+ "%d minutes", 1), 1), NULL)) - 2;
+
+ if (len_minutes < 1)
+ len_minutes = 1;
+
+ if (hour > 0)
+ {
+ if (sec > 0)
+ {
+ /* hour:minutes:seconds */
+ string = g_strdup_printf (_("%s %s %s"), hours, mins, secs);
+ }
+ else if (min > 0)
+ {
+ /* hour:minutes */
+ string = g_strdup_printf (_("%s %s"), hours, mins);
+ }
+ else
+ {
+ /* hour */
+ string = g_strdup_printf (_("%s"), hours);
+ }
+ }
+ else if (min > 0)
+ {
+ if (sec > 0)
+ {
+ /* minutes:seconds */
+ string = g_strdup_printf (_("%s %s"), mins, secs);
+ }
+ else
+ {
+ /* minutes */
+ string = g_strdup_printf (_("%s"), mins);
+
+ if (min < 10)
+ {
+ if (min == 1)
+ while (strlen (string) != (len_minutes + inc_len + 3))
+ {
+ if (strlen (string) % 2 == 0)
+ string = g_strconcat (string, " ", NULL);
+ else
+ string = g_strconcat (" " , string, NULL);
+ }
+ else
+ while (strlen (string) != (len_minutes + inc_len))
+ {
+ if (strlen (string) % 2 == 0)
+ string = g_strconcat (string, " ", NULL);
+ else
+ string = g_strconcat (" " , string, NULL);
+ }
+ }
+ else
+ {
+ while (strlen (string) != (len_minutes + inc_len - 1))
+ {
+ if (strlen (string) % 2 == 0)
+ string = g_strconcat (string, " ", NULL);
+ else
+ string = g_strconcat (" " , string, NULL);
+ }
+ }
+ }
+ }
+ else
+ {
+ /* seconds */
+ string = g_strdup_printf (_("%s"), secs);
+ }
+
+ g_free (hours);
+ g_free (mins);
+ g_free (secs);
+
+ return string;
}
static char *
format_value_callback_time (GtkScale *scale,
gdouble value)
{
- if (value == 0)
- return g_strdup_printf (_("Never"));
+ if (value == 0)
+ return g_strdup_printf (_("Never"));
- return time_to_string_text (value * 60.0);
+ return time_to_string_text (value * 60.0);
}
static void
lock_checkbox_toggled (GtkToggleButton *button, gpointer user_data)
{
- config_set_lock (gtk_toggle_button_get_active (button));
+ config_set_lock (gtk_toggle_button_get_active (button));
}
static void
enabled_checkbox_toggled (GtkToggleButton *button, gpointer user_data)
{
- config_set_enabled (gtk_toggle_button_get_active (button));
+ config_set_enabled (gtk_toggle_button_get_active (button));
}
static void
ui_set_lock (gboolean enabled)
{
- GtkWidget *widget;
- gboolean active;
+ GtkWidget *widget;
+ gboolean active;
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
- if (active != enabled)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), enabled);
- }
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ if (active != enabled)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), enabled);
+ }
}
static void
ui_set_enabled (gboolean enabled)
{
- GtkWidget *widget;
- gboolean active;
- gboolean is_writable;
-
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox"));
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
- if (active != enabled)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), enabled);
- }
-
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
- config_get_lock (&is_writable);
- if (is_writable)
- {
- gtk_widget_set_sensitive (widget, enabled);
- }
+ GtkWidget *widget;
+ gboolean active;
+ gboolean is_writable;
+
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox"));
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ if (active != enabled)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), enabled);
+ }
+
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
+ config_get_lock (&is_writable);
+ if (is_writable)
+ {
+ gtk_widget_set_sensitive (widget, enabled);
+ }
}
static void
ui_set_delay (int delay)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale"));
- gtk_range_set_value (GTK_RANGE (widget), delay);
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale"));
+ gtk_range_set_value (GTK_RANGE (widget), delay);
}
static void
key_changed_cb (XfconfChannel *channel, const gchar *key, gpointer data)
{
- if (strcmp (key, KEY_IDLE_ACTIVATION_ENABLED) == 0)
- {
- gboolean enabled;
- enabled = xfconf_channel_get_bool (channel, key, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
- ui_set_enabled (enabled);
- }
- else if (strcmp (key, KEY_LOCK_ENABLED) == 0)
- {
- gboolean enabled;
- enabled = xfconf_channel_get_bool (channel, key, DEFAULT_KEY_LOCK_ENABLED);
- ui_set_lock (enabled);
- }
- else if (strcmp (key, KEY_THEMES) == 0)
- {
- GtkWidget *treeview;
- treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
- setup_treeview_selection (treeview);
- }
- else if (strcmp (key, KEY_IDLE_DELAY) == 0)
- {
- int delay;
- delay = xfconf_channel_get_int (channel, key, DEFAULT_KEY_IDLE_DELAY);
- ui_set_delay (delay);
- }
- else
- {
- /*g_warning ("Config key not handled: %s", key);*/
- }
+ if (strcmp (key, KEY_IDLE_ACTIVATION_ENABLED) == 0)
+ {
+ gboolean enabled;
+ enabled = xfconf_channel_get_bool (channel, key, DEFAULT_KEY_IDLE_ACTIVATION_ENABLED);
+ ui_set_enabled (enabled);
+ }
+ else if (strcmp (key, KEY_LOCK_ENABLED) == 0)
+ {
+ gboolean enabled;
+ enabled = xfconf_channel_get_bool (channel, key, DEFAULT_KEY_LOCK_ENABLED);
+ ui_set_lock (enabled);
+ }
+ else if (strcmp (key, KEY_THEMES) == 0)
+ {
+ GtkWidget *treeview;
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ setup_treeview_selection (treeview);
+ }
+ else if (strcmp (key, KEY_IDLE_DELAY) == 0)
+ {
+ int delay;
+ delay = xfconf_channel_get_int (channel, key, DEFAULT_KEY_IDLE_DELAY);
+ ui_set_delay (delay);
+ }
+ else
+ {
+ /*g_warning ("Config key not handled: %s", key);*/
+ }
}
static void
fullscreen_preview_previous_cb (GtkWidget *fullscreen_preview_window,
gpointer user_data)
{
- GtkWidget *treeview;
- GtkTreeSelection *selection;
+ GtkWidget *treeview;
+ GtkTreeSelection *selection;
- treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- tree_selection_previous (selection);
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ tree_selection_previous (selection);
}
static void
fullscreen_preview_next_cb (GtkWidget *fullscreen_preview_window,
gpointer user_data)
{
- GtkWidget *treeview;
- GtkTreeSelection *selection;
+ GtkWidget *treeview;
+ GtkTreeSelection *selection;
- treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- tree_selection_next (selection);
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ tree_selection_next (selection);
}
static void
@@ -1176,47 +1181,47 @@ fullscreen_preview_cancelled_cb (GtkWidget *button,
gpointer user_data)
{
- GtkWidget *fullscreen_preview_area;
- GtkWidget *fullscreen_preview_window;
- GtkWidget *preview_area;
- GtkWidget *dialog;
+ GtkWidget *fullscreen_preview_area;
+ GtkWidget *fullscreen_preview_window;
+ GtkWidget *preview_area;
+ GtkWidget *dialog;
- preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area"));
- gs_job_set_widget (job, preview_area);
+ preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area"));
+ gs_job_set_widget (job, preview_area);
- fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
- gtk_widget_queue_draw (fullscreen_preview_area);
+ fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
+ gtk_widget_queue_draw (fullscreen_preview_area);
- fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
- gtk_widget_hide (fullscreen_preview_window);
+ fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
+ gtk_widget_hide (fullscreen_preview_window);
- dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
- gtk_widget_show (dialog);
- gtk_window_present (GTK_WINDOW (dialog));
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
+ gtk_widget_show (dialog);
+ gtk_window_present (GTK_WINDOW (dialog));
}
static void
fullscreen_preview_start_cb (GtkWidget *widget,
gpointer user_data)
{
- GtkWidget *fullscreen_preview_area;
- GtkWidget *fullscreen_preview_window;
- GtkWidget *dialog;
+ GtkWidget *fullscreen_preview_area;
+ GtkWidget *fullscreen_preview_window;
+ GtkWidget *dialog;
- dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
- gtk_widget_hide (dialog);
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
+ gtk_widget_hide (dialog);
- fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
+ fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
- gtk_window_fullscreen (GTK_WINDOW (fullscreen_preview_window));
- gtk_window_set_keep_above (GTK_WINDOW (fullscreen_preview_window), TRUE);
+ gtk_window_fullscreen (GTK_WINDOW (fullscreen_preview_window));
+ gtk_window_set_keep_above (GTK_WINDOW (fullscreen_preview_window), TRUE);
- gtk_widget_show (fullscreen_preview_window);
- gtk_widget_grab_focus (fullscreen_preview_window);
+ gtk_widget_show (fullscreen_preview_window);
+ gtk_widget_grab_focus (fullscreen_preview_window);
- fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
- gtk_widget_queue_draw (fullscreen_preview_area);
- gs_job_set_widget (job, fullscreen_preview_area);
+ fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
+ gtk_widget_queue_draw (fullscreen_preview_area);
+ gs_job_set_widget (job, fullscreen_preview_area);
}
static void
@@ -1224,101 +1229,101 @@ constrain_list_size (GtkWidget *widget,
GtkAllocation *allocation,
GtkWidget *to_size)
{
- GtkRequisition req;
- int max_height;
+ GtkRequisition req;
+ int max_height;
- /* constrain height to be the tree height up to a max */
- max_height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (widget)))) / 4;
+ /* constrain height to be the tree height up to a max */
+ max_height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (widget)))) / 4;
- gtk_widget_get_preferred_size (to_size, &req, NULL);
- allocation->height = MIN (req.height, max_height);
+ gtk_widget_get_preferred_size (to_size, &req, NULL);
+ allocation->height = MIN (req.height, max_height);
}
static void
setup_list_size_constraint (GtkWidget *widget,
GtkWidget *to_size)
{
- g_signal_connect (widget, "size-allocate",
- G_CALLBACK (constrain_list_size), to_size);
+ g_signal_connect (widget, "size-allocate",
+ G_CALLBACK (constrain_list_size), to_size);
}
static gboolean
check_is_root_user (void)
{
#ifndef G_OS_WIN32
- uid_t ruid, euid, suid; /* Real, effective and saved user ID's */
- gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */
+ uid_t ruid, euid, suid; /* Real, effective and saved user ID's */
+ gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */
#ifdef HAVE_GETRESUID
- if (getresuid (&ruid, &euid, &suid) != 0 ||
- getresgid (&rgid, &egid, &sgid) != 0)
+ if (getresuid (&ruid, &euid, &suid) != 0 ||
+ getresgid (&rgid, &egid, &sgid) != 0)
#endif /* HAVE_GETRESUID */
- {
- suid = ruid = getuid ();
- sgid = rgid = getgid ();
- euid = geteuid ();
- egid = getegid ();
- }
-
- if (ruid == 0)
- {
- return TRUE;
- }
+ {
+ suid = ruid = getuid ();
+ sgid = rgid = getgid ();
+ euid = geteuid ();
+ egid = getegid ();
+ }
+
+ if (ruid == 0)
+ {
+ return TRUE;
+ }
#endif
- return FALSE;
+ return FALSE;
}
static void
setup_for_root_user (void)
{
- GtkWidget *lock_checkbox;
- GtkWidget *label;
+ GtkWidget *lock_checkbox;
+ GtkWidget *label;
- lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
- label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label"));
+ lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
+ label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), FALSE);
- gtk_widget_set_sensitive (lock_checkbox, FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), FALSE);
+ gtk_widget_set_sensitive (lock_checkbox, FALSE);
- gtk_widget_show (label);
+ gtk_widget_show (label);
}
/* copied from gs-window-x11.c */
extern char **environ;
static gchar **
-spawn_make_environment_for_display (GdkDisplay *display,
- gchar **envp)
+spawn_make_environment_for_display (GdkDisplay *display,
+ gchar **envp)
{
- gchar **retval = NULL;
- const gchar *display_name;
- gint display_index = -1;
- gint i, env_len;
+ gchar **retval = NULL;
+ const gchar *display_name;
+ gint display_index = -1;
+ gint i, env_len;
- g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- if (envp == NULL)
- envp = environ;
+ if (envp == NULL)
+ envp = environ;
- for (env_len = 0; envp[env_len]; env_len++)
- if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
- display_index = env_len;
+ for (env_len = 0; envp[env_len]; env_len++)
+ if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
+ display_index = env_len;
- retval = g_new (char *, env_len + 1);
- retval[env_len] = NULL;
+ retval = g_new (char *, env_len + 1);
+ retval[env_len] = NULL;
- display_name = gdk_display_get_name (display);
+ display_name = gdk_display_get_name (display);
- for (i = 0; i < env_len; i++)
- if (i == display_index)
- retval[i] = g_strconcat ("DISPLAY=", display_name, NULL);
- else
- retval[i] = g_strdup (envp[i]);
+ for (i = 0; i < env_len; i++)
+ if (i == display_index)
+ retval[i] = g_strconcat ("DISPLAY=", display_name, NULL);
+ else
+ retval[i] = g_strdup (envp[i]);
- g_assert (i == env_len);
+ g_assert (i == env_len);
- return retval;
+ return retval;
}
static gboolean
@@ -1329,358 +1334,358 @@ spawn_command_line_on_display_sync (GdkDisplay *display,
int *exit_status,
GError **error)
{
- char **argv = NULL;
- char **envp = NULL;
- gboolean retval;
-
- g_return_val_if_fail (command_line != NULL, FALSE);
-
- if (! g_shell_parse_argv (command_line, NULL, &argv, error))
- {
- return FALSE;
- }
-
- envp = spawn_make_environment_for_display (display, NULL);
-
- retval = g_spawn_sync (NULL,
- argv,
- envp,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- standard_output,
- standard_error,
- exit_status,
- error);
-
- g_strfreev (argv);
- g_strfreev (envp);
-
- return retval;
+ char **argv = NULL;
+ char **envp = NULL;
+ gboolean retval;
+
+ g_return_val_if_fail (command_line != NULL, FALSE);
+
+ if (! g_shell_parse_argv (command_line, NULL, &argv, error))
+ {
+ return FALSE;
+ }
+
+ envp = spawn_make_environment_for_display (display, NULL);
+
+ retval = g_spawn_sync (NULL,
+ argv,
+ envp,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ standard_output,
+ standard_error,
+ exit_status,
+ error);
+
+ g_strfreev (argv);
+ g_strfreev (envp);
+
+ return retval;
}
static GdkVisual *
get_best_visual_for_display (GdkDisplay *display)
{
- GdkScreen *screen;
- char *command;
- char *std_output;
- int exit_status;
- GError *error;
- unsigned long v;
- char c;
- GdkVisual *visual;
- gboolean res;
-
- visual = NULL;
- screen = gdk_display_get_default_screen (display);
-
- command = g_build_filename (LIBEXECDIR, "xfce4-screensaver-gl-helper", NULL);
-
- error = NULL;
- std_output = NULL;
- res = spawn_command_line_on_display_sync (display,
- command,
- &std_output,
- NULL,
- &exit_status,
- &error);
- if (! res)
- {
- gs_debug ("Could not run command '%s': %s", command, error->message);
- g_error_free (error);
- goto out;
- }
-
- if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
- {
- if (v != 0)
- {
- VisualID visual_id;
-
- visual_id = (VisualID) v;
- visual = gdk_x11_screen_lookup_visual (screen, visual_id);
-
- gs_debug ("Found best GL visual for display %s: 0x%x",
- gdk_display_get_name (display),
- (unsigned int) visual_id);
- }
- }
+ GdkScreen *screen;
+ char *command;
+ char *std_output;
+ int exit_status;
+ GError *error;
+ unsigned long v;
+ char c;
+ GdkVisual *visual;
+ gboolean res;
+
+ visual = NULL;
+ screen = gdk_display_get_default_screen (display);
+
+ command = g_build_filename (LIBEXECDIR, "xfce4-screensaver-gl-helper", NULL);
+
+ error = NULL;
+ std_output = NULL;
+ res = spawn_command_line_on_display_sync (display,
+ command,
+ &std_output,
+ NULL,
+ &exit_status,
+ &error);
+ if (! res)
+ {
+ gs_debug ("Could not run command '%s': %s", command, error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
+ {
+ if (v != 0)
+ {
+ VisualID visual_id;
+
+ visual_id = (VisualID) v;
+ visual = gdk_x11_screen_lookup_visual (screen, visual_id);
+
+ gs_debug ("Found best GL visual for display %s: 0x%x",
+ gdk_display_get_name (display),
+ (unsigned int) visual_id);
+ }
+ }
out:
- g_free (std_output);
- g_free (command);
+ g_free (std_output);
+ g_free (command);
- return visual;
+ return visual;
}
static void
widget_set_best_visual (GtkWidget *widget)
{
- GdkVisual *visual;
+ GdkVisual *visual;
- g_return_if_fail (widget != NULL);
+ g_return_if_fail (widget != NULL);
- visual = get_best_visual_for_display (gtk_widget_get_display (widget));
- if (visual != NULL)
- {
- gtk_widget_set_visual (widget, visual);
- g_object_unref (visual);
- }
+ visual = get_best_visual_for_display (gtk_widget_get_display (widget));
+ if (visual != NULL)
+ {
+ gtk_widget_set_visual (widget, visual);
+ g_object_unref (visual);
+ }
}
static gboolean
setup_treeview_idle (gpointer data)
{
- GtkWidget *preview;
- GtkWidget *treeview;
+ GtkWidget *preview;
+ GtkWidget *treeview;
- preview = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area"));
- treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ preview = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area"));
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
- setup_treeview (treeview, preview);
- setup_treeview_selection (treeview);
+ setup_treeview (treeview, preview);
+ setup_treeview_selection (treeview);
- return FALSE;
+ return FALSE;
}
static gboolean
is_program_in_path (const char *program)
{
- char *tmp = g_find_program_in_path (program);
- if (tmp != NULL)
- {
- g_free (tmp);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
+ char *tmp = g_find_program_in_path (program);
+ if (tmp != NULL)
+ {
+ g_free (tmp);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
static void
init_capplet (void)
{
- GtkWidget *dialog;
- GtkWidget *preview;
- GtkWidget *treeview;
- GtkWidget *list_scroller;
- GtkWidget *activate_delay_hscale;
- GtkWidget *activate_delay_hbox;
- GtkWidget *label;
- GtkWidget *enabled_checkbox;
- GtkWidget *lock_checkbox;
- GtkWidget *root_warning_label;
- GtkWidget *preview_button;
- GtkWidget *gpm_button;
- GtkWidget *fullscreen_preview_window;
- GtkWidget *fullscreen_preview_area;
- GtkWidget *fullscreen_preview_previous;
- GtkWidget *fullscreen_preview_next;
- GtkWidget *fullscreen_preview_close;
- char *gtk_builder_file;
- gdouble activate_delay;
- gboolean enabled;
- gboolean is_writable;
- GError *error=NULL;
- gint mode;
-
- gtk_builder_file = g_build_filename (GTKBUILDERDIR, GTK_BUILDER_FILE, NULL);
- builder = gtk_builder_new();
- if (!gtk_builder_add_from_file(builder, gtk_builder_file, &error))
- {
- g_warning("Couldn't load builder file: %s", error->message);
- g_error_free(error);
- }
- g_free (gtk_builder_file);
-
- if (builder == NULL)
- {
-
- dialog = gtk_message_dialog_new (NULL,
- 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Could not load the main interface"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Please make sure that the screensaver is properly installed"));
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- exit (1);
- }
-
- preview = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area"));
- dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
- treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
- list_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "themes_scrolled_window"));
- activate_delay_hscale = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale"));
- activate_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hbox"));
- enabled_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox"));
- lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
- root_warning_label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label"));
- preview_button = GTK_WIDGET (gtk_builder_get_object (builder, "preview_button"));
- gpm_button = GTK_WIDGET (gtk_builder_get_object (builder, "gpm_button"));
- fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
- fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
- fullscreen_preview_close = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_close"));
- fullscreen_preview_previous = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_previous_button"));
- fullscreen_preview_next = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_next_button"));
-
- label = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_label"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), activate_delay_hscale);
- label = GTK_WIDGET (gtk_builder_get_object (builder, "savers_label"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), treeview);
-
- gtk_widget_set_no_show_all (root_warning_label, TRUE);
- widget_set_best_visual (preview);
-
- if (! is_program_in_path (GPM_COMMAND))
- {
- gtk_widget_set_no_show_all (gpm_button, TRUE);
- gtk_widget_hide (gpm_button);
- }
-
- screensaver_channel = xfconf_channel_get(SETTINGS_XFCONF_CHANNEL);
- g_signal_connect (screensaver_channel,
- "property-changed",
- G_CALLBACK (key_changed_cb),
- NULL);
-
- activate_delay = config_get_activate_delay (&is_writable);
- ui_set_delay (activate_delay);
- if (! is_writable)
- {
- gtk_widget_set_sensitive (activate_delay_hbox, FALSE);
- }
- g_signal_connect (activate_delay_hscale, "format-value",
- G_CALLBACK (format_value_callback_time), NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), config_get_lock (&is_writable));
- if (! is_writable)
- {
- gtk_widget_set_sensitive (lock_checkbox, FALSE);
- }
- g_signal_connect (lock_checkbox, "toggled",
- G_CALLBACK (lock_checkbox_toggled), NULL);
-
- enabled = config_get_enabled (&is_writable);
- ui_set_enabled (enabled);
- if (! is_writable)
- {
- gtk_widget_set_sensitive (enabled_checkbox, FALSE);
- }
- g_signal_connect (enabled_checkbox, "toggled",
- G_CALLBACK (enabled_checkbox_toggled), NULL);
-
- setup_list_size_constraint (list_scroller, treeview);
- gtk_widget_set_size_request (preview, 480, 300);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver");
- gtk_window_set_icon_name (GTK_WINDOW (fullscreen_preview_window), "screensaver");
-
- g_signal_connect (fullscreen_preview_area,
- "draw", G_CALLBACK (preview_on_draw),
- NULL);
-
- gtk_drag_dest_set (dialog, GTK_DEST_DEFAULT_ALL,
- drop_types, G_N_ELEMENTS (drop_types),
- GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
-
- g_signal_connect (dialog, "drag-motion",
- G_CALLBACK (drag_motion_cb), NULL);
- g_signal_connect (dialog, "drag-leave",
- G_CALLBACK (drag_leave_cb), NULL);
- g_signal_connect (dialog, "drag-data-received",
- G_CALLBACK (drag_data_received_cb), NULL);
-
- gtk_widget_show_all (dialog);
-
- /* Update list of themes if using random screensaver */
- mode = xfconf_channel_get_int (screensaver_channel, KEY_MODE, DEFAULT_KEY_MODE);
- if (mode == GS_MODE_RANDOM) {
- gchar **list;
- list = get_all_theme_ids (theme_manager);
- g_warning("instance b");
- xfconf_channel_set_string_list (screensaver_channel, KEY_THEMES, (const gchar * const*) list);
- g_strfreev (list);
- }
-
- g_signal_connect (preview, "draw", G_CALLBACK (preview_on_draw), NULL);
- gs_job_set_widget (job, preview);
-
- if (check_is_root_user ())
- {
- setup_for_root_user ();
- }
-
- g_signal_connect (activate_delay_hscale, "value-changed",
- G_CALLBACK (activate_delay_value_changed_cb), NULL);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (response_cb), NULL);
-
- g_signal_connect (preview_button, "clicked",
- G_CALLBACK (fullscreen_preview_start_cb),
- treeview);
-
- g_signal_connect (fullscreen_preview_close, "clicked",
- G_CALLBACK (fullscreen_preview_cancelled_cb), NULL);
- g_signal_connect (fullscreen_preview_previous, "clicked",
- G_CALLBACK (fullscreen_preview_previous_cb), NULL);
- g_signal_connect (fullscreen_preview_next, "clicked",
- G_CALLBACK (fullscreen_preview_next_cb), NULL);
-
- g_idle_add ((GSourceFunc)setup_treeview_idle, NULL);
+ GtkWidget *dialog;
+ GtkWidget *preview;
+ GtkWidget *treeview;
+ GtkWidget *list_scroller;
+ GtkWidget *activate_delay_hscale;
+ GtkWidget *activate_delay_hbox;
+ GtkWidget *label;
+ GtkWidget *enabled_checkbox;
+ GtkWidget *lock_checkbox;
+ GtkWidget *root_warning_label;
+ GtkWidget *preview_button;
+ GtkWidget *gpm_button;
+ GtkWidget *fullscreen_preview_window;
+ GtkWidget *fullscreen_preview_area;
+ GtkWidget *fullscreen_preview_previous;
+ GtkWidget *fullscreen_preview_next;
+ GtkWidget *fullscreen_preview_close;
+ char *gtk_builder_file;
+ gdouble activate_delay;
+ gboolean enabled;
+ gboolean is_writable;
+ GError *error=NULL;
+ gint mode;
+
+ gtk_builder_file = g_build_filename (GTKBUILDERDIR, GTK_BUILDER_FILE, NULL);
+ builder = gtk_builder_new();
+ if (!gtk_builder_add_from_file(builder, gtk_builder_file, &error))
+ {
+ g_warning("Couldn't load builder file: %s", error->message);
+ g_error_free(error);
+ }
+ g_free (gtk_builder_file);
+
+ if (builder == NULL)
+ {
+
+ dialog = gtk_message_dialog_new (NULL,
+ 0, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not load the main interface"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Please make sure that the screensaver is properly installed"));
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ exit (1);
+ }
+
+ preview = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area"));
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog"));
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ list_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "themes_scrolled_window"));
+ activate_delay_hscale = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale"));
+ activate_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hbox"));
+ enabled_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox"));
+ lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox"));
+ root_warning_label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label"));
+ preview_button = GTK_WIDGET (gtk_builder_get_object (builder, "preview_button"));
+ gpm_button = GTK_WIDGET (gtk_builder_get_object (builder, "gpm_button"));
+ fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
+ fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
+ fullscreen_preview_close = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_close"));
+ fullscreen_preview_previous = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_previous_button"));
+ fullscreen_preview_next = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_next_button"));
+
+ label = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_label"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), activate_delay_hscale);
+ label = GTK_WIDGET (gtk_builder_get_object (builder, "savers_label"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), treeview);
+
+ gtk_widget_set_no_show_all (root_warning_label, TRUE);
+ widget_set_best_visual (preview);
+
+ if (! is_program_in_path (GPM_COMMAND))
+ {
+ gtk_widget_set_no_show_all (gpm_button, TRUE);
+ gtk_widget_hide (gpm_button);
+ }
+
+ screensaver_channel = xfconf_channel_get(SETTINGS_XFCONF_CHANNEL);
+ g_signal_connect (screensaver_channel,
+ "property-changed",
+ G_CALLBACK (key_changed_cb),
+ NULL);
+
+ activate_delay = config_get_activate_delay (&is_writable);
+ ui_set_delay (activate_delay);
+ if (! is_writable)
+ {
+ gtk_widget_set_sensitive (activate_delay_hbox, FALSE);
+ }
+ g_signal_connect (activate_delay_hscale, "format-value",
+ G_CALLBACK (format_value_callback_time), NULL);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), config_get_lock (&is_writable));
+ if (! is_writable)
+ {
+ gtk_widget_set_sensitive (lock_checkbox, FALSE);
+ }
+ g_signal_connect (lock_checkbox, "toggled",
+ G_CALLBACK (lock_checkbox_toggled), NULL);
+
+ enabled = config_get_enabled (&is_writable);
+ ui_set_enabled (enabled);
+ if (! is_writable)
+ {
+ gtk_widget_set_sensitive (enabled_checkbox, FALSE);
+ }
+ g_signal_connect (enabled_checkbox, "toggled",
+ G_CALLBACK (enabled_checkbox_toggled), NULL);
+
+ setup_list_size_constraint (list_scroller, treeview);
+ gtk_widget_set_size_request (preview, 480, 300);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver");
+ gtk_window_set_icon_name (GTK_WINDOW (fullscreen_preview_window), "screensaver");
+
+ g_signal_connect (fullscreen_preview_area,
+ "draw", G_CALLBACK (preview_on_draw),
+ NULL);
+
+ gtk_drag_dest_set (dialog, GTK_DEST_DEFAULT_ALL,
+ drop_types, G_N_ELEMENTS (drop_types),
+ GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
+
+ g_signal_connect (dialog, "drag-motion",
+ G_CALLBACK (drag_motion_cb), NULL);
+ g_signal_connect (dialog, "drag-leave",
+ G_CALLBACK (drag_leave_cb), NULL);
+ g_signal_connect (dialog, "drag-data-received",
+ G_CALLBACK (drag_data_received_cb), NULL);
+
+ gtk_widget_show_all (dialog);
+
+ /* Update list of themes if using random screensaver */
+ mode = xfconf_channel_get_int (screensaver_channel, KEY_MODE, DEFAULT_KEY_MODE);
+ if (mode == GS_MODE_RANDOM) {
+ gchar **list;
+ list = get_all_theme_ids (theme_manager);
+ g_warning("instance b");
+ xfconf_channel_set_string_list (screensaver_channel, KEY_THEMES, (const gchar * const*) list);
+ g_strfreev (list);
+ }
+
+ g_signal_connect (preview, "draw", G_CALLBACK (preview_on_draw), NULL);
+ gs_job_set_widget (job, preview);
+
+ if (check_is_root_user ())
+ {
+ setup_for_root_user ();
+ }
+
+ g_signal_connect (activate_delay_hscale, "value-changed",
+ G_CALLBACK (activate_delay_value_changed_cb), NULL);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (response_cb), NULL);
+
+ g_signal_connect (preview_button, "clicked",
+ G_CALLBACK (fullscreen_preview_start_cb),
+ treeview);
+
+ g_signal_connect (fullscreen_preview_close, "clicked",
+ G_CALLBACK (fullscreen_preview_cancelled_cb), NULL);
+ g_signal_connect (fullscreen_preview_previous, "clicked",
+ G_CALLBACK (fullscreen_preview_previous_cb), NULL);
+ g_signal_connect (fullscreen_preview_next, "clicked",
+ G_CALLBACK (fullscreen_preview_next_cb), NULL);
+
+ g_idle_add ((GSourceFunc)setup_treeview_idle, NULL);
}
static void
finalize_capplet (void)
{
- g_object_unref (screensaver_channel);
+ g_object_unref (screensaver_channel);
}
int
main (int argc,
char **argv)
{
- GError *error = NULL;
+ GError *error = NULL;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- textdomain (GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
#endif
- gtk_init (&argc, &argv);
+ gtk_init (&argc, &argv);
- /* hook to make sure the libxfce4ui library is linked */
- if (xfce_titled_dialog_get_type() == 0)
- exit(1);
+ /* hook to make sure the libxfce4ui library is linked */
+ if (xfce_titled_dialog_get_type() == 0)
+ exit(1);
- if (!xfconf_init(&error))
- {
- g_error("Failed to connect to xfconf daemon: %s.", error->message);
- g_error_free(error);
+ if (!xfconf_init(&error))
+ {
+ g_error("Failed to connect to xfconf daemon: %s.", error->message);
+ g_error_free(error);
- return EXIT_FAILURE;
- }
+ return EXIT_FAILURE;
+ }
- job = gs_job_new ();
- theme_manager = gs_theme_manager_new ();
+ job = gs_job_new ();
+ theme_manager = gs_theme_manager_new ();
- init_capplet ();
+ init_capplet ();
- gtk_main ();
+ gtk_main ();
- finalize_capplet ();
+ finalize_capplet ();
- g_object_unref (theme_manager);
- g_object_unref (job);
+ g_object_unref (theme_manager);
+ g_object_unref (job);
- return 0;
+ return 0;
}
diff --git a/src/xfce4-screensaver.c b/src/xfce4-screensaver.c
index 3d0b7b9..02df553 100644
--- a/src/xfce4-screensaver.c
+++ b/src/xfce4-screensaver.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -41,97 +41,98 @@
void xfce4_screensaver_quit(void)
{
- gtk_main_quit();
+ gtk_main_quit();
}
-int main(int argc, char **argv)
+int main(int argc,
+ char **argv)
{
- GSMonitor* monitor;
- GError* error = NULL;
-
- static gboolean show_version = FALSE;
- static gboolean no_daemon = TRUE;
- static gboolean debug = FALSE;
-
- static GOptionEntry entries[] = {
- {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
- {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon"), NULL},
- {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL},
- {NULL}
- };
-
- #ifdef ENABLE_NLS
- bindtextdomain(GETTEXT_PACKAGE, XFCELOCALEDIR);
- #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- #endif
- textdomain(GETTEXT_PACKAGE);
- #endif
-
- if (!gtk_init_with_args(&argc, &argv, NULL, entries, NULL, &error))
- {
- if (error)
- {
- g_warning("%s", error->message);
- g_error_free(error);
- }
- else
- {
- g_warning("Unable to initialize GTK+");
- }
-
- exit(1);
- }
-
- if (show_version)
- {
- g_print("%s %s\n", argv[0], VERSION);
- exit(1);
- }
-
- if (!xfconf_init(&error))
- {
- g_error("Failed to connect to xfconf daemon: %s.", error->message);
- g_error_free(error);
-
- return EXIT_FAILURE;
- }
-
- /* debug to a file if in deamon mode */
- gs_debug_init(debug, FALSE);
- gs_debug("initializing xfce4-screensaver %s", VERSION);
-
- monitor = gs_monitor_new();
-
- if (monitor == NULL)
- {
- exit (1);
- }
-
- error = NULL;
-
- if (!gs_monitor_start(monitor, &error))
- {
- if (error)
- {
- g_warning("%s", error->message);
- g_error_free(error);
- }
- else
- {
- g_warning("Unable to start screensaver");
- }
-
- exit(1);
- }
-
- gtk_main();
-
- g_object_unref(monitor);
-
- gs_debug("xfce4-screensaver finished");
-
- gs_debug_shutdown();
-
- return 0;
+ GSMonitor *monitor;
+ GError *error = NULL;
+
+ static gboolean show_version = FALSE;
+ static gboolean no_daemon = TRUE;
+ static gboolean debug = FALSE;
+
+ static GOptionEntry entries[] = {
+ {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
+ {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon"), NULL},
+ {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL},
+ {NULL}
+ };
+
+ #ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, XFCELOCALEDIR);
+ #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ #endif
+ textdomain(GETTEXT_PACKAGE);
+ #endif
+
+ if (!gtk_init_with_args(&argc, &argv, NULL, entries, NULL, &error))
+ {
+ if (error)
+ {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ }
+ else
+ {
+ g_warning("Unable to initialize GTK+");
+ }
+
+ exit(1);
+ }
+
+ if (show_version)
+ {
+ g_print("%s %s\n", argv[0], VERSION);
+ exit(1);
+ }
+
+ if (!xfconf_init(&error))
+ {
+ g_error("Failed to connect to xfconf daemon: %s.", error->message);
+ g_error_free(error);
+
+ return EXIT_FAILURE;
+ }
+
+ /* debug to a file if in deamon mode */
+ gs_debug_init(debug, FALSE);
+ gs_debug("initializing xfce4-screensaver %s", VERSION);
+
+ monitor = gs_monitor_new();
+
+ if (monitor == NULL)
+ {
+ exit (1);
+ }
+
+ error = NULL;
+
+ if (!gs_monitor_start(monitor, &error))
+ {
+ if (error)
+ {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ }
+ else
+ {
+ g_warning("Unable to start screensaver");
+ }
+
+ exit(1);
+ }
+
+ gtk_main();
+
+ g_object_unref(monitor);
+
+ gs_debug("xfce4-screensaver finished");
+
+ gs_debug_shutdown();
+
+ return 0;
}
diff --git a/src/xfce4-screensaver.h b/src/xfce4-screensaver.h
index d0d9cbc..e6aa077 100644
--- a/src/xfce4-screensaver.h
+++ b/src/xfce4-screensaver.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
*
diff --git a/src/xfcekbd-config-private.h b/src/xfcekbd-config-private.h
index 12bd093..e5ce6b0 100644
--- a/src/xfcekbd-config-private.h
+++ b/src/xfcekbd-config-private.h
@@ -96,14 +96,12 @@
/**
* General config functions (private)
*/
-extern void xfcekbd_keyboard_config_model_set (XfcekbdKeyboardConfig *
- kbd_config,
- const gchar * model_name);
-
-extern void xfcekbd_keyboard_config_options_set (XfcekbdKeyboardConfig *
- kbd_config,
- gint idx,
- const gchar * group_name,
- const gchar * option_name);
+extern void xfcekbd_keyboard_config_model_set (XfcekbdKeyboardConfig *kbd_config,
+ const gchar *model_name);
+
+extern void xfcekbd_keyboard_config_options_set (XfcekbdKeyboardConfig *kbd_config,
+ gint idx,
+ const gchar *group_name,
+ const gchar *option_name);
#endif
diff --git a/src/xfcekbd-desktop-config.c b/src/xfcekbd-desktop-config.c
index 0109c93..c789899 100644
--- a/src/xfcekbd-desktop-config.c
+++ b/src/xfcekbd-desktop-config.c
@@ -36,165 +36,154 @@
*/
static gboolean
- xfcekbd_desktop_config_get_lv_descriptions
- (XfcekbdDesktopConfig * config,
- XklConfigRegistry * registry,
- const gchar ** layout_ids,
- const gchar ** variant_ids,
- gchar *** short_layout_descriptions,
- gchar *** long_layout_descriptions,
- gchar *** short_variant_descriptions,
- gchar *** long_variant_descriptions) {
- const gchar **pl, **pv;
- guint total_layouts;
- gchar **sld, **lld, **svd, **lvd;
- XklConfigItem *item = xkl_config_item_new ();
-
- if (!
- (xkl_engine_get_features (config->engine) &
- XKLF_MULTIPLE_LAYOUTS_SUPPORTED))
- return FALSE;
-
- pl = layout_ids;
- pv = variant_ids;
- total_layouts = g_strv_length ((char **) layout_ids);
- sld = *short_layout_descriptions =
- g_new0 (gchar *, total_layouts + 1);
- lld = *long_layout_descriptions =
- g_new0 (gchar *, total_layouts + 1);
- svd = *short_variant_descriptions =
- g_new0 (gchar *, total_layouts + 1);
- lvd = *long_variant_descriptions =
- g_new0 (gchar *, total_layouts + 1);
-
- while (pl != NULL && *pl != NULL) {
-
- xkl_debug (100, "ids: [%s][%s]\n", *pl,
- pv == NULL ? NULL : *pv);
-
- g_snprintf (item->name, sizeof item->name, "%s", *pl);
- if (xkl_config_registry_find_layout (registry, item)) {
- *sld = g_strdup (item->short_description);
- *lld = g_strdup (item->description);
- } else {
- *sld = g_strdup ("");
- *lld = g_strdup ("");
- }
-
- if (pv != NULL && *pv != NULL) {
- g_snprintf (item->name, sizeof item->name, "%s",
- *pv);
- if (xkl_config_registry_find_variant
- (registry, *pl, item)) {
- *svd = g_strdup (item->short_description);
- *lvd = g_strdup (item->description);
- } else {
- *svd = g_strdup ("");
- *lvd = g_strdup ("");
- }
- } else {
- *svd = g_strdup ("");
- *lvd = g_strdup ("");
- }
-
- xkl_debug (100, "description: [%s][%s][%s][%s]\n",
- *sld, *lld, *svd, *lvd);
- sld++;
- lld++;
- svd++;
- lvd++;
-
- pl++;
-
- if (pv != NULL && *pv != NULL)
- pv++;
- }
-
- g_object_unref (item);
- return TRUE;
+xfcekbd_desktop_config_get_lv_descriptions (XfcekbdDesktopConfig *config,
+ XklConfigRegistry *registry,
+ const gchar **layout_ids,
+ const gchar **variant_ids,
+ gchar ***short_layout_descriptions,
+ gchar ***long_layout_descriptions,
+ gchar ***short_variant_descriptions,
+ gchar ***long_variant_descriptions)
+{
+ const gchar **pl, **pv;
+ guint total_layouts;
+ gchar **sld, **lld, **svd, **lvd;
+ XklConfigItem *item = xkl_config_item_new ();
+
+ if (!(xkl_engine_get_features (config->engine) & XKLF_MULTIPLE_LAYOUTS_SUPPORTED))
+ return FALSE;
+
+ pl = layout_ids;
+ pv = variant_ids;
+ total_layouts = g_strv_length ((char **) layout_ids);
+ sld = *short_layout_descriptions = g_new0 (gchar *, total_layouts + 1);
+ lld = *long_layout_descriptions = g_new0 (gchar *, total_layouts + 1);
+ svd = *short_variant_descriptions = g_new0 (gchar *, total_layouts + 1);
+ lvd = *long_variant_descriptions = g_new0 (gchar *, total_layouts + 1);
+
+ while (pl != NULL && *pl != NULL) {
+
+ xkl_debug (100, "ids: [%s][%s]\n", *pl, pv == NULL ? NULL : *pv);
+
+ g_snprintf (item->name, sizeof item->name, "%s", *pl);
+ if (xkl_config_registry_find_layout (registry, item)) {
+ *sld = g_strdup (item->short_description);
+ *lld = g_strdup (item->description);
+ } else {
+ *sld = g_strdup ("");
+ *lld = g_strdup ("");
+ }
+
+ if (pv != NULL && *pv != NULL) {
+ g_snprintf (item->name, sizeof item->name, "%s", *pv);
+ if (xkl_config_registry_find_variant (registry, *pl, item)) {
+ *svd = g_strdup (item->short_description);
+ *lvd = g_strdup (item->description);
+ } else {
+ *svd = g_strdup ("");
+ *lvd = g_strdup ("");
+ }
+ } else {
+ *svd = g_strdup ("");
+ *lvd = g_strdup ("");
+ }
+
+ xkl_debug (100, "description: [%s][%s][%s][%s]\n", *sld, *lld, *svd, *lvd);
+ sld++;
+ lld++;
+ svd++;
+ lvd++;
+
+ pl++;
+
+ if (pv != NULL && *pv != NULL)
+ pv++;
+ }
+
+ g_object_unref (item);
+ return TRUE;
}
/*
* extern XfcekbdDesktopConfig config functions
*/
void
-xfcekbd_desktop_config_init (XfcekbdDesktopConfig * config,
- XklEngine * engine)
+xfcekbd_desktop_config_init (XfcekbdDesktopConfig *config,
+ XklEngine *engine)
{
- memset (config, 0, sizeof (*config));
- config->channel = xfconf_channel_get (SETTINGS_XFCONF_CHANNEL);
- config->engine = engine;
+ memset (config, 0, sizeof (*config));
+ config->channel = xfconf_channel_get (SETTINGS_XFCONF_CHANNEL);
+ config->engine = engine;
}
void
-xfcekbd_desktop_config_term (XfcekbdDesktopConfig * config)
+xfcekbd_desktop_config_term (XfcekbdDesktopConfig *config)
{
- g_object_unref (config->channel);
- config->channel = NULL;
+ g_object_unref (config->channel);
+ config->channel = NULL;
}
void
-xfcekbd_desktop_config_load_from_xfconf (XfcekbdDesktopConfig * config)
+xfcekbd_desktop_config_load_from_xfconf (XfcekbdDesktopConfig *config)
{
- config->group_per_app =
- xfconf_channel_get_bool(config->channel,
- KEY_KBD_GROUP_PER_WINDOW,
- DEFAULT_KEY_KBD_GROUP_PER_WINDOW);
- xkl_debug (150, "group_per_app: %d\n", config->group_per_app);
-
- config->handle_indicators =
- xfconf_channel_get_bool(config->channel,
- KEY_KBD_HANDLE_INDICATORS,
- DEFAULT_KEY_KBD_HANDLE_INDICATORS);
- xkl_debug (150, "handle_indicators: %d\n",
- config->handle_indicators);
-
- config->layout_names_as_group_names =
- xfconf_channel_get_bool(config->channel,
- KEY_KBD_LAYOUT_NAMES_AS_GROUP_NAMES,
- DEFAULT_KEY_KBD_LAYOUT_NAMES_AS_GROUP_NAMES);
- xkl_debug (150, "layout_names_as_group_names: %d\n",
- config->layout_names_as_group_names);
-
- config->load_extra_items =
- xfconf_channel_get_bool(config->channel,
- KEY_KBD_LOAD_EXTRA_ITEMS,
- DEFAULT_KEY_KBD_LOAD_EXTRA_ITEMS);
- xkl_debug (150, "load_extra_items: %d\n",
- config->load_extra_items);
-
- config->default_group =
- xfconf_channel_get_int(config->channel,
- KEY_KBD_DEFAULT_GROUP,
- DEFAULT_KEY_KBD_DEFAULT_GROUP);
-
- if (config->default_group < -1
- || config->default_group >=
- xkl_engine_get_max_num_groups (config->engine))
- config->default_group = -1;
- xkl_debug (150, "default_group: %d\n", config->default_group);
+ config->group_per_app =
+ xfconf_channel_get_bool(config->channel,
+ KEY_KBD_GROUP_PER_WINDOW,
+ DEFAULT_KEY_KBD_GROUP_PER_WINDOW);
+ xkl_debug (150, "group_per_app: %d\n", config->group_per_app);
+
+ config->handle_indicators =
+ xfconf_channel_get_bool(config->channel,
+ KEY_KBD_HANDLE_INDICATORS,
+ DEFAULT_KEY_KBD_HANDLE_INDICATORS);
+ xkl_debug (150, "handle_indicators: %d\n", config->handle_indicators);
+
+ config->layout_names_as_group_names =
+ xfconf_channel_get_bool(config->channel,
+ KEY_KBD_LAYOUT_NAMES_AS_GROUP_NAMES,
+ DEFAULT_KEY_KBD_LAYOUT_NAMES_AS_GROUP_NAMES);
+ xkl_debug (150, "layout_names_as_group_names: %d\n", config->layout_names_as_group_names);
+
+ config->load_extra_items =
+ xfconf_channel_get_bool(config->channel,
+ KEY_KBD_LOAD_EXTRA_ITEMS,
+ DEFAULT_KEY_KBD_LOAD_EXTRA_ITEMS);
+ xkl_debug (150, "load_extra_items: %d\n", config->load_extra_items);
+
+ config->default_group =
+ xfconf_channel_get_int(config->channel,
+ KEY_KBD_DEFAULT_GROUP,
+ DEFAULT_KEY_KBD_DEFAULT_GROUP);
+
+ if (config->default_group < -1
+ || config->default_group >=
+ xkl_engine_get_max_num_groups (config->engine))
+ {
+ config->default_group = -1;
+ }
+ xkl_debug (150, "default_group: %d\n", config->default_group);
}
gboolean
-xfcekbd_desktop_config_activate (XfcekbdDesktopConfig * config)
+xfcekbd_desktop_config_activate (XfcekbdDesktopConfig *config)
{
- gboolean rv = TRUE;
+ gboolean rv = TRUE;
- xkl_engine_set_group_per_toplevel_window (config->engine,
- config->group_per_app);
- xkl_engine_set_indicators_handling (config->engine,
- config->handle_indicators);
- xkl_engine_set_default_group (config->engine,
- config->default_group);
+ xkl_engine_set_group_per_toplevel_window (config->engine,
+ config->group_per_app);
+ xkl_engine_set_indicators_handling (config->engine,
+ config->handle_indicators);
+ xkl_engine_set_default_group (config->engine,
+ config->default_group);
- return rv;
+ return rv;
}
void
-xfcekbd_desktop_config_lock_next_group (XfcekbdDesktopConfig * config)
+xfcekbd_desktop_config_lock_next_group (XfcekbdDesktopConfig *config)
{
- int group = xkl_engine_get_next_group (config->engine);
- xkl_engine_lock_group (config->engine, group);
+ int group = xkl_engine_get_next_group (config->engine);
+ xkl_engine_lock_group (config->engine, group);
}
/**
@@ -202,69 +191,68 @@ xfcekbd_desktop_config_lock_next_group (XfcekbdDesktopConfig * config)
* @func: (scope notified): a function to call when settings are changed
*/
void
-xfcekbd_desktop_config_start_listen (XfcekbdDesktopConfig * config,
- GCallback func,
- gpointer user_data)
+xfcekbd_desktop_config_start_listen (XfcekbdDesktopConfig *config,
+ GCallback func,
+ gpointer user_data)
{
- config->config_listener_id =
- g_signal_connect (config->channel, "property-changed", func,
- user_data);
+ config->config_listener_id =
+ g_signal_connect (config->channel, "property-changed", func,
+ user_data);
}
void
-xfcekbd_desktop_config_stop_listen (XfcekbdDesktopConfig * config)
+xfcekbd_desktop_config_stop_listen (XfcekbdDesktopConfig *config)
{
- g_signal_handler_disconnect (config->channel,
- config->config_listener_id);
- config->config_listener_id = 0;
+ g_signal_handler_disconnect (config->channel,
+ config->config_listener_id);
+ config->config_listener_id = 0;
}
gboolean
-xfcekbd_desktop_config_load_group_descriptions (XfcekbdDesktopConfig
- * config,
- XklConfigRegistry *
- registry,
- const gchar **
- layout_ids,
- const gchar **
- variant_ids,
- gchar ***
- short_group_names,
- gchar *** full_group_names)
+xfcekbd_desktop_config_load_group_descriptions (XfcekbdDesktopConfig *config,
+ XklConfigRegistry *registry,
+ const gchar **layout_ids,
+ const gchar **variant_ids,
+ gchar ***short_group_names,
+ gchar ***full_group_names)
{
- gchar **sld, **lld, **svd, **lvd;
- gchar **psld, **plld, **plvd;
- gchar **psgn, **pfgn, **psvd;
- gint total_descriptions;
-
- if (!xfcekbd_desktop_config_get_lv_descriptions
- (config, registry, layout_ids, variant_ids, &sld, &lld, &svd,
- &lvd)) {
- return False;
- }
-
- total_descriptions = g_strv_length (sld);
-
- *short_group_names = psgn =
- g_new0 (gchar *, total_descriptions + 1);
- *full_group_names = pfgn =
- g_new0 (gchar *, total_descriptions + 1);
-
- plld = lld;
- psld = sld;
- plvd = lvd;
- psvd = svd;
- while (plld != NULL && *plld != NULL) {
- gchar *sd = (*psvd[0] == '\0') ? *psld : *psvd;
- psld++, psvd++;
- *psgn++ = g_strdup (sd);
- *pfgn++ = g_strdup (xfcekbd_keyboard_config_format_full_layout
- (*plld++, *plvd++));
- }
- g_strfreev (sld);
- g_strfreev (lld);
- g_strfreev (svd);
- g_strfreev (lvd);
-
- return True;
+ gchar **sld, **lld, **svd, **lvd;
+ gchar **psld, **plld, **plvd;
+ gchar **psgn, **pfgn, **psvd;
+ gint total_descriptions;
+
+ if (!xfcekbd_desktop_config_get_lv_descriptions (config,
+ registry,
+ layout_ids,
+ variant_ids,
+ &sld,
+ &lld,
+ &svd,
+ &lvd))
+ {
+ return False;
+ }
+
+ total_descriptions = g_strv_length (sld);
+
+ *short_group_names = psgn = g_new0 (gchar *, total_descriptions + 1);
+ *full_group_names = pfgn = g_new0 (gchar *, total_descriptions + 1);
+
+ plld = lld;
+ psld = sld;
+ plvd = lvd;
+ psvd = svd;
+ while (plld != NULL && *plld != NULL) {
+ gchar *sd = (*psvd[0] == '\0') ? *psld : *psvd;
+ psld++, psvd++;
+ *psgn++ = g_strdup (sd);
+ *pfgn++ = g_strdup (xfcekbd_keyboard_config_format_full_layout
+ (*plld++, *plvd++));
+ }
+ g_strfreev (sld);
+ g_strfreev (lld);
+ g_strfreev (svd);
+ g_strfreev (lvd);
+
+ return True;
}
diff --git a/src/xfcekbd-desktop-config.h b/src/xfcekbd-desktop-config.h
index cbe12f8..55598cf 100644
--- a/src/xfcekbd-desktop-config.h
+++ b/src/xfcekbd-desktop-config.h
@@ -32,50 +32,42 @@
*/
typedef struct _XfcekbdDesktopConfig XfcekbdDesktopConfig;
struct _XfcekbdDesktopConfig {
- gint default_group;
- gboolean group_per_app;
- gboolean handle_indicators;
- gboolean layout_names_as_group_names;
- gboolean load_extra_items;
+ gint default_group;
+ gboolean group_per_app;
+ gboolean handle_indicators;
+ gboolean layout_names_as_group_names;
+ gboolean load_extra_items;
- /* private, transient */
- XfconfChannel *channel;
- int config_listener_id;
- XklEngine *engine;
+ /* private, transient */
+ XfconfChannel *channel;
+ int config_listener_id;
+ XklEngine *engine;
};
/*
* XfcekbdDesktopConfig functions
*/
-extern void xfcekbd_desktop_config_init (XfcekbdDesktopConfig * config,
- XklEngine * engine);
-extern void xfcekbd_desktop_config_term (XfcekbdDesktopConfig * config);
+extern void xfcekbd_desktop_config_init (XfcekbdDesktopConfig *config,
+ XklEngine *engine);
+extern void xfcekbd_desktop_config_term (XfcekbdDesktopConfig *config);
-extern void xfcekbd_desktop_config_load_from_xfconf (XfcekbdDesktopConfig *
- config);
+extern void xfcekbd_desktop_config_load_from_xfconf (XfcekbdDesktopConfig *config);
-extern gboolean xfcekbd_desktop_config_activate (XfcekbdDesktopConfig * config);
+extern gboolean xfcekbd_desktop_config_activate (XfcekbdDesktopConfig *config);
-extern gboolean
-xfcekbd_desktop_config_load_group_descriptions (XfcekbdDesktopConfig
- * config,
- XklConfigRegistry *
- registry,
- const gchar **
- layout_ids,
- const gchar **
- variant_ids,
- gchar ***
- short_group_names,
- gchar *** full_group_names);
+extern gboolean xfcekbd_desktop_config_load_group_descriptions (XfcekbdDesktopConfig *config,
+ XklConfigRegistry *registry,
+ const gchar **layout_ids,
+ const gchar **variant_ids,
+ gchar ***short_group_names,
+ gchar ***full_group_names);
-extern void xfcekbd_desktop_config_lock_next_group (XfcekbdDesktopConfig *
- config);
+extern void xfcekbd_desktop_config_lock_next_group (XfcekbdDesktopConfig *config);
-extern void xfcekbd_desktop_config_start_listen (XfcekbdDesktopConfig * config,
- GCallback func,
- gpointer user_data);
+extern void xfcekbd_desktop_config_start_listen (XfcekbdDesktopConfig *config,
+ GCallback func,
+ gpointer user_data);
-extern void xfcekbd_desktop_config_stop_listen (XfcekbdDesktopConfig * config);
+extern void xfcekbd_desktop_config_stop_listen (XfcekbdDesktopConfig *config);
#endif
diff --git a/src/xfcekbd-indicator-config.c b/src/xfcekbd-indicator-config.c
index 6356a6b..abee906 100644
--- a/src/xfcekbd-indicator-config.c
+++ b/src/xfcekbd-indicator-config.c
@@ -40,249 +40,247 @@
* static applet config functions
*/
static void
-xfcekbd_indicator_config_load_font (XfcekbdIndicatorConfig * ind_config)
+xfcekbd_indicator_config_load_font (XfcekbdIndicatorConfig *ind_config)
{
- ind_config->font_family =
- xfconf_channel_get_string(ind_config->channel,
- KEY_KBD_INDICATOR_FONT_FAMILY,
- DEFAULT_KEY_KBD_INDICATOR_FONT_FAMILY);
-
- if (ind_config->font_family == NULL ||
- ind_config->font_family[0] == '\0') {
- PangoFontDescription *fd = NULL;
- GtkWidgetPath *widget_path = gtk_widget_path_new ();
- GtkStyleContext *context = gtk_style_context_new ();
-
- gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
- gtk_widget_path_iter_set_name (widget_path, -1 , "PanelWidget");
-
- gtk_style_context_set_path (context, widget_path);
- gtk_style_context_set_screen (context, gdk_screen_get_default ());
- gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
- gtk_style_context_add_class (context, "gnome-panel-menu-bar");
- gtk_style_context_add_class (context, "xfce-panel-menu-bar");
-
- gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
- GTK_STYLE_PROPERTY_FONT, &fd, NULL);
-
- if (fd != NULL) {
- ind_config->font_family =
- g_strdup (pango_font_description_to_string(fd));
- }
-
- g_object_unref (G_OBJECT (context));
- gtk_widget_path_unref (widget_path);
- }
- xkl_debug (150, "font: [%s]\n", ind_config->font_family);
-
+ ind_config->font_family =
+ xfconf_channel_get_string(ind_config->channel,
+ KEY_KBD_INDICATOR_FONT_FAMILY,
+ DEFAULT_KEY_KBD_INDICATOR_FONT_FAMILY);
+
+ if (ind_config->font_family == NULL ||
+ ind_config->font_family[0] == '\0')
+ {
+ PangoFontDescription *fd = NULL;
+ GtkWidgetPath *widget_path = gtk_widget_path_new ();
+ GtkStyleContext *context = gtk_style_context_new ();
+
+ gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
+ gtk_widget_path_iter_set_name (widget_path, -1 , "PanelWidget");
+
+ gtk_style_context_set_path (context, widget_path);
+ gtk_style_context_set_screen (context, gdk_screen_get_default ());
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
+ gtk_style_context_add_class (context, "gnome-panel-menu-bar");
+ gtk_style_context_add_class (context, "xfce-panel-menu-bar");
+
+ gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
+ GTK_STYLE_PROPERTY_FONT, &fd, NULL);
+
+ if (fd != NULL) {
+ ind_config->font_family =
+ g_strdup (pango_font_description_to_string(fd));
+ }
+
+ g_object_unref (G_OBJECT (context));
+ gtk_widget_path_unref (widget_path);
+ }
+ xkl_debug (150, "font: [%s]\n", ind_config->font_family);
}
static void
-xfcekbd_indicator_config_load_colors (XfcekbdIndicatorConfig * ind_config)
+xfcekbd_indicator_config_load_colors (XfcekbdIndicatorConfig *ind_config)
{
- ind_config->foreground_color =
- xfconf_channel_get_string(ind_config->channel,
- KEY_KBD_INDICATOR_FOREGROUND_COLOR,
- DEFAULT_KEY_KBD_INDICATOR_FOREGROUND_COLOR);
-
- if (ind_config->foreground_color == NULL ||
- ind_config->foreground_color[0] == '\0') {
- GtkWidgetPath *widget_path = gtk_widget_path_new ();
- GtkStyleContext *context = gtk_style_context_new ();
- GdkRGBA fg_color;
-
- gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
- gtk_widget_path_iter_set_name (widget_path, -1 , "PanelWidget");
-
- gtk_style_context_set_path (context, widget_path);
- gtk_style_context_set_screen (context, gdk_screen_get_default ());
- gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
- gtk_style_context_add_class (context, "gnome-panel-menu-bar");
- gtk_style_context_add_class (context, "xfce-panel-menu-bar");
-
- gtk_style_context_get_color (context,
- GTK_STATE_FLAG_NORMAL, &fg_color);
- ind_config->foreground_color =
- g_strdup_printf ("%g %g %g",
- fg_color.red,
- fg_color.green,
- fg_color.blue);
-
- g_object_unref (G_OBJECT (context));
- gtk_widget_path_unref (widget_path);
- }
-
- ind_config->background_color =
- xfconf_channel_get_string(ind_config->channel,
- KEY_KBD_INDICATOR_BACKGROUND_COLOR,
- DEFAULT_KEY_KBD_INDICATOR_BACKGROUND_COLOR);
+ ind_config->foreground_color =
+ xfconf_channel_get_string(ind_config->channel,
+ KEY_KBD_INDICATOR_FOREGROUND_COLOR,
+ DEFAULT_KEY_KBD_INDICATOR_FOREGROUND_COLOR);
+
+ if (ind_config->foreground_color == NULL ||
+ ind_config->foreground_color[0] == '\0') {
+ GtkWidgetPath *widget_path = gtk_widget_path_new ();
+ GtkStyleContext *context = gtk_style_context_new ();
+ GdkRGBA fg_color;
+
+ gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
+ gtk_widget_path_iter_set_name (widget_path, -1 , "PanelWidget");
+
+ gtk_style_context_set_path (context, widget_path);
+ gtk_style_context_set_screen (context, gdk_screen_get_default ());
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
+ gtk_style_context_add_class (context, "gnome-panel-menu-bar");
+ gtk_style_context_add_class (context, "xfce-panel-menu-bar");
+
+ gtk_style_context_get_color (context,
+ GTK_STATE_FLAG_NORMAL, &fg_color);
+ ind_config->foreground_color =
+ g_strdup_printf ("%g %g %g",
+ fg_color.red,
+ fg_color.green,
+ fg_color.blue);
+
+ g_object_unref (G_OBJECT (context));
+ gtk_widget_path_unref (widget_path);
+ }
+
+ ind_config->background_color =
+ xfconf_channel_get_string(ind_config->channel,
+ KEY_KBD_INDICATOR_BACKGROUND_COLOR,
+ DEFAULT_KEY_KBD_INDICATOR_BACKGROUND_COLOR);
}
static gchar *
-xfcekbd_indicator_config_get_images_file (XfcekbdIndicatorConfig *
- ind_config,
- XfcekbdKeyboardConfig *
- kbd_config, int group)
+xfcekbd_indicator_config_get_images_file (XfcekbdIndicatorConfig *ind_config,
+ XfcekbdKeyboardConfig *kbd_config,
+ int group)
{
- char *image_file = NULL;
- GtkIconInfo *icon_info = NULL;
-
- if (!ind_config->show_flags)
- return NULL;
-
- if ((kbd_config->layouts_variants != NULL) &&
- (g_strv_length (kbd_config->layouts_variants) > group)) {
- char *full_layout_name =
- kbd_config->layouts_variants[group];
-
- if (full_layout_name != NULL) {
- char *l, *v;
- xfcekbd_keyboard_config_split_items (full_layout_name,
- &l, &v);
- if (l != NULL) {
- /* probably there is something in theme? */
- icon_info = gtk_icon_theme_lookup_icon
- (ind_config->icon_theme, l, 48, 0);
-
- /* Unbelievable but happens */
- if (icon_info != NULL &&
- gtk_icon_info_get_filename (icon_info) == NULL) {
- g_object_unref (icon_info);
- icon_info = NULL;
- }
- }
- }
- }
- /* fallback to the default value */
- if (icon_info == NULL) {
- icon_info = gtk_icon_theme_lookup_icon
- (ind_config->icon_theme, "stock_dialog-error", 48, 0);
- }
- if (icon_info != NULL) {
- image_file =
- g_strdup (gtk_icon_info_get_filename (icon_info));
- g_object_unref (icon_info);
- }
-
- return image_file;
+ char *image_file = NULL;
+ GtkIconInfo *icon_info = NULL;
+
+ if (!ind_config->show_flags)
+ return NULL;
+
+ if ((kbd_config->layouts_variants != NULL) &&
+ (g_strv_length (kbd_config->layouts_variants) > group)) {
+ char *full_layout_name =
+ kbd_config->layouts_variants[group];
+
+ if (full_layout_name != NULL) {
+ char *l, *v;
+ xfcekbd_keyboard_config_split_items (full_layout_name,
+ &l, &v);
+ if (l != NULL) {
+ /* probably there is something in theme? */
+ icon_info = gtk_icon_theme_lookup_icon
+ (ind_config->icon_theme, l, 48, 0);
+
+ /* Unbelievable but happens */
+ if (icon_info != NULL &&
+ gtk_icon_info_get_filename (icon_info) == NULL) {
+ g_object_unref (icon_info);
+ icon_info = NULL;
+ }
+ }
+ }
+ }
+ /* fallback to the default value */
+ if (icon_info == NULL) {
+ icon_info = gtk_icon_theme_lookup_icon
+ (ind_config->icon_theme, "stock_dialog-error", 48, 0);
+ }
+ if (icon_info != NULL) {
+ image_file =
+ g_strdup (gtk_icon_info_get_filename (icon_info));
+ g_object_unref (icon_info);
+ }
+
+ return image_file;
}
void
xfcekbd_indicator_config_load_image_filenames (XfcekbdIndicatorConfig *
- ind_config,
- XfcekbdKeyboardConfig *
- kbd_config)
+ ind_config,
+ XfcekbdKeyboardConfig *
+ kbd_config)
{
- int i;
- ind_config->image_filenames = NULL;
-
- if (!ind_config->show_flags)
- return;
-
- for (i = xkl_engine_get_max_num_groups (ind_config->engine);
- --i >= 0;) {
- gchar *image_file =
- xfcekbd_indicator_config_get_images_file (ind_config,
- kbd_config,
- i);
- ind_config->image_filenames =
- g_slist_prepend (ind_config->image_filenames,
- image_file);
- }
+ int i;
+ ind_config->image_filenames = NULL;
+
+ if (!ind_config->show_flags)
+ return;
+
+ for (i = xkl_engine_get_max_num_groups (ind_config->engine);
+ --i >= 0;) {
+ gchar *image_file =
+ xfcekbd_indicator_config_get_images_file (ind_config,
+ kbd_config,
+ i);
+ ind_config->image_filenames =
+ g_slist_prepend (ind_config->image_filenames,
+ image_file);
+ }
}
void
-xfcekbd_indicator_config_free_image_filenames (XfcekbdIndicatorConfig *
- ind_config)
+xfcekbd_indicator_config_free_image_filenames (XfcekbdIndicatorConfig *ind_config)
{
- while (ind_config->image_filenames) {
- if (ind_config->image_filenames->data)
- g_free (ind_config->image_filenames->data);
- ind_config->image_filenames =
- g_slist_delete_link (ind_config->image_filenames,
- ind_config->image_filenames);
- }
+ while (ind_config->image_filenames) {
+ if (ind_config->image_filenames->data)
+ g_free (ind_config->image_filenames->data);
+ ind_config->image_filenames =
+ g_slist_delete_link (ind_config->image_filenames,
+ ind_config->image_filenames);
+ }
}
void
-xfcekbd_indicator_config_init (XfcekbdIndicatorConfig * ind_config,
- XklEngine * engine)
+xfcekbd_indicator_config_init (XfcekbdIndicatorConfig *ind_config,
+ XklEngine *engine)
{
- gchar *sp;
-
- memset (ind_config, 0, sizeof (*ind_config));
- ind_config->channel = xfconf_channel_get (SETTINGS_XFCONF_CHANNEL);
- ind_config->engine = engine;
-
- ind_config->icon_theme = gtk_icon_theme_get_default ();
-
- gtk_icon_theme_append_search_path (ind_config->icon_theme, sp =
- g_build_filename (g_get_home_dir
- (),
- ".icons/flags",
- NULL));
- g_free (sp);
-
- gtk_icon_theme_append_search_path (ind_config->icon_theme,
- sp =
- g_build_filename (DATADIR,
- "pixmaps/flags",
- NULL));
- g_free (sp);
-
- gtk_icon_theme_append_search_path (ind_config->icon_theme,
- sp =
- g_build_filename (DATADIR,
- "icons/flags",
- NULL));
- g_free (sp);
+ gchar *sp;
+
+ memset (ind_config, 0, sizeof (*ind_config));
+ ind_config->channel = xfconf_channel_get (SETTINGS_XFCONF_CHANNEL);
+ ind_config->engine = engine;
+
+ ind_config->icon_theme = gtk_icon_theme_get_default ();
+
+ gtk_icon_theme_append_search_path (ind_config->icon_theme, sp =
+ g_build_filename (g_get_home_dir
+ (),
+ ".icons/flags",
+ NULL));
+ g_free (sp);
+
+ gtk_icon_theme_append_search_path (ind_config->icon_theme,
+ sp =
+ g_build_filename (DATADIR,
+ "pixmaps/flags",
+ NULL));
+ g_free (sp);
+
+ gtk_icon_theme_append_search_path (ind_config->icon_theme,
+ sp =
+ g_build_filename (DATADIR,
+ "icons/flags",
+ NULL));
+ g_free (sp);
}
void
-xfcekbd_indicator_config_term (XfcekbdIndicatorConfig * ind_config)
+xfcekbd_indicator_config_term (XfcekbdIndicatorConfig *ind_config)
{
- g_free (ind_config->font_family);
- ind_config->font_family = NULL;
+ g_free (ind_config->font_family);
+ ind_config->font_family = NULL;
- g_free (ind_config->foreground_color);
- ind_config->foreground_color = NULL;
+ g_free (ind_config->foreground_color);
+ ind_config->foreground_color = NULL;
- g_free (ind_config->background_color);
- ind_config->background_color = NULL;
+ g_free (ind_config->background_color);
+ ind_config->background_color = NULL;
- ind_config->icon_theme = NULL;
+ ind_config->icon_theme = NULL;
- xfcekbd_indicator_config_free_image_filenames (ind_config);
+ xfcekbd_indicator_config_free_image_filenames (ind_config);
- g_object_unref (ind_config->channel);
- ind_config->channel = NULL;
+ g_object_unref (ind_config->channel);
+ ind_config->channel = NULL;
}
void
xfcekbd_indicator_config_load_from_xfconf (XfcekbdIndicatorConfig * ind_config)
{
- ind_config->secondary_groups_mask =
- xfconf_channel_get_int (ind_config->channel,
- KEY_KBD_INDICATOR_SECONDARIES,
- DEFAULT_KEY_KBD_INDICATOR_SECONDARIES);
+ ind_config->secondary_groups_mask =
+ xfconf_channel_get_int (ind_config->channel,
+ KEY_KBD_INDICATOR_SECONDARIES,
+ DEFAULT_KEY_KBD_INDICATOR_SECONDARIES);
- ind_config->show_flags =
- xfconf_channel_get_bool (ind_config->channel,
- KEY_KBD_INDICATOR_SHOW_FLAGS,
- DEFAULT_KEY_KBD_INDICATOR_SHOW_FLAGS);
+ ind_config->show_flags =
+ xfconf_channel_get_bool (ind_config->channel,
+ KEY_KBD_INDICATOR_SHOW_FLAGS,
+ DEFAULT_KEY_KBD_INDICATOR_SHOW_FLAGS);
- xfcekbd_indicator_config_load_font (ind_config);
- xfcekbd_indicator_config_load_colors (ind_config);
+ xfcekbd_indicator_config_load_font (ind_config);
+ xfcekbd_indicator_config_load_colors (ind_config);
}
void
xfcekbd_indicator_config_activate (XfcekbdIndicatorConfig * ind_config)
{
- xkl_engine_set_secondary_groups_mask (ind_config->engine,
- ind_config->secondary_groups_mask);
+ xkl_engine_set_secondary_groups_mask (ind_config->engine,
+ ind_config->secondary_groups_mask);
}
/**
@@ -290,20 +288,21 @@ xfcekbd_indicator_config_activate (XfcekbdIndicatorConfig * ind_config)
* @func: (scope notified): a function to call when settings are changed
*/
void
-xfcekbd_indicator_config_start_listen (XfcekbdIndicatorConfig *
- ind_config,
- GCallback func,
- gpointer user_data)
+xfcekbd_indicator_config_start_listen (XfcekbdIndicatorConfig *ind_config,
+ GCallback func,
+ gpointer user_data)
{
- ind_config->config_listener_id =
- g_signal_connect (ind_config->channel, "property-changed", func,
- user_data);
+ ind_config->config_listener_id =
+ g_signal_connect (ind_config->channel,
+ "property-changed",
+ func,
+ user_data);
}
void
-xfcekbd_indicator_config_stop_listen (XfcekbdIndicatorConfig * ind_config)
+xfcekbd_indicator_config_stop_listen (XfcekbdIndicatorConfig *ind_config)
{
- g_signal_handler_disconnect (ind_config->channel,
- ind_config->config_listener_id);
- ind_config->config_listener_id = 0;
+ g_signal_handler_disconnect (ind_config->channel,
+ ind_config->config_listener_id);
+ ind_config->config_listener_id = 0;
}
diff --git a/src/xfcekbd-indicator-config.h b/src/xfcekbd-indicator-config.h
index bb055de..8a85518 100644
--- a/src/xfcekbd-indicator-config.h
+++ b/src/xfcekbd-indicator-config.h
@@ -30,19 +30,19 @@
*/
typedef struct _XfcekbdIndicatorConfig XfcekbdIndicatorConfig;
struct _XfcekbdIndicatorConfig {
- int secondary_groups_mask;
- gboolean show_flags;
+ int secondary_groups_mask;
+ gboolean show_flags;
- gchar *font_family;
- gchar *foreground_color;
- gchar *background_color;
+ gchar *font_family;
+ gchar *foreground_color;
+ gchar *background_color;
- /* private, transient */
- XfconfChannel *channel;
- GSList *image_filenames;
- GtkIconTheme *icon_theme;
- int config_listener_id;
- XklEngine *engine;
+ /* private, transient */
+ XfconfChannel *channel;
+ GSList *image_filenames;
+ GtkIconTheme *icon_theme;
+ int config_listener_id;
+ XklEngine *engine;
};
/*
@@ -50,32 +50,23 @@ struct _XfcekbdIndicatorConfig {
* some of them require XfcekbdKeyboardConfig as well -
* for loading approptiate images
*/
-void xfcekbd_indicator_config_init (XfcekbdIndicatorConfig *
- applet_config,
- XklEngine * engine);
-void xfcekbd_indicator_config_term (XfcekbdIndicatorConfig *
- applet_config);
+void xfcekbd_indicator_config_init (XfcekbdIndicatorConfig *applet_config,
+ XklEngine *engine);
+void xfcekbd_indicator_config_term (XfcekbdIndicatorConfig *applet_config);
-void xfcekbd_indicator_config_load_from_xfconf (XfcekbdIndicatorConfig
- * applet_config);
+void xfcekbd_indicator_config_load_from_xfconf (XfcekbdIndicatorConfig *applet_config);
-void xfcekbd_indicator_config_load_image_filenames (XfcekbdIndicatorConfig
- * applet_config,
- XfcekbdKeyboardConfig
- * kbd_config);
-void xfcekbd_indicator_config_free_image_filenames (XfcekbdIndicatorConfig
- * applet_config);
+void xfcekbd_indicator_config_load_image_filenames (XfcekbdIndicatorConfig *applet_config,
+ XfcekbdKeyboardConfig *kbd_config);
+void xfcekbd_indicator_config_free_image_filenames (XfcekbdIndicatorConfig *applet_config);
/* Should be updated on Indicator/Xfconf configuration change */
-void xfcekbd_indicator_config_activate (XfcekbdIndicatorConfig *
- applet_config);
+void xfcekbd_indicator_config_activate (XfcekbdIndicatorConfig *applet_config);
-void xfcekbd_indicator_config_start_listen (XfcekbdIndicatorConfig *
- applet_config,
- GCallback
- func, gpointer user_data);
+void xfcekbd_indicator_config_start_listen (XfcekbdIndicatorConfig *applet_config,
+ GCallback func,
+ gpointer user_data);
-void xfcekbd_indicator_config_stop_listen (XfcekbdIndicatorConfig *
- applet_config);
+void xfcekbd_indicator_config_stop_listen (XfcekbdIndicatorConfig *applet_config);
#endif
diff --git a/src/xfcekbd-indicator.c b/src/xfcekbd-indicator.c
index c35b335..3c1a7f5 100644
--- a/src/xfcekbd-indicator.c
+++ b/src/xfcekbd-indicator.c
@@ -32,599 +32,596 @@
#include "xfcekbd-indicator-config.h"
typedef struct _gki_globals {
- XklEngine *engine;
- XklConfigRegistry *registry;
-
- XfcekbdDesktopConfig cfg;
- XfcekbdIndicatorConfig ind_cfg;
- XfcekbdKeyboardConfig kbd_cfg;
-
- const gchar *tooltips_format;
- gchar **full_group_names;
- gchar **short_group_names;
- GSList *widget_instances;
- GSList *images;
+ XklEngine *engine;
+ XklConfigRegistry *registry;
+
+ XfcekbdDesktopConfig cfg;
+ XfcekbdIndicatorConfig ind_cfg;
+ XfcekbdKeyboardConfig kbd_cfg;
+
+ const gchar *tooltips_format;
+ gchar **full_group_names;
+ gchar **short_group_names;
+ GSList *widget_instances;
+ GSList *images;
} gki_globals;
struct _XfcekbdIndicatorPrivate {
- gboolean set_parent_tooltips;
- gdouble angle;
+ gboolean set_parent_tooltips;
+ gdouble angle;
};
/* one instance for ALL widgets */
static gki_globals globals;
#define ForAllIndicators() \
- { \
- GSList* cur; \
- for (cur = globals.widget_instances; cur != NULL; cur = cur->next) { \
- XfcekbdIndicator * gki = (XfcekbdIndicator*)cur->data;
+ { \
+ GSList* cur; \
+ for (cur = globals.widget_instances; cur != NULL; cur = cur->next) { \
+ XfcekbdIndicator * gki = (XfcekbdIndicator*)cur->data;
#define NextIndicator() \
- } \
- }
+ } \
+ }
G_DEFINE_TYPE (XfcekbdIndicator, xfcekbd_indicator, GTK_TYPE_NOTEBOOK)
-static void
-xfcekbd_indicator_global_init (void);
-static void
-xfcekbd_indicator_global_term (void);
-static GtkWidget *
-xfcekbd_indicator_prepare_drawing (XfcekbdIndicator * gki, int group);
-static void
-xfcekbd_indicator_set_current_page_for_group (XfcekbdIndicator * gki, int group);
-static void
-xfcekbd_indicator_set_current_page (XfcekbdIndicator * gki);
-static void
-xfcekbd_indicator_cleanup (XfcekbdIndicator * gki);
-static void
-xfcekbd_indicator_fill (XfcekbdIndicator * gki);
-static void
-xfcekbd_indicator_set_tooltips (XfcekbdIndicator * gki, const char *str);
+static void xfcekbd_indicator_global_init (void);
+static void xfcekbd_indicator_global_term (void);
+static GtkWidget * xfcekbd_indicator_prepare_drawing (XfcekbdIndicator *gki,
+ int group);
+static void xfcekbd_indicator_set_current_page_for_group (XfcekbdIndicator *gki,
+ int group);
+static void xfcekbd_indicator_set_current_page (XfcekbdIndicator *gki);
+static void xfcekbd_indicator_cleanup (XfcekbdIndicator *gki);
+static void xfcekbd_indicator_fill (XfcekbdIndicator *gki);
+static void xfcekbd_indicator_set_tooltips (XfcekbdIndicator *gki,
+ const char *str);
static void
xfcekbd_indicator_load_images ()
{
- int i;
- GSList *image_filename;
-
- globals.images = NULL;
- xfcekbd_indicator_config_load_image_filenames (&globals.ind_cfg,
- &globals.kbd_cfg);
-
- if (!globals.ind_cfg.show_flags)
- return;
-
- image_filename = globals.ind_cfg.image_filenames;
-
- for (i = xkl_engine_get_max_num_groups (globals.engine);
- --i >= 0; image_filename = image_filename->next) {
- GdkPixbuf *image = NULL;
- char *image_file = (char *) image_filename->data;
-
- if (image_file != NULL) {
- GError *gerror = NULL;
- image =
- gdk_pixbuf_new_from_file (image_file, &gerror);
- if (image == NULL) {
- GtkWidget *dialog =
- gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _
- ("There was an error loading an image: %s"),
- gerror->
- message);
- g_signal_connect (G_OBJECT (dialog),
- "response",
- G_CALLBACK
- (gtk_widget_destroy),
- NULL);
-
- gtk_window_set_resizable (GTK_WINDOW
- (dialog), FALSE);
-
- gtk_widget_show (dialog);
- g_error_free (gerror);
- }
- xkl_debug (150,
- "Image %d[%s] loaded -> %p[%dx%d]\n",
- i, image_file, image,
- gdk_pixbuf_get_width (image),
- gdk_pixbuf_get_height (image));
- }
- /* We append the image anyway - even if it is NULL! */
- globals.images = g_slist_append (globals.images, image);
- }
+ int i;
+ GSList *image_filename;
+
+ globals.images = NULL;
+ xfcekbd_indicator_config_load_image_filenames (&globals.ind_cfg,
+ &globals.kbd_cfg);
+
+ if (!globals.ind_cfg.show_flags)
+ return;
+
+ image_filename = globals.ind_cfg.image_filenames;
+
+ for (i = xkl_engine_get_max_num_groups (globals.engine);
+ --i >= 0; image_filename = image_filename->next) {
+ GdkPixbuf *image = NULL;
+ char *image_file = (char *) image_filename->data;
+
+ if (image_file != NULL) {
+ GError *gerror = NULL;
+ image =
+ gdk_pixbuf_new_from_file (image_file, &gerror);
+ if (image == NULL) {
+ GtkWidget *dialog =
+ gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("There was an error loading an image: %s"),
+ gerror->
+ message);
+ g_signal_connect (G_OBJECT (dialog),
+ "response",
+ G_CALLBACK
+ (gtk_widget_destroy),
+ NULL);
+
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+ gtk_widget_show (dialog);
+ g_error_free (gerror);
+ }
+ xkl_debug (150,
+ "Image %d[%s] loaded -> %p[%dx%d]\n",
+ i, image_file, image,
+ gdk_pixbuf_get_width (image),
+ gdk_pixbuf_get_height (image));
+ }
+ /* We append the image anyway - even if it is NULL! */
+ globals.images = g_slist_append (globals.images, image);
+ }
}
static void
xfcekbd_indicator_free_images ()
{
- GdkPixbuf *pi;
- GSList *img_node;
+ GdkPixbuf *pi;
+ GSList *img_node;
- xfcekbd_indicator_config_free_image_filenames (&globals.ind_cfg);
+ xfcekbd_indicator_config_free_image_filenames (&globals.ind_cfg);
- while ((img_node = globals.images) != NULL) {
- pi = GDK_PIXBUF (img_node->data);
- /* It can be NULL - some images may be missing */
- if (pi != NULL) {
- g_object_unref (pi);
- }
- globals.images =
- g_slist_remove_link (globals.images, img_node);
- g_slist_free_1 (img_node);
- }
+ while ((img_node = globals.images) != NULL) {
+ pi = GDK_PIXBUF (img_node->data);
+ /* It can be NULL - some images may be missing */
+ if (pi != NULL) {
+ g_object_unref (pi);
+ }
+ globals.images =
+ g_slist_remove_link (globals.images, img_node);
+ g_slist_free_1 (img_node);
+ }
}
static void
xfcekbd_indicator_update_images (void)
{
- xfcekbd_indicator_free_images ();
- xfcekbd_indicator_load_images ();
+ xfcekbd_indicator_free_images ();
+ xfcekbd_indicator_load_images ();
}
void
-xfcekbd_indicator_set_tooltips (XfcekbdIndicator * gki, const char *str)
+xfcekbd_indicator_set_tooltips (XfcekbdIndicator *gki,
+ const char *str)
{
- g_assert (str == NULL || g_utf8_validate (str, -1, NULL));
+ g_assert (str == NULL || g_utf8_validate (str, -1, NULL));
- gtk_widget_set_tooltip_text (GTK_WIDGET (gki), str);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (gki), str);
- if (gki->priv->set_parent_tooltips) {
- GtkWidget *parent =
- gtk_widget_get_parent (GTK_WIDGET (gki));
- if (parent) {
- gtk_widget_set_tooltip_text (parent, str);
- }
- }
+ if (gki->priv->set_parent_tooltips) {
+ GtkWidget *parent =
+ gtk_widget_get_parent (GTK_WIDGET (gki));
+ if (parent) {
+ gtk_widget_set_tooltip_text (parent, str);
+ }
+ }
}
void
xfcekbd_indicator_cleanup (XfcekbdIndicator * gki)
{
- int i;
- GtkNotebook *notebook = GTK_NOTEBOOK (gki);
+ int i;
+ GtkNotebook *notebook = GTK_NOTEBOOK (gki);
- /* Do not remove the first page! It is the default page */
- for (i = gtk_notebook_get_n_pages (notebook); --i > 0;) {
- gtk_notebook_remove_page (notebook, i);
- }
+ /* Do not remove the first page! It is the default page */
+ for (i = gtk_notebook_get_n_pages (notebook); --i > 0;) {
+ gtk_notebook_remove_page (notebook, i);
+ }
}
void
xfcekbd_indicator_fill (XfcekbdIndicator * gki)
{
- int grp;
- int total_groups = xkl_engine_get_num_groups (globals.engine);
- GtkNotebook *notebook = GTK_NOTEBOOK (gki);
+ int grp;
+ int total_groups = xkl_engine_get_num_groups (globals.engine);
+ GtkNotebook *notebook = GTK_NOTEBOOK (gki);
- for (grp = 0; grp < total_groups; grp++) {
- GtkWidget *page;
- page = xfcekbd_indicator_prepare_drawing (gki, grp);
+ for (grp = 0; grp < total_groups; grp++) {
+ GtkWidget *page = xfcekbd_indicator_prepare_drawing (gki, grp);
- if (page == NULL)
- page = gtk_label_new ("");
+ if (page == NULL)
+ page = gtk_label_new ("");
- gtk_notebook_append_page (notebook, page, NULL);
- gtk_widget_show_all (page);
- }
+ gtk_notebook_append_page (notebook, page, NULL);
+ gtk_widget_show_all (page);
+ }
}
-static gboolean xfcekbd_indicator_key_pressed(GtkWidget* widget, GdkEventKey* event, XfcekbdIndicator* gki)
+static gboolean xfcekbd_indicator_key_pressed (GtkWidget *widget,
+ GdkEventKey *event,
+ XfcekbdIndicator *gki)
{
- switch (event->keyval)
- {
- case GDK_KEY_KP_Enter:
- case GDK_KEY_ISO_Enter:
- case GDK_KEY_3270_Enter:
- case GDK_KEY_Return:
- case GDK_KEY_space:
- case GDK_KEY_KP_Space:
- xfcekbd_desktop_config_lock_next_group(&globals.cfg);
- return TRUE;
- default:
- break;
- }
+ switch (event->keyval)
+ {
+ case GDK_KEY_KP_Enter:
+ case GDK_KEY_ISO_Enter:
+ case GDK_KEY_3270_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_space:
+ case GDK_KEY_KP_Space:
+ xfcekbd_desktop_config_lock_next_group(&globals.cfg);
+ return TRUE;
+ default:
+ break;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-xfcekbd_indicator_button_pressed (GtkWidget *
- widget,
- GdkEventButton * event, XfcekbdIndicator * gki)
-{
- GtkWidget *img = gtk_bin_get_child (GTK_BIN (widget));
- GtkAllocation allocation;
- gtk_widget_get_allocation (img, &allocation);
- xkl_debug (150, "Flag img size %d x %d\n",
- allocation.width, allocation.height);
- if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
- xkl_debug (150, "Mouse button pressed on applet\n");
- xfcekbd_desktop_config_lock_next_group (&globals.cfg);
- return TRUE;
- }
- return FALSE;
+xfcekbd_indicator_button_pressed (GtkWidget *widget,
+ GdkEventButton *event,
+ XfcekbdIndicator *gki)
+{
+ GtkWidget *img = gtk_bin_get_child (GTK_BIN (widget));
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (img, &allocation);
+ xkl_debug (150, "Flag img size %d x %d\n", allocation.width, allocation.height);
+ if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
+ xkl_debug (150, "Mouse button pressed on applet\n");
+ xfcekbd_desktop_config_lock_next_group (&globals.cfg);
+ return TRUE;
+ }
+ return FALSE;
}
static void
-draw_flag (GtkWidget * flag, cairo_t * cr, GdkPixbuf * image)
+draw_flag (GtkWidget *flag,
+ cairo_t *cr,
+ GdkPixbuf *image)
{
- /* Image width and height */
- int iw = gdk_pixbuf_get_width (image);
- int ih = gdk_pixbuf_get_height (image);
- GtkAllocation allocation;
- double xwiratio, ywiratio, wiratio;
+ /* Image width and height */
+ int iw = gdk_pixbuf_get_width (image);
+ int ih = gdk_pixbuf_get_height (image);
+ GtkAllocation allocation;
+ double xwiratio, ywiratio, wiratio;
- gtk_widget_get_allocation (flag, &allocation);
+ gtk_widget_get_allocation (flag, &allocation);
- /* widget-to-image scales, X and Y */
- xwiratio = 1.0 * allocation.width / iw;
- ywiratio = 1.0 * allocation.height / ih;
- wiratio = xwiratio < ywiratio ? xwiratio : ywiratio;
+ /* widget-to-image scales, X and Y */
+ xwiratio = 1.0 * allocation.width / iw;
+ ywiratio = 1.0 * allocation.height / ih;
+ wiratio = xwiratio < ywiratio ? xwiratio : ywiratio;
- /* transform cairo context */
- cairo_translate (cr, allocation.width / 2.0, allocation.height / 2.0);
- cairo_scale (cr, wiratio, wiratio);
- cairo_translate (cr, - iw / 2.0, - ih / 2.0);
+ /* transform cairo context */
+ cairo_translate (cr, allocation.width / 2.0, allocation.height / 2.0);
+ cairo_scale (cr, wiratio, wiratio);
+ cairo_translate (cr, - iw / 2.0, - ih / 2.0);
- gdk_cairo_set_source_pixbuf (cr, image, 0, 0);
- cairo_paint (cr);
+ gdk_cairo_set_source_pixbuf (cr, image, 0, 0);
+ cairo_paint (cr);
}
static gchar *
-xfcekbd_indicator_extract_layout_name (int group, XklEngine * engine,
- XfcekbdKeyboardConfig * kbd_cfg,
- gchar ** short_group_names,
- gchar ** full_group_names)
-{
- char *layout_name = NULL;
- if (group < g_strv_length (short_group_names)) {
- if (xkl_engine_get_features (engine) &
- XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
- char *full_layout_name =
- kbd_cfg->layouts_variants[group];
- char *variant_name;
- if (!xfcekbd_keyboard_config_split_items
- (full_layout_name, &layout_name,
- &variant_name))
- /* just in case */
- layout_name = full_layout_name;
-
- /* make it freeable */
- layout_name = g_strdup (layout_name);
-
- if (short_group_names != NULL) {
- char *short_group_name =
- short_group_names[group];
- if (short_group_name != NULL
- && *short_group_name != '\0') {
- /* drop the long name */
- g_free (layout_name);
- layout_name =
- g_strdup (short_group_name);
- }
- }
- } else {
- layout_name = g_strdup (full_group_names[group]);
- }
- }
-
- if (layout_name == NULL)
- layout_name = g_strdup ("");
-
- return layout_name;
+xfcekbd_indicator_extract_layout_name (int group,
+ XklEngine *engine,
+ XfcekbdKeyboardConfig *kbd_cfg,
+ gchar **short_group_names,
+ gchar **full_group_names)
+{
+ char *layout_name = NULL;
+ if (group < g_strv_length (short_group_names)) {
+ if (xkl_engine_get_features (engine) & XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
+ char *full_layout_name = kbd_cfg->layouts_variants[group];
+ char *variant_name;
+ if (!xfcekbd_keyboard_config_split_items (full_layout_name,
+ &layout_name,
+ &variant_name))
+ {
+ /* just in case */
+ layout_name = full_layout_name;
+ }
+
+ /* make it freeable */
+ layout_name = g_strdup (layout_name);
+
+ if (short_group_names != NULL) {
+ char *short_group_name = short_group_names[group];
+ if (short_group_name != NULL && *short_group_name != '\0') {
+ /* drop the long name */
+ g_free (layout_name);
+ layout_name =
+ g_strdup (short_group_name);
+ }
+ }
+ } else {
+ layout_name = g_strdup (full_group_names[group]);
+ }
+ }
+
+ if (layout_name == NULL)
+ layout_name = g_strdup ("");
+
+ return layout_name;
}
static gchar *
-xfcekbd_indicator_create_label_title (int group, GHashTable ** ln2cnt_map,
- gchar * layout_name)
-{
- gpointer pcounter = NULL;
- char *prev_layout_name = NULL;
- char *lbl_title = NULL;
- int counter = 0;
-
- if (group == 0) {
- *ln2cnt_map =
- g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- }
-
- /* Process layouts with repeating description */
- if (g_hash_table_lookup_extended
- (*ln2cnt_map, layout_name, (gpointer *) & prev_layout_name,
- &pcounter)) {
- /* "next" same description */
- gchar appendix[10] = "";
- gint utf8length;
- gunichar cidx;
- counter = GPOINTER_TO_INT (pcounter);
- /* Unicode subscript 2, 3, 4 */
- cidx = 0x2081 + counter;
- utf8length = g_unichar_to_utf8 (cidx, appendix);
- appendix[utf8length] = '\0';
- lbl_title = g_strconcat (layout_name, appendix, NULL);
- } else {
- /* "first" time this description */
- lbl_title = g_strdup (layout_name);
- }
- g_hash_table_insert (*ln2cnt_map, layout_name,
- GINT_TO_POINTER (counter + 1));
- return lbl_title;
+xfcekbd_indicator_create_label_title (int group,
+ GHashTable **ln2cnt_map,
+ gchar *layout_name)
+{
+ gpointer pcounter = NULL;
+ char *prev_layout_name = NULL;
+ char *lbl_title = NULL;
+ int counter = 0;
+
+ if (group == 0) {
+ *ln2cnt_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ }
+
+ /* Process layouts with repeating description */
+ if (g_hash_table_lookup_extended (*ln2cnt_map,
+ layout_name,
+ (gpointer *) & prev_layout_name,
+ &pcounter))
+ {
+ /* "next" same description */
+ gchar appendix[10] = "";
+ gint utf8length;
+ gunichar cidx;
+ counter = GPOINTER_TO_INT (pcounter);
+ /* Unicode subscript 2, 3, 4 */
+ cidx = 0x2081 + counter;
+ utf8length = g_unichar_to_utf8 (cidx, appendix);
+ appendix[utf8length] = '\0';
+ lbl_title = g_strconcat (layout_name, appendix, NULL);
+ } else {
+ /* "first" time this description */
+ lbl_title = g_strdup (layout_name);
+ }
+ g_hash_table_insert (*ln2cnt_map, layout_name,
+ GINT_TO_POINTER (counter + 1));
+ return lbl_title;
}
static GtkWidget *
-xfcekbd_indicator_prepare_drawing (XfcekbdIndicator * gki, int group)
-{
- gpointer pimage;
- GdkPixbuf *image;
- GtkWidget *ebox;
-
- pimage = g_slist_nth_data (globals.images, group);
- ebox = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
- if (globals.ind_cfg.show_flags) {
- GtkWidget *flag;
- if (pimage == NULL)
- return NULL;
- image = GDK_PIXBUF (pimage);
- flag = gtk_drawing_area_new ();
- gtk_widget_add_events (GTK_WIDGET (flag),
- GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (flag), "draw",
- G_CALLBACK (draw_flag), image);
- gtk_container_add (GTK_CONTAINER (ebox), flag);
- } else {
- char *lbl_title = NULL;
- char *layout_name = NULL;
- GtkWidget *label;
- static GHashTable *ln2cnt_map = NULL;
-
- layout_name =
- xfcekbd_indicator_extract_layout_name (group,
- globals.engine,
- &globals.kbd_cfg,
- globals.short_group_names,
- globals.full_group_names);
-
- lbl_title =
- xfcekbd_indicator_create_label_title (group,
- &ln2cnt_map,
- layout_name);
-
- label = gtk_label_new (lbl_title);
- gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
- gtk_widget_set_margin_start (label, 2);
- gtk_widget_set_margin_end (label, 2);
- gtk_widget_set_margin_top (label, 2);
- gtk_widget_set_margin_bottom (label, 2);
- g_free (lbl_title);
- gtk_label_set_angle (GTK_LABEL (label), gki->priv->angle);
-
- if (group + 1 ==
- xkl_engine_get_num_groups (globals.engine)) {
- g_hash_table_destroy (ln2cnt_map);
- ln2cnt_map = NULL;
- }
-
- gtk_container_add (GTK_CONTAINER (ebox), label);
- }
-
- g_signal_connect (G_OBJECT (ebox),
- "button_press_event",
- G_CALLBACK (xfcekbd_indicator_button_pressed), gki);
-
- g_signal_connect (G_OBJECT (gki),
- "key_press_event",
- G_CALLBACK (xfcekbd_indicator_key_pressed), gki);
-
- /* We have everything prepared for that size */
-
- return ebox;
+xfcekbd_indicator_prepare_drawing (XfcekbdIndicator *gki,
+ int group)
+{
+ gpointer pimage;
+ GdkPixbuf *image;
+ GtkWidget *ebox;
+
+ pimage = g_slist_nth_data (globals.images, group);
+ ebox = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
+ if (globals.ind_cfg.show_flags) {
+ GtkWidget *flag;
+ if (pimage == NULL)
+ return NULL;
+ image = GDK_PIXBUF (pimage);
+ flag = gtk_drawing_area_new ();
+ gtk_widget_add_events (GTK_WIDGET (flag),
+ GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (G_OBJECT (flag), "draw",
+ G_CALLBACK (draw_flag), image);
+ gtk_container_add (GTK_CONTAINER (ebox), flag);
+ } else {
+ char *lbl_title = NULL;
+ char *layout_name = NULL;
+ GtkWidget *label;
+ static GHashTable *ln2cnt_map = NULL;
+
+ layout_name =
+ xfcekbd_indicator_extract_layout_name (group,
+ globals.engine,
+ &globals.kbd_cfg,
+ globals.short_group_names,
+ globals.full_group_names);
+
+ lbl_title =
+ xfcekbd_indicator_create_label_title (group,
+ &ln2cnt_map,
+ layout_name);
+
+ label = gtk_label_new (lbl_title);
+ gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+ gtk_widget_set_margin_start (label, 2);
+ gtk_widget_set_margin_end (label, 2);
+ gtk_widget_set_margin_top (label, 2);
+ gtk_widget_set_margin_bottom (label, 2);
+ g_free (lbl_title);
+ gtk_label_set_angle (GTK_LABEL (label), gki->priv->angle);
+
+ if (group + 1 == xkl_engine_get_num_groups (globals.engine))
+ {
+ g_hash_table_destroy (ln2cnt_map);
+ ln2cnt_map = NULL;
+ }
+
+ gtk_container_add (GTK_CONTAINER (ebox), label);
+ }
+
+ g_signal_connect (G_OBJECT (ebox),
+ "button_press_event",
+ G_CALLBACK (xfcekbd_indicator_button_pressed), gki);
+
+ g_signal_connect (G_OBJECT (gki),
+ "key_press_event",
+ G_CALLBACK (xfcekbd_indicator_key_pressed), gki);
+
+ /* We have everything prepared for that size */
+
+ return ebox;
}
static void
-xfcekbd_indicator_update_tooltips (XfcekbdIndicator * gki)
+xfcekbd_indicator_update_tooltips (XfcekbdIndicator *gki)
{
- XklState *state = xkl_engine_get_current_state (globals.engine);
- gchar *buf;
- if (state == NULL || state->group < 0
- || state->group >= g_strv_length (globals.full_group_names))
- return;
+ XklState *state = xkl_engine_get_current_state (globals.engine);
+ gchar *buf;
+ if (state == NULL ||
+ state->group < 0 ||
+ state->group >= g_strv_length (globals.full_group_names))
+ {
+ return;
+ }
- buf = g_strdup_printf (globals.tooltips_format,
- globals.full_group_names[state->group]);
+ buf = g_strdup_printf (globals.tooltips_format, globals.full_group_names[state->group]);
- xfcekbd_indicator_set_tooltips (gki, buf);
- g_free (buf);
+ xfcekbd_indicator_set_tooltips (gki, buf);
+ g_free (buf);
}
static void
-xfcekbd_indicator_parent_set (GtkWidget * gki, GtkWidget * previous_parent)
+xfcekbd_indicator_parent_set (GtkWidget *gki,
+ GtkWidget *previous_parent)
{
- xfcekbd_indicator_update_tooltips (XFCEKBD_INDICATOR (gki));
+ xfcekbd_indicator_update_tooltips (XFCEKBD_INDICATOR (gki));
}
static void
-xfcekbd_indicator_reinit_ui (XfcekbdIndicator * gki)
+xfcekbd_indicator_reinit_ui (XfcekbdIndicator *gki)
{
- xfcekbd_indicator_cleanup (gki);
- xfcekbd_indicator_fill (gki);
+ xfcekbd_indicator_cleanup (gki);
+ xfcekbd_indicator_fill (gki);
- xfcekbd_indicator_set_current_page (gki);
+ xfcekbd_indicator_set_current_page (gki);
- g_signal_emit_by_name (gki, "reinit-ui");
+ g_signal_emit_by_name (gki, "reinit-ui");
}
/* Should be called once for all widgets */
static void
xfcekbd_indicator_cfg_changed (XfconfChannel *channel,
- gchar *key,
- gpointer user_data)
+ gchar *key,
+ gpointer user_data)
{
- xkl_debug (100,
- "General configuration changed in Xfconf - reiniting...\n");
- xfcekbd_desktop_config_load_from_xfconf (&globals.cfg);
- xfcekbd_desktop_config_activate (&globals.cfg);
- ForAllIndicators () {
- xfcekbd_indicator_reinit_ui (gki);
- } NextIndicator ();
+ xkl_debug (100, "General configuration changed in Xfconf - reiniting...\n");
+ xfcekbd_desktop_config_load_from_xfconf (&globals.cfg);
+ xfcekbd_desktop_config_activate (&globals.cfg);
+ ForAllIndicators () {
+ xfcekbd_indicator_reinit_ui (gki);
+ } NextIndicator ();
}
/* Should be called once for all widgets */
static void
xfcekbd_indicator_ind_cfg_changed (XfconfChannel *channel,
- gchar *key,
- gpointer user_data)
+ gchar *key,
+ gpointer user_data)
{
- xkl_debug (100,
- "Applet configuration changed in Xfconf - reiniting...\n");
- xfcekbd_indicator_config_load_from_xfconf (&globals.ind_cfg);
- xfcekbd_indicator_update_images ();
- xfcekbd_indicator_config_activate (&globals.ind_cfg);
+ xkl_debug (100, "Applet configuration changed in Xfconf - reiniting...\n");
+ xfcekbd_indicator_config_load_from_xfconf (&globals.ind_cfg);
+ xfcekbd_indicator_update_images ();
+ xfcekbd_indicator_config_activate (&globals.ind_cfg);
- ForAllIndicators () {
- xfcekbd_indicator_reinit_ui (gki);
- } NextIndicator ();
+ ForAllIndicators () {
+ xfcekbd_indicator_reinit_ui (gki);
+ } NextIndicator ();
}
static void
-xfcekbd_indicator_load_group_names (const gchar ** layout_ids,
- const gchar ** variant_ids)
-{
- if (!xfcekbd_desktop_config_load_group_descriptions
- (&globals.cfg, globals.registry, layout_ids, variant_ids,
- &globals.short_group_names, &globals.full_group_names)) {
- /* We just populate no short names (remain NULL) -
- * full names are going to be used anyway */
- gint i, total_groups =
- xkl_engine_get_num_groups (globals.engine);
- globals.full_group_names =
- g_new0 (gchar *, total_groups + 1);
-
- if (xkl_engine_get_features (globals.engine) &
- XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
- gchar **lst = globals.kbd_cfg.layouts_variants;
- for (i = 0; *lst; lst++, i++) {
- globals.full_group_names[i] =
- g_strdup ((char *) *lst);
- }
- } else {
- for (i = total_groups; --i >= 0;) {
- globals.full_group_names[i] =
- g_strdup_printf ("Group %d", i);
- }
- }
- }
+xfcekbd_indicator_load_group_names (const gchar **layout_ids,
+ const gchar **variant_ids)
+{
+ if (!xfcekbd_desktop_config_load_group_descriptions (&globals.cfg,
+ globals.registry,
+ layout_ids,
+ variant_ids,
+ &globals.short_group_names,
+ &globals.full_group_names))
+ {
+ /* We just populate no short names (remain NULL) -
+ * full names are going to be used anyway */
+ gint i, total_groups = xkl_engine_get_num_groups (globals.engine);
+ globals.full_group_names = g_new0 (gchar *, total_groups + 1);
+
+ if (xkl_engine_get_features (globals.engine) & XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
+ gchar **lst = globals.kbd_cfg.layouts_variants;
+ for (i = 0; *lst; lst++, i++) {
+ globals.full_group_names[i] = g_strdup ((char *) *lst);
+ }
+ } else {
+ for (i = total_groups; --i >= 0;) {
+ globals.full_group_names[i] = g_strdup_printf ("Group %d", i);
+ }
+ }
+ }
}
/* Should be called once for all widgets */
static void
-xfcekbd_indicator_kbd_cfg_callback (XfcekbdIndicator * gki)
+xfcekbd_indicator_kbd_cfg_callback (XfcekbdIndicator *gki)
{
- XklConfigRec *xklrec = xkl_config_rec_new ();
- xkl_debug (100,
- "XKB configuration changed on X Server - reiniting...\n");
+ XklConfigRec *xklrec = xkl_config_rec_new ();
+ xkl_debug (100, "XKB configuration changed on X Server - reiniting...\n");
- xfcekbd_keyboard_config_load_from_x_current (&globals.kbd_cfg,
- xklrec);
- xfcekbd_indicator_update_images ();
+ xfcekbd_keyboard_config_load_from_x_current (&globals.kbd_cfg, xklrec);
+ xfcekbd_indicator_update_images ();
- g_strfreev (globals.full_group_names);
- globals.full_group_names = NULL;
+ g_strfreev (globals.full_group_names);
+ globals.full_group_names = NULL;
- if (globals.short_group_names != NULL) {
- g_strfreev (globals.short_group_names);
- globals.short_group_names = NULL;
- }
+ if (globals.short_group_names != NULL) {
+ g_strfreev (globals.short_group_names);
+ globals.short_group_names = NULL;
+ }
- xfcekbd_indicator_load_group_names ((const gchar **) xklrec->layouts,
- (const gchar **)
- xklrec->variants);
+ xfcekbd_indicator_load_group_names ((const gchar **) xklrec->layouts,
+ (const gchar **)
+ xklrec->variants);
- ForAllIndicators () {
- xfcekbd_indicator_reinit_ui (gki);
- } NextIndicator ();
- g_object_unref (G_OBJECT (xklrec));
+ ForAllIndicators () {
+ xfcekbd_indicator_reinit_ui (gki);
+ } NextIndicator ();
+ g_object_unref (G_OBJECT (xklrec));
}
/* Should be called once for all applets */
static void
-xfcekbd_indicator_state_callback (XklEngine * engine,
- XklEngineStateChange changeType,
- gint group, gboolean restore)
+xfcekbd_indicator_state_callback (XklEngine *engine,
+ XklEngineStateChange changeType,
+ gint group,
+ gboolean restore)
{
- xkl_debug (150, "group is now %d, restore: %d\n", group, restore);
+ xkl_debug (150, "group is now %d, restore: %d\n", group, restore);
- if (changeType == GROUP_CHANGED) {
- ForAllIndicators () {
- xkl_debug (200, "do repaint\n");
- xfcekbd_indicator_set_current_page_for_group
- (gki, group);
- }
- NextIndicator ();
- }
+ if (changeType == GROUP_CHANGED) {
+ ForAllIndicators () {
+ xkl_debug (200, "do repaint\n");
+ xfcekbd_indicator_set_current_page_for_group
+ (gki, group);
+ }
+ NextIndicator ();
+ }
}
void
-xfcekbd_indicator_set_current_page (XfcekbdIndicator * gki)
+xfcekbd_indicator_set_current_page (XfcekbdIndicator *gki)
{
- XklState *cur_state;
- cur_state = xkl_engine_get_current_state (globals.engine);
- if (cur_state->group >= 0)
- xfcekbd_indicator_set_current_page_for_group (gki,
- cur_state->
- group);
+ XklState *cur_state;
+ cur_state = xkl_engine_get_current_state (globals.engine);
+ if (cur_state->group >= 0)
+ xfcekbd_indicator_set_current_page_for_group (gki,
+ cur_state->group);
}
void
-xfcekbd_indicator_set_current_page_for_group (XfcekbdIndicator * gki, int group)
+xfcekbd_indicator_set_current_page_for_group (XfcekbdIndicator *gki,
+ int group)
{
- xkl_debug (200, "Revalidating for group %d\n", group);
+ xkl_debug (200, "Revalidating for group %d\n", group);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (gki), group + 1);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (gki), group + 1);
- xfcekbd_indicator_update_tooltips (gki);
+ xfcekbd_indicator_update_tooltips (gki);
}
/* Should be called once for all widgets */
static GdkFilterReturn
-xfcekbd_indicator_filter_x_evt (GdkXEvent * xev, GdkEvent * event)
-{
- XEvent *xevent = (XEvent *) xev;
-
- xkl_engine_filter_events (globals.engine, xevent);
- switch (xevent->type) {
- case ReparentNotify:
- {
- XReparentEvent *rne = (XReparentEvent *) xev;
-
- ForAllIndicators () {
- GdkWindow *w =
- gtk_widget_get_parent_window
- (GTK_WIDGET (gki));
-
- /* compare the indicator's parent window with the even window */
- if (w != NULL
- && GDK_WINDOW_XID (w) == rne->window) {
- /* if so - make it transparent... */
- xkl_engine_set_window_transparent
- (globals.engine, rne->window,
- TRUE);
- }
- }
- NextIndicator ()
- }
- break;
- }
- return GDK_FILTER_CONTINUE;
+xfcekbd_indicator_filter_x_evt (GdkXEvent *xev,
+ GdkEvent *event)
+{
+ XEvent *xevent = (XEvent *) xev;
+
+ xkl_engine_filter_events (globals.engine, xevent);
+ switch (xevent->type) {
+ case ReparentNotify:
+ {
+ XReparentEvent *rne = (XReparentEvent *) xev;
+
+ ForAllIndicators () {
+ GdkWindow *w =
+ gtk_widget_get_parent_window
+ (GTK_WIDGET (gki));
+
+ /* compare the indicator's parent window with the even window */
+ if (w != NULL
+ && GDK_WINDOW_XID (w) == rne->window) {
+ /* if so - make it transparent... */
+ xkl_engine_set_window_transparent
+ (globals.engine, rne->window,
+ TRUE);
+ }
+ }
+ NextIndicator ()
+ }
+ break;
+ }
+ return GDK_FILTER_CONTINUE;
}
@@ -632,221 +629,215 @@ xfcekbd_indicator_filter_x_evt (GdkXEvent * xev, GdkEvent * event)
static void
xfcekbd_indicator_start_listen (void)
{
- gdk_window_add_filter (NULL, (GdkFilterFunc)
- xfcekbd_indicator_filter_x_evt, NULL);
- gdk_window_add_filter (gdk_get_default_root_window (),
- (GdkFilterFunc)
- xfcekbd_indicator_filter_x_evt, NULL);
+ gdk_window_add_filter (NULL, (GdkFilterFunc)
+ xfcekbd_indicator_filter_x_evt, NULL);
+ gdk_window_add_filter (gdk_get_default_root_window (),
+ (GdkFilterFunc) xfcekbd_indicator_filter_x_evt, NULL);
- xkl_engine_start_listen (globals.engine,
- XKLL_TRACK_KEYBOARD_STATE);
+ xkl_engine_start_listen (globals.engine,
+ XKLL_TRACK_KEYBOARD_STATE);
}
/* Should be called once for all widgets */
static void
xfcekbd_indicator_stop_listen (void)
{
- xkl_engine_stop_listen (globals.engine, XKLL_TRACK_KEYBOARD_STATE);
+ xkl_engine_stop_listen (globals.engine, XKLL_TRACK_KEYBOARD_STATE);
- gdk_window_remove_filter (NULL, (GdkFilterFunc)
- xfcekbd_indicator_filter_x_evt, NULL);
- gdk_window_remove_filter
- (gdk_get_default_root_window (),
- (GdkFilterFunc) xfcekbd_indicator_filter_x_evt, NULL);
+ gdk_window_remove_filter (NULL, (GdkFilterFunc)
+ xfcekbd_indicator_filter_x_evt, NULL);
+ gdk_window_remove_filter (gdk_get_default_root_window (),
+ (GdkFilterFunc) xfcekbd_indicator_filter_x_evt,
+ NULL);
}
static gboolean
-xfcekbd_indicator_scroll (GtkWidget * gki, GdkEventScroll * event)
+xfcekbd_indicator_scroll (GtkWidget *gki,
+ GdkEventScroll *event)
{
- /* mouse wheel events should be ignored, otherwise funny effects appear */
- return TRUE;
+ /* mouse wheel events should be ignored, otherwise funny effects appear */
+ return TRUE;
}
-static void xfcekbd_indicator_init(XfcekbdIndicator* gki)
+static void xfcekbd_indicator_init(XfcekbdIndicator *gki)
{
- GtkWidget *def_drawing;
- GtkNotebook *notebook;
+ GtkWidget *def_drawing;
+ GtkNotebook *notebook;
- if (!g_slist_length(globals.widget_instances))
- {
- xfcekbd_indicator_global_init();
- }
+ if (!g_slist_length(globals.widget_instances))
+ {
+ xfcekbd_indicator_global_init();
+ }
- gki->priv = g_new0 (XfcekbdIndicatorPrivate, 1);
+ gki->priv = g_new0 (XfcekbdIndicatorPrivate, 1);
- notebook = GTK_NOTEBOOK (gki);
+ notebook = GTK_NOTEBOOK (gki);
- xkl_debug (100, "Initiating the widget startup process for %p\n", gki);
+ xkl_debug (100, "Initiating the widget startup process for %p\n", gki);
- gtk_notebook_set_show_tabs (notebook, FALSE);
- gtk_notebook_set_show_border (notebook, FALSE);
+ gtk_notebook_set_show_tabs (notebook, FALSE);
+ gtk_notebook_set_show_border (notebook, FALSE);
- def_drawing =
- gtk_image_new_from_icon_name ("process-stop",
- GTK_ICON_SIZE_BUTTON);
+ def_drawing = gtk_image_new_from_icon_name ("process-stop",
+ GTK_ICON_SIZE_BUTTON);
- gtk_notebook_append_page (notebook, def_drawing,
- gtk_label_new (""));
+ gtk_notebook_append_page (notebook, def_drawing, gtk_label_new (""));
- if (globals.engine == NULL) {
- xfcekbd_indicator_set_tooltips (gki,
- _
- ("XKB initialization error"));
- return;
- }
+ if (globals.engine == NULL) {
+ xfcekbd_indicator_set_tooltips (gki, _("XKB initialization error"));
+ return;
+ }
- xfcekbd_indicator_set_tooltips (gki, NULL);
+ xfcekbd_indicator_set_tooltips (gki, NULL);
- xfcekbd_indicator_fill (gki);
- xfcekbd_indicator_set_current_page (gki);
+ xfcekbd_indicator_fill (gki);
+ xfcekbd_indicator_set_current_page (gki);
- gtk_widget_add_events (GTK_WIDGET (gki), GDK_BUTTON_PRESS_MASK);
+ gtk_widget_add_events (GTK_WIDGET (gki), GDK_BUTTON_PRESS_MASK);
- /* append AFTER all initialization work is finished */
- globals.widget_instances =
- g_slist_append (globals.widget_instances, gki);
+ /* append AFTER all initialization work is finished */
+ globals.widget_instances =
+ g_slist_append (globals.widget_instances, gki);
}
static void
-xfcekbd_indicator_finalize (GObject * obj)
+xfcekbd_indicator_finalize (GObject *obj)
{
- XfcekbdIndicator *gki = XFCEKBD_INDICATOR (obj);
- xkl_debug (100,
- "Starting the xfce-kbd-indicator widget shutdown process for %p\n",
- gki);
+ XfcekbdIndicator *gki = XFCEKBD_INDICATOR (obj);
+ xkl_debug (100,
+ "Starting the xfce-kbd-indicator widget shutdown process for %p\n",
+ gki);
- /* remove BEFORE all termination work is finished */
- globals.widget_instances =
- g_slist_remove (globals.widget_instances, gki);
+ /* remove BEFORE all termination work is finished */
+ globals.widget_instances = g_slist_remove (globals.widget_instances, gki);
- xfcekbd_indicator_cleanup (gki);
+ xfcekbd_indicator_cleanup (gki);
- xkl_debug (100,
- "The instance of xfce-kbd-indicator successfully finalized\n");
+ xkl_debug (100,
+ "The instance of xfce-kbd-indicator successfully finalized\n");
- g_free (gki->priv);
+ g_free (gki->priv);
- G_OBJECT_CLASS (xfcekbd_indicator_parent_class)->finalize (obj);
+ G_OBJECT_CLASS (xfcekbd_indicator_parent_class)->finalize (obj);
- if (!g_slist_length (globals.widget_instances))
- xfcekbd_indicator_global_term ();
+ if (!g_slist_length (globals.widget_instances))
+ xfcekbd_indicator_global_term ();
}
static void
xfcekbd_indicator_global_term (void)
{
- xkl_debug (100, "*** Last XfcekbdIndicator instance *** \n");
- xfcekbd_indicator_stop_listen ();
+ xkl_debug (100, "*** Last XfcekbdIndicator instance ***\n");
+ xfcekbd_indicator_stop_listen ();
- xfcekbd_desktop_config_stop_listen (&globals.cfg);
- xfcekbd_indicator_config_stop_listen (&globals.ind_cfg);
+ xfcekbd_desktop_config_stop_listen (&globals.cfg);
+ xfcekbd_indicator_config_stop_listen (&globals.ind_cfg);
- xfcekbd_indicator_config_term (&globals.ind_cfg);
- xfcekbd_keyboard_config_term (&globals.kbd_cfg);
- xfcekbd_desktop_config_term (&globals.cfg);
+ xfcekbd_indicator_config_term (&globals.ind_cfg);
+ xfcekbd_keyboard_config_term (&globals.kbd_cfg);
+ xfcekbd_desktop_config_term (&globals.cfg);
- g_object_unref (G_OBJECT (globals.registry));
- globals.registry = NULL;
- g_object_unref (G_OBJECT (globals.engine));
- globals.engine = NULL;
- xkl_debug (100, "*** Terminated globals *** \n");
+ g_object_unref (G_OBJECT (globals.registry));
+ globals.registry = NULL;
+ g_object_unref (G_OBJECT (globals.engine));
+ globals.engine = NULL;
+ xkl_debug (100, "*** Terminated globals *** \n");
}
static void
-xfcekbd_indicator_class_init (XfcekbdIndicatorClass * klass)
+xfcekbd_indicator_class_init (XfcekbdIndicatorClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- xkl_debug (100, "*** First XfcekbdIndicator instance *** \n");
+ xkl_debug (100, "*** First XfcekbdIndicator instance *** \n");
- memset (&globals, 0, sizeof (globals));
+ memset (&globals, 0, sizeof (globals));
- /* Initing some global vars */
- globals.tooltips_format = "%s";
+ /* Initing some global vars */
+ globals.tooltips_format = "%s";
- /* Initing vtable */
- object_class->finalize = xfcekbd_indicator_finalize;
+ /* Initing vtable */
+ object_class->finalize = xfcekbd_indicator_finalize;
- widget_class->scroll_event = xfcekbd_indicator_scroll;
- widget_class->parent_set = xfcekbd_indicator_parent_set;
+ widget_class->scroll_event = xfcekbd_indicator_scroll;
+ widget_class->parent_set = xfcekbd_indicator_parent_set;
- /* Signals */
- g_signal_new ("reinit-ui", XFCEKBD_TYPE_INDICATOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (XfcekbdIndicatorClass, reinit_ui),
- NULL, NULL, xfcekbd_indicator_VOID__VOID,
- G_TYPE_NONE, 0);
+ /* Signals */
+ g_signal_new ("reinit-ui",
+ XFCEKBD_TYPE_INDICATOR,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (XfcekbdIndicatorClass, reinit_ui),
+ NULL, NULL, xfcekbd_indicator_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
xfcekbd_indicator_global_init (void)
{
- XklConfigRec *xklrec = xkl_config_rec_new ();
+ XklConfigRec *xklrec = xkl_config_rec_new ();
- globals.engine = xkl_engine_get_instance(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+ globals.engine = xkl_engine_get_instance(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
- if (globals.engine == NULL)
- {
- xkl_debug (0, "Libxklavier initialization error");
- return;
- }
+ if (globals.engine == NULL)
+ {
+ xkl_debug (0, "Libxklavier initialization error");
+ return;
+ }
- g_signal_connect (globals.engine, "X-state-changed",
- G_CALLBACK (xfcekbd_indicator_state_callback),
- NULL);
- g_signal_connect (globals.engine, "X-config-changed",
- G_CALLBACK (xfcekbd_indicator_kbd_cfg_callback),
- NULL);
+ g_signal_connect (globals.engine,
+ "X-state-changed",
+ G_CALLBACK (xfcekbd_indicator_state_callback),
+ NULL);
+ g_signal_connect (globals.engine,
+ "X-config-changed",
+ G_CALLBACK (xfcekbd_indicator_kbd_cfg_callback),
+ NULL);
- xfcekbd_desktop_config_init (&globals.cfg, globals.engine);
- xfcekbd_keyboard_config_init (&globals.kbd_cfg, globals.engine);
- xfcekbd_indicator_config_init (&globals.ind_cfg, globals.engine);
+ xfcekbd_desktop_config_init (&globals.cfg, globals.engine);
+ xfcekbd_keyboard_config_init (&globals.kbd_cfg, globals.engine);
+ xfcekbd_indicator_config_init (&globals.ind_cfg, globals.engine);
- xfcekbd_desktop_config_start_listen (&globals.cfg,
- (GCallback)
- xfcekbd_indicator_cfg_changed,
- NULL);
- xfcekbd_indicator_config_start_listen (&globals.ind_cfg,
- (GCallback)
- xfcekbd_indicator_ind_cfg_changed,
- NULL);
+ xfcekbd_desktop_config_start_listen (&globals.cfg,
+ (GCallback)
+ xfcekbd_indicator_cfg_changed,
+ NULL);
+ xfcekbd_indicator_config_start_listen (&globals.ind_cfg,
+ (GCallback)
+ xfcekbd_indicator_ind_cfg_changed,
+ NULL);
- xfcekbd_desktop_config_load_from_xfconf (&globals.cfg);
- xfcekbd_desktop_config_activate (&globals.cfg);
+ xfcekbd_desktop_config_load_from_xfconf (&globals.cfg);
+ xfcekbd_desktop_config_activate (&globals.cfg);
- globals.registry =
- xkl_config_registry_get_instance (globals.engine);
- xkl_config_registry_load (globals.registry,
- globals.cfg.load_extra_items);
+ globals.registry = xkl_config_registry_get_instance (globals.engine);
+ xkl_config_registry_load (globals.registry, globals.cfg.load_extra_items);
- xfcekbd_keyboard_config_load_from_x_current (&globals.kbd_cfg,
- xklrec);
+ xfcekbd_keyboard_config_load_from_x_current (&globals.kbd_cfg, xklrec);
- xfcekbd_indicator_config_load_from_xfconf (&globals.ind_cfg);
- xfcekbd_indicator_update_images ();
- xfcekbd_indicator_config_activate (&globals.ind_cfg);
+ xfcekbd_indicator_config_load_from_xfconf (&globals.ind_cfg);
+ xfcekbd_indicator_update_images ();
+ xfcekbd_indicator_config_activate (&globals.ind_cfg);
- xfcekbd_indicator_load_group_names ((const gchar **) xklrec->layouts,
- (const gchar **)
- xklrec->variants);
- g_object_unref (G_OBJECT (xklrec));
+ xfcekbd_indicator_load_group_names ((const gchar **) xklrec->layouts,
+ (const gchar **)
+ xklrec->variants);
+ g_object_unref (G_OBJECT (xklrec));
- xfcekbd_indicator_start_listen ();
+ xfcekbd_indicator_start_listen ();
- xkl_debug (100, "*** Inited globals *** \n");
+ xkl_debug (100, "*** Inited globals *** \n");
}
GtkWidget *
xfcekbd_indicator_new (void)
{
- return
- GTK_WIDGET (g_object_new (xfcekbd_indicator_get_type (), NULL));
+ return GTK_WIDGET (g_object_new (xfcekbd_indicator_get_type (), NULL));
}
void
xfcekbd_indicator_set_parent_tooltips (XfcekbdIndicator * gki, gboolean spt)
{
- gki->priv->set_parent_tooltips = spt;
- xfcekbd_indicator_update_tooltips (gki);
+ gki->priv->set_parent_tooltips = spt;
+ xfcekbd_indicator_update_tooltips (gki);
}
diff --git a/src/xfcekbd-indicator.h b/src/xfcekbd-indicator.h
index 3aeef25..b8fdb4f 100644
--- a/src/xfcekbd-indicator.h
+++ b/src/xfcekbd-indicator.h
@@ -28,9 +28,9 @@
extern "C" {
#endif
- typedef struct _XfcekbdIndicator XfcekbdIndicator;
- typedef struct _XfcekbdIndicatorPrivate XfcekbdIndicatorPrivate;
- typedef struct _XfcekbdIndicatorClass XfcekbdIndicatorClass;
+typedef struct _XfcekbdIndicator XfcekbdIndicator;
+typedef struct _XfcekbdIndicatorPrivate XfcekbdIndicatorPrivate;
+typedef struct _XfcekbdIndicatorClass XfcekbdIndicatorClass;
#define XFCEKBD_TYPE_INDICATOR (xfcekbd_indicator_get_type ())
#define XFCEKBD_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCEKBD_TYPE_INDICATOR, XfcekbdIndicator))
@@ -39,24 +39,23 @@ extern "C" {
#define XFCEKBD_IS_INDICATOR_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XFCEKBD_TYPE_INDICATOR))
#define XFCEKBD_INDICATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCEKBD_TYPE_INDICATOR, XfcekbdIndicatorClass))
- struct _XfcekbdIndicator {
- GtkNotebook parent;
- XfcekbdIndicatorPrivate *priv;
- };
+struct _XfcekbdIndicator {
+ GtkNotebook parent;
+ XfcekbdIndicatorPrivate *priv;
+};
- struct _XfcekbdIndicatorClass {
- GtkNotebookClass parent_class;
+struct _XfcekbdIndicatorClass {
+ GtkNotebookClass parent_class;
- void (*reinit_ui) (XfcekbdIndicator * gki);
- };
+ void (*reinit_ui) (XfcekbdIndicator * gki);
+};
- extern GType xfcekbd_indicator_get_type (void);
+extern GType xfcekbd_indicator_get_type (void);
- extern GtkWidget *xfcekbd_indicator_new (void);
+extern GtkWidget * xfcekbd_indicator_new (void);
- extern void
- xfcekbd_indicator_set_parent_tooltips (XfcekbdIndicator *
- gki, gboolean ifset);
+extern void xfcekbd_indicator_set_parent_tooltips (XfcekbdIndicator *gki,
+ gboolean ifset);
#ifdef __cplusplus
}
diff --git a/src/xfcekbd-keyboard-config.c b/src/xfcekbd-keyboard-config.c
index 984385d..3d993a2 100644
--- a/src/xfcekbd-keyboard-config.c
+++ b/src/xfcekbd-keyboard-config.c
@@ -37,200 +37,202 @@
* extern common functions
*/
static const gchar *
-xfcekbd_keyboard_config_merge_items (const gchar * parent,
- const gchar * child)
+xfcekbd_keyboard_config_merge_items (const gchar *parent,
+ const gchar *child)
{
- static gchar buffer[XKL_MAX_CI_NAME_LENGTH * 2 - 1];
- *buffer = '\0';
- if (parent != NULL) {
- if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH)
- return NULL;
- strcat (buffer, parent);
- }
- if (child != NULL && *child != 0) {
- if (strlen (child) >= XKL_MAX_CI_NAME_LENGTH)
- return NULL;
- strcat (buffer, "\t");
- strcat (buffer, child);
- }
- return buffer;
+ static gchar buffer[XKL_MAX_CI_NAME_LENGTH * 2 - 1];
+ *buffer = '\0';
+ if (parent != NULL) {
+ if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH)
+ return NULL;
+ strcat (buffer, parent);
+ }
+ if (child != NULL && *child != 0) {
+ if (strlen (child) >= XKL_MAX_CI_NAME_LENGTH)
+ return NULL;
+ strcat (buffer, "\t");
+ strcat (buffer, child);
+ }
+ return buffer;
}
gboolean
-xfcekbd_keyboard_config_split_items (const gchar * merged, gchar ** parent,
- gchar ** child)
+xfcekbd_keyboard_config_split_items (const gchar *merged,
+ gchar **parent,
+ gchar **child)
{
- static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH];
- static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH];
- int plen, clen;
- const gchar *pos;
- *parent = *child = NULL;
-
- if (merged == NULL)
- return FALSE;
-
- pos = strchr (merged, '\t');
- if (pos == NULL) {
- plen = strlen (merged);
- clen = 0;
- } else {
- plen = pos - merged;
- clen = strlen (pos + 1);
- if (clen >= XKL_MAX_CI_NAME_LENGTH)
- return FALSE;
- strcpy (*child = cbuffer, pos + 1);
- }
- if (plen >= XKL_MAX_CI_NAME_LENGTH)
- return FALSE;
- memcpy (*parent = pbuffer, merged, plen);
- pbuffer[plen] = '\0';
- return TRUE;
+ static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH];
+ static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH];
+ int plen, clen;
+ const gchar *pos;
+ *parent = *child = NULL;
+
+ if (merged == NULL)
+ return FALSE;
+
+ pos = strchr (merged, '\t');
+ if (pos == NULL) {
+ plen = strlen (merged);
+ clen = 0;
+ } else {
+ plen = pos - merged;
+ clen = strlen (pos + 1);
+ if (clen >= XKL_MAX_CI_NAME_LENGTH)
+ return FALSE;
+ strcpy (*child = cbuffer, pos + 1);
+ }
+ if (plen >= XKL_MAX_CI_NAME_LENGTH)
+ return FALSE;
+ memcpy (*parent = pbuffer, merged, plen);
+ pbuffer[plen] = '\0';
+ return TRUE;
}
/*
* static XfcekbdKeyboardConfig functions
*/
static void
-xfcekbd_keyboard_config_copy_from_xkl_config (XfcekbdKeyboardConfig * kbd_config,
- XklConfigRec * pdata)
+xfcekbd_keyboard_config_copy_from_xkl_config (XfcekbdKeyboardConfig *kbd_config,
+ XklConfigRec *pdata)
{
- char **p, **p1;
- int i;
- xfcekbd_keyboard_config_model_set (kbd_config, pdata->model);
- xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model);
-
- /* Layouts */
- g_strfreev (kbd_config->layouts_variants);
- kbd_config->layouts_variants = NULL;
- if (pdata->layouts != NULL) {
- p = pdata->layouts;
- p1 = pdata->variants;
- kbd_config->layouts_variants =
- g_new0 (gchar *, g_strv_length (pdata->layouts) + 1);
- i = 0;
- while (*p != NULL) {
- const gchar *full_layout =
- xfcekbd_keyboard_config_merge_items (*p, *p1);
- xkl_debug (150,
- "Loaded Kbd layout (with variant): [%s]\n",
- full_layout);
- kbd_config->layouts_variants[i++] =
- g_strdup (full_layout);
- p++;
- p1++;
- }
- }
-
- /* Options */
- g_strfreev (kbd_config->options);
- kbd_config->options = NULL;
-
- if (pdata->options != NULL) {
- p = pdata->options;
- kbd_config->options =
- g_new0 (gchar *, g_strv_length (pdata->options) + 1);
- i = 0;
- while (*p != NULL) {
- char group[XKL_MAX_CI_NAME_LENGTH];
- char *option = *p;
- char *delim =
- (option != NULL) ? strchr (option, ':') : NULL;
- int len;
- if ((delim != NULL) &&
- ((len =
- (delim - option)) <
- XKL_MAX_CI_NAME_LENGTH)) {
- strncpy (group, option, len);
- group[len] = 0;
- xkl_debug (150,
- "Loaded Kbd option: [%s][%s]\n",
- group, option);
- xfcekbd_keyboard_config_options_set
- (kbd_config, i++, group, option);
- }
- p++;
- }
- }
+ char **p, **p1;
+ int i;
+
+ xfcekbd_keyboard_config_model_set (kbd_config, pdata->model);
+ xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model);
+
+ /* Layouts */
+ g_strfreev (kbd_config->layouts_variants);
+ kbd_config->layouts_variants = NULL;
+ if (pdata->layouts != NULL) {
+ p = pdata->layouts;
+ p1 = pdata->variants;
+ kbd_config->layouts_variants =
+ g_new0 (gchar *, g_strv_length (pdata->layouts) + 1);
+ i = 0;
+ while (*p != NULL) {
+ const gchar *full_layout =
+ xfcekbd_keyboard_config_merge_items (*p, *p1);
+ xkl_debug (150,
+ "Loaded Kbd layout (with variant): [%s]\n",
+ full_layout);
+ kbd_config->layouts_variants[i++] =
+ g_strdup (full_layout);
+ p++;
+ p1++;
+ }
+ }
+
+ /* Options */
+ g_strfreev (kbd_config->options);
+ kbd_config->options = NULL;
+
+ if (pdata->options != NULL) {
+ p = pdata->options;
+ kbd_config->options =
+ g_new0 (gchar *, g_strv_length (pdata->options) + 1);
+ i = 0;
+ while (*p != NULL) {
+ char group[XKL_MAX_CI_NAME_LENGTH];
+ char *option = *p;
+ char *delim =
+ (option != NULL) ? strchr (option, ':') : NULL;
+ int len;
+ if ((delim != NULL) &&
+ ((len =
+ (delim - option)) <
+ XKL_MAX_CI_NAME_LENGTH)) {
+ strncpy (group, option, len);
+ group[len] = 0;
+ xkl_debug (150,
+ "Loaded Kbd option: [%s][%s]\n",
+ group, option);
+ xfcekbd_keyboard_config_options_set
+ (kbd_config, i++, group, option);
+ }
+ p++;
+ }
+ }
}
/*
* extern XfcekbdKeyboardConfig config functions
*/
void
-xfcekbd_keyboard_config_init (XfcekbdKeyboardConfig * kbd_config,
- XklEngine * engine)
+xfcekbd_keyboard_config_init (XfcekbdKeyboardConfig *kbd_config,
+ XklEngine *engine)
{
- memset (kbd_config, 0, sizeof (*kbd_config));
- kbd_config->engine = engine;
+ memset (kbd_config, 0, sizeof (*kbd_config));
+ kbd_config->engine = engine;
}
void
-xfcekbd_keyboard_config_term (XfcekbdKeyboardConfig * kbd_config)
+xfcekbd_keyboard_config_term (XfcekbdKeyboardConfig *kbd_config)
{
- xfcekbd_keyboard_config_model_set (kbd_config, NULL);
+ xfcekbd_keyboard_config_model_set (kbd_config, NULL);
- g_strfreev (kbd_config->layouts_variants);
- kbd_config->layouts_variants = NULL;
- g_strfreev (kbd_config->options);
- kbd_config->options = NULL;
+ g_strfreev (kbd_config->layouts_variants);
+ kbd_config->layouts_variants = NULL;
+ g_strfreev (kbd_config->options);
+ kbd_config->options = NULL;
}
void
-xfcekbd_keyboard_config_load_from_x_current (XfcekbdKeyboardConfig * kbd_config,
- XklConfigRec * data)
+xfcekbd_keyboard_config_load_from_x_current (XfcekbdKeyboardConfig *kbd_config,
+ XklConfigRec *data)
{
- gboolean own_data = data == NULL;
- xkl_debug (150, "Copying config from X(current)\n");
- if (own_data)
- data = xkl_config_rec_new ();
- if (xkl_config_rec_get_from_server (data, kbd_config->engine))
- xfcekbd_keyboard_config_copy_from_xkl_config (kbd_config,
- data);
- else
- xkl_debug (150,
- "Could not load keyboard config from server: [%s]\n",
- xkl_get_last_error ());
- if (own_data)
- g_object_unref (G_OBJECT (data));
+ gboolean own_data = data == NULL;
+ xkl_debug (150, "Copying config from X(current)\n");
+ if (own_data)
+ data = xkl_config_rec_new ();
+ if (xkl_config_rec_get_from_server (data, kbd_config->engine))
+ xfcekbd_keyboard_config_copy_from_xkl_config (kbd_config,
+ data);
+ else
+ xkl_debug (150,
+ "Could not load keyboard config from server: [%s]\n",
+ xkl_get_last_error ());
+ if (own_data)
+ g_object_unref (G_OBJECT (data));
}
void
-xfcekbd_keyboard_config_model_set (XfcekbdKeyboardConfig * kbd_config,
- const gchar * model_name)
+xfcekbd_keyboard_config_model_set (XfcekbdKeyboardConfig *kbd_config,
+ const gchar *model_name)
{
- if (kbd_config->model != NULL)
- g_free (kbd_config->model);
- kbd_config->model =
- (model_name == NULL
- || model_name[0] == '\0') ? NULL : g_strdup (model_name);
+ if (kbd_config->model != NULL)
+ g_free (kbd_config->model);
+ kbd_config->model =
+ (model_name == NULL
+ || model_name[0] == '\0') ? NULL : g_strdup (model_name);
}
void
-xfcekbd_keyboard_config_options_set (XfcekbdKeyboardConfig * kbd_config,
- gint idx,
- const gchar * group_name,
- const gchar * option_name)
+xfcekbd_keyboard_config_options_set (XfcekbdKeyboardConfig *kbd_config,
+ gint idx,
+ const gchar *group_name,
+ const gchar *option_name)
{
- const gchar *merged;
- if (group_name == NULL || option_name == NULL)
- return;
- merged =
- xfcekbd_keyboard_config_merge_items (group_name, option_name);
- if (merged == NULL)
- return;
- kbd_config->options[idx] = g_strdup (merged);
+ const gchar *merged;
+ if (group_name == NULL || option_name == NULL)
+ return;
+ merged =
+ xfcekbd_keyboard_config_merge_items (group_name, option_name);
+ if (merged == NULL)
+ return;
+ kbd_config->options[idx] = g_strdup (merged);
}
const gchar *
-xfcekbd_keyboard_config_format_full_layout (const gchar * layout_descr,
- const gchar * variant_descr)
+xfcekbd_keyboard_config_format_full_layout (const gchar *layout_descr,
+ const gchar *variant_descr)
{
- static gchar full_descr[XKL_MAX_CI_DESC_LENGTH * 2];
- if (variant_descr == NULL || variant_descr[0] == 0)
- g_snprintf (full_descr, sizeof (full_descr), "%s",
- layout_descr);
- else
- g_snprintf (full_descr, sizeof (full_descr), "%s %s",
- layout_descr, variant_descr);
- return full_descr;
+ static gchar full_descr[XKL_MAX_CI_DESC_LENGTH * 2];
+ if (variant_descr == NULL || variant_descr[0] == 0)
+ g_snprintf (full_descr, sizeof (full_descr), "%s",
+ layout_descr);
+ else
+ g_snprintf (full_descr, sizeof (full_descr), "%s %s",
+ layout_descr, variant_descr);
+ return full_descr;
}
diff --git a/src/xfcekbd-keyboard-config.h b/src/xfcekbd-keyboard-config.h
index 2971393..041627b 100644
--- a/src/xfcekbd-keyboard-config.h
+++ b/src/xfcekbd-keyboard-config.h
@@ -34,34 +34,30 @@ extern const gchar XFCEKBD_KEYBOARD_CONFIG_KEY_OPTIONS[];
*/
typedef struct _XfcekbdKeyboardConfig XfcekbdKeyboardConfig;
struct _XfcekbdKeyboardConfig {
- gchar *model;
- gchar **layouts_variants;
- gchar **options;
+ gchar *model;
+ gchar **layouts_variants;
+ gchar **options;
- /* private, transient */
- int config_listener_id;
- XklEngine *engine;
+ /* private, transient */
+ int config_listener_id;
+ XklEngine *engine;
};
/*
* XfcekbdKeyboardConfig functions
*/
-extern void xfcekbd_keyboard_config_init (XfcekbdKeyboardConfig * kbd_config,
- XklEngine * engine);
-extern void xfcekbd_keyboard_config_term (XfcekbdKeyboardConfig * kbd_config);
+extern void xfcekbd_keyboard_config_init (XfcekbdKeyboardConfig *kbd_config,
+ XklEngine *engine);
+extern void xfcekbd_keyboard_config_term (XfcekbdKeyboardConfig *kbd_config);
-extern void xfcekbd_keyboard_config_load_from_x_current (XfcekbdKeyboardConfig *
- kbd_config,
- XklConfigRec * buf);
+extern void xfcekbd_keyboard_config_load_from_x_current (XfcekbdKeyboardConfig *kbd_config,
+ XklConfigRec *buf);
-extern gboolean xfcekbd_keyboard_config_split_items (const gchar * merged,
- gchar ** parent,
- gchar ** child);
+extern gboolean xfcekbd_keyboard_config_split_items (const gchar *merged,
+ gchar **parent,
+ gchar **child);
-extern const gchar *xfcekbd_keyboard_config_format_full_layout (const gchar
- *
- layout_descr,
- const gchar *
- variant_descr);
+extern const gchar * xfcekbd_keyboard_config_format_full_layout (const gchar *layout_descr,
+ const gchar *variant_descr);
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list