libglade helpers.
[mediadatabase.git] / gtk / search.c
blob854b15642515e50f89e2d4d4dbed15de07f940e9
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * $Id: search.c,v 1.5 2005/02/18 02:12:08 nedko Exp $
6 * DESCRIPTION:
7 *
9 * NOTES:
12 *****************************************************************************/
14 #include <limits.h>
15 #include <stdlib.h>
16 #include <time.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include <gtk/gtk.h>
21 /* ULLONG_MAX should come from limits.h but doesn't */
22 #if !defined(ULLONG_MAX) && defined(ULONG_LONG_MAX)
23 # define ULLONG_MAX ULONG_LONG_MAX
24 #endif
26 #include "../result.h"
27 #include "../libdb/libdb.h"
28 #include "../libfrontend/db.h"
29 #include "common.h"
30 #include "search.h"
31 #include "helper.h"
32 #include "path.h"
34 enum
36 COL_ICON,
37 COL_NAME,
38 COL_SIZE,
39 COL_TIME,
40 COL_MEDIAID,
41 COL_MEDIAICON,
42 COL_MEDIANAME,
43 COL_MEDIALOCATION,
44 NUM_COLS
47 #define KEY_PREFIX "mediadatabase_file_search_"
48 #define KEY_FILENAME KEY_PREFIX "filename"
49 #define KEY_FILENAME_PMM KEY_PREFIX "filename_pmm"
50 #define KEY_PATH KEY_PREFIX "path"
51 #define KEY_PATH_PMM KEY_PREFIX "path_pmm"
52 #define KEY_MIN_SIZE KEY_PREFIX "min_size"
53 #define KEY_MIN_SIZE_UNITS KEY_PREFIX "min_size_units"
54 #define KEY_MAX_SIZE KEY_PREFIX "max_size"
55 #define KEY_MAX_SIZE_UNITS KEY_PREFIX "max_size_units"
56 #define KEY_PMM KEY_PREFIX "pmm"
57 #define KEY_STORE KEY_PREFIX "store"
59 void
60 SearchCallback(
61 void *pUserContext,
62 mediadb_uint nMediaID,
63 mediadb_mediatype nMediaType,
64 const char *pszMediaName,
65 const char *pszMediaLocation,
66 const char *pszPath,
67 const char *pszName,
68 mediadb_filetype Filetype,
69 mediadb_uint nSize,
70 mediadb_uint nTime)
72 struct tm tm;
73 GdkPixbuf * pIcon;
74 GdkPixbuf * pMediaIcon;
75 time_t time = nTime;
76 GtkTreeIter Iter;
77 char strTime[26];
78 GError * error = NULL;
79 char * pszIcon;
80 char strSize[MAX_SIZE_DESCRIPTION];
81 char *pszFullPath;
82 gchar * pszIconFullname;
84 pszFullPath = g_malloc(strlen(pszPath)+strlen(pszName)+1);
85 sprintf(pszFullPath, "%s%s", pszPath, pszName);
87 localtime_r(&time, &tm);
88 sprintf(strTime,
89 "%u-%02u-%02u %02u:%02u:%02u",
90 1900+tm.tm_year,
91 1+tm.tm_mon,
92 tm.tm_mday,
93 tm.tm_hour,
94 tm.tm_min,
95 tm.tm_sec);
97 get_size_description(nSize, strSize);
99 pIcon = NULL;
101 if (Filetype == MEDIADB_FILETYPE_DIR)
103 pszIcon = "icon_folder.png";
105 else
107 pszIcon = "icon_unknown.png";
110 pszIconFullname = path_get_data_filename(pszIcon);
111 if (pszIconFullname != NULL)
113 pIcon = gdk_pixbuf_new_from_file(pszIconFullname, &error);
114 if (error)
116 g_warning("Could not load icon: %s\n", error->message);
117 g_error_free(error);
118 error = NULL;
121 g_free(pszIconFullname);
123 else
125 g_warning("Could not find icon %s\n", pszIcon);
128 pszIcon = "icon_cd.png";
130 pszIconFullname = path_get_data_filename(pszIcon);
131 if (pszIconFullname != NULL)
133 pMediaIcon = gdk_pixbuf_new_from_file(pszIconFullname, &error);
134 if (error)
136 g_warning("Could not load icon: %s\n", error->message);
137 g_error_free(error);
138 error = NULL;
141 g_free(pszIconFullname);
143 else
145 g_warning("Could not find icon %s\n", pszIcon);
148 gtk_list_store_append(
149 GTK_LIST_STORE(
150 g_object_get_data(
151 G_OBJECT(pUserContext),
152 KEY_STORE)),
153 &Iter);
155 gtk_list_store_set(
156 GTK_LIST_STORE(
157 g_object_get_data(
158 G_OBJECT(pUserContext),
159 KEY_STORE)),
160 &Iter,
161 COL_ICON, pIcon,
162 COL_NAME, pszFullPath,
163 COL_SIZE, (Filetype == MEDIADB_FILETYPE_DIR)?NULL:strSize,
164 COL_TIME, strTime,
165 COL_MEDIAID, (unsigned int)nMediaID,
166 COL_MEDIAICON, pMediaIcon,
167 COL_MEDIANAME, pszMediaName,
168 COL_MEDIALOCATION, pszMediaLocation,
169 -1);
171 g_free(pszFullPath);
174 void
175 DoSearch(
176 GtkEntry *pEntry,
177 gpointer pUserData)
179 GtkWidget *pDialog;
180 const char *pszFilename;
181 gint nFilenamePMMIndex;
182 const char *pszPath;
183 gint nPathPMMIndex;
184 const char *pszMinSize;
185 gint nMinSizeUnits;
186 const char *pszMaxSize;
187 gint nMaxSizeUnits;
188 const struct mediadb_pattern_match_method *pPMM;
189 mediadb_uint nMinSize;
190 mediadb_uint nMaxSize;
191 char *pchEnd;
192 mediadb_result r;
194 pPMM = (const struct mediadb_pattern_match_method *)g_object_get_data(
195 G_OBJECT(pUserData),
196 KEY_PMM);
198 pszFilename = gtk_entry_get_text(
199 GTK_ENTRY(
200 g_object_get_data(
201 G_OBJECT(pUserData),
202 KEY_FILENAME)));
204 nFilenamePMMIndex = gtk_combo_box_get_active(
205 GTK_COMBO_BOX(
206 g_object_get_data(
207 G_OBJECT(pUserData),
208 KEY_FILENAME_PMM)));
210 pszPath = gtk_entry_get_text(
211 GTK_ENTRY(
212 g_object_get_data(
213 G_OBJECT(pUserData),
214 KEY_PATH)));
216 nPathPMMIndex = gtk_combo_box_get_active(
217 GTK_COMBO_BOX(
218 g_object_get_data(
219 G_OBJECT(pUserData),
220 KEY_PATH_PMM)));
222 pszMinSize = gtk_entry_get_text(
223 GTK_ENTRY(
224 g_object_get_data(
225 G_OBJECT(pUserData),
226 KEY_MIN_SIZE)));
228 nMinSizeUnits = gtk_combo_box_get_active(
229 GTK_COMBO_BOX(
230 g_object_get_data(
231 G_OBJECT(pUserData),
232 KEY_MIN_SIZE_UNITS)));
234 pszMaxSize = gtk_entry_get_text(
235 GTK_ENTRY(
236 g_object_get_data(
237 G_OBJECT(pUserData),
238 KEY_MAX_SIZE)));
240 nMaxSizeUnits = gtk_combo_box_get_active(
241 GTK_COMBO_BOX(
242 g_object_get_data(
243 G_OBJECT(pUserData),
244 KEY_MAX_SIZE_UNITS)));
246 /* We better handle such thing in backend
247 if (*pszFilename == 0 &&
248 *pszPath == 0 &&
249 *pszMinSize == 0 &&
250 *pszMaxSize == 0)
252 pDialog = gtk_message_dialog_new(
253 GTK_WINDOW(pUserData),
254 GTK_DIALOG_DESTROY_WITH_PARENT,
255 GTK_MESSAGE_ERROR,
256 GTK_BUTTONS_CLOSE,
257 "No search criteria ...\n");
259 gtk_dialog_run(GTK_DIALOG(pDialog));
260 gtk_widget_destroy(pDialog);
262 return;
266 if (*pszMinSize &&
267 *pszMaxSize &&
268 nMinSizeUnits > nMaxSizeUnits)
270 pDialog = gtk_message_dialog_new(
271 GTK_WINDOW(pUserData),
272 GTK_DIALOG_DESTROY_WITH_PARENT,
273 GTK_MESSAGE_ERROR,
274 GTK_BUTTONS_CLOSE,
275 "Min size units (%s) are bigger than max size units (%s).",
276 g_arrSizeUnits[nMinSizeUnits].pszUnitsName,
277 g_arrSizeUnits[nMaxSizeUnits].pszUnitsName);
279 gtk_dialog_run(GTK_DIALOG(pDialog));
280 gtk_widget_destroy(pDialog);
282 return;
285 if (*pszMinSize)
287 nMinSize = strtoull(pszMinSize, &pchEnd, 10);
288 if (nMinSize == 0 || nMinSize == ULLONG_MAX || *pchEnd)
290 pDialog = gtk_message_dialog_new(
291 GTK_WINDOW(pUserData),
292 GTK_DIALOG_DESTROY_WITH_PARENT,
293 GTK_MESSAGE_ERROR,
294 GTK_BUTTONS_CLOSE,
295 "Cannot convert \"%s\" to decimal integer number.",
296 pszMinSize);
298 gtk_dialog_run(GTK_DIALOG(pDialog));
299 gtk_widget_destroy(pDialog);
301 return;
304 if (ULLONG_MAX / g_arrSizeUnits[nMinSizeUnits].nUnitSize < nMinSize)
306 pDialog = gtk_message_dialog_new(
307 GTK_WINDOW(pUserData),
308 GTK_DIALOG_DESTROY_WITH_PARENT,
309 GTK_MESSAGE_ERROR,
310 GTK_BUTTONS_CLOSE,
311 "%llu %s is too large number.",
312 nMinSize,
313 g_arrSizeUnits[nMinSizeUnits].pszUnitsName);
315 gtk_dialog_run(GTK_DIALOG(pDialog));
316 gtk_widget_destroy(pDialog);
318 return;
321 nMinSize = nMinSize * g_arrSizeUnits[nMinSizeUnits].nUnitSize;
324 if (*pszMaxSize)
326 nMaxSize = strtoull(pszMaxSize, &pchEnd, 10);
327 if (nMaxSize == 0 || nMaxSize == ULLONG_MAX || *pchEnd)
329 pDialog = gtk_message_dialog_new(
330 GTK_WINDOW(pUserData),
331 GTK_DIALOG_DESTROY_WITH_PARENT,
332 GTK_MESSAGE_ERROR,
333 GTK_BUTTONS_CLOSE,
334 "Cannot convert \"%s\" to decimal integer number.",
335 pszMaxSize);
337 gtk_dialog_run(GTK_DIALOG(pDialog));
338 gtk_widget_destroy(pDialog);
340 return;
343 if (ULLONG_MAX / g_arrSizeUnits[nMaxSizeUnits].nUnitSize < nMaxSize)
345 pDialog = gtk_message_dialog_new(
346 GTK_WINDOW(pUserData),
347 GTK_DIALOG_DESTROY_WITH_PARENT,
348 GTK_MESSAGE_ERROR,
349 GTK_BUTTONS_CLOSE,
350 "%llu %s is too large number.",
351 nMaxSize,
352 g_arrSizeUnits[nMaxSizeUnits].pszUnitsName);
354 gtk_dialog_run(GTK_DIALOG(pDialog));
355 gtk_widget_destroy(pDialog);
357 return;
360 nMaxSize = nMaxSize * g_arrSizeUnits[nMaxSizeUnits].nUnitSize;
363 pDialog = gtk_message_dialog_new(
364 GTK_WINDOW(pUserData),
365 GTK_DIALOG_DESTROY_WITH_PARENT,
366 GTK_MESSAGE_INFO,
367 GTK_BUTTONS_CLOSE,
368 "Searching ...\n"
369 "%s%s%s%s%s"
370 "%s%s%s%s%s"
371 "%s%s%s%s%s"
372 "%s%s%s%s%s",
373 *pszFilename?"Filename \"":"",
374 *pszFilename?pszFilename:"",
375 *pszFilename?"\" - ":"",
376 *pszFilename?pPMM[nFilenamePMMIndex].pszDescription:"",
377 *pszFilename?"\n":"",
378 *pszPath?"Path \"":"",
379 *pszPath?pszPath:"",
380 *pszPath?"\" - ":"",
381 *pszPath?pPMM[nPathPMMIndex].pszDescription:"",
382 *pszPath?"\n":"",
383 *pszMinSize?"Min size ":"",
384 *pszMinSize?pszMinSize:"",
385 *pszMinSize?" ":"",
386 *pszMinSize?g_arrSizeUnits[nMinSizeUnits].pszUnitsName:"",
387 *pszMinSize?"\n":"",
388 *pszMaxSize?"Max size ":"",
389 *pszMaxSize?pszMaxSize:"",
390 *pszMaxSize?" ":"",
391 *pszMaxSize?g_arrSizeUnits[nMaxSizeUnits].pszUnitsName:"",
392 *pszMaxSize?"\n":"");
394 gtk_dialog_run(GTK_DIALOG(pDialog));
395 gtk_widget_destroy(pDialog);
397 gtk_list_store_clear(
398 GTK_LIST_STORE(
399 g_object_get_data(
400 G_OBJECT(pUserData),
401 KEY_STORE)));
403 r = mediadb_files_search(
404 g_hDB,
405 *pszFilename?pPMM[nFilenamePMMIndex].nID:MEDIADB_PMM_NULL,
406 *pszFilename?pszFilename:NULL,
407 *pszPath?pPMM[nPathPMMIndex].nID:MEDIADB_PMM_NULL,
408 *pszPath?pszPath:NULL,
409 *pszMinSize?&nMinSize:NULL,
410 *pszMaxSize?&nMaxSize:NULL,
411 SearchCallback,
412 pUserData);
413 if (MEDIADB_IS_ERROR(r))
415 display_error_message_mediadb(GTK_WINDOW(pUserData));
416 return;
420 void
421 ShowSearchWindow()
423 GtkWidget *pSearchWindow;
424 GtkWidget *pFrame;
425 GtkWidget *pTableMain;
426 GtkWidget *pTableSearchParameters;
427 GtkWidget *pScrolledWindow;
428 GtkWidget *pChild;
429 GtkCellRenderer * pRendererText;
430 GtkCellRenderer * pRendererPixbuf;
431 GtkTreeViewColumn * pColumn;
432 GtkListStore *pListStore;
433 const struct mediadb_pattern_match_method *pPMM;
434 mediadb_result r;
435 unsigned int i, j;
437 r = mediadb_get_pattern_match_methods(
438 g_hDB,
439 &pPMM);
440 if (MEDIADB_IS_ERROR(r))
442 display_error_message_mediadb(GTK_WINDOW(pMainWindow));
443 return;
446 pSearchWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
448 g_object_set_data(G_OBJECT(pSearchWindow), KEY_PMM, (gpointer)pPMM);
450 gtk_window_set_role(GTK_WINDOW(pSearchWindow), "search");
452 gtk_window_set_title(GTK_WINDOW(pSearchWindow),
453 "Search");
455 pTableMain = gtk_table_new(2, 1, FALSE);
457 pFrame = gtk_frame_new(NULL);
459 gtk_table_attach(GTK_TABLE(pTableMain), pFrame, 0, 1, 0, 1,
460 GTK_FILL,
461 GTK_FILL,
465 pTableSearchParameters = gtk_table_new(
466 5, /* rows */
467 3, /* columns */
468 FALSE); /* homogeneous */
470 gtk_container_add(
471 GTK_CONTAINER(pFrame),
472 pTableSearchParameters);
474 gtk_container_set_border_width(
475 GTK_CONTAINER(pTableSearchParameters),
478 gtk_table_set_row_spacings(GTK_TABLE(pTableSearchParameters), 5);
479 gtk_table_set_col_spacings(GTK_TABLE(pTableSearchParameters), 5);
482 pChild = gtk_label_new("Filename");
484 gtk_table_attach(
485 GTK_TABLE(pTableSearchParameters),
486 pChild,
487 0, 1,
488 0, 1,
489 GTK_FILL,
490 GTK_FILL,
496 pChild = gtk_entry_new();
498 gtk_table_attach_defaults(
499 GTK_TABLE(pTableSearchParameters),
500 pChild,
501 1, 2,
502 0, 1);
504 g_signal_connect(
505 pChild,
506 "activate",
507 (GCallback)DoSearch,
508 pSearchWindow);
510 g_object_set_data(G_OBJECT(pSearchWindow), KEY_FILENAME, pChild);
514 pChild = gtk_combo_box_new_text();
516 i = 0;
518 while (pPMM[i].nID != MEDIADB_PMM_NULL)
520 gtk_combo_box_append_text(GTK_COMBO_BOX(pChild), pPMM[i].pszName);
521 i++;
524 gtk_combo_box_set_active(GTK_COMBO_BOX(pChild), 0);
526 gtk_table_attach(
527 GTK_TABLE(pTableSearchParameters),
528 pChild,
529 2, 3,
530 0, 1,
531 GTK_FILL,
532 GTK_FILL,
536 g_object_set_data(G_OBJECT(pSearchWindow), KEY_FILENAME_PMM, pChild);
540 pChild = gtk_label_new("Path");
542 gtk_table_attach(
543 GTK_TABLE(pTableSearchParameters),
544 pChild,
545 0, 1,
546 1, 2,
547 GTK_FILL,
548 GTK_FILL,
554 pChild = gtk_entry_new();
556 gtk_table_attach_defaults(
557 GTK_TABLE(pTableSearchParameters),
558 pChild,
559 1, 2,
560 1, 2);
562 g_signal_connect(
563 pChild,
564 "activate",
565 (GCallback)DoSearch,
566 pSearchWindow);
568 g_object_set_data(G_OBJECT(pSearchWindow), KEY_PATH, pChild);
572 pChild = gtk_combo_box_new_text();
574 i = 0;
576 while (pPMM[i].nID != MEDIADB_PMM_NULL)
578 gtk_combo_box_append_text(GTK_COMBO_BOX(pChild), pPMM[i].pszName);
579 i++;
582 gtk_combo_box_set_active(GTK_COMBO_BOX(pChild), 0);
584 gtk_table_attach(
585 GTK_TABLE(pTableSearchParameters),
586 pChild,
587 2, 3,
588 1, 2,
589 GTK_FILL,
590 GTK_FILL,
594 g_object_set_data(G_OBJECT(pSearchWindow), KEY_PATH_PMM, pChild);
598 pChild = gtk_label_new("Min size");
600 gtk_table_attach(
601 GTK_TABLE(pTableSearchParameters),
602 pChild,
603 0, 1,
604 2, 3,
605 GTK_FILL,
606 GTK_FILL,
612 pChild = gtk_entry_new();
614 gtk_table_attach_defaults(
615 GTK_TABLE(pTableSearchParameters),
616 pChild,
617 1, 2,
618 2, 3);
620 g_signal_connect(
621 pChild,
622 "activate",
623 (GCallback)DoSearch,
624 pSearchWindow);
626 g_object_set_data(G_OBJECT(pSearchWindow), KEY_MIN_SIZE, pChild);
630 pChild = gtk_combo_box_new_text();
632 i = j = 0;
634 while (g_arrSizeUnits[i].nUnitSize != 0)
636 if (i == 1)
638 /* Second entry should be kilobytes */
639 j = i;
642 gtk_combo_box_append_text(GTK_COMBO_BOX(pChild), g_arrSizeUnits[i].pszUnitsName);
644 i++;
647 gtk_combo_box_set_active(GTK_COMBO_BOX(pChild), j);
649 gtk_table_attach(
650 GTK_TABLE(pTableSearchParameters),
651 pChild,
652 2, 3,
653 2, 3,
654 GTK_FILL,
655 GTK_FILL,
659 g_object_set_data(G_OBJECT(pSearchWindow), KEY_MIN_SIZE_UNITS, pChild);
663 pChild = gtk_label_new("Max size");
665 gtk_table_attach(
666 GTK_TABLE(pTableSearchParameters),
667 pChild,
668 0, 1,
669 3, 4,
670 GTK_FILL,
671 GTK_FILL,
677 pChild = gtk_entry_new();
679 gtk_table_attach_defaults(
680 GTK_TABLE(pTableSearchParameters),
681 pChild,
682 1, 2,
683 3, 4);
685 g_signal_connect(
686 pChild,
687 "activate",
688 (GCallback)DoSearch,
689 pSearchWindow);
691 g_object_set_data(G_OBJECT(pSearchWindow), KEY_MAX_SIZE, pChild);
695 pChild = gtk_combo_box_new_text();
697 i = j = 0;
699 while (g_arrSizeUnits[i].nUnitSize != 0)
701 if (i == 1)
703 /* Second entry should be kilobytes */
704 j = i;
707 gtk_combo_box_append_text(GTK_COMBO_BOX(pChild), g_arrSizeUnits[i].pszUnitsName);
709 i++;
712 gtk_combo_box_set_active(GTK_COMBO_BOX(pChild), j);
714 gtk_table_attach(
715 GTK_TABLE(pTableSearchParameters),
716 pChild,
717 2, 3,
718 3, 4,
719 GTK_FILL,
720 GTK_FILL,
724 g_object_set_data(G_OBJECT(pSearchWindow), KEY_MAX_SIZE_UNITS, pChild);
728 pChild = gtk_button_new_from_stock(GTK_STOCK_FIND);
730 gtk_table_attach(
731 GTK_TABLE(pTableSearchParameters),
732 GTK_WIDGET(pChild),
733 0, 3,
734 4, 5,
735 GTK_FILL,
736 GTK_FILL,
740 g_signal_connect(
741 pChild,
742 "clicked",
743 (GCallback)DoSearch,
744 pSearchWindow);
747 /* Tree view creation */
748 pChild = gtk_tree_view_new();
749 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pChild), TRUE);
750 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(pChild), TRUE);
752 pRendererText = gtk_cell_renderer_text_new();
753 pRendererPixbuf = gtk_cell_renderer_pixbuf_new();
755 /* --- Column #1 --- */
757 pColumn = gtk_tree_view_column_new();
758 gtk_tree_view_column_set_title(pColumn, "Name");
760 gtk_tree_view_column_pack_start(pColumn, pRendererPixbuf, FALSE);
761 gtk_tree_view_column_set_attributes(pColumn, pRendererPixbuf,
762 "pixbuf", COL_ICON,
763 NULL);
765 gtk_tree_view_column_pack_start(pColumn, pRendererText, TRUE);
766 gtk_tree_view_column_set_attributes(pColumn,
767 pRendererText,
768 "text", COL_NAME,
769 NULL);
771 gtk_tree_view_append_column(
772 GTK_TREE_VIEW(pChild),
773 pColumn);
775 /* --- Column #2 --- */
777 pColumn = gtk_tree_view_column_new_with_attributes(
778 "Size",
779 pRendererText,
780 "text", COL_SIZE,
781 NULL);
783 gtk_tree_view_append_column(
784 GTK_TREE_VIEW(pChild),
785 pColumn);
787 /* --- Column #3 --- */
789 pColumn = gtk_tree_view_column_new_with_attributes(
790 "Time",
791 pRendererText,
792 "text", COL_TIME,
793 NULL);
795 gtk_tree_view_append_column(
796 GTK_TREE_VIEW(pChild),
797 pColumn);
799 /* --- Column #4 --- */
801 pColumn = gtk_tree_view_column_new_with_attributes(
802 "MediaID",
803 pRendererText,
804 "text", COL_MEDIAID,
805 NULL);
807 gtk_tree_view_append_column(
808 GTK_TREE_VIEW(pChild),
809 pColumn);
811 /* --- Column #5 --- */
813 pColumn = gtk_tree_view_column_new();
815 gtk_tree_view_column_set_title(
816 pColumn,
817 "MediaName");
819 gtk_tree_view_column_pack_start(
820 pColumn,
821 pRendererPixbuf,
822 FALSE);
824 gtk_tree_view_column_set_attributes(
825 pColumn,
826 pRendererPixbuf,
827 "pixbuf",
828 COL_MEDIAICON,
829 NULL);
831 gtk_tree_view_column_pack_end(
832 pColumn,
833 pRendererText,
834 TRUE);
836 gtk_tree_view_column_set_attributes(
837 pColumn,
838 pRendererText,
839 "text", COL_MEDIANAME,
840 NULL);
842 gtk_tree_view_append_column(
843 GTK_TREE_VIEW(pChild),
844 pColumn);
846 /* --- Column #6 --- */
848 pColumn = gtk_tree_view_column_new_with_attributes(
849 "Location",
850 pRendererText,
851 "text", COL_MEDIALOCATION,
852 NULL);
854 gtk_tree_view_append_column(
855 GTK_TREE_VIEW(pChild),
856 pColumn);
858 /* Create the store */
859 pListStore = gtk_list_store_new(
860 NUM_COLS,
861 GDK_TYPE_PIXBUF, /* COL_ICON */
862 G_TYPE_STRING, /* COL_NAME */
863 G_TYPE_STRING, /* COL_SIZE */
864 G_TYPE_STRING, /* COL_TIME */
865 G_TYPE_UINT, /* COL_MEDIAID */
866 GDK_TYPE_PIXBUF, /* COL_MEDIAICON */
867 G_TYPE_STRING, /* COL_MEDIANAME */
868 G_TYPE_STRING); /* COL_MEDIALOCATION */
870 /* Create a new scrolled window, with scrollbars only if needed */
872 pScrolledWindow = gtk_scrolled_window_new(NULL, NULL);
874 gtk_scrolled_window_set_policy(
875 GTK_SCROLLED_WINDOW(pScrolledWindow),
876 GTK_POLICY_AUTOMATIC,
877 GTK_POLICY_AUTOMATIC);
879 gtk_container_add(
880 GTK_CONTAINER(pScrolledWindow),
881 pChild);
883 gtk_table_attach(GTK_TABLE(pTableMain), pScrolledWindow, 0, 1, 1, 2,
884 GTK_FILL|GTK_EXPAND,
885 GTK_FILL|GTK_EXPAND,
889 /* Set model */
890 gtk_tree_view_set_model(GTK_TREE_VIEW(pChild), GTK_TREE_MODEL(pListStore));
892 g_object_set_data(G_OBJECT(pSearchWindow), KEY_STORE, pListStore);
894 /* Add main table to top window */
895 gtk_container_add(GTK_CONTAINER(pSearchWindow), pTableMain);
897 gtk_window_set_default_size(GTK_WINDOW(pSearchWindow), 600, 400);
899 gtk_widget_show_all(pSearchWindow);
902 /*****************************************************************************
904 * Modifications log:
906 * !!! WARNING !!! Following lines are automatically updated by the CVS system.
908 * $Log: search.c,v $
909 * Revision 1.5 2005/02/18 02:12:08 nedko
910 * Use path module to access project specific data files.
912 * Revision 1.4 2004/09/18 21:34:59 nedko
913 * Return media name, media type and media location when searching files.
915 * Revision 1.3 2004/09/01 05:05:43 nedko
916 * Search partitially works.
918 * Revision 1.2 2004/09/01 00:56:43 nedko
919 * Refine look.
920 * Attach callback for search action.
922 * Revision 1.1 2004/08/31 22:40:15 nedko
923 * Partitally implemented search feature.
925 *****************************************************************************/