static void save_print_settings (GeditApp *app) { GeditAppPrivate *priv; priv = gedit_app_get_instance_private (app); if (priv->print_settings != NULL) { gchar *filename; GError *error = NULL; filename = get_print_settings_file (); gtk_print_settings_to_file (priv->print_settings, filename, &error); if (error) { g_warning ("%s", error->message); g_error_free (error); } g_free (filename); } }
static void load_print_settings (GeditApp *app) { GeditAppPrivate *priv; gchar *filename; GError *error = NULL; priv = gedit_app_get_instance_private (app); g_return_if_fail (priv->print_settings == NULL); filename = get_print_settings_file (); priv->print_settings = gtk_print_settings_new_from_file (filename, &error); if (error) { /* Ignore file not found error */ if (error->domain != G_FILE_ERROR || error->code != G_FILE_ERROR_NOENT) { g_warning ("%s", error->message); } g_error_free (error); } g_free (filename); /* fall back to default settings */ if (priv->print_settings == NULL) { priv->print_settings = gtk_print_settings_new (); } }
static void load_print_settings (GeditApp *app) { GeditAppPrivate *priv; gchar *filename; GError *error = NULL; priv = gedit_app_get_instance_private (app); g_return_if_fail (priv->print_settings == NULL); filename = get_print_settings_file (); priv->print_settings = gtk_print_settings_new_from_file (filename, &error); if (error != NULL) { /* - Ignore file not found error. * - Ignore empty file error, i.e. group not found. This happens * when we click on cancel in the print dialog, when using the * printing for the first time in gedit. */ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) && !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { g_warning ("Load print settings error: %s", error->message); } g_error_free (error); } g_free (filename); /* fall back to default settings */ if (priv->print_settings == NULL) { priv->print_settings = gtk_print_settings_new (); } }