Commit graph

561 commits

Author SHA1 Message Date
Robert Ancell
f3bf0080d7 printers: Don't pass GDBusConnection references around
An internal GTask will hold a reference to it for the duration of the async call.
2020-09-22 21:23:04 +00:00
Robert Ancell
b2c5056031 printers: Use g_autoptr 2020-09-22 21:23:04 +00:00
Robert Ancell
ec23d22ada printers: Use g_clear_object 2020-09-22 21:23:04 +00:00
Robert Ancell
6db24acc49 Replace whitelist/blacklist terms
For rationale see here:
https://chromium.googlesource.com/chromium/src/+/master/styleguide/inclusive_code.md#racially-neutral
2020-07-21 10:41:55 +12:00
Yuri Chornoivan
e7050ab6f4 Fix minor typos 2020-07-20 10:38:09 +03:00
Robert Ancell
bc648d9c92 printers: Replace PpDevicesList with standard GPtrArray 2020-07-20 14:14:44 +12:00
Robert Ancell
958a7766fd printers: Remove unused finalize methods 2020-07-02 16:20:25 +00:00
Robert Ancell
b994237acd printers: Remove unused class members 2020-07-02 16:20:25 +00:00
Robert Ancell
287aee4371 printers: Don't initialize classes members to NULL/0/FALSE
These are the default values.
2020-07-02 16:20:25 +00:00
Robert Ancell
99c9186fd8 printers: Fix crash on close
It was calling g_free on an object and a warning trying to set a NULL object.
2020-06-30 10:12:55 +00:00
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
Marek Kasik
fb3e693ddf printers: Clear GSource id when printer removal finishes
Remove GSource used for real deletion of a printer when
the "Undo" notification was dismissed.
Also set the timout id of the notitification to 0 when triggered.
Replace cancel_notification_timeout() with one line.

The issue fixed here could be reproduced this way:
1) Open Printers panel
2) Remove a printer
3) Press back button to go to overview
4) Wait 10 seconds
5) Return to the printers panel
6) Close gnome-control-center

Result:
Critical warning on removal of non-existing GSource
2020-06-08 09:34:27 +00:00
Marek Kasik
cdb4727690 printers: Do not crash due to wrong argument
Callback for handling of "notification-dismiss-button" got its
parameters swapped. This resulted in crash when user closed
notification about deleted printer.
This commit converts the on_notification_dismissed() function
to accept swapped arguments as was probably intended.
2020-06-03 18:02:50 +02:00
Elia Geretto
1bf5d4f55f printers: Do not authenticate SMB servers when search field is edited
When the search field in the "Add Printer" dialog is edited, no
authentication with a remote SMB server should be attempted. The server
should just be added to the list and marked with "Server requires
authentication". The user can then authenticate the server by clicking
on it.

The behavior described above is probably the intended one when the code
was written, since there is no closure registered for the
"authentication-required" signal in the function this commit modifies.
This commit should simply restore the intended behavior.

Resolves: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/755
2020-05-12 22:16:32 +00:00
Robert Ancell
fe91d17b43 printers: Remove nesting on a GVariant iteration 2020-03-30 03:24:58 +00:00
Robert Ancell
02d001564a printers: Simplify D-Bus error case branches 2020-03-30 03:24:58 +00:00
Robert Ancell
e256dd57c3 printers: Replace D-Bus unrefs with g_autoptr
This case could leak the GDBusConnection
2020-03-30 03:24:58 +00:00
Robert Ancell
6b79e7ffa1 printers: Replace D-Bus unrefs with g_autoptr 2020-03-30 03:24:58 +00:00
Robert Ancell
2b9815dbf8 printers: Remove unnecessary checks on result of g_variant_get
This always returns a value or hits an assertion.
2020-03-30 03:24:58 +00:00
Robert Ancell
815db8f404 printers: Replace explicit g_variant_unref calls with g_autoptr 2020-03-30 03:24:58 +00:00
Robert Ancell
3a7533da1b printers: Use g_autoptr for the results of D-Bus calls 2020-03-30 03:24:58 +00:00
Robert Ancell
67074b7aea printers: Fix GVariantIter leaks 2020-03-30 03:24:58 +00:00
Robert Ancell
46443af0ca printers: Replace GVariant iteration with direct call to copy value 2020-03-30 03:24:58 +00:00
Robert Ancell
9065850b92 printers: Replace g_variant_iter_next_value with the simpler g_variant_iter_next 2020-03-30 03:24:58 +00:00
Robert Ancell
b7fbe4a72d printers: Use consistent value for GtkBuilder signal properties 2020-03-30 16:18:50 +13:00
Robert Ancell
4502673b6c printers: Connect signals with g_signal_connect_object in swapped form 2020-03-30 16:18:50 +13:00
Felipe Borges
57eae62c6e printers: Add whitespace between top right buttons
Fixes #895
Fixes #685
2020-03-29 22:34:17 +00:00
Felipe Borges
875df8d758 printers: Show the CcPermissionInfobar for all views
We were only presenting the permission infobar when there were
already printers added (printer-list view).

We also want users to see the infobar when they don't have any
printers (empty-page).
2020-02-25 17:59:30 +00:00
Robert Ancell
93b14a4339 panel: Move shared GCancellable code into panel class
Make the panel class provide a cancellable that will be cancelled when the panel
is destroyed. Panel implementations can use this and not have to mangage the
cancellable themselves. Consolidate cases where panels had multiple cancellables
that were all being used for this behaviour.
2020-02-03 09:36:24 +13:00
Felipe Borges
c9eb8ebf41 printers: Use CcPermissionInfobar
This makes the Printers panel consistent with the mockups at
https://gitlab.gnome.org/Teams/Design/settings-mockups/blob/master/users/users.png

See #685, #771 and !671
2020-01-31 14:28:01 +00:00
Marek Kasik
c54db039f8 printers: Avoid read of freed memory
This fixes an issue when on_get_job_attributes_cb()
was called after Printers panel has been finished.
It adds a GCancellable to pp_job_get_attributes_async()
calls.
2020-01-31 14:06:32 +00:00
Robert Ancell
4fe973022a printers: Simplify function 2020-01-28 14:46:53 +00:00
Robert Ancell
c0cd99d2a8 printers: Convert jobs dialog to use GtkTemplate 2020-01-28 14:46:53 +00:00
Robert Ancell
d03da03ee9 printers: Set transient window externally to dialog code 2020-01-28 14:46:53 +00:00
Robert Ancell
181a496a4e printers: Return a GPtrArray instead of GList
This makes the memory able to be managed with g_autoptr.
This fixes a memory leak where the job list was leaked if the operation was cancelled.
2020-01-21 23:12:14 +00:00
Marek Kasik
923b726b3b printers: Provide a scheme to address parser
Add a scheme to the address which we test for correctness
by g_network_address_parse_uri(). It does not work without it.
Use "none" scheme if user did not entered one.
Use port number 0 if user did not specify any.

Fixes #679
2019-10-08 18:05:56 +02:00
Robert Ancell
9a2e821fe5 Initialize autoptr values to NULL.
These cases were safe, but if the code changed this risked freeing uninitialized
memory.
2019-10-03 10:58:38 +13:00
Felipe Borges
e497ad900d printers: Check whether URI is valid while searching for printers
Fixes #679
2019-10-01 18:56:23 +02:00
Philip Chimento
8c08abd0a3 printers: Give printer name fewer characters in width
At the default window size, the printer name label is too wide and
collapses the UI into phone mode. (This is the only panel that shows up
in phone mode by default.) Giving the printer name fewer characters
avoids this.
2019-09-17 07:15:28 +00:00
Philip Chimento
389ee0dfe5 printers: Use CUPS httpConnect2() if available
In CUPS 1.7 httpConnect() and httpConnectEncrypt() were deprecated and
replaced with httpConnect2(). This checks if httpConnect2() is available
and if so, replaces the uses of the deprecated functions.

In the CUPS source code, httpConnect() and httpConnectEncrypt() are now
wrappers around httpConnect2(), so we make sure to use the same
arguments as in the CUPS source code so the two code paths are sure to
be identical:
2c030c7a06/cups/http.c (L412)
2c030c7a06/cups/http.c (L477)
2019-09-16 14:09:40 -07:00
Philip Chimento
96137369a5 build: Fix CUPS PPD deprecation warning
In https://bugzilla.gnome.org/show_bug.cgi?id=696766 it was decided to
build with _PPD_DEPRECATED defined, to suppress the warnings about the
deprecation of the CUPS PPD API, since there was no full replacement
yet. Unfortunately this didn't make it intact through the port to Meson,
so fix it here.
2019-09-16 14:09:40 -07:00
Robert Ancell
b842a33316 printers: Move callbacks into .ui file 2019-09-10 12:36:39 +12:00
Robert Ancell
015c79411a printers: Use gtk_stack_set_visible_child instead of names 2019-09-10 12:36:39 +12:00
Robert Ancell
0ca1632890 printers: Drop unused GtkBuilder IDs 2019-09-10 12:36:39 +12:00
Robert Ancell
60ea08cc64 printers: Make the options dialog a full widget using GtkTemplate 2019-09-10 12:36:38 +12:00
Robert Ancell
6d23ac0892 printers: Make .ui filename match the .c filename 2019-09-10 12:33:11 +12:00
Robert Ancell
d4b47bd9ff printers: Sort variables 2019-09-10 00:18:53 +00:00
Robert Ancell
1b999f36e2 printers: Use gtk_stack_set_visible_child instead of names 2019-09-10 00:18:53 +00:00
Robert Ancell
2c28987e41 printers: Connect signals in swapped form 2019-09-10 00:18:53 +00:00
Robert Ancell
d4adf67549 printers: use gtk_dialog_run 2019-09-10 00:18:53 +00:00