aboutsummaryrefslogtreecommitdiffstats
path: root/mail/message-browser.c
blob: 4e42bdd35c39b2685e69acdab05b1cba264daa10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Authors: Jeffrey Stedfast <fejj@ximian.com>
 *
 *  Copyright 2001 Ximian, Inc. (www.ximian.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gal/util/e-util.h>
#include <gal/widgets/e-unicode.h>

#include "message-browser.h"

#include "mail-display.h"

#include "mail-local.h"
#include "mail-config.h"

#define d(x) 

#define MINIMUM_WIDTH  600
#define MINIMUM_HEIGHT 400

#define PARENT_TYPE GTK_TYPE_WINDOW

/* Size of the window last time it was changed.  */
static GtkAllocation last_allocation = { 0, 0 };

static GtkWindowClass *parent_class = NULL;


static void
message_browser_class_init (GtkObjectClass *object_class)
{
    parent_class = gtk_type_class (PARENT_TYPE);
}

static void
message_browser_init (GtkObject *object)
{
    
}

GtkType
message_browser_get_type (void)
{
    static GtkType type = 0;
    
    if (!type) {
        GtkTypeInfo type_info = {
            "MessageBrowser",
            sizeof (MessageBrowser),
            sizeof (MessageBrowserClass),
            (GtkClassInitFunc) message_browser_class_init,
            (GtkObjectInitFunc) message_browser_init,
            (GtkArgSetFunc) NULL,
            (GtkArgGetFunc) NULL
        };
        
        type = gtk_type_unique (gtk_window_get_type (), &type_info);
    }
    
    return type;
}


static void
message_browser_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation)
{
    last_allocation = *allocation;
}

static void
set_default_size (GtkWidget *widget)
{
    int width, height;
    
    width  = MAX (MINIMUM_WIDTH, last_allocation.width);
    height = MAX (MINIMUM_HEIGHT, last_allocation.height);
    
    gtk_window_set_default_size (GTK_WINDOW (widget), width, height);
}

GtkWidget *
message_browser_new (CamelMimeMessage *message)
{
    GtkWidget *new, *mail_display;
    
    new = gtk_widget_new (message_browser_get_type (), NULL);
    gtk_signal_connect (GTK_OBJECT (new), "size_allocate", 
                GTK_SIGNAL_FUNC (message_browser_size_allocate_cb), NULL);
    
    mail_display = mail_display_new ();
    gtk_container_add (GTK_CONTAINER (new), mail_display);
    gtk_widget_show (mail_display);
    
    mail_display_set_message (MAIL_DISPLAY (mail_display), CAMEL_MEDIUM (message), NULL);
    
    set_default_size (new);
    
    return new;
}