Mercurial > hg > xemacs-beta
annotate src/scrollbar-gtk.c @ 5191:71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
tests/ChangeLog addition:
2010-04-05 Aidan Kehoe <kehoea@parhasard.net>
* automated/hash-table-tests.el:
Test the new built-in #'equalp hash table test. Test
#'define-hash-table-test.
* automated/lisp-tests.el:
When asserting that two objects are #'equalp, also assert that
their #'equalp-hash is identical.
man/ChangeLog addition:
2010-04-03 Aidan Kehoe <kehoea@parhasard.net>
* lispref/hash-tables.texi (Introduction to Hash Tables):
Document that we now support #'equalp as a hash table test by
default, and mention #'define-hash-table-test.
(Working With Hash Tables): Document #'define-hash-table-test.
src/ChangeLog addition:
2010-04-05 Aidan Kehoe <kehoea@parhasard.net>
* elhash.h:
* elhash.c (struct Hash_Table_Test, lisp_object_eql_equal)
(lisp_object_eql_hash, lisp_object_equal_equal)
(lisp_object_equal_hash, lisp_object_equalp_hash)
(lisp_object_equalp_equal, lisp_object_general_hash)
(lisp_object_general_equal, Feq_hash, Feql_hash, Fequal_hash)
(Fequalp_hash, define_hash_table_test, Fdefine_hash_table_test)
(init_elhash_once_early, mark_hash_table_tests, string_equalp_hash):
* glyphs.c (vars_of_glyphs):
Add a new hash table test in C, #'equalp.
Make it possible to specify new hash table tests with functions
define_hash_table_test, #'define-hash-table-test.
Use define_hash_table_test() in glyphs.c.
Expose the hash functions (besides that used for #'equal) to Lisp,
for people writing functions to be used with #'define-hash-table-test.
Call define_hash_table_test() very early in temacs, to create the
built-in hash table tests.
* ui-gtk.c (emacs_gtk_boxed_hash):
* specifier.h (struct specifier_methods):
* specifier.c (specifier_hash):
* rangetab.c (range_table_entry_hash, range_table_hash):
* number.c (bignum_hash, ratio_hash, bigfloat_hash):
* marker.c (marker_hash):
* lrecord.h (struct lrecord_implementation):
* keymap.c (keymap_hash):
* gui.c (gui_item_id_hash, gui_item_hash):
* glyphs.c (image_instance_hash, glyph_hash):
* glyphs-x.c (x_image_instance_hash):
* glyphs-msw.c (mswindows_image_instance_hash):
* glyphs-gtk.c (gtk_image_instance_hash):
* frame-msw.c (mswindows_set_title_from_ibyte):
* fontcolor.c (color_instance_hash, font_instance_hash):
* fontcolor-x.c (x_color_instance_hash):
* fontcolor-tty.c (tty_color_instance_hash):
* fontcolor-msw.c (mswindows_color_instance_hash):
* fontcolor-gtk.c (gtk_color_instance_hash):
* fns.c (bit_vector_hash):
* floatfns.c (float_hash):
* faces.c (face_hash):
* extents.c (extent_hash):
* events.c (event_hash):
* data.c (weak_list_hash, weak_box_hash):
* chartab.c (char_table_entry_hash, char_table_hash):
* bytecode.c (compiled_function_hash):
* alloc.c (vector_hash):
Change the various object hash methods to take a new EQUALP
parameter, hashing appropriately for #'equalp if it is true.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Mon, 05 Apr 2010 13:03:35 +0100 |
| parents | 5ddbab03b0e6 |
| children | 308d34e9f07d |
| rev | line source |
|---|---|
| 2168 | 1 /* scrollbar implementation -- GTK interface. |
| 462 | 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
| 3 Copyright (C) 1994 Amdhal Corporation. | |
| 4 Copyright (C) 1995 Sun Microsystems, Inc. | |
| 5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>. | |
|
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
6 Copyright (C) 2010 Ben Wing. |
| 462 | 7 |
| 8 This file is part of XEmacs. | |
| 9 | |
| 10 XEmacs is free software; you can redistribute it and/or modify it | |
| 11 under the terms of the GNU General Public License as published by the | |
| 12 Free Software Foundation; either version 2, or (at your option) any | |
| 13 later version. | |
| 14 | |
| 15 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 18 for more details. | |
| 19 | |
| 20 You should have received a copy of the GNU General Public License | |
| 21 along with XEmacs; see the file COPYING. If not, write to | |
| 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 23 Boston, MA 02111-1307, USA. */ | |
| 24 | |
| 25 /* Synched up with: Not in FSF. */ | |
| 26 /* Gtk version by William M. Perry */ | |
| 27 | |
| 28 #include <config.h> | |
| 29 #include "lisp.h" | |
| 30 | |
| 872 | 31 #include "frame-impl.h" |
| 32 #include "window.h" | |
| 33 | |
| 34 #include "console-gtk-impl.h" | |
| 462 | 35 #include "glyphs-gtk.h" |
| 36 #include "scrollbar-gtk.h" | |
| 37 | |
| 38 static gboolean scrollbar_cb (GtkAdjustment *adj, gpointer user_data); | |
| 39 | |
| 40 /* Used to prevent changing the size of the slider while drag | |
| 41 scrolling, under Motif. This is necessary because the Motif | |
| 42 scrollbar is incredibly stupid about updating the slider and causes | |
| 43 lots of flicker if it is done too often. */ | |
| 44 static int inhibit_slider_size_change; | |
| 45 | |
| 46 static int vertical_drag_in_progress; | |
| 47 | |
| 48 | |
| 49 /* A device method. */ | |
| 50 static int | |
| 51 gtk_inhibit_scrollbar_slider_size_change (void) | |
| 52 { | |
| 53 return inhibit_slider_size_change; | |
| 54 } | |
| 55 | |
| 56 /* A device method. */ | |
| 57 static void | |
| 58 gtk_free_scrollbar_instance (struct scrollbar_instance *instance) | |
| 59 { | |
| 3482 | 60 if (instance->scrollbar_data) |
| 462 | 61 { |
| 3482 | 62 if (SCROLLBAR_GTK_WIDGET (instance)) |
| 63 { | |
| 64 gtk_widget_hide_all (SCROLLBAR_GTK_WIDGET (instance)); | |
| 65 gtk_widget_destroy (SCROLLBAR_GTK_WIDGET (instance)); | |
| 66 } | |
| 67 | |
|
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
3482
diff
changeset
|
68 xfree (instance->scrollbar_data); |
|
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
69 instance->scrollbar_data = 0; |
| 462 | 70 } |
| 71 } | |
| 72 | |
| 73 /* A device method. */ | |
| 74 static void | |
| 75 gtk_release_scrollbar_instance (struct scrollbar_instance *instance) | |
| 76 { | |
| 77 /* It won't hurt to hide it all the time, will it? */ | |
| 78 gtk_widget_hide_all (SCROLLBAR_GTK_WIDGET (instance)); | |
| 79 } | |
| 80 | |
| 81 static gboolean | |
| 2286 | 82 scrollbar_drag_hack_cb (GtkWidget *UNUSED (w), GdkEventButton *UNUSED (ev), |
| 83 gpointer v) | |
| 462 | 84 { |
| 85 vertical_drag_in_progress = (int) v; | |
| 86 inhibit_slider_size_change = (int) v; | |
| 87 return (FALSE); | |
| 88 } | |
| 89 | |
| 90 /* A device method. */ | |
| 91 static void | |
| 92 gtk_create_scrollbar_instance (struct frame *f, int vertical, | |
| 93 struct scrollbar_instance *instance) | |
| 94 { | |
| 95 GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0,0,0,0,0,0)); | |
| 96 GtkScrollbar *sb = NULL; | |
| 97 | |
| 98 /* initialize the X specific data section. */ | |
| 99 instance->scrollbar_data = xnew_and_zero (struct gtk_scrollbar_data); | |
| 100 | |
| 101 SCROLLBAR_GTK_ID (instance) = new_gui_id (); | |
| 102 SCROLLBAR_GTK_VDRAG_ORIG_VALUE (instance) = -1; | |
| 103 SCROLLBAR_GTK_LAST_VALUE (instance) = adj->value; | |
| 104 | |
| 2168 | 105 gtk_object_set_data (GTK_OBJECT (adj), GTK_DATA_GUI_IDENTIFIER, (void *) SCROLLBAR_GTK_ID (instance)); |
| 106 gtk_object_set_data (GTK_OBJECT (adj), GTK_DATA_FRAME_IDENTIFIER, f); | |
| 462 | 107 |
| 108 sb = GTK_SCROLLBAR (vertical ? gtk_vscrollbar_new (adj) : gtk_hscrollbar_new (adj)); | |
| 109 SCROLLBAR_GTK_WIDGET (instance) = GTK_WIDGET (sb); | |
| 110 | |
| 111 gtk_signal_connect (GTK_OBJECT (adj),"value-changed", | |
| 112 GTK_SIGNAL_FUNC (scrollbar_cb), (gpointer) vertical); | |
| 113 | |
| 114 gtk_signal_connect (GTK_OBJECT (sb), "button-press-event", | |
| 115 GTK_SIGNAL_FUNC (scrollbar_drag_hack_cb), (gpointer) 1); | |
| 116 gtk_signal_connect (GTK_OBJECT (sb), "button-release-event", | |
| 117 GTK_SIGNAL_FUNC (scrollbar_drag_hack_cb), (gpointer) 0); | |
| 118 | |
| 119 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), SCROLLBAR_GTK_WIDGET (instance), 0, 0); | |
| 525 | 120 |
| 121 /* | |
| 122 ** With gtk version > 1.2.8 the scrollbars in gtk-xemacs and xemacs | |
| 123 ** from CVS are invisible. In fact they are not invisible but very | |
| 124 ** thin (0 pixels wide). This is so, because the new gtk code does | |
| 125 ** not call gtk_widget_request_size() on the newly created | |
| 126 ** scrollbars anymore. this change was done to allow the theme | |
| 127 ** engines to manipulate the scrollbar width. This patch calls | |
| 128 ** gtk_widget_request_size with the newly created scollbars. Maybe | |
| 129 ** it is better to postpone this call just before the | |
| 130 ** gtk_widget_show() call is done on the scrolbar. | |
| 131 */ | |
| 132 gtk_widget_size_request(GTK_WIDGET(sb), &(GTK_WIDGET(sb)->requisition)); | |
| 133 | |
| 462 | 134 gtk_widget_hide (SCROLLBAR_GTK_WIDGET (instance)); |
| 135 } | |
| 136 | |
| 137 #define UPDATE_DATA_FIELD(field) \ | |
| 138 if (new_##field >= 0 && \ | |
| 139 SCROLLBAR_GTK_POS_DATA (inst).field != new_##field) { \ | |
| 140 SCROLLBAR_GTK_POS_DATA (inst).field = new_##field; \ | |
| 141 inst->scrollbar_instance_changed = 1; \ | |
| 142 } | |
| 143 | |
| 144 /* A device method. */ | |
| 145 /* #### The -1 check is such a hack. */ | |
| 146 static void | |
| 147 gtk_update_scrollbar_instance_values (struct window *w, | |
| 148 struct scrollbar_instance *inst, | |
| 149 int new_line_increment, | |
| 150 int new_page_increment, | |
| 151 int new_minimum, int new_maximum, | |
| 152 int new_slider_size, | |
| 153 int new_slider_position, | |
| 154 int new_scrollbar_width, | |
| 155 int new_scrollbar_height, | |
| 156 int new_scrollbar_x, int new_scrollbar_y) | |
| 157 { | |
| 158 UPDATE_DATA_FIELD (line_increment); | |
| 159 UPDATE_DATA_FIELD (page_increment); | |
| 160 UPDATE_DATA_FIELD (minimum); | |
| 161 UPDATE_DATA_FIELD (maximum); | |
| 162 UPDATE_DATA_FIELD (slider_size); | |
| 163 UPDATE_DATA_FIELD (slider_position); | |
| 164 UPDATE_DATA_FIELD (scrollbar_width); | |
| 165 UPDATE_DATA_FIELD (scrollbar_height); | |
| 166 UPDATE_DATA_FIELD (scrollbar_x); | |
| 167 UPDATE_DATA_FIELD (scrollbar_y); | |
| 168 | |
| 169 if (w && !vertical_drag_in_progress) | |
| 170 { | |
| 171 int new_vov = SCROLLBAR_GTK_POS_DATA (inst).slider_position; | |
| 172 int new_vows = marker_position (w->start[CURRENT_DISP]); | |
| 173 | |
| 174 if (SCROLLBAR_GTK_VDRAG_ORIG_VALUE (inst) != new_vov) | |
| 175 { | |
| 176 SCROLLBAR_GTK_VDRAG_ORIG_VALUE (inst) = new_vov; | |
| 177 inst->scrollbar_instance_changed = 1; | |
| 178 } | |
| 179 if (SCROLLBAR_GTK_VDRAG_ORIG_WINDOW_START (inst) != new_vows) | |
| 180 { | |
| 181 SCROLLBAR_GTK_VDRAG_ORIG_WINDOW_START (inst) = new_vows; | |
| 182 inst->scrollbar_instance_changed = 1; | |
| 183 } | |
| 184 } | |
| 185 } | |
| 186 | |
| 187 /* Used by gtk_update_scrollbar_instance_status. */ | |
| 188 static void | |
| 189 update_one_widget_scrollbar_pointer (struct window *w, GtkWidget *wid) | |
| 190 { | |
| 191 if (!wid->window) | |
| 192 gtk_widget_realize (wid); | |
| 193 | |
| 194 if (POINTER_IMAGE_INSTANCEP (w->scrollbar_pointer)) | |
| 195 { | |
| 196 gdk_window_set_cursor (GET_GTK_WIDGET_WINDOW (wid), | |
| 197 XIMAGE_INSTANCE_GTK_CURSOR (w->scrollbar_pointer)); | |
| 198 gdk_flush (); | |
| 199 } | |
| 200 } | |
| 201 | |
| 202 /* A device method. */ | |
| 203 static void | |
| 204 gtk_update_scrollbar_instance_status (struct window *w, int active, int size, | |
| 205 struct scrollbar_instance *instance) | |
| 206 { | |
| 207 struct frame *f = XFRAME (w->frame); | |
| 208 GtkWidget *wid = SCROLLBAR_GTK_WIDGET (instance); | |
| 209 gboolean managed = GTK_WIDGET_MAPPED (wid); | |
| 210 | |
| 211 if (active && size) | |
| 212 { | |
| 213 if (instance->scrollbar_instance_changed) | |
| 214 { | |
| 215 /* Need to set the height, width, and position of the widget */ | |
| 216 GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (wid)); | |
| 217 scrollbar_values *pos_data = & SCROLLBAR_GTK_POS_DATA (instance); | |
| 218 int modified_p = 0; | |
| 219 | |
| 220 /* We do not want to update the size all the time if we can | |
| 221 help it. This cuts down on annoying flicker. | |
| 222 */ | |
| 223 if ((wid->allocation.width != pos_data->scrollbar_width) || | |
| 224 (wid->allocation.height != pos_data->scrollbar_height)) | |
| 225 { | |
| 226 gtk_widget_set_usize (wid, | |
| 227 pos_data->scrollbar_width, | |
| 228 pos_data->scrollbar_height); | |
| 2195 | 229 |
| 230 /* | |
| 231 UGLY! UGLY! UGLY! Changes to wid->allocation are queued and | |
| 232 not performed until the GTK event loop. However, when the | |
| 233 fontlock progress bar is run, the vertical scrollbar's height | |
| 234 is change and then changed back before events are again | |
| 235 processed. This means that the change back is not seen and | |
| 236 the scrollbar is left too short. Fix this by making the | |
| 237 change manually so the test above sees the change. This does | |
| 238 not seem to cause problems in other cases. | |
| 239 */ | |
| 240 | |
| 241 wid->allocation.width = pos_data->scrollbar_width; | |
| 242 wid->allocation.height = pos_data->scrollbar_height; | |
| 243 | |
| 462 | 244 modified_p = 1; |
| 245 } | |
| 246 | |
| 247 /* Ditto for the x/y position. */ | |
| 248 if ((wid->allocation.x != pos_data->scrollbar_x) || | |
| 249 (wid->allocation.y != pos_data->scrollbar_y)) | |
| 250 { | |
| 251 gtk_fixed_move (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), | |
| 252 wid, | |
| 253 pos_data->scrollbar_x, | |
| 254 pos_data->scrollbar_y); | |
| 2195 | 255 |
| 256 /* | |
| 257 UGLY! UGLY! UGLY! Changes to wid->allocation are queued and | |
| 258 not performed until the GTK event loop. However, when the | |
| 259 fontlock progress bar is run, the horizontal scrollbar's | |
| 260 position is change and then changed back before events are | |
| 261 again processed. This means that the change back is not seen | |
| 262 and the scrollbar is left in the wrong position. Fix this by | |
| 263 making the change manually so the test above sees the change. | |
| 264 This does not seem to cause problems in other cases. | |
| 265 */ | |
| 266 | |
| 267 wid->allocation.x = pos_data->scrollbar_x; | |
| 268 wid->allocation.y = pos_data->scrollbar_y; | |
| 269 | |
| 462 | 270 modified_p = 1; |
| 271 } | |
| 272 | |
| 273 adj->lower = pos_data->minimum; | |
| 274 adj->upper = pos_data->maximum; | |
| 275 adj->page_increment = pos_data->slider_size + 1; | |
| 276 adj->step_increment = w->max_line_len - 1; | |
| 277 adj->page_size = pos_data->slider_size + 1; | |
| 278 adj->value = pos_data->slider_position; | |
| 279 | |
| 280 /* But, if we didn't resize or move the scrollbar, the | |
| 281 widget will not get redrawn correctly when the user | |
| 282 scrolls around in the XEmacs frame manually. So we | |
| 283 update the slider manually here. | |
| 284 */ | |
| 285 if (!modified_p) | |
| 286 gtk_range_slider_update (GTK_RANGE (wid)); | |
| 287 | |
| 288 instance->scrollbar_instance_changed = 0; | |
| 289 } | |
| 290 | |
| 291 if (!managed) | |
| 292 { | |
| 293 gtk_widget_show (wid); | |
| 294 update_one_widget_scrollbar_pointer (w, wid); | |
| 295 } | |
| 296 } | |
| 297 else if (managed) | |
| 298 { | |
| 299 gtk_widget_hide (wid); | |
| 300 } | |
| 301 } | |
| 302 | |
| 303 enum gtk_scrollbar_loop | |
| 304 { | |
| 305 GTK_FIND_SCROLLBAR_WINDOW_MIRROR, | |
| 306 GTK_SET_SCROLLBAR_POINTER, | |
| 307 GTK_WINDOW_IS_SCROLLBAR, | |
| 308 GTK_UPDATE_FRAME_SCROLLBARS | |
| 309 }; | |
| 310 | |
| 311 static struct window_mirror * | |
| 312 gtk_scrollbar_loop (enum gtk_scrollbar_loop type, Lisp_Object window, | |
| 313 struct window_mirror *mir, | |
| 314 GUI_ID id, GdkWindow *x_win) | |
| 315 { | |
| 316 struct window_mirror *retval = NULL; | |
| 317 | |
| 318 while (mir) | |
| 319 { | |
| 320 struct scrollbar_instance *vinstance = mir->scrollbar_vertical_instance; | |
| 321 struct scrollbar_instance *hinstance = mir->scrollbar_horizontal_instance; | |
| 322 struct window *w = XWINDOW (window); | |
| 323 | |
| 324 if (mir->vchild) | |
| 325 retval = gtk_scrollbar_loop (type, w->vchild, mir->vchild, id, x_win); | |
| 326 else if (mir->hchild) | |
| 327 retval = gtk_scrollbar_loop (type, w->hchild, mir->hchild, id, x_win); | |
| 328 if (retval) | |
| 329 return retval; | |
| 330 | |
| 331 if (hinstance || vinstance) | |
| 332 { | |
| 333 switch (type) | |
| 334 { | |
| 335 case GTK_FIND_SCROLLBAR_WINDOW_MIRROR: | |
| 336 if ((vinstance && SCROLLBAR_GTK_ID (vinstance) == id) || | |
| 337 (hinstance && SCROLLBAR_GTK_ID (hinstance) == id)) | |
| 338 return mir; | |
| 339 break; | |
| 340 case GTK_UPDATE_FRAME_SCROLLBARS: | |
| 341 if (!mir->vchild && !mir->hchild) | |
| 342 update_window_scrollbars (w, mir, 1, 0); | |
| 343 break; | |
| 344 case GTK_SET_SCROLLBAR_POINTER: | |
| 345 if (!mir->vchild && !mir->hchild) | |
| 346 { | |
| 347 GtkWidget *widget; | |
| 348 | |
| 349 widget = SCROLLBAR_GTK_WIDGET (hinstance); | |
| 350 if (widget && GTK_WIDGET_MAPPED (widget)) | |
| 351 update_one_widget_scrollbar_pointer (w, widget); | |
| 352 | |
| 353 widget = SCROLLBAR_GTK_WIDGET (vinstance); | |
| 354 if (widget && GTK_WIDGET_MAPPED (widget)) | |
| 355 update_one_widget_scrollbar_pointer (w, widget); | |
| 356 } | |
| 357 break; | |
| 358 case GTK_WINDOW_IS_SCROLLBAR: | |
| 359 if (!mir->vchild && !mir->hchild) | |
| 360 { | |
| 361 GtkWidget *widget; | |
| 362 | |
| 363 widget = SCROLLBAR_GTK_WIDGET (hinstance); | |
| 364 if (widget && GTK_WIDGET_MAPPED (widget) && | |
| 365 GET_GTK_WIDGET_WINDOW (widget) == x_win) | |
| 366 return (struct window_mirror *) 1; | |
| 367 | |
| 368 widget = SCROLLBAR_GTK_WIDGET (vinstance); | |
| 369 if (widget && GTK_WIDGET_MAPPED (widget) && | |
| 370 GET_GTK_WIDGET_WINDOW (widget) == x_win) | |
| 371 return (struct window_mirror *) 1; | |
| 372 } | |
| 373 break; | |
| 374 default: | |
| 2500 | 375 ABORT (); |
| 462 | 376 } |
| 377 } | |
| 378 | |
| 379 mir = mir->next; | |
| 380 window = w->next; | |
| 381 } | |
| 382 | |
| 383 return NULL; | |
| 384 } | |
| 385 | |
| 386 /* Used by callbacks. */ | |
| 387 static struct window_mirror * | |
| 388 find_scrollbar_window_mirror (struct frame *f, GUI_ID id) | |
| 389 { | |
| 390 if (f->mirror_dirty) | |
| 391 update_frame_window_mirror (f); | |
| 392 return gtk_scrollbar_loop (GTK_FIND_SCROLLBAR_WINDOW_MIRROR, f->root_window, | |
| 617 | 393 XWINDOW_MIRROR (f->root_mirror), id, |
| 394 (GdkWindow *) NULL); | |
| 462 | 395 } |
| 396 | |
| 397 static gboolean | |
| 398 scrollbar_cb (GtkAdjustment *adj, gpointer user_data) | |
| 399 { | |
| 400 /* This function can GC */ | |
| 401 int vertical = (int) user_data; | |
| 2168 | 402 struct frame *f = (struct frame*) gtk_object_get_data (GTK_OBJECT (adj), GTK_DATA_FRAME_IDENTIFIER); |
| 617 | 403 struct scrollbar_instance *instance; |
| 2168 | 404 GUI_ID id = (GUI_ID) gtk_object_get_data (GTK_OBJECT (adj), GTK_DATA_GUI_IDENTIFIER); |
| 462 | 405 Lisp_Object win, frame; |
| 406 struct window_mirror *mirror; | |
| 407 Lisp_Object event_type = Qnil; | |
| 408 Lisp_Object event_data = Qnil; | |
| 409 | |
| 410 if (!f) | |
| 411 return(FALSE); | |
| 412 | |
| 413 mirror = find_scrollbar_window_mirror (f, id); | |
| 414 if (!mirror) | |
| 415 return(FALSE); | |
| 416 | |
| 417 win = real_window (mirror, 1); | |
| 418 | |
| 419 if (NILP (win)) | |
| 420 return(FALSE); | |
| 421 instance = vertical ? mirror->scrollbar_vertical_instance : mirror->scrollbar_horizontal_instance; | |
| 422 frame = WINDOW_FRAME (XWINDOW (win)); | |
| 423 | |
| 424 inhibit_slider_size_change = 0; | |
| 425 switch (GTK_RANGE (SCROLLBAR_GTK_WIDGET (instance))->scroll_type) | |
| 426 { | |
| 427 case GTK_SCROLL_PAGE_BACKWARD: | |
| 428 event_type = vertical ? Qscrollbar_page_up : Qscrollbar_page_left; | |
| 429 event_data = Fcons (win, Qnil); | |
| 430 break; | |
| 431 case GTK_SCROLL_PAGE_FORWARD: | |
| 432 event_type = vertical ? Qscrollbar_page_down : Qscrollbar_page_right; | |
| 433 event_data = Fcons (win, Qnil); | |
| 434 break; | |
| 435 case GTK_SCROLL_STEP_FORWARD: | |
| 436 event_type = vertical ? Qscrollbar_line_down : Qscrollbar_char_right; | |
| 437 event_data = win; | |
| 438 break; | |
| 439 case GTK_SCROLL_STEP_BACKWARD: | |
| 440 event_type = vertical ? Qscrollbar_line_up : Qscrollbar_char_left; | |
| 441 event_data = win; | |
| 442 break; | |
| 443 case GTK_SCROLL_NONE: | |
| 444 case GTK_SCROLL_JUMP: | |
| 445 inhibit_slider_size_change = 1; | |
| 446 event_type = vertical ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag; | |
| 447 event_data = Fcons (win, make_int ((int)adj->value)); | |
| 448 break; | |
| 449 default: | |
| 2500 | 450 ABORT(); |
| 462 | 451 } |
| 452 | |
| 453 signal_special_gtk_user_event (frame, event_type, event_data); | |
| 454 | |
| 455 return (TRUE); | |
| 456 } | |
| 457 | |
| 458 static void | |
| 459 gtk_scrollbar_pointer_changed_in_window (struct window *w) | |
| 460 { | |
| 793 | 461 Lisp_Object window = wrap_window (w); |
| 462 | 462 |
| 617 | 463 gtk_scrollbar_loop (GTK_SET_SCROLLBAR_POINTER, window, |
| 464 find_window_mirror (w), 0, (GdkWindow *) NULL); | |
| 462 | 465 } |
| 466 | |
| 467 /* #### BILL!!! This comment is not true for Gtk - should it be? */ | |
| 468 /* Make sure that all scrollbars on frame are up-to-date. Called | |
| 469 directly from gtk_set_frame_properties in frame-gtk.c*/ | |
| 470 void | |
| 471 gtk_update_frame_scrollbars (struct frame *f) | |
| 472 { | |
| 617 | 473 gtk_scrollbar_loop (GTK_UPDATE_FRAME_SCROLLBARS, f->root_window, |
| 474 XWINDOW_MIRROR (f->root_mirror), | |
| 462 | 475 0, (GdkWindow *) NULL); |
| 476 } | |
| 477 | |
| 478 #ifdef MEMORY_USAGE_STATS | |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
479 static Bytecount |
| 2286 | 480 gtk_compute_scrollbar_instance_usage (struct device *UNUSED (d), |
| 462 | 481 struct scrollbar_instance *inst, |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
482 struct usage_stats *ustats) |
| 462 | 483 { |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
484 struct gtk_scrollbar_data *data = |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
485 (struct gtk_scrollbar_data *) inst->scrollbar_data; |
| 462 | 486 |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5169
diff
changeset
|
487 return malloced_storage_size (data, sizeof (*data), ustats); |
| 462 | 488 } |
| 489 | |
| 490 #endif /* MEMORY_USAGE_STATS */ | |
| 491 | |
| 492 | |
| 493 /************************************************************************/ | |
| 494 /* initialization */ | |
| 495 /************************************************************************/ | |
| 496 | |
| 497 void | |
| 498 console_type_create_scrollbar_gtk (void) | |
| 499 { | |
| 500 CONSOLE_HAS_METHOD (gtk, inhibit_scrollbar_slider_size_change); | |
| 501 CONSOLE_HAS_METHOD (gtk, free_scrollbar_instance); | |
| 502 CONSOLE_HAS_METHOD (gtk, release_scrollbar_instance); | |
| 503 CONSOLE_HAS_METHOD (gtk, create_scrollbar_instance); | |
| 504 CONSOLE_HAS_METHOD (gtk, update_scrollbar_instance_values); | |
| 505 CONSOLE_HAS_METHOD (gtk, update_scrollbar_instance_status); | |
| 506 CONSOLE_HAS_METHOD (gtk, scrollbar_pointer_changed_in_window); | |
| 507 #ifdef MEMORY_USAGE_STATS | |
| 508 CONSOLE_HAS_METHOD (gtk, compute_scrollbar_instance_usage); | |
| 509 #endif /* MEMORY_USAGE_STATS */ | |
| 510 } | |
| 511 | |
| 512 void | |
| 513 vars_of_scrollbar_gtk (void) | |
| 514 { | |
| 515 Fprovide (intern ("gtk-scrollbars")); | |
| 516 } |
