#include <gtk/gtk.h>
#include <libergtk/ergtk.h>
#include <liberdm/display.h>
#include "connectionMgrLog.h"
#include "displayStatus.h"
#include "gtkSettingItem.h"
#include "gtkSettingItemTextEntry.h"
Go to the source code of this file.
<File description>="">
Copyright (C) 2007 iRex Technologies BV.
Definition in file gtkSettingItemTextEntry.c.
#define LOGPRINTF CN_LOGPRINTF |
Definition at line 40 of file gtkSettingItemTextEntry.c.
anonymous enum |
Definition at line 42 of file gtkSettingItemTextEntry.c.
00043 { 00044 // signals emitted when the user selects enter on the keyboard 00045 ENTER_SELECTED, 00046 LAST_SIGNAL, 00047 };
void gtk_settingitem_textentry_callback_on_buttonclicked | ( | GtkSettingItemTextEntry * | item, | |
on_textentry_buttonclicked_t * | callback | |||
) |
Definition at line 308 of file gtkSettingItemTextEntry.c.
00310 { 00311 item->callback_on_buttonclicked = callback; 00312 }
void gtk_settingitem_textentry_callback_on_changed | ( | GtkSettingItemTextEntry * | item, | |
on_textentry_changed_t * | callback | |||
) |
Definition at line 314 of file gtkSettingItemTextEntry.c.
00316 { 00317 item->callback_on_changed = callback; 00318 }
static void gtk_settingitem_textentry_class_init | ( | GtkSettingItemTextEntryClass * | klass | ) | [static] |
Definition at line 108 of file gtkSettingItemTextEntry.c.
00109 { 00110 GtkObjectClass *object_class; 00111 00112 object_class = (GtkObjectClass *) klass; 00113 00114 // event to notify page update 00115 00116 settingitem_textentry_signals[ENTER_SELECTED] = 00117 g_signal_new("settingitem_textentry_enter", 00118 G_OBJECT_CLASS_TYPE(object_class), 00119 G_SIGNAL_RUN_LAST, 00120 G_STRUCT_OFFSET(GtkSettingItemTextEntryClass, 00121 settingitem_textentry_enter), 00122 NULL, 00123 NULL, 00124 gtk_marshal_VOID__STRING, 00125 G_TYPE_NONE, 00126 1, 00127 G_TYPE_CHAR); 00128 }
const gboolean gtk_settingitem_textentry_get_buttonactive | ( | GtkSettingItemTextEntry * | item | ) |
Definition at line 300 of file gtkSettingItemTextEntry.c.
00301 { 00302 g_return_val_if_fail((item->button != NULL), FALSE); 00303 return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item->button)); 00304 }
GType gtk_settingitem_textentry_get_type | ( | void | ) |
Definition at line 81 of file gtkSettingItemTextEntry.c.
00082 { 00083 static GType settingitem_textentry_type = 0; 00084 00085 if (!settingitem_textentry_type) 00086 { 00087 static const GTypeInfo settingitem_textentry_info = { 00088 sizeof(GtkSettingItemTextEntryClass), 00089 NULL, /* base_init */ 00090 NULL, /* base_finalize */ 00091 (GClassInitFunc) gtk_settingitem_textentry_class_init, 00092 NULL, /* class_finalize */ 00093 NULL, /* class_data */ 00094 sizeof(GtkSettingItemTextEntry), 00095 0, /* n_preallocs */ 00096 (GInstanceInitFunc) gtk_settingitem_textentry_init, 00097 }; 00098 00099 settingitem_textentry_type = g_type_register_static(GTK_TYPE_EVENT_BOX, 00100 "SettingItemTextEntry", 00101 &settingitem_textentry_info, 00102 0); 00103 } 00104 return settingitem_textentry_type; 00105 }
const gchar* gtk_settingitem_textentry_gettext | ( | GtkSettingItemTextEntry * | item | ) |
Definition at line 237 of file gtkSettingItemTextEntry.c.
00238 { 00239 return gtk_entry_get_text(GTK_ENTRY(item->entry)); 00240 }
void gtk_settingitem_textentry_grabfocus | ( | GtkSettingItemTextEntry * | item | ) |
static void gtk_settingitem_textentry_init | ( | GtkSettingItemTextEntry * | item | ) | [static] |
Definition at line 143 of file gtkSettingItemTextEntry.c.
00144 { 00145 GtkWidget *item_background; 00146 GtkWidget *alignment; 00147 GtkWidget *vbox; 00148 GtkWidget *hbox; 00149 GtkWidget *widget; 00150 00151 gtk_widget_set_size_request(GTK_WIDGET(item), 00152 SETTINGITEMTEXT_REQ_WIDTH, SETTINGITEMTEXT_REQ_HEIGHT); 00153 00154 // item_background 00155 item_background = gtk_event_box_new(); 00156 gtk_widget_set_name(GTK_WIDGET(item_background), 00157 "settingitem_te_background"); 00158 gtk_container_add(GTK_CONTAINER(item), item_background); 00159 00160 // alignment 00161 alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0); 00162 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00163 SETTINGITEMTEXT_BORDER_TOP, 00164 SETTINGITEMTEXT_BORDER_BOTTOM, 00165 SETTINGITEMTEXT_BORDER_LEFT, 00166 SETTINGITEMTEXT_BORDER_RIGHT ); 00167 gtk_container_add(GTK_CONTAINER(item_background), alignment); 00168 00169 // vbox 00170 vbox = gtk_vbox_new(FALSE, 0); 00171 gtk_widget_set_size_request(vbox, -1, -1); 00172 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00173 00174 // item->label 00175 widget = gtk_label_new(""); 00176 gtk_widget_set_name(widget, "settingitem_te_label"); 00177 gtk_widget_set_size_request(widget, 00178 SETTINGITEMTEXT_REQ_WIDTH, SETTINGITEMTEXT_LABEL_HEIGHT); 00179 gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.6); 00180 gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0); 00181 item->label = widget; 00182 00183 // hbox 00184 hbox = gtk_hbox_new(FALSE, 0); 00185 gtk_widget_set_size_request(hbox, -1, -1); 00186 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 00187 00188 // item->entry 00189 widget = ergtk_entry_new(); 00190 gtk_widget_set_size_request(widget, 00191 SETTINGITEMTEXT_ENTRY_WIDTH, SETTINGITEMTEXT_ENTRY_HEIGHT); 00192 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); 00193 item->entry = widget; 00194 // signal callbacks 00195 g_signal_connect_after(G_OBJECT(widget), "changed-stable", 00196 G_CALLBACK(on_changed), item); 00197 00198 // item->button 00199 widget = ergtk_toggle_button_new_with_label(""); 00200 gtk_widget_set_size_request(widget, 00201 SETTINGITEMTEXT_BUTTON_WIDTH_SMALL, -1); 00202 gtk_box_pack_start(GTK_BOX(hbox), widget, 00203 FALSE, FALSE, SETTINGITEMTEXT_BUTTON_PADDING); 00204 item->button = widget; 00205 // signal callbacks 00206 g_signal_connect_after(G_OBJECT(widget), "toggled", 00207 G_CALLBACK(on_button_toggled), item); 00208 00209 // display 00210 gtk_widget_show_all(GTK_WIDGET(item)); 00211 00212 // instance-private data 00213 item->callback_on_changed = NULL; 00214 }
GtkWidget* gtk_settingitem_textentry_new | ( | gboolean | with_button | ) |
Definition at line 63 of file gtkSettingItemTextEntry.c.
00064 { 00065 GtkSettingItemTextEntry *settingItem; 00066 00067 settingItem = (GtkSettingItemTextEntry *) g_object_new(GTK_SETTINGITEM_TEXTENTRY_TYPE, 00068 NULL); 00069 00070 if (!with_button) 00071 { 00072 // remove button object 00073 gtk_widget_destroy(settingItem->button); 00074 settingItem->button = NULL; 00075 } 00076 00077 return GTK_WIDGET(settingItem); 00078 }
void gtk_settingitem_textentry_set_buttonsize | ( | GtkSettingItemTextEntry * | item, | |
const gboolean | large_button | |||
) |
Definition at line 276 of file gtkSettingItemTextEntry.c.
00278 { 00279 g_return_if_fail(item->button != NULL); 00280 00281 if (large_button) 00282 { 00283 gtk_widget_set_size_request(item->button, 00284 SETTINGITEMTEXT_BUTTON_WIDTH_LARGE, -1); 00285 } 00286 else 00287 { 00288 gtk_widget_set_size_request(item->button, 00289 SETTINGITEMTEXT_BUTTON_WIDTH_SMALL, -1); 00290 } 00291 }
void gtk_settingitem_textentry_set_buttonstate | ( | GtkSettingItemTextEntry * | item, | |
const gboolean | active | |||
) |
Definition at line 293 of file gtkSettingItemTextEntry.c.
00295 { 00296 g_return_if_fail(item->button != NULL); 00297 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item->button), active); 00298 }
void gtk_settingitem_textentry_set_buttontext | ( | GtkSettingItemTextEntry * | item, | |
const gchar * | text | |||
) |
Definition at line 269 of file gtkSettingItemTextEntry.c.
00271 { 00272 g_return_if_fail(item->button != NULL); 00273 gtk_button_set_label(GTK_BUTTON(item->button), text); 00274 }
void gtk_settingitem_textentry_setlabel | ( | GtkSettingItemTextEntry * | item, | |
const gchar * | text | |||
) |
Definition at line 225 of file gtkSettingItemTextEntry.c.
00227 { 00228 gtk_label_set_text(GTK_LABEL(item->label), text); 00229 }
void gtk_settingitem_textentry_setsensitive | ( | GtkSettingItemTextEntry * | item, | |
gboolean | sensitive | |||
) |
Definition at line 248 of file gtkSettingItemTextEntry.c.
00250 { 00251 gtk_widget_set_sensitive(item->entry, sensitive); 00252 }
void gtk_settingitem_textentry_settext | ( | GtkSettingItemTextEntry * | item, | |
const gchar * | text | |||
) |
Definition at line 231 of file gtkSettingItemTextEntry.c.
00233 { 00234 gtk_entry_set_text(GTK_ENTRY(item->entry), text); 00235 }
void gtk_settingitem_textentry_setvisibility | ( | GtkSettingItemTextEntry * | item, | |
gboolean | visible | |||
) |
Definition at line 242 of file gtkSettingItemTextEntry.c.
00244 { 00245 gtk_entry_set_visibility(GTK_ENTRY(item->entry), visible); 00246 }
void gtk_settingitem_textentry_show_button | ( | GtkSettingItemTextEntry * | item, | |
const gboolean | show | |||
) |
Definition at line 254 of file gtkSettingItemTextEntry.c.
00256 { 00257 g_return_if_fail(item->button != NULL); 00258 00259 if (show) 00260 { 00261 gtk_widget_show(item->button); 00262 } 00263 else 00264 { 00265 gtk_widget_hide(item->button); 00266 } 00267 }
static void on_button_toggled | ( | GtkToggleButton * | button, | |
gpointer | data | |||
) | [static] |
Definition at line 350 of file gtkSettingItemTextEntry.c.
00351 { 00352 LOGPRINTF("entry"); 00353 00354 GtkSettingItemTextEntry* item = GTK_SETTINGITEM_TEXTENTRY(data); 00355 g_return_if_fail(item != NULL); 00356 00357 gboolean active; 00358 00359 // inform user that button has changed 00360 if (item->callback_on_buttonclicked) 00361 { 00362 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); 00363 item->callback_on_buttonclicked(GTK_WIDGET(item), active); 00364 } 00365 }
static void on_changed | ( | GtkEntry * | widget, | |
gpointer | data | |||
) | [static] |
Definition at line 334 of file gtkSettingItemTextEntry.c.
00335 { 00336 LOGPRINTF("entry"); 00337 00338 GtkSettingItemTextEntry* item = GTK_SETTINGITEM_TEXTENTRY(data); 00339 g_return_if_fail(item != NULL); 00340 00341 // item text is stable: inform application and update screen 00342 send_button_press(item); 00343 if (item->callback_on_changed) 00344 { 00345 item->callback_on_changed( GTK_WIDGET(data), 00346 gtk_entry_get_text(GTK_ENTRY(item->entry)) ); 00347 } 00348 }
static void send_button_press | ( | GtkSettingItemTextEntry * | item | ) | [static] |
Definition at line 320 of file gtkSettingItemTextEntry.c.
00321 { 00322 LOGPRINTF("entry"); 00323 00324 // simulate button-press-event 00325 static GdkEventButton event; 00326 event.type = GDK_BUTTON_PRESS; 00327 gboolean result = FALSE; 00328 g_signal_emit_by_name(item, "button-press-event", GTK_WIDGET(item), 00329 &event, NULL, &result); 00330 }
gint settingitem_textentry_signals[LAST_SIGNAL] = { 0 } [static] |
Definition at line 49 of file gtkSettingItemTextEntry.c.