From 0bee26c7bac6928f05f6d928407e03f5bddbddff Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 29 Jun 2001 01:59:02 +0000 Subject: [PATCH] Clip the retrieved image data to the screen, using a server grab to avoid 2001-06-28 Havoc Pennington * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved image data to the screen, using a server grab to avoid race conditions. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove check for NULL return from gtk_image_new_from_stock(), it never returns NULL. (gtk_item_factory_create_item): fix bug where we parsed the stock ID as an inline pixbuf * gtk/gtktext.c (gtk_text_key_press): numeric keypad support * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad support (should be using binding set here) * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad support (should be using binding set here) * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad support * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad * gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress): keypad * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, should be binding-setted) * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes * gtk/gtkcalendar.c: numeric keypad fixes * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad support * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop screwup * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): clip the render area to the drawable's clip region in advance, so we don't get data from the server that we don't need. * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): check return value of gdk_pixbuf_get_from_drawable(), fall back to bilevel alpha if we can't get the pixbuf to composite against. * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap * gdk/gdkimage.c (gdk_image_get_colormap): add gdk_image_set_colormap, gdk_image_get_colormap * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to take a region of the image, instead of converting the entire image. * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help keybinding signal. Add default bindings for it. Add default handler for show_help that shows the tooltip for the widget. * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and "close" keybinding signal, remove key press handler. * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, it's not our usual practice to leave a deprecated function around with a runtime warning, plus we don't want it to appear in docs, plus if we make them yellow no one will want to change them anyhow. --- ChangeLog | 83 +++ ChangeLog.pre-2-0 | 83 +++ ChangeLog.pre-2-10 | 83 +++ ChangeLog.pre-2-2 | 83 +++ ChangeLog.pre-2-4 | 83 +++ ChangeLog.pre-2-6 | 83 +++ ChangeLog.pre-2-8 | 83 +++ contrib/gdk-pixbuf-xlib/ChangeLog | 4 + contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.c | 20 +- docs/Changes-2.0.txt | 8 + docs/reference/ChangeLog | 8 + .../reference/gdk-pixbuf/tmpl/gdk-pixbuf.sgml | 22 +- .../tmpl/initialization_versions.sgml | 20 +- docs/reference/gdk/tmpl/images.sgml | 1 + docs/reference/gtk/tmpl/gtkdialog.sgml | 7 + docs/reference/gtk/tmpl/gtkrc.sgml | 1 - docs/reference/gtk/tmpl/gtktooltips.sgml | 11 - docs/reference/gtk/tmpl/gtkwidget.sgml | 16 + gdk-pixbuf/ChangeLog | 7 + gdk-pixbuf/gdk-pixbuf-io.c | 2 +- gdk-pixbuf/gdk-pixdata.c | 1 + gdk/gdkdraw.c | 10 + gdk/gdkimage.c | 63 ++ gdk/gdkimage.h | 7 + gdk/gdkpixbuf-drawable.c | 556 ++++++++++++------ gdk/gdkpixbuf-render.c | 91 ++- gdk/gdkpixbuf.h | 10 + gdk/gdkwindow.c | 2 + gdk/x11/gdkdnd-x11.c | 2 +- gdk/x11/gdkimage-x11.c | 78 ++- gdk/x11/gdkwindow-x11.c | 5 +- gdk/x11/gdkx.h | 3 + gtk/gtkcalendar.c | 5 + gtk/gtkclist.c | 81 ++- gtk/gtkcolorsel.c | 5 +- gtk/gtkcombo.c | 5 +- gtk/gtkctree.c | 46 +- gtk/gtkdialog.c | 74 ++- gtk/gtkdialog.h | 4 + gtk/gtkentry.c | 11 +- gtk/gtkfilesel.c | 4 +- gtk/gtkimcontextsimple.c | 4 +- gtk/gtkitemfactory.c | 4 +- gtk/gtklistitem.c | 80 ++- gtk/gtkmarshal.list | 1 + gtk/gtkmarshalers.list | 1 + gtk/gtkmenu.c | 20 + gtk/gtkmenubar.c | 22 +- gtk/gtkmenushell.c | 10 + gtk/gtknotebook.c | 5 + gtk/gtkoptionmenu.c | 1 + gtk/gtkspinbutton.c | 173 +++--- gtk/gtktext.c | 11 +- gtk/gtktextview.c | 65 +- gtk/gtktooltips.c | 33 +- gtk/gtktooltips.h | 5 +- gtk/gtkwidget.c | 50 +- gtk/gtkwidget.h | 16 +- gtk/gtkwindow.c | 10 +- 59 files changed, 1874 insertions(+), 408 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 6bc8ba57ac..d6ec1bb28e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,86 @@ +2001-06-28 Havoc Pennington + + * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved + image data to the screen, using a server grab to avoid race + conditions. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove + check for NULL return from gtk_image_new_from_stock(), it never + returns NULL. + (gtk_item_factory_create_item): fix bug where we parsed the stock + ID as an inline pixbuf + + * gtk/gtktext.c (gtk_text_key_press): numeric keypad support + + * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad + support (should be using binding set here) + + * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad + support + + * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support + + * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad + + * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad + + * gtk/gtkimcontextsimple.c + (gtk_im_context_simple_filter_keypress): keypad + + * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad + + * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes + + * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support + + * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, + should be binding-setted) + + * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes + + * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes + + * gtk/gtkcalendar.c: numeric keypad fixes + + * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad + support + + * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop + screwup + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + clip the render area to the drawable's clip region in advance, + so we don't get data from the server that we don't need. + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + check return value of gdk_pixbuf_get_from_drawable(), fall back + to bilevel alpha if we can't get the pixbuf to composite against. + + * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap + + * gdk/gdkimage.c (gdk_image_get_colormap): add + gdk_image_set_colormap, gdk_image_get_colormap + + * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to + take a region of the image, instead of converting the entire + image. + + * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help + keybinding signal. Add default bindings for it. Add default + handler for show_help that shows the tooltip for the widget. + + * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and + "close" keybinding signal, remove key press handler. + + * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, + it's not our usual practice to leave a deprecated function around + with a runtime warning, plus we don't want it to appear in docs, + plus if we make them yellow no one will want to change them + anyhow. + Thu Jun 28 23:53:31 2001 Tim Janik * gtk/gtkwidget.c (gtk_widget_hide): !GTK_OBJECT_DESTROYED() -> diff --git a/contrib/gdk-pixbuf-xlib/ChangeLog b/contrib/gdk-pixbuf-xlib/ChangeLog index c6cc55fd58..55f0f50c1f 100644 --- a/contrib/gdk-pixbuf-xlib/ChangeLog +++ b/contrib/gdk-pixbuf-xlib/ChangeLog @@ -1,3 +1,7 @@ +2001-05-19 Havoc Pennington + + * gdk-pixbuf-xlibrgb.c: docs + 2001-06-04 Havoc Pennington * gdk-pixbuf-xlibrgb.c (xlib_rgb_init): remove C++ comment, diff --git a/contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.c b/contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.c index da70d703b2..1bf8655148 100644 --- a/contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.c +++ b/contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.c @@ -460,18 +460,36 @@ xlib_rgb_colorcube_222 (void) } } +/** + * xlib_rgb_set_verbose: + * @verbose: %True to be verbose + * + * Enables/disables debug spew. + **/ void xlib_rgb_set_verbose (Bool verbose) { xlib_rgb_verbose = verbose; } +/** + * xlib_rgb_set_install: + * @install: %True to install a colormap + * + * Sets whether we install an RGB colormap. + **/ void xlib_rgb_set_install (Bool install) { xlib_rgb_install_cmap = install; } +/** + * xlib_rgb_set_min_colors: + * @min_colors: minimum colors to use + * + * Sets the minimum number of colors in the color cube. + **/ void xlib_rgb_set_min_colors (int min_colors) { @@ -1020,7 +1038,7 @@ xlib_rgb_gc_set_foreground (GC gc, guint32 rgb) } /** - * xlib_rgb_gc_set_foreground: + * xlib_rgb_gc_set_background: * @gc: A graphic context. * @rgb: 32-bit representation of an RGB value, specified as 0x00RRGGBB. * diff --git a/docs/Changes-2.0.txt b/docs/Changes-2.0.txt index d643b27523..4c6a49b124 100644 --- a/docs/Changes-2.0.txt +++ b/docs/Changes-2.0.txt @@ -383,3 +383,11 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0: gtk_container_child_setv => gtk_container_child_get_property gtk_container_add_with_args => gtk_container_add_with_properties gtk_container_addv => gtk_container_add / gtk_container_child_set_property + +* gdk_image_get() (or rather its replacement, + gdk_drawable_get_image()) now handles errors properly by returning + NULL, previously it would crash. Also, a window being offscreen is + no longer considered an error; instead, the area being contains + undefined contents for the offscreen areas. In most cases, code + using gdk_image_get() should really be ported to + gdk_pixbuf_get_from_drawable(). diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 0c99021064..2e6280e002 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,11 @@ +2001-05-19 Havoc Pennington + + * gdk-pixbuf/tmpl/initialization_versions.sgml: docs + + * gdk-pixbuf/tmpl/gdk-pixbuf.sgml: docs + + * gdk-pixbuf/tmpl/gdk-pixbuf-xlib-init.sgml: docs + Sun Apr 15 15:04:12 2001 Owen Taylor * gtk/tmpl/gtkdnd.sgml: Move some of the function docs to the diff --git a/docs/reference/gdk-pixbuf/tmpl/gdk-pixbuf.sgml b/docs/reference/gdk-pixbuf/tmpl/gdk-pixbuf.sgml index ecc32bc201..d7d5532f2f 100644 --- a/docs/reference/gdk-pixbuf/tmpl/gdk-pixbuf.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/gdk-pixbuf.sgml @@ -17,22 +17,28 @@ Information that describes an image. - +An error code in the #GDK_PIXBUF_ERROR domain. Many &gdk-pixbuf; +operations can cause errors in this domain, or in the #G_FILE_ERROR +domain. @GDK_PIXBUF_ERROR_HEADER_CORRUPT: @GDK_PIXBUF_ERROR_PIXEL_CORRUPT: @GDK_PIXBUF_ERROR_UNKNOWN_FORMAT: -@GDK_PIXBUF_ERROR_CORRUPT_IMAGE: -@GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY: -@GDK_PIXBUF_ERROR_BAD_OPTION_VALUE: -@GDK_PIXBUF_ERROR_UNKNOWN_TYPE: -@GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION: -@GDK_PIXBUF_ERROR_FAILED: +@GDK_PIXBUF_ERROR_CORRUPT_IMAGE: An image file was broken somehow. +@GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY: Not enough memory. +@GDK_PIXBUF_ERROR_BAD_OPTION_VALUE: An option passed to +gdk_pixbuf_save() had a bad value. +@GDK_PIXBUF_ERROR_UNKNOWN_TYPE: Unknown image type. +@GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION: Don't know how to perform the +given operation on the type of image at hand. +@GDK_PIXBUF_ERROR_FAILED: Generic failure code, something went wrong. - +Error domain used for pixbuf operations. Indicates that the error code +will be in the #GdkPixbufError enumeration. See #GError for +information on error domains and error codes. diff --git a/docs/reference/gdk-pixbuf/tmpl/initialization_versions.sgml b/docs/reference/gdk-pixbuf/tmpl/initialization_versions.sgml index b5eef8ccb9..3c0f879aee 100644 --- a/docs/reference/gdk-pixbuf/tmpl/initialization_versions.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/initialization_versions.sgml @@ -3,10 +3,12 @@ Initialization and Versions +Library version numbers. - +These macros and variables let you check the version of &gdk-pixbuf; +you're linking against. @@ -16,34 +18,40 @@ Initialization and Versions - +Contains the full version of the &gdk-pixbuf; library as a string. +This is the version currently in use by a running program. - +Contains the full version of the &gdk-pixbuf; header as a string. +This is the version being compiled against; contrast with +#gdk_pixbuf_version. - +Major version of &gdk-pixbuf; library, that is the first "0" in +"0.8.0" for example. - +Minor version of &gdk-pixbuf; library, that is the "8" in +"0.8.0" for example. - +Micro version of &gdk-pixbuf; library, that is the last "0" in +"0.8.0" for example. diff --git a/docs/reference/gdk/tmpl/images.sgml b/docs/reference/gdk/tmpl/images.sgml index d74af57c82..4729f04caa 100644 --- a/docs/reference/gdk/tmpl/images.sgml +++ b/docs/reference/gdk/tmpl/images.sgml @@ -71,6 +71,7 @@ The #GdkImage struct contains information on the image and the pixel data. @bpl: the number of bytes per line of the image. @bits_per_pixel: @mem: the pixel data. +@colormap: @windowing_data: diff --git a/docs/reference/gtk/tmpl/gtkdialog.sgml b/docs/reference/gtk/tmpl/gtkdialog.sgml index 9a38b69f3d..ccc6a3105b 100644 --- a/docs/reference/gtk/tmpl/gtkdialog.sgml +++ b/docs/reference/gtk/tmpl/gtkdialog.sgml @@ -273,6 +273,13 @@ directly, but into the vbox and action_area, as described above. @setting: + + + + + +@dialog: the object which received the signal. + Emitted when an action widget is clicked, the dialog receives a delete event, or diff --git a/docs/reference/gtk/tmpl/gtkrc.sgml b/docs/reference/gtk/tmpl/gtkrc.sgml index 82694173c4..5f8876c8fe 100644 --- a/docs/reference/gtk/tmpl/gtkrc.sgml +++ b/docs/reference/gtk/tmpl/gtkrc.sgml @@ -495,7 +495,6 @@ This can later be composited together with other #GtkRcStyle structures to form a #GtkStyle. -@parent_instance: @name: @bg_pixmap_name: @font_desc: diff --git a/docs/reference/gtk/tmpl/gtktooltips.sgml b/docs/reference/gtk/tmpl/gtktooltips.sgml index 597de4d2f6..01b8b97b79 100644 --- a/docs/reference/gtk/tmpl/gtktooltips.sgml +++ b/docs/reference/gtk/tmpl/gtktooltips.sgml @@ -143,17 +143,6 @@ Adds a tooltip containing the message @tip_text to the specified #GtkWidget. @tip_private: a string of any further information that may be useful if the user gets stuck. - - -This function is unimplemented because tooltip colors are instead -determined by the theme. - - -@tooltips: a #GtkTooltip -@background: a #GdkColor that your tooltip text will be shown in. -@foreground: a #GdkColor that your tooltip backgrounds will be shown in. - - Retrieves any #GtkTooltipsData previously associated with the given widget. diff --git a/docs/reference/gtk/tmpl/gtkwidget.sgml b/docs/reference/gtk/tmpl/gtkwidget.sgml index ab9a355599..3160d91fb9 100644 --- a/docs/reference/gtk/tmpl/gtkwidget.sgml +++ b/docs/reference/gtk/tmpl/gtkwidget.sgml @@ -1529,6 +1529,14 @@ GtkWidget @event: @Returns: + + + + + +@widget: the object which received the signal. +@event: + @@ -1789,6 +1797,14 @@ a widget changes from un-anchored to anchored or vice-versa. @widget: the object which received the signal. + + + + + +@widget: the object which received the signal. +@arg1: + diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 992773220d..0273e7ed91 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,10 @@ +2001-06-28 Havoc Pennington + + * gdk-pixdata.c: + + * gdk-pixbuf-io.c (get_libdir): fix typo in dll name (aren't we + also leaking memory here from g_strdup_printf?) + Tue Jun 26 09:48:02 2001 Tim Janik * Makefile.am (noinst_PROGRAMS): get rid of make-inline-pixbuf diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 8055153edb..2ffed40659 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -239,7 +239,7 @@ get_libdir (void) if (libdir == NULL) libdir = g_win32_get_package_installation_subdirectory (GETTEXT_PACKAGE, - g_strdup_printf ("gdk_pixbug-%d.%d.dll", + g_strdup_printf ("gdk_pixbuf-%d.%d.dll", GDK_PIXBUF_MAJOR, GDK_PIXBUF_MINOR), "loaders"); diff --git a/gdk-pixbuf/gdk-pixdata.c b/gdk-pixbuf/gdk-pixdata.c index bc1b6a6466..152a2de106 100644 --- a/gdk-pixbuf/gdk-pixdata.c +++ b/gdk-pixbuf/gdk-pixdata.c @@ -20,6 +20,7 @@ #include "gdk-pixbuf-private.h" #include "gdk-pixbuf-i18n.h" +#include /* --- functions --- */ diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index 4946596121..d05bb1b7f4 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -597,6 +597,10 @@ gdk_draw_glyphs (GdkDrawable *drawable, * If the X server or other windowing system backend is on the local * machine, this function may use shared memory to avoid copying * the image data. + * + * If the source drawable is a #GdkWindow and partially offscreen + * or obscured, then the obscured portions of the returned image + * will contain undefined data. * * Return value: a #GdkImage containing the contents of @drawable **/ @@ -611,6 +615,7 @@ gdk_drawable_get_image (GdkDrawable *drawable, gint composite_x_offset = 0; gint composite_y_offset = 0; GdkImage *retval; + GdkColormap *cmap; g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (x >= 0, NULL); @@ -639,6 +644,11 @@ gdk_drawable_get_image (GdkDrawable *drawable, g_object_unref (G_OBJECT (composite)); + cmap = gdk_drawable_get_colormap (drawable); + + if (retval && cmap) + gdk_image_set_colormap (retval, cmap); + return retval; } diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c index 7438c51c6c..2606f48a10 100644 --- a/gdk/gdkimage.c +++ b/gdk/gdkimage.c @@ -44,6 +44,21 @@ gdk_image_unref (GdkImage *image) g_object_unref (G_OBJECT (image)); } +/** + * gdk_image_get: + * @window: a #GdkWindow + * @x: x coordinate in @window + * @y: y coordinate in @window + * @width: width of area in @window + * @height: height of area in @window + * + * This is a deprecated wrapper for gdk_drawable_get_image(); + * gdk_drawable_get_image() should be used instead. Or even better: in + * most cases gdk_pixbuf_get_from_drawable() is the most convenient + * choice. + * + * Return value: a new #GdkImage or %NULL + **/ GdkImage* gdk_image_get (GdkWindow *window, gint x, @@ -59,3 +74,51 @@ gdk_image_get (GdkWindow *window, return gdk_drawable_get_image (window, x, y, width, height); } + +/** + * gdk_image_set_colormap: + * @image: a #GdkImage + * @colormap: a #GdkColormap + * + * Sets the colormap for the image to the given colormap. Normally + * there's no need to use this function, images are created with the + * correct colormap if you get the image from a drawable. If you + * create the image from scratch, use the colormap of the drawable you + * intend to render the image to. + **/ +void +gdk_image_set_colormap (GdkImage *image, + GdkColormap *colormap) +{ + g_return_if_fail (GDK_IS_IMAGE (image)); + g_return_if_fail (GDK_IS_COLORMAP (colormap)); + + if (image->colormap != colormap) + { + if (image->colormap) + g_object_unref (G_OBJECT (image->colormap)); + + image->colormap = colormap; + g_object_ref (G_OBJECT (image->colormap)); + } + +} + +/** + * gdk_image_get_colormap: + * @image: a #GdkImage + * + * Retrieves the colormap for a given image, if it exists. An image + * will have a colormap if the drawable from which it was created has + * a colormap, or if a colormap was set explicitely with + * gdk_image_set_colormap(). + * + * Return value: colormap for the image + **/ +GdkColormap * +gdk_image_get_colormap (GdkImage *image) +{ + g_return_val_if_fail (GDK_IS_IMAGE (image), NULL); + + return image->colormap; +} diff --git a/gdk/gdkimage.h b/gdk/gdkimage.h index c8d74f3d4c..3812db988a 100644 --- a/gdk/gdkimage.h +++ b/gdk/gdkimage.h @@ -49,6 +49,8 @@ struct _GdkImage guint16 bits_per_pixel; /* bits per pixel */ gpointer mem; + GdkColormap *colormap; + gpointer windowing_data; }; @@ -81,6 +83,11 @@ guint32 gdk_image_get_pixel (GdkImage *image, gint x, gint y); +void gdk_image_set_colormap (GdkImage *image, + GdkColormap *colormap); +GdkColormap* gdk_image_get_colormap (GdkImage *image); + + #ifdef GDK_ENABLE_BROKEN GdkImage* gdk_image_new_bitmap (GdkVisual *visual, gpointer data, diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c index 97539a0e5f..ed2a307b1f 100644 --- a/gdk/gdkpixbuf-drawable.c +++ b/gdk/gdkpixbuf-drawable.c @@ -32,6 +32,7 @@ #include "gdkwindow.h" #include "gdkpixbuf.h" #include "gdk-pixbuf-private.h" +#include "gdkinternals.h" #if (G_BYTE_ORDER == G_LITTLE_ENDIAN) #define LITTLE @@ -62,10 +63,13 @@ static void rgb1 (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint8 *s; register guint8 data; @@ -78,16 +82,14 @@ rgb1 (GdkImage *image, /* its probably not worth trying to make this run very fast, who uses * 1 bit displays anymore? */ - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx ++) + for (xx = x1; xx < x2; xx ++) { data = srow[xx >> 3] >> (7 - (xx & 7)) & 1; *o++ = colormap->colors[data].red; @@ -107,10 +109,13 @@ static void rgb1a (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint8 *s; register guint8 data; @@ -123,11 +128,9 @@ rgb1a (GdkImage *image, /* convert upto 8 pixels/time */ /* its probably not worth trying to make this run very fast, who uses * 1 bit displays anymore? */ - width = image->width; - height = image->height; bpl = image->bpl; - for (xx = 0; xx < 2; xx++) + for (xx = x1; xx < 2; xx++) { #ifdef LITTLE remap[xx] = 0xff000000 @@ -142,12 +145,12 @@ rgb1a (GdkImage *image, #endif } - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx ++) + for (xx = x1; xx < x2; xx ++) { data = srow[xx >> 3] >> (7 - (xx & 7)) & 1; *o++ = remap[data]; @@ -165,10 +168,13 @@ static void rgb8 (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint32 mask; register guint32 data; @@ -176,19 +182,17 @@ rgb8 (GdkImage *image, register guint8 *s; register guint8 *o; - width = image->width; - height = image->height; bpl = image->bpl; d (printf ("8 bit, no alpha output\n")); mask = mask_table[image->depth]; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx++) { + for (xx = x1; xx < x2; xx++) { data = *s++ & mask; *o++ = colormap->colors[data].red; *o++ = colormap->colors[data].green; @@ -207,10 +211,13 @@ static void rgb8a (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint32 mask; register guint32 data; @@ -219,15 +226,13 @@ rgb8a (GdkImage *image, register guint32 *o; guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; d (printf ("8 bit, with alpha output\n")); mask = mask_table[image->depth]; - for (xx = 0; xx < colormap->size; xx++) + for (xx = x1; xx < colormap->size; xx++) { #ifdef LITTLE remap[xx] = 0xff000000 @@ -242,11 +247,11 @@ rgb8a (GdkImage *image, #endif } - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = (guint32 *) orow; - for (xx = 0; xx < width; xx ++) + for (xx = x1; xx < x2; xx ++) { data = *s++ & mask; *o++ = remap[data]; @@ -265,10 +270,13 @@ static void rgb565lsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -278,12 +286,10 @@ rgb565lsb (GdkImage *image, #endif register guint16 *o; guint8 *srow = image->mem, *orow = pixels; - - width = image->width; - height = image->height; + bpl = image->bpl; - - for (yy = 0; yy < height; yy++) + + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = (guint32 *) srow; @@ -291,7 +297,32 @@ rgb565lsb (GdkImage *image, s = srow; #endif o = (guint16 *) orow; - for (xx = 1; xx < width; xx += 2) + + /* check for first pixel odd */ + xx = x1; + if (xx & 1) + { + register guint16 data; +#ifdef LITTLE + data = *((short *) s); +#else + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#endif + ((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7); + ((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3); + ((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7); + ((char *) o) += 3; + ++xx; + } + + g_assert (!(xx & 1)); + + /* if x2 is even, then the -1 does nothing to number of + * loop iterations, if x2 is odd then the -1 reduces + * iterations by one + */ + for (; xx < (x2 - 1); xx += 2) { register guint32 data; #ifdef LITTLE @@ -315,7 +346,7 @@ rgb565lsb (GdkImage *image, #endif } /* check for last remaining pixel */ - if (width & 1) + if (x2 & 1) { register guint16 data; #ifdef LITTLE @@ -342,10 +373,13 @@ static void rgb565msb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -356,11 +390,9 @@ rgb565msb (GdkImage *image, register guint16 *o; guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = srow; @@ -368,7 +400,34 @@ rgb565msb (GdkImage *image, s = (guint32 *) srow; #endif o = (guint16 *) orow; - for (xx = 1; xx < width; xx += 2) + + xx = x1; + + /* check for first pixel odd */ + if (xx & 1) + { + register guint16 data; +#ifdef LITTLE + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#else + data = *((short *) s); +#endif + ((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7); + ((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3); + ((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7); + + ((char *) o) += 3; + ++xx; + } + + g_assert (!(xx & 1)); + + /* if x2 is even, then the -1 does nothing to number of + * loop iterations, if x2 is odd then the -1 reduces + * iterations by one + */ + for (; xx < (x2 - 1); xx += 2) { register guint32 data; #ifdef LITTLE @@ -392,7 +451,7 @@ rgb565msb (GdkImage *image, #endif } /* check for last remaining pixel */ - if (width & 1) + if (x2 & 1) { register guint16 data; #ifdef LITTLE @@ -419,10 +478,13 @@ static void rgb565alsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -434,11 +496,9 @@ rgb565alsb (GdkImage *image, guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = (guint16 *) srow; @@ -446,7 +506,7 @@ rgb565alsb (GdkImage *image, s = (guint8 *) srow; #endif o = (guint32 *) orow; - for (xx = 0; xx < width; xx ++) + for (xx = x1; xx < x2; xx ++) { register guint32 data; /* rrrrrggg gggbbbbb -> rrrrrRRR ggggggGG bbbbbBBB aaaaaaaa */ @@ -481,10 +541,13 @@ static void rgb565amsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -496,15 +559,13 @@ rgb565amsb (GdkImage *image, guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = (guint32 *) orow; - for (xx = 0; xx < width; xx ++) + for (xx = x1; xx < x2; xx ++) { register guint32 data; /* rrrrrggg gggbbbbb -> rrrrrRRR gggggg00 bbbbbBBB aaaaaaaa */ @@ -539,10 +600,13 @@ static void rgb555lsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -553,11 +617,9 @@ rgb555lsb (GdkImage *image, register guint16 *o; guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = (guint32 *) srow; @@ -565,7 +627,33 @@ rgb555lsb (GdkImage *image, s = srow; #endif o = (guint16 *) orow; - for (xx = 1; xx < width; xx += 2) + + xx = x1; + + /* check for first odd pixel */ + if (xx & 1) + { + register guint16 data; +#ifdef LITTLE + data = *((short *) s); +#else + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#endif + ((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12; + ((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7; + ((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2; + ((char *) o) += 3; + ++xx; + } + + g_assert (!(xx & 1)); + + /* if x2 is even, then the -1 does nothing to number of + * loop iterations, if x2 is odd then the -1 reduces + * iterations by one + */ + for (; xx < (x2 - 1); xx += 2) { register guint32 data; #ifdef LITTLE @@ -589,7 +677,7 @@ rgb555lsb (GdkImage *image, #endif } /* check for last remaining pixel */ - if (width & 1) + if (x2 & 1) { register guint16 data; #ifdef LITTLE @@ -616,10 +704,13 @@ static void rgb555msb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -630,15 +721,39 @@ rgb555msb (GdkImage *image, register guint16 *o; guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = (guint16 *) orow; - for (xx = 1; xx < width; xx += 2) + + xx = x1; + /* See if first pixel is odd */ + if (xx & 1) + { + register guint16 data; +#ifdef LITTLE + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#else + data = *((short *) s); +#endif + ((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12; + ((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7; + ((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2; + + ((char *) o) += 3; + ++xx; + } + + g_assert (!(xx & 1)); + + /* if x2 is even, then the -1 does nothing to number of + * loop iterations, if x2 is odd then the -1 reduces + * iterations by one + */ + for (; xx < (x2 - 1); xx += 2) { register guint32 data; #ifdef LITTLE @@ -662,7 +777,7 @@ rgb555msb (GdkImage *image, #endif } /* check for last remaining pixel */ - if (width & 1) + if (x2 & 1) { register guint16 data; #ifdef LITTLE @@ -689,10 +804,13 @@ static void rgb555alsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -704,11 +822,9 @@ rgb555alsb (GdkImage *image, guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = (guint16 *) srow; @@ -716,7 +832,7 @@ rgb555alsb (GdkImage *image, s = srow; #endif o = (guint32 *) orow; - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { register guint32 data; /* rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */ @@ -751,10 +867,13 @@ static void rgb555amsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; #ifdef LITTLE @@ -766,11 +885,9 @@ rgb555amsb (GdkImage *image, guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = (guint16 *) srow; @@ -778,7 +895,7 @@ rgb555amsb (GdkImage *image, s = srow; #endif o = (guint32 *) orow; - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { register guint32 data; /* rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */ @@ -809,28 +926,29 @@ static void rgb888alsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint8 *s; /* for byte order swapping */ guint8 *o; guint8 *srow = image->mem, *orow = pixels; - width = image->width; - height = image->height; bpl = image->bpl; d (printf ("32 bits/pixel with alpha\n")); /* lsb data */ - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { *o++ = s[2]; *o++ = s[1]; @@ -847,26 +965,27 @@ static void rgb888lsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint8 *srow = image->mem, *orow = pixels; guint8 *o, *s; - width = image->width; - height = image->height; bpl = image->bpl; d (printf ("32 bit, lsb, no alpha\n")); - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { *o++ = s[2]; *o++ = s[1]; @@ -882,10 +1001,13 @@ static void rgb888amsb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint8 *srow = image->mem, *orow = pixels; @@ -899,12 +1021,10 @@ rgb888amsb (GdkImage *image, d (printf ("32 bit, msb, with alpha\n")); - width = image->width; - height = image->height; bpl = image->bpl; /* msb data */ - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { #ifdef LITTLE s = (guint32 *) srow; @@ -913,7 +1033,7 @@ rgb888amsb (GdkImage *image, s = srow; o = orow; #endif - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { #ifdef LITTLE *o++ = s[1]; @@ -935,10 +1055,13 @@ static void rgb888msb (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *colormap) { int xx, yy; - int width, height; int bpl; guint8 *srow = image->mem, *orow = pixels; @@ -947,15 +1070,13 @@ rgb888msb (GdkImage *image, d (printf ("32 bit, msb, no alpha\n")); - width = image->width; - height = image->height; bpl = image->bpl; - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { *o++ = s[1]; *o++ = s[2]; @@ -975,11 +1096,14 @@ static void convert_real_slow (GdkImage *image, guchar *pixels, int rowstride, + int x1, + int y1, + int x2, + int y2, GdkColormap *cmap, - int alpha) + gboolean alpha) { int xx, yy; - int width, height; int bpl; guint8 *srow = image->mem, *orow = pixels; guint8 *s; @@ -989,8 +1113,6 @@ convert_real_slow (GdkImage *image, guint8 component; int i; - width = image->width; - height = image->height; bpl = image->bpl; v = gdk_colormap_get_visual(cmap); @@ -999,11 +1121,11 @@ convert_real_slow (GdkImage *image, v->red_shift, v->green_shift, v->blue_shift, v->red_prec, v->green_prec, v->blue_prec)); - for (yy = 0; yy < height; yy++) + for (yy = y1; yy < y2; yy++) { s = srow; o = orow; - for (xx = 0; xx < width; xx++) + for (xx = x1; xx < x2; xx++) { pixel = gdk_image_get_pixel(image, xx, yy); switch (v->type) @@ -1049,7 +1171,14 @@ convert_real_slow (GdkImage *image, } } -typedef void (* cfunc) (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *cmap); +typedef void (* cfunc) (GdkImage *image, + guchar *pixels, + int rowstride, + int x1, + int y1, + int x2, + int y2, + GdkColormap *cmap); static cfunc convert_map[] = { rgb1,rgb1,rgb1a,rgb1a, @@ -1070,16 +1199,23 @@ static void rgbconvert (GdkImage *image, guchar *pixels, int rowstride, - int alpha, + gboolean alpha, + int x, + int y, + int width, + int height, GdkColormap *cmap) { int index = (image->byte_order == GDK_MSB_FIRST) | (alpha != 0) << 1; - int bank=5; /* default fallback converter */ - GdkVisual *v = gdk_colormap_get_visual(cmap); + int bank = 5; /* default fallback converter */ + GdkVisual *v = gdk_colormap_get_visual (cmap); d(printf("masks = %x:%x:%x\n", v->red_mask, v->green_mask, v->blue_mask)); d(printf("image depth = %d, bits per pixel = %d\n", image->depth, image->bits_per_pixel)); + g_assert ((x + width) <= image->width); + g_assert ((y + height) <= image->height); + switch (v->type) { /* I assume this is right for static & greyscale's too? */ @@ -1124,16 +1260,21 @@ rgbconvert (GdkImage *image, break; } - d(printf("converting using conversion function in bank %d\n", bank)); + d (g_print ("converting using conversion function in bank %d\n", bank)); - if (bank==5) + if (bank == 5) { - convert_real_slow(image, pixels, rowstride, cmap, alpha); + convert_real_slow (image, pixels, rowstride, + x, y, x + width, y + height, + cmap, alpha); } else { index |= bank << 2; - (* convert_map[index]) (image, pixels, rowstride, cmap); + d (g_print ("converting with index %d\n", index)); + (* convert_map[index]) (image, pixels, rowstride, + x, y, x + width, y + height, + cmap); } } @@ -1142,7 +1283,7 @@ rgbconvert (GdkImage *image, /** * gdk_pixbuf_get_from_drawable: - * @dest: Destination pixbuf, or NULL if a new pixbuf should be created. + * @dest: Destination pixbuf, or %NULL if a new pixbuf should be created. * @src: Source drawable. * @cmap: A colormap if @src is a pixmap. If it is a window, this argument will * be ignored. @@ -1153,37 +1294,56 @@ rgbconvert (GdkImage *image, * @width: Width in pixels of region to get. * @height: Height in pixels of region to get. * - * Transfers image data from a Gdk drawable and converts it to an RGB(A) - * representation inside a GdkPixbuf. + * Transfers image data from a #GdkDrawable and converts it to an RGB(A) + * representation inside a #GdkPixbuf. In other words, copies + * image data from a server-side drawable to a client-side RGB(A) buffer. + * This allows you to efficiently read individual pixels on the client side. * - * If the drawable @src is a pixmap, then a suitable colormap must be specified, - * since pixmaps are just blocks of pixel data without an associated colormap. - * If the drawable is a window, the @cmap argument will be ignored and the - * window's own colormap will be used instead. + * If the drawable @src is a pixmap, then a suitable colormap must be + * specified, since pixmaps are just blocks of pixel data without an + * associated colormap. If the drawable is a window, the @cmap + * argument will be ignored and the window's own colormap will be used + * instead. * - * If the specified destination pixbuf @dest is #NULL, then this function will - * create an RGB pixbuf with 8 bits per channel and no alpha, with the same size - * specified by the @width and @height arguments. In this case, the @dest_x and - * @dest_y arguments must be specified as 0, otherwise the function will return - * #NULL. If the specified destination pixbuf is not NULL and it contains alpha - * information, then the filled pixels will be set to full opacity. + * If the specified destination pixbuf @dest is %NULL, then this + * function will create an RGB pixbuf with 8 bits per channel and no + * alpha, with the same size specified by the @width and @height + * arguments. In this case, the @dest_x and @dest_y arguments must be + * specified as 0. If the specified destination pixbuf is not %NULL + * and it contains alpha information, then the filled pixels will be + * set to full opacity (alpha = 255). * - * If the specified drawable is a pixmap, then the requested source rectangle - * must be completely contained within the pixmap, otherwise the function will - * return #NULL. + * If the specified drawable is a pixmap, then the requested source + * rectangle must be completely contained within the pixmap, otherwise + * the function will return %NULL. For pixmaps only (not for windows) + * passing -1 for width or height is allowed to mean the full width + * or height of the pixmap. * - * If the specified drawable is a window, then it must be viewable, i.e. all of - * its ancestors up to the root window must be mapped. Also, the specified - * source rectangle must be completely contained within the window and within - * the screen. If regions of the window are obscured by noninferior windows, the - * contents of those regions are undefined. The contents of regions obscured by - * inferior windows of a different depth than that of the source window will also - * be undefined. + * If the specified drawable is a window, and the window is off the + * screen, then there is no image data in the obscured/offscreen + * regions to be placed in the pixbuf. The contents of portions of the + * pixbuf corresponding to the offscreen region are undefined. * - * Return value: The same pixbuf as @dest if it was non-NULL, or a newly-created - * pixbuf with a reference count of 1 if no destination pixbuf was specified; in - * the latter case, NULL will be returned if not enough memory could be - * allocated for the pixbuf to be created. + * If the window you're obtaining data from is partially obscured by + * other windows, then the contents of the pixbuf areas corresponding + * to the obscured regions are undefined. + * + * If the target drawable is not mapped (typically because it's + * iconified/minimized or not on the current workspace), then %NULL + * will be returned. + * + * If memory can't be allocated for the return value, %NULL will be returned + * instead. + * + * (In short, there are several ways this function can fail, and if it fails + * it returns %NULL; so check the return value.) + * + * This function calls gdk_drawable_get_image() internally and + * converts the resulting image to a #GdkPixbuf, so the + * documentation for gdk_drawable_get_image() may also be relevant. + * + * Return value: The same pixbuf as @dest if it was non-%NULL, or a newly-created + * pixbuf with a reference count of 1 if no destination pixbuf was specified, or %NULL on error **/ GdkPixbuf * gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, @@ -1195,7 +1355,6 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, { int src_width, src_height; GdkImage *image; - int rowstride, bpp, alpha; /* General sanity checks */ @@ -1230,11 +1389,99 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, } /* Coordinate sanity checks */ + + if (GDK_IS_PIXMAP (src)) + { + gdk_drawable_get_size (src, &src_width, &src_height); + if (width < 0) + width = src_width; + if (height < 0) + height = src_height; + + g_return_val_if_fail (src_x >= 0 && src_y >= 0, NULL); + g_return_val_if_fail (src_x + width <= src_width && src_y + height <= src_height, NULL); + } - gdk_drawable_get_size (src, &src_width, &src_height); + if (dest) + { + g_return_val_if_fail (dest_x >= 0 && dest_y >= 0, NULL); + g_return_val_if_fail (dest_x + width <= dest->width, NULL); + g_return_val_if_fail (dest_y + height <= dest->height, NULL); + } + + /* Get Image in ZPixmap format (packed bits). */ + image = gdk_image_get (src, src_x, src_y, width, height); + + if (image == NULL) + return NULL; + + dest = gdk_pixbuf_get_from_image (dest, image, cmap, + 0, 0, dest_x, dest_y, + width, height); + + gdk_image_destroy (image); + + return dest; +} + +/** + * gdk_pixbuf_get_from_image: + * @dest: Destination pixbuf, or %NULL if a new pixbuf should be created. + * @src: Source #GdkImage. + * @cmap: A colormap, or %NULL to use the one for @src + * @src_x: Source X coordinate within drawable. + * @src_y: Source Y coordinate within drawable. + * @dest_x: Destination X coordinate in pixbuf, or 0 if @dest is NULL. + * @dest_y: Destination Y coordinate in pixbuf, or 0 if @dest is NULL. + * @width: Width in pixels of region to get. + * @height: Height in pixels of region to get. + * + * Same as gdk_pixbuf_get_from_drawable() but gets the pixbuf from + * an image. + * + * Return value: @dest, newly-created pixbuf if @dest was %NULL, %NULL on error + **/ +GdkPixbuf* +gdk_pixbuf_get_from_image (GdkPixbuf *dest, + GdkImage *src, + GdkColormap *cmap, + int src_x, + int src_y, + int dest_x, + int dest_y, + int width, + int height) +{ + int rowstride, bpp, alpha; + + /* General sanity checks */ + + g_return_val_if_fail (GDK_IS_IMAGE (src), NULL); + + if (!dest) + g_return_val_if_fail (dest_x == 0 && dest_y == 0, NULL); + else + { + g_return_val_if_fail (dest->colorspace == GDK_COLORSPACE_RGB, NULL); + g_return_val_if_fail (dest->n_channels == 3 || dest->n_channels == 4, NULL); + g_return_val_if_fail (dest->bits_per_sample == 8, NULL); + } + + if (cmap == NULL) + cmap = gdk_image_get_colormap (src); + + if (cmap == NULL) + { + g_warning ("%s: Source image has no colormap; either pass " + "in a colormap, or set the colormap on the image " + "with gdk_image_set_colormap()", G_STRLOC); + return NULL; + } + + /* Coordinate sanity checks */ g_return_val_if_fail (src_x >= 0 && src_y >= 0, NULL); - g_return_val_if_fail (src_x + width <= src_width && src_y + height <= src_height, NULL); + g_return_val_if_fail (src_x + width <= src->width && src_y + height <= src->height, NULL); if (dest) { @@ -1243,54 +1490,29 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, g_return_val_if_fail (dest_y + height <= dest->height, NULL); } - if (GDK_IS_WINDOW (src)) - { - int ret; - int src_xorigin, src_yorigin; - int screen_width, screen_height; - int screen_srcx, screen_srcy; - - ret = gdk_window_get_origin (src, &src_xorigin, &src_yorigin); - g_return_val_if_fail (ret != FALSE, NULL); - - screen_width = gdk_screen_width (); - screen_height = gdk_screen_height (); - - screen_srcx = src_xorigin + src_x; - screen_srcy = src_yorigin + src_y; - - g_return_val_if_fail (screen_srcx >= 0 && screen_srcy >= 0, NULL); - g_return_val_if_fail (screen_srcx + width <= screen_width, NULL); - g_return_val_if_fail (screen_srcy + height <= screen_height, NULL); - } - - /* Get Image in ZPixmap format (packed bits). */ - image = gdk_image_get (src, src_x, src_y, width, height); - g_return_val_if_fail (image != NULL, NULL); - /* Create the pixbuf if needed */ if (!dest) { dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); - if (!dest) - { - gdk_image_destroy(image); - return NULL; - } + if (dest == NULL) + return NULL; } alpha = dest->has_alpha; rowstride = dest->rowstride; bpp = alpha ? 4 : 3; - /* we offset into the image data based on the position we are retrieving from */ - rgbconvert (image, dest->pixels + + /* we offset into the image data based on the position we are + * retrieving from + */ + rgbconvert (src, dest->pixels + (dest_y * rowstride) + (dest_x * bpp), rowstride, alpha, + src_x, src_y, + src_x + width, + src_y + height, cmap); - - gdk_image_destroy(image); - + return dest; } diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c index cb4b9ea2bf..7b86f6e516 100644 --- a/gdk/gdkpixbuf-render.c +++ b/gdk/gdkpixbuf-render.c @@ -267,7 +267,9 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkGC *gc; GdkPixbuf *composited = NULL; gint dwidth, dheight; - + GdkRegion *clip; + GdkRegion *drect; + GdkRectangle tmp_rect; g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB); @@ -308,12 +310,70 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, if (width <= 0 || height <= 0) return; + /* Clip to the clip region; this avoids getting more + * image data from the server than we need to. + */ + + tmp_rect.x = dest_x; + tmp_rect.y = dest_y; + tmp_rect.width = width; + tmp_rect.height = height; + + drect = gdk_region_rectangle (&tmp_rect); + clip = gdk_drawable_get_clip_region (drawable); + + gdk_region_intersect (drect, clip); + + gdk_region_get_clipbox (drect, &tmp_rect); + + gdk_region_destroy (drect); + gdk_region_destroy (clip); + + if (tmp_rect.width == 0 || + tmp_rect.height == 0) + return; + /* Actually draw */ gc = gdk_gc_new (drawable); if (pixbuf->has_alpha) { + if (alpha_mode == GDK_PIXBUF_ALPHA_FULL) + { + GdkPixbuf *sub = NULL; + + composited = gdk_pixbuf_get_from_drawable (NULL, + drawable, + NULL, + dest_x, dest_y, + 0, 0, + width, height); + + if (composited) + { + if (src_x != 0 || src_y != 0) + { + sub = gdk_pixbuf_new_subpixbuf (pixbuf, src_x, src_y, + width, height); + } + + gdk_pixbuf_composite (sub ? sub : pixbuf, + composited, + 0, 0, + width, height, + 0, 0, + 1.0, 1.0, + GDK_INTERP_BILINEAR, + 255); + + if (sub) + g_object_unref (G_OBJECT (sub)); + } + else + alpha_mode = GDK_PIXBUF_ALPHA_BILEVEL; /* fall back */ + } + if (alpha_mode == GDK_PIXBUF_ALPHA_BILEVEL) { bitmap = gdk_pixmap_new (NULL, width, height, 1); @@ -326,35 +386,6 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, gdk_gc_set_clip_mask (gc, bitmap); gdk_gc_set_clip_origin (gc, dest_x, dest_y); } - else if (alpha_mode == GDK_PIXBUF_ALPHA_FULL) - { - GdkPixbuf *sub = NULL; - - composited = gdk_pixbuf_get_from_drawable (NULL, - drawable, - NULL, - dest_x, dest_y, - 0, 0, - width, height); - - if (src_x != 0 || src_y != 0) - { - sub = gdk_pixbuf_new_subpixbuf (pixbuf, src_x, src_y, - width, height); - } - - gdk_pixbuf_composite (sub ? sub : pixbuf, - composited, - 0, 0, - width, height, - 0, 0, - 1.0, 1.0, - GDK_INTERP_BILINEAR, - 255); - - if (sub) - g_object_unref (G_OBJECT (sub)); - } } if (composited) diff --git a/gdk/gdkpixbuf.h b/gdk/gdkpixbuf.h index db74d60117..593d4ad450 100644 --- a/gdk/gdkpixbuf.h +++ b/gdk/gdkpixbuf.h @@ -61,6 +61,16 @@ GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, int width, int height); +GdkPixbuf *gdk_pixbuf_get_from_image (GdkPixbuf *dest, + GdkImage *src, + GdkColormap *cmap, + int src_x, + int src_y, + int dest_x, + int dest_y, + int width, + int height); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 67002758ca..94d2a39467 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -1317,6 +1317,8 @@ gdk_window_get_clip_region (GdkDrawable *drawable) GdkWindowPaint *paint = tmp_list->data; gdk_region_union (paint_region, paint->region); + + tmp_list = tmp_list->next; } gdk_region_intersect (result, paint_region); diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 3652ab490f..c143ceae10 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -930,7 +930,7 @@ motif_find_drag_window (gboolean create) display = XOpenDisplay (gdk_display_name); XSetCloseDownMode (display, RetainPermanent); - XGrabServer (display); + XGrabServer (display); motif_drag_window = motif_lookup_drag_window (display); diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c index 2f1c7f7240..ac78afd507 100644 --- a/gdk/x11/gdkimage-x11.c +++ b/gdk/x11/gdkimage-x11.c @@ -381,8 +381,10 @@ _gdk_x11_get_image (GdkDrawable *drawable, GdkImagePrivateX11 *private; GdkDrawableImplX11 *impl; GdkVisual *visual; + gboolean have_grab; + GdkRectangle window_rect; XImage *ximage; - + g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_X11 (drawable), NULL); visual = gdk_drawable_get_visual (drawable); @@ -399,31 +401,69 @@ _gdk_x11_get_image (GdkDrawable *drawable, impl = GDK_DRAWABLE_IMPL_X11 (drawable); - ximage = XGetImage (impl->xdisplay, - impl->xid, - x, y, width, height, - AllPlanes, ZPixmap); + have_grab = FALSE; + window_rect.x = x; + window_rect.y = y; + window_rect.width = width; + window_rect.height = height; + if (GDK_IS_WINDOW (drawable)) + { + GdkRectangle screen_rect; + + have_grab = TRUE; + gdk_x11_grab_server (); - if (!ximage) + screen_rect.x = 0; + screen_rect.y = 0; + screen_rect.width = gdk_screen_width (); + screen_rect.height = gdk_screen_height (); + + gdk_error_trap_push (); + + gdk_window_get_geometry (GDK_WINDOW (drawable), + &window_rect.x, + &window_rect.y, + &window_rect.width, + &window_rect.height, + NULL); + + if (gdk_error_trap_pop () || + !gdk_rectangle_intersect (&window_rect, &screen_rect, + &window_rect)) + { + gdk_x11_ungrab_server (); + return NULL; + } + } + + image = gdk_image_new (GDK_IMAGE_FASTEST, + visual, + width, height); + + if (image == NULL) return NULL; - image = g_object_new (gdk_image_get_type (), NULL); private = PRIVATE_DATA (image); + + gdk_error_trap_push (); - private->xdisplay = gdk_display; - private->ximage = ximage; + ximage = XGetSubImage (impl->xdisplay, + impl->xid, + x, y, width, height, + AllPlanes, ZPixmap, + private->ximage, + x, y); - image->type = GDK_IMAGE_NORMAL; - image->visual = visual; - image->width = width; - image->height = height; - image->depth = private->ximage->depth; + if (have_grab) + gdk_x11_ungrab_server (); + + if (gdk_error_trap_pop () || ximage == NULL) + { + g_object_unref (G_OBJECT (image)); + return NULL; + } - image->mem = private->ximage->data; - image->bpl = private->ximage->bytes_per_line; - image->bits_per_pixel = private->ximage->bits_per_pixel; - image->bpp = (private->ximage->bits_per_pixel + 7) / 8; - image->byte_order = private->ximage->byte_order; + g_assert (ximage == private->ximage); return image; } diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index c4c498e340..31774a18d3 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -193,7 +193,7 @@ gdk_window_impl_x11_get_colormap (GdkDrawable *drawable) drawable_impl->colormap == NULL) { XWindowAttributes window_attributes; - + XGetWindowAttributes (drawable_impl->xdisplay, drawable_impl->xid, &window_attributes); @@ -2278,7 +2278,7 @@ gdk_window_set_override_redirect (GdkWindow *window, * gdk_window_set_icon_list: * @window: The #GdkWindow toplevel window to set the icon of. * @pixbufs: A list of pixbufs, of different sizes. - * @Returns: TRUE if the icons were set, false otherwise + * @Returns: %TRUE if the icons were set, false otherwise * * Sets a list of icons for the window. One of these will be used * to represent the window when it has been iconified. The icon is @@ -3841,4 +3841,3 @@ gdk_window_begin_move_drag (GdkWindow *window, else emulate_move_drag (window, button, root_x, root_y, timestamp); } - diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 5feb2bec4f..7125127fc0 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -176,6 +176,9 @@ void gdk_x11_ungrab_server (void); /* returns TRUE if we support the given WM spec feature */ gboolean gdk_net_wm_supports (GdkAtom property); +void gdk_x11_grab_server (void); +void gdk_x11_ungrab_server (void); + #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)) diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 00df16af66..4d222711b2 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -2648,6 +2648,7 @@ gtk_calendar_key_press (GtkWidget *widget, switch (event->keyval) { + case GDK_KP_Left: case GDK_Left: return_val = TRUE; if (event->state & GDK_CONTROL_MASK) @@ -2670,6 +2671,7 @@ gtk_calendar_key_press (GtkWidget *widget, calendar->focus_col); } break; + case GDK_KP_Right: case GDK_Right: return_val = TRUE; if (event->state & GDK_CONTROL_MASK) @@ -2692,6 +2694,7 @@ gtk_calendar_key_press (GtkWidget *widget, calendar->focus_col); } break; + case GDK_KP_Up: case GDK_Up: return_val = TRUE; if (event->state & GDK_CONTROL_MASK) @@ -2709,6 +2712,7 @@ gtk_calendar_key_press (GtkWidget *widget, calendar->focus_col); } break; + case GDK_KP_Down: case GDK_Down: return_val = TRUE; if (event->state & GDK_CONTROL_MASK) @@ -2726,6 +2730,7 @@ gtk_calendar_key_press (GtkWidget *widget, calendar->focus_col); } break; + case GDK_KP_Space: case GDK_space: row = calendar->focus_row; col = calendar->focus_col; diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c index 653783417e..b372a44b13 100644 --- a/gtk/gtkclist.c +++ b/gtk/gtkclist.c @@ -733,80 +733,157 @@ gtk_clist_class_init (GtkCListClass *klass) "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Down, 0, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, 0, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, 0, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Home, GDK_CONTROL_MASK, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, GDK_CONTROL_MASK, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_End, GDK_CONTROL_MASK, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 1.0); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_End, GDK_CONTROL_MASK, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 1.0); + gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Down, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Home, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, + GDK_SHIFT_MASK | GDK_CONTROL_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_End, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 1.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_End, + GDK_SHIFT_MASK | GDK_CONTROL_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 1.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, + GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, + GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_Home, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_End, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 1.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 1.0); + gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "undo_selection", 0); gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "abort_column_resize", 0); gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "toggle_focus_row", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, 0, + "toggle_focus_row", 0); gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_add_mode", 0); - gtk_binding_entry_add_signal (binding_set, '/', GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_CONTROL_MASK, + "toggle_add_mode", 0); + gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK, + "select_all", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Divide, GDK_CONTROL_MASK, "select_all", 0); gtk_binding_entry_add_signal (binding_set, '\\', GDK_CONTROL_MASK, "unselect_all", 0); diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index 47546b83b6..ba204ec040 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -955,7 +955,10 @@ palette_activate (GtkWidget *widget, gpointer data) { /* should have a drawing area subclass with an activate signal */ - if ((event->keyval == ' ') || (event->keyval == GDK_Return)) + if ((event->keyval == GDK_space) || + (event->keyval == GDK_Return) || + (event->keyval == GDK_KP_Enter) || + (event->keyval == GDK_KP_Space)) { if (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), "color_set")) != 0) { diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c index 1d11930292..11a1e464f6 100644 --- a/gtk/gtkcombo.c +++ b/gtk/gtkcombo.c @@ -176,7 +176,10 @@ gtk_combo_entry_key_press (GtkEntry * entry, GdkEventKey * event, GtkCombo * com GList *li; /* completion */ - if ((event->keyval == GDK_Tab) && (event->state & GDK_MOD1_MASK)) + if ((event->keyval == GDK_Tab || + event->keyval == GDK_ISO_Left_Tab || + event->keyval == GDK_KP_Tab) && + (event->state & GDK_MOD1_MASK)) { GtkEditable *editable = GTK_EDITABLE (entry); GCompletion * cmpl; diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c index 415fdeceec..763ddec171 100644 --- a/gtk/gtkctree.c +++ b/gtk/gtkctree.c @@ -474,36 +474,45 @@ gtk_ctree_class_init (GtkCTreeClass *klass) binding_set = gtk_binding_set_by_class (klass); gtk_binding_entry_add_signal (binding_set, - '+', GDK_SHIFT_MASK, + GDK_plus, GDK_SHIFT_MASK, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND); gtk_binding_entry_add_signal (binding_set, - '+', 0, + GDK_plus, 0, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND); gtk_binding_entry_add_signal (binding_set, - '+', GDK_CONTROL_MASK | GDK_SHIFT_MASK, + GDK_plus, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND_RECURSIVE); gtk_binding_entry_add_signal (binding_set, - '+', GDK_CONTROL_MASK, + GDK_plus, GDK_CONTROL_MASK, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND_RECURSIVE); + + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Add, GDK_SHIFT_MASK, + "change_focus_row_expansion", 1, + GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND); gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, 0, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Add, GDK_CONTROL_MASK | GDK_SHIFT_MASK, + "change_focus_row_expansion", 1, + GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND_RECURSIVE); gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_CONTROL_MASK, "change_focus_row_expansion", 1, - GTK_TYPE_ENUM, - GTK_CTREE_EXPANSION_EXPAND_RECURSIVE); + GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_EXPAND_RECURSIVE); + gtk_binding_entry_add_signal (binding_set, - '-', 0, + GDK_minus, 0, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_COLLAPSE); gtk_binding_entry_add_signal (binding_set, - '-', GDK_CONTROL_MASK, + GDK_minus, GDK_CONTROL_MASK, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE); @@ -517,22 +526,39 @@ gtk_ctree_class_init (GtkCTreeClass *klass) GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE); gtk_binding_entry_add_signal (binding_set, - '=', 0, + GDK_equal, 0, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE); gtk_binding_entry_add_signal (binding_set, - '=', GDK_SHIFT_MASK, + GDK_KP_Equal, 0, + "change_focus_row_expansion", 1, + GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE); + gtk_binding_entry_add_signal (binding_set, + GDK_equal, GDK_SHIFT_MASK, + "change_focus_row_expansion", 1, + GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Equal, GDK_SHIFT_MASK, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE); gtk_binding_entry_add_signal (binding_set, GDK_KP_Multiply, 0, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE); + gtk_binding_entry_add_signal (binding_set, + GDK_asterisk, 0, + "change_focus_row_expansion", 1, + GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE); gtk_binding_entry_add_signal (binding_set, GDK_KP_Multiply, GDK_CONTROL_MASK, "change_focus_row_expansion", 1, GTK_TYPE_ENUM, GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE); + gtk_binding_entry_add_signal (binding_set, + GDK_asterisk, GDK_CONTROL_MASK, + "change_focus_row_expansion", 1, + GTK_TYPE_ENUM, + GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE); } static void diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index 9e7e2ae68c..18b28df3bf 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -33,11 +33,10 @@ #include "gdkkeysyms.h" #include "gtkmain.h" #include "gtkintl.h" +#include "gtkbindings.h" static void gtk_dialog_class_init (GtkDialogClass *klass); static void gtk_dialog_init (GtkDialog *dialog); -static gint gtk_dialog_key_press (GtkWidget *widget, - GdkEventKey *key); static void gtk_dialog_add_buttons_valist (GtkDialog *dialog, const gchar *first_button_text, @@ -58,6 +57,8 @@ static void gtk_dialog_get_property (GObject *object, static void gtk_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style); +static void gtk_dialog_close (GtkDialog *dialog); + enum { PROP_0, PROP_HAS_SEPARATOR @@ -65,6 +66,7 @@ enum { enum { RESPONSE, + CLOSE, LAST_SIGNAL }; @@ -102,18 +104,20 @@ gtk_dialog_class_init (GtkDialogClass *class) GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; - + GtkBindingSet *binding_set; + gobject_class = G_OBJECT_CLASS (class); object_class = GTK_OBJECT_CLASS (class); widget_class = GTK_WIDGET_CLASS (class); - + parent_class = g_type_class_peek_parent (class); gobject_class->set_property = gtk_dialog_set_property; gobject_class->get_property = gtk_dialog_get_property; - widget_class->key_press_event = gtk_dialog_key_press; widget_class->style_set = gtk_dialog_style_set; + + class->close = gtk_dialog_close; g_object_class_install_property (gobject_class, PROP_HAS_SEPARATOR, @@ -132,6 +136,14 @@ gtk_dialog_class_init (GtkDialogClass *class) GTK_TYPE_NONE, 1, GTK_TYPE_INT); + dialog_signals[CLOSE] = + gtk_signal_new ("close", + GTK_RUN_LAST | GTK_RUN_ACTION, + GTK_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (GtkDialogClass, close), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_widget_class_install_style_property (widget_class, g_param_spec_int ("content_area_border", _("Content area border"), @@ -157,6 +169,11 @@ gtk_dialog_class_init (GtkDialogClass *class) G_MAXINT, 5, G_PARAM_READABLE)); + + binding_set = gtk_binding_set_by_class (class); + + gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, + "close", 0); } static void @@ -277,32 +294,6 @@ gtk_dialog_delete_event_handler (GtkWidget *widget, return FALSE; } -static gint -gtk_dialog_key_press (GtkWidget *widget, - GdkEventKey *key) -{ - GdkEventAny event; - - event.type = GDK_DELETE; - event.window = widget->window; - event.send_event = TRUE; - - if (GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, key)) - return TRUE; - - if (key->keyval != GDK_Escape) - return FALSE; - - /* Synthesize delete_event to close dialog. */ - g_object_ref (G_OBJECT (event.window)); - - gtk_main_do_event ((GdkEvent*)&event); - - g_object_unref (G_OBJECT (event.window)); - - return TRUE; -} - static void gtk_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style) @@ -310,6 +301,27 @@ gtk_dialog_style_set (GtkWidget *widget, update_spacings (GTK_DIALOG (widget)); } +static void +gtk_dialog_close (GtkDialog *dialog) +{ + /* Synthesize delete_event to close dialog. */ + + GdkEventAny event; + GtkWidget *widget; + + widget = GTK_WIDGET (dialog); + + event.type = GDK_DELETE; + event.window = widget->window; + event.send_event = TRUE; + + g_object_ref (G_OBJECT (event.window)); + + gtk_main_do_event ((GdkEvent*)&event); + + g_object_unref (G_OBJECT (event.window)); +} + GtkWidget* gtk_dialog_new (void) { diff --git a/gtk/gtkdialog.h b/gtk/gtkdialog.h index 7bd8e975bf..5ff49b62ac 100644 --- a/gtk/gtkdialog.h +++ b/gtk/gtkdialog.h @@ -109,6 +109,10 @@ struct _GtkDialogClass GtkWindowClass parent_class; void (* response) (GtkDialog *dialog, gint response_id); + + /* Keybinding signals */ + + void (* close) (GtkDialog *dialog); }; diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 3a4576f5cc..61cf5a8a91 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -698,10 +698,17 @@ gtk_entry_class_init (GtkEntryClass *class) "delete_from_cursor", 2, GTK_TYPE_ENUM, GTK_DELETE_WHITESPACE, GTK_TYPE_INT, 1); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_MOD1_MASK, + "delete_from_cursor", 2, + GTK_TYPE_ENUM, GTK_DELETE_WHITESPACE, + GTK_TYPE_INT, 1); gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_MOD1_MASK, "insert_at_cursor", 1, GTK_TYPE_STRING, " "); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_MOD1_MASK, + "insert_at_cursor", 1, + GTK_TYPE_STRING, " "); + gtk_binding_entry_add_signal (binding_set, GDK_backslash, GDK_MOD1_MASK, "delete_from_cursor", 2, GTK_TYPE_ENUM, GTK_DELETE_WHITESPACE, @@ -727,6 +734,8 @@ gtk_entry_class_init (GtkEntryClass *class) /* Overwrite */ gtk_binding_entry_add_signal (binding_set, GDK_Insert, 0, "toggle_overwrite", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0, + "toggle_overwrite", 0); } static void diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c index 4036bf4519..96111d7350 100644 --- a/gtk/gtkfilesel.c +++ b/gtk/gtkfilesel.c @@ -1416,7 +1416,9 @@ gtk_file_selection_key_press (GtkWidget *widget, g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE); - if (event->keyval == GDK_Tab) + if (event->keyval == GDK_Tab || + event->keyval == GDK_ISO_Left_Tab || + event->keyval == GDK_KP_Tab) { fs = GTK_FILE_SELECTION (user_data); #ifdef G_WITH_CYGWIN diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 9f4f3ad517..525a916626 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -1154,7 +1154,9 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, if ((event->state & (ISO_14755_MOD_MASK)) == ISO_14755_MOD_MASK) { /* space ends the sequence, and we eat the space */ - if (n_compose > 1 && event->keyval == GDK_space) + if (n_compose > 1 && + (event->keyval == GDK_space || + event->keyval == GDK_KP_Space)) { gtk_im_context_simple_commit_char (context, context_simple->tentative_match); context_simple->compose_buffer[0] = 0; diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c index b47970e760..bead0ebe5f 100644 --- a/gtk/gtkitemfactory.c +++ b/gtk/gtkitemfactory.c @@ -1250,8 +1250,8 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory, if (type_id == quark_type_stock_item) { image = gtk_image_new_from_stock (entry->extra_data, GTK_ICON_SIZE_MENU); - if (image) - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (widget), image); + + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (widget), image); if (gtk_stock_lookup (entry->extra_data, &stock_item)) { diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c index 4e9b7bd46b..06704a1094 100644 --- a/gtk/gtklistitem.c +++ b/gtk/gtklistitem.c @@ -207,78 +207,152 @@ gtk_list_item_class_init (GtkListItemClass *class) "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Down, 0, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, 0, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, 0, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, 0, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Home, GDK_CONTROL_MASK, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, GDK_CONTROL_MASK, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_End, GDK_CONTROL_MASK, "scroll_vertical", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 1.0); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_End, GDK_CONTROL_MASK, + "scroll_vertical", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 1.0); + gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_Down, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_BACKWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, GDK_SHIFT_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, GDK_SHIFT_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_PAGE_FORWARD, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Home, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, + GDK_SHIFT_MASK | GDK_CONTROL_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 0.0, GTK_TYPE_BOOL, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_End, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "extend_selection", 3, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 1.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_End, + GDK_SHIFT_MASK | GDK_CONTROL_MASK, + "extend_selection", 3, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 1.0, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_STEP_FORWARD, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_Home, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 0.0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 0.0); gtk_binding_entry_add_signal (binding_set, GDK_End, 0, "scroll_horizontal", 2, GTK_TYPE_ENUM, GTK_SCROLL_JUMP, GTK_TYPE_FLOAT, 1.0); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0, + "scroll_horizontal", 2, + GTK_TYPE_ENUM, GTK_SCROLL_JUMP, + GTK_TYPE_FLOAT, 1.0); + gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "undo_selection", 0); gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "toggle_focus_row", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, 0, + "toggle_focus_row", 0); gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_add_mode", 0); - gtk_binding_entry_add_signal (binding_set, '/', GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_CONTROL_MASK, + "toggle_add_mode", 0); + gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK, + "select_all", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Divide, GDK_CONTROL_MASK, "select_all", 0); gtk_binding_entry_add_signal (binding_set, '\\', GDK_CONTROL_MASK, "unselect_all", 0); diff --git a/gtk/gtkmarshal.list b/gtk/gtkmarshal.list index 0de93619d2..52777c822e 100644 --- a/gtk/gtkmarshal.list +++ b/gtk/gtkmarshal.list @@ -32,6 +32,7 @@ BOOLEAN:BOOLEAN ENUM:ENUM INT:POINTER NONE:BOOL +NONE:ENUM NONE:INT NONE:INT,INT NONE:NONE diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list index 0de93619d2..52777c822e 100644 --- a/gtk/gtkmarshalers.list +++ b/gtk/gtkmarshalers.list @@ -32,6 +32,7 @@ BOOLEAN:BOOLEAN ENUM:ENUM INT:POINTER NONE:BOOL +NONE:ENUM NONE:INT NONE:INT,INT NONE:NONE diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index b1c79fffd7..eb085fbbb8 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -186,21 +186,41 @@ gtk_menu_class_init (GtkMenuClass *class) "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_PREV); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Up, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_PREV); gtk_binding_entry_add_signal (binding_set, GDK_Down, 0, "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_NEXT); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Down, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_NEXT); gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_PARENT); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Left, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_PARENT); gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_CHILD); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Right, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_CHILD); } static gboolean diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 3b0cb73e10..f266340176 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -106,22 +106,42 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class) "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_PREV); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Left, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_PREV); gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_NEXT); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Right, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_NEXT); gtk_binding_entry_add_signal (binding_set, GDK_Up, 0, "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_PARENT); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Up, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_PARENT); gtk_binding_entry_add_signal (binding_set, GDK_Down, 0, "move_current", 1, GTK_TYPE_MENU_DIRECTION_TYPE, GTK_MENU_DIR_CHILD); - + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Down, 0, + "move_current", 1, + GTK_TYPE_MENU_DIRECTION_TYPE, + GTK_MENU_DIR_CHILD); + gtk_settings_install_property (gtk_settings_get_global (), g_param_spec_string ("gtk-menu-bar-accel", _("Menu bar accelerator"), diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index 6575a80e43..c757b64aeb 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -261,11 +261,21 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass) "activate_current", 1, GTK_TYPE_BOOL, TRUE); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Enter, 0, + "activate_current", 1, + GTK_TYPE_BOOL, + TRUE); gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "activate_current", 1, GTK_TYPE_BOOL, FALSE); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Space, 0, + "activate_current", 1, + GTK_TYPE_BOOL, + FALSE); } static GtkType diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index a41b4b8c51..0ac2a0f572 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -474,6 +474,11 @@ gtk_notebook_class_init (GtkNotebookClass *class) GDK_space, 0, "select_page", 1, G_TYPE_BOOLEAN, FALSE); + gtk_binding_entry_add_signal (binding_set, + GDK_KP_Space, 0, + "select_page", 1, + G_TYPE_BOOLEAN, FALSE); + gtk_binding_entry_add_signal (binding_set, GDK_Home, 0, "focus_tab", 1, diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c index cd90b37830..f9a5a764c5 100644 --- a/gtk/gtkoptionmenu.c +++ b/gtk/gtkoptionmenu.c @@ -606,6 +606,7 @@ gtk_option_menu_key_press (GtkWidget *widget, switch (event->keyval) { + case GDK_KP_Space: case GDK_space: gtk_option_menu_remove_contents (option_menu); gtk_menu_popup (GTK_MENU (option_menu->menu), NULL, NULL, diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 324aa87504..df69180b38 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -1154,7 +1154,8 @@ gtk_spin_button_key_press (GtkWidget *widget, GtkSpinButton *spin; gint key; gboolean key_repeat = FALSE; - + gboolean retval = FALSE; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -1164,100 +1165,112 @@ gtk_spin_button_key_press (GtkWidget *widget, key_repeat = (event->time == spin->ev_time); - if (GTK_ENTRY (widget)->editable && - (key == GDK_Up || key == GDK_Down || - key == GDK_Page_Up || key == GDK_Page_Down)) - gtk_spin_button_update (spin); - - switch (key) + if (GTK_ENTRY (widget)->editable) { - case GDK_Up: + switch (key) + { + case GDK_KP_Up: + case GDK_Up: - if (GTK_WIDGET_HAS_FOCUS (widget)) - { - gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), - "key_press_event"); - if (!key_repeat) - spin->timer_step = spin->adjustment->step_increment; + if (GTK_WIDGET_HAS_FOCUS (widget)) + { + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), + "key_press_event"); + if (!key_repeat) + spin->timer_step = spin->adjustment->step_increment; - gtk_spin_button_real_spin (spin, spin->timer_step); + gtk_spin_button_real_spin (spin, spin->timer_step); - if (key_repeat) - { - if (spin->climb_rate > 0.0 && spin->timer_step - < spin->adjustment->page_increment) - { - if (spin->timer_calls < MAX_TIMER_CALLS) - spin->timer_calls++; - else - { - spin->timer_calls = 0; - spin->timer_step += spin->climb_rate; - } - } - } - return TRUE; - } - return FALSE; + if (key_repeat) + { + if (spin->climb_rate > 0.0 && spin->timer_step + < spin->adjustment->page_increment) + { + if (spin->timer_calls < MAX_TIMER_CALLS) + spin->timer_calls++; + else + { + spin->timer_calls = 0; + spin->timer_step += spin->climb_rate; + } + } + } + retval = TRUE; + } + break; - case GDK_Down: + case GDK_KP_Down: + case GDK_Down: - if (GTK_WIDGET_HAS_FOCUS (widget)) - { - gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), - "key_press_event"); - if (!key_repeat) - spin->timer_step = spin->adjustment->step_increment; + if (GTK_WIDGET_HAS_FOCUS (widget)) + { + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), + "key_press_event"); + if (!key_repeat) + spin->timer_step = spin->adjustment->step_increment; - gtk_spin_button_real_spin (spin, -spin->timer_step); + gtk_spin_button_real_spin (spin, -spin->timer_step); - if (key_repeat) - { - if (spin->climb_rate > 0.0 && spin->timer_step - < spin->adjustment->page_increment) - { - if (spin->timer_calls < MAX_TIMER_CALLS) - spin->timer_calls++; - else - { - spin->timer_calls = 0; - spin->timer_step += spin->climb_rate; - } - } - } - return TRUE; - } - return FALSE; + if (key_repeat) + { + if (spin->climb_rate > 0.0 && spin->timer_step + < spin->adjustment->page_increment) + { + if (spin->timer_calls < MAX_TIMER_CALLS) + spin->timer_calls++; + else + { + spin->timer_calls = 0; + spin->timer_step += spin->climb_rate; + } + } + } + retval = TRUE; + } + break; - case GDK_Page_Up: + case GDK_KP_Page_Up: + case GDK_Page_Up: - if (event->state & GDK_CONTROL_MASK) - { - gdouble diff = spin->adjustment->upper - spin->adjustment->value; - if (diff > EPSILON) - gtk_spin_button_real_spin (spin, diff); - } - else - gtk_spin_button_real_spin (spin, spin->adjustment->page_increment); - return TRUE; + if (event->state & GDK_CONTROL_MASK) + { + gdouble diff = spin->adjustment->upper - spin->adjustment->value; + if (diff > EPSILON) + gtk_spin_button_real_spin (spin, diff); + } + else + gtk_spin_button_real_spin (spin, spin->adjustment->page_increment); - case GDK_Page_Down: + retval = TRUE; + break; + + case GDK_KP_Page_Down: + case GDK_Page_Down: - if (event->state & GDK_CONTROL_MASK) - { - gdouble diff = spin->adjustment->value - spin->adjustment->lower; - if (diff > EPSILON) - gtk_spin_button_real_spin (spin, -diff); - } - else - gtk_spin_button_real_spin (spin, -spin->adjustment->page_increment); - return TRUE; + if (event->state & GDK_CONTROL_MASK) + { + gdouble diff = spin->adjustment->value - spin->adjustment->lower; + if (diff > EPSILON) + gtk_spin_button_real_spin (spin, -diff); + } + else + gtk_spin_button_real_spin (spin, -spin->adjustment->page_increment); - default: - break; + retval = TRUE; + break; + + default: + break; + } } - return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); + if (retval) + { + gtk_spin_button_update (spin); + return TRUE; + } + else + return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); } static gint diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 1851b3698e..3b3db38620 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -1947,23 +1947,30 @@ gtk_text_key_press (GtkWidget *widget, { switch (event->keyval) { - case GDK_Home: + case GDK_Home: + case GDK_KP_Home: if (event->state & GDK_CONTROL_MASK) scroll_int (text, -text->vadj->value); else return_val = FALSE; break; case GDK_End: + case GDK_KP_End: if (event->state & GDK_CONTROL_MASK) scroll_int (text, +text->vadj->upper); else return_val = FALSE; break; + case GDK_KP_Page_Up: case GDK_Page_Up: scroll_int (text, -text->vadj->page_increment); break; + case GDK_KP_Page_Down: case GDK_Page_Down: scroll_int (text, +text->vadj->page_increment); break; + case GDK_KP_Up: case GDK_Up: scroll_int (text, -KEY_SCROLL_PIXELS); break; + case GDK_KP_Down: case GDK_Down: scroll_int (text, +KEY_SCROLL_PIXELS); break; case GDK_Return: + case GDK_KP_Enter: if (event->state & GDK_CONTROL_MASK) gtk_signal_emit_by_name (GTK_OBJECT (text), "activate"); else @@ -2047,6 +2054,7 @@ gtk_text_key_press (GtkWidget *widget, case GDK_Clear: gtk_text_delete_line (text); break; + case GDK_KP_Insert: case GDK_Insert: if (event->state & GDK_SHIFT_MASK) { @@ -2076,6 +2084,7 @@ gtk_text_key_press (GtkWidget *widget, break; case GDK_Tab: case GDK_ISO_Left_Tab: + case GDK_KP_Tab: position = text->point.index; gtk_editable_insert_text (GTK_EDITABLE (old_editable), "\t", 1, &position); break; diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index f268e11aa4..5de42f936c 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -715,9 +715,15 @@ gtk_text_view_class_init (GtkTextViewClass *klass) add_move_binding (binding_set, GDK_Right, 0, GTK_MOVEMENT_VISUAL_POSITIONS, 1); + add_move_binding (binding_set, GDK_KP_Right, 0, + GTK_MOVEMENT_VISUAL_POSITIONS, 1); + add_move_binding (binding_set, GDK_Left, 0, GTK_MOVEMENT_VISUAL_POSITIONS, -1); + add_move_binding (binding_set, GDK_KP_Left, 0, + GTK_MOVEMENT_VISUAL_POSITIONS, -1); + add_move_binding (binding_set, GDK_f, GDK_CONTROL_MASK, GTK_MOVEMENT_LOGICAL_POSITIONS, 1); @@ -727,16 +733,28 @@ gtk_text_view_class_init (GtkTextViewClass *klass) add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK, GTK_MOVEMENT_WORDS, 1); + add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK, + GTK_MOVEMENT_WORDS, 1); + add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK, GTK_MOVEMENT_WORDS, -1); + add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK, + GTK_MOVEMENT_WORDS, 1); + /* Eventually we want to move by display lines, not paragraphs */ add_move_binding (binding_set, GDK_Up, 0, GTK_MOVEMENT_DISPLAY_LINES, -1); + add_move_binding (binding_set, GDK_KP_Up, 0, + GTK_MOVEMENT_DISPLAY_LINES, -1); + add_move_binding (binding_set, GDK_Down, 0, GTK_MOVEMENT_DISPLAY_LINES, 1); + add_move_binding (binding_set, GDK_KP_Down, 0, + GTK_MOVEMENT_DISPLAY_LINES, 1); + add_move_binding (binding_set, GDK_p, GDK_CONTROL_MASK, GTK_MOVEMENT_DISPLAY_LINES, -1); @@ -758,26 +776,45 @@ gtk_text_view_class_init (GtkTextViewClass *klass) add_move_binding (binding_set, GDK_Home, 0, GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1); + add_move_binding (binding_set, GDK_KP_Home, 0, + GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1); + add_move_binding (binding_set, GDK_End, 0, GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1); + add_move_binding (binding_set, GDK_KP_End, 0, + GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1); + add_move_binding (binding_set, GDK_Home, GDK_CONTROL_MASK, GTK_MOVEMENT_BUFFER_ENDS, -1); + add_move_binding (binding_set, GDK_KP_Home, GDK_CONTROL_MASK, + GTK_MOVEMENT_BUFFER_ENDS, -1); + add_move_binding (binding_set, GDK_End, GDK_CONTROL_MASK, GTK_MOVEMENT_BUFFER_ENDS, 1); + add_move_binding (binding_set, GDK_KP_End, GDK_CONTROL_MASK, + GTK_MOVEMENT_BUFFER_ENDS, 1); + add_move_binding (binding_set, GDK_Page_Up, 0, GTK_MOVEMENT_PAGES, -1); + add_move_binding (binding_set, GDK_KP_Page_Up, 0, + GTK_MOVEMENT_PAGES, -1); + add_move_binding (binding_set, GDK_Page_Down, 0, GTK_MOVEMENT_PAGES, 1); - + add_move_binding (binding_set, GDK_KP_Page_Down, 0, + GTK_MOVEMENT_PAGES, 1); + /* Setting the cut/paste/copy anchor */ gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "set_anchor", 0); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_CONTROL_MASK, + "set_anchor", 0); + /* Deleting text */ gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0, "delete_from_cursor", 2, @@ -833,10 +870,17 @@ gtk_text_view_class_init (GtkTextViewClass *klass) "delete_from_cursor", 2, GTK_TYPE_ENUM, GTK_DELETE_WHITESPACE, GTK_TYPE_INT, 1); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_MOD1_MASK, + "delete_from_cursor", 2, + GTK_TYPE_ENUM, GTK_DELETE_WHITESPACE, + GTK_TYPE_INT, 1); gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_MOD1_MASK, "insert_at_cursor", 1, GTK_TYPE_STRING, " "); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, GDK_MOD1_MASK, + "insert_at_cursor", 1, + GTK_TYPE_STRING, " "); + gtk_binding_entry_add_signal (binding_set, GDK_backslash, GDK_MOD1_MASK, "delete_from_cursor", 2, GTK_TYPE_ENUM, GTK_DELETE_WHITESPACE, @@ -862,6 +906,8 @@ gtk_text_view_class_init (GtkTextViewClass *klass) /* Overwrite */ gtk_binding_entry_add_signal (binding_set, GDK_Insert, 0, "toggle_overwrite", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0, + "toggle_overwrite", 0); } void @@ -2168,7 +2214,7 @@ gtk_text_view_set_property (GObject *object, case PROP_WRAP_MODE: gtk_text_view_set_wrap_mode (text_view, g_value_get_enum (value)); break; - + case PROP_JUSTIFICATION: gtk_text_view_set_justification (text_view, g_value_get_enum (value)); break; @@ -3135,7 +3181,10 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event) retval = TRUE; } /* Pass through Tab as literal tab, unless Control is held down */ - else if (event->keyval == GDK_Tab && !(event->state & GDK_CONTROL_MASK)) + else if ((event->keyval == GDK_Tab || + event->keyval == GDK_KP_Tab || + event->keyval == GDK_ISO_Left_Tab) && + !(event->state & GDK_CONTROL_MASK)) { gtk_text_buffer_insert_interactive_at_cursor (get_buffer (text_view), "\t", 1, text_view->editable); @@ -3682,6 +3731,12 @@ gtk_text_view_check_cursor_blink (GtkTextView *text_view) return; #endif + if (text_view->layout == NULL) + return; + + if (!text_view->cursor_visible) + return; + if (text_view->layout != NULL && text_view->cursor_visible && GTK_WIDGET_HAS_FOCUS (text_view)) diff --git a/gtk/gtktooltips.c b/gtk/gtktooltips.c index 81858127bd..7bdf119d29 100644 --- a/gtk/gtktooltips.c +++ b/gtk/gtktooltips.c @@ -285,17 +285,6 @@ gtk_tooltips_set_tip (GtkTooltips *tooltips, } } -void -gtk_tooltips_set_colors (GtkTooltips *tooltips, - GdkColor *background, - GdkColor *foreground) -{ - g_return_if_fail (tooltips != NULL); - - g_warning ("gtk_tooltips_set_colors is deprecated and does nothing.\n" - "The colors for tooltips are now taken from the style."); -} - static gint gtk_tooltips_paint_window (GtkTooltips *tooltips) { @@ -521,3 +510,25 @@ gtk_tooltips_widget_remove (GtkWidget *widget, tooltipsdata); gtk_tooltips_destroy_data (tooltipsdata); } + +void +_gtk_tooltips_show_tip (GtkWidget *widget) +{ + /* Showing the tip from the keyboard */ + + /* FIXME this function is completely broken right now, + * popdown doesn't occur when it should. + */ + + GtkTooltipsData *tooltipsdata; + + tooltipsdata = gtk_tooltips_data_get (widget); + + if (tooltipsdata == NULL) + return; + + gtk_tooltips_set_active_widget (tooltipsdata->tooltips, + widget); + + gtk_tooltips_timeout (tooltipsdata->tooltips); +} diff --git a/gtk/gtktooltips.h b/gtk/gtktooltips.h index 609df3cd64..b88ae57d5d 100644 --- a/gtk/gtktooltips.h +++ b/gtk/gtktooltips.h @@ -66,6 +66,7 @@ struct _GtkTooltips guint delay : 30; guint enabled : 1; + guint have_grab : 1; gint timer_tag; gboolean use_sticky_delay; GTimeVal last_popdown; @@ -87,13 +88,11 @@ void gtk_tooltips_set_tip (GtkTooltips *tooltips, GtkWidget *widget, const gchar *tip_text, const gchar *tip_private); -void gtk_tooltips_set_colors (GtkTooltips *tooltips, - GdkColor *background, - GdkColor *foreground); GtkTooltipsData* gtk_tooltips_data_get (GtkWidget *widget); void gtk_tooltips_force_window (GtkTooltips *tooltips); +void _gtk_tooltips_show_tip (GtkWidget *widget); #ifdef __cplusplus } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ff9dfcfffc..3ff70a81c0 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -47,6 +47,7 @@ #include "gdk/gdkkeysyms.h" #include "gtkintl.h" #include "gtkaccessible.h" +#include "gtktooltips.h" #define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w) #define INIT_PATH_SIZE (512) @@ -112,6 +113,7 @@ enum { VISIBILITY_NOTIFY_EVENT, WINDOW_STATE_EVENT, POPUP_MENU, + SHOW_HELP, LAST_SIGNAL }; @@ -176,7 +178,11 @@ static void gtk_widget_style_set (GtkWidget *widget, GtkStyle *previous_style); static void gtk_widget_direction_changed (GtkWidget *widget, GtkTextDirection previous_direction); + static void gtk_widget_real_grab_focus (GtkWidget *focus_widget); +static void gtk_widget_real_show_help (GtkWidget *widget, + GtkWidgetHelpType help_type); + static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object, guint n_pspecs, GParamSpec **pspecs); @@ -214,7 +220,6 @@ static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget); static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface); static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor); - /* --- variables --- */ static gpointer parent_class = NULL; static guint widget_signals[LAST_SIGNAL] = { 0 }; @@ -226,6 +231,7 @@ static GSList *style_stack = NULL; static guint composite_child_stack = 0; static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR; static GParamSpecPool *style_property_spec_pool = NULL; + static GQuark quark_property_parser = 0; static GQuark quark_aux_info = 0; static GQuark quark_event_mask = 0; @@ -240,7 +246,6 @@ static GQuark quark_accessible_object = 0; GParamSpecPool *_gtk_widget_child_property_pool = NULL; GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL; - /* --- functions --- */ GtkType gtk_widget_get_type (void) @@ -378,7 +383,12 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->drag_motion = NULL; klass->drag_drop = NULL; klass->drag_data_received = NULL; - klass->get_accessible = gtk_widget_real_get_accessible; /* Accessibility support */ + + klass->show_help = gtk_widget_real_show_help; + + /* Accessibility support */ + klass->get_accessible = gtk_widget_real_get_accessible; + klass->no_expose_event = NULL; g_object_class_install_property (gobject_class, @@ -1021,6 +1031,13 @@ gtk_widget_class_init (GtkWidgetClass *klass) GTK_SIGNAL_OFFSET (GtkWidgetClass, popup_menu), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + widget_signals[SHOW_HELP] = + gtk_signal_new ("show_help", + GTK_RUN_LAST | GTK_RUN_ACTION, + GTK_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (GtkWidgetClass, show_help), + gtk_marshal_NONE__ENUM, + GTK_TYPE_NONE, 1, GTK_TYPE_WIDGET_HELP_TYPE); binding_set = gtk_binding_set_by_class (klass); gtk_binding_entry_add_signal (binding_set, GDK_F10, GDK_SHIFT_MASK, @@ -1028,6 +1045,24 @@ gtk_widget_class_init (GtkWidgetClass *klass) gtk_binding_entry_add_signal (binding_set, GDK_Menu, 0, "popup_menu", 0); + gtk_binding_entry_add_signal (binding_set, GDK_F1, GDK_CONTROL_MASK, + "show_help", 1, + GTK_TYPE_WIDGET_HELP_TYPE, + GTK_WIDGET_HELP_TOOLTIP); + gtk_binding_entry_add_signal (binding_set, GDK_KP_F1, GDK_CONTROL_MASK, + "show_help", 1, + GTK_TYPE_WIDGET_HELP_TYPE, + GTK_WIDGET_HELP_TOOLTIP); + + gtk_binding_entry_add_signal (binding_set, GDK_F1, GDK_SHIFT_MASK, + "show_help", 1, + GTK_TYPE_WIDGET_HELP_TYPE, + GTK_WIDGET_HELP_WHATS_THIS); + gtk_binding_entry_add_signal (binding_set, GDK_KP_F1, GDK_SHIFT_MASK, + "show_help", 1, + GTK_TYPE_WIDGET_HELP_TYPE, + GTK_WIDGET_HELP_WHATS_THIS); + gtk_widget_class_install_style_property (klass, g_param_spec_boolean ("interior_focus", _("Interior Focus"), @@ -3094,6 +3129,14 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget) } } +static void +gtk_widget_real_show_help (GtkWidget *widget, + GtkWidgetHelpType help_type) +{ + if (help_type == GTK_WIDGET_HELP_TOOLTIP) + _gtk_tooltips_show_tip (widget); +} + static gboolean gtk_widget_real_focus (GtkWidget *widget, GtkDirectionType direction) @@ -3110,7 +3153,6 @@ gtk_widget_real_focus (GtkWidget *widget, return FALSE; } - /** * gtk_widget_is_focus: * @widget: a #GtkWidget diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 597a385df7..f2c0fa75e3 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -78,6 +78,13 @@ typedef enum GTK_DOUBLE_BUFFERED = 1 << 21 } GtkWidgetFlags; +/* Kinds of widget-specific help */ +typedef enum +{ + GTK_WIDGET_HELP_TOOLTIP, + GTK_WIDGET_HELP_WHATS_THIS +} GtkWidgetHelpType; + /* Macro for casting a pointer to a GtkWidget or GtkWidgetClass pointer. * Macros for testing whether `widget' or `klass' are of type GTK_TYPE_WIDGET. */ @@ -391,7 +398,14 @@ struct _GtkWidgetClass /* Signals used only for keybindings */ void (* popup_menu) (GtkWidget *widget); - + + /* If a widget has multiple tooltips/whatsthis, it should show the + * one for the current focus location, or if that doesn't make + * sense, should cycle through them showing each tip alongside + * whatever piece of the widget it applies to. + */ + void (* show_help) (GtkWidget *widget, + GtkWidgetHelpType help_type); /* accessibility support */ diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index eb7e96a4f4..f787153a46 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -476,7 +476,9 @@ gtk_window_class_init (GtkWindowClass *klass) gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "activate_focus", 0); - + gtk_binding_entry_add_signal (binding_set, GDK_KP_Space, 0, + "activate_focus", 0); + gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "activate_default", 0); @@ -514,6 +516,9 @@ gtk_window_class_init (GtkWindowClass *klass) gtk_binding_entry_add_signal (binding_set, GDK_Tab, 0, "move_focus", 1, GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, 0, + "move_focus", 1, + GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD); gtk_binding_entry_add_signal (binding_set, GDK_ISO_Left_Tab, 0, "move_focus", 1, GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD); @@ -521,6 +526,9 @@ gtk_window_class_init (GtkWindowClass *klass) gtk_binding_entry_add_signal (binding_set, GDK_Tab, GDK_SHIFT_MASK, "move_focus", 1, GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, GDK_SHIFT_MASK, + "move_focus", 1, + GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD); gtk_binding_entry_add_signal (binding_set, GDK_ISO_Left_Tab, GDK_SHIFT_MASK, "move_focus", 1, GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD);