Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk
Dir : e17/libs/etk/src/bin Modified Files: etk_button_test.c etk_combobox_test.c etk_entry_test.c etk_slider_test.c Log Message: * Modified patch from saturn_vk to make widgets "disable-able". Some widgets may need some more theme-work to look good when they are disabled * Add saturn_vk to the list of authors since he did a really amazing work on Etk lately. Thanks :) =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_button_test.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- etk_button_test.c 20 Feb 2007 22:05:29 -0000 1.14 +++ etk_button_test.c 18 Mar 2007 20:44:47 -0000 1.15 @@ -1,68 +1,131 @@ #include "etk_test.h" #include "config.h" +/************************** + * + * Creation of the test-app window + * + **************************/ + /* Creates the window for the button test */ void etk_test_button_window_create(void *data) { static Etk_Widget *win = NULL; + Etk_Widget *table; + Etk_Widget *frame; Etk_Widget *vbox; - Etk_Widget *button_normal; - Etk_Widget *button_toggle; - Etk_Widget *button_check; - Etk_Widget *button_radio; + Etk_Widget *button; Etk_Widget *image; if (win) { etk_widget_show_all(ETK_WIDGET(win)); return; - } + } win = etk_window_new(); etk_window_title_set(ETK_WINDOW(win), "Etk Button Test"); etk_container_border_width_set(ETK_CONTAINER(win), 5); etk_signal_connect("delete_event", ETK_OBJECT(win), ETK_CALLBACK(etk_window_hide_on_delete), NULL); + table = etk_table_new(2, 2, ETK_FALSE); + etk_container_add(ETK_CONTAINER(win), table); + + + /******************* + * Normal buttons + *******************/ + frame = etk_frame_new("Buttons"); + etk_table_attach(ETK_TABLE(table), frame, 0, 0, 0, 0, 0, 0, ETK_TABLE_EXPAND_FILL); vbox = etk_vbox_new(ETK_FALSE, 3); - etk_container_add(ETK_CONTAINER(win), vbox); - - button_normal = etk_button_new_with_label("Normal button"); - etk_tooltips_tip_set(button_normal, "This is a normal button"); - etk_box_append(ETK_BOX(vbox), button_normal, ETK_BOX_START, ETK_BOX_NONE, 0); - + etk_container_add(ETK_CONTAINER(frame), vbox); + + button = etk_button_new_with_label("Normal button"); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_button_new_with_label("Button with an image"); image = etk_image_new_from_file(PACKAGE_DATA_DIR "/images/right_arrow.png", NULL); - button_normal = etk_button_new_with_label("Button with an image"); - etk_tooltips_tip_set(button_normal, "This is a normal button with an image"); - etk_button_image_set(ETK_BUTTON(button_normal), ETK_IMAGE(image)); - etk_box_append(ETK_BOX(vbox), button_normal, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_normal = etk_button_new(); - etk_tooltips_tip_set(button_normal, "This is a normal button with nothing"); - etk_box_append(ETK_BOX(vbox), button_normal, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_check = etk_check_button_new_with_label("Check button"); - etk_tooltips_tip_set(button_check, "This is a check button"); - etk_box_append(ETK_BOX(vbox), button_check, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_check = etk_check_button_new(); - etk_tooltips_tip_set(button_check, "This is another check button"); - etk_box_append(ETK_BOX(vbox), button_check, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_radio = etk_radio_button_new_with_label("Radio button", NULL); - etk_tooltips_tip_set(button_radio, "This is a radio button"); - etk_box_append(ETK_BOX(vbox), button_radio, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_radio = etk_radio_button_new_from_widget(ETK_RADIO_BUTTON(button_radio)); - etk_tooltips_tip_set(button_radio, "This is another radio button"); - etk_box_append(ETK_BOX(vbox), button_radio, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_toggle = etk_toggle_button_new_with_label("Toggle button"); - etk_tooltips_tip_set(button_toggle, "This is a toggle button"); - etk_box_append(ETK_BOX(vbox), button_toggle, ETK_BOX_START, ETK_BOX_NONE, 0); - - button_toggle = etk_toggle_button_new(); - etk_tooltips_tip_set(button_toggle, "This is another toggle button"); - etk_box_append(ETK_BOX(vbox), button_toggle, ETK_BOX_START, ETK_BOX_NONE, 0); - + etk_button_image_set(ETK_BUTTON(button), ETK_IMAGE(image)); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_button_new(); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_button_new_with_label("Disabled button"); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + + /******************* + * Toggle buttons + *******************/ + frame = etk_frame_new("Toggle Buttons"); + etk_table_attach(ETK_TABLE(table), frame, 1, 1, 0, 0, 0, 0, ETK_TABLE_EXPAND_FILL); + vbox = etk_vbox_new(ETK_FALSE, 3); + etk_container_add(ETK_CONTAINER(frame), vbox); + + button = etk_toggle_button_new_with_label("Toggle button"); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_toggle_button_new(); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_toggle_button_new_with_label("Disabled toggle button 1"); + etk_toggle_button_active_set(ETK_TOGGLE_BUTTON(button), ETK_TRUE); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_toggle_button_new_with_label("Disabled toggle button 2"); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + + /******************* + * Check buttons + *******************/ + frame = etk_frame_new("Check Buttons"); + etk_table_attach(ETK_TABLE(table), frame, 0, 0, 1, 1, 0, 0, ETK_TABLE_EXPAND_FILL); + vbox = etk_vbox_new(ETK_FALSE, 3); + etk_container_add(ETK_CONTAINER(frame), vbox); + + button = etk_check_button_new_with_label("Check button"); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_check_button_new(); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_check_button_new_with_label("Disabled check button 1"); + etk_toggle_button_active_set(ETK_TOGGLE_BUTTON(button), ETK_TRUE); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_check_button_new_with_label("Disabled check button 2"); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + + /******************* + * Radio buttons + *******************/ + frame = etk_frame_new("Radio Buttons"); + etk_table_attach(ETK_TABLE(table), frame, 1, 1, 1, 1, 0, 0, ETK_TABLE_EXPAND_FILL); + vbox = etk_vbox_new(ETK_FALSE, 3); + etk_container_add(ETK_CONTAINER(frame), vbox); + + button = etk_radio_button_new_with_label("Radio button", NULL); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_radio_button_new_from_widget(ETK_RADIO_BUTTON(button)); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_radio_button_new_with_label("Disabled radio button 1", NULL); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + button = etk_radio_button_new_with_label_from_widget("Disabled radio button 2", ETK_RADIO_BUTTON(button)); + etk_widget_disabled_set(button, ETK_TRUE); + etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_NONE, 0); + + etk_widget_show_all(win); } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_combobox_test.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- etk_combobox_test.c 10 Mar 2007 23:09:32 -0000 1.12 +++ etk_combobox_test.c 18 Mar 2007 20:44:47 -0000 1.13 @@ -49,9 +49,24 @@ /* Create a simple combobox containing one column of labels and add 3 items to it */ combobox = etk_combobox_new_default(); etk_container_add(ETK_CONTAINER(frame), combobox); - etk_combobox_item_append(ETK_COMBOBOX(combobox), "Test 1"); - etk_combobox_item_append(ETK_COMBOBOX(combobox), "Test 2"); - etk_combobox_item_append(ETK_COMBOBOX(combobox), "Test 3"); + etk_combobox_item_append(ETK_COMBOBOX(combobox), "Item 1"); + etk_combobox_item_append(ETK_COMBOBOX(combobox), "Item 2"); + etk_combobox_item_append(ETK_COMBOBOX(combobox), "Item 3"); + + + /******************* + * Disabled combobox + *******************/ + frame = etk_frame_new("Disabled combobox"); + etk_box_append(ETK_BOX(vbox), frame, ETK_BOX_START, ETK_BOX_NONE, 0); + + /* Create a simple combobox containing one column of labels and add 3 items to it */ + combobox = etk_combobox_new_default(); + etk_container_add(ETK_CONTAINER(frame), combobox); + etk_combobox_item_append(ETK_COMBOBOX(combobox), "Disabled text"); + etk_combobox_item_append(ETK_COMBOBOX(combobox), "Item 2"); + etk_combobox_item_append(ETK_COMBOBOX(combobox), "Item 3"); + etk_widget_disabled_set(combobox, ETK_TRUE); /******************* =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_entry_test.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- etk_entry_test.c 13 Jan 2007 23:00:38 -0000 1.13 +++ etk_entry_test.c 18 Mar 2007 20:44:47 -0000 1.14 @@ -1,11 +1,17 @@ #include "etk_test.h" -static void _etk_test_entry_normal_print_cb(Etk_Object *object, void *data); -static void _etk_test_entry_password_show_cb(Etk_Object *object, void *data); +static void _normal_print_cb(Etk_Object *object, void *data); +static void _password_show_cb(Etk_Object *object, void *data); static Etk_Widget *_label_normal = NULL; static Etk_Widget *_entry_normal = NULL; +/************************** + * + * Creation of the test-app window + * + **************************/ + /* Creates the window for the entry test */ void etk_test_entry_window_create(void *data) { @@ -15,14 +21,14 @@ Etk_Widget *separator; Etk_Widget *table; Etk_Widget *button; - Etk_Widget *password_entry; + Etk_Widget *entry; Etk_Widget *image; if (win) { etk_widget_show_all(ETK_WIDGET(win)); return; - } + } win = etk_window_new(); etk_window_title_set(ETK_WINDOW(win), "Etk Entry Test"); @@ -31,7 +37,10 @@ vbox = etk_vbox_new(ETK_FALSE, 0); etk_container_add(ETK_CONTAINER(win), vbox); - /* Normal entry */ + + /******************* + * Normal entry + *******************/ frame = etk_frame_new("Normal Entry"); etk_box_append(ETK_BOX(vbox), frame, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); table = etk_table_new(1, 2, ETK_FALSE); @@ -44,7 +53,7 @@ image = etk_image_new_from_stock(ETK_STOCK_DOCUMENT_PRINT, ETK_STOCK_SMALL); etk_entry_image_set(ETK_ENTRY(_entry_normal), ETK_ENTRY_IMAGE_PRIMARY, ETK_IMAGE(image)); - etk_signal_connect("mouse_click", ETK_OBJECT(image), ETK_CALLBACK(_etk_test_entry_normal_print_cb), NULL); + etk_signal_connect("mouse_click", ETK_OBJECT(image), ETK_CALLBACK(_normal_print_cb), NULL); etk_entry_clear_button_add(ETK_ENTRY(_entry_normal)); _label_normal = etk_label_new(NULL); @@ -54,32 +63,50 @@ etk_box_append(ETK_BOX(vbox), separator, ETK_BOX_START, ETK_BOX_NONE, 6); - /* Password entry */ + /******************* + * Disabled entry + *******************/ + frame = etk_frame_new("Disabled Entry"); + etk_box_append(ETK_BOX(vbox), frame, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); + + entry = etk_entry_new(); + etk_widget_disabled_set(entry, ETK_TRUE); + etk_entry_text_set(ETK_ENTRY(entry), "The disabled text"); + etk_entry_clear_button_add(ETK_ENTRY(entry)); + etk_container_add(ETK_CONTAINER(frame), entry); + + separator = etk_hseparator_new(); + etk_box_append(ETK_BOX(vbox), separator, ETK_BOX_START, ETK_BOX_NONE, 6); + + + /******************* + * Password entry + *******************/ frame = etk_frame_new("Password Entry"); etk_box_append(ETK_BOX(vbox), frame, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); vbox = etk_vbox_new(ETK_FALSE, 0); etk_container_add(ETK_CONTAINER(frame), vbox); - password_entry = etk_entry_new(); - etk_entry_text_set(ETK_ENTRY(password_entry), "Password"); - etk_entry_password_mode_set(ETK_ENTRY(password_entry), ETK_TRUE); - etk_box_append(ETK_BOX(vbox), password_entry, ETK_BOX_START, ETK_BOX_FILL, 0); + entry = etk_entry_new(); + etk_entry_text_set(ETK_ENTRY(entry), "Password"); + etk_entry_password_mode_set(ETK_ENTRY(entry), ETK_TRUE); + etk_box_append(ETK_BOX(vbox), entry, ETK_BOX_START, ETK_BOX_FILL, 0); button = etk_check_button_new_with_label("Password Visible"); etk_box_append(ETK_BOX(vbox), button, ETK_BOX_START, ETK_BOX_FILL, 0); - etk_signal_connect("toggled", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_entry_password_show_cb), password_entry); + etk_signal_connect("toggled", ETK_OBJECT(button), ETK_CALLBACK(_password_show_cb), entry); etk_widget_show_all(win); } /* Prints the text of the normal entry in the label */ -static void _etk_test_entry_normal_print_cb(Etk_Object *object, void *data) +static void _normal_print_cb(Etk_Object *object, void *data) { etk_label_set(ETK_LABEL(_label_normal), etk_entry_text_get(ETK_ENTRY(_entry_normal))); } /* Toggles the password mode of the password entry */ -static void _etk_test_entry_password_show_cb(Etk_Object *object, void *data) +static void _password_show_cb(Etk_Object *object, void *data) { etk_entry_password_mode_set(ETK_ENTRY(data), !etk_toggle_button_active_get(ETK_TOGGLE_BUTTON(object))); } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_slider_test.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- etk_slider_test.c 10 Mar 2007 18:19:21 -0000 1.13 +++ etk_slider_test.c 18 Mar 2007 20:44:47 -0000 1.14 @@ -4,11 +4,14 @@ static void _inverted_toggled_cb(Etk_Object *object, void *data); static void _show_label_toggled_cb(Etk_Object *object, void *data); static void _continuous_toggled_cb(Etk_Object *object, void *data); +static void _disabled_toggled_cb(Etk_Object *object, void *data); static void _maximum_changed_cb(Etk_Object *object, double value, void *data); static Etk_Widget *_label = NULL; static Etk_Widget *_hslider = NULL; static Etk_Widget *_vslider = NULL; +static Etk_Widget *_hspinner = NULL; +static Etk_Widget *_vspinner = NULL; /************************** @@ -29,7 +32,6 @@ Etk_Widget *vbox; Etk_Widget *check; Etk_Widget *label; - Etk_Widget *spinner; if (win) { @@ -89,13 +91,17 @@ etk_box_append(ETK_BOX(vbox), check, ETK_BOX_START, ETK_BOX_EXPAND, 0); etk_signal_connect("toggled", ETK_OBJECT(check), ETK_CALLBACK(_continuous_toggled_cb), _hslider); + check = etk_check_button_new_with_label("Disabled"); + etk_box_append(ETK_BOX(vbox), check, ETK_BOX_START, ETK_BOX_EXPAND, 0); + etk_signal_connect("toggled", ETK_OBJECT(check), ETK_CALLBACK(_disabled_toggled_cb), _hslider); + hbox = etk_hbox_new(ETK_FALSE, 5); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_EXPAND, 0); label = etk_label_new("Maximum:"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); - spinner = etk_spinner_new(10.0, 1000.0, 255.0, 1.0, 10.0); - etk_box_append(ETK_BOX(hbox), spinner, ETK_BOX_START, ETK_BOX_NONE, 0); - etk_signal_connect("value_changed", ETK_OBJECT(spinner), ETK_CALLBACK(_maximum_changed_cb), _hslider); + _hspinner = etk_spinner_new(10.0, 1000.0, 255.0, 1.0, 10.0); + etk_box_append(ETK_BOX(hbox), _hspinner, ETK_BOX_START, ETK_BOX_NONE, 0); + etk_signal_connect("value_changed", ETK_OBJECT(_hspinner), ETK_CALLBACK(_maximum_changed_cb), _hslider); /* Create the settings frame for the vertical slider */ @@ -118,13 +124,17 @@ etk_box_append(ETK_BOX(vbox), check, ETK_BOX_START, ETK_BOX_EXPAND, 0); etk_signal_connect("toggled", ETK_OBJECT(check), ETK_CALLBACK(_continuous_toggled_cb), _vslider); + check = etk_check_button_new_with_label("Disabled"); + etk_box_append(ETK_BOX(vbox), check, ETK_BOX_START, ETK_BOX_EXPAND, 0); + etk_signal_connect("toggled", ETK_OBJECT(check), ETK_CALLBACK(_disabled_toggled_cb), _vslider); + hbox = etk_hbox_new(ETK_FALSE, 5); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_EXPAND, 0); label = etk_label_new("Maximum:"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); - spinner = etk_spinner_new(10.0, 1000.0, 255.0, 1.0, 10.0); - etk_box_append(ETK_BOX(hbox), spinner, ETK_BOX_START, ETK_BOX_NONE, 0); - etk_signal_connect("value_changed", ETK_OBJECT(spinner), ETK_CALLBACK(_maximum_changed_cb), _vslider); + _vspinner = etk_spinner_new(10.0, 1000.0, 255.0, 1.0, 10.0); + etk_box_append(ETK_BOX(hbox), _vspinner, ETK_BOX_START, ETK_BOX_NONE, 0); + etk_signal_connect("value_changed", ETK_OBJECT(_vspinner), ETK_CALLBACK(_maximum_changed_cb), _vslider); etk_widget_show_all(win); @@ -185,6 +195,29 @@ etk_slider_update_policy_set(slider, ETK_SLIDER_CONTINUOUS); else etk_slider_update_policy_set(slider, ETK_SLIDER_DELAYED); +} + +/* Called when one of the "Disabled" check buttons is toggled */ +static void _disabled_toggled_cb(Etk_Object *object, void *data) +{ + Etk_Toggle_Button *toggle; + Etk_Widget *slider; + Etk_Bool disabled; + + if (!(toggle = ETK_TOGGLE_BUTTON(object)) || !(slider = ETK_WIDGET(data))) + return; + + disabled = etk_toggle_button_active_get(toggle); + if (slider == _hslider) + { + etk_widget_disabled_set(_hslider, disabled); + etk_widget_disabled_set(_hspinner, disabled); + } + else + { + etk_widget_disabled_set(_vslider, disabled); + etk_widget_disabled_set(_vspinner, disabled); + } } /* Called when the value of one the "Maximum" spinners is changed */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs