missing NULL terminator in set_config_x
[geda-gaf.git] / gschem / src / gschem_object_properties_dockable.c
blobd0d14201e0df68776370b64feab4d73a03336b0b
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_object_properties_dockable.c
23 * \brief A dialog box for editing object properties.
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 #include "../include/gschem_object_properties_dockable.h"
42 static void
43 class_init (GschemObjectPropertiesDockableClass *klass);
45 static GtkWidget*
46 create_fill_property_widget (GschemObjectPropertiesDockable *dialog);
48 static GtkWidget*
49 create_general_property_widget (GschemObjectPropertiesDockable *dialog);
51 static GtkWidget*
52 create_line_property_widget (GschemObjectPropertiesDockable *dialog);
54 static GtkWidget*
55 create_pin_property_widget (GschemObjectPropertiesDockable *dialog);
57 static void
58 dispose (GObject *object);
60 static GtkWidget *
61 create_widget (GschemDockable *parent);
63 static void
64 set_selection_adapter (GschemObjectPropertiesDockable *dialog, GschemSelectionAdapter *adapter);
66 static void
67 update_cap_style_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog);
69 static void
70 update_cap_style_widget (GschemObjectPropertiesDockable *dialog);
72 static void
73 update_fill_type_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog);
75 static void
76 update_fill_type_widget (GschemObjectPropertiesDockable *dialog);
78 static void
79 update_line_type_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog);
81 static void
82 update_line_type_widget (GschemObjectPropertiesDockable *dialog);
84 static void
85 update_object_color_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog);
87 static void
88 update_object_color_widget (GschemObjectPropertiesDockable *dialog);
90 static void
91 update_pin_type_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog);
93 static void
94 update_pin_type_widget (GschemObjectPropertiesDockable *dialog);
97 /*! \brief Get/register GschemObjectPropertiesDockable type.
99 GType
100 gschem_object_properties_dockable_get_type()
102 static GType type = 0;
104 if (type == 0) {
105 static const GTypeInfo info = {
106 sizeof(GschemObjectPropertiesDockableClass),
107 NULL, /* base_init */
108 NULL, /* base_finalize */
109 (GClassInitFunc) class_init,
110 NULL, /* class_finalize */
111 NULL, /* class_data */
112 sizeof(GschemObjectPropertiesDockable),
113 0, /* n_preallocs */
114 NULL, /* instance_init */
117 type = g_type_register_static (GSCHEM_TYPE_DOCKABLE, "GschemObjectPropertiesDockable", &info, 0);
120 return type;
125 /*! \private
126 * \brief Initialize GschemObjectPropertiesDockable class
128 * \par Function Description
130 * GType class initialiser for Multiattrib. We override our parent
131 * virtual class methods as needed and register our GObject properties.
133 * \param [in] klass
135 static void
136 class_init (GschemObjectPropertiesDockableClass *klass)
138 GObjectClass *object_class;
140 g_return_if_fail (klass != NULL);
142 GSCHEM_DOCKABLE_CLASS (klass)->create_widget = create_widget;
144 object_class = G_OBJECT_CLASS (klass);
146 g_return_if_fail (object_class != NULL);
148 object_class->dispose = dispose;
153 /*! \private
154 * \brief Create a fill property section widget
156 * \param [in] dialog
157 * \return A new fill property section widget
159 static GtkWidget*
160 create_fill_property_widget (GschemObjectPropertiesDockable *dialog)
162 GtkWidget *label[6];
163 GtkWidget *table;
164 GtkWidget *widget[6];
166 label[0] = gschem_dialog_misc_create_property_label (_("Fill Type:"));
167 label[1] = gschem_dialog_misc_create_property_label (_("Line Width:"));
168 label[2] = gschem_dialog_misc_create_property_label (_("Angle 1:"));
169 label[3] = gschem_dialog_misc_create_property_label (_("Pitch 1:"));
170 label[4] = gschem_dialog_misc_create_property_label (_("Angle 2:"));
171 label[5] = gschem_dialog_misc_create_property_label (_("Pitch 2:"));
173 widget[0] = dialog->fstylecb = x_fstylecb_new ();
174 widget[1] = dialog->widthe = gschem_integer_combo_box_new ();
175 widget[2] = dialog->angle1e = gschem_integer_combo_box_new ();
176 widget[3] = dialog->pitch1e = gschem_integer_combo_box_new ();
177 widget[4] = dialog->angle2e = gschem_integer_combo_box_new ();
178 widget[5] = dialog->pitch2e = gschem_integer_combo_box_new ();
180 table = gschem_dialog_misc_create_property_table (label, widget, 6);
182 dialog->bindings = g_slist_append (dialog->bindings,
183 gschem_binding_integer_new ("fill-width",
184 widget[1]));
186 dialog->bindings = g_slist_append (dialog->bindings,
187 gschem_binding_integer_new ("fill-angle1",
188 widget[2]));
190 dialog->bindings = g_slist_append (dialog->bindings,
191 gschem_binding_integer_new ("fill-pitch1",
192 widget[3]));
194 dialog->bindings = g_slist_append (dialog->bindings,
195 gschem_binding_integer_new ("fill-angle2",
196 widget[4]));
198 dialog->bindings = g_slist_append (dialog->bindings,
199 gschem_binding_integer_new ("fill-pitch2",
200 widget[5]));
202 g_signal_connect (G_OBJECT (dialog->fstylecb), "changed",
203 G_CALLBACK (update_fill_type_model),
204 dialog);
206 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->widthe)),
207 "activate",
208 G_CALLBACK (gschem_dialog_misc_entry_activate),
209 dialog);
211 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->angle1e)),
212 "activate",
213 G_CALLBACK (gschem_dialog_misc_entry_activate),
214 dialog);
216 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->pitch1e)),
217 "activate",
218 G_CALLBACK (gschem_dialog_misc_entry_activate),
219 dialog);
221 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->angle2e)),
222 "activate",
223 G_CALLBACK (gschem_dialog_misc_entry_activate),
224 dialog);
226 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->pitch2e)),
227 "activate",
228 G_CALLBACK (gschem_dialog_misc_entry_activate),
229 dialog);
231 return gschem_dialog_misc_create_section_widget (_("<b>Fill Properties</b>"), table);
236 /*! \private
237 * \brief Create a general property section widget
239 * \param [in] dialog
240 * \return A new general property section widget
242 static GtkWidget*
243 create_general_property_widget (GschemObjectPropertiesDockable *dialog)
245 GtkWidget *label[1];
246 GtkWidget *table;
247 GtkWidget *widget[1];
249 label[0] = gschem_dialog_misc_create_property_label (_("Color:"));
251 widget[0] = dialog->colorcb = x_colorcb_new ();
253 table = gschem_dialog_misc_create_property_table (label, widget, 1);
255 g_signal_connect(G_OBJECT (dialog->colorcb),
256 "changed",
257 G_CALLBACK (update_object_color_model),
258 dialog);
260 return gschem_dialog_misc_create_section_widget (_("<b>General Properties</b>"), table);
265 /*! \private
266 * \brief Create a line property section widget
268 * \param [in] dialog
269 * \return A new line property section widget
271 static GtkWidget*
272 create_line_property_widget (GschemObjectPropertiesDockable *dialog)
274 GtkWidget *label[5];
275 GtkWidget *table;
276 GtkWidget *widget[5];
278 label[0] = gschem_dialog_misc_create_property_label (_("Type:"));
279 label[1] = gschem_dialog_misc_create_property_label (_("Width:"));
280 label[2] = gschem_dialog_misc_create_property_label (_("Dash Length:"));
281 label[3] = gschem_dialog_misc_create_property_label (_("Dash Space:"));
282 label[4] = gschem_dialog_misc_create_property_label (_("Cap style:"));
284 widget[0] = dialog->line_type = x_linetypecb_new ();
285 widget[1] = dialog->width_entry = gschem_integer_combo_box_new ();
286 widget[2] = dialog->length_entry = gschem_integer_combo_box_new ();
287 widget[3] = dialog->space_entry = gschem_integer_combo_box_new ();
288 widget[4] = dialog->line_end = x_linecapcb_new ();
290 table = gschem_dialog_misc_create_property_table (label, widget, 5);
292 dialog->bindings = g_slist_append (dialog->bindings,
293 gschem_binding_integer_new ("line-width",
294 widget[1]));
296 dialog->bindings = g_slist_append (dialog->bindings,
297 gschem_binding_integer_new ("dash-length",
298 widget[2]));
300 dialog->bindings = g_slist_append (dialog->bindings,
301 gschem_binding_integer_new ("dash-space",
302 widget[3]));
304 g_signal_connect (G_OBJECT (dialog->line_type), "changed",
305 G_CALLBACK (update_line_type_model),
306 dialog);
308 g_signal_connect (G_OBJECT (dialog->line_end), "changed",
309 G_CALLBACK (update_cap_style_model),
310 dialog);
312 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->width_entry)),
313 "activate",
314 G_CALLBACK (gschem_dialog_misc_entry_activate),
315 dialog);
317 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->length_entry)),
318 "activate",
319 G_CALLBACK (gschem_dialog_misc_entry_activate),
320 dialog);
322 g_signal_connect (G_OBJECT (gschem_integer_combo_box_get_entry (dialog->space_entry)),
323 "activate",
324 G_CALLBACK (gschem_dialog_misc_entry_activate),
325 dialog);
327 return gschem_dialog_misc_create_section_widget (_("<b>Line Properties</b>"), table);
332 /*! \private
333 * \brief Create a pin property section widget
335 * \param [in] dialog
336 * \return A new pin property section widget
338 static GtkWidget*
339 create_pin_property_widget (GschemObjectPropertiesDockable *dialog)
341 GtkWidget *label[1];
342 GtkWidget *table;
343 GtkWidget *widget[1];
345 label[0] = gschem_dialog_misc_create_property_label (_("Pin Type:"));
347 widget[0] = dialog->pin_type = gschem_pin_type_combo_new ();
349 table = gschem_dialog_misc_create_property_table (label, widget, 1);
351 g_signal_connect (G_OBJECT (dialog->pin_type),
352 "changed",
353 G_CALLBACK (update_pin_type_model),
354 dialog);
356 return gschem_dialog_misc_create_section_widget (_("<b>Pin Properties</b>"), table);
361 /*! \brief Dispose
363 * \param [in,out] object This object
365 static void
366 dispose (GObject *object)
368 GschemObjectPropertiesDockable *dialog;
369 GschemObjectPropertiesDockableClass *klass;
370 GObjectClass *parent_class;
372 g_return_if_fail (object != NULL);
374 dialog = GSCHEM_OBJECT_PROPERTIES_DOCKABLE (object);
376 set_selection_adapter (dialog, NULL);
378 g_slist_foreach (dialog->bindings, (GFunc) g_object_unref, NULL);
379 g_slist_free (dialog->bindings);
380 dialog->bindings = NULL;
382 /* lastly, chain up to the parent dispose */
384 klass = GSCHEM_OBJECT_PROPERTIES_DOCKABLE_GET_CLASS (object);
385 g_return_if_fail (klass != NULL);
386 parent_class = g_type_class_peek_parent (klass);
387 g_return_if_fail (parent_class != NULL);
388 parent_class->dispose (object);
392 /*! \private
393 * \brief Create GschemObjectPropertiesDockable widgets and set up
394 * property change notifications
396 * \param [in,out] parent This dockable
398 static GtkWidget *
399 create_widget (GschemDockable *parent)
401 GschemObjectPropertiesDockable *dialog =
402 GSCHEM_OBJECT_PROPERTIES_DOCKABLE (parent);
403 GschemToplevel *w_current = parent->w_current;
405 GtkWidget *scrolled;
406 GtkWidget *vbox;
407 GtkWidget *viewport;
409 scrolled = gtk_scrolled_window_new (NULL, NULL);
411 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
412 GTK_POLICY_NEVER,
413 GTK_POLICY_AUTOMATIC);
415 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
416 GTK_SHADOW_NONE);
418 viewport = gtk_viewport_new (NULL, NULL);
419 gtk_container_add (GTK_CONTAINER (scrolled), viewport);
421 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport),
422 GTK_SHADOW_NONE);
424 vbox = gtk_vbox_new (FALSE, DIALOG_V_SPACING);
425 gtk_container_set_border_width (GTK_CONTAINER (vbox), DIALOG_BORDER_SPACING);
426 gtk_container_add (GTK_CONTAINER (viewport), vbox);
428 dialog->general_section_widget = create_general_property_widget (dialog);
429 dialog->line_section_widget = create_line_property_widget (dialog);
430 dialog->fill_section_widget = create_fill_property_widget (dialog);
431 dialog->pin_section_widget = create_pin_property_widget (dialog);
433 gtk_box_pack_start (GTK_BOX (vbox), /* box */
434 dialog->general_section_widget, /* child */
435 FALSE, /* expand */
436 FALSE, /* fill */
437 0); /* padding */
439 gtk_box_pack_start (GTK_BOX (vbox), /* box */
440 dialog->line_section_widget, /* child */
441 FALSE, /* expand */
442 FALSE, /* fill */
443 0); /* padding */
445 gtk_box_pack_start (GTK_BOX (vbox), /* box */
446 dialog->fill_section_widget, /* child */
447 FALSE, /* expand */
448 FALSE, /* fill */
449 0); /* padding */
451 gtk_box_pack_start (GTK_BOX (vbox), /* box */
452 dialog->pin_section_widget, /* child */
453 FALSE, /* expand */
454 FALSE, /* fill */
455 0); /* padding */
458 gschem_integer_combo_box_set_model (dialog->width_entry,
459 gschem_toplevel_get_line_width_list_store (w_current));
461 gschem_integer_combo_box_set_model (dialog->length_entry,
462 gschem_toplevel_get_dash_length_list_store (w_current));
464 gschem_integer_combo_box_set_model (dialog->space_entry,
465 gschem_toplevel_get_dash_space_list_store (w_current));
467 gschem_integer_combo_box_set_model (dialog->widthe,
468 gschem_toplevel_get_fill_width_list_store (w_current));
470 gschem_integer_combo_box_set_model (dialog->angle1e,
471 gschem_toplevel_get_fill_angle_list_store (w_current));
473 gschem_integer_combo_box_set_model (dialog->pitch1e,
474 gschem_toplevel_get_fill_pitch_list_store (w_current));
476 gschem_integer_combo_box_set_model (dialog->angle2e,
477 gschem_toplevel_get_fill_angle_list_store (w_current));
479 gschem_integer_combo_box_set_model (dialog->pitch2e,
480 gschem_toplevel_get_fill_pitch_list_store (w_current));
482 set_selection_adapter (dialog,
483 gschem_toplevel_get_selection_adapter (w_current));
486 gtk_widget_show_all (scrolled);
487 return scrolled;
492 /*! \private
493 * \brief Set the selection that this dialog manipulates
495 * \param [in,out] dialog This dialog
496 * \param [in] selection The selection to manipulate
498 static void
499 set_selection_adapter (GschemObjectPropertiesDockable *dialog, GschemSelectionAdapter *adapter)
501 g_return_if_fail (dialog != NULL);
503 if (dialog->adapter != NULL) {
504 g_signal_handlers_disconnect_by_func (dialog->adapter,
505 G_CALLBACK (update_pin_type_widget),
506 dialog);
508 g_signal_handlers_disconnect_by_func (dialog->adapter,
509 G_CALLBACK (update_object_color_widget),
510 dialog);
512 g_signal_handlers_disconnect_by_func (dialog->adapter,
513 G_CALLBACK (update_line_type_widget),
514 dialog);
516 g_signal_handlers_disconnect_by_func (dialog->adapter,
517 G_CALLBACK (update_fill_type_widget),
518 dialog);
520 g_signal_handlers_disconnect_by_func (dialog->adapter,
521 G_CALLBACK (update_cap_style_widget),
522 dialog);
524 g_object_unref (dialog->adapter);
527 dialog->adapter = adapter;
529 g_slist_foreach (dialog->bindings,
530 (GFunc) gschem_binding_set_model_object,
531 adapter);
533 if (dialog->adapter != NULL) {
534 g_object_ref (dialog->adapter);
536 g_signal_connect_swapped (dialog->adapter,
537 "notify::cap-style",
538 G_CALLBACK (update_cap_style_widget),
539 dialog);
541 g_signal_connect_swapped (dialog->adapter,
542 "notify::fill-type",
543 G_CALLBACK (update_fill_type_widget),
544 dialog);
546 g_signal_connect_swapped (dialog->adapter,
547 "notify::line-type",
548 G_CALLBACK (update_line_type_widget),
549 dialog);
551 g_signal_connect_swapped (dialog->adapter,
552 "notify::object-color",
553 G_CALLBACK (update_object_color_widget),
554 dialog);
556 g_signal_connect_swapped (dialog->adapter,
557 "notify::pin-type",
558 G_CALLBACK (update_pin_type_widget),
559 dialog);
561 update_cap_style_widget (dialog);
562 update_fill_type_widget (dialog);
563 update_line_type_widget (dialog);
564 update_object_color_widget (dialog);
565 update_pin_type_widget (dialog);
571 /*! \brief Update the cap style value in the model
573 * \param [in] widget The widget emitting the event
574 * \param [in] dialog The line properties dialog box
576 static void
577 update_cap_style_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog)
579 TOPLEVEL *toplevel;
580 GschemToplevel *w_current;
582 g_return_if_fail (dialog != NULL);
583 g_return_if_fail (widget != NULL);
585 w_current = dialog->parent.w_current;
586 g_return_if_fail (w_current != NULL);
588 toplevel = gschem_toplevel_get_toplevel (w_current);
589 g_return_if_fail (toplevel != NULL);
591 if ((dialog->adapter != NULL) && (dialog->line_end != NULL)) {
592 int cap_style;
594 g_return_if_fail (widget == dialog->line_end);
596 cap_style = x_linecapcb_get_index (dialog->line_end);
598 if (cap_style >= 0) {
599 gschem_selection_adapter_set_cap_style (dialog->adapter, cap_style);
606 /*! \private
607 * \brief Update the value in the cap style widget
609 * \param [in,out] dialog This dialog
611 static void
612 update_cap_style_widget (GschemObjectPropertiesDockable *dialog)
614 g_return_if_fail (dialog != NULL);
615 g_return_if_fail (dialog->line_end != NULL);
617 if (dialog->adapter != NULL) {
618 int end = gschem_selection_adapter_get_cap_style (dialog->adapter);
620 g_signal_handlers_block_by_func (G_OBJECT (dialog->line_end),
621 G_CALLBACK (update_cap_style_model),
622 dialog);
624 x_linecapcb_set_index (dialog->line_end, end);
626 g_signal_handlers_unblock_by_func (G_OBJECT (dialog->line_end),
627 G_CALLBACK (update_cap_style_model),
628 dialog);
630 gtk_widget_set_sensitive (GTK_WIDGET (dialog->line_end), (end != NO_SELECTION));
636 /*! \private
637 * \brief Update the cap style value in the model
639 * \param [in] widget The widget emitting the event
640 * \param [in] dialog The line properties dialog box
642 static void
643 update_fill_type_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog)
645 TOPLEVEL *toplevel;
646 GschemToplevel *w_current;
648 g_return_if_fail (dialog != NULL);
649 g_return_if_fail (widget != NULL);
651 w_current = dialog->parent.w_current;
652 g_return_if_fail (w_current != NULL);
654 toplevel = gschem_toplevel_get_toplevel (w_current);
655 g_return_if_fail (toplevel != NULL);
657 if ((dialog->adapter != NULL) && (dialog->fstylecb != NULL)) {
658 int fill_type;
660 g_return_if_fail (widget == dialog->fstylecb);
662 fill_type = x_fstylecb_get_index (dialog->fstylecb);
664 if (fill_type >= 0) {
665 gschem_selection_adapter_set_fill_type (dialog->adapter, fill_type);
672 /*! \private
673 * \brief Update the value in the fill type widget
675 * \param [in,out] dialog This dialog
677 static void
678 update_fill_type_widget (GschemObjectPropertiesDockable *dialog)
680 g_return_if_fail (dialog != NULL);
681 g_return_if_fail (dialog->fstylecb != NULL);
683 if (dialog->adapter != NULL) {
684 int index = gschem_selection_adapter_get_fill_type (dialog->adapter);
686 g_signal_handlers_block_by_func (G_OBJECT (dialog->fstylecb),
687 G_CALLBACK (update_fill_type_model),
688 dialog);
690 x_fstylecb_set_index (dialog->fstylecb, index);
692 g_signal_handlers_unblock_by_func (G_OBJECT (dialog->fstylecb),
693 G_CALLBACK (update_fill_type_model),
694 dialog);
696 gtk_widget_set_sensitive (GTK_WIDGET (dialog->fstylecb), (index != NO_SELECTION));
702 /*! \brief Update the line type value in the model
704 * \param [in] widget The widget emitting the event
705 * \param [in] dialog The line properties dialog box
707 static void
708 update_line_type_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog)
710 TOPLEVEL *toplevel;
711 GschemToplevel *w_current;
713 g_return_if_fail (dialog != NULL);
714 g_return_if_fail (widget != NULL);
716 w_current = dialog->parent.w_current;
717 g_return_if_fail (w_current != NULL);
719 toplevel = gschem_toplevel_get_toplevel (w_current);
720 g_return_if_fail (toplevel != NULL);
722 if ((dialog->adapter != NULL) && (dialog->line_type != NULL)) {
723 int line_type;
725 g_return_if_fail (widget == dialog->line_type);
727 line_type = x_linetypecb_get_index (dialog->line_type);
729 if (line_type >= 0) {
730 gschem_selection_adapter_set_line_type (dialog->adapter, line_type);
737 /*! \private
738 * \brief Update the value in the line type widget
740 * \param [in,out] dialog This dialog
742 static void
743 update_line_type_widget (GschemObjectPropertiesDockable *dialog)
745 g_return_if_fail (dialog != NULL);
746 g_return_if_fail (dialog->line_type != NULL);
748 if (dialog->adapter != NULL) {
749 int type = gschem_selection_adapter_get_line_type (dialog->adapter);
751 g_signal_handlers_block_by_func (G_OBJECT (dialog->line_type),
752 G_CALLBACK (update_line_type_model),
753 dialog);
755 x_linetypecb_set_index (dialog->line_type, type);
757 g_signal_handlers_unblock_by_func (G_OBJECT (dialog->line_type),
758 G_CALLBACK (update_line_type_model),
759 dialog);
761 gtk_widget_set_sensitive (GTK_WIDGET (dialog->line_type), (type != NO_SELECTION));
767 /*! \brief Update the object color value in the model
769 * \param [in] widget The widget emitting the event
770 * \param [in] dialog The line properties dialog box
772 static void
773 update_object_color_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog)
775 TOPLEVEL *toplevel;
776 GschemToplevel *w_current;
778 g_return_if_fail (dialog != NULL);
779 g_return_if_fail (widget != NULL);
781 w_current = dialog->parent.w_current;
782 g_return_if_fail (w_current != NULL);
784 toplevel = gschem_toplevel_get_toplevel (w_current);
785 g_return_if_fail (toplevel != NULL);
787 if ((dialog->adapter != NULL) && (dialog->colorcb != NULL)) {
788 int color;
790 g_return_if_fail (widget == dialog->colorcb);
792 color = x_colorcb_get_index (dialog->colorcb);
794 if (color >= 0) {
795 gschem_selection_adapter_set_object_color (dialog->adapter, color);
802 /*! \private
803 * \brief Update the value in the object color widget
805 * \param [in,out] dialog This dialog
807 static void
808 update_object_color_widget (GschemObjectPropertiesDockable *dialog)
810 g_return_if_fail (dialog != NULL);
811 g_return_if_fail (dialog->colorcb != NULL);
813 if (dialog->adapter != NULL) {
814 int color = gschem_selection_adapter_get_object_color (dialog->adapter);
816 g_signal_handlers_block_by_func (G_OBJECT (dialog->colorcb),
817 G_CALLBACK (update_object_color_model),
818 dialog);
820 x_colorcb_set_index (dialog->colorcb, color);
822 g_signal_handlers_unblock_by_func (G_OBJECT (dialog->colorcb),
823 G_CALLBACK (update_object_color_model),
824 dialog);
826 gtk_widget_set_sensitive (GTK_WIDGET (dialog->colorcb), (color != NO_SELECTION));
831 /*! \brief Update the pin type value in the model
833 * \param [in] widget The widget emitting the event
834 * \param [in] dialog The line properties dialog box
836 static void
837 update_pin_type_model (GtkWidget *widget, GschemObjectPropertiesDockable *dialog)
839 TOPLEVEL *toplevel;
840 GschemToplevel *w_current;
842 g_return_if_fail (dialog != NULL);
843 g_return_if_fail (widget != NULL);
845 w_current = dialog->parent.w_current;
846 g_return_if_fail (w_current != NULL);
848 toplevel = gschem_toplevel_get_toplevel (w_current);
849 g_return_if_fail (toplevel != NULL);
851 if ((dialog->adapter != NULL) && (dialog->pin_type != NULL)) {
852 int pin_type;
854 g_return_if_fail (widget == dialog->pin_type);
856 pin_type = gschem_pin_type_combo_get_index (dialog->pin_type);
858 if (pin_type >= 0) {
859 gschem_selection_adapter_set_pin_type (dialog->adapter, pin_type);
866 /*! \private
867 * \brief Update the value in the pin type widget
869 * \param [in,out] dialog This dialog
871 static void
872 update_pin_type_widget (GschemObjectPropertiesDockable *dialog)
874 g_return_if_fail (dialog != NULL);
875 g_return_if_fail (dialog->pin_type != NULL);
877 if (dialog->adapter != NULL) {
878 int type = gschem_selection_adapter_get_pin_type (dialog->adapter);
880 g_signal_handlers_block_by_func (G_OBJECT (dialog->pin_type),
881 G_CALLBACK (update_pin_type_model),
882 dialog);
884 gschem_pin_type_combo_set_index (dialog->pin_type, type);
886 g_signal_handlers_unblock_by_func (G_OBJECT (dialog->pin_type),
887 G_CALLBACK (update_pin_type_model),
888 dialog);
890 gtk_widget_set_sensitive (GTK_WIDGET (dialog->pin_type), (type != NO_SELECTION));