File: valueview.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 (168 lines) | stat: -rw-r--r-- 4,066 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* display a minimal graphic for an object (just the caption)
 */

/*

    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 GraphicviewClass *parent_class = NULL;

static void 
valueview_refresh( vObject *vobject )
{
	Valueview *valueview = VALUEVIEW( vobject );
	Model *model = MODEL( vobject->iobject );

#ifdef DEBUG
	printf( "valueview_refresh: " );
	row_name_print( HEAPMODEL( model )->row );
	printf( "\n" );
#endif /*DEBUG*/

	set_gcaption( valueview->label, "%s", NN( IOBJECT( model )->caption ) );

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

static void
valueview_link( View *view, Model *model, View *parent )
{
	Valueview *valueview = VALUEVIEW( view );
	Rowview *rview = ROWVIEW( parent->parent );

	VIEW_CLASS( parent_class )->link( view, model, parent );

	(void) rowview_menu_attach( rview, valueview->eb );
}

static void
valueview_class_init( ValueviewClass *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 = valueview_refresh;

	view_class->link = valueview_link;
}

static gboolean
valueview_event_cb( GtkWidget *widget, GdkEvent *ev, 
	Valueview *valueview )
{
	Model *model = MODEL( VOBJECT( valueview )->iobject );
	Row *row = HEAPMODEL( model )->row;

	gboolean handled = FALSE;

        switch( ev->type ) {
        case GDK_BUTTON_PRESS:
		if( ev->button.button == 1 ) {
			row_select_modifier( row, ev->button.state );
			handled = TRUE;
		}
		break;

        case GDK_2BUTTON_PRESS:
		if( ev->button.button == 1 ) {
			model_edit( widget, MODEL( model ) );

			handled = TRUE;
		}
		break;

	default:
		break;
	}

	return( handled );
}

static void
valueview_init( Valueview *valueview )
{
#ifdef DEBUG
	printf( "valueview_init\n" );
#endif /*DEBUG*/

        valueview->eb = gtk_event_box_new();
	gtk_widget_add_events( GTK_WIDGET( valueview->eb ), 
		GDK_POINTER_MOTION_HINT_MASK ); 
        gtk_box_pack_start( GTK_BOX( valueview ), 
		valueview->eb, FALSE, FALSE, 0 );
	valueview->label = gtk_label_new( "" );
        gtk_misc_set_alignment( GTK_MISC( valueview->label ), 0, 0.5 );
        gtk_misc_set_padding( GTK_MISC( valueview->label ), 2, 0 );
        gtk_container_add( GTK_CONTAINER( valueview->eb ), valueview->label );
	gtk_widget_set_name( valueview->eb, "caption_widget" );
        gtk_signal_connect( GTK_OBJECT( valueview->eb ), "event",
                GTK_SIGNAL_FUNC( valueview_event_cb ), valueview );

        gtk_widget_show_all( GTK_WIDGET( valueview->eb ) );
}

GtkType
valueview_get_type( void )
{
	static GtkType valueview_type = 0;

	if( !valueview_type ) {
		static const GtkTypeInfo info = {
			"Valueview",
			sizeof( Valueview ),
			sizeof( ValueviewClass ),
			(GtkClassInitFunc) valueview_class_init,
			(GtkObjectInitFunc) valueview_init,
			/* reserved_1 */ NULL,
			/* reserved_2 */ NULL,
			(GtkClassInitFunc) NULL,
		};

		valueview_type = gtk_type_unique( TYPE_GRAPHICVIEW, &info );
	}

	return( valueview_type );
}

View *
valueview_new( void )
{
	Valueview *valueview = gtk_type_new( TYPE_VALUEVIEW );

	return( VIEW( valueview ) );
}