From 5cee32568cadd66e8608afafca6c699310601e7b Mon Sep 17 00:00:00 2001 From: Harbour Date: Sat, 3 May 2008 22:05:46 +0300 Subject: [PATCH] Search can open File URL's in mozilla/djview/xpdf/xchm --- faraon/faraon.C | 13 ++++++++----- faraon/smenu.H | 21 ++++++++++++++++----- faraon/x11_ui.C | 33 +++++++++++++++++++++++++++------ faraon/x11_ui.H | 8 ++++++-- faraon/x11_ui.fl | 46 +++++++++++++++++++++++++++++++++------------- include/faraon.H | 18 ++++++++++++++++++ sfinx/Makefile | 7 ++++--- 7 files changed, 112 insertions(+), 34 deletions(-) diff --git a/faraon/faraon.C b/faraon/faraon.C index 68a5f2e..2278269 100644 --- a/faraon/faraon.C +++ b/faraon/faraon.C @@ -210,6 +210,8 @@ void faraon_app::prepare_search_info(sfinx_t *el, string &inf) sfinx_file_t *f; sfinx_slice_t *s; sfinx_note_t *n; + string dir; + files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, dir); switch (el->tid()) { case SFINX_ELEMENT_SLICE: s = (sfinx_slice_t *)el; @@ -233,7 +235,8 @@ void faraon_app::prepare_search_info(sfinx_t *el, string &inf) case SFINX_ELEMENT_FILE: f = (sfinx_file_t *)el; inf = "\nType: File\n"; - inf.append("Name: " + f->name + "\n"); + inf.append("Title: " + f->title + "\n"); + inf.append("URL: " + dir + slice_hierarchy_path(f->mtag.slice_id) + "/" + f->name + "\n"); inf.append("Slice Hierarchy: " + app->slice_hierarchy(f->mtag.slice_id) + "\n"); if (f->tags.size()) { inf.append("Additional Tags : "); @@ -244,7 +247,6 @@ void faraon_app::prepare_search_info(sfinx_t *el, string &inf) } inf.append("\n"); } - inf.append("Title: " + f->title + "\n"); inf.append("Authority: " + f->authority + "\n"); inf.append("Description: " + f->description + "\n"); inf.append("Comments: " + f->comments + "\n"); @@ -254,11 +256,12 @@ void faraon_app::prepare_search_info(sfinx_t *el, string &inf) inf.append(buf); if (f->csum.size()) inf.append("Csum: " + f->csum + "\n"); - sprintf(buf, "%llu bytes\n", f->compressed_fsize); + if (f->compressed_csum.size()) { inf.append("Compressed Size: "); + sprintf(buf, "%llu bytes\n", f->compressed_fsize); inf.append(buf); - if (f->compressed_csum.size()) - inf.append("Compressed Csum: " + f->compressed_csum + "\n"); + inf.append("Compressed Csum: " + f->compressed_csum + "\n"); + } inf.append("Create Entry Time: " + time2str(f->ctime)); inf.append("Edit Entry Time: " + time2str(f->etime)); inf.append("\n"); diff --git a/faraon/smenu.H b/faraon/smenu.H index 4ce5a10..10a75b9 100644 --- a/faraon/smenu.H +++ b/faraon/smenu.H @@ -14,8 +14,12 @@ extern Fl_Browser *search_browser_br; extern Fl_Menu_Item menu_search_menu[]; -#define open_link_mi (menu_search_menu+0) -#define copy_link_mi (menu_search_menu+1) +#define open_link_mozilla_mi (menu_search_menu+0) +#define open_link_evince_mi (menu_search_menu+1) +#define open_link_djview_mi (menu_search_menu+2) +#define open_link_xpdf_mi (menu_search_menu+3) +#define open_link_xchm_mi (menu_search_menu+4) +#define copy_link_mi (menu_search_menu+5) class Search_Menu_Button : public Fl_Menu_Button { @@ -31,12 +35,19 @@ class Search_Menu_Button : public Fl_Menu_Button { return 0; // url if (strstr(search_browser_br->text(line), "URL")) { // url - open_link_mi->activate(); - open_link_mi->label("Open Link"); + open_link_mozilla_mi->activate(); + open_link_evince_mi->activate(); + open_link_djview_mi->activate(); + open_link_xpdf_mi->activate(); + open_link_xchm_mi->activate(); copy_link_mi->label("Copy Link"); return Fl_Menu_Button::handle(e); } else { // ordinary text - open_link_mi->deactivate(); + open_link_mozilla_mi->deactivate(); + open_link_evince_mi->deactivate(); + open_link_djview_mi->deactivate(); + open_link_xpdf_mi->deactivate(); + open_link_xchm_mi->deactivate(); copy_link_mi->label("Copy Text"); return Fl_Menu_Button::handle(e); diff --git a/faraon/x11_ui.C b/faraon/x11_ui.C index 7c80345..d0f9a11 100644 --- a/faraon/x11_ui.C +++ b/faraon/x11_ui.C @@ -287,7 +287,8 @@ static void search_menu_cb(Fl_Widget *, void *d) { const char *url = search_browser_br->text(search_browser_br->value()); url = strstr(url, ": ") + 2; if (d) { - string cmd = "mozilla "; + string cmd = (char *) d; + cmd += " "; cmd += url; cmd += " &"; system(cmd.c_str()); @@ -1161,8 +1162,24 @@ Fl_Choice *goto_page_ch=(Fl_Choice *)0; Search_Menu_Button *search_menu=(Search_Menu_Button *)0; -static void cb_open_link_mi(Fl_Menu_*, void*) { - search_menu_cb(0, (void *)1); +static void cb_open_link_mozilla_mi(Fl_Menu_*, void*) { + search_menu_cb(0, (void *)"mozilla"); +} + +static void cb_open_link_evince_mi(Fl_Menu_*, void*) { + search_menu_cb(0, (void *)"evince"); +} + +static void cb_open_link_djview_mi(Fl_Menu_*, void*) { + search_menu_cb(0, (void *)"djview"); +} + +static void cb_open_link_xpdf_mi(Fl_Menu_*, void*) { + search_menu_cb(0, (void *)"xpdf"); +} + +static void cb_open_link_xchm_mi(Fl_Menu_*, void*) { + search_menu_cb(0, (void *)"xchm"); } static void cb_copy_link_mi(Fl_Menu_*, void*) { @@ -1170,7 +1187,11 @@ static void cb_copy_link_mi(Fl_Menu_*, void*) { } Fl_Menu_Item menu_search_menu[] = { - {gettext("Open Link"), 0, (Fl_Callback*)cb_open_link_mi, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, + {gettext("Open Link in Mozilla"), 0, (Fl_Callback*)cb_open_link_mozilla_mi, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, + {gettext("Open Link in Evince"), 0, (Fl_Callback*)cb_open_link_evince_mi, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, + {gettext("Open Link in DJView"), 0, (Fl_Callback*)cb_open_link_djview_mi, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, + {gettext("Open Link in XPDF"), 0, (Fl_Callback*)cb_open_link_xpdf_mi, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, + {gettext("Open Link in XCHM"), 0, (Fl_Callback*)cb_open_link_xchm_mi, 0, 0, FL_NORMAL_LABEL, 0, 14, 0}, {gettext("Copy Link"), 0, (Fl_Callback*)cb_copy_link_mi, (void*)(0), 0, FL_NORMAL_LABEL, 0, 14, 0}, {0,0,0,0,0,0,0,0,0} }; @@ -3784,7 +3805,7 @@ sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec); string path; app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); -string t = "URL: " + path + current_file.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; +string t = "URL: " + path + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; classify_file_to->value(t.c_str()); file_title_i->value(file.title.c_str()); file_name_i->value(file.name.c_str()); @@ -3995,7 +4016,7 @@ for (u32_t i = 0; i < tree.files.size(); i++) { files_module_tree_br->redraw(); string root; app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root); -sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_file.name.c_str()).c_str(), files, (files == 1) ? "" : "s", dirs, +sprintf(buf, "Path: %s | Total %d file%s and %d director%s", root.c_str(), files, (files == 1) ? "" : "s", dirs, (dirs == 1) ? "y" : "ies"); files_module_status_to->value(buf); files_module_status_to->redraw(); diff --git a/faraon/x11_ui.H b/faraon/x11_ui.H index 90fa7ca..82af83a 100644 --- a/faraon/x11_ui.H +++ b/faraon/x11_ui.H @@ -112,6 +112,10 @@ extern Fl_Menu_Item menu_data_deletion_type_ch[]; extern Fl_Menu_Item menu_note_secured_ch[]; extern Fl_Menu_Item menu_note_deletion_type_ch[]; extern Fl_Menu_Item menu_search_menu[]; -#define open_link_mi (menu_search_menu+0) -#define copy_link_mi (menu_search_menu+1) +#define open_link_mozilla_mi (menu_search_menu+0) +#define open_link_evince_mi (menu_search_menu+1) +#define open_link_djview_mi (menu_search_menu+2) +#define open_link_xpdf_mi (menu_search_menu+3) +#define open_link_xchm_mi (menu_search_menu+4) +#define copy_link_mi (menu_search_menu+5) #endif diff --git a/faraon/x11_ui.fl b/faraon/x11_ui.fl index eb19b8c..43424c6 100644 --- a/faraon/x11_ui.fl +++ b/faraon/x11_ui.fl @@ -344,12 +344,13 @@ config_tree->callback(config_tree_cb); config_tree->edit_on_reselect(0);} {} } -Function {search_menu_cb(Fl_Widget *, void *d)} {private return_type void +Function {search_menu_cb(Fl_Widget *, void *d)} {open private return_type void } { code {const char *url = search_browser_br->text(search_browser_br->value()); url = strstr(url, ": ") + 2; if (d) { - string cmd = "mozilla "; + string cmd = (char *) d; + cmd += " "; cmd += url; cmd += " &"; system(cmd.c_str()); @@ -948,7 +949,7 @@ fill_objects_tree(slices_tree, 1 << SFINX_SLICE_OBJECT, 0, 1); // force refresh} } } Fl_Window files_module_w { - label {Files Module} + label {Files Module} open xywh {87 152 730 370} type Double color 31 hide } { Fl_Button {} { @@ -1474,7 +1475,7 @@ fill_objects_tree(notes_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_NOTE_OBJEC } } Fl_Window search_browser_w { - label {Search Browser} + label {Search Browser} open xywh {71 48 854 476} type Double color 31 hide resizable modal } { Fl_Button {} { @@ -1502,9 +1503,29 @@ fill_objects_tree(notes_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_NOTE_OBJEC xywh {6 6 842 434} type popup23 box NO_BOX class Search_Menu_Button } { - MenuItem open_link_mi { - label {Open Link} - callback {search_menu_cb(0, (void *)1);} + MenuItem open_link_mozilla_mi { + label {Open Link in Mozilla} + callback {search_menu_cb(0, (void *)"mozilla");} + xywh {0 0 37 21} + } + MenuItem open_link_evince_mi { + label {Open Link in Evince} + callback {search_menu_cb(0, (void *)"evince");} selected + xywh {0 0 37 21} + } + MenuItem open_link_djview_mi { + label {Open Link in DJView} + callback {search_menu_cb(0, (void *)"djview");} + xywh {0 0 37 21} + } + MenuItem open_link_xpdf_mi { + label {Open Link in XPDF} + callback {search_menu_cb(0, (void *)"xpdf");} + xywh {0 0 37 21} + } + MenuItem open_link_xchm_mi { + label {Open Link in XCHM} + callback {search_menu_cb(0, (void *)"xchm");} xywh {0 0 37 21} } MenuItem copy_link_mi { @@ -1758,7 +1779,7 @@ if (classify_error->size() == 1) { Fl::unlock();} {} } -Function {x11_ui::files_module_edit(sfinx_file_t *f)} {return_type void +Function {x11_ui::files_module_edit(sfinx_file_t *f)} {open return_type void } { code {Fl::lock(); static sfinx_file_t file; @@ -1773,7 +1794,7 @@ sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec); string path; app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); -string t = "URL: " + path + current_file.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; +string t = "URL: " + path + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; classify_file_to->value(t.c_str()); file_title_i->value(file.title.c_str()); file_name_i->value(file.name.c_str()); @@ -1946,11 +1967,10 @@ tree->resize(tree->x(), tree->y(), width > tree_scroll->w() ? width : tree_scrol //node = slices_tree->find(to_voidp(current_slice_id)); //if (node) // slices_tree->select_range(node, node); -Fl::unlock();} {selected - } +Fl::unlock();} {} } -Function {x11_ui::fill_unsorted_files_tree(sfinx_files_vector_t *tree_)} {return_type void +Function {x11_ui::fill_unsorted_files_tree(sfinx_files_vector_t *tree_)} {open return_type void } { code {Fl::lock(); static sfinx_files_vector_t tree; @@ -1988,7 +2008,7 @@ for (u32_t i = 0; i < tree.files.size(); i++) { files_module_tree_br->redraw(); string root; app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root); -sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_file.name.c_str()).c_str(), files, (files == 1) ? "" : "s", dirs, +sprintf(buf, "Path: %s | Total %d file%s and %d director%s", root.c_str(), files, (files == 1) ? "" : "s", dirs, (dirs == 1) ? "y" : "ies"); files_module_status_to->value(buf); files_module_status_to->redraw(); diff --git a/include/faraon.H b/include/faraon.H index ef58941..1c70dd6 100644 --- a/include/faraon.H +++ b/include/faraon.H @@ -141,6 +141,24 @@ class faraon_app : public F_App { } return res; } + string slice_hierarchy_path(sfinx_id_t sid) { + vector h; + sfinx_slice_t *slice; + do { + slice = slices.find(sid); + if (!slice) + break; + h.push_back("/" + slice->directory_); + sid = slice->parent_id; + } while (sid != 1); + string res; + if (h.size()) { + for (int32_t i = h.size() - 1; i >= 0; i--) { + res.append(h[i]); + } + } + return res; + } }; extern faraon_app *app; diff --git a/sfinx/Makefile b/sfinx/Makefile index 999e45e..4cb3e13 100644 --- a/sfinx/Makefile +++ b/sfinx/Makefile @@ -11,9 +11,10 @@ CFLAGS = $(OPTIMIZE) $(PROFILE) $(DEBUG) -Werror -Wall -D_REENTRANT \ -D_GNU_SOURCE -D_THREAD_SAFE $(INCLUDES) LDFLAGS = $(LDFLAG) $(PROFILE) LIBS = -Wl,--start-group -L$(FIREBIRD_LIBS) -lfbembed -L$(IBPP_LIBS) -libpp \ - -L$(FORMS_LIBS) -lf -L$(FLTK_LIBS) -lfltk -L$(COMMONCPP_LIBS) \ - -L../lib -lsfinx -lccgnu2 -lccext2 -lxml2 -lpthread -lssl -ldl \ - -lz -lgpm -liberty -lmagic -lgcrypt -Wl,--end-group + -L$(FORMS_LIBS) -lf -L$(FLTK_LIBS) -lfltk-utf8 -lfltk_xutf8 \ + -L$(COMMONCPP_LIBS) -L../lib -lsfinx -lccgnu2 -lccext2 \ + -lxml2 -lpthread -lssl -ldl -lz -lgpm -liberty -lmagic \ + -lgcrypt -Wl,--end-group # -Wl,--export-dynamic OBJS = sfinx.o batch_ui.o -- 2.11.4.GIT