gnome-session r4905 - in trunk: . capplet compat gnome-session splash tools
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4905 - in trunk: . capplet compat gnome-session splash tools
- Date: Mon, 4 Aug 2008 19:05:22 +0000 (UTC)
Author: mccann
Date: Mon Aug 4 19:05:21 2008
New Revision: 4905
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4905&view=rev
Log:
2008-08-04 William Jon McCann <jmccann redhat com>
* capplet/commands.c (system_desktop_entry_exists), (find_by_id),
(ensure_user_autostart_dir), (key_file_to_file),
(key_file_set_locale_string), (delete_desktop_file),
(write_desktop_file), (append_app), (compare_app),
(append_autostart_apps), (spc_command_get_store),
(spc_command_enable_app), (spc_command_disable_app),
(spc_command_add_app):
* capplet/main.c (main):
* capplet/ui.c (make_exec_uri), (cmd_browse_button_clicked_cb),
(entry_activate_cb), (edit_app_dialog), (selection_changed_cb),
(startup_enabled_toggled_cb), (add_from_desktop_file),
(drag_data_cb), (setup_treeview), (add_app_cb), (delete_app_cb),
(edit_app_cb), (autosave_value_notify), (autosave_value_toggled),
(help_cb):
* compat/at-spi-registryd-wrapper.c (registry_ior_watch),
(set_gtk_modules), (main):
* compat/gnome-keyring-daemon-wrapper.c (keyring_daemon_stop),
(child_setup), (keyring_daemon_start), (quit), (main):
* compat/gnome-settings-daemon-helper.c (set_gtk1_theme_rcfile):
* gnome-session/gsm-gconf.c (gsm_gconf_init), (gsm_gconf_check),
(gsm_gconf_shutdown):
* gnome-session/gsm-util.c (gsm_util_get_autostart_dirs),
(gsm_util_get_app_dirs), (gsm_util_text_is_blank),
(gsm_util_init_error), (gsm_util_generate_startup_id),
(gsm_util_update_activation_environment), (gsm_util_setenv):
* splash/gnome-login-sound.c (get_sound_file_from_config),
(get_sound_file), (maybe_play_sound):
* splash/gnome-session-splash.c (get_session_bus),
(set_session_running_handler), (event_func), (splash_clicked),
(filter_func), (load_pixbuf), (load_splash_pixbuf), (main):
* splash/splash-window.c (re_scale), (splash_window_expose_event),
(splash_window_realize), (splash_icon_destroy),
(splash_window_finalize), (layout_icon), (re_laydown),
(update_trans_effect), (gsm_splash_window_new),
(gsm_splash_window_start), (gsm_splash_window_finish):
* tools/gnome-session-save.c (ping_reply), (ice_ping), (die_cb),
(cancelled_cb), (display_error), (ice_connection_watch),
(get_session_bus), (set_session_name), (main):
Some cosmetic / code-style changes requested by Lucas.
Modified:
trunk/ChangeLog
trunk/capplet/commands.c
trunk/capplet/commands.h
trunk/capplet/main.c
trunk/capplet/ui.c
trunk/capplet/ui.h
trunk/compat/at-spi-registryd-wrapper.c
trunk/compat/gnome-keyring-daemon-wrapper.c
trunk/compat/gnome-settings-daemon-helper.c
trunk/gnome-session/gsm-gconf.c
trunk/gnome-session/gsm-util.c
trunk/splash/gnome-login-sound.c
trunk/splash/gnome-session-splash.c
trunk/splash/splash-window.c
trunk/splash/splash-window.h
trunk/tools/gnome-session-save.c
Modified: trunk/capplet/commands.c
==============================================================================
--- trunk/capplet/commands.c (original)
+++ trunk/capplet/commands.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* commands.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * commands.c
* Copyright (C) 1999 Free Software Foundation, Inc.
* Copyright (C) 2007 Vincent Untz.
* Copyright (C) 2008 Lucas Rocha.
@@ -33,764 +34,767 @@
#define DESKTOP_ENTRY_GROUP "Desktop Entry"
#define STARTUP_APP_ICON "gnome-run"
-#define REALLY_IDENTICAL_STRING(a, b) \
- ((a && b && !strcmp (a, b)) || (!a && !b))
+#define REALLY_IDENTICAL_STRING(a, b) \
+ ((a && b && !strcmp (a, b)) || (!a && !b))
static gboolean
system_desktop_entry_exists (const char *basename,
char **system_path)
{
- char *path;
- char **autostart_dirs;
- int i;
+ char *path;
+ char **autostart_dirs;
+ int i;
+
+ autostart_dirs = gsm_util_get_autostart_dirs ();
+
+ for (i = 0; autostart_dirs[i]; i++) {
+ path = g_build_filename (autostart_dirs[i], basename, NULL);
+
+ if (g_str_has_prefix (autostart_dirs[i], g_get_user_config_dir ())) {
+ continue;
+ }
+
+ if (g_file_test (path, G_FILE_TEST_EXISTS)) {
+ if (system_path) {
+ *system_path = path;
+ } else {
+ g_free (path);
+ }
+ g_strfreev (autostart_dirs);
- autostart_dirs = gsm_util_get_autostart_dirs ();
+ return TRUE;
+ }
- for (i = 0; autostart_dirs[i]; i++)
- {
- path = g_build_filename (autostart_dirs[i], basename, NULL);
-
- if (g_str_has_prefix (autostart_dirs[i], g_get_user_config_dir ()))
- continue;
-
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- {
- if (system_path)
- *system_path = path;
- else
- g_free (path);
-
- g_strfreev (autostart_dirs);
-
- return TRUE;
+ g_free (path);
}
- g_free (path);
- }
+ g_strfreev (autostart_dirs);
- g_strfreev (autostart_dirs);
-
- return FALSE;
+ return FALSE;
}
static void
-update_desktop_file (GtkListStore *store,
- GtkTreeIter *iter,
+update_desktop_file (GtkListStore *store,
+ GtkTreeIter *iter,
EggDesktopFile *new_desktop_file)
{
- EggDesktopFile *old_desktop_file;
+ EggDesktopFile *old_desktop_file;
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_DESKTOP_FILE, &old_desktop_file,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_DESKTOP_FILE, &old_desktop_file,
+ -1);
- egg_desktop_file_free (old_desktop_file);
+ egg_desktop_file_free (old_desktop_file);
- gtk_list_store_set (store, iter,
- STORE_COL_DESKTOP_FILE, new_desktop_file,
- -1);
+ gtk_list_store_set (store, iter,
+ STORE_COL_DESKTOP_FILE, new_desktop_file,
+ -1);
}
-static gboolean
-find_by_id (GtkListStore *store, const gchar *id)
+static gboolean
+find_by_id (GtkListStore *store,
+ const char *id)
{
- GtkTreeIter iter;
- gchar *iter_id = NULL;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
- return FALSE;
-
- do
- {
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
- STORE_COL_ID, &iter_id,
- -1);
+ GtkTreeIter iter;
+ char *iter_id = NULL;
- if (!strcmp (iter_id, id))
- {
- return TRUE;
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) {
+ return FALSE;
}
- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
- return FALSE;
+ do {
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ STORE_COL_ID, &iter_id,
+ -1);
+
+ if (!strcmp (iter_id, id)) {
+ return TRUE;
+ }
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
+
+ return FALSE;
}
static void
ensure_user_autostart_dir ()
{
- gchar *dir;
-
- dir = g_build_filename (g_get_user_config_dir (), "autostart", NULL);
- g_mkdir_with_parents (dir, S_IRWXU);
+ char *dir;
- g_free (dir);
-}
-
-static gboolean
-key_file_to_file (GKeyFile *keyfile,
- const gchar *file,
- GError **error)
-{
- GError *write_error;
- gchar *filename;
- gchar *data;
- gsize length;
- gboolean res;
-
- g_return_val_if_fail (keyfile != NULL, FALSE);
- g_return_val_if_fail (file != NULL, FALSE);
-
- write_error = NULL;
-
- data = g_key_file_to_data (keyfile, &length, &write_error);
-
- if (write_error)
- {
- g_propagate_error (error, write_error);
- return FALSE;
- }
-
- if (!g_path_is_absolute (file))
- filename = g_filename_from_uri (file, NULL, &write_error);
- else
- filename = g_filename_from_utf8 (file, -1, NULL, NULL, &write_error);
-
- if (write_error)
- {
- g_propagate_error (error, write_error);
- g_free (data);
- return FALSE;
- }
-
- res = g_file_set_contents (filename, data, length, &write_error);
-
- g_free (filename);
-
- if (write_error)
- {
- g_propagate_error (error, write_error);
- g_free (data);
- return FALSE;
- }
+ dir = g_build_filename (g_get_user_config_dir (), "autostart", NULL);
+ g_mkdir_with_parents (dir, S_IRWXU);
- g_free (data);
-
- return res;
+ g_free (dir);
}
-static void
-key_file_set_locale_string (GKeyFile *keyfile,
- const gchar *group,
- const gchar *key,
- const gchar *value)
-{
- const char *locale;
- const char * const *langs_pointer;
- int i;
-
- locale = NULL;
- langs_pointer = g_get_language_names ();
-
- for (i = 0; langs_pointer[i] != NULL; i++)
- {
- /* Find first without encoding */
- if (strchr (langs_pointer[i], '.') == NULL)
- {
- locale = langs_pointer[i];
- break;
- }
- }
-
- if (locale)
- g_key_file_set_locale_string (keyfile, group,
- key, locale, value);
- else
- g_key_file_set_string (keyfile, "Desktop Entry", key, value);
-}
-
-static void
-delete_desktop_file (GtkListStore *store, GtkTreeIter *iter)
-{
- EggDesktopFile *desktop_file;
- GFile *source;
- char *basename, *path;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_DESKTOP_FILE, &desktop_file,
- -1);
+static gboolean
+key_file_to_file (GKeyFile *keyfile,
+ const char *file,
+ GError **error)
+{
+ GError *write_error;
+ char *filename;
+ char *data;
+ gsize length;
+ gboolean res;
+
+ g_return_val_if_fail (keyfile != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ write_error = NULL;
+
+ data = g_key_file_to_data (keyfile, &length, &write_error);
+
+ if (write_error) {
+ g_propagate_error (error, write_error);
+ return FALSE;
+ }
- source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
+ if (!g_path_is_absolute (file)) {
+ filename = g_filename_from_uri (file, NULL, &write_error);
+ } else {
+ filename = g_filename_from_utf8 (file, -1, NULL, NULL, &write_error);
+ }
- path = g_file_get_path (source);
- basename = g_file_get_basename (source);
+ if (write_error) {
+ g_propagate_error (error, write_error);
+ g_free (data);
+ return FALSE;
+ }
- if (g_str_has_prefix (path, g_get_user_config_dir ()) &&
- !system_desktop_entry_exists (basename, NULL))
- {
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- g_remove (path);
- }
- else
- {
- /* Two possible cases:
- * a) We want to remove a system wide startup desktop file.
- * We can't do that, so we will create a user desktop file
- * with the hidden flag set.
- * b) We want to remove a startup desktop file that is both
- * system and user. So we have to mark it as hidden.
- */
- GKeyFile *keyfile;
- GError *error;
- char *user_path;
+ res = g_file_set_contents (filename, data, length, &write_error);
- ensure_user_autostart_dir ();
+ g_free (filename);
- keyfile = g_key_file_new ();
+ if (write_error) {
+ g_propagate_error (error, write_error);
+ g_free (data);
+ return FALSE;
+ }
- error = NULL;
+ g_free (data);
- g_key_file_load_from_file (keyfile, path,
- G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
+ return res;
+}
- if (error)
- {
- g_error_free (error);
- g_key_file_free (keyfile);
+static void
+key_file_set_locale_string (GKeyFile *keyfile,
+ const char *group,
+ const char *key,
+ const char *value)
+{
+ const char *locale;
+ const char * const *langs_pointer;
+ int i;
+
+ locale = NULL;
+ langs_pointer = g_get_language_names ();
+
+ for (i = 0; langs_pointer[i] != NULL; i++) {
+ /* Find first without encoding */
+ if (strchr (langs_pointer[i], '.') == NULL) {
+ locale = langs_pointer[i];
+ break;
+ }
}
- g_key_file_set_boolean (keyfile, DESKTOP_ENTRY_GROUP,
- "Hidden", TRUE);
-
- user_path = g_build_filename (g_get_user_config_dir (),
- "autostart", basename, NULL);
+ if (locale) {
+ g_key_file_set_locale_string (keyfile, group,
+ key, locale, value);
+ } else {
+ g_key_file_set_string (keyfile, "Desktop Entry", key, value);
+ }
+}
- if (!key_file_to_file (keyfile, user_path, NULL))
- g_warning ("Could not save %s file", user_path);
+static void
+delete_desktop_file (GtkListStore *store,
+ GtkTreeIter *iter)
+{
+ EggDesktopFile *desktop_file;
+ GFile *source;
+ char *basename;
+ char *path;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_DESKTOP_FILE, &desktop_file,
+ -1);
+
+ source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
+
+ path = g_file_get_path (source);
+ basename = g_file_get_basename (source);
+
+ if (g_str_has_prefix (path, g_get_user_config_dir ()) &&
+ !system_desktop_entry_exists (basename, NULL)) {
+ if (g_file_test (path, G_FILE_TEST_EXISTS))
+ g_remove (path);
+ } else {
+ /* Two possible cases:
+ * a) We want to remove a system wide startup desktop file.
+ * We can't do that, so we will create a user desktop file
+ * with the hidden flag set.
+ * b) We want to remove a startup desktop file that is both
+ * system and user. So we have to mark it as hidden.
+ */
+ GKeyFile *keyfile;
+ GError *error;
+ char *user_path;
+
+ ensure_user_autostart_dir ();
+
+ keyfile = g_key_file_new ();
+
+ error = NULL;
+
+ g_key_file_load_from_file (keyfile, path,
+ G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error);
+
+ if (error) {
+ g_error_free (error);
+ g_key_file_free (keyfile);
+ }
+
+ g_key_file_set_boolean (keyfile, DESKTOP_ENTRY_GROUP,
+ "Hidden", TRUE);
+
+ user_path = g_build_filename (g_get_user_config_dir (),
+ "autostart", basename, NULL);
+
+ if (!key_file_to_file (keyfile, user_path, NULL)) {
+ g_warning ("Could not save %s file", user_path);
+ }
- g_key_file_free (keyfile);
+ g_key_file_free (keyfile);
- g_free (user_path);
- }
+ g_free (user_path);
+ }
- g_object_unref (source);
- g_free (path);
- g_free (basename);
+ g_object_unref (source);
+ g_free (path);
+ g_free (basename);
}
static void
write_desktop_file (EggDesktopFile *desktop_file,
- GtkListStore *store,
- GtkTreeIter *iter,
+ GtkListStore *store,
+ GtkTreeIter *iter,
gboolean enabled)
{
- GKeyFile *keyfile;
- GFile *source;
- GError *error;
- gchar *path, *name, *command, *comment;
- gboolean path_changed = FALSE;
+ GKeyFile *keyfile;
+ GFile *source;
+ GError *error;
+ char *path;
+ char *name;
+ char *command;
+ char *comment;
+ gboolean path_changed = FALSE;
- ensure_user_autostart_dir ();
+ ensure_user_autostart_dir ();
- keyfile = g_key_file_new ();
+ keyfile = g_key_file_new ();
- source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
+ source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
- path = g_file_get_path (source);
+ path = g_file_get_path (source);
- error = NULL;
+ error = NULL;
- g_key_file_load_from_file (keyfile, path,
- G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
+ g_key_file_load_from_file (keyfile, path,
+ G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error);
- if (error)
- goto out;
-
- if (!g_str_has_prefix (path, g_get_user_config_dir ()))
- {
- /* It's a system-wide file, save it to the user's home */
- gchar *basename;
-
- basename = g_file_get_basename (source);
-
- g_free (path);
+ if (error) {
+ goto out;
+ }
- path = g_build_filename (g_get_user_config_dir (),
- "autostart", basename, NULL);
+ if (!g_str_has_prefix (path, g_get_user_config_dir ())) {
+ /* It's a system-wide file, save it to the user's home */
+ char *basename;
- g_free (basename);
+ basename = g_file_get_basename (source);
- path_changed = TRUE;
- }
+ g_free (path);
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_NAME, &name,
- STORE_COL_COMMAND, &command,
- STORE_COL_COMMENT, &comment,
- -1);
+ path = g_build_filename (g_get_user_config_dir (),
+ "autostart", basename, NULL);
- key_file_set_locale_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Name", name);
+ g_free (basename);
- key_file_set_locale_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Comment", comment);
+ path_changed = TRUE;
+ }
- g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Exec", command);
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_NAME, &name,
+ STORE_COL_COMMAND, &command,
+ STORE_COL_COMMENT, &comment,
+ -1);
+
+ key_file_set_locale_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Name", name);
+
+ key_file_set_locale_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Comment", comment);
+
+ g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Exec", command);
+
+ g_key_file_set_boolean (keyfile,
+ DESKTOP_ENTRY_GROUP,
+ "X-GNOME-Autostart-enabled",
+ enabled);
- g_key_file_set_boolean (keyfile,
- DESKTOP_ENTRY_GROUP,
- "X-GNOME-Autostart-enabled",
- enabled);
+ if (!key_file_to_file (keyfile, path, &error)) {
+ goto out;
+ }
- if (!key_file_to_file (keyfile, path, &error))
- goto out;
+ if (path_changed) {
+ EggDesktopFile *new_desktop_file;
- if (path_changed)
- {
- EggDesktopFile *new_desktop_file;
+ new_desktop_file = egg_desktop_file_new (path, &error);
- new_desktop_file = egg_desktop_file_new (path, &error);
+ if (error) {
+ goto out;
+ }
- if (error)
- goto out;
-
- update_desktop_file (store, iter, new_desktop_file);
- }
+ update_desktop_file (store, iter, new_desktop_file);
+ }
-out:
- if (error)
- {
- g_warning ("Error when writing desktop file %s: %s",
- path, error->message);
+ out:
+ if (error) {
+ g_warning ("Error when writing desktop file %s: %s",
+ path, error->message);
- g_error_free (error);
- }
+ g_error_free (error);
+ }
- g_free (path);
- g_free (name);
- g_free (comment);
- g_free (command);
- g_object_unref (source);
- g_key_file_free (keyfile);
+ g_free (path);
+ g_free (name);
+ g_free (comment);
+ g_free (command);
+ g_object_unref (source);
+ g_key_file_free (keyfile);
}
-static gboolean
-append_app (GtkListStore *store, EggDesktopFile *desktop_file)
+static gboolean
+append_app (GtkListStore *store,
+ EggDesktopFile *desktop_file)
{
- GtkTreeIter iter;
- GFile *source;
- gchar *basename, *description, *name, *comment, *command, *icon_name;
- gboolean enabled = TRUE;
+ GtkTreeIter iter;
+ GFile *source;
+ char *basename;
+ char *description;
+ char *name;
+ char *comment;
+ char *command;
+ char *icon_name;
+ gboolean enabled = TRUE;
+
+ source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
+
+ basename = g_file_get_basename (source);
+
+ if (egg_desktop_file_has_key (desktop_file,
+ "Hidden", NULL)) {
+ if (egg_desktop_file_get_boolean (desktop_file,
+ "Hidden", NULL))
+ return FALSE;
+ }
- source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
+ /* Check for duplicate apps */
+ if (find_by_id (store, basename)) {
+ return TRUE;
+ }
- basename = g_file_get_basename (source);
+ name = egg_desktop_file_get_locale_string (desktop_file,
+ "Name", NULL, NULL);
- if (egg_desktop_file_has_key (desktop_file,
- "Hidden", NULL))
- {
- if (egg_desktop_file_get_boolean (desktop_file,
- "Hidden", NULL))
- return FALSE;
- }
+ comment = NULL;
- /* Check for duplicate apps */
- if (find_by_id (store, basename))
- return TRUE;
+ if (egg_desktop_file_has_key (desktop_file,
+ "Comment", NULL)) {
+ comment =
+ egg_desktop_file_get_locale_string (desktop_file,
+ "Comment", NULL, NULL);
+ }
- name = egg_desktop_file_get_locale_string (desktop_file,
- "Name", NULL, NULL);
+ description = spc_command_get_app_description (name, comment);
- comment = NULL;
+ command = egg_desktop_file_get_string (desktop_file,
+ "Exec", NULL);
- if (egg_desktop_file_has_key (desktop_file,
- "Comment", NULL))
- {
- comment =
- egg_desktop_file_get_locale_string (desktop_file,
- "Comment", NULL, NULL);
- }
+ icon_name = NULL;
- description = spc_command_get_app_description (name, comment);
-
- command = egg_desktop_file_get_string (desktop_file,
- "Exec", NULL);
+ if (egg_desktop_file_has_key (desktop_file,
+ "Icon", NULL)) {
+ icon_name =
+ egg_desktop_file_get_string (desktop_file,
+ "Icon", NULL);
+ }
- icon_name = NULL;
+ if (icon_name == NULL || *icon_name == '\0') {
+ icon_name = g_strdup (STARTUP_APP_ICON);
+ }
- if (egg_desktop_file_has_key (desktop_file,
- "Icon", NULL))
- {
- icon_name =
- egg_desktop_file_get_string (desktop_file,
- "Icon", NULL);
- }
+ if (egg_desktop_file_has_key (desktop_file,
+ "X-GNOME-Autostart-enabled", NULL)) {
+ enabled = egg_desktop_file_get_boolean (desktop_file,
+ "X-GNOME-Autostart-enabled",
+ NULL);
+ }
- if (icon_name == NULL || *icon_name == '\0')
- {
- icon_name = g_strdup (STARTUP_APP_ICON);
- }
+ gtk_list_store_append (store, &iter);
- if (egg_desktop_file_has_key (desktop_file,
- "X-GNOME-Autostart-enabled", NULL))
- {
- enabled = egg_desktop_file_get_boolean (desktop_file,
- "X-GNOME-Autostart-enabled",
- NULL);
- }
+ gtk_list_store_set (store, &iter,
+ STORE_COL_ENABLED, enabled,
+ STORE_COL_ICON_NAME, icon_name,
+ STORE_COL_DESCRIPTION, description,
+ STORE_COL_NAME, name,
+ STORE_COL_COMMAND, command,
+ STORE_COL_COMMENT, comment,
+ STORE_COL_DESKTOP_FILE, desktop_file,
+ STORE_COL_ID, basename,
+ STORE_COL_ACTIVATABLE, TRUE,
+ -1);
+
+ g_object_unref (source);
+ g_free (basename);
+ g_free (name);
+ g_free (comment);
+ g_free (description);
+ g_free (icon_name);
+
+ return TRUE;
+}
+
+static int
+compare_app (gconstpointer a,
+ gconstpointer b)
+{
+ if (!strcmp (a, b)) {
+ return 0;
+ }
- gtk_list_store_append (store, &iter);
+ return 1;
+}
+
+static void
+append_autostart_apps (GtkListStore *store,
+ const char *path,
+ GList **removed_apps)
+{
+ GDir *dir;
+ const char *name;
+
+ dir = g_dir_open (path, 0, NULL);
+ if (!dir) {
+ return;
+ }
- gtk_list_store_set (store, &iter,
- STORE_COL_ENABLED, enabled,
- STORE_COL_ICON_NAME, icon_name,
- STORE_COL_DESCRIPTION, description,
- STORE_COL_NAME, name,
- STORE_COL_COMMAND, command,
- STORE_COL_COMMENT, comment,
- STORE_COL_DESKTOP_FILE, desktop_file,
- STORE_COL_ID, basename,
- STORE_COL_ACTIVATABLE, TRUE,
- -1);
+ while ((name = g_dir_read_name (dir))) {
+ EggDesktopFile *desktop_file;
+ GError *error = NULL;
+ char *desktop_file_path;
+
+ if (!g_str_has_suffix (name, ".desktop")) {
+ continue;
+ }
+
+ if (removed_apps &&
+ g_list_find_custom (*removed_apps, name, compare_app)) {
+ continue;
+ }
+
+ desktop_file_path = g_build_filename (path, name, NULL);
+
+ desktop_file = egg_desktop_file_new (desktop_file_path, &error);
+
+ if (!error) {
+ if (!append_app (store, desktop_file)) {
+ if (removed_apps) {
+ *removed_apps = g_list_prepend (*removed_apps, g_strdup (name));
+ }
+ }
+ } else {
+ g_warning ("could not read %s: %s\n", desktop_file_path, error->message);
+
+ g_error_free (error);
+ error = NULL;
+ }
- g_object_unref (source);
- g_free (basename);
- g_free (name);
- g_free (comment);
- g_free (description);
- g_free (icon_name);
+ g_free (desktop_file_path);
+ }
- return TRUE;
+ g_dir_close (dir);
}
-static gint
-compare_app (gconstpointer a, gconstpointer b)
+GtkTreeModel *
+spc_command_get_store ()
{
- if (!strcmp (a, b))
- return 0;
+ GtkListStore *store;
+ GList *removed_apps;
+ char **autostart_dirs;
+ int i;
+
+ store = gtk_list_store_new (STORE_NUM_COLS,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_POINTER,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN);
+
+ autostart_dirs = gsm_util_get_autostart_dirs ();
+
+ removed_apps = NULL;
+
+ for (i = 0; autostart_dirs[i]; i++) {
+ append_autostart_apps (store, autostart_dirs[i], &removed_apps);
+ }
+
+ g_strfreev (autostart_dirs);
+ g_list_foreach (removed_apps, (GFunc) g_free, NULL);
+ g_list_free (removed_apps);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ STORE_COL_NAME,
+ GTK_SORT_ASCENDING);
- return 1;
+ return GTK_TREE_MODEL (store);
}
-static void
-append_autostart_apps (GtkListStore *store, const char *path, GList **removed_apps)
+gboolean
+spc_command_enable_app (GtkListStore *store,
+ GtkTreeIter *iter)
{
- GDir *dir;
- const char *name;
+ EggDesktopFile *desktop_file;
+ GFile *source;
+ char *system_path;
+ char *basename;
+ char *path;
+ char *name;
+ char *comment;
+ gboolean enabled;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_ENABLED, &enabled,
+ STORE_COL_NAME, &name,
+ STORE_COL_COMMENT, &comment,
+ STORE_COL_DESKTOP_FILE, &desktop_file,
+ -1);
- dir = g_dir_open (path, 0, NULL);
- if (!dir)
- return;
+ if (enabled) {
+ return TRUE;
+ }
- while ((name = g_dir_read_name (dir)))
- {
- EggDesktopFile *desktop_file;
- GError *error = NULL;
- char *desktop_file_path;
+ source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
- if (!g_str_has_suffix (name, ".desktop"))
- continue;
+ path = g_file_get_path (source);
- if (removed_apps &&
- g_list_find_custom (*removed_apps, name, compare_app))
- continue;
+ basename = g_file_get_basename (source);
- desktop_file_path = g_build_filename (path, name, NULL);
+ if (system_desktop_entry_exists (basename, &system_path)) {
+ EggDesktopFile *system_desktop_file;
+ char *original_name;
+ char *original_comment;
- desktop_file = egg_desktop_file_new (desktop_file_path, &error);
+ system_desktop_file = egg_desktop_file_new (system_path, NULL);
- if (!error)
- {
- if (!append_app (store, desktop_file))
- {
- if (removed_apps)
- *removed_apps =
- g_list_prepend (*removed_apps, g_strdup (name));
- }
- }
- else
- {
- g_warning ("could not read %s: %s\n", desktop_file_path, error->message);
+ original_name = egg_desktop_file_get_locale_string (system_desktop_file,
+ "Name", NULL, NULL);
- g_error_free (error);
- error = NULL;
- }
+ original_comment = egg_desktop_file_get_locale_string (system_desktop_file,
+ "Comment", NULL, NULL);
- g_free (desktop_file_path);
- }
+ if (REALLY_IDENTICAL_STRING (name, original_name) &&
+ REALLY_IDENTICAL_STRING (comment, original_comment)) {
+ char *user_file =
+ g_build_filename (g_get_user_config_dir (),
+ "autostart", basename, NULL);
- g_dir_close (dir);
-}
+ if (g_file_test (user_file, G_FILE_TEST_EXISTS)) {
+ g_remove (user_file);
+ }
-GtkTreeModel *
-spc_command_get_store ()
-{
- GtkListStore *store;
- GList *removed_apps;
- char **autostart_dirs;
- gint i;
-
- store = gtk_list_store_new (STORE_NUM_COLS,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_POINTER,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN);
-
- autostart_dirs = gsm_util_get_autostart_dirs ();
-
- removed_apps = NULL;
-
- for (i = 0; autostart_dirs[i]; i++)
- {
- append_autostart_apps (store, autostart_dirs[i], &removed_apps);
- }
-
- g_strfreev (autostart_dirs);
- g_list_foreach (removed_apps, (GFunc) g_free, NULL);
- g_list_free (removed_apps);
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
- STORE_COL_NAME,
- GTK_SORT_ASCENDING);
+ g_free (user_file);
- return GTK_TREE_MODEL (store);
-}
+ update_desktop_file (store, iter, system_desktop_file);
+ } else {
+ write_desktop_file (desktop_file, store, iter, TRUE);
+ egg_desktop_file_free (system_desktop_file);
+ }
-gboolean
-spc_command_enable_app (GtkListStore *store,
- GtkTreeIter *iter)
-{
- EggDesktopFile *desktop_file;
- GFile *source;
- char *system_path, *basename, *path;
- char *name, *comment;
- gboolean enabled;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_ENABLED, &enabled,
- STORE_COL_NAME, &name,
- STORE_COL_COMMENT, &comment,
- STORE_COL_DESKTOP_FILE, &desktop_file,
- -1);
-
- if (enabled)
- return TRUE;
-
- source = g_file_new_for_uri (egg_desktop_file_get_source (desktop_file));
-
- path = g_file_get_path (source);
-
- basename = g_file_get_basename (source);
-
- if (system_desktop_entry_exists (basename, &system_path))
- {
- EggDesktopFile *system_desktop_file;
-
- char *original_name, *original_comment;
-
- system_desktop_file = egg_desktop_file_new (system_path, NULL);
-
- original_name =
- egg_desktop_file_get_locale_string (system_desktop_file,
- "Name", NULL, NULL);
-
- original_comment =
- egg_desktop_file_get_locale_string (system_desktop_file,
- "Comment", NULL, NULL);
-
- if (REALLY_IDENTICAL_STRING (name, original_name) &&
- REALLY_IDENTICAL_STRING (comment, original_comment))
- {
- gchar *user_file =
- g_build_filename (g_get_user_config_dir (),
- "autostart", basename, NULL);
-
- if (g_file_test (user_file, G_FILE_TEST_EXISTS))
- g_remove (user_file);
-
- g_free (user_file);
-
- update_desktop_file (store, iter, system_desktop_file);
- }
- else
- {
- write_desktop_file (desktop_file, store, iter, TRUE);
- egg_desktop_file_free (system_desktop_file);
- }
-
- g_free (original_name);
- g_free (original_comment);
- }
- else
- {
- write_desktop_file (desktop_file, store, iter, TRUE);
- }
-
- g_free (name);
- g_free (comment);
- g_free (basename);
+ g_free (original_name);
+ g_free (original_comment);
+ } else {
+ write_desktop_file (desktop_file, store, iter, TRUE);
+ }
+
+ g_free (name);
+ g_free (comment);
+ g_free (basename);
- return TRUE;
+ return TRUE;
}
gboolean
-spc_command_disable_app (GtkListStore *store,
- GtkTreeIter *iter)
+spc_command_disable_app (GtkListStore *store,
+ GtkTreeIter *iter)
{
- EggDesktopFile *desktop_file;
- const gchar *source;
- gchar *basename;
- gboolean enabled;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_ENABLED, &enabled,
- STORE_COL_DESKTOP_FILE, &desktop_file,
- -1);
+ EggDesktopFile *desktop_file;
+ const char *source;
+ char *basename;
+ gboolean enabled;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_ENABLED, &enabled,
+ STORE_COL_DESKTOP_FILE, &desktop_file,
+ -1);
- if (!enabled)
- return TRUE;
+ if (!enabled) {
+ return TRUE;
+ }
- source = egg_desktop_file_get_source (desktop_file);
+ source = egg_desktop_file_get_source (desktop_file);
- basename = g_path_get_basename (source);
+ basename = g_path_get_basename (source);
- write_desktop_file (desktop_file, store, iter, FALSE);
+ write_desktop_file (desktop_file, store, iter, FALSE);
- g_free (basename);
+ g_free (basename);
- return TRUE;
+ return TRUE;
}
void
spc_command_add_app (GtkListStore *store,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EggDesktopFile *desktop_file;
- GKeyFile *keyfile;
- char **argv;
- char *basename, *orig_filename, *filename;
- char *name, *command, *comment, *description, *icon;
- int argc;
- int i = 2;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_NAME, &name,
- STORE_COL_COMMAND, &command,
- STORE_COL_COMMENT, &comment,
- STORE_COL_ICON_NAME, &icon,
- -1);
-
- g_shell_parse_argv (command, &argc, &argv, NULL);
-
- basename = g_path_get_basename (argv[0]);
-
- orig_filename = g_build_filename (g_get_user_config_dir (),
- "autostart", basename, NULL);
-
- filename = g_strdup_printf ("%s.desktop", orig_filename);
-
- while (g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- char *tmp = g_strdup_printf ("%s-%d.desktop", orig_filename, i);
-
- g_free (filename);
- filename = tmp;
-
- i++;
- }
-
- g_free (orig_filename);
-
- keyfile = g_key_file_new ();
-
- g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Type", "Application");
-
- g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Name", name);
-
- g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Exec", command);
-
- if (icon == NULL)
- {
- icon = g_strdup (STARTUP_APP_ICON);
- }
-
- g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Icon", icon);
-
- if (comment)
- g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
- "Comment", comment);
-
- description = spc_command_get_app_description (name, comment);
-
- if (!key_file_to_file (keyfile, filename, NULL))
- {
- g_warning ("Could not save %s file", filename);
- }
-
- desktop_file = egg_desktop_file_new_from_key_file (keyfile,
- filename,
- NULL);
-
- g_free (basename);
-
- basename = g_path_get_basename (filename);
-
- gtk_list_store_set (store, iter,
- STORE_COL_ENABLED, TRUE,
- STORE_COL_ICON_NAME, icon,
- STORE_COL_DESKTOP_FILE, desktop_file,
- STORE_COL_ID, basename,
- STORE_COL_ACTIVATABLE, TRUE,
- -1);
-
- g_key_file_free (keyfile);
- g_strfreev (argv);
- g_free (name);
- g_free (command);
- g_free (comment);
- g_free (description);
- g_free (basename);
- g_free (icon);
+ EggDesktopFile *desktop_file;
+ GKeyFile *keyfile;
+ char **argv;
+ char *basename;
+ char *orig_filename;
+ char *filename;
+ char *name;
+ char *command;
+ char *comment;
+ char *description;
+ char *icon;
+ int argc;
+ int i = 2;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_NAME, &name,
+ STORE_COL_COMMAND, &command,
+ STORE_COL_COMMENT, &comment,
+ STORE_COL_ICON_NAME, &icon,
+ -1);
+
+ g_shell_parse_argv (command, &argc, &argv, NULL);
+
+ basename = g_path_get_basename (argv[0]);
+
+ orig_filename = g_build_filename (g_get_user_config_dir (),
+ "autostart", basename, NULL);
+
+ filename = g_strdup_printf ("%s.desktop", orig_filename);
+
+ while (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ char *tmp = g_strdup_printf ("%s-%d.desktop", orig_filename, i);
+
+ g_free (filename);
+ filename = tmp;
+
+ i++;
+ }
+
+ g_free (orig_filename);
+
+ keyfile = g_key_file_new ();
+
+ g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Type", "Application");
+
+ g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Name", name);
+
+ g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Exec", command);
+
+ if (icon == NULL) {
+ icon = g_strdup (STARTUP_APP_ICON);
+ }
+
+ g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Icon", icon);
+
+ if (comment) {
+ g_key_file_set_string (keyfile, DESKTOP_ENTRY_GROUP,
+ "Comment", comment);
+ }
+
+ description = spc_command_get_app_description (name, comment);
+
+ if (!key_file_to_file (keyfile, filename, NULL)) {
+ g_warning ("Could not save %s file", filename);
+ }
+
+ desktop_file = egg_desktop_file_new_from_key_file (keyfile,
+ filename,
+ NULL);
+
+ g_free (basename);
+
+ basename = g_path_get_basename (filename);
+
+ gtk_list_store_set (store, iter,
+ STORE_COL_ENABLED, TRUE,
+ STORE_COL_ICON_NAME, icon,
+ STORE_COL_DESKTOP_FILE, desktop_file,
+ STORE_COL_ID, basename,
+ STORE_COL_ACTIVATABLE, TRUE,
+ -1);
+
+ g_key_file_free (keyfile);
+ g_strfreev (argv);
+ g_free (name);
+ g_free (command);
+ g_free (comment);
+ g_free (description);
+ g_free (basename);
+ g_free (icon);
}
void
-spc_command_delete_app (GtkListStore *store,
- GtkTreeIter *iter)
+spc_command_delete_app (GtkListStore *store,
+ GtkTreeIter *iter)
{
- delete_desktop_file (store, iter);
+ delete_desktop_file (store, iter);
}
void
-spc_command_update_app (GtkListStore *store,
- GtkTreeIter *iter)
+spc_command_update_app (GtkListStore *store,
+ GtkTreeIter *iter)
{
- EggDesktopFile *desktop_file;
- gboolean enabled;
+ EggDesktopFile *desktop_file;
+ gboolean enabled;
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_ENABLED, &enabled,
- STORE_COL_DESKTOP_FILE, &desktop_file,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_ENABLED, &enabled,
+ STORE_COL_DESKTOP_FILE, &desktop_file,
+ -1);
- write_desktop_file (desktop_file, store, iter, enabled);
+ write_desktop_file (desktop_file, store, iter, enabled);
}
char *
spc_command_get_app_description (const char *name,
const char *comment)
{
- return g_markup_printf_escaped ("<b>%s</b>\n%s", name,
- (!gsm_util_text_is_blank (comment) ?
- comment : _("No description")));
+ return g_markup_printf_escaped ("<b>%s</b>\n%s", name,
+ (!gsm_util_text_is_blank (comment) ?
+ comment : _("No description")));
}
Modified: trunk/capplet/commands.h
==============================================================================
--- trunk/capplet/commands.h (original)
+++ trunk/capplet/commands.h Mon Aug 4 19:05:21 2008
@@ -19,7 +19,7 @@
* 02111-1307, USA.
*/
-#ifndef __SESSION_PROPERTIES_COMMANDS_H__
+#ifndef __SESSION_PROPERTIES_COMMANDS_H__
#define __SESSION_PROPERTIES_COMMANDS_H__
#include <gtk/gtk.h>
@@ -36,22 +36,22 @@
STORE_COL_COMMENT,
STORE_COL_DESKTOP_FILE,
STORE_COL_ID,
- STORE_COL_ACTIVATABLE,
- STORE_NUM_COLS
+ STORE_COL_ACTIVATABLE,
+ STORE_NUM_COLS
};
GtkTreeModel* spc_command_get_store (void);
-gboolean spc_command_enable_app (GtkListStore *store,
+gboolean spc_command_enable_app (GtkListStore *store,
GtkTreeIter *iter);
-gboolean spc_command_disable_app (GtkListStore *store,
+gboolean spc_command_disable_app (GtkListStore *store,
GtkTreeIter *iter);
void spc_command_add_app (GtkListStore *store,
GtkTreeIter *iter);
-void spc_command_delete_app (GtkListStore *store,
+void spc_command_delete_app (GtkListStore *store,
GtkTreeIter *iter);
void spc_command_update_app (GtkListStore *store,
Modified: trunk/capplet/main.c
==============================================================================
--- trunk/capplet/main.c (original)
+++ trunk/capplet/main.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* main.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * main.c
* Copyright (C) 1999 Free Software Foundation, Inc.
* Copyright (C) 2008 Lucas Rocha.
*
@@ -18,9 +19,7 @@
* 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <glib/gi18n.h>
@@ -35,49 +34,48 @@
int
main (int argc, char *argv[])
{
- GOptionContext *context;
- GConfClient *client;
- GnomeClient *master_client;
+ GOptionContext *context;
+ GConfClient *client;
+ GnomeClient *master_client;
- bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- context = g_option_context_new (" - GNOME Session Preferences");
+ context = g_option_context_new (" - GNOME Session Preferences");
- gnome_program_init ("gnome-session-properties", VERSION,
- LIBGNOMEUI_MODULE, argc, argv,
- GNOME_PARAM_GOPTION_CONTEXT, context,
- NULL);
+ gnome_program_init ("gnome-session-properties", VERSION,
+ LIBGNOMEUI_MODULE, argc, argv,
+ GNOME_PARAM_GOPTION_CONTEXT, context,
+ NULL);
- /* Don't restart the capplet, it's the place where the session is saved. */
- gnome_client_set_restart_style (gnome_master_client (), GNOME_RESTART_NEVER);
+ /* Don't restart the capplet, it's the place where the session is saved. */
+ gnome_client_set_restart_style (gnome_master_client (), GNOME_RESTART_NEVER);
- gtk_window_set_default_icon_name ("session-properties");
+ gtk_window_set_default_icon_name ("session-properties");
- client = gconf_client_get_default ();
+ client = gconf_client_get_default ();
- gconf_client_add_dir (client,
- SPC_GCONF_CONFIG_PREFIX,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ gconf_client_add_dir (client,
+ SPC_GCONF_CONFIG_PREFIX,
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ NULL);
- master_client = gnome_master_client ();
+ master_client = gnome_master_client ();
- if (!GNOME_CLIENT_CONNECTED (master_client))
- {
- g_printerr (_("Could not connect to the session manager\n"));
- return 1;
- }
+ if (!GNOME_CLIENT_CONNECTED (master_client)) {
+ g_printerr (_("Could not connect to the session manager\n"));
+ return 1;
+ }
- g_signal_connect (master_client,
- "die",
- G_CALLBACK (gtk_main_quit),
- NULL);
+ g_signal_connect (master_client,
+ "die",
+ G_CALLBACK (gtk_main_quit),
+ NULL);
- spc_ui_build (client);
+ spc_ui_build (client);
- gtk_main ();
+ gtk_main ();
- return 0;
+ return 0;
}
Modified: trunk/capplet/ui.c
==============================================================================
--- trunk/capplet/ui.c (original)
+++ trunk/capplet/ui.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* ui.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * ui.c
* Copyright (C) 1999 Free Software Foundation, Inc.
* Copyright (C) 2008 Lucas Rocha.
*
@@ -18,11 +19,13 @@
* 02111-1307, USA.
*/
+#include "config.h"
+
+#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
-#include <string.h>
#include <gconf/gconf-client.h>
#include <libgnomeui/gnome-help.h>
#include <glade/glade.h>
@@ -50,248 +53,254 @@
static char *
make_exec_uri (const char *exec)
{
- GString *str;
- const char *c;
+ GString *str;
+ const char *c;
- if (!exec)
- return g_strdup ("");
+ if (!exec) {
+ return g_strdup ("");
+ }
- if (!strchr (exec, ' '))
- return g_strdup (exec);
+ if (!strchr (exec, ' ')) {
+ return g_strdup (exec);
+ }
+
+ str = g_string_new_len (NULL, strlen (exec));
- str = g_string_new_len (NULL, strlen (exec));
-
- str = g_string_append_c (str, '"');
- for (c = exec; *c != '\0'; c++)
- {
- /* FIXME: GKeyFile will add an additional backslach so we'll
- * end up with toto\\" instead of toto\"
- * We could use g_key_file_set_value(), but then we don't
- * benefit from the other escaping that glib is doing...
- */
- if (*c == '"')
- str = g_string_append (str, "\\\"");
- else
- str = g_string_append_c (str, *c);
- }
- str = g_string_append_c (str, '"');
+ str = g_string_append_c (str, '"');
+ for (c = exec; *c != '\0'; c++) {
+ /* FIXME: GKeyFile will add an additional backslach so we'll
+ * end up with toto\\" instead of toto\"
+ * We could use g_key_file_set_value(), but then we don't
+ * benefit from the other escaping that glib is doing...
+ */
+ if (*c == '"') {
+ str = g_string_append (str, "\\\"");
+ } else {
+ str = g_string_append_c (str, *c);
+ }
+ }
+ str = g_string_append_c (str, '"');
- return g_string_free (str, FALSE);
+ return g_string_free (str, FALSE);
}
static void
cmd_browse_button_clicked_cb (GladeXML *xml)
{
- GtkWidget *chooser;
- GtkWidget *dlg;
- GtkWidget *cmd_entry;
- int response;
+ GtkWidget *chooser;
+ GtkWidget *dlg;
+ GtkWidget *cmd_entry;
+ int response;
- dlg = glade_xml_get_widget (xml, CAPPLET_EDIT_DIALOG_WIDGET_NAME);
+ dlg = glade_xml_get_widget (xml, CAPPLET_EDIT_DIALOG_WIDGET_NAME);
- cmd_entry = glade_xml_get_widget (xml, CAPPLET_COMMAND_ENTRY_WIDGET_NAME);
+ cmd_entry = glade_xml_get_widget (xml, CAPPLET_COMMAND_ENTRY_WIDGET_NAME);
- chooser = gtk_file_chooser_dialog_new ("", GTK_WINDOW (dlg),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN,
- GTK_RESPONSE_ACCEPT,
- NULL);
+ chooser = gtk_file_chooser_dialog_new ("", GTK_WINDOW (dlg),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
- gtk_window_set_transient_for (GTK_WINDOW (chooser),
- GTK_WINDOW (dlg));
+ gtk_window_set_transient_for (GTK_WINDOW (chooser),
+ GTK_WINDOW (dlg));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
- gtk_window_set_title (GTK_WINDOW (chooser), _("Select Command"));
+ gtk_window_set_title (GTK_WINDOW (chooser), _("Select Command"));
- gtk_widget_show (chooser);
+ gtk_widget_show (chooser);
- response = gtk_dialog_run (GTK_DIALOG (chooser));
+ response = gtk_dialog_run (GTK_DIALOG (chooser));
- if (response == GTK_RESPONSE_ACCEPT)
- {
- char *text;
- char *uri;
+ if (response == GTK_RESPONSE_ACCEPT) {
+ char *text;
+ char *uri;
- text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+ text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
- uri = make_exec_uri (text);
+ uri = make_exec_uri (text);
- g_free (text);
+ g_free (text);
- g_assert (cmd_entry != NULL);
+ g_assert (cmd_entry != NULL);
- gtk_entry_set_text (GTK_ENTRY (cmd_entry), uri);
+ gtk_entry_set_text (GTK_ENTRY (cmd_entry), uri);
- g_free (uri);
- }
+ g_free (uri);
+ }
- gtk_widget_destroy (chooser);
+ gtk_widget_destroy (chooser);
}
static void
-entry_activate_cb (GtkEntry *entry, void *data)
+entry_activate_cb (GtkEntry *entry,
+ void *data)
{
- gtk_dialog_response (GTK_DIALOG (data), GTK_RESPONSE_OK);
+ gtk_dialog_response (GTK_DIALOG (data), GTK_RESPONSE_OK);
}
static gboolean
-edit_app_dialog (const char *title,
- GtkListStore *store,
- GtkTreeIter *iter,
- GtkWidget *parent)
-{
- GladeXML *xml;
- GtkWidget *dlg;
- GtkWidget *browse_button;
- GtkWidget *name_entry;
- GtkWidget *cmd_entry;
- GtkWidget *comment_entry;
- char *c_name, *c_command, *c_comment;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
- STORE_COL_NAME, &c_name,
- STORE_COL_COMMAND, &c_command,
- STORE_COL_COMMENT, &c_comment,
- -1);
-
- /* FIXME: ugly to read same xml file twice */
- xml = glade_xml_new (DATA_DIR "/session-properties.glade",
- CAPPLET_EDIT_DIALOG_WIDGET_NAME, NULL);
-
- dlg = glade_xml_get_widget (xml, CAPPLET_EDIT_DIALOG_WIDGET_NAME);
-
- name_entry = glade_xml_get_widget (xml, CAPPLET_NAME_ENTRY_WIDGET_NAME);
-
- g_signal_connect (name_entry, "activate",
- G_CALLBACK (entry_activate_cb),
- dlg);
-
- if (c_name)
- gtk_entry_set_text (GTK_ENTRY (name_entry), c_name);
-
- browse_button = glade_xml_get_widget (xml, CAPPLET_BROWSE_WIDGET_NAME);
-
- g_signal_connect_swapped (browse_button, "clicked",
- G_CALLBACK (cmd_browse_button_clicked_cb),
- xml);
-
- cmd_entry = glade_xml_get_widget (xml, CAPPLET_COMMAND_ENTRY_WIDGET_NAME);
-
- g_signal_connect (cmd_entry, "activate",
- G_CALLBACK (entry_activate_cb),
- dlg);
-
- if (c_command)
- gtk_entry_set_text (GTK_ENTRY (cmd_entry), c_command);
-
- comment_entry = glade_xml_get_widget (xml, CAPPLET_COMMENT_ENTRY_WIDGET_NAME);
-
- g_signal_connect (comment_entry, "activate",
- G_CALLBACK (entry_activate_cb),
- dlg);
-
- if (c_comment)
- gtk_entry_set_text (GTK_ENTRY (comment_entry), c_comment);
+edit_app_dialog (const char *title,
+ GtkListStore *store,
+ GtkTreeIter *iter,
+ GtkWidget *parent)
+{
+ GladeXML *xml;
+ GtkWidget *dlg;
+ GtkWidget *browse_button;
+ GtkWidget *name_entry;
+ GtkWidget *cmd_entry;
+ GtkWidget *comment_entry;
+ char *c_name, *c_command, *c_comment;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ STORE_COL_NAME, &c_name,
+ STORE_COL_COMMAND, &c_command,
+ STORE_COL_COMMENT, &c_comment,
+ -1);
- gtk_window_set_title (GTK_WINDOW (dlg), title);
+ /* FIXME: ugly to read same xml file twice */
+ xml = glade_xml_new (DATA_DIR "/session-properties.glade",
+ CAPPLET_EDIT_DIALOG_WIDGET_NAME, NULL);
- gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent));
+ dlg = glade_xml_get_widget (xml, CAPPLET_EDIT_DIALOG_WIDGET_NAME);
- g_free (c_name);
- g_free (c_command);
- g_free (c_comment);
+ name_entry = glade_xml_get_widget (xml, CAPPLET_NAME_ENTRY_WIDGET_NAME);
- while (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_OK)
- {
- const char *name = gtk_entry_get_text (GTK_ENTRY (name_entry));
- const char *command = gtk_entry_get_text (GTK_ENTRY (cmd_entry));
- const char *comment = gtk_entry_get_text (GTK_ENTRY (comment_entry));
- const char *error_msg = NULL;
- char **argv;
- char *description;
- int argc;
- GError *error = NULL;
+ g_signal_connect (name_entry, "activate",
+ G_CALLBACK (entry_activate_cb),
+ dlg);
- if (gsm_util_text_is_blank (name))
- error_msg = _("The name of the startup program cannot be empty");
+ if (c_name) {
+ gtk_entry_set_text (GTK_ENTRY (name_entry), c_name);
+ }
- if (gsm_util_text_is_blank (command))
- error_msg = _("The startup command cannot be empty");
+ browse_button = glade_xml_get_widget (xml, CAPPLET_BROWSE_WIDGET_NAME);
- if (!g_shell_parse_argv (command, &argc, &argv, &error))
- {
- if (error)
- error_msg = error->message;
- else
- error_msg = _("The startup command is not valid");
- }
+ g_signal_connect_swapped (browse_button, "clicked",
+ G_CALLBACK (cmd_browse_button_clicked_cb),
+ xml);
- if (error_msg != NULL)
- {
- GtkWidget *msgbox;
+ cmd_entry = glade_xml_get_widget (xml, CAPPLET_COMMAND_ENTRY_WIDGET_NAME);
- gtk_widget_show (dlg);
+ g_signal_connect (cmd_entry, "activate",
+ G_CALLBACK (entry_activate_cb),
+ dlg);
- msgbox = gtk_message_dialog_new (GTK_WINDOW (dlg),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- error_msg);
+ if (c_command) {
+ gtk_entry_set_text (GTK_ENTRY (cmd_entry), c_command);
+ }
- if (error)
- g_error_free (error);
+ comment_entry = glade_xml_get_widget (xml, CAPPLET_COMMENT_ENTRY_WIDGET_NAME);
- gtk_dialog_run (GTK_DIALOG (msgbox));
+ g_signal_connect (comment_entry, "activate",
+ G_CALLBACK (entry_activate_cb),
+ dlg);
- gtk_widget_destroy (msgbox);
+ if (c_comment) {
+ gtk_entry_set_text (GTK_ENTRY (comment_entry), c_comment);
}
- else
- {
- g_strfreev (argv);
- description =
- spc_command_get_app_description (name, comment);
+ gtk_window_set_title (GTK_WINDOW (dlg), title);
+
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent));
- gtk_list_store_set (GTK_LIST_STORE (store), iter,
- STORE_COL_DESCRIPTION, description,
- STORE_COL_NAME, name,
- STORE_COL_COMMAND, command,
- STORE_COL_COMMENT, comment,
- -1);
+ g_free (c_name);
+ g_free (c_command);
+ g_free (c_comment);
+
+ while (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_OK) {
+ const char *name = gtk_entry_get_text (GTK_ENTRY (name_entry));
+ const char *command = gtk_entry_get_text (GTK_ENTRY (cmd_entry));
+ const char *comment = gtk_entry_get_text (GTK_ENTRY (comment_entry));
+ const char *error_msg = NULL;
+ char **argv;
+ char *description;
+ int argc;
+ GError *error = NULL;
+
+ if (gsm_util_text_is_blank (name)) {
+ error_msg = _("The name of the startup program cannot be empty");
+ }
+
+ if (gsm_util_text_is_blank (command)) {
+ error_msg = _("The startup command cannot be empty");
+ }
+
+ if (!g_shell_parse_argv (command, &argc, &argv, &error)) {
+ if (error) {
+ error_msg = error->message;
+ } else {
+ error_msg = _("The startup command is not valid");
+ }
+ }
+
+ if (error_msg != NULL) {
+ GtkWidget *msgbox;
+
+ gtk_widget_show (dlg);
+
+ msgbox = gtk_message_dialog_new (GTK_WINDOW (dlg),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ error_msg);
+
+ if (error) {
+ g_error_free (error);
+ }
+
+ gtk_dialog_run (GTK_DIALOG (msgbox));
+
+ gtk_widget_destroy (msgbox);
+ } else {
+ g_strfreev (argv);
+
+ description = spc_command_get_app_description (name, comment);
+
+ gtk_list_store_set (GTK_LIST_STORE (store), iter,
+ STORE_COL_DESCRIPTION, description,
+ STORE_COL_NAME, name,
+ STORE_COL_COMMAND, command,
+ STORE_COL_COMMENT, comment,
+ -1);
- g_free (description);
+ g_free (description);
- gtk_widget_destroy (dlg);
+ gtk_widget_destroy (dlg);
- return TRUE;
+ return TRUE;
+ }
}
- }
- gtk_widget_destroy (dlg);
+ gtk_widget_destroy (dlg);
- return FALSE;
+ return FALSE;
}
static void
-selection_changed_cb (GtkTreeSelection *selection, GladeXML *xml)
+selection_changed_cb (GtkTreeSelection *selection,
+ GladeXML *xml)
{
- GtkWidget *edit_button;
- GtkWidget *delete_button;
- gboolean sel;
+ GtkWidget *edit_button;
+ GtkWidget *delete_button;
+ gboolean sel;
- edit_button = glade_xml_get_widget (xml, CAPPLET_EDIT_WIDGET_NAME);
- delete_button = glade_xml_get_widget (xml, CAPPLET_DELETE_WIDGET_NAME);
+ edit_button = glade_xml_get_widget (xml, CAPPLET_EDIT_WIDGET_NAME);
+ delete_button = glade_xml_get_widget (xml, CAPPLET_DELETE_WIDGET_NAME);
- sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
+ sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
- if (edit_button)
- gtk_widget_set_sensitive (edit_button, sel);
+ if (edit_button) {
+ gtk_widget_set_sensitive (edit_button, sel);
+ }
- if (delete_button)
- gtk_widget_set_sensitive (delete_button, sel);
+ if (delete_button) {
+ gtk_widget_set_sensitive (delete_button, sel);
+ }
}
static void
@@ -299,112 +308,113 @@
gchar *path,
GtkListStore *store)
{
- GtkTreeIter iter;
- gchar *desktop_file_path;
- gboolean active;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store),
- &iter, path))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
- STORE_COL_DESKTOP_FILE, &desktop_file_path,
- -1);
-
- active = gtk_cell_renderer_toggle_get_active (cell_renderer);
- active = !active;
- gtk_cell_renderer_toggle_set_active (cell_renderer, active);
-
- if (active)
- {
- if (spc_command_enable_app (store, &iter))
- gtk_list_store_set (store, &iter,
- STORE_COL_ENABLED, TRUE,
- -1);
- }
- else
- {
- if (spc_command_disable_app (store, &iter))
- gtk_list_store_set (store, &iter,
- STORE_COL_ENABLED, FALSE,
+ GtkTreeIter iter;
+ gchar *desktop_file_path;
+ gboolean active;
+
+ if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store),
+ &iter, path)) {
+ return;
+ }
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ STORE_COL_DESKTOP_FILE, &desktop_file_path,
-1);
- }
-}
+ active = gtk_cell_renderer_toggle_get_active (cell_renderer);
+ active = !active;
+ gtk_cell_renderer_toggle_set_active (cell_renderer, active);
+
+ if (active) {
+ if (spc_command_enable_app (store, &iter)) {
+ gtk_list_store_set (store, &iter,
+ STORE_COL_ENABLED, TRUE,
+ -1);
+ }
+ } else {
+ if (spc_command_disable_app (store, &iter)) {
+ gtk_list_store_set (store, &iter,
+ STORE_COL_ENABLED, FALSE,
+ -1);
+ }
+ }
+}
static gboolean
-add_from_desktop_file (GtkTreeView *treeview, char *filename)
+add_from_desktop_file (GtkTreeView *treeview,
+ char *filename)
{
- EggDesktopFile *desktop_file;
- gboolean success = FALSE;
+ EggDesktopFile *desktop_file;
+ gboolean success = FALSE;
- /* Assume that the file is local */
- GFile *file = g_file_new_for_uri (filename);
- gchar *path = g_file_get_path (file);
-
- if (path != NULL)
- {
- desktop_file = egg_desktop_file_new (path, NULL);
-
- if (desktop_file != NULL)
- {
- GtkTreeIter iter;
- GtkTreeModel *model;
- const char *name;
- char *comment, *description, *command, *icon;
-
- model = gtk_tree_view_get_model (treeview);
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
- name = egg_desktop_file_get_name (desktop_file);
-
- comment = egg_desktop_file_get_locale_string (desktop_file,
- EGG_DESKTOP_FILE_KEY_COMMENT,
- NULL, NULL);
- if (comment == NULL)
- comment = egg_desktop_file_get_string (desktop_file,
- EGG_DESKTOP_FILE_KEY_COMMENT,
- NULL);
-
- description = spc_command_get_app_description (name, comment);
-
- command = egg_desktop_file_get_string (desktop_file,
- EGG_DESKTOP_FILE_KEY_EXEC,
- NULL);
-
- icon = egg_desktop_file_get_string (desktop_file,
- EGG_DESKTOP_FILE_KEY_ICON,
- NULL);
-
- if (name && comment && description && command)
- {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- STORE_COL_DESCRIPTION, description,
- STORE_COL_NAME, name,
- STORE_COL_COMMAND, command,
- STORE_COL_COMMENT, comment,
- STORE_COL_ICON_NAME, icon,
- STORE_COL_DESKTOP_FILE, desktop_file,
- -1);
-
- spc_command_add_app (GTK_LIST_STORE (model), &iter);
- success = TRUE;
- }
-
- g_free (comment);
- g_free (description);
- g_free (command);
- g_free (icon);
- egg_desktop_file_free (desktop_file);
+ /* Assume that the file is local */
+ GFile *file = g_file_new_for_uri (filename);
+ gchar *path = g_file_get_path (file);
+
+ if (path != NULL) {
+ desktop_file = egg_desktop_file_new (path, NULL);
+
+ if (desktop_file != NULL) {
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ const char *name;
+ char *comment;
+ char *description;
+ char *command;
+ char *icon;
+
+ model = gtk_tree_view_get_model (treeview);
+
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ name = egg_desktop_file_get_name (desktop_file);
+
+ comment = egg_desktop_file_get_locale_string (desktop_file,
+ EGG_DESKTOP_FILE_KEY_COMMENT,
+ NULL, NULL);
+ if (comment == NULL) {
+ comment = egg_desktop_file_get_string (desktop_file,
+ EGG_DESKTOP_FILE_KEY_COMMENT,
+ NULL);
+ }
+
+ description = spc_command_get_app_description (name, comment);
+
+ command = egg_desktop_file_get_string (desktop_file,
+ EGG_DESKTOP_FILE_KEY_EXEC,
+ NULL);
+
+ icon = egg_desktop_file_get_string (desktop_file,
+ EGG_DESKTOP_FILE_KEY_ICON,
+ NULL);
+
+ if (name && comment && description && command) {
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ STORE_COL_DESCRIPTION, description,
+ STORE_COL_NAME, name,
+ STORE_COL_COMMAND, command,
+ STORE_COL_COMMENT, comment,
+ STORE_COL_ICON_NAME, icon,
+ STORE_COL_DESKTOP_FILE, desktop_file,
+ -1);
+
+ spc_command_add_app (GTK_LIST_STORE (model), &iter);
+ success = TRUE;
+ }
+
+ g_free (comment);
+ g_free (description);
+ g_free (command);
+ g_free (icon);
+ egg_desktop_file_free (desktop_file);
+ }
}
- }
- g_free (path);
- return success;
+ g_free (path);
+ return success;
}
-static gboolean
+static gboolean
drag_data_cb (GtkWidget *widget,
GdkDragContext *drag_context,
gint x,
@@ -414,348 +424,354 @@
guint time,
gpointer user_data)
{
- gboolean dnd_success = FALSE;
+ gboolean dnd_success = FALSE;
- if ((data != NULL) && (data->length >= 0))
- {
- gchar **filenames = g_strsplit ((gchar *)data->data, "\r\n", 0);
- int i;
+ if ((data != NULL) && (data->length >= 0)) {
+ gchar **filenames = g_strsplit ((gchar *)data->data, "\r\n", 0);
+ int i;
+
+ for (i = 0; filenames[i] && filenames[i][0]; i++) {
+ /* Return success if at least one file succeeded */
+ gboolean file_success =
+ add_from_desktop_file (GTK_TREE_VIEW (widget), filenames[i]);
+ dnd_success = dnd_success || file_success;
+ }
- for (i = 0; filenames[i] && filenames[i][0]; i++)
- {
- /* Return success if at least one file succeeded */
- gboolean file_success =
- add_from_desktop_file (GTK_TREE_VIEW (widget), filenames[i]);
- dnd_success = dnd_success || file_success;
+ g_strfreev (filenames);
}
- g_strfreev (filenames);
- }
-
- gtk_drag_finish (drag_context, dnd_success, FALSE, time);
- return TRUE;
+ gtk_drag_finish (drag_context, dnd_success, FALSE, time);
+ return TRUE;
}
static void
-setup_treeview (GtkTreeView *treeview, GladeXML *xml)
+setup_treeview (GtkTreeView *treeview,
+ GladeXML *xml)
{
- GtkTreeModel *store;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
- GtkTreeViewColumn *column;
+ GtkTreeModel *store;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
- static const GtkTargetEntry drag_targets[] = { { "text/uri-list", 0, 0 } };
+ static const GtkTargetEntry drag_targets[] = { { "text/uri-list", 0, 0 } };
- store = spc_command_get_store ();
- gtk_tree_view_set_model (treeview, store);
- gtk_tree_view_set_headers_visible (treeview, FALSE);
+ store = spc_command_get_store ();
+ gtk_tree_view_set_model (treeview, store);
+ gtk_tree_view_set_headers_visible (treeview, FALSE);
- selection = gtk_tree_view_get_selection (treeview);
+ selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- g_signal_connect (selection,
- "changed",
- G_CALLBACK (selection_changed_cb),
- xml);
+ g_signal_connect (selection,
+ "changed",
+ G_CALLBACK (selection_changed_cb),
+ xml);
- renderer = gtk_cell_renderer_toggle_new ();
+ renderer = gtk_cell_renderer_toggle_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Enabled"), renderer,
- "active", STORE_COL_ENABLED,
- "activatable", STORE_COL_ACTIVATABLE,
- NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Enabled"), renderer,
+ "active", STORE_COL_ENABLED,
+ "activatable", STORE_COL_ACTIVATABLE,
+ NULL);
- gtk_tree_view_append_column (treeview, column);
+ gtk_tree_view_append_column (treeview, column);
- g_signal_connect (renderer,
- "toggled",
- G_CALLBACK (startup_enabled_toggled_cb),
- store);
+ g_signal_connect (renderer,
+ "toggled",
+ G_CALLBACK (startup_enabled_toggled_cb),
+ store);
- renderer = gtk_cell_renderer_pixbuf_new ();
+ renderer = gtk_cell_renderer_pixbuf_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Icon"), renderer,
- "icon-name", STORE_COL_ICON_NAME,
- NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Icon"), renderer,
+ "icon-name", STORE_COL_ICON_NAME,
+ NULL);
- g_object_set (renderer,
- "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR,
- NULL);
+ g_object_set (renderer,
+ "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR,
+ NULL);
- gtk_tree_view_append_column (treeview, column);
+ gtk_tree_view_append_column (treeview, column);
- renderer = gtk_cell_renderer_text_new ();
+ renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Program"), renderer,
- "markup", STORE_COL_DESCRIPTION,
- NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Program"), renderer,
+ "markup", STORE_COL_DESCRIPTION,
+ NULL);
- g_object_set (renderer,
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
+ g_object_set (renderer,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
- gtk_tree_view_append_column (treeview, column);
+ gtk_tree_view_append_column (treeview, column);
- gtk_tree_view_column_set_sort_column_id (column, STORE_COL_NAME);
- gtk_tree_view_set_search_column (treeview, STORE_COL_NAME);
- gtk_tree_view_set_rules_hint (treeview, TRUE);
+ gtk_tree_view_column_set_sort_column_id (column, STORE_COL_NAME);
+ gtk_tree_view_set_search_column (treeview, STORE_COL_NAME);
+ gtk_tree_view_set_rules_hint (treeview, TRUE);
- gtk_drag_dest_set (GTK_WIDGET (treeview),
- GTK_DEST_DEFAULT_ALL,
- drag_targets,
- G_N_ELEMENTS (drag_targets),
- GDK_ACTION_COPY);
+ gtk_drag_dest_set (GTK_WIDGET (treeview),
+ GTK_DEST_DEFAULT_ALL,
+ drag_targets,
+ G_N_ELEMENTS (drag_targets),
+ GDK_ACTION_COPY);
- g_signal_connect (G_OBJECT (treeview),
- "drag-data-received",
- G_CALLBACK (drag_data_cb),
- NULL);
+ g_signal_connect (G_OBJECT (treeview),
+ "drag-data-received",
+ G_CALLBACK (drag_data_cb),
+ NULL);
}
static void
add_app_cb (GtkWidget *widget,
- GladeXML *xml)
+ GladeXML *xml)
{
- GtkWidget *parent;
- GtkTreeView *view;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- parent = glade_xml_get_widget (xml, CAPPLET_DIALOG_WIDGET_NAME);
-
- view = GTK_TREE_VIEW (glade_xml_get_widget (xml,
- CAPPLET_TREEVIEW_WIDGET_NAME));
-
- selection = gtk_tree_view_get_selection (view);
- model = gtk_tree_view_get_model (view);
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
- if (edit_app_dialog (_("Add Startup Program"), GTK_LIST_STORE (model), &iter, parent))
- spc_command_add_app (GTK_LIST_STORE (model), &iter);
- else
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ GtkWidget *parent;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ parent = glade_xml_get_widget (xml, CAPPLET_DIALOG_WIDGET_NAME);
+
+ view = GTK_TREE_VIEW (glade_xml_get_widget (xml,
+ CAPPLET_TREEVIEW_WIDGET_NAME));
+
+ selection = gtk_tree_view_get_selection (view);
+ model = gtk_tree_view_get_model (view);
+
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ if (edit_app_dialog (_("Add Startup Program"), GTK_LIST_STORE (model), &iter, parent)) {
+ spc_command_add_app (GTK_LIST_STORE (model), &iter);
+ } else {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ }
}
static void
delete_app_cb (GtkWidget *widget,
- GladeXML *xml)
+ GladeXML *xml)
{
- GtkTreeView *view;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- view = GTK_TREE_VIEW (glade_xml_get_widget (xml,
- CAPPLET_TREEVIEW_WIDGET_NAME));
+ view = GTK_TREE_VIEW (glade_xml_get_widget (xml,
+ CAPPLET_TREEVIEW_WIDGET_NAME));
- selection = gtk_tree_view_get_selection (view);
- model = gtk_tree_view_get_model (view);
+ selection = gtk_tree_view_get_selection (view);
+ model = gtk_tree_view_get_model (view);
- if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
- return;
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+ return;
+ }
- spc_command_delete_app (GTK_LIST_STORE (model), &iter);
+ spc_command_delete_app (GTK_LIST_STORE (model), &iter);
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
static void
edit_app_cb (GtkWidget *widget,
- GladeXML *xml)
+ GladeXML *xml)
{
- GtkWidget *parent;
- GtkTreeView *view;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkWidget *parent;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- parent = glade_xml_get_widget (xml, CAPPLET_DIALOG_WIDGET_NAME);
-
- view = GTK_TREE_VIEW (glade_xml_get_widget (xml,
- CAPPLET_TREEVIEW_WIDGET_NAME));
+ parent = glade_xml_get_widget (xml, CAPPLET_DIALOG_WIDGET_NAME);
- selection = gtk_tree_view_get_selection (view);
- model = gtk_tree_view_get_model (view);
+ view = GTK_TREE_VIEW (glade_xml_get_widget (xml,
+ CAPPLET_TREEVIEW_WIDGET_NAME));
- if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
- return;
+ selection = gtk_tree_view_get_selection (view);
+ model = gtk_tree_view_get_model (view);
- if (edit_app_dialog (_("Edit Startup Program"), GTK_LIST_STORE (model), &iter, parent))
- spc_command_update_app (GTK_LIST_STORE (model), &iter);
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+ return;
+ }
+
+ if (edit_app_dialog (_("Edit Startup Program"), GTK_LIST_STORE (model), &iter, parent)) {
+ spc_command_update_app (GTK_LIST_STORE (model), &iter);
+ }
}
static void
-autosave_value_notify (GConfClient *client, guint id,
- GConfEntry *entry, gpointer tb)
+autosave_value_notify (GConfClient *client,
+ guint id,
+ GConfEntry *entry,
+ gpointer tb)
{
- gboolean gval, bval;
-
- gval = gconf_value_get_bool (entry->value);
- bval = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb));
-
- if (bval != gval)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), gval);
- }
+ gboolean gval, bval;
+
+ gval = gconf_value_get_bool (entry->value);
+ bval = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb));
+
+ if (bval != gval) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), gval);
+ }
}
static void
-autosave_value_toggled (GtkToggleButton *tb, gpointer data)
+autosave_value_toggled (GtkToggleButton *tb,
+ gpointer data)
{
- GConfClient *client;
- gboolean gval, bval;
- const gchar *key;
+ GConfClient *client;
+ gboolean gval;
+ gboolean bval;
+ const gchar *key;
- client = (GConfClient *) data;
+ client = (GConfClient *) data;
- key = g_object_get_data (G_OBJECT (tb), "key");
+ key = g_object_get_data (G_OBJECT (tb), "key");
- gval = gconf_client_get_bool (client, key, NULL);
- bval = gtk_toggle_button_get_active (tb);
+ gval = gconf_client_get_bool (client, key, NULL);
+ bval = gtk_toggle_button_get_active (tb);
- if (gval != bval)
- {
- gconf_client_set_bool (client, key, bval, NULL);
- }
+ if (gval != bval) {
+ gconf_client_set_bool (client, key, bval, NULL);
+ }
}
static void
save_session_cb (GtkWidget *widget,
GladeXML *xml)
{
- g_debug ("Session saving is not implemented yet!");
+ g_debug ("Session saving is not implemented yet!");
}
static void
help_cb (GtkWidget *widget,
GtkWidget *dialog)
{
- GError *error = NULL;
-
- gnome_help_display_desktop (NULL, "user-guide", "user-guide.xml",
- "goscustsession-5", &error);
+ GError *error = NULL;
- if (error)
- {
- GtkWidget *error_dlg;
-
- error_dlg =
- gtk_message_dialog_new (GTK_WINDOW (dialog),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- ("There was an error displaying help: \n%s"),
- error->message);
-
- g_signal_connect (G_OBJECT (error_dlg), "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
+ gnome_help_display_desktop (NULL,
+ "user-guide",
+ "user-guide.xml",
+ "goscustsession-5",
+ &error);
+
+ if (error) {
+ GtkWidget *error_dlg;
+
+ error_dlg = gtk_message_dialog_new (GTK_WINDOW (dialog),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ ("There was an error displaying help: \n%s"),
+ error->message);
+
+ g_signal_connect (G_OBJECT (error_dlg), "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
- gtk_window_set_resizable (GTK_WINDOW (error_dlg), FALSE);
- gtk_widget_show (error_dlg);
+ gtk_window_set_resizable (GTK_WINDOW (error_dlg), FALSE);
+ gtk_widget_show (error_dlg);
- g_error_free (error);
- }
+ g_error_free (error);
+ }
}
static gboolean
delete_cb (GtkWidget *dialog)
{
- gtk_main_quit ();
- return FALSE;
+ gtk_main_quit ();
+ return FALSE;
}
static void
close_cb (GtkWidget *widget,
GtkWidget *dialog)
{
- delete_cb (dialog);
+ delete_cb (dialog);
}
void
spc_ui_build (GConfClient *client)
{
- GladeXML *xml;
- GtkWidget *dlg;
- GtkWidget *treeview;
- GtkWidget *button;
+ GladeXML *xml;
+ GtkWidget *dlg;
+ GtkWidget *treeview;
+ GtkWidget *button;
- xml = glade_xml_new (DATA_DIR "/session-properties.glade",
- CAPPLET_DIALOG_WIDGET_NAME, NULL);
+ xml = glade_xml_new (DATA_DIR "/session-properties.glade",
+ CAPPLET_DIALOG_WIDGET_NAME, NULL);
- dlg = glade_xml_get_widget (xml, CAPPLET_DIALOG_WIDGET_NAME);
+ dlg = glade_xml_get_widget (xml, CAPPLET_DIALOG_WIDGET_NAME);
- g_signal_connect (dlg,
- "delete-event",
- G_CALLBACK (delete_cb),
- NULL);
+ g_signal_connect (dlg,
+ "delete-event",
+ G_CALLBACK (delete_cb),
+ NULL);
- treeview = glade_xml_get_widget (xml, CAPPLET_TREEVIEW_WIDGET_NAME);
+ treeview = glade_xml_get_widget (xml, CAPPLET_TREEVIEW_WIDGET_NAME);
- setup_treeview (GTK_TREE_VIEW (treeview), xml);
+ setup_treeview (GTK_TREE_VIEW (treeview), xml);
- button = glade_xml_get_widget (xml, CAPPLET_CLOSE_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_CLOSE_WIDGET_NAME);
- gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_CLOSE);
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_CLOSE);
- g_signal_connect (G_OBJECT (button),
- "clicked",
- G_CALLBACK (close_cb),
- dlg);
+ g_signal_connect (G_OBJECT (button),
+ "clicked",
+ G_CALLBACK (close_cb),
+ dlg);
- button = glade_xml_get_widget (xml, CAPPLET_HELP_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_HELP_WIDGET_NAME);
- g_signal_connect (G_OBJECT (button),
- "clicked",
- G_CALLBACK (help_cb),
- dlg);
+ g_signal_connect (G_OBJECT (button),
+ "clicked",
+ G_CALLBACK (help_cb),
+ dlg);
- button = glade_xml_get_widget (xml, CAPPLET_ADD_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_ADD_WIDGET_NAME);
- g_signal_connect (G_OBJECT (button),
- "clicked",
- G_CALLBACK (add_app_cb),
- xml);
+ g_signal_connect (G_OBJECT (button),
+ "clicked",
+ G_CALLBACK (add_app_cb),
+ xml);
- button = glade_xml_get_widget (xml, CAPPLET_DELETE_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_DELETE_WIDGET_NAME);
- g_signal_connect (G_OBJECT (button),
- "clicked",
- G_CALLBACK (delete_app_cb),
- xml);
+ g_signal_connect (G_OBJECT (button),
+ "clicked",
+ G_CALLBACK (delete_app_cb),
+ xml);
- button = glade_xml_get_widget (xml, CAPPLET_EDIT_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_EDIT_WIDGET_NAME);
- g_signal_connect (G_OBJECT (button),
- "clicked",
- G_CALLBACK (edit_app_cb),
- xml);
+ g_signal_connect (G_OBJECT (button),
+ "clicked",
+ G_CALLBACK (edit_app_cb),
+ xml);
- button = glade_xml_get_widget (xml, CAPPLET_REMEMBER_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_REMEMBER_WIDGET_NAME);
- g_object_set_data (G_OBJECT (button), "key", SPC_GCONF_AUTOSAVE_KEY);
+ g_object_set_data (G_OBJECT (button), "key", SPC_GCONF_AUTOSAVE_KEY);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- gconf_client_get_bool (client, SPC_GCONF_AUTOSAVE_KEY, NULL));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+ gconf_client_get_bool (client, SPC_GCONF_AUTOSAVE_KEY, NULL));
- gconf_client_notify_add (client, SPC_GCONF_AUTOSAVE_KEY,
- autosave_value_notify,
- button, NULL, NULL);
+ gconf_client_notify_add (client, SPC_GCONF_AUTOSAVE_KEY,
+ autosave_value_notify,
+ button, NULL, NULL);
- g_signal_connect (G_OBJECT (button),
- "toggled",
- G_CALLBACK (autosave_value_toggled),
- client);
+ g_signal_connect (G_OBJECT (button),
+ "toggled",
+ G_CALLBACK (autosave_value_toggled),
+ client);
- button = glade_xml_get_widget (xml, CAPPLET_SAVE_WIDGET_NAME);
+ button = glade_xml_get_widget (xml, CAPPLET_SAVE_WIDGET_NAME);
- g_signal_connect (G_OBJECT (button),
- "clicked",
- G_CALLBACK (save_session_cb),
- xml);
+ g_signal_connect (G_OBJECT (button),
+ "clicked",
+ G_CALLBACK (save_session_cb),
+ xml);
- gtk_widget_show (dlg);
+ gtk_widget_show (dlg);
}
Modified: trunk/capplet/ui.h
==============================================================================
--- trunk/capplet/ui.h (original)
+++ trunk/capplet/ui.h Mon Aug 4 19:05:21 2008
@@ -18,7 +18,7 @@
* 02111-1307, USA.
*/
-#ifndef __SESSION_PROPERTIES_CAPPLET_H__
+#ifndef __SESSION_PROPERTIES_CAPPLET_H__
#define __SESSION_PROPERTIES_CAPPLET_H__
#include <gtk/gtk.h>
@@ -28,7 +28,7 @@
G_BEGIN_DECLS
#define SPC_GCONF_CONFIG_PREFIX "/apps/gnome-session/options"
-#define SPC_GCONF_AUTOSAVE_KEY SPC_GCONF_CONFIG_PREFIX "/auto_save_session"
+#define SPC_GCONF_AUTOSAVE_KEY SPC_GCONF_CONFIG_PREFIX "/auto_save_session"
void spc_ui_build (GConfClient *client);
Modified: trunk/compat/at-spi-registryd-wrapper.c
==============================================================================
--- trunk/compat/at-spi-registryd-wrapper.c (original)
+++ trunk/compat/at-spi-registryd-wrapper.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
* at-spi-registryd-wrapper: a wrapper to make at-spi-registryd
* conform to the startup item interfaces. (This should go away when
* at-spi-registryd supports session management directly.)
@@ -9,152 +10,155 @@
* Copyright (C) 2007 Novell, Inc.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
-#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
static Atom AT_SPI_IOR;
-static GdkFilterReturn
-registry_ior_watch (GdkXEvent *xevent, GdkEvent *event, gpointer data)
+static GdkFilterReturn
+registry_ior_watch (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer data)
{
- XEvent *xev = (XEvent *)xevent;
+ XEvent *xev = (XEvent *)xevent;
- if (xev->xany.type == PropertyNotify &&
- xev->xproperty.atom == AT_SPI_IOR)
- {
- gtk_main_quit ();
+ if (xev->xany.type == PropertyNotify &&
+ xev->xproperty.atom == AT_SPI_IOR) {
+ gtk_main_quit ();
- return GDK_FILTER_REMOVE;
- }
+ return GDK_FILTER_REMOVE;
+ }
- return GDK_FILTER_CONTINUE;
+ return GDK_FILTER_CONTINUE;
}
static gboolean
show_error (DBusGProxy *gsm)
{
- const char *message;
+ const char *message;
- message = _("Assistive technology support has been requested for this session, but the accessibility registry was not found. Please ensure that the AT-SPI package is installed. Your session has been started without assistive technology support.");
- dbus_g_proxy_call (gsm, "InitializationError", NULL,
- G_TYPE_STRING, message,
- G_TYPE_BOOLEAN, FALSE,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ message = _("Assistive technology support has been requested for this session, but the accessibility registry was not found. Please ensure that the AT-SPI package is installed. Your session has been started without assistive technology support.");
+ dbus_g_proxy_call (gsm, "InitializationError", NULL,
+ G_TYPE_STRING, message,
+ G_TYPE_BOOLEAN, FALSE,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
- exit (1);
+ exit (1);
- /* not reached */
- return FALSE;
+ /* not reached */
+ return FALSE;
}
static void
set_gtk_modules (DBusGProxy *gsm)
{
- const char *old;
- char *value;
- gboolean found_gail;
- gboolean found_atk_bridge;
- GError *error = NULL;
- int i;
-
- found_gail = FALSE;
- found_atk_bridge = FALSE;
-
- old = g_getenv ("GTK_MODULES");
- if (old != NULL)
- {
- char **old_modules, **modules;
-
- old_modules = g_strsplit (old, ":", -1);
- for (i = 0; old_modules[i]; i++)
- {
- if (!strcmp (old_modules[i], "gail"))
- found_gail = TRUE;
- else if (!strcmp (old_modules[i], "atk-bridge"))
- found_atk_bridge = TRUE;
+ const char *old;
+ char *value;
+ gboolean found_gail;
+ gboolean found_atk_bridge;
+ GError *error;
+ int i;
+
+ found_gail = FALSE;
+ found_atk_bridge = FALSE;
+
+ old = g_getenv ("GTK_MODULES");
+ if (old != NULL) {
+ char **old_modules;
+ char **modules;
+
+ old_modules = g_strsplit (old, ":", -1);
+ for (i = 0; old_modules[i]; i++) {
+ if (!strcmp (old_modules[i], "gail")) {
+ found_gail = TRUE;
+ } else if (!strcmp (old_modules[i], "atk-bridge")) {
+ found_atk_bridge = TRUE;
+ }
+ }
+
+ modules = g_new (char *, i + (found_gail ? 0 : 1) +
+ (found_atk_bridge ? 0 : 1) + 1);
+ for (i = 0; old_modules[i]; i++) {
+ modules[i] = old_modules[i];
+ }
+ if (!found_gail) {
+ modules[i++] = "gail";
+ }
+ if (!found_atk_bridge) {
+ modules[i++] = "atk-bridge";
+ }
+ modules[i] = NULL;
+
+ value = g_strjoinv (":", modules);
+ g_strfreev (modules);
+ } else {
+ value = g_strdup ("gail:atk-bridge");
}
- modules = g_new (char *, i + (found_gail ? 0 : 1) +
- (found_atk_bridge ? 0 : 1) + 1);
- for (i = 0; old_modules[i]; i++)
- modules[i] = old_modules[i];
- if (!found_gail)
- modules[i++] = "gail";
- if (!found_atk_bridge)
- modules[i++] = "atk-bridge";
- modules[i] = NULL;
-
- value = g_strjoinv (":", modules);
- g_strfreev (modules);
- }
- else
- value = g_strdup ("gail:atk-bridge");
-
- if (!dbus_g_proxy_call (gsm, "Setenv", &error,
- G_TYPE_STRING, "GTK_MODULES",
- G_TYPE_STRING, value,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- {
- g_warning ("Could not set GTK_MODULES: %s", error->message);
- g_error_free (error);
- }
+ error = NULL;
+ if (!dbus_g_proxy_call (gsm, "Setenv", &error,
+ G_TYPE_STRING, "GTK_MODULES",
+ G_TYPE_STRING, value,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID)) {
+ g_warning ("Could not set GTK_MODULES: %s", error->message);
+ g_error_free (error);
+ }
- g_free (value);
+ g_free (value);
}
int
main (int argc, char **argv)
{
- GdkDisplay *display;
- GdkWindow *root;
- GError *error = NULL;
- DBusGConnection *connection;
- DBusGProxy *gsm;
-
- gtk_init (&argc, &argv);
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!connection)
- g_error ("couldn't get D-Bus connection: %s", error->message);
- gsm = dbus_g_proxy_new_for_name (connection,
- "org.gnome.SessionManager",
- "/org/gnome/SessionManager",
- "org.gnome.SessionManager");
+ GdkDisplay *display;
+ GdkWindow *root;
+ GError *error;
+ DBusGConnection *connection;
+ DBusGProxy *gsm;
+
+ gtk_init (&argc, &argv);
+
+ error = NULL;
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (connection == NULL) {
+ g_error ("couldn't get D-Bus connection: %s", error->message);
+ }
+ gsm = dbus_g_proxy_new_for_name (connection,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager");
- display = gdk_display_get_default ();
- root = gdk_screen_get_root_window (gdk_display_get_default_screen (display));
+ display = gdk_display_get_default ();
+ root = gdk_screen_get_root_window (gdk_display_get_default_screen (display));
- AT_SPI_IOR = XInternAtom (gdk_x11_display_get_xdisplay (display),
- "AT_SPI_IOR", False);
+ AT_SPI_IOR = XInternAtom (gdk_x11_display_get_xdisplay (display),
+ "AT_SPI_IOR", False);
- gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK);
- gdk_window_add_filter (root, registry_ior_watch, NULL);
+ gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK);
+ gdk_window_add_filter (root, registry_ior_watch, NULL);
- set_gtk_modules (gsm);
+ set_gtk_modules (gsm);
- if (!g_spawn_command_line_async (AT_SPI_REGISTRYD_DIR "/at-spi-registryd", &error))
- {
- show_error (gsm);
- /* not reached */
- }
+ if (!g_spawn_command_line_async (AT_SPI_REGISTRYD_DIR "/at-spi-registryd", &error)) {
+ show_error (gsm);
+ /* not reached */
+ }
- gtk_main ();
+ gtk_main ();
- gdk_window_remove_filter (root, registry_ior_watch, NULL);
+ gdk_window_remove_filter (root, registry_ior_watch, NULL);
- g_object_unref (gsm);
+ g_object_unref (gsm);
- return 0;
+ return 0;
}
Modified: trunk/compat/gnome-keyring-daemon-wrapper.c
==============================================================================
--- trunk/compat/gnome-keyring-daemon-wrapper.c (original)
+++ trunk/compat/gnome-keyring-daemon-wrapper.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
* gnome-keyring-daemon-wrapper: a wrapper to make
* gnome-keyring-daemon conform to the startup item interfaces. (This
* should go away when gnome-keyring-daemon supports session
@@ -10,9 +11,7 @@
* Copyright (C) 2007 Novell, Inc.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <signal.h>
#include <stdlib.h>
@@ -24,196 +23,190 @@
#include <dbus/dbus-glib.h>
#include <glib.h>
+#include <gtk/gtk.h>
#include <gnome-keyring.h>
-#include <gtk/gtkmain.h>
#include "eggdesktopfile.h"
#include "eggsmclient.h"
static pid_t gnome_keyring_daemon_pid = 0;
-static int keyring_lifetime_pipe[2];
+static int keyring_lifetime_pipe[2];
static void
keyring_daemon_stop (void)
{
- if (gnome_keyring_daemon_pid != 0)
- {
- kill (gnome_keyring_daemon_pid, SIGTERM);
- gnome_keyring_daemon_pid = 0;
- }
+ if (gnome_keyring_daemon_pid != 0) {
+ kill (gnome_keyring_daemon_pid, SIGTERM);
+ gnome_keyring_daemon_pid = 0;
+ }
}
static void
child_setup (gpointer user_data)
{
- gint open_max;
- gint fd;
- char *fd_str;
-
- open_max = sysconf (_SC_OPEN_MAX);
- for (fd = 3; fd < open_max; fd++)
- {
- if (fd != keyring_lifetime_pipe[0])
- fcntl (fd, F_SETFD, FD_CLOEXEC);
- }
-
- fd_str = g_strdup_printf ("%d", keyring_lifetime_pipe[0]);
- g_setenv ("GNOME_KEYRING_LIFETIME_FD",
- fd_str,
- TRUE);
+ int open_max;
+ int fd;
+ char *fd_str;
+
+ open_max = sysconf (_SC_OPEN_MAX);
+ for (fd = 3; fd < open_max; fd++) {
+ if (fd != keyring_lifetime_pipe[0]) {
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
+ }
+ }
+
+ fd_str = g_strdup_printf ("%d", keyring_lifetime_pipe[0]);
+ g_setenv ("GNOME_KEYRING_LIFETIME_FD",
+ fd_str,
+ TRUE);
}
static void
keyring_daemon_start (DBusGProxy *gsm)
{
- GError *err;
- char *standard_out;
- char **lines, **env;
- int status;
- long pid;
- char *pid_str, *end;
- const char *old_keyring;
- const char *display;
- char *argv[2];
-
- /* If there is already a working keyring, don't start a new daemon */
- old_keyring = g_getenv ("GNOME_KEYRING_SOCKET");
- if (old_keyring != NULL &&
- access (old_keyring, R_OK | W_OK) == 0)
- {
- display = g_getenv ("DISPLAY");
- if (display != NULL)
- gnome_keyring_daemon_set_display_sync (display);
-
- return;
- }
-
- /* Pipe to slave keyring lifetime to */
- pipe (keyring_lifetime_pipe);
-
- err = NULL;
- argv[0] = GNOME_KEYRING_DAEMON;
- argv[1] = NULL;
- g_spawn_sync (NULL, argv, NULL, G_SPAWN_LEAVE_DESCRIPTORS_OPEN,
- child_setup, NULL,
- &standard_out, NULL, &status, &err);
-
- close (keyring_lifetime_pipe[0]);
- /* We leave keyring_lifetime_pipe[1] open for the lifetime of the session,
- in order to slave the keyring daemon lifecycle to the session. */
-
- if (err != NULL)
- {
- g_printerr ("Failed to run gnome-keyring-daemon: %s\n",
- err->message);
- g_error_free (err);
- exit (1);
- }
- else
- {
- if (WIFEXITED (status) &&
- WEXITSTATUS (status) == 0 &&
- standard_out != NULL)
- {
- lines = g_strsplit (standard_out, "\n", 3);
-
- if (lines[0] != NULL &&
- lines[1] != NULL &&
- lines[2] != NULL &&
- g_str_has_prefix (lines[1], "SSH_AUTH_SOCK=") &&
- g_str_has_prefix (lines[2], "GNOME_KEYRING_PID="))
- {
- env = g_strsplit (lines[1], "=", 2);
- if (!dbus_g_proxy_call (gsm, "Setenv", &err,
- G_TYPE_STRING, env[0],
- G_TYPE_STRING, env[1],
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- {
- g_warning ("Could not set %s: %s", env[0], err->message);
- g_clear_error (&err);
+ GError *err;
+ char *standard_out;
+ char **lines;
+ char **env;
+ int status;
+ long pid;
+ char *pid_str;
+ char *end;
+ const char *old_keyring;
+ const char *display;
+ char *argv[2];
+
+ /* If there is already a working keyring, don't start a new daemon */
+ old_keyring = g_getenv ("GNOME_KEYRING_SOCKET");
+ if (old_keyring != NULL &&
+ access (old_keyring, R_OK | W_OK) == 0) {
+ display = g_getenv ("DISPLAY");
+ if (display != NULL) {
+ gnome_keyring_daemon_set_display_sync (display);
}
- g_strfreev (env);
- pid_str = lines[2] + strlen ("GNOME_KEYRING_PID=");
+ return;
+ }
+
+ /* Pipe to slave keyring lifetime to */
+ pipe (keyring_lifetime_pipe);
- pid = strtol (pid_str, &end, 10);
- if (end != pid_str)
- {
- gnome_keyring_daemon_pid = pid;
-
- env = g_strsplit (lines[2], "=", 2);
- if (!dbus_g_proxy_call (gsm, "Setenv", &err,
- G_TYPE_STRING, env[0],
- G_TYPE_STRING, env[1],
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- {
- g_warning ("Could not set %s: %s", env[0], err->message);
- g_clear_error (&err);
- }
- g_strfreev (env);
+ err = NULL;
+ argv[0] = GNOME_KEYRING_DAEMON;
+ argv[1] = NULL;
+ g_spawn_sync (NULL, argv, NULL, G_SPAWN_LEAVE_DESCRIPTORS_OPEN,
+ child_setup, NULL,
+ &standard_out, NULL, &status, &err);
+
+ close (keyring_lifetime_pipe[0]);
+ /* We leave keyring_lifetime_pipe[1] open for the lifetime of the session,
+ in order to slave the keyring daemon lifecycle to the session. */
+
+ if (err != NULL) {
+ g_printerr ("Failed to run gnome-keyring-daemon: %s\n",
+ err->message);
+ g_error_free (err);
+ exit (1);
+ } else {
+ if (WIFEXITED (status) &&
+ WEXITSTATUS (status) == 0 &&
+ standard_out != NULL) {
+ lines = g_strsplit (standard_out, "\n", 3);
+
+ if (lines[0] != NULL &&
+ lines[1] != NULL &&
+ lines[2] != NULL &&
+ g_str_has_prefix (lines[1], "SSH_AUTH_SOCK=") &&
+ g_str_has_prefix (lines[2], "GNOME_KEYRING_PID=")) {
+ env = g_strsplit (lines[1], "=", 2);
+ if (!dbus_g_proxy_call (gsm, "Setenv", &err,
+ G_TYPE_STRING, env[0],
+ G_TYPE_STRING, env[1],
+ G_TYPE_INVALID,
+ G_TYPE_INVALID)) {
+ g_warning ("Could not set %s: %s", env[0], err->message);
+ g_clear_error (&err);
+ }
+ g_strfreev (env);
+
+ pid_str = lines[2] + strlen ("GNOME_KEYRING_PID=");
+
+ pid = strtol (pid_str, &end, 10);
+ if (end != pid_str) {
+ gnome_keyring_daemon_pid = pid;
+
+ env = g_strsplit (lines[2], "=", 2);
+ if (!dbus_g_proxy_call (gsm, "Setenv", &err,
+ G_TYPE_STRING, env[0],
+ G_TYPE_STRING, env[1],
+ G_TYPE_INVALID,
+ G_TYPE_INVALID)) {
+ g_warning ("Could not set %s: %s", env[0], err->message);
+ g_clear_error (&err);
+ }
+ g_strfreev (env);
+ }
+ }
+
+ g_strfreev (lines);
+ } else {
+ /* daemon failed for some reason */
+ g_printerr ("gnome-keyring-daemon failed to start correctly, exit code: %d\n",
+ WEXITSTATUS (status));
+ exit (1);
}
- }
-
- g_strfreev (lines);
- }
- else
- {
- /* daemon failed for some reason */
- g_printerr ("gnome-keyring-daemon failed to start correctly, exit code: %d\n",
- WEXITSTATUS (status));
- exit (1);
+ g_free (standard_out);
}
- g_free (standard_out);
- }
}
static void
-quit (EggSMClient *smclient, gpointer user_data)
+quit (EggSMClient *smclient,
+ gpointer user_data)
{
- gtk_main_quit ();
+ gtk_main_quit ();
}
int
main (int argc, char **argv)
{
- EggSMClient *client;
- GOptionContext *goption_context;
- GError *err = NULL;
- DBusGConnection *connection;
- DBusGProxy *gsm;
-
- g_type_init ();
-
- goption_context = g_option_context_new (NULL);
- g_option_context_add_group (goption_context, gtk_get_option_group (FALSE));
- g_option_context_add_group (goption_context, egg_sm_client_get_option_group ());
- if (!g_option_context_parse (goption_context, &argc, &argv, &err))
- {
- g_printerr ("Could not parse arguments: %s\n", err->message);
- g_error_free (err);
- g_option_context_free (goption_context);
- return 1;
- }
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &err);
- if (!connection)
- g_error ("couldn't get D-Bus connection: %s", err->message);
- gsm = dbus_g_proxy_new_for_name (connection,
- "org.gnome.SessionManager",
- "/org/gnome/SessionManager",
- "org.gnome.SessionManager");
-
- egg_set_desktop_file (DEFAULT_SESSION_DIR "/gnome-keyring-daemon-wrapper.desktop");
-
- client = egg_sm_client_get ();
- g_signal_connect (client, "quit", G_CALLBACK (quit), NULL);
-
- keyring_daemon_start (gsm);
- gtk_main ();
- keyring_daemon_stop ();
- g_option_context_free (goption_context);
+ EggSMClient *client;
+ GOptionContext *goption_context;
+ GError *err;
+ DBusGConnection *connection;
+ DBusGProxy *gsm;
+
+ g_type_init ();
+
+ goption_context = g_option_context_new (NULL);
+ g_option_context_add_group (goption_context, gtk_get_option_group (FALSE));
+ g_option_context_add_group (goption_context, egg_sm_client_get_option_group ());
+
+ err = NULL;
+ if (!g_option_context_parse (goption_context, &argc, &argv, &err)) {
+ g_printerr ("Could not parse arguments: %s\n", err->message);
+ g_error_free (err);
+ g_option_context_free (goption_context);
+ return 1;
+ }
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &err);
+ if (connection == NULL) {
+ g_error ("couldn't get D-Bus connection: %s", err->message);
+ }
+ gsm = dbus_g_proxy_new_for_name (connection,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager");
+
+ egg_set_desktop_file (DEFAULT_SESSION_DIR "/gnome-keyring-daemon-wrapper.desktop");
+
+ client = egg_sm_client_get ();
+ g_signal_connect (client, "quit", G_CALLBACK (quit), NULL);
+
+ keyring_daemon_start (gsm);
+ gtk_main ();
+ keyring_daemon_stop ();
+ g_option_context_free (goption_context);
- return 0;
+ return 0;
}
Modified: trunk/compat/gnome-settings-daemon-helper.c
==============================================================================
--- trunk/compat/gnome-settings-daemon-helper.c (original)
+++ trunk/compat/gnome-settings-daemon-helper.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
* gnome-settings-daemon-helper: Does things g-s-d should do, but doesn't:
*
* 1) Sets screen resolution
@@ -12,9 +13,7 @@
* Copyright (C) 2007 Novell, Inc.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <stdio.h>
#include <unistd.h>
@@ -25,44 +24,45 @@
static void
set_gtk1_theme_rcfile (void)
{
- DBusGConnection *connection;
- DBusGProxy *gsm;
- char *value;
- GError *error = NULL;
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
- if (!connection)
- g_error ("couldn't get D-Bus connection: %s", error->message);
-
- gsm = dbus_g_proxy_new_for_name (connection,
- "org.gnome.SessionManager",
- "/org/gnome/SessionManager",
- "org.gnome.SessionManager");
-
- value = g_strdup_printf (SYSCONFDIR "/gtk/gtkrc:%s/.gtkrc-1.2-gnome2", g_get_home_dir ());
- if (!dbus_g_proxy_call (gsm, "Setenv", &error,
- G_TYPE_STRING, "GTK_RC_FILES",
- G_TYPE_STRING, value,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- {
- g_warning ("Could not set GTK_RC_FILES: %s", error->message);
- g_error_free (error);
- }
+ DBusGConnection *connection;
+ DBusGProxy *gsm;
+ char *value;
+ GError *error;
+
+ error = NULL;
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+ if (connection == NULL) {
+ g_error ("couldn't get D-Bus connection: %s", error->message);
+ }
+
+ gsm = dbus_g_proxy_new_for_name (connection,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager");
+
+ value = g_strdup_printf (SYSCONFDIR "/gtk/gtkrc:%s/.gtkrc-1.2-gnome2", g_get_home_dir ());
+ if (!dbus_g_proxy_call (gsm, "Setenv", &error,
+ G_TYPE_STRING, "GTK_RC_FILES",
+ G_TYPE_STRING, value,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID)) {
+ g_warning ("Could not set GTK_RC_FILES: %s", error->message);
+ g_error_free (error);
+ }
- g_free (value);
+ g_free (value);
}
int
main (int argc, char **argv)
{
- gtk_init (&argc, &argv);
+ gtk_init (&argc, &argv);
- /* Point GTK_RC_FILES (for gtk 1.2) at a file that we change in in
- * gnome-settings-daemon.
- */
- set_gtk1_theme_rcfile ();
+ /* Point GTK_RC_FILES (for gtk 1.2) at a file that we change in in
+ * gnome-settings-daemon.
+ */
+ set_gtk1_theme_rcfile ();
- return 0;
+ return 0;
}
Modified: trunk/gnome-session/gsm-gconf.c
==============================================================================
--- trunk/gnome-session/gsm-gconf.c (original)
+++ trunk/gnome-session/gsm-gconf.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* gsm-gconf.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * gsm-gconf.c
* Copyright (C) 2007 Novell, Inc.
*
* FIXME: (C) on gconf-sanity-check call, gsm_get_conf_client,
@@ -20,9 +21,7 @@
* 02111-1307, USA.
*/
-#if HAVE_CONFIG_H
#include "config.h"
-#endif
#include <glib/gi18n.h>
@@ -45,42 +44,41 @@
void
gsm_gconf_init (void)
{
- GError *error = NULL;
- char *argv[2];
+ GError *error = NULL;
+ char *argv[2];
- /* Run gconf-sanity-check. As a side effect, this will cause gconfd
- * to be started. (We do this asynchronously so that other GSM
- * initialization can happen in parallel.)
- */
-
- argv[0] = GCONF_SANITY_CHECK;
- argv[1] = NULL;
-
- g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
- unset_display_setup, NULL, &gsc_pid, &error);
- if (error != NULL)
- {
- g_warning ("Failed to run gconf-sanity-check-2: %s\n",
- error->message);
- g_error_free (error);
-
- /* This probably means gconf-sanity-check wasn't found, which
- * really shouldn't happen, but we'll just ignore it for now as
- * long as gconf seems to be working later on...
- */
+ /* Run gconf-sanity-check. As a side effect, this will cause gconfd
+ * to be started. (We do this asynchronously so that other GSM
+ * initialization can happen in parallel.)
+ */
+
+ argv[0] = GCONF_SANITY_CHECK;
+ argv[1] = NULL;
+
+ g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
+ unset_display_setup, NULL, &gsc_pid, &error);
+ if (error != NULL) {
+ g_warning ("Failed to run gconf-sanity-check-2: %s\n",
+ error->message);
+ g_error_free (error);
+
+ /* This probably means gconf-sanity-check wasn't found, which
+ * really shouldn't happen, but we'll just ignore it for now as
+ * long as gconf seems to be working later on...
+ */
- gsc_pid = 0;
- }
+ gsc_pid = 0;
+ }
}
static void
unset_display_setup (gpointer user_data)
{
- /* Unset DISPLAY to make sure gconf-sanity-check spews errors to
- * stderr instead of trying to show a dialog (since it doesn't
- * compensate for the fact that a window manager isn't running yet.)
- */
- g_unsetenv ("DISPLAY");
+ /* Unset DISPLAY to make sure gconf-sanity-check spews errors to
+ * stderr instead of trying to show a dialog (since it doesn't
+ * compensate for the fact that a window manager isn't running yet.)
+ */
+ g_unsetenv ("DISPLAY");
}
/**
@@ -92,24 +90,23 @@
void
gsm_gconf_check (void)
{
- if (gsc_pid)
- {
- int status;
-
- /* Wait for gconf-sanity-check to finish */
- while (waitpid (gsc_pid, &status, 0) != gsc_pid)
- ;
- gsc_pid = 0;
-
- if (!WIFEXITED (status) || WEXITSTATUS (status) != 0)
- {
- /* FIXME: capture gconf-sanity-check's stderr */
- gsm_util_init_error (TRUE,
- _("There is a problem with the configuration server.\n"
- "(%s exited with status %d)"),
- GCONF_SANITY_CHECK, status);
- }
- }
+ if (gsc_pid) {
+ int status;
+
+ /* Wait for gconf-sanity-check to finish */
+ while (waitpid (gsc_pid, &status, 0) != gsc_pid) {
+ ;
+ }
+ gsc_pid = 0;
+
+ if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) {
+ /* FIXME: capture gconf-sanity-check's stderr */
+ gsm_util_init_error (TRUE,
+ _("There is a problem with the configuration server.\n"
+ "(%s exited with status %d)"),
+ GCONF_SANITY_CHECK, status);
+ }
+ }
}
/**
@@ -122,26 +119,24 @@
void
gsm_gconf_shutdown (void)
{
- GError *error;
- char *command;
- int status;
-
- command = g_strjoin (" ", GCONFTOOL_CMD, "--shutdown", NULL);
-
- status = 0;
- error = NULL;
- if (!g_spawn_command_line_sync (command, NULL, NULL, &status, &error))
- {
- g_warning ("Failed to execute '%s' on logout: %s\n",
- command, error->message);
- g_error_free (error);
- }
-
- if (status)
- {
- g_warning ("Running '%s' at logout returned an exit status of '%d'",
- command, status);
- }
+ GError *error;
+ char *command;
+ int status;
+
+ command = g_strjoin (" ", GCONFTOOL_CMD, "--shutdown", NULL);
+
+ status = 0;
+ error = NULL;
+ if (!g_spawn_command_line_sync (command, NULL, NULL, &status, &error)) {
+ g_warning ("Failed to execute '%s' on logout: %s\n",
+ command, error->message);
+ g_error_free (error);
+ }
+
+ if (status) {
+ g_warning ("Running '%s' at logout returned an exit status of '%d'",
+ command, status);
+ }
- g_free (command);
+ g_free (command);
}
Modified: trunk/gnome-session/gsm-util.c
==============================================================================
--- trunk/gnome-session/gsm-util.c (original)
+++ trunk/gnome-session/gsm-util.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* gsm-util.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * gsm-util.c
* Copyright (C) 2008 Lucas Rocha.
*
* This program is free software; you can redistribute it and/or
@@ -33,78 +34,77 @@
#include "gsm-util.h"
-gchar **
+char **
gsm_util_get_autostart_dirs ()
{
- GPtrArray *dirs;
- const char * const *system_config_dirs;
- const char * const *system_data_dirs;
- gint i;
-
- dirs = g_ptr_array_new ();
-
- g_ptr_array_add (dirs,
- g_build_filename (g_get_user_config_dir (),
- "autostart", NULL));
-
- system_data_dirs = g_get_system_data_dirs ();
- for (i = 0; system_data_dirs[i]; i++)
- {
- g_ptr_array_add (dirs,
- g_build_filename (system_data_dirs[i],
- "gnome", "autostart", NULL));
- }
-
- system_config_dirs = g_get_system_config_dirs ();
- for (i = 0; system_config_dirs[i]; i++)
- {
- g_ptr_array_add (dirs,
- g_build_filename (system_config_dirs[i],
- "autostart", NULL));
- }
+ GPtrArray *dirs;
+ const char * const *system_config_dirs;
+ const char * const *system_data_dirs;
+ int i;
+
+ dirs = g_ptr_array_new ();
+
+ g_ptr_array_add (dirs,
+ g_build_filename (g_get_user_config_dir (),
+ "autostart", NULL));
+
+ system_data_dirs = g_get_system_data_dirs ();
+ for (i = 0; system_data_dirs[i]; i++) {
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i],
+ "gnome", "autostart", NULL));
+ }
+
+ system_config_dirs = g_get_system_config_dirs ();
+ for (i = 0; system_config_dirs[i]; i++) {
+ g_ptr_array_add (dirs,
+ g_build_filename (system_config_dirs[i],
+ "autostart", NULL));
+ }
- g_ptr_array_add (dirs, NULL);
+ g_ptr_array_add (dirs, NULL);
- return (char **) g_ptr_array_free (dirs, FALSE);
+ return (char **) g_ptr_array_free (dirs, FALSE);
}
-gchar **
+char **
gsm_util_get_app_dirs ()
{
- GPtrArray *dirs;
- const char * const *system_data_dirs;
- gint i;
-
- dirs = g_ptr_array_new ();
-
- system_data_dirs = g_get_system_data_dirs ();
- for (i = 0; system_data_dirs[i]; i++)
- {
- g_ptr_array_add (dirs,
- g_build_filename (system_data_dirs[i], "applications",
- NULL));
- }
+ GPtrArray *dirs;
+ const char * const *system_data_dirs;
+ int i;
+
+ dirs = g_ptr_array_new ();
+
+ system_data_dirs = g_get_system_data_dirs ();
+ for (i = 0; system_data_dirs[i]; i++) {
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i],
+ "applications",
+ NULL));
+ }
- g_ptr_array_add (dirs, NULL);
+ g_ptr_array_add (dirs, NULL);
- return (char **) g_ptr_array_free (dirs, FALSE);
+ return (char **) g_ptr_array_free (dirs, FALSE);
}
gboolean
-gsm_util_text_is_blank (const gchar *str)
+gsm_util_text_is_blank (const char *str)
{
- if (str == NULL)
- return TRUE;
+ if (str == NULL) {
+ return TRUE;
+ }
+
+ while (*str) {
+ if (!isspace(*str)) {
+ return FALSE;
+ }
- while (*str)
- {
- if (!isspace(*str))
- return FALSE;
+ str++;
+ }
- str++;
- }
-
- return TRUE;
+ return TRUE;
}
/**
@@ -121,39 +121,38 @@
* itself, since no window manager will be running yet.)
**/
void
-gsm_util_init_error (gboolean fatal, const char *format, ...)
+gsm_util_init_error (gboolean fatal,
+ const char *format, ...)
{
- GtkWidget *dialog;
- char *msg;
- va_list args;
-
- va_start (args, format);
- msg = g_strdup_vprintf (format, args);
- va_end (args);
-
- /* If option parsing failed, Gtk won't have been initialized... */
- if (!gdk_display_get_default ())
- {
- if (!gtk_init_check (NULL, NULL))
- {
- /* Oh well, no X for you! */
- g_printerr (_("Unable to start login session (and unable connect to the X server)"));
- g_printerr (msg);
- exit (1);
- }
- }
-
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE, "%s", msg);
+ GtkWidget *dialog;
+ char *msg;
+ va_list args;
+
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ /* If option parsing failed, Gtk won't have been initialized... */
+ if (!gdk_display_get_default ()) {
+ if (!gtk_init_check (NULL, NULL)) {
+ /* Oh well, no X for you! */
+ g_printerr (_("Unable to start login session (and unable connect to the X server)"));
+ g_printerr (msg);
+ exit (1);
+ }
+ }
+
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE, "%s", msg);
- g_free (msg);
+ g_free (msg);
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- gtk_main_quit ();
+ gtk_main_quit ();
}
/**
@@ -166,120 +165,124 @@
char *
gsm_util_generate_startup_id (void)
{
- static int sequence = -1;
- static guint rand1 = 0, rand2 = 0;
- static pid_t pid = 0;
- struct timeval tv;
-
- /* The XSMP spec defines the ID as:
- *
- * Version: "1"
- * Address type and address:
- * "1" + an IPv4 address as 8 hex digits
- * "2" + a DECNET address as 12 hex digits
- * "6" + an IPv6 address as 32 hex digits
- * Time stamp: milliseconds since UNIX epoch as 13 decimal digits
- * Process-ID type and process-ID:
- * "1" + POSIX PID as 10 decimal digits
- * Sequence number as 4 decimal digits
- *
- * XSMP client IDs are supposed to be globally unique: if
- * SmsGenerateClientID() is unable to determine a network
- * address for the machine, it gives up and returns %NULL.
- * GNOME and KDE have traditionally used a fourth address
- * format in this case:
- * "0" + 16 random hex digits
- *
- * We don't even bother trying SmsGenerateClientID(), since the
- * user's IP address is probably "192.168.1.*" anyway, so a random
- * number is actually more likely to be globally unique.
- */
-
- if (!rand1)
- {
- rand1 = g_random_int ();
- rand2 = g_random_int ();
- pid = getpid ();
- }
-
- sequence = (sequence + 1) % 10000;
- gettimeofday (&tv, NULL);
- return g_strdup_printf ("10%.04x%.04x%.10lu%.3u%.10lu%.4d",
- rand1, rand2,
- (unsigned long) tv.tv_sec,
- (unsigned) tv.tv_usec,
- (unsigned long) pid,
- sequence);
+ static int sequence = -1;
+ static guint rand1 = 0;
+ static guint rand2 = 0;
+ static pid_t pid = 0;
+ struct timeval tv;
+
+ /* The XSMP spec defines the ID as:
+ *
+ * Version: "1"
+ * Address type and address:
+ * "1" + an IPv4 address as 8 hex digits
+ * "2" + a DECNET address as 12 hex digits
+ * "6" + an IPv6 address as 32 hex digits
+ * Time stamp: milliseconds since UNIX epoch as 13 decimal digits
+ * Process-ID type and process-ID:
+ * "1" + POSIX PID as 10 decimal digits
+ * Sequence number as 4 decimal digits
+ *
+ * XSMP client IDs are supposed to be globally unique: if
+ * SmsGenerateClientID() is unable to determine a network
+ * address for the machine, it gives up and returns %NULL.
+ * GNOME and KDE have traditionally used a fourth address
+ * format in this case:
+ * "0" + 16 random hex digits
+ *
+ * We don't even bother trying SmsGenerateClientID(), since the
+ * user's IP address is probably "192.168.1.*" anyway, so a random
+ * number is actually more likely to be globally unique.
+ */
+
+ if (!rand1) {
+ rand1 = g_random_int ();
+ rand2 = g_random_int ();
+ pid = getpid ();
+ }
+
+ sequence = (sequence + 1) % 10000;
+ gettimeofday (&tv, NULL);
+ return g_strdup_printf ("10%.04x%.04x%.10lu%.3u%.10lu%.4d",
+ rand1,
+ rand2,
+ (unsigned long) tv.tv_sec,
+ (unsigned) tv.tv_usec,
+ (unsigned long) pid,
+ sequence);
}
static gboolean
gsm_util_update_activation_environment (const char *variable,
- const char *value,
- GError **error)
+ const char *value,
+ GError **error)
{
- DBusGConnection *dbus_connection;
- DBusGProxy *bus_proxy;
- GHashTable *environment;
- gboolean environment_updated;
+ DBusGConnection *dbus_connection;
+ DBusGProxy *bus_proxy;
+ GHashTable *environment;
+ gboolean environment_updated;
- environment_updated = FALSE;
- bus_proxy = NULL;
- environment = NULL;
+ environment_updated = FALSE;
+ bus_proxy = NULL;
+ environment = NULL;
- dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
+ dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
- if (dbus_connection == NULL)
- return FALSE;
+ if (dbus_connection == NULL) {
+ return FALSE;
+ }
- bus_proxy = dbus_g_proxy_new_for_name_owner (dbus_connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- error);
+ bus_proxy = dbus_g_proxy_new_for_name_owner (dbus_connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ error);
- if (bus_proxy == NULL)
- goto out;
+ if (bus_proxy == NULL) {
+ goto out;
+ }
- environment = g_hash_table_new (g_str_hash, g_str_equal);
+ environment = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (environment, (void *) variable, (void *) value);
+ g_hash_table_insert (environment, (void *) variable, (void *) value);
- if (!dbus_g_proxy_call (bus_proxy,
- "UpdateActivationEnvironment", error,
- DBUS_TYPE_G_STRING_STRING_HASHTABLE,
- environment, G_TYPE_INVALID,
- G_TYPE_INVALID))
- goto out;
+ if (!dbus_g_proxy_call (bus_proxy,
+ "UpdateActivationEnvironment", error,
+ DBUS_TYPE_G_STRING_STRING_HASHTABLE,
+ environment, G_TYPE_INVALID,
+ G_TYPE_INVALID))
+ goto out;
- environment_updated = TRUE;
+ environment_updated = TRUE;
-out:
+ out:
- if (bus_proxy != NULL)
- g_object_unref (bus_proxy);
+ if (bus_proxy != NULL) {
+ g_object_unref (bus_proxy);
+ }
- if (environment != NULL)
- g_hash_table_destroy (environment);
+ if (environment != NULL) {
+ g_hash_table_destroy (environment);
+ }
- return environment_updated;
+ return environment_updated;
}
void
gsm_util_setenv (const char *variable,
const char *value)
{
- GError *bus_error;
+ GError *bus_error;
- g_setenv (variable, value, TRUE);
+ g_setenv (variable, value, TRUE);
- bus_error = NULL;
+ bus_error = NULL;
- /* If this fails it isn't fatal, it means some things like session
- * management and keyring won't work in activated clients.
- */
- if (!gsm_util_update_activation_environment (variable, value, &bus_error))
- {
- g_warning ("Could not make bus activated clients aware of %s=%s environment variable: %s", variable, value, bus_error->message);
- g_error_free (bus_error);
- }
+ /* If this fails it isn't fatal, it means some things like session
+ * management and keyring won't work in activated clients.
+ */
+ if (!gsm_util_update_activation_environment (variable, value, &bus_error)) {
+ g_warning ("Could not make bus activated clients aware of %s=%s environment variable: %s", variable, value, bus_error->message);
+ g_error_free (bus_error);
+ }
}
Modified: trunk/splash/gnome-login-sound.c
==============================================================================
--- trunk/splash/gnome-login-sound.c (original)
+++ trunk/splash/gnome-login-sound.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* gnome-login-sound.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * gnome-login-sound.c
* Copyright (C) 1999, 2007 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
@@ -17,9 +18,7 @@
* 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <libgnome/libgnome.h>
#include <gconf/gconf-client.h>
@@ -32,38 +31,35 @@
static char *
get_sound_file_from_config (const char *event,
- const char *config_file,
- gboolean *was_set)
+ const char *config_file,
+ gboolean *was_set)
{
- char *key;
- char *sound_file;
+ char *key;
+ char *sound_file;
- key = g_strdup_printf ("=%s=%s/file", config_file, event);
- sound_file = gnome_config_get_string (key);
- g_free (key);
-
- if (!sound_file)
- {
- *was_set = FALSE;
- return NULL;
- }
-
- *was_set = TRUE;
- if (!sound_file[0])
- {
- return NULL;
- }
-
- if (!g_path_is_absolute (sound_file))
- {
- char *tmp_sound_file;
-
- tmp_sound_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, sound_file, TRUE, NULL);
- g_free (sound_file);
- sound_file = tmp_sound_file;
- }
+ key = g_strdup_printf ("=%s=%s/file", config_file, event);
+ sound_file = gnome_config_get_string (key);
+ g_free (key);
+
+ if (!sound_file) {
+ *was_set = FALSE;
+ return NULL;
+ }
+
+ *was_set = TRUE;
+ if (!sound_file[0]) {
+ return NULL;
+ }
+
+ if (!g_path_is_absolute (sound_file)) {
+ char *tmp_sound_file;
+
+ tmp_sound_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, sound_file, TRUE, NULL);
+ g_free (sound_file);
+ sound_file = tmp_sound_file;
+ }
- return sound_file;
+ return sound_file;
}
#define SOUND_EVENT_FILE "sound/events/gnome-2.soundlist"
@@ -71,29 +67,27 @@
static char *
get_sound_file (const char *event)
{
- char *config_file, *sound_file;
- gboolean was_set;
+ char *config_file, *sound_file;
+ gboolean was_set;
- config_file = gnome_util_home_file (SOUND_EVENT_FILE);
- if (config_file)
- {
- sound_file = get_sound_file_from_config (event, config_file, &was_set);
- g_free (config_file);
-
- if (was_set)
- return sound_file;
- }
-
- config_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_CONFIG, SOUND_EVENT_FILE, TRUE, NULL);
- if (config_file)
- {
- sound_file = get_sound_file_from_config (event, config_file, &was_set);
- g_free (config_file);
+ config_file = gnome_util_home_file (SOUND_EVENT_FILE);
+ if (config_file) {
+ sound_file = get_sound_file_from_config (event, config_file, &was_set);
+ g_free (config_file);
+
+ if (was_set)
+ return sound_file;
+ }
+
+ config_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_CONFIG, SOUND_EVENT_FILE, TRUE, NULL);
+ if (config_file) {
+ sound_file = get_sound_file_from_config (event, config_file, &was_set);
+ g_free (config_file);
- return sound_file;
- }
+ return sound_file;
+ }
- return NULL;
+ return NULL;
}
#define ENABLE_SOUNDS_KEY "/desktop/gnome/sound/event_sounds"
@@ -101,71 +95,71 @@
static void
maybe_play_sound (const char *event)
{
- GConfClient *gconf;
- GError *error = NULL;
- gboolean enable_sounds;
- char *sound_file;
-
- gconf = gconf_client_get_default ();
- enable_sounds = gconf_client_get_bool (gconf, ENABLE_SOUNDS_KEY, &error);
- if (error)
- {
- g_warning ("Error getting value of " ENABLE_SOUNDS_KEY ": %s", error->message);
- g_error_free (error);
- return; /* assume FALSE */
- }
-
- if (!enable_sounds)
- return;
-
- sound_file = get_sound_file (event);
- if (sound_file)
- {
- gnome_sound_play (sound_file);
- g_free (sound_file);
- }
+ GConfClient *gconf;
+ GError *error;
+ gboolean enable_sounds;
+ char *sound_file;
+
+ gconf = gconf_client_get_default ();
+ error = NULL;
+ enable_sounds = gconf_client_get_bool (gconf, ENABLE_SOUNDS_KEY, &error);
+ if (error != NULL) {
+ g_warning ("Error getting value of " ENABLE_SOUNDS_KEY ": %s", error->message);
+ g_error_free (error);
+ return; /* assume FALSE */
+ }
+
+ if (!enable_sounds) {
+ return;
+ }
+
+ sound_file = get_sound_file (event);
+ if (sound_file != NULL) {
+ gnome_sound_play (sound_file);
+ g_free (sound_file);
+ }
- return;
+ return;
}
static gboolean
idle_quit (gpointer user_data)
{
- gtk_main_quit ();
- return FALSE;
+ gtk_main_quit ();
+ return FALSE;
}
static gboolean logout = FALSE;
static const GOptionEntry options[] = {
- { "logout", 0, 0, G_OPTION_ARG_NONE, &logout, N_("Play logout sound instead of login"), NULL },
+ { "logout", 0, 0, G_OPTION_ARG_NONE, &logout, N_("Play logout sound instead of login"), NULL },
- { NULL }
+ { NULL }
};
int
main (int argc, char *argv[])
{
- GOptionContext *context;
+ GOptionContext *context;
- g_type_init ();
+ g_type_init ();
- context = g_option_context_new (_("- GNOME login/logout sound"));
- g_option_context_add_main_entries (context, options, NULL);
+ context = g_option_context_new (_("- GNOME login/logout sound"));
+ g_option_context_add_main_entries (context, options, NULL);
- gnome_program_init (PACKAGE, VERSION,
- EGG_SM_CLIENT_LIBGNOMEUI_MODULE,
- argc, argv,
- GNOME_PARAM_GOPTION_CONTEXT, context,
- NULL);
+ gnome_program_init (PACKAGE, VERSION,
+ EGG_SM_CLIENT_LIBGNOMEUI_MODULE,
+ argc, argv,
+ GNOME_PARAM_GOPTION_CONTEXT, context,
+ NULL);
- maybe_play_sound (logout ? "logout" : "login");
+ maybe_play_sound (logout ? "logout" : "login");
- /* We need to start the main loop to force EggSMClient to register
- * so the session manager will know we started successfully.
- */
- g_idle_add (idle_quit, NULL);
- gtk_main ();
+ /* We need to start the main loop to force EggSMClient to register
+ * so the session manager will know we started successfully.
+ */
+ g_idle_add (idle_quit, NULL);
+ gtk_main ();
- return 0;
+ return 0;
}
Modified: trunk/splash/gnome-session-splash.c
==============================================================================
--- trunk/splash/gnome-session-splash.c (original)
+++ trunk/splash/gnome-session-splash.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* gnome-session-splash.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * gnome-session-splash.c
* Copyright (C) 2007 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
@@ -17,13 +18,11 @@
* 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <string.h>
-#include <gtk/gtkmain.h>
+#include <gtk/gtk.h>
#include <gdk/gdkx.h>
@@ -51,250 +50,252 @@
static DBusGConnection *
get_session_bus (void)
{
- GError *error;
- DBusGConnection *bus;
- DBusConnection *connection;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (bus == NULL)
- {
- g_warning ("Couldn't connect to session bus: %s",
- error->message);
- g_error_free (error);
- goto out;
- }
+ GError *error;
+ DBusGConnection *bus;
+ DBusConnection *connection;
+
+ error = NULL;
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to session bus: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
- connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, TRUE);
+ connection = dbus_g_connection_get_connection (bus);
+ dbus_connection_set_exit_on_disconnect (connection, TRUE);
-out:
- return bus;
+ out:
+ return bus;
}
static void
on_session_running (DBusGProxy *proxy, gpointer data)
{
- gtk_main_quit ();
+ gtk_main_quit ();
}
static void
set_session_running_handler ()
{
- DBusGConnection *bus;
- DBusGProxy *session_proxy;
+ DBusGConnection *bus;
+ DBusGProxy *session_proxy;
- bus = get_session_bus ();
- if (bus == NULL)
- {
- g_warning ("Could not get a connection to the bus");
- return;
- }
-
- session_proxy =
- dbus_g_proxy_new_for_name (bus,
- GNOME_SESSION_DBUS_NAME,
- GNOME_SESSION_DBUS_OBJECT,
- GNOME_SESSION_DBUS_INTERFACE);
-
- dbus_g_object_register_marshaller (
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- G_TYPE_INVALID);
-
- dbus_g_proxy_add_signal (session_proxy,
- "SessionRunning",
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (session_proxy,
- "SessionRunning",
- G_CALLBACK (on_session_running),
- NULL,
- NULL);
+ bus = get_session_bus ();
+ if (bus == NULL) {
+ g_warning ("Could not get a connection to the bus");
+ return;
+ }
+
+ session_proxy = dbus_g_proxy_new_for_name (bus,
+ GNOME_SESSION_DBUS_NAME,
+ GNOME_SESSION_DBUS_OBJECT,
+ GNOME_SESSION_DBUS_INTERFACE);
+
+ dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_add_signal (session_proxy,
+ "SessionRunning",
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (session_proxy,
+ "SessionRunning",
+ G_CALLBACK (on_session_running),
+ NULL,
+ NULL);
- dbus_g_connection_unref (bus);
+ dbus_g_connection_unref (bus);
}
static void
-event_func (SnMonitorEvent *event, void *user_data)
+event_func (SnMonitorEvent *event,
+ void *user_data)
{
- GsmSplashWindow *splash = user_data;
- SnStartupSequence *seq;
+ GsmSplashWindow *splash = user_data;
+ SnStartupSequence *seq;
- seq = sn_monitor_event_get_startup_sequence (event);
+ seq = sn_monitor_event_get_startup_sequence (event);
- switch (sn_monitor_event_get_type (event))
- {
- case SN_MONITOR_EVENT_INITIATED:
- gsm_splash_window_start (splash,
- sn_startup_sequence_get_name (seq),
- sn_startup_sequence_get_icon_name (seq));
- break;
-
- case SN_MONITOR_EVENT_COMPLETED:
- /* GSM (ab)uses startup notification to tell us when to quit */
- /* FIXME: Nope, doesn't actually work; libsn eats the notification */
- if (!strcmp (sn_startup_sequence_get_id (seq), "splash"))
- {
- gtk_main_quit ();
- return;
- }
-
- gsm_splash_window_finish (splash,
- sn_startup_sequence_get_name (seq));
- break;
-
- default:
- break;
- }
+ switch (sn_monitor_event_get_type (event)) {
+ case SN_MONITOR_EVENT_INITIATED:
+ gsm_splash_window_start (splash,
+ sn_startup_sequence_get_name (seq),
+ sn_startup_sequence_get_icon_name (seq));
+ break;
+
+ case SN_MONITOR_EVENT_COMPLETED:
+ /* GSM (ab)uses startup notification to tell us when to quit */
+ /* FIXME: Nope, doesn't actually work; libsn eats the notification */
+ if (!strcmp (sn_startup_sequence_get_id (seq), "splash")) {
+ gtk_main_quit ();
+ return;
+ }
+
+ gsm_splash_window_finish (splash,
+ sn_startup_sequence_get_name (seq));
+ break;
+
+ default:
+ break;
+ }
}
static gboolean
-splash_clicked (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+splash_clicked (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
{
- gtk_main_quit ();
- return TRUE;
+ gtk_main_quit ();
+ return TRUE;
}
static GdkFilterReturn
-filter_func (GdkXEvent *gdkxevent, GdkEvent *event, gpointer user_data)
+filter_func (GdkXEvent *gdkxevent,
+ GdkEvent *event,
+ gpointer user_data)
{
- SnDisplay *sn_display = user_data;
+ SnDisplay *sn_display = user_data;
- sn_display_process_event (sn_display, (XEvent *)gdkxevent);
- return GDK_FILTER_CONTINUE;
+ sn_display_process_event (sn_display, (XEvent *)gdkxevent);
+ return GDK_FILTER_CONTINUE;
}
static void
push_trap_func (SnDisplay *display, Display *xdisplay)
{
- gdk_error_trap_push ();
+ gdk_error_trap_push ();
}
static void
pop_trap_func (SnDisplay *display, Display *xdisplay)
{
- gdk_error_trap_pop ();
+ gdk_error_trap_pop ();
}
static GdkPixbuf *
load_pixbuf (const char *filename)
{
- GdkPixbuf *pixbuf;
- GError *error = NULL;
- char *path;
-
- if (!filename)
- return NULL;
-
- path = gnome_program_locate_file (NULL,
- GNOME_FILE_DOMAIN_PIXMAP,
- filename, TRUE,
- NULL);
- if (!path)
- return NULL;
-
- pixbuf = gdk_pixbuf_new_from_file (path, &error);
- if (!pixbuf)
- {
- g_warning ("Failed to load image from '%s': %s\n",
- path, error->message);
- g_error_free (error);
- }
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+ char *path;
+
+ if (filename == NULL) {
+ return NULL;
+ }
+
+ path = gnome_program_locate_file (NULL,
+ GNOME_FILE_DOMAIN_PIXMAP,
+ filename, TRUE,
+ NULL);
+ if (path == NULL) {
+ return NULL;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file (path, &error);
+ if (pixbuf == NULL) {
+ g_warning ("Failed to load image from '%s': %s\n",
+ path, error->message);
+ g_error_free (error);
+ }
- return pixbuf;
+ return pixbuf;
}
static GdkPixbuf *
load_splash_pixbuf (void)
{
- GConfClient *gconf;
- char *filename;
- GdkPixbuf *pixbuf;
-
- gconf = gconf_client_get_default ();
- filename = gconf_client_get_string (gconf,
- "/apps/gnome-session/options/splash_image",
- NULL);
-
- if (filename)
- {
- pixbuf = load_pixbuf (filename);
- g_free (filename);
- }
- else
- pixbuf = NULL;
+ GConfClient *gconf;
+ char *filename;
+ GdkPixbuf *pixbuf;
+
+ gconf = gconf_client_get_default ();
+ filename = gconf_client_get_string (gconf,
+ "/apps/gnome-session/options/splash_image",
+ NULL);
+
+ if (filename != NULL) {
+ pixbuf = load_pixbuf (filename);
+ g_free (filename);
+ } else {
+ pixbuf = NULL;
+ }
+
+ if (pixbuf == NULL) {
+ pixbuf = load_pixbuf ("splash/gnome-splash.png");
+ }
- if (!pixbuf)
- pixbuf = load_pixbuf ("splash/gnome-splash.png");
-
- return pixbuf;
+ return pixbuf;
}
static void
setup_splash_window (void)
{
- GdkDisplay *display;
- GdkScreen *screen;
- GdkWindow *root;
- SnDisplay *sn_display;
- GtkWidget *splash_widget;
- GsmSplashWindow *splash;
- GdkPixbuf *background;
-
- /* Create the splash window */
- background = load_splash_pixbuf ();
- splash_widget = gsm_splash_window_new (background);
- splash = (GsmSplashWindow *)splash_widget;
- g_object_unref (background);
-
- /* Set up startup notification monitoring */
- display = gdk_display_get_default ();
- screen = gdk_display_get_default_screen (display);
-
- sn_display = sn_display_new (gdk_x11_display_get_xdisplay (display),
- push_trap_func, pop_trap_func);
- sn_monitor_context_new (sn_display, gdk_screen_get_number (screen),
- event_func, splash, NULL);
-
- root = gdk_screen_get_root_window (screen);
- gdk_window_set_events (root, gdk_window_get_events (root) | GDK_PROPERTY_CHANGE_MASK);
- gdk_window_add_filter (NULL, filter_func, sn_display);
-
- /* Display the splash */
- gtk_widget_show (splash_widget);
- g_signal_connect (splash, "button-release-event",
- G_CALLBACK (splash_clicked), NULL);
+ GdkDisplay *display;
+ GdkScreen *screen;
+ GdkWindow *root;
+ SnDisplay *sn_display;
+ GtkWidget *splash_widget;
+ GsmSplashWindow *splash;
+ GdkPixbuf *background;
+
+ /* Create the splash window */
+ background = load_splash_pixbuf ();
+ splash_widget = gsm_splash_window_new (background);
+ splash = (GsmSplashWindow *)splash_widget;
+ g_object_unref (background);
+
+ /* Set up startup notification monitoring */
+ display = gdk_display_get_default ();
+ screen = gdk_display_get_default_screen (display);
+
+ sn_display = sn_display_new (gdk_x11_display_get_xdisplay (display),
+ push_trap_func, pop_trap_func);
+ sn_monitor_context_new (sn_display, gdk_screen_get_number (screen),
+ event_func, splash, NULL);
+
+ root = gdk_screen_get_root_window (screen);
+ gdk_window_set_events (root, gdk_window_get_events (root) | GDK_PROPERTY_CHANGE_MASK);
+ gdk_window_add_filter (NULL, filter_func, sn_display);
+
+ /* Display the splash */
+ gtk_widget_show (splash_widget);
+ g_signal_connect (splash, "button-release-event",
+ G_CALLBACK (splash_clicked), NULL);
}
static void
quit (EggSMClient *smclient, gpointer user_data)
{
- gtk_main_quit ();
+ gtk_main_quit ();
}
int
main (int argc, char *argv[])
{
- GOptionContext *context;
+ GOptionContext *context;
- g_type_init ();
+ g_type_init ();
- context = g_option_context_new (_("- GNOME Splash Screen"));
+ context = g_option_context_new (_("- GNOME Splash Screen"));
- gnome_program_init ("gnome-session-splash", VERSION,
- EGG_SM_CLIENT_LIBGNOMEUI_MODULE,
- argc, argv,
- GNOME_PARAM_GOPTION_CONTEXT, context,
- NULL);
+ gnome_program_init ("gnome-session-splash", VERSION,
+ EGG_SM_CLIENT_LIBGNOMEUI_MODULE,
+ argc, argv,
+ GNOME_PARAM_GOPTION_CONTEXT, context,
+ NULL);
- g_signal_connect (egg_sm_client_get (), "quit",
- G_CALLBACK (quit), NULL);
+ g_signal_connect (egg_sm_client_get (),
+ "quit",
+ G_CALLBACK (quit),
+ NULL);
- set_session_running_handler ();
+ set_session_running_handler ();
- setup_splash_window ();
- gtk_main ();
+ setup_splash_window ();
+ gtk_main ();
- return 0;
+ return 0;
}
Modified: trunk/splash/splash-window.c
==============================================================================
--- trunk/splash/splash-window.c (original)
+++ trunk/splash/splash-window.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* splash-window.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * splash-window.c
* Copyright (C) 1999, 2002, 2007 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
@@ -46,523 +47,507 @@
static gboolean update_trans_effect (gpointer);
typedef struct {
- GdkRectangle position;
- GdkPixbuf *unscaled;
- GdkPixbuf *scaled;
- GdkPixbuf *scaled_copy;
- gint trans_count;
+ GdkRectangle position;
+ GdkPixbuf *unscaled;
+ GdkPixbuf *scaled;
+ GdkPixbuf *scaled_copy;
+ gint trans_count;
} SplashIcon;
typedef struct {
- GsmSplashWindow *splash;
- SplashIcon *si;
- int width;
- int height;
- int n_channels;
- int rowstride_trans;
- int rowstride_orig;
- guchar *pixels_trans;
- guchar *pixels_orig;
+ GsmSplashWindow *splash;
+ SplashIcon *si;
+ int width;
+ int height;
+ int n_channels;
+ int rowstride_trans;
+ int rowstride_orig;
+ guchar *pixels_trans;
+ guchar *pixels_orig;
} TransParam;
static gboolean
re_scale (GsmSplashWindow *splash)
{
- int i;
+ int i;
- static struct {
- int icon_size;
- int icon_spacing;
- int icon_rows;
- } scales[] = {
- { SPLASH_BASE_ICON_SIZE,
- SPLASH_ICON_SPACING,
- SPLASH_BASE_ICON_ROWS },
- { 24, 3, 1 },
- { 24, 3, 2 },
- { 16, 2, 2 },
- { 16, 2, 3 },
- { 12, 1, 3 },
- { 8, 1, 4 },
- { 4, 1, 5 },
- { 4, 1, 4 }
- };
-
- for (i = 0; i < G_N_ELEMENTS (scales); i++)
- {
- if (scales [i].icon_size < splash->icon_size ||
- scales [i].icon_rows > splash->icon_rows)
- {
- splash->icon_size = scales [i].icon_size;
- splash->icon_spacing = scales [i].icon_spacing;
- splash->icon_rows = scales [i].icon_rows;
- break;
- }
- }
-
- if (i == G_N_ELEMENTS (scales))
- {
- g_warning ("Too many inits - overflowing");
- return FALSE;
- }
- else
- return TRUE;
+ static struct {
+ int icon_size;
+ int icon_spacing;
+ int icon_rows;
+ } scales[] = {
+ { SPLASH_BASE_ICON_SIZE,
+ SPLASH_ICON_SPACING,
+ SPLASH_BASE_ICON_ROWS },
+ { 24, 3, 1 },
+ { 24, 3, 2 },
+ { 16, 2, 2 },
+ { 16, 2, 3 },
+ { 12, 1, 3 },
+ { 8, 1, 4 },
+ { 4, 1, 5 },
+ { 4, 1, 4 }
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (scales); i++)
+ {
+ if (scales [i].icon_size < splash->icon_size ||
+ scales [i].icon_rows > splash->icon_rows) {
+ splash->icon_size = scales [i].icon_size;
+ splash->icon_spacing = scales [i].icon_spacing;
+ splash->icon_rows = scales [i].icon_rows;
+ break;
+ }
+ }
+
+ if (i == G_N_ELEMENTS (scales)) {
+ g_warning ("Too many inits - overflowing");
+ return FALSE;
+ } else {
+ return TRUE;
+ }
}
static void
calc_text_box (GsmSplashWindow *splash)
{
- GtkAllocation *allocation = >K_WIDGET (splash)->allocation;
- PangoRectangle pixel_rect;
+ GtkAllocation *allocation = >K_WIDGET (splash)->allocation;
+ PangoRectangle pixel_rect;
- pango_layout_get_pixel_extents (splash->layout, NULL, &pixel_rect);
+ pango_layout_get_pixel_extents (splash->layout, NULL, &pixel_rect);
- splash->text_box.x = (allocation->x + allocation->width / 2 -
- pixel_rect.width / 2);
- splash->text_box.y = (allocation->y + allocation->height -
- pixel_rect.height - SPLASH_LABEL_V_OFFSET);
- splash->text_box.width = pixel_rect.width + 1;
- splash->text_box.height = pixel_rect.height + 1;
+ splash->text_box.x = (allocation->x + allocation->width / 2 -
+ pixel_rect.width / 2);
+ splash->text_box.y = (allocation->y + allocation->height -
+ pixel_rect.height - SPLASH_LABEL_V_OFFSET);
+ splash->text_box.width = pixel_rect.width + 1;
+ splash->text_box.height = pixel_rect.height + 1;
}
static gboolean
splash_window_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+ GdkEventExpose *event)
{
- GList *l;
- GdkRectangle exposed;
- GsmSplashWindow *splash = GSM_SPLASH_WINDOW (widget);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- for (l = splash->icons; l; l = l->next)
- {
- SplashIcon *si = l->data;
-
- if (gdk_rectangle_intersect (&event->area,
- &si->position,
- &exposed))
- {
- gdk_pixbuf_render_to_drawable (si->scaled, widget->window,
- widget->style->black_gc,
- exposed.x - si->position.x,
- exposed.y - si->position.y,
- exposed.x, exposed.y,
- exposed.width, exposed.height,
- GDK_RGB_DITHER_MAX,
- exposed.x, exposed.y);
- }
- }
-
- if (splash->layout)
- {
- calc_text_box (splash);
- if (gdk_rectangle_intersect (&event->area, &splash->text_box, &exposed))
- {
- /* drop shadow */
- gdk_draw_layout (widget->window,
- widget->style->black_gc,
- splash->text_box.x + 1, splash->text_box.y + 1,
- splash->layout);
-
- /* text */
- gdk_draw_layout (widget->window,
- widget->style->white_gc,
- splash->text_box.x, splash->text_box.y,
- splash->layout);
- }
- }
+ GList *l;
+ GdkRectangle exposed;
+ GsmSplashWindow *splash = GSM_SPLASH_WINDOW (widget);
+
+ if (!GTK_WIDGET_DRAWABLE (widget)) {
+ return FALSE;
+ }
+
+ for (l = splash->icons; l; l = l->next) {
+ SplashIcon *si = l->data;
+
+ if (gdk_rectangle_intersect (&event->area,
+ &si->position,
+ &exposed)) {
+ gdk_pixbuf_render_to_drawable (si->scaled, widget->window,
+ widget->style->black_gc,
+ exposed.x - si->position.x,
+ exposed.y - si->position.y,
+ exposed.x, exposed.y,
+ exposed.width, exposed.height,
+ GDK_RGB_DITHER_MAX,
+ exposed.x, exposed.y);
+ }
+ }
+
+ if (splash->layout) {
+ calc_text_box (splash);
+ if (gdk_rectangle_intersect (&event->area, &splash->text_box, &exposed)) {
+ /* drop shadow */
+ gdk_draw_layout (widget->window,
+ widget->style->black_gc,
+ splash->text_box.x + 1, splash->text_box.y + 1,
+ splash->layout);
+
+ /* text */
+ gdk_draw_layout (widget->window,
+ widget->style->white_gc,
+ splash->text_box.x, splash->text_box.y,
+ splash->layout);
+ }
+ }
- return FALSE;
+ return FALSE;
}
static void
splash_window_realize (GtkWidget *widget)
{
- GsmSplashWindow *splash = (GsmSplashWindow *) widget;
+ GsmSplashWindow *splash = (GsmSplashWindow *) widget;
- GTK_WIDGET_CLASS (gsm_splash_window_parent_class)->realize (widget);
+ GTK_WIDGET_CLASS (gsm_splash_window_parent_class)->realize (widget);
- if (splash->background && widget->window)
- {
- GdkPixmap *pixmap = NULL;
- GdkBitmap *mask = NULL;
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (widget);
- pixmap = gdk_pixmap_new (widget->window,
- gdk_pixbuf_get_width (splash->background),
- gdk_pixbuf_get_height (splash->background),
- -1);
-
- if (pixmap)
- {
- GtkStyle *style;
-
- /* we want dither_max for 16-bits people */
- gdk_draw_pixbuf (pixmap, NULL, splash->background,
- 0, 0, 0, 0, -1, -1,
- GDK_RGB_DITHER_MAX, 0, 0);
-
- style = gtk_style_copy (widget->style);
- style->bg_pixmap[GTK_STATE_NORMAL] = pixmap;
-
- gtk_widget_set_style (widget, style);
- g_object_unref (style);
-
- gdk_pixbuf_render_pixmap_and_mask_for_colormap (splash->background,
- colormap,
- NULL,
- &mask,
- 125);
-
- if (mask)
- {
- gdk_window_shape_combine_mask (widget->window, mask, 0, 0);
- g_object_unref (mask);
- }
-
- gtk_style_set_background (widget->style, widget->window,
- GTK_STATE_NORMAL);
- }
- }
+ if (splash->background && widget->window) {
+ GdkPixmap *pixmap = NULL;
+ GdkBitmap *mask = NULL;
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (widget);
+ pixmap = gdk_pixmap_new (widget->window,
+ gdk_pixbuf_get_width (splash->background),
+ gdk_pixbuf_get_height (splash->background),
+ -1);
+
+ if (pixmap) {
+ GtkStyle *style;
+
+ /* we want dither_max for 16-bits people */
+ gdk_draw_pixbuf (pixmap, NULL, splash->background,
+ 0, 0, 0, 0, -1, -1,
+ GDK_RGB_DITHER_MAX, 0, 0);
+
+ style = gtk_style_copy (widget->style);
+ style->bg_pixmap[GTK_STATE_NORMAL] = pixmap;
+
+ gtk_widget_set_style (widget, style);
+ g_object_unref (style);
+
+ gdk_pixbuf_render_pixmap_and_mask_for_colormap (splash->background,
+ colormap,
+ NULL,
+ &mask,
+ 125);
+
+ if (mask) {
+ gdk_window_shape_combine_mask (widget->window, mask, 0, 0);
+ g_object_unref (mask);
+ }
+
+ gtk_style_set_background (widget->style, widget->window,
+ GTK_STATE_NORMAL);
+ }
+ }
}
static void
splash_icon_destroy (SplashIcon *si)
{
- g_object_unref (si->unscaled);
- if (si->scaled)
- g_object_unref (si->scaled);
- if (si->scaled_copy)
- g_object_unref (si->scaled_copy);
+ g_object_unref (si->unscaled);
+ if (si->scaled) {
+ g_object_unref (si->scaled);
+ }
+ if (si->scaled_copy) {
+ g_object_unref (si->scaled_copy);
+ }
- g_free (si);
+ g_free (si);
}
static void
splash_window_finalize (GObject *object)
{
- GsmSplashWindow *splash = (GsmSplashWindow *) object;
+ GsmSplashWindow *splash = (GsmSplashWindow *) object;
- g_object_unref (splash->icon_theme);
- splash->icon_theme = NULL;
+ g_object_unref (splash->icon_theme);
+ splash->icon_theme = NULL;
- g_list_foreach (splash->icons, (GFunc) splash_icon_destroy, NULL);
- g_list_free (splash->icons);
+ g_list_foreach (splash->icons, (GFunc) splash_icon_destroy, NULL);
+ g_list_free (splash->icons);
- if (splash->background)
- g_object_unref (splash->background);
- splash->background = NULL;
+ if (splash->background != NULL) {
+ g_object_unref (splash->background);
+ }
+ splash->background = NULL;
- g_object_unref (splash->layout);
- splash->layout = NULL;
+ g_object_unref (splash->layout);
+ splash->layout = NULL;
- G_OBJECT_CLASS (gsm_splash_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gsm_splash_window_parent_class)->finalize (object);
}
static void
gsm_splash_window_class_init (GsmSplashWindowClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass *) klass;
- GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ GObjectClass *gobject_class = (GObjectClass *) klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
- gobject_class->finalize = splash_window_finalize;
+ gobject_class->finalize = splash_window_finalize;
- widget_class->realize = splash_window_realize;
- widget_class->expose_event = splash_window_expose_event;
+ widget_class->realize = splash_window_realize;
+ widget_class->expose_event = splash_window_expose_event;
}
static void
gsm_splash_window_init (GsmSplashWindow *splash)
{
- GtkWindow *window;
- PangoAttrList *attrs;
+ GtkWindow *window;
+ PangoAttrList *attrs;
- window = &splash->window;
+ window = &splash->window;
- /* window->type clobbered by default properties on GtkWindow */
- g_object_set (window,
- "type_hint", GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
- "decorated", FALSE,
- "window_position", GTK_WIN_POS_CENTER,
- "allow_shrink", FALSE,
- "allow_grow", FALSE,
- NULL);
-
- splash->icon_size = SPLASH_BASE_ICON_SIZE;
- splash->icon_spacing = SPLASH_ICON_SPACING;
- splash->cur_y_row = SPLASH_BASE_ICON_ROWS;
-
- gtk_widget_add_events (GTK_WIDGET (window),
- GDK_BUTTON_RELEASE_MASK);
-
- splash->layout = gtk_widget_create_pango_layout (GTK_WIDGET (splash), "");
- pango_layout_set_alignment (splash->layout, PANGO_ALIGN_CENTER);
-
- attrs = pango_attr_list_new ();
- splash->font_size_attr = pango_attr_size_new (PANGO_SCALE * SPLASH_LABEL_FONT_SIZE);
- splash->font_size_attr->start_index = 0;
- splash->font_size_attr->end_index = 0;
- pango_attr_list_insert (attrs, splash->font_size_attr);
- pango_layout_set_attributes (splash->layout, attrs);
- pango_attr_list_unref (attrs);
+ /* window->type clobbered by default properties on GtkWindow */
+ g_object_set (window,
+ "type_hint", GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
+ "decorated", FALSE,
+ "window_position", GTK_WIN_POS_CENTER,
+ "allow_shrink", FALSE,
+ "allow_grow", FALSE,
+ NULL);
+
+ splash->icon_size = SPLASH_BASE_ICON_SIZE;
+ splash->icon_spacing = SPLASH_ICON_SPACING;
+ splash->cur_y_row = SPLASH_BASE_ICON_ROWS;
+
+ gtk_widget_add_events (GTK_WIDGET (window),
+ GDK_BUTTON_RELEASE_MASK);
+
+ splash->layout = gtk_widget_create_pango_layout (GTK_WIDGET (splash), "");
+ pango_layout_set_alignment (splash->layout, PANGO_ALIGN_CENTER);
+
+ attrs = pango_attr_list_new ();
+ splash->font_size_attr = pango_attr_size_new (PANGO_SCALE * SPLASH_LABEL_FONT_SIZE);
+ splash->font_size_attr->start_index = 0;
+ splash->font_size_attr->end_index = 0;
+ pango_attr_list_insert (attrs, splash->font_size_attr);
+ pango_layout_set_attributes (splash->layout, attrs);
+ pango_attr_list_unref (attrs);
- splash->icon_theme = gtk_icon_theme_get_default ();
+ splash->icon_theme = gtk_icon_theme_get_default ();
}
static void re_laydown (GsmSplashWindow *splash);
static void
-layout_icon (GsmSplashWindow *splash, SplashIcon *si, GdkRectangle *area)
-{
- GtkWidget *widget = GTK_WIDGET (splash);
- GtkAllocation *allocation = &widget->allocation;
-
- g_return_if_fail (si != NULL);
-
- si->position.x = allocation->x + splash->cur_x_offset + SPLASH_ICON_BORDER;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- si->position.x = allocation->width - si->position.x - splash->icon_size;
-
- si->position.y = (allocation->y + allocation->height -
- SPLASH_ICON_V_OFFSET -
- (splash->icon_size + splash->icon_spacing) * splash->cur_y_row);
-
- si->position.width = si->position.height = splash->icon_size;
-
- splash->cur_x_offset += splash->icon_size + splash->icon_spacing;
-
- if (area)
- *area = si->position;
-
- if (!si->scaled)
- {
- if (gdk_pixbuf_get_width (si->unscaled) == splash->icon_size &&
- gdk_pixbuf_get_height (si->unscaled) == splash->icon_size)
- si->scaled = g_object_ref (si->unscaled);
- else
- {
- si->scaled = gdk_pixbuf_scale_simple (si->unscaled, splash->icon_size,
- splash->icon_size,
- GDK_INTERP_BILINEAR);
- }
- }
-
- if (splash->cur_x_offset >= (allocation->width - SPLASH_ICON_BORDER * 2 -
- splash->icon_size))
- {
- if (--splash->cur_y_row > 0)
- splash->cur_x_offset = 0;
-
- else
- {
- if (re_scale (splash))
- {
- re_laydown (splash);
- gtk_widget_queue_draw (GTK_WIDGET (splash));
- }
- }
- }
+layout_icon (GsmSplashWindow *splash,
+ SplashIcon *si,
+ GdkRectangle *area)
+{
+ GtkWidget *widget = GTK_WIDGET (splash);
+ GtkAllocation *allocation = &widget->allocation;
+
+ g_return_if_fail (si != NULL);
+
+ si->position.x = allocation->x + splash->cur_x_offset + SPLASH_ICON_BORDER;
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
+ si->position.x = allocation->width - si->position.x - splash->icon_size;
+ }
+
+ si->position.y = (allocation->y + allocation->height -
+ SPLASH_ICON_V_OFFSET -
+ (splash->icon_size + splash->icon_spacing) * splash->cur_y_row);
+
+ si->position.width = si->position.height = splash->icon_size;
+
+ splash->cur_x_offset += splash->icon_size + splash->icon_spacing;
+
+ if (area) {
+ *area = si->position;
+ }
+
+ if (!si->scaled) {
+ if (gdk_pixbuf_get_width (si->unscaled) == splash->icon_size &&
+ gdk_pixbuf_get_height (si->unscaled) == splash->icon_size) {
+ si->scaled = g_object_ref (si->unscaled);
+ } else {
+ si->scaled = gdk_pixbuf_scale_simple (si->unscaled, splash->icon_size,
+ splash->icon_size,
+ GDK_INTERP_BILINEAR);
+ }
+ }
+
+ if (splash->cur_x_offset >= (allocation->width - SPLASH_ICON_BORDER * 2 -
+ splash->icon_size)) {
+ if (--splash->cur_y_row > 0) {
+ splash->cur_x_offset = 0;
+ } else {
+ if (re_scale (splash)) {
+ re_laydown (splash);
+ gtk_widget_queue_draw (GTK_WIDGET (splash));
+ }
+ }
+ }
}
static void
re_laydown (GsmSplashWindow *splash)
{
- GList *l;
+ GList *l;
- splash->cur_x_offset = 0;
- splash->cur_y_row = splash->icon_rows;
+ splash->cur_x_offset = 0;
+ splash->cur_y_row = splash->icon_rows;
- for (l = splash->icons; l; l = l->next)
- {
- SplashIcon *si = l->data;
-
- if (si->scaled)
- {
- g_object_unref (si->scaled);
- si->scaled = NULL;
- }
- layout_icon (splash, l->data, NULL);
-
- /* If si has a TransParam, it's now messed up because it's still
- * referring to the old icon. We deal with this by just
- * immediately finishing the effect now.
- */
- si->trans_count = TRANS_TIMEOUT_PERIOD;
- }
+ for (l = splash->icons; l; l = l->next) {
+ SplashIcon *si = l->data;
+
+ if (si->scaled) {
+ g_object_unref (si->scaled);
+ si->scaled = NULL;
+ }
+ layout_icon (splash, l->data, NULL);
+
+ /* If si has a TransParam, it's now messed up because it's still
+ * referring to the old icon. We deal with this by just
+ * immediately finishing the effect now.
+ */
+ si->trans_count = TRANS_TIMEOUT_PERIOD;
+ }
}
static gboolean
update_trans_effect (gpointer trans_param)
{
- guchar *p_trans;
- guchar *p_orig;
- gdouble r_mul, g_mul, b_mul, a_mul;
- gint x = 0;
- gint y = 0;
-
- TransParam *tp = (TransParam *) trans_param;
-
- if (tp->si->trans_count++ == TRANS_TIMEOUT_PERIOD)
- {
- gtk_widget_queue_draw_area (GTK_WIDGET (tp->splash),
- tp->si->position.x, tp->si->position.y,
- tp->si->position.width, tp->si->position.height);
- g_free (tp);
- return FALSE;
- }
-
- a_mul = (gdouble) tp->si->trans_count / TRANS_TIMEOUT_PERIOD;
- r_mul = 1;
- g_mul = 1;
- b_mul = 1;
-
- for (y = 0; y < tp->height; y++)
- {
- for (x = 0; x < tp->width; x++)
- {
- p_trans = tp->pixels_trans + y * tp->rowstride_trans + x * tp->n_channels;
- p_orig = tp->pixels_orig + y * tp->rowstride_orig + x * tp->n_channels;
-
- /* we can add more effects here apart from alpha fading */
- p_trans[0] = r_mul * p_orig[0];
- p_trans[1] = g_mul * p_orig[1];
- p_trans[2] = b_mul * p_orig[2];
- p_trans[3] = a_mul * p_orig[3];
- }
- }
-
- gtk_widget_queue_draw_area (GTK_WIDGET (tp->splash),
- tp->si->position.x, tp->si->position.y,
- tp->si->position.width, tp->si->position.height);
- return TRUE;
+ guchar *p_trans;
+ guchar *p_orig;
+ gdouble r_mul, g_mul, b_mul, a_mul;
+ gint x = 0;
+ gint y = 0;
+
+ TransParam *tp = (TransParam *) trans_param;
+
+ if (tp->si->trans_count++ == TRANS_TIMEOUT_PERIOD) {
+ gtk_widget_queue_draw_area (GTK_WIDGET (tp->splash),
+ tp->si->position.x, tp->si->position.y,
+ tp->si->position.width, tp->si->position.height);
+ g_free (tp);
+ return FALSE;
+ }
+
+ a_mul = (gdouble) tp->si->trans_count / TRANS_TIMEOUT_PERIOD;
+ r_mul = 1;
+ g_mul = 1;
+ b_mul = 1;
+
+ for (y = 0; y < tp->height; y++) {
+ for (x = 0; x < tp->width; x++) {
+ p_trans = tp->pixels_trans + y * tp->rowstride_trans + x * tp->n_channels;
+ p_orig = tp->pixels_orig + y * tp->rowstride_orig + x * tp->n_channels;
+
+ /* we can add more effects here apart from alpha fading */
+ p_trans[0] = r_mul * p_orig[0];
+ p_trans[1] = g_mul * p_orig[1];
+ p_trans[2] = b_mul * p_orig[2];
+ p_trans[3] = a_mul * p_orig[3];
+ }
+ }
+
+ gtk_widget_queue_draw_area (GTK_WIDGET (tp->splash),
+ tp->si->position.x, tp->si->position.y,
+ tp->si->position.width, tp->si->position.height);
+ return TRUE;
}
GtkWidget *
gsm_splash_window_new (GdkPixbuf *background)
{
- GsmSplashWindow *splash = g_object_new (GSM_TYPE_SPLASH_WINDOW, NULL);
+ GsmSplashWindow *splash = g_object_new (GSM_TYPE_SPLASH_WINDOW, NULL);
- /* FIXME: make this a property */
- if (background)
- {
- splash->background = g_object_ref (background);
- gtk_widget_set_size_request ((GtkWidget *)splash,
- gdk_pixbuf_get_width (background),
- gdk_pixbuf_get_height (background));
- }
- else
- {
- gtk_widget_set_size_request ((GtkWidget *)splash,
- SPLASH_BASE_WIDTH,
- SPLASH_BASE_HEIGHT);
- }
+ /* FIXME: make this a property */
+ if (background) {
+ splash->background = g_object_ref (background);
+ gtk_widget_set_size_request ((GtkWidget *)splash,
+ gdk_pixbuf_get_width (background),
+ gdk_pixbuf_get_height (background));
+ } else {
+ gtk_widget_set_size_request ((GtkWidget *)splash,
+ SPLASH_BASE_WIDTH,
+ SPLASH_BASE_HEIGHT);
+ }
- return (GtkWidget *)splash;
+ return (GtkWidget *)splash;
}
void
gsm_splash_window_start (GsmSplashWindow *splash,
- const char *app_name,
- const char *icon_name)
+ const char *app_name,
+ const char *icon_name)
{
- GdkPixbuf *pb;
- SplashIcon *si;
- GdkRectangle area;
- int length;
- TransParam *tp;
-
- g_return_if_fail (GSM_IS_SPLASH_WINDOW (splash));
-
- if (!icon_name)
- return;
-
- pb = gtk_icon_theme_load_icon (splash->icon_theme, icon_name,
- 48, /* icon size */
- 0 /* flags */, NULL);
- if (!pb)
- return;
-
- /* re-draw the old text extents */
- gtk_widget_queue_draw_area (GTK_WIDGET (splash),
- splash->text_box.x, splash->text_box.y,
- splash->text_box.width, splash->text_box.height);
-
- g_free (splash->cur_text);
- splash->cur_text = g_strdup (app_name);
-
- length = strlen (splash->cur_text);
- splash->font_size_attr->end_index = length;
- pango_layout_set_text (splash->layout, splash->cur_text, length);
- calc_text_box (splash);
-
- /* re-draw the new text extents */
- gtk_widget_queue_draw_area (GTK_WIDGET (splash),
- splash->text_box.x, splash->text_box.y,
- splash->text_box.width, splash->text_box.height);
-
- si = g_new0 (SplashIcon, 1);
- si->unscaled = pb;
-
- splash->icons = g_list_append (splash->icons, si);
-
- layout_icon (splash, si, &area);
-
- /* prepare transparency effect */
- if ((gdk_pixbuf_get_colorspace (si->scaled) == GDK_COLORSPACE_RGB) &&
- (gdk_pixbuf_get_bits_per_sample (si->scaled) == 8) &&
- (gdk_pixbuf_get_n_channels (si->scaled)))
- {
- si->trans_count = 0;
- if (!gdk_pixbuf_get_has_alpha (si->scaled))
- {
- si->scaled_copy = gdk_pixbuf_add_alpha (si->scaled, FALSE, 0, 0, 0);
- g_object_unref (si->scaled);
- si->scaled = gdk_pixbuf_copy (si->scaled_copy);
- }
- else
- si->scaled_copy = gdk_pixbuf_copy (si->scaled);
-
- tp = g_new0(TransParam, 1);
- tp->si = si;
- tp->splash = splash;
- tp->width = gdk_pixbuf_get_width (tp->si->scaled);
- tp->height = gdk_pixbuf_get_height (tp->si->scaled);
- tp->rowstride_trans = gdk_pixbuf_get_rowstride (tp->si->scaled);
- tp->rowstride_orig = gdk_pixbuf_get_rowstride (tp->si->scaled_copy);
- tp->pixels_trans = gdk_pixbuf_get_pixels (tp->si->scaled);
- tp->pixels_orig = gdk_pixbuf_get_pixels (tp->si->scaled_copy);
- tp->n_channels = gdk_pixbuf_get_n_channels (tp->si->scaled);
-
- gdk_pixbuf_fill (si->scaled, 0x00000000);
- g_timeout_add (TRANS_TIMEOUT, update_trans_effect, tp);
- }
- else
- {
- gtk_widget_queue_draw_area (GTK_WIDGET (splash), area.x, area.y,
- area.width, area.height);
- }
+ GdkPixbuf *pb;
+ SplashIcon *si;
+ GdkRectangle area;
+ int length;
+ TransParam *tp;
+
+ g_return_if_fail (GSM_IS_SPLASH_WINDOW (splash));
+
+ if (!icon_name) {
+ return;
+ }
+
+ pb = gtk_icon_theme_load_icon (splash->icon_theme,
+ icon_name,
+ 48, /* icon size */
+ 0 /* flags */,
+ NULL);
+ if (!pb) {
+ return;
+ }
+
+ /* re-draw the old text extents */
+ gtk_widget_queue_draw_area (GTK_WIDGET (splash),
+ splash->text_box.x, splash->text_box.y,
+ splash->text_box.width, splash->text_box.height);
+
+ g_free (splash->cur_text);
+ splash->cur_text = g_strdup (app_name);
+
+ length = strlen (splash->cur_text);
+ splash->font_size_attr->end_index = length;
+ pango_layout_set_text (splash->layout, splash->cur_text, length);
+ calc_text_box (splash);
+
+ /* re-draw the new text extents */
+ gtk_widget_queue_draw_area (GTK_WIDGET (splash),
+ splash->text_box.x, splash->text_box.y,
+ splash->text_box.width, splash->text_box.height);
+
+ si = g_new0 (SplashIcon, 1);
+ si->unscaled = pb;
+
+ splash->icons = g_list_append (splash->icons, si);
+
+ layout_icon (splash, si, &area);
+
+ /* prepare transparency effect */
+ if ((gdk_pixbuf_get_colorspace (si->scaled) == GDK_COLORSPACE_RGB) &&
+ (gdk_pixbuf_get_bits_per_sample (si->scaled) == 8) &&
+ (gdk_pixbuf_get_n_channels (si->scaled))) {
+ si->trans_count = 0;
+ if (!gdk_pixbuf_get_has_alpha (si->scaled)) {
+ si->scaled_copy = gdk_pixbuf_add_alpha (si->scaled, FALSE, 0, 0, 0);
+ g_object_unref (si->scaled);
+ si->scaled = gdk_pixbuf_copy (si->scaled_copy);
+ } else {
+ si->scaled_copy = gdk_pixbuf_copy (si->scaled);
+ }
+
+ tp = g_new0(TransParam, 1);
+ tp->si = si;
+ tp->splash = splash;
+ tp->width = gdk_pixbuf_get_width (tp->si->scaled);
+ tp->height = gdk_pixbuf_get_height (tp->si->scaled);
+ tp->rowstride_trans = gdk_pixbuf_get_rowstride (tp->si->scaled);
+ tp->rowstride_orig = gdk_pixbuf_get_rowstride (tp->si->scaled_copy);
+ tp->pixels_trans = gdk_pixbuf_get_pixels (tp->si->scaled);
+ tp->pixels_orig = gdk_pixbuf_get_pixels (tp->si->scaled_copy);
+ tp->n_channels = gdk_pixbuf_get_n_channels (tp->si->scaled);
+
+ gdk_pixbuf_fill (si->scaled, 0x00000000);
+ g_timeout_add (TRANS_TIMEOUT, update_trans_effect, tp);
+ } else {
+ gtk_widget_queue_draw_area (GTK_WIDGET (splash), area.x, area.y,
+ area.width, area.height);
+ }
}
void
gsm_splash_window_finish (GsmSplashWindow *splash,
- const char *app_name)
+ const char *app_name)
{
- if (splash->cur_text && !strcmp (splash->cur_text, app_name))
- {
- g_free (splash->cur_text);
- splash->cur_text = NULL;
-
- splash->font_size_attr->end_index = 0;
- pango_layout_set_text (splash->layout, "", 0);
-
- gtk_widget_queue_draw_area (GTK_WIDGET (splash),
- splash->text_box.x, splash->text_box.y,
- splash->text_box.width, splash->text_box.height);
+ if (splash->cur_text && !strcmp (splash->cur_text, app_name)) {
+ g_free (splash->cur_text);
+ splash->cur_text = NULL;
+
+ splash->font_size_attr->end_index = 0;
+ pango_layout_set_text (splash->layout, "", 0);
+
+ gtk_widget_queue_draw_area (GTK_WIDGET (splash),
+ splash->text_box.x, splash->text_box.y,
+ splash->text_box.width, splash->text_box.height);
- calc_text_box (splash);
- }
+ calc_text_box (splash);
+ }
}
Modified: trunk/splash/splash-window.h
==============================================================================
--- trunk/splash/splash-window.h (original)
+++ trunk/splash/splash-window.h Mon Aug 4 19:05:21 2008
@@ -34,7 +34,7 @@
GtkWindow window;
GtkIconTheme *icon_theme;
-
+
GdkPixbuf *background;
GList *icons;
PangoLayout *layout;
@@ -62,9 +62,9 @@
GtkWidget *gsm_splash_window_new (GdkPixbuf *background);
void gsm_splash_window_start (GsmSplashWindow *splash,
- const char *app_name,
- const char *icon_name);
+ const char *app_name,
+ const char *icon_name);
void gsm_splash_window_finish (GsmSplashWindow *splash,
- const char *app_name);
+ const char *app_name);
#endif /* __GSM_SPLASH_WINDOW_H__ */
Modified: trunk/tools/gnome-session-save.c
==============================================================================
--- trunk/tools/gnome-session-save.c (original)
+++ trunk/tools/gnome-session-save.c Mon Aug 4 19:05:21 2008
@@ -1,4 +1,5 @@
-/* save-session.c - Small program to talk to session manager.
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * save-session.c - Small program to talk to session manager.
Copyright (C) 1998 Tom Tromey
@@ -15,7 +16,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ 02111-1307, USA.
+*/
#include <config.h>
@@ -41,85 +43,86 @@
static gboolean zap = FALSE;
/* True if we should use dialog boxes */
-static gboolean gui = FALSE;
+static gboolean gui = FALSE;
/* True if we should do the requested action without confirmation */
-static gboolean silent = FALSE;
+static gboolean silent = FALSE;
static char *session_name = NULL;
static IceConn ice_conn = NULL;
static const GOptionEntry options[] = {
- {"session-name", 's', 0, G_OPTION_ARG_STRING, &session_name, N_("Set the current session name"), N_("NAME")},
- {"kill", '\0', 0, G_OPTION_ARG_NONE, &zap, N_("Kill session"), NULL},
- {"gui", '\0', 0, G_OPTION_ARG_NONE, &gui, N_("Use dialog boxes for errors"), NULL},
- {"silent", '\0', 0, G_OPTION_ARG_NONE, &silent, N_("Do not require confirmation"), NULL},
- {NULL}
+ {"session-name", 's', 0, G_OPTION_ARG_STRING, &session_name, N_("Set the current session name"), N_("NAME")},
+ {"kill", '\0', 0, G_OPTION_ARG_NONE, &zap, N_("Kill session"), NULL},
+ {"gui", '\0', 0, G_OPTION_ARG_NONE, &gui, N_("Use dialog boxes for errors"), NULL},
+ {"silent", '\0', 0, G_OPTION_ARG_NONE, &silent, N_("Do not require confirmation"), NULL},
+ {NULL}
};
static int exit_status = 0;
static void
-ping_reply (IceConn ice_conn, IcePointer clientData)
+ping_reply (IceConn ice_conn,
+ IcePointer clientData)
{
- gtk_main_quit ();
+ gtk_main_quit ();
}
static void
ice_ping (void)
{
- /* We can't exit immediately, because the trash mode above
- * might be discarded. So we do the equivalent of an XSync.
- */
- if (ice_conn)
- IcePing (ice_conn, ping_reply, NULL);
- else
- g_warning ("save complete, but we don't have an ice connection.");
+ /* We can't exit immediately, because the trash mode above
+ * might be discarded. So we do the equivalent of an XSync.
+ */
+ if (ice_conn) {
+ IcePing (ice_conn, ping_reply, NULL);
+ } else {
+ g_warning ("save complete, but we don't have an ice connection.");
+ }
}
static void
save_complete (GnomeClient* client, gpointer data)
{
- /* We could expose more of the arguments to the user if we wanted
- to. Some of them aren't particularly useful. Interestingly,
- there is no way to request a shutdown without a save. */
- gnome_client_request_save (client, GNOME_SAVE_BOTH, zap,
- silent ? GNOME_INTERACT_NONE : GNOME_INTERACT_ANY,
- 0, 1);
+ /* We could expose more of the arguments to the user if we wanted
+ to. Some of them aren't particularly useful. Interestingly,
+ there is no way to request a shutdown without a save. */
+ gnome_client_request_save (client, GNOME_SAVE_BOTH, zap,
+ silent ? GNOME_INTERACT_NONE : GNOME_INTERACT_ANY,
+ 0, 1);
- ice_ping ();
+ ice_ping ();
}
static void
-die_cb (GnomeClient *client, gpointer data)
+die_cb (GnomeClient *client,
+ gpointer data)
{
- ice_ping ();
+ ice_ping ();
}
static void
-cancelled_cb (GnomeClient *client, gpointer data)
+cancelled_cb (GnomeClient *client,
+ gpointer data)
{
- ice_ping ();
+ ice_ping ();
}
static void
display_error (const char *message)
{
- if (gui && !silent)
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
- else
- {
- g_printerr ("%s\n", message);
- }
+ if (gui && !silent) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ } else {
+ g_printerr ("%s\n", message);
+ }
}
@@ -127,157 +130,152 @@
* we do this so we can pick up our IceConnection to do a ping on
*/
static void
-ice_connection_watch (IceConn connection, IcePointer client_data,
- Bool opening, IcePointer *watch_data)
-{
- if (opening)
- {
- if (!ice_conn)
- ice_conn = connection;
- else
- g_message ("Second ICE connection opened: ignoring.");
- }
- else
- {
- if (ice_conn == connection)
- ice_conn = NULL;
- else
- g_message ("Second ICE connection closed: ignoring.");
- }
+ice_connection_watch (IceConn connection,
+ IcePointer client_data,
+ Bool opening,
+ IcePointer *watch_data)
+{
+ if (opening) {
+ if (!ice_conn) {
+ ice_conn = connection;
+ } else {
+ g_message ("Second ICE connection opened: ignoring.");
+ }
+ } else {
+ if (ice_conn == connection) {
+ ice_conn = NULL;
+ } else {
+ g_message ("Second ICE connection closed: ignoring.");
+ }
+ }
}
static DBusGProxy *
get_bus_proxy (DBusGConnection *connection)
{
- DBusGProxy *bus_proxy;
+ DBusGProxy *bus_proxy;
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- GSM_SERVICE_DBUS,
- GSM_PATH_DBUS,
- GSM_INTERFACE_DBUS);
+ bus_proxy = dbus_g_proxy_new_for_name (connection,
+ GSM_SERVICE_DBUS,
+ GSM_PATH_DBUS,
+ GSM_INTERFACE_DBUS);
- return bus_proxy;
+ return bus_proxy;
}
static DBusGConnection *
get_session_bus (void)
{
- DBusGConnection *bus;
- GError *error = NULL;
+ DBusGConnection *bus;
+ GError *error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (bus == NULL)
- {
- g_warning ("Couldn't connect to session bus: %s", error->message);
- g_error_free (error);
- }
+ if (bus == NULL) {
+ g_warning ("Couldn't connect to session bus: %s", error->message);
+ g_error_free (error);
+ }
- return bus;
+ return bus;
}
static void
set_session_name (GnomeClient *client,
const char *session_name)
{
- DBusGConnection *bus;
- DBusGProxy *bus_proxy = NULL;
- GError *error = NULL;
- gboolean res;
-
- bus = get_session_bus ();
-
- if (bus == NULL)
- {
- display_error (_("Could not connect to the session manager"));
- goto out;
- }
-
- bus_proxy = get_bus_proxy (bus);
- dbus_g_connection_unref (bus);
-
- if (bus_proxy == NULL)
- {
- display_error (_("Could not connect to the session manager"));
- goto out;
- }
-
- res = dbus_g_proxy_call (bus_proxy,
- "SetName",
- &error,
- G_TYPE_STRING, session_name,
- G_TYPE_INVALID, G_TYPE_INVALID);
-
- if (!res)
- {
- if (error)
- {
- g_warning ("Failed to set session name '%s': %s",
- session_name, error->message);
- g_error_free (error);
- }
- else
- {
- g_warning ("Failed to set session name '%s'",
- session_name);
+ DBusGConnection *bus;
+ DBusGProxy *bus_proxy = NULL;
+ GError *error = NULL;
+ gboolean res;
+
+ bus = get_session_bus ();
+
+ if (bus == NULL) {
+ display_error (_("Could not connect to the session manager"));
+ goto out;
+ }
+
+ bus_proxy = get_bus_proxy (bus);
+ dbus_g_connection_unref (bus);
+
+ if (bus_proxy == NULL) {
+ display_error (_("Could not connect to the session manager"));
+ goto out;
}
- goto out;
- }
+ res = dbus_g_proxy_call (bus_proxy,
+ "SetName",
+ &error,
+ G_TYPE_STRING, session_name,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
+ if (!res) {
+ if (error != NULL) {
+ g_warning ("Failed to set session name '%s': %s",
+ session_name, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to set session name '%s'",
+ session_name);
+ }
+
+ goto out;
+ }
-out:
- if (bus_proxy)
- g_object_unref (bus_proxy);
+ out:
+ if (bus_proxy != NULL) {
+ g_object_unref (bus_proxy);
+ }
}
int
main (int argc, char *argv[])
{
- GnomeClient *client;
- GOptionContext *goption_context;
+ GnomeClient *client;
+ GOptionContext *goption_context;
+
+ /* Initialize the i18n stuff */
+ bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ IceAddConnectionWatch (ice_connection_watch, NULL);
+
+ goption_context = g_option_context_new (N_(" - Save the current session"));
+ g_option_context_set_translation_domain (goption_context, GETTEXT_PACKAGE);
+ g_option_context_add_main_entries (goption_context, options, GETTEXT_PACKAGE);
+
+ gnome_program_init ("gnome-session-save", VERSION,
+ LIBGNOMEUI_MODULE, argc, argv,
+ GNOME_PARAM_GOPTION_CONTEXT, goption_context,
+ NULL);
+
+ gtk_window_set_default_icon_name (GTK_STOCK_SAVE);
+
+ client = gnome_master_client ();
+
+ if (!GNOME_CLIENT_CONNECTED (client)) {
+ display_error (_("Could not connect to the session manager"));
+ return 1;
+ }
+
+ gnome_client_set_restart_style (client, GNOME_RESTART_NEVER);
+
+ if (session_name != NULL) {
+ set_session_name (client, session_name);
+ }
- /* Initialize the i18n stuff */
- bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-
- IceAddConnectionWatch (ice_connection_watch, NULL);
-
- goption_context = g_option_context_new (N_(" - Save the current session"));
- g_option_context_set_translation_domain (goption_context, GETTEXT_PACKAGE);
- g_option_context_add_main_entries (goption_context, options, GETTEXT_PACKAGE);
-
- gnome_program_init ("gnome-session-save", VERSION,
- LIBGNOMEUI_MODULE, argc, argv,
- GNOME_PARAM_GOPTION_CONTEXT, goption_context,
- NULL);
-
- gtk_window_set_default_icon_name (GTK_STOCK_SAVE);
-
- client = gnome_master_client ();
-
- if (!GNOME_CLIENT_CONNECTED (client))
- {
- display_error (_("Could not connect to the session manager"));
- return 1;
- }
-
- gnome_client_set_restart_style (client, GNOME_RESTART_NEVER);
-
- if (session_name)
- set_session_name (client, session_name);
-
- /* Wait until our request is acknowledged:
- * gnome-session queues requests but does not honour them if the
- * requesting client is dead when the save starts. */
- g_signal_connect (client, "save_complete",
- G_CALLBACK (save_complete), GINT_TO_POINTER (1));
- g_signal_connect (client, "die",
- G_CALLBACK (die_cb), GINT_TO_POINTER (2));
- g_signal_connect (client, "shutdown_cancelled",
- G_CALLBACK (cancelled_cb), GINT_TO_POINTER (3));
+ /* Wait until our request is acknowledged:
+ * gnome-session queues requests but does not honour them if the
+ * requesting client is dead when the save starts. */
+ g_signal_connect (client, "save_complete",
+ G_CALLBACK (save_complete), GINT_TO_POINTER (1));
+ g_signal_connect (client, "die",
+ G_CALLBACK (die_cb), GINT_TO_POINTER (2));
+ g_signal_connect (client, "shutdown_cancelled",
+ G_CALLBACK (cancelled_cb), GINT_TO_POINTER (3));
- gtk_main ();
+ gtk_main ();
- return exit_status;
+ return exit_status;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]