Commit graph

190 commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
4300a4a290 panels: Use new CcPanel helpers for title widgets
This should significantly simplify these panels, by not forcing
them to override GObject.constructed all the time. Most panels
were quite straightfoward.
2022-01-20 02:23:42 +00:00
Georges Basile Stavracas Neto
0ab20af9ba panels: Switch to CcPanel content
Start porting panels to the new panel format. This commit
temporarily makes panels have two titlebar, which will be
fixed soon.
2022-01-20 02:23:42 +00:00
Georges Basile Stavracas Neto
8141af469c printers: Port to GTK4
Fortunately for us GtkTreeView still operates pretty
much exactly like in GTK3. Other than that, it's a
dense junction of all that we've done so far to port
other panels.
2021-12-14 22:34:21 -03:00
zhuyaliang
51760441b3 printers: Add adjust printer task priority button
Add a new  button to the 'PpJobRow',This button can adjust the priority of tasks in the print queue to the highest
2021-11-10 15:10:20 +00:00
Brandon Nielsen
c3c58aae38 Code cleanup based on feedback. 2021-07-26 16:03:05 +00:00
Brandon Nielsen
b19325167d gtk_widget_show over gtk_widget_show_all. 2021-07-26 16:03:05 +00:00
Brandon Nielsen
6223858c5e Formatting cleanup. 2021-07-26 16:03:05 +00:00
Brandon Nielsen
16aa95bdc8 Return a PpNewPrinter instead of PpPrintDevice, use gtk_show_all
pp_new_printer_dialog_get_new_print_device is replaced with
pp_new_printer_dialog_get_new_printer which returns a PpNewPrinter.

gtk_show_all is used instead of gtk_dialog_run for PpNewPrinterDialog
and PpPPDSelectionDialog.

This is in response to feedback:
https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/930#note_1202114
2021-07-26 16:03:05 +00:00
Brandon Nielsen
179bda1b64 Make PpNewPrinterDialog a GtkDialog instead of GObject
This is accomplished by moving the calls to pp_printer_add_async
directly to CcPrintersPanel. pp_printer_delete_async calls are already
done directly in the CcPrintersPanel so there is consistency gained by
this implementation in addition to PpNewPrinterDialog actually being a
GtkDialog.

A pp_new_printer_dialog_get_new_print_device method has been added to
PpNewPrinterDialog to allow getting the PpPrintDevice selected by the
user to add. This can be called anytime after a response callback
with a GTK_RESPONSE_OK reponse_id.

PpNewPrinterDialog still does asynchronous operations to populate the
dialog, but the create dialog -> receive signal -> destroy dialog flow
can all be handled like a traditional GtkDialog without additional
callbacks or signalling.
2021-07-26 16:03:05 +00:00
Eric
1fc8b772a4 printers: Make "Add…" button consistent with user accounts panel
The "Add..." toolbar button on the printers panel is currently hidden until the panel is unlocked.
This commit makes the button visible but insensitive when the panel is locked (becoming sensitive when unlocked),
as suggested in #1213. It also changes the text from "Add..." to "Add Printer..."
and updates the subtitle in the infobar to "Unlock to Add Printers and Change Settings."
These changes make the button's UI consistent with the Accounts panel's "Add User..." toolbar button.

Closes #1213
2021-06-09 13:34:01 +00:00
Robert Ancell
5b086c44e8 printers: Don't pass ownership in get_all_ppds_async callback 2021-02-15 10:34:32 +13:00
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