Skip to content

Commit

Permalink
Photo: new config options related to edj_gen
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtylee committed Apr 11, 2019
1 parent 66b1a66 commit 127eab7
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 28 deletions.
33 changes: 27 additions & 6 deletions photo/src/photo_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ static E_Config_DD *_photo_edd = NULL;
static E_Config_DD *_photo_dir_edd = NULL;
static E_Config_DD *_photo_item_edd = NULL;


/*
* Public functions
*/
Expand All @@ -13,7 +12,7 @@ int photo_config_init(void)
{
Eina_List *l;
char buf[4096];

_photo_dir_edd = E_CONFIG_DD_NEW("Photo_Local_Dir", Picture_Local_Dir);
#undef T
#undef D
Expand Down Expand Up @@ -47,6 +46,14 @@ int photo_config_init(void)
E_CONFIG_VAL(D, T, pictures_set_bg_purge, SHORT);
E_CONFIG_VAL(D, T, pictures_viewer, STR);
E_CONFIG_VAL(D, T, pictures_thumb_size, SHORT);
E_CONFIG_VAL(D, T, bg_dialog, SHORT);
E_CONFIG_VAL(D, T, bg_method, SHORT);
E_CONFIG_VAL(D, T, bg_external, SHORT);
E_CONFIG_VAL(D, T, bg_quality, SHORT);
E_CONFIG_VAL(D, T, bg_color_r, SHORT);
E_CONFIG_VAL(D, T, bg_color_g, SHORT);
E_CONFIG_VAL(D, T, bg_color_b, SHORT);
E_CONFIG_VAL(D, T, bg_color_a, SHORT);
E_CONFIG_LIST(D, T, local.dirs, _photo_dir_edd);
E_CONFIG_VAL(D, T, local.auto_reload, SHORT);
E_CONFIG_VAL(D, T, local.popup, SHORT);
Expand Down Expand Up @@ -99,7 +106,15 @@ int photo_config_init(void)
c->pictures_set_bg_purge = PICTURE_SET_BG_PURGE_DEFAULT;
c->pictures_viewer = eina_stringshare_add(PICTURE_VIEWER_DEFAULT);
c->pictures_thumb_size = PICTURE_THUMB_SIZE_DEFAULT;
c->local.dirs = eina_list_append(c->local.dirs,
c->bg_dialog = PHOTO_BG_DIALOG_DEFAULT;
c->bg_method = PHOTO_BG_METHOD_DEFAULT;
c->bg_external = PHOTO_BG_EXTERNAL_DEFAULT;
c->bg_quality = PHOTO_BG_QUALITY_DEFAULT;
c->bg_color_r = PHOTO_BG_COLOR_R_DEFAULT;
c->bg_color_g = PHOTO_BG_COLOR_G_DEFAULT;
c->bg_color_b = PHOTO_BG_COLOR_B_DEFAULT;
c->bg_color_a = PHOTO_BG_COLOR_A_DEFAULT;
c->local.dirs = eina_list_append(c->local.dirs,
photo_picture_local_dir_new((char *)e_module_dir_get(photo->module),
1, 0));
c->local.auto_reload = PICTURE_LOCAL_AUTO_RELOAD_DEFAULT;
Expand All @@ -114,6 +129,14 @@ int photo_config_init(void)
E_CONFIG_LIMIT(photo->config->show_label, 0, 1);
E_CONFIG_LIMIT(photo->config->nice_trans, 0, 1);
E_CONFIG_LIMIT(photo->config->pictures_from, 0, 2);
E_CONFIG_LIMIT(photo->config->bg_dialog, 0, 1);
E_CONFIG_LIMIT(photo->config->bg_method, 0, 5);
E_CONFIG_LIMIT(photo->config->bg_external, 0, 1);
E_CONFIG_LIMIT(photo->config->bg_quality, 1, 100);
E_CONFIG_LIMIT(photo->config->bg_color_r, 0, 255);
E_CONFIG_LIMIT(photo->config->bg_color_g, 0, 255);
E_CONFIG_LIMIT(photo->config->bg_color_b, 0, 255);
E_CONFIG_LIMIT(photo->config->bg_color_a, 0, 255);
E_CONFIG_LIMIT(photo->config->local.auto_reload, 0, 1);
E_CONFIG_LIMIT(photo->config->local.popup, 0, 2);
E_CONFIG_LIMIT(photo->config->local.thumb_msg, 0, 1);
Expand Down Expand Up @@ -143,7 +166,6 @@ int photo_config_init(void)
E_CONFIG_LIMIT(pic->action_mouse_left, ITEM_ACTION_NO, ITEM_ACTION_PARENT);
E_CONFIG_LIMIT(pic->action_mouse_middle, ITEM_ACTION_NO, ITEM_ACTION_PARENT);
}

return 1;
}

Expand Down Expand Up @@ -213,9 +235,8 @@ Photo_Config_Item *photo_config_item_new(const char *id)
pic->action_mouse_over = ITEM_ACTION_PARENT;
pic->action_mouse_left = ITEM_ACTION_PARENT;
pic->action_mouse_middle = ITEM_ACTION_PARENT;

photo->config->items = eina_list_append(photo->config->items, pic);

return pic;
}

Expand Down
26 changes: 25 additions & 1 deletion photo/src/photo_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@ typedef struct _Photo_Config_Item Photo_Config_Item;
#ifndef PHOTO_CONFIG_H_INCLUDED
#define PHOTO_CONFIG_H_INCLUDED

#define CONFIG_VERSION 3
#define CONFIG_VERSION 4

#define IMPORT_STRETCH 0
#define IMPORT_TILE 1
#define IMPORT_CENTER 2
#define IMPORT_SCALE_ASPECT_IN 3
#define IMPORT_SCALE_ASPECT_OUT 4
#define IMPORT_PAN 5

#define PHOTO_BG_DIALOG_DEFAULT EINA_FALSE
#define PHOTO_BG_METHOD_DEFAULT IMPORT_CENTER
#define PHOTO_BG_EXTERNAL_DEFAULT EINA_FALSE
#define PHOTO_BG_QUALITY_DEFAULT 100
#define PHOTO_BG_COLOR_R_DEFAULT 0
#define PHOTO_BG_COLOR_G_DEFAULT 0
#define PHOTO_BG_COLOR_B_DEFAULT 0
#define PHOTO_BG_COLOR_A_DEFAULT 255

struct _Photo_Config
{
Expand All @@ -21,6 +37,14 @@ struct _Photo_Config
int pictures_set_bg_purge;
const char *pictures_viewer;
int pictures_thumb_size;
int bg_dialog;
int bg_method;
int bg_external;
int bg_quality;
int bg_color_r;
int bg_color_g;
int bg_color_b;
int bg_color_a;
struct
{
Eina_List *dirs;
Expand Down
86 changes: 67 additions & 19 deletions photo/src/photo_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ else \
}

#define STRINGIFY(str) #str
#define IMPORT_STRETCH 0
#define IMPORT_TILE 1
#define IMPORT_CENTER 2
#define IMPORT_SCALE_ASPECT_IN 3
#define IMPORT_SCALE_ASPECT_OUT 4
#define IMPORT_PAN 5

typedef struct _Import Import;

Expand All @@ -59,13 +53,15 @@ struct _Import
int method;
int external;
int quality;
E_Color color;

Ecore_Exe *exe;
Ecore_Event_Handler *exe_handler;
Ecore_End_Cb ok;
char *tmpf;
char *fdest;
};

const char *name = NULL;

// Local Functions
Expand All @@ -84,6 +80,8 @@ static const char* _edj_gen(Import *import);
static void _cb_import_ok(void *data, void *dia __UNUSED__);
static Eina_Bool _cb_edje_cc_exit(void *data, int type __UNUSED__, void *event);
static void _import_free(Import *import);
static void _apply_import_ok(const char *file, E_Import_Config_Dialog *import);
static Import * _init_import(void);
// Public functions
Photo_Item *photo_item_add(E_Gadcon_Client *gcc, Evas_Object *obj, const char *id)
{
Expand Down Expand Up @@ -390,7 +388,7 @@ int photo_item_action_setbg(Photo_Item *pi)
Ecore_Exe *exe;
const char *file;
char buf[4096];
Import *import = NULL;
Import *import;

zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
if (!zone) return 0;
Expand All @@ -399,15 +397,18 @@ int photo_item_action_setbg(Photo_Item *pi)
if (!p) return 0;

name = p->infos.name;
import = E_NEW(Import, 1);
if (!import)
return 0;
import->method = IMPORT_SCALE_ASPECT_OUT;

if (!(import = _init_import())) return 0;

import->file = p->path;
import->quality = 100;
import->external = 0;
import->ok = _cb_import_ok;

if (photo->config && photo->config->bg_dialog)
{
E_Import_Config_Dialog *import_cfg;
import_cfg = e_import_config_dialog_show(NULL, import->file, (Ecore_End_Cb) _apply_import_ok, NULL);
return 1;
}
import->ok = _cb_import_ok;
if (photo->config->pictures_set_bg_purge)
photo_picture_setbg_purge(0);

Expand All @@ -420,7 +421,7 @@ int photo_item_action_setbg(Photo_Item *pi)
e_module_dialog_show(photo->module, D_("Photo Module Error"), buf);
return 0;
}

// use eina_str_has_extension here
if (!strstr(import->file, ".edj"))
{
DITEM(("Set background with image %s", import->file));
Expand Down Expand Up @@ -724,6 +725,9 @@ _cb_popi_close(void *data)
pi->popi = NULL;
}

/* Code duplicated more or less from _import_edj_gen in
* moksha/src/bin/e_import_config_dialog.c
* */
static const char *
_edj_gen(Import *import)
{
Expand Down Expand Up @@ -756,10 +760,11 @@ _edj_gen(Import *import)
for (num = 1; ecore_file_exists(buf) && num < 100; num++)
snprintf(buf + off, sizeof(buf) - off, "-%d.edj", num);
free(fstrip);
cr = 0;
cg = 0;
cb = 0;
ca = 0;

cr = import->color.r;
cg = import->color.g;
cb = import->color.b;
ca = import->color.a;

if (num == 100)
{
Expand Down Expand Up @@ -1051,3 +1056,46 @@ _import_free(Import *import)
}
E_FREE(import);
}

static void
_apply_import_ok(const char *file, E_Import_Config_Dialog *import)
{
e_bg_default_set(import->fdest);
if (photo->config->pictures_set_bg_purge)
photo_picture_setbg_add(name);
name = NULL;
e_bg_update();
e_config_save_queue();
}

static Import*
_init_import(void)
{
Import *import = E_NEW(Import, 1);
E_Color color;
EINA_SAFETY_ON_NULL_RETURN_VAL(import, NULL);
if (photo->config)
{
import->method = photo->config->bg_method;
import->quality = photo->config->bg_quality;
import->external = photo->config->bg_external;
color.r = photo->config->bg_color_r;
color.b = photo->config->bg_color_g;
color.g = photo->config->bg_color_b;
color.a = photo->config->bg_color_a;
}
else
{
// Should never happen
DITEM(("Error: No photo config"));
import->method = PHOTO_BG_METHOD_DEFAULT;
import->quality = PHOTO_BG_QUALITY_DEFAULT;
import->external = PHOTO_BG_EXTERNAL_DEFAULT;
color.r = PHOTO_BG_COLOR_R_DEFAULT;
color.b = PHOTO_BG_COLOR_B_DEFAULT;
color.g = PHOTO_BG_COLOR_G_DEFAULT;
color.a = PHOTO_BG_COLOR_A_DEFAULT;
}
import->color = color;
return import;
}
3 changes: 1 addition & 2 deletions photo/src/photo_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct _Photo_Item
Photo_Config_Item *config;
E_Config_Dialog *config_dialog;
E_Menu *menu;
E_Menu *menu_histo;
E_Menu *menu_histo;

Ecore_Timer *timer;

Expand All @@ -71,7 +71,6 @@ struct _Photo_Item
Ecore_Event_Handler *net_ev_fill_handler;
};


Photo_Item *photo_item_add(E_Gadcon_Client *gcc, Evas_Object *obj, const char *id);
void photo_item_del(Photo_Item *pi);

Expand Down

0 comments on commit 127eab7

Please sign in to comment.