debian bug #154629 - extended commands in gnome front end

Not all of the extended commands worked in the gnome interface because
'#' just caused the next character to be treated as a meta character (this
was a hack I added a while back when none of the extended commands worked).
Resolved by finally adding an extended command menu to the gnome interface.
- updated some formatting so I could read the code
- fixed startup player selection menus so accelerators work
- added necessary calls to make sure selected menu item is visible
- also removed some dead code
This commit is contained in:
cohrs
2003-10-15 06:02:27 +00:00
parent bf476cae6e
commit dadeed21d2
7 changed files with 201 additions and 97 deletions

View File

@@ -8,21 +8,24 @@
#include "gnmain.h"
#include "hack.h"
static gint role_number;
static GtkWidget* clist;
static void
player_sel_key_hit (GtkWidget *widget, GdkEventKey *event, gpointer data)
static gint role_number;
static GtkWidget* clist;
static void
player_sel_key_hit (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
const char** roles = data;
int i;
for (i = 0; roles[i] != 0; ++i) {
if (roles[i][0] == toupper(event->keyval)) {
role_number = i;
gtk_clist_select_row( GTK_CLIST (clist), i, 0);
}
}
}
const char** roles = data;
int i;
for (i = 0; roles[i] != 0; ++i) {
if (tolower(roles[i][0]) == tolower(event->keyval)) {
role_number = i;
gtk_clist_select_row( GTK_CLIST (clist), i, 0);
if (gtk_clist_row_is_visible(GTK_CLIST(clist),
i) != GTK_VISIBILITY_FULL)
gtk_clist_moveto(GTK_CLIST(clist), i, 0, 0.5, 0);
}
}
}
static void
player_sel_row_selected (GtkCList *clist, int row, int col, GdkEvent *event)
@@ -46,8 +49,8 @@ ghack_player_sel_dialog(const char** choices,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event",
GTK_SIGNAL_FUNC (player_sel_key_hit), choices );
gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event",
GTK_SIGNAL_FUNC (player_sel_key_hit), choices );
frame1 = gtk_frame_new(prompt);
gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1);
@@ -67,7 +70,7 @@ ghack_player_sel_dialog(const char** choices,
gtk_container_add (GTK_CONTAINER (frame1), swin);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1);
/* Add the roles into the list here... */
for (i=0; choices[i]; i++) {
gchar accelBuf[BUFSZ];
@@ -75,19 +78,18 @@ ghack_player_sel_dialog(const char** choices,
sprintf( accelBuf, "%c ", tolower(choices[i][0]));
gtk_clist_insert (GTK_CLIST (clist), i, (char**)text);
}
gtk_clist_columns_autosize (GTK_CLIST (clist));
gtk_widget_show_all (swin);
/* Center the dialog over over parent */
gnome_dialog_set_default( GNOME_DIALOG(dialog), 0);
gtk_window_set_modal( GTK_WINDOW(dialog), TRUE);
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
GTK_WINDOW (ghack_get_main_window ()) );
/* Run the dialog -- returning whichever button was pressed */
i = gnome_dialog_run (GNOME_DIALOG (dialog));
gnome_dialog_close (GNOME_DIALOG (dialog));
i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
/* Quit on button 2 or error */
if (i < 0 || i > 1) {