find.c: Use SetThing, rather than open-coding assignments to thing_*
[geda-pcb/pcjc2.git] / src / hid / gtk / gui-keyref-window.c
blobe2632cadeb997c039f7b3ebf97e3dc73160e41de
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
27 /* This file written by Bill Wilson for the PCB Gtk port */
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
33 #include "gui.h"
35 #ifdef HAVE_LIBDMALLOC
36 #include <dmalloc.h>
37 #endif
39 static GtkWidget *keyref_window;
42 static gchar *key_ref_text[] = {
43 "<h>",
44 N_("Keyboard\n"),
45 N_("Keyboard shortcuts and actions available in PCB.\n"),
46 N_("In below key actions, <s> is <shift>, <c> is <ctrl>\n"),
47 N_("and <a> is <alt> or <mod>\n"),
48 "\n",
50 "<b>\ta\t",
51 N_("Set layer and size from line or arc\n"),
52 "\n",
54 "<b><s><a>a ",
55 N_("Unselect all objects\n"),
56 "\n",
58 "<b>\tb\t",
59 N_("Flip element to opposite side of the board\n"),
60 "<b><c>\tb\t",
61 N_("Flip selected objects to opposite side of the board\n"),
62 "\n",
64 "<b><c>\tc\t",
65 N_("Copy selected to buffer and unselect\n"),
66 "\n",
68 "<b>\td\t",
69 N_("Display pin/pad names (numbers with View->Enable pinout shows number)\n"),
70 "<b><s>\td\t",
71 N_("Open pinout window for element under cursor\n"),
72 "\n",
74 "<b>\te\t",
75 N_("Delete all rats\n"),
76 "<b><s>\te\t",
77 N_("Delete selected rats\n"),
78 "\n",
80 "<b>\tf\t",
81 N_("Highlight connections to object\n"),
82 "<b><s>\tf\t",
83 N_("Reset highlighted connections\n"),
84 "<b><c>\tf\t",
85 N_("Cumulative highlight connections to object\n"),
86 "\n",
88 "<b>\tg\t",
89 N_("Increment grid by configured grid increment\n"),
91 "<b><s>\tg\t",
92 N_("Decrement grid by configured grid increment\n"),
93 "\n",
95 "<b>\th\t",
96 N_("Toggle visibility of element name under cursor\n"),
98 "<b><s>\th\t",
99 N_("Toggle visibility of selected element names\n"),
101 "<b><c>\th\t",
102 N_("Toggle the hole flag of object under cursor\n"),
103 "\n",
105 "<b>\tj\t",
106 N_("Toggle line/arc should clear polygons flag of object under cursor\n"),
108 "<b><s>\tj\t",
109 N_("Toggle line/arc should clear polygons flag of selected\n"),
110 "\n",
112 "<b>\tk\t",
113 N_("Increase clearance of object by configured clearance\n"),
115 "<b><s>\tk\t",
116 N_("Decrease clearance of object by configured clearance\n"),
118 "<b><c>\tk\t",
119 N_("Increase clearance of selected objects by configured clearance\n"),
121 "<b><s><c>k ",
122 N_("Decrease clearance of selected objects by configured clearance\n"),
123 "\n",
125 "<b>\tl\t",
126 N_("Increment current route style line size by configured line increment\n"),
128 "<b><s>\tl\t",
129 N_("Decrement current route style line size by configured line increment\n"),
130 "\n",
132 "<b>\tm\t",
133 N_("Move object to current layer\n"),
135 "<b><s>\tm\t",
136 N_("Move selected objects to current layer\n"),
138 "<b><c>\tm\t",
139 N_("Mark at cursor location for showing relative offsets\n"),
140 "\n",
142 "<b><s>\tn\t",
143 N_("Select the shortest unselected rat on the board\n"),
144 "\n",
146 "<b>\to\t",
147 N_("Optimize and draw all rats\n"),
149 "<b><s>\to\t",
150 N_("Optimize and draw selected rats\n"),
151 "\n",
153 "<b><c>\to\t",
154 N_("Change octagon flag of object\n"),
155 "\n",
157 "<b>\tp\t",
158 N_("Backup polygon drawing to previous point\n"),
160 "<b><s>\tp\t",
161 N_("Close polygon\n"),
162 "\n",
164 "<b>\tq\t",
165 N_("Toggle the square flag of an object\n"),
166 "\n",
168 "<b><s>\tr\t",
169 N_("Redo last undone operation\n"),
170 "\n",
172 "<b>\ts\t",
173 N_("Increment size of an object by configured size increment\n"),
174 "<b><s>\ts\t",
175 N_("Decrement size of an object by configured size increment\n"),
176 "<b><a>\ts\t",
177 N_("Increment drill size of a pin or via\n"),
178 "<b><s><a>s ",
179 N_("Decrement drill size of a pin or via\n"),
180 "\n",
182 "<b>\tt\t",
183 N_("Adjust text scale so new text increases by the configured size increment\n"),
184 "<b><s>\tt\t",
185 N_("Adjust text scale so new text decreases by the configured size increment\n"),
186 "\n",
188 "<b>\tu\t",
189 N_("Undo last operation\n"),
190 "\n",
192 "<b>\tv\t",
193 N_("Zoom to board extents\n"),
194 "<b><c>\tv\t",
195 N_("Increment current route style via size\n"),
196 "<b><s><c>v ",
197 N_("Decrement current route style via size\n"),
198 "<b><a>\tv\t",
199 N_("Increment current route style via hole size\n"),
200 "<b><s><a>v ",
201 N_("Decrement current route style via hole size\n"),
202 "\n",
204 "<b><c>\tx\t",
205 N_("Copy selection to buffer and enter pastebuffer mode\n"),
206 "<b><s><c>x ",
207 N_("Cut selection to buffer and enter pastebuffer mode\n"),
208 "\n",
210 "<b>\tz\t",
211 N_("Zoom in\n"),
212 "<b><z>\tz\t",
213 N_("Zoom out\n"),
214 "\n",
216 "<b>\t|\t",
217 N_("Toggle thin draw mode\n"),
218 "\n",
220 "<b>\t/\t",
221 N_("Cycle multiline mode (Using <s> overrides)\n"),
222 "\n",
224 "<b>\t.\t",
225 N_("Toggle all direction lines mode\n"),
226 "\n",
228 "<b>\tEsc\t",
229 N_("If drawing an object, return to a neutral state.\n"),
230 "\n",
232 "<b>\tTab\t",
233 N_("Switch view to other side\n"),
234 "\n",
236 "<b> Space\t",
237 N_("Switch to select mode\n"),
238 "\n",
240 "<b>\t:\t",
241 N_("Enter user command or pop up command window\n"),
242 "\n",
244 "<b>\tDEL\t",
245 N_("Delete object\n"),
246 "\n",
248 "<b>\t1-9\t",
249 N_("Select drawing layers\n"),
250 "\n",
252 "<b><c>\t1-5\t",
253 N_("Select current buffer\n"),
254 "\n",
255 "\n",
256 "<h>",
257 N_("Mouse\n"),
258 N_("Modifier key use can be combined with mouse button presses\n"
259 "to modify mouse button actions.\n"),
260 "\n",
261 N_("<b>Left button\n"),
262 N_("\tPerform or initiate action determined by current mode.\n"),
263 "\n",
264 "\t",
265 N_("<b><shift>"),
266 N_(" - change rotation direction for rotation tool actions.\n"),
267 "\n",
268 N_("\tAfter a draw operation has been left mouse button initiated,\n"
269 "\tmodifier key effects:\n"),
270 "\t",
271 N_("<b><shift>"),
272 N_(" - change line 45 degree direction and arc angle direction,\n"),
273 "\n",
274 N_("<b>Middle button\n"),
275 N_("\tIf a line, arc, rectangle, or polygon draw operation has been\n"
276 "\tinitiated, a click restarts the draw operation at the cursor position.\n"),
277 "\n",
278 N_("\tIf such a draw has not been initiated, a click selects objects and\n"
279 "\ta press and drag moves objects.\n"),
280 "\n",
281 N_("<b>Right button\n"),
282 N_("\tPress and drag to pan.\n"
283 "\tWhile drawing or moving, a click without a drag toggles auto pan mode.\n"),
284 "\n\t",
285 N_("<b><shift>"),
286 N_(" - Popup a menu.\n"),
287 "\n",
288 N_("<b>Scroll wheel\n"),
289 N_("\tZoom in/out.\n"),
290 "\n\t",
291 N_("<b><shift>"),
292 N_(" - pan vertically.\n"),
293 "\t",
294 N_("<b><ctrl>"),
295 N_(" - pan horizontally.\n"),
296 "\n",
297 N_("<b>Usage:\n"),
298 N_("\tMouse actions can typically be combined. For example: while moving\n"
299 "\tan object (with left or middle press and drag), the right button may\n"
300 "\tbe simultaneously clicked to toggle auto pan or pressed and dragged\n"
301 "\tto manually pan. Mouse moving or drawing may also be combined with\n"
302 "\tkey actions.\n"),
308 /* Remember user window resizes.
310 static gint
311 keyref_window_configure_event_cb (GtkWidget * widget, GdkEventConfigure * ev,
312 gpointer data)
314 GtkAllocation allocation;
316 gtk_widget_get_allocation (widget, &allocation);
317 ghidgui->keyref_window_width = allocation.width;
318 ghidgui->keyref_window_height = allocation.height;
319 ghidgui->config_modified = TRUE;
320 return FALSE;
323 static void
324 keyref_close_cb (gpointer data)
326 gtk_widget_destroy (keyref_window);
327 keyref_window = NULL;
330 static void
331 keyref_destroy_cb (GtkWidget * widget, gpointer data)
333 keyref_window = NULL;
336 void
337 ghid_keyref_window_show (gboolean raise)
339 GtkWidget *vbox, *hbox, *button, *text;
340 gint i;
342 if (keyref_window)
344 if (raise)
345 gtk_window_present(GTK_WINDOW(keyref_window));
346 return;
348 keyref_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
349 g_signal_connect (G_OBJECT (keyref_window), "destroy",
350 G_CALLBACK (keyref_destroy_cb), NULL);
351 g_signal_connect (G_OBJECT (keyref_window), "configure_event",
352 G_CALLBACK (keyref_window_configure_event_cb), NULL);
353 gtk_window_set_title (GTK_WINDOW (keyref_window), _("PCB Key Reference"));
354 gtk_window_set_wmclass (GTK_WINDOW (keyref_window), "PCB_Keyref", "PCB");
355 gtk_window_set_default_size (GTK_WINDOW (keyref_window),
356 ghidgui->keyref_window_width,
357 ghidgui->keyref_window_height);
359 vbox = gtk_vbox_new (FALSE, 0);
360 gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
361 gtk_container_add (GTK_CONTAINER (keyref_window), vbox);
363 text = ghid_scrolled_text_view (vbox, NULL,
364 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
365 for (i = 0; i < sizeof (key_ref_text) / sizeof (gchar *); ++i)
366 ghid_text_view_append (text, _(key_ref_text[i]));
368 /* The keyref window close button.
370 hbox = gtk_hbutton_box_new ();
371 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
372 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
373 button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
374 g_signal_connect (G_OBJECT (button), "clicked",
375 G_CALLBACK (keyref_close_cb), NULL);
376 gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
378 gtk_widget_show_all (keyref_window);