1 /** \file resourcewidgetmanager.h 2 * \brief Module to manage resource widgets - header 3 * 4 * \author Bas Wassink <b.wassink@ziggo.nl> 5 */ 6 7 /* 8 * This file is part of VICE, the Versatile Commodore Emulator. 9 * See README for copyright notice. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 24 * 02111-1307 USA. 25 */ 26 27 #ifndef VICE_RESOURCEMANAGERWIDGET_H 28 #define VICE_RESOURCEMANAGERWIDGET_H 29 30 31 #include "vice.h" 32 #include <gtk/gtk.h> 33 34 /** \brief A reference to a single resource-bound widget 35 * 36 * In case the widget is one of the resource* widgets in widgets/base, the 37 * resource, reset, factory and sync fields don't need to be filled in, and 38 * NULL can be passed for those. The resource* widgets themself contain all 39 * the information to handle a reset-to-initial-state or a reset-to-factory. 40 * In case of a non base resource widget, these fields need to be filled in 41 * for the manager to work correctly. 42 */ 43 typedef struct resource_widget_entry_s { 44 GtkWidget *widget; /**< widget bound to a resource */ 45 char *resource; /**< resource name (optional) */ 46 gboolean (*reset)(GtkWidget *); /**< reset method (optional) */ 47 gboolean (*factory)(GtkWidget *); /**< factory method (optiona) */ 48 gboolean (*sync)(GtkWidget *); /**< sync method (optional) */ 49 } resource_widget_entry_t; 50 51 52 /** \brief Resource widgets manager object 53 * 54 * Keeps track of all the resource-bound widgets and allows resetting widgets 55 * and their resources to their state during construction, setting widgets 56 * and their resources to their factory setting, or synchronizing widgets with 57 * their resources, should the resources have changed and for some reason the 58 * widget wasn't updated. 59 */ 60 typedef struct resource_widget_manager_s { 61 resource_widget_entry_t **widget_list; 62 size_t widget_num; 63 size_t widget_max; 64 } resource_widget_manager_t; 65 66 67 68 void vice_resource_widget_manager_init(resource_widget_manager_t *manager); 69 void vice_resource_widget_manager_exit(resource_widget_manager_t *manager); 70 71 void vice_resource_widget_manager_add_widget( 72 resource_widget_manager_t *manager, 73 GtkWidget *widget, 74 const char *resource, 75 gboolean (*reset)(GtkWidget *), 76 gboolean (*factory)(GtkWidget *), 77 gboolean (*sync)(GtkWidget *)); 78 79 80 void vice_resource_widget_manager_dump(resource_widget_manager_t *manager); 81 82 gboolean vice_resource_widget_manager_reset(resource_widget_manager_t *manager); 83 gboolean vice_resource_widget_manager_factory(resource_widget_manager_t *manager); 84 gboolean vice_resource_widget_manager_apply(resource_widget_manager_t *manager); 85 86 #endif 87 88 89