Example #1
0
void redecorateVolumes() {
	ASVolumeCanvasPlacement placement;
	int width, height;
	
	placement.vertical = get_flags(Config->flags, ASMOUNT_Vertical);
	placement.tileWidth = DEFAULT_TILE_WIDTH;
	placement.tileHeight = DEFAULT_TILE_HEIGHT;
  placement.currPos = 0;
	
	iterate_asbidirlist (AppState.volumes, redecorateVolume, &placement, NULL, False);

	XMapSubwindows (dpy, AppState.mainCanvas->w);

  width = placement.tileWidth;
  height = placement.tileHeight;
	
	if (placement.vertical)
		height = placement.currPos;
	else 
		width = placement.currPos;

	setHints (width, height);
	/* setHints must happen first */
	show_progress ( "resizing main canvas to %dx%d", width, height);	
	resize_canvas (AppState.mainCanvas, width, height);
	ASSync (False);
}
Example #2
0
ASVolume*
position2Volume( int x, int y )
{
	ASVolumeCanvasAtPos adata;
	adata.x = x;
	adata.y = y;
	adata.v = NULL;

	iterate_asbidirlist (AppState.volumes, volumeAtPos, &adata, NULL, False);
  return adata.v;
}
Example #3
0
ASVolume* 
name2Volume (const char *name)
{
	if (name) {
		ASVolumeByName adata;
		adata.name = name;
		adata.v = NULL;

		iterate_asbidirlist (AppState.volumes, volumeByName, &adata, NULL, False);
  	return adata.v;
  }
  return NULL;
}
char *
asgtk_gradient_get_xml( ASGtkGradient *ge, char **mini )
{
	char *xml = NULL ; 
	if( ge->points->count > 0 ) 
	{
		char *offsets = NULL ; 
		char *colors = NULL ; 
		ASGradientPoint *first, *last ; 
		Bool add_first = False, add_last = False ; 
		int width = 0, height = 0 ;
		int pos = 0, colors_len, offsets_len; 
	
		first = LIST_START(ge->points)->data ; 
		last  = LIST_END(ge->points)->data ; 
		
		add_first = ( first->offset > 0. );
		add_last  = ( last->offset < 1. ); 

		iterate_asbidirlist( ge->points, collect_gradient_offsets_str, &offsets, NULL, False );	  
		iterate_asbidirlist( ge->points, collect_gradient_colors_str, &colors, NULL, False );	  

		colors_len = strlen(colors);
		offsets_len = strlen(offsets );
			
		if( GTK_WIDGET_STATE( ge->width_entry) != GTK_STATE_INSENSITIVE ) 
			width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->width_entry));
	
		if( GTK_WIDGET_STATE( ge->height_entry) != GTK_STATE_INSENSITIVE ) 
			height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->height_entry));

		xml = safemalloc( 64 + 10+10+strlen(colors) + 4 + 4 + strlen(offsets) + 32 + 32 + 2 +1 );
		strcpy( xml, "<gradient colors=\"" );
		pos = 18 ; 
		if( add_first ) 
		{	
			strcpy( &xml[pos], "#FF000000 " );
			pos +=10 ;
		}
		strcpy( &xml[pos], colors );
		pos+=colors_len; 
		if( add_last ) 
		{	
			strcpy( &xml[pos], " #FF000000" );
			pos +=10 ;
		}
		strcpy( &xml[pos], "\" offsets=\"" );				
		pos += 11 ;

		if( add_first ) 
		{	
			strcpy( &xml[pos], "0.0 " );
			pos +=4 ;
		}
		strcpy( &xml[pos], offsets );
		pos+=offsets_len; 
		if( add_last ) 
		{	
			strcpy( &xml[pos], " 1.0" );
			pos +=4 ;
		}
		
		if( mini ) 
		{
			*mini = safemalloc(pos+64);
			sprintf( *mini, "%s\" width=\"$minipixmap.width\" height=\"$minipixmap.height\"/>", xml ); 	
		}	 

		strcpy( &xml[pos], "\" width=\"" );				   
		pos += 9 ; 
		
		if( width > 0 ) 
			sprintf( &xml[pos], "%d", width );
		else
			strcpy( &xml[pos], "$xroot.width" );
	    while( xml[pos] != '\0' ) ++pos; 
		
		strcpy( &xml[pos], "\" height=\"" );				   
		pos += 10 ; 
		
		/* no more then 32 bytes : */
		if( height > 0 ) 
			sprintf( &xml[pos], "%d", height );
		else
			strcpy( &xml[pos], "$xroot.height" );
	    while( xml[pos] != '\0' ) ++pos; 
		
		/* no more then 2 bytes : */
		sprintf( &xml[pos], "\"/>" );
	}		   
	return xml;
}
static void
refresh_gradient_preview(ASGtkGradient *ge)
{
	int width = get_screen_width(NULL);
	int height = get_screen_height(NULL); 
	struct ASGradient       gradient ; 
	struct ASImageListEntry *entry; 
	ARGB32 *color ;
	double *offset ;
	
	if( ge->points->count <= 0 ) 
		return ;

	if( GTK_WIDGET_STATE( ge->width_entry) != GTK_STATE_INSENSITIVE ) 
		if( (width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->width_entry))) == 0 )
			width = get_screen_width(NULL) ; 
		
	if( GTK_WIDGET_STATE( ge->height_entry) != GTK_STATE_INSENSITIVE ) 
		if( (height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->height_entry))) == 0 )
			height = get_screen_height(NULL) ; 
		
	entry = create_asimage_list_entry();
	/* rendering gradient preview : */

	gradient.npoints = 0 ;
	gradient.type = ge->type ; 

	gradient.offset = offset = safemalloc((ge->points->count+2) * sizeof(double) );
	gradient.color  = color = safemalloc((ge->points->count+2) * sizeof(ARGB32) );

	++gradient.offset ;
	++gradient.color ;
	iterate_asbidirlist( ge->points, add_point_to_gradient, &gradient, NULL, False );	

	if( gradient.offset[0] > 0. ) 
	{
		--gradient.offset ;
		--gradient.color ;
		gradient.offset[0] = 0. ; 
		gradient.color[0] = DEFAULT_COLOR ;  /* black */ 
		++gradient.npoints;
	}	 
	if( gradient.offset[gradient.npoints-1] < 1. ) 
	{
		gradient.offset[gradient.npoints] = 1. ; 
		gradient.color[gradient.npoints] = DEFAULT_COLOR ;  /* black */ 
		++gradient.npoints;
	}	 
		

	entry->preview = make_gradient(get_screen_visual(NULL), &gradient, width, height, SCL_DO_ALL, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT);

	free( offset );
	free( color );
			   
	/* applying gradient preview : */
	if( entry->preview ) 
		asgtk_image_view_set_entry ( ge->image_view, entry);
	else
		asgtk_image_view_set_entry ( ge->image_view, NULL);
	
	unref_asimage_list_entry( entry );
	
}
static void 
asgtk_gradient_update_color_list( ASGtkGradient *ge )
{
	gtk_list_store_clear( ge->point_list_model );
	iterate_asbidirlist( ge->points, add_point_to_color_list, ge, NULL, False );
}
Example #7
0
void
DispatchEvent (ASEvent * event)
{
	ASVolume *event_volume = NULL;
  SHOW_EVENT_TRACE(event);

	if( (event->eclass & ASE_POINTER_EVENTS) != 0 ) {
    XKeyEvent *xk = &(event->x.xkey);
		int pointer_root_x = xk->x_root;
		int pointer_root_y = xk->y_root;
		event_volume = position2Volume (pointer_root_x,// - (int)AppState.mainCanvas->bw,
                                    pointer_root_y);// - (int)AppState.mainCanvas->bw);
	
		LOCAL_DEBUG_OUT ("event_volume = %p, name = \"%s\"", event_volume, event_volume ? event_volume->name : "(none)");
		if(is_balloon_click( &(event->x) ) )
		{
			withdraw_balloon(NULL);
			return;
		}
		if (event_volume)
			event->context = check_astbar_point( event_volume->contents, pointer_root_x, pointer_root_y );
	}

  event->client = NULL ;

  switch (event->x.type)  {
		case ConfigureNotify:
				{
	        ASFlagType changes = handle_canvas_config (AppState.mainCanvas);
          if( changes != 0 )
					{
						volumeWindowMoved_AuxData aux;
						aux.backgroundChanged = False;
	          set_root_clip_area( AppState.mainCanvas );
						iterate_asbidirlist (AppState.volumes, volumeWindowMoved, &aux, NULL, False);
					}
					show_activity ("changes = 0x%lx", changes);
				}
        break;
    case KeyPress :
         return ;
    case KeyRelease :
				return ;
    case ButtonPress:
			  pressButton (event_volume, event);				
				return;
    case ButtonRelease:
LOCAL_DEBUG_OUT( "state(0x%X)->state&ButtonAnyMask(0x%X)", event->x.xbutton.state, event->x.xbutton.state&ButtonAnyMask );
        if( (event->x.xbutton.state&ButtonAnyMask) == (Button1Mask<<(event->x.xbutton.button-Button1)) )
					releaseButton();
			return ;
    case EnterNotify :
			if( event->x.xcrossing.window == Scr.Root )
				withdraw_active_balloon();
			return ;
    case LeaveNotify :
    case MotionNotify :
			{
				static Bool root_pointer_moved = True ;
				if( event->x.type == MotionNotify ) 
					root_pointer_moved = True ; 
    	  if (event_volume)	{	
        	on_astbar_pointer_action (event_volume->contents, event->context, (event->x.type == LeaveNotify), root_pointer_moved);
					root_pointer_moved = False ; 
				}
				return ;
			}
    case ClientMessage:
      LOCAL_DEBUG_OUT("ClientMessage(\"%s\",format = %d, data=(%8.8lX,%8.8lX,%8.8lX,%8.8lX,%8.8lX)", XGetAtomName( dpy, event->x.xclient.message_type ), event->x.xclient.format, event->x.xclient.data.l[0], event->x.xclient.data.l[1], event->x.xclient.data.l[2], event->x.xclient.data.l[3], event->x.xclient.data.l[4]);
      if ( event->x.xclient.format == 32 &&
           event->x.xclient.data.l[0] == _XA_WM_DELETE_WINDOW )
			{
	      DeadPipe(0);
      }
			return ;
	  case PropertyNotify:
    	if( event->x.xproperty.atom == _XA_NET_WM_STATE )
      {
				LOCAL_DEBUG_OUT( "_XA_NET_WM_STATE updated!%s","");
				return;
			}
			handle_wmprop_event (Scr.wmprops, &(event->x));
      if( event->x.xproperty.atom == _AS_BACKGROUND )
      {
				volumeWindowMoved_AuxData aux;
				aux.backgroundChanged = True;

				LOCAL_DEBUG_OUT( "root background updated!%s","");
        safe_asimage_destroy( Scr.RootImage );
        Scr.RootImage = NULL ;
				
				iterate_asbidirlist (AppState.volumes, volumeWindowMoved, &aux, NULL, False);
      }else if( event->x.xproperty.atom == _AS_STYLE )
			{
				volumeWindowMoved_AuxData aux;
				aux.backgroundChanged = False;

				LOCAL_DEBUG_OUT( "AS Styles updated!%s","");
				mystyle_list_destroy_all(&(Scr.Look.styles_list));
				LoadColorScheme();
				SetASMountLook();
	/* now we need to update everything */
				redecorateVolumes ();	
				iterate_asbidirlist (AppState.volumes, volumeWindowMoved, &aux, NULL, False);
			}
			return ;	
		default:
#ifdef XSHMIMAGE
			LOCAL_DEBUG_OUT( "XSHMIMAGE> EVENT : completion_type = %d, event->type = %d ", Scr.ShmCompletionEventType, event->x.type );
			if( event->x.type == Scr.ShmCompletionEventType )
				handle_ShmCompletion( event );
#endif /* SHAPE */
      return;
	}
  /*update_pager_shape();*/
}