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
35 #include "pcb-printf.h"
37 #ifdef HAVE_LIBDMALLOC
41 static GtkWidget
*log_window
, *log_text
;
42 static gboolean log_show_on_append
= FALSE
;
44 /* Remember user window resizes. */
46 log_window_configure_event_cb (GtkWidget
* widget
,
47 GdkEventConfigure
* ev
, gpointer data
)
49 GtkAllocation allocation
;
51 gtk_widget_get_allocation (widget
, &allocation
);
52 ghidgui
->log_window_width
= allocation
.width
;
53 ghidgui
->log_window_height
= allocation
.height
;
54 ghidgui
->config_modified
= TRUE
;
60 log_close_cb (gpointer data
)
62 gtk_widget_destroy (log_window
);
67 log_destroy_cb (GtkWidget
* widget
, gpointer data
)
73 ghid_log_window_create ()
75 GtkWidget
*vbox
, *hbox
, *button
;
80 log_window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
81 g_signal_connect (G_OBJECT (log_window
), "destroy",
82 G_CALLBACK (log_destroy_cb
), NULL
);
83 g_signal_connect (G_OBJECT (log_window
), "configure_event",
84 G_CALLBACK (log_window_configure_event_cb
), NULL
);
85 gtk_window_set_title (GTK_WINDOW (log_window
), _("PCB Log"));
86 gtk_window_set_wmclass (GTK_WINDOW (log_window
), "PCB_Log", "PCB");
87 gtk_window_set_default_size (GTK_WINDOW (log_window
),
88 ghidgui
->log_window_width
,
89 ghidgui
->log_window_height
);
91 vbox
= gtk_vbox_new (FALSE
, 0);
92 gtk_container_set_border_width (GTK_CONTAINER (vbox
), 6);
93 gtk_container_add (GTK_CONTAINER (log_window
), vbox
);
95 log_text
= ghid_scrolled_text_view (vbox
, NULL
,
97 GTK_POLICY_AUTOMATIC
);
99 hbox
= gtk_hbutton_box_new ();
100 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox
), GTK_BUTTONBOX_END
);
101 gtk_box_pack_start (GTK_BOX (vbox
), hbox
, FALSE
, FALSE
, 0);
102 button
= gtk_button_new_from_stock (GTK_STOCK_CLOSE
);
103 g_signal_connect (G_OBJECT (button
), "clicked",
104 G_CALLBACK (log_close_cb
), NULL
);
105 gtk_box_pack_start (GTK_BOX (hbox
), button
, TRUE
, TRUE
, 0);
107 gtk_widget_realize (log_window
);
108 if (Settings
.AutoPlace
)
109 gtk_window_move (GTK_WINDOW (log_window
), 10, 10);
113 ghid_log_window_show (gboolean raise
)
115 ghid_log_window_create ();
116 gtk_widget_show_all (log_window
);
118 gtk_window_present (GTK_WINDOW(log_window
));
122 ghid_log_append_string (gchar
* s
)
124 if (log_show_on_append
)
125 ghid_log_window_show(FALSE
);
127 ghid_log_window_create ();
128 ghid_text_view_append (log_text
, s
);
132 ghid_log (const char *fmt
, ...)
141 ghid_logv (const char *fmt
, va_list args
)
143 gchar
*msg
= pcb_vprintf (fmt
, args
);
144 ghid_log_append_string (msg
);
148 static const char logshowonappend_syntax
[] =
149 "LogShowOnAppend(true|false)";
151 static const char logshowonappend_help
[] =
152 "If true, the log window will be shown whenever something is appended \
153 to it. If false, the log will still be updated, but the window won't \
157 GhidLogShowOnAppend (int argc
, char **argv
, Coord x
, Coord y
)
159 char *a
= argc
== 1 ? argv
[0] : (char *)"";
161 if (strncasecmp(a
, "t", 1) == 0)
163 log_show_on_append
= TRUE
;
165 else if (strncasecmp(a
, "f", 1) == 0)
167 log_show_on_append
= FALSE
;
172 HID_Action ghid_log_action_list
[] = {
173 {"LogShowOnAppend", 0, GhidLogShowOnAppend
,
174 logshowonappend_help
, logshowonappend_syntax
}
178 REGISTER_ACTIONS (ghid_log_action_list
)