Exemplo n.º 1
0
void save_icon(Icon *i_window)
{
    if(i_name->size()==0) {
        fl_alert(_("Name of the icon must be filled."));
    }
    else
    {
        const char *icon_file = i_filename->value();
        const char *icons_path = PREFIX"/share/ede/icons/48x48";
        if(!strncmp(icons_path, i_filename->value(), strlen(icons_path))) {
            // Only relative path, if icon in default location
            icon_file = fl_file_filename(i_filename->value());
        }

        Fl_Config i_config(i_link->value());
        i_config.set_section("Desktop Entry");

        i_config.write(get_localized_string(), i_name->value());
        i_config.write("Name", i_name->value());	// fallback
        i_config.write("Exec", i_location->value());
        i_config.write("Icon", icon_file);
        i_config.flush();
        i_window->update_all();
    }
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    Fl_Button::default_style->box = FL_PLASTIC_BOX;

    create_the_forms();

    // Add tiled image as window background
    Fl_Image *tile = Fl_Image::read_xpm(0, tile_xpm);
    form->image(tile);
    form->align(FL_ALIGN_TILED);

    char buf[256];
    strcpy(buf, argv[0]);
    fl_file_setext(buf,".menu");
    const char *fname = buf;
    int i = 0;
    if (!Fl::args(argc,argv,i) || i < argc-1)
        Fl::fatal("Usage: %s <switches> <menufile>\n%s",Fl::help);
    if (i < argc) fname = argv[i];
    if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname);
    strcpy(buf,fname);
    const char *c = fl_file_filename(buf);
    if (c > buf) {buf[c-buf] = 0; chdir(buf);}
    push_menu("@main");
    form->show(argc,argv);
    Fl::run();

    return 0;
}
Exemplo n.º 3
0
void saveSchemeAs()
{
    const char *schemeName = fl_input(_("Save scheme as:"), _("New scheme"));
    if (schemeName) 
    {
	Fl_String pathScheme; 
	pathScheme.printf("%s/.ede/schemes/%s.scheme", fl_homedir().c_str(), schemeName);
	saveScheme(pathScheme);
	schemeListBox->add(fl_file_filename(pathScheme));
    }	
}
Exemplo n.º 4
0
int create_new_dnd_icon(int x, int y, char *filename) //create icon from dnd data
{
    if (filename) 
    {
        char config[FL_PATH_MAX];
	const char *name = fl_file_filename(filename);
	snprintf(config, sizeof(config)-1, "%s/.ede/desktop/%s.desktop", getenv("HOME"), name);
	
        if (!fl_file_exists((char*)config))
        {
	    char val[FL_PATH_MAX];
	    Fl_Config checkconf(filename, true, false);
	
	    if(!checkconf.get("Desktop Entry", "Exec", val, 0, sizeof(val))) 
	    {	
    	        Fl_Config cfg(config);
		cfg.set_section("Desktop Entry");
		
		checkconf.get("Desktop Entry", "Icon", val, "no icon", sizeof(val)); 
        	cfg.write("Icon", val);
        	cfg.write("X", x);
        	cfg.write("Y", y);
        	cfg.write(get_localized_string(), get_localized_name(checkconf));

                checkconf.get("Desktop Entry", "Exec", val, filename, sizeof(val));
        	cfg.write("Exec", val);
        	cfg.flush();
	    }
	    else
	    {
	        Fl_Config cfg(config);
    	        cfg.set_section("Desktop Entry");
        	cfg.write("Icon", "no icon");
        	cfg.write("X", x);
        	cfg.write("Y", y);
        	cfg.write(get_localized_string(), name);
                cfg.write("Exec", filename);
        	cfg.flush();
	    }	
	    desktop->begin();
            Icon *icon = new Icon((char*)config);
    	    icon->show();
    	    desktop->end();
    	    desktop->redraw();
	}
	else 
	{
	    fl_alert(_("The icon with the same name already exists."));
	}  
    }  
    return 0;
}
Exemplo n.º 5
0
void fillItems() 
{
    char *file;

    Fl_String path(fl_homedir()); 
    path += "/.ede/schemes";

    dirent **files;
    int count = fl_filename_list(path, &files);

    if (count > 0)
    {
        new Fl_Item("Active");
	schemeListBox->value("Active");


        for(int n=0; n<count; n++)
        {
            file = files[n]->d_name;
            if( strcmp(file, ".") && strcmp(file, ".."))
            {
		char *filename = fl_strdup_printf("%s/%s", (char*)path, file);
                if (!fl_is_dir(filename) &&
                    fl_file_match(file, "*.scheme") && strcmp(file, "Active.scheme")!=0) 
		{
                    new Fl_Item(strdup(fl_file_filename(filename)));
                }
		delete [] filename;
            }
            free(files[n]);
        }
        free(files);
	getSchemeColors(); //we apply first scheme - active.scheme
    }

}
Exemplo n.º 6
0
void
process_find_messages(int, void*)
{
    static char *buffer, line[256];
    static int nothing_found;
    char *filename;

    buffer = line;

    while (1)
    {
        if (!read (pfd[0], buffer, 1))
            return;
        if (buffer[0] == '\n')
        {
            buffer[1] = (char) 0;
            if (strncmp(line, "GLOB DONE=", strlen ("GLOB DONE=")) == 0)
            {
                fl_message(_("Search finished."));
                Gpid = 0;
                if (nothing_found)
                    fl_message(_("Nothing found."));
                if (findCount)
                {
                    char mess[128];
                    snprintf(mess, 127, _("Found %d files."), findCount);
                    if (findCount >= fileLimit)
                        fl_message(_("Interrupted because maximum limit exceded."));
                    fl_alert(mess);
                }
                return;
            }

            if ((strncmp (line, "PID=", 4) == 0))
            {
                Gpid = atoi (line + 4);
                //printf("Glob PID=%d\n",Gpid);
                //	      fflush(NULL);
                nothing_found = TRUE;
                return;
            }
            if (cancelled)
                return;

            if (line[0] == '/')  /* strstr for : and strtok and send to cuenta */
            {
                if (findCount >= fileLimit)
                    abort_glob1();
                else
                {
                    char *path, *linecount = NULL, *textos[6], cuenta[32],
                        sizeF[64], permF[16];
                    struct stat st;
                    int *data;

                    path = line;
                    char *ptr = path;
                    while(*ptr) { if(*ptr=='\n') *ptr='\0'; ptr++; }
                    statusLine->copy_label(fl_trim(path));
                    statusLine->redraw();

                    if (strstr(path, ":"))
                    {
                        path = strtok(path, ":");
                        linecount = strtok (NULL, ":");
                        if (strcmp(linecount, "0") == 0)
                        {
                            linecount = NULL;
                            return;
                        }
                    }

                    findCount++;
                    data=(int *)malloc(3*sizeof(int));
                    data[0]=findCount;
                    data[1]=data[2]=0;

                    if (linecount)
                        snprintf(cuenta, sizeof(cuenta)-1, "%d (%s %s)", findCount, linecount, "lines");
                    else
                        snprintf (cuenta, sizeof(cuenta)-1, "%d", findCount);

                    textos[0] = cuenta;
                    textos[1] = filename = (char*)fl_file_filename(path);
                    textos[2] = path;

                    Fl_Image *resultImage=0;

                    if (lstat (path, &st) == 0)
                    {
                        data[1]=st.st_size;
                        data[2]=st.st_ctime;

                        snprintf (sizeF, sizeof(sizeF)-1,"%ld", st.st_size);
                        snprintf (permF, sizeof(permF)-1,"0%o", st.st_mode & 07777);
                        textos[3] = sizeF;
                        textos[4] = ctime (&(st.st_ctime));
                        textos[5] = permF;

                        if (S_ISREG (st.st_mode))
                        {
                            resultImage = &page_pix;
                        }
                        if ((st.st_mode & 0100) || (st.st_mode & 010)
                            || (st.st_mode & 01))
                        {
                            resultImage = &exe_pix;
                        }
                        if (st.st_mode & 04000)
                        {
                            resultImage = &sexe_pix;
                        }
                        if (S_ISDIR (st.st_mode))
                        {
                            resultImage = &dir_close_pix;
                        }
                        if (S_ISCHR (st.st_mode))
                        {
                            resultImage = &char_dev_pix;
                        }
                        if (S_ISBLK (st.st_mode))
                        {
                            resultImage = &block_dev_pix;
                        }
                        if (S_ISFIFO (st.st_mode))
                        {
                            resultImage = &fifo_pix;
                        }
                        if (S_ISLNK (st.st_mode))
                        {
                            resultImage = &page_lnk_pix;
                        }
                        if (S_ISSOCK (st.st_mode))
                        {
                            resultImage = &socket_pix;
                        }
                    }
                    else
                    {
                        textos[2] = textos[3] = textos[4] = "-";
                    }
                    {
                                 // leave just directory
                        *(strrchr(path,'/'))=0;
                        if (!strlen(path))
                            textos[2]="/";
                        char output[FL_PATH_MAX];
                        snprintf(output, sizeof(output)-1, "%s/%s", textos[2], textos[1]);
                        searchList->begin();
                        Fl_ListView_Item *resultItem = new Fl_ListView_Item();

                        // Copy labels, so item destructor knows to de-allocate them
                        resultItem->copy_label(0, output);
                        resultItem->copy_label(1, textos[3]);
                        resultItem->copy_label(2, textos[4]);
                        resultItem->copy_label(3, textos[5]);

                        resultItem->image(resultImage);
                        searchList->end();
                        searchList->relayout();
                        searchList->redraw();
                    }
                }
            }
            //else {}
            nothing_found = FALSE;
            buffer = line;
            return;  ;           /* continue here causes main loop blocking */
        }
        buffer++;
    }
    return;
}
Exemplo n.º 7
0
void WindowManager::init_internals(int argc, char* argv[])
{
	DBG("starting window manager");

	fl_open_display();
	XSetErrorHandler(xerror_handler);
	XShapeQueryExtension(fl_display, &XShapeEventBase, &XShapeErrorBase);

	wm_area.set(0, 0/*22*/, Fl::w(), Fl::h()/*-22*/);

	// TODO: make this part of class
	program_name = fl_file_filename(argv[0]);

	int i;
	if(Fl::args(argc, argv, i, arg) < argc)
		Fl::error("options are:\n"
			" -d[isplay] host:#.#\tX display & screen to use\n"
			" -v[isual] #\t\tvisual to use\n"
			" -g[eometry] WxH+X+Y\tlimits windows to this area\n"
			" -x\t\t\tmenu says Exit instead of logout\n"
			" -bg color\t\tFrame color\n"
			" -fg color\t\tLabel color\n"
			" -bg2 color\t\tText field color\n"
			" -cfg color\t\tCursor color\n"
			" -cbg color\t\tCursor outline color" );

	// Init started
	is_init = false;

	Fl::add_handler(wm_event_handler);
	
	// intern atoms
	init_atoms();
	read_configuration();
	read_xset_configuration();
	
	// Set XID now
	show();

	set_default_cursor();
	ICCCM::set_iconsizes(this);
	MWM::set_motif_info(this);
	register_protocols(fl_xid(this));
	Grab_Hotkeys(this);

	XSync(fl_display, 0);

	init_desktops(this);

	//Init done
	is_init = true;

	// find all the windows and create a Frame for each:
	Frame *f=0;
	unsigned int n;
	Window w1, w2, *wins;
	XWindowAttributes attr;
	XQueryTree(fl_display, fl_xid(this), &w1, &w2, &wins, &n);
	for (i = 0; i < (int)n; ++i)
	{
		XGetWindowAttributes(fl_display, wins[i], &attr);
		if(attr.override_redirect) continue;
		if(!attr.map_state)
		{
			if(getIntProperty(wins[i], _XA_WM_STATE, _XA_WM_STATE, 0) != IconicState)
				continue;
		}
		f = new Frame(wins[i], &attr);
	}
	XFree((void *)wins);

	// Activate last one
	for(uint n=0; n<map_order.size(); n++)
	{
		Frame *f = map_order[n];
		if(f->desktop()==Desktop::current())
		{
			f->activate();
			f->raise();
			break;
		}
	}

	update_workarea(true);
	is_running = true;
}