printers: Drop cups_get_jobs_async
pp_printer_get_jobs_async does the job with more modern GLib API (GTask). https://bugzilla.gnome.org/show_bug.cgi?id=779313
This commit is contained in:
parent
2ad93bc0b2
commit
1df4da54fc
2 changed files with 0 additions and 113 deletions
|
@ -3624,109 +3624,6 @@ get_cups_devices_async (GCancellable *cancellable,
|
|||
data);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *printer_name;
|
||||
gboolean my_jobs;
|
||||
gint which_jobs;
|
||||
cups_job_t *jobs;
|
||||
gint num_of_jobs;
|
||||
CGJCallback callback;
|
||||
gpointer user_data;
|
||||
GMainContext *context;
|
||||
} CGJData;
|
||||
|
||||
static gboolean
|
||||
cups_get_jobs_idle_cb (gpointer user_data)
|
||||
{
|
||||
CGJData *data = (CGJData *) user_data;
|
||||
|
||||
data->callback (data->jobs,
|
||||
data->num_of_jobs,
|
||||
data->user_data);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
cups_get_jobs_data_free (gpointer user_data)
|
||||
{
|
||||
CGJData *data = (CGJData *) user_data;
|
||||
|
||||
if (data->context)
|
||||
g_main_context_unref (data->context);
|
||||
g_free (data->printer_name);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
cups_get_jobs_cb (gpointer user_data)
|
||||
{
|
||||
CGJData *data = (CGJData *) user_data;
|
||||
GSource *idle_source;
|
||||
|
||||
idle_source = g_idle_source_new ();
|
||||
g_source_set_callback (idle_source,
|
||||
cups_get_jobs_idle_cb,
|
||||
data,
|
||||
cups_get_jobs_data_free);
|
||||
g_source_attach (idle_source, data->context);
|
||||
g_source_unref (idle_source);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
cups_get_jobs_func (gpointer user_data)
|
||||
{
|
||||
CGJData *data = (CGJData *) user_data;
|
||||
|
||||
data->num_of_jobs = cupsGetJobs (&data->jobs,
|
||||
data->printer_name,
|
||||
data->my_jobs ? 1 : 0,
|
||||
data->which_jobs);
|
||||
|
||||
cups_get_jobs_cb (data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
cups_get_jobs_async (const gchar *printer_name,
|
||||
gboolean my_jobs,
|
||||
gint which_jobs,
|
||||
CGJCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
CGJData *data;
|
||||
GThread *thread;
|
||||
GError *error = NULL;
|
||||
|
||||
data = g_new0 (CGJData, 1);
|
||||
data->printer_name = g_strdup (printer_name);
|
||||
data->my_jobs = my_jobs;
|
||||
data->which_jobs = which_jobs;
|
||||
data->callback = callback;
|
||||
data->user_data = user_data;
|
||||
data->context = g_main_context_ref_thread_default ();
|
||||
|
||||
thread = g_thread_try_new ("cups-get-jobs",
|
||||
cups_get_jobs_func,
|
||||
data,
|
||||
&error);
|
||||
|
||||
if (!thread)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
callback (NULL, 0, user_data);
|
||||
|
||||
g_error_free (error);
|
||||
cups_get_jobs_data_free (data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_thread_unref (thread);
|
||||
}
|
||||
}
|
||||
|
||||
gchar *
|
||||
guess_device_hostname (PpPrintDevice *device)
|
||||
{
|
||||
|
|
|
@ -242,16 +242,6 @@ void printer_add_option_async (const gchar *printer_name,
|
|||
PAOCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
typedef void (*CGJCallback) (cups_job_t *jobs,
|
||||
gint num_of_jobs,
|
||||
gpointer user_data);
|
||||
|
||||
void cups_get_jobs_async (const gchar *printer_name,
|
||||
gboolean my_jobs,
|
||||
gint which_jobs,
|
||||
CGJCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
void pp_devices_list_free (PpDevicesList *result);
|
||||
|
||||
const gchar *get_page_size_from_locale (void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue