Line |
Branch |
Exec |
Source |
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, see <http://www.gnu.org/licenses/>. |
17 |
|
|
* |
18 |
|
|
* Author: Marek Kasik <mkasik@redhat.com> |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "config.h" |
22 |
|
|
|
23 |
|
|
#include <unistd.h> |
24 |
|
|
#include <stdlib.h> |
25 |
|
|
|
26 |
|
|
#include <glib.h> |
27 |
|
|
#include <glib/gi18n.h> |
28 |
|
|
#include <glib/gstdio.h> |
29 |
|
|
#include <gtk/gtk.h> |
30 |
|
|
#include <gdesktop-enums.h> |
31 |
|
|
|
32 |
|
|
#include <cups/cups.h> |
33 |
|
|
|
34 |
|
|
#include "pp-jobs-dialog.h" |
35 |
|
|
#include "pp-utils.h" |
36 |
|
|
#include "pp-job.h" |
37 |
|
|
#include "pp-job-row.h" |
38 |
|
|
#include "pp-cups.h" |
39 |
|
|
#include "pp-printer.h" |
40 |
|
|
|
41 |
|
|
#define EMPTY_TEXT "\xe2\x80\x94" |
42 |
|
|
|
43 |
|
|
#define CLOCK_SCHEMA "org.gnome.desktop.interface" |
44 |
|
|
#define CLOCK_FORMAT_KEY "clock-format" |
45 |
|
|
|
46 |
|
|
struct _PpJobsDialog { |
47 |
|
|
AdwWindow parent_instance; |
48 |
|
|
|
49 |
|
|
GtkButton *authenticate_button; |
50 |
|
|
GtkMenuButton *authenticate_jobs_button; |
51 |
|
|
GtkLabel *authenticate_jobs_label; |
52 |
|
|
GtkInfoBar *authentication_infobar; |
53 |
|
|
GtkLabel *authentication_label; |
54 |
|
|
GtkEntry *domain_entry; |
55 |
|
|
GtkLabel *domain_label; |
56 |
|
|
GtkButton *jobs_clear_all_button; |
57 |
|
|
GtkListBox *jobs_listbox; |
58 |
|
|
GtkScrolledWindow *list_jobs_page; |
59 |
|
|
GtkBox *no_jobs_page; |
60 |
|
|
GtkEntry *password_entry; |
61 |
|
|
GtkLabel *password_label; |
62 |
|
|
GtkStack *stack; |
63 |
|
|
GListStore *store; |
64 |
|
|
GtkEntry *username_entry; |
65 |
|
|
GtkLabel *username_label; |
66 |
|
|
|
67 |
|
|
gchar *printer_name; |
68 |
|
|
|
69 |
|
|
gchar **actual_auth_info_required; |
70 |
|
|
gboolean jobs_filled; |
71 |
|
|
gboolean pop_up_authentication_popup; |
72 |
|
|
gint max_priority; |
73 |
|
|
|
74 |
|
|
GCancellable *get_jobs_cancellable; |
75 |
|
|
}; |
76 |
|
|
|
77 |
|
✗ |
G_DEFINE_TYPE (PpJobsDialog, pp_jobs_dialog, ADW_TYPE_WINDOW) |
78 |
|
|
|
79 |
|
|
static gboolean |
80 |
|
✗ |
is_info_required (PpJobsDialog *self, |
81 |
|
|
const gchar *info) |
82 |
|
|
{ |
83 |
|
|
gint i; |
84 |
|
|
|
85 |
|
✗ |
if (self->actual_auth_info_required == NULL) |
86 |
|
✗ |
return FALSE; |
87 |
|
|
|
88 |
|
✗ |
for (i = 0; self->actual_auth_info_required[i] != NULL; i++) |
89 |
|
✗ |
if (g_strcmp0 (self->actual_auth_info_required[i], info) == 0) |
90 |
|
✗ |
return TRUE; |
91 |
|
|
|
92 |
|
✗ |
return FALSE; |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
static gboolean |
96 |
|
✗ |
is_domain_required (PpJobsDialog *self) |
97 |
|
|
{ |
98 |
|
✗ |
return is_info_required (self, "domain"); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
static gboolean |
102 |
|
✗ |
is_username_required (PpJobsDialog *self) |
103 |
|
|
{ |
104 |
|
✗ |
return is_info_required (self, "username"); |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
static gboolean |
108 |
|
✗ |
is_password_required (PpJobsDialog *self) |
109 |
|
|
{ |
110 |
|
✗ |
return is_info_required (self, "password"); |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
static gboolean |
114 |
|
✗ |
auth_popup_filled (PpJobsDialog *self) |
115 |
|
|
{ |
116 |
|
|
gboolean domain_required; |
117 |
|
|
gboolean username_required; |
118 |
|
|
gboolean password_required; |
119 |
|
|
guint16 domain_length; |
120 |
|
|
guint16 username_length; |
121 |
|
|
guint16 password_length; |
122 |
|
|
|
123 |
|
✗ |
domain_required = is_domain_required (self); |
124 |
|
✗ |
username_required = is_username_required (self); |
125 |
|
✗ |
password_required = is_password_required (self); |
126 |
|
|
|
127 |
|
✗ |
domain_length = gtk_entry_get_text_length (self->domain_entry); |
128 |
|
✗ |
username_length = gtk_entry_get_text_length (self->username_entry); |
129 |
|
✗ |
password_length = gtk_entry_get_text_length (self->password_entry); |
130 |
|
|
|
131 |
|
✗ |
return (!domain_required || domain_length > 0) && |
132 |
|
✗ |
(!username_required || username_length > 0) && |
133 |
|
✗ |
(!password_required || password_length > 0); |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
static void |
137 |
|
✗ |
auth_entries_changed (PpJobsDialog *self) |
138 |
|
|
{ |
139 |
|
✗ |
gtk_widget_set_sensitive (GTK_WIDGET (self->authenticate_button), auth_popup_filled (self)); |
140 |
|
✗ |
} |
141 |
|
|
|
142 |
|
|
static void |
143 |
|
✗ |
auth_entries_activated (PpJobsDialog *self) |
144 |
|
|
{ |
145 |
|
✗ |
if (auth_popup_filled (self)) |
146 |
|
✗ |
g_signal_emit_by_name (self->authenticate_button, "activate"); |
147 |
|
✗ |
} |
148 |
|
|
|
149 |
|
|
static void |
150 |
|
✗ |
authenticate_popover_update (PpJobsDialog *self) |
151 |
|
|
{ |
152 |
|
|
gboolean domain_required; |
153 |
|
|
gboolean username_required; |
154 |
|
|
gboolean password_required; |
155 |
|
|
|
156 |
|
✗ |
domain_required = is_domain_required (self); |
157 |
|
✗ |
username_required = is_username_required (self); |
158 |
|
✗ |
password_required = is_password_required (self); |
159 |
|
|
|
160 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->domain_label), domain_required); |
161 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->domain_entry), domain_required); |
162 |
|
✗ |
if (domain_required) |
163 |
|
✗ |
gtk_editable_set_text (GTK_EDITABLE (self->domain_entry), ""); |
164 |
|
|
|
165 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->username_label), username_required); |
166 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->username_entry), username_required); |
167 |
|
✗ |
if (username_required) |
168 |
|
✗ |
gtk_editable_set_text (GTK_EDITABLE (self->username_entry), cupsUser ()); |
169 |
|
|
|
170 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->password_label), password_required); |
171 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->password_entry), password_required); |
172 |
|
✗ |
if (password_required) |
173 |
|
✗ |
gtk_editable_set_text (GTK_EDITABLE (self->password_entry), ""); |
174 |
|
|
|
175 |
|
✗ |
gtk_widget_set_sensitive (GTK_WIDGET (self->authenticate_button), FALSE); |
176 |
|
✗ |
} |
177 |
|
|
|
178 |
|
|
static void |
179 |
|
✗ |
pp_job_update_cb (GObject *source_object, |
180 |
|
|
GAsyncResult *res, |
181 |
|
|
gpointer user_data) |
182 |
|
|
{ |
183 |
|
✗ |
PpJobsDialog *self = user_data; |
184 |
|
|
gboolean result; |
185 |
|
✗ |
g_autoptr(GError) error = NULL; |
186 |
|
✗ |
PpJob *job = PP_JOB (source_object); |
187 |
|
|
|
188 |
|
✗ |
result = pp_job_set_priority_finish (job, res, &error); |
189 |
|
✗ |
if (result) |
190 |
|
|
{ |
191 |
|
✗ |
pp_jobs_dialog_update (self); |
192 |
|
|
} |
193 |
|
✗ |
else if (error != NULL) |
194 |
|
|
{ |
195 |
|
✗ |
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
196 |
|
|
{ |
197 |
|
✗ |
g_warning ("Could not set job priority: %s", error->message); |
198 |
|
|
} |
199 |
|
|
} |
200 |
|
✗ |
} |
201 |
|
|
|
202 |
|
|
static void |
203 |
|
✗ |
on_priority_changed (PpJobsDialog *self, |
204 |
|
|
PpJobRow *job_row) |
205 |
|
|
{ |
206 |
|
|
PpJob *job; |
207 |
|
|
|
208 |
|
✗ |
job = pp_job_row_get_job (job_row); |
209 |
|
✗ |
pp_job_set_priority_async (job, ++self->max_priority, NULL, pp_job_update_cb, self); |
210 |
|
✗ |
} |
211 |
|
|
|
212 |
|
|
static GtkWidget * |
213 |
|
✗ |
create_listbox_row (gpointer item, |
214 |
|
|
gpointer user_data) |
215 |
|
|
{ |
216 |
|
✗ |
PpJobsDialog *self = user_data; |
217 |
|
|
PpJobRow *job_row; |
218 |
|
|
|
219 |
|
✗ |
job_row = pp_job_row_new (PP_JOB (item)); |
220 |
|
|
|
221 |
|
✗ |
g_signal_connect_swapped (job_row, |
222 |
|
|
"priority-changed", |
223 |
|
|
G_CALLBACK (on_priority_changed), |
224 |
|
|
self); |
225 |
|
|
|
226 |
|
✗ |
return GTK_WIDGET (job_row); |
227 |
|
|
} |
228 |
|
|
|
229 |
|
|
static void |
230 |
|
✗ |
pop_up_authentication_popup (PpJobsDialog *self) |
231 |
|
|
{ |
232 |
|
✗ |
if (self->actual_auth_info_required != NULL) |
233 |
|
✗ |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->authenticate_jobs_button), TRUE); |
234 |
|
✗ |
} |
235 |
|
|
|
236 |
|
|
static void |
237 |
|
✗ |
update_jobs_list_cb (GObject *source_object, |
238 |
|
|
GAsyncResult *result, |
239 |
|
|
gpointer user_data) |
240 |
|
|
{ |
241 |
|
✗ |
PpJobsDialog *self = user_data; |
242 |
|
✗ |
PpPrinter *printer = PP_PRINTER (source_object); |
243 |
|
✗ |
g_autoptr(GError) error = NULL; |
244 |
|
✗ |
g_autoptr(GPtrArray) jobs; |
245 |
|
|
PpJob *job; |
246 |
|
✗ |
gint num_of_auth_jobs = 0; |
247 |
|
|
gint job_priority; |
248 |
|
|
guint state; |
249 |
|
|
guint i; |
250 |
|
✗ |
gint current_max_value = 1; |
251 |
|
✗ |
gint first_unprocessed_job = -1; |
252 |
|
|
|
253 |
|
✗ |
g_list_store_remove_all (self->store); |
254 |
|
|
|
255 |
|
✗ |
jobs = pp_printer_get_jobs_finish (printer, result, &error); |
256 |
|
✗ |
if (error != NULL) |
257 |
|
|
{ |
258 |
|
✗ |
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
259 |
|
|
{ |
260 |
|
✗ |
g_warning ("Could not get jobs: %s", error->message); |
261 |
|
|
} |
262 |
|
|
|
263 |
|
✗ |
return; |
264 |
|
|
} |
265 |
|
|
|
266 |
|
✗ |
if (jobs->len > 0) |
267 |
|
|
{ |
268 |
|
✗ |
gtk_widget_set_sensitive (GTK_WIDGET (self->jobs_clear_all_button), TRUE); |
269 |
|
✗ |
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->list_jobs_page)); |
270 |
|
|
} |
271 |
|
|
else |
272 |
|
|
{ |
273 |
|
✗ |
gtk_widget_set_sensitive (GTK_WIDGET (self->jobs_clear_all_button), FALSE); |
274 |
|
✗ |
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->no_jobs_page)); |
275 |
|
|
} |
276 |
|
|
|
277 |
|
✗ |
for (i = 0; i < jobs->len; i++) |
278 |
|
|
{ |
279 |
|
✗ |
job = PP_JOB (g_ptr_array_index (jobs, i)); |
280 |
|
✗ |
state = pp_job_get_state (job); |
281 |
|
|
|
282 |
|
✗ |
if (state == IPP_JOB_PENDING || state == IPP_JOB_HELD) |
283 |
|
|
{ |
284 |
|
✗ |
if (first_unprocessed_job == -1) |
285 |
|
|
{ |
286 |
|
✗ |
first_unprocessed_job = i; |
287 |
|
✗ |
break; |
288 |
|
|
} |
289 |
|
|
} |
290 |
|
|
} |
291 |
|
|
|
292 |
|
✗ |
for (i = 0; i < jobs->len; i++) |
293 |
|
|
{ |
294 |
|
✗ |
job = PP_JOB (g_ptr_array_index (jobs, i)); |
295 |
|
✗ |
job_priority = pp_job_get_priority (job); |
296 |
|
✗ |
pp_job_priority_set_sensitive (job, (pp_job_get_state (job) == IPP_JOB_PENDING || |
297 |
|
✗ |
pp_job_get_state (job) == IPP_JOB_HELD) && |
298 |
|
✗ |
i > first_unprocessed_job); |
299 |
|
|
|
300 |
|
✗ |
if (job_priority >= current_max_value && job_priority != 100) |
301 |
|
✗ |
current_max_value = job_priority; |
302 |
|
|
|
303 |
|
✗ |
g_list_store_append (self->store, g_object_ref (job)); |
304 |
|
|
|
305 |
|
✗ |
if (pp_job_get_auth_info_required (job) != NULL) |
306 |
|
|
{ |
307 |
|
✗ |
num_of_auth_jobs++; |
308 |
|
|
|
309 |
|
✗ |
if (self->actual_auth_info_required == NULL) |
310 |
|
✗ |
self->actual_auth_info_required = g_strdupv (pp_job_get_auth_info_required (job)); |
311 |
|
|
} |
312 |
|
|
} |
313 |
|
✗ |
self->max_priority = current_max_value; |
314 |
|
✗ |
if (num_of_auth_jobs > 0) |
315 |
|
|
{ |
316 |
|
✗ |
g_autofree gchar *text = NULL; |
317 |
|
|
|
318 |
|
|
/* Translators: This label shows how many jobs of this printer needs to be authenticated to be printed. */ |
319 |
|
✗ |
text = g_strdup_printf (ngettext ("%u Job Requires Authentication", "%u Jobs Require Authentication", num_of_auth_jobs), num_of_auth_jobs); |
320 |
|
✗ |
gtk_label_set_text (self->authenticate_jobs_label, text); |
321 |
|
|
|
322 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->authentication_infobar), TRUE); |
323 |
|
|
} |
324 |
|
|
else |
325 |
|
|
{ |
326 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self->authentication_infobar), FALSE); |
327 |
|
|
} |
328 |
|
|
|
329 |
|
✗ |
authenticate_popover_update (self); |
330 |
|
|
|
331 |
|
✗ |
g_clear_object (&self->get_jobs_cancellable); |
332 |
|
|
|
333 |
|
✗ |
if (!self->jobs_filled) |
334 |
|
|
{ |
335 |
|
✗ |
if (self->pop_up_authentication_popup) |
336 |
|
|
{ |
337 |
|
✗ |
pop_up_authentication_popup (self); |
338 |
|
✗ |
self->pop_up_authentication_popup = FALSE; |
339 |
|
|
} |
340 |
|
|
|
341 |
|
✗ |
self->jobs_filled = TRUE; |
342 |
|
|
} |
343 |
|
|
} |
344 |
|
|
|
345 |
|
|
static void |
346 |
|
✗ |
update_jobs_list (PpJobsDialog *self) |
347 |
|
|
{ |
348 |
|
✗ |
g_autoptr(PpPrinter) printer = NULL; |
349 |
|
|
|
350 |
|
✗ |
if (self->printer_name != NULL) |
351 |
|
|
{ |
352 |
|
✗ |
g_cancellable_cancel (self->get_jobs_cancellable); |
353 |
|
✗ |
g_clear_object (&self->get_jobs_cancellable); |
354 |
|
|
|
355 |
|
✗ |
self->get_jobs_cancellable = g_cancellable_new (); |
356 |
|
|
|
357 |
|
✗ |
printer = pp_printer_new (self->printer_name); |
358 |
|
✗ |
pp_printer_get_jobs_async (printer, |
359 |
|
|
TRUE, |
360 |
|
|
CUPS_WHICHJOBS_ACTIVE, |
361 |
|
|
self->get_jobs_cancellable, |
362 |
|
|
update_jobs_list_cb, |
363 |
|
|
self); |
364 |
|
|
} |
365 |
|
✗ |
} |
366 |
|
|
|
367 |
|
|
static void |
368 |
|
✗ |
on_clear_all_button_clicked (PpJobsDialog *self) |
369 |
|
|
{ |
370 |
|
|
guint num_items; |
371 |
|
|
guint i; |
372 |
|
|
|
373 |
|
✗ |
num_items = g_list_model_get_n_items (G_LIST_MODEL (self->store)); |
374 |
|
|
|
375 |
|
✗ |
for (i = 0; i < num_items; i++) |
376 |
|
|
{ |
377 |
|
✗ |
PpJob *job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (self->store), i)); |
378 |
|
|
|
379 |
|
✗ |
pp_job_cancel_purge_async (job, FALSE); |
380 |
|
|
} |
381 |
|
✗ |
} |
382 |
|
|
|
383 |
|
|
static void |
384 |
|
✗ |
pp_job_authenticate_cb (GObject *source_object, |
385 |
|
|
GAsyncResult *res, |
386 |
|
|
gpointer user_data) |
387 |
|
|
{ |
388 |
|
✗ |
PpJobsDialog *self = user_data; |
389 |
|
|
gboolean result; |
390 |
|
✗ |
g_autoptr(GError) error = NULL; |
391 |
|
✗ |
PpJob *job = PP_JOB (source_object); |
392 |
|
|
|
393 |
|
✗ |
result = pp_job_authenticate_finish (job, res, &error); |
394 |
|
✗ |
if (result) |
395 |
|
|
{ |
396 |
|
✗ |
pp_jobs_dialog_update (self); |
397 |
|
|
} |
398 |
|
✗ |
else if (error != NULL) |
399 |
|
|
{ |
400 |
|
✗ |
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
401 |
|
|
{ |
402 |
|
✗ |
g_warning ("Could not authenticate job: %s", error->message); |
403 |
|
|
} |
404 |
|
|
} |
405 |
|
✗ |
} |
406 |
|
|
|
407 |
|
|
static void |
408 |
|
✗ |
authenticate_button_clicked (PpJobsDialog *self) |
409 |
|
|
{ |
410 |
|
|
PpJob *job; |
411 |
|
|
gchar **auth_info; |
412 |
|
|
guint num_items; |
413 |
|
|
gint i; |
414 |
|
|
|
415 |
|
✗ |
auth_info = g_new0 (gchar *, g_strv_length (self->actual_auth_info_required) + 1); |
416 |
|
✗ |
for (i = 0; self->actual_auth_info_required[i] != NULL; i++) |
417 |
|
|
{ |
418 |
|
✗ |
if (g_strcmp0 (self->actual_auth_info_required[i], "domain") == 0) |
419 |
|
✗ |
auth_info[i] = g_strdup (gtk_editable_get_text (GTK_EDITABLE (self->domain_entry))); |
420 |
|
✗ |
else if (g_strcmp0 (self->actual_auth_info_required[i], "username") == 0) |
421 |
|
✗ |
auth_info[i] = g_strdup (gtk_editable_get_text (GTK_EDITABLE (self->username_entry))); |
422 |
|
✗ |
else if (g_strcmp0 (self->actual_auth_info_required[i], "password") == 0) |
423 |
|
✗ |
auth_info[i] = g_strdup (gtk_editable_get_text (GTK_EDITABLE (self->password_entry))); |
424 |
|
|
} |
425 |
|
|
|
426 |
|
✗ |
num_items = g_list_model_get_n_items (G_LIST_MODEL (self->store)); |
427 |
|
✗ |
for (i = 0; i < num_items; i++) |
428 |
|
|
{ |
429 |
|
✗ |
job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (self->store), i)); |
430 |
|
|
|
431 |
|
✗ |
if (pp_job_get_auth_info_required (job) != NULL) |
432 |
|
|
{ |
433 |
|
✗ |
pp_job_authenticate_async (job, auth_info, NULL, pp_job_authenticate_cb, self); |
434 |
|
|
} |
435 |
|
|
} |
436 |
|
|
|
437 |
|
✗ |
g_strfreev (auth_info); |
438 |
|
✗ |
} |
439 |
|
|
|
440 |
|
|
PpJobsDialog * |
441 |
|
✗ |
pp_jobs_dialog_new (const gchar *printer_name) |
442 |
|
|
{ |
443 |
|
|
PpJobsDialog *self; |
444 |
|
✗ |
g_autofree gchar *text = NULL; |
445 |
|
✗ |
g_autofree gchar *title = NULL; |
446 |
|
|
|
447 |
|
✗ |
self = g_object_new (PP_TYPE_JOBS_DIALOG, NULL); |
448 |
|
|
|
449 |
|
✗ |
self->printer_name = g_strdup (printer_name); |
450 |
|
✗ |
self->actual_auth_info_required = NULL; |
451 |
|
✗ |
self->jobs_filled = FALSE; |
452 |
|
✗ |
self->pop_up_authentication_popup = FALSE; |
453 |
|
|
|
454 |
|
|
/* Translators: This is the printer name for which we are showing the active jobs */ |
455 |
|
✗ |
title = g_strdup_printf (C_("Printer jobs dialog title", "%s — Active Jobs"), printer_name); |
456 |
|
✗ |
gtk_window_set_title (GTK_WINDOW (self), title); |
457 |
|
|
|
458 |
|
|
/* Translators: The printer needs authentication info to print. */ |
459 |
|
✗ |
text = g_strdup_printf (_("Enter credentials to print from %s"), printer_name); |
460 |
|
✗ |
gtk_label_set_text (self->authentication_label, text); |
461 |
|
|
|
462 |
|
✗ |
self->store = g_list_store_new (pp_job_get_type ()); |
463 |
|
✗ |
gtk_list_box_bind_model (self->jobs_listbox, G_LIST_MODEL (self->store), |
464 |
|
|
create_listbox_row, self, NULL); |
465 |
|
|
|
466 |
|
✗ |
update_jobs_list (self); |
467 |
|
|
|
468 |
|
✗ |
return self; |
469 |
|
|
} |
470 |
|
|
|
471 |
|
|
void |
472 |
|
✗ |
pp_jobs_dialog_update (PpJobsDialog *self) |
473 |
|
|
{ |
474 |
|
✗ |
update_jobs_list (self); |
475 |
|
✗ |
} |
476 |
|
|
|
477 |
|
|
void |
478 |
|
✗ |
pp_jobs_dialog_authenticate_jobs (PpJobsDialog *self) |
479 |
|
|
{ |
480 |
|
✗ |
if (self->jobs_filled) |
481 |
|
✗ |
pop_up_authentication_popup (self); |
482 |
|
|
else |
483 |
|
✗ |
self->pop_up_authentication_popup = TRUE; |
484 |
|
✗ |
} |
485 |
|
|
|
486 |
|
|
static void |
487 |
|
✗ |
pp_jobs_dialog_init (PpJobsDialog *dialog) |
488 |
|
|
{ |
489 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (dialog)); |
490 |
|
✗ |
} |
491 |
|
|
|
492 |
|
|
static void |
493 |
|
✗ |
pp_jobs_dialog_dispose (GObject *object) |
494 |
|
|
{ |
495 |
|
✗ |
PpJobsDialog *self = PP_JOBS_DIALOG (object); |
496 |
|
|
|
497 |
|
✗ |
g_cancellable_cancel (self->get_jobs_cancellable); |
498 |
|
✗ |
g_clear_object (&self->get_jobs_cancellable); |
499 |
|
✗ |
g_clear_pointer (&self->actual_auth_info_required, g_strfreev); |
500 |
|
✗ |
g_clear_pointer (&self->printer_name, g_free); |
501 |
|
|
|
502 |
|
✗ |
G_OBJECT_CLASS (pp_jobs_dialog_parent_class)->dispose (object); |
503 |
|
✗ |
} |
504 |
|
|
|
505 |
|
|
static void |
506 |
|
✗ |
pp_jobs_dialog_class_init (PpJobsDialogClass *klass) |
507 |
|
|
{ |
508 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
509 |
|
✗ |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
510 |
|
|
|
511 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/printers/pp-jobs-dialog.ui"); |
512 |
|
|
|
513 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, authenticate_button); |
514 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, authenticate_jobs_button); |
515 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, authenticate_jobs_label); |
516 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, authentication_infobar); |
517 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, authentication_label); |
518 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, domain_entry); |
519 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, domain_label); |
520 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, jobs_clear_all_button); |
521 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, jobs_listbox); |
522 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, list_jobs_page); |
523 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, no_jobs_page); |
524 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, password_entry); |
525 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, password_label); |
526 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, stack); |
527 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, username_entry); |
528 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, PpJobsDialog, username_label); |
529 |
|
|
|
530 |
|
✗ |
gtk_widget_class_bind_template_callback (widget_class, authenticate_button_clicked); |
531 |
|
✗ |
gtk_widget_class_bind_template_callback (widget_class, on_clear_all_button_clicked); |
532 |
|
✗ |
gtk_widget_class_bind_template_callback (widget_class, auth_entries_activated); |
533 |
|
✗ |
gtk_widget_class_bind_template_callback (widget_class, auth_entries_changed); |
534 |
|
|
|
535 |
|
✗ |
object_class->dispose = pp_jobs_dialog_dispose; |
536 |
|
|
|
537 |
|
✗ |
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "window.close", NULL); |
538 |
|
✗ |
} |
539 |
|
|
|