Mercurial > audlegacy
annotate src/audacious/widgets/textbox.c @ 2574:40407b7363f3 trunk
[svn] - enforce playback stop when clearing the playlist to load new files in. closes #808.
| author | nenolod |
|---|---|
| date | Sun, 25 Feb 2007 00:53:19 -0800 |
| parents | ad1d7687814c |
| children |
| rev | line source |
|---|---|
| 2313 | 1 /* BMP - Cross-platform multimedia player |
| 2 * Copyright (C) 2003-2004 BMP development team. | |
| 3 * | |
| 4 * Based on XMMS: | |
| 5 * Copyright (C) 1998-2003 XMMS development team. | |
| 6 * | |
| 7 * This program is free software; you can redistribute it and/or modify | |
| 8 * it under the terms of the GNU General Public License as published by | |
| 9 * the Free Software Foundation; either version 2 of the License, or | |
| 10 * (at your option) any later version. | |
| 11 * | |
| 12 * This program is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 * GNU General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU General Public License | |
| 18 * along with this program; if not, write to the Free Software | |
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 */ | |
| 21 | |
| 22 #include "widgetcore.h" | |
| 23 | |
| 24 #include <glib.h> | |
| 25 #include <gtk/gtk.h> | |
| 26 #include <gdk/gdk.h> | |
| 27 #include <gdk/gdkprivate.h> | |
| 28 #include <string.h> | |
| 29 #include <ctype.h> | |
| 30 | |
| 31 #include "main.h" | |
|
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2313
diff
changeset
|
32 #include "strings.h" |
| 2313 | 33 #include "util.h" |
| 34 | |
| 35 static void textbox_generate_pixmap(TextBox * tb); | |
| 36 | |
| 37 static void | |
| 38 textbox_draw(Widget * w) | |
| 39 { | |
| 40 TextBox *tb = TEXT_BOX(w); | |
| 41 gint cw; | |
| 42 GdkPixmap *obj; | |
| 43 GdkPixmap *src; | |
| 44 | |
| 45 g_return_if_fail(tb != NULL); | |
| 46 g_return_if_fail(tb->tb_widget.visible != FALSE); | |
| 47 | |
| 48 if (tb->tb_text && | |
| 49 (!tb->tb_pixmap_text || strcmp(tb->tb_text, tb->tb_pixmap_text))) | |
| 50 textbox_generate_pixmap(tb); | |
| 51 | |
| 52 if (tb->tb_pixmap) { | |
| 53 if (skin_get_id() != tb->tb_skin_id) { | |
| 54 tb->tb_skin_id = skin_get_id(); | |
| 55 textbox_generate_pixmap(tb); | |
| 56 } | |
| 57 obj = tb->tb_widget.parent; | |
| 58 src = tb->tb_pixmap; | |
| 59 | |
| 60 cw = tb->tb_pixmap_width - tb->tb_offset; | |
| 61 if (cw > tb->tb_widget.width) | |
| 62 cw = tb->tb_widget.width; | |
| 63 gdk_draw_drawable(obj, tb->tb_widget.gc, src, tb->tb_offset, 0, | |
| 64 tb->tb_widget.x, tb->tb_widget.y, cw, | |
| 65 tb->tb_widget.height); | |
| 66 if (cw < tb->tb_widget.width) | |
| 67 gdk_draw_drawable(obj, tb->tb_widget.gc, src, 0, 0, | |
| 68 tb->tb_widget.x + cw, tb->tb_widget.y, | |
| 69 tb->tb_widget.width - cw, tb->tb_widget.height); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 static gboolean | |
| 74 textbox_scroll(gpointer data) | |
| 75 { | |
| 76 TextBox *tb = TEXT_BOX(data); | |
| 77 | |
| 78 if (!tb->tb_is_dragging) { | |
| 79 tb->tb_offset += 1; | |
| 80 if (tb->tb_offset >= tb->tb_pixmap_width) | |
| 81 tb->tb_offset -= tb->tb_pixmap_width; | |
| 82 widget_draw(WIDGET(tb)); | |
| 83 } | |
| 84 | |
| 85 return TRUE; | |
| 86 } | |
| 87 | |
| 88 static void | |
| 89 textbox_button_press(GtkWidget * w, GdkEventButton * event, gpointer data) | |
| 90 { | |
| 91 TextBox *tb = TEXT_BOX(data); | |
| 92 | |
| 93 if (event->button != 1) | |
| 94 return; | |
| 95 if (widget_contains(&tb->tb_widget, event->x, event->y) && | |
| 96 tb->tb_scroll_allowed && | |
| 97 tb->tb_pixmap_width > tb->tb_widget.width && tb->tb_is_scrollable) { | |
| 98 tb->tb_is_dragging = TRUE; | |
| 99 tb->tb_drag_off = tb->tb_offset; | |
| 100 tb->tb_drag_x = event->x; | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 static void | |
| 105 textbox_motion(GtkWidget * w, GdkEventMotion * event, gpointer data) | |
| 106 { | |
| 107 TextBox *tb = TEXT_BOX(data); | |
| 108 | |
| 109 if (tb->tb_is_dragging) { | |
| 110 if (tb->tb_scroll_allowed && | |
| 111 tb->tb_pixmap_width > tb->tb_widget.width) { | |
| 112 tb->tb_offset = tb->tb_drag_off - (event->x - tb->tb_drag_x); | |
| 113 | |
| 114 while (tb->tb_offset < 0) | |
| 115 tb->tb_offset += tb->tb_pixmap_width; | |
| 116 | |
| 117 while (tb->tb_offset > tb->tb_pixmap_width) | |
| 118 tb->tb_offset -= tb->tb_pixmap_width; | |
| 119 | |
| 120 widget_draw(WIDGET(tb)); | |
| 121 } | |
| 122 } | |
| 123 } | |
| 124 | |
| 125 static void | |
| 126 textbox_button_release(GtkWidget * w, GdkEventButton * event, gpointer data) | |
| 127 { | |
| 128 TextBox *tb = TEXT_BOX(data); | |
| 129 | |
| 130 if (event->button == 1) | |
| 131 tb->tb_is_dragging = FALSE; | |
| 132 } | |
| 133 | |
| 134 static gboolean | |
| 135 textbox_should_scroll(TextBox * tb) | |
| 136 { | |
| 137 g_return_val_if_fail(tb != NULL, FALSE); | |
| 138 | |
| 139 if (!tb->tb_scroll_allowed) | |
| 140 return FALSE; | |
| 141 | |
| 142 if (tb->tb_font) { | |
| 143 gint width; | |
| 144 | |
| 145 text_get_extents(tb->tb_fontname, tb->tb_text, &width, NULL, NULL, | |
| 146 NULL); | |
| 147 | |
| 148 if (width <= tb->tb_widget.width) | |
| 149 return FALSE; | |
| 150 else | |
| 151 return TRUE; | |
| 152 } | |
| 153 | |
| 154 if (g_utf8_strlen(tb->tb_text, -1) * bmp_active_skin->properties.textbox_bitmap_font_width > tb->tb_widget.width) | |
| 155 return TRUE; | |
| 156 | |
| 157 return FALSE; | |
| 158 } | |
| 159 | |
| 160 void | |
| 161 textbox_set_text(TextBox * tb, const gchar * text) | |
| 162 { | |
| 163 g_return_if_fail(tb != NULL); | |
| 164 g_return_if_fail(text != NULL); | |
| 165 | |
| 166 widget_lock(WIDGET(tb)); | |
| 167 | |
| 168 if (tb->tb_text) { | |
| 169 if (!strcmp(text, tb->tb_text)) { | |
| 170 widget_unlock(WIDGET(tb)); | |
| 171 return; | |
| 172 } | |
| 173 g_free(tb->tb_text); | |
| 174 } | |
| 175 | |
| 176 tb->tb_text = str_to_utf8(text); | |
| 177 | |
| 178 widget_unlock(WIDGET(tb)); | |
| 179 widget_draw(WIDGET(tb)); | |
| 180 } | |
| 181 | |
| 182 static void | |
| 183 textbox_generate_xfont_pixmap(TextBox * tb, const gchar * pixmaptext) | |
| 184 { | |
| 185 gint length, i; | |
| 186 GdkGC *gc, *maskgc; | |
| 187 GdkColor *c, pattern; | |
| 188 GdkBitmap *mask; | |
| 189 PangoLayout *layout; | |
| 190 gint width; | |
| 191 | |
| 192 g_return_if_fail(tb != NULL); | |
| 193 g_return_if_fail(pixmaptext != NULL); | |
| 194 | |
| 195 length = g_utf8_strlen(pixmaptext, -1); | |
| 196 | |
| 197 text_get_extents(tb->tb_fontname, pixmaptext, &width, NULL, NULL, NULL); | |
| 198 | |
| 199 tb->tb_pixmap_width = MAX(width, tb->tb_widget.width); | |
| 200 tb->tb_pixmap = gdk_pixmap_new(mainwin->window, tb->tb_pixmap_width, | |
| 201 tb->tb_widget.height, | |
| 202 gdk_rgb_get_visual()->depth); | |
| 203 gc = tb->tb_widget.gc; | |
| 204 c = skin_get_color(bmp_active_skin, SKIN_TEXTBG); | |
| 205 for (i = 0; i < tb->tb_widget.height; i++) { | |
| 206 gdk_gc_set_foreground(gc, &c[6 * i / tb->tb_widget.height]); | |
| 207 gdk_draw_line(tb->tb_pixmap, gc, 0, i, tb->tb_pixmap_width, i); | |
| 208 } | |
| 209 | |
| 210 mask = gdk_pixmap_new(mainwin->window, tb->tb_pixmap_width, | |
| 211 tb->tb_widget.height, 1); | |
| 212 maskgc = gdk_gc_new(mask); | |
| 213 pattern.pixel = 0; | |
| 214 gdk_gc_set_foreground(maskgc, &pattern); | |
| 215 | |
| 216 gdk_draw_rectangle(mask, maskgc, TRUE, 0, 0, | |
| 217 tb->tb_pixmap_width, tb->tb_widget.height); | |
| 218 pattern.pixel = 1; | |
| 219 gdk_gc_set_foreground(maskgc, &pattern); | |
| 220 | |
| 221 gdk_gc_set_foreground(gc, skin_get_color(bmp_active_skin, SKIN_TEXTFG)); | |
| 222 | |
| 223 layout = gtk_widget_create_pango_layout(mainwin, pixmaptext); | |
| 224 pango_layout_set_font_description(layout, tb->tb_font); | |
| 225 | |
| 226 gdk_draw_layout(tb->tb_pixmap, gc, 0, (tb->tb_font_descent / 2), layout); | |
| 227 g_object_unref(layout); | |
| 228 | |
| 229 g_object_unref(maskgc); | |
| 230 | |
| 231 gdk_gc_set_clip_mask(gc, mask); | |
| 232 c = skin_get_color(bmp_active_skin, SKIN_TEXTFG); | |
| 233 for (i = 0; i < tb->tb_widget.height; i++) { | |
| 234 gdk_gc_set_foreground(gc, &c[6 * i / tb->tb_widget.height]); | |
| 235 gdk_draw_line(tb->tb_pixmap, gc, 0, i, tb->tb_pixmap_width, i); | |
| 236 } | |
| 237 g_object_unref(mask); | |
| 238 gdk_gc_set_clip_mask(gc, NULL); | |
| 239 } | |
| 240 | |
| 241 static void | |
| 242 textbox_handle_special_char(gchar c, gint * x, gint * y) | |
| 243 { | |
| 244 gint tx, ty; | |
| 245 | |
| 246 switch (c) { | |
| 247 case '"': | |
| 248 tx = 26; | |
| 249 ty = 0; | |
| 250 break; | |
| 251 case '\r': | |
| 252 tx = 10; | |
| 253 ty = 1; | |
| 254 break; | |
| 255 case ':': | |
| 256 case ';': | |
| 257 tx = 12; | |
| 258 ty = 1; | |
| 259 break; | |
| 260 case '(': | |
| 261 tx = 13; | |
| 262 ty = 1; | |
| 263 break; | |
| 264 case ')': | |
| 265 tx = 14; | |
| 266 ty = 1; | |
| 267 break; | |
| 268 case '-': | |
| 269 tx = 15; | |
| 270 ty = 1; | |
| 271 break; | |
| 272 case '`': | |
| 273 case '\'': | |
| 274 tx = 16; | |
| 275 ty = 1; | |
| 276 break; | |
| 277 case '!': | |
| 278 tx = 17; | |
| 279 ty = 1; | |
| 280 break; | |
| 281 case '_': | |
| 282 tx = 18; | |
| 283 ty = 1; | |
| 284 break; | |
| 285 case '+': | |
| 286 tx = 19; | |
| 287 ty = 1; | |
| 288 break; | |
| 289 case '\\': | |
| 290 tx = 20; | |
| 291 ty = 1; | |
| 292 break; | |
| 293 case '/': | |
| 294 tx = 21; | |
| 295 ty = 1; | |
| 296 break; | |
| 297 case '[': | |
| 298 tx = 22; | |
| 299 ty = 1; | |
| 300 break; | |
| 301 case ']': | |
| 302 tx = 23; | |
| 303 ty = 1; | |
| 304 break; | |
| 305 case '^': | |
| 306 tx = 24; | |
| 307 ty = 1; | |
| 308 break; | |
| 309 case '&': | |
| 310 tx = 25; | |
| 311 ty = 1; | |
| 312 break; | |
| 313 case '%': | |
| 314 tx = 26; | |
| 315 ty = 1; | |
| 316 break; | |
| 317 case '.': | |
| 318 case ',': | |
| 319 tx = 27; | |
| 320 ty = 1; | |
| 321 break; | |
| 322 case '=': | |
| 323 tx = 28; | |
| 324 ty = 1; | |
| 325 break; | |
| 326 case '$': | |
| 327 tx = 29; | |
| 328 ty = 1; | |
| 329 break; | |
| 330 case '#': | |
| 331 tx = 30; | |
| 332 ty = 1; | |
| 333 break; | |
| 334 case 'å': | |
| 335 case 'Å': | |
| 336 tx = 0; | |
| 337 ty = 2; | |
| 338 break; | |
| 339 case 'ö': | |
| 340 case 'Ö': | |
| 341 tx = 1; | |
| 342 ty = 2; | |
| 343 break; | |
| 344 case 'ä': | |
| 345 case 'Ä': | |
| 346 tx = 2; | |
| 347 ty = 2; | |
| 348 break; | |
| 349 case 'ü': | |
| 350 case 'Ü': | |
| 351 tx = 20; | |
| 352 ty = 0; | |
| 353 break; | |
| 354 case '?': | |
| 355 tx = 3; | |
| 356 ty = 2; | |
| 357 break; | |
| 358 case '*': | |
| 359 tx = 4; | |
| 360 ty = 2; | |
| 361 break; | |
| 362 default: | |
| 363 tx = 29; | |
| 364 ty = 0; | |
| 365 break; | |
| 366 } | |
| 367 | |
| 368 *x = tx * bmp_active_skin->properties.textbox_bitmap_font_width; | |
| 369 *y = ty * bmp_active_skin->properties.textbox_bitmap_font_height; | |
| 370 } | |
| 371 | |
| 372 static void | |
| 373 textbox_generate_pixmap(TextBox * tb) | |
| 374 { | |
| 375 gint length, i, x, y, wl; | |
| 376 gchar *pixmaptext; | |
| 377 GdkGC *gc; | |
| 378 | |
| 379 g_return_if_fail(tb != NULL); | |
| 380 | |
| 381 if (tb->tb_pixmap) { | |
| 382 g_object_unref(tb->tb_pixmap); | |
| 383 tb->tb_pixmap = NULL; | |
| 384 } | |
| 385 | |
| 386 /* | |
| 387 * Don't reset the offset if only text after the last '(' has | |
| 388 * changed. This is a hack to avoid visual noice on vbr files | |
| 389 * where we guess the length. | |
| 390 */ | |
| 391 if (!(tb->tb_pixmap_text && strrchr(tb->tb_text, '(') && | |
| 392 !strncmp(tb->tb_pixmap_text, tb->tb_text, | |
| 393 strrchr(tb->tb_text, '(') - tb->tb_text))) | |
| 394 tb->tb_offset = 0; | |
| 395 | |
| 396 g_free(tb->tb_pixmap_text); | |
| 397 tb->tb_pixmap_text = g_strdup(tb->tb_text); | |
| 398 | |
| 399 /* | |
| 400 * wl is the number of (partial) letters visible. Only makes | |
| 401 * sense when using skinned font. | |
| 402 */ | |
| 403 | |
| 404 wl = tb->tb_widget.width / 5; | |
| 405 if (wl * 5 != tb->tb_widget.width) | |
| 406 wl++; | |
| 407 | |
| 408 length = g_utf8_strlen(tb->tb_text, -1); | |
| 409 | |
| 410 tb->tb_is_scrollable = FALSE; | |
| 411 | |
| 412 if (textbox_should_scroll(tb)) { | |
| 413 tb->tb_is_scrollable = TRUE; | |
| 414 pixmaptext = g_strconcat(tb->tb_pixmap_text, " *** ", NULL); | |
| 415 length += 7; | |
| 416 } | |
| 417 else if (!tb->tb_font && length <= wl) { | |
| 418 gint pad = wl - length; | |
| 419 gchar *padchars = g_strnfill(pad, ' '); | |
| 420 | |
| 421 pixmaptext = g_strconcat(tb->tb_pixmap_text, padchars, NULL); | |
| 422 g_free(padchars); | |
| 423 length += pad; | |
| 424 } | |
| 425 else | |
| 426 pixmaptext = g_strdup(tb->tb_pixmap_text); | |
| 427 | |
| 428 | |
| 429 if (tb->tb_is_scrollable) { | |
| 430 if (tb->tb_scroll_enabled && !tb->tb_timeout_tag) { | |
| 431 gint tag; | |
| 432 tag = TEXTBOX_SCROLL_SMOOTH_TIMEOUT; | |
| 433 tb->tb_timeout_tag = g_timeout_add(tag, textbox_scroll, tb); | |
| 434 } | |
| 435 } | |
| 436 else { | |
| 437 if (tb->tb_timeout_tag) { | |
| 438 g_source_remove(tb->tb_timeout_tag); | |
| 439 tb->tb_timeout_tag = 0; | |
| 440 } | |
| 441 tb->tb_offset = 0; | |
| 442 } | |
| 443 | |
| 444 if (tb->tb_font) { | |
| 445 textbox_generate_xfont_pixmap(tb, pixmaptext); | |
| 446 g_free(pixmaptext); | |
| 447 return; | |
| 448 } | |
| 449 | |
| 450 tb->tb_pixmap_width = length * bmp_active_skin->properties.textbox_bitmap_font_width; | |
| 451 tb->tb_pixmap = gdk_pixmap_new(mainwin->window, | |
| 452 tb->tb_pixmap_width, bmp_active_skin->properties.textbox_bitmap_font_height, | |
| 453 gdk_rgb_get_visual()->depth); | |
| 454 gc = tb->tb_widget.gc; | |
| 455 | |
| 456 for (i = 0; i < length; i++) { | |
| 457 gchar c; | |
| 458 x = y = -1; | |
| 459 c = toupper((int) pixmaptext[i]); | |
| 460 if (c >= 'A' && c <= 'Z') { | |
| 461 x = bmp_active_skin->properties.textbox_bitmap_font_width * (c - 'A'); | |
| 462 y = 0; | |
| 463 } | |
| 464 else if (c >= '0' && c <= '9') { | |
| 465 x = bmp_active_skin->properties.textbox_bitmap_font_width * (c - '0'); | |
| 466 y = bmp_active_skin->properties.textbox_bitmap_font_height; | |
| 467 } | |
| 468 else | |
| 469 textbox_handle_special_char(c, &x, &y); | |
| 470 | |
| 471 skin_draw_pixmap(bmp_active_skin, | |
| 472 tb->tb_pixmap, gc, tb->tb_skin_index, | |
| 473 x, y, i * bmp_active_skin->properties.textbox_bitmap_font_width, 0, bmp_active_skin->properties.textbox_bitmap_font_width, | |
| 474 bmp_active_skin->properties.textbox_bitmap_font_height); | |
| 475 } | |
| 476 g_free(pixmaptext); | |
| 477 } | |
| 478 | |
| 479 void | |
| 480 textbox_set_scroll(TextBox * tb, gboolean s) | |
| 481 { | |
| 482 g_return_if_fail(tb != NULL); | |
| 483 | |
| 484 tb->tb_scroll_enabled = s; | |
| 485 if (tb->tb_scroll_enabled && tb->tb_is_scrollable | |
| 486 && tb->tb_scroll_allowed) { | |
| 487 gint tag; | |
| 488 tag = TEXTBOX_SCROLL_SMOOTH_TIMEOUT; | |
| 489 | |
| 490 if (tb->tb_timeout_tag) | |
| 491 { | |
| 492 g_source_remove(tb->tb_timeout_tag); | |
| 493 tb->tb_timeout_tag = 0; | |
| 494 } | |
| 495 | |
| 496 tb->tb_timeout_tag = g_timeout_add(tag, textbox_scroll, tb); | |
| 497 } | |
| 498 else | |
| 499 { | |
| 500 if (tb->tb_timeout_tag) | |
| 501 { | |
| 502 g_source_remove(tb->tb_timeout_tag); | |
| 503 tb->tb_timeout_tag = 0; | |
| 504 } | |
| 505 | |
| 506 tb->tb_offset = 0; | |
| 507 widget_draw(WIDGET(tb)); | |
| 508 } | |
| 509 | |
| 510 } | |
| 511 | |
| 512 void | |
| 513 textbox_set_xfont(TextBox * tb, gboolean use_xfont, const gchar * fontname) | |
| 514 { | |
| 515 gint ascent, descent; | |
| 516 | |
| 517 g_return_if_fail(tb != NULL); | |
| 518 | |
| 519 if (tb->tb_font) { | |
| 520 pango_font_description_free(tb->tb_font); | |
| 521 tb->tb_font = NULL; | |
| 522 } | |
| 523 | |
| 524 tb->tb_widget.y = tb->tb_nominal_y; | |
| 525 tb->tb_widget.height = tb->tb_nominal_height; | |
| 526 | |
| 527 /* Make sure the pixmap is regenerated */ | |
| 528 if (tb->tb_pixmap_text) { | |
| 529 g_free(tb->tb_pixmap_text); | |
| 530 tb->tb_pixmap_text = NULL; | |
| 531 } | |
| 532 | |
| 533 if (!use_xfont || strlen(fontname) == 0) | |
| 534 return; | |
| 535 | |
| 536 tb->tb_font = pango_font_description_from_string(fontname); | |
| 537 tb->tb_fontname = g_strdup(fontname); | |
| 538 | |
| 539 text_get_extents(fontname, | |
| 540 "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ", | |
| 541 NULL, NULL, &ascent, &descent); | |
| 542 tb->tb_font_ascent = ascent; | |
| 543 tb->tb_font_descent = descent; | |
| 544 | |
| 545 | |
| 546 if (tb->tb_font == NULL) | |
| 547 return; | |
| 548 | |
| 549 tb->tb_widget.height = tb->tb_font_ascent; | |
| 550 if (tb->tb_widget.height > tb->tb_nominal_height) | |
| 551 tb->tb_widget.y -= (tb->tb_widget.height - tb->tb_nominal_height) / 2; | |
| 552 else | |
| 553 tb->tb_widget.height = tb->tb_nominal_height; | |
| 554 } | |
| 555 | |
| 556 TextBox * | |
| 557 create_textbox(GList ** wlist, GdkPixmap * parent, GdkGC * gc, | |
| 558 gint x, gint y, gint w, gboolean allow_scroll, SkinPixmapId si) | |
| 559 { | |
| 560 TextBox *tb; | |
| 561 | |
| 562 tb = g_new0(TextBox, 1); | |
| 563 widget_init(&tb->tb_widget, parent, gc, x, y, w, bmp_active_skin->properties.textbox_bitmap_font_height, 1); | |
| 564 tb->tb_widget.button_press_cb = textbox_button_press; | |
| 565 tb->tb_widget.button_release_cb = textbox_button_release; | |
| 566 tb->tb_widget.motion_cb = textbox_motion; | |
| 567 tb->tb_widget.draw = textbox_draw; | |
| 568 tb->tb_scroll_allowed = allow_scroll; | |
| 569 tb->tb_scroll_enabled = TRUE; | |
| 570 tb->tb_skin_index = si; | |
| 571 tb->tb_nominal_y = y; | |
| 572 tb->tb_nominal_height = tb->tb_widget.height; | |
| 573 widget_list_add(wlist, WIDGET(tb)); | |
| 574 tb->tb_timeout_tag = 0; | |
| 575 return tb; | |
| 576 } | |
| 577 | |
| 578 void | |
| 579 textbox_free(TextBox * tb) | |
| 580 { | |
| 581 g_return_if_fail(tb != NULL); | |
| 582 | |
| 583 if (tb->tb_pixmap) | |
| 584 g_object_unref(tb->tb_pixmap); | |
| 585 g_free(tb->tb_text); | |
| 586 g_free(tb); | |
| 587 } |
