gnome-control-center/panels/printers/pp-printer-entry.h
Marek Kasik dfbe1faea2 printers: Update GtkListBox of printers consecutively
Goal of this commit is to not overwhelm UI when a lot of printers is added
to CUPS. You can reproduce this situation when you add e.g. 30 printers using
lpadmin. Th UI stops to respond for some time.

To do so, the printer entries are not deleted every time there is a request
for updating of the list of printers but only new printer entries are added
and printer entries of deleted printers are removed. Other printer
entries are just updated by new method pp_printer_entry_update().
Which, by the way, is almost whole taken from pp_printer_entry_new().

This needed to add sort function for the list of printer entries. It sorts
printers according to their names not taking case into account.

In the similar manner, the filter function was extended to not show printers
which are being deleted. This needs a list of names of deleted printers
which we keep until they are really deleted.
One important thing here is the "reference" object which points to the panel
itself via its "self" key. We pass this object to the pp_printer_delete_async()'s
callback so it knows whether it can remove the printer's name from the list
of deleted printers (once the panel is being destroyed it clears the key itself).
2020-06-22 11:57:57 +00:00

41 lines
1.6 KiB
C

/*
* Copyright 2017 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Felipe Borges <felipeborges@gnome.org>
*/
#pragma once
#include <gtk/gtk.h>
#include <cups/cups.h>
#define PP_PRINTER_ENTRY_TYPE (pp_printer_entry_get_type ())
G_DECLARE_FINAL_TYPE (PpPrinterEntry, pp_printer_entry, PP, PRINTER_ENTRY, GtkListBoxRow)
PpPrinterEntry *pp_printer_entry_new (cups_dest_t printer,
gboolean is_authorized);
void pp_printer_entry_update_jobs_count (PpPrinterEntry *self);
GSList *pp_printer_entry_get_size_group_widgets (PpPrinterEntry *self);
void pp_printer_entry_show_jobs_dialog (PpPrinterEntry *self);
void pp_printer_entry_authenticate_jobs (PpPrinterEntry *self);
void pp_printer_entry_update (PpPrinterEntry *self,
cups_dest_t printer,
gboolean is_authorized);