Commit ae7ad342 authored by Claes Sjofors's avatar Claes Sjofors

Ge open dialog removed when Ge is closed

parent 459f7632
......@@ -126,7 +126,7 @@ void WCast::get_subcid( pwr_tCid cid)
}
}
void WCast::selected_cb( void *ctx, char *text)
void WCast::selected_cb( void *ctx, char *text, int ok_pressed)
{
WCast *wcast = (WCast *)ctx;
pwr_tStatus sts;
......
......@@ -78,7 +78,7 @@ class WCast {
~WCast();
static void selected_cb( void *ctx, char *text);
static void selected_cb( void *ctx, char *text, int ok_pressed);
};
#endif
......
......@@ -125,7 +125,7 @@ void Wda::import_textfile()
import_file_cb, 0, this, 1);
}
void Wda::import_file_cb( void *ctx, char *text)
void Wda::import_file_cb( void *ctx, char *text, int ok_pressed)
{
pwr_tFileName filename;
Wda *wda = (Wda *)ctx;
......@@ -358,7 +358,7 @@ int Wda::prev_attr()
return WDA__NOPREVATTR;
}
void Wda::set_attr_cb( void *ctx, char *text)
void Wda::set_attr_cb( void *ctx, char *text, int ok_pressed)
{
Wda *wda = (Wda *)ctx;
int sts;
......
......@@ -114,9 +114,9 @@ class Wda {
static void message_cb( void *wda, char severity, const char *message);
static void change_value_cb( void *wda);
static void set_attr_cb( void *ctx, char *text);
static void set_attr_cb( void *ctx, char *text, int ok_pressed);
static void file_selected_cb( void *ctx, void *data, char *text);
static void import_file_cb( void *ctx, char *text);
static void import_file_cb( void *ctx, char *text, int ok_pressed);
};
......
......@@ -5720,7 +5720,7 @@ static int wnav_backup_func( void *client_data,
return 1;
}
static void wnav_clone_volume_cb( void *ctx, char *text)
static void wnav_clone_volume_cb( void *ctx, char *text, int ok_pressed)
{
WNav *wnav = (WNav *)ctx;
pwr_tObjName vname;
......
......@@ -96,7 +96,7 @@ class Xtt {
virtual void print() {}
void list_opplace();
static void opplace_selected_cb( void *ctx, char *text);
static void opplace_selected_cb( void *ctx, char *text, int ok_pressed);
void hotkey_activate_command( char *cmdp);
static void hotkey_activate_toggledig( char *namep);
......
......@@ -864,7 +864,7 @@ Xtt::Xtt( int *argc, char **argv[], int *return_sts) :
}
void Xtt::opplace_selected_cb( void *ctx, char *text)
void Xtt::opplace_selected_cb( void *ctx, char *text, int ok_pressed)
{
Xtt *xtt = (Xtt *)ctx;
pwr_tCmd cmd;
......
......@@ -433,13 +433,16 @@ void CoWowGtk::DisplayText( const char *title, const char *text, int width, int
class WowListCtx {
public:
WowListCtx() :
texts(0), textsize(0),ok_pressed(0) {}
GtkWidget *toplevel;
GtkWidget *list;
char *texts;
int textsize;
void (* action_cb) ( void *, char *);
void (* action_cb) ( void *, char *, int);
void (* cancel_cb) ( void *);
void *parent_ctx;
int ok_pressed;
};
void CoWowGtk::list_row_activated_cb( GtkTreeView *tree_view,
......@@ -475,7 +478,7 @@ void CoWowGtk::list_apply_cb (
strcpy( selected_text, textiso);
g_free( textiso);
(ctx->action_cb)( ctx->parent_ctx, selected_text);
(ctx->action_cb)( ctx->parent_ctx, selected_text, ctx->ok_pressed);
}
}
......@@ -487,6 +490,7 @@ void CoWowGtk::list_ok_cb (
{
WowListCtx *ctx = (WowListCtx *) data;
ctx->ok_pressed = 1;
list_apply_cb( w, data);
gtk_widget_destroy( ctx->toplevel);
......@@ -521,11 +525,27 @@ static gboolean list_delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
return TRUE;
}
void CoWowGtk::PopList ( void *data)
{
WowListCtx *ctx = (WowListCtx *) data;
gtk_window_present( GTK_WINDOW(ctx->toplevel));
}
void CoWowGtk::DeleteList ( void *data)
{
WowListCtx *ctx = (WowListCtx *) data;
gtk_widget_destroy( ctx->toplevel);
free( ctx->texts);
delete ctx;
}
void *CoWowGtk::CreateList (
const char *title,
const char *texts,
int textsize,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *parent_ctx,
int show_apply_button
......
......@@ -135,10 +135,12 @@ class CoWowGtk : public CoWow {
char *init_text,
void *data);
void *CreateList( const char *title, const char *texts, int textsize,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button = 0);
void PopList( void *ctx);
void DeleteList( void *ctx);
void CreateFileSelDia( const char *title, void *parent_ctx,
void (*file_selected_cb)(void *, char *, wow_eFileSelType),
wow_eFileSelType file_type);
......
......@@ -264,7 +264,7 @@ void CoWowMotif::list_ok_cb( Widget w, XtPointer data,
if ( ctx->action_cb) {
if (XmListGetSelectedPos( ctx->list, &pos_list, &pos_cnt)) {
strcpy( selected_text, ctx->texts + (pos_list[0] - 1) * ctx->textsize);
(ctx->action_cb)( ctx->parent_ctx, selected_text);
(ctx->action_cb)( ctx->parent_ctx, selected_text, 1);
XtFree( (char *)pos_list);
}
......@@ -313,7 +313,7 @@ void CoWowMotif::list_action_cb( Widget w, XtPointer data,
}
void *CoWowMotif::CreateList( const char *title, const char *texts, int textsize,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *parent_ctx,
int show_apply_button)
......@@ -335,6 +335,7 @@ void *CoWowMotif::CreateList( const char *title, const char *texts, int textsize
ctx->action_cb = action_cb;
ctx->cancel_cb = cancel_cb;
ctx->parent_ctx = parent_ctx;
ctx->ok_pressed = 1;
i=0;
XtSetArg( args[i], XmNiconName, title); i++;
......
......@@ -50,7 +50,7 @@ typedef struct {
Widget list;
char *texts;
int textsize;
void (* action_cb) ( void *, char *);
void (* action_cb) ( void *, char *, int);
void (* cancel_cb) ( void *);
void *parent_ctx;
} *wow_tListCtx;
......@@ -111,7 +111,7 @@ class CoWowMotif : public CoWow {
void DisplayError( const char *title, const char *text);
void DisplayText( const char *title, const char *text) {}
void *CreateList( const char *title, const char *texts, int textsize,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button = 0);
......
......@@ -67,7 +67,7 @@ void *CoWow::CreateFileList(
const char *dir,
const char *pattern,
const char *type,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button
......
......@@ -127,10 +127,12 @@ class CoWow {
char *init_text,
void *data) {}
virtual void *CreateList( const char *title, const char *texts, int textsize,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button = 0) { return NULL;}
virtual void PopList( void *ctx) {};
virtual void DeleteList( void *ctx) {};
virtual void CreateFileSelDia( const char *title, void *parent_ctx,
void (*file_selected_cb)(void *, char *, wow_eFileSelType),
wow_eFileSelType file_type) {}
......@@ -149,7 +151,7 @@ class CoWow {
const char *dir,
const char *pattern,
const char *type,
void (action_cb)( void *, char *),
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button = 0);
......
......@@ -123,11 +123,12 @@ int GeGtk::create_modal_dialog( const char *title, const char *text, const char
return wow->CreateModalDialog( title, text, button1, button2, button3, image);
}
void GeGtk::create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx)
void *GeGtk::create_list( const char *title, const char *texts,
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *), void *ctx)
{
CoWowGtk wow( toplevel);
wow.CreateList( title, texts, 80, action_cb, 0, ctx, 1);
return wow.CreateList( title, texts, 80, action_cb, cancel_cb, ctx, 1);
}
void GeGtk::subgraphs_new()
......@@ -1591,6 +1592,8 @@ gboolean GeGtk::ge_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer da
GeGtk::~GeGtk()
{
if ( open_dialog)
wow->DeleteList( open_dialog);
if ( subgraphs)
delete subgraphs;
delete recall_entry;
......
......@@ -106,8 +106,9 @@ class GeGtk : public Ge {
virtual void subgraphs_new();
virtual void update();
virtual int get_plant_select( char *name, int size);
virtual void create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx);
virtual void *create_list( const char *title, const char *texts,
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *), void *ctx);
virtual int create_modal_dialog( const char *title, const char *text, const char *button1,
const char *button2, const char *button3, const char *image);
......
......@@ -91,11 +91,12 @@
#include "wb_wnav_selformat.h"
#include "wb_nav_motif.h"
void GeMotif::create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx)
void *GeMotif::create_list( const char *title, const char *texts,
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *), void *ctx)
{
CoWowMotif wow( toplevel);
wow.CreateList( title, texts, 80, action_cb, 0, ctx);
return wow.CreateList( title, texts, 80, action_cb, cancel_cb, ctx);
}
void GeMotif::subgraphs_new()
......
......@@ -100,8 +100,9 @@ class GeMotif : public Ge {
virtual void subgraphs_new();
virtual void update();
virtual int get_plant_select( char *name, int size);
virtual void create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx);
virtual void *create_list( const char *title, const char *texts,
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *), void *ctx);
virtual void plant_del( void *plantctx);
virtual int plant_get_select( void *plantctx, pwr_sAttrRef *attrref, int *is_attr);
......
......@@ -1517,9 +1517,16 @@ void Ge::activate_graph_attr()
graph->edit_subgraph_attributes();
}
void Ge::open_list_cb( void *ctx, char *text)
void Ge::open_list_cb( void *ctx, char *text, int ok_pressed)
{
((Ge *)ctx)->open_graph( text);
if ( ok_pressed)
((Ge *)ctx)->open_dialog = 0;
}
void Ge::open_cancel_cb( void *ctx)
{
((Ge *)ctx)->open_dialog = 0;
}
int Ge::sort_files( const void *file1, const void *file2)
......@@ -1543,6 +1550,11 @@ void Ge::activate_open()
char type[80];
int version;
if ( open_dialog) {
wow->PopList( open_dialog);
return;
}
// Get the pwg files and order them
dcli_translate_filename( fname, "$pwrp_pop/*.pwg");
......@@ -1586,8 +1598,8 @@ void Ge::activate_open()
qsort( file_p, file_cnt, sizeof(*file_p), Ge::sort_files);
create_list( "Open Graph",
(char *)file_p, Ge::open_list_cb, (void *)this);
open_dialog = create_list( "Open Graph",
(char *)file_p, Ge::open_list_cb, Ge::open_cancel_cb, (void *)this);
free( file_p);
......@@ -1618,7 +1630,7 @@ static tThemes themes[] = {
{"Polar", 14},
{"Custom", 100}};
static void ge_colortheme_selector_ok_cb( void *ctx, char *text)
static void ge_colortheme_selector_ok_cb( void *ctx, char *text, int ok_pressed)
{
Ge *gectx = (Ge *)ctx;
int idx = -1;
......@@ -2258,6 +2270,7 @@ void Ge::help_cb( void *ctx, char *topic, char *helpfile)
Ge::~Ge()
{
#ifdef LDH
if ( ldhses)
ldh_CloseSession( ldhses);
......@@ -2274,7 +2287,8 @@ Ge::Ge( void *x_parent_ctx,
yesnodia_yes_cb(0), yesnodia_no_cb(0), india_ok_cb(0), current_text_object(0),
current_value_object(0), current_confirm_object(0), ldhses(0), plantctx(0),
exit_when_close(x_exit_when_close), prev_count(0), focused_component(0),
recover_object(0), plant_mapped(0), subpalette_mapped(0), options(x_options)
recover_object(0), plant_mapped(0), subpalette_mapped(0), options(x_options),
open_dialog(0)
{
strcpy( name, "PwR Ge");
......
......@@ -118,6 +118,7 @@ class Ge {
int subpalette_mapped;
unsigned int options;
CoWow *wow;
void *open_dialog;
Ge( void *parent_ctx,
ldh_tSesContext ldhses, int exit_when_close, unsigned int x_options);
......@@ -140,8 +141,9 @@ class Ge {
virtual void subgraphs_new() {}
virtual void update() {}
virtual int get_plant_select( char *name, int size) { return 0;}
virtual void create_list( const char *title, const char *texts,
void (action_cb)( void *, char *), void *ctx) {}
virtual void *create_list( const char *title, const char *texts,
void (action_cb)( void *, char *, int),
void (cancel_cb)( void *), void *ctx) {return 0;}
virtual int create_modal_dialog( const char *title, const char *text, const char *button1,
const char *button2, const char *button3,
const char *image) { return 0;}
......@@ -320,7 +322,8 @@ class Ge {
static void subgraphs_close_cb( SubGraphs *subgraphs);
static void status_msg( void *ge_ctx, double x, double y);
static int command_cb( void *ge_ctx, char *command, char *script);
static void open_list_cb( void *ctx, char *text);
static void open_list_cb( void *ctx, char *text, int ok_pressed);
static void open_cancel_cb( void *ctx);
static int sort_files( const void *file1, const void *file2);
static int colorpalette_cb( GlowCtx *ctx, glow_tEvent event);
......
......@@ -338,7 +338,7 @@ void CLogGtk::activate_select_file( GtkWidget *w, gpointer data)
free( str);
}
void CLogGtk::file_selected_cb( void *ctx, char *text)
void CLogGtk::file_selected_cb( void *ctx, char *text, int ok_pressed)
{
CLog *clog = (CLog *)ctx;
int idx = -1;
......
......@@ -91,7 +91,7 @@ class CLogGtk : public CLog {
static void filter_ok_cb( GtkWidget*w, gpointer data);
static void filter_apply_cb( GtkWidget*w, gpointer data);
static void filter_cancel_cb( GtkWidget*w, gpointer data);
static void file_selected_cb( void *ctx, char *text);
static void file_selected_cb( void *ctx, char *text, int ok_pressed);
};
......
......@@ -500,7 +500,7 @@ void XttTCurve::tcurve_save_cb( void *ctx)
tcurve_file_selected_cb, 0, 40, tcurve->title, 0);
}
void XttTCurve::tcurve_open_file_cb( void *ctx, char *text)
void XttTCurve::tcurve_open_file_cb( void *ctx, char *text, int ok_pressed)
{
XttTCurve *tcurve = (XttTCurve *)ctx;
......
......@@ -151,7 +151,7 @@ class XttTCurve {
int rows, int idx, char *filename);
static void tcurve_help_cb( void *ctx);
static void tcurve_file_selected_cb( void *ctx, void *data, char *text);
static void tcurve_open_file_cb( void *ctx, char *text);
static void tcurve_open_file_cb( void *ctx, char *text, int ok_pressed);
static void tcurve_scan( void *data);
};
......
......@@ -542,7 +542,7 @@ public:
vector<AttrList> v;
};
static void add_objectlist_cb( void *ctx, char *text)
static void add_objectlist_cb( void *ctx, char *text, int ok_pressed)
{
printf( "%s\n", text);
......
......@@ -192,11 +192,11 @@ static void xnav_fast_close_cb( void *ctx, XttFast *fast);
static void xnav_fast_help_cb( void *ctx, const char *key);
static void xnav_xao_close_cb( void *ctx, XAttOne *xao);
static void xnav_clog_close_cb( void *ctx);
static void xnav_open_shist_cb( void *ctx, char *text);
static void xnav_open_shist_cb( void *ctx, char *text, int ok_pressed);
static void xnav_open_shist_cancel_cb( void *ctx);
static void xnav_show_objectlist_cb( void *ctx, char *text);
static void xnav_show_objectlist_cb( void *ctx, char *text, int ok_pressed);
static void xnav_show_objectlist_cancel_cb( void *ctx);
static void xnav_colortheme_selector_ok_cb( void *ctx, char *text);
static void xnav_colortheme_selector_ok_cb( void *ctx, char *text, int ok_pressed);
static void xnav_keyboard_key_pressed_cb( void *, int);
static void xnav_keyboard_close_cb( void *);
static int xnav_replace_node_str( char *out, char *object_str);
......@@ -6197,7 +6197,7 @@ static int xnav_delete_func( void *client_data,
return XNAV__SUCCESS;
}
static void xnav_collect_open_cb( void *ctx, char *text)
static void xnav_collect_open_cb( void *ctx, char *text, int ok_pressed)
{
XNav *xnav = (XNav *)ctx;
pwr_tCmd cmd;
......@@ -10101,7 +10101,7 @@ void XNav::print_methods()
}
}
static void xnav_open_shist_cb( void *ctx, char *text)
static void xnav_open_shist_cb( void *ctx, char *text, int ok_pressed)
{
pwr_tOName oname;
pwr_tOid coid;
......@@ -10129,7 +10129,7 @@ static void xnav_open_shist_cancel_cb( void *ctx)
free( ctx);
}
static void xnav_colortheme_selector_ok_cb( void *ctx, char *text)
static void xnav_colortheme_selector_ok_cb( void *ctx, char *text, int ok_pressed)
{
XNav *xnav = (XNav *)ctx;
gdh_sValueDef *vd;
......@@ -10179,7 +10179,7 @@ static void xnav_colortheme_selector_ok_cb( void *ctx, char *text)
free( vd);
}
static void xnav_show_objectlist_cb( void *ctx, char *text)
static void xnav_show_objectlist_cb( void *ctx, char *text, int ok_pressed)
{
XNav *xnav = ((xnav_sObjectList *)ctx)->xnav;
pwr_tCid cid = ((xnav_sObjectList *)ctx)->cid;
......
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