コード例 #1
0
ファイル: value-format.c プロジェクト: svn2github/gwyddion
static void
gwy_value_format_finalize(GObject *object)
{
    GwyValueFormat *format = (GwyValueFormat*)object;
    ValueFormat *priv = format->priv;
    GWY_FREE(priv->units);
    GWY_FREE(priv->glue);
    GWY_STRING_FREE(priv->value);
    G_OBJECT_CLASS(gwy_value_format_parent_class)->finalize(object);
}
コード例 #2
0
ファイル: surface.c プロジェクト: cbuehler/gwyddion
static void
alloc_data(GwySurface *surface)
{
    GWY_FREE(surface->data);
    if (surface->n)
        surface->data = g_new(GwyXYZ, surface->n);
}
コード例 #3
0
ファイル: coords-view.c プロジェクト: svn2github/gwyddion
/**
 * gwy_coords_view_set_dimension_format:
 * @view: A coords view.
 * @d: Dimension index.
 * @format: (allow-none) (transfer full):
 *          Format to use for coordinates in dimension @d.
 *
 * Sets the format for coordinates in a specific dimension in a coords view.
 *
 * Changing the format for a dimension influences all columns for this
 * dimension with gwy_coords_view_create_column_coord(), whether already
 * existing or created in the future.
 *
 * This method requires the coords type to be set.
 *
 * If @view displays shapes the format set by this function is in effect only
 * for real coordinates, a pixel format is used to display pixel values.
 **/
void
gwy_coords_view_set_dimension_format(GwyCoordsView *view,
                                     guint d,
                                     GwyValueFormat *format)
{
    g_return_if_fail(GWY_IS_COORDS_VIEW(view));
    CoordsView *priv = view->priv;
    g_return_if_fail(priv->dim_info);
    g_return_if_fail(d < priv->coords_class->dimension);
    DimInfo *dim_info = priv->dim_info + d;
    if (!gwy_set_member_object(view, format, GWY_TYPE_VALUE_FORMAT,
                               &dim_info->vf,
                               "notify", format_notify,
                               &dim_info->vf_notify_id,
                               G_CONNECT_SWAPPED,
                               NULL))
        return;

    gboolean title_changed = FALSE;
    if (!format && dim_info->units) {
        GWY_FREE(dim_info->units);
        title_changed = TRUE;
    }
    else if (format) {
       const gchar *units = gwy_value_format_get_units(format);
       if (!dim_info->units) {
           dim_info->units = g_strdup(units);
           title_changed = TRUE;
       }
       else if (dim_info->units && !gwy_strequal(dim_info->units, units)) {
           GWY_FREE(dim_info->units);
           dim_info->units = g_strdup(units);
           title_changed = TRUE;
       }
    }

    if (title_changed)
        recalc_column_titles_for_dim(view, d);

    // Is this sufficient to re-render the cells?
    gtk_widget_queue_draw(GTK_WIDGET(view));
}
コード例 #4
0
ファイル: module.c プロジェクト: svn2github/gwyddion
static void
close_module(GModule *mod, const gchar *filename)
{
    gchar *modfilename = NULL;

    // We cannot get the file name after we close the module, even
    // unsuccessfull, because it may be freed.
    if (!filename) {
        modfilename = g_strdup(g_module_name(mod));
        filename = modfilename;
    }

    if (g_module_close(mod)) {
        GWY_FREE(modfilename);
        return;
    }

    g_warning("Cannot close module ‘%s’: %s", filename, g_module_error());
    GWY_FREE(modfilename);
}
コード例 #5
0
ファイル: coords-view.c プロジェクト: svn2github/gwyddion
static void
column_gone(gpointer data,
            GObject *where_the_object_was)
{
    GwyCoordsView *view = (GwyCoordsView*)data;
    CoordsView *priv = view->priv;
    GSList *l = find_column_info(view,
                                 (GtkTreeViewColumn*)where_the_object_was);
    g_return_if_fail(l);
    priv->column_info = g_slist_remove_link(priv->column_info, l);

    ColumnInfo *column_info = (ColumnInfo*)l->data;
    column_info->column = NULL;
    GWY_FREE(column_info->title);
    g_slist_free1(l);
}
コード例 #6
0
ファイル: coords-view.c プロジェクト: svn2github/gwyddion
static void
free_dim_info(GwyCoordsView *view)
{
    CoordsView *priv = view->priv;
    if (!priv->dim_info)
        return;

    guint dimension = priv->coords_class->dimension;
    for (guint i = 0; i < dimension; i++) {
        DimInfo *info = priv->dim_info + i;
        GWY_SIGNAL_HANDLER_DISCONNECT(info->vf, info->vf_notify_id);
        GWY_OBJECT_UNREF(info->vf);
        GWY_FREE(info->units);
    }
    g_slice_free1(dimension*sizeof(DimInfo), priv->dim_info);
    priv->dim_info = NULL;
    g_type_class_unref(priv->coords_class);
}
コード例 #7
0
ファイル: surface.c プロジェクト: cbuehler/gwyddion
static void
free_data(GwySurface *surface)
{
    GWY_FREE(surface->data);
}