]> git.0d.be Git - empathy.git/commitdiff
ContactSelector: mark standard action as the default.
authorWill Thompson <will.thompson@collabora.co.uk>
Tue, 6 Sep 2011 10:25:26 +0000 (11:25 +0100)
committerWill Thompson <will.thompson@collabora.co.uk>
Tue, 6 Sep 2011 17:34:18 +0000 (18:34 +0100)
This allows Gtk+ to style the button differently to indicate that it
will be pressed when the user hits Enter; it also fixes hitting enter in
the New Conversation dialog, which does not consider GTK_RESPONSE_ACCEPT
to be a reasonable response and ignores it. So we get a bug fix and
better styling in exchange for less code!

https://bugzilla.gnome.org/show_bug.cgi?id=658343

libempathy-gtk/empathy-contact-selector-dialog.c

index a4747b488bcbab72872c910a218d26aa1f28b2d8..59d5e071de54effd6cd759f986ac7f2151413dd3 100644 (file)
@@ -232,19 +232,6 @@ contact_selector_change_state_button_cb  (GtkEditable *editable,
   gtk_widget_set_sensitive (dialog->button_action, sensitive);
 }
 
-static void
-entry_activate_cb (GtkEntry *entry,
-    gpointer self)
-{
-  const gchar *id;
-
-  id = gtk_entry_get_text (entry);
-  if (EMP_STR_EMPTY (id))
-    return;
-
-  gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT);
-}
-
 static void
 account_chooser_filter (TpAccount *account,
     EmpathyAccountChooserFilterResultCallback callback,
@@ -311,9 +298,7 @@ empathy_contact_selector_dialog_init (EmpathyContactSelectorDialog *dialog)
                 NULL);
   g_free (filename);
 
-  empathy_builder_connect (gui, dialog,
-      "entry_id", "activate", entry_activate_cb,
-      NULL);
+  gtk_entry_set_activates_default (GTK_ENTRY (priv->entry_id), TRUE);
 
   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
   gtk_container_add (GTK_CONTAINER (content_area), dialog->vbox);
@@ -439,8 +424,12 @@ empathy_contact_selector_dialog_set_property (GObject *self,
 static void
 empathy_contact_selector_dialog_constructed (GObject *dialog)
 {
+  EmpathyContactSelectorDialog *self = EMPATHY_CONTACT_SELECTOR_DIALOG (dialog);
   EmpathyContactSelectorDialogPriv *priv = GET_PRIV (dialog);
 
+  gtk_widget_set_can_default (self->button_action, TRUE);
+  gtk_widget_grab_default (self->button_action);
+
   if (EMPATHY_CONTACT_SELECTOR_DIALOG_GET_CLASS (dialog)->contact_filter)
     {
       GtkEntryCompletion *completion;