1
/* $Id: html_diag.c 1712 2006-01-28 09:59:34Z kyanh $ */
2
/* Winefish LaTeX Editor (based on Bluefish HTML Editor)
3
* html_diag.c - general functions to create HTML dialogs
5
* Copyright (C) 2000-2002 Olivier Sessink
6
* Modified for Winefish (C) 2005 Ky Anh <kyanh@o2.pl>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include <string.h> /* strrchr */
25
#include <stdlib.h> /* strtod */
29
#include "html_diag.h" /* myself */
30
#include "gtk_easy.h" /* window_full() */
32
#include "stringlist.h" /* add_to_stringlist */
33
#include "document.h" /* doc_save_selection */
35
/* kyanh, removed, 20050225
36
Trecent_attribs recent_attribs;
39
/*****************************************/
40
/********** DIALOG FUNCTIONS *************/
41
/*****************************************/
43
void html_diag_destroy_cb(GtkWidget * widget, Thtml_diag *dg) {
44
/* kyanh, removed, 20050225,
45
dg->tobedestroyed = TRUE; */
47
gtk_text_buffer_delete_mark(dg->doc->buffer,dg->mark_ins);
50
gtk_text_buffer_delete_mark(dg->doc->buffer,dg->mark_sel);
52
window_destroy(dg->dialog); /* kyanh, from: gtk_easy.h */
53
DEBUG_MSG("html_diag_destroy_cb, about to free dg=%p\n",dg);
57
void html_diag_cancel_clicked_cb(GtkWidget *widget, gpointer data) {
58
html_diag_destroy_cb(NULL, data);
61
Thtml_diag *html_diag_new(Tbfwin *bfwin, gchar *title) {
64
dg = g_malloc(sizeof(Thtml_diag));
65
/* kyanh, removed, 20050225,
66
dg->tobedestroyed = FALSE;
68
DEBUG_MSG("html_diag_new, dg=%p\n",dg);
69
dg->dialog = window_full2(title, GTK_WIN_POS_MOUSE, 12,G_CALLBACK(html_diag_destroy_cb), dg, TRUE/* escape key close the winow */, bfwin ? bfwin->main_window : NULL);
70
gtk_window_set_type_hint(GTK_WINDOW(dg->dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
71
gtk_window_set_role(GTK_WINDOW(dg->dialog), "html_dialog");
72
dg->vbox = gtk_vbox_new(FALSE, 1);
73
gtk_container_add(GTK_CONTAINER(dg->dialog), dg->vbox);
75
if (!gtk_text_buffer_get_mark(bfwin->current_document->buffer,"diag_ins")) {
77
GtkTextMark* mark = gtk_text_buffer_get_mark(bfwin->current_document->buffer,"insert");
78
gtk_text_buffer_get_iter_at_mark(bfwin->current_document->buffer,&iter,mark);
79
dg->mark_ins = gtk_text_buffer_create_mark(bfwin->current_document->buffer,"diag_ins",&iter,TRUE);
80
mark = gtk_text_buffer_get_mark(bfwin->current_document->buffer,"selection_bound");
81
gtk_text_buffer_get_iter_at_mark(bfwin->current_document->buffer,&iter,mark);
82
dg->mark_sel = gtk_text_buffer_create_mark(bfwin->current_document->buffer,"diag_sel",&iter,TRUE);
84
dg->mark_ins = dg->mark_sel = NULL;
92
if (main_v->props.view_bars & MODE_MAKE_LATEX_TRANSIENT) {
93
/* must be set before realizing */
94
DEBUG_MSG("html_diag_finish, setting dg->dialog=%p transient!\n", dg->dialog);
95
gtk_window_set_transient_for(GTK_WINDOW(dg->dialog), GTK_WINDOW(bfwin->main_window));
97
gtk_widget_realize(dg->dialog);
99
dg->doc = bfwin->current_document;
103
GtkWidget *html_diag_table_in_vbox(Thtml_diag *dg, gint rows, gint cols) {
104
GtkWidget *returnwidget = gtk_table_new(rows, cols, FALSE);
105
gtk_table_set_row_spacings(GTK_TABLE(returnwidget), 12);
106
gtk_table_set_col_spacings(GTK_TABLE(returnwidget), 12);
107
gtk_box_pack_start(GTK_BOX(dg->vbox), returnwidget, FALSE, FALSE, 0);
111
void html_diag_finish(Thtml_diag *dg, GtkSignalFunc ok_func) {
114
gtk_box_pack_start(GTK_BOX(dg->vbox), gtk_hseparator_new(), FALSE, FALSE, 12);
115
hbox = gtk_hbutton_box_new();
116
gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_END);
117
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 12);
119
dg->obut = bf_stock_ok_button(ok_func, dg);
120
dg->cbut = bf_stock_cancel_button(G_CALLBACK(html_diag_cancel_clicked_cb), dg);
122
gtk_box_pack_start(GTK_BOX(hbox),dg->cbut , FALSE, FALSE, 0);
123
gtk_box_pack_start(GTK_BOX(hbox),dg->obut , FALSE, FALSE, 0);
124
gtk_window_set_default(GTK_WINDOW(dg->dialog), dg->obut);
126
gtk_box_pack_start(GTK_BOX(dg->vbox), hbox, FALSE, FALSE, 0);
127
gtk_widget_show_all(GTK_WIDGET(dg->dialog));
130
/*************************************************/
131
/********** HTML -> DIALOG FUNCTIONS *************/
132
/*************************************************/
134
/* TODO: removed this function */
135
void fill_dialogvalues(gchar *dialogitems[], gchar *dialogvalues[], gchar **custom, Ttagpopup *data, Thtml_diag *diag) {
139
while (dialogitems[count]) {
140
dialogvalues[count] = NULL;
145
GList *add_entry_to_stringlist(GList *which_list, GtkWidget *entry) {
147
gchar *temp = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
148
which_list = add_to_stringlist(which_list, temp);