diff --git a/ChangeLog b/ChangeLog index cde11c8d50..e45c06eb54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-05-05 Tor Lillqvist + + * gdk/win32/gdkdnd-win32.c (gdk_drag_find_window_for_screen): Add + multi-monitor offset. (#141842, John Ehresman) + 2004-05-04 Federico Mena Quintero Fixes #139562, based on a patch by Christian Neumair. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index cde11c8d50..e45c06eb54 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2004-05-05 Tor Lillqvist + + * gdk/win32/gdkdnd-win32.c (gdk_drag_find_window_for_screen): Add + multi-monitor offset. (#141842, John Ehresman) + 2004-05-04 Federico Mena Quintero Fixes #139562, based on a patch by Christian Neumair. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index cde11c8d50..e45c06eb54 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +2004-05-05 Tor Lillqvist + + * gdk/win32/gdkdnd-win32.c (gdk_drag_find_window_for_screen): Add + multi-monitor offset. (#141842, John Ehresman) + 2004-05-04 Federico Mena Quintero Fixes #139562, based on a patch by Christian Neumair. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index cde11c8d50..e45c06eb54 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2004-05-05 Tor Lillqvist + + * gdk/win32/gdkdnd-win32.c (gdk_drag_find_window_for_screen): Add + multi-monitor offset. (#141842, John Ehresman) + 2004-05-04 Federico Mena Quintero Fixes #139562, based on a patch by Christian Neumair. diff --git a/demos/testgtk/main.c b/demos/testgtk/main.c deleted file mode 100644 index 9c479dee61..0000000000 --- a/demos/testgtk/main.c +++ /dev/null @@ -1,392 +0,0 @@ -#include -#include -#include -#include - -#include - -#include - -static GtkTextBuffer *info_buffer; -static GtkTextBuffer *source_buffer; - -static gchar *current_file = NULL; - -enum { - TITLE_COLUMN, - FILENAME_COLUMN, - FUNC_COLUMN, - ITALIC_COLUMN, - NUM_COLUMNS -}; - -gboolean -read_line (FILE *stream, GString *str) -{ - int n_read = 0; - - flockfile (stream); - - g_string_truncate (str, 0); - - while (1) - { - int c; - - c = getc_unlocked (stream); - - if (c == EOF) - goto done; - else - n_read++; - - switch (c) - { - case '\r': - case '\n': - { - int next_c = getc_unlocked (stream); - - if (!(next_c == EOF || - (c == '\r' && next_c == '\n') || - (c == '\n' && next_c == '\r'))) - ungetc (next_c, stream); - - goto done; - } - default: - g_string_append_c (str, c); - } - } - - done: - - funlockfile (stream); - - return n_read > 0; -} - -void -load_file (const gchar *filename) -{ - FILE *file; - GtkTextIter start, end; - GString *buffer = g_string_new (NULL); - int state = 0; - gboolean in_para = 0; - - if (current_file && !strcmp (current_file, filename)) - return; - - g_free (current_file); - current_file = g_strdup (filename); - - gtk_text_buffer_get_bounds (info_buffer, &start, &end); - gtk_text_buffer_delete (info_buffer, &start, &end); - - gtk_text_buffer_get_bounds (source_buffer, &start, &end); - gtk_text_buffer_delete (source_buffer, &start, &end); - - file = fopen (filename, "r"); - if (!file) - { - g_warning ("Cannot open %s: %s\n", filename, g_strerror (errno)); - return; - } - - gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0); - while (read_line (file, buffer)) - { - gchar *p = buffer->str; - gchar *q; - - switch (state) - { - case 0: - /* Reading title */ - while (*p == '/' || *p == '*' || isspace (*p)) - p++; - q = p + strlen (p); - while (q > p && isspace (*(q - 1))) - q--; - - if (q > p) - { - int len_chars = g_utf8_pointer_to_offset (p, q); - - end = start; - - g_assert (strlen (p) >= q - p); - gtk_text_buffer_insert (info_buffer, &end, p, q - p); - start = end; - - gtk_text_iter_backward_chars (&start, len_chars); - gtk_text_buffer_apply_tag_by_name (info_buffer, "title", &start, &end); - - start = end; - - state++; - } - break; - - case 1: - /* Reading body of info section */ - while (isspace (*p)) - p++; - if (*p == '*' && *(p + 1) == '/') - { - gtk_text_buffer_get_iter_at_offset (source_buffer, &start, 0); - state++; - } - else - { - int len; - - while (*p == '*' || isspace (*p)) - p++; - - len = strlen (p); - while (isspace (*(p + len - 1))) - len--; - - if (len > 0) - { - if (in_para) - gtk_text_buffer_insert (info_buffer, &start, " ", 1); - - g_assert (strlen (p) >= len); - gtk_text_buffer_insert (info_buffer, &start, p, len); - in_para = 1; - } - else - { - gtk_text_buffer_insert (info_buffer, &start, "\n", 1); - in_para = 0; - } - } - break; - - case 2: - /* Skipping blank lines */ - while (isspace (*p)) - p++; - if (*p) - { - p = buffer->str; - state++; - /* Fall through */ - } - else - break; - - case 3: - /* Reading program body */ - gtk_text_buffer_insert (source_buffer, &start, p, -1); - gtk_text_buffer_insert (info_buffer, &start, "\n", 1); - break; - } - } - - gtk_text_buffer_get_bounds (source_buffer, &start, &end); - gtk_text_buffer_apply_tag_by_name (info_buffer, "source", &start, &end); -} - -gboolean -button_press_event_cb (GtkTreeView *tree_view, - GdkEventButton *event, - GtkTreeModel *model) -{ - if (event->type == GDK_2BUTTON_PRESS) - { - GtkTreePath *path = NULL; - - gtk_tree_view_get_path_at_pos (tree_view, - event->window, - event->x, - event->y, - &path, - NULL); - - if (path) - { - GtkTreeIter iter; - gboolean italic; - GVoidFunc func; - - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_store_get (GTK_TREE_STORE (model), - &iter, - FUNC_COLUMN, &func, - ITALIC_COLUMN, &italic, - -1); - (func) (); - gtk_tree_store_set (GTK_TREE_STORE (model), - &iter, - ITALIC_COLUMN, !italic, - -1); - gtk_tree_path_free (path); - } - - gtk_signal_emit_stop_by_name (GTK_OBJECT (tree_view), - "button_press_event"); - return TRUE; - } - - return FALSE; -} - -static void -selection_cb (GtkTreeSelection *selection, - GtkTreeModel *model) -{ - GtkTreeIter iter; - GValue value = {0, }; - - if (! gtk_tree_selection_get_selected (selection, NULL, &iter)) - return; - - gtk_tree_model_get_value (model, &iter, - FILENAME_COLUMN, - &value); - load_file (g_value_get_string (&value)); - g_value_unset (&value); -} - -static GtkWidget * -create_text (GtkTextBuffer **buffer, - gboolean is_source) -{ - GtkWidget *scrolled_window; - GtkWidget *text_view; - PangoFontDescription *font_desc; - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_SHADOW_IN); - - text_view = gtk_text_view_new (); - gtk_container_add (GTK_CONTAINER (scrolled_window), text_view); - - *buffer = gtk_text_buffer_new (NULL); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), *buffer); - gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE); - - if (is_source) - { - font_desc = pango_font_description_from_string ("Courier 10"); - gtk_widget_modify_font (text_view, font_desc); - pango_font_description_free (font_desc); - } - - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), !is_source); - - return scrolled_window; -} - -/* Technically a list, but if we do go to 80 demos, we may want to move to a tree */ -static GtkWidget * -create_tree (void) -{ - GtkTreeSelection *selection; - GtkCellRenderer *cell; - GtkWidget *tree_view; - GtkTreeViewColumn *column; - GtkTreeStore *model; - GtkTreeIter iter; - gint i; - - model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN); - tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - - gtk_tree_selection_set_type (GTK_TREE_SELECTION (selection), - GTK_TREE_SELECTION_SINGLE); - gtk_widget_set_usize (tree_view, 200, -1); - - for (i=0; i < G_N_ELEMENTS (testgtk_demos); i++) - { - gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL); - - gtk_tree_store_set (GTK_TREE_STORE (model), - &iter, - TITLE_COLUMN, testgtk_demos[i].title, - FILENAME_COLUMN, testgtk_demos[i].filename, - FUNC_COLUMN, testgtk_demos[i].func, - ITALIC_COLUMN, FALSE, - -1); - } - - cell = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes ("Widget", - cell, - "text", TITLE_COLUMN, - "italic", ITALIC_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), - GTK_TREE_VIEW_COLUMN (column)); - - gtk_signal_connect (GTK_OBJECT (selection), "selection_changed", selection_cb, model); - gtk_signal_connect (GTK_OBJECT (tree_view), "button_press_event", GTK_SIGNAL_FUNC (button_press_event_cb), model); - - return tree_view; -} - -int -main (int argc, char **argv) -{ - GtkWidget *window; - GtkWidget *notebook; - GtkWidget *hbox; - GtkWidget *tree; - GtkTextTag *tag; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_main_quit), NULL); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), hbox); - - tree = create_tree (); - gtk_box_pack_start (GTK_BOX (hbox), tree, FALSE, FALSE, 0); - - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (hbox), notebook, TRUE, TRUE, 0); - - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), - create_text (&info_buffer, FALSE), - gtk_label_new ("Info")); - - - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), - create_text (&source_buffer, TRUE), - gtk_label_new ("Source")); - - tag = gtk_text_buffer_create_tag (info_buffer, "title"); - gtk_object_set (GTK_OBJECT (tag), - "font", "Sans 18", - NULL); - - tag = gtk_text_buffer_create_tag (info_buffer, "source"); - gtk_object_set (GTK_OBJECT (tag), - "font", "Courier 10", - "pixels_above_lines", 0, - "pixels_below_lines", 0, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (window), 600, 400); - gtk_widget_show_all (window); - - - load_file (testgtk_demos[0].filename); - - gtk_main (); - - return 0; -} diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index f6b857b6b7..7842fdf2b8 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -1362,8 +1362,8 @@ gdk_drag_find_window_for_screen (GdkDragContext *context, { find_window_enum_arg a; - a.x = x_root; - a.y = y_root; + a.x = x_root - _gdk_offset_x; + a.y = y_root - _gdk_offset_y; a.ignore = drag_window ? GDK_WINDOW_HWND (drag_window) : NULL; a.result = NULL; diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c deleted file mode 100644 index 8aaae61590..0000000000 --- a/gtk/gtkiconview.c +++ /dev/null @@ -1,2484 +0,0 @@ -/* eggiconlist.h - * Copyright (C) 2002 Anders Carlsson - * - * 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. - */ - -#include "eggiconlist.h" - -#include -#include -#include -#include -#include -#include - -#include "eggintl.h" -#include "eggmarshalers.h" - - -#define MINIMUM_ICON_ITEM_WIDTH 100 -#define ICON_TEXT_PADDING 3 - -#define ICON_LIST_ITEM_DATA "egg-icon-list-item-data" - -struct _EggIconListItem -{ - gint ref_count; - - EggIconList *icon_list; - char *label; - GdkPixbuf *icon; - - GList *list; - - gpointer user_data; - GDestroyNotify destroy_notify; - - /* Bounding boxes */ - gint x, y; - gint width, height; - - gint pixbuf_x, pixbuf_y; - gint pixbuf_height, pixbuf_width; - - gint layout_x, layout_y; - gint layout_width, layout_height; - - guint selected : 1; - guint selected_before_rubberbanding : 1; -}; - -struct _EggIconListPrivate -{ - gint width, height; - - GtkSelectionMode selection_mode; - - GdkWindow *bin_window; - - GList *items; - GList *last_item; - gint item_count; - - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; - - guint layout_idle_id; - - gboolean rubberbanding; - gint rubberband_x1, rubberband_y1; - gint rubberband_x2, rubberband_y2; - - EggIconListItem *cursor_item; - - char *typeahead_string; - - /* Sorting */ - gboolean sorted; - GtkSortType sort_order; - - EggIconListItemCompareFunc sort_func; - gpointer sort_data; - GDestroyNotify sort_destroy_notify; - - EggIconListItem *last_single_clicked; - - /* Drag-and-drop. */ - gint pressed_button; - gint press_start_x; - gint press_start_y; - - /* Layout used to draw icon text */ - PangoLayout *layout; -}; - -/* Signals */ -enum -{ - ITEM_ACTIVATED, - ITEM_ADDED, - ITEM_REMOVED, - SELECTION_CHANGED, - SELECT_ALL, - UNSELECT_ALL, - SELECT_CURSOR_ITEM, - TOGGLE_CURSOR_ITEM, - MOVE_CURSOR, - LAST_SIGNAL -}; - -/* Properties */ -enum -{ - PROP_0, - PROP_SELECTION_MODE, - PROP_SORTED, - PROP_SORT_ORDER, -}; - -/* Icon List Item properties */ -enum -{ - PROP_ITEM_0, - PROP_LABEL, -}; - -static void egg_icon_list_class_init (EggIconListClass *klass); -static void egg_icon_list_init (EggIconList *icon_list); - -/* GObject signals */ -static void egg_icon_list_finalize (GObject *object); -static void egg_icon_list_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void egg_icon_list_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - - -/* GtkWidget signals */ -static void egg_icon_list_realize (GtkWidget *widget); -static void egg_icon_list_unrealize (GtkWidget *widget); -static void egg_icon_list_map (GtkWidget *widget); -static void egg_icon_list_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void egg_icon_list_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean egg_icon_list_expose (GtkWidget *widget, - GdkEventExpose *expose); -static gboolean egg_icon_list_motion (GtkWidget *widget, - GdkEventMotion *event); -static gboolean egg_icon_list_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean egg_icon_list_button_release (GtkWidget *widget, - GdkEventButton *event); -static gboolean egg_icon_list_key_press (GtkWidget *widget, - GdkEventKey *event); - - -/* EggIconList signals */ -static void egg_icon_list_set_adjustments (EggIconList *icon_list, - GtkAdjustment *hadj, - GtkAdjustment *vadj); -static void egg_icon_list_real_select_all (EggIconList *icon_list); -static void egg_icon_list_real_unselect_all (EggIconList *icon_list); -static void egg_icon_list_real_select_cursor_item (EggIconList *icon_list); -static void egg_icon_list_real_toggle_cursor_item (EggIconList *icon_list); - -/* Internal functions */ -static void egg_icon_list_adjustment_changed (GtkAdjustment *adjustment, - EggIconList *icon_list); -static void egg_icon_list_layout (EggIconList *icon_list); -static void egg_icon_list_paint_item (EggIconList *icon_list, - EggIconListItem *item, - GdkRectangle *area); -static void egg_icon_list_paint_rubberband (EggIconList *icon_list, - GdkRectangle *area); -static void egg_icon_list_queue_draw_item (EggIconList *icon_list, - EggIconListItem *item); -static void egg_icon_list_queue_layout (EggIconList *icon_list); -static void egg_icon_list_set_cursor_item (EggIconList *icon_list, - EggIconListItem *item); -static void egg_icon_list_append_typeahead_string (EggIconList *icon_list, - const gchar *string); -static void egg_icon_list_select_first_matching_item (EggIconList *icon_list, - const char *pattern); -static void egg_icon_list_start_rubberbanding (EggIconList *icon_list, - gint x, - gint y); -static void egg_icon_list_stop_rubberbanding (EggIconList *icon_list); -static void egg_icon_list_sort (EggIconList *icon_list); -static gint egg_icon_list_sort_func (EggIconListItem *a, - EggIconListItem *b, - EggIconList *icon_list); -static void egg_icon_list_insert_item_sorted (EggIconList *icon_list, - EggIconListItem *item); -static void egg_icon_list_validate (EggIconList *icon_list); -static void egg_icon_list_update_rubberband_selection (EggIconList *icon_list); -static gboolean egg_icon_list_item_hit_test (EggIconListItem *item, - gint x, - gint y, - gint width, - gint height); -static gboolean egg_icon_list_maybe_begin_dragging_items (EggIconList *icon_list, - GdkEventMotion *event); -static gboolean egg_icon_list_unselect_all_internal (EggIconList *icon_list, - gboolean emit); -static void egg_icon_list_calculate_item_size (EggIconList *icon_list, EggIconListItem *item); -static void rubberbanding (gpointer data); - - -static void egg_icon_list_item_invalidate_size (EggIconListItem *item); - -static GtkContainerClass *parent_class = NULL; -static guint icon_list_signals[LAST_SIGNAL] = { 0 }; - -GType -egg_icon_list_item_get_type (void) -{ - static GType boxed_type = 0; - - if (!boxed_type) - boxed_type = g_boxed_type_register_static ("EggIconListItem", - (GBoxedCopyFunc) egg_icon_list_item_ref, - (GBoxedFreeFunc) egg_icon_list_item_unref); - - return boxed_type; -} - -GType -egg_icon_list_get_type (void) -{ - static GType object_type = 0; - - if (!object_type) - { - static const GTypeInfo object_info = - { - sizeof (EggIconListClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) egg_icon_list_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EggIconList), - 0, /* n_preallocs */ - (GInstanceInitFunc) egg_icon_list_init - }; - - object_type = g_type_register_static (GTK_TYPE_CONTAINER, "EggIconList", &object_info, 0); - } - - return object_type; -} - -static void -egg_icon_list_class_init (EggIconListClass *klass) -{ - GObjectClass *gobject_class; - GtkWidgetClass *widget_class; - GtkBindingSet *binding_set; - - parent_class = g_type_class_peek_parent (klass); - binding_set = gtk_binding_set_by_class (klass); - - gobject_class = (GObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - gobject_class->finalize = egg_icon_list_finalize; - gobject_class->set_property = egg_icon_list_set_property; - gobject_class->get_property = egg_icon_list_get_property; - - widget_class->realize = egg_icon_list_realize; - widget_class->unrealize = egg_icon_list_unrealize; - widget_class->map = egg_icon_list_map; - widget_class->size_request = egg_icon_list_size_request; - widget_class->size_allocate = egg_icon_list_size_allocate; - widget_class->expose_event = egg_icon_list_expose; - widget_class->motion_notify_event = egg_icon_list_motion; - widget_class->button_press_event = egg_icon_list_button_press; - widget_class->button_release_event = egg_icon_list_button_release; - widget_class->key_press_event = egg_icon_list_key_press; - - klass->set_scroll_adjustments = egg_icon_list_set_adjustments; - klass->select_all = egg_icon_list_real_select_all; - klass->unselect_all = egg_icon_list_real_unselect_all; - klass->select_cursor_item = egg_icon_list_real_select_cursor_item; - klass->toggle_cursor_item = egg_icon_list_real_toggle_cursor_item; - - /* Properties */ - g_object_class_install_property (gobject_class, - PROP_SELECTION_MODE, - g_param_spec_enum ("selection_mode", - _("Selection mode"), - _("The selection mode"), - GTK_TYPE_SELECTION_MODE, - GTK_SELECTION_SINGLE, - G_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_SORTED, - g_param_spec_boolean ("sorted", - _("Sorted"), - _("Icon list is sorted"), - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (gobject_class, - PROP_SORT_ORDER, - g_param_spec_enum ("sort_order", - _("Sort order"), - _("Sort direction the icon list should use"), - GTK_TYPE_SORT_TYPE, - GTK_SORT_ASCENDING, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - - /* Style properties */ -#define _ICON_LIST_TOP_MARGIN 6 -#define _ICON_LIST_BOTTOM_MARGIN 6 -#define _ICON_LIST_LEFT_MARGIN 6 -#define _ICON_LIST_RIGHT_MARGIN 6 -#define _ICON_LIST_ICON_PADDING 6 - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("icon_padding", - _("Icon padding"), - _("Number of pixels between icons"), - 0, - G_MAXINT, - _ICON_LIST_ICON_PADDING, - G_PARAM_READABLE)); - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("top_margin", - _("Top margin"), - _("Number of pixels in top margin"), - 0, - G_MAXINT, - _ICON_LIST_TOP_MARGIN, - G_PARAM_READABLE)); - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("bottom_margin", - _("Bottom margin"), - _("Number of pixels in bottom margin"), - 0, - G_MAXINT, - _ICON_LIST_BOTTOM_MARGIN, - G_PARAM_READABLE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("left_margin", - _("Left margin"), - _("Number of pixels in left margin"), - 0, - G_MAXINT, - _ICON_LIST_LEFT_MARGIN, - G_PARAM_READABLE)); - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("right_margin", - _("Right margin"), - _("Number of pixels in right margin"), - 0, - G_MAXINT, - _ICON_LIST_RIGHT_MARGIN, - G_PARAM_READABLE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boxed ("selection_box_color", - _("Selection Box Color"), - _("Color of the selection box"), - GDK_TYPE_COLOR, - G_PARAM_READABLE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_uchar ("selection_box_alpha", - _("Selection Box Alpha"), - _("Opacity of the selection box"), - 0, 0xff, - 0x40, - G_PARAM_READABLE)); - - /* Signals */ - widget_class->set_scroll_adjustments_signal = - g_signal_new ("set_scroll_adjustments", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggIconListClass, set_scroll_adjustments), - NULL, NULL, - _egg_marshal_VOID__OBJECT_OBJECT, - G_TYPE_NONE, 2, - GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); - - icon_list_signals[ITEM_ACTIVATED] = - g_signal_new ("item_activated", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggIconListClass, item_activated), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - EGG_TYPE_ICON_LIST_ITEM); - - icon_list_signals[SELECTION_CHANGED] = - g_signal_new ("selection_changed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EggIconListClass, selection_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - icon_list_signals[ITEM_ADDED] = - g_signal_new ("item_added", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggIconListClass, item_added), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, EGG_TYPE_ICON_LIST_ITEM); - - icon_list_signals[ITEM_REMOVED] = - g_signal_new ("item_removed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggIconListClass, item_removed), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, EGG_TYPE_ICON_LIST_ITEM); - - icon_list_signals[SELECT_ALL] = - g_signal_new ("select_all", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EggIconListClass, select_all), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - icon_list_signals[UNSELECT_ALL] = - g_signal_new ("unselect_all", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EggIconListClass, unselect_all), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - icon_list_signals[SELECT_CURSOR_ITEM] = - g_signal_new ("select_cursor_item", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EggIconListClass, select_cursor_item), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - icon_list_signals[SELECT_CURSOR_ITEM] = - g_signal_new ("toggle_cursor_item", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EggIconListClass, toggle_cursor_item), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* Key bindings */ - gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, "select_all", 0); - gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect_all", 0); - gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "select_cursor_item", 0); - gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_cursor_item", 0); -} - - -static void -egg_icon_list_init (EggIconList *icon_list) -{ - icon_list->priv = g_new0 (EggIconListPrivate, 1); - GTK_WIDGET_SET_FLAGS (icon_list, GTK_CAN_FOCUS); - - icon_list->priv->width = 0; - icon_list->priv->height = 0; - icon_list->priv->selection_mode = GTK_SELECTION_SINGLE; - icon_list->priv->sort_order = GTK_SORT_ASCENDING; - icon_list->priv->pressed_button = -1; - icon_list->priv->press_start_x = -1; - icon_list->priv->press_start_y = -1; - icon_list->priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (icon_list), NULL); - pango_layout_set_wrap (icon_list->priv->layout, PANGO_WRAP_CHAR); - - egg_icon_list_set_adjustments (icon_list, NULL, NULL); -} - - -/* GObject methods */ -static void -egg_icon_list_finalize (GObject *object) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (object); - - if (icon_list->priv->layout_idle_id != 0) - g_source_remove (icon_list->priv->layout_idle_id); - - g_free (icon_list->priv); - - (G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -egg_icon_list_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (object); - - switch (prop_id) - { - case PROP_SELECTION_MODE: - egg_icon_list_set_selection_mode (icon_list, g_value_get_enum (value)); - break; - case PROP_SORTED: - egg_icon_list_set_sorted (icon_list, g_value_get_boolean (value)); - break; - case PROP_SORT_ORDER: - egg_icon_list_set_sort_order (icon_list, g_value_get_enum (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -egg_icon_list_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (object); - - switch (prop_id) - { - case PROP_SELECTION_MODE: - g_value_set_enum (value, icon_list->priv->selection_mode); - break; - case PROP_SORTED: - g_value_set_boolean (value, icon_list->priv->sorted); - break; - case PROP_SORT_ORDER: - g_value_set_enum (value, icon_list->priv->sort_order); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* GtkWidget signals */ -static void -egg_icon_list_realize (GtkWidget *widget) -{ - EggIconList *icon_list; - GdkWindowAttr attributes; - gint attributes_mask; - - icon_list = EGG_ICON_LIST (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - /* Make the main, clipping window */ - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - /* Make the window for the icon list */ - attributes.x = 0; - attributes.y = 0; - attributes.width = MAX (icon_list->priv->width, widget->allocation.width); - attributes.height = MAX (icon_list->priv->height, widget->allocation.height); - attributes.event_mask = (GDK_EXPOSURE_MASK | - GDK_SCROLL_MASK | - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK) | - gtk_widget_get_events (widget); - - icon_list->priv->bin_window = gdk_window_new (widget->window, - &attributes, attributes_mask); - gdk_window_set_user_data (icon_list->priv->bin_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gdk_window_set_background (icon_list->priv->bin_window, &widget->style->base[widget->state]); - gdk_window_set_background (widget->window, &widget->style->base[widget->state]); - - -} - -static void -egg_icon_list_unrealize (GtkWidget *widget) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (widget); - - gdk_window_set_user_data (icon_list->priv->bin_window, NULL); - gdk_window_destroy (icon_list->priv->bin_window); - icon_list->priv->bin_window = NULL; - - /* GtkWidget::unrealize destroys children and widget->window */ - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); -} - -static void -egg_icon_list_map (GtkWidget *widget) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); - - gdk_window_show (icon_list->priv->bin_window); - gdk_window_show (widget->window); -} - -static void -egg_icon_list_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (widget); - - requisition->width = icon_list->priv->width; - requisition->height = icon_list->priv->height; -} - -static void -egg_icon_list_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - EggIconList *icon_list; - - widget->allocation = *allocation; - - icon_list = EGG_ICON_LIST (widget); - - if (GTK_WIDGET_REALIZED (widget)) - { - gdk_window_move_resize (widget->window, - allocation->x, allocation->y, - allocation->width, allocation->height); - gdk_window_resize (icon_list->priv->bin_window, - MAX (icon_list->priv->width, allocation->width), - MAX (icon_list->priv->height, allocation->height)); - } - - icon_list->priv->hadjustment->page_size = allocation->width; - icon_list->priv->hadjustment->page_increment = allocation->width * 0.9; - icon_list->priv->hadjustment->step_increment = allocation->width * 0.1; - icon_list->priv->hadjustment->lower = 0; - icon_list->priv->hadjustment->upper = MAX (allocation->width, icon_list->priv->width); - gtk_adjustment_changed (icon_list->priv->hadjustment); - - icon_list->priv->vadjustment->page_size = allocation->height; - icon_list->priv->vadjustment->page_increment = allocation->height * 0.9; - icon_list->priv->vadjustment->step_increment = allocation->width * 0.1; - icon_list->priv->vadjustment->lower = 0; - icon_list->priv->vadjustment->upper = MAX (allocation->height, icon_list->priv->height); - gtk_adjustment_changed (icon_list->priv->vadjustment); - - egg_icon_list_layout (icon_list); -} - -static gboolean -egg_icon_list_expose (GtkWidget *widget, - GdkEventExpose *expose) -{ - EggIconList *icon_list; - GList *icons; - - icon_list = EGG_ICON_LIST (widget); - - if (expose->window != icon_list->priv->bin_window) - return FALSE; - - for (icons = icon_list->priv->items; icons; icons = icons->next) { - EggIconListItem *item = icons->data; - GdkRectangle item_rectangle; - - item_rectangle.x = item->x; - item_rectangle.y = item->y; - item_rectangle.width = item->width; - item_rectangle.height = item->height; - - if (gdk_region_rect_in (expose->region, &item_rectangle) == GDK_OVERLAP_RECTANGLE_OUT) - continue; - - egg_icon_list_paint_item (icon_list, item, &expose->area); - } - - if (icon_list->priv->rubberbanding) - { - GdkRectangle *rectangles; - gint n_rectangles; - - gdk_region_get_rectangles (expose->region, - &rectangles, - &n_rectangles); - - while (n_rectangles--) - egg_icon_list_paint_rubberband (icon_list, &rectangles[n_rectangles]); - - g_free (rectangles); - } - - return TRUE; -} - -static gboolean -egg_icon_list_motion (GtkWidget *widget, - GdkEventMotion *event) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (widget); - - egg_icon_list_maybe_begin_dragging_items (icon_list, event); - - if (icon_list->priv->rubberbanding) - rubberbanding (widget); - - return TRUE; -} - -static gboolean -egg_icon_list_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - EggIconList *icon_list; - EggIconListItem *item; - gboolean dirty = FALSE; - - icon_list = EGG_ICON_LIST (widget); - - if (event->window != icon_list->priv->bin_window) - return FALSE; - - if (!GTK_WIDGET_HAS_FOCUS (widget)) - gtk_widget_grab_focus (widget); - - if (event->button == 1 && event->type == GDK_BUTTON_PRESS) - { - - if (icon_list->priv->selection_mode == GTK_SELECTION_NONE) - return TRUE; - - item = egg_icon_list_get_item_at_pos (icon_list, - event->x, event->y); - - if (item != NULL) - { - if (icon_list->priv->selection_mode == GTK_SELECTION_MULTIPLE && - (event->state & GDK_CONTROL_MASK)) - { - item->selected = !item->selected; - dirty = TRUE; - } - else - { - if (!item->selected) - { - egg_icon_list_unselect_all_internal (icon_list, FALSE); - - item->selected = TRUE; - dirty = TRUE; - } - } - - egg_icon_list_set_cursor_item (icon_list, item); - egg_icon_list_queue_draw_item (icon_list, item); - - /* Save press to possibly begin a drag */ - if (icon_list->priv->pressed_button < 0) - { - icon_list->priv->pressed_button = event->button; - icon_list->priv->press_start_x = event->x; - icon_list->priv->press_start_y = event->y; - } - - if (!icon_list->priv->last_single_clicked) - icon_list->priv->last_single_clicked = item; - } - else - { - if (icon_list->priv->selection_mode != GTK_SELECTION_BROWSE && - !(event->state & GDK_CONTROL_MASK)) - { - dirty = egg_icon_list_unselect_all_internal (icon_list, FALSE); - } - - if (icon_list->priv->selection_mode == GTK_SELECTION_MULTIPLE) - egg_icon_list_start_rubberbanding (icon_list, event->x, event->y); - } - - } - - if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) - { - item = egg_icon_list_get_item_at_pos (icon_list, - event->x, event->y); - - if (item && item == icon_list->priv->last_single_clicked) - { - egg_icon_list_item_activated (icon_list, item); - } - - icon_list->priv->last_single_clicked = NULL; - } - - if (dirty) - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); - - return TRUE; -} - -static gboolean -egg_icon_list_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (widget); - - if (icon_list->priv->pressed_button == event->button) - icon_list->priv->pressed_button = -1; - - egg_icon_list_stop_rubberbanding (icon_list); - - return TRUE; -} - - -static gboolean -egg_icon_list_key_press (GtkWidget *widget, - GdkEventKey *event) -{ - if ((* GTK_WIDGET_CLASS (parent_class)->key_press_event) (widget, event)) - return TRUE; - - return FALSE; - - if ((event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0) - egg_icon_list_append_typeahead_string (EGG_ICON_LIST (widget), event->string); - - return TRUE; -} - -static void -egg_icon_list_select_first_matching_item (EggIconList *icon_list, - const char *pattern) -{ - GList *items; - - if (pattern == NULL) - return; - - for (items = icon_list->priv->items; items; items = items->next) - { - EggIconListItem *item = items->data; - - if (strncmp (pattern, item->label, strlen (pattern)) == 0) - { - egg_icon_list_select_item (icon_list, item); - break; - } - } -} - -static void -rubberbanding (gpointer data) -{ - EggIconList *icon_list; - gint x, y; - GdkRectangle old_area; - GdkRectangle new_area; - GdkRectangle common; - GdkRegion *invalid_region; - - icon_list = EGG_ICON_LIST (data); - - gdk_window_get_pointer (icon_list->priv->bin_window, &x, &y, NULL); - - x = MAX (x, 0); - y = MAX (y, 0); - - old_area.x = MIN (icon_list->priv->rubberband_x1, - icon_list->priv->rubberband_x2); - old_area.y = MIN (icon_list->priv->rubberband_y1, - icon_list->priv->rubberband_y2); - old_area.width = ABS (icon_list->priv->rubberband_x2 - - icon_list->priv->rubberband_x1) + 1; - old_area.height = ABS (icon_list->priv->rubberband_y2 - - icon_list->priv->rubberband_y1) + 1; - - new_area.x = MIN (icon_list->priv->rubberband_x1, x); - new_area.y = MIN (icon_list->priv->rubberband_y1, y); - new_area.width = ABS (x - icon_list->priv->rubberband_x1) + 1; - new_area.height = ABS (y - icon_list->priv->rubberband_y1) + 1; - - invalid_region = gdk_region_rectangle (&old_area); - gdk_region_union_with_rect (invalid_region, &new_area); - - gdk_rectangle_intersect (&old_area, &new_area, &common); - if (common.width > 2 && common.height > 2) - { - GdkRegion *common_region; - - /* make sure the border is invalidated */ - common.x += 1; - common.y += 1; - common.width -= 2; - common.height -= 2; - - common_region = gdk_region_rectangle (&common); - - gdk_region_subtract (invalid_region, common_region); - gdk_region_destroy (common_region); - } - - gdk_window_invalidate_region (icon_list->priv->bin_window, invalid_region, TRUE); - - gdk_region_destroy (invalid_region); - - icon_list->priv->rubberband_x2 = x; - icon_list->priv->rubberband_y2 = y; - - egg_icon_list_update_rubberband_selection (icon_list); -} - -static void -egg_icon_list_start_rubberbanding (EggIconList *icon_list, - gint x, - gint y) -{ - GList *items; - - g_assert (!icon_list->priv->rubberbanding); - - for (items = icon_list->priv->items; items; items = items->next) - { - EggIconListItem *item = items->data; - - item->selected_before_rubberbanding = item->selected; - } - - icon_list->priv->rubberband_x1 = x; - icon_list->priv->rubberband_y1 = y; - icon_list->priv->rubberband_x2 = x; - icon_list->priv->rubberband_y2 = y; - - icon_list->priv->rubberbanding = TRUE; - - gtk_grab_add (GTK_WIDGET (icon_list)); -} - -static void -egg_icon_list_stop_rubberbanding (EggIconList *icon_list) -{ - if (!icon_list->priv->rubberbanding) - return; - - icon_list->priv->rubberbanding = FALSE; - - gtk_grab_remove (GTK_WIDGET (icon_list)); - - gtk_widget_queue_draw (GTK_WIDGET (icon_list)); -} - -static gint -egg_icon_list_sort_func (EggIconListItem *a, - EggIconListItem *b, - EggIconList *icon_list) -{ - gint result; - - result = (* icon_list->priv->sort_func) (icon_list, a, b, - icon_list->priv->sort_data); - - if (icon_list->priv->sort_order == GTK_SORT_DESCENDING) - result = -result; - - return result; -} - -static void -egg_icon_list_insert_item_sorted (EggIconList *icon_list, - EggIconListItem *item) -{ - GList *list; - GList *tmp_list = icon_list->priv->items; - gint cmp; - - egg_icon_list_validate (icon_list); - - list = g_list_alloc (); - item->list = list; - item->icon_list = icon_list; - list->data = item; - egg_icon_list_item_ref (item); - - if (!icon_list->priv->items) - { - icon_list->priv->items = list; - icon_list->priv->last_item = list; - icon_list->priv->item_count += 1; - - egg_icon_list_validate (icon_list); - - return; - } - - cmp = egg_icon_list_sort_func (item, tmp_list->data, icon_list); - - while ((tmp_list->next) && (cmp > 0)) - { - tmp_list = tmp_list->next; - cmp = egg_icon_list_sort_func (item, tmp_list->data, icon_list); - } - - if ((!tmp_list->next) && (cmp > 0)) - { - tmp_list->next = list; - list->prev = tmp_list; - icon_list->priv->last_item = list; - icon_list->priv->item_count += 1; - egg_icon_list_validate (icon_list); - - return; - } - - if (tmp_list->prev) - { - tmp_list->prev->next = list; - list->prev = tmp_list->prev; - } - - list->next = tmp_list; - tmp_list->prev = list; - - if (tmp_list == icon_list->priv->items) - icon_list->priv->items = list; - - icon_list->priv->item_count += 1; - egg_icon_list_validate (icon_list); - - egg_icon_list_queue_layout (icon_list); -} - - -static void -egg_icon_list_sort (EggIconList *icon_list) -{ - egg_icon_list_validate (icon_list); - - /* FIXME: We can optimize this */ - icon_list->priv->items = g_list_sort_with_data (icon_list->priv->items, - (GCompareDataFunc)egg_icon_list_sort_func, - icon_list); - icon_list->priv->last_item = g_list_last (icon_list->priv->items); - - egg_icon_list_validate (icon_list); - egg_icon_list_queue_layout (icon_list); -} - - -static void -egg_icon_list_validate (EggIconList *icon_list) -{ -#if 0 - GList *list; - - g_print ("----\n"); - for (list = icon_list->priv->items; list; list = list->next) - { - EggIconListItem *item = list->data; - - g_print ("%s\n", egg_icon_list_item_get_label (item)); - } - g_print ("----\n"); -#endif - - g_assert (g_list_length (icon_list->priv->items) == icon_list->priv->item_count); - g_assert (g_list_last (icon_list->priv->items) == icon_list->priv->last_item); - g_assert (g_list_first (icon_list->priv->last_item) == icon_list->priv->items); -} - -static void -egg_icon_list_update_rubberband_selection (EggIconList *icon_list) -{ - GList *items; - gint x, y, width, height; - gboolean dirty = FALSE; - - x = MIN (icon_list->priv->rubberband_x1, - icon_list->priv->rubberband_x2); - y = MIN (icon_list->priv->rubberband_y1, - icon_list->priv->rubberband_y2); - width = ABS (icon_list->priv->rubberband_x1 - - icon_list->priv->rubberband_x2); - height = ABS (icon_list->priv->rubberband_y1 - - icon_list->priv->rubberband_y2); - - for (items = icon_list->priv->items; items; items = items->next) - { - EggIconListItem *item = items->data; - gboolean is_in; - gboolean selected; - - is_in = egg_icon_list_item_hit_test (item, x, y, width, height); - - selected = is_in ^ item->selected_before_rubberbanding; - - if (item->selected != selected) - { - item->selected = selected; - dirty = TRUE; - egg_icon_list_queue_draw_item (icon_list, item); - } - } - - if (dirty) - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); -} - -static gboolean -egg_icon_list_item_hit_test (EggIconListItem *item, - gint x, - gint y, - gint width, - gint height) -{ - /* First try the pixbuf */ - if (MIN (x + width, item->pixbuf_x + item->pixbuf_width) - MAX (x, item->pixbuf_x) > 0 && - MIN (y + height, item->pixbuf_y + item->pixbuf_height) - MAX (y, item->pixbuf_y) > 0) - return TRUE; - - /* Then try the text */ - if (MIN (x + width, item->layout_x + item->layout_width) - MAX (x, item->layout_x) > 0 && - MIN (y + height, item->layout_y + item->layout_height) - MAX (y, item->layout_y) > 0) - return TRUE; - - return FALSE; -} - -static gboolean -egg_icon_list_maybe_begin_dragging_items (EggIconList *icon_list, - GdkEventMotion *event) -{ - gboolean retval = FALSE; - gint button; - if (icon_list->priv->pressed_button < 0) - return retval; - - if (!gtk_drag_check_threshold (GTK_WIDGET (icon_list), - icon_list->priv->press_start_x, - icon_list->priv->press_start_y, - event->x, event->y)) - return retval; - - button = icon_list->priv->pressed_button; - icon_list->priv->pressed_button = -1; - - { - static GtkTargetEntry row_targets[] = { - { "EGG_ICON_LIST_ITEMS", GTK_TARGET_SAME_APP, 0 } - }; - GtkTargetList *target_list; - GdkDragContext *context; - EggIconListItem *item; - - retval = TRUE; - - target_list = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets)); - - context = gtk_drag_begin (GTK_WIDGET (icon_list), - target_list, GDK_ACTION_MOVE, - button, - (GdkEvent *)event); - - item = egg_icon_list_get_item_at_pos (icon_list, - icon_list->priv->press_start_x, - icon_list->priv->press_start_y); - g_assert (item != NULL); - gtk_drag_set_icon_pixbuf (context, egg_icon_list_item_get_icon (item), - event->x - item->x, - event->y - item->y); - } - - return retval; -} - - -static gboolean -egg_icon_list_unselect_all_internal (EggIconList *icon_list, - gboolean emit) -{ - gboolean dirty = FALSE; - GList *items; - - for (items = icon_list->priv->items; items; items = items->next) - { - EggIconListItem *item = items->data; - - if (item->selected) - { - item->selected = FALSE; - dirty = TRUE; - egg_icon_list_queue_draw_item (icon_list, item); - } - } - - if (emit && dirty) - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); - - return dirty; -} - - -/* EggIconList signals */ -static void -egg_icon_list_set_adjustments (EggIconList *icon_list, - GtkAdjustment *hadj, - GtkAdjustment *vadj) -{ - gboolean need_adjust = FALSE; - - if (hadj) - g_return_if_fail (GTK_IS_ADJUSTMENT (hadj)); - else - hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - if (vadj) - g_return_if_fail (GTK_IS_ADJUSTMENT (vadj)); - else - vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - - if (icon_list->priv->hadjustment && (icon_list->priv->hadjustment != hadj)) - { - g_signal_handlers_disconnect_matched (icon_list->priv->hadjustment, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, icon_list); - g_object_unref (icon_list->priv->hadjustment); - } - - if (icon_list->priv->vadjustment && (icon_list->priv->vadjustment != vadj)) - { - g_signal_handlers_disconnect_matched (icon_list->priv->vadjustment, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, icon_list); - g_object_unref (icon_list->priv->vadjustment); - } - - if (icon_list->priv->hadjustment != hadj) - { - icon_list->priv->hadjustment = hadj; - g_object_ref (icon_list->priv->hadjustment); - gtk_object_sink (GTK_OBJECT (icon_list->priv->hadjustment)); - - g_signal_connect (icon_list->priv->hadjustment, "value_changed", - G_CALLBACK (egg_icon_list_adjustment_changed), - icon_list); - need_adjust = TRUE; - } - - if (icon_list->priv->vadjustment != vadj) - { - icon_list->priv->vadjustment = vadj; - g_object_ref (icon_list->priv->vadjustment); - gtk_object_sink (GTK_OBJECT (icon_list->priv->vadjustment)); - - g_signal_connect (icon_list->priv->vadjustment, "value_changed", - G_CALLBACK (egg_icon_list_adjustment_changed), - icon_list); - need_adjust = TRUE; - } - - if (need_adjust) - egg_icon_list_adjustment_changed (NULL, icon_list); -} - -static void -egg_icon_list_real_select_all (EggIconList *icon_list) -{ - if (icon_list->priv->selection_mode != GTK_SELECTION_MULTIPLE) - return; - - egg_icon_list_select_all (icon_list); -} - -static void -egg_icon_list_real_unselect_all (EggIconList *icon_list) -{ - if (icon_list->priv->selection_mode == GTK_SELECTION_BROWSE) - return; - - egg_icon_list_unselect_all (icon_list); -} - -static void -egg_icon_list_real_select_cursor_item (EggIconList *icon_list) -{ - egg_icon_list_unselect_all (icon_list); - - if (icon_list->priv->cursor_item != NULL) - egg_icon_list_select_item (icon_list, icon_list->priv->cursor_item); -} - -static void -egg_icon_list_real_toggle_cursor_item (EggIconList *icon_list) -{ - if (icon_list->priv->selection_mode == GTK_SELECTION_NONE) - return; - - /* FIXME: Use another function here */ - if (icon_list->priv->cursor_item != NULL) - { - if (icon_list->priv->selection_mode == GTK_SELECTION_BROWSE) - icon_list->priv->cursor_item->selected = TRUE; - else - icon_list->priv->cursor_item->selected = !icon_list->priv->cursor_item->selected; - - egg_icon_list_queue_draw_item (icon_list, icon_list->priv->cursor_item); - } -} - -/* Internal functions */ -static void -egg_icon_list_adjustment_changed (GtkAdjustment *adjustment, - EggIconList *icon_list) -{ - if (GTK_WIDGET_REALIZED (icon_list)) - { - gdk_window_move (icon_list->priv->bin_window, - - icon_list->priv->hadjustment->value, - - icon_list->priv->vadjustment->value); - gdk_window_process_updates (icon_list->priv->bin_window, TRUE); - } -} - -static GList * -egg_icon_list_layout_single_row (EggIconList *icon_list, GList *first_item, gint *y, gint *maximum_width) -{ - gint x, current_width, max_height, max_pixbuf_height; - GList *items, *last_item; - gint icon_padding; - gint left_margin, right_margin; - gint maximum_layout_width; - - x = 0; - max_height = 0; - max_pixbuf_height = 0; - items = first_item; - current_width = 0; - - gtk_widget_style_get (GTK_WIDGET (icon_list), - "icon_padding", &icon_padding, - "left_margin", &left_margin, - "right_margin", &right_margin, - NULL); - - x += left_margin; - current_width += left_margin + right_margin; - items = first_item; - - while (items) - { - EggIconListItem *item = items->data; - - egg_icon_list_calculate_item_size (icon_list, item); - - current_width += MAX (item->width, MINIMUM_ICON_ITEM_WIDTH); - - /* Don't add padding to the first or last icon */ - - if (current_width > GTK_WIDGET (icon_list)->allocation.width && - items != first_item) - break; - - maximum_layout_width = MAX (item->pixbuf_width, MINIMUM_ICON_ITEM_WIDTH); - - item->y = *y; - item->x = x; - - if (item->width < MINIMUM_ICON_ITEM_WIDTH) { - item->x += (MINIMUM_ICON_ITEM_WIDTH - item->width) / 2; - x += (MINIMUM_ICON_ITEM_WIDTH - item->width); - } - - item->pixbuf_x = item->x + (item->width - item->pixbuf_width) / 2; - item->layout_x = item->x + (item->width - item->layout_width) / 2; - - x += item->width; - - max_height = MAX (max_height, item->height); - max_pixbuf_height = MAX (max_pixbuf_height, item->pixbuf_height); - - if (current_width > *maximum_width) - *maximum_width = current_width; - - items = items->next; - } - - last_item = items; - - *y += max_height + icon_padding; - - /* Now go through the row again and align the icons */ - for (items = first_item; items != last_item; items = items->next) - { - EggIconListItem *item = items->data; - - item->pixbuf_y = item->y + (max_pixbuf_height - item->pixbuf_height); - item->layout_y = item->pixbuf_y + item->pixbuf_height + ICON_TEXT_PADDING; - - /* Update the bounding box */ - item->y = item->pixbuf_y; - - /* We may want to readjust the new y coordinate. */ - if (item->y + item->height > *y) - *y = item->y + item->height; - } - - return last_item; -} - -static void -egg_icon_list_set_adjustment_upper (GtkAdjustment *adj, - gdouble upper) -{ - if (upper != adj->upper) - { - gdouble min = MAX (0.0, upper - adj->page_size); - gboolean value_changed = FALSE; - - adj->upper = upper; - - if (adj->value > min) - { - adj->value = min; - value_changed = TRUE; - } - - gtk_adjustment_changed (adj); - - if (value_changed) - gtk_adjustment_value_changed (adj); - } -} - -static void -egg_icon_list_layout (EggIconList *icon_list) -{ - gint y = 0, maximum_width = 0; - GList *icons; - GtkWidget *widget; - gint top_margin, bottom_margin; - - widget = GTK_WIDGET (icon_list); - icons = icon_list->priv->items; - - gtk_widget_style_get (widget, - "top_margin", &top_margin, - "bottom_margin", &bottom_margin, - NULL); - y += top_margin; - - do - { - icons = egg_icon_list_layout_single_row (icon_list, icons, &y, &maximum_width); - } - while (icons != NULL); - - if (maximum_width != icon_list->priv->width) - { - icon_list->priv->width = maximum_width; - } - y += bottom_margin; - - if (y != icon_list->priv->height) - { - icon_list->priv->height = y; - } - - egg_icon_list_set_adjustment_upper (icon_list->priv->hadjustment, icon_list->priv->width); - egg_icon_list_set_adjustment_upper (icon_list->priv->vadjustment, icon_list->priv->height); - - if (GTK_WIDGET_REALIZED (icon_list)) - { - gdk_window_resize (icon_list->priv->bin_window, - MAX (icon_list->priv->width, widget->allocation.width), - MAX (icon_list->priv->height, widget->allocation.height)); - } - - if (icon_list->priv->layout_idle_id != 0) - { - g_source_remove (icon_list->priv->layout_idle_id); - icon_list->priv->layout_idle_id = 0; - } - - gtk_widget_queue_draw (GTK_WIDGET (icon_list)); -} - -/* Creates or updates the pango layout and calculates the size */ -static void -egg_icon_list_calculate_item_size (EggIconList *icon_list, EggIconListItem *item) -{ - int layout_width, layout_height; - int maximum_layout_width; - - if (item->width != -1 && item->width != -1) - return; - - item->pixbuf_width = gdk_pixbuf_get_width (item->icon); - item->pixbuf_height = gdk_pixbuf_get_height (item->icon); - - maximum_layout_width = MAX (item->pixbuf_width, MINIMUM_ICON_ITEM_WIDTH); - - pango_layout_set_text (icon_list->priv->layout, item->label, -1); - - pango_layout_set_alignment (icon_list->priv->layout, PANGO_ALIGN_CENTER); - pango_layout_set_width (icon_list->priv->layout, maximum_layout_width * PANGO_SCALE); - - pango_layout_get_pixel_size (icon_list->priv->layout, &layout_width, &layout_height); - - item->width = MAX ((layout_width + 2 * ICON_TEXT_PADDING), item->pixbuf_width); - item->height = layout_height + 2 * ICON_TEXT_PADDING + item->pixbuf_height; - item->layout_width = layout_width; - item->layout_height = layout_height; -} - -static void -egg_icon_list_item_invalidate_size (EggIconListItem *item) -{ - item->width = -1; - item->height = -1; -} - -static GdkPixbuf * -create_colorized_pixbuf (GdkPixbuf *src, GdkColor *new_color) -{ - gint i, j; - gint width, height, has_alpha, src_row_stride, dst_row_stride; - gint red_value, green_value, blue_value; - guchar *target_pixels; - guchar *original_pixels; - guchar *pixsrc; - guchar *pixdest; - GdkPixbuf *dest; - - red_value = new_color->red / 255.0; - green_value = new_color->green / 255.0; - blue_value = new_color->blue / 255.0; - - dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), - gdk_pixbuf_get_has_alpha (src), - gdk_pixbuf_get_bits_per_sample (src), - gdk_pixbuf_get_width (src), - gdk_pixbuf_get_height (src)); - - has_alpha = gdk_pixbuf_get_has_alpha (src); - width = gdk_pixbuf_get_width (src); - height = gdk_pixbuf_get_height (src); - src_row_stride = gdk_pixbuf_get_rowstride (src); - dst_row_stride = gdk_pixbuf_get_rowstride (dest); - target_pixels = gdk_pixbuf_get_pixels (dest); - original_pixels = gdk_pixbuf_get_pixels (src); - - for (i = 0; i < height; i++) { - pixdest = target_pixels + i*dst_row_stride; - pixsrc = original_pixels + i*src_row_stride; - for (j = 0; j < width; j++) { - *pixdest++ = (*pixsrc++ * red_value) >> 8; - *pixdest++ = (*pixsrc++ * green_value) >> 8; - *pixdest++ = (*pixsrc++ * blue_value) >> 8; - if (has_alpha) { - *pixdest++ = *pixsrc++; - } - } - } - return dest; -} - -static void -egg_icon_list_paint_item (EggIconList *icon_list, - EggIconListItem *item, - GdkRectangle *area) -{ - GdkPixbuf *pixbuf; - GtkStateType state; - - if (GTK_WIDGET_HAS_FOCUS (icon_list)) - state = GTK_STATE_SELECTED; - else - state = GTK_STATE_ACTIVE; - - if (item->selected) - pixbuf = create_colorized_pixbuf (item->icon, - >K_WIDGET (icon_list)->style->base[state]); - else - pixbuf = g_object_ref (item->icon); - - gdk_draw_pixbuf (icon_list->priv->bin_window, NULL, pixbuf, - 0, 0, - item->pixbuf_x, item->pixbuf_y, - item->pixbuf_width, item->pixbuf_height, - GDK_RGB_DITHER_NORMAL, - item->pixbuf_width, item->pixbuf_height); - g_object_unref (pixbuf); - - if (item->selected) - { - gdk_draw_rectangle (icon_list->priv->bin_window, - GTK_WIDGET (icon_list)->style->base_gc[state], - TRUE, - item->layout_x - ICON_TEXT_PADDING, - item->layout_y - ICON_TEXT_PADDING, - item->layout_width + 2 * ICON_TEXT_PADDING, - item->layout_height + 2 * ICON_TEXT_PADDING); - } - - pango_layout_set_text (icon_list->priv->layout, item->label, -1); - gdk_draw_layout (icon_list->priv->bin_window, - GTK_WIDGET (icon_list)->style->text_gc[item->selected ? state : GTK_STATE_NORMAL], - item->layout_x - ((item->width - item->layout_width) / 2) - (MAX (item->pixbuf_width, MINIMUM_ICON_ITEM_WIDTH) - item->width) / 2, - item->layout_y, - icon_list->priv->layout); - - if (GTK_WIDGET_HAS_FOCUS (icon_list) && - item == icon_list->priv->cursor_item) - gtk_paint_focus (GTK_WIDGET (icon_list)->style, - icon_list->priv->bin_window, - item->selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL, - area, - GTK_WIDGET (icon_list), - "iconlist", - item->layout_x - ICON_TEXT_PADDING, - item->layout_y - ICON_TEXT_PADDING, - item->layout_width + 2 * ICON_TEXT_PADDING, - item->layout_height + 2 * ICON_TEXT_PADDING); -} - -static guint32 -egg_gdk_color_to_rgb (const GdkColor *color) -{ - guint32 result; - result = (0xff0000 | (color->red & 0xff00)); - result <<= 8; - result |= ((color->green & 0xff00) | (color->blue >> 8)); - return result; -} - -static void -egg_icon_list_paint_rubberband (EggIconList *icon_list, - GdkRectangle *area) -{ - GdkRectangle rect; - GdkPixbuf *pixbuf; - GdkGC *gc; - GdkRectangle rubber_rect; - GdkColor *fill_color_gdk; - guint fill_color; - guchar fill_color_alpha; - - rubber_rect.x = MIN (icon_list->priv->rubberband_x1, icon_list->priv->rubberband_x2); - rubber_rect.y = MIN (icon_list->priv->rubberband_y1, icon_list->priv->rubberband_y2); - rubber_rect.width = ABS (icon_list->priv->rubberband_x1 - icon_list->priv->rubberband_x2) + 1; - rubber_rect.height = ABS (icon_list->priv->rubberband_y1 - icon_list->priv->rubberband_y2) + 1; - - if (!gdk_rectangle_intersect (&rubber_rect, area, &rect)) - return; - - gtk_widget_style_get (GTK_WIDGET (icon_list), - "selection_box_color", &fill_color_gdk, - "selection_box_alpha", &fill_color_alpha, - NULL); - - if (!fill_color_gdk) { - fill_color_gdk = gdk_color_copy (>K_WIDGET (icon_list)->style->base[GTK_STATE_SELECTED]); - } - - fill_color = egg_gdk_color_to_rgb (fill_color_gdk) << 8 | fill_color_alpha; - - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height); - gdk_pixbuf_fill (pixbuf, fill_color); - - gdk_draw_pixbuf (icon_list->priv->bin_window, NULL, pixbuf, - 0, 0, - rect.x,rect.y, - rect.width, rect.height, - GDK_RGB_DITHER_NONE, - 0, 0); - g_object_unref (pixbuf); - gc = gdk_gc_new (icon_list->priv->bin_window); - gdk_gc_set_rgb_fg_color (gc, fill_color_gdk); - gdk_gc_set_clip_rectangle (gc, &rect); - gdk_draw_rectangle (icon_list->priv->bin_window, - gc, FALSE, - rubber_rect.x, rubber_rect.y, - rubber_rect.width - 1, rubber_rect.height - 1); - gdk_color_free (fill_color_gdk); - g_object_unref (gc); -} - -static void -egg_icon_list_queue_draw_item (EggIconList *icon_list, - EggIconListItem *item) -{ - GdkRectangle rect; - - rect.x = item->x; - rect.y = item->y; - rect.width = item->width; - rect.height = item->height; - - gdk_window_invalidate_rect (icon_list->priv->bin_window, &rect, TRUE); -} - -static gboolean -layout_callback (gpointer user_data) -{ - EggIconList *icon_list; - - icon_list = EGG_ICON_LIST (user_data); - - icon_list->priv->layout_idle_id = 0; - - egg_icon_list_layout (icon_list); - - return FALSE; -} - -static void -egg_icon_list_queue_layout (EggIconList *icon_list) -{ - if (icon_list->priv->layout_idle_id != 0) - return; - - icon_list->priv->layout_idle_id = g_idle_add (layout_callback, icon_list); -} - -static void -egg_icon_list_set_cursor_item (EggIconList *icon_list, - EggIconListItem *item) -{ - if (icon_list->priv->cursor_item == item) - return; - - if (icon_list->priv->cursor_item != NULL) - egg_icon_list_queue_draw_item (icon_list, icon_list->priv->cursor_item); - - icon_list->priv->cursor_item = item; - egg_icon_list_queue_draw_item (icon_list, item); -} - -static void -egg_icon_list_append_typeahead_string (EggIconList *icon_list, - const gchar *string) -{ - int i; - char *typeahead_string; - - if (strlen (string) == 0) - return; - - for (i = 0; i < strlen (string); i++) - { - if (!g_ascii_isprint (string[i])) - return; - } - - typeahead_string = g_strconcat (icon_list->priv->typeahead_string ? - icon_list->priv->typeahead_string : "", - string, NULL); - g_free (icon_list->priv->typeahead_string); - icon_list->priv->typeahead_string = typeahead_string; - - egg_icon_list_select_first_matching_item (icon_list, - icon_list->priv->typeahead_string); - - g_print ("wooo: \"%s\"\n", typeahead_string); -} - -/* Public API */ -GtkWidget * -egg_icon_list_new (void) -{ - EggIconList *icon_list; - - icon_list = g_object_new (EGG_TYPE_ICON_LIST, NULL); - - return GTK_WIDGET (icon_list); -} - -EggIconListItem * -egg_icon_list_item_new (GdkPixbuf *icon, - const char *label) -{ - EggIconListItem *item; - - item = g_new0 (EggIconListItem, 1); - - item->ref_count = 1; - item->width = -1; - item->height = -1; - item->label = g_strdup (label); - item->icon = g_object_ref (icon); - - return item; -} - -void -egg_icon_list_item_ref (EggIconListItem *item) -{ - g_return_if_fail (item != NULL); - - item->ref_count += 1; -} - -void -egg_icon_list_item_unref (EggIconListItem *item) -{ - g_return_if_fail (item != NULL); - - item->ref_count -= 1; - - if (item->ref_count == 0) - { - if (item->destroy_notify) - item->destroy_notify (item->user_data); - - g_free (item->label); - g_object_unref (item->icon); - g_free (item); - } - -} - -void -egg_icon_list_item_set_data (EggIconListItem *item, - gpointer data) -{ - egg_icon_list_item_set_data_full (item, data, NULL); -} - -void -egg_icon_list_item_set_data_full (EggIconListItem *item, - gpointer data, - GDestroyNotify destroy_notify) -{ - g_return_if_fail (item != NULL); - - if (item->destroy_notify) - item->destroy_notify (item->user_data); - - item->destroy_notify = destroy_notify; - item->user_data = data; -} - -gpointer -egg_icon_list_item_get_data (EggIconListItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - - return item->user_data; -} - -void -egg_icon_list_item_set_label (EggIconListItem *item, - const char *label) -{ - g_return_if_fail (item != NULL); - g_return_if_fail (label != NULL); - - if (strcmp (item->label, label) == 0) - return; - - g_free (item->label); - item->label = g_strdup (label); - egg_icon_list_item_invalidate_size (item); - - egg_icon_list_queue_layout (item->icon_list); - - g_object_notify (G_OBJECT (item), "label"); -} - -G_CONST_RETURN gchar * -egg_icon_list_item_get_label (EggIconListItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - - return item->label; -} - -void -egg_icon_list_item_set_icon (EggIconListItem *item, - GdkPixbuf *icon) -{ - g_return_if_fail (item != NULL); - - if (icon == item->icon) - return; - - g_object_unref (item->icon); - item->icon = g_object_ref (icon); - - egg_icon_list_item_invalidate_size (item); - - egg_icon_list_queue_layout (item->icon_list); -} - -GdkPixbuf * -egg_icon_list_item_get_icon (EggIconListItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - - return item->icon; -} - -void -egg_icon_list_append_item (EggIconList *icon_list, - EggIconListItem *item) -{ - GList *list; - - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - g_return_if_fail (item->icon_list == NULL); - - if (icon_list->priv->sorted) - { - egg_icon_list_insert_item_sorted (icon_list, item); - return; - } - - egg_icon_list_validate (icon_list); - - list = g_list_alloc (); - item->list = list; - item->icon_list = icon_list; - list->data = item; - egg_icon_list_item_ref (item); - - if (icon_list->priv->last_item) - { - icon_list->priv->last_item->next = list; - list->prev = icon_list->priv->last_item; - } - else - icon_list->priv->items = list; - - icon_list->priv->last_item = list; - icon_list->priv->item_count += 1; - - egg_icon_list_validate (icon_list); - - g_signal_emit (icon_list, icon_list_signals[ITEM_ADDED], 0, item); - - egg_icon_list_queue_layout (icon_list); -} - -void -egg_icon_list_prepend_item (EggIconList *icon_list, - EggIconListItem *item) -{ - GList *list; - - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - g_return_if_fail (item->icon_list == NULL); - - egg_icon_list_validate (icon_list); - - list = g_list_alloc (); - item->list = list; - item->icon_list = icon_list; - list->data = item; - egg_icon_list_item_ref (item); - - if (icon_list->priv->last_item == NULL) - icon_list->priv->last_item = list; - - if (icon_list->priv->items) - icon_list->priv->items->prev = list; - - list->next = icon_list->priv->items; - icon_list->priv->items = list; - icon_list->priv->item_count += 1; - - egg_icon_list_validate (icon_list); - - g_signal_emit (icon_list, icon_list_signals[ITEM_ADDED], 0, item); - - egg_icon_list_queue_layout (icon_list); - -} - - -void -egg_icon_list_insert_item_before (EggIconList *icon_list, - EggIconListItem *sibling, - EggIconListItem *item) -{ - GList *list; - - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - g_return_if_fail (item->icon_list == NULL); - - if (icon_list->priv->sorted) - { - egg_icon_list_insert_item_sorted (icon_list, item); - return; - } - - if (sibling == NULL) - egg_icon_list_append_item (icon_list, item); - - egg_icon_list_validate (icon_list); - - list = g_list_alloc (); - item->list = list; - item->icon_list = icon_list; - list->data = item; - egg_icon_list_item_ref (item); - - list->prev = sibling->list->prev; - list->next = sibling->list; - sibling->list->prev->next = list; - sibling->list->prev = list; - - if (sibling->list == icon_list->priv->items) - icon_list->priv->items = list; - - icon_list->priv->item_count += 1; - egg_icon_list_validate (icon_list); - - g_signal_emit (icon_list, icon_list_signals[ITEM_ADDED], 0, item); - - egg_icon_list_queue_layout (icon_list); -} - -void -egg_icon_list_insert_item_after (EggIconList *icon_list, - EggIconListItem *sibling, - EggIconListItem *item) -{ - GList *list; - - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - g_return_if_fail (item->icon_list == NULL); - - if (icon_list->priv->sorted) - { - egg_icon_list_insert_item_sorted (icon_list, item); - return; - } - - if (sibling == NULL) - { - egg_icon_list_prepend_item (icon_list, item); - return; - } - - egg_icon_list_validate (icon_list); - - list = g_list_alloc (); - item->list = list; - item->icon_list = icon_list; - list->data = item; - egg_icon_list_item_ref (item); - - list->next = sibling->list->next; - list->prev = sibling->list; - sibling->list->next->prev = list; - sibling->list->next = list; - - if (sibling->list == icon_list->priv->last_item) - icon_list->priv->last_item = list; - - icon_list->priv->item_count += 1; - egg_icon_list_validate (icon_list); - g_signal_emit (icon_list, icon_list_signals[ITEM_ADDED], 0, item); - - egg_icon_list_queue_layout (icon_list); -} - -void -egg_icon_list_remove_item (EggIconList *icon_list, - EggIconListItem *item) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - g_return_if_fail (item->icon_list == icon_list); - - egg_icon_list_validate (icon_list); - - if (item->list->prev) - item->list->prev->next = item->list->next; - if (item->list->next) - item->list->next->prev = item->list->prev; - - if (item->list == icon_list->priv->items) - icon_list->priv->items = item->list->next; - if (item->list == icon_list->priv->last_item) - icon_list->priv->last_item = item->list->prev; - - g_list_free_1 (item->list); - item->list = NULL; - item->icon_list = NULL; - egg_icon_list_item_invalidate_size (item); - - icon_list->priv->item_count -= 1; - egg_icon_list_validate (icon_list); - - g_signal_emit (icon_list, icon_list_signals[ITEM_REMOVED], 0, item); - - if (item->selected) - { - item->selected = FALSE; - - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); - } - -#if 0 - if (icon_list->priv->cursor_item == item) - g_error ("FIXME: Move to first focused item"); -#endif - - if (icon_list->priv->last_single_clicked == item) - icon_list->priv->last_single_clicked = NULL; - - egg_icon_list_item_unref (item); - - egg_icon_list_queue_layout (icon_list); -} - -void -egg_icon_list_clear (EggIconList *icon_list) -{ - GList *items, *p; - - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - - items = g_list_copy (icon_list->priv->items); - p = items; - while (items) - { - EggIconListItem *item = items->data; - - egg_icon_list_remove_item (icon_list, item); - items = items->next; - } - - g_list_free (p); -} - -EggIconListItem * -egg_icon_list_get_item_at_pos (EggIconList *icon_list, - gint x, - gint y) -{ - GList *items; - - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), NULL); - - for (items = icon_list->priv->items; items; items = items->next) - { - EggIconListItem *item = items->data; - - if (x > item->x && x < item->x + item->width && - y > item->y && y < item->y + item->height) - { - gint layout_x = item->x + (item->width - item->layout_width) / 2; - /* Check if the mouse is inside the icon or the label */ - if ((x > item->pixbuf_x && x < item->pixbuf_x + item->pixbuf_width && - y > item->pixbuf_y && y < item->pixbuf_y + item->pixbuf_height) || - (x > layout_x - ICON_TEXT_PADDING && - x < layout_x + item->layout_width + ICON_TEXT_PADDING * 2 && - y > item->layout_y - ICON_TEXT_PADDING - && y < item->layout_y + item->layout_height + ICON_TEXT_PADDING * 2)) - return item; - } - } - - return NULL; -} - -gint -egg_icon_list_get_item_count (EggIconList *icon_list) -{ - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), 0); - - return icon_list->priv->item_count; -} - -void -egg_icon_list_foreach (EggIconList *icon_list, - EggIconListForeachFunc func, - gpointer data) -{ - GList *list; - - for (list = icon_list->priv->items; list; list = list->next) - (* func) (icon_list, list->data, data); -} - -void -egg_icon_list_selected_foreach (EggIconList *icon_list, - EggIconListForeachFunc func, - gpointer data) -{ - GList *list; - - for (list = icon_list->priv->items; list; list = list->next) - { - EggIconListItem *item = list->data; - - if (item->selected) - (* func) (icon_list, list->data, data); - } -} - -GList * -egg_icon_list_get_selected (EggIconList *icon_list) -{ - GList *list, *selected = NULL; - - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), NULL); - - for (list = icon_list->priv->items; list; list = list->next) - { - EggIconListItem *item = list->data; - - if (item->selected) - selected = g_list_prepend (selected, item); - } - - return g_list_reverse (selected); -} - -void -egg_icon_list_set_selection_mode (EggIconList *icon_list, - GtkSelectionMode mode) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - - if (mode == icon_list->priv->selection_mode) - return; - - if (mode == GTK_SELECTION_NONE || - icon_list->priv->selection_mode == GTK_SELECTION_MULTIPLE) - egg_icon_list_unselect_all (icon_list); - - icon_list->priv->selection_mode = mode; - - g_object_notify (G_OBJECT (icon_list), "selection_mode"); -} - -GtkSelectionMode -egg_icon_list_get_selection_mode (EggIconList *icon_list) -{ - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), GTK_SELECTION_SINGLE); - - return icon_list->priv->selection_mode; -} - -void -egg_icon_list_select_item (EggIconList *icon_list, - EggIconListItem *item) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - - if (item->selected) - return; - - if (icon_list->priv->selection_mode == GTK_SELECTION_NONE) - return; - else if (icon_list->priv->selection_mode != GTK_SELECTION_MULTIPLE) - egg_icon_list_unselect_all_internal (icon_list, FALSE); - - item->selected = TRUE; - - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); - - egg_icon_list_queue_draw_item (icon_list, item); -} - - -void -egg_icon_list_unselect_item (EggIconList *icon_list, - EggIconListItem *item) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (item != NULL); - - if (!item->selected) - return; - - if (icon_list->priv->selection_mode == GTK_SELECTION_NONE || - icon_list->priv->selection_mode == GTK_SELECTION_BROWSE) - return; - - item->selected = FALSE; - - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); - - egg_icon_list_queue_draw_item (icon_list, item); -} - -gboolean -egg_icon_list_item_is_selected (EggIconListItem *item) -{ - g_return_val_if_fail (item != NULL, FALSE); - - return item->selected; -} - -void -egg_icon_list_unselect_all (EggIconList *icon_list) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - - egg_icon_list_unselect_all_internal (icon_list, TRUE); -} - -void -egg_icon_list_select_all (EggIconList *icon_list) -{ - GList *items; - gboolean dirty = FALSE; - - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - - for (items = icon_list->priv->items; items; items = items->next) - { - EggIconListItem *item = items->data; - - if (!item->selected) - { - dirty = TRUE; - item->selected = TRUE; - egg_icon_list_queue_draw_item (icon_list, item); - } - } - - if (dirty) - g_signal_emit (icon_list, icon_list_signals[SELECTION_CHANGED], 0); -} - -void -egg_icon_list_set_sorted (EggIconList *icon_list, - gboolean sorted) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (icon_list->priv->sort_func != NULL); - - if (icon_list->priv->sorted == sorted) - return; - - icon_list->priv->sorted = sorted; - g_object_notify (G_OBJECT (icon_list), "sorted"); - - if (icon_list->priv->sorted) - egg_icon_list_sort (icon_list); -} - -gboolean -egg_icon_list_get_sorted (EggIconList *icon_list) -{ - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), FALSE); - - return icon_list->priv->sorted; -} - -void -egg_icon_list_set_sort_func (EggIconList *icon_list, - EggIconListItemCompareFunc func, - gpointer data, - GDestroyNotify destroy_notify) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - g_return_if_fail (func != NULL); - - if (icon_list->priv->sort_destroy_notify && - icon_list->priv->sort_data) - (* icon_list->priv->sort_destroy_notify) (icon_list->priv->sort_data); - - icon_list->priv->sort_func = func; - icon_list->priv->sort_data = data; - icon_list->priv->sort_destroy_notify = destroy_notify; -} - -void -egg_icon_list_set_sort_order (EggIconList *icon_list, - GtkSortType order) -{ - g_return_if_fail (EGG_IS_ICON_LIST (icon_list)); - - if (icon_list->priv->sort_order == order) - return; - - icon_list->priv->sort_order = order; - - if (icon_list->priv->sorted) - egg_icon_list_sort (icon_list); - - g_object_notify (G_OBJECT (icon_list), "sort_order"); -} - -GtkSortType -egg_icon_list_get_sort_order (EggIconList *icon_list) -{ - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), GTK_SORT_ASCENDING); - - return icon_list->priv->sort_order; -} - -void -egg_icon_list_item_activated (EggIconList *icon_list, - EggIconListItem *item) -{ - g_signal_emit (G_OBJECT (icon_list), icon_list_signals[ITEM_ACTIVATED], 0, item); -} - -GList * -egg_icon_list_get_items (EggIconList *icon_list) -{ - g_return_val_if_fail (EGG_IS_ICON_LIST (icon_list), NULL); - - return icon_list->priv->items; -} - -EggIconList * -egg_icon_list_item_get_icon_list (EggIconListItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - - return item->icon_list; -} diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h deleted file mode 100644 index ae6be00c0a..0000000000 --- a/gtk/gtkiconview.h +++ /dev/null @@ -1,151 +0,0 @@ -/* eggiconlist.h - * Copyright (C) 2002 Anders Carlsson - * - * 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. - */ -#ifndef __EGG_ICON_LIST_H__ -#define __EGG_ICON_LIST_H__ - -#include - -G_BEGIN_DECLS - -#define EGG_TYPE_ICON_LIST (egg_icon_list_get_type ()) -#define EGG_ICON_LIST(obj) (GTK_CHECK_CAST ((obj), EGG_TYPE_ICON_LIST, EggIconList)) -#define EGG_ICON_LIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EGG_TYPE_ICON_LIST, EggIconListClass)) -#define EGG_IS_ICON_LIST(obj) (GTK_CHECK_TYPE ((obj), EGG_TYPE_ICON_LIST)) -#define EGG_IS_ICON_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EGG_TYPE_ICON_LIST)) -#define EGG_ICON_LIST_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), EGG_TYPE_ICON_LIST, EggIconListClass)) - -#define EGG_TYPE_ICON_LIST_ITEM (egg_icon_list_item_get_type ()) - -typedef struct _EggIconList EggIconList; -typedef struct _EggIconListClass EggIconListClass; -typedef struct _EggIconListPrivate EggIconListPrivate; -typedef struct _EggIconListItem EggIconListItem; - -typedef void (* EggIconListForeachFunc) (EggIconList *icon_list, - EggIconListItem *item, - gpointer data); -typedef gint (* EggIconListItemCompareFunc) (EggIconList *icon_list, - EggIconListItem *a, - EggIconListItem *b, - gpointer user_data); - -struct _EggIconList -{ - GtkContainer parent; - - EggIconListPrivate *priv; -}; - -struct _EggIconListClass -{ - GtkContainerClass parent_class; - - void (* set_scroll_adjustments) (EggIconList *icon_list, - GtkAdjustment *hadjustment, - GtkAdjustment *vadjustment); - - void (* item_activated) (EggIconList *icon_list, - EggIconListItem *item); - void (* selection_changed) (EggIconList *icon_list); - void (* item_added) (EggIconList *icon_list, - EggIconListItem *item); - void (* item_removed) (EggIconList *icon_list, - EggIconListItem *item); - void (* item_changed) (EggIconList *icon_list, - EggIconListItem *item); - /* Key binding signals */ - void (* select_all) (EggIconList *icon_list); - void (* unselect_all) (EggIconList *icon_list); - void (* select_cursor_item) (EggIconList *icon_list); - void (* toggle_cursor_item) (EggIconList *icon_list); -}; - -GType egg_icon_list_get_type (void); -GType egg_icon_list_item_get_type (void); -GtkWidget *egg_icon_list_new (void); - -EggIconListItem * egg_icon_list_item_new (GdkPixbuf *icon, - const gchar *label); -void egg_icon_list_item_ref (EggIconListItem *item); -void egg_icon_list_item_unref (EggIconListItem *item); -void egg_icon_list_item_set_data (EggIconListItem *item, - gpointer data); -void egg_icon_list_item_set_data_full (EggIconListItem *item, - gpointer data, - GDestroyNotify destroy_notify); -gpointer egg_icon_list_item_get_data (EggIconListItem *item); -void egg_icon_list_item_set_label (EggIconListItem *item, - const char *label); -G_CONST_RETURN gchar *egg_icon_list_item_get_label (EggIconListItem *item); -void egg_icon_list_item_set_icon (EggIconListItem *item, - GdkPixbuf *icon); -GdkPixbuf * egg_icon_list_item_get_icon (EggIconListItem *item); -void egg_icon_list_append_item (EggIconList *icon_list, - EggIconListItem *item); -void egg_icon_list_prepend_item (EggIconList *icon_list, - EggIconListItem *item); -void egg_icon_list_insert_item_before (EggIconList *icon_list, - EggIconListItem *sibling, - EggIconListItem *item); -void egg_icon_list_insert_item_after (EggIconList *icon_list, - EggIconListItem *sibling, - EggIconListItem *item); -void egg_icon_list_remove_item (EggIconList *icon_list, - EggIconListItem *item); -void egg_icon_list_clear (EggIconList *icon_list); -EggIconListItem * egg_icon_list_get_item_at_pos (EggIconList *icon_list, - gint x, - gint y); -gint egg_icon_list_get_item_count (EggIconList *icon_list); -void egg_icon_list_foreach (EggIconList *icon_list, - EggIconListForeachFunc func, - gpointer data); -GList * egg_icon_list_get_selected (EggIconList *icon_list); -void egg_icon_list_selected_foreach (EggIconList *icon_list, - EggIconListForeachFunc func, - gpointer data); -void egg_icon_list_set_selection_mode (EggIconList *icon_list, - GtkSelectionMode mode); -GtkSelectionMode egg_icon_list_get_selection_mode (EggIconList *icon_list); -void egg_icon_list_select_item (EggIconList *icon_list, - EggIconListItem *item); -void egg_icon_list_unselect_item (EggIconList *icon_list, - EggIconListItem *item); -gboolean egg_icon_list_item_is_selected (EggIconListItem *item); -void egg_icon_list_select_all (EggIconList *icon_list); -void egg_icon_list_unselect_all (EggIconList *icon_list); -void egg_icon_list_set_sorted (EggIconList *icon_list, - gboolean sorted); -gboolean egg_icon_list_get_sorted (EggIconList *icon_list); -void egg_icon_list_set_sort_func (EggIconList *icon_list, - EggIconListItemCompareFunc func, - gpointer data, - GDestroyNotify destroy_notify); -void egg_icon_list_set_sort_order (EggIconList *icon_list, - GtkSortType order); -GtkSortType egg_icon_list_get_sort_order (EggIconList *icon_list); -void egg_icon_list_item_activated (EggIconList *icon_list, - EggIconListItem *item); - -/* For accessibility */ -GList *egg_icon_list_get_items (EggIconList *icon_list); - -G_END_DECLS - -#endif /* __EGG_ICON_LIST_H__ */ diff --git a/modules/engines/ms-windows/ChangeLog.old b/modules/engines/ms-windows/ChangeLog.old deleted file mode 100755 index e1c7594ba1..0000000000 --- a/modules/engines/ms-windows/ChangeLog.old +++ /dev/null @@ -1,367 +0,0 @@ -2004-03-20 Raymond Penners - - * all: Renamed GTK-Wimp to MS-Windows Engine - -2004-03-11 Raymond Penners - - * === Released 0.5.4 === - -2004-03-10 Dom Lachowicz - - * configure.in: Bump version number (0.5.4) - -2004-02-25 Dom Lachowicz - - * src/wimp_style.c: Fix - http://bugzilla.gnome.org/show_bug.cgi?id=135098 - http://sourceforge.net/tracker/index.php?func=detail&aid=895762&group_id=76416&atid=547655 - -2004-01-25 Raymond Penners - - * === Released 0.5.3 === - -2004-01-20 Dom Lachowicz - - * src/wimp_style.c: Fix disappearing text in Gimp option menus. - Fix background color on XP menus. - -2004-01-20 Dom Lachowicz - - * src/xp_theme.h - * src/xp_theme.c - * src/wimp_style.c: Remove UXTHEME_HAS_LINES stuff. I played around - with line drawing, and the results were absolutely dreadful. - -2003-12-30 Dom Lachowicz - - * src/wimp_style.c - * src/xp_theme.c - * src/xp_theme.h - * src/xp_theme_defs.h: Toward 853775, get toolbar button borders correct - -2003-12-30 Dom Lachowicz - - * src/wimp_style.c: Fix bug 852354 to my liking - -2003-12-01 Dom Lachowicz - - * src/wimp_style.c: Fix coloration for the expander's +/- part. Was - the wrong color when selected or selected+insensitive - -2003-11-26 Dom Lachowicz - - * src/wimp_style.c: Fix coloration for several GIMP widgets, - specifically their own OptionMenu-like widget. - -2003-11-24 Dom Lachowicz - - * src/wimp_style.c: Get the coloration correct for menu bars (XP theme - was showing white foreground instead of gray) - - * configure.in: Post-release version number bump - -2003-11-19 Raymond Penners - - * === Released 0.5.2 === - -2003-11-14 Dom Lachowicz - - * src/wimp_style.c: Protect against buffer overflows when grabbing - fonts and generating RC strings. Get the Progress and Status - widget backgrounds to behave properly on themes like "Brick". - -2003-11-05 Dom Lachowicz - - * src/wimp_style.c: Toolbar steppers get drawn ETCHED_IN when - pressed now. More consistent with Win32 behavior. - - * src/Theme/gtk-2.0/gtkrc: Make menubars have shadow=NONE. More - consistent with Win32 behavior, though Win32 apps tend to differ - in this area. Setup menu and toolbar icon sizes to be compatible - with win32 - -2003-11-04 Dom Lachowicz - - * src/xp_theme.c: Move Raymond's scrollbar work into wimp_style.c - - * src/wimp_style.c: Get the colorations better for other windows - schemes, such as brick. Based on some work by Jernej Simonèiè - - -2003-11-01 Raymond Penners - - * src/xp_theme.c: Do not display XP scrollbar grippers on tiny - scrollbars. - -2003-10-23 Raymond Penners - - * === Released 0.5.1 === - -2003-10-23 Dom Lachowicz - - * src/xp_theme_defs.h: Update to include definitions for my latest - work. - -2003-10-22 Raymond Penners - - * src/*.[ch]: Code formatting & XP constants renaming. - -2003-10-21 Dom Lachowicz - - * src/wimp_style.c: Use theme colors, use theme metrics - (disabled), use theme fonts, theme menu items, menu separators, - draw status bar resize grips. - - * src/xp_theme.c: Ditto. - -2003-10-20 Raymond Penners - - * src/wimp_style.c: Added grippers to XP scrollbars. - -2003-10-20 Dom Lachowicz - - * configure.in: Bump version to the next release number (0.5.1) - -2003-10-18 Raymond Penners - - * src/Theme/gtk-2.0/gtkrc: "GtkToolBar" should read "GtkToolbar" - - * src/*: Attempted to fix the grippers for the GNAT Programming - System. Things behave a tiny bit better now. See #ifdef GNATS_HACK - -2003-10-17 Raymond Penners - - * src/wimp_style.c: Horizontal/vertical scrollbars were mixed up, - fixed. - -2003-04-15 Arnaud Charlet - - * src/*.c: The handling of selected radio button was broken. - - * src/xp_theme_defs.h: When building with gcc, the tree expanders - were inverted. - -2003-10-08 Raymond Penners - - * === Released 0.5.0 === - -2003-10-07 Raymond Penners - - * src/wimp_style.c: Tabs not located on top of the notebook are - now (again) no longer rendered using XP theming. - - * src/xp_theme.c: Added a more lightweight method to cope with - theme changes. Added a crude theme switch detection scheme in the - case that GTK+ does not implement gdk_window_add_filter properly - (GTK+ 2.2.0?). - -2003-10-07 Dom Lachowicz - - * Added new mingw based build system, tidied up other missing bits - - * src/xp_theme.c: Tidied up some return cases - -2003-10-07 Raymond Penners - - * src/xp_theme.c: We now properly use IsThemeActive(). - - * src/xp_theme_defs.h: Renamed from xp_theme_dfns.h - -2003-10-06 Dom Lachowicz - - * src/wimp_style_main.c: Catch system settings changes, disable - theme and color changes as they're too experimental - - * src/wimp_style.[ch]: Export some things, make them accept 0 args - - * src/xp_theme_dfns.h: New file. WinXP's UXTHEME constants, for - building on platforms without them - - * src/xp_theme.c: Should be able to build on Win32 != [WinXP,2k3] - now - -2003-10-03 Dom Lachowicz - - * src/wimp_style.c wimp_style_main.c: Refactor how we're doing - styles. Much faster, lower memory consumption - -2003-10-03 Dom Lachowicz - - * src/wimp_style_main.c: Catch theme and color changes. Needs more - testing and fine-tuning - -2003-10-02 Dom Lachowicz - - * src/wimp_style.c: Deallocate used HDCs - -2003-10-01 Dom Lachowicz - - * src/wimp_style.c: Only set the delays if the param is - installed. Silly gtk - installing those 3 params only in the - menus... - -2003-09-25 Dom Lachowicz - - * src/wimp_style.c: Set a delay on popdown menus - -2003-09-22 Dom Lachowicz - - * src/xp_theme.c: Make a string array const - -2003-09-20 Raymond Penners - - * === Released 0.4.3 === - - * src/wimp_style.c: The Gaim buddy icons were missing due to - recent tree expander changes, not the clipping area. Fixed. - - * src/xp_theme.c: Re-enabled clipping area, I am confident it - should not cause any problems now. - -2003-09-18 Raymond Penners - - * === Released 0.4.2 === - -2003-09-16 Dom Lachowicz - - * src/xp_theme.c: Ignore cliprect for now - -2003-09-15 Raymond Penners - - * === Released 0.4.1 === - - * src/wimp_style.c: Fixed typ-o (gtk-double-cliNk-time), adjusted - cursor blink time to cope with Windows semantics (GTK+ uses cycle - time), fixed clipping area computation. Fixed XP tree expanders to - cope with clipping area, and made non-XP tree expanders look - pixel-perfect. - -2003-09-15 Dom Lachowicz - - * src/wimp_style.c: Fix a few more console messages, implement - caret blinking - - * src/xp_theme.*: Stub out line drawing. Apparently, documented - bits are missing from MS's implementation. Go figure... - -2003-09-14 Raymond Penners - - * src/wimp_style.c: Fixed console message complaining about - "default_border". - - * src/wimp_style.c: Due to a bug lots of console message - complaining about "unexpected keyword `fg'" occured, fixed. - -2003-09-11 Dom Lachowicz - - * src/Theme/gtk-2.0/gtkrc: Remove unused cruft wrt GtkScrollbars - -2003-09-11 Raymond Penners - - * === Released 0.4.0 === - - * src/wimp_style.c: Notebook tabs were no longer properly drawn, - fixed. - -2003-09-08 Dom Lachowicz - - * src/wimp_style.c: Honor scrollbar sizes, radio/check button - sizes, paned sizes - -2003-09-03 Dom Lachowicz - - * src/wimp_style.c: Honor tooltip color, font - -2003-09-02 Dom Lachowicz - - * src/wimp_style.c: We now honor font preferences being bold or - italic - -2003-08-29 Dom Lachowicz - - * src/*.c: Theme GTK toolbar arrows to XP chevrons, once my GTK - patch is committed. - - * src/wimp_style.c: Enable proper fonts/sizes for menus, status - bars. Tooltips are waiting for my GTK patches, though. - -2003-08-28 Dom Lachowicz - - * src/wimp_style.c: Change how we draw handle boxes in the non-XP - case. This does not yet apply to GtkHandleBoxes - -2003-08-26 Dom Lachowicz - - * src/*.c: Tooltips should do XP-style theming. Handle Boxes/Panes - do XP style REBAR theming (TODO: non-XP version of the above for - handleboxes). Toolbars should draw the REBAR part - properly. Preparation for using the Toolbar class. Menubars and - Toolbars now are etched-in to mimic Windows' - behavior. HandleBoxes' shadow types should also be correct now, - compared to OfficeXP applications. - -2003-08-26 Raymond Penners - - * === Released 0.3.0 === - -2003-08-23 Raymond Penners - - * src/*.c: Merged Dom Lachowicz's patches, now tooltips and - progress bars nicely adhere to the system colors as well. - - * src/xp_theme.c: There was a mixup in drawing the proper checkbox - state, fixed (Gaim bug #790305). - -2003-08-20 Raymond Penners - - * src/Theme/gtk-2.0/gtkrc: Disabled the colored, alternating - rules for GtkTreeViews to match the Windows behaviour. - - * */Makefile.msc: Provided MS-VC++ make files. - - * src/xp_theme.c: The open/close tree expander symbols were - accidentally switched, fixed (Gaim bug #790300). - -2003-08-11 Raymond Penners - - * src/wimp_style.c: The menu background color now follows XP's - color scheme. - -2003-08-07 Raymond Penners - - * === Released 0.2.0 === - -2003-08-06 Raymond Penners - - * src/*.c: Added XP theming support for progress bars. - -2003-08-05 Raymond Penners - - * src/xp_theme.c: Internal redesign: extracted XP specific theming - from wimp_style.c, improved code. - - * src/wimp_style.c: Added XP theming support for list headers, and - entry widgets. - -2003-08-03 Raymond Penners - - * src/wimp_style.c: Improved system color handling, added XP - theming support for option menus. - -2003-04-15 Raymond Penners - - * src/wimp_style.c: Tabs not located on top of the notebook are - not rendered properly using XP theming. Added fallback to non-XP - theming behaviour if the tabs are not located on top (to be - removed when full notebook support is in). - -2003-04-15 Arnaud Charlet - - * src/wimp_style.c: Add handling of expander. Fix colors for combo - box items. Add native rendering of radio buttons. Fix handling of - default buttons. Add native rendering of tree expanders. - -2003-03-18 Raymond Penners - - * === Released 0.1.0 === - diff --git a/modules/engines/ms-windows/Makefile.am b/modules/engines/ms-windows/Makefile.am deleted file mode 100644 index 592fd62201..0000000000 --- a/modules/engines/ms-windows/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -SUBDIRS=Theme - -EXTRA_DIST=Makefile.msc - -INCLUDES=$(MSW_CFLAGS) - -enginedir=$(libdir)/gtk-2.0/$(GTK_VERSION)/engines - -engine_LTLIBRARIES = libms-windows-engine.la - -libms_windows_engine_la_SOURCES = \ - msw_rc_style.c \ - msw_rc_style.h \ - msw_style.c \ - msw_style.h \ - msw_theme_main.c \ - xp_theme.c \ - xp_theme_defs.h \ - xp_theme.h - -libms_windows_engine_la_LDFLAGS = \ - -avoid-version -module -no-undefined -export-dynamic - -libms_windows_engine_la_LIBADD= $(MSW_LIBS) - diff --git a/modules/engines/ms-windows/Makefile.msc b/modules/engines/ms-windows/Makefile.msc deleted file mode 100755 index 38f5e78136..0000000000 --- a/modules/engines/ms-windows/Makefile.msc +++ /dev/null @@ -1,71 +0,0 @@ -# Makefile.msc -- Makefile for MS-VC++ (-*- makefile -*-) -# -# Copyright (C) 2003, 2004 Raymond Penners -# -# $Id$ - -!INCLUDE ../Makefile.msc.config - -## -# Target -TARGET=libms-windows-engine.dll - -OBJS = \ - msw_style.obj \ - msw_theme_main.obj \ - msw_rc_style.obj \ - xp_theme.obj - -## -# GTK -# -GTK_CFLAGS=\ - -I$(GTK_DIR)/include/gtk-2.0 \ - -I$(GTK_DIR)/lib/gtk-2.0/include \ - -I$(GTK_DIR)/include/atk-1.0 \ - -I$(GTK_DIR)/include/pango-1.0 \ - -I$(GTK_DIR)/include/glib-2.0 \ - -I$(GTK_DIR)/lib/glib-2.0/include - -GTK_LDFLAGS=/libpath:$(GTK_DIR)/lib - -GTK_LIBS= \ - gtk-win32-2.0.lib \ - gdk-win32-2.0.lib \ - atk-1.0.lib \ - gdk_pixbuf-2.0.lib \ - pangowin32-1.0.lib \ - pango-1.0.lib \ - gobject-2.0.lib \ - gmodule-2.0.lib \ - glib-2.0.lib \ - intl.lib \ - iconv.lib - -## -# WIN32 -# -WIN32_LIBS = \ - gdi32.lib \ - user32.lib - -WIN32_CFLAGS=-I"$(SDK_DIR)" -WIN32_LDFLAGS=/DLL /SUBSYSTEM:WINDOWS - -## -# Target -# -LIBS=$(GTK_LIBS) $(WIN32_LIBS) -CFLAGS=$(WIN32_CFLAGS) $(GTK_CFLAGS) -LDFLAGS= $(WIN32_LDFLAGS) $(GTK_LDFLAGS) - -all: $(TARGET) - -$(TARGET): $(OBJS) - link $(LDFLAGS) $(LIBS) /OUT:$@ $(OBJS) - -install: $(TARGET) - copy $(TARGET) "$(INSTALL_DIR)" - -clean: - del *.obj *.dll *.exp *.lib diff --git a/modules/engines/ms-windows/Theme/Makefile.am b/modules/engines/ms-windows/Theme/Makefile.am deleted file mode 100644 index 7e652b8ff9..0000000000 --- a/modules/engines/ms-windows/Theme/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS=gtk-2.0 diff --git a/modules/engines/ms-windows/Theme/gtk-2.0/Makefile.am b/modules/engines/ms-windows/Theme/gtk-2.0/Makefile.am deleted file mode 100644 index b50f7107cb..0000000000 --- a/modules/engines/ms-windows/Theme/gtk-2.0/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -themedir = $(datadir)/themes/gtk-2.0 -theme_DATA=gtkrc - -EXTRA_DIST=$(theme_DATA) diff --git a/modules/engines/ms-windows/Theme/gtk-2.0/gtkrc b/modules/engines/ms-windows/Theme/gtk-2.0/gtkrc deleted file mode 100755 index 7ed8bb710c..0000000000 --- a/modules/engines/ms-windows/Theme/gtk-2.0/gtkrc +++ /dev/null @@ -1,21 +0,0 @@ -# TODO: we should probably obtain these from a Win32 IconMetrics struct -gtk-icon-sizes="gtk-menu=16,16:gtk-small-toolbar=18,18:gtk-large-toolbar=24,24:gtk-dnd=32,32" - -style "msw-default" -{ - GtkWidget::interior_focus = 1 - GtkOptionMenu::indicator_size = { 9, 5 } - GtkOptionMenu::indicator_spacing = { 7, 5, 2, 2 } - GtkMenuBar::shadow-type = none - GtkToolbar::shadow-type = etched-in - GtkHandleBox::shadow-type = none - GtkSpinButton::shadow-type = in - - GtkTreeView::allow-rules = 0 - GtkTreeView::expander_size = 11 - - engine "ms-windows-engine" - { - } -} -class "*" style "msw-default" diff --git a/modules/engines/ms-windows/msw_rc_style.c b/modules/engines/ms-windows/msw_rc_style.c deleted file mode 100755 index 22b8e158fd..0000000000 --- a/modules/engines/ms-windows/msw_rc_style.c +++ /dev/null @@ -1,78 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * Includes code adapted from redmond95 by Owen Taylor, and - * gtk-nativewin by Evan Martin - * - * 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. - */ - -#include "msw_style.h" -#include "msw_rc_style.h" - -static void msw_rc_style_init (MswRcStyle *style); -static void msw_rc_style_class_init (MswRcStyleClass *klass); -static GtkStyle *msw_rc_style_create_style (GtkRcStyle *rc_style); - -static GtkRcStyleClass *parent_class; - -GType msw_type_rc_style = 0; - -void -msw_rc_style_register_type (GTypeModule *module) -{ - static const GTypeInfo object_info = - { - sizeof (MswRcStyleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) msw_rc_style_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (MswRcStyle), - 0, /* n_preallocs */ - (GInstanceInitFunc) msw_rc_style_init, - }; - - msw_type_rc_style = g_type_module_register_type (module, - GTK_TYPE_RC_STYLE, - "MswRcStyle", - &object_info, 0); -} - -static void -msw_rc_style_init (MswRcStyle *style) -{ -} - -static void -msw_rc_style_class_init (MswRcStyleClass *klass) -{ - GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - rc_style_class->create_style = msw_rc_style_create_style; -} - -/* Create an empty style suitable to this RC style - */ -static GtkStyle * -msw_rc_style_create_style (GtkRcStyle *rc_style) -{ - return GTK_STYLE (g_object_new (MSW_TYPE_STYLE, NULL)); -} - diff --git a/modules/engines/ms-windows/msw_rc_style.h b/modules/engines/ms-windows/msw_rc_style.h deleted file mode 100755 index 9055db63a5..0000000000 --- a/modules/engines/ms-windows/msw_rc_style.h +++ /dev/null @@ -1,54 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * Includes code adapted from redmond95 by Owen Taylor, and - * gtk-nativewin by Evan Martin - * - * 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. - */ - -#ifndef MSW_RC_STYLE_H -#define MSW_RC_STYLE_H - -#include - -typedef struct _MswRcStyle MswRcStyle; -typedef struct _MswRcStyleClass MswRcStyleClass; - -extern GType msw_type_rc_style; - -#define MSW_TYPE_RC_STYLE msw_type_rc_style -#define MSW_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MSW_TYPE_RC_STYLE, MswRcStyle)) -#define MSW_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MSW_TYPE_RC_STYLE, MswRcStyleClass)) -#define MSW_IS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MSW_TYPE_RC_STYLE)) -#define MSW_IS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MSW_TYPE_RC_STYLE)) -#define MSW_RC_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MSW_TYPE_RC_STYLE, MswRcStyleClass)) - -struct _MswRcStyle -{ - GtkRcStyle parent_instance; - - GList *img_list; -}; - -struct _MswRcStyleClass -{ - GtkRcStyleClass parent_class; -}; - -void msw_rc_style_register_type (GTypeModule *module); - -#endif /* MSW_TYPE_RC_STYLE */ diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c deleted file mode 100755 index 0cb22b4ab6..0000000000 --- a/modules/engines/ms-windows/msw_style.c +++ /dev/null @@ -1,2050 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * Includes code adapted from redmond95 by Owen Taylor, and - * gtk-nativewin by Evan Martin - * - * 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. - */ - -#include "msw_style.h" -#include "xp_theme.h" - -#include -#include -#include -#include -#include -#include - -#include - -/* Default values, not normally used - */ -static const GtkRequisition default_option_indicator_size = { 9, 8 }; -static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 }; - -static GtkStyleClass *parent_class; - -typedef enum { - CHECK_AA, - CHECK_BASE, - CHECK_BLACK, - CHECK_DARK, - CHECK_LIGHT, - CHECK_MID, - CHECK_TEXT, - RADIO_BASE, - RADIO_BLACK, - RADIO_DARK, - RADIO_LIGHT, - RADIO_MID, - RADIO_TEXT -} Part; - -#define PART_SIZE 13 - -static const char check_aa_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -static const char check_base_bits[] = { - 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc, - 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00}; -static const char check_black_bits[] = { - 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02, - 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00}; -static const char check_dark_bits[] = { - 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, - 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00}; -static const char check_light_bits[] = { - 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00, - 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f}; -static const char check_mid_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00, - 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00}; -static const char check_text_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x88,0x03,0xd8,0x01,0xf8, - 0x00,0x70,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -static const char radio_base_bits[] = { - 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc, - 0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00}; -static const char radio_black_bits[] = { - 0x00,0x00,0xf0,0x01,0x0c,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02, - 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -static const char radio_dark_bits[] = { - 0xf0,0x01,0x0c,0x06,0x02,0x00,0x02,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, - 0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00}; -static const char radio_light_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00, - 0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x0c,0x06,0xf0,0x01}; -static const char radio_mid_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x08,0x00, - 0x08,0x00,0x08,0x00,0x04,0x0c,0x06,0xf0,0x01,0x00,0x00}; -static const char radio_text_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0, - 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - -static struct { - const char *bits; - GdkBitmap *bmap; -} parts[] = { - { check_aa_bits, NULL }, - { check_base_bits, NULL }, - { check_black_bits, NULL }, - { check_dark_bits, NULL }, - { check_light_bits, NULL }, - { check_mid_bits, NULL }, - { check_text_bits, NULL }, - { radio_base_bits, NULL }, - { radio_black_bits, NULL }, - { radio_dark_bits, NULL }, - { radio_light_bits, NULL }, - { radio_mid_bits, NULL }, - { radio_text_bits, NULL } -}; - -static gboolean -get_system_font(XpThemeClass klazz, XpThemeFont type, LOGFONT *out_lf) -{ -#if 0 - /* TODO: this crashes. need to figure out why and how to fix it */ - if (xp_theme_get_system_font(klazz, type, out_lf)) { - return TRUE; - } else -#endif - { - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof(NONCLIENTMETRICS); - - if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, - sizeof(NONCLIENTMETRICS), &ncm, 0)) - { - if (type == XP_THEME_FONT_CAPTION) - *out_lf = ncm.lfCaptionFont; - else if (type == XP_THEME_FONT_MENU) - *out_lf = ncm.lfMenuFont; - else if (type == XP_THEME_FONT_STATUS) - *out_lf = ncm.lfStatusFont; - else - *out_lf = ncm.lfMessageFont; - - return TRUE; - } - } - return FALSE; -} - -/***************************** STOLEN FROM PANGO *****************************/ - -/* - This code is stolen from Pango 1.4. It attempts to address the following problems: - - http://bugzilla.gnome.org/show_bug.cgi?id=135098 - http://sourceforge.net/tracker/index.php?func=detail&aid=895762&group_id=76416&atid=547655 - - As Owen suggested in bug 135098, once Pango 1.6 is released, we need to get rid of this code. -*/ - -#define PING(printlist) - -/* TrueType defines: */ - -#define MAKE_TT_TABLE_NAME(c1, c2, c3, c4) \ - (((guint32)c4) << 24 | ((guint32)c3) << 16 | ((guint32)c2) << 8 | ((guint32)c1)) - -#define CMAP (MAKE_TT_TABLE_NAME('c','m','a','p')) -#define CMAP_HEADER_SIZE 4 - -#define NAME (MAKE_TT_TABLE_NAME('n','a','m','e')) -#define NAME_HEADER_SIZE 6 - -#define ENCODING_TABLE_SIZE 8 - -#define APPLE_UNICODE_PLATFORM_ID 0 -#define MACINTOSH_PLATFORM_ID 1 -#define ISO_PLATFORM_ID 2 -#define MICROSOFT_PLATFORM_ID 3 - -#define SYMBOL_ENCODING_ID 0 -#define UNICODE_ENCODING_ID 1 -#define UCS4_ENCODING_ID 10 - -struct name_header -{ - guint16 format_selector; - guint16 num_records; - guint16 string_storage_offset; -}; - -struct name_record -{ - guint16 platform_id; - guint16 encoding_id; - guint16 language_id; - guint16 name_id; - guint16 string_length; - guint16 string_offset; -}; - -gboolean -pango_win32_get_name_header (HDC hdc, - struct name_header *header) -{ - if (GetFontData (hdc, NAME, 0, header, sizeof (*header)) != sizeof (*header)) - return FALSE; - - header->num_records = GUINT16_FROM_BE (header->num_records); - header->string_storage_offset = GUINT16_FROM_BE (header->string_storage_offset); - - return TRUE; -} - -gboolean -pango_win32_get_name_record (HDC hdc, - gint i, - struct name_record *record) -{ - if (GetFontData (hdc, NAME, 6 + i * sizeof (*record), - record, sizeof (*record)) != sizeof (*record)) - return FALSE; - - record->platform_id = GUINT16_FROM_BE (record->platform_id); - record->encoding_id = GUINT16_FROM_BE (record->encoding_id); - record->language_id = GUINT16_FROM_BE (record->language_id); - record->name_id = GUINT16_FROM_BE (record->name_id); - record->string_length = GUINT16_FROM_BE (record->string_length); - record->string_offset = GUINT16_FROM_BE (record->string_offset); - - return TRUE; -} - -static gchar * -get_family_name (LOGFONT *lfp, HDC pango_win32_hdc) -{ - HFONT hfont; - HFONT oldhfont; - - struct name_header header; - struct name_record record; - - gint unicode_ix = -1, mac_ix = -1, microsoft_ix = -1; - gint name_ix; - gchar *codeset; - - gchar *string = NULL; - gchar *name; - - gint i, l; - gsize nbytes; - - /* If lfFaceName is ASCII, assume it is the common (English) name - * for the font. Is this valid? Do some TrueType fonts have - * different names in French, German, etc, and does the system - * return these if the locale is set to use French, German, etc? - */ - l = strlen (lfp->lfFaceName); - for (i = 0; i < l; i++) - if (lfp->lfFaceName[i] < ' ' || lfp->lfFaceName[i] > '~') - break; - - if (i == l) - return g_strdup (lfp->lfFaceName); - - if ((hfont = CreateFontIndirect (lfp)) == NULL) - goto fail0; - - if ((oldhfont = SelectObject (pango_win32_hdc, hfont)) == NULL) - goto fail1; - - if (!pango_win32_get_name_header (pango_win32_hdc, &header)) - goto fail2; - - PING (("%d name records", header.num_records)); - - for (i = 0; i < header.num_records; i++) - { - if (!pango_win32_get_name_record (pango_win32_hdc, i, &record)) - goto fail2; - - if ((record.name_id != 1 && record.name_id != 16) || record.string_length <= 0) - continue; - - PING(("platform:%d encoding:%d language:%04x name_id:%d", - record.platform_id, record.encoding_id, record.language_id, record.name_id)); - - if (record.platform_id == APPLE_UNICODE_PLATFORM_ID || - record.platform_id == ISO_PLATFORM_ID) - unicode_ix = i; - else if (record.platform_id == MACINTOSH_PLATFORM_ID && - record.encoding_id == 0 && /* Roman */ - record.language_id == 0) /* English */ - mac_ix = i; - else if (record.platform_id == MICROSOFT_PLATFORM_ID) - if ((microsoft_ix == -1 || - PRIMARYLANGID (record.language_id) == LANG_ENGLISH) && - (record.encoding_id == SYMBOL_ENCODING_ID || - record.encoding_id == UNICODE_ENCODING_ID || - record.encoding_id == UCS4_ENCODING_ID)) - microsoft_ix = i; - } - - if (microsoft_ix >= 0) - name_ix = microsoft_ix; - else if (mac_ix >= 0) - name_ix = mac_ix; - else if (unicode_ix >= 0) - name_ix = unicode_ix; - else - goto fail2; - - if (!pango_win32_get_name_record (pango_win32_hdc, name_ix, &record)) - goto fail2; - - string = g_malloc (record.string_length + 1); - if (GetFontData (pango_win32_hdc, NAME, - header.string_storage_offset + record.string_offset, - string, record.string_length) != record.string_length) - goto fail2; - - string[record.string_length] = '\0'; - - if (name_ix == microsoft_ix) - if (record.encoding_id == SYMBOL_ENCODING_ID || - record.encoding_id == UNICODE_ENCODING_ID) - codeset = "UTF-16BE"; - else - codeset = "UCS-4BE"; - else if (name_ix == mac_ix) - codeset = "MacRoman"; - else /* name_ix == unicode_ix */ - codeset = "UCS-4BE"; - - name = g_convert (string, record.string_length, "UTF-8", codeset, NULL, &nbytes, NULL); - if (name == NULL) - goto fail2; - g_free (string); - - PING(("%s", name)); - - SelectObject (pango_win32_hdc, oldhfont); - DeleteObject (hfont); - - return name; - - fail2: - g_free (string); - SelectObject (pango_win32_hdc, oldhfont); - - fail1: - DeleteObject (hfont); - - fail0: - return g_locale_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL); -} - -/***************************** STOLEN FROM PANGO *****************************/ - -static char * -sys_font_to_pango_font (XpThemeClass klazz, XpThemeFont type, char * buf, size_t bufsiz) -{ - HDC hDC; - HWND hwnd; - LOGFONT lf; - int pt_size; - const char * weight; - const char * style; - char * font; - - if (get_system_font(klazz, type, &lf)) - { - switch (lf.lfWeight) { - case FW_THIN: - case FW_EXTRALIGHT: - weight = "Ultra-Light"; - break; - - case FW_LIGHT: - weight = "Light"; - break; - - case FW_BOLD: - weight = "Bold"; - break; - - case FW_SEMIBOLD: - weight = "Semi-Bold"; - break; - - case FW_ULTRABOLD: - weight = "Ultra-Bold"; - break; - - case FW_HEAVY: - weight = "Heavy"; - break; - - default: - weight = ""; - break; - } - - if (lf.lfItalic) - style="Italic"; - else - style=""; - - hwnd = GetDesktopWindow(); - hDC = GetDC(hwnd); - if (hDC) { - pt_size = -MulDiv(lf.lfHeight, 72, - GetDeviceCaps(hDC,LOGPIXELSY)); - ReleaseDC(hwnd, hDC); - } else - pt_size = 10; - - font = get_family_name(&lf, hDC); - g_snprintf(buf, bufsiz, "%s %s %s %d", font, style, weight, pt_size); - g_free(font); - - return buf; - } - - return NULL; -} - -/* missing from ms's header files */ -#ifndef SPI_GETMENUSHOWDELAY -#define SPI_GETMENUSHOWDELAY 106 -#endif - -/* I don't know the proper XP theme class for things like - HIGHLIGHTTEXT, so we'll just define it to be "BUTTON" - for now */ -#define XP_THEME_CLASS_TEXT XP_THEME_CLASS_BUTTON - -static void -setup_menu_settings (void) -{ - int menu_delay; - gboolean win95 = FALSE; - - GtkSettings * settings; - OSVERSIONINFOEX osvi; - - settings = gtk_settings_get_default (); - if (!settings) - return; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if (!GetVersionEx ( (OSVERSIONINFO *) &osvi)) - win95 = TRUE; /* assume the worst */ - - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) - win95 = TRUE; - - if (!win95) { - if (SystemParametersInfo (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0)) { - GObjectClass * klazz = G_OBJECT_GET_CLASS(G_OBJECT(settings)); - - if (klazz) { - if (g_object_class_find_property (klazz, "gtk-menu-bar-popup-delay")) { - g_object_set (G_OBJECT (settings), "gtk-menu-bar-popup-delay", - 0, NULL); - } - if (g_object_class_find_property (klazz, "gtk-menu-popup-delay")) { - g_object_set (G_OBJECT (settings), "gtk-menu-popup-delay", - menu_delay, NULL); - } - if (g_object_class_find_property (klazz, "gtk-menu-popdown-delay")) { - g_object_set (G_OBJECT (settings), "gtk-menu-popdown-delay", - menu_delay, NULL); - } - } - } - } -} - -void -msw_style_setup_system_settings (void) -{ - GtkSettings * settings; - int cursor_blink_time; - - settings = gtk_settings_get_default (); - if (!settings) - return; - - cursor_blink_time = GetCaretBlinkTime (); - g_object_set (G_OBJECT (settings), "gtk-cursor-blink", - cursor_blink_time > 0, NULL); - - if (cursor_blink_time > 0) - { - g_object_set (G_OBJECT (settings), "gtk-cursor-blink-time", - 2*cursor_blink_time, NULL); - } - - g_object_set (G_OBJECT (settings), "gtk-double-click-time", - GetDoubleClickTime(), NULL); - g_object_set (G_OBJECT (settings), "gtk-dnd-drag-threshold", - GetSystemMetrics(SM_CXDRAG), NULL); - - setup_menu_settings (); - - /* - http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp - */ -} - -static void -setup_system_font(GtkStyle *style) -{ - char buf[256], * font; /* It's okay, lfFaceName is smaller than 32 chars */ - - if ((font = sys_font_to_pango_font(XP_THEME_CLASS_TEXT, XP_THEME_FONT_MESSAGE, buf, sizeof (buf))) != NULL) - style->font_desc = pango_font_description_from_string(font); -} - -static void -sys_color_to_gtk_color(XpThemeClass klazz, int id, GdkColor *pcolor) -{ - DWORD color; - - if (!xp_theme_get_system_color (klazz, id, &color)) - color = GetSysColor(id); - - pcolor->pixel = color; - pcolor->red = (GetRValue(color) << 8) | GetRValue(color); - pcolor->green = (GetGValue(color) << 8) | GetGValue(color); - pcolor->blue = (GetBValue(color) << 8) | GetBValue(color); -} - -static int -get_system_metric(XpThemeClass klazz, int id) -{ - int rval; - - if (!xp_theme_get_system_metric(klazz, id, &rval)) - rval = GetSystemMetrics (id); - - return rval; -} - -#if 0 -static void -setup_default_style (void) -{ - GdkColor btnface; - GdkColor highlight; - GdkColor window; - GdkColor windowtext; - GdkColor highlighttext; - GdkColor graytext; - GdkColor btntext; - GdkColor dark; - GdkColor light; - GdkColor mid; - GdkColor text_aa[5]; - - char buf[2048]; - - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &btnface); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &highlight); - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOW, &window); - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &windowtext); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, &highlighttext); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_GRAYTEXT, &graytext); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &btntext); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DSHADOW, &dark); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DHILIGHT, &light); - - mid.red = (light.red + dark.red) / 2; - mid.green = (light.green + dark.green) / 2; - mid.blue = (light.blue + dark.blue) / 2; - - text_aa[0].red = (windowtext.red + window.red) / 2; - text_aa[0].green = (windowtext.green + window.green) / 2; - text_aa[0].blue = (windowtext.blue + window.blue) / 2; - text_aa[1].red = (highlighttext.red + highlight.red) / 2; - text_aa[1].green = (highlighttext.green + highlight.green) / 2; - text_aa[1].blue = (highlighttext.blue + highlight.blue) / 2; - - text_aa[2].red = (graytext.red + btnface.red) / 2; - text_aa[2].green = (graytext.green + btnface.green) / 2; - text_aa[2].blue = (graytext.blue + btnface.blue) / 2; - - text_aa[3].red = (btntext.red + btnface.red) / 2; - text_aa[3].green = (btntext.green + btnface.green) / 2; - text_aa[3].blue = (btntext.blue + btnface.blue) / 2; - - text_aa[4].red = (windowtext.red + window.red) / 2; - text_aa[4].green = (windowtext.green + window.green) / 2; - text_aa[4].blue = (windowtext.blue + window.blue) / 2; - - g_snprintf(buf, sizeof (buf), - "style \"msw-base\" = \"msw-default\"\n" - "{\n" - "bg[NORMAL] = { %d, %d, %d }\n" - "bg[SELECTED] = { %d, %d, %d }\n" - "bg[INSENSITIVE] = { %d, %d, %d }\n" - "bg[ACTIVE] = { %d, %d, %d }\n" - "bg[PRELIGHT] = { %d, %d, %d }\n" - "base[NORMAL] = { %d, %d, %d }\n" - "base[SELECTED] = { %d, %d, %d }\n" - "base[INSENSITIVE] = { %d, %d, %d }\n" - "base[ACTIVE] = { %d, %d, %d }\n" - "base[PRELIGHT] = { %d, %d, %d }\n" - "text[NORMAL] = { %d, %d, %d }\n" - "text[SELECTED] = { %d, %d, %d }\n" - "text[INSENSITIVE] = { %d, %d, %d }\n" - "text[ACTIVE] = { %d, %d, %d }\n" - "text[PRELIGHT] = { %d, %d, %d }\n" - "fg[NORMAL] = { %d, %d, %d }\n" - "fg[SELECTED] = { %d, %d, %d }\n" - "fg[INSENSITIVE] = { %d, %d, %d }\n" - "fg[ACTIVE] = { %d, %d, %d }\n" - "fg[PRELIGHT] = { %d, %d, %d }\n" - "dark[NORMAL] = { %d, %d, %d }\n" - "dark[SELECTED] = { %d, %d, %d }\n" - "dark[INSENSITIVE] = { %d, %d, %d }\n" - "dark[ACTIVE] = { %d, %d, %d }\n" - "dark[PRELIGHT] = { %d, %d, %d }\n" - "light[NORMAL] = { %d, %d, %d }\n" - "light[SELECTED] = { %d, %d, %d }\n" - "light[INSENSITIVE] = { %d, %d, %d }\n" - "light[ACTIVE] = { %d, %d, %d }\n" - "light[PRELIGHT] = { %d, %d, %d }\n" - "text_aa[NORMAL] = { %d, %d, %d }\n" - "text_aa[SELECTED] = { %d, %d, %d }\n" - "text_aa[INSENSITIVE] = { %d, %d, %d }\n" - "text_aa[ACTIVE] = { %d, %d, %d }\n" - "text_aa[PRELIGHT] = { %d, %d, %d }\n" - "}widget_class \"*\" style \"msw-base\"\n", - - /* bg */ - btnface.red, btnface.green, btnface.blue, - highlight.red, highlight.green, highlight.blue, - btnface.red, btnface.green, btnface.blue, - btnface.red, btnface.green, btnface.blue, - btnface.red, btnface.green, btnface.blue, - - /* base */ - window.red, window.green, window.blue, - highlight.red, highlight.green, highlight.blue, - btnface.red, btnface.green, btnface.blue, - btnface.red, btnface.green, btnface.blue, - window.red, window.green, window.blue, - - /* text */ - windowtext.red, windowtext.green, windowtext.blue, - highlighttext.red, highlighttext.green, highlighttext.blue, - graytext.red, graytext.green, graytext.blue, - btntext.red, btntext.green, btntext.blue, - windowtext.red, windowtext.green, windowtext.blue, - - /* fg */ - btntext.red, btntext.green, btntext.blue, - highlighttext.red, highlighttext.green, highlighttext.blue, - graytext.red, graytext.green, graytext.blue, - btntext.red, btntext.green, btntext.blue, - windowtext.red, windowtext.green, windowtext.blue, - - /* dark */ - dark.red, dark.green, dark.blue, - dark.red, dark.green, dark.blue, - dark.red, dark.green, dark.blue, - dark.red, dark.green, dark.blue, - dark.red, dark.green, dark.blue, - - /* light */ - light.red, light.green, light.blue, - light.red, light.green, light.blue, - light.red, light.green, light.blue, - light.red, light.green, light.blue, - light.red, light.green, light.blue, - - /* text_aa */ - text_aa[0].red, text_aa[0].green, text_aa[0].blue, - text_aa[1].red, text_aa[1].green, text_aa[1].blue, - text_aa[2].red, text_aa[2].green, text_aa[2].blue, - text_aa[3].red, text_aa[3].green, text_aa[3].blue, - text_aa[4].red, text_aa[4].green, text_aa[4].blue - ); - gtk_rc_parse_string(buf); -} -#endif - -static void -setup_msw_rc_style(void) -{ - /* TODO: Owen says: - "If your setup_system_styles() function called gtk_rc_parse_string(), then you are just piling a new set of strings on top each time the theme changes .. the old ones won't be removed" */ - - char buf[1024], font_buf[256], *font_ptr; - - GdkColor menu_color; - GdkColor menu_text_color; - GdkColor tooltip_back; - GdkColor tooltip_fore; - GdkColor btn_fore; - GdkColor btn_face; - GdkColor progress_back; - - GdkColor fg_prelight; - GdkColor bg_prelight; - GdkColor base_prelight; - GdkColor text_prelight; - - NONCLIENTMETRICS nc; - - /* Prelight */ - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, &fg_prelight); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &bg_prelight); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &base_prelight); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, &text_prelight); - - sys_color_to_gtk_color(XP_THEME_CLASS_MENU, COLOR_MENUTEXT, &menu_text_color); - sys_color_to_gtk_color(XP_THEME_CLASS_MENU, COLOR_MENU, &menu_color); - - /* tooltips */ - sys_color_to_gtk_color(XP_THEME_CLASS_TOOLTIP, COLOR_INFOTEXT, &tooltip_fore); - sys_color_to_gtk_color(XP_THEME_CLASS_TOOLTIP, COLOR_INFOBK, &tooltip_back); - - /* text on push buttons. TODO: button shadows, backgrounds, and highlights */ - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &btn_fore); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &btn_face); - - /* progress bar background color */ - sys_color_to_gtk_color(XP_THEME_CLASS_PROGRESS, COLOR_HIGHLIGHT, &progress_back); - - /* Enable coloring for menus. */ - font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_MENU, XP_THEME_FONT_MENU,font_buf, sizeof (font_buf)); - g_snprintf(buf, sizeof (buf), - "style \"msw-menu\" = \"msw-default\"\n" - "{\n" - "fg[PRELIGHT] = { %d, %d, %d }\n" - "bg[PRELIGHT] = { %d, %d, %d }\n" - "text[PRELIGHT] = { %d, %d, %d }\n" - "base[PRELIGHT] = { %d, %d, %d }\n" - "fg[NORMAL] = { %d, %d, %d }\n" - "bg[NORMAL] = { %d, %d, %d }\n" - "%s = \"%s\"\n" - "}widget_class \"*MenuItem*\" style \"msw-menu\"\n" - "widget_class \"*GtkMenu\" style \"msw-menu\"\n" - "widget_class \"*GtkMenuShell*\" style \"msw-menu\"\n", - fg_prelight.red, - fg_prelight.green, - fg_prelight.blue, - bg_prelight.red, - bg_prelight.green, - bg_prelight.blue, - text_prelight.red, - text_prelight.green, - text_prelight.blue, - base_prelight.red, - base_prelight.green, - base_prelight.blue, - menu_text_color.red, - menu_text_color.green, - menu_text_color.blue, - menu_color.red, - menu_color.green, - menu_color.blue, - (font_ptr ? "font_name" : "#"), - (font_ptr ? font_ptr : " font name should go here")); - gtk_rc_parse_string(buf); - - /* Enable coloring for menu bars. */ - font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_MENU, XP_THEME_FONT_MENU,font_buf, sizeof (font_buf)); - g_snprintf(buf, sizeof (buf), - "style \"msw-menu-bar\" = \"msw-menu\"\n" - "{\n" - "bg[NORMAL] = { %d, %d, %d }\n" - "}widget_class \"*MenuBar*\" style \"msw-menu-bar\"\n", - btn_face.red, - btn_face.green, - btn_face.blue); - gtk_rc_parse_string(buf); - - /* enable tooltip fonts */ - font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,font_buf, sizeof (font_buf)); - g_snprintf(buf, sizeof (buf), - "style \"msw-tooltips-caption\" = \"msw-default\"\n" - "{fg[NORMAL] = { %d, %d, %d }\n" - "%s = \"%s\"\n" - "}widget \"gtk-tooltips.GtkLabel\" style \"msw-tooltips-caption\"\n", - tooltip_fore.red, - tooltip_fore.green, - tooltip_fore.blue, - (font_ptr ? "font_name" : "#"), - (font_ptr ? font_ptr : " font name should go here")); - gtk_rc_parse_string(buf); - - g_snprintf(buf, sizeof (buf), - "style \"msw-tooltips\" = \"msw-default\"\n" - "{bg[NORMAL] = { %d, %d, %d }\n" - "}widget \"gtk-tooltips*\" style \"msw-tooltips\"\n", - tooltip_back.red, - tooltip_back.green, - tooltip_back.blue); - gtk_rc_parse_string(buf); - - /* enable font theming for status bars */ - font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,font_buf, sizeof (font_buf)); - g_snprintf(buf, sizeof (buf), - "style \"msw-status\" = \"msw-default\"\n" - "{%s = \"%s\"\n" - "bg[NORMAL] = { %d, %d, %d }\n" - "}widget_class \"*Status*\" style \"msw-status\"\n", - (font_ptr ? "font_name" : "#"), - (font_ptr ? font_ptr : " font name should go here"), - btn_face.red, btn_face.green, btn_face.blue); - gtk_rc_parse_string(buf); - - /* enable coloring for text on buttons - TODO: use GetThemeMetric for the border and outside border */ - g_snprintf(buf, sizeof (buf), - "style \"msw-button\" = \"msw-default\"\n" - "{\n" - "bg[NORMAL] = { %d, %d, %d }\n" - "bg[PRELIGHT] = { %d, %d, %d }\n" - "bg[INSENSITIVE] = { %d, %d, %d }\n" - "fg[PRELIGHT] = { %d, %d, %d }\n" - "GtkButton::default-border = { 1, 1, 1, 1 }\n" - "GtkButton::default-outside-border = { 0, 0, 0, 0 }\n" - "GtkButton::child-displacement-x = 1\n" - "GtkButton::child-displacement-y = 1\n" - "}widget_class \"*Button*\" style \"msw-button\"\n", - btn_face.red, btn_face.green, btn_face.blue, - btn_face.red, btn_face.green, btn_face.blue, - btn_face.red, btn_face.green, btn_face.blue, - btn_fore.red, btn_fore.green, btn_fore.blue - ); - gtk_rc_parse_string(buf); - - /* enable coloring for progress bars */ - g_snprintf(buf, sizeof (buf), - "style \"msw-progress\" = \"msw-default\"\n" - "{bg[PRELIGHT] = { %d, %d, %d }\n" - "bg[NORMAL] = { %d, %d, %d }\n" - "}widget_class \"*Progress*\" style \"msw-progress\"\n", - progress_back.red, - progress_back.green, - progress_back.blue, - btn_face.red, btn_face.green, btn_face.blue); - gtk_rc_parse_string(buf); - - /* scrollbar thumb width and height */ - g_snprintf(buf, sizeof (buf), - "style \"msw-vscrollbar\" = \"msw-default\"\n" - "{GtkRange::slider-width = %d\n" - "GtkRange::stepper-size = %d\n" - "GtkRange::stepper-spacing = 0\n" - "GtkRange::trough_border = 0\n" - "}widget_class \"*VScrollbar*\" style \"msw-vscrollbar\"\n", - GetSystemMetrics(SM_CYVTHUMB), - get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL)); - gtk_rc_parse_string(buf); - - g_snprintf(buf, sizeof (buf), - "style \"msw-hscrollbar\" = \"msw-default\"\n" - "{GtkRange::slider-width = %d\n" - "GtkRange::stepper-size = %d\n" - "GtkRange::stepper-spacing = 0\n" - "GtkRange::trough_border = 0\n" - "}widget_class \"*HScrollbar*\" style \"msw-hscrollbar\"\n", - GetSystemMetrics(SM_CXHTHUMB), - get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL)); - gtk_rc_parse_string(buf); - - /* radio/check button sizes */ - g_snprintf(buf, sizeof (buf), - "style \"msw-checkbutton\" = \"msw-button\"\n" - "{GtkCheckButton::indicator-size = 13\n" - "}widget_class \"*CheckButton*\" style \"msw-checkbutton\"\n" - "widget_class \"*RadioButton*\" style \"msw-checkbutton\"\n"); - gtk_rc_parse_string(buf); -} - -static void -setup_system_styles(GtkStyle *style) -{ - int i; - - /* Default background */ - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &style->bg[GTK_STATE_NORMAL]); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &style->bg[GTK_STATE_SELECTED]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &style->bg[GTK_STATE_INSENSITIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &style->bg[GTK_STATE_ACTIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &style->bg[GTK_STATE_PRELIGHT]); - - /* Default base */ - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOW, &style->base[GTK_STATE_NORMAL]); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &style->base[GTK_STATE_SELECTED]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &style->base[GTK_STATE_INSENSITIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &style->base[GTK_STATE_ACTIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOW, &style->base[GTK_STATE_PRELIGHT]); - - /* Default text */ - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->text[GTK_STATE_NORMAL]); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, &style->text[GTK_STATE_SELECTED]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_GRAYTEXT, &style->text[GTK_STATE_INSENSITIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &style->text[GTK_STATE_ACTIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->text[GTK_STATE_PRELIGHT]); - - /* Default forgeground */ - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &style->fg[GTK_STATE_NORMAL]); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, &style->fg[GTK_STATE_SELECTED]); - sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_GRAYTEXT, &style->fg[GTK_STATE_INSENSITIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &style->fg[GTK_STATE_ACTIVE]); - sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->fg[GTK_STATE_PRELIGHT]); - - for (i = 0; i < 5; i++) - { - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DSHADOW, &style->dark[i]); - sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DHILIGHT, &style->light[i]); - - style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2; - style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2; - style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2; - - style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2; - style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2; - style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2; - } -} - -static gboolean -sanitize_size (GdkWindow *window, - gint *width, - gint *height) -{ - gboolean set_bg = FALSE; - - if ((*width == -1) && (*height == -1)) - { - set_bg = GDK_IS_WINDOW (window); - gdk_window_get_size (window, width, height); - } - else if (*width == -1) - gdk_window_get_size (window, width, NULL); - else if (*height == -1) - gdk_window_get_size (window, NULL, height); - - return set_bg; -} - -static XpThemeElement -map_gtk_progress_bar_to_xp(GtkProgressBar *progress_bar, gboolean trough) -{ - XpThemeElement ret; - switch (progress_bar->orientation) - { - case GTK_PROGRESS_LEFT_TO_RIGHT: - case GTK_PROGRESS_RIGHT_TO_LEFT: - ret = trough - ? XP_THEME_ELEMENT_PROGRESS_TROUGH_H - : XP_THEME_ELEMENT_PROGRESS_BAR_H; - break; - default: - ret = trough - ? XP_THEME_ELEMENT_PROGRESS_TROUGH_V - : XP_THEME_ELEMENT_PROGRESS_BAR_V; - break; - } - return ret; -} - -static void -draw_part (GdkDrawable *drawable, - GdkGC *gc, - GdkRectangle *area, - gint x, - gint y, - Part part) -{ - if (area) - gdk_gc_set_clip_rectangle (gc, area); - - if (!parts[part].bmap) - parts[part].bmap = gdk_bitmap_create_from_data (drawable, - parts[part].bits, - PART_SIZE, PART_SIZE); - - gdk_gc_set_ts_origin (gc, x, y); - gdk_gc_set_stipple (gc, parts[part].bmap); - gdk_gc_set_fill (gc, GDK_STIPPLED); - - gdk_draw_rectangle (drawable, gc, TRUE, x, y, PART_SIZE, PART_SIZE); - - gdk_gc_set_fill (gc, GDK_SOLID); - - if (area) - gdk_gc_set_clip_rectangle (gc, NULL); -} - -static void -draw_check(GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - x -= (1 + PART_SIZE - width) / 2; - y -= (1 + PART_SIZE - height) / 2; - - if (detail && strcmp (detail, "check") == 0) /* Menu item */ - { - if (shadow == GTK_SHADOW_IN) - { - draw_part (window, style->black_gc, area, x, y, CHECK_TEXT); - draw_part (window, style->dark_gc[state], area, x, y, CHECK_AA); - } - } - else - { - if (xp_theme_draw(window, shadow == GTK_SHADOW_IN - ? XP_THEME_ELEMENT_PRESSED_CHECKBOX - : XP_THEME_ELEMENT_CHECKBOX, - style, x, y, width, height, state, area)) - { - } - else - { - draw_part (window, style->black_gc, area, x, y, CHECK_BLACK); - draw_part (window, style->dark_gc[state], area, x, y, CHECK_DARK); - draw_part (window, style->mid_gc[state], area, x, y, CHECK_MID); - draw_part (window, style->light_gc[state], area, x, y, CHECK_LIGHT); - draw_part (window, style->base_gc[state], area, x, y, CHECK_BASE); - - if (shadow == GTK_SHADOW_IN) - { - draw_part (window, style->text_gc[state], area, x, y, CHECK_TEXT); - draw_part (window, style->text_aa_gc[state], area, x, y, CHECK_AA); - } - } - } -} - -static void -draw_expander(GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - GtkExpanderStyle expander_style) -{ - gint expander_size; - gint expander_semi_size; - GdkColor color; - GdkGCValues values; - gboolean success; - XpThemeElement xp_expander; - - gtk_widget_style_get (widget, "expander_size", &expander_size, NULL); - - switch (expander_style) - { - case GTK_EXPANDER_COLLAPSED: - case GTK_EXPANDER_SEMI_COLLAPSED: - xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED; - break; - default: - xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED; - break; - } - - if ((expander_size % 2) == 0) - expander_size--; - - if (expander_size > 2) - expander_size -= 2; - - if (area) - gdk_gc_set_clip_rectangle (style->fg_gc[state], area); - - expander_semi_size = expander_size / 2; - x -= expander_semi_size; - y -= expander_semi_size; - - gdk_gc_get_values (style->fg_gc[state], &values); - - if (! xp_theme_draw(window, xp_expander, style, - x, y, - expander_size, expander_size, state, area)) - { - /* RGB values to emulate Windows Classic style */ - color.red = color.green = color.blue = 128 << 8; - - success = gdk_colormap_alloc_color - (gtk_widget_get_default_colormap (), &color, FALSE, TRUE); - - if (success) - gdk_gc_set_foreground (style->fg_gc[state], &color); - - gdk_draw_rectangle - (window, style->fg_gc[state], FALSE, x, y, - expander_size - 1, expander_size - 1); - - gdk_draw_line - (window, style->fg_gc[state], x + 2, y + expander_semi_size, - x + expander_size - 2, y + expander_semi_size); - - switch (expander_style) - { - case GTK_EXPANDER_COLLAPSED: - case GTK_EXPANDER_SEMI_COLLAPSED: - gdk_draw_line - (window, style->fg_gc[state], x + expander_semi_size, y + 2, - x + expander_semi_size, y + expander_size - 2); - break; - } - - if (success) - gdk_gc_set_foreground (style->fg_gc[state], &values.foreground); - } - - if (area) - gdk_gc_set_clip_rectangle (style->fg_gc[state], NULL); -} - -static void -draw_option(GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - x -= (1 + PART_SIZE - width) / 2; - y -= (1 + PART_SIZE - height) / 2; - - if (detail && strcmp (detail, "option") == 0) /* Menu item */ - { - if (shadow == GTK_SHADOW_IN) - draw_part (window, style->fg_gc[state], area, x, y, RADIO_TEXT); - } - else - { - if (xp_theme_draw (window, shadow == GTK_SHADOW_IN - ? XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON - : XP_THEME_ELEMENT_RADIO_BUTTON, - style, x, y, width, height, state, area)) - { - } - else - { - draw_part (window, style->black_gc, area, x, y, RADIO_BLACK); - draw_part (window, style->dark_gc[state], area, x, y, RADIO_DARK); - draw_part (window, style->mid_gc[state], area, x, y, RADIO_MID); - draw_part (window, style->light_gc[state], area, x, y, RADIO_LIGHT); - draw_part (window, style->base_gc[state], area, x, y, RADIO_BASE); - - if (shadow == GTK_SHADOW_IN) - draw_part (window, style->text_gc[state], area, x, y, RADIO_TEXT); - } - } -} - -static void -draw_varrow (GdkWindow *window, - GdkGC *gc, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkArrowType arrow_type, - gint x, - gint y, - gint width, - gint height) -{ - gint steps, extra; - gint y_start, y_increment; - gint i; - - if (area) - gdk_gc_set_clip_rectangle (gc, area); - - width = width + width % 2 - 1; /* Force odd */ - - steps = 1 + width / 2; - - extra = height - steps; - - if (arrow_type == GTK_ARROW_DOWN) - { - y_start = y; - y_increment = 1; - } - else - { - y_start = y + height - 1; - y_increment = -1; - } - -#if 0 - for (i = 0; i < extra; i++) - { - gdk_draw_line (window, gc, - x, y_start + i * y_increment, - x + width - 1, y_start + i * y_increment); - } -#endif - for (i = extra; i < height; i++) - { - gdk_draw_line (window, gc, - x + (i - extra), y_start + i * y_increment, - x + width - (i - extra) - 1, y_start + i * y_increment); - } - - - if (area) - gdk_gc_set_clip_rectangle (gc, NULL); -} - -static void -draw_harrow (GdkWindow *window, - GdkGC *gc, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkArrowType arrow_type, - gint x, - gint y, - gint width, - gint height) -{ - gint steps, extra; - gint x_start, x_increment; - gint i; - - if (area) - gdk_gc_set_clip_rectangle (gc, area); - - height = height + height % 2 - 1; /* Force odd */ - - steps = 1 + height / 2; - - extra = width - steps; - - if (arrow_type == GTK_ARROW_RIGHT) - { - x_start = x; - x_increment = 1; - } - else - { - x_start = x + width - 1; - x_increment = -1; - } - -#if 0 - for (i = 0; i < extra; i++) - { - gdk_draw_line (window, gc, - x_start + i * x_increment, y, - x_start + i * x_increment, y + height - 1); - } -#endif - for (i = extra; i < width; i++) - { - gdk_draw_line (window, gc, - x_start + i * x_increment, y + (i - extra), - x_start + i * x_increment, y + height - (i - extra) - 1); - } - - - if (area) - gdk_gc_set_clip_rectangle (gc, NULL); -} - -/* This function makes up for some brokeness in gtkrange.c - * where we never get the full arrow of the stepper button - * and the type of button in a single drawing function. - * - * It doesn't work correctly when the scrollbar is squished - * to the point we don't have room for full-sized steppers. - */ -static void -reverse_engineer_stepper_box (GtkWidget *range, - GtkArrowType arrow_type, - gint *x, - gint *y, - gint *width, - gint *height) -{ - gint slider_width = 14, stepper_size = 14; - gint box_width; - gint box_height; - - if (range) - { - gtk_widget_style_get (range, - "slider_width", &slider_width, - "stepper_size", &stepper_size, - NULL); - } - - if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) - { - box_width = slider_width; - box_height = stepper_size; - } - else - { - box_width = stepper_size; - box_height = slider_width; - } - - *x = *x - (box_width - *width) / 2; - *y = *y - (box_height - *height) / 2; - *width = box_width; - *height = box_height; -} - -static void -draw_arrow (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - GtkArrowType arrow_type, - gboolean fill, - gint x, - gint y, - gint width, - gint height) -{ - const gchar * name; - - name = gtk_widget_get_name (widget); - - sanitize_size (window, &width, &height); - - if (detail && strcmp (detail, "spinbutton") == 0) - { - if (xp_theme_is_drawable(XP_THEME_ELEMENT_SPIN_BUTTON_UP)) - { - return; - } - else - { - x += (width - 7) / 2; - - if (arrow_type == GTK_ARROW_UP) - y += (height - 4) / 2; - else - y += (1 + height - 4) / 2; - draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type, - x, y, 7, 4); - } - } - else if (detail && (!strcmp (detail, "vscrollbar") - || !strcmp (detail, "hscrollbar"))) - { - gint box_x = x; - gint box_y = y; - gint box_width = width; - gint box_height = height; - XpThemeElement xp_arrow; - reverse_engineer_stepper_box (widget, arrow_type, - &box_x, &box_y, &box_width, &box_height); - - switch (arrow_type) - { - case GTK_ARROW_UP: - xp_arrow = XP_THEME_ELEMENT_ARROW_UP; - break; - case GTK_ARROW_DOWN: - xp_arrow = XP_THEME_ELEMENT_ARROW_DOWN; - break; - case GTK_ARROW_LEFT: - xp_arrow = XP_THEME_ELEMENT_ARROW_LEFT; - break; - default: - xp_arrow = XP_THEME_ELEMENT_ARROW_RIGHT; - break; - } - if (xp_theme_draw(window, xp_arrow, style, box_x, box_y, box_width, box_height, state, area)) - { - } - else if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) - { - x += (width - 7) / 2; - y += (height - 5) / 2; - - draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type, - x, y, 7, 5); - } - else - { - y += (height - 7) / 2; - x += (width - 5) / 2; - - draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type, - x, y, 5, 7); - } - } - else - { - /* draw the toolbar chevrons - waiting for GTK 2.4 */ - if (name && !strcmp (name, "gtk-toolbar-arrow")) - { - if (xp_theme_draw(window, XP_THEME_ELEMENT_REBAR_CHEVRON, style, x, y, width, height, state, area)) - return; - } - - if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) - { - x += (width - 7) / 2; - y += (height - 5) / 2; - - draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type, - x, y, 7, 5); - } - else - { - x += (width - 5) / 2; - y += (height - 7) / 2; - - draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type, - x, y, 5, 7); - } - } -} - -static void -option_menu_get_props (GtkWidget *widget, - GtkRequisition *indicator_size, - GtkBorder *indicator_spacing) -{ - GtkRequisition *tmp_size = NULL; - GtkBorder *tmp_spacing = NULL; - - if (widget) - gtk_widget_style_get (widget, - "indicator_size", &tmp_size, - "indicator_spacing", &tmp_spacing, - NULL); - - if (tmp_size) - { - *indicator_size = *tmp_size; - g_free (tmp_size); - } - else - *indicator_size = default_option_indicator_size; - - if (tmp_spacing) - { - *indicator_spacing = *tmp_spacing; - g_free (tmp_spacing); - } - else - *indicator_spacing = default_option_indicator_spacing; -} - -static void -draw_box (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - if (detail && - (!strcmp (detail, "button") || - !strcmp (detail, "buttondefault"))) - { - if (GTK_IS_TREE_VIEW (widget->parent) || GTK_IS_CLIST (widget->parent)) - { - if (xp_theme_draw(window, XP_THEME_ELEMENT_LIST_HEADER, style, x, y, - width, height, state_type, area)) - return; - } - else if (GTK_IS_TOOLBAR (widget->parent)) - { - if (xp_theme_draw(window, XP_THEME_ELEMENT_TOOLBAR_BUTTON, style, x, y, - width, height, state_type, area)) - return; - } - else - { - gboolean is_default = !strcmp (detail, "buttondefault"); - if (xp_theme_draw(window, is_default ? XP_THEME_ELEMENT_DEFAULT_BUTTON - : XP_THEME_ELEMENT_BUTTON, style, x, y, - width, height, state_type, area)) - return; - } - } - else if (detail && !strcmp (detail, "spinbutton")) - { - if (xp_theme_is_drawable(XP_THEME_ELEMENT_SPIN_BUTTON_UP)) - { - return; - } - } - else if (detail && (!strcmp (detail, "spinbutton_up") - || !strcmp (detail, "spinbutton_down"))) - { - if (xp_theme_draw(window, - (! strcmp (detail, "spinbutton_up")) - ? XP_THEME_ELEMENT_SPIN_BUTTON_UP - : XP_THEME_ELEMENT_SPIN_BUTTON_DOWN, - style, x, y, width, height, state_type, area)) - { - return; - } - } - - else if (detail && !strcmp (detail, "slider")) - { - if (GTK_IS_SCROLLBAR(widget)) - { - GtkScrollbar * scrollbar = GTK_SCROLLBAR(widget); - gboolean is_v = GTK_IS_VSCROLLBAR(widget); - if (xp_theme_draw(window, - is_v - ? XP_THEME_ELEMENT_SCROLLBAR_V - : XP_THEME_ELEMENT_SCROLLBAR_H, - style, x, y, width, height, state_type, area)) - { - XpThemeElement gripper = (is_v ? XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V : XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H); - - /* Do not display grippers on tiny scroll bars, the limit imposed - is rather arbitrary, perhaps we can fetch the gripper geometry - from somewhere and use that... */ - if ((gripper == XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H && width < 16) - || (gripper == XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V && height < 16)) - { - return; - } - - xp_theme_draw(window, gripper, style, x, y, width, height, state_type, area); - return; - } - } - } - else if (detail && !strcmp (detail, "bar")) - { - if (widget && GTK_IS_PROGRESS_BAR (widget)) - { - GtkProgressBar *progress_bar = GTK_PROGRESS_BAR(widget); - XpThemeElement xp_progress_bar = map_gtk_progress_bar_to_xp (progress_bar, FALSE); - if (xp_theme_draw (window, xp_progress_bar, - style, x, y, width, height, state_type, area)) - { - return; - } - } - } - else if (detail && !strcmp (detail, "handlebox_bin")) { - if (xp_theme_draw (window, XP_THEME_ELEMENT_REBAR, style, x, y, width, height, state_type, area)) - { - return; - } - } - else if (detail && strcmp (detail, "menuitem") == 0) { - shadow_type = GTK_SHADOW_NONE; - if (xp_theme_draw (window, XP_THEME_ELEMENT_MENU_ITEM, style, x, y, width, height, state_type, area)) - { - return; - } - } - else if (detail && !strcmp (detail, "trough")) - { - if (widget && GTK_IS_PROGRESS_BAR (widget)) - { - GtkProgressBar *progress_bar = GTK_PROGRESS_BAR(widget); - XpThemeElement xp_progress_bar = map_gtk_progress_bar_to_xp (progress_bar, TRUE); - if (xp_theme_draw (window, xp_progress_bar, - style, x, y, width, height, state_type, area)) - { - return; - } - else - { - /* Blank in classic Windows */ - } - } - else if (widget && GTK_IS_SCROLLBAR(widget)) - { - gboolean is_vertical = GTK_IS_VSCROLLBAR(widget); - - if (GTK_IS_RANGE(widget) - && xp_theme_draw(window, - is_vertical - ? XP_THEME_ELEMENT_TROUGH_V - : XP_THEME_ELEMENT_TROUGH_H, - style, - x, y, width, height, state_type, area)) - { - return; - } - else - { - GdkGCValues gc_values; - GdkGC *gc; - GdkPixmap *pixmap; - - sanitize_size (window, &width, &height); - - pixmap = gdk_pixmap_new (window, 2, 2, -1); - - gdk_draw_point (pixmap, style->bg_gc[GTK_STATE_NORMAL], 0, 0); - gdk_draw_point (pixmap, style->bg_gc[GTK_STATE_NORMAL], 1, 1); - gdk_draw_point (pixmap, style->light_gc[GTK_STATE_NORMAL], 1, 0); - gdk_draw_point (pixmap, style->light_gc[GTK_STATE_NORMAL], 0, 1); - - gc_values.fill = GDK_TILED; - gc_values.tile = pixmap; - gc_values.ts_x_origin = x; - gc_values.ts_y_origin = y; - gc = gdk_gc_new_with_values (window, &gc_values, - GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN | GDK_GC_FILL | GDK_GC_TILE); - - if (area) - gdk_gc_set_clip_rectangle (gc, area); - - gdk_draw_rectangle (window, gc, TRUE, x, y, width, height); - - gdk_gc_unref (gc); - gdk_pixmap_unref (pixmap); - - return; - } - } - else if (widget && GTK_IS_SCALE(widget)) - { - gboolean is_vertical = GTK_IS_VSCALE(widget); - - parent_class->draw_box (style, window, state_type, GTK_SHADOW_NONE, area, - widget, detail, x, y, width, height); - - if(is_vertical) - parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, (2 * x + width)/2, y, 1, height); - else - parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, x, (2 * y + height)/2, width, 1); - - return; - } - } - else if (detail && strcmp (detail, "optionmenu") == 0) - { - if (xp_theme_draw(window, XP_THEME_ELEMENT_EDIT_TEXT, - style, x, y, width, height, state_type, area)) - { - return; - } - } - else if (detail && (strcmp (detail, "vscrollbar") == 0 || strcmp (detail, "hscrollbar") == 0)) - { - if (shadow_type == GTK_SHADOW_IN) - shadow_type = GTK_SHADOW_ETCHED_IN; - } - else - { - const gchar * name = gtk_widget_get_name (widget); - - if (name && !strcmp (name, "gtk-tooltips")) { - if (xp_theme_draw (window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width, height, state_type, area)) - { - return; - } - } - } - - parent_class->draw_box (style, window, state_type, shadow_type, area, - widget, detail, x, y, width, height); - - if (detail && strcmp (detail, "optionmenu") == 0) - { - GtkRequisition indicator_size; - GtkBorder indicator_spacing; - gint vline_x; - - option_menu_get_props (widget, &indicator_size, &indicator_spacing); - - sanitize_size (window, &width, &height); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - vline_x = x + indicator_size.width + indicator_spacing.left + indicator_spacing.right; - else - vline_x = x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness; - - parent_class->draw_vline (style, window, state_type, area, widget, - detail, - y + style->ythickness + 1, - y + height - style->ythickness - 3, - vline_x); - } -} - -static void -draw_tab (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - GtkRequisition indicator_size; - GtkBorder indicator_spacing; - - gint arrow_height; - - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - if (detail && ! strcmp (detail, "optionmenutab")) - { - if (xp_theme_draw(window, XP_THEME_ELEMENT_COMBOBUTTON, - style, x-5, widget->allocation.y+1, - width+10, widget->allocation.height-2, state, area)) - { - return; - } - } - - if (widget) - gtk_widget_style_get (widget, "indicator_size", &indicator_size, NULL); - - option_menu_get_props (widget, &indicator_size, &indicator_spacing); - - x += (width - indicator_size.width) / 2; - arrow_height = (indicator_size.width + 1) / 2; - - y += (height - arrow_height) / 2; - - draw_varrow (window, style->black_gc, shadow, area, GTK_ARROW_DOWN, - x, y, indicator_size.width, arrow_height); -} - -/* this is an undefined magic value that, according to the mozilla folks, - worked for all the various themes that they tried */ -#define XP_EDGE_SIZE 2 - -static void -draw_extension(GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkPositionType gap_side) -{ - if (detail && !strcmp(detail, "tab")) - { - GtkNotebook *notebook = GTK_NOTEBOOK(widget); - GtkPositionType pos_type = gtk_notebook_get_tab_pos(notebook); - - if (pos_type == GTK_POS_TOP && state_type == GTK_STATE_NORMAL) - height += XP_EDGE_SIZE; - -#if 0 - /* FIXME: pos != TOP to be implemented */ - else if (pos_type == GTK_POS_BOTTOM) - y -= XP_EDGE_SIZE; - else if (pos_type == GTK_POS_RIGHT) - width += XP_EDGE_SIZE; - else if (pos_type == GTK_POS_LEFT) - height -= XP_EDGE_SIZE; -#endif - - if (pos_type == GTK_POS_TOP - && xp_theme_draw - (window, gtk_notebook_get_current_page(notebook)==0 - ? XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE - : XP_THEME_ELEMENT_TAB_ITEM, - style, x, y, width, height, state_type, area)) - { - return; - } - } - parent_class->draw_extension - (style, window, state_type, shadow_type, area, widget, detail, - x, y, width, height, gap_side); -} - -static void -draw_box_gap (GtkStyle *style, GdkWindow *window, GtkStateType state_type, - GtkShadowType shadow_type, GdkRectangle *area, - GtkWidget *widget, const gchar *detail, gint x, - gint y, gint width, gint height, GtkPositionType gap_side, - gint gap_x, gint gap_width) -{ - if (detail && !strcmp(detail, "notebook")) - { - GtkNotebook *notebook = GTK_NOTEBOOK(widget); - - /* FIXME: pos != TOP to be implemented */ - if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP && xp_theme_draw(window, XP_THEME_ELEMENT_TAB_PANE, style, x, y, width, height, - state_type, area)) - { - return; - } - } - parent_class->draw_box_gap(style, window, state_type, shadow_type, - area, widget, detail, x, y, width, height, - gap_side, gap_x, gap_width); -} - -static void -draw_flat_box (GtkStyle *style, GdkWindow *window, - GtkStateType state_type, GtkShadowType shadow_type, - GdkRectangle *area, GtkWidget *widget, - const gchar *detail, gint x, gint y, - gint width, gint height) -{ - if (detail && ! strcmp (detail, "checkbutton")) - { - if (state_type == GTK_STATE_PRELIGHT) - { - return; - } - } - - parent_class->draw_flat_box(style, window, state_type, shadow_type, - area, widget, detail, x, y, width, height); -} - -static void -draw_shadow (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - if(detail && ! strcmp(detail, "entry")) - { - if (xp_theme_draw(window, XP_THEME_ELEMENT_EDIT_TEXT, style, - x, y, width, height, state_type, area)) - { - return; - } - } - parent_class->draw_shadow (style, window, state_type, shadow_type, area, widget, - detail, x, y, width, height); -} - -static void -draw_hline (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x1, - gint x2, - gint y) -{ - - if (detail && !strcmp(detail, "menuitem")) { - if (xp_theme_draw(window, XP_THEME_ELEMENT_MENU_SEPARATOR, style, - x1, y, x2, style->ythickness, state_type, area)) { - return; - } - } - - parent_class->draw_hline (style, window, state_type, area, widget, - detail, x1, x2, y); -} - -static void -draw_vline (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint y1, - gint y2, - gint x) -{ - parent_class->draw_vline (style, window, state_type, area, widget, - detail, y1, y2, x); -} - -static void -draw_resize_grip (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - GdkWindowEdge edge, - gint x, - gint y, - gint width, - gint height) -{ - if (detail && !strcmp(detail, "statusbar")) { - if (!xp_theme_draw(window, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width, height, - state_type, area)) - return; - } - - parent_class->draw_resize_grip (style, window, state_type, area, - widget, detail, edge, x, y, width, height); -} - -static void -draw_handle (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) -{ - if (! GTK_IS_HANDLE_BOX (widget)) - { - XpThemeElement hndl; - - sanitize_size (window, &width, &height); - - if (orientation == GTK_ORIENTATION_VERTICAL) - hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_V; - else - hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_H; - - if (xp_theme_draw (window, hndl, style, x, y, width, height, - state_type, area)) - { - return; - } - /* grippers are just flat boxes when they're not a toolbar */ - parent_class->draw_box (style, window, state_type, shadow_type, - area, widget, detail, x, y, width, height); - } - else - { - /* TODO: Draw handle boxes as double lines: || */ - parent_class->draw_handle (style, window, state_type, shadow_type, - area, widget, detail, x, y, width, height, - orientation); - } -} - -static void -msw_style_init_from_rc (GtkStyle * style, GtkRcStyle * rc_style) -{ - setup_system_font (style); - setup_menu_settings (); - setup_system_styles (style); - parent_class->init_from_rc(style, rc_style); -} - -static void -msw_style_class_init (MswStyleClass *klass) -{ - GtkStyleClass *style_class = GTK_STYLE_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - style_class->init_from_rc = msw_style_init_from_rc; - style_class->draw_arrow = draw_arrow; - style_class->draw_box = draw_box; - style_class->draw_check = draw_check; - style_class->draw_option = draw_option; - style_class->draw_tab = draw_tab; - style_class->draw_flat_box = draw_flat_box; - style_class->draw_expander = draw_expander; - style_class->draw_extension = draw_extension; - style_class->draw_box_gap = draw_box_gap; - style_class->draw_shadow = draw_shadow; - style_class->draw_hline = draw_hline; - style_class->draw_vline = draw_vline; - style_class->draw_handle = draw_handle; - style_class->draw_resize_grip = draw_resize_grip; -} - -GType msw_type_style = 0; - -void -msw_style_register_type (GTypeModule *module) -{ - static const GTypeInfo object_info = - { - sizeof (MswStyleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) msw_style_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (MswStyle), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - }; - - msw_type_style = g_type_module_register_type (module, - GTK_TYPE_STYLE, - "MswStyle", - &object_info, 0); -} - -void -msw_style_init (void) -{ - xp_theme_init (); - msw_style_setup_system_settings (); - setup_msw_rc_style (); -} diff --git a/modules/engines/ms-windows/msw_style.h b/modules/engines/ms-windows/msw_style.h deleted file mode 100755 index 0c959a7e74..0000000000 --- a/modules/engines/ms-windows/msw_style.h +++ /dev/null @@ -1,54 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * Includes code adapted from redmond95 by Owen Taylor, and - * gtk-nativewin by Evan Martin - * - * 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. - */ - -#ifndef MSW_STYLE_H -#define MSW_STYLE_H - -#include - -typedef struct _MswStyle MswStyle; -typedef struct _MswStyleClass MswStyleClass; - -extern GType msw_type_style; - -#define MSW_TYPE_STYLE msw_type_style -#define MSW_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MSW_TYPE_STYLE, MswStyle)) -#define MSW_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MSW_TYPE_STYLE, MswStyleClass)) -#define MSW_IS_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MSW_TYPE_STYLE)) -#define MSW_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MSW_TYPE_STYLE)) -#define MSW_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MSW_TYPE_STYLE, MswStyleClass)) - -struct _MswStyle -{ - GtkStyle parent_instance; -}; - -struct _MswStyleClass -{ - GtkStyleClass parent_class; -}; - -void msw_style_register_type (GTypeModule *module); -void msw_style_init (void); -void msw_style_setup_system_settings (void); - -#endif /* MSW_TYPE_STYLE */ diff --git a/modules/engines/ms-windows/msw_theme_main.c b/modules/engines/ms-windows/msw_theme_main.c deleted file mode 100755 index 72c523f3d1..0000000000 --- a/modules/engines/ms-windows/msw_theme_main.c +++ /dev/null @@ -1,102 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * Includes code adapted from redmond95 by Owen Taylor, and - * gtk-nativewin by Evan Martin - * - * 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. - */ - -#include -#include -#include - -#include "msw_style.h" -#include "msw_rc_style.h" - -#ifndef WM_THEMECHANGED -#define WM_THEMECHANGED 0x031A /* winxp only */ -#endif - -/* TODO - look into whether we need to handle these: - * - * WM_STYLECHANGED - * WM_PALETTECHANGED - */ -static GdkFilterReturn -global_filter_func (void *xevent, - GdkEvent *event, - gpointer data) -{ - MSG *msg = (MSG *) xevent; - - switch (msg->message) - { -#if ENABLE_THEME_CHANGING - /* catch theme changes */ - case WM_THEMECHANGED: - case WM_SYSCOLORCHANGE: - xp_theme_reset (); - msw_style_init (); - - /* force all gtkwidgets to redraw */ - gtk_rc_reparse_all_for_settings (gtk_settings_get_default(), TRUE); - return GDK_FILTER_REMOVE; -#endif - - case WM_SETTINGCHANGE: - /* catch cursor blink, etc... changes */ - msw_style_setup_system_settings (); - return GDK_FILTER_REMOVE; - - default: - return GDK_FILTER_CONTINUE; - } -} - -G_MODULE_EXPORT void -theme_init (GTypeModule *module) -{ - msw_rc_style_register_type (module); - msw_style_register_type (module); - msw_style_init (); - gdk_window_add_filter (NULL, global_filter_func, NULL); -} - -G_MODULE_EXPORT void -theme_exit (void) -{ - gdk_window_remove_filter (NULL, global_filter_func, NULL); -} - -G_MODULE_EXPORT GtkRcStyle * -theme_create_rc_style (void) -{ - return GTK_RC_STYLE (g_object_new (MSW_TYPE_RC_STYLE, NULL)); -} - -/* The following function will be called by GTK+ when the module - * is loaded and checks to see if we are compatible with the - * version of GTK+ that loads us. - */ -G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module); -const gchar* -g_module_check_init (GModule *module) -{ - return gtk_check_version (GTK_MAJOR_VERSION, - GTK_MINOR_VERSION, - GTK_MICRO_VERSION - GTK_INTERFACE_AGE); -} diff --git a/modules/engines/ms-windows/xp_theme.c b/modules/engines/ms-windows/xp_theme.c deleted file mode 100755 index ce0f0915d7..0000000000 --- a/modules/engines/ms-windows/xp_theme.c +++ /dev/null @@ -1,787 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * - * 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. - */ - -#include "xp_theme.h" - -#include -#include -#include -#include - -#include - -#ifdef DONT_HAVE_UXTHEME_H -#include "xp_theme_defs.h" -#else -#include -#include -#endif - -static const LPCWSTR class_descriptors[] = -{ - L"Scrollbar", /* XP_THEME_CLASS_SCROLLBAR */ - L"Button", /* XP_THEME_CLASS_BUTTON */ - L"Header", /* XP_THEME_CLASS_HEADER */ - L"ComboBox", /* XP_THEME_CLASS_COMBOBOX */ - L"Tab", /* XP_THEME_CLASS_TAB */ - L"Edit", /* XP_THEME_CLASS_EDIT */ - L"TreeView", /* XP_THEME_CLASS_TREEVIEW */ - L"Spin", /* XP_THEME_CLASS_SPIN */ - L"Progress", /* XP_THEME_CLASS_PROGRESS */ - L"Tooltip", /* XP_THEME_CLASS_TOOLTIP */ - L"Rebar", /* XP_THEME_CLASS_REBAR */ - L"Toolbar", /* XP_THEME_CLASS_TOOLBAR */ - L"Globals", /* XP_THEME_CLASS_GLOBALS */ - L"Menu", /* XP_THEME_CLASS_MENU */ - L"Window", /* XP_THEME_CLASS_WINDOW */ - L"Status" /* XP_THEME_CLASS_STATUS */ -}; - -static const short element_part_map[]= -{ - BP_CHECKBOX, - BP_CHECKBOX, - BP_PUSHBUTTON, - HP_HEADERITEM, - CP_DROPDOWNBUTTON, - TABP_BODY, - TABP_TABITEM, - TABP_TABITEMLEFTEDGE, - TABP_PANE, - SBP_THUMBBTNHORZ, - SBP_THUMBBTNVERT, - SBP_ARROWBTN, - SBP_ARROWBTN, - SBP_ARROWBTN, - SBP_ARROWBTN, - SBP_GRIPPERHORZ, - SBP_GRIPPERVERT, - SBP_LOWERTRACKHORZ, - SBP_LOWERTRACKVERT, - EP_EDITTEXT, - BP_PUSHBUTTON, - SPNP_UP, - SPNP_DOWN, - BP_RADIOBUTTON, - BP_RADIOBUTTON, - TVP_GLYPH, - TVP_GLYPH, - PP_CHUNK, - PP_CHUNKVERT, - PP_BAR, - PP_BARVERT, - TTP_STANDARD, - RP_BAND, - RP_GRIPPER, - RP_GRIPPERVERT, - RP_CHEVRON, - TP_BUTTON, - MP_MENUITEM, - MP_SEPARATOR, - SP_GRIPPER, - SP_PANE -}; - -static HINSTANCE uxtheme_dll = NULL; -static HTHEME open_themes[XP_THEME_CLASS__SIZEOF]; - -typedef HRESULT (FAR PASCAL *GetThemeSysFontFunc) - (HTHEME hTheme, int iFontID, OUT LOGFONT *plf); -typedef int (FAR PASCAL *GetThemeSysSizeFunc) - (HTHEME hTheme, int iSizeId); -typedef COLORREF (FAR PASCAL *GetThemeSysColorFunc)(HTHEME hTheme, int iColorID); -typedef HTHEME (FAR PASCAL *OpenThemeDataFunc) - (HWND hwnd, LPCWSTR pszClassList); -typedef HRESULT (FAR PASCAL *CloseThemeDataFunc)(HTHEME theme); -typedef HRESULT (FAR PASCAL *DrawThemeBackgroundFunc) - (HTHEME hTheme, HDC hdc, int iPartId, int iStateId, - const RECT *pRect, const RECT *pClipRect); -typedef HRESULT (FAR PASCAL *EnableThemeDialogTextureFunc)(HWND hwnd, DWORD dwFlags); -typedef BOOL (FAR PASCAL *IsThemeActiveFunc)(VOID); - -static GetThemeSysFontFunc get_theme_sys_font_func = NULL; -static GetThemeSysColorFunc get_theme_sys_color_func = NULL; -static GetThemeSysSizeFunc get_theme_sys_metric_func = NULL; -static OpenThemeDataFunc open_theme_data_func = NULL; -static CloseThemeDataFunc close_theme_data_func = NULL; -static DrawThemeBackgroundFunc draw_theme_background_func = NULL; -static EnableThemeDialogTextureFunc enable_theme_dialog_texture_func = NULL; -static IsThemeActiveFunc is_theme_active_func = NULL; - -static gboolean was_theming_active = FALSE; - -static void -xp_theme_close_open_handles (void) -{ - int i; - - for (i=0; i < XP_THEME_CLASS__SIZEOF; i++) - { - if (open_themes[i]) - { - close_theme_data_func (open_themes[i]); - open_themes[i] = NULL; - } - } -} - -void -xp_theme_init (void) -{ - if (uxtheme_dll) - return; - - memset(open_themes, 0, sizeof(open_themes)); - - uxtheme_dll = LoadLibrary("uxtheme.dll"); - if (!uxtheme_dll) { - was_theming_active = FALSE; - return; - } - - is_theme_active_func = (IsThemeActiveFunc) GetProcAddress(uxtheme_dll, "IsThemeActive"); - open_theme_data_func = (OpenThemeDataFunc) GetProcAddress(uxtheme_dll, "OpenThemeData"); - close_theme_data_func = (CloseThemeDataFunc) GetProcAddress(uxtheme_dll, "CloseThemeData"); - draw_theme_background_func = (DrawThemeBackgroundFunc) GetProcAddress(uxtheme_dll, "DrawThemeBackground"); - enable_theme_dialog_texture_func = (EnableThemeDialogTextureFunc) GetProcAddress(uxtheme_dll, "EnableThemeDialogTexture"); - get_theme_sys_font_func = (GetThemeSysFontFunc) GetProcAddress(uxtheme_dll, "GetThemeSysFont"); - get_theme_sys_color_func = (GetThemeSysColorFunc) GetProcAddress(uxtheme_dll, "GetThemeSysColor"); - get_theme_sys_metric_func = (GetThemeSysSizeFunc) GetProcAddress(uxtheme_dll, "GetThemeSysSize"); - - if (is_theme_active_func) - { - was_theming_active = (*is_theme_active_func) (); - } -} - -void -xp_theme_reset (void) -{ - xp_theme_close_open_handles (); - was_theming_active = is_theme_active_func - ? (*is_theme_active_func) () : FALSE; -} - -void -xp_theme_exit (void) -{ - if (! uxtheme_dll) - return; - - xp_theme_close_open_handles (); - - FreeLibrary (uxtheme_dll); - uxtheme_dll = NULL; - - is_theme_active_func = NULL; - open_theme_data_func = NULL; - close_theme_data_func = NULL; - draw_theme_background_func = NULL; - enable_theme_dialog_texture_func = NULL; - get_theme_sys_font_func = NULL; - get_theme_sys_color_func = NULL; - get_theme_sys_metric_func = NULL; -} - -static HTHEME -xp_theme_get_handle_by_class (XpThemeClass klazz) -{ - if (!open_themes[klazz] && open_theme_data_func) - { - open_themes[klazz] = open_theme_data_func(NULL, class_descriptors[klazz]); - } - return open_themes[klazz]; -} - -static HTHEME -xp_theme_get_handle_by_element (XpThemeElement element) -{ - HTHEME ret = NULL; - XpThemeClass klazz = XP_THEME_CLASS__SIZEOF; - - switch(element) - { - case XP_THEME_ELEMENT_TOOLTIP: - klazz = XP_THEME_CLASS_TOOLTIP; - break; - - case XP_THEME_ELEMENT_REBAR: - case XP_THEME_ELEMENT_REBAR_GRIPPER_H: - case XP_THEME_ELEMENT_REBAR_GRIPPER_V: - case XP_THEME_ELEMENT_REBAR_CHEVRON: - klazz = XP_THEME_CLASS_REBAR; - break; - - case XP_THEME_ELEMENT_STATUS_GRIPPER: - case XP_THEME_ELEMENT_STATUS_PANE: - klazz = XP_THEME_CLASS_STATUS; - break; - - case XP_THEME_ELEMENT_TOOLBAR_BUTTON: - klazz = XP_THEME_CLASS_TOOLBAR; - break; - - case XP_THEME_ELEMENT_MENU_ITEM: - case XP_THEME_ELEMENT_MENU_SEPARATOR: - klazz = XP_THEME_CLASS_MENU; - break; - - case XP_THEME_ELEMENT_PRESSED_CHECKBOX: - case XP_THEME_ELEMENT_CHECKBOX: - case XP_THEME_ELEMENT_BUTTON: - case XP_THEME_ELEMENT_DEFAULT_BUTTON: - case XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON: - case XP_THEME_ELEMENT_RADIO_BUTTON: - klazz = XP_THEME_CLASS_BUTTON; - break; - - case XP_THEME_ELEMENT_LIST_HEADER: - klazz = XP_THEME_CLASS_HEADER; - break; - - case XP_THEME_ELEMENT_COMBOBUTTON: - klazz = XP_THEME_CLASS_COMBOBOX; - break; - - case XP_THEME_ELEMENT_BODY: - case XP_THEME_ELEMENT_TAB_ITEM: - case XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE: - case XP_THEME_ELEMENT_TAB_PANE: - klazz = XP_THEME_CLASS_TAB; - break; - - case XP_THEME_ELEMENT_SCROLLBAR_V: - case XP_THEME_ELEMENT_SCROLLBAR_H: - case XP_THEME_ELEMENT_ARROW_UP: - case XP_THEME_ELEMENT_ARROW_DOWN: - case XP_THEME_ELEMENT_ARROW_LEFT: - case XP_THEME_ELEMENT_ARROW_RIGHT: - case XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V: - case XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H: - case XP_THEME_ELEMENT_TROUGH_V: - case XP_THEME_ELEMENT_TROUGH_H: - klazz = XP_THEME_CLASS_SCROLLBAR; - break; - - case XP_THEME_ELEMENT_EDIT_TEXT: - klazz = XP_THEME_CLASS_EDIT; - break; - - case XP_THEME_ELEMENT_SPIN_BUTTON_UP: - case XP_THEME_ELEMENT_SPIN_BUTTON_DOWN: - klazz = XP_THEME_CLASS_SPIN; - break; - - case XP_THEME_ELEMENT_PROGRESS_BAR_H: - case XP_THEME_ELEMENT_PROGRESS_BAR_V: - case XP_THEME_ELEMENT_PROGRESS_TROUGH_H: - case XP_THEME_ELEMENT_PROGRESS_TROUGH_V: - klazz = XP_THEME_CLASS_PROGRESS; - break; - - case XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED: - case XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED: - klazz = XP_THEME_CLASS_TREEVIEW; - break; - } - - if (klazz != XP_THEME_CLASS__SIZEOF) - { - ret = xp_theme_get_handle_by_class (klazz); - } - return ret; -} - -static int -xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state) -{ - int ret; - - switch(element) - { - case XP_THEME_ELEMENT_TOOLTIP: - ret = TTSS_NORMAL; - break; - - case XP_THEME_ELEMENT_REBAR: - case XP_THEME_ELEMENT_REBAR_GRIPPER_H: - case XP_THEME_ELEMENT_REBAR_GRIPPER_V: - ret = CHEVS_NORMAL; - break; - - case XP_THEME_ELEMENT_STATUS_GRIPPER: - case XP_THEME_ELEMENT_STATUS_PANE: - ret = 1; - break; - - case XP_THEME_ELEMENT_REBAR_CHEVRON: - switch (state) - { - case GTK_STATE_PRELIGHT: - ret = CHEVS_HOT; - break; - case GTK_STATE_SELECTED: - case GTK_STATE_ACTIVE: - ret = CHEVS_PRESSED; - break; - default: - ret = CHEVS_NORMAL; - } - break; - - case XP_THEME_ELEMENT_TOOLBAR_BUTTON: - switch (state) - { - case GTK_STATE_ACTIVE: - ret = TS_PRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = TS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = TS_DISABLED; - break; - default: - ret = TS_NORMAL; - } - break; - - case XP_THEME_ELEMENT_TAB_PANE: - ret = 1; - break; - - case XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE: - case XP_THEME_ELEMENT_TAB_ITEM: - switch(state) - { - case GTK_STATE_PRELIGHT: - ret = TIS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = TIS_DISABLED; - break; - case GTK_STATE_SELECTED: - case GTK_STATE_ACTIVE: - ret = TIS_NORMAL; - break; - default: - ret = TIS_SELECTED; - } - break; - - case XP_THEME_ELEMENT_EDIT_TEXT: - switch(state) - { - case GTK_STATE_PRELIGHT: - ret = ETS_FOCUSED; - break; - case GTK_STATE_INSENSITIVE: - ret = ETS_READONLY; - break; - case GTK_STATE_SELECTED: - case GTK_STATE_ACTIVE: - default: - ret = ETS_NORMAL; - } - break; - - case XP_THEME_ELEMENT_SCROLLBAR_H: - case XP_THEME_ELEMENT_SCROLLBAR_V: - case XP_THEME_ELEMENT_TROUGH_H: - case XP_THEME_ELEMENT_TROUGH_V: - switch(state) - { - case GTK_STATE_SELECTED: - case GTK_STATE_ACTIVE: - ret = SCRBS_PRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = SCRBS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = SCRBS_DISABLED; - break; - default: - ret = SCRBS_NORMAL; - } - break; - - case XP_THEME_ELEMENT_ARROW_DOWN: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = ABS_DOWNPRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = ABS_DOWNHOT; - break; - case GTK_STATE_INSENSITIVE: - ret = ABS_DOWNDISABLED; - break; - default: - ret = ABS_DOWNNORMAL; - } - break; - - case XP_THEME_ELEMENT_ARROW_UP: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = ABS_UPPRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = ABS_UPHOT; - break; - case GTK_STATE_INSENSITIVE: - ret = ABS_UPDISABLED; - break; - default: - ret = ABS_UPNORMAL; - } - break; - - case XP_THEME_ELEMENT_ARROW_LEFT: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = ABS_LEFTPRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = ABS_LEFTHOT; - break; - case GTK_STATE_INSENSITIVE: - ret = ABS_LEFTDISABLED; - break; - default: - ret = ABS_LEFTNORMAL; - } - break; - - case XP_THEME_ELEMENT_ARROW_RIGHT: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = ABS_RIGHTPRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = ABS_RIGHTHOT; - break; - case GTK_STATE_INSENSITIVE: - ret = ABS_RIGHTDISABLED; - break; - default: - ret = ABS_RIGHTNORMAL; - } - break; - - case XP_THEME_ELEMENT_CHECKBOX: - case XP_THEME_ELEMENT_RADIO_BUTTON: - switch(state) - { - case GTK_STATE_SELECTED: - ret = CBS_UNCHECKEDPRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = CBS_UNCHECKEDHOT; - break; - case GTK_STATE_INSENSITIVE: - ret = CBS_UNCHECKEDDISABLED; - break; - default: - ret = CBS_UNCHECKEDNORMAL; - } - break; - - case XP_THEME_ELEMENT_PRESSED_CHECKBOX: - case XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON: - switch(state) - { - case GTK_STATE_SELECTED: - ret = CBS_CHECKEDPRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = CBS_CHECKEDHOT; - break; - case GTK_STATE_INSENSITIVE: - ret = CBS_CHECKEDDISABLED; - break; - default: - ret = CBS_CHECKEDNORMAL; - } - break; - - XP_THEME_ELEMENT_DEFAULT_BUTTON: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = PBS_PRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = PBS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = PBS_DISABLED; - break; - default: - ret = PBS_DEFAULTED; - } - break; - - case XP_THEME_ELEMENT_SPIN_BUTTON_DOWN: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = DNS_PRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = DNS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = DNS_DISABLED; - break; - default: - ret = DNS_NORMAL; - } - break; - - case XP_THEME_ELEMENT_SPIN_BUTTON_UP: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = UPS_PRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = UPS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = UPS_DISABLED; - break; - default: - ret = UPS_NORMAL; - } - break; - - case XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED: - ret = GLPS_OPENED; - break; - - case XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED: - ret = GLPS_CLOSED; - break; - - case XP_THEME_ELEMENT_PROGRESS_BAR_H: - case XP_THEME_ELEMENT_PROGRESS_BAR_V: - case XP_THEME_ELEMENT_PROGRESS_TROUGH_H: - case XP_THEME_ELEMENT_PROGRESS_TROUGH_V: - ret = 1; - break; - - case XP_THEME_ELEMENT_MENU_ITEM: - case XP_THEME_ELEMENT_MENU_SEPARATOR: - switch(state) { - case GTK_STATE_SELECTED: - ret = MS_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - ret = MS_DEMOTED; - break; - default: - ret = MS_NORMAL; - } - break; - - default: - switch(state) - { - case GTK_STATE_ACTIVE: - ret = PBS_PRESSED; - break; - case GTK_STATE_PRELIGHT: - ret = PBS_HOT; - break; - case GTK_STATE_INSENSITIVE: - ret = PBS_DISABLED; - break; - default: - ret = PBS_NORMAL; - } - } - return ret; -} - -gboolean -xp_theme_draw (GdkWindow *win, XpThemeElement element, GtkStyle *style, - int x, int y, int width, int height, - GtkStateType state_type, GdkRectangle *area) -{ - HTHEME theme; - RECT rect, clip, *pClip; - int xoff, yoff, state; - HDC dc; - GdkDrawable *drawable; - int part_state; - - if (! xp_theme_is_drawable (element)) - return FALSE; - - theme = xp_theme_get_handle_by_element(element); - if (!theme) - return FALSE; - - /* FIXME: Recheck its function */ - enable_theme_dialog_texture_func(GDK_WINDOW_HWND(win), ETDT_ENABLETAB); - - if (!GDK_IS_WINDOW(win)) - { - xoff = 0; - yoff = 0; - drawable = win; - } - else - { - gdk_window_get_internal_paint_info(win, &drawable, &xoff, &yoff); - } - rect.left = x - xoff; - rect.top = y - yoff; - rect.right = rect.left + width; - rect.bottom = rect.top + height; - - if (area) - { - clip.left = area->x - xoff; - clip.top = area->y - yoff; - clip.right = clip.left + area->width; - clip.bottom = clip.top + area->height; - - pClip = &clip; - } - else - { - pClip = NULL; - } - - gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); - dc = gdk_win32_hdc_get(drawable, style->dark_gc[state_type], 0); - if (!dc) - return FALSE; - - part_state = xp_theme_map_gtk_state(element, state_type); - -#ifdef GNATS_HACK - if (element == XP_THEME_ELEMENT_REBAR_GRIPPER_V - || element == XP_THEME_ELEMENT_REBAR_GRIPPER_H) - { - /* Hack alert: when XP draws a gripper, it does not seem to fill - up the whole rectangle. It only fills the gripper line - itself. Therefore we manually fill up the background here - ourselves. I still have to look into this a bit further, as - tests with GNAT Programming System show some awkward - interference between this FillRect and the subsequent - DrawThemeBackground(). */ - FillRect (dc, &rect, (HBRUSH) (COLOR_3DFACE+1)); - } -#endif - - draw_theme_background_func(theme, dc, element_part_map[element], part_state, &rect, pClip); - gdk_win32_hdc_release(drawable, style->dark_gc[state_type], 0); - - return TRUE; -} - -gboolean -xp_theme_is_drawable (XpThemeElement element) -{ - if (is_theme_active_func) - { - gboolean active = (*is_theme_active_func) (); - /* A bit of a hack, but it at least detects theme - switches between XP and classic looks on systems - using older GTK+ version (2.2.0-?) that do not - support theme switch detection (gdk_window_add_filter). */ - if (active != was_theming_active) - { - xp_theme_reset (); - } - - if (active) - { - return (xp_theme_get_handle_by_element (element) != NULL); - } - } - - return FALSE; -} - -gboolean -xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, LOGFONT *lf) -{ - int themeFont; - - if (get_theme_sys_font_func != NULL) - { - HTHEME theme = xp_theme_get_handle_by_class(klazz); - if (!theme) - return FALSE; - - switch (fontId) - { - case XP_THEME_FONT_CAPTION: - themeFont = TMT_CAPTIONFONT; break; - case XP_THEME_FONT_MENU: - themeFont = TMT_MENUFONT; break; - case XP_THEME_FONT_STATUS: - themeFont = TMT_STATUSFONT; break; - case XP_THEME_FONT_MESSAGE: - default: - themeFont = TMT_MSGBOXFONT; break; - } - /* if theme is NULL, it will just return the GetSystemFont() value */ - return ((*get_theme_sys_font_func)(theme, themeFont, lf) == S_OK); - } - return FALSE; -} - -gboolean -xp_theme_get_system_color (XpThemeClass klazz, int colorId, DWORD * pColor) -{ - if (get_theme_sys_color_func != NULL) - { - HTHEME theme = xp_theme_get_handle_by_class(klazz); - - /* if theme is NULL, it will just return the GetSystemColor() value */ - *pColor = (*get_theme_sys_color_func)(theme, colorId); - return TRUE; - } - return FALSE; -} - -gboolean -xp_theme_get_system_metric (XpThemeClass klazz, int metricId, int * pVal) -{ - if (get_theme_sys_metric_func != NULL) - { - HTHEME theme = xp_theme_get_handle_by_class(klazz); - - /* if theme is NULL, it will just return the GetSystemMetrics() value */ - *pVal = (*get_theme_sys_metric_func)(theme, metricId); - return TRUE; - } - return FALSE; -} diff --git a/modules/engines/ms-windows/xp_theme.h b/modules/engines/ms-windows/xp_theme.h deleted file mode 100755 index 408d087ddb..0000000000 --- a/modules/engines/ms-windows/xp_theme.h +++ /dev/null @@ -1,114 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Raymond Penners - * - * 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. - */ - -#ifndef XP_THEME_H -#define XP_THEME_H - -#include -#include - -typedef enum -{ - XP_THEME_CLASS_SCROLLBAR = 0, - XP_THEME_CLASS_BUTTON, - XP_THEME_CLASS_HEADER, - XP_THEME_CLASS_COMBOBOX, - XP_THEME_CLASS_TAB, - XP_THEME_CLASS_EDIT, - XP_THEME_CLASS_TREEVIEW, - XP_THEME_CLASS_SPIN, - XP_THEME_CLASS_PROGRESS, - XP_THEME_CLASS_TOOLTIP, - XP_THEME_CLASS_REBAR, - XP_THEME_CLASS_TOOLBAR, - XP_THEME_CLASS_GLOBALS, - XP_THEME_CLASS_MENU, - XP_THEME_CLASS_WINDOW, - XP_THEME_CLASS_STATUS, - XP_THEME_CLASS__SIZEOF -} XpThemeClass; - -typedef enum -{ - XP_THEME_ELEMENT_PRESSED_CHECKBOX = 0, - XP_THEME_ELEMENT_CHECKBOX, - XP_THEME_ELEMENT_BUTTON, - XP_THEME_ELEMENT_LIST_HEADER, - XP_THEME_ELEMENT_COMBOBUTTON, - XP_THEME_ELEMENT_BODY, - XP_THEME_ELEMENT_TAB_ITEM, - XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE, - XP_THEME_ELEMENT_TAB_PANE, - XP_THEME_ELEMENT_SCROLLBAR_H, - XP_THEME_ELEMENT_SCROLLBAR_V, - XP_THEME_ELEMENT_ARROW_UP, - XP_THEME_ELEMENT_ARROW_DOWN, - XP_THEME_ELEMENT_ARROW_LEFT, - XP_THEME_ELEMENT_ARROW_RIGHT, - XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H, - XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V, - XP_THEME_ELEMENT_TROUGH_H, - XP_THEME_ELEMENT_TROUGH_V, - XP_THEME_ELEMENT_EDIT_TEXT, - XP_THEME_ELEMENT_DEFAULT_BUTTON, - XP_THEME_ELEMENT_SPIN_BUTTON_UP, - XP_THEME_ELEMENT_SPIN_BUTTON_DOWN, - XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON, - XP_THEME_ELEMENT_RADIO_BUTTON, - XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED, - XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED, - XP_THEME_ELEMENT_PROGRESS_BAR_H, - XP_THEME_ELEMENT_PROGRESS_BAR_V, - XP_THEME_ELEMENT_PROGRESS_TROUGH_H, - XP_THEME_ELEMENT_PROGRESS_TROUGH_V, - XP_THEME_ELEMENT_TOOLTIP, - XP_THEME_ELEMENT_REBAR, - XP_THEME_ELEMENT_REBAR_GRIPPER_H, - XP_THEME_ELEMENT_REBAR_GRIPPER_V, - XP_THEME_ELEMENT_REBAR_CHEVRON, - XP_THEME_ELEMENT_TOOLBAR_BUTTON, - XP_THEME_ELEMENT_MENU_ITEM, - XP_THEME_ELEMENT_MENU_SEPARATOR, - XP_THEME_ELEMENT_STATUS_GRIPPER, - XP_THEME_ELEMENT_STATUS_PANE, - XP_THEME_ELEMENT__SIZEOF -} XpThemeElement; - -typedef enum -{ - XP_THEME_FONT_CAPTION, - XP_THEME_FONT_MENU, - XP_THEME_FONT_STATUS, - XP_THEME_FONT_MESSAGE -} XpThemeFont; - -void xp_theme_init (void); -void xp_theme_reset (void); -void xp_theme_exit (void); -gboolean xp_theme_draw (GdkWindow *win, XpThemeElement element, - GtkStyle *style, int x, int y, int width, - int height, GtkStateType state_type, - GdkRectangle *area); -gboolean xp_theme_is_drawable (XpThemeElement element); -gboolean xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, LOGFONT *lf); -gboolean xp_theme_get_system_color (XpThemeClass klazz, int colorId, DWORD * pColor); -gboolean xp_theme_get_system_metric (XpThemeClass klazz, int metricId, int * pVal); - -#endif /* XP_THEME_H */ diff --git a/modules/engines/ms-windows/xp_theme_defs.h b/modules/engines/ms-windows/xp_theme_defs.h deleted file mode 100644 index c6d4473897..0000000000 --- a/modules/engines/ms-windows/xp_theme_defs.h +++ /dev/null @@ -1,177 +0,0 @@ -/* MS-Windows Engine (aka GTK-Wimp) - * - * Copyright (C) 2003, 2004 Dom Lachowicz - * - * 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. - */ - -/* - * These are the real values of these UXTHEME constants, provided so that we can - * compile/link on Win32 platforms that aren't WinXP, and also build against - * MinGW 1.0/1.1, which also doesn't have these things defined in its header files - */ - -#ifndef XP_THEME_DFNS_H -#define XP_THEME_DFNS_H - -typedef HANDLE HTHEME; - -#define ETDT_ENABLE 0x00000002 -#define ETDT_USETABTEXTURE 0x00000004 -#define ETDT_ENABLETAB (ETDT_ENABLE | ETDT_USETABTEXTURE) - -#define BP_PUSHBUTTON 1 -#define BP_CHECKBOX 3 - -#define HP_HEADERITEM 1 - -#define CP_DROPDOWNBUTTON 1 - -#define TABP_TABITEM 1 -#define TABP_TABITEMLEFTEDGE 2 -#define TABP_PANE 9 -#define TABP_BODY 10 - -#define SBP_ARROWBTN 1 -#define SBP_THUMBBTNHORZ 2 -#define SBP_THUMBBTNVERT 3 -#define SBP_LOWERTRACKHORZ 5 -#define SBP_LOWERTRACKVERT 6 -#define SBP_GRIPPERHORZ 8 -#define SBP_GRIPPERVERT 9 - -#define EP_EDITTEXT 1 - -#define SPNP_UP 1 -#define SPNP_DOWN 2 - -#define BP_RADIOBUTTON 2 - -#define TVP_GLYPH 2 - -#define PP_BAR 1 -#define PP_BARVERT 2 -#define PP_CHUNK 3 -#define PP_CHUNKVERT 4 - -#define TTP_STANDARD 1 - -#define RP_GRIPPER 1 -#define RP_GRIPPERVERT 2 -#define RP_BAND 3 -#define RP_CHEVRON 4 - -#define TP_BUTTON 1 -#define TS_NORMAL 1 -#define TS_HOT 2 -#define TS_PRESSED 3 -#define TS_DISABLED 4 - -#define TTSS_NORMAL 1 - -#define CHEVS_NORMAL 1 -#define CHEVS_HOT 2 -#define CHEVS_PRESSED 3 - -#define TIS_NORMAL 1 -#define TIS_HOT 2 -#define TIS_SELECTED 3 -#define TIS_DISABLED 4 - -#define ETS_NORMAL 1 -#define ETS_FOCUSED 5 -#define ETS_READONLY 6 - -#define SCRBS_NORMAL 1 -#define SCRBS_HOT 2 -#define SCRBS_PRESSED 3 -#define SCRBS_DISABLED 4 - -#define ABS_UPNORMAL 1 -#define ABS_UPHOT 2 -#define ABS_UPPRESSED 3 -#define ABS_UPDISABLED 4 -#define ABS_DOWNNORMAL 5 -#define ABS_DOWNHOT 6 -#define ABS_DOWNPRESSED 7 -#define ABS_DOWNDISABLED 8 -#define ABS_LEFTNORMAL 9 -#define ABS_LEFTHOT 10 -#define ABS_LEFTPRESSED 11 -#define ABS_LEFTDISABLED 12 -#define ABS_RIGHTNORMAL 13 -#define ABS_RIGHTHOT 14 -#define ABS_RIGHTPRESSED 15 -#define ABS_RIGHTDISABLED 16 - -#define CBS_UNCHECKEDNORMAL 1 -#define CBS_UNCHECKEDHOT 2 -#define CBS_UNCHECKEDPRESSED 3 -#define CBS_UNCHECKEDDISABLED 4 -#define CBS_CHECKEDNORMAL 5 -#define CBS_CHECKEDHOT 6 -#define CBS_CHECKEDPRESSED 7 -#define CBS_CHECKEDDISABLED 8 - -#define PBS_NORMAL 1 -#define PBS_HOT 2 -#define PBS_PRESSED 3 -#define PBS_DISABLED 4 -#define PBS_DEFAULTED 5 - -#define DNS_NORMAL 1 -#define DNS_HOT 2 -#define DNS_PRESSED 3 -#define DNS_DISABLED 4 - -#define UPS_NORMAL 1 -#define UPS_HOT 2 -#define UPS_PRESSED 3 -#define UPS_DISABLED 4 - -#define GLPS_CLOSED 1 -#define GLPS_OPENED 2 - -#define MP_MENUITEM 1 -#define MP_SEPARATOR 6 -#define MS_NORMAL 1 -#define MS_SELECTED 2 -#define MS_DEMOTED 3 - -#define SP_PANE 1 -#define SP_GRIPPER 2 - -#define TMT_CAPTIONFONT 801 -#define TMT_MENUFONT 803 -#define TMT_STATUSFONT 804 -#define TMT_MSGBOXFONT 805 - -#if UXTHEME_HAS_LINES - -#error unknown/undocumented uxtheme values - -/* #define GP_LINEHORZ */ -/* #define GP_LINEVERT */ -/* #define LHS_RAISED */ -/* #define LHS_SUNKEN */ -/* #define LHS_FLAT */ -/* #define LVS_RAISED */ -/* #define LVS_SUNKEN */ -/* #define LHS_FLAT */ - -#endif /* UXTHEME_HAS_LINES */ - -#endif /* XP_THEME_DFNS_H */ diff --git a/modules/engines/pixbuf/.cvsignore b/modules/engines/pixbuf/.cvsignore deleted file mode 100644 index 020d528ee0..0000000000 --- a/modules/engines/pixbuf/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -.libs -*.lo -*.la \ No newline at end of file diff --git a/modules/engines/pixbuf/ChangeLog b/modules/engines/pixbuf/ChangeLog deleted file mode 100644 index 20cf1078bb..0000000000 --- a/modules/engines/pixbuf/ChangeLog +++ /dev/null @@ -1,271 +0,0 @@ -Thu Mar 18 10:07:15 2004 Owen Taylor - - * pixbuf-draw.c (match_theme_image): Fix ./-> typo. - (Federic Crozat) - -Wed Mar 17 16:38:00 2004 Owen Taylor - - * pixbuf-draw.c (match_theme_image): Fix problem with - NULL details. (#112066, MINAMI Hirokazu, Matthias Clasen) - -2003-07-15 Mark McLoughlin - - * pixbuf-render.c: make pixbuf_cache static to avoid - possible symbol conflicts. - -2003-03-02 Tor Lillqvist - - * Makefile.am: Use -no-undefined on Windows. - -Fri Sep 6 20:32:45 2002 Owen Taylor - - * pixbuf-draw.c: Account for the possibility of detail == NULL - (#89561, Hongli Lai, Luca Barbato) - -Sun Apr 21 14:10:04 2002 Owen Taylor - - * pixbuf-rc-style.c pixbuf.h pixbuf-draw.c: Add a fake STEPPER - function that is used for drawing scrollbar steppers, - so that themes that want to draw the button and arrow - separately can override the default handling. - - * pixbuf-draw.c: Remove draw_polygon() since it was - just a cut-and-paste of the default one. Remove - some unused code. - -2002-03-07 James Henstridge - - * Makefile.am (libpixmap_la_LIBADD): link pixbuf engine against - the gtk+ libraries, so that it can be used with programs that - dlopen gtk+ without the RTLD_GLOBAL flag (such as scripting - languages and mozilla). - -Thu Feb 7 00:21:21 2002 Owen Taylor - - * pixbuf-render.c (pixbuf_render): Add gradient - rendering -- if the source width/height is zero, - render a gradient from the surrounding values. - -Mon Jan 28 15:34:43 2002 Owen Taylor - - * pixbuf-render.c (compute_hint): Fix hint computation - again. - -Mon Jan 28 12:17:07 2002 Owen Taylor - - * pixbuf-render.c (compute_hint): Fix problems in computing - MISSING hint. - -Sun Jan 27 23:58:13 2002 Owen Taylor - - * pixbuf-render.c (compute_hint): Optimize the case - where a component is entirely transparent by skipping - drawing it. - - * pixbuf-rc-style.c (theme_parse_image): Catch case - where background or overlay border/stretch are specified - without a background image. - - * pixbuf-render.c (theme_pixbuf_destroy): Actually free - the structure and filename. - -=================== Move back into gtk-engines ==================== - -Sat Jan 19 02:45:17 2002 Owen Taylor - - * src/pixbuf-render.c (theme_pixbuf_compute_hints): Catch - invalid borders, and warn. - -Sat Jan 19 00:32:14 2002 Owen Taylor - - * examples/*: Add an extrodinarily ugly example. - - * src/pixbuf-draw.c (draw_simple_image): Never shape - the window, even if we are allowed to. Shaping is - ugly -- if the widget isn't NO_WINDOW (most are), - you'll just have to draw it rectangular. - - * src/pixbuf-render.c (pixbuf_render): Always use - gdk_pixbuf_render_alpha() with FULL_ALPHA() as the - type. - - * pixbuf.h src/pixbuf-render.c (theme_pixbuf_compute_hints): To - speed up scaling, cache whether pixbufs have constant rows - or constant columns. - - * src/pixbuf-render.c (pixbuf_render): Speed up scaling - by using the hints from compute_hints(). - -Fri Jan 18 20:49:48 2002 Owen Taylor - - * configure.in: Use pkg-config to get the binray version - of GTK+ that we use for an install path. - -Fri Jan 18 18:14:11 2002 Owen Taylor - - * src/pixbuf-draw.c (draw_focus): Fix for changes to draw_focus. - -2001-09-21 Hans Breuer - - * src/pixbuf-rc-style-c : GtkRcStyle::parse has a GtkSettings - parameter now. Pass it through theme_parse_file () to use it - gtk_rc_find_pixmap_in_path () - - * src/pixbuf-draw.c : the font field from GtkStyle is private - now, use accessor gtk_style_get_font () - - * makefile.msc : compile on win32, use it if you have a _real_ - fast computer or want to see gtk in slow motion :-) - -Thu May 3 05:36:06 2001 Owen Taylor - - * pixbuf.h: Fix trailing comma on enumeration. (#54071) - -2001-03-05 Michael Natterer - - * src/pixbuf-draw.c: made the "parent_class" pointer static. - - (Owen, I just commented out the draw methods which don't exist any - more to make it compile). - -2001-02-20 Sven Neumann - - * src/pixbuf-draw.c (draw_vline): use draw_vline method of - parent_class, not draw_hline - -Wed Nov 15 21:56:28 2000 Owen Taylor - - * src/pixbuf-*: A few updates for GTypePlugin. - -Tue Jul 18 12:13:19 2000 Owen Taylor - - Updates to work with GTK+-2.0 theme engine architecture. - It won't even sort of work with GTK+-1.2 any more. - - * configure.in src/Makefile.am: Look for GTK+-2.0, - install engine into GTK+-2.0 location. - - * src/pixbuf-style.h src/pixbuf-rc-style.[ch]: New - files for GtkRcStyle and GtkStyle subclasses. Parsing, - etc, moves to pixbuf-rc-style.[ch] - - * src/pixbuf-draw.c: Chain up to parent implementation - when images aren't found for a certain element. - -Sun Jul 9 18:15:58 2000 Owen Taylor - - * configure.in (ACLOCAL): Add -Wall for gcc. - - * src/pixbuf-render.c (pixbuf_render): Fix problem - using gdk_rectangle_intersect() from GTK+-1.2. - - * src/pixbuf-render.c src/pixbuf-draw.c: Remove - direct access to pixbuf internals. - -Mon Mar 6 11:44:58 2000 Owen Taylor - - * docs/gap-geometry.fig: Moved into docs/ subdir - - * Makefile.am configure.in autogen.sh src/Makefile.am: - automakify - - * src/pixbuf.h src/pixbuf-render.c src/pixbuf-draw.c - src/pixbuf-main.c: Move sources into subdir and - rename. - -Mon Mar 6 11:02:07 2000 Owen Taylor - - * pixmap_theme_pixbuf.c: Handle drawing transparency without a - mask correctly. - - * pixmap_theme_main.c pixmap_theme_draw.c: Remove duplicate - includes. - -Sun Feb 6 21:34:30 2000 Owen Taylor - - * Started ChangeLog for pixbuf engine, check sources - into CVS. - -========== ChangeLog for pixmap engine =================== - -1999-11-22 Martin Baulig - - * pixmap_theme_main.c (theme_duplicate_style): Really copy the - `src_data->img_list', not just the pointer that points to it. - -Tue Oct 5 15:13:29 1999 Owen Taylor - - * pixmap_theme_draw.c (apply_theme_image): Don't set - background pixmap on pixmaps. - -1999-02-14 Raja R Harinath - - * Theme/gtk/Makefile.am.in (Makefile.am): Handle the case when - files are deleted. - -Thu Feb 11 21:16:53 1999 Owen Taylor - - * pixmap_theme_main.c (theme_data_unref): Free the - theme data structure as well as the contents. - -1999-02-03 Raja R Harinath - - * Theme/gtk/Makefile.am.in: New file. Theme/gtk/Makefile.am is - generated from this file when new *.png files are added. - -1999-01-23 Miguel de Icaza - - * pixmap_theme_main.c (theme_init): Turn on pixmap cache. - -Mon Jan 18 13:37:23 1999 Owen Taylor - - * Theme/gtk/gtkrc: Give buttons a gray background - color so they look a little less funny when initially - drawing. - -Wed Jan 13 18:58:25 1999 Owen Taylor - - * pixmap_theme_draw.c: Fixed pervasive mis-bracketing - that was causing drawing if the drawn region and - clipping region did NOT intersect, and a couple - of errors in computing source and destination - regions. - -1998-11-09 Federico Mena Quintero - - * pixmap_theme_draw.c: #include - -1998-11-07 Raja R Harinath - - * Theme/gtk/Makefile.am (theme_DATA): - Update to new directory contents. - * configure.in: Remove. - -Fri Nov 6 17:26:12 1998 Owen Taylor - - * pixmap_theme_main.c: Removed some debugging - printf's. - - * Theme/gtk/notebook1.c Theme/gtk/menubar.png: new - bigger pixmaps to reduce pixelation. - - * Theme/gtk/gtkrc: Reorganized to use several styles - instead of one huge style. Change clist backgrounds - to be prettier. - -Thu Nov 5 10:23:46 1998 Owen Taylor - - * pixmap_theme_draw.c (draw_shadow_gap): Fixed hard-coded - gap_side of '0'. - -Mon Nov 2 14:46:02 1998 Owen Taylor - - * pixmap_theme_draw.c (apply_theme_image_shadow_gap): Removed - several hundred lines of duplicated code with a bit of - reoriganization. - -Wed Oct 28 16:18:04 1998 Owen Taylor - - * pixmap_theme_main.c (theme_symbols): Removed lots - and lots of white space. - diff --git a/modules/engines/pixbuf/Makefile.am b/modules/engines/pixbuf/Makefile.am deleted file mode 100644 index 27ebd8e37b..0000000000 --- a/modules/engines/pixbuf/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -if OS_WIN32 -no_undefined = -no-undefined -endif - -INCLUDES = $(GTK_CFLAGS) - -enginedir = $(libdir)/gtk-2.0/$(GTK_VERSION)/engines - -engine_LTLIBRARIES = libpixmap.la - -libpixmap_la_SOURCES = \ - pixbuf-draw.c \ - pixbuf-main.c \ - pixbuf-render.c \ - pixbuf-rc-style.c \ - pixbuf-rc-style.h \ - pixbuf-style.h \ - pixbuf.h - -libpixmap_la_LDFLAGS = -avoid-version -module $(no_undefined) -libpixmap_la_LIBADD = $(GTK_LIBS) - -dist-hook: - cp -pr examples $(distdir); \ - find $(distdir)/examples -name 'CVS' -print | xargs rm -rf diff --git a/modules/engines/pixbuf/README b/modules/engines/pixbuf/README deleted file mode 100644 index 6b48ec67ca..0000000000 --- a/modules/engines/pixbuf/README +++ /dev/null @@ -1,17 +0,0 @@ -The code in this directory is a GTK+ theme engine based on the earlier -pixmap theme engine. - -The config files are meant to be compatible, but instead of rendering -using Imlib, it renders using GdkPixbuf. This makes the memory -management much more understandable, and also allows us to use -GdkPixbuf's high quality scaling. - -Most of the code was reworked/rewritten in the process to make it more -understandable and maintainable. - -There are lots of bugs here, a considersable number of bugs. But it's -cleaned up a great deal from the older pixmap engine. Please don't -make it uglier again. - -Owen Taylor -6 February 2000 \ No newline at end of file diff --git a/modules/engines/pixbuf/examples/bubble/README b/modules/engines/pixbuf/examples/bubble/README deleted file mode 100644 index 46cade49d1..0000000000 --- a/modules/engines/pixbuf/examples/bubble/README +++ /dev/null @@ -1,14 +0,0 @@ -gtk-2.0/triangle-background.png is copyright Owen Taylor, 1997 -and may be used without restriction as long as this attribution -is reproduced. - -images/bc.pnm images/bc-dark.pnm images/bc-light.png are -from the BrushedMetalClean theme; I believe Tuomas Kuosmanen -and Carsten Haitzler had something to do with the original -BrushedMetal artwork. - -This theme is truly hideous for a reason ... to demonstrate -that alpha-compositing is going on. - -Owen Taylor -19 Jan 2002x \ No newline at end of file diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc-dark.png b/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc-dark.png deleted file mode 100644 index ab87858cea..0000000000 Binary files a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc-dark.png and /dev/null differ diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc-light.png b/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc-light.png deleted file mode 100644 index 0c7ecd5d83..0000000000 Binary files a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc-light.png and /dev/null differ diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc.png b/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc.png deleted file mode 100644 index 7b7c1da47f..0000000000 Binary files a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bc.png and /dev/null differ diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bubble-blue.png b/modules/engines/pixbuf/examples/bubble/gtk-2.0/bubble-blue.png deleted file mode 100644 index bea78c350f..0000000000 Binary files a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bubble-blue.png and /dev/null differ diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bubble-parts.xcf b/modules/engines/pixbuf/examples/bubble/gtk-2.0/bubble-parts.xcf deleted file mode 100644 index 184d75069e..0000000000 Binary files a/modules/engines/pixbuf/examples/bubble/gtk-2.0/bubble-parts.xcf and /dev/null differ diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/gtkrc b/modules/engines/pixbuf/examples/bubble/gtk-2.0/gtkrc deleted file mode 100644 index 2d621e0d67..0000000000 --- a/modules/engines/pixbuf/examples/bubble/gtk-2.0/gtkrc +++ /dev/null @@ -1,65 +0,0 @@ -style "default" -{ - fg[NORMAL] = "#ffffff" - fg[PRELIGHT] = "#ffffff" - bg_pixmap[NORMAL] = "triangle_background.png" -# bg_pixmap[NORMAL] = "bc.png" - bg_pixmap[PRELIGHT] = "bc-light.png" - bg_pixmap[ACTIVE] = "bc-dark.png" bg_pixmap[INSENSITIVE] = "bc.png" -} - -class "GtkWidget" style "default" - -style "bubble-button" -{ - engine "pixmap" - { - image - { - function = BOX - file = "bubble-blue.png" - border = { 8, 8, 8, 8 } - stretch = TRUE - } - } -} - -# common default -class "GtkButton" style "bubble-button" - -style "bubble-range" -{ - GtkRange::slider_width = 16 - GtkRange::stepper_size = 16 - - engine "pixmap" - { - image - { - function = BOX - file = "bubble-blue.png" - border = { 8, 8, 8, 8 } - stretch = TRUE - } - } -} - -# common default -class "GtkRange" style "bubble-range" - -style "bubble-menuitem" -{ - engine "pixmap" - { - image - { - function = BOX - file = "bubble-blue.png" - border = { 8, 8, 8, 8 } - stretch = TRUE - } - } -} - -# common default -class "GtkMenuItem" style "bubble-menuitem" diff --git a/modules/engines/pixbuf/examples/bubble/gtk-2.0/triangle_background.png b/modules/engines/pixbuf/examples/bubble/gtk-2.0/triangle_background.png deleted file mode 100644 index a4a612d7ba..0000000000 Binary files a/modules/engines/pixbuf/examples/bubble/gtk-2.0/triangle_background.png and /dev/null differ diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c deleted file mode 100644 index f3eb17d35c..0000000000 --- a/modules/engines/pixbuf/pixbuf-draw.c +++ /dev/null @@ -1,1034 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include -#include - -#include "pixbuf.h" -#include "pixbuf-rc-style.h" -#include "pixbuf-style.h" - -static void pixbuf_style_init (PixbufStyle *style); -static void pixbuf_style_class_init (PixbufStyleClass *klass); - -static GtkStyleClass *parent_class = NULL; - -static ThemeImage * -match_theme_image (GtkStyle *style, - ThemeMatchData *match_data) -{ - GList *tmp_list; - - tmp_list = PIXBUF_RC_STYLE (style->rc_style)->img_list; - - while (tmp_list) - { - guint flags; - ThemeImage *image = tmp_list->data; - tmp_list = tmp_list->next; - - if (match_data->function != image->match_data.function) - continue; - - flags = match_data->flags & image->match_data.flags; - - if (flags != image->match_data.flags) /* Required components not present */ - continue; - - if ((flags & THEME_MATCH_STATE) && - match_data->state != image->match_data.state) - continue; - - if ((flags & THEME_MATCH_SHADOW) && - match_data->shadow != image->match_data.shadow) - continue; - - if ((flags & THEME_MATCH_ARROW_DIRECTION) && - match_data->arrow_direction != image->match_data.arrow_direction) - continue; - - if ((flags & THEME_MATCH_ORIENTATION) && - match_data->orientation != image->match_data.orientation) - continue; - - if ((flags & THEME_MATCH_GAP_SIDE) && - match_data->gap_side != image->match_data.gap_side) - continue; - - if (image->match_data.detail && - (!match_data->detail || - strcmp (match_data->detail, image->match_data.detail) != 0)) - continue; - - return image; - } - - return NULL; -} - -static gboolean -draw_simple_image(GtkStyle *style, - GdkWindow *window, - GdkRectangle *area, - GtkWidget *widget, - ThemeMatchData *match_data, - gboolean draw_center, - gboolean allow_setbg, - gint x, - gint y, - gint width, - gint height) -{ - ThemeImage *image; - gboolean setbg = FALSE; - - if ((width == -1) && (height == -1)) - { - gdk_window_get_size(window, &width, &height); - if (allow_setbg) - setbg = TRUE; - } - else if (width == -1) - gdk_window_get_size(window, &width, NULL); - else if (height == -1) - gdk_window_get_size(window, NULL, &height); - - if (!(match_data->flags & THEME_MATCH_ORIENTATION)) - { - match_data->flags |= THEME_MATCH_ORIENTATION; - - if (height > width) - match_data->orientation = GTK_ORIENTATION_VERTICAL; - else - match_data->orientation = GTK_ORIENTATION_HORIZONTAL; - } - - image = match_theme_image (style, match_data); - if (image) - { - if (image->background) - { - theme_pixbuf_render (image->background, - window, NULL, area, - draw_center ? COMPONENT_ALL : COMPONENT_ALL | COMPONENT_CENTER, - FALSE, - x, y, width, height); - } - - if (image->overlay && draw_center) - theme_pixbuf_render (image->overlay, - window, NULL, area, COMPONENT_ALL, - TRUE, - x, y, width, height); - - return TRUE; - } - else - return FALSE; -} - -static gboolean -draw_gap_image(GtkStyle *style, - GdkWindow *window, - GdkRectangle *area, - GtkWidget *widget, - ThemeMatchData *match_data, - gboolean draw_center, - gint x, - gint y, - gint width, - gint height, - GtkPositionType gap_side, - gint gap_x, - gint gap_width) -{ - ThemeImage *image; - gboolean setbg = FALSE; - - if ((width == -1) && (height == -1)) - { - gdk_window_get_size(window, &width, &height); - setbg = TRUE; - } - else if (width == -1) - gdk_window_get_size(window, &width, NULL); - else if (height == -1) - gdk_window_get_size(window, NULL, &height); - - if (!(match_data->flags & THEME_MATCH_ORIENTATION)) - { - match_data->flags |= THEME_MATCH_ORIENTATION; - - if (height > width) - match_data->orientation = GTK_ORIENTATION_VERTICAL; - else - match_data->orientation = GTK_ORIENTATION_HORIZONTAL; - } - - match_data->flags |= THEME_MATCH_GAP_SIDE; - match_data->gap_side = gap_side; - - image = match_theme_image (style, match_data); - if (image) - { - gint thickness; - GdkRectangle r1, r2, r3; - GdkPixbuf *pixbuf = NULL; - guint components = COMPONENT_ALL; - - if (!draw_center) - components |= COMPONENT_CENTER; - - if (image->gap_start) - pixbuf = theme_pixbuf_get_pixbuf (image->gap_start); - - switch (gap_side) - { - case GTK_POS_TOP: - if (pixbuf) - thickness = gdk_pixbuf_get_height (pixbuf); - else - thickness = style->ythickness; - - if (!draw_center) - components |= COMPONENT_NORTH_WEST | COMPONENT_NORTH | COMPONENT_NORTH_EAST; - - r1.x = x; - r1.y = y; - r1.width = gap_x; - r1.height = thickness; - r2.x = x + gap_x; - r2.y = y; - r2.width = gap_width; - r2.height = thickness; - r3.x = x + gap_x + gap_width; - r3.y = y; - r3.width = width - (gap_x + gap_width); - r3.height = thickness; - break; - - case GTK_POS_BOTTOM: - if (pixbuf) - thickness = gdk_pixbuf_get_height (pixbuf); - else - thickness = style->ythickness; - - if (!draw_center) - components |= COMPONENT_SOUTH_WEST | COMPONENT_SOUTH | COMPONENT_SOUTH_EAST; - - r1.x = x; - r1.y = y + height - thickness; - r1.width = gap_x; - r1.height = thickness; - r2.x = x + gap_x; - r2.y = y + height - thickness; - r2.width = gap_width; - r2.height = thickness; - r3.x = x + gap_x + gap_width; - r3.y = y + height - thickness; - r3.width = width - (gap_x + gap_width); - r3.height = thickness; - break; - - case GTK_POS_LEFT: - if (pixbuf) - thickness = gdk_pixbuf_get_width (pixbuf); - else - thickness = style->xthickness; - - if (!draw_center) - components |= COMPONENT_NORTH_WEST | COMPONENT_WEST | COMPONENT_SOUTH_WEST; - - r1.x = x; - r1.y = y; - r1.width = thickness; - r1.height = gap_x; - r2.x = x; - r2.y = y + gap_x; - r2.width = thickness; - r2.height = gap_width; - r3.x = x; - r3.y = y + gap_x + gap_width; - r3.width = thickness; - r3.height = height - (gap_x + gap_width); - break; - - case GTK_POS_RIGHT: - if (pixbuf) - thickness = gdk_pixbuf_get_width (pixbuf); - else - thickness = style->xthickness; - - if (!draw_center) - components |= COMPONENT_NORTH_EAST | COMPONENT_EAST | COMPONENT_SOUTH_EAST; - - r1.x = x + width - thickness; - r1.y = y; - r1.width = thickness; - r1.height = gap_x; - r2.x = x + width - thickness; - r2.y = y + gap_x; - r2.width = thickness; - r2.height = gap_width; - r3.x = x + width - thickness; - r3.y = y + gap_x + gap_width; - r3.width = thickness; - r3.height = height - (gap_x + gap_width); - break; - } - - if (image->background) - theme_pixbuf_render (image->background, - window, NULL, area, components, FALSE, - x, y, width, height); - if (image->gap_start) - theme_pixbuf_render (image->gap_start, - window, NULL, area, COMPONENT_ALL, FALSE, - r1.x, r1.y, r1.width, r1.height); - if (image->gap) - theme_pixbuf_render (image->gap, - window, NULL, area, COMPONENT_ALL, FALSE, - r2.x, r2.y, r2.width, r2.height); - if (image->gap_end) - theme_pixbuf_render (image->gap_end, - window, NULL, area, COMPONENT_ALL, FALSE, - r3.x, r3.y, r3.width, r3.height); - - return TRUE; - } - else - return FALSE; -} - -static void -draw_hline (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x1, - gint x2, - gint y) -{ - ThemeImage *image; - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_HLINE; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_ORIENTATION | THEME_MATCH_STATE; - match_data.state = state; - match_data.orientation = GTK_ORIENTATION_HORIZONTAL; - - image = match_theme_image (style, &match_data); - if (image) - { - if (image->background) - theme_pixbuf_render (image->background, - window, NULL, area, COMPONENT_ALL, FALSE, - x1, y, (x2 - x1) + 1, 2); - } - else - parent_class->draw_hline (style, window, state, area, widget, detail, - x1, x2, y); -} - -static void -draw_vline (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint y1, - gint y2, - gint x) -{ - ThemeImage *image; - ThemeMatchData match_data; - - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - match_data.function = TOKEN_D_VLINE; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_ORIENTATION | THEME_MATCH_STATE; - match_data.state = state; - match_data.orientation = GTK_ORIENTATION_VERTICAL; - - image = match_theme_image (style, &match_data); - if (image) - { - if (image->background) - theme_pixbuf_render (image->background, - window, NULL, area, COMPONENT_ALL, FALSE, - x, y1, 2, (y2 - y1) + 1); - } - else - parent_class->draw_vline (style, window, state, area, widget, detail, - y1, y2, x); -} - -static void -draw_shadow(GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_SHADOW; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, FALSE, FALSE, - x, y, width, height)) - parent_class->draw_shadow (style, window, state, shadow, area, widget, detail, - x, y, width, height); -} - -/* This function makes up for some brokeness in gtkrange.c - * where we never get the full arrow of the stepper button - * and the type of button in a single drawing function. - * - * It doesn't work correctly when the scrollbar is squished - * to the point we don't have room for full-sized steppers. - */ -static void -reverse_engineer_stepper_box (GtkWidget *range, - GtkArrowType arrow_type, - gint *x, - gint *y, - gint *width, - gint *height) -{ - gint slider_width = 14, stepper_size = 14; - gint box_width; - gint box_height; - - if (range) - { - gtk_widget_style_get (range, - "slider_width", &slider_width, - "stepper_size", &stepper_size, - NULL); - } - - if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) - { - box_width = slider_width; - box_height = stepper_size; - } - else - { - box_width = stepper_size; - box_height = slider_width; - } - - *x = *x - (box_width - *width) / 2; - *y = *y - (box_height - *height) / 2; - *width = box_width; - *height = box_height; -} - -static void -draw_arrow (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - GtkArrowType arrow_direction, - gint fill, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - if (detail && - (strcmp (detail, "hscrollbar") == 0 || strcmp (detail, "vscrollbar") == 0)) - { - /* This is a hack to work around the fact that scrollbar steppers are drawn - * as a box + arrow, so we never have - * - * The full bounding box of the scrollbar - * The arrow direction - * - * At the same time. We simulate an extra paint function, "STEPPER", by doing - * nothing for the box, and then here, reverse engineering the box that - * was passed to draw box and using that - */ - gint box_x = x; - gint box_y = y; - gint box_width = width; - gint box_height = height; - - reverse_engineer_stepper_box (widget, arrow_direction, - &box_x, &box_y, &box_width, &box_height); - - match_data.function = TOKEN_D_STEPPER; - match_data.detail = (gchar *)detail; - match_data.flags = (THEME_MATCH_SHADOW | - THEME_MATCH_STATE | - THEME_MATCH_ARROW_DIRECTION); - match_data.shadow = shadow; - match_data.state = state; - match_data.arrow_direction = arrow_direction; - - if (draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - box_x, box_y, box_width, box_height)) - { - /* The theme included stepper images, we're done */ - return; - } - - /* Otherwise, draw the full box, and fall through to draw the arrow - */ - match_data.function = TOKEN_D_BOX; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - box_x, box_y, box_width, box_height)) - parent_class->draw_box (style, window, state, shadow, area, widget, detail, - box_x, box_y, box_width, box_height); - } - - - match_data.function = TOKEN_D_ARROW; - match_data.detail = (gchar *)detail; - match_data.flags = (THEME_MATCH_SHADOW | - THEME_MATCH_STATE | - THEME_MATCH_ARROW_DIRECTION); - match_data.shadow = shadow; - match_data.state = state; - match_data.arrow_direction = arrow_direction; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_arrow (style, window, state, shadow, area, widget, detail, - arrow_direction, fill, x, y, width, height); -} - -static void -draw_diamond (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_DIAMOND; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_diamond (style, window, state, shadow, area, widget, detail, - x, y, width, height); -} - -static void -draw_string (GtkStyle * style, - GdkWindow * window, - GtkStateType state, - GdkRectangle * area, - GtkWidget * widget, - const gchar *detail, - gint x, - gint y, - const gchar * string) -{ - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - if (state == GTK_STATE_INSENSITIVE) - { - if (area) - { - gdk_gc_set_clip_rectangle(style->white_gc, area); - gdk_gc_set_clip_rectangle(style->fg_gc[state], area); - } - - gdk_draw_string(window, gtk_style_get_font (style), style->fg_gc[state], x, y, string); - - if (area) - { - gdk_gc_set_clip_rectangle(style->white_gc, NULL); - gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL); - } - } - else - { - gdk_gc_set_clip_rectangle(style->fg_gc[state], area); - gdk_draw_string(window, gtk_style_get_font (style), style->fg_gc[state], x, y, string); - gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL); - } -} - -static void -draw_box (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - if (detail && - (strcmp (detail, "hscrollbar") == 0 || strcmp (detail, "vscrollbar") == 0)) - { - /* We handle this in draw_arrow */ - return; - } - - match_data.function = TOKEN_D_BOX; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) { - parent_class->draw_box (style, window, state, shadow, area, widget, detail, - x, y, width, height); - } -} - -static void -draw_flat_box (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_FLAT_BOX; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_flat_box (style, window, state, shadow, area, widget, detail, - x, y, width, height); -} - -static void -draw_check (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_CHECK; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_check (style, window, state, shadow, area, widget, detail, - x, y, width, height); -} - -static void -draw_option (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_OPTION; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_option (style, window, state, shadow, area, widget, detail, - x, y, width, height); -} - -static void -draw_tab (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_TAB; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_tab (style, window, state, shadow, area, widget, detail, - x, y, width, height); -} - -static void -draw_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkPositionType gap_side, - gint gap_x, - gint gap_width) -{ - ThemeMatchData match_data; - - match_data.function = TOKEN_D_SHADOW_GAP; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.flags = (THEME_MATCH_SHADOW | - THEME_MATCH_STATE | - THEME_MATCH_ORIENTATION); - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_gap_image (style, window, area, widget, &match_data, FALSE, - x, y, width, height, gap_side, gap_x, gap_width)) - parent_class->draw_shadow_gap (style, window, state, shadow, area, widget, detail, - x, y, width, height, gap_side, gap_x, gap_width); -} - -static void -draw_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkPositionType gap_side, - gint gap_x, - gint gap_width) -{ - ThemeMatchData match_data; - - match_data.function = TOKEN_D_BOX_GAP; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; - match_data.flags = (THEME_MATCH_SHADOW | - THEME_MATCH_STATE | - THEME_MATCH_ORIENTATION); - match_data.shadow = shadow; - match_data.state = state; - - if (!draw_gap_image (style, window, area, widget, &match_data, TRUE, - x, y, width, height, gap_side, gap_x, gap_width)) - parent_class->draw_box_gap (style, window, state, shadow, area, widget, detail, - x, y, width, height, gap_side, gap_x, gap_width); -} - -static void -draw_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkPositionType gap_side) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - /* Why? */ - if (width >=0) - width++; - if (height >=0) - height++; - - match_data.function = TOKEN_D_EXTENSION; - match_data.detail = (gchar *)detail; - match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE | THEME_MATCH_GAP_SIDE; - match_data.shadow = shadow; - match_data.state = state; - match_data.gap_side = gap_side; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_extension (style, window, state, shadow, area, widget, detail, - x, y, width, height, gap_side); -} - -static void -draw_focus (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_FOCUS; - match_data.detail = (gchar *)detail; - match_data.flags = 0; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, FALSE, - x, y, width, height)) - parent_class->draw_focus (style, window, state_type, area, widget, detail, - x, y, width, height); -} - -static void -draw_slider (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) -{ - ThemeMatchData match_data; - - g_return_if_fail(style != NULL); - g_return_if_fail(window != NULL); - - match_data.function = TOKEN_D_SLIDER; - match_data.detail = (gchar *)detail; - match_data.flags = (THEME_MATCH_SHADOW | - THEME_MATCH_STATE | - THEME_MATCH_ORIENTATION); - match_data.shadow = shadow; - match_data.state = state; - match_data.orientation = orientation; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_slider (style, window, state, shadow, area, widget, detail, - x, y, width, height, orientation); -} - - -static void -draw_handle (GtkStyle *style, - GdkWindow *window, - GtkStateType state, - GtkShadowType shadow, - GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) -{ - ThemeMatchData match_data; - - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - match_data.function = TOKEN_D_HANDLE; - match_data.detail = (gchar *)detail; - match_data.flags = (THEME_MATCH_SHADOW | - THEME_MATCH_STATE | - THEME_MATCH_ORIENTATION); - match_data.shadow = shadow; - match_data.state = state; - match_data.orientation = orientation; - - if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE, - x, y, width, height)) - parent_class->draw_handle (style, window, state, shadow, area, widget, detail, - x, y, width, height, orientation); -} - -GType pixbuf_type_style = 0; - -void -pixbuf_style_register_type (GTypeModule *module) -{ - static const GTypeInfo object_info = - { - sizeof (PixbufStyleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) pixbuf_style_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PixbufStyle), - 0, /* n_preallocs */ - (GInstanceInitFunc) pixbuf_style_init, - }; - - pixbuf_type_style = g_type_module_register_type (module, - GTK_TYPE_STYLE, - "PixbufStyle", - &object_info, 0); -} - -static void -pixbuf_style_init (PixbufStyle *style) -{ -} - -static void -pixbuf_style_class_init (PixbufStyleClass *klass) -{ - GtkStyleClass *style_class = GTK_STYLE_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - style_class->draw_hline = draw_hline; - style_class->draw_vline = draw_vline; - style_class->draw_shadow = draw_shadow; - style_class->draw_arrow = draw_arrow; - style_class->draw_diamond = draw_diamond; - style_class->draw_string = draw_string; - style_class->draw_box = draw_box; - style_class->draw_flat_box = draw_flat_box; - style_class->draw_check = draw_check; - style_class->draw_option = draw_option; - style_class->draw_tab = draw_tab; - style_class->draw_shadow_gap = draw_shadow_gap; - style_class->draw_box_gap = draw_box_gap; - style_class->draw_extension = draw_extension; - style_class->draw_focus = draw_focus; - style_class->draw_slider = draw_slider; - style_class->draw_handle = draw_handle; -} diff --git a/modules/engines/pixbuf/pixbuf-main.c b/modules/engines/pixbuf/pixbuf-main.c deleted file mode 100644 index 95d4525869..0000000000 --- a/modules/engines/pixbuf/pixbuf-main.c +++ /dev/null @@ -1,57 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include "pixbuf.h" -#include "pixbuf-style.h" -#include "pixbuf-rc-style.h" -#include - -G_MODULE_EXPORT void -theme_init (GTypeModule *module) -{ - pixbuf_rc_style_register_type (module); - pixbuf_style_register_type (module); -} - -G_MODULE_EXPORT void -theme_exit (void) -{ -} - -G_MODULE_EXPORT GtkRcStyle * -theme_create_rc_style (void) -{ - return GTK_RC_STYLE (g_object_new (PIXBUF_TYPE_RC_STYLE, NULL)); -} - -/* The following function will be called by GTK+ when the module - * is loaded and checks to see if we are compatible with the - * version of GTK+ that loads us. - */ -G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module); -const gchar* -g_module_check_init (GModule *module) -{ - return gtk_check_version (GTK_MAJOR_VERSION, - GTK_MINOR_VERSION, - GTK_MICRO_VERSION - GTK_INTERFACE_AGE); -} diff --git a/modules/engines/pixbuf/pixbuf-rc-style.c b/modules/engines/pixbuf/pixbuf-rc-style.c deleted file mode 100644 index 22f3941455..0000000000 --- a/modules/engines/pixbuf/pixbuf-rc-style.c +++ /dev/null @@ -1,815 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include "pixbuf.h" -#include "pixbuf-style.h" -#include "pixbuf-rc-style.h" - -static void pixbuf_rc_style_init (PixbufRcStyle *style); -static void pixbuf_rc_style_class_init (PixbufRcStyleClass *klass); -static void pixbuf_rc_style_finalize (GObject *object); -static guint pixbuf_rc_style_parse (GtkRcStyle *rc_style, - GtkSettings *settings, - GScanner *scanner); -static void pixbuf_rc_style_merge (GtkRcStyle *dest, - GtkRcStyle *src); -static GtkStyle *pixbuf_rc_style_create_style (GtkRcStyle *rc_style); - -static void theme_image_unref (ThemeImage *data); - -static struct - { - gchar *name; - guint token; - } -theme_symbols[] = -{ - { "image", TOKEN_IMAGE }, - { "function", TOKEN_FUNCTION }, - { "file", TOKEN_FILE }, - { "stretch", TOKEN_STRETCH }, - { "recolorable", TOKEN_RECOLORABLE }, - { "border", TOKEN_BORDER }, - { "detail", TOKEN_DETAIL }, - { "state", TOKEN_STATE }, - { "shadow", TOKEN_SHADOW }, - { "gap_side", TOKEN_GAP_SIDE }, - { "gap_file", TOKEN_GAP_FILE }, - { "gap_border", TOKEN_GAP_BORDER }, - { "gap_start_file", TOKEN_GAP_START_FILE }, - { "gap_start_border", TOKEN_GAP_START_BORDER }, - { "gap_end_file", TOKEN_GAP_END_FILE }, - { "gap_end_border", TOKEN_GAP_END_BORDER }, - { "overlay_file", TOKEN_OVERLAY_FILE }, - { "overlay_border", TOKEN_OVERLAY_BORDER }, - { "overlay_stretch", TOKEN_OVERLAY_STRETCH }, - { "arrow_direction", TOKEN_ARROW_DIRECTION }, - { "orientation", TOKEN_ORIENTATION }, - - { "HLINE", TOKEN_D_HLINE }, - { "VLINE", TOKEN_D_VLINE }, - { "SHADOW", TOKEN_D_SHADOW }, - { "POLYGON", TOKEN_D_POLYGON }, - { "ARROW", TOKEN_D_ARROW }, - { "DIAMOND", TOKEN_D_DIAMOND }, - { "OVAL", TOKEN_D_OVAL }, - { "STRING", TOKEN_D_STRING }, - { "BOX", TOKEN_D_BOX }, - { "FLAT_BOX", TOKEN_D_FLAT_BOX }, - { "CHECK", TOKEN_D_CHECK }, - { "OPTION", TOKEN_D_OPTION }, - { "CROSS", TOKEN_D_CROSS }, - { "RAMP", TOKEN_D_RAMP }, - { "TAB", TOKEN_D_TAB }, - { "SHADOW_GAP", TOKEN_D_SHADOW_GAP }, - { "BOX_GAP", TOKEN_D_BOX_GAP }, - { "EXTENSION", TOKEN_D_EXTENSION }, - { "FOCUS", TOKEN_D_FOCUS }, - { "SLIDER", TOKEN_D_SLIDER }, - { "ENTRY", TOKEN_D_ENTRY }, - { "HANDLE", TOKEN_D_HANDLE }, - { "STEPPER", TOKEN_D_STEPPER }, - - { "TRUE", TOKEN_TRUE }, - { "FALSE", TOKEN_FALSE }, - - { "TOP", TOKEN_TOP }, - { "UP", TOKEN_UP }, - { "BOTTOM", TOKEN_BOTTOM }, - { "DOWN", TOKEN_DOWN }, - { "LEFT", TOKEN_LEFT }, - { "RIGHT", TOKEN_RIGHT }, - - { "NORMAL", TOKEN_NORMAL }, - { "ACTIVE", TOKEN_ACTIVE }, - { "PRELIGHT", TOKEN_PRELIGHT }, - { "SELECTED", TOKEN_SELECTED }, - { "INSENSITIVE", TOKEN_INSENSITIVE }, - - { "NONE", TOKEN_NONE }, - { "IN", TOKEN_IN }, - { "OUT", TOKEN_OUT }, - { "ETCHED_IN", TOKEN_ETCHED_IN }, - { "ETCHED_OUT", TOKEN_ETCHED_OUT }, - { "HORIZONTAL", TOKEN_HORIZONTAL }, - { "VERTICAL", TOKEN_VERTICAL }, -}; - -static GtkRcStyleClass *parent_class; - -GType pixbuf_type_rc_style = 0; - -void -pixbuf_rc_style_register_type (GTypeModule *module) -{ - static const GTypeInfo object_info = - { - sizeof (PixbufRcStyleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) pixbuf_rc_style_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PixbufRcStyle), - 0, /* n_preallocs */ - (GInstanceInitFunc) pixbuf_rc_style_init, - }; - - pixbuf_type_rc_style = g_type_module_register_type (module, - GTK_TYPE_RC_STYLE, - "PixbufRcStyle", - &object_info, 0); -} - -static void -pixbuf_rc_style_init (PixbufRcStyle *style) -{ -} - -static void -pixbuf_rc_style_class_init (PixbufRcStyleClass *klass) -{ - GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - rc_style_class->parse = pixbuf_rc_style_parse; - rc_style_class->merge = pixbuf_rc_style_merge; - rc_style_class->create_style = pixbuf_rc_style_create_style; - - object_class->finalize = pixbuf_rc_style_finalize; -} - -static void -pixbuf_rc_style_finalize (GObject *object) -{ - PixbufRcStyle *rc_style = PIXBUF_RC_STYLE (object); - - g_list_foreach (rc_style->img_list, (GFunc) theme_image_unref, NULL); - g_list_free (rc_style->img_list); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static guint -theme_parse_file(GtkSettings *settings, - GScanner *scanner, - ThemePixbuf **theme_pb) -{ - guint token; - gchar *pixmap; - - /* Skip 'blah_file' */ - token = g_scanner_get_next_token(scanner); - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - if (!*theme_pb) - *theme_pb = theme_pixbuf_new (); - - pixmap = gtk_rc_find_pixmap_in_path(settings, scanner, scanner->value.v_string); - if (pixmap) - { - theme_pixbuf_set_filename (*theme_pb, pixmap); - g_free (pixmap); - } - - return G_TOKEN_NONE; -} - -static guint -theme_parse_border (GScanner *scanner, - ThemePixbuf **theme_pb) -{ - guint token; - gint left, right, top, bottom; - - /* Skip 'blah_border' */ - token = g_scanner_get_next_token(scanner); - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_LEFT_CURLY) - return G_TOKEN_LEFT_CURLY; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_INT) - return G_TOKEN_INT; - left = scanner->value.v_int; - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_COMMA) - return G_TOKEN_COMMA; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_INT) - return G_TOKEN_INT; - right = scanner->value.v_int; - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_COMMA) - return G_TOKEN_COMMA; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_INT) - return G_TOKEN_INT; - top = scanner->value.v_int; - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_COMMA) - return G_TOKEN_COMMA; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_INT) - return G_TOKEN_INT; - bottom = scanner->value.v_int; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_RIGHT_CURLY) - return G_TOKEN_RIGHT_CURLY; - - if (!*theme_pb) - *theme_pb = theme_pixbuf_new (); - - theme_pixbuf_set_border (*theme_pb, left, right, top, bottom); - - return G_TOKEN_NONE; -} - -static guint -theme_parse_stretch(GScanner *scanner, - ThemePixbuf **theme_pb) -{ - guint token; - gboolean stretch; - - /* Skip 'blah_stretch' */ - token = g_scanner_get_next_token(scanner); - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token == TOKEN_TRUE) - stretch = TRUE; - else if (token == TOKEN_FALSE) - stretch = FALSE; - else - return TOKEN_TRUE; - - if (!*theme_pb) - *theme_pb = theme_pixbuf_new (); - - theme_pixbuf_set_stretch (*theme_pb, stretch); - - return G_TOKEN_NONE; -} - -static guint -theme_parse_recolorable(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_RECOLORABLE) - return TOKEN_RECOLORABLE; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token == TOKEN_TRUE) - data->recolorable = 1; - else if (token == TOKEN_FALSE) - data->recolorable = 0; - else - return TOKEN_TRUE; - - return G_TOKEN_NONE; -} - -static guint -theme_parse_function(GScanner * scanner, - ThemeImage *data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_FUNCTION) - return TOKEN_FUNCTION; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if ((token >= TOKEN_D_HLINE) && (token <= TOKEN_D_STEPPER)) - data->match_data.function = token; - - return G_TOKEN_NONE; -} - -static guint -theme_parse_detail(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_DETAIL) - return TOKEN_DETAIL; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - if (data->match_data.detail) - g_free (data->match_data.detail); - - data->match_data.detail = g_strdup(scanner->value.v_string); - - return G_TOKEN_NONE; -} - -static guint -theme_parse_state(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_STATE) - return TOKEN_STATE; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token == TOKEN_NORMAL) - data->match_data.state = GTK_STATE_NORMAL; - else if (token == TOKEN_ACTIVE) - data->match_data.state = GTK_STATE_ACTIVE; - else if (token == TOKEN_PRELIGHT) - data->match_data.state = GTK_STATE_PRELIGHT; - else if (token == TOKEN_SELECTED) - data->match_data.state = GTK_STATE_SELECTED; - else if (token == TOKEN_INSENSITIVE) - data->match_data.state = GTK_STATE_INSENSITIVE; - else - return TOKEN_NORMAL; - - data->match_data.flags |= THEME_MATCH_STATE; - - return G_TOKEN_NONE; -} - -static guint -theme_parse_shadow(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_SHADOW) - return TOKEN_SHADOW; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token == TOKEN_NONE) - data->match_data.shadow = GTK_SHADOW_NONE; - else if (token == TOKEN_IN) - data->match_data.shadow = GTK_SHADOW_IN; - else if (token == TOKEN_OUT) - data->match_data.shadow = GTK_SHADOW_OUT; - else if (token == TOKEN_ETCHED_IN) - data->match_data.shadow = GTK_SHADOW_ETCHED_IN; - else if (token == TOKEN_ETCHED_OUT) - data->match_data.shadow = GTK_SHADOW_ETCHED_OUT; - else - return TOKEN_NONE; - - data->match_data.flags |= THEME_MATCH_SHADOW; - - return G_TOKEN_NONE; -} - -static guint -theme_parse_arrow_direction(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_ARROW_DIRECTION) - return TOKEN_ARROW_DIRECTION; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - if (token == TOKEN_UP) - data->match_data.arrow_direction = GTK_ARROW_UP; - else if (token == TOKEN_DOWN) - data->match_data.arrow_direction = GTK_ARROW_DOWN; - else if (token == TOKEN_LEFT) - data->match_data.arrow_direction = GTK_ARROW_LEFT; - else if (token == TOKEN_RIGHT) - data->match_data.arrow_direction = GTK_ARROW_RIGHT; - else - return TOKEN_UP; - - data->match_data.flags |= THEME_MATCH_ARROW_DIRECTION; - - return G_TOKEN_NONE; -} - -static guint -theme_parse_gap_side(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_GAP_SIDE) - return TOKEN_GAP_SIDE; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - - if (token == TOKEN_TOP) - data->match_data.gap_side = GTK_POS_TOP; - else if (token == TOKEN_BOTTOM) - data->match_data.gap_side = GTK_POS_BOTTOM; - else if (token == TOKEN_LEFT) - data->match_data.gap_side = GTK_POS_LEFT; - else if (token == TOKEN_RIGHT) - data->match_data.gap_side = GTK_POS_RIGHT; - else - return TOKEN_TOP; - - data->match_data.flags |= THEME_MATCH_GAP_SIDE; - - return G_TOKEN_NONE; -} - -static guint -theme_parse_orientation(GScanner * scanner, - ThemeImage * data) -{ - guint token; - - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_ORIENTATION) - return TOKEN_ORIENTATION; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token(scanner); - - if (token == TOKEN_HORIZONTAL) - data->match_data.orientation = GTK_ORIENTATION_HORIZONTAL; - else if (token == TOKEN_VERTICAL) - data->match_data.orientation = GTK_ORIENTATION_VERTICAL; - else - return TOKEN_HORIZONTAL; - - data->match_data.flags |= THEME_MATCH_ORIENTATION; - - return G_TOKEN_NONE; -} - -static void -theme_image_ref (ThemeImage *data) -{ - data->refcount++; -} - -static void -theme_image_unref (ThemeImage *data) -{ - data->refcount--; - if (data->refcount == 0) - { - if (data->match_data.detail) - g_free (data->match_data.detail); - if (data->background) - theme_pixbuf_destroy (data->background); - if (data->overlay) - theme_pixbuf_destroy (data->overlay); - if (data->gap_start) - theme_pixbuf_destroy (data->gap_start); - if (data->gap) - theme_pixbuf_destroy (data->gap); - if (data->gap_end) - theme_pixbuf_destroy (data->gap_end); - g_free (data); - } -} - -static guint -theme_parse_image(GtkSettings *settings, - GScanner *scanner, - PixbufRcStyle *pixbuf_style, - ThemeImage **data_return) -{ - guint token; - ThemeImage *data; - - data = NULL; - token = g_scanner_get_next_token(scanner); - if (token != TOKEN_IMAGE) - return TOKEN_IMAGE; - - token = g_scanner_get_next_token(scanner); - if (token != G_TOKEN_LEFT_CURLY) - return G_TOKEN_LEFT_CURLY; - - data = g_malloc(sizeof(ThemeImage)); - - data->refcount = 1; - - data->background = NULL; - data->overlay = NULL; - data->gap_start = NULL; - data->gap = NULL; - data->gap_end = NULL; - - data->recolorable = FALSE; - - data->match_data.function = 0; - data->match_data.detail = NULL; - data->match_data.flags = 0; - - token = g_scanner_peek_next_token(scanner); - while (token != G_TOKEN_RIGHT_CURLY) - { - switch (token) - { - case TOKEN_FUNCTION: - token = theme_parse_function(scanner, data); - break; - case TOKEN_RECOLORABLE: - token = theme_parse_recolorable(scanner, data); - break; - case TOKEN_DETAIL: - token = theme_parse_detail(scanner, data); - break; - case TOKEN_STATE: - token = theme_parse_state(scanner, data); - break; - case TOKEN_SHADOW: - token = theme_parse_shadow(scanner, data); - break; - case TOKEN_GAP_SIDE: - token = theme_parse_gap_side(scanner, data); - break; - case TOKEN_ARROW_DIRECTION: - token = theme_parse_arrow_direction(scanner, data); - break; - case TOKEN_ORIENTATION: - token = theme_parse_orientation(scanner, data); - break; - case TOKEN_FILE: - token = theme_parse_file(settings, scanner, &data->background); - break; - case TOKEN_BORDER: - token = theme_parse_border(scanner, &data->background); - break; - case TOKEN_STRETCH: - token = theme_parse_stretch(scanner, &data->background); - break; - case TOKEN_GAP_FILE: - token = theme_parse_file(settings, scanner, &data->gap); - break; - case TOKEN_GAP_BORDER: - token = theme_parse_border(scanner, &data->gap); - break; - case TOKEN_GAP_START_FILE: - token = theme_parse_file(settings, scanner, &data->gap_start); - break; - case TOKEN_GAP_START_BORDER: - token = theme_parse_border(scanner, &data->gap_start); - break; - case TOKEN_GAP_END_FILE: - token = theme_parse_file(settings, scanner, &data->gap_end); - break; - case TOKEN_GAP_END_BORDER: - token = theme_parse_border(scanner, &data->gap_end); - break; - case TOKEN_OVERLAY_FILE: - token = theme_parse_file(settings, scanner, &data->overlay); - break; - case TOKEN_OVERLAY_BORDER: - token = theme_parse_border(scanner, &data->overlay); - break; - case TOKEN_OVERLAY_STRETCH: - token = theme_parse_stretch(scanner, &data->overlay); - break; - default: - g_scanner_get_next_token(scanner); - token = G_TOKEN_RIGHT_CURLY; - break; - } - if (token != G_TOKEN_NONE) - { - /* error - cleanup for exit */ - theme_image_unref (data); - *data_return = NULL; - return token; - } - token = g_scanner_peek_next_token(scanner); - } - - token = g_scanner_get_next_token(scanner); - - if (data->background && !data->background->filename) - { - g_scanner_warn (scanner, "Background image options specified without filename"); - theme_pixbuf_destroy (data->background); - data->background = NULL; - } - - if (data->overlay && !data->overlay->filename) - { - g_scanner_warn (scanner, "Overlay image options specified without filename"); - theme_pixbuf_destroy (data->overlay); - data->overlay = NULL; - } - - if (token != G_TOKEN_RIGHT_CURLY) - { - /* error - cleanup for exit */ - theme_image_unref (data); - *data_return = NULL; - return G_TOKEN_RIGHT_CURLY; - } - - /* everything is fine now - insert yer cruft */ - *data_return = data; - return G_TOKEN_NONE; -} - -static guint -pixbuf_rc_style_parse (GtkRcStyle *rc_style, - GtkSettings *settings, - GScanner *scanner) - -{ - static GQuark scope_id = 0; - PixbufRcStyle *pixbuf_style = PIXBUF_RC_STYLE (rc_style); - - guint old_scope; - guint token; - gint i; - ThemeImage *img; - - /* Set up a new scope in this scanner. */ - - if (!scope_id) - scope_id = g_quark_from_string("pixbuf_theme_engine"); - - /* If we bail out due to errors, we *don't* reset the scope, so the - * error messaging code can make sense of our tokens. - */ - old_scope = g_scanner_set_scope(scanner, scope_id); - - /* Now check if we already added our symbols to this scope - * (in some previous call to theme_parse_rc_style for the - * same scanner. - */ - - if (!g_scanner_lookup_symbol(scanner, theme_symbols[0].name)) - { - g_scanner_freeze_symbol_table(scanner); - for (i = 0; i < G_N_ELEMENTS (theme_symbols); i++) - g_scanner_scope_add_symbol(scanner, scope_id, - theme_symbols[i].name, - GINT_TO_POINTER(theme_symbols[i].token)); - g_scanner_thaw_symbol_table(scanner); - } - - /* We're ready to go, now parse the top level */ - - token = g_scanner_peek_next_token(scanner); - while (token != G_TOKEN_RIGHT_CURLY) - { - switch (token) - { - case TOKEN_IMAGE: - img = NULL; - token = theme_parse_image(settings, scanner, pixbuf_style, &img); - break; - default: - g_scanner_get_next_token(scanner); - token = G_TOKEN_RIGHT_CURLY; - break; - } - - if (token != G_TOKEN_NONE) - return token; - else - pixbuf_style->img_list = g_list_append(pixbuf_style->img_list, img); - - token = g_scanner_peek_next_token(scanner); - } - - g_scanner_get_next_token(scanner); - - g_scanner_set_scope(scanner, old_scope); - - return G_TOKEN_NONE; -} - -static void -pixbuf_rc_style_merge (GtkRcStyle *dest, - GtkRcStyle *src) -{ - if (PIXBUF_IS_RC_STYLE (src)) - { - PixbufRcStyle *pixbuf_dest = PIXBUF_RC_STYLE (dest); - PixbufRcStyle *pixbuf_src = PIXBUF_RC_STYLE (src); - GList *tmp_list1, *tmp_list2; - - if (pixbuf_src->img_list) - { - /* Copy src image list and append to dest image list */ - - tmp_list2 = g_list_last (pixbuf_dest->img_list); - tmp_list1 = pixbuf_src->img_list; - - while (tmp_list1) - { - if (tmp_list2) - { - tmp_list2->next = g_list_alloc(); - tmp_list2->next->data = tmp_list1->data; - tmp_list2->next->prev = tmp_list2; - - tmp_list2 = tmp_list2->next; - } - else - { - pixbuf_dest->img_list = g_list_append (NULL, tmp_list1->data); - tmp_list2 = pixbuf_dest->img_list; - } - - theme_image_ref (tmp_list1->data); - tmp_list1 = tmp_list1->next; - } - } - } - - parent_class->merge (dest, src); -} - -/* Create an empty style suitable to this RC style - */ -static GtkStyle * -pixbuf_rc_style_create_style (GtkRcStyle *rc_style) -{ - return GTK_STYLE (g_object_new (PIXBUF_TYPE_STYLE, NULL)); -} - diff --git a/modules/engines/pixbuf/pixbuf-rc-style.h b/modules/engines/pixbuf/pixbuf-rc-style.h deleted file mode 100644 index 53d93b794e..0000000000 --- a/modules/engines/pixbuf/pixbuf-rc-style.h +++ /dev/null @@ -1,49 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include - -typedef struct _PixbufRcStyle PixbufRcStyle; -typedef struct _PixbufRcStyleClass PixbufRcStyleClass; - -extern GType pixbuf_type_rc_style; - -#define PIXBUF_TYPE_RC_STYLE pixbuf_type_rc_style -#define PIXBUF_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PIXBUF_TYPE_RC_STYLE, PixbufRcStyle)) -#define PIXBUF_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIXBUF_TYPE_RC_STYLE, PixbufRcStyleClass)) -#define PIXBUF_IS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PIXBUF_TYPE_RC_STYLE)) -#define PIXBUF_IS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIXBUF_TYPE_RC_STYLE)) -#define PIXBUF_RC_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIXBUF_TYPE_RC_STYLE, PixbufRcStyleClass)) - -struct _PixbufRcStyle -{ - GtkRcStyle parent_instance; - - GList *img_list; -}; - -struct _PixbufRcStyleClass -{ - GtkRcStyleClass parent_class; -}; - -void pixbuf_rc_style_register_type (GTypeModule *module); diff --git a/modules/engines/pixbuf/pixbuf-render.c b/modules/engines/pixbuf/pixbuf-render.c deleted file mode 100644 index c449da3734..0000000000 --- a/modules/engines/pixbuf/pixbuf-render.c +++ /dev/null @@ -1,803 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include - -#include "pixbuf.h" -#include - -static GCache *pixbuf_cache = NULL; - -static GdkPixbuf * -bilinear_gradient (GdkPixbuf *src, - gint src_x, - gint src_y, - gint width, - gint height) -{ - guint n_channels = gdk_pixbuf_get_n_channels (src); - guint src_rowstride = gdk_pixbuf_get_rowstride (src); - guchar *src_pixels = gdk_pixbuf_get_pixels (src); - guchar *p1, *p2, *p3, *p4; - guint dest_rowstride; - guchar *dest_pixels; - GdkPixbuf *result; - int i, j, k; - - p1 = src_pixels + (src_y - 1) * src_rowstride + (src_x - 1) * n_channels; - p2 = p1 + n_channels; - p3 = src_pixels + src_y * src_rowstride + (src_x - 1) * n_channels; - p4 = p3 + n_channels; - - result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, - width, height); - dest_rowstride = gdk_pixbuf_get_rowstride (result); - dest_pixels = gdk_pixbuf_get_pixels (result); - - for (i = 0; i < height; i++) - { - guchar *p = dest_pixels + dest_rowstride *i; - guint v[4]; - gint dv[4]; - - for (k = 0; k < n_channels; k++) - { - guint start = ((height - i) * p1[k] + (1 + i) * p3[k]) / (height + 1); - guint end = ((height - i) * p2[k] + (1 + i) * p4[k]) / (height + 1); - - dv[k] = (((gint)end - (gint)start) << 16) / (width + 1); - v[k] = (start << 16) + dv[k] + 0x8000; - } - - for (j = width; j; j--) - { - for (k = 0; k < n_channels; k++) - { - *(p++) = v[k] >> 16; - v[k] += dv[k]; - } - } - } - - return result; -} - -static GdkPixbuf * -horizontal_gradient (GdkPixbuf *src, - gint src_x, - gint src_y, - gint width, - gint height) -{ - guint n_channels = gdk_pixbuf_get_n_channels (src); - guint src_rowstride = gdk_pixbuf_get_rowstride (src); - guchar *src_pixels = gdk_pixbuf_get_pixels (src); - guint dest_rowstride; - guchar *dest_pixels; - GdkPixbuf *result; - int i, j, k; - - result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, - width, height); - dest_rowstride = gdk_pixbuf_get_rowstride (result); - dest_pixels = gdk_pixbuf_get_pixels (result); - - for (i = 0; i < height; i++) - { - guchar *p = dest_pixels + dest_rowstride *i; - guchar *p1 = src_pixels + (src_y + i) * src_rowstride + (src_x - 1) * n_channels; - guchar *p2 = p1 + n_channels; - - guint v[4]; - gint dv[4]; - - for (k = 0; k < n_channels; k++) - { - dv[k] = (((gint)p2[k] - (gint)p1[k]) << 16) / (width + 1); - v[k] = (p1[k] << 16) + dv[k] + 0x8000; - } - - for (j = width; j; j--) - { - for (k = 0; k < n_channels; k++) - { - *(p++) = v[k] >> 16; - v[k] += dv[k]; - } - } - } - - return result; -} - -static GdkPixbuf * -vertical_gradient (GdkPixbuf *src, - gint src_x, - gint src_y, - gint width, - gint height) -{ - guint n_channels = gdk_pixbuf_get_n_channels (src); - guint src_rowstride = gdk_pixbuf_get_rowstride (src); - guchar *src_pixels = gdk_pixbuf_get_pixels (src); - guchar *top_pixels, *bottom_pixels; - guint dest_rowstride; - guchar *dest_pixels; - GdkPixbuf *result; - int i, j; - - top_pixels = src_pixels + (src_y - 1) * src_rowstride + (src_x) * n_channels; - bottom_pixels = top_pixels + src_rowstride; - - result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, - width, height); - dest_rowstride = gdk_pixbuf_get_rowstride (result); - dest_pixels = gdk_pixbuf_get_pixels (result); - - for (i = 0; i < height; i++) - { - guchar *p = dest_pixels + dest_rowstride *i; - guchar *p1 = top_pixels; - guchar *p2 = bottom_pixels; - - for (j = width * n_channels; j; j--) - *(p++) = ((height - i) * *(p1++) + (1 + i) * *(p2++)) / (height + 1); - } - - return result; -} - -static GdkPixbuf * -replicate_single (GdkPixbuf *src, - gint src_x, - gint src_y, - gint width, - gint height) -{ - guint n_channels = gdk_pixbuf_get_n_channels (src); - guchar *pixels = (gdk_pixbuf_get_pixels (src) + - src_y * gdk_pixbuf_get_rowstride (src) + - src_x * n_channels); - guchar r = *(pixels++); - guchar g = *(pixels++); - guchar b = *(pixels++); - guint dest_rowstride; - guchar *dest_pixels; - guchar a = 0; - GdkPixbuf *result; - int i, j; - - if (n_channels == 4) - a = *(pixels++); - - result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, - width, height); - dest_rowstride = gdk_pixbuf_get_rowstride (result); - dest_pixels = gdk_pixbuf_get_pixels (result); - - for (i = 0; i < height; i++) - { - guchar *p = dest_pixels + dest_rowstride *i; - - for (j = 0; j < width; j++) - { - *(p++) = r; - *(p++) = g; - *(p++) = b; - - if (n_channels == 4) - *(p++) = a; - } - } - - return result; -} - -static GdkPixbuf * -replicate_rows (GdkPixbuf *src, - gint src_x, - gint src_y, - gint width, - gint height) -{ - guint n_channels = gdk_pixbuf_get_n_channels (src); - guint src_rowstride = gdk_pixbuf_get_rowstride (src); - guchar *pixels = (gdk_pixbuf_get_pixels (src) + src_y * src_rowstride + src_x * n_channels); - guchar *dest_pixels; - GdkPixbuf *result; - guint dest_rowstride; - int i; - - result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, - width, height); - dest_rowstride = gdk_pixbuf_get_rowstride (result); - dest_pixels = gdk_pixbuf_get_pixels (result); - - for (i = 0; i < height; i++) - memcpy (dest_pixels + dest_rowstride * i, pixels, n_channels * width); - - return result; -} - -static GdkPixbuf * -replicate_cols (GdkPixbuf *src, - gint src_x, - gint src_y, - gint width, - gint height) -{ - guint n_channels = gdk_pixbuf_get_n_channels (src); - guint src_rowstride = gdk_pixbuf_get_rowstride (src); - guchar *pixels = (gdk_pixbuf_get_pixels (src) + src_y * src_rowstride + src_x * n_channels); - guchar *dest_pixels; - GdkPixbuf *result; - guint dest_rowstride; - int i, j; - - result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, - width, height); - dest_rowstride = gdk_pixbuf_get_rowstride (result); - dest_pixels = gdk_pixbuf_get_pixels (result); - - for (i = 0; i < height; i++) - { - guchar *p = dest_pixels + dest_rowstride * i; - guchar *q = pixels + src_rowstride * i; - - guchar r = *(q++); - guchar g = *(q++); - guchar b = *(q++); - guchar a = 0; - - if (n_channels == 4) - a = *(q++); - - for (j = 0; j < width; j++) - { - *(p++) = r; - *(p++) = g; - *(p++) = b; - - if (n_channels == 4) - *(p++) = a; - } - } - - return result; -} - -/* Scale the rectangle (src_x, src_y, src_width, src_height) - * onto the rectangle (dest_x, dest_y, dest_width, dest_height) - * of the destination, clip by clip_rect and render - */ -static void -pixbuf_render (GdkPixbuf *src, - guint hints, - GdkWindow *window, - GdkBitmap *mask, - GdkRectangle *clip_rect, - gint src_x, - gint src_y, - gint src_width, - gint src_height, - gint dest_x, - gint dest_y, - gint dest_width, - gint dest_height) -{ - GdkPixbuf *tmp_pixbuf; - GdkRectangle rect; - int x_offset, y_offset; - gboolean has_alpha = gdk_pixbuf_get_has_alpha (src); - gint src_rowstride = gdk_pixbuf_get_rowstride (src); - gint src_n_channels = gdk_pixbuf_get_n_channels (src); - - if (dest_width <= 0 || dest_height <= 0) - return; - - rect.x = dest_x; - rect.y = dest_y; - rect.width = dest_width; - rect.height = dest_height; - - if (hints & THEME_MISSING) - return; - - /* FIXME: Because we use the mask to shape windows, we don't use - * clip_rect to clip what we draw to the mask, only to clip - * what we actually draw. But this leads to the horrible ineffiency - * of scale the whole image to get a little bit of it. - */ - if (!mask && clip_rect) - { - if (!gdk_rectangle_intersect (clip_rect, &rect, &rect)) - return; - } - - if (dest_width == src_width && dest_height == src_height) - { - tmp_pixbuf = g_object_ref (src); - - x_offset = src_x + rect.x - dest_x; - y_offset = src_y + rect.y - dest_y; - } - else if (src_width == 0 && src_height == 0) - { - tmp_pixbuf = bilinear_gradient (src, src_x, src_y, dest_width, dest_height); - - x_offset = rect.x - dest_x; - y_offset = rect.y - dest_y; - } - else if (src_width == 0 && dest_height == src_height) - { - tmp_pixbuf = horizontal_gradient (src, src_x, src_y, dest_width, dest_height); - - x_offset = rect.x - dest_x; - y_offset = rect.y - dest_y; - } - else if (src_height == 0 && dest_width == src_width) - { - tmp_pixbuf = vertical_gradient (src, src_x, src_y, dest_width, dest_height); - - x_offset = rect.x - dest_x; - y_offset = rect.y - dest_y; - } - else if ((hints & THEME_CONSTANT_COLS) && (hints & THEME_CONSTANT_ROWS)) - { - tmp_pixbuf = replicate_single (src, src_x, src_y, dest_width, dest_height); - - x_offset = rect.x - dest_x; - y_offset = rect.y - dest_y; - } - else if (dest_width == src_width && (hints & THEME_CONSTANT_COLS)) - { - tmp_pixbuf = replicate_rows (src, src_x, src_y, dest_width, dest_height); - - x_offset = rect.x - dest_x; - y_offset = rect.y - dest_y; - } - else if (dest_height == src_height && (hints & THEME_CONSTANT_ROWS)) - { - tmp_pixbuf = replicate_cols (src, src_x, src_y, dest_width, dest_height); - - x_offset = rect.x - dest_x; - y_offset = rect.y - dest_y; - } - else - { - double x_scale = (double)dest_width / src_width; - double y_scale = (double)dest_height / src_height; - guchar *pixels; - GdkPixbuf *partial_src; - - pixels = (gdk_pixbuf_get_pixels (src) - + src_y * src_rowstride - + src_x * src_n_channels); - - partial_src = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, - has_alpha, - 8, src_width, src_height, - src_rowstride, - NULL, NULL); - - tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, - has_alpha, 8, - rect.width, rect.height); - - gdk_pixbuf_scale (partial_src, tmp_pixbuf, - 0, 0, rect.width, rect.height, - dest_x - rect.x, dest_y - rect.y, - x_scale, y_scale, - GDK_INTERP_BILINEAR); - - gdk_pixbuf_unref (partial_src); - - x_offset = 0; - y_offset = 0; - } - - if (mask) - { - gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask, - x_offset, y_offset, - rect.x, rect.y, - rect.width, rect.height, - 128); - } - - gdk_pixbuf_render_to_drawable_alpha (tmp_pixbuf, window, - x_offset, y_offset, - rect.x, rect.y, - rect.width, rect.height, - GDK_PIXBUF_ALPHA_FULL, 128, - GDK_RGB_DITHER_NORMAL, - 0, 0); - gdk_pixbuf_unref (tmp_pixbuf); -} - -ThemePixbuf * -theme_pixbuf_new (void) -{ - ThemePixbuf *result = g_new0 (ThemePixbuf, 1); - result->filename = NULL; - result->pixbuf = NULL; - - result->stretch = TRUE; - result->border_left = 0; - result->border_right = 0; - result->border_bottom = 0; - result->border_top = 0; - - return result; -} - -void -theme_pixbuf_destroy (ThemePixbuf *theme_pb) -{ - theme_pixbuf_set_filename (theme_pb, NULL); - g_free (theme_pb); -} - -void -theme_pixbuf_set_filename (ThemePixbuf *theme_pb, - const char *filename) -{ - if (theme_pb->pixbuf) - { - g_cache_remove (pixbuf_cache, theme_pb->pixbuf); - theme_pb->pixbuf = NULL; - } - - if (theme_pb->filename) - g_free (theme_pb->filename); - - if (filename) - theme_pb->filename = g_strdup (filename); - else - theme_pb->filename = NULL; -} - -static guint -compute_hint (GdkPixbuf *pixbuf, - gint x0, - gint x1, - gint y0, - gint y1) -{ - int i, j; - int hints = THEME_CONSTANT_ROWS | THEME_CONSTANT_COLS | THEME_MISSING; - int n_channels = gdk_pixbuf_get_n_channels (pixbuf); - - guchar *data = gdk_pixbuf_get_pixels (pixbuf); - int rowstride = gdk_pixbuf_get_rowstride (pixbuf); - - if (x0 == x1 || y0 == y1) - return 0; - - for (i = y0; i < y1; i++) - { - guchar *p = data + i * rowstride + x0 * n_channels; - guchar r = p[0]; - guchar g = p[1]; - guchar b = p[2]; - guchar a = 0; - - if (n_channels == 4) - a = p[3]; - - for (j = x0; j < x1 ; j++) - { - if (n_channels != 4 || p[3] != 0) - { - hints &= ~THEME_MISSING; - if (!(hints & THEME_CONSTANT_ROWS)) - goto cols; - } - - if (r != *(p++) || - g != *(p++) || - b != *(p++) || - (n_channels != 4 && a != *(p++))) - { - hints &= ~THEME_CONSTANT_ROWS; - if (!(hints & THEME_MISSING)) - goto cols; - } - } - } - - cols: - for (i = y0 + 1; i < y1; i++) - { - guchar *base = data + y0 * rowstride + x0 * n_channels; - guchar *p = data + i * rowstride + x0 * n_channels; - - if (memcmp (p, base, n_channels * (x1 - x0)) != 0) - { - hints &= ~THEME_CONSTANT_COLS; - return hints; - } - } - - return hints; -} - -static void -theme_pixbuf_compute_hints (ThemePixbuf *theme_pb) -{ - int i, j; - gint width = gdk_pixbuf_get_width (theme_pb->pixbuf); - gint height = gdk_pixbuf_get_height (theme_pb->pixbuf); - - if (theme_pb->border_left + theme_pb->border_right > width || - theme_pb->border_top + theme_pb->border_bottom > height) - { - g_warning ("Invalid borders specified for theme pixmap:\n" - " %s,\n" - "borders don't fit within the image", theme_pb->filename); - if (theme_pb->border_left + theme_pb->border_right > width) - { - theme_pb->border_left = width / 2; - theme_pb->border_right = (width + 1) / 2; - } - if (theme_pb->border_bottom + theme_pb->border_top > height) - { - theme_pb->border_top = height / 2; - theme_pb->border_bottom = (height + 1) / 2; - } - } - - for (i = 0; i < 3; i++) - { - gint y0, y1; - - switch (i) - { - case 0: - y0 = 0; - y1 = theme_pb->border_top; - break; - case 1: - y0 = theme_pb->border_top; - y1 = height - theme_pb->border_bottom; - break; - default: - y0 = height - theme_pb->border_bottom; - y1 = height; - break; - } - - for (j = 0; j < 3; j++) - { - gint x0, x1; - - switch (j) - { - case 0: - x0 = 0; - x1 = theme_pb->border_left; - break; - case 1: - x0 = theme_pb->border_left; - x1 = width - theme_pb->border_right; - break; - default: - x0 = width - theme_pb->border_right; - x1 = width; - break; - } - - theme_pb->hints[i][j] = compute_hint (theme_pb->pixbuf, x0, x1, y0, y1); - } - } - -} - -void -theme_pixbuf_set_border (ThemePixbuf *theme_pb, - gint left, - gint right, - gint top, - gint bottom) -{ - theme_pb->border_left = left; - theme_pb->border_right = right; - theme_pb->border_top = top; - theme_pb->border_bottom = bottom; - - if (theme_pb->pixbuf) - theme_pixbuf_compute_hints (theme_pb); -} - -void -theme_pixbuf_set_stretch (ThemePixbuf *theme_pb, - gboolean stretch) -{ - theme_pb->stretch = stretch; - - if (theme_pb->pixbuf) - theme_pixbuf_compute_hints (theme_pb); -} - -GdkPixbuf * -pixbuf_cache_value_new (gchar *filename) -{ - GError *err = NULL; - - GdkPixbuf *result = gdk_pixbuf_new_from_file (filename, &err); - if (!result) - { - g_warning ("Pixbuf theme: Cannot load pixmap file %s: %s\n", - filename, err->message); - g_error_free (err); - } - - return result; -} - -GdkPixbuf * -theme_pixbuf_get_pixbuf (ThemePixbuf *theme_pb) -{ - if (!theme_pb->pixbuf) - { - if (!pixbuf_cache) - pixbuf_cache = g_cache_new ((GCacheNewFunc)pixbuf_cache_value_new, - (GCacheDestroyFunc)gdk_pixbuf_unref, - (GCacheDupFunc)g_strdup, - (GCacheDestroyFunc)g_free, - g_str_hash, g_direct_hash, g_str_equal); - - theme_pb->pixbuf = g_cache_insert (pixbuf_cache, theme_pb->filename); - - if (theme_pb->stretch) - theme_pixbuf_compute_hints (theme_pb); - } - - return theme_pb->pixbuf; -} - -void -theme_pixbuf_render (ThemePixbuf *theme_pb, - GdkWindow *window, - GdkBitmap *mask, - GdkRectangle *clip_rect, - guint component_mask, - gboolean center, - gint x, - gint y, - gint width, - gint height) -{ - GdkPixbuf *pixbuf = theme_pixbuf_get_pixbuf (theme_pb); - gint src_x[4], src_y[4], dest_x[4], dest_y[4]; - gint pixbuf_width = gdk_pixbuf_get_width (pixbuf); - gint pixbuf_height = gdk_pixbuf_get_height (pixbuf); - - if (!pixbuf) - return; - - if (theme_pb->stretch) - { - src_x[0] = 0; - src_x[1] = theme_pb->border_left; - src_x[2] = pixbuf_width - theme_pb->border_right; - src_x[3] = pixbuf_width; - - src_y[0] = 0; - src_y[1] = theme_pb->border_top; - src_y[2] = pixbuf_height - theme_pb->border_bottom; - src_y[3] = pixbuf_height; - - dest_x[0] = x; - dest_x[1] = x + theme_pb->border_left; - dest_x[2] = x + width - theme_pb->border_right; - dest_x[3] = x + width; - - dest_y[0] = y; - dest_y[1] = y + theme_pb->border_top; - dest_y[2] = y + height - theme_pb->border_bottom; - dest_y[3] = y + height; - - if (component_mask & COMPONENT_ALL) - component_mask = (COMPONENT_ALL - 1) & ~component_mask; - -#define RENDER_COMPONENT(X1,X2,Y1,Y2) \ - pixbuf_render (pixbuf, theme_pb->hints[Y1][X1], window, mask, clip_rect, \ - src_x[X1], src_y[Y1], \ - src_x[X2] - src_x[X1], src_y[Y2] - src_y[Y1], \ - dest_x[X1], dest_y[Y1], \ - dest_x[X2] - dest_x[X1], dest_y[Y2] - dest_y[Y1]); - - if (component_mask & COMPONENT_NORTH_WEST) - RENDER_COMPONENT (0, 1, 0, 1); - - if (component_mask & COMPONENT_NORTH) - RENDER_COMPONENT (1, 2, 0, 1); - - if (component_mask & COMPONENT_NORTH_EAST) - RENDER_COMPONENT (2, 3, 0, 1); - - if (component_mask & COMPONENT_WEST) - RENDER_COMPONENT (0, 1, 1, 2); - - if (component_mask & COMPONENT_CENTER) - RENDER_COMPONENT (1, 2, 1, 2); - - if (component_mask & COMPONENT_EAST) - RENDER_COMPONENT (2, 3, 1, 2); - - if (component_mask & COMPONENT_SOUTH_WEST) - RENDER_COMPONENT (0, 1, 2, 3); - - if (component_mask & COMPONENT_SOUTH) - RENDER_COMPONENT (1, 2, 2, 3); - - if (component_mask & COMPONENT_SOUTH_EAST) - RENDER_COMPONENT (2, 3, 2, 3); - } - else - { - if (center) - { - x += (width - pixbuf_width) / 2; - y += (height - pixbuf_height) / 2; - - pixbuf_render (pixbuf, 0, window, NULL, clip_rect, - 0, 0, - pixbuf_width, pixbuf_height, - x, y, - pixbuf_width, pixbuf_height); - } - else - { - GdkPixmap *tmp_pixmap; - GdkGC *tmp_gc; - GdkGCValues gc_values; - - tmp_pixmap = gdk_pixmap_new (window, - pixbuf_width, - pixbuf_height, - -1); - tmp_gc = gdk_gc_new (tmp_pixmap); - gdk_pixbuf_render_to_drawable (pixbuf, tmp_pixmap, tmp_gc, - 0, 0, - 0, 0, - pixbuf_width, pixbuf_height, - GDK_RGB_DITHER_NORMAL, - 0, 0); - gdk_gc_unref (tmp_gc); - - gc_values.fill = GDK_TILED; - gc_values.tile = tmp_pixmap; - tmp_gc = gdk_gc_new_with_values (window, - &gc_values, GDK_GC_FILL | GDK_GC_TILE); - if (clip_rect) - gdk_draw_rectangle (window, tmp_gc, TRUE, - clip_rect->x, clip_rect->y, clip_rect->width, clip_rect->height); - else - gdk_draw_rectangle (window, tmp_gc, TRUE, x, y, width, height); - - gdk_gc_unref (tmp_gc); - gdk_pixmap_unref (tmp_pixmap); - } - } -} diff --git a/modules/engines/pixbuf/pixbuf-style.h b/modules/engines/pixbuf/pixbuf-style.h deleted file mode 100644 index 75fc0fd1ad..0000000000 --- a/modules/engines/pixbuf/pixbuf-style.h +++ /dev/null @@ -1,49 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include - -typedef struct _PixbufStyle PixbufStyle; -typedef struct _PixbufStyleClass PixbufStyleClass; - -extern GType pixbuf_type_style; - -#define PIXBUF_TYPE_STYLE pixbuf_type_style -#define PIXBUF_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PIXBUF_TYPE_STYLE, PixbufStyle)) -#define PIXBUF_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIXBUF_TYPE_STYLE, PixbufStyleClass)) -#define PIXBUF_IS_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PIXBUF_TYPE_STYLE)) -#define PIXBUF_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIXBUF_TYPE_STYLE)) -#define PIXBUF_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIXBUF_TYPE_STYLE, PixbufStyleClass)) - -struct _PixbufStyle -{ - GtkStyle parent_instance; -}; - -struct _PixbufStyleClass -{ - GtkStyleClass parent_class; -}; - -void pixbuf_style_register_type (GTypeModule *module); - - diff --git a/modules/engines/pixbuf/pixbuf.h b/modules/engines/pixbuf/pixbuf.h deleted file mode 100644 index 5d3b32e126..0000000000 --- a/modules/engines/pixbuf/pixbuf.h +++ /dev/null @@ -1,196 +0,0 @@ -/* GTK+ Pixbuf Engine - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * 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. - * - * Written by Owen Taylor , based on code by - * Carsten Haitzler - */ - -#include -#include - -/* internals */ - -typedef struct _ThemeData ThemeData; -typedef struct _ThemeImage ThemeImage; -typedef struct _ThemeMatchData ThemeMatchData; -typedef struct _ThemePixbuf ThemePixbuf; - -enum -{ - TOKEN_IMAGE = G_TOKEN_LAST + 1, - TOKEN_FUNCTION, - TOKEN_FILE, - TOKEN_STRETCH, - TOKEN_RECOLORABLE, - TOKEN_BORDER, - TOKEN_DETAIL, - TOKEN_STATE, - TOKEN_SHADOW, - TOKEN_GAP_SIDE, - TOKEN_GAP_FILE, - TOKEN_GAP_BORDER, - TOKEN_GAP_START_FILE, - TOKEN_GAP_START_BORDER, - TOKEN_GAP_END_FILE, - TOKEN_GAP_END_BORDER, - TOKEN_OVERLAY_FILE, - TOKEN_OVERLAY_BORDER, - TOKEN_OVERLAY_STRETCH, - TOKEN_ARROW_DIRECTION, - TOKEN_D_HLINE, - TOKEN_D_VLINE, - TOKEN_D_SHADOW, - TOKEN_D_POLYGON, - TOKEN_D_ARROW, - TOKEN_D_DIAMOND, - TOKEN_D_OVAL, - TOKEN_D_STRING, - TOKEN_D_BOX, - TOKEN_D_FLAT_BOX, - TOKEN_D_CHECK, - TOKEN_D_OPTION, - TOKEN_D_CROSS, - TOKEN_D_RAMP, - TOKEN_D_TAB, - TOKEN_D_SHADOW_GAP, - TOKEN_D_BOX_GAP, - TOKEN_D_EXTENSION, - TOKEN_D_FOCUS, - TOKEN_D_SLIDER, - TOKEN_D_ENTRY, - TOKEN_D_HANDLE, - TOKEN_D_STEPPER, - TOKEN_TRUE, - TOKEN_FALSE, - TOKEN_TOP, - TOKEN_UP, - TOKEN_BOTTOM, - TOKEN_DOWN, - TOKEN_LEFT, - TOKEN_RIGHT, - TOKEN_NORMAL, - TOKEN_ACTIVE, - TOKEN_PRELIGHT, - TOKEN_SELECTED, - TOKEN_INSENSITIVE, - TOKEN_NONE, - TOKEN_IN, - TOKEN_OUT, - TOKEN_ETCHED_IN, - TOKEN_ETCHED_OUT, - TOKEN_ORIENTATION, - TOKEN_HORIZONTAL, - TOKEN_VERTICAL -}; - -typedef enum -{ - COMPONENT_NORTH_WEST = 1 << 0, - COMPONENT_NORTH = 1 << 1, - COMPONENT_NORTH_EAST = 1 << 2, - COMPONENT_WEST = 1 << 3, - COMPONENT_CENTER = 1 << 4, - COMPONENT_EAST = 1 << 5, - COMPONENT_SOUTH_EAST = 1 << 6, - COMPONENT_SOUTH = 1 << 7, - COMPONENT_SOUTH_WEST = 1 << 8, - COMPONENT_ALL = 1 << 9 -} ThemePixbufComponent; - -typedef enum { - THEME_MATCH_GAP_SIDE = 1 << 0, - THEME_MATCH_ORIENTATION = 1 << 1, - THEME_MATCH_STATE = 1 << 2, - THEME_MATCH_SHADOW = 1 << 3, - THEME_MATCH_ARROW_DIRECTION = 1 << 4 -} ThemeMatchFlags; - -typedef enum { - THEME_CONSTANT_ROWS = 1 << 0, - THEME_CONSTANT_COLS = 1 << 1, - THEME_MISSING = 1 << 2 -} ThemeRenderHints; - -struct _ThemePixbuf -{ - gchar *filename; - GdkPixbuf *pixbuf; - gboolean stretch; - gint border_left; - gint border_right; - gint border_bottom; - gint border_top; - guint hints[3][3]; -}; - -struct _ThemeMatchData -{ - guint function; /* Mandatory */ - gchar *detail; - - ThemeMatchFlags flags; - - GtkPositionType gap_side; - GtkOrientation orientation; - GtkStateType state; - GtkShadowType shadow; - GtkArrowType arrow_direction; -}; - -struct _ThemeImage -{ - guint refcount; - - ThemePixbuf *background; - ThemePixbuf *overlay; - ThemePixbuf *gap_start; - ThemePixbuf *gap; - ThemePixbuf *gap_end; - - gchar recolorable; - - ThemeMatchData match_data; -}; - - -ThemePixbuf *theme_pixbuf_new (void); -void theme_pixbuf_destroy (ThemePixbuf *theme_pb); -void theme_pixbuf_set_filename (ThemePixbuf *theme_pb, - const char *filename); -GdkPixbuf * theme_pixbuf_get_pixbuf (ThemePixbuf *theme_pb); -void theme_pixbuf_set_border (ThemePixbuf *theme_pb, - gint left, - gint right, - gint top, - gint bottom); -void theme_pixbuf_set_stretch (ThemePixbuf *theme_pb, - gboolean stretch); -void theme_pixbuf_render (ThemePixbuf *theme_pb, - GdkWindow *window, - GdkBitmap *mask, - GdkRectangle *clip_rect, - guint component_mask, - gboolean center, - gint dest_x, - gint dest_y, - gint dest_width, - gint dest_height); - - - -extern GtkStyleClass pixmap_default_class;