static void
thinice_style_draw_box_gap(GtkStyle * style,
             cairo_t * cr,
             GtkStateType state_type,
             GtkShadowType shadow_type,
             GtkWidget * widget,
             const gchar *detail,
             gint x,
             gint y,
             gint width,
             gint height,
             GtkPositionType gap_side,
             gint gap_x,
             gint gap_width)
{
    CHECK_ARGS

    gtk_style_apply_default_background(style, cr,
            gtk_widget_get_window (widget),
            state_type,
            x, y, width, height);
    thinice_style_draw_shadow_gap (style, cr, state_type, shadow_type,
            widget, detail, x, y, width, height,
            gap_side, gap_x, gap_width);
}
Example #2
0
static VALUE
style_apply_default_background(VALUE self, VALUE gdkwindow, VALUE set_bg, VALUE state_type, VALUE area, VALUE x, VALUE y, VALUE width, VALUE height)
{
    gtk_style_apply_default_background(_SELF(self), 
                                       GDK_WINDOW(RVAL2GOBJ(gdkwindow)),
                                       RVAL2CBOOL(set_bg), RVAL2STATE(state_type),
                                       RVAL2REC(area), 
                                       NUM2INT(x), NUM2INT(y), 
                                       NUM2INT(width), NUM2INT(height));
    return self;
}
Example #3
0
void wxAuiGtkTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect)
{
    wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
    GdkWindow* window = impldc->GetGDKWindow();

    gtk_style_apply_default_background(gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget()),
                                       window,
                                       true,
                                       GTK_STATE_NORMAL,
                                       NULL,
                                       rect.x, rect.y, rect.width, rect.height);
}
static void
thinice_style_draw_extension(DRAW_ARGS, GtkPositionType gap_side)
{
	ThiniceStyle *thinice_style = THINICE_STYLE (style);

	CairoColor *background, *light, *dark;

	CHECK_ARGS

	background = &thinice_style->color_cube.bg[state_type];
	light = &thinice_style->color_cube.light[state_type];
	dark = &thinice_style->color_cube.dark[state_type];

        gtk_style_apply_default_background(style, cr,
                        gtk_widget_get_window (widget),
                        state_type, x, y, width, height);

	cairo_rectangle (cr, x, y, width, height);
	cairo_clip (cr);

	switch(gap_side)
	{
		case GTK_POS_TOP:
			y--;
			height++;
		break;

		case GTK_POS_LEFT:
			x--;
			width++;
		break;

		case GTK_POS_BOTTOM:
			height++;
		break;

		case GTK_POS_RIGHT:
			width++;
		break;
	}

	ge_cairo_simple_border (cr, light, dark, x, y, width, height, FALSE);
}
/* Draw text Entry */
void cl_draw_entry (GtkStyle *style, GdkWindow *window,
                        GtkStateType state_type, GtkShadowType shadow_type,
                        GdkRectangle *area,
                        GtkWidget *widget, const gchar *detail,
                        gint x, gint y, gint width, gint height)
{
	CLRectangle r;
	gboolean has_focus = GTK_WIDGET_HAS_FOCUS(widget);
	GdkGC *bg_gc = cl_get_window_bg_gc(widget);
	
	gdk_draw_rectangle (window, bg_gc, FALSE, x, y, width-1, height-1);

	gtk_style_apply_default_background (style, window, TRUE, state_type,
										area, x+1, y+1, width-2, height-2);

	
	cl_rectangle_set_entry (&r, style, state_type,
							CL_CORNER_ROUND, CL_CORNER_ROUND,
							CL_CORNER_ROUND, CL_CORNER_ROUND,
							has_focus);
	
	/* Draw "sunken" look when border thickness is more than 2 pixels. */
	if (style->xthickness > 2 && style->ythickness > 2)
	{
		cl_draw_inset (style, window, widget, area, x, y, width, height,
		               CL_CORNER_ROUND, CL_CORNER_ROUND,
		               CL_CORNER_ROUND, CL_CORNER_ROUND);
	
		x++;
		y++;
		width-=2;
		height-=2;
	}
	
	cl_rectangle_set_clip_rectangle (&r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
	cl_draw_shadow (window, widget, style, x, y, width, height, &r); 
	cl_rectangle_reset_clip_rectangle (&r);
}
static void
thinice_style_draw_box(GtkStyle * style,
         cairo_t *cr,
         GtkStateType state_type,
         GtkShadowType shadow_type,
         GtkWidget * widget,
         const gchar *detail,
         gint x,
         gint y,
         gint width,
         gint height)
{
	ThiniceStyle *thinice_style = THINICE_STYLE (style);
	gboolean draw_border = TRUE;

	/***********************************************/
	/* GTK Sanity Checks                           */
	/***********************************************/
	CHECK_ARGS


	/***********************************************/
	/* GTK Special Cases - Ignored Widgets         */
	/***********************************************/
	if ((CHECK_DETAIL(detail, "optionmenutab")) ||
		(CHECK_DETAIL (detail, "slider")) ||
		(CHECK_DETAIL (detail, "buttondefault")) ||
		(CHECK_DETAIL (detail, "bar") && 
			((height < 1) && (width < 1))))
	{
		return;
	}


	/***********************************************/
	/* GTK Special Cases - adjust Size/Offset      */
	/***********************************************/
	if ((CHECK_DETAIL (detail, "bar")))
	{
		x += 1;
		y += 1;
		width -= 2;
		height -= 2;

		draw_border=FALSE;
    }
	else if (CHECK_DETAIL (detail, "handlebox_bin"))
	{
		draw_border=FALSE;
	}
	else if (CHECK_DETAIL (detail, "entry-progress"))
	{
        	draw_border=FALSE;
	}


	/***********************************************/
	/* Fill Box                                    */
	/***********************************************/
        gtk_style_apply_default_background(style, cr,
                        gtk_widget_get_window (widget),
                        state_type,
                        x, y, width, height);
	
	/***********************************************/
	/* Draw Box Border                             */
	/***********************************************/
	if (draw_border)
	{
		thinice_style_draw_shadow(style, cr, state_type, shadow_type, widget,
						detail, x, y, width, height);
	}

	/***********************************************/
	/* Draw Widget Specific Sub-Parts              */
	/***********************************************/
	if (CHECK_DETAIL (detail, "button"))
	{
		/* Paint a triangle here instead of in "buttondefault"
			which is drawn _behind_ the current button */
		if (widget && GE_WIDGET_HAS_DEFAULT (widget))
		{
			ge_cairo_set_color(cr, &thinice_style->color_cube.bg[GTK_STATE_SELECTED]);
			cairo_move_to(cr, x+2.5, y+2.5);
			cairo_line_to(cr, x+10.5, y+2.5);
			cairo_line_to(cr, x+2.5, y+10.5);
			cairo_line_to(cr, x+2.5, y+2.5);
			cairo_fill(cr);

			ge_cairo_set_color(cr, &thinice_style->color_cube.dark[state_type]);
			cairo_move_to(cr, x + 2.5, y + 11);
			cairo_line_to(cr, x + 2.5, y + 2.5);
			cairo_line_to(cr, x + 11, y + 2.5);
			cairo_stroke(cr);

			cairo_set_line_width (cr, 0.5);
			ge_cairo_set_color(cr, &thinice_style->color_cube.light[state_type]);
			cairo_move_to(cr, x+11, y+3);
			cairo_line_to(cr, x+3, y+11);
			cairo_stroke(cr);
		}
	}

	/* Draw Option Menus and Combo Box "Tab" The Same Way Here */
	if (CHECK_DETAIL(detail, "optionmenu") ||  (CHECK_DETAIL(detail, "button") && 
		(ge_is_combo_box(widget, FALSE)) && !(ge_is_combo_box_entry(widget))))
	{
		GtkRequisition indicator_size;
		GtkBorder indicator_spacing;
		CairoColor *dark;
		CairoColor *light;
		gint vline_x;
 
		if (state_type != GTK_STATE_INSENSITIVE)
			state_type = GTK_STATE_NORMAL;
 
		ge_option_menu_get_props (widget, &indicator_size, &indicator_spacing);
 
		if ((!widget) || (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL))
			vline_x = x + indicator_size.width + indicator_spacing.left + indicator_spacing.right;
		else
			vline_x = x + width - (indicator_size.width + indicator_spacing.left + 
						indicator_spacing.right) - style->xthickness;

		dark = &thinice_style->color_cube.dark[state_type];
		light = &thinice_style->color_cube.light[state_type];
		thinice_draw_separator(cr, dark, light, FALSE,
                                       vline_x, y + style->ythickness + 1,
                                       style->xthickness, height - 2*style->ythickness - 2);

		if ((widget) && (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL))
			x +=  indicator_spacing.right + style->xthickness;
		else
			x += width - indicator_size.width - indicator_spacing.right - style->xthickness;
 
		y += ((height - indicator_size.height) / 2) + 1;
 
		width = indicator_size.width;
		height = indicator_size.height;
 
		thinice_style_draw_arrow (style, cr, state_type, shadow_type, NULL, "optionmenu", 
						GTK_ARROW_DOWN, TRUE,  x,  y,  width,  height);
	}
}
Example #7
0
static void
clearlooks_style_draw_box (DRAW_ARGS)
{
	ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
	const ClearlooksColors *colors;
	cairo_t *cr;

	cr     = ge_gdk_drawable_to_cairo (window, area);
	colors = &clearlooks_style->colors;

	CHECK_ARGS
	SANITIZE_SIZE

	if (DETAIL ("menubar") && !ge_is_panel_widget_item(widget))
	{
		WidgetParameters params;
		MenuBarParameters menubar;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		menubar.style = clearlooks_style->menubarstyle;

		STYLE_FUNCTION(draw_menubar) (cr, colors, &params, &menubar,
		                         x, y, width, height);
	}
	else if (DETAIL ("button") && widget && widget->parent &&
                  (GE_IS_TREE_VIEW(widget->parent) ||
                   GE_IS_CLIST (widget->parent) ||
                   ge_object_is_a (G_OBJECT(widget->parent), "ETree"))) /* ECanvas inside ETree */
	{
		WidgetParameters params;
		ListViewHeaderParameters header;

		gint columns, column_index;
		gboolean resizable = TRUE;

		/* XXX: This makes unknown treeview header CL_ORDER_MIDDLE, in need for something nicer */
		columns = 3;
		column_index = 1;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		params.corners = CR_CORNER_NONE;

		if (GE_IS_TREE_VIEW (widget->parent))
		{
			clearlooks_treeview_get_header_index (GTK_TREE_VIEW(widget->parent),
										   widget, &column_index, &columns,
										   &resizable);
		}
		else if (GE_IS_CLIST (widget->parent))
		{
			clearlooks_clist_get_header_index (GTK_CLIST(widget->parent),
										widget, &column_index, &columns);
		}

		header.resizable = resizable;

		if (column_index == 0)
			header.order = params.ltr ? CL_ORDER_FIRST : CL_ORDER_LAST;
		else if (column_index == columns-1)
			header.order = params.ltr ? CL_ORDER_LAST : CL_ORDER_FIRST;
		else
			header.order = CL_ORDER_MIDDLE;

		gtk_style_apply_default_background (style, window, FALSE, state_type, area, x, y, width, height);

		STYLE_FUNCTION(draw_list_view_header) (cr, colors, &params, &header,
		                                  x, y, width, height);
	}
	else if (DETAIL ("button") || DETAIL ("buttondefault"))
	{
		WidgetParameters params;
		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		if (ge_is_in_combo_box(widget))
		{
			if (params.ltr)
				params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
			else
				params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;

			if (params.xthickness > 2)
			{
				if (params.ltr)
					x--;
				width++;
			}
		}
		else
		{
			params.corners    = CR_CORNER_ALL;
			/* if (!(ge_is_combo_box (widget, FALSE))) */
			params.enable_glow = TRUE;
		}

		if (GE_IS_TOGGLE_BUTTON (widget) &&
		    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
			params.active = TRUE;

		STYLE_FUNCTION(draw_button) (cr, &clearlooks_style->colors, &params,
		                             x, y, width, height);
	}
	else if (DETAIL ("spinbutton_up") || DETAIL ("spinbutton_down"))
	{
		if (state_type == GTK_STATE_ACTIVE)
		{
			WidgetParameters params;
			clearlooks_set_widget_parameters (widget, style, state_type, &params);

			if (style->xthickness == 3)
			{
				width++;
				if (params.ltr)
					x--;
			}

			if (DETAIL ("spinbutton_up"))
			{
				height+=2;
				if (params.ltr)
					params.corners = CR_CORNER_TOPRIGHT;
				else
					params.corners = CR_CORNER_TOPLEFT;
			}
			else
			{
				if (params.ltr)
					params.corners = CR_CORNER_BOTTOMRIGHT;
				else
					params.corners = CR_CORNER_BOTTOMLEFT;
			}

			STYLE_FUNCTION(draw_spinbutton_down) (cr, &clearlooks_style->colors, &params, x, y, width, height);
		}
	}
	else if (DETAIL ("spinbutton"))
	{
		WidgetParameters params;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		if (params.ltr)
			params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
		else
			params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;

		if (style->xthickness == 3)
		{
			if (params.ltr)
				x--;
			width++;
		}

		STYLE_FUNCTION(draw_spinbutton) (cr, &clearlooks_style->colors, &params,
		                            x, y, width, height);
	}
	else if (detail && g_str_has_prefix (detail, "trough") && GE_IS_SCALE (widget))
	{
		WidgetParameters params;
		SliderParameters slider;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);
		params.corners    = CR_CORNER_NONE;

		slider.lower = DETAIL ("trough-lower");
		slider.fill_level = DETAIL ("trough-fill-level") || DETAIL ("trough-fill-level-full");

		slider.horizontal = (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL);

		STYLE_FUNCTION(draw_scale_trough) (cr, &clearlooks_style->colors,
		                              &params, &slider,
		                              x, y, width, height);
	}
	else if (DETAIL ("trough") && widget && GE_IS_PROGRESS_BAR (widget))
	{
		WidgetParameters params;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		STYLE_FUNCTION(draw_progressbar_trough) (cr, colors, &params,
		                                    x, y, width, height);
	}
	else if (DETAIL ("trough") && widget && (GE_IS_VSCROLLBAR (widget) || GE_IS_HSCROLLBAR (widget)))
	{
		WidgetParameters params;
		ScrollBarParameters scrollbar;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);
		params.corners = CR_CORNER_NONE;

		scrollbar.horizontal = TRUE;
		scrollbar.junction   = clearlooks_scrollbar_get_junction (widget);

		if (GE_IS_RANGE (widget))
			scrollbar.horizontal = GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL;

		if (scrollbar.horizontal)
		{
			x += 2;
			width -= 4;
		}
		else
		{
			y += 2;
			height -= 4;
		}

		STYLE_FUNCTION(draw_scrollbar_trough) (cr, colors, &params, &scrollbar,
		                                  x, y, width, height);
	}
	else if (DETAIL ("bar"))
	{
		WidgetParameters      params;
		ProgressBarParameters progressbar;
		gdouble               elapsed = 0.0;

#ifdef HAVE_ANIMATION
		if(clearlooks_style->animation && CL_IS_PROGRESS_BAR (widget))
		{
			gboolean activity_mode = GTK_PROGRESS (widget)->activity_mode;

		 	if (!activity_mode)
				clearlooks_animation_progressbar_add ((gpointer)widget);
		}

		elapsed = clearlooks_animation_elapsed (widget);
#endif

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		if (widget && GE_IS_PROGRESS_BAR (widget))
		{
			progressbar.orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget));
			progressbar.value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget));
			progressbar.pulsing = GTK_PROGRESS (widget)->activity_mode;
		}
		else
		{
			progressbar.orientation = CL_ORIENTATION_LEFT_TO_RIGHT;
			progressbar.value = 0;
			progressbar.pulsing = FALSE;
		}

		if (!params.ltr)
		{
			if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_LEFT_TO_RIGHT)
				progressbar.orientation = GTK_PROGRESS_RIGHT_TO_LEFT;
			else if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_RIGHT_TO_LEFT)
				progressbar.orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
		}

		/* Following is a hack to have a larger clip area, the one passed in
		 * does not allow for the shadow. */
		if (area)
		{
			GdkRectangle tmp = *area;
			if (!progressbar.pulsing)
			{
				switch (progressbar.orientation)
				{
					case GTK_PROGRESS_RIGHT_TO_LEFT:
						tmp.x -= 1;
					case GTK_PROGRESS_LEFT_TO_RIGHT:
						tmp.width += 1;
						break;
					case GTK_PROGRESS_BOTTOM_TO_TOP:
						tmp.y -= 1;
					case GTK_PROGRESS_TOP_TO_BOTTOM:
						tmp.height += 1;
						break;
				}
			}
			else
			{
				if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_RIGHT_TO_LEFT ||
				    progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_LEFT_TO_RIGHT)
				{
					tmp.x -= 1;
					tmp.width += 2;
				}
				else
				{
					tmp.y -= 1;
					tmp.height += 2;
				}
			}

			cairo_reset_clip (cr);
			gdk_cairo_rectangle (cr, &tmp);
			cairo_clip (cr);
		}

		STYLE_FUNCTION(draw_progressbar_fill) (cr, colors, &params, &progressbar,
		                                  x, y, width, height,
		                                  10 - (int)(elapsed * 10.0) % 10);
	}
	else if (DETAIL ("optionmenu"))
	{
		WidgetParameters params;
		OptionMenuParameters optionmenu;

		GtkRequisition indicator_size;
		GtkBorder indicator_spacing;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		params.enable_glow = TRUE;

		ge_option_menu_get_props (widget, &indicator_size, &indicator_spacing);

		if (ge_widget_is_ltr (widget))
			optionmenu.linepos = width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - 1;
		else
			optionmenu.linepos = (indicator_size.width + indicator_spacing.left + indicator_spacing.right) + 1;

		STYLE_FUNCTION(draw_optionmenu) (cr, colors, &params, &optionmenu,
		                                 x, y, width, height);
	}
	else if (DETAIL ("menuitem"))
	{
		WidgetParameters params;
		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		if (widget && GE_IS_MENU_BAR (widget->parent))
		{
			params.corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
			height += 1;
			STYLE_FUNCTION(draw_menubaritem) (cr, colors, &params, x, y, width, height);
		}
		else
		{
			params.corners = CR_CORNER_ALL;
			STYLE_FUNCTION(draw_menuitem) (cr, colors, &params, x, y, width, height);
		}
	}
	else if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar")) /* This can't be "stepper" for scrollbars ... */
	{
		WidgetParameters    params;
		ScrollBarParameters scrollbar;
		ScrollBarStepperParameters stepper;
		GdkRectangle this_rectangle;

		this_rectangle.x = x;
		this_rectangle.y = y;
		this_rectangle.width  = width;
		this_rectangle.height = height;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);
		params.corners = CR_CORNER_NONE;

		scrollbar.has_color  = FALSE;
		scrollbar.horizontal = TRUE;
		scrollbar.junction   = clearlooks_scrollbar_get_junction (widget);

		if (clearlooks_style->colorize_scrollbar || clearlooks_style->has_scrollbar_color) {
			scrollbar.has_color = TRUE;
		}

		scrollbar.horizontal = DETAIL ("hscrollbar");

		stepper.stepper = clearlooks_scrollbar_get_stepper (widget, &this_rectangle);

		STYLE_FUNCTION(draw_scrollbar_stepper) (cr, colors, &params, &scrollbar, &stepper,
			                                x, y, width, height);
	}
	else if (DETAIL ("toolbar") || DETAIL ("handlebox_bin") || DETAIL ("dockitem_bin"))
	{
		WidgetParameters  params;
		ToolbarParameters toolbar;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);
		clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y);

		toolbar.style = clearlooks_style->toolbarstyle;

		/* Only draw the shadows on horizontal toolbars */
		if (shadow_type != GTK_SHADOW_NONE && height < 2*width )
			STYLE_FUNCTION(draw_toolbar) (cr, colors, &params, &toolbar, x, y, width, height);
	}
	else if (DETAIL ("trough"))
	{

	}
	else if (DETAIL ("menu"))
	{
		WidgetParameters params;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		STYLE_FUNCTION(draw_menu_frame) (cr, colors, &params, x, y, width, height);
	}
	else if (DETAIL ("hseparator") || DETAIL ("vseparator"))
	{
		const gchar *new_detail = detail;
		/* Draw a normal separator, we just use this because it gives more control
		 * over sizing (currently). */

		/* This isn't nice ... but it seems like the best cleanest way to me right now.
		 * It will get slightly nicer in the future hopefully. */
		if (GE_IS_MENU_ITEM (widget))
			new_detail = "menuitem";

		if (DETAIL ("hseparator")) {
			gtk_paint_hline (style, window, state_type, area, widget, new_detail,
			                 x, x + width - 1, y + height/2);
		} else
			gtk_paint_vline (style, window, state_type, area, widget, new_detail,
			                 y, y + height - 1, x + width/2);
	}
	else
	{
		clearlooks_parent_class->draw_box (style, window, state_type, shadow_type, area,
		                        widget, detail, x, y, width, height);
	}

	cairo_destroy (cr);
}
Example #8
0
static void
clearlooks_style_draw_shadow (DRAW_ARGS)
{
	ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
	ClearlooksColors *colors = &clearlooks_style->colors;
	cairo_t          *cr     = ge_gdk_drawable_to_cairo (window, area);

	CHECK_ARGS
	SANITIZE_SIZE

	if ((DETAIL ("entry") && !(widget && widget->parent && GE_IS_TREE_VIEW (widget->parent))) ||
	    (DETAIL ("frame") && ge_is_in_combo_box (widget)))
	{
		WidgetParameters params;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		/* Override the entries state type, because we are too lame to handle this via
		 * the focus ring, and GtkEntry doesn't even set the INSENSITIVE state ... */
		if (state_type == GTK_STATE_NORMAL && widget && GE_IS_ENTRY (widget))
			params.state_type = GTK_WIDGET_STATE (widget);

		if (widget && (ge_is_in_combo_box (widget) || GE_IS_SPIN_BUTTON (widget)))
		{
			width += style->xthickness;
			if (!params.ltr)
				x -= style->xthickness;

			if (params.ltr)
				params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
			else
				params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
		}

		STYLE_FUNCTION (draw_entry) (cr, &clearlooks_style->colors, &params,
		                       x, y, width, height);
	}
	else if (DETAIL ("frame") && widget && GE_IS_STATUSBAR (widget->parent))
	{
		WidgetParameters params;

		clearlooks_set_widget_parameters (widget, style, state_type, &params);

		gtk_style_apply_default_background (style, window, TRUE, state_type,
		                                    area, x, y, width, height);

		STYLE_FUNCTION (draw_statusbar) (cr, colors, &params,
		                           x, y, width, height);
	}
	else if (DETAIL ("frame"))
	{
		WidgetParameters params;
		FrameParameters  frame;
		frame.shadow  = shadow_type;
		frame.gap_x   = -1;                 /* No gap will be drawn */
		frame.border  = &colors->shade[4];

		clearlooks_set_widget_parameters (widget, style, state_type, &params);
		params.corners = CR_CORNER_NONE;

		if (widget && !g_str_equal ("XfcePanelWindow", gtk_widget_get_name (gtk_widget_get_toplevel (widget))))
			STYLE_FUNCTION(draw_frame) (cr, colors, &params, &frame,
			                       x, y, width, height);
	}
	else if (DETAIL ("scrolled_window") || DETAIL ("viewport") || detail == NULL)
	{
		CairoColor *border = (CairoColor*)&colors->shade[5];
		cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1);
		ge_cairo_set_color (cr, border);
		cairo_set_line_width (cr, 1);
		cairo_stroke (cr);
	}
	else
	{
		WidgetParameters params;
		FrameParameters frame;

		frame.shadow = shadow_type;
		frame.gap_x  = -1;
		frame.border = &colors->shade[5];
		clearlooks_set_widget_parameters (widget, style, state_type, &params);
		params.corners = CR_CORNER_ALL;

		STYLE_FUNCTION(draw_frame) (cr, colors, &params, &frame, x, y, width, height);
	}

	cairo_destroy (cr);
}
static void
moblin_netbook_draw_extension (GtkStyle       *style,
                               GdkWindow      *window,
                               GtkStateType    state_type,
                               GtkShadowType   shadow_type,
                               GdkRectangle   *area,
                               GtkWidget      *widget,
                               const gchar    *detail,
                               gint            x,
                               gint            y,
                               gint            width,
                               gint            height,
                               GtkPositionType gap_side)
{
  cairo_t *cr;
  cairo_pattern_t *pattern;
  gint radius = MOBLIN_NETBOOK_STYLE (style)->radius;

  /* initialise the background */
  gtk_style_apply_default_background (style, window, TRUE, state_type, area,
                                      x, y, width, height);

  cr = moblin_netbook_cairo_create (window, area);

  /* set up for line drawing */
  cairo_set_line_width (cr, LINE_WIDTH);
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
  cairo_translate (cr, 0.5, 0.5);

  /* reduce with and height since we are using them for co-ordinate values */
  width--; height--;

  /* tab border */
  switch (gap_side)
    {
    case GTK_POS_TOP:     /* bottom tab */
      cairo_move_to (cr, x, y);
      cairo_arc_negative (cr, x + radius, y + height - radius, radius, M_PI,
                          M_PI * 0.5);
      cairo_arc_negative (cr, x + width - radius, y + height - radius, radius,
                          M_PI * 0.5, 0);
      cairo_line_to (cr, x + width, y);
      break;
    case GTK_POS_BOTTOM: /* top tab */
      height++; /* add overlap */
      if (state_type == GTK_STATE_NORMAL)
        cairo_arc_negative (cr, x, y + height - radius, radius, M_PI / 2.0, 0);
      else
        cairo_move_to (cr, x + radius, y + height);
      cairo_arc (cr, x + radius * 2, y + radius, radius, M_PI, M_PI * 1.5);
      cairo_arc (cr, x + width - radius * 2, y + radius, radius, M_PI * 1.5, 0);
      if (state_type == GTK_STATE_NORMAL)
        cairo_arc_negative (cr, x + width, y + height - radius, radius, M_PI, M_PI / 2.0);
      else
        cairo_line_to (cr, x + width - radius, y + height);
      break;
    case GTK_POS_LEFT:  /* right tab */
      cairo_move_to (cr, x, y);
      cairo_arc (cr, x + width - radius, y + radius, radius, M_PI * 1.5, 0);
      cairo_arc (cr, x + width - radius, y + height - radius, radius, 0,
                 M_PI * 0.5);
      cairo_line_to (cr, x, y + height);
      break;
    case GTK_POS_RIGHT: /* left tab */
      cairo_move_to (cr, x + width, y);
      cairo_arc_negative (cr, x + radius, y + radius, radius, M_PI * 1.5, M_PI);
      cairo_arc_negative (cr, x + radius, y + height - radius, radius, M_PI,
                          M_PI * 0.5);
      cairo_line_to (cr, x + width, y + height);
      break;
    }

  if (state_type == GTK_STATE_NORMAL)
    {
      pattern = cairo_pattern_create_linear (x, y, x, y +height);
      cairo_pattern_add_color_stop_rgb (pattern, 0,
                                        0xf9/255.0, 0xf9/255.0,0xf9/255.0);
      cairo_pattern_add_color_stop_rgb (pattern, 1,
                                        0xe6/255.0, 0xe6/255.0,0xe6/255.0);
      cairo_set_source (cr, pattern);
      cairo_fill_preserve (cr);
      cairo_pattern_destroy (pattern);
    }

  moblin_netbook_set_border_color (cr, style, state_type);
  cairo_stroke (cr);

  cairo_destroy (cr);

}
static void
moblin_netbook_draw_box_gap (GtkStyle       *style,
                             GdkWindow      *window,
                             GtkStateType    state_type,
                             GtkShadowType   shadow_type,
                             GdkRectangle   *area,
                             GtkWidget      *widget,
                             const gchar    *detail,
                             gint            x,
                             gint            y,
                             gint            width,
                             gint            height,
                             GtkPositionType gap_side,
                             gint            gap_x,
                             gint            gap_width)
{
  cairo_t *cr;
  GdkRectangle rect = { 0, };

  if (shadow_type == GTK_SHADOW_NONE)
    return;

  cr = moblin_netbook_cairo_create (window, area);

  cairo_set_line_width (cr, LINE_WIDTH);
  cairo_translate (cr, 0.5, 0.5);

  moblin_netbook_set_border_color (cr, style, state_type);

  /* start off with a rectangle... */
  cairo_rectangle (cr, x, y, width -1, height -1);
  cairo_stroke (cr);
  cairo_destroy (cr);

  switch (gap_side)
    {
    case GTK_POS_TOP:
      rect.x = x + gap_x + LINE_WIDTH;
      rect.y = y;
      rect.width = gap_width - LINE_WIDTH * 2;
      rect.height = LINE_WIDTH;
      break;
    case GTK_POS_BOTTOM:
      rect.x = x + gap_x + LINE_WIDTH;
      rect.y = y + height - 2;
      rect.width = gap_width - LINE_WIDTH * 2;
      rect.height = 2;
      break;
    case GTK_POS_LEFT:
      rect.x = x;
      rect.y = y + gap_x + LINE_WIDTH;
      rect.width = 2;
      rect.height = gap_width - LINE_WIDTH * 2;
      break;
    case GTK_POS_RIGHT:
      rect.x = x + width - 2;
      rect.y = y + gap_x + LINE_WIDTH;
      rect.width = 2;
      rect.height = gap_width - LINE_WIDTH * 2;
      break;
    }

  /* and finally blank out the gap */
  gtk_style_apply_default_background (style, window, TRUE, state_type, area,
                                      rect.x, rect.y, rect.width,
                                      rect.height);


}
static void
freetuxtv_cellrenderer_channelslist_render (GtkCellRenderer *cell,
    GdkWindow       *window,
    GtkWidget       *widget,
    GdkRectangle    *background_area,
    GdkRectangle    *cell_area,
    GdkRectangle    *expose_area,
    guint            flags)
#endif
{
	FreetuxTVCellRendererChannelsList *self = FREETUXTV_CELLRENDERER_CHANNELSLIST (cell);
	
	gint width, height;
	PangoLayout *layout;

	gboolean is_selected = FALSE;
	gboolean is_playing = FALSE;
	
	if ((flags & GTK_CELL_RENDERER_SELECTED) != 0){
		is_selected = TRUE;
	}

	if(self->type == CELLRENDERER_TYPE_CHANNEL){
		if(self->is_playing){
			is_playing = TRUE;
		}
	}

#if GTK_API_VERSION == 3
	
	// Set the cell state
	GtkStateFlags state = GTK_STATE_FLAG_NORMAL;
	if(is_selected){
		if(self->type == CELLRENDERER_TYPE_CHANNEL){
			state = GTK_STATE_FLAG_SELECTED;
		}else{
			state = GTK_STATE_FLAG_ACTIVE;
		}
	}

	// Define the style of the row.
	GtkStyleContext *pStyleContext;
	pStyleContext = gtk_widget_get_style_context (GTK_WIDGET(widget));
	gtk_style_context_save(pStyleContext);
	gtk_style_context_set_state(pStyleContext, state);
	if(self->type == CELLRENDERER_TYPE_CHANNEL){
		gtk_style_context_add_class (pStyleContext, GTK_STYLE_CLASS_CELL);
	}else{
		gtk_style_context_add_class (pStyleContext, GTK_STYLE_CLASS_BUTTON);
	}

	freetuxtv_cellrenderer_channelslist_get_preferred_width(cell, widget, NULL, &width);
	freetuxtv_cellrenderer_channelslist_get_preferred_height_for_width(cell, widget, width, NULL, &height);
#else
	GtkStyle* pStyle;
	pStyle = widget->style;

	GtkStateType state;
	state = GTK_STATE_NORMAL;
	if(is_selected){
		state = GTK_STATE_SELECTED;
	}

	freetuxtv_cellrenderer_channelslist_get_size (cell, widget, cell_area,
	    NULL, NULL,
	    &width, &height);
#endif

	// Build the layout
	layout = gtk_widget_create_pango_layout (widget, self->name);
	//pango_layout_set_width(layout, 700);
	//pango_layout_set_height(layout, 20);
	pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
	if(is_playing){
		PangoFontDescription *desc;
		desc = pango_font_description_new();
		pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
		pango_font_description_set_style (desc, PANGO_STYLE_ITALIC);
		pango_layout_set_font_description (layout, desc);
		pango_font_description_free(desc);
	}

	// gtk_paint_flat_box (widget->style, window, GTK_STATE_SELECTED,
	//     GTK_SHADOW_NONE , NULL, widget,
	//     NULL,
	//     0, cell_area->y,
	//     cell_area->x + width, cell_area->height);
	
	// gtk_paint_hline (widget->style, window, state,
	//     NULL, widget, NULL,
	//     0, widget->allocation.width, cell_area->y);
	//	 gtk_paint_hline (widget->style, window, state,
	//	     NULL, widget, NULL,
	//	     cell_area->x, cell_area->width, cell_area->y + 2);
	//		 gtk_paint_hline (widget->style, window, state,
	//		     NULL, widget, NULL,
	//		     0, 176, cell_area->y + 3);

	GdkPixbuf* logo;

	// If the cell contain a channel
	if(self->type == CELLRENDERER_TYPE_CHANNEL){

		// Backgroung of the cell
#if GTK_API_VERSION == 3
		gtk_style_context_set_state (pStyleContext, state);
		// gtk_style_context_set_background (pStyleContext, window); // This block the main loop

		gtk_render_background (pStyleContext, cr,
		    0, cell_area->y,
		    cell_area->x + width, cell_area->height);
		gtk_render_frame (pStyleContext, cr, 0, cell_area->y, cell_area->x + width, cell_area->height);
#else
		if(state != GTK_STATE_NORMAL){
			// gtk_style_set_background (pStyle, window, state); // This block the main loop
			gtk_style_apply_default_background  (pStyle, window, TRUE, state, NULL,
				0, cell_area->y, cell_area->x + width, cell_area->height);
		}
#endif

		//static int count = 0;
		//count++;
		//g_print("cell(%d) : %d %d\n", count, cell_area->x, width);

		// Display the logo and text of the cell
		logo = gdk_pixbuf_new_from_file(self->logo, NULL);

		int cell_xpad;
		int cell_ypad;

#if GTK_API_VERSION == 3
		gtk_cell_renderer_get_padding (cell, &cell_xpad, &cell_ypad);

		// Render the logo
		gdk_cairo_set_source_pixbuf(cr, logo,
		    (double)cell_xpad + 1.0, cell_area->y + (double)cell_ypad + 1.0);
		cairo_paint(cr);

		// Render the channel name
		gtk_render_layout (pStyleContext, cr,
		    cell_xpad * 2 + gdk_pixbuf_get_width(logo) + 5,
		    cell_area->y + 15,
		    layout);

#else
		cell_xpad = cell->xpad;
		cell_ypad = cell->ypad;

		// Render the logo
		gdk_draw_pixbuf (GDK_DRAWABLE(window), NULL, logo,
		    0, 0, cell_xpad + 1, cell_area->y + cell_ypad + 1,
		    -1, -1,
		    GDK_RGB_DITHER_NONE, 0,0);
		
		// Render the channel name
		gtk_paint_layout (widget->style, window, state,
		    TRUE, NULL, widget, NULL,
		    cell->xpad * 2 + gdk_pixbuf_get_width(logo) + 5, cell_area->y + 15,
		    layout);
#endif

		if(logo){
			g_object_unref(logo);
			logo = NULL;
		}
	}

	// If the cell contain a group
	if(self->type == CELLRENDERER_TYPE_CHANNELS_GROUP){

#if GTK_API_VERSION == 3
		int x = background_area->x;
        int y = background_area->y;
		width = background_area->width;
		height = background_area->height;

		// Background of the cell
		gtk_render_background (pStyleContext, cr,
		    x, y, width, height);
		gtk_render_frame (pStyleContext, cr,
		    x, y, width, height);

		//g_print("cell_bg %s : x=%d, y=%d\n", self->name, background_area->x, background_area->y);
		//g_print("cell %s : x=%d, y=%d, w=%d, h=%d\n", self->name, x, y, width, height);

		// Render the group name
		gtk_render_layout (pStyleContext, cr,
		    cell_area->x, cell_area->y + 3,
		    layout);
#else
		// Background of the cell
		gtk_style_apply_default_background  (widget->style, window, TRUE,
		    state, NULL,
		    0, cell_area->y, cell_area->x + width, cell_area->height);

		// Render the group name
		gtk_paint_layout (widget->style, window, state,
		    TRUE, NULL, widget, NULL,
		    cell_area->x, cell_area->y + 3, layout);
#endif
	}

#if GTK_API_VERSION == 3
	gtk_style_context_restore(pStyleContext);
#endif
}