aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/search.c')
-rw-r--r--src/plugins/fs/search.c832
1 files changed, 510 insertions, 322 deletions
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index e7c1a63e..63d7622c 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -46,19 +46,102 @@
46 */ 46 */
47typedef struct SL { 47typedef struct SL {
48 struct SL * next; 48 struct SL * next;
49 GtkWidget * treeview; 49 /**
50 * Reference to the glade XML context that was
51 * used to create the search page.
52 */
53 GladeXML * searchXML;
54
55 /**
56 * Reference to the glade XML context that was
57 * used to create the search label.
58 */
59 GladeXML * labelXML;
60
61 /**
62 * Tree view widget that is used to display the
63 * search results.
64 */
65 GtkTreeView * treeview;
66
67 /**
68 * Model of the tree view.
69 */
70 GtkTreeStore * tree;
71
72 /**
73 * The label used in the notebook page.
74 */
75 GtkLabel * tab_label;
76
77 /**
78 * The notebook page that is associated with this
79 * search.
80 */
50 GtkWidget * searchpage; 81 GtkWidget * searchpage;
51 GtkWidget * anonymityButton; /* FIXME: initialize! */ 82
83 /**
84 * Path to the entry in the summary list
85 * for this search.
86 */
87 GtkTreeRowReference * summaryViewRowReference;
88
89 /**
90 * URI for this search.
91 */
52 struct ECRS_URI * uri; 92 struct ECRS_URI * uri;
53 struct FSUI_SearchList * fsui_list; /* FIXME: initialize! */ 93
94 /**
95 * String describing the search.
96 */
97 char * searchString;
98
99 /**
100 * Number of results received so far.
101 */
102 unsigned int resultsReceived;
103
104 /**
105 * FSUI search handle.
106 */
107 struct FSUI_SearchList * fsui_list;
54} SearchList; 108} SearchList;
55 109
56typedef struct DL { 110typedef struct DL {
57 struct DL * next; 111 struct DL * next;
112
113 /**
114 * URI of the download.
115 */
58 struct ECRS_URI * uri; 116 struct ECRS_URI * uri;
117
118 /**
119 * Where is the download being saved to?
120 */
59 char * filename; 121 char * filename;
60 GtkTreeRowReference * rr; 122
61 GtkTreeModel * model; 123 /**
124 * Path in the summary view for this download.
125 */
126 GtkTreeRowReference * summaryViewRowReference;
127
128 /**
129 * Search that this download belongs to.
130 * Maybe NULL.
131 */
132 struct SL * searchList;
133
134 /**
135 * Path in the search view that this
136 * download is represented by. Maybe NULL
137 * if search has been closed or if download
138 * was initiated from URI without search.
139 */
140 GtkTreeRowReference * searchViewRowReference;
141
142 /**
143 * FSUI reference for the download.
144 */
62 struct FSUI_DownloadList * fsui_list; 145 struct FSUI_DownloadList * fsui_list;
63} DownloadList; 146} DownloadList;
64 147
@@ -74,40 +157,38 @@ static struct GE_Context * ectx;
74 157
75static struct GC_Configuration * cfg; 158static struct GC_Configuration * cfg;
76 159
77 160/**
161 * The user has clicked the "SEARCH" button.
162 * Initiate a search.
163 */
78void on_fssearchbutton_clicked_fs(gpointer dummy2, 164void on_fssearchbutton_clicked_fs(gpointer dummy2,
79 GtkWidget * searchButton) { 165 GtkWidget * searchButton) {
80 struct ECRS_URI * uri; 166 struct ECRS_URI * uri;
81 const char * ss; 167 const char * searchString;
82 const char * ns;
83 gint pages; 168 gint pages;
84 const char * descStr;
85 char * ustring;
86 gint i; 169 gint i;
87 SearchList * list; 170 SearchList * list;
88 GtkListStore * model;
89 GtkTreeModel * tmodel;
90 GtkTreeIter iter; 171 GtkTreeIter iter;
91 GtkWidget * searchKeywordGtkCB; 172 GtkWidget * searchKeywordGtkCB;
92 GtkWidget * searchNamespaceGtkCB; 173 GtkWidget * searchNamespaceGtkCB;
93 GtkWidget * entry; 174 GtkNotebook * notebook;
94 GtkWidget * notebook;
95 GtkWidget * page;
96 175
97 DEBUG_BEGIN();
98 searchKeywordGtkCB 176 searchKeywordGtkCB
99 = glade_xml_get_widget(getMainXML(), 177 = glade_xml_get_widget(getMainXML(),
100 "fssearchKeywordComboBoxEntry"); 178 "fssearchKeywordComboBoxEntry");
101 entry = gtk_bin_get_child(GTK_BIN(searchKeywordGtkCB)); 179 searchString = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(searchKeywordGtkCB))));
102 ss = gtk_entry_get_text(GTK_ENTRY(entry)); 180 if (searchString == NULL) {
103 if (ss == NULL) {
104 GE_LOG(ectx, 181 GE_LOG(ectx,
105 GE_ERROR | GE_USER | GE_IMMEDIATE, 182 GE_ERROR | GE_USER | GE_IMMEDIATE,
106 _("Need a keyword to search!\n")); 183 _("Need a keyword to search!\n"));
107 return; 184 return;
108 } 185 }
186 /* add the keyword to the list of keywords that have
187 been used so far */
109 i = gtk_combo_box_get_active(GTK_COMBO_BOX(searchKeywordGtkCB)); 188 i = gtk_combo_box_get_active(GTK_COMBO_BOX(searchKeywordGtkCB));
110 if (i == -1) { 189 if (i == -1) {
190 GtkListStore * model;
191
111 model = GTK_LIST_STORE 192 model = GTK_LIST_STORE
112 (gtk_combo_box_get_model 193 (gtk_combo_box_get_model
113 (GTK_COMBO_BOX(searchKeywordGtkCB))); 194 (GTK_COMBO_BOX(searchKeywordGtkCB)));
@@ -115,18 +196,22 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
115 &iter); 196 &iter);
116 gtk_list_store_set(model, 197 gtk_list_store_set(model,
117 &iter, 198 &iter,
118 0, ss, 199 0, searchString,
119 -1); 200 -1);
120 } 201 }
202 uri = NULL;
203 /* check for namespace search */
121 searchNamespaceGtkCB 204 searchNamespaceGtkCB
122 = glade_xml_get_widget(getMainXML(), 205 = glade_xml_get_widget(getMainXML(),
123 "searchNamespaceComboBoxEntry"); 206 "searchNamespaceComboBoxEntry");
124 tmodel = gtk_combo_box_get_model(GTK_COMBO_BOX(searchNamespaceGtkCB));
125 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(searchNamespaceGtkCB), 207 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(searchNamespaceGtkCB),
126 &iter)) { 208 &iter)) {
209 const char * descStr;
210 const char * ns;
211
127 ns = NULL; 212 ns = NULL;
128 descStr = NULL; 213 descStr = NULL;
129 gtk_tree_model_get(tmodel, 214 gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(searchNamespaceGtkCB)),
130 &iter, 215 &iter,
131 NS_SEARCH_DESCRIPTION, &descStr, 216 NS_SEARCH_DESCRIPTION, &descStr,
132 NS_SEARCH_ENCNAME, &ns, 217 NS_SEARCH_ENCNAME, &ns,
@@ -141,43 +226,47 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
141 if (descStr == NULL) 226 if (descStr == NULL)
142 descStr = ns; 227 descStr = ns;
143 } 228 }
144 } 229 if (ns != NULL) {
145 if (ns != NULL) { 230 char * ustring;
146 ustring = MALLOC(strlen(ss) + sizeof(EncName) + 231
147 strlen(ECRS_URI_PREFIX) + 232 ustring = MALLOC(strlen(searchString) + sizeof(EncName) +
148 strlen(ECRS_SUBSPACE_INFIX) + 10); 233 strlen(ECRS_URI_PREFIX) +
149 strcpy(ustring, ECRS_URI_PREFIX); 234 strlen(ECRS_SUBSPACE_INFIX) + 10);
150 strcat(ustring, ECRS_SUBSPACE_INFIX); 235 strcpy(ustring, ECRS_URI_PREFIX);
151 strcat(ustring, ns); 236 strcat(ustring, ECRS_SUBSPACE_INFIX);
152 strcat(ustring, "/"); 237 strcat(ustring, ns);
153 strcat(ustring, ss); 238 strcat(ustring, "/");
154 uri = ECRS_stringToUri(ectx, ustring); 239 strcat(ustring, searchString);
155 if (uri == NULL) { 240 uri = ECRS_stringToUri(ectx, ustring);
156 GE_LOG(ectx, 241 if (uri == NULL) {
157 GE_ERROR | GE_BULK | GE_USER, 242 GE_LOG(ectx,
158 _("Failed to create namespace URI from `%s'.\n"), 243 GE_ERROR | GE_BULK | GE_USER,
159 ustring); 244 _("Failed to create namespace URI from `%s'.\n"),
245 ustring);
246 }
247 FREE(ustring);
160 } 248 }
161 FREE(ustring);
162 } else {
163 uri = ECRS_parseCharKeywordURI(ectx, ss);
164 } 249 }
165 if (uri == NULL) 250 if (uri == NULL)
251 uri = ECRS_parseCharKeywordURI(ectx, searchString);
252 if (uri == NULL) {
253 GE_BREAK(ectx, 0);
166 return; 254 return;
255 }
167 /* check if search is already running */ 256 /* check if search is already running */
168 notebook 257 notebook
169 = glade_xml_get_widget(getMainXML(), 258 = GTK_NOTEBOOK(glade_xml_get_widget(getMainXML(),
170 "downloadNotebook"); 259 "downloadNotebook"));
171 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); 260 pages = gtk_notebook_get_n_pages(notebook);
172 list = search_head; 261 list = search_head;
173 while (list != NULL) { 262 while (list != NULL) {
174 if (ECRS_equalsUri(list->uri, 263 if (ECRS_equalsUri(list->uri,
175 uri)) { 264 uri)) {
176 for (i=0;i<pages;i++) { 265 for (i=0;i<pages;i++) {
177 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 266 if (gtk_notebook_get_nth_page(notebook,
178 i); 267 i)
179 if (page == list->searchpage) { 268 == list->searchpage) {
180 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 269 gtk_notebook_set_current_page(notebook,
181 i); 270 i);
182 ECRS_freeUri(uri); 271 ECRS_freeUri(uri);
183 return; 272 return;
@@ -188,35 +277,46 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
188 list = list->next; 277 list = list->next;
189 } 278 }
190 FSUI_startSearch(ctx, 279 FSUI_startSearch(ctx,
191 getAnonymityLevel(getMainXML(), 280 getSpinButtonValue(getMainXML(),
192 "searchAnonymitySelectionSpinButton"), 281 "searchAnonymitySelectionSpinButton"),
193 1000, /* FIXME: max results */ 282 getSpinButtonValue(getMainXML(),
194 99 * cronYEARS, /* FIXME: timeout */ 283 "maxResultsSpinButton"),
284 getSpinButtonValue(getMainXML(),
285 "searchDelaySpinButton") * cronSECONDS,
195 uri); 286 uri);
196} 287}
197 288
289/**
290 * This method is called when the user clicks on either
291 * the "CLOSE" button (at the bottom of the search page)
292 * or on the "CANCEL (X)" button in the TAB of the
293 * search notebook. Note that "searchPage" can thus
294 * either refer to the main page in the tab or to the
295 * main entry of the tab label.
296 */
198void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, 297void on_closeSearchButton_clicked_fs(GtkWidget * searchPage,
199 GtkWidget * closeButton) { 298 GtkWidget * closeButton) {
200 SearchList * list; 299 SearchList * list;
201 300
202 DEBUG_BEGIN();
203 list = search_head; 301 list = search_head;
204 while (list != NULL) { 302 while (list != NULL) {
205 if (list->searchpage == searchPage) 303 if ( (list->searchpage == searchPage) ||
304 (list->tab_label == searchPage) )
206 break; 305 break;
207 list = list->next; 306 list = list->next;
208 } 307 }
209 GE_ASSERT(ectx, list != NULL); 308 GE_ASSERT(ectx, list != NULL);
210 FSUI_stopSearch(ctx, 309 FSUI_stopSearch(ctx,
211 list->fsui_list); 310 list->fsui_list);
212 DEBUG_END();
213} 311}
214 312
313/**
314 * The abort button was clicked. Abort the search.
315 */
215void on_abortSearchButton_clicked_fs(GtkWidget * searchPage, 316void on_abortSearchButton_clicked_fs(GtkWidget * searchPage,
216 GtkWidget * closeButton) { 317 GtkWidget * closeButton) {
217 SearchList * list; 318 SearchList * list;
218 319
219 DEBUG_BEGIN();
220 list = search_head; 320 list = search_head;
221 while (list != NULL) { 321 while (list != NULL) {
222 if (list->searchpage == searchPage) 322 if (list->searchpage == searchPage)
@@ -226,25 +326,27 @@ void on_abortSearchButton_clicked_fs(GtkWidget * searchPage,
226 GE_ASSERT(ectx, list != NULL); 326 GE_ASSERT(ectx, list != NULL);
227 FSUI_abortSearch(ctx, 327 FSUI_abortSearch(ctx,
228 list->fsui_list); 328 list->fsui_list);
229 DEBUG_END();
230} 329}
231 330
232static void stopSearch(GtkTreeModel * model, 331static void stopSearch(GtkTreeModel * model,
233 GtkTreePath * path, 332 GtkTreePath * path,
234 GtkTreeIter * iter, 333 GtkTreeIter * iter,
235 gpointer unused) { 334 gpointer unused) {
236 struct FSUI_SearchList * s; 335 struct SL * s;
237 336
238 s = NULL; 337 s = NULL;
239 gtk_tree_model_get(model, 338 gtk_tree_model_get(model,
240 iter, 339 iter,
241 SER_SUM_FSUI, &s, 340 SEARCH_SUMMARY_INTERNAL, &s,
242 -1); 341 -1);
243 if (s != NULL) 342 if (s != NULL)
244 FSUI_stopSearch(ctx, 343 FSUI_stopSearch(ctx,
245 s); 344 s->fsui_list);
246} 345}
247 346
347/**
348 * The stop button in the search summary was clicked.
349 */
248void on_closeSearchSummaryButton_clicked_fs(GtkWidget * treeview, 350void on_closeSearchSummaryButton_clicked_fs(GtkWidget * treeview,
249 GtkWidget * closeButton) { 351 GtkWidget * closeButton) {
250 GtkTreeSelection * selection; 352 GtkTreeSelection * selection;
@@ -260,18 +362,21 @@ static void abortSearch(GtkTreeModel * model,
260 GtkTreePath * path, 362 GtkTreePath * path,
261 GtkTreeIter * iter, 363 GtkTreeIter * iter,
262 gpointer unused) { 364 gpointer unused) {
263 struct FSUI_SearchList * s; 365 struct SL * s;
264 366
265 s = NULL; 367 s = NULL;
266 gtk_tree_model_get(model, 368 gtk_tree_model_get(model,
267 iter, 369 iter,
268 SER_SUM_FSUI, &s, 370 SEARCH_SUMMARY_INTERNAL, &s,
269 -1); 371 -1);
270 if (s != NULL) 372 if (s != NULL)
271 FSUI_abortSearch(ctx, 373 FSUI_abortSearch(ctx,
272 s); 374 s->fsui_list);
273} 375}
274 376
377/**
378 * The abort button in the search summary was clicked.
379 */
275void on_abortSearchSummaryButton_clicked_fs(GtkWidget * treeview, 380void on_abortSearchSummaryButton_clicked_fs(GtkWidget * treeview,
276 GtkWidget * closeButton) { 381 GtkWidget * closeButton) {
277 GtkTreeSelection * selection; 382 GtkTreeSelection * selection;
@@ -284,6 +389,42 @@ void on_abortSearchSummaryButton_clicked_fs(GtkWidget * treeview,
284} 389}
285 390
286/** 391/**
392 * Update the number of results received for the given
393 * search in the summary and in the label of the tab.
394 */
395static void updateSearchSummary(struct SL * searchContext) {
396 GtkTreePath * path;
397 GtkTreeIter iter;
398 char * new_title;
399 GtkWidget * label;
400
401 path = gtk_tree_row_reference_get_path(searchContext->summaryViewRowReference);
402 if (TRUE != gtk_tree_model_get_iter(GTK_TREE_MODEL(search_summary),
403 &iter,
404 path)) {
405 GE_BREAK(ectx, 0);
406 return;
407 }
408 gtk_tree_path_free(path);
409 gtk_list_store_set(search_summary,
410 &iter,
411 SEARCH_SUMMARY_RESULT_COUNT, searchContext->resultsReceived,
412 -1);
413
414
415
416 /* update tab title with the number of results */
417 new_title =
418 g_strdup_printf("%s (%u)",
419 searchContext->searchString,
420 searchContext->resultsReceived);
421 label = glade_xml_get_widget(searchContext->labelXML,
422 "searchTabLabel");
423 gtk_label_set(label, new_title);
424 FREE(new_title);
425}
426
427/**
287 * Add the given result to the model (search result 428 * Add the given result to the model (search result
288 * list). 429 * list).
289 * 430 *
@@ -297,85 +438,20 @@ void fs_search_result_received(struct SL * searchContext,
297 char * name; 438 char * name;
298 char * mime; 439 char * mime;
299 char * desc; 440 char * desc;
300 unsigned char * thumb;
301 size_t ts;
302 GdkPixbuf * pixbuf;
303 GdkPixbufLoader * loader;
304 unsigned long long size; 441 unsigned long long size;
305 char * size_h; 442 char * size_h;
306 GtkTreeStore * model; 443 GtkTreeStore * model;
307 GtkTreeIter iter; 444 GtkTreeIter iter;
308 unsigned int * file_count;
309 GtkWidget * tab_label;
310 const char * tab_title;
311 char * new_title;
312 struct ECRS_URI * euri;
313 445
314 DEBUG_BEGIN(); 446 mime = getMimeTypeFromMetaData(info->meta);
447 desc = getDescriptionFromMetaData(info->meta);
448 name = getFileNameFromMetaData(info->meta);
449 size = ECRS_isFileUri(info->uri) ? ECRS_fileSize(info->uri) : 0
450 pixbuf = getThumbnailFromMetaData(info->meta);
451 size_h = string_get_fancy_byte_size(size);
315 model = GTK_TREE_STORE 452 model = GTK_TREE_STORE
316 (gtk_tree_view_get_model 453 (gtk_tree_view_get_model
317 (GTK_TREE_VIEW(searchContext->treeview))); 454 (GTK_TREE_VIEW(searchContext->treeview)));
318 mime = ECRS_getFromMetaData(info->meta,
319 EXTRACTOR_MIMETYPE);
320 if (mime == NULL)
321 mime = STRDUP(_("unknown"));
322 mime = validate_utf8(mime);
323 desc = ECRS_getFirstFromMetaData(info->meta,
324 EXTRACTOR_DESCRIPTION,
325 EXTRACTOR_GENRE,
326 EXTRACTOR_ALBUM,
327 EXTRACTOR_COMMENT,
328 EXTRACTOR_SUBJECT,
329 EXTRACTOR_FORMAT,
330 EXTRACTOR_SIZE,
331 EXTRACTOR_KEYWORDS,
332 -1);
333 if (desc == NULL)
334 desc = STRDUP("");
335 desc = validate_utf8(desc);
336 name = ECRS_getFirstFromMetaData(info->meta,
337 EXTRACTOR_FILENAME,
338 EXTRACTOR_TITLE,
339 EXTRACTOR_ARTIST,
340 EXTRACTOR_AUTHOR,
341 EXTRACTOR_PUBLISHER,
342 EXTRACTOR_CREATOR,
343 EXTRACTOR_PRODUCER,
344 EXTRACTOR_UNKNOWN,
345 -1);
346 if (name == NULL) {
347 name = STRDUP(_("no name given"));
348 } else {
349 char * dotdot;
350
351 while (NULL != (dotdot = strstr(name, "..")))
352 dotdot[0] = dotdot[1] = '_';
353 }
354 name = validate_utf8(name);
355
356 if (ECRS_isFileUri(info->uri))
357 size = ECRS_fileSize(info->uri);
358 else
359 size = 0;
360 thumb = NULL;
361 ts = ECRS_getThumbnailFromMetaData(info->meta,
362 &thumb);
363 if (ts != 0) {
364 loader = gdk_pixbuf_loader_new();
365 gdk_pixbuf_loader_write(loader,
366 (const guchar*) thumb,
367 ts,
368 NULL);
369 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
370 gdk_pixbuf_loader_close(loader,
371 NULL);
372 if (pixbuf != NULL)
373 g_object_ref(pixbuf);
374 UNREF(loader);
375 } else {
376 pixbuf = NULL;
377 }
378 size_h = string_get_fancy_byte_size(size);
379 gtk_tree_store_append(model, 455 gtk_tree_store_append(model,
380 &iter, 456 &iter,
381 NULL); 457 NULL);
@@ -392,82 +468,35 @@ void fs_search_result_received(struct SL * searchContext,
392 SEARCH_INTERNAL, searchContext, 468 SEARCH_INTERNAL, searchContext,
393 -1); 469 -1);
394 FREE(size_h); 470 FREE(size_h);
395 FREE(mime);
396 FREE(desc);
397 FREE(name); 471 FREE(name);
398 FREENONNULL(thumb); 472 FREE(desc);
399 473 FREE(mime);
400 /* update tab title with the number of results */ 474 /* UNREF pixbuf? */
401 file_count = (unsigned int *) 475 searchContext->resultsReceived++;
402 g_object_get_data(G_OBJECT(searchContext->searchpage), "file_count"); 476 updateSearchSummary(searchContext);
403 (*file_count)++;
404 tab_label = (GtkWidget *)
405 g_object_get_data(G_OBJECT(searchContext->searchpage), "label");
406 tab_title = (const char *)
407 g_object_get_data(G_OBJECT(searchContext->searchpage), "title");
408 new_title =
409 g_strdup_printf("%s%s%u%s",
410 tab_title, " (", *file_count, ")");
411 gtk_label_set(GTK_LABEL(tab_label), new_title);
412 FREE(new_title);
413
414 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(search_summary),
415 &iter)) {
416 GE_BREAK(ectx, 0);
417 return;
418 }
419
420 do {
421 gtk_tree_model_get(GTK_TREE_MODEL(search_summary),
422 &iter,
423 SER_SUM_URI, &euri,
424 -1);
425 if (ECRS_equalsUri(euri,
426 uri)) {
427 gtk_list_store_set(GTK_LIST_STORE(search_summary),
428 &iter,
429 SER_SUM_COUNT, *file_count,
430 -1);
431 DEBUG_END();
432 return;
433 }
434
435 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(search_summary),
436 &iter));
437} 477}
438 478
439SearchList * 479/**
480 * FSUI event: a search was started; create the
481 * tab and add an entry to the summary.
482 */
483struct SL *
440fs_search_started(struct FSUI_SearchList * fsui_list, 484fs_search_started(struct FSUI_SearchList * fsui_list,
441 const struct ECRS_URI * uri, 485 const struct ECRS_URI * uri,
442 unsigned int anonymityLevel, 486 unsigned int anonymityLevel,
443 unsigned int resultCount, 487 unsigned int resultCount,
444 const ECRS_FileInfo * results) { 488 const ECRS_FileInfo * results) {
445 GtkWidget * notebook; 489 struct SL * list;
446 GtkWidget * label;
447 GtkTreeIter iter;
448 SearchList * list;
449 char * tabtxt;
450 int i;
451 const char * dhead;
452 gint pages; 490 gint pages;
453 char * description; 491 char * description;
454 492 const char * dhead;
455 notebook 493 GtkContainer * window;
456 = glade_xml_get_widget(getMainXML(), 494 GtkTreeViewColumn * column;
457 "downloadNotebook"); 495 GtkCellRenderer * renderer;
458 list 496 int col;
459 = MALLOC(sizeof(SearchList)); 497 GtkNotebook * notebook;
460 list->searchpage 498 GtkTreePath * path;
461 = makeSearchResultFrame(cfg, 499 GtkTreeIter iter;
462 &list->treeview,
463 &list->anonymityButton);
464 list->uri
465 = ECRS_dupUri(uri);
466 list->next
467 = search_head;
468 list->fsui_list
469 = fsui_list;
470 search_head = list;
471 500
472 description = ECRS_uriToString(uri); 501 description = ECRS_uriToString(uri);
473 if (description == NULL) { 502 if (description == NULL) {
@@ -485,31 +514,169 @@ fs_search_started(struct FSUI_SearchList * fsui_list,
485 ECRS_SUBSPACE_INFIX, 514 ECRS_SUBSPACE_INFIX,
486 strlen(ECRS_SUBSPACE_INFIX))) 515 strlen(ECRS_SUBSPACE_INFIX)))
487 dhead = &dhead[strlen(ECRS_SUBSPACE_INFIX)]; 516 dhead = &dhead[strlen(ECRS_SUBSPACE_INFIX)];
517 list
518 = MALLOC(sizeof(struct SL));
519 memset(list,
520 0,
521 sizeof(struct SL));
522 list->searchString
523 = STRDUP(dhead);
524 FREE(description);
525 list->uri
526 = ECRS_dupUri(uri);
527 list->fsui_list
528 = fsui_list;
529 list->next
530 = search_head;
531 search_head = list;
532 list->searchXML
533 = glade_xml_new(getGladeFileName(),
534 "searchResultsFrame",
535 PACKAGE_NAME);
536 connectGladeWithPlugins(list->searchXML);
537 list->searchpage
538 = extractMainWidgetFromWindow(list->searchXML,
539 "searchResultsFrame");
540 /* setup tree view and renderers */
541 list->treeview = GTK_TREE_VIEW(glade_xml_get_widget(list->searchXML,
542 "searchResults"));
543
544 list->tree =
545 gtk_tree_store_new(SEARCH_NUM,
546 G_TYPE_STRING, /* name */
547 G_TYPE_UINT64, /* size */
548 G_TYPE_STRING, /* human-readable size */
549 G_TYPE_STRING, /* mime-type */
550 G_TYPE_STRING, /* meta-data (some) */
551 GDK_TYPE_PIXBUF, /* preview */
552 G_TYPE_POINTER, /* url */
553 G_TYPE_POINTER, /* meta */
554 G_TYPE_POINTER); /* internal: download info/NULL */
555
556 gtk_tree_view_set_model(list->treeview,
557 GTK_TREE_MODEL(list->tree));
558 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(list->treeview),
559 GTK_SELECTION_MULTIPLE);
488 560
489 tabtxt = STRDUP("foo"); /* FIXME! */ 561 renderer = gtk_cell_renderer_text_new();
562 col = gtk_tree_view_insert_column_with_attributes(list->treeview,
563 -1,
564 _("Name"),
565 renderer,
566 "text", SEARCH_NAME,
567 NULL);
568 column = gtk_tree_view_get_column(list->treeview,
569 col - 1);
570 gtk_tree_view_column_set_resizable(column, TRUE);
571 gtk_tree_view_column_set_clickable(column, TRUE);
572 gtk_tree_view_column_set_reorderable(column, TRUE);
573 gtk_tree_view_column_set_sort_column_id(column, SEARCH_NAME);
574
575 renderer = gtk_cell_renderer_text_new();
576 g_object_set (renderer, "xalign", 1.00, NULL);
577 col = gtk_tree_view_insert_column_with_attributes(list->treeview,
578 -1,
579 _("Size"),
580 renderer,
581 "text", SEARCH_HSIZE,
582 NULL);
583 column = gtk_tree_view_get_column(list->treeview,
584 col - 1);
585 gtk_tree_view_column_set_resizable(column, TRUE);
586 gtk_tree_view_column_set_clickable(column, TRUE);
587 gtk_tree_view_column_set_reorderable(column, TRUE);
588 gtk_tree_view_column_set_sort_column_id(column, SEARCH_SIZE);
589
590 renderer = gtk_cell_renderer_text_new();
591 col = gtk_tree_view_insert_column_with_attributes(list->treeview,
592 -1,
593 _("Mime-type"),
594 renderer,
595 "text", SEARCH_MIME,
596 NULL);
597 column = gtk_tree_view_get_column(list->treeview,
598 col - 1);
599 gtk_tree_view_column_set_resizable(column, TRUE);
600 gtk_tree_view_column_set_clickable(column, TRUE);
601 gtk_tree_view_column_set_reorderable(column, TRUE);
602 gtk_tree_view_column_set_sort_column_id(column, SEARCH_MIME);
603
604 renderer = gtk_cell_renderer_text_new();
605 col = gtk_tree_view_insert_column_with_attributes(list->treeview,
606 -1,
607 _("Meta-data"),
608 renderer,
609 "text", SEARCH_DESC,
610 NULL);
611 column = gtk_tree_view_get_column(list->treeview,
612 col - 1);
613 gtk_tree_view_column_set_resizable(column, TRUE);
614 gtk_tree_view_column_set_clickable(column, TRUE);
615 gtk_tree_view_column_set_reorderable(column, TRUE);
616 gtk_tree_view_column_set_sort_column_id(column, SEARCH_DESC);
617 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
618 if (YES != GC_get_configuration_value_yesno(cfg,
619 "GNUNET-GTK",
620 "DISABLE-PREVIEWS",
621 NO)) {
622 renderer = gtk_cell_renderer_pixbuf_new();
623 col = gtk_tree_view_insert_column_with_attributes(list->treeview,
624 -1,
625 _("Preview"),
626 renderer,
627 "pixbuf", SEARCH_PIXBUF,
628 NULL);
629 column = gtk_tree_view_get_column(list->treeview,
630 col - 1);
631 gtk_tree_view_column_set_resizable(column, TRUE);
632 gtk_tree_view_column_set_reorderable(column, TRUE);
633 gtk_tree_view_column_set_resizable(column, TRUE);
634 }
635
636
637 /* add entry in search summary */
490 gtk_list_store_append(search_summary, 638 gtk_list_store_append(search_summary,
491 &iter); 639 &iter);
492 gtk_list_store_set(search_summary, 640 gtk_list_store_set(search_summary,
493 &iter, 641 &iter,
494 SER_SUM_NAME, dhead, 642 SEARCH_SUMMARY_NAME, dhead,
495 SER_SUM_COUNT, 0, 643 SEARCH_SUMMARY_RESULT_COUNT, 0,
496 SER_SUM_URI, ECRS_dupUri(uri), 644 SEARCH_SUMMARY_INTERNAL, list,
497 -1); 645 -1);
498 label = buildSearchTabLabel(list->searchpage, 646 path = gtk_tree_model_get_path(GTK_TREE_MODEL(search_summary),
499 dhead); 647 &iter);
500 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); 648 list->summaryViewRowReference
501 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 649 = gtk_tree_row_reference_new(GTK_TREE_MODEL(search_summary),
502 list->searchpage, 650 path);
503 label); 651 gtk_tree_path_free(path);
504 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 652
505 pages); 653 /* load label */
506 gtk_widget_show(notebook); 654 list->labelXML
507 FREE(description); 655 = glade_xml_new(getGladeFileName(),
656 "searchTabLabelWindow",
657 PACKAGE_NAME);
658 list->tab_label
659 = extractMainWidgetFromWindow(list->labelXML,
660 "searchTabLabelWindow");
661
662 /* process existing results */
508 for (i=0;i<resultCount;i++) 663 for (i=0;i<resultCount;i++)
509 fs_search_result_received(list, 664 fs_search_result_received(list,
510 &results[i], 665 &results[i],
511 uri); 666 uri);
512 DEBUG_END(); 667
668 /* insert new page into search notebook */
669 notebook
670 = GTK_NOTEBOOK(glade_xml_get_widget(getMainXML(),
671 "downloadNotebook"));
672 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
673 gtk_notebook_append_page(notebook,
674 list->searchpage,
675 list->tab_label);
676 gtk_notebook_set_current_page(notebook,
677 pages);
678 gtk_widget_show(GTK_WIDGET(notebook)); /* may have been hidden! */
679
513 return list; 680 return list;
514} 681}
515 682
@@ -548,15 +715,21 @@ static void freeIterSubtree(GtkTreeModel * tree,
548 iter)); 715 iter));
549} 716}
550 717
718/**
719 * FSUI event: a search was stopped. Remove the
720 * respective tab and its entry in the summary.
721 */
551void fs_search_stopped(SearchList * list) { 722void fs_search_stopped(SearchList * list) {
552 GtkWidget * notebook; 723 GtkNotebook * notebook;
553 int index; 724 int index;
554 int i; 725 int i;
555 GtkTreeIter iter; 726 GtkTreeIter iter;
556 struct ECRS_URI * euri; 727 struct ECRS_URI * euri;
557 SearchList * prev; 728 SearchList * prev;
729 DownloadList * downloads;
730 GtkTreePath * path;
558 731
559 DEBUG_BEGIN(); 732 /* remove from linked list */
560 if (search_head == list) { 733 if (search_head == list) {
561 search_head = search_head->next; 734 search_head = search_head->next;
562 } else { 735 } else {
@@ -565,48 +738,53 @@ void fs_search_stopped(SearchList * list) {
565 prev = prev->next; 738 prev = prev->next;
566 prev->next = list->next; 739 prev->next = list->next;
567 } 740 }
741
742 /* remove links from download views */
743 downloads = download_head;
744 while (downloads != NULL) {
745 if (download->searchList == list) {
746 gtk_tree_row_reference_free(download->searchViewRowReference);
747 download->searchViewRowReference = NULL;
748 download->searchList = NULL;
749 }
750 downloads = downloads->next;
751 }
752
753 /* remove page from notebook */
568 notebook 754 notebook
569 = glade_xml_get_widget(getMainXML(), 755 = GTK_NOTEBOOK(glade_xml_get_widget(getMainXML(),
570 "downloadNotebook"); 756 "downloadNotebook"));
571 index = -1; 757 index = -1;
572 for (i=gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook))-1;i>=0;i--) 758 for (i=gtk_notebook_get_n_pages(notebook)-1;i>=0;i--)
573 if (list->searchpage == gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 759 if (list->searchpage == gtk_notebook_get_nth_page(notebook,
574 i)) 760 i))
575 index = i; 761 index = i;
576 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), 762 GE_BREAK(ectx, index != -1);
763 gtk_notebook_remove_page(notebook,
577 index); 764 index);
578#if 0 765
579 /* recursively free download tree */ 766 /* recursively free search model */
580 if (gtk_tree_model_get_iter_first(list->model, 767 if (gtk_tree_model_get_iter_first(list->model,
581 &iter)) 768 &iter))
582 freeIterSubtree(list->model, 769 freeIterSubtree(list->model,
583 &iter); 770 &iter);
584#endif 771
585 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(search_summary), 772 /* destroy entry in summary */
586 &iter)) { 773 path = gtk_tree_row_reference_get_path(list->summaryViewRowReference);
587 GE_BREAK(ectx, 0); 774 gtk_tree_model_get_iter(GTK_TREE_MODEL(search_summary),
588 ECRS_freeUri(list->uri); 775 &iter,
589 FREE(list); 776 path);
590 DEBUG_END(); 777 gtk_tree_path_free(path);
591 return; 778 gtk_list_store_remove(search_summary,
592 } 779 &iter);
593 do { 780
594 gtk_tree_model_get(GTK_TREE_MODEL(search_summary), 781 /* free list state itself */
595 &iter, 782 UNREF(list->searchXML);
596 SER_SUM_URI, &euri, 783 UNREF(list->labelXML);
597 -1); 784 gtk_tree_row_reference_free(list->summaryViewRowReference);
598 if (ECRS_equalsUri(euri, 785 FREE(list->searchString);
599 list->uri)) {
600 gtk_list_store_remove(GTK_LIST_STORE(search_summary),
601 &iter);
602 ECRS_freeUri(euri);
603 break;
604 }
605 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(search_summary),
606 &iter));
607 ECRS_freeUri(list->uri); 786 ECRS_freeUri(list->uri);
608 FREE(list); 787 FREE(list);
609 DEBUG_END();
610} 788}
611 789
612 790
@@ -678,12 +856,16 @@ static int addFilesToDirectory
678} 856}
679#endif 857#endif
680 858
859
681/** 860/**
682 * FIXME: somehow need way to pass 861 * A download has been started. Add an entry
683 * tree path for search into this download! 862 * to the search tree view (if applicable) and
863 * the download summary.
684 */ 864 */
685struct DL * 865struct DL *
686fs_download_started(struct FSUI_DownloadList * fsui_dl, 866fs_download_started(struct FSUI_DownloadList * fsui_dl,
867 struct DL * dl_parent,
868 struct SL * sl_parent,
687 unsigned long long total, 869 unsigned long long total,
688 unsigned int anonymityLevel, 870 unsigned int anonymityLevel,
689 const ECRS_FileInfo * fi, 871 const ECRS_FileInfo * fi,
@@ -1209,25 +1391,28 @@ void on_abortDownloadButton_clicked_fs(void * unused,
1209 1391
1210 1392
1211 1393
1394/* *************** startup/shutdown ****************** */
1212 1395
1213 1396/**
1397 * Setup the summary views (in particular the models
1398 * and the renderers).
1399 */
1214void fs_search_start(struct GE_Context * e, 1400void fs_search_start(struct GE_Context * e,
1215 struct GC_Configuration * c) { 1401 struct GC_Configuration * c) {
1216 GtkWidget * searchCB; 1402 GtkComboBoxEntry * searchCB;
1217 GtkWidget * searchList; 1403 GtkTreeView * searchList;
1404 GtkTreeView * downloadList;
1218 GtkListStore * model; 1405 GtkListStore * model;
1219 GtkCellRenderer * renderer; 1406 GtkCellRenderer * renderer;
1220 GtkTreeViewColumn * column; 1407 GtkTreeViewColumn * column;
1221 int col; 1408 int col;
1222 GtkWidget * downloadList;
1223 1409
1224 ectx = e; 1410 ectx = e;
1225 cfg = c; 1411 cfg = c;
1226 DEBUG_BEGIN();
1227 searchCB 1412 searchCB
1228 = glade_xml_get_widget(getMainXML(), 1413 = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(),
1229 "fssearchKeywordComboBoxEntry"); 1414 "fssearchKeywordComboBoxEntry"));
1230 1415
1231 model = gtk_list_store_new(NS_SEARCH_NUM, 1416 model = gtk_list_store_new(NS_SEARCH_NUM,
1232 G_TYPE_STRING, /* what we show */ 1417 G_TYPE_STRING, /* what we show */
1233 G_TYPE_STRING, /* EncName of namespace */ 1418 G_TYPE_STRING, /* EncName of namespace */
@@ -1236,54 +1421,52 @@ void fs_search_start(struct GE_Context * e,
1236 G_TYPE_INT); /* Meta-data about namespace */ 1421 G_TYPE_INT); /* Meta-data about namespace */
1237 gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB), 1422 gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB),
1238 GTK_TREE_MODEL(model)); 1423 GTK_TREE_MODEL(model));
1239 gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(searchCB), 1424 gtk_combo_box_entry_set_text_column(searchCB,
1240 NS_SEARCH_DESCRIPTION); 1425 NS_SEARCH_DESCRIPTION);
1241 searchList = glade_xml_get_widget(getMainXML(), 1426 searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(),
1242 "activeSearchesSummary"); 1427 "activeSearchesSummary"));
1243 search_summary = 1428 search_summary =
1244 gtk_list_store_new(SER_SUM_NUM, 1429 gtk_list_store_new(SER_SUM_NUM,
1245 G_TYPE_STRING, /* name */ 1430 G_TYPE_STRING, /* name */
1246 G_TYPE_INT, /* # results */ 1431 G_TYPE_INT, /* # results */
1247 G_TYPE_POINTER, /* internal: FSUI search list */ 1432 G_TYPE_POINTER); /* internal: search list */
1248 G_TYPE_POINTER); /* internal: uri */ 1433 gtk_tree_view_set_model(searchList,
1249 gtk_tree_view_set_model(GTK_TREE_VIEW(searchList),
1250 GTK_TREE_MODEL(search_summary)); 1434 GTK_TREE_MODEL(search_summary));
1435 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(searchList),
1436 GTK_SELECTION_MULTIPLE);
1437
1251 renderer = gtk_cell_renderer_text_new(); 1438 renderer = gtk_cell_renderer_text_new();
1252 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList), 1439 col = gtk_tree_view_insert_column_with_attributes(searchList,
1253 -1, 1440 -1,
1254 _("Query"), 1441 _("Query"),
1255 renderer, 1442 renderer,
1256 "text", SER_SUM_NAME, 1443 "text", SERARCH_SUMMARY_NAME,
1257 NULL); 1444 NULL);
1258 column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList), 1445 column = gtk_tree_view_get_column(searchList,
1259 col - 1); 1446 col - 1);
1260 gtk_tree_view_column_set_resizable(column, TRUE); 1447 gtk_tree_view_column_set_resizable(column, TRUE);
1261 gtk_tree_view_column_set_clickable(column, TRUE); 1448 gtk_tree_view_column_set_clickable(column, TRUE);
1262 gtk_tree_view_column_set_reorderable(column, TRUE); 1449 gtk_tree_view_column_set_reorderable(column, TRUE);
1263 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_NAME); 1450 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_NAME);
1264 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList), 1451 gtk_tree_view_column_set_resizable(column, TRUE);
1265 col - 1),
1266 TRUE);
1267 renderer = gtk_cell_renderer_text_new(); 1452 renderer = gtk_cell_renderer_text_new();
1268 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList), 1453 col = gtk_tree_view_insert_column_with_attributes(searchList,
1269 -1, 1454 -1,
1270 _("Results"), 1455 _("Results"),
1271 renderer, 1456 renderer,
1272 "text", SER_SUM_COUNT, 1457 "text", SERARCH_SUMMARY_RESULT_COUNT,
1273 NULL); 1458 NULL);
1274 column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList), 1459 column = gtk_tree_view_get_column(searchList,
1275 col - 1); 1460 col - 1);
1276 gtk_tree_view_column_set_resizable(column, TRUE); 1461 gtk_tree_view_column_set_resizable(column, TRUE);
1277 gtk_tree_view_column_set_clickable(column, TRUE); 1462 gtk_tree_view_column_set_clickable(column, TRUE);
1278 gtk_tree_view_column_set_reorderable(column, TRUE); 1463 gtk_tree_view_column_set_reorderable(column, TRUE);
1279 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_COUNT); 1464 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_COUNT);
1280 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList), 1465 gtk_tree_view_column_set_resizable(column, TRUE);
1281 col - 1),
1282 TRUE);
1283 1466
1284 1467
1285 downloadList = glade_xml_get_widget(getMainXML(), 1468 downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(),
1286 "activeDownloadsList"); 1469 "activeDownloadsList"));
1287 download_summary = 1470 download_summary =
1288 gtk_tree_store_new(DOWNLOAD_NUM, 1471 gtk_tree_store_new(DOWNLOAD_NUM,
1289 G_TYPE_STRING, /* name (full-path file name) */ 1472 G_TYPE_STRING, /* name (full-path file name) */
@@ -1291,68 +1474,73 @@ void fs_search_start(struct GE_Context * e,
1291 G_TYPE_UINT64, /* size */ 1474 G_TYPE_UINT64, /* size */
1292 G_TYPE_STRING, /* human readable size */ 1475 G_TYPE_STRING, /* human readable size */
1293 G_TYPE_INT, /* progress */ 1476 G_TYPE_INT, /* progress */
1294 G_TYPE_STRING, /* uri */ 1477 G_TYPE_STRING, /* uri as string */
1295 G_TYPE_POINTER, /* url */ 1478 G_TYPE_POINTER); /* internal download list ptr */
1296 G_TYPE_POINTER, /* internal: gtk tree path / NULL */ 1479 gtk_tree_view_set_model(downloadList,
1297 G_TYPE_POINTER); /* directory path if file is inside a dir */
1298 gtk_tree_view_set_model(GTK_TREE_VIEW(downloadList),
1299 GTK_TREE_MODEL(download_summary)); 1480 GTK_TREE_MODEL(download_summary));
1481 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(downloadList),
1482 GTK_SELECTION_MULTIPLE);
1300 renderer = gtk_cell_renderer_progress_new(); 1483 renderer = gtk_cell_renderer_progress_new();
1301 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList), 1484 col = gtk_tree_view_insert_column_with_attributes(downloadList,
1302 -1, 1485 -1,
1303 _("Name"), 1486 _("Name"),
1304 renderer, 1487 renderer,
1305 "value", DOWNLOAD_PROGRESS, 1488 "value", DOWNLOAD_PROGRESS,
1306 "text", DOWNLOAD_SHORTNAME, 1489 "text", DOWNLOAD_SHORTNAME,
1307 NULL); 1490 NULL);
1308 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 1491 column = gtk_tree_view_get_column(downloadList,
1309 col - 1); 1492 col - 1);
1310 gtk_tree_view_column_set_resizable(column, TRUE); 1493 gtk_tree_view_column_set_resizable(column, TRUE);
1311 gtk_tree_view_column_set_clickable(column, TRUE); 1494 gtk_tree_view_column_set_clickable(column, TRUE);
1312 gtk_tree_view_column_set_reorderable(column, TRUE); 1495 gtk_tree_view_column_set_reorderable(column, TRUE);
1313 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS); 1496 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS);
1314 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ 1497 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
1315 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 1498 gtk_tree_view_column_set_resizable(column, TRUE);
1316 col - 1),
1317 TRUE);
1318 renderer = gtk_cell_renderer_text_new(); 1499 renderer = gtk_cell_renderer_text_new();
1319 g_object_set (renderer, "xalign", 1.00, NULL); 1500 g_object_set (renderer, "xalign", 1.00, NULL);
1320 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList), 1501 col = gtk_tree_view_insert_column_with_attributes(downloadList,
1321 -1, 1502 -1,
1322 _("Size"), 1503 _("Size"),
1323 renderer, 1504 renderer,
1324 "text", DOWNLOAD_HSIZE, 1505 "text", DOWNLOAD_HSIZE,
1325 NULL); 1506 NULL);
1326 1507
1327 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 1508 column = gtk_tree_view_get_column(downloadList,
1328 col - 1); 1509 col - 1);
1329 gtk_tree_view_column_set_resizable(column, TRUE); 1510 gtk_tree_view_column_set_resizable(column, TRUE);
1330 gtk_tree_view_column_set_clickable(column, TRUE); 1511 gtk_tree_view_column_set_clickable(column, TRUE);
1331 gtk_tree_view_column_set_reorderable(column, TRUE); 1512 gtk_tree_view_column_set_reorderable(column, TRUE);
1332 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE); 1513 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE);
1333 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ 1514 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
1334 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 1515 gtk_tree_view_column_set_resizable(column, TRUE);
1335 col - 1),
1336 TRUE);
1337 renderer = gtk_cell_renderer_text_new(); 1516 renderer = gtk_cell_renderer_text_new();
1338 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList), 1517 col = gtk_tree_view_insert_column_with_attributes(downloadList,
1339 -1, 1518 -1,
1340 _("URI"), 1519 _("URI"),
1341 renderer, 1520 renderer,
1342 "text", DOWNLOAD_URISTRING, 1521 "text", DOWNLOAD_URISTRING,
1343 NULL); 1522 NULL);
1344 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 1523 column = gtk_tree_view_get_column(downloadList,
1345 col - 1); 1524 col - 1);
1346 gtk_tree_view_column_set_resizable(column, TRUE); 1525 gtk_tree_view_column_set_resizable(column, TRUE);
1347 gtk_tree_view_column_set_reorderable(column, TRUE); 1526 gtk_tree_view_column_set_reorderable(column, TRUE);
1348 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ 1527 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
1349 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 1528 gtk_tree_view_column_set_resizable(column, TRUE);
1350 col - 1),
1351 TRUE);
1352 DEBUG_END();
1353} 1529}
1354 1530
1531/**
1532 * Shutdown.
1533 */
1355void fs_search_stop() { 1534void fs_search_stop() {
1535 GtkComboBox * searchCB;
1536 GtkListStore * model;
1537
1538 searchCB
1539 = GTK_COMBO_BOX(glade_xml_get_widget(getMainXML(),
1540 "fssearchKeywordComboBoxEntry"));
1541 model = gtk_combo_box_get_model(searchCB);
1542 /* FIXME: iterate over model entries
1543 and free URIs and MetaData! */
1356} 1544}
1357 1545
1358 1546