25 #include "pips_config.h"
43 #include <sys/resource.h>
73 GtkTreeModel ** model = NULL;
76 GtkTreeSelection * selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
79 if (!gtk_tree_selection_get_selected(selection, model, &iter)) {
106 (*apply_on_choice)(gc_choice);
121 (*apply_on_cancel)();
127 GtkTreeModel * model;
135 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
136 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
146 (*apply_on_cancel)();
151 void(*function_for_ok)(
const char *),
void(*function_for_cancel)(
void)) {
155 GtkTreeSelection * selection;
156 bool do_select = FALSE;
165 if (initial_choice != NULL) {
167 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
choices_list));
170 for (i = 0; i < argc; i++) {
172 gtk_list_store_append(GTK_LIST_STORE(
choices), &iter);
176 if (i == 0 || strcmp(initial_choice, name) == 0)
177 gtk_tree_selection_select_iter(GTK_TREE_SELECTION(selection),
191 GtkWidget *window_vbox, *buttons_hbox, *current_choice_hbox;
193 GtkTreeSelection * selection;
195 window_vbox = gtk_vbox_new(FALSE, 0);
196 buttons_hbox = gtk_hbox_new(FALSE, 0);
197 current_choice_hbox = gtk_hbox_new(FALSE, 0);
198 gtk_box_pack_start(GTK_BOX(window_vbox), current_choice_hbox, FALSE, FALSE,
202 gtk_box_pack_start(GTK_BOX(current_choice_hbox), gtk_label_new(
203 "Current choice : "), FALSE, FALSE, 0);
205 gtk_box_pack_start(GTK_BOX(current_choice_hbox),
choice_label, FALSE,
209 for (i = 0; i < 5; i++) {
210 gtk_list_store_append(GTK_LIST_STORE(
choices), &iter);
211 gtk_list_store_set(GTK_LIST_STORE(
choices), &iter,
218 GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
219 GtkTreeViewColumn * column;
220 column = gtk_tree_view_column_new_with_attributes(
"Available choices",
222 gtk_tree_view_append_column(GTK_TREE_VIEW(
choices_list), column);
224 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
choices_list));
225 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection),
226 GTK_SELECTION_SINGLE);
230 gtk_box_pack_start(GTK_BOX(window_vbox),
choices_list, TRUE, FALSE, 0);
233 ok_button = gtk_button_new_with_label(
"OK");
234 g_signal_connect(GTK_OBJECT(
ok_button),
"clicked", G_CALLBACK(
236 gtk_box_pack_start(GTK_BOX(buttons_hbox),
ok_button, FALSE, FALSE, 5);
239 g_signal_connect(GTK_OBJECT(
cancel_button),
"clicked", G_CALLBACK(
241 gtk_box_pack_start(GTK_BOX(buttons_hbox),
cancel_button, FALSE, FALSE, 5);
243 help = gtk_button_new_with_label(
"Help");
244 g_signal_connect(GTK_OBJECT(
help),
"clicked",
246 gtk_box_pack_start(GTK_BOX(buttons_hbox),
help, FALSE, FALSE, 5);
248 gtk_box_pack_start(GTK_BOX(window_vbox), buttons_hbox, FALSE, FALSE, 5);
252 g_signal_connect(GTK_OBJECT(
schoose_window),
"delete_event", G_CALLBACK(
255 gtk_widget_show_all(window_vbox);
size_t gen_array_nitems(const gen_array_t a)
void * gen_array_item(const gen_array_t a, size_t i)
GtkWidget * schoose_window
void display_help(char *topic)
void prompt_user(string a_printf_format,...)
static GtkWidget * ok_button
static GtkWidget * choice_label
Single choice handling.
static GtkListStore * choices
void schoose(char *title, gen_array_t array, char *initial_choice, void(*function_for_ok)(const char *), void(*function_for_cancel)(void))
void schoose_close()
schoose_close() can be called even when schoose window is already closed.
static void(* apply_on_cancel)(void)
static GtkWidget * cancel_button
static void schoose_ok_notify(GtkWidget *widget, gpointer data)
called when the "ok button" is clicked to validate an entry or when you select something with the men...
static void schoose_choice_callback(GtkTreeSelection *selection, gpointer data)
Function used to update the text panel according to the list panel:
@ SC2_AVAILABLE_CHOICES_COLUMN_ID
static void schoose_window_done_callback(GtkWidget *window, GdkEvent *ev, gpointer data)
Avoid the schoose_frame destruction and act as cancel:
static void(* apply_on_choice)(const char *)
void schoose_cancel_notify(GtkWidget *widget, gpointer data)
void create_schoose_window()
static GtkWidget * choices_list
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
static void schoose_help_notify(Panel_item item, Event *event)