void do_print(Widget w) { char *printer_val; char *param_val; char cmd[255],cmd2[255]; char *c1; char backgrnd[10], grid[80]; /* don't print if in the middle of drawing/editing */ if (check_action_on()) return; if (emptyfigure_msg(print_msg) && !batch_exists) return; /* create popup panel if not already there so we have all the resources necessary (e.g. printer name etc.) */ if (!print_popup) create_print_panel(w); /* get the magnification into appres.magnification */ get_magnif(); /* update the figure size (magnification * bounding_box) */ print_update_figure_size(); printer_val = panel_get_value(printer_text); param_val = panel_get_value(param_text); /* get grid params and assemble into fig2dev parm */ get_grid_spec(grid, print_grid_minor_text, print_grid_major_text); if (batch_exists) { gen_print_cmd(cmd,batch_file,printer_val,param_val); if (system(cmd) != 0) file_msg("Error during PRINT"); /* clear the batch file and the count */ do_clear_batch(w); } else { strcpy(cmd, param_val); /* see if the user wants the filename in the param list (%f) */ if (!strstr(cur_filename,"%f")) { /* don't substitute if the filename has a %f */ while (c1=strstr(cmd,"%f")) { strcpy(cmd2, c1+2); /* save tail */ strcpy(c1, cur_filename); /* change %f to filename */ strcat(c1, cmd2); /* append tail */ } } /* make a #rrggbb string from the background color */ make_rgb_string(export_background_color, backgrnd); print_to_printer(printer_val, backgrnd, appres.magnification, print_all_layers, bound_active_layers, grid, cmd); } }
static void search_and_replace_text(Widget widget, XtPointer closure, XtPointer call_data) { char *string; show_search_msg("Searching text..."); XtSetSensitive(do_replace_button, False); XtSetSensitive(do_update_button, False); /* clear any old search results first */ found_text_cnt = 0; msg_length = 0; FirstArg(XtNstring, "\0"); SetValues(search_results_win); do_replace_called = False; string = panel_get_value(search_text_widget); if (strlen(string)!=0) search_text_in_compound(&objects, string, show_text_object); if (found_text_cnt == 0) show_search_msg("No match"); else show_search_msg("%d line%s match%s", found_text_cnt, (found_text_cnt != 1)? "s":"", (found_text_cnt == 1)? "es":""); if (found_text_cnt > 0) { XtSetSensitive(replace_text_label, True); XtSetSensitive(do_replace_button, True); XtSetSensitive(do_update_button, True); } }
static void update_mag(Widget widget, XtPointer item, XtPointer event) { char *buf; buf = panel_get_value(print_mag_text); appres.magnification = (float) atof(buf); update_figure_size(); }
static void get_magnif(void) { char buf[60]; appres.magnification = (float) atof(panel_get_value(print_mag_text)); if (appres.magnification <= 0.0) appres.magnification = 100.0; /* write it back to the widget in case it had a bad value */ sprintf(buf,"%.1f",appres.magnification); FirstArg(XtNstring, buf); SetValues(print_mag_text); }
static void do_update(Widget widget, XtPointer closure, XtPointer call_data) { if (found_text_cnt > 0) { search_text_in_compound(&objects, panel_get_value(search_text_widget), update_text); found_text_panel_dismiss(); redisplay_canvas(); set_modifiedflag(); show_search_msg("%d object%s updated", found_text_cnt, (found_text_cnt != 1)? "s":""); } }
void popup_browse_panel(Widget w) { char *fval, *pval; set_temp_cursor(wait_cursor); XtSetSensitive(w, False); browse_parent = w; browse_up = True; file_viewed[0] = '\0'; if (!browse_popup) { get_directory(local_dir); } else { strcpy(local_dir, cur_browse_dir); } /* move to the file directory - if not the current dir and set up the file/directory values */ pval = (char*) panel_get_value( pic_name_panel ); fval = strrchr(pval, '/'); if ( !fval ) { /* no path in name so just use name */ strcpy(browse_filename, pval); } else { /* set us up in the same path as the file */ strcpy(local_dir, pval); strcpy(browse_filename, fval+1); local_dir[strlen(pval) - strlen(fval)] = '\0'; (void) change_directory(local_dir); } if (!browse_popup) { create_browse_panel(w); } FirstArg(XtNstring, local_dir); SetValues(browse_dir); FirstArg(XtNstring, browse_filename); SetValues(browse_selfile); XtPopup(browse_popup, XtGrabNonexclusive); Rescan(0, 0, 0, 0); (void) XSetWMProtocols(tool_d, XtWindow(browse_popup), &wm_delete_window, 1); /* if the file message window is up add it to the grab */ file_msg_add_grab(); set_cmap(XtWindow(browse_popup)); /* ensure most recent cmap is installed */ reset_cursor(); }