[gnome-control-center] printers: Use async rename method
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Use async rename method
- Date: Wed, 22 Feb 2017 16:06:31 +0000 (UTC)
commit ca30e0ead993d63a46a4706a436bacd4a7bfecfd
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Feb 15 15:15:50 2017 +0100
printers: Use async rename method
pp_printer_rename_async is better than the old printer_rename
utility.
The PpDetailsDialog doesn't need to do anything in the callback
since we are emiting the "printer-changed" signal when the dialog
is closed.
https://bugzilla.gnome.org/show_bug.cgi?id=769114
panels/printers/pp-details-dialog.c | 19 +++++++++++++++++--
panels/printers/pp-printer.c | 2 ++
2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index 4473d22..35b65dc 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -36,6 +36,7 @@
#include "cc-editable-entry.h"
#include "pp-details-dialog.h"
#include "pp-ppd-selection-dialog.h"
+#include "pp-printer.h"
#include "pp-utils.h"
struct _PpDetailsDialog {
@@ -68,6 +69,16 @@ struct _PpDetailsDialogClass
G_DEFINE_TYPE (PpDetailsDialog, pp_details_dialog, GTK_TYPE_DIALOG)
static void
+on_printer_rename_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ pp_printer_rename_finish (PP_PRINTER (source_object), result, NULL);
+
+ g_object_unref (source_object);
+}
+
+static void
pp_details_dialog_response_cb (GtkDialog *dialog,
gint response_id,
gpointer user_data)
@@ -87,9 +98,13 @@ pp_details_dialog_response_cb (GtkDialog *dialog,
new_name = gtk_entry_get_text (GTK_ENTRY (self->printer_name_entry));
if (g_strcmp0 (self->printer_name, new_name) != 0)
{
- printer_rename (self->printer_name, new_name);
+ PpPrinter *printer = pp_printer_new (self->printer_name);
- self->printer_name = g_strdup (new_name);
+ pp_printer_rename_async (printer,
+ new_name,
+ NULL,
+ on_printer_rename_cb,
+ NULL);
}
}
diff --git a/panels/printers/pp-printer.c b/panels/printers/pp-printer.c
index 220c932..3854ffe 100644
--- a/panels/printers/pp-printer.c
+++ b/panels/printers/pp-printer.c
@@ -267,6 +267,8 @@ pp_printer_rename_async (PpPrinter *printer,
{
GTask *task;
+ g_return_if_fail (new_printer_name != NULL);
+
task = g_task_new (G_OBJECT (printer), cancellable, callback, user_data);
g_task_set_task_data (task, g_strdup (new_printer_name), g_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]