aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table-sort-info.c
blob: 9e8d6e8228b6820b9fbe2c2b175ae59aab1ff804 (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
121
122
123
124
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * e-table-sort-info.c: a Table Model
 *
 * Author:
 *   Miguel de Icaza (miguel@gnu.org)
 *
 * (C) 1999 Helix Code, Inc.
 */
#include <config.h>
#include <gtk/gtksignal.h>
#include <gnome-xml/tree.h>
#include "e-table-sort-info.h"

#define ETM_CLASS(e) ((ETableSortInfoClass *)((GtkObject *)e)->klass)

#define PARENT_TYPE gtk_object_get_type ();
                      

static GtkObjectClass *e_table_sort_info_parent_class;

enum {
    SORT_INFO_CHANGED,
    LAST_SIGNAL
};

static guint e_table_sort_info_signals [LAST_SIGNAL] = { 0, };

enum {
    ARG_0,
    ARG_GROUPING
};

static void
etsi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
    ETableSortInfo *etsi;

    etsi = E_TABLE_SORT_INFO (o);

    switch (arg_id){
    case ARG_GROUPING:
        etsi->grouping = GTK_VALUE_POINTER (*arg);
        break;
    }
}

static void
etsi_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
    ETableSortInfo *etsi;

    etsi = E_TABLE_SORT_INFO (o);

    switch (arg_id){
    case ARG_GROUPING:
        GTK_VALUE_POINTER (*arg) = etsi->grouping;
        break;
    }
}

static void
e_table_sort_info_class_init (GtkObjectClass *object_class)
{
    e_table_sort_info_parent_class = gtk_type_class (gtk_object_get_type ());
    
    object_class->set_arg = etsi_set_arg;
    object_class->get_arg = etsi_get_arg;

    e_table_sort_info_signals [SORT_INFO_CHANGED] =
        gtk_signal_new ("sort_info_changed",
                GTK_RUN_LAST,
                object_class->type,
                GTK_SIGNAL_OFFSET (ETableSortInfoClass, sort_info_changed),
                gtk_marshal_NONE__NONE,
                GTK_TYPE_NONE, 0);

    gtk_object_class_add_signals (object_class, e_table_sort_info_signals, LAST_SIGNAL);

    gtk_object_add_arg_type ("ETableSortInfo::grouping", GTK_TYPE_POINTER,
                 GTK_ARG_READWRITE, ARG_GROUPING);
}


guint
e_table_sort_info_get_type (void)
{
  static guint type = 0;

  if (!type)
    {
      GtkTypeInfo info =
      {
    "ETableSortInfo",
    sizeof (ETableSortInfo),
    sizeof (ETableSortInfoClass),
    (GtkClassInitFunc) e_table_sort_info_class_init,
    NULL,
    /* reserved_1 */ NULL,
        /* reserved_2 */ NULL,
        (GtkClassInitFunc) NULL,
      };

      type = gtk_type_unique (gtk_object_get_type (), &info);
    }

  return type;
}

void
e_table_sort_info_changed (ETableSortInfo *e_table_sort_info)
{
    g_return_if_fail (e_table_sort_info != NULL);
    g_return_if_fail (E_IS_TABLE_SORT_INFO (e_table_sort_info));
    
    gtk_signal_emit (GTK_OBJECT (e_table_sort_info),
             e_table_sort_info_signals [SORT_INFO_CHANGED]);
}

ETableSortInfo *
e_table_sort_info_new (void)
{
    return gtk_type_new (e_table_sort_info_get_type ());
}