| tvkaista-0.971/tvkaista_gtkui.c | | tvkaista-0.975/tvkaista_gtkui.c |
| 4 | WARN="-Wall -Wno-long-long -Wstrict-prototypes -pedantic" | 4 | WARN="-Wall -Wno-long-long -Wstrict-prototypes -pedantic" |
| 5 | WARN="$WARN -Wcast-align -Wpointer-arith " # -Wfloat-equal #-Werror | 5 | WARN="$WARN -Wcast-align -Wpointer-arith " # -Wfloat-equal #-Werror |
| 6 | WARN="$WARN -W -Wwrite-strings -Wcast-qual -Wshadow" # -Wconversion | 6 | WARN="$WARN -W -Wwrite-strings -Wcast-qual -Wshadow" # -Wconversion |
| 7 | FLAGS=`pkg-config --cflags --libs gtk+-2.0` | 7 | FLAGS=`pkg-config --cflags --libs gtk+-2.0 | sed 's/-I/-isystem '/g` |
| 8 | ver=`sed -n 's/Version=//p' tvkaista.desktop` | 8 | ver=`sed -n 's/Version=//p' tvkaista.desktop` |
| 9 | OPTS="$WARN $FLAGS -DVERSION=$ver" | 9 | OPTS="$WARN $FLAGS -DVERSION=$ver" # -DCDATE=\"`date`\"" |
| | 10 | case $1 in '') set x -ggdb |
| 10 | case $1 in '') set x -O2 ### set x -ggdb | 11 | #case $1 in '') set x -O2 ### set x -ggdb |
| 11 | shift ;; esac; | 12 | shift ;; esac; |
| 12 | set -x; ${CC:-gcc} -std=gnu99 $OPTS "$@" -o "$TRG" "$0" -DCDATE="\"`date`\"" | 13 | set -x; ${CC:-gcc} -std=gnu99 $OPTS "$@" -o "$TRG" "$0" custom-list.o |
| 13 | exit $? | 14 | exit $? |
| 14 | | 15 | |
| 15 | */ | 16 | */ |
| 50 | | 51 | |
| 51 | #include <errno.h> | 52 | #include <errno.h> |
| 52 | | 53 | |
| | 54 | #include "custom-list.h" |
| | 55 | |
| 53 | #define null ((void*)0) | 56 | #define null ((void*)0) |
| 54 | | 57 | |
| 55 | enum { false = 0, true = 1 } bool; | 58 | enum { false = 0, true = 1 } bool; |
| 100 | } | 103 | } |
| 101 | #endif | 104 | #endif |
| 102 | | 105 | |
| 103 | typedef struct | | |
| 104 | { | | |
| 105 | int id; | | |
| 106 | int16_t channelindex; | | |
| 107 | int16_t txtfileindex; | | |
| 108 | int txtoffset; | | |
| 109 | } PrgInfo; | | |
| 110 | | | |
| 111 | | | |
| 112 | #define MAXSEARCHLEN 30 | 106 | #define MAXSEARCHLEN 30 |
| 113 | struct | 107 | struct |
| 114 | { | 108 | { |
| 115 | int channelfilter; | 109 | int channelfilter; |
| 116 | int16_t maxchannelindex; | 110 | int16_t maxchannelindex; |
| 117 | bool8 dotextfiltering; | | |
| 118 | bool8 notidle; | 111 | bool8 notidle; |
| 119 | char * path; | 112 | char * path; |
| 120 | char compare[MAXSEARCHLEN + 2]; | 113 | char compare[MAXSEARCHLEN + 2]; |
| 121 | // max 32 for now (14 is current maximum in tvkaista). | 114 | // max 32 for now (14 is current maximum in tvkaista). |
| 122 | char prgfile[32][sizeof "2/program_2009-mm-dd"]; | 115 | char prgfile[32][sizeof "3/program_2009-mm-dd"]; |
| 123 | int prgfd[32]; | 116 | int prgfd[32]; |
| 124 | PrgInfo * prgbuffers[100]; // up to 100 000 programs. | 117 | int indx; |
| 125 | int previndx; | 118 | int prevabsindx; |
| 126 | } G; | 119 | } G; |
| 127 | | 120 | |
| 128 | /* widgets in separate structure, for code readability */ | 121 | /* widgets in separate structure, for code readability */ |
| 132 | GtkWidget * scb; /* speed combo box */ | 125 | GtkWidget * scb; /* speed combo box */ |
| 133 | GtkWidget * pcb; /* player combo box */ | 126 | GtkWidget * pcb; /* player combo box */ |
| 134 | GtkTextBuffer * txtbuffer; /* detailed program text */ | 127 | GtkTextBuffer * txtbuffer; /* detailed program text */ |
| 135 | GtkTreeModelFilter * listfilter; | 128 | GtkWidget * listview; |
| | 129 | CustomList * listmodel; |
| 136 | } W; | 130 | } W; |
| 137 | | 131 | |
| 138 | // XXX make better later... | 132 | // XXX make better later... |
| 142 | { | 136 | { |
| 143 | memset(&G, 0, sizeof G); | 137 | memset(&G, 0, sizeof G); |
| 144 | memset(&W, 0, sizeof W); | 138 | memset(&W, 0, sizeof W); |
| 145 | G.previndx = -1; | 139 | G.indx = G.prevabsindx = -1; |
| 146 | for (unsigned int i = 0; i < sizeof G.prgfd / sizeof G.prgfd[0]; i++) | 140 | for (unsigned int i = 0; i < sizeof G.prgfd / sizeof G.prgfd[0]; i++) |
| 147 | G.prgfd[i] = -1; | 141 | G.prgfd[i] = -1; |
| 148 | } | 142 | } |
| 166 | return popen(cmdline, "r"); | 160 | return popen(cmdline, "r"); |
| 167 | } | 161 | } |
| 168 | | 162 | |
| 169 | enum | 163 | void refilter_model(void) |
| 170 | { | 164 | { |
| 171 | COL_DATE = 0, | 165 | //g_object_ref(W.listfilter); // there will be 1 reference always... |
| 172 | COL_TIME, | 166 | gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview), null); |
| 173 | COL_CHANNEL, | 167 | #if 1 |
| 174 | COL_PROGRAM, | 168 | struct timeval st, et; |
| 175 | COL_HIDDEN_INDEX, | 169 | gettimeofday(&st, null); |
| 176 | NUM_COLS | 170 | #endif |
| 177 | }; | 171 | custom_list_filter(W.listmodel, G.channelfilter, G.compare); |
| | 172 | #if 1 |
| | 173 | gettimeofday(&et, null); |
| | 174 | printf("%.3f\n", (float)(et.tv_sec - st.tv_sec) * 1000 |
| | 175 | + (float)(et.tv_usec - st.tv_usec) / 1000); |
| | 176 | #endif |
| 178 | | 177 | |
| 179 | bool visible_rows(GtkTreeModel * model, GtkTreeIter * iter, gpointer data) | 178 | gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview), |
| 180 | { | 179 | GTK_TREE_MODEL(W.listmodel)); |
| 181 | (void)data; | 180 | //g_object_unref(W.listfilter); // there will be 1 reference always... |
| 182 | | | |
| 183 | if (G.channelfilter) { | | |
| 184 | int indx; | | |
| 185 | gtk_tree_model_get (model, iter, COL_HIDDEN_INDEX, &indx, -1); | | |
| 186 | int i = indx / 1000, j = indx % 1000; | | |
| 187 | PrgInfo * prginfo = &G.prgbuffers[i][j]; | | |
| 188 | if (G.channelfilter != prginfo->channelindex) | | |
| 189 | return false; | | |
| 190 | } | | |
| 191 | | | |
| 192 | if (! G.dotextfiltering) | | |
| 193 | return true; | | |
| 194 | | | |
| 195 | gchar * str; | | |
| 196 | gtk_tree_model_get (model, iter, COL_PROGRAM, &str, -1); | | |
| 197 | if (!str) | | |
| 198 | return false; | | |
| 199 | gboolean visible = (strcasestr(str, G.compare) != null); | | |
| 200 | g_free(str); | | |
| 201 | return visible; | | |
| 202 | } | 181 | } |
| | 182 | |
| | 183 | // after filter make unselected -- and G.indx == -1 |
| 203 | | 184 | |
| 204 | bool selected_row(GtkTreeSelection * selection, | 185 | bool selected_row(GtkTreeSelection * selection, |
| 205 | GtkTreeModel * model, GtkTreePath * path, | 186 | GtkTreeModel * model, GtkTreePath * path, |
| 220 | GtkTreeIter iter; | 201 | GtkTreeIter iter; |
| 221 | if (gtk_tree_model_get_iter(model, &iter, path)) | 202 | if (gtk_tree_model_get_iter(model, &iter, path)) |
| 222 | { | 203 | { |
| 223 | int indx; | 204 | int indx = GPOINTER_TO_INT(iter.user_data); |
| 224 | gtk_tree_model_get(model, &iter, COL_HIDDEN_INDEX, &indx, -1); | 205 | CustomRecord * record = custom_list_get_record(W.listmodel, indx); |
| | 206 | if (record == null) |
| | 207 | die("XXXX\n"); |
| | 208 | int absindx = record->absolute_position; |
| 225 | d0(("going to be selected %d %d\n", indx, G.previndx)); | 209 | d0(("going to be selected %d %d\n", absindx, G.prevabsindx)); |
| 226 | if (indx != G.previndx) { | 210 | if (absindx != G.prevabsindx) { |
| 227 | G.previndx = indx; | 211 | G.indx = indx; |
| 228 | int i = indx / 1000, j = indx % 1000; | 212 | G.prevabsindx = absindx; |
| 229 | PrgInfo * prginfo = &G.prgbuffers[i][j]; | | |
| 230 | if (prginfo->txtoffset == 0) { | 213 | if (record->txtoffset == 0) { |
| 231 | gtk_text_buffer_set_text(W.txtbuffer, "Ei ohjelmatietoja.", -1); | 214 | gtk_text_buffer_set_text(W.txtbuffer, "Ei ohjelmatietoja.", -1); |
| 232 | return true; | 215 | return true; |
| 233 | } | 216 | } |
| 234 | int fd = G.prgfd[prginfo->txtfileindex]; | 217 | int fd = G.prgfd[record->txtfileindex]; |
| 235 | if (fd < 0) { | 218 | if (fd < 0) { |
| 236 | fd = open(G.prgfile[prginfo->txtfileindex], O_RDONLY); | 219 | fd = open(G.prgfile[record->txtfileindex], O_RDONLY); |
| 237 | if (fd < 0) | 220 | if (fd < 0) |
| 238 | die("fd %d\n", fd); // XXX | 221 | die("fd %d\n", fd); // XXX |
| 239 | G.prgfd[prginfo->txtfileindex] = fd; | 222 | G.prgfd[record->txtfileindex] = fd; |
| 240 | } | 223 | } |
| 241 | lseek(fd, prginfo->txtoffset, SEEK_SET); | 224 | lseek(fd, record->txtoffset, SEEK_SET); |
| 242 | char buf[1024], *p; | 225 | char buf[1024], *p; |
| 243 | int l = read(fd, buf, sizeof buf - 1); // XXX | 226 | int l = read(fd, buf, sizeof buf - 1); // XXX |
| 244 | if (l > 0) | 227 | if (l > 0) |
| 250 | *p = '\0'; | 233 | *p = '\0'; |
| 251 | d0(("i %d j %d id %d tfi %d to %d tf %s fd %d : %x %x %x\n", | 234 | d0(("i %d j %d id %d tfi %d to %d tf %s fd %d : %x %x %x\n", |
| 252 | i, j, prginfo->id, | 235 | i, j, prginfo->id, |
| 253 | prginfo->txtfileindex, prginfo->txtoffset, | 236 | record->txtfileindex, record->txtoffset, |
| 254 | G.prgfile[prginfo->txtfileindex], fd, buf[0], buf[1], buf[2])); | 237 | G.prgfile[record->txtfileindex], fd, buf[0], buf[1], buf[2])); |
| 255 | gtk_text_buffer_set_text(W.txtbuffer, buf, -1); | 238 | gtk_text_buffer_set_text(W.txtbuffer, buf, -1); |
| 256 | //write(2, buf, strlen(buf)); | 239 | //write(2, buf, strlen(buf)); |
| 257 | } | 240 | } |
| 292 | dest[n - 1] = '\0'; | 275 | dest[n - 1] = '\0'; |
| 293 | } | 276 | } |
| 294 | | 277 | |
| 295 | /* copied and edited | | |
| 296 | http://scentric.net/tutorial/sec-treeview-col-example.htm */ | | |
| 297 | | | |
| 298 | static GtkTreeModel * create_model(void) | | |
| 299 | { | | |
| 300 | W.listfilter = GTK_TREE_MODEL_FILTER( | | |
| 301 | gtk_tree_model_filter_new( | | |
| 302 | GTK_TREE_MODEL(gtk_list_store_new(NUM_COLS, | | |
| 303 | G_TYPE_STRING, G_TYPE_STRING, | | |
| 304 | G_TYPE_STRING, G_TYPE_STRING, | | |
| 305 | G_TYPE_UINT)), 0)); | | |
| 306 | #if 0 | | |
| 307 | liststore = gtk_list_store_new(NUM_COLS, | | |
| 308 | G_TYPE_STRING, G_TYPE_STRING, | | |
| 309 | G_TYPE_STRING, G_TYPE_STRING); | | |
| 310 | #endif | | |
| 311 | | | |
| 312 | gtk_tree_model_filter_set_visible_func(W.listfilter, visible_rows, | | |
| 313 | null, null); | | |
| 314 | return GTK_TREE_MODEL(W.listfilter); | | |
| 315 | } | | |
| 316 | | | |
| 317 | void clear_store(void) | | |
| 318 | { | | |
| 319 | GtkListStore * liststore | | |
| 320 | = GTK_LIST_STORE(gtk_tree_model_filter_get_model(W.listfilter)); | | |
| 321 | gtk_list_store_clear(liststore); | | |
| 322 | } | | |
| 323 | | | |
| 324 | int fill_store(FILE * fh) | 278 | int fill_store(FILE * fh) |
| 325 | { | 279 | { |
| 326 | GtkListStore * liststore | | |
| 327 | = GTK_LIST_STORE(gtk_tree_model_filter_get_model(W.listfilter)); | | |
| 328 | GtkTreeIter iter; | | |
| 329 | char line[1024]; | 280 | char line[1024]; |
| 330 | | 281 | |
| 331 | int id = -1; | 282 | int id = -1; |
| 332 | int offset = 0; | 283 | int offset = 0; |
| 333 | int indx = 0; | | |
| 334 | int prgdayindex = 0; | 284 | int prgdayindex = 0; |
| 335 | int channelindex = 0; | 285 | int channelindex = 0; |
| 336 | char day[10]; | 286 | char day[10]; |
| 379 | case 'X': | 329 | case 'X': |
| 380 | break; | 330 | break; |
| 381 | case 'Q': | 331 | case 'Q': |
| | 332 | custom_list_full(W.listmodel, G.channelfilter, G.compare); |
| 382 | return true; | 333 | return true; |
| 383 | default: | 334 | default: |
| 384 | fprintf(stderr, "Unknown line: '%s'\n", line); | 335 | fprintf(stderr, "Unknown line: '%s'\n", line); |
| 388 | if (id < 0) | 339 | if (id < 0) |
| 389 | continue; | 340 | continue; |
| 390 | | 341 | |
| 391 | int i = indx / 1000; | | |
| 392 | int j = indx % 1000; | | |
| 393 | if (j == 0) { | | |
| 394 | if (i == sizeof G.prgbuffers / sizeof G.prgbuffers[0]) | | |
| 395 | die("i = %d\n", sizeof G.prgbuffers / sizeof G.prgbuffers[0]); | | |
| 396 | G.prgbuffers[i] = malloc(1000 * sizeof (PrgInfo)); | | |
| 397 | if (G.prgbuffers[i] == null) | | |
| 398 | die("G.prgbuffers[%d] == null\n", i); | | |
| 399 | } | | |
| 400 | | | |
| 401 | G.prgbuffers[i][j].id = id; | | |
| 402 | G.prgbuffers[i][j].channelindex = channelindex; | | |
| 403 | G.prgbuffers[i][j].txtfileindex = prgdayindex; | | |
| 404 | G.prgbuffers[i][j].txtoffset = offset; | | |
| 405 | | | |
| 406 | if (channelindex > G.maxchannelindex) | 342 | if (channelindex > G.maxchannelindex) |
| 407 | G.maxchannelindex = channelindex; | 343 | G.maxchannelindex = channelindex; |
| 408 | | 344 | |
| 409 | /*fputs(line, stdout); */ | 345 | custom_list_append(W.listmodel, |
| 410 | gtk_list_store_append(liststore, &iter); | 346 | day, hourmin, channel, shortinfo, |
| 411 | gtk_list_store_set(liststore, &iter, | 347 | id, channelindex, prgdayindex, offset); |
| 412 | COL_DATE, day, | | |
| 413 | COL_TIME, hourmin, | | |
| 414 | COL_CHANNEL, channel, | | |
| 415 | COL_PROGRAM, shortinfo, | | |
| 416 | COL_HIDDEN_INDEX, indx++, | | |
| 417 | -1); | | |
| 418 | id = -1; | 348 | id = -1; |
| 419 | offset = 0; | 349 | offset = 0; |
| 420 | } | 350 | } |
| | 351 | custom_list_full(W.listmodel, G.channelfilter, G.compare); |
| 421 | return false; | 352 | return false; |
| 422 | } | 353 | } |
| 423 | | 354 | |
| 433 | | 364 | |
| 434 | void channel_clicked(int promille) | 365 | void channel_clicked(int promille) |
| 435 | { | 366 | { |
| | 367 | #if 0 |
| 436 | printf("channel_clicked(%d)\n", promille); | 368 | printf("channel_clicked(%d) %d %d\n", promille, |
| 437 | | 369 | G.channelfilter, G.maxchannelindex); |
| | 370 | #endif |
| 438 | if (promille < 300) { | 371 | if (promille < 300) { |
| 439 | if (G.channelfilter <= 1) | 372 | if (G.channelfilter <= 1) |
| 440 | G.channelfilter = G.maxchannelindex; | 373 | G.channelfilter = G.maxchannelindex; |
| 449 | } | 382 | } |
| 450 | else | 383 | else |
| 451 | G.channelfilter = 0; | 384 | G.channelfilter = 0; |
| 452 | gtk_tree_model_filter_refilter(W.listfilter); | 385 | refilter_model(); |
| 453 | G.notidle = false; | 386 | G.notidle = false; |
| 454 | } | 387 | } |
| 455 | | 388 | |
| 488 | GtkTreeViewColumn * col; | 421 | GtkTreeViewColumn * col; |
| 489 | GtkCellRenderer * renderer; | 422 | GtkCellRenderer * renderer; |
| 490 | GtkWidget * view; | 423 | GtkWidget * view; |
| 491 | GtkTreeModel * model; | | |
| 492 | //GtkRequisition sizereq; | | |
| 493 | GtkTreeSelection * selection; | 424 | GtkTreeSelection * selection; |
| 494 | | 425 | |
| 495 | int i; | 426 | int i; |
| 497 | | 428 | |
| 498 | view = gtk_tree_view_new(); | 429 | view = gtk_tree_view_new(); |
| 499 | | 430 | |
| 500 | //sizereq.width = 600; | | |
| 501 | //sizereq.height = 400; | | |
| 502 | | | |
| 503 | //gtk_widget_size_request(view, &sizereq); | | |
| 504 | gtk_widget_set_size_request(view, 768, 512); | 431 | gtk_widget_set_size_request(view, 768, 512); |
| 505 | | 432 | |
| 506 | for (i = 0; i < 4; i++) | 433 | for (i = 0; i < 4; i++) |
| 533 | age_cell_data_func, NULL, NULL); | 460 | age_cell_data_func, NULL, NULL); |
| 534 | #endif | 461 | #endif |
| 535 | | 462 | |
| 536 | model = create_model(); | 463 | W.listmodel = CUSTOM_LIST(custom_list_new()); |
| 537 | | 464 | |
| 538 | FILE * fh = runhelper("list"); | 465 | FILE * fh = runhelper("list"); |
| 539 | if (fh == null) | 466 | if (fh == null) |
| 541 | fill_store(fh); | 468 | fill_store(fh); |
| 542 | pclose(fh); | 469 | pclose(fh); |
| 543 | | 470 | |
| 544 | gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); | 471 | gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(W.listmodel)); |
| 545 | | 472 | |
| | 473 | //* never deleted ! */ |
| 546 | g_object_unref(model); /* destroy model automatically with view */ | 474 | //g_object_unref(W.listmodel); /* destroy model automatically with view */ |
| 547 | | 475 | |
| 548 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); | 476 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
| 549 | gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); | 477 | gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); |
| 550 | | 478 | |
| 551 | gtk_tree_selection_set_select_function(selection, selected_row, null,null); | 479 | gtk_tree_selection_set_select_function(selection, selected_row, null,null); |
| 552 | | 480 | |
| 553 | return view; | 481 | return (W.listview = view); |
| 554 | } | 482 | } |
| 555 | | 483 | |
| 556 | /* ----------------------------------------------------------------------- | 484 | /* ----------------------------------------------------------------------- |
| 572 | { | 500 | { |
| 573 | GtkWidget * window; | 501 | GtkWidget * window; |
| 574 | | 502 | |
| 575 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 503 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 576 | gtk_window_set_title(GTK_WINDOW(window), title); | 504 | gtk_window_set_title(GTK_WINDOW(window), title); |
| 577 | | 505 | |
| 578 | g_signal_connect(G_OBJECT(window), "delete_event", | 506 | g_signal_connect(G_OBJECT(window), "delete_event", |
| 581 | g_signal_connect(G_OBJECT(window), "destroy", | 509 | g_signal_connect(G_OBJECT(window), "destroy", |
| 582 | G_CALLBACK(delete_cb), ...); | 510 | G_CALLBACK(delete_cb), ...); |
| 583 | #endif | 511 | #endif |
| 584 | gtk_container_set_border_width (GTK_CONTAINER (window), borderwidth); | 512 | gtk_container_set_border_width(GTK_CONTAINER (window), borderwidth); |
| 585 | | 513 | |
| 586 | gtk_container_add(GTK_CONTAINER(window), child); | 514 | gtk_container_add(GTK_CONTAINER(window), child); |
| 587 | gtk_window_set_resizable(GTK_WINDOW(window), resizable); | 515 | gtk_window_set_resizable(GTK_WINDOW(window), resizable); |
| 762 | | 690 | |
| 763 | void clean_data(void) | 691 | void clean_data(void) |
| 764 | { | 692 | { |
| 765 | clear_store(); | 693 | custom_list_clear(W.listmodel); |
| 766 | for (unsigned int i = 0; G.prgbuffers[i]; i++) { | | |
| 767 | free(G.prgbuffers[i]); G.prgbuffers[i] = null; } | | |
| 768 | for (unsigned int i = 0; i < sizeof G.prgfd / sizeof G.prgfd[0]; i++) | 694 | for (unsigned int i = 0; i < sizeof G.prgfd / sizeof G.prgfd[0]; i++) |
| 769 | if (G.prgfd[i] >= 0) { close(G.prgfd[i]); G.prgfd[i] = -1; } | 695 | if (G.prgfd[i] >= 0) { close(G.prgfd[i]); G.prgfd[i] = -1; } |
| 770 | G.previndx = -1; | 696 | G.indx = G.prevabsindx = -1; |
| 771 | G.compare[0] = '\0'; | 697 | G.compare[0] = '\0'; |
| 772 | G.channelfilter = 0; | 698 | G.channelfilter = 0; |
| 773 | G.maxchannelindex = 0; | 699 | G.maxchannelindex = 0; |
| 774 | G.dotextfiltering = false; // XXX see usage here and elsewhere | | |
| 775 | } | 700 | } |
| 776 | | 701 | |
| 777 | bool reset_signal(void * inprogress_p) | 702 | bool reset_signal(void * inprogress_p) |
| 785 | static int inprogress = false; | 710 | static int inprogress = false; |
| 786 | (void)uu; | 711 | (void)uu; |
| 787 | | 712 | |
| 788 | if (inprogress) | 713 | if (inprogress) // XXX what if reset_signal() never called ?? |
| 789 | return; | 714 | return; |
| 790 | | 715 | |
| | 716 | gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview), null); |
| 791 | FILE * fh = runhelper("update"); | 717 | FILE * fh = runhelper("update"); |
| 792 | clean_data(); | 718 | clean_data(); |
| 793 | if (fill_store(fh)) { | 719 | if (fill_store(fh)) { |
| 795 | g_idle_add(reset_signal, &inprogress); | 721 | g_idle_add(reset_signal, &inprogress); |
| 796 | } | 722 | } |
| 797 | pclose(fh); | 723 | pclose(fh); |
| | 724 | gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview), |
| | 725 | GTK_TREE_MODEL(W.listmodel)); |
| 798 | } | 726 | } |
| 799 | | 727 | |
| 800 | void handle_program(const char * tool) | 728 | void handle_program(const char * tool) |
| 808 | } | 736 | } |
| 809 | d0(("noppeus %s\n", speeds[speed])); | 737 | d0(("noppeus %s\n", speeds[speed])); |
| 810 | | 738 | |
| 811 | if (G.previndx < 0) { | 739 | if (G.indx < 0) { |
| 812 | ModalMessageDialog("TV-ohjelmaa ei valittu"); | 740 | ModalMessageDialog("TV-ohjelmaa ei valittu"); |
| 813 | return; | 741 | return; |
| 814 | } | 742 | } |
| 815 | | 743 | |
| 816 | int i = G.previndx / 1000; | 744 | pclose(runhelper("play %s %d %s", tool, |
| 817 | int j = G.previndx % 1000; | 745 | custom_list_get_id(W.listmodel, G.indx), |
| 818 | | 746 | speeds[speed])); |
| 819 | runhelper("play %s %d %s", tool, G.prgbuffers[i][j].id, speeds[speed]); | | |
| 820 | } | 747 | } |
| 821 | | 748 | |
| 822 | void play_pressed(void * uu) | 749 | void play_pressed(void * uu) |
| 848 | //return false; | 775 | //return false; |
| 849 | if (strcmp(txt, G.compare) != 0) | 776 | if (strcmp(txt, G.compare) != 0) |
| 850 | strcpy(G.compare, txt); | 777 | strcpy(G.compare, txt); |
| 851 | G.dotextfiltering = true; // XXX move elsewhere | 778 | |
| 852 | gtk_tree_model_filter_refilter(W.listfilter); | 779 | refilter_model(); |
| | 780 | |
| 853 | G.notidle = false; | 781 | G.notidle = false; |
| 854 | return false; | 782 | return false; |
| 855 | } | 783 | } |