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
This commit is contained in:
Felipe Borges 2017-02-21 15:32:59 +01:00
parent 83f3cb406d
commit 5fa1dede21
2 changed files with 17 additions and 31 deletions

View file

@ -10,8 +10,7 @@
<property name="destroy_with_parent">True</property> <property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<property name="use-header-bar">1</property> <property name="use-header-bar">1</property>
<signal name="response" handler="printer_name_edit_cb" swapped="yes"/> <signal name="response" handler="pp_details_dialog_response_cb"/>
<signal name="response" handler="printer_location_edit_cb" swapped="yes"/>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox"> <object class="GtkBox">
<property name="margin">20</property> <property name="margin">20</property>
@ -37,7 +36,6 @@
<object class="GtkEntry" id="printer_name_entry"> <object class="GtkEntry" id="printer_name_entry">
<property name="halign">fill</property> <property name="halign">fill</property>
<property name="width_request">320</property> <property name="width_request">320</property>
<signal name="focus-out-event" handler="printer_name_edit_cb"/>
<signal name="changed" handler="printer_name_changed"/> <signal name="changed" handler="printer_name_changed"/>
</object> </object>
<packing> <packing>
@ -63,7 +61,6 @@
<object class="GtkEntry" id="printer_location_entry"> <object class="GtkEntry" id="printer_location_entry">
<property name="width_request">320</property> <property name="width_request">320</property>
<property name="halign">fill</property> <property name="halign">fill</property>
<signal name="focus-out-event" handler="printer_location_edit_cb"/>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>

View file

@ -65,14 +65,24 @@ struct _PpDetailsDialogClass
GtkDialogClass parent_class; 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 static void
printer_name_edit_cb (GtkWidget *entry, pp_details_dialog_response_cb (GtkDialog *dialog,
GdkEventFocus *event, gint response_id,
PpDetailsDialog *self) gpointer user_data)
{ {
PpDetailsDialog *self = (PpDetailsDialog*) dialog;
const gchar *new_name; 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)); new_name = gtk_entry_get_text (GTK_ENTRY (self->printer_name_entry));
if (g_strcmp0 (self->printer_name, new_name) != 0) 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); self->printer_name = g_strdup (new_name);
} }
return FALSE;
} }
static void static void
@ -105,24 +113,6 @@ printer_name_changed (GtkEditable *editable,
g_free (title); 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 static void
ppd_names_free (gpointer user_data) 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, search_for_drivers_button);
gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, driver_buttons); 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_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, 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_in_dialog);
gtk_widget_class_bind_template_callback (widget_class, select_ppd_manually); 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 * PpDetailsDialog *