#include <gtk/gtk.h>
#include <liberdm/display.h>
#include <libergtk/ergtk.h>
#include "setupLog.h"
#include "displayStatus.h"
#include "gtkSettingItem.h"
#include "gtkSettingItemTextEntry.h"
Go to the source code of this file.
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
<File description>="">
Definition in file gtkSettingItemTextEntry.c.
| #define LOGPRINTF ST_LOGPRINTF |
Definition at line 41 of file gtkSettingItemTextEntry.c.
| anonymous enum |
Definition at line 43 of file gtkSettingItemTextEntry.c.
00044 { 00045 ENTER_SELECTED, // signals emitted when the user selects enter on the keyboard 00046 LAST_SIGNAL, 00047 };
| void gtk_settingitem_textentry_callback_on_button_press | ( | GtkSettingItemTextEntry * | item, | |
| on_textentry_button_press_t * | callback | |||
| ) |
Definition at line 234 of file gtkSettingItemTextEntry.c.
00235 { 00236 item->callback_on_button_press = callback; 00237 }
| void gtk_settingitem_textentry_callback_on_changed | ( | GtkSettingItemTextEntry * | item, | |
| on_textentry_changed_t * | callback | |||
| ) |
Definition at line 229 of file gtkSettingItemTextEntry.c.
00230 { 00231 item->callback_on_changed = callback; 00232 }
| void gtk_settingitem_textentry_callback_on_validate | ( | GtkSettingItemTextEntry * | item, | |
| on_textentry_validate_t * | callback | |||
| ) |
Definition at line 239 of file gtkSettingItemTextEntry.c.
00240 { 00241 item->callback_on_validate = callback; 00242 }
| static void gtk_settingitem_textentry_class_init | ( | GtkSettingItemTextEntryClass * | klass | ) | [static] |
Definition at line 99 of file gtkSettingItemTextEntry.c.
00100 { 00101 GtkObjectClass *object_class; 00102 00103 object_class = (GtkObjectClass *) klass; 00104 00105 // event to notify page update 00106 00107 settingitem_textentry_signals[ENTER_SELECTED] = 00108 g_signal_new("settingitem_textentry_enter", 00109 G_OBJECT_CLASS_TYPE(object_class), 00110 G_SIGNAL_RUN_LAST, 00111 G_STRUCT_OFFSET(GtkSettingItemTextEntryClass, settingitem_textentry_enter), 00112 NULL, NULL, gtk_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_CHAR); 00113 }
| GType gtk_settingitem_textentry_get_type | ( | void | ) |
Definition at line 75 of file gtkSettingItemTextEntry.c.
00076 { 00077 static GType settingitem_textentry_type = 0; 00078 00079 if (!settingitem_textentry_type) 00080 { 00081 static const GTypeInfo settingitem_textentry_info = { 00082 sizeof(GtkSettingItemTextEntryClass), 00083 NULL, /* base_init */ 00084 NULL, /* base_finalize */ 00085 (GClassInitFunc) gtk_settingitem_textentry_class_init, 00086 NULL, /* class_finalize */ 00087 NULL, /* class_data */ 00088 sizeof(GtkSettingItemTextEntry), 00089 0, /* n_preallocs */ 00090 (GInstanceInitFunc) gtk_settingitem_textentry_init, 00091 }; 00092 00093 settingitem_textentry_type = g_type_register_static(GTK_TYPE_EVENT_BOX, "SettingItemTextEntry", &settingitem_textentry_info, 0); 00094 } 00095 return settingitem_textentry_type; 00096 }

| const gchar* gtk_settingitem_textentry_gettext | ( | GtkSettingItemTextEntry * | item | ) |
Definition at line 214 of file gtkSettingItemTextEntry.c.
00215 { 00216 return gtk_entry_get_text(GTK_ENTRY(item->entry)); 00217 }
| void gtk_settingitem_textentry_grabfocus | ( | GtkSettingItemTextEntry * | item | ) |
Definition at line 244 of file gtkSettingItemTextEntry.c.
00245 { 00246 ST_LOGPRINTF("entry"); 00247 gtk_widget_grab_focus(item->entry); 00248 }
| static void gtk_settingitem_textentry_init | ( | GtkSettingItemTextEntry * | item | ) | [static] |
Definition at line 128 of file gtkSettingItemTextEntry.c.
00129 { 00130 GtkWidget *item_background; 00131 GtkWidget *alignment; 00132 GtkWidget *vbox; 00133 GtkWidget *hbox; 00134 GtkWidget *widget; 00135 00136 gtk_widget_set_size_request(GTK_WIDGET(item), SETTINGITEMTEXT_REQ_WIDTH, SETTINGITEMTEXT_REQ_HEIGHT); 00137 00138 // item_background 00139 item_background = gtk_event_box_new(); 00140 gtk_widget_set_name(GTK_WIDGET(item_background), "settingitem_te_background"); 00141 gtk_container_add(GTK_CONTAINER(item), item_background); 00142 00143 // alignment 00144 alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0); 00145 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00146 SETTINGITEMTEXT_BORDER_TOP, 00147 SETTINGITEMTEXT_BORDER_BOTTOM, 00148 SETTINGITEMTEXT_BORDER_LEFT, 00149 SETTINGITEMTEXT_BORDER_RIGHT ); 00150 gtk_container_add(GTK_CONTAINER(item_background), alignment); 00151 00152 // vbox 00153 vbox = gtk_vbox_new(FALSE, 0); 00154 gtk_widget_set_size_request(vbox, -1, -1); 00155 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00156 00157 // item->label 00158 widget = gtk_label_new(""); 00159 gtk_widget_set_name(widget, "settingitem_te_label"); 00160 gtk_widget_set_size_request(widget, SETTINGITEMTEXT_REQ_WIDTH, SETTINGITEMTEXT_LABEL_HEIGHT); 00161 gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.6); 00162 gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0); 00163 item->label = widget; 00164 00165 // hbox 00166 hbox = gtk_hbox_new(FALSE, SETTINGITEMTEXT_HBOX_SPACING); 00167 gtk_widget_set_size_request(hbox, -1, -1); 00168 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 00169 00170 // item->entry 00171 widget = ergtk_entry_new(); 00172 gtk_widget_set_size_request(widget, SETTINGITEMTEXT_ENTRY_WIDTH, SETTINGITEMTEXT_ENTRY_HEIGHT); 00173 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); 00174 item->entry = widget; 00175 // signal callbacks 00176 g_signal_connect_after( G_OBJECT(widget), "focus-out-event", G_CALLBACK(on_focus_out), item); 00177 g_signal_connect( G_OBJECT(widget), "button-press-event", G_CALLBACK(on_entry_button_press), item); 00178 g_signal_connect_after( G_OBJECT(widget), "changed-stable", G_CALLBACK(on_changed_stable), item); 00179 00180 // item->entry_info 00181 widget = gtk_label_new(""); 00182 gtk_widget_set_name(widget, "settingitem_te_label"); 00183 gtk_widget_set_size_request(widget, -1, SETTINGITEMTEXT_LABEL_HEIGHT); 00184 gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); 00185 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); 00186 item->entry_info = widget; 00187 00188 // display 00189 gtk_widget_show_all(GTK_WIDGET(item)); 00190 00191 // instance-private data 00192 item->callback_on_button_press = NULL; 00193 item->callback_on_changed = NULL; 00194 item->callback_on_validate = NULL; 00195 }

| GtkWidget* gtk_settingitem_textentry_new | ( | void | ) |
Definition at line 65 of file gtkSettingItemTextEntry.c.
00066 { 00067 GtkSettingItemTextEntry *settingItem; 00068 00069 settingItem = (GtkSettingItemTextEntry *) g_object_new(GTK_SETTINGITEM_TEXTENTRY_TYPE, NULL); 00070 00071 return GTK_WIDGET(settingItem); 00072 }
| void gtk_settingitem_textentry_setentrywidth | ( | GtkSettingItemTextEntry * | item, | |
| guint | width | |||
| ) |
Definition at line 224 of file gtkSettingItemTextEntry.c.
00225 { 00226 gtk_widget_set_size_request(GTK_WIDGET(item->entry), width, SETTINGITEMTEXT_ENTRY_HEIGHT); 00227 }
| void gtk_settingitem_textentry_setinfo | ( | GtkSettingItemTextEntry * | item, | |
| const gchar * | text | |||
| ) |
Definition at line 203 of file gtkSettingItemTextEntry.c.
00204 { 00205 gtk_label_set_text(GTK_LABEL(item->entry_info), text); 00206 }
| void gtk_settingitem_textentry_setlabel | ( | GtkSettingItemTextEntry * | item, | |
| const gchar * | text | |||
| ) |
| void gtk_settingitem_textentry_settext | ( | GtkSettingItemTextEntry * | item, | |
| const gchar * | text | |||
| ) |
Definition at line 208 of file gtkSettingItemTextEntry.c.
00209 { 00210 gtk_entry_set_text(GTK_ENTRY(item->entry), text); 00211 on_validate(item); 00212 }

| void gtk_settingitem_textentry_setvisibility | ( | GtkSettingItemTextEntry * | item, | |
| gboolean | visible | |||
| ) |
Definition at line 219 of file gtkSettingItemTextEntry.c.
00220 { 00221 gtk_entry_set_visibility(GTK_ENTRY(item->entry), visible); 00222 }
| static void on_changed_stable | ( | GtkEditable * | widget, | |
| gpointer | data | |||
| ) | [static] |
Definition at line 298 of file gtkSettingItemTextEntry.c.
00299 { 00300 LOGPRINTF("entry"); 00301 00302 GtkSettingItemTextEntry* item = GTK_SETTINGITEM_TEXTENTRY(data); 00303 g_return_if_fail(item != NULL); 00304 00305 // report item text has changed 00306 if (item->callback_on_changed) 00307 { 00308 item->callback_on_changed( GTK_WIDGET(item), 00309 gtk_entry_get_text(GTK_ENTRY(item->entry)) ); 00310 } 00311 }
| static gboolean on_entry_button_press | ( | GtkWidget * | widget, | |
| GdkEventButton * | event, | |||
| gpointer | data | |||
| ) | [static] |
Definition at line 282 of file gtkSettingItemTextEntry.c.
00283 { 00284 LOGPRINTF("entry"); 00285 00286 GtkSettingItemTextEntry* item = GTK_SETTINGITEM_TEXTENTRY(data); 00287 if (IS_GTK_SETTINGITEM_TEXTENTRY(item)) 00288 { 00289 if (item->callback_on_button_press) 00290 { 00291 item->callback_on_button_press( GTK_WIDGET(item) ); 00292 } 00293 } 00294 00295 return FALSE; // continue with GTK signal handling 00296 }
| static gboolean on_focus_out | ( | GtkWidget * | widget, | |
| GdkEventFocus * | event, | |||
| gpointer | data | |||
| ) | [static] |
Definition at line 251 of file gtkSettingItemTextEntry.c.
00252 { 00253 LOGPRINTF("entry"); 00254 00255 // validate & fix content 00256 on_validate( GTK_SETTINGITEM_TEXTENTRY(data) ); 00257 00258 return FALSE; 00259 }

| static void on_validate | ( | GtkSettingItemTextEntry * | item | ) | [static] |
Definition at line 261 of file gtkSettingItemTextEntry.c.
00262 { 00263 LOGPRINTF("entry"); 00264 00265 gchar* new_text = NULL; 00266 00267 // validate & fix content 00268 if (item->callback_on_validate) 00269 { 00270 item->callback_on_validate( GTK_WIDGET(item), 00271 gtk_entry_get_text(GTK_ENTRY(item->entry)), 00272 &new_text ); 00273 if (new_text) 00274 { 00275 gtk_entry_set_text(GTK_ENTRY(item->entry), new_text); 00276 g_free(new_text); 00277 new_text = NULL; 00278 } 00279 } 00280 }
gint settingitem_textentry_signals[LAST_SIGNAL] = { 0 } [static] |
Definition at line 49 of file gtkSettingItemTextEntry.c.
1.5.6