Cleaned up and consolidated code which creates new pages.
[geda-gaf.git] / gschem / src / i_basic.c
blob65dde59cf76dc3ecfdbe10362e87117e7f979c8e
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2000 Ales V. Hvezda
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
19 #include <config.h>
21 #ifdef HAVE_STRING_H
22 #include <string.h>
23 #endif
25 #include <libgeda/libgeda.h>
27 #include "../include/globals.h"
28 #include "../include/prototype.h"
30 #ifdef HAVE_LIBDMALLOC
31 #include <dmalloc.h>
32 #endif
34 /*! \todo Finish function documentation!!!
35 * \brief
36 * \par Function Description
39 static void i_update_status(TOPLEVEL *w_current, const char *string)
41 if (!w_current->status_label) {
42 return;
45 if (string) {
46 /* NOTE: consider optimizing this if same label */
47 w_current->DONT_RESIZE=1;
48 gtk_label_set(GTK_LABEL(w_current->status_label),
49 (char *) string);
53 /*! \todo Finish function documentation!!!
54 * \brief
55 * \par Function Description
58 /* Prefix to i_show_state(), i_set_state() and i_set_state_msg()
59 , Allows expose events to happen
60 * *EK* Egil Kvaleberg
62 void i_allow_expose(void)
64 /* This function is probably not needed and should be deleted eventually */
65 #if 0
66 /* HACK: This one allows the expose events to happen? */
67 w_current->DONT_EXPOSE = 1;
68 #endif
71 /*! \todo Finish function documentation!!!
72 * \brief
73 * \par Function Description
76 /* Get string corresponding to the currently selected mode
77 * The returned string will only last until the next time
78 * the function is called (which is probably just fine, really)
79 * *EK* Egil Kvaleberg
81 static const char *i_status_string(TOPLEVEL *w_current)
83 static char *buf = 0;
85 switch ( w_current->event_state ) {
86 case NONE:
87 case STARTROUTENET: /*! \todo */
88 case ENDROUTENET: /*! \todo */
89 return "";
90 case STARTSELECT:
91 case SELECT:
92 case SBOX:
93 case GRIPS:
94 return _("Select Mode");
95 case DRAWATTRIB:
96 case ENDATTRIB:
97 return _("Attribute Mode"); /*EK* new */
98 case DRAWCOMP:
99 case ENDCOMP:
100 return _("Component Mode"); /*EK* new */
101 case TEXTENTRY:
102 case ENDTEXT:
103 case DRAWTEXT:
104 return _("Text Mode"); /*EK* new */
105 case STARTCOPY:
106 case ENDCOPY:
107 return _("Copy Mode");
108 case STARTMOVE:
109 case ENDMOVE:
110 return _("Move Mode");
111 case ENDROTATEP:
112 return _("Rotate Mode");
113 case ENDMIRROR:
114 return _("Mirror Mode");
115 case ZOOM:
116 case ZOOMBOXEND:
117 case ZOOMBOXSTART:
118 return _("Zoom Box");
119 case STARTPAN:
120 case PAN:
121 case MOUSEPAN:
122 return _("Pan Mode");
123 case STARTPASTE:
124 case ENDPASTE:
125 if (buf) g_free(buf);
126 buf = g_strdup_printf(_("Paste %d Mode"), w_current->buffer_number+1);
127 return buf;
128 case STARTDRAWNET:
129 case DRAWNET:
130 case NETCONT:
131 return _("Net Mode");
132 case STARTDRAWBUS:
133 case DRAWBUS:
134 case BUSCONT:
135 return _("Bus Mode");
136 case DRAWLINE:
137 case ENDLINE:
138 return _("Line Mode");
139 case DRAWBOX:
140 case ENDBOX:
141 return _("Box Mode");
142 case DRAWPICTURE:
143 case ENDPICTURE:
144 return _("Picture Mode");
145 case DRAWCIRCLE:
146 case ENDCIRCLE:
147 return _("Circle Mode");
148 case DRAWARC:
149 case ENDARC:
150 return _("Arc Mode");
151 case DRAWPIN:
152 case ENDPIN:
153 return _("Pin Mode");
154 case COPY:
155 return _("Copy");
156 case MOVE:
157 return _("Move");
158 case MCOPY:
159 return _("Multiple Copy");
160 case STARTMCOPY:
161 case ENDMCOPY:
162 return _("Multiple Copy Mode");
164 return ""; /* should not happen */
167 /*! \todo Finish function documentation!!!
168 * \brief
169 * \par Function Description
172 /* Show state field on screen,
173 * possibly with the addition of an extra message
174 * *EK* Egil Kvaleberg
176 void i_show_state(TOPLEVEL *w_current, const char *message)
178 static char *buf = 0;
179 char *aux = 0;
180 const char *state_string = i_status_string(w_current);
181 const char *what_to_say;
183 /* This may be a memory leak... either way it's weird and -Wall is */
184 /* complaining... */
185 buf = g_strdup("");
186 aux = buf;
188 if ( message != NULL) {
189 if ( message && message[0] ) {
190 buf = g_strdup_printf("%s - ", message);
191 if (aux) g_free(aux);
192 aux = buf;
196 if ( !w_current->snap ) {
197 buf = g_strdup_printf("%s%s - ", buf, _("Snap Off"));
198 if (aux) g_free(aux);
199 aux = buf;
202 if ( w_current->show_hidden_text ) {
203 buf = g_strdup_printf("%s%s - ", buf, _("Show Hidden"));
204 if (aux) g_free(aux);
205 aux = buf;
208 if (buf != NULL) {
209 if (strlen(buf) > 0) {
210 buf = g_strdup_printf("%s%s", buf, state_string);
211 if (aux) g_free(aux);
212 aux = buf;
213 what_to_say = buf;
214 } else {
215 what_to_say = state_string;
218 else {
219 what_to_say = state_string;
222 i_update_status(w_current, what_to_say);
223 if (buf != NULL) g_free(buf);
226 /*! \todo Finish function documentation!!!
227 * \brief
228 * \par Function Description
231 /* Set new state, then show state field
232 * *EK* Egil Kvaleberg
234 void i_set_state(TOPLEVEL *w_current, enum x_states newstate)
236 i_set_state_msg(w_current, newstate, NULL);
239 /*! \todo Finish function documentation!!!
240 * \brief
241 * \par Function Description
244 /* Set new state, then show state field including some message
245 * *EK* Egil Kvaleberg
247 void i_set_state_msg(TOPLEVEL *w_current, enum x_states newstate,
248 const char *message)
250 w_current->event_state = newstate;
251 i_show_state(w_current, message);
254 /*! \todo Finish function documentation!!!
255 * \brief
256 * \par Function Description
259 void i_update_left_button(const char *string)
263 /*! \todo Finish function documentation!!!
264 * \brief
265 * \par Function Description
268 void i_update_middle_button(TOPLEVEL *w_current,
269 void (*func_ptr)(gpointer, guint, GtkWidget*), const char *string)
271 char *temp_string;
273 if (func_ptr == NULL) {
274 return;
277 if (string == NULL) {
278 return;
281 if (!w_current->middle_label) {
282 return;
285 switch(w_current->middle_button) {
287 /* remove this case eventually and make it a null case */
288 case(ACTION):
289 w_current->DONT_RESIZE = 1;
290 gtk_label_set(GTK_LABEL(w_current->middle_label),
291 _("Action"));
292 break;
294 #ifdef HAS_LIBSTROKE
295 case(STROKE):
296 w_current->DONT_RESIZE = 1;
298 gtk_label_set(GTK_LABEL(w_current->middle_label),
299 _("Stroke"));
300 break;
301 #else
302 /* remove this case eventually and make it a null case */
303 case(STROKE):
304 w_current->DONT_RESIZE = 1;
305 gtk_label_set(GTK_LABEL(w_current->middle_label),
306 _("none"));
307 break;
308 #endif
310 case(REPEAT):
311 w_current->DONT_RESIZE = 1;
313 temp_string = g_strconcat (_("Repeat/"), string, NULL);
315 gtk_label_set(GTK_LABEL(w_current->middle_label),
316 temp_string);
317 w_current->last_callback = func_ptr;
318 g_free(temp_string);
319 break;
325 /*! \todo Finish function documentation!!!
326 * \brief
327 * \par Function Description
330 void i_update_right_button(const char *string)
334 /*! \todo Finish function documentation!!!
335 * \brief
336 * \par Function Description
339 void i_update_toolbar(TOPLEVEL *w_current)
341 if (!w_current->toolbars)
342 return;
344 switch(w_current->event_state) {
345 case(NONE):
346 case(SELECT):
347 case(STARTSELECT):
348 case(TEXTENTRY):
349 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
350 w_current->toolbar_select), TRUE);
351 break;
353 case(DRAWNET):
354 case(STARTDRAWNET):
355 case(NETCONT):
356 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
357 w_current->toolbar_net), TRUE);
358 break;
360 case(DRAWBUS):
361 case(STARTDRAWBUS):
362 case(BUSCONT):
363 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
364 w_current->toolbar_bus), TRUE);
365 break;
367 case(DRAWCOMP): /*! \todo */
368 case(DRAWLINE): /*! \todo */
369 case(DRAWBOX): /*! \todo */
370 case(DRAWPICTURE): /*! \todo */
371 case(DRAWPIN): /*! \todo */
372 case(DRAWCIRCLE): /*! \todo */
373 case(DRAWARC): /*! \todo */
374 case(MOVE): /*! \todo */
375 case(COPY): /*! \todo */
376 case(ZOOM): /*! \todo */
377 case(PAN): /*! \todo */
378 case(STARTPAN): /*! \todo */
379 case(STARTCOPY): /*! \todo */
380 case(STARTMOVE): /*! \todo */
381 case(ENDCOPY): /*! \todo */
382 case(ENDMOVE): /*! \todo */
383 case(ENDLINE): /*! \todo */
384 case(ENDBOX): /*! \todo */
385 case(ENDPICTURE): /*! \todo */
386 case(ENDCIRCLE): /*! \todo */
387 case(ENDARC): /*! \todo */
388 case(ENDPIN): /*! \todo */
389 case(ENDCOMP): /*! \todo */
390 case(DRAWATTRIB): /*! \todo */
391 case(ENDATTRIB): /*! \todo */
392 case(DRAWTEXT): /*! \todo */
393 case(ENDTEXT): /*! \todo */
394 case(ENDROTATEP): /*! \todo */
395 case(ENDMIRROR): /*! \todo */
396 case(ZOOMBOXSTART): /*! \todo */
397 case(ZOOMBOXEND): /*! \todo */
398 case(STARTROUTENET): /*! \todo */
399 case(ENDROUTENET): /*! \todo */
400 case(MOUSEPAN): /*! \todo */
401 case(STARTPASTE): /*! \todo */
402 case(ENDPASTE): /*! \todo */
403 case(GRIPS): /*! \todo */
404 case(MCOPY): /*! \todo */
405 case(STARTMCOPY): /*! \todo */
406 case(ENDMCOPY): /*! \todo */
407 default:
408 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
409 w_current->toolbar_select), TRUE);
410 break;
414 /*! \todo Finish function documentation!!!
415 * \brief
416 * \par Function Description
419 void i_update_menus(TOPLEVEL *w_current)
422 * This is very simplistic. Right now it just disables all menu
423 * items which get greyed out when a component is not selected.
424 * Eventually what gets enabled/disabled
425 * should be based on what is in the selection list
428 g_assert(w_current != NULL);
429 g_assert(w_current->page_current != NULL);
431 if (w_current->page_current->selection_list != NULL) {
432 /* since one or more things are selected, we set these TRUE */
433 /* These strings should NOT be internationalized */
434 x_menus_sensitivity(w_current, "Edit/Cut Buffer", TRUE);
435 x_menus_sensitivity(w_current, "Edit/Copy Buffer", TRUE);
436 x_menus_sensitivity(w_current, "Edit/Edit...", TRUE);
437 x_menus_sensitivity(w_current, "Edit/Edit Text...", TRUE);
438 x_menus_sensitivity(w_current, "Edit/Copy Mode", TRUE);
439 x_menus_sensitivity(w_current, "Edit/Multiple Copy Mode", TRUE);
440 x_menus_sensitivity(w_current, "Edit/Move Mode", TRUE);
441 x_menus_sensitivity(w_current, "Edit/Delete", TRUE);
442 x_menus_sensitivity(w_current, "Edit/Rotate 90 Mode", TRUE);
443 x_menus_sensitivity(w_current, "Edit/Mirror Mode", TRUE);
444 x_menus_sensitivity(w_current, "Edit/Slot...", TRUE);
445 x_menus_sensitivity(w_current, "Edit/Color...", TRUE);
446 x_menus_sensitivity(w_current, "Edit/Lock", TRUE);
447 x_menus_sensitivity(w_current, "Edit/Unlock", TRUE);
448 x_menus_sensitivity(w_current, "Edit/Line Width & Type...", TRUE);
449 x_menus_sensitivity(w_current, "Edit/Fill Type...", TRUE);
450 x_menus_sensitivity(w_current, "Edit/Embed Component/Picture", TRUE);
451 x_menus_sensitivity(w_current, "Edit/Unembed Component/Picture", TRUE);
452 x_menus_sensitivity(w_current, "Edit/Update Component", TRUE);
453 x_menus_sensitivity(w_current, "Buffer/Copy into 1", TRUE);
454 x_menus_sensitivity(w_current, "Buffer/Copy into 2", TRUE);
455 x_menus_sensitivity(w_current, "Buffer/Copy into 3", TRUE);
456 x_menus_sensitivity(w_current, "Buffer/Copy into 4", TRUE);
457 x_menus_sensitivity(w_current, "Buffer/Copy into 5", TRUE);
458 x_menus_sensitivity(w_current, "Buffer/Cut into 1", TRUE);
459 x_menus_sensitivity(w_current, "Buffer/Cut into 2", TRUE);
460 x_menus_sensitivity(w_current, "Buffer/Cut into 3", TRUE);
461 x_menus_sensitivity(w_current, "Buffer/Cut into 4", TRUE);
462 x_menus_sensitivity(w_current, "Buffer/Cut into 5", TRUE);
463 x_menus_sensitivity(w_current, "Hierarchy/Down Schematic", TRUE);
464 x_menus_sensitivity(w_current, "Hierarchy/Down Symbol", TRUE);
465 x_menus_sensitivity(w_current, "Hierarchy/Documentation", TRUE);
466 x_menus_sensitivity(w_current, "Attributes/Attach", TRUE);
467 x_menus_sensitivity(w_current, "Attributes/Detach", TRUE);
468 x_menus_sensitivity(w_current, "Attributes/Show Value", TRUE);
469 x_menus_sensitivity(w_current, "Attributes/Show Name", TRUE);
470 x_menus_sensitivity(w_current, "Attributes/Show Both", TRUE);
471 x_menus_sensitivity(w_current, "Attributes/Toggle Visibility", TRUE);
473 /* Menu items for hierarchy added by SDB 1.9.2005. */
474 x_menus_popup_sensitivity(w_current, "/Down Schematic", TRUE);
475 x_menus_popup_sensitivity(w_current, "/Down Symbol", TRUE);
476 /* x_menus_popup_sensitivity(w_current, "/Up", TRUE); */
478 } else {
479 /* Nothing is slected. grey these out */
480 /* These strings should NOT be internationalized */
481 x_menus_sensitivity(w_current, "Edit/Cut Buffer", FALSE);
482 x_menus_sensitivity(w_current, "Edit/Copy Buffer", FALSE);
483 x_menus_sensitivity(w_current, "Edit/Edit...", FALSE);
484 x_menus_sensitivity(w_current, "Edit/Edit Text...", FALSE);
485 x_menus_sensitivity(w_current, "Edit/Copy Mode", FALSE);
486 x_menus_sensitivity(w_current, "Edit/Multiple Copy Mode", FALSE);
487 x_menus_sensitivity(w_current, "Edit/Move Mode", FALSE);
488 x_menus_sensitivity(w_current, "Edit/Delete", FALSE);
489 x_menus_sensitivity(w_current, "Edit/Rotate 90 Mode", FALSE);
490 x_menus_sensitivity(w_current, "Edit/Mirror Mode", FALSE);
491 x_menus_sensitivity(w_current, "Edit/Slot...", FALSE);
492 x_menus_sensitivity(w_current, "Edit/Color...", FALSE);
493 x_menus_sensitivity(w_current, "Edit/Lock", FALSE);
494 x_menus_sensitivity(w_current, "Edit/Unlock", FALSE);
495 x_menus_sensitivity(w_current, "Edit/Line Width & Type...", FALSE);
496 x_menus_sensitivity(w_current, "Edit/Fill Type...", FALSE);
497 x_menus_sensitivity(w_current, "Edit/Embed Component/Picture", FALSE);
498 x_menus_sensitivity(w_current, "Edit/Unembed Component/Picture", FALSE);
499 x_menus_sensitivity(w_current, "Edit/Update Component", FALSE);
500 x_menus_sensitivity(w_current, "Buffer/Copy into 1", FALSE);
501 x_menus_sensitivity(w_current, "Buffer/Copy into 2", FALSE);
502 x_menus_sensitivity(w_current, "Buffer/Copy into 3", FALSE);
503 x_menus_sensitivity(w_current, "Buffer/Copy into 4", FALSE);
504 x_menus_sensitivity(w_current, "Buffer/Copy into 5", FALSE);
505 x_menus_sensitivity(w_current, "Buffer/Cut into 1", FALSE);
506 x_menus_sensitivity(w_current, "Buffer/Cut into 2", FALSE);
507 x_menus_sensitivity(w_current, "Buffer/Cut into 3", FALSE);
508 x_menus_sensitivity(w_current, "Buffer/Cut into 4", FALSE);
509 x_menus_sensitivity(w_current, "Buffer/Cut into 5", FALSE);
510 x_menus_sensitivity(w_current, "Hierarchy/Down Schematic", FALSE);
511 x_menus_sensitivity(w_current, "Hierarchy/Down Symbol", FALSE);
512 x_menus_sensitivity(w_current, "Hierarchy/Documentation", FALSE);
513 x_menus_sensitivity(w_current, "Attributes/Attach", FALSE);
514 x_menus_sensitivity(w_current, "Attributes/Detach", FALSE);
515 x_menus_sensitivity(w_current, "Attributes/Show Value", FALSE);
516 x_menus_sensitivity(w_current, "Attributes/Show Name", FALSE);
517 x_menus_sensitivity(w_current, "Attributes/Show Both", FALSE);
518 x_menus_sensitivity(w_current, "Attributes/Toggle Visibility", FALSE);
520 /* Menu items for hierarchy added by SDB 1.9.2005. */
521 x_menus_popup_sensitivity(w_current, "/Down Schematic", FALSE);
522 x_menus_popup_sensitivity(w_current, "/Down Symbol", FALSE);
523 /* x_menus_popup_sensitivity(w_current, "/Up", FALSE); */
526 if ((object_buffer[0] != NULL) && (object_buffer[0]->next != NULL)) {
527 x_menus_sensitivity(w_current, "Edit/Paste Buffer", TRUE);
528 x_menus_sensitivity(w_current, "Buffer/Paste from 1", TRUE);
529 } else {
530 x_menus_sensitivity(w_current, "Edit/Paste Buffer", FALSE);
531 x_menus_sensitivity(w_current, "Buffer/Paste from 1", FALSE);
534 if ((object_buffer[1] != NULL) && (object_buffer[1]->next != NULL)) {
535 x_menus_sensitivity(w_current, "Buffer/Paste from 2", TRUE);
536 } else {
537 x_menus_sensitivity(w_current, "Buffer/Paste from 2", FALSE);
540 if ((object_buffer[2] != NULL) && (object_buffer[2]->next != NULL)) {
541 x_menus_sensitivity(w_current, "Buffer/Paste from 3", TRUE);
542 } else {
543 x_menus_sensitivity(w_current, "Buffer/Paste from 3", FALSE);
546 if ((object_buffer[3] != NULL) && (object_buffer[3]->next != NULL)) {
547 x_menus_sensitivity(w_current, "Buffer/Paste from 4", TRUE);
548 } else {
549 x_menus_sensitivity(w_current, "Buffer/Paste from 4", FALSE);
552 if ((object_buffer[4] != NULL) && (object_buffer[4]->next != NULL)) {
553 x_menus_sensitivity(w_current, "Buffer/Paste from 5", TRUE);
554 } else {
555 x_menus_sensitivity(w_current, "Buffer/Paste from 5", FALSE);
561 #if 0
562 /* This data is in X bitmap format, and can be created with the 'bitmap'
563 utility. */
564 #define cursor1_width 16
565 #define cursor1_height 16
566 static unsigned char cursor1_bits[] = {
567 0x00, 0x00, 0x08, 0x38, 0x18, 0x08, 0x38, 0x18, 0x78, 0x08, 0xf8, 0x38,
568 0xf8, 0x01, 0xf8, 0x03, 0xf8, 0x07, 0xf8, 0x00, 0xd8, 0x00, 0x88, 0x01,
569 0x80, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00};
571 static unsigned char cursor1mask_bits[] = {
572 0x0c, 0x7c, 0x1c, 0x7c, 0x3c, 0x7c, 0x7c, 0x3c, 0xfc, 0x7c, 0xfc, 0x7d,
573 0xfc, 0x7f, 0xfc, 0x07, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x01, 0xdc, 0x03,
574 0xcc, 0x03, 0x80, 0x07, 0x80, 0x07, 0x00, 0x03};
575 #endif
577 /*! \todo Finish function documentation!!!
578 * \brief
579 * \par Function Description
582 void i_update_cursor(TOPLEVEL *w_current)
584 #if 0
585 if (!w_current->cursors)
586 return;
587 #endif
589 #if 0
590 GdkCursor *cursor;
592 GdkPixmap *source, *mask;
593 GdkColor fg = { 0, 0, 0, 0 }; /* Red. */
594 GdkColor bg = { 0, 65535, 65535, 65535 }; /* Blue. */
596 source = gdk_bitmap_create_from_data (NULL, cursor1_bits,
597 cursor1_width, cursor1_height);
598 mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits,
599 cursor1_width, cursor1_height);
600 cursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 3, 1);
601 gdk_pixmap_unref (source);
602 gdk_pixmap_unref (mask);
604 gdk_window_set_cursor (w_current->window, cursor);
605 #endif
608 GdkCursor* cursor;
609 cursor = gdk_cursor_new(GDK_ARROW);
610 gdk_window_set_cursor(w_current->window, cursor);
611 gdk_cursor_destroy(cursor);
613 #if 0
614 switch(w_current->event_state) {
615 case(NONE):
616 case(SELECT):
617 case(STARTSELECT):
618 case(TEXTENTRY):
619 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
620 w_current->toolbar_select), TRUE);
621 break;
623 case(DRAWNET):
624 case(STARTDRAWNET):
625 case(NETCONT):
626 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
627 w_current->toolbar_net), TRUE);
628 break;
630 case(DRAWBUS):
631 case(STARTDRAWBUS):
632 case(BUSCONT):
633 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
634 w_current->toolbar_bus), TRUE);
635 break;
637 case(DRAWCOMP): /*! \todo */
638 case(DRAWLINE): /*! \todo */
639 case(DRAWBOX): /*! \todo */
640 case(DRAWPICTURE): /*! \todo */
641 case(DRAWPIN): /*! \todo */
642 case(DRAWCIRCLE): /*! \todo */
643 case(DRAWARC): /*! \todo */
644 case(MOVE): /*! \todo */
645 case(COPY): /*! \todo */
646 case(ZOOM): /*! \todo */
647 case(PAN): /*! \todo */
648 case(STARTPAN): /*! \todo */
649 case(STARTCOPY): /*! \todo */
650 case(STARTMOVE): /*! \todo */
651 case(ENDCOPY): /*! \todo */
652 case(ENDMOVE): /*! \todo */
653 case(ENDLINE): /*! \todo */
654 case(ENDBOX): /*! \todo */
655 case(ENDPICTURE): /*! \todo */
656 case(ENDCIRCLE): /*! \todo */
657 case(ENDARC): /*! \todo */
658 case(ENDPIN): /*! \todo */
659 case(ENDCOMP): /*! \todo */
660 case(DRAWATTRIB): /*! \todo */
661 case(ENDATTRIB): /*! \todo */
662 case(DRAWTEXT): /*! \todo */
663 case(ENDTEXT): /*! \todo */
664 case(ENDROTATEP): /*! \todo */
665 case(ENDMIRROR): /*! \todo */
666 case(ZOOMBOXSTART): /*! \todo */
667 case(ZOOMBOXEND): /*! \todo */
668 case(STARTROUTENET): /*! \todo */
669 case(ENDROUTENET): /*! \todo */
670 case(MOUSEPAN): /*! \todo */
671 case(STARTPASTE): /*! \todo */
672 case(ENDPASTE): /*! \todo */
673 case(GRIPS): /*! \todo */
674 case(MCOPY): /*! \todo */
675 case(MCOPYSTART): /*! \todo */
676 case(MCOPYEND): /*! \todo */
677 default:
678 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
679 w_current->toolbar_select), TRUE);
680 break;
682 #endif
685 /*! \brief Set filename as gschem window title
686 * \par Function Description
687 * Set the window title using the gnome HID format style.
689 void i_set_filename(TOPLEVEL *w_current, const gchar *string)
691 gchar *print_string=NULL;
692 gchar *filename=NULL;
694 if (!w_current->main_window)
695 return;
696 if (string == NULL)
697 return;
699 filename = g_path_get_basename(string);
701 print_string = g_strdup_printf("%s - gschem", filename);
703 /* alternativ code with length limited pathname */
704 /* int max_len = 70;
705 if (strlen(string) > max_len) {
706 print_string = g_strdup_printf("gschem: ...%s",
707 &(string[strlen(string)-max_len]));
709 else {
710 print_string = g_strdup_printf("gschem: %s",string);
714 gtk_window_set_title(GTK_WINDOW(w_current->main_window),
715 print_string);
717 g_free(print_string);
718 g_free(filename);
721 /*! \brief Write the grid settings to the gschem status bar
722 * \par Function Description
723 * The function takes the current grid paramters of gschem and
724 * prints it to the status bar.
725 * The format is "Grid([SnapGridSize],[CurrentGridSize])"
727 void i_set_grid(TOPLEVEL *w_current, int visible_grid)
729 gchar *print_string=NULL;
730 gchar *snap=NULL;
731 gchar *grid=NULL;
733 if (!w_current->grid_label) {
734 return;
737 if (!w_current->snap)
738 snap = g_strdup(_("OFF"));
739 else
740 snap = g_strdup_printf("%d", w_current->snap_size);
742 if (!w_current->grid)
743 grid = g_strdup(_("OFF"));
744 else
745 grid = g_strdup_printf("%d", visible_grid);
747 print_string = g_strdup_printf(_("Grid(%s, %s)"), snap, grid);
748 gtk_label_set(GTK_LABEL(w_current->grid_label), print_string);
750 g_free(print_string);
751 g_free(grid);
752 g_free(snap);