diff options
author | Felipe Borges <felipeborges@gnome.org> | 2017-02-28 16:20:07 +0100 |
---|---|---|
committer | Felipe Borges <felipeborges@gnome.org> | 2017-03-06 16:07:07 +0100 |
commit | 1df4da54fc0d089edf9aedc492e9e9e58ce8c230 (patch) | |
tree | c47b0f3152e558981ad4acb2165a3a57e50a3781 | |
parent | 2ad93bc0b23d0cf468579900e9f1039e20a945a2 (diff) | |
download | gnome-control-center-1df4da54fc0d089edf9aedc492e9e9e58ce8c230.tar.gz |
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
-rw-r--r-- | panels/printers/pp-utils.c | 103 | ||||
-rw-r--r-- | panels/printers/pp-utils.h | 10 |
2 files changed, 0 insertions, 113 deletions
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c index dc6606189..c140e37e5 100644 --- a/panels/printers/pp-utils.c +++ b/panels/printers/pp-utils.c @@ -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) { diff --git a/panels/printers/pp-utils.h b/panels/printers/pp-utils.h index 17dbaf734..97239845c 100644 --- a/panels/printers/pp-utils.h +++ b/panels/printers/pp-utils.h @@ -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); |