gwenhywfar  5.10.1
gtk3/w_lineedit.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  GWEN_UNUSED int index,
18  int value,
19  GWEN_UNUSED int doSignal)
20 {
21  GtkWidget *g;
22 
24  assert(g);
25 
26  switch (prop) {
28  gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
29  return 0;
30 
32  gtk_widget_grab_focus(GTK_WIDGET(g));
33  return 0;
34 
37  /* just ignore these for now */
38  return 0;
39 
40  default:
41  break;
42  }
43 
45  "Function is not appropriate for this type of widget (%s)",
47  return GWEN_ERROR_INVALID;
48 }
49 
50 
51 
52 
53 static GWENHYWFAR_CB
56  GWEN_UNUSED int index,
57  int defaultValue)
58 {
59  GtkWidget *g;
60 
62  assert(g);
63 
64  switch (prop) {
66  return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
67 
69  return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
70  return 0;
71 
74  /* just ignore these for now */
75  return 0;
76 
77  default:
78  break;
79  }
80 
82  "Function is not appropriate for this type of widget (%s)",
84  return defaultValue;
85 }
86 
87 
88 
89 static GWENHYWFAR_CB
92  GWEN_UNUSED int index,
93  const char *value,
94  GWEN_UNUSED int doSignal)
95 {
96  GtkWidget *g;
97 
99  assert(g);
100 
101  switch (prop) {
103  if (value && *value)
104  gtk_entry_set_text(GTK_ENTRY(g), value);
105  return 0;
106  default:
107  break;
108  }
109 
111  "Function is not appropriate for this type of widget (%s)",
113  return GWEN_ERROR_INVALID;
114 }
115 
116 
117 
118 static GWENHYWFAR_CB
121  GWEN_UNUSED int index,
122  const char *defaultValue)
123 {
124  GtkWidget *g;
125 
127  assert(g);
128 
129  switch (prop) {
131  return gtk_entry_get_text(GTK_ENTRY(g));
132  default:
133  break;
134  }
135 
137  "Function is not appropriate for this type of widget (%s)",
139  return defaultValue;
140 }
141 
142 
143 
144 static void Gtk3Gui_WLineEdit_Deleted_text_handler(GWEN_UNUSED GtkEntryBuffer *entrybuffer,
145  GWEN_UNUSED guint arg1,
146  GWEN_UNUSED guint arg2,
147  gpointer data)
148 {
149  GWEN_WIDGET *w;
150  int rv;
151 
152  w=data;
153  assert(w);
159  else if (rv==GWEN_DialogEvent_ResultReject)
161 }
162 
163 
164 
165 static void Gtk3Gui_WLineEdit_Inserted_text_handler(GWEN_UNUSED GtkEntryBuffer *entrybuffer,
166  GWEN_UNUSED guint arg1,
167  GWEN_UNUSED gchar *arg2,
168  GWEN_UNUSED guint arg3,
169  gpointer data)
170 {
171  GWEN_WIDGET *w;
172  int rv;
173 
174  w=data;
175  assert(w);
181  else if (rv==GWEN_DialogEvent_ResultReject)
183 }
184 
185 
186 
188 {
189  GtkWidget *g;
190  const char *s;
191  uint32_t flags;
192  GWEN_WIDGET *wParent;
193  gboolean text_is_visible;
194 
195  flags=GWEN_Widget_GetFlags(w);
196  text_is_visible = (flags & GWEN_WIDGET_FLAGS_PASSWORD) == 0;
197  wParent=GWEN_Widget_Tree_GetParent(w);
198  s=GWEN_Widget_GetText(w, 0);
199 
200  /* create widget */
201  g=gtk_entry_new();
202  if (s && *s)
203  gtk_entry_set_text(GTK_ENTRY(g), s);
204  gtk_entry_set_visibility(GTK_ENTRY(g), text_is_visible);
205 
208 
213 
214  g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
215  "deleted-text",
217  w);
218 
219  g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
220  "inserted-text",
222  w);
223 
224  if (wParent)
225  GWEN_Widget_AddChildGuiWidget(wParent, w);
226 
227  return 0;
228 }
229 
230 
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition: widget.c:185
int Gtk3Gui_WLineEdit_Setup(GWEN_WIDGET *w)
#define GWEN_ERROR_INVALID
Definition: error.h:67
#define GTK3_DIALOG_WIDGET_REAL
#define GTK3_DIALOG_WIDGET_CONTENT
const char * GWEN_Widget_GetName(const GWEN_WIDGET *w)
Definition: widget.c:320
GWEN_WIDGET_SETCHARPROPERTY_FN GWEN_Widget_SetSetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETCHARPROPERTY_FN fn)
Definition: widget.c:717
GWEN_WIDGET_GETCHARPROPERTY_FN GWEN_Widget_SetGetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETCHARPROPERTY_FN fn)
Definition: widget.c:732
GWEN_DIALOG_PROPERTY
Definition: dialog.h:260
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
#define DBG_WARN(dbg_logger, format, args...)
Definition: debug.h:125
#define GWEN_LOGDOMAIN
Definition: logger.h:35
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
static GWENHYWFAR_CB int Gtk3Gui_WLineEdit_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int defaultValue)
GWEN_WIDGET_GETINTPROPERTY_FN GWEN_Widget_SetGetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETINTPROPERTY_FN fn)
Definition: widget.c:702
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
GWEN_DIALOG * GWEN_Widget_GetDialog(const GWEN_WIDGET *w)
Definition: widget.c:92
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
#define GWEN_WIDGET_FLAGS_PASSWORD
Definition: dialog.h:64
GWEN_WIDGET_SETINTPROPERTY_FN GWEN_Widget_SetSetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETINTPROPERTY_FN fn)
Definition: widget.c:687
GWEN_DIALOG * GWEN_Widget_GetTopDialog(const GWEN_WIDGET *w)
Definition: widget.c:102
static GWENHYWFAR_CB int Gtk3Gui_WLineEdit_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int value, GWEN_UNUSED int doSignal)
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:828
int GWEN_Dialog_EmitSignal(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
Definition: dialog.c:321
static GWENHYWFAR_CB int Gtk3Gui_WLineEdit_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *value, GWEN_UNUSED int doSignal)
static GWENHYWFAR_CB const char * Gtk3Gui_WLineEdit_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *defaultValue)
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition: widget.c:452
static void Gtk3Gui_WLineEdit_Deleted_text_handler(GWEN_UNUSED GtkEntryBuffer *entrybuffer, GWEN_UNUSED guint arg1, GWEN_UNUSED guint arg2, gpointer data)
void Gtk3Gui_Dialog_Leave(GWEN_DIALOG *dlg, int result)
static void Gtk3Gui_WLineEdit_Inserted_text_handler(GWEN_UNUSED GtkEntryBuffer *entrybuffer, GWEN_UNUSED guint arg1, GWEN_UNUSED gchar *arg2, GWEN_UNUSED guint arg3, gpointer data)
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition: widget.c:293
#define GWEN_UNUSED