From 5546f4109d01cd2c79643e6d9801df3824b9b0eb Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 9 Jul 2012 11:50:08 +0000 Subject: [PATCH] formatting SVN revision: 73502 --- src/bin/e_bg.c | 354 +++++++++++++++++++++++++------------------------ 1 file changed, 181 insertions(+), 173 deletions(-) diff --git a/src/bin/e_bg.c b/src/bin/e_bg.c index f6f4e81b6..f6509b66d 100644 --- a/src/bin/e_bg.c +++ b/src/bin/e_bg.c @@ -14,13 +14,14 @@ static E_Fm2_Mime_Handler *bg_hdl = NULL; struct _E_Bg_Image_Import_Handle { - struct { - void (*func)(void *data, const char *edje_file); + struct + { + void (*func)(void *data, const char *edje_file); void *data; } cb; - E_Dialog *dia; + E_Dialog *dia; E_Util_Image_Import_Handle *importer; - Eina_Bool canceled:1; + Eina_Bool canceled : 1; }; /* externally accessible functions */ @@ -32,14 +33,14 @@ e_bg_init(void) /* Register mime handler */ bg_hdl = e_fm2_mime_handler_new(_("Set As Background"), - "preferences-desktop-wallpaper", - e_bg_handler_set, NULL, - e_bg_handler_test, NULL); + "preferences-desktop-wallpaper", + e_bg_handler_set, NULL, + e_bg_handler_test, NULL); if (bg_hdl) { - e_fm2_mime_handler_glob_add(bg_hdl, "*.edj"); - e_fm2_mime_handler_mime_add(bg_hdl, "image/png"); - e_fm2_mime_handler_mime_add(bg_hdl, "image/jpeg"); + e_fm2_mime_handler_glob_add(bg_hdl, "*.edj"); + e_fm2_mime_handler_mime_add(bg_hdl, "image/png"); + e_fm2_mime_handler_mime_add(bg_hdl, "image/jpeg"); } /* Register files in use */ @@ -48,8 +49,8 @@ e_bg_init(void) EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) { - if (!cfbg) continue; - e_filereg_register(cfbg->file); + if (!cfbg) continue; + e_filereg_register(cfbg->file); } E_EVENT_BG_UPDATE = ecore_event_type_new(); @@ -65,8 +66,8 @@ e_bg_shutdown(void) /* Deregister mime handler */ if (bg_hdl) { - e_fm2_mime_handler_glob_del(bg_hdl, "*.edj"); - e_fm2_mime_handler_free(bg_hdl); + e_fm2_mime_handler_glob_del(bg_hdl, "*.edj"); + e_fm2_mime_handler_free(bg_hdl); } /* Deregister files in use */ @@ -75,8 +76,8 @@ e_bg_shutdown(void) EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) { - if (!cfbg) continue; - e_filereg_deregister(cfbg->file); + if (!cfbg) continue; + e_filereg_deregister(cfbg->file); } return 1; @@ -99,33 +100,37 @@ e_bg_config_get(int container_num, int zone_num, int desk_x, int desk_y) /* look for desk specific background. */ if (container_num >= 0 || zone_num >= 0 || desk_x >= 0 || desk_y >= 0) { - EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) - { - int spec; + EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) + { + int spec; - if (!cfbg) continue; - spec = 0; - if (cfbg->container == container_num) spec++; - else if (cfbg->container >= 0) continue; - if (cfbg->zone == zone_num) spec++; - else if (cfbg->zone >= 0) continue; - if (cfbg->desk_x == desk_x) spec++; - else if (cfbg->desk_x >= 0) continue; - if (cfbg->desk_y == desk_y) spec++; - else if (cfbg->desk_y >= 0) continue; + if (!cfbg) continue; + spec = 0; + if (cfbg->container == container_num) spec++; + else if (cfbg->container >= 0) + continue; + if (cfbg->zone == zone_num) spec++; + else if (cfbg->zone >= 0) + continue; + if (cfbg->desk_x == desk_x) spec++; + else if (cfbg->desk_x >= 0) + continue; + if (cfbg->desk_y == desk_y) spec++; + else if (cfbg->desk_y >= 0) + continue; - if (spec <= current_spec) continue; - bgfile = cfbg->file; - if (bgfile) - { - if (bgfile[0] != '/') - { - const char *bf; + if (spec <= current_spec) continue; + bgfile = cfbg->file; + if (bgfile) + { + if (bgfile[0] != '/') + { + const char *bf; - bf = e_path_find(path_backgrounds, bgfile); - if (bf) bgfile = bf; - } - } + bf = e_path_find(path_backgrounds, bgfile); + if (bf) bgfile = bf; + } + } if (eina_str_has_extension(bgfile, ".edj")) { entries = edje_file_collection_list(bgfile); @@ -147,7 +152,7 @@ e_bg_config_get(int container_num, int zone_num, int desk_x, int desk_y) bg = cfbg; current_spec = spec; } - } + } } return bg; } @@ -166,31 +171,31 @@ e_bg_file_get(int container_num, int zone_num, int desk_x, int desk_y) /* fall back to default */ if (cfbg) { - bgfile = cfbg->file; - if (bgfile) - { - if (bgfile[0] != '/') - { - const char *bf; + bgfile = cfbg->file; + if (bgfile) + { + if (bgfile[0] != '/') + { + const char *bf; - bf = e_path_find(path_backgrounds, bgfile); - if (bf) bgfile = bf; - } - } + bf = e_path_find(path_backgrounds, bgfile); + if (bf) bgfile = bf; + } + } } else { - bgfile = e_config->desktop_default_background; - if (bgfile) - { - if (bgfile[0] != '/') - { - const char *bf; + bgfile = e_config->desktop_default_background; + if (bgfile) + { + if (bgfile[0] != '/') + { + const char *bf; - bf = e_path_find(path_backgrounds, bgfile); - if (bf) bgfile = bf; - } - } + bf = e_path_find(path_backgrounds, bgfile); + if (bf) bgfile = bf; + } + } if (bgfile && eina_str_has_extension(bgfile, ".edj")) { entries = edje_file_collection_list(bgfile); @@ -207,10 +212,11 @@ e_bg_file_get(int container_num, int zone_num, int desk_x, int desk_y) edje_file_collection_list_free(entries); } } - else if ((bgfile) && (bgfile[0])) ok = 1; - if (!ok) - bgfile = e_theme_edje_file_get("base/theme/background", - "e/desktop/background"); + else if ((bgfile) && (bgfile[0])) + ok = 1; + if (!ok) + bgfile = e_theme_edje_file_get("base/theme/background", + "e/desktop/background"); } return bgfile; @@ -225,8 +231,10 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition) E_Desk *desk; if (transition == E_BG_TRANSITION_START) trans = e_config->transition_start; - else if (transition == E_BG_TRANSITION_DESK) trans = e_config->transition_desk; - else if (transition == E_BG_TRANSITION_CHANGE) trans = e_config->transition_change; + else if (transition == E_BG_TRANSITION_DESK) + trans = e_config->transition_desk; + else if (transition == E_BG_TRANSITION_CHANGE) + trans = e_config->transition_change; if ((!trans) || (!trans[0])) transition = E_BG_TRANSITION_NONE; desk = e_desk_current_get(zone); @@ -237,46 +245,46 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition) if (zone->bg_object) { - const char *pfile = ""; + const char *pfile = ""; - edje_object_file_get(zone->bg_object, &pfile, NULL); - if (!e_util_strcmp(pfile, bgfile)) return; + edje_object_file_get(zone->bg_object, &pfile, NULL); + if (!e_util_strcmp(pfile, bgfile)) return; } if (transition == E_BG_TRANSITION_NONE) { - if (zone->bg_object) - { - evas_object_del(zone->bg_object); - zone->bg_object = NULL; - } + if (zone->bg_object) + { + evas_object_del(zone->bg_object); + zone->bg_object = NULL; + } } else { - char buf[4096]; + char buf[4096]; - if (zone->bg_object) - { - if (zone->prev_bg_object) - evas_object_del(zone->prev_bg_object); - zone->prev_bg_object = zone->bg_object; - if (zone->transition_object) - evas_object_del(zone->transition_object); - zone->transition_object = NULL; - zone->bg_object = NULL; - } - o = edje_object_add(zone->container->bg_evas); - zone->transition_object = o; - /* FIXME: segv if zone is deleted while up??? */ - evas_object_data_set(o, "e_zone", zone); - snprintf(buf, sizeof(buf), "e/transitions/%s", trans); - e_theme_edje_object_set(o, "base/theme/transitions", buf); - edje_object_signal_callback_add(o, "e,state,done", "*", _e_bg_signal, zone); - evas_object_move(o, zone->x, zone->y); - evas_object_resize(o, zone->w, zone->h); - evas_object_layer_set(o, -1); - evas_object_clip_set(o, zone->bg_clip_object); - evas_object_show(o); + if (zone->bg_object) + { + if (zone->prev_bg_object) + evas_object_del(zone->prev_bg_object); + zone->prev_bg_object = zone->bg_object; + if (zone->transition_object) + evas_object_del(zone->transition_object); + zone->transition_object = NULL; + zone->bg_object = NULL; + } + o = edje_object_add(zone->container->bg_evas); + zone->transition_object = o; + /* FIXME: segv if zone is deleted while up??? */ + evas_object_data_set(o, "e_zone", zone); + snprintf(buf, sizeof(buf), "e/transitions/%s", trans); + e_theme_edje_object_set(o, "base/theme/transitions", buf); + edje_object_signal_callback_add(o, "e,state,done", "*", _e_bg_signal, zone); + evas_object_move(o, zone->x, zone->y); + evas_object_resize(o, zone->w, zone->h); + evas_object_layer_set(o, -1); + evas_object_clip_set(o, zone->bg_clip_object); + evas_object_show(o); } if (eina_str_has_extension(bgfile, ".edj")) { @@ -294,24 +302,24 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition) zone->bg_object = o; if (transition == E_BG_TRANSITION_NONE) { - evas_object_move(o, zone->x, zone->y); - evas_object_resize(o, zone->w, zone->h); - evas_object_layer_set(o, -1); + evas_object_move(o, zone->x, zone->y); + evas_object_resize(o, zone->w, zone->h); + evas_object_layer_set(o, -1); } evas_object_clip_set(o, zone->bg_clip_object); evas_object_show(o); if (transition != E_BG_TRANSITION_NONE) { - edje_extern_object_max_size_set(zone->prev_bg_object, 65536, 65536); - edje_extern_object_min_size_set(zone->prev_bg_object, 0, 0); - edje_object_part_swallow(zone->transition_object, "e.swallow.bg.old", - zone->prev_bg_object); - edje_extern_object_max_size_set(zone->bg_object, 65536, 65536); - edje_extern_object_min_size_set(zone->bg_object, 0, 0); - edje_object_part_swallow(zone->transition_object, "e.swallow.bg.new", - zone->bg_object); - edje_object_signal_emit(zone->transition_object, "e,action,start", "e"); + edje_extern_object_max_size_set(zone->prev_bg_object, 65536, 65536); + edje_extern_object_min_size_set(zone->prev_bg_object, 0, 0); + edje_object_part_swallow(zone->transition_object, "e.swallow.bg.old", + zone->prev_bg_object); + edje_extern_object_max_size_set(zone->bg_object, 65536, 65536); + edje_extern_object_min_size_set(zone->bg_object, 0, 0); + edje_object_part_swallow(zone->transition_object, "e.swallow.bg.new", + zone->bg_object); + edje_object_signal_emit(zone->transition_object, "e,action,start", "e"); } } @@ -326,20 +334,20 @@ e_bg_default_set(const char *file) if (!changed) { - eina_stringshare_del(file); - return; + eina_stringshare_del(file); + return; } if (e_config->desktop_default_background) { - e_filereg_deregister(e_config->desktop_default_background); - eina_stringshare_del(e_config->desktop_default_background); + e_filereg_deregister(e_config->desktop_default_background); + eina_stringshare_del(e_config->desktop_default_background); } if (file) { - e_filereg_register(file); - e_config->desktop_default_background = file; + e_filereg_register(file); + e_config->desktop_default_background = file; } else e_config->desktop_default_background = NULL; @@ -363,16 +371,16 @@ e_bg_add(int container, int zone, int desk_x, int desk_y, const char *file) EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) { - if ((cfbg) && - (cfbg->container == container) && - (cfbg->zone == zone) && - (cfbg->desk_x == desk_x) && - (cfbg->desk_y == desk_y) && - (cfbg->file == file)) - { - eina_stringshare_del(file); - return; - } + if ((cfbg) && + (cfbg->container == container) && + (cfbg->zone == zone) && + (cfbg->desk_x == desk_x) && + (cfbg->desk_y == desk_y) && + (cfbg->file == file)) + { + eina_stringshare_del(file); + return; + } } e_bg_del(container, zone, desk_x, desk_y); @@ -403,16 +411,16 @@ e_bg_del(int container, int zone, int desk_x, int desk_y) EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) { - if (!cfbg) continue; - if ((cfbg->container == container) && (cfbg->zone == zone) && - (cfbg->desk_x == desk_x) && (cfbg->desk_y == desk_y)) - { - e_config->desktop_backgrounds = eina_list_remove_list(e_config->desktop_backgrounds, l); - e_filereg_deregister(cfbg->file); - if (cfbg->file) eina_stringshare_del(cfbg->file); - free(cfbg); - break; - } + if (!cfbg) continue; + if ((cfbg->container == container) && (cfbg->zone == zone) && + (cfbg->desk_x == desk_x) && (cfbg->desk_y == desk_y)) + { + e_config->desktop_backgrounds = eina_list_remove_list(e_config->desktop_backgrounds, l); + e_filereg_deregister(cfbg->file); + if (cfbg->file) eina_stringshare_del(cfbg->file); + free(cfbg); + break; + } } ev = E_NEW(E_Event_Bg_Update, 1); @@ -433,13 +441,13 @@ e_bg_update(void) EINA_LIST_FOREACH(e_manager_list(), l, man) { - EINA_LIST_FOREACH(man->containers, ll, con) - { - EINA_LIST_FOREACH(con->zones, lll, zone) - { - e_zone_bg_reconfigure(zone); - } - } + EINA_LIST_FOREACH(man->containers, ll, con) + { + EINA_LIST_FOREACH(con->zones, lll, zone) + { + e_zone_bg_reconfigure(zone); + } + } } } @@ -501,11 +509,11 @@ e_bg_image_import(const char *image_file, void (*cb)(void *data, const char *edj handle->cb.data = (void *)data; handle->dia = e_util_image_import_settings_new - (image_file, _e_bg_image_import_dialog_done, handle); + (image_file, _e_bg_image_import_dialog_done, handle); if (!handle->dia) { - free(handle); - return NULL; + free(handle); + return NULL; } e_dialog_show(handle->dia); @@ -527,18 +535,18 @@ e_bg_image_import_cancel(E_Bg_Image_Import_Handle *handle) if (handle->cb.func) { - handle->cb.func(handle->cb.data, NULL); - handle->cb.func = NULL; + handle->cb.func(handle->cb.data, NULL); + handle->cb.func = NULL; } if (handle->dia) { - e_object_del(E_OBJECT(handle->dia)); - handle->dia = NULL; + e_object_del(E_OBJECT(handle->dia)); + handle->dia = NULL; } else if (handle->importer) { - e_util_image_import_cancel(handle->importer); - handle->importer = NULL; + e_util_image_import_cancel(handle->importer); + handle->importer = NULL; } E_FREE(handle); } @@ -556,19 +564,19 @@ e_bg_handler_set(Evas_Object *obj __UNUSED__, const char *path, void *data __UNU char buf[PATH_MAX]; int copy = 1; - E_Container *con = e_container_current_get(e_manager_current_get()); - E_Zone *zone = e_zone_current_get(con); - E_Desk *desk = e_desk_current_get(zone); + E_Container *con = e_container_current_get(e_manager_current_get()); + E_Zone *zone = e_zone_current_get(con); + E_Desk *desk = e_desk_current_get(zone); /* if not in system dir or user dir, copy to user dir */ e_prefix_data_concat_static(buf, "data/backgrounds"); if (!strncmp(buf, path, strlen(buf))) - copy = 0; + copy = 0; if (copy) { e_user_dir_concat_static(buf, "backgrounds"); if (!strncmp(buf, path, strlen(buf))) - copy = 0; + copy = 0; } if (copy) { @@ -587,10 +595,10 @@ e_bg_handler_set(Evas_Object *obj __UNUSED__, const char *path, void *data __UNU e_bg_add(con->num, zone->num, desk->x, desk->y, buf); } else - e_bg_add(con->num, zone->num, desk->x, desk->y, path); + e_bg_add(con->num, zone->num, desk->x, desk->y, path); } else - e_bg_add(con->num, zone->num, desk->x, desk->y, path); + e_bg_add(con->num, zone->num, desk->x, desk->y, path); e_bg_update(); e_config_save_queue(); @@ -615,13 +623,12 @@ e_bg_handler_set(Evas_Object *obj __UNUSED__, const char *path, void *data __UNU EAPI int e_bg_handler_test(Evas_Object *obj __UNUSED__, const char *path, void *data __UNUSED__) { - if (!path) return 0; if (_e_bg_file_edje_check(path)) { - if (edje_file_group_exists(path, "e/desktop/background")) return 1; - return 0; + if (edje_file_group_exists(path, "e/desktop/background")) return 1; + return 0; } /* it's image/png or image/jpeg, we'll import it. */ @@ -636,13 +643,13 @@ _e_bg_signal(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNU if (zone->prev_bg_object) { - evas_object_del(zone->prev_bg_object); - zone->prev_bg_object = NULL; + evas_object_del(zone->prev_bg_object); + zone->prev_bg_object = NULL; } if (zone->transition_object) { - evas_object_del(zone->transition_object); - zone->transition_object = NULL; + evas_object_del(zone->transition_object); + zone->transition_object = NULL; } evas_object_move(zone->bg_object, zone->x, zone->y); evas_object_resize(zone->bg_object, zone->w, zone->h); @@ -684,17 +691,17 @@ _e_bg_image_import_dialog_done(void *data, const char *path, Eina_Bool ok, Eina_ snprintf(buf + off, sizeof(buf) - off, "-%u.edj", num); handle->importer = e_util_image_import - (path, buf, "e/desktop/background", external, quality, mode, - _e_bg_image_import_done, handle); + (path, buf, "e/desktop/background", external, quality, mode, + _e_bg_image_import_done, handle); if (!handle->importer) goto aborted; return; - aborted: +aborted: if (handle->cb.func) { - handle->cb.func(handle->cb.data, NULL); - handle->cb.func = NULL; + handle->cb.func(handle->cb.data, NULL); + handle->cb.func = NULL; } if (!handle->canceled) E_FREE(handle); } @@ -708,8 +715,8 @@ _e_bg_image_import_done(void *data, Eina_Bool ok, const char *image_path __UNUSE if (handle->cb.func) { - handle->cb.func(handle->cb.data, edje_path); - handle->cb.func = NULL; + handle->cb.func(handle->cb.data, edje_path); + handle->cb.func = NULL; } if (!handle->canceled) E_FREE(handle); @@ -728,3 +735,4 @@ _e_bg_handler_image_imported(void *data __UNUSED__, const char *image_path) e_bg_update(); e_config_save_queue(); } +