#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <liberdm/display.h>
#include <libergtk/ergtk.h>
#include <liberregxml/erregapi.h>
#include "setupLog.h"
#include "displayStatus.h"
#include "gtkSettingItem.h"
#include "iLiadStartUpData.h"
#include "iLiadStartUpScreen.h"
#include "iLiadConfigData.h"
#include "settings.h"
#include "languages.h"
Go to the source code of this file.
Functions | |
| static GtkWidget * | gtk_behaviour_new (gtkBehaviour_t *behaviour) |
| static GtkWidget * | gtk_calibration_new (gtkCalibration_t *calibration) |
| static void | on_selection_update (erGtkSelectionGroup *selection, gpointer button, gpointer data) |
| static void | on_calibration_button_toggled_event (GtkToggleButton *button, gpointer data) |
| GtkWidget * | iLiad_startup_screen_create (void) |
| void | iLiad_startup_screen_set_text (void) |
| void | iLiad_startup_screen_display_data (void) |
| pid_t | get_xtscal_pid () |
| void | handle_xtscal_quit () |
| void | stop_xtscal () |
Variables | |
| struct { | |
| const gchar * text | |
| const startup_behaviour_t behaviour | |
| const gchar * document_path | |
| } | g_button_info [STARTUP_BUTTON_NUMBER] |
| static gtkStartUp_t | g_startup |
| static pid_t | g_xtscal_pid = 0 |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
Providing GUI interface to let users input their customized startup behaviour.
Definition in file iLiadStartUpScreen.c.
| pid_t get_xtscal_pid | ( | ) |
| static GtkWidget * gtk_behaviour_new | ( | gtkBehaviour_t * | behaviour | ) | [static] |
Definition at line 128 of file iLiadStartUpScreen.c.
00129 { 00130 GtkWidget* item; 00131 GtkWidget* background; 00132 GtkWidget *alignment; 00133 GtkWidget* vbox1, *vbox2, *vbox3; 00134 GtkWidget* label; 00135 GtkWidget* hbox; 00136 GtkWidget* button; 00137 GtkWidget* selection; 00138 GtkToggleButton* button_tbl[STARTUP_BUTTON_NUMBER + 1]; 00139 gint i; 00140 00141 ST_LOGPRINTF("entry"); 00142 g_return_val_if_fail(NULL != behaviour, NULL); 00143 00144 // item 00145 item = gtk_settingitem_new(""); 00146 gtk_widget_set_size_request(item, -1, -1); 00147 behaviour->item = item; 00148 00149 // background 00150 background = gtk_event_box_new(); 00151 gtk_widget_set_name(background, "startup_behaviour_background"); 00152 gtk_widget_set_size_request(background, TITLE_MIN_WIDTH, STARTUP_BEHAVIOUR_HEIGHT); 00153 gtk_settingitem_add_details(GTK_SETTINGITEM(item), background); 00154 00155 // alignment 00156 alignment = gtk_alignment_new(0, 0, 0, 0); 00157 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00158 STARTUP_ITEM_PADDING_TOP, STARTUP_ITEM_PADDING_BOTTOM, 00159 STARTUP_ITEM_PADDING_LEFT, STARTUP_ITEM_PADDING_RIGHT); 00160 gtk_container_add(GTK_CONTAINER(background), alignment); 00161 00162 // vbox1 00163 vbox1 = gtk_vbox_new(FALSE, STARTUP_ITEM_SPACING*3); 00164 gtk_container_add(GTK_CONTAINER(alignment), vbox1); 00165 00166 // label 00167 label = gtk_label_new(""); 00168 gtk_box_pack_start(GTK_BOX(vbox1), label, FALSE, FALSE, 0); 00169 gtk_widget_set_name(label, "startup_info_text"); 00170 gtk_widget_set_size_request(label, STARTUP_LABEL_WIDTH, (-1)); 00171 gtk_label_set_single_line_mode(GTK_LABEL(label), FALSE); 00172 gtk_label_set_line_wrap(GTK_LABEL(label), FALSE); 00173 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); 00174 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); 00175 behaviour->label = label; 00176 00177 // hbox 00178 hbox = gtk_hbox_new(FALSE, (STARTUP_LABEL_WIDTH - STARTUP_BUTTON_WIDTH * 2) / 2); 00179 gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0); 00180 00181 // vbox2 00182 vbox2 = gtk_vbox_new(FALSE, STARTUP_ITEM_SPACING*2); 00183 gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0); 00184 00185 // vbox3 00186 vbox3 = gtk_vbox_new(FALSE, STARTUP_ITEM_SPACING*2); 00187 gtk_box_pack_start(GTK_BOX(hbox), vbox3, FALSE, FALSE, 0); 00188 00189 // buttons 00190 for (i = 0; i < STARTUP_BUTTON_NUMBER; i++) 00191 { 00192 button = ergtk_toggle_button_new_with_label(""); 00193 gtk_widget_set_size_request(GTK_WIDGET(button), STARTUP_BUTTON_WIDTH, STARTUP_BUTTON_HEIGHT); 00194 if (i <= 4) 00195 { 00196 gtk_box_pack_start(GTK_BOX(vbox2), GTK_WIDGET(button), FALSE, FALSE, 0); 00197 } 00198 else 00199 { 00200 gtk_box_pack_start(GTK_BOX(vbox3), GTK_WIDGET(button), FALSE, FALSE, 0); 00201 } 00202 button_tbl[i] = GTK_TOGGLE_BUTTON(button); 00203 behaviour->buttons[i] = GTK_WIDGET(button); 00204 } 00205 button_tbl[i] = NULL; 00206 00207 // selection group not part of widget hierarchy 00208 selection = ergtk_selection_group_new(button_tbl); 00209 ergtk_selection_group_set_details(ERGTK_SELECTION_GROUP(selection), 1, 1); 00210 g_signal_connect(G_OBJECT(selection), "selection-update", G_CALLBACK(on_selection_update), &g_startup); 00211 behaviour->selection = selection; 00212 00213 // show widgets 00214 gtk_widget_show_all(background); 00215 gtk_widget_show(item); 00216 00217 return item; 00218 }

| static GtkWidget * gtk_calibration_new | ( | gtkCalibration_t * | calibration | ) | [static] |
Definition at line 228 of file iLiadStartUpScreen.c.
00229 { 00230 GtkWidget* item; 00231 GtkWidget* background; 00232 GtkWidget* alignment; 00233 GtkWidget* vbox; 00234 GtkWidget* hbox; 00235 GtkWidget* label; 00236 GtkWidget* button; 00237 00238 ST_LOGPRINTF("entry"); 00239 g_return_val_if_fail(NULL != calibration, NULL); 00240 00241 // item 00242 item = gtk_settingitem_new(""); 00243 gtk_widget_set_size_request(item, -1, -1); 00244 calibration->item = item; 00245 00246 // background 00247 background = gtk_event_box_new(); 00248 gtk_widget_set_name(background, "startup_calibration_background"); 00249 gtk_widget_set_size_request(background, TITLE_MIN_WIDTH, STARTUP_CALIBRATION_HEIGHT); 00250 gtk_settingitem_add_details(GTK_SETTINGITEM(item), background); 00251 00252 // alignment 00253 alignment = gtk_alignment_new(0, 0, 0, 0); 00254 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00255 STARTUP_ITEM_PADDING_TOP, STARTUP_ITEM_PADDING_BOTTOM, 00256 STARTUP_ITEM_PADDING_LEFT, STARTUP_ITEM_PADDING_RIGHT); 00257 gtk_container_add(GTK_CONTAINER(background), alignment); 00258 00259 // vbox 00260 vbox = gtk_vbox_new(FALSE, STARTUP_ITEM_SPACING*3); 00261 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00262 00263 // label 00264 label = gtk_label_new(""); 00265 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 00266 gtk_widget_set_name(label, "startup_info_text"); 00267 gtk_widget_set_size_request(label, STARTUP_LABEL_WIDTH, (-1)); 00268 gtk_label_set_single_line_mode(GTK_LABEL(label), FALSE); 00269 gtk_label_set_line_wrap(GTK_LABEL(label), FALSE); 00270 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); 00271 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); 00272 calibration->label = label; 00273 00274 hbox = gtk_hbox_new(FALSE, 0); 00275 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 0); 00276 00277 // button 00278 button = ergtk_toggle_button_new_with_label(""); 00279 gtk_widget_set_size_request(GTK_WIDGET(button), STARTUP_BUTTON_WIDTH, STARTUP_BUTTON_HEIGHT); 00280 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), FALSE, FALSE, 0); 00281 g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(on_calibration_button_toggled_event), NULL); 00282 calibration->button = GTK_WIDGET(button); 00283 00284 // show widgets 00285 gtk_widget_show_all(background); 00286 gtk_widget_show(item); 00287 00288 return item; 00289 }

| void handle_xtscal_quit | ( | ) |
Definition at line 385 of file iLiadStartUpScreen.c.
00386 { 00387 // Remember child process gone 00388 g_xtscal_pid = 0; 00389 00390 // Refresh screen 00391 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_startup.calibration.button), FALSE); 00392 // display_update_request_screen_refresh(MAIN_WINDOW_EXPOSE_LEVEL, WAVEFORM_FULLSCREEN); 00393 }
| GtkWidget* iLiad_startup_screen_create | ( | void | ) |
Definition at line 85 of file iLiadStartUpScreen.c.
00086 { 00087 GtkWidget *vbox; 00088 GtkWidget *behaviour; 00089 GtkWidget *calibration; 00090 00091 ST_LOGPRINTF("entry"); 00092 00093 memset(&g_startup, 0, sizeof(gtkStartUp_t)); 00094 00095 vbox = gtk_vbox_new(FALSE, STARTUP_ITEM_SPACING); 00096 g_startup.widget = vbox; 00097 00098 behaviour = gtk_behaviour_new(&(g_startup.behaviour)); 00099 gtk_box_pack_start(GTK_BOX(vbox), behaviour, FALSE, FALSE, 0); 00100 00101 calibration = gtk_calibration_new(&(g_startup.calibration)); 00102 gtk_box_pack_start(GTK_BOX(vbox), calibration, FALSE, FALSE, 0); 00103 00104 // show widgets 00105 gtk_widget_show(vbox); 00106 00107 return vbox; 00108 }

| void iLiad_startup_screen_display_data | ( | void | ) |
Definition at line 315 of file iLiadStartUpScreen.c.
00316 { 00317 startup_behaviour_t behaviour; 00318 GtkWidget* button; 00319 int i; 00320 00321 ST_LOGPRINTF("entry"); 00322 00323 behaviour = iLiad_startup_data_get_behaviour(); 00324 for (i = 0 ; i < STARTUP_BUTTON_NUMBER ; i++) 00325 { 00326 if (g_button_info[i].behaviour == behaviour) 00327 { 00328 button = g_startup.behaviour.buttons[i]; 00329 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); 00330 gtk_widget_grab_focus(button); 00331 } 00332 } 00333 }

| void iLiad_startup_screen_set_text | ( | void | ) |
Definition at line 291 of file iLiadStartUpScreen.c.
00292 { 00293 ST_LOGPRINTF("entry"); 00294 int i; 00295 00296 if (g_startup.widget) 00297 { 00298 gtkBehaviour_t* behaviour = &(g_startup.behaviour); 00299 gtkCalibration_t* calibration = &(g_startup.calibration); 00300 00301 gtk_settingitem_set_header_text(GTK_SETTINGITEM(behaviour->item), _("Start-up Settings")); 00302 gtk_label_set_text(GTK_LABEL(behaviour->label), _("Please select what to open when starting up your iLiad.")); 00303 00304 for (i = 0; i < STARTUP_BUTTON_NUMBER; i++) 00305 { 00306 gtk_button_set_label( GTK_BUTTON(behaviour->buttons[i]), _(g_button_info[i].text) ); 00307 } 00308 00309 gtk_settingitem_set_header_text(GTK_SETTINGITEM(calibration->item), _("Stylus calibration")); 00310 gtk_label_set_text(GTK_LABEL(calibration->label), _("With this function you can re-calibrate your stylus.")); 00311 gtk_button_set_label(GTK_BUTTON(calibration->button), _("Start Calibration")); 00312 } 00313 }

| static void on_calibration_button_toggled_event | ( | GtkToggleButton * | button, | |
| gpointer | data | |||
| ) | [static] |
Definition at line 347 of file iLiadStartUpScreen.c.
00348 { 00349 pid_t pid; 00350 00351 ST_LOGPRINTF("entry"); 00352 00353 // check if it is a "pressed event" 00354 gboolean pressed = gtk_toggle_button_get_active(button); 00355 if (pressed) 00356 { 00357 if ((pid = fork()) < 0) 00358 { 00359 ST_ERRORPRINTF("Can't fork child process!"); 00360 return; 00361 } 00362 else if (pid == 0) 00363 { 00364 // Child process, exec xtscal 00365 if (execvp("/usr/bin/xtscal", NULL) < 0) 00366 { 00367 ST_ERRORPRINTF("execve error!"); 00368 return; 00369 } 00370 // Should never be here 00371 } 00372 else 00373 { 00374 // Parent process 00375 g_xtscal_pid = pid; 00376 } 00377 } 00378 }
| static void on_selection_update | ( | erGtkSelectionGroup * | selection, | |
| gpointer | button, | |||
| gpointer | data | |||
| ) | [static] |
Definition at line 335 of file iLiadStartUpScreen.c.
00336 { 00337 const gtkStartUp_t *startup = (gtkStartUp_t*)data; 00338 int button_id = 0; 00339 00340 ST_LOGPRINTF("entry"); 00341 g_return_if_fail(data != NULL); 00342 00343 ergtk_selection_group_get_selected_buttons(ERGTK_SELECTION_GROUP(startup->behaviour.selection), &button_id, 1); 00344 iLiad_startup_data_set_behaviour(g_button_info[button_id].behaviour, g_button_info[button_id].document_path); 00345 }

| void stop_xtscal | ( | ) |
Definition at line 395 of file iLiadStartUpScreen.c.
00396 { 00397 if (g_xtscal_pid != 0) 00398 { 00399 kill(g_xtscal_pid, SIGTERM); 00400 } 00401 }
| const startup_behaviour_t behaviour |
Definition at line 54 of file iLiadStartUpScreen.c.
| const gchar* document_path |
Definition at line 55 of file iLiadStartUpScreen.c.
struct { ... } g_button_info[STARTUP_BUTTON_NUMBER] [static] |
gtkStartUp_t g_startup [static] |
Definition at line 70 of file iLiadStartUpScreen.c.
pid_t g_xtscal_pid = 0 [static] |
Definition at line 72 of file iLiadStartUpScreen.c.
| const gchar* text |
Definition at line 53 of file iLiadStartUpScreen.c.
1.5.6