* src/widgets/modest-attachments-view.c:
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 19 Sep 2007 21:28:00 +0000 (21:28 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 19 Sep 2007 21:28:00 +0000 (21:28 +0000)
        * Added focus in event. If focus in, we select the first
          attachment available (fixes NB#66101).

pmo-trunk-r3358

src/widgets/modest-attachments-view.c

index 91b6845..6f617a4 100644 (file)
@@ -68,6 +68,7 @@ static gboolean motion_notify_event (GtkWidget *widget, GdkEventMotion *event, M
 static gboolean button_release_event (GtkWidget *widget, GdkEventButton *event, ModestAttachmentsView *atts_view);
 static gboolean key_press_event (GtkWidget *widget, GdkEventKey *event, ModestAttachmentsView *atts_view);
 static gboolean focus_out_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view);
+static gboolean focus_in_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view);
 static GtkWidget *get_att_view_at_coords (ModestAttachmentsView *atts_view,
                                          gdouble x, gdouble y);
 static void unselect_all (ModestAttachmentsView *atts_view);
@@ -262,6 +263,7 @@ modest_attachments_view_instance_init (GTypeInstance *instance, gpointer g_class
        g_signal_connect (G_OBJECT (instance), "motion-notify-event", G_CALLBACK (motion_notify_event), instance);
        g_signal_connect (G_OBJECT (instance), "key-press-event", G_CALLBACK (key_press_event), instance);
        g_signal_connect (G_OBJECT (instance), "focus-out-event", G_CALLBACK (focus_out_event), instance);
+       g_signal_connect (G_OBJECT (instance), "focus-in-event", G_CALLBACK (focus_in_event), instance);
 
        GTK_WIDGET_SET_FLAGS (instance, GTK_CAN_FOCUS);
 
@@ -781,3 +783,18 @@ focus_out_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView
 
        return FALSE;
 }
+
+static gboolean 
+focus_in_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view)
+{
+       ModestAttachmentsViewPrivate *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+       GList *children = NULL;
+
+       children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+       if (children != NULL) {
+               set_selected (atts_view, MODEST_ATTACHMENT_VIEW (children->data));
+       }
+       g_list_free (children);
+
+       return FALSE;
+}