gint _check_for_distribution_license(gchar *mod_name) { gchar *distributionlicense; gchar *conf_file; conf_file = g_strdup_printf("%s/" DOTSWORD "/mods.d/%s.conf", settings.homedir, g_utf8_strdown(mod_name, -1)); if (g_file_test(conf_file, G_FILE_TEST_EXISTS)) distributionlicense = get_conf_file_item(conf_file, mod_name, "DistributionLicense"); else distributionlicense = main_get_mod_config_entry(mod_name, "DistributionLicense"); g_free(conf_file); XI_message(("DistributionLicense: %s", distributionlicense)); if (!distributionlicense || (distributionlicense && g_strstr_len(distributionlicense, strlen(distributionlicense), "Copyright"))) { if (main_get_one_option(mod_name, OP_NAME) == 0) { gui_generic_warning(_("Please check copyright before exporting!")); main_save_module_options(mod_name, OP_NAME, 1); } return 1; } return 0; }
G_MODULE_EXPORT void on_send_list_via_biblesync_activate(GtkMenuItem *menuitem, gpointer user_data) { if (biblesync_active_xmit_allowed()) { GList *verse; GString *vlist = g_string_new(""); gboolean first = TRUE; for (verse = list_of_verses; verse; verse = g_list_next(verse)) { RESULTS *item = (RESULTS *)verse->data; if (!first) { vlist = g_string_append_c(vlist, ';'); } vlist = g_string_append(vlist, (char *) main_get_osisref_from_key(settings.MainWindowModule, item->key)); first = FALSE; } biblesync_transmit_verse_list(settings.MainWindowModule, vlist->str); g_string_free(vlist, TRUE); } else { gui_generic_warning(_("BibleSync is not active for transmit.")); } }
/****************************************************************************** * Name * gui_open_passage_in_new_tab * * Synopsis * #include "tabbed_browser.h" * * void gui_open_passage_in_new_tab(gchar *verse_key) * * Description * opens the given verse in a new passage tab * * Return value * void */ void gui_open_passage_in_new_tab(gchar *verse_key) { PASSAGE_TAB_INFO *pt; if (stop_refresh) return; if (!settings.browsing) return; if ((pt = g_new0(PASSAGE_TAB_INFO, 1)) == NULL) { gui_generic_warning("Could not allocate a new tab"); return; } pt->text_mod = g_strdup(settings.MainWindowModule); pt->commentary_mod = g_strdup(settings.CommWindowModule); pt->dictlex_mod = g_strdup(settings.DictWindowModule); pt->book_mod = g_strdup(settings.book_mod); pt->paratab = NULL; pt->text_commentary_key = g_strdup(verse_key); pt->dictlex_key = g_strdup(settings.dictkey); pt->book_offset = g_strdup_printf("%ld", settings.book_offset); pt->comm_showing = settings.comm_showing; if (cur_passage_tab && cur_passage_tab->showparallel) { pt->showtexts = 1; pt->showcomms = 1; pt->showdicts = 1; } else { pt->showtexts = settings.showtexts; pt->showcomms = settings.showcomms; pt->showdicts = settings.showdicts; } pt->showpreview = settings.showpreview; pt->showparallel = FALSE; pt->history_items = 0; pt->current_history_item = 0; pt->first_back_click = TRUE; main_add_tab_history_item((PASSAGE_TAB_INFO *)pt); passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO *)pt); //set_current_tab(pt); notebook_main_add_page(pt); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main), gtk_notebook_page_num(GTK_NOTEBOOK(widgets.notebook_main), pt->page_widget)); }
void gui_open_parallel_view_in_new_tab(void) { PASSAGE_TAB_INFO *pt; if (stop_refresh) return; if (!settings.browsing) return; if ((pt = g_new0(PASSAGE_TAB_INFO, 1)) == NULL) { gui_generic_warning("Could not allocate a new tab"); return; } pt->showtexts = FALSE; pt->showpreview = TRUE; pt->showcomms = FALSE; pt->showdicts = FALSE; pt->showparallel = TRUE; pt->text_mod = g_strdup(settings.MainWindowModule); pt->commentary_mod = g_strdup(settings.CommWindowModule); pt->dictlex_mod = g_strdup(settings.DictWindowModule); pt->book_mod = g_strdup(settings.book_mod); pt->showbookeditor = FALSE; pt->comm_showing = FALSE; pt->text_commentary_key = g_strdup(settings.currentverse); pt->dictlex_key = g_strdup(settings.dictkey); pt->book_offset = g_strdup_printf("%ld", settings.book_offset); passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO *)pt); set_current_tab(pt); gui_recompute_view_menu_choices(); notebook_main_add_page(pt); pt->paratab = gui_create_parallel_tab(); gui_parallel_tab_sync((gchar *)settings.currentverse); /*gtk_box_pack_start(GTK_BOX(widgets.page), pt->paratab, TRUE, TRUE, 0); */ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main), gtk_notebook_page_num(GTK_NOTEBOOK(widgets.notebook_main), pt->page_widget)); }
static void kbd_toggle_option(gboolean cond, gchar *option) { gchar *msg; if (cond) { int opt = !main_get_one_option(sM, option); // negate. main_save_module_options(sM, option, opt); gchar *url = g_strdup_printf("sword://%s/%s", sM, sV); main_url_handler(url, TRUE); g_free(url); msg = g_strdup_printf("%s %s", option, (opt ? "on" : "off")); gui_set_statusbar(msg); g_free(msg); } else { msg = g_strdup_printf(_("Module has no support for %s."), option); gui_generic_warning(msg); g_free(msg); } }
G_MODULE_EXPORT void on_read_selection_aloud_activate(GtkMenuItem * menuitem, gpointer user_data) { gchar *dict_key; int len; GtkWidget *html_widget = _get_html(); XIPHOS_HTML_COPY_SELECTION(html_widget); gtk_editable_select_region((GtkEditable *)widgets.entry_dict, 0, -1); gtk_editable_paste_clipboard((GtkEditable *)widgets.entry_dict); dict_key = g_strdup(gtk_editable_get_chars((GtkEditable *)widgets.entry_dict, 0, -1)); len = (dict_key ? strlen(dict_key) : 0); if (dict_key && len && *dict_key) { ReadAloud(0, dict_key); g_free(dict_key); } else gui_generic_warning("No selection made"); }
G_MODULE_EXPORT void on_lookup_google_activate(GtkMenuItem *menuitem, gpointer user_data) { gchar *dict_key; XIPHOS_HTML_COPY_SELECTION(_get_html()); gtk_editable_select_region((GtkEditable *)widgets.entry_dict, 0, -1); gtk_editable_paste_clipboard((GtkEditable *)widgets.entry_dict); dict_key = g_strdup(gtk_editable_get_chars((GtkEditable *)widgets.entry_dict, 0, -1)); if ((dict_key == NULL) || (*dict_key == '\0')) { gui_generic_warning("No selection made"); } else { gchar *showstr = g_strconcat("http://www.biblemap.org/#", dict_key, NULL); xiphos_open_default(showstr); g_free(showstr); } g_free(dict_key); }
void gui_menu_popup(XiphosHtml *html, const gchar *mod_name, DIALOG_DATA *d) { GtkWidget *menu; if (d) { dialog = d; menu_mod_name = NULL; //(gchar*) mod_name; is_dialog = TRUE; } else if (mod_name) { menu_mod_name = (gchar *)mod_name; dialog = NULL; is_dialog = FALSE; } else return; menu = _create_popup_menu(html, mod_name, d); if (menu) gtk_menu_popup((GtkMenu *)menu, NULL, NULL, NULL, NULL, 2, gtk_get_current_event_time()); else gui_generic_warning(_("No module in this pane.")); }
static gboolean on_vbox1_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { /* these are the mods we actually use for global keys, we always only check for these set */ guint state = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD4_MASK); switch (event->keyval) { case XK_Shift_L: /* shift keys - we need this for locking strongs (and */ case XK_Shift_R: /* other stuff) while moving mouse to previewer */ shift_key_pressed = TRUE; /* no break? hm... */ case XK_a: case XK_A: if (state == GDK_MOD1_MASK) { // Alt-A annotation gui_mark_verse_dialog(sM, sV); } else if (state == (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) on_biblesync_kbd(3); // BSP audience break; case XK_b: case XK_B: if (state == GDK_MOD1_MASK) { // Alt-B bookmark gchar *label = g_strdup_printf("%s, %s", sV, sM); gui_bookmark_dialog(label, sM, sV); g_free(label); } break; case XK_c: case XK_C: if (state == GDK_MOD1_MASK) { // Alt-C commentary pane gtk_widget_grab_focus(navbar_versekey.lookup_entry); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_comm_book), 0); } break; case XK_d: case XK_D: if (state == GDK_MOD1_MASK) // Alt-D dictionary entry gtk_widget_grab_focus(widgets.entry_dict); break; case XK_f: case XK_F: if (state == GDK_CONTROL_MASK) { // Ctrl-F find text if (settings.showtexts) { gui_find_dlg(widgets.html_text, sM, FALSE, NULL); } else if (settings.showcomms) { if (settings.comm_showing) { gui_find_dlg(widgets.html_comm, sC, FALSE, NULL); } else { gui_find_dlg(widgets.html_book, sB, FALSE, NULL); } } else if (settings.showdicts) { gui_find_dlg(widgets.html_dict, sD, FALSE, NULL); } else gui_generic_warning(_("Xiphos: No windows.")); } break; case XK_g: case XK_G: if (state == GDK_MOD1_MASK) { // Alt-G genbook entry gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_comm_book), 1); gtk_widget_grab_focus(navbar_book.lookup_entry); } break; case XK_j: if (state == 0) // J "next verse" access_on_down_eventbox_button_release_event(VERSE_BUTTON); break; case XK_k: if (state == 0) // K "previous verse" access_on_up_eventbox_button_release_event(VERSE_BUTTON); break; case XK_l: case XK_L: if (state == GDK_CONTROL_MASK) // Ctrl-L verse entry gtk_widget_grab_focus(navbar_versekey.lookup_entry); break; case XK_m: case XK_M: if (state == GDK_MOD1_MASK) // Alt-M morph { kbd_toggle_option((main_check_for_global_option(sM, "GBFMorph") || main_check_for_global_option(sM, "ThMLMorph") || main_check_for_global_option(sM, "OSISMorph")), "Morphological Tags"); } break; case XK_n: case XK_N: if (state == GDK_CONTROL_MASK) // Ctrl-N verse access_on_down_eventbox_button_release_event(VERSE_BUTTON); else if (state == 0) // n chapter access_on_down_eventbox_button_release_event(CHAPTER_BUTTON); else if (state == GDK_SHIFT_MASK) // N book access_on_down_eventbox_button_release_event(BOOK_BUTTON); else if (state == (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) { // BSP transient navigate if (biblesync_active_xmit_allowed()) { biblesync_prep_and_xmit(sM, sV); gui_set_statusbar(_("BibleSync: Current navigation sent.")); } else { gui_generic_warning(_("BibleSync: Not speaking.")); } } break; case XK_o: case XK_O: if (state == (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) on_biblesync_kbd(0); // BSP off break; case XK_p: case XK_P: if (state == GDK_CONTROL_MASK) // Ctrl-P verse access_on_up_eventbox_button_release_event(VERSE_BUTTON); else if (state == 0) // p chapter access_on_up_eventbox_button_release_event(CHAPTER_BUTTON); else if (state == GDK_SHIFT_MASK) // P book access_on_up_eventbox_button_release_event(BOOK_BUTTON); else if (state == GDK_MOD1_MASK) // Alt-P parallel detach on_undockInt_activate(NULL); else if (state == (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) on_biblesync_kbd(1); // BSP personal break; case XK_q: case XK_Q: if (state == GDK_CONTROL_MASK) // Ctrl-Q quit delete_event(NULL, NULL, NULL); break; case XK_r: case XK_R: if (state == GDK_MOD1_MASK) // Alt-R red words { kbd_toggle_option(((main_check_for_global_option(sM, "GBFRedLetterWords")) || (main_check_for_global_option(sM, "OSISRedLetterWords"))), "Words of Christ in Red"); } break; case XK_s: case XK_S: if (state == GDK_MOD1_MASK) // Alt-S strong's { kbd_toggle_option(((main_check_for_global_option(sM, "GBFStrongs")) || (main_check_for_global_option(sM, "ThMLStrongs")) || (main_check_for_global_option(sM, "OSISStrongs"))), "Strong's Numbers"); } else if (state == (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) on_biblesync_kbd(2); // BSP speaker break; case XK_t: case XK_T: if (state == GDK_CONTROL_MASK) // open a new tab on_notebook_main_new_tab_clicked(NULL, NULL); break; case XK_z: case XK_Z: if (state == GDK_MOD1_MASK) // Alt-Z open personal commentary access_to_edit_percomm(); break; case XK_plus: // Ctrl-Plus Increase base font size if (state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) new_base_font_size(TRUE); break; case XK_minus: // Ctrl-Minus Decrease base font size if (state == GDK_CONTROL_MASK) new_base_font_size(FALSE); break; case XK_0: // Ctrl-0 (zero) Neutralize base font size. if (state == GDK_CONTROL_MASK) { settings.base_font_size = 1; new_base_font_size(FALSE); } break; // ctrl-DIGIT [1-9] selects DIGIT-th tab. case XK_1: case XK_2: case XK_3: case XK_4: case XK_5: case XK_6: case XK_7: case XK_8: case XK_9: if (state == GDK_CONTROL_MASK) gui_select_nth_tab((event->keyval - XK_0) - 1); /* 0-based list */ case XK_F1: // F1 help if (state == 0) on_help_contents_activate(NULL, NULL); break; case XK_F2: // F2 preferences if (state == 0) on_preferences_activate(NULL, NULL); break; case XK_F3: // F3 search if (state == 0) main_open_search_dialog(); else if (state == GDK_CONTROL_MASK) gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_sidebar), 2); break; case XK_F4: // F4 module manager if (state == 0) on_module_manager_activate(NULL, NULL); else if (state == GDK_CONTROL_MASK) gui_close_passage_tab(gtk_notebook_page_num(GTK_NOTEBOOK(widgets.notebook_main), ((PASSAGE_TAB_INFO *) cur_passage_tab)->page_widget)); break; case XK_F10: // Shift-F10 bible module right click if (state == GDK_SHIFT_MASK) gui_menu_popup(NULL, sM, NULL); /* FIXME: needs the html widget as first pram */ break; } XI_message(("on_vbox1_key_press_event\nkeycode: %d, keysym: %0x, state: %d", event->hardware_keycode, event->keyval, state)); return FALSE; }
G_MODULE_EXPORT void on_rename_perscomm_activate(GtkMenuItem *menuitem, gpointer user_data) { if (is_dialog) return; #if defined(WIN32) gui_generic_warning(_("Renaming is not available in Windows.\n\n" "Xiphos is limited by Windows' filesystem,\n" "because it disallows the renaming of filename\n" "components of currently-open files,\n" "such as the contents of this commentary.\n" "Therefore, personal commentary renaming is\n" "not available in the Windows environment.")); #else GS_DIALOG *info; GString *workstr; char *s; char *datapath_old, *datapath_new; const char *conf_old; char *conf_new; char *sworddir, *modsdir; FILE *result; // get a new name for the module. info = gui_new_dialog(); info->title = _("Rename Commentary"); workstr = g_string_new(""); g_string_printf(workstr, "<span weight=\"bold\">%s</span>", _("Choose Commentary Name")); info->label_top = workstr->str; info->text1 = g_strdup(_("New Name")); info->label1 = N_("Name: "); info->ok = TRUE; info->cancel = TRUE; if (gui_gs_dialog(info) != GS_OK) goto out1; for (s = info->text1; *s; ++s) { if (!isalnum(*s) && (*s != '_')) { gui_generic_warning_modal(_("Module names must contain [A-Za-z0-9_] only.")); goto out1; } } if (main_is_module(info->text1)) { gui_generic_warning_modal(_("Xiphos already knows a module by that name.")); goto out1; } sworddir = g_strdup_printf("%s/" DOTSWORD, settings.homedir); modsdir = g_strdup_printf("%s/mods.d", sworddir); conf_old = main_get_mod_config_file(settings.CommWindowModule, sworddir); conf_new = g_strdup(info->text1); // dirname is lowercase. for (s = conf_new; *s; ++s) if (isupper(*s)) *s = tolower(*s); datapath_old = main_get_mod_config_entry(settings.CommWindowModule, "DataPath"); datapath_new = g_strdup(datapath_old); if ((s = strstr(datapath_new, "rawfiles/")) == NULL) { gui_generic_warning_modal("Malformed datapath in old configuration!"); goto out2; } *(s + 9) = '\0'; // skip past "rawfiles/". s = g_strdup_printf("%s%s", datapath_new, conf_new); g_free(datapath_new); // out with the old... datapath_new = s; // ..and in with the new. // move old data directory to new. if ((g_chdir(sworddir) != 0) || (rename(datapath_old, datapath_new) != 0)) { gui_generic_warning_modal("Failed to rename directory."); goto out2; } // manufacture new .conf from old. g_string_printf(workstr, "( cd \"%s\" && sed -e '/^\\[/s|^.*$|[%s]|' -e '/^DataPath=/s|rawfiles/.*$|rawfiles/%s/|' < \"%s\" > \"%s.conf\" ) 2>&1", modsdir, info->text1, conf_new, conf_old, conf_new); if ((result = popen(workstr->str, "r")) == NULL) { g_string_printf(workstr, _("Failed to create new configuration:\n%s"), strerror(errno)); gui_generic_warning_modal(workstr->str); goto out2; } else { gchar output[258]; if (fgets(output, 256, result) != NULL) { g_string_truncate(workstr, 0); g_string_append(workstr, _("Configuration build error:\n\n")); g_string_append(workstr, output); gui_generic_warning_modal(workstr->str); goto out2; // necessary? advisable? } pclose(result); } // unlink old conf. g_string_printf(workstr, "%s/%s", modsdir, conf_old); if (unlink(workstr->str) != 0) { g_string_printf(workstr, "Unlink of old configuration failed:\n%s", strerror(errno)); gui_generic_warning_modal(workstr->str); goto out2; } main_update_module_lists(); settings.CommWindowModule = g_strdup(info->text1); main_display_commentary(info->text1, settings.currentverse); out2: g_free(conf_new); g_free((char *)conf_old); g_free(datapath_old); g_free(datapath_new); g_free(modsdir); g_free(sworddir); out1: g_free(info->text1); g_free(info); g_string_free(workstr, TRUE); #endif /* !WIN32 */ }
void gui_open_module_in_new_tab(gchar *module) { PASSAGE_TAB_INFO *pt; gint module_type; if (stop_refresh) return; if (!settings.browsing) return; if ((pt = g_new0(PASSAGE_TAB_INFO, 1)) == NULL) { gui_generic_warning("Could not allocate a new tab"); return; } module_type = main_get_mod_type(module); pt->showtexts = FALSE; pt->showpreview = settings.showpreview; pt->showcomms = FALSE; pt->showdicts = FALSE; pt->showparallel = FALSE; pt->paratab = NULL; switch (module_type) { case -1: return; break; case TEXT_TYPE: pt->text_mod = g_strdup(module); pt->commentary_mod = g_strdup(settings.CommWindowModule); pt->dictlex_mod = g_strdup(settings.DictWindowModule); pt->book_mod = g_strdup(settings.book_mod); pt->showtexts = TRUE; break; case COMMENTARY_TYPE: pt->text_mod = g_strdup(settings.MainWindowModule); pt->commentary_mod = g_strdup(module); pt->dictlex_mod = g_strdup(settings.DictWindowModule); pt->book_mod = g_strdup(settings.book_mod); pt->showcomms = TRUE; pt->comm_showing = 1; break; case DICTIONARY_TYPE: pt->text_mod = g_strdup(settings.MainWindowModule); pt->commentary_mod = g_strdup(settings.CommWindowModule); pt->dictlex_mod = g_strdup(module); pt->book_mod = g_strdup(settings.book_mod); pt->showdicts = TRUE; break; case BOOK_TYPE: pt->text_mod = g_strdup(settings.MainWindowModule); pt->commentary_mod = g_strdup(settings.CommWindowModule); pt->dictlex_mod = g_strdup(settings.DictWindowModule); pt->book_mod = g_strdup(module); pt->showcomms = TRUE; pt->comm_showing = 0; break; case PRAYERLIST_TYPE: pt->text_mod = g_strdup(settings.MainWindowModule); pt->commentary_mod = g_strdup(settings.CommWindowModule); pt->dictlex_mod = g_strdup(settings.DictWindowModule); pt->book_mod = g_strdup(module); pt->showcomms = TRUE; pt->comm_showing = 0; break; } pt->text_commentary_key = g_strdup(settings.currentverse); pt->dictlex_key = g_strdup(settings.dictkey); pt->book_offset = g_strdup_printf("%ld", settings.book_offset); passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO *)pt); //set_current_tab(pt); notebook_main_add_page(pt); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main), gtk_notebook_page_num(GTK_NOTEBOOK(widgets.notebook_main), pt->page_widget)); }