Beispiel #1
0
void MainMenu::clear_favourites()
{
    static Fl_String favourites;
    if(favourites.empty()) {
        favourites = fl_homedir();
        favourites += "/.ede/favourites/";

        if(!fl_file_exists(favourites)) {
            mkdir( favourites, 0777 );
        }
    }

    dirent **files;
    int pNumFiles = fl_filename_list(favourites, &files);

    if (pNumFiles > 10)
    {
        for (int i=0; i<(pNumFiles-10); i++) {
            if (strcmp(files[i]->d_name, ".") != 0 && strcmp(files[i]->d_name, "..") != 0 ) {
                Fl_String filename(favourites);
                filename += files[i]->d_name;
                unlink(filename);
            }
        }
    }

    for(int i = 0; i < pNumFiles; i++)
        free(files[i]);

    if(pNumFiles && files)
        free(files);
}
Beispiel #2
0
void update_property_dialog(Icon *i)
{
    Fl_String val;

    Fl_Config i_config(i->get_cfg()->filename());
    i_config.set_section("Desktop Entry");

    val = get_localized_name(i_config);
    if(!val.empty()) {
        pr_name->label(val);
    }

    if(!i_config.read("Exec", val, 0)) {
        pr_exec->label(val);
    }

    Fl_FileAttr *attr = fl_file_attr(i->get_cfg()->filename());
    if(attr)
    {
        char size[32];
        snprintf(size, 32, _("%d bytes, %s"), (int) attr->size, attr->time);
        pr_size->label(size);
        delete attr;
    }

    pr_icon->image(i->icon_im);
}
Beispiel #3
0
static void LaunchApp(char *name)
{
    Fl_Config conf(fl_find_config_file("wmanager.conf", false));
    Fl_String app;
    conf.get("Applications", name, app, NULL);
    if(! app.empty())
        fl_start_child_process(app, false);
}
Beispiel #4
0
// Start utility, like "time/date" or "volume"
void startUtility(Fl_Button *, void *pName)
{
	Fl_String value;
	pGlobalConfig.get("Panel", (char*)pName, value, "");

	if(!pGlobalConfig.error() && !value.empty()) {
		value = "ede-launch \""+value;
		value += "\"";
		fl_start_child_process(value, false);
	}
}
Beispiel #5
0
Fl_String get_localized_string()
{
    Fl_String locale = setlocale(LC_MESSAGES, NULL);
//    int pos = locale.rpos('_');
//    if(pos>0) locale.sub_delete(pos, locale.length()-pos);
    if(locale=="C" || locale=="POSIX") locale.clear();

    Fl_String localName;
    if(locale.empty()) localName = "Name";
    else localName.printf("Name[%s]", locale.c_str());

    return localName;
}
Beispiel #6
0
void parse_header(Fl_Buffer &buf)
{
	if(!header.empty()) return;

	char *ptr = buf.data();
	char *header_end = strstr(ptr, "\r\n\r\n");
	if(header_end) {
		header = Fl_String(ptr, header_end-ptr);		
		int hlen = header.length()+4;
		buf.set(buf.data()+hlen, buf.bytes()-hlen);

		printf("HEADER (%s)\n", header.c_str());
		int pos = header.pos("Content-Length");
		if(pos>-1) {
			pos += 15;
			int pos2 = header.pos("\r\n", pos);
			content_len = header.sub_str(pos, pos2-pos).to_int();	
			p_bar->range(0, content_len);
		}		
	}
}
Beispiel #7
0
void update_iconeditdialog(Icon *i)
{ 
    i_link->value(i->get_cfg()->filename());

    Fl_Config &i_config = *i->get_cfg();

    Fl_String val;
    i_config.set_section("Desktop Entry");

    val = get_localized_name(i_config);
    if(!val.empty()) {
        i_name->value(val);
    }

    if(!i_config.read("Exec", val, 0)) {
        i_location->value(val);
    }

    if(!i_config.read("Icon", val, 0)) {
        i_filename->value(val);
    }
}
Beispiel #8
0
// 'Fl_FileBrowser::load()' - Load a directory into the browser.
int                                         // O - Number of files loaded
    Fl_File_Browser::load(const Fl_String &dir) // I - Directory to load
{   
    Fl_String old_dir(directory());
    m_dir_ds.directory(dir);

    clear();
    clear_columns();
    sort_col(1);
    m_up_item = 0;

    if(dir.empty()) {
        header()->add_column("", 20);

        // No directory specified:
        //  - For UNIX list all mount points.
        //  - For Win32 list all valid drive letters.

        //icon      = Fl_FileIcon::find("any", Fl_FileIcon::DEVICE);
        //if (icon == (Fl_FileIcon *)0)
        //  icon = Fl_FileIcon::find("any", Fl_FileIcon::DIR);

        begin();
        char filename[FL_PATH_MAX];
#ifdef _WIN32
        header()->add_column(_("File"), 100);
        header()->add_column(_("Type"), 100);
        header()->add_column(_("Capacity"), 100);
        header()->add_column(_("Free Space"), 100);

        // Drive available bits
        DWORD drives = GetLogicalDrives();
        for(int i = 'A'; i <= 'Z'; i ++, drives >>= 1) {
            if (drives & 1) {
                Fl_ListView_Item *item = new Fl_ListView_Item();
                item->image(&hd_pix);
                snprintf(filename, sizeof(filename)-1, "%c:\\", i);
                item->label(1, filename);

                Fl_File_Attr *attr = fl_file_attr(filename);
                if(attr->flags & Fl_File_Attr::DEVICE)
                {
                    uint type = GetDriveTypeA(filename);
                    const char *typestr=_(types[0]);

                    if (type==DRIVE_CDROM)      { typestr=_(types[4]); item->image(&cd_pix); }
                    else if (type==DRIVE_REMOVABLE) { typestr=_(types[5]); item->image(&floppy_pix); }
                    else if (type==DRIVE_FIXED)     typestr=_(types[6]);
                    else if (type==DRIVE_REMOTE)        typestr=_(types[7]);
                    else if (type==DRIVE_RAMDISK)   typestr=_(types[8]);

                    item->label(2, typestr);

                    uint s = 0;
                    Fl_String suffix;
                    if((s = get_dev_size(attr->capacity, suffix))>0) {
                        item->label(3, Fl_String(s)+" "+suffix);
                    }
                    if((s = get_dev_size(attr->free, suffix))>0) {
                        item->label(4, Fl_String(s)+" "+suffix);
                    }

                    /*
                     //TOO SLOW!!!
                     char drivename[255];
                     if(GetVolumeInformation(
                     filename, drivename, sizeof(drivename)-1,
                     NULL, NULL, NULL, NULL, 0))
                     {
                     if(drivename[0])
                     snprintf(fname, sizeof(fname)-1, "%s (%s)", filename, drivename);
                     }
                     */
                }

            }
        }
#else
        header()->add_column(_("File"), 100);
        header()->add_column(_("Device"), 100);
        header()->add_column(_("Type"), 100);

        FILE    *mtab = 0;      // /etc/mtab or /etc/mnttab file
        char    line[1024];     // Input line
        char    dev[256];       // Device name
        char    fstype[256];    // Filesystem type

        // Open the file that contains a list of mounted filesystems...
#  if defined(__hpux) || defined(__sun)
        // Fairly standard
        mtab = fl_fopen("/etc/mnttab", "r");
#  elif defined(__sgi) || defined(linux)
        // More standard
        mtab = fl_fopen("/etc/mtab", "r");
#  endif
        // Otherwise fallback to full list
        if(mtab == NULL) mtab = fl_fopen("/etc/fstab", "r");
        if(mtab == NULL) mtab = fl_fopen("/etc/vfstab", "r");

        if (mtab != NULL)
        {
            while (fgets(line, sizeof(line), mtab) != NULL)
            {
                if (line[0] == '#' || line[0] == '\n')
                    continue;
                if (sscanf(line, "%255s%4095s%255s", dev, filename, fstype) != 3)
                    continue;
                if(!strcasecmp(dev, "none"))
                    continue;

                Fl_ListView_Item *item = new Fl_ListView_Item();
                item->image(&hd_pix);
                item->label(1, filename);
                item->label(2, dev);
                item->label(3, fstype);
            }
            fclose(mtab);
        }
#endif // _WIN32
        end();
        resizable_col(0, false);
        return children();

    } else {