示例#1
0
XImlib2Background::XImlib2Background(AbstractContainer * c, AbstractConfig * con): TimerControl(), 
                                                    container(c), config(con),delay(0), mode(0),  save(NULL), show(NULL),
						    srctime(0), images(""), directory(""), OneShot(false)
{
     cmap = imlib_context_get_colormap();
     visual = imlib_context_get_visual();
     
     DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(config);
    
     if( !show) {
		 show = &data[0];
	     	 save = &data[1];
     }
	
     int d = dConfig->getDelayBackground();
     directory = dConfig->getSourceBackground();

	
     if(d == 0 || directory == "None"){
	     OneShot = true;
     }
     
     srand( (unsigned)time(0) );
     
     if(OneShot){
		SetOneImage();
     }else{
		ScanImages();
		SetDelay( d );
     }
	
}
示例#2
0
void XImlib2Image::configure()
{
    x = iconParent->getX();
    y = iconParent->getY();

    DesktopIconConfig * dIconConfig =
        dynamic_cast<DesktopIconConfig *>(iconConfig);
	
    DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(config);

    transparency = dConfig->getTransparency();

    width = dIconConfig->getWidth();
    height = dIconConfig->getHeight();
    
    glowing = false;
    glowChange = true;

    colorMod = imlib_create_color_modifier();
    
    fillStyle = dIconConfig->getFillStyle();
    
    XDesktopContainer * xContainer =
		    dynamic_cast<XDesktopContainer *>(container);  
	
    rootWindow = xContainer->getRootWindow();
    widthOfScreen = xContainer->widthOfScreen();
    heightOfScreen = xContainer->heightOfScreen();
    display = xContainer->getDisplay();
    visual = imlib_context_get_visual();
    cmap = imlib_context_get_colormap();
    screen = DefaultScreen(display);
    depth =  DefaultDepth(display,screen);
}
示例#3
0
void XDesktopContainer::saveState()
{
    //save each of the icons
    for(unsigned int i = 0; i < iconList.size(); i++)
        saveIcon(iconList[i]);

    //general config saves
    
    DesktopConfig * dConfig = dynamic_cast<DesktopConfig *>(config);

    dConfig->saveLockState(locked);
}
示例#4
0
void XDesktopContainer::exeCurrentAction(XIcon * icon)
{
			
	if (actionConfig->getReload()->isOccuring(currentAction)){
		app->restartIdesk();
	}
    
    if (actionConfig->getLock()->isOccuring(currentAction))
    {
        toggleLock();
        DesktopConfig * dConfig = dynamic_cast<DesktopConfig *>(config);
        dConfig->saveLockState(locked); 
    }
    
    if (icon) //make sure icon is not NULL
    {
        if (actionConfig->getDrag()->isOccuring(currentAction)
            && !isLocked()
            && !icon->isDragging() ) //only start drag if not already occuring
            icon->dragButtonPress(event);
        else if (actionConfig->getEndDrag()->isOccuring(currentAction))
            icon->dragButtonRelease(event);

        for (int i = 0; i < icon->getCommandArray().size() &&
                        i < actionConfig->getExecuteActions().size();
                        i++)
		if (actionConfig->getExecuteAction(i)->isOccuring(currentAction)){
#ifdef HAVE_STARTUP_NOTIFICATION
			if (sn_display != NULL)
			{
			  sn_context = sn_launcher_context_new (sn_display, DefaultScreen (display));
			  if ((sn_context != NULL) && !sn_launcher_context_get_initiated (sn_context))
			  {
			   sn_launcher_context_set_name (sn_context, icon->getCommand(i).c_str());
			   sn_launcher_context_set_description (sn_context, icon->getCommand(i).c_str());
		           sn_launcher_context_set_binary_name (sn_context, icon->getCommand(i).c_str());
                           sn_launcher_context_set_icon_name(sn_context, icon->getCommand(i).c_str());
			   
			   sn_launcher_context_initiate (sn_context,
					   icon->getCommand(i).c_str(),
					   icon->getCommand(i).c_str(),	      
					   event.xproperty.time);
			  }
			}
#endif  /*HAVE_STARTUP_NOTIFICATION */
			runCommand(icon->getCommand(i));
		}
    }

}
示例#5
0
void XDesktopContainer::configure()
{    
    //get the user's config file
    string ideskrcFile = getenv("HOME");
    ideskrcFile += "/.ideskrc";

    Database db(ideskrcFile);
    config = new DesktopConfig(db, ideskrcFile);
    
    DesktopConfig * dConfig = dynamic_cast<DesktopConfig *>(config);
    
    if(config->numIcons() == 0){
	    dConfig->loadDefaultIcons();
    }

    locked = dConfig->getLocked();
    clickDelay = dConfig->getClickSpeed();

    snapState = dConfig->getSnapState();
    snapShadow = dConfig->getSnapShadow();
    snapWidth = dConfig->getSnapWidth();
    snapHeight = dConfig->getSnapHeight();

    actionConfig = new ActionConfig(db, ideskrcFile);
}   
示例#6
0
void XImlib2Background::SetOneImage()
{
	Imlib_Image image = None;
	DesktopConfig * dConfig =
			dynamic_cast<DesktopConfig *>(config);
	
	string file = dConfig->getFileBackground();
	
	if(file != "None"){
		image = imlib_load_image(file.c_str());
	}
	
	   if(image)
	    SetMultiImage(image);
}
示例#7
0
bool Desktop::save_icons_positions(void) {
	DesktopConfig pos;
	DesktopIcon   *o;
	char          *base;

	for(int i = 0; i < children(); i++) {
		if(NOT_SELECTABLE(child(i))) continue;

		o = (DesktopIcon*)child(i);
		base = get_basename(o->get_path());
		pos.set(base, "X", o->x());
		pos.set(base, "Y", o->y());
	}
	
	return pos.save(ICONS_POS_FILE);
}
示例#8
0
void XImlib2Caption::createWindow()
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);

    DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(XImlib2Image::config);

    XSetWindowAttributes attr;
    attr.override_redirect = True;
    attr.cursor = XCreateFontCursor(xContainer->getDisplay(), dConfig->getCursorOver());
    
    attr.event_mask = SubstructureRedirectMask |
                      SubstructureNotifyMask   |
                      ButtonPressMask          |
                      ButtonReleaseMask        |
                      PointerMotionMask        |
                      PropertyChangeMask       |
                      ExposureMask;

    XftTextExtentsUtf8( xContainer->getDisplay(), font, (XftChar8*)text.c_str(), text.length(), &fontInfo );

    // fix window extents so shadow text is not cut
    // TODO: fix window extents if shadow is negative:
    // Would have to edit x and y of the window
    width = fontInfo.width + FONTSHIFT;
    height = font->height;

    if (shadowOn)
    {
        width += shadowX > 0 ? shadowX : 0;
        height += shadowY > 0 ? shadowY : 0;
    }
    window = XCreateWindow( xContainer->getDisplay(),
                            xContainer->getRootWindow(),
                            0,
                            0,
                            width,
                            height,
                            0,
                            CopyFromParent,
                            CopyFromParent,
                            CopyFromParent,
			    CWOverrideRedirect|CWEventMask|CWCursor,
                            &attr );
}
示例#9
0
void Desktop::read_desktop_folder(const char *dpath) {
	E_RETURN_IF_FAIL(dpath != NULL);
	String path;

	DIR *dir = opendir(dpath);
	E_RETURN_IF_FAIL(dir != NULL);
	
	DesktopConfig pos;
	pos.load(ICONS_POS_FILE);

	dirent *d;
	while((d = readdir(dir)) != NULL) {
		if(DOT_OR_DOTDOT(d->d_name))
			continue;

		if(d->d_type > 0) {
			if(d->d_type != DT_REG && d->d_type != DT_LNK && d->d_type != DT_DIR)
				continue;

			path = dpath;
			path += E_DIR_SEPARATOR;
			path += d->d_name;
		} else {
			/* 
			 * If we got here, it means d_type isn't set and we must do it via file_test() which could be much slower.
			 * By POSIX standard, only d_name must be set, but many modern *nixes set all dirent members correctly. Except Slackware ;)
			 */
			path = dpath;
			path += E_DIR_SEPARATOR;
			path += d->d_name;

			if(!(file_test(path.c_str(), FILE_TEST_IS_REGULAR) ||
			     file_test(path.c_str(), FILE_TEST_IS_DIR)     ||
			     file_test(path.c_str(), FILE_TEST_IS_SYMLINK)))
				continue;
		}

		DesktopIcon *o = read_desktop_file(path.c_str(), (const char*)d->d_name, &pos);
		if(o) add(o);
	}

	closedir(dir);
}
示例#10
0
void XImlib2Image::createWindow()
{	
    createPicture();

    DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(config);
    

    XSetWindowAttributes attr;
    attr.background_pixmap = ParentRelative;
    attr.backing_store = Always;
    attr.override_redirect = True;
    attr.save_under = True;
    attr.cursor = XCreateFontCursor(display, dConfig->getCursorOver());
  
    attr.event_mask = SubstructureRedirectMask |
                      SubstructureNotifyMask   |
                      ButtonPressMask          |
                      ButtonReleaseMask        |
                      PointerMotionMask        |
                      EnterWindowMask          |
                      PropertyChangeMask       |
                      LeaveWindowMask           |
                      ExposureMask;
    
    window = XCreateWindow( display,
                            rootWindow,
                            0,
                            0,
                            width,
                            height,
                            0,
                            depth,
                            CopyFromParent,
                            CopyFromParent,
			    CWSaveUnder|CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask| CWCursor,
                            &attr );  
    shapeWindow();
}
示例#11
0
void XImlib2Background::SetMultiImage(Imlib_Image image)
{
      Pixmap pmap = None, mask = None;
      GC gc;
      XGCValues gcv;
      XColor xcolor;
      int w, h, x, y, widthOfScreen, heightOfScreen, screen, depth;
      char *bgcolor = NULL;
      Colormap colormap;
      Display* display;
      Window rootWindow;
      string mode;
      
      DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(config);
       
      XDesktopContainer * xContainer =
                    dynamic_cast<XDesktopContainer *>(container);
      
      display = xContainer->getDisplay();
      rootWindow = xContainer->getRootWindow();	
      screen = DefaultScreen(display);
      depth =  DefaultDepth(display, screen);
      colormap = DefaultColormap(display, screen);
      widthOfScreen = xContainer->widthOfScreen();
      heightOfScreen = xContainer->heightOfScreen();
      mode = dConfig->getModeBackground();
      
      pixmap = XCreatePixmap(display, rootWindow , widthOfScreen, heightOfScreen, depth);
      
      string color = dConfig->getColorBackground();
      
      if(color != "None"){
      	gcv.foreground = gcv.background = BlackPixel(display, screen);
      
      	bgcolor = (char*)dConfig->getColorBackground().c_str();
      
      	if (bgcolor && XParseColor(display, colormap , bgcolor, &xcolor) && XAllocColor(display,  colormap, &xcolor)) {
	      gcv.foreground = gcv.background = xcolor.pixel;
      	  }
        }
      
      gc = XCreateGC(display, pixmap, (GCForeground | GCBackground), &gcv);
      
        if(image){
		
		imlib_context_set_image(image);
		
		if (mode == "SCALE") {
			w = widthOfScreen;
			h = heightOfScreen;
		} else if (mode == "MIRROR") {
			w = imlib_image_get_width() * 2;
			h = imlib_image_get_height() * 2;
		} else if (mode == "FIT") {
			double x_ratio, y_ratio;
			x_ratio = ((double) widthOfScreen) / ((double)  imlib_image_get_width());
			y_ratio = ((double) heightOfScreen) / ((double) imlib_image_get_height());
			if (x_ratio > y_ratio) {
				x_ratio = y_ratio;
			}
			w = (int) (imlib_image_get_width() * x_ratio);
			h = (int) (imlib_image_get_height() * x_ratio);
		} else {
			w = imlib_image_get_width();
			h = imlib_image_get_height();
		}
      	
		if (mode == "SCALE") {
			XFillRectangle(display, pixmap, gc, 0, 0, w, h);
		}
		if (mode == "CENTER" || mode == "FIT") {
			XFillRectangle(display, pixmap, gc, 0, 0, widthOfScreen, heightOfScreen);
			x = (widthOfScreen - w) >> 1;
			y = (heightOfScreen - h) >> 1;
		} else {