1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright 2012 Red Hat, Inc,
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.
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.
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.
19
* Author: Marek Kasik <mkasik@redhat.com>
24
G_DEFINE_TYPE (PpCups, pp_cups, G_TYPE_OBJECT);
27
pp_cups_finalize (GObject *object)
29
G_OBJECT_CLASS (pp_cups_parent_class)->finalize (object);
33
pp_cups_class_init (PpCupsClass *klass)
35
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
37
gobject_class->finalize = pp_cups_finalize;
41
pp_cups_init (PpCups *cups)
48
return g_object_new (PP_TYPE_CUPS, NULL);
57
_pp_cups_get_dests_thread (GSimpleAsyncResult *res,
59
GCancellable *cancellable)
63
data = g_simple_async_result_get_op_res_gpointer (res);
65
data->dests = g_new0 (PpCupsDests, 1);
66
data->dests->num_of_dests = cupsGetDests (&data->dests->dests);
70
cgd_data_free (CGDData *data)
76
cupsFreeDests (data->dests->num_of_dests, data->dests->dests);
85
pp_cups_get_dests_async (PpCups *cups,
86
GCancellable *cancellable,
87
GAsyncReadyCallback callback,
90
GSimpleAsyncResult *res;
93
res = g_simple_async_result_new (G_OBJECT (cups), callback, user_data, pp_cups_get_dests_async);
94
data = g_new0 (CGDData, 1);
97
g_simple_async_result_set_check_cancellable (res, cancellable);
98
g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify) cgd_data_free);
99
g_simple_async_result_run_in_thread (res, _pp_cups_get_dests_thread, 0, cancellable);
101
g_object_unref (res);
105
pp_cups_get_dests_finish (PpCups *cups,
109
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
110
PpCupsDests *result = NULL;
113
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == pp_cups_get_dests_async);
115
if (g_simple_async_result_propagate_error (simple, error))
120
data = g_simple_async_result_get_op_res_gpointer (simple);
121
result = data->dests;