pcb 4.1.1
An interactive printed circuit board layout editor.

gui-pinout-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 "global.h"
00034 
00035 #include "gui.h"
00036 
00037 #include "copy.h"
00038 #include "data.h"
00039 #include "draw.h"
00040 #include "mymem.h"
00041 #include "move.h"
00042 #include "rotate.h"
00043 
00044 #include "gui-pinout-preview.h"
00045 
00046 #ifdef HAVE_LIBDMALLOC
00047 #include <dmalloc.h>
00048 #endif
00049 
00050 static void
00051 pinout_close_cb (GtkWidget * widget, GtkWidget *top_window)
00052 {
00053   gtk_widget_destroy (top_window);
00054 }
00055 
00056 
00057 void
00058 ghid_pinout_window_show (GHidPort * out, ElementType * element)
00059 {
00060   GtkWidget *button, *vbox, *hbox, *preview, *top_window;
00061   gchar *title;
00062   int width, height;
00063 
00064   if (!element)
00065     return;
00066   title = g_strdup_printf ("%s [%s,%s]",
00067                            UNKNOWN (DESCRIPTION_NAME (element)),
00068                            UNKNOWN (NAMEONPCB_NAME (element)),
00069                            UNKNOWN (VALUE_NAME (element)));
00070 
00071   top_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
00072   gtk_window_set_title (GTK_WINDOW (top_window), title);
00073   g_free (title);
00074   gtk_window_set_wmclass (GTK_WINDOW (top_window), "PCB_Pinout", "PCB");
00075   gtk_container_set_border_width (GTK_CONTAINER (top_window), 4);
00076 
00077   vbox = gtk_vbox_new (FALSE, 0);
00078   gtk_container_add (GTK_CONTAINER (top_window), vbox);
00079 
00080 
00081   preview = ghid_pinout_preview_new (element);
00082   gtk_box_pack_start (GTK_BOX (vbox), preview, TRUE, TRUE, 0);
00083 
00084   ghid_pinout_preview_get_natural_size (GHID_PINOUT_PREVIEW (preview),
00085                                         &width, &height);
00086 
00087   gtk_window_resize (GTK_WINDOW (top_window), width + 50, height + 50);
00088 
00089   hbox = gtk_hbutton_box_new ();
00090   gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
00091   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
00092   button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
00093   g_signal_connect (G_OBJECT (button), "clicked",
00094                     G_CALLBACK (pinout_close_cb), top_window);
00095   gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
00096 
00097   gtk_widget_realize (top_window);
00098   if (Settings.AutoPlace)
00099     gtk_window_move (GTK_WINDOW (top_window), 10, 10);
00100   gtk_widget_show_all (top_window);
00101 }