2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* gtkprintsettings.c: Print Settings
|
|
|
|
|
* Copyright (C) 2006, Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2011-01-04 19:51:19 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include <glib/gprintf.h>
|
2011-01-04 19:51:19 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include "gtkprintsettings.h"
|
2006-04-23 05:48:04 +00:00
|
|
|
|
#include "gtkprintutils.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
|
|
|
|
#include "gtkwidget.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
|
2011-04-17 23:00:27 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* GtkPrintSettings:
|
2011-04-17 23:00:27 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* A `GtkPrintSettings` object represents the settings of a print dialog in
|
|
|
|
|
* a system-independent way.
|
|
|
|
|
*
|
|
|
|
|
* The main use for this object is that once you’ve printed you can get a
|
|
|
|
|
* settings object that represents the settings the user chose, and the next
|
|
|
|
|
* time you print you can pass that object in so that the user doesn’t have
|
|
|
|
|
* to re-set all his settings.
|
2011-04-17 23:00:27 +00:00
|
|
|
|
*
|
|
|
|
|
* Its also possible to enumerate the settings so that you can easily save
|
|
|
|
|
* the settings for the next time your app runs, or even store them in a
|
|
|
|
|
* document. The predefined keys try to use shared values as much as possible
|
|
|
|
|
* so that moving such a document between systems still works.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
typedef struct _GtkPrintSettingsClass GtkPrintSettingsClass;
|
|
|
|
|
|
|
|
|
|
#define GTK_IS_PRINT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_SETTINGS))
|
|
|
|
|
#define GTK_PRINT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_SETTINGS, GtkPrintSettingsClass))
|
|
|
|
|
#define GTK_PRINT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_SETTINGS, GtkPrintSettingsClass))
|
|
|
|
|
|
|
|
|
|
struct _GtkPrintSettings
|
|
|
|
|
{
|
|
|
|
|
GObject parent_instance;
|
2011-04-17 23:00:27 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GHashTable *hash;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkPrintSettingsClass
|
|
|
|
|
{
|
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2007-04-29 06:23:58 +00:00
|
|
|
|
#define KEYFILE_GROUP_NAME "Print Settings"
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
G_DEFINE_TYPE (GtkPrintSettings, gtk_print_settings, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_settings_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintSettings *settings = GTK_PRINT_SETTINGS (object);
|
|
|
|
|
|
|
|
|
|
g_hash_table_destroy (settings->hash);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_print_settings_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_settings_init (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
settings->hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
|
g_free, g_free);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_settings_class_init (GtkPrintSettingsClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *)class;
|
|
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_print_settings_finalize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_new:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Creates a new `GtkPrintSettings` object.
|
|
|
|
|
*
|
|
|
|
|
* Returns: a new `GtkPrintSettings` object
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPrintSettings *
|
|
|
|
|
gtk_print_settings_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_PRINT_SETTINGS, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
copy_hash_entry (gpointer key,
|
|
|
|
|
gpointer value,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintSettings *settings = user_data;
|
|
|
|
|
|
|
|
|
|
g_hash_table_insert (settings->hash,
|
|
|
|
|
g_strdup (key),
|
|
|
|
|
g_strdup (value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_copy:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @other: a `GtkPrintSettings`
|
2010-09-21 04:18:11 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Copies a `GtkPrintSettings` object.
|
2010-09-21 04:18:11 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer full): a newly allocated copy of @other
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPrintSettings *
|
|
|
|
|
gtk_print_settings_copy (GtkPrintSettings *other)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintSettings *settings;
|
|
|
|
|
|
|
|
|
|
if (other == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (other), NULL);
|
|
|
|
|
|
|
|
|
|
settings = gtk_print_settings_new ();
|
|
|
|
|
|
|
|
|
|
g_hash_table_foreach (other->hash,
|
|
|
|
|
copy_hash_entry,
|
|
|
|
|
settings);
|
|
|
|
|
|
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Looks up the string value associated with @key.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the string value for @key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
return g_hash_table_lookup (settings->hash, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @value: (nullable): a string value
|
2009-12-10 10:23:40 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Associates @value with @key.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
|
|
|
|
const char *value)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (value == NULL)
|
|
|
|
|
gtk_print_settings_unset (settings, key);
|
|
|
|
|
else
|
|
|
|
|
g_hash_table_insert (settings->hash,
|
|
|
|
|
g_strdup (key),
|
|
|
|
|
g_strdup (value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_unset:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Removes any value associated with @key.
|
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* This has the same effect as setting the value to %NULL.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_unset (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
g_hash_table_remove (settings->hash, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_has_key:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns %TRUE, if a value is associated with @key.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE, if @key has a value
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_has_key (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, key) != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_bool:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns the boolean represented by the value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* that is associated with @key.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* The string “true” represents %TRUE, any other
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* string %FALSE.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE, if @key maps to a true value.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_get_bool (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, key);
|
2010-01-09 00:15:55 +00:00
|
|
|
|
if (g_strcmp0 (val, "true") == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_bool_with_default:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
|
|
|
|
* @default_val: the default value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns the boolean represented by the value
|
|
|
|
|
* that is associated with @key, or @default_val
|
|
|
|
|
* if the value does not represent a boolean.
|
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* The string “true” represents %TRUE, the string
|
|
|
|
|
* “false” represents %FALSE.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the boolean value associated with @key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_print_settings_get_bool_with_default (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean default_val)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, key);
|
2010-01-09 00:15:55 +00:00
|
|
|
|
if (g_strcmp0 (val, "true") == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2010-01-09 00:15:55 +00:00
|
|
|
|
if (g_strcmp0 (val, "false") == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return default_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_bool:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
|
|
|
|
* @value: a boolean
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets @key to a boolean value.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_bool (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean value)
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
|
|
|
|
gtk_print_settings_set (settings, key, "true");
|
|
|
|
|
else
|
|
|
|
|
gtk_print_settings_set (settings, key, "false");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_double_with_default:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
|
|
|
|
* @def: the default value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the floating point number represented by
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* the value that is associated with @key, or @default_val
|
|
|
|
|
* if the value does not represent a floating point number.
|
|
|
|
|
*
|
|
|
|
|
* Floating point numbers are parsed with g_ascii_strtod().
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the floating point number associated with @key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_double_with_default (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double def)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, key);
|
|
|
|
|
if (val == NULL)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
return g_ascii_strtod (val, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_double:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns the double value associated with @key, or 0.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the double value of @key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_double (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_double_with_default (settings, key, 0.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_double:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @key: a key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @value: a double value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets @key to a double value.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_double (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char buf[G_ASCII_DTOSTR_BUF_SIZE];
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, value);
|
|
|
|
|
gtk_print_settings_set (settings, key, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_length:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
|
|
|
|
* @unit: the unit of the return value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns the value associated with @key, interpreted
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* as a length.
|
|
|
|
|
*
|
|
|
|
|
* The returned value is converted to @units.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the length value of @key, converted to @unit
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_length (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkUnit unit)
|
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double length = gtk_print_settings_get_double (settings, key);
|
2006-04-23 05:48:04 +00:00
|
|
|
|
return _gtk_print_convert_from_mm (length, unit);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_length:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2006-04-24 05:42:12 +00:00
|
|
|
|
* @value: a length
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @unit: the unit of @length
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Associates a length in units of @unit with @key.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_length (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkUnit unit)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_double (settings, key,
|
2006-04-24 05:42:12 +00:00
|
|
|
|
_gtk_print_convert_to_mm (value, unit));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_int_with_default:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
|
|
|
|
* @def: the default value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns the value of @key, interpreted as
|
|
|
|
|
* an integer, or the default value.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the integer value of @key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_int_with_default (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int def)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, key);
|
|
|
|
|
if (val == NULL)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
return atoi (val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_int:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Returns the integer value of @key, or 0.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the integer value of @key
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_int (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_int_with_default (settings, key, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_int:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @key: a key
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @value: an integer
|
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets @key to an integer value.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_int (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int value)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char buf[128];
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_sprintf (buf, "%d", value);
|
|
|
|
|
gtk_print_settings_set (settings, key, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_foreach:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2010-09-21 04:18:11 +00:00
|
|
|
|
* @func: (scope call): the function to call
|
2020-01-13 01:26:50 +00:00
|
|
|
|
* @user_data: (closure): user data for @func
|
2009-12-10 10:23:40 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Calls @func for each key-value pair of @settings.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_foreach (GtkPrintSettings *settings,
|
|
|
|
|
GtkPrintSettingsFunc func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
g_hash_table_foreach (settings->hash, (GHFunc)func, user_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_printer:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
|
|
|
|
* Convenience function to obtain the value of
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* %GTK_PRINT_SETTINGS_PRINTER.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the printer name
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_printer (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_PRINTER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_printer:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @printer: the printer name
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Convenience function to set %GTK_PRINT_SETTINGS_PRINTER
|
|
|
|
|
* to @printer.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_printer (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PRINTER, printer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_orientation:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
|
|
|
|
* Get the value of %GTK_PRINT_SETTINGS_ORIENTATION,
|
|
|
|
|
* converted to a `GtkPageOrientation`.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the orientation
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPageOrientation
|
|
|
|
|
gtk_print_settings_get_orientation (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_ORIENTATION);
|
|
|
|
|
|
|
|
|
|
if (val == NULL || strcmp (val, "portrait") == 0)
|
|
|
|
|
return GTK_PAGE_ORIENTATION_PORTRAIT;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "landscape") == 0)
|
|
|
|
|
return GTK_PAGE_ORIENTATION_LANDSCAPE;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "reverse_portrait") == 0)
|
|
|
|
|
return GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "reverse_landscape") == 0)
|
|
|
|
|
return GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE;
|
|
|
|
|
|
|
|
|
|
return GTK_PAGE_ORIENTATION_PORTRAIT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_orientation:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @orientation: a page orientation
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_ORIENTATION.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_orientation (GtkPrintSettings *settings,
|
|
|
|
|
GtkPageOrientation orientation)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
switch (orientation)
|
|
|
|
|
{
|
|
|
|
|
case GTK_PAGE_ORIENTATION_LANDSCAPE:
|
|
|
|
|
val = "landscape";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case GTK_PAGE_ORIENTATION_PORTRAIT:
|
|
|
|
|
val = "portrait";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
|
|
|
|
|
val = "reverse_landscape";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
|
|
|
|
|
val = "reverse_portrait";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_ORIENTATION, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_paper_size:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PAPER_FORMAT,
|
|
|
|
|
* converted to a `GtkPaperSize`.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the paper size
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPaperSize *
|
|
|
|
|
gtk_print_settings_get_paper_size (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
|
|
|
|
const char *name;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double w, h;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_PAPER_FORMAT);
|
|
|
|
|
if (val == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (g_str_has_prefix (val, "custom-"))
|
|
|
|
|
{
|
|
|
|
|
name = val + strlen ("custom-");
|
|
|
|
|
w = gtk_print_settings_get_paper_width (settings, GTK_UNIT_MM);
|
|
|
|
|
h = gtk_print_settings_get_paper_height (settings, GTK_UNIT_MM);
|
|
|
|
|
return gtk_paper_size_new_custom (name, name, w, h, GTK_UNIT_MM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return gtk_paper_size_new (val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_paper_size:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @paper_size: a paper size
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PAPER_FORMAT,
|
|
|
|
|
* %GTK_PRINT_SETTINGS_PAPER_WIDTH and
|
|
|
|
|
* %GTK_PRINT_SETTINGS_PAPER_HEIGHT.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_paper_size (GtkPrintSettings *settings,
|
|
|
|
|
GtkPaperSize *paper_size)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *custom_name;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (paper_size == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAPER_FORMAT, NULL);
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAPER_WIDTH, NULL);
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAPER_HEIGHT, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (gtk_paper_size_is_custom (paper_size))
|
|
|
|
|
{
|
|
|
|
|
custom_name = g_strdup_printf ("custom-%s",
|
|
|
|
|
gtk_paper_size_get_name (paper_size));
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAPER_FORMAT, custom_name);
|
|
|
|
|
g_free (custom_name);
|
|
|
|
|
gtk_print_settings_set_paper_width (settings,
|
|
|
|
|
gtk_paper_size_get_width (paper_size,
|
|
|
|
|
GTK_UNIT_MM),
|
|
|
|
|
GTK_UNIT_MM);
|
|
|
|
|
gtk_print_settings_set_paper_height (settings,
|
|
|
|
|
gtk_paper_size_get_height (paper_size,
|
|
|
|
|
GTK_UNIT_MM),
|
|
|
|
|
GTK_UNIT_MM);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAPER_FORMAT,
|
|
|
|
|
gtk_paper_size_get_name (paper_size));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_paper_width:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @unit: the unit for the return value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PAPER_WIDTH,
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* converted to @unit.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the paper width, in units of @unit
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_paper_width (GtkPrintSettings *settings,
|
|
|
|
|
GtkUnit unit)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_length (settings, GTK_PRINT_SETTINGS_PAPER_WIDTH, unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_paper_width:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @width: the paper width
|
|
|
|
|
* @unit: the units of @width
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PAPER_WIDTH.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_paper_width (GtkPrintSettings *settings,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double width,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkUnit unit)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_length (settings, GTK_PRINT_SETTINGS_PAPER_WIDTH, width, unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_paper_height:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @unit: the unit for the return value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PAPER_HEIGHT,
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* converted to @unit.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the paper height, in units of @unit
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_paper_height (GtkPrintSettings *settings,
|
|
|
|
|
GtkUnit unit)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_length (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_PAPER_HEIGHT,
|
|
|
|
|
unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_paper_height:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* @height: the paper height
|
|
|
|
|
* @unit: the units of @height
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PAPER_HEIGHT.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_paper_height (GtkPrintSettings *settings,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double height,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkUnit unit)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_length (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_PAPER_HEIGHT,
|
|
|
|
|
height, unit);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_use_color:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_USE_COLOR.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: whether to use color
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_get_use_color (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_bool_with_default (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_USE_COLOR,
|
|
|
|
|
TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_use_color:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @use_color: whether to use color
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_USE_COLOR.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_use_color (GtkPrintSettings *settings,
|
|
|
|
|
gboolean use_color)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_bool (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_USE_COLOR,
|
|
|
|
|
use_color);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_collate:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_COLLATE.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: whether to collate the printed pages
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_get_collate (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2012-03-12 12:43:23 +00:00
|
|
|
|
return gtk_print_settings_get_bool_with_default (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_COLLATE,
|
|
|
|
|
TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_collate:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @collate: whether to collate the output
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_COLLATE.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_collate (GtkPrintSettings *settings,
|
|
|
|
|
gboolean collate)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_bool (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_COLLATE,
|
|
|
|
|
collate);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_reverse:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_REVERSE.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: whether to reverse the order of the printed pages
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_get_reverse (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_bool (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_REVERSE);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_reverse:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @reverse: whether to reverse the output
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_REVERSE.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_reverse (GtkPrintSettings *settings,
|
|
|
|
|
gboolean reverse)
|
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_bool (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_REVERSE,
|
|
|
|
|
reverse);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_duplex:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_DUPLEX.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: whether to print the output in duplex.
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintDuplex
|
|
|
|
|
gtk_print_settings_get_duplex (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_DUPLEX);
|
|
|
|
|
|
|
|
|
|
if (val == NULL || (strcmp (val, "simplex") == 0))
|
|
|
|
|
return GTK_PRINT_DUPLEX_SIMPLEX;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "horizontal") == 0)
|
|
|
|
|
return GTK_PRINT_DUPLEX_HORIZONTAL;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "vertical") == 0)
|
2006-10-03 18:01:33 +00:00
|
|
|
|
return GTK_PRINT_DUPLEX_VERTICAL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
return GTK_PRINT_DUPLEX_SIMPLEX;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_duplex:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @duplex: a `GtkPrintDuplex` value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_DUPLEX.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_duplex (GtkPrintSettings *settings,
|
|
|
|
|
GtkPrintDuplex duplex)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *str;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
switch (duplex)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case GTK_PRINT_DUPLEX_SIMPLEX:
|
|
|
|
|
str = "simplex";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PRINT_DUPLEX_HORIZONTAL:
|
|
|
|
|
str = "horizontal";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PRINT_DUPLEX_VERTICAL:
|
|
|
|
|
str = "vertical";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_DUPLEX, str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_quality:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_QUALITY.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the print quality
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintQuality
|
|
|
|
|
gtk_print_settings_get_quality (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_QUALITY);
|
|
|
|
|
|
|
|
|
|
if (val == NULL || (strcmp (val, "normal") == 0))
|
|
|
|
|
return GTK_PRINT_QUALITY_NORMAL;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "high") == 0)
|
|
|
|
|
return GTK_PRINT_QUALITY_HIGH;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "low") == 0)
|
|
|
|
|
return GTK_PRINT_QUALITY_LOW;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "draft") == 0)
|
|
|
|
|
return GTK_PRINT_QUALITY_DRAFT;
|
|
|
|
|
|
|
|
|
|
return GTK_PRINT_QUALITY_NORMAL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_quality:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @quality: a `GtkPrintQuality` value
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_QUALITY.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_quality (GtkPrintSettings *settings,
|
|
|
|
|
GtkPrintQuality quality)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *str;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
switch (quality)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case GTK_PRINT_QUALITY_NORMAL:
|
|
|
|
|
str = "normal";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PRINT_QUALITY_HIGH:
|
|
|
|
|
str = "high";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PRINT_QUALITY_LOW:
|
|
|
|
|
str = "low";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PRINT_QUALITY_DRAFT:
|
|
|
|
|
str = "draft";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_QUALITY, str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_page_set:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PAGE_SET.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the set of pages to print
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageSet
|
|
|
|
|
gtk_print_settings_get_page_set (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_PAGE_SET);
|
|
|
|
|
|
|
|
|
|
if (val == NULL || (strcmp (val, "all") == 0))
|
|
|
|
|
return GTK_PAGE_SET_ALL;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "even") == 0)
|
|
|
|
|
return GTK_PAGE_SET_EVEN;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "odd") == 0)
|
|
|
|
|
return GTK_PAGE_SET_ODD;
|
|
|
|
|
|
|
|
|
|
return GTK_PAGE_SET_ALL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_page_set:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @page_set: a `GtkPageSet` value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PAGE_SET.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_page_set (GtkPrintSettings *settings,
|
|
|
|
|
GtkPageSet page_set)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *str;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
switch (page_set)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case GTK_PAGE_SET_ALL:
|
|
|
|
|
str = "all";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PAGE_SET_EVEN:
|
|
|
|
|
str = "even";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PAGE_SET_ODD:
|
|
|
|
|
str = "odd";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAGE_SET, str);
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_number_up_layout:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2008-08-21 10:25:27 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: layout of page in number-up mode
|
2008-08-21 10:25:27 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkNumberUpLayout
|
|
|
|
|
gtk_print_settings_get_number_up_layout (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
GtkNumberUpLayout layout;
|
|
|
|
|
GtkTextDirection text_direction;
|
2008-09-04 14:14:11 +00:00
|
|
|
|
GEnumClass *enum_class;
|
|
|
|
|
GEnumValue *enum_value;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (settings), GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM);
|
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT);
|
|
|
|
|
text_direction = gtk_widget_get_default_direction ();
|
|
|
|
|
|
|
|
|
|
if (text_direction == GTK_TEXT_DIR_LTR)
|
|
|
|
|
layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
|
|
|
|
|
else
|
|
|
|
|
layout = GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM;
|
|
|
|
|
|
|
|
|
|
if (val == NULL)
|
|
|
|
|
return layout;
|
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
enum_class = g_type_class_ref (GTK_TYPE_NUMBER_UP_LAYOUT);
|
|
|
|
|
enum_value = g_enum_get_value_by_nick (enum_class, val);
|
|
|
|
|
if (enum_value)
|
|
|
|
|
layout = enum_value->value;
|
|
|
|
|
g_type_class_unref (enum_class);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_number_up_layout:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @number_up_layout: a `GtkNumberUpLayout` value
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2008-08-21 10:25:27 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_number_up_layout (GtkPrintSettings *settings,
|
|
|
|
|
GtkNumberUpLayout number_up_layout)
|
|
|
|
|
{
|
2008-09-04 14:14:11 +00:00
|
|
|
|
GEnumClass *enum_class;
|
|
|
|
|
GEnumValue *enum_value;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
|
|
|
|
|
|
|
|
|
|
enum_class = g_type_class_ref (GTK_TYPE_NUMBER_UP_LAYOUT);
|
|
|
|
|
enum_value = g_enum_get_value (enum_class, number_up_layout);
|
|
|
|
|
g_return_if_fail (enum_value != NULL);
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT, enum_value->value_nick);
|
|
|
|
|
g_type_class_unref (enum_class);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
2006-05-12 09:47:58 +00:00
|
|
|
|
* gtk_print_settings_get_n_copies:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
2006-05-12 09:47:58 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_N_COPIES.
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the number of copies to print
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-05-12 09:47:58 +00:00
|
|
|
|
gtk_print_settings_get_n_copies (GtkPrintSettings *settings)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-05-12 09:47:58 +00:00
|
|
|
|
return gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_N_COPIES, 1);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
2006-05-12 09:47:58 +00:00
|
|
|
|
* gtk_print_settings_set_n_copies:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @num_copies: the number of copies
|
|
|
|
|
*
|
2006-05-12 09:47:58 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_N_COPIES.
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
2006-05-12 09:47:58 +00:00
|
|
|
|
gtk_print_settings_set_n_copies (GtkPrintSettings *settings,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num_copies)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-05-12 09:47:58 +00:00
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_N_COPIES,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
num_copies);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_number_up:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_NUMBER_UP.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the number of pages per sheet
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_number_up (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2009-10-26 16:47:37 +00:00
|
|
|
|
return gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_NUMBER_UP, 1);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_number_up:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @number_up: the number of pages per sheet
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_NUMBER_UP.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_number_up (GtkPrintSettings *settings,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int number_up)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_NUMBER_UP,
|
|
|
|
|
number_up);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_resolution:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the resolution in dpi
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_resolution (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2009-08-30 15:10:47 +00:00
|
|
|
|
return gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION, 300);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_resolution:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @resolution: the resolution in dpi
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* Sets the values of %GTK_PRINT_SETTINGS_RESOLUTION,
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* %GTK_PRINT_SETTINGS_RESOLUTION_X and
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* %GTK_PRINT_SETTINGS_RESOLUTION_Y.
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_resolution (GtkPrintSettings *settings,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int resolution)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_RESOLUTION,
|
|
|
|
|
resolution);
|
2008-10-30 16:24:27 +00:00
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_RESOLUTION_X,
|
|
|
|
|
resolution);
|
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_RESOLUTION_Y,
|
|
|
|
|
resolution);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_resolution_x:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION_X.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the horizontal resolution in dpi
|
2008-10-30 16:24:27 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2008-10-30 16:24:27 +00:00
|
|
|
|
gtk_print_settings_get_resolution_x (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2009-08-30 15:10:47 +00:00
|
|
|
|
return gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION_X, 300);
|
2008-10-30 16:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_resolution_y:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION_Y.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the vertical resolution in dpi
|
2008-10-30 16:24:27 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2008-10-30 16:24:27 +00:00
|
|
|
|
gtk_print_settings_get_resolution_y (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2009-08-30 15:10:47 +00:00
|
|
|
|
return gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION_Y, 300);
|
2008-10-30 16:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_resolution_xy:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* @resolution_x: the horizontal resolution in dpi
|
|
|
|
|
* @resolution_y: the vertical resolution in dpi
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* Sets the values of %GTK_PRINT_SETTINGS_RESOLUTION,
|
|
|
|
|
* %GTK_PRINT_SETTINGS_RESOLUTION_X and
|
|
|
|
|
* %GTK_PRINT_SETTINGS_RESOLUTION_Y.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_resolution_xy (GtkPrintSettings *settings,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int resolution_x,
|
|
|
|
|
int resolution_y)
|
2008-10-30 16:24:27 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_RESOLUTION_X,
|
|
|
|
|
resolution_x);
|
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_RESOLUTION_Y,
|
|
|
|
|
resolution_y);
|
|
|
|
|
gtk_print_settings_set_int (settings, GTK_PRINT_SETTINGS_RESOLUTION,
|
|
|
|
|
resolution_x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_printer_lpi:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2008-10-30 16:24:27 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PRINTER_LPI.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the resolution in lpi (lines per inch)
|
2008-10-30 16:24:27 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2008-10-30 16:24:27 +00:00
|
|
|
|
gtk_print_settings_get_printer_lpi (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2009-08-30 15:10:47 +00:00
|
|
|
|
return gtk_print_settings_get_double_with_default (settings, GTK_PRINT_SETTINGS_PRINTER_LPI, 150.0);
|
2008-10-30 16:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_printer_lpi:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2008-12-29 03:22:30 +00:00
|
|
|
|
* @lpi: the resolution in lpi (lines per inch)
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2008-12-29 03:22:30 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PRINTER_LPI.
|
2008-10-30 16:24:27 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_printer_lpi (GtkPrintSettings *settings,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double lpi)
|
2008-10-30 16:24:27 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_double (settings, GTK_PRINT_SETTINGS_PRINTER_LPI,
|
|
|
|
|
lpi);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_scale:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_SCALE.
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the scale in percent
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_scale (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get_double_with_default (settings,
|
|
|
|
|
GTK_PRINT_SETTINGS_SCALE,
|
|
|
|
|
100.0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_scale:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-24 05:42:12 +00:00
|
|
|
|
* @scale: the scale in percent
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_SCALE.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_scale (GtkPrintSettings *settings,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double scale)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set_double (settings, GTK_PRINT_SETTINGS_SCALE,
|
|
|
|
|
scale);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_print_pages:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PRINT_PAGES.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: which pages to print
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintPages
|
|
|
|
|
gtk_print_settings_get_print_pages (GtkPrintSettings *settings)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_PRINT_PAGES);
|
|
|
|
|
|
|
|
|
|
if (val == NULL || (strcmp (val, "all") == 0))
|
|
|
|
|
return GTK_PRINT_PAGES_ALL;
|
|
|
|
|
|
2009-06-08 13:37:32 +00:00
|
|
|
|
if (strcmp (val, "selection") == 0)
|
|
|
|
|
return GTK_PRINT_PAGES_SELECTION;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (strcmp (val, "current") == 0)
|
|
|
|
|
return GTK_PRINT_PAGES_CURRENT;
|
|
|
|
|
|
|
|
|
|
if (strcmp (val, "ranges") == 0)
|
|
|
|
|
return GTK_PRINT_PAGES_RANGES;
|
|
|
|
|
|
|
|
|
|
return GTK_PRINT_PAGES_ALL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_print_pages:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @pages: a `GtkPrintPages` value
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PRINT_PAGES.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_print_pages (GtkPrintSettings *settings,
|
2006-04-24 05:42:12 +00:00
|
|
|
|
GtkPrintPages pages)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *str;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-04-24 05:42:12 +00:00
|
|
|
|
switch (pages)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case GTK_PRINT_PAGES_ALL:
|
|
|
|
|
str = "all";
|
|
|
|
|
break;
|
|
|
|
|
case GTK_PRINT_PAGES_CURRENT:
|
|
|
|
|
str = "current";
|
|
|
|
|
break;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
case GTK_PRINT_PAGES_SELECTION:
|
|
|
|
|
str = "selection";
|
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
case GTK_PRINT_PAGES_RANGES:
|
|
|
|
|
str = "ranges";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PRINT_PAGES, str);
|
|
|
|
|
}
|
2010-09-21 04:18:11 +00:00
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_page_ranges:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2011-01-18 09:10:30 +00:00
|
|
|
|
* @num_ranges: (out): return location for the length of the returned array
|
2010-09-21 04:18:11 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_PAGE_RANGES.
|
2010-09-21 04:18:11 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (array length=num_ranges) (transfer full): an array
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* of `GtkPageRange`s. Use g_free() to free the array when
|
|
|
|
|
* it is no longer needed.
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageRange *
|
|
|
|
|
gtk_print_settings_get_page_ranges (GtkPrintSettings *settings,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *num_ranges)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
|
|
|
|
char **range_strs;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageRange *ranges;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i, n;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
val = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_PAGE_RANGES);
|
|
|
|
|
|
|
|
|
|
if (val == NULL)
|
|
|
|
|
{
|
|
|
|
|
*num_ranges = 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
range_strs = g_strsplit (val, ",", 0);
|
|
|
|
|
|
|
|
|
|
for (i = 0; range_strs[i] != NULL; i++)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
n = i;
|
|
|
|
|
|
|
|
|
|
ranges = g_new0 (GtkPageRange, n);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start, end;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *str;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
start = (int)strtol (range_strs[i], &str, 10);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
end = start;
|
|
|
|
|
|
|
|
|
|
if (*str == '-')
|
|
|
|
|
{
|
|
|
|
|
str++;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
end = (int)strtol (str, NULL, 10);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ranges[i].start = start;
|
|
|
|
|
ranges[i].end = end;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-23 20:11:28 +00:00
|
|
|
|
g_strfreev (range_strs);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*num_ranges = n;
|
|
|
|
|
return ranges;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_page_ranges:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @page_ranges: (array length=num_ranges): an array of `GtkPageRange`s
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @num_ranges: the length of @page_ranges
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_PAGE_RANGES.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_page_ranges (GtkPrintSettings *settings,
|
|
|
|
|
GtkPageRange *page_ranges,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num_ranges)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
GString *s;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
s = g_string_new ("");
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_ranges; i++)
|
|
|
|
|
{
|
|
|
|
|
if (page_ranges[i].start == page_ranges[i].end)
|
|
|
|
|
g_string_append_printf (s, "%d", page_ranges[i].start);
|
|
|
|
|
else
|
|
|
|
|
g_string_append_printf (s, "%d-%d",
|
|
|
|
|
page_ranges[i].start,
|
|
|
|
|
page_ranges[i].end);
|
|
|
|
|
if (i < num_ranges - 1)
|
|
|
|
|
g_string_append (s, ",");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_PAGE_RANGES,
|
|
|
|
|
s->str);
|
|
|
|
|
|
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_default_source:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_DEFAULT_SOURCE.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the default source
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_default_source (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_DEFAULT_SOURCE);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_default_source:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @default_source: the default source
|
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_DEFAULT_SOURCE.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_default_source (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *default_source)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_DEFAULT_SOURCE, default_source);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_media_type:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_MEDIA_TYPE.
|
|
|
|
|
*
|
|
|
|
|
* The set of media types is defined in PWG 5101.1-2002 PWG.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the media type
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_media_type (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_MEDIA_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_media_type:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @media_type: the media type
|
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_MEDIA_TYPE.
|
|
|
|
|
*
|
|
|
|
|
* The set of media types is defined in PWG 5101.1-2002 PWG.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_media_type (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *media_type)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_MEDIA_TYPE, media_type);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_dither:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_DITHER.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the dithering that is used
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_dither (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_DITHER);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_dither:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @dither: the dithering that is used
|
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_DITHER.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_dither (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *dither)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_DITHER, dither);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_finishings:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_FINISHINGS.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the finishings
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_finishings (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_FINISHINGS);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_finishings:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @finishings: the finishings
|
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_FINISHINGS.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_finishings (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *finishings)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_FINISHINGS, finishings);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_get_output_bin:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the value of %GTK_PRINT_SETTINGS_OUTPUT_BIN.
|
|
|
|
|
*
|
2022-01-01 18:20:29 +00:00
|
|
|
|
* Returns: (nullable): the output bin
|
2006-04-23 05:03:59 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_get_output_bin (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_BIN);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 05:03:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_set_output_bin:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2006-04-23 05:03:59 +00:00
|
|
|
|
* @output_bin: the output bin
|
|
|
|
|
*
|
|
|
|
|
* Sets the value of %GTK_PRINT_SETTINGS_OUTPUT_BIN.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_set_output_bin (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *output_bin)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_BIN, output_bin);
|
|
|
|
|
}
|
2007-04-29 06:23:58 +00:00
|
|
|
|
|
2007-12-14 09:02:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_load_file:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2011-01-18 05:42:31 +00:00
|
|
|
|
* @file_name: (type filename): the filename to read the settings from
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @error: (nullable): return location for errors
|
2007-12-14 09:02:54 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Reads the print settings from @file_name.
|
|
|
|
|
*
|
|
|
|
|
* If the file could not be loaded then error is set to either
|
|
|
|
|
* a `GFileError` or `GKeyFileError`.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.PrintSettings.to_file].
|
2007-12-14 09:02:54 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE on success
|
2007-12-14 09:02:54 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_load_file (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *file_name,
|
2007-12-14 09:02:54 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
GKeyFile *key_file;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (settings), FALSE);
|
|
|
|
|
g_return_val_if_fail (file_name != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
key_file = g_key_file_new ();
|
|
|
|
|
|
|
|
|
|
if (g_key_file_load_from_file (key_file, file_name, 0, error) &&
|
|
|
|
|
gtk_print_settings_load_key_file (settings, key_file, NULL, error))
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
g_key_file_free (key_file);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 06:23:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_new_from_file:
|
2011-01-18 05:42:31 +00:00
|
|
|
|
* @file_name: (type filename): the filename to read the settings from
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @error: (nullable): return location for errors
|
2007-04-29 06:23:58 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Reads the print settings from @file_name.
|
|
|
|
|
*
|
|
|
|
|
* Returns a new `GtkPrintSettings` object with the restored settings,
|
|
|
|
|
* or %NULL if an error occurred. If the file could not be loaded then
|
|
|
|
|
* error is set to either a `GFileError` or `GKeyFileError`.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.PrintSettings.to_file].
|
|
|
|
|
*
|
|
|
|
|
* Returns: the restored `GtkPrintSettings`
|
2007-04-29 06:23:58 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPrintSettings *
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_print_settings_new_from_file (const char *file_name,
|
2007-04-29 06:23:58 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2007-12-14 09:02:54 +00:00
|
|
|
|
GtkPrintSettings *settings = gtk_print_settings_new ();
|
2007-04-29 06:23:58 +00:00
|
|
|
|
|
2007-12-14 09:02:54 +00:00
|
|
|
|
if (!gtk_print_settings_load_file (settings, file_name, error))
|
2007-04-29 06:23:58 +00:00
|
|
|
|
{
|
2007-12-14 09:02:54 +00:00
|
|
|
|
g_object_unref (settings);
|
|
|
|
|
settings = NULL;
|
2007-04-29 06:23:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2007-12-14 09:02:54 +00:00
|
|
|
|
* gtk_print_settings_load_key_file:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @key_file: the `GKeyFile` to retrieve the settings from
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @group_name: (nullable): the name of the group to use, or %NULL
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* to use the default “Print Settings”
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @error: (nullable): return location for errors
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
|
|
|
|
* Reads the print settings from the group @group_name in @key_file.
|
|
|
|
|
*
|
|
|
|
|
* If the file could not be loaded then error is set to either a
|
|
|
|
|
* `GFileError` or `GKeyFileError`.
|
2007-04-29 06:23:58 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE on success
|
2007-04-29 06:23:58 +00:00
|
|
|
|
*/
|
2007-12-14 09:02:54 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_load_key_file (GtkPrintSettings *settings,
|
|
|
|
|
GKeyFile *key_file,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *group_name,
|
2007-12-14 09:02:54 +00:00
|
|
|
|
GError **error)
|
2007-04-29 06:23:58 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char **keys;
|
2007-04-29 06:23:58 +00:00
|
|
|
|
gsize n_keys, i;
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
2007-12-14 09:02:54 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (settings), FALSE);
|
|
|
|
|
g_return_val_if_fail (key_file != NULL, FALSE);
|
2007-04-29 06:23:58 +00:00
|
|
|
|
|
|
|
|
|
if (!group_name)
|
|
|
|
|
group_name = KEYFILE_GROUP_NAME;
|
|
|
|
|
|
|
|
|
|
keys = g_key_file_get_keys (key_file,
|
|
|
|
|
group_name,
|
|
|
|
|
&n_keys,
|
|
|
|
|
&err);
|
|
|
|
|
if (err != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_propagate_error (error, err);
|
2007-12-14 09:02:54 +00:00
|
|
|
|
return FALSE;
|
2007-04-29 06:23:58 +00:00
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2007-04-29 06:23:58 +00:00
|
|
|
|
for (i = 0 ; i < n_keys; ++i)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *value;
|
2007-04-29 06:23:58 +00:00
|
|
|
|
|
|
|
|
|
value = g_key_file_get_string (key_file,
|
2012-01-11 13:37:08 +00:00
|
|
|
|
group_name,
|
2007-04-29 06:23:58 +00:00
|
|
|
|
keys[i],
|
|
|
|
|
NULL);
|
|
|
|
|
if (!value)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, keys[i], value);
|
|
|
|
|
g_free (value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_strfreev (keys);
|
|
|
|
|
|
2007-12-14 09:02:54 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_new_from_key_file:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @key_file: the `GKeyFile` to retrieve the settings from
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @group_name: (nullable): the name of the group to use, or %NULL to use
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* the default “Print Settings”
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @error: (nullable): return location for errors
|
2007-12-14 09:02:54 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Reads the print settings from the group @group_name in @key_file.
|
2007-12-14 09:02:54 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Returns a new `GtkPrintSettings` object with the restored settings,
|
|
|
|
|
* or %NULL if an error occurred. If the file could not be loaded then
|
|
|
|
|
* error is set to either `GFileError` or `GKeyFileError`.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the restored `GtkPrintSettings`
|
2007-12-14 09:02:54 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPrintSettings *
|
|
|
|
|
gtk_print_settings_new_from_key_file (GKeyFile *key_file,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *group_name,
|
2007-12-14 09:02:54 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintSettings *settings = gtk_print_settings_new ();
|
|
|
|
|
|
|
|
|
|
if (!gtk_print_settings_load_key_file (settings, key_file,
|
|
|
|
|
group_name, error))
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (settings);
|
|
|
|
|
settings = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 06:23:58 +00:00
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_to_file:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2011-01-18 05:42:31 +00:00
|
|
|
|
* @file_name: (type filename): the file to save to
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @error: (nullable): return location for errors
|
2021-02-27 15:55:01 +00:00
|
|
|
|
*
|
|
|
|
|
* This function saves the print settings from @settings to @file_name.
|
|
|
|
|
*
|
|
|
|
|
* If the file could not be written then error is set to either a
|
|
|
|
|
* `GFileError` or `GKeyFileError`.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE on success
|
2007-04-29 06:23:58 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_settings_to_file (GtkPrintSettings *settings,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *file_name,
|
2007-04-29 06:23:58 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GKeyFile *key_file;
|
|
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
key_file = g_key_file_new ();
|
|
|
|
|
gtk_print_settings_to_key_file (settings, key_file, NULL);
|
|
|
|
|
|
|
|
|
|
data = g_key_file_to_data (key_file, &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 (key_file);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
GKeyFile *key_file;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *group_name;
|
2007-04-29 06:23:58 +00:00
|
|
|
|
} SettingsData;
|
|
|
|
|
|
|
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
|
add_value_to_key_file (const char *key,
|
|
|
|
|
const char *value,
|
2007-04-29 06:23:58 +00:00
|
|
|
|
SettingsData *data)
|
|
|
|
|
{
|
|
|
|
|
g_key_file_set_string (data->key_file, data->group_name, key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_to_key_file:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @key_file: the `GKeyFile` to save the print settings to
|
2018-11-18 12:36:50 +00:00
|
|
|
|
* @group_name: (nullable): the group to add the settings to in @key_file, or
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* %NULL to use the default “Print Settings”
|
2007-04-29 06:23:58 +00:00
|
|
|
|
*
|
|
|
|
|
* This function adds the print settings from @settings to @key_file.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_settings_to_key_file (GtkPrintSettings *settings,
|
|
|
|
|
GKeyFile *key_file,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *group_name)
|
2007-04-29 06:23:58 +00:00
|
|
|
|
{
|
|
|
|
|
SettingsData data;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
|
|
|
|
|
g_return_if_fail (key_file != NULL);
|
|
|
|
|
|
|
|
|
|
if (!group_name)
|
|
|
|
|
group_name = KEYFILE_GROUP_NAME;
|
|
|
|
|
|
|
|
|
|
data.key_file = key_file;
|
|
|
|
|
data.group_name = group_name;
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_foreach (settings,
|
|
|
|
|
(GtkPrintSettingsFunc) add_value_to_key_file,
|
|
|
|
|
&data);
|
|
|
|
|
}
|
2016-07-03 00:29:08 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
|
add_to_variant (const char *key,
|
|
|
|
|
const char *value,
|
2016-07-03 00:29:08 +00:00
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GVariantBuilder *builder = data;
|
|
|
|
|
g_variant_builder_add (builder, "{sv}", key, g_variant_new_string (value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_to_gvariant:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @settings: a `GtkPrintSettings`
|
2016-07-03 00:29:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Serialize print settings to an a{sv} variant.
|
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Returns: (transfer none): a new, floating, `GVariant`
|
2016-07-03 00:29:08 +00:00
|
|
|
|
*/
|
|
|
|
|
GVariant *
|
|
|
|
|
gtk_print_settings_to_gvariant (GtkPrintSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
GVariantBuilder builder;
|
|
|
|
|
|
|
|
|
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
|
|
|
|
|
gtk_print_settings_foreach (settings, add_to_variant, &builder);
|
|
|
|
|
|
|
|
|
|
return g_variant_builder_end (&builder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_settings_new_from_gvariant:
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* @variant: an a{sv} `GVariant`
|
|
|
|
|
*
|
|
|
|
|
* Deserialize print settings from an a{sv} variant.
|
2016-07-03 00:29:08 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* The variant must be in the format produced by
|
|
|
|
|
* [method@Gtk.PrintSettings.to_gvariant].
|
2016-07-03 00:29:08 +00:00
|
|
|
|
*
|
2021-02-27 15:55:01 +00:00
|
|
|
|
* Returns: (transfer full): a new `GtkPrintSettings` object
|
2016-07-03 00:29:08 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPrintSettings *
|
|
|
|
|
gtk_print_settings_new_from_gvariant (GVariant *variant)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintSettings *settings;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_VARDICT), NULL);
|
|
|
|
|
|
|
|
|
|
settings = gtk_print_settings_new ();
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < g_variant_n_children (variant); i++)
|
|
|
|
|
{
|
|
|
|
|
const char *key;
|
|
|
|
|
GVariant *v;
|
|
|
|
|
|
|
|
|
|
g_variant_get_child (variant, i, "{&sv}", &key, &v);
|
|
|
|
|
if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
|
|
|
|
|
gtk_print_settings_set (settings, key, g_variant_get_string (v, NULL));
|
|
|
|
|
g_variant_unref (v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return settings;
|
|
|
|
|
}
|