1 /* 2 * Copyright (C) 2009 - 2012 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_ENTRY_H_ 22 #define __GDAUI_DATA_ENTRY_H_ 23 24 #include <glib-object.h> 25 #include <libgda/libgda.h> 26 #include <gtk/gtk.h> 27 28 G_BEGIN_DECLS 29 30 #define GDAUI_TYPE_DATA_ENTRY (gdaui_data_entry_get_type()) 31 #define GDAUI_DATA_ENTRY(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, GDAUI_TYPE_DATA_ENTRY, GdauiDataEntry) 32 #define GDAUI_IS_DATA_ENTRY(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, GDAUI_TYPE_DATA_ENTRY) 33 #define GDAUI_DATA_ENTRY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDAUI_TYPE_DATA_ENTRY, GdauiDataEntryIface)) 34 35 typedef struct _GdauiDataEntry GdauiDataEntry; 36 typedef struct _GdauiDataEntryIface GdauiDataEntryIface; 37 38 /* error reporting */ 39 extern GQuark gdaui_data_entry_error_quark (void); 40 #define GDAUI_DATA_ENTRY_ERROR gdaui_data_entry_error_quark () 41 42 typedef enum 43 { 44 GDAUI_DATA_ENTRY_FILE_NOT_FOUND_ERROR, 45 GDAUI_DATA_ENTRY_INVALID_DATA_ERROR 46 } GdauiDataEntryError; 47 48 /* struct for the interface */ 49 struct _GdauiDataEntryIface 50 { 51 GTypeInterface g_iface; 52 53 /* signals */ 54 void (* contents_modified) (GdauiDataEntry *de); 55 void (* contents_activated) (GdauiDataEntry *de); 56 void (* status_changed) (GdauiDataEntry *de); 57 gboolean (* contents_valid) (GdauiDataEntry *de, GError **error); 58 59 /* virtual table */ 60 void (*set_value_type) (GdauiDataEntry *de, GType type); 61 GType (*get_value_type) (GdauiDataEntry *de); 62 void (*set_value) (GdauiDataEntry *de, const GValue * value); 63 GValue *(*get_value) (GdauiDataEntry *de); 64 void (*set_ref_value) (GdauiDataEntry *de, const GValue * value); 65 const GValue *(*get_ref_value) (GdauiDataEntry *de); 66 void (*set_value_default) (GdauiDataEntry *de, const GValue * value); 67 void (*set_attributes) (GdauiDataEntry *de, GdaValueAttribute attrs, GdaValueAttribute mask); 68 GdaValueAttribute (*get_attributes) (GdauiDataEntry *de); 69 GdaDataHandler *(*get_handler) (GdauiDataEntry *de); 70 gboolean (*can_expand) (GdauiDataEntry *de, gboolean horiz); /* not used anymore */ 71 void (*set_editable) (GdauiDataEntry *de, gboolean editable); 72 gboolean (*get_editable) (GdauiDataEntry *de); 73 void (*grab_focus) (GdauiDataEntry *de); 74 75 /* another signal */ 76 void (*expand_changed) (GdauiDataEntry *de); 77 78 void (*set_unknown_color) (GdauiDataEntry *de, gdouble red, gdouble green, 79 gdouble blue, gdouble alpha); 80 /* New Validating mecanism */ 81 gboolean (*validate) (GdauiDataEntry* de, GError **error); 82 /*< private >*/ 83 /* Padding for future expansion */ 84 void (*_gdaui_reserved2) (void); 85 void (*_gdaui_reserved3) (void); 86 }; 87 88 /** 89 * SECTION:gdaui-data-entry 90 * @short_description: Data entry widget 91 * @title: GdauiDataEntry 92 * @stability: Stable 93 * @Image: vi-data-entry.png 94 * @see_also: 95 * 96 * The #GdaUiDataEntry is an interface for widgets (simple or complex) 97 * which lets the user view and/or modify a #GValue. 98 * 99 * This interface is implemented by widgets which feature data editing (usually composed of an editing 100 * area and a button to have some more control on the value being edited). 101 * The interface allows to control how the widget works and to query the value and the attributes 102 * of the data held by the widget. 103 * 104 * The widget can store the original value (to be able to tell if the value has been changed 105 * by the user) and a default value (which will be returned if the user explicitly forces the widget 106 * to be set to the default value). 107 * Control methods allow to set the type of value to be edited (the requested type must be 108 * compatible with what the widget can handle), set the value (which replaces the currently edited 109 * value), set the value and the original value (the value passed as argument is set and is also 110 * considered to be the original value). 111 * 112 * #GdaUiDataEntry widgets are normally created using the gdaui_new_data_entry() function. 113 */ 114 115 116 117 GType gdaui_data_entry_get_type (void) G_GNUC_CONST; 118 119 void gdaui_data_entry_set_value_type (GdauiDataEntry *de, GType type); 120 GType gdaui_data_entry_get_value_type (GdauiDataEntry *de); 121 122 void gdaui_data_entry_set_value (GdauiDataEntry *de, const GValue *value); 123 GValue *gdaui_data_entry_get_value (GdauiDataEntry *de); 124 gboolean gdaui_data_entry_content_is_valid (GdauiDataEntry *de, GError **error); 125 gboolean gdaui_data_entry_validate (GdauiDataEntry *de, GError **error); 126 void gdaui_data_entry_set_reference_value (GdauiDataEntry *de, const GValue *value); 127 const GValue *gdaui_data_entry_get_reference_value (GdauiDataEntry *de); 128 void gdaui_data_entry_set_reference_current (GdauiDataEntry *de); 129 void gdaui_data_entry_set_default_value (GdauiDataEntry *de, const GValue *value); 130 131 void gdaui_data_entry_set_attributes (GdauiDataEntry *de, GdaValueAttribute attrs, 132 GdaValueAttribute mask); 133 GdaValueAttribute gdaui_data_entry_get_attributes (GdauiDataEntry *de); 134 135 GdaDataHandler *gdaui_data_entry_get_handler (GdauiDataEntry *de); 136 gboolean gdaui_data_entry_can_expand (GdauiDataEntry *de, gboolean horiz); 137 void gdaui_data_entry_set_editable (GdauiDataEntry *de, gboolean editable); 138 gboolean gdaui_data_entry_get_editable (GdauiDataEntry *de); 139 void gdaui_data_entry_grab_focus (GdauiDataEntry *de); 140 141 void gdaui_data_entry_set_unknown_color (GdauiDataEntry *de, gdouble red, gdouble green, 142 gdouble blue, gdouble alpha); 143 144 G_END_DECLS 145 146 #endif 147