reindent some functions
[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 Widget tagsShell, editTagsShell;
60
61 #ifdef ENABLE_NLS
62 # define  _(s) gettext (s)
63 # define N_(s) gettext_noop (s)
64 #else
65 # define  _(s) (s)
66 # define N_(s)  s
67 #endif
68
69 void 
70 TagsPopDown()
71 {
72   return;
73 }
74
75 void 
76 TagsPopUp(char *tags, char *msg)
77 {
78   EditTagsPopUp(tags);
79   return;
80 }
81
82
83 //void EditTagsCallback(w, client_data, call_data)
84 //     Widget w;
85 //     XtPointer client_data, call_data;
86 //{
87 //    String name, val;
88 //    Arg args[16];
89 //    int j;
90 //    Widget textw;
91 //
92 //    j = 0;
93 //    XtSetArg(args[j], XtNlabel, &name);  j++;
94 //    XtGetValues(w, args, j);
95 //    
96 //
97 //    if (strcmp(name, _("ok")) == 0) {
98 //    /* ok: get values, update, close */
99 //      textw = XtNameToWidget(editTagsShell, "*form.text");
100 //      j = 0;
101 //      XtSetArg(args[j], XtNstring, &val); j++;
102 //      XtGetValues(textw, args, j);
103 //      ReplaceTags(val, &gameInfo);
104 //      TagsPopDown();
105 //    } else if (strcmp(name, _("cancel")) == 0) {
106 //      /* close */
107 //      TagsPopDown();
108 //    } else if (strcmp(name, _("clear")) == 0) {
109 //      /* clear all */
110 //      textw = XtNameToWidget(editTagsShell, "*form.text");
111 //      XtCallActionProc(textw, "select-all", NULL, NULL, 0);
112 //      XtCallActionProc(textw, "kill-selection", NULL, NULL, 0);
113 //    }
114 //}
115
116
117 void 
118 EditTagsPopUp(tags)
119      char *tags;
120 {
121   GtkWidget *label;  
122   
123   /* add the text to the dialog */
124   
125   label = gtk_label_new (tags);
126
127   /* remove old tags that we already added */
128   gtk_container_foreach(GTK_CONTAINER (GUI_EditTagsTextArea),G_CALLBACK (gtk_widget_destroy),NULL);
129   
130   /* TODO replace this with a version where you can edit and a callback for the edit button that saves the new tags*/
131   gtk_container_add (GTK_CONTAINER (GUI_EditTagsTextArea), label);
132   
133   /* realize widget */
134   gtk_widget_show_all (GUI_EditTags);
135
136   return;
137 }
138
139 void
140 EditTagsProc(object, user_data)
141      GtkObject *object;
142      gpointer user_data;
143 {
144   /* always call EditTagsEvent, which calls the function to popup the window */
145   EditTagsEvent();
146   return;
147 }
148
149 void
150 EditTagsHideProc(object, user_data)
151      GtkObject *object;
152      gpointer user_data;
153 {
154   /* hide everything */
155   gtk_widget_hide_all(GUI_EditTags);
156   return;
157 }