evolution-3.6.4/widgets/misc/e-selectable.c

No issues found

  1 /*
  2  * e-selectable.c
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 19  *
 20  */
 21 
 22 #ifdef HAVE_CONFIG_H
 23 #include <config.h>
 24 #endif
 25 
 26 #include "e-selectable.h"
 27 
 28 G_DEFINE_INTERFACE (
 29 	ESelectable,
 30 	e_selectable,
 31 	GTK_TYPE_WIDGET)
 32 
 33 static void
 34 e_selectable_default_init (ESelectableInterface *interface)
 35 {
 36 	g_object_interface_install_property (
 37 		interface,
 38 		g_param_spec_boxed (
 39 			"copy-target-list",
 40 			"Copy Target List",
 41 			NULL,
 42 			GTK_TYPE_TARGET_LIST,
 43 			G_PARAM_READABLE));
 44 
 45 	g_object_interface_install_property (
 46 		interface,
 47 		g_param_spec_boxed (
 48 			"paste-target-list",
 49 			"Paste Target List",
 50 			NULL,
 51 			GTK_TYPE_TARGET_LIST,
 52 			G_PARAM_READABLE));
 53 }
 54 
 55 void
 56 e_selectable_update_actions (ESelectable *selectable,
 57                              EFocusTracker *focus_tracker,
 58                              GdkAtom *clipboard_targets,
 59                              gint n_clipboard_targets)
 60 {
 61 	ESelectableInterface *interface;
 62 
 63 	g_return_if_fail (E_IS_SELECTABLE (selectable));
 64 
 65 	interface = E_SELECTABLE_GET_INTERFACE (selectable);
 66 	g_return_if_fail (interface->update_actions != NULL);
 67 
 68 	interface->update_actions (
 69 		selectable, focus_tracker,
 70 		clipboard_targets, n_clipboard_targets);
 71 }
 72 
 73 void
 74 e_selectable_cut_clipboard (ESelectable *selectable)
 75 {
 76 	ESelectableInterface *interface;
 77 
 78 	g_return_if_fail (E_IS_SELECTABLE (selectable));
 79 
 80 	interface = E_SELECTABLE_GET_INTERFACE (selectable);
 81 
 82 	if (interface->cut_clipboard != NULL)
 83 		interface->cut_clipboard (selectable);
 84 }
 85 
 86 void
 87 e_selectable_copy_clipboard (ESelectable *selectable)
 88 {
 89 	ESelectableInterface *interface;
 90 
 91 	g_return_if_fail (E_IS_SELECTABLE (selectable));
 92 
 93 	interface = E_SELECTABLE_GET_INTERFACE (selectable);
 94 
 95 	if (interface->copy_clipboard != NULL)
 96 		interface->copy_clipboard (selectable);
 97 }
 98 
 99 void
100 e_selectable_paste_clipboard (ESelectable *selectable)
101 {
102 	ESelectableInterface *interface;
103 
104 	g_return_if_fail (E_IS_SELECTABLE (selectable));
105 
106 	interface = E_SELECTABLE_GET_INTERFACE (selectable);
107 
108 	if (interface->paste_clipboard != NULL)
109 		interface->paste_clipboard (selectable);
110 }
111 
112 void
113 e_selectable_delete_selection (ESelectable *selectable)
114 {
115 	ESelectableInterface *interface;
116 
117 	g_return_if_fail (E_IS_SELECTABLE (selectable));
118 
119 	interface = E_SELECTABLE_GET_INTERFACE (selectable);
120 
121 	if (interface->delete_selection != NULL)
122 		interface->delete_selection (selectable);
123 }
124 
125 void
126 e_selectable_select_all (ESelectable *selectable)
127 {
128 	ESelectableInterface *interface;
129 
130 	g_return_if_fail (E_IS_SELECTABLE (selectable));
131 
132 	interface = E_SELECTABLE_GET_INTERFACE (selectable);
133 
134 	if (interface->select_all != NULL)
135 		interface->select_all (selectable);
136 }
137 
138 GtkTargetList *
139 e_selectable_get_copy_target_list (ESelectable *selectable)
140 {
141 	GtkTargetList *target_list;
142 
143 	g_return_val_if_fail (E_IS_SELECTABLE (selectable), NULL);
144 
145 	g_object_get (selectable, "copy-target-list", &target_list, NULL);
146 
147 	/* We want to return a borrowed reference to the target
148 	 * list, so undo the reference that g_object_get() added. */
149 	gtk_target_list_unref (target_list);
150 
151 	return target_list;
152 }
153 
154 GtkTargetList *
155 e_selectable_get_paste_target_list (ESelectable *selectable)
156 {
157 	GtkTargetList *target_list;
158 
159 	g_return_val_if_fail (E_IS_SELECTABLE (selectable), NULL);
160 
161 	g_object_get (selectable, "paste-target-list", &target_list, NULL);
162 
163 	/* We want to return a borrowed reference to the target
164 	 * list, so undo the reference that g_object_get() added. */
165 	gtk_target_list_unref (target_list);
166 
167 	return target_list;
168 }