~ubuntu-branches/ubuntu/trusty/unity-control-center/trusty

« back to all changes in this revision

Viewing changes to panels/printers/pp-ipp-option-widget.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-01-08 16:29:18 UTC
  • Revision ID: package-import@ubuntu.com-20140108162918-g29dd08tr913y2qh
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
2
 *
 
3
 * Copyright 2012  Red Hat, Inc,
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 *
 
19
 * Author: Marek Kasik <mkasik@redhat.com>
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
#include <stdlib.h>
 
24
#include <string.h>
 
25
#include <stdio.h>
 
26
#include <ctype.h>
 
27
#include <glib/gi18n-lib.h>
 
28
 
 
29
#include "pp-ipp-option-widget.h"
 
30
#include "pp-utils.h"
 
31
 
 
32
#define PP_IPP_OPTION_WIDGET_GET_PRIVATE(o)  \
 
33
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), PP_TYPE_IPP_OPTION_WIDGET, PpIPPOptionWidgetPrivate))
 
34
 
 
35
static void pp_ipp_option_widget_finalize (GObject *object);
 
36
 
 
37
static gboolean construct_widget   (PpIPPOptionWidget *widget);
 
38
static void     update_widget      (PpIPPOptionWidget *widget);
 
39
static void     update_widget_real (PpIPPOptionWidget *widget);
 
40
 
 
41
struct PpIPPOptionWidgetPrivate
 
42
{
 
43
  GtkWidget *switch_button;
 
44
  GtkWidget *spin_button;
 
45
  GtkWidget *combo;
 
46
  GtkWidget *box;
 
47
 
 
48
  IPPAttribute *option_supported;
 
49
  IPPAttribute *option_default;
 
50
 
 
51
  gchar *printer_name;
 
52
  gchar *option_name;
 
53
 
 
54
  GHashTable *ipp_attribute;
 
55
};
 
56
 
 
57
G_DEFINE_TYPE (PpIPPOptionWidget, pp_ipp_option_widget, GTK_TYPE_HBOX)
 
58
 
 
59
static const struct {
 
60
  const char *keyword;
 
61
  const char *choice;
 
62
  const char *translation;
 
63
} ipp_choice_translations[] = {
 
64
  /* Translators: this is an option of "Two Sided" */
 
65
  { "sides", "one-sided", N_("One Sided") },
 
66
  /* Translators: this is an option of "Two Sided" */
 
67
  { "sides", "two-sided-long-edge", N_("Long Edge (Standard)") },
 
68
  /* Translators: this is an option of "Two Sided" */
 
69
  { "sides", "two-sided-short-edge", N_("Short Edge (Flip)") },
 
70
  /* Translators: this is an option of "Orientation" */
 
71
  { "orientation-requested", "3", N_("Portrait") },
 
72
  /* Translators: this is an option of "Orientation" */
 
73
  { "orientation-requested", "4", N_("Landscape") },
 
74
  /* Translators: this is an option of "Orientation" */
 
75
  { "orientation-requested", "5", N_("Reverse landscape") },
 
76
  /* Translators: this is an option of "Orientation" */
 
77
  { "orientation-requested", "6", N_("Reverse portrait") },
 
78
};
 
79
 
 
80
static const gchar *
 
81
ipp_choice_translate (const gchar *option,
 
82
                      const gchar *choice)
 
83
{
 
84
  gint i;
 
85
 
 
86
  for (i = 0; i < G_N_ELEMENTS (ipp_choice_translations); i++)
 
87
    {
 
88
      if (g_strcmp0 (ipp_choice_translations[i].keyword, option) == 0 &&
 
89
          g_strcmp0 (ipp_choice_translations[i].choice, choice) == 0)
 
90
        return _(ipp_choice_translations[i].translation);
 
91
    }
 
92
 
 
93
  return choice;
 
94
}
 
95
 
 
96
static void
 
97
pp_ipp_option_widget_class_init (PpIPPOptionWidgetClass *class)
 
98
{
 
99
  GObjectClass *object_class;
 
100
 
 
101
  object_class = G_OBJECT_CLASS (class);
 
102
 
 
103
  object_class->finalize = pp_ipp_option_widget_finalize;
 
104
 
 
105
  g_type_class_add_private (class, sizeof (PpIPPOptionWidgetPrivate));
 
106
}
 
107
 
 
108
static void
 
109
pp_ipp_option_widget_init (PpIPPOptionWidget *widget)
 
110
{
 
111
  PpIPPOptionWidgetPrivate *priv;
 
112
 
 
113
  priv = widget->priv = PP_IPP_OPTION_WIDGET_GET_PRIVATE (widget);
 
114
 
 
115
  priv->switch_button = NULL;
 
116
  priv->spin_button = NULL;
 
117
  priv->combo = NULL;
 
118
  priv->box = NULL;
 
119
 
 
120
  priv->printer_name = NULL;
 
121
  priv->option_name = NULL;
 
122
 
 
123
  priv->option_supported = NULL;
 
124
  priv->option_default = NULL;
 
125
 
 
126
  priv->ipp_attribute = NULL;
 
127
}
 
128
 
 
129
static void
 
130
pp_ipp_option_widget_finalize (GObject *object)
 
131
{
 
132
  PpIPPOptionWidget *widget = PP_IPP_OPTION_WIDGET (object);
 
133
  PpIPPOptionWidgetPrivate *priv = widget->priv;
 
134
 
 
135
  if (priv)
 
136
    {
 
137
      if (priv->option_name)
 
138
        {
 
139
          g_free (priv->option_name);
 
140
          priv->option_name = NULL;
 
141
        }
 
142
 
 
143
      if (priv->printer_name)
 
144
        {
 
145
          g_free (priv->printer_name);
 
146
          priv->printer_name = NULL;
 
147
        }
 
148
 
 
149
      if (priv->option_supported)
 
150
        {
 
151
          ipp_attribute_free (priv->option_supported);
 
152
          priv->option_supported = NULL;
 
153
        }
 
154
 
 
155
      if (priv->option_default)
 
156
        {
 
157
          ipp_attribute_free (priv->option_default);
 
158
          priv->option_default = NULL;
 
159
        }
 
160
 
 
161
      if (priv->ipp_attribute)
 
162
        {
 
163
          g_hash_table_unref (priv->ipp_attribute);
 
164
          priv->ipp_attribute = NULL;
 
165
        }
 
166
    }
 
167
 
 
168
  G_OBJECT_CLASS (pp_ipp_option_widget_parent_class)->finalize (object);
 
169
}
 
170
 
 
171
GtkWidget *
 
172
pp_ipp_option_widget_new (IPPAttribute *attr_supported,
 
173
                          IPPAttribute *attr_default,
 
174
                          const gchar  *option_name,
 
175
                          const gchar  *printer)
 
176
{
 
177
  PpIPPOptionWidgetPrivate *priv;
 
178
  PpIPPOptionWidget        *widget = NULL;
 
179
 
 
180
  if (attr_supported && option_name && printer)
 
181
    {
 
182
      widget = g_object_new (PP_TYPE_IPP_OPTION_WIDGET, NULL);
 
183
 
 
184
      priv = PP_IPP_OPTION_WIDGET_GET_PRIVATE (widget);
 
185
 
 
186
      priv->printer_name = g_strdup (printer);
 
187
      priv->option_name = g_strdup (option_name);
 
188
      priv->option_supported = ipp_attribute_copy (attr_supported);
 
189
      priv->option_default = ipp_attribute_copy (attr_default);
 
190
 
 
191
      if (construct_widget (widget))
 
192
        {
 
193
          update_widget_real (widget);
 
194
        }
 
195
      else
 
196
        {
 
197
          g_object_ref_sink (widget);
 
198
          g_object_unref (widget);
 
199
          widget = NULL;
 
200
        }
 
201
    }
 
202
 
 
203
  return (GtkWidget *) widget;
 
204
}
 
205
 
 
206
enum {
 
207
  NAME_COLUMN,
 
208
  VALUE_COLUMN,
 
209
  N_COLUMNS
 
210
};
 
211
 
 
212
static GtkWidget *
 
213
combo_box_new (void)
 
214
{
 
215
  GtkCellRenderer *cell;
 
216
  GtkListStore    *store;
 
217
  GtkWidget       *combo_box;
 
218
 
 
219
  combo_box = gtk_combo_box_new ();
 
220
 
 
221
  store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
 
222
  gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
 
223
  g_object_unref (store);
 
224
 
 
225
  cell = gtk_cell_renderer_text_new ();
 
226
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
 
227
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
 
228
                                  "text", NAME_COLUMN,
 
229
                                  NULL);
 
230
 
 
231
  return combo_box;
 
232
}
 
233
 
 
234
static void
 
235
combo_box_append (GtkWidget   *combo,
 
236
                  const gchar *display_text,
 
237
                  const gchar *value)
 
238
{
 
239
  GtkTreeModel *model;
 
240
  GtkListStore *store;
 
241
  GtkTreeIter   iter;
 
242
 
 
243
  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
 
244
  store = GTK_LIST_STORE (model);
 
245
 
 
246
  gtk_list_store_append (store, &iter);
 
247
  gtk_list_store_set (store, &iter,
 
248
                      NAME_COLUMN, display_text,
 
249
                      VALUE_COLUMN, value,
 
250
                      -1);
 
251
}
 
252
 
 
253
struct ComboSet {
 
254
  GtkComboBox *combo;
 
255
  const gchar *value;
 
256
};
 
257
 
 
258
static gboolean
 
259
set_cb (GtkTreeModel *model,
 
260
        GtkTreePath  *path,
 
261
        GtkTreeIter  *iter,
 
262
        gpointer      data)
 
263
{
 
264
  struct ComboSet *set_data = data;
 
265
  gboolean         found;
 
266
  char            *value;
 
267
 
 
268
  gtk_tree_model_get (model, iter, VALUE_COLUMN, &value, -1);
 
269
  found = (strcmp (value, set_data->value) == 0);
 
270
  g_free (value);
 
271
 
 
272
  if (found)
 
273
    gtk_combo_box_set_active_iter (set_data->combo, iter);
 
274
 
 
275
  return found;
 
276
}
 
277
 
 
278
static void
 
279
combo_box_set (GtkWidget   *combo,
 
280
               const gchar *value)
 
281
{
 
282
  struct ComboSet  set_data;
 
283
  GtkTreeModel    *model;
 
284
 
 
285
  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
 
286
 
 
287
  set_data.combo = GTK_COMBO_BOX (combo);
 
288
  set_data.value = value;
 
289
  gtk_tree_model_foreach (model, set_cb, &set_data);
 
290
}
 
291
 
 
292
static char *
 
293
combo_box_get (GtkWidget *combo)
 
294
{
 
295
  GtkTreeModel *model;
 
296
  GtkTreeIter   iter;
 
297
  gchar        *value = NULL;
 
298
 
 
299
  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
 
300
 
 
301
  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
 
302
     gtk_tree_model_get (model, &iter, VALUE_COLUMN, &value, -1);
 
303
 
 
304
  return value;
 
305
}
 
306
 
 
307
static void
 
308
printer_add_option_async_cb (gboolean success,
 
309
                             gpointer user_data)
 
310
{
 
311
  update_widget (user_data);
 
312
}
 
313
 
 
314
static void
 
315
switch_changed_cb (GtkWidget         *switch_button,
 
316
                   GParamSpec        *pspec,
 
317
                   PpIPPOptionWidget *widget)
 
318
{
 
319
  PpIPPOptionWidgetPrivate  *priv = widget->priv;
 
320
  gchar                    **values;
 
321
 
 
322
  values = g_new0 (gchar *, 2);
 
323
 
 
324
  if (gtk_switch_get_active (GTK_SWITCH (switch_button)))
 
325
    values[0] = g_strdup ("True");
 
326
  else
 
327
    values[0] = g_strdup ("False");
 
328
 
 
329
  printer_add_option_async (priv->printer_name,
 
330
                            priv->option_name,
 
331
                            values,
 
332
                            TRUE,
 
333
                            NULL,
 
334
                            printer_add_option_async_cb,
 
335
                            widget);
 
336
 
 
337
  g_strfreev (values);
 
338
}
 
339
 
 
340
static void
 
341
combo_changed_cb (GtkWidget         *combo,
 
342
                  PpIPPOptionWidget *widget)
 
343
{
 
344
  PpIPPOptionWidgetPrivate  *priv = widget->priv;
 
345
  gchar                    **values;
 
346
 
 
347
  values = g_new0 (gchar *, 2);
 
348
  values[0] = combo_box_get (combo);
 
349
 
 
350
  printer_add_option_async (priv->printer_name,
 
351
                            priv->option_name,
 
352
                            values,
 
353
                            TRUE,
 
354
                            NULL,
 
355
                            printer_add_option_async_cb,
 
356
                            widget);
 
357
 
 
358
  g_strfreev (values);
 
359
}
 
360
 
 
361
static void
 
362
spin_button_changed_cb (GtkWidget         *spin_button,
 
363
                        PpIPPOptionWidget *widget)
 
364
{
 
365
  PpIPPOptionWidgetPrivate  *priv = widget->priv;
 
366
  gchar                    **values;
 
367
 
 
368
  values = g_new0 (gchar *, 2);
 
369
  values[0] = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin_button)));
 
370
 
 
371
  printer_add_option_async (priv->printer_name,
 
372
                            priv->option_name,
 
373
                            values,
 
374
                            TRUE,
 
375
                            NULL,
 
376
                            printer_add_option_async_cb,
 
377
                            widget);
 
378
 
 
379
  g_strfreev (values);
 
380
}
 
381
 
 
382
static gboolean
 
383
construct_widget (PpIPPOptionWidget *widget)
 
384
{
 
385
  PpIPPOptionWidgetPrivate *priv = widget->priv;
 
386
  gboolean                  trivial_option = FALSE;
 
387
  gboolean                  result = FALSE;
 
388
  gchar                    *value;
 
389
  gint                      i;
 
390
 
 
391
  if (priv->option_supported)
 
392
    {
 
393
      switch (priv->option_supported->attribute_type)
 
394
        {
 
395
          case IPP_ATTRIBUTE_TYPE_INTEGER:
 
396
            if (priv->option_supported->num_of_values <= 1)
 
397
              trivial_option = TRUE;
 
398
            break;
 
399
 
 
400
          case IPP_ATTRIBUTE_TYPE_STRING:
 
401
            if (priv->option_supported->num_of_values <= 1)
 
402
              trivial_option = TRUE;
 
403
            break;
 
404
 
 
405
          case IPP_ATTRIBUTE_TYPE_RANGE:
 
406
            if (priv->option_supported->attribute_values[0].lower_range ==
 
407
                priv->option_supported->attribute_values[0].upper_range)
 
408
              trivial_option = TRUE;
 
409
            break;
 
410
        }
 
411
 
 
412
      if (!trivial_option)
 
413
        {
 
414
          switch (priv->option_supported->attribute_type)
 
415
            {
 
416
              case IPP_ATTRIBUTE_TYPE_BOOLEAN:
 
417
                  priv->switch_button = gtk_switch_new ();
 
418
 
 
419
                  gtk_box_pack_start (GTK_BOX (widget), priv->switch_button, FALSE, FALSE, 0);
 
420
                  g_signal_connect (priv->switch_button, "notify::active", G_CALLBACK (switch_changed_cb), widget);
 
421
                  break;
 
422
 
 
423
              case IPP_ATTRIBUTE_TYPE_INTEGER:
 
424
                  priv->combo = combo_box_new ();
 
425
 
 
426
                  for (i = 0; i < priv->option_supported->num_of_values; i++)
 
427
                    {
 
428
                      value = g_strdup_printf ("%d", priv->option_supported->attribute_values[i].integer_value);
 
429
                      combo_box_append (priv->combo,
 
430
                                        ipp_choice_translate (priv->option_name,
 
431
                                                              value),
 
432
                                        value);
 
433
                      g_free (value);
 
434
                    }
 
435
 
 
436
                  gtk_box_pack_start (GTK_BOX (widget), priv->combo, FALSE, FALSE, 0);
 
437
                  g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
 
438
                  break;
 
439
 
 
440
              case IPP_ATTRIBUTE_TYPE_STRING:
 
441
                  priv->combo = combo_box_new ();
 
442
 
 
443
                  for (i = 0; i < priv->option_supported->num_of_values; i++)
 
444
                    combo_box_append (priv->combo,
 
445
                                      ipp_choice_translate (priv->option_name,
 
446
                                                            priv->option_supported->attribute_values[i].string_value),
 
447
                                      priv->option_supported->attribute_values[i].string_value);
 
448
 
 
449
                  gtk_box_pack_start (GTK_BOX (widget), priv->combo, FALSE, FALSE, 0);
 
450
                  g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
 
451
                  break;
 
452
 
 
453
              case IPP_ATTRIBUTE_TYPE_RANGE:
 
454
                  priv->spin_button = gtk_spin_button_new_with_range (
 
455
                                        priv->option_supported->attribute_values[0].lower_range,
 
456
                                        priv->option_supported->attribute_values[0].upper_range,
 
457
                                        1);
 
458
 
 
459
                  gtk_box_pack_start (GTK_BOX (widget), priv->spin_button, FALSE, FALSE, 0);
 
460
                  g_signal_connect (priv->spin_button, "value-changed", G_CALLBACK (spin_button_changed_cb), widget);
 
461
                  break;
 
462
 
 
463
              default:
 
464
                  break;
 
465
            }
 
466
 
 
467
          result = TRUE;
 
468
        }
 
469
    }
 
470
 
 
471
  return result;
 
472
}
 
473
 
 
474
static void
 
475
update_widget_real (PpIPPOptionWidget *widget)
 
476
{
 
477
  PpIPPOptionWidgetPrivate *priv = widget->priv;
 
478
  IPPAttribute             *attr = NULL;
 
479
  gchar                    *value;
 
480
  gchar                    *attr_name;
 
481
 
 
482
  if (priv->option_default)
 
483
    {
 
484
      attr = ipp_attribute_copy (priv->option_default);
 
485
 
 
486
      ipp_attribute_free (priv->option_default);
 
487
      priv->option_default = NULL;
 
488
    }
 
489
  else if (priv->ipp_attribute)
 
490
    {
 
491
      attr_name = g_strdup_printf ("%s-default", priv->option_name);
 
492
      attr = ipp_attribute_copy (g_hash_table_lookup (priv->ipp_attribute, attr_name));
 
493
 
 
494
      g_free (attr_name);
 
495
      g_hash_table_unref (priv->ipp_attribute);
 
496
      priv->ipp_attribute = NULL;
 
497
    }
 
498
 
 
499
  switch (priv->option_supported->attribute_type)
 
500
    {
 
501
      case IPP_ATTRIBUTE_TYPE_BOOLEAN:
 
502
        g_signal_handlers_block_by_func (priv->switch_button, switch_changed_cb, widget);
 
503
 
 
504
        if (attr && attr->num_of_values > 0 &&
 
505
            attr->attribute_type == IPP_ATTRIBUTE_TYPE_BOOLEAN)
 
506
          {
 
507
            gtk_switch_set_active (GTK_SWITCH (priv->switch_button),
 
508
                                   attr->attribute_values[0].boolean_value);
 
509
          }
 
510
 
 
511
        g_signal_handlers_unblock_by_func (priv->switch_button, switch_changed_cb, widget);
 
512
        break;
 
513
 
 
514
      case IPP_ATTRIBUTE_TYPE_INTEGER:
 
515
        g_signal_handlers_block_by_func (priv->combo, combo_changed_cb, widget);
 
516
 
 
517
        if (attr && attr->num_of_values > 0 &&
 
518
            attr->attribute_type == IPP_ATTRIBUTE_TYPE_INTEGER)
 
519
          {
 
520
            value = g_strdup_printf ("%d", attr->attribute_values[0].integer_value);
 
521
            combo_box_set (priv->combo, value);
 
522
            g_free (value);
 
523
          }
 
524
        else
 
525
          {
 
526
            value = g_strdup_printf ("%d", priv->option_supported->attribute_values[0].integer_value);
 
527
            combo_box_set (priv->combo, value);
 
528
            g_free (value);
 
529
          }
 
530
 
 
531
        g_signal_handlers_unblock_by_func (priv->combo, combo_changed_cb, widget);
 
532
        break;
 
533
 
 
534
      case IPP_ATTRIBUTE_TYPE_STRING:
 
535
        g_signal_handlers_block_by_func (priv->combo, combo_changed_cb, widget);
 
536
 
 
537
        if (attr && attr->num_of_values > 0 &&
 
538
            attr->attribute_type == IPP_ATTRIBUTE_TYPE_STRING)
 
539
          {
 
540
            combo_box_set (priv->combo, attr->attribute_values[0].string_value);
 
541
          }
 
542
        else
 
543
          {
 
544
            combo_box_set (priv->combo, priv->option_supported->attribute_values[0].string_value);
 
545
          }
 
546
 
 
547
        g_signal_handlers_unblock_by_func (priv->combo, combo_changed_cb, widget);
 
548
        break;
 
549
 
 
550
      case IPP_ATTRIBUTE_TYPE_RANGE:
 
551
        g_signal_handlers_block_by_func (priv->spin_button, spin_button_changed_cb, widget);
 
552
 
 
553
        if (attr && attr->num_of_values > 0 &&
 
554
            attr->attribute_type == IPP_ATTRIBUTE_TYPE_INTEGER)
 
555
          {
 
556
            gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spin_button),
 
557
                                       attr->attribute_values[0].integer_value);
 
558
          }
 
559
        else
 
560
          {
 
561
            gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spin_button),
 
562
                                       priv->option_supported->attribute_values[0].lower_range);
 
563
          }
 
564
 
 
565
        g_signal_handlers_unblock_by_func (priv->spin_button, spin_button_changed_cb, widget);
 
566
        break;
 
567
 
 
568
      default:
 
569
        break;
 
570
    }
 
571
 
 
572
  ipp_attribute_free (attr);
 
573
}
 
574
 
 
575
static void
 
576
get_ipp_attributes_cb (GHashTable *table,
 
577
                       gpointer    user_data)
 
578
{
 
579
  PpIPPOptionWidget        *widget = (PpIPPOptionWidget *) user_data;
 
580
  PpIPPOptionWidgetPrivate *priv = widget->priv;
 
581
 
 
582
  if (priv->ipp_attribute)
 
583
    g_hash_table_unref (priv->ipp_attribute);
 
584
 
 
585
  priv->ipp_attribute = table;
 
586
 
 
587
  update_widget_real (widget);
 
588
}
 
589
 
 
590
static void
 
591
update_widget (PpIPPOptionWidget *widget)
 
592
{
 
593
  PpIPPOptionWidgetPrivate  *priv = widget->priv;
 
594
  gchar                    **attributes_names;
 
595
 
 
596
  attributes_names = g_new0 (gchar *, 2);
 
597
  attributes_names[0] = g_strdup_printf ("%s-default", priv->option_name);
 
598
 
 
599
  get_ipp_attributes_async (priv->printer_name,
 
600
                            attributes_names,
 
601
                            get_ipp_attributes_cb,
 
602
                            widget);
 
603
 
 
604
  g_strfreev (attributes_names);
 
605
}