#include <Elementary.h>
#include "elm_priv.h"
-/**
- * @defgroup File_Selector_Button File Selector Button
- *
- * A button that, when clicked, creates an Elementary window (or inner
- * window) with an Elementary File Selector within. When a file is
- * chosen, the (inner) window is closed and the selected file is
- * exposed as an evas_object_smart_callback_call() of the button.
- */
-
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
static const char *widtype = NULL;
+static void _del_pre_hook(Evas_Object *obj);
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _disable_hook(Evas_Object *obj);
Evas *e,
Evas_Object *obj,
void *event_info);
+static void _button_clicked(void *data,
+ Evas_Object *obj,
+ void *event_info);
static void _on_focus_hook(void *data,
Evas_Object *obj);
static void _selection_done(void *data,
};
static void
+_del_pre_hook(Evas_Object *obj)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ evas_object_event_callback_del_full(wd->btn, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ evas_object_smart_callback_del(wd->btn, "clicked", _button_clicked);
+}
+
+static void
_del_hook(Evas_Object *obj)
{
Evas_Object *win;
(void *)wd->fsd.path);
}
-/**
- * Add a new file selector button into the parent object.
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup File_Selector_Button
- */
+static void
+_elm_fileselector_button_label_set(Evas_Object *obj, const char *item,
+ const char *label)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ if (item && strcmp(item, "default")) return;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ elm_object_text_set(wd->btn, label);
+}
+
+static const char *
+_elm_fileselector_button_label_get(const Evas_Object *obj, const char *item)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (item && strcmp(item, "default")) return NULL;
+ if (!wd) return NULL;
+ return elm_object_text_get(wd->btn);
+}
+
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ elm_object_part_content_set(wd->btn, part, content);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return elm_object_part_content_get(wd->btn, part);
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return elm_object_part_content_unset(wd->btn, part);
+}
+
EAPI Evas_Object *
elm_fileselector_button_add(Evas_Object *parent)
{
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
+ elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_disable_hook_set(obj, _disable_hook);
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_activate_hook_set(obj, _activate_hook);
+ elm_widget_text_set_hook_set(obj, _elm_fileselector_button_label_set);
+ elm_widget_text_get_hook_set(obj, _elm_fileselector_button_label_get);
+ elm_widget_content_set_hook_set(obj, _content_set_hook);
+ elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_content_unset_hook_set(obj, _content_unset_hook);
wd->self = obj;
wd->window_title = eina_stringshare_add(DEFAULT_WINDOW_TITLE);
return obj;
}
-/**
- * Set the label used in the file selector button.
- *
- * @param obj The button object
- * @param label The text label text to be displayed on the button
- *
- * @ingroup File_Selector_Button
- */
-EAPI void
-elm_fileselector_button_label_set(Evas_Object *obj,
- const char *label)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- elm_button_label_set(wd->btn, label);
-}
-/**
- * Get the label used in the file selector button.
- *
- * @param obj The button object
- * @return The button label
- *
- * @ingroup File_Selector_Button
- */
-EAPI const char *
-elm_fileselector_button_label_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return elm_button_label_get(wd->btn);
-}
-
-/**
- * Set the title of the file selector button's window.
- *
- * @param obj The button object
- * @param title The title string
- *
- * Note that it will only take any effect if the fileselector button
- * not at "inwin mode".
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_window_title_set(Evas_Object *obj,
const char *title)
elm_win_title_set(wd->fsw, wd->window_title);
}
-/**
- * Get the title of the file selector button's window.
- *
- * @param obj The button object
- * @return Title of the file selector button's window
- *
- * @ingroup File_Selector_Button
- */
EAPI const char *
elm_fileselector_button_window_title_get(const Evas_Object *obj)
{
return wd->window_title;
}
-/**
- * Set the size of the file selector button's window.
- *
- * @param obj The button object
- * @param width The width
- * @param height The height
- *
- * Note that it will only take any effect if the fileselector button not at
- * "inwin mode". Default size for the window (when applicable) is 400x400.
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_window_size_set(Evas_Object *obj,
Evas_Coord width,
evas_object_resize(wd->fsw, wd->w, wd->h);
}
-/**
- * Get the size of the file selector button's window.
- *
- * @param obj The button object
- * @param width Pointer into which to store the width value
- * @param height Pointer into which to store the height value
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_window_size_get(const Evas_Object *obj,
Evas_Coord *width,
if (height) *height = wd->h;
}
-/**
- * Set the starting path of the file selector button's window.
- *
- * @param obj The button object
- * @param path The path string
- *
- * It must be a <b>directory</b> path.
- * Default path is "HOME" environment variable's value.
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_path_set(Evas_Object *obj,
const char *path)
elm_fileselector_selected_set(wd->fs, wd->fsd.path);
}
-/**
- * Get the <b>last</b> path of the file selector button's window.
- *
- * @param obj The button object
- *
- * @ingroup File_Selector_Button
- */
EAPI const char *
elm_fileselector_button_path_get(const Evas_Object *obj)
{
return wd->fsd.path;
}
-/**
- * Set whether the button's file selector is to present itself as an
- * Elementary Generic List (which will expand its entries for nested
- * directories) or as canonical list, which will be rendered again
- * with the contents of each selected directory.
- *
- * @param obj The button object
- * @param value The expandable flag
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_expandable_set(Evas_Object *obj,
Eina_Bool value)
elm_fileselector_expandable_set(wd->fs, wd->fsd.expandable);
}
-/**
- * Get the button's file selector expandable flag.
- *
- * @param obj The button object
- * @return value The expandable flag
- *
- * @ingroup File_Selector_Button
- */
EAPI Eina_Bool
elm_fileselector_button_expandable_get(const Evas_Object *obj)
{
return wd->fsd.expandable;
}
-/**
- * Set whether the button's file selector list is to display folders
- * only or the directory contents, as well.
- *
- * @param obj The button object
- * @param value The "folder only" flag
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_folder_only_set(Evas_Object *obj,
Eina_Bool value)
elm_fileselector_folder_only_set(wd->fs, wd->fsd.folder_only);
}
-/**
- * Get the button's file selector "folder only" flag.
- *
- * @param obj The button object
- * @return value The "folder only" flag
- *
- * @ingroup File_Selector_Button
- */
EAPI Eina_Bool
elm_fileselector_button_folder_only_get(const Evas_Object *obj)
{
return wd->fsd.folder_only;
}
-/**
- * Set whether the button's file selector has an editable text entry
- * which will hold its current selection.
- *
- * @param obj The button object
- * @param value The "is save" flag
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_is_save_set(Evas_Object *obj,
Eina_Bool value)
elm_fileselector_is_save_set(wd->fs, wd->fsd.is_save);
}
-/**
- * Get the button's file selector "is save" flag.
- *
- * @param obj The button object
- * @return value The "is save" flag
- *
- * @ingroup File_Selector_Button
- */
EAPI Eina_Bool
elm_fileselector_button_is_save_get(const Evas_Object *obj)
{
return wd->fsd.is_save;
}
-/**
- * Set whether the button's file selector will raise an Elementary
- * Inner Window, instead of a dedicated Elementary Window. By default,
- * it won't.
- *
- * @param obj The button object
- * @param value The "inwin mode" flag
- *
- * @ingroup File_Selector_Button
- */
EAPI void
elm_fileselector_button_inwin_mode_set(Evas_Object *obj,
Eina_Bool value)
wd->inwin_mode = value;
}
-/**
- * Get the button's file selector "inwin mode" flag.
- *
- * @param obj The button object
- * @return value The "inwin mode" flag
- *
- * @ingroup File_Selector_Button
- */
EAPI Eina_Bool
elm_fileselector_button_inwin_mode_get(const Evas_Object *obj)
{
if (!wd) return EINA_FALSE;
return wd->inwin_mode;
}
-
-/**
- * Set the icon used for the button
- *
- * Once the icon object is set, a previously set one will be deleted.
- * If you want to keep that old content object, use the
- * elm_fileselector_button_icon_unset() function.
- *
- * @param obj The button object
- * @param icon The icon object for the button
- *
- * @ingroup File_Selector_Button
- */
-EAPI void
-elm_fileselector_button_icon_set(Evas_Object *obj,
- Evas_Object *icon)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd)
- {
- evas_object_del(icon);
- return;
- }
- elm_button_icon_set(wd->btn, icon);
-}
-
-/**
- * Get the icon used for the button
- *
- * @param obj The button object
- * @return The icon object that is being used
- *
- * @ingroup File_Selector_Button
- */
-EAPI Evas_Object *
-elm_fileselector_button_icon_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return elm_button_icon_get(wd->btn);
-}
-
-/**
- * Unset the icon used for the button
- *
- * Unparent and return the icon object which was set for this widget.
- *
- * @param obj The button object
- * @return The icon object that was being used
- *
- * @ingroup File_Selector_Button
- */
-EAPI Evas_Object *
-elm_fileselector_button_icon_unset(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return elm_button_icon_unset(wd->btn);
-}
-