Modificaciones varias:
- Se han añadido constructores new() a las columnas. - VnLabel se alinea a la izquierda y hace un widget_show()
This commit is contained in:
parent
b042af35db
commit
e1b3173e5b
|
@ -105,11 +105,15 @@ format = "%Y-%m-%d %T";
|
||||||
//format = "%s";
|
//format = "%s";
|
||||||
}
|
}
|
||||||
|
|
||||||
column = vn_grid_append_column (obj->grid, i
|
column = g_object_new (col_type
|
||||||
,db_model_get_column_name (model, i)
|
,"title", db_model_get_column_name (model, i)
|
||||||
,col_type
|
,"column-index", i
|
||||||
,TRUE, FALSE
|
,"editable", TRUE
|
||||||
|
,"expand", FALSE
|
||||||
|
,NULL
|
||||||
);
|
);
|
||||||
|
gtk_tree_view_append_column (GTK_TREE_VIEW (obj->grid),
|
||||||
|
GTK_TREE_VIEW_COLUMN (column));
|
||||||
|
|
||||||
if (format)
|
if (format)
|
||||||
g_object_set (column, "format", format, NULL);
|
g_object_set (column, "format", format, NULL);
|
||||||
|
@ -221,6 +225,7 @@ static void vn_consulter_open (VnConsulter * obj)
|
||||||
,"/*pg*/ SELECT id1, id2, name, ok, date, number, floating, image "
|
,"/*pg*/ SELECT id1, id2, name, ok, date, number, floating, image "
|
||||||
"FROM prueben"
|
"FROM prueben"
|
||||||
,"/*pg*/ SELECT id1, number, floating FROM prueben LIMIT 1"
|
,"/*pg*/ SELECT id1, number, floating FROM prueben LIMIT 1"
|
||||||
|
,"SELECT 1, 'A', 1.1, TRUE, NULL"
|
||||||
,NULL
|
,NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
G_DEFINE_TYPE (VnColumnCheck, vn_column_check, VN_TYPE_COLUMN);
|
G_DEFINE_TYPE (VnColumnCheck, vn_column_check, VN_TYPE_COLUMN);
|
||||||
|
|
||||||
|
VnColumn * vn_column_check_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (VN_TYPE_COLUMN_CHECK, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||||
|
|
||||||
static void vn_column_check_cb_toggled (GtkCellRendererToggle * cell,
|
static void vn_column_check_cb_toggled (GtkCellRendererToggle * cell,
|
||||||
|
|
|
@ -42,5 +42,6 @@ struct _VnColumnCheckClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType vn_column_check_get_type ();
|
GType vn_column_check_get_type ();
|
||||||
|
VnColumn * vn_column_check_new ();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -25,6 +25,13 @@ G_DEFINE_TYPE_WITH_CODE (VnColumnCombo, vn_column_combo, VN_TYPE_COLUMN,
|
||||||
vn_column_combo_model_holder_init)
|
vn_column_combo_model_holder_init)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
VnColumn * vn_column_combo_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (VN_TYPE_COLUMN_COMBO, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||||
|
|
||||||
static void vn_column_combo_set_value (VnColumnCombo * obj, GtkTreeModel * model,
|
static void vn_column_combo_set_value (VnColumnCombo * obj, GtkTreeModel * model,
|
||||||
GtkTreeIter * tree_iter, GObject * cell, const GValue * value)
|
GtkTreeIter * tree_iter, GObject * cell, const GValue * value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,5 +51,6 @@ struct _VnColumnComboClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType vn_column_combo_get_type ();
|
GType vn_column_combo_get_type ();
|
||||||
|
VnColumn * vn_column_combo_new ();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
G_DEFINE_TYPE (VnColumnEntry, vn_column_entry, VN_TYPE_COLUMN);
|
G_DEFINE_TYPE (VnColumnEntry, vn_column_entry, VN_TYPE_COLUMN);
|
||||||
|
|
||||||
|
VnColumn * vn_column_entry_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (VN_TYPE_COLUMN_ENTRY, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||||
|
|
||||||
static void vn_column_entry_cb_edited (GtkCellRendererText * cell,
|
static void vn_column_entry_cb_edited (GtkCellRendererText * cell,
|
||||||
|
|
|
@ -44,5 +44,6 @@ struct _VnColumnEntryClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType vn_column_entry_get_type ();
|
GType vn_column_entry_get_type ();
|
||||||
|
VnColumn * vn_column_entry_new ();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -41,7 +41,12 @@ typedef struct
|
||||||
}
|
}
|
||||||
TooltipData;
|
TooltipData;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Methods
|
VnColumn * vn_column_image_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (VN_TYPE_COLUMN_IMAGE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||||
|
|
||||||
static void vn_column_image_download_error (VnColumnImage * obj, const GError * error)
|
static void vn_column_image_download_error (VnColumnImage * obj, const GError * error)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,5 +55,6 @@ struct _VnColumnImageClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType vn_column_image_get_type ();
|
GType vn_column_image_get_type ();
|
||||||
|
VnColumn * vn_column_image_new ();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,13 @@
|
||||||
|
|
||||||
G_DEFINE_TYPE (VnColumnSpin, vn_column_spin, VN_TYPE_COLUMN);
|
G_DEFINE_TYPE (VnColumnSpin, vn_column_spin, VN_TYPE_COLUMN);
|
||||||
|
|
||||||
|
VnColumn * vn_column_spin_new ()
|
||||||
|
{
|
||||||
|
return g_object_new (VN_TYPE_COLUMN_SPIN, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||||
|
|
||||||
static void vn_column_spin_on_edited (GtkCellRendererSpin * cell,
|
static void vn_column_spin_on_edited (GtkCellRendererSpin * cell,
|
||||||
const gchar * path, gchar * text, VnColumnSpin * obj)
|
const gchar * path, gchar * text, VnColumnSpin * obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,5 +44,6 @@ struct _VnColumnSpinClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType vn_column_spin_get_type ();
|
GType vn_column_spin_get_type ();
|
||||||
|
VnColumn * vn_column_spin_new ();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -25,7 +25,6 @@
|
||||||
*
|
*
|
||||||
* A label representing a generic value field.
|
* A label representing a generic value field.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
G_DEFINE_TYPE (VnLabel, vn_label, VN_TYPE_FIELD);
|
G_DEFINE_TYPE (VnLabel, vn_label, VN_TYPE_FIELD);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +89,8 @@ static void vn_label_init (VnLabel * obj)
|
||||||
{
|
{
|
||||||
obj->format = NULL;
|
obj->format = NULL;
|
||||||
obj->label = GTK_LABEL (gtk_label_new (""));
|
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));
|
gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->label));
|
||||||
|
|
||||||
VN_FIELD (obj)->field = GTK_WIDGET (obj->label);
|
VN_FIELD (obj)->field = GTK_WIDGET (obj->label);
|
||||||
|
|
97
vn/vn-grid.c
97
vn/vn-grid.c
|
@ -349,103 +349,6 @@ DbModel * vn_grid_get_model (VnGrid * obj)
|
||||||
return obj->model;
|
return obj->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* vn_grid_insert_column:
|
|
||||||
* @obj: #VnGrid where the new column will be appended
|
|
||||||
* @position: the position where the column will be inserted
|
|
||||||
* @column_index: the index of the source column in the model
|
|
||||||
* @title: the title
|
|
||||||
* @column_type: the #GType of the assigned #VnColumn
|
|
||||||
* @editable: a %gboolean indicating whether the column is editable
|
|
||||||
* @expand: a %gboolean indicating whether the column is expandable
|
|
||||||
*
|
|
||||||
* Creates and inserts a new column in the grid with the given column and
|
|
||||||
* position, if @position is -1 the column will be appended to the end.
|
|
||||||
*
|
|
||||||
* Return value: (transfer none): the #VnColumn assigned to the new column.
|
|
||||||
**/
|
|
||||||
VnColumn * vn_grid_insert_column (VnGrid * obj, gint position, gint column_index,
|
|
||||||
const gchar * title, GType column_type, gboolean editable, gboolean expand)
|
|
||||||
{
|
|
||||||
GtkTreeViewColumn * column;
|
|
||||||
|
|
||||||
g_return_val_if_fail (VN_IS_GRID (obj), NULL);
|
|
||||||
g_return_val_if_fail (index >= 0, NULL);
|
|
||||||
g_return_val_if_fail (g_type_is_a (column_type, VN_TYPE_COLUMN), NULL);
|
|
||||||
|
|
||||||
column = g_object_new (column_type
|
|
||||||
,"title" ,title
|
|
||||||
,"expand" ,expand
|
|
||||||
,"resizable" ,TRUE
|
|
||||||
,"sort-indicator" ,TRUE
|
|
||||||
,"sizing" ,GTK_TREE_VIEW_COLUMN_GROW_ONLY
|
|
||||||
,"column-index" ,column_index
|
|
||||||
,"editable" ,editable
|
|
||||||
,NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (obj), column);
|
|
||||||
return VN_COLUMN (column);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* vn_grid_append_column:
|
|
||||||
* @obj: #VnGrid where the new column will be appended
|
|
||||||
* @column_index: the index of the source column in the model
|
|
||||||
* @title: the title
|
|
||||||
* @column_type: the #GType of the assigned #VnCell
|
|
||||||
* @editable: a %gboolean indicating whether the column is editable
|
|
||||||
* @expand: a %gboolean indicating whether the column is expandable
|
|
||||||
*
|
|
||||||
* Creates and appends a new column at the end of the grid with the given column.
|
|
||||||
*
|
|
||||||
* Return value: (transfer none): the #VnCell assigned to the new column.
|
|
||||||
**/
|
|
||||||
VnColumn * vn_grid_append_column (VnGrid * obj, gint column_index, const gchar * title,
|
|
||||||
GType column_type, gboolean editable, gboolean expand)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (VN_IS_GRID (obj), NULL);
|
|
||||||
g_return_val_if_fail (index >= 0, NULL);
|
|
||||||
g_return_val_if_fail (g_type_is_a (column_type, VN_TYPE_COLUMN), NULL);
|
|
||||||
|
|
||||||
return vn_grid_insert_column (obj, -1, column_index, title, column_type, editable, expand);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* vn_grid_append_columns:
|
|
||||||
* @obj: the #VnGrid
|
|
||||||
* @...: columns information, see vn_grid_append_column(), terminated with -1
|
|
||||||
*
|
|
||||||
* Appends columns into a #VnGrid.
|
|
||||||
**/
|
|
||||||
void vn_grid_append_columns (VnGrid * obj, ...)
|
|
||||||
{
|
|
||||||
va_list vl;
|
|
||||||
gint index;
|
|
||||||
gchar * title;
|
|
||||||
GType column_type;
|
|
||||||
gboolean editable;
|
|
||||||
gboolean expand;
|
|
||||||
|
|
||||||
g_return_if_fail (VN_IS_GRID (obj));
|
|
||||||
|
|
||||||
va_start (vl, obj);
|
|
||||||
|
|
||||||
while ((index = va_arg (vl, gint)) != -1)
|
|
||||||
{
|
|
||||||
title = va_arg (vl, gchar *);
|
|
||||||
column_type = va_arg (vl, GType);
|
|
||||||
editable = va_arg (vl, gboolean);
|
|
||||||
expand = va_arg (vl, gboolean);
|
|
||||||
|
|
||||||
vn_grid_append_column (obj,
|
|
||||||
index, title, column_type, editable, expand);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end (vl);
|
|
||||||
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
|
@ -52,8 +52,5 @@ VnGrid * vn_grid_new_with_iterator (DbIterator * iterator);
|
||||||
DbIterator * vn_grid_get_iterator (VnGrid * obj);
|
DbIterator * vn_grid_get_iterator (VnGrid * obj);
|
||||||
void vn_grid_set_iterator (VnGrid * obj, DbIterator * iterator);
|
void vn_grid_set_iterator (VnGrid * obj, DbIterator * iterator);
|
||||||
DbModel * vn_grid_get_model (VnGrid * obj);
|
DbModel * vn_grid_get_model (VnGrid * obj);
|
||||||
VnColumn * vn_grid_insert_column (VnGrid * obj, gint position, gint column_index, const gchar * title, GType column_type, gboolean editable, gboolean expand);
|
|
||||||
VnColumn * vn_grid_append_column (VnGrid * obj, gint column_index, const gchar * title, GType column_type, gboolean editable, gboolean expand);
|
|
||||||
void vn_grid_append_columns (VnGrid * obj, ...);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue