diff options
author | Christopher Michael <cpmichael1@comcast.net> | 2006-09-01 17:21:23 +0000 |
---|---|---|
committer | Christopher Michael <cpmichael1@comcast.net> | 2006-09-01 17:21:23 +0000 |
commit | 3bd22b5c7086c4da10c60f052e052e2edf4ebe7a (patch) | |
tree | 7c4e92126ef2f7f3eee704a90c655e4a68f3c99e /src/bin | |
parent | 743ff19503b373e937269d718c4f3957fc709b50 (diff) | |
download | enlightenment-3bd22b5c7086c4da10c60f052e052e2edf4ebe7a.tar.gz |
Added theme import dialog :) Auto-sets to the imported theme.
Some cleanup on wallpaper import dialog.
SVN revision: 25302
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/Makefile.am | 2 | ||||
-rw-r--r-- | src/bin/e_includes.h | 1 | ||||
-rw-r--r-- | src/bin/e_int_config_theme.c | 78 | ||||
-rw-r--r-- | src/bin/e_int_config_theme.h | 2 | ||||
-rw-r--r-- | src/bin/e_int_config_theme_import.c | 350 | ||||
-rw-r--r-- | src/bin/e_int_config_theme_import.h | 10 |
6 files changed, 441 insertions, 2 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 7bea582023..4919441e11 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -129,6 +129,7 @@ e_widget_slider.h \ e_int_config_window_manipulation.h \ e_int_config_window_display.h \ e_int_config_theme.h \ +e_int_config_theme_import.h \ e_int_config_icon_themes.h \ e_int_config_menus.h \ e_int_config_keybindings.h \ @@ -282,6 +283,7 @@ e_widget_slider.c \ e_int_config_window_manipulation.c \ e_int_config_window_display.c \ e_int_config_theme.c \ +e_int_config_theme_import.c \ e_int_config_icon_themes.c \ e_int_config_menus.c \ e_int_config_keybindings.c \ diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index 7bc59c3eec..653af49708 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -102,6 +102,7 @@ #include "e_int_config_window_manipulation.h" #include "e_int_config_window_display.h" #include "e_int_config_theme.h" +#include "e_int_config_theme_import.h" #include "e_int_config_icon_themes.h" #include "e_int_config_menus.h" #include "e_int_config_keybindings.h" diff --git a/src/bin/e_int_config_theme.c b/src/bin/e_int_config_theme.c index ad1445c981..ef4f762714 100644 --- a/src/bin/e_int_config_theme.c +++ b/src/bin/e_int_config_theme.c @@ -22,6 +22,9 @@ struct _E_Config_Dialog_Data int fmdir; char *theme; + + /* Dialog */ + E_Win *win_import; }; EAPI E_Config_Dialog * @@ -44,6 +47,53 @@ e_int_config_theme(E_Container *con) return cfd; } +EAPI void +e_int_config_theme_import_done(E_Config_Dialog *dia) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = dia->cfdata; + cfdata->win_import = NULL; +} + +EAPI void +e_int_config_theme_update(E_Config_Dialog *dia, char *file) +{ + E_Config_Dialog_Data *cfdata; + char *homedir, path[4096]; + + cfdata = dia->cfdata; + + homedir = e_user_homedir_get(); + if (!homedir) return; + cfdata->fmdir = 1; + e_widget_radio_toggle_set(cfdata->o_personal, 1); + + snprintf(path, sizeof(path), "%s/.e/e/themes", homedir); + E_FREE(homedir); + E_FREE(cfdata->theme); + cfdata->theme = strdup(file); + + if (cfdata->o_fm) + e_fm2_path_set(cfdata->o_fm, path, "/"); + + if (cfdata->o_preview) + e_widget_preview_edje_set(cfdata->o_preview, cfdata->theme, "e/desktop/background"); + if (cfdata->o_frame) + e_widget_change(cfdata->o_frame); + +/* + + if (cfdata->o_fm) + { + e_fm2_select_set(cfdata->o_fm, file, 1); + e_fm2_file_show(cfdata->o_fm, file); + + evas_object_smart_callback_call(cfdata->o_fm, + "selection_change", cfdata); + } + */ +} static void _cb_button_up(void *data1, void *data2) @@ -86,19 +136,24 @@ _cb_files_selection_change(void *data, Evas_Object *obj, void *event_info) E_Fm2_Icon_Info *ici; const char *realpath; char buf[4096]; - + cfdata = data; if (!cfdata->o_fm) return; + selected = e_fm2_selected_list_get(cfdata->o_fm); if (!selected) return; + ici = selected->data; realpath = e_fm2_real_path_get(cfdata->o_fm); + if (!strcmp(realpath, "/")) snprintf(buf, sizeof(buf), "/%s", ici->file); else snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file); evas_list_free(selected); + if (ecore_file_is_dir(buf)) return; + E_FREE(cfdata->theme); cfdata->theme = strdup(buf); if (cfdata->o_preview) @@ -207,7 +262,17 @@ _cb_files_files_deleted(void *data, Evas_Object *obj, void *event_info) evas_object_smart_callback_call(cfdata->o_fm, "selection_change", cfdata); } - +static void +_cb_import(void *data1, void *data2) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data1; + if (cfdata->win_import) + e_win_raise(cfdata->win_import); + else + cfdata->win_import = e_int_config_theme_import(cfdata->cfd); +} static void _fill_data(E_Config_Dialog_Data *cfdata) @@ -264,6 +329,9 @@ _create_data(E_Config_Dialog *cfd) static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { + if (cfdata->win_import) + e_int_config_theme_del(cfdata->win_import); + E_FREE(cfdata->theme); free(cfdata); } @@ -356,6 +424,12 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_table_object_append(ot, ol, 0, 0, 1, 1, 1, 1, 1, 1); of = e_widget_list_add(evas, 0, 0); + + il = e_widget_list_add(evas, 0, 1); + o = e_widget_button_add(evas, _("Import..."), "enlightenment/theme", + _cb_import, cfdata, NULL); + e_widget_list_object_append(il, o, 1, 0, 0.5); + e_widget_list_object_append(of, il, 1, 0, 0.0); o = e_widget_preview_add(evas, 320, (320 * z->h) / z->w); cfdata->o_preview = o; diff --git a/src/bin/e_int_config_theme.h b/src/bin/e_int_config_theme.h index 4021c816a9..43c30612b2 100644 --- a/src/bin/e_int_config_theme.h +++ b/src/bin/e_int_config_theme.h @@ -7,6 +7,8 @@ #define E_INT_CONFIG_THEME_H EAPI E_Config_Dialog *e_int_config_theme(E_Container *con); +EAPI void e_int_config_theme_import_done(E_Config_Dialog *dia); +EAPI void e_int_config_theme_update(E_Config_Dialog *dia, char *file); #endif #endif diff --git a/src/bin/e_int_config_theme_import.c b/src/bin/e_int_config_theme_import.c new file mode 100644 index 0000000000..08b645368b --- /dev/null +++ b/src/bin/e_int_config_theme_import.c @@ -0,0 +1,350 @@ +#include "e.h" + +typedef struct _Import Import; + +struct _Import +{ + E_Config_Dialog *parent; + E_Config_Dialog_Data *cfdata; + + Evas_Object *bg_obj; + Evas_Object *box_obj; + Evas_Object *content_obj; + Evas_Object *event_obj; + Evas_Object *fsel_obj; + + Evas_Object *ok_obj; + Evas_Object *cancel_obj; + + E_Win *win; +}; + +struct _E_Config_Dialog_Data +{ + char *file; +}; + +static void _theme_import_cb_delete (E_Win *win); +static void _theme_import_cb_resize (E_Win *win); +static void _theme_import_cb_wid_focus (void *data, Evas_Object *obj); +static void _theme_import_cb_selected (void *data, Evas_Object *obj); +static void _theme_import_cb_changed (void *data, Evas_Object *obj); +static void _theme_import_cb_ok (void *data, void *data2); +static void _theme_import_cb_close (void *data, void *data2); +static void _theme_import_cb_key_down (void *data, Evas *e, Evas_Object *obj, + void *event); + +EAPI E_Win * +e_int_config_theme_import(E_Config_Dialog *parent) +{ + Evas *evas; + E_Win *win; + Evas_Object *o, *ofm; + Import *import; + E_Config_Dialog_Data *cfdata; + Evas_Modifier_Mask mask; + Evas_Coord w, h; + + import = E_NEW(Import, 1); + if (!import) return NULL; + + win = e_win_new(parent->con); + if (!win) + { + E_FREE(import); + return NULL; + } + + evas = e_win_evas_get(win); + + cfdata = E_NEW(E_Config_Dialog_Data, 1); + import->cfdata = cfdata; + import->win = win; + import->parent = parent; + + e_win_title_set(win, _("Select a Theme...")); + e_win_delete_callback_set(win, _theme_import_cb_delete); + e_win_resize_callback_set(win, _theme_import_cb_resize); + e_win_dialog_set(win, 1); + e_win_name_class_set(win, "E", "_theme_import_dialog"); + + o = edje_object_add(evas); + import->bg_obj = o; + e_theme_edje_object_set(o, "base/theme/dialog", "e/widgets/dialog/main"); + evas_object_move(o, 0, 0); + evas_object_show(o); + + o = e_widget_list_add(evas, 1, 1); + e_widget_on_focus_hook_set(o, _theme_import_cb_wid_focus, import); + import->box_obj = o; + edje_object_part_swallow(import->bg_obj, "e.swallow.buttons", o); + + o = evas_object_rectangle_add(evas); + import->event_obj = o; + mask = 0; + evas_object_key_grab(o, "Tab", mask, ~mask, 0); + mask = evas_key_modifier_mask_get(evas, "Shift"); + evas_object_key_grab(o, "Tab", mask, ~mask, 0); + mask = 0; + evas_object_key_grab(o, "Return", mask, ~mask, 0); + mask = 0; + evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0); + mask = 0; + evas_object_key_grab(o, "Space", mask, ~mask, 0); + mask = 0; + evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, + _theme_import_cb_key_down, import); + + o = e_widget_list_add(evas, 0, 0); + import->content_obj = o; + + ofm = e_widget_fsel_add(evas, e_user_homedir_get(), "/", + NULL, NULL, + _theme_import_cb_selected, import, + _theme_import_cb_changed, import, 1); + import->fsel_obj = ofm; + e_widget_list_object_append(o, ofm, 1, 1, 0.5); + + e_widget_min_size_get(o, &w, &h); + edje_extern_object_min_size_set(o, w, h); + edje_object_part_swallow(import->bg_obj, "e.swallow.content", o); + evas_object_show(o); + + import->ok_obj = e_widget_button_add(evas, _("OK"), NULL, + _theme_import_cb_ok, win, cfdata); + e_widget_list_object_append(import->box_obj, import->ok_obj, 1, 0, 0.5); + + import->cancel_obj = e_widget_button_add(evas, _("Cancel"), NULL, + _theme_import_cb_close, + win, cfdata); + e_widget_list_object_append(import->box_obj, import->cancel_obj, 1, 0, 0.5); + + e_widget_disabled_set(import->ok_obj, 1); + + e_win_centered_set(win, 1); + + o = import->box_obj; + e_widget_min_size_get(o, &w, &h); + edje_extern_object_min_size_set(o, w, h); + edje_object_part_swallow(import->bg_obj, "e.swallow.buttons", o); + + edje_object_size_min_calc(import->bg_obj, &w, &h); + evas_object_resize(import->bg_obj, w, h); + e_win_resize(win, w, h); + e_win_size_min_set(win, w, h); + e_win_size_max_set(win, 99999, 99999); + e_win_show(win); + + win->data = import; + + return win; +} + +EAPI void +e_int_config_theme_del(E_Win *win) +{ + Import *import; + + import = win->data; + + e_object_del(E_OBJECT(import->win)); + e_int_config_theme_import_done(import->parent); + + E_FREE(import->cfdata); + E_FREE(import); + + return; +} + +static void +_theme_import_cb_delete(E_Win *win) +{ + e_int_config_theme_del(win); +} + +static void +_theme_import_cb_resize(E_Win *win) +{ + Import *import; + + import = win->data; + if (!import) return; + evas_object_resize(import->bg_obj, win->w, win->h); +} + +static void +_theme_import_cb_wid_focus(void *data, Evas_Object *obj) +{ + Import *import; + + import = data; + if (obj == import->content_obj) + e_widget_focused_object_clear(import->box_obj); + else if (import->content_obj) + e_widget_focused_object_clear(import->content_obj); +} + +static void +_theme_import_cb_selected(void *data, Evas_Object *obj) +{ + Import *import; + + import = data; + _theme_import_cb_ok(import->win, NULL); +} + +static void +_theme_import_cb_changed(void *data, Evas_Object *obj) +{ + Import *import; + const char *path; + const char *file; + + import = data; + if (!import) return; + if (!import->fsel_obj) return; + + path = e_widget_fsel_selection_path_get(import->fsel_obj); + E_FREE(import->cfdata->file); + if (path) + import->cfdata->file = strdup(path); + + if (import->cfdata->file) + { + file = ecore_file_get_file(import->cfdata->file); + if (!ecore_file_strip_ext(file)) + { + E_FREE(import->cfdata->file); + e_widget_disabled_set(import->ok_obj, 1); + return; + } + if (!e_util_glob_case_match(file, "*.edj")) + { + E_FREE(import->cfdata->file); + e_widget_disabled_set(import->ok_obj, 1); + return; + } + e_widget_disabled_set(import->ok_obj, 0); + } + else + e_widget_disabled_set(import->ok_obj, 1); +} + +static void +_theme_import_cb_ok(void *data, void *data2) +{ + Import *import; + E_Win *win; + const char *path; + const char *file; + char *homedir; + char buf[4096]; + + win = data; + import = win->data; + if (!import) return; + + homedir = e_user_homedir_get(); + if (!homedir) return; + + path = e_widget_fsel_selection_path_get(import->fsel_obj); + E_FREE(import->cfdata->file); + if (path) + import->cfdata->file = strdup(path); + + if (import->cfdata->file) + { + file = ecore_file_get_file(import->cfdata->file); + if (!ecore_file_strip_ext(file)) + { + E_FREE(homedir); + return; + } + if (!e_util_glob_case_match(file, "*.edj")) + { + E_FREE(homedir); + return; + } + + /* Copy File */ + snprintf(buf, sizeof(buf), "%s/.e/e/themes/%s", homedir, file); + if (!ecore_file_cp(import->cfdata->file, buf)) + { + e_util_dialog_show(_("Theme Import Error"), + _("Enlightenment was unable to import" + "the theme<br>due to a copy error")); + } + else + e_int_config_theme_update(import->parent, buf); + } + + e_int_config_theme_del(import->win); +} + +static void +_theme_import_cb_close(void *data, void *data2) +{ + E_Win *win; + + win = data; + e_int_config_theme_del(win); +} + +static void +_theme_import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event) +{ + Evas_Event_Key_Down *ev; + Import *import; + + ev = event; + import = data; + if (!strcmp(ev->keyname, "Tab")) + { + if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(import->win)), "Shift")) + { + if (e_widget_focus_get(import->box_obj)) + { + if (!e_widget_focus_jump(import->box_obj, 0)) + { + e_widget_focus_set(import->content_obj, 0); + if (!e_widget_focus_get(import->content_obj)) + e_widget_focus_set(import->box_obj, 0); + } + } + else + { + if (!e_widget_focus_jump(import->content_obj, 0)) + e_widget_focus_set(import->box_obj, 0); + } + } + else + { + if (e_widget_focus_get(import->box_obj)) + { + if (!e_widget_focus_jump(import->box_obj, 1)) + { + e_widget_focus_set(import->content_obj, 1); + if (!e_widget_focus_get(import->content_obj)) + e_widget_focus_set(import->box_obj, 1); + } + } + else + { + if (!e_widget_focus_jump(import->content_obj, 1)) + e_widget_focus_set(import->box_obj, 1); + } + } + } + else if (((!strcmp(ev->keyname, "Return")) || + (!strcmp(ev->keyname, "KP_Enter")) || + (!strcmp(ev->keyname, "space")))) + { + Evas_Object *o = NULL; + + if ((import->content_obj) && (e_widget_focus_get(import->content_obj))) + o = e_widget_focused_object_get(import->content_obj); + else + o = e_widget_focused_object_get(import->box_obj); + if (o) e_widget_activate(o); + } +} diff --git a/src/bin/e_int_config_theme_import.h b/src/bin/e_int_config_theme_import.h new file mode 100644 index 0000000000..ab838ec493 --- /dev/null +++ b/src/bin/e_int_config_theme_import.h @@ -0,0 +1,10 @@ +#ifdef E_TYPEDEFS +#else +#ifndef E_INT_CONFIG_THEME_IMPORT_H +#define E_INT_CONFIG_THEME_IMPORT_H + +EAPI E_Win *e_int_config_theme_import (E_Config_Dialog *parent); +EAPI void e_int_config_theme_del (E_Win *win); + +#endif +#endif |