+
+static gboolean
+focus (GtkWidget *widget, GtkDirectionType direction, ModestAttachmentsView *atts_view)
+{
+ ModestAttachmentsViewPrivate *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+ GList *children = NULL;
+ GtkWidget *toplevel = NULL;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!gtk_window_has_toplevel_focus (GTK_WINDOW (toplevel)))
+ return FALSE;
+
+ if (priv->style != MODEST_ATTACHMENTS_VIEW_STYLE_NO_FOCUS) {
+ 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;
+}
+
+void
+modest_attachments_view_set_style (ModestAttachmentsView *self,
+ ModestAttachmentsViewStyle style)
+{
+ ModestAttachmentsViewPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ATTACHMENTS_VIEW (self));
+ priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (self);
+
+ if (priv->style != style) {
+ priv->style = style;
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+ if (priv->style == MODEST_ATTACHMENTS_VIEW_STYLE_SELECTABLE) {
+ GTK_WIDGET_SET_FLAGS (self, GTK_CAN_FOCUS);
+ } else {
+ GTK_WIDGET_UNSET_FLAGS (self, GTK_CAN_FOCUS);
+ }
+
+ }
+}
+
+guint
+modest_attachments_view_get_num_attachments (ModestAttachmentsView *atts_view)
+{
+ ModestAttachmentsViewPrivate *priv;
+ GList *children;
+ gint result;
+
+ g_return_val_if_fail (MODEST_IS_ATTACHMENTS_VIEW (atts_view), 0);
+ priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+ result = g_list_length (children);
+ g_list_free (children);
+
+ return result;
+}