GvnParam:
- Ahora es una interfaz en vez de una clase. SqlValue, DbParam, DbCalc, VnField: - Implementan la interfaz GvnParam. VnField: - Se ha afinado su funcionamiento. VnLogin: - Mejorada integracion con GApplication (Aun quedan cosas por hacer).
This commit is contained in:
parent
e092946ec5
commit
0048d83191
|
@ -36,17 +36,17 @@
|
|||
|
||||
/**
|
||||
* gvn_key_file_save:
|
||||
* @obj: a #GKeyFile
|
||||
* @self: a #GKeyFile
|
||||
* @file: the file name
|
||||
*
|
||||
* Creates an ini file with the contents of @obj.
|
||||
* Creates an ini file with the contents of @self.
|
||||
**/
|
||||
void gvn_key_file_save (GKeyFile * obj, const gchar * file)
|
||||
void gvn_key_file_save (GKeyFile * self, const gchar * file)
|
||||
{
|
||||
gsize len;
|
||||
gchar * aux;
|
||||
|
||||
aux = g_key_file_to_data (obj, &len, NULL);
|
||||
aux = g_key_file_to_data (self, &len, NULL);
|
||||
|
||||
if (len > 0)
|
||||
g_file_set_contents (file, aux, len, NULL);
|
||||
|
|
|
@ -53,182 +53,182 @@ GvnParamSpec * gvn_param_spec_new_with_attrs (GType gtype,
|
|||
{
|
||||
g_return_val_if_fail (G_IS_VALUE (def) || !def, NULL);
|
||||
|
||||
GvnParamSpec * obj = g_new (GvnParamSpec, 1);
|
||||
obj->gtype = gtype;
|
||||
obj->editable = editable;
|
||||
obj->null = null;
|
||||
obj->def = NULL;
|
||||
gvn_param_spec_set_default (obj, def);
|
||||
return obj;
|
||||
GvnParamSpec * self = g_new (GvnParamSpec, 1);
|
||||
self->gtype = gtype;
|
||||
self->editable = editable;
|
||||
self->null = null;
|
||||
self->def = NULL;
|
||||
gvn_param_spec_set_default (self, def);
|
||||
return self;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
|
||||
|
||||
/**
|
||||
* gvn_param_spec_get_gtype:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
*
|
||||
* Gets the type of @obj.
|
||||
* Gets the type of @self.
|
||||
*
|
||||
* Return value: the type
|
||||
**/
|
||||
GType gvn_param_spec_get_gtype (const GvnParamSpec * obj)
|
||||
GType gvn_param_spec_get_gtype (const GvnParamSpec * self)
|
||||
{
|
||||
g_return_val_if_fail (obj, G_TYPE_INVALID);
|
||||
g_return_val_if_fail (self, G_TYPE_INVALID);
|
||||
|
||||
return obj->gtype;
|
||||
return self->gtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_set_gtype:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
* @gtype: the #GType
|
||||
**/
|
||||
void gvn_param_spec_set_gtype (GvnParamSpec * obj, GType gtype)
|
||||
void gvn_param_spec_set_gtype (GvnParamSpec * self, GType gtype)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
g_return_if_fail (G_TYPE_IS_VALUE_TYPE (gtype) || gtype == G_TYPE_NONE);
|
||||
|
||||
obj->gtype = gtype;
|
||||
self->gtype = gtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_get_editable:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
**/
|
||||
gboolean gvn_param_spec_get_editable (const GvnParamSpec * obj)
|
||||
gboolean gvn_param_spec_get_editable (const GvnParamSpec * self)
|
||||
{
|
||||
g_return_val_if_fail (obj, FALSE);
|
||||
g_return_val_if_fail (self, FALSE);
|
||||
|
||||
return obj->editable;
|
||||
return self->editable;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_set_editable:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
* @editable: a %gboolean indicating whether it will be editable
|
||||
*
|
||||
* Sets if the value can be edited.
|
||||
**/
|
||||
void gvn_param_spec_set_editable (GvnParamSpec * obj, gboolean editable)
|
||||
void gvn_param_spec_set_editable (GvnParamSpec * self, gboolean editable)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
|
||||
obj->editable = editable;
|
||||
self->editable = editable;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_get_null:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
**/
|
||||
gboolean gvn_param_spec_get_null (const GvnParamSpec * obj)
|
||||
gboolean gvn_param_spec_get_null (const GvnParamSpec * self)
|
||||
{
|
||||
g_return_val_if_fail (obj, FALSE);
|
||||
g_return_val_if_fail (self, FALSE);
|
||||
|
||||
return obj->null;
|
||||
return self->null;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_set_null:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
* @null: a %gboolean indicating whether it can be null
|
||||
*
|
||||
* Set if the value can be null.
|
||||
**/
|
||||
void gvn_param_spec_set_null (GvnParamSpec * obj, gboolean null)
|
||||
void gvn_param_spec_set_null (GvnParamSpec * self, gboolean null)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
|
||||
obj->null = null;
|
||||
self->null = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_get_default:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
*
|
||||
* Gets the default value.
|
||||
*
|
||||
* Return value: the #GValue or %NULL if it havent
|
||||
**/
|
||||
const GValue * gvn_param_spec_get_default (const GvnParamSpec * obj)
|
||||
const GValue * gvn_param_spec_get_default (const GvnParamSpec * self)
|
||||
{
|
||||
g_return_val_if_fail (obj, NULL);
|
||||
g_return_val_if_fail (self, NULL);
|
||||
|
||||
return obj->def;
|
||||
return self->def;
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_set_default:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
* @def: the default #GValue
|
||||
*
|
||||
* Sets the default value.
|
||||
**/
|
||||
void gvn_param_spec_set_default (GvnParamSpec * obj, const GValue * def)
|
||||
void gvn_param_spec_set_default (GvnParamSpec * self, const GValue * def)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
g_return_if_fail (G_IS_VALUE (def) || !def);
|
||||
|
||||
if (obj->def)
|
||||
if (self->def)
|
||||
{
|
||||
g_value_unset (obj->def);
|
||||
g_free (obj->def);
|
||||
obj->def = NULL;
|
||||
g_value_unset (self->def);
|
||||
g_free (self->def);
|
||||
self->def = NULL;
|
||||
}
|
||||
if (def)
|
||||
{
|
||||
GValue * value = g_new0 (GValue, 1);
|
||||
g_value_init (value, G_VALUE_TYPE (def));
|
||||
g_value_copy (def, value);
|
||||
obj->def = value;
|
||||
self->def = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_merge:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
* @merge: (allow-none): a #GvnParamSpec
|
||||
*
|
||||
* Merges the attributes of @merge into @obj remaining the most restrictive.
|
||||
* Merges the attributes of @merge into @self remaining the most restrictive.
|
||||
**/
|
||||
void gvn_param_spec_merge (GvnParamSpec * obj, const GvnParamSpec * merge)
|
||||
void gvn_param_spec_merge (GvnParamSpec * self, const GvnParamSpec * merge)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
|
||||
if (merge)
|
||||
{
|
||||
obj->editable = obj->editable && merge->editable;
|
||||
obj->null = obj->null && merge->null;
|
||||
self->editable = self->editable && merge->editable;
|
||||
self->null = self->null && merge->null;
|
||||
|
||||
if (obj->gtype == G_TYPE_NONE)
|
||||
obj->gtype = merge->gtype;
|
||||
if (!obj->def && merge->def)
|
||||
gvn_param_spec_set_default (obj, merge->def);
|
||||
if (self->gtype == G_TYPE_NONE)
|
||||
self->gtype = merge->gtype;
|
||||
if (!self->def && merge->def)
|
||||
gvn_param_spec_set_default (self, merge->def);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_ccopy_value:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
* @src: source value to be copied
|
||||
* @dst: destination for the copied value
|
||||
*
|
||||
* Return value: %TRUE if the value has been copied, %FALSE otherwise
|
||||
**/
|
||||
gboolean gvn_param_spec_ccopy_value (const GvnParamSpec * obj, const GValue * src, GValue * dst)
|
||||
gboolean gvn_param_spec_ccopy_value (const GvnParamSpec * self, const GValue * src, GValue * dst)
|
||||
{
|
||||
g_return_val_if_fail (obj, FALSE);
|
||||
g_return_val_if_fail (self, FALSE);
|
||||
g_return_val_if_fail (G_IS_VALUE (src), FALSE);
|
||||
g_return_val_if_fail (G_IS_VALUE (dst), FALSE);
|
||||
|
||||
if (!gvn_value_is_null (src)
|
||||
&& G_VALUE_TYPE (src) != obj->gtype
|
||||
&& obj->gtype != G_TYPE_NONE)
|
||||
&& G_VALUE_TYPE (src) != self->gtype
|
||||
&& self->gtype != G_TYPE_NONE)
|
||||
{
|
||||
if (gvn_value_is_null (dst))
|
||||
{
|
||||
g_value_unset (dst);
|
||||
g_value_init (dst, obj->gtype);
|
||||
g_value_init (dst, self->gtype);
|
||||
}
|
||||
|
||||
g_value_transform (src, dst);
|
||||
|
@ -241,33 +241,33 @@ gboolean gvn_param_spec_ccopy_value (const GvnParamSpec * obj, const GValue * sr
|
|||
|
||||
/**
|
||||
* gvn_param_spec_validate:
|
||||
* @obj: #GvnParamSpec object where @GValue wants to be validated
|
||||
* @self: #GvnParamSpec object where @GValue wants to be validated
|
||||
* @value: new value
|
||||
* @err: (out) (allow-none): the return location for an allocated @GError, or
|
||||
* %NULL to ignore errors.
|
||||
*
|
||||
* It checks if the value is valid to be saved into @obj
|
||||
* It checks if the value is valid to be saved into @self
|
||||
*
|
||||
* Return value: gboolean
|
||||
**/
|
||||
gboolean gvn_param_spec_validate (const GvnParamSpec * obj, const GValue * value, GError ** err)
|
||||
gboolean gvn_param_spec_validate (const GvnParamSpec * self, const GValue * value, GError ** err)
|
||||
{
|
||||
g_return_val_if_fail (obj, FALSE);
|
||||
g_return_val_if_fail (self, FALSE);
|
||||
|
||||
gboolean is_null = gvn_value_is_null (value);
|
||||
|
||||
if (!obj->editable)
|
||||
if (!self->editable)
|
||||
g_set_error (err
|
||||
,GVN_PARAM_SPEC_LOG_DOMAIN
|
||||
,GVN_PARAM_SPEC_ERROR_NOT_EDITABLE
|
||||
,_("Param not editable"));
|
||||
else if (is_null && !obj->null)
|
||||
else if (is_null && !self->null)
|
||||
g_set_error (err
|
||||
,GVN_PARAM_SPEC_LOG_DOMAIN
|
||||
,GVN_PARAM_SPEC_ERROR_NOT_NULL
|
||||
,_("Param can't be NULL"));
|
||||
else if (!is_null && obj->gtype != G_TYPE_NONE
|
||||
&& !g_value_type_transformable (obj->gtype, G_VALUE_TYPE (value)))
|
||||
else if (!is_null && self->gtype != G_TYPE_NONE
|
||||
&& !g_value_type_transformable (self->gtype, G_VALUE_TYPE (value)))
|
||||
g_set_error (err
|
||||
,GVN_PARAM_SPEC_LOG_DOMAIN
|
||||
,GVN_PARAM_SPEC_ERROR_WRONG_TYPE
|
||||
|
@ -280,46 +280,46 @@ gboolean gvn_param_spec_validate (const GvnParamSpec * obj, const GValue * value
|
|||
|
||||
/**
|
||||
* gvn_param_spec_unset:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
**/
|
||||
void gvn_param_spec_unset (GvnParamSpec * obj)
|
||||
void gvn_param_spec_unset (GvnParamSpec * self)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
|
||||
obj->null = TRUE;
|
||||
obj->editable = TRUE;
|
||||
obj->gtype = G_TYPE_NONE;
|
||||
gvn_param_spec_set_default (obj, NULL);
|
||||
self->null = TRUE;
|
||||
self->editable = TRUE;
|
||||
self->gtype = G_TYPE_NONE;
|
||||
gvn_param_spec_set_default (self, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_copy:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
*
|
||||
* Makes a copy of @obj with the same attributes.
|
||||
* Makes a copy of @self with the same attributes.
|
||||
*
|
||||
* Return value: the new created #GvnParamSpec
|
||||
**/
|
||||
GvnParamSpec * gvn_param_spec_copy (const GvnParamSpec * obj)
|
||||
GvnParamSpec * gvn_param_spec_copy (const GvnParamSpec * self)
|
||||
{
|
||||
g_return_val_if_fail (obj, NULL);
|
||||
g_return_val_if_fail (self, NULL);
|
||||
|
||||
return gvn_param_spec_new_with_attrs (obj->gtype,
|
||||
obj->editable, obj->null, obj->def);
|
||||
return gvn_param_spec_new_with_attrs (self->gtype,
|
||||
self->editable, self->null, self->def);
|
||||
}
|
||||
|
||||
/**
|
||||
* gvn_param_spec_free:
|
||||
* @obj: a #GvnParamSpec
|
||||
* @self: a #GvnParamSpec
|
||||
*
|
||||
* Frees the memory used by @obj
|
||||
* Frees the memory used by @self
|
||||
**/
|
||||
void gvn_param_spec_free (GvnParamSpec * obj)
|
||||
void gvn_param_spec_free (GvnParamSpec * self)
|
||||
{
|
||||
g_return_if_fail (obj);
|
||||
g_return_if_fail (self);
|
||||
|
||||
gvn_param_spec_set_default (obj, NULL);
|
||||
g_free (obj);
|
||||
gvn_param_spec_set_default (self, NULL);
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GvnParamSpec, gvn_param_spec, gvn_param_spec_copy, gvn_param_spec_free);
|
||||
|
|
|
@ -63,19 +63,19 @@ GvnParamError;
|
|||
GType gvn_param_spec_get_type ();
|
||||
GvnParamSpec * gvn_param_spec_new ();
|
||||
GvnParamSpec * gvn_param_spec_new_with_attrs (GType gtype, gboolean editable, gboolean null, const GValue * def);
|
||||
GType gvn_param_spec_get_gtype (const GvnParamSpec * obj);
|
||||
void gvn_param_spec_set_gtype (GvnParamSpec * obj, GType gtype);
|
||||
gboolean gvn_param_spec_get_editable (const GvnParamSpec * obj);
|
||||
void gvn_param_spec_set_editable (GvnParamSpec * obj, gboolean editable);
|
||||
gboolean gvn_param_spec_get_null (const GvnParamSpec * obj);
|
||||
void gvn_param_spec_set_null (GvnParamSpec * obj, gboolean null);
|
||||
const GValue * gvn_param_spec_get_default (const GvnParamSpec * obj);
|
||||
void gvn_param_spec_set_default (GvnParamSpec * obj, const GValue * def);
|
||||
void gvn_param_spec_merge (GvnParamSpec * obj, const GvnParamSpec * merge);
|
||||
gboolean gvn_param_spec_ccopy_value (const GvnParamSpec * obj, const GValue * src, GValue * dst);
|
||||
gboolean gvn_param_spec_validate (const GvnParamSpec * obj, const GValue * value, GError ** err);
|
||||
void gvn_param_spec_unset (GvnParamSpec * obj);
|
||||
GvnParamSpec * gvn_param_spec_copy (const GvnParamSpec * obj);
|
||||
void gvn_param_spec_free (GvnParamSpec * obj);
|
||||
GType gvn_param_spec_get_gtype (const GvnParamSpec * self);
|
||||
void gvn_param_spec_set_gtype (GvnParamSpec * self, GType gtype);
|
||||
gboolean gvn_param_spec_get_editable (const GvnParamSpec * self);
|
||||
void gvn_param_spec_set_editable (GvnParamSpec * self, gboolean editable);
|
||||
gboolean gvn_param_spec_get_null (const GvnParamSpec * self);
|
||||
void gvn_param_spec_set_null (GvnParamSpec * self, gboolean null);
|
||||
const GValue * gvn_param_spec_get_default (const GvnParamSpec * self);
|
||||
void gvn_param_spec_set_default (GvnParamSpec * self, const GValue * def);
|
||||
void gvn_param_spec_merge (GvnParamSpec * self, const GvnParamSpec * merge);
|
||||
gboolean gvn_param_spec_ccopy_value (const GvnParamSpec * self, const GValue * src, GValue * dst);
|
||||
gboolean gvn_param_spec_validate (const GvnParamSpec * self, const GValue * value, GError ** err);
|
||||
void gvn_param_spec_unset (GvnParamSpec * self);
|
||||
GvnParamSpec * gvn_param_spec_copy (const GvnParamSpec * self);
|
||||
void gvn_param_spec_free (GvnParamSpec * self);
|
||||
|
||||
#endif
|
|
@ -21,13 +21,7 @@ G_DEFINE_TYPE (VnCustomer, vn_customer, VN_TYPE_FORM);
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_customer_open (VnForm * obj, gpointer user_data)
|
||||
{
|
||||
DbIterator * info = vn_form_get (obj, "info");
|
||||
|
||||
DbIterator * homes = vn_form_get (obj, "homes");
|
||||
db_iterator_link (homes, "user_address.user_id", info, "id");
|
||||
}
|
||||
static void vn_customer_open (VnForm * obj, gpointer user_data) {}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ VnField * vn_calendar_new ()
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_calendar_cb_day_selected (GtkCalendar * calendar, VnCalendar * obj)
|
||||
static void vn_calendar_on_day_selected (GtkCalendar * calendar, VnCalendar * self)
|
||||
{
|
||||
guint year;
|
||||
guint month;
|
||||
|
@ -58,28 +58,28 @@ static void vn_calendar_cb_day_selected (GtkCalendar * calendar, VnCalendar * ob
|
|||
g_date_clear (&new_date, 1);
|
||||
g_date_set_dmy (&new_date, day, month, year);
|
||||
|
||||
if (!g_date_valid (&obj->date) || g_date_compare (&new_date, &obj->date))
|
||||
if (!g_date_valid (&self->date) || g_date_compare (&new_date, &self->date))
|
||||
{
|
||||
g_date_set_julian (&obj->date, g_date_get_julian (&new_date));
|
||||
g_date_set_julian (&self->date, g_date_get_julian (&new_date));
|
||||
gtk_calendar_mark_day (calendar, day);
|
||||
g_value_init (&value, G_TYPE_DATE);
|
||||
g_value_set_boxed (&value, &obj->date);
|
||||
g_value_set_boxed (&value, &self->date);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_date_clear (&obj->date, 1);
|
||||
g_date_clear (&self->date, 1);
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
}
|
||||
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
void vn_calendar_cb_month_changed (GtkCalendar * calendar, VnCalendar * obj)
|
||||
void vn_calendar_on_month_changed (GtkCalendar * calendar, VnCalendar * self)
|
||||
{
|
||||
guint year;
|
||||
guint month;
|
||||
GDate * date = &obj->date;
|
||||
GDate * date = &self->date;
|
||||
|
||||
gtk_calendar_clear_marks (calendar);
|
||||
gtk_calendar_get_date (calendar, &year, &month, NULL);
|
||||
|
@ -90,13 +90,13 @@ void vn_calendar_cb_month_changed (GtkCalendar * calendar, VnCalendar * obj)
|
|||
{
|
||||
guint day = g_date_get_day (date);
|
||||
gtk_calendar_mark_day (calendar, day);
|
||||
gtk_calendar_select_day (obj->calendar, day);
|
||||
gtk_calendar_select_day (self->calendar, day);
|
||||
}
|
||||
else
|
||||
gtk_calendar_select_day (obj->calendar, 0);
|
||||
gtk_calendar_select_day (self->calendar, 0);
|
||||
}
|
||||
|
||||
static void vn_calendar_set_value (VnCalendar * obj, const GValue * value)
|
||||
static void vn_calendar_set_value (VnCalendar * self, const GValue * value)
|
||||
{
|
||||
GDate * date = NULL;
|
||||
|
||||
|
@ -112,41 +112,43 @@ static void vn_calendar_set_value (VnCalendar * obj, const GValue * value)
|
|||
|
||||
if (date)
|
||||
{
|
||||
obj->date = *date;
|
||||
gtk_calendar_select_month (obj->calendar
|
||||
self->date = *date;
|
||||
gtk_calendar_select_month (self->calendar
|
||||
,g_date_get_month (date) - 1
|
||||
,g_date_get_year (date)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_date_clear (&obj->date, 1);
|
||||
gtk_calendar_select_day (obj->calendar, 0);
|
||||
gtk_calendar_clear_marks (obj->calendar);
|
||||
g_date_clear (&self->date, 1);
|
||||
gtk_calendar_select_day (self->calendar, 0);
|
||||
gtk_calendar_clear_marks (self->calendar);
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_calendar_init (VnCalendar * obj)
|
||||
static void vn_calendar_init (VnCalendar * self)
|
||||
{
|
||||
g_date_clear (&obj->date, 1);
|
||||
g_date_clear (&self->date, 1);
|
||||
|
||||
obj->calendar = GTK_CALENDAR (gtk_calendar_new ());
|
||||
gtk_calendar_set_display_options (obj->calendar,
|
||||
self->calendar = GTK_CALENDAR (gtk_calendar_new ());
|
||||
gtk_calendar_set_display_options (self->calendar,
|
||||
GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
|
||||
g_object_connect (obj->calendar
|
||||
,"signal::day-selected-double-click", vn_calendar_cb_day_selected, obj
|
||||
,"signal::month-changed", vn_calendar_cb_month_changed, obj
|
||||
g_object_connect (self->calendar
|
||||
,"signal::day-selected-double-click", vn_calendar_on_day_selected, self
|
||||
,"signal::month-changed", vn_calendar_on_month_changed, self
|
||||
,NULL
|
||||
);
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->calendar));
|
||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->calendar);
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->calendar));
|
||||
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->calendar));
|
||||
}
|
||||
|
||||
static void vn_calendar_finalize (VnCalendar * obj)
|
||||
static void vn_calendar_finalize (VnCalendar * self)
|
||||
{
|
||||
G_OBJECT_CLASS (vn_calendar_parent_class)->finalize (G_OBJECT (obj));
|
||||
G_OBJECT_CLASS (vn_calendar_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_calendar_class_init (VnCalendarClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_CALENDAR (vn_calendar_get_type ())
|
||||
#define VN_CALENDAR(object) (G_TYPE_CHECK_INSTANCE_CAST (object, VN_TYPE_CALENDAR , VnCalendar))
|
||||
#define VN_IS_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_CALENDAR))
|
||||
#define VN_CALENDAR(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_CALENDAR , VnCalendar))
|
||||
#define VN_IS_CALENDAR(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_CALENDAR))
|
||||
#define VN_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_CALENDAR, VnCalendarClass))
|
||||
#define VN_IS_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_CALENDAR))
|
||||
#define VN_CALENDAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_CALENDAR, VnCalendarClass))
|
||||
#define VN_CALENDAR_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_CALENDAR, VnCalendarClass))
|
||||
|
||||
typedef struct _VnCalendar VnCalendar;
|
||||
typedef struct _VnCalendarClass VnCalendarClass;
|
||||
|
|
|
@ -43,31 +43,31 @@ VnField * vn_check_new ()
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_check_changed (VnCheck * obj)
|
||||
static void vn_check_changed (VnCheck * self)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
if (!gtk_toggle_button_get_inconsistent (obj->button))
|
||||
if (!gtk_toggle_button_get_inconsistent (self->button))
|
||||
{
|
||||
g_value_init (&value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (&value, gtk_toggle_button_get_active (obj->button));
|
||||
g_value_set_boolean (&value, gtk_toggle_button_get_active (self->button));
|
||||
}
|
||||
else
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static void vn_check_on_toggled (GtkToggleButton * button, VnCheck * obj)
|
||||
static void vn_check_on_toggled (GtkToggleButton * button, VnCheck * self)
|
||||
{
|
||||
gtk_toggle_button_set_inconsistent (button, FALSE);
|
||||
vn_check_changed (obj);
|
||||
vn_check_changed (self);
|
||||
}
|
||||
|
||||
static gboolean vn_check_on_secondary_button (GtkToggleButton * button, GdkEventButton * event, VnField * obj)
|
||||
static gboolean vn_check_on_secondary_button (GtkToggleButton * button, GdkEventButton * event, VnField * self)
|
||||
{
|
||||
if (event->type != GDK_BUTTON_RELEASE || event->button != 3 || !vn_field_get_null (obj))
|
||||
if (event->type != GDK_BUTTON_RELEASE || event->button != 3 || !vn_field_get_null (self))
|
||||
return FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_inconsistent (button))
|
||||
|
@ -75,15 +75,15 @@ static gboolean vn_check_on_secondary_button (GtkToggleButton * button, GdkEvent
|
|||
else
|
||||
gtk_toggle_button_set_inconsistent (button, TRUE);
|
||||
|
||||
g_signal_handlers_block_by_func (button, vn_check_on_toggled, obj);
|
||||
g_signal_handlers_block_by_func (button, vn_check_on_toggled, self);
|
||||
gtk_toggle_button_set_active (button, FALSE);
|
||||
g_signal_handlers_unblock_by_func (button, vn_check_on_toggled, obj);
|
||||
g_signal_handlers_unblock_by_func (button, vn_check_on_toggled, self);
|
||||
|
||||
vn_check_changed (VN_CHECK (obj));
|
||||
vn_check_changed (VN_CHECK (self));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void vn_check_set_value (VnCheck * obj, const GValue * value)
|
||||
static void vn_check_set_value (VnCheck * self, const GValue * value)
|
||||
{
|
||||
GValue new_value = G_VALUE_INIT;
|
||||
|
||||
|
@ -95,44 +95,45 @@ static void vn_check_set_value (VnCheck * obj, const GValue * value)
|
|||
else
|
||||
g_value_init (&new_value, GVN_TYPE_NULL);
|
||||
|
||||
g_signal_handlers_block_by_func (obj->button, vn_check_on_toggled, obj);
|
||||
g_signal_handlers_block_by_func (self->button, vn_check_on_toggled, self);
|
||||
|
||||
if (!gvn_value_is_null (&new_value))
|
||||
{
|
||||
gtk_toggle_button_set_inconsistent (obj->button, FALSE);
|
||||
gtk_toggle_button_set_active (obj->button,
|
||||
gtk_toggle_button_set_inconsistent (self->button, FALSE);
|
||||
gtk_toggle_button_set_active (self->button,
|
||||
g_value_get_boolean (&new_value));
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_toggle_button_set_inconsistent (obj->button, TRUE);
|
||||
gtk_toggle_button_set_active (obj->button, FALSE);
|
||||
gtk_toggle_button_set_inconsistent (self->button, TRUE);
|
||||
gtk_toggle_button_set_active (self->button, FALSE);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (obj->button, vn_check_on_toggled, obj);
|
||||
g_signal_handlers_unblock_by_func (self->button, vn_check_on_toggled, self);
|
||||
|
||||
g_value_unset (&new_value);
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_check_init (VnCheck * obj)
|
||||
static void vn_check_init (VnCheck * self)
|
||||
{
|
||||
obj->button = GTK_TOGGLE_BUTTON (gtk_check_button_new ());
|
||||
gtk_button_set_use_underline (GTK_BUTTON (obj->button), TRUE);
|
||||
g_object_connect (obj->button
|
||||
,"signal::toggled", vn_check_on_toggled, obj
|
||||
,"signal::button-release-event", vn_check_on_secondary_button, obj
|
||||
self->button = GTK_TOGGLE_BUTTON (gtk_check_button_new ());
|
||||
gtk_button_set_use_underline (GTK_BUTTON (self->button), TRUE);
|
||||
g_object_connect (self->button
|
||||
,"signal::toggled", vn_check_on_toggled, self
|
||||
,"signal::button-release-event", vn_check_on_secondary_button, self
|
||||
,NULL
|
||||
);
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->button));
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->button));
|
||||
|
||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->button);
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->button));
|
||||
}
|
||||
|
||||
static void vn_check_finalize (VnCheck * obj)
|
||||
static void vn_check_finalize (VnCheck * self)
|
||||
{
|
||||
G_OBJECT_CLASS (vn_check_parent_class)->finalize (G_OBJECT (obj));
|
||||
G_OBJECT_CLASS (vn_check_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_check_class_init (VnCheckClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_CHECK (vn_check_get_type ())
|
||||
#define VN_CHECK(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_CHECK , VnCheck))
|
||||
#define VN_IS_CHECK(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_CHECK))
|
||||
#define VN_CHECK(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_CHECK , VnCheck))
|
||||
#define VN_IS_CHECK(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_CHECK))
|
||||
#define VN_CHECK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_CHECK, VnCheckClass))
|
||||
#define VN_IS_CHECK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_CHECK))
|
||||
#define VN_CHECK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_CHECK, VnCheckClass))
|
||||
#define VN_CHECK_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_CHECK, VnCheckClass))
|
||||
|
||||
typedef struct _VnCheck VnCheck;
|
||||
typedef struct _VnCheckClass VnCheckClass;
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_COMBO (vn_combo_get_type ())
|
||||
#define VN_COMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_COMBO , VnCombo))
|
||||
#define VN_IS_COMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_COMBO))
|
||||
#define VN_COMBO(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_COMBO , VnCombo))
|
||||
#define VN_IS_COMBO(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_COMBO))
|
||||
#define VN_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_COMBO, VnComboClass))
|
||||
#define VN_IS_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_COMBO))
|
||||
#define VN_COMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_COMBO, VnComboClass))
|
||||
#define VN_COMBO_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_COMBO, VnComboClass))
|
||||
|
||||
typedef struct _VnCombo VnCombo;
|
||||
typedef struct _VnComboClass VnComboClass;
|
||||
|
@ -50,9 +50,9 @@ struct _VnComboClass
|
|||
|
||||
GType vn_combo_get_type ();
|
||||
VnField * vn_combo_new (DbModel * model);
|
||||
guint vn_combo_get_index_column (VnCombo * obj);
|
||||
void vn_combo_set_index_column (VnCombo * obj, guint column);
|
||||
guint vn_combo_get_show_column (VnCombo * obj);
|
||||
void vn_combo_set_show_column (VnCombo * obj, guint column);
|
||||
guint vn_combo_get_index_column (VnCombo * self);
|
||||
void vn_combo_set_index_column (VnCombo * self, guint column);
|
||||
guint vn_combo_get_show_column (VnCombo * self);
|
||||
void vn_combo_set_show_column (VnCombo * self, guint column);
|
||||
|
||||
#endif
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_COMPLETION (vn_completion_get_type ())
|
||||
#define VN_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_COMPLETION, VnCompletion))
|
||||
#define VN_IS_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_COMPLETION))
|
||||
#define VN_COMPLETION(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_COMPLETION, VnCompletion))
|
||||
#define VN_IS_COMPLETION(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_COMPLETION))
|
||||
#define VN_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_COMPLETION, VnCompletionClass))
|
||||
#define VN_IS_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_COMPLETION))
|
||||
#define VN_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_COMPLETION, VnCompletionClass))
|
||||
#define VN_COMPLETION_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_COMPLETION, VnCompletionClass))
|
||||
|
||||
typedef struct _VnCompletion VnCompletion;
|
||||
typedef struct _VnCompletionClass VnCompletionClass;
|
||||
|
|
|
@ -47,33 +47,33 @@ VnField * vn_date_chooser_new ()
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_date_chooser_hide_popup (VnDateChooser * obj)
|
||||
static void vn_date_chooser_hide_popup (VnDateChooser * self)
|
||||
{
|
||||
if (obj->device)
|
||||
if (self->device)
|
||||
{
|
||||
gdk_device_ungrab (obj->device, GDK_CURRENT_TIME);
|
||||
gtk_device_grab_remove (obj->popup, obj->device);
|
||||
gdk_device_ungrab (self->device, GDK_CURRENT_TIME);
|
||||
gtk_device_grab_remove (self->popup, self->device);
|
||||
}
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (obj->button), FALSE);
|
||||
gtk_widget_hide (obj->popup);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), FALSE);
|
||||
gtk_widget_hide (self->popup);
|
||||
}
|
||||
|
||||
static void vn_date_chooser_changed (VnDateChooser * obj)
|
||||
static void vn_date_chooser_changed (VnDateChooser * self)
|
||||
{
|
||||
GDateTime * datetime = obj->datetime;
|
||||
GDateTime * datetime = self->datetime;
|
||||
|
||||
if (datetime)
|
||||
{
|
||||
gchar * str = g_date_time_format (datetime, obj->format);
|
||||
gtk_label_set_text (obj->label, str);
|
||||
gchar * str = g_date_time_format (datetime, self->format);
|
||||
gtk_label_set_text (self->label, str);
|
||||
g_free (str);
|
||||
}
|
||||
else
|
||||
gtk_label_set_text (obj->label, "");
|
||||
gtk_label_set_text (self->label, "");
|
||||
}
|
||||
|
||||
static void vn_date_chooser_set_value (VnDateChooser * obj, const GValue * value)
|
||||
static void vn_date_chooser_set_value (VnDateChooser * self, const GValue * value)
|
||||
{
|
||||
GDateTime * datetime = NULL;
|
||||
|
||||
|
@ -91,133 +91,133 @@ static void vn_date_chooser_set_value (VnDateChooser * obj, const GValue * value
|
|||
if (datetime)
|
||||
{
|
||||
if (gvn_value_is_null (datetime))
|
||||
obj->datetime = datetime;
|
||||
self->datetime = datetime;
|
||||
else
|
||||
obj->datetime = g_date_time_ref (datetime);
|
||||
self->datetime = g_date_time_ref (datetime);
|
||||
}
|
||||
else if (obj->datetime)
|
||||
else if (self->datetime)
|
||||
{
|
||||
g_date_time_unref (obj->datetime);
|
||||
obj->datetime = NULL;
|
||||
g_date_time_unref (self->datetime);
|
||||
self->datetime = NULL;
|
||||
}
|
||||
|
||||
vn_date_chooser_changed (obj);
|
||||
vn_date_chooser_changed (self);
|
||||
}
|
||||
|
||||
static GDateTime * vn_date_chooser_get_datetime (VnDateChooser * obj)
|
||||
static GDateTime * vn_date_chooser_get_datetime (VnDateChooser * self)
|
||||
{
|
||||
guint year, month, day, hour = 0, minute = 0;
|
||||
gdouble second = 0.0;
|
||||
|
||||
gtk_calendar_get_date (obj->calendar, &year, &month, &day);
|
||||
gtk_calendar_get_date (self->calendar, &year, &month, &day);
|
||||
month++;
|
||||
|
||||
hour = (guint) gtk_adjustment_get_value (obj->hour);
|
||||
minute = (guint) gtk_adjustment_get_value (obj->minute);
|
||||
second = gtk_adjustment_get_value (obj->second);
|
||||
hour = (guint) gtk_adjustment_get_value (self->hour);
|
||||
minute = (guint) gtk_adjustment_get_value (self->minute);
|
||||
second = gtk_adjustment_get_value (self->second);
|
||||
|
||||
return g_date_time_new_local (year, month, day, hour, minute, second);
|
||||
}
|
||||
|
||||
void vn_date_chooser_on_day_selected (GtkCalendar * calendar, VnDateChooser * obj)
|
||||
void vn_date_chooser_on_day_selected (GtkCalendar * calendar, VnDateChooser * self)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
GDateTime * datetime = vn_date_chooser_get_datetime (obj);
|
||||
GDateTime * datetime = vn_date_chooser_get_datetime (self);
|
||||
|
||||
if (!obj->datetime
|
||||
|| (obj->datetime && g_date_time_compare (datetime, obj->datetime)))
|
||||
if (!self->datetime
|
||||
|| (self->datetime && g_date_time_compare (datetime, self->datetime)))
|
||||
{
|
||||
obj->datetime = datetime;
|
||||
self->datetime = datetime;
|
||||
g_value_init (&value, G_TYPE_DATE_TIME);
|
||||
g_value_set_boxed (&value, obj->datetime);
|
||||
g_value_set_boxed (&value, self->datetime);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
|
||||
if (obj->datetime)
|
||||
g_date_time_unref (obj->datetime);
|
||||
if (self->datetime)
|
||||
g_date_time_unref (self->datetime);
|
||||
|
||||
obj->datetime = NULL;
|
||||
self->datetime = NULL;
|
||||
}
|
||||
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
g_value_unset (&value);
|
||||
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_changed (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
vn_date_chooser_changed (self);
|
||||
}
|
||||
|
||||
void vn_date_chooser_on_ok_clicked (GtkButton * button, VnDateChooser * obj)
|
||||
void vn_date_chooser_on_ok_clicked (GtkButton * button, VnDateChooser * self)
|
||||
{
|
||||
GDateTime * datetime = vn_date_chooser_get_datetime (obj);
|
||||
GDateTime * datetime = vn_date_chooser_get_datetime (self);
|
||||
|
||||
if (datetime)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
if (obj->datetime)
|
||||
g_date_time_unref (obj->datetime);
|
||||
if (self->datetime)
|
||||
g_date_time_unref (self->datetime);
|
||||
|
||||
obj->datetime = datetime;
|
||||
self->datetime = datetime;
|
||||
g_value_init (&value, G_TYPE_DATE_TIME);
|
||||
g_value_set_boxed (&value, datetime);
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_changed (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
vn_date_chooser_changed (self);
|
||||
}
|
||||
|
||||
void vn_date_chooser_on_clear_clicked (GtkButton * button, VnDateChooser * obj)
|
||||
void vn_date_chooser_on_clear_clicked (GtkButton * button, VnDateChooser * self)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
|
||||
if (obj->datetime)
|
||||
g_date_time_unref (obj->datetime);
|
||||
if (self->datetime)
|
||||
g_date_time_unref (self->datetime);
|
||||
|
||||
obj->datetime = NULL;
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
self->datetime = NULL;
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
g_value_unset (&value);
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_changed (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
vn_date_chooser_changed (self);
|
||||
|
||||
gtk_adjustment_set_value (obj->hour, 0);
|
||||
gtk_adjustment_set_value (obj->minute, 0);
|
||||
gtk_adjustment_set_value (obj->second, 0);
|
||||
gtk_adjustment_set_value (self->hour, 0);
|
||||
gtk_adjustment_set_value (self->minute, 0);
|
||||
gtk_adjustment_set_value (self->second, 0);
|
||||
}
|
||||
|
||||
void vn_date_chooser_on_now_clicked (GtkButton * button, VnDateChooser * obj)
|
||||
void vn_date_chooser_on_now_clicked (GtkButton * button, VnDateChooser * self)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
if (obj->datetime)
|
||||
g_date_time_unref (obj->datetime);
|
||||
if (self->datetime)
|
||||
g_date_time_unref (self->datetime);
|
||||
|
||||
obj->datetime = g_date_time_new_now_local ();
|
||||
self->datetime = g_date_time_new_now_local ();
|
||||
g_value_init (&value, G_TYPE_DATE_TIME);
|
||||
g_value_set_boxed (&value, obj->datetime);
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
g_value_set_boxed (&value, self->datetime);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
g_value_unset (&value);
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_changed (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
vn_date_chooser_changed (self);
|
||||
}
|
||||
|
||||
static gboolean vn_date_chooser_on_button_press (GtkWidget * widget,
|
||||
GdkEventButton * event, VnDateChooser * obj)
|
||||
GdkEventButton * event, VnDateChooser * self)
|
||||
{
|
||||
gint x, y;
|
||||
GtkAllocation allocation;
|
||||
|
||||
gdk_window_get_origin (gtk_widget_get_window (obj->popup), &x, &y);
|
||||
gtk_widget_get_allocation (obj->popup, &allocation);
|
||||
gdk_window_get_origin (gtk_widget_get_window (self->popup), &x, &y);
|
||||
gtk_widget_get_allocation (self->popup, &allocation);
|
||||
|
||||
if (!( event->x_root >= x && event->x_root <= x + allocation.width
|
||||
&& event->y_root >= y && event->y_root <= y + allocation.height))
|
||||
{
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -225,18 +225,18 @@ static gboolean vn_date_chooser_on_button_press (GtkWidget * widget,
|
|||
}
|
||||
|
||||
static gboolean vn_date_chooser_on_key_press (GtkWidget * widget,
|
||||
GdkEventKey * event, VnDateChooser * obj)
|
||||
GdkEventKey * event, VnDateChooser * self)
|
||||
{
|
||||
if (event->keyval == GDK_KEY_Escape)
|
||||
{
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser * obj)
|
||||
static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser * self)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (button))
|
||||
{
|
||||
|
@ -250,40 +250,40 @@ static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser
|
|||
|
||||
// Set the date/time on the calendar
|
||||
|
||||
if (obj->datetime)
|
||||
if (self->datetime)
|
||||
{
|
||||
gtk_calendar_select_month (obj->calendar
|
||||
,g_date_time_get_month (obj->datetime) - 1
|
||||
,g_date_time_get_year (obj->datetime)
|
||||
gtk_calendar_select_month (self->calendar
|
||||
,g_date_time_get_month (self->datetime) - 1
|
||||
,g_date_time_get_year (self->datetime)
|
||||
);
|
||||
gtk_calendar_select_day (obj->calendar,
|
||||
g_date_time_get_day_of_month (obj->datetime));
|
||||
gtk_calendar_select_day (self->calendar,
|
||||
g_date_time_get_day_of_month (self->datetime));
|
||||
|
||||
gtk_adjustment_set_value (obj->hour,
|
||||
g_date_time_get_hour (obj->datetime));
|
||||
gtk_adjustment_set_value (obj->minute,
|
||||
g_date_time_get_minute (obj->datetime));
|
||||
gtk_adjustment_set_value (obj->second,
|
||||
g_date_time_get_second (obj->datetime));
|
||||
gtk_adjustment_set_value (self->hour,
|
||||
g_date_time_get_hour (self->datetime));
|
||||
gtk_adjustment_set_value (self->minute,
|
||||
g_date_time_get_minute (self->datetime));
|
||||
gtk_adjustment_set_value (self->second,
|
||||
g_date_time_get_second (self->datetime));
|
||||
}
|
||||
else
|
||||
gtk_calendar_select_day (obj->calendar, 0);
|
||||
gtk_calendar_select_day (self->calendar, 0);
|
||||
|
||||
// Set visibility
|
||||
|
||||
if (!obj->show_date)
|
||||
gtk_widget_hide (GTK_WIDGET (obj->calendar));
|
||||
if (!self->show_date)
|
||||
gtk_widget_hide (GTK_WIDGET (self->calendar));
|
||||
|
||||
if (!obj->show_time)
|
||||
gtk_widget_hide (obj->time);
|
||||
if (!self->show_time)
|
||||
gtk_widget_hide (self->time);
|
||||
|
||||
gtk_widget_set_no_show_all (GTK_WIDGET (obj->calendar), !obj->show_date);
|
||||
gtk_widget_set_no_show_all (obj->time, !obj->show_time);
|
||||
gtk_widget_set_no_show_all (GTK_WIDGET (self->calendar), !self->show_date);
|
||||
gtk_widget_set_no_show_all (self->time, !self->show_time);
|
||||
|
||||
gtk_widget_get_preferred_width (obj->box, &x, NULL);
|
||||
gtk_widget_get_preferred_height (obj->box, &y, NULL);
|
||||
gtk_widget_get_preferred_width (self->box, &x, NULL);
|
||||
gtk_widget_get_preferred_height (self->box, &y, NULL);
|
||||
|
||||
gtk_window_resize (GTK_WINDOW (obj->popup), x, y);
|
||||
gtk_window_resize (GTK_WINDOW (self->popup), x, y);
|
||||
|
||||
// Setting the position of the popup
|
||||
|
||||
|
@ -299,7 +299,7 @@ static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser
|
|||
gdk_screen_get_monitor_geometry (screen,
|
||||
gdk_screen_get_monitor_at_point (screen, x, y), &monitor);
|
||||
|
||||
gtk_widget_get_preferred_size (obj->popup, &req, NULL);
|
||||
gtk_widget_get_preferred_size (self->popup, &req, NULL);
|
||||
|
||||
if (y - monitor.y > monitor.height)
|
||||
y = monitor.y + monitor.height - req.height;
|
||||
|
@ -313,45 +313,45 @@ static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser
|
|||
else if ((x - monitor.x) + req.width > monitor.width)
|
||||
x -= req.width - allocation.width;
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (obj->popup), screen);
|
||||
gtk_window_move (GTK_WINDOW (obj->popup), x, y);
|
||||
gtk_widget_show_all (obj->popup);
|
||||
gtk_window_set_screen (GTK_WINDOW (self->popup), screen);
|
||||
gtk_window_move (GTK_WINDOW (self->popup), x, y);
|
||||
gtk_widget_show_all (self->popup);
|
||||
|
||||
// Grabbing the focus on the popup window
|
||||
|
||||
obj->device = gtk_get_current_event_device ();
|
||||
self->device = gtk_get_current_event_device ();
|
||||
|
||||
if (obj->device && gdk_device_get_source (obj->device) == GDK_SOURCE_KEYBOARD)
|
||||
obj->device = gdk_device_get_associated_device (obj->device);
|
||||
if (self->device && gdk_device_get_source (self->device) == GDK_SOURCE_KEYBOARD)
|
||||
self->device = gdk_device_get_associated_device (self->device);
|
||||
|
||||
if (!obj->device)
|
||||
if (!self->device)
|
||||
{
|
||||
GList * devices;
|
||||
GdkDisplay * display;
|
||||
GdkDeviceManager * device_manager;
|
||||
|
||||
display = gtk_widget_get_display (GTK_WIDGET (obj->popup));
|
||||
display = gtk_widget_get_display (GTK_WIDGET (self->popup));
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
|
||||
devices = gdk_device_manager_list_devices (device_manager,
|
||||
GDK_DEVICE_TYPE_MASTER);
|
||||
obj->device = devices->data;
|
||||
self->device = devices->data;
|
||||
g_list_free (devices);
|
||||
}
|
||||
|
||||
gtk_device_grab_add (obj->popup, obj->device, TRUE);
|
||||
gdk_device_grab (obj->device
|
||||
,gtk_widget_get_window (obj->popup)
|
||||
gtk_device_grab_add (self->popup, self->device, TRUE);
|
||||
gdk_device_grab (self->device
|
||||
,gtk_widget_get_window (self->popup)
|
||||
,GDK_OWNERSHIP_WINDOW, TRUE
|
||||
,GDK_BUTTON_PRESS_MASK, NULL
|
||||
,GDK_CURRENT_TIME
|
||||
);
|
||||
}
|
||||
else
|
||||
vn_date_chooser_hide_popup (obj);
|
||||
vn_date_chooser_hide_popup (self);
|
||||
}
|
||||
|
||||
gboolean vn_date_chooser_on_spin_output (GtkSpinButton * spin, VnDateChooser * obj)
|
||||
gboolean vn_date_chooser_on_spin_output (GtkSpinButton * spin, VnDateChooser * self)
|
||||
{
|
||||
gchar * format;
|
||||
GtkAdjustment * adj = gtk_spin_button_get_adjustment (spin);
|
||||
|
@ -370,98 +370,100 @@ enum
|
|||
,PROP_SHOW_DATE
|
||||
};
|
||||
|
||||
static void vn_date_chooser_set_property (VnDateChooser * obj, guint id,
|
||||
static void vn_date_chooser_set_property (VnDateChooser * self, guint id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_FORMAT:
|
||||
g_free (obj->format);
|
||||
obj->format = g_value_dup_string (value);
|
||||
g_free (self->format);
|
||||
self->format = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_SHOW_TIME:
|
||||
obj->show_time = g_value_get_boolean (value);
|
||||
self->show_time = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_SHOW_DATE:
|
||||
obj->show_date = g_value_get_boolean (value);
|
||||
self->show_date = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void vn_date_chooser_get_property (VnDateChooser * obj, guint id,
|
||||
static void vn_date_chooser_get_property (VnDateChooser * self, guint id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_FORMAT:
|
||||
g_value_set_string (value, obj->format);
|
||||
g_value_set_string (value, self->format);
|
||||
break;
|
||||
case PROP_SHOW_TIME:
|
||||
g_value_set_boolean (value, obj->show_time);
|
||||
g_value_set_boolean (value, self->show_time);
|
||||
break;
|
||||
case PROP_SHOW_DATE:
|
||||
g_value_set_boolean (value, obj->show_date);
|
||||
g_value_set_boolean (value, self->show_date);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_date_chooser_init (VnDateChooser * obj)
|
||||
static void vn_date_chooser_init (VnDateChooser * self)
|
||||
{
|
||||
GtkBuilder * builder;
|
||||
|
||||
obj->show_time = FALSE;
|
||||
obj->show_date = TRUE;
|
||||
obj->format = NULL;
|
||||
obj->popup = NULL;
|
||||
obj->device = NULL;
|
||||
obj->datetime = NULL;
|
||||
self->show_time = FALSE;
|
||||
self->show_date = TRUE;
|
||||
self->format = NULL;
|
||||
self->popup = NULL;
|
||||
self->device = NULL;
|
||||
self->datetime = NULL;
|
||||
|
||||
obj->button = gtk_toggle_button_new ();
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (obj->button), _("Change date"));
|
||||
g_signal_connect (obj->button, "toggled",
|
||||
G_CALLBACK (vn_date_chooser_on_toggled), obj);
|
||||
VN_FIELD (obj)->field = obj->button;
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->button));
|
||||
g_object_set (obj->button, "relief", GTK_RELIEF_HALF, NULL);
|
||||
self->button = gtk_toggle_button_new ();
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (self->button), _("Change date"));
|
||||
g_signal_connect (self->button, "toggled",
|
||||
G_CALLBACK (vn_date_chooser_on_toggled), self);
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->button));
|
||||
g_object_set (self->button, "relief", GTK_RELIEF_HALF, NULL);
|
||||
|
||||
obj->label = GTK_LABEL (gtk_label_new (NULL));
|
||||
gtk_misc_set_alignment (GTK_MISC (obj->label), 0, 0.5);
|
||||
gtk_container_add (GTK_CONTAINER (obj->button), GTK_WIDGET (obj->label));
|
||||
self->label = GTK_LABEL (gtk_label_new (NULL));
|
||||
gtk_misc_set_alignment (GTK_MISC (self->label), 0, 0.5);
|
||||
gtk_container_add (GTK_CONTAINER (self->button), GTK_WIDGET (self->label));
|
||||
|
||||
obj->popup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
g_object_connect (obj->popup
|
||||
,"signal::button-press-event", vn_date_chooser_on_button_press, obj
|
||||
,"signal::key-press-event", vn_date_chooser_on_key_press, obj
|
||||
self->popup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
g_object_connect (self->popup
|
||||
,"signal::button-press-event", vn_date_chooser_on_button_press, self
|
||||
,"signal::key-press-event", vn_date_chooser_on_key_press, self
|
||||
,NULL
|
||||
);
|
||||
|
||||
builder = gtk_builder_new_from_file (GUI_FILE);
|
||||
gtk_builder_connect_signals (builder, obj);
|
||||
gtk_builder_connect_signals (builder, self);
|
||||
|
||||
obj->calendar = GTK_CALENDAR (gtk_builder_get_object (builder, "calendar"));
|
||||
obj->hour = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "hour"));
|
||||
obj->minute = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "minute"));
|
||||
obj->second = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "second"));
|
||||
obj->time = GTK_WIDGET (gtk_builder_get_object (builder, "time"));
|
||||
self->calendar = GTK_CALENDAR (gtk_builder_get_object (builder, "calendar"));
|
||||
self->hour = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "hour"));
|
||||
self->minute = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "minute"));
|
||||
self->second = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "second"));
|
||||
self->time = GTK_WIDGET (gtk_builder_get_object (builder, "time"));
|
||||
|
||||
obj->box = GTK_WIDGET (gtk_builder_get_object (builder, "box"));
|
||||
gtk_container_add (GTK_CONTAINER (obj->popup), obj->box);
|
||||
self->box = GTK_WIDGET (gtk_builder_get_object (builder, "box"));
|
||||
gtk_container_add (GTK_CONTAINER (self->popup), self->box);
|
||||
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->button));
|
||||
}
|
||||
|
||||
static void vn_date_chooser_finalize (VnDateChooser * obj)
|
||||
static void vn_date_chooser_finalize (VnDateChooser * self)
|
||||
{
|
||||
if (obj->datetime)
|
||||
g_date_time_unref (obj->datetime);
|
||||
if (self->datetime)
|
||||
g_date_time_unref (self->datetime);
|
||||
|
||||
g_free (obj->format);
|
||||
gtk_widget_destroy (obj->popup);
|
||||
G_OBJECT_CLASS (vn_date_chooser_parent_class)->finalize (G_OBJECT (obj));
|
||||
g_free (self->format);
|
||||
gtk_widget_destroy (self->popup);
|
||||
G_OBJECT_CLASS (vn_date_chooser_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_date_chooser_class_init (VnDateChooserClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_DATE_CHOOSER (vn_date_chooser_get_type ())
|
||||
#define VN_DATE_CHOOSER(object) (G_TYPE_CHECK_INSTANCE_CAST (object, VN_TYPE_DATE_CHOOSER , VnDateChooser))
|
||||
#define VN_IS_DATE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_DATE_CHOOSER))
|
||||
#define VN_DATE_CHOOSER(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_DATE_CHOOSER , VnDateChooser))
|
||||
#define VN_IS_DATE_CHOOSER(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_DATE_CHOOSER))
|
||||
#define VN_DATE_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_DATE_CHOOSER, VnDateChooserClass))
|
||||
#define VN_IS_DATE_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_DATE_CHOOSER))
|
||||
#define VN_DATE_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_DATE_CHOOSER, VnDateChooserClass))
|
||||
#define VN_DATE_CHOOSER_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_DATE_CHOOSER, VnDateChooserClass))
|
||||
|
||||
typedef struct _VnDateChooser VnDateChooser;
|
||||
typedef struct _VnDateChooserClass VnDateChooserClass;
|
||||
|
|
|
@ -36,19 +36,19 @@ G_DEFINE_TYPE (VnEntry, vn_entry, VN_TYPE_FIELD);
|
|||
*
|
||||
* Return value: a #VnEntry
|
||||
**/
|
||||
VnField * vn_entry_new (VnEntry * obj)
|
||||
VnField * vn_entry_new (VnEntry * self)
|
||||
{
|
||||
return g_object_new (VN_TYPE_ENTRY, NULL);
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_entry_cb_editing_done (GtkEntry * entry, VnField * obj)
|
||||
static void vn_entry_on_editing_done (GtkEntry * entry, VnField * self)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
const gchar * text = gtk_entry_get_text (entry);
|
||||
|
||||
if (g_strcmp0 (text, "") || !vn_field_get_null (obj))
|
||||
if (g_strcmp0 (text, "") || !vn_field_get_null (self))
|
||||
{
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_set_string (&value, text);
|
||||
|
@ -56,33 +56,33 @@ static void vn_entry_cb_editing_done (GtkEntry * entry, VnField * obj)
|
|||
else
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (obj, &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (self, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static gboolean vn_entry_cb_focus_out (GtkEntry * entry, GdkEvent * event, VnField * obj)
|
||||
static gboolean vn_entry_on_focus_out (GtkEntry * entry, GdkEvent * event, VnField * self)
|
||||
{
|
||||
vn_entry_cb_editing_done (entry, obj);
|
||||
vn_entry_on_editing_done (entry, self);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void vn_entry_set_value (VnEntry * obj, const GValue * value)
|
||||
static void vn_entry_set_value (VnEntry * self, const GValue * value)
|
||||
{
|
||||
GValue new_value = G_VALUE_INIT;
|
||||
gvn_value_to_format_string (value, obj->format, &new_value);
|
||||
gvn_value_to_format_string (value, self->format, &new_value);
|
||||
|
||||
g_signal_handlers_block_by_func (obj->entry,
|
||||
vn_entry_cb_editing_done, obj);
|
||||
g_signal_handlers_block_by_func (obj->entry,
|
||||
vn_entry_cb_focus_out, obj);
|
||||
g_signal_handlers_block_by_func (self->entry,
|
||||
vn_entry_on_editing_done, self);
|
||||
g_signal_handlers_block_by_func (self->entry,
|
||||
vn_entry_on_focus_out, self);
|
||||
|
||||
gtk_entry_set_text (obj->entry,
|
||||
gtk_entry_set_text (self->entry,
|
||||
g_value_get_string (&new_value));
|
||||
|
||||
g_signal_handlers_unblock_by_func (obj->entry,
|
||||
vn_entry_cb_editing_done, obj);
|
||||
g_signal_handlers_unblock_by_func (obj->entry,
|
||||
vn_entry_cb_focus_out, obj);
|
||||
g_signal_handlers_unblock_by_func (self->entry,
|
||||
vn_entry_on_editing_done, self);
|
||||
g_signal_handlers_unblock_by_func (self->entry,
|
||||
vn_entry_on_focus_out, self);
|
||||
|
||||
g_value_unset (&new_value);
|
||||
}
|
||||
|
@ -94,53 +94,54 @@ enum
|
|||
PROP_FORMAT = 1
|
||||
};
|
||||
|
||||
static void vn_entry_set_property (VnEntry * obj, guint id,
|
||||
static void vn_entry_set_property (VnEntry * self, guint id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_FORMAT:
|
||||
g_free (obj->format);
|
||||
obj->format = g_value_dup_string (value);
|
||||
g_free (self->format);
|
||||
self->format = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void vn_entry_get_property (VnEntry * obj, guint id,
|
||||
static void vn_entry_get_property (VnEntry * self, guint id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_FORMAT:
|
||||
g_value_set_string (value, obj->format);
|
||||
g_value_set_string (value, self->format);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_entry_init (VnEntry * obj)
|
||||
static void vn_entry_init (VnEntry * self)
|
||||
{
|
||||
obj->format = NULL;
|
||||
obj->entry = GTK_ENTRY (gtk_entry_new ());
|
||||
g_object_connect (obj->entry
|
||||
,"signal::activate", vn_entry_cb_editing_done, obj
|
||||
,"signal::focus-out-event", vn_entry_cb_focus_out, obj
|
||||
self->format = NULL;
|
||||
self->entry = GTK_ENTRY (gtk_entry_new ());
|
||||
g_object_connect (self->entry
|
||||
,"signal::activate", vn_entry_on_editing_done, self
|
||||
,"signal::focus-out-event", vn_entry_on_focus_out, self
|
||||
,NULL
|
||||
);
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->entry));
|
||||
|
||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->entry);
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->entry));
|
||||
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->entry));
|
||||
}
|
||||
|
||||
static void vn_entry_finalize (VnEntry * obj)
|
||||
static void vn_entry_finalize (VnEntry * self)
|
||||
{
|
||||
g_free (obj->format);
|
||||
G_OBJECT_CLASS (vn_entry_parent_class)->finalize (G_OBJECT (obj));
|
||||
g_free (self->format);
|
||||
G_OBJECT_CLASS (vn_entry_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_entry_class_init (VnEntryClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_ENTRY (vn_entry_get_type ())
|
||||
#define VN_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_ENTRY, VnEntry))
|
||||
#define VN_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_ENTRY))
|
||||
#define VN_ENTRY(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_ENTRY, VnEntry))
|
||||
#define VN_IS_ENTRY(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_ENTRY))
|
||||
#define VN_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_ENTRY, VnEntryClass))
|
||||
#define VN_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_ENTRY))
|
||||
#define VN_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_ENTRY, VnEntryClass))
|
||||
#define VN_ENTRY_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_ENTRY, VnEntryClass))
|
||||
|
||||
typedef struct _VnEntry VnEntry;
|
||||
typedef struct _VnEntryClass VnEntryClass;
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_HTTP_IMAGE (vn_http_image_get_type ())
|
||||
#define VN_HTTP_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_HTTP_IMAGE, VnHttpImage))
|
||||
#define VN_IS_HTTP_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_HTTP_IMAGE))
|
||||
#define VN_HTTP_IMAGE(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_HTTP_IMAGE, VnHttpImage))
|
||||
#define VN_IS_HTTP_IMAGE(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_HTTP_IMAGE))
|
||||
#define VN_HTTP_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_HTTP_IMAGE, VnHttpImageClass))
|
||||
#define VN_IS_HTTP_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_HTTP_IMAGE))
|
||||
#define VN_HTTP_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_HTTP_IMAGE, VnHttpImageClass))
|
||||
#define VN_HTTP_IMAGE_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_HTTP_IMAGE, VnHttpImageClass))
|
||||
|
||||
typedef struct _VnHttpImage VnHttpImage;
|
||||
typedef struct _VnHttpImageClass VnHttpImageClass;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "vn-image.h"
|
||||
#include <db/db.h>
|
||||
|
||||
#define set_default_image(obj) g_object_set (obj->image, \
|
||||
#define set_default_image(self) g_object_set (self->image, \
|
||||
"icon-name", "dialog-question", "icon-size", GTK_ICON_SIZE_DIALOG, NULL)
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ VnField * vn_image_new ()
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_image_set_value (VnImage * obj, const GValue * value)
|
||||
static void vn_image_set_value (VnImage * self, const GValue * value)
|
||||
{
|
||||
GBytes * bytes = NULL;
|
||||
|
||||
|
@ -68,22 +68,22 @@ static void vn_image_set_value (VnImage * obj, const GValue * value)
|
|||
&& gdk_pixbuf_loader_close (loader, &err))
|
||||
{
|
||||
GdkPixbuf * pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
gtk_image_set_from_pixbuf (obj->image, pixbuf);
|
||||
gtk_image_set_from_pixbuf (self->image, pixbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s",err->message);
|
||||
g_error_free (err);
|
||||
set_default_image (obj);
|
||||
set_default_image (self);
|
||||
}
|
||||
|
||||
g_object_unref (loader);
|
||||
}
|
||||
else
|
||||
set_default_image (obj);
|
||||
set_default_image (self);
|
||||
}
|
||||
|
||||
static void vn_image_cb_update_preview (GtkFileChooser * chooser, GtkImage * image)
|
||||
static void vn_image_on_update_preview (GtkFileChooser * chooser, GtkImage * image)
|
||||
{
|
||||
char *filename;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
@ -107,7 +107,7 @@ static void vn_image_cb_update_preview (GtkFileChooser * chooser, GtkImage * ima
|
|||
gtk_file_chooser_set_preview_widget_active (chooser, pixbuf != NULL);
|
||||
}
|
||||
|
||||
static gboolean vn_image_cb_event (VnField * field, GdkEvent * event, VnImage * obj)
|
||||
static gboolean vn_image_on_event (VnField * field, GdkEvent * event, VnImage * self)
|
||||
{
|
||||
if (event->type != GDK_2BUTTON_PRESS)
|
||||
return FALSE;
|
||||
|
@ -124,7 +124,7 @@ static gboolean vn_image_cb_event (VnField * field, GdkEvent * event, VnImage *
|
|||
gtk_file_filter_add_mime_type (filter, "image/bmp");
|
||||
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (obj));
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
|
||||
|
||||
if (!gtk_widget_is_toplevel (toplevel))
|
||||
toplevel = NULL;
|
||||
|
@ -142,7 +142,7 @@ static gboolean vn_image_cb_event (VnField * field, GdkEvent * event, VnImage *
|
|||
image = gtk_image_new ();
|
||||
gtk_file_chooser_set_preview_widget (chooser, image);
|
||||
g_signal_connect (chooser, "update-preview",
|
||||
G_CALLBACK (vn_image_cb_update_preview), image);
|
||||
G_CALLBACK (vn_image_on_update_preview), image);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
|
@ -159,8 +159,8 @@ static gboolean vn_image_cb_event (VnField * field, GdkEvent * event, VnImage *
|
|||
g_value_init (&value, G_TYPE_BYTES);
|
||||
g_value_take_boxed (&value, g_bytes_new_take (data, len));
|
||||
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), &value);
|
||||
vn_image_set_value (obj, &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (VN_FIELD (self), &value);
|
||||
vn_image_set_value (self, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
|
@ -178,19 +178,21 @@ static gboolean vn_image_cb_event (VnField * field, GdkEvent * event, VnImage *
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_image_init (VnImage * obj)
|
||||
static void vn_image_init (VnImage * self)
|
||||
{
|
||||
obj->image = GTK_IMAGE (gtk_image_new ());
|
||||
g_signal_connect (obj, "event",
|
||||
G_CALLBACK (vn_image_cb_event), obj);
|
||||
set_default_image (obj);
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->image));
|
||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->image);
|
||||
self->image = GTK_IMAGE (gtk_image_new ());
|
||||
g_signal_connect (self, "event",
|
||||
G_CALLBACK (vn_image_on_event), self);
|
||||
set_default_image (self);
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->image));
|
||||
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->image));
|
||||
}
|
||||
|
||||
static void vn_image_finalize (VnImage * obj)
|
||||
static void vn_image_finalize (VnImage * self)
|
||||
{
|
||||
G_OBJECT_CLASS (vn_image_parent_class)->finalize (G_OBJECT (obj));
|
||||
G_OBJECT_CLASS (vn_image_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_image_class_init (VnImageClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_IMAGE (vn_image_get_type ())
|
||||
#define VN_IMAGE(object) (G_TYPE_CHECK_INSTANCE_CAST (object, VN_TYPE_IMAGE , VnImage))
|
||||
#define VN_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_IMAGE))
|
||||
#define VN_IMAGE(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_IMAGE , VnImage))
|
||||
#define VN_IS_IMAGE(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_IMAGE))
|
||||
#define VN_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_IMAGE, VnImageClass))
|
||||
#define VN_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_IMAGE))
|
||||
#define VN_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_IMAGE, VnImageClass))
|
||||
#define VN_IMAGE_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_IMAGE, VnImageClass))
|
||||
|
||||
typedef struct _VnImage VnImage;
|
||||
typedef struct _VnImageClass VnImageClass;
|
||||
|
|
|
@ -41,11 +41,11 @@ VnField * vn_label_new ()
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_label_set_value (VnLabel * obj, const GValue * value)
|
||||
static void vn_label_set_value (VnLabel * self, const GValue * value)
|
||||
{
|
||||
GValue new_value = G_VALUE_INIT;
|
||||
gvn_value_to_format_string (value, obj->format, &new_value);
|
||||
gtk_label_set_text (obj->label, g_value_get_string (&new_value));
|
||||
gvn_value_to_format_string (value, self->format, &new_value);
|
||||
gtk_label_set_text (self->label, g_value_get_string (&new_value));
|
||||
g_value_unset (&new_value);
|
||||
}
|
||||
|
||||
|
@ -56,50 +56,51 @@ enum
|
|||
PROP_FORMAT = 1
|
||||
};
|
||||
|
||||
static void vn_label_set_property (VnLabel * obj, guint id,
|
||||
static void vn_label_set_property (VnLabel * self, guint id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_FORMAT:
|
||||
g_free (obj->format);
|
||||
obj->format = g_value_dup_string (value);
|
||||
g_free (self->format);
|
||||
self->format = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void vn_label_get_property (VnLabel * obj, guint id,
|
||||
static void vn_label_get_property (VnLabel * self, guint id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_FORMAT:
|
||||
g_value_set_string (value, obj->format);
|
||||
g_value_set_string (value, self->format);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_label_init (VnLabel * obj)
|
||||
static void vn_label_init (VnLabel * self)
|
||||
{
|
||||
obj->format = NULL;
|
||||
obj->label = GTK_LABEL (gtk_label_new (""));
|
||||
gtk_misc_set_alignment (GTK_MISC (obj->label), 0, 0.5);
|
||||
gtk_widget_show (GTK_WIDGET (obj->label));
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->label));
|
||||
self->format = NULL;
|
||||
self->label = GTK_LABEL (gtk_label_new (""));
|
||||
gtk_misc_set_alignment (GTK_MISC (self->label), 0, 0.5);
|
||||
gtk_widget_show (GTK_WIDGET (self->label));
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->label));
|
||||
|
||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->label);
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->label));
|
||||
}
|
||||
|
||||
static void vn_label_finalize (VnLabel * obj)
|
||||
static void vn_label_finalize (VnLabel * self)
|
||||
{
|
||||
g_free (obj->format);
|
||||
G_OBJECT_CLASS (vn_label_parent_class)->finalize (G_OBJECT (obj));
|
||||
g_free (self->format);
|
||||
G_OBJECT_CLASS (vn_label_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_label_class_init (VnLabelClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_LABEL (vn_label_get_type ())
|
||||
#define VN_LABEL(object) (G_TYPE_CHECK_INSTANCE_CAST (object, VN_TYPE_LABEL , VnLabel))
|
||||
#define VN_IS_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_LABEL))
|
||||
#define VN_LABEL(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_LABEL , VnLabel))
|
||||
#define VN_IS_LABEL(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_LABEL))
|
||||
#define VN_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_LABEL, VnLabelClass))
|
||||
#define VN_IS_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_LABEL))
|
||||
#define VN_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_LABEL, VnLabelClass))
|
||||
#define VN_LABEL_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_LABEL, VnLabelClass))
|
||||
|
||||
typedef struct _VnLabel VnLabel;
|
||||
typedef struct _VnLabelClass VnLabelClass;
|
||||
|
|
|
@ -43,7 +43,7 @@ VnField * vn_spin_new ()
|
|||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
||||
static void vn_spin_on_value_changed (GtkSpinButton * spin, VnField * obj)
|
||||
static void vn_spin_on_value_changed (GtkSpinButton * spin, VnField * self)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
|
@ -55,43 +55,45 @@ static void vn_spin_on_value_changed (GtkSpinButton * spin, VnField * obj)
|
|||
else
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
|
||||
VN_FIELD_GET_CLASS (obj)->value_changed (obj, &value);
|
||||
VN_FIELD_GET_CLASS (self)->value_changed (self, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static gboolean vn_spin_cb_focus_out (GtkSpinButton * spin, GdkEvent * event, VnField * obj)
|
||||
static gboolean vn_spin_on_focus_out (GtkSpinButton * spin, GdkEvent * event, VnField * self)
|
||||
{
|
||||
vn_spin_on_value_changed (spin, obj);
|
||||
vn_spin_on_value_changed (spin, self);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean vn_spin_on_output (GtkSpinButton * spin, VnField * obj)
|
||||
static gboolean vn_spin_on_output (GtkSpinButton * spin, VnField * self)
|
||||
{
|
||||
const gchar * text = gtk_entry_get_text (GTK_ENTRY (spin));
|
||||
|
||||
return vn_field_get_null (obj)
|
||||
&& (!text || !g_strcmp0 (text, ""))
|
||||
&& gtk_spin_button_get_value (spin) == 0.0;
|
||||
return !text || !g_strcmp0 (text, "");
|
||||
}
|
||||
|
||||
static void vn_spin_set_value (VnSpin * obj, const GValue * value)
|
||||
static void vn_spin_set_value (VnSpin * self, const GValue * value)
|
||||
{
|
||||
g_signal_handlers_block_by_func (obj->spin,
|
||||
vn_spin_on_value_changed, obj);
|
||||
g_signal_handlers_block_by_func (self->spin,
|
||||
vn_spin_on_value_changed, self);
|
||||
|
||||
if (!gvn_value_is_null (value))
|
||||
{
|
||||
GValue new_value = {0};
|
||||
g_value_init (&new_value, G_TYPE_DOUBLE);
|
||||
g_value_transform (value, &new_value);
|
||||
gtk_spin_button_set_value (obj->spin, g_value_get_double (&new_value));
|
||||
|
||||
g_signal_handlers_block_by_func (self->spin, vn_spin_on_output, self);
|
||||
gtk_spin_button_set_value (self->spin, g_value_get_double (&new_value));
|
||||
g_signal_handlers_unblock_by_func (self->spin, vn_spin_on_output, self);
|
||||
|
||||
g_value_unset (&new_value);
|
||||
}
|
||||
else
|
||||
gtk_entry_set_text (GTK_ENTRY (obj->spin), "");
|
||||
gtk_entry_set_text (GTK_ENTRY (self->spin), "");
|
||||
|
||||
g_signal_handlers_unblock_by_func (obj->spin,
|
||||
vn_spin_on_value_changed, obj);
|
||||
g_signal_handlers_unblock_by_func (self->spin,
|
||||
vn_spin_on_value_changed, self);
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
|
||||
|
@ -101,61 +103,62 @@ enum
|
|||
PROP_DIGITS = 1
|
||||
};
|
||||
|
||||
static void vn_spin_set_property (VnSpin * obj, guint id,
|
||||
static void vn_spin_set_property (VnSpin * self, guint id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_DIGITS:
|
||||
gtk_spin_button_set_digits (obj->spin, g_value_get_uint (value));
|
||||
gtk_spin_button_set_digits (self->spin, g_value_get_uint (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void vn_spin_get_property (VnSpin * obj, guint id,
|
||||
static void vn_spin_get_property (VnSpin * self, guint id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_DIGITS:
|
||||
g_value_set_uint (value, gtk_spin_button_get_digits (obj->spin));
|
||||
g_value_set_uint (value, gtk_spin_button_get_digits (self->spin));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
||||
|
||||
static void vn_spin_init (VnSpin * obj)
|
||||
static void vn_spin_init (VnSpin * self)
|
||||
{
|
||||
obj->spin = GTK_SPIN_BUTTON (gtk_spin_button_new (NULL, 1, 0));
|
||||
gtk_spin_button_set_range (obj->spin, G_MININT, G_MAXINT);
|
||||
gtk_spin_button_set_update_policy (obj->spin, GTK_UPDATE_ALWAYS);
|
||||
gtk_spin_button_set_numeric (obj->spin, TRUE);
|
||||
gtk_spin_button_set_increments (obj->spin, 1, 1);
|
||||
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->spin));
|
||||
self->spin = GTK_SPIN_BUTTON (gtk_spin_button_new (NULL, 1, 0));
|
||||
gtk_spin_button_set_range (self->spin, G_MININT, G_MAXINT);
|
||||
gtk_spin_button_set_update_policy (self->spin, GTK_UPDATE_ALWAYS);
|
||||
gtk_spin_button_set_numeric (self->spin, TRUE);
|
||||
gtk_spin_button_set_increments (self->spin, 1, 1);
|
||||
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->spin));
|
||||
|
||||
g_object_connect (obj->spin
|
||||
// ,"signal::activate", vn_spin_on_value_changed, obj
|
||||
,"signal::value-changed", vn_spin_on_value_changed, obj
|
||||
,"signal::focus-out-event", vn_spin_cb_focus_out, obj
|
||||
,"signal::output", vn_spin_on_output, obj
|
||||
g_object_connect (self->spin
|
||||
// ,"signal::activate", vn_spin_on_value_changed, self
|
||||
,"signal::value-changed", vn_spin_on_value_changed, self
|
||||
,"signal::focus-out-event", vn_spin_on_focus_out, self
|
||||
,"signal::output", vn_spin_on_output, self
|
||||
,NULL
|
||||
);
|
||||
g_signal_connect (obj->spin, "value-changed",
|
||||
G_CALLBACK (vn_spin_on_value_changed), obj);
|
||||
g_signal_connect (obj->spin, "output",
|
||||
G_CALLBACK (vn_spin_on_output), obj);
|
||||
g_signal_connect (self->spin, "value-changed",
|
||||
G_CALLBACK (vn_spin_on_value_changed), self);
|
||||
g_signal_connect (self->spin, "output",
|
||||
G_CALLBACK (vn_spin_on_output), self);
|
||||
|
||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->spin);
|
||||
VN_FIELD_GET_CLASS (self)->set_widget (VN_FIELD (self),
|
||||
GTK_WIDGET (self->spin));
|
||||
}
|
||||
|
||||
static void vn_spin_finalize (VnSpin * obj)
|
||||
static void vn_spin_finalize (VnSpin * self)
|
||||
{
|
||||
G_OBJECT_CLASS (vn_spin_parent_class)->finalize (G_OBJECT (obj));
|
||||
G_OBJECT_CLASS (vn_spin_parent_class)->finalize (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void vn_spin_class_init (VnSpinClass * klass)
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vn/vn-field.h>
|
||||
|
||||
#define VN_TYPE_SPIN (vn_spin_get_type ())
|
||||
#define VN_SPIN(object) (G_TYPE_CHECK_INSTANCE_CAST (object, VN_TYPE_SPIN , VnSpin))
|
||||
#define VN_IS_SPIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_SPIN))
|
||||
#define VN_SPIN(self) (G_TYPE_CHECK_INSTANCE_CAST (self, VN_TYPE_SPIN , VnSpin))
|
||||
#define VN_IS_SPIN(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, VN_TYPE_SPIN))
|
||||
#define VN_SPIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_SPIN, VnSpinClass))
|
||||
#define VN_IS_SPIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_SPIN))
|
||||
#define VN_SPIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_SPIN, VnSpinClass))
|
||||
#define VN_SPIN_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, VN_TYPE_SPIN, VnSpinClass))
|
||||
|
||||
typedef struct _VnSpin VnSpin;
|
||||
typedef struct _VnSpinClass VnSpinClass;
|
||||
|
|
Reference in New Issue