File: prefcolumnview.c

package info (click to toggle)
nip2 8.9.1-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 23,404 kB
  • sloc: ansic: 64,076; sh: 4,681; yacc: 1,133; makefile: 927; lex: 386; xml: 40; perl: 17
file content (128 lines) | stat: -rw-r--r-- 3,103 bytes parent folder | download | duplicates (7)
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
125
126
127
128
/* a view of a column
 */

/*

    Copyright (C) 1991-2003 The National Gallery

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    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.,
    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

 */

/*

    These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk

 */

/* 
#define DEBUG
 */

#include "ip.h"

static ViewClass *parent_class = NULL;

static void 
prefcolumnview_refresh( vObject *vobject )
{
	Prefcolumnview *pcview = PREFCOLUMNVIEW( vobject );
	Column *col = COLUMN( VOBJECT( pcview )->iobject );
	char buf[256];
	char buf2[256];

	escape_markup( IOBJECT( col )->caption, buf2, 256 );
	im_snprintf( buf, 256, "<b>%s</b>", buf2 );
	gtk_label_set_markup( GTK_LABEL( pcview->lab ), buf );

	/* Closed columns are hidden.
	 */
	widget_visible( GTK_WIDGET( pcview ), col->open );

	VOBJECT_CLASS( parent_class )->refresh( vobject );
}

static void
prefcolumnview_child_add( View *parent, View *child )
{
	Prefcolumnview *pcview = PREFCOLUMNVIEW( parent );
	Subcolumnview *sview = SUBCOLUMNVIEW( child );

	VIEW_CLASS( parent_class )->child_add( parent, child );

	gtk_box_pack_end( GTK_BOX( pcview ), GTK_WIDGET( sview ), 
		FALSE, FALSE, 0 );
}

static void
prefcolumnview_class_init( PrefcolumnviewClass *class )
{
	vObjectClass *vobject_class = (vObjectClass *) class;
	ViewClass *view_class = (ViewClass *) class;

	parent_class = g_type_class_peek_parent( class );

	/* Create signals.
	 */

	/* Init methods.
	 */
	vobject_class->refresh = prefcolumnview_refresh;

	view_class->child_add = prefcolumnview_child_add;
}

static void
prefcolumnview_init( Prefcolumnview *pcview )
{
        pcview->lab = gtk_label_new( "" );
        gtk_box_pack_start( GTK_BOX( pcview ), pcview->lab, FALSE, FALSE, 2 );
	gtk_misc_set_padding( GTK_MISC( pcview->lab ), 2, 6 );
	gtk_misc_set_alignment( GTK_MISC( pcview->lab ), 0, 0.5 );

        gtk_widget_show_all( GTK_WIDGET( pcview ) );
}

GtkType
prefcolumnview_get_type( void )
{
	static GtkType type = 0;

	if( !type ) {
		static const GtkTypeInfo info = {
			"Prefcolumnview",
			sizeof( Prefcolumnview ),
			sizeof( PrefcolumnviewClass ),
			(GtkClassInitFunc) prefcolumnview_class_init,
			(GtkObjectInitFunc) prefcolumnview_init,
			/* reserved_1 */ NULL,
			/* reserved_2 */ NULL,
			(GtkClassInitFunc) NULL,
		};

		type = gtk_type_unique( TYPE_VIEW, &info );
	}

	return( type );
}

View *
prefcolumnview_new( void )
{
	Prefcolumnview *pcview = gtk_type_new( TYPE_PREFCOLUMNVIEW );

	return( VIEW( pcview ) );
}