~cjcurran/gnome-control-center/expose-card-ports

« back to all changes in this revision

Viewing changes to libslab/tile.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of libtile.
3
 
 *
4
 
 * Copyright (c) 2006 Novell, Inc.
5
 
 *
6
 
 * Libtile is free software; you can redistribute it and/or modify it under the
7
 
 * terms of the GNU Lesser General Public License as published by the Free
8
 
 * Software Foundation; either version 2 of the License, or (at your option)
9
 
 * any later version.
10
 
 *
11
 
 * Libtile is distributed in the hope that it will be useful, but WITHOUT ANY
12
 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
14
 
 * more details.
15
 
 *
16
 
 * You should have received a copy of the GNU Lesser General Public License
17
 
 * along with libslab; if not, write to the Free Software Foundation, Inc., 51
18
 
 * Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#include "tile.h"
22
 
 
23
 
#include <gdk/gdkkeysyms.h>
24
 
#include <string.h>
25
 
 
26
 
#include "double-click-detector.h"
27
 
 
28
 
G_DEFINE_TYPE (Tile, tile, GTK_TYPE_BUTTON)
29
 
 
30
 
typedef struct
31
 
{
32
 
        DoubleClickDetector *double_click_detector;
33
 
        
34
 
        gboolean is_dragging;
35
 
} TilePrivate;
36
 
 
37
 
static void tile_finalize (GObject *);
38
 
static void tile_get_property (GObject *, guint, GValue *, GParamSpec *);
39
 
static void tile_set_property (GObject *, guint, const GValue *, GParamSpec *);
40
 
static GObject *tile_constructor (GType, guint, GObjectConstructParam *);
41
 
 
42
 
static void tile_setup (Tile *);
43
 
 
44
 
static void tile_enter (GtkButton * widget);
45
 
static void tile_leave (GtkButton * widget);
46
 
static void tile_clicked (GtkButton *widget);
47
 
 
48
 
static gboolean tile_focus_in (GtkWidget *, GdkEventFocus *);
49
 
static gboolean tile_focus_out (GtkWidget *, GdkEventFocus *);
50
 
static gboolean tile_expose (GtkWidget *, GdkEventExpose *);
51
 
static gboolean tile_button_release (GtkWidget *, GdkEventButton *);
52
 
static gboolean tile_key_release (GtkWidget *, GdkEventKey *);
53
 
static gboolean tile_popup_menu (GtkWidget *);
54
 
 
55
 
static void tile_popup_menu_position (GtkMenu *, gint *, gint *, gboolean *, gpointer);
56
 
 
57
 
static void tile_drag_begin (GtkWidget *, GdkDragContext *);
58
 
static void tile_drag_data_get (GtkWidget *, GdkDragContext *, GtkSelectionData *, guint,
59
 
guint);
60
 
 
61
 
static void tile_emit_resource_event (Tile *, TileEventType, guint32);
62
 
 
63
 
static void tile_tile_action_triggered (Tile *, TileEvent *, TileAction *);
64
 
static void tile_action_triggered_event_marshal (GClosure *, GValue *, guint, const GValue *,
65
 
gpointer, gpointer);
66
 
 
67
 
typedef void (*marshal_func_VOID__POINTER_POINTER) (gpointer, gpointer, gpointer, gpointer);
68
 
 
69
 
#define TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TILE_TYPE, TilePrivate))
70
 
 
71
 
enum
72
 
{
73
 
        TILE_ACTIVATED_SIGNAL,
74
 
        TILE_IMPLICIT_ENABLE_SIGNAL,
75
 
        TILE_IMPLICIT_DISABLE_SIGNAL,
76
 
        TILE_ACTION_TRIGGERED_SIGNAL,
77
 
        LAST_SIGNAL
78
 
};
79
 
 
80
 
static guint tile_signals[LAST_SIGNAL] = { 0 };
81
 
 
82
 
enum
83
 
{
84
 
        PROP_0,
85
 
        PROP_TILE_URI,
86
 
        PROP_TILE_CONTEXT_MENU,
87
 
        PROP_TILE_ACTIONS
88
 
};
89
 
 
90
 
static void
91
 
tile_class_init (TileClass * this_class)
92
 
{
93
 
        GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class);
94
 
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (this_class);
95
 
        GtkButtonClass *button_class = GTK_BUTTON_CLASS (this_class);
96
 
 
97
 
        g_obj_class->constructor = tile_constructor;
98
 
        g_obj_class->get_property = tile_get_property;
99
 
        g_obj_class->set_property = tile_set_property;
100
 
        g_obj_class->finalize = tile_finalize;
101
 
 
102
 
        widget_class->focus_in_event = tile_focus_in;
103
 
        widget_class->focus_out_event = tile_focus_out;
104
 
        widget_class->expose_event = tile_expose;
105
 
        widget_class->button_release_event = tile_button_release;
106
 
        widget_class->key_release_event = tile_key_release;
107
 
        widget_class->drag_begin = tile_drag_begin;
108
 
        widget_class->drag_data_get = tile_drag_data_get;
109
 
        widget_class->popup_menu = tile_popup_menu;
110
 
 
111
 
        button_class->enter = tile_enter;
112
 
        button_class->leave = tile_leave;
113
 
        button_class->clicked = tile_clicked;
114
 
 
115
 
        this_class->tile_explicit_enable = NULL;
116
 
        this_class->tile_explicit_disable = NULL;
117
 
        this_class->tile_activated = NULL;
118
 
        this_class->tile_implicit_enable = NULL;
119
 
        this_class->tile_implicit_disable = NULL;
120
 
        this_class->tile_action_triggered = tile_tile_action_triggered;
121
 
 
122
 
        g_type_class_add_private (this_class, sizeof (TilePrivate));
123
 
 
124
 
        g_object_class_install_property (g_obj_class, PROP_TILE_URI,
125
 
                g_param_spec_string ("tile-uri", "tile-uri", "the uri of the tile", NULL,
126
 
                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
127
 
 
128
 
        g_object_class_install_property (g_obj_class, PROP_TILE_CONTEXT_MENU,
129
 
                g_param_spec_object ("context-menu", "context-menu",
130
 
                        "the context menu for the tile", GTK_TYPE_MENU, G_PARAM_READWRITE));
131
 
 
132
 
        tile_signals[TILE_ACTIVATED_SIGNAL] = g_signal_new ("tile-activated",
133
 
                G_TYPE_FROM_CLASS (this_class),
134
 
                G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
135
 
                G_STRUCT_OFFSET (TileClass, tile_activated),
136
 
                NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
137
 
 
138
 
        tile_signals[TILE_IMPLICIT_ENABLE_SIGNAL] = g_signal_new ("tile-implicit-enable",
139
 
                G_TYPE_FROM_CLASS (this_class),
140
 
                G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
141
 
                G_STRUCT_OFFSET (TileClass, tile_implicit_enable),
142
 
                NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
143
 
 
144
 
        tile_signals[TILE_IMPLICIT_DISABLE_SIGNAL] = g_signal_new ("tile-implicit-disable",
145
 
                G_TYPE_FROM_CLASS (this_class),
146
 
                G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
147
 
                G_STRUCT_OFFSET (TileClass, tile_implicit_disable),
148
 
                NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
149
 
 
150
 
        tile_signals[TILE_ACTION_TRIGGERED_SIGNAL] = g_signal_new ("tile-action-triggered",
151
 
                G_TYPE_FROM_CLASS (this_class),
152
 
                G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
153
 
                G_STRUCT_OFFSET (TileClass, tile_action_triggered),
154
 
                NULL, NULL, tile_action_triggered_event_marshal, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
155
 
}
156
 
 
157
 
static GObject *
158
 
tile_constructor (GType type, guint n_param, GObjectConstructParam * param)
159
 
{
160
 
        GObject *g_obj;
161
 
        TilePrivate *priv;
162
 
 
163
 
        g_obj = (*G_OBJECT_CLASS (tile_parent_class)->constructor) (type, n_param, param);
164
 
 
165
 
        priv = TILE_GET_PRIVATE (g_obj);
166
 
        priv->double_click_detector = double_click_detector_new ();
167
 
 
168
 
        tile_setup (TILE (g_obj));
169
 
 
170
 
        return g_obj;
171
 
}
172
 
 
173
 
static void
174
 
tile_init (Tile * tile)
175
 
{
176
 
        TilePrivate *priv = TILE_GET_PRIVATE (tile);
177
 
 
178
 
        tile->uri = NULL;
179
 
        tile->context_menu = NULL;
180
 
        tile->entered = FALSE;
181
 
        tile->enabled = TRUE;
182
 
 
183
 
        tile->actions = NULL;
184
 
        tile->n_actions = 0;
185
 
 
186
 
        tile->default_action = NULL;
187
 
 
188
 
        priv->double_click_detector = NULL;
189
 
        priv->is_dragging = FALSE;
190
 
}
191
 
 
192
 
static void
193
 
tile_finalize (GObject * g_object)
194
 
{
195
 
        Tile *tile = TILE (g_object);
196
 
        TilePrivate *priv = TILE_GET_PRIVATE (g_object);
197
 
 
198
 
        if (tile->n_actions)    /* this will also free "default_action" entry */
199
 
        {
200
 
                gint x;
201
 
                for (x = 0; x < tile->n_actions; x++)
202
 
                {
203
 
                        if (tile->actions[x])
204
 
                                g_object_unref (tile->actions[x]);
205
 
                }
206
 
                g_free (tile->actions);
207
 
        }
208
 
 
209
 
        if (tile->uri)
210
 
                g_free (tile->uri);
211
 
        if (tile->context_menu)
212
 
                gtk_widget_destroy (GTK_WIDGET (tile->context_menu));
213
 
 
214
 
        g_object_unref (priv->double_click_detector);
215
 
 
216
 
        (*G_OBJECT_CLASS (tile_parent_class)->finalize) (g_object);
217
 
}
218
 
 
219
 
static void
220
 
tile_get_property (GObject * g_obj, guint prop_id, GValue * value, GParamSpec * param_spec)
221
 
{
222
 
        if (!IS_TILE (g_obj))
223
 
                return;
224
 
 
225
 
        switch (prop_id)
226
 
        {
227
 
        case PROP_TILE_URI:
228
 
                g_value_set_string (value, TILE (g_obj)->uri);
229
 
                break;
230
 
 
231
 
        case PROP_TILE_CONTEXT_MENU:
232
 
                g_value_set_object (value, TILE (g_obj)->context_menu);
233
 
                break;
234
 
 
235
 
        default:
236
 
                break;
237
 
        }
238
 
}
239
 
 
240
 
static void
241
 
tile_set_property (GObject * g_obj, guint prop_id, const GValue * value, GParamSpec * param_spec)
242
 
{
243
 
        Tile *tile;
244
 
        GtkMenu *menu;
245
 
 
246
 
        if (!IS_TILE (g_obj))
247
 
                return;
248
 
 
249
 
        tile = TILE (g_obj);
250
 
 
251
 
        switch (prop_id)
252
 
        {
253
 
        case PROP_TILE_URI:
254
 
                tile->uri = g_strdup (g_value_get_string (value));
255
 
                break;
256
 
 
257
 
        case PROP_TILE_CONTEXT_MENU:
258
 
                menu = g_value_get_object (value);
259
 
 
260
 
                if (menu == tile->context_menu)
261
 
                        break;
262
 
 
263
 
                if (tile->context_menu)
264
 
                        gtk_menu_detach (tile->context_menu);
265
 
 
266
 
                tile->context_menu = menu;
267
 
 
268
 
                if (tile->context_menu)
269
 
                        gtk_menu_attach_to_widget (tile->context_menu, GTK_WIDGET (tile), NULL);
270
 
 
271
 
                break;
272
 
 
273
 
        default:
274
 
                break;
275
 
        }
276
 
}
277
 
 
278
 
static void
279
 
tile_setup (Tile * tile)
280
 
{
281
 
        gtk_button_set_relief (GTK_BUTTON (tile), GTK_RELIEF_NONE);
282
 
 
283
 
        if (tile->uri)
284
 
        {
285
 
                gtk_drag_source_set (GTK_WIDGET (tile), GDK_BUTTON1_MASK, NULL, 0,
286
 
                        GDK_ACTION_COPY | GDK_ACTION_MOVE);
287
 
 
288
 
                gtk_drag_source_add_uri_targets (GTK_WIDGET (tile));
289
 
        }
290
 
}
291
 
 
292
 
static void
293
 
tile_enter (GtkButton * widget)
294
 
{
295
 
        gtk_widget_set_state (GTK_WIDGET (widget), TILE_STATE_ENTERED);
296
 
 
297
 
        TILE (widget)->entered = TRUE;
298
 
}
299
 
 
300
 
static void
301
 
tile_leave (GtkButton * widget)
302
 
{
303
 
        if (GTK_WIDGET_HAS_FOCUS (widget))
304
 
                gtk_widget_set_state (GTK_WIDGET (widget), TILE_STATE_FOCUSED);
305
 
        else
306
 
                gtk_widget_set_state (GTK_WIDGET (widget), GTK_STATE_NORMAL);
307
 
 
308
 
        TILE (widget)->entered = FALSE;
309
 
}
310
 
 
311
 
static void
312
 
tile_clicked (GtkButton * widget)
313
 
{
314
 
        TileEvent *tile_event;
315
 
 
316
 
        tile_event = g_new0 (TileEvent, 1);
317
 
        tile_event->type = TILE_EVENT_ACTIVATED_DOUBLE_CLICK;
318
 
        tile_event->time = gtk_get_current_event_time ();
319
 
 
320
 
        g_signal_emit (widget, tile_signals[TILE_ACTIVATED_SIGNAL], 0, tile_event);
321
 
 
322
 
        gtk_button_released (widget);
323
 
        g_free (tile_event);
324
 
}
325
 
 
326
 
static gboolean
327
 
tile_focus_in (GtkWidget * widget, GdkEventFocus * event)
328
 
{
329
 
        gtk_widget_set_state (widget, TILE_STATE_FOCUSED);
330
 
 
331
 
        return FALSE;
332
 
}
333
 
 
334
 
static gboolean
335
 
tile_focus_out (GtkWidget * widget, GdkEventFocus * event)
336
 
{
337
 
        if (TILE (widget)->entered)
338
 
                gtk_widget_set_state (widget, TILE_STATE_ENTERED);
339
 
        else
340
 
                gtk_widget_set_state (widget, GTK_STATE_NORMAL);
341
 
 
342
 
        return FALSE;
343
 
}
344
 
 
345
 
static gboolean
346
 
tile_expose (GtkWidget * widget, GdkEventExpose * event)
347
 
{
348
 
        /* FIXME: there ought to be a better way to prevent the focus from being rendered. */
349
 
 
350
 
        gboolean has_focus;
351
 
        gboolean retval;
352
 
 
353
 
        if ((has_focus = GTK_WIDGET_HAS_FOCUS (widget)))
354
 
                GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
355
 
 
356
 
        retval = (*GTK_WIDGET_CLASS (tile_parent_class)->expose_event) (widget, event);
357
 
 
358
 
        if (has_focus)
359
 
                GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
360
 
 
361
 
        return retval;
362
 
}
363
 
 
364
 
static gboolean
365
 
tile_button_release (GtkWidget * widget, GdkEventButton * event)
366
 
{
367
 
        Tile *tile = TILE (widget);
368
 
        TilePrivate *priv = TILE_GET_PRIVATE (tile);
369
 
 
370
 
        TileEvent *tile_event;
371
 
 
372
 
        if (priv->is_dragging)
373
 
        {
374
 
                priv->is_dragging = FALSE;
375
 
 
376
 
                return TRUE;
377
 
        }
378
 
 
379
 
        switch (event->button)
380
 
        {
381
 
        case 1:
382
 
                tile_event = g_new0 (TileEvent, 1);
383
 
                tile_event->time = event->time;
384
 
 
385
 
                if (double_click_detector_is_double_click (priv->double_click_detector, event->time,
386
 
                                TRUE))
387
 
                        tile_event->type = TILE_EVENT_ACTIVATED_DOUBLE_CLICK;
388
 
                else
389
 
                        tile_event->type = TILE_EVENT_ACTIVATED_SINGLE_CLICK;
390
 
 
391
 
                g_signal_emit (tile, tile_signals[TILE_ACTIVATED_SIGNAL], 0, tile_event);
392
 
 
393
 
                gtk_button_released (GTK_BUTTON (widget));
394
 
                g_free (tile_event);
395
 
 
396
 
                break;
397
 
 
398
 
        case 3:
399
 
                if (GTK_IS_MENU (tile->context_menu))
400
 
                        gtk_menu_popup (tile->context_menu, NULL, NULL, NULL, NULL, event->button,
401
 
                                event->time);
402
 
 
403
 
                break;
404
 
 
405
 
        default:
406
 
                break;
407
 
        }
408
 
 
409
 
        return TRUE;
410
 
}
411
 
 
412
 
static gboolean
413
 
tile_key_release (GtkWidget * widget, GdkEventKey * event)
414
 
{
415
 
        TileEvent *tile_event;
416
 
 
417
 
        if (event->keyval == GDK_Return)
418
 
        {
419
 
                tile_event = g_new0 (TileEvent, 1);
420
 
                tile_event->type = TILE_EVENT_ACTIVATED_KEYBOARD;
421
 
                tile_event->time = event->time;
422
 
 
423
 
                g_signal_emit (widget, tile_signals[TILE_ACTIVATED_SIGNAL], 0, tile_event);
424
 
 
425
 
                return TRUE;
426
 
        }
427
 
 
428
 
        return FALSE;
429
 
}
430
 
 
431
 
static void
432
 
tile_popup_menu_position (GtkMenu * menu, gint * x, gint * y, gboolean * push_in, gpointer data)
433
 
{
434
 
        Tile *tile = TILE (data);
435
 
 
436
 
        GtkRequisition req;
437
 
        GtkWidget *top;
438
 
 
439
 
        if (!GTK_WIDGET_REALIZED (tile))
440
 
                return;
441
 
 
442
 
        gtk_widget_size_request (GTK_WIDGET (menu), &req);
443
 
 
444
 
        top = gtk_widget_get_toplevel (GTK_WIDGET (tile));
445
 
 
446
 
        gdk_window_get_origin (top->window, x, y);
447
 
 
448
 
        *x += (top->allocation.width / 2) - (req.width / 2);
449
 
        *y += (top->allocation.height / 2) - (req.height / 2);
450
 
 
451
 
        *push_in = FALSE;
452
 
}
453
 
 
454
 
static gboolean
455
 
tile_popup_menu (GtkWidget * widget)
456
 
{
457
 
        Tile *tile = TILE (widget);
458
 
 
459
 
        if (GTK_IS_MENU (tile->context_menu))
460
 
        {
461
 
                gtk_menu_popup (tile->context_menu, NULL, NULL, tile_popup_menu_position, tile, 0,
462
 
                        gtk_get_current_event_time ());
463
 
 
464
 
                return TRUE;
465
 
        }
466
 
 
467
 
        else
468
 
                return FALSE;
469
 
}
470
 
 
471
 
static void
472
 
tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
473
 
{
474
 
        TILE_GET_PRIVATE (widget)->is_dragging = TRUE;
475
 
}
476
 
 
477
 
static void
478
 
tile_drag_data_get (GtkWidget * widget, GdkDragContext * context, GtkSelectionData * data,
479
 
        guint info, guint time)
480
 
{
481
 
        gchar *uris[2];
482
 
 
483
 
        if (TILE (widget)->uri)
484
 
        {
485
 
                uris[0] = TILE (widget)->uri;
486
 
                uris[1] = NULL;
487
 
 
488
 
                gtk_selection_data_set_uris (data, uris);
489
 
        }
490
 
}
491
 
 
492
 
static void
493
 
tile_tile_action_triggered (Tile * tile, TileEvent * event, TileAction * action)
494
 
{
495
 
        if (action && action->func)
496
 
                (*action->func) (tile, event, action);
497
 
}
498
 
 
499
 
gint
500
 
tile_compare (gconstpointer a, gconstpointer b)
501
 
{
502
 
        if (IS_TILE (a) && IS_TILE (b))
503
 
                return strcmp (TILE (a)->uri, TILE (b)->uri);
504
 
 
505
 
        return a - b;
506
 
}
507
 
 
508
 
void
509
 
tile_explicit_enable (Tile * this)
510
 
{
511
 
        TileClass *this_class = TILE_GET_CLASS (this);
512
 
 
513
 
        if (this_class->tile_explicit_enable)
514
 
                (*this_class->tile_explicit_enable) (this);
515
 
}
516
 
 
517
 
void
518
 
tile_explicit_disable (Tile * this)
519
 
{
520
 
        TileClass *this_class = TILE_GET_CLASS (this);
521
 
 
522
 
        if (this_class->tile_explicit_disable)
523
 
                (*this_class->tile_explicit_disable) (this);
524
 
}
525
 
 
526
 
void
527
 
tile_implicit_enable (Tile * tile)
528
 
{
529
 
        tile_implicit_enable_with_time (tile, GDK_CURRENT_TIME);
530
 
}
531
 
 
532
 
void
533
 
tile_implicit_disable (Tile * tile)
534
 
{
535
 
        tile_implicit_disable_with_time (tile, GDK_CURRENT_TIME);
536
 
}
537
 
 
538
 
void
539
 
tile_implicit_enable_with_time (Tile * tile, guint32 time)
540
 
{
541
 
        tile_emit_resource_event (tile, TILE_EVENT_IMPLICIT_ENABLE, time);
542
 
}
543
 
 
544
 
void
545
 
tile_implicit_disable_with_time (Tile * tile, guint32 time)
546
 
{
547
 
        tile_emit_resource_event (tile, TILE_EVENT_IMPLICIT_DISABLE, time);
548
 
}
549
 
 
550
 
static void
551
 
tile_emit_resource_event (Tile * tile, TileEventType type, guint32 time)
552
 
{
553
 
        TileEvent *event;
554
 
        guint signal_id;
555
 
 
556
 
        event = g_new0 (TileEvent, 1);
557
 
        event->type = type;
558
 
        event->time = time;
559
 
 
560
 
        if (type == TILE_EVENT_IMPLICIT_ENABLE)
561
 
        {
562
 
                signal_id = tile_signals[TILE_IMPLICIT_ENABLE_SIGNAL];
563
 
                tile->enabled = TRUE;
564
 
        }
565
 
        else
566
 
        {
567
 
                signal_id = tile_signals[TILE_IMPLICIT_DISABLE_SIGNAL];
568
 
                tile->enabled = FALSE;
569
 
        }
570
 
 
571
 
        g_signal_emit (tile, signal_id, 0, event);
572
 
        g_free (event);
573
 
}
574
 
 
575
 
void
576
 
tile_trigger_action (Tile * tile, TileAction * action)
577
 
{
578
 
        tile_trigger_action_with_time (tile, action, GDK_CURRENT_TIME);
579
 
}
580
 
 
581
 
void
582
 
tile_trigger_action_with_time (Tile * tile, TileAction * action, guint32 time)
583
 
{
584
 
        TileEvent *event = g_new0 (TileEvent, 1);
585
 
 
586
 
        event->type = TILE_EVENT_ACTION_TRIGGERED;
587
 
        event->time = time;
588
 
 
589
 
        g_signal_emit (tile, tile_signals[TILE_ACTION_TRIGGERED_SIGNAL], 0, event, action);
590
 
        g_free (event);
591
 
}
592
 
 
593
 
static void
594
 
tile_action_triggered_event_marshal (GClosure * closure, GValue * retval, guint n_param,
595
 
        const GValue * param, gpointer invocation_hint, gpointer marshal_data)
596
 
{
597
 
        marshal_func_VOID__POINTER_POINTER callback;
598
 
        GCClosure *cc = (GCClosure *) closure;
599
 
        gpointer data_0, data_1;
600
 
 
601
 
        g_return_if_fail (n_param == 3);
602
 
 
603
 
        if (G_CCLOSURE_SWAP_DATA (closure))
604
 
        {
605
 
                data_0 = closure->data;
606
 
                data_1 = g_value_peek_pointer (param);
607
 
        }
608
 
        else
609
 
        {
610
 
                data_0 = g_value_peek_pointer (param);
611
 
                data_1 = closure->data;
612
 
        }
613
 
 
614
 
        if (marshal_data)
615
 
                callback = (marshal_func_VOID__POINTER_POINTER) marshal_data;
616
 
        else
617
 
                callback = (marshal_func_VOID__POINTER_POINTER) cc->callback;
618
 
 
619
 
        callback (data_0, g_value_peek_pointer (param + 1), g_value_peek_pointer (param + 2),
620
 
                data_1);
621
 
}