summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/xbibfile/techreport.c
blob: 95ee47aca1395c991cd1af46c309d5471f8d3a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/* This file is a part of XBibFile - a system for handling BibTeX references
 *
 * Author:    Ross Maloney
 * Date:      October 1999
 * Modified:  January 2002
 *
 */

#include  <stdio.h>
#include  <gtk/gtk.h>

#include  "xbibfile.h"

/* This file is a modified copy of phd.c so that it handles the
 * Technical Report BibTeX reference style */


GtkWidget  *labelX, *dataX;
GtkWidget  *label0, *data0;
GtkWidget  *label1, *data1;
GtkWidget  *label2, *data2;
GtkWidget  *label3, *data3;
GtkWidget  *label9, *data9;
GtkWidget  *label12, *data12;
GtkWidget  *label13, *data13, *textscroll;
GtkWidget  *label14, *data14;
GtkWidget  *label20, *data20;
GtkWidget  *label21, *data21;
GtkWidget  *label22, *data22;
GtkWidget  *label24, *data24;
GtkWidget  *label30, *data30;
GtkWidget  *label31, *data31;
GtkWidget  *label32, *data32;
GtkTextBuffer  *text13;
GtkTextIter  start, end;
PangoFontDescription  *font_desc;




/* The procedure to save the Technical Reporot style */

void save_techreport(GtkWidget *widget)
{
  extern int format;
  extern int length[];
  extern char slate[][];
  extern int lengthX;
  extern char slateX[];
  extern char slate1[];
  extern char slate2[];
  extern char slate3[];
  extern char slate9[];
  extern char slate12[];
  extern char slate13[];
  extern char slate14[];
  extern char slate20[];
  extern char slate21[];
  extern char slate22[];
  extern char slate24[];
  extern char slate30[];
  extern char slate31[];
  extern char slate32[];
  extern  void error();          /* defined in file error.c */
  extern  FILE *finput;          /* defined in file xbibfile.c */
  extern  void close_window();   /* defined in file cleanup.c */

  if (format != 13) {
    error(widget, GINT_TO_POINTER(5));
    return;
  }
  strcpy(slateX, gtk_entry_get_text(GTK_ENTRY(dataX)));
  lengthX = strlen(slateX);
  strcpy(slate3, gtk_entry_get_text(GTK_ENTRY(data3)));
  length[3] = strlen(slate3);
  strcpy(slate9, gtk_entry_get_text(GTK_ENTRY(data9)));
  length[9] = strlen(slate9);
  strcpy(slate20, gtk_entry_get_text(GTK_ENTRY(data20)));
  length[20] = strlen(slate20);
  strcpy(slate24, gtk_entry_get_text(GTK_ENTRY(data24)));
  length[24] = strlen(slate24);
  if (!(length[3] && length[9] && length[20] && length[24] && lengthX)) {
    error(widget, GINT_TO_POINTER(3));
    return;
  }
  if (!finput) {
    error(widget, GINT_TO_POINTER(8));
    return;
  }
  /*  finput = stdout; */
  fprintf(finput, "\n@TECHREPORT{%s,\n", slateX);
  fprintf(finput, "   author = {%s},\n", slate3);
  fprintf(finput, "   title = {%s},\n", slate20);
  fprintf(finput, "   institution = {%s},\n", slate9);
  fprintf(finput, "   year = {%s}", slate24);
  if (length[21])
    fprintf(finput, ",\n   type = {%s}", slate21);
  if (length[14])
    fprintf(finput, ",\n   number = {%s}", slate14);
  if (length[1])
    fprintf(finput, ",\n   address = {%s}", slate1);
  if (length[12])
     fprintf(finput, ",\n   month = {%s}", slate12);
  if (length[22])
     fprintf(finput, ",\n   URL = {%s}", slate22);
  if (length[2])
     fprintf(finput, ",\n   note = {%s}", slate2);
  if (length[13])
      fprintf(finput, ",\n   annote = {%s}", slate13);
  if (length[30])
    fprintf(finput, ",\n   uplink = {%s}", slate30);
  if (length[31])
    fprintf(finput, ",\n   crosslink = {%s}", slate31);
  if (length[32])
    fprintf(finput, ",\n   externlink = {%s}", slate32);
  fprintf(finput, " }\n");
                      /* indicate that the reference is saved */
  format = 0;
  length[1] = 0;
  length[2] = 0;
  length[12] = 0;
  length[13] = 0;
  length[14] = 0;
  length[21] = 0;
  length[22] = 0;
  length[30] = 0;
  length[31] = 0;
  length[32] = 0;
  close_window(widget);   /* remove this reference window */
}


/* Save the Technical Report optional fields for subsequent saving */

void  save_techoptions(GtkWidget *widget)
{
  extern  void close_window();
  extern  int length[];
  extern  char slate1[];
  extern  char slate2[];
  extern  char slate12[];
  extern  char slate13[];
  extern  char slate14[];
  extern  char slate21[];
  extern  char slate22[];
  char  *text_in_field;
  int   count;

  strcpy(slate1, gtk_entry_get_text(GTK_ENTRY(data1)));
  length[1] = strlen(slate1);
  strcpy(slate12, gtk_entry_get_text(GTK_ENTRY(data12)));
  length[12] = strlen(slate12);
  count = gtk_text_buffer_get_char_count(text13);
  gtk_text_buffer_get_iter_at_offset(text13, &end, count);
  gtk_text_buffer_get_iter_at_offset(text13, &start, 0);
  strcpy(slate13, gtk_text_buffer_get_text(text13, &start, &end, FALSE)); 
  length[13] = count;
  strcpy(slate14, gtk_entry_get_text(GTK_ENTRY(data14)));
  length[14] = strlen(slate14);
  strcpy(slate21, gtk_entry_get_text(GTK_ENTRY(data21)));
  length[21] = strlen(slate21);
  strcpy(slate22, gtk_entry_get_text(GTK_ENTRY(data22)));
  length[22] = strlen(slate22);
  strcpy(slate2, gtk_entry_get_text(GTK_ENTRY(data2)));
  length[2] = strlen(slate2);
  close_window(widget);
}
 



/* Close the option entry window, but first delete the entries */

void  close_techoptions(GtkWidget *widget)
{
  extern  void  close_window();
  extern  int length[];

  length[1] = 0;
  length[2] = 0;
  length[12] = 0;
  length[13] = 0;
  length[14] = 0;
  length[21] = 0;  
  length[22] = 0;  
  close_window(widget);
}


/* The procedure to put the optional Technical Report style
 * fields on the screen */

void techoptions(GtkWidget *widget)
{
  extern  int format;
  GtkTooltips *tooltips;
  GtkWidget  *window;
  GtkWidget  *decoration;
  GtkWidget  *totalPane;
  GtkWidget  *field0;
  GtkWidget  *field1;
  GtkWidget  *field2;
  GtkWidget  *field3;
  GtkWidget  *field4;
  GtkWidget  *field5;
  GtkWidget  *field6;
  GtkWidget  *key0;
  GtkWidget  *key1;

  void close_techoptions();
  void save_techoptions();

  if (format == 0) {
    error (widget, GINT_TO_POINTER(6));
    return;
  }

                    /* create the tooltip help feature */

  tooltips = gtk_tooltips_new();

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "XBibFile create");
  gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
  gtk_widget_set_usize(GTK_WIDGET(window), 400, 570);
  decoration = gtk_frame_new("Optional Technical Report fields");
  gtk_container_add(GTK_CONTAINER(window), decoration);
  totalPane = gtk_vbox_new(FALSE, 5);
  gtk_container_add(GTK_CONTAINER(decoration), totalPane);

                         /* put the text fields in place */
  field1 = gtk_hbox_new(FALSE, 0);
  data21 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data21), TINY);
  label21 = gtk_label_new("Type:");
  gtk_widget_set_usize(GTK_WIDGET(label21), 75, -1);
  gtk_box_pack_start(GTK_BOX(field1), label21, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field1), data21, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field1, FALSE, TRUE, 10);

  field2 = gtk_hbox_new(FALSE, 0);
  data14 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data14), TINY);
  label14 = gtk_label_new("Number:");
  gtk_widget_set_usize(GTK_WIDGET(label14), 75, -1);
  gtk_box_pack_start(GTK_BOX(field2), label14, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field2), data14, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field2, FALSE, TRUE, 2);

  field3 = gtk_hbox_new(FALSE, 0);
  data1 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data1), LARGE);
  label1 = gtk_label_new("Address:");
  gtk_widget_set_usize(GTK_WIDGET(label1), 75, -1);
  gtk_box_pack_start(GTK_BOX(field3), label1, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field3), data1, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field3, FALSE, TRUE, 2);

  field4 = gtk_hbox_new(FALSE, 0);
  data12 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data12), TINY);
  label12 = gtk_label_new("Month:");
  gtk_widget_set_usize(GTK_WIDGET(label12), 75, -1);
  gtk_box_pack_start(GTK_BOX(field4), label12, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field4), data12, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field4, FALSE, TRUE, 2);

  field5 = gtk_hbox_new(FALSE, 0);
  data22 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data22), LARGE);
  label22 = gtk_label_new("URL:");
  gtk_widget_set_usize(GTK_WIDGET(label22), 75, -1);
  gtk_box_pack_start(GTK_BOX(field5), label22, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field5), data22, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field5, FALSE, TRUE, 2);

  field6 = gtk_hbox_new(FALSE, 0);
  data2 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data2), LARGE);
  label2 = gtk_label_new("note:");
  gtk_widget_set_usize(GTK_WIDGET(label2), 75, -1);
  gtk_box_pack_start(GTK_BOX(field6), label2, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field6), data2, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field6, FALSE, TRUE, 2);

  text13 = gtk_text_buffer_new(NULL);
  data13 = gtk_text_view_new_with_buffer(text13);
  textscroll = gtk_scrolled_window_new(NULL, NULL);
  font_desc = pango_font_description_from_string("Sans 12");
  gtk_widget_modify_font(data13, font_desc);
  gtk_container_add(GTK_CONTAINER(textscroll), data13);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(textscroll),
                                 GTK_POLICY_AUTOMATIC,
				 GTK_POLICY_AUTOMATIC);
  gtk_widget_set_usize(GTK_WIDGET(data13), 30, 250);
  label13 = gtk_label_new("Annotation:");
  gtk_box_pack_start(GTK_BOX(totalPane), label13, FALSE, TRUE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), textscroll, FALSE, TRUE, 2);

                          /* finally, put the cancel button in place */
  field0 = gtk_hbox_new(FALSE, 0);
  key0 = gtk_button_new_with_label("CANCEL");
  gtk_widget_set_usize(GTK_WIDGET(key0), 90, -1);
  g_signal_connect(GTK_OBJECT(key0), "clicked",
                   G_CALLBACK(close_techoptions), NULL);
  gtk_tooltips_set_tip(tooltips, key0,
                       "Discard the contents of this window", NULL);
  gtk_box_pack_end(GTK_BOX(field0), key0, FALSE, FALSE, 10);
  key1 = gtk_button_new_with_label("Save");
  gtk_widget_set_usize(GTK_WIDGET(key1), 90, -1);
  g_signal_connect(GTK_OBJECT(key1), "clicked",
                   G_CALLBACK(save_techoptions), NULL);
  gtk_tooltips_set_tip(tooltips, key1,
                       "Store the contents of this window", NULL);
  gtk_box_pack_end(GTK_BOX(field0), key1, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field0, FALSE, TRUE, 10);

                         /* put the composite window on the screen */
  gtk_widget_show_all(window);
}



/* The procedure to put the basic Technical Report style on the screen */

void techreport(GtkWidget *widget)
{
  GtkTooltips *tooltips;
  GtkWidget  *window;
  GtkWidget  *decoration;
  GtkWidget  *totalPane;
  GtkWidget  *opDecoration;
  GtkWidget  *field0;
  GtkWidget  *field1;
  GtkWidget  *option;
  GtkWidget  *controls;
  GtkWidget  *key1;
  GtkWidget  *key2;
  GtkWidget  *key3;
  GtkWidget  *key4;
  GtkWidget  *field2;
  GtkWidget  *field3;
  GtkWidget  *field4; 
  GtkWidget  *field5;
  extern int  format;
  extern char slate0[];

  extern  void linkwindow();
  extern void closure_check();  /* defined in file cleanup.c */
  extern void close_window();   /* defined in file cleanup.c */
  void  techoptions();
  void  save_techreport();

                         /* create the tooltip help feature */

  tooltips = gtk_tooltips_new();

  format = 13;           /* indicate processing of a TECHREPORT */

                         /* create the wondow and its top panel */
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "XBibFile create");
  gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
  decoration = gtk_frame_new("Technical Report type - required fields");
  gtk_widget_set_usize(GTK_WIDGET(window), 450, 325);
  gtk_container_add(GTK_CONTAINER(window), decoration);
  totalPane = gtk_vbox_new(FALSE, 5);
  gtk_container_add(GTK_CONTAINER(decoration), totalPane);

  field1 = gtk_hbox_new(FALSE,0);
  dataX = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(dataX), SMALL);
  gtk_widget_set_usize(GTK_WIDGET(dataX), 345, -1);
  labelX = gtk_label_new("Tag/s:");
  gtk_widget_set_usize(GTK_WIDGET(labelX), 65, -1);
  gtk_box_pack_start(GTK_BOX(field1), labelX, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field1), dataX, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field1, FALSE, TRUE, 10);

  field0 = gtk_hbox_new(FALSE, 0);
  data0 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data0), LARGE);
  gtk_widget_set_usize(GTK_WIDGET(data0), 345, -1);
  label0 = gtk_label_new("File used:");
  gtk_widget_set_usize(GTK_WIDGET(label0), 65, -1);
  gtk_entry_set_text(GTK_ENTRY(data0), slate0);
  gtk_box_pack_start(GTK_BOX(field0), label0, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field0), data0, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field0, FALSE, TRUE, 2);

                         /* position the remaining field entries */
  field2 = gtk_hbox_new(FALSE, 0);
  data3 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data3), LARGE);
  gtk_widget_set_usize(GTK_WIDGET(data3), 345, -1);
  label3 = gtk_label_new("Author/s:");
  gtk_widget_set_usize(GTK_WIDGET(label3), 65, -1);
  gtk_box_pack_start(GTK_BOX(field2), label3, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field2), data3, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field2, FALSE, TRUE, 8);

  field3 = gtk_hbox_new(FALSE, 0);
  data20 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data20), LARGE);
  gtk_widget_set_usize(GTK_WIDGET(data20), 345, -1);
  label20 = gtk_label_new("Title:");
  gtk_widget_set_usize(GTK_WIDGET(label20), 65, -1);
  gtk_box_pack_start(GTK_BOX(field3), label20, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field3), data20, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field3, FALSE, TRUE, 2);

  field4 = gtk_hbox_new(FALSE, 0);
  data9 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data9), SMALL);
  gtk_widget_set_usize(GTK_WIDGET(data9), 345, -1);
  label9 = gtk_label_new("Institution:");
  gtk_widget_set_usize(GTK_WIDGET(label9), 65, -1);
  gtk_box_pack_start(GTK_BOX(field4), label9, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field4), data9, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field4, FALSE, TRUE, 2);

  field5 = gtk_hbox_new(FALSE, 0);
  data24 = gtk_entry_new();
  gtk_entry_set_max_length(GTK_ENTRY(data24), TINY);
  gtk_widget_set_usize(GTK_WIDGET(data24), 200, -1);
  label24 = gtk_label_new("Year:");
  gtk_widget_set_usize(GTK_WIDGET(label24), 65, -1);
  gtk_box_pack_start(GTK_BOX(field5), label24, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(field5), data24, FALSE, FALSE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), field5, FALSE, TRUE, 2);

                         /* put the control keys on to the window */
  option = gtk_hbox_new(FALSE, 0);
  key2 = gtk_button_new_with_label("Optional fields");
  gtk_widget_set_usize(GTK_WIDGET(key2), 130, -1);
  g_signal_connect(GTK_OBJECT(key2), "clicked",
                   G_CALLBACK(techoptions), NULL);
  gtk_tooltips_set_tip(tooltips, key2,
            "Click here to get window containing remaining Tech Report fields",
                       NULL);
  gtk_box_pack_start(GTK_BOX(option), key2, FALSE, FALSE, 10);
  controls = gtk_hbox_new(FALSE, 0);
  key1 = gtk_button_new_with_label("Save");
  gtk_widget_set_usize(GTK_WIDGET(key1), 90, -1);
  g_signal_connect(GTK_OBJECT(key1), "clicked",
                   G_CALLBACK(save_techreport), NULL);
  gtk_tooltips_set_tip(tooltips, key1,
                       "Store this Tech Report reference in database", NULL);
  gtk_box_pack_start(GTK_BOX(controls), key1, FALSE, FALSE, 30);
  key3 = gtk_button_new_with_label("Cancel");
  gtk_widget_set_usize(GTK_WIDGET(key3), 90, -1);
  g_signal_connect(GTK_OBJECT(key3), "clicked",
                   G_CALLBACK(closure_check), NULL);
  gtk_tooltips_set_tip(tooltips, key3,
                       "Discard this Tech Report entry", NULL);
  gtk_box_pack_start(GTK_BOX(controls), key3, FALSE, FALSE, 30);
  key4 = gtk_button_new_with_label("Linking");
  gtk_widget_set_usize(GTK_WIDGET(key4), 90, -1);
  g_signal_connect(GTK_OBJECT(key4), "clicked",
                   G_CALLBACK(linkwindow), NULL);
  gtk_tooltips_set_tip(tooltips, key4,
                  "Click here for window to create links for this Tech Report",
                        NULL);
  gtk_box_pack_start(GTK_BOX(controls), key4, FALSE, FALSE, 30);
  gtk_box_pack_start(GTK_BOX(totalPane), option, FALSE, TRUE, 10);
  gtk_box_pack_start(GTK_BOX(totalPane), controls, FALSE, TRUE, 10);


  format = 13;

                         /* make the composite visible on screen */
  gtk_widget_show_all(window);
}