[empathy] ContactSelector: mark standard action as the default.



commit 4c56f91672941396112202617345b1b0445c29e0
Author: Will Thompson <will thompson collabora co uk>
Date:   Tue Sep 6 11:25:26 2011 +0100

    ContactSelector: mark standard action as the default.
    
    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 |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-selector-dialog.c b/libempathy-gtk/empathy-contact-selector-dialog.c
index a4747b4..59d5e07 100644
--- a/libempathy-gtk/empathy-contact-selector-dialog.c
+++ b/libempathy-gtk/empathy-contact-selector-dialog.c
@@ -233,19 +233,6 @@ contact_selector_change_state_button_cb  (GtkEditable *editable,
 }
 
 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,
     gpointer callback_data,
@@ -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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]