File: kz-gesture.h

package info (click to toggle)
kazehakase 0.5.8-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,184 kB
  • ctags: 7,837
  • sloc: ansic: 64,119; sh: 19,622; cpp: 12,601; ruby: 1,590; makefile: 1,437; xml: 464
file content (131 lines) | stat: -rw-r--r-- 4,472 bytes parent folder | download | duplicates (5)
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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *  Copyright (C) 2003 Takuro Ashie
 *
 *  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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __KZ_GESTURE_H__
#define __KZ_GESTURE_H__

#include <gtk/gtk.h>

G_BEGIN_DECLS

#define KZ_TYPE_GESTURE			(kz_gesture_get_type ())
#define KZ_GESTURE(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_GESTURE, KzGesture))
#define KZ_GESTURE_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_GESTURE, KzGestureClass))
#define KZ_IS_GESTURE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_GESTURE))
#define KZ_IS_GESTURE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_GESTURE))
#define KZ_GESTURE_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_GESTURE, KzGestureClass))

typedef struct _KzGesture	KzGesture;
typedef struct _KzGestureClass	KzGestureClass;
typedef struct _KzGestureItem	KzGestureItem;
typedef struct _KzGestureItems	KzGestureItems;

#define	KZ_GESTURE_MOTION_TERMINATOR	'\0'
#define	KZ_GESTURE_MOTION_UP		'U'
#define	KZ_GESTURE_MOTION_DOWN		'D'
#define	KZ_GESTURE_MOTION_LEFT		'L'
#define	KZ_GESTURE_MOTION_RIGHT		'R'

typedef gchar KzGestureMotion;

struct _KzGesture
{
	GObject parent;

	KzGestureMotion  sequence[32];
	gint             sequence_len;
	gint             max_sequence_len;
	gint             current_mode;
	gint             prev_x, prev_y;
	gint             x, y;
	gboolean         started;
	gint             threshold;

	KzGestureItems  *items;
};

struct _KzGestureClass
{
	GObjectClass parent_class;

	/* -- signals -- */
	void (*start)        (KzGesture *gesture);
	void (*cancel)       (KzGesture *gesture);
	void (*stack_motion) (KzGesture *gesture,
			      KzGestureMotion motion);
	void (*perform)      (KzGesture *gesture);
};

struct _KzGestureItem
{
	GtkAction       *action;
	gint             mode;
	KzGestureMotion *sequence;
};

struct _KzGestureItems
{
	GSList *list;
	gint ref_count;
};

GType        kz_gesture_get_type               (void) G_GNUC_CONST;
KzGesture   *kz_gesture_new                    (void);

void         kz_gesture_set_items              (KzGesture *gesture,
						KzGestureItems *items);

void         kz_gesture_start                  (KzGesture *gesture,
						gint mode,
						gint x, gint y);
void         kz_gesture_perform                (KzGesture *gesture);
void         kz_gesture_cancel                 (KzGesture *gesture);
gboolean     kz_gesture_is_started             (KzGesture *gesture);
void         kz_gesture_update_position        (KzGesture *gesture,
						gint x, gint y);
void         kz_gesture_create_gesture_string  (KzGesture *gesture,
						gchar buf[], gint len);
gboolean     kz_gesture_is_matched             (KzGesture *gesture);
const gchar *kz_gesture_get_matched_label      (KzGesture *gesture);
void         kz_gesture_get_current_position   (KzGesture *gesture,
					        gint *x, gint *y);
const KzGestureMotion *
             kz_gesture_get_current_sequence   (KzGesture *gesture);
gint         kz_gesture_get_mode               (KzGesture *gesture);
void         kz_gesture_set_mode               (KzGesture *gesture,
						gint mode);
gint         kz_gesture_get_threshold          (KzGesture *gesture);
void         kz_gesture_set_threshold          (KzGesture *gesture,
						gint threshold);


KzGestureItems *kz_gesture_items_new           (void);
KzGestureItems *kz_gesture_items_ref           (KzGestureItems *items);
void            kz_gesture_items_unref         (KzGestureItems *items);
void            kz_gesture_items_set_action    (KzGestureItems *items,
						GtkAction *action,
						gint mode,
						const KzGestureMotion *sequence);
void            kz_gesture_items_unset_action  (KzGestureItems *items,
						GtkAction *action);

G_END_DECLS

#endif /* __KZ_GESTURE_H__ */