pcb 4.1.1
An interactive printed circuit board layout editor.

gui-command-window.c File Reference

Provides a command entry window for the GTK UI. More...

#include "gui.h"
#include <gdk/gdkkeysyms.h>
#include "crosshair.h"
Include dependency graph for gui-command-window.c:

Go to the source code of this file.

Functions

static void command_history_add (gchar *cmd)
 Put an allocated string on the history list and combo text list if it is not a duplicate.
static void command_entry_activate_cb (GtkWidget *widget, gpointer data)
 Called when user hits "Enter" key in command entry.
static void command_combo_box_entry_create (void)
 Create the command_combo_box.
static void command_window_disconnect_combobox ()
static void command_window_close_cb (GtkWidget *widget, gpointer data)
static gboolean command_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
static void command_destroy_cb (GtkWidget *widget, gpointer data)
static gboolean command_escape_cb (GtkWidget *widget, GdkEventKey *kev, gpointer data)
void ghid_command_use_command_window_sync (void)
 If ghidgui->use_command_window toggles, the config code calls this to ensure the command_combo_box is set up for living in the right place.
void ghid_command_window_show (gboolean raise)
 If ghidgui->use_command_window is TRUE this will get called from ActionCommand() to show the command window.
gchar * ghid_command_entry_get (gchar *prompt, gchar *command)
 This is the command entry function called from ActionCommand() when ghidgui->use_command_window is FALSE.
void ghid_handle_user_command (gboolean raise)

Variables

static GtkWidget * command_window
static GtkWidget * combo_vbox
static GList * history_list
static gchar * command_entered
static GMainLoop * loop
static gchar * command_ref_text []
 When using a command window for command entry, provide a quick and abbreviated reference to available commands.

Detailed Description

Provides a command entry window for the GTK UI.

This file was written by Bill Wilson for the PCB Gtk port.

gui-command-window.c provides two interfaces for getting user input for executing a command.

As the Xt PCB was ported to Gtk, the traditional user entry in the status line window presented some focus problems which require that there can be no menu key shortcuts that might be a key the user would type in. It also requires a coordinating flag so the drawing area won't grab focus while the command entry is up.

I thought the interface should be cleaner, so I made an alternate command window interface which works better I think as a gui interface. The user must focus onto the command window, but since it's a separate window, there's no confusion. It has the restriction that objects to be operated on must be selected, but that actually seems a better user interface than one where typing into one location requires the user to be careful about which object might be under the cursor somewhere else.

In any event, both interfaces are here to work with.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact addresses for paper mail and Email: Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany Thomas.Nau@rz.uni-ulm.de

Definition in file gui-command-window.c.


Function Documentation

static void command_combo_box_entry_create ( void  ) [static]

Create the command_combo_box.

Called once, either by ghid_command_window_show() or ghid_command_entry_get(). Then as long as ghidgui->use_command_window is TRUE, the command_combo_box will live in a command window vbox or float if the command window is not up. But if ghidgui->use_command_window is FALSE, the command_combo_box will live in the status_line_hbox either shown or hidden. Since it's never destroyed, the combo history strings never need rebuilding and history is maintained if the combo box location is moved.

Definition at line 253 of file gui-command-window.c.

References GhidGui::command_combo_box, GhidGui::command_entry, command_entry_activate_cb(), ghidgui, and TRUE.

Referenced by ghid_command_entry_get(), and ghid_command_window_show().

Here is the call graph for this function:

static void command_destroy_cb ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 299 of file gui-command-window.c.

References command_window.

Referenced by ghid_command_window_show().

static void command_entry_activate_cb ( GtkWidget *  widget,
gpointer  data 
) [static]

Called when user hits "Enter" key in command entry.

The action to take depends on where the combo box is. If it's in the command window, we can immediately execute the command and carry on. If it's in the status line hbox, then we need stop the command entry g_main_loop from running and save the allocated string so it can be returned from ghid_command_entry_get()

Definition at line 213 of file gui-command-window.c.

References command, command_entered, GhidGui::command_entry, command_history_add(), ghid_entry_get_text(), ghidgui, hid_parse_command(), loop, and GhidGui::use_command_window.

Referenced by command_combo_box_entry_create().

Here is the call graph for this function:

static gboolean command_escape_cb ( GtkWidget *  widget,
GdkEventKey *  kev,
gpointer  data 
) [static]

Definition at line 306 of file gui-command-window.c.

References command_entered, command_window, command_window_disconnect_combobox(), FALSE, loop, and TRUE.

Referenced by ghid_command_entry_get(), and ghid_command_window_show().

Here is the call graph for this function:

static void command_history_add ( gchar *  cmd) [static]

Put an allocated string on the history list and combo text list if it is not a duplicate.

The history_list is just a shadow of the combo list, but I think is needed because I don't see an api for reading the combo strings. The combo box strings take "const gchar *", so the same allocated string can go in both the history list and the combo list.

If removed from both lists, a string can be freed.

Definition at line 156 of file gui-command-window.c.

References GhidGui::command_combo_box, ghidgui, history_list, GhidGui::history_size, and s.

Referenced by command_entry_activate_cb().

static void command_window_close_cb ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 282 of file gui-command-window.c.

References command_window, and command_window_disconnect_combobox().

Referenced by ghid_command_use_command_window_sync(), and ghid_command_window_show().

Here is the call graph for this function:

static gboolean command_window_delete_event_cb ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  data 
) [static]

Definition at line 290 of file gui-command-window.c.

References command_window_disconnect_combobox(), and FALSE.

Referenced by ghid_command_window_show().

Here is the call graph for this function:

static void command_window_disconnect_combobox ( ) [static]
gchar* ghid_command_entry_get ( gchar *  prompt,
gchar *  command 
)

This is the command entry function called from ActionCommand() when ghidgui->use_command_window is FALSE.

The command_combo_box is already packed into the status line label hbox in this case.

Definition at line 431 of file gui-command-window.c.

References GhidGui::command_combo_box, command_combo_box_entry_create(), command_entered, GhidGui::command_entry, GhidGui::command_entry_status_line_active, command_escape_cb(), GHidPort::drawing_area, FALSE, ghid_install_accel_groups(), ghid_interface_input_signals_connect(), ghid_interface_input_signals_disconnect(), ghid_interface_set_sensitive(), ghid_port, ghid_remove_accel_groups(), ghid_status_line_set_text(), ghidgui, gport, loop, s, GhidGui::status_line_hbox, GHidPort::top_window, and TRUE.

Referenced by ghid_handle_user_command().

Here is the call graph for this function:

void ghid_command_use_command_window_sync ( void  )

If ghidgui->use_command_window toggles, the config code calls this to ensure the command_combo_box is set up for living in the right place.

Definition at line 332 of file gui-command-window.c.

References GhidGui::command_combo_box, command_window, command_window_close_cb(), FALSE, ghidgui, GhidGui::status_line_hbox, and GhidGui::use_command_window.

Referenced by config_command_window_toggle_cb().

Here is the call graph for this function:

void ghid_command_window_show ( gboolean  raise)

If ghidgui->use_command_window is TRUE this will get called from ActionCommand() to show the command window.

Definition at line 362 of file gui-command-window.c.

References _, combo_vbox, GhidGui::command_combo_box, command_combo_box_entry_create(), command_destroy_cb(), command_escape_cb(), command_ref_text, command_window, command_window_close_cb(), command_window_delete_event_cb(), FALSE, ghid_scrolled_text_view(), ghid_text_view_append(), ghidgui, and TRUE.

Referenced by ghid_handle_user_command().

Here is the call graph for this function:

void ghid_handle_user_command ( gboolean  raise)

Variable Documentation

GtkWidget* combo_vbox [static]
gchar* command_entered [static]
gchar* command_ref_text[] [static]

When using a command window for command entry, provide a quick and abbreviated reference to available commands.

This is currently just a start and can be expanded if it proves useful.

Definition at line 82 of file gui-command-window.c.

Referenced by ghid_command_window_show().

GList* history_list [static]

Definition at line 70 of file gui-command-window.c.

Referenced by command_history_add().