static void _admin_edit_combo_box_resv(GtkComboBox *combo, resv_desc_msg_t *resv_msg) { GtkTreeModel *model = NULL; GtkTreeIter iter; int column = 0; char *name = NULL; if (!resv_msg) return; if (!gtk_combo_box_get_active_iter(combo, &iter)) { g_print("nothing selected\n"); return; } model = gtk_combo_box_get_model(combo); if (!model) { g_print("nothing selected\n"); return; } gtk_tree_model_get(model, &iter, 0, &name, -1); gtk_tree_model_get(model, &iter, 1, &column, -1); _set_resv_msg(resv_msg, name, column); g_free(name); }
static gboolean _admin_focus_out_resv(GtkEntry *entry, GdkEventFocus *event, resv_desc_msg_t *resv_msg) { if (global_entry_changed) { const char *col_name = NULL; int type = gtk_entry_get_max_length(entry); const char *name = gtk_entry_get_text(entry); type -= DEFAULT_ENTRY_LENGTH; col_name = _set_resv_msg(resv_msg, name, type); if (global_edit_error && !global_edit_error_msg) { global_edit_error_msg = g_strdup_printf( "Reservation %s %s can't be set to %s", resv_msg->name, col_name, name); } global_entry_changed = 0; } return false; }
extern void admin_edit_resv(GtkCellRendererText *cell, const char *path_string, const char *new_text, gpointer data) { GtkTreeStore *treestore = GTK_TREE_STORE(data); GtkTreePath *path = gtk_tree_path_new_from_string(path_string); GtkTreeIter iter; resv_desc_msg_t *resv_msg = xmalloc(sizeof(resv_desc_msg_t)); char *temp = NULL; char *old_text = NULL; const char *type = NULL; int column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column")); if (!new_text || !strcmp(new_text, "")) goto no_input; gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), &iter, path); slurm_init_resv_desc_msg(resv_msg); gtk_tree_model_get(GTK_TREE_MODEL(treestore), &iter, SORTID_NAME, &temp, column, &old_text, -1); resv_msg->name = xstrdup(temp); g_free(temp); type = _set_resv_msg(resv_msg, new_text, column); if (global_edit_error) goto print_error; if (got_edit_signal) { temp = got_edit_signal; got_edit_signal = NULL; _admin_resv(GTK_TREE_MODEL(treestore), &iter, temp); xfree(temp); goto no_input; } if (old_text && !strcmp(old_text, new_text)) { temp = g_strdup_printf("No change in value."); } else if (slurm_update_reservation(resv_msg) == SLURM_SUCCESS) { gtk_tree_store_set(treestore, &iter, column, new_text, -1); temp = g_strdup_printf("Reservation %s %s changed to %s", resv_msg->name, type, new_text); } else if (errno == ESLURM_DISABLED) { temp = g_strdup_printf( "Can only edit %s on reservations not yet started.", type); } else { print_error: temp = g_strdup_printf("Reservation %s %s can't be " "set to %s", resv_msg->name, type, new_text); } display_edit_note(temp); g_free(temp); no_input: slurm_free_resv_desc_msg(resv_msg); gtk_tree_path_free (path); g_free(old_text); g_mutex_unlock(sview_mutex); }