1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 /* 3 property.h 4 Copyright (C) 2004 Sebastien Granjoux 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef __PROPERTY_H__ 22 #define __PROPERTY_H__ 23 24 #include <config.h> 25 26 #include <glib.h> 27 #include <gtk/gtk.h> 28 29 30 typedef struct _NPWProperty NPWProperty; 31 typedef struct _NPWPage NPWPage; 32 typedef struct _NPWItem NPWItem; 33 34 /* You should update the NPWPropertyTypeString array in the .c file, 35 * after changing the NPWPropertyType enum */ 36 typedef enum { 37 NPW_UNKNOWN_PROPERTY = 0, 38 NPW_HIDDEN_PROPERTY, 39 NPW_BOOLEAN_PROPERTY, 40 NPW_INTEGER_PROPERTY, 41 NPW_STRING_PROPERTY, 42 NPW_LIST_PROPERTY, 43 NPW_DIRECTORY_PROPERTY, 44 NPW_FILE_PROPERTY, 45 NPW_ICON_PROPERTY, 46 NPW_PACKAGE_PROPERTY, 47 NPW_LAST_PROPERTY 48 } NPWPropertyType; 49 50 /* You should update the NPWPropertyRestrictionString array in the .c file, 51 * after changing the NPWPropertyRestriction enum */ 52 typedef enum { 53 NPW_NO_RESTRICTION = 0, 54 NPW_FILENAME_RESTRICTION, 55 NPW_DIRECTORY_RESTRICTION, 56 NPW_PRINTABLE_RESTRICTION, 57 NPW_LAST_RESTRICTION 58 } NPWPropertyRestriction; 59 60 typedef enum { 61 NPW_MANDATORY_OPTION = 1 << 0, 62 NPW_SUMMARY_OPTION = 1 << 1, 63 NPW_EDITABLE_OPTION = 1 << 2, 64 NPW_EXIST_OPTION = 1 << 3, 65 NPW_EXIST_SET_OPTION = 1 << 4 66 } NPWPropertyOptions; 67 68 typedef enum { 69 NPW_DEFAULT = -1, 70 NPW_FALSE = 0, 71 NPW_TRUE = 1 72 } NPWPropertyBooleanValue; 73 74 typedef enum 75 { 76 NPW_MIN_MARK = 0, 77 NPW_MAX_MARK = 1, 78 NPW_STEP_MARK = 2 79 } NPWPropertyRangeMark; 80 81 NPWProperty* npw_property_new (void); 82 void npw_property_free (NPWProperty* prop); 83 84 void npw_property_set_language (NPWProperty* prop, gint language); 85 void npw_property_set_type (NPWProperty* prop, NPWPropertyType type); 86 void npw_property_set_string_type (NPWProperty* prop, const gchar* type); 87 NPWPropertyType npw_property_get_type (const NPWProperty* prop); 88 89 void npw_property_set_restriction (NPWProperty* prop, NPWPropertyRestriction restriction); 90 void npw_property_set_string_restriction (NPWProperty* prop, const gchar* restriction); 91 NPWPropertyRestriction npw_property_get_restriction (const NPWProperty* prop); 92 gboolean npw_property_is_valid_restriction (const NPWProperty* prop); 93 94 void npw_property_set_name (NPWProperty* prop, const gchar* name, NPWPage *page); 95 const gchar* npw_property_get_name (const NPWProperty* prop); 96 97 void npw_property_set_label (NPWProperty* prop, const gchar* name); 98 const gchar* npw_property_get_label (const NPWProperty* prop); 99 100 void npw_property_set_description (NPWProperty* prop, const gchar* description); 101 const gchar* npw_property_get_description (const NPWProperty* prop); 102 103 GtkWidget* npw_property_create_widget (NPWProperty* prop); 104 void npw_property_set_widget (NPWProperty* prop, GtkWidget* widget); 105 GtkWidget* npw_property_get_widget (const NPWProperty* prop); 106 107 void npw_property_set_default (NPWProperty* prop, const gchar* value); 108 109 gboolean npw_property_set_range (NPWProperty* prop, NPWPropertyRangeMark mark, const gchar* value); 110 111 gboolean npw_property_update_value_from_widget (NPWProperty* prop); 112 gboolean npw_property_save_value_from_widget (NPWProperty* prop); 113 gboolean npw_property_remove_value (NPWProperty* prop); 114 const char* npw_property_get_value (const NPWProperty* prop); 115 116 gboolean npw_property_add_list_item (NPWProperty* prop, const char* name, const gchar* label, gint language); 117 118 void npw_property_set_mandatory_option (NPWProperty* prop, gboolean value); 119 void npw_property_set_summary_option (NPWProperty* prop, gboolean value); 120 void npw_property_set_editable_option (NPWProperty* prop, gboolean value); 121 NPWPropertyOptions npw_property_get_options (const NPWProperty* prop); 122 123 void npw_property_set_exist_option (NPWProperty* prop, NPWPropertyBooleanValue value); 124 NPWPropertyBooleanValue npw_property_get_exist_option (const NPWProperty* prop); 125 126 127 NPWPage* npw_page_new (GHashTable* value); 128 void npw_page_free (NPWPage* page); 129 130 gboolean npw_page_set_language (NPWPage* page, gint language); 131 132 void npw_page_set_name (NPWPage* page, const gchar* name); 133 const gchar* npw_page_get_name (const NPWPage* page); 134 135 void npw_page_set_label (NPWPage* page, const gchar* name); 136 const gchar* npw_page_get_label (const NPWPage* page); 137 138 void npw_page_set_description (NPWPage* page, const gchar* name); 139 const gchar* npw_page_get_description (const NPWPage* page); 140 141 void npw_page_set_widget (NPWPage* page, GtkWidget *widget); 142 GtkWidget *npw_page_get_widget (const NPWPage *page); 143 144 void npw_page_foreach_property (const NPWPage* page, GFunc func, gpointer data); 145 NPWProperty *npw_page_add_property (NPWPage* page, NPWProperty* prop); 146 147 #endif 148