/*! \brief places object in the store so the user can see them * * \param [in] state * \param [in] objects the list of objects to put in the store */ static void assign_store (GschemFindTextState *state, GSList *objects) { GSList *object_iter; g_return_if_fail (state != NULL); g_return_if_fail (state->store != NULL); clear_store (state); object_iter = objects; while (object_iter != NULL) { char *basename; OBJECT *object = (OBJECT*) object_iter->data; const char *str; GtkTreeIter tree_iter; object_iter = g_slist_next (object_iter); if (object == NULL) { g_warning ("NULL object encountered"); continue; } if (object->page == NULL) { g_warning ("NULL page encountered"); continue; } if (object->type != OBJ_TEXT) { g_warning ("expecting a text object"); continue; } str = geda_text_object_get_string (object); if (str == NULL) { g_warning ("NULL string encountered"); continue; } s_object_weak_ref (object, (NotifyFunc) object_weakref_cb, state); gtk_list_store_append (state->store, &tree_iter); basename = g_path_get_basename (s_page_get_filename (object->page)); gtk_list_store_set (state->store, &tree_iter, COLUMN_FILENAME, basename, COLUMN_STRING, str, COLUMN_OBJECT, object, -1); g_free (basename); } }
/*! \brief Get a smob for a schematic object. * \ingroup guile_c_iface * \par Function Description * Create a new smob representing \a object. * * \warning The returned smob is initially marked as owned by the C * code. If it should be permitted to be garbage-collected, you * should set the garbage-collectable flag by calling: * * \code * SCM x = edascm_from_object (object); * edascm_c_set_gc (x, 1); * \endcode * * \note We currently have to bake a TOPLEVEL pointer into the smob, * so that if the object becomes garbage-collectable we can obtain a * TOPLEVEL to use for deleting the smob without accessing the * TOPLEVEL fluid and potentially causing a race condition (see bug * 909358). * * \param object #OBJECT to create a smob for. * \return a smob representing \a object. */ SCM edascm_from_object (OBJECT *object) { SCM smob; TOPLEVEL *toplevel = edascm_c_current_toplevel (); SCM_NEWSMOB2 (smob, geda_smob_tag, object, toplevel); SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_OBJECT); /* Set weak references */ s_object_weak_ref (object, smob_weakref_notify, smob); s_toplevel_weak_ref (toplevel, smob_weakref2_notify, smob); return smob; }
/*! \brief Get a smob for a schematic object. * \ingroup guile_c_iface * \par Function Description * Create a new smob representing \a object. * * \warning The returned smob is initially marked as owned by the C * code. If it should be permitted to be garbage-collected, you * should set the garbage-collectable flag by calling: * * \code * SCM x = edascm_from_object (object); * edascm_c_set_gc (x, 1); * \endcode * * \note We currently have to bake a TOPLEVEL pointer into the smob, * so that if the object becomes garbage-collectable we can obtain a * TOPLEVEL to use for deleting the smob without accessing the * TOPLEVEL fluid and potentially causing a race condition (see bug * 909358). * * \param object #OBJECT to create a smob for. * \return a smob representing \a object. */ SCM edascm_from_object (OBJECT *object) { SCM smob = smob_cache_lookup (object); if (EDASCM_OBJECTP (smob)) { return smob; } TOPLEVEL *toplevel = edascm_c_current_toplevel (); SCM_NEWSMOB2 (smob, geda_smob_tag, object, toplevel); SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_OBJECT); /* Set weak references */ s_object_weak_ref (object, smob_weakref2_notify, unpack_as_pointer (smob)); smob_cache_add (object, smob); return smob; }