tvkaista-0.981/custom-list.c tvkaista-0.982/custom-list.c
24#include <stdlib.h>24#include <stdlib.h>
2525
26#include "custom-list.h"26#include "custom-list.h"
27
28#define null ((void *)0)
29enum { false = 0, true = 1 };
3027
31/* boring declarations of local functions */28/* boring declarations of local functions */
3229
667 after all additions done, model is attached to view */664 after all additions done, model is attached to view */
668}665}
669666
670void custom_list_full(CustomList * list, int channelindex, char * compare)667/* always do filtering after this */
668void custom_list_full(CustomList * list)
671{669{
672 list->filtered_rows = malloc(list->all_rows_count670 list->filtered_rows = malloc(list->all_rows_count
673 * sizeof *list->filtered_rows);671 * sizeof *list->filtered_rows);
674 if (list->filtered_rows == null)672 if (list->filtered_rows == null)
675 exit(19);673 exit(19);
676 // if empty list, might add one dummy line (for information)674 // if empty list, might add one dummy line (for information)
677 custom_list_filter(list, channelindex, compare);675 //custom_list_filter(list, filterfunc, filterdata);
678}676}
679677
680void custom_list_clear(CustomList * list)678void custom_list_clear(CustomList * list)
719 return list->filtered_rows[indx]->id;717 return list->filtered_rows[indx]->id;
720}718}
721719
722void custom_list_filter(CustomList * list, int channelindex, char * compare)720void custom_list_filter(CustomList * list,
721 bool (*filterfunc)(CustomRecord * record, void * data),
722 void * filterdata)
723{723{
724 int fi = 0, clen = strlen(compare);724 int fi = 0;
725725
726 if (list->all_rows_count == 0) {726 if (list->all_rows_count == 0) {
727 list->filtered_rows_count = 0;727 list->filtered_rows_count = 0;
733 CustomRecord * record = &list->all_rows[i][j];733 CustomRecord * record = &list->all_rows[i][j];
734 if (record->day == null) { i = 1000; break; }734 if (record->day == null) { i = 1000; break; }
735 record->filtered_position = fi;735 record->filtered_position = fi;
736 if (channelindex && channelindex != record->channelindex)736 if (filterfunc(record, filterdata))
737 continue;
738 if (clen && strcasestr(record->program, compare) == null)
739 continue;
740 list->filtered_rows[fi++] = record;737 list->filtered_rows[fi++] = record;
741 }738 }
742 list->filtered_rows_count = fi;739 list->filtered_rows_count = fi;
743#if 0740#if 0

tvkaista-0.981/custom-list.h tvkaista-0.982/custom-list.h
33
4#include <stdint.h>4#include <stdint.h>
5#include <gtk/gtk.h>5#include <gtk/gtk.h>
6
7// XXX but lazy to do separate include file ...
8#define null ((void*)0)
9enum { false = 0, true = 1 } bool;
10#define bool int // hmm
11#define bool8 char
612
7/* Some boilerplate GObject defines. 'klass' is used13/* Some boilerplate GObject defines. 'klass' is used
8 * instead of 'class', because 'class' is a C++ keyword */14 * instead of 'class', because 'class' is a C++ keyword */
98 char * day, char * hourmin, char * channel,104 char * day, char * hourmin, char * channel,
99 char * shortinfo,105 char * shortinfo,
100 int id, int channelindex, int prgdayindex, int offset);106 int id, int channelindex, int prgdayindex, int offset);
101void custom_list_full(CustomList * list, int channelindex, char * compare);107void custom_list_full(CustomList * list);
102void custom_list_clear(CustomList * list);108void custom_list_clear(CustomList * list);
103CustomRecord * custom_list_get_record(CustomList * list, int indx);109CustomRecord * custom_list_get_record(CustomList * list, int indx);
104CustomRecord * custom_list_get_abs_record(CustomList * list, int indx);110CustomRecord * custom_list_get_abs_record(CustomList * list, int indx);
105int custom_list_get_id(CustomList * list, int indx);111int custom_list_get_id(CustomList * list, int indx);
106void custom_list_filter(CustomList * list, int channelindex, char * compare);112void custom_list_filter(CustomList * list,
113 bool (*filterfunc)(CustomRecord * record, void * data),
114 void * filterdata);
107115
108116
109117

tvkaista-0.981/gitlog tvkaista-0.982/gitlog
1commit 3f3155cbb06deef87a98851dbbe6206ca0c7561b
2Author: Tomi Ollila <too@iki.fi>
3Date: Tue Jul 21 19:50:47 2009 +0300
4
5 ok. yksi fiksi vielä jakeluversioon.
6
7M tvkaista_gtkui.c
8
9commit 75198d07a773779676477e9d917142d894127c95
10Author: Tomi Ollila <too@iki.fi>
11Date: Tue Jul 21 19:15:35 2009 +0300
12
13 kippaus korjattu (ylimääräinen refilter_model()). Version 0.982
14
15M tvkaista.desktop
16M tvkaista_gtkui.c
17
18commit 6682a2e2ed77578ba0823caccc3d544ac3e79c68
19Author: Tomi Ollila <too@iki.fi>
20Date: Tue Jul 21 19:12:10 2009 +0300
21
22 säädöt tehty, kippaa vielä kummallisesti. tutkitaan.
23
24M tvkaista_gtkui.c
25
26commit 058458405f8dcd2505ca43045a2d1d49881d4576
27Author: Tomi Ollila <too@iki.fi>
28Date: Tue Jul 21 18:45:34 2009 +0300
29
30 suosikkilistat toimivat! säätöä vielä...
31
32M custom-list.c
33M custom-list.h
34M tvkaista_gtkui.c
35
36commit 83274f7972a7bc3bc7f5a17a56f224c2a3dadb71
37Author: Tomi Ollila <too@iki.fi>
38Date: Tue Jul 21 12:24:02 2009 +0300
39
40 ohjelmasuodatuksessa käytetään nyt "callback"-funktiota...
41
42M custom-list.c
43M custom-list.h
44M tvkaista_gtkui.c
45
46commit 8275c3a33255c0fb15f76d5e15d09e5925d6edf3
47Author: Tomi Ollila <too@iki.fi>
48Date: Tue Jul 21 00:02:29 2009 +0300
49
50 suosikkilistat tulossa, väliaikatallennus
51
52M tvkaista_gtkui.c
53
1commit 918f9e96dbb117ee24d6fe347ff290b6b14a825954commit 918f9e96dbb117ee24d6fe347ff290b6b14a8259
2Author: Tomi Ollila <too@iki.fi>55Author: Tomi Ollila <too@iki.fi>
3Date: Tue Jul 14 21:20:38 2009 +030056Date: Tue Jul 14 21:20:38 2009 +0300

tvkaista-0.981/tvkaista.desktop tvkaista-0.982/tvkaista.desktop
1[Desktop Entry]1[Desktop Entry]
2Encoding=UTF-82Encoding=UTF-8
3Version=0.9813Version=0.982
4Name=tv kaista4Name=tv kaista
5Comment=gui-kilentti tvkaistalle5Comment=gui-kilentti tvkaistalle
6GenericName=tvkaista-kilentti6GenericName=tvkaista-kilentti

tvkaista-0.981/tvkaista_gtkui.c tvkaista-0.982/tvkaista_gtkui.c
5555
56#include "custom-list.h"56#include "custom-list.h"
5757
58#define null ((void*)0)
59
60enum { false = 0, true = 1 } bool;
61#define bool int // hmm
62#define bool8 char
63
64#if (__GNUC__ >= 4)58#if (__GNUC__ >= 4)
65#define GCCATTR_SENTINEL __attribute__ ((sentinel))59#define GCCATTR_SENTINEL __attribute__ ((sentinel))
66#else60#else
125 int refindx;119 int refindx;
126 char daytime[8];120 char daytime[8];
127 bool (*childexit_cb)(void);121 bool (*childexit_cb)(void);
122 /* favorites window */
123 bool8 fav_open;
124 int8_t fav_window;
125 char * fav_text;
128} G;126} G;
129127
130/* widgets in separate structure, for code readability */128/* widgets in separate structure, for code readability */
133 GtkWidget * w; /* main toplevel window */131 GtkWidget * w; /* main toplevel window */
134 GtkWidget * scb; /* speed combo box */132 GtkWidget * scb; /* speed combo box */
135 GtkWidget * pcb; /* player combo box */133 GtkWidget * pcb; /* player combo box */
134 GtkWidget * fcb; /* favorites combo box */
135 GtkWidget * ste; /* search text entry */
136 GtkTextBuffer * txtbuffer; /* detailed program text */136 GtkTextBuffer * txtbuffer; /* detailed program text */
137 GtkWidget * listview;137 GtkWidget * listview;
138 CustomList * listmodel;138 CustomList * listmodel;
139 // favorites widgets
140 GtkWindow * fw;
141 GtkTextBuffer * ftxtbuf;
139} W;142} W;
140143
141// XXX make better later...144// XXX make better later...
288 g_idle_add(idle_set_refindx, null);291 g_idle_add(idle_set_refindx, null);
289}292}
290293
294static bool filter_nofilter(CustomRecord * record, void * data)
295{
296 (void)record; (void)data;
297 return true;
298}
299
300static bool filter_by_search(CustomRecord * record, void * data)
301{
302 (void)data;
303 if (G.channelfilter && G.channelfilter != record->channelindex)
304 return false;
305 // XXX deliver G.compare as data, null if empty -- later.
306 if (strcasestr(record->program, G.compare) == null)
307 return false;
308 return true;
309}
310
311typedef struct {
312 const char * str;
313 int len;
314} LStr;
315
316static bool filter_by_favorites(CustomRecord * record, void * data)
317{
318 LStr * lines = (LStr *)data;
319 if (G.channelfilter && G.channelfilter != record->channelindex)
320 return false;
321 int plen = strlen(record->program);
322 int i;
323 for (i = 0; lines[i].str; i++)
324 {
325 // memmem is GNU extension, although easy to implement on need.
326 if (memmem(record->program, plen, lines[i].str, lines[i].len))
327 return true;
328 }
329 return false;
330}
331
332
333void do_filtering(void)
334{
335 if (G.fav_window == 0) {
336 custom_list_filter(W.listmodel, filter_by_search, null);
337 return;
338 }
339 if (G.fav_text == null) {
340 custom_list_filter(W.listmodel, filter_nofilter, null);
341 return;
342 }
343
344 LStr lines[128];
345 int i = 0;
346 char * p = G.fav_text;
347
348 while (1) {
349 char * q = p;
350 // ignore whitespace-only lines
351 while (isspace(*q)) {
352 if (*q == '\n')
353 p = q + 1;
354 q++;
355 }
356 // last line only whitespace
357 if (*q == '\0')
358 break;
359 while (*q != '\n' && *q != '\0')
360 q++;
361 if (q == '\0') {
362 if (p != q) {
363 lines[i].str = p;
364 lines[i].len = q - p;
365 i++;
366 }
367 break;
368 }
369 if (p == q) {
370 p++;
371 continue;
372 }
373 lines[i].str = p;
374 lines[i].len = q - p;
375 i++;
376 if (i == (sizeof lines / sizeof lines[0]) - 1)
377 break;
378 p = q + 1;
379 }
380 lines[i].str = null;
381
382 if (i)
383 custom_list_filter(W.listmodel, filter_by_favorites, &lines);
384 else
385 custom_list_filter(W.listmodel, filter_nofilter, null);
386}
387
291void refilter_model(void)388void refilter_model(void)
292{389{
293 int f, l;390 int f, l;
304 struct timeval st, et;401 struct timeval st, et;
305 gettimeofday(&st, null);402 gettimeofday(&st, null);
306#endif403#endif
307 custom_list_filter(W.listmodel, G.channelfilter, G.compare);404 do_filtering();
308#if DBG0405#if DBG0
309 gettimeofday(&et, null);406 gettimeofday(&et, null);
310 printf("filter time: %.3f\n", (float)(et.tv_sec - st.tv_sec) * 1000407 printf("filter time: %.3f\n", (float)(et.tv_sec - st.tv_sec) * 1000
469 case 'X':566 case 'X':
470 break;567 break;
471 case 'Q':568 case 'Q':
472 custom_list_full(W.listmodel, G.channelfilter, G.compare);569 custom_list_full(W.listmodel);
570 do_filtering();
473 return true;571 return true;
474 default:572 default:
475 fprintf(stderr, "Unknown line: '%s'\n", line);573 fprintf(stderr, "Unknown line: '%s'\n", line);
488 id = -1;586 id = -1;
489 offset = 0;587 offset = 0;
490 }588 }
491 custom_list_full(W.listmodel, G.channelfilter, G.compare);589 custom_list_full(W.listmodel);
590 do_filtering();
492 return false;591 return false;
493}592}
494593
583 else682 else
584 G.channelfilter = 0;683 G.channelfilter = 0;
585 refilter_model();684 refilter_model();
586 G.notidle = false;
587}685}
588686
589// ISO C forbids passing argument 4 of 'g_signal_connect_data'687// ISO C forbids passing argument 4 of 'g_signal_connect_data'
845 return w;943 return w;
846}944}
847945
848GtkWidget * aTextView(GtkTextBuffer * child)946GtkWidget * aTextView(GtkTextBuffer * child, bool editable)
849{947{
850 GtkWidget * textview948 GtkWidget * textview
851 = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(child));949 = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(child));
854 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textview), 3);952 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textview), 3);
855 gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(textview), 2);953 gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(textview), 2);
856 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(textview), 2);954 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(textview), 2);
857 gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), false);955 gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), editable);
858 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_CHAR);956 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
859 /* gtk_widget_set_size_request(textview, 500, 250); */957 /* gtk_widget_set_size_request(textview, 500, 250); */
860958
861 return textview;959 return textview;
887985
888const char * speeds[] = { "300k", "1M", "2M", "8M" };986const char * speeds[] = { "300k", "1M", "2M", "8M" };
889const char nspeeds = sizeof speeds / sizeof speeds[0];987const char nspeeds = sizeof speeds / sizeof speeds[0];
988
989const char * favorites[] = { "haku", "oma1", "oma2", "oma3", "oma4" };
990const char nfavorites = sizeof favorites / sizeof favorites[0];
991
890992
891/* XXX combine with init_G */993/* XXX combine with init_G */
892void clean_data(void)994void clean_data(void)
10041106
1005bool entry_key_pressed(GtkEntry * e)1107bool entry_key_pressed(GtkEntry * e)
1006{1108{
1007 if (! G.notidle) {1109 if (! G.notidle && G.fav_window == 0) {
1008 G.notidle = true;1110 G.notidle = true;
1009 g_idle_add(entry_changed, e);1111 g_idle_add(entry_changed, e);
1010 }1112 }
1011 return false;1113 return false;
1012}1114}
10131115
1116char * xmalloc(int len)
1117{
1118 char * buf = (char *)malloc(len);
1119 if (buf == null)
1120 die("Out of Memory!");
1121 return buf;
1122}
1123
1124/* ********************** text read/write ******************* */
1125
1126char * read_textfile(const char * filename)
1127{
1128 int fd = open(filename, O_RDONLY);
1129 if (fd < 0) {
1130 char * txtbuf = xmalloc(1);
1131 txtbuf[0] = 0;
1132 return txtbuf;
1133 }
1134 struct stat st;
1135 if (fstat(fd, &st) < 0)
1136 die("fstat() failed:");
1137 if (st.st_size > 1024)
1138 st.st_size = 1024; // XXX
1139 char * textbuf = xmalloc(st.st_size + 1);
1140 if (read(fd, textbuf, st.st_size) != st.st_size)
1141 die("read could not read full buf:"); // XXX but should be safe
1142 textbuf[st.st_size] = '\0';
1143 close(fd);
1144 return textbuf;
1145}
1146
1147void write_textfile(const char * filename, const char * text)
1148{
1149 int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
1150 int l = strlen(text) - 1;
1151 while (l >= 0 && isspace(text[l]))
1152 l--;
1153 if (l < 0) {
1154 unlink(filename);
1155 return;
1156 }
1157 l++;
1158 if (fd < 0)
1159 die("open() failed:");
1160 if (write(fd, text, l) != l)
1161 die("write() failed:");
1162 close(fd);
1163}
1164
1165char * textbuffer_get_text(GtkTextBuffer * tb)
1166{
1167 GtkTextIter start, end;
1168
1169 gtk_text_buffer_get_start_iter(tb, &start);
1170 gtk_text_buffer_get_end_iter(tb, &end);
1171
1172 return gtk_text_buffer_get_text(tb, &start, &end, false);
1173}
1174
1175/* ********************** favorites window code ******************* */
1176
1177char * favorites_filename(int i)
1178{
1179 static char filename[20];
1180 sprintf(filename, "suosikit.%d", i);
1181 return filename;
1182}
1183
1184void save_fav_content(void)
1185{
1186 if (G.fav_window == 0)
1187 return;
1188
1189 char * fw_text = textbuffer_get_text(W.ftxtbuf);
1190
1191 if (fw_text == null) {
1192 write_textfile(favorites_filename(G.fav_window), "");
1193 return;
1194 }
1195 if (G.fav_text == null || strcmp(fw_text, G.fav_text) != 0) {
1196 write_textfile(favorites_filename(G.fav_window), fw_text);
1197 free(G.fav_text);
1198 G.fav_text = fw_text;
1199 }
1200 else
1201 free(fw_text);
1202}
1203
1204
1205bool do_hide_fav_window(void)
1206{
1207 save_fav_content();
1208 gtk_widget_hide(GTK_WIDGET(W.fw));
1209 G.fav_open = false;
1210}
1211
1212// event_... or ..._cb or... and rename above ?
1213bool hide_fav_window(void * w, void * e, void * d)
1214{
1215 (void)w; (void)e; (void)d;
1216 do_hide_fav_window();
1217 refilter_model();
1218 return true;
1219}
1220
1221
1222bool shown_set_winpos(void)
1223{
1224 gint tx, ty;
1225 gdk_window_get_position(W.w->window, &tx, &ty);
1226 //gint ex, ey;
1227 //gdk_window_get_position(W.ste->window, &ex, &ey);
1228
1229 gint fx, fy, fh, fw;
1230 fx = W.fcb->allocation.x;
1231 fy = W.fcb->allocation.y;
1232 fw = W.fcb->allocation.width;
1233 fh = W.fcb->allocation.height;
1234
1235 //printf("%d %d - %d %d - %d %d %d %d\n", tx, ty, ex, ey, fx, fy, fw, fh);
1236
1237 //gtk_window_set_position(GTK_WINDOW(W.fw), GTK_WIN_POS_MOUSE);
1238 //gdk_window_move(GTK_WIDGET(W.fw)->window, tx + fx, ty + fy + fh + 5);
1239 gtk_window_move(W.fw, tx + fx, ty + fy + fh + 5);
1240 return false;
1241}
1242
1243void show_fav_window(int indx, bool do_show)
1244{
1245 char * text = read_textfile(favorites_filename(indx));
1246 gtk_text_buffer_set_text(W.ftxtbuf, text, -1);
1247 free(G.fav_text);
1248 G.fav_text = text;
1249
1250 // always open favorites window if content empty
1251 if ( (text[0] == '\0' || do_show) && ! G.fav_open) {
1252 gtk_widget_show_all(GTK_WIDGET(W.fw));
1253 //shown_set_winpos();
1254 G.fav_open = true;
1255 }
1256}
1257
1258#if 0
1259void favorites_changed(GtkComboBox * cb)
1260{
1261 write(1, "goo\n", 4);
1262}
1263#endif
1264
1265/*
1266 "popdown" differs from "changed" so that same selection if notified too.
1267 */
1268bool favorites_popdown(GtkComboBox * cb /*, GdkEvent * e*/)
1269{
1270 static bool prev_shown = false;
1271 bool popup_shown;
1272
1273 g_object_get(G_OBJECT(cb), "popup-shown", &popup_shown, null);
1274 //printf("popdown: event type %d, popup_shown %d\n", e->type, popup_shown);
1275
1276 if (popup_shown == false && prev_shown) {
1277 gint indx = gtk_combo_box_get_active(GTK_COMBO_BOX(cb));
1278 //printf("index: %d\n", indx);
1279 if (indx == 0) {
1280 // back to search...
1281 if (G.fav_window != 0) {
1282 do_hide_fav_window();
1283 gtk_entry_set_visibility(GTK_ENTRY(W.ste), true);
1284 }
1285 }
1286 else {
1287 if (G.fav_window == 0) {
1288 gtk_entry_set_visibility(GTK_ENTRY(W.ste), false);
1289 }
1290 else
1291 save_fav_content();
1292 show_fav_window(indx, indx == G.fav_window);
1293 }
1294 G.fav_window = indx;
1295 refilter_model();
1296 }
1297 prev_shown = popup_shown;
1298 return false;
1299}
1300
1301bool main_quit(void * w, void * e, void * d)
1302{
1303 (void)w; (void)e; (void)d;
1304 do_hide_fav_window();
1305 gtk_main_quit();
1306 return true;
1307}
1308
1014#define __S(x) __STRING(x)1309#define __S(x) __STRING(x)
10151310
1016void gui(void)1311void gui(void)
1017{1312{
1018 GtkWidget * e;1313 W.fw = aWindow("Suosikit",
1314 hide_fav_window, null, 2, true, false,
1315 aTextView(W.ftxtbuf = aTextBuffer(), true));
1316
1317 gtk_window_set_default_size(GTK_WINDOW(W.fw), 100, 20);
1318 //gtk_window_set_position(GTK_WINDOW(W.fw), GTK_WIN_POS_MOUSE);
1319 //gtk_widget_show_all(W.fw);
1320 g_signal_connect(G_OBJECT(W.fw), "show", shown_set_winpos, null);
1321 //gtk_widget_realize(GTK_WIDGET(W.fw));
10191322
1020 W.w = aWindow("tv kaista " __S(VERSION),1323 W.w = aWindow("tv kaista " __S(VERSION),
1021 (gboolean(*)(void *,void *,void *))gtk_main_quit, null,
1022 2, true, true,1324 main_quit, null, 2, true, true,
1023 aVBox(/* <- homogeneous spacing */ false, 2,1325 aVBox(/* <- homogeneous spacing */ false, 2,
1024 aHBox(/* <- homogeneous spacing */ false, 2,1326 aHBox(/* <- homogeneous spacing */ false, 2,
1025 aButton("päivitä", update_pressed, null),1327 aButton("päivitä", update_pressed, null),
1032 /* ^^ expand fill padding */ false, true, 2,1334 /* ^^ expand fill padding */ false, true, 2,
1033 W.pcb = aTextComboBox(players, nplayers, 2),1335 W.pcb = aTextComboBox(players, nplayers, 2),
1034 /* ^^ expand fill padding */ false, true, 2,1336 /* ^^ expand fill padding */ false, true, 2,
1035 aLabel("haku"),1337 //aLabel("haku"),
1338 W.fcb = aTextComboBox(favorites, nfavorites, 0),
1036 /* ^^ expand fill padding */ false, true, 2,1339 /* ^^ expand fill padding */ false, true, 2,
1037 e = anEntry("", 10, MAXSEARCHLEN),1340 W.ste = anEntry("", 10, MAXSEARCHLEN),
1038 /* ^^ expand fill padding */ true, true, 2,1341 /* ^^ expand fill padding */ true, true, 2,
1039 null),1342 null),
1040 /* ^^ expand fill padding */ false, true, 2,1343 /* ^^ expand fill padding */ false, true, 2,
1041 aScrolledWindow(create_view_and_model()),1344 aScrolledWindow(create_view_and_model()),
1042 /* ^^ expand fill padding */ true, true, 2,1345 /* ^^ expand fill padding */ true, true, 2,
1043 aTextView(W.txtbuffer = aTextBuffer()),1346 aTextView(W.txtbuffer = aTextBuffer(), false),
1044 /* ^^ expand fill padding */ true, true, 2,1347 /* ^^ expand fill padding */ true, true, 2,
1045 null));1348 null));
10461349
1047 gtk_signal_connect(GTK_OBJECT(e), "key-press-event",1350 g_signal_connect(G_OBJECT(W.ste), "key-press-event",
1048 GTK_SIGNAL_FUNC(entry_key_pressed), null);1351 G_CALLBACK(entry_key_pressed), null);
1352
1353#if 0 // "changed" does not cover choosing the same...
1354 g_signal_connect(G_OBJECT(W.fcb), "changed",
1355 G_CALLBACK(favorites_changed), null);
1356#endif
1357
1358 /* no help, no window probably... use event-after then */
1359 //gtk_widget_add_events(W.fcb, GDK_KEY_RELEASE_MASK);
1360 //gtk_widget_add_events(W.fcb, GDK_ALL_EVENTS_MASK);
1361
1362 //gtk_signal_connect(GTK_OBJECT(W.fcb), "notify::popup-shown",
1363 g_signal_connect(G_OBJECT(W.fcb), "event-after",
1364 G_CALLBACK(favorites_popdown), null);
10491365
1050 //g_signal_connect(e, "insert-at-cursor", entry_changed, null);1366 //g_signal_connect(e, "insert-at-cursor", entry_changed, null);
10511367
1052 gtk_window_set_icon_from_file(GTK_WINDOW(W.w), "tvkaista.png", null);1368 gtk_window_set_icon_from_file(GTK_WINDOW(W.w), "tvkaista.png", null);
1053
1054#if 0
1055 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1056
1057 gtk_window_set_default_size(GTK_WINDOW(window), 600, 400);
1058 g_signal_connect(window, "delete_event", gtk_main_quit, NULL); /* dirty */
1059
1060 view = create_view_and_model();
1061
1062 sw = gtk_scrolled_window_new(null, null);
1063
1064 /* gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), view); */
1065 gtk_container_add(GTK_CONTAINER(sw), view);
1066
1067 gtk_container_add(GTK_CONTAINER(window), sw);
1068#endif
1069// gtk_widget_show_all(W.w);
1070}1369}
10711370
1072const char intro[] = "\n"1371const char intro[] = "\n"
1083 "<kanava> -\"painike\" palauttaa kaikki kanavat näkyviin keskialueen\n"1382 "<kanava> -\"painike\" palauttaa kaikki kanavat näkyviin keskialueen\n"
1084 "napsautuksella.\n"1383 "napsautuksella.\n"
1085 "\n"1384 "\n"
1385 "Hauissa on mahdollista tallentaa suosikkilistoja. Suosikkilistaikkuna\n"
1386 "aukeaa mikäli se on tyhjä tai sama suosikkilista valitaan valikosta.\n"
1387 "\n"
1086 "Tallenteiden sijaintipaikka on $HOME/.tvkaista/tallenteet/.\n"1388 "Tallenteiden sijaintipaikka on $HOME/.tvkaista/tallenteet/.\n"
1087 "\n";1389 "\n";
10881390