[appearance] remove custom cell renderers
The custom cell renderers were required to draw the selection inidicator around the entire item, not just the text. This has now been fixed in GTK+ as the as the resolution of bug 382544.
This commit is contained in:
parent
8389b285a1
commit
683102f257
7 changed files with 4 additions and 325 deletions
|
@ -31,11 +31,7 @@ gnome_appearance_properties_SOURCES = \
|
|||
theme-save.c \
|
||||
theme-save.h \
|
||||
theme-util.c \
|
||||
theme-util.h \
|
||||
wp-cellrenderer.c \
|
||||
wp-cellrenderer.h \
|
||||
caption-cellrenderer.c \
|
||||
caption-cellrenderer.h
|
||||
theme-util.h
|
||||
|
||||
AM_CFLAGS = -DGNOME_DESKTOP_USE_UNSTABLE_API
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "gnome-wp-info.h"
|
||||
#include "gnome-wp-item.h"
|
||||
#include "gnome-wp-xml.h"
|
||||
#include "wp-cellrenderer.h"
|
||||
#include <glib/gi18n.h>
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
@ -1050,7 +1049,7 @@ desktop_init (AppearanceData *data,
|
|||
|
||||
gtk_cell_layout_clear (GTK_CELL_LAYOUT (data->wp_view));
|
||||
|
||||
cr = cell_renderer_wallpaper_new ();
|
||||
cr = gtk_cell_renderer_pixbuf_new ();
|
||||
g_object_set (cr, "xpad", 5, "ypad", 5, NULL);
|
||||
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->wp_view), cr, TRUE);
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "theme-util.h"
|
||||
#include "gtkrc-utils.h"
|
||||
#include "gedit-message-area.h"
|
||||
#include "wp-cellrenderer.h"
|
||||
#include "caption-cellrenderer.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <libwindow-settings/gnome-wm-manager.h>
|
||||
|
@ -1078,14 +1076,14 @@ themes_init (AppearanceData *data)
|
|||
|
||||
icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"));
|
||||
|
||||
renderer = cell_renderer_wallpaper_new ();
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
g_object_set (renderer, "xpad", 5, "ypad", 5,
|
||||
"xalign", 0.5, "yalign", 1.0, NULL);
|
||||
gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
|
||||
"pixbuf", COL_THUMBNAIL, NULL);
|
||||
|
||||
renderer = cell_renderer_caption_new ();
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (renderer, "alignment", PANGO_ALIGN_CENTER,
|
||||
"wrap-mode", PANGO_WRAP_WORD_CHAR,
|
||||
"wrap-width", gtk_icon_view_get_item_width (icon_view),
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* caption-cellrenderer was based on wp-cellrenderer
|
||||
*
|
||||
* Copyright (C) 2007, 2008 The GNOME Foundation
|
||||
* Written by Denis Washington <denisw@svn.gnome.org>
|
||||
* Jens Granseuer <jensgr@gmx.net>
|
||||
* Thomas Wood <thos@gnome.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "caption-cellrenderer.h"
|
||||
#include <math.h>
|
||||
|
||||
static void cell_renderer_caption_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
G_DEFINE_TYPE (CellRendererCaption, cell_renderer_caption, GTK_TYPE_CELL_RENDERER_TEXT)
|
||||
|
||||
static void
|
||||
cell_renderer_caption_class_init (CellRendererCaptionClass *klass)
|
||||
{
|
||||
GtkCellRendererClass *renderer_class;
|
||||
|
||||
renderer_class = (GtkCellRendererClass *) klass;
|
||||
renderer_class->render = cell_renderer_caption_render;
|
||||
}
|
||||
|
||||
static void
|
||||
cell_renderer_caption_init (CellRendererCaption *renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GtkCellRenderer *
|
||||
cell_renderer_caption_new (void)
|
||||
{
|
||||
return g_object_new (cell_renderer_caption_get_type (), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
cell_renderer_caption_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
(* GTK_CELL_RENDERER_CLASS (cell_renderer_caption_parent_class)->render)
|
||||
(cell, window, widget, background_area, cell_area, expose_area, flags);
|
||||
|
||||
if ((flags & (GTK_CELL_RENDERER_SELECTED|GTK_CELL_RENDERER_PRELIT)) != 0)
|
||||
{
|
||||
cairo_t *cr;
|
||||
int radius = 5;
|
||||
int x, y, w, h;
|
||||
GtkStateType state;
|
||||
x = background_area->x;
|
||||
y = background_area->y;
|
||||
w = background_area->width;
|
||||
h = background_area->height;
|
||||
|
||||
/* sometimes width is -1 - not sure what to do here */
|
||||
if (w == -1)
|
||||
return;
|
||||
|
||||
if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
|
||||
{
|
||||
if (GTK_WIDGET_HAS_FOCUS (widget))
|
||||
state = GTK_STATE_SELECTED;
|
||||
else
|
||||
state = GTK_STATE_ACTIVE;
|
||||
}
|
||||
else
|
||||
state = GTK_STATE_PRELIGHT;
|
||||
|
||||
/* add rounded corners to the selection indicator */
|
||||
cr = gdk_cairo_create (GDK_DRAWABLE (window));
|
||||
|
||||
gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]);
|
||||
|
||||
cairo_rectangle (cr, x, y, w, h);
|
||||
|
||||
cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
|
||||
cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, 0);
|
||||
cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, M_PI * 0.5);
|
||||
cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.5, M_PI);
|
||||
cairo_close_path (cr);
|
||||
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
|
||||
cairo_fill (cr);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* caption-cellrenderer was based on wp-cellrenderer
|
||||
*
|
||||
* Copyright (C) 2007, 2008 The GNOME Foundation
|
||||
* Written by Denis Washington <denisw@svn.gnome.org>
|
||||
* Thomas Wood <thos@gnome.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef _CAPTION_CELL_RENDERER_H
|
||||
#define _CAPTION_CELL_RENDERER_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _CellRendererCaption CellRendererCaption;
|
||||
typedef struct _CellRendererCaptionClass CellRendererCaptionClass;
|
||||
|
||||
struct _CellRendererCaption
|
||||
{
|
||||
GtkCellRendererText parent;
|
||||
};
|
||||
|
||||
struct _CellRendererCaptionClass
|
||||
{
|
||||
GtkCellRendererTextClass parent;
|
||||
};
|
||||
|
||||
GtkCellRenderer *cell_renderer_caption_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The GNOME Foundation
|
||||
* Written by Denis Washington <denisw@svn.gnome.org>
|
||||
* Jens Granseuer <jensgr@gmx.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#include "wp-cellrenderer.h"
|
||||
#include <math.h>
|
||||
|
||||
static void cell_renderer_wallpaper_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
G_DEFINE_TYPE (CellRendererWallpaper, cell_renderer_wallpaper, GTK_TYPE_CELL_RENDERER_PIXBUF)
|
||||
|
||||
static void
|
||||
cell_renderer_wallpaper_class_init (CellRendererWallpaperClass *klass)
|
||||
{
|
||||
GtkCellRendererClass *renderer_class;
|
||||
|
||||
renderer_class = (GtkCellRendererClass *) klass;
|
||||
renderer_class->render = cell_renderer_wallpaper_render;
|
||||
}
|
||||
|
||||
static void
|
||||
cell_renderer_wallpaper_init (CellRendererWallpaper *renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GtkCellRenderer *
|
||||
cell_renderer_wallpaper_new (void)
|
||||
{
|
||||
return g_object_new (cell_renderer_wallpaper_get_type (), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
cell_renderer_wallpaper_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
(* GTK_CELL_RENDERER_CLASS (cell_renderer_wallpaper_parent_class)->render)
|
||||
(cell, window, widget, background_area, cell_area, expose_area, flags);
|
||||
|
||||
if ((flags & (GTK_CELL_RENDERER_SELECTED|GTK_CELL_RENDERER_PRELIT)) != 0)
|
||||
{
|
||||
cairo_t *cr;
|
||||
int radius = 5;
|
||||
int x, y, w, h;
|
||||
GtkStateType state;
|
||||
x = background_area->x;
|
||||
y = background_area->y;
|
||||
w = background_area->width;
|
||||
h = background_area->height;
|
||||
|
||||
/* sometimes width is -1 - not sure what to do here */
|
||||
if (w == -1)
|
||||
return;
|
||||
|
||||
if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
|
||||
{
|
||||
if (GTK_WIDGET_HAS_FOCUS (widget))
|
||||
state = GTK_STATE_SELECTED;
|
||||
else
|
||||
state = GTK_STATE_ACTIVE;
|
||||
}
|
||||
else
|
||||
state = GTK_STATE_PRELIGHT;
|
||||
|
||||
/* draw the selection indicator */
|
||||
cr = gdk_cairo_create (GDK_DRAWABLE (window));
|
||||
gdk_cairo_set_source_color (cr, &widget->style->base[state]);
|
||||
|
||||
cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
|
||||
cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, 0);
|
||||
cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, M_PI * 0.5);
|
||||
cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.5, M_PI);
|
||||
cairo_close_path (cr);
|
||||
|
||||
/* FIXME: this should not be hardcoded to 4 */
|
||||
cairo_rectangle (cr, x + 4, y + 4, w - 8, h - 8);
|
||||
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
cairo_fill (cr);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The GNOME Foundation
|
||||
* Written by Denis Washington <denisw@svn.gnome.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef _WP_CELL_RENDERER_H
|
||||
#define _WP_CELL_RENDERER_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _CellRendererWallpaper CellRendererWallpaper;
|
||||
typedef struct _CellRendererWallpaperClass CellRendererWallpaperClass;
|
||||
|
||||
struct _CellRendererWallpaper
|
||||
{
|
||||
GtkCellRendererPixbuf parent;
|
||||
};
|
||||
|
||||
struct _CellRendererWallpaperClass
|
||||
{
|
||||
GtkCellRendererPixbufClass parent;
|
||||
};
|
||||
|
||||
GtkCellRenderer *cell_renderer_wallpaper_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue