Editing mode on click
authorDavyd Madeley <davyd@madeley.id.au>
Fri, 10 Apr 2009 16:54:31 +0000 (16:54 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 10 Apr 2009 16:54:31 +0000 (16:54 +0000)
From: Davyd Madeley <davyd@madeley.id.au>

svn path=/trunk/; revision=2791

libempathy-gtk/empathy-presence-chooser.c

index 1d84c52e0c600fbbec5b18eb7c0821c8d3de6fdb..74eefee2ab70061fecad059a493fbbff24cfb8ae 100644 (file)
@@ -362,6 +362,25 @@ entry_key_press_event_cb (EmpathyPresenceChooser   *self,
        return FALSE; /* send this event elsewhere */
 }
 
+static gboolean
+entry_button_press_event_cb (EmpathyPresenceChooser *self,
+                             GdkEventButton         *event,
+                            GtkWidget              *entry)
+{
+       EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
+
+       if (!priv->editing_status && event->button == 1)
+       {
+               set_status_editing (self, TRUE);
+               gtk_widget_grab_focus (entry);
+               gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 static void
 text_changed_cb (EmpathyPresenceChooser *self, gpointer user_data)
 {
@@ -525,7 +544,9 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
        g_signal_connect_object (entry, "key-press-event",
                        G_CALLBACK (entry_key_press_event_cb), chooser,
                        G_CONNECT_SWAPPED);
-       // FIXME - should this also happen when the user presses TAB ?
+       g_signal_connect_object (entry, "button-press-event",
+                       G_CALLBACK (entry_button_press_event_cb), chooser,
+                       G_CONNECT_SWAPPED);
 
        GtkCellRenderer *renderer;
        gtk_cell_layout_clear (GTK_CELL_LAYOUT (chooser));