printers: Use self variable to match coding style
This commit is contained in:
parent
a3c251301e
commit
47cd15d911
14 changed files with 1187 additions and 1238 deletions
|
@ -51,7 +51,7 @@ pp_cups_class_init (PpCupsClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_cups_init (PpCups *cups)
|
||||
pp_cups_init (PpCups *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -89,25 +89,25 @@ _pp_cups_get_dests_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_cups_get_dests_async (PpCups *cups,
|
||||
pp_cups_get_dests_async (PpCups *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (cups, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread (task, (GTaskThreadFunc) _pp_cups_get_dests_thread);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
PpCupsDests *
|
||||
pp_cups_get_dests_finish (PpCups *cups,
|
||||
pp_cups_get_dests_finish (PpCups *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, cups), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -130,14 +130,14 @@ connection_test_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_cups_connection_test_async (PpCups *cups,
|
||||
pp_cups_connection_test_async (PpCups *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (cups, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread (task, connection_test_thread);
|
||||
|
||||
|
@ -145,11 +145,11 @@ pp_cups_connection_test_async (PpCups *cups,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_cups_connection_test_finish (PpCups *cups,
|
||||
pp_cups_connection_test_finish (PpCups *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, cups), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
@ -183,14 +183,14 @@ cancel_subscription_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_cups_cancel_subscription_async (PpCups *cups,
|
||||
pp_cups_cancel_subscription_async (PpCups *self,
|
||||
gint subscription_id,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (cups, NULL, callback, user_data);
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
g_task_set_task_data (task, GINT_TO_POINTER (subscription_id), NULL);
|
||||
g_task_run_in_thread (task, cancel_subscription_thread);
|
||||
|
||||
|
@ -198,10 +198,10 @@ pp_cups_cancel_subscription_async (PpCups *cups,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_cups_cancel_subscription_finish (PpCups *cups,
|
||||
pp_cups_cancel_subscription_finish (PpCups *self,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, cups), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), NULL);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ renew_subscription_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_cups_renew_subscription_async (PpCups *cups,
|
||||
pp_cups_renew_subscription_async (PpCups *self,
|
||||
gint subscription_id,
|
||||
gchar **events,
|
||||
gint lease_duration,
|
||||
|
@ -304,7 +304,7 @@ pp_cups_renew_subscription_async (PpCups *cups,
|
|||
subscription_data->events = g_strdupv (events);
|
||||
subscription_data->lease_duration = lease_duration;
|
||||
|
||||
task = g_task_new (cups, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, subscription_data, (GDestroyNotify) crs_data_free);
|
||||
g_task_run_in_thread (task, renew_subscription_thread);
|
||||
|
||||
|
@ -313,10 +313,10 @@ pp_cups_renew_subscription_async (PpCups *cups,
|
|||
|
||||
/* Returns id of renewed subscription or new id */
|
||||
gint
|
||||
pp_cups_renew_subscription_finish (PpCups *cups,
|
||||
pp_cups_renew_subscription_finish (PpCups *self,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, cups), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
|
||||
return g_task_propagate_int (G_TASK (result), NULL);
|
||||
}
|
||||
|
|
|
@ -140,9 +140,9 @@ pp_host_class_init (PpHostClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_host_init (PpHost *host)
|
||||
pp_host_init (PpHost *self)
|
||||
{
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (host);
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (self);
|
||||
priv->port = PP_HOST_UNSET_PORT;
|
||||
}
|
||||
|
||||
|
@ -244,8 +244,8 @@ _pp_host_get_snmp_devices_thread (GTask *task,
|
|||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
PpHost *host = (PpHost *) source_object;
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (host);
|
||||
PpHost *self = source_object;
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (self);
|
||||
PpDevicesList *devices;
|
||||
PpPrintDevice *device;
|
||||
gboolean is_network_device;
|
||||
|
@ -310,23 +310,23 @@ _pp_host_get_snmp_devices_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_host_get_snmp_devices_async (PpHost *host,
|
||||
pp_host_get_snmp_devices_async (PpHost *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
task = g_task_new (host, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_run_in_thread (task, _pp_host_get_snmp_devices_thread);
|
||||
}
|
||||
|
||||
PpDevicesList *
|
||||
pp_host_get_snmp_devices_finish (PpHost *host,
|
||||
pp_host_get_snmp_devices_finish (PpHost *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, host), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -338,8 +338,8 @@ _pp_host_get_remote_cups_devices_thread (GTask *task,
|
|||
GCancellable *cancellable)
|
||||
{
|
||||
cups_dest_t *dests = NULL;
|
||||
PpHost *host = (PpHost *) source_object;
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (host);
|
||||
PpHost *self = (PpHost *) source_object;
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (self);
|
||||
PpDevicesList *devices;
|
||||
PpPrintDevice *device;
|
||||
const char *device_location;
|
||||
|
@ -396,23 +396,23 @@ _pp_host_get_remote_cups_devices_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_host_get_remote_cups_devices_async (PpHost *host,
|
||||
pp_host_get_remote_cups_devices_async (PpHost *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
task = g_task_new (host, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_run_in_thread (task, _pp_host_get_remote_cups_devices_thread);
|
||||
}
|
||||
|
||||
PpDevicesList *
|
||||
pp_host_get_remote_cups_devices_finish (PpHost *host,
|
||||
pp_host_get_remote_cups_devices_finish (PpHost *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, host), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -485,25 +485,25 @@ jetdirect_connection_test_cb (GObject *source_object,
|
|||
See http://en.wikipedia.org/wiki/JetDirect
|
||||
http://www.cups.org/documentation.php/network.html */
|
||||
void
|
||||
pp_host_get_jetdirect_devices_async (PpHost *host,
|
||||
pp_host_get_jetdirect_devices_async (PpHost *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (host);
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (self);
|
||||
JetDirectData *data;
|
||||
g_autoptr(GTask) task = NULL;
|
||||
g_autofree gchar *address = NULL;
|
||||
|
||||
data = g_new0 (JetDirectData, 1);
|
||||
data->host = g_object_ref (host);
|
||||
data->host = g_object_ref (self);
|
||||
|
||||
if (priv->port == PP_HOST_UNSET_PORT)
|
||||
data->port = PP_HOST_DEFAULT_JETDIRECT_PORT;
|
||||
else
|
||||
data->port = priv->port;
|
||||
|
||||
task = g_task_new (G_OBJECT (host), cancellable, callback, user_data);
|
||||
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, data, (GDestroyNotify) jetdirect_data_free);
|
||||
|
||||
address = g_strdup_printf ("%s:%d", priv->hostname, data->port);
|
||||
|
@ -527,11 +527,11 @@ pp_host_get_jetdirect_devices_async (PpHost *host,
|
|||
}
|
||||
|
||||
PpDevicesList *
|
||||
pp_host_get_jetdirect_devices_finish (PpHost *host,
|
||||
pp_host_get_jetdirect_devices_finish (PpHost *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, host), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -616,8 +616,8 @@ _pp_host_get_lpd_devices_thread (GTask *task,
|
|||
{
|
||||
g_autoptr(GSocketConnection) connection = NULL;
|
||||
PpPrintDevice *device;
|
||||
PpHost *host = (PpHost *) source_object;
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (host);
|
||||
PpHost *self = source_object;
|
||||
PpHostPrivate *priv = pp_host_get_instance_private (self);
|
||||
PpDevicesList *devices;
|
||||
g_autoptr(GSocketClient) client = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
@ -720,23 +720,23 @@ _pp_host_get_lpd_devices_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_host_get_lpd_devices_async (PpHost *host,
|
||||
pp_host_get_lpd_devices_async (PpHost *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
task = g_task_new (G_OBJECT (host), cancellable, callback, user_data);
|
||||
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
|
||||
g_task_run_in_thread (task, _pp_host_get_lpd_devices_thread);
|
||||
}
|
||||
|
||||
PpDevicesList *
|
||||
pp_host_get_lpd_devices_finish (PpHost *host,
|
||||
pp_host_get_lpd_devices_finish (PpHost *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, host), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
|
||||
static void pp_ipp_option_widget_finalize (GObject *object);
|
||||
|
||||
static gboolean construct_widget (PpIPPOptionWidget *widget);
|
||||
static void update_widget (PpIPPOptionWidget *widget);
|
||||
static void update_widget_real (PpIPPOptionWidget *widget);
|
||||
static gboolean construct_widget (PpIPPOptionWidget *self);
|
||||
static void update_widget (PpIPPOptionWidget *self);
|
||||
static void update_widget_real (PpIPPOptionWidget *self);
|
||||
|
||||
struct _PpIPPOptionWidget
|
||||
{
|
||||
|
@ -104,38 +104,38 @@ pp_ipp_option_widget_class_init (PpIPPOptionWidgetClass *class)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_ipp_option_widget_init (PpIPPOptionWidget *widget)
|
||||
pp_ipp_option_widget_init (PpIPPOptionWidget *self)
|
||||
{
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (widget),
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (self),
|
||||
GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
widget->switch_button = NULL;
|
||||
widget->spin_button = NULL;
|
||||
widget->combo = NULL;
|
||||
widget->box = NULL;
|
||||
self->switch_button = NULL;
|
||||
self->spin_button = NULL;
|
||||
self->combo = NULL;
|
||||
self->box = NULL;
|
||||
|
||||
widget->printer_name = NULL;
|
||||
widget->option_name = NULL;
|
||||
self->printer_name = NULL;
|
||||
self->option_name = NULL;
|
||||
|
||||
widget->option_supported = NULL;
|
||||
widget->option_default = NULL;
|
||||
self->option_supported = NULL;
|
||||
self->option_default = NULL;
|
||||
|
||||
widget->ipp_attribute = NULL;
|
||||
self->ipp_attribute = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
pp_ipp_option_widget_finalize (GObject *object)
|
||||
{
|
||||
PpIPPOptionWidget *widget = PP_IPP_OPTION_WIDGET (object);
|
||||
PpIPPOptionWidget *self = PP_IPP_OPTION_WIDGET (object);
|
||||
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
|
||||
g_clear_pointer (&widget->option_name, g_free);
|
||||
g_clear_pointer (&widget->printer_name, g_free);
|
||||
g_clear_pointer (&widget->option_supported, ipp_attribute_free);
|
||||
g_clear_pointer (&widget->option_default, ipp_attribute_free);
|
||||
g_clear_pointer (&widget->ipp_attribute, g_hash_table_unref);
|
||||
g_clear_object (&widget->cancellable);
|
||||
g_clear_pointer (&self->option_name, g_free);
|
||||
g_clear_pointer (&self->printer_name, g_free);
|
||||
g_clear_pointer (&self->option_supported, ipp_attribute_free);
|
||||
g_clear_pointer (&self->option_default, ipp_attribute_free);
|
||||
g_clear_pointer (&self->ipp_attribute, g_hash_table_unref);
|
||||
g_clear_object (&self->cancellable);
|
||||
|
||||
G_OBJECT_CLASS (pp_ipp_option_widget_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -146,30 +146,30 @@ pp_ipp_option_widget_new (IPPAttribute *attr_supported,
|
|||
const gchar *option_name,
|
||||
const gchar *printer)
|
||||
{
|
||||
PpIPPOptionWidget *widget = NULL;
|
||||
PpIPPOptionWidget *self = NULL;
|
||||
|
||||
if (attr_supported && option_name && printer)
|
||||
{
|
||||
widget = g_object_new (PP_TYPE_IPP_OPTION_WIDGET, NULL);
|
||||
self = g_object_new (PP_TYPE_IPP_OPTION_WIDGET, NULL);
|
||||
|
||||
widget->printer_name = g_strdup (printer);
|
||||
widget->option_name = g_strdup (option_name);
|
||||
widget->option_supported = ipp_attribute_copy (attr_supported);
|
||||
widget->option_default = ipp_attribute_copy (attr_default);
|
||||
self->printer_name = g_strdup (printer);
|
||||
self->option_name = g_strdup (option_name);
|
||||
self->option_supported = ipp_attribute_copy (attr_supported);
|
||||
self->option_default = ipp_attribute_copy (attr_default);
|
||||
|
||||
if (construct_widget (widget))
|
||||
if (construct_widget (self))
|
||||
{
|
||||
update_widget_real (widget);
|
||||
update_widget_real (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_ref_sink (widget);
|
||||
g_object_unref (widget);
|
||||
widget = NULL;
|
||||
g_object_ref_sink (self);
|
||||
g_object_unref (self);
|
||||
self = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (GtkWidget *) widget;
|
||||
return (GtkWidget *) self;
|
||||
}
|
||||
|
||||
enum {
|
||||
|
@ -277,16 +277,16 @@ static void
|
|||
printer_add_option_async_cb (gboolean success,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpIPPOptionWidget *widget = (PpIPPOptionWidget *) user_data;
|
||||
PpIPPOptionWidget *self = user_data;
|
||||
|
||||
update_widget (user_data);
|
||||
g_clear_object (&widget->cancellable);
|
||||
g_clear_object (&self->cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
switch_changed_cb (GtkWidget *switch_button,
|
||||
GParamSpec *pspec,
|
||||
PpIPPOptionWidget *widget)
|
||||
PpIPPOptionWidget *self)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
|
@ -297,156 +297,156 @@ switch_changed_cb (GtkWidget *switch_button,
|
|||
else
|
||||
values[0] = g_strdup ("False");
|
||||
|
||||
if (widget->cancellable)
|
||||
if (self->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
g_object_unref (widget->cancellable);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_object_unref (self->cancellable);
|
||||
}
|
||||
|
||||
widget->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (widget->printer_name,
|
||||
widget->option_name,
|
||||
self->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (self->printer_name,
|
||||
self->option_name,
|
||||
values,
|
||||
TRUE,
|
||||
widget->cancellable,
|
||||
self->cancellable,
|
||||
printer_add_option_async_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
g_strfreev (values);
|
||||
}
|
||||
|
||||
static void
|
||||
combo_changed_cb (GtkWidget *combo,
|
||||
PpIPPOptionWidget *widget)
|
||||
PpIPPOptionWidget *self)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
values = g_new0 (gchar *, 2);
|
||||
values[0] = combo_box_get (combo);
|
||||
|
||||
if (widget->cancellable)
|
||||
if (self->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
g_object_unref (widget->cancellable);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_object_unref (self->cancellable);
|
||||
}
|
||||
|
||||
widget->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (widget->printer_name,
|
||||
widget->option_name,
|
||||
self->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (self->printer_name,
|
||||
self->option_name,
|
||||
values,
|
||||
TRUE,
|
||||
widget->cancellable,
|
||||
self->cancellable,
|
||||
printer_add_option_async_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
g_strfreev (values);
|
||||
}
|
||||
|
||||
static void
|
||||
spin_button_changed_cb (GtkWidget *spin_button,
|
||||
PpIPPOptionWidget *widget)
|
||||
PpIPPOptionWidget *self)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
values = g_new0 (gchar *, 2);
|
||||
values[0] = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin_button)));
|
||||
|
||||
if (widget->cancellable)
|
||||
if (self->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
g_object_unref (widget->cancellable);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_object_unref (self->cancellable);
|
||||
}
|
||||
|
||||
widget->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (widget->printer_name,
|
||||
widget->option_name,
|
||||
self->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (self->printer_name,
|
||||
self->option_name,
|
||||
values,
|
||||
TRUE,
|
||||
widget->cancellable,
|
||||
self->cancellable,
|
||||
printer_add_option_async_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
g_strfreev (values);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
construct_widget (PpIPPOptionWidget *widget)
|
||||
construct_widget (PpIPPOptionWidget *self)
|
||||
{
|
||||
gboolean trivial_option = FALSE;
|
||||
gboolean result = FALSE;
|
||||
gchar *value;
|
||||
gint i;
|
||||
|
||||
if (widget->option_supported)
|
||||
if (self->option_supported)
|
||||
{
|
||||
switch (widget->option_supported->attribute_type)
|
||||
switch (self->option_supported->attribute_type)
|
||||
{
|
||||
case IPP_ATTRIBUTE_TYPE_INTEGER:
|
||||
if (widget->option_supported->num_of_values <= 1)
|
||||
if (self->option_supported->num_of_values <= 1)
|
||||
trivial_option = TRUE;
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_STRING:
|
||||
if (widget->option_supported->num_of_values <= 1)
|
||||
if (self->option_supported->num_of_values <= 1)
|
||||
trivial_option = TRUE;
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_RANGE:
|
||||
if (widget->option_supported->attribute_values[0].lower_range ==
|
||||
widget->option_supported->attribute_values[0].upper_range)
|
||||
if (self->option_supported->attribute_values[0].lower_range ==
|
||||
self->option_supported->attribute_values[0].upper_range)
|
||||
trivial_option = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!trivial_option)
|
||||
{
|
||||
switch (widget->option_supported->attribute_type)
|
||||
switch (self->option_supported->attribute_type)
|
||||
{
|
||||
case IPP_ATTRIBUTE_TYPE_BOOLEAN:
|
||||
widget->switch_button = gtk_switch_new ();
|
||||
self->switch_button = gtk_switch_new ();
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->switch_button, FALSE, FALSE, 0);
|
||||
g_signal_connect (widget->switch_button, "notify::active", G_CALLBACK (switch_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->switch_button, FALSE, FALSE, 0);
|
||||
g_signal_connect (self->switch_button, "notify::active", G_CALLBACK (switch_changed_cb), self);
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_INTEGER:
|
||||
widget->combo = combo_box_new ();
|
||||
self->combo = combo_box_new ();
|
||||
|
||||
for (i = 0; i < widget->option_supported->num_of_values; i++)
|
||||
for (i = 0; i < self->option_supported->num_of_values; i++)
|
||||
{
|
||||
value = g_strdup_printf ("%d", widget->option_supported->attribute_values[i].integer_value);
|
||||
combo_box_append (widget->combo,
|
||||
ipp_choice_translate (widget->option_name,
|
||||
value = g_strdup_printf ("%d", self->option_supported->attribute_values[i].integer_value);
|
||||
combo_box_append (self->combo,
|
||||
ipp_choice_translate (self->option_name,
|
||||
value),
|
||||
value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->combo, FALSE, FALSE, 0);
|
||||
g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->combo, FALSE, FALSE, 0);
|
||||
g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_STRING:
|
||||
widget->combo = combo_box_new ();
|
||||
self->combo = combo_box_new ();
|
||||
|
||||
for (i = 0; i < widget->option_supported->num_of_values; i++)
|
||||
combo_box_append (widget->combo,
|
||||
ipp_choice_translate (widget->option_name,
|
||||
widget->option_supported->attribute_values[i].string_value),
|
||||
widget->option_supported->attribute_values[i].string_value);
|
||||
for (i = 0; i < self->option_supported->num_of_values; i++)
|
||||
combo_box_append (self->combo,
|
||||
ipp_choice_translate (self->option_name,
|
||||
self->option_supported->attribute_values[i].string_value),
|
||||
self->option_supported->attribute_values[i].string_value);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->combo, FALSE, FALSE, 0);
|
||||
g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->combo, FALSE, FALSE, 0);
|
||||
g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_RANGE:
|
||||
widget->spin_button = gtk_spin_button_new_with_range (
|
||||
widget->option_supported->attribute_values[0].lower_range,
|
||||
widget->option_supported->attribute_values[0].upper_range,
|
||||
self->spin_button = gtk_spin_button_new_with_range (
|
||||
self->option_supported->attribute_values[0].lower_range,
|
||||
self->option_supported->attribute_values[0].upper_range,
|
||||
1);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->spin_button, FALSE, FALSE, 0);
|
||||
g_signal_connect (widget->spin_button, "value-changed", G_CALLBACK (spin_button_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->spin_button, FALSE, FALSE, 0);
|
||||
g_signal_connect (self->spin_button, "value-changed", G_CALLBACK (spin_button_changed_cb), self);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -461,96 +461,96 @@ construct_widget (PpIPPOptionWidget *widget)
|
|||
}
|
||||
|
||||
static void
|
||||
update_widget_real (PpIPPOptionWidget *widget)
|
||||
update_widget_real (PpIPPOptionWidget *self)
|
||||
{
|
||||
IPPAttribute *attr = NULL;
|
||||
gchar *value;
|
||||
gchar *attr_name;
|
||||
|
||||
if (widget->option_default)
|
||||
if (self->option_default)
|
||||
{
|
||||
attr = ipp_attribute_copy (widget->option_default);
|
||||
attr = ipp_attribute_copy (self->option_default);
|
||||
|
||||
ipp_attribute_free (widget->option_default);
|
||||
widget->option_default = NULL;
|
||||
ipp_attribute_free (self->option_default);
|
||||
self->option_default = NULL;
|
||||
}
|
||||
else if (widget->ipp_attribute)
|
||||
else if (self->ipp_attribute)
|
||||
{
|
||||
attr_name = g_strdup_printf ("%s-default", widget->option_name);
|
||||
attr = ipp_attribute_copy (g_hash_table_lookup (widget->ipp_attribute, attr_name));
|
||||
attr_name = g_strdup_printf ("%s-default", self->option_name);
|
||||
attr = ipp_attribute_copy (g_hash_table_lookup (self->ipp_attribute, attr_name));
|
||||
|
||||
g_free (attr_name);
|
||||
g_hash_table_unref (widget->ipp_attribute);
|
||||
widget->ipp_attribute = NULL;
|
||||
g_hash_table_unref (self->ipp_attribute);
|
||||
self->ipp_attribute = NULL;
|
||||
}
|
||||
|
||||
switch (widget->option_supported->attribute_type)
|
||||
switch (self->option_supported->attribute_type)
|
||||
{
|
||||
case IPP_ATTRIBUTE_TYPE_BOOLEAN:
|
||||
g_signal_handlers_block_by_func (widget->switch_button, switch_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->switch_button, switch_changed_cb, self);
|
||||
|
||||
if (attr && attr->num_of_values > 0 &&
|
||||
attr->attribute_type == IPP_ATTRIBUTE_TYPE_BOOLEAN)
|
||||
{
|
||||
gtk_switch_set_active (GTK_SWITCH (widget->switch_button),
|
||||
gtk_switch_set_active (GTK_SWITCH (self->switch_button),
|
||||
attr->attribute_values[0].boolean_value);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (widget->switch_button, switch_changed_cb, widget);
|
||||
g_signal_handlers_unblock_by_func (self->switch_button, switch_changed_cb, self);
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_INTEGER:
|
||||
g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->combo, combo_changed_cb, self);
|
||||
|
||||
if (attr && attr->num_of_values > 0 &&
|
||||
attr->attribute_type == IPP_ATTRIBUTE_TYPE_INTEGER)
|
||||
{
|
||||
value = g_strdup_printf ("%d", attr->attribute_values[0].integer_value);
|
||||
combo_box_set (widget->combo, value);
|
||||
combo_box_set (self->combo, value);
|
||||
g_free (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = g_strdup_printf ("%d", widget->option_supported->attribute_values[0].integer_value);
|
||||
combo_box_set (widget->combo, value);
|
||||
value = g_strdup_printf ("%d", self->option_supported->attribute_values[0].integer_value);
|
||||
combo_box_set (self->combo, value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
|
||||
g_signal_handlers_unblock_by_func (self->combo, combo_changed_cb, self);
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_STRING:
|
||||
g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->combo, combo_changed_cb, self);
|
||||
|
||||
if (attr && attr->num_of_values > 0 &&
|
||||
attr->attribute_type == IPP_ATTRIBUTE_TYPE_STRING)
|
||||
{
|
||||
combo_box_set (widget->combo, attr->attribute_values[0].string_value);
|
||||
combo_box_set (self->combo, attr->attribute_values[0].string_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
combo_box_set (widget->combo, widget->option_supported->attribute_values[0].string_value);
|
||||
combo_box_set (self->combo, self->option_supported->attribute_values[0].string_value);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
|
||||
g_signal_handlers_unblock_by_func (self->combo, combo_changed_cb, self);
|
||||
break;
|
||||
|
||||
case IPP_ATTRIBUTE_TYPE_RANGE:
|
||||
g_signal_handlers_block_by_func (widget->spin_button, spin_button_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->spin_button, spin_button_changed_cb, self);
|
||||
|
||||
if (attr && attr->num_of_values > 0 &&
|
||||
attr->attribute_type == IPP_ATTRIBUTE_TYPE_INTEGER)
|
||||
{
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget->spin_button),
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->spin_button),
|
||||
attr->attribute_values[0].integer_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget->spin_button),
|
||||
widget->option_supported->attribute_values[0].lower_range);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->spin_button),
|
||||
self->option_supported->attribute_values[0].lower_range);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (widget->spin_button, spin_button_changed_cb, widget);
|
||||
g_signal_handlers_unblock_by_func (self->spin_button, spin_button_changed_cb, self);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -564,28 +564,28 @@ static void
|
|||
get_ipp_attributes_cb (GHashTable *table,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpIPPOptionWidget *widget = (PpIPPOptionWidget *) user_data;
|
||||
PpIPPOptionWidget *self = user_data;
|
||||
|
||||
if (widget->ipp_attribute)
|
||||
g_hash_table_unref (widget->ipp_attribute);
|
||||
if (self->ipp_attribute)
|
||||
g_hash_table_unref (self->ipp_attribute);
|
||||
|
||||
widget->ipp_attribute = table;
|
||||
self->ipp_attribute = table;
|
||||
|
||||
update_widget_real (widget);
|
||||
update_widget_real (self);
|
||||
}
|
||||
|
||||
static void
|
||||
update_widget (PpIPPOptionWidget *widget)
|
||||
update_widget (PpIPPOptionWidget *self)
|
||||
{
|
||||
gchar **attributes_names;
|
||||
|
||||
attributes_names = g_new0 (gchar *, 2);
|
||||
attributes_names[0] = g_strdup_printf ("%s-default", widget->option_name);
|
||||
attributes_names[0] = g_strdup_printf ("%s-default", self->option_name);
|
||||
|
||||
get_ipp_attributes_async (widget->printer_name,
|
||||
get_ipp_attributes_async (self->printer_name,
|
||||
attributes_names,
|
||||
get_ipp_attributes_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
g_strfreev (attributes_names);
|
||||
}
|
||||
|
|
|
@ -86,14 +86,14 @@ pp_job_cancel_purge_async_dbus_cb (GObject *source_object,
|
|||
}
|
||||
|
||||
void
|
||||
pp_job_cancel_purge_async (PpJob *job,
|
||||
pp_job_cancel_purge_async (PpJob *self,
|
||||
gboolean job_purge)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gint *job_id;
|
||||
|
||||
g_object_get (job, "id", &job_id, NULL);
|
||||
g_object_get (self, "id", &job_id, NULL);
|
||||
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!bus)
|
||||
|
@ -137,14 +137,14 @@ pp_job_set_hold_until_async_dbus_cb (GObject *source_object,
|
|||
}
|
||||
|
||||
void
|
||||
pp_job_set_hold_until_async (PpJob *job,
|
||||
pp_job_set_hold_until_async (PpJob *self,
|
||||
const gchar *job_hold_until)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gint *job_id;
|
||||
|
||||
g_object_get (job, "id", &job_id, NULL);
|
||||
g_object_get (self, "id", &job_id, NULL);
|
||||
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!bus)
|
||||
|
@ -392,7 +392,7 @@ _pp_job_get_attributes_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_job_get_attributes_async (PpJob *job,
|
||||
pp_job_get_attributes_async (PpJob *self,
|
||||
gchar **attributes_names,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
@ -400,7 +400,7 @@ pp_job_get_attributes_async (PpJob *job,
|
|||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (job, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, g_strdupv (attributes_names), (GDestroyNotify) g_strfreev);
|
||||
g_task_run_in_thread (task, _pp_job_get_attributes_thread);
|
||||
|
||||
|
@ -408,11 +408,11 @@ pp_job_get_attributes_async (PpJob *job,
|
|||
}
|
||||
|
||||
GVariant *
|
||||
pp_job_get_attributes_finish (PpJob *job,
|
||||
pp_job_get_attributes_finish (PpJob *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, job), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ _pp_job_authenticate_thread (GTask *task,
|
|||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
PpJob *job = PP_JOB (source_object);
|
||||
PpJob *self = source_object;
|
||||
gboolean result = FALSE;
|
||||
gchar **auth_info = task_data;
|
||||
ipp_t *request;
|
||||
|
@ -433,7 +433,7 @@ _pp_job_authenticate_thread (GTask *task,
|
|||
|
||||
if (auth_info != NULL)
|
||||
{
|
||||
job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", job->id);
|
||||
job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", self->id);
|
||||
|
||||
length = g_strv_length (auth_info);
|
||||
|
||||
|
@ -458,7 +458,7 @@ _pp_job_authenticate_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_job_authenticate_async (PpJob *job,
|
||||
pp_job_authenticate_async (PpJob *self,
|
||||
gchar **auth_info,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
@ -466,7 +466,7 @@ pp_job_authenticate_async (PpJob *job,
|
|||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (job, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, g_strdupv (auth_info), (GDestroyNotify) g_strfreev);
|
||||
g_task_run_in_thread (task, _pp_job_authenticate_thread);
|
||||
|
||||
|
@ -474,11 +474,11 @@ pp_job_authenticate_async (PpJob *job,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_job_authenticate_finish (PpJob *job,
|
||||
pp_job_authenticate_finish (PpJob *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, job), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define CLOCK_SCHEMA "org.gnome.desktop.interface"
|
||||
#define CLOCK_FORMAT_KEY "clock-format"
|
||||
|
||||
static void pp_jobs_dialog_hide (PpJobsDialog *dialog);
|
||||
static void pp_jobs_dialog_hide (PpJobsDialog *self);
|
||||
|
||||
struct _PpJobsDialog {
|
||||
GtkBuilder *builder;
|
||||
|
@ -66,17 +66,17 @@ struct _PpJobsDialog {
|
|||
};
|
||||
|
||||
static gboolean
|
||||
is_info_required (PpJobsDialog *dialog,
|
||||
is_info_required (PpJobsDialog *self,
|
||||
const gchar *info)
|
||||
{
|
||||
gboolean required = FALSE;
|
||||
gint i;
|
||||
|
||||
if (dialog != NULL && dialog->actual_auth_info_required != NULL)
|
||||
if (self != NULL && self->actual_auth_info_required != NULL)
|
||||
{
|
||||
for (i = 0; dialog->actual_auth_info_required[i] != NULL; i++)
|
||||
for (i = 0; self->actual_auth_info_required[i] != NULL; i++)
|
||||
{
|
||||
if (g_strcmp0 (dialog->actual_auth_info_required[i], info) == 0)
|
||||
if (g_strcmp0 (self->actual_auth_info_required[i], info) == 0)
|
||||
{
|
||||
required = TRUE;
|
||||
break;
|
||||
|
@ -88,25 +88,25 @@ is_info_required (PpJobsDialog *dialog,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
is_domain_required (PpJobsDialog *dialog)
|
||||
is_domain_required (PpJobsDialog *self)
|
||||
{
|
||||
return is_info_required (dialog, "domain");
|
||||
return is_info_required (self, "domain");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_username_required (PpJobsDialog *dialog)
|
||||
is_username_required (PpJobsDialog *self)
|
||||
{
|
||||
return is_info_required (dialog, "username");
|
||||
return is_info_required (self, "username");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_password_required (PpJobsDialog *dialog)
|
||||
is_password_required (PpJobsDialog *self)
|
||||
{
|
||||
return is_info_required (dialog, "password");
|
||||
return is_info_required (self, "password");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
auth_popup_filled (PpJobsDialog *dialog)
|
||||
auth_popup_filled (PpJobsDialog *self)
|
||||
{
|
||||
gboolean domain_required;
|
||||
gboolean username_required;
|
||||
|
@ -115,13 +115,13 @@ auth_popup_filled (PpJobsDialog *dialog)
|
|||
guint16 username_length;
|
||||
guint16 password_length;
|
||||
|
||||
domain_required = is_domain_required (dialog);
|
||||
username_required = is_username_required (dialog);
|
||||
password_required = is_password_required (dialog);
|
||||
domain_required = is_domain_required (self);
|
||||
username_required = is_username_required (self);
|
||||
password_required = is_password_required (self);
|
||||
|
||||
domain_length = gtk_entry_get_text_length (GTK_ENTRY (gtk_builder_get_object (dialog->builder, "domain-entry")));
|
||||
username_length = gtk_entry_get_text_length (GTK_ENTRY (gtk_builder_get_object (dialog->builder, "username-entry")));
|
||||
password_length = gtk_entry_get_text_length (GTK_ENTRY (gtk_builder_get_object (dialog->builder, "password-entry")));
|
||||
domain_length = gtk_entry_get_text_length (GTK_ENTRY (gtk_builder_get_object (self->builder, "domain-entry")));
|
||||
username_length = gtk_entry_get_text_length (GTK_ENTRY (gtk_builder_get_object (self->builder, "username-entry")));
|
||||
password_length = gtk_entry_get_text_length (GTK_ENTRY (gtk_builder_get_object (self->builder, "password-entry")));
|
||||
|
||||
return (!domain_required || domain_length > 0) &&
|
||||
(!username_required || username_length > 0) &&
|
||||
|
@ -130,59 +130,59 @@ auth_popup_filled (PpJobsDialog *dialog)
|
|||
|
||||
static void
|
||||
auth_entries_changed (GtkEntry *entry,
|
||||
PpJobsDialog *dialog)
|
||||
PpJobsDialog *self)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "authenticate-button"));
|
||||
gtk_widget_set_sensitive (widget, auth_popup_filled (dialog));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "authenticate-button"));
|
||||
gtk_widget_set_sensitive (widget, auth_popup_filled (self));
|
||||
}
|
||||
|
||||
static void
|
||||
auth_entries_activated (GtkEntry *entry,
|
||||
PpJobsDialog *dialog)
|
||||
PpJobsDialog *self)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "authenticate-button"));
|
||||
if (auth_popup_filled (dialog))
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "authenticate-button"));
|
||||
if (auth_popup_filled (self))
|
||||
gtk_button_clicked (GTK_BUTTON (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
authenticate_popover_update (PpJobsDialog *dialog)
|
||||
authenticate_popover_update (PpJobsDialog *self)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean domain_required;
|
||||
gboolean username_required;
|
||||
gboolean password_required;
|
||||
|
||||
domain_required = is_domain_required (dialog);
|
||||
username_required = is_username_required (dialog);
|
||||
password_required = is_password_required (dialog);
|
||||
domain_required = is_domain_required (self);
|
||||
username_required = is_username_required (self);
|
||||
password_required = is_password_required (self);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "domain-label"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "domain-label"));
|
||||
gtk_widget_set_visible (widget, domain_required);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "domain-entry"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "domain-entry"));
|
||||
gtk_widget_set_visible (widget, domain_required);
|
||||
if (domain_required)
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), "");
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "username-label"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "username-label"));
|
||||
gtk_widget_set_visible (widget, username_required);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "username-entry"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "username-entry"));
|
||||
gtk_widget_set_visible (widget, username_required);
|
||||
if (username_required)
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), cupsUser ());
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "password-label"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "password-label"));
|
||||
gtk_widget_set_visible (widget, password_required);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "password-entry"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "password-entry"));
|
||||
gtk_widget_set_visible (widget, password_required);
|
||||
if (password_required)
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), "");
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "authenticate-button"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "authenticate-button"));
|
||||
gtk_widget_set_sensitive (widget, FALSE);
|
||||
}
|
||||
|
||||
|
@ -301,13 +301,13 @@ create_listbox_row (gpointer item,
|
|||
}
|
||||
|
||||
static void
|
||||
pop_up_authentication_popup (PpJobsDialog *dialog)
|
||||
pop_up_authentication_popup (PpJobsDialog *self)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
if (dialog->actual_auth_info_required != NULL)
|
||||
if (self->actual_auth_info_required != NULL)
|
||||
{
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "authenticate-jobs-button"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "authenticate-jobs-button"));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ update_jobs_list_cb (GObject *source_object,
|
|||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpJobsDialog *dialog = user_data;
|
||||
PpJobsDialog *self = user_data;
|
||||
PpPrinter *printer = PP_PRINTER (source_object);
|
||||
GtkWidget *clear_all_button;
|
||||
GtkWidget *infobar;
|
||||
|
@ -330,10 +330,10 @@ update_jobs_list_cb (GObject *source_object,
|
|||
gchar *text;
|
||||
gint num_of_jobs, num_of_auth_jobs = 0;
|
||||
|
||||
g_list_store_remove_all (dialog->store);
|
||||
g_list_store_remove_all (self->store);
|
||||
|
||||
stack = GTK_STACK (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "stack"));
|
||||
clear_all_button = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "jobs-clear-all-button"));
|
||||
stack = GTK_STACK (gtk_builder_get_object (GTK_BUILDER (self->builder), "stack"));
|
||||
clear_all_button = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "jobs-clear-all-button"));
|
||||
|
||||
jobs = pp_printer_get_jobs_finish (printer, result, &error);
|
||||
if (error != NULL)
|
||||
|
@ -362,7 +362,7 @@ update_jobs_list_cb (GObject *source_object,
|
|||
{
|
||||
job = PP_JOB (l->data);
|
||||
|
||||
g_list_store_append (dialog->store, job);
|
||||
g_list_store_append (self->store, job);
|
||||
|
||||
g_object_get (G_OBJECT (job),
|
||||
"auth-info-required", &auth_info_required,
|
||||
|
@ -371,8 +371,8 @@ update_jobs_list_cb (GObject *source_object,
|
|||
{
|
||||
num_of_auth_jobs++;
|
||||
|
||||
if (dialog->actual_auth_info_required == NULL)
|
||||
dialog->actual_auth_info_required = auth_info_required;
|
||||
if (self->actual_auth_info_required == NULL)
|
||||
self->actual_auth_info_required = auth_info_required;
|
||||
else
|
||||
g_strfreev (auth_info_required);
|
||||
|
||||
|
@ -380,10 +380,10 @@ update_jobs_list_cb (GObject *source_object,
|
|||
}
|
||||
}
|
||||
|
||||
infobar = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "authentication-infobar"));
|
||||
infobar = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "authentication-infobar"));
|
||||
if (num_of_auth_jobs > 0)
|
||||
{
|
||||
label = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "authenticate-jobs-label"));
|
||||
label = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "authenticate-jobs-label"));
|
||||
|
||||
/* Translators: This label shows how many jobs of this printer needs to be authenticated to be printed. */
|
||||
text = g_strdup_printf (ngettext ("%u Job Requires Authentication", "%u Jobs Require Authentication", num_of_auth_jobs), num_of_auth_jobs);
|
||||
|
@ -397,42 +397,42 @@ update_jobs_list_cb (GObject *source_object,
|
|||
gtk_widget_hide (infobar);
|
||||
}
|
||||
|
||||
authenticate_popover_update (dialog);
|
||||
authenticate_popover_update (self);
|
||||
|
||||
g_list_free (jobs);
|
||||
g_clear_object (&dialog->get_jobs_cancellable);
|
||||
g_clear_object (&self->get_jobs_cancellable);
|
||||
|
||||
if (!dialog->jobs_filled)
|
||||
if (!self->jobs_filled)
|
||||
{
|
||||
if (dialog->pop_up_authentication_popup)
|
||||
if (self->pop_up_authentication_popup)
|
||||
{
|
||||
pop_up_authentication_popup (dialog);
|
||||
dialog->pop_up_authentication_popup = FALSE;
|
||||
pop_up_authentication_popup (self);
|
||||
self->pop_up_authentication_popup = FALSE;
|
||||
}
|
||||
|
||||
dialog->jobs_filled = TRUE;
|
||||
self->jobs_filled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_jobs_list (PpJobsDialog *dialog)
|
||||
update_jobs_list (PpJobsDialog *self)
|
||||
{
|
||||
PpPrinter *printer;
|
||||
|
||||
if (dialog->printer_name != NULL)
|
||||
if (self->printer_name != NULL)
|
||||
{
|
||||
g_cancellable_cancel (dialog->get_jobs_cancellable);
|
||||
g_clear_object (&dialog->get_jobs_cancellable);
|
||||
g_cancellable_cancel (self->get_jobs_cancellable);
|
||||
g_clear_object (&self->get_jobs_cancellable);
|
||||
|
||||
dialog->get_jobs_cancellable = g_cancellable_new ();
|
||||
self->get_jobs_cancellable = g_cancellable_new ();
|
||||
|
||||
printer = pp_printer_new (dialog->printer_name);
|
||||
printer = pp_printer_new (self->printer_name);
|
||||
pp_printer_get_jobs_async (printer,
|
||||
TRUE,
|
||||
CUPS_WHICHJOBS_ACTIVE,
|
||||
dialog->get_jobs_cancellable,
|
||||
self->get_jobs_cancellable,
|
||||
update_jobs_list_cb,
|
||||
dialog);
|
||||
self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,28 +441,28 @@ jobs_dialog_response_cb (GtkDialog *dialog,
|
|||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpJobsDialog *jobs_dialog = (PpJobsDialog*) user_data;
|
||||
PpJobsDialog *self = (PpJobsDialog*) user_data;
|
||||
|
||||
pp_jobs_dialog_hide (jobs_dialog);
|
||||
pp_jobs_dialog_hide (self);
|
||||
|
||||
jobs_dialog->user_callback (GTK_DIALOG (jobs_dialog->dialog),
|
||||
response_id,
|
||||
jobs_dialog->user_data);
|
||||
self->user_callback (GTK_DIALOG (self->dialog),
|
||||
response_id,
|
||||
self->user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
on_clear_all_button_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpJobsDialog *dialog = user_data;
|
||||
PpJobsDialog *self = user_data;
|
||||
guint num_items;
|
||||
guint i;
|
||||
|
||||
num_items = g_list_model_get_n_items (G_LIST_MODEL (dialog->store));
|
||||
num_items = g_list_model_get_n_items (G_LIST_MODEL (self->store));
|
||||
|
||||
for (i = 0; i < num_items; i++)
|
||||
{
|
||||
PpJob *job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (dialog->store), i));
|
||||
PpJob *job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (self->store), i));
|
||||
|
||||
pp_job_cancel_purge_async (job, FALSE);
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ pp_job_authenticate_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpJobsDialog *dialog = user_data;
|
||||
PpJobsDialog *self = user_data;
|
||||
gboolean result;
|
||||
g_autoptr(GError) error = NULL;
|
||||
PpJob *job = PP_JOB (source_object);
|
||||
|
@ -481,7 +481,7 @@ pp_job_authenticate_cb (GObject *source_object,
|
|||
result = pp_job_authenticate_finish (job, res, &error);
|
||||
if (result)
|
||||
{
|
||||
pp_jobs_dialog_update (dialog);
|
||||
pp_jobs_dialog_update (self);
|
||||
}
|
||||
else if (error != NULL)
|
||||
{
|
||||
|
@ -496,7 +496,7 @@ static void
|
|||
authenticate_button_clicked (GtkWidget *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpJobsDialog *dialog = user_data;
|
||||
PpJobsDialog *self = user_data;
|
||||
GtkWidget *widget;
|
||||
PpJob *job;
|
||||
gchar **auth_info_required = NULL;
|
||||
|
@ -504,15 +504,15 @@ authenticate_button_clicked (GtkWidget *button,
|
|||
guint num_items;
|
||||
gint i;
|
||||
|
||||
auth_info = g_new0 (gchar *, g_strv_length (dialog->actual_auth_info_required) + 1);
|
||||
for (i = 0; dialog->actual_auth_info_required[i] != NULL; i++)
|
||||
auth_info = g_new0 (gchar *, g_strv_length (self->actual_auth_info_required) + 1);
|
||||
for (i = 0; self->actual_auth_info_required[i] != NULL; i++)
|
||||
{
|
||||
if (g_strcmp0 (dialog->actual_auth_info_required[i], "domain") == 0)
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "domain-entry"));
|
||||
else if (g_strcmp0 (dialog->actual_auth_info_required[i], "username") == 0)
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "username-entry"));
|
||||
else if (g_strcmp0 (dialog->actual_auth_info_required[i], "password") == 0)
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "password-entry"));
|
||||
if (g_strcmp0 (self->actual_auth_info_required[i], "domain") == 0)
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "domain-entry"));
|
||||
else if (g_strcmp0 (self->actual_auth_info_required[i], "username") == 0)
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "username-entry"));
|
||||
else if (g_strcmp0 (self->actual_auth_info_required[i], "password") == 0)
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "password-entry"));
|
||||
else
|
||||
widget = NULL;
|
||||
|
||||
|
@ -520,15 +520,15 @@ authenticate_button_clicked (GtkWidget *button,
|
|||
auth_info[i] = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
|
||||
}
|
||||
|
||||
num_items = g_list_model_get_n_items (G_LIST_MODEL (dialog->store));
|
||||
num_items = g_list_model_get_n_items (G_LIST_MODEL (self->store));
|
||||
for (i = 0; i < num_items; i++)
|
||||
{
|
||||
job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (dialog->store), i));
|
||||
job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (self->store), i));
|
||||
|
||||
g_object_get (job, "auth-info-required", &auth_info_required, NULL);
|
||||
if (auth_info_required != NULL)
|
||||
{
|
||||
pp_job_authenticate_async (job, auth_info, NULL, pp_job_authenticate_cb, dialog);
|
||||
pp_job_authenticate_async (job, auth_info, NULL, pp_job_authenticate_cb, self);
|
||||
|
||||
g_strfreev (auth_info_required);
|
||||
auth_info_required = NULL;
|
||||
|
@ -555,7 +555,7 @@ pp_jobs_dialog_new (GtkWindow *parent,
|
|||
gpointer user_data,
|
||||
gchar *printer_name)
|
||||
{
|
||||
PpJobsDialog *dialog;
|
||||
PpJobsDialog *self;
|
||||
GtkWidget *widget;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gchar *objects[] = { "jobs-dialog", "authentication_popover", NULL };
|
||||
|
@ -563,12 +563,12 @@ pp_jobs_dialog_new (GtkWindow *parent,
|
|||
guint builder_result;
|
||||
gchar *title;
|
||||
|
||||
dialog = g_new0 (PpJobsDialog, 1);
|
||||
self = g_new0 (PpJobsDialog, 1);
|
||||
|
||||
dialog->builder = gtk_builder_new ();
|
||||
dialog->parent = GTK_WIDGET (parent);
|
||||
self->builder = gtk_builder_new ();
|
||||
self->parent = GTK_WIDGET (parent);
|
||||
|
||||
builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
|
||||
builder_result = gtk_builder_add_objects_from_resource (self->builder,
|
||||
"/org/gnome/control-center/printers/jobs-dialog.ui",
|
||||
objects, &error);
|
||||
|
||||
|
@ -578,109 +578,108 @@ pp_jobs_dialog_new (GtkWindow *parent,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
dialog->dialog = (GtkWidget *) gtk_builder_get_object (dialog->builder, "jobs-dialog");
|
||||
dialog->user_callback = user_callback;
|
||||
dialog->user_data = user_data;
|
||||
dialog->printer_name = g_strdup (printer_name);
|
||||
dialog->actual_auth_info_required = NULL;
|
||||
dialog->jobs_filled = FALSE;
|
||||
dialog->pop_up_authentication_popup = FALSE;
|
||||
self->dialog = (GtkWidget *) gtk_builder_get_object (self->builder, "jobs-dialog");
|
||||
self->user_callback = user_callback;
|
||||
self->user_data = user_data;
|
||||
self->printer_name = g_strdup (printer_name);
|
||||
self->actual_auth_info_required = NULL;
|
||||
self->jobs_filled = FALSE;
|
||||
self->pop_up_authentication_popup = FALSE;
|
||||
|
||||
/* connect signals */
|
||||
g_signal_connect (dialog->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
g_signal_connect (dialog->dialog, "response", G_CALLBACK (jobs_dialog_response_cb), dialog);
|
||||
g_signal_connect (dialog->dialog, "key-press-event", G_CALLBACK (key_press_event_cb), NULL);
|
||||
g_signal_connect (self->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
g_signal_connect (self->dialog, "response", G_CALLBACK (jobs_dialog_response_cb), self);
|
||||
g_signal_connect (self->dialog, "key-press-event", G_CALLBACK (key_press_event_cb), NULL);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "jobs-clear-all-button"));
|
||||
g_signal_connect (widget, "clicked", G_CALLBACK (on_clear_all_button_clicked), dialog);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "jobs-clear-all-button"));
|
||||
g_signal_connect (widget, "clicked", G_CALLBACK (on_clear_all_button_clicked), self);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "authenticate-button"));
|
||||
g_signal_connect (widget, "clicked", G_CALLBACK (authenticate_button_clicked), dialog);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "authenticate-button"));
|
||||
g_signal_connect (widget, "clicked", G_CALLBACK (authenticate_button_clicked), self);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "domain-entry"));
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), dialog);
|
||||
g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), dialog);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "domain-entry"));
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), self);
|
||||
g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), self);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "username-entry"));
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), dialog);
|
||||
g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), dialog);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "username-entry"));
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), self);
|
||||
g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), self);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "password-entry"));
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), dialog);
|
||||
g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), dialog);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "password-entry"));
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (auth_entries_changed), self);
|
||||
g_signal_connect (widget, "activate", G_CALLBACK (auth_entries_activated), self);
|
||||
|
||||
/* Translators: This is the printer name for which we are showing the active jobs */
|
||||
title = g_strdup_printf (C_("Printer jobs dialog title", "%s — Active Jobs"), printer_name);
|
||||
gtk_window_set_title (GTK_WINDOW (dialog->dialog), title);
|
||||
gtk_window_set_title (GTK_WINDOW (self->dialog), title);
|
||||
g_free (title);
|
||||
|
||||
/* Translators: The printer needs authentication info to print. */
|
||||
text = g_strdup_printf (_("Enter credentials to print from %s."), printer_name);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (dialog->builder), "authentication-label"));
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (self->builder), "authentication-label"));
|
||||
gtk_label_set_text (GTK_LABEL (widget), text);
|
||||
g_free (text);
|
||||
|
||||
dialog->listbox = GTK_LIST_BOX (gtk_builder_get_object (dialog->builder, "jobs-listbox"));
|
||||
gtk_list_box_set_header_func (dialog->listbox,
|
||||
self->listbox = GTK_LIST_BOX (gtk_builder_get_object (self->builder, "jobs-listbox"));
|
||||
gtk_list_box_set_header_func (self->listbox,
|
||||
cc_list_box_update_header_func, NULL, NULL);
|
||||
dialog->store = g_list_store_new (pp_job_get_type ());
|
||||
gtk_list_box_bind_model (dialog->listbox, G_LIST_MODEL (dialog->store),
|
||||
self->store = g_list_store_new (pp_job_get_type ());
|
||||
gtk_list_box_bind_model (self->listbox, G_LIST_MODEL (self->store),
|
||||
create_listbox_row, NULL, NULL);
|
||||
|
||||
update_jobs_list (dialog);
|
||||
update_jobs_list (self);
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (parent));
|
||||
gtk_window_present (GTK_WINDOW (dialog->dialog));
|
||||
gtk_widget_show_all (GTK_WIDGET (dialog->dialog));
|
||||
gtk_window_set_transient_for (GTK_WINDOW (self->dialog), GTK_WINDOW (parent));
|
||||
gtk_window_present (GTK_WINDOW (self->dialog));
|
||||
gtk_widget_show_all (GTK_WIDGET (self->dialog));
|
||||
|
||||
return dialog;
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
pp_jobs_dialog_update (PpJobsDialog *dialog)
|
||||
pp_jobs_dialog_update (PpJobsDialog *self)
|
||||
{
|
||||
update_jobs_list (dialog);
|
||||
update_jobs_list (self);
|
||||
}
|
||||
|
||||
void
|
||||
pp_jobs_dialog_set_callback (PpJobsDialog *dialog,
|
||||
pp_jobs_dialog_set_callback (PpJobsDialog *self,
|
||||
UserResponseCallback user_callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (dialog != NULL)
|
||||
{
|
||||
dialog->user_callback = user_callback;
|
||||
dialog->user_data = user_data;
|
||||
}
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
self->user_callback = user_callback;
|
||||
self->user_data = user_data;
|
||||
}
|
||||
|
||||
void
|
||||
pp_jobs_dialog_free (PpJobsDialog *dialog)
|
||||
pp_jobs_dialog_free (PpJobsDialog *self)
|
||||
{
|
||||
g_cancellable_cancel (dialog->get_jobs_cancellable);
|
||||
g_clear_object (&dialog->get_jobs_cancellable);
|
||||
g_cancellable_cancel (self->get_jobs_cancellable);
|
||||
g_clear_object (&self->get_jobs_cancellable);
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
|
||||
dialog->dialog = NULL;
|
||||
gtk_widget_destroy (GTK_WIDGET (self->dialog));
|
||||
self->dialog = NULL;
|
||||
|
||||
g_strfreev (dialog->actual_auth_info_required);
|
||||
g_strfreev (self->actual_auth_info_required);
|
||||
|
||||
g_clear_object (&dialog->builder);
|
||||
g_free (dialog->printer_name);
|
||||
g_free (dialog);
|
||||
g_clear_object (&self->builder);
|
||||
g_free (self->printer_name);
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
static void
|
||||
pp_jobs_dialog_hide (PpJobsDialog *dialog)
|
||||
pp_jobs_dialog_hide (PpJobsDialog *self)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (dialog->dialog));
|
||||
gtk_widget_hide (GTK_WIDGET (self->dialog));
|
||||
}
|
||||
|
||||
void
|
||||
pp_jobs_dialog_authenticate_jobs (PpJobsDialog *dialog)
|
||||
pp_jobs_dialog_authenticate_jobs (PpJobsDialog *self)
|
||||
{
|
||||
if (dialog->jobs_filled)
|
||||
pop_up_authentication_popup (dialog);
|
||||
if (self->jobs_filled)
|
||||
pop_up_authentication_popup (self);
|
||||
else
|
||||
dialog->pop_up_authentication_popup = TRUE;
|
||||
self->pop_up_authentication_popup = TRUE;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ pp_maintenance_command_class_init (PpMaintenanceCommandClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_maintenance_command_init (PpMaintenanceCommand *command)
|
||||
pp_maintenance_command_init (PpMaintenanceCommand *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -198,11 +198,11 @@ _pp_maintenance_command_execute_thread (GTask *task,
|
|||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
PpMaintenanceCommand *command = PP_MAINTENANCE_COMMAND (source_object);
|
||||
PpMaintenanceCommand *self = PP_MAINTENANCE_COMMAND (source_object);
|
||||
gboolean success = FALSE;
|
||||
GError *error = NULL;
|
||||
|
||||
if (_pp_maintenance_command_is_supported (command->printer_name, command->command))
|
||||
if (_pp_maintenance_command_is_supported (self->printer_name, self->command))
|
||||
{
|
||||
ipp_t *request;
|
||||
ipp_t *response = NULL;
|
||||
|
@ -211,14 +211,14 @@ _pp_maintenance_command_execute_thread (GTask *task,
|
|||
int fd = -1;
|
||||
|
||||
printer_uri = g_strdup_printf ("ipp://localhost/printers/%s",
|
||||
command->printer_name);
|
||||
self->printer_name);
|
||||
|
||||
request = ippNewRequest (IPP_PRINT_JOB);
|
||||
|
||||
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
|
||||
"printer-uri", NULL, printer_uri);
|
||||
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
|
||||
"job-name", NULL, command->title);
|
||||
"job-name", NULL, self->title);
|
||||
ippAddString (request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
|
||||
"document-format", NULL, "application/vnd.cups-command");
|
||||
|
||||
|
@ -230,9 +230,9 @@ _pp_maintenance_command_execute_thread (GTask *task,
|
|||
|
||||
file = fdopen (fd, "w");
|
||||
fprintf (file, "#CUPS-COMMAND\n");
|
||||
fprintf (file, "%s", command->command);
|
||||
if (command->parameters)
|
||||
fprintf (file, " %s", command->parameters);
|
||||
fprintf (file, "%s", self->command);
|
||||
if (self->parameters)
|
||||
fprintf (file, " %s", self->parameters);
|
||||
fprintf (file, "\n");
|
||||
fclose (file);
|
||||
|
||||
|
@ -270,14 +270,14 @@ _pp_maintenance_command_execute_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_maintenance_command_execute_async (PpMaintenanceCommand *command,
|
||||
pp_maintenance_command_execute_async (PpMaintenanceCommand *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (command, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, TRUE);
|
||||
g_task_run_in_thread (task, _pp_maintenance_command_execute_thread);
|
||||
|
||||
|
@ -285,11 +285,11 @@ pp_maintenance_command_execute_async (PpMaintenanceCommand *command,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_maintenance_command_execute_finish (PpMaintenanceCommand *command,
|
||||
pp_maintenance_command_execute_finish (PpMaintenanceCommand *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, command), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
@ -368,22 +368,22 @@ _pp_maintenance_command_is_supported_thread (GTask *task,
|
|||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
PpMaintenanceCommand *command = PP_MAINTENANCE_COMMAND (source_object);
|
||||
PpMaintenanceCommand *self = PP_MAINTENANCE_COMMAND (source_object);
|
||||
gboolean success = FALSE;
|
||||
|
||||
success = _pp_maintenance_command_is_supported (command->printer_name, command->command);
|
||||
success = _pp_maintenance_command_is_supported (self->printer_name, self->command);
|
||||
g_task_return_boolean (task, success);
|
||||
}
|
||||
|
||||
void
|
||||
pp_maintenance_command_is_supported_async (PpMaintenanceCommand *command,
|
||||
pp_maintenance_command_is_supported_async (PpMaintenanceCommand *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (command, cancellable, callback, user_data);
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, TRUE);
|
||||
g_task_run_in_thread (task, _pp_maintenance_command_is_supported_thread);
|
||||
|
||||
|
@ -391,11 +391,11 @@ pp_maintenance_command_is_supported_async (PpMaintenanceCommand *command,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_maintenance_command_is_supported_finish (PpMaintenanceCommand *command,
|
||||
pp_maintenance_command_is_supported_finish (PpMaintenanceCommand *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, command), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -114,9 +114,7 @@ pp_new_printer_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *param_spec)
|
||||
{
|
||||
PpNewPrinter *self;
|
||||
|
||||
self = PP_NEW_PRINTER (object);
|
||||
PpNewPrinter *self = PP_NEW_PRINTER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
|
@ -337,7 +335,7 @@ pp_new_printer_class_init (PpNewPrinterClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_new_printer_init (PpNewPrinter *printer)
|
||||
pp_new_printer_init (PpNewPrinter *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -347,29 +345,29 @@ pp_new_printer_new ()
|
|||
return g_object_new (PP_TYPE_NEW_PRINTER, NULL);
|
||||
}
|
||||
|
||||
static void printer_configure_async (PpNewPrinter *new_printer);
|
||||
static void printer_configure_async (PpNewPrinter *self);
|
||||
|
||||
static void
|
||||
_pp_new_printer_add_async_cb (gboolean success,
|
||||
PpNewPrinter *printer)
|
||||
PpNewPrinter *self)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
g_task_return_new_error (printer->task,
|
||||
g_task_return_new_error (self->task,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
"Installation of the new printer failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
g_task_return_boolean (printer->task, success);
|
||||
g_task_return_boolean (self->task, success);
|
||||
}
|
||||
|
||||
static void
|
||||
printer_add_real_async_cb (cups_dest_t *destination,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpNewPrinter *printer = (PpNewPrinter *) user_data;
|
||||
PpNewPrinter *self = user_data;
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (destination)
|
||||
|
@ -380,11 +378,11 @@ printer_add_real_async_cb (cups_dest_t *destination,
|
|||
|
||||
if (success)
|
||||
{
|
||||
printer_configure_async (printer);
|
||||
printer_configure_async (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +391,7 @@ printer_add_real_async_dbus_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpNewPrinter *printer = (PpNewPrinter *) user_data;
|
||||
PpNewPrinter *self = user_data;
|
||||
GVariant *output;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
|
@ -409,7 +407,7 @@ printer_add_real_async_dbus_cb (GObject *source_object,
|
|||
g_variant_get (output, "(&s)", &ret_error);
|
||||
if (ret_error[0] != '\0')
|
||||
{
|
||||
g_warning ("cups-pk-helper: addition of printer %s failed: %s", printer->name, ret_error);
|
||||
g_warning ("cups-pk-helper: addition of printer %s failed: %s", self->name, ret_error);
|
||||
}
|
||||
|
||||
g_variant_unref (output);
|
||||
|
@ -422,21 +420,21 @@ printer_add_real_async_dbus_cb (GObject *source_object,
|
|||
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
get_named_dest_async (printer->name,
|
||||
get_named_dest_async (self->name,
|
||||
printer_add_real_async_cb,
|
||||
printer);
|
||||
self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printer_add_real_async (PpNewPrinter *printer)
|
||||
printer_add_real_async (PpNewPrinter *self)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!printer->ppd_name && !printer->ppd_file_name)
|
||||
if (!self->ppd_name && !self->ppd_file_name)
|
||||
{
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -444,7 +442,7 @@ printer_add_real_async (PpNewPrinter *printer)
|
|||
if (!bus)
|
||||
{
|
||||
g_warning ("Failed to get system bus: %s", error->message);
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -452,19 +450,19 @@ printer_add_real_async (PpNewPrinter *printer)
|
|||
MECHANISM_BUS,
|
||||
"/",
|
||||
MECHANISM_BUS,
|
||||
printer->ppd_name ? "PrinterAdd" : "PrinterAddWithPpdFile",
|
||||
self->ppd_name ? "PrinterAdd" : "PrinterAddWithPpdFile",
|
||||
g_variant_new ("(sssss)",
|
||||
printer->name,
|
||||
printer->device_uri,
|
||||
printer->ppd_name ? printer->ppd_name : printer->ppd_file_name,
|
||||
printer->info ? printer->info : "",
|
||||
printer->location ? printer->location : ""),
|
||||
self->name,
|
||||
self->device_uri,
|
||||
self->ppd_name ? self->ppd_name : self->ppd_file_name,
|
||||
self->info ? self->info : "",
|
||||
self->location ? self->location : ""),
|
||||
G_VARIANT_TYPE ("(s)"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
DBUS_TIMEOUT,
|
||||
NULL,
|
||||
printer_add_real_async_dbus_cb,
|
||||
printer);
|
||||
self);
|
||||
}
|
||||
|
||||
static PPDName *
|
||||
|
@ -532,7 +530,7 @@ printer_add_async_scb3 (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpNewPrinter *printer = (PpNewPrinter *) user_data;
|
||||
PpNewPrinter *self = user_data;
|
||||
GVariant *output;
|
||||
PPDName *ppd_item = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
@ -556,12 +554,12 @@ printer_add_async_scb3 (GObject *source_object,
|
|||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
|
||||
ppd_item && ppd_item->ppd_name)
|
||||
{
|
||||
printer->ppd_name = g_strdup (ppd_item->ppd_name);
|
||||
printer_add_real_async (printer);
|
||||
self->ppd_name = g_strdup (ppd_item->ppd_name);
|
||||
printer_add_real_async (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
|
||||
if (ppd_item)
|
||||
|
@ -576,7 +574,7 @@ install_printer_drivers_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpNewPrinter *printer;
|
||||
PpNewPrinter *self = user_data;
|
||||
GVariant *output;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
|
@ -600,8 +598,6 @@ install_printer_drivers_cb (GObject *source_object,
|
|||
GDBusConnection *bus;
|
||||
g_autoptr(GError) bus_error = NULL;
|
||||
|
||||
printer = (PpNewPrinter *) user_data;
|
||||
|
||||
/* Try whether CUPS has a driver for the new printer */
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &bus_error);
|
||||
if (bus)
|
||||
|
@ -612,20 +608,20 @@ install_printer_drivers_cb (GObject *source_object,
|
|||
SCP_IFACE,
|
||||
"GetBestDrivers",
|
||||
g_variant_new ("(sss)",
|
||||
printer->device_id,
|
||||
printer->make_and_model ? printer->make_and_model : "",
|
||||
printer->device_uri ? printer->device_uri : ""),
|
||||
self->device_id,
|
||||
self->make_and_model ? self->make_and_model : "",
|
||||
self->device_uri ? self->device_uri : ""),
|
||||
G_VARIANT_TYPE ("(a(ss))"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
DBUS_TIMEOUT_LONG,
|
||||
printer->cancellable,
|
||||
self->cancellable,
|
||||
printer_add_async_scb3,
|
||||
printer);
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Failed to get system bus: %s", bus_error->message);
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -635,7 +631,7 @@ printer_add_async_scb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpNewPrinter *printer = (PpNewPrinter *) user_data;
|
||||
PpNewPrinter *self = user_data;
|
||||
GDBusConnection *bus;
|
||||
GVariantBuilder array_builder;
|
||||
GVariant *output;
|
||||
|
@ -671,7 +667,7 @@ printer_add_async_scb (GObject *source_object,
|
|||
if (bus)
|
||||
{
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
|
||||
g_variant_builder_add (&array_builder, "s", printer->device_id);
|
||||
g_variant_builder_add (&array_builder, "s", self->device_id);
|
||||
|
||||
g_dbus_connection_call (bus,
|
||||
PACKAGE_KIT_BUS,
|
||||
|
@ -679,7 +675,7 @@ printer_add_async_scb (GObject *source_object,
|
|||
PACKAGE_KIT_MODIFY_IFACE,
|
||||
"InstallPrinterDrivers",
|
||||
g_variant_new ("(uass)",
|
||||
printer->window_id,
|
||||
self->window_id,
|
||||
&array_builder,
|
||||
"hide-finished"),
|
||||
G_VARIANT_TYPE ("()"),
|
||||
|
@ -687,22 +683,22 @@ printer_add_async_scb (GObject *source_object,
|
|||
DBUS_TIMEOUT_LONG,
|
||||
NULL,
|
||||
install_printer_drivers_cb,
|
||||
printer);
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Failed to get session bus: %s", bus_error->message);
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
else if (ppd_item && ppd_item->ppd_name)
|
||||
{
|
||||
printer->ppd_name = g_strdup (ppd_item->ppd_name);
|
||||
printer_add_real_async (printer);
|
||||
self->ppd_name = g_strdup (ppd_item->ppd_name);
|
||||
printer_add_real_async (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -717,17 +713,17 @@ static void
|
|||
printer_add_async_scb4 (const gchar *ppd_filename,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpNewPrinter *printer = (PpNewPrinter *) user_data;
|
||||
PpNewPrinter *self = user_data;
|
||||
|
||||
printer->ppd_file_name = g_strdup (ppd_filename);
|
||||
if (printer->ppd_file_name)
|
||||
self->ppd_file_name = g_strdup (ppd_filename);
|
||||
if (self->ppd_file_name)
|
||||
{
|
||||
printer->unlink_ppd_file = TRUE;
|
||||
printer_add_real_async (printer);
|
||||
self->unlink_ppd_file = TRUE;
|
||||
printer_add_real_async (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,11 +763,11 @@ typedef struct
|
|||
static void
|
||||
printer_configure_async_finish (PCData *data)
|
||||
{
|
||||
PpNewPrinter *printer = data->new_printer;
|
||||
PpNewPrinter *self = data->new_printer;
|
||||
|
||||
if (data->set_accept_jobs_finished &&
|
||||
data->set_enabled_finished &&
|
||||
(data->autoconfigure_finished || printer->is_network_device) &&
|
||||
(data->autoconfigure_finished || self->is_network_device) &&
|
||||
data->set_media_size_finished &&
|
||||
data->install_missing_executables_finished)
|
||||
{
|
||||
|
@ -1180,7 +1176,7 @@ pp_maintenance_command_execute_cb (GObject *source_object,
|
|||
}
|
||||
|
||||
static void
|
||||
printer_configure_async (PpNewPrinter *new_printer)
|
||||
printer_configure_async (PpNewPrinter *self)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
PCData *data;
|
||||
|
@ -1189,7 +1185,7 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
g_autoptr(GError) error = NULL;
|
||||
|
||||
data = g_new0 (PCData, 1);
|
||||
data->new_printer = new_printer;
|
||||
data->new_printer = self;
|
||||
data->set_accept_jobs_finished = FALSE;
|
||||
data->set_enabled_finished = FALSE;
|
||||
data->autoconfigure_finished = FALSE;
|
||||
|
@ -1197,7 +1193,7 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
data->install_missing_executables_finished = FALSE;
|
||||
|
||||
/* Enable printer and make it accept jobs */
|
||||
if (new_printer->name)
|
||||
if (self->name)
|
||||
{
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (bus)
|
||||
|
@ -1208,7 +1204,7 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
MECHANISM_BUS,
|
||||
"PrinterSetAcceptJobs",
|
||||
g_variant_new ("(sbs)",
|
||||
new_printer->name,
|
||||
self->name,
|
||||
TRUE,
|
||||
""),
|
||||
G_VARIANT_TYPE ("(s)"),
|
||||
|
@ -1224,7 +1220,7 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
MECHANISM_BUS,
|
||||
"PrinterSetEnabled",
|
||||
g_variant_new ("(sb)",
|
||||
new_printer->name,
|
||||
self->name,
|
||||
TRUE),
|
||||
G_VARIANT_TYPE ("(s)"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
|
@ -1247,10 +1243,10 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
}
|
||||
|
||||
/* Run autoconfiguration of printer */
|
||||
if (!new_printer->is_network_device)
|
||||
if (!self->is_network_device)
|
||||
{
|
||||
PpMaintenanceCommand *command;
|
||||
command = pp_maintenance_command_new (new_printer->name,
|
||||
command = pp_maintenance_command_new (self->name,
|
||||
"autoconfigure",
|
||||
NULL,
|
||||
/* Translators: Name of job which makes printer to autoconfigure itself */
|
||||
|
@ -1266,18 +1262,18 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
values = g_new0 (gchar *, 2);
|
||||
values[0] = g_strdup (get_page_size_from_locale ());
|
||||
|
||||
printer_add_option_async (new_printer->name, "PageSize", values, FALSE, NULL, pao_cb, data);
|
||||
printer_add_option_async (self->name, "PageSize", values, FALSE, NULL, pao_cb, data);
|
||||
|
||||
g_strfreev (values);
|
||||
|
||||
/* Install missing executables for printer */
|
||||
ime_data = g_new0 (IMEData, 1);
|
||||
ime_data->window_id = new_printer->window_id;
|
||||
ime_data->window_id = self->window_id;
|
||||
if (data->cancellable)
|
||||
ime_data->cancellable = g_object_ref (data->cancellable);
|
||||
ime_data->user_data = data;
|
||||
|
||||
printer_get_ppd_async (new_printer->name,
|
||||
printer_get_ppd_async (self->name,
|
||||
NULL,
|
||||
0,
|
||||
printer_get_ppd_cb,
|
||||
|
@ -1285,22 +1281,22 @@ printer_configure_async (PpNewPrinter *new_printer)
|
|||
}
|
||||
|
||||
void
|
||||
pp_new_printer_add_async (PpNewPrinter *printer,
|
||||
pp_new_printer_add_async (PpNewPrinter *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
printer->task = g_task_new (printer, cancellable, callback, user_data);
|
||||
printer->cancellable = g_object_ref (cancellable);
|
||||
self->task = g_task_new (self, cancellable, callback, user_data);
|
||||
self->cancellable = g_object_ref (cancellable);
|
||||
|
||||
if (printer->ppd_name || printer->ppd_file_name)
|
||||
if (self->ppd_name || self->ppd_file_name)
|
||||
{
|
||||
/* We have everything we need */
|
||||
printer_add_real_async (printer);
|
||||
printer_add_real_async (self);
|
||||
}
|
||||
else if (printer->device_id)
|
||||
else if (self->device_id)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
@ -1315,43 +1311,43 @@ pp_new_printer_add_async (PpNewPrinter *printer,
|
|||
SCP_IFACE,
|
||||
"GetBestDrivers",
|
||||
g_variant_new ("(sss)",
|
||||
printer->device_id,
|
||||
printer->make_and_model ? printer->make_and_model : "",
|
||||
printer->device_uri ? printer->device_uri : ""),
|
||||
self->device_id,
|
||||
self->make_and_model ? self->make_and_model : "",
|
||||
self->device_uri ? self->device_uri : ""),
|
||||
G_VARIANT_TYPE ("(a(ss))"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
DBUS_TIMEOUT_LONG,
|
||||
cancellable,
|
||||
printer_add_async_scb,
|
||||
printer);
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Failed to get system bus: %s", error->message);
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
else if (printer->original_name && printer->host_name)
|
||||
else if (self->original_name && self->host_name)
|
||||
{
|
||||
/* Try to get PPD from remote CUPS */
|
||||
printer_get_ppd_async (printer->original_name,
|
||||
printer->host_name,
|
||||
printer->host_port,
|
||||
printer_get_ppd_async (self->original_name,
|
||||
self->host_name,
|
||||
self->host_port,
|
||||
printer_add_async_scb4,
|
||||
printer);
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pp_new_printer_add_async_cb (FALSE, printer);
|
||||
_pp_new_printer_add_async_cb (FALSE, self);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
pp_new_printer_add_finish (PpNewPrinter *printer,
|
||||
pp_new_printer_add_finish (PpNewPrinter *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, printer), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ struct _PpOptionsDialog {
|
|||
gboolean sensitive;
|
||||
};
|
||||
|
||||
static void pp_options_dialog_hide (PpOptionsDialog *dialog);
|
||||
static void pp_options_dialog_hide (PpOptionsDialog *self);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ static void
|
|||
category_selection_changed_cb (GtkTreeSelection *selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpOptionsDialog *dialog = (PpOptionsDialog *) user_data;
|
||||
PpOptionsDialog *self = (PpOptionsDialog *) user_data;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *options_notebook;
|
||||
|
@ -483,14 +483,14 @@ category_selection_changed_cb (GtkTreeSelection *selection,
|
|||
if (id >= 0)
|
||||
{
|
||||
options_notebook = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "options-notebook");
|
||||
gtk_builder_get_object (self->builder, "options-notebook");
|
||||
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (options_notebook), id);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
populate_options_real (PpOptionsDialog *dialog)
|
||||
populate_options_real (PpOptionsDialog *self)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
|
@ -511,69 +511,69 @@ populate_options_real (PpOptionsDialog *dialog)
|
|||
gint i, j;
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "options-spinner");
|
||||
gtk_builder_get_object (self->builder, "options-spinner");
|
||||
gtk_spinner_stop (GTK_SPINNER (widget));
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "stack");
|
||||
gtk_builder_get_object (self->builder, "stack");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (widget), "main-box");
|
||||
|
||||
treeview = (GtkTreeView *)
|
||||
gtk_builder_get_object (dialog->builder, "options-categories-treeview");
|
||||
gtk_builder_get_object (self->builder, "options-categories-treeview");
|
||||
|
||||
notebook = (GtkWidget *)
|
||||
gtk_builder_get_object (dialog->builder, "options-notebook");
|
||||
gtk_builder_get_object (self->builder, "options-notebook");
|
||||
|
||||
if (dialog->ipp_attributes)
|
||||
if (self->ipp_attributes)
|
||||
{
|
||||
/* Add number-up option to Page Setup tab */
|
||||
ipp_option_add (g_hash_table_lookup (dialog->ipp_attributes,
|
||||
ipp_option_add (g_hash_table_lookup (self->ipp_attributes,
|
||||
"number-up-supported"),
|
||||
g_hash_table_lookup (dialog->ipp_attributes,
|
||||
g_hash_table_lookup (self->ipp_attributes,
|
||||
"number-up-default"),
|
||||
"number-up",
|
||||
/* Translators: This option sets number of pages printed on one sheet */
|
||||
_("Pages per side"),
|
||||
dialog->printer_name,
|
||||
self->printer_name,
|
||||
page_setup_tab_grid,
|
||||
dialog->sensitive);
|
||||
self->sensitive);
|
||||
|
||||
/* Add sides option to Page Setup tab */
|
||||
ipp_option_add (g_hash_table_lookup (dialog->ipp_attributes,
|
||||
ipp_option_add (g_hash_table_lookup (self->ipp_attributes,
|
||||
"sides-supported"),
|
||||
g_hash_table_lookup (dialog->ipp_attributes,
|
||||
g_hash_table_lookup (self->ipp_attributes,
|
||||
"sides-default"),
|
||||
"sides",
|
||||
/* Translators: This option sets whether to print on both sides of paper */
|
||||
_("Two-sided"),
|
||||
dialog->printer_name,
|
||||
self->printer_name,
|
||||
page_setup_tab_grid,
|
||||
dialog->sensitive);
|
||||
self->sensitive);
|
||||
|
||||
/* Add orientation-requested option to Page Setup tab */
|
||||
ipp_option_add (g_hash_table_lookup (dialog->ipp_attributes,
|
||||
ipp_option_add (g_hash_table_lookup (self->ipp_attributes,
|
||||
"orientation-requested-supported"),
|
||||
g_hash_table_lookup (dialog->ipp_attributes,
|
||||
g_hash_table_lookup (self->ipp_attributes,
|
||||
"orientation-requested-default"),
|
||||
"orientation-requested",
|
||||
/* Translators: This option sets orientation of print (portrait, landscape...) */
|
||||
_("Orientation"),
|
||||
dialog->printer_name,
|
||||
self->printer_name,
|
||||
page_setup_tab_grid,
|
||||
dialog->sensitive);
|
||||
self->sensitive);
|
||||
}
|
||||
|
||||
if (dialog->destination && dialog->ppd_filename)
|
||||
if (self->destination && self->ppd_filename)
|
||||
{
|
||||
ppd_file = ppdOpenFile (dialog->ppd_filename);
|
||||
ppd_file = ppdOpenFile (self->ppd_filename);
|
||||
ppdLocalize (ppd_file);
|
||||
|
||||
if (ppd_file)
|
||||
{
|
||||
ppdMarkDefaults (ppd_file);
|
||||
cupsMarkOptions (ppd_file,
|
||||
dialog->destination->num_options,
|
||||
dialog->destination->options);
|
||||
self->destination->num_options,
|
||||
self->destination->options);
|
||||
|
||||
for (i = 0; i < ppd_file->num_groups; i++)
|
||||
{
|
||||
|
@ -620,9 +620,9 @@ populate_options_real (PpOptionsDialog *dialog)
|
|||
grid = advanced_tab_grid;
|
||||
|
||||
ppd_option_add (ppd_file->groups[i].options[j],
|
||||
dialog->printer_name,
|
||||
self->printer_name,
|
||||
grid,
|
||||
dialog->sensitive);
|
||||
self->sensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -631,26 +631,26 @@ populate_options_real (PpOptionsDialog *dialog)
|
|||
}
|
||||
}
|
||||
|
||||
dialog->ppd_filename_set = FALSE;
|
||||
if (dialog->ppd_filename)
|
||||
self->ppd_filename_set = FALSE;
|
||||
if (self->ppd_filename)
|
||||
{
|
||||
g_unlink (dialog->ppd_filename);
|
||||
g_free (dialog->ppd_filename);
|
||||
dialog->ppd_filename = NULL;
|
||||
g_unlink (self->ppd_filename);
|
||||
g_free (self->ppd_filename);
|
||||
self->ppd_filename = NULL;
|
||||
}
|
||||
|
||||
dialog->destination_set = FALSE;
|
||||
if (dialog->destination)
|
||||
self->destination_set = FALSE;
|
||||
if (self->destination)
|
||||
{
|
||||
cupsFreeDests (1, dialog->destination);
|
||||
dialog->destination = NULL;
|
||||
cupsFreeDests (1, self->destination);
|
||||
self->destination = NULL;
|
||||
}
|
||||
|
||||
dialog->ipp_attributes_set = FALSE;
|
||||
if (dialog->ipp_attributes)
|
||||
self->ipp_attributes_set = FALSE;
|
||||
if (self->ipp_attributes)
|
||||
{
|
||||
g_hash_table_unref (dialog->ipp_attributes);
|
||||
dialog->ipp_attributes = NULL;
|
||||
g_hash_table_unref (self->ipp_attributes);
|
||||
self->ipp_attributes = NULL;
|
||||
}
|
||||
|
||||
/* Translators: "General" tab contains general printer options */
|
||||
|
@ -684,17 +684,17 @@ populate_options_real (PpOptionsDialog *dialog)
|
|||
{
|
||||
g_signal_connect (selection,
|
||||
"changed",
|
||||
G_CALLBACK (category_selection_changed_cb), dialog);
|
||||
G_CALLBACK (category_selection_changed_cb), self);
|
||||
|
||||
if ((model = gtk_tree_view_get_model (treeview)) != NULL &&
|
||||
gtk_tree_model_get_iter_first (model, &iter))
|
||||
gtk_tree_selection_select_iter (selection, &iter);
|
||||
}
|
||||
|
||||
dialog->populating_dialog = FALSE;
|
||||
if (dialog->response != GTK_RESPONSE_NONE)
|
||||
self->populating_dialog = FALSE;
|
||||
if (self->response != GTK_RESPONSE_NONE)
|
||||
{
|
||||
dialog->user_callback (GTK_DIALOG (dialog->dialog), dialog->response, dialog->user_data);
|
||||
self->user_callback (GTK_DIALOG (self->dialog), self->response, self->user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,21 +702,21 @@ static void
|
|||
printer_get_ppd_cb (const gchar *ppd_filename,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpOptionsDialog *dialog = (PpOptionsDialog *) user_data;
|
||||
PpOptionsDialog *self = (PpOptionsDialog *) user_data;
|
||||
|
||||
if (dialog->ppd_filename)
|
||||
if (self->ppd_filename)
|
||||
{
|
||||
g_unlink (dialog->ppd_filename);
|
||||
g_free (dialog->ppd_filename);
|
||||
g_unlink (self->ppd_filename);
|
||||
g_free (self->ppd_filename);
|
||||
}
|
||||
|
||||
dialog->ppd_filename = g_strdup (ppd_filename);
|
||||
dialog->ppd_filename_set = TRUE;
|
||||
self->ppd_filename = g_strdup (ppd_filename);
|
||||
self->ppd_filename_set = TRUE;
|
||||
|
||||
if (dialog->destination_set &&
|
||||
dialog->ipp_attributes_set)
|
||||
if (self->destination_set &&
|
||||
self->ipp_attributes_set)
|
||||
{
|
||||
populate_options_real (dialog);
|
||||
populate_options_real (self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -724,18 +724,18 @@ static void
|
|||
get_named_dest_cb (cups_dest_t *dest,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpOptionsDialog *dialog = (PpOptionsDialog *) user_data;
|
||||
PpOptionsDialog *self = (PpOptionsDialog *) user_data;
|
||||
|
||||
if (dialog->destination)
|
||||
cupsFreeDests (1, dialog->destination);
|
||||
if (self->destination)
|
||||
cupsFreeDests (1, self->destination);
|
||||
|
||||
dialog->destination = dest;
|
||||
dialog->destination_set = TRUE;
|
||||
self->destination = dest;
|
||||
self->destination_set = TRUE;
|
||||
|
||||
if (dialog->ppd_filename_set &&
|
||||
dialog->ipp_attributes_set)
|
||||
if (self->ppd_filename_set &&
|
||||
self->ipp_attributes_set)
|
||||
{
|
||||
populate_options_real (dialog);
|
||||
populate_options_real (self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,23 +743,23 @@ static void
|
|||
get_ipp_attributes_cb (GHashTable *table,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpOptionsDialog *dialog = (PpOptionsDialog *) user_data;
|
||||
PpOptionsDialog *self = (PpOptionsDialog *) user_data;
|
||||
|
||||
if (dialog->ipp_attributes)
|
||||
g_hash_table_unref (dialog->ipp_attributes);
|
||||
if (self->ipp_attributes)
|
||||
g_hash_table_unref (self->ipp_attributes);
|
||||
|
||||
dialog->ipp_attributes = table;
|
||||
dialog->ipp_attributes_set = TRUE;
|
||||
self->ipp_attributes = table;
|
||||
self->ipp_attributes_set = TRUE;
|
||||
|
||||
if (dialog->ppd_filename_set &&
|
||||
dialog->destination_set)
|
||||
if (self->ppd_filename_set &&
|
||||
self->destination_set)
|
||||
{
|
||||
populate_options_real (dialog);
|
||||
populate_options_real (self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
populate_options (PpOptionsDialog *dialog)
|
||||
populate_options (PpOptionsDialog *self)
|
||||
{
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
|
@ -781,11 +781,11 @@ populate_options (PpOptionsDialog *dialog)
|
|||
NULL};
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "stack");
|
||||
gtk_builder_get_object (self->builder, "stack");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (widget), "progress-box");
|
||||
|
||||
treeview = (GtkTreeView *)
|
||||
gtk_builder_get_object (dialog->builder, "options-categories-treeview");
|
||||
gtk_builder_get_object (self->builder, "options-categories-treeview");
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
|
||||
|
@ -795,23 +795,23 @@ populate_options (PpOptionsDialog *dialog)
|
|||
gtk_tree_view_append_column (treeview, column);
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "options-spinner");
|
||||
gtk_builder_get_object (self->builder, "options-spinner");
|
||||
gtk_spinner_start (GTK_SPINNER (widget));
|
||||
|
||||
printer_get_ppd_async (dialog->printer_name,
|
||||
printer_get_ppd_async (self->printer_name,
|
||||
NULL,
|
||||
0,
|
||||
printer_get_ppd_cb,
|
||||
dialog);
|
||||
self);
|
||||
|
||||
get_named_dest_async (dialog->printer_name,
|
||||
get_named_dest_async (self->printer_name,
|
||||
get_named_dest_cb,
|
||||
dialog);
|
||||
self);
|
||||
|
||||
get_ipp_attributes_async (dialog->printer_name,
|
||||
get_ipp_attributes_async (self->printer_name,
|
||||
(gchar **) attributes,
|
||||
get_ipp_attributes_cb,
|
||||
dialog);
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -862,10 +862,10 @@ static void
|
|||
test_page_cb (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpOptionsDialog *dialog = (PpOptionsDialog*) user_data;
|
||||
PpOptionsDialog *self = (PpOptionsDialog*) user_data;
|
||||
gint i;
|
||||
|
||||
if (dialog->printer_name)
|
||||
if (self->printer_name)
|
||||
{
|
||||
const gchar *const dirs[] = { "/usr/share/cups",
|
||||
"/usr/local/share/cups",
|
||||
|
@ -888,7 +888,7 @@ test_page_cb (GtkButton *button,
|
|||
{
|
||||
PpPrinter *printer;
|
||||
|
||||
printer = pp_printer_new (dialog->printer_name);
|
||||
printer = pp_printer_new (self->printer_name);
|
||||
pp_printer_print_file_async (printer,
|
||||
filename,
|
||||
/* Translators: Name of job which makes printer to print test page */
|
||||
|
@ -903,7 +903,7 @@ test_page_cb (GtkButton *button,
|
|||
{
|
||||
PpMaintenanceCommand *command;
|
||||
|
||||
command = pp_maintenance_command_new (dialog->printer_name,
|
||||
command = pp_maintenance_command_new (self->printer_name,
|
||||
"PrintSelfTestPage",
|
||||
NULL,
|
||||
/* Translators: Name of job which makes printer to print test page */
|
||||
|
@ -919,13 +919,13 @@ options_dialog_response_cb (GtkDialog *_dialog,
|
|||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpOptionsDialog *dialog = (PpOptionsDialog*) user_data;
|
||||
PpOptionsDialog *self = (PpOptionsDialog*) user_data;
|
||||
|
||||
pp_options_dialog_hide (dialog);
|
||||
dialog->response = response_id;
|
||||
pp_options_dialog_hide (self);
|
||||
self->response = response_id;
|
||||
|
||||
if (!dialog->populating_dialog)
|
||||
dialog->user_callback (GTK_DIALOG (dialog->dialog), response_id, dialog->user_data);
|
||||
if (!self->populating_dialog)
|
||||
self->user_callback (GTK_DIALOG (self->dialog), response_id, self->user_data);
|
||||
}
|
||||
|
||||
PpOptionsDialog *
|
||||
|
@ -935,18 +935,18 @@ pp_options_dialog_new (GtkWindow *parent,
|
|||
gchar *printer_name,
|
||||
gboolean sensitive)
|
||||
{
|
||||
PpOptionsDialog *dialog;
|
||||
PpOptionsDialog *self;
|
||||
GtkWidget *test_page_button;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gchar *objects[] = { "options-dialog", NULL };
|
||||
guint builder_result;
|
||||
|
||||
dialog = g_new0 (PpOptionsDialog, 1);
|
||||
self = g_new0 (PpOptionsDialog, 1);
|
||||
|
||||
dialog->builder = gtk_builder_new ();
|
||||
dialog->parent = GTK_WIDGET (parent);
|
||||
self->builder = gtk_builder_new ();
|
||||
self->parent = GTK_WIDGET (parent);
|
||||
|
||||
builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
|
||||
builder_result = gtk_builder_add_objects_from_resource (self->builder,
|
||||
"/org/gnome/control-center/printers/options-dialog.ui",
|
||||
objects, &error);
|
||||
|
||||
|
@ -956,90 +956,90 @@ pp_options_dialog_new (GtkWindow *parent,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
dialog->dialog = (GtkWidget *) gtk_builder_get_object (dialog->builder, "options-dialog");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (parent));
|
||||
self->dialog = (GtkWidget *) gtk_builder_get_object (self->builder, "options-dialog");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (self->dialog), GTK_WINDOW (parent));
|
||||
|
||||
dialog->user_callback = user_callback;
|
||||
dialog->user_data = user_data;
|
||||
self->user_callback = user_callback;
|
||||
self->user_data = user_data;
|
||||
|
||||
dialog->printer_name = g_strdup (printer_name);
|
||||
self->printer_name = g_strdup (printer_name);
|
||||
|
||||
dialog->ppd_filename = NULL;
|
||||
dialog->ppd_filename_set = FALSE;
|
||||
self->ppd_filename = NULL;
|
||||
self->ppd_filename_set = FALSE;
|
||||
|
||||
dialog->destination = NULL;
|
||||
dialog->destination_set = FALSE;
|
||||
self->destination = NULL;
|
||||
self->destination_set = FALSE;
|
||||
|
||||
dialog->ipp_attributes = NULL;
|
||||
dialog->ipp_attributes_set = FALSE;
|
||||
self->ipp_attributes = NULL;
|
||||
self->ipp_attributes_set = FALSE;
|
||||
|
||||
dialog->response = GTK_RESPONSE_NONE;
|
||||
self->response = GTK_RESPONSE_NONE;
|
||||
|
||||
dialog->sensitive = sensitive;
|
||||
self->sensitive = sensitive;
|
||||
|
||||
/* connect signals */
|
||||
g_signal_connect (dialog->dialog, "response", G_CALLBACK (options_dialog_response_cb), dialog);
|
||||
test_page_button = (GtkWidget*) gtk_builder_get_object (dialog->builder, "print-test-page");
|
||||
g_signal_connect (test_page_button, "clicked", G_CALLBACK (test_page_cb), dialog);
|
||||
g_signal_connect (self->dialog, "response", G_CALLBACK (options_dialog_response_cb), self);
|
||||
test_page_button = (GtkWidget*) gtk_builder_get_object (self->builder, "print-test-page");
|
||||
g_signal_connect (test_page_button, "clicked", G_CALLBACK (test_page_cb), self);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dialog->dialog), printer_name);
|
||||
gtk_window_set_title (GTK_WINDOW (self->dialog), printer_name);
|
||||
|
||||
gtk_widget_show_all (GTK_WIDGET (dialog->dialog));
|
||||
gtk_widget_show_all (GTK_WIDGET (self->dialog));
|
||||
|
||||
dialog->populating_dialog = TRUE;
|
||||
populate_options (dialog);
|
||||
self->populating_dialog = TRUE;
|
||||
populate_options (self);
|
||||
|
||||
return dialog;
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
pp_options_dialog_set_callback (PpOptionsDialog *dialog,
|
||||
pp_options_dialog_set_callback (PpOptionsDialog *self,
|
||||
UserResponseCallback user_callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (dialog != NULL)
|
||||
if (self != NULL)
|
||||
{
|
||||
dialog->user_callback = user_callback;
|
||||
dialog->user_data = user_data;
|
||||
self->user_callback = user_callback;
|
||||
self->user_data = user_data;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pp_options_dialog_free (PpOptionsDialog *dialog)
|
||||
pp_options_dialog_free (PpOptionsDialog *self)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
|
||||
dialog->dialog = NULL;
|
||||
gtk_widget_destroy (GTK_WIDGET (self->dialog));
|
||||
self->dialog = NULL;
|
||||
|
||||
g_object_unref (dialog->builder);
|
||||
dialog->builder = NULL;
|
||||
g_object_unref (self->builder);
|
||||
self->builder = NULL;
|
||||
|
||||
g_free (dialog->printer_name);
|
||||
dialog->printer_name = NULL;
|
||||
g_free (self->printer_name);
|
||||
self->printer_name = NULL;
|
||||
|
||||
if (dialog->ppd_filename)
|
||||
if (self->ppd_filename)
|
||||
{
|
||||
g_unlink (dialog->ppd_filename);
|
||||
g_free (dialog->ppd_filename);
|
||||
dialog->ppd_filename = NULL;
|
||||
g_unlink (self->ppd_filename);
|
||||
g_free (self->ppd_filename);
|
||||
self->ppd_filename = NULL;
|
||||
}
|
||||
|
||||
if (dialog->destination)
|
||||
if (self->destination)
|
||||
{
|
||||
cupsFreeDests (1, dialog->destination);
|
||||
dialog->destination = NULL;
|
||||
cupsFreeDests (1, self->destination);
|
||||
self->destination = NULL;
|
||||
}
|
||||
|
||||
if (dialog->ipp_attributes)
|
||||
if (self->ipp_attributes)
|
||||
{
|
||||
g_hash_table_unref (dialog->ipp_attributes);
|
||||
dialog->ipp_attributes = NULL;
|
||||
g_hash_table_unref (self->ipp_attributes);
|
||||
self->ipp_attributes = NULL;
|
||||
}
|
||||
|
||||
g_free (dialog);
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
static void
|
||||
pp_options_dialog_hide (PpOptionsDialog *dialog)
|
||||
pp_options_dialog_hide (PpOptionsDialog *self)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (dialog->dialog));
|
||||
gtk_widget_hide (GTK_WIDGET (self->dialog));
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
|
||||
static void pp_ppd_option_widget_finalize (GObject *object);
|
||||
|
||||
static gboolean construct_widget (PpPPDOptionWidget *widget);
|
||||
static void update_widget (PpPPDOptionWidget *widget);
|
||||
static void update_widget_real (PpPPDOptionWidget *widget);
|
||||
static gboolean construct_widget (PpPPDOptionWidget *self);
|
||||
static void update_widget (PpPPDOptionWidget *self);
|
||||
static void update_widget_real (PpPPDOptionWidget *self);
|
||||
|
||||
struct _PpPPDOptionWidget
|
||||
{
|
||||
|
@ -142,45 +142,45 @@ pp_ppd_option_widget_class_init (PpPPDOptionWidgetClass *class)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_ppd_option_widget_init (PpPPDOptionWidget *widget)
|
||||
pp_ppd_option_widget_init (PpPPDOptionWidget *self)
|
||||
{
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (widget),
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (self),
|
||||
GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
widget->switch_button = NULL;
|
||||
widget->combo = NULL;
|
||||
widget->image = NULL;
|
||||
widget->box = NULL;
|
||||
self->switch_button = NULL;
|
||||
self->combo = NULL;
|
||||
self->image = NULL;
|
||||
self->box = NULL;
|
||||
|
||||
widget->printer_name = NULL;
|
||||
widget->option_name = NULL;
|
||||
self->printer_name = NULL;
|
||||
self->option_name = NULL;
|
||||
|
||||
widget->destination = NULL;
|
||||
widget->destination_set = FALSE;
|
||||
self->destination = NULL;
|
||||
self->destination_set = FALSE;
|
||||
|
||||
widget->ppd_filename = NULL;
|
||||
widget->ppd_filename_set = FALSE;
|
||||
self->ppd_filename = NULL;
|
||||
self->ppd_filename_set = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
pp_ppd_option_widget_finalize (GObject *object)
|
||||
{
|
||||
PpPPDOptionWidget *widget = PP_PPD_OPTION_WIDGET (object);
|
||||
PpPPDOptionWidget *self = PP_PPD_OPTION_WIDGET (object);
|
||||
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
if (widget->ppd_filename)
|
||||
g_unlink (widget->ppd_filename);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
if (self->ppd_filename)
|
||||
g_unlink (self->ppd_filename);
|
||||
|
||||
g_clear_pointer (&widget->option, cups_option_free);
|
||||
g_clear_pointer (&widget->printer_name, g_free);
|
||||
g_clear_pointer (&widget->option_name, g_free);
|
||||
if (widget->destination)
|
||||
g_clear_pointer (&self->option, cups_option_free);
|
||||
g_clear_pointer (&self->printer_name, g_free);
|
||||
g_clear_pointer (&self->option_name, g_free);
|
||||
if (self->destination)
|
||||
{
|
||||
cupsFreeDests (1, widget->destination);
|
||||
widget->destination = NULL;
|
||||
cupsFreeDests (1, self->destination);
|
||||
self->destination = NULL;
|
||||
}
|
||||
g_clear_pointer (&widget->ppd_filename, g_free);
|
||||
g_clear_object (&widget->cancellable);
|
||||
g_clear_pointer (&self->ppd_filename, g_free);
|
||||
g_clear_object (&self->cancellable);
|
||||
|
||||
G_OBJECT_CLASS (pp_ppd_option_widget_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -205,29 +205,29 @@ GtkWidget *
|
|||
pp_ppd_option_widget_new (ppd_option_t *option,
|
||||
const gchar *printer_name)
|
||||
{
|
||||
PpPPDOptionWidget *widget = NULL;
|
||||
PpPPDOptionWidget *self = NULL;
|
||||
|
||||
if (option && printer_name)
|
||||
{
|
||||
widget = g_object_new (PP_TYPE_PPD_OPTION_WIDGET, NULL);
|
||||
self = g_object_new (PP_TYPE_PPD_OPTION_WIDGET, NULL);
|
||||
|
||||
widget->printer_name = g_strdup (printer_name);
|
||||
widget->option = cups_option_copy (option);
|
||||
widget->option_name = g_strdup (option->keyword);
|
||||
self->printer_name = g_strdup (printer_name);
|
||||
self->option = cups_option_copy (option);
|
||||
self->option_name = g_strdup (option->keyword);
|
||||
|
||||
if (construct_widget (widget))
|
||||
if (construct_widget (self))
|
||||
{
|
||||
update_widget_real (widget);
|
||||
update_widget_real (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_ref_sink (widget);
|
||||
g_object_unref (widget);
|
||||
widget = NULL;
|
||||
g_object_ref_sink (self);
|
||||
g_object_unref (self);
|
||||
self = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (GtkWidget *) widget;
|
||||
return (GtkWidget *) self;
|
||||
}
|
||||
|
||||
enum {
|
||||
|
@ -335,16 +335,16 @@ static void
|
|||
printer_add_option_async_cb (gboolean success,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDOptionWidget *widget = (PpPPDOptionWidget *) user_data;
|
||||
PpPPDOptionWidget *self = user_data;
|
||||
|
||||
update_widget (user_data);
|
||||
g_clear_object (&widget->cancellable);
|
||||
g_clear_object (&self->cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
switch_changed_cb (GtkWidget *switch_button,
|
||||
GParamSpec *pspec,
|
||||
PpPPDOptionWidget *widget)
|
||||
PpPPDOptionWidget *self)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
|
@ -355,104 +355,104 @@ switch_changed_cb (GtkWidget *switch_button,
|
|||
else
|
||||
values[0] = g_strdup ("False");
|
||||
|
||||
if (widget->cancellable)
|
||||
if (self->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
g_object_unref (widget->cancellable);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_object_unref (self->cancellable);
|
||||
}
|
||||
|
||||
widget->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (widget->printer_name,
|
||||
widget->option_name,
|
||||
self->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (self->printer_name,
|
||||
self->option_name,
|
||||
values,
|
||||
FALSE,
|
||||
widget->cancellable,
|
||||
self->cancellable,
|
||||
printer_add_option_async_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
g_strfreev (values);
|
||||
}
|
||||
|
||||
static void
|
||||
combo_changed_cb (GtkWidget *combo,
|
||||
PpPPDOptionWidget *widget)
|
||||
PpPPDOptionWidget *self)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
values = g_new0 (gchar *, 2);
|
||||
values[0] = combo_box_get (combo);
|
||||
|
||||
if (widget->cancellable)
|
||||
if (self->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (widget->cancellable);
|
||||
g_object_unref (widget->cancellable);
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_object_unref (self->cancellable);
|
||||
}
|
||||
|
||||
widget->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (widget->printer_name,
|
||||
widget->option_name,
|
||||
self->cancellable = g_cancellable_new ();
|
||||
printer_add_option_async (self->printer_name,
|
||||
self->option_name,
|
||||
values,
|
||||
FALSE,
|
||||
widget->cancellable,
|
||||
self->cancellable,
|
||||
printer_add_option_async_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
g_strfreev (values);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
construct_widget (PpPPDOptionWidget *widget)
|
||||
construct_widget (PpPPDOptionWidget *self)
|
||||
{
|
||||
gint i;
|
||||
|
||||
/* Don't show options which has only one choice */
|
||||
if (widget->option && widget->option->num_choices > 1)
|
||||
if (self->option && self->option->num_choices > 1)
|
||||
{
|
||||
switch (widget->option->ui)
|
||||
switch (self->option->ui)
|
||||
{
|
||||
case PPD_UI_BOOLEAN:
|
||||
widget->switch_button = gtk_switch_new ();
|
||||
g_signal_connect (widget->switch_button, "notify::active", G_CALLBACK (switch_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->switch_button, FALSE, FALSE, 0);
|
||||
self->switch_button = gtk_switch_new ();
|
||||
g_signal_connect (self->switch_button, "notify::active", G_CALLBACK (switch_changed_cb), self);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->switch_button, FALSE, FALSE, 0);
|
||||
break;
|
||||
|
||||
case PPD_UI_PICKONE:
|
||||
widget->combo = combo_box_new ();
|
||||
self->combo = combo_box_new ();
|
||||
|
||||
for (i = 0; i < widget->option->num_choices; i++)
|
||||
for (i = 0; i < self->option->num_choices; i++)
|
||||
{
|
||||
combo_box_append (widget->combo,
|
||||
ppd_choice_translate (&widget->option->choices[i]),
|
||||
widget->option->choices[i].choice);
|
||||
combo_box_append (self->combo,
|
||||
ppd_choice_translate (&self->option->choices[i]),
|
||||
self->option->choices[i].choice);
|
||||
}
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->combo, FALSE, FALSE, 0);
|
||||
g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->combo, FALSE, FALSE, 0);
|
||||
g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
|
||||
break;
|
||||
|
||||
case PPD_UI_PICKMANY:
|
||||
widget->combo = combo_box_new ();
|
||||
self->combo = combo_box_new ();
|
||||
|
||||
for (i = 0; i < widget->option->num_choices; i++)
|
||||
for (i = 0; i < self->option->num_choices; i++)
|
||||
{
|
||||
combo_box_append (widget->combo,
|
||||
ppd_choice_translate (&widget->option->choices[i]),
|
||||
widget->option->choices[i].choice);
|
||||
combo_box_append (self->combo,
|
||||
ppd_choice_translate (&self->option->choices[i]),
|
||||
self->option->choices[i].choice);
|
||||
}
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->combo, TRUE, TRUE, 0);
|
||||
g_signal_connect (widget->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->combo, TRUE, TRUE, 0);
|
||||
g_signal_connect (self->combo, "changed", G_CALLBACK (combo_changed_cb), self);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
widget->image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_MENU);
|
||||
if (!widget->image)
|
||||
widget->image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_MENU);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->image, FALSE, FALSE, 0);
|
||||
gtk_widget_set_no_show_all (GTK_WIDGET (widget->image), TRUE);
|
||||
self->image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_MENU);
|
||||
if (!self->image)
|
||||
self->image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_MENU);
|
||||
gtk_box_pack_start (GTK_BOX (self), self->image, FALSE, FALSE, 0);
|
||||
gtk_widget_set_no_show_all (GTK_WIDGET (self->image), TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -463,22 +463,22 @@ construct_widget (PpPPDOptionWidget *widget)
|
|||
}
|
||||
|
||||
static void
|
||||
update_widget_real (PpPPDOptionWidget *widget)
|
||||
update_widget_real (PpPPDOptionWidget *self)
|
||||
{
|
||||
ppd_option_t *option = NULL, *iter;
|
||||
ppd_file_t *ppd_file;
|
||||
gchar *value = NULL;
|
||||
gint i;
|
||||
|
||||
if (widget->option)
|
||||
if (self->option)
|
||||
{
|
||||
option = cups_option_copy (widget->option);
|
||||
cups_option_free (widget->option);
|
||||
widget->option = NULL;
|
||||
option = cups_option_copy (self->option);
|
||||
cups_option_free (self->option);
|
||||
self->option = NULL;
|
||||
}
|
||||
else if (widget->ppd_filename)
|
||||
else if (self->ppd_filename)
|
||||
{
|
||||
ppd_file = ppdOpenFile (widget->ppd_filename);
|
||||
ppd_file = ppdOpenFile (self->ppd_filename);
|
||||
ppdLocalize (ppd_file);
|
||||
|
||||
if (ppd_file)
|
||||
|
@ -487,7 +487,7 @@ update_widget_real (PpPPDOptionWidget *widget)
|
|||
|
||||
for (iter = ppdFirstOption(ppd_file); iter; iter = ppdNextOption(ppd_file))
|
||||
{
|
||||
if (g_str_equal (iter->keyword, widget->option_name))
|
||||
if (g_str_equal (iter->keyword, self->option_name))
|
||||
{
|
||||
option = cups_option_copy (iter);
|
||||
break;
|
||||
|
@ -497,9 +497,9 @@ update_widget_real (PpPPDOptionWidget *widget)
|
|||
ppdClose (ppd_file);
|
||||
}
|
||||
|
||||
g_unlink (widget->ppd_filename);
|
||||
g_free (widget->ppd_filename);
|
||||
widget->ppd_filename = NULL;
|
||||
g_unlink (self->ppd_filename);
|
||||
g_free (self->ppd_filename);
|
||||
self->ppd_filename = NULL;
|
||||
}
|
||||
|
||||
if (option)
|
||||
|
@ -516,24 +516,24 @@ update_widget_real (PpPPDOptionWidget *widget)
|
|||
switch (option->ui)
|
||||
{
|
||||
case PPD_UI_BOOLEAN:
|
||||
g_signal_handlers_block_by_func (widget->switch_button, switch_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->switch_button, switch_changed_cb, self);
|
||||
if (g_ascii_strcasecmp (value, "True") == 0)
|
||||
gtk_switch_set_active (GTK_SWITCH (widget->switch_button), TRUE);
|
||||
gtk_switch_set_active (GTK_SWITCH (self->switch_button), TRUE);
|
||||
else
|
||||
gtk_switch_set_active (GTK_SWITCH (widget->switch_button), FALSE);
|
||||
g_signal_handlers_unblock_by_func (widget->switch_button, switch_changed_cb, widget);
|
||||
gtk_switch_set_active (GTK_SWITCH (self->switch_button), FALSE);
|
||||
g_signal_handlers_unblock_by_func (self->switch_button, switch_changed_cb, self);
|
||||
break;
|
||||
|
||||
case PPD_UI_PICKONE:
|
||||
g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
|
||||
combo_box_set (widget->combo, value);
|
||||
g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->combo, combo_changed_cb, self);
|
||||
combo_box_set (self->combo, value);
|
||||
g_signal_handlers_unblock_by_func (self->combo, combo_changed_cb, self);
|
||||
break;
|
||||
|
||||
case PPD_UI_PICKMANY:
|
||||
g_signal_handlers_block_by_func (widget->combo, combo_changed_cb, widget);
|
||||
combo_box_set (widget->combo, value);
|
||||
g_signal_handlers_unblock_by_func (widget->combo, combo_changed_cb, widget);
|
||||
g_signal_handlers_block_by_func (self->combo, combo_changed_cb, self);
|
||||
combo_box_set (self->combo, value);
|
||||
g_signal_handlers_unblock_by_func (self->combo, combo_changed_cb, self);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -544,9 +544,9 @@ update_widget_real (PpPPDOptionWidget *widget)
|
|||
}
|
||||
|
||||
if (option->conflicted)
|
||||
gtk_widget_show (widget->image);
|
||||
gtk_widget_show (self->image);
|
||||
else
|
||||
gtk_widget_hide (widget->image);
|
||||
gtk_widget_hide (self->image);
|
||||
}
|
||||
|
||||
cups_option_free (option);
|
||||
|
@ -556,17 +556,17 @@ static void
|
|||
get_named_dest_cb (cups_dest_t *dest,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDOptionWidget *widget = (PpPPDOptionWidget *) user_data;
|
||||
PpPPDOptionWidget *self = user_data;
|
||||
|
||||
if (widget->destination)
|
||||
cupsFreeDests (1, widget->destination);
|
||||
if (self->destination)
|
||||
cupsFreeDests (1, self->destination);
|
||||
|
||||
widget->destination = dest;
|
||||
widget->destination_set = TRUE;
|
||||
self->destination = dest;
|
||||
self->destination_set = TRUE;
|
||||
|
||||
if (widget->ppd_filename_set)
|
||||
if (self->ppd_filename_set)
|
||||
{
|
||||
update_widget_real (widget);
|
||||
update_widget_real (self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,36 +574,36 @@ static void
|
|||
printer_get_ppd_cb (const gchar *ppd_filename,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDOptionWidget *widget = (PpPPDOptionWidget *) user_data;
|
||||
PpPPDOptionWidget *self = user_data;
|
||||
|
||||
if (widget->ppd_filename)
|
||||
if (self->ppd_filename)
|
||||
{
|
||||
g_unlink (widget->ppd_filename);
|
||||
g_free (widget->ppd_filename);
|
||||
g_unlink (self->ppd_filename);
|
||||
g_free (self->ppd_filename);
|
||||
}
|
||||
|
||||
widget->ppd_filename = g_strdup (ppd_filename);
|
||||
widget->ppd_filename_set = TRUE;
|
||||
self->ppd_filename = g_strdup (ppd_filename);
|
||||
self->ppd_filename_set = TRUE;
|
||||
|
||||
if (widget->destination_set)
|
||||
if (self->destination_set)
|
||||
{
|
||||
update_widget_real (widget);
|
||||
update_widget_real (self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_widget (PpPPDOptionWidget *widget)
|
||||
update_widget (PpPPDOptionWidget *self)
|
||||
{
|
||||
widget->ppd_filename_set = FALSE;
|
||||
widget->destination_set = FALSE;
|
||||
self->ppd_filename_set = FALSE;
|
||||
self->destination_set = FALSE;
|
||||
|
||||
get_named_dest_async (widget->printer_name,
|
||||
get_named_dest_async (self->printer_name,
|
||||
get_named_dest_cb,
|
||||
widget);
|
||||
self);
|
||||
|
||||
printer_get_ppd_async (widget->printer_name,
|
||||
printer_get_ppd_async (self->printer_name,
|
||||
NULL,
|
||||
0,
|
||||
printer_get_ppd_cb,
|
||||
widget);
|
||||
self);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ static void
|
|||
manufacturer_selection_changed_cb (GtkTreeSelection *selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDSelectionDialog *dialog = (PpPPDSelectionDialog *) user_data;
|
||||
PpPPDSelectionDialog *self = user_data;
|
||||
GtkListStore *store;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
@ -88,10 +88,10 @@ manufacturer_selection_changed_cb (GtkTreeSelection *selection,
|
|||
if (manufacturer_name)
|
||||
{
|
||||
index = -1;
|
||||
for (i = 0; i < dialog->list->num_of_manufacturers; i++)
|
||||
for (i = 0; i < self->list->num_of_manufacturers; i++)
|
||||
{
|
||||
if (g_strcmp0 (manufacturer_name,
|
||||
dialog->list->manufacturers[i]->manufacturer_name) == 0)
|
||||
self->list->manufacturers[i]->manufacturer_name) == 0)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
|
@ -101,16 +101,16 @@ manufacturer_selection_changed_cb (GtkTreeSelection *selection,
|
|||
if (index >= 0)
|
||||
{
|
||||
models_treeview = (GtkTreeView*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-selection-models-treeview");
|
||||
gtk_builder_get_object (self->builder, "ppd-selection-models-treeview");
|
||||
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
for (i = 0; i < dialog->list->manufacturers[index]->num_of_ppds; i++)
|
||||
for (i = 0; i < self->list->manufacturers[index]->num_of_ppds; i++)
|
||||
{
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
PPD_NAMES_COLUMN, dialog->list->manufacturers[index]->ppds[i]->ppd_name,
|
||||
PPD_DISPLAY_NAMES_COLUMN, dialog->list->manufacturers[index]->ppds[i]->ppd_display_name,
|
||||
PPD_NAMES_COLUMN, self->list->manufacturers[index]->ppds[i]->ppd_name,
|
||||
PPD_DISPLAY_NAMES_COLUMN, self->list->manufacturers[index]->ppds[i]->ppd_display_name,
|
||||
-1);
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ static void
|
|||
model_selection_changed_cb (GtkTreeSelection *selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDSelectionDialog *dialog = (PpPPDSelectionDialog *) user_data;
|
||||
PpPPDSelectionDialog *self = user_data;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *widget;
|
||||
|
@ -141,7 +141,7 @@ model_selection_changed_cb (GtkTreeSelection *selection,
|
|||
}
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-selection-select-button");
|
||||
gtk_builder_get_object (self->builder, "ppd-selection-select-button");
|
||||
|
||||
if (model_name)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ model_selection_changed_cb (GtkTreeSelection *selection,
|
|||
}
|
||||
|
||||
static void
|
||||
fill_ppds_list (PpPPDSelectionDialog *dialog)
|
||||
fill_ppds_list (PpPPDSelectionDialog *self)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkListStore *store;
|
||||
|
@ -167,31 +167,31 @@ fill_ppds_list (PpPPDSelectionDialog *dialog)
|
|||
gint i;
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-spinner");
|
||||
gtk_builder_get_object (self->builder, "ppd-spinner");
|
||||
gtk_widget_hide (widget);
|
||||
gtk_spinner_stop (GTK_SPINNER (widget));
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "progress-label");
|
||||
gtk_builder_get_object (self->builder, "progress-label");
|
||||
gtk_widget_hide (widget);
|
||||
|
||||
treeview = (GtkTreeView*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-selection-manufacturers-treeview");
|
||||
gtk_builder_get_object (self->builder, "ppd-selection-manufacturers-treeview");
|
||||
|
||||
if (dialog->list)
|
||||
if (self->list)
|
||||
{
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
for (i = 0; i < dialog->list->num_of_manufacturers; i++)
|
||||
for (i = 0; i < self->list->num_of_manufacturers; i++)
|
||||
{
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
PPD_MANUFACTURERS_NAMES_COLUMN, dialog->list->manufacturers[i]->manufacturer_name,
|
||||
PPD_MANUFACTURERS_DISPLAY_NAMES_COLUMN, dialog->list->manufacturers[i]->manufacturer_display_name,
|
||||
PPD_MANUFACTURERS_NAMES_COLUMN, self->list->manufacturers[i]->manufacturer_name,
|
||||
PPD_MANUFACTURERS_DISPLAY_NAMES_COLUMN, self->list->manufacturers[i]->manufacturer_display_name,
|
||||
-1);
|
||||
|
||||
if (g_strcmp0 (dialog->manufacturer,
|
||||
dialog->list->manufacturers[i]->manufacturer_display_name) == 0)
|
||||
if (g_strcmp0 (self->manufacturer,
|
||||
self->list->manufacturers[i]->manufacturer_display_name) == 0)
|
||||
{
|
||||
preselect_iter = gtk_tree_iter_copy (&iter);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ fill_ppds_list (PpPPDSelectionDialog *dialog)
|
|||
}
|
||||
|
||||
static void
|
||||
populate_dialog (PpPPDSelectionDialog *dialog)
|
||||
populate_dialog (PpPPDSelectionDialog *self)
|
||||
{
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
|
@ -224,7 +224,7 @@ populate_dialog (PpPPDSelectionDialog *dialog)
|
|||
GtkWidget *header;
|
||||
|
||||
manufacturers_treeview = (GtkTreeView*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-selection-manufacturers-treeview");
|
||||
gtk_builder_get_object (self->builder, "ppd-selection-manufacturers-treeview");
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_renderer_set_padding (renderer, 10, 0);
|
||||
|
@ -241,7 +241,7 @@ populate_dialog (PpPPDSelectionDialog *dialog)
|
|||
|
||||
|
||||
models_treeview = (GtkTreeView*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-selection-models-treeview");
|
||||
gtk_builder_get_object (self->builder, "ppd-selection-models-treeview");
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_renderer_set_padding (renderer, 10, 0);
|
||||
|
@ -259,27 +259,27 @@ populate_dialog (PpPPDSelectionDialog *dialog)
|
|||
|
||||
|
||||
g_signal_connect (gtk_tree_view_get_selection (models_treeview),
|
||||
"changed", G_CALLBACK (model_selection_changed_cb), dialog);
|
||||
"changed", G_CALLBACK (model_selection_changed_cb), self);
|
||||
|
||||
g_signal_connect (gtk_tree_view_get_selection (manufacturers_treeview),
|
||||
"changed", G_CALLBACK (manufacturer_selection_changed_cb), dialog);
|
||||
"changed", G_CALLBACK (manufacturer_selection_changed_cb), self);
|
||||
|
||||
gtk_widget_show_all (dialog->dialog);
|
||||
gtk_widget_show_all (self->dialog);
|
||||
|
||||
if (!dialog->list)
|
||||
if (!self->list)
|
||||
{
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-spinner");
|
||||
gtk_builder_get_object (self->builder, "ppd-spinner");
|
||||
gtk_widget_show (widget);
|
||||
gtk_spinner_start (GTK_SPINNER (widget));
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "progress-label");
|
||||
gtk_builder_get_object (self->builder, "progress-label");
|
||||
gtk_widget_show (widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
fill_ppds_list (dialog);
|
||||
fill_ppds_list (self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,19 +288,19 @@ ppd_selection_dialog_response_cb (GtkDialog *dialog,
|
|||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDSelectionDialog *ppd_selection_dialog = (PpPPDSelectionDialog*) user_data;
|
||||
PpPPDSelectionDialog *self = user_data;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeView *models_treeview;
|
||||
GtkTreeIter iter;
|
||||
|
||||
pp_ppd_selection_dialog_hide (ppd_selection_dialog);
|
||||
pp_ppd_selection_dialog_hide (self);
|
||||
|
||||
ppd_selection_dialog->response = response_id;
|
||||
self->response = response_id;
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
models_treeview = (GtkTreeView*)
|
||||
gtk_builder_get_object (ppd_selection_dialog->builder, "ppd-selection-models-treeview");
|
||||
gtk_builder_get_object (self->builder, "ppd-selection-models-treeview");
|
||||
|
||||
if (models_treeview)
|
||||
{
|
||||
|
@ -311,17 +311,15 @@ ppd_selection_dialog_response_cb (GtkDialog *dialog,
|
|||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
{
|
||||
gtk_tree_model_get (model, &iter,
|
||||
PPD_NAMES_COLUMN, &ppd_selection_dialog->ppd_name,
|
||||
PPD_DISPLAY_NAMES_COLUMN, &ppd_selection_dialog->ppd_display_name,
|
||||
PPD_NAMES_COLUMN, &self->ppd_name,
|
||||
PPD_DISPLAY_NAMES_COLUMN, &self->ppd_display_name,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ppd_selection_dialog->user_callback (GTK_DIALOG (ppd_selection_dialog->dialog),
|
||||
response_id,
|
||||
ppd_selection_dialog->user_data);
|
||||
self->user_callback (GTK_DIALOG (self->dialog), response_id, self->user_data);
|
||||
}
|
||||
|
||||
PpPPDSelectionDialog *
|
||||
|
@ -331,18 +329,18 @@ pp_ppd_selection_dialog_new (GtkWindow *parent,
|
|||
UserResponseCallback user_callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPPDSelectionDialog *dialog;
|
||||
PpPPDSelectionDialog *self;
|
||||
GtkWidget *widget;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gchar *objects[] = { "ppd-selection-dialog", NULL };
|
||||
guint builder_result;
|
||||
|
||||
dialog = g_new0 (PpPPDSelectionDialog, 1);
|
||||
self = g_new0 (PpPPDSelectionDialog, 1);
|
||||
|
||||
dialog->builder = gtk_builder_new ();
|
||||
dialog->parent = GTK_WIDGET (parent);
|
||||
self->builder = gtk_builder_new ();
|
||||
self->parent = GTK_WIDGET (parent);
|
||||
|
||||
builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
|
||||
builder_result = gtk_builder_add_objects_from_resource (self->builder,
|
||||
"/org/gnome/control-center/printers/ppd-selection-dialog.ui",
|
||||
objects, &error);
|
||||
|
||||
|
@ -352,71 +350,71 @@ pp_ppd_selection_dialog_new (GtkWindow *parent,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
dialog->dialog = (GtkWidget *) gtk_builder_get_object (dialog->builder, "ppd-selection-dialog");
|
||||
dialog->user_callback = user_callback;
|
||||
dialog->user_data = user_data;
|
||||
self->dialog = (GtkWidget *) gtk_builder_get_object (self->builder, "ppd-selection-dialog");
|
||||
self->user_callback = user_callback;
|
||||
self->user_data = user_data;
|
||||
|
||||
dialog->response = GTK_RESPONSE_NONE;
|
||||
dialog->list = ppd_list_copy (ppd_list);
|
||||
self->response = GTK_RESPONSE_NONE;
|
||||
self->list = ppd_list_copy (ppd_list);
|
||||
|
||||
dialog->manufacturer = get_standard_manufacturers_name (manufacturer);
|
||||
self->manufacturer = get_standard_manufacturers_name (manufacturer);
|
||||
|
||||
/* connect signals */
|
||||
g_signal_connect (dialog->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
g_signal_connect (dialog->dialog, "response", G_CALLBACK (ppd_selection_dialog_response_cb), dialog);
|
||||
g_signal_connect (self->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
g_signal_connect (self->dialog, "response", G_CALLBACK (ppd_selection_dialog_response_cb), self);
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (parent));
|
||||
gtk_window_set_transient_for (GTK_WINDOW (self->dialog), GTK_WINDOW (parent));
|
||||
|
||||
widget = (GtkWidget*)
|
||||
gtk_builder_get_object (dialog->builder, "ppd-spinner");
|
||||
gtk_builder_get_object (self->builder, "ppd-spinner");
|
||||
gtk_spinner_start (GTK_SPINNER (widget));
|
||||
|
||||
populate_dialog (dialog);
|
||||
populate_dialog (self);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog->dialog));
|
||||
gtk_widget_show_all (GTK_WIDGET (dialog->dialog));
|
||||
gtk_window_present (GTK_WINDOW (self->dialog));
|
||||
gtk_widget_show_all (GTK_WIDGET (self->dialog));
|
||||
|
||||
return dialog;
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
pp_ppd_selection_dialog_free (PpPPDSelectionDialog *dialog)
|
||||
pp_ppd_selection_dialog_free (PpPPDSelectionDialog *self)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
|
||||
gtk_widget_destroy (GTK_WIDGET (self->dialog));
|
||||
|
||||
g_object_unref (dialog->builder);
|
||||
g_object_unref (self->builder);
|
||||
|
||||
g_free (dialog->ppd_name);
|
||||
g_free (self->ppd_name);
|
||||
|
||||
g_free (dialog->ppd_display_name);
|
||||
g_free (self->ppd_display_name);
|
||||
|
||||
g_free (dialog->manufacturer);
|
||||
g_free (self->manufacturer);
|
||||
|
||||
g_free (dialog);
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_ppd_selection_dialog_get_ppd_name (PpPPDSelectionDialog *dialog)
|
||||
pp_ppd_selection_dialog_get_ppd_name (PpPPDSelectionDialog *self)
|
||||
{
|
||||
return g_strdup (dialog->ppd_name);
|
||||
return g_strdup (self->ppd_name);
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_ppd_selection_dialog_get_ppd_display_name (PpPPDSelectionDialog *dialog)
|
||||
pp_ppd_selection_dialog_get_ppd_display_name (PpPPDSelectionDialog *self)
|
||||
{
|
||||
return g_strdup (dialog->ppd_display_name);
|
||||
return g_strdup (self->ppd_display_name);
|
||||
}
|
||||
|
||||
void
|
||||
pp_ppd_selection_dialog_set_ppd_list (PpPPDSelectionDialog *dialog,
|
||||
pp_ppd_selection_dialog_set_ppd_list (PpPPDSelectionDialog *self,
|
||||
PPDList *list)
|
||||
{
|
||||
dialog->list = list;
|
||||
fill_ppds_list (dialog);
|
||||
self->list = list;
|
||||
fill_ppds_list (self);
|
||||
}
|
||||
|
||||
static void
|
||||
pp_ppd_selection_dialog_hide (PpPPDSelectionDialog *dialog)
|
||||
pp_ppd_selection_dialog_hide (PpPPDSelectionDialog *self)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (dialog->dialog));
|
||||
gtk_widget_hide (GTK_WIDGET (self->dialog));
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ pp_print_device_class_init (PpPrintDeviceClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_print_device_init (PpPrintDevice *printer)
|
||||
pp_print_device_init (PpPrintDevice *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -345,106 +345,106 @@ pp_print_device_new ()
|
|||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_name (PpPrintDevice *device)
|
||||
pp_print_device_get_device_name (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_name;
|
||||
return self->device_name;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_display_name (PpPrintDevice *device)
|
||||
pp_print_device_get_display_name (PpPrintDevice *self)
|
||||
{
|
||||
return device->display_name;
|
||||
return self->display_name;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_original_name (PpPrintDevice *device)
|
||||
pp_print_device_get_device_original_name (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_original_name;
|
||||
return self->device_original_name;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_make_and_model (PpPrintDevice *device)
|
||||
pp_print_device_get_device_make_and_model (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_make_and_model;
|
||||
return self->device_make_and_model;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_location (PpPrintDevice *device)
|
||||
pp_print_device_get_device_location (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_location;
|
||||
return self->device_location;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_info (PpPrintDevice *device)
|
||||
pp_print_device_get_device_info (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_info;
|
||||
return self->device_info;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_uri (PpPrintDevice *device)
|
||||
pp_print_device_get_device_uri (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_uri;
|
||||
return self->device_uri;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_id (PpPrintDevice *device)
|
||||
pp_print_device_get_device_id (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_id;
|
||||
return self->device_id;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_device_ppd (PpPrintDevice *device)
|
||||
pp_print_device_get_device_ppd (PpPrintDevice *self)
|
||||
{
|
||||
return device->device_ppd;
|
||||
return self->device_ppd;
|
||||
}
|
||||
|
||||
gchar *
|
||||
pp_print_device_get_host_name (PpPrintDevice *device)
|
||||
pp_print_device_get_host_name (PpPrintDevice *self)
|
||||
{
|
||||
return device->host_name;
|
||||
return self->host_name;
|
||||
}
|
||||
|
||||
gint
|
||||
pp_print_device_get_host_port (PpPrintDevice *device)
|
||||
pp_print_device_get_host_port (PpPrintDevice *self)
|
||||
{
|
||||
return device->host_port;
|
||||
return self->host_port;
|
||||
}
|
||||
|
||||
gboolean
|
||||
pp_print_device_is_authenticated_server (PpPrintDevice *device)
|
||||
pp_print_device_is_authenticated_server (PpPrintDevice *self)
|
||||
{
|
||||
return device->is_authenticated_server;
|
||||
return self->is_authenticated_server;
|
||||
}
|
||||
|
||||
gint
|
||||
pp_print_device_get_acquisition_method (PpPrintDevice *device)
|
||||
pp_print_device_get_acquisition_method (PpPrintDevice *self)
|
||||
{
|
||||
return device->acquisition_method;
|
||||
return self->acquisition_method;
|
||||
}
|
||||
|
||||
gboolean
|
||||
pp_print_device_is_network_device (PpPrintDevice *device)
|
||||
pp_print_device_is_network_device (PpPrintDevice *self)
|
||||
{
|
||||
return device->is_network_device;
|
||||
return self->is_network_device;
|
||||
}
|
||||
|
||||
PpPrintDevice *
|
||||
pp_print_device_copy (PpPrintDevice *device)
|
||||
pp_print_device_copy (PpPrintDevice *self)
|
||||
{
|
||||
return g_object_new (PP_TYPE_PRINT_DEVICE,
|
||||
"device-name", pp_print_device_get_device_name (device),
|
||||
"display-name", pp_print_device_get_display_name (device),
|
||||
"device-original-name", pp_print_device_get_device_original_name (device),
|
||||
"device-make-and-model", pp_print_device_get_device_make_and_model (device),
|
||||
"device-location", pp_print_device_get_device_location (device),
|
||||
"device-info", pp_print_device_get_device_info (device),
|
||||
"device-uri", pp_print_device_get_device_uri (device),
|
||||
"device-id", pp_print_device_get_device_id (device),
|
||||
"device-ppd", pp_print_device_get_device_ppd (device),
|
||||
"host-name", pp_print_device_get_host_name (device),
|
||||
"host-port", pp_print_device_get_host_port (device),
|
||||
"is-authenticated-server", pp_print_device_is_authenticated_server (device),
|
||||
"acquisition-method", pp_print_device_get_acquisition_method (device),
|
||||
"is-network-device", pp_print_device_is_network_device (device),
|
||||
"device-name", pp_print_device_get_device_name (self),
|
||||
"display-name", pp_print_device_get_display_name (self),
|
||||
"device-original-name", pp_print_device_get_device_original_name (self),
|
||||
"device-make-and-model", pp_print_device_get_device_make_and_model (self),
|
||||
"device-location", pp_print_device_get_device_location (self),
|
||||
"device-info", pp_print_device_get_device_info (self),
|
||||
"device-uri", pp_print_device_get_device_uri (self),
|
||||
"device-id", pp_print_device_get_device_id (self),
|
||||
"device-ppd", pp_print_device_get_device_ppd (self),
|
||||
"host-name", pp_print_device_get_host_name (self),
|
||||
"host-port", pp_print_device_get_host_port (self),
|
||||
"is-authenticated-server", pp_print_device_is_authenticated_server (self),
|
||||
"acquisition-method", pp_print_device_get_acquisition_method (self),
|
||||
"is-network-device", pp_print_device_is_network_device (self),
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -414,7 +414,7 @@ printer_renamed_cb (PpDetailsDialog *dialog,
|
|||
gchar *new_name,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinterEntry *self = PP_PRINTER_ENTRY (user_data);
|
||||
PpPrinterEntry *self = user_data;
|
||||
|
||||
g_signal_emit_by_name (self, "printer-renamed", new_name);
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ details_dialog_cb (GtkDialog *dialog,
|
|||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinterEntry *self = PP_PRINTER_ENTRY (user_data);
|
||||
PpPrinterEntry *self = user_data;
|
||||
|
||||
pp_details_dialog_free (self->pp_details_dialog);
|
||||
self->pp_details_dialog = NULL;
|
||||
|
@ -462,7 +462,7 @@ printer_options_dialog_cb (GtkDialog *dialog,
|
|||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinterEntry *self = PP_PRINTER_ENTRY (user_data);
|
||||
PpPrinterEntry *self = user_data;
|
||||
|
||||
if (self->pp_options_dialog != NULL)
|
||||
{
|
||||
|
@ -505,6 +505,7 @@ check_clean_heads_maintenance_command_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinterEntry *self = user_data;
|
||||
PpMaintenanceCommand *command = (PpMaintenanceCommand *) source_object;
|
||||
gboolean is_supported = FALSE;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
@ -518,7 +519,6 @@ check_clean_heads_maintenance_command_cb (GObject *source_object,
|
|||
|
||||
if (is_supported)
|
||||
{
|
||||
PpPrinterEntry *self = PP_PRINTER_ENTRY (user_data);
|
||||
gtk_widget_show (GTK_WIDGET (self->clean_heads_menuitem));
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ clean_heads_maintenance_command_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinterEntry *self = PP_PRINTER_ENTRY (user_data);
|
||||
PpPrinterEntry *self = user_data;
|
||||
PpMaintenanceCommand *command = (PpMaintenanceCommand *) source_object;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
|
@ -583,7 +583,7 @@ get_jobs_cb (GObject *source_object,
|
|||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinterEntry *self;
|
||||
PpPrinterEntry *self = user_data;
|
||||
PpPrinter *printer = PP_PRINTER (source_object);
|
||||
g_autoptr(GError) error = NULL;
|
||||
GList *jobs;
|
||||
|
@ -617,8 +617,6 @@ get_jobs_cb (GObject *source_object,
|
|||
button_label = g_strdup_printf (ngettext ("%u Job", "%u Jobs", num_jobs), num_jobs);
|
||||
}
|
||||
|
||||
self = PP_PRINTER_ENTRY (user_data);
|
||||
|
||||
gtk_button_set_label (GTK_BUTTON (self->show_jobs_dialog_button), button_label);
|
||||
gtk_widget_set_sensitive (self->show_jobs_dialog_button, num_jobs > 0);
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ pp_printer_class_init (PpPrinterClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
pp_printer_init (PpPrinter *printer)
|
||||
pp_printer_init (PpPrinter *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -133,18 +133,18 @@ printer_rename_thread (GTask *task,
|
|||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
PpPrinter *printer = PP_PRINTER (source_object);
|
||||
PpPrinter *self = PP_PRINTER (source_object);
|
||||
gboolean result;
|
||||
gchar *new_printer_name = task_data;
|
||||
gchar *old_printer_name;
|
||||
|
||||
g_object_get (printer, "printer-name", &old_printer_name, NULL);
|
||||
g_object_get (self, "printer-name", &old_printer_name, NULL);
|
||||
|
||||
result = printer_rename (old_printer_name, new_printer_name);
|
||||
|
||||
if (result)
|
||||
{
|
||||
g_object_set (printer, "printer-name", new_printer_name, NULL);
|
||||
g_object_set (self, "printer-name", new_printer_name, NULL);
|
||||
}
|
||||
|
||||
g_free (old_printer_name);
|
||||
|
@ -157,7 +157,7 @@ printer_rename_dbus_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpPrinter *printer;
|
||||
PpPrinter *self;
|
||||
GVariant *output;
|
||||
gboolean result = FALSE;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
@ -173,8 +173,8 @@ printer_rename_dbus_cb (GObject *source_object,
|
|||
{
|
||||
const gchar *ret_error;
|
||||
|
||||
printer = g_task_get_source_object (task);
|
||||
g_object_get (printer, "printer-name", &old_printer_name, NULL);
|
||||
self = g_task_get_source_object (task);
|
||||
g_object_get (self, "printer-name", &old_printer_name, NULL);
|
||||
|
||||
g_variant_get (output, "(&s)", &ret_error);
|
||||
if (ret_error[0] != '\0')
|
||||
|
@ -184,7 +184,7 @@ printer_rename_dbus_cb (GObject *source_object,
|
|||
else
|
||||
{
|
||||
result = TRUE;
|
||||
g_object_set (printer, "printer-name", g_task_get_task_data (task), NULL);
|
||||
g_object_set (self, "printer-name", g_task_get_task_data (task), NULL);
|
||||
}
|
||||
|
||||
g_task_return_boolean (task, result);
|
||||
|
@ -250,7 +250,7 @@ get_bus_cb (GObject *source_object,
|
|||
}
|
||||
|
||||
void
|
||||
pp_printer_rename_async (PpPrinter *printer,
|
||||
pp_printer_rename_async (PpPrinter *self,
|
||||
const gchar *new_printer_name,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
@ -260,7 +260,7 @@ pp_printer_rename_async (PpPrinter *printer,
|
|||
|
||||
g_return_if_fail (new_printer_name != NULL);
|
||||
|
||||
task = g_task_new (G_OBJECT (printer), cancellable, callback, user_data);
|
||||
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, g_strdup (new_printer_name), g_free);
|
||||
|
||||
g_bus_get (G_BUS_TYPE_SYSTEM,
|
||||
|
@ -270,11 +270,11 @@ pp_printer_rename_async (PpPrinter *printer,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_printer_rename_finish (PpPrinter *printer,
|
||||
pp_printer_rename_finish (PpPrinter *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, printer), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
||||
g_object_unref (res);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
|
@ -296,7 +296,7 @@ get_jobs_thread (GTask *task,
|
|||
static gchar *printer_attributes[] = { "auth-info-required" };
|
||||
GetJobsData *get_jobs_data = task_data;
|
||||
cups_job_t *jobs = NULL;
|
||||
PpPrinter *printer = PP_PRINTER (source_object);
|
||||
PpPrinter *self = PP_PRINTER (source_object);
|
||||
gboolean auth_info_is_required;
|
||||
PpJob *job;
|
||||
ipp_t *job_request;
|
||||
|
@ -311,7 +311,7 @@ get_jobs_thread (GTask *task,
|
|||
gint num_jobs;
|
||||
gint i, j;
|
||||
|
||||
g_object_get (printer, "printer-name", &printer_name, NULL);
|
||||
g_object_get (self, "printer-name", &printer_name, NULL);
|
||||
|
||||
num_jobs = cupsGetJobs (&jobs,
|
||||
printer_name,
|
||||
|
@ -398,7 +398,7 @@ get_jobs_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_printer_get_jobs_async (PpPrinter *printer,
|
||||
pp_printer_get_jobs_async (PpPrinter *self,
|
||||
gboolean myjobs,
|
||||
gint which_jobs,
|
||||
GCancellable *cancellable,
|
||||
|
@ -412,7 +412,7 @@ pp_printer_get_jobs_async (PpPrinter *printer,
|
|||
get_jobs_data->myjobs = myjobs;
|
||||
get_jobs_data->which_jobs = which_jobs;
|
||||
|
||||
task = g_task_new (G_OBJECT (printer), cancellable, callback, user_data);
|
||||
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, get_jobs_data, g_free);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread (task, get_jobs_thread);
|
||||
|
@ -420,11 +420,11 @@ pp_printer_get_jobs_async (PpPrinter *printer,
|
|||
}
|
||||
|
||||
GList *
|
||||
pp_printer_get_jobs_finish (PpPrinter *printer,
|
||||
pp_printer_get_jobs_finish (PpPrinter *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, printer), NULL);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -510,14 +510,14 @@ pp_printer_delete_cb (GObject *source_object,
|
|||
}
|
||||
|
||||
void
|
||||
pp_printer_delete_async (PpPrinter *printer,
|
||||
pp_printer_delete_async (PpPrinter *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (G_OBJECT (printer), cancellable, callback, user_data);
|
||||
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
|
||||
|
||||
g_bus_get (G_BUS_TYPE_SYSTEM,
|
||||
cancellable,
|
||||
|
@ -526,11 +526,11 @@ pp_printer_delete_async (PpPrinter *printer,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_printer_delete_finish (PpPrinter *printer,
|
||||
pp_printer_delete_finish (PpPrinter *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, printer), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
@ -556,11 +556,11 @@ print_file_thread (GTask *task,
|
|||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
PpPrinter *self = PP_PRINTER (source_object);
|
||||
PrintFileData *print_file_data;
|
||||
cups_ptype_t type = 0;
|
||||
cups_dest_t *dest = NULL;
|
||||
const gchar *printer_type = NULL;
|
||||
PpPrinter *printer;
|
||||
gboolean ret = FALSE;
|
||||
gchar *printer_name = NULL;
|
||||
gchar *printer_uri = NULL;
|
||||
|
@ -568,9 +568,7 @@ print_file_thread (GTask *task,
|
|||
ipp_t *response = NULL;
|
||||
ipp_t *request;
|
||||
|
||||
printer = PP_PRINTER (source_object);
|
||||
|
||||
g_object_get (printer, "printer-name", &printer_name, NULL);
|
||||
g_object_get (self, "printer-name", &printer_name, NULL);
|
||||
dest = cupsGetNamedDest (CUPS_HTTP_DEFAULT, printer_name, NULL);
|
||||
if (dest != NULL)
|
||||
{
|
||||
|
@ -626,7 +624,7 @@ print_file_thread (GTask *task,
|
|||
}
|
||||
|
||||
void
|
||||
pp_printer_print_file_async (PpPrinter *printer,
|
||||
pp_printer_print_file_async (PpPrinter *self,
|
||||
const gchar *filename,
|
||||
const gchar *job_name,
|
||||
GCancellable *cancellable,
|
||||
|
@ -640,7 +638,7 @@ pp_printer_print_file_async (PpPrinter *printer,
|
|||
print_file_data->filename = g_strdup (filename);
|
||||
print_file_data->job_name = g_strdup (job_name);
|
||||
|
||||
task = g_task_new (G_OBJECT (printer), cancellable, callback, user_data);
|
||||
task = g_task_new (G_OBJECT (self), cancellable, callback, user_data);
|
||||
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_set_task_data (task, print_file_data, (GDestroyNotify) print_file_data_free);
|
||||
|
@ -650,11 +648,11 @@ pp_printer_print_file_async (PpPrinter *printer,
|
|||
}
|
||||
|
||||
gboolean
|
||||
pp_printer_print_file_finish (PpPrinter *printer,
|
||||
pp_printer_print_file_finish (PpPrinter *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (res, printer), FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue