diff options
author | monsta <[email protected]> | 2016-08-21 03:29:50 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-08-22 16:40:21 +0300 |
commit | 3c6122df79f4d6e86d7afa0e6c4b64403de7bc44 (patch) | |
tree | bd06579cadb62b290fb983f61a02e4dedb3f64b1 /eel | |
parent | 6f295db45ebcb52c6e9ad39f8d639e35f88c5ef5 (diff) | |
download | caja-3c6122df79f4d6e86d7afa0e6c4b64403de7bc44.tar.bz2 caja-3c6122df79f4d6e86d7afa0e6c4b64403de7bc44.tar.xz |
drop a large amount of completely unused code
Diffstat (limited to 'eel')
-rw-r--r-- | eel/Makefile.am | 2 | ||||
-rw-r--r-- | eel/eel-art-gtk-extensions.c | 280 | ||||
-rw-r--r-- | eel/eel-art-gtk-extensions.h | 21 | ||||
-rw-r--r-- | eel/eel-background.c | 1 | ||||
-rw-r--r-- | eel/eel-canvas-rect-ellipse.c | 225 | ||||
-rw-r--r-- | eel/eel-canvas-rect-ellipse.h | 32 | ||||
-rw-r--r-- | eel/eel-canvas-util.c | 426 | ||||
-rw-r--r-- | eel/eel-canvas-util.h | 110 | ||||
-rw-r--r-- | eel/eel-debug.c | 28 | ||||
-rw-r--r-- | eel/eel-debug.h | 1 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.c | 38 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.h | 6 | ||||
-rw-r--r-- | eel/eel-gtk-extensions.h | 2 | ||||
-rw-r--r-- | eel/eel-mate-extensions.c | 6 | ||||
-rw-r--r-- | eel/eel-mate-extensions.h | 1 | ||||
-rw-r--r-- | eel/eel-stock-dialogs.c | 36 | ||||
-rw-r--r-- | eel/eel-stock-dialogs.h | 7 | ||||
-rw-r--r-- | eel/eel-string.c | 216 | ||||
-rw-r--r-- | eel/eel-string.h | 16 | ||||
-rw-r--r-- | eel/eel-xml-extensions.c | 73 | ||||
-rw-r--r-- | eel/eel-xml-extensions.h | 6 |
21 files changed, 0 insertions, 1533 deletions
diff --git a/eel/Makefile.am b/eel/Makefile.am index b2f35e95..d7a7515a 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -37,7 +37,6 @@ eel_headers = \ eel-background.h \ eel-background-box.h \ eel-canvas.h \ - eel-canvas-util.h \ eel-canvas-rect-ellipse.h \ eel-debug.h \ eel-editable-label.h \ @@ -67,7 +66,6 @@ libeel_2_la_SOURCES = \ eel-background.c \ eel-background-box.c \ eel-canvas.c \ - eel-canvas-util.c \ eel-canvas-rect-ellipse.c \ eel-debug.c \ eel-editable-label.c \ diff --git a/eel/eel-art-gtk-extensions.c b/eel/eel-art-gtk-extensions.c index 5e7f4dab..610cf129 100644 --- a/eel/eel-art-gtk-extensions.c +++ b/eel/eel-art-gtk-extensions.c @@ -25,116 +25,6 @@ #include <config.h> #include "eel-art-gtk-extensions.h" -#include <gdk/gdkx.h> - -#if !GTK_CHECK_VERSION(3,0,0) -#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) -#endif - -/** - * eel_gdk_rectangle_to_eel_irect: - * @gdk_rectangle: The source GdkRectangle. - * - * Return value: An EelIRect representation of the GdkRectangle. - * - * This is a very simple conversion of rectangles from the Gdk to the Libeel - * universe. This is useful in code that does clipping (or other operations) - * using libeel and has a GdkRectangle to work with - for example expose_event() - * in GtkWidget's. - */ -EelIRect -eel_gdk_rectangle_to_eel_irect (GdkRectangle gdk_rectangle) -{ - EelIRect rectangle; - - rectangle.x0 = gdk_rectangle.x; - rectangle.y0 = gdk_rectangle.y; - rectangle.x1 = rectangle.x0 + (int) gdk_rectangle.width; - rectangle.y1 = rectangle.y0 + (int) gdk_rectangle.height; - - return rectangle; -} - -/** - * eel_screen_get_dimensions: - * - * Return value: The screen dimensions. - * - */ -EelDimensions -eel_screen_get_dimensions (void) -{ - EelDimensions screen_dimensions; - - screen_dimensions.width = gdk_screen_width (); - screen_dimensions.height = gdk_screen_height (); - - g_assert (screen_dimensions.width > 0); - g_assert (screen_dimensions.height > 0); - - return screen_dimensions; -} - -/** - * eel_gdk_window_get_bounds: - * @gdk_window: The source GdkWindow. - * - * Return value: An EelIRect representation of the given GdkWindow's geometry - * relative to its parent in the Gdk window hierarchy. - * - */ -EelIRect -eel_gdk_window_get_bounds (GdkWindow *gdk_window) -{ - EelIRect bounds; - int width; - int height; - - g_return_val_if_fail (gdk_window != NULL, eel_irect_empty); - - gdk_window_get_position (gdk_window, &bounds.x0, &bounds.y0); - - width = gdk_window_get_width(gdk_window); - height = gdk_window_get_height(gdk_window); - - bounds.x1 = bounds.x0 + width; - bounds.y1 = bounds.y0 + height; - - return bounds; -} - -/** - * eel_gdk_window_get_bounds: - * @gdk_window: The source GdkWindow. - * - * Return value: An EelIRect representation of the given GdkWindow's geometry - * relative to the screen. - * - */ -EelIRect -eel_gdk_window_get_screen_relative_bounds (GdkWindow *gdk_window) -{ - EelIRect screen_bounds; - int width; - int height; - - g_return_val_if_fail (gdk_window != NULL, eel_irect_empty); - - if (!gdk_window_get_origin (gdk_window, - &screen_bounds.x0, - &screen_bounds.y0)) - { - return eel_irect_empty; - } - - width = gdk_window_get_width(gdk_window); - height = gdk_window_get_height(gdk_window); - - screen_bounds.x1 = screen_bounds.x0 + width; - screen_bounds.y1 = screen_bounds.y0 + height; - - return screen_bounds; -} /** * eel_gtk_widget_get_bounds: @@ -178,173 +68,3 @@ eel_gtk_widget_get_dimensions (GtkWidget *gtk_widget) return dimensions; } - -/** - * eel_gtk_widget_get_preferred_dimensions: - * @gtk_widget: The source GtkWidget. - * - * Return value: The widget's preferred dimensions. The preferred dimensions are - * computed by calling the widget's 'size_request' method and thus - * could potentially be expensive for complicated widgets. - */ -EelDimensions -eel_gtk_widget_get_preferred_dimensions (GtkWidget *gtk_widget) -{ - GtkRequisition requisition; - EelDimensions preferred_dimensions; - - g_return_val_if_fail (GTK_IS_WIDGET (gtk_widget), eel_dimensions_empty); - - gtk_widget_get_preferred_size (gtk_widget, &requisition, NULL); - - preferred_dimensions.width = (int) requisition.width; - preferred_dimensions.height = (int) requisition.height; - - return preferred_dimensions; -} - -/** - * eel_gdk_window_clip_dirty_area_to_screen: - * @gdk_window: The GdkWindow that the damage occured on. - * @dirty_area: The dirty area as an EelIRect. - * - * Return value: An EelIRect of the dirty area clipped to the screen. - * - * This function is useful to do less work in expose_event() GtkWidget methods. - * It also ensures that any drawing that the widget does is actually onscreen. - */ -EelIRect -eel_gdk_window_clip_dirty_area_to_screen (GdkWindow *gdk_window, - EelIRect dirty_area) -{ - EelIRect clipped; - EelDimensions screen_dimensions; - EelIRect screen_relative_bounds; - int dirty_width; - int dirty_height; - - g_return_val_if_fail (gdk_window != NULL, eel_irect_empty); - - dirty_width = dirty_area.x1 - dirty_area.x0; - dirty_height = dirty_area.y1 - dirty_area.y0; - - g_return_val_if_fail (dirty_width > 0, eel_irect_empty); - g_return_val_if_fail (dirty_height > 0, eel_irect_empty); - - screen_dimensions = eel_screen_get_dimensions (); - screen_relative_bounds = eel_gdk_window_get_screen_relative_bounds (gdk_window); - - /* Window is obscured by left edge of screen */ - if ((screen_relative_bounds.x0 + dirty_area.x0) < 0) - { - int clipped_width = screen_relative_bounds.x0 + dirty_area.x0 + dirty_width; - clipped.x0 = dirty_area.x0 + dirty_width - clipped_width; - clipped.x1 = clipped.x0 + clipped_width; - } - else - { - clipped.x0 = dirty_area.x0; - clipped.x1 = clipped.x0 + dirty_width; - } - - /* Window is obscured by right edge of screen */ - if (screen_relative_bounds.x1 > screen_dimensions.width) - { - int obscured_width; - - obscured_width = - screen_relative_bounds.x0 + dirty_area.x0 + dirty_width - screen_dimensions.width; - - if (obscured_width > 0) - { - clipped.x1 -= obscured_width; - } - } - - /* Window is obscured by top edge of screen */ - if ((screen_relative_bounds.y0 + dirty_area.y0) < 0) - { - int clipped_height = screen_relative_bounds.y0 + dirty_area.y0 + dirty_height; - clipped.y0 = dirty_area.y0 + dirty_height - clipped_height; - clipped.y1 = clipped.y0 + clipped_height; - } - else - { - clipped.y0 = dirty_area.y0; - clipped.y1 = clipped.y0 + dirty_height; - } - - /* Window is obscured by bottom edge of screen */ - if (screen_relative_bounds.y1 > screen_dimensions.height) - { - int obscured_height; - - obscured_height = - screen_relative_bounds.y0 + dirty_area.y0 + dirty_height - screen_dimensions.height; - - if (obscured_height > 0) - { - clipped.y1 -= obscured_height; - } - } - - if (eel_irect_is_empty (&clipped)) - { - clipped = eel_irect_empty; - } - - return clipped; -} - -GdkRectangle -eel_irect_to_gdk_rectangle (EelIRect rectangle) -{ - GdkRectangle gdk_rect; - - gdk_rect.x = rectangle.x0; - gdk_rect.y = rectangle.y0; - gdk_rect.width = eel_irect_get_width (rectangle); - gdk_rect.height = eel_irect_get_height (rectangle); - - return gdk_rect; -} - -EelDimensions -eel_gdk_window_get_dimensions (GdkWindow *gdk_window) -{ - EelDimensions dimensions; - - g_return_val_if_fail (gdk_window != NULL, eel_dimensions_empty); - - dimensions.width = gdk_window_get_width(gdk_window); - dimensions.height = gdk_window_get_height(gdk_window); - - return dimensions; -} - -EelIPoint -eel_gdk_get_pointer_position (void) -{ - - EelIPoint position; -#if GTK_CHECK_VERSION (3, 0, 0) - GdkDeviceManager *manager; - GdkDevice *pointer; - - manager = gdk_display_get_device_manager (gdk_window_get_display (gdk_get_default_root_window ())); - pointer = gdk_device_manager_get_client_pointer (manager); - gdk_window_get_device_position (gdk_get_default_root_window (), - pointer, - &position.x, - &position.y, - NULL); -#else - - gdk_window_get_pointer (gdk_get_default_root_window (), - &position.x, - &position.y, - NULL); -#endif - - return position; -} diff --git a/eel/eel-art-gtk-extensions.h b/eel/eel-art-gtk-extensions.h index aea709c3..fbb554d5 100644 --- a/eel/eel-art-gtk-extensions.h +++ b/eel/eel-art-gtk-extensions.h @@ -35,7 +35,6 @@ #ifndef EEL_ART_GTK_EXTENSIONS_H #define EEL_ART_GTK_EXTENSIONS_H -#include <eel/eel-gdk-extensions.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-art-extensions.h> @@ -43,29 +42,9 @@ extern "C" { #endif - /* Convert between GdkRectangle and EelIRect and back */ - GdkRectangle eel_irect_to_gdk_rectangle (EelIRect rectangle); - EelIRect eel_gdk_rectangle_to_eel_irect (GdkRectangle gdk_rectangle); - EelDimensions eel_screen_get_dimensions (void); - - /* GdkWindow parent-relative bounds */ - EelIRect eel_gdk_window_get_bounds (GdkWindow *window); - - /* GdkWindow dimensions */ - EelDimensions eel_gdk_window_get_dimensions (GdkWindow *window); - - /* GdkWindow screen parent-relative bounds */ - EelIRect eel_gdk_window_get_screen_relative_bounds (GdkWindow *window); - - /* Clip a dirty area (from exposures) to the on screen parts of a GdkWindow */ - EelIRect eel_gdk_window_clip_dirty_area_to_screen (GdkWindow *window, - EelIRect dirty_area); - /* GtkWidget bounds and dimensions */ EelIRect eel_gtk_widget_get_bounds (GtkWidget *widget); EelDimensions eel_gtk_widget_get_dimensions (GtkWidget *widget); - EelDimensions eel_gtk_widget_get_preferred_dimensions (GtkWidget *widget); - EelIPoint eel_gdk_get_pointer_position (void); #ifdef __cplusplus } diff --git a/eel/eel-background.c b/eel/eel-background.c index d62bde6e..f652e98e 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -31,7 +31,6 @@ #include "eel-lib-self-check-functions.h" #include <gtk/gtk.h> #include <eel/eel-canvas.h> -#include <eel/eel-canvas-util.h> #if GTK_CHECK_VERSION (3, 0, 0) # include <cairo-xlib.h> #endif diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index 0ed0c826..b1300679 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -35,7 +35,6 @@ #include <config.h> #include <math.h> #include "eel-canvas-rect-ellipse.h" -#include "eel-canvas-util.h" #include <string.h> #ifdef HAVE_RENDER @@ -88,7 +87,6 @@ static void eel_canvas_re_unrealize (EelCanvasItem *item); static void eel_canvas_re_bounds (EelCanvasItem *item, double *x1, double *y1, double *x2, double *y2); static void eel_canvas_re_translate (EelCanvasItem *item, double dx, double dy); static void eel_canvas_rect_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, int flags); -static void eel_canvas_ellipse_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, int flags); typedef struct { @@ -1073,229 +1071,6 @@ eel_canvas_rect_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, gint } } -/* Ellipse item */ - - -static void eel_canvas_ellipse_class_init (EelCanvasEllipseClass *klass); - -#if GTK_CHECK_VERSION(3,0,0) -static void eel_canvas_ellipse_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); -#else -static void eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); -#endif -static double eel_canvas_ellipse_point (EelCanvasItem *item, double x, double y, int cx, int cy, - EelCanvasItem **actual_item); - - -GType -eel_canvas_ellipse_get_type (void) -{ - static GType ellipse_type = 0; - - if (!ellipse_type) - { - GTypeInfo ellipse_info = - { - sizeof (EelCanvasEllipseClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) eel_canvas_ellipse_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EelCanvasEllipse), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL - - }; - - ellipse_type = g_type_register_static (eel_canvas_re_get_type (), - "EelCanvasEllipse", - &ellipse_info, - 0); - } - - return ellipse_type; -} - -static void -eel_canvas_ellipse_class_init (EelCanvasEllipseClass *klass) -{ - EelCanvasItemClass *item_class; - - item_class = (EelCanvasItemClass *) klass; - - item_class->draw = eel_canvas_ellipse_draw; - item_class->point = eel_canvas_ellipse_point; - item_class->update = eel_canvas_ellipse_update; -} - -static void -#if GTK_CHECK_VERSION(3,0,0) -eel_canvas_ellipse_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region) -#else -eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) -#endif -{ - EelCanvasRE *re; - int x1, y1, x2, y2; - double i2w_dx, i2w_dy; - - re = EEL_CANVAS_RE (item); - - /* Get canvas pixel coordinates */ - - i2w_dx = 0.0; - i2w_dy = 0.0; - eel_canvas_item_i2w (item, &i2w_dx, &i2w_dy); - - eel_canvas_w2c (item->canvas, - re->x1 + i2w_dx, - re->y1 + i2w_dy, - &x1, &y1); - eel_canvas_w2c (item->canvas, - re->x2 + i2w_dx, - re->y2 + i2w_dy, - &x2, &y2); - -#if GTK_CHECK_VERSION(3,0,0) - cairo_save (cr); -#else - cairo_t *cr = gdk_cairo_create (drawable); - gdk_cairo_region (cr, expose->region); - cairo_clip (cr); -#endif - - cairo_save (cr); - cairo_translate (cr, (x1 + x2) / 2., (y1 + y2) / 2.); - cairo_scale (cr, (x2 - x1), (y2 - y1)); - cairo_arc (cr, 0, 0, 1, 0, 2 * G_PI); - cairo_restore (cr); - - if (re->fill_set) - { -#if GTK_CHECK_VERSION(3,0,0) - eel_canvas_set_source_color (cr, &re->fill_color); -#else - eel_canvas_set_source_color (cr, re->fill_color); -#endif - cairo_fill_preserve (cr); - } - - if (re->outline_set) - { -#if GTK_CHECK_VERSION(3,0,0) - eel_canvas_set_source_color (cr, &re->outline_color); -#else - eel_canvas_set_source_color (cr, re->outline_color); -#endif - if (re->width_pixels) { - cairo_set_line_width (cr, (int) re->width); - } else { - cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5)); - } - - cairo_stroke_preserve (cr); - } - -#if GTK_CHECK_VERSION(3,0,0) - cairo_restore (cr); -#else - cairo_destroy (cr); -#endif -} - -static double -eel_canvas_ellipse_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item) -{ - EelCanvasRE *re; - double dx, dy; - double scaled_dist; - double outline_dist; - double center_dist; - double width; - double a, b; - double diamx, diamy; - - re = EEL_CANVAS_RE (item); - - *actual_item = item; - - if (re->outline_set) - { - if (re->width_pixels) - width = re->width / item->canvas->pixels_per_unit; - else - width = re->width; - } - else - width = 0.0; - - /* Compute the distance between the center of the ellipse and the point, with the ellipse - * considered as being scaled to a circle. - */ - - dx = x - (re->x1 + re->x2) / 2.0; - dy = y - (re->y1 + re->y2) / 2.0; - center_dist = sqrt (dx * dx + dy * dy); - - a = dx / ((re->x2 + width - re->x1) / 2.0); - b = dy / ((re->y2 + width - re->y1) / 2.0); - scaled_dist = sqrt (a * a + b * b); - - /* If the scaled distance is greater than 1, then we are outside. Compute the distance from - * the point to the edge of the circle, then scale back to the original un-scaled coordinate - * system. - */ - - if (scaled_dist > 1.0) - return (center_dist / scaled_dist) * (scaled_dist - 1.0); - - /* We are inside the outer edge of the ellipse. If it is filled, then we are "inside". - * Otherwise, do the same computation as above, but also check whether we are inside the - * outline. - */ - - if (re->fill_set) - return 0.0; - - if (scaled_dist > EEL_CANVAS_EPSILON) - outline_dist = (center_dist / scaled_dist) * (1.0 - scaled_dist) - width; - else - { - /* Handle very small distance */ - - diamx = re->x2 - re->x1; - diamy = re->y2 - re->y1; - - if (diamx < diamy) - outline_dist = (diamx - width) / 2.0; - else - outline_dist = (diamy - width) / 2.0; - } - - if (outline_dist < 0.0) - return 0.0; - - return outline_dist; -} - -static void -eel_canvas_ellipse_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, gint flags) -{ - EelCanvasRE *re; - double x0, y0, x1, y1; - -#ifdef VERBOSE - g_print ("eel_canvas_sllipse_update item %x\n", item); -#endif - - eel_canvas_re_update_shared (item, i2w_dx, i2w_dy, flags); - re = EEL_CANVAS_RE (item); - - get_bounds (re, &x0, &y0, &x1, &y1); - eel_canvas_update_bbox (item, x0, y0, x1, y1); -} - static int rect_empty (const Rect *src) { diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h index d54de4d2..2d1dac59 100644 --- a/eel/eel-canvas-rect-ellipse.h +++ b/eel/eel-canvas-rect-ellipse.h @@ -143,38 +143,6 @@ extern "C" { /* Standard Gtk function */ GType eel_canvas_rect_get_type (void) G_GNUC_CONST; - - /* Ellipse item. No configurable or queryable arguments are available (use those in - * EelCanvasRE). - */ - - -#define EEL_TYPE_CANVAS_ELLIPSE (eel_canvas_ellipse_get_type ()) -#define EEL_CANVAS_ELLIPSE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_CANVAS_ELLIPSE, EelCanvasEllipse)) -#define EEL_CANVAS_ELLIPSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_CANVAS_ELLIPSE, EelCanvasEllipseClass)) -#define EEL_IS_CANVAS_ELLIPSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_CANVAS_ELLIPSE)) -#define EEL_IS_CANVAS_ELLIPSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_CANVAS_ELLIPSE)) -#define EEL_CANVAS_ELLIPSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_CANVAS_ELLIPSE, EelCanvasEllipseClass)) - - - typedef struct _EelCanvasEllipse EelCanvasEllipse; - typedef struct _EelCanvasEllipseClass EelCanvasEllipseClass; - - struct _EelCanvasEllipse - { - EelCanvasRE re; - }; - - struct _EelCanvasEllipseClass - { - EelCanvasREClass parent_class; - }; - - - /* Standard Gtk function */ - GType eel_canvas_ellipse_get_type (void) G_GNUC_CONST; - - #ifdef __cplusplus } #endif diff --git a/eel/eel-canvas-util.c b/eel/eel-canvas-util.c deleted file mode 100644 index 26e2b29e..00000000 --- a/eel/eel-canvas-util.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation - * All rights reserved. - * - * This file is part of the Mate Library. - * - * The Mate Library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The Mate Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Mate Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -/* - @NOTATION@ - */ -/* Miscellaneous utility functions for the EelCanvas widget - * - * EelCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is - * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties. - * - * - * Author: Federico Mena <[email protected]> - */ - -#include <config.h> - -#include <sys/types.h> -#include <glib.h> -#include <math.h> - -#include "eel-canvas.h" -#include "eel-canvas-util.h" - -/* - * Ok, so some systems require magic incantations for M_PI to be defined. - * It's not important enough to worry about. - */ -#ifndef M_PI -#define M_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117 -#endif - -/** - * eel_canvas_points_new: - * @num_points: The number of points to allocate space for in the array. - * - * Creates a structure that should be used to pass an array of points to - * items. - * - * Return value: A newly-created array of points. It should be filled in - * by the user. - **/ -EelCanvasPoints * -eel_canvas_points_new (int num_points) -{ - EelCanvasPoints *points; - - g_return_val_if_fail (num_points > 1, NULL); - - points = g_new (EelCanvasPoints, 1); - points->num_points = num_points; - points->coords = g_new (double, 2 * num_points); - points->ref_count = 1; - - return points; -} - -/** - * eel_canvas_points_ref: - * @points: A canvas points structure. - * - * Increases the reference count of the specified points structure. - * - * Return value: The canvas points structure itself. - **/ -EelCanvasPoints * -eel_canvas_points_ref (EelCanvasPoints *points) -{ - g_return_val_if_fail (points != NULL, NULL); - - points->ref_count += 1; - return points; -} - -/** - * eel_canvas_points_free: - * @points: A canvas points structure. - * - * Decreases the reference count of the specified points structure. If it - * reaches zero, then the structure is freed. - **/ -void -eel_canvas_points_free (EelCanvasPoints *points) -{ - g_return_if_fail (points != NULL); - - points->ref_count -= 1; - if (points->ref_count == 0) - { - g_free (points->coords); - g_free (points); - } -} - -/** - * eel_canvas_get_miter_points: - * @x1: X coordinate of the first point - * @y1: Y coordinate of the first point - * @x2: X coordinate of the second (angle) point - * @y2: Y coordinate of the second (angle) point - * @x3: X coordinate of the third point - * @y3: Y coordinate of the third point - * @width: Width of the line - * @mx1: The X coordinate of the first miter point is returned here. - * @my1: The Y coordinate of the first miter point is returned here. - * @mx2: The X coordinate of the second miter point is returned here. - * @my2: The Y coordinate of the second miter point is returned here. - * - * Given three points forming an angle, computes the coordinates of the inside - * and outside points of the mitered corner formed by a line of a given width at - * that angle. - * - * Return value: FALSE if the angle is less than 11 degrees (this is the same - * threshold as X uses. If this occurs, the return points are not modified. - * Otherwise, returns TRUE. - **/ -int -eel_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3, - double width, - double *mx1, double *my1, double *mx2, double *my2) -{ - double theta1; /* angle of segment p2-p1 */ - double theta2; /* angle of segment p2-p3 */ - double theta; /* angle between line segments */ - double theta3; /* angle that bisects theta1 and theta2 and points to p1 */ - double dist; /* distance of miter points from p2 */ - double dx, dy; /* x and y offsets corresponding to dist */ - - double ELEVEN_DEGREES = 11.0 * M_PI / 180.0; - - /* Degenerate cases. */ - if ((x1 == x2 && y1 == y2) || (x2 == x3 && y2 == y3)) - return FALSE; - - theta1 = atan2 (y1 - y2, x1 - x2); - theta2 = atan2 (y3 - y2, x3 - x2); - theta = theta1 - theta2; - - /* Normalize to (-pi; pi]. */ - if (theta > M_PI) - theta -= 2.0 * M_PI; - else if (theta <= -M_PI) - theta += 2.0 * M_PI; - - if (fabs (theta) < ELEVEN_DEGREES) - return FALSE; - - dist = fabs (0.5 * width / sin (0.5 * theta)); - - theta3 = (theta1 + theta2) / 2.0; - if (sin (theta3 - theta1) > 0.0) - theta3 += M_PI; - - dx = dist * cos (theta3); - dy = dist * sin (theta3); - - *mx1 = x2 + dx; - *mx2 = x2 - dx; - *my1 = y2 + dy; - *my2 = y2 - dy; - - return TRUE; -} - -/** - * eel_canvas_get_butt_points: - * @x1: X coordinate of first point in the line - * @y1: Y cooordinate of first point in the line - * @x2: X coordinate of second point (endpoint) of the line - * @y2: Y coordinate of second point (endpoint) of the line - * @width: Width of the line - * @project: Whether the butt points should project out by width/2 distance - * @bx1: X coordinate of first butt point is returned here - * @by1: Y coordinate of first butt point is returned here - * @bx2: X coordinate of second butt point is returned here - * @by2: Y coordinate of second butt point is returned here - * - * Computes the butt points of a line segment. - **/ -void -eel_canvas_get_butt_points (double x1, double y1, double x2, double y2, - double width, int project, - double *bx1, double *by1, double *bx2, double *by2) -{ - double length; - double dx, dy; - - width *= 0.5; - dx = x2 - x1; - dy = y2 - y1; - length = sqrt (dx * dx + dy * dy); - - if (length < EEL_CANVAS_EPSILON) - { - *bx1 = *bx2 = x2; - *by1 = *by2 = y2; - } - else - { - dx = -width * (y2 - y1) / length; - dy = width * (x2 - x1) / length; - - *bx1 = x2 + dx; - *bx2 = x2 - dx; - *by1 = y2 + dy; - *by2 = y2 - dy; - - if (project) - { - *bx1 += dy; - *bx2 += dy; - *by1 -= dx; - *by2 -= dx; - } - } -} - -/** - * eel_canvas_polygon_to_point: - * @poly: Vertices of the polygon. X coordinates are in the even indices, and Y - * coordinates are in the odd indices - * @num_points: Number of points in the polygon - * @x: X coordinate of the point - * @y: Y coordinate of the point - * - * Computes the distance between a point and a polygon. - * - * Return value: The distance from the point to the polygon, or zero if the - * point is inside the polygon. - **/ -double -eel_canvas_polygon_to_point (double *poly, int num_points, double x, double y) -{ - double best; - int intersections; - int i; - double *p; - double dx, dy; - - /* Iterate through all the edges in the polygon, updating best and intersections. - * - * When computing intersections, include left X coordinate of line within its range, but not - * Y coordinate. Otherwise if the point lies exactly below a vertex we'll count it as two - * intersections. - */ - - best = 1.0e36; - if (poly == NULL) - return best; - - intersections = 0; - - for (i = num_points, p = poly; i > 1; i--, p += 2) - { - double px, py, dist; - - /* Compute the point on the current edge closest to the point and update the - * intersection count. This must be done separately for vertical edges, horizontal - * edges, and others. - */ - - if (p[2] == p[0]) - { - /* Vertical edge */ - - px = p[0]; - - if (p[1] >= p[3]) - { - py = MIN (p[1], y); - py = MAX (py, p[3]); - } - else - { - py = MIN (p[3], y); - py = MAX (py, p[1]); - } - } - else if (p[3] == p[1]) - { - /* Horizontal edge */ - - py = p[1]; - - if (p[0] >= p[2]) - { - px = MIN (p[0], x); - px = MAX (px, p[2]); - - if ((y < py) && (x < p[0]) && (x >= p[2])) - intersections++; - } - else - { - px = MIN (p[2], x); - px = MAX (px, p[0]); - - if ((y < py) && (x < p[2]) && (x >= p[0])) - intersections++; - } - } - else - { - double m1, b1, m2, b2; - int lower; - - /* Diagonal edge. Convert the edge to a line equation (y = m1*x + b1), then - * compute a line perpendicular to this edge but passing through the point, - * (y = m2*x + b2). - */ - - m1 = (p[3] - p[1]) / (p[2] - p[0]); - b1 = p[1] - m1 * p[0]; - - m2 = -1.0 / m1; - b2 = y - m2 * x; - - px = (b2 - b1) / (m1 - m2); - py = m1 * px + b1; - - if (p[0] > p[2]) - { - if (px > p[0]) - { - px = p[0]; - py = p[1]; - } - else if (px < p[2]) - { - px = p[2]; - py = p[3]; - } - } - else - { - if (px > p[2]) - { - px = p[2]; - py = p[3]; - } - else if (px < p[0]) - { - px = p[0]; - py = p[1]; - } - } - - lower = (m1 * x + b1) > y; - - if (lower && (x >= MIN (p[0], p[2])) && (x < MAX (p[0], p[2]))) - intersections++; - } - - /* Compute the distance to the closest point, and see if that is the best so far */ - - dx = x - px; - dy = y - py; - dist = sqrt (dx * dx + dy * dy); - if (dist < best) - best = dist; - } - - /* We've processed all the points. If the number of intersections is odd, the point is - * inside the polygon. - */ - - if (intersections & 0x1) - return 0.0; - else - return best; -} - -/** - * eel_canvas_item_reset_bounds: - * @item: A canvas item - * - * Resets the bounding box of a canvas item to an empty rectangle. - **/ -void -eel_canvas_item_reset_bounds (EelCanvasItem *item) -{ - item->x1 = 0.0; - item->y1 = 0.0; - item->x2 = 0.0; - item->y2 = 0.0; -} - -/** - * eel_canvas_update_bbox: - * @canvas: the canvas needing update - * @x1: Left coordinate of the new bounding box - * @y1: Top coordinate of the new bounding box - * @x2: Right coordinate of the new bounding box - * @y2: Bottom coordinate of the new bounding box - * - * Sets the bbox to the new value, requesting full repaint. - **/ -void -eel_canvas_update_bbox (EelCanvasItem *item, int x1, int y1, int x2, int y2) -{ - eel_canvas_item_request_redraw (item); - item->x1 = x1; - item->y1 = y1; - item->x2 = x2; - item->y2 = y2; - eel_canvas_item_request_redraw (item); -} - diff --git a/eel/eel-canvas-util.h b/eel/eel-canvas-util.h deleted file mode 100644 index 62e53d04..00000000 --- a/eel/eel-canvas-util.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation - * All rights reserved. - * - * This file is part of the Mate Library. - * - * The Mate Library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The Mate Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Mate Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -/* - @NOTATION@ - */ -/* Miscellaneous utility functions for the EelCanvas widget - * - * EelCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is - * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties. - * - * Author: Federico Mena <[email protected]> - */ - -#ifndef EEL_CANVAS_UTIL_H -#define EEL_CANVAS_UTIL_H - - -#ifdef __cplusplus -extern "C" { -#endif - - - /* This structure defines an array of points. X coordinates are stored in the even-numbered - * indices, and Y coordinates are stored in the odd-numbered indices. num_points indicates the - * number of points, so the array is 2*num_points elements big. - */ - typedef struct - { - double *coords; - int num_points; - int ref_count; - } EelCanvasPoints; - - - /* Allocate a new EelCanvasPoints structure with enough space for the specified number of points */ - EelCanvasPoints *eel_canvas_points_new (int num_points); - - /* Increate ref count */ - EelCanvasPoints *eel_canvas_points_ref (EelCanvasPoints *points); -#define eel_canvas_points_unref eel_canvas_points_free - - /* Decrease ref count and free structure if it has reached zero */ - void eel_canvas_points_free (EelCanvasPoints *points); - - /* Given three points forming an angle, compute the coordinates of the inside and outside points of - * the mitered corner formed by a line of a given width at that angle. - * - * If the angle is less than 11 degrees, then FALSE is returned and the return points are not - * modified. Otherwise, TRUE is returned. - */ - int eel_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3, - double width, - double *mx1, double *my1, double *mx2, double *my2); - - /* Compute the butt points of a line segment. If project is FALSE, then the results are as follows: - * - * -------------------* (bx1, by1) - * | - * (x1, y1) *------------------* (x2, y2) - * | - * -------------------* (bx2, by2) - * - * that is, the line is not projected beyond (x2, y2). If project is TRUE, then the results are as - * follows: - * - * -------------------* (bx1, by1) - * (x2, y2) | - * (x1, y1) *-------------* | - * | - * -------------------* (bx2, by2) - */ - void eel_canvas_get_butt_points (double x1, double y1, double x2, double y2, - double width, int project, - double *bx1, double *by1, double *bx2, double *by2); - - /* Calculate the distance from a polygon to a point. The polygon's X coordinates are in the even - * indices of the poly array, and the Y coordinates are in the odd indices. - */ - double eel_canvas_polygon_to_point (double *poly, int num_points, double x, double y); - - - void eel_canvas_item_reset_bounds (EelCanvasItem *item); - - /* Sets the bbox to the new value, requesting full repaint. */ - void eel_canvas_update_bbox (EelCanvasItem *item, int x1, int y1, int x2, int y2); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/eel/eel-debug.c b/eel/eel-debug.c index 25bfaceb..46ad3330 100644 --- a/eel/eel-debug.c +++ b/eel/eel-debug.c @@ -74,34 +74,6 @@ eel_make_warnings_and_criticals_stop_in_debugger (void) g_log_set_default_handler (log_handler, NULL); } -int -eel_get_available_file_descriptor_count (void) -{ - int count; - GList *list; - GList *p; - FILE *file; - - list = NULL; - for (count = 0; ; count++) - { - file = fopen ("/dev/null", "r"); - if (file == NULL) - { - break; - } - list = g_list_prepend (list, file); - } - - for (p = list; p != NULL; p = p->next) - { - fclose (p->data); - } - g_list_free (list); - - return count; -} - void eel_debug_shut_down (void) { diff --git a/eel/eel-debug.h b/eel/eel-debug.h index 86a36ada..d3e2d90f 100644 --- a/eel/eel-debug.h +++ b/eel/eel-debug.h @@ -35,7 +35,6 @@ extern "C" { void eel_stop_in_debugger (void); void eel_make_warnings_and_criticals_stop_in_debugger (void); - int eel_get_available_file_descriptor_count (void); /* A way to do cleanup at exit for compatibility with shutdown tools * like the ones in MateComponent. diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index 58610529..448e933a 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -392,12 +392,6 @@ eel_rgb16_to_rgb (gushort r, gushort g, gushort b) return result; } -guint32 -eel_rgb8_to_rgb (guchar r, guchar g, guchar b) -{ - return eel_rgb16_to_rgb (r << 8, g << 8, b << 8); -} - #if GTK_CHECK_VERSION (3, 0, 0) /** * eel_gdk_rgba_to_rgb @@ -612,38 +606,6 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, } #endif -#if GTK_CHECK_VERSION(3,0,0) -#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, 1)) -#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v)) - -void -eel_make_color_inactive (GdkRGBA *color) -{ - double intensity, saturation; - gdouble t; - - saturation = 0.7; - intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11; - color->red = SATURATE (color->red); - color->green = SATURATE (color->green); - color->blue = SATURATE (color->blue); - - if (intensity > 0.5) { - color->red *= 0.9; - color->green *= 0.9; - color->blue *= 0.9; - } else { - color->red *= 1.25; - color->green *= 1.25; - color->blue *= 1.25; - } - - color->red = CLAMP_COLOR (color->red); - color->green = CLAMP_COLOR (color->green); - color->blue = CLAMP_COLOR (color->blue); -} -#endif - #if ! defined (EEL_OMIT_SELF_CHECK) #if GTK_CHECK_VERSION(3,0,0) diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index cd2ab757..0e8af740 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -112,9 +112,6 @@ void eel_gdk_color_parse_with_white_default (const char guint32 eel_rgb16_to_rgb (gushort r, gushort g, gushort b); -guint32 eel_rgb8_to_rgb (guchar r, - guchar g, - guchar b); #if GTK_CHECK_VERSION (3, 0, 0) guint32 eel_gdk_rgba_to_rgb (const GdkRGBA *color); GdkRGBA eel_gdk_rgb_to_rgba (guint32 color); @@ -148,7 +145,4 @@ void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable int x, int y, PangoLayout *layout); -#if GTK_CHECK_VERSION(3,0,0) -void eel_make_color_inactive (GdkRGBA *color); -#endif #endif /* EEL_GDK_EXTENSIONS_H */ diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index ba4beb1d..aec680f3 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -33,8 +33,6 @@ #include <eel/eel-gdk-extensions.h> #define EEL_DEFAULT_POPUP_MENU_DISPLACEMENT 2 -#define EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY 'w' - /* GtkWindow */ void eel_gtk_window_set_initial_geometry (GtkWindow *window, diff --git a/eel/eel-mate-extensions.c b/eel/eel-mate-extensions.c index 80563034..b40e4afc 100644 --- a/eel/eel-mate-extensions.c +++ b/eel/eel-mate-extensions.c @@ -199,9 +199,3 @@ eel_mate_open_terminal_on_screen (const char *command, mate_gdk_spawn_command_line_on_screen(screen, command_line, NULL); g_free (command_line); } - -void -eel_mate_open_terminal (const char *command) -{ - eel_mate_open_terminal_on_screen (command, NULL); -} diff --git a/eel/eel-mate-extensions.h b/eel/eel-mate-extensions.h index cb97e55b..711ce0ec 100644 --- a/eel/eel-mate-extensions.h +++ b/eel/eel-mate-extensions.h @@ -33,7 +33,6 @@ char * eel_mate_make_terminal_command (const char *command); /* Open up a new terminal, optionally passing in a command to execute */ -void eel_mate_open_terminal (const char *command); void eel_mate_open_terminal_on_screen (const char *command, GdkScreen *screen); diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c index 7f83476e..1d6d0802 100644 --- a/eel/eel-stock-dialogs.c +++ b/eel/eel-stock-dialogs.c @@ -445,17 +445,6 @@ show_ok_dialog (const char *primary_text, } GtkDialog * -eel_create_info_dialog (const char *primary_text, - const char *secondary_text, - GtkWindow *parent) -{ - return create_message_dialog (primary_text, secondary_text, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - parent); -} - -GtkDialog * eel_show_info_dialog (const char *primary_text, const char *secondary_text, GtkWindow *parent) @@ -512,31 +501,6 @@ eel_show_error_dialog (const char *primary_text, GTK_MESSAGE_ERROR, parent); } -GtkDialog * -eel_show_error_dialog_with_details (const char *primary_text, - const char *secondary_text, - const char *detailed_error_message, - GtkWindow *parent) -{ - GtkDialog *dialog; - - g_return_val_if_fail (primary_text != NULL, NULL); - g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL); - - if (detailed_error_message == NULL - || strcmp (primary_text, detailed_error_message) == 0) - { - return eel_show_error_dialog (primary_text, secondary_text, parent); - } - - dialog = show_message_dialog (primary_text, - secondary_text, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, detailed_error_message, - parent); - return dialog; -} - /** * eel_show_yes_no_dialog: * diff --git a/eel/eel-stock-dialogs.h b/eel/eel-stock-dialogs.h index 178f02de..8c138a14 100644 --- a/eel/eel-stock-dialogs.h +++ b/eel/eel-stock-dialogs.h @@ -68,10 +68,6 @@ GtkDialog *eel_show_warning_dialog (const char *primary_text, GtkDialog *eel_show_error_dialog (const char *primary_text, const char *secondary_text, GtkWindow *parent); -GtkDialog *eel_show_error_dialog_with_details (const char *primary_text, - const char *secondary_text, - const char *detailed_error_message, - GtkWindow *parent); GtkDialog *eel_show_yes_no_dialog (const char *primary_text, const char *secondary_text, const char *yes_label, @@ -84,8 +80,5 @@ GtkDialog *eel_create_question_dialog (const char *primary_text, const char *answer_two, int response_two, GtkWindow *parent); -GtkDialog *eel_create_info_dialog (const char *primary_text, - const char *secondary_text, - GtkWindow *parent); #endif /* EEL_STOCK_DIALOGS_H */ diff --git a/eel/eel-string.c b/eel/eel-string.c index 5d74c317..61343eec 100644 --- a/eel/eel-string.c +++ b/eel/eel-string.c @@ -59,36 +59,6 @@ eel_strcmp (const char *string_a, const char *string_b) string_b == NULL ? "" : string_b); } -int -eel_strcasecmp (const char *string_a, const char *string_b) -{ - /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this - * treat 'NULL < ""', or have a flavor that does that. If we - * didn't have code that already relies on 'NULL == ""', I - * would change it right now. - */ - return g_ascii_strcasecmp (string_a == NULL ? "" : string_a, - string_b == NULL ? "" : string_b); -} - -int -eel_strcmp_case_breaks_ties (const char *string_a, const char *string_b) -{ - int casecmp_result; - - /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this - * treat 'NULL < ""', or have a flavor that does that. If we - * didn't have code that already relies on 'NULL == ""', I - * would change it right now. - */ - casecmp_result = eel_strcasecmp (string_a, string_b); - if (casecmp_result != 0) - { - return casecmp_result; - } - return eel_strcmp (string_a, string_b); -} - gboolean eel_str_is_empty (const char *string_or_null) { @@ -96,28 +66,6 @@ eel_str_is_empty (const char *string_or_null) } gboolean -eel_str_is_equal (const char *string_a, const char *string_b) -{ - /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this - * treat 'NULL != ""', or have a flavor that does that. If we - * didn't have code that already relies on 'NULL == ""', I - * would change it right now. - */ - return eel_strcmp (string_a, string_b) == 0; -} - -gboolean -eel_istr_is_equal (const char *string_a, const char *string_b) -{ - /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this - * treat 'NULL != ""', or have a flavor that does that. If we - * didn't have code that already relies on 'NULL == ""', I - * would change it right now. - */ - return eel_strcasecmp (string_a, string_b) == 0; -} - -gboolean eel_str_has_prefix (const char *haystack, const char *needle) { return g_str_has_prefix (haystack == NULL ? "" : haystack, @@ -125,21 +73,6 @@ eel_str_has_prefix (const char *haystack, const char *needle) } gboolean -eel_str_has_suffix (const char *haystack, const char *needle) -{ - if (needle == NULL) - { - return TRUE; - } - if (haystack == NULL) - { - return needle[0] == '\0'; - } - - return g_str_has_suffix (haystack, needle); -} - -gboolean eel_istr_has_prefix (const char *haystack, const char *needle) { const char *h, *n; @@ -167,43 +100,6 @@ eel_istr_has_prefix (const char *haystack, const char *needle) return FALSE; } -gboolean -eel_istr_has_suffix (const char *haystack, const char *needle) -{ - const char *h, *n; - char hc, nc; - - if (needle == NULL) - { - return TRUE; - } - if (haystack == NULL) - { - return needle[0] == '\0'; - } - - /* Eat one character at a time. */ - h = haystack + strlen (haystack); - n = needle + strlen (needle); - do - { - if (n == needle) - { - return TRUE; - } - if (h == haystack) - { - return FALSE; - } - hc = *--h; - nc = *--n; - hc = g_ascii_tolower (hc); - nc = g_ascii_tolower (nc); - } - while (hc == nc); - return FALSE; -} - /** * eel_str_get_prefix: * Get a new string containing the first part of an existing string. @@ -244,46 +140,6 @@ eel_str_get_prefix (const char *source, return g_strndup (source, prefix_start - source); } -gboolean -eel_str_to_int (const char *string, int *integer) -{ - long result; - char *parse_end; - - /* Check for the case of an empty string. */ - if (string == NULL || *string == '\0') - { - return FALSE; - } - - /* Call the standard library routine to do the conversion. */ - errno = 0; - result = strtol (string, &parse_end, 0); - - /* Check that the result is in range. */ - if ((result == G_MINLONG || result == G_MAXLONG) && errno == ERANGE) - { - return FALSE; - } - if (result < G_MININT || result > G_MAXINT) - { - return FALSE; - } - - /* Check that all the trailing characters are spaces. */ - while (*parse_end != '\0') - { - if (!g_ascii_isspace (*parse_end++)) - { - return FALSE; - } - } - - /* Return the result. */ - *integer = result; - return TRUE; -} - char * eel_str_double_underscores (const char *string) { @@ -1005,16 +861,6 @@ retry_atomic_decrement: #if !defined (EEL_OMIT_SELF_CHECK) -static int -call_str_to_int (const char *string) -{ - int integer; - - integer = 9999; - eel_str_to_int (string, &integer); - return integer; -} - static void verify_printf (const char *format, ...) { @@ -1125,25 +971,6 @@ eel_self_check_string (void) EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaa", "aaab"), FALSE); EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaab", "aaa"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix (NULL, NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix (NULL, ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", "a"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", "a"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("aaab", "aaab"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix (NULL, "a"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("", "a"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", "b"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("a", "ab"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("ab", "a"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("ab", "b"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("aaa", "baaa"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_has_suffix ("baaa", "aaa"), TRUE); - EEL_CHECK_STRING_RESULT (eel_str_get_prefix (NULL, NULL), NULL); EEL_CHECK_STRING_RESULT (eel_str_get_prefix (NULL, "foo"), NULL); EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo", NULL), "foo"); @@ -1201,49 +1028,6 @@ eel_self_check_string (void) EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 14), "something_even"); EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 13), "something_odd"); -#define TEST_INTEGER_CONVERSION_FUNCTIONS(string, boolean_result, integer_result) \ - EEL_CHECK_BOOLEAN_RESULT (eel_str_to_int (string, &integer), boolean_result); \ - EEL_CHECK_INTEGER_RESULT (call_str_to_int (string), integer_result); - - TEST_INTEGER_CONVERSION_FUNCTIONS (NULL, FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("a", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS (".", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("0", TRUE, 0) - TEST_INTEGER_CONVERSION_FUNCTIONS ("1", TRUE, 1) - TEST_INTEGER_CONVERSION_FUNCTIONS ("+1", TRUE, 1) - TEST_INTEGER_CONVERSION_FUNCTIONS ("-1", TRUE, -1) - TEST_INTEGER_CONVERSION_FUNCTIONS ("2147483647", TRUE, 2147483647) - TEST_INTEGER_CONVERSION_FUNCTIONS ("2147483648", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("+2147483647", TRUE, 2147483647) - TEST_INTEGER_CONVERSION_FUNCTIONS ("+2147483648", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("-2147483648", TRUE, INT_MIN) - TEST_INTEGER_CONVERSION_FUNCTIONS ("-2147483649", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("1a", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("0.0", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("1e1", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("21474836470", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("+21474836470", FALSE, 9999) - TEST_INTEGER_CONVERSION_FUNCTIONS ("-21474836480", FALSE, 9999) - - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal (NULL, NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal (NULL, ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("", NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("foo", "foo"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_str_is_equal ("foo", "bar"), FALSE); - - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal (NULL, NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal (NULL, ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("", NULL), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("", ""), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("foo", "foo"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("foo", "bar"), FALSE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("Foo", "foo"), TRUE); - EEL_CHECK_BOOLEAN_RESULT (eel_istr_is_equal ("foo", "Foo"), TRUE); - EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after (NULL, "bar"), NULL); EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("", "bar"), ""); EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("foo", "bar"), "foo"); diff --git a/eel/eel-string.h b/eel/eel-string.h index fb98157a..929d11a2 100644 --- a/eel/eel-string.h +++ b/eel/eel-string.h @@ -46,31 +46,15 @@ char * eel_strchr (const char *haystack, char needle); int eel_strcmp (const char *str_a, const char *str_b); -int eel_strcasecmp (const char *str_a, - const char *str_b); -int eel_strcmp_case_breaks_ties (const char *str_a, - const char *str_b); /* Other basic string operations. */ gboolean eel_str_is_empty (const char *str_or_null); -gboolean eel_str_is_equal (const char *str_a, - const char *str_b); -gboolean eel_istr_is_equal (const char *str_a, - const char *str_b); gboolean eel_str_has_prefix (const char *target, const char *prefix); char * eel_str_get_prefix (const char *source, const char *delimiter); gboolean eel_istr_has_prefix (const char *target, const char *prefix); -gboolean eel_str_has_suffix (const char *target, - const char *suffix); -gboolean eel_istr_has_suffix (const char *target, - const char *suffix); - -/* Conversions to and from strings. */ -gboolean eel_str_to_int (const char *str, - int *integer); /* Escape function for '_' character. */ char * eel_str_double_underscores (const char *str); diff --git a/eel/eel-xml-extensions.c b/eel/eel-xml-extensions.c index 2bcd4477..de09b99f 100644 --- a/eel/eel-xml-extensions.c +++ b/eel/eel-xml-extensions.c @@ -43,12 +43,6 @@ eel_xml_get_children (xmlNodePtr parent) } xmlNodePtr -eel_xml_get_root_children (xmlDocPtr document) -{ - return eel_xml_get_children (xmlDocGetRootElement (document)); -} - -xmlNodePtr eel_xml_get_child_by_name_and_property (xmlNodePtr parent, const char *child_name, const char *property_name, @@ -78,29 +72,6 @@ eel_xml_get_child_by_name_and_property (xmlNodePtr parent, return NULL; } -/* return a child of the passed-in node with a matching name */ - -xmlNodePtr -eel_xml_get_child_by_name (xmlNodePtr parent, - const char *child_name) -{ - xmlNodePtr child; - - if (parent == NULL) - { - return NULL; - } - for (child = eel_xml_get_children (parent); child != NULL; child = child->next) - { - if (strcmp (child->name, child_name) == 0) - { - return child; - } - } - return NULL; -} - - xmlNodePtr eel_xml_get_root_child_by_name_and_property (xmlDocPtr document, const char *child_name, @@ -114,50 +85,6 @@ eel_xml_get_root_child_by_name_and_property (xmlDocPtr document, property_value); } -/** - * eel_xml_get_property_for_children - * - * Returns a list of the values for the specified property for all - * children of the node that have the specified name. - * - * @parent: xmlNodePtr representing the node in question. - * @child_name: child element name to look for - * @property: name of propety to reutnr for matching children that have the property - * - * Returns: A list of keywords. - * - **/ -GList * -eel_xml_get_property_for_children (xmlNodePtr parent, - const char *child_name, - const char *property_name) -{ - GList *properties; - xmlNode *child; - xmlChar *property; - - properties = NULL; - - for (child = eel_xml_get_children (parent); - child != NULL; - child = child->next) - { - if (strcmp (child->name, child_name) == 0) - { - property = xmlGetProp (child, property_name); - if (property != NULL) - { - properties = g_list_prepend (properties, - g_strdup (property)); - xmlFree (property); - } - } - } - - /* Reverse so you get them in the same order as the XML file. */ - return g_list_reverse (properties); -} - xmlChar * eel_xml_get_property_translated (xmlNodePtr parent, const char *property_name) diff --git a/eel/eel-xml-extensions.h b/eel/eel-xml-extensions.h index 328e1d33..90d19f5f 100644 --- a/eel/eel-xml-extensions.h +++ b/eel/eel-xml-extensions.h @@ -29,9 +29,6 @@ #include <glib.h> xmlNodePtr eel_xml_get_children (xmlNodePtr parent); -xmlNodePtr eel_xml_get_root_children (xmlDocPtr document); -xmlNodePtr eel_xml_get_child_by_name (xmlNodePtr parent, - const char *child_name); xmlNodePtr eel_xml_get_child_by_name_and_property (xmlNodePtr parent, const char *child_name, const char *property_name, @@ -40,9 +37,6 @@ xmlNodePtr eel_xml_get_root_child_by_name_and_property (xmlDocPtr document, const char *child_name, const char *property_name, const char *property_value); -GList *eel_xml_get_property_for_children (xmlNodePtr parent, - const char *child_name, - const char *property_name); xmlChar *eel_xml_get_property_translated (xmlNodePtr parent, const char *property_name); |