gwenhywfar  4.7.0beta
w_textbrowser.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Sun May 16 2010
3  copyright : (C) 2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 
12 
13 
14 static GWENHYWFAR_CB
17  int index,
18  int value,
19  int doSignal) {
20  GtkWidget *g; /* text view */
21  GtkWidget *gs; /* scrollable window */
22 
24  assert(g);
26  assert(gs);
27 
28  switch(prop) {
30  gtk_widget_set_sensitive(GTK_WIDGET(gs), (value==0)?FALSE:TRUE);
31  return 0;
32 
34  gtk_widget_grab_focus(GTK_WIDGET(gs));
35  return 0;
36 
39  /* just ignore these for now */
40  return 0;
41 
42  default:
43  break;
44  }
45 
47  "Function is not appropriate for this type of widget (%s)",
49  return GWEN_ERROR_INVALID;
50 }
51 
52 
53 
54 
55 static GWENHYWFAR_CB
58  int index,
59  int defaultValue) {
60  GtkWidget *g; /* text view */
61  GtkWidget *gs; /* scrollable window */
62 
64  assert(g);
66  assert(gs);
67 
69  assert(g);
70 
71  switch(prop) {
73  return (gtk_widget_get_sensitive(GTK_WIDGET(gs))==TRUE)?1:0;
74 
76  return (gtk_widget_has_focus(GTK_WIDGET(gs))==TRUE)?1:0;
77  return 0;
78 
81  /* just ignore these for now */
82  return 0;
83 
84  default:
85  break;
86  }
87 
89  "Function is not appropriate for this type of widget (%s)",
91  return defaultValue;
92 }
93 
94 
95 
96 static GWENHYWFAR_CB
99  int index,
100  const char *value,
101  int doSignal) {
102  GtkWidget *g; /* text view */
103  GtkWidget *gs; /* scrollable window */
104  GWEN_BUFFER *tbuf;
105 
107  assert(g);
109  assert(gs);
110 
111  tbuf=GWEN_Buffer_new(0, 128, 0, 1);
112  if (value && *value)
113  Gtk2Gui_GetRawText(value, tbuf);
114 
115  switch(prop) {
117  GtkTextBuffer *tb;
118  GtkAdjustment *va;
119 
120  tb=gtk_text_view_get_buffer(GTK_TEXT_VIEW(g));
121  assert(tb);
122  gtk_text_buffer_set_text(tb, GWEN_Buffer_GetStart(tbuf), -1);
123 
124  /* scroll to end */
125  va=gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(gs));
126  if (va)
127  gtk_adjustment_set_value(va, va->upper);
128  GWEN_Buffer_free(tbuf);
129 
130  return 0;
131  }
132  default:
133  break;
134  }
135 
137  "Function is not appropriate for this type of widget (%s)",
139  GWEN_Buffer_free(tbuf);
140  return GWEN_ERROR_INVALID;
141 }
142 
143 
144 
145 static GWENHYWFAR_CB
148  int index,
149  const char *defaultValue) {
150  GtkWidget *g; /* text view */
151  GtkWidget *gs; /* scrollable window */
152 
154  assert(g);
156  assert(gs);
157 
158  switch(prop) {
160  GtkTextBuffer *tb;
161  GtkTextIter startIter;
162  GtkTextIter endIter;
163  gchar *s;
164 
165  tb=gtk_text_view_get_buffer(GTK_TEXT_VIEW(g));
166  assert(tb);
167 
168  gtk_text_buffer_get_start_iter(tb, &startIter);
169  gtk_text_buffer_get_end_iter(tb, &endIter);
170 
171  s=gtk_text_buffer_get_text(tb, &startIter, &endIter, FALSE);
172  if (s) {
174  g_free(s);
176  }
177  return defaultValue;
178  }
179 
180  default:
181  break;
182  }
183 
185  "Function is not appropriate for this type of widget (%s)",
187  return defaultValue;
188 }
189 
190 
191 
193  GtkWidget *gs;
194  GtkWidget *g;
195  const char *s;
196  uint32_t flags;
197  GWEN_WIDGET *wParent;
198 
199  flags=GWEN_Widget_GetFlags(w);
200  wParent=GWEN_Widget_Tree_GetParent(w);
201  s=GWEN_Widget_GetText(w, 0);
202 
203  /* create widget */
204  gs=gtk_scrolled_window_new(NULL, NULL);
205  g=gtk_text_view_new();
206  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(gs), g);
207 
208  if (s && *s) {
209  GWEN_BUFFER *tbuf;
210 
211  tbuf=GWEN_Buffer_new(0, 128, 0, 1);
212  Gtk2Gui_GetRawText(s, tbuf);
213  gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g)), GWEN_Buffer_GetStart(tbuf), -1);
214  GWEN_Buffer_free(tbuf);
215  }
216 
219 
224 
225  if (wParent)
226  GWEN_Widget_AddChildGuiWidget(wParent, w);
227 
228  return 0;
229 }
230 
231