aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristian Persch <chpe@gnome.org>2007-07-11 02:45:59 +0800
committerChristian Persch <chpe@src.gnome.org>2007-07-11 02:45:59 +0800
commitdd039744f9f164ac9afeaa39ca13cf5db37f422a (patch)
tree5da3a7f93e7db3ed7713bd1637283ad900324d87 /lib
parent538c11a68c3f5ff52399bda39c880cd8cf33761d (diff)
downloadgsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.tar
gsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.tar.gz
gsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.tar.bz2
gsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.tar.lz
gsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.tar.xz
gsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.tar.zst
gsoc2013-epiphany-dd039744f9f164ac9afeaa39ca13cf5db37f422a.zip
Use the new gtk functions to persist and load the print settings and page
2007-07-10 Christian Persch <chpe@gnome.org> * embed/ephy-embed-shell.c: (ephy_embed_shell_set_page_setup), (ephy_embed_shell_get_page_setup), (ephy_embed_shell_set_print_settings), (ephy_embed_shell_get_print_settings): * lib/ephy-print-utils.c: * lib/ephy-print-utils.h: Use the new gtk functions to persist and load the print settings and page setup. Migrate our old settings, if present. svn path=/trunk/; revision=7143
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-print-utils.c169
-rw-r--r--lib/ephy-print-utils.h14
2 files changed, 0 insertions, 183 deletions
diff --git a/lib/ephy-print-utils.c b/lib/ephy-print-utils.c
index d56de4765..1376604c0 100644
--- a/lib/ephy-print-utils.c
+++ b/lib/ephy-print-utils.c
@@ -37,175 +37,6 @@
#define ERROR_QUARK (g_quark_from_static_string ("ephy-print-utils-error"))
/**
- * ephy_print_utils_settings_new_from_file:
- * @file_name: the filename to read the settings from
- * @error:
- *
- * Reads the print settings from @filename. Returns a new #GtkPrintSettings
- * object with the restored settings, or %NULL if an error occurred.
- *
- * Return value: the restored #GtkPrintSettings
- *
- * Since: 2.10
- */
-GtkPrintSettings *
-ephy_print_utils_settings_new_from_file (const gchar *file_name,
- GError **error)
-{
- GtkPrintSettings *settings;
- GKeyFile *key_file;
-
- g_return_val_if_fail (file_name != NULL, NULL);
-
- key_file = g_key_file_new ();
- if (!g_key_file_load_from_file (key_file, file_name, 0, error))
- {
- g_key_file_free (key_file);
- return NULL;
- }
-
- settings = ephy_print_utils_settings_new_from_key_file (key_file, error);
- g_key_file_free (key_file);
-
- return settings;
-}
-
-/**
- * ephy_print_utils_settings_new_from_key_file:
- * @key_file: the #GKeyFile to retrieve the settings from
- * @error:
- *
- * Reads the print settings from @key_file. Returns a new #GtkPrintSettings
- * object with the restored settings, or %NULL if an error occurred.
- *
- * Return value: the restored #GtkPrintSettings
- *
- * Since: 2.10
- */
-GtkPrintSettings *
-ephy_print_utils_settings_new_from_key_file (GKeyFile *key_file,
- GError **error)
-{
- GtkPrintSettings *settings;
- gchar **keys;
- gsize n_keys, i;
- GError *err = NULL;
-
- g_return_val_if_fail (key_file != NULL, NULL);
-
- keys = g_key_file_get_keys (key_file,
- PRINT_SETTINGS_GROUP,
- &n_keys,
- &err);
- if (err != NULL)
- {
- g_propagate_error (error, err);
- return NULL;
- }
-
- settings = gtk_print_settings_new ();
-
- for (i = 0 ; i < n_keys; ++i)
- {
- gchar *value;
-
- value = g_key_file_get_string (key_file,
- PRINT_SETTINGS_GROUP,
- keys[i],
- NULL);
- if (!value)
- continue;
-
- gtk_print_settings_set (settings, keys[i], value);
- g_free (value);
- }
-
- g_strfreev (keys);
-
- return settings;
-}
-
-/**
- * ephy_print_utils_settings_to_file:
- * @settings: a #GtkPrintSettings
- * @file_name: the file to save to
- * @error:
- *
- * This function saves the print settings from @settings to @file_name.
- *
- * Return value: %TRUE on success
- *
- * Since: 2.10
- */
-gboolean
-ephy_print_utils_settings_to_file (GtkPrintSettings *settings,
- const char *file_name,
- GError **error)
-{
- GKeyFile *keyfile;
- gboolean retval;
- char *data = NULL;
- gsize len;
- GError *err = NULL;
-
- g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (settings), FALSE);
- g_return_val_if_fail (file_name != NULL, FALSE);
-
- keyfile = g_key_file_new ();
- retval = ephy_print_utils_settings_to_key_file (settings, keyfile, &err);
- if (!retval) goto out;
-
- data = g_key_file_to_data (keyfile, &len, &err);
- if (!data) goto out;
-
- retval = g_file_set_contents (file_name, data, len, &err);
-
-out:
- if (err != NULL)
- g_propagate_error (error, err);
-
- g_key_file_free (keyfile);
- g_free (data);
-
- return retval;
-}
-
-static void
-add_value_to_keyfile (const gchar *key,
- const gchar *value,
- GKeyFile *keyfile)
-{
- g_key_file_set_string (keyfile, PRINT_SETTINGS_GROUP, key, value);
-}
-
-/**
- * ephy_print_utils_settings_to_key_file:
- * @settings: a #GtkPrintSettings
- * @key_file: the #GKeyFile to save the print settings to
- * @error:
- *
- * This function adds the print settings from @settings to @key_file.
- *
- * Return value: %TRUE on success
- *
- * Since: 2.10
- */
-gboolean
-ephy_print_utils_settings_to_key_file (GtkPrintSettings *settings,
- GKeyFile *key_file,
- GError **error)
-{
- g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (settings), FALSE);
- g_return_val_if_fail (key_file != NULL, FALSE);
-
- gtk_print_settings_foreach (settings,
- (GtkPrintSettingsFunc) add_value_to_keyfile,
- key_file);
-
- return TRUE;
-}
-
-/**
* ephy_print_utils_page_setup_new_from_file:
* @file_name: the filename to read the page_setup from
* @error:
diff --git a/lib/ephy-print-utils.h b/lib/ephy-print-utils.h
index 3236db537..551a0a968 100644
--- a/lib/ephy-print-utils.h
+++ b/lib/ephy-print-utils.h
@@ -27,20 +27,6 @@
G_BEGIN_DECLS
-GtkPrintSettings *ephy_print_utils_settings_new_from_file (const gchar *file_name,
- GError **error);
-
-GtkPrintSettings *ephy_print_utils_settings_new_from_key_file (GKeyFile *key_file,
- GError **error);
-
-gboolean ephy_print_utils_settings_to_file (GtkPrintSettings *settings,
- const char *file_name,
- GError **error);
-
-gboolean ephy_print_utils_settings_to_key_file (GtkPrintSettings *settings,
- GKeyFile *key_file,
- GError **error);
-
GtkPageSetup *ephy_print_utils_page_setup_new_from_file (const gchar *file_name,
GError **error);