Exemple #1
0
static si_t
handle_window_cancel
(union message * msg)
{
    struct widget* w;
    w = application_widgets_for_each_increament(do_find_window, msg);
    if(w->callback != NULL)
        w->callback(w, msg);

    /* 如果要关闭主窗口 */
    if(global_application.main_window == WINDOW_POINTER(w))
    {
        application_del_window(WINDOW_POINTER(w));
    }
    else
    {
        cancel_window(WINDOW_POINTER(w)->descriptor);
        application_del_window(WINDOW_POINTER(w));

        /* 没有顶层窗口了 */
        /* 退出程序 */
        /* 这是为了处理没有设置主窗口的情况 */
        if(vector_size(&(global_application.window_vector)) == 0)
        {
            application_exit();
        }
        /* 还有顶层窗口 */
        else
        {
            application_widgets_for_each_increament(do_dispatch_repaint_event_to_all, NULL);
        }
    }

    return 0;
}
Exemple #2
0
si_t save_window_ok_button_callback(void* btn, void* msg)
{
    union message* m = (union message*)msg;
	switch(m->base.type)
	{
    case MESSAGE_TYPE_MOUSE_SINGLE_CLICK:
		if(0 == save_file(text_line_get_buf(save_text_line), text_line_get_buf(file_context_text_line)))
		{
			sprintf(log_label->text, "save successfully!");
		}
		else
		{
			sprintf(log_label->text, "failed to save file!");
		}
		application_del_window(save_window);
		sprintf(file_label->text, "%s", text_line_get_buf(save_text_line));
		save_window = NULL;
		save_text_line = NULL;
		break;
    default:
        button_default_callback(btn, msg);
        return 0;
        break;
	}
    label_repaint(log_label);
    label_show(log_label);
    return 0;
}
Exemple #3
0
si_t rename_window_ok_button_callback(void* btn, void* msg)
{
    union message* m = (union message*)msg;
	switch(m->base.type)
	{
    case MESSAGE_TYPE_MOUSE_SINGLE_CLICK:
		sprintf(save_file_name, "%s", text_line_get_buf(save_text_line));
		//重命名
		if(save_or_rename_flag==2){
			if(sh_temp_ptr && sh_temp_ptr->is_real==0){
				shortcut_set_text(sh_temp_ptr,save_file_name);
				change_file_content(sh_temp_ptr->link_file_path,"NAME:",save_file_name);
			}
			else if(sh_temp_ptr && sh_temp_ptr->is_real==1){
				shortcut_set_text(sh_temp_ptr,save_file_name);
				//pid_t pid;
				//if((pid = fork()) == 0){
					char new_name[100]={0};
					strcpy(new_name,desktop_path);
					strcat(new_name,save_file_name);
					//execl("/bin/mv","mv",sh_temp_ptr->link_file_path,new_name,NULL);
					chmod(new_name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
					rename(sh_temp_ptr->link_file_path,new_name);
					strcpy(sh_temp_ptr->link_file_path,new_name);			
				//}
			}
		}
		//新建文件
		else if(save_or_rename_flag==1){
			shortcut_set_text(sh_new_ptr,save_file_name);
			char new_name[100]={0};
			strcpy(new_name,desktop_path);
			strcat(new_name,save_file_name);
			pid_t pid;
			if((pid = fork()) == 0){

				execl("/bin/touch","touch",new_name,NULL);
				chmod(new_name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
			}
			strcpy(sh_new_ptr->link_file_path,new_name);	
			sh_new_ptr->is_real=1;
		}
		//新建文件夹
		else if(save_or_rename_flag==0){
			shortcut_set_text(sh_new_ptr,save_file_name);
			char new_name[100]={0};
			strcpy(new_name,desktop_path);
			strcat(new_name,save_file_name);
			pid_t pid;
			if((pid = fork()) == 0){

				execl("/bin/mkdir","mkdir",new_name,NULL);
				
				//FILE *out=fopen(new_name,"w");  /*out是充当临时文件作用*/
				//fclose(out);
				chmod(new_name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
			}
			strcpy(sh_new_ptr->link_file_path,new_name);	
			sh_new_ptr->is_real=1;
		}
		//关闭窗口		
        application_del_window(save_window);
		save_window = NULL;
		save_text_line = NULL;
		save_button = NULL;
		sh_new_ptr = NULL;
		break;
    default:
        button_default_callback(btn, msg);
        return 0;
        break;
	}
	//desktop_flush();
    return 0;
}