summaryrefslogtreecommitdiff
path: root/shell/tile.h
blob: 9c8d3f2a4440fdfe65eb0d0aa2c872b9b9d7cd51 (plain)
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
/*
 * This file is part of libtile.
 *
 * Copyright (c) 2006 Novell, Inc.
 *
 * Libtile is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * Libtile 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 Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libslab; if not, write to the Free Software Foundation, Inc., 51
 * Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef __TILE_H__
#define __TILE_H__

#include <glib.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS

#define TILE_TYPE         (tile_get_type ())
#define TILE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TILE_TYPE, Tile))
#define TILE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c), TILE_TYPE, TileClass))
#define IS_TILE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TILE_TYPE))
#define IS_TILE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), TILE_TYPE))
#define TILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TILE_TYPE, TileClass))
#define TILE_ACTION_TYPE         (tile_action_get_type ())
#define TILE_ACTION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TILE_ACTION_TYPE, TileAction))
#define TILE_ACTION_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c), TILE_ACTION_TYPE, TileActionClass))
#define IS_TILE_ACTION(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TILE_ACTION_TYPE))
#define IS_TILE_ACTION_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), TILE_ACTION_TYPE))
#define TILE_ACTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TILE_ACTION_TYPE, TileActionClass))
#define TILE_ACTION_CHECK_FLAG(action,flag) ((TILE_ACTION (action)->flags & (flag)) != 0)
#define TILE_STATE_ENTERED GTK_STATE_FLAG_PRELIGHT
#define TILE_STATE_FOCUSED GTK_STATE_FLAG_PRELIGHT

typedef struct _Tile Tile;
typedef struct _TileClass TileClass;
typedef struct _TileAction TileAction;
typedef struct _TileActionClass TileActionClass;
typedef struct _TileEvent TileEvent;

typedef void (*TileActionFunc) (Tile *, TileEvent *, TileAction *);

typedef enum
{
	TILE_EVENT_ACTIVATED_SINGLE_CLICK,
	TILE_EVENT_ACTIVATED_DOUBLE_CLICK,
	TILE_EVENT_ACTIVATED_KEYBOARD,
	TILE_EVENT_ACTION_TRIGGERED
} TileEventType;

typedef enum
{
	TILE_ACTION_OPENS_NEW_WINDOW = 1 << 0,
	TILE_ACTION_OPENS_HELP = 1 << 1
} TileActionFlags;

struct _Tile
{
	GtkButton gtk_button;

	gchar *uri;
	GtkMenu *context_menu;
	gboolean entered;
	gboolean enabled;

	TileAction **actions;
	gint n_actions;

	TileAction *default_action;
};

struct _TileClass
{
	GtkButtonClass gtk_button_class;

	void (*tile_activated) (Tile *, TileEvent *);
	void (*tile_action_triggered) (Tile *, TileEvent *, TileAction *);
};

struct _TileAction
{
	GObject parent;

	Tile *tile;

	TileActionFunc func;
	GtkMenuItem *menu_item;

	guint32 flags;
};

struct _TileActionClass
{
	GObjectClass parent_class;
};

struct _TileEvent
{
	TileEventType type;
	guint32 time;
};

GType tile_get_type (void);
GType tile_action_get_type (void);

void tile_trigger_action (Tile * tile, TileAction * action);
void tile_trigger_action_with_time (Tile * tile, TileAction * action, guint32 time);

TileAction *tile_action_new (Tile * tile, TileActionFunc func, const gchar * menu_item_markup,
	guint32 flags);

void tile_action_set_menu_item_label (TileAction * action, const gchar * markup);
GtkMenuItem *tile_action_get_menu_item (TileAction * action);

G_END_DECLS

#endif /* __TILE_H__ */