summaryrefslogtreecommitdiff
path: root/gui/greeter/greeter_item.h
blob: ec7fd6aab3d40679cb5c0b15e75b60a46cb48665 (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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/* GDM - The GNOME Display Manager
 * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef GREETER_ITEM_H
#define GREETER_ITEM_H

#include <libgnomecanvas/libgnomecanvas.h>

typedef struct _GreeterItemInfo GreeterItemInfo;
typedef struct _GreeterItemListItem GreeterItemListItem;
typedef enum _GreeterItemState GreeterItemState;
typedef enum _GreeterItemType GreeterItemType;
typedef enum _GreeterItemSizeType GreeterItemSizeType;
typedef enum _GreeterItemPosType GreeterItemPosType;
typedef enum _GreeterItemShowModes GreeterItemShowModes;

/* Make sure to adjust the bitfield in the structure if
   you make this larger */
enum _GreeterItemState {
  GREETER_ITEM_STATE_NORMAL,
  GREETER_ITEM_STATE_PRELIGHT,
  GREETER_ITEM_STATE_ACTIVE,
  GREETER_ITEM_STATE_MAX
};

/* Make sure to adjust the bitfield in the structure if
   you make this larger */
enum _GreeterItemType {
  GREETER_ITEM_TYPE_RECT,
  GREETER_ITEM_TYPE_SVG,
  GREETER_ITEM_TYPE_PIXMAP,
  GREETER_ITEM_TYPE_LABEL,
  GREETER_ITEM_TYPE_ENTRY,
  GREETER_ITEM_TYPE_LIST,
  GREETER_ITEM_TYPE_BUTTON
};

/* Make sure to adjust the bitfield in the structure if
   you make this larger */
enum _GreeterItemSizeType {
  GREETER_ITEM_SIZE_UNSET,
  GREETER_ITEM_SIZE_ABSOLUTE,
  GREETER_ITEM_SIZE_RELATIVE,
  GREETER_ITEM_SIZE_BOX,
  GREETER_ITEM_SIZE_SCALE
};

/* Make sure to adjust the bitfield in the structure if
   you make this larger */
enum _GreeterItemPosType {
  GREETER_ITEM_POS_UNSET,
  GREETER_ITEM_POS_ABSOLUTE,
  GREETER_ITEM_POS_RELATIVE
};

/* Make sure to adjust the bitfield in the structure if
   you make this larger */
enum _GreeterItemShowModes {
  GREETER_ITEM_SHOW_EVERYWHERE = 0xf,
  GREETER_ITEM_SHOW_NOWHERE = 0,
  GREETER_ITEM_SHOW_CONSOLE_FIXED = 1<<0,
  GREETER_ITEM_SHOW_CONSOLE = (1<<0) | (1<<1),
  GREETER_ITEM_SHOW_CONSOLE_FLEXI = 1<<1,
  GREETER_ITEM_SHOW_REMOTE_FLEXI = 1<<2,
  GREETER_ITEM_SHOW_FLEXI = (1<<1) | (1<<2),
  GREETER_ITEM_SHOW_REMOTE = 1<<3
};

struct _GreeterItemInfo {
  GreeterItemInfo *parent;
  
  GtkAnchorType anchor;
  float x;
  float y;
  float width;
  float height;
  GreeterItemPosType x_type:2;
  GreeterItemPosType y_type:2;
  GreeterItemSizeType width_type:4;
  GreeterItemSizeType height_type:4;
  guint x_negative:1; /* needed for -0 */
  guint y_negative:1; /* needed for -0 */

  /* For packed items */
  guint expand:1;

  /* The item type */
  GreeterItemType item_type:4;

  GreeterItemShowModes show_modes:4;

  /* Runtime state: */
  GreeterItemState state:2;
  GreeterItemState base_state:2;
  guint mouse_down:1;
  guint mouse_over:1;

  /* box flags */
  guint box_homogeneous:1;

  /* is a canvas rectangle that acts like a button */
  /* (see the my_button comment) */
  guint canvasbutton:1;

  /* is a real GTK button (not the fake canvas button) */
  guint gtkbutton:1;

  /* geometry handling: */
  guint has_requisition:1;
  GtkRequisition requisition;
  GtkAllocation allocation;

  /* Button can propagate states and collect states from underlying items,
   * it should be a parent of this item */
  GreeterItemInfo *my_button;

  char *show_type; /* timed, system, config, chooser, halt, suspend, reboot */

  char *id;

  GList *box_children;
  GtkOrientation box_orientation;
  guint16 box_x_padding;
  guint16 box_y_padding;
  guint16 box_min_width;
  guint16 box_min_height;
  guint16 box_spacing;

  /* Container data */
  GList *fixed_children;

  union {
	  /* Note: we want to have alphas, colors and have_color coincide for all types
	     that have it */
#define GREETER_ITEM_TYPE_IS_TEXT(info) ((info)->item_type == GREETER_ITEM_TYPE_LABEL || (info)->item_type == GREETER_ITEM_TYPE_ENTRY)
	  struct {
		  guint8 alphas[GREETER_ITEM_STATE_MAX];
		  guint32 colors[GREETER_ITEM_STATE_MAX];

		  guint8 have_color; /* this is a bitfield since these are
					true/false values */

		  PangoFontDescription *fonts[GREETER_ITEM_STATE_MAX];
		  char *orig_text;
		  guint16 max_width;
		  guint8 max_screen_percent_width;
		  guint16 real_max_width;
	  } text; /* text and entry (entry only uses fonts) */

#define GREETER_ITEM_TYPE_IS_PIXMAP(info) ((info)->item_type == GREETER_ITEM_TYPE_PIXMAP || (info)->item_type == GREETER_ITEM_TYPE_SVG)
	  struct {
		  guint8 alphas[GREETER_ITEM_STATE_MAX];
		  guint32 tints[GREETER_ITEM_STATE_MAX];
		  guint8 have_tint; /* this is a bitfield since these are
				       true/false values */

		  char *files[GREETER_ITEM_STATE_MAX];
		  GdkPixbuf *pixbufs[GREETER_ITEM_STATE_MAX];
	  } pixmap;

#define GREETER_ITEM_TYPE_IS_LIST(info) ((info)->item_type == GREETER_ITEM_TYPE_LIST)
	  struct {
		  char *icon_color;
		  char *label_color;
		  /* If this is a custom list, then these are the items
		     to pick from */
		  GList *items;
	  } list;

#define GREETER_ITEM_TYPE_IS_RECT(info) ((info)->item_type == GREETER_ITEM_TYPE_RECT)
	  struct {
		  guint8 alphas[GREETER_ITEM_STATE_MAX];
		  guint32 colors[GREETER_ITEM_STATE_MAX];

		  guint8 have_color; /* this is a bitfield since these are
					true/false values */
	  } rect;
  } data;

  guint8 have_state; /* this is a bitfield since these are
			true/false values */

  /* Canvas data: */
  GnomeCanvasItem *item;
  GnomeCanvasGroup *group_item;
};

struct _GreeterItemListItem {
	char *id;
	char *text;
};

gint greeter_item_event_handler (GnomeCanvasItem *item,
				 GdkEvent        *event,
				 gpointer         data);

GreeterItemInfo *greeter_item_info_new (GreeterItemInfo *parent,
					GreeterItemType  type);
void greeter_item_info_free (GreeterItemInfo *info);

char *greeter_item_expand_text (const char *text);

void greeter_item_update_text (GreeterItemInfo *info);

gboolean greeter_item_is_visible (GreeterItemInfo *info);

#endif /* GREETER_ITEM_H */