25 #include "pips_config.h"
33 #include <sys/resource.h>
63 GtkTreeSelection * selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
66 gchar *
buffer, *mchoices_notify_buffer;
67 int mchoices_length = 0;
77 buffer = (
char *)
malloc(strlen(mchoices_notify_buffer) + 1);
79 p = mchoices_notify_buffer;
80 while (sscanf(p,
"%s%n",
buffer, &len) == 1) {
94 g_free(mchoices_notify_buffer);
108 if (gtk_tree_selection_count_selected_rows(selection) == 0) {
109 prompt_user(
"You have to select at least 1 item !");
118 (*apply_on_mchoices)(mchoices_args);
137 (*cancel_on_mchoices)();
150 GtkTreePath *
path = (GtkTreePath *) _row;
151 gchar ** label = (gchar **) _label;
154 GValue path_associated_value = { 0, };
156 gtk_tree_model_get_iter(GTK_TREE_MODEL(
choices), &iter,
path);
157 gtk_tree_model_get_value(GTK_TREE_MODEL(
choices), &iter,
159 gchar * path_associated_value_string = (gchar *) g_value_get_string(
160 &path_associated_value);
172 GList * selected_rows;
173 gchar * new_mchoices_label;
175 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
choices_list));
176 new_mchoices_label =
strdup(
"");
180 selected_rows = gtk_tree_selection_get_selected_rows(GTK_TREE_SELECTION(
181 selection), (GtkTreeModel**)&
choices);
183 g_list_foreach(selected_rows,
concat_labels, &new_mchoices_label);
184 g_list_free(selected_rows);
186 gtk_label_set_text(GTK_LABEL(
mchoices_label), new_mchoices_label);
187 g_free(new_mchoices_label);
193 GtkTreeSelection * selection;
195 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
choices_list));
197 static bool select_all_when_press_this_button = TRUE;
199 if (select_all_when_press_this_button) {
200 gtk_tree_selection_select_all(GTK_TREE_SELECTION(selection));
202 gtk_tree_selection_unselect_all(GTK_TREE_SELECTION(selection));
209 select_all_when_press_this_button = !select_all_when_press_this_button;
213 void(*function_cancel)(
void)) {
225 for (i = 0; i < argc; i++) {
227 gtk_list_store_append(GTK_LIST_STORE(
choices), &iter);
244 GtkWidget *vbox, *buttons_hbox;
246 GtkTreeSelection * _select;
247 GtkWidget *deselect_button;
249 GtkWidget * scrolled_window;
250 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
251 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
252 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
254 vbox = gtk_vbox_new(FALSE, 0);
255 buttons_hbox = gtk_hbox_new(FALSE, 0);
266 gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(
"Current choices : "),
269 gtk_box_pack_start(GTK_BOX(vbox),
mchoices_label, FALSE, FALSE, 0);
279 for (i = 0; i < 5; i++) {
280 gtk_list_store_append(GTK_LIST_STORE(
choices), &iter);
286 GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
287 GtkTreeViewColumn * column;
288 column = gtk_tree_view_column_new_with_attributes(
"Available choices",
290 gtk_tree_view_append_column(GTK_TREE_VIEW(
choices_list), column);
292 _select = gtk_tree_view_get_selection(GTK_TREE_VIEW(
choices_list));
293 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(_select),
294 GTK_SELECTION_MULTIPLE);
297 gtk_container_add(GTK_CONTAINER(scrolled_window),
choices_list);
298 gtk_container_add(GTK_CONTAINER(
mchoose_frame), scrolled_window);
299 gtk_box_pack_start(GTK_BOX(vbox),
mchoose_frame, TRUE, TRUE, 5);
306 ok_button = gtk_button_new_with_label(
"OK");
307 gtk_signal_connect(GTK_OBJECT(
ok_button),
"clicked", GTK_SIGNAL_FUNC(
309 gtk_box_pack_start(GTK_BOX(buttons_hbox),
ok_button, FALSE, FALSE, 5);
314 deselect_button = gtk_button_new_with_label(
"(De)Select all");
315 gtk_signal_connect(GTK_OBJECT(deselect_button),
"clicked", GTK_SIGNAL_FUNC(
317 gtk_box_pack_start(GTK_BOX(buttons_hbox), deselect_button, FALSE, FALSE, 5);
322 gtk_signal_connect(GTK_OBJECT(
cancel_button),
"clicked", GTK_SIGNAL_FUNC(
324 gtk_box_pack_start(GTK_BOX(buttons_hbox),
cancel_button, FALSE, FALSE, 5);
329 gtk_signal_connect(GTK_OBJECT(
help_button),
"clicked", GTK_SIGNAL_FUNC(
331 gtk_box_pack_start(GTK_BOX(buttons_hbox),
help_button, FALSE, FALSE, 5);
333 gtk_box_pack_start(GTK_BOX(vbox), buttons_hbox, FALSE, FALSE, 5);
340 gtk_widget_show_all(vbox);
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
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
GtkWidget * mchoose_window
void display_help(char *topic)
void prompt_user(string a_printf_format,...)
static GtkWidget * ok_button
static GtkListStore * choices
static void(* apply_on_mchoices)(gen_array_t)
static GtkWidget * help_button
static void mchoose_callback(GtkTreeSelection *selection, gpointer data __attribute__((unused)))
Function used to update the text panel according to the list panel:
static GtkWidget * cancel_button
static void(* cancel_on_mchoices)(void)
void create_mchoose_window()
@ M_AVAILABLE_CHOICES_COLUMN_ID
void mchoose(char *title, gen_array_t array, void(*function_ok)(gen_array_t), void(*function_cancel)(void))
static void mchoose_ok_notify(GtkWidget *widget __attribute__((unused)), gpointer data __attribute__((unused)))
static GtkWidget * mchoices_label
Multiple choices handling.
static GtkWidget * choices_list
static void concat_labels(gpointer _row, gpointer _label)
static void mchoose_de_select_all_notify(GtkWidget *widget __attribute__((unused)), gpointer data __attribute__((unused)))
When we press on the "(De)Select" all button, select or deselect all the items.
static void mchoose_cancel_notify(GtkWidget *widget __attribute__((unused)), gpointer data __attribute__((unused)))
static void mchoose_window_done_proc(GtkWidget *window __attribute__((unused)), gpointer data __attribute__((unused)))
Avoid the mchoose_frame destruction and act as cancel:
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
struct _gen_array_chunk_t * gen_array_t
string concatenate(const char *,...)
Return the concatenation of the given strings.
static void mchoose_help_notify(Panel_item item, Event *event)