From fce2c3b1fc4d9306c4ed3b431cbf976591270ec9 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 16 Feb 2006 06:32:54 +0000 Subject: [PATCH] working on shelf config SVN revision: 20515 --- src/bin/e_config.c | 55 ++++++++++++++ src/bin/e_config.h | 24 ++++++- src/bin/e_main.c | 29 +------- src/bin/e_shelf.c | 174 +++++++++++++++++++++++++++++++++++++++++---- src/bin/e_shelf.h | 6 +- 5 files changed, 247 insertions(+), 41 deletions(-) diff --git a/src/bin/e_config.c b/src/bin/e_config.c index 66740c2ce..df1e5cde0 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -37,6 +37,8 @@ static E_Config_DD *_e_config_remember_edd = NULL; static E_Config_DD *_e_config_color_class_edd = NULL; static E_Config_DD *_e_config_gadcon_edd = NULL; static E_Config_DD *_e_config_gadcon_client_edd = NULL; +static E_Config_DD *_e_config_shelf_edd = NULL; +static E_Config_DD *_e_config_shelf_config_edd = NULL; /* externally accessible functions */ @@ -98,6 +100,32 @@ e_config_init(void) E_CONFIG_VAL(D, T, id, STR); E_CONFIG_LIST(D, T, clients, _e_config_gadcon_client_edd); + _e_config_shelf_config_edd = E_CONFIG_DD_NEW("E_Config_Shelf_Config", E_Config_Shelf_Config); +#undef T +#undef D +#define T E_Config_Shelf_Config +#define D _e_config_shelf_config_edd + E_CONFIG_VAL(D, T, res.w, INT); + E_CONFIG_VAL(D, T, res.h, INT); + E_CONFIG_VAL(D, T, x, INT); + E_CONFIG_VAL(D, T, y, INT); + E_CONFIG_VAL(D, T, w, INT); + E_CONFIG_VAL(D, T, h, INT); + E_CONFIG_VAL(D, T, orient, INT); + E_CONFIG_VAL(D, T, style, STR); + + _e_config_shelf_edd = E_CONFIG_DD_NEW("E_Config_Shelf", E_Config_Shelf); +#undef T +#undef D +#define T E_Config_Shelf +#define D _e_config_shelf_edd + E_CONFIG_VAL(D, T, name, STR); + E_CONFIG_VAL(D, T, container, INT); + E_CONFIG_VAL(D, T, zone, INT); + E_CONFIG_VAL(D, T, layer, INT); + E_CONFIG_VAL(D, T, popup, UCHAR); + E_CONFIG_LIST(D, T, configs, _e_config_shelf_config_edd); + _e_config_desktop_bg_edd = E_CONFIG_DD_NEW("E_Config_Desktop_Background", E_Config_Desktop_Background); #undef T #undef D @@ -428,6 +456,7 @@ e_config_init(void) E_CONFIG_VAL(D, T, cfgdlg_auto_apply, INT); /**/ E_CONFIG_VAL(D, T, cfgdlg_default_mode, INT); /**/ E_CONFIG_LIST(D, T, gadcons, _e_config_gadcon_edd); + E_CONFIG_LIST(D, T, shelves, _e_config_shelf_edd); e_config = e_config_domain_load("e", _e_config_edd); if (e_config) @@ -581,6 +610,30 @@ e_config_init(void) e_config->gadcons = NULL; /* FIXME: fill up default gadcons! */ + { + E_Config_Shelf *cf_es; + E_Config_Shelf_Config *cf_escf; + + cf_es = E_NEW(E_Config_Shelf, 1); + cf_es->name = evas_stringshare_add("shelf"); + cf_es->container = 0; + cf_es->zone = 0; + cf_es->popup = 1; + cf_es->layer = 200; + e_config->shelves = evas_list_append(e_config->shelves, cf_es); + + cf_escf = E_NEW(E_Config_Shelf_Config, 1); + cf_escf->res.w = 800; + cf_escf->res.h = 600; + cf_escf->x = 0; + cf_escf->y = 0; + cf_escf->w = 800; + cf_escf->h = 32; + cf_escf->orient = E_GADCON_ORIENT_TOP; + cf_escf->style = evas_stringshare_add("default"); + cf_es->configs = evas_list_append(cf_es->configs, cf_escf); + } + { E_Config_Gadcon *cf_gc; E_Config_Gadcon_Client *cf_gcc; @@ -1628,6 +1681,8 @@ e_config_shutdown(void) E_CONFIG_DD_FREE(_e_config_remember_edd); E_CONFIG_DD_FREE(_e_config_gadcon_edd); E_CONFIG_DD_FREE(_e_config_gadcon_client_edd); + E_CONFIG_DD_FREE(_e_config_shelf_edd); + E_CONFIG_DD_FREE(_e_config_shelf_config_edd); return 1; } diff --git a/src/bin/e_config.h b/src/bin/e_config.h index 682a8843c..e6836f979 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -35,6 +35,8 @@ typedef struct _E_Config_Desktop_Background E_Config_Desktop_Background; typedef struct _E_Config_Desktop_Name E_Config_Desktop_Name; typedef struct _E_Config_Gadcon E_Config_Gadcon; typedef struct _E_Config_Gadcon_Client E_Config_Gadcon_Client; +typedef struct _E_Config_Shelf E_Config_Shelf; +typedef struct _E_Config_Shelf_Config E_Config_Shelf_Config; typedef Eet_Data_Descriptor E_Config_DD; @@ -47,7 +49,7 @@ typedef Eet_Data_Descriptor E_Config_DD; * versioning feature. the value of this is really irrelevant - just as * long as it increases every time we change something */ -#define E_CONFIG_FILE_VERSION 137 +#define E_CONFIG_FILE_VERSION 138 #define E_EVAS_ENGINE_DEFAULT 0 #define E_EVAS_ENGINE_SOFTWARE_X11 1 @@ -207,6 +209,7 @@ struct _E_Config int cfgdlg_auto_apply; // GUI int cfgdlg_default_mode; // GUI Evas_List *gadcons; + Evas_List *shelves; }; struct _E_Config_Module @@ -295,6 +298,25 @@ struct _E_Config_Gadcon_Client } geom; }; +struct _E_Config_Shelf +{ + char *name; + int container, zone; + int layer; + unsigned char popup; + Evas_List *configs; +}; + +struct _E_Config_Shelf_Config +{ + struct { + int w, h; + } res; + int x, y, w, h; + int orient; + char *style; +}; + EAPI int e_config_init(void); EAPI int e_config_shutdown(void); diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 33ef42d6a..44a3feb06 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -663,33 +663,8 @@ main(int argc, char **argv) e_test(); /* FIXME: for testing only */ - if (0) - { - Evas_List *l, *l2, *l3, *managers; - - for (l = e_manager_list(); l; l = l->next) - { - E_Manager *man; - - man = l->data; - for (l2 = man->containers; l2; l2 = l2->next) - { - E_Container *con; - - con = l2->data; - for (l3 = con->zones; l3; l3 = l3->next) - { - E_Zone *zone; - E_Shelf *es; - - zone = l3->data; - es = e_shelf_zone_new(zone, "shelf", 0, 200); - e_shelf_populate(es); - } - } - } - } - +// e_shelf_config_init(); + /* no longer starting up */ starting = 0; /* start our main loop */ diff --git a/src/bin/e_shelf.c b/src/bin/e_shelf.c index 206ce8db2..e7bbda36c 100644 --- a/src/bin/e_shelf.c +++ b/src/bin/e_shelf.c @@ -4,6 +4,7 @@ #include "e.h" static void _e_shelf_free(E_Shelf *es); +static void _e_shelf_config_port(E_Config_Shelf_Config *cf1, E_Config_Shelf_Config *cf2); static Evas_List *shelves = NULL; static int shelf_id = 0; @@ -21,8 +22,82 @@ e_shelf_shutdown(void) return 1; } +EAPI void +e_shelf_config_init(void) +{ + Evas_List *l, *l2; + + for (l = e_config->shelves; l; l = l->next) + { + E_Config_Shelf *cf_es; + E_Config_Shelf_Config *cf_escf, *cf_escf2; + E_Zone *zone; + int closeness; + + cf_es = l->data; + zone = e_util_container_zone_number_get(cf_es->container, cf_es->zone); + if (zone) + { + cf_escf2 = NULL; + closeness = 0x7fffffff; + for (l2 = cf_es->configs; l2; l2 = l2->next) + { + cf_escf = l2->data; + if ((cf_escf->res.w == zone->w) && + (cf_escf->res.h == zone->h)) + { + cf_escf2 = cf_escf; + closeness = 0; + break; + } + else + { + int difx, dify; + + difx = cf_escf->res.w - zone->w; + if (difx < 0) difx = -difx; + dify = cf_escf->res.h - zone->h; + if (dify < 0) dify = -dify; + difx = difx * dify; + if (difx < closeness) + { + closeness = difx; + cf_escf2 = cf_escf; + } + } + } + if ((closeness != 0) && (cf_escf2)) + { + cf_escf = E_NEW(E_Config_Shelf_Config, 1); + cf_escf->res.w = zone->w; + cf_escf->res.h = zone->h; + cf_escf->orient = cf_escf2->orient; + cf_escf->style = evas_stringshare_add(cf_escf2->style); + _e_shelf_config_port(cf_escf2, cf_escf); + cf_escf2 = cf_escf; + e_config_save_queue(); + } + if (cf_escf2) + { + E_Shelf *es; + + es = e_shelf_zone_new(zone, cf_es->name, cf_escf2->style, + cf_es->popup, cf_es->layer); + if (es) + { + e_shelf_move_resize(es, cf_escf2->x, cf_escf2->y, + cf_escf2->w, cf_escf2->h); + e_shelf_orient(es, cf_escf2->orient); + e_shelf_populate(es); + e_shelf_show(es); + } + } + } + } +} + EAPI E_Shelf * -e_shelf_zone_new(E_Zone *zone, char *name, int popup, int layer) +e_shelf_zone_new(E_Zone *zone, char *name, char *style, int popup, int layer) { E_Shelf *es; char buf[1024]; @@ -30,11 +105,9 @@ e_shelf_zone_new(E_Zone *zone, char *name, int popup, int layer) es = E_OBJECT_ALLOC(E_Shelf, E_SHELF_TYPE, _e_shelf_free); if (!es) return NULL; - /* FIXME: geometry, layer and style shoudl be loaded from config for this - named shelf */ es->x = 0; es->y = 0; - es->w = zone->w; + es->w = 32; es->h = 32; if (popup) { @@ -50,25 +123,24 @@ e_shelf_zone_new(E_Zone *zone, char *name, int popup, int layer) } es->layer = layer; es->zone = zone; - es->style = strdup("default"); + es->style = evas_stringshare_add(style); es->o_base = edje_object_add(es->evas); - es->name = strdup(name); + es->name = evas_stringshare_add(name); snprintf(buf, sizeof(buf), "shelf/%s/base", es->style); evas_object_resize(es->o_base, es->w, es->h); if (!e_theme_edje_object_set(es->o_base, "base/theme/shelf", buf)) e_theme_edje_object_set(es->o_base, "base/theme/shelf", "shelf/default/base"); if (es->popup) { + evas_object_show(es->o_base); e_popup_edje_bg_object_set(es->popup, es->o_base); - e_popup_show(es->popup); } else { evas_object_move(es->o_base, es->zone->x + es->x, es->zone->y + es->y); evas_object_layer_set(es->o_base, layer); } - evas_object_show(es->o_base); snprintf(buf, sizeof(buf), "%i", shelf_id); shelf_id++; @@ -89,6 +161,28 @@ e_shelf_populate(E_Shelf *es) e_gadcon_populate(es->gadcon); } +EAPI void +e_shelf_show(E_Shelf *es) +{ + E_OBJECT_CHECK(es); + E_OBJECT_TYPE_CHECK(es, E_GADMAN_SHELF_TYPE); + if (es->popup) + e_popup_show(es->popup); + else + evas_object_show(es->o_base); +} + +EAPI void +e_shelf_hide(E_Shelf *es) +{ + E_OBJECT_CHECK(es); + E_OBJECT_TYPE_CHECK(es, E_GADMAN_SHELF_TYPE); + if (es->popup) + e_popup_hide(es->popup); + else + evas_object_hide(es->o_base); +} + EAPI void e_shelf_move(E_Shelf *es, int x, int y) { @@ -110,7 +204,10 @@ e_shelf_resize(E_Shelf *es, int w, int h) es->w = w; es->h = h; if (es->popup) - e_popup_resize(es->popup, es->w, es->h); + { + e_popup_resize(es->popup, es->w, es->h); + evas_object_resize(es->o_base, es->w, es->h); + } else evas_object_resize(es->o_base, es->w, es->h); } @@ -125,7 +222,10 @@ e_shelf_move_resize(E_Shelf *es, int x, int y, int w, int h) es->w = w; es->h = h; if (es->popup) - e_popup_move_resize(es->popup, es->x, es->y, es->w, es->h); + { + e_popup_move_resize(es->popup, es->x, es->y, es->w, es->h); + evas_object_resize(es->o_base, es->w, es->h); + } else { evas_object_move(es->o_base, es->zone->x + es->x, es->zone->y + es->y); @@ -155,6 +255,16 @@ e_shelf_save(E_Shelf *es) */ } +EAPI void +e_shelf_unsave(E_Shelf *es) +{ + E_OBJECT_CHECK(es); + E_OBJECT_TYPE_CHECK(es, E_GADMAN_SHELF_TYPE); + /* FIXME: find or create saved shelf node and then delete and queue a + * save + */ +} + EAPI void e_shelf_orient(E_Shelf *es, E_Gadcon_Orient orient) { @@ -169,9 +279,49 @@ _e_shelf_free(E_Shelf *es) { shelves = evas_list_remove(shelves, es); e_object_del(E_OBJECT(es->gadcon)); - E_FREE(es->name); - E_FREE(es->style); + evas_stringshare_del(es->name); + evas_stringshare_del(es->style); evas_object_del(es->o_base); if (es->popup) e_object_del(E_OBJECT(es->popup)); free(es); } + +static void +_e_shelf_config_port(E_Config_Shelf_Config *cf1, E_Config_Shelf_Config *cf2) +{ + int px[4], py[4]; + int i; + + /* + * We have 4 corners. figure out what gravity zone (3x3 grid) they are in + * then lock them in relative to the edge or middle of that zone and re + * calculate it all then. + */ + px[0] = cf1->x; + px[1] = cf1->x + cf1->w - 1; + px[2] = cf1->x; + px[3] = cf1->x + cf1->w - 1; + py[0] = cf1->y; + py[1] = cf1->y; + py[2] = cf1->y + cf1->h - 1; + py[3] = cf1->y + cf1->h - 1; + for (i = 0; i < 4; i++) + { + if (px[i] < (cf1->res.w / 3)) + px[i] = px[i]; + else if (px[i] > ((2 * cf1->res.w) / 3)) + px[i] = (cf2->res.w) + (px[i] - cf1->res.w); + else + px[i] = (cf2->res.w / 2) + (px[i] - (cf1->res.w / 2)); + if (py[i] < (cf1->res.h / 3)) + py[i] = py[i]; + else if (py[i] > ((2 * cf1->res.h) / 3)) + py[i] = (cf2->res.h) + (py[i] - cf1->res.h); + else + py[i] = (cf2->res.h / 2) + (py[i] - (cf1->res.h / 2)); + } + cf2->x = px[0]; + cf2->y = py[0]; + cf2->w = px[3] - px[0] + 1; + cf2->h = py[3] = py[0] + 1; +} diff --git a/src/bin/e_shelf.h b/src/bin/e_shelf.h index 0d83e7f0b..95aed31d3 100644 --- a/src/bin/e_shelf.h +++ b/src/bin/e_shelf.h @@ -31,13 +31,17 @@ struct _E_Shelf EAPI int e_shelf_init(void); EAPI int e_shelf_shutdown(void); -EAPI E_Shelf *e_shelf_zone_new(E_Zone *zone, char *name, int popup, int layer); +EAPI void e_shelf_config_init(void); +EAPI E_Shelf *e_shelf_zone_new(E_Zone *zone, char *name, char *style, int popup, int layer); EAPI void e_shelf_populate(E_Shelf *es); +EAPI void e_shelf_show(E_Shelf *es); +EAPI void e_shelf_hide(E_Shelf *es); EAPI void e_shelf_move(E_Shelf *es, int x, int y); EAPI void e_shelf_resize(E_Shelf *es, int w, int h); EAPI void e_shelf_move_resize(E_Shelf *es, int x, int y, int w, int h); EAPI void e_shelf_layer_set(E_Shelf *es, int layer); EAPI void e_shelf_save(E_Shelf *es); +EAPI void e_shelf_unsave(E_Shelf *es); EAPI void e_shelf_orient(E_Shelf *es, E_Gadcon_Orient orient); #endif