From 4c56f91672941396112202617345b1b0445c29e0 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 6 Sep 2011 11:25:26 +0100 Subject: 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 file changed, 5 insertions(+), 16 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-selector-dialog.c b/libempathy-gtk/empathy-contact-selector-dialog.c index a4747b488..59d5e071d 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.c +++ b/libempathy-gtk/empathy-contact-selector-dialog.c @@ -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; -- cgit v1.2.3