[patch] don't poll individual jobs



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?

--- 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 */

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]