Example #1
0
void alert_window(GtkWidget *widget) {
  UNUSED(widget);
  check_alerts();
  char **listCompte = bdd_get_libelle_account();
  if (listCompte != NULL) {
    UNUSED(widget);
    clean_window();
    GtkWidget *button_alerte_cat, *button_alert_compte, *button_retour;

    gtk_window_set_title(GTK_WINDOW(window), "Alertes");
    gtk_window_set_default_size(GTK_WINDOW(window), 800,600);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

    button_alerte_cat = gtk_button_new_with_label("Nouvelle alerte sur une categorie");
    g_signal_connect(button_alerte_cat, "clicked", G_CALLBACK(create_alert_form), "max_cat");

    button_alert_compte = gtk_button_new_with_label("Nouvelle alerte sur un compte");
    g_signal_connect(button_alert_compte, "clicked", G_CALLBACK(create_alert_form), "min_account");

    button_retour = gtk_button_new_with_label("Retour");
    g_signal_connect(button_retour, "clicked", G_CALLBACK(main_window), NULL);

    gtk_grid_attach(GTK_GRID(grid), button_alerte_cat, 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), button_alert_compte, 0, 1, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), button_retour, 0, 2, 1, 1);

    gtk_widget_show_all(window);
  } else {
    alert_dialog(window, "Please create accounts before trying to add alerts");
  }
}
Example #2
0
int	main(int ac, char **av, char **env)
{
  char	**cpenv;

  cpenv = NULL;
  signal(SIGINT, SIG_IGN);
  if (ac > 1 && av[1] == NULL)
    return (0);
  clean_window();
  cpenv = cp_environ(env, cpenv);
  minishell2(cpenv);
  return (0);
}
Example #3
0
/** search mode staff **/
void
turnon_search_mode(void)
{
  // show up the input window
  wchain[SEARCH_INPUT].visible = 1;
  
  songlist->key[0] = '\0';
  songlist->picking_mode = 0;
  //songlist->wmode.listen_keyboard = &searchmode_keymap;
  songlist_cursor_hide();

  clean_window(VERBOSE_PROC_BAR);
  clean_window(VISUALIZER);

  // switch the keyboard and update_checking() rountine
  songlist->wmode.listen_keyboard = &searchmode_keymap;
  wchain[SONGLIST].update_checking = &searchmode_update_checking;

  being_mode_update(&songlist->wmode);

  songlist->search_mode = 1;

  crt_menu = 1;
}
Example #4
0
void
turnoff_search_mode(void)
{
  // turn off the input window
  wchain[SEARCH_INPUT].visible = 0;
  
  songlist->key[0] = '\0';
  songlist_update();
  songlist_scroll_to_current();

  clean_window(SEARCH_INPUT);

  // switch the keboard and update_checking() back
  songlist->wmode.listen_keyboard = &songlist_keymap;
  wchain[SONGLIST].update_checking = &songlist_update_checking;

  songlist->update_signal = 1;

  songlist->search_mode = 0;  
}
Example #5
0
void display_execution(int num_instruction, mot * tab_mot_instruction, int nb_instruction, int* registres,int nb_reg, int PC, int SP, int SR){
        ITEM *item_en_cour = NULL; 
    
        char ** tab_instruction;
        // for instructions
        ITEM **instructions_items;
	int c;		
        WINDOW *instructions_win;
	MENU *instruction_menu;
	int i;
	instructions_items = (ITEM **)calloc(nb_instruction + 1, sizeof(ITEM *));
        int menu_instruction_alrdy_dlt = 0; //pour ne pas supprimer le menu 2 fois --> évite les erreur de segmentation lorsqu'on quitte
        
        
        char ** files;  //in case of F2
        
        // for register
        char  ** tab_register;
        ITEM **register_items;
	WINDOW *register_win;
	MENU *register_menu;
	register_items = (ITEM **)calloc(nb_reg + 1 +3, sizeof(ITEM *)); //+3 pour PC SP et SR
        int menu_register_alrdy_dlt = 0; //pour ne pas supprimer le menu 2 fois --> évite les erreur de segmentation lorsqu'on quitte
        
        
        char dest_string[5];
        char source_string[5];
        char brut_string[10];
        char pc_string[6], sp_string[6], sr_string[6];
        
        
        
        int is_brut = 0; //si le mot précedent contient un mode direct, alors le mot suivant est un brut //si DIRIMM les 2 suivant sont des brut
        
        
        //allocation de mémoire pour les insctruction sous forme de chaine
        tab_instruction = (char**) malloc (nb_instruction* sizeof(char*));
        
        
        
        //allocation de mémoire pour le tabeau de registre sous forme de string
        tab_register = (char**) malloc (nb_reg* sizeof(char *));
        
        int num_choix;
        char * choix = NULL;

         
	for(i = 0; i < nb_instruction; ++i){
            
            tab_instruction[i] = malloc(50 * sizeof(char)); //plus simple pour le moment, une instruction ne peut dépasser 50caractères ... a améliorer si assez de temps
                
            
            if(is_brut == 0){
               
                
                
                sprintf(dest_string, "%d", tab_mot_instruction[i].codage.dest);
                sprintf(source_string, "%d", tab_mot_instruction[i].codage.source);
                
                //si l'instruction contient une source ou destination en mode immediat ou direct, la prochaine instruction sera un brut
                if(is_brut==2 || tab_mot_instruction[i].codage.mode == REGIMM || tab_mot_instruction[i].codage.mode == INDIMM || tab_mot_instruction[i].codage.mode == REGDIR || tab_mot_instruction[i].codage.mode ==  DIRREG){
                    is_brut = 1;
                }
                if(tab_mot_instruction[i].codage.mode == DIRIMM){
                    is_brut = 2;
                }
                
                strcpy(tab_instruction[i], codeop_tostring(tab_mot_instruction[i].codage.codeop) ); //on met tout les élément sous forme de string concaténé et espacé
                strcat(tab_instruction[i], "    "); 
                strcat(tab_instruction[i], mode_tostring(tab_mot_instruction[i].codage.mode));
                strcat(tab_instruction[i], "    "); 
                strcat(tab_instruction[i], dest_string);
                strcat(tab_instruction[i], "    "); 
                strcat(tab_instruction[i], source_string);
            }
            else{
               sprintf(brut_string, "%d", tab_mot_instruction[i].brut); 
               strcpy(tab_instruction[i], brut_string ); 
               if(is_brut == 2){
                   is_brut = 1; // cas du DIRIMM
               } else{
                   is_brut = 0;
               }
            }
                

                //mvprintw(i+2, 0, "%s", tab_instruction[i]);
                instructions_items[i] = new_item(tab_instruction[i], ""); //ajoute les éléments dans mon tableau d'item
                
                if(i == num_instruction){
                        //on sauvegarde l'adresse de l'item que l'on est entrain de traiter (celui donner par num_instruction)
                        item_en_cour = instructions_items[i];
                        //n le desactive, cela permet de lui doonner une autre apparence pur le repérer
                        item_opts_off(instructions_items[i], O_SELECTABLE);
                }
        }
                
        
        
        
        
        for(i = 0; i < nb_reg; ++i){
                //contient le registre sous forme de string par exemple R1 ou PC
                tab_register[i] = malloc(3 * sizeof(char));
                
                sprintf(tab_register[i], "R%i: %d",i, registres[i]);
                
                //mvprintw(i+2, 0, "%s", tab_instruction[i]);
                register_items[i] = new_item(tab_register[i], ""); //ajoute les éléments dans mon tableau d'item
        }
                sprintf(pc_string, "%d", PC);
                sprintf(sp_string, "%d", SP);
                sprintf(sr_string, "%d", SR);
                register_items[nb_reg] = new_item("PC:", pc_string); //register_items[8]
                register_items[nb_reg+1] = new_item("SP:", sp_string); //register_items[9]
                register_items[nb_reg+2] = new_item("SR:", sr_string);  //register_items[10]
                //pour cacher la selection du premier registre
                item_opts_off(register_items[0], O_SELECTABLE);
        
        
	instruction_menu = new_menu((ITEM **)instructions_items); //creer un menu contenant les instructions
        
        register_menu = new_menu((ITEM **)register_items); //creer un menu contenant les registres
	mvprintw(LINES - 2, 0, "F9 to close the menu"); 
        
        
        
        instructions_win = newwin((LINES-4)/2, 40 , 3, (COLS/2)- (COLS-4)/4); //créer une nouvelle fenetre pour les instructions
        register_win = newwin(16, 20 , 3, (COLS/2) + 10); //créer une nouvelle fenetre pour les registres
        
        keypad(instructions_win, TRUE); //active le clavier sur les instructions
       
        
        
        /* Set main window and sub window */
        set_menu_win(instruction_menu, instructions_win); //set main menu
        set_menu_sub(instruction_menu, derwin(instructions_win, ((LINES-4)/2)-4, 38, 3, 1)); // set sub window
        set_menu_format(instruction_menu, ((LINES-4)/2)-4, 1);
        
        set_menu_win(register_menu, register_win); //set main menu
        set_menu_sub(register_menu, derwin(register_win, 13, 18, 3, 1)); // set sub window
        set_menu_format(register_menu, 13, 1);
        
        
        
        
       /* Set menu mark to the string " * " */
        set_menu_mark(instruction_menu, " * ");
        set_menu_mark(register_menu, "");
        
        
        /* Print a border around the main window and print a title */
        box(instructions_win, 0, 0);
        print_in_middle(instructions_win, 1, 0, 40, "liste des instructions", COLOR_PAIR(1));
	mvwaddch(instructions_win, 2, 0, ACS_LTEE);
	mvwhline(instructions_win, 2, 1, ACS_HLINE, 43);
	mvwaddch(instructions_win, 2, 39, ACS_RTEE);
        
        box(register_win, 0, 0);
        print_in_middle(register_win, 1, 0, 20, "Registres", COLOR_PAIR(1));
	mvwaddch(register_win, 2, 0, ACS_LTEE);
	mvwhline(register_win, 2, 1, ACS_HLINE, 22);
	mvwaddch(register_win, 2, 19, ACS_RTEE);
	refresh();
        
	post_menu(instruction_menu);
        post_menu(register_menu);
        
        //on se place sur l'instruction en cour
        set_current_item (instruction_menu, item_en_cour);
        
	wrefresh(instructions_win);
        wrefresh(register_win);
       

	while((c = getch()) != KEY_F(9) && c != 32)
	{   switch(c)
	    {	case KEY_F(5):
                mvprintw(LINES-2, 0, "Exiting...");
                endwin();			/* End curses mode		  */
                exit(0);
            
                case KEY_F(2):
                        files = list_file("", &i);
                        draw_menu(files, execute_file_menu, "", i);
                        
                case KEY_DOWN:
		        menu_driver(instruction_menu, REQ_DOWN_ITEM);
			break;
		case KEY_UP:
			menu_driver(instruction_menu, REQ_UP_ITEM);
			break;
                
            
                //case KEY_NPAGE:
		//	menu_driver(my_menu, REQ_SCR_DPAGE);
		//	break;
                //case KEY_PPAGE:
		//	menu_driver(my_menu, REQ_SCR_UPAGE);
		//	break;
        
            
                case 10:
                        move(20, 0);
			clrtoeol();
                       
			break;
                 

		}
                wrefresh(instructions_win);
	}
        if(menu_instruction_alrdy_dlt == 0){
                clean_menu(instruction_menu);
                clean_window(instructions_win);
        }
                if(menu_register_alrdy_dlt == 0){
                clean_menu(register_menu);
                clean_window(register_win);
        }
    
    
}
Example #6
0
void draw_menu(char ** menu_liste, void (*ptrfonction)(int,const char *, char *), char * folder, int taille_menu){
        ITEM **my_items;
	int c;		
        WINDOW *my_menu_win;
	MENU *my_menu;
	int i;
	ITEM *cur_item;
        my_items = (ITEM **)calloc(taille_menu + 1, sizeof(ITEM *));
        int menu_alrdy_dlt = 0; //pour ne pas supprimer le menu 2 fois --> évite les erreur de segmentation lorsqu'on quitte
        char ** files; //pour le cas ou on utilise F2 (ouvrir un fichier)
        
        int num_choix;
        char choix[FILE_MAX];

	for(i = 0; i < taille_menu; ++i){
	        my_items[i] = new_item(menu_liste[i], ""); //ajoute les éléments dans mon tableau d'item
        }
	//my_items[taille_menu+1] = (ITEM *)NULL; //ajoute un item vide à la fin du tableau
        my_menu = new_menu((ITEM **)my_items); //creer un menu contenan les items
	mvprintw(LINES - 2, 0, "F9 to close the menu"); //affiche un pied de page pour fermer le menu
        
        my_menu_win = newwin(10, 45, (LINES-10)/2, (COLS-45)/2); //créer une nouvelle fenetre
        keypad(my_menu_win, TRUE); //active le clavier pour le menu
       
        
        
        
        /* Set main window and sub window */
        set_menu_win(my_menu, my_menu_win); //set main menu
        set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1)); // set sub window
        set_menu_format(my_menu, 5, 1);
        
       /* Set menu mark to the string " * " */
        set_menu_mark(my_menu, " * ");
        
        /* Print a border around the main window and print a title */
        box(my_menu_win, 0, 0);
        print_in_middle(my_menu_win, 1, 0, 45, "Menu Principal", COLOR_PAIR(1));
	mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
	mvwhline(my_menu_win, 2, 1, ACS_HLINE, 43);
	mvwaddch(my_menu_win, 2, 44, ACS_RTEE);
	refresh();
        
	post_menu(my_menu);
	wrefresh(my_menu_win);
       

	while((c = getch()) != KEY_F(9) && c != 27)
	{   switch(c)
	    {	case KEY_F(5):
                        mvprintw(LINES-2, 0, "Exiting...");
                        endwin();			/* End curses mode		  */
                        exit(0);
            
                case KEY_F(2):
                        files = list_file("", &i);
                        clean_menu(my_menu);
                        clean_window(my_menu_win);
                        draw_menu(files, execute_file_menu, "", i);
                        return;
                    
                case KEY_DOWN:
		        menu_driver(my_menu, REQ_DOWN_ITEM);
			break;
		case KEY_UP:
			menu_driver(my_menu, REQ_UP_ITEM);
			break;
                
            
                case KEY_NPAGE:
			menu_driver(my_menu, REQ_SCR_DPAGE);
			break;
                case KEY_PPAGE:
			menu_driver(my_menu, REQ_SCR_UPAGE);
			break;
        
            
                case 10:
                        move(20, 0);
			clrtoeol();
                        num_choix = item_index(current_item(my_menu));
                        strcpy(choix, item_name(current_item(my_menu)));
			//mvprintw(5, 0, "Item selected is : %s", item_name(current_item(my_menu)));
                        clean_menu(my_menu);
                        menu_alrdy_dlt = 1;
                        clean_window(my_menu_win);
                        (*ptrfonction)(num_choix, choix, folder);
			pos_menu_cursor(my_menu);
			break;
                 

		}
                wrefresh(my_menu_win);
	}
        if(menu_alrdy_dlt == 0)
                clean_menu(my_menu);
        clean_window(my_menu_win);
        
       
        
    
}