[gnome-control-center] printers: Do not apply rename/location changes in focus-out-event
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Do not apply rename/location changes in focus-out-event
- Date: Wed, 22 Feb 2017 16:06:26 +0000 (UTC)
commit 5fa1dede21dcc931ce109f02e12629d10ba10598
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Feb 21 15:32:59 2017 +0100
printers: Do not apply rename/location changes in focus-out-event
Since we are already applying the changing in the PpDetailsDialog
when it gets closed, there's no need to apply these changes in
the focus-out-event of its respective GtkEntries.
https://bugzilla.gnome.org/show_bug.cgi?id=769114
panels/printers/details-dialog.ui | 5 +---
panels/printers/pp-details-dialog.c | 43 +++++++++++++----------------------
2 files changed, 17 insertions(+), 31 deletions(-)
---
diff --git a/panels/printers/details-dialog.ui b/panels/printers/details-dialog.ui
index 181bbcd..58f2517 100644
--- a/panels/printers/details-dialog.ui
+++ b/panels/printers/details-dialog.ui
@@ -10,8 +10,7 @@
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="use-header-bar">1</property>
- <signal name="response" handler="printer_name_edit_cb" swapped="yes"/>
- <signal name="response" handler="printer_location_edit_cb" swapped="yes"/>
+ <signal name="response" handler="pp_details_dialog_response_cb"/>
<child internal-child="vbox">
<object class="GtkBox">
<property name="margin">20</property>
@@ -37,7 +36,6 @@
<object class="GtkEntry" id="printer_name_entry">
<property name="halign">fill</property>
<property name="width_request">320</property>
- <signal name="focus-out-event" handler="printer_name_edit_cb"/>
<signal name="changed" handler="printer_name_changed"/>
</object>
<packing>
@@ -63,7 +61,6 @@
<object class="GtkEntry" id="printer_location_entry">
<property name="width_request">320</property>
<property name="halign">fill</property>
- <signal name="focus-out-event" handler="printer_location_edit_cb"/>
</object>
<packing>
<property name="left-attach">1</property>
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index 6a98f88..4473d22 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -65,14 +65,24 @@ struct _PpDetailsDialogClass
GtkDialogClass parent_class;
};
-G_DEFINE_TYPE (PpDetailsDialog, pp_details_dialog, GTK_TYPE_DIALOG);
+G_DEFINE_TYPE (PpDetailsDialog, pp_details_dialog, GTK_TYPE_DIALOG)
-static gboolean
-printer_name_edit_cb (GtkWidget *entry,
- GdkEventFocus *event,
- PpDetailsDialog *self)
+static void
+pp_details_dialog_response_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
{
+ PpDetailsDialog *self = (PpDetailsDialog*) dialog;
const gchar *new_name;
+ const gchar *new_location;
+
+ new_location = gtk_entry_get_text (GTK_ENTRY (self->printer_location_entry));
+ if (g_strcmp0 (self->printer_location, new_location) != 0)
+ {
+ printer_set_location (self->printer_name, new_location);
+
+ self->printer_location = g_strdup (new_location);
+ }
new_name = gtk_entry_get_text (GTK_ENTRY (self->printer_name_entry));
if (g_strcmp0 (self->printer_name, new_name) != 0)
@@ -81,8 +91,6 @@ printer_name_edit_cb (GtkWidget *entry,
self->printer_name = g_strdup (new_name);
}
-
- return FALSE;
}
static void
@@ -105,24 +113,6 @@ printer_name_changed (GtkEditable *editable,
g_free (title);
}
-static gboolean
-printer_location_edit_cb (GtkWidget *entry,
- GdkEventFocus *event,
- PpDetailsDialog *self)
-{
- const gchar *location;
-
- location = gtk_entry_get_text (GTK_ENTRY (self->printer_location_entry));
- if (g_strcmp0 (self->printer_location, location) != 0)
- {
- printer_set_location (self->printer_name, location);
-
- self->printer_location = g_strdup (location);
- }
-
- return FALSE;
-}
-
static void
ppd_names_free (gpointer user_data)
{
@@ -379,12 +369,11 @@ pp_details_dialog_class_init (PpDetailsDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, search_for_drivers_button);
gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, driver_buttons);
- gtk_widget_class_bind_template_callback (widget_class, printer_name_edit_cb);
gtk_widget_class_bind_template_callback (widget_class, printer_name_changed);
- gtk_widget_class_bind_template_callback (widget_class, printer_location_edit_cb);
gtk_widget_class_bind_template_callback (widget_class, search_for_drivers);
gtk_widget_class_bind_template_callback (widget_class, select_ppd_in_dialog);
gtk_widget_class_bind_template_callback (widget_class, select_ppd_manually);
+ gtk_widget_class_bind_template_callback (widget_class, pp_details_dialog_response_cb);
}
PpDetailsDialog *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]