Commit 2840833e authored by Darin Adler's avatar Darin Adler
Browse files

Added self-check framework. Added first bits of code for FMDirectory.

parent fc3d3932
2000-01-04 Darin Adler <darin@eazel.com>
* src/Makefile.am, src/check-nautilus,
src/nautilus-self-check-functions.h, src/nautilus-self-checks.c,
src/nautilus-self-checks.h, src/ntl-main.c (main): Added self
checks to nautilus. The checks are invoked by "make check"
(actually need to do "make install check" if you changed
libnautilus) or by invoking the nautilus executable with "--check".
Later, nautilus-self-checks.h may include various helpful
functions for use by the self-checking code.
* src/file-manager/Makefile.am, src/file-manager/fm-directory.c,
src/file-manager/fm-directory.h,
src/file-manager/fm-directory-protected.h,
src/file-manager/fm-vfs-directory.c,
src/file-manager/fm-vfs-directory.h: Started work on an abstract
FMDirectory class that provides a model for what's viewed by the
file manager. Also began work on the FMVFSDirectory concrete child
class that implements this on top of VFS. It's not hooked up yet,
and there's a lot that needs to be done before it's ready to use.
* libnautilus/gdk-extensions.c, libnautilus/gdk-extensions.h:
Renamed functions to use nautilus_ prefix instead of gdk_
prefix. Added a tiny bit of self-check code.
* libnautilus/nautilus-gtk-macros.h: Added some macros (that will
no doubt be controversial) to do some basic GTK object
boilerplate.
2000-01-04 John Sullivan <sullivan@eazel.com>
Made location-entering field handle bogus URIs better
......@@ -147,7 +176,7 @@
harm in repeating them in here and it fixes the problem for
now, but I'd like to know what happened.
* components/html/.cvsignore: Added some generated files.
* components/html/gnome-dialogs.c (glibwww_progress):
* components/html/gnome-dialogs.c: (glibwww_progress):
Replaced an incorrect "%l" in a printf format string with
the correct "%ld".
* libnautilus/.cvsignore: Added some generated files.
......@@ -577,7 +606,6 @@
* src/file-manager/gnome-desktop.c (main): Quiet some warnings.
>>>>>>> 1.33
1999-12-16 Havoc Pennington <hp@redhat.com>
* src/file-manager/gnome-desktop.c (main): warning fixes
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
/* gdk-extensions.c - Possible additions for gdk.
gdk-extensions.c: Graphics routines to augment what's in gdk.
Copyright (C) 1999, 2000 Eazel, Inc.
......@@ -28,10 +28,12 @@
#include "gdk-extensions.h"
#include "../src/nautilus-self-check-functions.h"
#define GRADIENT_BAND_SIZE 4
/**
* gdk_fill_rectangle:
* nautilus_fill_rectangle:
* @drawable: Target to draw into.
* @gc: Graphics context (mainly for clip).
* @rectangle: Rectangle to fill.
......@@ -40,16 +42,16 @@
* Convenient when you have a GdkRectangle structure.
*/
void
gdk_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle)
nautilus_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle)
{
gdk_draw_rectangle (drawable, gc, TRUE,
rectangle->x, rectangle->y, rectangle->width, rectangle->height);
}
/**
* gdk_fill_rectangle_with_color:
* nautilus_fill_rectangle_with_color:
* @drawable: Target to draw into.
* @gc: Graphics context (mainly for clip).
* @rectangle: Rectangle to fill.
......@@ -59,21 +61,21 @@ gdk_fill_rectangle (GdkDrawable *drawable,
* Convenient when you have a GdkRectangle structure.
*/
void
gdk_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color)
nautilus_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color)
{
GdkGCValues saved_values;
gdk_gc_get_values(gc, &saved_values);
gdk_gc_set_foreground (gc, (GdkColor *) color);
gdk_fill_rectangle (drawable, gc, rectangle);
nautilus_fill_rectangle (drawable, gc, rectangle);
gdk_gc_set_foreground (gc, &saved_values.foreground);
}
/**
* gdk_fill_rectangle_with_gradient:
* nautilus_fill_rectangle_with_gradient:
* @drawable: Target to draw into.
* @gc: Graphics context (mainly for clip).
* @colormap: Map to use to allocate colors for gradient.
......@@ -88,13 +90,13 @@ gdk_fill_rectangle_with_color (GdkDrawable *drawable,
* This effect works best on true color displays.
*/
void
gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal)
nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal)
{
GdkRectangle band_box;
gint16 *position;
......@@ -126,12 +128,12 @@ gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
/* Set up a multiplier to use to interpolate the colors as we go. */
multiplier = num_bands <= 1 ? 0.0 : 1.0 / (num_bands - 1);
/* Fill each band with a separate gdk_draw_rectangle call. */
/* Fill each band with a separate nautilus_draw_rectangle call. */
for (band = 0; band < num_bands; band++) {
GdkColor band_color;
/* Compute a new color value for each band. */
gdk_interpolate_color(band * multiplier, start_color, end_color, &band_color);
nautilus_interpolate_color (band * multiplier, start_color, end_color, &band_color);
if (!gdk_colormap_alloc_color (colormap, &band_color, FALSE, TRUE))
g_warning ("could not allocate color for gradient");
else {
......@@ -141,14 +143,14 @@ gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
if (band == num_bands - 1)
*size = last_band_size;
gdk_fill_rectangle_with_color (drawable, gc, &band_box, &band_color);
nautilus_fill_rectangle_with_color (drawable, gc, &band_box, &band_color);
}
*position += *size;
}
}
/**
* gdk_interpolate_color:
* nautilus_interpolate_color:
* @ratio: Place on line between colors to interpolate.
* @start_color: Color for one end.
* @end_color: Color for the other end
......@@ -160,18 +162,46 @@ gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
* human perception.
*/
void
gdk_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color)
nautilus_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color)
{
g_return_if_fail(ratio >= 0.0);
g_return_if_fail(ratio <= 1.0);
g_return_if_fail(start_color);
g_return_if_fail(end_color);
g_return_if_fail(interpolated_color);
g_return_if_fail (ratio >= 0.0);
g_return_if_fail (ratio <= 1.0);
g_return_if_fail (start_color);
g_return_if_fail (end_color);
g_return_if_fail (interpolated_color);
interpolated_color->red = start_color->red * (1.0 - ratio) + end_color->red * ratio;
interpolated_color->green = start_color->green * (1.0 - ratio) + end_color->green * ratio;
interpolated_color->blue = start_color->blue * (1.0 - ratio) + end_color->blue * ratio;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static void
self_check_interpolate(gdouble ratio,
gushort r1, gushort g1, gushort b1,
gushort r2, gushort g2, gushort b2,
gushort r3, gushort g3, gushort b3)
{
GdkColor start_color = { 0, r1, g1, b1 };
GdkColor end_color = { 0, r2, g2, b2 };
GdkColor interpolated_color;
nautilus_interpolate_color(ratio, &start_color, &end_color, &interpolated_color);
g_assert(interpolated_color.red == r3);
g_assert(interpolated_color.red == g3);
g_assert(interpolated_color.red == b3);
}
void
self_check_gdk_extensions (void)
{
self_check_interpolate(0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
self_check_interpolate(0.0, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0);
self_check_interpolate(0.5, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF, 0x7FFF, 0x7FFF);
self_check_interpolate(1.0, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);
}
#endif /* ! NAUTILUS_OMIT_SELF_CHECK */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
/* gdk-extensions.h - Possible additions for gdk.
gdk-extensions.h: Graphics routines to augment what's in gdk.
Copyright (C) 1999, 2000 Eazel, Inc.
......@@ -27,30 +27,23 @@
#include <gdk/gdk.h>
/* Maybe these will get new names that don't start with gdk, but for now,
* I'll name them as if they were part of it.
*/
/* Perhaps we need a separate call that allocates colors for the gradient? */
void gdk_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle);
void gdk_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color);
void gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal_gradient);
void gdk_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color);
void nautilus_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle);
void nautilus_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color);
void nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal_gradient);
void nautilus_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color);
#endif /* GDK_EXTENSIONS_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-gtk-macros.h: Macros to reduce boilerplate when using GTK.
Copyright (C) 1999 Eazel, Inc.
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Darin Adler <darin@eazel.com>
*/
#ifndef NAUTILUS_GTK_MACROS_H
#define NAUTILUS_GTK_MACROS_H
/* Define a get_type function for a GTK class.
Since this is boilerplate, it's better not to repeat it over and over again.
Called like this:
NAUTILUS_DEFINE_GET_TYPE_FUNCTION(NautilusBookmark, nautilus_bookmark, GTK_TYPE_OBJECT)
The parent_class_type parameter is guaranteed to be evaluated only once
so it can be an expression, even an expression that contains a function call.
*/
#define NAUTILUS_DEFINE_GET_TYPE_FUNCTION(class_name, class_name_in_function_format, parent_class_type) \
\
GtkType \
class_name_in_function_format##_get_type (void) \
{ \
static GtkType type; \
\
if (type == 0) { \
static GtkTypeInfo info = { \
#class_name, \
sizeof (class_name), \
sizeof (class_name##Class), \
class_name_in_function_format##_initialize_class, \
class_name_in_function_format##_initialize, \
NULL, \
NULL, \
NULL \
}; \
\
type = gtk_type_unique ((parent_class_type), &info); \
} \
\
return type; \
}
/* Call a parent class version of a signal.
Nice because it documents what it's doing and there is less chance for
a typo. Depends on the parent class pointer having the conventional
name "parent_class".
*/
#define NAUTILUS_CALL_PARENT_CLASS(parent_class_cast_macro, signal, parameters) \
\
G_STMT_START { \
if (parent_class_cast_macro (parent_class)->signal != NULL) \
(* parent_class_cast_macro (parent_class)->signal) parameters; \
} G_STMT_END
#endif /* NAUTILUS_GTK_MACROS_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
/* gdk-extensions.c - Possible additions for gdk.
gdk-extensions.c: Graphics routines to augment what's in gdk.
Copyright (C) 1999, 2000 Eazel, Inc.
......@@ -28,10 +28,12 @@
#include "gdk-extensions.h"
#include "../src/nautilus-self-check-functions.h"
#define GRADIENT_BAND_SIZE 4
/**
* gdk_fill_rectangle:
* nautilus_fill_rectangle:
* @drawable: Target to draw into.
* @gc: Graphics context (mainly for clip).
* @rectangle: Rectangle to fill.
......@@ -40,16 +42,16 @@
* Convenient when you have a GdkRectangle structure.
*/
void
gdk_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle)
nautilus_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle)
{
gdk_draw_rectangle (drawable, gc, TRUE,
rectangle->x, rectangle->y, rectangle->width, rectangle->height);
}
/**
* gdk_fill_rectangle_with_color:
* nautilus_fill_rectangle_with_color:
* @drawable: Target to draw into.
* @gc: Graphics context (mainly for clip).
* @rectangle: Rectangle to fill.
......@@ -59,21 +61,21 @@ gdk_fill_rectangle (GdkDrawable *drawable,
* Convenient when you have a GdkRectangle structure.
*/
void
gdk_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color)
nautilus_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color)
{
GdkGCValues saved_values;
gdk_gc_get_values(gc, &saved_values);
gdk_gc_set_foreground (gc, (GdkColor *) color);
gdk_fill_rectangle (drawable, gc, rectangle);
nautilus_fill_rectangle (drawable, gc, rectangle);
gdk_gc_set_foreground (gc, &saved_values.foreground);
}
/**
* gdk_fill_rectangle_with_gradient:
* nautilus_fill_rectangle_with_gradient:
* @drawable: Target to draw into.
* @gc: Graphics context (mainly for clip).
* @colormap: Map to use to allocate colors for gradient.
......@@ -88,13 +90,13 @@ gdk_fill_rectangle_with_color (GdkDrawable *drawable,
* This effect works best on true color displays.
*/
void
gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal)
nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal)
{
GdkRectangle band_box;
gint16 *position;
......@@ -126,12 +128,12 @@ gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
/* Set up a multiplier to use to interpolate the colors as we go. */
multiplier = num_bands <= 1 ? 0.0 : 1.0 / (num_bands - 1);
/* Fill each band with a separate gdk_draw_rectangle call. */
/* Fill each band with a separate nautilus_draw_rectangle call. */
for (band = 0; band < num_bands; band++) {
GdkColor band_color;
/* Compute a new color value for each band. */
gdk_interpolate_color(band * multiplier, start_color, end_color, &band_color);
nautilus_interpolate_color (band * multiplier, start_color, end_color, &band_color);
if (!gdk_colormap_alloc_color (colormap, &band_color, FALSE, TRUE))
g_warning ("could not allocate color for gradient");
else {
......@@ -141,14 +143,14 @@ gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
if (band == num_bands - 1)
*size = last_band_size;
gdk_fill_rectangle_with_color (drawable, gc, &band_box, &band_color);
nautilus_fill_rectangle_with_color (drawable, gc, &band_box, &band_color);
}
*position += *size;
}
}
/**
* gdk_interpolate_color:
* nautilus_interpolate_color:
* @ratio: Place on line between colors to interpolate.
* @start_color: Color for one end.
* @end_color: Color for the other end
......@@ -160,18 +162,46 @@ gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
* human perception.
*/
void
gdk_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color)
nautilus_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color)
{
g_return_if_fail(ratio >= 0.0);
g_return_if_fail(ratio <= 1.0);
g_return_if_fail(start_color);
g_return_if_fail(end_color);
g_return_if_fail(interpolated_color);
g_return_if_fail (ratio >= 0.0);
g_return_if_fail (ratio <= 1.0);
g_return_if_fail (start_color);
g_return_if_fail (end_color);
g_return_if_fail (interpolated_color);
interpolated_color->red = start_color->red * (1.0 - ratio) + end_color->red * ratio;
interpolated_color->green = start_color->green * (1.0 - ratio) + end_color->green * ratio;
interpolated_color->blue = start_color->blue * (1.0 - ratio) + end_color->blue * ratio;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static void
self_check_interpolate(gdouble ratio,
gushort r1, gushort g1, gushort b1,
gushort r2, gushort g2, gushort b2,
gushort r3, gushort g3, gushort b3)
{
GdkColor start_color = { 0, r1, g1, b1 };
GdkColor end_color = { 0, r2, g2, b2 };
GdkColor interpolated_color;
nautilus_interpolate_color(ratio, &start_color, &end_color, &interpolated_color);
g_assert(interpolated_color.red == r3);
g_assert(interpolated_color.red == g3);
g_assert(interpolated_color.red == b3);
}
void
self_check_gdk_extensions (void)
{
self_check_interpolate(0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
self_check_interpolate(0.0, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0);
self_check_interpolate(0.5, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF, 0x7FFF, 0x7FFF);
self_check_interpolate(1.0, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);
}
#endif /* ! NAUTILUS_OMIT_SELF_CHECK */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
/* gdk-extensions.h - Possible additions for gdk.
gdk-extensions.h: Graphics routines to augment what's in gdk.
Copyright (C) 1999, 2000 Eazel, Inc.
......@@ -27,30 +27,23 @@
#include <gdk/gdk.h>
/* Maybe these will get new names that don't start with gdk, but for now,
* I'll name them as if they were part of it.
*/
/* Perhaps we need a separate call that allocates colors for the gradient? */
void gdk_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle);
void gdk_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color);
void gdk_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal_gradient);
void gdk_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color);
void nautilus_fill_rectangle (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle);
void nautilus_fill_rectangle_with_color (GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
const GdkColor *color);
void nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable,
GdkGC *gc,
GdkColormap *colormap,
const GdkRectangle *rectangle,
const GdkColor *start_color,
const GdkColor *end_color,
gboolean horizontal_gradient);
void nautilus_interpolate_color (gdouble ratio,
const GdkColor *start_color,
const GdkColor *end_color,
GdkColor *interpolated_color);
#endif /* GDK_EXTENSIONS_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-gtk-macros.h: Macros to reduce boilerplate when using GTK.
Copyright (C) 1999 Eazel, Inc.
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