| -rw-r--r-- | Makefile | 25 | ||||
| -rw-r--r-- | gtk-bg-style-modifier.c | 206 | ||||
| -rw-r--r-- | gtk-bg-style-modifier.h | 59 | ||||
| -rw-r--r-- | gtk-range-validator.c | 255 | ||||
| -rw-r--r-- | gtk-range-validator.h | 62 | ||||
| -rw-r--r-- | gtk-style-modifier.c | 121 | ||||
| -rw-r--r-- | gtk-style-modifier.h | 62 | ||||
| -rw-r--r-- | gtk-validator.c | 271 | ||||
| -rw-r--r-- | gtk-validator.h | 68 | ||||
| -rw-r--r-- | test.c | 56 | ||||
| -rw-r--r-- | test.ui | 163 | ||||
| -rw-r--r-- | utils.c | 73 | ||||
| -rw-r--r-- | utils.h | 29 |
13 files changed, 1450 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d335099 --- a/dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +#all: libgtkvalidate.so +all: test + +NULL = + +PKGS = gtk+-2.0 + +HEADERS = *.h + +FILES = \ + gtk-validator.c \ + gtk-range-validator.c \ + gtk-style-modifier.c \ + gtk-bg-style-modifier.c \ + utils.c \ + $(NULL) + +libgtkvalidate.so: $(FILES) $(HEADERS) Makefile + $(CC) -g -shared -fPIC -o $@ -Wall -Werror $(FILES) `pkg-config --libs --cflags $(PKGS)` + +test: $(FILES) $(HEADERS) test.c Makefile + $(CC) -o $@ -fPIC -Wall -Werror $(FILES) test.c `pkg-config --libs --cflags $(PKGS)` + +clean: + rm -rf libgtkvalidate.so diff --git a/gtk-bg-style-modifier.c b/gtk-bg-style-modifier.c new file mode 100644 index 0000000..abc92a5 --- a/dev/null +++ b/gtk-bg-style-modifier.c @@ -0,0 +1,206 @@ +/* gtk-bg-style-modifier.c + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#include <string.h> + +#include "gtk-bg-style-modifier.h" + +G_DEFINE_TYPE (GtkBgStyleModifier, gtk_bg_style_modifier, GTK_TYPE_STYLE_MODIFIER) + +enum +{ + PROP_0, + PROP_COLOR, +}; + +struct _GtkBgStyleModifierPrivate +{ + gchar *color; + GHashTable *hash; +}; + +static void +gtk_bg_style_modifier_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_COLOR: + g_value_set_string (value, GTK_BG_STYLE_MODIFIER (object)->priv->color); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_bg_style_modifier_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_COLOR: + g_free (GTK_BG_STYLE_MODIFIER (object)->priv->color); + GTK_BG_STYLE_MODIFIER (object)->priv->color = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_bg_style_modifier_finalize (GObject *object) +{ + G_OBJECT_CLASS (gtk_bg_style_modifier_parent_class)->finalize (object); +} + +static void +gtk_bg_style_modifier_dispose (GObject *object) +{ +} + +static void +modify_invalid (GtkStyleModifier *modifier, + GtkWidget *widget) +{ + const gchar *color_str; + GdkColor color; + GHashTable *hash; + GdkColor *orig_color; + + if (!widget) + return; + + g_object_get (modifier, "color", &color_str, NULL); + hash = GTK_BG_STYLE_MODIFIER (modifier)->priv->hash; + + if (!g_hash_table_lookup (hash, widget)) { + orig_color = gdk_color_copy (&widget->style->base[GTK_STATE_NORMAL]); + g_hash_table_insert (hash, widget, orig_color); + } + + gdk_color_parse (color_str, &color); + gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &color); +} + +static void +modify_valid (GtkStyleModifier *modifier, + GtkWidget *widget) +{ + GHashTable *hash; + GdkColor *orig_color; + GdkColor color; + + if (!widget) + return; + + hash = GTK_BG_STYLE_MODIFIER (modifier)->priv->hash; + orig_color = g_hash_table_lookup (hash, widget); + if (orig_color) { + memcpy (&color, orig_color, sizeof (GdkColor)); + gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &color); + } +} + +static void +gtk_bg_style_modifier_class_init (GtkBgStyleModifierClass *klass) +{ + GObjectClass *object_class; + GtkStyleModifierClass *modifier_class; + + g_type_class_add_private (klass, sizeof (GtkBgStyleModifierPrivate)); + + object_class = G_OBJECT_CLASS (klass); + object_class->set_property = gtk_bg_style_modifier_set_property; + object_class->get_property = gtk_bg_style_modifier_get_property; + object_class->finalize = gtk_bg_style_modifier_finalize; + object_class->dispose = gtk_bg_style_modifier_dispose; + + modifier_class = GTK_STYLE_MODIFIER_CLASS (klass); + modifier_class->modify_invalid = modify_invalid; + modifier_class->modify_valid = modify_valid; + + /** + * GtkBgStyleModifier:color: + * + * The "color" property. + */ + g_object_class_install_property (object_class, + PROP_COLOR, + g_param_spec_string ("color", + "Color", + "Modified color", + NULL, + G_PARAM_READWRITE)); +} + +static void +gtk_bg_style_modifier_init (GtkBgStyleModifier *bg_style_modifier) +{ + bg_style_modifier->priv = G_TYPE_INSTANCE_GET_PRIVATE (bg_style_modifier, + GTK_TYPE_BG_STYLE_MODIFIER, + GtkBgStyleModifierPrivate); + bg_style_modifier->priv->hash = g_hash_table_new_full (g_direct_hash, + g_direct_equal, + NULL, + (GDestroyNotify)gdk_color_free); +} + +/** + * gtk_bg_style_modifier_new: + * + * Return value: + */ +GtkStyleModifier* +gtk_bg_style_modifier_new (void) +{ + return g_object_new (GTK_TYPE_BG_STYLE_MODIFIER, NULL); +} + +/** + * gtk_bg_style_modifier_get_color: + * @bg_style_modifier: A #GtkBgStyleModifier + * + * Return value: + */ +G_CONST_RETURN gchar* +gtk_bg_style_modifier_get_color (GtkBgStyleModifier *bg_style_modifier) +{ + g_return_val_if_fail (GTK_IS_BG_STYLE_MODIFIER (bg_style_modifier), NULL); + return GTK_BG_STYLE_MODIFIER (bg_style_modifier)->priv->color; +} + +/** + * gtk_bg_style_modifier_set_color: + * @bg_style_modifier: A #GtkBgStyleModifier + * @color: A #const gchar + */ +void +gtk_bg_style_modifier_set_color (GtkBgStyleModifier *bg_style_modifier, + const gchar* color) +{ + g_return_if_fail (GTK_IS_BG_STYLE_MODIFIER (bg_style_modifier)); + g_free (GTK_BG_STYLE_MODIFIER (bg_style_modifier)->priv->color); + GTK_BG_STYLE_MODIFIER (bg_style_modifier)->priv->color = g_strdup (color); + g_object_notify (G_OBJECT (bg_style_modifier), "color"); +} + diff --git a/gtk-bg-style-modifier.h b/gtk-bg-style-modifier.h new file mode 100644 index 0000000..40ab150 --- a/dev/null +++ b/gtk-bg-style-modifier.h @@ -0,0 +1,59 @@ +/* gtk-bg-style-modifier.h + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#ifndef __GTK_BG_STYLE_MODIFIER_H__ +#define __GTK_BG_STYLE_MODIFIER_H__ + +#include "gtk-style-modifier.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_BG_STYLE_MODIFIER (gtk_bg_style_modifier_get_type()) +#define GTK_BG_STYLE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BG_STYLE_MODIFIER, GtkBgStyleModifier)) +#define GTK_BG_STYLE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BG_STYLE_MODIFIER, GtkBgStyleModifierClass)) +#define GTK_IS_BG_STYLE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BG_STYLE_MODIFIER)) +#define GTK_IS_BG_STYLE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BG_STYLE_MODIFIER)) +#define GTK_BG_STYLE_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BG_STYLE_MODIFIER, GtkBgStyleModifierClass)) + +typedef struct _GtkBgStyleModifier GtkBgStyleModifier; +typedef struct _GtkBgStyleModifierClass GtkBgStyleModifierClass; +typedef struct _GtkBgStyleModifierPrivate GtkBgStyleModifierPrivate; + +struct _GtkBgStyleModifier +{ + GtkStyleModifier parent; + + /*< private >*/ + GtkBgStyleModifierPrivate *priv; +}; + +struct _GtkBgStyleModifierClass +{ + GtkStyleModifierClass parent_class; +}; + +GType gtk_bg_style_modifier_get_type (void); +GtkStyleModifier* gtk_bg_style_modifier_new (void); +G_CONST_RETURN gchar* gtk_bg_style_modifier_get_color (GtkBgStyleModifier *bg_style_modifier); +void gtk_bg_style_modifier_set_color (GtkBgStyleModifier *bg_style_modifier, const gchar* color); + +G_END_DECLS + +#endif /* __GTK_BG_STYLE_MODIFIER_H__ */ diff --git a/gtk-range-validator.c b/gtk-range-validator.c new file mode 100644 index 0000000..90ac109 --- a/dev/null +++ b/gtk-range-validator.c @@ -0,0 +1,255 @@ +/* gtk-range-validator.c + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#include <stdlib.h> + +#include "gtk-range-validator.h" + +G_DEFINE_TYPE (GtkRangeValidator, gtk_range_validator, GTK_TYPE_VALIDATOR) + +enum +{ + PROP_0, + PROP_LOWER, + PROP_UPPER, +}; + +struct _GtkRangeValidatorPrivate +{ + gdouble lower; + gdouble upper; +}; + +static void +gtk_range_validator_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_LOWER: + g_value_set_double (value, GTK_RANGE_VALIDATOR (object)->priv->lower); + break; + case PROP_UPPER: + g_value_set_double (value, GTK_RANGE_VALIDATOR (object)->priv->upper); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_range_validator_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_LOWER: + GTK_RANGE_VALIDATOR (object)->priv->lower = g_value_get_double (value); + break; + case PROP_UPPER: + GTK_RANGE_VALIDATOR (object)->priv->upper = g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_range_validator_finalize (GObject *object) +{ + G_OBJECT_CLASS (gtk_range_validator_parent_class)->finalize (object); +} + +static void +gtk_range_validator_dispose (GObject *object) +{ +} + +static gboolean +gtk_range_validator_real_validate (GtkValidator *validator) +{ + GtkWidget *widget; + const gchar *prop_name; + GValue value = {0,}; + gdouble dbl_val = 0, + lower = 0, + upper = 0; + gboolean success = FALSE; + GParamSpec *pspec; + + g_object_get (validator, + "widget", &widget, + "prop_name", &prop_name, + "lower", &lower, + "upper", &upper, + NULL); + + if (!widget) + return FALSE; + + if (!(pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (widget), prop_name))) + return FALSE; + + if (pspec->value_type == G_TYPE_STRING) { + g_value_init (&value, G_TYPE_STRING); + g_object_get_property (G_OBJECT (widget), prop_name, &value); + dbl_val = atof (g_value_get_string (&value)); + } + else if (pspec->value_type == G_TYPE_INT || pspec->value_type == G_TYPE_UINT || + pspec->value_type == G_TYPE_INT64 || pspec->value_type == G_TYPE_UINT64 || + pspec->value_type == G_TYPE_LONG || pspec->value_type == G_TYPE_ULONG || + pspec->value_type == G_TYPE_DOUBLE) + { + g_value_init (&value, G_TYPE_DOUBLE); + g_object_get_property (G_OBJECT (widget), prop_name, &value); + dbl_val = g_value_get_double (&value); + } + else return FALSE; + + if (dbl_val <= upper && dbl_val >= lower) + success = TRUE; + + g_value_unset (&value); + return success; +} + +static void +gtk_range_validator_class_init (GtkRangeValidatorClass *klass) +{ + GObjectClass *object_class; + GtkValidatorClass *validator_class; + + g_type_class_add_private (klass, sizeof (GtkRangeValidatorPrivate)); + + object_class = G_OBJECT_CLASS (klass); + object_class->set_property = gtk_range_validator_set_property; + object_class->get_property = gtk_range_validator_get_property; + object_class->finalize = gtk_range_validator_finalize; + object_class->dispose = gtk_range_validator_dispose; + + validator_class = GTK_VALIDATOR_CLASS (klass); + validator_class->validate = gtk_range_validator_real_validate; + + /** + * GtkRangeValidator:lower: + * + * The "lower" property. + */ + g_object_class_install_property (object_class, + PROP_LOWER, + g_param_spec_double ("lower", + "Lower", + "Lower range", + -G_MINDOUBLE, + G_MAXDOUBLE, + 0, + G_PARAM_READWRITE)); + + /** + * GtkRangeValidator:upper: + * + * The "upper" property. + */ + g_object_class_install_property (object_class, + PROP_UPPER, + g_param_spec_double ("upper", + "Upper", + "Upper range", + -G_MINDOUBLE, + G_MAXDOUBLE, + 0, + G_PARAM_READWRITE)); +} + +static void +gtk_range_validator_init (GtkRangeValidator *range_validator) +{ + range_validator->priv = G_TYPE_INSTANCE_GET_PRIVATE (range_validator, + GTK_TYPE_RANGE_VALIDATOR, + GtkRangeValidatorPrivate); +} + +/** + * gtk_range_validator_new: + * + * Return value: + */ +GtkValidator* +gtk_range_validator_new (void) +{ + return g_object_new (GTK_TYPE_RANGE_VALIDATOR, NULL); +} + +/** + * gtk_range_validator_get_lower: + * @range_validator: A #GtkRangeValidator + * + * Return value: + */ +gdouble +gtk_range_validator_get_lower (GtkRangeValidator *range_validator) +{ + g_return_val_if_fail (GTK_IS_RANGE_VALIDATOR (range_validator), 0); + return GTK_RANGE_VALIDATOR (range_validator)->priv->lower; +} + +/** + * gtk_range_validator_set_lower: + * @range_validator: A #GtkRangeValidator + * @lower: A #gdouble + */ +void +gtk_range_validator_set_lower (GtkRangeValidator *range_validator, + gdouble lower) +{ + g_return_if_fail (GTK_IS_RANGE_VALIDATOR (range_validator)); + GTK_RANGE_VALIDATOR (range_validator)->priv->lower = lower; + g_object_notify (G_OBJECT (range_validator), "lower"); +} + +/** + * gtk_range_validator_get_upper: + * @range_validator: A #GtkRangeValidator + * + * Return value: + */ +gdouble +gtk_range_validator_get_upper (GtkRangeValidator *range_validator) +{ + g_return_val_if_fail (GTK_IS_RANGE_VALIDATOR (range_validator), 0); + return GTK_RANGE_VALIDATOR (range_validator)->priv->upper; +} + +/** + * gtk_range_validator_set_upper: + * @range_validator: A #GtkRangeValidator + * @upper: A #gdouble + */ +void +gtk_range_validator_set_upper (GtkRangeValidator *range_validator, + gdouble upper) +{ + g_return_if_fail (GTK_IS_RANGE_VALIDATOR (range_validator)); + GTK_RANGE_VALIDATOR (range_validator)->priv->upper = upper; + g_object_notify (G_OBJECT (range_validator), "upper"); +} + diff --git a/gtk-range-validator.h b/gtk-range-validator.h new file mode 100644 index 0000000..d3fa9c8 --- a/dev/null +++ b/gtk-range-validator.h @@ -0,0 +1,62 @@ +/* gtk-range-validator.h + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#ifndef __GTK_RANGE_VALIDATOR_H__ +#define __GTK_RANGE_VALIDATOR_H__ + +#include "gtk-validator.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_RANGE_VALIDATOR (gtk_range_validator_get_type()) +#define GTK_RANGE_VALIDATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RANGE_VALIDATOR, GtkRangeValidator)) +#define GTK_RANGE_VALIDATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RANGE_VALIDATOR, GtkRangeValidatorClass)) +#define GTK_IS_RANGE_VALIDATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RANGE_VALIDATOR)) +#define GTK_IS_RANGE_VALIDATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RANGE_VALIDATOR)) +#define GTK_RANGE_VALIDATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RANGE_VALIDATOR, GtkRangeValidatorClass)) + +typedef struct _GtkRangeValidator GtkRangeValidator; +typedef struct _GtkRangeValidatorClass GtkRangeValidatorClass; +typedef struct _GtkRangeValidatorPrivate GtkRangeValidatorPrivate; + +struct _GtkRangeValidator +{ + GtkValidator parent; + + /*< private >*/ + GtkRangeValidatorPrivate *priv; +}; + +struct _GtkRangeValidatorClass +{ + GtkValidatorClass parent_class; +}; + +GType gtk_range_validator_get_type (void); +GtkValidator* gtk_range_validator_new (void); + +gdouble gtk_range_validator_get_lower (GtkRangeValidator *range_validator); +void gtk_range_validator_set_lower (GtkRangeValidator *range_validator, gdouble lower); +gdouble gtk_range_validator_get_upper (GtkRangeValidator *range_validator); +void gtk_range_validator_set_upper (GtkRangeValidator *range_validator, gdouble upper); + +G_END_DECLS + +#endif /* __GTK_RANGE_VALIDATOR_H__ */ diff --git a/gtk-style-modifier.c b/gtk-style-modifier.c new file mode 100644 index 0000000..e2d4edd --- a/dev/null +++ b/gtk-style-modifier.c @@ -0,0 +1,121 @@ +/* gtk-style-modifier.c + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#include "gtk-style-modifier.h" + +G_DEFINE_TYPE (GtkStyleModifier, gtk_style_modifier, G_TYPE_OBJECT) + +struct _GtkStyleModifierPrivate +{ + gpointer dummy; +}; + +static void +gtk_style_modifier_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_style_modifier_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_style_modifier_finalize (GObject *object) +{ + G_OBJECT_CLASS (gtk_style_modifier_parent_class)->finalize (object); +} + +static void +gtk_style_modifier_dispose (GObject *object) +{ +} + +static void +gtk_style_modifier_class_init (GtkStyleModifierClass *klass) +{ + GObjectClass *object_class; + + g_type_class_add_private (klass, sizeof (GtkStyleModifierPrivate)); + + object_class = G_OBJECT_CLASS (klass); + object_class->set_property = gtk_style_modifier_set_property; + object_class->get_property = gtk_style_modifier_get_property; + object_class->finalize = gtk_style_modifier_finalize; + object_class->dispose = gtk_style_modifier_dispose; +} + +static void +gtk_style_modifier_init (GtkStyleModifier *style_modifier) +{ + style_modifier->priv = G_TYPE_INSTANCE_GET_PRIVATE (style_modifier, + GTK_TYPE_STYLE_MODIFIER, + GtkStyleModifierPrivate); +} + +/** + * gtk_style_modifier_new: + * + * Return value: + */ +GtkStyleModifier* +gtk_style_modifier_new (void) +{ + return g_object_new (GTK_TYPE_STYLE_MODIFIER, NULL); +} + +/** + * gtk_style_modifier_modify_valid: + * @style_modifier: A #GtkStyleModifier + */ +void +gtk_style_modifier_modify_valid (GtkStyleModifier *style_modifier, + GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_STYLE_MODIFIER (style_modifier)); + GTK_STYLE_MODIFIER_GET_CLASS (style_modifier)->modify_valid (style_modifier, widget); +} + +/** + * gtk_style_modifier_modify_invalid: + * @style_modifier: A #GtkStyleModifier + */ +void +gtk_style_modifier_modify_invalid (GtkStyleModifier *style_modifier, + GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_STYLE_MODIFIER (style_modifier)); + GTK_STYLE_MODIFIER_GET_CLASS (style_modifier)->modify_invalid (style_modifier, widget); +} + diff --git a/gtk-style-modifier.h b/gtk-style-modifier.h new file mode 100644 index 0000000..687e527 --- a/dev/null +++ b/gtk-style-modifier.h @@ -0,0 +1,62 @@ +/* gtk-style-modifier.h + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#ifndef __GTK_STYLE_MODIFIER_H__ +#define __GTK_STYLE_MODIFIER_H__ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GTK_TYPE_STYLE_MODIFIER (gtk_style_modifier_get_type()) +#define GTK_STYLE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STYLE_MODIFIER, GtkStyleModifier)) +#define GTK_STYLE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STYLE_MODIFIER, GtkStyleModifierClass)) +#define GTK_IS_STYLE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STYLE_MODIFIER)) +#define GTK_IS_STYLE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STYLE_MODIFIER)) +#define GTK_STYLE_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STYLE_MODIFIER, GtkStyleModifierClass)) + +typedef struct _GtkStyleModifier GtkStyleModifier; +typedef struct _GtkStyleModifierClass GtkStyleModifierClass; +typedef struct _GtkStyleModifierPrivate GtkStyleModifierPrivate; + +struct _GtkStyleModifier +{ + GObject parent; + + /*< private >*/ + GtkStyleModifierPrivate *priv; +}; + +struct _GtkStyleModifierClass +{ + GObjectClass parent_class; + + void (*modify_invalid) (GtkStyleModifier *style_modifier, GtkWidget *widget); + void (*modify_valid) (GtkStyleModifier *style_modifier, GtkWidget *widget); +}; + +GType gtk_style_modifier_get_type (void); +GtkStyleModifier* gtk_style_modifier_new (void); +void gtk_style_modifier_modify_valid (GtkStyleModifier *style_modifier, GtkWidget *widget); +void gtk_style_modifier_modify_invalid (GtkStyleModifier *style_modifier, GtkWidget *widget); + +G_END_DECLS + +#endif /* __GTK_STYLE_MODIFIER_H__ */ diff --git a/gtk-validator.c b/gtk-validator.c new file mode 100644 index 0000000..14ff75f --- a/dev/null +++ b/gtk-validator.c @@ -0,0 +1,271 @@ +/* gtk-validator.c + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#include "gtk-validator.h" + +G_DEFINE_ABSTRACT_TYPE (GtkValidator, gtk_validator, G_TYPE_OBJECT) + +enum +{ + PROP_0, + PROP_MODIFIER, + PROP_WIDGET, + PROP_PROP_NAME, +}; + +struct _GtkValidatorPrivate +{ + GtkStyleModifier *modifier; + GtkWidget *widget; + gchar *prop_name; +}; + +static void +gtk_validator_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MODIFIER: + g_value_set_object (value, gtk_validator_get_modifier (GTK_VALIDATOR (object))); + break; + case PROP_WIDGET: + g_value_set_object (value, gtk_validator_get_widget (GTK_VALIDATOR (object))); + break; + case PROP_PROP_NAME: + g_value_set_string (value, GTK_VALIDATOR (object)->priv->prop_name); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_validator_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MODIFIER: + gtk_validator_set_modifier (GTK_VALIDATOR (object), + GTK_STYLE_MODIFIER (g_value_get_object (value))); + break; + case PROP_WIDGET: + gtk_validator_set_widget (GTK_VALIDATOR (object), + GTK_WIDGET (g_value_get_object (value))); + break; + case PROP_PROP_NAME: + g_free (GTK_VALIDATOR (object)->priv->prop_name); + GTK_VALIDATOR (object)->priv->prop_name = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +gtk_validator_finalize (GObject *object) +{ + G_OBJECT_CLASS (gtk_validator_parent_class)->finalize (object); +} + +static void +gtk_validator_dispose (GObject *object) +{ +} + +static void +gtk_validator_class_init (GtkValidatorClass *klass) +{ + GObjectClass *object_class; + + g_type_class_add_private (klass, sizeof (GtkValidatorPrivate)); + + object_class = G_OBJECT_CLASS (klass); + object_class->set_property = gtk_validator_set_property; + object_class->get_property = gtk_validator_get_property; + object_class->finalize = gtk_validator_finalize; + object_class->dispose = gtk_validator_dispose; + + /** + * GtkValidator:modifier: + * + * The "modifier" property. + */ + g_object_class_install_property (object_class, + PROP_MODIFIER, + g_param_spec_object ("modifier", + "Modifier", + "Widget style modifier", + GTK_TYPE_STYLE_MODIFIER, + G_PARAM_READWRITE)); + + /** + * GtkValidator:widget: + * + * The "widget" property. + */ + g_object_class_install_property (object_class, + PROP_WIDGET, + g_param_spec_object ("widget", + "Widget", + "Widget to validate", + GTK_TYPE_WIDGET, + G_PARAM_READWRITE)); + + /** + * GtkValidator:prop-name: + * + * The "prop-name" property. + */ + g_object_class_install_property (object_class, + PROP_PROP_NAME, + g_param_spec_string ("prop-name", + "PropName", + "Name of property to validate", + NULL, + G_PARAM_READWRITE)); +} + +static void +gtk_validator_init (GtkValidator *validator) +{ + validator->priv = G_TYPE_INSTANCE_GET_PRIVATE (validator, + GTK_TYPE_VALIDATOR, + GtkValidatorPrivate); +} + +/** + * gtk_validator_get_modifier: + * @validator: A #GtkValidator + * + * Return value: + */ +GtkStyleModifier* +gtk_validator_get_modifier (GtkValidator *validator) +{ + g_return_val_if_fail (GTK_IS_VALIDATOR (validator), NULL); + return GTK_STYLE_MODIFIER (GTK_VALIDATOR (validator)->priv->modifier); +} + +/** + * gtk_validator_set_modifier: + * @validator: A #GtkValidator + * @modifier: A #GObject + */ +void +gtk_validator_set_modifier (GtkValidator *validator, + GtkStyleModifier *modifier) +{ + g_return_if_fail (GTK_IS_VALIDATOR (validator)); + if (GTK_VALIDATOR (validator)->priv->modifier) + g_object_unref (GTK_VALIDATOR (validator)->priv->modifier); + GTK_VALIDATOR (validator)->priv->modifier = g_object_ref (modifier); + g_object_notify (G_OBJECT (validator), "modifier"); +} + +/** + * gtk_validator_get_widget: + * @validator: A #GtkValidator + * + * Return value: + */ +GtkWidget* +gtk_validator_get_widget (GtkValidator *validator) +{ + g_return_val_if_fail (GTK_IS_VALIDATOR (validator), NULL); + return GTK_VALIDATOR (validator)->priv->widget; +} + +/** + * gtk_validator_set_widget: + * @validator: A #GtkValidator + * @widget: A #GtkWidget + * + */ +void +gtk_validator_set_widget (GtkValidator *validator, + GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_VALIDATOR (validator)); + if (GTK_VALIDATOR (validator)->priv->widget) + g_object_unref (GTK_VALIDATOR (validator)->priv->widget); + GTK_VALIDATOR (validator)->priv->widget = g_object_ref (widget); + g_object_notify (G_OBJECT (validator), "widget"); +} + +/** + * gtk_validator_get_prop_name: + * @validator: A #GtkValidator + * + * Return value: + */ +G_CONST_RETURN gchar* +gtk_validator_get_prop_name (GtkValidator *validator) +{ + g_return_val_if_fail (GTK_IS_VALIDATOR (validator), NULL); + return GTK_VALIDATOR (validator)->priv->prop_name; +} + +/** + * gtk_validator_set_prop_name: + * @validator: A #GtkValidator + * @prop_name: A #const gchar + */ +void +gtk_validator_set_prop_name (GtkValidator *validator, + const gchar* prop_name) +{ + g_return_if_fail (GTK_IS_VALIDATOR (validator)); + g_free (GTK_VALIDATOR (validator)->priv->prop_name); + GTK_VALIDATOR (validator)->priv->prop_name = g_strdup (prop_name); + g_object_notify (G_OBJECT (validator), "prop-name"); +} + +/** + * gtk_validator_validate: + * @validator: A #GtkValidator + * + * Return value: + */ +gboolean +gtk_validator_validate (GtkValidator *validator) +{ + GtkValidatorPrivate *priv; + gboolean success; + + g_return_val_if_fail (GTK_IS_VALIDATOR (validator), FALSE); + + priv = validator->priv; + success = GTK_VALIDATOR_GET_CLASS (validator)->validate (validator); + + if (priv->modifier) { + if (success) + gtk_style_modifier_modify_valid (priv->modifier, priv->widget); + else + gtk_style_modifier_modify_invalid (priv->modifier, priv->widget); + } + + g_debug ("Success: %d", success); + + return success; +} diff --git a/gtk-validator.h b/gtk-validator.h new file mode 100644 index 0000000..17df76e --- a/dev/null +++ b/gtk-validator.h @@ -0,0 +1,68 @@ +/* gtk-validator.h + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + * 02110-1301 USA + */ + +#ifndef __GTK_VALIDATOR_H__ +#define __GTK_VALIDATOR_H__ + +#include <gtk/gtk.h> + +#include "gtk-style-modifier.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_VALIDATOR (gtk_validator_get_type()) +#define GTK_VALIDATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_VALIDATOR, GtkValidator)) +#define GTK_VALIDATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_VALIDATOR, GtkValidatorClass)) +#define GTK_IS_VALIDATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_VALIDATOR)) +#define GTK_IS_VALIDATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_VALIDATOR)) +#define GTK_VALIDATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_VALIDATOR, GtkValidatorClass)) + +typedef struct _GtkValidator GtkValidator; +typedef struct _GtkValidatorClass GtkValidatorClass; +typedef struct _GtkValidatorPrivate GtkValidatorPrivate; + +struct _GtkValidator +{ + GObject parent; + + /*< private >*/ + GtkValidatorPrivate *priv; +}; + +struct _GtkValidatorClass +{ + GObjectClass parent_class; + + gboolean (*validate) (GtkValidator *validator); +}; + +GType gtk_validator_get_type (void); +GtkValidator* gtk_validator_new (void); +gboolean gtk_validator_validate (GtkValidator *validator); +GtkStyleModifier* gtk_validator_get_modifier (GtkValidator *validator); +void gtk_validator_set_modifier (GtkValidator *validator, GtkStyleModifier *modifier); +GtkWidget* gtk_validator_get_widget (GtkValidator *validator); +void gtk_validator_set_widget (GtkValidator *validator, GtkWidget *widget); +G_CONST_RETURN gchar* gtk_validator_get_prop_name (GtkValidator *validator); +void gtk_validator_set_prop_name (GtkValidator *validator, const gchar *prop_name); + +G_END_DECLS + +#endif /* __GTK_VALIDATOR_H__ */ @@ -0,0 +1,56 @@ +#include <gtk/gtk.h> +#include "gtk-range-validator.h" +#include "gtk-bg-style-modifier.h" +#include "utils.h" + +int main (int argc, char *argv[]) +{ + GtkBuilder *builder; + GtkWidget *dialog, + *apply, + *spinbutton, + *entry; + GtkValidator *range, *range2; + GtkStyleModifier *bg_modifier; + + gtk_init (&argc, &argv); + + builder = gtk_builder_new (); + gtk_builder_add_file_or_exit (builder, "test.ui"); + gtk_builder_get_objects_ex (builder, + "dialog", &dialog, + "apply", &apply, + "spinbutton", &spinbutton, + "entry", &entry, + NULL); + + bg_modifier = gtk_bg_style_modifier_new (); + g_object_set (bg_modifier, "color", "#f84848", NULL); + + range = gtk_range_validator_new (); + g_object_set (range, + "widget", spinbutton, + "modifier", bg_modifier, + "prop-name", "value", + "lower", 0.0, + "upper", 10.0, + NULL); + + range2 = gtk_range_validator_new (); + g_object_set (range2, + "widget", entry, + "prop-name", "text", + "lower", 0.0, + "upper", 10.0, + "modifier", bg_modifier, + NULL); + + g_signal_connect (dialog, "destroy", gtk_main_quit, NULL); + g_signal_connect_swapped (apply, "clicked", G_CALLBACK (gtk_validator_validate), range); + g_signal_connect_swapped (apply, "clicked", G_CALLBACK (gtk_validator_validate), range2); + //g_signal_connect_swapped (apply, "clicked", G_CALLBACK (gtk_widget_hide), dialog); + gtk_widget_show (dialog); + gtk_main (); + + return 0; +} @@ -0,0 +1,163 @@ +<?xml version="1.0"?> +<interface> + <requires lib="gtk+" version="2.16"/> + <!-- interface-naming-policy project-wide --> + <object class="GtkDialog" id="dialog"> + <property name="border_width">5</property> + <property name="type_hint">normal</property> + <property name="has_separator">False</property> + <signal name="delete_event" handler="gtk_main_quit"/> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">3</property> + <property name="column_spacing">6</property> + <property name="row_spacing">3</property> + <child> + <object class="GtkSpinButton" id="spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="max_length">5</property> + <property name="invisible_char">●</property> + <property name="adjustment">adjustment1</property> + <property name="digits">5</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Range Validator</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Range Validator</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button1"> + <property name="label" translatable="yes">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="apply"> + <property name="label" translatable="yes">gtk-apply</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">button1</action-widget> + <action-widget response="0">apply</action-widget> + </action-widgets> + </object> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + <property name="page_size">10</property> + </object> +</interface> @@ -0,0 +1,73 @@ +/* marina-utils.c + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with This; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#include <stdlib.h> +#include <glib.h> +#include <glib/gi18n.h> + +#include "utils.h" + +void +gtk_builder_add_file_or_exit (GtkBuilder *builder, + const gchar *ui_file) +{ + GError *error = NULL; + gchar *builder_file = NULL; + + builder_file = g_build_filename (".", ui_file, NULL); + + if (!gtk_builder_add_from_file (builder, builder_file, &error)) { + g_printerr (_("\n Marina could not locate the user interface definitions. This\n" + " typically happens when marina has not been installed correctly.\n" + " If you are a developer looking to get started developing on\n" + " marina, you probably want \"make run\".\n\n Error: %s\n\n"), + error->message); + exit (EXIT_FAILURE); + } + + g_free (builder_file); +} + +void +gtk_builder_get_objects_ex (GtkBuilder *builder, + const gchar *first_name, ...) +{ + va_list args; + const gchar *name; + gpointer *object; + + g_return_if_fail (GTK_IS_BUILDER (builder)); + g_return_if_fail (first_name != NULL); + + va_start (args, first_name); + name = first_name; + + while (name != NULL) { + if (!(object = va_arg (args, gpointer*))) { + g_warning ("%s: Object requested without a storage location", __func__); + goto cleanup; + } + *object = gtk_builder_get_object (builder, name); + name = va_arg (args, const gchar*); + } + +cleanup: + va_end (args); +} @@ -0,0 +1,29 @@ +/* marina-utils.h + * + * Copyright (C) 2009 Christian Hergert <chris@dronelabs.com> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with This; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef __MARINA_UTILS_H__ +#define __MARINA_UTILS_H__ + +#include <gtk/gtk.h> + +void gtk_builder_add_file_or_exit (GtkBuilder *builder, const gchar *ui_file); +void gtk_builder_get_objects_ex (GtkBuilder *builder, const gchar *first_name, ...); + +#endif /* __MARINA_UTILS_H__ */ |
