1 /*
2 * glade-clipboard.c - An object for handling Cut/Copy/Paste.
3 *
4 * Copyright (C) 2005 The GNOME Foundation.
5 *
6 * Author(s):
7 * Tristan Van Berkom <tvb@gnome.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 * USA.
23 */
24
25 #include "config.h"
26
27 #include "glade-accumulators.h"
28
29 #include <glib-object.h>
30
31
32 gboolean
_glade_single_object_accumulator(GSignalInvocationHint * ihint,GValue * return_accu,const GValue * handler_return,gpointer dummy)33 _glade_single_object_accumulator (GSignalInvocationHint *ihint,
34 GValue *return_accu,
35 const GValue *handler_return, gpointer dummy)
36 {
37 GObject *object = g_value_get_object (handler_return);
38 g_value_set_object (return_accu, object);
39
40 return (object == NULL);
41 }
42
43 gboolean
_glade_integer_handled_accumulator(GSignalInvocationHint * ihint,GValue * return_accu,const GValue * handler_return,gpointer dummy)44 _glade_integer_handled_accumulator (GSignalInvocationHint *ihint,
45 GValue *return_accu,
46 const GValue *handler_return,
47 gpointer dummy)
48 {
49 gboolean continue_emission;
50 gint retval;
51
52 retval = g_value_get_int (handler_return);
53 g_value_set_int (return_accu, retval >> 1);
54 continue_emission = !(retval & 1);
55
56 return continue_emission;
57 }
58
59 /* From gtkmain.c */
60 gboolean
_glade_boolean_handled_accumulator(GSignalInvocationHint * ihint,GValue * return_accu,const GValue * handler_return,gpointer dummy)61 _glade_boolean_handled_accumulator (GSignalInvocationHint *ihint,
62 GValue *return_accu,
63 const GValue *handler_return,
64 gpointer dummy)
65 {
66 gboolean continue_emission;
67 gboolean signal_handled;
68
69 signal_handled = g_value_get_boolean (handler_return);
70 g_value_set_boolean (return_accu, signal_handled);
71 continue_emission = !signal_handled;
72
73 return continue_emission;
74 }
75
76 gboolean
_glade_string_accumulator(GSignalInvocationHint * ihint,GValue * return_accu,const GValue * handler_return,gpointer dummy)77 _glade_string_accumulator (GSignalInvocationHint *ihint,
78 GValue *return_accu,
79 const GValue *handler_return, gpointer dummy)
80 {
81 const gchar *handler_str;
82
83 g_free ((void *) g_value_get_string (return_accu));
84
85 handler_str = g_value_get_string (handler_return);
86 g_value_set_string (return_accu, handler_str);
87
88 return (handler_str == NULL);
89 }
90
91 gboolean
_glade_strv_handled_accumulator(GSignalInvocationHint * ihint,GValue * return_accu,const GValue * handler_return,gpointer dummy)92 _glade_strv_handled_accumulator (GSignalInvocationHint *ihint,
93 GValue *return_accu,
94 const GValue *handler_return, gpointer dummy)
95 {
96 const gchar **handler_strv;
97
98 handler_strv = g_value_get_boxed (handler_return);
99 g_value_set_boxed (return_accu, handler_strv);
100
101 return (handler_strv == NULL);
102 }
103
104 gboolean
_glade_stop_emission_accumulator(GSignalInvocationHint * ihint,GValue * return_accu,const GValue * handler_return,gpointer dummy)105 _glade_stop_emission_accumulator (GSignalInvocationHint *ihint,
106 GValue *return_accu,
107 const GValue *handler_return, gpointer dummy)
108 {
109 g_value_copy (handler_return, return_accu);
110
111 return FALSE;
112 }
113