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
21 * \file gschem_selection_adapter.c
37 #include <gdk/gdkkeysyms.h>
67 class_init (GschemSelectionAdapterClass
*klass
);
70 get_selection_iter (GschemSelectionAdapter
*adapter
);
73 get_property (GObject
*object
, guint param_id
, GValue
*value
, GParamSpec
*pspec
);
76 instance_init (GschemSelectionAdapter
*adapter
);
79 selection_changed (GedaList
*selection
, GschemSelectionAdapter
*adapter
);
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
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
;
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
,
118 cap_style
= temp_cap_style
;
120 else if (cap_style
!= temp_cap_style
) {
121 cap_style
= MULTIPLE_VALUES
;
126 iter
= g_list_next (iter
);
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
;
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
,
165 if (dash_length
< 0) {
166 dash_length
= temp_dash_length
;
168 else if (dash_length
!= temp_dash_length
) {
169 dash_length
= MULTIPLE_VALUES
;
174 iter
= g_list_next (iter
);
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
;
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
,
213 if (dash_space
< 0) {
214 dash_space
= temp_dash_space
;
216 else if (dash_space
!= temp_dash_space
) {
217 dash_space
= MULTIPLE_VALUES
;
222 iter
= g_list_next (iter
);
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
;
249 OBJECT_FILLING temp_fill_type
;
254 success
= o_get_fill_options(object
,
264 if (fill_angle
< 0) {
265 fill_angle
= temp_angle1
;
267 else if (fill_angle
!= temp_angle1
) {
268 fill_angle
= MULTIPLE_VALUES
;
273 iter
= g_list_next (iter
);
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
;
300 OBJECT_FILLING temp_fill_type
;
305 success
= o_get_fill_options(object
,
315 if (fill_angle
< 0) {
316 fill_angle
= temp_angle2
;
318 else if (fill_angle
!= temp_angle2
) {
319 fill_angle
= MULTIPLE_VALUES
;
324 iter
= g_list_next (iter
);
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
;
351 OBJECT_FILLING temp_fill_type
;
356 success
= o_get_fill_options(object
,
366 if (fill_pitch
< 0) {
367 fill_pitch
= temp_pitch1
;
369 else if (fill_pitch
!= temp_pitch1
) {
370 fill_pitch
= MULTIPLE_VALUES
;
375 iter
= g_list_next (iter
);
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
;
402 OBJECT_FILLING temp_fill_type
;
407 success
= o_get_fill_options(object
,
417 if (fill_pitch
< 0) {
418 fill_pitch
= temp_pitch2
;
420 else if (fill_pitch
!= temp_pitch2
) {
421 fill_pitch
= MULTIPLE_VALUES
;
426 iter
= g_list_next (iter
);
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
;
453 OBJECT_FILLING temp_fill_type
;
458 success
= o_get_fill_options(object
,
469 fill_type
= temp_fill_type
;
471 else if (fill_type
!= temp_fill_type
) {
472 fill_type
= MULTIPLE_VALUES
;
477 iter
= g_list_next (iter
);
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
;
504 OBJECT_FILLING temp_fill_type
;
509 success
= o_get_fill_options(object
,
519 if (fill_width
< 0) {
520 fill_width
= temp_width
;
522 else if (fill_width
!= temp_width
) {
523 fill_width
= MULTIPLE_VALUES
;
528 iter
= g_list_next (iter
);
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
;
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
,
568 line_type
= temp_line_type
;
570 else if (line_type
!= temp_line_type
) {
571 line_type
= MULTIPLE_VALUES
;
576 iter
= g_list_next (iter
);
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
;
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
,
615 if (line_width
< 0) {
616 line_width
= temp_line_width
;
618 else if (line_width
!= temp_line_width
) {
619 line_width
= MULTIPLE_VALUES
;
624 iter
= g_list_next (iter
);
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
;
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
;
677 iter
= g_list_next (iter
);
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
;
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
;
718 iter
= g_list_next (iter
);
726 /*! \brief Get the selection associated with this adapter
728 * \param [in] adapter This adapter
729 * \return The libgeda 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
;
762 alignment
= temp_alignment
;
764 else if (alignment
!= temp_alignment
) {
765 alignment
= MULTIPLE_VALUES
;
770 iter
= g_list_next (iter
);
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
;
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
;
811 iter
= g_list_next (iter
);
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
;
842 else if (angle
!= temp_angle
) {
843 angle
= MULTIPLE_VALUES
;
848 iter
= g_list_next (iter
);
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
;
879 else if (size
!= temp_size
) {
880 size
= MULTIPLE_VALUES
;
885 iter
= g_list_next (iter
);
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]
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
);
917 iter
= g_list_next (iter
);
926 /*! \brief Get the libgeda toplevel associated with this adapter
928 * \param [in] adapter This adapter
929 * \return The libgeda 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.
944 gschem_selection_adapter_get_type ()
946 static GType 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
),
958 (GInstanceInitFunc
) instance_init
,
961 type
= g_type_register_static (G_TYPE_OBJECT
, "GschemSelectionAdapter", &info
, 0);
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
987 gschem_selection_adapter_set_fill_angle1 (GschemSelectionAdapter
*adapter
, int angle
)
991 g_return_if_fail (adapter
!= NULL
);
993 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
1008 OBJECT_FILLING temp_fill_type
;
1013 success
= o_get_fill_options(object
,
1022 o_set_fill_options (adapter
->toplevel
,
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
1047 gschem_selection_adapter_set_fill_angle2 (GschemSelectionAdapter
*adapter
, int angle
)
1051 g_return_if_fail (adapter
!= NULL
);
1053 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
1068 OBJECT_FILLING temp_fill_type
;
1073 success
= o_get_fill_options(object
,
1082 o_set_fill_options (adapter
->toplevel
,
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
1109 gschem_selection_adapter_set_fill_pitch1 (GschemSelectionAdapter
*adapter
, int pitch
)
1113 g_return_if_fail (adapter
!= NULL
);
1115 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
1130 OBJECT_FILLING temp_fill_type
;
1135 success
= o_get_fill_options(object
,
1144 o_set_fill_options (adapter
->toplevel
,
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
1169 gschem_selection_adapter_set_fill_pitch2 (GschemSelectionAdapter
*adapter
, int pitch
)
1173 g_return_if_fail (adapter
!= NULL
);
1175 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
1190 OBJECT_FILLING temp_fill_type
;
1195 success
= o_get_fill_options(object
,
1204 o_set_fill_options (adapter
->toplevel
,
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
1231 gschem_selection_adapter_set_fill_type (GschemSelectionAdapter
*adapter
, int fill_type
)
1235 g_return_if_fail (adapter
!= NULL
);
1237 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
1252 OBJECT_FILLING temp_fill_type
;
1257 success
= o_get_fill_options(object
,
1266 o_set_fill_options (adapter
->toplevel
,
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
1297 gschem_selection_adapter_set_fill_width (GschemSelectionAdapter
*adapter
, int fill_width
)
1301 g_return_if_fail (adapter
!= NULL
);
1303 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
1318 OBJECT_FILLING temp_fill_type
;
1323 success
= o_get_fill_options(object
,
1332 o_set_fill_options (adapter
->toplevel
,
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
1358 gschem_selection_adapter_set_line_type (GschemSelectionAdapter
*adapter
, int line_type
)
1362 g_return_if_fail (adapter
!= NULL
);
1364 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
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
,
1391 o_set_line_options (adapter
->toplevel
,
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
1418 gschem_selection_adapter_set_line_width (GschemSelectionAdapter
*adapter
, int line_width
)
1422 g_return_if_fail (adapter
!= NULL
);
1424 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
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
,
1451 o_set_line_options (adapter
->toplevel
,
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
1476 gschem_selection_adapter_set_dash_length (GschemSelectionAdapter
*adapter
, int dash_length
)
1480 g_return_if_fail (adapter
!= NULL
);
1482 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
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
,
1509 o_set_line_options (adapter
->toplevel
,
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
1534 gschem_selection_adapter_set_dash_space (GschemSelectionAdapter
*adapter
, int dash_space
)
1538 g_return_if_fail (adapter
!= NULL
);
1540 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
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
,
1567 o_set_line_options (adapter
->toplevel
,
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
1592 gschem_selection_adapter_set_cap_style (GschemSelectionAdapter
*adapter
, int cap_style
)
1596 g_return_if_fail (adapter
!= NULL
);
1598 if ((adapter
->selection
== NULL
) || (adapter
->toplevel
== NULL
)) {
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
;
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
,
1625 o_set_line_options (adapter
->toplevel
,
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
1650 gschem_selection_adapter_set_object_color (GschemSelectionAdapter
*adapter
, int color
)
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
1682 gschem_selection_adapter_set_pin_type (GschemSelectionAdapter
*adapter
, int type
)
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
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
),
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
,
1735 G_CALLBACK (selection_changed
),
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
1762 gschem_selection_adapter_set_text_alignment (GschemSelectionAdapter
*adapter
, int alignment
)
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
1796 gschem_selection_adapter_set_text_color (GschemSelectionAdapter
*adapter
, int color
)
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
1830 gschem_selection_adapter_set_text_rotation (GschemSelectionAdapter
*adapter
, int angle
)
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
1864 gschem_selection_adapter_set_text_size (GschemSelectionAdapter
*adapter
, int size
)
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
1896 * \param [in] w_current
1899 gschem_selection_adapter_set_text_string (GschemSelectionAdapter
*adapter
, const char *string
, GschemToplevel
*w_current
)
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
1940 gschem_selection_adapter_set_toplevel (GschemSelectionAdapter
*adapter
, TOPLEVEL
*toplevel
)
1942 g_return_if_fail (adapter
!= NULL
);
1944 adapter
->toplevel
= toplevel
;
1950 * \brief Initialize GschemSelectionAdapter class
1952 * \param [in] klass The class for the GschemSelectionAdapter
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
),
1962 g_param_spec_int ("cap-style",
1968 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
1970 g_object_class_install_property (G_OBJECT_CLASS (klass
),
1972 g_param_spec_int ("dash-length",
1978 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
1980 g_object_class_install_property (G_OBJECT_CLASS (klass
),
1982 g_param_spec_int ("dash-space",
1988 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
1990 g_object_class_install_property (G_OBJECT_CLASS (klass
),
1992 g_param_spec_int ("fill-angle1",
1998 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2000 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2002 g_param_spec_int ("fill-angle2",
2008 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2010 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2012 g_param_spec_int ("fill-pitch1",
2018 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2020 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2022 g_param_spec_int ("fill-pitch2",
2028 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2030 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2032 g_param_spec_int ("fill-type",
2038 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2040 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2042 g_param_spec_int ("fill-width",
2048 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2050 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2052 g_param_spec_int ("line-type",
2058 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2061 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2063 g_param_spec_int ("line-width",
2069 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2071 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2073 g_param_spec_int ("object-color",
2079 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2081 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2083 g_param_spec_int ("pin-type",
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",
2099 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2101 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2103 g_param_spec_int ("text-color",
2109 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2111 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2113 g_param_spec_int ("text-rotation",
2119 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2121 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2123 g_param_spec_int ("text-size",
2129 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
2131 g_object_class_install_property (G_OBJECT_CLASS (klass
),
2133 g_param_spec_string ("text-string",
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 */
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
2163 get_selection_iter (GschemSelectionAdapter
*adapter
)
2166 SELECTION
*selection
= gschem_selection_adapter_get_selection (adapter
);
2168 if (selection
!= NULL
) {
2169 iter
= geda_list_get_glist (selection
);
2177 * \brief Get a property
2179 * \param [in] object
2180 * \param [in] param_id
2181 * \param [in,out] value
2185 get_property (GObject
*object
, guint param_id
, GValue
*value
, GParamSpec
*pspec
)
2187 GschemSelectionAdapter
*adapter
= GSCHEM_SELECTION_ADAPTER (object
);
2190 case PROP_CAP_STYLE
:
2191 g_value_set_int (value
, gschem_selection_adapter_get_cap_style (adapter
));
2194 case PROP_DASH_LENGTH
:
2195 g_value_set_int (value
, gschem_selection_adapter_get_dash_length (adapter
));
2198 case PROP_DASH_SPACE
:
2199 g_value_set_int (value
, gschem_selection_adapter_get_dash_space (adapter
));
2202 case PROP_FILL_ANGLE1
:
2203 g_value_set_int (value
, gschem_selection_adapter_get_fill_angle1 (adapter
));
2206 case PROP_FILL_ANGLE2
:
2207 g_value_set_int (value
, gschem_selection_adapter_get_fill_angle2 (adapter
));
2210 case PROP_FILL_PITCH1
:
2211 g_value_set_int (value
, gschem_selection_adapter_get_fill_pitch1 (adapter
));
2214 case PROP_FILL_PITCH2
:
2215 g_value_set_int (value
, gschem_selection_adapter_get_fill_pitch2 (adapter
));
2218 case PROP_FILL_TYPE
:
2219 g_value_set_int (value
, gschem_selection_adapter_get_fill_type (adapter
));
2222 case PROP_FILL_WIDTH
:
2223 g_value_set_int (value
, gschem_selection_adapter_get_fill_width (adapter
));
2226 case PROP_LINE_TYPE
:
2227 g_value_set_int (value
, gschem_selection_adapter_get_line_type (adapter
));
2230 case PROP_LINE_WIDTH
:
2231 g_value_set_int (value
, gschem_selection_adapter_get_line_width (adapter
));
2234 case PROP_OBJECT_COLOR
:
2235 g_value_set_int (value
, gschem_selection_adapter_get_object_color (adapter
));
2239 g_value_set_int (value
, gschem_selection_adapter_get_pin_type (adapter
));
2242 case PROP_TEXT_ALIGNMENT
:
2243 g_value_set_int (value
, gschem_selection_adapter_get_text_alignment (adapter
));
2246 case PROP_TEXT_COLOR
:
2247 g_value_set_int (value
, gschem_selection_adapter_get_text_color (adapter
));
2250 case PROP_TEXT_ROTATION
:
2251 g_value_set_int (value
, gschem_selection_adapter_get_text_rotation (adapter
));
2254 case PROP_TEXT_SIZE
:
2255 g_value_set_int (value
, gschem_selection_adapter_get_text_size (adapter
));
2258 case PROP_TEXT_STRING
:
2259 g_value_set_string (value
, gschem_selection_adapter_get_text_string (adapter
));
2263 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
2269 /*! \brief Initialize GschemSelection instance
2271 * \param [in,out] selection
2274 instance_init (GschemSelectionAdapter
*adapter
)
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
2287 * \param [in] selection The selection that changed
2288 * \param [in] adapter This adapter
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
2327 set_property (GObject
*object
, guint param_id
, const GValue
*value
, GParamSpec
*pspec
)
2329 GschemSelectionAdapter
*adapter
= GSCHEM_SELECTION_ADAPTER (object
);
2332 case PROP_CAP_STYLE
:
2333 gschem_selection_adapter_set_cap_style (adapter
, g_value_get_int (value
));
2336 case PROP_DASH_LENGTH
:
2337 gschem_selection_adapter_set_dash_length (adapter
, g_value_get_int (value
));
2340 case PROP_DASH_SPACE
:
2341 gschem_selection_adapter_set_dash_space (adapter
, g_value_get_int (value
));
2344 case PROP_FILL_ANGLE1
:
2345 gschem_selection_adapter_set_fill_angle1 (adapter
, g_value_get_int (value
));
2348 case PROP_FILL_ANGLE2
:
2349 gschem_selection_adapter_set_fill_angle2 (adapter
, g_value_get_int (value
));
2352 case PROP_FILL_PITCH1
:
2353 gschem_selection_adapter_set_fill_pitch1 (adapter
, g_value_get_int (value
));
2356 case PROP_FILL_PITCH2
:
2357 gschem_selection_adapter_set_fill_pitch2 (adapter
, g_value_get_int (value
));
2360 case PROP_FILL_TYPE
:
2361 gschem_selection_adapter_set_fill_type (adapter
, g_value_get_int (value
));
2364 case PROP_FILL_WIDTH
:
2365 gschem_selection_adapter_set_fill_width (adapter
, g_value_get_int (value
));
2368 case PROP_LINE_TYPE
:
2369 gschem_selection_adapter_set_line_type (adapter
, g_value_get_int (value
));
2372 case PROP_LINE_WIDTH
:
2373 gschem_selection_adapter_set_line_width (adapter
, g_value_get_int (value
));
2376 case PROP_OBJECT_COLOR
:
2377 gschem_selection_adapter_set_object_color (adapter
, g_value_get_int (value
));
2381 gschem_selection_adapter_set_pin_type (adapter
, g_value_get_int (value
));
2384 case PROP_TEXT_ALIGNMENT
:
2385 gschem_selection_adapter_set_text_alignment (adapter
, g_value_get_int (value
));
2388 case PROP_TEXT_COLOR
:
2389 gschem_selection_adapter_set_text_color (adapter
, g_value_get_int (value
));
2392 case PROP_TEXT_ROTATION
:
2393 gschem_selection_adapter_set_text_rotation (adapter
, g_value_get_int (value
));
2396 case PROP_TEXT_SIZE
:
2397 gschem_selection_adapter_set_text_size (adapter
, g_value_get_int (value
));
2400 /* Currently, the text string cannot be set using the gobject property
2403 * case PROP_TEXT_STRING:
2404 * gschem_selection_adapter_set_text_string (adapter, g_value_get_string (value));
2409 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);