static void imageset_loaded (HDImagesetBackground *background, GAsyncResult *result, HDAvailableBackgrounds *backgrounds) { HDImagesetBackgroundPrivate *priv = background->priv; GError *error = NULL; if (hd_imageset_background_init_finish (background, result, &error)) { char *label; label = get_display_label (priv->name); hd_available_backgrounds_add_with_file (backgrounds, HD_BACKGROUND (background), label, hd_object_vector_at (priv->image_files, 0)); g_free (label); } }
static void theme_loaded (HDImagesetBackground *background, GAsyncResult *result, HDAvailableBackgrounds *backgrounds) { GError *error = NULL; if (hd_imageset_background_init_finish (background, result, &error)) { GKeyFile *key_file; char *name, *label; GdkPixbuf *icon; key_file = get_theme_key_file (HD_THEME_BACKGROUND (background)); name = get_theme_name (key_file); icon = get_theme_icon (key_file); g_key_file_free (key_file); label = get_display_label (name); hd_available_backgrounds_add_with_icon (backgrounds, HD_BACKGROUND (background), label, icon); g_free (name); if (icon) g_object_unref (icon); g_free (label); } }
/*----------------------------------------------- | | | getdata()/0 | | | | This function reads the 1D or 2D data in | | form disk, manipulates it appropriately, | | and moves the ReRe component to the memory | | allocated for the phasefile data. | | | +----------------------------------------------*/ static int getdata() { char dsplymes[20], /* display mode label */ dmg1[5]; int npf1=0, /* number of points along F1 */ npf2=0, /* number of points along F2 */ i, r, found, f1phase, f2phase, quad2, quad4, complex_1D=0, norm_av, norm_dir, norm_phase, norm_phaseangle, norm_dbm, rev_av=0, rev_dir=0, rev_phase=0, rev_phaseangle=0, nplinear, npblock; float *f1phasevec=NULL, /* F1 phasing vector */ *f2phasevec=NULL; /* F2 phasing vector */ double rp_norm, lp_norm; double rp_rev, lp_rev; dpointers datablock; hycmplxhead *tmpblkhead; /******************************************** * Get pointer to data in specified block. * ********************************************/ if ( (r = D_getbuf(D_DATAFILE, nblocks, c_buffer, &datablock)) ) { D_error(r); return(ERROR); } else if (checkdata(datablock.head)) { return(ERROR); } /********************** * Setup for 2D data * **********************/ quad2 = quad4 = FALSE; f1phase = f2phase = FALSE; if (d2flag) { /************************************ * Set the flags for the number of * * quadrants. * ************************************/ quad4 = (datahead.status & S_HYPERCOMPLEX); if (!quad4) quad2 = (datahead.status & S_COMPLEX); /******************************************** * Precalculate phasing vectors for the F1 * * and F2 dimensions if necessary. * ********************************************/ nplinear = pointsperspec; npblock = specperblock * nblocks; if (quad4) { npblock *= 2; nplinear /= 2; } if (revflag) { npf1 = nplinear; npf2 = npblock; } else { npf2 = nplinear; npf1 = npblock; } f1phasevec = NULL; /* initialize pointer */ f2phasevec = NULL; /* initialize pointer */ /********************************************** * If a phase-sensitive display is requested * * along F1, precalculate the F1 phasing * * vector. * **********************************************/ rev_dir = get_direction(REVDIR); get_phase_pars(rev_dir,&rp_rev,&lp_rev); rev_phase = get_phase_mode(rev_dir); rev_phaseangle = get_phaseangle_mode(rev_dir); rev_av = get_av_mode(rev_dir); f1phase = ( ((rev_phase && nonzerophase(rp_rev, lp_rev)) || rev_phaseangle) && (quad2 || quad4) && get_axis_freq(rev_dir) ); if (f1phase) { f1phasevec = (float *) (allocateWithId( (unsigned) (sizeof(float) * npf1), "getdata" )); if (f1phasevec == NULL) { Werrprintf("Unable to allocate memory for F1 phase buffer"); return(ERROR); } else { phasefunc(f1phasevec, npf1/2, lp_rev, rp_rev); } } /********************************************** * If a phase-sensitive display is requested * * along F2, precalculate the F2 phasing * * vector. * **********************************************/ norm_dir = get_direction(NORMDIR); get_phase_pars(norm_dir,&rp_norm,&lp_norm); norm_phase = get_phase_mode(norm_dir); norm_phaseangle = get_phaseangle_mode(norm_dir); norm_av = get_av_mode(norm_dir); norm_dbm = get_dbm_mode(norm_dir); /* may not be active?? */ f2phase = ( (norm_phase || norm_phaseangle) && quad4 && nonzerophase(rp_norm, lp_norm) ); /* (quad4 || quad2)?? (quad4) only?? */ if (f2phase) { f2phasevec = (float *) (allocateWithId( (unsigned) (sizeof(float) * npf2), "getdata" )); if (f2phasevec == NULL) { Werrprintf("Unable to allocate memory for F2 phase buffer"); if (f1phase) releaseAllWithId("getdata"); return(ERROR); } else { phasefunc(f2phasevec, npf2/2, lp_norm, rp_norm); } } } else { complex_1D = (datablock.head->status & NP_CMPLX); norm_dir = HORIZ; norm_phase = get_phase_mode(norm_dir); norm_phaseangle = get_phaseangle_mode(norm_dir); norm_av = get_av_mode(norm_dir); norm_dbm = get_dbm_mode(norm_dir); /* may not be active 2 */ } /************************************* * Readjust "npf1" and "npf2" to be * * per block. * *************************************/ if (d2flag) { if (revflag) { npf2 /= nblocks; } else { npf1 /= nblocks; } } /********************************** * Construct display mode label. * **********************************/ strcpy(dsplymes, ""); /* initialization of string */ if ( d2flag && (quad2 || quad4) ) { char charval; char tmp[10]; get_display_label(rev_dir,&charval); if (rev_phase) { sprintf(tmp, "PH%c ",charval); } else if (rev_av) { sprintf(tmp, "AV%c ",charval); } else if (rev_phaseangle) { sprintf(tmp, "PA%c ",charval); } else { sprintf(tmp, "PW%c ",charval); } strcpy(dsplymes, tmp); } if ( (d2flag && quad4) || ((!d2flag) && complex_1D) ) { char charval; char tmp[10]; get_display_label(norm_dir,&charval); if (charval == '\0') charval = ' '; if (norm_phase) { sprintf(tmp, "PH%c",charval); } else if (norm_av) { sprintf(tmp, "AV%c",charval); } else if (norm_phaseangle) { sprintf(tmp, "PA%c",charval); } else { sprintf(tmp, "PW%c",charval); } strcat(dsplymes, tmp); } disp_status(dsplymes); /************************************************* * Manipulate data depending upon the number of * * 2D data quadrants and the desired mode of * * display. * *************************************************/ if (d2flag) { if (quad4) { /*********************************** * HYPERCOMPLEX 2D spectral data: * * F2 phase-sensitive display * ***********************************/ if (norm_phase) { if (rev_phase) { /***************************** * phase for ReRe component * *****************************/ if (f1phase && f2phase) { blockphase4(datablock.data, c_block.data, f1phasevec, f2phasevec, nblocks, c_buffer, npf1/2, npf2/2); } else if (f1phase) { blockphase2(datablock.data, c_block.data, f1phasevec, nblocks, c_buffer, npf1/2, npf2/2, HYPERCOMPLEX, COMPLEX, TRUE, FALSE); } else if (f2phase) { blockphase2(datablock.data, c_block.data, f2phasevec, nblocks, c_buffer, npf1/2, npf2/2, HYPERCOMPLEX, REAL, FALSE, FALSE); } else { movmem((char *)datablock.data, (char *)c_block.data, (npf1*npf2*sizeof(float))/4, HYPERCOMPLEX, 4); } } else { if (f2phase) { /*************************** * rotate ReRe <---> ReIm * * rotate ImRe <---> ImIm * ***************************/ if (rev_av) { /******************************** * S = sqrt(ReRe**2 + ImRe**2) * ********************************/ blockphsabs4(datablock.data, c_block.data, f2phasevec, nblocks, c_buffer, npf1/2, npf2/2, REAL, FALSE); } else if (rev_phaseangle) { blockphaseangle2(datablock.data, c_block.data, f1phasevec, nblocks, c_buffer, npf1/2, npf2/2, HYPERCOMPLEX, COMPLEX, TRUE, FALSE); } else { /************************** * S = ReRe**2 + ImRe**2 * **************************/ blockphspwr4(datablock.data, c_block.data, f2phasevec, nblocks, c_buffer, npf1/2, npf2/2, REAL, FALSE); } } else if (rev_av) /* no F2 phasing required */ { /******************************** * S = sqrt(ReRe**2 + ImRe**2) * ********************************/ absval2(datablock.data, c_block.data, (npf1*npf2)/4, HYPERCOMPLEX, COMPLEX, REAL, FALSE); } /* else if (rev_phaseangle) {} */ else /* no F2 phasing required */ { /************************** * S = ReRe**2 + ImRe**2 * **************************/ pwrval2(datablock.data, c_block.data, (npf1*npf2)/4, HYPERCOMPLEX, COMPLEX, REAL, FALSE); } } } /*********************************** * HYPERCOMPLEX 2D spectral data: * * F2 absolute-value display * ***********************************/ else if (norm_av) { if (rev_phase) { if (f1phase) { /******************************** * rotate ReRe <---> ImRe * * rotate ReIm <---> ImIm * * S = sqrt(ReRe**2 + ReIm**2) * ********************************/ blockphsabs4(datablock.data, c_block.data, f1phasevec, nblocks, c_buffer, npf1/2, npf2/2, COMPLEX, TRUE); } else { /******************************** * S = sqrt(ReRe**2 + ReIm**2) * ********************************/ absval2(datablock.data, c_block.data, (npf1*npf2)/4, HYPERCOMPLEX, REAL, REAL, FALSE); } } else if (rev_av) { /**************************************************** * S = sqrt(ReRe**2 + ReIm**2 + ImRe**2 + ImIm**2) * ****************************************************/ absval4(datablock.data, c_block.data, npf1*npf2/4); } /* else if (rev_phaseangle) {} */ else { /**************************** * S1 = ReRe**2 + ImRe**2 * * S2 = ReIm**2 + ImIm**2 * * S = sqrt(S1**2 + S2**2) * ****************************/ blockpwrabs(datablock.data, c_block.data, (npf1*npf2)/4, COMPLEX); } } /*********************************** * HYPERCOMPLEX 2D spectral data: * * F2 phaseangle display * ***********************************/ else if (norm_phaseangle) { Werrprintf("Cannot perform hypercomplex phaseangle"); return(ERROR); } /*********************************** * HYPERCOMPLEX 2D spectral data: * * F2 power display * ***********************************/ else { if (rev_phase) { if (f1phase) { /*************************** * rotate ReRe <---> ImRe * * rotate ReIm <---> ImIm * * S = ReRe**2 + ReIm**2 * ***************************/ blockphspwr4(datablock.data, c_block.data, f1phasevec, nblocks, c_buffer, npf1/2, npf2/2, COMPLEX, TRUE); } else { /************************** * S = ReRe**2 + ReIm**2 * **************************/ pwrval2(datablock.data, c_block.data, (npf1*npf2)/4, HYPERCOMPLEX, REAL, REAL, FALSE); } } else if (rev_av) { /**************************** * S1 = ReRe**2 + ReIm**2 * * S2 = ImRe**2 + ImIm**2 * * S = sqrt(S1**2 + S2**2) * ****************************/ blockpwrabs(datablock.data, c_block.data, (npf1*npf2)/4, REAL); } /* else if (rev_phaseangle) {} */ else { /********************************************** * S = ReRe**2 + ReIm**2 + ImRe**2 + ImIm**2 * * THIS IS NOT QUITE RIGHT! * **********************************************/ pwrval4(datablock.data, c_block.data, npf1*npf2/4); } } /********************************************** * Set the F1 phase constants into the block * * header of the phasefile data. * **********************************************/ if (rev_phase || rev_phaseangle) { c_block.head->lpval = lp_rev; c_block.head->rpval = rp_rev; } else { c_block.head->lpval = 0.0; c_block.head->rpval = 0.0; } /*************************************************** * Locate the block header for the "hypercomplex" * * information. Then set the F2 phase constants * * into the block header of the phasefile data. * ***************************************************/ i = 0; found = FALSE; while (!found) { if ( (~(datablock.head + i)->status) & MORE_BLOCKS ) { Werrprintf("Block headers inconsistent with hypercomplex data"); if (f1phase || f2phase) releaseAllWithId("getdata"); return(ERROR); } i += 1; found = ( (datablock.head + i)->status & U_HYPERCOMPLEX ); } tmpblkhead = (hycmplxhead *) (c_block.head + i); if (norm_phase) { tmpblkhead->lpval1 = lp_norm; tmpblkhead->rpval1 = rp_norm; } else { tmpblkhead->lpval1 = 0.0; tmpblkhead->rpval1 = 0.0; } } else if (quad2) { /******************************* * COMPLEX 2D spectral data: * * F1 display selection * *******************************/ if (rev_phase) { /*************************** * rotate ReRe <---> ImRe * ***************************/ if (f1phase) { blockphase2(datablock.data, c_block.data, f1phasevec, nblocks, c_buffer, npf1/2, npf2, COMPLEX, 1, TRUE, FALSE); } else { movmem((char *)datablock.data, (char *)c_block.data, (npf1*npf2*sizeof(float))/2, COMPLEX, 4); } } else if (rev_phaseangle) { if (f1phase) { blockphaseangle2(datablock.data, c_block.data, f1phasevec, nblocks, c_buffer, npf1/2, npf2, COMPLEX, 1, TRUE, FALSE); } else { movmem((char *)datablock.data, (char *)c_block.data, (npf1*npf2*sizeof(float))/2, COMPLEX, 4); } } else if (rev_av) { /******************************** * S = sqrt(ReRe**2 + ImRe**2) * ********************************/ absval2(datablock.data, c_block.data, (npf1*npf2)/2, COMPLEX, 1, 1, FALSE); } else { /************************** * S = ReRe**2 + ImRe**2 * **************************/ pwrval2(datablock.data, c_block.data, (npf1*npf2)/2, COMPLEX, 1, 1, FALSE); } if (rev_phase || rev_phaseangle) { c_block.head->lpval = lp_rev; c_block.head->rpval = rp_rev; } else { c_block.head->lpval = 0.0; c_block.head->rpval = 0.0; } } else { /*************************** * REAL 2D spectral data * ***************************/ movmem((char *)datablock.data, (char *)c_block.data, npf1*npf2*sizeof(float), REAL, 4); c_block.head->lpval = 0.0; c_block.head->rpval = 0.0; } } /********************** * Setup for 1D data * **********************/ else { if(bph()>0 && complex_1D && (norm_phase || norm_phaseangle)) { // don't use lp, rp, because block is individually phased. c_block.head->lpval=getBph1(c_buffer); c_block.head->rpval=getBph0(c_buffer); if (norm_phase) { phase2(datablock.data, c_block.data, fn/2, c_block.head->lpval, c_block.head->rpval); } else if (norm_phaseangle) { phaseangle2(datablock.data, c_block.data, fn/2, COMPLEX, 1, 1, FALSE, c_block.head->lpval, c_block.head->rpval); } P_setreal(CURRENT,"bph1",c_block.head->lpval,0); P_setreal(CURRENT,"bph0",c_block.head->rpval,0); } else { c_block.head->lpval = 0.0; c_block.head->rpval = 0.0; if (complex_1D) { if (norm_phase) { phase2(datablock.data, c_block.data, fn/2, lp, rp); c_block.head->lpval = lp; c_block.head->rpval = rp; } else if (norm_phaseangle) { phaseangle2(datablock.data, c_block.data, fn/2, COMPLEX, 1, 1, FALSE, lp, rp); c_block.head->lpval = lp; c_block.head->rpval = rp; } else if (norm_av) { absval2(datablock.data, c_block.data, fn/2, COMPLEX, 1, 1, FALSE); } else if (norm_dbm) { dbmval2(datablock.data, c_block.data, fn/2, COMPLEX, 1, 1, FALSE); } else { pwrval2(datablock.data, c_block.data, fn/2, COMPLEX, 1, 1, FALSE); } } else { if (datablock.head->status & S_COMPLEX) { movmem((char *)datablock.data, (char *)c_block.data, (fn/2)*sizeof(float), COMPLEX, 4); } else { movmem((char *)datablock.data, (char *)c_block.data, (fn/2)*sizeof(float), REAL, 4); } } } } /************************************* * Set status word for block header * * of phasefile. * *************************************/ c_block.head->status = (S_DATA|S_SPEC|S_FLOAT); /*********************************** * Set mode word for block header * * of phasefile. * ***********************************/ c_block.head->mode = get_mode(HORIZ); if (d2flag) c_block.head->mode |= get_mode(VERT); /*************************************** * Set additional words in main block * * header of phasefile. * ***************************************/ c_block.head->scale = 0; c_block.head->ctcount = 0; c_block.head->index = (short)c_buffer; c_block.head->lvl = 0.0; c_block.head->tlt = 0.0; /************************************************ * Set status word in previous block header of * * phasefile to indicate the presence of a * * following block header. * ************************************************/ if (d2flag) { i = 0; while ((datablock.head + i)->status & MORE_BLOCKS) { (c_block.head + i)->status |= MORE_BLOCKS; i += 1; if ((datablock.head + i)->status & U_HYPERCOMPLEX) (c_block.head + i)->status |= U_HYPERCOMPLEX; } } /****************************************** * Release this DATAFILE buffer with the * * data handler routines. * ******************************************/ if ( (r = D_release(D_DATAFILE, c_buffer)) ) { D_error(r); if (f1phase || f2phase) releaseAllWithId("getdata"); return(ERROR); } if (P_copyvar(CURRENT, PROCESSED, "dmg", "dmg")) { Werrprintf("dmg: cannot copy from 'current' to 'processed' tree\n"); if (f1phase || f2phase) releaseAllWithId("getdata"); return(ERROR); } if (d2flag) { if (!P_getstring(CURRENT, "dmg1", dmg1, 1, 5)) { if (P_copyvar(CURRENT, PROCESSED, "dmg1", "dmg1")) { Werrprintf("dmg1: cannot copy from 'current' to 'processed' tree"); if (f1phase || f2phase) releaseAllWithId("getdata"); return(ERROR); } } } if (f1phase || f2phase) releaseAllWithId("getdata"); if (!Bnmr) disp_status(" "); return(COMPLETE); }