25 #include "pips_config.h"
33 #include <sys/resource.h>
34 #include <xview/xview.h>
35 #include <xview/panel.h>
36 #include <xview/notice.h>
37 #include <xview/notify.h>
62 char *
buffer, * mchoices_notify_buffer;
63 int mchoices_length = 0;
65 int item_is_in_the_list = FALSE;
68 nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS, NULL);
71 mchoices_notify_buffer =
strdup((
char *) xv_get(
mchoices, PANEL_VALUE));
73 buffer = (
char *)
malloc(strlen(mchoices_notify_buffer) + 1);
75 p = mchoices_notify_buffer;
76 while(sscanf(p,
"%s%n",
buffer, &len) == 1) {
78 item_is_in_the_list = FALSE;
79 for(i = 0; i < nchoices; i++)
82 item_is_in_the_list = TRUE;
85 if (item_is_in_the_list == FALSE)
90 free(mchoices_notify_buffer);
96 if (mchoices_length == 0 || item_is_in_the_list == FALSE) {
98 s = mchoices_length == 0 ?
"You have to select at least 1 item!" :
99 "You have selected an item not in the choice list!";
109 xv_set(
mchoices, PANEL_NOTIFY_PROC, NULL);
111 (*apply_on_mchoices)(mchoices_args);
118 PANEL_LIST_DELETE_ROWS, 0, nchoices,
121 xv_set(
mchoices, PANEL_VALUE,
"", NULL);
133 xv_set(
mchoices, PANEL_NOTIFY_PROC, NULL);
135 (*cancel_on_mchoices)();
139 PANEL_LIST_DELETE_ROWS, 0, (
int) xv_get(
choices,
144 xv_set(
mchoices, PANEL_VALUE,
"", NULL);
179 Xv_opaque client_data,
185 case PANEL_LIST_OP_SELECT:
186 case PANEL_LIST_OP_DESELECT:
189 int nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS);
196 xv_set(
mchoices, PANEL_VALUE,
"", NULL);
198 for(i = 0; i < nchoices; i++) {
199 if ((
int) xv_get(
choices, PANEL_LIST_SELECTED, i) == TRUE) {
203 PANEL_LIST_STRING, i),
213 case PANEL_LIST_OP_DELETE:
214 case PANEL_LIST_OP_VALIDATE:
218 pips_assert(
"schoose_choice_notify: unknown operation !", 0);
233 static bool select_all_when_press_this_button = TRUE;
235 int nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS);
237 for(i = nchoices - 1; i >= 0; i--)
239 PANEL_LIST_SELECT, i, select_all_when_press_this_button,
244 (Xv_opaque)NULL, PANEL_LIST_OP_SELECT,
248 select_all_when_press_this_button = !select_all_when_press_this_button;
256 void (*function_cancel)(
void))
266 nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS, 0);
270 PANEL_LIST_DELETE_ROWS, 0, nchoices,
273 for (i = 0; i < argc; i++) {
275 xv_set(
choices, PANEL_LIST_STRING, i, mn, NULL);
297 PANEL_LABEL_STRING,
"Current choices",
298 PANEL_VALUE_DISPLAY_LENGTH, 30,
299 PANEL_VALUE_STORED_LENGTH, 12800,
305 PANEL_LABEL_STRING,
"Available choices",
306 PANEL_LIST_DISPLAY_ROWS, 5,
308 PANEL_CHOOSE_ONE, FALSE,
314 PANEL_LABEL_STRING,
"OK",
321 PANEL_LABEL_STRING,
"(De)Select all",
326 PANEL_LABEL_STRING,
"Cancel",
331 PANEL_LABEL_STRING,
"Help",
void const char const char const int
size_t gen_array_nitems(const gen_array_t a)
void gen_array_full_free(gen_array_t a)
gen_array_t gen_array_make(size_t size)
declarations...
void gen_array_dupaddto(gen_array_t a, size_t i, void *what)
void * gen_array_item(const gen_array_t a, size_t i)
GtkWidget * mchoose_frame
void display_help(char *topic)
void prompt_user(string a_printf_format,...)
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
struct _gen_array_chunk_t * gen_array_t
string concatenate(const char *,...)
Return the concatenation of the given strings.
static void mchoose_cancel_notify(Panel_item item, Event *event)
static void mchoose_help_notify(Panel_item item, Event *event)
static Panel_item choices
static void(* apply_on_mchoices)(gen_array_t)
static void mchoose_frame_done_proc(Frame frame)
Avoid the mchoose_frame destruction and act as cancel:
static void mchoose_ok_notify(Panel_item item, Event *event)
static void mchoose_de_select_all_notify(Panel_item item, Event *event)
When we press on the "(De)Select" all button, select or deselect all the items.
static void(* cancel_on_mchoices)(void)
void create_mchoose_window()
static int mchoose_notify(Panel_item item, char *item_string, Xv_opaque client_data, Panel_list_op op, Event *event, int row)
Function used to update the text panel according to the list panel:
static Panel_item mchoices
Multiple choices handling.
void mchoose(char *title, gen_array_t array, void(*function_ok)(gen_array_t), void(*function_cancel)(void))
void unhide_window(Frame frame)
map a frame on the screen
void pointer_in_center_of_frame(Frame frame)
Centre la souris sur une fene^tre :