2006-10-14 02:43:12 -07:00
|
|
|
#include "e.h"
|
|
|
|
|
2007-09-13 14:11:02 -07:00
|
|
|
static E_Config_Dialog_View *_config_view_new(void);
|
2006-10-14 02:43:12 -07:00
|
|
|
|
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
|
|
|
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
|
|
|
static int _basic_apply_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);
|
2008-11-09 10:41:35 -08:00
|
|
|
static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
2006-10-14 02:43:12 -07:00
|
|
|
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _basic_apply_border(E_Config_Dialog_Data *cfdata);
|
|
|
|
|
|
|
|
struct _E_Config_Dialog_Data
|
|
|
|
{
|
|
|
|
E_Border *border;
|
|
|
|
E_Container *container;
|
2009-03-11 08:13:42 -07:00
|
|
|
const char *bordername;
|
2006-10-14 02:43:12 -07:00
|
|
|
int remember_border;
|
|
|
|
};
|
|
|
|
|
2010-01-22 12:28:39 -08:00
|
|
|
E_Config_Dialog *
|
2007-07-24 11:47:26 -07:00
|
|
|
e_int_config_borders(E_Container *con, const char *params __UNUSED__)
|
2006-10-14 02:43:12 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
E_Config_Dialog_View *v;
|
2006-11-29 12:40:27 -08:00
|
|
|
|
2009-12-04 14:37:18 -08:00
|
|
|
if (e_config_dialog_find("E", "appearance/borders")) return NULL;
|
2006-10-14 02:43:12 -07:00
|
|
|
v = _config_view_new();
|
|
|
|
if (!v) return NULL;
|
|
|
|
cfd = e_config_dialog_new(con, _("Default Border Style"),
|
2009-12-04 14:37:18 -08:00
|
|
|
"E", "appearance/borders",
|
2009-03-04 18:39:50 -08:00
|
|
|
"preferences-system-windows", 0, v, con);
|
2006-10-14 02:43:12 -07:00
|
|
|
return cfd;
|
|
|
|
}
|
|
|
|
|
2010-01-22 12:28:39 -08:00
|
|
|
E_Config_Dialog *
|
2008-11-09 10:41:35 -08:00
|
|
|
e_int_config_borders_border(E_Container *con __UNUSED__, const char *params)
|
2006-10-14 02:43:12 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
E_Config_Dialog_View *v;
|
2007-07-04 04:11:03 -07:00
|
|
|
E_Border *bd;
|
2006-11-30 02:34:59 -08:00
|
|
|
|
2007-07-04 04:11:03 -07:00
|
|
|
if (!params) return NULL;
|
|
|
|
bd = NULL;
|
|
|
|
sscanf(params, "%p", &bd);
|
|
|
|
if (!bd) return NULL;
|
2006-10-14 02:43:12 -07:00
|
|
|
v = _config_view_new();
|
|
|
|
if (!v) return NULL;
|
|
|
|
cfd = e_config_dialog_new(bd->zone->container,
|
|
|
|
_("Window Border Selection"),
|
Fix E crash when module is unloaded while dialog is up.
ATTN Devs:
--------------------------
SOMEONE changed all the window class settings for these modules,
so now when a module gets unloaded, the respective config dialogs are
not closed, leading to E crashes.
An Example if someone wants to tackle changing all these cause I don't have
the time right now:
e_modapi_shutdown
--------------------------
while ((cfd = e_config_dialog_find("E", "_config_desk_dialog")))
e_object_del(E_OBJECT(cfd));
You will see a ton of these lines in e/src/modules. Basically, when the
config dialog gets created, we assign a icccm name & class to that dialog:
e_config_dialog_new(con, _("Label"), "E", "_config_desk_dialog");
The class needs to match what is used in e_modapi_shutdown !!!
In just about every existing module in e/src/modules/, the class names are
not set correctly when the dialog gets created. This needs fixing badly !!!
SVN revision: 44156
2009-12-02 20:00:34 -08:00
|
|
|
"E", "_config_border_border_style_dialog",
|
2009-03-04 18:39:50 -08:00
|
|
|
"preferences-system-windows", 0, v, bd);
|
2006-10-14 02:43:12 -07:00
|
|
|
bd->border_border_dialog = cfd;
|
|
|
|
return cfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Config_Dialog_View *
|
2007-09-13 14:11:02 -07:00
|
|
|
_config_view_new(void)
|
2006-10-14 02:43:12 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog_View *v;
|
|
|
|
|
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
|
|
|
if (!v) return NULL;
|
|
|
|
v->create_cfdata = _create_data;
|
|
|
|
v->free_cfdata = _free_data;
|
|
|
|
v->basic.create_widgets = _basic_create_widgets;
|
|
|
|
v->basic.apply_cfdata = _basic_apply_data;
|
2008-11-09 10:41:35 -08:00
|
|
|
v->basic.check_changed = _basic_check_changed;
|
2006-10-14 02:43:12 -07:00
|
|
|
v->override_auto_apply = 1;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
_create_data(E_Config_Dialog *cfd)
|
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
|
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
|
|
|
cfdata->container = NULL;
|
|
|
|
cfdata->border = NULL;
|
|
|
|
if (E_OBJECT(cfd->data)->type == E_CONTAINER_TYPE)
|
|
|
|
cfdata->container = cfd->data;
|
|
|
|
else
|
|
|
|
cfdata->border = cfd->data;
|
|
|
|
|
|
|
|
_fill_data(cfdata);
|
|
|
|
return cfdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
if (cfdata->border)
|
|
|
|
{
|
|
|
|
if ((cfdata->border->remember) &&
|
|
|
|
(cfdata->border->remember->apply & E_REMEMBER_APPLY_BORDER))
|
|
|
|
{
|
|
|
|
cfdata->remember_border = 1;
|
|
|
|
}
|
2009-03-11 08:13:42 -07:00
|
|
|
cfdata->bordername = eina_stringshare_add(cfdata->border->client.border.name);
|
2006-10-14 02:43:12 -07:00
|
|
|
}
|
|
|
|
else
|
2009-03-11 08:13:42 -07:00
|
|
|
cfdata->bordername = eina_stringshare_add(e_config->theme_default_border_style);
|
2006-10-14 02:43:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-09 10:41:35 -08:00
|
|
|
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
2006-10-14 02:43:12 -07:00
|
|
|
{
|
|
|
|
if (cfdata->border)
|
|
|
|
cfdata->border->border_border_dialog = NULL;
|
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->bordername);
|
2007-01-15 09:07:08 -08:00
|
|
|
E_FREE(cfdata);
|
2006-10-14 02:43:12 -07:00
|
|
|
}
|
|
|
|
|
2008-11-09 10:41:35 -08:00
|
|
|
static int
|
|
|
|
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__,
|
|
|
|
E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
if (cfdata->border)
|
|
|
|
return strcmp(cfdata->bordername, cfdata->border->client.border.name);
|
|
|
|
else
|
|
|
|
return strcmp(cfdata->bordername, e_config->theme_default_border_style);
|
|
|
|
}
|
|
|
|
|
2006-10-14 02:43:12 -07:00
|
|
|
static int
|
2008-11-09 10:41:35 -08:00
|
|
|
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__,
|
|
|
|
E_Config_Dialog_Data *cfdata)
|
2006-10-14 02:43:12 -07:00
|
|
|
{
|
|
|
|
if (cfdata->border)
|
|
|
|
_basic_apply_border(cfdata);
|
|
|
|
else if (cfdata->container)
|
|
|
|
{
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(e_config->theme_default_border_style);
|
|
|
|
e_config->theme_default_border_style = eina_stringshare_ref(cfdata->bordername);
|
2006-10-14 02:43:12 -07:00
|
|
|
/* FIXME: Should this trigger an E Restart to reset all borders ? */
|
|
|
|
}
|
|
|
|
e_config_save_queue();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_basic_apply_border(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
2006-10-27 18:32:43 -07:00
|
|
|
if ((!cfdata->border->lock_border) && (!cfdata->border->shaded))
|
|
|
|
{
|
2009-03-11 08:13:42 -07:00
|
|
|
eina_stringshare_del(cfdata->border->bordername);
|
|
|
|
cfdata->border->bordername = eina_stringshare_ref(cfdata->bordername);
|
2006-10-27 18:32:43 -07:00
|
|
|
cfdata->border->client.border.changed = 1;
|
|
|
|
cfdata->border->changed = 1;
|
|
|
|
}
|
2006-10-14 02:43:12 -07:00
|
|
|
if (cfdata->remember_border)
|
|
|
|
{
|
2009-09-12 04:08:07 -07:00
|
|
|
E_Remember *rem = cfdata->border->remember;
|
|
|
|
|
|
|
|
if (!rem)
|
2008-07-09 12:38:35 -07:00
|
|
|
{
|
2009-09-12 04:08:07 -07:00
|
|
|
rem = e_remember_new();
|
|
|
|
if (rem)
|
|
|
|
e_remember_use(rem);
|
2008-07-09 12:38:35 -07:00
|
|
|
}
|
2009-09-12 04:08:07 -07:00
|
|
|
if (rem)
|
2008-07-09 12:38:35 -07:00
|
|
|
{
|
2009-09-12 04:08:07 -07:00
|
|
|
rem->apply |= E_REMEMBER_APPLY_BORDER;
|
|
|
|
e_remember_default_match_set(rem, cfdata->border);
|
|
|
|
if (rem->prop.border) eina_stringshare_del(rem->prop.border);
|
|
|
|
rem->prop.border = eina_stringshare_add(cfdata->border->bordername);
|
|
|
|
cfdata->border->remember = rem;
|
|
|
|
e_remember_update(cfdata->border);
|
2008-07-09 12:38:35 -07:00
|
|
|
}
|
2006-10-14 02:43:12 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cfdata->border->remember)
|
|
|
|
{
|
|
|
|
cfdata->border->remember->apply &= ~E_REMEMBER_APPLY_BORDER;
|
|
|
|
if (cfdata->border->remember->apply == 0)
|
|
|
|
{
|
|
|
|
e_remember_unuse(cfdata->border->remember);
|
|
|
|
e_remember_del(cfdata->border->remember);
|
|
|
|
cfdata->border->remember = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
2006-11-28 03:48:35 -08:00
|
|
|
Evas_Object *o, *ol, *ob, *oj, *orect, *of;
|
2006-10-14 02:43:12 -07:00
|
|
|
Evas_Coord w, h;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *borders, *l;
|
2006-10-14 02:43:12 -07:00
|
|
|
int n, sel = 0;
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
if (cfdata->border)
|
|
|
|
tmp = strdup(cfdata->border->client.border.name);
|
|
|
|
else
|
|
|
|
tmp = strdup(e_config->theme_default_border_style);
|
2006-11-30 02:34:59 -08:00
|
|
|
|
2006-10-14 02:43:12 -07:00
|
|
|
o = e_widget_list_add(evas, 0, 0);
|
2006-11-28 03:48:35 -08:00
|
|
|
of = e_widget_framelist_add(evas, _("Default Border Style"), 0);
|
2007-04-17 01:58:58 -07:00
|
|
|
e_widget_framelist_content_align_set(of, 0.0, 0.0);
|
2009-04-18 09:25:13 -07:00
|
|
|
ol = e_widget_ilist_add(evas, 96, 96, &(cfdata->bordername));
|
2006-10-14 02:43:12 -07:00
|
|
|
borders = e_theme_border_list();
|
|
|
|
orect = evas_object_rectangle_add(evas);
|
|
|
|
evas_object_color_set(orect, 0, 0, 0, 128);
|
2006-11-27 07:42:06 -08:00
|
|
|
|
|
|
|
evas_event_freeze(evas_object_evas_get(ol));
|
|
|
|
edje_freeze();
|
|
|
|
e_widget_ilist_freeze(ol);
|
2006-10-14 02:43:12 -07:00
|
|
|
e_widget_ilist_append(ol, orect, "borderless", NULL, NULL, "borderless");
|
|
|
|
|
|
|
|
for (n = 1, l = borders; l; l = l->next, n++)
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
ob = e_livethumb_add(evas);
|
2009-04-18 09:25:13 -07:00
|
|
|
e_livethumb_vsize_set(ob, 96, 96);
|
2006-10-14 02:43:12 -07:00
|
|
|
oj = edje_object_add(e_livethumb_evas_get(ob));
|
|
|
|
snprintf(buf, sizeof(buf), "e/widgets/border/%s/border", (char *)l->data);
|
|
|
|
e_theme_edje_object_set(oj, "base/theme/borders", buf);
|
|
|
|
e_livethumb_thumb_set(ob, oj);
|
|
|
|
orect = evas_object_rectangle_add(e_livethumb_evas_get(ob));
|
|
|
|
evas_object_color_set(orect, 0, 0, 0, 128);
|
|
|
|
evas_object_show(orect);
|
|
|
|
edje_object_part_swallow(oj, "e.swallow.client", orect);
|
|
|
|
e_widget_ilist_append(ol, ob, (char *)l->data, NULL, NULL, l->data);
|
|
|
|
if (!strcmp(tmp, (char *)l->data))
|
|
|
|
sel = n;
|
|
|
|
}
|
|
|
|
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(ol, &w, &h);
|
|
|
|
e_widget_size_min_set(ol, w > 200 ? w : 200, 200);
|
2006-10-14 02:43:12 -07:00
|
|
|
|
|
|
|
e_widget_ilist_go(ol);
|
|
|
|
e_widget_ilist_selected_set(ol, sel);
|
2006-11-27 07:42:06 -08:00
|
|
|
e_widget_ilist_thaw(ol);
|
|
|
|
edje_thaw();
|
|
|
|
evas_event_thaw(evas_object_evas_get(ol));
|
2006-11-28 03:48:35 -08:00
|
|
|
|
|
|
|
e_widget_framelist_object_append(of, ol);
|
2007-04-17 01:58:58 -07:00
|
|
|
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
2006-11-29 11:14:54 -08:00
|
|
|
|
2006-10-14 02:43:12 -07:00
|
|
|
if (cfdata->border)
|
|
|
|
{
|
|
|
|
ob = e_widget_check_add(evas, _("Remember this Border for this window next time it appears"), &(cfdata->remember_border));
|
2008-01-16 11:14:05 -08:00
|
|
|
e_widget_list_object_append(o, ob, 1, 0, 0.0);
|
2006-10-14 02:43:12 -07:00
|
|
|
}
|
2006-11-28 03:48:35 -08:00
|
|
|
|
2006-10-14 02:43:12 -07:00
|
|
|
E_FREE(tmp);
|
2007-04-17 01:58:58 -07:00
|
|
|
e_dialog_resizable_set(cfd->dia, 1);
|
2006-10-14 02:43:12 -07:00
|
|
|
return o;
|
|
|
|
}
|