void gwy_remote_free(GwyRemote *remote) { if (!remote) return; gwy_object_unref(remote->display); gwy_object_unref(remote->toolbox); g_free(remote); }
static void gwy_vector_layer_destroy(GtkObject *object) { GwyVectorLayer *layer; layer = GWY_VECTOR_LAYER(object); gwy_object_unref(layer->gc); gwy_object_unref(layer->layout); GTK_OBJECT_CLASS(gwy_vector_layer_parent_class)->destroy(object); }
static void gwy_data_view_unrealize(GtkWidget *widget) { GwyDataView *data_view = GWY_DATA_VIEW(widget); gwy_object_unref(data_view->pixbuf); gwy_object_unref(data_view->base_pixbuf); if (GTK_WIDGET_CLASS(parent_class)->unrealize) GTK_WIDGET_CLASS(parent_class)->unrealize(widget); }
/** * gwy_data_field_correlate_finalize: * @state: Correlation iterator. * * Destroys a correlation iterator, freeing all resources. **/ void gwy_data_field_correlate_finalize(GwyComputationState *cstate) { GwyCorrelationState *state = (GwyCorrelationState*)cstate; gwy_object_unref(state->data_field); gwy_object_unref(state->kernel_field); gwy_object_unref(state->score); gwy_object_unref(state->avg); gwy_object_unref(state->rms); g_free(state); }
/** * gwy_data_field_crosscorrelate_finalize: * @state: Cross-correlation iterator. * * Destroys a cross-correlation iterator, freeing all resources. **/ void gwy_data_field_crosscorrelate_finalize(GwyComputationState *cstate) { GwyCrossCorrelationState *state = (GwyCrossCorrelationState*)cstate; gwy_object_unref(state->data_field1); gwy_object_unref(state->data_field2); gwy_object_unref(state->x_dist); gwy_object_unref(state->y_dist); gwy_object_unref(state->score); g_free(state); }
static void gwy_color_axis_finalize(GObject *object) { GwyColorAxis *axis; gwy_debug(""); axis = (GwyColorAxis*)object; gwy_object_unref(axis->palette); gwy_object_unref(axis->pixbuf); g_object_unref(axis->siunit); g_object_unref(axis->gradient); G_OBJECT_CLASS(parent_class)->finalize(object); }
/** * gwy_graph_label_set_model: * @label: A graph label. * @gmodel: New graph model. * * Sets new model of a graph label. **/ void gwy_graph_label_set_model(GwyGraphLabel *label, GwyGraphModel *gmodel) { g_return_if_fail(GWY_IS_GRAPH_LABEL(label)); g_return_if_fail(!gmodel || GWY_IS_GRAPH_MODEL(gmodel)); if (label->graph_model == gmodel) return; gwy_signal_handler_disconnect(label->graph_model, label->model_notify_id); gwy_signal_handler_disconnect(label->graph_model, label->curve_notify_id); if (gmodel) g_object_ref(gmodel); gwy_object_unref(label->graph_model); label->graph_model = gmodel; if (gmodel) { label->model_notify_id = g_signal_connect_swapped(gmodel, "notify", G_CALLBACK(gwy_graph_label_model_notify), label); label->curve_notify_id = g_signal_connect_swapped(gmodel, "curve-notify", G_CALLBACK(gwy_graph_label_curve_notify), label); } gwy_graph_label_refresh_all(label); gwy_graph_label_refresh_visible(label); }
static void gwy_vector_layer_finalize(GObject *object) { GwyVectorLayer *layer; gwy_debug(" "); g_return_if_fail(GWY_IS_VECTOR_LAYER(object)); layer = GWY_VECTOR_LAYER(object); gwy_object_unref(layer->gc); gwy_object_unref(layer->layout); G_OBJECT_CLASS(parent_class)->finalize(object); }
/** * gwy_layer_basic_show_field_disconnect: * @basic_layer: A basic layer. * * Disconnects from all data field's signals and drops reference to it. **/ static void gwy_layer_basic_show_field_disconnect(GwyLayerBasic *basic_layer) { gwy_signal_handler_disconnect(basic_layer->show_field, basic_layer->show_id); gwy_object_unref(basic_layer->show_field); }
/** * gwy_app_recent_file_list_free: * * Frees all memory taken by recent file list. * * Should not be called while the recent file menu still exists. **/ void gwy_app_recent_file_list_free(void) { GtkTreeIter iter; GwyRecentFile *rf; if (!gcontrols.store) return; if (gcontrols.window) gtk_widget_destroy(gcontrols.window); if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(gcontrols.store), &iter)) { do { gtk_tree_model_get(GTK_TREE_MODEL(gcontrols.store), &iter, FILELIST_RAW, &rf, -1); gwy_app_recent_file_free(rf); } while (gtk_list_store_remove(gcontrols.store, &iter)); } gwy_object_unref(gcontrols.store); if (gcontrols.glob) { g_string_free(gcontrols.glob, TRUE); gcontrols.glob = NULL; } g_list_free(gcontrols.recent_file_list); gcontrols.recent_file_list = NULL; gwy_app_recent_file_list_update_menu(&gcontrols); }
static void gwy_layer_basic_finalize(GObject *object) { gwy_debug(" "); gwy_object_unref(GWY_LAYER_BASIC(object)->gradient); G_OBJECT_CLASS(parent_class)->finalize(object); }
static void gwy_data_view_finalize(GObject *object) { GwyDataView *data_view; gwy_debug("finalizing a GwyDataView (refcount = %u)", object->ref_count); g_return_if_fail(GWY_IS_DATA_VIEW(object)); data_view = GWY_DATA_VIEW(object); gwy_object_unref(data_view->base_layer); gwy_object_unref(data_view->alpha_layer); gwy_object_unref(data_view->top_layer); gwy_debug(" child data ref count %d", G_OBJECT(data_view->data)->ref_count); gwy_object_unref(data_view->data); G_OBJECT_CLASS(parent_class)->finalize(object); }
static void gwy_graph_data_destroy(GtkObject *object) { GwyGraphData *graph_data; graph_data = GWY_GRAPH_DATA(object); gwy_graph_data_set_model(graph_data, NULL); gwy_object_unref(graph_data->store); GTK_OBJECT_CLASS(gwy_graph_data_parent_class)->destroy(object); }
static void gwy_app_recent_file_free(GwyRecentFile *rf) { gwy_object_unref(rf->pixbuf); g_free(rf->file_utf8_lc); g_free(rf->file_utf8); g_free(rf->file_sys); g_free(rf->file_uri); g_free(rf->thumb_sys); g_free(rf->image_real_size); g_free(rf); }
static GwyDataField* read_text_data(const gchar *buffer, gint text_data_start, GHashTable *hash, GError **error) { const gchar *p; gchar *end; gint xres, yres, i, power10; gdouble xreal, yreal, zscale, xoff, yoff, zoff; GwySIUnit *unitxy, *unitz; GwyDataField *dfield = NULL; gdouble *d; unitxy = gwy_si_unit_new(NULL); unitz = gwy_si_unit_new(NULL); if (!get_scales(hash, TRUE, &xres, &yres, &xreal, &yreal, &xoff, &yoff, unitxy, &zscale, &zoff, unitz, error)) goto fail; p = g_hash_table_lookup(hash, "DATA Unit"); gwy_si_unit_set_from_string_parse(unitz, p, &power10); zscale = pow10(power10); dfield = gwy_data_field_new(xres, yres, xreal, yreal, FALSE); gwy_data_field_set_xoffset(dfield, xoff); gwy_data_field_set_yoffset(dfield, yoff); gwy_data_field_set_si_unit_xy(dfield, unitxy); gwy_data_field_set_si_unit_z(dfield, unitz); d = gwy_data_field_get_data(dfield); p = (const gchar*)buffer + text_data_start; for (i = 0; i < xres*yres; i++) { d[i] = zscale*g_ascii_strtod(p, &end) + zoff; if (end == p) { g_set_error(error, GWY_MODULE_FILE_ERROR, GWY_MODULE_FILE_ERROR_DATA, _("Cannot parse data values after %d of %d."), i, xres*yres); gwy_object_unref(dfield); goto fail; } p = end + (*end == ','); } fail: g_object_unref(unitxy); g_object_unref(unitz); return dfield; }
static void gwy_layer_basic_unplugged(GwyDataViewLayer *layer) { GwyPixmapLayer *pixmap_layer; GwyLayerBasic *basic_layer; g_return_if_fail(GWY_IS_LAYER_BASIC(layer)); pixmap_layer = GWY_PIXMAP_LAYER(layer); basic_layer = GWY_LAYER_BASIC(layer); gwy_object_unref(pixmap_layer->pixbuf); GWY_DATA_VIEW_LAYER_CLASS(parent_class)->unplugged(layer); }
/** * gwy_graph_window_class_set_tooltips: * @tips: #GtkTooltips object #GwyGraphWindow should use for setting tooltips. * A %NULL value disables tooltips altogether. * * Sets the tooltips object to use for adding tooltips to graph window parts. * * This is a class method. It affects only newly created graph windows, * existing graph windows will continue to use the tooltips they were * constructed with. * * If no class tooltips object is set before first #GwyGraphWindow is created, * the class instantiates one on its own. You can normally obtain it with * gwy_graph_window_class_get_tooltips() then. The class takes a reference on * the tooltips in either case. **/ void gwy_graph_window_class_set_tooltips(GtkTooltips *tips) { g_return_if_fail(!tips || GTK_IS_TOOLTIPS(tips)); if (tips) { g_object_ref(tips); gtk_object_sink(GTK_OBJECT(tips)); } gwy_object_unref(tooltips); tooltips = tips; tooltips_set = TRUE; }
/** * gwy_spectra_set_si_unit_xy: * @spectra: A Spectra object. * @si_unit: SI unit to be set. * * Sets the SI unit corresponding to the location co-ordinates of the spectra * object. * * It does not assume a reference on @si_unit, instead it adds its own * reference. * * Since: 2.7 **/ void gwy_spectra_set_si_unit_xy(GwySpectra *spectra, GwySIUnit *si_unit) { g_return_if_fail(GWY_IS_SPECTRA(spectra)); g_return_if_fail(GWY_IS_SI_UNIT(si_unit)); if (spectra->si_unit_xy == si_unit) return; gwy_object_unref(spectra->si_unit_xy); g_object_ref(si_unit); spectra->si_unit_xy = si_unit; }
static void gwy_vector_layer_unplugged(GwyDataViewLayer *layer) { GwyVectorLayer *vector_layer; gwy_debug(" "); vector_layer = GWY_VECTOR_LAYER(layer); gwy_object_unref(vector_layer->gc); if (vector_layer->timer) { gtk_timeout_remove(vector_layer->timer); vector_layer->timer = 0; } g_signal_handlers_disconnect_matched(layer->parent, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, gwy_vector_layer_update_context, layer); gwy_object_unref(vector_layer->layout); GWY_DATA_VIEW_LAYER_CLASS(parent_class)->unplugged(layer); }
static void gwy_spectra_finalize(GObject *object) { GwySpectra *spectra = (GwySpectra*)object; guint i; gwy_debug(""); gwy_object_unref(spectra->si_unit_xy); for (i = 0; i < spectra->spectra->len; i++) { GwySpectrum *spec = &g_array_index(spectra->spectra, GwySpectrum, i); gwy_object_unref(spec->ydata); } g_array_free(spectra->spectra, TRUE); spectra->spectra = NULL; g_free(spectra->title); g_free(spectra->spec_xlabel); g_free(spectra->spec_ylabel); G_OBJECT_CLASS(gwy_spectra_parent_class)->finalize(object); }
static void gwy_color_axis_adjust(GwyColorAxis *axis, gint width, gint height) { gint i, j, rowstride, palsize, dval; guchar *pixels, *line; const guchar *samples, *s; gdouble cor; gwy_debug(""); gwy_object_unref(axis->pixbuf); axis->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height); gwy_debug_objects_creation(G_OBJECT(axis->pixbuf)); /*render pixbuf according to orientation*/ pixels = gdk_pixbuf_get_pixels(axis->pixbuf); rowstride = gdk_pixbuf_get_rowstride(axis->pixbuf); samples = gwy_gradient_get_samples(axis->gradient, &palsize); if (axis->orientation == GTK_ORIENTATION_VERTICAL) { cor = (palsize-1.0)/height; for (i = 0; i < height; i++) { line = pixels + i*rowstride; dval = (gint)((height-i-1)*cor + 0.5); for (j = 0; j < width*height; j += height) { s = samples + 4*dval; *(line++) = *(s++); *(line++) = *(s++); *(line++) = *s; } } } if (axis->orientation == GTK_ORIENTATION_HORIZONTAL) { cor = (palsize-1.0)/width; for (i = 0; i < height; i++) { line = pixels + i*rowstride; for (j = 0; j < width*height; j += height) { dval = (gint)((j/height)*cor + 0.5); s = samples + 4*dval; *(line++) = *(s++); *(line++) = *(s++); *(line++) = *s; } } } }
static void gwy_data_view_make_pixmap(GwyDataView *data_view) { GtkWidget *widget; GwyDataField *data_field; gint width, height, scwidth, scheight, src_width, src_height; data_field = GWY_DATA_FIELD( gwy_container_get_object_by_name(data_view->data, "/0/data")); src_width = gwy_data_field_get_xres(data_field); src_height = gwy_data_field_get_yres(data_field); if (!data_view->base_pixbuf) { data_view->base_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, BITS_PER_SAMPLE, src_width, src_height); gwy_debug_objects_creation(G_OBJECT(data_view->base_pixbuf)); } if (data_view->pixbuf) { width = gdk_pixbuf_get_width(data_view->pixbuf); height = gdk_pixbuf_get_height(data_view->pixbuf); } else width = height = -1; widget = GTK_WIDGET(data_view); data_view->zoom = MIN((gdouble)widget->allocation.width/src_width, (gdouble)widget->allocation.height/src_height); data_view->newzoom = data_view->zoom; scwidth = floor(src_width * data_view->zoom + 0.000001); scheight = floor(src_height * data_view->zoom + 0.000001); data_view->xmeasure = gwy_data_field_get_xreal(data_field)/scwidth; data_view->ymeasure = gwy_data_field_get_yreal(data_field)/scheight; data_view->xoff = (widget->allocation.width - scwidth)/2; data_view->yoff = (widget->allocation.height - scheight)/2; if (scwidth != width || scheight != height) { gwy_object_unref(data_view->pixbuf); data_view->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, BITS_PER_SAMPLE, scwidth, scheight); gwy_debug_objects_creation(G_OBJECT(data_view->pixbuf)); gdk_pixbuf_fill(data_view->pixbuf, 0x00000000); gwy_data_view_paint(data_view); } }
static void gwy_pixmap_layer_finalize(GObject *object) { GwyPixmapLayer *layer; gwy_debug(""); g_return_if_fail(GWY_IS_PIXMAP_LAYER(object)); layer = GWY_PIXMAP_LAYER(object); gwy_object_unref(layer->pixbuf); G_OBJECT_CLASS(parent_class)->finalize(object); }
static void gwy_graph_label_finalize(GObject *object) { GwyGraphLabel *label; label = GWY_GRAPH_LABEL(object); gwy_signal_handler_disconnect(label->graph_model, label->model_notify_id); gwy_signal_handler_disconnect(label->graph_model, label->curve_notify_id); gwy_object_unref(label->graph_model); pango_font_description_free(label->font_desc); g_array_free(label->samplepos, TRUE); G_OBJECT_CLASS(gwy_graph_label_parent_class)->finalize(object); }
static void gwy_app_file_chooser_free_preview(GwyAppFileChooser *chooser) { if (chooser->full_preview_id) { g_source_remove(chooser->full_preview_id); chooser->full_preview_id = 0; } if (chooser->preview_name_sys) { gwy_debug("freeing preview of <%s>", chooser->preview_name_sys); } g_free(chooser->preview_name_sys); chooser->preview_name_sys = NULL; gwy_object_unref(chooser->preview_data); }
void gwy_color_axis_set_si_unit(GwyColorAxis *axis, GwySIUnit *unit) { GwySIUnit *old; g_return_if_fail(GWY_IS_COLOR_AXIS(axis)); g_return_if_fail(GWY_IS_SI_UNIT(unit)); if (axis->siunit == unit) return; old = axis->siunit; g_object_ref(unit); axis->siunit = unit; gwy_object_unref(old); }
static void gwy_spectra_clone_real(GObject *source, GObject *copy) { GwySpectra *spectra, *clone; GwyDataLine *dataline; guint i; g_return_if_fail(GWY_IS_SPECTRA(source)); g_return_if_fail(GWY_IS_SPECTRA(copy)); spectra = GWY_SPECTRA(source); clone = GWY_SPECTRA(copy); /* Title */ g_free(clone->title); clone->title = g_strdup(spectra->title); /* Remove any existing datalines in the clone */ for (i = 0; i < clone->spectra->len; i++) { g_object_unref(g_array_index(clone->spectra, GwySpectrum, i).ydata); } /* Copy the spectra to clone */ g_array_set_size(clone->spectra, 0); g_array_append_vals(clone->spectra, spectra->spectra->data, spectra->spectra->len); /* Clone the spectra theselves */ for (i = 0; i < spectra->spectra->len; i++) { dataline = g_array_index(clone->spectra, GwySpectrum, i).ydata; g_array_index(clone->spectra, GwySpectrum, i).ydata = gwy_data_line_duplicate(dataline); } /* SI Units can be NULL */ if (spectra->si_unit_xy && clone->si_unit_xy) gwy_serializable_clone(G_OBJECT(spectra->si_unit_xy), G_OBJECT(clone->si_unit_xy)); else if (spectra->si_unit_xy && !clone->si_unit_xy) clone->si_unit_xy = gwy_si_unit_duplicate(spectra->si_unit_xy); else if (!spectra->si_unit_xy && clone->si_unit_xy) gwy_object_unref(clone->si_unit_xy); }
static GwySelection* gwyfile_gather_old_line_selection(GwyContainer *data) { GwySelection *sel; GType type; gint i, nselected; gdouble xy[4]; gchar key[40]; type = g_type_from_name("GwySelectionLine"); if (!type || !gwy_container_gis_int32_by_name(data, "/0/select/lines/nselected", &nselected)) return NULL; nselected = CLAMP(nselected, 0, 16); if (!nselected) return NULL; sel = GWY_SELECTION(g_object_new(type, "max-objects", nselected, NULL)); for (i = 0; i < nselected; i++) { g_snprintf(key, sizeof(key), "/0/select/lines/%d/x0", i); if (!gwy_container_gis_double_by_name(data, key, &xy[0])) break; g_snprintf(key, sizeof(key), "/0/select/lines/%d/y0", i); if (!gwy_container_gis_double_by_name(data, key, &xy[1])) break; g_snprintf(key, sizeof(key), "/0/select/lines/%d/x1", i); if (!gwy_container_gis_double_by_name(data, key, &xy[2])) break; g_snprintf(key, sizeof(key), "/0/select/lines/%d/y1", i); if (!gwy_container_gis_double_by_name(data, key, &xy[3])) break; gwy_selection_set_object(sel, i, xy); } if (!i) gwy_object_unref(sel); return sel; }
static void gwy_layer_basic_unplugged(GwyDataViewLayer *layer) { GwyPixmapLayer *pixmap_layer; GwyLayerBasic *basic_layer; pixmap_layer = GWY_PIXMAP_LAYER(layer); basic_layer = GWY_LAYER_BASIC(layer); gwy_debug("disconnecting all handlers"); gwy_layer_basic_disconnect_fixed(basic_layer); gwy_signal_handler_disconnect(layer->data, basic_layer->range_type_id); gwy_signal_handler_disconnect(layer->data, basic_layer->gradient_item_id); gwy_layer_basic_gradient_disconnect(basic_layer); gwy_signal_handler_disconnect(layer->data, basic_layer->show_item_id); gwy_layer_basic_show_field_disconnect(basic_layer); gwy_object_unref(pixmap_layer->pixbuf); GWY_DATA_VIEW_LAYER_CLASS(gwy_layer_basic_parent_class)->unplugged(layer); }
/** * gwy_graph_data_set_model: * @graph_data: A graph data widget. * @gmodel: New graph_data model. * * Changes the graph model a graph data table displays. **/ void gwy_graph_data_set_model(GwyGraphData *graph_data, GwyGraphModel *gmodel) { g_return_if_fail(GWY_IS_GRAPH_DATA(graph_data)); g_return_if_fail(!gmodel || GWY_IS_GRAPH_MODEL(gmodel)); gwy_signal_handler_disconnect(graph_data->graph_model, graph_data->notify_id); gwy_object_unref(graph_data->graph_model); gwy_debug("setting model to: %p", gmodel); graph_data->graph_model = gmodel; if (gmodel) { g_object_ref(gmodel); graph_data->notify_id = g_signal_connect_swapped(gmodel, "notify", G_CALLBACK(gwy_graph_data_model_notify), graph_data); } gwy_graph_data_update_ncurves(graph_data); }