1 /* 2 * 3 * Copyright (C) 2010-2011 Colomban Wendling <ban@herbesfolles.org> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef H_GWH_SETTINGS 21 #define H_GWH_SETTINGS 22 23 #include <stdarg.h> 24 #include <glib.h> 25 #include <glib-object.h> 26 #include <gtk/gtk.h> 27 28 G_BEGIN_DECLS 29 30 31 #define GWH_TYPE_SETTINGS (gwh_settings_get_type ()) 32 #define GWH_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GWH_TYPE_SETTINGS, GwhSettings)) 33 #define GWH_SETTINGS_CLASS(ko) (G_TYPE_CHECK_CLASS_CAST ((k), GWH_TYPE_SETTINGS, GwhSettingsClass)) 34 #define GWH_IS_SETTINGS(b) (G_TYPE_CHECK_INSTANCE_TYPE ((b), GWH_TYPE_SETTINGS)) 35 #define GWH_IS_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GWH_TYPE_SETTINGS)) 36 37 38 /** 39 * GwhSettingsNotifyFlags: 40 * @GWH_SETTINGS_NOTIFY_NONE: 0, no flags 41 * @GWH_SETTINGS_NOTIFY_ON_CONNEXION: Call user callback just after widget 42 * creation. 43 * 44 * Notification flags for gwh_settings_widget_new_full(). 45 */ 46 typedef enum _GwhSettingsNotifyFlags 47 { 48 GWH_SETTINGS_NOTIFY_NONE = 0, 49 GWH_SETTINGS_NOTIFY_ON_CONNEXION = 1<<0 50 } GwhSettingsNotifyFlags; 51 52 typedef struct _GwhSettings GwhSettings; 53 typedef struct _GwhSettingsClass GwhSettingsClass; 54 typedef struct _GwhSettingsPrivate GwhSettingsPrivate; 55 typedef void (*GwhSettingsWidgetBooleanNotify) (GwhSettings *settings, 56 gboolean value, 57 gpointer data); 58 typedef void (*GwhSettingsWidgetEnumNotify) (GwhSettings *settings, 59 gint value, 60 gpointer data); 61 typedef void (*GwhSettingsWidgetIntNotify) (GwhSettings *settings, 62 gint value, 63 gpointer data); 64 typedef void (*GwhSettingsWidgetStringNotify) (GwhSettings *settings, 65 const gchar *value, 66 gpointer data); 67 68 struct _GwhSettings 69 { 70 GObject parent; 71 72 GwhSettingsPrivate *priv; 73 }; 74 75 struct _GwhSettingsClass 76 { 77 GObjectClass parent_class; 78 }; 79 80 81 G_GNUC_INTERNAL 82 GType gwh_settings_get_type (void) G_GNUC_CONST; 83 G_GNUC_INTERNAL 84 GwhSettings *gwh_settings_get_default (void); 85 G_GNUC_INTERNAL 86 void gwh_settings_install_property (GwhSettings *self, 87 GParamSpec *pspec); 88 G_GNUC_INTERNAL 89 gboolean gwh_settings_save_to_file (GwhSettings *self, 90 const gchar *filename, 91 GError **error); 92 G_GNUC_INTERNAL 93 gboolean gwh_settings_load_from_file (GwhSettings *self, 94 const gchar *filename, 95 GError **error); 96 G_GNUC_INTERNAL 97 GtkWidget *gwh_settings_widget_new_full (GwhSettings *self, 98 const gchar *prop_name, 99 GCallback setting_changed_callback, 100 gpointer user_data, 101 GwhSettingsNotifyFlags notify_flags); 102 G_GNUC_INTERNAL 103 GtkWidget *gwh_settings_widget_new (GwhSettings *self, 104 const gchar *prop_name); 105 G_GNUC_INTERNAL 106 void gwh_settings_widget_sync_v (GwhSettings *self, 107 ...) G_GNUC_NULL_TERMINATED; 108 G_GNUC_INTERNAL 109 void gwh_settings_widget_sync (GwhSettings *self, 110 GtkWidget *widget); 111 112 113 114 G_END_DECLS 115 116 #endif /* guard */ 117