"Fossies" - the Fresh Open Source Software Archive

Member "gfsview-snapshot-121130/view/glade/callbacks.c" (30 Nov 2012, 54641 Bytes) of package /linux/privat/gfsview-snapshot-121130.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "callbacks.c" see the Fossies "Dox" file reference documentation.

    1 #ifdef HAVE_CONFIG_H
    2 #  include <config.h>
    3 #endif
    4 
    5 #include <math.h>
    6 #include <glob.h>
    7 #include <sys/types.h>
    8 #include <sys/stat.h>
    9 #include <unistd.h>
   10 #include <gtk/gtk.h>
   11 
   12 #include "callbacks.h"
   13 #include "interface.h"
   14 #include "support.h"
   15 #include "../gfkgl.h"
   16 #include "gl/trackball.h"
   17 
   18 gpointer lookup_gl (gpointer widget);
   19 
   20 gpointer lookup_gl (gpointer widget)
   21 {
   22   GtkWidget * parent;
   23   GfkGl * gl;
   24 
   25   for (;;)
   26     {
   27       if (GTK_IS_MENU (widget))
   28         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
   29       else
   30         parent = GTK_WIDGET (widget)->parent;
   31       if (parent == NULL)
   32         break;
   33       widget = parent;
   34     }
   35 
   36   gl = g_object_get_data (G_OBJECT (widget), "GfkGl");
   37   if (!gl)
   38     g_warning ("GfkGl not found");
   39   return gl;
   40 }
   41 
   42 gpointer lookup_widget_params (gpointer widget, const gchar * widget_name);
   43 
   44 gpointer lookup_widget_params (gpointer widget, const gchar * widget_name)
   45 {
   46   GtkWidget *parent, *found_widget;
   47 
   48   for (;;)
   49     {
   50       if (GTK_IS_MENU (widget))
   51         parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
   52       else
   53         parent = GTK_WIDGET (widget)->parent;
   54       if (parent == NULL || GTK_IS_NOTEBOOK (parent))
   55         break;
   56       widget = parent;
   57     }
   58 
   59   found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
   60                                                  widget_name);
   61   return found_widget;
   62 }
   63 
   64 void
   65 on_amin_toggled                        (GtkToggleButton *togglebutton,
   66                     gpointer user_data)
   67 {
   68   GfsGlScalar * gl = GFS_GL_SCALAR (GFK_GL (lookup_gl (togglebutton))->gl);
   69   GtkWidget * smin = lookup_widget_params (togglebutton, "spinbuttonmin");
   70 
   71   gl->amin = !gl->amin;
   72   gtk_widget_set_sensitive (smin, !gl->amin);
   73   if (gl->amin) {
   74     gtk_spin_button_set_value (GTK_SPIN_BUTTON (smin), gl->aminv);
   75     gl->min = gl->aminv;
   76   }
   77 }
   78 
   79 void
   80 on_amax_toggled                        (GtkToggleButton *togglebutton,
   81                                         gpointer         user_data)
   82 {
   83   GfsGlScalar * gl = GFS_GL_SCALAR (GFK_GL (lookup_gl (togglebutton))->gl);
   84   GtkWidget * smax = lookup_widget_params (togglebutton, "spinbuttonmax");
   85   
   86   gl->amax = !gl->amax;
   87   gtk_widget_set_sensitive (smax, !gl->amax);
   88   if (gl->amax) {
   89     gtk_spin_button_set_value (GTK_SPIN_BUTTON (smax), gl->amaxv);
   90     gl->max = gl->amaxv;
   91   }
   92 }
   93 
   94 void
   95 on_spinbuttonmin_changed               (GtkEditable     *editable,
   96                                         gpointer         user_data)
   97 {
   98   GtkSpinButton * min = GTK_SPIN_BUTTON (editable);
   99   GfkGl * gl = lookup_gl (editable);
  100   GfsGlScalar * gls = GFS_GL_SCALAR (gl->gl);
  101   gdouble v = gtk_spin_button_get_value_as_float (min);
  102 
  103   if (gls->min != v) {
  104     GtkSpinButton * max = lookup_widget_params (editable, "spinbuttonmax");
  105     GtkAdjustment * amax = gtk_spin_button_get_adjustment (max);
  106     gls->min = amax->lower = v;
  107     gtk_spin_button_set_adjustment (max, amax);
  108     gfk_gl_expose (gl);
  109   }
  110 }
  111 
  112 void
  113 on_spinbuttonmax_changed               (GtkEditable     *editable,
  114                                         gpointer         user_data)
  115 {
  116   GtkSpinButton * max = GTK_SPIN_BUTTON (editable);
  117   GfkGl * gl = lookup_gl (editable);
  118   GfsGlScalar * gls = GFS_GL_SCALAR (gl->gl);
  119   gdouble v = gtk_spin_button_get_value_as_float (max);
  120 
  121   if (gls->max != v) {
  122     GtkSpinButton * min = lookup_widget_params (editable, "spinbuttonmin");
  123     GtkAdjustment * amin = gtk_spin_button_get_adjustment (min);
  124     gls->max = amin->upper = v;
  125     gtk_spin_button_set_adjustment (min, amin);
  126     gfk_gl_expose (gl);
  127   }
  128 }
  129 
  130 void
  131 expose_gl                              (GtkToggleButton *togglebutton,
  132                                         gpointer         user_data)
  133 {
  134   gfk_gl_expose (lookup_gl (togglebutton));
  135 }
  136 
  137 void
  138 on_scale_changed                       (GtkEditable     *editable,
  139                                         gpointer         user_data)
  140 {
  141   GfkGl * gl = lookup_gl (editable);
  142   GfsGlVectors * glv = GFS_GL_VECTORS (gl->gl);
  143   gdouble scale = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
  144 
  145   if (scale != glv->scale) {
  146     glv->scale = scale;
  147     gfk_gl_expose (gl);
  148   }
  149 }
  150 
  151 void
  152 on_open1_activate                      (GtkMenuItem     *menuitem,
  153                                         gpointer         user_data)
  154 {
  155   gtk_widget_show (lookup_widget (GTK_WIDGET (menuitem), "filew"));
  156 }
  157 
  158 
  159 void
  160 on_save1_activate                    (GtkMenuItem     *menuitem,
  161                       gpointer         user_data)
  162 {
  163   gtk_widget_show (lookup_widget (GTK_WIDGET (menuitem), "gl2ps"));
  164 }
  165 
  166 
  167 void
  168 on_delete_activate                     (GtkMenuItem     *menuitem,
  169                                         gpointer         user_data)
  170 {
  171   GtkWidget * list = lookup_widget (GTK_WIDGET (menuitem), "gl_list");
  172   GtkTreeSelection * select = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
  173   GtkTreeModel * model;
  174   GtkTreeIter iter;
  175 
  176   if (gtk_tree_selection_get_selected (select, &model, &iter)) {
  177     GfkGl * gl;
  178 
  179     gtk_tree_model_get (model, &iter, GL_COLUMN, &gl, -1);
  180     gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
  181     if (g_object_get_data (G_OBJECT (list), "former") == gl)
  182       g_object_set_data (G_OBJECT (list), "former", NULL);
  183     gtk_widget_set_sensitive (lookup_widget (list, "properties1"), FALSE);
  184     gtk_widget_set_sensitive (lookup_widget (list, "delete3"), FALSE);
  185     gfk_gl_expose (gl);
  186     gts_object_destroy (GTS_OBJECT (gl));
  187   }
  188 }
  189 
  190 
  191 void
  192 on_color_clicked                       (GtkButton       *button,
  193                                         gpointer         user_data)
  194 {
  195   GfkGl * gl = lookup_gl (button);
  196   gtk_widget_show (gl->color_selector);
  197 }
  198 
  199 
  200 void
  201 on_maxlevel_changed                    (GtkEditable     *editable,
  202                                         gpointer         user_data)
  203 {
  204   GfkGl * gl = lookup_gl (editable);
  205   guint maxlevel = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editable));
  206 
  207   if (maxlevel != gl->gl->maxlevel) {
  208     gl->gl->maxlevel = maxlevel;
  209     gfk_gl_expose (gl);
  210   }
  211 }
  212 
  213 
  214 void
  215 on_linewidth_value_changed             (GtkSpinButton    *spinbutton,
  216                                         gpointer         user_data)
  217 {
  218   GfkGl * gl = lookup_gl (spinbutton);
  219   gfloat lw = gtk_spin_button_get_value (spinbutton);
  220 
  221   if (lw != gl->gl->line_width) {
  222     gl->gl->line_width = lw;
  223     gfk_gl_expose (gl);
  224   }
  225 }
  226 
  227 
  228 void
  229 on_finest_toggled                      (GtkToggleButton *togglebutton,
  230                                         gpointer         user_data)
  231 {
  232   GfkGl * gl = lookup_gl (togglebutton);
  233   GtkWidget * widget = lookup_widget_params (togglebutton, "maxlevel");
  234     
  235   if (gl->gl->maxlevel == -1) {
  236     gl->gl->maxlevel = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
  237     gtk_widget_set_sensitive (widget, TRUE);
  238   }
  239   else {
  240     GtkAdjustment * amax = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
  241     gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), amax->upper);
  242     gl->gl->maxlevel = -1;
  243     gtk_widget_set_sensitive (widget, FALSE);
  244   }
  245   gfk_gl_expose (gl);
  246 }
  247 
  248 
  249 void
  250 on_constant1_activate                  (GtkMenuItem     *menuitem,
  251                                         gpointer         user_data)
  252 {
  253 
  254 }
  255 
  256 
  257 void
  258 on_flat1_activate                      (GtkMenuItem     *menuitem,
  259                                         gpointer         user_data)
  260 {
  261 
  262 }
  263 
  264 
  265 void
  266 on_smooth1_activate                    (GtkMenuItem     *menuitem,
  267                                         gpointer         user_data)
  268 {
  269 
  270 }
  271 
  272 
  273 void
  274 on_csmooth1_activate                   (GtkMenuItem     *menuitem,
  275                                         gpointer         user_data)
  276 {
  277 
  278 }
  279 
  280 
  281 void
  282 on_color_selector_clicked              (GtkButton       *button,
  283                                         gpointer         user_data)
  284 {
  285   GtkWidget * color_selection = lookup_widget (GTK_WIDGET (button), "colorselection1");
  286   GfkGl * gl = lookup_gl (button);
  287   GtkWidget * color_button = lookup_widget_params (gl->properties, "default_color");
  288   GdkColor c;
  289 
  290   gtk_widget_hide (lookup_widget (GTK_WIDGET (button), "color_selector"));
  291   gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (color_selection), &c);
  292   gtk_widget_modify_bg (color_button, GTK_STATE_NORMAL, &c);
  293   gtk_widget_modify_bg (color_button, GTK_STATE_PRELIGHT, &c);
  294   gtk_widget_modify_bg (color_button, GTK_STATE_ACTIVE, &c);
  295   gl->gl->lc.r = c.red/(gdouble)65535;
  296   gl->gl->lc.g = c.green/(gdouble)65535;
  297   gl->gl->lc.b = c.blue/(gdouble)65535;
  298   gfk_gl_expose (gl);
  299 }
  300 
  301 void
  302 on_clear1_activate                     (GtkMenuItem     *menuitem,
  303                                         gpointer         user_data)
  304 {
  305   gfk_gl_view_clear (GTK_WIDGET (menuitem));
  306 }
  307 
  308 
  309 void
  310 on_properties1_activate                (GtkMenuItem     *menuitem,
  311                                         gpointer         user_data)
  312 {
  313   GtkWidget * list = lookup_widget (GTK_WIDGET (menuitem), "gl_list");
  314   GtkTreeSelection * select = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
  315   GtkTreeModel * model;
  316   GtkTreeIter iter;
  317 
  318   if (gtk_tree_selection_get_selected (select, &model, &iter)) {
  319     GfkGl * gl, * former = g_object_get_data (G_OBJECT (list), "former");
  320 
  321     gtk_tree_model_get (model, &iter, GL_COLUMN, &gl, -1);
  322     if (former != gl) {
  323       if (former) {
  324     gint x, y;
  325     gtk_window_get_position (GTK_WINDOW (former->params), &x, &y);
  326     gtk_window_move (GTK_WINDOW (gl->params), x, y);
  327     gtk_widget_show (gl->params);
  328     gtk_widget_hide (former->params);
  329       }
  330       else
  331     gtk_widget_show (gl->params);
  332       g_object_set_data (G_OBJECT (list), "former", gl);
  333     }
  334   }
  335 }
  336 
  337 
  338 void
  339 on_preferences1_activate               (GtkMenuItem     *menuitem,
  340                                         gpointer         user_data)
  341 {
  342   gtk_widget_show (lookup_widget (GTK_WIDGET (menuitem), "preferences"));
  343 }
  344 
  345 
  346 void
  347 on_resolution_changed                  (GtkEditable     *editable,
  348                                         gpointer         user_data)
  349 {
  350   GtkWidget * view = lookup_widget (GTK_WIDGET (editable), "view");
  351   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
  352   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
  353   gdouble res = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
  354 
  355   if (res != p->base_res) {
  356     p->res = p->base_res = res;
  357     gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
  358   }
  359 }
  360 
  361 
  362 void
  363 on_lines_closer_changed                (GtkEditable     *editable,
  364                                         gpointer         user_data)
  365 {
  366   GtkWidget * view = lookup_widget (GTK_WIDGET (editable), "view");
  367   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
  368   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
  369   gdouble lc = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
  370 
  371   if (lc != p->lc) {
  372     p->lc = lc;
  373     gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
  374   }
  375 }
  376 
  377 void
  378 on_reactivity_changed                  (GtkEditable     *editable,
  379                                         gpointer         user_data)
  380 {
  381   GtkWidget * view = lookup_widget (GTK_WIDGET (editable), "view");
  382   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
  383   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
  384   
  385   p->reactivity = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
  386 }
  387 
  388 void
  389 on_bgcolor_clicked                     (GtkButton       *button,
  390                                         gpointer         user_data)
  391 {
  392   gtk_widget_show (g_object_get_data (G_OBJECT (button), "colorsel"));
  393 }
  394 
  395 
  396 void
  397 on_bg_color_selector_clicked           (GtkButton       *button,
  398                                         gpointer         user_data)
  399 {
  400   GtkWidget * color_selection = lookup_widget (GTK_WIDGET (button), "colorselection2");
  401   GtkWidget * color_button = lookup_widget (GTK_WIDGET (button), "bgcolor");
  402   GtkWidget * view = lookup_widget (GTK_WIDGET (color_button), "view");
  403   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
  404   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
  405   GdkColor c;
  406 
  407   gtk_widget_hide (lookup_widget (GTK_WIDGET (button), "bg_color_selector"));
  408   gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (color_selection), &c);
  409   gtk_widget_modify_bg (color_button, GTK_STATE_NORMAL, &c);
  410   gtk_widget_modify_bg (color_button, GTK_STATE_PRELIGHT, &c);
  411   gtk_widget_modify_bg (color_button, GTK_STATE_ACTIVE, &c);
  412   p->bg.r = c.red/(gdouble)65535;
  413   p->bg.g = c.green/(gdouble)65535;
  414   p->bg.b = c.blue/(gdouble)65535;
  415   gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
  416 }
  417 
  418 void gl2ps_ppm_set_sensitive (GtkWidget * w, gboolean s, gboolean s1);
  419 
  420 void gl2ps_ppm_set_sensitive (GtkWidget * w, gboolean s, gboolean s1)
  421 {
  422   gtk_widget_set_sensitive (lookup_widget (w, "orientationlabel"), s);
  423   gtk_widget_set_sensitive (lookup_widget (w, "orientationmenu"), s);
  424   gtk_widget_set_sensitive (lookup_widget (w, "label25"), s);
  425   gtk_widget_set_sensitive (lookup_widget (w, "spinbutton1"), s);
  426 
  427   if (s)
  428     gtk_widget_show (lookup_widget (w, "gl2ps_options"));
  429   else
  430     gtk_widget_hide (lookup_widget (w, "gl2ps_options"));
  431   if (s1)
  432     gtk_widget_show (lookup_widget (w, "ppm_options"));
  433   else
  434     gtk_widget_hide (lookup_widget (w, "ppm_options"));
  435 }
  436 
  437 #define gl2psparams(x) ((GfsGl2PSParams *) g_object_get_data (G_OBJECT (lookup_widget (GTK_WIDGET (x), "gl2ps")), "GfsGl2PSParams"))
  438 
  439 static void set_extension (GtkMenuItem * item, const gchar * ext)
  440 {
  441   GtkEntry * entry = GTK_ENTRY (lookup_widget (GTK_WIDGET (item), "entry2"));
  442   const gchar * fname = gtk_entry_get_text (entry);
  443 
  444   if (fname != NULL) {
  445     gchar * fname1 = g_strdup (fname), * c = fname1, * e = NULL;
  446 
  447     while (*c != '\0') {
  448       if (*c == '.')
  449     e = c;
  450       c++;
  451     }
  452     if (e != NULL) {
  453       gchar * fname2;
  454 
  455       *e = '\0';
  456       fname2 = g_strconcat (fname1, ".", ext, NULL);
  457       gtk_entry_set_text (entry, fname2);
  458       g_free (fname2);
  459     }
  460     g_free (fname1);
  461   }
  462 }
  463 
  464 void
  465 on_portable_pixmap1_activate           (GtkMenuItem     *menuitem,
  466                                         gpointer         user_data)
  467 {
  468   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), FALSE, TRUE);
  469   set_extension (menuitem, "ppm");
  470   gl2psparams (menuitem)->format = GFSGL_PPM;
  471 }
  472 
  473 
  474 void
  475 on_postscript1_activate                (GtkMenuItem     *menuitem,
  476                                         gpointer         user_data)
  477 {
  478   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  479   set_extension (menuitem, "ps");
  480   gl2psparams (menuitem)->format = GL2PS_PS;
  481 }
  482 
  483 
  484 void
  485 on_encapsulated_postscript1_activate   (GtkMenuItem     *menuitem,
  486                                         gpointer         user_data)
  487 {
  488   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  489   set_extension (menuitem, "eps");
  490   gl2psparams (menuitem)->format = GL2PS_EPS;
  491 }
  492 
  493 
  494 void
  495 on_portable_document_format1_activate  (GtkMenuItem     *menuitem,
  496                                         gpointer         user_data)
  497 {
  498   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  499   set_extension (menuitem, "pdf");
  500   gl2psparams (menuitem)->format = GL2PS_PDF;
  501 }
  502 
  503 
  504 void
  505 on_scalable_vector_graphics_activate (GtkMenuItem     *menuitem,
  506                       gpointer         user_data)
  507 {
  508   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  509   set_extension (menuitem, "svg");
  510   gl2psparams (menuitem)->format = GL2PS_SVG;
  511 }
  512 
  513 
  514 void
  515 on_gnuplot1_activate                   (GtkMenuItem     *menuitem,
  516                                         gpointer         user_data)
  517 {
  518   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  519   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationlabel"), FALSE);
  520   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationmenu"), FALSE);
  521   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "label25"), FALSE);
  522   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "spinbutton1"), FALSE);  
  523   set_extension (menuitem, "gnu");
  524   gl2psparams (menuitem)->format = GFSGL_GNUPLOT;
  525 }
  526 
  527 
  528 void
  529 on_wavefront_obj1_activate             (GtkMenuItem     *menuitem,
  530                                         gpointer         user_data)
  531 {
  532   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  533   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationlabel"), FALSE);
  534   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationmenu"), FALSE);
  535   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "label25"), FALSE);
  536   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "spinbutton1"), FALSE);  
  537   set_extension (menuitem, "obj");
  538   gl2psparams (menuitem)->format = GFSGL_OBJ;
  539 }
  540 
  541 
  542 void
  543 on_kml_obj_activate             (GtkMenuItem     *menuitem,
  544                  gpointer         user_data)
  545 {
  546   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), TRUE, FALSE);
  547   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationlabel"), FALSE);
  548   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationmenu"), FALSE);
  549   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "label25"), FALSE);
  550   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "spinbutton1"), FALSE);  
  551   set_extension (menuitem, "kml");
  552   gl2psparams (menuitem)->format = GFSGL_KML;
  553 }
  554 
  555 
  556 void
  557 on_latex1_activate                     (GtkMenuItem     *menuitem,
  558                                         gpointer         user_data)
  559 {
  560   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), FALSE, FALSE);
  561   set_extension (menuitem, "tex");
  562   gl2psparams (menuitem)->format = GL2PS_TEX;
  563 }
  564 
  565 
  566 static void gl2pstoggle (gpointer w, GLint option)
  567 {
  568   GfsGl2PSParams * q = gl2psparams (w);
  569 
  570   if (q->options & option)
  571     q->options &= ~option;
  572   else
  573     q->options |= option;
  574 }
  575 
  576 
  577 void
  578 on_none1_activate                      (GtkMenuItem     *menuitem,
  579                                         gpointer         user_data)
  580 {
  581   gl2psparams (menuitem)->sort = GL2PS_NO_SORT;
  582 }
  583 
  584 
  585 void
  586 on_barycenter1_activate                (GtkMenuItem     *menuitem,
  587                                         gpointer         user_data)
  588 {
  589   gl2psparams (menuitem)->sort = GL2PS_SIMPLE_SORT;
  590 }
  591 
  592 
  593 void
  594 on_bsp_tree1_activate                  (GtkMenuItem     *menuitem,
  595                                         gpointer         user_data)
  596 {
  597   gl2psparams (menuitem)->sort = GL2PS_BSP_SORT;
  598 }
  599 
  600 
  601 void
  602 on_portrait1_activate                  (GtkMenuItem     *menuitem,
  603                                         gpointer         user_data)
  604 {
  605   gl2psparams (menuitem)->options &= ~GL2PS_LANDSCAPE;
  606 }
  607 
  608 
  609 void
  610 on_landscape1_activate                 (GtkMenuItem     *menuitem,
  611                                         gpointer         user_data)
  612 {
  613   gl2psparams (menuitem)->options |= GL2PS_LANDSCAPE;
  614 }
  615 
  616 
  617 void
  618 on_line_width_changed                  (GtkSpinButton    *editable,
  619                                         gpointer         user_data)
  620 {
  621   gl2psparams (editable)->lw = gtk_spin_button_get_value_as_float (editable);
  622 }
  623 
  624 
  625 void
  626 on_line_offset_toggled                 (GtkToggleButton *togglebutton,
  627                                         gpointer         user_data)
  628 {
  629   gl2pstoggle (togglebutton, GL2PS_SIMPLE_LINE_OFFSET);
  630 }
  631 
  632 
  633 void
  634 on_best_root_toggled                   (GtkToggleButton *togglebutton,
  635                                         gpointer         user_data)
  636 {
  637   gl2pstoggle (togglebutton, GL2PS_BEST_ROOT);
  638 }
  639 
  640 
  641 void
  642 on_no_text_toggled                     (GtkToggleButton *togglebutton,
  643                                         gpointer         user_data)
  644 {
  645   gl2pstoggle (togglebutton, GL2PS_NO_TEXT);
  646 }
  647 
  648 
  649 void
  650 on_no_pixmap_toggled                   (GtkToggleButton *togglebutton,
  651                                         gpointer         user_data)
  652 {
  653   gl2pstoggle (togglebutton, GL2PS_NO_PIXMAP);
  654 }
  655 
  656 
  657 void
  658 on_no_ps3_toggled                      (GtkToggleButton *togglebutton,
  659                                         gpointer         user_data)
  660 {
  661   gl2pstoggle (togglebutton, GL2PS_NO_PS3_SHADING);
  662 }
  663 
  664 static gint browse_ok (GtkWidget * widget, GtkWidget * filew)
  665 {
  666   GtkWidget * gl2ps = g_object_get_data (G_OBJECT (filew), "gl2ps");
  667 
  668   gtk_entry_set_text (GTK_ENTRY (lookup_widget (gl2ps, "entry2")),
  669               gtk_file_selection_get_filename (GTK_FILE_SELECTION (filew)));
  670   gtk_widget_destroy (filew);
  671   return TRUE;
  672 }
  673 
  674 void
  675 on_browse_clicked                      (GtkButton       *button,
  676                                         gpointer         user_data)
  677 {
  678   GtkWidget * filew = gtk_file_selection_new ("Save as");
  679 
  680   gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew),
  681                    gtk_entry_get_text (GTK_ENTRY (lookup_widget 
  682                                   (GTK_WIDGET (button), 
  683                                    "entry2"))));
  684   g_object_set_data (G_OBJECT (filew), "gl2ps", lookup_widget (GTK_WIDGET (button), "gl2ps"));
  685   g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), "clicked",
  686             G_CALLBACK (browse_ok), filew);
  687 
  688   g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", 
  689                 G_CALLBACK (gtk_widget_destroy), filew);
  690   gtk_widget_show (filew);
  691 }
  692 
  693 
  694 static void refine_cell_corner (FttCell * cell, GfsDomain * domain)
  695 {
  696   if (FTT_CELL_IS_LEAF (cell) && ftt_refine_corner (cell))
  697     ftt_cell_refine_single (cell, (FttCellInitFunc) gfs_cell_fine_init, domain);
  698 }
  699 
  700 void
  701 on_save_as_button_clicked              (GtkButton       *button,
  702                                         gpointer         user_data)
  703 {
  704   GfsGl2PSParams * p = gl2psparams (button);
  705   GtkWidget * view = lookup_widget (GTK_WIDGET (button), "view");
  706   const gchar * fname = 
  707     gtk_entry_get_text (GTK_ENTRY (lookup_widget (GTK_WIDGET (button), "entry2")));
  708   FILE * fp;
  709 
  710   if (fname == NULL || fname[0] == '\0') {
  711     GtkWidget * msg = gtk_message_dialog_new (GTK_WINDOW (view),
  712                           GTK_DIALOG_DESTROY_WITH_PARENT,
  713                           GTK_MESSAGE_WARNING,
  714                           GTK_BUTTONS_CLOSE,
  715                           "You must first select a filename");
  716     gtk_dialog_run (GTK_DIALOG (msg));
  717     gtk_widget_destroy (msg);
  718     return;
  719   }
  720   fp = fopen (fname, "w");
  721   if (!fp) {
  722     GtkWidget * msg = gtk_message_dialog_new (GTK_WINDOW (view),
  723                           GTK_DIALOG_DESTROY_WITH_PARENT,
  724                           GTK_MESSAGE_WARNING,
  725                           GTK_BUTTONS_CLOSE,
  726                           "Cannot open file `%s`",
  727                           fname);
  728     gtk_dialog_run (GTK_DIALOG (msg));
  729     gtk_widget_destroy (msg);
  730     return;
  731   }
  732   switch (p->format) {
  733   case GFSGL_GERRIS: {
  734     GtkWidget * glarea = lookup_widget (view, "glarea");
  735     GfsSimulation * sim = g_object_get_data (G_OBJECT (glarea), "sim");
  736     GfsDomain * domain = GFS_DOMAIN (sim);
  737     gint l;
  738     for (l = gfs_domain_depth (domain) - 2; l >= 0; l--)
  739       gfs_domain_cell_traverse (domain, 
  740                 FTT_PRE_ORDER, FTT_TRAVERSE_LEVEL, l,
  741                 (FttCellTraverseFunc) refine_cell_corner, domain);
  742     gfs_simulation_write (sim, -1, fp);
  743     /* fall through */
  744   }
  745   case GFSGL_GFSVIEW: {
  746     GtkWidget * glarea = lookup_widget (view, "glarea");
  747     GtkTreeModel * list = 
  748       gtk_tree_view_get_model (GTK_TREE_VIEW (lookup_widget (view, "gl_list")));
  749     GtkTreeIter iter;
  750     gboolean valid = gtk_tree_model_get_iter_first (list, &iter);
  751 
  752     fprintf (fp, "# GfsView %dD\n", FTT_DIMENSION);
  753     gfs_gl_view_params_write (g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams"), fp);
  754     fputc ('\n', fp);
  755     while (valid) {
  756       gboolean visible;
  757       GtsObject * gl;
  758       
  759       gtk_tree_model_get (list, &iter, GL_COLUMN, &gl, VISIBLE_COLUMN, &visible, -1);
  760       if (visible) {
  761     (* gl->klass->write) (gl, fp);
  762     fputc ('\n', fp);
  763       }
  764       valid = gtk_tree_model_iter_next (list, &iter);
  765     }
  766     break;
  767   }
  768   default:
  769     gfs_gl2ps (p, fp, fname, view);
  770   }
  771   fclose (fp);
  772   gtk_widget_hide (lookup_widget (view, "gl2ps"));
  773 }
  774 
  775 void
  776 on_about1_activate                     (GtkMenuItem     *menuitem,
  777                                         gpointer         user_data)
  778 {
  779   gtk_widget_show (lookup_widget (GTK_WIDGET (menuitem), "about"));
  780 }
  781 
  782 static 
  783 void 
  784 rotate_view                               (GtkMenuItem     *menuitem, 
  785                        float * n, 
  786                        float alpha)
  787 {
  788   GtkWidget * glarea = lookup_widget (GTK_WIDGET (menuitem), "glarea");
  789   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
  790 
  791   p->dquat[0] = p->dquat[1] = p->dquat[2] = 0; p->dquat[3] = 1.;
  792   gfs_gl_axis_to_quat (n, alpha, p->quat);
  793   gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
  794 }
  795 
  796 void
  797 on_front1_activate                     (GtkMenuItem     *menuitem,
  798                                         gpointer         user_data)
  799 {
  800   float n[3] = { 0., 0., 1. };
  801   rotate_view (menuitem, n, 0.);
  802 }
  803 
  804 
  805 void
  806 on_back1_activate                      (GtkMenuItem     *menuitem,
  807                                         gpointer         user_data)
  808 {
  809   float n[3] = { 0., 1., 0. };
  810   rotate_view (menuitem, n, M_PI);
  811 }
  812 
  813 
  814 void
  815 on_top1_activate                       (GtkMenuItem     *menuitem,
  816                                         gpointer         user_data)
  817 {
  818   float n[3] = { 1., 0., 0. };
  819   rotate_view (menuitem, n, - M_PI/2.);
  820 }
  821 
  822 
  823 void
  824 on_bottom1_activate                    (GtkMenuItem     *menuitem,
  825                                         gpointer         user_data)
  826 {
  827   float n[3] = { 1., 0., 0. };
  828   rotate_view (menuitem, n, M_PI/2.);
  829 }
  830 
  831 
  832 void
  833 on_left1_activate                      (GtkMenuItem     *menuitem,
  834                                         gpointer         user_data)
  835 {
  836   float n[3] = { 0., 1., 0. };
  837   rotate_view (menuitem, n, - M_PI/2.);
  838 }
  839 
  840 
  841 void
  842 on_right1_activate                     (GtkMenuItem     *menuitem,
  843                                         gpointer         user_data)
  844 {
  845   float n[3] = { 0., 1., 0. };
  846   rotate_view (menuitem, n, M_PI/2.);
  847 }
  848 
  849 void
  850 on_entry2_changed                      (GtkEditable     *editable,
  851                                         gpointer         user_data)
  852 {
  853   const gchar * fname = gtk_entry_get_text (GTK_ENTRY (editable));
  854 
  855   if (fname != NULL) {
  856     const gchar * c = fname, * e = NULL;
  857 
  858     while (*c != '\0') {
  859       if (*c == '.')
  860     e = c;
  861       c++;
  862     }
  863     if (e != NULL) {
  864       GtkOptionMenu * menu = GTK_OPTION_MENU (lookup_widget (GTK_WIDGET (editable), 
  865                                  "format"));
  866 
  867       if (!strcmp (e, ".ppm")) {
  868     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), FALSE, TRUE);
  869     gtk_option_menu_set_history (menu, 0);
  870     gl2psparams (menu)->format = GFSGL_PPM;
  871       }
  872       else if (!strcmp (e, ".ps")) {
  873     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  874     gtk_option_menu_set_history (menu, 1);
  875     gl2psparams (menu)->format = GL2PS_PS;
  876       }
  877       else if (!strcmp (e, ".eps")) {
  878     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  879     gtk_option_menu_set_history (menu, 2);
  880     gl2psparams (menu)->format = GL2PS_EPS;
  881       }
  882       else if (!strcmp (e, ".pdf")) {
  883     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  884     gtk_option_menu_set_history (menu, 3);
  885     gl2psparams (menu)->format = GL2PS_PDF;
  886       }
  887       else if (!strcmp (e, ".svg")) {
  888     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  889     gtk_option_menu_set_history (menu, 4);
  890     gl2psparams (menu)->format = GL2PS_SVG;
  891       }
  892       else if (!strcmp (e, ".gnu")) {
  893     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  894     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "orientationlabel"), FALSE);
  895     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "orientationmenu"), FALSE);
  896     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "label25"), FALSE);
  897     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "spinbutton1"), FALSE);  
  898     gtk_option_menu_set_history (menu, 5);
  899     gl2psparams (menu)->format = GFSGL_GNUPLOT;
  900       }
  901       else if (!strcmp (e, ".obj")) {
  902     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  903     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "orientationlabel"), FALSE);
  904     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "orientationmenu"), FALSE);
  905     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "label25"), FALSE);
  906     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "spinbutton1"), FALSE);  
  907     gtk_option_menu_set_history (menu, 6);
  908     gl2psparams (menu)->format = GFSGL_OBJ;
  909       }
  910       else if (!strcmp (e, ".kml")) {
  911     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), TRUE, FALSE);
  912     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "orientationlabel"), FALSE);
  913     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "orientationmenu"), FALSE);
  914     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "label25"), FALSE);
  915     gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menu), "spinbutton1"), FALSE);  
  916     gtk_option_menu_set_history (menu, 7);
  917     gl2psparams (menu)->format = GFSGL_KML;
  918       }
  919       else if (!strcmp (e, ".tex")) {
  920     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), FALSE, FALSE);
  921     gtk_option_menu_set_history (menu, 8);
  922     gl2psparams (menu)->format = GL2PS_TEX;
  923       }
  924       else if (!strcmp (e, ".gfv")) {
  925     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), FALSE, FALSE);
  926     gtk_option_menu_set_history (menu, 9);
  927     gl2psparams (menu)->format = GFSGL_GFSVIEW;
  928       }
  929       else if (!strcmp (e, ".gfs")) {
  930     gl2ps_ppm_set_sensitive (GTK_WIDGET (menu), FALSE, FALSE);
  931     gtk_option_menu_set_history (menu, 10);
  932     gl2psparams (menu)->format = GFSGL_GERRIS;
  933       }
  934     }
  935   }
  936 }
  937 
  938 void
  939 on_spinbuttonx_changed                 (GtkEditable     *editable,
  940                                         gpointer         user_data)
  941 {
  942   GfkGl * gl = lookup_gl (editable);
  943   GfkGl2D * gl2 = GFK_GL2D (gl);
  944   gdouble nx = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editable));
  945 
  946   if (nx != gl2->n.x) {
  947     gl2->n.x = nx;
  948     if (gts_vector_norm (&gl2->n.x) == 0.) {
  949       gl2->n.x = 1.;
  950       gtk_spin_button_set_value (GTK_SPIN_BUTTON (editable), 1.);
  951     }
  952     GFS_GL2D (gl->gl)->n = gl2->n;
  953     gfs_gl2D_update_plane (GFS_GL2D (gl->gl));
  954     gfk_gl2D_update_pos_bounds (gl2);
  955     gfk_gl_expose (gl);
  956   }
  957 }
  958 
  959 
  960 void
  961 on_spinbuttony_changed                 (GtkEditable     *editable,
  962                                         gpointer         user_data)
  963 {
  964   GfkGl * gl = lookup_gl (editable);
  965   GfkGl2D * gl2 = GFK_GL2D (gl);
  966   gdouble ny = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editable));
  967 
  968   if (ny != gl2->n.y) {
  969     gl2->n.y = ny;
  970     if (gts_vector_norm (&gl2->n.x) == 0.) {
  971       gl2->n.y = 1.;
  972       gtk_spin_button_set_value (GTK_SPIN_BUTTON (editable), 1.);
  973     }
  974     GFS_GL2D (gl->gl)->n = gl2->n;
  975     gfs_gl2D_update_plane (GFS_GL2D (gl->gl));
  976     gfk_gl2D_update_pos_bounds (gl2);
  977     gfk_gl_expose (gl);    
  978   }
  979 }
  980 
  981 
  982 void
  983 on_spinbuttonz_changed                 (GtkEditable     *editable,
  984                                         gpointer         user_data)
  985 {
  986   GfkGl * gl = lookup_gl (editable);
  987   GfkGl2D * gl2 = GFK_GL2D (gl);
  988   gdouble nz = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editable));
  989 
  990   if (nz != gl2->n.z) {
  991     gl2->n.z = nz;
  992     if (gts_vector_norm (&gl2->n.x) == 0.) {
  993       gl2->n.z = 1.;
  994       gtk_spin_button_set_value (GTK_SPIN_BUTTON (editable), 1.);
  995     }
  996     GFS_GL2D (gl->gl)->n = gl2->n;
  997     gfs_gl2D_update_plane (GFS_GL2D (gl->gl));
  998     gfk_gl2D_update_pos_bounds (gl2);
  999     gfk_gl_expose (gl);    
 1000   }
 1001 }
 1002 
 1003 void
 1004 on_spinbuttonpos_changed               (GtkEditable     *editable,
 1005                                         gpointer         user_data)
 1006 {
 1007   GfkGl * gl = lookup_gl (editable);
 1008   GfsGl2D * gl2 = GFS_GL2D (gl->gl);
 1009   gdouble pos = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editable));
 1010 
 1011   if (pos != gl2->pos) {
 1012     gl2->pos = pos;
 1013     gfs_gl2D_update_plane (gl2);  
 1014     gfk_gl_expose (gl);    
 1015   }
 1016 }
 1017 
 1018 void
 1019 on_spinbuttonlevel_changed             (GtkEditable     *editable,
 1020                                         gpointer         user_data)
 1021 {
 1022 #if (!FTT_2D)
 1023   GfkGl * gl = lookup_gl (editable);
 1024   GfsGlIsosurface * gli = GFS_GL_ISOSURFACE (gl->gl);
 1025   gdouble level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editable));
 1026 
 1027   if (level != gli->level) {
 1028     gli->level = level;
 1029     gfs_gl_isosurface_reset (gli);
 1030     gfk_gl_expose (gl);
 1031   }
 1032 #endif /* 3D */
 1033 }
 1034 
 1035 
 1036 void
 1037 on_reversed_toggled                    (GtkToggleButton *togglebutton,
 1038                                         gpointer         user_data)
 1039 {
 1040 #if (!FTT_2D)
 1041   GfkGl * gl = lookup_gl (togglebutton);
 1042   GfsGlIsosurface * gli = GFS_GL_ISOSURFACE (gl->gl);
 1043   gli->reversed = !gli->reversed;
 1044   gfk_gl_expose (gl);
 1045 #endif /* 3D */
 1046 }
 1047 
 1048 
 1049 void
 1050 on_solid_reversed_toggled              (GtkToggleButton *togglebutton,
 1051                                         gpointer         user_data)
 1052 {
 1053 #if (!FTT_2D)
 1054   GfkGl * gl = lookup_gl (togglebutton);
 1055   GfsGlSolid * gls = GFS_GL_SOLID (gl->gl);
 1056   gls->reversed = !gls->reversed;
 1057   gfk_gl_expose (gl);
 1058 #endif /* 3D */
 1059 }
 1060 
 1061 gboolean
 1062 main_quit                              (GtkWidget       *widget,
 1063                                         GdkEvent        *event,
 1064                                         gpointer         user_data)
 1065 {
 1066   struct stat sb;
 1067   if (fstat (STDIN_FILENO, &sb) != -1 && 
 1068       (sb.st_mode & S_IFMT) == S_IFIFO &&
 1069       !feof (stdin)) {
 1070     GtkWidget * view = lookup_widget (widget, "view");
 1071     GtkWidget * msg = gtk_message_dialog_new (GTK_WINDOW (view),
 1072                           GTK_DIALOG_MODAL,
 1073                           GTK_MESSAGE_INFO,
 1074                           GTK_BUTTONS_OK_CANCEL,
 1075                           "GfsView is connected to another application\n"
 1076                           "Quitting GfsView now will also terminate this\n"
 1077                           "application");
 1078     if (gtk_dialog_run (GTK_DIALOG (msg)) == GTK_RESPONSE_OK) {
 1079       gtk_widget_destroy (msg);
 1080       gtk_main_quit ();
 1081     }
 1082     else
 1083       gtk_widget_destroy (msg);
 1084   }
 1085   else
 1086     gtk_main_quit ();
 1087   return TRUE;
 1088 }
 1089 
 1090 void
 1091 on_spinbuttoniso_value_changed         (GtkSpinButton   *spinbutton,
 1092                                         gpointer         user_data)
 1093 {
 1094   GfkGl * gl = lookup_gl (spinbutton);
 1095   GfsGlIsoline * gli = GFS_GL_ISOLINE (gl->gl);
 1096   gdouble n = gtk_spin_button_get_value (spinbutton);
 1097 
 1098   if (n != gli->n) {
 1099     gli->n = n;
 1100     gfk_gl_expose (gl);
 1101   }
 1102 }
 1103 
 1104 
 1105 void
 1106 on_entryiso_activate                   (GtkEntry        *entry,
 1107                                         gpointer         user_data)
 1108 {
 1109   GfkGl * gl = lookup_gl (entry);
 1110   GfsGlIsoline * gli = GFS_GL_ISOLINE (gl->gl);
 1111 
 1112   gfs_gl_isoline_set_levels (gli, gtk_entry_get_text (entry));
 1113   gfk_gl_expose (gl);
 1114 }
 1115 
 1116 
 1117 void
 1118 on_ellipse_scale_changed               (GtkSpinButton   *spinbutton,
 1119                                         gpointer         user_data)
 1120 {
 1121   GfkGl * gl = lookup_gl (spinbutton);
 1122   GfsGlEllipses * gle = GFS_GL_ELLIPSES (gl->gl);
 1123   gdouble scale = gtk_spin_button_get_value_as_float (spinbutton);
 1124 
 1125   if (scale != gle->scale) {
 1126     gle->scale = scale;
 1127     gfk_gl_expose (GFK_GL (gl));
 1128   }
 1129 }
 1130 
 1131 
 1132 void
 1133 on_symbol_size_value_changed           (GtkSpinButton   *spinbutton,
 1134                                         gpointer         user_data)
 1135 {
 1136   GfkGl * gl = lookup_gl (spinbutton);
 1137   GfsGlLocation * gll = GFS_GL_LOCATION (gl->gl);
 1138   gdouble size = gtk_spin_button_get_value_as_float (spinbutton);
 1139 
 1140   if (size != gll->size) {
 1141     gll->size = size;
 1142     gfk_gl_expose (gl);
 1143   }
 1144 }
 1145 
 1146 
 1147 void
 1148 on_substract1_activate                 (GtkMenuItem     *menuitem,
 1149                                         gpointer         user_data)
 1150 {
 1151   gtk_widget_show (lookup_widget (GTK_WIDGET (menuitem), "filews"));
 1152 }
 1153 
 1154 
 1155 void
 1156 on_back_clicked                        (GtkButton       *button,
 1157                                         gpointer         user_data)
 1158 {
 1159   GtkWidget * play = lookup_widget (GTK_WIDGET (button), "play");
 1160   glob_t * files = g_object_get_data (G_OBJECT (play), "glob_t");
 1161 
 1162   if (files->gl_offs > 0) {
 1163     GtkWidget * parent = g_object_get_data (G_OBJECT (play), "parent");
 1164 
 1165     gfk_gl_simulation_read (files->gl_pathv[--files->gl_offs], parent, TRUE);
 1166     if (files->gl_offs == 0)
 1167       gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
 1168     if (files->gl_offs == files->gl_pathc - 2)
 1169       gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (button), "forward"), TRUE);
 1170   } 
 1171 }
 1172 
 1173 
 1174 void
 1175 on_forward_clicked                     (GtkButton       *button,
 1176                                         gpointer         user_data)
 1177 {
 1178   GtkWidget * play = lookup_widget (GTK_WIDGET (button), "play");
 1179   glob_t * files = g_object_get_data (G_OBJECT (play), "glob_t");
 1180 
 1181   if (files->gl_offs < files->gl_pathc - 1) {
 1182     GtkWidget * parent = g_object_get_data (G_OBJECT (play), "parent");
 1183    
 1184     gfk_gl_simulation_read (files->gl_pathv[++files->gl_offs], parent, TRUE);
 1185     if (files->gl_offs == files->gl_pathc - 1)
 1186       gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
 1187     if (files->gl_offs == 1)
 1188       gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (button), "back"), TRUE);
 1189   }
 1190 }
 1191 
 1192 
 1193 void
 1194 on_gfsview_activate                    (GtkMenuItem     *menuitem,
 1195                                         gpointer         user_data)
 1196 {
 1197   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), FALSE, FALSE);
 1198   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationlabel"), FALSE);
 1199   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationmenu"), FALSE);
 1200   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "label25"), FALSE);
 1201   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "spinbutton1"), FALSE);
 1202   set_extension (menuitem, "gfv");
 1203   gl2psparams (menuitem)->format = GFSGL_GFSVIEW;
 1204 }
 1205 
 1206 
 1207 void
 1208 on_gerris_activate                     (GtkMenuItem     *menuitem,
 1209                                         gpointer         user_data)
 1210 {
 1211   gl2ps_ppm_set_sensitive (GTK_WIDGET (menuitem), FALSE, FALSE);
 1212   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationlabel"), FALSE);
 1213   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "orientationmenu"), FALSE);
 1214   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "label25"), FALSE);
 1215   gtk_widget_set_sensitive (lookup_widget (GTK_WIDGET (menuitem), "spinbutton1"), FALSE);
 1216   set_extension (menuitem, "gfs");
 1217   gl2psparams (menuitem)->format = GFSGL_GERRIS;
 1218 }
 1219 
 1220 
 1221 void
 1222 on_scripting_toggled                   (GtkToggleButton *togglebutton,
 1223                                         gpointer         user_data)
 1224 {
 1225   G_LOCK (gfk_gl_scripting);
 1226   gfk_gl_scripting = !gfk_gl_scripting;
 1227   G_UNLOCK (gfk_gl_scripting);
 1228 }
 1229 
 1230 void
 1231 mark_edited                           (GtkEditable     *editable,
 1232                        gpointer         user_data)
 1233 {
 1234   g_object_set_data (G_OBJECT (editable), "edited", editable);
 1235 }
 1236 
 1237 void
 1238 unmark_edited                          (GObject   *object,
 1239                                         gpointer         user_data)
 1240 {
 1241   g_object_set_data (object, "edited", NULL);
 1242 }
 1243 
 1244 void
 1245 on_delete_streamline_clicked           (GtkButton       *button,
 1246                                         gpointer         user_data)
 1247 {
 1248   GfkGl * gl = lookup_gl (button);
 1249 
 1250   if (gfs_gl_streamlines_remove_selected (GFS_GL_STREAMLINES (gl->gl))) {
 1251     gtk_widget_set_sensitive (lookup_widget_params (GFK_GL_STREAMLINES (gl)->stream, "delete"), 
 1252                   FALSE);
 1253     gfk_gl_expose (gl);
 1254   }
 1255 }
 1256 
 1257 void
 1258 on_new_streamline_toggled              (GtkToggleButton *togglebutton,
 1259                                         gpointer         user_data)
 1260 {
 1261   GfkGlStreamlines * gl = lookup_gl (togglebutton);
 1262 
 1263   if (gtk_toggle_button_get_active (togglebutton)) {
 1264     if (GFS_GL_STREAMLINES (GFK_GL (gl)->gl)->selected) {
 1265       GFS_GL_STREAMLINES (GFK_GL (gl)->gl)->selected = NULL;
 1266       gtk_widget_set_sensitive (lookup_widget_params (gl->stream, "delete"), FALSE);
 1267       gfk_gl_expose (GFK_GL (gl));
 1268     }
 1269     gl->edit = FALSE;
 1270   }
 1271   else
 1272     gl->edit = TRUE;
 1273 }
 1274 
 1275 
 1276 void
 1277 on_show_cells_toggled                  (GtkToggleButton *togglebutton,
 1278                                         gpointer         user_data)
 1279 {
 1280   GfkGl * gl = lookup_gl (togglebutton);
 1281   
 1282   GFS_GL_STREAMLINES (gl->gl)->show_cells = gtk_toggle_button_get_active (togglebutton);
 1283   gfk_gl_expose (gl);
 1284 }
 1285 
 1286 void
 1287 on_dmin_changed                        (GtkSpinButton   *spinbutton,
 1288                                         gpointer         user_data)
 1289 {
 1290   GfkGl * gl = lookup_gl (spinbutton);
 1291   GfsGlStreamlines * gls = GFS_GL_STREAMLINES (gl->gl);
 1292   gdouble v = gtk_spin_button_get_value (spinbutton);
 1293 
 1294   if (gls->dmin != v) {
 1295     GfkGlStreamlines * glk = GFK_GL_STREAMLINES (gl);
 1296 
 1297     if (v > 0.)
 1298       gtk_widget_set_sensitive (lookup_widget_params (glk->stream, "evenly_spaced"), TRUE);
 1299     else
 1300       gtk_widget_set_sensitive (lookup_widget_params (glk->stream, "evenly_spaced"), FALSE);
 1301     gls->dmin = v;
 1302     gfs_gl_streamlines_reset (gls);
 1303     gfk_gl_expose (gl);
 1304   }
 1305 }
 1306 
 1307 static gboolean callback (GfsGlStreamlines * gls, gpointer data)
 1308 {
 1309   GfkGlStreamlines * gl = data;
 1310 
 1311   if (gtk_toggle_button_get_active (lookup_widget_params (gl->stream, "show_execution")))
 1312     gfk_gl_expose (GFK_GL (gl));
 1313   while (gtk_events_pending ())
 1314     gtk_main_iteration ();
 1315   return (g_object_get_data (lookup_widget_params (gl->stream, "stop_evenly"), "stop") != NULL);
 1316 }
 1317 
 1318 void
 1319 on_evenly_spaced_clicked               (GtkButton       *button,
 1320                                         gpointer         user_data)
 1321 {
 1322   GfkGl * gl = lookup_gl (button);
 1323   GfkGlStreamlines * glk = GFK_GL_STREAMLINES (gl);
 1324   GfsGlStreamlines * gls = GFS_GL_STREAMLINES (gl->gl);
 1325   GtkWidget * stop = lookup_widget_params (glk->stream, "stop_evenly");
 1326   GtkWidget * view = lookup_widget (gl->list, "view");
 1327   GtkWidget * pref = g_object_get_data (G_OBJECT (view), "preferences");
 1328   GtkToggleButton * scripting_on = GTK_TOGGLE_BUTTON (lookup_widget (pref, "scripting_on"));
 1329   GtkToggleButton * scripting_off = GTK_TOGGLE_BUTTON (lookup_widget (pref, "scripting_off"));
 1330   gboolean sensitive, scripting;
 1331 
 1332   gtk_widget_set_sensitive (stop, TRUE);
 1333   g_object_set_data (G_OBJECT (stop), "stop", NULL);
 1334   gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
 1335 
 1336   if ((scripting = gtk_toggle_button_get_active (scripting_on)))
 1337     gtk_toggle_button_set_active (scripting_off, TRUE);
 1338   if ((sensitive = GTK_WIDGET_IS_SENSITIVE (lookup_widget (pref, "scripting"))))
 1339     gtk_widget_set_sensitive (lookup_widget (pref, "scripting"), FALSE);
 1340 
 1341   gfs_gl_streamlines_evenly_spaced (gls, callback, gl);
 1342 
 1343   gtk_widget_set_sensitive (lookup_widget (pref, "scripting"), sensitive);
 1344   gtk_toggle_button_set_active (scripting_on, scripting);
 1345 
 1346   gtk_widget_set_sensitive (stop, FALSE);
 1347   gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
 1348   gfk_gl_expose (gl);
 1349 }
 1350 
 1351 
 1352 void
 1353 on_stop_evenly_clicked                 (GtkButton       *button,
 1354                                         gpointer         user_data)
 1355 {
 1356   g_object_set_data (G_OBJECT (button), "stop", button);
 1357 }
 1358 
 1359 
 1360 void
 1361 on_radius_changed                      (GtkSpinButton   *spinbutton,
 1362                                         gpointer         user_data)
 1363 {
 1364   GfkGl * gl = lookup_gl (spinbutton);
 1365   GfsGlStreamlines * gls = GFS_GL_STREAMLINES (gl->gl);
 1366   gdouble v = gtk_spin_button_get_value (spinbutton);
 1367 
 1368   if (gls->radius != v) {
 1369     gls->radius = v;
 1370     gfs_gl_streamlines_update_display_lists (gls);
 1371     gfk_gl_expose (gl);
 1372   }
 1373 }
 1374 
 1375 gboolean 
 1376 gl2ps_update_ppm_size (GtkWidget * widget, GdkEventExpose * event, GtkWidget * size)
 1377 {
 1378   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (size, "screen")))) {
 1379     guint width = widget->allocation.width;
 1380     guint height = widget->allocation.height;
 1381     gdouble * ratio = g_object_get_data (G_OBJECT (size), "ratio");
 1382 
 1383     if (width % 2) width++;
 1384     if (height % 2) height++;
 1385     gtk_spin_button_set_value (GTK_SPIN_BUTTON (lookup_widget (size, "width")), width);
 1386     gtk_spin_button_set_value (GTK_SPIN_BUTTON (lookup_widget (size, "height")), height);
 1387     *ratio = width/(gdouble) height;
 1388   }
 1389   return TRUE;
 1390 }
 1391 
 1392 
 1393 void
 1394 on_screen_ppm_toggled                  (GtkToggleButton *togglebutton,
 1395                                         gpointer         user_data)
 1396 {
 1397   GtkWidget * size = lookup_widget (GTK_WIDGET (togglebutton), "size");
 1398 
 1399   if (gtk_toggle_button_get_active (togglebutton)) {
 1400     GtkWidget * view = lookup_widget (GTK_WIDGET (togglebutton), "view");
 1401     GtkWidget * glarea = g_object_get_data (G_OBJECT (view), "glarea");
 1402 
 1403     gl2ps_update_ppm_size (glarea, NULL, size);
 1404     gtk_widget_set_sensitive (size, FALSE);
 1405   }
 1406   else
 1407     gtk_widget_set_sensitive (size, TRUE);
 1408 }
 1409 
 1410 
 1411 void
 1412 on_width_value_changed                 (GtkSpinButton   *spinbutton,
 1413                                         gpointer         user_data)
 1414 {
 1415   GfsGl2PSParams * p = gl2psparams (spinbutton);
 1416 
 1417   p->width = gtk_spin_button_get_value (spinbutton);
 1418   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (GTK_WIDGET (spinbutton), 
 1419                                       "screen"))) &&
 1420       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (GTK_WIDGET (spinbutton), 
 1421                                       "keep_ratio")))) {
 1422     GtkWidget * size = lookup_widget (GTK_WIDGET (spinbutton), "size");
 1423     GtkSpinButton * heights = GTK_SPIN_BUTTON (lookup_widget (size, "height"));
 1424     gdouble * ratio = g_object_get_data (G_OBJECT (size), "ratio");
 1425     guint height = p->width/(*ratio);
 1426 
 1427     if (height % 2) height++;
 1428     if (fabs (height - gtk_spin_button_get_value (heights)) > 2.)
 1429       gtk_spin_button_set_value (heights, height);
 1430   }
 1431 }
 1432 
 1433 
 1434 void
 1435 on_height_value_changed                (GtkSpinButton   *spinbutton,
 1436                                         gpointer         user_data)
 1437 {
 1438   GfsGl2PSParams * p = gl2psparams (spinbutton);
 1439 
 1440   p->height = gtk_spin_button_get_value (spinbutton);
 1441   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (GTK_WIDGET (spinbutton), 
 1442                                       "screen"))) &&
 1443       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (GTK_WIDGET (spinbutton), 
 1444                                       "keep_ratio")))) {
 1445     GtkWidget * size = lookup_widget (GTK_WIDGET (spinbutton), "size");
 1446     GtkSpinButton * widths = GTK_SPIN_BUTTON (lookup_widget (size, "width"));
 1447     gdouble * ratio = g_object_get_data (G_OBJECT (size), "ratio");
 1448     guint width = p->height*(*ratio);
 1449 
 1450     if (width % 2) width++;
 1451     if (fabs (width - gtk_spin_button_get_value (widths)) > 2.)
 1452       gtk_spin_button_set_value (widths, width);
 1453   }
 1454 }
 1455 
 1456 
 1457 void
 1458 on_keep_ratio_toggled                  (GtkToggleButton *togglebutton,
 1459                                         gpointer         user_data)
 1460 {
 1461   if (gtk_toggle_button_get_active (togglebutton)) {
 1462     GtkWidget * size = lookup_widget (GTK_WIDGET (togglebutton), "size");
 1463     gdouble * ratio = g_object_get_data (G_OBJECT (size), "ratio");
 1464     guint width = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lookup_widget (size, "width")));
 1465     guint height = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lookup_widget (size, "height")));
 1466     *ratio = width/(gdouble) height;
 1467   }
 1468 }
 1469 
 1470 
 1471 void
 1472 on_information_toggled                 (GtkToggleButton *togglebutton,
 1473                                         gpointer         user_data)
 1474 {
 1475   GfkGlCells * gl = lookup_gl (togglebutton);
 1476 
 1477   if (gtk_toggle_button_get_active (togglebutton)) {
 1478     gtk_widget_set_sensitive (lookup_widget_params (gl->cells, "edit_level"), FALSE);
 1479     gl->edit = FALSE;
 1480   }
 1481   else {
 1482     gtk_widget_set_sensitive (lookup_widget_params (gl->cells, "edit_level"), TRUE);
 1483     gl->edit = TRUE;
 1484   }
 1485 }
 1486 
 1487 
 1488 void
 1489 on_locate_x_entry_changed              (GtkEditable     *editable,
 1490                                         gpointer         user_data)
 1491 {
 1492   GtkEntry * entry = GTK_ENTRY (editable);
 1493   GfkGl * gl = lookup_gl (editable);
 1494   GfsGlLocate * locate = GFS_GL_LOCATE (gl->gl);
 1495   gdouble v = atof (gtk_entry_get_text (entry));
 1496 
 1497   if (locate->p.x != v) {
 1498     locate->p.x = v;
 1499     gfk_gl_expose (gl);
 1500   }
 1501 }
 1502 
 1503 
 1504 void
 1505 on_locate_y_entry_changed              (GtkEditable     *editable,
 1506                                         gpointer         user_data)
 1507 {
 1508   GtkEntry * entry = GTK_ENTRY (editable);
 1509   GfkGl * gl = lookup_gl (editable);
 1510   GfsGlLocate * locate = GFS_GL_LOCATE (gl->gl);
 1511   gdouble v = atof (gtk_entry_get_text (entry));
 1512 
 1513   if (locate->p.y != v) {
 1514     locate->p.y = v;
 1515     gfk_gl_expose (gl);
 1516   }  
 1517 }
 1518 
 1519 
 1520 void
 1521 on_locate_z_entry_changed              (GtkEditable     *editable,
 1522                                         gpointer         user_data)
 1523 {
 1524   GtkEntry * entry = GTK_ENTRY (editable);
 1525   GfkGl * gl = lookup_gl (editable);
 1526   GfsGlLocate * locate = GFS_GL_LOCATE (gl->gl);
 1527   gdouble v = atof (gtk_entry_get_text (entry));
 1528 
 1529   if (locate->p.z != v) {
 1530     locate->p.z = v;
 1531     gfk_gl_expose (gl);
 1532   }
 1533 }
 1534 
 1535 void
 1536 on_x_scaling_changed                   (GtkEditable     *editable,
 1537                                         gpointer         user_data)
 1538 {
 1539   GtkWidget * view = lookup_widget (GTK_WIDGET (editable), "view");
 1540   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
 1541   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
 1542   gdouble sx = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
 1543 
 1544   if (sx != p->sx) {
 1545     p->sx = sx;
 1546     gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
 1547   }
 1548 }
 1549 
 1550 
 1551 void
 1552 on_y_scaling_changed                   (GtkEditable     *editable,
 1553                                         gpointer         user_data)
 1554 {
 1555   GtkWidget * view = lookup_widget (GTK_WIDGET (editable), "view");
 1556   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
 1557   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
 1558   gdouble sy = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
 1559 
 1560   if (sy != p->sy) {
 1561     p->sy = sy;
 1562     gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
 1563   }
 1564 }
 1565 
 1566 
 1567 void
 1568 on_z_scaling_changed                   (GtkEditable     *editable,
 1569                                         gpointer         user_data)
 1570 {
 1571   GtkWidget * view = lookup_widget (GTK_WIDGET (editable), "view");
 1572   GtkWidget * glarea = lookup_widget (GTK_WIDGET (view), "glarea");
 1573   GfsGlViewParams * p = g_object_get_data (G_OBJECT (glarea), "GfsGlViewParams");
 1574   gdouble sz = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (editable));
 1575 
 1576   if (sz != p->sz) {
 1577     p->sz = sz;
 1578     gdk_window_invalidate_rect (glarea->window, &glarea->allocation, FALSE);
 1579   }
 1580 }
 1581 
 1582 void
 1583 on_vof_reversed_toggled                (GtkToggleButton *togglebutton,
 1584                                         gpointer         user_data)
 1585 {
 1586   GfkGl * gl = lookup_gl (togglebutton);
 1587   GfsGlVOF * gli = GFS_GL_VOF (gl->gl);
 1588   gli->reversed = !gli->reversed;
 1589   gfk_gl_expose (gl);
 1590 }
 1591 
 1592 void
 1593 on_vof_visible_toggled                 (GtkToggleButton *togglebutton,
 1594                                         gpointer         user_data)
 1595 {
 1596   GfkGl * gl = lookup_gl (togglebutton);
 1597   GfsGlVOF * gli = GFS_GL_VOF (gl->gl);
 1598   gli->draw_edges = !gli->draw_edges;
 1599   gfk_gl_expose (gl);
 1600 }
 1601 
 1602 void
 1603 on_linear_reversed_toggled             (GtkToggleButton *togglebutton,
 1604                                         gpointer         user_data)
 1605 {
 1606   GfkGl * gl = lookup_gl (togglebutton);
 1607   GfsGlLinear * gli = GFS_GL_LINEAR (gl->gl);
 1608   gli->reversed = !gli->reversed;
 1609   gfk_gl_expose (gl);
 1610 }
 1611 
 1612 void
 1613 on_location_label_toggled              (GtkToggleButton *togglebutton,
 1614                                         gpointer         user_data)
 1615 {
 1616   GfkGl * gl = lookup_gl (togglebutton);
 1617   GfsGlLocation * gll = GFS_GL_LOCATION (gl->gl);
 1618   gll->label = !gll->label;
 1619   gfk_gl_expose (gl);
 1620 }
 1621 
 1622 
 1623 void
 1624 on_font_size_changed                   (GtkSpinButton   *spinbutton,
 1625                                         gpointer         user_data)
 1626 {
 1627   GfkGl * gl = lookup_gl (spinbutton);
 1628   gfs_gl_set_font_size (gl->gl, gtk_spin_button_get_value_as_float (spinbutton));
 1629   gfk_gl_expose (gl);
 1630 }
 1631 
 1632 
 1633 void
 1634 on_vector_font_toggled                 (GtkToggleButton *togglebutton,
 1635                                         gpointer         user_data)
 1636 {
 1637   GfkGl * gl = lookup_gl (togglebutton);
 1638   gfs_gl_set_raster_font (gl->gl, !gl->gl->use_raster_font);
 1639   gfk_gl_expose (gl);
 1640 }
 1641 
 1642 
 1643 void
 1644 on_raster_font_toggled                 (GtkToggleButton *togglebutton,
 1645                                         gpointer         user_data)
 1646 {
 1647 
 1648 }
 1649 
 1650 
 1651 static void set_labelpos_increment (GfkGl * gl)
 1652 {
 1653   double maxlevel = gl->gl->maxlevel;
 1654   if (maxlevel < 0) {
 1655     GtkSpinButton * max = lookup_widget_params (gl->properties, "maxlevel");
 1656     GtkAdjustment * amax = gtk_spin_button_get_adjustment (max);
 1657     maxlevel = amax->upper;
 1658   }
 1659   FttComponent c;
 1660   for (c = 0; c < FTT_DIMENSION; c++) {
 1661     const char * name[] = { "labelx", "labely", "labelz" };
 1662     GtkSpinButton * spos = lookup_widget_params (GFK_GL_LABEL (gl)->label, name[c]);
 1663     GtkAdjustment * pos = gtk_spin_button_get_adjustment (spos);
 1664     pos->page_increment = (pos->upper - pos->lower)/exp (maxlevel*log (2.));
 1665     pos->step_increment = pos->page_increment/10.;
 1666     gtk_spin_button_set_adjustment (spos, pos);
 1667   }
 1668 }
 1669 
 1670 
 1671 void
 1672 on_labelx_changed                      (GtkSpinButton   *spinbutton,
 1673                                         gpointer         user_data)
 1674 {
 1675   GfkGl * gl = lookup_gl (spinbutton);
 1676   GfsGlLabel * l = GFS_GL_LABEL (gl->gl);
 1677   gdouble x = gtk_spin_button_get_value (spinbutton);
 1678   
 1679   if (x != l->p.x) {
 1680     l->p.x = x;
 1681     set_labelpos_increment (gl);
 1682     gfk_gl_expose (gl);
 1683   }
 1684 }
 1685 
 1686 
 1687 void
 1688 on_labely_changed                      (GtkSpinButton   *spinbutton,
 1689                                         gpointer         user_data)
 1690 {
 1691   GfkGl * gl = lookup_gl (spinbutton);
 1692   GfsGlLabel * l = GFS_GL_LABEL (gl->gl);
 1693   gdouble y = gtk_spin_button_get_value (spinbutton);
 1694   
 1695   if (y != l->p.y) {
 1696     l->p.y = y;
 1697     set_labelpos_increment (gl);
 1698     gfk_gl_expose (gl);
 1699   }
 1700 }
 1701 
 1702 
 1703 void
 1704 on_labelz_changed                      (GtkSpinButton   *spinbutton,
 1705                                         gpointer         user_data)
 1706 {
 1707   GfkGl * gl = lookup_gl (spinbutton);
 1708   GfsGlLabel * l = GFS_GL_LABEL (gl->gl);
 1709   gdouble z = gtk_spin_button_get_value (spinbutton);
 1710   
 1711   if (z != l->p.z) {
 1712     l->p.z = z;
 1713     set_labelpos_increment (gl);
 1714     gfk_gl_expose (gl);
 1715   }
 1716 }
 1717 
 1718 
 1719 void
 1720 on_labelentry_activate                 (GtkEntry        *entry,
 1721                                         gpointer         user_data)
 1722 {
 1723   GfkGl * gl = lookup_gl (entry);
 1724   GfsGlLabel * l = GFS_GL_LABEL (gl->gl);
 1725 
 1726   gfs_gl_label_set_label (l, gtk_entry_get_text (entry), gl->gl->sim);
 1727   
 1728   gfk_gl_update_properties (gl);
 1729   gfk_gl_expose (gl);
 1730 }
 1731 
 1732 
 1733 void
 1734 on_label_symbol_check_toggled          (GtkToggleButton *togglebutton,
 1735                                         gpointer         user_data)
 1736 {
 1737   GfkGl * gl = lookup_gl (togglebutton);
 1738   GFS_GL_LABEL (gl->gl)->symbol = !GFS_GL_LABEL (gl->gl)->symbol;
 1739   gfk_gl_expose (gl);
 1740 }
 1741 
 1742 
 1743 void
 1744 on_showscale_toggled                   (GtkToggleButton *togglebutton,
 1745                                         gpointer         user_data)
 1746 {
 1747   GfkGl * gl = lookup_gl (togglebutton);
 1748   GFS_GL_SCALAR (gl->gl)->show = !GFS_GL_SCALAR (gl->gl)->show;
 1749   gfk_gl_expose (gl);
 1750 }