Hello Moom, CodeWarrior, As per my discussion with CodeWarrior, here is a diff for etk_filechooser_widget which does the following:
*********************************************************************** -Adds 2 new properties: Select_Multiple and Show_Hidden. -Adds a function to allow/disallow multiple files to be selected. (False By Default). -Adds a function to allow/disallow showing of hidden files. (False By Default). -Adds a function to get the current_folder. -Adds a function to get/set the current_file. *********************************************************************** Please give it a once-over, and if everything is kewl, commit it :) I've tested all this with a proto app I am making. The only "gotcha" I found is that show_hidden needs to be set before the current_folder is set. Perhaps there is a way to work around that. Cheers, devilhorns
--- etk_filechooser_widget.c.orig 2006-02-10 05:43:33.000000000 -0500 +++ etk_filechooser_widget.c 2006-02-10 19:30:36.000000000 -0500 @@ -29,7 +29,9 @@ enum _Etk_Filechooser_Widget_Property_Id { - ETK_FILECHOOSER_WIDGET_PATH_PROPERTY + ETK_FILECHOOSER_WIDGET_PATH_PROPERTY, + ETK_FILECHOOSER_WIDGET_SELECT_MULTIPLE_PROPERTY, + ETK_FILECHOOSER_WIDGET_SHOW_HIDDEN_PROPERTY }; typedef struct _Etk_Filechooser_Widget_Icons @@ -45,6 +47,7 @@ static void _etk_filechooser_widget_favs_get(Etk_Filechooser_Widget *filechooser_widget); static void _etk_filechooser_widget_dir_row_selected_cb(Etk_Object *object, Etk_Tree_Row *row, void *data); static void _etk_filechooser_widget_fav_row_selected_cb(Etk_Object *object, Etk_Tree_Row *row, void *data); +static void _etk_filechooser_widget_file_row_selected_cb(Etk_Object *object, Etk_Tree_Row *row, void *data); static Etk_Filechooser_Widget_Icons _etk_file_chooser_icons[] = { @@ -67,7 +70,7 @@ { "rar", "mimetypes/package-x-generic_16" }, }; static int _etk_file_chooser_num_icons = sizeof(_etk_file_chooser_icons) / sizeof (_etk_file_chooser_icons[0]); -static Etk_Signal *_etk_filechooser_widget_signals[ETK_FILECHOOSER_WIDGET_NUM_SIGNALS]; +//static Etk_Signal *_etk_filechooser_widget_signals[ETK_FILECHOOSER_WIDGET_NUM_SIGNALS]; /************************** * @@ -90,7 +93,9 @@ //_etk_filechooser_widget_signals[ETK_FILECHOOSER_WIDGET_TEXT_POPPED_SIGNAL] = etk_signal_new("text_popped", filechooser_widget_type, -1, etk_marshaller_VOID__INT_POINTER, NULL, NULL); etk_type_property_add(filechooser_widget_type, "path", ETK_FILECHOOSER_WIDGET_PATH_PROPERTY, ETK_PROPERTY_STRING, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_string(NULL)); - + etk_type_property_add(filechooser_widget_type, "select_multiple", ETK_FILECHOOSER_WIDGET_SELECT_MULTIPLE_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_FALSE)); + etk_type_property_add(filechooser_widget_type, "show_hidden", ETK_FILECHOOSER_WIDGET_SHOW_HIDDEN_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_FALSE)); + filechooser_widget_type->property_set = _etk_filechooser_widget_property_set; filechooser_widget_type->property_get = _etk_filechooser_widget_property_get; } @@ -135,8 +140,11 @@ ecore_list_goto_first(files); while ((file_name = ecore_list_next(files))) { - if (file_name[0] == '.') - continue; + if (!filechooser_widget->show_hidden) + { + if (file_name[0] == '.') + continue; + } free(file_path); file_path = malloc(strlen(folder) + strlen(file_name) + 2); @@ -162,9 +170,12 @@ const char *ext; char *icon = NULL; int i; - - if (file_name[0] == '.') - continue; + + if (!filechooser_widget->show_hidden) + { + if (file_name[0] == '.') + continue; + } free(file_path); file_path = malloc(strlen(folder) + strlen(file_name) + 2); @@ -197,6 +208,112 @@ ecore_list_destroy(files); } +/** + * @brief Retrieve the current folder + * @return Returns the current folder + */ +char *etk_filechooser_widget_current_folder_get(Etk_Filechooser_Widget *filechooser_widget) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget)) || !filechooser_widget->dir_tree) + return NULL; + + return filechooser_widget->current_folder; +} + +/** + * @brief Sets the current filename + * @return + */ +void etk_filechooser_widget_current_file_set(Etk_Filechooser_Widget *filechooser_widget, const char *file) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget)) || !filechooser_widget->files_tree) + return; + + filechooser_widget->current_file = strdup(file); +} + +/** + * @brief Retrieve the currently selected filename + * @return Returns the currenttly selected filename + */ +char *etk_filechooser_widget_current_file_get(Etk_Filechooser_Widget *filechooser_widget) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget)) || !filechooser_widget->files_tree) + return NULL; + + if (!filechooser_widget->current_file) + return NULL; + + return filechooser_widget->current_file; +} + +/** + * @brief Set if the filechooser widget can select multiple files + * @return + */ +void +etk_filechooser_widget_select_multiple_set(Etk_Filechooser_Widget *filechooser_widget, Etk_Bool select_multiple) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget)) || !filechooser_widget->files_tree) + return; + + etk_tree_multiple_select_set(ETK_TREE(filechooser_widget->files_tree), select_multiple); +} + +/** + * @brief Retrieve if the file chooser widget can select multiple files + * @return Returns if the file chooser widget can select multiple files + */ +Etk_Bool +etk_filechooser_widget_select_multiple_get(Etk_Filechooser_Widget *filechooser_widget) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget)) || !filechooser_widget->files_tree) + return ETK_FALSE; + + return etk_tree_multiple_select_get(ETK_TREE(filechooser_widget->files_tree)); +} + +/** + * @brief Sets if the file chooser widget can show hidden files + * @return + */ +void +etk_filechooser_widget_show_hidden_set(Etk_Filechooser_Widget *filechooser_widget, Etk_Bool show_hidden) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget))) + return; + + filechooser_widget->show_hidden = show_hidden; + //etk_filechooser_widget_current_folder_set(filechooser_widget, filechooser_widget->current_folder); +} + +/** + * @brief Retrieve if the file chooser widget can show hidden files + * @return Returns if the file chooser widget can show hidden files + */ +Etk_Bool +etk_filechooser_widget_show_hidden_get(Etk_Filechooser_Widget *filechooser_widget) +{ + Etk_Widget *fcw; + + if (!(fcw = ETK_WIDGET(filechooser_widget))) + return ETK_FALSE; + + return filechooser_widget->show_hidden; +} + /************************** * * Etk specific functions @@ -249,10 +366,15 @@ fcw->files_date_col = etk_tree_col_new(ETK_TREE(fcw->files_tree), "Date", etk_tree_model_text_new(ETK_TREE(fcw->files_tree)), 60); etk_tree_build(ETK_TREE(fcw->files_tree)); etk_widget_show(fcw->files_tree); + etk_signal_connect("row_selected", ETK_OBJECT(fcw->files_tree), ETK_CALLBACK(_etk_filechooser_widget_file_row_selected_cb), fcw); _etk_filechooser_widget_favs_get(ETK_FILECHOOSER_WIDGET(fcw)); fcw->current_folder = NULL; + fcw->current_file = NULL; + fcw->select_multiple = ETK_FALSE; + fcw->show_hidden = ETK_FALSE; + /* Go to home */ etk_filechooser_widget_current_folder_set(ETK_FILECHOOSER_WIDGET(fcw), NULL); } @@ -263,6 +385,7 @@ if (!filechooser_widget) return; free(filechooser_widget->current_folder); + free(filechooser_widget->current_file); } /* Sets the property whose id is "property_id" to the value "value" */ @@ -278,8 +401,14 @@ case ETK_FILECHOOSER_WIDGET_HAS_RESIZE_GRIP_PROPERTY: etk_filechooser_widget_has_resize_grip_set(filechooser_widget, etk_property_value_bool_get(value)); break;*/ - default: - break; + case ETK_FILECHOOSER_WIDGET_SELECT_MULTIPLE_PROPERTY: + etk_filechooser_widget_select_multiple_set(filechooser_widget, etk_property_value_bool_get(value)); + break; + case ETK_FILECHOOSER_WIDGET_SHOW_HIDDEN_PROPERTY: + etk_filechooser_widget_show_hidden_set(filechooser_widget, etk_property_value_bool_get(value)); + break; + default: + break; } } @@ -296,8 +425,14 @@ case ETK_FILECHOOSER_WIDGET_HAS_RESIZE_GRIP_PROPERTY: etk_property_value_bool_set(value, filechooser_widget->has_resize_grip); break;*/ - default: - break; + case ETK_FILECHOOSER_WIDGET_SELECT_MULTIPLE_PROPERTY: + etk_property_value_bool_set(value, etk_filechooser_widget_select_multiple_get(filechooser_widget)); + break; + case ETK_FILECHOOSER_WIDGET_SHOW_HIDDEN_PROPERTY: + etk_property_value_bool_set(value, etk_filechooser_widget_show_hidden_get(filechooser_widget)); + break; + default: + break; } } @@ -368,9 +503,26 @@ return; selected_dir = etk_tree_row_data_get(row); - etk_filechooser_widget_current_folder_set(filechooser_widget, selected_dir); + etk_filechooser_widget_current_folder_set(filechooser_widget, selected_dir); +} + +/* Called when a row of the "files" tree is selected */ +static void _etk_filechooser_widget_file_row_selected_cb(Etk_Object *object, Etk_Tree_Row *row, void *data) +{ + Etk_Filechooser_Widget *filechooser_widget; + char *selected_file; + char *new_file; -} + if (!(filechooser_widget = ETK_FILECHOOSER_WIDGET(data))) + return; + + etk_tree_row_fields_get(row, filechooser_widget->files_name_col, NULL, NULL, &selected_file, NULL); + + new_file = malloc(strlen(filechooser_widget->current_folder) + strlen(selected_file) + 2); + sprintf(new_file, "%s/%s", filechooser_widget->current_folder, selected_file); + etk_filechooser_widget_current_file_set(filechooser_widget, new_file); + free(new_file); +} /************************** *
--- etk_filechooser_widget.h.orig 2006-02-10 05:43:40.000000000 -0500 +++ etk_filechooser_widget.h 2006-02-10 18:54:31.000000000 -0500 @@ -41,15 +41,28 @@ Etk_Widget *files_tree; Etk_Tree_Col *files_name_col; Etk_Tree_Col *files_date_col; + + Etk_Bool select_multiple; + Etk_Bool show_hidden; char *current_folder; + char *current_file; }; Etk_Type *etk_filechooser_widget_type_get(); Etk_Widget *etk_filechooser_widget_new(); +void etk_filechooser_widget_select_multiple_set(Etk_Filechooser_Widget *filechooser_widget, Etk_Bool select_multiple); +Etk_Bool etk_filechooser_widget_select_multiple_get(Etk_Filechooser_Widget *filechooser_widget); + +void etk_filechooser_widget_show_hidden_set(Etk_Filechooser_Widget *filechooser_widget, Etk_Bool show_hidden); +Etk_Bool etk_filechooser_widget_show_hidden_get(Etk_Filechooser_Widget *filechooser_widget); + void etk_filechooser_widget_current_folder_set(Etk_Filechooser_Widget *filechooser_widget, const char *folder); +char *etk_filechooser_widget_current_folder_get(Etk_Filechooser_Widget *filechooser_widget); +void etk_filechooser_widget_current_file_set(Etk_Filechooser_Widget *filechooser_widget, const char *file); +char *etk_filechooser_widget_current_file_get(Etk_Filechooser_Widget *filechooser_widget); /** @} */