reviewed by: John Harper

reviewed by: John Harper

	* configure.in:
	* libnautilus-extensions/nautilus-background-canvas-group.c:
	(nautilus_background_canvas_group_initialize_common),
	(nautilus_background_canvas_group_initialize),
	(nautilus_background_canvas_group_supplant_root_class):
	* libnautilus-extensions/nautilus-background-canvas-group.h:
	* libnautilus-extensions/nautilus-background.c:
	(nautilus_background_set_up_canvas):
	Turned on dithering for canvases (aa mode). We no longer expose
	NautilusBackgroundCanvasGroupClass, in nautilus-background-canvas-
	group.h. Now we just provide an API to do the class change.
This commit is contained in:
Mike Engber 2001-01-10 23:54:58 +00:00
parent 74728e1fe2
commit 49b199f24a
7 changed files with 162 additions and 84 deletions

View file

@ -1,3 +1,19 @@
2001-01-10 Michael Engber <engber@eazel.com>
reviewed by: John Harper
* configure.in:
* libnautilus-extensions/nautilus-background-canvas-group.c:
(nautilus_background_canvas_group_initialize_common),
(nautilus_background_canvas_group_initialize),
(nautilus_background_canvas_group_supplant_root_class):
* libnautilus-extensions/nautilus-background-canvas-group.h:
* libnautilus-extensions/nautilus-background.c:
(nautilus_background_set_up_canvas):
Turned on dithering for canvases (aa mode). We no longer expose
NautilusBackgroundCanvasGroupClass, in nautilus-background-canvas-
group.h. Now we just provide an API to do the class change.
2001-01-10 Pavel Cisler <pavel@eazel.com>
* components/services/install/nautilus-view/nautilus-service-install-view.c:

View file

@ -54,6 +54,23 @@ static void nautilus_background_canvas_group_draw (GnomeCanvasItem *item,
static void nautilus_background_canvas_group_render (GnomeCanvasItem *item,
GnomeCanvasBuf *buffer);
typedef GnomeCanvasGroup NautilusBackgroundCanvasGroup;
typedef GnomeCanvasGroupClass NautilusBackgroundCanvasGroupClass;
#define NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP \
(nautilus_background_canvas_group_get_type ())
#define NAUTILUS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroup))
#define NAUTILUS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroupClass))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
GtkType nautilus_background_canvas_group_get_type (void);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusBackgroundCanvasGroup, nautilus_background_canvas_group, GNOME_TYPE_CANVAS_GROUP)
static void
@ -64,9 +81,58 @@ nautilus_background_canvas_group_initialize_class (gpointer klass)
GNOME_CANVAS_ITEM_CLASS (klass)->update = nautilus_background_canvas_group_update;
}
/* This function is for initialization code that's needed both when we're allocating
* a new NautilusBackgroundCanvasGroup object as well as when we're taking over an existing
* GnomeCanvasGroup item (replacing its klass).
*/
static void
nautilus_background_canvas_group_initialize_common (NautilusBackgroundCanvasGroup *canvas_group)
{
/* gnome_canvas_set_dither is only available in gnome-libs > v 1.2.8
*/
#ifdef HAVE_GNOME_CANVAS_SET_DITHER
gnome_canvas_set_dither (GNOME_CANVAS_ITEM (canvas_group)->canvas, GDK_RGB_DITHER_MAX);
#endif
}
static void
nautilus_background_canvas_group_initialize (gpointer object, gpointer klass)
{
/* The way we currently use nautilus_background_canvas_group, assigning
* it to the klass of a root canvas object, circumvents this initialze fn.
*/
nautilus_background_canvas_group_initialize_common (NAUTILUS_BACKGROUND_CANVAS_GROUP (object));
}
void
nautilus_background_canvas_group_supplant_root_class (GnomeCanvas *canvas)
{
/* Attach ourselves to a canvas in a way that will work.
Changing the style is not sufficient.
Since there's no signal to override in GnomeCanvas to control
drawing the background, we change the class of the canvas root.
This gives us a chance to draw the background before any of the
objects draw themselves, and has no effect on the bounds or
anything related to scrolling.
We settled on this after less-than-thrilling results using a
canvas item as the background. The canvas item contributed to
the bounds of the canvas and had to constantly be resized.
*/
g_assert (GNOME_IS_CANVAS (canvas));
if (GTK_OBJECT (canvas->root)->klass != gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP)) {
g_assert (GTK_OBJECT (canvas->root)->klass == gtk_type_class (GNOME_TYPE_CANVAS_GROUP));
GTK_OBJECT (canvas->root)->klass =
gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP);
nautilus_background_canvas_group_initialize_common (NAUTILUS_BACKGROUND_CANVAS_GROUP (canvas->root));
}
}
static void

View file

@ -26,35 +26,21 @@
#ifndef NAUTILUS_BACKGROUND_CANVAS_GROUP_H
#define NAUTILUS_BACKGROUND_CANVAS_GROUP_H
#include "nautilus-background.h"
#include <libgnomeui/gnome-canvas.h>
/* A NautilusBackgroundCanvasGroup is used internally by NautilusBackground to change
the color of a canvas. The reason we have to change the class of a canvas group is
/* nautilus_background_canvas_group_supplant_root_class is used internally by
NautilusBackground to change the class of a canvas in order to customize its
background drawing. The reason we have to change the class of a canvas group is
that the cleanest way to hook into the code that erases the canvas is to be the
root canvas group. But the canvas class creates the root object and doesn't allow
it to be destroyed, so we change the class of the root object in place.
A future version of GnomeCanvas may allow a nicer way of hooking in to the code
that draws the background, and then we can get rid of this class.
obviating this fn.
This class is private to NautilusBackground.
This fn is private to NautilusBackground.
*/
typedef GnomeCanvasGroup NautilusBackgroundCanvasGroup;
typedef GnomeCanvasGroupClass NautilusBackgroundCanvasGroupClass;
#define NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP \
(nautilus_background_canvas_group_get_type ())
#define NAUTILUS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroup))
#define NAUTILUS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroupClass))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
GtkType nautilus_background_canvas_group_get_type (void);
void nautilus_background_canvas_group_supplant_root_class (GnomeCanvas *canvas);
#endif /* NAUTILUS_BACKGROUND_CANVAS_GROUP_H */

View file

@ -1335,29 +1335,8 @@ nautilus_background_reset (NautilusBackground *background)
static void
nautilus_background_set_up_canvas (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
/* Attach ourselves to a canvas in a way that will work.
Changing the style is not sufficient.
Since there's no signal to override in GnomeCanvas to control
drawing the background, we change the class of the canvas root.
This gives us a chance to draw the background before any of the
objects draw themselves, and has no effect on the bounds or
anything related to scrolling.
We settled on this after less-than-thrilling results using a
canvas item as the background. The canvas item contributed to
the bounds of the canvas and had to constantly be resized.
*/
if (GNOME_IS_CANVAS (widget)) {
g_assert (GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass
== gtk_type_class (GNOME_TYPE_CANVAS_GROUP)
|| GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass
== gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP));
GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass =
gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP);
nautilus_background_canvas_group_supplant_root_class (GNOME_CANVAS (widget));
}
}

View file

@ -54,6 +54,23 @@ static void nautilus_background_canvas_group_draw (GnomeCanvasItem *item,
static void nautilus_background_canvas_group_render (GnomeCanvasItem *item,
GnomeCanvasBuf *buffer);
typedef GnomeCanvasGroup NautilusBackgroundCanvasGroup;
typedef GnomeCanvasGroupClass NautilusBackgroundCanvasGroupClass;
#define NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP \
(nautilus_background_canvas_group_get_type ())
#define NAUTILUS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroup))
#define NAUTILUS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroupClass))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
GtkType nautilus_background_canvas_group_get_type (void);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusBackgroundCanvasGroup, nautilus_background_canvas_group, GNOME_TYPE_CANVAS_GROUP)
static void
@ -64,9 +81,58 @@ nautilus_background_canvas_group_initialize_class (gpointer klass)
GNOME_CANVAS_ITEM_CLASS (klass)->update = nautilus_background_canvas_group_update;
}
/* This function is for initialization code that's needed both when we're allocating
* a new NautilusBackgroundCanvasGroup object as well as when we're taking over an existing
* GnomeCanvasGroup item (replacing its klass).
*/
static void
nautilus_background_canvas_group_initialize_common (NautilusBackgroundCanvasGroup *canvas_group)
{
/* gnome_canvas_set_dither is only available in gnome-libs > v 1.2.8
*/
#ifdef HAVE_GNOME_CANVAS_SET_DITHER
gnome_canvas_set_dither (GNOME_CANVAS_ITEM (canvas_group)->canvas, GDK_RGB_DITHER_MAX);
#endif
}
static void
nautilus_background_canvas_group_initialize (gpointer object, gpointer klass)
{
/* The way we currently use nautilus_background_canvas_group, assigning
* it to the klass of a root canvas object, circumvents this initialze fn.
*/
nautilus_background_canvas_group_initialize_common (NAUTILUS_BACKGROUND_CANVAS_GROUP (object));
}
void
nautilus_background_canvas_group_supplant_root_class (GnomeCanvas *canvas)
{
/* Attach ourselves to a canvas in a way that will work.
Changing the style is not sufficient.
Since there's no signal to override in GnomeCanvas to control
drawing the background, we change the class of the canvas root.
This gives us a chance to draw the background before any of the
objects draw themselves, and has no effect on the bounds or
anything related to scrolling.
We settled on this after less-than-thrilling results using a
canvas item as the background. The canvas item contributed to
the bounds of the canvas and had to constantly be resized.
*/
g_assert (GNOME_IS_CANVAS (canvas));
if (GTK_OBJECT (canvas->root)->klass != gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP)) {
g_assert (GTK_OBJECT (canvas->root)->klass == gtk_type_class (GNOME_TYPE_CANVAS_GROUP));
GTK_OBJECT (canvas->root)->klass =
gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP);
nautilus_background_canvas_group_initialize_common (NAUTILUS_BACKGROUND_CANVAS_GROUP (canvas->root));
}
}
static void

View file

@ -26,35 +26,21 @@
#ifndef NAUTILUS_BACKGROUND_CANVAS_GROUP_H
#define NAUTILUS_BACKGROUND_CANVAS_GROUP_H
#include "nautilus-background.h"
#include <libgnomeui/gnome-canvas.h>
/* A NautilusBackgroundCanvasGroup is used internally by NautilusBackground to change
the color of a canvas. The reason we have to change the class of a canvas group is
/* nautilus_background_canvas_group_supplant_root_class is used internally by
NautilusBackground to change the class of a canvas in order to customize its
background drawing. The reason we have to change the class of a canvas group is
that the cleanest way to hook into the code that erases the canvas is to be the
root canvas group. But the canvas class creates the root object and doesn't allow
it to be destroyed, so we change the class of the root object in place.
A future version of GnomeCanvas may allow a nicer way of hooking in to the code
that draws the background, and then we can get rid of this class.
obviating this fn.
This class is private to NautilusBackground.
This fn is private to NautilusBackground.
*/
typedef GnomeCanvasGroup NautilusBackgroundCanvasGroup;
typedef GnomeCanvasGroupClass NautilusBackgroundCanvasGroupClass;
#define NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP \
(nautilus_background_canvas_group_get_type ())
#define NAUTILUS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroup))
#define NAUTILUS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP, NautilusBackgroundCanvasGroupClass))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
#define NAUTILUS_IS_BACKGROUND_CANVAS_GROUP_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP))
GtkType nautilus_background_canvas_group_get_type (void);
void nautilus_background_canvas_group_supplant_root_class (GnomeCanvas *canvas);
#endif /* NAUTILUS_BACKGROUND_CANVAS_GROUP_H */

View file

@ -1335,29 +1335,8 @@ nautilus_background_reset (NautilusBackground *background)
static void
nautilus_background_set_up_canvas (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
/* Attach ourselves to a canvas in a way that will work.
Changing the style is not sufficient.
Since there's no signal to override in GnomeCanvas to control
drawing the background, we change the class of the canvas root.
This gives us a chance to draw the background before any of the
objects draw themselves, and has no effect on the bounds or
anything related to scrolling.
We settled on this after less-than-thrilling results using a
canvas item as the background. The canvas item contributed to
the bounds of the canvas and had to constantly be resized.
*/
if (GNOME_IS_CANVAS (widget)) {
g_assert (GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass
== gtk_type_class (GNOME_TYPE_CANVAS_GROUP)
|| GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass
== gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP));
GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass =
gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP);
nautilus_background_canvas_group_supplant_root_class (GNOME_CANVAS (widget));
}
}