Beispiel #1
0
void del_matrix(sp_matrix_t *m)
{
	int i;

	for (i = 0; i < m->rowc; ++i) {
		if (! is_empty_row(i)) {
			entry_t *e;
			sp_matrix_list_head_t *n;

			n = m->rows[i]->next;
			do {
				/* get current matrix element */
				e = _container_of(n, entry_t, row_chain);
				n = n->next;
				free(e);
			} while (n != NULL);

		}
		free(m->rows[i]);
	}
	for (i = 0; i < m->colc; ++i)
		free(m->cols[i]);
	free(m->last_col_el);
	free(m->last_row_el);
	free(m->rows);
	free(m->cols);
	free(m);
}
Beispiel #2
0
static void
sync_object (GladeEPropAttrs *eprop_attrs, gboolean use_command)
{
  GList *attributes = NULL;
  GladeAttribute *gattr;
  GtkTreeIter iter;
  PangoAttrType type;
  AttrEditType edit_type;
  gchar *strval = NULL;
  gboolean valid;

  valid = gtk_tree_model_iter_children (eprop_attrs->model, &iter, NULL);

  while (valid)
    {
      if (!is_empty_row (eprop_attrs->model, &iter))
        {
          gtk_tree_model_get (eprop_attrs->model, &iter,
                              COLUMN_TYPE, &type,
                              COLUMN_EDIT_TYPE, &edit_type,
                              COLUMN_TEXT, &strval, -1);

          gattr =
              glade_gtk_attribute_from_string (type,
                                               (edit_type ==
                                                EDIT_TOGGLE) ? "" : strval);
          strval = (g_free (strval), NULL);

          attributes = g_list_prepend (attributes, gattr);

        }
      valid = gtk_tree_model_iter_next (eprop_attrs->model, &iter);
    }

  if (use_command)
    {
      GValue value = { 0, };

      g_value_init (&value, GLADE_TYPE_ATTR_GLIST);
      g_value_take_boxed (&value, g_list_reverse (attributes));
      glade_editor_property_commit (GLADE_EDITOR_PROPERTY (eprop_attrs),
                                    &value);
      g_value_unset (&value);
    }
  else
    {
      GladeProperty *property = 
	glade_editor_property_get_property (GLADE_EDITOR_PROPERTY (eprop_attrs));

      glade_property_set (property, g_list_reverse (attributes));
      glade_attr_list_free (attributes);
    }
}
Beispiel #3
0
const matrix_elem_t *matrix_row_first(sp_matrix_t *m, int row)
{
	if (is_empty_row(row))
		return NULL;

	m->dir   = right;
	m->first = m->rows[row];
	m->last  = m->first->next;
	m->next  = m->last ? m->last->next : NULL;

	assert (list_entry_by_row(m->last)->row == row);

	return list_entry_by_row(m->last);
}
Beispiel #4
0
double matrix_get(const sp_matrix_t *m, int row, int col)
{
	sp_matrix_list_head_t *dummy, *dummy2;
	matrix_elem_t *me;

	if (is_empty_row(row) || is_empty_col(col))
		return 0.0;

	if (m->maxrow < m->maxcol)
		me = m_search_in_col(m, row, col, &dummy, &dummy2);
	else
		me = m_search_in_row(m, row, col, &dummy, &dummy2);

	if (me)
		assert(me->col == col && me->row == row);

	return me ? me->val : 0.0;
}