Esempio n. 1
0
void WidgetChatBubble::add_filerecv(Toxmm::EventFileRecv file) {
    auto msg_time = Glib::DateTime::create_now_utc();

    // remove seconds
    msg_time = Glib::DateTime::create_utc(msg_time.get_year(),
                                          msg_time.get_month(),
                                          msg_time.get_day_of_month(),
                                          msg_time.get_hour(),
                                          msg_time.get_minute(),
                                          0);

    bool display_time = true;

    if (m_last_timestamp != 0) {
        auto old_time = Glib::DateTime::create_now_utc(m_last_timestamp);
        // remove seconds
        old_time = Glib::DateTime::create_utc(old_time.get_year(),
                                              old_time.get_month(),
                                              old_time.get_day_of_month(),
                                              old_time.get_hour(),
                                              old_time.get_minute(),
                                              0);
        // check
        display_time = !(msg_time.compare(old_time) == 0);
    }

    // create a new row
    auto msg  = Gtk::manage(WidgetChatFileRecv::create(observable(), file));
    auto time = Gtk::manage(new Gtk::Label());
    m_last_timestamp = msg_time.to_unix();

    // get local time
    msg_time = Glib::DateTime::create_now_local(m_last_timestamp);

    time->set_text(msg_time.format("%R"));

    // add to grid
    if (m_side == RIGHT) {
        rows.emplace_back(m_grid, m_row_count, *msg, *time);
    } else {
        rows.emplace_back(m_grid, m_row_count, *time, *msg);
    }
    m_row_count += 1;

    // styling
    time->set_halign(Gtk::ALIGN_CENTER);
    time->set_valign(Gtk::ALIGN_START);
    time->get_style_context()->add_class("bubble_chat_line_time");

    msg->set_halign(Gtk::ALIGN_START);
    msg->set_valign(Gtk::ALIGN_CENTER);

    msg->show_all();
    time->show_all();
    time->set_no_show_all();
    if (!display_time) {
        time->hide();
    }
}
Esempio n. 2
0
const Path& get_current_directory()
{
    if( s_current_dir.is_empty() )
    {
#ifdef PLATFORM_WIN32
        wchar_t path[kMaxPath];
        path[0] = 0;
        GetCurrentDirectory(kMaxPath, path);
        s_current_dir.set(to_unix(path));
#else
        char path[kMaxPath];
        path[0] = 0;
        getcwd(path, kMaxPath);
        s_current_dir.set(path);
#endif
    }

    return s_current_dir;
}
Esempio n. 3
0
static int list_file(direntry_t *entry, MainParam_t *mp)
{
	unsigned long size;
	int i;
	int Case;
	int r;

	if(!all && (entry->dir.attr & 0x6))
		return 0;

	if(concise && isSpecial(entry->name))
		return 0;

	r=enterDirectory(entry->Dir);
	if (r)
		return ERROR_ONE;
	if (wide) {
		if(filesInDir % 5)
			putchar(' ');				
		else
			putchar('\n');
	}
	
	if(IS_DIR(entry)){
		size = 0;
	} else
		size = FILE_SIZE(&entry->dir);
	
	Case = entry->dir.Case;
	if(!(Case & (BASECASE | EXTCASE)) && 
	   mtools_ignore_short_case)
		Case |= BASECASE | EXTCASE;
	
	if(Case & EXTCASE){
		for(i=0; i<3;i++)
			entry->dir.ext[i] = tolower(entry->dir.ext[i]);
	}
	to_unix(entry->dir.ext,3);
	if(Case & BASECASE){
		for(i=0; i<8;i++)
			entry->dir.name[i] = tolower(entry->dir.name[i]);
	}
	to_unix(entry->dir.name,8);
	if(wide){
		if(IS_DIR(entry))
			printf("[%s]%*s", shortname,
			       (int) (15 - 2 - strlen(shortname)), "");
		else
			printf("%-15s", shortname);
	} else if(!concise) {				
		/* is a subdirectory */
		if(mtools_dotted_dir)
			printf("%-13s", shortname);
		else
			printf("%-8.8s %-3.3s ",
			       entry->dir.name, 
			       entry->dir.ext);
		if(IS_DIR(entry))
			printf("<DIR>    ");
		else
			printf(" %8ld", (long) size);
		printf(" ");
		print_date(&entry->dir);
		printf("  ");
		print_time(&entry->dir);

		if(debug)
			printf(" %s %d ", entry->dir.name, START(&entry->dir));
		
		if(*longname)
			printf(" %s", longname);
		printf("\n");
	} else {
		printf("%s/%s", dirPath, entry->name);
		if(IS_DIR(entry))
			putchar('/');
		putchar('\n');
	}

	filesOnDrive++;
	filesInDir++;

	bytesOnDrive += (mt_size_t) size;
	bytesInDir += (mt_size_t) size;
	return GOT_ONE;
}