pcb 4.1.1
An interactive printed circuit board layout editor.

gui-keyref-window.c

Go to the documentation of this file.
00001 /*
00002  *                            COPYRIGHT
00003  *
00004  *  PCB, interactive printed circuit board design
00005  *  Copyright (C) 1994,1995,1996 Thomas Nau
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along
00018  *  with this program; if not, write to the Free Software Foundation, Inc.,
00019  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  *
00021  *  Contact addresses for paper mail and Email:
00022  *  Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
00023  *  Thomas.Nau@rz.uni-ulm.de
00024  *
00025  */
00026 
00027 /* This file written by Bill Wilson for the PCB Gtk port */
00028 
00029 #ifdef HAVE_CONFIG_H
00030 #include "config.h"
00031 #endif
00032 
00033 #include "gui.h"
00034 
00035 #ifdef HAVE_LIBDMALLOC
00036 #include <dmalloc.h>
00037 #endif
00038 
00039 static GtkWidget *keyref_window;
00040 
00041 
00042 static gchar *key_ref_text[] = {
00043   "<h>",
00044   N_("Keyboard\n"),
00045   N_("Keyboard shortcuts and actions available in PCB.\n"),
00046   N_("In below key actions, <s> is <shift>, <c> is <ctrl>\n"),
00047   N_("and <a> is <alt> or <mod>\n"),
00048   "\n",
00049 
00050   "<b>\ta\t",
00051   N_("Set layer and size from line or arc\n"),
00052   "\n",
00053 
00054   "<b><s><a>a ",
00055   N_("Unselect all objects\n"),
00056   "\n",
00057 
00058   "<b>\tb\t",
00059   N_("Flip element to opposite side of the board\n"),
00060   "<b><c>\tb\t",
00061   N_("Flip selected objects to opposite side of the board\n"),
00062   "\n",
00063 
00064   "<b><c>\tc\t",
00065   N_("Copy selected to buffer and unselect\n"),
00066   "\n",
00067 
00068   "<b>\td\t",
00069   N_("Display pin/pad names (numbers with View->Enable pinout shows number)\n"),
00070   "<b><s>\td\t",
00071   N_("Open pinout window for element under cursor\n"),
00072   "\n",
00073 
00074   "<b>\te\t",
00075   N_("Delete all rats\n"),
00076   "<b><s>\te\t",
00077   N_("Delete selected rats\n"),
00078   "\n",
00079 
00080   "<b>\tf\t",
00081   N_("Highlight connections to object\n"),
00082   "<b><s>\tf\t",
00083   N_("Reset highlighted connections\n"),
00084   "<b><c>\tf\t",
00085   N_("Cumulative highlight connections to object\n"),
00086   "\n",
00087 
00088   "<b>\tg\t",
00089   N_("Increment grid by configured grid increment\n"),
00090 
00091   "<b><s>\tg\t",
00092   N_("Decrement grid by configured grid increment\n"),
00093   "\n",
00094 
00095   "<b>\th\t",
00096   N_("Toggle visibility of element name under cursor\n"),
00097 
00098   "<b><s>\th\t",
00099   N_("Toggle visibility of selected element names\n"),
00100 
00101   "<b><c>\th\t",
00102   N_("Toggle the hole flag of object under cursor\n"),
00103   "\n",
00104 
00105   "<b>\tj\t",
00106   N_("Toggle line/arc should clear polygons flag of object under cursor\n"),
00107 
00108   "<b><s>\tj\t",
00109   N_("Toggle line/arc should clear polygons flag of selected\n"),
00110   "\n",
00111 
00112   "<b>\tk\t",
00113   N_("Increase clearance of object by configured clearance\n"),
00114 
00115   "<b><s>\tk\t",
00116   N_("Decrease clearance of object by configured clearance\n"),
00117 
00118   "<b><c>\tk\t",
00119   N_("Increase clearance of selected objects by configured clearance\n"),
00120 
00121   "<b><s><c>k ",
00122   N_("Decrease clearance of selected objects by configured clearance\n"),
00123   "\n",
00124 
00125   "<b>\tl\t",
00126   N_("Increment current route style line size by configured line increment\n"),
00127 
00128   "<b><s>\tl\t",
00129   N_("Decrement current route style line size by configured line increment\n"),
00130   "\n",
00131 
00132   "<b>\tm\t",
00133   N_("Move object to current layer\n"),
00134 
00135   "<b><s>\tm\t",
00136   N_("Move selected objects to current layer\n"),
00137 
00138   "<b><c>\tm\t",
00139   N_("Mark at cursor location for showing relative offsets\n"),
00140   "\n",
00141 
00142   "<b><s>\tn\t",
00143   N_("Select the shortest unselected rat on the board\n"),
00144   "\n",
00145 
00146   "<b>\to\t",
00147   N_("Optimize and draw all rats\n"),
00148 
00149   "<b><s>\to\t",
00150   N_("Optimize and draw selected rats\n"),
00151   "\n",
00152 
00153   "<b><c>\to\t",
00154   N_("Change octagon flag of object\n"),
00155   "\n",
00156 
00157   "<b>\tp\t",
00158   N_("Backup polygon drawing to previous point\n"),
00159 
00160   "<b><s>\tp\t",
00161   N_("Close polygon\n"),
00162   "\n",
00163 
00164   "<b>\tq\t",
00165   N_("Toggle the square flag of an object\n"),
00166   "\n",
00167 
00168   "<b><s>\tr\t",
00169   N_("Redo last undone operation\n"),
00170   "\n",
00171 
00172   "<b>\ts\t",
00173   N_("Increment size of an object by configured size increment\n"),
00174   "<b><s>\ts\t",
00175   N_("Decrement size of an object by configured size increment\n"),
00176   "<b><a>\ts\t",
00177   N_("Increment drill size of a pin or via\n"),
00178   "<b><s><a>s ",
00179   N_("Decrement drill size of a pin or via\n"),
00180   "\n",
00181 
00182   "<b>\tt\t",
00183   N_("Adjust text scale so new text increases by the configured size increment\n"),
00184   "<b><s>\tt\t",
00185   N_("Adjust text scale so new text decreases by the configured size increment\n"),
00186   "\n",
00187 
00188   "<b>\tu\t",
00189   N_("Undo last operation\n"),
00190   "\n",
00191 
00192   "<b>\tv\t",
00193   N_("Zoom to board extents\n"),
00194   "<b><c>\tv\t",
00195   N_("Increment current route style via size\n"),
00196   "<b><s><c>v ",
00197   N_("Decrement current route style via size\n"),
00198   "<b><a>\tv\t",
00199   N_("Increment current route style via hole size\n"),
00200   "<b><s><a>v ",
00201   N_("Decrement current route style via hole size\n"),
00202   "\n",
00203 
00204   "<b><c>\tx\t",
00205   N_("Copy selection to buffer and enter pastebuffer mode\n"),
00206   "<b><s><c>x ",
00207   N_("Cut selection to buffer and enter pastebuffer mode\n"),
00208   "\n",
00209 
00210   "<b>\tz\t",
00211   N_("Zoom in\n"),
00212   "<b><z>\tz\t",
00213   N_("Zoom out\n"),
00214   "\n",
00215 
00216   "<b>\t|\t",
00217   N_("Toggle thin draw mode\n"),
00218   "\n",
00219 
00220   "<b>\t/\t",
00221   N_("Cycle multiline mode (Using <s> overrides)\n"),
00222   "\n",
00223 
00224   "<b>\t.\t",
00225   N_("Toggle all direction lines mode\n"),
00226   "\n",
00227 
00228   "<b>\tEsc\t",
00229   N_("If drawing an object, return to a neutral state.\n"),
00230   "\n",
00231 
00232   "<b>\tTab\t",
00233   N_("Switch view to other side\n"),
00234   "\n",
00235 
00236   "<b>  Space\t",
00237   N_("Switch to select mode\n"),
00238   "\n",
00239 
00240   "<b>\t:\t",
00241   N_("Enter user command or pop up command window\n"),
00242   "\n",
00243 
00244   "<b>\tDEL\t",
00245   N_("Delete object\n"),
00246   "\n",
00247 
00248   "<b>\t1-9\t",
00249   N_("Select drawing layers\n"),
00250   "\n",
00251 
00252   "<b><c>\t1-5\t",
00253   N_("Select current buffer\n"),
00254   "\n",
00255   "\n",
00256   "<h>",
00257   N_("Mouse\n"),
00258   N_("Modifier key use can be combined with mouse button presses\n"
00259      "to modify mouse button actions.\n"),
00260   "\n",
00261   N_("<b>Left button\n"),
00262   N_("\tPerform or initiate action determined by current mode.\n"),
00263   "\n",
00264   "\t",
00265   N_("<b><shift>"),
00266   N_(" - change rotation direction for rotation tool actions.\n"),
00267   "\n",
00268   N_("\tAfter a draw operation has been left mouse button initiated,\n"
00269      "\tmodifier key effects:\n"),
00270   "\t",
00271   N_("<b><shift>"),
00272   N_(" - change line 45 degree direction and arc angle direction,\n"),
00273   "\n",
00274   N_("<b>Middle button\n"),
00275   N_("\tIf a line, arc, rectangle, or polygon draw operation has been\n"
00276      "\tinitiated, a click restarts the draw operation at the cursor position.\n"),
00277   "\n",
00278   N_("\tIf such a draw has not been initiated, a click selects objects and\n"
00279      "\ta press and drag moves objects.\n"),
00280   "\n",
00281   N_("<b>Right button\n"),
00282   N_("\tPress and drag to pan.\n"
00283      "\tWhile drawing or moving, a click without a drag toggles auto pan mode.\n"),
00284   "\n\t",
00285   N_("<b><shift>"),
00286   N_(" - Popup a menu.\n"),
00287   "\n",
00288   N_("<b>Scroll wheel\n"),
00289   N_("\tZoom in/out.\n"),
00290   "\n\t",
00291   N_("<b><shift>"),
00292   N_(" - pan vertically.\n"),
00293   "\t",
00294   N_("<b><ctrl>"),
00295   N_(" - pan horizontally.\n"),
00296   "\n",
00297   N_("<b>Usage:\n"),
00298   N_("\tMouse actions can typically be combined.  For example: while moving\n"
00299      "\tan object (with left or middle press and drag), the right button may\n"
00300      "\tbe simultaneously clicked to toggle auto pan or pressed and dragged\n"
00301      "\tto manually pan.  Mouse moving or drawing may also be combined with\n"
00302      "\tkey actions.\n"),
00303 };
00304 
00305 
00306 
00307 
00308   /* Remember user window resizes.
00309    */
00310 static gint
00311 keyref_window_configure_event_cb (GtkWidget * widget, GdkEventConfigure * ev,
00312                                   gpointer data)
00313 {
00314   GtkAllocation allocation;
00315 
00316   gtk_widget_get_allocation (widget, &allocation);
00317   ghidgui->keyref_window_width = allocation.width;
00318   ghidgui->keyref_window_height = allocation.height;
00319   ghidgui->config_modified = TRUE;
00320   return FALSE;
00321 }
00322 
00323 static void
00324 keyref_close_cb (gpointer data)
00325 {
00326   gtk_widget_destroy (keyref_window);
00327   keyref_window = NULL;
00328 }
00329 
00330 static void
00331 keyref_destroy_cb (GtkWidget * widget, gpointer data)
00332 {
00333   keyref_window = NULL;
00334 }
00335 
00336 void
00337 ghid_keyref_window_show (gboolean raise)
00338 {
00339   GtkWidget *vbox, *hbox, *button, *text;
00340   gint i;
00341 
00342   if (keyref_window)
00343     {
00344       if (raise)
00345                           gtk_window_present(GTK_WINDOW(keyref_window));
00346       return;
00347     }
00348   keyref_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
00349   g_signal_connect (G_OBJECT (keyref_window), "destroy",
00350                     G_CALLBACK (keyref_destroy_cb), NULL);
00351   g_signal_connect (G_OBJECT (keyref_window), "configure_event",
00352                     G_CALLBACK (keyref_window_configure_event_cb), NULL);
00353   gtk_window_set_title (GTK_WINDOW (keyref_window), _("PCB Key Reference"));
00354   gtk_window_set_wmclass (GTK_WINDOW (keyref_window), "PCB_Keyref", "PCB");
00355   gtk_window_resize (GTK_WINDOW (keyref_window),
00356                      ghidgui->keyref_window_width,
00357                      ghidgui->keyref_window_height);
00358 
00359   vbox = gtk_vbox_new (FALSE, 0);
00360   gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
00361   gtk_container_add (GTK_CONTAINER (keyref_window), vbox);
00362 
00363   text = ghid_scrolled_text_view (vbox, NULL,
00364                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00365   for (i = 0; i < sizeof (key_ref_text) / sizeof (gchar *); ++i)
00366     ghid_text_view_append (text, _(key_ref_text[i]));
00367 
00368   /* The keyref window close button.
00369    */
00370   hbox = gtk_hbutton_box_new ();
00371   gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
00372   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
00373   button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
00374   g_signal_connect (G_OBJECT (button), "clicked",
00375                     G_CALLBACK (keyref_close_cb), NULL);
00376   gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
00377 
00378   gtk_widget_show_all (keyref_window);
00379 
00380 }