updated version number
[xboard.git] / xedittags.c
1 /*
2  * xedittags.c -- Tags edit window, part of X front end for XBoard
3  *
4  * Copyright 1995,2009 Free Software Foundation, Inc.
5  *
6  * ------------------------------------------------------------------------
7  *
8  * GNU XBoard 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 3 of the License, or (at
11  * your option) any later version.
12  *
13  * GNU XBoard is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see http://www.gnu.org/licenses/.  *
20  *
21  *------------------------------------------------------------------------
22  ** See the file ChangeLog for a revision history.  */
23
24 #include "config.h"
25
26 #include <stdio.h>
27 #include <ctype.h>
28 #include <errno.h>
29 #include <sys/types.h>
30 #include <gtk/gtk.h>
31
32
33 #if STDC_HEADERS
34 # include <stdlib.h>
35 # include <string.h>
36 #else /* not STDC_HEADERS */
37 extern char *getenv();
38 # if HAVE_STRING_H
39 #  include <string.h>
40 # else /* not HAVE_STRING_H */
41 #  include <strings.h>
42 # endif /* not HAVE_STRING_H */
43 #endif /* not STDC_HEADERS */
44
45 #if HAVE_UNISTD_H
46 # include <unistd.h>
47 #endif
48
49 #include "common.h"
50 #include "frontend.h"
51 #include "backend.h"
52 #include "xboard.h"
53 #include "xedittags.h"
54 #include "gettext.h"
55
56 extern GtkWidget               *GUI_EditTags;
57 extern GtkWidget               *GUI_EditTagsTextArea;
58
59
60 #ifdef ENABLE_NLS
61 # define  _(s) gettext (s)
62 # define N_(s) gettext_noop (s)
63 #else
64 # define  _(s) (s)
65 # define N_(s)  s
66 #endif
67
68 void 
69 TagsPopDown()
70 {
71   return;
72 }
73
74 void 
75 TagsPopUp(char *tags, char *msg)
76 {
77   EditTagsPopUp(tags);
78   return;
79 }
80
81
82 //void EditTagsCallback(w, client_data, call_data)
83 //     Widget w;
84 //     XtPointer client_data, call_data;
85 //{
86 //    String name, val;
87 //    Arg args[16];
88 //    int j;
89 //    Widget textw;
90 //
91 //    j = 0;
92 //    XtSetArg(args[j], XtNlabel, &name);  j++;
93 //    XtGetValues(w, args, j);
94 //    
95 //
96 //    if (strcmp(name, _("ok")) == 0) {
97 //    /* ok: get values, update, close */
98 //      textw = XtNameToWidget(editTagsShell, "*form.text");
99 //      j = 0;
100 //      XtSetArg(args[j], XtNstring, &val); j++;
101 //      XtGetValues(textw, args, j);
102 //      ReplaceTags(val, &gameInfo);
103 //      TagsPopDown();
104 //    } else if (strcmp(name, _("cancel")) == 0) {
105 //      /* close */
106 //      TagsPopDown();
107 //    } else if (strcmp(name, _("clear")) == 0) {
108 //      /* clear all */
109 //      textw = XtNameToWidget(editTagsShell, "*form.text");
110 //      XtCallActionProc(textw, "select-all", NULL, NULL, 0);
111 //      XtCallActionProc(textw, "kill-selection", NULL, NULL, 0);
112 //    }
113 //}
114
115
116 void 
117 EditTagsPopUp(tags)
118      char *tags;
119 {
120   GtkWidget *label;  
121   
122   /* add the text to the dialog */
123   
124   label = gtk_label_new (tags);
125
126   /* remove old tags that we already added */
127   gtk_container_foreach(GTK_CONTAINER (GUI_EditTagsTextArea),G_CALLBACK (gtk_widget_destroy),NULL);
128   
129   /* TODO replace this with a version where you can edit and a callback for the edit button that saves the new tags*/
130   gtk_container_add (GTK_CONTAINER (GUI_EditTagsTextArea), label);
131   
132   /* realize widget */
133   gtk_widget_show_all (GUI_EditTags);
134
135   return;
136 }
137
138 void
139 EditTagsProc(object, user_data)
140      GtkObject *object;
141      gpointer user_data;
142 {
143   /* always call EditTagsEvent, which calls the function to popup the window */
144   EditTagsEvent();
145   return;
146 }
147
148 void
149 EditTagsHideProc(object, user_data)
150      GtkObject *object;
151      gpointer user_data;
152 {
153   /* hide everything */
154   gtk_widget_hide_all(GUI_EditTags);
155   return;
156 }