aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/menus/gal-view.c
blob: 19c9d50f85afa95bea45e8b6df6618656d1f535b (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * gal-view-menus.c: Savable state of a table.
 *
 * Author:
 *   Chris Lahey <clahey@helixcode.com>
 *
 * (C) 2000 Helix Code, Inc.
 */
#include <config.h>
#include <stdlib.h>
#include <gtk/gtksignal.h>
#include "gal-view.h"
#include <gal/util/e-util.h>

static void gal_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
static void gal_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);

#define PARENT_TYPE (gtk_object_get_type())

static GtkObjectClass *gv_parent_class;

enum {
    ARG_0,
    ARG_NAME,
};

static void
gv_destroy (GtkObject *object)
{
    GalView *gv = GAL_VIEW (object);

    g_free(gv->name);

    GTK_OBJECT_CLASS (gv_parent_class)->destroy (object);
}

static void
gal_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
    GalView *view;

    view = GAL_VIEW (o);
    
    switch (arg_id){
    case ARG_NAME:
        g_free(view->name);
        view->name = g_strdup(GTK_VALUE_STRING (*arg));
        break;
    }
}

static void
gal_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
    GalView *view;

    view = GAL_VIEW (object);

    switch (arg_id) {
    case ARG_NAME:
        GTK_VALUE_STRING (*arg) = g_strdup(view->name);
        break;
    default:
        arg->type = GTK_TYPE_INVALID;
        break;
    }
}

static void
gv_init (GalView *view)
{
    view->name = NULL;
}

static void
gv_class_init (GtkObjectClass *klass)
{
    gv_parent_class = gtk_type_class (PARENT_TYPE);
    
    klass->destroy = gv_destroy;
    klass->set_arg = gal_view_set_arg;
    klass->get_arg = gal_view_get_arg;

    gtk_object_add_arg_type ("GalView::name", GTK_TYPE_STRING,
                 GTK_ARG_READWRITE, ARG_NAME);
}

E_MAKE_TYPE(gal_view, "GalView", GalView, gv_class_init, gv_init, PARENT_TYPE);

GalView *
gal_view_new (void)
{
    GalView *gv = gtk_type_new (GAL_VIEW_TYPE);

    return (GalView *) gv;
}