Bump gEDA version
[geda-gaf.git] / gschem / src / gschem_selection_adapter.c
blob700de35cb14a891b192b0e31d4816c20af66650a
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2020 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 /*!
21 * \file gschem_selection_adapter.c
23 * \brief
26 #include <config.h>
28 #include <stdio.h>
29 #ifdef HAVE_STDLIB_H
30 #include <stdlib.h>
31 #endif
32 #ifdef HAVE_STRING_H
33 #include <string.h>
34 #endif
36 #include "gschem.h"
37 #include <gdk/gdkkeysyms.h>
39 /*! \private
41 enum
43 PROP_0,
44 PROP_CAP_STYLE,
45 PROP_DASH_LENGTH,
46 PROP_DASH_SPACE,
47 PROP_FILL_ANGLE1,
48 PROP_FILL_ANGLE2,
49 PROP_FILL_PITCH1,
50 PROP_FILL_PITCH2,
51 PROP_FILL_TYPE,
52 PROP_FILL_WIDTH,
53 PROP_LINE_TYPE,
54 PROP_LINE_WIDTH,
55 PROP_OBJECT_COLOR,
56 PROP_PIN_TYPE,
57 PROP_TEXT_ALIGNMENT,
58 PROP_TEXT_COLOR,
59 PROP_TEXT_ROTATION,
60 PROP_TEXT_SIZE,
61 PROP_TEXT_STRING
66 static void
67 class_init (GschemSelectionAdapterClass *klass);
69 static GList*
70 get_selection_iter (GschemSelectionAdapter *adapter);
72 static void
73 get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec);
75 static void
76 instance_init (GschemSelectionAdapter *adapter);
78 static void
79 selection_changed (GedaList *selection, GschemSelectionAdapter *adapter);
81 static void
82 set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
86 /*! \brief Get the cap style from the selection
88 * \param [in] adapter This adapter
90 * \retval NO_SELECTION No objects are selected
91 * \retval MULTIPLE_VALUES Multiple objects with different cap styles are selected
92 * \retval others The cap style of the selected objects
94 int
95 gschem_selection_adapter_get_cap_style (GschemSelectionAdapter *adapter)
97 gint cap_style = NO_SELECTION;
98 GList *iter = get_selection_iter (adapter);
100 while (iter != NULL) {
101 OBJECT *object = (OBJECT*) iter->data;
102 gboolean success;
103 OBJECT_END temp_cap_style;
104 gint temp_dash_length;
105 gint temp_dash_space;
106 OBJECT_TYPE temp_line_type;
107 gint temp_line_width;
109 success = o_get_line_options (object,
110 &temp_cap_style,
111 &temp_line_type,
112 &temp_line_width,
113 &temp_dash_length,
114 &temp_dash_space);
116 if (success) {
117 if (cap_style < 0) {
118 cap_style = temp_cap_style;
120 else if (cap_style != temp_cap_style) {
121 cap_style = MULTIPLE_VALUES;
122 break;
126 iter = g_list_next (iter);
129 return cap_style;
134 /*! \brief Get the dash_length from the selection
136 * \param [in] adapter This adapter
138 * \retval NO_SELECTION No objects are selected
139 * \retval MULTIPLE_VALUES Multiple objects with different dash lengths are selected
140 * \retval others The dash length of the selected objects
143 gschem_selection_adapter_get_dash_length (GschemSelectionAdapter *adapter)
145 gint dash_length = NO_SELECTION;
146 GList *iter = get_selection_iter (adapter);
148 while (iter != NULL) {
149 OBJECT *object = (OBJECT*) iter->data;
150 gboolean success;
151 OBJECT_END temp_cap_style;
152 gint temp_dash_length;
153 gint temp_dash_space;
154 OBJECT_TYPE temp_line_type;
155 gint temp_line_width;
157 success = o_get_line_options (object,
158 &temp_cap_style,
159 &temp_line_type,
160 &temp_line_width,
161 &temp_dash_length,
162 &temp_dash_space);
164 if (success) {
165 if (dash_length < 0) {
166 dash_length = temp_dash_length;
168 else if (dash_length != temp_dash_length) {
169 dash_length = MULTIPLE_VALUES;
170 break;
174 iter = g_list_next (iter);
177 return dash_length;
182 /*! \brief Get the dash space from the selection
184 * \param [in] adapter This adapter
186 * \retval NO_SELECTION No objects are selected
187 * \retval MULTIPLE_VALUES Multiple objects with different dash spacings are selected
188 * \retval others The dash spacing of the selected objects
191 gschem_selection_adapter_get_dash_space (GschemSelectionAdapter *adapter)
193 gint dash_space = NO_SELECTION;
194 GList *iter = get_selection_iter (adapter);
196 while (iter != NULL) {
197 OBJECT *object = (OBJECT*) iter->data;
198 gboolean success;
199 OBJECT_END temp_cap_style;
200 gint temp_dash_length;
201 gint temp_dash_space;
202 OBJECT_TYPE temp_line_type;
203 gint temp_line_width;
205 success = o_get_line_options (object,
206 &temp_cap_style,
207 &temp_line_type,
208 &temp_line_width,
209 &temp_dash_length,
210 &temp_dash_space);
212 if (success) {
213 if (dash_space < 0) {
214 dash_space = temp_dash_space;
216 else if (dash_space != temp_dash_space) {
217 dash_space = MULTIPLE_VALUES;
218 break;
222 iter = g_list_next (iter);
225 return dash_space;
230 /*! \brief Get the first fill line angle of the selected objects
232 * \param [in] adapter This adapter
234 * \retval NO_SELECTION No objects are selected
235 * \retval MULTIPLE_VALUES Multiple objects with different fill line angles are selected
236 * \retval others The fill line angle of the selected objects
239 gschem_selection_adapter_get_fill_angle1 (GschemSelectionAdapter *adapter)
241 gint fill_angle = NO_SELECTION;
242 GList *iter = get_selection_iter (adapter);
244 while (iter != NULL) {
245 OBJECT *object = (OBJECT*) iter->data;
246 gboolean success;
247 gint temp_angle1;
248 gint temp_angle2;
249 OBJECT_FILLING temp_fill_type;
250 gint temp_pitch1;
251 gint temp_pitch2;
252 gint temp_width;
254 success = o_get_fill_options(object,
255 &temp_fill_type,
256 &temp_width,
257 &temp_pitch1,
258 &temp_angle1,
259 &temp_pitch2,
260 &temp_angle2);
263 if (success) {
264 if (fill_angle < 0) {
265 fill_angle = temp_angle1;
267 else if (fill_angle != temp_angle1) {
268 fill_angle = MULTIPLE_VALUES;
269 break;
273 iter = g_list_next (iter);
276 return fill_angle;
281 /*! \brief Get the second fill line angle of the selected objects
283 * \param [in] adapter This adapter
285 * \retval NO_SELECTION No objects are selected
286 * \retval MULTIPLE_VALUES Multiple objects with different fill line angles are selected
287 * \retval others The fill line angle of the selected objects
290 gschem_selection_adapter_get_fill_angle2 (GschemSelectionAdapter *adapter)
292 gint fill_angle = NO_SELECTION;
293 GList *iter = get_selection_iter (adapter);
295 while (iter != NULL) {
296 OBJECT *object = (OBJECT*) iter->data;
297 gboolean success;
298 gint temp_angle1;
299 gint temp_angle2;
300 OBJECT_FILLING temp_fill_type;
301 gint temp_pitch1;
302 gint temp_pitch2;
303 gint temp_width;
305 success = o_get_fill_options(object,
306 &temp_fill_type,
307 &temp_width,
308 &temp_pitch1,
309 &temp_angle1,
310 &temp_pitch2,
311 &temp_angle2);
314 if (success) {
315 if (fill_angle < 0) {
316 fill_angle = temp_angle2;
318 else if (fill_angle != temp_angle2) {
319 fill_angle = MULTIPLE_VALUES;
320 break;
324 iter = g_list_next (iter);
327 return fill_angle;
332 /*! \brief Get the first fill line pitch of the selected objects
334 * \param [in] adapter This adapter
336 * \retval NO_SELECTION No objects are selected
337 * \retval MULTIPLE_VALUES Multiple objects with different fill line pitches are selected
338 * \retval others The fill line pitch of the selected objects
341 gschem_selection_adapter_get_fill_pitch1 (GschemSelectionAdapter *adapter)
343 gint fill_pitch = NO_SELECTION;
344 GList *iter = get_selection_iter (adapter);
346 while (iter != NULL) {
347 OBJECT *object = (OBJECT*) iter->data;
348 gboolean success;
349 gint temp_angle1;
350 gint temp_angle2;
351 OBJECT_FILLING temp_fill_type;
352 gint temp_pitch1;
353 gint temp_pitch2;
354 gint temp_width;
356 success = o_get_fill_options(object,
357 &temp_fill_type,
358 &temp_width,
359 &temp_pitch1,
360 &temp_angle1,
361 &temp_pitch2,
362 &temp_angle2);
365 if (success) {
366 if (fill_pitch < 0) {
367 fill_pitch = temp_pitch1;
369 else if (fill_pitch != temp_pitch1) {
370 fill_pitch = MULTIPLE_VALUES;
371 break;
375 iter = g_list_next (iter);
378 return fill_pitch;
383 /*! \brief Get the second fill line pitch of the selected objects
385 * \param [in] adapter This adapter
387 * \retval NO_SELECTION No objects are selected
388 * \retval MULTIPLE_VALUES Multiple objects with different fill line pitches are selected
389 * \retval others The fill line pitch of the selected objects
392 gschem_selection_adapter_get_fill_pitch2 (GschemSelectionAdapter *adapter)
394 gint fill_pitch = NO_SELECTION;
395 GList *iter = get_selection_iter (adapter);
397 while (iter != NULL) {
398 OBJECT *object = (OBJECT*) iter->data;
399 gboolean success;
400 gint temp_angle1;
401 gint temp_angle2;
402 OBJECT_FILLING temp_fill_type;
403 gint temp_pitch1;
404 gint temp_pitch2;
405 gint temp_width;
407 success = o_get_fill_options(object,
408 &temp_fill_type,
409 &temp_width,
410 &temp_pitch1,
411 &temp_angle1,
412 &temp_pitch2,
413 &temp_angle2);
416 if (success) {
417 if (fill_pitch < 0) {
418 fill_pitch = temp_pitch2;
420 else if (fill_pitch != temp_pitch2) {
421 fill_pitch = MULTIPLE_VALUES;
422 break;
426 iter = g_list_next (iter);
429 return fill_pitch;
434 /*! \brief Get the fill type from the selection
436 * \param [in] adapter This adapter
438 * \retval NO_SELECTION No objects are selected
439 * \retval MULTIPLE_VALUES Multiple objects with different fill types are selected
440 * \retval others The fill type of the selected objects
443 gschem_selection_adapter_get_fill_type (GschemSelectionAdapter *adapter)
445 gint fill_type = NO_SELECTION;
446 GList *iter = get_selection_iter (adapter);
448 while (iter != NULL) {
449 OBJECT *object = (OBJECT*) iter->data;
450 gboolean success;
451 gint temp_angle1;
452 gint temp_angle2;
453 OBJECT_FILLING temp_fill_type;
454 gint temp_pitch1;
455 gint temp_pitch2;
456 gint temp_width;
458 success = o_get_fill_options(object,
459 &temp_fill_type,
460 &temp_width,
461 &temp_pitch1,
462 &temp_angle1,
463 &temp_pitch2,
464 &temp_angle2);
467 if (success) {
468 if (fill_type < 0) {
469 fill_type = temp_fill_type;
471 else if (fill_type != temp_fill_type) {
472 fill_type = MULTIPLE_VALUES;
473 break;
477 iter = g_list_next (iter);
480 return fill_type;
485 /*! \brief Get the width of the fill lines from the selection
487 * \param [in] adapter This adapter
489 * \retval NO_SELECTION No objects are selected
490 * \retval MULTIPLE_VALUES Multiple objects with different fill line widths are selected
491 * \retval others The fill line width of the selected objects
494 gschem_selection_adapter_get_fill_width (GschemSelectionAdapter *adapter)
496 gint fill_width = NO_SELECTION;
497 GList *iter = get_selection_iter (adapter);
499 while (iter != NULL) {
500 OBJECT *object = (OBJECT*) iter->data;
501 gboolean success;
502 gint temp_angle1;
503 gint temp_angle2;
504 OBJECT_FILLING temp_fill_type;
505 gint temp_pitch1;
506 gint temp_pitch2;
507 gint temp_width;
509 success = o_get_fill_options(object,
510 &temp_fill_type,
511 &temp_width,
512 &temp_pitch1,
513 &temp_angle1,
514 &temp_pitch2,
515 &temp_angle2);
518 if (success) {
519 if (fill_width < 0) {
520 fill_width = temp_width;
522 else if (fill_width != temp_width) {
523 fill_width = MULTIPLE_VALUES;
524 break;
528 iter = g_list_next (iter);
531 return fill_width;
536 /*! \brief Get the line_type from the selection
538 * \param [in] adapter This adapter
540 * \retval NO_SELECTION No objects are selected
541 * \retval MULTIPLE_VALUES Multiple objects with different line types are selected
542 * \retval others The line type of the selected objects
545 gschem_selection_adapter_get_line_type (GschemSelectionAdapter *adapter)
547 gint line_type = NO_SELECTION;
548 GList *iter = get_selection_iter (adapter);
550 while (iter != NULL) {
551 OBJECT *object = (OBJECT*) iter->data;
552 gboolean success;
553 OBJECT_END temp_cap_style;
554 gint temp_dash_length;
555 gint temp_dash_space;
556 OBJECT_TYPE temp_line_type;
557 gint temp_line_width;
559 success = o_get_line_options (object,
560 &temp_cap_style,
561 &temp_line_type,
562 &temp_line_width,
563 &temp_dash_length,
564 &temp_dash_space);
566 if (success) {
567 if (line_type < 0) {
568 line_type = temp_line_type;
570 else if (line_type != temp_line_type) {
571 line_type = MULTIPLE_VALUES;
572 break;
576 iter = g_list_next (iter);
579 return line_type;
584 /*! \brief Get the line width from the selection
586 * \param [in] adapter This adapter
588 * \retval NO_SELECTION No objects are selected
589 * \retval MULTIPLE_VALUES Multiple objects with different widths are selected
590 * \retval others The width of the selected objects
593 gschem_selection_adapter_get_line_width (GschemSelectionAdapter *adapter)
595 gint line_width = NO_SELECTION;
596 GList *iter = get_selection_iter (adapter);
598 while (iter != NULL) {
599 OBJECT *object = (OBJECT*) iter->data;
600 gboolean success;
601 OBJECT_END temp_cap_style;
602 gint temp_dash_length;
603 gint temp_dash_space;
604 OBJECT_TYPE temp_line_type;
605 gint temp_line_width;
607 success = o_get_line_options (object,
608 &temp_cap_style,
609 &temp_line_type,
610 &temp_line_width,
611 &temp_dash_length,
612 &temp_dash_space);
614 if (success) {
615 if (line_width < 0) {
616 line_width = temp_line_width;
618 else if (line_width != temp_line_width) {
619 line_width = MULTIPLE_VALUES;
620 break;
624 iter = g_list_next (iter);
627 return line_width;
632 /*! \brief Get the color of selected objects
634 * \param [in] adapter This adapter
636 * \retval NO_SELECTION No objects are selected
637 * \retval MULTIPLE_VALUES Multiple objects with different colors are selected
638 * \retval others The color of the selected objects
641 gschem_selection_adapter_get_object_color (GschemSelectionAdapter *adapter)
643 int color = NO_SELECTION;
644 GList *iter = get_selection_iter (adapter);
646 while (iter != NULL) {
647 OBJECT* object = (OBJECT *) iter->data;
648 iter = g_list_next (iter);
649 if ((object != NULL) && (
650 (object->type == OBJ_ARC) ||
651 (object->type == OBJ_BOX) ||
652 (object->type == OBJ_CIRCLE) ||
653 (object->type == OBJ_LINE) ||
654 (object->type == OBJ_PATH) ||
655 (object->type == OBJ_TEXT))) {
656 color = object->color;
657 break;
661 /* Check if all other objects have the same properties */
663 while (iter != NULL) {
664 OBJECT* object = (OBJECT *) iter->data;
665 if ((object != NULL) && (
666 (object->type == OBJ_ARC) ||
667 (object->type == OBJ_BOX) ||
668 (object->type == OBJ_CIRCLE) ||
669 (object->type == OBJ_LINE) ||
670 (object->type == OBJ_PATH) ||
671 (object->type == OBJ_TEXT))) {
672 if (color != object->color) {
673 color = MULTIPLE_VALUES;
674 break;
677 iter = g_list_next (iter);
680 return color;
685 /*! \brief Get the pin type of selected objects
687 * \param [in] adapter This adapter
689 * \retval NO_SELECTION No objects are selected
690 * \retval MULTIPLE_VALUES Multiple objects with different pin types are selected
691 * \retval others The pin type of the selected objects
694 gschem_selection_adapter_get_pin_type (GschemSelectionAdapter *adapter)
696 int type = NO_SELECTION;
697 GList *iter = get_selection_iter (adapter);
699 while (iter != NULL) {
700 OBJECT* object = (OBJECT *) iter->data;
701 iter = g_list_next (iter);
702 if ((object != NULL) && (object->type == OBJ_PIN)) {
703 type = object->pin_type;
704 break;
708 /* Check if all other objects have the same properties */
710 while (iter != NULL) {
711 OBJECT* object = (OBJECT *) iter->data;
712 if ((object != NULL) && (object->type == OBJ_PIN)) {
713 if (type != object->pin_type) {
714 type = MULTIPLE_VALUES;
715 break;
718 iter = g_list_next (iter);
721 return type;
726 /*! \brief Get the selection associated with this adapter
728 * \param [in] adapter This adapter
729 * \return The libgeda selection
731 SELECTION*
732 gschem_selection_adapter_get_selection (GschemSelectionAdapter *adapter)
734 g_return_val_if_fail (adapter != NULL, NULL);
736 return adapter->selection;
741 /*! \brief Get the text alignment from the selection
743 * \param [in] adapter This adapter
745 * \retval NO_SELECTION No objects are selected
746 * \retval MULTIPLE_VALUES Multiple objects with different rotations are selected
747 * \retval others The rotation of the selected objects
750 gschem_selection_adapter_get_text_alignment (GschemSelectionAdapter *adapter)
752 gint alignment = NO_SELECTION;
753 GList *iter = get_selection_iter (adapter);
755 while (iter != NULL) {
756 OBJECT *object = (OBJECT*) iter->data;
758 if ((object != NULL) && (object->type == OBJ_TEXT)) {
759 int temp_alignment = object->text->alignment;
761 if (alignment < 0) {
762 alignment = temp_alignment;
764 else if (alignment != temp_alignment) {
765 alignment = MULTIPLE_VALUES;
766 break;
770 iter = g_list_next (iter);
773 return alignment;
778 /*! \brief Get the color of selected objects
780 * \param [in] adapter This adapter
782 * \retval NO_SELECTION No objects are selected
783 * \retval MULTIPLE_VALUES Multiple objects with different colors are selected
784 * \retval others The color of the selected objects
787 gschem_selection_adapter_get_text_color (GschemSelectionAdapter *adapter)
789 int color = NO_SELECTION;
790 GList *iter = get_selection_iter (adapter);
792 while (iter != NULL) {
793 OBJECT* object = (OBJECT *) iter->data;
794 iter = g_list_next (iter);
795 if ((object != NULL) && (object->type == OBJ_TEXT)) {
796 color = object->color;
797 break;
801 /* Check if all other objects have the same properties */
803 while (iter != NULL) {
804 OBJECT* object = (OBJECT *) iter->data;
805 if ((object != NULL) && (object->type == OBJ_TEXT)) {
806 if (color != object->color) {
807 color = MULTIPLE_VALUES;
808 break;
811 iter = g_list_next (iter);
814 return color;
819 /*! \brief Get the text rotation angle from the selection
821 * \param [in] adapter This adapter
823 * \retval NO_SELECTION No objects are selected
824 * \retval MULTIPLE_VALUES Multiple objects with different rotations are selected
825 * \retval others The rotation of the selected objects
828 gschem_selection_adapter_get_text_rotation (GschemSelectionAdapter *adapter)
830 gint angle = NO_SELECTION;
831 GList *iter = get_selection_iter (adapter);
833 while (iter != NULL) {
834 OBJECT *object = (OBJECT*) iter->data;
836 if ((object != NULL) && (object->type == OBJ_TEXT)) {
837 int temp_angle = object->text->angle;
839 if (angle < 0) {
840 angle = temp_angle;
842 else if (angle != temp_angle) {
843 angle = MULTIPLE_VALUES;
844 break;
848 iter = g_list_next (iter);
851 return angle;
856 /*! \brief Get the text size from the selection
858 * \param [in] adapter This adapter
860 * \retval NO_SELECTION No objects are selected
861 * \retval MULTIPLE_VALUES Multiple objects with different rotations are selected
862 * \retval others The rotation of the selected objects
865 gschem_selection_adapter_get_text_size (GschemSelectionAdapter *adapter)
867 gint size = NO_SELECTION;
868 GList *iter = get_selection_iter (adapter);
870 while (iter != NULL) {
871 OBJECT *object = (OBJECT*) iter->data;
873 if ((object != NULL) && (object->type == OBJ_TEXT)) {
874 int temp_size = object->text->size;
876 if (size < 0) {
877 size = temp_size;
879 else if (size != temp_size) {
880 size = MULTIPLE_VALUES;
881 break;
885 iter = g_list_next (iter);
888 return size;
892 /*! \brief Get the text string from the selection
894 * \param [in] adapter This adapter
896 * \retval NULL No objects or multiple values are selected
897 * \retval non-NULL The content string of the selected text object [transfer none]
899 const char*
900 gschem_selection_adapter_get_text_string (GschemSelectionAdapter *adapter)
902 const char *string = NULL;
903 GList *iter = get_selection_iter (adapter);
905 while (iter != NULL) {
906 OBJECT *object = (OBJECT*) iter->data;
908 if ((object != NULL) && (object->type == OBJ_TEXT)) {
909 if (string == NULL) {
910 string = o_text_get_string (adapter->toplevel, object);
911 } else {
912 string = NULL;
913 break;
917 iter = g_list_next (iter);
920 return string;
926 /*! \brief Get the libgeda toplevel associated with this adapter
928 * \param [in] adapter This adapter
929 * \return The libgeda toplevel
931 TOPLEVEL*
932 gschem_selection_adapter_get_toplevel (GschemSelectionAdapter *adapter)
934 g_return_val_if_fail (adapter != NULL, NULL);
936 return adapter->toplevel;
941 /*! \brief Get/register GschemSelection type.
943 GType
944 gschem_selection_adapter_get_type ()
946 static GType type = 0;
948 if (type == 0) {
949 static const GTypeInfo info = {
950 sizeof(GschemSelectionAdapterClass),
951 NULL, /* base_init */
952 NULL, /* base_finalize */
953 (GClassInitFunc) class_init,
954 NULL, /* class_finalize */
955 NULL, /* class_data */
956 sizeof(GschemSelectionAdapter),
957 0, /* n_preallocs */
958 (GInstanceInitFunc) instance_init,
961 type = g_type_register_static (G_TYPE_OBJECT, "GschemSelectionAdapter", &info, 0);
964 return type;
969 /*! \brief Create a new instance of the GschemSelectionAdapter
971 * \return A new instance of the GschemSelectionAdapter
973 GschemSelectionAdapter*
974 gschem_selection_adapter_new ()
976 return GSCHEM_SELECTION_ADAPTER (g_object_new (GSCHEM_TYPE_SELECTION_ADAPTER, NULL));
981 /*! \brief Set the first fill angle in the selection
983 * \param [in] selection
984 * \param [in] angle
986 void
987 gschem_selection_adapter_set_fill_angle1 (GschemSelectionAdapter *adapter, int angle)
989 GList *iter;
991 g_return_if_fail (adapter != NULL);
993 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
994 return;
997 g_return_if_fail (adapter->toplevel->page_current != NULL);
998 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
999 g_return_if_fail (angle >= 0);
1001 iter = geda_list_get_glist (adapter->selection);
1003 while (iter != NULL) {
1004 OBJECT *object = (OBJECT*) iter->data;
1005 gboolean success;
1006 gint temp_angle1;
1007 gint temp_angle2;
1008 OBJECT_FILLING temp_fill_type;
1009 gint temp_pitch1;
1010 gint temp_pitch2;
1011 gint temp_width;
1013 success = o_get_fill_options(object,
1014 &temp_fill_type,
1015 &temp_width,
1016 &temp_pitch1,
1017 &temp_angle1,
1018 &temp_pitch2,
1019 &temp_angle2);
1021 if (success) {
1022 o_set_fill_options (adapter->toplevel,
1023 object,
1024 temp_fill_type,
1025 temp_width,
1026 temp_pitch1,
1027 angle,
1028 temp_pitch2,
1029 temp_angle2);
1032 iter = g_list_next (iter);
1035 g_object_notify (G_OBJECT (adapter), "fill-angle1");
1037 g_signal_emit_by_name (adapter, "handle-undo", _("Change Fill Angle 1"));
1041 /*! \brief Set the fill angle 2 in the selection
1043 * \param [in] selection
1044 * \param [in] angle
1046 void
1047 gschem_selection_adapter_set_fill_angle2 (GschemSelectionAdapter *adapter, int angle)
1049 GList *iter;
1051 g_return_if_fail (adapter != NULL);
1053 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1054 return;
1057 g_return_if_fail (adapter->toplevel->page_current != NULL);
1058 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1059 g_return_if_fail (angle >= 0);
1061 iter = geda_list_get_glist (adapter->selection);
1063 while (iter != NULL) {
1064 OBJECT *object = (OBJECT*) iter->data;
1065 gboolean success;
1066 gint temp_angle1;
1067 gint temp_angle2;
1068 OBJECT_FILLING temp_fill_type;
1069 gint temp_pitch1;
1070 gint temp_pitch2;
1071 gint temp_width;
1073 success = o_get_fill_options(object,
1074 &temp_fill_type,
1075 &temp_width,
1076 &temp_pitch1,
1077 &temp_angle1,
1078 &temp_pitch2,
1079 &temp_angle2);
1081 if (success) {
1082 o_set_fill_options (adapter->toplevel,
1083 object,
1084 temp_fill_type,
1085 temp_width,
1086 temp_pitch1,
1087 temp_angle1,
1088 temp_pitch2,
1089 angle);
1092 iter = g_list_next (iter);
1095 g_object_notify (G_OBJECT (adapter), "fill-angle2");
1097 g_signal_emit_by_name (adapter, "handle-undo", _("Change Fill Angle 2"));
1103 /*! \brief Set the fill pitch 1 in the selection
1105 * \param [in] selection
1106 * \param [in] angle
1108 void
1109 gschem_selection_adapter_set_fill_pitch1 (GschemSelectionAdapter *adapter, int pitch)
1111 GList *iter;
1113 g_return_if_fail (adapter != NULL);
1115 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1116 return;
1119 g_return_if_fail (adapter->toplevel->page_current != NULL);
1120 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1121 g_return_if_fail (pitch >= 0);
1123 iter = geda_list_get_glist (adapter->selection);
1125 while (iter != NULL) {
1126 OBJECT *object = (OBJECT*) iter->data;
1127 gboolean success;
1128 gint temp_angle1;
1129 gint temp_angle2;
1130 OBJECT_FILLING temp_fill_type;
1131 gint temp_pitch1;
1132 gint temp_pitch2;
1133 gint temp_width;
1135 success = o_get_fill_options(object,
1136 &temp_fill_type,
1137 &temp_width,
1138 &temp_pitch1,
1139 &temp_angle1,
1140 &temp_pitch2,
1141 &temp_angle2);
1143 if (success) {
1144 o_set_fill_options (adapter->toplevel,
1145 object,
1146 temp_fill_type,
1147 temp_width,
1148 pitch,
1149 temp_angle1,
1150 temp_pitch2,
1151 temp_angle2);
1154 iter = g_list_next (iter);
1157 g_object_notify (G_OBJECT (adapter), "fill-pitch1");
1159 g_signal_emit_by_name (adapter, "handle-undo", _("Change Fill Pitch 1"));
1163 /*! \brief Set the fill pitch 2 in the selection
1165 * \param [in] selection
1166 * \param [in] pitch
1168 void
1169 gschem_selection_adapter_set_fill_pitch2 (GschemSelectionAdapter *adapter, int pitch)
1171 GList *iter;
1173 g_return_if_fail (adapter != NULL);
1175 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1176 return;
1179 g_return_if_fail (adapter->toplevel->page_current != NULL);
1180 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1181 g_return_if_fail (pitch >= 0);
1183 iter = geda_list_get_glist (adapter->selection);
1185 while (iter != NULL) {
1186 OBJECT *object = (OBJECT*) iter->data;
1187 gboolean success;
1188 gint temp_angle1;
1189 gint temp_angle2;
1190 OBJECT_FILLING temp_fill_type;
1191 gint temp_pitch1;
1192 gint temp_pitch2;
1193 gint temp_width;
1195 success = o_get_fill_options(object,
1196 &temp_fill_type,
1197 &temp_width,
1198 &temp_pitch1,
1199 &temp_angle1,
1200 &temp_pitch2,
1201 &temp_angle2);
1203 if (success) {
1204 o_set_fill_options (adapter->toplevel,
1205 object,
1206 temp_fill_type,
1207 temp_width,
1208 temp_pitch1,
1209 temp_angle1,
1210 pitch,
1211 temp_angle2);
1214 iter = g_list_next (iter);
1217 g_object_notify (G_OBJECT (adapter), "fill-pitch2");
1219 g_signal_emit_by_name (adapter, "handle-undo", _("Change Fill Pitch 2"));
1225 /*! \brief Set the fill type in the selection
1227 * \param [in] selection
1228 * \param [in] line_type
1230 void
1231 gschem_selection_adapter_set_fill_type (GschemSelectionAdapter *adapter, int fill_type)
1233 GList *iter;
1235 g_return_if_fail (adapter != NULL);
1237 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1238 return;
1241 g_return_if_fail (adapter->toplevel->page_current != NULL);
1242 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1243 g_return_if_fail (fill_type >= 0);
1245 iter = geda_list_get_glist (adapter->selection);
1247 while (iter != NULL) {
1248 OBJECT *object = (OBJECT*) iter->data;
1249 gboolean success;
1250 gint temp_angle1;
1251 gint temp_angle2;
1252 OBJECT_FILLING temp_fill_type;
1253 gint temp_pitch1;
1254 gint temp_pitch2;
1255 gint temp_width;
1257 success = o_get_fill_options(object,
1258 &temp_fill_type,
1259 &temp_width,
1260 &temp_pitch1,
1261 &temp_angle1,
1262 &temp_pitch2,
1263 &temp_angle2);
1265 if (success) {
1266 o_set_fill_options (adapter->toplevel,
1267 object,
1268 fill_type,
1269 temp_width,
1270 temp_pitch1,
1271 temp_angle1,
1272 temp_pitch2,
1273 temp_angle2);
1276 iter = g_list_next (iter);
1279 g_object_notify (G_OBJECT (adapter), "fill-angle1");
1280 g_object_notify (G_OBJECT (adapter), "fill-angle2");
1281 g_object_notify (G_OBJECT (adapter), "fill-pitch1");
1282 g_object_notify (G_OBJECT (adapter), "fill-pitch2");
1283 g_object_notify (G_OBJECT (adapter), "fill-type");
1284 g_object_notify (G_OBJECT (adapter), "fill-width");
1286 g_signal_emit_by_name (adapter, "handle-undo", _("Change Fill Properties"));
1291 /*! \brief Set the fill width in the selection
1293 * \param [in] selection
1294 * \param [in] fill_width
1296 void
1297 gschem_selection_adapter_set_fill_width (GschemSelectionAdapter *adapter, int fill_width)
1299 GList *iter;
1301 g_return_if_fail (adapter != NULL);
1303 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1304 return;
1307 g_return_if_fail (adapter->toplevel->page_current != NULL);
1308 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1309 g_return_if_fail (fill_width >= 0);
1311 iter = geda_list_get_glist (adapter->selection);
1313 while (iter != NULL) {
1314 OBJECT *object = (OBJECT*) iter->data;
1315 gboolean success;
1316 gint temp_angle1;
1317 gint temp_angle2;
1318 OBJECT_FILLING temp_fill_type;
1319 gint temp_pitch1;
1320 gint temp_pitch2;
1321 gint temp_width;
1323 success = o_get_fill_options(object,
1324 &temp_fill_type,
1325 &temp_width,
1326 &temp_pitch1,
1327 &temp_angle1,
1328 &temp_pitch2,
1329 &temp_angle2);
1331 if (success) {
1332 o_set_fill_options (adapter->toplevel,
1333 object,
1334 temp_fill_type,
1335 fill_width,
1336 temp_pitch1,
1337 temp_angle1,
1338 temp_pitch2,
1339 temp_angle2);
1342 iter = g_list_next (iter);
1345 g_object_notify (G_OBJECT (adapter), "fill-width");
1347 g_signal_emit_by_name (adapter, "handle-undo", _("Change Fill Width"));
1352 /*! \brief Set the line type in the selection
1354 * \param [in] selection
1355 * \param [in] line_type
1357 void
1358 gschem_selection_adapter_set_line_type (GschemSelectionAdapter *adapter, int line_type)
1360 GList *iter;
1362 g_return_if_fail (adapter != NULL);
1364 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1365 return;
1368 g_return_if_fail (adapter->toplevel->page_current != NULL);
1369 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1370 g_return_if_fail (line_type >= 0);
1372 iter = geda_list_get_glist (adapter->selection);
1374 while (iter != NULL) {
1375 OBJECT *object = (OBJECT*) iter->data;
1376 gboolean success;
1377 OBJECT_END temp_cap_style;
1378 int temp_dash_length;
1379 int temp_dash_space;
1380 OBJECT_TYPE temp_line_type;
1381 int temp_line_width;
1383 success = o_get_line_options (object,
1384 &temp_cap_style,
1385 &temp_line_type,
1386 &temp_line_width,
1387 &temp_dash_length,
1388 &temp_dash_space);
1390 if (success) {
1391 o_set_line_options (adapter->toplevel,
1392 object,
1393 temp_cap_style,
1394 line_type,
1395 temp_line_width,
1396 temp_dash_length,
1397 temp_dash_space);
1400 iter = g_list_next (iter);
1403 g_object_notify (G_OBJECT (adapter), "line-type");
1404 g_object_notify (G_OBJECT (adapter), "dash-length");
1405 g_object_notify (G_OBJECT (adapter), "dash-space");
1407 g_signal_emit_by_name (adapter, "handle-undo", _("Change Line Properties"));
1412 /*! \brief Set the line width in the selection
1414 * \param [in] selection
1415 * \param [in] line_width
1417 void
1418 gschem_selection_adapter_set_line_width (GschemSelectionAdapter *adapter, int line_width)
1420 GList *iter;
1422 g_return_if_fail (adapter != NULL);
1424 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1425 return;
1428 g_return_if_fail (adapter->toplevel->page_current != NULL);
1429 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1430 g_return_if_fail (line_width >= 0);
1432 iter = geda_list_get_glist (adapter->selection);
1434 while (iter != NULL) {
1435 OBJECT *object = (OBJECT*) iter->data;
1436 gboolean success;
1437 OBJECT_END temp_cap_style;
1438 int temp_dash_length;
1439 int temp_dash_space;
1440 OBJECT_TYPE temp_line_type;
1441 int temp_line_width;
1443 success = o_get_line_options (object,
1444 &temp_cap_style,
1445 &temp_line_type,
1446 &temp_line_width,
1447 &temp_dash_length,
1448 &temp_dash_space);
1450 if (success) {
1451 o_set_line_options (adapter->toplevel,
1452 object,
1453 temp_cap_style,
1454 temp_line_type,
1455 line_width,
1456 temp_dash_length,
1457 temp_dash_space);
1460 iter = g_list_next (iter);
1463 g_object_notify (G_OBJECT (adapter), "line-width");
1465 g_signal_emit_by_name (adapter, "handle-undo", _("Change Line Width"));
1470 /*! \brief Set the dash length in the selection
1472 * \param [in] selection
1473 * \param [in] dash_length
1475 void
1476 gschem_selection_adapter_set_dash_length (GschemSelectionAdapter *adapter, int dash_length)
1478 GList *iter;
1480 g_return_if_fail (adapter != NULL);
1482 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1483 return;
1486 g_return_if_fail (adapter->toplevel->page_current != NULL);
1487 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1488 g_return_if_fail (dash_length >= 0);
1490 iter = geda_list_get_glist (adapter->selection);
1492 while (iter != NULL) {
1493 OBJECT *object = (OBJECT*) iter->data;
1494 gboolean success;
1495 OBJECT_END temp_cap_style;
1496 int temp_dash_length;
1497 int temp_dash_space;
1498 OBJECT_TYPE temp_line_type;
1499 int temp_line_width;
1501 success = o_get_line_options (object,
1502 &temp_cap_style,
1503 &temp_line_type,
1504 &temp_line_width,
1505 &temp_dash_length,
1506 &temp_dash_space);
1508 if (success) {
1509 o_set_line_options (adapter->toplevel,
1510 object,
1511 temp_cap_style,
1512 temp_line_type,
1513 temp_line_width,
1514 dash_length,
1515 temp_dash_space);
1518 iter = g_list_next (iter);
1521 g_object_notify (G_OBJECT (adapter), "dash-length");
1523 g_signal_emit_by_name (adapter, "handle-undo", _("Change Line Dash Length"));
1528 /*! \brief Set the dash spacing in the selection
1530 * \param [in] selection
1531 * \param [in] dash_space
1533 void
1534 gschem_selection_adapter_set_dash_space (GschemSelectionAdapter *adapter, int dash_space)
1536 GList *iter;
1538 g_return_if_fail (adapter != NULL);
1540 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1541 return;
1544 g_return_if_fail (adapter->toplevel->page_current != NULL);
1545 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1546 g_return_if_fail (dash_space >= 0);
1548 iter = geda_list_get_glist (adapter->selection);
1550 while (iter != NULL) {
1551 OBJECT *object = (OBJECT*) iter->data;
1552 gboolean success;
1553 OBJECT_END temp_cap_style;
1554 int temp_dash_length;
1555 int temp_dash_space;
1556 OBJECT_TYPE temp_line_type;
1557 int temp_line_width;
1559 success = o_get_line_options (object,
1560 &temp_cap_style,
1561 &temp_line_type,
1562 &temp_line_width,
1563 &temp_dash_length,
1564 &temp_dash_space);
1566 if (success) {
1567 o_set_line_options (adapter->toplevel,
1568 object,
1569 temp_cap_style,
1570 temp_line_type,
1571 temp_line_width,
1572 temp_dash_length,
1573 dash_space);
1576 iter = g_list_next (iter);
1579 g_object_notify (G_OBJECT (adapter), "dash-space");
1581 g_signal_emit_by_name (adapter, "handle-undo", _("Change Line Dash Space"));
1586 /*! \brief Set the cap styles in the selection
1588 * \param [in] adapter
1589 * \param [in] cap_style
1591 void
1592 gschem_selection_adapter_set_cap_style (GschemSelectionAdapter *adapter, int cap_style)
1594 GList *iter;
1596 g_return_if_fail (adapter != NULL);
1598 if ((adapter->selection == NULL) || (adapter->toplevel == NULL)) {
1599 return;
1602 g_return_if_fail (adapter->toplevel->page_current != NULL);
1603 g_return_if_fail (adapter->toplevel->page_current->selection_list == adapter->selection);
1604 g_return_if_fail (cap_style >= 0);
1606 iter = geda_list_get_glist (adapter->selection);
1608 while (iter != NULL) {
1609 OBJECT *object = (OBJECT*) iter->data;
1610 gboolean success;
1611 OBJECT_END temp_cap_style;
1612 int temp_dash_length;
1613 int temp_dash_space;
1614 OBJECT_TYPE temp_line_type;
1615 int temp_line_width;
1617 success = o_get_line_options (object,
1618 &temp_cap_style,
1619 &temp_line_type,
1620 &temp_line_width,
1621 &temp_dash_length,
1622 &temp_dash_space);
1624 if (success) {
1625 o_set_line_options (adapter->toplevel,
1626 object,
1627 cap_style,
1628 temp_line_type,
1629 temp_line_width,
1630 temp_dash_length,
1631 temp_dash_space);
1634 iter = g_list_next (iter);
1637 g_object_notify (G_OBJECT (adapter), "cap-style");
1639 g_signal_emit_by_name (adapter, "handle-undo", _("Change Line Cap Style"));
1644 /*! \brief Set the object color in the selection
1646 * \param [in] adapter
1647 * \param [in] color
1649 void
1650 gschem_selection_adapter_set_object_color (GschemSelectionAdapter *adapter, int color)
1652 GList *iter;
1654 g_return_if_fail (adapter != NULL);
1655 g_return_if_fail (color >= 0);
1656 g_return_if_fail (color < MAX_OBJECT_COLORS);
1658 iter = geda_list_get_glist (adapter->selection);
1660 while (iter != NULL) {
1661 OBJECT *object = (OBJECT*) iter->data;
1663 o_set_color (adapter->toplevel, object, color);
1665 iter = g_list_next (iter);
1668 g_object_notify (G_OBJECT (adapter), "object-color");
1669 g_object_notify (G_OBJECT (adapter), "text-color");
1671 g_signal_emit_by_name (adapter, "handle-undo", _("Change Color"));
1676 /*! \brief Set the pin type in the selection
1678 * \param [in] adapter
1679 * \param [in] color
1681 void
1682 gschem_selection_adapter_set_pin_type (GschemSelectionAdapter *adapter, int type)
1684 GList *iter;
1686 g_return_if_fail (adapter != NULL);
1687 g_return_if_fail ((type == PIN_TYPE_NET) || (type == PIN_TYPE_BUS));
1689 iter = geda_list_get_glist (adapter->selection);
1691 while (iter != NULL) {
1692 OBJECT *object = (OBJECT*) iter->data;
1694 if (object->type == OBJ_PIN && object->pin_type != type) {
1695 s_conn_remove_object_connections (adapter->toplevel, object);
1696 o_pin_set_type (adapter->toplevel, object, type);
1697 s_conn_update_object (object->page, object);
1700 iter = g_list_next (iter);
1703 g_object_notify (G_OBJECT (adapter), "pin-type");
1705 g_signal_emit_by_name (adapter, "handle-undo", _("Change Pin Type"));
1710 /*! \brief Set the selection associated with this adapter
1712 * \param [in] adapter
1713 * \param [in] selection
1715 void
1716 gschem_selection_adapter_set_selection (GschemSelectionAdapter *adapter, SELECTION *selection)
1718 g_return_if_fail (adapter != NULL);
1720 if (adapter->selection != NULL) {
1721 g_signal_handlers_disconnect_by_func (adapter->selection,
1722 G_CALLBACK (selection_changed),
1723 adapter);
1725 g_object_unref (adapter->selection);
1728 adapter->selection = selection;
1730 if (adapter->selection != NULL) {
1731 g_object_ref (adapter->selection);
1733 g_signal_connect (adapter->selection,
1734 "changed",
1735 G_CALLBACK (selection_changed),
1736 adapter);
1739 g_object_notify (G_OBJECT (adapter), "cap-style");
1740 g_object_notify (G_OBJECT (adapter), "dash-length");
1741 g_object_notify (G_OBJECT (adapter), "dash-space");
1742 g_object_notify (G_OBJECT (adapter), "fill-angle1");
1743 g_object_notify (G_OBJECT (adapter), "fill-angle2");
1744 g_object_notify (G_OBJECT (adapter), "fill-pitch1");
1745 g_object_notify (G_OBJECT (adapter), "fill-pitch2");
1746 g_object_notify (G_OBJECT (adapter), "fill-type");
1747 g_object_notify (G_OBJECT (adapter), "fill-width");
1748 g_object_notify (G_OBJECT (adapter), "line-type");
1749 g_object_notify (G_OBJECT (adapter), "line-width");
1750 g_object_notify (G_OBJECT (adapter), "object-color");
1751 g_object_notify (G_OBJECT (adapter), "pin-type");
1756 /*! \brief Set the text alignment in the selection
1758 * \param [in] adapter
1759 * \param [in] size
1761 void
1762 gschem_selection_adapter_set_text_alignment (GschemSelectionAdapter *adapter, int alignment)
1764 GList *iter;
1766 g_return_if_fail (adapter != NULL);
1767 g_return_if_fail (adapter->toplevel != NULL);
1768 g_return_if_fail (alignment >= 0);
1770 iter = geda_list_get_glist (adapter->selection);
1772 while (iter != NULL) {
1773 OBJECT *object = (OBJECT*) iter->data;
1775 if (object->type == OBJ_TEXT) {
1776 object->text->alignment = alignment;
1777 o_text_recreate(adapter->toplevel, object);
1780 iter = g_list_next (iter);
1783 g_object_notify (G_OBJECT (adapter), "text-alignment");
1785 g_signal_emit_by_name (adapter, "handle-undo", _("Change Alignment"));
1790 /*! \brief Set the text color in the selection
1792 * \param [in] adapter
1793 * \param [in] color
1795 void
1796 gschem_selection_adapter_set_text_color (GschemSelectionAdapter *adapter, int color)
1798 GList *iter;
1800 g_return_if_fail (adapter != NULL);
1801 g_return_if_fail (color >= 0);
1802 g_return_if_fail (color < MAX_OBJECT_COLORS);
1804 iter = geda_list_get_glist (adapter->selection);
1806 while (iter != NULL) {
1807 OBJECT *object = (OBJECT*) iter->data;
1809 if (object->type == OBJ_TEXT) {
1810 o_set_color (adapter->toplevel, object, color);
1813 iter = g_list_next (iter);
1816 g_object_notify (G_OBJECT (adapter), "object-color");
1817 g_object_notify (G_OBJECT (adapter), "text-color");
1819 g_signal_emit_by_name (adapter, "handle-undo", _("Change Color"));
1824 /*! \brief Set the text rotation in the selection
1826 * \param [in] adapter
1827 * \param [in] angle
1829 void
1830 gschem_selection_adapter_set_text_rotation (GschemSelectionAdapter *adapter, int angle)
1832 GList *iter;
1834 g_return_if_fail (adapter != NULL);
1835 g_return_if_fail (adapter->toplevel != NULL);
1836 g_return_if_fail (angle >= 0);
1838 iter = geda_list_get_glist (adapter->selection);
1840 while (iter != NULL) {
1841 OBJECT *object = (OBJECT*) iter->data;
1843 if (object->type == OBJ_TEXT) {
1844 object->text->angle = angle;
1845 o_text_recreate(adapter->toplevel, object);
1848 iter = g_list_next (iter);
1851 g_object_notify (G_OBJECT (adapter), "text-rotation");
1853 g_signal_emit_by_name (adapter, "handle-undo", _("Change Rotation"));
1858 /*! \brief Set the text size in the selection
1860 * \param [in] adapter
1861 * \param [in] size
1863 void
1864 gschem_selection_adapter_set_text_size (GschemSelectionAdapter *adapter, int size)
1866 GList *iter;
1868 g_return_if_fail (adapter != NULL);
1869 g_return_if_fail (adapter->toplevel != NULL);
1870 g_return_if_fail (size >= 0);
1872 iter = geda_list_get_glist (adapter->selection);
1874 while (iter != NULL) {
1875 OBJECT *object = (OBJECT*) iter->data;
1877 if (object->type == OBJ_TEXT) {
1878 object->text->size = size;
1879 o_text_recreate(adapter->toplevel, object);
1882 iter = g_list_next (iter);
1885 g_object_notify (G_OBJECT (adapter), "text-size");
1887 g_signal_emit_by_name (adapter, "handle-undo", _("Change Text Size"));
1892 /*! \brief Set the text size in the selection
1894 * \param [in] adapter
1895 * \param [in] size
1896 * \param [in] w_current
1898 void
1899 gschem_selection_adapter_set_text_string (GschemSelectionAdapter *adapter, const char *string, GschemToplevel *w_current)
1901 GList *iter;
1903 g_return_if_fail (w_current != NULL);
1904 g_return_if_fail (adapter != NULL);
1905 g_return_if_fail (adapter->toplevel != NULL);
1906 g_return_if_fail (string != NULL);
1908 iter = geda_list_get_glist (adapter->selection);
1910 while (iter != NULL) {
1911 OBJECT *object = (OBJECT*) iter->data;
1913 if (object->type == OBJ_TEXT) {
1914 o_text_set_string (adapter->toplevel, object, string);
1916 /* handle slot= attribute, it's a special case */
1917 if (object->attached_to != NULL && g_ascii_strncasecmp (string, "slot=", 5) == 0) {
1918 o_slot_end (w_current, object->attached_to, string);
1921 o_text_recreate (adapter->toplevel, object);
1924 iter = g_list_next (iter);
1927 g_object_notify (G_OBJECT (adapter), "text-string");
1929 g_signal_emit_by_name (adapter, "handle-undo", _("Change Text"));
1934 /*! \brief Set the toplevel associated with this adapter
1936 * \param [in] adapter
1937 * \param [in] toplevel
1939 void
1940 gschem_selection_adapter_set_toplevel (GschemSelectionAdapter *adapter, TOPLEVEL *toplevel)
1942 g_return_if_fail (adapter != NULL);
1944 adapter->toplevel = toplevel;
1949 /*! \private
1950 * \brief Initialize GschemSelectionAdapter class
1952 * \param [in] klass The class for the GschemSelectionAdapter
1954 static void
1955 class_init (GschemSelectionAdapterClass *klass)
1957 G_OBJECT_CLASS (klass)->get_property = get_property;
1958 G_OBJECT_CLASS (klass)->set_property = set_property;
1960 g_object_class_install_property (G_OBJECT_CLASS (klass),
1961 PROP_CAP_STYLE,
1962 g_param_spec_int ("cap-style",
1963 "Cap Style",
1964 "Cap Style",
1965 G_MININT,
1966 G_MAXINT,
1967 NO_SELECTION,
1968 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1970 g_object_class_install_property (G_OBJECT_CLASS (klass),
1971 PROP_DASH_LENGTH,
1972 g_param_spec_int ("dash-length",
1973 "Dash Length",
1974 "Dash Length",
1975 G_MININT,
1976 G_MAXINT,
1977 NO_SELECTION,
1978 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1980 g_object_class_install_property (G_OBJECT_CLASS (klass),
1981 PROP_DASH_SPACE,
1982 g_param_spec_int ("dash-space",
1983 "Dash Space",
1984 "Dash Space",
1985 G_MININT,
1986 G_MAXINT,
1987 NO_SELECTION,
1988 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1990 g_object_class_install_property (G_OBJECT_CLASS (klass),
1991 PROP_FILL_ANGLE1,
1992 g_param_spec_int ("fill-angle1",
1993 "Fill Angle 1",
1994 "Fill Angle 1",
1995 G_MININT,
1996 G_MAXINT,
1997 NO_SELECTION,
1998 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2000 g_object_class_install_property (G_OBJECT_CLASS (klass),
2001 PROP_FILL_ANGLE2,
2002 g_param_spec_int ("fill-angle2",
2003 "Fill Angle 2",
2004 "Fill Angle 2",
2005 G_MININT,
2006 G_MAXINT,
2007 NO_SELECTION,
2008 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2010 g_object_class_install_property (G_OBJECT_CLASS (klass),
2011 PROP_FILL_PITCH1,
2012 g_param_spec_int ("fill-pitch1",
2013 "Fill Pitch 1",
2014 "Fill Pitch 1",
2015 G_MININT,
2016 G_MAXINT,
2017 NO_SELECTION,
2018 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2020 g_object_class_install_property (G_OBJECT_CLASS (klass),
2021 PROP_FILL_PITCH2,
2022 g_param_spec_int ("fill-pitch2",
2023 "Fill Pitch 2",
2024 "Fill Pitch 2",
2025 G_MININT,
2026 G_MAXINT,
2027 NO_SELECTION,
2028 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2030 g_object_class_install_property (G_OBJECT_CLASS (klass),
2031 PROP_FILL_TYPE,
2032 g_param_spec_int ("fill-type",
2033 "Fill Type",
2034 "Fill Type",
2035 G_MININT,
2036 G_MAXINT,
2037 NO_SELECTION,
2038 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2040 g_object_class_install_property (G_OBJECT_CLASS (klass),
2041 PROP_FILL_WIDTH,
2042 g_param_spec_int ("fill-width",
2043 "Fill Width",
2044 "Fill Width",
2045 G_MININT,
2046 G_MAXINT,
2047 NO_SELECTION,
2048 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2050 g_object_class_install_property (G_OBJECT_CLASS (klass),
2051 PROP_LINE_TYPE,
2052 g_param_spec_int ("line-type",
2053 "Line Type",
2054 "Line Type",
2055 G_MININT,
2056 G_MAXINT,
2057 NO_SELECTION,
2058 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2061 g_object_class_install_property (G_OBJECT_CLASS (klass),
2062 PROP_LINE_WIDTH,
2063 g_param_spec_int ("line-width",
2064 "Line Width",
2065 "Line Width",
2066 G_MININT,
2067 G_MAXINT,
2068 NO_SELECTION,
2069 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2071 g_object_class_install_property (G_OBJECT_CLASS (klass),
2072 PROP_OBJECT_COLOR,
2073 g_param_spec_int ("object-color",
2074 "Object Color",
2075 "Object Color",
2076 G_MININT,
2077 G_MAXINT,
2078 NO_SELECTION,
2079 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2081 g_object_class_install_property (G_OBJECT_CLASS (klass),
2082 PROP_PIN_TYPE,
2083 g_param_spec_int ("pin-type",
2084 "Pin Type",
2085 "Pin Type",
2086 G_MININT,
2087 G_MAXINT,
2088 NO_SELECTION,
2089 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2091 g_object_class_install_property (G_OBJECT_CLASS (klass),
2092 PROP_TEXT_ALIGNMENT,
2093 g_param_spec_int ("text-alignment",
2094 "Text Alignment",
2095 "Text Alignment",
2096 G_MININT,
2097 G_MAXINT,
2098 NO_SELECTION,
2099 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2101 g_object_class_install_property (G_OBJECT_CLASS (klass),
2102 PROP_TEXT_COLOR,
2103 g_param_spec_int ("text-color",
2104 "Text Color",
2105 "Text Color",
2106 G_MININT,
2107 G_MAXINT,
2108 NO_SELECTION,
2109 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2111 g_object_class_install_property (G_OBJECT_CLASS (klass),
2112 PROP_TEXT_ROTATION,
2113 g_param_spec_int ("text-rotation",
2114 "Text Rotation",
2115 "Text Rotation",
2116 G_MININT,
2117 G_MAXINT,
2118 NO_SELECTION,
2119 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2121 g_object_class_install_property (G_OBJECT_CLASS (klass),
2122 PROP_TEXT_SIZE,
2123 g_param_spec_int ("text-size",
2124 "Text Size",
2125 "Text Size",
2126 G_MININT,
2127 G_MAXINT,
2128 NO_SELECTION,
2129 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2131 g_object_class_install_property (G_OBJECT_CLASS (klass),
2132 PROP_TEXT_STRING,
2133 g_param_spec_string ("text-string",
2134 "Text String",
2135 "Text String",
2136 NULL,
2137 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2139 /* This signal indicates changes to the selection that requires the undo
2140 * manager save the state.
2143 g_signal_new ("handle-undo", /* signal_name */
2144 G_OBJECT_CLASS_TYPE (klass), /* itype */
2145 0, /* signal_flags */
2146 0, /* class_offset */
2147 NULL, /* accumulator */
2148 NULL, /* accu_data */
2149 g_cclosure_marshal_VOID__STRING, /* c_marshaller */
2150 G_TYPE_NONE, /* return_type */
2151 1, /* n_params */
2152 G_TYPE_POINTER);
2156 /*! \private
2157 * \brief Get an iterator for objects in the selection
2159 * \param [in] adapter this adapter
2160 * \return an iterator for the selection or NULL in none
2162 static GList*
2163 get_selection_iter (GschemSelectionAdapter *adapter)
2165 GList *iter = NULL;
2166 SELECTION *selection = gschem_selection_adapter_get_selection (adapter);
2168 if (selection != NULL) {
2169 iter = geda_list_get_glist (selection);
2172 return iter;
2176 /*! \private
2177 * \brief Get a property
2179 * \param [in] object
2180 * \param [in] param_id
2181 * \param [in,out] value
2182 * \param [in] pspec
2184 static void
2185 get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec)
2187 GschemSelectionAdapter *adapter = GSCHEM_SELECTION_ADAPTER (object);
2189 switch (param_id) {
2190 case PROP_CAP_STYLE:
2191 g_value_set_int (value, gschem_selection_adapter_get_cap_style (adapter));
2192 break;
2194 case PROP_DASH_LENGTH:
2195 g_value_set_int (value, gschem_selection_adapter_get_dash_length (adapter));
2196 break;
2198 case PROP_DASH_SPACE:
2199 g_value_set_int (value, gschem_selection_adapter_get_dash_space (adapter));
2200 break;
2202 case PROP_FILL_ANGLE1:
2203 g_value_set_int (value, gschem_selection_adapter_get_fill_angle1 (adapter));
2204 break;
2206 case PROP_FILL_ANGLE2:
2207 g_value_set_int (value, gschem_selection_adapter_get_fill_angle2 (adapter));
2208 break;
2210 case PROP_FILL_PITCH1:
2211 g_value_set_int (value, gschem_selection_adapter_get_fill_pitch1 (adapter));
2212 break;
2214 case PROP_FILL_PITCH2:
2215 g_value_set_int (value, gschem_selection_adapter_get_fill_pitch2 (adapter));
2216 break;
2218 case PROP_FILL_TYPE:
2219 g_value_set_int (value, gschem_selection_adapter_get_fill_type (adapter));
2220 break;
2222 case PROP_FILL_WIDTH:
2223 g_value_set_int (value, gschem_selection_adapter_get_fill_width (adapter));
2224 break;
2226 case PROP_LINE_TYPE:
2227 g_value_set_int (value, gschem_selection_adapter_get_line_type (adapter));
2228 break;
2230 case PROP_LINE_WIDTH:
2231 g_value_set_int (value, gschem_selection_adapter_get_line_width (adapter));
2232 break;
2234 case PROP_OBJECT_COLOR:
2235 g_value_set_int (value, gschem_selection_adapter_get_object_color (adapter));
2236 break;
2238 case PROP_PIN_TYPE:
2239 g_value_set_int (value, gschem_selection_adapter_get_pin_type (adapter));
2240 break;
2242 case PROP_TEXT_ALIGNMENT:
2243 g_value_set_int (value, gschem_selection_adapter_get_text_alignment (adapter));
2244 break;
2246 case PROP_TEXT_COLOR:
2247 g_value_set_int (value, gschem_selection_adapter_get_text_color (adapter));
2248 break;
2250 case PROP_TEXT_ROTATION:
2251 g_value_set_int (value, gschem_selection_adapter_get_text_rotation (adapter));
2252 break;
2254 case PROP_TEXT_SIZE:
2255 g_value_set_int (value, gschem_selection_adapter_get_text_size (adapter));
2256 break;
2258 case PROP_TEXT_STRING:
2259 g_value_set_string (value, gschem_selection_adapter_get_text_string (adapter));
2260 break;
2262 default:
2263 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
2269 /*! \brief Initialize GschemSelection instance
2271 * \param [in,out] selection
2273 static void
2274 instance_init (GschemSelectionAdapter *adapter)
2280 /*! \private
2281 * \brief Signal handler for when the selection changes
2283 * \par Function Description
2284 * This function gets called when items are added or removed from the
2285 * selection.
2287 * \param [in] selection The selection that changed
2288 * \param [in] adapter This adapter
2290 static void
2291 selection_changed (GedaList *selection, GschemSelectionAdapter *adapter)
2293 g_return_if_fail (adapter != NULL);
2294 g_return_if_fail (selection != NULL);
2295 g_return_if_fail (adapter->selection == selection);
2297 g_object_notify (G_OBJECT (adapter), "cap-style");
2298 g_object_notify (G_OBJECT (adapter), "dash-length");
2299 g_object_notify (G_OBJECT (adapter), "dash-space");
2300 g_object_notify (G_OBJECT (adapter), "fill-angle1");
2301 g_object_notify (G_OBJECT (adapter), "fill-angle2");
2302 g_object_notify (G_OBJECT (adapter), "fill-pitch1");
2303 g_object_notify (G_OBJECT (adapter), "fill-pitch2");
2304 g_object_notify (G_OBJECT (adapter), "fill-type");
2305 g_object_notify (G_OBJECT (adapter), "fill-width");
2306 g_object_notify (G_OBJECT (adapter), "line-type");
2307 g_object_notify (G_OBJECT (adapter), "line-width");
2308 g_object_notify (G_OBJECT (adapter), "object-color");
2309 g_object_notify (G_OBJECT (adapter), "pin-type");
2310 g_object_notify (G_OBJECT (adapter), "text-alignment");
2311 g_object_notify (G_OBJECT (adapter), "text-color");
2312 g_object_notify (G_OBJECT (adapter), "text-rotation");
2313 g_object_notify (G_OBJECT (adapter), "text-size");
2314 g_object_notify (G_OBJECT (adapter), "text-string");
2319 /*! \brief Set a property
2321 * \param [in,out] object
2322 * \param [in] param_id
2323 * \param [in] value
2324 * \param [in] pspec
2326 static void
2327 set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec)
2329 GschemSelectionAdapter *adapter = GSCHEM_SELECTION_ADAPTER (object);
2331 switch (param_id) {
2332 case PROP_CAP_STYLE:
2333 gschem_selection_adapter_set_cap_style (adapter, g_value_get_int (value));
2334 break;
2336 case PROP_DASH_LENGTH:
2337 gschem_selection_adapter_set_dash_length (adapter, g_value_get_int (value));
2338 break;
2340 case PROP_DASH_SPACE:
2341 gschem_selection_adapter_set_dash_space (adapter, g_value_get_int (value));
2342 break;
2344 case PROP_FILL_ANGLE1:
2345 gschem_selection_adapter_set_fill_angle1 (adapter, g_value_get_int (value));
2346 break;
2348 case PROP_FILL_ANGLE2:
2349 gschem_selection_adapter_set_fill_angle2 (adapter, g_value_get_int (value));
2350 break;
2352 case PROP_FILL_PITCH1:
2353 gschem_selection_adapter_set_fill_pitch1 (adapter, g_value_get_int (value));
2354 break;
2356 case PROP_FILL_PITCH2:
2357 gschem_selection_adapter_set_fill_pitch2 (adapter, g_value_get_int (value));
2358 break;
2360 case PROP_FILL_TYPE:
2361 gschem_selection_adapter_set_fill_type (adapter, g_value_get_int (value));
2362 break;
2364 case PROP_FILL_WIDTH:
2365 gschem_selection_adapter_set_fill_width (adapter, g_value_get_int (value));
2366 break;
2368 case PROP_LINE_TYPE:
2369 gschem_selection_adapter_set_line_type (adapter, g_value_get_int (value));
2370 break;
2372 case PROP_LINE_WIDTH:
2373 gschem_selection_adapter_set_line_width (adapter, g_value_get_int (value));
2374 break;
2376 case PROP_OBJECT_COLOR:
2377 gschem_selection_adapter_set_object_color (adapter, g_value_get_int (value));
2378 break;
2380 case PROP_PIN_TYPE:
2381 gschem_selection_adapter_set_pin_type (adapter, g_value_get_int (value));
2382 break;
2384 case PROP_TEXT_ALIGNMENT:
2385 gschem_selection_adapter_set_text_alignment (adapter, g_value_get_int (value));
2386 break;
2388 case PROP_TEXT_COLOR:
2389 gschem_selection_adapter_set_text_color (adapter, g_value_get_int (value));
2390 break;
2392 case PROP_TEXT_ROTATION:
2393 gschem_selection_adapter_set_text_rotation (adapter, g_value_get_int (value));
2394 break;
2396 case PROP_TEXT_SIZE:
2397 gschem_selection_adapter_set_text_size (adapter, g_value_get_int (value));
2398 break;
2400 /* Currently, the text string cannot be set using the gobject property
2401 * system
2403 * case PROP_TEXT_STRING:
2404 * gschem_selection_adapter_set_text_string (adapter, g_value_get_string (value));
2405 * break;
2408 default:
2409 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);