diff options
author | Owen Taylor <otaylor@redhat.com> | 1998-11-06 16:03:17 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-11-06 16:03:17 +0000 |
commit | 093032a4c1940919ef403556d4912f371c3bfc24 (patch) | |
tree | 78ec24e0d6ce2d84453f27ba496673f53206db8e | |
parent | 4b0e615fc5e2ab8c996f08e5401ba459eca7f078 (diff) | |
download | gtk+-themes-2.tar.gz |
Queue a clear/redraw, not just a redraw, so the focus gets undrawnthemes-2
Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue
a clear/redraw, not just a redraw, so the focus
gets undrawn properly.
* gtk/gtktogglebutton.c (gtk_toggle_button_unrealize):
Chain to gtk_widget_unrealize() instead of duplicating
code.
Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed
last vestiges of old DND.
Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c: Restored inner border to entries,
erase cursors to background image.
Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() -
it was identical to paint_flat_box().
* gtk/gtkstyle.c: Coding style fixups.
* gtk/gtkwindow.c (gtk_window_move_resize): removed useless
test.
* gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c:
Change 'side' for paint_[box/shadow]_gap and paint_extension
to be GtkPositionType instead of a random int.
* gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use
"frame" as detail - an aspectframe should draw identical
to a frame.
Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed
from combine_child_shapes().
* gdk/gdkwindow.c: Merge propagate_shapes() and
propagate_combine_shapes() to remove code duplication.
56 files changed, 1789 insertions, 2131 deletions
@@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index dcf9ceb8a1..a2830a90f7 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index dcf9ceb8a1..a2830a90f7 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index dcf9ceb8a1..a2830a90f7 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index dcf9ceb8a1..a2830a90f7 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index dcf9ceb8a1..a2830a90f7 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index dcf9ceb8a1..a2830a90f7 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,49 @@ +Thu Nov 5 12:06:16 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkcheckbutton.c (gtk_check_button_draw_focus): Queue + a clear/redraw, not just a redraw, so the focus + gets undrawn properly. + + * gtk/gtktogglebutton.c (gtk_toggle_button_unrealize): + Chain to gtk_widget_unrealize() instead of duplicating + code. + +Wed Nov 4 14:34:51 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdk.c gdk/gdkprivate.h gdk/gdkwindow.c: Removed + last vestiges of old DND. + +Tue Nov 3 12:27:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c: Restored inner border to entries, + erase cursors to background image. + +Fri Oct 30 12:09:21 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtkstyle.[ch]: removed paint_entry() - + it was identical to paint_flat_box(). + + * gtk/gtkstyle.c: Coding style fixups. + + * gtk/gtkwindow.c (gtk_window_move_resize): removed useless + test. + + * gtk/gtkframe.c gtkstyle.[ch] gtknotebook.c: + Change 'side' for paint_[box/shadow]_gap and paint_extension + to be GtkPositionType instead of a random int. + + * gtk/gtkaspectframe.c (gtk_aspect_frame_paint): Use + "frame" as detail - an aspectframe should draw identical + to a frame. + +Tue Oct 27 09:58:11 1998 Owen Taylor <otaylor@redhat.com> + + * gdk/gdkwindow.c (gdk_window_merge_child_shapes): renamed + from combine_child_shapes(). + + * gdk/gdkwindow.c: Merge propagate_shapes() and + propagate_combine_shapes() to remove code duplication. + Thu Nov 5 14:31:57 PST 1998 Manish Singh <yosh@gimp.org> * gdk/gdk.c: sometimes we get a KeyRelease before a KeyPress in @@ -3,11 +3,6 @@ For 1.2.0 release: non-functional ones. Bugs: - * Widget redrawing when the window resizes sometimes messes up. - - GtkLabels sometimes redraw without clearing up the underlying background on - window resizes. - * Change bitfields to guints from enums, or vice versa? * MappingNotify events produce warnings. @@ -18,39 +13,10 @@ Bugs: types seperatedly from derived types, so we don't screw foreign fundamental types with an already extensively increased seqno. - * Expose events aren't being generated correctly for DND demo - - * delay dnd settings to take effect once a widget is realized, this is - to avoid force realizations. i think this goes along with owens dnd - changes? - -timj - The way DND data types are set in GtkWidget really needs to be fixed. - This is pretty high on my priority list, and I'll get to it as soon as - the column list widget is done. The correct way dnd data needs to be set - is to have a additional keyed data type with GtkWidget, which is applied to - the widget's window upon realize. - There also needs to be a way to set dnd-data on widget windows which are - not the main window (for widgets that create more than one window). - -Jay Painter - DnD seems to work for me, but yes, there needs to be some sort of - gtk_widget layer that makes it easier... Also, adding support for drop - zones might be nice. - -Elliot - This one is reproducabel for me: - testgtk --sync - popup colorselection - drag/drop works - start up preview color - drag works but not dropping - end preview color - drag/drop works - start up prewiev color - segfault in malloc - -timj + * A filter function which destroys the GDK window it is filtering + events on is bad news. Additions: - * implement keyboard navigation in menus - * focus handling for GtkOptionMenu (needs the previous) * GScanner: it might be good to ues stdio and getch() instead of 1-character @@ -288,11 +254,28 @@ Themes - When a scale gets shown/hidden only queue a redraw on the non-window portion, not the whole area. + + - In various places, to avoid shaping windows excessively, + we set parent relative backgrounds. This is an ugly + hack and needs a better solution. Plus, I don't think + these parent-relative backgrounds always persist to + when they are actually needed. + + Such calls exist in: GtkButton, GtkHandeBox, GtkItem, + GtkListItem, GtkMenu, GtkMenuItem, GtkMisc, + GtkNoteBook, GtkOptionMenu, GtkPaned, GtkPreview, + GtkSpinButton and GtkTreeItem. + + - For menus and for GtkWindow's, the realize() function + calls paint(), so that background pixmaps can be set + ahead of time, and prevent flashing when the window is + shown. This is an ugly hack and needs a better solution. + ======= Calendar Widget: - - The widget should be nicely resizeable vertical to. + - The widget should be nicely resizeable vertical too. - CALENDAR_MARGIN should be removed, uses INNER_BORDER and style->class->[xy]thickness insted. diff --git a/acconfig.h b/acconfig.h index 3e76d8ab2d..aa20a8a18e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -18,7 +18,6 @@ #undef GTK_COMPILED_WITH_DEBUGGING #undef HAVE_IPC_H -#undef HAVE_LIBDL #undef HAVE_SHM_H #undef HAVE_XSHM_H #undef HAVE_SHAPE_EXT diff --git a/configure.in b/configure.in index 78f222582f..394fc67c54 100644 --- a/configure.in +++ b/configure.in @@ -289,14 +289,6 @@ else AC_DEFINE(XINPUT_NONE) fi -# Dynamic loading (temporary - will eventually be in -lgmodule) - -AC_CHECK_LIB(dl, dlopen, - AC_DEFINE(HAVE_LIBDL) - DL_LIBS=-ldl) - -AC_SUBST(DL_LIBS) - # Threads CFLAGS="$saved_cflags" diff --git a/docs/Changes-1.2.txt b/docs/Changes-1.2.txt index 6cda1761de..6474d6ec99 100644 --- a/docs/Changes-1.2.txt +++ b/docs/Changes-1.2.txt @@ -46,4 +46,19 @@ Incompatible Changes from GTK+-1.0 to GTK+-1.2: * The old drag and drop API has been completely removed and replaced. See the reference documentation for details on the new API. +* Support for Themes has been added. In general, this does + not affect application code, however, a few new rules should + be observed: + + - To set a shape for a window, you must use + gtk_widget_shape_combine_mask() instead of + gdk_window_shape_combine_mask(), or the shape will be + reset when switching themes. + + - It is no longer permissable to draw directly on an arbitrary + widget, or to set an arbitrary widget's background pixmap. + If you need to do that, use a GtkDrawingArea or (for a + toplevel) the new GtkDrawWindow widget. + + @@ -116,10 +116,6 @@ static Bool gdk_event_get_type (Display *display, static void gdk_synthesize_click (GdkEvent *event, gint nclicks); -#ifdef DEBUG_DND -static void gdk_print_atom (GdkAtom anatom); -#endif - #ifndef HAVE_XCONVERTCASE static void gdkx_XConvertCase (KeySym symbol, KeySym *lower, @@ -2226,8 +2222,7 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_message ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d", - window_private?window_private->dnd_drag_enabled:0, + g_message ("button press:\t\twindow: %ld x,y: %d %d button: %d", xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.button)); @@ -2297,8 +2292,7 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_message ("button release[%d]:\twindow: %ld x,y: %d %d button: %d", - window_private?window_private->dnd_drag_enabled:0, + g_message ("button release:\twindow: %ld x,y: %d %d button: %d", xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.button)); @@ -3837,61 +3831,6 @@ _g_mbtowc (wchar_t *wstr, const char *str, size_t len) #endif /* X_LOCALE */ -/* - * used for debugging only - */ -#ifdef DEBUG_DND -static void -gdk_print_atom (GdkAtom anatom) -{ - gchar *tmpstr = NULL; - tmpstr = (anatom!=None)?gdk_atom_name(anatom):"(none)"; - g_message("Atom %lu has name %s", anatom, tmpstr); - if(tmpstr) - g_free(tmpstr); -} -#endif - -#ifdef WE_HAVE_MOTIF_DROPS_DONE -static GdkWindow * -gdk_drop_get_real_window (GdkWindow *w, - guint16 *x, - guint16 *y) -{ - GdkWindow *retval = w; - GdkWindowPrivate *awin; - GList *children; - gint16 myx = *x, myy = *y; - - g_return_val_if_fail (w != NULL && x != NULL && y != NULL, NULL); - - myx = *x; - myy = *y; - - descend: - for (children = gdk_window_get_children(retval); - children && children->next; - children = children->next) - { - awin = (GdkWindowPrivate *) children->data; - if ((myx >= awin->x) && (myy >= awin->y) - && (myx < (awin->x + awin->width)) - && (myy < (awin->y + awin->height))) - { - retval = (GdkWindow *) awin; - myx -= awin->x; - myy -= awin->y; - goto descend; - } - } - - *x = myx; - *y = myy; - - return retval; -} -#endif - /* Sends a ClientMessage to all toplevel client windows */ gboolean gdk_event_send_client_message (GdkEvent *event, guint32 xid) @@ -206,13 +206,13 @@ void gdk_window_shape_combine_mask (GdkWindow *window, void gdk_window_set_child_shapes (GdkWindow *window); /* - * This routine allows you to combine (ie ADD) child shapes to your + * This routine allows you to merge (ie ADD) child shapes to your * own window's shape keeping its current shape and ADDING the shild * shapes to it. * * - Raster */ -void gdk_window_combine_child_shapes (GdkWindow *window); +void gdk_window_merge_child_shapes (GdkWindow *window); /* * The following function adds a global filter for all client @@ -270,24 +270,6 @@ GdkAtom gdk_drag_get_selection (GdkDragContext *context); /* GdkWindow */ -/* - * This is used by the GDK_DRAG_BEGIN handler. An example of usage would be a - * file manager where multiple icons were selected and the drag began. - * The icon that the drag actually began on would gdk_dnd_drag_addwindow - * for all the other icons that were being dragged... - */ -void gdk_dnd_drag_addwindow (GdkWindow *window); -void gdk_window_dnd_data_set (GdkWindow *window, - GdkEvent *event, - gpointer data, - gulong data_numbytes); -void gdk_dnd_set_drag_cursors(GdkCursor *default_cursor, - GdkCursor *goahead_cursor); -void gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, - GdkPoint *default_hotspot, - GdkWindow *goahead_pixmapwin, - GdkPoint *goahead_hotspot); - void gdk_window_set_hints (GdkWindow *window, gint x, gint y, diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index d14ee79db2..c4dc41a078 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -919,7 +919,12 @@ motif_read_target_table (void) goto error; n_targets = card16_to_host (*(gushort *)p, header->byte_order); - targets = (guint32 *)(p + sizeof(guint16)); + + /* We need to make a copy of the targets, since it may + * be unaligned + */ + targets = g_new (guint32, n_targets); + memcpy (targets, p + sizeof(guint16), sizeof(guint32) * n_targets); p += sizeof(guint16) + n_targets * sizeof(guint32); if (p - target_bytes > nitems) @@ -930,7 +935,7 @@ motif_read_target_table (void) g_list_prepend (motif_target_lists[i], GUINT_TO_POINTER (card32_to_host (targets[j], header->byte_order))); - + g_free (targets); motif_target_lists[i] = g_list_reverse (motif_target_lists[i]); } @@ -1037,7 +1042,6 @@ motif_add_to_target_table (GList *targets) guchar *data; guchar *p; guint16 *p16; - guint32 *p32; MotifTargetTableHeader *header; if (!motif_target_lists) @@ -1071,20 +1075,27 @@ motif_add_to_target_table (GList *targets) for (i = 0; i < motif_n_target_lists ; i++) { - guint16 count = 0; + guint16 n_targets = g_list_length (motif_target_lists[i]); + guint32 *targets = g_new (guint32, n_targets); + guint32 *p32 = targets; - p16 = (guint16 *)p; - p += sizeof(guint16); - p32 = (guint32 *)p; tmp_list = motif_target_lists[i]; while (tmp_list) { - *p32++ = GPOINTER_TO_UINT (tmp_list->data); + *p32 = GPOINTER_TO_UINT (tmp_list->data); + tmp_list = tmp_list->next; - count++; + p32++; } - *p16 = count; - p = (guchar *)p32; + + p16 = (guint16 *)p; + p += sizeof(guint16); + + memcpy (p, targets, n_targets * sizeof(guint32)); + + *p16 = n_targets; + p += sizeof(guint32) * n_targets; + g_free (targets); } XChangeProperty (gdk_display, motif_drag_window, diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h index 781db81b1f..d7f71cd224 100644 --- a/gdk/gdkprivate.h +++ b/gdk/gdkprivate.h @@ -24,8 +24,6 @@ #include <X11/Xutil.h> #include <gdk/gdktypes.h> -#define DND_PROTOCOL_VERSION 0 - #define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid)) #define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid)) #define gdk_font_lookup(xid) ((GdkFont*) gdk_xid_table_lookup (xid)) @@ -65,20 +63,6 @@ struct _GdkWindowPrivate guint8 window_type; guint ref_count; guint destroyed : 2; - guint dnd_drag_enabled : 1, - dnd_drag_datashow : 1, - dnd_drag_destructive_op : 1, - dnd_drag_accepted : 1, - dnd_drop_enabled : 1, - dnd_drop_destructive_op : 1; - GdkAtom dnd_drag_data_type, *dnd_drag_data_typesavail; - guint dnd_drag_data_numtypesavail; - /* We have to turn on MotionMask/EnterWindowMask/LeaveWindowMask - during drags, then set it back to what it was after */ - glong dnd_drag_savedeventmask, dnd_drag_eventmask; - GdkAtom *dnd_drop_data_typesavail; - guint dnd_drop_data_numtypesavail; - /* need to allow custom drag/drop cursors */ gint extension_events; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 9cc213e16e..002696b872 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -286,14 +286,6 @@ gdk_window_new (GdkWindow *parent, private->height = (attributes->height > 1) ? (attributes->height) : (1); private->window_type = attributes->window_type; private->extension_events = FALSE; - private->dnd_drag_data_type = None; - private->dnd_drag_data_typesavail = - private->dnd_drop_data_typesavail = NULL; - private->dnd_drop_enabled = private->dnd_drag_enabled = - private->dnd_drag_accepted = private->dnd_drag_datashow = - private->dnd_drop_data_numtypesavail = - private->dnd_drag_data_numtypesavail = 0; - private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0; private->filters = NULL; private->children = NULL; @@ -507,15 +499,6 @@ gdk_window_foreign_new (guint32 anid) private->colormap = NULL; - private->dnd_drag_data_type = None; - private->dnd_drag_data_typesavail = - private->dnd_drop_data_typesavail = NULL; - private->dnd_drop_enabled = private->dnd_drag_enabled = - private->dnd_drag_accepted = private->dnd_drag_datashow = - private->dnd_drop_data_numtypesavail = - private->dnd_drag_data_numtypesavail = 0; - private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0; - private->filters = NULL; private->children = NULL; @@ -585,17 +568,6 @@ gdk_window_internal_destroy (GdkWindow *window, gboolean xdestroy, if (private->extension_events != 0) gdk_input_window_destroy (window); - if(private->dnd_drag_data_numtypesavail > 0) - { - g_free (private->dnd_drag_data_typesavail); - private->dnd_drag_data_typesavail = NULL; - } - if(private->dnd_drop_data_numtypesavail > 0) - { - g_free (private->dnd_drop_data_typesavail); - private->dnd_drop_data_typesavail = NULL; - } - if (private->filters) { tmp = private->filters; @@ -1631,8 +1603,8 @@ gdk_window_add_colormap_windows (GdkWindow *window) } static gboolean -gdk_window_have_shape_ext (void){ - +gdk_window_have_shape_ext (void) +{ enum { UNKNOWN, NO, YES }; static gint have_shape = UNKNOWN; @@ -2107,167 +2079,52 @@ gdk_add_to_span(struct _gdk_span **s, int x, int xx) } static void -gdk_propagate_shapes(Display *disp, Window win) +gdk_add_rectangles (Display *disp, Window win, struct _gdk_span **spans, + gint basew, gint baseh, gint x, gint y) { - Window rt, par, *list = NULL; - gint a, k, i, j, num = 0, num_rects = 0, rn = 0, ord; - gint x, y, contig, x1, y1, x2, y2; - guint w, h, d; - gint baseh, basew; - XRectangle *rects = NULL, *rl = NULL; - struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3; - XWindowAttributes xatt; - - XGetGeometry(disp, win, &rt, &x, &y, &w, &h, &d, &d); - if (h <= 0) - return; - basew = w; - baseh = h; - spans = g_malloc(sizeof(struct _gdk_span *) * h); - - for (i = 0; i < h; i++) - spans[i] = NULL; - XQueryTree(disp, win, &rt, &par, &list, (unsigned int *)&num); - if (list) - { - /* go through all child windows and create/insert spans */ - for (i = 0; i < num; i++) - { - if (XGetWindowAttributes(disp, list[i], &xatt)) - { - if (XGetGeometry(disp, list[i], &rt, &x, &y, &w, &h, &d, &d)) - { - rl = XShapeGetRectangles(disp, list[i], ShapeBounding, &rn, &ord); - if ((rl) && (xatt.map_state != IsUnmapped)) - { - /* go through all clip rects in this window's shape */ - for (k = 0; k < rn; k++) - { - /* for each clip rect, add it to each line's spans */ - x1 = x + rl[k].x; - x2 = x + rl[k].x + (rl[k].width - 1); - y1 = y + rl[k].y; - y2 = y + rl[k].y + (rl[k].height - 1); - if (x1 < 0) - x1 = 0; - if (y1 < 0) - y1 = 0; - if (x2 >= basew) - x2 = basew - 1; - if (y2 >= baseh) - y2 = baseh - 1; - for (a = y1; a <= y2; a++) - { - if ((x2 - x1) >= 0) - gdk_add_to_span(&spans[a], x1, x2); - } - } - XFree(rl); - } - } - } - } - /* go through the spans list and build a list of rects */ - rects = g_malloc(sizeof(XRectangle) * 256); - num_rects = 0; - for (i = 0; i < baseh; i++) - { - ptr1 = spans[i]; - /* go through the line for all spans */ - while (ptr1) - { - rects[num_rects].x = ptr1->start; - rects[num_rects].y = i; - rects[num_rects].width = ptr1->end - ptr1->start + 1; - rects[num_rects].height = 1; - j = i + 1; - /* if there are more lines */ - contig = 1; - /* while contigous rects (same start/end coords) exist */ - while ((contig) && (j < baseh)) - { - /* search next line for spans matching this one */ - contig = 0; - ptr2 = spans[j]; - ptr3 = NULL; - while (ptr2) - { - /* if we have an exact span match set contig */ - if ((ptr2->start == ptr1->start) && - (ptr2->end == ptr1->end)) - { - contig = 1; - /* remove the span - not needed */ - if (ptr3) - { - ptr3->next = ptr2->next; - g_free(ptr2); - ptr2 = NULL; - } - else - { - spans[j] = ptr2->next; - g_free(ptr2); - ptr2 = NULL; - } - break; - } - /* gone past the span point no point looking */ - else if (ptr2->start < ptr1->start) - break; - if (ptr2) - { - ptr3 = ptr2; - ptr2 = ptr2->next; - } - } - /* if a contiguous span was found increase the rect h */ - if (contig) - { - rects[num_rects].height++; - j++; - } - } - /* up the rect count */ - num_rects++; - /* every 256 new rects increase the rect array */ - if ((num_rects % 256) == 0) - rects = g_realloc(rects, sizeof(XRectangle) * (num_rects + 256)); - ptr1 = ptr1->next; - } - } - /* set the rects as the shape mask */ - if (rects) - { - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rects, num_rects, - ShapeSet, YXSorted); - g_free(rects); - } - XFree(list); - } - /* free up all the spans we made */ - for (i = 0; i < baseh; i++) - { - ptr1 = spans[i]; - while (ptr1) - { - ptr2 = ptr1; - ptr1 = ptr1->next; - g_free(ptr2); - } - } - g_free(spans); + gint a, k; + gint x1, y1, x2, y2; + gint rn, ord; + XRectangle *rl; + + rl = XShapeGetRectangles(disp, win, ShapeBounding, &rn, &ord); + if (rl) + { + /* go through all clip rects in this window's shape */ + for (k = 0; k < rn; k++) + { + /* for each clip rect, add it to each line's spans */ + x1 = x + rl[k].x; + x2 = x + rl[k].x + (rl[k].width - 1); + y1 = y + rl[k].y; + y2 = y + rl[k].y + (rl[k].height - 1); + if (x1 < 0) + x1 = 0; + if (y1 < 0) + y1 = 0; + if (x2 >= basew) + x2 = basew - 1; + if (y2 >= baseh) + y2 = baseh - 1; + for (a = y1; a <= y2; a++) + { + if ((x2 - x1) >= 0) + gdk_add_to_span(&spans[a], x1, x2); + } + } + XFree(rl); + } } static void -gdk_propagate_combine_shapes(Display *disp, Window win) +gdk_propagate_shapes(Display *disp, Window win, gboolean merge) { Window rt, par, *list = NULL; - gint a, k, i, j, num = 0, num_rects = 0, rn = 0, ord; - gint x, y, contig, x1, y1, x2, y2; + gint i, j, num = 0, num_rects = 0; + gint x, y, contig; guint w, h, d; gint baseh, basew; - XRectangle *rects = NULL, *rl = NULL; + XRectangle *rects = NULL; struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3; XWindowAttributes xatt; @@ -2283,50 +2140,16 @@ gdk_propagate_combine_shapes(Display *disp, Window win) XQueryTree(disp, win, &rt, &par, &list, (unsigned int *)&num); if (list) { - list = realloc(list, ++num * sizeof(Window)); - list[num - 1] = win; /* go through all child windows and create/insert spans */ for (i = 0; i < num; i++) { - if (XGetWindowAttributes(disp, list[i], &xatt)) - { - if (XGetGeometry(disp, list[i], &rt, &x, &y, &w, &h, &d, &d)) - { - if (i == (num - 1)) - { - x = 0; - y = 0; - } - rl = XShapeGetRectangles(disp, list[i], ShapeBounding, &rn, &ord); - if ((rl) && ((xatt.map_state != IsUnmapped) || (i == (num - 1)))) - { - /* go through all clip rects in this window's shape */ - for (k = 0; k < rn; k++) - { - /* for each clip rect, add it to each line's spans */ - x1 = x + rl[k].x; - x2 = x + rl[k].x + (rl[k].width - 1); - y1 = y + rl[k].y; - y2 = y + rl[k].y + (rl[k].height - 1); - if (x1 < 0) - x1 = 0; - if (y1 < 0) - y1 = 0; - if (x2 >= basew) - x2 = basew - 1; - if (y2 >= baseh) - y2 = baseh - 1; - for (a = y1; a <= y2; a++) - { - if ((x2 - x1) >= 0) - gdk_add_to_span(&spans[a], x1, x2); - } - } - XFree(rl); - } - } - } + if (XGetWindowAttributes(disp, list[i], &xatt) && (xatt.map_state != IsUnmapped)) + if (XGetGeometry(disp, list[i], &rt, &x, &y, &w, &h, &d, &d)) + gdk_add_rectangles (disp, list[i], spans, basew, baseh, x, y); } + if (merge) + gdk_add_rectangles (disp, win, spans, basew, baseh, x, y); + /* go through the spans list and build a list of rects */ rects = g_malloc(sizeof(XRectangle) * 256); num_rects = 0; @@ -2432,12 +2255,12 @@ gdk_window_set_child_shapes (GdkWindow *window) return; if (gdk_window_have_shape_ext()) - gdk_propagate_shapes (private->xdisplay, private->xwindow); + gdk_propagate_shapes (private->xdisplay, private->xwindow, FALSE); #endif } void -gdk_window_combine_child_shapes (GdkWindow *window) +gdk_window_merge_child_shapes (GdkWindow *window) { GdkWindowPrivate *private; @@ -2449,7 +2272,7 @@ gdk_window_combine_child_shapes (GdkWindow *window) return; if (gdk_window_have_shape_ext()) - gdk_propagate_combine_shapes (private->xdisplay, private->xwindow); + gdk_propagate_shapes (private->xdisplay, private->xwindow, TRUE); #endif } diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index d14ee79db2..c4dc41a078 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -919,7 +919,12 @@ motif_read_target_table (void) goto error; n_targets = card16_to_host (*(gushort *)p, header->byte_order); - targets = (guint32 *)(p + sizeof(guint16)); + + /* We need to make a copy of the targets, since it may + * be unaligned + */ + targets = g_new (guint32, n_targets); + memcpy (targets, p + sizeof(guint16), sizeof(guint32) * n_targets); p += sizeof(guint16) + n_targets * sizeof(guint32); if (p - target_bytes > nitems) @@ -930,7 +935,7 @@ motif_read_target_table (void) g_list_prepend (motif_target_lists[i], GUINT_TO_POINTER (card32_to_host (targets[j], header->byte_order))); - + g_free (targets); motif_target_lists[i] = g_list_reverse (motif_target_lists[i]); } @@ -1037,7 +1042,6 @@ motif_add_to_target_table (GList *targets) guchar *data; guchar *p; guint16 *p16; - guint32 *p32; MotifTargetTableHeader *header; if (!motif_target_lists) @@ -1071,20 +1075,27 @@ motif_add_to_target_table (GList *targets) for (i = 0; i < motif_n_target_lists ; i++) { - guint16 count = 0; + guint16 n_targets = g_list_length (motif_target_lists[i]); + guint32 *targets = g_new (guint32, n_targets); + guint32 *p32 = targets; - p16 = (guint16 *)p; - p += sizeof(guint16); - p32 = (guint32 *)p; tmp_list = motif_target_lists[i]; while (tmp_list) { - *p32++ = GPOINTER_TO_UINT (tmp_list->data); + *p32 = GPOINTER_TO_UINT (tmp_list->data); + tmp_list = tmp_list->next; - count++; + p32++; } - *p16 = count; - p = (guchar *)p32; + + p16 = (guint16 *)p; + p += sizeof(guint16); + + memcpy (p, targets, n_targets * sizeof(guint32)); + + *p16 = n_targets; + p += sizeof(guint32) * n_targets; + g_free (targets); } XChangeProperty (gdk_display, motif_drag_window, diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index b857635ba6..a3200c45d3 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -116,10 +116,6 @@ static Bool gdk_event_get_type (Display *display, static void gdk_synthesize_click (GdkEvent *event, gint nclicks); -#ifdef DEBUG_DND -static void gdk_print_atom (GdkAtom anatom); -#endif - #ifndef HAVE_XCONVERTCASE static void gdkx_XConvertCase (KeySym symbol, KeySym *lower, @@ -2226,8 +2222,7 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_message ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d", - window_private?window_private->dnd_drag_enabled:0, + g_message ("button press:\t\twindow: %ld x,y: %d %d button: %d", xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.button)); @@ -2297,8 +2292,7 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_message ("button release[%d]:\twindow: %ld x,y: %d %d button: %d", - window_private?window_private->dnd_drag_enabled:0, + g_message ("button release:\twindow: %ld x,y: %d %d button: %d", xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.button)); @@ -3837,61 +3831,6 @@ _g_mbtowc (wchar_t *wstr, const char *str, size_t len) #endif /* X_LOCALE */ -/* - * used for debugging only - */ -#ifdef DEBUG_DND -static void -gdk_print_atom (GdkAtom anatom) -{ - gchar *tmpstr = NULL; - tmpstr = (anatom!=None)?gdk_atom_name(anatom):"(none)"; - g_message("Atom %lu has name %s", anatom, tmpstr); - if(tmpstr) - g_free(tmpstr); -} -#endif - -#ifdef WE_HAVE_MOTIF_DROPS_DONE -static GdkWindow * -gdk_drop_get_real_window (GdkWindow *w, - guint16 *x, - guint16 *y) -{ - GdkWindow *retval = w; - GdkWindowPrivate *awin; - GList *children; - gint16 myx = *x, myy = *y; - - g_return_val_if_fail (w != NULL && x != NULL && y != NULL, NULL); - - myx = *x; - myy = *y; - - descend: - for (children = gdk_window_get_children(retval); - children && children->next; - children = children->next) - { - awin = (GdkWindowPrivate *) children->data; - if ((myx >= awin->x) && (myy >= awin->y) - && (myx < (awin->x + awin->width)) - && (myy < (awin->y + awin->height))) - { - retval = (GdkWindow *) awin; - myx -= awin->x; - myy -= awin->y; - goto descend; - } - } - - *x = myx; - *y = myy; - - return retval; -} -#endif - /* Sends a ClientMessage to all toplevel client windows */ gboolean gdk_event_send_client_message (GdkEvent *event, guint32 xid) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 9cc213e16e..002696b872 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -286,14 +286,6 @@ gdk_window_new (GdkWindow *parent, private->height = (attributes->height > 1) ? (attributes->height) : (1); private->window_type = attributes->window_type; private->extension_events = FALSE; - private->dnd_drag_data_type = None; - private->dnd_drag_data_typesavail = - private->dnd_drop_data_typesavail = NULL; - private->dnd_drop_enabled = private->dnd_drag_enabled = - private->dnd_drag_accepted = private->dnd_drag_datashow = - private->dnd_drop_data_numtypesavail = - private->dnd_drag_data_numtypesavail = 0; - private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0; private->filters = NULL; private->children = NULL; @@ -507,15 +499,6 @@ gdk_window_foreign_new (guint32 anid) private->colormap = NULL; - private->dnd_drag_data_type = None; - private->dnd_drag_data_typesavail = - private->dnd_drop_data_typesavail = NULL; - private->dnd_drop_enabled = private->dnd_drag_enabled = - private->dnd_drag_accepted = private->dnd_drag_datashow = - private->dnd_drop_data_numtypesavail = - private->dnd_drag_data_numtypesavail = 0; - private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0; - private->filters = NULL; private->children = NULL; @@ -585,17 +568,6 @@ gdk_window_internal_destroy (GdkWindow *window, gboolean xdestroy, if (private->extension_events != 0) gdk_input_window_destroy (window); - if(private->dnd_drag_data_numtypesavail > 0) - { - g_free (private->dnd_drag_data_typesavail); - private->dnd_drag_data_typesavail = NULL; - } - if(private->dnd_drop_data_numtypesavail > 0) - { - g_free (private->dnd_drop_data_typesavail); - private->dnd_drop_data_typesavail = NULL; - } - if (private->filters) { tmp = private->filters; @@ -1631,8 +1603,8 @@ gdk_window_add_colormap_windows (GdkWindow *window) } static gboolean -gdk_window_have_shape_ext (void){ - +gdk_window_have_shape_ext (void) +{ enum { UNKNOWN, NO, YES }; static gint have_shape = UNKNOWN; @@ -2107,167 +2079,52 @@ gdk_add_to_span(struct _gdk_span **s, int x, int xx) } static void -gdk_propagate_shapes(Display *disp, Window win) +gdk_add_rectangles (Display *disp, Window win, struct _gdk_span **spans, + gint basew, gint baseh, gint x, gint y) { - Window rt, par, *list = NULL; - gint a, k, i, j, num = 0, num_rects = 0, rn = 0, ord; - gint x, y, contig, x1, y1, x2, y2; - guint w, h, d; - gint baseh, basew; - XRectangle *rects = NULL, *rl = NULL; - struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3; - XWindowAttributes xatt; - - XGetGeometry(disp, win, &rt, &x, &y, &w, &h, &d, &d); - if (h <= 0) - return; - basew = w; - baseh = h; - spans = g_malloc(sizeof(struct _gdk_span *) * h); - - for (i = 0; i < h; i++) - spans[i] = NULL; - XQueryTree(disp, win, &rt, &par, &list, (unsigned int *)&num); - if (list) - { - /* go through all child windows and create/insert spans */ - for (i = 0; i < num; i++) - { - if (XGetWindowAttributes(disp, list[i], &xatt)) - { - if (XGetGeometry(disp, list[i], &rt, &x, &y, &w, &h, &d, &d)) - { - rl = XShapeGetRectangles(disp, list[i], ShapeBounding, &rn, &ord); - if ((rl) && (xatt.map_state != IsUnmapped)) - { - /* go through all clip rects in this window's shape */ - for (k = 0; k < rn; k++) - { - /* for each clip rect, add it to each line's spans */ - x1 = x + rl[k].x; - x2 = x + rl[k].x + (rl[k].width - 1); - y1 = y + rl[k].y; - y2 = y + rl[k].y + (rl[k].height - 1); - if (x1 < 0) - x1 = 0; - if (y1 < 0) - y1 = 0; - if (x2 >= basew) - x2 = basew - 1; - if (y2 >= baseh) - y2 = baseh - 1; - for (a = y1; a <= y2; a++) - { - if ((x2 - x1) >= 0) - gdk_add_to_span(&spans[a], x1, x2); - } - } - XFree(rl); - } - } - } - } - /* go through the spans list and build a list of rects */ - rects = g_malloc(sizeof(XRectangle) * 256); - num_rects = 0; - for (i = 0; i < baseh; i++) - { - ptr1 = spans[i]; - /* go through the line for all spans */ - while (ptr1) - { - rects[num_rects].x = ptr1->start; - rects[num_rects].y = i; - rects[num_rects].width = ptr1->end - ptr1->start + 1; - rects[num_rects].height = 1; - j = i + 1; - /* if there are more lines */ - contig = 1; - /* while contigous rects (same start/end coords) exist */ - while ((contig) && (j < baseh)) - { - /* search next line for spans matching this one */ - contig = 0; - ptr2 = spans[j]; - ptr3 = NULL; - while (ptr2) - { - /* if we have an exact span match set contig */ - if ((ptr2->start == ptr1->start) && - (ptr2->end == ptr1->end)) - { - contig = 1; - /* remove the span - not needed */ - if (ptr3) - { - ptr3->next = ptr2->next; - g_free(ptr2); - ptr2 = NULL; - } - else - { - spans[j] = ptr2->next; - g_free(ptr2); - ptr2 = NULL; - } - break; - } - /* gone past the span point no point looking */ - else if (ptr2->start < ptr1->start) - break; - if (ptr2) - { - ptr3 = ptr2; - ptr2 = ptr2->next; - } - } - /* if a contiguous span was found increase the rect h */ - if (contig) - { - rects[num_rects].height++; - j++; - } - } - /* up the rect count */ - num_rects++; - /* every 256 new rects increase the rect array */ - if ((num_rects % 256) == 0) - rects = g_realloc(rects, sizeof(XRectangle) * (num_rects + 256)); - ptr1 = ptr1->next; - } - } - /* set the rects as the shape mask */ - if (rects) - { - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rects, num_rects, - ShapeSet, YXSorted); - g_free(rects); - } - XFree(list); - } - /* free up all the spans we made */ - for (i = 0; i < baseh; i++) - { - ptr1 = spans[i]; - while (ptr1) - { - ptr2 = ptr1; - ptr1 = ptr1->next; - g_free(ptr2); - } - } - g_free(spans); + gint a, k; + gint x1, y1, x2, y2; + gint rn, ord; + XRectangle *rl; + + rl = XShapeGetRectangles(disp, win, ShapeBounding, &rn, &ord); + if (rl) + { + /* go through all clip rects in this window's shape */ + for (k = 0; k < rn; k++) + { + /* for each clip rect, add it to each line's spans */ + x1 = x + rl[k].x; + x2 = x + rl[k].x + (rl[k].width - 1); + y1 = y + rl[k].y; + y2 = y + rl[k].y + (rl[k].height - 1); + if (x1 < 0) + x1 = 0; + if (y1 < 0) + y1 = 0; + if (x2 >= basew) + x2 = basew - 1; + if (y2 >= baseh) + y2 = baseh - 1; + for (a = y1; a <= y2; a++) + { + if ((x2 - x1) >= 0) + gdk_add_to_span(&spans[a], x1, x2); + } + } + XFree(rl); + } } static void -gdk_propagate_combine_shapes(Display *disp, Window win) +gdk_propagate_shapes(Display *disp, Window win, gboolean merge) { Window rt, par, *list = NULL; - gint a, k, i, j, num = 0, num_rects = 0, rn = 0, ord; - gint x, y, contig, x1, y1, x2, y2; + gint i, j, num = 0, num_rects = 0; + gint x, y, contig; guint w, h, d; gint baseh, basew; - XRectangle *rects = NULL, *rl = NULL; + XRectangle *rects = NULL; struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3; XWindowAttributes xatt; @@ -2283,50 +2140,16 @@ gdk_propagate_combine_shapes(Display *disp, Window win) XQueryTree(disp, win, &rt, &par, &list, (unsigned int *)&num); if (list) { - list = realloc(list, ++num * sizeof(Window)); - list[num - 1] = win; /* go through all child windows and create/insert spans */ for (i = 0; i < num; i++) { - if (XGetWindowAttributes(disp, list[i], &xatt)) - { - if (XGetGeometry(disp, list[i], &rt, &x, &y, &w, &h, &d, &d)) - { - if (i == (num - 1)) - { - x = 0; - y = 0; - } - rl = XShapeGetRectangles(disp, list[i], ShapeBounding, &rn, &ord); - if ((rl) && ((xatt.map_state != IsUnmapped) || (i == (num - 1)))) - { - /* go through all clip rects in this window's shape */ - for (k = 0; k < rn; k++) - { - /* for each clip rect, add it to each line's spans */ - x1 = x + rl[k].x; - x2 = x + rl[k].x + (rl[k].width - 1); - y1 = y + rl[k].y; - y2 = y + rl[k].y + (rl[k].height - 1); - if (x1 < 0) - x1 = 0; - if (y1 < 0) - y1 = 0; - if (x2 >= basew) - x2 = basew - 1; - if (y2 >= baseh) - y2 = baseh - 1; - for (a = y1; a <= y2; a++) - { - if ((x2 - x1) >= 0) - gdk_add_to_span(&spans[a], x1, x2); - } - } - XFree(rl); - } - } - } + if (XGetWindowAttributes(disp, list[i], &xatt) && (xatt.map_state != IsUnmapped)) + if (XGetGeometry(disp, list[i], &rt, &x, &y, &w, &h, &d, &d)) + gdk_add_rectangles (disp, list[i], spans, basew, baseh, x, y); } + if (merge) + gdk_add_rectangles (disp, win, spans, basew, baseh, x, y); + /* go through the spans list and build a list of rects */ rects = g_malloc(sizeof(XRectangle) * 256); num_rects = 0; @@ -2432,12 +2255,12 @@ gdk_window_set_child_shapes (GdkWindow *window) return; if (gdk_window_have_shape_ext()) - gdk_propagate_shapes (private->xdisplay, private->xwindow); + gdk_propagate_shapes (private->xdisplay, private->xwindow, FALSE); #endif } void -gdk_window_combine_child_shapes (GdkWindow *window) +gdk_window_merge_child_shapes (GdkWindow *window) { GdkWindowPrivate *private; @@ -2449,7 +2272,7 @@ gdk_window_combine_child_shapes (GdkWindow *window) return; if (gdk_window_have_shape_ext()) - gdk_propagate_combine_shapes (private->xdisplay, private->xwindow); + gdk_propagate_shapes (private->xdisplay, private->xwindow, TRUE); #endif } diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index 59bb14f050..2472e8b2aa 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -166,39 +166,40 @@ gtk_aspect_frame_paint (GtkWidget *widget, x = GTK_CONTAINER (frame)->border_width; y = GTK_CONTAINER (frame)->border_width; - - if (frame->label) - { - label_area_width = (allocation->width + - GTK_CONTAINER (frame)->border_width * 2 - - widget->style->klass->xthickness * 2); - x2 = ((label_area_width - frame->label_width) * frame->label_xalign + - GTK_CONTAINER (frame)->border_width + widget->style->klass->xthickness); - y2 = (GTK_CONTAINER (frame)->border_width + widget->style->font->ascent); - - gtk_paint_shadow_gap (widget->style, widget->window, - GTK_STATE_NORMAL, frame->shadow_type, - area, widget, "aspectframe", - allocation->x + x, - allocation->y + y + height_extra / 2, - allocation->width - x * 2, - allocation->height - y * 2 - height_extra / 2, - 0, x2 + 2 - x, frame->label_width - 4); - - gtk_paint_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), - area, widget, "aspectframe", - allocation->x + x2 + 3, - allocation->y + y2, - frame->label); - } - else - gtk_paint_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, frame->shadow_type, - area, widget, "aspectframe", - allocation->x + x, - allocation->y + y + height_extra / 2, - allocation->width - x * 2, - allocation->height - y * 2 - height_extra / 2); + if (frame->label) + { + label_area_width = (allocation->width + + GTK_CONTAINER (frame)->border_width * 2 - + widget->style->klass->xthickness * 2); + + x2 = ((label_area_width - frame->label_width) * frame->label_xalign + + GTK_CONTAINER (frame)->border_width + widget->style->klass->xthickness); + y2 = (GTK_CONTAINER (frame)->border_width + widget->style->font->ascent); + + gtk_paint_shadow_gap (widget->style, widget->window, + GTK_STATE_NORMAL, frame->shadow_type, + area, widget, "frame", + allocation->x + x, + allocation->y + y + height_extra / 2, + allocation->width - x * 2, + allocation->height - y * 2 - height_extra / 2, + GTK_POS_TOP, + x2 + 2 - x, frame->label_width - 4); + + gtk_paint_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), + area, widget, "frame", + allocation->x + x2 + 3, + allocation->y + y2, + frame->label); + } + else + gtk_paint_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, frame->shadow_type, + area, widget, "frame", + allocation->x + x, + allocation->y + y + height_extra / 2, + allocation->width - x * 2, + allocation->height - y * 2 - height_extra / 2); } } diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index d07eeab576..7ea658af2c 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -507,83 +507,75 @@ static void gtk_button_paint (GtkWidget *widget, GdkRectangle *area) { - GtkButton *button; - GtkShadowType shadow_type; - gint width, height; - gint x, y; + GtkButton *button; + GtkShadowType shadow_type; + gint width, height; + gint x, y; - if (GTK_WIDGET_DRAWABLE (widget)) - { - button = GTK_BUTTON (widget); + if (GTK_WIDGET_DRAWABLE (widget)) + { + button = GTK_BUTTON (widget); - x = 0; - y = 0; - width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2; - height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; - - if (GTK_WIDGET_HAS_DEFAULT (widget) && - GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) - { - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - gtk_paint_box (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - area, widget, "buttondefault", - x, y, width, height); - } - else - { - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - } - if (GTK_WIDGET_CAN_DEFAULT (widget)) - { - x += widget->style->klass->xthickness; - y += widget->style->klass->ythickness; - width -= 2 * x + DEFAULT_SPACING; - height -= 2 * y + DEFAULT_SPACING; - x += DEFAULT_LEFT_POS; - y += DEFAULT_TOP_POS; - } + x = 0; + y = 0; + width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2; + height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; + + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + + if (GTK_WIDGET_HAS_DEFAULT (widget) && + GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) + { + gtk_paint_box (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + area, widget, "buttondefault", + x, y, width, height); + } + + if (GTK_WIDGET_CAN_DEFAULT (widget)) + { + x += widget->style->klass->xthickness; + y += widget->style->klass->ythickness; + width -= 2 * x + DEFAULT_SPACING; + height -= 2 * y + DEFAULT_SPACING; + x += DEFAULT_LEFT_POS; + y += DEFAULT_TOP_POS; + } - if (GTK_WIDGET_HAS_FOCUS (widget)) - { - x += 1; - y += 1; - width -= 2; - height -= 2; - } + if (GTK_WIDGET_HAS_FOCUS (widget)) + { + x += 1; + y += 1; + width -= 2; + height -= 2; + } - if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) - shadow_type = GTK_SHADOW_IN; - else - shadow_type = GTK_SHADOW_OUT; - - if ((button->relief == GTK_RELIEF_NONE) && - ((GTK_WIDGET_STATE(widget) == GTK_STATE_NORMAL) || - (GTK_WIDGET_STATE(widget) == GTK_STATE_INSENSITIVE))) - { - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - } - else - gtk_paint_box (widget->style, widget->window, - GTK_WIDGET_STATE (widget), - shadow_type, area, widget, "button", - x, y, width, height); + if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) + shadow_type = GTK_SHADOW_IN; + else + shadow_type = GTK_SHADOW_OUT; + + if ((button->relief != GTK_RELIEF_NONE) || + ((GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL) && + (GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))) + gtk_paint_box (widget->style, widget->window, + GTK_WIDGET_STATE (widget), + shadow_type, area, widget, "button", + x, y, width, height); - if (GTK_WIDGET_HAS_FOCUS (widget)) - { - x -= 1; - y -= 1; - width += 2; - height += 2; + if (GTK_WIDGET_HAS_FOCUS (widget)) + { + x -= 1; + y -= 1; + width += 2; + height += 2; - gtk_paint_focus (widget->style, widget->window, - area, widget, "button", - x, y, width - 1, height - 1); - } - } + gtk_paint_focus (widget->style, widget->window, + area, widget, "button", + x, y, width - 1, height - 1); + } + } } static void @@ -616,13 +608,13 @@ gtk_button_draw (GtkWidget *widget, static void gtk_button_draw_focus (GtkWidget *widget) { - gtk_widget_draw (widget, NULL); + gtk_widget_draw (widget, NULL); } static void gtk_button_draw_default (GtkWidget *widget) { - gtk_widget_draw (widget, NULL); + gtk_widget_draw (widget, NULL); } static gint diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index eca9fad7cf..3560b422d5 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -92,8 +92,8 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) static void gtk_check_button_init (GtkCheckButton *check_button) { - GTK_WIDGET_SET_FLAGS (check_button, GTK_NO_WINDOW); - check_button->toggle_button.draw_indicator = TRUE; + GTK_WIDGET_SET_FLAGS (check_button, GTK_NO_WINDOW); + check_button->toggle_button.draw_indicator = TRUE; } GtkWidget* @@ -172,11 +172,11 @@ gtk_check_button_draw_focus (GtkWidget *widget) g_return_if_fail (GTK_IS_CHECK_BUTTON (widget)); border_width = GTK_CONTAINER (widget)->border_width; - gtk_widget_queue_draw_area(widget->parent, - border_width + widget->allocation.x, - border_width + widget->allocation.y, - widget->allocation.width - 2 * border_width - 1, - widget->allocation.height - 2 * border_width - 1); + gtk_widget_queue_clear_area(widget->parent, + border_width + widget->allocation.x, + border_width + widget->allocation.y, + widget->allocation.width - 2 * border_width, + widget->allocation.height - 2 * border_width); } static void diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 579633e6d9..663485be55 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -32,7 +32,7 @@ #define MIN_ENTRY_WIDTH 150 #define DRAW_TIMEOUT 20 -#define INNER_BORDER 0 +#define INNER_BORDER 2 enum { ARG_0, @@ -565,8 +565,8 @@ gtk_entry_realize (GtkWidget *widget) widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, entry); - attributes.x = widget->style->klass->xthickness + INNER_BORDER; - attributes.y = widget->style->klass->ythickness + INNER_BORDER; + attributes.x = widget->style->klass->xthickness; + attributes.y = widget->style->klass->ythickness; attributes.width = widget->allocation.width - attributes.x * 2; attributes.height = widget->requisition.height - attributes.y * 2; attributes.cursor = entry->cursor = gdk_cursor_new (GDK_XTERM); @@ -756,10 +756,10 @@ gtk_entry_size_allocate (GtkWidget *widget, allocation->y + (allocation->height - widget->requisition.height) / 2, allocation->width, widget->requisition.height); gdk_window_move_resize (entry->text_area, - widget->style->klass->xthickness + INNER_BORDER, - widget->style->klass->ythickness + INNER_BORDER, - allocation->width - (widget->style->klass->xthickness + INNER_BORDER) * 2, - widget->requisition.height - (widget->style->klass->ythickness + INNER_BORDER) * 2); + widget->style->klass->xthickness, + widget->style->klass->ythickness, + allocation->width - widget->style->klass->xthickness * 2, + widget->requisition.height - widget->style->klass->ythickness * 2); /* And make sure the cursor is on screen */ gtk_entry_adjust_scroll (entry); @@ -1270,8 +1270,11 @@ gtk_entry_draw_text (GtkEntry *entry) if (!entry->text) { - gtk_paint_entry(widget->style, entry->text_area,GTK_WIDGET_STATE(widget), - NULL, widget, "entry_bg", 0, 0, -1, -1); + gtk_paint_flat_box (widget->style, entry->text_area, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + NULL, widget, "entry_bg", + 0, 0, -1, -1); + if (editable->editable) gtk_entry_draw_cursor (entry); return; @@ -1289,21 +1292,15 @@ gtk_entry_draw_text (GtkEntry *entry) { gtk_entry_make_backing_pixmap (entry, width, height); drawable = entry->backing_pixmap; -/* gdk_draw_rectangle (drawable, - widget->style->base_gc[GTK_WIDGET_STATE(widget)], - TRUE, - 0, 0, - width, - height);*/ } else { drawable = entry->text_area; } - gtk_paint_entry (widget->style, drawable, - GTK_WIDGET_STATE(widget), - NULL, widget, "entry", - 0, 0, width, height); + gtk_paint_flat_box (widget->style, drawable, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + NULL, widget, "entry_bg", + 0, 0, width, height); y = (height - (widget->style->font->ascent + widget->style->font->descent)) / 2; y += widget->style->font->ascent; @@ -1359,7 +1356,7 @@ gtk_entry_draw_text (GtkEntry *entry) if (selection_start_pos > start_pos) gdk_draw_text (drawable, widget->style->font, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - start_xoffset, y, + INNER_BORDER + start_xoffset, y, toprint, selection_start_pos - start_pos); @@ -1367,24 +1364,16 @@ gtk_entry_draw_text (GtkEntry *entry) (selection_start_pos < end_pos) && (selection_start_pos != selection_end_pos)) { -/* - gdk_draw_rectangle (drawable, - widget->style->bg_gc[selected_state], - TRUE, - selection_start_xoffset, - 0, - selection_end_xoffset - selection_start_xoffset, - -1);*/ - gtk_paint_entry(widget->style, drawable, - selected_state, - NULL, widget, "selected", - selection_start_xoffset, - 0, - selection_end_xoffset - selection_start_xoffset, - -1); + gtk_paint_flat_box (widget->style, drawable, + selected_state, GTK_SHADOW_NONE, + NULL, widget, "text", + INNER_BORDER + selection_start_xoffset, + INNER_BORDER, + selection_end_xoffset - selection_start_xoffset, + height - 2*INNER_BORDER); gdk_draw_text (drawable, widget->style->font, widget->style->fg_gc[selected_state], - selection_start_xoffset, y, + INNER_BORDER + selection_start_xoffset, y, toprint + selection_start_pos - start_pos, selection_end_pos - selection_start_pos); } @@ -1392,7 +1381,7 @@ gtk_entry_draw_text (GtkEntry *entry) if (selection_end_pos < end_pos) gdk_draw_text (drawable, widget->style->font, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - selection_end_xoffset, y, + INNER_BORDER + selection_end_xoffset, y, toprint + selection_end_pos - start_pos, end_pos - selection_end_pos); /* free the space allocated for the stars if it's neccessary. */ @@ -1403,13 +1392,10 @@ gtk_entry_draw_text (GtkEntry *entry) gtk_entry_draw_cursor_on_drawable (entry, drawable); if (use_backing_pixmap) - { - gdk_gc_set_clip_rectangle (widget->style->fg_gc[GTK_STATE_NORMAL], NULL); - gdk_draw_pixmap(entry->text_area, - widget->style->fg_gc[GTK_STATE_NORMAL], - entry->backing_pixmap, - 0, 0, 0, 0, width, height); - } + gdk_draw_pixmap(entry->text_area, + widget->style->fg_gc[GTK_STATE_NORMAL], + entry->backing_pixmap, + 0, 0, 0, 0, width, height); } } @@ -1427,7 +1413,6 @@ gtk_entry_draw_cursor_on_drawable (GtkEntry *entry, GdkDrawable *drawable) { GtkWidget *widget; GtkEditable *editable; - GdkGC *gc; gint xoffset; gint text_area_height; @@ -1439,17 +1424,25 @@ gtk_entry_draw_cursor_on_drawable (GtkEntry *entry, GdkDrawable *drawable) widget = GTK_WIDGET (entry); editable = GTK_EDITABLE (entry); - xoffset = entry->char_offset[gtk_entry_find_char (entry, editable->current_pos)]; + xoffset = INNER_BORDER + entry->char_offset[gtk_entry_find_char (entry, editable->current_pos)]; xoffset -= entry->scroll_offset; + gdk_window_get_size (entry->text_area, NULL, &text_area_height); + if (GTK_WIDGET_HAS_FOCUS (widget) && (editable->selection_start_pos == editable->selection_end_pos)) - gc = widget->style->fg_gc[GTK_STATE_NORMAL]; + { + gdk_draw_line (drawable, widget->style->fg_gc[GTK_STATE_NORMAL], + xoffset, 0, xoffset, text_area_height); + } else - gc = widget->style->base_gc[GTK_WIDGET_STATE(widget)]; + { + gtk_paint_flat_box (widget->style, drawable, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + NULL, widget, "entry_bg", + xoffset, 0, 1, text_area_height); + } - gdk_window_get_size (entry->text_area, NULL, &text_area_height); - gdk_draw_line (drawable, gc, xoffset, 0, xoffset, text_area_height); #ifdef USE_XIM if (gdk_im_ready() && editable->ic && gdk_ic_get_style (editable->ic) & GDK_IM_PREEDIT_POSITION) diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index d38ae6517f..93414fa113 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -363,7 +363,8 @@ gtk_frame_paint (GtkWidget *widget, widget->allocation.y + y + height_extra / 2, widget->allocation.width - x * 2, widget->allocation.height - y * 2 - height_extra / 2, - 0, x2 + 2 - x, frame->label_width - 4); + GTK_POS_TOP, + x2 + 2 - x, frame->label_width - 4); gtk_paint_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), area, widget, "frame", diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index a6a9e2531f..a4d8bac299 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -308,7 +308,7 @@ gtk_handle_box_realize (GtkWidget *widget) gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (hb)); gtk_style_set_background (widget->style, hb->bin_window, GTK_WIDGET_STATE (hb)); gtk_style_set_background (widget->style, hb->float_window, GTK_WIDGET_STATE (hb)); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); } static void @@ -639,29 +639,25 @@ gtk_handle_box_paint (GtkWidget *widget, width = widget->allocation.width; height = widget->allocation.height - DRAG_HANDLE_SIZE; } -/* - if (!event) - gdk_window_clear_area (hb->bin_window, - area->x, - area->y, - area->width, - area->height); -*/ + if (!event) gtk_paint_box(widget->style, hb->bin_window, GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, area, widget, "handlebox_bin", - 0,0,-1,-1); + 0, 0, -1, -1); else gtk_paint_box(widget->style, hb->bin_window, GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, &event->area, widget, "handlebox_bin", - 0,0,-1,-1); -/* + 0, 0, -1, -1); + +/* We currently draw the handle _above_ the relief of the handlebox. + * it could also be drawn on the same level... + hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0, hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0, width, diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c index a3cc923fa9..cfea85c322 100644 --- a/gtk/gtklistitem.c +++ b/gtk/gtklistitem.c @@ -456,54 +456,37 @@ gtk_list_item_draw (GtkWidget *widget, { bin = GTK_BIN (widget); - if (widget->state == GTK_STATE_NORMAL) - { - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - } - else - { - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gtk_paint_flat_box(widget->style, widget->window, - widget->state, GTK_STATE_INSENSITIVE, - area, widget, "listitem", - 0, 0, -1, -1); - else - gtk_paint_flat_box(widget->style, widget->window, - widget->state, GTK_SHADOW_ETCHED_OUT, - area, widget, "listitem", - 0, 0, -1, -1); - } -/* - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gtk_style_set_background (widget->style, widget->window, GTK_STATE_INSENSITIVE); - else if (widget->state == GTK_STATE_NORMAL) - gdk_window_set_background (widget->window, - &widget->style->base[GTK_STATE_NORMAL]); + if (widget->state == GTK_STATE_NORMAL) + { + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + } else - gtk_style_set_background (widget->style, widget->window, widget->state); + { + gtk_paint_flat_box(widget->style, widget->window, + widget->state, GTK_SHADOW_ETCHED_OUT, + area, widget, "listitem", + 0, 0, -1, -1); + } - gdk_window_clear_area (widget->window, area->x, area->y, - area->width, area->height); -*/ if (bin->child && gtk_widget_intersect (bin->child, area, &child_area)) gtk_widget_draw (bin->child, &child_area); - if (GTK_WIDGET_HAS_FOCUS (widget)) - { - if (GTK_IS_LIST (widget->parent) && GTK_LIST (widget->parent)->add_mode) - gtk_paint_focus (widget->style, widget->window, - NULL, widget, "add-mode", - 0, 0, - widget->allocation.width - 1, - widget->allocation.height - 1); - else - gtk_paint_focus (widget->style, widget->window, - NULL, widget, NULL, - 0, 0, - widget->allocation.width - 1, - widget->allocation.height - 1); - } + if (GTK_WIDGET_HAS_FOCUS (widget)) + { + if (GTK_IS_LIST (widget->parent) && GTK_LIST (widget->parent)->add_mode) + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "add-mode", + 0, 0, + widget->allocation.width - 1, + widget->allocation.height - 1); + else + gtk_paint_focus (widget->style, widget->window, + NULL, widget, NULL, + 0, 0, + widget->allocation.width - 1, + widget->allocation.height - 1); + } } } diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 4876162e78..663c7c7405 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -668,7 +668,7 @@ gtk_menu_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gtk_menu_paint(widget); + gtk_menu_paint(widget); } static void diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 30417a1b05..50bb4eecc1 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -33,7 +33,8 @@ static void gtk_menu_bar_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_menu_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void gtk_menu_bar_paint (GtkWidget *widget); +static void gtk_menu_bar_paint (GtkWidget *widget, + GdkRectangle *area); static void gtk_menu_bar_draw (GtkWidget *widget, GdkRectangle *area); static gint gtk_menu_bar_expose (GtkWidget *widget, @@ -262,10 +263,21 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, } static void -gtk_menu_bar_paint (GtkWidget *widget) +gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU_BAR (widget)); + + if (GTK_WIDGET_DRAWABLE (widget)) + { + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_NORMAL, + GTK_SHADOW_OUT, + area, widget, "menubar", + 0, 0, + -1,-1); + } } static void @@ -283,13 +295,7 @@ gtk_menu_bar_draw (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { - gtk_paint_box (widget->style, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - area, widget, "menubar", - 0, 0, - -1,-1); + gtk_menu_bar_paint (widget, area); menu_shell = GTK_MENU_SHELL (widget); @@ -309,13 +315,32 @@ static gint gtk_menu_bar_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkMenuShell *menu_shell; + GdkEventExpose child_event; + GList *children; + GtkWidget *child; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); if (GTK_WIDGET_DRAWABLE (widget)) { - gtk_menu_bar_draw(widget, &event->area); + gtk_menu_bar_paint (widget, &event->area); + + menu_shell = GTK_MENU_SHELL (widget); + child_event = *event; + + children = menu_shell->children; + while (children) + { + child = children->data; + children = children->next; + + if (GTK_WIDGET_NO_WINDOW (child) && + gtk_widget_intersect (child, &event->area, &child_event.area)) + gtk_widget_event (child, (GdkEvent*) &child_event); + } } return FALSE; diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 823d99c420..8890a7502b 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -415,26 +415,25 @@ gtk_menu_item_paint (GtkWidget *widget, if (!GTK_WIDGET_IS_SENSITIVE (widget)) state_type = GTK_STATE_INSENSITIVE; -/* gdk_window_set_back_pixmap (widget->window, NULL, TRUE);*/ - x = GTK_CONTAINER (menu_item)->border_width; y = GTK_CONTAINER (menu_item)->border_width; width = widget->allocation.width - x * 2; height = widget->allocation.height - y * 2; - + if ((state_type == GTK_STATE_PRELIGHT) && (GTK_BIN (menu_item)->child)) - gtk_paint_box (widget->style, - widget->window, - GTK_STATE_PRELIGHT, - GTK_SHADOW_OUT, - area, widget, "menuitem", - x, y, width, height); - else + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_PRELIGHT, + GTK_SHADOW_OUT, + area, widget, "menuitem", + x, y, width, height); + else { gdk_window_set_back_pixmap (widget->window, NULL, TRUE); gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); } + if (menu_item->submenu && menu_item->show_submenu_indicator) { shadow_type = GTK_SHADOW_OUT; diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 3f7d05e471..e10724624a 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -168,9 +168,9 @@ static void gtk_notebook_menu_item_create (GtkNotebook *notebook, static GtkType gtk_notebook_child_type (GtkContainer *container); static gint gtk_notebook_find_page (gconstpointer a, gconstpointer b); -static void gtk_notebook_set_shape (GtkNotebook *notebook); -static void gtk_notebook_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void gtk_notebook_set_shape (GtkNotebook *notebook); +static void gtk_notebook_style_set (GtkWidget *widget, + GtkStyle *previous_style); static GtkContainerClass *parent_class = NULL; static guint notebook_signals[LAST_SIGNAL] = { 0 }; @@ -1274,7 +1274,7 @@ gtk_notebook_set_scrollable (GtkNotebook *notebook, g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); - scrollable = (scrollable != 0); + scrollable = (scrollable != FALSE); if (scrollable != notebook->scrollable) { @@ -1371,8 +1371,8 @@ gtk_notebook_realize (GtkWidget *widget) attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK; + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; @@ -1382,8 +1382,8 @@ gtk_notebook_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); - if (notebook->scrollable) + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + if (notebook->scrollable) gtk_notebook_panel_realize (notebook); } @@ -1428,8 +1428,8 @@ gtk_notebook_panel_realize (GtkNotebook *notebook) attributes_mask); gtk_style_set_background (widget->style, notebook->panel, GTK_STATE_NORMAL); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); - gdk_window_set_user_data (notebook->panel, widget); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_set_user_data (notebook->panel, widget); } static void @@ -1655,21 +1655,21 @@ static void gtk_notebook_paint (GtkWidget *widget, GdkRectangle *area) { - GtkNotebook *notebook; - GtkNotebookPage *page; - GList *children; - gint width, height; - gint x, y; - gint showarrow; - gint gap_side = 0, gap_x = 0, gap_width = 0; + GtkNotebook *notebook; + GtkNotebookPage *page; + GList *children; + gint width, height; + gint x, y; + gint showarrow; + gint gap_x = 0, gap_width = 0; - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_NOTEBOOK (widget)); - g_return_if_fail (area != NULL); + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_NOTEBOOK (widget)); + g_return_if_fail (area != NULL); - if (GTK_WIDGET_DRAWABLE (widget)) - { - notebook = GTK_NOTEBOOK (widget); + if (GTK_WIDGET_DRAWABLE (widget)) + { + notebook = GTK_NOTEBOOK (widget); if (notebook->show_tabs || notebook->show_border) { @@ -1702,9 +1702,9 @@ gtk_notebook_paint (GtkWidget *widget, case GTK_POS_RIGHT: width -= page->allocation.width + widget->style->klass->xthickness; - break; + break; } - gtk_paint_box(widget->style, widget->window, + gtk_paint_box (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, area, widget, "notebook", x, y, width, height); @@ -1726,37 +1726,33 @@ gtk_notebook_paint (GtkWidget *widget, } switch (notebook->tab_pos) - { - case GTK_POS_TOP: - gap_side = 0; - gap_x = notebook->cur_page->allocation.x - - GTK_CONTAINER(notebook)->border_width; - gap_width = notebook->cur_page->allocation.width; - break; - case GTK_POS_BOTTOM: - gap_side = 1; - gap_x = notebook->cur_page->allocation.x - - GTK_CONTAINER(notebook)->border_width; - gap_width = notebook->cur_page->allocation.width; - break; - case GTK_POS_LEFT: - gap_side = 2; - gap_x = notebook->cur_page->allocation.y - - GTK_CONTAINER(notebook)->border_width; - gap_width = notebook->cur_page->allocation.height; - break; - case GTK_POS_RIGHT: - gap_side = 3; - gap_x = notebook->cur_page->allocation.y - - GTK_CONTAINER(notebook)->border_width; - gap_width = notebook->cur_page->allocation.height; - break; - } - gtk_paint_box_gap(widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - area, widget, "notebook", - x, y, width, height, - gap_side, gap_x, gap_width); + { + case GTK_POS_TOP: + gap_x = notebook->cur_page->allocation.x - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.width; + break; + case GTK_POS_BOTTOM: + gap_x = notebook->cur_page->allocation.x - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.width; + break; + case GTK_POS_LEFT: + gap_x = notebook->cur_page->allocation.y - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.height; + break; + case GTK_POS_RIGHT: + gap_x = notebook->cur_page->allocation.y - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.height; + break; + } + gtk_paint_box_gap(widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + area, widget, "notebook", + x, y, width, height, + notebook->tab_pos, gap_x, gap_width); } children = g_list_last (notebook->children); showarrow = FALSE; @@ -1784,10 +1780,10 @@ gtk_notebook_paint (GtkWidget *widget, } else if (notebook->show_border) { - gtk_paint_box(widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - area, widget, "notebook", - x, y, width, height); + gtk_paint_box(widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + area, widget, "notebook", + x, y, width, height); } } } @@ -2189,7 +2185,8 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, guint arrow) if (notebook->tab_pos == GTK_POS_LEFT || notebook->tab_pos == GTK_POS_RIGHT) arrow = GTK_ARROW_UP; - gdk_window_clear_area(notebook->panel, 0, 0, ARROW_SIZE, ARROW_SIZE); + + gdk_window_clear_area (notebook->panel, 0, 0, ARROW_SIZE, ARROW_SIZE); gtk_paint_arrow (widget->style, notebook->panel, state_type, shadow_type, NULL, GTK_WIDGET(notebook), "notebook", arrow, TRUE, @@ -2262,11 +2259,11 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, GdkRectangle *area) { - GdkRectangle child_area; - GdkRectangle page_area; - GtkStateType state_type; - gint gap_side; - + GdkRectangle child_area; + GdkRectangle page_area; + GtkStateType state_type; + GtkPositionType gap_side; + g_return_if_fail (notebook != NULL); g_return_if_fail (page != NULL); g_return_if_fail (area != NULL); @@ -2284,47 +2281,47 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, { GtkWidget *widget; - widget = GTK_WIDGET(notebook); - gap_side = 0; + widget = GTK_WIDGET (notebook); + gap_side = 0; switch (notebook->tab_pos) { - case GTK_POS_TOP: - gap_side = 1; - break; - case GTK_POS_BOTTOM: - gap_side = 0; - break; - case GTK_POS_LEFT: - gap_side = 3; - break; - case GTK_POS_RIGHT: - gap_side = 2; - break; + case GTK_POS_TOP: + gap_side = GTK_POS_BOTTOM; + break; + case GTK_POS_BOTTOM: + gap_side = GTK_POS_TOP; + break; + case GTK_POS_LEFT: + gap_side = GTK_POS_RIGHT; + break; + case GTK_POS_RIGHT: + gap_side = GTK_POS_RIGHT; + break; } - + if (notebook->cur_page == page) - state_type = GTK_STATE_NORMAL; + state_type = GTK_STATE_NORMAL; else - state_type = GTK_STATE_ACTIVE; - gtk_paint_extension(widget->style, widget->window, - state_type, GTK_SHADOW_OUT, + state_type = GTK_STATE_ACTIVE; + gtk_paint_extension(widget->style, widget->window, + state_type, GTK_SHADOW_OUT, + area, widget, "tab", + page_area.x, page_area.y, + page_area.width, page_area.height, + gap_side); + if ((GTK_WIDGET_HAS_FOCUS (widget)) && + notebook->focus_tab && (notebook->focus_tab->data == page) && + (page)) + { + gtk_paint_focus (widget->style, widget->window, area, widget, "tab", - page_area.x, page_area.y, - page_area.width, page_area.height, - gap_side); - if ((GTK_WIDGET_HAS_FOCUS (widget)) && - notebook->focus_tab && (notebook->focus_tab->data == page) && - (page)) - { - gtk_paint_focus (widget->style, widget->window, - area, widget, "tab", - page->tab_label->allocation.x - 1, - page->tab_label->allocation.y - 1, - page->tab_label->allocation.width + 1, - page->tab_label->allocation.height + 1); - } - if (gtk_widget_intersect (page->tab_label, area, &child_area)) - gtk_widget_draw (page->tab_label, &child_area); + page->tab_label->allocation.x - 1, + page->tab_label->allocation.y - 1, + page->tab_label->allocation.width + 1, + page->tab_label->allocation.height + 1); + } + if (gtk_widget_intersect (page->tab_label, area, &child_area)) + gtk_widget_draw (page->tab_label, &child_area); } } @@ -2738,7 +2735,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, gtk_widget_map (page->tab_label); } } - gtk_notebook_set_shape (notebook); + gtk_notebook_set_shape (notebook); } static void diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h index 88cae1b721..013e08c2b0 100644 --- a/gtk/gtknotebook.h +++ b/gtk/gtknotebook.h @@ -78,13 +78,13 @@ struct _GtkNotebookClass struct _GtkNotebookPage { - GtkWidget *child; - GtkWidget *tab_label; - GtkWidget *menu_label; - guint default_menu : 1; - guint default_tab : 1; - GtkRequisition requisition; - GtkAllocation allocation; + GtkWidget *child; + GtkWidget *tab_label; + GtkWidget *menu_label; + guint default_menu : 1; + guint default_tab : 1; + GtkRequisition requisition; + GtkAllocation allocation; }; diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 8786402231..ae4da2a5e9 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -31,10 +31,10 @@ static void gtk_paned_add (GtkContainer *container, GtkWidget *widget); static void gtk_paned_remove (GtkContainer *container, GtkWidget *widget); -static void gtk_paned_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); +static void gtk_paned_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); static GtkType gtk_paned_child_type (GtkContainer *container); diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c index 5f4006555e..9cc6ec0076 100644 --- a/gtk/gtkpixmap.c +++ b/gtk/gtkpixmap.c @@ -80,15 +80,15 @@ GtkWidget* gtk_pixmap_new (GdkPixmap *val, GdkBitmap *mask) { - GtkPixmap *pixmap; - - g_return_val_if_fail (val != NULL, NULL); - - pixmap = gtk_type_new (gtk_pixmap_get_type ()); + GtkPixmap *pixmap; - gtk_pixmap_set (pixmap, val, mask); - - return GTK_WIDGET (pixmap); + g_return_val_if_fail (val != NULL, NULL); + + pixmap = gtk_type_new (gtk_pixmap_get_type ()); + + gtk_pixmap_set (pixmap, val, mask); + + return GTK_WIDGET (pixmap); } static void @@ -184,17 +184,6 @@ gtk_pixmap_expose (GtkWidget *widget, pixmap = GTK_PIXMAP (widget); misc = GTK_MISC (widget); -/* - x = widget->allocation.x + - (gint)((gfloat)((widget->allocation.width - - widget->requisition.width) - + (misc->xpad * 2)) * misc->xalign); - y = widget->allocation.y + - (gint)((gfloat)((widget->allocation.height - - widget->requisition.height) - + (misc->ypad * 2)) * misc->yalign); -*/ - x = (widget->allocation.x * (1.0 - misc->xalign) + (widget->allocation.x + widget->allocation.width - (widget->requisition.width - misc->xpad * 2)) * diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c index aed159df07..076310137a 100644 --- a/gtk/gtkpreview.c +++ b/gtk/gtkpreview.c @@ -423,7 +423,7 @@ gtk_preview_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); } static gint diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 115bf8bf18..429f8a435d 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -379,47 +379,47 @@ gtk_progress_bar_paint (GtkProgress *progress) if (progress->offscreen_pixmap) { - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - NULL, widget, "trough", - 0, 0, - widget->allocation.width, - widget->allocation.height); - + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + NULL, widget, "trough", + 0, 0, + widget->allocation.width, + widget->allocation.height); + if (progress->activity_mode) { if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT || pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT) { size = MAX (2, widget->allocation.width / pbar->activity_blocks); - - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - pbar->activity_pos, - widget->style->klass->ythickness, - size, - widget->allocation.height - widget->style->klass->ythickness * 2); + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + pbar->activity_pos, + widget->style->klass->ythickness, + size, + widget->allocation.height - widget->style->klass->ythickness * 2); return; } else { size = MAX (2, widget->allocation.height / pbar->activity_blocks); - - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->style->klass->xthickness, - pbar->activity_pos, - widget->allocation.width - widget->style->klass->xthickness * 2, - size); + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + pbar->activity_pos, + widget->allocation.width - widget->style->klass->xthickness * 2, + size); return; } } - + amount = percentage * space; if (amount > 0) @@ -431,14 +431,14 @@ gtk_progress_bar_paint (GtkProgress *progress) if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->style->klass->xthickness, - widget->style->klass->ythickness, - amount, - widget->allocation.height - widget->style->klass->ythickness * 2); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + widget->style->klass->ythickness, + amount, + widget->allocation.height - widget->style->klass->ythickness * 2); } else { @@ -449,56 +449,56 @@ gtk_progress_bar_paint (GtkProgress *progress) block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - x, - widget->style->klass->ythickness, - block_delta, - widget->allocation.height - widget->style->klass->ythickness * 2); - + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + x, + widget->style->klass->ythickness, + block_delta, + widget->allocation.height - widget->style->klass->ythickness * 2); + x += block_delta; } } break; - + case GTK_PROGRESS_RIGHT_TO_LEFT: - + if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->allocation.width - - widget->style->klass->xthickness - amount, - widget->style->klass->ythickness, - amount, - widget->allocation.height - - widget->style->klass->ythickness * 2); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->allocation.width - + widget->style->klass->xthickness - amount, + widget->style->klass->ythickness, + amount, + widget->allocation.height - + widget->style->klass->ythickness * 2); } else { x = widget->allocation.width - widget->style->klass->xthickness; - + for (i = 0; i <= pbar->in_block; i++) { block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - - x -= block_delta; - - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - x, - widget->style->klass->ythickness, - block_delta, - widget->allocation.height - - widget->style->klass->ythickness * 2); + + x -= block_delta; + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + x, + widget->style->klass->ythickness, + block_delta, + widget->allocation.height - + widget->style->klass->ythickness * 2); } } break; @@ -507,86 +507,86 @@ gtk_progress_bar_paint (GtkProgress *progress) if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->style->klass->xthickness, - widget->allocation.height - - widget->style->klass->ythickness - amount, - widget->allocation.width - - widget->style->klass->xthickness * 2, - amount); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + widget->allocation.height - + widget->style->klass->ythickness - amount, + widget->allocation.width - + widget->style->klass->xthickness * 2, + amount); } else { y = widget->allocation.height - widget->style->klass->ythickness; - + for (i = 0; i <= pbar->in_block; i++) { block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - y -= block_delta; - - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->style->klass->xthickness, - y, - widget->allocation.width - - widget->style->klass->xthickness * 2, - block_delta); + y -= block_delta; + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + y, + widget->allocation.width - + widget->style->klass->xthickness * 2, + block_delta); } } break; - + case GTK_PROGRESS_TOP_TO_BOTTOM: - + if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) - { - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->style->klass->xthickness, - widget->style->klass->ythickness, - widget->allocation.width - - widget->style->klass->xthickness * 2, - amount); - } + { + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + widget->style->klass->ythickness, + widget->allocation.width - + widget->style->klass->xthickness * 2, + amount); + } else { y = widget->style->klass->ythickness; - + for (i = 0; i <= pbar->in_block; i++) { - + block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - - gtk_paint_box (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - NULL, widget, "bar", - widget->style->klass->xthickness, - y, - widget->allocation.width - - widget->style->klass->xthickness * 2, - block_delta); - + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + y, + widget->allocation.width - + widget->style->klass->xthickness * 2, + block_delta); + y += block_delta; } } break; - + default: break; } } - + if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE) { gint x; diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index 0d3cecc4ce..33c78e76ea 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -98,8 +98,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class) static void gtk_radio_button_init (GtkRadioButton *radio_button) { - GTK_WIDGET_SET_FLAGS (radio_button, GTK_NO_WINDOW); - radio_button->group = g_slist_prepend (NULL, radio_button); + GTK_WIDGET_SET_FLAGS (radio_button, GTK_NO_WINDOW); + radio_button->group = g_slist_prepend (NULL, radio_button); } static void @@ -395,15 +395,15 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; width = CHECK_BUTTON_CLASS (widget)->indicator_size; height = CHECK_BUTTON_CLASS (widget)->indicator_size; - + if (GTK_TOGGLE_BUTTON (widget)->active) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; - - gtk_paint_option (widget->style, widget->window, - GTK_WIDGET_STATE (widget), shadow_type, - area, widget, "radiobutton", - x, y, width, height); + + gtk_paint_option (widget->style, widget->window, + GTK_WIDGET_STATE (widget), shadow_type, + area, widget, "radiobutton", + x, y, width, height); } } diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index 43c041f9b5..482bcdd85d 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -253,10 +253,11 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; - gtk_paint_option (widget->style, widget->window, - state_type, shadow_type, - area, widget, "option", - x, y, width, height); + + gtk_paint_option (widget->style, widget->window, + state_type, shadow_type, + area, widget, "option", + x, y, width, height); } } } diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 09b112df23..0f3767a03a 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -597,7 +597,22 @@ gtk_rc_styles_match (GSList *rc_styles, GtkStyle* gtk_rc_get_style (GtkWidget *widget) { + GtkRcStyle *widget_rc_style; GSList *rc_styles = NULL; + + static guint rc_style_key_id = 0; + + /* We allow the specification of a single rc style to be bound + * tightly to a widget, for application modifications + */ + if (!rc_style_key_id) + rc_style_key_id = g_quark_from_static_string ("gtk-rc-style"); + + widget_rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), + rc_style_key_id); + + if (widget_rc_style) + rc_styles = g_list_prepend (rc_styles, widget_rc_style); if (gtk_rc_sets_widget) { diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c index 9ce7eeb053..2b25500f04 100644 --- a/gtk/gtkruler.c +++ b/gtk/gtkruler.c @@ -247,23 +247,23 @@ gtk_ruler_expose (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { - ruler = GTK_RULER (widget); - - gtk_paint_box (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - NULL, widget, "ruler", - 0, 0, -1, -1); - - gtk_ruler_draw_ticks (ruler); - - gdk_draw_pixmap (widget->window, - ruler->non_gr_exp_gc, - ruler->backing_store, - 0, 0, 0, 0, - widget->allocation.width, - widget->allocation.height); - - gtk_ruler_draw_pos (ruler); + ruler = GTK_RULER (widget); + + gtk_paint_box (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, widget, "ruler", + 0, 0, -1, -1); + + gtk_ruler_draw_ticks (ruler); + + gdk_draw_pixmap (widget->window, + ruler->non_gr_exp_gc, + ruler->backing_store, + 0, 0, 0, 0, + widget->allocation.width, + widget->allocation.height); + + gtk_ruler_draw_pos (ruler); } return FALSE; diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 2c54fbe309..3cb6889f31 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -505,7 +505,7 @@ gtk_spin_button_paint (GtkWidget *widget, 0, 0, ARROW_SIZE + 2 * widget->style->klass->xthickness, widget->requisition.height); - else + else { gdk_window_set_back_pixmap (spin->panel, NULL, TRUE); gdk_window_clear_area (spin->panel, area->x, area->y, area->width, area->height); @@ -587,12 +587,12 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, x = widget->style->klass->xthickness - 1; y = widget->style->klass->ythickness - 1; } - gtk_paint_arrow (widget->style, spin_button->panel, - state_type, shadow_type, - NULL, widget, "spinbutton", - arrow, TRUE, - x, y, ARROW_SIZE, widget->requisition.height / 2 - - widget->style->klass->ythickness); + gtk_paint_arrow (widget->style, spin_button->panel, + state_type, shadow_type, + NULL, widget, "spinbutton", + arrow, TRUE, + x, y, ARROW_SIZE, widget->requisition.height / 2 + - widget->style->klass->ythickness); } else { @@ -606,12 +606,12 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, x = widget->style->klass->xthickness - 1; y = widget->requisition.height / 2 + 1; } - gtk_paint_arrow (widget->style, spin_button->panel, - state_type, shadow_type, - NULL, widget, "spinbutton", - arrow, TRUE, - x, y, ARROW_SIZE, widget->requisition.height / 2 - - widget->style->klass->ythickness); + gtk_paint_arrow (widget->style, spin_button->panel, + state_type, shadow_type, + NULL, widget, "spinbutton", + arrow, TRUE, + x, y, ARROW_SIZE, widget->requisition.height / 2 + - widget->style->klass->ythickness); } } } diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 16f7c2e098..8f4fc5f614 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -84,7 +84,7 @@ static void gtk_default_draw_polygon (GtkStyle *style, gchar *detail, GdkPoint *points, gint npoints, - gint fill); + gboolean fill); static void gtk_default_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -93,7 +93,7 @@ static void gtk_default_draw_arrow (GtkStyle *style, GtkWidget *widget, gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -207,46 +207,46 @@ static void gtk_default_draw_tab (GtkStyle *style, gint y, gint width, gint height); -static void gtk_default_draw_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); -static void gtk_default_draw_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); -static void gtk_default_draw_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side); +static void gtk_default_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +static void gtk_default_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +static void gtk_default_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); static void gtk_default_draw_focus (GtkStyle *style, GdkWindow *window, GdkRectangle *area, @@ -268,16 +268,6 @@ static void gtk_default_draw_slider (GtkStyle *style, gint width, gint height, GtkOrientation orientation); -static void gtk_default_draw_entry (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height); static void gtk_default_draw_handle (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -324,7 +314,6 @@ GtkStyleClass default_class = gtk_default_draw_extension, gtk_default_draw_focus, gtk_default_draw_slider, - gtk_default_draw_entry, gtk_default_draw_handle }; GdkFont *default_font = NULL; @@ -833,7 +822,7 @@ gtk_draw_polygon (GtkStyle *style, GtkShadowType shadow_type, GdkPoint *points, gint npoints, - gint fill) + gboolean fill) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -848,7 +837,7 @@ gtk_draw_arrow (GtkStyle *style, GtkStateType state_type, GtkShadowType shadow_type, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -1033,17 +1022,17 @@ gtk_draw_tab (GtkStyle *style, } void -gtk_draw_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width) +gtk_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -1053,17 +1042,17 @@ gtk_draw_shadow_gap (GtkStyle *style, } void -gtk_draw_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width) +gtk_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -1073,15 +1062,15 @@ gtk_draw_box_gap (GtkStyle *style, } void -gtk_draw_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height, - gint gap_side) +gtk_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -1124,22 +1113,6 @@ gtk_draw_slider (GtkStyle *style, } void -gtk_draw_entry (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - gint x, - gint y, - gint width, - gint height) -{ - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_entry != NULL); - - (*style->klass->draw_entry) (style, window, state_type, NULL, NULL, NULL, x, y, width, height); -} - -void gtk_draw_handle (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -1498,7 +1471,7 @@ gtk_default_draw_polygon (GtkStyle *style, gchar *detail, GdkPoint *points, gint npoints, - gint fill) + gboolean fill) { #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -1638,7 +1611,7 @@ gtk_default_draw_arrow (GtkStyle *style, GtkWidget *widget, gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -2212,26 +2185,27 @@ gtk_default_draw_flat_box (GtkStyle *style, gint width, gint height) { - GdkGC *gc1; - - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); + GdkGC *gc1; - if ((width == -1) && (height == -1)) - 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); + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); - gc1 = style->bg_gc[state_type]; + if ((width == -1) && (height == -1)) + 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); - if ((detail) && (!strcmp("selected",detail))) - gc1 = style->bg_gc[GTK_STATE_SELECTED]; - if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED)) - gc1 = style->bg_gc[GTK_STATE_SELECTED]; - else if ((detail) && (!strcmp("viewportbin",detail))) - gc1 = style->bg_gc[GTK_STATE_NORMAL]; + if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED)) + gc1 = style->bg_gc[GTK_STATE_SELECTED]; + else if ((detail) && (!strcmp("viewportbin",detail))) + gc1 = style->bg_gc[GTK_STATE_NORMAL]; + else if ((detail) && (!strcmp("entry_bg",detail))) + gc1 = style->base_gc[state_type]; + else + gc1 = style->bg_gc[state_type]; + if ((!style->bg_pixmap[state_type]) || (gc1 != style->bg_gc[state_type]) || (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP)) { @@ -2287,34 +2261,36 @@ gtk_default_draw_option (GtkStyle *style, detail, x, y, width, height); } -static void gtk_default_draw_cross (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +static void +gtk_default_draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); } -static void gtk_default_draw_ramp (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - GtkArrowType arrow_type, - gint x, - gint y, - gint width, - gint height) +static void +gtk_default_draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height) { g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); @@ -2339,20 +2315,21 @@ static void gtk_default_draw_tab (GtkStyle *style, x, y, width, height); } -static void gtk_default_draw_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width) +static void +gtk_default_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { GdkGC *gc1 = NULL; GdkGC *gc2 = NULL; @@ -2413,14 +2390,14 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style, case GTK_SHADOW_OUT: case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_OUT: - if (gap_side == 0) - /* top */ + switch (gap_side) { + case GTK_POS_TOP: gdk_draw_line (window, gc1, x, y, x, y + height - 1); gdk_draw_line (window, gc2, x + 1, y, x + 1, y + height - 2); - + gdk_draw_line (window, gc3, x + 1, y + height - 2, x + width - 2, y + height - 2); gdk_draw_line (window, gc3, @@ -2447,10 +2424,8 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style, gdk_draw_line (window, gc2, x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y); } - } - else if (gap_side == 1) - /* bottom */ - { + break; + case GTK_POS_BOTTOM: gdk_draw_line (window, gc1, x, y, x + width - 1, y); gdk_draw_line (window, gc1, @@ -2482,10 +2457,8 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style, gdk_draw_line (window, gc3, x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1); } - } - else if (gap_side == 2) - /* left */ - { + break; + case GTK_POS_LEFT: gdk_draw_line (window, gc1, x, y, x + width - 1, y); gdk_draw_line (window, gc2, @@ -2517,10 +2490,8 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style, gdk_draw_line (window, gc2, x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1); } - } - else if (gap_side == 3) - /* right */ - { + break; + case GTK_POS_RIGHT: gdk_draw_line (window, gc1, x, y, x + width - 1, y); gdk_draw_line (window, gc1, @@ -2552,6 +2523,7 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style, gdk_draw_line (window, gc3, x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1); } + break; } } if (area) @@ -2563,20 +2535,21 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style, } } -static void gtk_default_draw_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width) +static void +gtk_default_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { GdkGC *gc1 = NULL; GdkGC *gc2 = NULL; @@ -2790,18 +2763,19 @@ static void gtk_default_draw_box_gap (GtkStyle *style, } } -static void gtk_default_draw_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side) +static void +gtk_default_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side) { GdkGC *gc1 = NULL; GdkGC *gc2 = NULL; @@ -2864,9 +2838,9 @@ static void gtk_default_draw_extension (GtkStyle *style, case GTK_SHADOW_OUT: case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_OUT: - if (gap_side == 0) - /* top */ + switch (gap_side) { + case GTK_POS_TOP: gtk_style_apply_default_pixmap(style, window, state_type, area, x + style->klass->xthickness, y, @@ -2885,10 +2859,8 @@ static void gtk_default_draw_extension (GtkStyle *style, x + 1, y + height - 1, x + width - 2, y + height - 1); gdk_draw_line (window, gc4, x + width - 1, y, x + width - 1, y + height - 2); - } - else if (gap_side == 1) - /* bottom */ - { + break; + case GTK_POS_BOTTOM: gtk_style_apply_default_pixmap(style, window, state_type, area, x + style->klass->xthickness, y + style->klass->ythickness, @@ -2907,10 +2879,8 @@ static void gtk_default_draw_extension (GtkStyle *style, x + width - 2, y + 2, x + width - 2, y + height - 1); gdk_draw_line (window, gc4, x + width - 1, y + 1, x + width - 1, y + height - 1); - } - else if (gap_side == 2) - /* left */ - { + break; + case GTK_POS_LEFT: gtk_style_apply_default_pixmap(style, window, state_type, area, x, y + style->klass->ythickness, @@ -2929,10 +2899,8 @@ static void gtk_default_draw_extension (GtkStyle *style, x, y + height - 1, x + width - 2, y + height - 1); gdk_draw_line (window, gc4, x + width - 1, y + 1, x + width - 1, y + height - 2); - } - else if (gap_side == 3) - /* right */ - { + break; + case GTK_POS_RIGHT: gtk_style_apply_default_pixmap(style, window, state_type, area, x + style->klass->xthickness, y + style->klass->ythickness, @@ -2951,6 +2919,7 @@ static void gtk_default_draw_extension (GtkStyle *style, x + 2, y + height - 2, x + width - 1, y + height - 2); gdk_draw_line (window, gc4, x + 1, y + height - 1, x + width - 1, y + height - 1); + break; } } if (area) @@ -2962,15 +2931,16 @@ static void gtk_default_draw_extension (GtkStyle *style, } } -static void gtk_default_draw_focus (GtkStyle *style, - GdkWindow *window, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +static void +gtk_default_draw_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); @@ -3018,18 +2988,19 @@ static void gtk_default_draw_focus (GtkStyle *style, } } -static void gtk_default_draw_slider (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) +static void +gtk_default_draw_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) { g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); @@ -3053,63 +3024,19 @@ static void gtk_default_draw_slider (GtkStyle *style, width - style->klass->xthickness - 1, height / 2); } -static void gtk_default_draw_entry (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) -{ - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - if ((width == -1) && (height == -1)) - 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); - - if (!strcmp("selected",detail)) - { - gdk_draw_rectangle (window, - style->bg_gc[state_type], - TRUE, - x, y, - width, - height); - } - else - { - if (area) - gdk_gc_set_clip_rectangle (style->base_gc[state_type], area); - gdk_draw_rectangle (window, - style->base_gc[state_type], - TRUE, - x, y, - width, - height); - if (area) - gdk_gc_set_clip_rectangle (style->base_gc[state_type], NULL); - } -} - -static void gtk_default_draw_handle (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) +static void +gtk_default_draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) { gint xx, yy; gint xthick, ythick; @@ -3339,18 +3266,17 @@ hls_to_rgb (gdouble *h, *s = b; } } - - - -void gtk_paint_hline (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x1, - gint x2, - gint y) + +void +gtk_paint_hline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x1, + gint x2, + gint y) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -3359,52 +3285,55 @@ void gtk_paint_hline (GtkStyle *style, (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y); } -void gtk_paint_vline (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint y1, - gint y2, - gint x) +void +gtk_paint_vline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint y1, + gint y2, + gint x) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_vline != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_vline != NULL); - (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x); + (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x); } -void gtk_paint_shadow (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_shadow != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_shadow != NULL); - (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_polygon (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - GdkPoint *points, - gint npoints, - gint fill) +void +gtk_paint_polygon (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GdkPoint *points, + gint npoints, + gboolean fill) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -3413,19 +3342,20 @@ void gtk_paint_polygon (GtkStyle *style, (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill); } -void gtk_paint_arrow (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - GtkArrowType arrow_type, - gint fill, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_arrow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gboolean fill, + gint x, + gint y, + gint width, + gint height) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -3434,17 +3364,18 @@ void gtk_paint_arrow (GtkStyle *style, (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height); } -void gtk_paint_diamond (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_diamond (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -3453,17 +3384,18 @@ void gtk_paint_diamond (GtkStyle *style, (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_oval (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_oval (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -3472,15 +3404,16 @@ void gtk_paint_oval (GtkStyle *style, (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_string (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - const gchar *string) +void +gtk_paint_string (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + const gchar *string) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); @@ -3489,276 +3422,271 @@ void gtk_paint_string (GtkStyle *style, (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string); } -void gtk_paint_box (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_box != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_box != NULL); - (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_flat_box (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_flat_box != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_flat_box != NULL); - (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_check (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_check != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_check != NULL); - (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_option (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_option != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_option != NULL); - (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_cross (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_cross != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_cross != NULL); - (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_ramp (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - GtkArrowType arrow_type, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_ramp != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_ramp != NULL); - (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height); + (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height); } -void gtk_paint_tab (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_tab != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_tab != NULL); - (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } -void gtk_paint_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width) +void +gtk_paint_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_shadow_gap != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_shadow_gap != NULL); - (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); + (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); } -void gtk_paint_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width) -{ - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_box_gap != NULL); - - (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); -} - -void gtk_paint_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side) +void +gtk_paint_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_extension != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_box_gap != NULL); - (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side); + (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); } -void gtk_paint_focus (GtkStyle *style, - GdkWindow *window, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_focus != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_extension != NULL); - (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height); + (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side); } -void gtk_paint_slider (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) +void +gtk_paint_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_slider != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_focus != NULL); - (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); + (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height); } -void gtk_paint_entry (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height) +void +gtk_paint_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_entry != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_slider != NULL); - (*style->klass->draw_entry) (style, window, state_type, area, widget, detail, x, y, width, height); + (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); } -void gtk_paint_handle (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - GtkOrientation orientation) +void +gtk_paint_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) { - g_return_if_fail (style != NULL); - g_return_if_fail (style->klass != NULL); - g_return_if_fail (style->klass->draw_handle != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_handle != NULL); - (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); + (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); } diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h index 296017f24b..556722475c 100644 --- a/gtk/gtkstyle.h +++ b/gtk/gtkstyle.h @@ -35,12 +35,12 @@ typedef struct _GtkStyleClass GtkStyleClass; */ typedef struct _GtkThemeEngine GtkThemeEngine; -typedef struct _GtkRcStyle GtkRcStyle; +typedef struct _GtkRcStyle GtkRcStyle; -#ifndef __TYPEDEFED_GTK_WIDGET__ -typedef struct _GtkWidget GtkWidget; -#define __TYPEDEFED_GTK_WIDGET__ -#endif +/* We make this forward declaration here, since we pass + * GtkWidgt's to the draw functions. + */ +typedef struct _GtkWidget GtkWidget; /* This is used for having dynamic style changing stuff */ /* fg, bg, light, dark, mid, text, base */ @@ -134,7 +134,7 @@ struct _GtkStyleClass gchar *detail, GdkPoint *point, gint npoints, - gint fill); + gboolean fill); void (*draw_arrow) (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -143,7 +143,7 @@ struct _GtkStyleClass GtkWidget *widget, gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -257,46 +257,46 @@ struct _GtkStyleClass gint y, gint width, gint height); - void (*draw_shadow_gap) (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); - void (*draw_box_gap) (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); - void (*draw_extension) (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side); + void (*draw_shadow_gap) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); + void (*draw_box_gap) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); + void (*draw_extension) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); void (*draw_focus) (GtkStyle *style, GdkWindow *window, GdkRectangle *area, @@ -318,16 +318,6 @@ struct _GtkStyleClass gint width, gint height, GtkOrientation orientation); - void (*draw_entry) (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height); void (*draw_handle) (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -387,13 +377,13 @@ void gtk_draw_polygon (GtkStyle *style, GtkShadowType shadow_type, GdkPoint *points, gint npoints, - gint fill); + gboolean fill); void gtk_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -477,37 +467,37 @@ void gtk_draw_tab (GtkStyle *style, gint y, gint width, gint height); -void gtk_draw_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); -void gtk_draw_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); -void gtk_draw_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height, - gint gap_side); +void gtk_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); void gtk_draw_focus (GtkStyle *style, GdkWindow *window, gint x, @@ -523,13 +513,6 @@ void gtk_draw_slider (GtkStyle *style, gint width, gint height, GtkOrientation orientation); -void gtk_draw_entry (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - gint x, - gint y, - gint width, - gint height); void gtk_draw_handle (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -598,7 +581,7 @@ void gtk_paint_polygon (GtkStyle *style, gchar *detail, GdkPoint *points, gint npoints, - gint fill); + gboolean fill); void gtk_paint_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -607,7 +590,7 @@ void gtk_paint_arrow (GtkStyle *style, GtkWidget *widget, gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -721,46 +704,46 @@ void gtk_paint_tab (GtkStyle *style, gint y, gint width, gint height); -void gtk_paint_shadow_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); -void gtk_paint_box_gap (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side, - gint gap_x, - gint gap_width); -void gtk_paint_extension (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height, - gint gap_side); +void gtk_paint_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_paint_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_paint_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); void gtk_paint_focus (GtkStyle *style, GdkWindow *window, GdkRectangle *area, @@ -782,16 +765,6 @@ void gtk_paint_slider (GtkStyle *style, gint width, gint height, GtkOrientation orientation); -void gtk_paint_entry (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GdkRectangle *area, - GtkWidget *widget, - gchar *detail, - gint x, - gint y, - gint width, - gint height); void gtk_paint_handle (GtkStyle *style, GdkWindow *window, GtkStateType state_type, diff --git a/gtk/gtktearoffmenuitem.c b/gtk/gtktearoffmenuitem.c index d34a3a7c41..fb76f1010b 100644 --- a/gtk/gtktearoffmenuitem.c +++ b/gtk/gtktearoffmenuitem.c @@ -141,12 +141,12 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget, right_max = x + width; if (widget->state == GTK_STATE_PRELIGHT) - gtk_paint_box (widget->style, - widget->window, - GTK_STATE_PRELIGHT, - GTK_SHADOW_OUT, - area, widget, "menuitem", - x, y, width, height); + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_PRELIGHT, + GTK_SHADOW_OUT, + area, widget, "menuitem", + x, y, width, height); else gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); diff --git a/gtk/gtkthemes.c b/gtk/gtkthemes.c index 29d6ac23b9..d2482a0af9 100644 --- a/gtk/gtkthemes.c +++ b/gtk/gtkthemes.c @@ -52,7 +52,7 @@ gtk_theme_engine_get (gchar *name) if (!engine_hash) engine_hash = g_hash_table_new (g_str_hash, g_str_equal); - + /* get the library name for the theme */ result = g_hash_table_lookup (engine_hash, name); @@ -100,11 +100,13 @@ gtk_theme_engine_get (gchar *name) /* setup anything it needs to set up. */ result->init((GtkThemeEngine *)result); - g_hash_table_insert (engine_hash, name, result); + g_hash_table_insert (engine_hash, result->name, result); } } - - return (GtkThemeEngine *)result; + else + result->refcount++; + + return (GtkThemeEngine *)result; } void @@ -127,7 +129,7 @@ gtk_theme_engine_unref (GtkThemeEngine *engine) if (private->refcount == 0) { - g_hash_table_remove (engine_hash, private); + g_hash_table_remove (engine_hash, private->name); g_module_close (private->library); g_free (private->name); diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index b87ecb0a3e..cd8e6e04e2 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -52,12 +52,12 @@ static void gtk_toggle_button_set_arg (GtkObject *object, static void gtk_toggle_button_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void gtk_toggle_button_leave (GtkButton *button); -static void gtk_toggle_button_realize (GtkWidget *widget); -static void gtk_toggle_button_unrealize (GtkWidget *widget); +static void gtk_toggle_button_leave (GtkButton *button); +static void gtk_toggle_button_realize (GtkWidget *widget); +static void gtk_toggle_button_unrealize (GtkWidget *widget); static guint toggle_button_signals[LAST_SIGNAL] = { 0 }; - +static GtkContainerClass *parent_class = NULL; GtkType gtk_toggle_button_get_type (void) @@ -97,6 +97,8 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class) container_class = (GtkContainerClass*) class; button_class = (GtkButtonClass*) class; + parent_class = gtk_type_class (GTK_TYPE_BUTTON); + gtk_object_add_arg_type ("GtkToggleButton::active", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ACTIVE); gtk_object_add_arg_type ("GtkToggleButton::draw_indicator", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_INDICATOR); @@ -214,19 +216,10 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button, { if (GTK_WIDGET_REALIZED(toggle_button)) { - if (GTK_WIDGET_VISIBLE (toggle_button)) - { - gtk_widget_unrealize(GTK_WIDGET(toggle_button)); - toggle_button->draw_indicator = draw_indicator; - gtk_widget_realize(GTK_WIDGET(toggle_button)); - gtk_widget_show(GTK_WIDGET(toggle_button)); - } - else - { - gtk_widget_unrealize(GTK_WIDGET(toggle_button)); - toggle_button->draw_indicator = draw_indicator; - gtk_widget_realize(GTK_WIDGET(toggle_button)); - } + gtk_widget_unrealize(GTK_WIDGET(toggle_button)); + toggle_button->draw_indicator = draw_indicator; + gtk_widget_realize(GTK_WIDGET(toggle_button)); + gtk_widget_show(GTK_WIDGET(toggle_button)); } else toggle_button->draw_indicator = draw_indicator; @@ -508,31 +501,17 @@ gtk_toggle_button_unrealize (GtkWidget *widget) GtkToggleButton *toggle_button; g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget)); toggle_button = GTK_TOGGLE_BUTTON (widget); - GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED); - gtk_style_detach (widget->style); - if (toggle_button->draw_indicator) { gdk_window_set_user_data (toggle_button->event_window, NULL); gdk_window_destroy (toggle_button->event_window); - gdk_window_unref (widget->window); + toggle_button->event_window = NULL; } - else - { - gdk_window_set_user_data (widget->window, NULL); - gdk_window_destroy (widget->window); - } - widget->window = NULL; - toggle_button->event_window = NULL; - /* Unrealize afterwards to improve visual effect */ - - if (GTK_IS_CONTAINER (widget)) - gtk_container_foreach (GTK_CONTAINER (widget), - (GtkCallback) gtk_widget_unrealize, - NULL); + if (GTK_WIDGET_CLASS (parent_class)->unrealize) + (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); } diff --git a/gtk/gtktooltips.c b/gtk/gtktooltips.c index 9a4d769b7c..74cdcbc92b 100644 --- a/gtk/gtktooltips.c +++ b/gtk/gtktooltips.c @@ -20,10 +20,9 @@ #include <string.h> #include <stdio.h> -#include "gtkdrawingarea.h" #include "gtkmain.h" #include "gtkwidget.h" -#include "gtkwindow.h" +#include "gtkdrawwindow.h" #include "gtksignal.h" #include "gtkstyle.h" #include "gtktooltips.h" @@ -170,22 +169,17 @@ gtk_tooltips_destroy (GtkObject *object) void gtk_tooltips_force_window (GtkTooltips *tooltips) { - GtkWidget *darea; - g_return_if_fail (tooltips != NULL); g_return_if_fail (GTK_IS_TOOLTIPS (tooltips)); if (!tooltips->tip_window) { - tooltips->tip_window = gtk_window_new (GTK_WINDOW_POPUP); + tooltips->tip_window = gtk_draw_window_new (GTK_WINDOW_POPUP); gtk_widget_ref (tooltips->tip_window); gtk_window_set_policy (GTK_WINDOW (tooltips->tip_window), FALSE, FALSE, TRUE); - darea = gtk_drawing_area_new (); - gtk_container_add (GTK_CONTAINER (tooltips->tip_window), darea); - gtk_widget_show (darea); - - gtk_signal_connect_object (GTK_OBJECT (darea), "expose_event", + gtk_signal_connect_object (GTK_OBJECT (tooltips->tip_window), + "expose_event", GTK_SIGNAL_FUNC (gtk_tooltips_expose), GTK_OBJECT (tooltips)); @@ -396,14 +390,12 @@ gtk_tooltips_set_colors (GtkTooltips *tooltips, static gint gtk_tooltips_expose (GtkTooltips *tooltips, GdkEventExpose *event) { - GtkWidget *darea; GtkStyle *style; gint y, baseline_skip, gap; GtkTooltipsData *data; GList *el; - darea = GTK_BIN (tooltips->tip_window)->child; - style = darea->style; + style = tooltips->tip_window->style; gap = (style->font->ascent + style->font->descent) / 4; if (gap < 2) @@ -414,9 +406,9 @@ gtk_tooltips_expose (GtkTooltips *tooltips, GdkEventExpose *event) if (!data) return FALSE; - gtk_paint_flat_box(style, darea->window, + gtk_paint_flat_box(style, tooltips->tip_window->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - NULL, GTK_WIDGET(darea), "tooltip", + NULL, GTK_WIDGET(tooltips->tip_window), "tooltip", 0, 0, -1, -1); y = style->font->ascent + 4; @@ -425,11 +417,9 @@ gtk_tooltips_expose (GtkTooltips *tooltips, GdkEventExpose *event) { if (el->data) { - /* gdk_draw_string (tooltips->tip_window->window, style->font, - tooltips->gc, 4, y, el->data);*/ - gtk_paint_string (style, darea->window, + gtk_paint_string (style, tooltips->tip_window->window, GTK_STATE_NORMAL, - NULL, GTK_WIDGET(darea), "tooltip", + NULL, GTK_WIDGET(tooltips->tip_window), "tooltip", 4, y, el->data); y += baseline_skip; } @@ -443,7 +433,7 @@ gtk_tooltips_expose (GtkTooltips *tooltips, GdkEventExpose *event) static void gtk_tooltips_draw_tips (GtkTooltips * tooltips) { - GtkWidget *widget, *darea; + GtkWidget *widget; GtkStyle *style; gint gap, x, y, w, h, scr_w, scr_h, baseline_skip; GtkTooltipsData *data; @@ -454,8 +444,7 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips) else if (GTK_WIDGET_VISIBLE (tooltips->tip_window)) gtk_widget_hide (tooltips->tip_window); - darea = GTK_BIN (tooltips->tip_window)->child; - style = darea->style; + style = tooltips->tip_window->style; widget = tooltips->active_tips_data->widget; @@ -498,40 +487,6 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips) gtk_widget_set_usize (tooltips->tip_window, w, h); gtk_widget_popup (tooltips->tip_window, x, y); - -/* - if (tooltips->gc == NULL) - tooltips->gc = gdk_gc_new (tooltips->tip_window->window); - - if (tooltips->background != NULL) - { - gdk_gc_set_foreground (tooltips->gc, tooltips->background); - gdk_gc_set_background (tooltips->gc, tooltips->foreground); - } - else - { - gdk_gc_set_foreground (tooltips->gc, &style->bg[GTK_STATE_NORMAL]); - gdk_gc_set_background (tooltips->gc, &style->fg[GTK_STATE_NORMAL]); - } - - gdk_gc_set_font (tooltips->gc, style->font); - gdk_draw_rectangle (tooltips->tip_window->window, tooltips->gc, TRUE, 0, 0, w, h); - - if (tooltips->foreground != NULL) - { - gdk_gc_set_foreground (tooltips->gc, tooltips->foreground); - gdk_gc_set_background (tooltips->gc, tooltips->background); - } - else - { - gdk_gc_set_foreground (tooltips->gc, &style->fg[GTK_STATE_NORMAL]); - gdk_gc_set_background (tooltips->gc, &style->bg[GTK_STATE_NORMAL]); - } - - gdk_draw_rectangle (tooltips->tip_window->window, tooltips->gc, FALSE, 0, 0, w, h); -*/ - - } static gint diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c index 7902e7d133..a4f57e3d5f 100644 --- a/gtk/gtktreeitem.c +++ b/gtk/gtktreeitem.c @@ -648,7 +648,7 @@ gtk_tree_item_draw (GtkWidget *widget, GTK_TREE (widget->parent)->current_indent + 2); item_area.height = widget->allocation.height; - if(gdk_rectangle_intersect(&item_area, area, &child_area)) + if (gdk_rectangle_intersect(&item_area, area, &child_area)) { if (widget->state == GTK_STATE_NORMAL) { @@ -668,18 +668,7 @@ gtk_tree_item_draw (GtkWidget *widget, area, widget, "treeitem", 0, 0, -1, -1); } -/* - else if(GTK_TREE(widget->parent)->view_mode == GTK_TREE_VIEW_LINE && - widget->state == GTK_STATE_SELECTED) - gtk_style_set_background (widget->style, widget->window, widget->state); - else - gdk_window_set_background (widget->window, - &widget->style->base[GTK_STATE_NORMAL]); - - gdk_window_clear_area (widget->window, - child_area.x, child_area.y, - child_area.width, child_area.height); -*/ + gtk_tree_item_draw_lines(widget); if (tree_item->pixmaps_box && @@ -689,26 +678,13 @@ gtk_tree_item_draw (GtkWidget *widget, } /* draw right side */ - if(gtk_widget_intersect (bin->child, area, &child_area)) + if (gtk_widget_intersect (bin->child, area, &child_area)) { -/* - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gtk_style_set_background (widget->style, widget->window, - GTK_STATE_INSENSITIVE); - else if (widget->state == GTK_STATE_NORMAL) - gdk_window_set_background(widget->window, &widget->style->base[GTK_STATE_NORMAL]); - else - gtk_style_set_background (widget->style, widget->window, widget->state); - - gdk_window_clear_area (widget->window, child_area.x, child_area.y, - child_area.width+1, child_area.height); -*/ - if (bin->child && GTK_WIDGET_VISIBLE(bin->child) && gtk_widget_intersect (bin->child, area, &child_area)) gtk_widget_draw (bin->child, &child_area); - } + } if (GTK_WIDGET_HAS_FOCUS (widget)) gtk_paint_focus (widget->style, widget->window, @@ -842,7 +818,7 @@ gtk_real_tree_item_toggle (GtkItem *item) { /* Should we really bother with this bit? A listitem not in a list? * -Johannes Keukelaar - * yes, always be on the save side! + * yes, always be on the safe side! * -timj */ if (GTK_WIDGET (item)->state == GTK_STATE_SELECTED) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 96810975db..41a501fa1d 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -201,8 +201,8 @@ static guint saved_default_style_key_id = 0; static const gchar *shape_info_key = "gtk-shape-info"; static const gchar *colormap_key = "gtk-colormap"; static const gchar *visual_key = "gtk-visual"; - - +static const gchar *rc_style_key = "gtk-rc-style"; +static guint rc_style_key_id = 0; /***************************************** * gtk_widget_get_type: @@ -3047,6 +3047,7 @@ gtk_widget_set_parent (GtkWidget *widget, GtkStateData data; g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (widget->parent == NULL); g_return_if_fail (!GTK_WIDGET_TOPLEVEL (widget)); g_return_if_fail (parent != NULL); @@ -3109,6 +3110,9 @@ gtk_widget_set_style (GtkWidget *widget, void gtk_widget_ensure_style (GtkWidget *widget) { + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + if (!GTK_WIDGET_USER_STYLE (widget) && !GTK_WIDGET_RC_STYLE (widget)) gtk_widget_set_rc_style (widget); @@ -3188,6 +3192,24 @@ gtk_widget_get_style (GtkWidget *widget) return widget->style; } +void +gtk_widget_modify_style (GtkWidget *widget, + GtkRcStyle *style) +{ + GtkRcStyle *old_style; + + if (!rc_style_key_id) + rc_style_key_id = g_quark_from_static_string (rc_style_key); + + old_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), rc_style_key_id); + + if (style != old_style) + gtk_object_set_data_by_id_full (GTK_OBJECT (widget), + rc_style_key_id, + style, + (GtkDestroyNotify)gtk_rc_style_unref); +} + static void gtk_widget_style_set (GtkWidget *widget, GtkStyle *previous_style) @@ -3974,7 +3996,6 @@ gtk_widget_get_default_visual (void) return default_visual; } - static void gtk_widget_shutdown (GtkObject *object) { diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 0a12e1f7b7..24bbda0be4 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -99,10 +99,6 @@ typedef enum typedef struct _GtkRequisition GtkRequisition; typedef struct _GtkAllocation GtkAllocation; typedef struct _GtkSelectionData GtkSelectionData; -#ifndef __TYPEDEFED_GTK_WIDGET__ -typedef struct _GtkWidget GtkWidget; -#define __TYPEDEFED_GTK_WIDGET__ -#endif typedef struct _GtkWidgetClass GtkWidgetClass; typedef struct _GtkWidgetAuxInfo GtkWidgetAuxInfo; typedef struct _GtkWidgetShapeInfo GtkWidgetShapeInfo; @@ -537,6 +533,9 @@ void gtk_widget_ensure_style (GtkWidget *widget); GtkStyle* gtk_widget_get_style (GtkWidget *widget); void gtk_widget_restore_default_style (GtkWidget *widget); +void gtk_widget_modify_style (GtkWidget *widget, + GtkRcStyle *style); + /* Descend recursively and set rc-style on all widgets without user styles */ void gtk_widget_reset_rc_styles (GtkWidget *widget); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 4d608b3cf0..97ec38c05c 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -624,7 +624,7 @@ gtk_window_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gtk_window_draw(widget, NULL); + gtk_window_paint (widget, NULL); } static void @@ -1156,7 +1156,7 @@ gtk_window_move_resize (GtkWindow *window) (height < widget->requisition.height)))) { window->resize_count += 1; - if ((x != -1) && (y != -1) && (window->position != GTK_WIN_POS_NONE)) + if ((x != -1) && (y != -1)) gdk_window_move_resize (widget->window, x, y, widget->requisition.width, widget->requisition.height); @@ -1171,21 +1171,21 @@ gtk_window_move_resize (GtkWindow *window) * visible, so reallocate everything, since we didn't * keep track of what changed */ - GtkAllocation allocation; - - allocation.x = 0; - allocation.y = 0; - allocation.width = widget->requisition.width; - allocation.height = widget->requisition.height; - - gtk_widget_size_allocate (widget, &allocation); + GtkAllocation allocation; + + allocation.x = 0; + allocation.y = 0; + allocation.width = widget->requisition.width; + allocation.height = widget->requisition.height; + + gtk_widget_size_allocate (widget, &allocation); } else { - if ((x != -1) && (y != -1)) - gdk_window_move (widget->window, x, y); - - gtk_container_resize_children (GTK_CONTAINER (window)); + if ((x != -1) && (y != -1)) + gdk_window_move (widget->window, x, y); + + gtk_container_resize_children (GTK_CONTAINER (window)); } } diff --git a/gtk/testdnd.c b/gtk/testdnd.c index f46c6a3f6a..26c38f3d23 100644 --- a/gtk/testdnd.c +++ b/gtk/testdnd.c @@ -343,6 +343,7 @@ target_drag_data_received (GtkWidget *widget, { if ((data->length >= 0) && (data->format == 8)) { + g_print ("Received %s\n", (gchar *)data->data); gtk_drag_finish (context, TRUE, FALSE, time); return; } diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 1aafdbc2c2..e16ee72b65 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -1867,10 +1867,7 @@ create_pixmap (void) button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0); - style = gtk_widget_get_style(button); - - pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, - &style->bg[GTK_STATE_NORMAL], + pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, NULL, "test.xpm"); pixmapwid = gtk_pixmap_new (pixmap, mask); gdk_pixmap_unref (pixmap); diff --git a/gtk/testgtkrc b/gtk/testgtkrc index 6ae6080d86..6a3f890649 100644 --- a/gtk/testgtkrc +++ b/gtk/testgtkrc @@ -11,6 +11,13 @@ # widget_class <widget_class_set> style <style_name> #include "/opt/themes/share/themes/Motif/gtk/gtkrc" +#include "/home/otaylor/.themes/Ignorant/gtk/gtkrc" + +#style "defaultfont" { +# fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*" +#} +# +#class "GtkWidget" style "defaultfont" binding "test1" { diff --git a/tests/testdnd.c b/tests/testdnd.c index f46c6a3f6a..26c38f3d23 100644 --- a/tests/testdnd.c +++ b/tests/testdnd.c @@ -343,6 +343,7 @@ target_drag_data_received (GtkWidget *widget, { if ((data->length >= 0) && (data->format == 8)) { + g_print ("Received %s\n", (gchar *)data->data); gtk_drag_finish (context, TRUE, FALSE, time); return; } diff --git a/tests/testgtk.c b/tests/testgtk.c index 1aafdbc2c2..e16ee72b65 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -1867,10 +1867,7 @@ create_pixmap (void) button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0); - style = gtk_widget_get_style(button); - - pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, - &style->bg[GTK_STATE_NORMAL], + pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, NULL, "test.xpm"); pixmapwid = gtk_pixmap_new (pixmap, mask); gdk_pixmap_unref (pixmap); diff --git a/tests/testgtkrc b/tests/testgtkrc index 6ae6080d86..6a3f890649 100644 --- a/tests/testgtkrc +++ b/tests/testgtkrc @@ -11,6 +11,13 @@ # widget_class <widget_class_set> style <style_name> #include "/opt/themes/share/themes/Motif/gtk/gtkrc" +#include "/home/otaylor/.themes/Ignorant/gtk/gtkrc" + +#style "defaultfont" { +# fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*" +#} +# +#class "GtkWidget" style "defaultfont" binding "test1" { |