Enlightenment CVS committal Author : essiene Project : e17 Module : proto
Dir : e17/proto/entrance_edit_gui/src/gui Modified Files: Egui.h Makefile.am behavior.c egui_graphics_dialog.c layout.c x_settings.c Removed Files: egui_settings_dialog.c egui_settings_dialog.h Log Message: Fixed the annoying crashings and in the process restructured the gui code a lot, bottom-line - It Works (tm). We also now have a .desktop file, so you can start us from the main menu: Applications -> Settings -> Entrance (now we need a sweet icon... help! help!) For the what is left, see TODO. We have just 2 or 3 critical features/fixes left to add before we are ready to more into Entrance's main tree. [widgets] - Added ew_dialog_onclose_set(so we can explicitly declare onclose callback, especially for non-toplevel dialog windows. A couple of nasty bugs were hiding behind this one. [gui] - fixup crashings. All config dialogs work well now, and don't allow opening multiple instances. - Added a .desktop file for entrance_edit_gui, it shows up under Applications->Settings->Entrance =================================================================== RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/Egui.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- Egui.h 29 Sep 2006 02:36:38 -0000 1.13 +++ Egui.h 6 Nov 2006 09:56:18 -0000 1.14 @@ -1,11 +1,13 @@ #ifndef _EGUI_H #define _EGUI_H - - -#include <Ecore_Data.h> - #include "egui_graphics_dialog.h" -#include "egui_settings_dialog.h" + +#define EGUI_TYPE_BUTTON 0 +#define EGUI_TYPE_ENTRY 1 +#define EGUI_TYPE_LIST 2 +#define EGUI_TYPE_CHECKBOX 3 +#define EGUI_TYPE_INT 4 +#define EGUI_TYPE_STR 5 void egui_theme_dialog_show(void*); void egui_background_dialog_show(void*); @@ -14,5 +16,14 @@ void egui_behavior_dialog_show(void*); void egui_sessions_dialog_show(void*); void egui_x_settings_dialog_show(void*); + +void egui_load_button(void *w, const char *key, int ktype); +void egui_load_entry(void *w, const char *key, int ktype); +void egui_load_checkbox(void *w, const char *key, int ktype); + +void egui_save_button(void *w, const char *key, int ktype); +void egui_save_entry(void *w, const char *key, int ktype); +void egui_save_checkbox(void *w, const char *key, int ktype); +void egui_save_list(void *w, const char *key, int ktype); #endif =================================================================== RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/Makefile.am,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- Makefile.am 29 Sep 2006 02:36:38 -0000 1.15 +++ Makefile.am 6 Nov 2006 09:56:18 -0000 1.16 @@ -11,9 +11,7 @@ x_settings.c \ egui_graphics_dialog.c \ egui_graphics_dialog.h \ - egui_settings_dialog.c \ - egui_settings_dialog.h \ - Egui.h + Egui.h egui.c entrance_edit_gui_CFLAGS = \ =================================================================== RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/behavior.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- behavior.c 29 Sep 2006 02:36:38 -0000 1.11 +++ behavior.c 6 Nov 2006 09:56:18 -0000 1.12 @@ -3,118 +3,212 @@ #include <stdio.h> #include "Egui.h" +static void _cb_close(void*, void*); +static void _cb_apply(void*, void*); +static void _cb_ok(void *, void *); + +static void _close(void*); +static int _apply(void*); +static void _save_to_file(void*); + +typedef struct { + Entrance_Dialog win; + + Entrance_Widget group_autologin; + Entrance_Widget check_autologin; + Entrance_Entry entry_autologin_user; + + Entrance_Widget group_preselect; + Entrance_Widget check_preselect; + Entrance_Entry entry_preselect_user; + + Entrance_Widget group_remember; + Entrance_Widget check_remember; + Entrance_Entry entry_remember_count; + Entrance_Entry entry_remember_user_count; + + + Entrance_Widget group_others; + Entrance_Widget check_others_auth; + Entrance_Widget check_others_engine; + Entrance_Widget check_others_reboot; + Entrance_Widget check_others_halt; +}* Behaviour_Dialog; + +static Behaviour_Dialog _create_widgets(Behaviour_Dialog); +static void _show(Behaviour_Dialog bd); + void -egui_behavior_dialog_show(void *data) { - Ecore_List *groups = ecore_list_new(); +egui_behavior_dialog_show(void *data) +{ + static Behaviour_Dialog bd = NULL; + + if (bd == NULL) + { + bd = calloc(1, sizeof(*bd)); + + if(!bd) + return; + } + + _show(bd); +} + + +static void +_show(Behaviour_Dialog bd) +{ + if(!bd) + return; + + if(bd->win == NULL) + { + bd = _create_widgets(bd); + } + + ew_dialog_show(bd->win); +} + +Behaviour_Dialog +_create_widgets(Behaviour_Dialog bd) { - /* Autologin group */ - Egui_Settings_Group autologin = egui_sg_new("AutoLogin", EW_GROUP_VERTICAL); - Egui_Settings_Item autologin_check = egui_si_new( - ew_checkbox_new("Enable Autologin"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_AUTOLOGIN_MODE_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item autologin_entry = egui_si_new( - ew_entry_new("Autologin User", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_AUTOLOGIN_USER_STR, - EGUI_TYPE_STR - ); + if(!bd) + return NULL; + + if(bd->win != NULL) + return bd; + + bd->win = ew_dialog_new("Behaviour", EW_FALSE); + + /*Autologin group*/ + bd->group_autologin = ew_dialog_group_add(bd->win, "Autologin", EW_GROUP_VERTICAL); + + bd->check_autologin = ew_checkbox_new("Enable Autologin"); + egui_load_checkbox(bd->check_autologin, ENTRANCE_EDIT_KEY_CLIENT_AUTOLOGIN_MODE_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_autologin, bd->check_autologin); + + bd->entry_autologin_user = ew_entry_new("Autologin User", NULL, EW_FALSE); + egui_load_entry(bd->entry_autologin_user, ENTRANCE_EDIT_KEY_CLIENT_AUTOLOGIN_USER_STR, EGUI_TYPE_STR); + ew_group_add(bd->group_autologin, bd->entry_autologin_user); /* Preselect group */ - Egui_Settings_Group preselect = egui_sg_new("Preselect", EW_GROUP_VERTICAL); - Egui_Settings_Item preselect_check = egui_si_new( - ew_checkbox_new("Enable Preselect Mode"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_PRESEL_MODE_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item preselect_entry = egui_si_new( - ew_entry_new("Previous Preselect User", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_PRESEL_PREVUSER_STR, - EGUI_TYPE_STR - ); + bd->group_preselect = ew_dialog_group_add(bd->win, "Preselect", EW_GROUP_VERTICAL); + + bd->check_preselect = ew_checkbox_new("Enable Preselect Mode"); + egui_load_checkbox(bd->check_preselect, ENTRANCE_EDIT_KEY_CLIENT_PRESEL_MODE_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_preselect, bd->check_preselect); + + bd->entry_preselect_user = ew_entry_new("Preselected User", NULL, EW_FALSE); + egui_load_entry(bd->entry_preselect_user, ENTRANCE_EDIT_KEY_CLIENT_PRESEL_PREVUSER_STR, EGUI_TYPE_STR); + ew_group_add(bd->group_preselect, bd->entry_preselect_user); /* Remember group */ - Egui_Settings_Group remember = egui_sg_new("Remember", EW_GROUP_VERTICAL); - Egui_Settings_Item remember_check = egui_si_new( - ew_checkbox_new("Enable User Remember"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_USER_REMEMBER_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item remember_count = egui_si_new( - ew_entry_new("User Remember Count", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_USER_REMEMBER_N_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item remember_user_count = egui_si_new( - ew_entry_new("User Count", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_USER_COUNT_INT, - EGUI_TYPE_INT - ); + bd->group_remember = ew_dialog_group_add(bd->win, "Remember", EW_GROUP_VERTICAL); + + bd->check_remember = ew_checkbox_new("Enable User Remember"); + egui_load_checkbox(bd->check_remember, ENTRANCE_EDIT_KEY_CLIENT_USER_REMEMBER_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_remember, bd->check_remember); + + bd->entry_remember_count = ew_entry_new("User Remember Count", NULL, EW_FALSE); + egui_load_entry(bd->entry_remember_count, ENTRANCE_EDIT_KEY_CLIENT_USER_REMEMBER_N_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_remember, bd->entry_remember_count); + + bd->entry_remember_user_count = ew_entry_new("User Count", NULL, EW_FALSE); + egui_load_entry(bd->entry_remember_user_count, ENTRANCE_EDIT_KEY_CLIENT_USER_COUNT_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_remember, bd->entry_remember_user_count); /* Others group */ - Egui_Settings_Group others = egui_sg_new("Others", EW_GROUP_VERTICAL); - Egui_Settings_Item others_auth = egui_si_new( - ew_checkbox_new("Use Authentication"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_AUTH_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item others_engine = egui_si_new( - ew_checkbox_new("Use OpenGL Engine"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_ENGINE_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item others_reboot = egui_si_new( - ew_checkbox_new("Show Reboot Button"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_SYSTEM_REBOOT_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item others_halt = egui_si_new( - ew_checkbox_new("Show Halt Button"), - EGUI_TYPE_CHECKBOX, - ENTRANCE_EDIT_KEY_CLIENT_SYSTEM_HALT_INT, - EGUI_TYPE_INT - ); - - /* init */ - egui_sg_item_append(autologin, autologin_check); - egui_sg_item_append(autologin, autologin_entry); - ecore_list_append(groups, autologin); - - egui_sg_item_append(preselect, preselect_check); - egui_sg_item_append(preselect, preselect_entry); - ecore_list_append(groups, preselect); - - egui_sg_item_append(remember, remember_check); - egui_sg_item_append(remember, remember_count); - egui_sg_item_append(remember, remember_user_count); - ecore_list_append(groups, remember); - - egui_sg_item_append(others, others_auth); - egui_sg_item_append(others, others_engine); - egui_sg_item_append(others, others_reboot); - egui_sg_item_append(others, others_halt); - ecore_list_append(groups, others); - /* show */ - static Egui_Settings_Dialog esd = NULL; - if(!esd) - esd = egui_sd_new("Behaviour", groups); + bd->group_others = ew_dialog_group_add(bd->win, "Others", EW_GROUP_VERTICAL); + + bd->check_others_auth = ew_checkbox_new("Use Authentication"); + egui_load_checkbox(bd->check_others_auth, ENTRANCE_EDIT_KEY_CLIENT_AUTH_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_others, bd->check_others_auth); + + bd->check_others_engine = ew_checkbox_new("Use OpenGL Engine"); + egui_load_checkbox(bd->check_others_engine, ENTRANCE_EDIT_KEY_CLIENT_ENGINE_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_others, bd->check_others_engine); - egui_sd_show(esd); + bd->check_others_reboot = ew_checkbox_new("Show Reboot Button"); + egui_load_checkbox(bd->check_others_reboot, ENTRANCE_EDIT_KEY_CLIENT_SYSTEM_REBOOT_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_others, bd->check_others_reboot); + + bd->check_others_halt = ew_checkbox_new("Show Halt Button"); + egui_load_checkbox(bd->check_others_halt, ENTRANCE_EDIT_KEY_CLIENT_SYSTEM_HALT_INT, EGUI_TYPE_INT); + ew_group_add(bd->group_others, bd->check_others_halt); + + ew_dialog_close_button_add(bd->win, _cb_close, bd); + ew_dialog_apply_button_add(bd->win, _cb_apply, bd); + ew_dialog_ok_button_add(bd->win, _cb_ok, bd); + + ew_dialog_onclose_set(bd->win, _cb_close, bd); + + return bd; +} + +/*private*/ +static void +_close(void* data) +{ + Behaviour_Dialog bd = data; + if(!bd) + return; + + ew_dialog_destroy(bd->win); + bd->win = NULL; } + + +static int +_apply(void* data) +{ + Behaviour_Dialog bd = data; + if(!bd) + return; + + egui_save_checkbox(bd->check_autologin, ENTRANCE_EDIT_KEY_CLIENT_AUTOLOGIN_MODE_INT, EGUI_TYPE_INT); + egui_save_entry(bd->entry_autologin_user, ENTRANCE_EDIT_KEY_CLIENT_AUTOLOGIN_USER_STR, EGUI_TYPE_STR); + + egui_save_checkbox(bd->check_preselect, ENTRANCE_EDIT_KEY_CLIENT_PRESEL_MODE_INT, EGUI_TYPE_INT); + egui_save_entry(bd->entry_preselect_user, ENTRANCE_EDIT_KEY_CLIENT_PRESEL_PREVUSER_STR, EGUI_TYPE_STR); + + egui_save_checkbox(bd->check_remember, ENTRANCE_EDIT_KEY_CLIENT_USER_REMEMBER_INT, EGUI_TYPE_INT); + egui_save_entry(bd->entry_remember_count, ENTRANCE_EDIT_KEY_CLIENT_USER_REMEMBER_N_INT, EGUI_TYPE_INT); + egui_save_entry(bd->entry_remember_user_count, ENTRANCE_EDIT_KEY_CLIENT_USER_COUNT_INT, EGUI_TYPE_INT); + + egui_save_checkbox(bd->check_others_auth, ENTRANCE_EDIT_KEY_CLIENT_AUTH_INT, EGUI_TYPE_INT); + egui_save_checkbox(bd->check_others_engine, ENTRANCE_EDIT_KEY_CLIENT_ENGINE_INT, EGUI_TYPE_INT); + egui_save_checkbox(bd->check_others_reboot, ENTRANCE_EDIT_KEY_CLIENT_SYSTEM_REBOOT_INT, EGUI_TYPE_INT); + egui_save_checkbox(bd->check_others_halt, ENTRANCE_EDIT_KEY_CLIENT_SYSTEM_HALT_INT, EGUI_TYPE_INT); + + if(!entrance_edit_save()) + { + ew_messagebox_ok("Entrance Configuration - Error", "Can not save to config file. Please check your permissions", EW_MESSAGEBOX_ICON_ERROR); + return 0; + } + + return 1; +} + +/*callbacks*/ +static void +_cb_close(void* sender, void* data) +{ + _close(data); + /*TODO: free(data) at this point?*/ + data = NULL; +} + +static void +_cb_apply(void* sender, void* data) +{ + _apply(data); +} + +static void +_cb_ok(void* sender, void* data) +{ + if(_apply(data)) + _close(data); +} + + =================================================================== RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/egui_graphics_dialog.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- egui_graphics_dialog.c 29 Sep 2006 02:36:38 -0000 1.2 +++ egui_graphics_dialog.c 6 Nov 2006 09:56:18 -0000 1.3 @@ -1,4 +1,5 @@ #include <limits.h> +#include <string.h> #include <Evas.h> #include <Ecore_File.h> #include <Ecore_Data.h> @@ -86,6 +87,7 @@ ew_dialog_close_button_add(egd->win, _gd_cb_close, egd); ew_dialog_apply_button_add(egd->win, _gd_cb_apply, egd); ew_dialog_ok_button_add(egd->win, _gd_cb_ok, egd); + ew_dialog_onclose_set(egd->win, _gd_cb_close, egd); egd->newly_created = 1; return egd; @@ -97,6 +99,8 @@ if(!egd) return; + printf("egd->win = %s\n", egd->win); + if(egd->win == NULL) egd = _egui_gd_create_widgets(egd); @@ -135,7 +139,6 @@ { _gd_close(data); /*TODO: neccessary?*/ - data = NULL; } static void @@ -199,6 +202,7 @@ return; ew_dialog_destroy(egd->win); egd->win = NULL; + printf("egd->win has been set to null\n"); } static char* =================================================================== RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/layout.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- layout.c 29 Sep 2006 02:36:38 -0000 1.10 +++ layout.c 6 Nov 2006 09:56:18 -0000 1.11 @@ -3,55 +3,157 @@ #include <stdio.h> #include "Egui.h" +static void _cb_close(void*, void*); +static void _cb_apply(void*, void*); +static void _cb_ok(void *, void *); + +static void _close(void*); +static int _apply(void*); +static void _save_to_file(void*); + +typedef struct { + Entrance_Dialog win; + + Entrance_Widget group_greeting; + Entrance_Entry entry_greeting_before; + Entrance_Entry entry_greeting_after; + + Entrance_Widget group_format; + Entrance_Entry entry_time_format; + Entrance_Entry entry_date_format; + +}* Layout_Dialog; + +static Layout_Dialog _create_widgets(Layout_Dialog); +static void _show(Layout_Dialog ld); + void egui_layout_dialog_show(void *data) { + static Layout_Dialog ld = NULL; + + if (ld == NULL) + { + ld = calloc(1, sizeof(*ld)); - Egui_Settings_Group group_greeting = egui_sg_new("Greetings", EW_GROUP_VERTICAL); + if(!ld) + return; + } - Egui_Settings_Item before = egui_si_new( - ew_entry_new("Before", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_GREETING_BEFORE_STR, - EGUI_TYPE_STR - ); - - Egui_Settings_Item after = egui_si_new( - ew_entry_new("After", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_GREETING_AFTER_STR, - EGUI_TYPE_STR - ); - - egui_sg_item_append(group_greeting, before); - egui_sg_item_append(group_greeting, after); - - Egui_Settings_Group group_format = egui_sg_new("Time/Date Format", EW_GROUP_VERTICAL); - - Egui_Settings_Item time_format = egui_si_new( - ew_entry_new("Time format", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_TIME_FORMAT_STR, - EGUI_TYPE_STR - ); - - Egui_Settings_Item date_format = egui_si_new( - ew_entry_new("Data format", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_TIME_FORMAT_STR, - EGUI_TYPE_STR - ); + _show(ld); +} - egui_sg_item_append(group_format, time_format); - egui_sg_item_append(group_format, date_format); - - Ecore_List *groups = ecore_list_new(); - ecore_list_append(groups, group_greeting); - ecore_list_append(groups, group_format); - - static Egui_Settings_Dialog esd = NULL; - if(!esd) - esd = egui_sd_new("Layout settings", groups); - egui_sd_show(esd); +static void +_show(Layout_Dialog ld) +{ + if(!ld) + return; + + if(ld->win == NULL) + { + ld = _create_widgets(ld); + } + + ew_dialog_show(ld->win); +} + + +static Layout_Dialog +_create_widgets(Layout_Dialog ld) +{ + if (!ld) + return NULL; + + if(ld->win != NULL) + return ld; + + ld->win = ew_dialog_new("Layout Settings", EW_FALSE); + + ld->group_greeting = ew_dialog_group_add(ld->win, "Greetings", EW_GROUP_VERTICAL); + + ld->entry_greeting_before = ew_entry_new("Before", NULL, EW_FALSE); + egui_load_entry(ld->entry_greeting_before, ENTRANCE_EDIT_KEY_CLIENT_GREETING_BEFORE_STR, EGUI_TYPE_STR); + ew_group_add(ld->group_greeting, ld->entry_greeting_before); + + ld->entry_greeting_after = ew_entry_new("After", NULL, EW_FALSE); + egui_load_entry(ld->entry_greeting_after, ENTRANCE_EDIT_KEY_CLIENT_GREETING_AFTER_STR, EGUI_TYPE_STR); + ew_group_add(ld->group_greeting, ld->entry_greeting_after); + + ld->group_format = ew_dialog_group_add(ld->win, "Time/Date Format", EW_GROUP_VERTICAL); + + ld->entry_time_format = ew_entry_new("Time Format", NULL, EW_FALSE); + egui_load_entry(ld->entry_time_format, ENTRANCE_EDIT_KEY_CLIENT_TIME_FORMAT_STR, EGUI_TYPE_STR); + ew_group_add(ld->group_format, ld->entry_time_format); + + ld->entry_date_format = ew_entry_new("Date Format", NULL, EW_FALSE); + egui_load_entry(ld->entry_date_format, ENTRANCE_EDIT_KEY_CLIENT_DATE_FORMAT_STR, EGUI_TYPE_STR); + ew_group_add(ld->group_format, ld->entry_date_format); + + ew_dialog_close_button_add(ld->win, _cb_close, ld); + ew_dialog_apply_button_add(ld->win, _cb_apply, ld); + ew_dialog_ok_button_add(ld->win, _cb_ok, ld); + + ew_dialog_onclose_set(ld->win, _cb_close, ld); + + return ld; +} + + + + +/*private*/ +static void +_close(void* data) +{ + Layout_Dialog ld = data; + if(!ld) + return; + + ew_dialog_destroy(ld->win); + ld->win = NULL; +} + + +static int +_apply(void* data) +{ + Layout_Dialog ld = data; + if(!ld) + return; + + egui_save_entry(ld->entry_greeting_before, ENTRANCE_EDIT_KEY_CLIENT_GREETING_BEFORE_STR, EGUI_TYPE_STR); + egui_save_entry(ld->entry_greeting_after, ENTRANCE_EDIT_KEY_CLIENT_GREETING_AFTER_STR, EGUI_TYPE_STR); + egui_save_entry(ld->entry_time_format, ENTRANCE_EDIT_KEY_CLIENT_TIME_FORMAT_STR, EGUI_TYPE_STR); + egui_save_entry(ld->entry_date_format, ENTRANCE_EDIT_KEY_CLIENT_DATE_FORMAT_STR, EGUI_TYPE_STR); + + if(!entrance_edit_save()) + { + ew_messagebox_ok("Entrance Configuration - Error", "Can not save to config file. Please check your permissions", EW_MESSAGEBOX_ICON_ERROR); + return 0; + } + + return 1; +} + +/*callbacks*/ +static void +_cb_close(void* sender, void* data) +{ + _close(data); + /*TODO: free(data) at this point?*/ + data = NULL; +} + +static void +_cb_apply(void* sender, void* data) +{ + _apply(data); +} + +static void +_cb_ok(void* sender, void* data) +{ + if(_apply(data)) + _close(data); } =================================================================== RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/x_settings.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- x_settings.c 29 Sep 2006 02:36:38 -0000 1.8 +++ x_settings.c 6 Nov 2006 09:56:18 -0000 1.9 @@ -1,54 +1,158 @@ -#include <limits.h> -#include <stdlib.h> -#include <strings.h> -#include <Entrance_Widgets.h> +#include <string.h> #include <Entrance_Edit.h> +#include <Entrance_Widgets.h> #include "Egui.h" -#include <stdio.h> + +static void _cb_close(void*, void*); +static void _cb_apply(void*, void*); +static void _cb_ok(void *, void *); + +static void _close(void*); +static int _apply(void*); +static void _save_to_file(void*); + + + +typedef struct { + Entrance_Dialog win; + + Entrance_Widget group_daemon_settings; + Entrance_Entry entry_x_attempts; + Entrance_Entry entry_x_commandline; + + Entrance_Widget group_client_settings; + Entrance_Entry entry_x_session; +}* X_Settings_Dialog; + + +static X_Settings_Dialog _create_widgets(X_Settings_Dialog); +static void _show(X_Settings_Dialog xsd); void egui_x_settings_dialog_show(void *data) { - Egui_Settings_Group group_daemon = egui_sg_new("Daemon Settings", EW_GROUP_VERTICAL); - Egui_Settings_Item item_attempts = egui_si_new( - ew_entry_new("X Attempts", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_DAEMON_ATTEMPTS_INT, - EGUI_TYPE_INT - ); - - Egui_Settings_Item item_xserver = egui_si_new( - ew_entry_new("X Commandline", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_DAEMON_XSERVER_STR, - EGUI_TYPE_STR - ); - - egui_sg_item_append(group_daemon, item_attempts); - egui_sg_item_append(group_daemon, item_xserver); - - - Egui_Settings_Group group_client = egui_sg_new("Client Settings", EW_GROUP_VERTICAL); - Egui_Settings_Item item_xsession = egui_si_new( - ew_entry_new("X Session", NULL, EW_FALSE), - EGUI_TYPE_ENTRY, - ENTRANCE_EDIT_KEY_CLIENT_XSESSION_STR, - EGUI_TYPE_STR - ); + static X_Settings_Dialog xsd = NULL; + + if (xsd == NULL) + { + xsd = calloc(1, sizeof(*xsd)); - egui_sg_item_append(group_client, item_xsession); + if(!xsd) + return; + } - Ecore_List *groups = ecore_list_new(); - if(groups) + _show(xsd); +} + + +static void +_show(X_Settings_Dialog xsd) +{ + if(!xsd) + return; + + if(xsd->win == NULL) { - ecore_list_append(groups, group_daemon); - ecore_list_append(groups, group_client); + xsd = _create_widgets(xsd); + } + + ew_dialog_show(xsd->win); +} + +static X_Settings_Dialog +_create_widgets(X_Settings_Dialog xsd) +{ + if(!xsd) + return NULL; + + if(xsd->win != NULL) + return xsd; + + xsd->win = ew_dialog_new("X Settings", EW_FALSE); + + xsd->group_daemon_settings = ew_dialog_group_add(xsd->win, "Daemon Settings", EW_GROUP_VERTICAL); + + xsd->entry_x_attempts = ew_entry_new("X Attempts", NULL, EW_FALSE); + egui_load_entry(xsd->entry_x_attempts, ENTRANCE_EDIT_KEY_DAEMON_ATTEMPTS_INT, EGUI_TYPE_INT); - static Egui_Settings_Dialog esd = NULL; - if(!esd) - esd = egui_sd_new("X Settings", groups); + xsd->entry_x_commandline = ew_entry_new("X Commandline", NULL, EW_FALSE); + egui_load_entry(xsd->entry_x_commandline, ENTRANCE_EDIT_KEY_DAEMON_XSERVER_STR, EGUI_TYPE_STR); - egui_sd_show(esd); + ew_group_add(xsd->group_daemon_settings, xsd->entry_x_attempts); + ew_group_add(xsd->group_daemon_settings, xsd->entry_x_commandline); + + + xsd->group_client_settings = ew_dialog_group_add(xsd->win, "Client Settings", EW_GROUP_VERTICAL); + + xsd->entry_x_session = ew_entry_new("X Session", NULL, EW_FALSE); + egui_load_entry(xsd->entry_x_session, ENTRANCE_EDIT_KEY_CLIENT_XSESSION_STR, EGUI_TYPE_STR); + + ew_group_add(xsd->group_client_settings, xsd->entry_x_session); + + ew_dialog_close_button_add(xsd->win, _cb_close, xsd); + ew_dialog_apply_button_add(xsd->win, _cb_apply, xsd); + ew_dialog_ok_button_add(xsd->win, _cb_ok, xsd); + + ew_dialog_onclose_set(xsd->win, _cb_close, xsd); + + return xsd; +} + + +/*private*/ + + +static void +_close(void* data) +{ + X_Settings_Dialog xsd = data; + if(!xsd) + return; + + ew_dialog_destroy(xsd->win); + xsd->win = NULL; +} + + +static int +_apply(void* data) +{ + X_Settings_Dialog xsd = data; + if(!xsd) + return; + + egui_save_entry(xsd->entry_x_attempts, ENTRANCE_EDIT_KEY_DAEMON_ATTEMPTS_INT, EGUI_TYPE_INT); + egui_save_entry(xsd->entry_x_commandline, ENTRANCE_EDIT_KEY_DAEMON_XSERVER_STR, EGUI_TYPE_STR); + egui_save_entry(xsd->entry_x_session, ENTRANCE_EDIT_KEY_CLIENT_XSESSION_STR, EGUI_TYPE_STR); + + if(!entrance_edit_save()) + { + ew_messagebox_ok("Entrance Configuration - Error", "Can not save to config file. Please check your permissions", EW_MESSAGEBOX_ICON_ERROR); + return 0; } + + return 1; +} + +/*callbacks*/ +static void +_cb_close(void* sender, void* data) +{ + _close(data); + /*TODO: free(data) at this point?*/ + data = NULL; +} + +static void +_cb_apply(void* sender, void* data) +{ + _apply(data); +} + +static void +_cb_ok(void* sender, void* data) +{ + if(_apply(data)) + _close(data); } ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs