Commit graph

179 commits

Author SHA1 Message Date
Robert Ancell
ae1a37b009 printers: Remove use of gtk_widget_show_all
It is removed in GTK 4.
2020-11-26 16:02:57 +00:00
Robert Ancell
06eb07bbd6 printers: Remove dead PPD dialog code 2020-11-10 14:47:20 +13:00
Robert Ancell
902f90e5ea printers: Add methods for getting printer name and location
Remove the GObject properties that aren't type safe.
2020-10-29 20:36:48 +00:00
Robert Ancell
2def271824 printers: Add pp_job_new and associated methods.
The previous code was leaking a string (job title), used an integer pointer
instead of an integer for an id and requited a lot of memory management for a
string array. There was a lot of boilerplate code required for property
management which was not being used much. This is why type safe methods are a
much better idea than GObject properties. :)
2020-10-27 13:03:56 +00:00
Robert Ancell
68042c95c1 printers: Use a shared PpCups object 2020-09-22 21:23:05 +00:00
Robert Ancell
b25db4f601 printers: Don't pass PpJob references around
An internal GTask will hold a reference to it for the duration of the async calls.
2020-09-22 21:23:05 +00:00
Robert Ancell
9d0815bb90 printers: Don't pass PpCups references around
An internal GTask will hold a reference to it for the duration of the async calls.
2020-09-22 21:23:05 +00:00
Robert Ancell
703d833e2f printers: Don't pass PpPrinter references around
An internal GTask will hold a reference to it for the duration of the async call.
2020-09-22 21:23:05 +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
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
Robert Ancell
815db8f404 printers: Replace explicit g_variant_unref calls with g_autoptr 2020-03-30 03:24:58 +00: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
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
Georges Basile Stavracas Neto
75f150d5a2 shell: Add position to cc_shell_embed_widget_in_header()
So we can control where the widget should be added to. The
main window only supports left and right positions.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/528
2019-05-21 12:59:36 -03:00
Robert Ancell
e9b9966e7d printers: Use g_autoptr with strings 2019-02-05 10:26:15 +13:00
Robert Ancell
85604ab4f0 printers: Simplify finalize/dispose methods
Use g_clear_* functions to simplify code and ensure values are set to NULL after freeing.
2019-01-30 11:33:28 +13:00
Robert Ancell
4042cb5d33 printers: Replace GObject boilerplace with G_DECLARE_TYPE 2019-01-30 11:33:28 +13:00
Robert Ancell
877445cbaf printers: Use g_autoptr for GError handling 2018-09-17 15:19:21 +00:00
Robert Ancell
55d47bc83e printers: Plug memory leaks 2018-06-25 22:53:10 +00:00
Felipe Borges
8879cd476a printers: Fix crash when panel is closed quickly
Fix a user-after-free while testing the connectivity to a cups
server. This is similar to the fix in commit 1d72a0b.

This is an addition to the changes introduced in commit 2ff5cfd
which allowed the connection testing to be cancellable.

Fixes #51
Fixes https://bugzilla.gnome.org/794632
2018-04-09 13:26:55 +02:00
Georges Basile Stavracas Neto
28ad1d1602 printers: Cache CUPS D-Bus proxy 2018-04-06 22:23:39 -03:00
Marek Kasik
873c2c6839 Printers: Add commandline action "show-jobs"
Add action "show-jobs" to printers panel which
gets printer name as a parameter and shows user
jobs dialog.
Syntax for trigerring this action looks like:
"gnome-control-center printers show-jobs my-local-printer".

https://bugzilla.gnome.org/show_bug.cgi?id=758170
2018-02-26 14:33:30 +01:00
Marek Kasik
91328078fe Printers: Fix GVariant handling
Some const strings taken from GVariants were used
after their GVariants were unreffed.

https://bugzilla.gnome.org/show_bug.cgi?id=758170
2018-02-26 14:33:27 +01:00
Marek Kasik
aa0819894f Printers: Add commandline action "authenticate-jobs"
Add action "authenticate-jobs" to printers panel which
gets printer name as a parameter and asks user for
credentials.
Syntax for trigerring this action looks like:
"gnome-control-center printers authenticate-jobs my-local-printer".

https://bugzilla.gnome.org/show_bug.cgi?id=758170
2018-02-20 01:13:13 +01:00
Felipe Borges
2ff5cfd6aa printers: Make the cups connection test cancellable
Currently gnome-control-center could crash whenever a connection
test is interrupted by the disposal of the Printers panel.

Searching in the g-c-c shell for any query that could match the
Printers panel would instantiate the CcPrintersPanel class. Since
we perform a connection test to the printing server as soon as this
object is created, a fast disposal of the panel (by choosing another
search result) would cause the whole application to crash.

https://bugzilla.gnome.org/show_bug.cgi?id=792753
2018-02-09 13:27:25 +01:00
Felipe Borges
db9017bf30 printers: Hide header buttons when there's no printer server
There's no reason to "Unlock" the panel and/or "Add" a new printer
if there's no printer server available.

This patch sets the visibility of the "headerbar-buttons" based on
whether the current visible stack page in the panel is the
"no-cups-page".

https://bugzilla.gnome.org/show_bug.cgi?id=778599
2018-02-05 14:21:05 +01:00
Felipe Borges
34565466a2 printers: Don't show duplicates while renaming printer
During the time it took to rename a printer asynchronously, we had
cases where two entries were shown for the same printer: one with
the old name and another with a new name.

Now we signal from DetailsDialog to the given PrinterEntry which
passes it along to the main panel object. The CcPrintersPanel object
blacklists the renamed printer old name.

https://bugzilla.gnome.org/show_bug.cgi?id=790361
2018-02-05 14:15:10 +01:00
Rui Matos
535c5d1fa2 printers: Disconnect the search bar from the shell's key-press-event
Using g_connect_object() ensures the disconnection happens when the
search bar is finalized.

https://bugzilla.gnome.org/show_bug.cgi?id=786603
2017-08-23 14:30:20 +02:00
Mohammed Sadiq
d5110977da printers: Check if printer name is NULL
This was causing a segfault when the user clicks the cancel button
on add new printer dialog (in case when no printers are listed, and no
printers are added).

output from sanitizer:

==22669==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fe1c7a4d409 bp 0x7ffd179f6410 sp 0x7ffd179f6410 T0)
    #0 0x7fe1c7a4d408 in g_str_hash /home/sadiq/jhbuild/checkout/glib/glib/ghash.c:1882
    #1 0x7fe1c7a4c814 in g_hash_table_lookup_node /home/sadiq/jhbuild/checkout/glib/glib/ghash.c:379
    #2 0x7fe1c7a4c814 in g_hash_table_lookup /home/sadiq/jhbuild/checkout/glib/glib/ghash.c:1153
    #3 0x55cef023a121 in new_printer_dialog_response_cb /home/sadiq/jhbuild/checkout/gnome-control-center/panels/printers/cc-printers-panel.c:914

https://bugzilla.gnome.org/show_bug.cgi?id=783406
2017-06-23 13:32:42 +02:00
Felipe Borges
0d0b42eb50 printers: Hide supply level bar when there is no inklevel data
https://bugzilla.gnome.org/show_bug.cgi?id=779702
2017-06-15 15:39:22 +02:00
Felipe Borges
6dcf057a53 printers: Scroll view to show newly added Printer
In scenarios with a long list of printers, it might be difficult
to find a newly added printer.

This patch make the view scroll to the allocated position of the
printer entry.

https://bugzilla.gnome.org/show_bug.cgi?id=779506
2017-05-29 17:49:11 +02:00
Felipe Borges
f3141e430b printers: Drop "select_new_printer" property leftover
The select_new_printer property used to be an indicator whether
the view should change to present the newly added printer.

With the Printers presented as a list in the new design, there's
no need for this flag.

https://bugzilla.gnome.org/show_bug.cgi?id=779506
2017-05-29 17:34:55 +02:00
Piotr Drąg
21d697cbe5 printers: Use Unicode quotation marks in a translatable string
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772199
2017-05-26 16:10:47 +02:00
Felipe Borges
e5624f90bf printers: Add 10s timeout for printer removal
Dismisses the Printer removal notification after 10 seconds,
removing the printer permanently.

The 10 seconds value is taken from the online-accounts panel.

https://bugzilla.gnome.org/show_bug.cgi?id=693187
2017-05-26 13:16:39 +02:00
Felipe Borges
f065f5005f printers: Allow undoing deletion of a printer
Instead of directly applying the deletion of a printer, we should
follow the GNOME in-app notification deletion guidelines.

This patch introduces the in-app notification following the HIG[0]
for the deletion of a printer. It allows to "undo" the deletion.

The default behavior for these notification is to dismiss a previous
notification. In doing so, when deleting multiple printers, the
"Undo" button only restores the last deleted one. We don't do batch/
bulk removal in the printers panel.

[0] https://developer.gnome.org/hig/stable/in-app-notifications.html.en

https://bugzilla.gnome.org/show_bug.cgi?id=693187
2017-05-26 13:16:39 +02:00
Felipe Borges
870b4e7190 printers: Filter the printer-location in the search
Show printer search results where the searched string matches
the printer-location.

https://bugzilla.gnome.org/show_bug.cgi?id=779656
2017-05-10 11:04:29 +02:00
Felipe Borges
34aedbe992 printers: Add search capabilities to the panel
Due to the recent changes towards the new design, it became slightly
harder to find a printer given a long list of entries.

This patch introduces search capabilities to the panel, filtering
based on the printer name.

https://bugzilla.gnome.org/show_bug.cgi?id=779656
2017-05-09 15:52:12 +02:00
Felipe Borges
e26756d7e3 printers: Make printers-list a GtkListBox
By making the printers list a GtkListBox instead of a GtkBox, we
can use listbox's capabilities for sorting and filter.

https://bugzilla.gnome.org/show_bug.cgi?id=779656
2017-05-09 15:47:04 +02:00
Felipe Borges
519e19f974 printers: Make actualize_printers_list cancellable
This way we can safely interrupt an update without crashing
g-c-c.

https://bugzilla.gnome.org/show_bug.cgi?id=780299
2017-03-28 18:04:56 +02:00
Felipe Borges
89ff6a610e printers: Store PpPrinterEntry instances for individual manipulation
We were actualizing the whole printers collection everytime
something should change.

These patch introduces a HashTable keyed by the unique printer.name,
which allows us to access individual instances of PpPrinterEntry.

https://bugzilla.gnome.org/show_bug.cgi?id=779079
2017-02-27 16:29:43 +01:00