void save_render_options_inc (render_struct *rs) { // Private method, added 2007-01-01 // Save some render options in render_options.inc, in the current directory // those that are not camera related // and that cannot be specified on the command line FILE *fin; gchar *msg_buf, str_format[100], *ext; if (!(fin=fopen("render_options.inc","wb"))) { msg_buf = (gchar *) x_malloc(sizeof(gchar) + strlen("render_options.inc") + strlen(_("Not able to open '%s' file for writing"))+5, "const gchar (msg_buf - open file for writing)"); sprintf(msg_buf,_("Not able to open '%s' file for writing"),"render_options.inc"); my_msg(msg_buf,WARNING); } else { // loc = setlocale(LC_NUMERIC,""); // Povray uses "." as decimal separator instead of "," // setlocale(LC_NUMERIC,"C"); if (*rs->if_creation || *rs->if_modified) { // The PNG file to render is written in a temporary directory fprintf(fin,"#declare hf_to_render = %c%s%c;\n",'\"',HF_OUTPUT_FOR_RENDERING,'\"'); fprintf(fin,"#declare temporary_directory = %c%s%c;\n",'\"',TMP_DIR,'\"'); } else // If the current height field has not been changed, we render the source file fprintf(fin,"#declare hf_to_render = %c%s%c;\n",'\"',*rs->filename,'\"'); fprintf(fin,"#declare current_directory = %c%s%c;\n",'\"',*rs->dirname,'\"'); ext = strstr(*rs->filename,".png"); if (ext) { sprintf(str_format, "#declare fname_radix = %%c%%%d.%ds%%c;\n", ext-*rs->filename,ext-*rs->filename); // printf("STR_FORMAT: %s\n",str_format); fprintf(fin,str_format,'\"',*rs->filename,'\"'); } // setlocale(LC_NUMERIC,loc); fclose(fin); } }
void gl_save_water_inc (gl_preview_struct *gl_preview) { // Public method // Save the current water plane parameters in "geomorph_water.inc" in the current directory // Eventually move in a scene management file FILE *fin; gchar *loc, *tmp, *msg_buf; if (!(fin=fopen("water.inc","wb"))) { msg_buf = (gchar *) x_malloc(sizeof(gchar) + strlen("water.inc") + strlen(_("Not able to open '%s' file for writing"))+5 , "const gchar (msg_buf - open file for writing)"); sprintf(msg_buf,_("Not able to open '%s' file for writing"),"water.inc"); my_msg(msg_buf,WARNING); } else { tmp = setlocale(LC_NUMERIC,NULL); // Povray uses "." as decimal separator instead of "," loc = (gchar *) malloc(strlen(tmp)+1); strcpy(loc,tmp); setlocale(LC_NUMERIC,"C"); if (gl_preview->use_water && *gl_preview->use_water) fprintf(fin,"#declare preview_water_level = %5.2f;\n",*gl_preview->water_level); else fprintf(fin," "); setlocale(LC_NUMERIC,loc); free(loc); fclose(fin); } }
void HandleNewRelayChoiceMessage(NewRelayChoiceMessage msg) { if (keydata[msg.VerificationKey()].HasProperty("privkey")) return; if (!CheckNewRelayChoiceMessage(msg)) return; if (tradedata[msg.accept_commit_hash]["is_mine"]) { if (tradedata[msg.accept_commit_hash]["new_relay_choice_handled"]) return; if ((msg.chooser_side == ASK && tradedata[msg.accept_commit_hash]["my_buy"]) || (msg.chooser_side == BID && tradedata[msg.accept_commit_hash]["my_sell"])) { NewRelayChoiceMessage my_msg(msg.accept_commit_hash, msg.credit_hash, 1 - msg.chooser_side); if (my_msg.positions != msg.positions) return; flexnode.tradehandler.BroadcastMessage(my_msg); } tradedata[msg.accept_commit_hash]["new_relay_choice_handled"] = true; } CheckForRelayDutiesAfterNewRelayChoice(msg); }
gint glarea_init (GtkWidget* widget, gpointer data) { // printf ("GLAREA_INIT - Realize Event\n"); gl_preview_struct *gl_hf = (gl_preview_struct *) data; GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); /*** OpenGL BEGIN ***/ if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { my_msg(_("Not able to display the Open GL preview"),WARNING); return FALSE; } glClearColor(0.0,0.0,0.0,1.0); glEnable(GL_DEPTH_TEST); glPolygonMode(GL_FRONT, GL_FILL); // glDisable(GL_CULL_FACE); set_perspective (gl_hf->cameras[gl_hf->current_camera_id]); // Lights glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glLightfv(GL_LIGHT0, GL_DIFFUSE, l0dif); glLightfv(GL_LIGHT0, GL_SPECULAR, l0dif); glLightfv(GL_LIGHT1, GL_DIFFUSE, l1dif); glLightfv(GL_LIGHT1, GL_SPECULAR, l1dif); glEnable(GL_COLOR_MATERIAL); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ; // Materials glMaterialfv(GL_FRONT, GL_SPECULAR, mspec); glMaterialf(GL_FRONT, GL_SHININESS, mshiny); glShadeModel (GL_SMOOTH); if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); else glFlush (); gdk_gl_drawable_gl_end (gldrawable); return TRUE; }
void save_copy_as_callb(GtkWidget *wdg,gpointer data) { // Saves top document under a new name, // after copying it in a new window // Choose new file name // Returns if cancelled // Create new doc_wrapper // Simple implementation (probably with overhead...): // Save under a new name, reopen the original document, // swap on the top the old renamed document app_struct *app; gchar *dname, *fname; doc_wrapper *doc; app = (app_struct *)data; if (!app->docs) return; if (!app->docs->current_doc) return; doc = app->docs->current_doc; if (doc->fname_tochoose) { my_msg(_("You'll be asked to save the document before cloning it."),INFO); } // Any modification should be saved, whatever happens commit_or_reset (app->stack); doc_save(app->docs->current_doc); if (app->file_on_cmdline) x_free(app->file_on_cmdline); app->file_on_cmdline = concat_dname_fname(doc->dir, doc->filename); app->docs->current_doc->fname_tochoose = TRUE; if (!doc_save(app->docs->current_doc)) { app->docs->current_doc->fname_tochoose = FALSE; return; } fname = doc->filename; // new name dname = doc->dir; open_callb(NULL,data); // Open the filename given by app->file_on_cmdline (old name) // Swap the file and dir names (some window focusing problems, otherwise) doc->filename = app->docs->current_doc->filename; // old name doc->dir = app->docs->current_doc->dir; app->docs->current_doc->filename = fname; app->docs->current_doc->dir = dname; // Old name for original doc gtk_window_set_title(GTK_WINDOW(doc->window), g_filename_to_utf8(app->file_on_cmdline,-1, NULL, NULL, NULL)); // New name for newly opened doc gtk_window_set_title(GTK_WINDOW(app->docs->current_doc->window), g_filename_to_utf8(concat_dname_fname(dname, fname), -1, NULL, NULL, NULL)); }
void about_callb(GtkWidget *wdg, gpointer app) { GtkWidget *content=NULL, *lbl; gchar *fname = NULL,*utf8_msg=NULL; gsize br,bw; GError *ger; static gchar *f1=NULL; static gchar *f2 = "splash.jpg"; static gchar *msg = "\nGEOMORPH 0.6\nhttp://geomorph.sourceforge.net\n\n(c) Patrice St-Gelais 2003-2009 (GPL)\[email protected]\n\nGerman translation by\nSimon Donike (2005-2008) and Tim Schuermann (2004)"; if (!f1) { f1 = x_malloc(2+strlen(PKGDATADIR)+strlen(VERSION)+strlen(f2), "Splash image"); strcpy(f1,PKGDATADIR); strcat(f1,VERSION); strcat(f1,"/"); strcat(f1,f2); } if (!utf8_msg) { utf8_msg = g_locale_to_utf8(msg,-1,&br,&bw,&ger); } if (!utf8_msg) utf8_msg = msg; if (filexists(f1)) fname = f1; else if (filexists(f2)) fname = f2; if (fname) { content = gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(content),gtk_image_new_from_file(fname)); lbl = gtk_label_new(utf8_msg); gtk_label_set_justify(GTK_LABEL(lbl),GTK_JUSTIFY_CENTER); gtk_container_add(GTK_CONTAINER(content),lbl); gtk_widget_show_all(content); } if (content) modal_dialog (content, " ", NULL, NULL, NULL, GTK_WIN_POS_CENTER, TRUE); else my_msg(utf8_msg,INFO); }
GtkWidget* create_glarea (gpointer gl_preview_ptr, gint view_size) { GtkWidget* glarea; GdkGLConfig *glconfig; /* * Configure OpenGL-capable visual. * IMPORTED from the gtkglext gears.c example 2005-11 */ /* Try double-buffered visual */ glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); if (glconfig == NULL) { g_print ("*** Cannot find the double-buffered visual.\n"); g_print ("*** Trying single-buffered visual.\n"); /* Try single-buffered visual */ glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH); if (glconfig == NULL) { // my_msg(_("Not able to display the Open GL preview"),WARNING); my_msg(_("Error creating GtkGLArea!\nPreview not available!"),WARNING); return NULL; } } /* Now, create the GtkGLArea using the attribute list that */ /* we defined above. */ glarea = gtk_drawing_area_new (); // gtk_widget_set_size_request (drawing_area, 300, 300); /* Set OpenGL-capability to the widget. */ gtk_widget_set_gl_capability (glarea, glconfig, NULL, DIRECT_RENDERING, GDK_GL_RGBA_TYPE); gtk_widget_set_events(GTK_WIDGET(glarea), GDK_EXPOSURE_MASK| GDK_BUTTON_PRESS_MASK| GDK_BUTTON_RELEASE_MASK| GDK_POINTER_MOTION_MASK| GDK_POINTER_MOTION_HINT_MASK); /* button_release_event - The user has released one of the */ /* mouse buttons in the window. */ gtk_signal_connect (GTK_OBJECT(glarea), "button_release_event", GTK_SIGNAL_FUNC(glarea_button_release), gl_preview_ptr); /* button_press_event - The user has pressed one of the */ /* mouse buttons in the window. */ gtk_signal_connect (GTK_OBJECT(glarea), "button_press_event", GTK_SIGNAL_FUNC(glarea_button_press), gl_preview_ptr); /* motion_notify_event - The mouse is moving in the window. */ gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event", GTK_SIGNAL_FUNC(glarea_motion_notify), gl_preview_ptr); /* expose_event - The window was exposed and the contents */ /* need to be redrawn. */ gtk_signal_connect (GTK_OBJECT(glarea), "expose_event", GTK_SIGNAL_FUNC(glarea_draw), gl_preview_ptr); /* configure_event - The window has been resized. You will */ /* probably want to call your reshape */ /* function here. */ gtk_signal_connect (GTK_OBJECT(glarea), "configure_event", GTK_SIGNAL_FUNC(glarea_reshape), gl_preview_ptr); /* realize - The window has been created, this is where you */ /* can hook up your initialization routines. */ gtk_signal_connect (GTK_OBJECT(glarea), "realize", GTK_SIGNAL_FUNC(glarea_init), gl_preview_ptr); /* destroy - The window has received a destroy event, this */ /* is where you should do any cleanup that needs */ /* to happen, such as de-allocating data objects */ /* that you have added to your GtkGLArea. */ gtk_signal_connect (GTK_OBJECT(glarea), "destroy", GTK_SIGNAL_FUNC (glarea_destroy), gl_preview_ptr); gtk_widget_show (GTK_WIDGET(glarea)); gtk_widget_set_usize(GTK_WIDGET(glarea), view_size, view_size/ASPECT_RATIO); return (glarea); }
void paste_special_callb(GtkWidget *wdg, gpointer app) { my_msg("PASTE_SPECIAL_CALLB",WARNING); }
void paste_callb(GtkWidget *wdg, gpointer app) { my_msg("PASTE_CALLB",WARNING); }
void cut_callb(GtkWidget *wdg, gpointer app) { my_msg("CUT_CALLB",WARNING); }
void copy_callb(GtkWidget *wdg, gpointer app) { my_msg("COPY_CALLB",WARNING); }
void print_callb(GtkWidget *wdg, gpointer app) { my_msg("PRINT_CALLB",WARNING); }
gint app_quit(GtkWidget* wdg, gpointer data) { GList *node; GtkWidget *window; gint answer, modcount, newmodcount; gboolean discard=TRUE; doc_wrapper *dw=NULL, *dwtmp; app_struct *app; app = (app_struct *) data; modcount = count_modified_documents (app->docs); // We try to avoid inconsistencies... if (app->docs->current_doc) { commit_or_reset (app->stack); } while (modcount) { if (modcount==1) { for (node = app->docs->doc_list; node; node = node->next) { dwtmp = (doc_wrapper *) node->data; if (dwtmp->if_modified) { dw = dwtmp; break; } } if (!dw) { my_msg("One document is marked as unsaved, but I'm not able to find it\nPlease save it with the menu bar", WARNING); return TRUE; } answer = doc_save_question(dw); if (answer==CANCEL_YESNO) return TRUE; // Quitting cancelled! else // We continue the process (quitting + freeing docs) break; } else { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); modal_dialog_with_titles_window_provided (window, save_all_dialog_new (window, app->docs), _("Exiting Geomorph"), (gpointer) gboolean_set_true, "Discard all and quit", (gpointer) gboolean_set_false, "Return", &discard, GTK_WIN_POS_CENTER, TRUE); if (discard) { // If there are less unsaved documents than before, // the user is still saving them, so we re-display // the dialog. // Otherwise, we continue the quitting process newmodcount = count_modified_documents (app->docs); if (newmodcount==modcount) break; else { modcount = newmodcount; continue; } } else // !discard return TRUE; // Quitting cancelled! } } gtk_main_quit(); // 2005-02: The "save" and the "destroy" parts are separated, // otherwise some events stay connected to freed structures for (node = app->docs->doc_list; node; node = node->next) { doc_wrapper_free((doc_wrapper *) node->data, FALSE); } // xalloc_print_all (); return TRUE; }