G_MODULE_EXPORT void on_populate_verse_list_activate(GtkMenuItem *menuitem, gpointer user_data) { GS_DIALOG *info = gui_new_dialog(); #ifdef HAVE_GTK_310 info->stock_icon = g_strdup("dialog-warning"); #else info->stock_icon = g_strdup(GTK_STOCK_DIALOG_WARNING); #endif info->label_top = g_strdup(_("Paste verse references")); info->text1 = g_strdup(""); info->label1 = _("List:"); info->ok = TRUE; (void)gui_gs_dialog(info); main_display_verse_list_in_sidebar(settings.currentverse, settings.MainWindowModule, info->text1); g_free(info->label_top); g_free(info->text1); g_free(info); }
static void add_folder_button(void) { GtkTreeIter selected; GtkTreeIter iter; BOOKMARK_DATA *data; GtkTreeSelection *selection; char *t; gint test; GS_DIALOG *info; GString *str; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); if (!gtk_tree_selection_get_selected(selection, NULL, &selected)) return; t = "|"; str = g_string_new(""); info = gui_new_dialog(); //info->stock_icon = GTK_STOCK_OPEN; info->title = _("Bookmark"); g_string_printf(str, "<span weight=\"bold\">%s</span>", _("Enter Folder Name")); info->label_top = str->str; info->text1 = g_strdup(_("Folder Name")); info->label1 = _("Folder: "); info->ok = TRUE; info->cancel = TRUE; data = g_new(BOOKMARK_DATA, 1); /*** open dialog to get name for new folder ***/ test = gui_gs_dialog(info); if (test == GS_OK) { char *buf = g_strdelimit(info->text1, t, ' '); data->caption = g_strdup(buf); data->key = NULL; data->module = NULL; data->module_desc = NULL; data->description = NULL; data->is_leaf = FALSE; data->opened = bm_pixbufs->pixbuf_opened; data->closed = bm_pixbufs->pixbuf_closed; gui_add_item_to_tree(&iter, &selected, data); bookmarks_changed = TRUE; gui_save_bookmarks(NULL, NULL); g_free(data->caption); GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter); gtk_tree_view_expand_to_path(GTK_TREE_VIEW(treeview), path); gtk_tree_selection_select_path(selection, path); gtk_tree_path_free(path); } g_free(data); g_free(info->text1); g_free(info); g_string_free(str, TRUE); }
G_MODULE_EXPORT void on_add_sibling_activate(GtkMenuItem *menuitem, gpointer user_data) { INFO *info; EDITOR *e = (EDITOR *)user_data; GtkWidget *tree = GTK_WIDGET(e->treeview); gint test; GS_DIALOG *d; GtkTreeIter sibling; info = _get_info(tree); d = gui_new_dialog(); #ifdef HAVE_GTK_310 d->stock_icon = "dialog-question"; #else d->stock_icon = GTK_STOCK_DIALOG_QUESTION; #endif d->title = _("Prayer List/Journal Item"); d->label_top = _("New name"); d->label1 = _("Name: "); d->text1 = g_strdup(info->local_name); d->ok = TRUE; d->cancel = TRUE; test = gui_gs_dialog(d); if (test == GS_OK) { unsigned long l_offset = main_treekey_append_sibling(info->book, d->text1, info->offset); if (l_offset) { char *buf = g_strdup_printf("%ld", l_offset); gtk_tree_store_insert_after(GTK_TREE_STORE(info->model), &sibling, NULL, &info->iter); gtk_tree_store_set(GTK_TREE_STORE(info->model), &sibling, COL_OPEN_PIXBUF, pixbufs->pixbuf_helpdoc, COL_CLOSED_PIXBUF, NULL, COL_CAPTION, d->text1, COL_MODULE, info->book, COL_OFFSET, buf, -1); if (e->key) g_free(e->key); e->key = g_strdup(buf); editor_load_book(e); g_free(buf); } } g_free(info->book); g_free(info->local_name); g_free(info->offset); g_free(info); g_free(d->text1); g_free(d); }
G_MODULE_EXPORT void on_edit_activate2(GtkMenuItem *menuitem, gpointer user_data) { INFO *info; EDITOR *editor = (EDITOR *)user_data; GtkWidget *tree = GTK_WIDGET(editor->treeview); gint test; GS_DIALOG *d; info = _get_info(tree); d = gui_new_dialog(); #ifdef HAVE_GTK_310 d->stock_icon = "dialog-question"; #else d->stock_icon = GTK_STOCK_DIALOG_QUESTION; #endif d->title = _("Prayer List/Journal Item"); d->label_top = _("New name"); d->label1 = _("Name: "); d->text1 = g_strdup(info->local_name); d->ok = TRUE; d->cancel = TRUE; test = gui_gs_dialog(d); if (test == GS_OK) { main_treekey_set_local_name(info->book, d->text1, info->offset); gtk_tree_store_set(GTK_TREE_STORE(info->model), &info->iter, COL_CAPTION, (gchar *)d->text1, -1); } g_free(info->book); g_free(info->local_name); g_free(info->offset); g_free(info); g_free(d->text1); g_free(d); }
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_verselist_to_bookmarks(GList *verses, gint save_as_single) { gint test; gchar *module_name = NULL; GtkTreeIter parent; GtkTreeIter iter; GS_DIALOG *info; RESULTS *list_item; /*gchar *dlg = g_strdup_printf("<span weight=\"bold\">%s</span>\n%s", _("Save these results as a single bookmark?"), _("(rather than as a series of bookmarks)")); */ if (save_as_single) { GString *name = g_string_new(NULL); GString *verse_string = g_string_new(""); gboolean first_entry = TRUE; g_string_printf(name, _("Search result: %s"), settings.searchText); while (verses) { list_item = (RESULTS *)verses->data; if (main_is_Bible_key(list_item->module, list_item->key)) { if (first_entry) { module_name = g_strdup(list_item->module); first_entry = FALSE; } else { verse_string = g_string_append(verse_string, "; "); } verse_string = g_string_append(verse_string, list_item->key); } verses = g_list_next(verses); } gui_bookmark_dialog(name->str, module_name, verse_string->str); g_string_free(name, TRUE); g_string_free(verse_string, TRUE); g_free(module_name); return; } gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter); info = gui_new_dialog(); #ifdef HAVE_GTK_310 info->stock_icon = "document-open"; #else info->stock_icon = GTK_STOCK_OPEN; #endif info->title = _("Bookmark"); info->label_top = _("Enter Folder Name"); info->text1 = g_strdup(settings.searchText); info->label1 = _("Folder: "); info->ok = TRUE; info->cancel = TRUE; /*** open dialog to get name for root node ***/ test = gui_gs_dialog(info); if (test == GS_OK) { gtk_tree_store_append(GTK_TREE_STORE(model), &parent, &iter); gtk_tree_store_set(GTK_TREE_STORE(model), &parent, COL_OPEN_PIXBUF, bm_pixbufs->pixbuf_opened, COL_CLOSED_PIXBUF, bm_pixbufs->pixbuf_closed, COL_CAPTION, info->text1, COL_KEY, NULL, COL_MODULE, NULL, -1); // set_results_position((char) 1); // TOP GString *str = g_string_new(" "); while (verses) { list_item = (RESULTS *)verses->data; module_name = list_item->module; gchar *tmpbuf = list_item->key; g_string_printf(str, "%s, %s", tmpbuf, module_name); XI_message(("bookmark: %s", str->str)); gtk_tree_store_append(GTK_TREE_STORE(model), &iter, &parent); gtk_tree_store_set(GTK_TREE_STORE(model), &iter, COL_OPEN_PIXBUF, bm_pixbufs->pixbuf_helpdoc, COL_CLOSED_PIXBUF, NULL, COL_CAPTION, str->str, COL_KEY, tmpbuf, COL_MODULE, module_name, -1); verses = g_list_next(verses); } g_string_free(str, TRUE); bookmarks_changed = TRUE; gui_save_bookmarks_treeview(); } g_free(info->text1); g_free(info); }