This commit is contained in:
Olaf Rempel 2008-03-17 21:40:12 +01:00
parent 41432859c8
commit f7db63b4b3
5 changed files with 31 additions and 10 deletions

View File

@ -15,7 +15,7 @@
static struct tdc_var * var_map[256];
static GByteArray *stream;
void get_varvalue(struct tdc_var *var, char *buf, int size, int viewmode)
void tdc_store_get_varvalue(struct tdc_var *var, char *buf, int size, int viewmode)
{
switch ((var->flags & TDC_TYPEMASK) | ((viewmode & 0x01) << 8)) {
case TDC_UNSIGNED:
@ -122,7 +122,7 @@ void get_varvalue(struct tdc_var *var, char *buf, int size, int viewmode)
}
}
void get_vartype(struct tdc_var *var, char *buf, int size)
void tdc_store_get_vartype(struct tdc_var *var, char *buf, int size)
{
int pos;
int width = (var->flags & TDC_SIZEMASK);
@ -160,6 +160,10 @@ void get_vartype(struct tdc_var *var, char *buf, int size)
pos = snprintf(buf + pos, size - pos, " (ro)");
}
void tdc_store_update_graphlist(void)
{
}
static void destroy_var(int id)
{
g_free(var_map[id]);
@ -186,6 +190,8 @@ static void create_var(int id, uint32_t flags, char *name, int len)
static void update_var(int id, uint8_t *data, int len)
{
memcpy(&(var_map[id & 0xFF]->data_uint8), data, len);
vartab_update_var(var_map[id & 0xFF]);
}
#if 0
@ -394,6 +400,8 @@ int tdc_parse_data(int fd)
void tdc_flush_vars(void)
{
vartab_remove_all_vars();
int i;
for (i = 0; i < ARRAY_SIZE(var_map); i++) {
if (var_map[i] == NULL)

View File

@ -17,8 +17,9 @@ struct tdc_var {
char name[0];
};
void get_varvalue(struct tdc_var *var, char *buf, int size, int viewmode);
void get_vartype(struct tdc_var *var, char *buf, int size);
void tdc_store_get_varvalue(struct tdc_var *var, char *buf, int size, int viewmode);
void tdc_store_get_vartype(struct tdc_var *var, char *buf, int size);
void tdc_store_update_graphlist(void);
int tdc_parse_data(int fd);
void tdc_flush_vars(void);

View File

@ -98,4 +98,6 @@ struct tdc_reqvalues_reply {
#define TDC_READONLY 0x0100
#define TDC_GUI_GRAPH 0x8000
#endif /* TDCPROTO_H_ */

View File

@ -22,14 +22,23 @@ static void cell_graph_toggle(GtkCellRendererToggle *cell,
gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(user_data), &it, path_string);
gboolean toggle;
struct tdc_var *var;
gtk_tree_model_get(GTK_TREE_MODEL(user_data), &it,
COL_GRAPH, &toggle,
COL_VALUE, &var,
-1);
if (var->flags & TDC_GUI_GRAPH)
var->flags &= ~TDC_GUI_GRAPH;
else
var->flags |= TDC_GUI_GRAPH;
gtk_list_store_set(GTK_LIST_STORE(user_data), &it,
COL_GRAPH, !toggle,
-1);
tdc_store_update_graphlist();
}
static gboolean header_toggle_update(GtkTreeModel *model,
@ -103,7 +112,7 @@ static void cell_value_func(GtkTreeViewColumn *column,
gtk_tree_model_get(model, iter, COL_VALUE, &var, -1);
char buf[32];
get_varvalue(var, buf, sizeof(buf), viewmode);
tdc_store_get_varvalue(var, buf, sizeof(buf), viewmode);
g_object_set(cell, "text", buf, NULL);
}
@ -175,7 +184,7 @@ void vartab_add_var(struct tdc_var *var)
gtk_list_store_append(list_store, &it);
char typestr[32];
get_vartype(var, typestr, sizeof(typestr));
tdc_store_get_vartype(var, typestr, sizeof(typestr));
gtk_list_store_set(list_store, &it,
COL_ID, var->id,
@ -189,10 +198,11 @@ void vartab_add_var(struct tdc_var *var)
void vartab_update_var(struct tdc_var *var)
{
// FIXME: don't update *all* columns when *one* value changed
gtk_tree_model_foreach(GTK_TREE_MODEL(list_store), header_toggle_update, NULL);
}
void vartab_remove_var(struct tdc_var *var)
void vartab_remove_all_vars(void)
{
gtk_list_store_clear(list_store);
}

View File

@ -8,6 +8,6 @@ gint variable_tab_init(GtkNotebook *notebook);
void vartab_add_var(struct tdc_var *var);
void vartab_update_var(struct tdc_var *var);
void vartab_remove_var(struct tdc_var *var);
void vartab_remove_all_vars(void);
#endif /* VARIABLE_TAB_H_ */