2006-04-21 15:09:32 +00:00
|
|
|
/* GtkPrinterOptionWidget
|
|
|
|
* Copyright (C) 2006 Alexander Larsson <alexl@redhat.com>
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2006-07-18 18:26:51 +00:00
|
|
|
#include <ctype.h>
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2022-09-24 13:07:56 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
2006-04-21 15:09:32 +00:00
|
|
|
#include "gtkcheckbutton.h"
|
2020-06-11 23:59:35 +00:00
|
|
|
#include "gtkdropdown.h"
|
|
|
|
#include "gtklistitem.h"
|
|
|
|
#include "gtksignallistitemfactory.h"
|
|
|
|
#include "gtkentry.h"
|
2012-08-17 23:04:22 +00:00
|
|
|
#include "gtkfilechooserdialog.h"
|
2020-07-09 04:46:55 +00:00
|
|
|
#include "gtkfilechooserprivate.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
#include "gtkimage.h"
|
|
|
|
#include "gtklabel.h"
|
2020-08-30 21:43:00 +00:00
|
|
|
#include "gtkcheckbutton.h"
|
2011-08-28 05:40:10 +00:00
|
|
|
#include "gtkgrid.h"
|
2011-06-07 23:55:24 +00:00
|
|
|
#include "gtkorientable.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
#include "gtkprivate.h"
|
2020-07-26 13:34:08 +00:00
|
|
|
#include "gtkstringlist.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
#include "gtkprinteroptionwidget.h"
|
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
/* This defines the max file length that the file chooser
|
|
|
|
* button should display. The total length will be
|
|
|
|
* FILENAME_LENGTH_MAX+3 because the truncated name is prefixed
|
2014-02-05 18:07:34 +00:00
|
|
|
* with “...”.
|
2012-08-17 23:04:22 +00:00
|
|
|
*/
|
|
|
|
#define FILENAME_LENGTH_MAX 27
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void gtk_printer_option_widget_finalize (GObject *object);
|
|
|
|
|
|
|
|
static void deconstruct_widgets (GtkPrinterOptionWidget *widget);
|
2012-08-17 23:04:22 +00:00
|
|
|
static void construct_widgets (GtkPrinterOptionWidget *widget);
|
|
|
|
static void update_widgets (GtkPrinterOptionWidget *widget);
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static char *trim_long_filename (const char *filename);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
struct GtkPrinterOptionWidgetPrivate
|
|
|
|
{
|
|
|
|
GtkPrinterOption *source;
|
|
|
|
gulong source_changed_handler;
|
2012-08-17 23:04:22 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *check;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *label;
|
2011-06-08 11:02:39 +00:00
|
|
|
GtkWidget *info_label;
|
2006-06-17 04:53:22 +00:00
|
|
|
GtkWidget *box;
|
2012-08-17 23:04:22 +00:00
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
/* the last location for save to file, that the user selected */
|
2020-02-21 15:11:15 +00:00
|
|
|
GFile *last_location;
|
2006-04-21 15:09:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
2007-09-09 20:08:31 +00:00
|
|
|
PROP_SOURCE
|
2006-04-21 15:09:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkPrinterOptionWidget, gtk_printer_option_widget, GTK_TYPE_BOX)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
static void gtk_printer_option_widget_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_printer_option_widget_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2006-04-30 05:31:14 +00:00
|
|
|
static gboolean gtk_printer_option_widget_mnemonic_activate (GtkWidget *widget,
|
2012-08-17 23:04:22 +00:00
|
|
|
gboolean group_cycling);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_printer_option_widget_class_init (GtkPrinterOptionWidgetClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
object_class = (GObjectClass *) class;
|
|
|
|
widget_class = (GtkWidgetClass *) class;
|
|
|
|
|
|
|
|
object_class->finalize = gtk_printer_option_widget_finalize;
|
|
|
|
object_class->set_property = gtk_printer_option_widget_set_property;
|
|
|
|
object_class->get_property = gtk_printer_option_widget_get_property;
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
widget_class->mnemonic_activate = gtk_printer_option_widget_mnemonic_activate;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
signals[CHANGED] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("changed"),
|
2006-04-21 15:09:32 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkPrinterOptionWidgetClass, changed),
|
|
|
|
NULL, NULL,
|
2019-05-29 20:48:33 +00:00
|
|
|
NULL,
|
2006-04-21 15:09:32 +00:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_SOURCE,
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_object ("source", NULL, NULL,
|
2006-04-21 15:09:32 +00:00
|
|
|
GTK_TYPE_PRINTER_OPTION,
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_printer_option_widget_init (GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2013-06-27 19:02:52 +00:00
|
|
|
widget->priv = gtk_printer_option_widget_get_instance_private (widget);
|
2006-04-30 05:31:14 +00:00
|
|
|
|
|
|
|
gtk_box_set_spacing (GTK_BOX (widget), 12);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_printer_option_widget_finalize (GObject *object)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidget *widget = GTK_PRINTER_OPTION_WIDGET (object);
|
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->source)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2013-03-21 08:45:32 +00:00
|
|
|
g_signal_handler_disconnect (priv->source,
|
|
|
|
priv->source_changed_handler);
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->source);
|
|
|
|
priv->source = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
G_OBJECT_CLASS (gtk_printer_option_widget_parent_class)->finalize (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_printer_option_widget_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkPrinterOptionWidget *widget;
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
widget = GTK_PRINTER_OPTION_WIDGET (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SOURCE:
|
|
|
|
gtk_printer_option_widget_set_source (widget, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_printer_option_widget_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidget *widget = GTK_PRINTER_OPTION_WIDGET (object);
|
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SOURCE:
|
2006-05-02 12:48:52 +00:00
|
|
|
g_value_set_object (value, priv->source);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_printer_option_widget_mnemonic_activate (GtkWidget *widget,
|
|
|
|
gboolean group_cycling)
|
|
|
|
{
|
|
|
|
GtkPrinterOptionWidget *powidget = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
GtkPrinterOptionWidgetPrivate *priv = powidget->priv;
|
|
|
|
|
|
|
|
if (priv->check)
|
|
|
|
return gtk_widget_mnemonic_activate (priv->check, group_cycling);
|
|
|
|
if (priv->combo)
|
|
|
|
return gtk_widget_mnemonic_activate (priv->combo, group_cycling);
|
|
|
|
if (priv->entry)
|
|
|
|
return gtk_widget_mnemonic_activate (priv->entry, group_cycling);
|
2012-08-17 23:04:22 +00:00
|
|
|
if (priv->button)
|
|
|
|
return gtk_widget_mnemonic_activate (priv->button, group_cycling);
|
2006-04-30 05:31:14 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
emit_changed (GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
|
|
|
g_signal_emit (widget, signals[CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gtk_printer_option_widget_new (GtkPrinterOption *source)
|
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_PRINTER_OPTION_WIDGET, "source", source, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
source_changed_cb (GtkPrinterOption *source,
|
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
|
|
|
update_widgets (widget);
|
|
|
|
emit_changed (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-23 19:31:56 +00:00
|
|
|
gtk_printer_option_widget_set_source (GtkPrinterOptionWidget *widget,
|
|
|
|
GtkPrinterOption *source)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
if (source)
|
|
|
|
g_object_ref (source);
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->source)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_disconnect (priv->source,
|
|
|
|
priv->source_changed_handler);
|
|
|
|
g_object_unref (priv->source);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->source = source;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (source)
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->source_changed_handler =
|
2006-04-21 15:09:32 +00:00
|
|
|
g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), widget);
|
|
|
|
|
|
|
|
construct_widgets (widget);
|
|
|
|
update_widgets (widget);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (widget), "source");
|
|
|
|
}
|
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
#define GTK_TYPE_STRING_PAIR (gtk_string_pair_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (GtkStringPair, gtk_string_pair, GTK, STRING_PAIR, GObject)
|
|
|
|
|
|
|
|
struct _GtkStringPair {
|
|
|
|
GObject parent_instance;
|
|
|
|
char *id;
|
|
|
|
char *string;
|
|
|
|
};
|
|
|
|
|
2006-08-23 19:31:56 +00:00
|
|
|
enum {
|
2020-06-11 23:59:35 +00:00
|
|
|
PROP_ID = 1,
|
|
|
|
PROP_STRING,
|
|
|
|
PROP_NUM_PROPERTIES
|
2006-08-23 19:31:56 +00:00
|
|
|
};
|
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
G_DEFINE_TYPE (GtkStringPair, gtk_string_pair, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_string_pair_init (GtkStringPair *pair)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_string_pair_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkStringPair *pair = GTK_STRING_PAIR (object);
|
|
|
|
|
|
|
|
g_free (pair->id);
|
|
|
|
g_free (pair->string);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_string_pair_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_string_pair_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkStringPair *pair = GTK_STRING_PAIR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_STRING:
|
|
|
|
g_free (pair->string);
|
|
|
|
pair->string = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ID:
|
|
|
|
g_free (pair->id);
|
|
|
|
pair->id = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_string_pair_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkStringPair *pair = GTK_STRING_PAIR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_STRING:
|
|
|
|
g_value_set_string (value, pair->string);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ID:
|
|
|
|
g_value_set_string (value, pair->id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_string_pair_class_init (GtkStringPairClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
|
|
|
object_class->finalize = gtk_string_pair_finalize;
|
|
|
|
object_class->set_property = gtk_string_pair_set_property;
|
|
|
|
object_class->get_property = gtk_string_pair_get_property;
|
|
|
|
|
2022-05-11 12:19:39 +00:00
|
|
|
pspec = g_param_spec_string ("string", NULL, NULL,
|
2020-06-11 23:59:35 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_STRING, pspec);
|
|
|
|
|
2022-05-11 12:19:39 +00:00
|
|
|
pspec = g_param_spec_string ("id", NULL, NULL,
|
2020-06-11 23:59:35 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_ID, pspec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkStringPair *
|
|
|
|
gtk_string_pair_new (const char *id,
|
|
|
|
const char *string)
|
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_STRING_PAIR,
|
|
|
|
"id", id,
|
|
|
|
"string", string,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
gtk_string_pair_get_string (GtkStringPair *pair)
|
|
|
|
{
|
|
|
|
return pair->string;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
gtk_string_pair_get_id (GtkStringPair *pair)
|
|
|
|
{
|
|
|
|
return pair->id;
|
|
|
|
}
|
|
|
|
|
2006-07-18 18:26:51 +00:00
|
|
|
static void
|
|
|
|
combo_box_set_model (GtkWidget *combo_box)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GListStore *store;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
store = g_list_store_new (GTK_TYPE_STRING_PAIR);
|
|
|
|
gtk_drop_down_set_model (GTK_DROP_DOWN (combo_box), G_LIST_MODEL (store));
|
2006-04-21 15:09:32 +00:00
|
|
|
g_object_unref (store);
|
2006-07-18 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
static void
|
|
|
|
setup_no_item (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *item)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_list_item (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *item)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
label = gtk_label_new ("");
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_list_item_set_child (item, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_list_item (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *item)
|
|
|
|
{
|
|
|
|
GtkStringPair *pair;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
pair = gtk_list_item_get_item (item);
|
|
|
|
label = gtk_list_item_get_child (item);
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), gtk_string_pair_get_string (pair));
|
|
|
|
}
|
|
|
|
|
2006-07-18 18:26:51 +00:00
|
|
|
static void
|
|
|
|
combo_box_set_view (GtkWidget *combo_box)
|
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkListItemFactory *factory;
|
|
|
|
|
|
|
|
factory = gtk_signal_list_item_factory_new ();
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_list_item), NULL);
|
|
|
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_list_item), NULL);
|
|
|
|
gtk_drop_down_set_factory (GTK_DROP_DOWN (combo_box), factory);
|
|
|
|
g_object_unref (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
selected_changed (GtkDropDown *dropdown,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GListModel *model;
|
|
|
|
guint selected;
|
|
|
|
GtkStringPair *pair;
|
|
|
|
GtkWidget *entry = data;
|
|
|
|
|
|
|
|
model = gtk_drop_down_get_model (dropdown);
|
|
|
|
selected = gtk_drop_down_get_selected (dropdown);
|
|
|
|
|
|
|
|
pair = g_list_model_get_item (model, selected);
|
|
|
|
if (pair)
|
|
|
|
{
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), gtk_string_pair_get_string (pair));
|
|
|
|
g_object_unref (pair);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-07-18 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
combo_box_entry_new (void)
|
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkWidget *hbox, *entry, *button;
|
|
|
|
GtkListItemFactory *factory;
|
2006-07-18 18:26:51 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
|
gtk_widget_add_css_class (hbox, "linked");
|
2006-07-18 18:26:51 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
entry = gtk_entry_new ();
|
2020-07-26 13:34:08 +00:00
|
|
|
button = gtk_drop_down_new (NULL, NULL);
|
2020-06-11 23:59:35 +00:00
|
|
|
combo_box_set_model (button);
|
2006-07-18 18:26:51 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
factory = gtk_signal_list_item_factory_new ();
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_no_item), NULL);
|
|
|
|
gtk_drop_down_set_factory (GTK_DROP_DOWN (button), factory);
|
|
|
|
g_object_unref (factory);
|
|
|
|
|
|
|
|
factory = gtk_signal_list_item_factory_new ();
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_list_item), NULL);
|
|
|
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_list_item), NULL);
|
|
|
|
gtk_drop_down_set_list_factory (GTK_DROP_DOWN (button), factory);
|
|
|
|
g_object_unref (factory);
|
|
|
|
|
|
|
|
g_signal_connect (button, "notify::selected", G_CALLBACK (selected_changed), entry);
|
|
|
|
|
|
|
|
gtk_box_append (GTK_BOX (hbox), entry);
|
|
|
|
gtk_box_append (GTK_BOX (hbox), button);
|
|
|
|
|
|
|
|
return hbox;
|
2006-07-18 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
combo_box_new (void)
|
|
|
|
{
|
|
|
|
GtkWidget *combo_box;
|
2020-06-11 23:59:35 +00:00
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
combo_box = gtk_drop_down_new (NULL, NULL);
|
2006-07-18 18:26:51 +00:00
|
|
|
|
|
|
|
combo_box_set_model (combo_box);
|
|
|
|
combo_box_set_view (combo_box);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
return combo_box;
|
|
|
|
}
|
2020-06-11 23:59:35 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
2006-08-23 19:31:56 +00:00
|
|
|
combo_box_append (GtkWidget *combo,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *display_text,
|
|
|
|
const char *value)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkWidget *dropdown;
|
|
|
|
GListModel *model;
|
|
|
|
GtkStringPair *object;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
if (GTK_IS_DROP_DOWN (combo))
|
|
|
|
dropdown = combo;
|
|
|
|
else
|
|
|
|
dropdown = gtk_widget_get_last_child (combo);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
model = gtk_drop_down_get_model (GTK_DROP_DOWN (dropdown));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
object = gtk_string_pair_new (value, display_text);
|
|
|
|
g_list_store_append (G_LIST_STORE (model), object);
|
|
|
|
g_object_unref (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-23 19:31:56 +00:00
|
|
|
combo_box_set (GtkWidget *combo,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *value)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkWidget *dropdown;
|
|
|
|
GListModel *model;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
if (GTK_IS_DROP_DOWN (combo))
|
|
|
|
dropdown = combo;
|
|
|
|
else
|
|
|
|
dropdown = gtk_widget_get_last_child (combo);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
model = gtk_drop_down_get_model (GTK_DROP_DOWN (dropdown));
|
|
|
|
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
|
|
|
{
|
|
|
|
GtkStringPair *item = g_list_model_get_item (model, i);
|
|
|
|
if (strcmp (value, gtk_string_pair_get_id (item)) == 0)
|
|
|
|
{
|
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (dropdown), i);
|
|
|
|
g_object_unref (item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static char *
|
2011-12-28 00:02:28 +00:00
|
|
|
combo_box_get (GtkWidget *combo, gboolean *custom)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkWidget *dropdown;
|
|
|
|
GListModel *model;
|
|
|
|
guint selected;
|
|
|
|
gpointer item;
|
|
|
|
const char *id;
|
|
|
|
const char *string;
|
|
|
|
|
|
|
|
if (GTK_IS_DROP_DOWN (combo))
|
|
|
|
dropdown = combo;
|
|
|
|
else
|
|
|
|
dropdown = gtk_widget_get_last_child (combo);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
model = gtk_drop_down_get_model (GTK_DROP_DOWN (dropdown));
|
|
|
|
selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (dropdown));
|
|
|
|
item = g_list_model_get_item (model, selected);
|
|
|
|
if (item)
|
|
|
|
{
|
|
|
|
id = gtk_string_pair_get_id (item);
|
|
|
|
string = gtk_string_pair_get_string (item);
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
id = "";
|
|
|
|
string = NULL;
|
|
|
|
}
|
2006-07-18 18:26:51 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
if (dropdown == combo) // no entry
|
2011-12-28 00:02:28 +00:00
|
|
|
{
|
|
|
|
*custom = FALSE;
|
2020-06-11 23:59:35 +00:00
|
|
|
return g_strdup (id);
|
2011-12-28 00:02:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
const char *text;
|
|
|
|
|
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (gtk_widget_get_first_child (combo)));
|
|
|
|
if (g_strcmp0 (text, string) == 0)
|
2011-12-28 00:02:28 +00:00
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
*custom = FALSE;
|
|
|
|
return g_strdup (id);
|
2011-12-28 00:02:28 +00:00
|
|
|
}
|
2020-06-11 23:59:35 +00:00
|
|
|
else
|
2011-12-28 00:02:28 +00:00
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
*custom = TRUE;
|
|
|
|
return g_strdup (text);
|
2011-12-28 00:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
deconstruct_widgets (GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
|
|
|
|
2020-05-09 14:33:02 +00:00
|
|
|
g_clear_pointer (&priv->check, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&priv->combo, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&priv->entry, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&priv->image, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&priv->label, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&priv->info_label, gtk_widget_unparent);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-07-12 14:22:59 +00:00
|
|
|
check_toggled_cb (GtkCheckButton *check_button,
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
|
|
|
|
|
|
|
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
|
|
|
gtk_printer_option_set_boolean (priv->source,
|
2022-07-12 14:22:59 +00:00
|
|
|
gtk_check_button_get_active (check_button));
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
|
2006-04-21 15:09:32 +00:00
|
|
|
emit_changed (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-17 23:04:22 +00:00
|
|
|
dialog_response_callback (GtkDialog *dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
int response_id,
|
2012-08-17 23:04:22 +00:00
|
|
|
GtkPrinterOptionWidget *widget)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2020-02-21 15:11:15 +00:00
|
|
|
GFile *new_location = NULL;
|
|
|
|
char *uri = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
if (response_id == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2020-02-21 15:11:15 +00:00
|
|
|
GFileInfo *info;
|
|
|
|
|
|
|
|
new_location = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
|
|
info = g_file_query_info (new_location,
|
|
|
|
"standard::display-name",
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (info != NULL)
|
|
|
|
{
|
|
|
|
const char *filename_utf8 = g_file_info_get_display_name (info);
|
|
|
|
|
|
|
|
char *filename_short = trim_long_filename (filename_utf8);
|
|
|
|
gtk_button_set_label (GTK_BUTTON (priv->button), filename_short);
|
|
|
|
|
|
|
|
g_free (filename_short);
|
|
|
|
g_object_unref (info);
|
|
|
|
}
|
2022-05-08 00:30:55 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *path = g_file_peek_path (new_location);
|
|
|
|
char *filename_utf8 = g_utf8_make_valid (path, -1);
|
|
|
|
|
|
|
|
char *filename_short = trim_long_filename (filename_utf8);
|
|
|
|
gtk_button_set_label (GTK_BUTTON (priv->button), filename_short);
|
|
|
|
|
|
|
|
g_free (filename_short);
|
|
|
|
g_free (filename_utf8);
|
|
|
|
}
|
2012-08-17 23:04:22 +00:00
|
|
|
}
|
2006-06-20 17:36:55 +00:00
|
|
|
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
if (new_location)
|
2020-02-21 15:11:15 +00:00
|
|
|
uri = g_file_get_uri (new_location);
|
2012-08-17 23:04:22 +00:00
|
|
|
else
|
2020-02-21 15:11:15 +00:00
|
|
|
uri = g_file_get_uri (priv->last_location);
|
2008-09-30 08:45:01 +00:00
|
|
|
|
2020-02-21 15:11:15 +00:00
|
|
|
if (uri != NULL)
|
2006-06-20 17:36:55 +00:00
|
|
|
{
|
2012-08-17 23:04:22 +00:00
|
|
|
gtk_printer_option_set (priv->source, uri);
|
|
|
|
emit_changed (widget);
|
2020-02-21 15:11:15 +00:00
|
|
|
g_free (uri);
|
2012-08-17 23:04:22 +00:00
|
|
|
}
|
2007-01-03 21:23:42 +00:00
|
|
|
|
2020-05-11 18:26:31 +00:00
|
|
|
g_clear_object (&new_location);
|
2020-02-21 15:11:15 +00:00
|
|
|
g_clear_object (&priv->last_location);
|
2007-01-03 21:23:42 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
/* unblock the handler which was blocked in the filesave_choose_cb function */
|
|
|
|
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
|
|
|
|
}
|
2007-01-03 21:23:42 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
static void
|
|
|
|
filesave_choose_cb (GtkWidget *button,
|
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
|
|
|
/* this will be unblocked in the dialog_response_callback function */
|
|
|
|
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
|
|
|
|
2019-05-20 04:47:50 +00:00
|
|
|
toplevel = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (widget)));
|
2012-08-17 23:04:22 +00:00
|
|
|
dialog = gtk_file_chooser_dialog_new (_("Select a filename"),
|
|
|
|
toplevel,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
2013-06-24 23:28:53 +00:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
2012-08-17 23:04:22 +00:00
|
|
|
_("_Select"), GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* select the current filename in the dialog */
|
2020-02-21 15:11:15 +00:00
|
|
|
if (priv->source != NULL && priv->source->value != NULL)
|
2008-09-30 08:45:01 +00:00
|
|
|
{
|
2020-02-21 15:11:15 +00:00
|
|
|
priv->last_location = g_file_new_for_uri (priv->source->value);
|
|
|
|
if (priv->last_location)
|
2022-05-08 00:30:55 +00:00
|
|
|
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), priv->last_location, NULL);
|
2006-06-20 17:36:55 +00:00
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
2020-05-01 10:08:41 +00:00
|
|
|
G_CALLBACK (dialog_response_callback),
|
|
|
|
widget);
|
2012-08-17 23:04:22 +00:00
|
|
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static char *
|
|
|
|
filter_numeric (const char *val,
|
2006-08-23 19:31:56 +00:00
|
|
|
gboolean allow_neg,
|
|
|
|
gboolean allow_dec,
|
|
|
|
gboolean *changed_out)
|
2006-07-18 18:26:51 +00:00
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *filtered_val;
|
2006-07-18 18:26:51 +00:00
|
|
|
int i, j;
|
|
|
|
int len = strlen (val);
|
|
|
|
gboolean dec_set = FALSE;
|
|
|
|
|
|
|
|
filtered_val = g_malloc (len + 1);
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < len; i++)
|
|
|
|
{
|
2007-01-03 21:23:42 +00:00
|
|
|
if (isdigit (val[i]))
|
2006-07-18 18:26:51 +00:00
|
|
|
{
|
|
|
|
filtered_val[j] = val[i];
|
|
|
|
j++;
|
|
|
|
}
|
2022-05-08 00:30:55 +00:00
|
|
|
else if (allow_dec && !dec_set &&
|
2006-07-18 18:26:51 +00:00
|
|
|
(val[i] == '.' || val[i] == ','))
|
|
|
|
{
|
|
|
|
/* allow one period or comma
|
|
|
|
* we should be checking locals
|
|
|
|
* but this is good enough for now
|
|
|
|
*/
|
|
|
|
filtered_val[j] = val[i];
|
|
|
|
dec_set = TRUE;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
else if (allow_neg && i == 0 && val[0] == '-')
|
|
|
|
{
|
|
|
|
filtered_val[0] = val[0];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
filtered_val[j] = '\0';
|
|
|
|
*changed_out = !(i == j);
|
|
|
|
|
|
|
|
return filtered_val;
|
|
|
|
}
|
2006-08-23 19:31:56 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
2006-08-23 19:31:56 +00:00
|
|
|
combo_changed_cb (GtkWidget *combo,
|
2020-06-11 23:59:35 +00:00
|
|
|
GParamSpec *pspec,
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *value;
|
|
|
|
char *filtered_val = NULL;
|
2006-07-18 18:26:51 +00:00
|
|
|
gboolean changed;
|
2011-12-28 00:02:28 +00:00
|
|
|
gboolean custom = TRUE;
|
2006-07-18 18:26:51 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2020-06-11 23:59:35 +00:00
|
|
|
value = combo_box_get (priv->combo, &custom);
|
2006-07-18 18:26:51 +00:00
|
|
|
|
2011-12-28 00:02:28 +00:00
|
|
|
/* Handle constraints if the user entered a custom value. */
|
|
|
|
if (custom)
|
2006-07-18 18:26:51 +00:00
|
|
|
{
|
2011-12-28 00:02:28 +00:00
|
|
|
switch (priv->source->type)
|
|
|
|
{
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_PASSCODE:
|
|
|
|
filtered_val = filter_numeric (value, FALSE, FALSE, &changed);
|
|
|
|
break;
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_INT:
|
|
|
|
filtered_val = filter_numeric (value, TRUE, FALSE, &changed);
|
|
|
|
break;
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_REAL:
|
|
|
|
filtered_val = filter_numeric (value, TRUE, TRUE, &changed);
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_PASSWORD:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_STRING:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_ALTERNATIVE:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_STRING:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_FILESAVE:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_INFO:
|
2011-12-28 00:02:28 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-07-18 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (filtered_val)
|
|
|
|
{
|
|
|
|
g_free (value);
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkWidget *entry = gtk_widget_get_first_child (priv->combo);
|
2019-02-28 19:31:36 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), filtered_val);
|
2020-06-11 23:59:35 +00:00
|
|
|
}
|
2006-07-18 18:26:51 +00:00
|
|
|
value = filtered_val;
|
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
if (value)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_printer_option_set (priv->source, value);
|
2006-04-21 15:09:32 +00:00
|
|
|
g_free (value);
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
|
2006-04-21 15:09:32 +00:00
|
|
|
emit_changed (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-23 19:31:56 +00:00
|
|
|
entry_changed_cb (GtkWidget *entry,
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *value;
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
2019-02-28 19:31:36 +00:00
|
|
|
value = gtk_editable_get_text (GTK_EDITABLE (entry));
|
2006-04-21 15:09:32 +00:00
|
|
|
if (value)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_printer_option_set (priv->source, value);
|
|
|
|
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
|
2006-04-21 15:09:32 +00:00
|
|
|
emit_changed (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-17 04:53:22 +00:00
|
|
|
static void
|
|
|
|
radio_changed_cb (GtkWidget *button,
|
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *value;
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-06-17 04:53:22 +00:00
|
|
|
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
|
|
|
value = g_object_get_data (G_OBJECT (button), "value");
|
|
|
|
if (value)
|
|
|
|
gtk_printer_option_set (priv->source, value);
|
|
|
|
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
|
|
|
|
emit_changed (widget);
|
|
|
|
}
|
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
static void
|
|
|
|
alternative_set (GtkWidget *box,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *value)
|
2006-06-17 05:15:49 +00:00
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
for (child = gtk_widget_get_first_child (box);
|
|
|
|
child != NULL;
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2020-08-30 21:43:00 +00:00
|
|
|
{
|
|
|
|
char *v = g_object_get_data (G_OBJECT (child), "value");
|
|
|
|
|
|
|
|
if (strcmp (value, v) == 0)
|
|
|
|
{
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (child), TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-06-17 04:53:22 +00:00
|
|
|
}
|
|
|
|
|
2020-08-30 21:43:00 +00:00
|
|
|
static void
|
2006-08-23 19:31:56 +00:00
|
|
|
alternative_append (GtkWidget *box,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *label,
|
|
|
|
const char *value,
|
2006-06-17 04:53:22 +00:00
|
|
|
GtkPrinterOptionWidget *widget,
|
2020-08-30 21:43:00 +00:00
|
|
|
GtkWidget **group)
|
2006-06-17 04:53:22 +00:00
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
|
2020-08-30 21:43:00 +00:00
|
|
|
button = gtk_check_button_new_with_label (label);
|
|
|
|
if (*group)
|
|
|
|
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (*group));
|
|
|
|
else
|
|
|
|
*group = button;
|
|
|
|
|
2016-02-21 05:09:32 +00:00
|
|
|
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), button);
|
2006-06-17 04:53:22 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button), "value", (gpointer)value);
|
2020-08-30 21:43:00 +00:00
|
|
|
g_signal_connect (button, "toggled", G_CALLBACK (radio_changed_cb), widget);
|
2006-06-17 04:53:22 +00:00
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
construct_widgets (GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOption *source;
|
|
|
|
char *text;
|
|
|
|
int i;
|
2020-08-30 21:43:00 +00:00
|
|
|
GtkWidget *group;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
source = priv->source;
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
deconstruct_widgets (widget);
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2010-01-04 06:30:57 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
|
2009-12-20 23:32:58 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
if (source == NULL)
|
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
const char * strings[2];
|
|
|
|
strings[0] = _("Not available");
|
|
|
|
strings[1] = NULL;
|
2020-07-26 13:34:08 +00:00
|
|
|
priv->combo = gtk_drop_down_new_from_strings (strings);
|
2020-06-11 23:59:35 +00:00
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (priv->combo), 0);
|
2010-01-04 06:30:57 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (widget), FALSE);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->combo);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->combo);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
else switch (source->type)
|
|
|
|
{
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->check = gtk_check_button_new_with_mnemonic (source->display_text);
|
|
|
|
g_signal_connect (priv->check, "toggled", G_CALLBACK (check_toggled_cb), widget);
|
|
|
|
gtk_widget_show (priv->check);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->check);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE:
|
2006-07-18 18:26:51 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_PASSWORD:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_PASSCODE:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_REAL:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_INT:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_STRING:
|
|
|
|
if (source->type == GTK_PRINTER_OPTION_TYPE_PICKONE)
|
|
|
|
{
|
|
|
|
priv->combo = combo_box_new ();
|
2020-06-11 23:59:35 +00:00
|
|
|
}
|
2006-07-18 18:26:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
priv->combo = combo_box_entry_new ();
|
|
|
|
|
|
|
|
if (source->type == GTK_PRINTER_OPTION_TYPE_PICKONE_PASSWORD ||
|
2020-06-11 23:59:35 +00:00
|
|
|
source->type == GTK_PRINTER_OPTION_TYPE_PICKONE_PASSCODE)
|
|
|
|
{
|
|
|
|
GtkWidget *entry = gtk_widget_get_first_child (priv->combo);
|
|
|
|
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
|
|
|
|
}
|
2006-07-18 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
for (i = 0; i < source->num_choices; i++)
|
2012-08-17 23:04:22 +00:00
|
|
|
combo_box_append (priv->combo,
|
|
|
|
source->choices_display[i],
|
|
|
|
source->choices[i]);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->combo);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->combo);
|
2020-06-11 23:59:35 +00:00
|
|
|
if (GTK_IS_DROP_DOWN (priv->combo))
|
|
|
|
g_signal_connect (priv->combo, "notify::selected", G_CALLBACK (combo_changed_cb),widget);
|
|
|
|
else
|
|
|
|
g_signal_connect (gtk_widget_get_last_child (priv->combo), "notify::selected",G_CALLBACK (combo_changed_cb), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
text = g_strdup_printf ("%s:", source->display_text);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->label = gtk_label_new_with_mnemonic (text);
|
2006-04-21 15:09:32 +00:00
|
|
|
g_free (text);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->label);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
2006-06-17 04:53:22 +00:00
|
|
|
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_ALTERNATIVE:
|
|
|
|
group = NULL;
|
2010-10-31 17:07:20 +00:00
|
|
|
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2016-02-21 05:09:32 +00:00
|
|
|
gtk_widget_set_valign (priv->box, GTK_ALIGN_BASELINE);
|
2006-06-17 04:53:22 +00:00
|
|
|
gtk_widget_show (priv->box);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->box);
|
2006-06-17 04:53:22 +00:00
|
|
|
for (i = 0; i < source->num_choices; i++)
|
2012-09-01 02:44:45 +00:00
|
|
|
{
|
2020-08-30 21:43:00 +00:00
|
|
|
alternative_append (priv->box,
|
|
|
|
source->choices_display[i],
|
|
|
|
source->choices[i],
|
|
|
|
widget,
|
|
|
|
&group);
|
2012-09-01 02:44:45 +00:00
|
|
|
/* for mnemonic activation */
|
|
|
|
if (i == 0)
|
2020-08-30 21:43:00 +00:00
|
|
|
priv->button = group;
|
2012-09-01 02:44:45 +00:00
|
|
|
}
|
2006-06-17 04:53:22 +00:00
|
|
|
|
|
|
|
if (source->display_text)
|
|
|
|
{
|
|
|
|
text = g_strdup_printf ("%s:", source->display_text);
|
|
|
|
priv->label = gtk_label_new_with_mnemonic (text);
|
2016-02-21 05:09:32 +00:00
|
|
|
gtk_widget_set_valign (priv->label, GTK_ALIGN_BASELINE);
|
2006-06-17 04:53:22 +00:00
|
|
|
g_free (text);
|
|
|
|
gtk_widget_show (priv->label);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_STRING:
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->entry = gtk_entry_new ();
|
2009-08-11 07:24:18 +00:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (priv->entry),
|
|
|
|
gtk_printer_option_get_activates_default (source));
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->entry);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->entry);
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_connect (priv->entry, "changed", G_CALLBACK (entry_changed_cb), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
text = g_strdup_printf ("%s:", source->display_text);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->label = gtk_label_new_with_mnemonic (text);
|
2006-04-21 15:09:32 +00:00
|
|
|
g_free (text);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->label);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_FILESAVE:
|
2012-08-17 23:04:22 +00:00
|
|
|
priv->button = gtk_button_new ();
|
|
|
|
gtk_widget_show (priv->button);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->button);
|
2012-08-17 23:04:22 +00:00
|
|
|
g_signal_connect (priv->button, "clicked", G_CALLBACK (filesave_choose_cb), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
text = g_strdup_printf ("%s:", source->display_text);
|
|
|
|
priv->label = gtk_label_new_with_mnemonic (text);
|
|
|
|
g_free (text);
|
|
|
|
gtk_widget_show (priv->label);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
break;
|
2011-06-08 11:02:39 +00:00
|
|
|
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_INFO:
|
|
|
|
priv->info_label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_selectable (GTK_LABEL (priv->info_label), TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->info_label);
|
2011-06-08 11:02:39 +00:00
|
|
|
|
|
|
|
text = g_strdup_printf ("%s:", source->display_text);
|
|
|
|
priv->label = gtk_label_new_with_mnemonic (text);
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-11-15 00:43:13 +00:00
|
|
|
priv->image = gtk_image_new_from_icon_name ("dialog-warning");
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), priv->image);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2014-01-20 23:53:58 +00:00
|
|
|
/*
|
2012-08-17 23:04:22 +00:00
|
|
|
* If the filename exceeds FILENAME_LENGTH_MAX, then trim it and replace
|
|
|
|
* the first three letters with three dots.
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
static char *
|
|
|
|
trim_long_filename (const char *filename)
|
2012-08-17 23:04:22 +00:00
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *home;
|
2020-07-24 13:54:49 +00:00
|
|
|
int len, offset;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *result;
|
2012-08-17 23:04:22 +00:00
|
|
|
|
|
|
|
home = g_get_home_dir ();
|
|
|
|
if (g_str_has_prefix (filename, home))
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *homeless_filename;
|
2012-08-17 23:04:22 +00:00
|
|
|
|
|
|
|
offset = g_utf8_strlen (home, -1);
|
|
|
|
len = g_utf8_strlen (filename, -1);
|
|
|
|
homeless_filename = g_utf8_substring (filename, offset, len);
|
|
|
|
result = g_strconcat ("~", homeless_filename, NULL);
|
|
|
|
g_free (homeless_filename);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = g_strdup (filename);
|
|
|
|
|
|
|
|
len = g_utf8_strlen (result, -1);
|
|
|
|
if (len > FILENAME_LENGTH_MAX)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *suffix;
|
2012-08-17 23:04:22 +00:00
|
|
|
|
|
|
|
suffix = g_utf8_substring (result, len - FILENAME_LENGTH_MAX, len);
|
|
|
|
g_free (result);
|
|
|
|
result = g_strconcat ("...", suffix, NULL);
|
|
|
|
g_free (suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
update_widgets (GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOption *source;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
source = priv->source;
|
2022-05-08 00:30:55 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
if (source == NULL)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_hide (priv->image);
|
2006-04-21 15:09:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (source->type)
|
|
|
|
{
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
|
2009-09-09 15:52:07 +00:00
|
|
|
if (g_ascii_strcasecmp (source->value, "True") == 0)
|
2020-08-30 23:36:27 +00:00
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (priv->check), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
else
|
2020-08-30 23:36:27 +00:00
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (priv->check), FALSE);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE:
|
2006-05-02 12:48:52 +00:00
|
|
|
combo_box_set (priv->combo, source->value);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
2006-06-17 04:53:22 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_ALTERNATIVE:
|
|
|
|
alternative_set (priv->box, source->value);
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_STRING:
|
2019-02-28 19:31:36 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (priv->entry), source->value);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
2011-12-28 00:02:28 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_PASSWORD:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_PASSCODE:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_REAL:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_INT:
|
|
|
|
case GTK_PRINTER_OPTION_TYPE_PICKONE_STRING:
|
|
|
|
{
|
2020-06-11 23:59:35 +00:00
|
|
|
GtkWidget *entry = gtk_widget_get_first_child (priv->combo);
|
2011-12-28 00:02:28 +00:00
|
|
|
if (gtk_printer_option_has_choice (source, source->value))
|
|
|
|
combo_box_set (priv->combo, source->value);
|
|
|
|
else
|
2019-02-28 19:31:36 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), source->value);
|
2011-12-28 00:02:28 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_FILESAVE:
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *text;
|
|
|
|
char *filename;
|
2012-08-17 23:04:22 +00:00
|
|
|
|
|
|
|
filename = g_filename_from_uri (source->value, NULL, NULL);
|
2006-08-18 01:30:24 +00:00
|
|
|
if (filename != NULL)
|
|
|
|
{
|
2012-08-17 23:04:22 +00:00
|
|
|
text = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
|
|
|
|
if (text != NULL)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *short_filename;
|
2011-12-08 01:03:07 +00:00
|
|
|
|
2012-08-17 23:04:22 +00:00
|
|
|
short_filename = trim_long_filename (text);
|
|
|
|
gtk_button_set_label (GTK_BUTTON (priv->button), short_filename);
|
|
|
|
g_free (short_filename);
|
|
|
|
}
|
2006-08-18 01:30:24 +00:00
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2012-08-17 23:04:22 +00:00
|
|
|
else
|
|
|
|
gtk_button_set_label (GTK_BUTTON (priv->button), source->value);
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
2011-06-08 11:02:39 +00:00
|
|
|
case GTK_PRINTER_OPTION_TYPE_INFO:
|
|
|
|
gtk_label_set_text (GTK_LABEL (priv->info_label), source->value);
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (source->has_conflict)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->image);
|
2006-04-21 15:09:32 +00:00
|
|
|
else
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_hide (priv->image);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2006-08-23 19:31:56 +00:00
|
|
|
gtk_printer_option_widget_has_external_label (GtkPrinterOptionWidget *widget)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
return widget->priv->label != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
|
|
|
return widget->priv->label;
|
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *
|
2006-08-23 19:31:56 +00:00
|
|
|
gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *widget)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
|
|
|
|
|
|
|
if (priv->source)
|
|
|
|
return priv->source->value;
|
2012-08-17 23:04:22 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
return "";
|
|
|
|
}
|