/* * Add a major MIME type (as "text") to our viewer list * 'Key' is the content-type string that identifies the MIME type * 'Method' is the function that handles it */ static int Mime_add_major_type(const char *Key, Viewer_t Method) { a_List_add(MimeMajItems, MimeMajItemsSize, MimeMajItemsMax); MimeMajItems[MimeMajItemsSize].Name = Key; MimeMajItems[MimeMajItemsSize].Data = Method; MimeMajItemsSize++; return 0; }
/* * Queue an area for drawing. This function is called by * p_Dw_widget_queue_draw_area. x and y are passed in world coordinates. */ void Dw_gtk_viewport_queue_draw (GtkDwViewport *viewport, gint32 x, gint32 y, gint32 width, gint32 height) { DwRectangle area; int i; if (viewport->draw_resize_idle_id == 0) { viewport->draw_resize_action = DW_GTK_VIEWPORT_DRAW; viewport->draw_resize_idle_id = gtk_idle_add (Dw_gtk_viewport_draw_resize_idle, (gpointer)viewport); } else if (viewport->draw_resize_action == DW_GTK_VIEWPORT_RESIZE) /* Drawing is always overridden by resizing. */ return; area.x = x; area.y = y; area.width = width; area.height = height; /* First, try to keep the list as clean as possible. Check whether other * rectangles interfer with this one in some way. */ /* An idea for optimization: The list could be sorted, and so the part of * the list we have to consider here, may be reduced, the start may be * found via linear search. However, this probably makes balanced binary * trees necessary, since moving elements within the array may be quite * time-consuming. */ _MSG(" num_draw_areas = %d\n", viewport->num_draw_areas); for (i = 0; i < viewport->num_draw_areas; i++) { if (p_Dw_rectangle_is_subset (&area, &viewport->draw_areas[i])) /* First case: area is a subset of an already queued rectangle * -> nothing to do. */ return; else if (p_Dw_rectangle_is_subset (&viewport->draw_areas[i], &area)) { /* Second case: area is a subset of an already queued rectangle * -> replace the other one with area. */ viewport->draw_areas[i] = area; return; } /* Maybe some more tests: if both areas may exactly be combined to a * rectangle? Very unlikely case ... */ } /* No interference: add the new area to the list. */ viewport->num_draw_areas++; a_List_add (viewport->draw_areas, viewport->num_draw_areas, viewport->num_draw_areas_max); viewport->draw_areas[viewport->num_draw_areas - 1] = area; }