diff options
author | Christian Grothoff <christian@grothoff.org> | 2006-10-29 22:40:43 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2006-10-29 22:40:43 +0000 |
commit | 75519d3ded24a8b38012716ccfa0ec784f609dd2 (patch) | |
tree | 31cfd406bf2c1db0203b45b65e0a8e8cd72cd1de | |
parent | 4e0767f1bff582de45c4fe3acdc08b9c2eaeb8dc (diff) | |
download | gnunet-gtk-75519d3ded24a8b38012716ccfa0ec784f609dd2.tar.gz gnunet-gtk-75519d3ded24a8b38012716ccfa0ec784f609dd2.zip |
updates
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | src/plugins/fs/collection.c | 8 | ||||
-rw-r--r-- | src/plugins/fs/download.c | 3 | ||||
-rw-r--r-- | src/plugins/fs/meta.c | 25 | ||||
-rw-r--r-- | src/plugins/fs/meta.h | 12 | ||||
-rw-r--r-- | src/plugins/fs/namespace.c | 12 | ||||
-rw-r--r-- | src/plugins/fs/search.c | 25 | ||||
-rw-r--r-- | src/plugins/fs/upload.c | 231 |
8 files changed, 140 insertions, 179 deletions
@@ -1,8 +1,5 @@ | |||
1 | 0.7.1: | 1 | 0.7.1: |
2 | - support new FSUI apis: [pre0] | 2 | - support new FSUI apis: [pre0] |
3 | * update UI event management for upload | ||
4 | * complete UI options processing for search and download and upload; | ||
5 | including recursive download, anonymity levels, etc. | ||
6 | * fix thread context switching: switch to GTK Thread before UI updates! | 3 | * fix thread context switching: switch to GTK Thread before UI updates! |
7 | * test, test, test! | 4 | * test, test, test! |
8 | * support abort of search/download/upload (without killing it) | 5 | * support abort of search/download/upload (without killing it) |
diff --git a/src/plugins/fs/collection.c b/src/plugins/fs/collection.c index 886ea3c1..681606a2 100644 --- a/src/plugins/fs/collection.c +++ b/src/plugins/fs/collection.c | |||
@@ -72,13 +72,9 @@ void createCollection_clicked_fs(GtkWidget * dummy1, | |||
72 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | 72 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
73 | GTK_RESPONSE_OK); | 73 | GTK_RESPONSE_OK); |
74 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { | 74 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { |
75 | nameLine | ||
76 | = glade_xml_get_widget(metaXML, | ||
77 | "collectionUpdateIntervalComboBoxEntry"); | ||
78 | nameLine | ||
79 | = gtk_bin_get_child(GTK_BIN(nameLine)); | ||
80 | updateIntervalString | 75 | updateIntervalString |
81 | = gtk_entry_get_text(GTK_ENTRY(nameLine)); | 76 | = getEntryLineValue(metaXML, |
77 | "collectionUpdateIntervalComboBoxEntry"); | ||
82 | if (0 == strcmp(_("--sporadic update--"), | 78 | if (0 == strcmp(_("--sporadic update--"), |
83 | updateIntervalString)) | 79 | updateIntervalString)) |
84 | updateInterval = ECRS_SBLOCK_UPDATE_SPORADIC; | 80 | updateInterval = ECRS_SBLOCK_UPDATE_SPORADIC; |
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index f425a3f7..b58bb5ef 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -538,7 +538,8 @@ initiateDownload(GtkTreeModel * model, | |||
538 | 538 | ||
539 | addLogEntry(_("Downloading `%s'"), idc_name); | 539 | addLogEntry(_("Downloading `%s'"), idc_name); |
540 | FSUI_startDownload(ctx, | 540 | FSUI_startDownload(ctx, |
541 | 0, /* FIXME: anonymity level */ | 541 | getSpinButtonValue(searchContext->searchXML, |
542 | "downloadAnonymitySpinButton"), | ||
542 | NO, /* FIXME: isRecursive */ | 543 | NO, /* FIXME: isRecursive */ |
543 | idc_uri, | 544 | idc_uri, |
544 | idc_meta, | 545 | idc_meta, |
diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c index 12087f30..28fa7cb1 100644 --- a/src/plugins/fs/meta.c +++ b/src/plugins/fs/meta.c | |||
@@ -464,13 +464,8 @@ int parseTimeInterval(const char * timeSpec, | |||
464 | int tryParseTimeInterval(GladeXML * xml, | 464 | int tryParseTimeInterval(GladeXML * xml, |
465 | const char * intervalComboBoxEntry, | 465 | const char * intervalComboBoxEntry, |
466 | TIME_T * interval) { | 466 | TIME_T * interval) { |
467 | GtkWidget * update; | 467 | return parseTimeInterval(getEntryLineValue(xml, |
468 | const char * timeSpec; | 468 | intervalComboBoxEntry), |
469 | |||
470 | update = glade_xml_get_widget(xml, | ||
471 | intervalComboBoxEntry); | ||
472 | timeSpec = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(update)))); | ||
473 | return parseTimeInterval(timeSpec, | ||
474 | interval); | 469 | interval); |
475 | } | 470 | } |
476 | 471 | ||
@@ -580,5 +575,21 @@ extractMainWidgetFromWindow(GladeXML * xml, | |||
580 | return ret; | 575 | return ret; |
581 | } | 576 | } |
582 | 577 | ||
578 | int getToggleButtonValue(GladeXML * xml, | ||
579 | const char * widgetName) { | ||
580 | return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, | ||
581 | widgetName))); | ||
582 | } | ||
583 | |||
584 | const char * getEntryLineValue(GladeXML * xml, | ||
585 | const char * widgetName) { | ||
586 | GtkBin * line; | ||
587 | GtkEntry * entry; | ||
588 | |||
589 | line = GTK_BIN(glade_xml_get_widget(xml, | ||
590 | widgetName)); | ||
591 | entry = GTK_ENTRY(gtk_bin_get_child(line)); | ||
592 | return gtk_entry_get_text(entry); | ||
593 | } | ||
583 | 594 | ||
584 | /* end of meta.c */ | 595 | /* end of meta.c */ |
diff --git a/src/plugins/fs/meta.h b/src/plugins/fs/meta.h index 5852d79f..860734e8 100644 --- a/src/plugins/fs/meta.h +++ b/src/plugins/fs/meta.h | |||
@@ -69,15 +69,21 @@ int tryParseTimeInterval(GladeXML * xml, | |||
69 | int parseTimeInterval(const char * frequency, | 69 | int parseTimeInterval(const char * frequency, |
70 | TIME_T * interval); | 70 | TIME_T * interval); |
71 | 71 | ||
72 | unsigned int getSpinButtonValue(GladeXML * xml, | ||
73 | const char * spinButtonName); | ||
74 | |||
75 | char * getMimeTypeFromMetaData(const struct ECRS_MetaData * meta); | 72 | char * getMimeTypeFromMetaData(const struct ECRS_MetaData * meta); |
76 | 73 | ||
77 | char * getFileNameFromMetaData(const struct ECRS_MetaData * meta); | 74 | char * getFileNameFromMetaData(const struct ECRS_MetaData * meta); |
78 | 75 | ||
79 | char * getDescriptionFromMetaData(const struct ECRS_MetaData * meta); | 76 | char * getDescriptionFromMetaData(const struct ECRS_MetaData * meta); |
80 | 77 | ||
78 | unsigned int getSpinButtonValue(GladeXML * xml, | ||
79 | const char * spinButtonName); | ||
80 | |||
81 | int getToggleButtonValue(GladeXML * xml, | ||
82 | const char * widgetName); | ||
83 | |||
84 | const char * getEntryLineValue(GladeXML * xml, | ||
85 | const char * widgetName); | ||
86 | |||
81 | GdkPixbuf * getThumbnailFromMetaData(const struct ECRS_MetaData * meta); | 87 | GdkPixbuf * getThumbnailFromMetaData(const struct ECRS_MetaData * meta); |
82 | 88 | ||
83 | GtkWidget * extractMainWidgetFromWindow(GladeXML * xml, | 89 | GtkWidget * extractMainWidgetFromWindow(GladeXML * xml, |
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c index 37e6b99f..37bfeab6 100644 --- a/src/plugins/fs/namespace.c +++ b/src/plugins/fs/namespace.c | |||
@@ -57,7 +57,6 @@ static GladeXML * metaXML; | |||
57 | 57 | ||
58 | static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, | 58 | static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, |
59 | GtkWidget ** anonSpin) { | 59 | GtkWidget ** anonSpin) { |
60 | GtkWidget * window; | ||
61 | GtkWidget * child; | 60 | GtkWidget * child; |
62 | GtkWidget * resultList; | 61 | GtkWidget * resultList; |
63 | GtkCellRenderer * renderer; | 62 | GtkCellRenderer * renderer; |
@@ -72,8 +71,8 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, | |||
72 | "namespaceContentFrame", | 71 | "namespaceContentFrame", |
73 | PACKAGE_NAME); | 72 | PACKAGE_NAME); |
74 | connectGladeWithPlugins(namespaceXML); | 73 | connectGladeWithPlugins(namespaceXML); |
75 | window = glade_xml_get_widget(namespaceXML, | 74 | child = extractMainWidgetFromWindow(namespaceXML, |
76 | "namespaceContentFrame"); | 75 | "namespaceContentFrame"); |
77 | resultList = glade_xml_get_widget(namespaceXML, | 76 | resultList = glade_xml_get_widget(namespaceXML, |
78 | "namespaceContentFrameTreeView"); | 77 | "namespaceContentFrameTreeView"); |
79 | *anonSpin = glade_xml_get_widget(namespaceXML, | 78 | *anonSpin = glade_xml_get_widget(namespaceXML, |
@@ -229,11 +228,8 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, | |||
229 | gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(resultList), | 228 | gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(resultList), |
230 | col - 1), | 229 | col - 1), |
231 | TRUE); | 230 | TRUE); |
232 | child = gtk_bin_get_child(GTK_BIN(window)); | 231 | |
233 | gtk_widget_ref(GTK_WIDGET(child)); | 232 | |
234 | gtk_container_remove(GTK_CONTAINER(window), | ||
235 | child); | ||
236 | gtk_widget_destroy(window); | ||
237 | UNREF(namespaceXML); | 233 | UNREF(namespaceXML); |
238 | DEBUG_END(); | 234 | DEBUG_END(); |
239 | 235 | ||
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index f026d07e..cb292e22 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -46,14 +46,12 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
46 | gint i; | 46 | gint i; |
47 | SearchList * list; | 47 | SearchList * list; |
48 | GtkTreeIter iter; | 48 | GtkTreeIter iter; |
49 | GtkWidget * searchKeywordGtkCB; | 49 | GtkComboBox * searchKeywordGtkCB; |
50 | GtkWidget * searchNamespaceGtkCB; | 50 | GtkWidget * searchNamespaceGtkCB; |
51 | GtkNotebook * notebook; | 51 | GtkNotebook * notebook; |
52 | 52 | ||
53 | searchKeywordGtkCB | 53 | searchString = getEntryLineValue(getMainXML(), |
54 | = glade_xml_get_widget(getMainXML(), | 54 | "fssearchKeywordComboBoxEntry"); |
55 | "fssearchKeywordComboBoxEntry"); | ||
56 | searchString = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(searchKeywordGtkCB)))); | ||
57 | if (searchString == NULL) { | 55 | if (searchString == NULL) { |
58 | GE_LOG(ectx, | 56 | GE_LOG(ectx, |
59 | GE_ERROR | GE_USER | GE_IMMEDIATE, | 57 | GE_ERROR | GE_USER | GE_IMMEDIATE, |
@@ -62,13 +60,14 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
62 | } | 60 | } |
63 | /* add the keyword to the list of keywords that have | 61 | /* add the keyword to the list of keywords that have |
64 | been used so far */ | 62 | been used so far */ |
65 | i = gtk_combo_box_get_active(GTK_COMBO_BOX(searchKeywordGtkCB)); | 63 | searchKeywordGtkCB |
64 | = GTK_COMBO_BOX(glade_xml_get_widget(getMainXML(), | ||
65 | "fssearchKeywordComboBoxEntry")); | ||
66 | i = gtk_combo_box_get_active(searchKeywordGtkCB); | ||
66 | if (i == -1) { | 67 | if (i == -1) { |
67 | GtkListStore * model; | 68 | GtkListStore * model; |
68 | 69 | ||
69 | model = GTK_LIST_STORE | 70 | model = GTK_LIST_STORE(gtk_combo_box_get_model(searchKeywordGtkCB)); |
70 | (gtk_combo_box_get_model | ||
71 | (GTK_COMBO_BOX(searchKeywordGtkCB))); | ||
72 | gtk_list_store_prepend(model, | 71 | gtk_list_store_prepend(model, |
73 | &iter); | 72 | &iter); |
74 | gtk_list_store_set(model, | 73 | gtk_list_store_set(model, |
@@ -608,6 +607,14 @@ static void freeIterSubtree(GtkTreeModel * tree, | |||
608 | } | 607 | } |
609 | 608 | ||
610 | /** | 609 | /** |
610 | * FSUI event: a search was aborted. | ||
611 | * Update views accordingly. | ||
612 | */ | ||
613 | void fs_search_aborted(SearchList * list) { | ||
614 | /* FIXME: show aborted status somehow! */ | ||
615 | } | ||
616 | |||
617 | /** | ||
611 | * FSUI event: a search was stopped. Remove the | 618 | * FSUI event: a search was stopped. Remove the |
612 | * respective tab and its entry in the summary. | 619 | * respective tab and its entry in the summary. |
613 | */ | 620 | */ |
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c index b4bf68cb..500830ba 100644 --- a/src/plugins/fs/upload.c +++ b/src/plugins/fs/upload.c | |||
@@ -186,7 +186,7 @@ fs_upload_started(struct FSUI_UploadList * fsui, | |||
186 | return ret; | 186 | return ret; |
187 | } | 187 | } |
188 | 188 | ||
189 | /* *************** Glade UI event handling ************** */ | 189 | /* *************** user upload event handling ************** */ |
190 | 190 | ||
191 | 191 | ||
192 | void on_selectAlternativePreviewButton_selection_changed_fs(GtkWidget * preview, | 192 | void on_selectAlternativePreviewButton_selection_changed_fs(GtkWidget * preview, |
@@ -224,50 +224,17 @@ void on_metaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy, | |||
224 | "metaDataDialogMetaDataList"); | 224 | "metaDataDialogMetaDataList"); |
225 | } | 225 | } |
226 | 226 | ||
227 | typedef struct { | ||
228 | int anon; | ||
229 | int doRec; | ||
230 | int doIndex; | ||
231 | int deepIndex; | ||
232 | const char * filename; | ||
233 | struct ECRS_URI * keywordURI; | ||
234 | struct ECRS_URI * gkeywordURI; | ||
235 | struct ECRS_MetaData * meta; | ||
236 | struct FSUI_UploadList * fsui_list; // FIXME: use this! | ||
237 | } UploadClosure; | ||
238 | |||
239 | static void * doUpload(void * cls) { | ||
240 | UploadClosure * uc = cls; | ||
241 | |||
242 | uc->fsui_list = FSUI_startUpload(ctx, | ||
243 | uc->filename, | ||
244 | (DirectoryScanCallback) &disk_directory_scan, | ||
245 | ectx, | ||
246 | uc->anon, | ||
247 | 1000, /* FIXME: priority */ | ||
248 | uc->doIndex, | ||
249 | YES, /* FIXME: do extract */ | ||
250 | uc->deepIndex, | ||
251 | uc->meta, | ||
252 | uc->gkeywordURI, | ||
253 | uc->keywordURI); | ||
254 | return NULL; | ||
255 | } | ||
256 | |||
257 | void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | 227 | void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, |
258 | GtkWidget * uploadButton) { | 228 | GtkWidget * uploadButton) { |
259 | UploadClosure uc; | ||
260 | const char * filenamerest; | 229 | const char * filenamerest; |
261 | GtkWidget * uploadLine; | 230 | const char * filename; |
262 | GtkWidget * entry; | ||
263 | GtkWidget * dialog; | 231 | GtkWidget * dialog; |
264 | GtkWidget * recBut; | ||
265 | GtkWidget * idxBut; | ||
266 | GtkWidget * deepIndex; | ||
267 | EXTRACTOR_ExtractorList * extractors; | 232 | EXTRACTOR_ExtractorList * extractors; |
268 | char * config; | 233 | char * config; |
234 | struct ECRS_URI * keywordURI; | ||
235 | struct ECRS_URI * gkeywordURI; | ||
236 | struct ECRS_MetaData * meta; | ||
269 | 237 | ||
270 | DEBUG_BEGIN(); | ||
271 | extractors = EXTRACTOR_loadDefaultLibraries(); | 238 | extractors = EXTRACTOR_loadDefaultLibraries(); |
272 | config = NULL; | 239 | config = NULL; |
273 | GC_get_configuration_value_string(cfg, | 240 | GC_get_configuration_value_string(cfg, |
@@ -281,10 +248,8 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | |||
281 | FREE(config); | 248 | FREE(config); |
282 | } | 249 | } |
283 | 250 | ||
284 | uploadLine = glade_xml_get_widget(getMainXML(), | 251 | filename = getEntryLineValue(getMainXML(), |
285 | "uploadFilenameComboBoxEntry"); | 252 | "uploadFilenameComboBoxEntry"); |
286 | entry = gtk_bin_get_child(GTK_BIN(uploadLine)); | ||
287 | uc.filename = gtk_entry_get_text(GTK_ENTRY(entry)); | ||
288 | metaXML | 253 | metaXML |
289 | = glade_xml_new(getGladeFileName(), | 254 | = glade_xml_new(getGladeFileName(), |
290 | "metaDataDialog", | 255 | "metaDataDialog", |
@@ -292,155 +257,137 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | |||
292 | connectGladeWithPlugins(metaXML); | 257 | connectGladeWithPlugins(metaXML); |
293 | dialog = glade_xml_get_widget(metaXML, | 258 | dialog = glade_xml_get_widget(metaXML, |
294 | "metaDataDialog"); | 259 | "metaDataDialog"); |
295 | uc.meta = ECRS_createMetaData(); | 260 | meta = ECRS_createMetaData(); |
296 | ECRS_extractMetaData(ectx, | 261 | ECRS_extractMetaData(ectx, |
297 | uc.meta, | 262 | meta, |
298 | uc.filename, | 263 | filename, |
299 | extractors); | 264 | extractors); |
300 | EXTRACTOR_removeAll(extractors); | 265 | EXTRACTOR_removeAll(extractors); |
301 | filenamerest = &uc.filename[strlen(uc.filename)-1]; | 266 | filenamerest = &filename[strlen(filename)-1]; |
302 | while ( (filenamerest > uc.filename) && | 267 | while ( (filenamerest > filename) && |
303 | (filenamerest[-1] != DIR_SEPARATOR) ) | 268 | (filenamerest[-1] != DIR_SEPARATOR) ) |
304 | filenamerest--; | 269 | filenamerest--; |
305 | ECRS_addToMetaData(uc.meta, | 270 | ECRS_addToMetaData(meta, |
306 | EXTRACTOR_FILENAME, | 271 | EXTRACTOR_FILENAME, |
307 | filenamerest); | 272 | filenamerest); |
308 | createMetaDataListTreeView(metaXML, | 273 | createMetaDataListTreeView(metaXML, |
309 | "metaDataDialogMetaDataList", | 274 | "metaDataDialogMetaDataList", |
310 | "previewImage", | 275 | "previewImage", |
311 | uc.meta); | 276 | meta); |
312 | uc.keywordURI = ECRS_metaDataToUri(uc.meta); | 277 | keywordURI = ECRS_metaDataToUri(meta); |
313 | ECRS_freeMetaData(uc.meta); | 278 | ECRS_freeMetaData(meta); |
314 | createKeywordListTreeView(metaXML, | 279 | createKeywordListTreeView(metaXML, |
315 | "metaDataDialogKeywordList", | 280 | "metaDataDialogKeywordList", |
316 | uc.keywordURI); | 281 | keywordURI); |
317 | ECRS_freeUri(uc.keywordURI); | 282 | ECRS_freeUri(keywordURI); |
318 | createMetaTypeComboBox(metaXML, | 283 | createMetaTypeComboBox(metaXML, |
319 | "metaDataDialogMetaTypeComboBox"); | 284 | "metaDataDialogMetaTypeComboBox"); |
320 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | 285 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
321 | GTK_RESPONSE_OK); | 286 | GTK_RESPONSE_OK); |
322 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) { | 287 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) { |
323 | addLogEntry(_("Uploading `%s'"), filenamerest); | 288 | meta = getMetaDataFromList(metaXML, |
324 | 289 | "metaDataDialogMetaDataList", | |
325 | recBut = glade_xml_get_widget(getMainXML(), | 290 | "previewImage"); |
326 | "scopeRecursiveButton"); | 291 | keywordURI = getKeywordURIFromList(metaXML, |
327 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(recBut))) | 292 | "metaDataDialogKeywordList"); |
328 | uc.doRec = YES; | 293 | gkeywordURI = ECRS_stringToUri(ectx, |
329 | else | 294 | ECRS_URI_PREFIX |
330 | uc.doRec = NO; | 295 | ECRS_SEARCH_INFIX); |
331 | idxBut = glade_xml_get_widget(getMainXML(), | 296 | FSUI_startUpload(ctx, |
332 | "indexbutton"); | 297 | filename, |
333 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(idxBut))) | 298 | (DirectoryScanCallback) &disk_directory_scan, |
334 | uc.doIndex = YES; | 299 | ectx, |
335 | else | 300 | getSpinButtonValue(getMainXML(), |
336 | uc.doIndex = NO; | 301 | "uploadAnonymityLevelSpinButton"), |
337 | 302 | getSpinButtonValue(getMainXML(), | |
338 | uc.meta = getMetaDataFromList(metaXML, | 303 | "contentPrioritySpinButton"), |
339 | "metaDataDialogMetaDataList", | 304 | getToggleButtonValue(getMainXML(), |
340 | "previewImage"); | 305 | "indexbutton"), |
341 | uc.keywordURI = getKeywordURIFromList(metaXML, | 306 | getToggleButtonValue(getMainXML(), |
342 | "metaDataDialogKeywordList"); | 307 | "doExtractCheckButton"), |
343 | uc.anon = getSpinButtonValue(getMainXML(), | 308 | getToggleButtonValue(getMainXML(), |
344 | "uploadAnonymityLevelSpinButton"); | 309 | "deepIndexCheckButton"), |
345 | deepIndex = glade_xml_get_widget(getMainXML(), | 310 | meta, |
346 | "deepIndexCheckButton"); | 311 | gkeywordURI, |
347 | uc.deepIndex = (TRUE == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(deepIndex))) ? YES : NO; | 312 | keywordURI); |
348 | uc.gkeywordURI = ECRS_stringToUri(ectx, | 313 | ECRS_freeMetaData(meta); |
349 | ECRS_URI_PREFIX | 314 | ECRS_freeUri(gkeywordURI); |
350 | ECRS_SEARCH_INFIX); | 315 | ECRS_freeUri(keywordURI); |
351 | run_with_save_calls(&doUpload, | ||
352 | &uc); | ||
353 | ECRS_freeMetaData(uc.meta); | ||
354 | ECRS_freeUri(uc.gkeywordURI); | ||
355 | ECRS_freeUri(uc.keywordURI); | ||
356 | } | 316 | } |
357 | gtk_widget_destroy (dialog); | 317 | gtk_widget_destroy (dialog); |
358 | UNREF(metaXML); | 318 | UNREF(metaXML); |
359 | metaXML = NULL; | 319 | metaXML = NULL; |
360 | DEBUG_END(); | ||
361 | } | 320 | } |
362 | 321 | ||
363 | static char * selectFile(const char *oldfilename) { | ||
364 | #ifndef MINGW | 322 | #ifndef MINGW |
365 | GtkWidget *dialog; | 323 | |
324 | static char * | ||
325 | selectFile(const char * oldfilename) { | ||
366 | GladeXML * uploadXML; | 326 | GladeXML * uploadXML; |
367 | GtkWidget * recBut; | 327 | GtkFileChooser * dialog; |
368 | char *ret; | 328 | char * ret; |
369 | 329 | ||
370 | uploadXML | 330 | uploadXML |
371 | = glade_xml_new(getGladeFileName(), | 331 | = glade_xml_new(getGladeFileName(), |
372 | "uploadfilechooserdialog", | 332 | "uploadfilechooserdialog", |
373 | PACKAGE_NAME); | 333 | PACKAGE_NAME); |
374 | connectGladeWithPlugins(uploadXML); | 334 | connectGladeWithPlugins(uploadXML); |
375 | dialog = glade_xml_get_widget(uploadXML, | 335 | dialog = GTK_FILE_CHOOSER(glade_xml_get_widget(uploadXML, |
376 | "uploadfilechooserdialog"); | 336 | "uploadfilechooserdialog")); |
377 | 337 | gtk_file_chooser_set_filename(dialog, | |
378 | recBut = glade_xml_get_widget(getMainXML(), | 338 | oldfilename); |
379 | "scopeRecursiveButton"); | 339 | if (getToggleButtonValue(getMainXML(), |
380 | 340 | "scopeRecursiveButton")) | |
381 | /* show the user last used dir */ | 341 | gtk_file_chooser_set_action(dialog, |
382 | gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | ||
383 | oldfilename); | ||
384 | |||
385 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(recBut))) | ||
386 | gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog), | ||
387 | GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); | 342 | GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); |
388 | 343 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) | |
389 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) { | 344 | ret = gtk_file_chooser_get_filename(dialog); |
390 | char * filename; | 345 | else |
391 | |||
392 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | ||
393 | ret = STRDUP(filename); | ||
394 | g_free(filename); | ||
395 | } else | ||
396 | ret = NULL; | 346 | ret = NULL; |
397 | 347 | gtk_widget_destroy(GTK_WIDGET(dialog)); | |
398 | gtk_widget_destroy (dialog); | ||
399 | UNREF(uploadXML); | 348 | UNREF(uploadXML); |
400 | return ret; | 349 | return ret; |
350 | } | ||
351 | |||
401 | #else /* MINGW */ | 352 | #else /* MINGW */ |
402 | GtkWidget *fileBut; | ||
403 | char *fn; | ||
404 | |||
405 | fileBut = glade_xml_get_widget(getMainXML(), | ||
406 | "scopeFileOnlyButton"); | ||
407 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fileBut))) | ||
408 | fn = plibc_ChooseFile(_("Choose the file you want to publish."), | ||
409 | OFN_FILEMUSTEXIST | OFN_SHAREAWARE); | ||
410 | else | ||
411 | fn = plibc_ChooseDir(_("Choose the directory you want to publish."), | ||
412 | BIF_USENEWUI | BIF_SHAREABLE | BIF_NONEWFOLDERBUTTON); | ||
413 | 353 | ||
414 | return fn; | 354 | static char * |
415 | #endif /* MINGW */ | 355 | selectFile(const char * oldfilename) { |
356 | if (getToggleButtonValue(getMainXML(), | ||
357 | "scopeFileOnlyButton")) | ||
358 | return plibc_ChooseFile(_("Choose the file you want to publish."), | ||
359 | OFN_FILEMUSTEXIST | OFN_SHAREAWARE); | ||
360 | return plibc_ChooseDir(_("Choose the directory you want to publish."), | ||
361 | BIF_USENEWUI | BIF_SHAREABLE | BIF_NONEWFOLDERBUTTON); | ||
416 | } | 362 | } |
363 | #endif /* MINGW */ | ||
417 | 364 | ||
418 | void on_mainFileSharingInsertBrowseButton_clicked_fs(GtkWidget * browseButton, | 365 | void on_mainFileSharingInsertBrowseButton_clicked_fs(GtkWidget * browseButton, |
419 | gpointer dummy) { | 366 | gpointer dummy) { |
420 | char * filename; | 367 | char * filename; |
421 | const char *oldfilename; | 368 | const char *oldfilename; |
422 | GtkWidget * uploadLine; | 369 | GtkWidget * uploadLine; |
423 | GtkWidget * entry; | 370 | GtkEntry * entry; |
424 | GtkListStore * model; | 371 | GtkListStore * model; |
425 | GtkTreeIter iter; | 372 | GtkTreeIter iter; |
426 | 373 | ||
427 | uploadLine = glade_xml_get_widget(getMainXML(), | 374 | uploadLine = glade_xml_get_widget(getMainXML(), |
428 | "uploadFilenameComboBoxEntry"); | 375 | "uploadFilenameComboBoxEntry"); |
429 | entry = gtk_bin_get_child(GTK_BIN(uploadLine)); | 376 | entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(uploadLine))); |
430 | oldfilename = gtk_entry_get_text(GTK_ENTRY(entry)); | 377 | oldfilename = gtk_entry_get_text(entry); |
431 | if ((filename = selectFile(oldfilename))) { | 378 | if (NULL == (filename = selectFile(oldfilename))) |
432 | gtk_entry_set_text(GTK_ENTRY(entry), | 379 | return; |
433 | filename); | 380 | gtk_entry_set_text(entry, |
434 | model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(uploadLine))); | 381 | filename); |
435 | gtk_list_store_prepend(model, | 382 | model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(uploadLine))); |
436 | &iter); | 383 | gtk_list_store_prepend(model, |
437 | gtk_list_store_set(model, | 384 | &iter); |
438 | &iter, | 385 | gtk_list_store_set(model, |
439 | 0, | 386 | &iter, |
440 | filename, | 387 | 0, |
441 | -1); | 388 | filename, |
442 | free(filename); | 389 | -1); |
443 | } | 390 | free(filename); |
444 | } | 391 | } |
445 | 392 | ||
446 | /* end of upload.c */ | 393 | /* end of upload.c */ |