Commit 0660a32d authored by claes's avatar claes

Try to get List window to get input focus

parent efaf7dc6
/** /**
* Proview $Id: co_wow_gtk.cpp,v 1.3 2007-01-17 10:27:06 claes Exp $ * Proview $Id: co_wow_gtk.cpp,v 1.4 2007-02-05 09:30:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -169,20 +169,21 @@ void CoWowGtk::DisplayError( char *title, char *text) ...@@ -169,20 +169,21 @@ void CoWowGtk::DisplayError( char *title, char *text)
* *
*************************************************************************/ *************************************************************************/
typedef struct { class WowListCtx {
public:
GtkWidget *toplevel; GtkWidget *toplevel;
GtkWidget *list; GtkWidget *list;
char *texts; char *texts;
void (* action_cb) ( void *, char *); void (* action_cb) ( void *, char *);
void *parent_ctx; void *parent_ctx;
} *wow_tListCtx; };
void CoWowGtk::list_ok_cb ( void CoWowGtk::list_ok_cb (
GtkWidget *w, GtkWidget *w,
gpointer data gpointer data
) )
{ {
wow_tListCtx ctx = (wow_tListCtx) data; WowListCtx *ctx = (WowListCtx *) data;
char *text; char *text;
static char selected_text[80]; static char selected_text[80];
GtkTreeIter iter; GtkTreeIter iter;
...@@ -203,7 +204,7 @@ void CoWowGtk::list_ok_cb ( ...@@ -203,7 +204,7 @@ void CoWowGtk::list_ok_cb (
gtk_widget_destroy( ctx->toplevel); gtk_widget_destroy( ctx->toplevel);
free( ctx->texts); free( ctx->texts);
free( ctx); delete ctx;
} }
void CoWowGtk::list_cancel_cb ( void CoWowGtk::list_cancel_cb (
...@@ -211,11 +212,17 @@ void CoWowGtk::list_cancel_cb ( ...@@ -211,11 +212,17 @@ void CoWowGtk::list_cancel_cb (
gpointer data gpointer data
) )
{ {
wow_tListCtx ctx = (wow_tListCtx) data; WowListCtx *ctx = (WowListCtx *) data;
gtk_widget_destroy( ctx->toplevel); gtk_widget_destroy( ctx->toplevel);
free( ctx->texts); free( ctx->texts);
free( ctx); delete ctx;
}
static gboolean list_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
gtk_window_present( GTK_WINDOW(w));
return FALSE;
} }
void *CoWowGtk::CreateList ( void *CoWowGtk::CreateList (
...@@ -227,13 +234,13 @@ void *CoWowGtk::CreateList ( ...@@ -227,13 +234,13 @@ void *CoWowGtk::CreateList (
{ {
char *name_p; char *name_p;
int i; int i;
wow_tListCtx ctx; WowListCtx *ctx;
GtkListStore *store; GtkListStore *store;
GtkTreeIter iter; GtkTreeIter iter;
GtkCellRenderer *text_renderer; GtkCellRenderer *text_renderer;
GtkTreeViewColumn *name_column; GtkTreeViewColumn *name_column;
ctx = (wow_tListCtx) calloc( 1, sizeof(*ctx)); ctx = new WowListCtx();
ctx->action_cb = action_cb; ctx->action_cb = action_cb;
ctx->parent_ctx = parent_ctx; ctx->parent_ctx = parent_ctx;
...@@ -245,6 +252,9 @@ void *CoWowGtk::CreateList ( ...@@ -245,6 +252,9 @@ void *CoWowGtk::CreateList (
"window-position", GTK_WIN_POS_CENTER, "window-position", GTK_WIN_POS_CENTER,
NULL); NULL);
g_signal_connect( ctx->toplevel, "focus-in-event", G_CALLBACK(list_action_inputfocus), ctx);
store = gtk_list_store_new( 1, G_TYPE_STRING); store = gtk_list_store_new( 1, G_TYPE_STRING);
name_p = texts; name_p = texts;
i = 0; i = 0;
...@@ -309,7 +319,6 @@ void *CoWowGtk::CreateList ( ...@@ -309,7 +319,6 @@ void *CoWowGtk::CreateList (
// Set input focus to the scrolled list widget // Set input focus to the scrolled list widget
gtk_widget_grab_focus( ctx->list); gtk_widget_grab_focus( ctx->list);
return ctx; return ctx;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment