diff options
author | Owen Taylor <otaylor@src.gnome.org> | 1997-12-18 02:17:14 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1997-12-18 02:17:14 +0000 |
commit | d5d01a5af9aaa11762d7ba86760796df00af3786 (patch) | |
tree | c12bb7c7980b3177456cab8987755a976297b205 /gtk | |
parent | 65e63db01e93820093c2eb5169d5f8c0be3fe4e5 (diff) | |
download | gtk+-d5d01a5af9aaa11762d7ba86760796df00af3786.tar.gz |
It's all in the changelog. Well, almost all.
-owt
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtk.defs | 1428 | ||||
-rw-r--r-- | gtk/gtkaccelerator.c | 19 | ||||
-rw-r--r-- | gtk/gtkaccelerator.h | 1 | ||||
-rw-r--r-- | gtk/gtkcurve.c | 4 | ||||
-rw-r--r-- | gtk/gtkgamma.c | 4 | ||||
-rw-r--r-- | gtk/gtkhscrollbar.c | 2 | ||||
-rw-r--r-- | gtk/gtkinputdialog.c | 227 | ||||
-rw-r--r-- | gtk/gtkinputdialog.h | 3 | ||||
-rw-r--r-- | gtk/gtkmain.c | 156 | ||||
-rw-r--r-- | gtk/gtkmain.h | 2 | ||||
-rw-r--r-- | gtk/gtkmenu.c | 14 | ||||
-rw-r--r-- | gtk/gtkmenufactory.c | 20 | ||||
-rw-r--r-- | gtk/gtkmenuitem.c | 23 | ||||
-rw-r--r-- | gtk/gtkobject.c | 2 | ||||
-rw-r--r-- | gtk/gtkpixmap.c | 55 | ||||
-rw-r--r-- | gtk/gtkprogressbar.c | 2 | ||||
-rw-r--r-- | gtk/gtkrange.c | 45 | ||||
-rw-r--r-- | gtk/gtkrc.c | 4 | ||||
-rw-r--r-- | gtk/gtkruler.c | 4 | ||||
-rw-r--r-- | gtk/gtksignal.c | 14 | ||||
-rw-r--r-- | gtk/gtkstyle.c | 25 | ||||
-rw-r--r-- | gtk/gtktext.c | 34 | ||||
-rw-r--r-- | gtk/gtktooltips.c | 31 | ||||
-rw-r--r-- | gtk/gtktooltips.h | 3 | ||||
-rw-r--r-- | gtk/gtktypebuiltins.c | 6 | ||||
-rw-r--r-- | gtk/gtktypebuiltins.h | 70 | ||||
-rw-r--r-- | gtk/gtkviewport.c | 64 | ||||
-rw-r--r-- | gtk/gtkvscrollbar.c | 2 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 96 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 108 | ||||
-rw-r--r-- | gtk/gtkwindow.h | 2 | ||||
-rw-r--r-- | gtk/testgtk.c | 189 | ||||
-rw-r--r-- | gtk/testinput.c | 20 | ||||
-rw-r--r-- | gtk/testselection.c | 1 |
34 files changed, 2158 insertions, 522 deletions
diff --git a/gtk/gtk.defs b/gtk/gtk.defs index 0228e7a8bf..25d991ee73 100644 --- a/gtk/gtk.defs +++ b/gtk/gtk.defs @@ -1,4 +1,4 @@ -; -*- scheme -*- +;; -*- scheme -*- ;;; Gtk enums @@ -44,8 +44,8 @@ (automatic GTK_POLICY_AUTOMATIC)) (define-enum GtkUpdateType - (continous GTK_UPDATE_CONTINUOUS) - (discontinous GTK_UPDATE_DISCONTINUOUS) + (continuous GTK_UPDATE_CONTINUOUS) + (discontinuous GTK_UPDATE_DISCONTINUOUS) (delayed GTK_UPDATE_DELAYED)) (define-flags GtkAttachOptions @@ -122,6 +122,45 @@ (basic GTK_BASIC) (user-style GTK_USER_STYLE)) +(define-enum GtkSelectionMode + (single GTK_SELECTION_SINGLE) + (browse GTK_SELECTION_BROWSE) + (multiple GTK_SELECTION_MULTIPLE) + (extended GTK_SELECTION_EXTENDED)) + +(define-enum GtkCurveType + (linear GTK_CURVE_TYPE_LINEAR) + (spline GTK_CURVE_TYPE_SPLINE) + (free GTK_CURVE_TYPE_FREE)) + +(define-enum GtkFundamentalType + (invalid GTK_TYPE_INVALID) + (none GTK_TYPE_NONE) + (char GTK_TYPE_CHAR) + (bool GTK_TYPE_BOOL) + (int GTK_TYPE_INT) + (uint GTK_TYPE_UINT) + (long GTK_TYPE_LONG) + (ulong GTK_TYPE_ULONG) + (float GTK_TYPE_FLOAT) + (string GTK_TYPE_STRING) + (enum GTK_TYPE_ENUM) + (flags GTK_TYPE_FLAGS) + (boxed GTK_TYPE_BOXED) + (foreign GTK_TYPE_FOREIGN) + (callback GTK_TYPE_CALLBACK) + (args GTK_TYPE_ARGS) + (pointer GTK_TYPE_POINTER) + (signal GTK_TYPE_SIGNAL) + (c-callback GTK_TYPE_C_CALLBACK) + (object GTK_TYPE_OBJECT)) + +(define-enum GtkJustification + (left GTK_JUSTIFY_LEFT) + (right GTK_JUSTIFY_RIGHT) + (center GTK_JUSTIFY_CENTER) + (fill GTK_JUSTIFY_FILL)) + ;;; Gdk enums (define-enum GdkWindowType @@ -322,9 +361,9 @@ ;;; Gdk boxed types -;(define-boxed GdkPoint -; gdk_point_copy -; gdk_point_destroy) + ;(define-boxed GdkPoint + ; gdk_point_copy + ; gdk_point_destroy) (define-boxed GdkColormap gdk_colormap_ref @@ -344,247 +383,330 @@ (define-boxed GdkEvent gdk_event_copy - gdk_event_free) + gdk_event_free + "sizeof(GdkEvent)") + +(define-boxed GdkColor + gdk_color_copy + gdk_color_free + "sizeof(GdkColor)") + +(define-func gtk_style_get_white_interp + GdkColor + ((GtkStyle style))) ;;; Functions +;; Gdk + +(define-func gdk_font_load + GdkFont + ((string name))) + +;; main + (define-func gtk_exit none - (int code 0)) + ((int code (= "0")))) + +(define-func gtk_main + none + ()) + +(define-func gtk_main_quit + none + ()) + +(define-func gtk_main_iteration + bool + ()) + +(define-func gtk_timeout_add_interp + int + ((int interval) + (callback function))) + +(define-func gtk_timeout_remove + none + ((int tag))) + +(define-func gtk_idle_add_interp + int + ((callback function))) + +(define-func gtk_idle_remove + none + ((int tag))) + +(define-func gtk_input_add_interp + int + ((int source) + (GdkInputCondition condition) + (callback callback))) + +(define-func gtk_input_remove + none + ((int tag))) (define-func gtk_rc_parse none - (string file)) + ((string file))) (define-func g_mem_chunk_info - none) + none + ()) ;; GtkObject (define-func gtk_object_destroy none - (GtkObject object)) + ((GtkObject object))) + +;; Signals + +(define-func gtk_signal_connect_interp + int + ((GtkObject object) + (string name) + (callback func) + (bool after (= "0")))) ;; GtkWidget -(define-object GtkWidget (GtkObject)) +(define-object GtkWidget (GtkObject) + (fields + (GtkStyle style))) + +(define-func gtk_grab_add + none + ((GtkWidget widget))) + +(define-func gtk_grab_remove + none + ((GtkWidget widget))) (define-func GTK_WIDGET_STATE GtkStateType - (GtkWidget widget)) + ((GtkWidget widget))) (define-func GTK_WIDGET_FLAGS GtkWidgetFlags - (GtkWidget widget)) + ((GtkWidget widget))) (define-func GTK_WIDGET_SET_FLAGS none - (GtkWidget widget) - (GtkWidgetFlags flags)) + ((GtkWidget widget) + (GtkWidgetFlags flags))) (define-func GTK_WIDGET_UNSET_FLAGS none - (GtkWidget widget) - (GtkWidgetFlags flags)) + ((GtkWidget widget) + (GtkWidgetFlags flags))) (define-func gtk_widget_destroy none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_unparent none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_show none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_hide none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_map none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_unmap none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_realize none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_unrealize none - (GtkWidget widget)) + ((GtkWidget widget))) -;(define-func gtk_widget_install_accelerator -; none -; (GtkWidget widget) -; (GtkAcceleratorTable table) -; (string signal_name) -; (char key) -; (...)) + ;(define-func gtk_widget_install_accelerator + ; none + ; ((GtkWidget widget) + ; (GtkAcceleratorTable table) + ; (string signal_name) + ; (char key) + ; (...))) (define-func gtk_widget_remove_accelerator none - (GtkWidget widget) - (GtkAcceleratorTable table) - (string signal_name)) + ((GtkWidget widget) + (GtkAcceleratorTable table) + (string signal_name))) -;(define-func gtk_widget_event -; bool -; (GtkWidget widget) -; (GdkEvent event)) +(define-func gtk_widget_event + bool + ((GtkWidget widget) + (GdkEvent event))) (define-func gtk_widget_activate none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_reparent none - (GtkWidget widget) - (GtkWidget new_parent)) + ((GtkWidget widget) + (GtkWidget new_parent))) (define-func gtk_widget_popup none - (GtkWidget widget) - (int x) - (int y)) + ((GtkWidget widget) + (int x) + (int y))) (define-func gtk_widget_basic bool - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_grab_focus none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_grab_default none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_restore_state none - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_set_name none - (GtkWidget widget) - (string name)) + ((GtkWidget widget) + (string name))) (define-func gtk_widget_get_name static_string - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_set_state none - (GtkWidget widget) - (GtkStateType state)) + ((GtkWidget widget) + (GtkStateType state))) (define-func gtk_widget_set_sensitive none - (GtkWidget widget) - (bool sensitive)) + ((GtkWidget widget) + (bool sensitive))) (define-func gtk_widget_set_style none - (GtkWidget widget) - (GtkStyle style)) + ((GtkWidget widget) + (GtkStyle style))) (define-func gtk_widget_set_uposition none - (GtkWidget widget) - (int x) - (int y)) + ((GtkWidget widget) + (int x) + (int y))) (define-func gtk_widget_set_usize none - (GtkWidget widget) - (int height) - (int width)) + ((GtkWidget widget) + (int height) + (int width))) (define-func gtk_widget_set_events none - (GtkWidget widget) - (GdkEventMask events)) + ((GtkWidget widget) + (GdkEventMask events))) (define-func gtk_widget_set_extension_events none - (GtkWidget widget) - (GdkEventMask events)) + ((GtkWidget widget) + (GdkEventMask events))) (define-func gtk_widget_get_toplevel GtkWidget - (GtkWidget widget)) + ((GtkWidget widget))) -;(define-func gtk_widget_get_ancestor -; GtkWidget -; (GtkWidget widget) -; (GtkType type)) + ;(define-func gtk_widget_get_ancestor + ; GtkWidget + ; ((GtkWidget widget) + ; (GtkType type))) (define-func gtk_widget_get_colormap GdkColormap - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_get_visual GdkVisual - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_get_style GtkStyle - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_get_events GdkEventMask - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_get_extension_events GdkEventMask - (GtkWidget widget)) + ((GtkWidget widget))) (define-func gtk_widget_push_colormap none - (GdkColormap cmap)) + ((GdkColormap cmap))) (define-func gtk_widget_push_visual none - (GdkVisual visual)) + ((GdkVisual visual))) (define-func gtk_widget_push_style none - (GtkStyle style)) + ((GtkStyle style))) (define-func gtk_widget_pop_colormap - none) + none + ()) (define-func gtk_widget_pop_visual - none) + none + ()) (define-func gtk_widget_pop_style - none) + none + ()) (define-func gtk_widget_set_default_colormap none - (GdkColormap cmap)) + ((GdkColormap cmap))) (define-func gtk_widget_set_default_visual none - (GdkVisual visual)) + ((GdkVisual visual))) (define-func gtk_widget_set_default_style none - (GtkStyle style)) + ((GtkStyle style))) (define-func gtk_widget_get_default_colormap - GdkColormap) + GdkColormap + ()) (define-func gtk_widget_get_default_visual - GdkVisual) + GdkVisual + ()) (define-func gtk_widget_get_default_style - GtkStyle) + GtkStyle + ()) ;;; Container @@ -592,49 +714,43 @@ (define-func gtk_container_border_width none - (GtkContainer container) - (int border_width)) + ((GtkContainer container) + (int border_width))) (define-func gtk_container_add none - (GtkContainer container) - (GtkWidget widget)) + ((GtkContainer container) + (GtkWidget widget))) (define-func gtk_container_remove none - (GtkContainer container) - (GtkWidget widget)) + ((GtkContainer container) + (GtkWidget widget))) (define-func gtk_container_disable_resize none - (GtkContainer container)) + ((GtkContainer container))) (define-func gtk_container_enable_resize none - (GtkContainer container)) + ((GtkContainer container))) (define-func gtk_container_block_resize none - (GtkContainer container)) + ((GtkContainer container))) (define-func gtk_container_unblock_resize none - (GtkContainer container)) + ((GtkContainer container))) (define-func gtk_container_need_resize bool - (GtkContainer container) - (GtkWidget widget)) - -(define-func gtk_container_check_resize - none - (GtkContainer container) - (GtkWidget widget)) + ((GtkContainer container))) (define-func gtk_container_focus GtkDirectionType - (GtkContainer container) - (GtkDirectionType direction)) + ((GtkContainer container) + (GtkDirectionType direction))) ;;; Bin @@ -646,165 +762,1101 @@ (define-func gtk_window_new GtkWidget - (GtkWindowType type)) + ((GtkWindowType type))) (define-func gtk_window_set_title none - (GtkWindow window) - (string title)) + ((GtkWindow window) + (string title))) (define-func gtk_window_set_focus none - (GtkWindow window) - (GtkWidget focus)) + ((GtkWindow window) + (GtkWidget focus))) (define-func gtk_window_set_default none - (GtkWindow window) - (GtkWidget default)) + ((GtkWindow window) + (GtkWidget default))) (define-func gtk_window_set_policy none - (GtkWindow window) - (bool allow_shrink) - (bool allow_grow) - (bool auto_shrink)) + ((GtkWindow window) + (bool allow_shrink) + (bool allow_grow) + (bool auto_shrink))) (define-func gtk_window_add_accelerator_table none - (GtkWindow window) - (GtkAcceleratorTable table)) + ((GtkWindow window) + (GtkAcceleratorTable table))) (define-func gtk_window_remove_accelerator_table none - (GtkWindow window) - (GtkAcceleratorTable table)) + ((GtkWindow window) + (GtkAcceleratorTable table))) (define-func gtk_window_position none - (GtkWindow window) - (GtkWindowPosition position)) + ((GtkWindow window) + (GtkWindowPosition position))) ;;; Box (define-object GtkBox (GtkContainer)) +(define-func gtk_box_pack_start + none + ((GtkBox box) + (GtkWidget child) + (bool expand (= "TRUE")) + (bool fill (= "TRUE")) + (int padding (= "0")))) + +(define-func gtk_box_pack_end + none + ((GtkBox box) + (GtkWidget child) + (bool expand (= "TRUE")) + (bool fill (= "TRUE")) + (int padding (= "0")))) + +(define-func gtk_box_pack_start_defaults + none + ((GtkBox box) + (GtkWidget child))) + +(define-func gtk_box_pack_end_defaults + none + ((GtkBox box) + (GtkWidget child))) + +(define-func gtk_box_set_homogeneous + none + ((GtkBox box) + (bool homogenous))) + +(define-func gtk_box_set_spacing + none + ((GtkBox box) + (int spacing))) + ;;; Table (define-object GtkTable (GtkContainer)) +(define-func gtk_table_new + GtkWidget + ((int rows) + (int columns) + (bool homogenous))) + +(define-func gtk_table_attach + none + ((GtkTable table) + (GtkWidget child) + (int left_attach) + (int right_attach) + (int top_attach) + (int bottom_attach) + (GtkAttachOptions xoptions (= "GTK_EXPAND|GTK_FILL")) + (GtkAttachOptions yoptions (= "GTK_EXPAND|GTK_FILL")) + (int xpadding (= "0")) + (int ypadding (= "0")))) + +(define-func gtk_table_attach_defaults + none + ((GtkTable table) + (GtkWidget child) + (int left_attach) + (int right_attach) + (int top_attach) + (int bottom_attach))) + +(define-func gtk_table_set_row_spacing + none + ((GtkTable table) + (int row) + (int spacing))) + +(define-func gtk_table_set_col_spacing + none + ((GtkTable table) + (int column) + (int spacing))) + +(define-func gtk_table_set_row_spacings + none + ((GtkTable table) + (int spacing))) + +(define-func gtk_table_set_col_spacings + none + ((GtkTable table) + (int spacing))) + ;;; Button (define-object GtkButton (GtkContainer)) +(define-func gtk_button_new + GtkWidget + ()) + +(define-func gtk_button_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_button_pressed + none + ((GtkButton button))) + +(define-func gtk_button_released + none + ((GtkButton button))) + +(define-func gtk_button_clicked + none + ((GtkButton button))) + +(define-func gtk_button_enter + none + ((GtkButton button))) + +(define-func gtk_button_leave + none + ((GtkButton button))) + ;;; ToggleButton (define-object GtkToggleButton (GtkButton)) +(define-func gtk_toggle_button_new + GtkWidget + ()) + +(define-func gtk_toggle_button_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_toggle_button_set_mode + none + ((GtkToggleButton toggle_button) + (bool draw_indicator))) + +(define-func gtk_toggle_button_set_state + none + ((GtkToggleButton toggle_button) + (bool state))) + +(define-func gtk_toggle_button_toggled + none + ((GtkToggleButton toggle_button))) + ;;; CheckButton (define-object GtkCheckButton (GtkToggleButton)) +(define-func gtk_check_button_new + GtkWidget + ()) + +(define-func gtk_check_button_new_with_label + GtkWidget + ((string label))) + ;;; RadioButton (define-object GtkRadioButton (GtkCheckButton)) +(define-func gtk_radio_button_new_interp + GtkWidget + ((GtkRadioButton group (null-ok)))) -;; misc +(define-func gtk_radio_button_new_with_label_interp + GtkWidget + ((GtkRadioButton group (null-ok)) + (string label))) +;;; Misc -(define-func gtk_button_new_with_label +(define-object GtkMisc (GkWidget)) + +(define-func gtk_misc_set_alignment + none + ((GtkMisc misc) + (float xalign) + (float yalign))) + +(define-func gtk_misc_set_padding + none + ((GtkMisc misc) + (int xpad) + (int ypad))) + +;;; Label + +(define-object GtkLabel (GtkMisc)) + +(define-func gtk_label_new GtkWidget - (string label)) + ((string str))) + +(define-func gtk_label_set + none + ((GtkLabel label) + (string str))) + +(define-func gtk_label_get_interp + static_string + ((GtkLabel label))) + +;; VBox + +(define-object GtkVBox (GtkBox)) (define-func gtk_vbox_new GtkWidget - (bool homogenous) - (int spacing)) + ((bool homogenous) + (int spacing))) + +;; HBox + +(define-object GtkHBox (GtkBox)) (define-func gtk_hbox_new GtkWidget - (bool homogenous) - (int spacing)) + ((bool homogenous) + (int spacing))) + +;; Separator + +(define-object GtkSeparator (GtkWidget)) + +;; HSeparator + +(define-object GtkHSeparator (GtkSeparator)) (define-func gtk_hseparator_new - GtkWidget) + GtkWidget + ()) -(define-func gtk_box_pack_start +;; VSeparator + +(define-object GtkVSeparator (GtkSeparator)) + +(define-func gtk_vseparator_new + GtkWidget + ()) + +;; Frame + +(define-object GtkFrame (GtkBin)) + +(define-func gtk_frame_new + GtkWidget + ((string label (null-ok)))) + +(define-func gtk_frame_set_label none - (GtkBox box) - (GtkWidget child) - (bool expand) - (bool fill) - (int padding)) + ((GtkFrame frame) + (string label))) -(define-func gtk_table_new +(define-func gtk_frame_set_label_align + none + ((GtkFrame frame) + (float xalign) + (float yalign))) + +(define-func gtk_frame_set_shadow_type + none + ((GtkFrame frame) + (GtkShadowType type))) + +;; Progress Bar + +(define-object GtkProgressBar (GtkWidget) + (fields + (float percentage))) + +(define-func gtk_progress_bar_new GtkWidget - (int rows) - (int columns) - (bool homogenous)) + ()) -(define-func gtk_table_attach +(define-func gtk_progress_bar_update none - (GtkTable table) - (GtkWidget child) - (int left_attach) - (int right_attach) - (int top_attach) - (int bottom_attach) - (GtkAttachOptions xoptions) - (GtkAttachOptions yoptions) - (int xpadding) - (int ypadding)) + ((GtkProgressBar progress_bar) + (float percentage))) -(define-func gtk_table_attach_defaults + ;(define-func gtk_progress_bar_percentage + ; float + ; ((GtkProgressBar progress_bar))) + +;; Tooltips + +(define-boxed GtkTooltips + gtk_tooltips_ref + gtk_tooltips_unref) + +(define-func gtk_tooltips_new + GtkTooltips + ()) + +(define-func gtk_tooltips_destroy none - (GtkTable table) - (GtkWidget child) - (int left_attach) - (int right_attach) - (int top_attach) - (int bottom_attach)) + ((GtkTooltips tooltips))) -(define-func gtk_table_set_row_spacing +(define-func gtk_tooltips_enable none - (GtkTable table) - (int row) - (int spacing)) + ((GtkTooltips tooltips))) -(define-func gtk_table_set_col_spacing +(define-func gtk_tooltips_disable none - (GtkTable table) - (int col) - (int spacing)) + ((GtkTooltips tooltips))) -(define-func gtk_table_set_row_spacings +(define-func gtk_tooltips_set_delay none - (GtkTable table) - (int spacing)) + ((GtkTooltips tooltips) + (int delay))) -(define-func gtk_table_set_col_spacings +(define-func gtk_tooltips_set_tips none - (GtkTable table) - (int spacing)) + ((GtkTooltips tooltips) + (GtkWidget widget) + (string tips_text (null-ok)))) -(define-func gtk_toggle_button_new_with_label +(define-func gtk_tooltips_set_colors + none + ((GtkTooltips tooltips) + (GdkColor background) + (GdkColor foreground))) + +;; MenuShell + +(define-object GtkMenuShell (GtkContainer)) + +(define-func gtk_menu_shell_append + none + ((GtkMenuShell menu_shell) + (GtkWidget child))) + +(define-func gtk_menu_shell_prepend + none + ((GtkMenuShell menu_shell) + (GtkWidget child))) + +(define-func gtk_menu_shell_insert + none + ((GtkMenuShell menu_shell) + (GtkWidget child) + (int position))) + +(define-func gtk_menu_shell_deactivate + none + ((GtkMenuShell menu_shell))) + +;; MenuBar + +(define-object GtkMenuBar (GtkMenuShell)) + +(define-func gtk_menu_bar_new GtkWidget - (string label)) + ()) -(define-func gtk_check_button_new_with_label +(define-func gtk_menu_bar_append + none + ((GtkMenuBar menu_bar) + (GtkWidget child))) + +(define-func gtk_menu_bar_prepend + none + ((GtkMenuBar menu_bar) + (GtkWidget child))) + +(define-func gtk_menu_bar_insert + none + ((GtkMenuBar menu_bar) + (GtkWidget child) + (int position))) + +;; Menu + +(define-object GtkMenu (GtkMenuShell)) + +(define-func gtk_menu_new GtkWidget - (string label)) + ()) + +(define-func gtk_menu_append + none + ((GtkMenu menu) + (GtkWidget child))) + +(define-func gtk_menu_prepend + none + ((GtkMenu menu) + (GtkWidget child))) + +(define-func gtk_menu_insert + none + ((GtkMenu menu) + (GtkWidget child) + (int position))) + +(define-func gtk_menu_popup_interp + none + ((GtkMenu menu) + (GtkWidget parent_menu_shell) + (GtkWidget parent_menu_item) + (int button) + (int activate_time))) -(define-func gtk_radio_button_new_with_label_from_widget +(define-func gtk_menu_popdown + none + ((GtkMenu menu))) + +(define-func gtk_menu_get_active GtkWidget - (GtkRadioButton group) - (string label)) + ((GtkMenu menu))) -(define-func gtk_label_new +(define-func gtk_menu_set_active + none + ((GtkMenu menu) + (int index))) + +(define-func gtk_menu_set_accelerator_table + none + ((GtkMenu menu) + (GtkAcceleratorTable table))) + + +;; Item + +(define-object GtkItem (GtkBin)) + +(define-func gtk_item_select + none + ((GtkItem item))) + +(define-func gtk_item_deselect + none + ((GtkItem item))) + +(define-func gtk_item_toggle + none + ((GtkItem item))) + +;; MenuItem + +(define-object GtkMenuItem (GtkItem)) + +(define-func gtk_menu_item_new GtkWidget - (string label)) + ()) -(define-func gtk_frame_new +(define-func gtk_menu_item_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_menu_item_set_submenu + none + ((GtkMenuItem menu_item) + (GtkWidget submenu))) + +(define-func gtk_menu_item_set_placement + none + ((GtkMenuItem menu_item) + (GtkSubmenuPlacement placement))) + +(define-func gtk_menu_item_accelerator_size + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_configure + none + ((GtkMenuItem menu_item) + (bool show_toggle_indicator) + (bool show_submenu_indicator))) + +(define-func gtk_menu_item_select + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_deselect + none + ((GtkMenuItem menu_item))) + +(define-func gtk_menu_item_activate + none + ((GtkMenuItem menu_item))) + +;; CheckMenuItem + +(define-object GtkCheckMenuItem (GtkMenuItem)) + +(define-func gtk_check_menu_item_new + GtkWidget + ()) + +(define-func gtk_check_menu_item_new_with_label GtkWidget - (string label)) + ((string label))) + +(define-func gtk_check_menu_item_set_state + none + ((GtkCheckMenuItem check_menu_item) + (bool state))) + +(define-func gtk_check_menu_item_toggled + none + ((GtkCheckMenuItem check_menu_item))) + +;; RadioMenuItem + +(define-object GtkRadioMenuItem (GtkCheckMenuItem)) + +(define-func gtk_radio_menu_item_new_interp + GtkWidget + ((GtkRadioMenuItem group (null-ok)))) + +(define-func gtk_radio_menu_item_new_with_label_interp + GtkWidget + ((GtkRadioMenuItem group (null-ok)) + (string label))) + +;; OptionMenu + +(define-object GtkOptionMenu (GtkButton)) + +(define-func gtk_option_menu_new + GtkWidget + ()) + +(define-func gtk_option_menu_get_menu + GtkWidget + ((GtkOptionMenu option_menu))) + +(define-func gtk_option_menu_set_menu + none + ((GtkOptionMenu option_menu) + (GtkWidget menu))) + +(define-func gtk_option_menu_remove_menu + none + ((GtkOptionMenu option_menu))) + +(define-func gtk_option_menu_set_history + none + ((GtkOptionMenu option_menu) + (int index))) + +;; Pixmaps + +(define-object GtkPixmap (GtkMisc)) + +(define-func gtk_pixmap_new_interp + GtkWidget + ((string xpm_file) + (GtkWidget intended_parent))) + +;; Data + +(define-object GtkData (GtkObject)) + +;; Adjustment + +(define-object GtkAdjustment (GtkData)) + +(define-func gtk_adjustment_new + GtkObject + ((float value) + (float lower) + (float upper) + (float step_increment) + (float page_increment) + (float page_size))) + +;; ScrolledWidow + +(define-object GtkScrolledWindow (GtkContainer)) + +(define-func gtk_scrolled_window_new + GtkWidget + ((GtkAdjustment hadjustment (null-ok) (= "NULL")) + (GtkAdjustment vadjustment (null-ok) (= "NULL")))) + +(define-func gtk_scrolled_window_get_hadjustment + GtkAdjustment + ((GtkScrolledWindow scrolled_window))) + +(define-func gtk_scrolled_window_get_vadjustment + GtkAdjustment + ((GtkScrolledWindow scrolled_window))) + +(define-func gtk_scrolled_window_set_policy + none + ((GtkScrolledWindow scrolled_window) + (GtkPolicyType hscrollbar_policy) + (GtkPolicyType vscrollbar_policy))) + +;; ListItem + +(define-object GtkListItem (GtkItem)) + +(define-func gtk_list_item_new + GtkWidget + ()) + +(define-func gtk_list_item_new_with_label + GtkWidget + ((string label))) + +(define-func gtk_list_item_select + none + ((GtkListItem list_item))) + +(define-func gtk_list_item_deselect + none + ((GtkListItem list_item))) + +;; List + +(define-object GtkList (GtkContainer)) + +(define-func gtk_list_new + GtkWidget + ()) + +(define-func gtk_list_append_item + none + ((GtkList list) + (GtkListItem item))) + +(define-func gtk_list_prepend_item + none + ((GtkList list) + (GtkListItem item))) + +;; XXX many missing + +(define-func gtk_list_clear_items + none + ((GtkList list) + (int start) + (int end))) + +(define-func gtk_list_select_item + none + ((GtkList list) + (int item))) + +(define-func gtk_list_unselect_item + none + ((GtkList list) + (int item))) + +(define-func gtk_list_select_child + none + ((GtkList list) + (GtkWidget child))) + +(define-func gtk_list_unselect_child + none + ((GtkList list) + (GtkWidget child))) + +(define-func gtk_list_child_position + int + ((GtkList list) + (GtkWidget child))) + +(define-func gtk_list_set_selection_mode + none + ((GtkList list) + (GtkSelectionMode mode))) + +;; Notebook + +(define-object GtkNotebook (GtkContainer) + (fields + (GtkPositionType tab_pos))) + +(define-func gtk_notebook_new + GtkWidget + ()) + +(define-func gtk_notebook_append_page + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label))) + +(define-func gtk_notebook_prepend_page + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label))) + +(define-func gtk_notebook_insert_page + none + ((GtkNotebook notebook) + (GtkWidget child) + (GtkWidget tab_label) + (int position))) + +(define-func gtk_notebook_remove_page + none + ((GtkNotebook notebook) + (int page_num))) + +(define-func gtk_notebook_current_page + int + ((GtkNotebook notebook))) + +(define-func gtk_notebook_set_page + none + ((GtkNotebook notebook) + (int page_num))) + +(define-func gtk_notebook_next_page + none + ((GtkNotebook notebook))) + +(define-func gtk_notebook_prev_page + none + ((GtkNotebook notebook))) + +(define-func gtk_notebook_set_tab_pos + none + ((GtkNotebook notebook) + (GtkPositionType pos))) + +(define-func gtk_notebook_set_show_tabs + none + ((GtkNotebook notebook) + (bool show_tabs))) + +(define-func gtk_notebook_set_show_border + none + ((GtkNotebook notebook) + (bool show_border))) + +;; Entry + +(define-object GtkEntry (GtkWidget)) + +(define-func gtk_entry_new + GtkWidget + ()) + +(define-func gtk_entry_set_text + none + ((GtkEntry entry) + (string text))) + +(define-func gtk_entry_append_text + none + ((GtkEntry entry) + (string text))) + +(define-func gtk_entry_prepend_text + none + ((GtkEntry entry) + (string text))) + +(define-func gtk_entry_set_position + none + ((GtkEntry entry) + (int position))) + +(define-func gtk_entry_get_text + static_string + ((GtkEntry entry))) + +;; Text + +(define-object GtkText (GtkWidget)) + +(define-func gtk_text_new + GtkWidget + ((GtkAdjustment hadj (null-ok)) + (GtkAdjustment vadj (null-ok)))) + +(define-func gtk_text_set_editable + none + ((GtkText text) + (bool editable))) + +(define-func gtk_text_set_adjustments + none + ((GtkText text) + (GtkAdjustment hadj) + (GtkAdjustment vadj))) + +(define-func gtk_text_set_point + none + ((GtkText text) + (uint index))) + +(define-func gtk_text_get_point + uint + ((GtkText text))) + +(define-func gtk_text_get_length + uint + ((GtkText text))) + +(define-func gtk_text_freeze + none + ((GtkText text))) + +(define-func gtk_text_thaw + none + ((GtkText text))) + +(define-func gtk_text_insert + none + ((GtkText text) + (GdkFont font (null-ok)) + (GdkColor fore (null-ok)) + (GdkColor back (null-ok)) + (string chars) + (int length))) + +(define-func gtk_text_backward_delete + none + ((GtkText text) + (uint nchars))) + +(define-func gtk_text_foreward_delete + none + ((GtkText text) + (uint nchars))) + +;; Alignment + +(define-object GtkAlignment (GtkBin)) + +(define-func gtk_alignment_new + GtkWidget + ((float xalign) + (float yalign) + (float xscale) + (float yscale))) + +(define-func gtk_alignment_set + none + ((GtkAlignment alignment) + (float xalign) + (float yalign) + (float xscale) + (float yscale))) + +;; Color + + ; XXX lots missing + +(define-func gdk_color_parse_interp + GdkColor + ((string spec))) + +;; Preview + +(define-object GtkPreview (GtkWidget)) + +;; XXX lots missing + +(define-func gtk_preview_set_install_cmap + none + ((bool install_cmap))) + +(define-func gtk_preview_set_reserved + none + ((int nreserved))) + +(define-func gtk_preview_get_visual + GdkVisual + ()) + +(define-func gtk_preview_get_cmap + GdkColormap + ()) + +;; ColorSelectionDialog + +(define-object GtkColorSelectionDialog (GtkWindow) + (fields + (GtkWidget colorsel) + (GtkWidget main_vbox) + (GtkWidget ok_button) + (GtkWidget reset_button) + (GtkWidget cancel_button) + (GtkWidget help_button))) + +(define-func gtk_color_selection_dialog_new + GtkWidget + ((string title))) + +;; ColorSelection + +(define-object GtkColorSelection (GtkVBox)) + +(define-func gtk_color_selection_new + GtkWidget + ()) + +(define-func gtk_color_selection_set_update_policy + none + ((GtkColorSelection colorsel) + (GtkUpdateType policy))) + +(define-func gtk_color_selection_set_opacity + none + ((GtkColorSelection colorsel) + (bool use_opacity))) + +;; Range + +(define-object GtkRange (GtkWidget)) + +(define-func gtk_range_get_adjustment + GtkAdjustment + ((GtkRange range))) + +(define-func gtk_range_set_update_policy + none + ((GtkRange range) + (GtkUpdateType policy))) + +(define-func gtk_range_set_adjustment + none + ((GtkRange range) + (GtkAdjustment adjustment))) + +;; Scale + +(define-object GtkScale (GtkRange)) + +(define-func gtk_scale_set_digits + none + ((GtkScale scale) + (bool digits))) + +(define-func gtk_scale_set_draw_value + none + ((GtkScale scale) + (bool draw_value))) + +(define-func gtk_scale_set_value_pos + none + ((GtkScale scale) + (GtkPositionType pos))) + +;; HScale + +(define-object GtkHScale (GtkScale)) + +(define-func gtk_hscale_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; VScale + +(define-object GtkVScale (GtkScale)) + +(define-func gtk_vscale_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; Scrollbar + +(define-object GtkScrollbar (GtkRange)) + +;; HScrollbar + +(define-object GtkHScrollbar (GtkScrollbar)) + +(define-func gtk_hscrollbar_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; VScrollbar + +(define-object GtkVScrollbar (GtkScrollbar)) + +(define-func gtk_vscrollbar_new + GtkWidget + ((GtkAdjustment adjustment))) + +;; Dialog + +(define-object GtkDialog (GtkWindow) + (fields + (GtkWidget vbox) + (GtkWidget action_area))) + +(define-func gtk_dialog_new + GtkWidget + ()) + +;; Paned + +(define-object GtkPaned (GtkContainer)) + +(define-func gtk_paned_add1 + none + ((GtkPaned paned) + (GtkWidget child))) + +(define-func gtk_paned_add2 + none + ((GtkPaned paned) + (GtkWidget child))) + +(define-func gtk_paned_handle_size + none + ((GtkPaned paned) + (int size))) + +(define-func gtk_paned_gutter_size + none + ((GtkPaned paned) + (int size))) + +;; HPaned + +(define-object GtkHPaned (GtkPaned)) + +(define-func gtk_hpaned_new + GtkWidget + ()) + +;; VPaned + +(define-object GtkVPaned (GtkPaned)) + +(define-func gtk_vpaned_new + GtkWidget + ()) + +;;; hack + +;(define-func panel_register_toy +; none +; ((gpointer panel) +; (GtkWidget applet) +; (string id) +; (string params) +; (int x) +; (int y) +; (int flags))) + +;(define-func panel_quit +; none +; ((gpointer panel))) + +;(define-func panel_new_applet +; none +; ((gpointer panel) +; (string applet) +; (string params))) diff --git a/gtk/gtkaccelerator.c b/gtk/gtkaccelerator.c index a06a06a995..cd8b3a7247 100644 --- a/gtk/gtkaccelerator.c +++ b/gtk/gtkaccelerator.c @@ -95,17 +95,6 @@ gtk_accelerator_table_find (GtkObject *object, return NULL; } -void -gtk_accelerator_table_destroy (GtkAcceleratorTable *table) -{ - g_return_if_fail (table != NULL); - g_return_if_fail (table->ref_count <= 0); - - tables = g_slist_remove (tables, table); - gtk_accelerator_table_clean (table); - g_free (table); -} - GtkAcceleratorTable* gtk_accelerator_table_ref (GtkAcceleratorTable *table) { @@ -122,7 +111,11 @@ gtk_accelerator_table_unref (GtkAcceleratorTable *table) table->ref_count -= 1; if (table->ref_count <= 0) - gtk_accelerator_table_destroy (table); + { + tables = g_slist_remove (tables, table); + gtk_accelerator_table_clean (table); + g_free (table); + } } void @@ -322,7 +315,7 @@ gtk_accelerator_table_init (GtkAcceleratorTable *table) for (i = 0; i < 256; i++) table->entries[i] = NULL; - table->ref_count = 0; + table->ref_count = 1; table->modifier_mask = gtk_accelerator_table_default_mod_mask; } diff --git a/gtk/gtkaccelerator.h b/gtk/gtkaccelerator.h index 975196a0ec..35fdc2d261 100644 --- a/gtk/gtkaccelerator.h +++ b/gtk/gtkaccelerator.h @@ -46,7 +46,6 @@ GtkAcceleratorTable* gtk_accelerator_table_find (GtkObject *object, guchar accelerator_key, guint8 accelerator_mods); -void gtk_accelerator_table_destroy (GtkAcceleratorTable *table); GtkAcceleratorTable *gtk_accelerator_table_ref (GtkAcceleratorTable *table); void gtk_accelerator_table_unref (GtkAcceleratorTable *table); void gtk_accelerator_table_install (GtkAcceleratorTable *table, diff --git a/gtk/gtkcurve.c b/gtk/gtkcurve.c index d2b6e08c84..93efd10150 100644 --- a/gtk/gtkcurve.c +++ b/gtk/gtkcurve.c @@ -296,7 +296,7 @@ gtk_curve_graph_events (GtkWidget *widget, GdkEvent *event, GtkCurve *c) { case GDK_CONFIGURE: if (c->pixmap) - gdk_pixmap_destroy (c->pixmap); + gdk_pixmap_unref (c->pixmap); c->pixmap = 0; /* fall through */ case GDK_EXPOSE: @@ -849,7 +849,7 @@ gtk_curve_destroy (GtkObject *object) curve = GTK_CURVE (object); if (curve->pixmap) - gdk_pixmap_destroy (curve->pixmap); + gdk_pixmap_unref (curve->pixmap); if (curve->point) g_free (curve->point); if (curve->ctlpoint) diff --git a/gtk/gtkgamma.c b/gtk/gtkgamma.c index 1d7abc6fba..977aabe67f 100644 --- a/gtk/gtkgamma.c +++ b/gtk/gtkgamma.c @@ -252,8 +252,8 @@ button_realize_callback (GtkWidget *w) gtk_container_add (GTK_CONTAINER (w), pixmap); gtk_widget_show (pixmap); - gdk_pixmap_destroy (pm); - gdk_pixmap_destroy (mask); /* a bitmap is really just a special pixmap */ + gdk_pixmap_unref (pm); + gdk_bitmap_unref (mask); /* a bitmap is really just a special pixmap */ } static void diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c index 9b757d406f..3b52a7a798 100644 --- a/gtk/gtkhscrollbar.c +++ b/gtk/gtkhscrollbar.c @@ -147,7 +147,9 @@ gtk_hscrollbar_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + range->trough = widget->window; + gdk_window_ref (range->trough); attributes.x = widget->style->klass->xthickness; attributes.y = widget->style->klass->ythickness; diff --git a/gtk/gtkinputdialog.c b/gtk/gtkinputdialog.c index 1d412a32ea..d197fc8e0f 100644 --- a/gtk/gtkinputdialog.c +++ b/gtk/gtkinputdialog.c @@ -28,6 +28,7 @@ #include <ctype.h> #include "gdk/gdkkeysyms.h" #include "gtkbutton.h" +#include "gtkentry.h" #include "gtkhbox.h" #include "gtkhseparator.h" #include "gtkinputdialog.h" @@ -36,15 +37,23 @@ #include "gtkmain.h" #include "gtkmenu.h" #include "gtkmenuitem.h" +#include "gtknotebook.h" #include "gtkoptionmenu.h" #include "gtkscrolledwindow.h" #include "gtksignal.h" +#include "gtktable.h" #include "gtkvbox.h" typedef void (*GtkInputDialogSignal1) (GtkObject *object, int arg1, gpointer data); +typedef struct { + gint index; + GtkWidget *entry; + GtkInputDialog *inputd; +} GtkInputKeyInfo; + enum { ENABLE_DEVICE, @@ -56,6 +65,9 @@ enum #define AXIS_LIST_WIDTH 160 #define AXIS_LIST_HEIGHT 175 +#define KEYS_LIST_WIDTH 200 +#define KEYS_LIST_HEIGHT 175 + /* Forward declarations */ static void gtk_input_dialog_marshal_signal1 (GtkObject *object, @@ -72,6 +84,18 @@ static void gtk_input_dialog_set_mapping_mode(GtkWidget *w, static void gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data); static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd, GdkDeviceInfo *info); +static void gtk_input_dialog_set_key (GtkInputKeyInfo *key, + guint keyval, + GdkModifierType modifiers); +static gint gtk_input_dialog_key_press (GtkWidget *widget, + GdkEventKey *event, + GtkInputKeyInfo *key); +static void gtk_input_dialog_clear_key (GtkWidget *widget, + GtkInputKeyInfo *key); +static void gtk_input_dialog_destroy_key (GtkWidget *widget, + GtkInputKeyInfo *key); +static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd, + GdkDeviceInfo *info); static GtkObjectClass *parent_class = NULL; static gint input_dialog_signals[LAST_SIGNAL] = { 0 }; @@ -171,6 +195,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd) GtkWidget *menuitem; GtkWidget *optionmenu; GtkWidget *separator; + GtkWidget *notebook; GList *tmp_list; GList *device_info; @@ -225,17 +250,9 @@ gtk_input_dialog_init (GtkInputDialog *inputd) gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), device_menu); gtk_widget_show (label); - gtk_widget_show (util_box); /* Device options */ - separator = gtk_hseparator_new(); - gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0); - gtk_widget_show (separator); - - util_box = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (vbox), util_box, FALSE, FALSE, 0); - /* mapping mode option menu */ mapping_menu = gtk_menu_new (); @@ -282,34 +299,65 @@ gtk_input_dialog_init (GtkInputDialog *inputd) gtk_widget_show (label); gtk_widget_show (util_box); + separator = gtk_hseparator_new(); + gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0); + gtk_widget_show (separator); + + /* Notebook */ + + notebook = gtk_notebook_new (); + gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0); + gtk_widget_show (notebook); + /* The axis listbox */ label = gtk_label_new ("Axes"); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); inputd->axis_listbox = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(inputd->axis_listbox), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_widget_set_usize (inputd->axis_listbox, AXIS_LIST_WIDTH, AXIS_LIST_HEIGHT); - gtk_box_pack_start (GTK_BOX (vbox), inputd->axis_listbox, TRUE, TRUE, 0); + gtk_notebook_append_page (GTK_NOTEBOOK(notebook), + inputd->axis_listbox, label); + gtk_widget_show (inputd->axis_listbox); inputd->axis_list = 0; - gtk_widget_show(label); + /* Keys listbox */ + + label = gtk_label_new ("Keys"); + + inputd->keys_listbox = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_set_usize (inputd->keys_listbox, KEYS_LIST_WIDTH, KEYS_LIST_HEIGHT); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(inputd->keys_listbox), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_notebook_append_page (GTK_NOTEBOOK(notebook), + inputd->keys_listbox, label); + + gtk_widget_show (inputd->keys_listbox); + + inputd->keys_list = 0; /* ...set_device expects to get input dialog from widget user data */ gtk_object_set_user_data (GTK_OBJECT (inputd), inputd); gtk_input_dialog_set_device(GTK_WIDGET(inputd), (gpointer)((long) ((GdkDeviceInfo *)device_info->data)->deviceid)); - } - /* buttons */ + } + /* We create the save button in any case, so that clients can + connect to it, without paying attention to whether it exits */ inputd->save_button = gtk_button_new_with_label ("Save"); GTK_WIDGET_SET_FLAGS (inputd->save_button, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area), inputd->save_button, TRUE, TRUE, 0); gtk_widget_show (inputd->save_button); + if (g_list_length(device_info) <= 1) /* only core device */ + gtk_widget_set_sensitive(inputd->save_button, FALSE); + inputd->close_button = gtk_button_new_with_label ("Close"); GTK_WIDGET_SET_FLAGS (inputd->close_button, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area), @@ -345,6 +393,7 @@ gtk_input_dialog_set_device(GtkWidget *widget, gpointer data) info = gtk_input_dialog_get_device_info((guint32)data); gtk_input_dialog_fill_axes(inputd, info); + gtk_input_dialog_fill_keys(inputd, info); gtk_option_menu_set_history(GTK_OPTION_MENU(inputd->mode_optionmenu), info->mode); @@ -464,11 +513,8 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info) }; int i,j; - GtkWidget *list_item; GtkWidget *menu; GtkWidget *option_menu; - GtkWidget *vbox; - GtkWidget *hbox; GtkWidget *label; /* remove all the old items */ @@ -477,7 +523,7 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info) gtk_widget_hide (inputd->axis_list); /* suppress resizes (or get warnings) */ gtk_widget_destroy (inputd->axis_list); } - inputd->axis_list = gtk_vbox_new (FALSE, 0); + inputd->axis_list = gtk_table_new (GDK_AXIS_LAST, 2, 0); gtk_container_add (GTK_CONTAINER (inputd->axis_listbox), inputd->axis_list); gtk_widget_show (inputd->axis_list); @@ -487,21 +533,11 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info) for (i=GDK_AXIS_X;i<GDK_AXIS_LAST;i++) { - list_item = gtk_list_item_new(); - - gtk_box_pack_start(GTK_BOX(inputd->axis_list),list_item,FALSE,FALSE,0); - gtk_widget_show (list_item); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add(GTK_CONTAINER (list_item), vbox); - - hbox = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 1); - /* create the label */ label = gtk_label_new(axis_use_strings[i]); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 2); + gtk_table_attach (GTK_TABLE (inputd->axis_list), label, 0, 1, i, i+1, + 0, 0, 2, 2); /* and the use option menu */ menu = gtk_menu_new(); @@ -527,7 +563,8 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info) } inputd->axis_items[i] = option_menu = gtk_option_menu_new (); - gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 2); + gtk_table_attach (GTK_TABLE (inputd->axis_list), option_menu, + 1, 2, i, i+1, 0, 0, 2, 2); gtk_widget_show (option_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); @@ -539,8 +576,134 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info) } gtk_widget_show (label); + } +} + +static void +gtk_input_dialog_clear_key (GtkWidget *widget, GtkInputKeyInfo *key) +{ + gtk_entry_set_text (GTK_ENTRY(key->entry), "(disabled)"); + gdk_input_set_key (key->inputd->current_device, key->index, 0, 0); +} + +static void +gtk_input_dialog_set_key (GtkInputKeyInfo *key, + guint keyval, GdkModifierType modifiers) +{ + GString *str; + gchar chars[2]; + + if (keyval) + { + str = g_string_new(""); + + if (modifiers & GDK_SHIFT_MASK) + g_string_append (str, "Shft+"); + if (modifiers & GDK_CONTROL_MASK) + g_string_append (str, "Ctl+"); + if (modifiers & GDK_MOD1_MASK) + g_string_append (str, "Alt+"); + + if ((keyval >= 0x20) && (keyval <= 0xFF)) + { + chars[0] = keyval; + chars[1] = 0; + g_string_append (str, chars); + } + else + g_string_append (str, "(unknown)"); + gtk_entry_set_text (GTK_ENTRY(key->entry), str->str); + + g_string_free (str, TRUE); + } + else + { + gtk_entry_set_text (GTK_ENTRY(key->entry), "(disabled)"); + } +} + +static gint +gtk_input_dialog_key_press (GtkWidget *widget, + GdkEventKey *event, + GtkInputKeyInfo *key) +{ + gtk_input_dialog_set_key (key, event->keyval, event->state & 0xFF); + gdk_input_set_key (key->inputd->current_device, key->index, + event->keyval, event->state & 0xFF); + + gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event"); + + return TRUE; +} + +static void +gtk_input_dialog_destroy_key (GtkWidget *widget, GtkInputKeyInfo *key) +{ + g_free (key); +} + +static void +gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDeviceInfo *info) +{ + int i; + GtkWidget *label; + GtkWidget *button; + + char buffer[16]; + + /* remove all the old items */ + if (inputd->keys_list) + { + gtk_widget_hide (inputd->keys_list); /* suppress resizes (or get warnings) */ + gtk_widget_destroy (inputd->keys_list); + } + + inputd->keys_list = gtk_table_new (info->num_keys, 3, FALSE); + gtk_container_add (GTK_CONTAINER (inputd->keys_listbox), inputd->keys_list); + gtk_widget_show (inputd->keys_list); + + gtk_widget_realize (inputd->keys_list); + gdk_window_set_background (inputd->keys_list->window, + &inputd->keys_list->style->white); + + for (i=0;i<info->num_keys;i++) + { + GtkInputKeyInfo *key = g_new (GtkInputKeyInfo, 1); + key->index = i; + key->inputd = inputd; + + /* create the label */ + + sprintf(buffer, "%d", i+1); + label = gtk_label_new(buffer); + gtk_table_attach (GTK_TABLE (inputd->keys_list), label, 0, 1, i, i+1, + 0, 0, 2, 2); + gtk_widget_show (label); + + /* the entry */ + + key->entry = gtk_entry_new (); + gtk_table_attach (GTK_TABLE (inputd->keys_list), key->entry, 1, 2, i, i+1, + GTK_EXPAND | GTK_FILL , 0, 2, 2); + gtk_widget_show (key->entry); + + gtk_signal_connect (GTK_OBJECT(key->entry), "key_press_event", + GTK_SIGNAL_FUNC (gtk_input_dialog_key_press), key); + gtk_signal_connect (GTK_OBJECT(key->entry), "destroy", + GTK_SIGNAL_FUNC (gtk_input_dialog_destroy_key), + key); + + /* and clear button */ + + button = gtk_button_new_with_label ("clear"); + gtk_table_attach (GTK_TABLE (inputd->keys_list), button, 2, 3, i, i+1, + 0, 0, 2, 2); + gtk_widget_show (button); + + gtk_signal_connect (GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC (gtk_input_dialog_clear_key), key); - gtk_widget_show (hbox); - gtk_widget_show (vbox); + gtk_input_dialog_set_key (key, info->keys[i].keyval, + info->keys[i].modifiers); } } diff --git a/gtk/gtkinputdialog.h b/gtk/gtkinputdialog.h index 93c667f440..80a900090a 100644 --- a/gtk/gtkinputdialog.h +++ b/gtk/gtkinputdialog.h @@ -49,6 +49,9 @@ struct _GtkInputDialog GtkWidget *axis_items[GDK_AXIS_LAST]; guint32 current_device; + + GtkWidget *keys_list; + GtkWidget *keys_listbox; }; struct _GtkInputDialogClass diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index c55ade8a51..e2c064a483 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -38,6 +38,7 @@ typedef struct _GtkInitFunction GtkInitFunction; typedef struct _GtkTimeoutFunction GtkTimeoutFunction; typedef struct _GtkIdleFunction GtkIdleFunction; +typedef struct _GtkInputFunction GtkInputFunction; struct _GtkInitFunction { @@ -66,6 +67,12 @@ struct _GtkIdleFunction GtkDestroyNotify destroy; }; +struct _GtkInputFunction +{ + GtkCallbackMarshal callback; + gpointer data; + GtkDestroyNotify destroy; +}; static void gtk_exit_func (void); static void gtk_timeout_insert (GtkTimeoutFunction *timeoutf); @@ -85,10 +92,9 @@ static void gtk_print (gchar *str); static gint done; static guint main_level = 0; static gint initialized = FALSE; -static GdkEvent next_event; -static GdkEvent current_event; -static gint have_event = FALSE; -static gint have_next_event = FALSE; +static GdkEvent *next_event = NULL; +static GdkEvent *current_event = NULL; +static GList *current_events = NULL; static GList *grabs = NULL; /* A list of grabs. The grabbing widget * is the first one on the list. @@ -219,9 +225,10 @@ gtk_main_quit () gint gtk_main_iteration () { - GdkEvent event_copy; GtkWidget *event_widget; GtkWidget *grab_widget; + GdkEvent *event = NULL; + GList *tmp_list; done = FALSE; @@ -240,19 +247,17 @@ gtk_main_iteration () return done; } - /* If there is a valid event in 'next_event' then copy - * it to 'event' and unset the flag. + /* If there is a valid event in 'next_event' then move it to 'event' */ - if (have_next_event) + if (next_event) { - have_next_event = FALSE; - have_event = TRUE; - current_event = next_event; + event = next_event; + next_event = NULL; } /* If we don't have an event then get one. */ - if (!have_event) + if (!event) { /* Handle setting of the "gdk" timer. If there are no * timeout functions, then the timer is turned off. @@ -262,21 +267,19 @@ gtk_main_iteration () */ gtk_handle_timer (); - have_event = gdk_event_get (¤t_event, NULL, NULL); + event = gdk_event_get (); } /* "gdk_event_get" can return FALSE if the timer goes off * and no events are pending. Therefore, we should make * sure that we got an event before continuing. */ - if (have_event) + if (event) { - have_event = FALSE; - /* If there are any events pending then get the next one. */ if (gdk_events_pending () > 0) - have_next_event = gdk_event_get (&next_event, NULL, NULL); + next_event = gdk_event_get (); /* Try to compress enter/leave notify events. These event * pairs occur when the mouse is dragged quickly across @@ -286,19 +289,32 @@ gtk_main_iteration () * which contained the mouse initially and highlight the * widget which ends up containing the mouse. */ - if (have_next_event) - if (((current_event.type == GDK_ENTER_NOTIFY) || - (current_event.type == GDK_LEAVE_NOTIFY)) && - ((next_event.type == GDK_ENTER_NOTIFY) || - (next_event.type == GDK_LEAVE_NOTIFY)) && - (next_event.type != current_event.type) && - (next_event.any.window == current_event.any.window)) - return done; + if (next_event) + if (((event->type == GDK_ENTER_NOTIFY) || + (event->type == GDK_LEAVE_NOTIFY)) && + ((next_event->type == GDK_ENTER_NOTIFY) || + (next_event->type == GDK_LEAVE_NOTIFY)) && + (next_event->type != event->type) && + (next_event->any.window == event->any.window)) + { + tmp_list = current_events; + current_events = g_list_remove_link (current_events, tmp_list); + g_list_free_1 (tmp_list); + + gdk_event_free (event); + + return done; + } + + /* Push the event onto a stack of current events for + * gdk_current_event_get */ + + current_events = g_list_prepend (current_events, event); /* Find the widget which got the event. We store the widget * in the user_data field of GdkWindow's. */ - event_widget = gtk_get_event_widget (¤t_event); + event_widget = gtk_get_event_widget (event); /* If there is a grab in effect... */ @@ -325,20 +341,23 @@ gtk_main_iteration () * and 2) redirecting these events to the grabbing widget * could cause the display to be messed up. */ - event_copy = current_event; - switch (event_copy.type) + switch (event->type) { case GDK_NOTHING: break; case GDK_DELETE: - if (gtk_widget_event (event_widget, &event_copy)) + gtk_object_ref (GTK_OBJECT (event_widget)); + if (gtk_widget_event (event_widget, event)) gtk_widget_destroy (event_widget); + gtk_object_unref (GTK_OBJECT (event_widget)); break; case GDK_DESTROY: - gtk_widget_event (event_widget, &event_copy); + gtk_object_ref (GTK_OBJECT (event_widget)); + gtk_widget_event (event_widget, event); gtk_widget_destroy (event_widget); + gtk_object_unref (GTK_OBJECT (event_widget)); break; case GDK_PROPERTY_NOTIFY: @@ -351,8 +370,8 @@ gtk_main_iteration () if (event_widget == NULL) { - gtk_selection_incr_event (event_copy.any.window, - &event_copy.property); + gtk_selection_incr_event (event->any.window, + &event->property); break; } /* otherwise fall through */ @@ -371,7 +390,7 @@ gtk_main_iteration () case GDK_DROP_ENTER: case GDK_DROP_LEAVE: case GDK_DROP_DATA_AVAIL: - gtk_widget_event (event_widget, &event_copy); + gtk_widget_event (event_widget, event); break; case GDK_MOTION_NOTIFY: @@ -384,15 +403,23 @@ gtk_main_iteration () case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: case GDK_OTHER_EVENT: - gtk_propagate_event (grab_widget, &event_copy); + gtk_propagate_event (grab_widget, event); break; case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: if (grab_widget && GTK_WIDGET_IS_SENSITIVE (grab_widget)) - gtk_widget_event (grab_widget, &event_copy); + gtk_widget_event (grab_widget, event); break; } + + tmp_list = current_events; + current_events = g_list_remove_link (current_events, tmp_list); + g_list_free_1 (tmp_list); + + gdk_event_free (event); + + current_event = NULL; } else { @@ -686,12 +713,63 @@ gtk_idle_remove_by_data (gpointer data) } } +static void +gtk_invoke_input_function (GtkInputFunction *input, + gint source, + GdkInputCondition condition) +{ + GtkArg args[3]; + args[0].type = GTK_TYPE_INT; + args[0].name = NULL; + GTK_VALUE_INT(args[0]) = source; + args[1].type = GTK_TYPE_GDK_INPUT_CONDITION; + args[1].name = NULL; + GTK_VALUE_FLAGS(args[1]) = condition; + args[2].type = GTK_TYPE_NONE; + args[2].name = NULL; + + input->callback (NULL, input->data, 2, args); +} + +static void +gtk_destroy_input_function (GtkInputFunction *input) +{ + if (input->destroy) + (input->destroy) (input->data); + g_free (input); +} + +gint +gtk_input_add_interp (gint source, + GdkInputCondition condition, + GtkCallbackMarshal callback, + gpointer data, + GtkDestroyNotify destroy) +{ + GtkInputFunction *input = g_new (GtkInputFunction, 1); + input->callback = callback; + input->data = data; + input->destroy = destroy; + return gdk_input_add_interp (source, + condition, + (GdkInputFunction) gtk_invoke_input_function, + input, + (GdkDestroyNotify) gtk_destroy_input_function); +} + void -gtk_get_current_event (GdkEvent *event) +gtk_input_remove (gint tag) { - g_assert (event != NULL); - - *event = current_event; + gdk_input_remove (tag); +} + +GdkEvent * +gtk_get_current_event () +{ + if (current_events) + return gdk_event_copy ((GdkEvent *)current_events->data); + else + return NULL; } GtkWidget* diff --git a/gtk/gtkmain.h b/gtk/gtkmain.h index c014f190a3..ae588d4d22 100644 --- a/gtk/gtkmain.h +++ b/gtk/gtkmain.h @@ -65,7 +65,7 @@ gint gtk_idle_add_interp (GtkCallbackMarshal function, void gtk_idle_remove (gint tag); void gtk_idle_remove_by_data (gpointer data); -void gtk_get_current_event (GdkEvent *event); +GdkEvent* gtk_get_current_event (void); GtkWidget* gtk_get_event_widget (GdkEvent *event); diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 13fff9023a..caab1a0a0d 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -247,12 +247,14 @@ gtk_menu_set_accelerator_table (GtkMenu *menu, g_return_if_fail (menu != NULL); g_return_if_fail (GTK_IS_MENU (menu)); - if (menu->accelerator_table) - gtk_accelerator_table_unref (menu->accelerator_table); - - menu->accelerator_table = table; - if (menu->accelerator_table) - gtk_accelerator_table_ref (menu->accelerator_table); + if (menu->accelerator_table != table) + { + if (menu->accelerator_table) + gtk_accelerator_table_unref (menu->accelerator_table); + menu->accelerator_table = table; + if (menu->accelerator_table) + gtk_accelerator_table_ref (menu->accelerator_table); + } } diff --git a/gtk/gtkmenufactory.c b/gtk/gtkmenufactory.c index d6e9ea6841..eef5c8a373 100644 --- a/gtk/gtkmenufactory.c +++ b/gtk/gtkmenufactory.c @@ -85,6 +85,9 @@ gtk_menu_factory_destroy (GtkMenuFactory *factory) gtk_menu_factory_destroy (subfactory); } + + if (factory->table) + gtk_accelerator_table_unref (factory->table); } void @@ -237,11 +240,8 @@ gtk_menu_factory_create (GtkMenuFactory *factory, &accelerator_key, &accelerator_mods); if (!factory->table) - { - factory->table = gtk_accelerator_table_new (); - gtk_accelerator_table_ref (factory->table); - } - + factory->table = gtk_accelerator_table_new (); + gtk_widget_install_accelerator (menu_path->widget, factory->table, "activate", @@ -291,10 +291,7 @@ gtk_menu_factory_create (GtkMenuFactory *factory, gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_path->widget), menu); if (!factory->table) - { - factory->table = gtk_accelerator_table_new (); - gtk_accelerator_table_ref (factory->table); - } + factory->table = gtk_accelerator_table_new (); gtk_menu_set_accelerator_table (GTK_MENU (menu), factory->table); } @@ -369,10 +366,7 @@ gtk_menu_factory_make_widget (GtkMenuFactory *factory) widget = gtk_menu_new (); if (!factory->table) - { - factory->table = gtk_accelerator_table_new (); - gtk_accelerator_table_ref (factory->table); - } + factory->table = gtk_accelerator_table_new (); gtk_menu_set_accelerator_table (GTK_MENU (widget), factory->table); return widget; case GTK_MENU_FACTORY_MENU_BAR: diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index f7715fb25e..b023a85e5b 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -207,19 +207,20 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item, g_return_if_fail (menu_item != NULL); g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); - if (menu_item->submenu) + if (menu_item->submenu != submenu) { - g_return_if_fail (!GTK_WIDGET_VISIBLE (menu_item->submenu)); - gtk_object_unref (GTK_OBJECT (menu_item->submenu)); - } - - menu_item->submenu = submenu; - - if (menu_item->submenu) - gtk_object_ref (GTK_OBJECT (menu_item->submenu)); + if (menu_item->submenu) + { + g_return_if_fail (!GTK_WIDGET_VISIBLE (menu_item->submenu)); + gtk_object_unref (GTK_OBJECT (menu_item->submenu)); + } + menu_item->submenu = submenu; + if (menu_item->submenu) + gtk_object_ref (GTK_OBJECT (menu_item->submenu)); - if (GTK_WIDGET (menu_item)->parent) - gtk_widget_queue_resize (GTK_WIDGET (menu_item)); + if (GTK_WIDGET (menu_item)->parent) + gtk_widget_queue_resize (GTK_WIDGET (menu_item)); + } } void diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c index ffe487e891..38257b9b4a 100644 --- a/gtk/gtkobject.c +++ b/gtk/gtkobject.c @@ -230,7 +230,7 @@ gtk_object_ref (GtkObject *object) } /***************************************** - * gtk_object_new: + * gtk_object_unref: * * arguments: * diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c index ae640f81f1..66ef1538cc 100644 --- a/gtk/gtkpixmap.c +++ b/gtk/gtkpixmap.c @@ -23,7 +23,9 @@ static void gtk_pixmap_class_init (GtkPixmapClass *klass); static void gtk_pixmap_init (GtkPixmap *pixmap); static gint gtk_pixmap_expose (GtkWidget *widget, GdkEventExpose *event); +static void gtk_pixmap_destroy (GtkObject *object); +static GtkWidgetClass *parent_class; guint gtk_pixmap_get_type () @@ -51,10 +53,14 @@ gtk_pixmap_get_type () static void gtk_pixmap_class_init (GtkPixmapClass *class) { + GtkObjectClass *object_class; GtkWidgetClass *widget_class; + object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; + parent_class = gtk_type_class (gtk_widget_get_type ()); + object_class->destroy = gtk_pixmap_destroy; widget_class->expose_event = gtk_pixmap_expose; } @@ -82,6 +88,14 @@ gtk_pixmap_new (GdkPixmap *val, return GTK_WIDGET (pixmap); } +static void +gtk_pixmap_destroy (GtkObject *object) +{ + gtk_pixmap_set (GTK_PIXMAP (object), NULL, NULL); + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + void gtk_pixmap_set (GtkPixmap *pixmap, GdkPixmap *val, @@ -92,25 +106,38 @@ gtk_pixmap_set (GtkPixmap *pixmap, g_return_if_fail (pixmap != NULL); g_return_if_fail (GTK_IS_PIXMAP (pixmap)); - g_return_if_fail (val != NULL); - pixmap->pixmap = val; - pixmap->mask = mask; - - if (pixmap->pixmap) + if (pixmap->pixmap != val) { - gdk_window_get_size (pixmap->pixmap, &width, &height); - GTK_WIDGET (pixmap)->requisition.width = width + GTK_MISC (pixmap)->xpad * 2; - GTK_WIDGET (pixmap)->requisition.height = height + GTK_MISC (pixmap)->ypad * 2; + if (pixmap->pixmap) + gdk_pixmap_unref (pixmap->pixmap); + pixmap->pixmap = val; + if (pixmap->pixmap) + { + gdk_pixmap_ref (pixmap->pixmap); + gdk_window_get_size (pixmap->pixmap, &width, &height); + GTK_WIDGET (pixmap)->requisition.width = + width + GTK_MISC (pixmap)->xpad * 2; + GTK_WIDGET (pixmap)->requisition.height = + height + GTK_MISC (pixmap)->ypad * 2; + } + else + { + GTK_WIDGET (pixmap)->requisition.width = 0; + GTK_WIDGET (pixmap)->requisition.height = 0; + } + if (GTK_WIDGET_VISIBLE (pixmap)) + gtk_widget_queue_resize (GTK_WIDGET (pixmap)); } - else + + if (pixmap->mask != mask) { - GTK_WIDGET (pixmap)->requisition.width = 0; - GTK_WIDGET (pixmap)->requisition.height = 0; + if (pixmap->mask) + gdk_bitmap_unref (pixmap->mask); + pixmap->mask = mask; + if (pixmap->mask) + gdk_bitmap_ref (pixmap->mask); } - - if (GTK_WIDGET_VISIBLE (pixmap)) - gtk_widget_queue_resize (GTK_WIDGET (pixmap)); } void diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 8db560ba0c..620e5eed68 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -199,7 +199,7 @@ gtk_progress_bar_make_pixmap (GtkProgressBar *pbar) widget = GTK_WIDGET (pbar); if (pbar->offscreen_pixmap) - gdk_pixmap_destroy (pbar->offscreen_pixmap); + gdk_pixmap_unref (pbar->offscreen_pixmap); pbar->offscreen_pixmap = gdk_pixmap_new (widget->window, widget->allocation.width, diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index f00bbf6838..58c41e43f9 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -195,28 +195,33 @@ gtk_range_set_adjustment (GtkRange *range, g_return_if_fail (range != NULL); g_return_if_fail (GTK_IS_RANGE (range)); - if (range->adjustment) + if (range->adjustment != adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (range->adjustment), (gpointer) range); - gtk_object_unref (GTK_OBJECT (range->adjustment)); + if (range->adjustment) + { + gtk_signal_disconnect_by_data (GTK_OBJECT (range->adjustment), + (gpointer) range); + gtk_object_unref (GTK_OBJECT (range->adjustment)); + } + range->adjustment = adjustment; + if (adjustment) + { + gtk_object_ref (GTK_OBJECT (adjustment)); + gtk_signal_connect (GTK_OBJECT (adjustment), "changed", + (GtkSignalFunc) gtk_range_adjustment_changed, + (gpointer) range); + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + (GtkSignalFunc) gtk_range_adjustment_value_changed, + (gpointer) range); + + range->old_value = adjustment->value; + range->old_lower = adjustment->lower; + range->old_upper = adjustment->upper; + range->old_page_size = adjustment->page_size; + + gtk_range_adjustment_changed (adjustment, (gpointer) range); + } } - - range->adjustment = adjustment; - gtk_object_ref (GTK_OBJECT (range->adjustment)); - - gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - (GtkSignalFunc) gtk_range_adjustment_changed, - (gpointer) range); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - (GtkSignalFunc) gtk_range_adjustment_value_changed, - (gpointer) range); - - range->old_value = adjustment->value; - range->old_lower = adjustment->lower; - range->old_upper = adjustment->upper; - range->old_page_size = adjustment->page_size; - - gtk_range_adjustment_changed (range->adjustment, (gpointer) range); } void diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 131dd0b0fb..7ada4f3363 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -441,7 +441,7 @@ gtk_rc_style_init (GtkRcStyle *rc_style) old_font = rc_style->style->font; rc_style->style->font = gdk_fontset_load (rc_style->fontset_name); if (rc_style->style->font) - gdk_fontset_free (old_font); + gdk_font_unref (old_font); else rc_style->style->font = old_font; } @@ -450,7 +450,7 @@ gtk_rc_style_init (GtkRcStyle *rc_style) old_font = rc_style->style->font; rc_style->style->font = gdk_font_load (rc_style->font_name); if (rc_style->style->font) - gdk_font_free (old_font); + gdk_font_unref (old_font); else rc_style->style->font = old_font; } diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c index dad0e11f64..e8a9b07107 100644 --- a/gtk/gtkruler.c +++ b/gtk/gtkruler.c @@ -200,7 +200,7 @@ gtk_ruler_unrealize (GtkWidget *widget) widget->window = NULL; if (ruler->backing_store) - gdk_pixmap_destroy (ruler->backing_store); + gdk_pixmap_unref (ruler->backing_store); if (ruler->non_gr_exp_gc) gdk_gc_destroy (ruler->non_gr_exp_gc); @@ -286,7 +286,7 @@ gtk_ruler_make_pixmap (GtkRuler *ruler) (height == widget->allocation.height)) return; - gdk_pixmap_destroy (ruler->backing_store); + gdk_pixmap_unref (ruler->backing_store); } ruler->backing_store = gdk_pixmap_new (widget->window, diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c index 65efdb991f..2db72ee19c 100644 --- a/gtk/gtksignal.c +++ b/gtk/gtksignal.c @@ -1173,11 +1173,8 @@ gtk_params_get (GtkArg *params, for (i = 0; i < nparams; i++) { - if (param_types[i] != GTK_TYPE_NONE) - { - params[i].type = param_types[i]; - params[i].name = NULL; - } + params[i].type = param_types[i]; + params[i].name = NULL; switch (GTK_FUNDAMENTAL_TYPE (param_types[i])) { @@ -1258,11 +1255,8 @@ gtk_params_get (GtkArg *params, } } - if (return_val != GTK_TYPE_NONE) - { - params[i].type = return_val; - params[i].name = NULL; - } + params[i].type = return_val; + params[i].name = NULL; switch (GTK_FUNDAMENTAL_TYPE (return_val)) { diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 8cb2b12578..db9ee483df 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -168,12 +168,13 @@ gtk_style_new () style = g_new (GtkStyle, 1); if (!default_font) - default_font = gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*"); + default_font = + gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*"); style->font = default_font; gdk_font_ref (style->font); - style->ref_count = 0; + style->ref_count = 1; style->attach_count = 0; style->colormap = NULL; style->depth = -1; @@ -587,7 +588,7 @@ gtk_styles_init () initialize = FALSE; style_cache = g_cache_new ((GCacheNewFunc) gtk_style_new_from_key, - (GCacheDestroyFunc) gtk_style_destroy, + (GCacheDestroyFunc) gtk_style_unref, (GCacheDupFunc) gtk_style_key_dup, (GCacheDestroyFunc) gtk_style_key_destroy, (GHashFunc) gtk_style_key_hash, @@ -712,14 +713,17 @@ gtk_style_new_from_key (GtkStyleKey *key) } if (style) - break; + { + gtk_style_ref (style); + break; + } } if (!style) { style = g_new (GtkStyle, 1); - style->ref_count = 0; + style->ref_count = 1; style->attach_count = 0; style->font = key->font; @@ -794,9 +798,6 @@ gtk_style_destroy (GtkStyle *style) { gint i; - if (style->ref_count != 0) - return; - if (style->attach_count > 0) { gtk_gc_release (style->black_gc); @@ -816,13 +817,7 @@ gtk_style_destroy (GtkStyle *style) unattached_styles = g_slist_remove (unattached_styles, style); - if (style->font->type == GDK_FONT_FONT) - gdk_font_free (style->font); - else if (style->font->type == GDK_FONT_FONTSET) - gdk_fontset_free (style->font); - else - g_error("undefined font type\n"); - + gdk_font_unref (style->font); g_free (style); } diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 4a94de0843..a3f8f219a7 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -244,6 +244,8 @@ static void scroll_up (GtkText* text, gint diff); static void scroll_down (GtkText* text, gint diff); static void scroll_int (GtkText* text, gint diff); +static void process_exposes (GtkText *text); + /* Cache Management. */ static GList* remove_cache_line (GtkText* text, GList* list); @@ -1548,6 +1550,9 @@ delete_char_line_expose (GtkText* text, gchar key, guint old_pixels) draw_cursor (text, FALSE); + if (old_pixels != new_pixels) + process_exposes (text); + TEXT_ASSERT (text); TEXT_SHOW(text); } @@ -1650,6 +1655,9 @@ insert_char_line_expose (GtkText* text, gchar key, guint old_pixels) draw_cursor (text, FALSE); + if (old_pixels != new_pixels) + process_exposes (text); + TEXT_SHOW_ADJ (text, text->vadj, "vadj"); TEXT_ASSERT (text); TEXT_SHOW(text); @@ -2564,6 +2572,26 @@ scroll_int (GtkText* text, gint diff) gtk_signal_emit_by_name (GTK_OBJECT (text->vadj), "value_changed"); } +static void +process_exposes (GtkText *text) +{ + GdkEvent *event; + + /* Make sure graphics expose events are processed before scrolling + * again */ + + while ((event = gdk_event_get_graphics_expose (text->text_area)) != NULL) + { + gtk_widget_event (GTK_WIDGET (text), event); + if (event->expose.count == 0) + { + gdk_event_free (event); + break; + } + gdk_event_free (event); + } +} + static gint last_visible_line_height (GtkText* text) { GList *cache = text->line_start_cache; @@ -2660,6 +2688,9 @@ scroll_down (GtkText* text, gint diff0) mouse_click_1 (text, &button); } } + + if (height > real_diff) + process_exposes (text); } static void @@ -2734,6 +2765,9 @@ scroll_up (GtkText* text, gint diff0) mouse_click_1 (text, &button); } } + + if (height > real_diff) + process_exposes (text); } /**********************************************************************/ diff --git a/gtk/gtktooltips.c b/gtk/gtktooltips.c index a367504819..774258036e 100644 --- a/gtk/gtktooltips.c +++ b/gtk/gtktooltips.c @@ -17,6 +17,7 @@ */ #include <stdlib.h> #include <string.h> +#include <stdio.h> #include "gtkmain.h" #include "gtkwidget.h" @@ -41,7 +42,7 @@ static gint gtk_tooltips_widget_visible (GtkWidget *widget); static gint gtk_tooltips_timeout (gpointer data); static void gtk_tooltips_create_window (GtkTooltips *tooltips); static void gtk_tooltips_draw_tips (GtkTooltips *tooltips); - +static void gtk_tooltips_real_destroy (GtkTooltips *tooltips); GtkTooltips * gtk_tooltips_new () @@ -52,8 +53,7 @@ gtk_tooltips_new () if (tooltips != NULL) { - tooltips->ref_count = 0; - tooltips->pending_destroy = 0; + tooltips->ref_count = 1; tooltips->enabled = TRUE; tooltips->numwidgets = 0; @@ -81,8 +81,8 @@ gtk_tooltips_unref (GtkTooltips *tooltips) { g_return_if_fail (tooltips != NULL); tooltips->ref_count -= 1; - if (tooltips->ref_count == 0 && tooltips->pending_destroy) - gtk_tooltips_destroy (tooltips); + if (tooltips->ref_count == 0) + gtk_tooltips_real_destroy (tooltips); } void @@ -105,20 +105,14 @@ gtk_tooltips_destroy_data (GtkTooltips *tooltips, g_free (tooltipsdata); } -void -gtk_tooltips_destroy (GtkTooltips *tooltips) +static void +gtk_tooltips_real_destroy (GtkTooltips *tooltips) { GList *current; GtkTooltipsData *tooltipsdata; g_return_if_fail (tooltips != NULL); - if (tooltips->ref_count > 0) - { - tooltips->pending_destroy = 1; - return; - } - if (tooltips->timer_active == TRUE) { tooltips->timer_active = FALSE; @@ -627,14 +621,9 @@ gtk_tooltips_widget_remove (GtkWidget *widget, if (list) { tooltipsdata = (GtkTooltipsData*) list->data; - - g_free (tooltipsdata->tips_text); - g_list_foreach (tooltipsdata->row, gtk_tooltips_free_string, 0); - g_list_free (tooltipsdata->row); - gtk_signal_disconnect_by_data (GTK_OBJECT (tooltipsdata->widget), (gpointer) tooltips); - g_free (tooltipsdata); - - tooltips->widget_list = g_list_remove (tooltips->widget_list, tooltipsdata); + tooltips->widget_list = g_list_remove (tooltips->widget_list, + tooltipsdata); + gtk_tooltips_destroy_data (tooltips, tooltipsdata); } gtk_object_set_data (GTK_OBJECT (widget), "_GtkTooltips", NULL); diff --git a/gtk/gtktooltips.h b/gtk/gtktooltips.h index f5c6ddbdb7..5625aa59b9 100644 --- a/gtk/gtktooltips.h +++ b/gtk/gtktooltips.h @@ -53,13 +53,10 @@ typedef struct gint timer_active; gint ref_count; - gint pending_destroy; } GtkTooltips; GtkTooltips* gtk_tooltips_new (void); - -void gtk_tooltips_destroy (GtkTooltips *tooltips); GtkTooltips* gtk_tooltips_ref (GtkTooltips *tooltips); void gtk_tooltips_unref (GtkTooltips *tooltips); diff --git a/gtk/gtktypebuiltins.c b/gtk/gtktypebuiltins.c index e43573119d..d42ba64b94 100644 --- a/gtk/gtktypebuiltins.c +++ b/gtk/gtktypebuiltins.c @@ -20,6 +20,10 @@ { "GtkPositionType", GTK_TYPE_ENUM }, { "GtkPreviewType", GTK_TYPE_ENUM }, { "GtkWidgetFlags", GTK_TYPE_FLAGS }, + { "GtkSelectionMode", GTK_TYPE_ENUM }, + { "GtkCurveType", GTK_TYPE_ENUM }, + { "GtkFundamentalType", GTK_TYPE_ENUM }, + { "GtkJustification", GTK_TYPE_ENUM }, { "GdkWindowType", GTK_TYPE_ENUM }, { "GdkWindowClass", GTK_TYPE_ENUM }, { "GdkImageType", GTK_TYPE_ENUM }, @@ -51,3 +55,5 @@ { "GdkFont", GTK_TYPE_BOXED }, { "GdkWindow", GTK_TYPE_BOXED }, { "GdkEvent", GTK_TYPE_BOXED }, + { "GdkColor", GTK_TYPE_BOXED }, + { "GtkTooltips", GTK_TYPE_BOXED }, diff --git a/gtk/gtktypebuiltins.h b/gtk/gtktypebuiltins.h index ba9131f0f1..4cf9f8f403 100644 --- a/gtk/gtktypebuiltins.h +++ b/gtk/gtktypebuiltins.h @@ -20,35 +20,41 @@ #define GTK_TYPE_POSITION_TYPE (gtk_type_builtins[17]) #define GTK_TYPE_PREVIEW_TYPE (gtk_type_builtins[18]) #define GTK_TYPE_WIDGET_FLAGS (gtk_type_builtins[19]) -#define GTK_TYPE_GDK_WINDOW_TYPE (gtk_type_builtins[20]) -#define GTK_TYPE_GDK_WINDOW_CLASS (gtk_type_builtins[21]) -#define GTK_TYPE_GDK_IMAGE_TYPE (gtk_type_builtins[22]) -#define GTK_TYPE_GDK_VISUAL_TYPE (gtk_type_builtins[23]) -#define GTK_TYPE_GDK_WINDOW_ATTRIBUTES_TYPE (gtk_type_builtins[24]) -#define GTK_TYPE_GDK_WINDOW_HINTS (gtk_type_builtins[25]) -#define GTK_TYPE_GDK_FUNCTION (gtk_type_builtins[26]) -#define GTK_TYPE_GDK_FILL (gtk_type_builtins[27]) -#define GTK_TYPE_GDK_LINE_STYLE (gtk_type_builtins[28]) -#define GTK_TYPE_GDK_CAP_STYLE (gtk_type_builtins[29]) -#define GTK_TYPE_GDK_JOIN_STYLE (gtk_type_builtins[30]) -#define GTK_TYPE_GDK_CURSOR_TYPE (gtk_type_builtins[31]) -#define GTK_TYPE_GDK_EVENT_TYPE (gtk_type_builtins[32]) -#define GTK_TYPE_GDK_EVENT_MASK (gtk_type_builtins[33]) -#define GTK_TYPE_GDK_NOTIFY_TYPE (gtk_type_builtins[34]) -#define GTK_TYPE_GDK_MODIFIER_TYPE (gtk_type_builtins[35]) -#define GTK_TYPE_GDK_SUBWINDOW_MODE (gtk_type_builtins[36]) -#define GTK_TYPE_GDK_INPUT_CONDITION (gtk_type_builtins[37]) -#define GTK_TYPE_GDK_STATUS (gtk_type_builtins[38]) -#define GTK_TYPE_GDK_BYTE_ORDER (gtk_type_builtins[39]) -#define GTK_TYPE_GDK_GCVALUES_MASK (gtk_type_builtins[40]) -#define GTK_TYPE_GDK_SELECTION (gtk_type_builtins[41]) -#define GTK_TYPE_GDK_PROPERTY_STATE (gtk_type_builtins[42]) -#define GTK_TYPE_GDK_PROP_MODE (gtk_type_builtins[43]) -#define GTK_TYPE_ACCELERATOR_TABLE (gtk_type_builtins[44]) -#define GTK_TYPE_STYLE (gtk_type_builtins[45]) -#define GTK_TYPE_GDK_COLORMAP (gtk_type_builtins[46]) -#define GTK_TYPE_GDK_VISUAL (gtk_type_builtins[47]) -#define GTK_TYPE_GDK_FONT (gtk_type_builtins[48]) -#define GTK_TYPE_GDK_WINDOW (gtk_type_builtins[49]) -#define GTK_TYPE_GDK_EVENT (gtk_type_builtins[50]) -#define GTK_TYPE_NUM_BUILTINS 51 +#define GTK_TYPE_SELECTION_MODE (gtk_type_builtins[20]) +#define GTK_TYPE_CURVE_TYPE (gtk_type_builtins[21]) +#define GTK_TYPE_FUNDAMENTAL_TYPE (gtk_type_builtins[22]) +#define GTK_TYPE_JUSTIFICATION (gtk_type_builtins[23]) +#define GTK_TYPE_GDK_WINDOW_TYPE (gtk_type_builtins[24]) +#define GTK_TYPE_GDK_WINDOW_CLASS (gtk_type_builtins[25]) +#define GTK_TYPE_GDK_IMAGE_TYPE (gtk_type_builtins[26]) +#define GTK_TYPE_GDK_VISUAL_TYPE (gtk_type_builtins[27]) +#define GTK_TYPE_GDK_WINDOW_ATTRIBUTES_TYPE (gtk_type_builtins[28]) +#define GTK_TYPE_GDK_WINDOW_HINTS (gtk_type_builtins[29]) +#define GTK_TYPE_GDK_FUNCTION (gtk_type_builtins[30]) +#define GTK_TYPE_GDK_FILL (gtk_type_builtins[31]) +#define GTK_TYPE_GDK_LINE_STYLE (gtk_type_builtins[32]) +#define GTK_TYPE_GDK_CAP_STYLE (gtk_type_builtins[33]) +#define GTK_TYPE_GDK_JOIN_STYLE (gtk_type_builtins[34]) +#define GTK_TYPE_GDK_CURSOR_TYPE (gtk_type_builtins[35]) +#define GTK_TYPE_GDK_EVENT_TYPE (gtk_type_builtins[36]) +#define GTK_TYPE_GDK_EVENT_MASK (gtk_type_builtins[37]) +#define GTK_TYPE_GDK_NOTIFY_TYPE (gtk_type_builtins[38]) +#define GTK_TYPE_GDK_MODIFIER_TYPE (gtk_type_builtins[39]) +#define GTK_TYPE_GDK_SUBWINDOW_MODE (gtk_type_builtins[40]) +#define GTK_TYPE_GDK_INPUT_CONDITION (gtk_type_builtins[41]) +#define GTK_TYPE_GDK_STATUS (gtk_type_builtins[42]) +#define GTK_TYPE_GDK_BYTE_ORDER (gtk_type_builtins[43]) +#define GTK_TYPE_GDK_GCVALUES_MASK (gtk_type_builtins[44]) +#define GTK_TYPE_GDK_SELECTION (gtk_type_builtins[45]) +#define GTK_TYPE_GDK_PROPERTY_STATE (gtk_type_builtins[46]) +#define GTK_TYPE_GDK_PROP_MODE (gtk_type_builtins[47]) +#define GTK_TYPE_ACCELERATOR_TABLE (gtk_type_builtins[48]) +#define GTK_TYPE_STYLE (gtk_type_builtins[49]) +#define GTK_TYPE_GDK_COLORMAP (gtk_type_builtins[50]) +#define GTK_TYPE_GDK_VISUAL (gtk_type_builtins[51]) +#define GTK_TYPE_GDK_FONT (gtk_type_builtins[52]) +#define GTK_TYPE_GDK_WINDOW (gtk_type_builtins[53]) +#define GTK_TYPE_GDK_EVENT (gtk_type_builtins[54]) +#define GTK_TYPE_GDK_COLOR (gtk_type_builtins[55]) +#define GTK_TYPE_TOOLTIPS (gtk_type_builtins[56]) +#define GTK_TYPE_NUM_BUILTINS 57 diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index dfa00c4b08..a084b13345 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -145,23 +145,27 @@ gtk_viewport_set_hadjustment (GtkViewport *viewport, g_return_if_fail (GTK_IS_VIEWPORT (viewport)); g_return_if_fail (adjustment != NULL); - if (viewport->hadjustment) + if (viewport->hadjustment != adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), (gpointer) viewport); - gtk_object_unref (GTK_OBJECT (viewport->hadjustment)); - } + if (viewport->hadjustment) + { + gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), + (gpointer) viewport); + gtk_object_unref (GTK_OBJECT (viewport->hadjustment)); + } - viewport->hadjustment = adjustment; - gtk_object_ref (GTK_OBJECT (viewport->hadjustment)); + viewport->hadjustment = adjustment; + gtk_object_ref (GTK_OBJECT (viewport->hadjustment)); - gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - (GtkSignalFunc) gtk_viewport_adjustment_changed, - (gpointer) viewport); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - (GtkSignalFunc) gtk_viewport_adjustment_value_changed, - (gpointer) viewport); + gtk_signal_connect (GTK_OBJECT (adjustment), "changed", + (GtkSignalFunc) gtk_viewport_adjustment_changed, + (gpointer) viewport); + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + (GtkSignalFunc)gtk_viewport_adjustment_value_changed, + (gpointer) viewport); - gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport); + gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport); + } } void @@ -172,23 +176,27 @@ gtk_viewport_set_vadjustment (GtkViewport *viewport, g_return_if_fail (GTK_IS_VIEWPORT (viewport)); g_return_if_fail (adjustment != NULL); - if (viewport->vadjustment) + if (viewport->vadjustment != adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), (gpointer) viewport); - gtk_object_unref (GTK_OBJECT (viewport->vadjustment)); - } - - viewport->vadjustment = adjustment; - gtk_object_ref (GTK_OBJECT (viewport->vadjustment)); - - gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - (GtkSignalFunc) gtk_viewport_adjustment_changed, - (gpointer) viewport); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - (GtkSignalFunc) gtk_viewport_adjustment_value_changed, - (gpointer) viewport); + if (viewport->vadjustment) + { + gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), + (gpointer) viewport); + gtk_object_unref (GTK_OBJECT (viewport->vadjustment)); + } - gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport); + viewport->vadjustment = adjustment; + gtk_object_ref (GTK_OBJECT (viewport->vadjustment)); + + gtk_signal_connect (GTK_OBJECT (adjustment), "changed", + (GtkSignalFunc) gtk_viewport_adjustment_changed, + (gpointer) viewport); + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + (GtkSignalFunc)gtk_viewport_adjustment_value_changed, + (gpointer) viewport); + + gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport); + } } void diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c index f272617528..053131e654 100644 --- a/gtk/gtkvscrollbar.c +++ b/gtk/gtkvscrollbar.c @@ -146,7 +146,9 @@ gtk_vscrollbar_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + range->trough = widget->window; + gdk_window_ref (range->trough); attributes.x = widget->style->klass->xthickness; attributes.y = widget->style->klass->ythickness; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 7cf35547ea..1ded117db5 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -135,6 +135,8 @@ static GdkColormap* gtk_widget_peek_colormap (void); static GdkVisual* gtk_widget_peek_visual (void); static GtkStyle* gtk_widget_peek_style (void); +static void gtk_widget_reparent_container_child (GtkWidget *widget, + gpointer client_data); static void gtk_widget_set_parent_sensitive (GtkWidget *widget, gpointer client_data); static void gtk_widget_propagate_restore (GtkWidget *widget, @@ -730,11 +732,19 @@ gtk_widget_init (GtkWidget *widget) colormap = gtk_widget_peek_colormap (); visual = gtk_widget_peek_visual (); + /* XXX - should we ref the colormap and visual, too? */ + if (colormap != gtk_widget_get_default_colormap ()) - gtk_object_set_data (GTK_OBJECT (widget), colormap_key, colormap); - + { + /* gdk_colormap_ref (colormap); */ + gtk_object_set_data (GTK_OBJECT (widget), colormap_key, colormap); + } + if (visual != gtk_widget_get_default_visual ()) - gtk_object_set_data (GTK_OBJECT (widget), visual_key, visual); + { + /* gdk_visual_ref (visual); */ + gtk_object_set_data (GTK_OBJECT (widget), visual_key, visual); + } } /***************************************** @@ -1549,6 +1559,26 @@ gtk_widget_activate (GtkWidget *widget) * results: *****************************************/ +static void +gtk_widget_reparent_container_child(GtkWidget *widget, + gpointer client_data) +{ + GtkWidget *new_parent = GTK_WIDGET (client_data); + + g_return_if_fail (widget != NULL); + g_return_if_fail (client_data != NULL); + + if (!GTK_WIDGET_NO_WINDOW (widget)) + gdk_window_reparent (widget->window, new_parent->window, 0, 0); + else if (GTK_IS_CONTAINER (widget)) + gtk_container_foreach (GTK_CONTAINER (widget), + gtk_widget_reparent_container_child, + new_parent); + else + widget->window = new_parent->window; +} + + void gtk_widget_reparent (GtkWidget *widget, GtkWidget *new_parent) @@ -1559,32 +1589,35 @@ gtk_widget_reparent (GtkWidget *widget, if (widget->parent != new_parent) { + gtk_object_ref (GTK_OBJECT (widget)); gtk_container_remove (GTK_CONTAINER (widget->parent), widget); gtk_container_add (GTK_CONTAINER (new_parent), widget); - + gtk_object_unref (GTK_OBJECT (widget)); + if (GTK_WIDGET_REALIZED (widget)) { - if (GTK_WIDGET_REALIZED (new_parent) && !GTK_WIDGET_NO_WINDOW (widget)) + if (GTK_WIDGET_REALIZED (new_parent)) { - gdk_window_reparent (widget->window, widget->parent->window, 0, 0); + if (GTK_WIDGET_NO_WINDOW (widget)) + { + if (GTK_IS_CONTAINER (widget)) + gtk_container_foreach (GTK_CONTAINER(widget), + gtk_widget_reparent_container_child, + new_parent); + else + widget->window = widget->parent->window; + } + else + gdk_window_reparent (widget->window, widget->parent->window, 0, 0); } else - { - GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED); - if (!GTK_WIDGET_NO_WINDOW (widget)) - gdk_window_destroy (widget->window); - widget->window = NULL; - - if (GTK_WIDGET_REALIZED (new_parent)) - gtk_widget_realize (widget); - if (GTK_WIDGET_MAPPED (new_parent)) - gtk_widget_map (widget); - } + gtk_widget_unrealize (widget); } if (!GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_REALIZED (new_parent)) gtk_widget_realize (widget); - if (!GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_MAPPED (new_parent)) + if (GTK_WIDGET_VISIBLE (widget) && + !GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_MAPPED (new_parent)) gtk_widget_map (widget); gtk_widget_queue_resize (widget); @@ -2446,9 +2479,14 @@ gtk_widget_pop_style () void gtk_widget_set_default_colormap (GdkColormap *colormap) { - if (default_colormap && (default_colormap != colormap)) - gdk_colormap_destroy (default_colormap); - default_colormap = colormap; + if (default_colormap != colormap) + { + if (default_colormap) + gdk_colormap_unref (default_colormap); + default_colormap = colormap; + if (default_colormap) + gdk_colormap_ref (default_colormap); + } } /***************************************** @@ -2476,11 +2514,14 @@ gtk_widget_set_default_visual (GdkVisual *visual) void gtk_widget_set_default_style (GtkStyle *style) { - if (default_style) - gtk_style_unref (default_style); - - default_style = style; - gtk_style_ref (default_style); + if (style != default_style) + { + if (default_style) + gtk_style_unref (default_style); + default_style = style; + if (default_style) + gtk_style_ref (default_style); + } } /* Basically, send a message to all toplevel windows telling them @@ -2854,7 +2895,7 @@ gtk_real_widget_unrealize (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED | GTK_VISIBLE); + GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED); gtk_style_detach (widget->style); if (!GTK_WIDGET_NO_WINDOW (widget)) @@ -3177,7 +3218,6 @@ gtk_widget_set_style_internal (GtkWidget *widget, gtk_style_detach (widget->style); gtk_style_unref (widget->style); - widget->style = style; gtk_style_ref (widget->style); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 4fc8dd5e33..f7ed03ed70 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -25,6 +25,7 @@ enum { MOVE_RESIZE, + SET_FOCUS, LAST_SIGNAL }; @@ -35,13 +36,18 @@ typedef gint (*GtkWindowSignal1) (GtkObject *object, gint arg3, gint arg4, gpointer data); - +typedef void (*GtkWindowSignal2) (GtkObject *object, + gpointer arg1, + gpointer data); static void gtk_window_marshal_signal_1 (GtkObject *object, GtkSignalFunc func, gpointer func_data, GtkArg *args); - +static void gtk_window_marshal_signal_2 (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); static void gtk_window_class_init (GtkWindowClass *klass); static void gtk_window_init (GtkWindow *window); static void gtk_window_arg (GtkWindow *window, @@ -80,6 +86,8 @@ static gint gtk_real_window_move_resize (GtkWindow *window, gint *y, gint width, gint height); +static void gtk_real_window_set_focus (GtkWindow *window, + GtkWidget *focus); static gint gtk_window_move_resize (GtkWidget *widget); static void gtk_window_set_hints (GtkWidget *widget, GtkRequisition *requisition); @@ -144,6 +152,15 @@ gtk_window_class_init (GtkWindowClass *klass) GTK_TYPE_POINTER, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_INT); + window_signals[SET_FOCUS] = + gtk_signal_new ("set_focus", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GtkWindowClass, set_focus), + gtk_window_marshal_signal_2, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); + gtk_object_class_add_signals (object_class, window_signals, LAST_SIGNAL); object_class->destroy = gtk_window_destroy; @@ -168,6 +185,7 @@ gtk_window_class_init (GtkWindowClass *klass) container_class->need_resize = gtk_window_need_resize; klass->move_resize = gtk_real_window_move_resize; + klass->set_focus = gtk_real_window_set_focus; } static void @@ -270,36 +288,7 @@ void gtk_window_set_focus (GtkWindow *window, GtkWidget *focus) { - GdkEventFocus event; - - g_return_if_fail (window != NULL); - g_return_if_fail (GTK_IS_WINDOW (window)); - - if (focus && !GTK_WIDGET_CAN_FOCUS (focus)) - return; - - if (window->focus_widget != focus) - { - if (window->focus_widget) - { - event.type = GDK_FOCUS_CHANGE; - event.window = window->focus_widget->window; - event.in = FALSE; - - gtk_widget_event (window->focus_widget, (GdkEvent*) &event); - } - - window->focus_widget = focus; - - if (window->focus_widget) - { - event.type = GDK_FOCUS_CHANGE; - event.window = window->focus_widget->window; - event.in = TRUE; - - gtk_widget_event (window->focus_widget, (GdkEvent*) &event); - } - } + gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus); } void @@ -350,7 +339,8 @@ gtk_window_add_accelerator_table (GtkWindow *window, g_return_if_fail (GTK_IS_WINDOW (window)); gtk_accelerator_table_ref (table); - window->accelerator_tables = g_list_prepend (window->accelerator_tables, table); + window->accelerator_tables = g_list_prepend (window->accelerator_tables, + table); } void @@ -360,7 +350,8 @@ gtk_window_remove_accelerator_table (GtkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); - window->accelerator_tables = g_list_remove (window->accelerator_tables, table); + window->accelerator_tables = g_list_remove (window->accelerator_tables, + table); gtk_accelerator_table_unref (table); } @@ -395,6 +386,19 @@ gtk_window_marshal_signal_1 (GtkObject *object, } static void +gtk_window_marshal_signal_2 (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + GtkWindowSignal2 rfunc; + + rfunc = (GtkWindowSignal2) func; + + (* rfunc) (object, GTK_VALUE_POINTER (args[0]), func_data); +} + +static void gtk_window_destroy (GtkObject *object) { GtkWindow *window; @@ -1128,6 +1132,42 @@ gtk_window_move_resize (GtkWidget *widget) } static void +gtk_real_window_set_focus (GtkWindow *window, + GtkWidget *focus) +{ + GdkEventFocus event; + + g_return_if_fail (window != NULL); + g_return_if_fail (GTK_IS_WINDOW (window)); + + if (focus && !GTK_WIDGET_CAN_FOCUS (focus)) + return; + + if (window->focus_widget != focus) + { + if (window->focus_widget) + { + event.type = GDK_FOCUS_CHANGE; + event.window = window->focus_widget->window; + event.in = FALSE; + + gtk_widget_event (window->focus_widget, (GdkEvent*) &event); + } + + window->focus_widget = focus; + + if (window->focus_widget) + { + event.type = GDK_FOCUS_CHANGE; + event.window = window->focus_widget->window; + event.in = TRUE; + + gtk_widget_event (window->focus_widget, (GdkEvent*) &event); + } + } +} + +static void gtk_window_set_hints (GtkWidget *widget, GtkRequisition *requisition) { diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index ff22527312..755b9340c5 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -66,6 +66,8 @@ struct _GtkWindowClass gint *y, gint width, gint height); + void (* set_focus) (GtkWindow *window, + GtkWidget *focus); }; diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 1a54d439f7..a1d5545dfe 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -2763,6 +2763,194 @@ create_gamma_curve () ++count; } +static int scroll_test_pos = 0.0; +static GdkGC *scroll_test_gc = NULL; + +static gint +scroll_test_expose (GtkWidget *widget, GdkEventExpose *event, + GtkAdjustment *adj) +{ + gint i,j; + gint imin, imax, jmin, jmax; + + imin = (event->area.x) / 10; + imax = (event->area.x + event->area.width + 9) / 10; + + jmin = ((int)adj->value + event->area.y) / 10; + jmax = ((int)adj->value + event->area.y + event->area.height + 9) / 10; + + gdk_window_clear_area (widget->window, + event->area.x, event->area.y, + event->area.width, event->area.height); + + for (i=imin; i<imax; i++) + for (j=jmin; j<jmax; j++) + if ((i+j) % 2) + gdk_draw_rectangle (widget->window, + widget->style->black_gc, + TRUE, + 10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10); + + return TRUE; +} + +static void +scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event, + GtkAdjustment *adj) +{ + adj->page_increment = 0.9 * widget->allocation.height; + adj->page_size = widget->allocation.height; + + gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed"); +} + +static void +scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget) +{ + gint source_min = (int)adj->value - scroll_test_pos; + gint source_max = source_min + widget->allocation.height; + gint dest_min = 0; + gint dest_max = widget->allocation.height; + GdkRectangle rect; + GdkEvent *event; + + scroll_test_pos = adj->value; + + if (!GTK_WIDGET_DRAWABLE (widget)) + return; + + if (source_min < 0) + { + rect.x = 0; + rect.y = 0; + rect.width = widget->allocation.width; + rect.height = -source_min; + if (rect.height > widget->allocation.height) + rect.height = widget->allocation.height; + + source_min = 0; + dest_min = rect.height; + } + else + { + rect.x = 0; + rect.y = 2*widget->allocation.height - source_max; + if (rect.y < 0) + rect.y = 0; + rect.width = widget->allocation.width; + rect.height = widget->allocation.height - rect.y; + + source_max = widget->allocation.height; + dest_max = rect.y; + } + + if (source_min != source_max) + { + if (scroll_test_gc == NULL) + { + scroll_test_gc = gdk_gc_new (widget->window); + gdk_gc_set_exposures (scroll_test_gc, TRUE); + } + + gdk_draw_pixmap (widget->window, + scroll_test_gc, + widget->window, + 0, source_min, + 0, dest_min, + widget->allocation.width, + source_max - source_min); + + /* Make sure graphics expose events are processed before scrolling + * again */ + + while ((event = gdk_event_get_graphics_expose (widget->window)) != NULL) + { + gtk_widget_event (widget, event); + if (event->expose.count == 0) + { + gdk_event_free (event); + break; + } + gdk_event_free (event); + } + } + + + if (rect.height != 0) + gtk_widget_draw (widget, &rect); +} + + +void +create_scroll_test () +{ + static GtkWidget *window = NULL; + GtkWidget *hbox; + GtkWidget *drawing_area; + GtkWidget *scrollbar; + GtkWidget *button; + GtkAdjustment *adj; + + if (!window) + { + window = gtk_dialog_new (); + + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC(destroy_window), + &window); + gtk_signal_connect (GTK_OBJECT (window), "delete_event", + GTK_SIGNAL_FUNC(destroy_window), + &window); + + gtk_window_set_title (GTK_WINDOW (window), "Scroll Test"); + gtk_container_border_width (GTK_CONTAINER (window), 0); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), hbox, + TRUE, TRUE, 0); + gtk_widget_show (hbox); + + drawing_area = gtk_drawing_area_new (); + gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200); + gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0); + gtk_widget_show (drawing_area); + + gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK); + + adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1000.0, 1.0, 180.0, 200.0)); + scroll_test_pos = 0.0; + + scrollbar = gtk_vscrollbar_new (adj); + gtk_box_pack_start (GTK_BOX (hbox), scrollbar, FALSE, FALSE, 0); + gtk_widget_show (scrollbar); + + gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", + GTK_SIGNAL_FUNC (scroll_test_expose), adj); + gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event", + GTK_SIGNAL_FUNC (scroll_test_configure), adj); + + + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (scroll_test_adjustment_changed), + drawing_area); + + /* .. And create some buttons */ + + button = gtk_button_new_with_label ("Quit"); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area), + button, TRUE, TRUE, 0); + + gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (window)); + gtk_widget_show (button); + } + + if (!GTK_WIDGET_VISIBLE (window)) + gtk_widget_show (window); + else + gtk_widget_destroy (window); +} /* * Timeout Test @@ -3069,6 +3257,7 @@ create_main_window () { "preview color", create_color_preview }, { "preview gray", create_gray_preview }, { "gamma curve", create_gamma_curve }, + { "test scrolling", create_scroll_test }, { "test selection", create_selection_test }, { "test timeout", create_timeout_test }, { "test idle", create_idle_test }, diff --git a/gtk/testinput.c b/gtk/testinput.c index 1c6dae0e1d..218e5ca769 100644 --- a/gtk/testinput.c +++ b/gtk/testinput.c @@ -96,9 +96,7 @@ static gint configure_event (GtkWidget *widget, GdkEventConfigure *event) { if (pixmap) - { - gdk_pixmap_destroy(pixmap); - } + gdk_pixmap_unref (pixmap); pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, @@ -187,6 +185,17 @@ button_press_event (GtkWidget *widget, GdkEventButton *event) } static gint +key_press_event (GtkWidget *widget, GdkEventKey *event) +{ + if ((event->keyval >= 0x20) && (event->keyval <= 0xFF)) + printf("I got a %c\n", event->keyval); + else + printf("I got some other key\n"); + + return TRUE; +} + +static gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { GdkTimeCoord *coords; @@ -338,6 +347,8 @@ main (int argc, char *argv[]) (GtkSignalFunc) motion_notify_event, NULL); gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", (GtkSignalFunc) button_press_event, NULL); + gtk_signal_connect (GTK_OBJECT (drawing_area), "key_press_event", + (GtkSignalFunc) key_press_event, NULL); gtk_signal_connect (GTK_OBJECT (drawing_area), "leave_notify_event", (GtkSignalFunc) leave_notify_event, NULL); @@ -347,6 +358,7 @@ main (int argc, char *argv[]) gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK + | GDK_KEY_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_PROXIMITY_OUT_MASK); @@ -355,6 +367,8 @@ main (int argc, char *argv[]) events for the drawing area */ gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_ALL); + gtk_widget_grab_focus (drawing_area); + /* .. And create some buttons */ button = gtk_button_new_with_label ("Input Dialog"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); diff --git a/gtk/testselection.c b/gtk/testselection.c index 0a1fd87f49..6f33be989d 100644 --- a/gtk/testselection.c +++ b/gtk/testselection.c @@ -319,6 +319,7 @@ selection_received (GtkWidget *widget, GtkSelectionData *data) name?name:"<unknown>", data->type); position = data->length; + continue; } } gtk_text_insert (GTK_TEXT (selection_text), NULL, |