[patch] don't poll individual jobs
Colin Walters <[email protected]> Fri, 30 Jul 2004 13:25:38 -0400
| Newsgroups | gmane.comp.gnome.print |
|---|---|
| Message-ID | <[email protected]> |
Hi, The attached patch causes libgnomeprint to not instantiate GnomeCupsQueue objects. These were simply used to get the number of jobs, which is much more efficiently done by simply getting the queued- job-count from the attributes update. Ok to apply? _______________________________________________ gnome-print-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gnome-print-list
libgnomeprint22-2.7.0-queue-removal.patch
(text/x-patch, 3.7 KB)
--- libgnomeprint.cvs/libgnomeprint/modules/cups/gnome-print-cups.c~ 30 Jul 2004 10:39:12 -0400 1.33
+++ libgnomeprint.cvs/libgnomeprint/modules/cups/gnome-print-cups.c 30 Jul 2004 11:10:01 -0400
@@ -542,7 +542,9 @@
{
GPANode *state;
GPANode *printerstate;
+ GPANode *jobcount;
const char *str;
+ char *len_str;
state = gpa_printer_get_state (printer);
printerstate = gpa_node_get_child_from_path (state, "PrinterState");
@@ -552,6 +554,15 @@
}
str = gnome_cups_printer_get_state_name (cupsprinter);
gpa_node_set_value (printerstate, str);
+
+ jobcount = gpa_node_get_child_from_path (state, "QueueLength");
+ if (jobcount == NULL) {
+ jobcount = GPA_NODE (gpa_state_new ("QueueLength"));
+ gpa_node_attach (state, jobcount);
+ }
+ len_str = g_strdup_printf ("%d", gnome_cups_printer_get_job_count (cupsprinter));
+ gpa_node_set_value (jobcount, len_str);
+ g_free (len_str);
}
static void
@@ -572,27 +583,6 @@
gpa_node_set_value (location, str);
}
-
-static void
-queue_changed_cb (GnomeCupsQueue *cupsqueue,
- GList *jobs,
- GPAPrinter *printer)
-{
- GPANode *state;
- GPANode *jobcount;
- char *str;
-
- state = gpa_printer_get_state (printer);
- jobcount = gpa_node_get_child_from_path (state, "QueueLength");
- if (jobcount == NULL) {
- jobcount = GPA_NODE (gpa_state_new ("QueueLength"));
- gpa_node_attach (state, jobcount);
- }
- str = g_strdup_printf ("%d", gnome_cups_queue_get_job_count (cupsqueue));
- gpa_node_set_value (jobcount, str);
- g_free (str);
-}
-
static void
printer_added_cb (const char *name, struct GnomePrintCupsNewPrinterCbData *data)
{
@@ -633,39 +623,25 @@
start_polling (GPAPrinter *printer)
{
GnomeCupsPrinter *cupsprinter;
- GnomeCupsQueue *cupsqueue;
cupsprinter = gnome_cups_printer_get (printer->name);
- cupsqueue = gnome_cups_printer_get_queue (cupsprinter);
attributes_changed_cb (cupsprinter, printer);
g_signal_connect_object (cupsprinter, "attributes-changed",
G_CALLBACK (attributes_changed_cb), printer, 0);
- queue_changed_cb (cupsqueue, NULL, printer);
- g_signal_connect_object (cupsqueue, "jobs-added",
- G_CALLBACK (queue_changed_cb), printer, 0);
- g_signal_connect_object (cupsqueue, "jobs-removed",
- G_CALLBACK (queue_changed_cb), printer, 0);
}
static void
stop_polling (GPAPrinter *printer)
{
GnomeCupsPrinter *cupsprinter;
- GnomeCupsQueue *cupsqueue;
cupsprinter = gnome_cups_printer_get (printer->name);
- cupsqueue = gnome_cups_printer_get_queue (cupsprinter);
g_signal_handlers_disconnect_by_func (cupsprinter,
G_CALLBACK (attributes_changed_cb),
printer);
- g_signal_handlers_disconnect_by_func (cupsqueue,
- G_CALLBACK (queue_changed_cb),
- printer);
/* Unref twice since _get refs itself */
g_object_unref (G_OBJECT (cupsprinter));
g_object_unref (G_OBJECT (cupsprinter));
- g_object_unref (G_OBJECT (cupsqueue));
- g_object_unref (G_OBJECT (cupsqueue));
}
void gpa_module_polling (GPAPrinter *printer, gboolean polling);
@@ -689,7 +665,6 @@
ppd_file_t *ppd = NULL;
gboolean success = FALSE;
GnomeCupsPrinter *cupsprinter;
- GnomeCupsQueue *cupsqueue;
if (printer->is_complete)
return;
@@ -719,11 +694,8 @@
success = gpa_printer_complete_stub (printer, model,
GPA_SETTINGS (settings));
- cupsqueue = gnome_cups_printer_get_queue (cupsprinter);
add_printer_location (cupsprinter, printer);
attributes_changed_cb (cupsprinter, printer);
- queue_changed_cb (cupsqueue, NULL, printer);
- g_object_unref (cupsqueue);
/* Do we have to add any further instances */
/* FIXME - punt on instance bits for now */
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBBCoSSOIkJWWp2WGURAtotAJ9aB3hhrLu2hII+Oyjr0TErmIXKVgCeMH+M XPgqxeieaJEbEBLJMgD4TLo= =bydc -----END PGP SIGNATURE-----