Enlightenment CVS committal
Author : rephorm
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_bg.c e_bg.h e_config_dialog.h e_int_config_wallpaper.c
e_int_config_wallpaper.h e_widget_desk_preview.c
Log Message:
Allow setting bg of desktops from within virtual desktop dialog.
For now, left click on the small desktop.
We'll probably add a menu on click, with the ability to set the desktop name or
set bg.
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_bg.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- e_bg.c 17 Oct 2006 12:29:00 -0000 1.23
+++ e_bg.c 20 Oct 2006 03:23:46 -0000 1.24
@@ -5,10 +5,13 @@
/* local subsystem functions */
static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission,
const char *source);
+static void _e_bg_event_bg_update_free(void *data, void *event);
/* local subsystem globals */
static int _e_bg_reg_files = 0;
+EAPI int E_EVENT_BG_UPDATE = 0;
+
/* externally accessible functions */
EAPI int
e_bg_init(void)
@@ -26,6 +29,7 @@
e_filereg_register(cfbg->file);
}
+ E_EVENT_BG_UPDATE = ecore_event_type_new();
return 1;
}
@@ -48,16 +52,18 @@
return 1;
}
-EAPI const char *
-e_bg_file_get(int container_num, int zone_num, int desk_x, int desk_y)
+/**
+ * Find the configuration for a given desktop background
+ * Use -1 as a wild card for each parameter.
+ * The most specific match will be returned
+ */
+EAPI const E_Config_Desktop_Background *
+e_bg_config_get(int container_num, int zone_num, int desk_x, int desk_y)
{
Evas_List *l, *ll, *entries;
- int ok;
- int current_spec;
- const char *bgfile = "";
- ok = 0;
- current_spec = 0; /* how specific the setting is - we want the least
general one that applies */
+ E_Config_Desktop_Background *bg = NULL;
+ int current_spec = 0; /* how specific the setting is - we want the least
general one that applies */
/* look for desk specific background. */
if (container_num >= 0 || zone_num >= 0 || desk_x >= 0 || desk_y >= 0)
@@ -88,24 +94,38 @@
{
if (!strcmp(ll->data, "e/desktop/background"))
{
- bgfile = cfbg->file;
+ bg = cfbg;
current_spec = spec;
- ok = 1;
}
}
edje_file_collection_list_free(entries);
}
}
}
+ return bg;
+}
+
+EAPI const char *
+e_bg_file_get(int container_num, int zone_num, int desk_x, int desk_y)
+{
+ const E_Config_Desktop_Background *cfbg;
+ Evas_List *l, *entries;
+ const char *bgfile = "";
+ int ok = 0;
+
+ cfbg = e_bg_config_get(container_num, zone_num, desk_x, desk_y);
+
/* fall back to default */
- if (!ok)
+ if (cfbg)
+ bgfile = cfbg->file;
+ else
{
entries =
edje_file_collection_list(e_config->desktop_default_background);
if (entries)
{
- for (ll = entries; ll; ll = ll->next)
+ for (l = entries; l; l = l->next)
{
- if (!strcmp(ll->data, "e/desktop/background"))
+ if (!strcmp(l->data, "e/desktop/background"))
{
bgfile = e_config->desktop_default_background;
ok = 1;
@@ -119,6 +139,7 @@
bgfile = e_theme_edje_file_get("base/theme/background",
"e/desktop/background");
}
}
+
return bgfile;
}
@@ -207,25 +228,35 @@
EAPI void
e_bg_default_set(char * file)
{
- if (e_config->desktop_default_background)
- {
- e_filereg_deregister(e_config->desktop_default_background);
- evas_stringshare_del(e_config->desktop_default_background);
- }
-
- if (file)
- {
- e_filereg_register(file);
- e_config->desktop_default_background = evas_stringshare_add(file);
- }
- else
- e_config->desktop_default_background = NULL;
+ E_Event_Bg_Update *ev;
+
+ if (e_config->desktop_default_background)
+ {
+ e_filereg_deregister(e_config->desktop_default_background);
+ evas_stringshare_del(e_config->desktop_default_background);
+ }
+
+ if (file)
+ {
+ e_filereg_register(file);
+ e_config->desktop_default_background = evas_stringshare_add(file);
+ }
+ else
+ e_config->desktop_default_background = NULL;
+
+ ev = E_NEW(E_Event_Bg_Update, 1);
+ ev->container = -1;
+ ev->zone = -1;
+ ev->desk_x = -1;
+ ev->desk_y = -1;
+ ecore_event_add(E_EVENT_BG_UPDATE, ev, _e_bg_event_bg_update_free, NULL);
}
EAPI void
e_bg_add(int container, int zone, int desk_x, int desk_y, char *file)
{
E_Config_Desktop_Background *cfbg;
+ E_Event_Bg_Update *ev;
e_bg_del(container, zone, desk_x, desk_y);
cfbg = E_NEW(E_Config_Desktop_Background, 1);
@@ -235,13 +266,22 @@
cfbg->desk_y = desk_y;
cfbg->file = evas_stringshare_add(file);
e_config->desktop_backgrounds =
evas_list_append(e_config->desktop_backgrounds, cfbg);
+
e_filereg_register(cfbg->file);
+
+ ev = E_NEW(E_Event_Bg_Update, 1);
+ ev->container = container;
+ ev->zone = zone;
+ ev->desk_x = desk_x;
+ ev->desk_y = desk_y;
+ ecore_event_add(E_EVENT_BG_UPDATE, ev, _e_bg_event_bg_update_free, NULL);
}
EAPI void
e_bg_del(int container, int zone, int desk_x, int desk_y)
{
Evas_List *l;
+ E_Event_Bg_Update *ev;
for (l = e_config->desktop_backgrounds; l; l = l->next)
{
@@ -258,6 +298,13 @@
break;
}
}
+
+ ev = E_NEW(E_Event_Bg_Update, 1);
+ ev->container = container;
+ ev->zone = zone;
+ ev->desk_x = desk_x;
+ ev->desk_y = desk_y;
+ ecore_event_add(E_EVENT_BG_UPDATE, ev, _e_bg_event_bg_update_free, NULL);
}
EAPI void
@@ -309,3 +356,8 @@
evas_object_show(zone->bg_object);
}
+static void
+_e_bg_event_bg_update_free(void *data, void *event)
+{
+ free(event);
+}
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_bg.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- e_bg.h 17 Oct 2006 12:29:00 -0000 1.8
+++ e_bg.h 20 Oct 2006 03:23:46 -0000 1.9
@@ -10,19 +10,30 @@
E_BG_TRANSITION_CHANGE
} E_Bg_Transition;
+typedef struct _E_Event_Bg_Update E_Event_Bg_Update;
#else
#ifndef E_BG_H
#define E_BG_H
+extern EAPI int E_EVENT_BG_UPDATE;
+
+struct _E_Event_Bg_Update
+{
+ int container;
+ int zone;
+ int desk_x;
+ int desk_y;
+};
+
EAPI int e_bg_init(void);
EAPI int e_bg_shutdown(void);
+EAPI const E_Config_Desktop_Background *e_bg_config_get(int container_num, int
zone_num, int desk_x, int desk_y);
EAPI const char *e_bg_file_get(int container_num, int zone_num, int desk_x,
int desk_y);
EAPI void e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition);
EAPI void e_bg_add(int container, int zone, int desk_x, int desk_y, char
*file);
EAPI void e_bg_del(int container, int zone, int desk_x, int desk_y);
EAPI void e_bg_default_set(char *file);
EAPI void e_bg_update(void);
-
#endif
#endif
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_config_dialog.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- e_config_dialog.h 8 Oct 2006 08:04:17 -0000 1.14
+++ e_config_dialog.h 20 Oct 2006 03:23:46 -0000 1.15
@@ -22,6 +22,7 @@
struct _E_Config_Dialog_View
{
int override_auto_apply;
+ int basic_only;
void *(*create_cfdata) (E_Config_Dialog *cfd);
void (*free_cfdata) (E_Config_Dialog *cfd,
E_Config_Dialog_Data *cfdata);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_int_config_wallpaper.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- e_int_config_wallpaper.c 17 Oct 2006 12:29:00 -0000 1.20
+++ e_int_config_wallpaper.c 20 Oct 2006 03:23:46 -0000 1.21
@@ -12,6 +12,17 @@
static int _advanced_apply_data (E_Config_Dialog *cfd,
E_Config_Dialog_Data *cfdata);
static Evas_Object *_advanced_create_widgets (E_Config_Dialog *cfd, Evas
*evas, E_Config_Dialog_Data *cfdata);
+#define E_CONFIG_WALLPAPER_ALL 0
+#define E_CONFIG_WALLPAPER_DESK 1
+#define E_CONFIG_WALLPAPER_SCREEN 2
+
+struct _E_Config_Wallpaper
+{
+ int specific_config;
+ int con_num, zone_num;
+ int desk_x, desk_y;
+};
+
struct _E_Config_Dialog_Data
{
E_Config_Dialog *cfd;
@@ -23,9 +34,10 @@
Evas_Object *o_personal;
Evas_Object *o_system;
int fmdir;
-
+
int use_theme_bg;
char *bg;
+
/* advanced */
int all_this_desk_screen;
/* dialogs */
@@ -36,23 +48,48 @@
EAPI E_Config_Dialog *
e_int_config_wallpaper(E_Container *con)
{
+ E_Zone *zone;
+ return e_int_config_wallpaper_desk(-1, -1, -1, -1);
+}
+
+EAPI E_Config_Dialog *
+e_int_config_wallpaper_desk(int con_num, int zone_num, int desk_x, int desk_y)
+{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
+ E_Config_Wallpaper *cw;
+ E_Container *con;
if (e_config_dialog_find("E", "_config_wallpaper_dialog")) return NULL;
v = E_NEW(E_Config_Dialog_View, 1);
-
+ cw = E_NEW(E_Config_Wallpaper, 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->advanced.apply_cfdata = _advanced_apply_data;
- v->advanced.create_widgets = _advanced_create_widgets;
+
+ if (!(con_num == -1 && zone_num == -1 && desk_x == -1 && desk_y == -1))
+ cw->specific_config = 1;
+ else
+ {
+ v->advanced.apply_cfdata = _advanced_apply_data;
+ v->advanced.create_widgets = _advanced_create_widgets;
+ }
+
v->override_auto_apply = 1;
+
+ cw->con_num = con_num;
+ cw->zone_num = zone_num;
+ cw->desk_x = desk_x;
+ cw->desk_y = desk_y;
+
+ con = e_container_current_get(e_manager_current_get());
+
cfd = e_config_dialog_new(con,
_("Wallpaper Settings"),
"E", "_config_wallpaper_dialog",
- "enlightenment/background", 0, v, NULL);
+ "enlightenment/background", 0, v, cw);
return cfd;
}
@@ -318,45 +355,52 @@
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
- E_Zone *z;
- E_Desk *d;
Evas_List *l;
char path[4096];
-
- if (e_config->desktop_default_background)
- cfdata->bg = strdup(e_config->desktop_default_background);
-
- z = e_zone_current_get(cfdata->cfd->con);
- if (!z) return;
- d = e_desk_current_get(z);
- if (!d) return;
- for (l = e_config->desktop_backgrounds; l; l = l->next)
+ E_Config_Wallpaper *cw;
+ const E_Config_Desktop_Background *cfbg;
+
+ cw = cfdata->cfd->data;
+
+ if (cw->specific_config)
+ {
+ const char *bg;
+ /* specific config passed in. set for that only */
+ bg = e_bg_file_get(cw->con_num, cw->zone_num, cw->desk_x, cw->desk_y);
+ if (bg) cfdata->bg = strdup(bg);
+ }
+ else
{
- E_Config_Desktop_Background *cfbg;
-
- cfbg = l->data;
- if (((cfbg->container == z->container->num) ||
- (cfbg->container < 0)) &&
- ((cfbg->zone == z->num) ||
- (cfbg->zone < 0)) &&
- ((cfbg->desk_x == d->x) ||
- (cfbg->desk_x < 0)) &&
- ((cfbg->desk_y == d->y) ||
- (cfbg->desk_y < 0)))
+ /* get current desk. advanced mode allows selecting all, screen or desk
*/
+ E_Container *c;
+ E_Zone *z;
+ E_Desk *d;
+
+ c = e_container_current_get(e_manager_current_get());
+ z = e_zone_current_get(c);
+ d = e_desk_current_get(z);
+
+ cfbg = e_bg_config_get(c->num, z->num, d->x, d->y);
+ /* if we have a config for this bg, use it. */
+ if (cfbg)
{
+ if (cfbg->container >= 0 && cfbg->zone >= 0)
+ {
+ if (cfbg->desk_x >= 0 && cfbg->desk_y >= 0)
+ cfdata->all_this_desk_screen = E_CONFIG_WALLPAPER_DESK;
+ else
+ cfdata->all_this_desk_screen = E_CONFIG_WALLPAPER_SCREEN;
+ }
E_FREE(cfdata->bg);
cfdata->bg = strdup(cfbg->file);
- if ((cfbg->container >= 0) ||
- (cfbg->zone >= 0))
- cfdata->all_this_desk_screen = 2;
- if ((cfbg->desk_x >= 0) ||
- (cfbg->desk_y >= 0))
- cfdata->all_this_desk_screen = 1;
- break;
}
}
- if (!cfdata->bg) cfdata->use_theme_bg = 1;
+ if (!cfdata->bg && e_config->desktop_default_background)
+ cfdata->bg = strdup(e_config->desktop_default_background);
+ else
+ cfdata->use_theme_bg = 1;
+
if (cfdata->bg)
{
snprintf(path, sizeof(path), "%s/data/backgrounds",
e_prefix_data_get());
@@ -383,6 +427,7 @@
if (cfdata->win_import) e_int_config_wallpaper_del(cfdata->win_import);
if (cfdata->dia_gradient)
e_int_config_wallpaper_gradient_del(cfdata->dia_gradient);
E_FREE(cfdata->bg);
+ E_FREE(cfd->data);
free(cfdata);
}
@@ -509,19 +554,33 @@
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- while (e_config->desktop_backgrounds)
+ E_Config_Wallpaper *cw;
+
+ cw = cfd->data;
+ if (cw->specific_config)
{
- E_Config_Desktop_Background *cfbg;
- cfbg = e_config->desktop_backgrounds->data;
- e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
+ /* update a specific config */
+ e_bg_del(cw->con_num, cw->zone_num, cw->desk_x, cw->desk_y);
+ e_bg_add(cw->con_num, cw->zone_num, cw->desk_x, cw->desk_y, cfdata->bg);
}
- if ((cfdata->use_theme_bg) || (!cfdata->bg))
- e_bg_default_set(NULL);
else
- e_bg_default_set(cfdata->bg);
-
- cfdata->all_this_desk_screen = 0;
+ {
+ /* set the default and nuke individual configs */
+ while (e_config->desktop_backgrounds)
+ {
+ E_Config_Desktop_Background *cfbg;
+ cfbg = e_config->desktop_backgrounds->data;
+ e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
+ }
+ if ((cfdata->use_theme_bg) || (!cfdata->bg))
+ e_bg_default_set(NULL);
+ else
+ e_bg_default_set(cfdata->bg);
+
+ cfdata->all_this_desk_screen = 0;
+ }
+
e_bg_update();
e_config_save_queue();
return 1;
@@ -642,11 +701,11 @@
e_widget_framelist_content_align_set(ol, 0.0, 0.0);
rg = e_widget_radio_group_new(&(cfdata->all_this_desk_screen));
- o = e_widget_radio_add(evas, _("All Desktops"), 0, rg);
+ o = e_widget_radio_add(evas, _("All Desktops"), E_CONFIG_WALLPAPER_ALL, rg);
e_widget_framelist_object_append(ol, o);
- o = e_widget_radio_add(evas, _("This Desktop"), 1, rg);
+ o = e_widget_radio_add(evas, _("This Desktop"), E_CONFIG_WALLPAPER_DESK,
rg);
e_widget_framelist_object_append(ol, o);
- o = e_widget_radio_add(evas, _("This Screen"), 2, rg);
+ o = e_widget_radio_add(evas, _("This Screen"), E_CONFIG_WALLPAPER_SCREEN,
rg);
if (!((e_util_container_zone_number_get(0, 1)) ||
(e_util_container_zone_number_get(1, 0))))
e_widget_disabled_set(o, 1);
@@ -683,7 +742,7 @@
}
else
{
- if (cfdata->all_this_desk_screen == 0)
+ if (cfdata->all_this_desk_screen == E_CONFIG_WALLPAPER_ALL)
{
while (e_config->desktop_backgrounds)
{
@@ -693,7 +752,7 @@
}
e_bg_default_set(cfdata->bg);
}
- else if (cfdata->all_this_desk_screen == 1)
+ else if (cfdata->all_this_desk_screen == E_CONFIG_WALLPAPER_DESK)
{
e_bg_del(z->container->num, z->num, d->x, d->y);
e_bg_del(z->container->num, -1, d->x, d->y);
@@ -702,7 +761,7 @@
e_bg_add(z->container->num, z->num, d->x, d->y, cfdata->bg);
}
- else if (cfdata->all_this_desk_screen == 2)
+ else if (cfdata->all_this_desk_screen == E_CONFIG_WALLPAPER_SCREEN)
{
for (l = e_config->desktop_backgrounds; l; l = l->next)
{
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_int_config_wallpaper.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- e_int_config_wallpaper.h 21 Aug 2006 15:52:58 -0000 1.2
+++ e_int_config_wallpaper.h 20 Oct 2006 03:23:46 -0000 1.3
@@ -2,11 +2,13 @@
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
+typedef struct _E_Config_Wallpaper E_Config_Wallpaper;
#else
#ifndef E_INT_CONFIG_WALLPAPER_H
#define E_INT_CONFIG_WALLPAPER_H
EAPI E_Config_Dialog *e_int_config_wallpaper(E_Container *con);
+EAPI E_Config_Dialog *e_int_config_wallpaper_desk(int con_num, int zone_num,
int desk_x, int desk_y);
EAPI void e_int_config_wallpaper_update(E_Config_Dialog *dia, char
*file);
EAPI void e_int_config_wallpaper_import_done(E_Config_Dialog *dia);
EAPI void e_int_config_wallpaper_gradient_done(E_Config_Dialog
*dia);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_widget_desk_preview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- e_widget_desk_preview.c 18 Oct 2006 03:31:45 -0000 1.4
+++ e_widget_desk_preview.c 20 Oct 2006 03:23:46 -0000 1.5
@@ -15,6 +15,8 @@
Evas_Object *table;
Evas_List *desks;
+ Ecore_Event_Handler *update_handler;
+
int w, h;
int cur_x, cur_y; /* currently drawn */
int desk_count_x, desk_count_y;
@@ -24,19 +26,32 @@
struct _E_Widget_Desk_Data
{
Evas_Object *thumb;
+ int container, zone;
int x, y;
};
static void _e_wid_reconfigure(E_Widget_Data *wd);
+static void _e_wid_desk_cb_menu(void *data, Evas_Object *obj, const char
*signal, const char *source);
+static void _e_wid_cb_bg_update(void *data, int type, void *event);
static void
_e_wid_del_hook(Evas_Object *obj)
{
E_Widget_Data *wd;
+ Evas_List *l;
wd = e_widget_data_get(obj);
if (!wd) return;
+ if (wd->update_handler) ecore_event_handler_del(wd->update_handler);
+ for (l = wd->desks; l; l = l->next)
+ {
+ Evas_Object *o;
+ E_Widget_Desk_Data *dd;
+ o = l->data;
+ dd = e_widget_data_get(o);
+ e_thumb_icon_end(o);
+ }
evas_list_free(wd->desks);
free(wd);
}
@@ -81,6 +96,8 @@
dd = calloc(1, sizeof(E_Widget_Desk_Data));
e_widget_data_set(obj, dd);
+ dd->container = zone->container->num;
+ dd->zone = zone->num;
dd->x = x;
dd->y = y;
@@ -92,6 +109,7 @@
evas_object_show(o);
e_widget_sub_object_add(obj, o);
overlay = o;
+ edje_object_signal_callback_add(o, "mouse,down,1", "e.event.menu",
_e_wid_desk_cb_menu, dd);
o = e_thumb_icon_add(evas);
e_icon_fill_inside_set(o, 0);
@@ -103,6 +121,7 @@
e_widget_sub_object_add(obj, o);
dd->thumb = o;
+
return obj;
}
@@ -230,7 +249,51 @@
e_widget_desk_preview_num_desks_set(obj, nx, ny);
+ wd->update_handler = ecore_event_handler_add(E_EVENT_BG_UPDATE,
_e_wid_cb_bg_update, wd);
+
return obj;
}
+static void
+_e_wid_desk_cb_menu(void *data, Evas_Object *obj, const char *signal, const
char *source)
+{
+ E_Widget_Desk_Data *dd;
+
+ dd = data;
+ /* XXX change this to display a menu with the option to set the desktop
name or change the desktop bg */
+ e_int_config_wallpaper_desk(dd->container, dd->zone, dd->x, dd->y);
+}
+
+static void
+_e_wid_cb_bg_update(void *data, int type, void *event)
+{
+ E_Event_Bg_Update *ev;
+ E_Widget_Data *wd;
+ Evas_List *l;
+
+ if (type != E_EVENT_BG_UPDATE) return;
+
+ wd = data;
+ ev = event;
+ for(l = wd->desks; l; l = l->next)
+ {
+ Evas_Object *o;
+ E_Widget_Desk_Data *dd;
+ o = l->data;
+ dd = e_widget_data_get(o);
+
+ if (!dd)
+ continue;
+
+ if (((ev->container < 0) || (dd->container == ev->container)) &&
+ ((ev->zone < 0) || (dd->zone == ev->zone)) &&
+ ((ev->desk_x < 0) || (dd->x == ev->desk_x)) &&
+ ((ev->desk_y < 0) || (dd->y == ev->desk_y)))
+ {
+ const char *bgfile = e_bg_file_get(dd->container, dd->zone, dd->x,
dd->y);
+ e_thumb_icon_file_set(dd->thumb, bgfile, "e/desktop/background");
+ e_thumb_icon_rethumb(dd->thumb);
+ }
+ }
+}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs