Пример #1
0
static void _button_one(EDITOR *e)
{
	INFO *info;

	editor_save_book(e);

	info = _get_info(e->treeview);

	if (atol(info->offset) == 0)
		gtk_widget_set_sensitive(e->html_widget, FALSE);
	else
		gtk_widget_set_sensitive(e->html_widget, TRUE);

	if (e->module)
		g_free(e->module);
	e->module = g_strdup(info->book);

	if (e->key)
		g_free(e->key);
	e->key = g_strdup(info->offset);
	editor_load_book(e);

	g_free(info->book);
	g_free(info->local_name);
	g_free(info->offset);
	g_free(info);
}
Пример #2
0
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);
}
Пример #3
0
gint editor_create_new(const gchar *filename, const gchar *key,
		       gint editor_type)
{
	GList *tmp = NULL;

	tmp = g_list_first(editors_all);
	while (tmp != NULL) {
		EDITOR *e = (EDITOR *)tmp->data;
		switch (editor_type) {
		case STUDYPAD_EDITOR:
			if (e->studypad) {
				if (editor_is_dirty(e))
					_save_file(e);
				if (e->filename)
					g_free(e->filename);
				e->filename = g_strdup(filename);
				gtk_widget_show(e->window);
				gdk_window_raise(gtk_widget_get_parent_window(GTK_WIDGET(e->window)));

				_load_file(e, g_strdup(filename));
				return 1;
			}
			break;
		case NOTE_EDITOR:
			if (!e->noteeditor)
				break;
			if (editor_is_dirty(e))
				_save_note(e);
			if (e->module)
				g_free(e->module);
			e->module = g_strdup(filename);
			if (e->key)
				g_free(e->key);
			e->key = g_strdup(key);
			gtk_widget_show(e->window);
			gdk_window_raise(gtk_widget_get_parent_window(GTK_WIDGET(e->window)));

			editor_load_note(e, NULL, NULL);

			return 1;
			break;
		case BOOK_EDITOR:
			if (!e->bookeditor)
				break;
			if (editor_is_dirty(e))
				_save_book(e);
			if (e->module)
				g_free(e->module);
			e->module = g_strdup(filename);
			if (e->key)
				g_free(e->key);
			e->key = g_strdup(key);
			gtk_widget_show(e->window);
			gdk_window_raise(gtk_widget_get_parent_window(GTK_WIDGET(e->window)));
			main_load_book_tree_in_editor(GTK_TREE_VIEW(e->treeview),
						      e->module);
			editor_load_book(e);

			return 1;
			break;
		}
		tmp = g_list_next(tmp);
	}
	XI_message(("filename %s, key %s",
		    (filename ? filename : "-null-"),
		    (key ? key : "-null-")));
	return _create_new(filename, key, editor_type);
}
Пример #4
0
static gint _create_new(const gchar *filename, const gchar *key,
			gint editor_type)
{
	EDITOR *editor;
	GtkWidget *vbox = NULL;
	GtkWidget *toolbar_nav = NULL;

	editor = g_new(EDITOR, 1);
	editor->html_widget = NULL;
	editor->sync = FALSE;
	editor->type = editor_type;

	switch (editor_type) {
	case STUDYPAD_EDITOR:
		editor->studypad = TRUE;
		editor->bookeditor = FALSE;
		editor->noteeditor = FALSE;
		editor->module = NULL;
		editor->key = NULL;
		editor->filename = NULL;
		widgets.studypad_dialog =
		    editor_new(_("StudyPad"), editor);

		if (filename) {
			editor->filename = g_strdup(filename);
			_load_file(editor, g_strdup(filename));
		}
		break;
	case NOTE_EDITOR:
		editor->noteeditor = TRUE;
		editor->bookeditor = FALSE;
		editor->studypad = FALSE;
		editor->filename = NULL;
		editor->module = g_strdup(filename);
		editor->key = g_strdup(key);
		editor->navbar.key = NULL;
		editor_new(_("Note Editor"), editor);
		vbox = GTKHTML_EDITOR(editor->window)->vbox;
		toolbar_nav = gui_navbar_versekey_editor_new(editor);
		gtk_widget_show(toolbar_nav);
		gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(toolbar_nav),
				   FALSE, TRUE, 0);
		gtk_box_reorder_child(GTK_BOX(vbox),
				      GTK_WIDGET(toolbar_nav), 1);

		editor_load_note(editor, NULL, NULL);
		break;
	case BOOK_EDITOR:
		editor->bookeditor = TRUE;
		editor->noteeditor = FALSE;
		editor->studypad = FALSE;
		editor->filename = NULL;
		editor->module = g_strdup(filename);
		editor->key = g_strdup(key);
		editor_new(_("Prayer List/Journal Editor"), editor);

		GtkWidget *box;
		UI_VBOX(box, TRUE, 0);
		gtk_widget_show(box);
		GtkWidget *hpaned1 = UI_HPANE();
		gtk_widget_show(hpaned1);
		gtk_paned_pack2(GTK_PANED(hpaned1), box, TRUE, TRUE);

		GtkWidget *scrollbar = gtk_scrolled_window_new(NULL, NULL);
		gtk_widget_show(scrollbar);
		gtk_paned_pack1(GTK_PANED(hpaned1), GTK_WIDGET(scrollbar),
				TRUE, TRUE);
		gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollbar),
					       GTK_POLICY_AUTOMATIC,
					       GTK_POLICY_AUTOMATIC);
		gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)
						    scrollbar,
						    settings.shadow_type);

		editor->treeview = gui_create_editor_tree(editor);
		gtk_widget_show(editor->treeview);
		gtk_container_add(GTK_CONTAINER(scrollbar),
				  editor->treeview);
		gtk_paned_set_position(GTK_PANED(hpaned1), 125);
		gtk_tree_view_collapse_all((GtkTreeView *)
					   editor->treeview);
		// then we should expand on the item to which we've opened for edit.
		vbox = GTKHTML_EDITOR(editor->window)->vbox;

		gtk_widget_reparent(vbox, box);

		gtk_container_add(GTK_CONTAINER(editor->window), hpaned1);

		editor_load_book(editor);

		break;
	}
	editor->is_changed = FALSE;
	editors_all = g_list_append(editors_all, (EDITOR *)editor);
	return 1;
}