VnColumnSpin:
- Eliminadas propiedades ya definidas en su cellrenderer interno. VnConsulter: - Limpieza de codigo obsoleto.
This commit is contained in:
parent
cc827ae619
commit
9bea4cae33
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.0"/>
|
||||
<requires lib="gtk+" version="3.8"/>
|
||||
<requires lib="vn" version="0.0"/>
|
||||
<!-- interface-local-resource-path ../image -->
|
||||
<object class="GtkActionGroup" id="actions">
|
||||
|
@ -31,24 +31,17 @@
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model">
|
||||
<columns>
|
||||
<!-- column-name col -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkBox" id="main">
|
||||
<property name="height_request">300</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">8</property>
|
||||
<property name="border_width">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">8</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox">
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">8</property>
|
||||
<property name="spacing">4</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label">
|
||||
<property name="visible">True</property>
|
||||
|
@ -71,7 +64,7 @@
|
|||
<object class="GtkEntry" id="combo-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="activates_default">True</property>
|
||||
<property name="placeholder_text">Set on the code</property>
|
||||
<property name="placeholder_text" translatable="yes">Type or select a query</property>
|
||||
<signal name="activate" handler="gtk_action_activate" object="send" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -83,48 +76,65 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button-send">
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="related_action">send</property>
|
||||
<object class="GtkButtonBox" id="buttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="layout_style">start</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button-send">
|
||||
<property name="label" translatable="yes">Send</property>
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="related_action">send</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">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="button-clean">
|
||||
<property name="label" translatable="yes">Clean</property>
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="related_action">clean</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="stop">
|
||||
<property name="label">gtk-stop</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="vn_consulter_on_stop_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button-clean">
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="related_action">clean</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="stop">
|
||||
<property name="label">gtk-stop</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="vn_consulter_on_stop_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -133,16 +143,37 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkVPaned" id="paned">
|
||||
<object class="GtkPaned" id="paned1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="position">120</property>
|
||||
<property name="position_set">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow">
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow-data">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="VnGrid" id="consulter">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="grid-selection">
|
||||
<property name="mode">multiple</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow-log">
|
||||
<property name="height_request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview">
|
||||
|
@ -154,35 +185,19 @@
|
|||
<property name="fixed_height_mode">True</property>
|
||||
<property name="rubber_banding">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection1"/>
|
||||
<object class="GtkTreeSelection" id="treeview-selection"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="VnGrid" id="consulter">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="grid-selection1">
|
||||
<property name="mode">multiple</property>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="column-log">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Log</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -236,4 +251,10 @@
|
|||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model">
|
||||
<columns>
|
||||
<!-- column-name col -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -20,6 +20,31 @@
|
|||
|
||||
#define FILE_KW "sql://"
|
||||
|
||||
static const gchar * queries[] =
|
||||
{
|
||||
//MySQL (kk schema)
|
||||
|
||||
"/*my*/SELECT id, name, item_id, item_id2, amount, item.price "
|
||||
"FROM movement JOIN item USING (item_id, item_id2)"
|
||||
,"/*my*/SELECT item_id,item_id2, i.name, m.id, m.amount, m.price "
|
||||
"FROM item i LEFT JOIN movement m USING (item_id, item_id2)"
|
||||
,"/*my*/SELECT item_id, item_id2, name, price FROM item"
|
||||
|
||||
//PgSQL (test schema)
|
||||
|
||||
,"/*pg*/SELECT pg_sleep(120)"
|
||||
,"/*pg*/SELECT i.id, i.name, i.color, m.id, m.amount "
|
||||
"FROM item i LEFT JOIN movement m ON i.id = m.item_id"
|
||||
,"/*pg*/SELECT m.id, amount, item_id, name, color "
|
||||
"FROM movement m JOIN item ON m.item_id = item.id"
|
||||
,"sql://example/consulter"
|
||||
,"/*pg*/ SELECT id1, id2, name, ok, date, number, floating, image "
|
||||
"FROM prueben"
|
||||
,"/*pg*/ SELECT id1, number, floating FROM prueben LIMIT 1"
|
||||
|
||||
,"SELECT 1 f_integer, 'A' f_varchar, 1.1 f_double, TRUE f_boolean, NULL f_null"
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (VnConsulter, vn_consulter, VN_TYPE_FORM);
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
||||
|
@ -49,6 +74,7 @@ static void vn_consulter_set_message (VnConsulter * obj, const gchar * msg)
|
|||
static void vn_consulter_model_status_changed (DbModel * model,
|
||||
DbModelStatus status, VnConsulter * obj)
|
||||
{
|
||||
gint i;
|
||||
GList * n;
|
||||
GtkTreeView * tv = GTK_TREE_VIEW (obj->grid);
|
||||
GList * cols = gtk_tree_view_get_columns (tv);
|
||||
|
@ -61,96 +87,111 @@ static void vn_consulter_model_status_changed (DbModel * model,
|
|||
|
||||
g_list_free (cols);
|
||||
|
||||
switch (status)
|
||||
if (status == DB_MODEL_STATUS_READY)
|
||||
for (i = 0; i < db_model_get_ncols (model); i++)
|
||||
{
|
||||
case DB_MODEL_STATUS_READY:
|
||||
VnColumn * column;
|
||||
GType col_type, type = db_model_get_column_type (model, i);
|
||||
const gchar * colname = db_model_get_column_name (model, i);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
gint i;
|
||||
case G_TYPE_BOOLEAN:
|
||||
col_type = VN_TYPE_COLUMN_CHECK;
|
||||
break;
|
||||
case G_TYPE_INT:
|
||||
case G_TYPE_UINT:
|
||||
case G_TYPE_FLOAT:
|
||||
case G_TYPE_DOUBLE:
|
||||
col_type = VN_TYPE_COLUMN_SPIN;
|
||||
break;
|
||||
default:
|
||||
if (g_strcmp0 (colname, "image"))
|
||||
col_type = VN_TYPE_COLUMN_ENTRY;
|
||||
else
|
||||
col_type = VN_TYPE_COLUMN_IMAGE;
|
||||
}
|
||||
|
||||
for (i = 0; i < db_model_get_ncols (model); i++)
|
||||
column = g_object_new (col_type
|
||||
,"title", colname
|
||||
,"column-index", i
|
||||
,"editable", TRUE
|
||||
,"expand", FALSE
|
||||
,"resizable", TRUE
|
||||
,NULL
|
||||
);
|
||||
|
||||
// Cofigures the numeric columns
|
||||
|
||||
if (col_type == VN_TYPE_COLUMN_SPIN)
|
||||
{
|
||||
guint min_width = 100;
|
||||
guint digits = 0;
|
||||
gdouble climb_rate = 0.5;
|
||||
GtkCellRenderer * cell;
|
||||
GtkAdjustment * adjustment = NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
VnColumn * column;
|
||||
GType col_type, type = db_model_get_column_type (model, i);
|
||||
gboolean image = FALSE;
|
||||
gchar * format = NULL;
|
||||
/*col_type = VN_TYPE_COLUMN_ENTRY;
|
||||
if (type == G_TYPE_INT)
|
||||
format = "%d";
|
||||
else if (type == G_TYPE_UINT)
|
||||
format = "%u";
|
||||
else*/
|
||||
if (type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE
|
||||
|| type == G_TYPE_INT || type == G_TYPE_UINT)
|
||||
col_type = VN_TYPE_COLUMN_SPIN;
|
||||
//format = "%.2f";
|
||||
else if (type == G_TYPE_BYTES)
|
||||
col_type = VN_TYPE_COLUMN_IMAGE;
|
||||
else if (type == G_TYPE_BOOLEAN)
|
||||
col_type = VN_TYPE_COLUMN_CHECK;
|
||||
//format = "%b";
|
||||
else if (type == G_TYPE_STRING && !g_utf8_collate
|
||||
(g_utf8_casefold (db_model_get_column_name (model, i), -1)
|
||||
,g_utf8_casefold ("image", -1)))
|
||||
{
|
||||
image = TRUE;
|
||||
col_type = VN_TYPE_COLUMN_IMAGE;
|
||||
}
|
||||
/*else if (type == G_TYPE_DATE)
|
||||
format = "%Y-%m-%d";
|
||||
else if (type == G_TYPE_DATE_TIME)
|
||||
format = "%Y-%m-%d %T";
|
||||
*/ else
|
||||
{
|
||||
col_type = VN_TYPE_COLUMN_ENTRY;
|
||||
//format = "%s";
|
||||
}
|
||||
|
||||
column = g_object_new (col_type
|
||||
,"title", db_model_get_column_name (model, i)
|
||||
,"column-index", i
|
||||
,"editable", TRUE
|
||||
,"expand", FALSE
|
||||
,NULL
|
||||
);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (obj->grid),
|
||||
GTK_TREE_VIEW_COLUMN (column));
|
||||
|
||||
if (format)
|
||||
g_object_set (column, "format", format, NULL);
|
||||
|
||||
if (type == G_TYPE_INT)
|
||||
g_object_set (column,
|
||||
"lower", (gdouble)G_MININT,
|
||||
"upper", (gdouble)G_MAXINT,
|
||||
NULL);
|
||||
else if (type == G_TYPE_UINT)
|
||||
g_object_set (column,
|
||||
"upper", (gdouble)G_MAXUINT,
|
||||
NULL);
|
||||
else if (type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE)
|
||||
g_object_set (column,
|
||||
"digits", 2,
|
||||
"lower", -1000.0,
|
||||
"upper", 1000.0,
|
||||
"step-increment", 0.1,
|
||||
NULL);
|
||||
else
|
||||
if (image)
|
||||
g_object_set (column,
|
||||
"host", "www.verdnatura.es",
|
||||
"path", "image/cache/catalog/icon",
|
||||
"tooltip-path", "../full",
|
||||
NULL);
|
||||
case G_TYPE_INT:
|
||||
adjustment = gtk_adjustment_new (
|
||||
0, G_MININT, G_MAXINT, 1, 1, 0);
|
||||
break;
|
||||
case G_TYPE_UINT:
|
||||
adjustment = gtk_adjustment_new (
|
||||
0, 0, G_MAXUINT, 1, 1, 0);
|
||||
break;
|
||||
case G_TYPE_FLOAT:
|
||||
adjustment = gtk_adjustment_new (
|
||||
0, G_MINFLOAT, G_MAXFLOAT, 0.1, 1, 0);
|
||||
break;
|
||||
case G_TYPE_DOUBLE:
|
||||
adjustment = gtk_adjustment_new (
|
||||
0, G_MINDOUBLE, G_MAXDOUBLE, 0.1, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
switch (type)
|
||||
{
|
||||
case G_TYPE_FLOAT:
|
||||
case G_TYPE_DOUBLE:
|
||||
digits = 2;
|
||||
climb_rate = 0.1;
|
||||
min_width = 120;
|
||||
}
|
||||
|
||||
g_object_set (column
|
||||
,"digits", digits
|
||||
,"min-width", min_width
|
||||
,NULL
|
||||
);
|
||||
|
||||
cell = vn_column_get_cell_renderer (column);
|
||||
g_object_set (cell
|
||||
,"adjustment", adjustment
|
||||
,"climb_rate", climb_rate
|
||||
,"digits", digits
|
||||
,NULL
|
||||
);
|
||||
}
|
||||
case DB_MODEL_STATUS_ERROR:
|
||||
vn_consulter_set_message (obj, "Error");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
// Cofigures the image columns
|
||||
|
||||
if (col_type == VN_TYPE_COLUMN_IMAGE)
|
||||
g_object_set (column
|
||||
,"host", "www.verdnatura.es"
|
||||
,"path", "image/cache/catalog/icon"
|
||||
,"tooltip-path", "../full"
|
||||
,NULL
|
||||
);
|
||||
|
||||
// Appends the column to the grid
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (obj->grid),
|
||||
GTK_TREE_VIEW_COLUMN (column));
|
||||
}
|
||||
else if (status == DB_MODEL_STATUS_ERROR)
|
||||
vn_consulter_set_message (obj, "Error");
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (obj->mode), TRUE);
|
||||
}
|
||||
|
@ -202,46 +243,23 @@ void vn_consulter_send (GtkButton * button, VnConsulter * obj)
|
|||
static void vn_consulter_open (VnConsulter * obj)
|
||||
{
|
||||
gint i;
|
||||
GtkCellRenderer * cell;
|
||||
GtkTreeViewColumn * column;
|
||||
VnForm * form = VN_FORM (obj);
|
||||
|
||||
obj->file = g_strconcat
|
||||
(FILE_KW, vn_mod_get_name (form->mod), "/consulter", NULL);
|
||||
|
||||
gchar * queries[] =
|
||||
{
|
||||
//MySQL (kk schema)
|
||||
"/*my*/SELECT id, name, item_id, item_id2, amount, item.price "
|
||||
"FROM movement JOIN item USING (item_id, item_id2)"
|
||||
,"/*my*/SELECT item_id,item_id2, i.name, m.id, m.amount, m.price "
|
||||
"FROM item i LEFT JOIN movement m USING (item_id, item_id2)"
|
||||
,"/*my*/SELECT item_id, item_id2, name, price FROM item"
|
||||
//PgSQL (test schema)
|
||||
,"/*pg*/SELECT pg_sleep(120)"
|
||||
,"/*pg*/SELECT i.id, i.name, i.color, m.id, m.amount "
|
||||
"FROM item i LEFT JOIN movement m ON i.id = m.item_id"
|
||||
,"/*pg*/SELECT m.id, amount, item_id, name, color "
|
||||
"FROM movement m JOIN item ON m.item_id = item.id"
|
||||
,obj->file
|
||||
,"/*pg*/ SELECT id1, id2, name, ok, date, number, floating, image "
|
||||
"FROM prueben"
|
||||
,"/*pg*/ SELECT id1, number, floating FROM prueben LIMIT 1"
|
||||
,"SELECT 1, 'A', 1.1, TRUE, NULL"
|
||||
,NULL
|
||||
};
|
||||
|
||||
obj->model = vn_form_get (form, "model");
|
||||
obj->combo = vn_form_get (form, "query");
|
||||
obj->tv = vn_form_get (form, "treeview");
|
||||
obj->mode = vn_form_get (form, "mode");
|
||||
obj->grid = vn_form_get (form, "consulter");
|
||||
obj->handler = vn_form_get (form, "handler");
|
||||
gtk_entry_set_placeholder_text (vn_form_get (form, "combo-entry"),
|
||||
_("Type or select a query"));
|
||||
|
||||
gtk_tree_view_insert_column_with_attributes (obj->tv, -1, _("Message"),
|
||||
gtk_cell_renderer_text_new (), "text", 0, NULL);
|
||||
column = vn_form_get (form, "column-log");
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_column_pack_start (column, cell, TRUE);
|
||||
gtk_tree_view_column_add_attribute (column, cell, "text", 0);
|
||||
|
||||
for (i = 0; i < g_strv_length (queries); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (queries); i++)
|
||||
gtk_combo_box_text_prepend_text (obj->combo, queries[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,27 +31,11 @@ static void vn_column_spin_on_edited (GtkCellRendererSpin * cell,
|
|||
const gchar * path, gchar * text, VnColumnSpin * obj)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
DbModelStatus status = db_model_get_status (vn_column_get_model (VN_COLUMN (obj)));
|
||||
|
||||
if (status != DB_MODEL_STATUS_READY)
|
||||
return;
|
||||
|
||||
if (g_strcmp0 (text, ""))
|
||||
{
|
||||
gchar * err;
|
||||
|
||||
if (!err || *err == '\0')
|
||||
{
|
||||
gdouble val, min, max;
|
||||
|
||||
g_object_get (obj->adjustment, "lower", &min, "upper", &max, NULL);
|
||||
val = CLAMP (g_strtod (text, &err), min, max);
|
||||
g_value_init (&value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (&value, val);
|
||||
g_object_set (obj->adjustment, "value", val, NULL);
|
||||
}
|
||||
else
|
||||
return;
|
||||
g_value_init (&value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (&value, g_strtod (text, NULL));
|
||||
}
|
||||
else
|
||||
g_value_init (&value, GVN_TYPE_NULL);
|
||||
|
@ -148,11 +132,7 @@ static void vn_column_spin_set_value (VnColumnSpin * obj, GtkTreeModel * model,
|
|||
|
||||
enum
|
||||
{
|
||||
PROP_CLIMB_RATE = 1
|
||||
,PROP_DIGITS
|
||||
,PROP_LOWER
|
||||
,PROP_UPPER
|
||||
,PROP_STEP
|
||||
PROP_DIGITS = 1
|
||||
};
|
||||
|
||||
static void vn_column_spin_set_property (VnColumnSpin * obj, guint id,
|
||||
|
@ -160,9 +140,6 @@ static void vn_column_spin_set_property (VnColumnSpin * obj, guint id,
|
|||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_CLIMB_RATE:
|
||||
g_object_set (VN_COLUMN (obj)->cell, "climb-rate", g_value_get_double (value), NULL);
|
||||
break;
|
||||
case PROP_DIGITS:
|
||||
{
|
||||
guint digits = g_value_get_uint (value);
|
||||
|
@ -171,18 +148,6 @@ static void vn_column_spin_set_property (VnColumnSpin * obj, guint id,
|
|||
obj->format = g_strdup_printf ("%%.%df", digits);
|
||||
break;
|
||||
}
|
||||
case PROP_LOWER:
|
||||
g_object_set (obj->adjustment, "lower", g_value_get_double (value), NULL);
|
||||
break;
|
||||
case PROP_UPPER:
|
||||
g_object_set (obj->adjustment, "upper", g_value_get_double (value), NULL);
|
||||
break;
|
||||
case PROP_STEP:
|
||||
g_object_set (obj->adjustment,
|
||||
"step-increment", g_value_get_double (value),
|
||||
"page-increment", g_value_get_double (value) * 10,
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
}
|
||||
|
@ -193,21 +158,9 @@ static void vn_column_spin_get_property (VnColumnSpin * obj, guint id,
|
|||
{
|
||||
switch (id)
|
||||
{
|
||||
case PROP_CLIMB_RATE:
|
||||
g_object_get_property (G_OBJECT (VN_COLUMN (obj)->cell), "climb-rate", value);
|
||||
break;
|
||||
case PROP_DIGITS:
|
||||
g_object_get_property (G_OBJECT (VN_COLUMN (obj)->cell), "digits", value);
|
||||
break;
|
||||
case PROP_LOWER:
|
||||
g_object_get_property (G_OBJECT (obj->adjustment), "lower", value);
|
||||
break;
|
||||
case PROP_UPPER:
|
||||
g_object_get_property (G_OBJECT (obj->adjustment), "upper", value);
|
||||
break;
|
||||
case PROP_STEP:
|
||||
g_object_get_property (G_OBJECT (obj->adjustment), "step-increment", value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
|
||||
}
|
||||
|
@ -215,19 +168,16 @@ static void vn_column_spin_get_property (VnColumnSpin * obj, guint id,
|
|||
|
||||
static void vn_column_spin_init (VnColumnSpin * obj)
|
||||
{
|
||||
GtkCellRenderer * cell = gtk_cell_renderer_spin_new ();
|
||||
GtkCellRenderer * cell;
|
||||
|
||||
obj->adjustment = gtk_adjustment_new (0.0, G_MININT, G_MAXINT, 0.0, 1.0, 0.0);
|
||||
obj->format = NULL;
|
||||
|
||||
cell = gtk_cell_renderer_spin_new ();
|
||||
g_object_set (cell
|
||||
,"adjustment", obj->adjustment
|
||||
,"xalign", 1.0
|
||||
,"alignment", PANGO_ALIGN_RIGHT
|
||||
,NULL
|
||||
);
|
||||
|
||||
obj->format = NULL;
|
||||
|
||||
VN_COLUMN_GET_CLASS (obj)->set_renderer (VN_COLUMN (obj), cell);
|
||||
}
|
||||
|
||||
|
@ -246,14 +196,6 @@ static void vn_column_spin_class_init (VnColumnSpinClass * klass)
|
|||
col_k->set_value = (VnColumnSetValueFunc) vn_column_spin_set_value;
|
||||
col_k->set_editable = (VnColumnSetEditableFunc) vn_column_spin_set_editable;
|
||||
|
||||
g_object_class_install_property (k, PROP_CLIMB_RATE,
|
||||
g_param_spec_double ("climb-rate"
|
||||
,_("Climb rate")
|
||||
,_("The acceleration rate when you hold down a button.")
|
||||
,0.0 ,G_MAXDOUBLE ,0.0
|
||||
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
|
||||
));
|
||||
|
||||
g_object_class_install_property (k, PROP_DIGITS,
|
||||
g_param_spec_uint ("digits"
|
||||
,_("Digits")
|
||||
|
@ -261,28 +203,4 @@ static void vn_column_spin_class_init (VnColumnSpinClass * klass)
|
|||
,0 ,20 ,0
|
||||
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
|
||||
));
|
||||
|
||||
g_object_class_install_property (k, PROP_LOWER,
|
||||
g_param_spec_double ("lower"
|
||||
,_("Minimum value")
|
||||
,_("The minimum value of the internal adjustment.")
|
||||
,-G_MAXDOUBLE ,G_MAXDOUBLE ,-G_MAXDOUBLE
|
||||
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
|
||||
));
|
||||
|
||||
g_object_class_install_property (k, PROP_UPPER,
|
||||
g_param_spec_double ("upper"
|
||||
,_("Maximum value")
|
||||
,_("The maximum value of the internal adjustment.")
|
||||
,-G_MAXDOUBLE ,G_MAXDOUBLE ,G_MAXDOUBLE
|
||||
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
|
||||
));
|
||||
|
||||
g_object_class_install_property (k, PROP_STEP,
|
||||
g_param_spec_double ("step-increment"
|
||||
,_("Step Increment")
|
||||
,_("The step increment of the internal adjustment")
|
||||
,0.00000000000000000001 ,10000000000.0 ,1.0
|
||||
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
|
||||
));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ typedef struct _VnColumnSpinClass VnColumnSpinClass;
|
|||
struct _VnColumnSpin
|
||||
{
|
||||
VnColumn parent;
|
||||
GtkAdjustment * adjustment;
|
||||
gchar * format;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,14 +55,14 @@ static void vn_column_value_changed (VnColumn * obj, const gchar * path, const G
|
|||
static void vn_column_data_func (GtkTreeViewColumn * col, GtkCellRenderer * cell,
|
||||
GtkTreeModel * model, GtkTreeIter * iter, VnColumn * obj)
|
||||
{
|
||||
GdkRGBA * background;
|
||||
/* GdkRGBA * background;
|
||||
DbIter dbiter;
|
||||
DbModelRowOp ops;
|
||||
|
||||
*/
|
||||
GValue value = G_VALUE_INIT;
|
||||
gtk_tree_model_get_value (model, iter, obj->column_index, &value);
|
||||
obj->set_value (obj, model, iter, cell, &value);
|
||||
|
||||
/*
|
||||
vn_gtk_tree_iter_to_db_iter (iter, &dbiter);
|
||||
ops = db_model_get_row_operations (
|
||||
vn_grid_model_get_model (VN_GRID_MODEL (model))
|
||||
|
@ -76,9 +76,8 @@ static void vn_column_data_func (GtkTreeViewColumn * col, GtkCellRenderer * cell
|
|||
else
|
||||
background = NULL;
|
||||
|
||||
if (background)
|
||||
g_object_set (cell, "cell-background-rgba", background, NULL);
|
||||
|
||||
g_object_set (cell, "cell-background-rgba", background, NULL);
|
||||
*/
|
||||
if (obj->style_func)
|
||||
obj->style_func (VN_COLUMN (col), cell, iter, &value);
|
||||
|
||||
|
|
Reference in New Issue