missing NULL terminator in set_config_x
[geda-gaf.git] / gschem / src / gschem_arc_dialog.c
blobf03f94b0e66f1ffb8c73b1309e7797e046fc9609
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 /*! \todo STILL NEED to clean up line lengths in aa and tr */
21 #include <config.h>
23 #include <stdio.h>
24 #ifdef HAVE_STDLIB_H
25 #include <stdlib.h>
26 #endif
27 #ifdef HAVE_STRING_H
28 #include <string.h>
29 #endif
31 #include "gschem.h"
33 #define GLADE_HOOKUP_OBJECT(component,widget,name) \
34 g_object_set_data_full (G_OBJECT (component), name, \
35 gtk_widget_ref (widget), (GDestroyNotify) g_object_unref)
37 /***************** Start of Arc dialog box ***************************/
39 /*! \brief response function for the arc angle dialog
40 * \par Function Description
41 * The response function of th arc angle dialog takes the content of
42 * the dialog and applies it on the current arc.
43 * If the dialog is closed or canceled the function destroys the dialog.
45 void arc_angle_dialog_response(GtkWidget *w, gint response,
46 GschemToplevel *w_current)
48 GtkWidget *spinentry;
49 gint radius, start_angle, sweep_angle;
50 OBJECT *arc_object = NULL;
52 switch (response) {
53 case GTK_RESPONSE_REJECT:
54 case GTK_RESPONSE_DELETE_EVENT:
55 /* void */
56 break;
57 case GTK_RESPONSE_ACCEPT:
58 spinentry = g_object_get_data(G_OBJECT(w_current->aawindow),"radius");
59 radius = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinentry));
60 spinentry = g_object_get_data(G_OBJECT(w_current->aawindow),"spin_start");
61 start_angle = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinentry));
62 spinentry = g_object_get_data(G_OBJECT(w_current->aawindow),"spin_sweep");
63 sweep_angle = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinentry));
64 arc_object = (OBJECT*) g_object_get_data(G_OBJECT(w_current->aawindow),"arc_object");
66 if (arc_object != NULL) {
67 o_arc_modify(w_current->toplevel, arc_object, radius, 0, ARC_RADIUS);
68 o_arc_modify(w_current->toplevel, arc_object, start_angle, 0, ARC_START_ANGLE);
69 o_arc_modify(w_current->toplevel, arc_object, sweep_angle, 0, ARC_SWEEP_ANGLE);
70 } else {
71 o_arc_end4(w_current, radius, start_angle, sweep_angle);
73 break;
74 default:
75 printf("arc_angle_dialog_response(): strange signal %d\n",response);
78 gtk_widget_destroy(w_current->aawindow);
79 w_current->aawindow = NULL;
82 /*! \brief Creates the arc angle dialog
83 * \par Function Description
84 * This function creates the arc angle dialog. Depending on the
85 * \a arc_object the entries are filled with the arc OBJECT properties
86 * or with some standard values.
88 * \param [in] w_current The GschemToplevel object
89 * \param [in] arc_object an arc OBJECT if used to modify an arc
90 * or NULL to create a new arc.
92 void arc_angle_dialog (GschemToplevel *w_current, OBJECT *arc_object)
94 GtkWidget *label[3];
95 GtkWidget *vbox;
96 GtkWidget *alignment, *table;
97 GtkWidget *widget[3];
99 if (!w_current->aawindow) {
100 w_current->aawindow = gschem_dialog_new_with_buttons(_("Arc Params"),
101 GTK_WINDOW(w_current->main_window),
102 GTK_DIALOG_MODAL,
103 "arc-angle", w_current,
104 GTK_STOCK_CANCEL,
105 GTK_RESPONSE_REJECT,
106 GTK_STOCK_OK,
107 GTK_RESPONSE_ACCEPT,
108 NULL);
110 /* Set the alternative button order (ok, cancel, help) for other systems */
111 gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->aawindow),
112 GTK_RESPONSE_ACCEPT,
113 GTK_RESPONSE_REJECT,
114 -1);
116 gtk_window_set_position (GTK_WINDOW (w_current->aawindow), GTK_WIN_POS_MOUSE);
118 g_signal_connect (G_OBJECT (w_current->aawindow), "response",
119 G_CALLBACK (arc_angle_dialog_response),
120 w_current);
122 gtk_dialog_set_default_response(GTK_DIALOG(w_current->aawindow),
123 GTK_RESPONSE_ACCEPT);
125 gtk_container_set_border_width (GTK_CONTAINER (w_current->aawindow),
126 DIALOG_BORDER_SPACING);
127 vbox = GTK_DIALOG(w_current->aawindow)->vbox;
128 gtk_box_set_spacing(GTK_BOX(vbox), DIALOG_V_SPACING);
131 alignment = gtk_alignment_new(0,0,1,1);
132 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0,
133 0 /*DIALOG_INDENTATION */, 0);
134 gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, FALSE, 0);
136 label[0] = gschem_dialog_misc_create_property_label (_("Arc Radius:"));
137 label[1] = gschem_dialog_misc_create_property_label (_("Start Angle:"));
138 label[2] = gschem_dialog_misc_create_property_label (_("Degrees of Sweep:"));
140 widget[0] = gtk_spin_button_new_with_range (1, 100000, 100);
141 gtk_entry_set_activates_default (GTK_ENTRY(widget[0]), TRUE);
143 widget[1] = gtk_spin_button_new_with_range (-360,360,1);
144 gtk_entry_set_activates_default (GTK_ENTRY(widget[1]), TRUE);
146 widget[2] = gtk_spin_button_new_with_range (-360,360,1);
147 gtk_entry_set_activates_default(GTK_ENTRY(widget[2]), TRUE);
149 table = gschem_dialog_misc_create_property_table (label, widget, 3);
150 gtk_container_add (GTK_CONTAINER(alignment), table);
152 GLADE_HOOKUP_OBJECT(w_current->aawindow, widget[0], "radius");
153 GLADE_HOOKUP_OBJECT(w_current->aawindow, widget[1],"spin_start");
154 GLADE_HOOKUP_OBJECT(w_current->aawindow, widget[2],"spin_sweep");
155 g_object_set_data(G_OBJECT(w_current->aawindow), "arc_object", arc_object);
156 gtk_widget_show_all (w_current->aawindow);
159 else { /* dialog already created */
160 gtk_window_present (GTK_WINDOW(w_current->aawindow));
161 widget[0] = g_object_get_data(G_OBJECT(w_current->aawindow),"radius");
162 widget[1] = g_object_get_data(G_OBJECT(w_current->aawindow),"spin_start");
163 widget[2] = g_object_get_data(G_OBJECT(w_current->aawindow),"spin_sweep");
166 if (arc_object == NULL) {
167 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget[0]), w_current->distance);
168 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget[1]),0);
169 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget[2]), 90);
170 } else {
171 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget[0]),
172 arc_object->arc->radius);
173 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget[1]),
174 arc_object->arc->start_angle);
175 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget[2]),
176 arc_object->arc->sweep_angle);
179 gtk_widget_grab_focus(widget[0]);
182 /***************** End of Arc dialog box *****************************/