/****************************************************************************** * Name * on_show_verse_numbers_activate * * Synopsis * #include "gui/main_menu.h" * * void on_show_verse_numbers_activate(GtkMenuItem *menuitem, gpointer user_data) * * Description * toggle showing verse numbers together. * * Return value * void */ G_MODULE_EXPORT void on_show_verse_numbers_activate(GtkCheckMenuItem *menuitem, gpointer user_data) { settings.showversenum = gtk_check_menu_item_get_active(menuitem); xml_set_value("Xiphos", "misc", "showversenum", (settings.showversenum ? "1" : "0")); main_display_commentary(NULL, settings.currentverse); main_display_bible(NULL, settings.currentverse); }
static void on_notebook_comm_book_switch_page(GtkNotebook *notebook, GtkNotebookPage *page, gint page_num, GList **tl) #endif { gchar *url = NULL; if (page_num == 0) { #if 0 gtk_drag_dest_unset(GTK_WIDGET(widgets.html_book)); gui_set_drop_target(widgets.html_comm); #endif /* 0 */ settings.comm_showing = TRUE; gtk_widget_show(nav_toolbar); } else { #if 0 gtk_drag_dest_unset(GTK_WIDGET(widgets.html_comm)); gui_set_drop_target(widgets.html_book); #endif /* 0 */ settings.comm_showing = FALSE; if (!settings.showtexts) gtk_widget_hide(nav_toolbar); } gui_update_tab_struct(NULL, settings.CommWindowModule, NULL, NULL, NULL, NULL, settings.comm_showing, settings.showtexts, settings.showpreview, settings.showcomms, settings.showdicts); if (settings.comm_showing) main_display_commentary(settings.CommWindowModule, settings.currentverse); else if (settings.book_mod && *settings.book_mod) { url = g_strdup_printf("sword://%s/%ld", settings.book_mod, settings.book_offset); main_url_handler(url, TRUE); g_free(url); } gui_set_tab_label(settings.currentverse, TRUE); }
void main_change_verse_tab_history(gint historynum) { PASSAGE_TAB_INFO *tab = cur_passage_tab; gchar *key; tab->current_history_item = historynum; settings.addhistoryitem = tab->first_back_click; XI_print(("commod = %s\n", tab->history_list[historynum].commod)); XI_print(("textmod = %s\n", tab->history_list[historynum].textmod)); key = main_update_nav_controls(tab->history_list[historynum].textmod, tab->history_list[historynum].verseref); main_display_commentary(tab->history_list[historynum].commod, key); main_display_bible(tab->history_list[historynum].textmod, key); main_keep_bibletext_dialog_in_sync(key); if (key) g_free(key); }
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_notebook_main_switch_page(GtkNotebook *notebook, GtkNotebookPage *page, gint page_num, GList **tl) #endif { gboolean comm_showing; gint number_of_pages = gtk_notebook_get_n_pages(notebook); PASSAGE_TAB_INFO *pt; if (stop_refresh) return; XI_message(("on_notebook_main_switch_page")); page_change = TRUE; /* get data structure for new passage */ /* * this is needed to stop seg fault if the left tab is closed when * there are only two tabs - because number_of_pages equals 2 even * thought there is only 1. */ if (number_of_pages == 2 && removed_page == 0) pt = (PASSAGE_TAB_INFO *)g_list_nth_data(*tl, 0); else pt = (PASSAGE_TAB_INFO *)g_list_nth_data(*tl, page_num); removed_page = 1; //cur_passage_tab = pt; #ifdef USE_TREEVIEW_PATH if (cur_passage_tab && cur_passage_tab->book_mod) gui_collapse_treeview_to_book(GTK_TREE_VIEW(sidebar.module_list), cur_passage_tab->book_mod); #endif /* USE_TREEVIEW_PATH */ if (!pt->showparallel) { if (cur_passage_tab && cur_passage_tab->paratab) gtk_widget_hide(cur_passage_tab->paratab); gtk_widget_show(widgets.hpaned); } set_current_tab(pt); companion_activity = TRUE; if (pt->showparallel) { gtk_widget_hide(widgets.hpaned); if (pt->paratab) gtk_widget_show(pt->paratab); companion_activity = FALSE; page_change = FALSE; settings.paratab_showing = TRUE; return; } else settings.paratab_showing = FALSE; //sets the book mod and key main_display_book(pt->book_mod, pt->book_offset); #ifdef USE_TREEVIEW_PATH if (pt->showcomms && pt->book_mod) gui_expand_treeview_to_path(GTK_TREE_VIEW(sidebar.module_list), pt->book_mod); #endif /* USE_TREEVIEW_PATH */ comm_showing = settings.comm_showing; settings.comm_showing = 1; //sets the commentary mod and key main_display_commentary(pt->commentary_mod, pt->text_commentary_key); settings.comm_showing = comm_showing; //sets the text mod and key main_display_bible(pt->text_mod, pt->text_commentary_key); navbar_versekey.module_name = g_string_assign(navbar_versekey.module_name, pt->text_mod); navbar_versekey.key = g_string_assign(navbar_versekey.key, pt->text_commentary_key); main_update_nav_controls(navbar_versekey.module_name->str, pt->text_commentary_key); //sets the dictionary mod and key main_display_dictionary(pt->dictlex_mod, pt->dictlex_key); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_comm_book), (pt->comm_showing ? 0 : 1)); gui_recompute_view_menu_choices(); companion_activity = FALSE; page_change = FALSE; }