/** * gwy_graph_func_register: * @name: Name of function to register. It should be a valid identifier and * if a module registers only one function, module and function names * should be the same. * @func: The function itself. * @menu_path: Menu path under Graph menu. The menu path should be * marked translatabe, but passed untranslated (to allow merging * of translated and untranslated submenus). * @stock_id: Stock icon id for toolbar. * @sens_mask: Sensitivity mask (a combination of #GwyMenuSensFlags flags). * Usually it is equal to #GWY_MENU_FLAG_GRAPH, but it's * possible to set other requirements. * @tooltip: Tooltip for this function. * * Registers a graph function. * * Note: the string arguments are not copied as modules are not expected to * vanish. If they are constructed (non-constant) strings, do not free them. * Should modules ever become unloadable they will get chance to clean-up. * * Returns: Normally %TRUE; %FALSE on failure. **/ gboolean gwy_graph_func_register(const gchar *name, GwyGraphFunc func, const gchar *menu_path, const gchar *stock_id, guint sens_mask, const gchar *tooltip) { GwyGraphFuncInfo *func_info; g_return_val_if_fail(name, FALSE); g_return_val_if_fail(func, FALSE); g_return_val_if_fail(menu_path, FALSE); gwy_debug("name = %s, menu path = %s, func = %p", name, menu_path, func); if (!graph_funcs) { gwy_debug("initializing..."); graph_funcs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); call_stack = g_ptr_array_new(); } if (!gwy_strisident(name, "_-", NULL)) g_warning("Function name `%s' is not a valid identifier. " "It may be rejected in future.", name); if (g_hash_table_lookup(graph_funcs, name)) { g_warning("Duplicate function %s, keeping only first", name); return FALSE; } func_info = g_new0(GwyGraphFuncInfo, 1); func_info->name = name; func_info->func = func; func_info->menu_path = menu_path; func_info->stock_id = stock_id; func_info->tooltip = tooltip; func_info->sens_mask = sens_mask; g_hash_table_insert(graph_funcs, (gpointer)func_info->name, func_info); if (!_gwy_module_add_registered_function(GWY_MODULE_PREFIX_GRAPH, name)) { g_hash_table_remove(graph_funcs, func_info->name); return FALSE; } return TRUE; }
static void pygwy_plugin_run(GwyContainer *data, GwyRunType run, const gchar *name) { PygwyPluginInfo *info; PyThreadState* py_thread_state = NULL; FILE *pyfile; if (!(info = pygwy_find_plugin(name))) { g_warning("cannot find plugin."); return; } /* open script file */ pyfile = fopen(info->filename, "r"); if (!pyfile) { g_warning("Cannot find pygwy script file '%s'", info->filename); return; } /* Initialize the Python interpreter. Required. */ if (!Py_IsInitialized()) { gwy_debug("Initializing Python interpreter" ); // Do not register signal handlers Py_InitializeEx(0); gwy_debug("Initializing Pygwy classes."); initpygwy(data); } else { gwy_debug("Python interpreter already initialized"); } /* initialize module class */ gwy_debug("Running plugin '%s', filename '%s'", info->name, info->filename); py_thread_state = Py_NewInterpreter(); initpygwy(data); /* Run pyfile */ PyRun_AnyFile(pyfile, info->filename); gwy_debug("Clear interpreter"); /* Cleaning interpreter */ Py_EndInterpreter(py_thread_state); // Py_Finalize(); fclose(pyfile); }
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 gboolean gwy_graph_label_dialog_delete(GtkWidget *widget, G_GNUC_UNUSED GdkEventAny *event) { gwy_debug(""); gtk_widget_hide(widget); return TRUE; }
static void gwy_graph_curve_model_serializable_init(GwySerializableIface *iface) { gwy_debug(""); /* initialize stuff */ iface->serialize = gwy_graph_curve_model_serialize; iface->deserialize = gwy_graph_curve_model_deserialize; iface->duplicate = gwy_graph_curve_model_duplicate; }
static inline guchar gwy_serialize_unpack_char(const guchar *buffer, gsize size, gsize *position) { guchar value; gwy_debug("buf = %p, size = %" G_GSIZE_FORMAT ", pos = %" G_GSIZE_FORMAT, buffer, size, *position); g_assert(buffer); g_assert(position); g_return_val_if_fail(*position + sizeof(guchar) <= size, '\0'); value = buffer[*position]; *position += sizeof(guchar); gwy_debug("value = <%c>", value); return value; }
/** Low-level deserialization functions for 1.x file import {{{ **/ static inline gboolean gwy_serialize_unpack_boolean(const guchar *buffer, gsize size, gsize *position) { gboolean value; gwy_debug("buf = %p, size = %" G_GSIZE_FORMAT ", pos = %" G_GSIZE_FORMAT, buffer, size, *position); g_assert(buffer); g_assert(position); g_return_val_if_fail(*position + sizeof(guchar) <= size, FALSE); value = !!buffer[*position]; *position += sizeof(guchar); gwy_debug("value = <%s>", value ? "TRUE" : "FALSE"); return value; }
static guchar* x3p_get_file_content(unzFile *zipfile, gsize *contentsize, GError **error) { unz_file_info fileinfo; guchar *buffer; gulong size; glong readbytes; gint status; gwy_debug("calling unzGetCurrentFileInfo() to figure out buffer size"); status = unzGetCurrentFileInfo(zipfile, &fileinfo, NULL, 0, NULL, 0, NULL, 0); if (status != UNZ_OK) { err_MINIZIP(status, error); return NULL; } gwy_debug("calling unzGetCurrentFileInfo()"); status = unzOpenCurrentFile(zipfile); if (status != UNZ_OK) { err_MINIZIP(status, error); return NULL; } size = fileinfo.uncompressed_size; buffer = g_new(guchar, size + 1); gwy_debug("calling unzReadCurrentFile()"); readbytes = unzReadCurrentFile(zipfile, buffer, size); if (readbytes != size) { err_MINIZIP(status, error); unzCloseCurrentFile(zipfile); g_free(buffer); return NULL; } gwy_debug("calling unzCloseCurrentFile()"); unzCloseCurrentFile(zipfile); buffer[size] = '\0'; if (contentsize) *contentsize = size; return buffer; }
/** * gwy_tool_func_register: * @modname: Module identifier (name). * @func_info: Tool use function info. * * Registeres a tool use function. * * To keep compatibility with old versions @func_info should not be an * automatic variable. However, since 1.6 it keeps a copy of @func_info. * * Returns: %TRUE on success, %FALSE on failure. **/ gboolean gwy_tool_func_register(const gchar *modname, GwyToolFuncInfo *func_info) { _GwyModuleInfoInternal *iinfo; GwyToolFuncInfo *tfinfo; gchar *canon_name; gwy_debug(""); gwy_debug("name = %s, stock id = %s, func = %p", func_info->name, func_info->stock_id, func_info->use); if (!tool_funcs) { gwy_debug("Initializing..."); tool_funcs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, gwy_tool_func_info_free); } iinfo = gwy_module_get_module_info(modname); g_return_val_if_fail(iinfo, FALSE); g_return_val_if_fail(func_info->use, FALSE); g_return_val_if_fail(func_info->name, FALSE); g_return_val_if_fail(func_info->stock_id, FALSE); g_return_val_if_fail(func_info->tooltip, FALSE); if (g_hash_table_lookup(tool_funcs, func_info->name)) { g_warning("Duplicate function %s, keeping only first", func_info->name); return FALSE; } tfinfo = g_memdup(func_info, sizeof(GwyToolFuncInfo)); tfinfo->name = g_strdup(func_info->name); tfinfo->stock_id = g_strdup(func_info->stock_id); /* FIXME: This is not very clean. But we need the translated string often, * namely in menu building code. */ tfinfo->tooltip = g_strdup(_(func_info->tooltip)); g_hash_table_insert(tool_funcs, (gpointer)tfinfo->name, tfinfo); canon_name = g_strconcat(GWY_MODULE_PREFIX_TOOL, tfinfo->name, NULL); iinfo->funcs = g_slist_append(iinfo->funcs, canon_name); if (func_register_callback) func_register_callback(canon_name); return TRUE; }
static void gwy_color_axis_realize(GtkWidget *widget) { GwyColorAxis *axis; GdkWindowAttr attributes; gint attributes_mask; GtkStyle *s; gwy_debug(""); g_return_if_fail(widget != NULL); g_return_if_fail(GWY_IS_COLOR_AXIS(widget)); GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); axis = GWY_COLOR_AXIS(widget); attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK; attributes.visual = gtk_widget_get_visual(widget); attributes.colormap = gtk_widget_get_colormap(widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); gdk_window_set_user_data(widget->window, widget); widget->style = gtk_style_attach(widget->style, widget->window); /*set backgroun for white forever*/ s = gtk_style_copy(widget->style); s->bg_gc[0] = s->bg_gc[1] = s->bg_gc[2] = s->bg_gc[3] = s->bg_gc[4] = widget->style->white_gc; s->bg[0] = s->bg[1] = s->bg[2] = s->bg[3] = s->bg[4] = widget->style->white; gtk_style_set_background(s, widget->window, GTK_STATE_NORMAL); /*compute axis*/ gwy_color_axis_update(axis); }
/** * gwy_graph_func_register: * @modname: Module identifier (name). * @func_info: Data graphing function info. * * Registeres a data graphing function. * * To keep compatibility with old versions @func_info should not be an * automatic variable. However, since 1.6 it keeps a copy of @func_info. * * Returns: %TRUE on success, %FALSE on failure. **/ gboolean gwy_graph_func_register(const gchar *modname, GwyGraphFuncInfo *func_info) { _GwyModuleInfoInternal *iinfo; GraphFuncInfo *gfinfo; gchar *canon_name; gwy_debug(""); gwy_debug("name = %s, menu path = %s, func = %p", func_info->name, func_info->menu_path, func_info->graph); if (!graph_funcs) { gwy_debug("Initializing..."); graph_funcs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, gwy_graph_func_info_free); } iinfo = gwy_module_get_module_info(modname); g_return_val_if_fail(iinfo, FALSE); g_return_val_if_fail(func_info->graph, FALSE); g_return_val_if_fail(func_info->name, FALSE); if (g_hash_table_lookup(graph_funcs, func_info->name)) { g_warning("Duplicate function %s, keeping only first", func_info->name); return FALSE; } gfinfo = g_new0(GraphFuncInfo, 1); gfinfo->info = *func_info; gfinfo->info.name = g_strdup(func_info->name); gfinfo->info.menu_path = g_strdup(func_info->menu_path); gfinfo->menu_path_translated = _(func_info->menu_path); gfinfo->menu_path_factory = gwy_strkill(g_strdup(gfinfo->menu_path_translated), "_"); g_hash_table_insert(graph_funcs, (gpointer)gfinfo->info.name, gfinfo); canon_name = g_strconcat(GWY_MODULE_PREFIX_GRAPH, gfinfo->info.name, NULL); iinfo->funcs = g_slist_append(iinfo->funcs, canon_name); if (func_register_callback) func_register_callback(canon_name); return TRUE; }
static void gwy_spectra_serializable_init(GwySerializableIface *iface) { gwy_debug(""); iface->serialize = gwy_spectra_serialize; iface->deserialize = gwy_spectra_deserialize; iface->get_size = gwy_spectra_get_size; iface->duplicate = gwy_spectra_duplicate_real; iface->clone = gwy_spectra_clone_real; }
/** * gwy_spectra_new: * * Creates a new Spectra object containing zero spectra. * * Returns: A newly created spectra. * * Since: 2.7 **/ GwySpectra* gwy_spectra_new(void) { GwySpectra *spectra; gwy_debug(""); spectra = g_object_new(GWY_TYPE_SPECTRA, NULL); return spectra; }
static inline gint64 gwy_serialize_unpack_int64(const guchar *buffer, gsize size, gsize *position) { gint64 value; gwy_debug("buf = %p, size = %" G_GSIZE_FORMAT ", pos = %" G_GSIZE_FORMAT, buffer, size, *position); g_assert(buffer); g_assert(position); g_return_val_if_fail(*position + sizeof(gint64) <= size, 0); memcpy(&value, buffer + *position, sizeof(gint64)); value = GINT64_FROM_LE(value); *position += sizeof(gint64); gwy_debug("value = <%lld>", value); return value; }
static void gwy_process_import_fftw_wisdom(void) { #ifdef HAVE_FFTW3 G_GNUC_UNUSED gboolean ok; ok = fftw_import_system_wisdom(); gwy_debug("FFTW3 system wisdom imported: %d", ok); #endif }
static GPtrArray* read_channel_labels(const gchar *p, guint n, guint l) { GPtrArray *array = g_ptr_array_sized_new(n); guint i; for (i = 0; i < l; i++) { g_ptr_array_add(array, g_strndup(p + i*(MAX_WAVE_NAME5 + 1), MAX_WAVE_NAME5)); gwy_debug("label%u=%s", i, (gchar*)g_ptr_array_index(array, i)); } for (i = l; i < n; i++) { g_ptr_array_add(array, NULL); gwy_debug("label%u=NULL", i); }; return array; }
static void gwy_app_recent_file_create_dirs(void) { const gchar *base; gchar *dir; base = gwy_recent_file_thumbnail_dir(); if (!g_file_test(base, G_FILE_TEST_IS_DIR)) { gwy_debug("Creating base thumbnail directory <%s>", base); g_mkdir(base, 0700); } dir = g_build_filename(base, "normal", NULL); if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) { gwy_debug("Creating normal thumbnail directory <%s>", dir); g_mkdir(dir, 0700); } g_free(dir); }
gboolean gwy_tool_func_remove(const gchar *name) { gwy_debug("%s", name); if (!g_hash_table_remove(tool_funcs, name)) { g_warning("Cannot remove function %s", name); return FALSE; } return TRUE; }
static void gwy_app_file_chooser_update_preview(GwyAppFileChooser *chooser) { GtkFileChooser *fchooser; GtkTreeModel *model; GdkPixbuf *pixbuf; GtkTreeIter iter; gchar *filename_sys; gwy_app_file_chooser_free_preview(chooser); model = gtk_icon_view_get_model(GTK_ICON_VIEW(chooser->preview)); gtk_list_store_clear(GTK_LIST_STORE(model)); fchooser = GTK_FILE_CHOOSER(chooser); filename_sys = gtk_file_chooser_get_preview_filename(fchooser); /* It should be UTF-8, but don't convert it just for gwy_debug() */ gwy_debug("%s", filename_sys); /* Make directories fail gracefully */ if (filename_sys && g_file_test(filename_sys, G_FILE_TEST_IS_DIR)) { g_free(filename_sys); filename_sys = NULL; } /* Never set the preview inactive. Gtk+ can do all kinds of silly things * if you do. */ if (!filename_sys) return; pixbuf = _gwy_app_recent_file_try_thumbnail(filename_sys); g_free(filename_sys); if (!pixbuf) { pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); gdk_pixbuf_fill(pixbuf, 0x00000000); chooser->make_thumbnail = TRUE; } else chooser->make_thumbnail = FALSE; g_object_set(chooser->renderer_fileinfo, "ellipsize", PANGO_ELLIPSIZE_NONE, "wrap-width", TMS_NORMAL_THUMB_SIZE, NULL); gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter, -1, COLUMN_PIXBUF, pixbuf, COLUMN_FILEINFO, _("…"), -1); g_object_unref(pixbuf); chooser->full_preview_id = g_timeout_add_full(G_PRIORITY_LOW, 250, gwy_app_file_chooser_do_full_preview, chooser, NULL); }
static gboolean mif_read_image_configuration(MIFImageConfiguration *config, const guchar **p, gsize size, guint file_version, GError **error) { if (file_version >= 0x107 && file_version <= 0x109) { if (size < IMAGE_CONFIGURATION_SIZE_1_3) return err_IMAGE_HEADER_TOO_SHORT(error); config->scan_int_to_meter = gwy_get_gdouble_le(p); gwy_debug("scan_int_to_meter: %g", config->scan_int_to_meter); config->xcal = gwy_get_gdouble_le(p); config->ycal = gwy_get_gdouble_le(p); config->zcal = gwy_get_gdouble_le(p); gwy_debug("calibration: %g %g %g", config->xcal, config->ycal, config->zcal); get_CHARARRAY(config->direction, p); gwy_debug_chars(config, direction); get_CHARARRAY(config->signal, p); gwy_debug_chars(config, signal); get_CHARARRAY(config->scan_head, p); gwy_debug_chars(config, scan_head); config->scan_head_code = *((*p)++); get_CHARARRAY(config->scan_mode, p); gwy_debug_chars(config, scan_mode); config->z_linearized = !!*((*p)++); gwy_debug_bool(config, z_linearized); config->z_correction = gwy_get_gfloat_le(p); gwy_debug("z_correction: %g", config->z_correction); config->is_zcorrected = !!*((*p)++); gwy_debug_bool(config, is_zcorrected); config->is_flattened = !!*((*p)++); gwy_debug_bool(config, is_flattened); get_CHARARRAY(config->scan_head_name, p); gwy_debug_chars(config, scan_head_name); } else { g_return_val_if_reached(FALSE); } return TRUE; }
static gboolean read_qt_string(const guchar **p, gsize *size, gchar **value) { const gunichar2 *utf16native; gunichar2 *must_free; guint len; *value = NULL; if (*size < sizeof(guint32)) return FALSE; len = gwy_get_guint32_be(p); *size -= sizeof(guint32); gwy_debug("QString length: %u", len); if (*size < len || len % sizeof(gunichar2)) return FALSE; if (!len) { *value = g_strdup(""); return TRUE; } if (G_BYTE_ORDER == G_BIG_ENDIAN) { utf16native = (const gunichar2*)(*p); must_free = NULL; } else if (G_BYTE_ORDER == G_LITTLE_ENDIAN) { utf16native = must_free = g_new(gunichar2, len/sizeof(gunichar2)); swab(*p, (gpointer)must_free, len); } *value = g_utf16_to_utf8(utf16native, len/sizeof(gunichar2), NULL, NULL, NULL); gwy_debug("QString data: <%s>", *value); g_free(must_free); *size -= len; *p += len; return TRUE; }
static gchar* oldmda_find_data_name(const gchar *headername, const gchar *dataname) { gchar *dirname = g_path_get_dirname(headername); gchar *data_name = g_path_get_basename(dataname); gchar *dname, *filename; filename = g_build_filename(dirname, data_name, NULL); gwy_debug("trying <%s>", filename); if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(dirname); return filename; } g_free(filename); dname = g_ascii_strup(data_name, -1); filename = g_build_filename(dirname, dname, NULL); gwy_debug("trying <%s>", filename); if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(dname); g_free(dirname); return filename; } g_free(dname); g_free(filename); dname = g_ascii_strdown(data_name, -1); filename = g_build_filename(dirname, dname, NULL); gwy_debug("trying <%s>", filename); if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(dname); g_free(dirname); return filename; } g_free(dname); g_free(filename); g_free(dirname); gwy_debug("failed"); return NULL; }
static gchar* hitachi_find_data_name(const gchar *header_name, const gchar *image_name) { gchar *dirname = g_path_get_dirname(header_name); gchar *filename, *iname; filename = g_build_filename(dirname, image_name, NULL); gwy_debug("trying <%s>", filename); if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(dirname); return filename; } g_free(filename); iname = g_ascii_strup(image_name, -1); filename = g_build_filename(dirname, iname, NULL); gwy_debug("trying <%s>", filename); if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(iname); g_free(dirname); return filename; } g_free(iname); g_free(filename); iname = g_ascii_strdown(image_name, -1); filename = g_build_filename(dirname, iname, NULL); gwy_debug("trying <%s>", filename); if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(iname); g_free(dirname); return filename; } g_free(iname); g_free(filename); g_free(dirname); gwy_debug("failed"); return NULL; }
static void gwy_vector_layer_init(GwyVectorLayer *layer) { gwy_debug(" "); layer->gc = NULL; layer->layout = NULL; layer->timer = 0; layer->update_policy = GTK_UPDATE_CONTINUOUS; layer->in_selection = FALSE; }
/** * gwy_tip_estimate_partial: * @tip: Tip data to be refined (allocated). * @surface: Surface data. * @threshold: Threshold for noise supression. * @use_edges: Whether use also edges of image. * @count: Where to store the number of places that produced refinements to. * @set_fraction: Function that sets fraction to output (or %NULL). * @set_message: Function that sets message to output (or %NULL). * * Performs partial blind estimation algorithm published by Villarrubia. This * function converts all fields into form requested by "morph_lib.c" library, * that is almost identical with original Villarubia's library. Note that the * threshold value must be chosen sufficently high value to supress small * fluctulations due to noise (that would lead to very sharp tip) but * sufficiently low value to put algorithm at work. A value similar to 1/10000 * of surface range can be good. Otherwise we recommend to start with zero * threshold and increase it slowly to observe changes and choose right value. * * Returns: Estimated tip. May return %NULL if aborted. **/ GwyDataField* gwy_tip_estimate_partial(GwyDataField *tip, GwyDataField *surface, gdouble threshold, gboolean use_edges, gint *count, GwySetFractionFunc set_fraction, GwySetMessageFunc set_message) { gint **ftip; gint **fsurface; gdouble tipmin, surfacemin, step; gint cnt; if (set_message && !set_message(N_("Converting fields"))) return NULL; tipmin = gwy_data_field_get_min(tip); surfacemin = gwy_data_field_get_min(surface); step = (gwy_data_field_get_max(surface)-surfacemin)/10000; ftip = i_datafield_to_field(tip, TRUE, tipmin, step); fsurface = i_datafield_to_field(surface, FALSE, surfacemin, step); if (set_message && !set_message(N_("Starting partial estimation"))) { _gwy_morph_lib_ifreematrix(ftip, tip->xres); _gwy_morph_lib_ifreematrix(fsurface, surface->xres); return NULL; } cnt = _gwy_morph_lib_itip_estimate0(fsurface, surface->yres, surface->xres, tip->yres, tip->xres, tip->yres/2, tip->xres/2, ftip, threshold/step, use_edges, set_fraction, set_message); if (cnt == -1 || (set_fraction && !set_fraction(0.0))) { _gwy_morph_lib_ifreematrix(ftip, tip->xres); _gwy_morph_lib_ifreematrix(fsurface, surface->xres); return NULL; } gwy_debug("Converting fields"); if (set_message) set_message(N_("Converting fields")); tip = i_field_to_datafield(ftip, tip, tipmin, step); gwy_data_field_add(tip, -gwy_data_field_get_min(tip)); _gwy_morph_lib_ifreematrix(ftip, tip->xres); _gwy_morph_lib_ifreematrix(fsurface, surface->xres); if (count) *count = cnt; return tip; }
static void mif_read_block(MIFBlock *block, G_GNUC_UNUSED const gchar *name, const guchar **p) { block->offset = gwy_get_guint32_le(p); block->size = gwy_get_guint32_le(p); if (block->size) { gwy_debug("%s offset: %zu (0x%zx), size: %zu (0x%zx)", name, block->offset, block->offset, block->size, block->size); } }
/** * file_register_plugins: * @plugins: Plug-in list to eventually add the plug-in to. * @file: Plug-in file (full path). * @buffer: The output from "plugin register". * * Parse output from "plugin register" and eventually add it to the * plugin-list. * * Returns: The new plug-in list, with the plug-in eventually prepended. **/ static GList* file_register_plugins(GList *plugins, const gchar *file, gchar *buffer) { FilePluginInfo *info; gchar *pname = NULL, *file_desc = NULL, *run_modes = NULL, *glob = NULL; GwyFileOperationType run; gwy_debug("buffer: <<<%s>>>", buffer); while (buffer) { if ((pname = gwy_str_next_line(&buffer)) && *pname && (file_desc = gwy_str_next_line(&buffer)) && *file_desc && (glob = gwy_str_next_line(&buffer)) && *glob && (run_modes = gwy_str_next_line(&buffer)) && (run = gwy_string_to_flags(run_modes, file_op_names, -1, NULL))) { info = g_new0(FilePluginInfo, 1); info->name = g_strdup(pname); info->description = g_strdup(file_desc); if (gwy_file_func_register(info->name, info->description, &file_plugin_proxy_detect, (run & GWY_FILE_OPERATION_LOAD) ? file_plugin_proxy_load : NULL, NULL, (run & GWY_FILE_OPERATION_EXPORT) ? file_plugin_proxy_export : NULL)) { info->file = g_strdup(file); info->run = run; info->glob = g_strdup(glob); info->pattern = file_patternize_globs(glob); info->specificity = file_glob_specificities(glob); plugins = g_list_prepend(plugins, info); } else { g_free((gpointer)info->name); g_free((gpointer)info->description); g_free(info); } } else if (pname && *pname) { g_warning("failed; " "pname = %s, file_desc = %s, run_modes = %s, glob = %s", pname, file_desc, run_modes, glob); } while (buffer && *buffer) gwy_str_next_line(&buffer); } return plugins; }
static void gwy_data_view_init(GwyDataView *data_view) { gwy_debug(" "); data_view->zoom = 1.0; data_view->newzoom = 1.0; data_view->xmeasure = -1.0; data_view->ymeasure = -1.0; data_view->force_update = TRUE; }
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); }
/** * gwy_tool_hide: * @tool: A tool. * * Hides a tool's dialog. **/ void gwy_tool_hide(GwyTool *tool) { GwyToolClass *klass; g_return_if_fail(GWY_IS_TOOL(tool)); klass = GWY_TOOL_GET_CLASS(tool); gwy_debug("%s", klass->title); if (klass->hide) klass->hide(tool); }