diff options
Diffstat (limited to 'widgets/misc')
38 files changed, 0 insertions, 8050 deletions
diff --git a/widgets/misc/.cvsignore b/widgets/misc/.cvsignore deleted file mode 100644 index 411f0fc219..0000000000 --- a/widgets/misc/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -test-title-bar -test-calendar diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog deleted file mode 100644 index 279e7fc9bc..0000000000 --- a/widgets/misc/ChangeLog +++ /dev/null @@ -1,50 +0,0 @@ -2000-08-10 Christopher James Lahey <clahey@helixcode.com> - - * e-calendar-item.c, e-calendar.c: Fixed some warnings. - -2000-07-25 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.h: - * e-calendar.[hc]: new widget and canvas item to replace GtkCalendar. - Not quite finished yet. - -2000-07-21 Ettore Perazzoli <ettore@helixcode.com> - - * e-title-bar.c (e_title_bar_set_title): We have a `EClippedLabel', - not a `GtkLabel' here: use the right function to change the text. - -2000-07-12 Christopher James Lahey <clahey@helixcode.com> - - * e-scroll-frame.c: Tried rearranging the casts to try for a more - correct computation. - -2000-07-08 Dan Winship <danw@helixcode.com> - - * e-scroll-frame.c (e_scroll_frame_add): comment out true but - confused warning about non-scrollable widgets until Chris and/or - Federico fix this correctly. - (e_scroll_frame_size_allocate): If the available space for the - child is less than the width/height of the frame, give the child - an allocation of 0 rather than some small negative number cast to - unsigned. - -2000-07-05 Dan Winship <danw@helixcode.com> - - * Makefile.am (INCLUDES): Set G_LOG_DOMAIN=__FILE__ rather than - "e-title-bar" in all three widgets. - -2000-06-13 Anders Carlsson <andersca@gnu.org> - - * e-scroll-frame.c (e_scroll_frame_button_press): Control does - horizontal scrolling, a la gimp. - -2000-06-11 Anders Carlsson <andersca@gnu.org> - - * e-scroll-frame.c (e_scroll_frame_button_press): Add support - for mouse wheel scrolling in EScrollFrame. - -2000-06-10 Ettore Perazzoli <ettore@helixcode.com> - - * e-title-bar.c (close_button_realize_cb): Unref the pixmap and - the mask. - diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am deleted file mode 100644 index e2872e7006..0000000000 --- a/widgets/misc/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -# FIXME we use the EClippedLabel widget from EShortcutBar. Probably -# it should be moved somewhere else. - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets/shortcut-bar \ - $(EXTRA_GNOME_CFLAGS) \ - -DG_LOG_DOMAIN=__FILE__ - -noinst_LIBRARIES = \ - libemiscwidgets.a - -libemiscwidgets_a_SOURCES = \ - e-calendar.c \ - e-calendar.h \ - e-calendar-item.c \ - e-calendar-item.h \ - e-clipped-label.c \ - e-clipped-label.h \ - e-scroll-frame.c \ - e-scroll-frame.h \ - e-title-bar.c \ - e-title-bar.h - -noinst_PROGRAMS = \ - test-title-bar \ - test-calendar - -test_title_bar_SOURCES = \ - test-title-bar.c - -test_title_bar_LDADD = \ - ./libemiscwidgets.a \ - $(EXTRA_GNOME_LIBS) - -test_calendar_SOURCES = \ - test-calendar.c - -test_calendar_LDADD = \ - ./libemiscwidgets.a \ - ../../e-util/libeutil.la \ - $(EXTRA_GNOME_LIBS) diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c deleted file mode 100644 index e51754d786..0000000000 --- a/widgets/misc/e-calendar-item.c +++ /dev/null @@ -1,1615 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 - */ - -/* - * ECalendarItem - canvas item displaying a calendar. - */ - -#include <config.h> -#include <time.h> -#include <glib.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-i18n.h> -#include <e-util/e-util.h> -#include "e-calendar-item.h" - - -/* The minimum padding around the numbers in each cell/day. */ -#define E_CALENDAR_ITEM_MIN_CELL_XPAD 4 -#define E_CALENDAR_ITEM_MIN_CELL_YPAD 0 - - -/* These are the padding sizes between various pieces of the calendar. */ -/* FIXME: Use decent names eventually. */ -#define E_CALENDAR_ITEM_XPAD1 4 -#define E_CALENDAR_ITEM_XPAD2 2 -#define E_CALENDAR_ITEM_XPAD3 2 -#define E_CALENDAR_ITEM_XPAD4 4 - -#define E_CALENDAR_ITEM_YPAD3 1 -#define E_CALENDAR_ITEM_YPAD4 0 -#define E_CALENDAR_ITEM_YPAD5 1 -#define E_CALENDAR_ITEM_YPAD6 2 - -#define E_CALENDAR_ITEM_XPAD11 16 -#define E_CALENDAR_ITEM_XPAD12 2 -#define E_CALENDAR_ITEM_XPAD13 1 -#define E_CALENDAR_ITEM_XPAD14 1 -#define E_CALENDAR_ITEM_XPAD15 2 -#define E_CALENDAR_ITEM_XPAD16 16 - -/* The number of rows & columns of days in each month. */ -#define E_CALENDAR_ROWS_PER_MONTH 6 -#define E_CALENDAR_COLS_PER_MONTH 7 - - -static void e_calendar_item_class_init (ECalendarItemClass *class); -static void e_calendar_item_init (ECalendarItem *calitem); - -static void e_calendar_item_get_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_calendar_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_calendar_item_realize (GnomeCanvasItem *item); -static void e_calendar_item_unrealize (GnomeCanvasItem *item); -static void e_calendar_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_calendar_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_calendar_item_draw_month (ECalendarItem *calitem, - GdkDrawable *drawable, - int x, - int y, - int width, - int height, - int row, - int col); -static void e_calendar_item_draw_day_numbers (ECalendarItem *calitem, - GdkDrawable *drawable, - int width, - int height, - int row, - int col, - int year, - int month, - int start_weekday, - gint cells_x, - gint cells_y); -static double e_calendar_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); -static gint e_calendar_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static gboolean e_calendar_item_button_press (ECalendarItem *calitem, - GdkEvent *event); -static gboolean e_calendar_item_button_release (ECalendarItem *calitem, - GdkEvent *event); -static gboolean e_calendar_item_motion (ECalendarItem *calitem, - GdkEvent *event); - -static gboolean e_calendar_item_convert_position_to_day (ECalendarItem *calitem, - gint x, - gint y, - gint *month, - gint *day, - gboolean *entire_week); -static void e_calendar_item_get_month_info (ECalendarItem *calitem, - gint row, - gint col, - gint *first_valid_day, - gint *last_valid_day); -static void e_calendar_item_recalc_sizes(ECalendarItem *calitem); - -static gint e_calendar_item_get_week_number (ECalendarItem *calitem, - gint day, - gint month, - gint year); - -static void e_calendar_item_get_day_style (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gboolean today, - gboolean current_month, - gboolean selected, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold); - -static GnomeCanvasItemClass *parent_class; - -/* Our arguments. */ -enum { - ARG_0, - ARG_YEAR, - ARG_MONTH, - ARG_X1, - ARG_Y1, - ARG_X2, - ARG_Y2, - ARG_FONT, - ARG_WEEK_NUMBER_FONT, - ARG_ROW_HEIGHT, - ARG_COLUMN_WIDTH, - ARG_MINIMUM_ROWS, - ARG_MINIMUM_COLUMNS, - ARG_MAXIMUM_ROWS, - ARG_MAXIMUM_COLUMNS, - ARG_WEEK_START_DAY, - ARG_SHOW_WEEK_NUMBERS -}; - - -E_MAKE_TYPE (e_calendar_item, "ECalendarItem", ECalendarItem, - e_calendar_item_class_init, e_calendar_item_init, - GNOME_TYPE_CANVAS_ITEM) - - -static void -e_calendar_item_class_init (ECalendarItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("ECalendarItem::year", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_YEAR); - gtk_object_add_arg_type ("ECalendarItem::month", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MONTH); - gtk_object_add_arg_type ("ECalendarItem::x1", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_X1); - gtk_object_add_arg_type ("ECalendarItem::y1", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_Y1); - gtk_object_add_arg_type ("ECalendarItem::x2", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_X2); - gtk_object_add_arg_type ("ECalendarItem::y2", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_Y2); - gtk_object_add_arg_type ("ECalendarItem::font", - GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, - ARG_FONT); - gtk_object_add_arg_type ("ECalendarItem::week_number_font", - GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, - ARG_WEEK_NUMBER_FONT); - gtk_object_add_arg_type ("ECalendarItem::row_height", - GTK_TYPE_DOUBLE, GTK_ARG_READABLE, - ARG_ROW_HEIGHT); - gtk_object_add_arg_type ("ECalendarItem::column_width", - GTK_TYPE_DOUBLE, GTK_ARG_READABLE, - ARG_COLUMN_WIDTH); - gtk_object_add_arg_type ("ECalendarItem::mininum_rows", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MINIMUM_ROWS); - gtk_object_add_arg_type ("ECalendarItem::minimum_columns", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MINIMUM_COLUMNS); - gtk_object_add_arg_type ("ECalendarItem::maximum_rows", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MAXIMUM_ROWS); - gtk_object_add_arg_type ("ECalendarItem::maximum_columns", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MAXIMUM_COLUMNS); - gtk_object_add_arg_type ("ECalendarItem::week_start_day", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_WEEK_START_DAY); - gtk_object_add_arg_type ("ECalendarItem::show_week_numbers", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_SHOW_WEEK_NUMBERS); - - object_class->get_arg = e_calendar_item_get_arg; - object_class->set_arg = e_calendar_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_calendar_item_realize; - item_class->unrealize = e_calendar_item_unrealize; - item_class->update = e_calendar_item_update; - item_class->draw = e_calendar_item_draw; - item_class->point = e_calendar_item_point; - item_class->event = e_calendar_item_event; -} - - -static void -e_calendar_item_init (ECalendarItem *calitem) -{ - struct tm *tmp_tm; - time_t t; - - /* Set the default time to the current month. */ - t = time (NULL); - tmp_tm = localtime (&t); - calitem->year = tmp_tm->tm_year + 1900; - calitem->month = tmp_tm->tm_mon; - - calitem->min_cols = 1; - calitem->min_rows = 1; - calitem->show_week_numbers = FALSE; - calitem->week_start_day = 0; - calitem->expand = TRUE; - - calitem->x1 = 0.0; - calitem->y1 = 0.0; - calitem->x2 = 0.0; - calitem->y2 = 0.0; - - calitem->selection_start_month_offset = -1; - - /* Translators: These are the first characters of each day of the - week, 'M' for 'Monday', 'T' for Tuesday etc. */ - calitem->days = _("MTWTFSS"); -} - - -static void -e_calendar_item_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ECalendarItem *calitem; - - item = GNOME_CANVAS_ITEM (o); - calitem = E_CALENDAR_ITEM (o); - - switch (arg_id) { - case ARG_YEAR: - GTK_VALUE_INT (*arg) = calitem->year; - break; - case ARG_MONTH: - GTK_VALUE_INT (*arg) = calitem->month; - break; - case ARG_X1: - GTK_VALUE_DOUBLE (*arg) = calitem->x1; - break; - case ARG_Y1: - GTK_VALUE_DOUBLE (*arg) = calitem->y1; - break; - case ARG_X2: - GTK_VALUE_DOUBLE (*arg) = calitem->x2; - break; - case ARG_Y2: - GTK_VALUE_DOUBLE (*arg) = calitem->y2; - break; - case ARG_FONT: - GTK_VALUE_BOXED (*arg) = calitem->font; - break; - case ARG_WEEK_NUMBER_FONT: - GTK_VALUE_BOXED (*arg) = calitem->week_number_font; - break; - case ARG_ROW_HEIGHT: - e_calendar_item_recalc_sizes (calitem); - GTK_VALUE_DOUBLE (*arg) = calitem->min_month_height; - break; - case ARG_COLUMN_WIDTH: - e_calendar_item_recalc_sizes (calitem); - GTK_VALUE_DOUBLE (*arg) = calitem->min_month_width; - break; - case ARG_MINIMUM_ROWS: - GTK_VALUE_INT (*arg) = calitem->min_rows; - break; - case ARG_MINIMUM_COLUMNS: - GTK_VALUE_INT (*arg) = calitem->min_cols; - break; - case ARG_MAXIMUM_ROWS: - GTK_VALUE_INT (*arg) = calitem->max_rows; - break; - case ARG_MAXIMUM_COLUMNS: - GTK_VALUE_INT (*arg) = calitem->max_cols; - break; - case ARG_WEEK_START_DAY: - GTK_VALUE_INT (*arg) = calitem->week_start_day; - break; - case ARG_SHOW_WEEK_NUMBERS: - GTK_VALUE_BOOL (*arg) = calitem->show_week_numbers; - break; - } -} - - -static void -e_calendar_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ECalendarItem *calitem; - GdkFont *font; - gboolean need_reshape = FALSE; - gdouble dvalue; - gint ivalue; - gboolean bvalue; - - item = GNOME_CANVAS_ITEM (o); - calitem = E_CALENDAR_ITEM (o); - - switch (arg_id){ - case ARG_YEAR: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->year != ivalue) { - calitem->year = ivalue; - need_reshape = TRUE; - } - break; - case ARG_MONTH: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->month != ivalue) { - calitem->month = ivalue; - need_reshape = TRUE; - } - break; - case ARG_X1: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->x1 != dvalue) { - calitem->x1 = dvalue; - need_reshape = TRUE; - } - break; - case ARG_Y1: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->y1 != dvalue) { - calitem->y1 = dvalue; - need_reshape = TRUE; - } - break; - case ARG_X2: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->x2 != dvalue) { - calitem->x2 = dvalue; - need_reshape = TRUE; - } - break; - case ARG_Y2: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->y2 != dvalue) { - calitem->y2 = dvalue; - need_reshape = TRUE; - } - break; - case ARG_FONT: - font = GTK_VALUE_BOXED (*arg); - if (calitem->font != font) { - if (calitem->font) - gdk_font_unref (calitem->font); - calitem->font = font; - if (font) - gdk_font_ref (font); - need_reshape = TRUE; - } - break; - case ARG_WEEK_NUMBER_FONT: - font = GTK_VALUE_BOXED (*arg); - if (calitem->week_number_font != font) { - if (calitem->week_number_font) - gdk_font_unref (calitem->week_number_font); - calitem->week_number_font = font; - if (font) - gdk_font_ref (font); - need_reshape = TRUE; - } - break; - case ARG_MINIMUM_ROWS: - ivalue = GTK_VALUE_INT (*arg); - ivalue = MAX (1, ivalue); - if (calitem->min_rows != ivalue) { - calitem->min_rows = ivalue; - need_reshape = TRUE; - } - break; - case ARG_MINIMUM_COLUMNS: - ivalue = GTK_VALUE_INT (*arg); - ivalue = MAX (1, ivalue); - if (calitem->min_cols != ivalue) { - calitem->min_cols = ivalue; - need_reshape = TRUE; - } - break; - case ARG_MAXIMUM_ROWS: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->max_rows != ivalue) { - calitem->max_rows = ivalue; - need_reshape = TRUE; - } - break; - case ARG_MAXIMUM_COLUMNS: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->max_cols != ivalue) { - calitem->max_cols = ivalue; - need_reshape = TRUE; - } - break; - case ARG_WEEK_START_DAY: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->week_start_day != ivalue) { - calitem->week_start_day = ivalue; - need_reshape = TRUE; - } - break; - case ARG_SHOW_WEEK_NUMBERS: - bvalue = GTK_VALUE_BOOL (*arg); - if (calitem->show_week_numbers != bvalue) { - calitem->show_week_numbers = bvalue; - need_reshape = TRUE; - } - break; - default: - g_warning ("Invalid arg"); - } - - /* FIXME: finish. */ - if (need_reshape) { - gnome_canvas_item_request_update (item); - } -} - - -static void -e_calendar_item_realize (GnomeCanvasItem *item) -{ - ECalendarItem *calitem; - GdkColormap *colormap; - gboolean success[E_CALENDAR_COLOR_LAST]; - gint nfailed; - - calitem = E_CALENDAR_ITEM (item); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - - calitem->colors[E_CALENDAR_COLOR_SELECTION].red = 65535; - calitem->colors[E_CALENDAR_COLOR_SELECTION].green = 65535; - calitem->colors[E_CALENDAR_COLOR_SELECTION].blue = 65535; - - calitem->colors[E_CALENDAR_COLOR_HIGHLIGHT].red = 56000; - calitem->colors[E_CALENDAR_COLOR_HIGHLIGHT].green = 57000; - calitem->colors[E_CALENDAR_COLOR_HIGHLIGHT].blue = 57000; - - calitem->colors[E_CALENDAR_COLOR_TODAY].red = 65535; - calitem->colors[E_CALENDAR_COLOR_TODAY].green = 0; - calitem->colors[E_CALENDAR_COLOR_TODAY].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, calitem->colors, - E_CALENDAR_COLOR_LAST, FALSE, - TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); -} - - -static void -e_calendar_item_unrealize (GnomeCanvasItem *item) -{ - ECalendarItem *calitem; - GdkColormap *colormap; - gint i; - - calitem = E_CALENDAR_ITEM (item); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - - for (i = 0; i < E_CALENDAR_COLOR_LAST; i++) - gdk_colors_free (colormap, &calitem->colors[i].pixel, 1, 0); -} - - -static void -e_calendar_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - ECalendarItem *calitem; - GtkStyle *style; - GdkFont *font; - gint char_height, width, height, space, space_per_cal, space_per_cell; - gint xthickness, ythickness; - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - calitem = E_CALENDAR_ITEM (item); - style = GTK_WIDGET (item->canvas)->style; - xthickness = style->klass->xthickness; - ythickness = style->klass->ythickness; - - item->x1 = calitem->x1; - item->y1 = calitem->y1; - item->x2 = calitem->x2 >= calitem->x1 ? calitem->x2 : calitem->x1; - item->y2 = calitem->y2 >= calitem->y1 ? calitem->y2 : calitem->y1; - - /* - * Calculate the new layout of the calendar. - */ - - /* Make sure the minimum row width & cell height and the widths of - all the digits and characters are up to date. */ - e_calendar_item_recalc_sizes (calitem); - - /* Calculate how many rows & cols we can fit in. */ - width = item->x2 - item->x1; - height = item->y2 - item->y1; - - width -= xthickness * 2; - height -= ythickness * 2; - - calitem->rows = height / calitem->min_month_height; - calitem->rows = MAX (calitem->rows, calitem->min_rows); - if (calitem->max_rows > 0) - calitem->rows = MIN (calitem->rows, calitem->max_rows); - calitem->cols = width / calitem->min_month_width; - calitem->cols = MAX (calitem->cols, calitem->min_cols); - if (calitem->max_cols > 0) - calitem->cols = MIN (calitem->cols, calitem->max_cols); - - /* Split up the empty space according to the configuration. - If the calendar is set to expand, we divide the space between the - cells and the spaces around the calendar, otherwise we place the - calendars in the center of the available area. */ - - font = calitem->font; - if (!font) - font = style->font; - char_height = font->ascent + font->descent; - - calitem->month_width = calitem->min_month_width; - calitem->month_height = calitem->min_month_height; - calitem->cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - calitem->cell_height = char_height - + E_CALENDAR_ITEM_MIN_CELL_YPAD; - calitem->month_tpad = 0; - calitem->month_bpad = 0; - calitem->month_lpad = 0; - calitem->month_rpad = 0; - - space = height - calitem->rows * calitem->month_height; - if (space > 0) { - space_per_cal = space / calitem->rows; - calitem->month_height += space_per_cal; - - if (calitem->expand) { - space_per_cell = space_per_cal / E_CALENDAR_ROWS_PER_MONTH; - calitem->cell_height += space_per_cell; - space_per_cal -= space_per_cell * E_CALENDAR_ROWS_PER_MONTH; - } - - calitem->month_tpad = space_per_cal / 2; - calitem->month_bpad = space_per_cal - calitem->month_tpad; - } - - space = width - calitem->cols * calitem->month_width; - if (space > 0) { - space_per_cal = space / calitem->cols; - calitem->month_width += space_per_cal; - space -= space_per_cal * calitem->cols; - - if (calitem->expand) { - space_per_cell = space_per_cal / E_CALENDAR_COLS_PER_MONTH; - calitem->cell_width += space_per_cell; - space_per_cal -= space_per_cell * E_CALENDAR_COLS_PER_MONTH; - } - - calitem->month_lpad = space_per_cal / 2; - calitem->month_rpad = space_per_cal - calitem->month_lpad; - } - - space = MAX (0, space); - calitem->x_offset = space / 2; - - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, - item->x2, item->y2); -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_calendar_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - ECalendarItem *calitem; - GtkStyle *style; - GdkFont *font; - GdkGC *base_gc, *bg_gc; - gint char_height, row, col, row_y, bar_height, col_x, ythickness; - -#if 0 - g_print ("In e_calendar_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - calitem = E_CALENDAR_ITEM (canvas_item); - style = GTK_WIDGET (canvas_item->canvas)->style; - font = calitem->font; - if (!font) - font = style->font; - char_height = font->ascent + font->descent; - ythickness = style->klass->ythickness; - base_gc = style->base_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - - /* Clear the entire background. */ - gdk_draw_rectangle (drawable, base_gc, TRUE, - calitem->x1 - x, calitem->y1 - y, - calitem->x2 - calitem->x1, - calitem->y2 - calitem->y1); - - /* Draw the shadow around the entire item. - FIXME: must also leave room for the 'Today' & 'None' buttons etc. */ - gtk_draw_shadow (style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - calitem->x1 - x, calitem->y1 - y, - calitem->x2 - calitem->x1, calitem->y2 - calitem->y1); - - row_y = canvas_item->y1 + ythickness; - bar_height = ythickness * 2 + E_CALENDAR_ITEM_YPAD1 + char_height - + E_CALENDAR_ITEM_YPAD2; - - for (row = 0; row < calitem->rows; row++) { - /* Draw the background for the title bars and the shadow around - it, and the vertical lines between columns. */ - - gdk_draw_rectangle (drawable, bg_gc, TRUE, - calitem->x1 - x, row_y - y, - calitem->x2 - calitem->x1, bar_height); - - gtk_draw_shadow (style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - calitem->x1 - x, row_y - y, - calitem->x2 - calitem->x1, bar_height); - - - for (col = 0; col < calitem->cols; col++) { - if (col != 0) { - col_x = calitem->x1 + calitem->x_offset - + calitem->month_width * col; - gtk_draw_vline (style, drawable, - GTK_STATE_NORMAL, - row_y + ythickness + 1 - y, - row_y + bar_height - - ythickness - 2 - y, - col_x - 1 - x); - } - - - e_calendar_item_draw_month (calitem, drawable, x, y, - width, height, row, col); - } - - row_y += calitem->month_height; - } -} - - -static void -e_calendar_item_draw_month (ECalendarItem *calitem, - GdkDrawable *drawable, - int x, - int y, - int width, - int height, - int row, - int col) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - GdkFont *font; - GdkGC *fg_gc, *bg_gc; - struct tm tmp_tm; - GdkRectangle clip_rect; - gint char_height, xthickness, ythickness, start_weekday; - gint year, month, month_x, month_y, min_x, max_x, text_x, text_y; - gint day, day_index, cells_x, cells_y, min_cell_width, text_width; - gchar buffer[64]; - -#if 0 - g_print ("In e_calendar_item_draw_month: %i,%i %ix%i\n", - x, y, width, height); -#endif - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - font = calitem->font; - if (!font) - font = style->font; - char_height = font->ascent + font->descent; - xthickness = style->klass->xthickness; - ythickness = style->klass->ythickness; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - - /* Calculate the top-left position of the entire month display. */ - month_x = item->x1 + xthickness + calitem->x_offset - + col * calitem->month_width - x; - month_y = item->y1 + ythickness + row * calitem->month_height - y; - - /* Just return if the month is outside the given area. */ - if (month_x >= width || month_x + calitem->month_width <= 0 - || month_y >= height || month_y + calitem->month_height <= 0) - return; - - - /* Draw the month name & year, with clipping. Note that the top row - needs extra space around it for the buttons. */ - if (row == 0 && col == 0) - min_x = E_CALENDAR_ITEM_XPAD11; - else - min_x = E_CALENDAR_ITEM_XPAD14 + E_CALENDAR_ITEM_XPAD15; - - if (row == 0 && col == calitem->cols - 1) - max_x = calitem->month_width - E_CALENDAR_ITEM_XPAD16; - else - max_x = calitem->month_width - E_CALENDAR_ITEM_XPAD12 - - E_CALENDAR_ITEM_XPAD13; - - text_y = month_y + style->klass->ythickness - + E_CALENDAR_ITEM_YPAD1; - clip_rect.x = month_x + min_x; - clip_rect.y = text_y; - clip_rect.width = max_x - min_x; - clip_rect.height = char_height; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - memset (&tmp_tm, 0, sizeof (tmp_tm)); - month = calitem->month + row * calitem->cols + col; - year = calitem->year + month / 12; - month %= 12; - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = 1; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - strftime (buffer, 64, "%B %Y", &tmp_tm); - start_weekday = (tmp_tm.tm_wday + 6) % 7; - - /* Ideally we place the text centered in the month, but we won't go - to the left of the minimum x position. */ - text_width = gdk_string_width (font, buffer); - text_x = (calitem->month_width - text_width) / 2; - text_x = MAX (min_x, text_x); - - gdk_draw_string (drawable, font, fg_gc, - month_x + text_x, text_y + font->ascent, buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - - /* Draw the day initials across the top of the month. */ - min_cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - - cells_x = month_x + E_CALENDAR_ITEM_XPAD1 + calitem->month_lpad - + E_CALENDAR_ITEM_XPAD3; - if (calitem->show_week_numbers) - cells_x += calitem->max_week_number_digit_width * 2 - + E_CALENDAR_ITEM_XPAD2 + 1; - text_x = cells_x + calitem->cell_width - - (calitem->cell_width - min_cell_width) / 2; - text_x -= E_CALENDAR_ITEM_MIN_CELL_XPAD / 2; - text_y = month_y + ythickness * 2 + E_CALENDAR_ITEM_YPAD1 - + char_height + E_CALENDAR_ITEM_YPAD2 + E_CALENDAR_ITEM_YPAD3 - + calitem->month_tpad; - - cells_y = text_y + char_height + E_CALENDAR_ITEM_YPAD4 + 1 - + E_CALENDAR_ITEM_YPAD5; - - text_y += font->ascent; - day_index = calitem->week_start_day; - for (day = 0; day < 7; day++) { - gdk_draw_text (drawable, font, fg_gc, - text_x - calitem->day_widths[day_index], text_y, - &calitem->days[day_index], 1); - text_x += calitem->cell_width; - day_index++; - if (day_index == 7) - day_index = 0; - } - - - /* Draw the horizontal line beneath the day initials. */ - gdk_draw_line (drawable, fg_gc, - cells_x - E_CALENDAR_ITEM_XPAD3, - cells_y - E_CALENDAR_ITEM_YPAD5, - cells_x + E_CALENDAR_COLS_PER_MONTH * calitem->cell_width - 1, - cells_y - E_CALENDAR_ITEM_YPAD5); - - e_calendar_item_draw_day_numbers (calitem, drawable, width, height, - row, col, year, month, start_weekday, - cells_x, cells_y); - - /* Draw the vertical line after the week number. */ - if (calitem->show_week_numbers) { - gdk_draw_line (drawable, fg_gc, - cells_x - E_CALENDAR_ITEM_XPAD3, - cells_y, - cells_x - E_CALENDAR_ITEM_XPAD3, - cells_y + E_CALENDAR_ROWS_PER_MONTH * calitem->cell_height - 1); - } -} - - -static void -e_calendar_item_draw_day_numbers (ECalendarItem *calitem, - GdkDrawable *drawable, - int width, - int height, - int row, - int col, - int year, - int month, - int start_weekday, - gint cells_x, - gint cells_y) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - GdkFont *font, *wkfont; - GdkGC *fg_gc; - GdkColor *bg_color, *fg_color, *box_color; - struct tm *today_tm; - time_t t; - gint char_height, min_cell_width, min_cell_height; - gint day_num, drow, dcol, day_x, day_y; - gint text_x, text_y; - gint num_chars, digit; - gint week_num, mon, days_from_week_start; - gint years[3], months[3], days_in_month[3]; - gboolean bold, today, draw_day, finished = FALSE, selected; - gint today_year, today_month, today_mday, month_offset, day_offset; - gchar buffer[2]; - - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - font = calitem->font; - if (!font) - font = style->font; - wkfont = calitem->week_number_font; - if (!wkfont) - wkfont = font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - char_height = font->ascent + font->descent; - - min_cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - min_cell_height = char_height + E_CALENDAR_ITEM_MIN_CELL_YPAD; - - /* Calculate the number of days in the previous, current, and next - months. Note that g_date uses 1 to 12 for months. */ - years[0] = years[1] = years[2] = year; - months[0] = month - 1; - months[1] = month; - months[2] = month + 1; - if (months[0] == -1) { - months[0] = 11; - years[0]--; - } - if (months[2] == 12) { - months[2] = 0; - years[2]++; - } - - days_in_month[0] = g_date_days_in_month (months[0] + 1, years[0]); - days_in_month[1] = g_date_days_in_month (months[1] + 1, years[1]); - days_in_month[2] = g_date_days_in_month (months[2] + 1, years[2]); - - /* Mon 0 is the previous month, which we may show the end of. Mon 1 is - the current month, and mon 2 is the next month. */ - mon = 0; - - day_num = days_in_month[0]; - days_from_week_start = (start_weekday + 7 - calitem->week_start_day) - % 7; - /* For the top-left month we show the end of the previous month, and - if the new month starts on the first day of the week we show a - complete week from the previous month. */ - if (days_from_week_start == 0) { - if (row == 0 && col == 0) { - day_num -= 6; - } else { - mon++; - day_num = 1; - } - } else { - day_num -= days_from_week_start - 1; - } - - /* Get today's date, so we can highlight it. */ - t = time (NULL); - today_tm = localtime (&t); - today_year = today_tm->tm_year + 1900; - today_month = today_tm->tm_mon; - today_mday = today_tm->tm_mday; - - /* We usually skip the last days of the previous month (mon = 0), - except for the top-left month displayed. */ - draw_day = (mon == 1 || (row == 0 && col == 0)); - - month_offset = row * calitem->cols + col; - day_offset = 0; - - for (drow = 0; drow < 6; drow++) { - /* Draw the week number. */ - if (calitem->show_week_numbers) { - week_num = e_calendar_item_get_week_number (calitem, - day_num, - months[mon], - years[mon]); - - text_x = cells_x - E_CALENDAR_ITEM_XPAD3 - 1 - - E_CALENDAR_ITEM_XPAD2; - text_y = cells_y + drow * calitem->cell_height + - + (calitem->cell_height - min_cell_height + 1) / 2; - - num_chars = 0; - if (week_num >= 10) { - digit = week_num / 10; - text_x -= calitem->week_number_digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - } - - digit = week_num % 10; - text_x -= calitem->week_number_digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - - gdk_draw_text (drawable, wkfont, fg_gc, - text_x, text_y + font->ascent, - buffer, num_chars); - } - - for (dcol = 0; dcol < 7; dcol++) { - if (draw_day) { - day_x = cells_x + dcol * calitem->cell_width; - day_y = cells_y + drow * calitem->cell_height; - - today = years[mon] == today_year - && months[mon] == today_month - && day_num == today_mday; - - selected = calitem->selection_start_month_offset != -1 - && (calitem->selection_start_month_offset < month_offset - || (calitem->selection_start_month_offset == month_offset - && calitem->selection_start_day_offset <= day_offset)) - && (calitem->selection_end_month_offset > month_offset - || (calitem->selection_end_month_offset == month_offset - && calitem->selection_end_day_offset >= day_offset)); - - /* Get the colors & style to use for the day.*/ - e_calendar_item_get_day_style (calitem, - years[mon], - months[mon], - day_num, - today, - mon == 1, - selected, - &bg_color, - &fg_color, - &box_color, - &bold); - - /* Draw the background, if set. */ - if (bg_color) { - gdk_gc_set_foreground (fg_gc, bg_color); - gdk_draw_rectangle (drawable, fg_gc, - TRUE, - day_x, day_y, - calitem->cell_width, - calitem->cell_height); - } - - /* Draw the box, if set. */ - if (box_color) { - gdk_gc_set_foreground (fg_gc, box_color); - gdk_draw_rectangle (drawable, fg_gc, - FALSE, - day_x, day_y, - calitem->cell_width - 1, - calitem->cell_height - 1); - } - - /* Draw the 1- or 2-digit day number. */ - day_x += calitem->cell_width - (calitem->cell_width - min_cell_width) / 2; - day_x -= E_CALENDAR_ITEM_MIN_CELL_XPAD / 2; - day_y += (calitem->cell_height - min_cell_height + 1) / 2; - day_y += E_CALENDAR_ITEM_MIN_CELL_YPAD / 2; - - num_chars = 0; - if (day_num >= 10) { - digit = day_num / 10; - day_x -= calitem->digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - } - - digit = day_num % 10; - day_x -= calitem->digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - - if (fg_color) { - gdk_gc_set_foreground (fg_gc, - fg_color); - } else { - gdk_gc_set_foreground (fg_gc, - &style->fg[GTK_STATE_NORMAL]); - } - - gdk_draw_text (drawable, font, fg_gc, - day_x, - day_y + font->ascent, - buffer, num_chars); - /* We use a stupid technique for bold. Just - draw it again 1 pixel to the left. */ - if (bold) - gdk_draw_text (drawable, font, fg_gc, - day_x - 1, - day_y + font->ascent, - buffer, num_chars); - } - - /* See if we've reached the end of a month. */ - if (day_num == days_in_month[mon]) { - mon++; - /* We only draw the start of the next month - for the bottom-right month displayed. */ - if (mon == 2 && (row != calitem->rows - 1 - || col != calitem->cols - 1)) { - /* Set a flag so we exit the loop. */ - finished = TRUE; - break; - } - day_num = 1; - draw_day = TRUE; - } else { - day_num++; - } - - day_offset++; - } - - /* Exit the loop if the flag is set. */ - if (finished) - break; - } - - /* Reset the foreground color. */ - gdk_gc_set_foreground (fg_gc, &style->fg[GTK_STATE_NORMAL]); -} - - -static gint -e_calendar_item_get_week_number (ECalendarItem *calitem, - gint day, - gint month, - gint year) -{ - GDate tmp_date; - gint weekday, yearday, offset, week_num; - - /* FIXME: check what happens at year boundaries. */ - - g_date_clear (&tmp_date, 1); - g_date_set_dmy (&tmp_date, day, month + 1, year); - - /* This results in a value of 0 (Monday) - 6 (Sunday). */ - weekday = g_date_weekday (&tmp_date) - 1; - - /* Calculate the offset from the start of the week. */ - offset = (calitem->week_start_day + 7 - weekday) % 7; - - /* Calculate the day of the year, from 0 to 365. */ - yearday = g_date_day_of_year (&tmp_date) - 1; - - /* If the week starts on or after 29th December, it is week 1 of the - next year, since there are 4 days in the next year. */ - g_date_subtract_days (&tmp_date, offset); - if (g_date_month (&tmp_date) == 12 && g_date_day (&tmp_date) >= 29) - return 1; - - /* Calculate the week number, from 0. */ - week_num = (yearday - offset) / 7; - - /* If the first week starts on or after Jan 5th, then we need to add - 1 since the previous week will really be the first week. */ - if ((yearday - offset) % 7 >= 4) - week_num++; - - /* Add 1 so week numbers are from 1 to 53. */ - return week_num + 1; -} - - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_calendar_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_calendar_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - ECalendarItem *calitem; - - calitem = E_CALENDAR_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - return e_calendar_item_button_press (calitem, event); - case GDK_BUTTON_RELEASE: - return e_calendar_item_button_release (calitem, event); - case GDK_MOTION_NOTIFY: - return e_calendar_item_motion (calitem, event); - default: - break; - } - - return FALSE; -} - - - -/* This checks if any fonts have changed, and if so it recalculates the - layout of the item. */ -static void -e_calendar_item_recalc_sizes (ECalendarItem *calitem) -{ - GnomeCanvasItem *canvas_item; - GtkStyle *style; - GdkFont *font, *wkfont; - gchar *digits = "0123456789"; - gint day, digit, max_digit_width, max_week_number_digit_width; - gint char_height, width, min_cell_width, min_cell_height; - - canvas_item = GNOME_CANVAS_ITEM (calitem); - style = GTK_WIDGET (canvas_item->canvas)->style; - - font = calitem->font; - if (!font) - font = style->font; - wkfont = calitem->week_number_font; - if (!wkfont) - wkfont = font; - char_height = font->ascent + font->descent; - - /* If both fonts are the same, just return. */ - if (font == calitem->old_font - && wkfont == calitem->old_week_number_font) - return; - - calitem->old_font = font; - calitem->old_week_number_font = wkfont; - - for (day = 0; day < 7; day++) - calitem->day_widths[day] = gdk_char_width (font, - calitem->days[day]); - - max_digit_width = 0; - max_week_number_digit_width = 0; - for (digit = 0; digit < 10; digit++) { - width = gdk_char_width (font, digits[digit]); - calitem->digit_widths[digit] = width; - max_digit_width = MAX (max_digit_width, width); - - if (wkfont) { - width = gdk_char_width (wkfont, digits[digit]); - calitem->week_number_digit_widths[digit] = width; - max_week_number_digit_width = MAX (max_week_number_digit_width, width); - } else { - calitem->week_number_digit_widths[digit] = width; - max_week_number_digit_width = max_digit_width; - } - } - calitem->max_digit_width = max_digit_width; - calitem->max_week_number_digit_width = max_week_number_digit_width; - - - min_cell_width = max_digit_width * 2 + E_CALENDAR_ITEM_MIN_CELL_XPAD; - min_cell_height = char_height + E_CALENDAR_ITEM_MIN_CELL_YPAD; - - calitem->min_month_width = E_CALENDAR_ITEM_XPAD1 - + E_CALENDAR_ITEM_XPAD3 + min_cell_width * 7 - + E_CALENDAR_ITEM_XPAD4; - if (calitem->show_week_numbers) - calitem->min_month_width += max_week_number_digit_width * 2 - + E_CALENDAR_ITEM_XPAD2 + 1; - - calitem->min_month_height = style->klass->ythickness * 2 - + E_CALENDAR_ITEM_YPAD1 + char_height - + E_CALENDAR_ITEM_YPAD2 + 1 + E_CALENDAR_ITEM_YPAD3 - + char_height + E_CALENDAR_ITEM_YPAD4 + 1 - + E_CALENDAR_ITEM_YPAD5 + min_cell_height * 6 - + E_CALENDAR_ITEM_YPAD6; -} - - -static void -e_calendar_item_get_day_style (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gboolean today, - gboolean current_month, - gboolean selected, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold) -{ - *bg_color = NULL; - *fg_color = NULL; - *box_color = NULL; - *bold = FALSE; - - if (today) - *box_color = &calitem->colors[E_CALENDAR_COLOR_TODAY]; - - if (!current_month) - *fg_color = &calitem->colors[E_CALENDAR_COLOR_HIGHLIGHT]; - - if (selected) { - *fg_color = &calitem->colors[E_CALENDAR_COLOR_SELECTION]; - *bg_color = &calitem->colors[E_CALENDAR_COLOR_HIGHLIGHT]; - } -} - - - -static gboolean -e_calendar_item_button_press (ECalendarItem *calitem, - GdkEvent *event) -{ - gint month, day; - gboolean all_week; - - g_print ("In e_calendar_item_button_press\n"); - - if (e_calendar_item_convert_position_to_day (calitem, - event->button.x, - event->button.y, - &month, &day, &all_week)) { - g_print (" Pressed month: %i day: %i\n", month, day); - - calitem->selection_start_month_offset = month; - calitem->selection_start_day_offset = day; - calitem->selection_end_month_offset = month; - calitem->selection_end_day_offset = day; - calitem->selecting = TRUE; - calitem->selection_dragging_end = TRUE; - - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); - - return TRUE; - } - - return FALSE; -} - - -static gboolean -e_calendar_item_button_release (ECalendarItem *calitem, - GdkEvent *event) -{ - gint month, day; - gboolean all_week; - - g_print ("In e_calendar_item_button_release\n"); - - calitem->selecting = FALSE; - - if (e_calendar_item_convert_position_to_day (calitem, - event->button.x, - event->button.y, - &month, &day, &all_week)) - g_print (" Released month: %i day: %i\n", month, day); - - return FALSE; -} - - -static gboolean -e_calendar_item_motion (ECalendarItem *calitem, - GdkEvent *event) -{ - gint month, day; - gboolean all_week; - - if (!calitem->selecting) - return FALSE; - - if (e_calendar_item_convert_position_to_day (calitem, - event->button.x, - event->button.y, - &month, &day, &all_week)) { - if (calitem->selection_dragging_end) { - if (calitem->selection_end_month_offset == month - && calitem->selection_end_day_offset == day) - return FALSE; - calitem->selection_end_month_offset = month; - calitem->selection_end_day_offset = day; - } else { - if (calitem->selection_start_month_offset == month - && calitem->selection_start_day_offset == day) - return FALSE; - calitem->selection_start_month_offset = month; - calitem->selection_start_day_offset = day; - } - - if (calitem->selection_start_month_offset > calitem->selection_end_month_offset - || (calitem->selection_start_month_offset == calitem->selection_end_month_offset - && calitem->selection_start_day_offset > calitem->selection_end_day_offset)) { - month = calitem->selection_start_month_offset; - day = calitem->selection_start_day_offset; - calitem->selection_start_month_offset = calitem->selection_end_month_offset; - calitem->selection_end_month_offset = month; - calitem->selection_start_day_offset = calitem->selection_end_day_offset; - calitem->selection_end_day_offset = day; - - calitem->selection_dragging_end = !calitem->selection_dragging_end; - } - - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); - } - - return FALSE; -} - - - - -/* Converts a position within the item to a month & day. - The month returned is 0 for the top-left month displayed. - If the position is over a week number the first day of the week is returned - and entire_week is set to TRUE. */ -static gboolean -e_calendar_item_convert_position_to_day (ECalendarItem *calitem, - gint event_x, - gint event_y, - gint *month, - gint *day, - gboolean *entire_week) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - gint xthickness, ythickness, char_height; - gint x, y, row, col, cells_x, cells_y, day_row, day_col; - gint first_valid_day, last_valid_day; - - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - char_height = style->font->ascent + style->font->descent; - xthickness = style->klass->xthickness; - ythickness = style->klass->ythickness; - - x = event_x - xthickness - calitem->x_offset; - y = event_y - ythickness; - - if (x < 0 || y < 0) - return FALSE; - - row = y / calitem->month_height; - col = x / calitem->month_width; - - if (row < 0 || row >= calitem->rows - || col < 0 || col >= calitem->cols) - return FALSE; - - x = x % calitem->month_width; - y = y % calitem->month_height; - - cells_x = E_CALENDAR_ITEM_XPAD1 + calitem->month_lpad - + E_CALENDAR_ITEM_XPAD3; - if (calitem->show_week_numbers) - cells_x += calitem->max_week_number_digit_width * 2 - + E_CALENDAR_ITEM_XPAD2 + 1; - cells_y = ythickness * 2 + E_CALENDAR_ITEM_YPAD1 - + char_height + E_CALENDAR_ITEM_YPAD2 + E_CALENDAR_ITEM_YPAD3 - + calitem->month_tpad - + char_height + E_CALENDAR_ITEM_YPAD4 + 1 - + E_CALENDAR_ITEM_YPAD5; - - x -= cells_x; - y -= cells_y; - - if (x < 0 || y < 0) - return FALSE; - - day_row = y / calitem->cell_height; - day_col = x / calitem->cell_width; - - if (day_row < 0 || day_row >= E_CALENDAR_ROWS_PER_MONTH - || day_col < 0 || day_col >= E_CALENDAR_COLS_PER_MONTH) - return FALSE; - - *month = row * calitem->cols + col; - *day = day_row * E_CALENDAR_COLS_PER_MONTH + day_col; - *entire_week = FALSE; - - e_calendar_item_get_month_info (calitem, row, col, - &first_valid_day, &last_valid_day); - if (*day < first_valid_day || *day > last_valid_day) - return FALSE; - - return TRUE; -} - - -static void -e_calendar_item_get_month_info (ECalendarItem *calitem, - gint row, - gint col, - gint *first_valid_day, - gint *last_valid_day) -{ - gint year, month, days_in_month, start_weekday, first_day_of_month; - struct tm tmp_tm = { 0 }; - - month = calitem->month + row * calitem->cols + col; - year = calitem->year + month / 12; - month = month % 12; - days_in_month = g_date_days_in_month (month + 1, year); - - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = 1; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - - /* Convert to 0 (Monday) to 6 (Sunday). */ - start_weekday = (tmp_tm.tm_wday + 6) % 7; - - first_day_of_month = (start_weekday + 7 - calitem->week_start_day) % 7; - - if (row == 0 && col == 0) - *first_valid_day = 0; - else - *first_valid_day = first_day_of_month; - - if (row == calitem->rows - 1 && col == calitem->cols - 1) - *last_valid_day = E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH - 1; - else - *last_valid_day = first_day_of_month + days_in_month - 1; -} - - - - - - - - - - - - - - - - - - - - - - -#if 0 - -static gint -e_calendar_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - ECalendar *cal; - gint day; - - cal = E_CALENDAR (widget); - - g_print ("In e_calendar_button_press\n"); - - day = e_calendar_convert_position_to_day (cal, event->x, event->y); - - cal->selection_start_day = day; - cal->selection_end_day = day; - cal->selection_dragging_end = TRUE; - - gtk_widget_queue_draw (widget); - - return FALSE; -} - - -static gint -e_calendar_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - g_print ("In e_calendar_button_release\n"); - - return FALSE; -} - - -static gint -e_calendar_motion (GtkWidget *widget, - GdkEventMotion *event) -{ - ECalendar *cal; - gint x, y, day; - - cal = E_CALENDAR (widget); - - g_print ("In e_calendar_motion\n"); - - x = event->x; - y = event->y; - - if (event->is_hint || event->window != widget->window) - gtk_widget_get_pointer (widget, &x, &y); - - day = e_calendar_convert_position_to_day (cal, event->x, event->y); - - if (cal->selection_dragging_end) - cal->selection_end_day = day; - else - cal->selection_start_day = day; - - if (cal->selection_start_day > cal->selection_end_day) { - day = cal->selection_start_day; - cal->selection_start_day = cal->selection_end_day; - cal->selection_end_day = day; - cal->selection_dragging_end = !cal->selection_dragging_end; - } - - gtk_widget_queue_draw (widget); - - return FALSE; -} -#endif diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h deleted file mode 100644 index a59ca6d407..0000000000 --- a/widgets/misc/e-calendar-item.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 - */ -#ifndef _E_CALENDAR_ITEM_H_ -#define _E_CALENDAR_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * ECalendarItem - canvas item displaying a calendar. - */ - -#define E_CALENDAR_ITEM_YPAD1 1 -#define E_CALENDAR_ITEM_YPAD2 1 - -/* These index our colors array. */ -typedef enum -{ - E_CALENDAR_COLOR_SELECTION, - E_CALENDAR_COLOR_HIGHLIGHT, - E_CALENDAR_COLOR_TODAY, - - E_CALENDAR_COLOR_LAST -} ECalendarColors; - - -#define E_CALENDAR_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_calendar_item_get_type (), ECalendarItem)) -#define E_CALENDAR_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_calendar_item_get_type ())) -#define E_IS_CALENDAR_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_calendar_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The year & month of the first calendar being displayed. */ - gint year; - gint month; /* 0 to 11 */ - - /* Bounds of item. */ - gdouble x1, y1, x2, y2; - - /* The minimum & maximum number of rows & columns of months. */ - gint min_rows; - gint min_cols; - gint max_rows; - gint max_cols; - - /* The number of rows & columns of months. */ - gint rows; - gint cols; - - /* Whether we show week nubers. */ - gboolean show_week_numbers; - - /* The first day of the week, 0 (Monday) to 6 (Sunday). */ - gint week_start_day; - - /* Whether the cells expand to fill extra space. */ - gboolean expand; - - /* The minimum size of each month, based on the fonts used. */ - gint min_month_width; - gint min_month_height; - - /* The actual size of each month, after dividing extra space. */ - gint month_width; - gint month_height; - - /* The offset to the left edge of the first calendar. */ - gint x_offset; - - /* The padding around each calendar month. */ - gint month_lpad, month_rpad; - gint month_tpad, month_bpad; - - /* The size of each cell. */ - gint cell_width; - gint cell_height; - - - /* The current selection. The month offsets are from 0, which is the - top-left calendar month view. The day offsets are from 0, which is - the top-left cell in the month view (which may be empty). */ - gint selection_start_month_offset; - gint selection_start_day_offset; - gint selection_end_month_offset; - gint selection_end_day_offset; - gboolean selecting; - gboolean selection_dragging_end; - - /* The first character of each day of the week, e.g. 'MTWTFSS'. */ - gchar *days; - - /* Widths of the day characters. */ - gint day_widths[7]; - - /* Widths of the digits, '0' .. '9'. */ - gint digit_widths[10]; - gint max_digit_width; - gint week_number_digit_widths[10]; - gint max_week_number_digit_width; - - /* Fonts for drawing text. If font isn't set it uses the font from the - canvas widget. If week_number_font isn't set it uses font. */ - GdkFont *font, *old_font; - GdkFont *week_number_font, *old_week_number_font; - - /* Colors for drawing. */ - GdkColor colors[E_CALENDAR_COLOR_LAST]; -} ECalendarItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} ECalendarItemClass; - - -GtkType e_calendar_item_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CALENDAR_ITEM_H_ */ diff --git a/widgets/misc/e-calendar.c b/widgets/misc/e-calendar.c deleted file mode 100644 index ec85e3471f..0000000000 --- a/widgets/misc/e-calendar.c +++ /dev/null @@ -1,486 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 - */ - -/* - * ECalendar - displays a table of monthly calendars, allowing highlighting - * and selection of one or more days. Like GtkCalendar with more features. - * Most of the functionality is in the ECalendarItem canvas item, though - * we also add GnomeCanvasWidget buttons to go to the previous/next month and - * to got to the current day. - */ - -#include <config.h> -#include <e-util/e-util.h> -#include "e-calendar.h" - -#define E_CALENDAR_SMALL_FONT \ - "-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*" -#define E_CALENDAR_SMALL_FONT_FALLBACK \ - "-adobe-helvetica-medium-r-normal-*-*-80-*-*-p-*-iso8859-*" - -#define E_CALENDAR_BUTTON_X_PAD 2 -#define E_CALENDAR_BUTTON_Y_PAD 0 - -static void e_calendar_class_init (ECalendarClass *class); -static void e_calendar_init (ECalendar *cal); -static void e_calendar_destroy (GtkObject *object); -static void e_calendar_realize (GtkWidget *widget); -static void e_calendar_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void e_calendar_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void e_calendar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint e_calendar_expose (GtkWidget *widget, - GdkEventExpose *event); -static void e_calendar_draw (GtkWidget *widget, - GdkRectangle *area); -#if 0 -static gint e_calendar_button_press (GtkWidget *widget, - GdkEventButton *event); -static gint e_calendar_button_release (GtkWidget *widget, - GdkEventButton *event); -#endif -static gint e_calendar_focus_in (GtkWidget *widget, - GdkEventFocus *event); -static gint e_calendar_focus_out (GtkWidget *widget, - GdkEventFocus *event); -static gint e_calendar_key_press (GtkWidget *widget, - GdkEventKey *event); - -static void e_calendar_paint (ECalendar *cal, - GdkRectangle *area); - -static void e_calendar_on_prev_clicked (ECalendar *cal); -static void e_calendar_on_next_clicked (ECalendar *cal); - -static GnomeCanvasClass *parent_class; -static GtkLayoutClass *grandparent_class; - -E_MAKE_TYPE (e_calendar, "ECalendar", ECalendar, - e_calendar_class_init, e_calendar_init, E_CANVAS_TYPE) - - -static void -e_calendar_class_init (ECalendarClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (E_CANVAS_TYPE); - grandparent_class = gtk_type_class (GTK_TYPE_LAYOUT); - - object_class->destroy = e_calendar_destroy; - - widget_class->realize = e_calendar_realize; - widget_class->style_set = e_calendar_style_set; - widget_class->size_request = e_calendar_size_request; - widget_class->size_allocate = e_calendar_size_allocate; - widget_class->expose_event = e_calendar_expose; - widget_class->draw = e_calendar_draw; -#if 0 - widget_class->button_press_event = e_calendar_button_press; - widget_class->button_release_event = e_calendar_button_release; -#endif - widget_class->focus_in_event = e_calendar_focus_in; - widget_class->focus_out_event = e_calendar_focus_out; - widget_class->key_press_event = e_calendar_key_press; -} - - -static void -e_calendar_init (ECalendar *cal) -{ - GnomeCanvasGroup *canvas_group; - GdkFont *small_font; - GtkWidget *button, *arrow; - - /* Create the small font. */ - small_font = gdk_font_load (E_CALENDAR_SMALL_FONT); - if (!small_font) - small_font = gdk_font_load (E_CALENDAR_SMALL_FONT_FALLBACK); - if (!small_font) - g_warning ("Couldn't load font"); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (cal)->root); - - cal->calitem = E_CALENDAR_ITEM (gnome_canvas_item_new (canvas_group, - e_calendar_item_get_type (), - "week_number_font", small_font, - "week_start_day", 6, - NULL)); - -#if 0 - "show_week_numbers", TRUE, - "minimum_columns", 5, - "maximum_columns", 5, -#endif - - if (small_font) - gdk_font_unref (small_font); - - - button = gtk_button_new (); - /* FIXME: The buttons doesn't display properly if we do this. */ - /*gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);*/ - gtk_widget_show (button); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (e_calendar_on_prev_clicked), - GTK_OBJECT (cal)); - arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_OUT); - gtk_widget_show (arrow); - gtk_container_add (GTK_CONTAINER (button), arrow); - cal->prev_item = gnome_canvas_item_new (canvas_group, - gnome_canvas_widget_get_type (), - "widget", button, - NULL); - - button = gtk_button_new (); - /*gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);*/ - gtk_widget_show (button); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (e_calendar_on_next_clicked), - GTK_OBJECT (cal)); - arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT); - gtk_widget_show (arrow); - gtk_container_add (GTK_CONTAINER (button), arrow); - cal->next_item = gnome_canvas_item_new (canvas_group, - gnome_canvas_widget_get_type (), - "widget", button, - NULL); - - cal->min_rows = 1; - cal->min_cols = 1; - cal->max_rows = -1; - cal->max_cols = -1; -} - - -/** - * e_calendar_new: - * @Returns: a new #ECalendar. - * - * Creates a new #ECalendar. - **/ -GtkWidget * -e_calendar_new (void) -{ - GtkWidget *cal; - - cal = gtk_type_new (e_calendar_get_type ()); - - return cal; -} - - -static void -e_calendar_destroy (GtkObject *object) -{ - ECalendar *cal; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_CALENDAR (object)); - - cal = E_CALENDAR (object); - - - -} - - -static void -e_calendar_realize (GtkWidget *widget) -{ - (*GTK_WIDGET_CLASS (parent_class)->realize) (widget); -} - - -static void -e_calendar_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ -} - - -static void -e_calendar_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - ECalendar *cal; - GtkStyle *style; - gdouble col_width, row_height; - gint width, height; - - cal = E_CALENDAR (widget); - style = GTK_WIDGET (cal)->style; - - gtk_object_get (GTK_OBJECT (cal->calitem), - "row_height", &row_height, - "column_width", &col_width, - NULL); - - height = row_height * cal->min_rows; - width = col_width * cal->min_cols; - - /* FIXME: Add on space for line & button if shown. */ - - requisition->width = width + style->klass->xthickness * 2; - requisition->height = height + style->klass->ythickness * 2; -} - - -static void -e_calendar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - ECalendar *cal; - GdkFont *font; - gdouble old_x2, old_y2, new_x2, new_y2; - gdouble xthickness, ythickness, button_size; - - cal = E_CALENDAR (widget); - font = widget->style->font; - xthickness = widget->style->klass->xthickness; - ythickness = widget->style->klass->ythickness; - - (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); - - /* Set the scroll region to its allocated size, if changed. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (cal), - NULL, NULL, &old_x2, &old_y2); - new_x2 = widget->allocation.width - 1; - new_y2 = widget->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (cal), - 0, 0, new_x2, new_y2); - - /* FIXME: Take off space for line & buttons if shown. */ - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "x1", 0.0, - "y1", 0.0, - "x2", new_x2, - "y2", new_y2, - NULL); - - button_size = font->ascent + font->descent + E_CALENDAR_ITEM_YPAD1 - + E_CALENDAR_ITEM_YPAD2 - E_CALENDAR_BUTTON_Y_PAD * 2; - - gnome_canvas_item_set (cal->prev_item, - "x", xthickness * 2 + E_CALENDAR_BUTTON_X_PAD, - "y", ythickness * 2 + E_CALENDAR_BUTTON_Y_PAD, - "width", button_size, - "height", button_size, - NULL); - - gnome_canvas_item_set (cal->next_item, - "x", new_x2 + 1 - xthickness * 2 - - E_CALENDAR_BUTTON_X_PAD - button_size, - "y", ythickness * 2 + E_CALENDAR_BUTTON_Y_PAD, - "width", button_size, - "height", button_size, - NULL); -} - - -static gint -e_calendar_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - ECalendar *cal; - - cal = E_CALENDAR (widget); - - (*GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); - - e_calendar_paint (cal, &event->area); - - return FALSE; -} - - -static void -e_calendar_draw (GtkWidget *widget, - GdkRectangle *area) -{ - ECalendar *cal; - - cal = E_CALENDAR (widget); - - (*GTK_WIDGET_CLASS (parent_class)->draw) (widget, area); - - (*GTK_WIDGET_CLASS (grandparent_class)->draw) (widget, area); - - e_calendar_paint (cal, area); -} - - -static void -e_calendar_paint (ECalendar *cal, - GdkRectangle *area) -{ -#if 0 - g_print ("In e_calendar_paint: %i,%i %ix%i\n", area->x, area->y, - area->width, area->height); -#endif -} - - -/* FIXME These aren't used? */ - -#if 0 -static gint -e_calendar_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - ECalendar *cal; - - cal = E_CALENDAR (widget); - - g_print ("In e_calendar_button_press\n"); - - return FALSE; -} - - -static gint -e_calendar_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - g_print ("In e_calendar_button_release\n"); - - return FALSE; -} -#endif - - -static gint -e_calendar_focus_in (GtkWidget *widget, - GdkEventFocus *event) -{ - return FALSE; -} - - -static gint -e_calendar_focus_out (GtkWidget *widget, - GdkEventFocus *event) -{ - return FALSE; -} - - -static gint -e_calendar_key_press (GtkWidget *widget, - GdkEventKey *event) -{ - return FALSE; -} - - -void -e_calendar_set_minimum_size (ECalendar *cal, - gint rows, - gint cols) -{ - g_return_if_fail (E_IS_CALENDAR (cal)); - - cal->min_rows = rows; - cal->min_cols = cols; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "minimum_rows", rows, - "minimum_columns", cols, - NULL); - - gtk_widget_queue_resize (GTK_WIDGET (cal)); -} - - -void -e_calendar_set_maximum_size (ECalendar *cal, - gint rows, - gint cols) -{ - g_return_if_fail (E_IS_CALENDAR (cal)); - - cal->max_rows = rows; - cal->max_cols = cols; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "maximum_rows", rows, - "maximum_columns", cols, - NULL); - - gtk_widget_queue_resize (GTK_WIDGET (cal)); -} - - -static void -e_calendar_on_prev_clicked (ECalendar *cal) -{ - gint year, month; - - gtk_object_get (GTK_OBJECT (cal->calitem), - "year", &year, - "month", &month, - NULL); - - month--; - if (month == -1) { - year--; - month = 11; - } - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "year", year, - "month", month, - NULL); -} - - -static void -e_calendar_on_next_clicked (ECalendar *cal) -{ - gint year, month; - - gtk_object_get (GTK_OBJECT (cal->calitem), - "year", &year, - "month", &month, - NULL); - - month++; - if (month == 12) { - year++; - month = 0; - } - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "year", year, - "month", month, - NULL); -} - diff --git a/widgets/misc/e-calendar.h b/widgets/misc/e-calendar.h deleted file mode 100644 index b0e9c1f985..0000000000 --- a/widgets/misc/e-calendar.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 - */ -#ifndef _E_CALENDAR_H_ -#define _E_CALENDAR_H_ - -#include <gtk/gtkwidget.h> -#include "e-util/e-canvas.h" -#include "e-calendar-item.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * ECalendar - displays a table of monthly calendars, allowing highlighting - * and selection of one or more days. Like GtkCalendar with more features. - * Most of the functionality is in the ECalendarItem canvas item, though - * we also add GnomeCanvasWidget buttons to go to the previous/next month and - * to got to the current day. - */ - -#define E_CALENDAR(obj) GTK_CHECK_CAST (obj, e_calendar_get_type (), ECalendar) -#define E_CALENDAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_calendar_get_type (), ECalendarClass) -#define E_IS_CALENDAR(obj) GTK_CHECK_TYPE (obj, e_calendar_get_type ()) - - -typedef struct _ECalendar ECalendar; -typedef struct _ECalendarClass ECalendarClass; - -struct _ECalendar -{ - ECanvas canvas; - - ECalendarItem *calitem; - - GnomeCanvasItem *prev_item, *next_item; - - gint min_rows; - gint min_cols; - - gint max_rows; - gint max_cols; -}; - -struct _ECalendarClass -{ - ECanvasClass parent_class; -}; - - -GtkType e_calendar_get_type (void); -GtkWidget* e_calendar_new (void); - -void e_calendar_set_minimum_size (ECalendar *cal, - gint rows, - gint cols); -void e_calendar_set_maximum_size (ECalendar *cal, - gint rows, - gint cols); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CALENDAR_H_ */ diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c deleted file mode 100644 index ac61545b5f..0000000000 --- a/widgets/misc/e-canvas-utils.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-canvas-utils.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "e-canvas-utils.h" - -void -e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy) -{ - double translate[6]; - - g_return_if_fail (item != NULL); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - art_affine_translate (translate, dx, dy); - - gnome_canvas_item_affine_absolute (item, translate); -} - -void -e_canvas_item_show_area (GnomeCanvasItem *item, double x1, double y1, double x2, double y2) -{ - GtkAdjustment *h, *v; - double dx = 0, dy = 0; - - g_return_if_fail (item != NULL); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - gnome_canvas_item_i2w(item, &x1, &y1); - gnome_canvas_item_i2w(item, &x2, &y2); - - h = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - v = gtk_layout_get_vadjustment(GTK_LAYOUT(item->canvas)); - - if (x2 > h->value + h->page_size) - dx = (x2 - (h->value + h->page_size)); - if (y2 > v->value + v->page_size) - dy = (y2 - (v->value + v->page_size)); - - if (x1 < h->value + dx) - dx = (x1 - h->value); - if (y1 < v->value + dy) - dy = (y1 - v->value); - - if (dx) - gtk_adjustment_set_value(h, h->value + dx); - if (dy) - gtk_adjustment_set_value(v, v->value + dy); -} diff --git a/widgets/misc/e-canvas-utils.h b/widgets/misc/e-canvas-utils.h deleted file mode 100644 index a940ea393c..0000000000 --- a/widgets/misc/e-canvas-utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-canvas-utils.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __E_CANVAS_UTILS__ -#define __E_CANVAS_UTILS__ - -#include <gnome.h> -void e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy); -void e_canvas_item_show_area (GnomeCanvasItem *item, double x1, double y1, double x2, double y2); - -#endif /* __E_CANVAS_UTILS__ */ diff --git a/widgets/misc/e-canvas-vbox.c b/widgets/misc/e-canvas-vbox.c deleted file mode 100644 index 2d389a83e6..0000000000 --- a/widgets/misc/e-canvas-vbox.c +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-canvas-vbox.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <math.h> -#include "e-canvas-vbox.h" -#include <e-util/e-canvas-utils.h> -#include <e-util/e-canvas.h> -#include <e-util/e-util.h> - -static void e_canvas_vbox_init (ECanvasVbox *CanvasVbox); -static void e_canvas_vbox_class_init (ECanvasVboxClass *klass); -static void e_canvas_vbox_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_canvas_vbox_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_canvas_vbox_destroy (GtkObject *object); - -static gint e_canvas_vbox_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_canvas_vbox_realize (GnomeCanvasItem *item); - -static void e_canvas_vbox_reflow (GnomeCanvasItem *item, int flags); - -static void e_canvas_vbox_real_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item); -static void e_canvas_vbox_resize_children (GnomeCanvasItem *item); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_SPACING, -}; - -GtkType -e_canvas_vbox_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GtkTypeInfo info = - { - "ECanvasVbox", - sizeof (ECanvasVbox), - sizeof (ECanvasVboxClass), - (GtkClassInitFunc) e_canvas_vbox_class_init, - (GtkObjectInitFunc) e_canvas_vbox_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gnome_canvas_group_get_type (), &info); - } - - return type; -} - -static void -e_canvas_vbox_class_init (ECanvasVboxClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("ECanvasVbox::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("ECanvasVbox::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("ECanvasVbox::spacing", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_SPACING); - - klass->add_item = e_canvas_vbox_real_add_item; - - object_class->set_arg = e_canvas_vbox_set_arg; - object_class->get_arg = e_canvas_vbox_get_arg; - object_class->destroy = e_canvas_vbox_destroy; - - /* GnomeCanvasItem method overrides */ - item_class->event = e_canvas_vbox_event; - item_class->realize = e_canvas_vbox_realize; -} - -static void -e_canvas_vbox_init (ECanvasVbox *vbox) -{ - vbox->items = NULL; - - vbox->width = 10; - vbox->height = 10; - vbox->spacing = 0; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(vbox), e_canvas_vbox_reflow); -} - -static void -e_canvas_vbox_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ECanvasVbox *e_canvas_vbox; - - item = GNOME_CANVAS_ITEM (o); - e_canvas_vbox = E_CANVAS_VBOX (o); - - switch (arg_id){ - case ARG_WIDTH: - e_canvas_vbox->width = GTK_VALUE_DOUBLE (*arg); - e_canvas_vbox_resize_children(item); - e_canvas_item_request_reflow(item); - break; - case ARG_SPACING: - e_canvas_vbox->spacing = GTK_VALUE_DOUBLE (*arg); - e_canvas_item_request_reflow(item); - break; - } -} - -static void -e_canvas_vbox_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ECanvasVbox *e_canvas_vbox; - - e_canvas_vbox = E_CANVAS_VBOX (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_canvas_vbox->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_canvas_vbox->height; - break; - case ARG_SPACING: - GTK_VALUE_DOUBLE (*arg) = e_canvas_vbox->spacing; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_canvas_vbox_destroy (GtkObject *object) -{ - ECanvasVbox *vbox = E_CANVAS_VBOX(object); - - g_list_foreach(vbox->items, (GFunc) gtk_object_unref, NULL); - g_list_free(vbox->items); - vbox->items = NULL; - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -static gint -e_canvas_vbox_event (GnomeCanvasItem *item, GdkEvent *event) -{ - gint return_val = TRUE; - - switch (event->type) { - case GDK_KEY_PRESS: - switch (event->key.keyval) { - case GDK_Tab: - case GDK_KP_Tab: - case GDK_ISO_Left_Tab: - case GDK_Left: - case GDK_KP_Left: - case GDK_Right: - case GDK_KP_Right: - case GDK_Down: - case GDK_KP_Down: - case GDK_Up: - case GDK_KP_Up: - case GDK_Return: - case GDK_KP_Enter: - return_val = TRUE; - break; - default: - return_val = FALSE; - break; - } - break; - default: - return_val = FALSE; - break; - } - if (!return_val) { - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event) - return GNOME_CANVAS_ITEM_CLASS (parent_class)->event (item, event); - } - return return_val; - -} - -static void -e_canvas_vbox_realize (GnomeCanvasItem *item) -{ - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_canvas_vbox_resize_children(item); - e_canvas_item_request_reflow(item); -} - -static void -e_canvas_vbox_remove_item (GnomeCanvasItem *item, ECanvasVbox *vbox) -{ - vbox->items = g_list_remove(vbox->items, item); - gtk_object_unref(GTK_OBJECT(vbox)); -} - -static void -e_canvas_vbox_real_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item) -{ - e_canvas_vbox->items = g_list_append(e_canvas_vbox->items, item); - gtk_object_ref(GTK_OBJECT(item)); - gtk_object_ref(GTK_OBJECT(e_canvas_vbox)); - gtk_signal_connect(GTK_OBJECT(item), "destroy", - GTK_SIGNAL_FUNC(e_canvas_vbox_remove_item), e_canvas_vbox); - if ( GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED ) { - gnome_canvas_item_set(item, - "width", (double) e_canvas_vbox->width, - NULL); - e_canvas_item_request_reflow(item); - } - -} - -static void -e_canvas_vbox_resize_children (GnomeCanvasItem *item) -{ - GList *list; - ECanvasVbox *e_canvas_vbox; - - e_canvas_vbox = E_CANVAS_VBOX (item); - for ( list = e_canvas_vbox->items; list; list = list->next ) { - GnomeCanvasItem *child = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(child, - "width", (double) e_canvas_vbox->width, - NULL); - } -} - -static void -e_canvas_vbox_reflow( GnomeCanvasItem *item, int flags ) -{ - ECanvasVbox *e_canvas_vbox = E_CANVAS_VBOX(item); - if ( GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED ) { - - gdouble old_height; - gdouble running_height; - - old_height = e_canvas_vbox->height; - - running_height = 0; - - if (e_canvas_vbox->items == NULL) { - } else { - GList *list; - gdouble item_height; - - list = e_canvas_vbox->items; - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), - (double) 0, - (double) running_height); - running_height += item_height; - list = g_list_next(list); - - for( ; list; list = g_list_next(list)) { - running_height += e_canvas_vbox->spacing; - - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), - (double) 0, - (double) running_height); - - running_height += item_height; - } - - } - e_canvas_vbox->height = running_height; - if (old_height != e_canvas_vbox->height) - e_canvas_item_request_parent_reflow(item); - } -} - -void -e_canvas_vbox_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item) -{ - if (E_CANVAS_VBOX_CLASS(GTK_OBJECT(e_canvas_vbox)->klass)->add_item) - (E_CANVAS_VBOX_CLASS(GTK_OBJECT(e_canvas_vbox)->klass)->add_item) (e_canvas_vbox, item); -} diff --git a/widgets/misc/e-canvas-vbox.h b/widgets/misc/e-canvas-vbox.h deleted file mode 100644 index c45baa0b0a..0000000000 --- a/widgets/misc/e-canvas-vbox.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-canvas-vbox.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CANVAS_VBOX_H__ -#define __E_CANVAS_VBOX_H__ - -#include <gnome.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ECanvasVbox - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the CanvasVbox - * height double R height of the CanvasVbox - * spacing double RW Spacing between items. - */ - -#define E_CANVAS_VBOX_TYPE (e_canvas_vbox_get_type ()) -#define E_CANVAS_VBOX(obj) (GTK_CHECK_CAST ((obj), E_CANVAS_VBOX_TYPE, ECanvasVbox)) -#define E_CANVAS_VBOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CANVAS_VBOX_TYPE, ECanvasVboxClass)) -#define E_IS_CANVAS_VBOX(obj) (GTK_CHECK_TYPE ((obj), E_CANVAS_VBOX_TYPE)) -#define E_IS_CANVAS_VBOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CANVAS_VBOX_TYPE)) - - -typedef struct _ECanvasVbox ECanvasVbox; -typedef struct _ECanvasVboxClass ECanvasVboxClass; - -struct _ECanvasVbox -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - GList *items; /* Of type GnomeCanvasItem */ - - double width; - double height; - double spacing; -}; - -struct _ECanvasVboxClass -{ - GnomeCanvasGroupClass parent_class; - - /* Virtual methods. */ - void (* add_item) (ECanvasVbox *CanvasVbox, GnomeCanvasItem *item); -}; - -/* - * To be added to a CanvasVbox, an item must have the argument "width" as - * a Read/Write argument and "height" as a Read Only argument. It - * should also do an ECanvas parent CanvasVbox request if its size - * changes. - */ -void e_canvas_vbox_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item); -GtkType e_canvas_vbox_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CANVAS_VBOX_H__ */ diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c deleted file mode 100644 index fb67bf0379..0000000000 --- a/widgets/misc/e-canvas.c +++ /dev/null @@ -1,696 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-canvas.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <gnome.h> -#include "e-canvas.h" -static void e_canvas_init (ECanvas *card); -static void e_canvas_destroy (GtkObject *object); -static void e_canvas_class_init (ECanvasClass *klass); -static void e_canvas_realize (GtkWidget *widget); -static void e_canvas_unrealize (GtkWidget *widget); -static gint e_canvas_key (GtkWidget *widget, - GdkEventKey *event); - -static gint e_canvas_focus_in (GtkWidget *widget, - GdkEventFocus *event); -static gint e_canvas_focus_out (GtkWidget *widget, - GdkEventFocus *event); - -static int emit_event (GnomeCanvas *canvas, GdkEvent *event); - -static GnomeCanvasClass *parent_class = NULL; - -enum { - REFLOW, - LAST_SIGNAL -}; - -static guint e_canvas_signals [LAST_SIGNAL] = { 0, }; - -GtkType -e_canvas_get_type (void) -{ - static GtkType canvas_type = 0; - - if (!canvas_type) - { - static const GtkTypeInfo canvas_info = - { - "ECanvas", - sizeof (ECanvas), - sizeof (ECanvasClass), - (GtkClassInitFunc) e_canvas_class_init, - (GtkObjectInitFunc) e_canvas_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - canvas_type = gtk_type_unique (gnome_canvas_get_type (), &canvas_info); - } - - return canvas_type; -} - -static void -e_canvas_class_init (ECanvasClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasClass *canvas_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) klass; - canvas_class = (GnomeCanvasClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_get_type ()); - - object_class->destroy = e_canvas_destroy; - - widget_class->key_press_event = e_canvas_key; - widget_class->key_release_event = e_canvas_key; - widget_class->focus_in_event = e_canvas_focus_in; - widget_class->focus_out_event = e_canvas_focus_out; - widget_class->realize = e_canvas_realize; - widget_class->unrealize = e_canvas_unrealize; - - klass->reflow = NULL; - - e_canvas_signals [REFLOW] = - gtk_signal_new ("reflow", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ECanvasClass, reflow), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_canvas_signals, LAST_SIGNAL); -} - -static void -e_canvas_init (ECanvas *canvas) -{ - canvas->selection = NULL; - canvas->cursor = NULL; - canvas->ic = NULL; - canvas->ic_attr = NULL; -} - -static void -e_canvas_destroy (GtkObject *object) -{ - ECanvas *canvas = E_CANVAS(object); - if (canvas->idle_id) - g_source_remove(canvas->idle_id); - if ((GTK_OBJECT_CLASS (parent_class))->destroy) - (*(GTK_OBJECT_CLASS (parent_class))->destroy) (object); -} - -GtkWidget * -e_canvas_new () -{ - return GTK_WIDGET (gtk_type_new (e_canvas_get_type ())); -} - - -/* Returns whether the item is an inferior of or is equal to the parent. */ -static int -is_descendant (GnomeCanvasItem *item, GnomeCanvasItem *parent) -{ - for (; item; item = item->parent) - if (item == parent) - return TRUE; - - return FALSE; -} - -/* Emits an event for an item in the canvas, be it the current item, grabbed - * item, or focused item, as appropriate. - */ -static int -emit_event (GnomeCanvas *canvas, GdkEvent *event) -{ - /*GdkEvent ev;*/ - gint finished; - GnomeCanvasItem *item; - GnomeCanvasItem *parent; - guint mask; - - /* Perform checks for grabbed items */ - - if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) - return FALSE; - - if (canvas->grabbed_item) { - switch (event->type) { - case GDK_ENTER_NOTIFY: - mask = GDK_ENTER_NOTIFY_MASK; - break; - - case GDK_LEAVE_NOTIFY: - mask = GDK_LEAVE_NOTIFY_MASK; - break; - - case GDK_MOTION_NOTIFY: - mask = GDK_POINTER_MOTION_MASK; - break; - - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - mask = GDK_BUTTON_PRESS_MASK; - break; - - case GDK_BUTTON_RELEASE: - mask = GDK_BUTTON_RELEASE_MASK; - break; - - case GDK_KEY_PRESS: - mask = GDK_KEY_PRESS_MASK; - break; - - case GDK_KEY_RELEASE: - mask = GDK_KEY_RELEASE_MASK; - break; - - default: - mask = 0; - break; - } - - if (!(mask & canvas->grabbed_event_mask)) - return FALSE; - } - - /* Convert to world coordinates -- we have two cases because of diferent - * offsets of the fields in the event structures. - */ - - /*ev = *event;*/ - - switch (event->type) { - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - gnome_canvas_window_to_world (canvas, - event->crossing.x, - event->crossing.y, - &(event->crossing.x), - &(event->crossing.y)); - break; - - case GDK_MOTION_NOTIFY: - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - gnome_canvas_window_to_world (canvas, - event->motion.x, - event->motion.y, - &(event->motion.x), - &(event->motion.y)); - break; - - default: - break; - } - - /* Choose where we send the event */ - - item = canvas->current_item; - - if (canvas->focused_item - && ((event->type == GDK_KEY_PRESS) || (event->type == GDK_KEY_RELEASE) || (event->type == GDK_FOCUS_CHANGE))) - item = canvas->focused_item; - - /* The event is propagated up the hierarchy (for if someone connected to - * a group instead of a leaf event), and emission is stopped if a - * handler returns TRUE, just like for GtkWidget events. - */ - - finished = FALSE; - - while (item && !finished) { - gtk_object_ref (GTK_OBJECT (item)); - - gtk_signal_emit_by_name (GTK_OBJECT (item), "event", - event, - &finished); - - if (GTK_OBJECT_DESTROYED (item)) - finished = TRUE; - - parent = item->parent; - gtk_object_unref (GTK_OBJECT (item)); - - item = parent; - } - - return finished; -} - -/* Key event handler for the canvas */ -static gint -e_canvas_key (GtkWidget *widget, GdkEventKey *event) -{ - GnomeCanvas *canvas; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - canvas = GNOME_CANVAS (widget); - - return emit_event (canvas, (GdkEvent *) event); -} - - -/** - * e_canvas_item_grab_focus: - * @item: A canvas item. - * - * Makes the specified item take the keyboard focus, so all keyboard events will - * be sent to it. If the canvas widget itself did not have the focus, it grabs - * it as well. - **/ -void -e_canvas_item_grab_focus (GnomeCanvasItem *item) -{ - GnomeCanvasItem *focused_item; - GdkEvent ev; - - g_return_if_fail (item != NULL); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - g_return_if_fail (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (item->canvas))); - - focused_item = item->canvas->focused_item; - - if (focused_item) { - ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; - ev.focus_change.send_event = FALSE; - ev.focus_change.in = FALSE; - - emit_event (item->canvas, &ev); - } - - item->canvas->focused_item = item; - - if (!GTK_WIDGET_HAS_FOCUS (GTK_WIDGET(item->canvas))) { - gtk_widget_grab_focus (GTK_WIDGET (item->canvas)); - } - - if (focused_item) { - ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; - ev.focus_change.send_event = FALSE; - ev.focus_change.in = TRUE; - - emit_event (item->canvas, &ev); - } -} - -/* Focus in handler for the canvas */ -static gint -e_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) -{ - GnomeCanvas *canvas; - ECanvas *ecanvas; - - canvas = GNOME_CANVAS (widget); - ecanvas = E_CANVAS (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); - - if (ecanvas->ic) - gdk_im_begin (ecanvas->ic, canvas->layout.bin_window); - - if (canvas->focused_item) - return emit_event (canvas, (GdkEvent *) event); - else - return FALSE; -} - -/* Focus out handler for the canvas */ -static gint -e_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) -{ - GnomeCanvas *canvas; - ECanvas *ecanvas; - - canvas = GNOME_CANVAS (widget); - ecanvas = E_CANVAS (widget); - - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - - if (ecanvas->ic) - gdk_im_end (); - - if (canvas->focused_item) - return emit_event (canvas, (GdkEvent *) event); - else - return FALSE; -} - -static void -e_canvas_realize (GtkWidget *widget) -{ - ECanvas *ecanvas = E_CANVAS (widget); - - if (GTK_WIDGET_CLASS (parent_class)->realize) - (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); - - gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window, NULL, FALSE); - - if (gdk_im_ready () && (ecanvas->ic_attr = gdk_ic_attr_new ()) != NULL) { - GdkEventMask mask; - GdkICAttr *attr = ecanvas->ic_attr; - GdkICAttributesType attrmask = GDK_IC_ALL_REQ; - GdkIMStyle style; - GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE | - GDK_IM_PREEDIT_NOTHING | - GDK_IM_STATUS_NONE | - GDK_IM_STATUS_NOTHING; - - attr->style = style = gdk_im_decide_style (supported_style); - attr->client_window = ecanvas->parent.layout.bin_window; - - ecanvas->ic = gdk_ic_new (attr, attrmask); - if (ecanvas->ic != NULL) { - mask = gdk_window_get_events (attr->client_window); - mask |= gdk_ic_get_events (ecanvas->ic); - gdk_window_set_events (attr->client_window, mask); - - if (GTK_WIDGET_HAS_FOCUS (widget)) - gdk_im_begin (ecanvas->ic, attr->client_window); - } else - g_warning ("Can't create input context."); - } - -} - -static void -e_canvas_unrealize (GtkWidget *widget) -{ - ECanvas * ecanvas = E_CANVAS (widget); - if (ecanvas->ic) { - gdk_ic_destroy (ecanvas->ic); - ecanvas->ic = NULL; - } - if (ecanvas->ic_attr) { - gdk_ic_attr_destroy (ecanvas->ic_attr); - ecanvas->ic_attr = NULL; - } - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); -} - -static void -e_canvas_item_invoke_reflow (GnomeCanvasItem *item, int flags) -{ - GnomeCanvasGroup *group; - GList *list; - GnomeCanvasItem *child; - - if (GNOME_IS_CANVAS_GROUP (item)) { - group = GNOME_CANVAS_GROUP (item); - for (list = group->item_list; list; list = list->next) { - child = GNOME_CANVAS_ITEM (list->data); - if (child->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) - e_canvas_item_invoke_reflow (child, flags); - } - } - - if (item->object.flags & E_CANVAS_ITEM_NEEDS_REFLOW) { - ECanvasItemReflowFunc func; - func = gtk_object_get_data (GTK_OBJECT (item), - "ECanvasItem::reflow_callback"); - if (func) - func (item, flags); - } - - item->object.flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW; - item->object.flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; -} - -static void -do_reflow (ECanvas *canvas) -{ - if (GNOME_CANVAS(canvas)->root->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) - e_canvas_item_invoke_reflow (GNOME_CANVAS(canvas)->root, 0); -} - -/* Idle handler for the e-canvas. It deals with pending reflows. */ -static gint -idle_handler (gpointer data) -{ - ECanvas *canvas; - - GDK_THREADS_ENTER(); - - canvas = E_CANVAS (data); - do_reflow (canvas); - - /* Reset idle id */ - canvas->idle_id = 0; - - gtk_signal_emit (GTK_OBJECT (canvas), - e_canvas_signals [REFLOW]); - - GDK_THREADS_LEAVE(); - - return FALSE; -} - -/* Convenience function to add an idle handler to a canvas */ -static void -add_idle (ECanvas *canvas) -{ - if (canvas->idle_id != 0) - return; - - canvas->idle_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, idle_handler, (gpointer) canvas, NULL); -} - -static void -e_canvas_item_descendent_needs_reflow (GnomeCanvasItem *item) -{ - if (item->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) - return; - - item->object.flags |= E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; - if (item->parent) - e_canvas_item_descendent_needs_reflow(item->parent); -} - -void -e_canvas_item_request_reflow (GnomeCanvasItem *item) -{ - if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) { - item->object.flags |= E_CANVAS_ITEM_NEEDS_REFLOW; - e_canvas_item_descendent_needs_reflow(item); - add_idle(E_CANVAS(item->canvas)); - } -} - -void -e_canvas_item_request_parent_reflow (GnomeCanvasItem *item) -{ - g_return_if_fail(item != NULL); - g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); - e_canvas_item_request_reflow(item->parent); -} - -void -e_canvas_item_set_reflow_callback (GnomeCanvasItem *item, ECanvasItemReflowFunc func) -{ - gtk_object_set_data(GTK_OBJECT(item), "ECanvasItem::reflow_callback", (gpointer) func); -} - - -void -e_canvas_item_set_selection_callback (GnomeCanvasItem *item, ECanvasItemSelectionFunc func) -{ - gtk_object_set_data(GTK_OBJECT(item), "ECanvasItem::selection_callback", (gpointer) func); -} - -void -e_canvas_item_set_selection_compare_callback (GnomeCanvasItem *item, ECanvasItemSelectionCompareFunc func) -{ - gtk_object_set_data(GTK_OBJECT(item), "ECanvasItem::selection_compare_callback", (gpointer) func); -} - -void -e_canvas_item_set_cursor (GnomeCanvasItem *item, gpointer id) -{ - GList *list; - int flags; - ECanvas *canvas; - ECanvasSelectionInfo *info; - ECanvasItemSelectionFunc func; - - g_return_if_fail(item != NULL); - g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); - g_return_if_fail(item->canvas != NULL); - g_return_if_fail(E_IS_CANVAS(item->canvas)); - - canvas = E_CANVAS(item->canvas); - flags = E_CANVAS_ITEM_SELECTION_DELETE_DATA; - - for (list = canvas->selection; list; list = g_list_next(list)) { - info = list->data; - - func = gtk_object_get_data(GTK_OBJECT(info->item), "ECanvasItem::selection_callback"); - if (func) - func(info->item, flags, info->id); - g_message ("ECANVAS: free info (2): item %p, id %p", - info->item, info->id); - gtk_object_unref (GTK_OBJECT (info->item)); - g_free(info); - } - g_list_free(canvas->selection); - - canvas->selection = NULL; - - gnome_canvas_item_grab_focus(item); - - info = g_new(ECanvasSelectionInfo, 1); - info->item = item; - gtk_object_ref (GTK_OBJECT (info->item)); - info->id = id; - g_message ("ECANVAS: new info item %p, id %p", item, id); - - flags = E_CANVAS_ITEM_SELECTION_SELECT | E_CANVAS_ITEM_SELECTION_CURSOR; - func = gtk_object_get_data(GTK_OBJECT(item), "ECanvasItem::selection_callback"); - if (func) - func(item, flags, id); - - canvas->selection = g_list_prepend(canvas->selection, info); - canvas->cursor = info; -} - -void -e_canvas_item_set_cursor_end (GnomeCanvasItem *item, gpointer id) -{ -} - -void -e_canvas_item_add_selection (GnomeCanvasItem *item, gpointer id) -{ - int flags; - ECanvas *canvas; - ECanvasSelectionInfo *info; - ECanvasItemSelectionFunc func; - GList *list; - - g_return_if_fail(item != NULL); - g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); - g_return_if_fail(item->canvas != NULL); - g_return_if_fail(E_IS_CANVAS(item->canvas)); - - flags = E_CANVAS_ITEM_SELECTION_SELECT; - canvas = E_CANVAS(item->canvas); - - if (canvas->cursor) { - func = gtk_object_get_data(GTK_OBJECT(canvas->cursor->item), "ECanvasItem::selection_callback"); - if (func) - func(canvas->cursor->item, flags, canvas->cursor->id); - } - - gnome_canvas_item_grab_focus(item); - - flags = E_CANVAS_ITEM_SELECTION_SELECT | E_CANVAS_ITEM_SELECTION_CURSOR; - - for (list = canvas->selection; list; list = g_list_next(list)) { - ECanvasSelectionInfo *search; - search = list->data; - - if (search->item == item) { - ECanvasItemSelectionCompareFunc compare_func; - compare_func = gtk_object_get_data(GTK_OBJECT(search->item), "ECanvasItem::selection_compare_callback"); - - if (compare_func(search->item, search->id, id, 0) == 0) { - canvas->cursor = search; - func = gtk_object_get_data(GTK_OBJECT(item), "ECanvasItem::selection_callback"); - if (func) - func(item, flags, search->id); - return; - } - } - } - - info = g_new(ECanvasSelectionInfo, 1); - info->item = item; - gtk_object_ref (GTK_OBJECT (info->item)); - info->id = id; - g_message ("ECANVAS: new info (2): item %p, id %p", item, id); - - func = gtk_object_get_data(GTK_OBJECT(item), "ECanvasItem::selection_callback"); - if (func) - func(item, flags, id); - - canvas->selection = g_list_prepend(canvas->selection, info); - canvas->cursor = info; -} - -void -e_canvas_item_remove_selection (GnomeCanvasItem *item, gpointer id) -{ - int flags; - ECanvas *canvas; - ECanvasSelectionInfo *info; - GList *list; - - g_return_if_fail(item != NULL); - g_return_if_fail(GNOME_IS_CANVAS_ITEM(item)); - g_return_if_fail(item->canvas != NULL); - g_return_if_fail(E_IS_CANVAS(item->canvas)); - - flags = E_CANVAS_ITEM_SELECTION_DELETE_DATA; - canvas = E_CANVAS(item->canvas); - - for (list = canvas->selection; list; list = g_list_next(list)) { - info = list->data; - - if (info->item == item) { - ECanvasItemSelectionCompareFunc compare_func; - compare_func = gtk_object_get_data(GTK_OBJECT(info->item), "ECanvasItem::selection_compare_callback"); - - if (compare_func(info->item, info->id, id, 0) == 0) { - ECanvasItemSelectionFunc func; - func = gtk_object_get_data(GTK_OBJECT(info->item), "ECanvasItem::selection_callback"); - if (func) - func(info->item, flags, info->id); - canvas->selection = g_list_remove_link(canvas->selection, list); - - if (canvas->cursor == info) - canvas->cursor = NULL; - - g_message ("ECANVAS: removing info: item %p, info %p", - info->item, info->id); - gtk_object_unref (GTK_OBJECT (info->item)); - g_free(info); - g_list_free_1(list); - break; - } - } - } -} diff --git a/widgets/misc/e-canvas.h b/widgets/misc/e-canvas.h deleted file mode 100644 index b13a9dd2ab..0000000000 --- a/widgets/misc/e-canvas.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-canvas.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CANVAS_H__ -#define __E_CANVAS_H__ - -#include <gnome.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ECanvas - A class derived from canvas for the purpose of adding - * evolution specific canvas hacks. - */ - -#define E_CANVAS_TYPE (e_canvas_get_type ()) -#define E_CANVAS(obj) (GTK_CHECK_CAST ((obj), E_CANVAS_TYPE, ECanvas)) -#define E_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CANVAS_TYPE, ECanvasClass)) -#define E_IS_CANVAS(obj) (GTK_CHECK_TYPE ((obj), E_CANVAS_TYPE)) -#define E_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CANVAS_TYPE)) - -typedef void (*ECanvasItemReflowFunc) (GnomeCanvasItem *item, - gint flags); - -typedef void (*ECanvasItemSelectionFunc) (GnomeCanvasItem *item, - gint flags, - gpointer user_data); -/* Returns the same as strcmp does. */ -typedef gint (*ECanvasItemSelectionCompareFunc) (GnomeCanvasItem *item, - gpointer data1, - gpointer data2, - gint flags); - - -typedef struct _ECanvas ECanvas; -typedef struct _ECanvasClass ECanvasClass; - -/* Object flags for items */ -enum { - E_CANVAS_ITEM_NEEDS_REFLOW = 1 << 13, - E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW = 1 << 14 -}; - -enum { - E_CANVAS_ITEM_SELECTION_SELECT = 1 << 0, /* TRUE = select. FALSE = unselect. */ - E_CANVAS_ITEM_SELECTION_CURSOR = 1 << 1, /* TRUE = has become cursor. FALSE = not cursor. */ - E_CANVAS_ITEM_SELECTION_DELETE_DATA = 1 << 2, -}; - -typedef struct { - GnomeCanvasItem *item; - gpointer id; -} ECanvasSelectionInfo; - -struct _ECanvas -{ - GnomeCanvas parent; - - int idle_id; - GList *selection; - ECanvasSelectionInfo *cursor; - - /* Input context for dead key support */ - GdkIC *ic; - GdkICAttr *ic_attr; -}; - -struct _ECanvasClass -{ - GnomeCanvasClass parent_class; - void (* reflow) (ECanvas *canvas); -}; - - -GtkType e_canvas_get_type (void); -GtkWidget *e_canvas_new (void); - -/* Used to send all of the keystroke events to a specific item as well as - * GDK_FOCUS_CHANGE events. - */ -void e_canvas_item_grab_focus (GnomeCanvasItem *item); - -void e_canvas_item_request_reflow (GnomeCanvasItem *item); -void e_canvas_item_request_parent_reflow (GnomeCanvasItem *item); -void e_canvas_item_set_reflow_callback (GnomeCanvasItem *item, ECanvasItemReflowFunc func); - -void e_canvas_item_set_selection_callback (GnomeCanvasItem *item, ECanvasItemSelectionFunc func); -void e_canvas_item_set_selection_compare_callback (GnomeCanvasItem *item, ECanvasItemSelectionCompareFunc func); - -void e_canvas_item_set_cursor (GnomeCanvasItem *item, gpointer id); -void e_canvas_item_add_selection (GnomeCanvasItem *item, gpointer id); -void e_canvas_item_remove_selection (GnomeCanvasItem *item, gpointer id); - -/* Not implemented yet. */ -void e_canvas_item_set_cursor_end (GnomeCanvasItem *item, gpointer id); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CANVAS_H__ */ diff --git a/widgets/misc/e-clipped-label.c b/widgets/misc/e-clipped-label.c deleted file mode 100644 index 6f6fc9731d..0000000000 --- a/widgets/misc/e-clipped-label.c +++ /dev/null @@ -1,378 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * This is similar to GtkLabel but clips itself and displays '...' if it - * can't fit inside its allocated area. The intended use is for inside buttons - * that are a fixed size. The GtkLabel would normally display only the middle - * part of the text, which doesn't look very good. This only supports one line - * of text (so no wrapping/justification), without underlined characters. - */ - -#include <math.h> - -#include <gdk/gdki18n.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-i18n.h> - -#include "e-clipped-label.h" - - -static void e_clipped_label_class_init (EClippedLabelClass *class); -static void e_clipped_label_init (EClippedLabel *label); -static void e_clipped_label_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void e_clipped_label_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint e_clipped_label_expose (GtkWidget *widget, - GdkEventExpose *event); -static void e_clipped_label_recalc_chars_displayed (EClippedLabel *label); -static void e_clipped_label_destroy (GtkObject *object); - - -static GtkMiscClass *parent_class; - -/* This is the string to draw when the label is clipped, e.g. '...'. */ -static gchar *e_clipped_label_ellipsis; - -/* Flags used in chars_displayed field. Must be negative. */ -#define E_CLIPPED_LABEL_NEED_RECALC -1 -#define E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL -2 - - -GtkType -e_clipped_label_get_type (void) -{ - static GtkType e_clipped_label_type = 0; - - if (!e_clipped_label_type){ - GtkTypeInfo e_clipped_label_info = { - "EClippedLabel", - sizeof (EClippedLabel), - sizeof (EClippedLabelClass), - (GtkClassInitFunc) e_clipped_label_class_init, - (GtkObjectInitFunc) e_clipped_label_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_MISC); - e_clipped_label_type = gtk_type_unique (GTK_TYPE_MISC, - &e_clipped_label_info); - } - - return e_clipped_label_type; -} - - -static void -e_clipped_label_class_init (EClippedLabelClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - widget_class->size_request = e_clipped_label_size_request; - widget_class->size_allocate = e_clipped_label_size_allocate; - widget_class->expose_event = e_clipped_label_expose; - - object_class->destroy = e_clipped_label_destroy; - - e_clipped_label_ellipsis = _("..."); -} - - -static void -e_clipped_label_init (EClippedLabel *label) -{ - GTK_WIDGET_SET_FLAGS (label, GTK_NO_WINDOW); - - label->label = NULL; - label->label_wc = NULL; - label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC; -} - - -/** - * e_clipped_label_new: - * - * @text: The label text. - * @Returns: A new #EClippedLabel. - * - * Creates a new #EClippedLabel with the given text. - **/ -GtkWidget * -e_clipped_label_new (const gchar *text) -{ - GtkWidget *label; - - label = GTK_WIDGET (gtk_type_new (e_clipped_label_get_type ())); - - if (text && *text) - e_clipped_label_set_text (E_CLIPPED_LABEL (label), text); - - return label; -} - - -static void -e_clipped_label_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - EClippedLabel *label; - GdkFont *font; - - g_return_if_fail (E_IS_CLIPPED_LABEL (widget)); - g_return_if_fail (requisition != NULL); - - label = E_CLIPPED_LABEL (widget); - font = widget->style->font; - - requisition->width = 0; - requisition->height = font->ascent + font->descent - + 2 * GTK_MISC (widget)->ypad; -} - - -static void -e_clipped_label_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - EClippedLabel *label; - - label = E_CLIPPED_LABEL (widget); - - widget->allocation = *allocation; - - /* Flag that we need to recalculate how many characters to display. */ - label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC; -} - - -static gint -e_clipped_label_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - EClippedLabel *label; - GtkMisc *misc; - gint x, y; - GdkFont *font; - gchar *tmp_str, tmp_ch; - - g_return_val_if_fail (E_IS_CLIPPED_LABEL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - label = E_CLIPPED_LABEL (widget); - misc = GTK_MISC (widget); - font = widget->style->font; - - /* If the label isn't visible or has no text, just return. */ - if (!GTK_WIDGET_VISIBLE (widget) || !GTK_WIDGET_MAPPED (widget) - || !label->label || (*label->label == '\0')) - return TRUE; - - /* Recalculate the number of characters displayed, if necessary. */ - if (label->chars_displayed == E_CLIPPED_LABEL_NEED_RECALC) - e_clipped_label_recalc_chars_displayed (label); - - /* - * GC Clipping - */ - gdk_gc_set_clip_rectangle (widget->style->white_gc, - &event->area); - gdk_gc_set_clip_rectangle (widget->style->fg_gc[widget->state], - &event->area); - - y = floor (widget->allocation.y + (gint)misc->ypad - + (((gint)widget->allocation.height - 2 * (gint)misc->ypad - - (gint)font->ascent - font->descent) - * misc->yalign) + 0.5) + font->ascent; - - if (label->chars_displayed == E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL) { - x = floor (widget->allocation.x + (gint)misc->xpad - + (((gint)widget->allocation.width - - (gint)label->label_width - 2 * (gint)misc->xpad) - * misc->xalign) + 0.5); - - gtk_paint_string (widget->style, widget->window, widget->state, - &event->area, widget, "label", - x, y, label->label); - } else { - x = widget->allocation.x + (gint)misc->xpad; - - tmp_ch = label->label_wc[label->chars_displayed]; - label->label_wc[label->chars_displayed] = '\0'; - tmp_str = gdk_wcstombs (label->label_wc); - if (tmp_str) { - gtk_paint_string (widget->style, widget->window, - widget->state, &event->area, - widget, "label", - x, y, tmp_str); - g_free (tmp_str); - } - label->label_wc[label->chars_displayed] = tmp_ch; - - x = widget->allocation.x + (gint)misc->xpad - + label->ellipsis_x; - gtk_paint_string (widget->style, widget->window, widget->state, - &event->area, widget, "label", - x, y, e_clipped_label_ellipsis); - } - - gdk_gc_set_clip_mask (widget->style->white_gc, NULL); - gdk_gc_set_clip_mask (widget->style->fg_gc[widget->state], NULL); - - return TRUE; -} - - -static void -e_clipped_label_destroy (GtkObject *object) -{ - EClippedLabel *label; - - g_return_if_fail (E_IS_CLIPPED_LABEL (object)); - - label = E_CLIPPED_LABEL(object); - - g_free (label->label); - g_free (label->label_wc); -} - - -/** - * e_clipped_label_get_text: - * - * @label: An #EClippedLabel. - * @Return: The label text. - * - * Returns the label text, or NULL. - **/ -gchar* -e_clipped_label_get_text (EClippedLabel *label) -{ - g_return_val_if_fail (E_IS_CLIPPED_LABEL (label), NULL); - - return label->label; -} - - -/** - * e_clipped_label_set_text: - * - * @label: An #EClippedLabel. - * @text: The new label text. - * - * Sets the label text. - **/ -void -e_clipped_label_set_text (EClippedLabel *label, - const gchar *text) -{ - gint len; - - g_return_if_fail (E_IS_CLIPPED_LABEL (label)); - - if (label->label != text || !label->label || !text - || strcmp (label->label, text)) { - g_free (label->label); - g_free (label->label_wc); - label->label = NULL; - label->label_wc = NULL; - - if (text) { - label->label = g_strdup (text); - len = strlen (text); - label->label_wc = g_new (GdkWChar, len + 1); - label->wc_len = gdk_mbstowcs (label->label_wc, - label->label, len + 1); - label->label_wc[label->wc_len] = '\0'; - } - - /* Reset the number of characters displayed, so it is - recalculated when needed. */ - label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC; - - /* We don't queue a resize, since the label should not affect - the widget size, but we queue a draw. */ - gtk_widget_queue_draw (GTK_WIDGET (label)); - } -} - - -static void -e_clipped_label_recalc_chars_displayed (EClippedLabel *label) -{ - GdkFont *font; - gint max_width, width, ch, last_width; - - font = GTK_WIDGET (label)->style->font; - - max_width = GTK_WIDGET (label)->allocation.width - - 2 * GTK_MISC (label)->xpad; - - if (!label->label) { - label->chars_displayed = 0; - return; - } - - /* See if the entire label fits in the allocated width. */ - label->label_width = gdk_string_width (font, label->label); - if (label->label_width <= max_width) { - label->chars_displayed = E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL; - return; - } - - /* Calculate the width of the ellipsis string. */ - max_width -= gdk_string_measure (font, e_clipped_label_ellipsis); - - if (max_width <= 0) { - label->chars_displayed = 0; - label->ellipsis_x = 0; - return; - } - - /* Step through the wide-char label, adding on the widths of the - characters, until we can't fit any more in. */ - width = last_width = 0; - for (ch = 0; ch < label->wc_len; ch++) { - width += gdk_char_width_wc (font, label->label_wc[ch]); - - if (width > max_width) { - label->chars_displayed = ch; - label->ellipsis_x = last_width; - return; - } - - last_width = width; - } - - g_warning ("Clipped label width not exceeded as expected"); - label->chars_displayed = E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL; -} - diff --git a/widgets/misc/e-clipped-label.h b/widgets/misc/e-clipped-label.h deleted file mode 100644 index a21ceadeca..0000000000 --- a/widgets/misc/e-clipped-label.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * This is similar to GtkLabel but clips itself and displays '...' if it - * can't fit inside its allocated area. The intended use is for inside buttons - * that are a fixed size. The GtkLabel would normally display only the middle - * part of the text, which doesn't look very good. This only supports one line - * of text (so no wrapping/justification), without underlined characters. - */ -#ifndef _E_CLIPPED_LABEL_H_ -#define _E_CLIPPED_LABEL_H_ - -#include <gtk/gtkmisc.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define E_CLIPPED_LABEL(obj) GTK_CHECK_CAST (obj, e_clipped_label_get_type (), EClippedLabel) -#define E_CLIPPED_LABEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_clipped_label_get_type (), EClippedLabelClass) -#define E_IS_CLIPPED_LABEL(obj) GTK_CHECK_TYPE (obj, e_clipped_label_get_type ()) - - -typedef struct _EClippedLabel EClippedLabel; -typedef struct _EClippedLabelClass EClippedLabelClass; - -struct _EClippedLabel -{ - GtkMisc misc; - - gchar *label; - GdkWChar *label_wc; - - /* This is the number of wide characters in the label. */ - gint wc_len; - - /* This is the width of the entire label string, in pixels. */ - gint label_width; - - /* This is the number of characters we can fit in, or - E_CLIPPED_LABEL_NEED_RECALC if it needs to be recalculated, or - E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL to show the entire label. */ - gint chars_displayed; - - /* This is the x position to display the ellipsis string, e.g. '...', - relative to the start of the label. */ - gint ellipsis_x; -}; - -struct _EClippedLabelClass -{ - GtkMiscClass parent_class; -}; - - -GtkType e_clipped_label_get_type (void); -GtkWidget* e_clipped_label_new (const gchar *text); - -gchar* e_clipped_label_get_text (EClippedLabel *label); -void e_clipped_label_set_text (EClippedLabel *label, - const gchar *text); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CLIPPED_LABEL_H_ */ diff --git a/widgets/misc/e-colors.c b/widgets/misc/e-colors.c deleted file mode 100644 index ba86538dab..0000000000 --- a/widgets/misc/e-colors.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * color.c: Color allocation on the Gnumeric spreadsheet - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * We keep our own color context, as the color allocation might take place - * before any of our Canvases are realized. - */ -#include <config.h> -#include <gnome.h> -#include "color.h" - -static int color_inited; -static GdkColorContext *gnumeric_color_context; - -/* Public colors: shared by all of our items in Gnumeric */ -GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray, gs_red, gs_lavender; - -int -color_alloc (gushort red, gushort green, gushort blue) -{ - int failed; - - if (!color_inited) - color_init (); - - return gdk_color_context_get_pixel (gnumeric_color_context, - red, green, blue, &failed); -} - -void -color_alloc_gdk (GdkColor *c) -{ - int failed; - - g_return_if_fail (c != NULL); - - c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed); -} - -void -color_alloc_name (const char *name, GdkColor *c) -{ - int failed; - - g_return_if_fail (name != NULL); - g_return_if_fail (c != NULL); - - gdk_color_parse (name, c); - c->pixel = 0; - c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed); -} - -void -color_init (void) -{ - GdkColormap *colormap = gtk_widget_get_default_colormap (); - - /* Initialize the color context */ - gnumeric_color_context = gdk_color_context_new ( - gtk_widget_get_default_visual (), colormap); - - /* Allocate the default colors */ - gdk_color_white (colormap, &gs_white); - gdk_color_black (colormap, &gs_black); - - color_alloc_name ("gray78", &gs_light_gray); - color_alloc_name ("gray20", &gs_dark_gray); - color_alloc_name ("red", &gs_red); - color_alloc_name ("lavender",&gs_lavender); - - color_inited = 1; -} diff --git a/widgets/misc/e-colors.h b/widgets/misc/e-colors.h deleted file mode 100644 index 4a2cb74c73..0000000000 --- a/widgets/misc/e-colors.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef GNUMERIC_COLOR_H -#define GNUMERIC_COLOR_H - -void color_init (void); - -/* Return the pixel value for the given red, green and blue */ -int color_alloc (gushort red, gushort green, gushort blue); -void color_alloc_name (const char *name, GdkColor *color); -void color_alloc_gdk (GdkColor *color); - -/* Colors used by any GnumericSheet item */ -extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black, gs_red, gs_lavender; - -#endif /* GNUMERIC_COLOR_H */ diff --git a/widgets/misc/e-cursors.c b/widgets/misc/e-cursors.c deleted file mode 100644 index 597c3c1787..0000000000 --- a/widgets/misc/e-cursors.c +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef GNUMERIC_CURSORS_H -#define GNUMERIC_CURSORS_H - -typedef enum { - GNUMERIC_CURSOR_FAT_CROSS, - GNUMERIC_CURSOR_THIN_CROSS, - GNUMERIC_CURSOR_ARROW, - GNUMERIC_CURSOR_MOVE, - GNUMERIC_CURSOR_ZOOM_IN, - GNUMERIC_CURSOR_ZOOM_OUT, - GNUMERIC_CURSOR_SIZE_X, - GNUMERIC_CURSOR_SIZE_Y, - GNUMERIC_CURSOR_SIZE_TL, - GNUMERIC_CURSOR_SIZE_TR, - GNUMERIC_CURSOR_PRESS, - GNUMERIC_CURSOR_HAND_OPEN, - GNUMERIC_CURSOR_HAND_CLOSED, - GNUMERIC_CURSOR_NUM_CURSORS -} CursorType; - -void cursors_init (void); -void cursors_shutdown (void); - -#define cursor_set(win, c) \ -G_STMT_START { \ - if (win) \ - gdk_window_set_cursor (win, cursor_get (c)); \ -} G_STMT_END - -#define cursor_set_widget(w, c) \ -G_STMT_START { \ - if (GTK_WIDGET (w)->window) \ - gdk_window_set_cursor (GTK_WIDGET (w)->window, cursor_get (c)); \ -} G_STMT_END - -GdkCursor *cursor_get (CursorType type); - -#endif /* GNUMERIC_CURSORS_H */ diff --git a/widgets/misc/e-cursors.h b/widgets/misc/e-cursors.h deleted file mode 100644 index 597c3c1787..0000000000 --- a/widgets/misc/e-cursors.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef GNUMERIC_CURSORS_H -#define GNUMERIC_CURSORS_H - -typedef enum { - GNUMERIC_CURSOR_FAT_CROSS, - GNUMERIC_CURSOR_THIN_CROSS, - GNUMERIC_CURSOR_ARROW, - GNUMERIC_CURSOR_MOVE, - GNUMERIC_CURSOR_ZOOM_IN, - GNUMERIC_CURSOR_ZOOM_OUT, - GNUMERIC_CURSOR_SIZE_X, - GNUMERIC_CURSOR_SIZE_Y, - GNUMERIC_CURSOR_SIZE_TL, - GNUMERIC_CURSOR_SIZE_TR, - GNUMERIC_CURSOR_PRESS, - GNUMERIC_CURSOR_HAND_OPEN, - GNUMERIC_CURSOR_HAND_CLOSED, - GNUMERIC_CURSOR_NUM_CURSORS -} CursorType; - -void cursors_init (void); -void cursors_shutdown (void); - -#define cursor_set(win, c) \ -G_STMT_START { \ - if (win) \ - gdk_window_set_cursor (win, cursor_get (c)); \ -} G_STMT_END - -#define cursor_set_widget(w, c) \ -G_STMT_START { \ - if (GTK_WIDGET (w)->window) \ - gdk_window_set_cursor (GTK_WIDGET (w)->window, cursor_get (c)); \ -} G_STMT_END - -GdkCursor *cursor_get (CursorType type); - -#endif /* GNUMERIC_CURSORS_H */ diff --git a/widgets/misc/e-gui-utils.c b/widgets/misc/e-gui-utils.c deleted file mode 100644 index 2e31eb101b..0000000000 --- a/widgets/misc/e-gui-utils.c +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * GUI utility functions - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * - * (C) 1999 Miguel de Icaza - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include <libgnomeui/gnome-messagebox.h> -#include <libgnomeui/gnome-stock.h> -#include <gnome.h> -#include "e-gui-utils.h" -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> - -void -e_notice (GtkWindow *window, const char *type, const char *format, ...) -{ - GtkWidget *dialog; - va_list args; - char *str; - - va_start (args, format); - str = g_strdup_vprintf (format, args); - dialog = gnome_message_box_new (str, type, GNOME_STOCK_BUTTON_OK, NULL); - va_end (args); - g_free (str); - - if (window) - gnome_dialog_set_parent (GNOME_DIALOG (dialog), window); - - gnome_dialog_run (GNOME_DIALOG (dialog)); -} - -static void -kill_popup_menu (GtkWidget *widget, GtkMenu *menu) -{ - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_MENU (menu)); - - gtk_object_unref (GTK_OBJECT (menu)); -} - -void -e_auto_kill_popup_menu_on_hide (GtkMenu *menu) -{ - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_MENU (menu)); - - gtk_signal_connect (GTK_OBJECT (menu), "hide", - GTK_SIGNAL_FUNC (kill_popup_menu), menu); -} - -void -e_popup_menu (GtkMenu *menu, GdkEventButton *event) -{ - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_MENU (menu)); - - e_auto_kill_popup_menu_on_hide (menu); - gtk_menu_popup (menu, NULL, NULL, 0, NULL, event->button, event->time); -} - -GtkWidget *e_create_image_widget(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - char *filename; - GdkPixbuf *pixbuf; - double width, height; - GtkWidget *canvas, *alignment; - if (string1) { - if (*string1 == '/') - filename = g_strdup(string1); - else - filename = g_concat_dir_and_file(EVOLUTION_IMAGES, string1); - pixbuf = gdk_pixbuf_new_from_file(filename); - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - - canvas = gnome_canvas_new_aa(); - GTK_OBJECT_UNSET_FLAGS(GTK_WIDGET(canvas), GTK_CAN_FOCUS); - gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(canvas)), - gnome_canvas_pixbuf_get_type(), - - "pixbuf", pixbuf, - NULL); - - alignment = gtk_widget_new(gtk_alignment_get_type(), - "child", canvas, - "xalign", (double) 0, - "yalign", (double) 0, - "xscale", (double) 0, - "yscale", (double) 0, - NULL); - - gtk_widget_set_usize(canvas, width, height); - - gdk_pixbuf_unref(pixbuf); - - gtk_widget_show(canvas); - gtk_widget_show(alignment); - g_free(filename); - - return alignment; - } else - return NULL; -} - -typedef struct { - GtkCallback callback; - gpointer closure; -} CallbackClosure; - -static void -e_container_foreach_leaf_callback(GtkWidget *widget, CallbackClosure *callback_closure) -{ - if (GTK_IS_CONTAINER(widget)) { - e_container_foreach_leaf(GTK_CONTAINER(widget), callback_closure->callback, callback_closure->closure); - } else { - (*callback_closure->callback) (widget, callback_closure->closure); - } -} - -void -e_container_foreach_leaf(GtkContainer *container, - GtkCallback callback, - gpointer closure) -{ - CallbackClosure callback_closure; - callback_closure.callback = callback; - callback_closure.closure = closure; - gtk_container_foreach(container, (GtkCallback) e_container_foreach_leaf_callback, &callback_closure); -} - -static void -e_container_change_tab_order_destroy_notify(gpointer data) -{ - GList *list = data; - g_list_foreach(list, (GFunc) gtk_object_unref, NULL); - g_list_free(list); -} - - -static gint -e_container_change_tab_order_callback(GtkContainer *container, - GtkDirectionType direction, - GList *children) -{ - GtkWidget *focus_child; - GtkWidget *child; - - if (direction != GTK_DIR_TAB_FORWARD && - direction != GTK_DIR_TAB_BACKWARD) - return FALSE; - - focus_child = container->focus_child; - - if (direction == GTK_DIR_TAB_BACKWARD) { - children = g_list_last(children); - } - - while (children) { - child = children->data; - if (direction == GTK_DIR_TAB_FORWARD) - children = children->next; - else - children = children->prev; - - if (!child) - continue; - - if (focus_child) { - if (focus_child == child) { - focus_child = NULL; - - if (GTK_WIDGET_DRAWABLE (child) && - GTK_IS_CONTAINER (child) && - !GTK_WIDGET_HAS_FOCUS (child)) - if (gtk_container_focus (GTK_CONTAINER (child), direction)) { - gtk_signal_emit_stop_by_name(GTK_OBJECT(container), "focus"); - return TRUE; - } - } - } - else if (GTK_WIDGET_DRAWABLE (child)) { - if (GTK_IS_CONTAINER (child)) { - if (gtk_container_focus (GTK_CONTAINER (child), direction)) { - gtk_signal_emit_stop_by_name(GTK_OBJECT(container), "focus"); - return TRUE; - } - } - else if (GTK_WIDGET_CAN_FOCUS (child)) { - gtk_widget_grab_focus (child); - gtk_signal_emit_stop_by_name(GTK_OBJECT(container), "focus"); - return TRUE; - } - } - } - - return FALSE; -} - -gint -e_container_change_tab_order(GtkContainer *container, GList *widgets) -{ - GList *list; - list = g_list_copy(widgets); - g_list_foreach(list, (GFunc) gtk_object_ref, NULL); - return gtk_signal_connect_full(GTK_OBJECT(container), "focus", - GTK_SIGNAL_FUNC(e_container_change_tab_order_callback), - NULL, list, - e_container_change_tab_order_destroy_notify, - FALSE, FALSE); -} diff --git a/widgets/misc/e-gui-utils.h b/widgets/misc/e-gui-utils.h deleted file mode 100644 index 1d47a7b514..0000000000 --- a/widgets/misc/e-gui-utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef E_GUI_UTILS_H -#define E_GUI_UTILS_H - -#include <gtk/gtkmenu.h> -#include <gtk/gtkwindow.h> - -#include <libgnomeui/gnome-messagebox.h> - -void e_popup_menu (GtkMenu *menu, GdkEventButton *event); -void e_auto_kill_popup_menu_on_hide (GtkMenu *menu); -void e_notice (GtkWindow *window, const char *type, const char *format, ...); -GtkWidget *e_create_image_widget (gchar *name, gchar *string1, gchar *string2, gint int1, gint int2); -void e_container_foreach_leaf (GtkContainer *container, - GtkCallback callback, - gpointer closure); -gint e_container_change_tab_order (GtkContainer *container, - GList *widgets); - -#endif /* E_GUI_UTILS_H */ diff --git a/widgets/misc/e-popup-menu.c b/widgets/misc/e-popup-menu.c deleted file mode 100644 index 3fb382ae20..0000000000 --- a/widgets/misc/e-popup-menu.c +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-popup-menu.c: popup menu display -nnn * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * Jody Goldberg (jgoldberg@home.com) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include "e-popup-menu.h" -#include "e-gui-utils.h" - -/* - * Creates an item with an optional icon - */ -static GtkWidget * -make_item (GtkMenu *menu, const char *name, const char *pixname) -{ - GtkWidget *label, *item; - guint label_accel; - - if (*name == '\0') - return gtk_menu_item_new (); - - /* - * Ugh. This needs to go into Gtk+ - */ - label = gtk_accel_label_new (""); - label_accel = gtk_label_parse_uline (GTK_LABEL (label), name); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - - item = gtk_pixmap_menu_item_new (); - gtk_container_add (GTK_CONTAINER (item), label); - - if (label_accel != GDK_VoidSymbol){ - gtk_widget_add_accelerator ( - item, - "activate_item", - gtk_menu_ensure_uline_accel_group (GTK_MENU (menu)), - label_accel, 0, - GTK_ACCEL_LOCKED); - } - - if (pixname){ - GtkWidget *pixmap = gnome_stock_pixmap_widget (item, pixname); - - gtk_widget_show (pixmap); - gtk_pixmap_menu_item_set_pixmap ( - GTK_PIXMAP_MENU_ITEM (item), pixmap); - } - - return item; -} - -GtkMenu * -e_popup_menu_create (EPopupMenu *menu_list, int disable_mask, int hide_mask, void *closure) -{ - GtkMenu *menu = GTK_MENU (gtk_menu_new ()); - int i; - gboolean last_item_seperator = TRUE; - gint last_non_seperator = -1; - - for (i = 0; menu_list[i].name; i++) { - if (strcmp("", menu_list[i].name) && !(menu_list [i].disable_mask & hide_mask)) { - last_non_seperator = i; - } - } - - for (i = 0; i <= last_non_seperator; i++) { - GtkWidget *item; - gboolean seperator; - - seperator = !strcmp("", menu_list[i].name); - - if ((!(seperator && last_item_seperator)) && !(menu_list [i].disable_mask & hide_mask)) { - - item = make_item (menu, menu_list [i].name, - menu_list [i].pixname); - - if (menu_list [i].fn) - gtk_signal_connect ( - GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (menu_list [i].fn), - closure); - - if (menu_list [i].disable_mask & disable_mask) - gtk_widget_set_sensitive (item, FALSE); - - gtk_widget_show (item); - gtk_menu_append (menu, item); - } - last_item_seperator = seperator; - } - - return menu; -} - -void -e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, int disable_mask, int hide_mask, void *closure) -{ - GtkMenu *menu; - - g_return_if_fail (menu_list != NULL); - g_return_if_fail (event != NULL); - - menu = e_popup_menu_create (menu_list, disable_mask, hide_mask, closure); - - e_popup_menu (menu, event); -} - diff --git a/widgets/misc/e-popup-menu.h b/widgets/misc/e-popup-menu.h deleted file mode 100644 index ed54a632a5..0000000000 --- a/widgets/misc/e-popup-menu.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef E_POPUP_MENU_H -#define E_POPUP_MENU_H - -#include <gtk/gtkwidget.h> - -typedef struct { - char const * const name; - char const * const pixname; - void (*fn)(GtkWidget *widget, void *closure); - int disable_mask; -} EPopupMenu; - -GtkMenu *e_popup_menu_create (EPopupMenu *menu_list, - int disable_mask, - int hide_mask, - void *closure); - -void e_popup_menu_run (EPopupMenu *menu_list, - GdkEventButton *event, - int disable_mask, - int hide_mask, - void *closure); - -#endif /* E_POPUP_MENU_H */ diff --git a/widgets/misc/e-printable.c b/widgets/misc/e-printable.c deleted file mode 100644 index ed982469b8..0000000000 --- a/widgets/misc/e-printable.c +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-printable.c: an object printer. - * - * Author: - * Christopher James Lahey <clahey@helixcode.com> - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-util.h" -#include "e-printable.h" - -#define EP_CLASS(e) ((EPrintableClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gtk_object_get_type () - - -static GtkObjectClass *e_printable_parent_class; - -enum { - PRINT_PAGE, - DATA_LEFT, - RESET, - HEIGHT, - WILL_FIT, - LAST_SIGNAL -}; - -static guint e_printable_signals [LAST_SIGNAL] = { 0, }; - -static void -e_printable_class_init (GtkObjectClass *object_class) -{ - EPrintableClass *klass = E_PRINTABLE_CLASS(object_class); - e_printable_parent_class = gtk_type_class (PARENT_TYPE); - - e_printable_signals [PRINT_PAGE] = - gtk_signal_new ("print_page", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EPrintableClass, print_page), - e_marshal_NONE__OBJECT_DOUBLE_DOUBLE_BOOL, - GTK_TYPE_NONE, 4, GTK_TYPE_OBJECT, GTK_TYPE_DOUBLE, GTK_TYPE_DOUBLE, GTK_TYPE_BOOL); - - e_printable_signals [DATA_LEFT] = - gtk_signal_new ("data_left", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EPrintableClass, data_left), - gtk_marshal_BOOL__NONE, - GTK_TYPE_BOOL, 0, GTK_TYPE_NONE); - - e_printable_signals [RESET] = - gtk_signal_new ("reset", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EPrintableClass, reset), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0, GTK_TYPE_NONE); - - e_printable_signals [HEIGHT] = - gtk_signal_new ("height", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EPrintableClass, height), - e_marshal_DOUBLE__OBJECT_DOUBLE_DOUBLE_BOOL, - GTK_TYPE_DOUBLE, 4, GTK_TYPE_OBJECT, GTK_TYPE_DOUBLE, GTK_TYPE_DOUBLE, GTK_TYPE_BOOL); - - e_printable_signals [WILL_FIT] = - gtk_signal_new ("will_fit", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EPrintableClass, will_fit), - e_marshal_BOOL__OBJECT_DOUBLE_DOUBLE_BOOL, - GTK_TYPE_BOOL, 4, GTK_TYPE_OBJECT, GTK_TYPE_DOUBLE, GTK_TYPE_DOUBLE, GTK_TYPE_BOOL); - - gtk_object_class_add_signals (object_class, e_printable_signals, LAST_SIGNAL); - - klass->print_page = NULL; - klass->data_left = NULL; - klass->reset = NULL; - klass->height = NULL; - klass->will_fit = NULL; -} - - -guint -e_printable_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "EPrintable", - sizeof (EPrintable), - sizeof (EPrintableClass), - (GtkClassInitFunc) e_printable_class_init, - NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -EPrintable * -e_printable_new(void) -{ - return E_PRINTABLE(gtk_type_new(e_printable_get_type())); -} - -void -e_printable_print_page (EPrintable *e_printable, - GnomePrintContext *context, - gdouble width, - gdouble height, - gboolean quantized) -{ - g_return_if_fail (e_printable != NULL); - g_return_if_fail (E_IS_PRINTABLE (e_printable)); - - gtk_signal_emit (GTK_OBJECT (e_printable), - e_printable_signals [PRINT_PAGE], - context, - width, - height, - quantized); -} - -gboolean -e_printable_data_left (EPrintable *e_printable) -{ - gboolean ret_val; - - g_return_val_if_fail (e_printable != NULL, FALSE); - g_return_val_if_fail (E_IS_PRINTABLE (e_printable), FALSE); - - gtk_signal_emit (GTK_OBJECT (e_printable), - e_printable_signals [DATA_LEFT], - &ret_val); - - return ret_val; -} - -void -e_printable_reset (EPrintable *e_printable) -{ - g_return_if_fail (e_printable != NULL); - g_return_if_fail (E_IS_PRINTABLE (e_printable)); - - gtk_signal_emit (GTK_OBJECT (e_printable), - e_printable_signals [RESET]); -} - -gdouble -e_printable_height (EPrintable *e_printable, - GnomePrintContext *context, - gdouble width, - gdouble max_height, - gboolean quantized) -{ - gdouble ret_val; - - g_return_val_if_fail (e_printable != NULL, -1); - g_return_val_if_fail (E_IS_PRINTABLE (e_printable), -1); - - gtk_signal_emit (GTK_OBJECT (e_printable), - e_printable_signals [HEIGHT], - context, - width, - max_height, - quantized, - &ret_val); - - return ret_val; -} - -gboolean -e_printable_will_fit (EPrintable *e_printable, - GnomePrintContext *context, - gdouble width, - gdouble max_height, - gboolean quantized) -{ - gboolean ret_val; - - g_return_val_if_fail (e_printable != NULL, -1); - g_return_val_if_fail (E_IS_PRINTABLE (e_printable), -1); - - gtk_signal_emit (GTK_OBJECT (e_printable), - e_printable_signals [WILL_FIT], - context, - width, - max_height, - quantized, - &ret_val); - - return ret_val; -} diff --git a/widgets/misc/e-printable.h b/widgets/misc/e-printable.h deleted file mode 100644 index 18e6ec8472..0000000000 --- a/widgets/misc/e-printable.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-printable.h: an object printer. - * - * Author: - * Christopher James Lahey <clahey@helixcode.com> - * - * (C) 2000 Helix Code, Inc. - */ -#ifndef _E_PRINTABLE_H_ -#define _E_PRINTABLE_H_ - -#include <gtk/gtkobject.h> -#include <libgnomeprint/gnome-print.h> - -#define E_PRINTABLE_TYPE (e_printable_get_type ()) -#define E_PRINTABLE(o) (GTK_CHECK_CAST ((o), E_PRINTABLE_TYPE, EPrintable)) -#define E_PRINTABLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_PRINTABLE_TYPE, EPrintableClass)) -#define E_IS_PRINTABLE(o) (GTK_CHECK_TYPE ((o), E_PRINTABLE_TYPE)) -#define E_IS_PRINTABLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_PRINTABLE_TYPE)) - -typedef struct { - GtkObject base; -} EPrintable; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Signals - */ - - void (*print_page) (EPrintable *etm, GnomePrintContext *context, gdouble width, gdouble height, gboolean quantized); - gboolean (*data_left) (EPrintable *etm); - void (*reset) (EPrintable *etm); - gdouble (*height) (EPrintable *etm, GnomePrintContext *context, gdouble width, gdouble max_height, gboolean quantized); - - /* e_printable_will_fit (ep, ...) should be equal in value to - * (e_printable_print_page (ep, ...), - * !e_printable_data_left(ep)) except that the latter has the - * side effect of doing the printing and advancing the - * position of the printable. - */ - - gboolean (*will_fit) (EPrintable *etm, GnomePrintContext *context, gdouble width, gdouble max_height, gboolean quantized); -} EPrintableClass; - -GtkType e_printable_get_type (void); - -EPrintable *e_printable_new (void); - -/* - * Routines for emitting signals on the e_table */ -void e_printable_print_page (EPrintable *e_printable, - GnomePrintContext *context, - gdouble width, - gdouble height, - gboolean quantized); -gboolean e_printable_data_left (EPrintable *e_printable); -void e_printable_reset (EPrintable *e_printable); -gdouble e_printable_height (EPrintable *e_printable, - GnomePrintContext *context, - gdouble width, - gdouble max_height, - gboolean quantized); -gboolean e_printable_will_fit (EPrintable *e_printable, - GnomePrintContext *context, - gdouble width, - gdouble max_height, - gboolean quantized); - -#endif /* _E_PRINTABLE_H_ */ diff --git a/widgets/misc/e-reflow.c b/widgets/misc/e-reflow.c deleted file mode 100644 index 0e9c8b92b1..0000000000 --- a/widgets/misc/e-reflow.c +++ /dev/null @@ -1,859 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-reflow.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <math.h> -#include "e-reflow.h" -#include "e-text.h" -#include <e-util/e-canvas-utils.h> -#include <e-util/e-canvas.h> -#include <e-util/e-util.h> - -static void e_reflow_init (EReflow *reflow); -static void e_reflow_class_init (EReflowClass *klass); -static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_reflow_destroy (GtkObject *object); -static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_reflow_realize (GnomeCanvasItem *item); -static void e_reflow_unrealize (GnomeCanvasItem *item); -static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable, - int x, int y, int width, int height); -static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags); -static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item); -static void e_reflow_reflow (GnomeCanvasItem *item, int flags); -static void e_reflow_real_add_item(EReflow *e_reflow, GnomeCanvasItem *item); -static void set_empty(EReflow *e_reflow); - -static void e_reflow_resize_children (GnomeCanvasItem *item); - -#define E_REFLOW_DIVIDER_WIDTH 2 -#define E_REFLOW_BORDER_WIDTH 7 -#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2) - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_MINIMUM_WIDTH, - ARG_WIDTH, - ARG_HEIGHT, - ARG_EMPTY_MESSAGE, -}; - -GtkType -e_reflow_get_type (void) -{ - static GtkType reflow_type = 0; - - if (!reflow_type) - { - static const GtkTypeInfo reflow_info = - { - "EReflow", - sizeof (EReflow), - sizeof (EReflowClass), - (GtkClassInitFunc) e_reflow_class_init, - (GtkObjectInitFunc) e_reflow_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - reflow_type = gtk_type_unique (gnome_canvas_group_get_type (), &reflow_info); - } - - return reflow_type; -} - -static void -e_reflow_class_init (EReflowClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EReflow::minimum_width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH); - gtk_object_add_arg_type ("EReflow::width", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_WIDTH); - gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_HEIGHT); - gtk_object_add_arg_type ("EReflow::empty_message", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_EMPTY_MESSAGE); - - klass->add_item = e_reflow_real_add_item; - - object_class->set_arg = e_reflow_set_arg; - object_class->get_arg = e_reflow_get_arg; - object_class->destroy = e_reflow_destroy; - - /* GnomeCanvasItem method overrides */ - item_class->event = e_reflow_event; - item_class->realize = e_reflow_realize; - item_class->unrealize = e_reflow_unrealize; - item_class->draw = e_reflow_draw; - item_class->update = e_reflow_update; - item_class->point = e_reflow_point; -} - -static void -e_reflow_init (EReflow *reflow) -{ - reflow->items = NULL; - reflow->columns = NULL; - reflow->column_width = 150; - - reflow->minimum_width = 10; - reflow->width = 10; - reflow->height = 10; - reflow->idle = 0; - - reflow->empty_message = NULL; - reflow->empty_text = NULL; - - reflow->column_drag = FALSE; - - reflow->need_height_update = FALSE; - reflow->need_column_resize = FALSE; - - reflow->default_cursor_shown = TRUE; - reflow->arrow_cursor = NULL; - reflow->default_cursor = NULL; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(reflow), e_reflow_reflow); -} - -static void -e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EReflow *e_reflow; - - item = GNOME_CANVAS_ITEM (o); - e_reflow = E_REFLOW (o); - - switch (arg_id){ - case ARG_HEIGHT: - e_reflow->height = GTK_VALUE_DOUBLE (*arg); - e_canvas_item_request_reflow(item); - break; - case ARG_MINIMUM_WIDTH: - e_reflow->minimum_width = GTK_VALUE_DOUBLE (*arg); - if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(o)) - set_empty(e_reflow); - e_canvas_item_request_reflow(item); - break; - case ARG_EMPTY_MESSAGE: - g_free(e_reflow->empty_message); - e_reflow->empty_message = g_strdup(GTK_VALUE_STRING (*arg)); - if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(o)) - set_empty(e_reflow); - } -} - -static void -e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EReflow *e_reflow; - - e_reflow = E_REFLOW (object); - - switch (arg_id) { - case ARG_MINIMUM_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_reflow->minimum_width; - break; - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_reflow->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_reflow->height; - break; - case ARG_EMPTY_MESSAGE: - GTK_VALUE_STRING (*arg) = g_strdup(e_reflow->empty_message); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_reflow_destroy (GtkObject *object) -{ - EReflow *reflow = E_REFLOW(object); - - g_list_foreach(reflow->items, (GFunc) gtk_object_unref, NULL); - g_list_free(reflow->items); - reflow->items = NULL; - - g_free(reflow->empty_message); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -static void -e_reflow_realize (GnomeCanvasItem *item) -{ - EReflow *e_reflow; - GnomeCanvasGroup *group; - GList *list; - GtkAdjustment *adjustment; - - e_reflow = E_REFLOW (item); - group = GNOME_CANVAS_GROUP( item ); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_reflow->arrow_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - e_reflow->default_cursor = gdk_cursor_new (GDK_LEFT_PTR); - - for(list = e_reflow->items; list; list = g_list_next(list)) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(item, - "width", (double) e_reflow->column_width, - NULL); - } - - set_empty(e_reflow); - - e_canvas_item_request_reflow(item); - - adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2; - adjustment->page_increment = adjustment->page_size - adjustment->step_increment; - gtk_adjustment_changed(adjustment); - - if (!item->canvas->aa) { - } -} - -static void -e_reflow_unrealize (GnomeCanvasItem *item) -{ - EReflow *e_reflow; - - e_reflow = E_REFLOW (item); - - if (!item->canvas->aa) - { - } - - gdk_cursor_destroy (e_reflow->arrow_cursor); - gdk_cursor_destroy (e_reflow->default_cursor); - e_reflow->arrow_cursor = NULL; - e_reflow->default_cursor = NULL; - - g_list_free (e_reflow->columns); - e_reflow->columns = NULL; - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item); -} - -static gint -e_reflow_pick_line (EReflow *e_reflow, double x) -{ - x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - x /= e_reflow->column_width + E_REFLOW_FULL_GUTTER; - return x; -} - -static gboolean -e_reflow_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EReflow *e_reflow; - - e_reflow = E_REFLOW (item); - - switch( event->type ) - { - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Tab || - event->key.keyval == GDK_KP_Tab || - event->key.keyval == GDK_ISO_Left_Tab) { - GList *list; - for (list = e_reflow->items; list; list = list->next) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data); - EFocus has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus) { - if (event->key.state & GDK_SHIFT_MASK) - list = list->prev; - else - list = list->next; - if (list) { - item = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(item, - "has_focus", (event->key.state & GDK_SHIFT_MASK) ? E_FOCUS_END : E_FOCUS_START, - NULL); - return 1; - } else { - return 0; - } - } - } - } - break; - case GDK_BUTTON_PRESS: - switch(event->button.button) - { - case 1: - { - GdkEventButton *button = (GdkEventButton *) event; - double n_x, max_x; - n_x = button->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - - max_x = E_REFLOW_BORDER_WIDTH; - max_x += (e_reflow->column_width + E_REFLOW_FULL_GUTTER) * e_reflow->column_count; - if ( button->y >= E_REFLOW_BORDER_WIDTH && button->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER && max_x > button->x ) { - e_reflow->which_column_dragged = e_reflow_pick_line(e_reflow, button->x); - e_reflow->start_x = e_reflow->which_column_dragged * (e_reflow->column_width + E_REFLOW_FULL_GUTTER) - E_REFLOW_DIVIDER_WIDTH / 2; - e_reflow->temp_column_width = e_reflow->column_width; - e_reflow->column_drag = TRUE; - - gnome_canvas_item_grab (item, - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, - e_reflow->arrow_cursor, - button->time); - - e_reflow->previous_temp_column_width = -1; - e_reflow->need_column_resize = TRUE; - gnome_canvas_item_request_update(item); - return TRUE; - } - } - break; - case 4: - { - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - gdouble new_value = adjustment->value; - new_value -= adjustment->step_increment; - gtk_adjustment_set_value(adjustment, new_value); - } - break; - case 5: - { - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - gdouble new_value = adjustment->value; - new_value += adjustment->step_increment; - if ( new_value > adjustment->upper - adjustment->page_size ) - new_value = adjustment->upper - adjustment->page_size; - gtk_adjustment_set_value(adjustment, new_value); - } - break; - } - break; - case GDK_BUTTON_RELEASE: - if (e_reflow->column_drag) { - gdouble old_width = e_reflow->column_width; - GdkEventButton *button = (GdkEventButton *) event; - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - e_reflow->temp_column_width = e_reflow->column_width + - (button->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value)); - if ( e_reflow->temp_column_width < 50 ) - e_reflow->temp_column_width = 50; - e_reflow->column_drag = FALSE; - if ( old_width != e_reflow->temp_column_width ) { - gtk_adjustment_set_value(adjustment, adjustment->value + e_reflow_pick_line(e_reflow, adjustment->value) * (e_reflow->temp_column_width - e_reflow->column_width)); - e_reflow->column_width = e_reflow->temp_column_width; - adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2; - adjustment->page_increment = adjustment->page_size - adjustment->step_increment; - gtk_adjustment_changed(adjustment); - e_reflow_resize_children(item); - e_canvas_item_request_reflow(item); - } - e_reflow->need_column_resize = TRUE; - gnome_canvas_item_request_update(item); - gnome_canvas_item_ungrab (item, button->time); - return TRUE; - } - break; - case GDK_MOTION_NOTIFY: - if (e_reflow->column_drag) { - double old_width = e_reflow->temp_column_width; - GdkEventMotion *motion = (GdkEventMotion *) event; - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - e_reflow->temp_column_width = e_reflow->column_width + - (motion->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value)); - if (e_reflow->temp_column_width < 50) - e_reflow->temp_column_width = 50; - if (old_width != e_reflow->temp_column_width) { - e_reflow->need_column_resize = TRUE; - gnome_canvas_item_request_update(item); - } - return TRUE; - } else { - GdkEventMotion *motion = (GdkEventMotion *) event; - double n_x, max_x; - - n_x = motion->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - - max_x = E_REFLOW_BORDER_WIDTH; - max_x += (e_reflow->column_width + E_REFLOW_FULL_GUTTER) * e_reflow->column_count; - - if ( motion->y >= E_REFLOW_BORDER_WIDTH && motion->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER && max_x > motion->x) { - if ( e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor); - e_reflow->default_cursor_shown = FALSE; - } - } else - if ( ! e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor); - e_reflow->default_cursor_shown = TRUE; - } - - } - break; - case GDK_ENTER_NOTIFY: - if (!e_reflow->column_drag) { - GdkEventCrossing *crossing = (GdkEventCrossing *) event; - double n_x, max_x; - n_x = crossing->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - - max_x = E_REFLOW_BORDER_WIDTH; - max_x += (e_reflow->column_width + E_REFLOW_FULL_GUTTER) * e_reflow->column_count; - if ( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER && max_x > crossing->x) { - if ( e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor); - e_reflow->default_cursor_shown = FALSE; - } - } - } - break; - case GDK_LEAVE_NOTIFY: - if (!e_reflow->column_drag) { - GdkEventCrossing *crossing = (GdkEventCrossing *) event; - double n_x; - n_x = crossing->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if ( !( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) ) { - if ( ! e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor); - e_reflow->default_cursor_shown = TRUE; - } - } - } - break; - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_reflow_real_add_item(EReflow *e_reflow, GnomeCanvasItem *item) -{ - e_reflow->items = g_list_append(e_reflow->items, item); - gtk_object_ref(GTK_OBJECT(item)); - if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) { - gnome_canvas_item_set(item, - "width", (double) e_reflow->column_width, - NULL); - e_reflow_post_add_item(e_reflow, item); - e_canvas_item_request_reflow(item); - } - -} - -static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable, - int x, int y, int width, int height) -{ - int x_rect, y_rect, width_rect, height_rect; - gdouble running_width; - EReflow *e_reflow = E_REFLOW(item); - int i; - double column_width; - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->draw) - GNOME_CANVAS_ITEM_CLASS(parent_class)->draw (item, drawable, x, y, width, height); - column_width = e_reflow->column_width; - running_width = E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - x_rect = running_width; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - /* Compute first column to draw. */ - i = x; - i /= column_width + E_REFLOW_FULL_GUTTER; - running_width += i * (column_width + E_REFLOW_FULL_GUTTER); - - for ( ; i < e_reflow->column_count; i++) { - if ( running_width > x + width ) - break; - x_rect = running_width; - gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style, - drawable, - GTK_STATE_ACTIVE, - GTK_SHADOW_NONE, - NULL, - GTK_WIDGET(item->canvas), - "reflow", - x_rect - x, - y_rect - y, - width_rect, - height_rect); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - if (e_reflow->column_drag) { - int start_line = e_reflow_pick_line(e_reflow, - gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value); - i = x - start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width = start_line * (column_width + E_REFLOW_FULL_GUTTER); - column_width = e_reflow->temp_column_width; - running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER); - i += start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - x_rect = running_width; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - /* Compute first column to draw. */ - i /= column_width + E_REFLOW_FULL_GUTTER; - running_width += i * (column_width + E_REFLOW_FULL_GUTTER); - - for ( ; i < e_reflow->column_count; i++) { - if ( running_width > x + width ) - break; - x_rect = running_width; - gdk_draw_rectangle(drawable, - GTK_WIDGET(item->canvas)->style->fg_gc[GTK_STATE_NORMAL], - TRUE, - x_rect - x, - y_rect - y, - width_rect - 1, - height_rect - 1); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - } -} - -static void -e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags) -{ - EReflow *e_reflow; - double x0, x1, y0, y1; - - e_reflow = E_REFLOW (item); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->update) - GNOME_CANVAS_ITEM_CLASS(parent_class)->update (item, affine, clip_path, flags); - - x0 = item->x1; - y0 = item->y1; - x1 = item->x2; - y1 = item->y2; - if ( x1 < x0 + e_reflow->width ) - x1 = x0 + e_reflow->width; - if ( y1 < y0 + e_reflow->height ) - y1 = y0 + e_reflow->height; - item->x2 = x1; - item->y2 = y1; - - if (e_reflow->need_height_update) { - x0 = item->x1; - y0 = item->y1; - x1 = item->x2; - y1 = item->y2; - if ( x0 > 0 ) - x0 = 0; - if ( y0 > 0 ) - y0 = 0; - if ( x1 < E_REFLOW(item)->width ) - x1 = E_REFLOW(item)->width; - if ( x1 < E_REFLOW(item)->height ) - x1 = E_REFLOW(item)->height; - - gnome_canvas_request_redraw(item->canvas, x0, y0, x1, y1); - e_reflow->need_height_update = FALSE; - } else if (e_reflow->need_column_resize) { - int x_rect, y_rect, width_rect, height_rect; - int start_line = e_reflow_pick_line(e_reflow, - gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value); - gdouble running_width; - int i; - double column_width; - - if ( e_reflow->previous_temp_column_width != -1 ) { - running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER); - column_width = e_reflow->previous_temp_column_width; - running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - for ( i = 0; i < e_reflow->column_count; i++) { - x_rect = running_width; - gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - } - - if ( e_reflow->temp_column_width != -1 ) { - running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER); - column_width = e_reflow->temp_column_width; - running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - for ( i = 0; i < e_reflow->column_count; i++) { - x_rect = running_width; - gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - } - - e_reflow->previous_temp_column_width = e_reflow->temp_column_width; - e_reflow->need_column_resize = FALSE; - } -} - -static void -e_reflow_resize_children (GnomeCanvasItem *item) -{ - GList *list; - EReflow *e_reflow; - - e_reflow = E_REFLOW (item); - for ( list = e_reflow->items; list; list = list->next ) { - GnomeCanvasItem *child = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(child, - "width", (double) e_reflow->column_width, - NULL); - } -} - -static double -e_reflow_point (GnomeCanvasItem *item, - double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - double distance = 1; - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->point) - distance = GNOME_CANVAS_ITEM_CLASS(parent_class)->point (item, x, y, cx, cy, actual_item); - if (*actual_item) - return 0; - - *actual_item = item; - return 0; -#if 0 - if (y >= E_REFLOW_BORDER_WIDTH && y <= e_reflow->height - E_REFLOW_BORDER_WIDTH) { - float n_x; - n_x = x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x, (e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if (n_x < E_REFLOW_FULL_GUTTER) { - *actual_item = item; - return 0; - } - } - return distance; -#endif -} - -static void -_reflow( EReflow *e_reflow ) -{ - gdouble running_height; - GList *list; - double item_height; - - if (e_reflow->columns) { - g_list_free (e_reflow->columns); - e_reflow->columns = NULL; - } - - e_reflow->column_count = 0; - - if (e_reflow->items == NULL) { - e_reflow->columns = NULL; - e_reflow->column_count = 0; - return; - } - - list = e_reflow->items; - - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH; - e_reflow->columns = g_list_append (e_reflow->columns, list); - e_reflow->column_count = 1; - - list = g_list_next(list); - - for ( ; list; list = g_list_next(list)) { - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - if (running_height + item_height + E_REFLOW_BORDER_WIDTH > e_reflow->height) { - running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH; - e_reflow->columns = g_list_append (e_reflow->columns, list); - e_reflow->column_count ++; - } else { - running_height += item_height + E_REFLOW_BORDER_WIDTH; - } - } -} - -static void -set_empty(EReflow *e_reflow) -{ - if (e_reflow->items == NULL) { - if (e_reflow->empty_text) { - if (e_reflow->empty_message) { - gnome_canvas_item_set(e_reflow->empty_text, - "width", e_reflow->minimum_width, - "text", e_reflow->empty_message, - NULL); - e_canvas_item_move_absolute(e_reflow->empty_text, - e_reflow->minimum_width / 2, - 0); - } else { - gtk_object_destroy(GTK_OBJECT(e_reflow->empty_text)); - e_reflow->empty_text = NULL; - } - } else { - if (e_reflow->empty_message) - e_reflow->empty_text = - gnome_canvas_item_new(GNOME_CANVAS_GROUP(e_reflow), - e_text_get_type(), - "anchor", GTK_ANCHOR_N, - "width", e_reflow->minimum_width, - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", GTK_WIDGET(GNOME_CANVAS_ITEM(e_reflow)->canvas)->style->font, - "fill_color", "black", - "justification", GTK_JUSTIFY_CENTER, - "text", e_reflow->empty_message, - NULL); - e_canvas_item_move_absolute(e_reflow->empty_text, - e_reflow->minimum_width / 2, - 0); - } - } else { - if (e_reflow->empty_text) { - gtk_object_destroy(GTK_OBJECT(e_reflow->empty_text)); - e_reflow->empty_text = NULL; - } - } -} - -static void -e_reflow_reflow( GnomeCanvasItem *item, int flags ) -{ - EReflow *e_reflow = E_REFLOW(item); - if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) { - - gdouble old_width; - gdouble running_width; - - _reflow (e_reflow); - - old_width = e_reflow->width; - - running_width = E_REFLOW_BORDER_WIDTH; - - if (e_reflow->items == NULL) { - } else { - GList *list; - GList *next_column; - gdouble item_height; - gdouble running_height; - - running_height = E_REFLOW_BORDER_WIDTH; - - list = e_reflow->items; - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), - (double) running_width, - (double) running_height); - running_height += item_height + E_REFLOW_BORDER_WIDTH; - next_column = g_list_next(e_reflow->columns); - list = g_list_next(list); - - for( ; list; list = g_list_next(list)) { - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - - if (next_column && (next_column->data == list)) { - next_column = g_list_next (next_column); - running_height = E_REFLOW_BORDER_WIDTH; - running_width += e_reflow->column_width + E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH; - } - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), - (double) running_width, - (double) running_height); - - running_height += item_height + E_REFLOW_BORDER_WIDTH; - } - - } - e_reflow->width = running_width + e_reflow->column_width + E_REFLOW_BORDER_WIDTH; - if ( e_reflow->width < e_reflow->minimum_width ) - e_reflow->width = e_reflow->minimum_width; - if (old_width != e_reflow->width) - e_canvas_item_request_parent_reflow(item); - } -} - -void -e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item) -{ - if (E_REFLOW_CLASS(GTK_OBJECT(e_reflow)->klass)->add_item) - (E_REFLOW_CLASS(GTK_OBJECT(e_reflow)->klass)->add_item) (e_reflow, item); -} - -void -e_reflow_post_add_item(EReflow *e_reflow, GnomeCanvasItem *item) -{ - set_empty(e_reflow); -} diff --git a/widgets/misc/e-reflow.h b/widgets/misc/e-reflow.h deleted file mode 100644 index eb66b094a5..0000000000 --- a/widgets/misc/e-reflow.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-reflow.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_REFLOW_H__ -#define __E_REFLOW_H__ - -#include <gnome.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EReflow - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_REFLOW_TYPE (e_reflow_get_type ()) -#define E_REFLOW(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_TYPE, EReflow)) -#define E_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_TYPE, EReflowClass)) -#define E_IS_REFLOW(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_TYPE)) -#define E_IS_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_TYPE)) - - -typedef struct _EReflow EReflow; -typedef struct _EReflowClass EReflowClass; - -struct _EReflow -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - GList *items; /* Of type GnomeCanvasItem */ - GList *columns; /* Of type GList of type GnomeCanvasItem (points into items) */ - gint column_count; /* Number of columnns */ - - GnomeCanvasItem *empty_text; - gchar *empty_message; - - double minimum_width; - double width; - double height; - - double column_width; - - int idle; - - /* These are all for when the column is being dragged. */ - gboolean column_drag; - gdouble start_x; - gint which_column_dragged; - double temp_column_width; - double previous_temp_column_width; - - guint need_height_update : 1; - guint need_column_resize : 1; - - guint default_cursor_shown : 1; - GdkCursor *arrow_cursor; - GdkCursor *default_cursor; -}; - -struct _EReflowClass -{ - GnomeCanvasGroupClass parent_class; - - /* Virtual methods. */ - void (* add_item) (EReflow *reflow, GnomeCanvasItem *item); -}; - -/* - * To be added to a reflow, an item must have the argument "width" as - * a Read/Write argument and "height" as a Read Only argument. It - * should also do an ECanvas parent reflow request if its size - * changes. - */ -void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item); -GtkType e_reflow_get_type (void); - -/* Internal usage only: */ -void e_reflow_post_add_item(EReflow *e_reflow, GnomeCanvasItem *item); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_REFLOW_H__ */ diff --git a/widgets/misc/e-scroll-frame.c b/widgets/misc/e-scroll-frame.c deleted file mode 100644 index 8105b9dee8..0000000000 --- a/widgets/misc/e-scroll-frame.c +++ /dev/null @@ -1,1250 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -/* EScrollFrame based on GtkScrolledWindow. - * - * Modifications by Federico Mena <federico@helixcode.com> - */ - -#include <config.h> -#include <gtk/gtkhscrollbar.h> -#include <gtk/gtkvscrollbar.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkviewport.h> -#include "e-scroll-frame.h" - - -/* scrolled window policy and size requisition handling: - * - * gtk size requisition works as follows: - * a widget upon size-request reports the width and height that it finds - * to be best suited to display its contents, including children. - * the width and/or height reported from a widget upon size requisition - * may be overidden by the user by specifying a width and/or height - * other than 0 through gtk_widget_set_usize(). - * - * a scrolled window needs (for imlementing all three policy types) to - * request its width and height based on two different rationales. - * 1) the user wants the scrolled window to just fit into the space - * that it gets allocated for a specifc dimension. - * 1.1) this does not apply if the user specified a concrete value - * value for that specific dimension by either specifying usize for the - * scrolled window or for its child. - * 2) the user wants the scrolled window to take as much space up as - * is desired by the child for a specifc dimension (i.e. POLICY_NEVER). - * - * also, kinda obvious: - * 3) a user would certainly not have choosen a scrolled window as a container - * for the child, if the resulting allocation takes up more space than the - * child would have allocated without the scrolled window. - * - * conclusions: - * A) from 1) follows: the scrolled window shouldn't request more space for a - * specifc dimension than is required at minimum. - * B) from 1.1) follows: the requisition may be overidden by usize of the scrolled - * window (done automatically) or by usize of the child (needs to be checked). - * C) from 2) follows: for POLICY_NEVER, the scrolled window simply reports the - * child's dimension. - * D) from 3) follows: the scrolled window child's minimum width and minimum height - * under A) at least correspond to the space taken up by its scrollbars. - */ - -/* Object argument IDs */ -enum { - ARG_0, - ARG_HADJUSTMENT, - ARG_VADJUSTMENT, - ARG_HSCROLLBAR_POLICY, - ARG_VSCROLLBAR_POLICY, - ARG_FRAME_PLACEMENT, - ARG_SHADOW_TYPE, - ARG_SCROLLBAR_SPACING -}; - -/* Private part of the EScrollFrame structure */ -typedef struct { - /* Horizontal and vertical scrollbars */ - GtkWidget *hsb; - GtkWidget *vsb; - - /* Space between scrollbars and frame */ - guint sb_spacing; - - /* Allocation for frame */ - guint frame_x; - guint frame_y; - guint frame_w; - guint frame_h; - - /* Scrollbar policy */ - guint hsb_policy : 2; - guint vsb_policy : 2; - - /* Whether scrollbars are visible */ - guint hsb_visible : 1; - guint vsb_visible : 1; - - /* Placement of frame wrt scrollbars */ - guint frame_placement : 2; - - /* Shadow type for frame */ - guint shadow_type : 3; -} ScrollFramePrivate; - - -static void e_scroll_frame_class_init (EScrollFrameClass *class); -static void e_scroll_frame_init (EScrollFrame *sf); -static void e_scroll_frame_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_scroll_frame_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_scroll_frame_destroy (GtkObject *object); -static void e_scroll_frame_finalize (GtkObject *object); - -static void e_scroll_frame_map (GtkWidget *widget); -static void e_scroll_frame_unmap (GtkWidget *widget); -static void e_scroll_frame_draw (GtkWidget *widget, GdkRectangle *area); -static void e_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void e_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gint e_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event); -static gint e_scroll_frame_button_press (GtkWidget *widget, GdkEventButton *event); -static void e_scroll_frame_add (GtkContainer *container, GtkWidget *widget); -static void e_scroll_frame_remove (GtkContainer *container, GtkWidget *widget); -static void e_scroll_frame_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data); - -static GtkBinClass *parent_class; - - -/** - * e_scroll_frame_get_type: - * @void: - * - * Registers the #EScrollFrame class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #EScrollFrame class. - **/ -GtkType -e_scroll_frame_get_type (void) -{ - static GtkType scroll_frame_type = 0; - - if (!scroll_frame_type) { - static const GtkTypeInfo scroll_frame_info = { - "EScrollFrame", - sizeof (EScrollFrame), - sizeof (EScrollFrameClass), - (GtkClassInitFunc) e_scroll_frame_class_init, - (GtkObjectInitFunc) e_scroll_frame_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - scroll_frame_type = gtk_type_unique (GTK_TYPE_BIN, &scroll_frame_info); - } - - return scroll_frame_type; -} - -/* Class initialization function for the scroll frame widget */ -static void -e_scroll_frame_class_init (EScrollFrameClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - container_class = (GtkContainerClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_BIN); - - gtk_object_add_arg_type ("EScrollFrame::hadjustment", - GTK_TYPE_ADJUSTMENT, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, - ARG_HADJUSTMENT); - gtk_object_add_arg_type ("EScrollFrame::vadjustment", - GTK_TYPE_ADJUSTMENT, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, - ARG_VADJUSTMENT); - gtk_object_add_arg_type ("EScrollFrame::hscrollbar_policy", - GTK_TYPE_POLICY_TYPE, - GTK_ARG_READWRITE, - ARG_HSCROLLBAR_POLICY); - gtk_object_add_arg_type ("EScrollFrame::vscrollbar_policy", - GTK_TYPE_POLICY_TYPE, - GTK_ARG_READWRITE, - ARG_VSCROLLBAR_POLICY); - gtk_object_add_arg_type ("EScrollFrame::frame_placement", - GTK_TYPE_CORNER_TYPE, - GTK_ARG_READWRITE, - ARG_FRAME_PLACEMENT); - gtk_object_add_arg_type ("EScrollFrame::shadow_type", - GTK_TYPE_SHADOW_TYPE, - GTK_ARG_READWRITE, - ARG_SHADOW_TYPE); - gtk_object_add_arg_type ("EScrollFrame::scrollbar_spacing", - GTK_TYPE_UINT, - GTK_ARG_READWRITE, - ARG_SCROLLBAR_SPACING); - - object_class->set_arg = e_scroll_frame_set_arg; - object_class->get_arg = e_scroll_frame_get_arg; - object_class->destroy = e_scroll_frame_destroy; - object_class->finalize = e_scroll_frame_finalize; - - widget_class->map = e_scroll_frame_map; - widget_class->unmap = e_scroll_frame_unmap; - widget_class->draw = e_scroll_frame_draw; - widget_class->size_request = e_scroll_frame_size_request; - widget_class->size_allocate = e_scroll_frame_size_allocate; - widget_class->expose_event = e_scroll_frame_expose; - widget_class->button_press_event = e_scroll_frame_button_press; - - container_class->add = e_scroll_frame_add; - container_class->remove = e_scroll_frame_remove; - container_class->forall = e_scroll_frame_forall; -} - -/* Object initialization function for the scroll frame widget */ -static void -e_scroll_frame_init (EScrollFrame *sf) -{ - ScrollFramePrivate *priv; - - priv = g_new0 (ScrollFramePrivate, 1); - sf->priv = priv; - - GTK_WIDGET_SET_FLAGS (sf, GTK_NO_WINDOW); - - gtk_container_set_resize_mode (GTK_CONTAINER (sf), GTK_RESIZE_QUEUE); - - priv->sb_spacing = 3; - priv->hsb_policy = GTK_POLICY_ALWAYS; - priv->vsb_policy = GTK_POLICY_ALWAYS; - priv->frame_placement = GTK_CORNER_TOP_LEFT; - priv->shadow_type = GTK_SHADOW_NONE; -} - -/* Set_arg handler for the scroll frame widget */ -static void -e_scroll_frame_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - sf = E_SCROLL_FRAME (object); - priv = sf->priv; - - switch (arg_id) { - case ARG_HADJUSTMENT: - e_scroll_frame_set_hadjustment (sf, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_VADJUSTMENT: - e_scroll_frame_set_vadjustment (sf, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_HSCROLLBAR_POLICY: - e_scroll_frame_set_policy (sf, GTK_VALUE_ENUM (*arg), priv->vsb_policy); - break; - - case ARG_VSCROLLBAR_POLICY: - e_scroll_frame_set_policy (sf, priv->hsb_policy, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_FRAME_PLACEMENT: - e_scroll_frame_set_placement (sf, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_SHADOW_TYPE: - e_scroll_frame_set_shadow_type (sf, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_SCROLLBAR_SPACING: - e_scroll_frame_set_scrollbar_spacing (sf, GTK_VALUE_UINT (*arg)); - break; - - default: - break; - } -} - -/* Get_arg handler for the scroll frame widget */ -static void -e_scroll_frame_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - sf = E_SCROLL_FRAME (object); - priv = sf->priv; - - switch (arg_id) { - case ARG_HADJUSTMENT: - GTK_VALUE_POINTER (*arg) = e_scroll_frame_get_hadjustment (sf); - break; - - case ARG_VADJUSTMENT: - GTK_VALUE_POINTER (*arg) = e_scroll_frame_get_vadjustment (sf); - break; - - case ARG_HSCROLLBAR_POLICY: - GTK_VALUE_ENUM (*arg) = priv->hsb_policy; - break; - - case ARG_VSCROLLBAR_POLICY: - GTK_VALUE_ENUM (*arg) = priv->vsb_policy; - break; - - case ARG_FRAME_PLACEMENT: - GTK_VALUE_ENUM (*arg) = priv->frame_placement; - break; - - case ARG_SHADOW_TYPE: - GTK_VALUE_ENUM (*arg) = priv->shadow_type; - break; - - case ARG_SCROLLBAR_SPACING: - GTK_VALUE_UINT (*arg) = priv->sb_spacing; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/* Destroy handler for the scroll frame widget */ -static void -e_scroll_frame_destroy (GtkObject *object) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (object)); - - sf = E_SCROLL_FRAME (object); - priv = sf->priv; - - gtk_widget_unparent (priv->hsb); - gtk_widget_unparent (priv->vsb); - gtk_widget_destroy (priv->hsb); - gtk_widget_destroy (priv->vsb); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Finalize handler for the scroll frame widget */ -static void -e_scroll_frame_finalize (GtkObject *object) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - sf = E_SCROLL_FRAME (object); - priv = sf->priv; - - gtk_widget_unref (priv->hsb); - gtk_widget_unref (priv->vsb); - - g_free (priv); - - if (GTK_OBJECT_CLASS (parent_class)->finalize) - (* GTK_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Map handler for the scroll frame widget */ -static void -e_scroll_frame_map (GtkWidget *widget) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - g_return_if_fail (widget != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (widget)); - - sf = E_SCROLL_FRAME (widget); - priv = sf->priv; - - /* chain parent class handler to map self and child */ - if (GTK_WIDGET_CLASS (parent_class)->map) - (* GTK_WIDGET_CLASS (parent_class)->map) (widget); - - if (GTK_WIDGET_VISIBLE (priv->hsb) && !GTK_WIDGET_MAPPED (priv->hsb)) - gtk_widget_map (priv->hsb); - - if (GTK_WIDGET_VISIBLE (priv->vsb) && !GTK_WIDGET_MAPPED (priv->vsb)) - gtk_widget_map (priv->vsb); -} - -/* Unmap handler for the scroll frame widget */ -static void -e_scroll_frame_unmap (GtkWidget *widget) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - g_return_if_fail (widget != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (widget)); - - sf = E_SCROLL_FRAME (widget); - priv = sf->priv; - - /* chain parent class handler to unmap self and child */ - if (GTK_WIDGET_CLASS (parent_class)->unmap) - (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); - - if (GTK_WIDGET_MAPPED (priv->hsb)) - gtk_widget_unmap (priv->hsb); - - if (GTK_WIDGET_MAPPED (priv->vsb)) - gtk_widget_unmap (priv->vsb); -} - -/* Draws the shadow of a scroll frame widget */ -static void -draw_shadow (EScrollFrame *sf, GdkRectangle *area) -{ - ScrollFramePrivate *priv; - - g_assert (area != NULL); - - priv = sf->priv; - - gtk_paint_shadow (GTK_WIDGET (sf)->style, - GTK_WIDGET (sf)->window, - GTK_STATE_NORMAL, priv->shadow_type, - area, GTK_WIDGET (sf), - "scroll_frame", - priv->frame_x, priv->frame_y, - priv->frame_w, priv->frame_h); -} - -/* Draw handler for the scroll frame widget */ -static void -e_scroll_frame_draw (GtkWidget *widget, GdkRectangle *area) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - GtkBin *bin; - GdkRectangle child_area; - - g_return_if_fail (widget != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (widget)); - g_return_if_fail (area != NULL); - - sf = E_SCROLL_FRAME (widget); - priv = sf->priv; - bin = GTK_BIN (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) - draw_shadow (sf, area); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child) - && gtk_widget_intersect (bin->child, area, &child_area)) - gtk_widget_draw (bin->child, &child_area); - - if (GTK_WIDGET_VISIBLE (priv->hsb) - && gtk_widget_intersect (priv->hsb, area, &child_area)) - gtk_widget_draw (priv->hsb, &child_area); - - if (GTK_WIDGET_VISIBLE (priv->vsb) - && gtk_widget_intersect (priv->vsb, area, &child_area)) - gtk_widget_draw (priv->vsb, &child_area); -} - -/* Forall handler for the scroll frame widget */ -static void -e_scroll_frame_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - g_return_if_fail (container != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (container)); - g_return_if_fail (callback != NULL); - - sf = E_SCROLL_FRAME (container); - priv = sf->priv; - - if (GTK_CONTAINER_CLASS (parent_class)->forall) - (* GTK_CONTAINER_CLASS (parent_class)->forall) ( - container, include_internals, - callback, callback_data); - - if (include_internals) { - if (priv->vsb) - (* callback) (priv->vsb, callback_data); - - if (priv->hsb) - (* callback) (priv->hsb, callback_data); - } -} - -/* Size_request handler for the scroll frame widget */ -static void -e_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - GtkBin *bin; - gint extra_width; - gint extra_height; - GtkRequisition hsb_requisition; - GtkRequisition vsb_requisition; - GtkRequisition child_requisition; - - g_return_if_fail (widget != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (widget)); - g_return_if_fail (requisition != NULL); - - sf = E_SCROLL_FRAME (widget); - priv = sf->priv; - bin = GTK_BIN (widget); - - extra_width = 0; - extra_height = 0; - - requisition->width = GTK_CONTAINER (widget)->border_width * 2; - requisition->height = GTK_CONTAINER (widget)->border_width * 2; - - if (priv->shadow_type != GTK_SHADOW_NONE) { - requisition->width += 2 * widget->style->klass->xthickness; - requisition->height += 2 * widget->style->klass->ythickness; - } - - gtk_widget_size_request (priv->hsb, &hsb_requisition); - gtk_widget_size_request (priv->vsb, &vsb_requisition); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - static guint quark_aux_info; - - if (!quark_aux_info) - quark_aux_info = g_quark_from_static_string ("gtk-aux-info"); - - gtk_widget_size_request (bin->child, &child_requisition); - - if (priv->hsb_policy == GTK_POLICY_NEVER) - requisition->width += child_requisition.width; - else { - GtkWidgetAuxInfo *aux_info; - - aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), - quark_aux_info); - if (aux_info && aux_info->width > 0) { - requisition->width += aux_info->width; - extra_width = -1; - } else - requisition->width += vsb_requisition.width; - } - - if (priv->vsb_policy == GTK_POLICY_NEVER) - requisition->height += child_requisition.height; - else { - GtkWidgetAuxInfo *aux_info; - - aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), - quark_aux_info); - if (aux_info && aux_info->height > 0) { - requisition->height += aux_info->height; - extra_height = -1; - } else - requisition->height += hsb_requisition.height; - } - } - - if (priv->hsb_policy == GTK_POLICY_AUTOMATIC || GTK_WIDGET_VISIBLE (priv->hsb)) { - requisition->width = MAX (requisition->width, hsb_requisition.width); - if (!extra_height || GTK_WIDGET_VISIBLE (priv->hsb)) - extra_height = priv->sb_spacing + hsb_requisition.height; - } - - if (priv->vsb_policy == GTK_POLICY_AUTOMATIC || GTK_WIDGET_VISIBLE (priv->vsb)) { - requisition->height = MAX (requisition->height, vsb_requisition.height); - if (!extra_width || GTK_WIDGET_VISIBLE (priv->vsb)) - extra_width = priv->sb_spacing + vsb_requisition.width; - } - - requisition->width += MAX (0, extra_width); - requisition->height += MAX (0, extra_height); -} - -/* Computes the relative allocation for the scroll frame widget */ -static void -compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - g_assert (widget != NULL); - g_assert (E_IS_SCROLL_FRAME (widget)); - g_assert (allocation != NULL); - - sf = E_SCROLL_FRAME (widget); - priv = sf->priv; - - allocation->x = GTK_CONTAINER (widget)->border_width; - allocation->y = GTK_CONTAINER (widget)->border_width; - allocation->width = MAX (1, ((gint)widget->allocation.width) - (gint) allocation->x * 2); - allocation->height = MAX (1, ((gint)widget->allocation.height) - (gint) allocation->y * 2); - - if (priv->vsb_visible) { - GtkRequisition vsb_requisition; - - gtk_widget_get_child_requisition (priv->vsb, &vsb_requisition); - - if (priv->frame_placement == GTK_CORNER_TOP_RIGHT - || priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->x += vsb_requisition.width + priv->sb_spacing; - - allocation->width = MAX (1, ((gint) allocation->width) - - (gint) (vsb_requisition.width + priv->sb_spacing)); - } - - if (priv->hsb_visible) { - GtkRequisition hsb_requisition; - - gtk_widget_get_child_requisition (priv->hsb, &hsb_requisition); - - if (priv->frame_placement == GTK_CORNER_BOTTOM_LEFT - || priv->frame_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->y += hsb_requisition.height + priv->sb_spacing; - - allocation->height = MAX (1, ((gint) allocation->height) - - (gint) (hsb_requisition.height + priv->sb_spacing)); - } -} - -/* Size_allocate handler for the scroll frame widget */ -static void -e_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - GtkBin *bin; - GtkAllocation relative_allocation; - GtkAllocation child_allocation; - gint xthickness, ythickness; - - g_return_if_fail (widget != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (widget)); - g_return_if_fail (allocation != NULL); - - sf = E_SCROLL_FRAME (widget); - priv = sf->priv; - bin = GTK_BIN (widget); - - widget->allocation = *allocation; - - if (priv->hsb_policy == GTK_POLICY_ALWAYS) - priv->hsb_visible = TRUE; - else if (priv->hsb_policy == GTK_POLICY_NEVER) - priv->hsb_visible = FALSE; - - if (priv->vsb_policy == GTK_POLICY_ALWAYS) - priv->vsb_visible = TRUE; - else if (priv->vsb_policy == GTK_POLICY_NEVER) - priv->vsb_visible = FALSE; - - if (priv->shadow_type == GTK_SHADOW_NONE) { - xthickness = 0; - ythickness = 0; - } else { - xthickness = widget->style->klass->xthickness; - ythickness = widget->style->klass->ythickness; - } - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gboolean previous_hvis; - gboolean previous_vvis; - guint count = 0; - - do { - compute_relative_allocation (widget, &relative_allocation); - - priv->frame_x = relative_allocation.x + allocation->x; - priv->frame_y = relative_allocation.y + allocation->y; - priv->frame_w = relative_allocation.width; - priv->frame_h = relative_allocation.height; - - child_allocation.x = priv->frame_x + xthickness; - child_allocation.y = priv->frame_y + ythickness; - child_allocation.width = MAX ((gint)priv->frame_w - 2 * xthickness, 0); - child_allocation.height = MAX ((gint)priv->frame_h - 2 * ythickness, 0); - - previous_hvis = priv->hsb_visible; - previous_vvis = priv->vsb_visible; - - gtk_widget_size_allocate (bin->child, &child_allocation); - - /* If, after the first iteration, the hscrollbar and the - * vscrollbar flip visiblity, then we need both. - */ - if (count - && previous_hvis != priv->hsb_visible - && previous_vvis != priv->vsb_visible) { - priv->hsb_visible = TRUE; - priv->vsb_visible = TRUE; - - /* a new resize is already queued at this point, - * so we will immediatedly get reinvoked - */ - return; - } - - count++; - } while (previous_hvis != priv->hsb_visible - || previous_vvis != priv->vsb_visible); - } else - compute_relative_allocation (widget, &relative_allocation); - - if (priv->hsb_visible) { - GtkRequisition hscrollbar_requisition; - - gtk_widget_get_child_requisition (priv->hsb, &hscrollbar_requisition); - - if (!GTK_WIDGET_VISIBLE (priv->hsb)) - gtk_widget_show (priv->hsb); - - child_allocation.x = relative_allocation.x; - if (priv->frame_placement == GTK_CORNER_TOP_LEFT - || priv->frame_placement == GTK_CORNER_TOP_RIGHT) - child_allocation.y = (relative_allocation.y - + relative_allocation.height - + priv->sb_spacing); - else - child_allocation.y = GTK_CONTAINER (sf)->border_width; - - child_allocation.width = relative_allocation.width; - child_allocation.height = hscrollbar_requisition.height; - child_allocation.x += allocation->x; - child_allocation.y += allocation->y; - - gtk_widget_size_allocate (priv->hsb, &child_allocation); - } else if (GTK_WIDGET_VISIBLE (priv->hsb)) - gtk_widget_hide (priv->hsb); - - if (priv->vsb_visible) { - GtkRequisition vscrollbar_requisition; - - if (!GTK_WIDGET_VISIBLE (priv->vsb)) - gtk_widget_show (priv->vsb); - - gtk_widget_get_child_requisition (priv->vsb, &vscrollbar_requisition); - - if (priv->frame_placement == GTK_CORNER_TOP_LEFT - || priv->frame_placement == GTK_CORNER_BOTTOM_LEFT) - child_allocation.x = (relative_allocation.x - + relative_allocation.width - + priv->sb_spacing); - else - child_allocation.x = GTK_CONTAINER (sf)->border_width; - - child_allocation.y = relative_allocation.y; - child_allocation.width = vscrollbar_requisition.width; - child_allocation.height = relative_allocation.height; - child_allocation.x += allocation->x; - child_allocation.y += allocation->y; - - gtk_widget_size_allocate (priv->vsb, &child_allocation); - } else if (GTK_WIDGET_VISIBLE (priv->vsb)) - gtk_widget_hide (priv->vsb); -} - -/* Button press handler for the scroll framw diget */ -static gint -e_scroll_frame_button_press (GtkWidget *widget, GdkEventButton *event) -{ - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_SCROLL_FRAME (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - /* This is to handle mouse wheel scrolling */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj; - gfloat new_value; - - gtk_object_get (GTK_OBJECT (widget), - (event->state & GDK_CONTROL_MASK) ? - "hadjustment" : "vadjustment", - &adj, - NULL); - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment / 2: - adj->page_increment / 2); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - return FALSE; -} - -/* Expose handler for the scroll frame widget */ -static gint -e_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event) -{ - EScrollFrame *sf; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_SCROLL_FRAME (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - sf = E_SCROLL_FRAME (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) - draw_shadow (sf, &event->area); - - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); - - return FALSE; -} - -/* Add handler for the scroll frame widget */ -static void -e_scroll_frame_add (GtkContainer *container, GtkWidget *child) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - GtkBin *bin; - - sf = E_SCROLL_FRAME (container); - priv = sf->priv; - bin = GTK_BIN (container); - g_return_if_fail (bin->child == NULL); - - bin->child = child; - gtk_widget_set_parent (child, GTK_WIDGET (bin)); - - /* this is a temporary message */ - if (!gtk_widget_set_scroll_adjustments (child, - gtk_range_get_adjustment (GTK_RANGE (priv->hsb)), - gtk_range_get_adjustment (GTK_RANGE (priv->vsb)))) -#if 0 - g_warning ("e_scroll_frame_add(): cannot add non scrollable widget " - "use e_scroll_frame_add_with_viewport() instead"); -#else - ; -#endif - - if (GTK_WIDGET_REALIZED (child->parent)) - gtk_widget_realize (child); - - if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child)) { - if (GTK_WIDGET_MAPPED (child->parent)) - gtk_widget_map (child); - - gtk_widget_queue_resize (child); - } -} - -/* Remove method for the scroll frame widget */ -static void -e_scroll_frame_remove (GtkContainer *container, GtkWidget *child) -{ - g_return_if_fail (container != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (container)); - g_return_if_fail (child != NULL); - g_return_if_fail (GTK_BIN (container)->child == child); - - gtk_widget_set_scroll_adjustments (child, NULL, NULL); - - /* chain parent class handler to remove child */ - if (GTK_CONTAINER_CLASS (parent_class)->remove) - (* GTK_CONTAINER_CLASS (parent_class)->remove) (container, child); -} - -/** - * e_scroll_frame_new: - * @hadj: If non-NULL, the adjustment to use for horizontal scrolling. - * @vadj: If non-NULL, the adjustment to use for vertical scrolling. - * - * Creates a new scroll frame widget. - * - * Return value: The newly-created scroll frame widget. - **/ -GtkWidget * -e_scroll_frame_new (GtkAdjustment *hadj, GtkAdjustment *vadj) -{ - if (hadj) - g_return_val_if_fail (GTK_IS_ADJUSTMENT (hadj), NULL); - - if (vadj) - g_return_val_if_fail (GTK_IS_ADJUSTMENT (vadj), NULL); - - return gtk_widget_new (E_TYPE_SCROLL_FRAME, - "hadjustment", hadj, - "vadjustment", vadj, - NULL); -} - -/* Callback used when one of the scroll frame widget's adjustments changes */ -static void -adjustment_changed (GtkAdjustment *adj, gpointer data) -{ - EScrollFrame *sf; - ScrollFramePrivate *priv; - - g_return_if_fail (adj != NULL); - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - g_return_if_fail (data != NULL); - - sf = E_SCROLL_FRAME (data); - priv = sf->priv; - - if (adj == gtk_range_get_adjustment (GTK_RANGE (priv->hsb))) { - if (priv->hsb_policy == GTK_POLICY_AUTOMATIC) { - gboolean visible; - - visible = priv->hsb_visible; - priv->hsb_visible = (adj->upper - adj->lower > adj->page_size); - if (priv->hsb_visible != visible) - gtk_widget_queue_resize (GTK_WIDGET (sf)); - } - } else if (adj == gtk_range_get_adjustment (GTK_RANGE (priv->vsb))) { - if (priv->vsb_policy == GTK_POLICY_AUTOMATIC) { - gboolean visible; - - visible = priv->vsb_visible; - priv->vsb_visible = (adj->upper - adj->lower > adj->page_size); - if (priv->vsb_visible != visible) - gtk_widget_queue_resize (GTK_WIDGET (sf)); - } - } -} - -/** - * e_scroll_frame_set_hadjustment: - * @sf: A scroll frame widget. - * @adj: An adjustment. - * - * Sets the adjustment to be used for horizontal scrolling in a scroll frame - * widget. - **/ -void -e_scroll_frame_set_hadjustment (EScrollFrame *sf, GtkAdjustment *adj) -{ - ScrollFramePrivate *priv; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - - priv = sf->priv; - - if (adj) - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - else - adj = GTK_ADJUSTMENT (gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL)); - - if (!priv->hsb) { - gtk_widget_push_composite_child (); - priv->hsb = gtk_hscrollbar_new (adj); - gtk_widget_set_composite_name (priv->hsb, "hscrollbar"); - gtk_widget_pop_composite_child (); - - gtk_widget_set_parent (priv->hsb, GTK_WIDGET (sf)); - gtk_widget_ref (priv->hsb); - gtk_widget_show (priv->hsb); - } else { - GtkAdjustment *old_adj; - - old_adj = gtk_range_get_adjustment (GTK_RANGE (priv->hsb)); - if (old_adj == adj) - return; - - gtk_signal_disconnect_by_func (GTK_OBJECT (old_adj), - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - gtk_range_set_adjustment (GTK_RANGE (priv->hsb), adj); - } - - adj = gtk_range_get_adjustment (GTK_RANGE (priv->hsb)); - gtk_signal_connect (GTK_OBJECT (adj), - "changed", - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - adjustment_changed (adj, sf); - - if (GTK_BIN (sf)->child) - gtk_widget_set_scroll_adjustments ( - GTK_BIN (sf)->child, - gtk_range_get_adjustment (GTK_RANGE (priv->hsb)), - gtk_range_get_adjustment (GTK_RANGE (priv->vsb))); -} - -/** - * e_scroll_frame_set_vadjustment: - * @sf: A scroll frame widget. - * @adj: An adjustment. - * - * Sets the adjustment to be used for vertical scrolling in a scroll frame - * widget. - **/ -void -e_scroll_frame_set_vadjustment (EScrollFrame *sf, GtkAdjustment *adj) -{ - ScrollFramePrivate *priv; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - - priv = sf->priv; - - if (adj) - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - else - adj = GTK_ADJUSTMENT (gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL)); - - if (!priv->vsb) { - gtk_widget_push_composite_child (); - priv->vsb = gtk_vscrollbar_new (adj); - gtk_widget_set_composite_name (priv->vsb, "vscrollbar"); - gtk_widget_pop_composite_child (); - - gtk_widget_set_parent (priv->vsb, GTK_WIDGET (sf)); - gtk_widget_ref (priv->vsb); - gtk_widget_show (priv->vsb); - } else { - GtkAdjustment *old_adj; - - old_adj = gtk_range_get_adjustment (GTK_RANGE (priv->vsb)); - if (old_adj == adj) - return; - - gtk_signal_disconnect_by_func (GTK_OBJECT (old_adj), - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - gtk_range_set_adjustment (GTK_RANGE (priv->vsb), adj); - } - - adj = gtk_range_get_adjustment (GTK_RANGE (priv->vsb)); - gtk_signal_connect (GTK_OBJECT (adj), - "changed", - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - adjustment_changed (adj, sf); - - if (GTK_BIN (sf)->child) - gtk_widget_set_scroll_adjustments ( - GTK_BIN (sf)->child, - gtk_range_get_adjustment (GTK_RANGE (priv->hsb)), - gtk_range_get_adjustment (GTK_RANGE (priv->vsb))); -} - -/** - * e_scroll_frame_get_hadjustment: - * @sf: A scroll frame widget. - * - * Queries the horizontal adjustment of a scroll frame widget. - * - * Return value: The horizontal adjustment of the scroll frame, or NULL if none. - **/ -GtkAdjustment * -e_scroll_frame_get_hadjustment (EScrollFrame *sf) -{ - ScrollFramePrivate *priv; - - g_return_val_if_fail (sf != NULL, NULL); - g_return_val_if_fail (E_IS_SCROLL_FRAME (sf), NULL); - - priv = sf->priv; - - return priv->hsb ? gtk_range_get_adjustment (GTK_RANGE (priv->hsb)) : NULL; -} - -/** - * e_scroll_frame_get_vadjustment: - * @sf: A scroll frame widget. - * - * Queries the vertical adjustment of a scroll frame widget. - * - * Return value: The vertical adjustment of the scroll frame, or NULL if none. - **/ -GtkAdjustment * -e_scroll_frame_get_vadjustment (EScrollFrame *sf) -{ - ScrollFramePrivate *priv; - - g_return_val_if_fail (sf != NULL, NULL); - g_return_val_if_fail (E_IS_SCROLL_FRAME (sf), NULL); - - priv = sf->priv; - - return priv->vsb ? gtk_range_get_adjustment (GTK_RANGE (priv->vsb)) : NULL; -} - -/** - * e_scroll_frame_set_policy: - * @sf: A scroll frame widget. - * @hsb_policy: Policy for the horizontal scrollbar. - * @vsb_policy: Policy for the vertical scrollbar. - * - * Sets the scrollbar policies of a scroll frame widget. These determine when - * the scrollbars are to be shown or hidden. - **/ -void -e_scroll_frame_set_policy (EScrollFrame *sf, - GtkPolicyType hsb_policy, - GtkPolicyType vsb_policy) -{ - ScrollFramePrivate *priv; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - - priv = sf->priv; - - if (priv->hsb_policy == hsb_policy && priv->vsb_policy == vsb_policy) - return; - - priv->hsb_policy = hsb_policy; - priv->vsb_policy = vsb_policy; - - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * e_scroll_frame_set_placement: - * @sf: A scroll frame widget. - * @frame_placement: Placement for the frame. - * - * Sets the placement of a scroll frame widget's frame with respect to its - * scrollbars. - **/ -void -e_scroll_frame_set_placement (EScrollFrame *sf, GtkCornerType frame_placement) -{ - ScrollFramePrivate *priv; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - - priv = sf->priv; - - if (priv->frame_placement == frame_placement) - return; - - priv->frame_placement = frame_placement; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * e_scroll_frame_set_shadow_type: - * @sf: A scroll frame widget. - * @shadow_type: A shadow type. - * - * Sets the shadow type of a scroll frame widget. You can use this when you - * insert a child that does not paint a frame on its own. - **/ -void -e_scroll_frame_set_shadow_type (EScrollFrame *sf, GtkShadowType shadow_type) -{ - ScrollFramePrivate *priv; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - g_return_if_fail (shadow_type >= GTK_SHADOW_NONE && shadow_type <= GTK_SHADOW_ETCHED_OUT); - - priv = sf->priv; - - if (priv->shadow_type == shadow_type) - return; - - priv->shadow_type = shadow_type; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * e_scroll_frame_set_scrollbar_spacing: - * @sf: A scroll frame widget. - * @spacing: Desired spacing in pixels. - * - * Sets the spacing between the frame and the scrollbars of a scroll frame - * widget. - **/ -void -e_scroll_frame_set_scrollbar_spacing (EScrollFrame *sf, guint spacing) -{ - ScrollFramePrivate *priv; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - - priv = sf->priv; - - if (priv->sb_spacing == spacing) - return; - - priv->sb_spacing = spacing; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * e_scroll_frame_add_with_viewport: - * @sf: A scroll frame widget. - * @child: A widget. - * - * Creates a #GtkViewport and puts the specified child inside it, thus allowing - * the viewport to be scrolled by the scroll frame widget. This is meant to be - * used only when a child does not support the scrolling interface. - **/ -void -e_scroll_frame_add_with_viewport (EScrollFrame *sf, GtkWidget *child) -{ - ScrollFramePrivate *priv; - GtkBin *bin; - GtkWidget *viewport; - - g_return_if_fail (sf != NULL); - g_return_if_fail (E_IS_SCROLL_FRAME (sf)); - g_return_if_fail (child != NULL); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - - priv = sf->priv; - bin = GTK_BIN (sf); - - if (bin->child != NULL) { - g_return_if_fail (GTK_IS_VIEWPORT (bin->child)); - g_return_if_fail (GTK_BIN (bin->child)->child == NULL); - - viewport = bin->child; - } else { - viewport = gtk_viewport_new (e_scroll_frame_get_hadjustment (sf), - e_scroll_frame_get_vadjustment (sf)); - gtk_container_add (GTK_CONTAINER (sf), viewport); - } - - gtk_widget_show (viewport); - gtk_container_add (GTK_CONTAINER (viewport), child); -} diff --git a/widgets/misc/e-scroll-frame.h b/widgets/misc/e-scroll-frame.h deleted file mode 100644 index 4bdeee3e1d..0000000000 --- a/widgets/misc/e-scroll-frame.h +++ /dev/null @@ -1,95 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -/* EScrollFrame based on GtkScrolledWindow. - * - * Modifications by Federico Mena <federico@helixcode.com> - */ - -#ifndef __E_SCROLL_FRAME_H__ -#define __E_SCROLL_FRAME_H__ - - -#include <gdk/gdk.h> -#include <gtk/gtkbin.h> - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define E_TYPE_SCROLL_FRAME (e_scroll_frame_get_type ()) -#define E_SCROLL_FRAME(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SCROLL_FRAME, EScrollFrame)) -#define E_SCROLL_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SCROLL_FRAME, \ - EScrollFrameClass)) -#define E_IS_SCROLL_FRAME(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SCROLL_FRAME)) -#define E_IS_SCROLL_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SCROLL_FRAME)) - - -typedef struct _EScrollFrame EScrollFrame; -typedef struct _EScrollFrameClass EScrollFrameClass; - -struct _EScrollFrame -{ - GtkBin bin; - - /* Private data */ - gpointer priv; -}; - -struct _EScrollFrameClass -{ - GtkBinClass parent_class; -}; - - -GtkType e_scroll_frame_get_type (void); -GtkWidget *e_scroll_frame_new (GtkAdjustment *hadj, GtkAdjustment *vadj); - -void e_scroll_frame_set_hadjustment (EScrollFrame *sf, GtkAdjustment *adj); -void e_scroll_frame_set_vadjustment (EScrollFrame *sf, GtkAdjustment *adj); - -GtkAdjustment *e_scroll_frame_get_hadjustment (EScrollFrame *sf); -GtkAdjustment *e_scroll_frame_get_vadjustment (EScrollFrame *sf); - -void e_scroll_frame_set_policy (EScrollFrame *sf, - GtkPolicyType hsb_policy, - GtkPolicyType vsb_policy); - -void e_scroll_frame_set_placement (EScrollFrame *sf, GtkCornerType frame_placement); -void e_scroll_frame_set_shadow_type (EScrollFrame *sf, GtkShadowType shadow_type); -void e_scroll_frame_set_scrollbar_spacing (EScrollFrame *sf, guint spacing); - -void e_scroll_frame_add_with_viewport (EScrollFrame *sf, GtkWidget *child); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_SCROLL_FRAME_H__ */ diff --git a/widgets/misc/e-title-bar.c b/widgets/misc/e-title-bar.c deleted file mode 100644 index 30c4a42c88..0000000000 --- a/widgets/misc/e-title-bar.c +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.c - * - * Copyright (C) 2000 Helix Code, 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: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkbox.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkpixmap.h> -#include <gtk/gtksignal.h> -#include <gtk/gtktypeutils.h> - -#include "e-util/e-util.h" -#include "e-clipped-label.h" - -#include "e-title-bar.h" - - -enum { - TITLE_BUTTON_PRESS_EVENT, - CLOSE_BUTTON_CLICKED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - - -static char *close_button_xpm[] = { - "12 12 2 1", - " c none", - ". c #000000000000", - " ", - " .. .. ", - " ... ... ", - " ... ... ", - " ...... ", - " .... ", - " .... ", - " ...... ", - " ... ... ", - " ... ... ", - " .. .. ", - " " -}; - -#define PARENT_TYPE GTK_TYPE_FRAME -static GtkFrameClass *parent_class = NULL; - -struct _ETitleBarPrivate { - GtkWidget *label; - GtkWidget *close_button; - GtkWidget *close_button_gtk_pixmap; -}; - - -/* Child signal callbacks. */ - -static void -close_button_realize_cb (GtkWidget *widget, - gpointer data) -{ - GdkPixmap *close_button_pixmap; - GdkBitmap *close_button_mask; - ETitleBar *title_bar; - ETitleBarPrivate *priv; - - title_bar = E_TITLE_BAR (data); - priv = title_bar->priv; - - if (priv->close_button_gtk_pixmap != NULL) - return; - - close_button_pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (priv->close_button)->window, - &close_button_mask, - NULL, close_button_xpm); - priv->close_button_gtk_pixmap = gtk_pixmap_new (close_button_pixmap, close_button_mask); - - gtk_container_add (GTK_CONTAINER (priv->close_button), priv->close_button_gtk_pixmap); - gtk_widget_show (priv->close_button_gtk_pixmap); - - gdk_pixmap_unref (close_button_pixmap); - gdk_bitmap_unref (close_button_mask); -} - -static void -close_button_clicked_cb (GtkButton *button, - gpointer data) -{ - ETitleBar *title_bar; - - title_bar = E_TITLE_BAR (data); - - gtk_signal_emit (GTK_OBJECT (title_bar), signals[CLOSE_BUTTON_CLICKED]); -} - -static void -label_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - ETitleBar *title_bar; - - title_bar = E_TITLE_BAR (data); - - gtk_signal_emit (GTK_OBJECT (title_bar), signals[TITLE_BUTTON_PRESS_EVENT], event); -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - ETitleBar *title_bar; - ETitleBarPrivate *priv; - - title_bar = E_TITLE_BAR (object); - priv = title_bar->priv; - - g_free (priv); - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -class_init (ETitleBarClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - object_class->destroy = destroy; - - parent_class = gtk_type_class (gtk_frame_get_type ()); - - signals[TITLE_BUTTON_PRESS_EVENT] = - gtk_signal_new ("title_button_press_event", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (ETitleBarClass, title_button_press_event), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_GDK_EVENT); - - signals[CLOSE_BUTTON_CLICKED] = - gtk_signal_new ("close_button_clicked", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (ETitleBarClass, close_button_clicked), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -init (ETitleBar *title_bar) -{ - ETitleBarPrivate *priv; - - priv = g_new (ETitleBarPrivate, 1); - - priv->label = NULL; - priv->close_button = NULL; - priv->close_button_gtk_pixmap = NULL; - - title_bar->priv = priv; -} - - -void -e_title_bar_construct (ETitleBar *title_bar, - const char *title) -{ - ETitleBarPrivate *priv; - GtkWidget *hbox; - - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - - priv = title_bar->priv; - - priv->label = e_clipped_label_new (title); - gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); - gtk_widget_show (priv->label); - - priv->close_button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (priv->close_button, GTK_CAN_FOCUS); - gtk_container_set_border_width (GTK_CONTAINER (priv->close_button), 1); - gtk_button_set_relief (GTK_BUTTON (priv->close_button), GTK_RELIEF_NONE); - gtk_widget_show (priv->close_button); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->label, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (hbox), priv->close_button, FALSE, TRUE, 1); - gtk_widget_show (hbox); - - gtk_container_add (GTK_CONTAINER (title_bar), hbox); - - gtk_signal_connect (GTK_OBJECT (priv->close_button), "realize", - GTK_SIGNAL_FUNC (close_button_realize_cb), title_bar); - gtk_signal_connect (GTK_OBJECT (priv->close_button), "clicked", - GTK_SIGNAL_FUNC (close_button_clicked_cb), title_bar); - gtk_signal_connect (GTK_OBJECT (priv->label), "button_press_event", - GTK_SIGNAL_FUNC (label_button_press_event_cb), title_bar); -} - -GtkWidget * -e_title_bar_new (const char *title) -{ - ETitleBar *title_bar; - - title_bar = gtk_type_new (e_title_bar_get_type ()); - - e_title_bar_construct (title_bar, title); - - return GTK_WIDGET (title_bar); -} - - -void -e_title_bar_set_title (ETitleBar *title_bar, - const char *title) -{ - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - - e_clipped_label_set_text (E_CLIPPED_LABEL (title_bar->priv->label), title); -} - -void -e_title_bar_show_close_button (ETitleBar *title_bar, - gboolean show) -{ - ETitleBarPrivate *priv; - - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - - priv = title_bar->priv; - - if (show) - gtk_widget_show (priv->close_button); - else - gtk_widget_hide (priv->close_button); -} - - -E_MAKE_TYPE (e_title_bar, "ETitleBar", ETitleBar, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-title-bar.h b/widgets/misc/e-title-bar.h deleted file mode 100644 index ce7d23b07b..0000000000 --- a/widgets/misc/e-title-bar.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.h - * - * Copyright (C) 2000 Helix Code, 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: Ettore Perazzoli - */ - -#ifndef __E_TITLE_BAR_H__ -#define __E_TITLE_BAR_H__ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkframe.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_TITLE_BAR (e_title_bar_get_type ()) -#define E_TITLE_BAR(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TITLE_BAR, ETitleBar)) -#define E_TITLE_BAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TITLE_BAR, ETitleBarClass)) -#define E_IS_TITLE_BAR(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TITLE_BAR)) -#define E_IS_TITLE_BAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_TITLE_BAR)) - - -typedef struct _ETitleBar ETitleBar; -typedef struct _ETitleBarPrivate ETitleBarPrivate; -typedef struct _ETitleBarClass ETitleBarClass; - -struct _ETitleBar { - GtkFrame parent; - - ETitleBarPrivate *priv; -}; - -struct _ETitleBarClass { - GtkFrameClass parent_class; - - /* Signals. */ - - void (* title_button_press_event) (ETitleBar *title_bar, GdkEventButton *event); - void (* close_button_clicked) (ETitleBar *title_bar); -}; - - -GtkType e_title_bar_get_type (void); -void e_title_bar_construct (ETitleBar *title_bar, - const char *title); -GtkWidget *e_title_bar_new (const char *title); - -void e_title_bar_set_title (ETitleBar *title_bar, - const char *title); -void e_title_bar_show_close_button (ETitleBar *title_bar, - gboolean show); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_TITLE_BAR_H__ */ diff --git a/widgets/misc/pixmaps/cursor_cross.xpm b/widgets/misc/pixmaps/cursor_cross.xpm deleted file mode 100644 index cf9d0aca33..0000000000 --- a/widgets/misc/pixmaps/cursor_cross.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char * cursor_cross_xpm[] = { -"32 32 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ....... ", -" .+++++.. ", -" .+++++.. ", -" .+++++.. ", -" .+++++.. ", -" ......+++++...... ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" ......+++++....... ", -" .....+++++....... ", -" .+++++.. ", -" .+++++.. ", -" .+++++.. ", -" ........ ", -" ....... ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_hand_closed.xpm b/widgets/misc/pixmaps/cursor_hand_closed.xpm deleted file mode 100644 index 61a6de4b88..0000000000 --- a/widgets/misc/pixmaps/cursor_hand_closed.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char * cursor_hand_closed_xpm[] = { -"32 32 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ", -" ", -" .. ", -" ..++... ", -" .+++++++.. ", -" .+++++++++. ", -" ...+++++++++. ", -" .++.+++++++++. ", -" .++++++++++++. ", -" .+++++++++++. ", -" .++++++++++. ", -" .+++++++++. ", -" .+++++++. ", -" .++++++. ", -" .++++++. ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_hand_open.xpm b/widgets/misc/pixmaps/cursor_hand_open.xpm deleted file mode 100644 index 048acc8054..0000000000 --- a/widgets/misc/pixmaps/cursor_hand_open.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char * cursor_hand_open_xpm[] = { -"32 32 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" .. ", -" .. .++... ", -" .++..++.++. ", -" .++..++.++. . ", -" .++.++.++..+. ", -" .++.++.++.++. ", -" .. .+++++++.++. ", -" .++..++++++++++. ", -" .+++.+++++++++. ", -" .++++++++++++. ", -" .+++++++++++. ", -" .++++++++++. ", -" .+++++++++. ", -" .+++++++. ", -" .++++++. ", -" .++++++. ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_zoom_in.xpm b/widgets/misc/pixmaps/cursor_zoom_in.xpm deleted file mode 100644 index 1caf9e3e2a..0000000000 --- a/widgets/misc/pixmaps/cursor_zoom_in.xpm +++ /dev/null @@ -1,37 +0,0 @@ -/* XPM */ -static char * cursor_zoom_in_xpm[] = { -"32 32 2 1", -" c None", -". c #000000", -" ", -" ", -" ", -" ", -" ", -" ", -" ...... ", -" .. .. ", -" .. .. ", -" . . ", -" . ... . ", -" . ... . ", -" . ....... . ", -" . ....... . ", -" . ... . ", -" . ... .. ", -" .. . . ", -" .. . . . ", -" ........ . . ", -" ..... . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . ", -" . . ", -" .. ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_zoom_out.xpm b/widgets/misc/pixmaps/cursor_zoom_out.xpm deleted file mode 100644 index af1b698521..0000000000 --- a/widgets/misc/pixmaps/cursor_zoom_out.xpm +++ /dev/null @@ -1,37 +0,0 @@ -/* XPM */ -static char * cursor_zoom_out_xpm[] = { -"32 32 2 1", -" c None", -". c #000000", -" ", -" ", -" ", -" ", -" ", -" ", -" ...... ", -" .. .. ", -" .. .. ", -" . . ", -" . . ", -" . . ", -" . ....... . ", -" . ....... . ", -" . . ", -" . .. ", -" .. . . ", -" .. . . . ", -" ........ . . ", -" ..... . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . ", -" . . ", -" .. ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/test-calendar.c b/widgets/misc/test-calendar.c deleted file mode 100644 index 6463a21ce3..0000000000 --- a/widgets/misc/test-calendar.c +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 - */ - -/* - * test-calendar - tests the ECalendar widget. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> - -#include "e-calendar.h" - -static void -delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - gpointer data) -{ - gtk_main_quit (); -} - -int -main (int argc, char **argv) -{ - GtkWidget *app; - GtkWidget *cal; - GtkWidget *vbox; - - gnome_init ("test-calendar", "0.0", argc, argv); - - app = gnome_app_new ("Test", "Test"); - gtk_window_set_default_size (GTK_WINDOW (app), 400, 400); - gtk_window_set_policy (GTK_WINDOW (app), FALSE, TRUE, FALSE); - - gtk_signal_connect (GTK_OBJECT (app), "delete_event", - GTK_SIGNAL_FUNC (delete_event_cb), NULL); - - cal = e_calendar_new (); - gtk_widget_show (cal); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), cal, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - gnome_app_set_contents (GNOME_APP (app), vbox); - gtk_widget_show (app); - - gtk_main (); - - return 0; -} diff --git a/widgets/misc/test-title-bar.c b/widgets/misc/test-title-bar.c deleted file mode 100644 index fdca1ae0db..0000000000 --- a/widgets/misc/test-title-bar.c +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.c - * - * Copyright (C) 2000 Helix Code, 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: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> - -#include "e-title-bar.h" - -static void -delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - gpointer data) -{ - gtk_main_quit (); -} - -int -main (int argc, char **argv) -{ - GtkWidget *app; - GtkWidget *title_bar; - GtkWidget *text; - GtkWidget *vbox; - - gnome_init ("test-title-bar", "0.0", argc, argv); - - app = gnome_app_new ("Test", "Test"); - gtk_window_set_default_size (GTK_WINDOW (app), 400, 400); - gtk_window_set_policy (GTK_WINDOW (app), FALSE, TRUE, FALSE); - - gtk_signal_connect (GTK_OBJECT (app), "delete_event", GTK_SIGNAL_FUNC (delete_event_cb), NULL); - - title_bar = e_title_bar_new ("This is a very annoyingly long title bar"); - gtk_widget_show (title_bar); - - text = gtk_text_new (NULL, NULL); - gtk_widget_show (text); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), title_bar, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), text, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - gnome_app_set_contents (GNOME_APP (app), vbox); - gtk_widget_show (app); - - gtk_main (); - - return 0; -} |