From a964e85dc2dfd03f32010ce4f4fa8070aae8b9cc Mon Sep 17 00:00:00 2001 From: Davide Andreoli Date: Sat, 11 Oct 2008 00:59:21 +0000 Subject: [PATCH] Add configuration options to gadman. Now you can choose the type of background (theme default, custom color, custom image or transparent). And you can also choose to enable/disable the animations for gadgets/background. The custom background image can be any of the e17 background or even a normal (jpg, png..) image. This BREAK all existing themes :( I will update the b_and_w theme tomorrow SVN revision: 36576 --- data/themes/default_gadman.edc | 140 +++++++++++++--- src/modules/gadman/e_mod_config.c | 267 +++++++++++++++++++++++++++++- src/modules/gadman/e_mod_config.h | 2 +- src/modules/gadman/e_mod_gadman.c | 156 ++++++++++++----- src/modules/gadman/e_mod_gadman.h | 24 ++- src/modules/gadman/e_mod_main.c | 46 ++++- 6 files changed, 564 insertions(+), 71 deletions(-) diff --git a/data/themes/default_gadman.edc b/data/themes/default_gadman.edc index 0616869ff..11562bb0a 100644 --- a/data/themes/default_gadman.edc +++ b/data/themes/default_gadman.edc @@ -1430,36 +1430,114 @@ group { group { name: "e/gadman/full_bg"; parts { - part{ - name: "bg"; - type: RECT; - mouse_events: 1; + part { + name: "bg"; + type: RECT; + mouse_events: 0; description { - state: "default" 0.0; - color: 255 255 255 200; + state: "default" 0.0; + color: 255 255 255 0; } description { - state: "hidden" 0.0; - color: 255 255 255 0; + state: "visible" 0.0; + color: 255 255 255 200; } } + part { + name: "custom_bg"; + type: RECT; + description { + state: "default" 0.0; + color: 255 255 255 0; + } + description { + state: "visible" 0.0; + color: 255 255 255 200; + } + } + part { + name: "e.swallow.bg"; + type: SWALLOW; + clip_to: "custom_bg"; + description { + state: "default" 0.0; + } + } + part { + name: "grabber"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } } programs { program { - name: "hide"; - signal: "e,state,visibility,hide"; - source: "e"; - action: STATE_SET "hidden" 0.0; - transition: LINEAR 0.4; - target: "bg"; + name: "show"; + signal: "e,state,visibility,show"; + source: "e"; + action: STATE_SET "visible" 0.0; + transition: LINEAR 0.4; + target: "bg"; } program { - name: "show"; - signal: "e,state,visibility,show"; - source: "e"; - action: STATE_SET "default" 0.0; - transition: LINEAR 0.4; - target: "bg"; + name: "show_now"; + signal: "e,state,visibility,show,now"; + source: "e"; + action: STATE_SET "visible" 0.0; + transition: LINEAR 0.0; + target: "bg"; + } + program { + name: "hide"; + signal: "e,state,visibility,hide"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.4; + target: "bg"; + } + program { + name: "hide_now"; + signal: "e,state,visibility,hide,now"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.0; + target: "bg"; + } + program { + name: "show_custom"; + signal: "e,state,visibility,show,custom"; + source: "e"; + action: STATE_SET "visible" 0.0; + transition: LINEAR 0.4; + target: "custom_bg"; + } + program { + name: "show_custom_now"; + signal: "e,state,visibility,show,custom,now"; + source: "e"; + action: STATE_SET "visible" 0.0; + transition: LINEAR 0.0; + target: "custom_bg"; + } + program { + name: "hide_custom"; + signal: "e,state,visibility,hide,custom"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.4; + target: "custom_bg"; + } + program { + name: "hide_custom_now"; + signal: "e,state,visibility,hide,custom,now"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.0; + target: "custom_bg"; } } } @@ -1618,6 +1696,17 @@ group { target: "overlay"; target: "e.swallow.content"; } + program { + name: "hide_now"; + signal: "e,state,visibility,hide,now"; + source: "e"; + action: STATE_SET "hidden" 0.0; + transition: ACCELERATE 0.0; + target: "items_clip"; + target: "background"; + target: "overlay"; + target: "e.swallow.content"; + } program { name: "show"; signal: "e,state,visibility,show"; @@ -1629,5 +1718,16 @@ group { target: "overlay"; target: "e.swallow.content"; } + program { + name: "show_now"; + signal: "e,state,visibility,show,now"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.0; + target: "items_clip"; + target: "background"; + target: "overlay"; + target: "e.swallow.content"; + } } } diff --git a/src/modules/gadman/e_mod_config.c b/src/modules/gadman/e_mod_config.c index aafa3d616..587204f4d 100644 --- a/src/modules/gadman/e_mod_config.c +++ b/src/modules/gadman/e_mod_config.c @@ -8,6 +8,14 @@ struct _E_Config_Dialog_Data { Evas_Object *o_avail; //List of available gadgets Evas_Object *o_add; //Add button + Evas_Object *o_fm; //Filemanager Object + Evas_Object *o_sf; //Filemanager Scrollframe + Evas_Object *o_btn; //Filemanager updir button + E_Color *color; //Custom Color + int bg_method; //Type of background + int anim_bg; //Anim the background + int anim_gad; //Anim the gadgets + int fmdir; //Filemanager dir (personal or system) }; /* Local protos */ @@ -15,12 +23,19 @@ static void *_create_data(E_Config_Dialog *cfd); static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +static Evas_Object *_adv_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); +static int _adv_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static void _fill_gadgets_list(Evas_Object *ilist); static void _cb_add(void *data, void *data2); static void _avail_list_cb_change(void *data, Evas_Object *obj); +static void _cb_fm_radio_change(void *data, Evas_Object *obj); +static void _cb_color_changed(void *data, Evas_Object *o); +static void _cb_fm_change(void *data, Evas_Object *obj, void *event_info); +static void _cb_fm_sel_change(void *data, Evas_Object *obj, void *event_info); +static void _cb_button_up(void *data1, void *data2); EAPI E_Config_Dialog * -e_int_config_gadman_module(E_Container *con, const char *params __UNUSED__) +_config_gadman_module(E_Container *con, const char *params __UNUSED__) { E_Config_Dialog *cfd; E_Config_Dialog_View *v; @@ -34,9 +49,10 @@ e_int_config_gadman_module(E_Container *con, const char *params __UNUSED__) v = E_NEW(E_Config_Dialog_View, 1); v->create_cfdata = _create_data; v->free_cfdata = _free_data; - v->basic.apply_cfdata = _basic_apply_data; v->basic.create_widgets = _basic_create_widgets; - v->override_auto_apply = 0; //TODO this should remove the ok/apply buttons ... but doesnt work :( + v->basic.apply_cfdata = _basic_apply_data; + v->advanced.create_widgets = _adv_create_widgets; + v->advanced.apply_cfdata = _adv_apply_data; snprintf(buf, sizeof(buf), "%s/e-module-gadman.edj", Man->module->dir); cfd = e_config_dialog_new(con, _("Gadgets Manager"), @@ -44,7 +60,6 @@ e_int_config_gadman_module(E_Container *con, const char *params __UNUSED__) buf, 0, v, Man); Man->config_dialog = cfd; - return Man->config_dialog; } @@ -54,6 +69,23 @@ _create_data(E_Config_Dialog *cfd) E_Config_Dialog_Data *cfdata; cfdata = E_NEW(E_Config_Dialog_Data, 1); + cfdata->bg_method = Man->conf->bg_type; + if (Man->conf->custom_bg) + { + if (!strstr(Man->conf->custom_bg, e_user_homedir_get())) + cfdata->fmdir = 1; + } + + cfdata->color = E_NEW(E_Color, 1); + cfdata->color->r = Man->conf->color_r; + cfdata->color->g = Man->conf->color_g; + cfdata->color->b = Man->conf->color_b; + cfdata->color->a = Man->conf->color_a; + cfdata->anim_bg = Man->conf->anim_bg; + cfdata->anim_gad = Man->conf->anim_gad; + + e_color_update_rgb(cfdata->color); + return cfdata; } @@ -61,6 +93,7 @@ static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { Man->config_dialog = NULL; + E_FREE(cfdata->color); E_FREE(cfdata); } @@ -87,7 +120,8 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_framelist_object_append(of, ob); e_widget_list_object_append(o, of, 1, 1, 0.5); - + e_dialog_resizable_set(cfd->dia, 1); + return o; } @@ -99,6 +133,151 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) return 1; } +static Evas_Object * +_adv_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +{ + Evas_Object *rt, *ow, *ft, *of; + E_Radio_Group *rg; + E_Fm2_Config fmc; + char path[PATH_MAX]; + + ft = e_widget_table_add(evas, 0); + + //Background mode + of = e_widget_frametable_add(evas, _("Background Mode"), 0); + rg = e_widget_radio_group_new(&(cfdata->bg_method)); + ow = e_widget_radio_add(evas, _("Theme Defined"), BG_STD, rg); + //~ evas_object_smart_callback_add(ow, "changed", _cb_method_change, cfdata); + e_widget_frametable_object_append(of, ow, 0, 0, 1, 1, 1, 0, 1, 0); + ow = e_widget_radio_add(evas, _("Custom Image"), BG_CUSTOM, rg); + //~ evas_object_smart_callback_add(cfdata->o_custom, "changed", + //~ _cb_method_change, cfdata); + e_widget_frametable_object_append(of, ow, 0, 1, 1, 1, 1, 0, 1, 0); + ow = e_widget_radio_add(evas, _("Custom Color"), BG_COLOR, rg); + //~ evas_object_smart_callback_add(cfdata->o_custom, "changed", + //~ _cb_method_change, cfdata); + e_widget_frametable_object_append(of, ow, 0, 2, 1, 1, 1, 0, 1, 0); + ow = e_widget_radio_add(evas, _("Transparent"), BG_TRANS, rg); + //~ evas_object_smart_callback_add(cfdata->o_custom, "changed", + //~ _cb_method_change, cfdata); + e_widget_frametable_object_append(of, ow, 0, 3, 1, 1, 1, 0, 1, 0); + e_widget_table_object_append(ft, of, 0, 0, 1, 1, 1, 1, 1, 1); + + //Animations + of = e_widget_frametable_add(evas, _("Animations"), 0); + ow = e_widget_check_add(evas, "Background", &(cfdata->anim_bg)); + e_widget_frametable_object_append(of, ow, 0, 0, 1, 1, 1, 0, 1, 0); + + ow = e_widget_check_add(evas, "Gadgets", &(cfdata->anim_gad)); + e_widget_frametable_object_append(of, ow, 0, 1, 1, 1, 1, 0, 1, 0); + + e_widget_table_object_append(ft, of, 0, 1, 1, 1, 1, 1, 1, 1); + + //Custom Color + of = e_widget_framelist_add(evas, _("Custom Color"), 0); + ow = e_widget_color_well_add(evas, cfdata->color, 1); + e_widget_framelist_object_append(of, ow); + e_widget_on_change_hook_set(ow, _cb_color_changed, cfdata); + e_widget_table_object_append(ft, of, 0, 2, 1, 1, 1, 1, 1, 1); + + //Background filemanager chooser + of = e_widget_frametable_add(evas, _("Custom Image"), 0); + rg = e_widget_radio_group_new(&(cfdata->fmdir)); + ow = e_widget_radio_add(evas, _("Personal"), 0, rg); + e_widget_on_change_hook_set(ow, _cb_fm_radio_change, cfdata); + e_widget_frametable_object_append(of, ow, 0, 0, 1, 1, 1, 1, 0, 0); + ow = e_widget_radio_add(evas, _("System"), 1, rg); + e_widget_on_change_hook_set(ow, _cb_fm_radio_change, cfdata); + e_widget_frametable_object_append(of, ow, 1, 0, 1, 1, 1, 1, 0, 0); + + cfdata->o_btn = e_widget_button_add(evas, _("Go up a Directory"), + "widgets/up_dir", _cb_button_up, + cfdata, NULL); + e_widget_frametable_object_append(of, cfdata->o_btn, 0, 1, 2, 1, 1, 1, 0, 0); + + + if (cfdata->fmdir == 1) + snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); + else + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); + + ow = e_fm2_add(evas); + cfdata->o_fm = ow; + memset(&fmc, 0, sizeof(E_Fm2_Config)); + fmc.view.mode = E_FM2_VIEW_MODE_LIST; + fmc.view.open_dirs_in_place = 1; + fmc.view.selector = 1; + fmc.view.single_click = 0; + fmc.view.no_subdir_jump = 0; + fmc.icon.list.w = 48; + fmc.icon.list.h = 48; + fmc.icon.fixed.w = 1; + fmc.icon.fixed.h = 1; + fmc.icon.extension.show = 0; + fmc.icon.key_hint = NULL; + fmc.list.sort.no_case = 1; + fmc.list.sort.dirs.first = 0; + fmc.list.sort.dirs.last = 1; + fmc.selection.single = 1; + fmc.selection.windows_modifiers = 0; + e_fm2_config_set(ow, &fmc); + e_fm2_icon_menu_flags_set(ow, E_FM2_MENU_NO_SHOW_HIDDEN); + e_fm2_path_set(ow, path, "/"); + + evas_object_smart_callback_add(ow, "selection_change", + _cb_fm_sel_change, cfdata); + evas_object_smart_callback_add(ow, "changed", _cb_fm_change, cfdata); + + cfdata->o_sf = e_widget_scrollframe_pan_add(evas, ow, e_fm2_pan_set, + e_fm2_pan_get, + e_fm2_pan_max_get, + e_fm2_pan_child_size_get); + e_widget_min_size_set(cfdata->o_sf, 200, 250); + e_widget_frametable_object_append(of, cfdata->o_sf, 0, 2, 2, 1, 1, 1, 1, 1); + e_widget_table_object_append(ft, of, 1, 0, 1, 3, 1, 1, 1, 1); + + e_dialog_resizable_set(cfd->dia, 1); + + return ft; +} + +static int +_adv_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + Evas_List *sel; + const char *p = NULL; + E_Fm2_Icon_Info *ic; + char path[PATH_MAX]; + + Man->conf->bg_type = cfdata->bg_method; + Man->conf->color_r = cfdata->color->r; + Man->conf->color_g = cfdata->color->g; + Man->conf->color_b = cfdata->color->b; + Man->conf->color_a = 255; + Man->conf->anim_bg = cfdata->anim_bg; + Man->conf->anim_gad = cfdata->anim_gad; + + p = e_fm2_real_path_get(cfdata->o_fm); + sel = e_fm2_selected_list_get(cfdata->o_fm); + if (sel && p) + { + ic = sel->data; + if (ic->file) + { + snprintf(path, sizeof(path), "%s/%s", p, ic->file); + if (Man->conf->custom_bg) + evas_stringshare_del(Man->conf->custom_bg); + Man->conf->custom_bg = evas_stringshare_add(path); + } + evas_list_free(sel); + } + + e_config_save_queue(); + gadman_update_bg(); + + return 1; +} +//Basic Callbacks static void _fill_gadgets_list(Evas_Object *ilist) { @@ -164,3 +343,81 @@ _avail_list_cb_change(void *data, Evas_Object *obj) if (!(cfdata = data)) return; e_widget_disabled_set(cfdata->o_add, 0); } + +//Advanced Callbacks +static void +_cb_color_changed(void *data, Evas_Object *o) +{ + E_Config_Dialog_Data *cfdata; + cfdata = data; + if (!cfdata) return; + e_color_update_rgb(cfdata->color); +} + +static void +_cb_fm_radio_change(void *data, Evas_Object *obj) +{ + E_Config_Dialog_Data *cfdata; + char path[PATH_MAX]; + + cfdata = data; + if (!cfdata->o_fm) return; + if (cfdata->fmdir == 0) + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); + else + snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); + e_fm2_path_set(cfdata->o_fm, path, "/"); +} + +static void +_cb_fm_change(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + const char *p; + char path[PATH_MAX]; + + cfdata = data; + if (!Man->conf->custom_bg) return; + if (!cfdata->o_fm) return; + + p = e_fm2_real_path_get(cfdata->o_fm); + if (!p) return; + + if (strncmp(p, Man->conf->custom_bg, strlen(p))) return; + + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); + if (!strncmp(Man->conf->custom_bg, path, strlen(path))) + p = Man->conf->custom_bg + strlen(path) + 1; + else + { + snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); + if (!strncmp(Man->conf->custom_bg, path, strlen(path))) + p = Man->conf->custom_bg + strlen(path) + 1; + else + p = Man->conf->custom_bg; + } + + e_fm2_select_set(cfdata->o_fm, p, 1); + e_fm2_file_show(cfdata->o_fm, p); +} + +static void +_cb_fm_sel_change(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data; + e_widget_change(cfdata->o_sf); +} +static void +_cb_button_up(void *data1, void *data2) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data1; + if (!cfdata->o_fm) return; + + e_fm2_parent_go(cfdata->o_fm); + e_widget_scrollframe_child_pos_set(cfdata->o_sf, 0, 0); +} + diff --git a/src/modules/gadman/e_mod_config.h b/src/modules/gadman/e_mod_config.h index af15b4952..18bf24489 100644 --- a/src/modules/gadman/e_mod_config.h +++ b/src/modules/gadman/e_mod_config.h @@ -3,7 +3,7 @@ #ifndef E_MOD_CONFIG_H #define E_MOD_CONFIG_H -EAPI E_Config_Dialog *e_int_config_gadman_module(E_Container *con, const char *params __UNUSED__); +EAPI E_Config_Dialog *_config_gadman_module(E_Container *con, const char *params __UNUSED__); #endif #endif diff --git a/src/modules/gadman/e_mod_gadman.c b/src/modules/gadman/e_mod_gadman.c index 40eaaf29e..8f2fc1cf8 100644 --- a/src/modules/gadman/e_mod_gadman.c +++ b/src/modules/gadman/e_mod_gadman.c @@ -1,5 +1,4 @@ #include -//#include #include "config.h" #include "e_mod_main.h" #include "e_mod_gadman.h" @@ -11,7 +10,7 @@ static void _save_widget_position(E_Gadcon_Client *gcc); static void _apply_widget_position(E_Gadcon_Client *gcc); static char *_get_bind_text(const char* action); -static void _hide_finished(void *data, Evas_Object *o, const char *em, const char *src); +//static void _hide_finished(void *data, Evas_Object *o, const char *em, const char *src); static Evas_Object* _create_mover(E_Gadcon *gc); static Evas_Object* _get_mover(E_Gadcon_Client *gcc); @@ -163,7 +162,7 @@ gadman_gadget_place(E_Config_Gadcon_Client *cf, int ontop) edje_object_signal_emit(gcc->o_frame, "e,state,visibility,inset", "e"); else edje_object_signal_emit(gcc->o_frame, "e,state,visibility,plain", "e"); - + gcc->o_box = gcc->o_frame; /* swallow the client inside the frame */ @@ -277,16 +276,37 @@ gadman_gadgets_show(void) Man->visible = 1; ecore_evas_show(Man->top_ee); - - edje_object_signal_emit(Man->full_bg, "e,state,visibility,show", "e"); + if (Man->conf->bg_type == BG_STD) + { + if (Man->conf->anim_bg) + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,show", "e"); + else + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,show,now", "e"); + } + else + { + if (Man->conf->anim_bg) + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,show,custom", "e"); + else + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,show,custom,now", "e"); + } for (l = Man->gadgets; l; l = l->next) { - E_Gadcon_Client *gcc; + E_Gadcon_Client *gcc; - if (!(gcc = l->data)) continue; - if (gcc->gadcon == Man->gc_top) - edje_object_signal_emit(gcc->o_frame, "e,state,visibility,show", "e"); + if (!(gcc = l->data)) continue; + if (gcc->gadcon != Man->gc_top) continue; + if (Man->conf->anim_gad) + edje_object_signal_emit(gcc->o_frame, + "e,state,visibility,show", "e"); + else + edje_object_signal_emit(gcc->o_frame, + "e,state,visibility,show,now", "e"); } } @@ -297,15 +317,33 @@ gadman_gadgets_hide(void) Man->visible = 0; - edje_object_signal_emit(Man->full_bg, "e,state,visibility,hide", "e"); + if (Man->conf->anim_bg) + { + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,hide", "e"); + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,hide,custom", "e"); + } + else + { + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,hide,now", "e"); + edje_object_signal_emit(Man->full_bg, + "e,state,visibility,hide,custom,now", "e"); + } for (l = Man->gadgets; l; l = l->next) { E_Gadcon_Client *gcc; - if (!(gcc = l->data)) continue; - if (gcc->gadcon == Man->gc_top) - edje_object_signal_emit(gcc->o_frame, "e,state,visibility,hide", "e"); + if (!(gcc = l->data)) continue; + if (gcc->gadcon != Man->gc_top) continue; + if (Man->conf->anim_gad) + edje_object_signal_emit(gcc->o_frame, + "e,state,visibility,hide", "e"); + else + edje_object_signal_emit(gcc->o_frame, + "e,state,visibility,hide,now", "e"); } } @@ -318,6 +356,54 @@ gadman_gadgets_toggle(void) gadman_gadgets_show(); } +void +gadman_update_bg(void) +{ + Evas_Object *obj; + const char *ext; + + obj = edje_object_part_swallow_get(Man->full_bg, "e.swallow.bg"); + if (obj) + { + edje_object_part_unswallow(Man->full_bg, obj); + evas_object_del(obj); + } + + switch (Man->conf->bg_type) + { + case BG_STD: + case BG_TRANS: + break; + case BG_COLOR: + obj = evas_object_rectangle_add(Man->gc_top->evas); + evas_object_color_set(obj, Man->conf->color_r, Man->conf->color_g, + Man->conf->color_b, 200); + edje_object_part_swallow(Man->full_bg, "e.swallow.bg", obj); + break; + case BG_CUSTOM: + ext = strrchr(Man->conf->custom_bg, '.'); + if (!strcmp(ext, ".edj") || !strcmp(ext, ".EDJ")) + { + //THIS IS FOR E17 backgrounds + obj = edje_object_add(Man->gc_top->evas); + edje_object_file_set(obj, Man->conf->custom_bg, + "e/desktop/background"); + } + else + { + //THIS IS FOR A NORMAL IMAGE + obj = evas_object_image_add(Man->gc_top->evas); + evas_object_image_file_set(obj, Man->conf->custom_bg, NULL); + evas_object_image_fill_set(obj, 0, 0, Man->container->w, + Man->container->h); + } + edje_object_part_swallow(Man->full_bg, "e.swallow.bg", obj); + break; + default: + break; + } +} + /* Internals */ static E_Gadcon* _gadman_gadcon_new(const char* name, int ontop) @@ -336,18 +422,16 @@ _gadman_gadcon_new(const char* name, int ontop) /* Create ecore fullscreen window */ if (ontop) { - Man->top_ee = - e_canvas_new(e_config->evas_engine_popups, Man->container->win, - 0, 0, 0, 0, 1, 1, &(Man->top_win), NULL); + Man->top_ee = e_canvas_new(e_config->evas_engine_popups, + Man->container->win, 0, 0, 0, 0, 1, 1, + &(Man->top_win), NULL); if (Man->use_composite) { ecore_evas_alpha_set(Man->top_ee, 1); Man->top_win = ecore_evas_software_x11_window_get(Man->top_ee); - // Leave 1px to switch desktop when mouse is on border - ecore_x_window_shape_rectangle_set(Man->top_win, 1, 1, - (Man->width - 2), - (Man->height - 2)); + ecore_x_window_shape_rectangle_set(Man->top_win, 0, 0, + Man->width, Man->height); } else ecore_evas_shaped_set(Man->top_ee, 1); @@ -363,12 +447,10 @@ _gadman_gadcon_new(const char* name, int ontop) /* create full background object */ Man->full_bg = edje_object_add(gc->evas); - e_theme_edje_object_set(Man->full_bg, "base/theme/gadman", + e_theme_edje_object_set(Man->full_bg, "base/theme/gadman", "e/gadman/full_bg"); - edje_object_signal_callback_add(Man->full_bg, "mouse,down,*", "bg", - on_bg_click, NULL); - edje_object_signal_callback_add(Man->full_bg, "program,stop", "hide", - _hide_finished, NULL); + edje_object_signal_callback_add(Man->full_bg, "mouse,down,*", + "grabber", on_bg_click, NULL); evas_object_move(Man->full_bg, 0, 0); evas_object_resize(Man->full_bg, Man->width, Man->height); evas_object_show(Man->full_bg); @@ -646,11 +728,12 @@ _get_bind_text(const char* action) return "(You must define a binding)"; } -static void -_hide_finished(void *data, Evas_Object *o, const char *em, const char *src) -{ - ecore_evas_hide(Man->top_ee); -} +//~ static void +//~ _hide_finished(void *data, Evas_Object *o, const char *em, const char *src) +//~ { + //~ printf("MACOOMEEEE\n"); + //~ ecore_evas_hide(Man->top_ee); +//~ } /* Callbacks */ static void @@ -709,7 +792,6 @@ on_menu_style_inset(void *data, E_Menu *m, E_Menu_Item *mi) E_Gadcon_Client *gcc; gcc = current; -// printf("Inset (%s)\n", gcc->name); if (gcc->style) evas_stringshare_del(gcc->style); gcc->style = evas_stringshare_add(E_GADCON_CLIENT_STYLE_INSET); @@ -798,8 +880,6 @@ on_frame_click(void *data, Evas *e, Evas_Object *obj, void *event_info) int cx, cy, cw, ch; mn = e_menu_new(); - //e_menu_post_deactivate_callback_set(mn, _e_gadcon_client_cb_menu_post, - // gcc); gcc->menu = mn; e_gadcon_client_util_menu_items_append(gcc, mn, 0); e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &cx, &cy, &cw, &ch); @@ -815,7 +895,7 @@ on_top(void *data, Evas_Object *o, const char *em, const char *src) { static int ox, oy, ow, oh; //Object coord int mx, my; //Mouse coord - int action = (int)data; + int action = (int)(long)data; Evas_Object *mover; mover = _get_mover(current); @@ -859,7 +939,7 @@ on_right(void *data, Evas_Object *o, const char *em, const char *src) mover = _get_mover(current); - action = (int)data; + action = (int)(long)data; if (action == DRAG_START) { evas_pointer_output_xy_get(current->gadcon->evas, &mx, &my); @@ -894,7 +974,7 @@ on_down(void *data, Evas_Object *o, const char *em, const char *src) int mx, my; //Mouse coord int action; - action = (int)data; + action = (int)(long)data; mover = _get_mover(current); if (action == DRAG_START) @@ -930,7 +1010,7 @@ on_left(void *data, Evas_Object *o, const char *em, const char *src) int mx, my; //Mouse coord int action; - action = (int)data; + action = (int)(long)data; mover = _get_mover(current); if (action == DRAG_START) @@ -972,7 +1052,7 @@ on_move(void *data, Evas_Object *o, const char *em, const char *src) int mx, my; //Mouse coord int action; - action = (int)data; + action = (int)(long)data; mover = _get_mover(current); /* DRAG_START */ diff --git a/src/modules/gadman/e_mod_gadman.h b/src/modules/gadman/e_mod_gadman.h index cbc1f21cd..770dd15ec 100644 --- a/src/modules/gadman/e_mod_gadman.h +++ b/src/modules/gadman/e_mod_gadman.h @@ -10,7 +10,25 @@ #define DRAG_STOP 1 #define DRAG_MOVE 2 +#define BG_STD 0 +#define BG_COLOR 1 +#define BG_CUSTOM 2 +#define BG_TRANS 3 + typedef struct _Manager Manager; +typedef struct _Config Config; + +struct _Config +{ + int bg_type; + int color_r; + int color_g; + int color_b; + int color_a; + const char* custom_bg; + int anim_bg; + int anim_gad; +}; struct _Manager { @@ -20,7 +38,7 @@ struct _Manager Evas_Object *mover; Evas_Object *mover_top; Evas_Object *full_bg; - const char *icon_name; + const char *icon_name; int visible; int use_composite; @@ -34,6 +52,9 @@ struct _Manager E_Config_Dialog *config_dialog; E_Int_Menu_Augmentation *maug; E_Action *action; + + E_Config_DD *conf_edd; + Config *conf; }; Manager *Man; @@ -46,5 +67,6 @@ E_Gadcon_Client *gadman_gadget_place(E_Config_Gadcon_Client *cf, int ontop); void gadman_gadget_edit_start(E_Gadcon_Client *gcc); void gadman_gadget_edit_end(void); void gadman_gadgets_toggle(void); +void gadman_update_bg(void); #endif diff --git a/src/modules/gadman/e_mod_main.c b/src/modules/gadman/e_mod_main.c index 49250e023..4ac9d5d99 100644 --- a/src/modules/gadman/e_mod_main.c +++ b/src/modules/gadman/e_mod_main.c @@ -20,17 +20,12 @@ e_modapi_init(E_Module *m) { char buf[4096]; - /* Set up module's message catalogue */ - //snprintf(buf, sizeof(buf), "%s/locale", e_module_dir_get(m)); - //bindtextdomain(PACKAGE, buf); - //bind_textdomain_codeset(PACKAGE, "UTF-8"); - /* Set up a new configuration panel */ snprintf(buf, sizeof(buf), "%s/e-module-gadman.edj", m->dir); e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "enlightenment/extensions"); e_configure_registry_item_add("extensions/gadman", 150, _("Gadgets"), NULL, - buf, e_int_config_gadman_module); + buf, _config_gadman_module); /* Set this module to be loaded after all other modules, or we don't see modules loaded after this */ @@ -38,6 +33,42 @@ e_modapi_init(E_Module *m) gadman_init(m); + //Configuration values + Man->conf_edd = E_CONFIG_DD_NEW("Gadman_Config", Config); +#undef T +#undef D +#define T Config +#define D Man->conf_edd + E_CONFIG_VAL(D, T, bg_type, INT); + E_CONFIG_VAL(D, T, color_r, INT); + E_CONFIG_VAL(D, T, color_g, INT); + E_CONFIG_VAL(D, T, color_b, INT); + E_CONFIG_VAL(D, T, color_a, INT); + E_CONFIG_VAL(D, T, anim_bg, INT); + E_CONFIG_VAL(D, T, anim_gad, INT); + E_CONFIG_VAL(D, T, custom_bg, STR); + + Man->conf = e_config_domain_load("module.gadman", Man->conf_edd); + if (!Man->conf) + { + Man->conf = E_NEW(Config, 1); + Man->conf->bg_type = 0; + Man->conf->color_r = 255; + Man->conf->color_g = 255; + Man->conf->color_b = 255; + Man->conf->color_a = 255; + Man->conf->anim_bg = 1; + Man->conf->anim_gad = 1; + Man->conf->custom_bg = NULL; + } + E_CONFIG_LIMIT(Man->conf->bg_type, 0, 5); + E_CONFIG_LIMIT(Man->conf->color_r, 0, 255); + E_CONFIG_LIMIT(Man->conf->color_g, 0, 255); + E_CONFIG_LIMIT(Man->conf->color_b, 0, 255); + E_CONFIG_LIMIT(Man->conf->color_a, 0, 255); + E_CONFIG_LIMIT(Man->conf->anim_bg, 0, 1); + E_CONFIG_LIMIT(Man->conf->anim_gad, 0, 1); + /* Menu augmentation */ Man->icon_name = evas_stringshare_add(buf); Man->maug = NULL; @@ -64,6 +95,8 @@ e_modapi_init(E_Module *m) e_config_save_queue(); } + gadman_update_bg(); + return Man; } @@ -96,6 +129,7 @@ e_modapi_shutdown(E_Module *m) EAPI int e_modapi_save(E_Module *m) { + e_config_domain_save("module.gadman", Man->conf_edd, Man->conf); return 1; }