1 /*
2  * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  *
4  * This library 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) any later version.
8  *
9  * This library 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 this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 
20 
21 #ifndef __GDAUI_DATA_PROXY_H_
22 #define __GDAUI_DATA_PROXY_H_
23 
24 #include <glib-object.h>
25 #include <gtk/gtk.h>
26 #include <libgda/gda-decl.h>
27 #include "gdaui-decl.h"
28 #include "gdaui-enums.h"
29 
30 G_BEGIN_DECLS
31 
32 #define GDAUI_TYPE_DATA_PROXY          (gdaui_data_proxy_get_type())
33 #define GDAUI_DATA_PROXY(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, GDAUI_TYPE_DATA_PROXY, GdauiDataProxy)
34 #define GDAUI_IS_DATA_PROXY(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, GDAUI_TYPE_DATA_PROXY)
35 #define GDAUI_DATA_PROXY_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDAUI_TYPE_DATA_PROXY, GdauiDataProxyIface))
36 
37 /**
38  * GdauiDataProxyWriteMode:
39  * @GDAUI_DATA_PROXY_WRITE_ON_DEMAND: write only when explicitly requested
40  * @GDAUI_DATA_PROXY_WRITE_ON_ROW_CHANGE: write when the current selected row changes
41  * @GDAUI_DATA_PROXY_WRITE_ON_VALUE_ACTIVATED: write when user activates a value change
42  * @GDAUI_DATA_PROXY_WRITE_ON_VALUE_CHANGE: write when a parameters's value changes
43  *
44  * Defines when the data modifications held in the underlying #GdaDataProxy are written to the
45  * data model being proxied (using gda_data_proxy_apply_row_changes()).
46  */
47 typedef enum {
48 	GDAUI_DATA_PROXY_WRITE_ON_DEMAND           = 0,
49 	GDAUI_DATA_PROXY_WRITE_ON_ROW_CHANGE       = 1,
50 	GDAUI_DATA_PROXY_WRITE_ON_VALUE_ACTIVATED  = 2,
51 	GDAUI_DATA_PROXY_WRITE_ON_VALUE_CHANGE     = 3
52 } GdauiDataProxyWriteMode;
53 
54 /* struct for the interface */
55 struct _GdauiDataProxyIface
56 {
57 	GTypeInterface           g_iface;
58 
59 	/* virtual table */
60 	GdaDataProxy        *(* get_proxy)           (GdauiDataProxy *iface);
61 	void                 (* set_column_editable) (GdauiDataProxy *iface, gint column, gboolean editable);
62 	void                 (* show_column_actions) (GdauiDataProxy *iface, gint column, gboolean show_actions);
63 	GtkActionGroup      *(* get_actions_group)   (GdauiDataProxy *iface);
64 	gboolean             (* set_write_mode)      (GdauiDataProxy *iface, GdauiDataProxyWriteMode mode);
65 	GdauiDataProxyWriteMode (* get_write_mode)(GdauiDataProxy *iface);
66 
67 	/* signals */
68 	void                 (* proxy_changed)       (GdauiDataProxy *iface, GdaDataProxy *proxy);
69 };
70 
71 /**
72  * SECTION:gdaui-data-proxy
73  * @short_description: Displaying and modifying data in a #GdaDataProxy
74  * @title: GdauiDataProxy
75  * @stability: Stable
76  * @Image:
77  * @see_also: The #GdauiDataSelector interface which is usually also implemented by the widgets which implement the #GdauiDataProxy interface.
78  *
79  * The #GdauiDataProxy interface is implemented by widgets which allow modifications
80  * to a #GdaDataModel (through a #GdaDataProxy to actually proxy the changes before they
81  * are written to the data model).
82  */
83 
84 GType             gdaui_data_proxy_get_type                  (void) G_GNUC_CONST;
85 
86 GdaDataProxy     *gdaui_data_proxy_get_proxy                 (GdauiDataProxy *iface);
87 GtkActionGroup   *gdaui_data_proxy_get_actions_group         (GdauiDataProxy *iface);
88 void              gdaui_data_proxy_perform_action            (GdauiDataProxy *iface, GdauiAction action);
89 
90 void              gdaui_data_proxy_column_set_editable       (GdauiDataProxy *iface, gint column, gboolean editable);
91 void              gdaui_data_proxy_column_show_actions       (GdauiDataProxy *iface, gint column, gboolean show_actions);
92 
93 gboolean          gdaui_data_proxy_set_write_mode            (GdauiDataProxy *iface, GdauiDataProxyWriteMode mode);
94 GdauiDataProxyWriteMode gdaui_data_proxy_get_write_mode   (GdauiDataProxy *iface);
95 
96 G_END_DECLS
97 
98 #endif
99