gwenhywfar  4.7.0beta
w_pushbutton.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  GtkButton *g;
21 
23  assert(g);
24 
25  switch(prop) {
27  gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
28  return 0;
29 
31  gtk_widget_grab_focus(GTK_WIDGET(g));
32  return 0;
33 
36  /* just ignore these for now */
37  return 0;
38 
39  default:
40  break;
41  }
42 
44  "Function is not appropriate for this type of widget (%s)",
46  return GWEN_ERROR_INVALID;
47 }
48 
49 
50 
51 
52 static GWENHYWFAR_CB
55  int index,
56  int defaultValue) {
57  GtkButton *g;
58 
60  assert(g);
61 
62  switch(prop) {
64  return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
65 
67  return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
68  return 0;
69 
72  /* just ignore these for now */
73  return 0;
74 
75  default:
76  break;
77  }
78 
80  "Function is not appropriate for this type of widget (%s)",
82  return defaultValue;
83 }
84 
85 
86 
87 static GWENHYWFAR_CB
90  int index,
91  const char *value,
92  int doSignal) {
93  GtkButton *g;
94 
96  assert(g);
97 
98  switch(prop) {
100  gtk_button_set_label(g, value);
101  return 0;
102  default:
103  break;
104  }
105 
107  "Function is not appropriate for this type of widget (%s)",
109  return GWEN_ERROR_INVALID;
110 }
111 
112 
113 
114 static GWENHYWFAR_CB
117  int index,
118  const char *defaultValue) {
119  GtkButton *g;
120 
122  assert(g);
123 
124  switch(prop) {
126  return gtk_button_get_label(g);
127  default:
128  break;
129  }
130 
132  "Function is not appropriate for this type of widget (%s)",
134  return defaultValue;
135 }
136 
137 
138 
139 static void Gtk2Gui_WPushButton_Clicked_handler(GtkButton *button, gpointer data) {
140  GWEN_WIDGET *w;
141  int rv;
142 
143  w=data;
144  assert(w);
150  else if (rv==GWEN_DialogEvent_ResultReject)
152 }
153 
154 
155 
157  GtkWidget *g;
158  const char *s;
159  uint32_t flags;
160  GWEN_WIDGET *wParent;
161  gulong clicked_handler_id;
162 
163  flags=GWEN_Widget_GetFlags(w);
164  wParent=GWEN_Widget_Tree_GetParent(w);
165  s=GWEN_Widget_GetText(w, 0);
166 
167  /* create widget */
168  if (s && *s)
169  g=gtk_button_new_with_mnemonic(s);
170  else
171  g=gtk_button_new();
172 
174  if (s && *s) {
175  GWEN_STRINGLIST *sl;
176 
178  if (sl) {
179  int rv;
180  GWEN_BUFFER *tbuf;
181 
182  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
183  rv=GWEN_Directory_FindFileInPaths(sl, s, tbuf);
184  if (rv<0) {
185  DBG_ERROR(GWEN_LOGDOMAIN, "Image file [%s] not found (%d)", s, rv);
186  /* ignore result here, instead create GtkImage with "broken mage" later */
187  }
188  else {
189  GtkWidget *gImage;
190 
191  gImage=gtk_image_new_from_file(GWEN_Buffer_GetStart(tbuf));
192  gtk_button_set_image(GTK_BUTTON(g), gImage);
193  gtk_button_set_image_position(GTK_BUTTON(g), GTK_POS_LEFT);
194  }
195  GWEN_Buffer_free(tbuf);
196  }
197  }
198 
201 
206 
207  clicked_handler_id=g_signal_connect(g,
208  "clicked",
210  w);
211 
212  if (wParent)
213  GWEN_Widget_AddChildGuiWidget(wParent, w);
214 
215  return 0;
216 }
217 
218