/*! \brief Iterator callback for freeing a source. * \par Function Description * Private function used only in s_clib.c. */ static void free_source (gpointer data, gpointer user_data) { CLibSource *source = (CLibSource*) data; if (source != NULL) { if (source->name != NULL) { g_free (source->name); source->name = NULL; } if (source->symbols != NULL) { g_list_foreach (source->symbols, (GFunc) free_symbol, NULL); g_list_free (source->symbols); source->symbols = NULL; } if (source->directory != NULL) { g_free (source->directory); source->directory = NULL; } if (source->list_cmd != NULL) { g_free (source->list_cmd); source->list_cmd = NULL; } if (source->get_cmd != NULL) { g_free (source->get_cmd); source->get_cmd = NULL; } if (source->type == CLIB_SCM) { scm_gc_unprotect_object (source->list_fn); scm_gc_unprotect_object (source->get_fn); } } }
static void gnc_column_view_edit_destroy(gnc_column_view_edit * view) { gnc_options_dialog_destroy(view->optwin); scm_gc_unprotect_object(view->options); scm_gc_unprotect_object(view->view); gnc_option_db_destroy(view->odb); g_free(view); }
static void delete_scm_hook (gpointer data) { GncScmDangler *scm = data; scm_gc_unprotect_object(scm->proc); g_free(scm); }
static SCM dispatch_event(void *data) { SCM action = *((SCM *)data); scm_call_0(action); scm_gc_unprotect_object(action); scm_remember_upto_here_1(action); return SCM_BOOL_T; }
static SCM device_change(SCM obj) { if (device_change_handler != SCM_BOOL_F) scm_gc_unprotect_object(device_change_handler); if (obj != SCM_BOOL_F) scm_gc_protect_object(obj); device_change_handler = obj; return SCM_UNSPECIFIED; }
static void guilePropertyListenerFreeCallback(guihckContext* ctx, guihckElementId listenerId, guihckElementId listenedId, const char* property, SCM value, void* data) { (void) ctx; (void) listenerId; (void) listenedId; (void) property; (void) value; SCM callback = data; scm_gc_unprotect_object(callback); }
static void timeout_free (AvahiTimeout *timeout) { (void) scm_call_1 (timeout->guile_poll->free_timeout, timeout->timeout_smob); /* We don't free the C object here. Instead, it will get freed eventually, when its Scheme representative gets GC'd. */ scm_gc_unprotect_object (timeout->timeout_smob); timeout->dead = 1; }
static void gnc_column_view_edit_size_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; GtkWidget * rowspin; GtkWidget * colspin; GtkWidget * dlg; GladeXML *xml; SCM current; int length; int dlg_ret; xml = gnc_glade_xml_new ("report.glade", "Edit Report Size"); dlg = glade_xml_get_widget (xml, "Edit Report Size"); /* get the spinner widgets */ rowspin = glade_xml_get_widget (xml, "row_spin"); colspin = glade_xml_get_widget (xml, "col_spin"); length = scm_ilength(r->contents_list); if (length > r->contents_selected) { current = scm_list_ref(r->contents_list, scm_int2num(r->contents_selected)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(colspin), (float)scm_num2int(SCM_CADR(current), SCM_ARG1, G_STRFUNC)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(rowspin), (float)scm_num2int(SCM_CADDR(current), SCM_ARG1, G_STRFUNC)); dlg_ret = gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_hide(dlg); if (dlg_ret == GTK_RESPONSE_OK) { current = SCM_LIST4(SCM_CAR(current), scm_int2num(gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(colspin))), scm_int2num(gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(rowspin))), SCM_BOOL_F); scm_gc_unprotect_object(r->contents_list); r->contents_list = scm_list_set_x(r->contents_list, scm_int2num(r->contents_selected), current); scm_gc_protect_object(r->contents_list); gnc_options_dialog_changed (r->optwin); update_display_lists(r); } gtk_widget_destroy(dlg); } }
SCMFunctor& SCMFunctor::operator= (const SCMFunctor& hook) { if (this != &hook) { scm_gc_unprotect_object(func); func = hook.func; scm_gc_protect_object(func); } return *this; }
static void watch_free (AvahiWatch *watch) { scm_call_1 (watch->guile_poll->free_watch, watch->watch_smob); /* We don't free the C object here. Instead, it will get freed eventually, when its Scheme representative gets GC'd. */ scm_gc_unprotect_object (watch->watch_smob); watch->fd = -1; watch->dead = 1; }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void s_menu_free() { int i; for (i = 0; i < menu_index; i++) { if (menu[i].menu_name) { g_free(menu[i].menu_name); menu[i].menu_name = NULL; scm_gc_unprotect_object (menu[i].menu_items); } } menu_index=0; }
static void cleanup_extension_info(gpointer extension_info, gpointer not_used) { ExtensionInfo *ext_info = extension_info; if (ext_info->extension) scm_gc_unprotect_object(ext_info->extension); g_free(ext_info->sort_key); g_free((gchar *)ext_info->ae.name); g_free((gchar *)ext_info->ae.label); g_free((gchar *)ext_info->ae.tooltip); g_free(ext_info->path); g_free(ext_info); }
static void gnc_column_view_edit_remove_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; SCM newlist = SCM_EOL; SCM oldlist = r->contents_list; int count; int oldlength; if (scm_is_list(r->contents_list)) { oldlength = scm_ilength(r->contents_list); if (oldlength > r->contents_selected) { for (count = 0; count < r->contents_selected; count++) { newlist = scm_cons(SCM_CAR(oldlist), newlist); oldlist = SCM_CDR(oldlist); } if (count <= oldlength) { newlist = scm_append(scm_listify(scm_reverse(newlist), SCM_CDR(oldlist), SCM_UNDEFINED)); } } if (r->contents_selected > 0 && oldlength == r->contents_selected + 1) { r->contents_selected --; } scm_gc_unprotect_object(r->contents_list); r->contents_list = newlist; scm_gc_protect_object(r->contents_list); gnc_column_view_set_option(r->odb, "__general", "report-list", r->contents_list); gnc_options_dialog_changed (r->optwin); } update_display_lists(r); }
static void gnc_style_sheet_options_close_cb(GNCOptionWin * propertybox, gpointer user_data) { ss_info * ssi = user_data; GtkTreeIter iter; if (gtk_tree_row_reference_valid (ssi->row_ref)) { StyleSheetDialog * ss = gnc_style_sheet_dialog; GtkTreePath *path = gtk_tree_row_reference_get_path (ssi->row_ref); if (gtk_tree_model_get_iter (GTK_TREE_MODEL(ss->list_store), &iter, path)) gtk_list_store_set (ss->list_store, &iter, COLUMN_DIALOG, NULL, -1); gtk_tree_path_free(path); } gtk_tree_row_reference_free (ssi->row_ref); gnc_options_dialog_destroy(ssi->odialog); gnc_option_db_destroy(ssi->odb); scm_gc_unprotect_object(ssi->stylesheet); g_free(ssi); }
static void gnc_edit_column_view_move_up_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; SCM oldlist = r->contents_list; SCM newlist = SCM_EOL; SCM temp; int oldlength; int count; oldlength = scm_ilength(r->contents_list); if ((r->contents_selected > 0) && (oldlength > r->contents_selected)) { for (count = 1; count < r->contents_selected; count++) { newlist = scm_cons(SCM_CAR(oldlist), newlist); oldlist = SCM_CDR(oldlist); } temp = SCM_CAR(oldlist); oldlist = SCM_CDR(oldlist); newlist = scm_cons(temp, scm_cons(SCM_CAR(oldlist), newlist)); newlist = scm_append(scm_listify(scm_reverse(newlist), SCM_CDR(oldlist), SCM_UNDEFINED)); scm_gc_unprotect_object(r->contents_list); r->contents_list = newlist; scm_gc_protect_object(r->contents_list); r->contents_selected = r->contents_selected - 1; gnc_column_view_set_option(r->odb, "__general", "report-list", r->contents_list); gnc_options_dialog_changed (r->optwin); update_display_lists(r); } }
static void update_display_lists(gnc_column_view_edit * view) { SCM get_names = scm_c_eval_string("gnc:all-report-template-names"); SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/report-guid"); SCM report_menu_name = scm_c_eval_string("gnc:report-menu-name"); SCM names = scm_call_0(get_names); SCM contents = gnc_option_db_lookup_option(view->odb, "__general", "report-list", SCM_BOOL_F); SCM this_report; SCM selection; const gchar *name; int row, i, id; GtkListStore *store; GtkTreeIter iter; GtkTreePath *path; GtkTreeSelection *tree_selection; /* Update the list of available reports (left selection box). */ row = view->available_selected; if (scm_is_list(view->available_list) && !scm_is_null (view->available_list)) { row = MIN (row, scm_ilength (view->available_list) - 1); selection = scm_list_ref (view->available_list, scm_int2num (row)); } else { selection = SCM_UNDEFINED; } scm_gc_unprotect_object(view->available_list); view->available_list = names; scm_gc_protect_object(view->available_list); store = GTK_LIST_STORE(gtk_tree_view_get_model(view->available)); gtk_list_store_clear(store); if (scm_is_list(names)) { for (i = 0; !scm_is_null(names); names = SCM_CDR(names), i++) { char * str; if (scm_is_equal (SCM_CAR(names), selection)) row = i; scm_dynwind_begin (0); str = scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names), SCM_BOOL_F)); name = _(g_strdup (str)); scm_dynwind_free (str); scm_dynwind_end (); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, AVAILABLE_COL_NAME, name, AVAILABLE_COL_ROW, i, -1); } } tree_selection = gtk_tree_view_get_selection(view->available); path = gtk_tree_path_new_from_indices(row, -1); gtk_tree_selection_select_path(tree_selection, path); gtk_tree_path_free(path); /* Update the list of selected reports (right selection box). */ row = view->contents_selected; if (scm_is_list(view->contents_list) && !scm_is_null (view->contents_list)) { row = MIN (row, scm_ilength (view->contents_list) - 1); selection = scm_list_ref (view->contents_list, scm_int2num (row)); } else { selection = SCM_UNDEFINED; } scm_gc_unprotect_object(view->contents_list); view->contents_list = contents; scm_gc_protect_object(view->contents_list); store = GTK_LIST_STORE(gtk_tree_view_get_model(view->contents)); gtk_list_store_clear(store); if (scm_is_list(contents)) { for (i = 0; !scm_is_null(contents); contents = SCM_CDR(contents), i++) { char * str; if (scm_is_equal (SCM_CAR(contents), selection)) row = i; id = scm_num2int(SCM_CAAR(contents), SCM_ARG1, G_STRFUNC); this_report = gnc_report_find(id); scm_dynwind_begin (0); str = scm_to_locale_string (scm_call_1(report_menu_name, this_report)); name = _(g_strdup (str)); scm_dynwind_free (str); scm_dynwind_end (); gtk_list_store_append(store, &iter); gtk_list_store_set (store, &iter, CONTENTS_COL_NAME, name, CONTENTS_COL_ROW, i, CONTENTS_COL_REPORT_COLS, scm_num2int(SCM_CADR(SCM_CAR(contents)), SCM_ARG1, G_STRFUNC), CONTENTS_COL_REPORT_ROWS, scm_num2int(SCM_CADDR(SCM_CAR(contents)), SCM_ARG1, G_STRFUNC), -1); } } tree_selection = gtk_tree_view_get_selection(view->contents); path = gtk_tree_path_new_from_indices(row, -1); gtk_tree_selection_select_path(tree_selection, path); // gtk_tree_view_scroll_to_cell(view->contents, path, NULL, TRUE, 0.5, 0.0); gtk_tree_path_free(path); }
/**************************************************************** * qif_account_picker_dialog * * Select an account from the ones that the engine knows about, * plus those that will be created by the QIF import. If the * user clicks OK, map_entry is changed and TRUE is returned. * If the clicks Cancel instead, FALSE is returned. Modal. ****************************************************************/ gboolean qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry) { QIFAccountPickerDialog * wind; SCM gnc_name = scm_c_eval_string("qif-map-entry:gnc-name"); SCM set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!"); SCM orig_acct = scm_call_1(gnc_name, map_entry); int response; GtkBuilder *builder; GtkWidget *button; wind = g_new0(QIFAccountPickerDialog, 1); /* Save the map entry. */ wind->map_entry = map_entry; scm_gc_protect_object(wind->map_entry); /* Set the initial account to be selected. */ if (scm_is_string(orig_acct)) wind->selected_name = gnc_scm_to_utf8_string (orig_acct); builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-account-picker.glade", "QIF Import Account Picker"); /* Connect all the signals */ gtk_builder_connect_signals (builder, wind); wind->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Account Picker")); wind->treeview = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_tree")); wind->qif_wind = qif_wind; { GtkTreeStore *store; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *selection; store = gtk_tree_store_new(NUM_ACCOUNT_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); gtk_tree_view_set_model(wind->treeview, GTK_TREE_MODEL(store)); g_object_unref(store); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer, "text", ACCOUNT_COL_NAME, NULL); g_object_set(column, "expand", TRUE, NULL); gtk_tree_view_append_column(wind->treeview, column); renderer = gtk_cell_renderer_toggle_new(); g_object_set(renderer, "activatable", FALSE, NULL); column = gtk_tree_view_column_new_with_attributes(_("New?"), renderer, "active", ACCOUNT_COL_CHECK, NULL); gtk_tree_view_append_column(wind->treeview, column); selection = gtk_tree_view_get_selection(wind->treeview); g_signal_connect(selection, "changed", G_CALLBACK(gnc_ui_qif_account_picker_changed_cb), wind); g_signal_connect(wind->treeview, "row-activated", G_CALLBACK(gnc_ui_qif_account_picker_row_activated_cb), wind); } g_signal_connect_after(wind->dialog, "map", G_CALLBACK(gnc_ui_qif_account_picker_map_cb), wind); button = GTK_WIDGET(gtk_builder_get_object (builder, "newbutton")); gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); /* this is to get the checkmarks set up right.. it will get called * again after the window is mapped. */ build_acct_tree(wind, wind->qif_wind); do { response = gtk_dialog_run(GTK_DIALOG(wind->dialog)); } while (response == GNC_RESPONSE_NEW); gtk_widget_destroy(wind->dialog); g_object_unref(G_OBJECT(builder)); scm_gc_unprotect_object(wind->map_entry); g_free(wind->selected_name); g_free(wind); if (response == GTK_RESPONSE_OK) return TRUE; /* Restore the original mapping. */ scm_call_2(set_gnc_name, map_entry, orig_acct); return FALSE; }
SCMFunctor::~SCMFunctor() { scm_gc_unprotect_object(func); }
/*! \brief Destroy a cache entry for Scheme values. * \par Function Description * Destroy \a entry, removing garbage collection protection from the * Scheme value it contains. * * \param entry The cache entry structure to be destroyed. */ static void smob_cache_entry_destroy (SmobCacheEntry *entry) { scm_gc_unprotect_object (entry->smob); g_slice_free (SmobCacheEntry, entry); }
static void gnc_style_sheet_select_dialog_response_cb (GtkDialog *unused, gint response, gpointer user_data) { StyleSheetDialog * ss; GtkTreeSelection * selection; GtkTreeRowReference * row_ref; GtkTreeModel * model; GtkTreePath * path; GtkTreeIter iter; ss_info * ssinfo; SCM remover; SCM sheet_info; gchar *name; ss = (StyleSheetDialog *)user_data; switch (response) { case GNC_RESPONSE_NEW: sheet_info = gnc_style_sheet_new(ss); if (sheet_info == SCM_BOOL_F) break; gnc_style_sheet_select_dialog_add_one(ss, sheet_info, TRUE); /* Fall through */ case GNC_RESPONSE_EDIT: selection = gtk_tree_view_get_selection (ss->list_view); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, COLUMN_NAME, &name, COLUMN_STYLESHEET, &sheet_info, -1); /* Fire off options dialog here */ path = gtk_tree_model_get_path (GTK_TREE_MODEL(ss->list_store), &iter); row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL(ss->list_store), path); ssinfo = gnc_style_sheet_dialog_create(ss, name, sheet_info, row_ref); gtk_list_store_set (ss->list_store, &iter, COLUMN_DIALOG, ssinfo, -1); g_free(name); } break; case GNC_RESPONSE_DELETE: selection = gtk_tree_view_get_selection (ss->list_view); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, COLUMN_STYLESHEET, &sheet_info, COLUMN_DIALOG, &ssinfo, -1); gtk_list_store_remove (ss->list_store, &iter); if (ssinfo) gnc_style_sheet_options_close_cb(NULL, ssinfo); remover = scm_c_eval_string("gnc:html-style-sheet-remove"); scm_call_1(remover, sheet_info); scm_gc_unprotect_object(sheet_info); } break; case GTK_RESPONSE_CLOSE: default: gnc_style_sheet_dialog = NULL; gtk_widget_destroy(ss->toplevel); g_free(ss); break; } }
static void cmdscm_release_command (command_smob *c_smob) { c_smob->command = NULL; scm_gc_unprotect_object (c_smob->containing_scm); }
static void gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; SCM make_report = scm_c_eval_string("gnc:make-report"); SCM mark_report = scm_c_eval_string("gnc:report-set-needs-save?!"); SCM template_name; SCM new_report; SCM newlist = SCM_EOL; SCM oldlist = r->contents_list; int count; int oldlength, id; if (scm_is_list(r->available_list) && (scm_ilength(r->available_list) > r->available_selected)) { template_name = scm_list_ref(r->available_list, scm_int2num(r->available_selected)); new_report = scm_call_1(make_report, template_name); id = scm_num2int(new_report, SCM_ARG1, G_STRFUNC); scm_call_2(mark_report, gnc_report_find(id), SCM_BOOL_T); oldlength = scm_ilength(r->contents_list); if (oldlength > r->contents_selected) { for (count = 0; count < r->contents_selected; count++) { newlist = scm_cons(SCM_CAR(oldlist), newlist); oldlist = SCM_CDR(oldlist); } newlist = scm_append (scm_listify(scm_reverse(scm_cons(SCM_LIST4(new_report, scm_int2num(1), scm_int2num(1), SCM_BOOL_F), newlist)), oldlist, SCM_UNDEFINED)); } else { newlist = scm_append (scm_listify(oldlist, SCM_LIST1(SCM_LIST4(new_report, scm_int2num(1), scm_int2num(1), SCM_BOOL_F)), SCM_UNDEFINED)); r->contents_selected = oldlength; } scm_gc_unprotect_object(r->contents_list); r->contents_list = newlist; scm_gc_protect_object(r->contents_list); gnc_column_view_set_option(r->odb, "__general", "report-list", r->contents_list); gnc_options_dialog_changed (r->optwin); } update_display_lists(r); }