aboutsummaryrefslogtreecommitdiffstats
path: root/mail/folder-browser.c
blob: 63cf7566fb62490bd2a58b8ae78460050d5e8c28 (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
/*
 * folder-browser.c: Folder browser top level component
 *
 * Author:
 *   Miguel de Icaza (miguel@kernel.org)
 *
 * (C) 2000 Helix Code, Inc.
 */

#include <config.h>
#include "folder-browser.h"

#define PARENT_TYPE (gtk_table_get_type ())

static GtkObjectClass *folder_browser_parent_class;

#define PROPERTY_FOLDER_URI "folder_uri"

static void
folder_browser_destroy (GtkObject *object)
{
    FolderBrowser *folder_browser = FOLDER_BROWSER (object);

    folder_browser_parent_class->destroy (object);
}

static void
folder_browser_class_init (GtkObjectClass *object_class)
{
    object_class->destroy = folder_browser_destroy;

    folder_browser_parent_class = gtk_type_class (PARENT_TYPE);
}

#define EQUAL(a,b) (strcmp (a,b) == 0)

void
folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri)
{
    g_free (folder_browser->uri);
    folder_browser->uri = g_strudp (uri);
}

static void
folder_browser_property_changed (GnomePropertyBag *properties,
                 const char *name,
                 const char *type,
                 gpointer old_value,
                 gpointer new_value,
                 gpointer user_data)
{
    FolderBrowser *folder_browser = FOLDER_BROWSER (user_data);

    if (EQUAL (name, PROPERTY_FOLDER_URI)){
        folder_browser_set_uri (folder_browser, new_value);
        return;
    }
}

static void
folder_browser_init (GtkObject *object)
{
    FolderBrowser *fb = FOLDER_BROWSER (object);

    fb->properties = gnome_property_bag_new ();

    gnome_property_bag_add (
        fb->properties, PROPERTY_FOLDER_URI, "string",
        NULL, NULL, _("The URI that the Folder Browser will display", 0);

    gtk_signal_connect (GTK_OBJECT (fb->properties), "value_changed",
                property_changed, fb);
}

GtkWidget *
folder_browser_new (void)
{
    FolderBrowser *folder_browser = gtk_type_new (folder_browser_get_type ());
    GtkTable *table = GTK_TABLE (folder_browser);
    
    table->homogeous = FALSE;
    gtk_table_resize (table, 1, 2);

    return GTK_WIDGET (folder_browser);
}


E_MAKE_TYPE (folder_browser, "FolderBrowser", FolderBrowser, folder_browser_class_init, folder_browser_init, PARENT_TYPE);