work on some todo items i left for xkbswitch.

gagdte looks nicer now
flags aspect ratio is correct now based on each flag
name of kbd layout only appears on mouseover
fixed buffer overflow possibility in execution.



SVN revision: 70534
This commit is contained in:
Carsten Haitzler 2012-04-29 03:47:53 +00:00
parent caaf8c6ea0
commit c90e3c1517
98 changed files with 200 additions and 222 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 B

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 B

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -41315,138 +41315,116 @@ collections {
}
}
group
{
name: "modules/xkbswitch/main";
max: 148 128;
parts
{
part
{
name: "flag";
type: SWALLOW;
mouse_events: 0;
description
{
state: "default" 0.0;
align: 0.5 0.5;
}
/////////////////////////////////////////////////////////////////////////////
/*** MOD: XKBSWITCH ***/
group { name: "modules/xkbswitch/main";
images {
image: "xkbshad.png" COMP;
}
max: 128 128;
parts {
part { name: "shadow";
mouse_events: 1;
description { state: "default" 0.0;
rel1.to: "e.swallow.flag";
rel1.offset: -2 -1;
rel2.to: "e.swallow.flag";
rel2.offset: 1 2;
image {
normal: "xkbshad.png";
border: 5 5 5 5;
}
}
}
part { name: "e.swallow.flag";
type: SWALLOW;
mouse_events: 0;
description { state: "default" 0.0;
rel1.offset: 2 3;
rel2.offset: -3 -4;
}
}
part { name: "e.text.label"; type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
description { state: "default" 0.0;
rel1 {
to: "e.swallow.flag";
relative: 0.0 0.5;
}
rel2 {
to: "e.swallow.flag";
relative: 1.0 0.5;
}
color: 255 255 255 0;
color3: 0 0 0 0;
text {
font: "Sans";
size: 9;
min: 0 1;
text_class: "module_small";
}
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
color: 255 255 255 255;
color3: 0 0 0 24;
}
}
part { name: "event"; type: RECT;
mouse_events: 1;
description { state: "default" 0.0;
color: 0 0 0 0;
}
}
}
programs {
program { name: "fade1";
signal: "mouse,in";
source: "event";
action: STATE_SET "visible" 0.0;
transition: DECELERATE 1.0;
target: "e.text.label";
}
program { name: "fade2";
signal: "mouse,out";
source: "event";
action: STATE_SET "default" 0.0;
transition: DECELERATE 1.0;
target: "e.text.label";
}
}
}
part
{
name: "event";
type: RECT;
mouse_events: 1;
description
{
state: "default" 0.0;
color: 255 255 255 0;
}
group { name: "modules/xkbswitch/noflag";
max: 128 128;
parts {
part { name: "e.text.label"; type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
description { state: "default" 0.0;
rel1 {
relative: 0.0 0.5;
}
rel2 {
relative: 1.0 0.5;
}
color: 255 255 255 255;
color3: 0 0 0 24;
text {
font: "Sans";
size: 9;
min: 0 1;
text_class: "module_small";
}
}
part
{
name: "label";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
align: 0.5 0.5;
rel1
{
relative: 0.5 0.5;
offset: 0 0;
}
rel2
{
relative: 0.5 0.5;
offset: 0 0;
}
color: 255 255 255 255;
color3: 0 0 0 128;
text
{
text: "";
font: "Sans";
size: 9;
align: 0.5 0.5;
min: 1 1;
text_class: "module_small";
}
}
}
}
}
group
{
name: "modules/xkbswitch/noflag";
max: 148 128;
parts
{
part
{
name: "event";
type: RECT;
mouse_events: 1;
description
{
state: "default" 0.0;
color: 255 255 255 0;
}
}
part
{
name: "label";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
align: 0.5 0.5;
rel1
{
relative: 0.5 0.5;
offset: 0 0;
}
rel2
{
relative: 0.5 0.5;
offset: 0 0;
}
color: 255 255 255 255;
color3: 0 0 0 128;
text
{
text: "";
font: "Sans";
size: 9;
align: 0.5 0.5;
min: 1 1;
text_class: "module_small";
}
}
}
}
}
}
part { name: "event"; type: RECT;
mouse_events: 1;
description { state: "default" 0.0;
color: 0 0 0 0;
}
}
}
}
}

View File

@ -446,4 +446,5 @@ batt_over.png \
batt_power.png \
bg_shadow.png \
bg_over.png \
bg_base.png
bg_base.png \
xkbshad.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

View File

@ -521,22 +521,13 @@ _dlg_add_cb_ok(void *data __UNUSED__, E_Dialog *dlg)
{
Evas_Object *ic = e_icon_add(cfdata->evas);
{
const char *name = cl->name;
if (strchr(name, '/')) name = strchr(name, '/') + 1;
snprintf(buf, sizeof(buf), "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name);
if (!ecore_file_exists(buf))
snprintf(buf, sizeof(buf), "%s/data/flags/unknown_flag.png",
e_prefix_data_get());
e_icon_file_set(ic, buf);
}
const char *name = cl->name;
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name, cl->model, cl->variant);
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf, _cb_used_select, cfdata, NULL);
e_xkb_e_icon_flag_setup(ic, name);
snprintf(buf, sizeof(buf), "%s (%s, %s)",
cl->name, cl->model, cl->variant);
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
_cb_used_select, cfdata, NULL);
}
e_widget_ilist_go (cfdata->used_list);
@ -585,21 +576,13 @@ _cb_dlg_fill_delay(void *data)
EINA_LIST_FOREACH(layouts, l, layout)
{
Evas_Object *ic = e_icon_add(cfdata->dlg_evas);
{
const char *name = layout->name;
if (strchr(name, '/')) name = strchr(name, '/') + 1;
snprintf(buf, sizeof(buf), "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name);
if (!ecore_file_exists(buf))
snprintf(buf, sizeof(buf), "%s/data/flags/unknown_flag.png",
e_prefix_data_get());
e_icon_file_set(ic, buf);
}
const char *name = layout->name;
snprintf(buf, sizeof(buf), "%s (%s)", layout->description, layout->name);
e_widget_ilist_append_full(cfdata->layout_list, ic, NULL, buf, _cb_layout_select, cfdata, layout->name);
e_xkb_e_icon_flag_setup(ic, name);
snprintf(buf, sizeof(buf), "%s (%s)",
layout->description, layout->name);
e_widget_ilist_append_full(cfdata->layout_list, ic, NULL, buf,
_cb_layout_select, cfdata, layout->name);
}
e_widget_ilist_go (cfdata->layout_list);
@ -700,17 +683,12 @@ _cb_fill_delay(void *data)
{
Evas_Object *ic = e_icon_add(cfdata->evas);
const char *name = cl->name;
if (strchr(name, '/')) name = strchr(name, '/') + 1;
snprintf(buf, sizeof(buf), "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name);
if (!ecore_file_exists(buf))
snprintf(buf, sizeof(buf), "%s/flags/unknown_flag.png",
e_prefix_data_get());
e_icon_file_set(ic, buf);
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name, cl->model, cl->variant);
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf, _cb_used_select, cfdata, NULL);
e_xkb_e_icon_flag_setup(ic, name);
snprintf(buf, sizeof(buf), "%s (%s, %s)",
cl->name, cl->model, cl->variant);
e_widget_ilist_append_full(cfdata->used_list, ic, NULL, buf,
_cb_used_select, cfdata, NULL);
}
e_widget_ilist_go(cfdata->used_list);
@ -723,7 +701,8 @@ _cb_fill_delay(void *data)
EINA_LIST_FOREACH(models, l, model)
{
snprintf(buf, sizeof(buf), "%s (%s)", model->description, model->name);
e_widget_ilist_append(cfdata->dmodel_list, NULL, buf, NULL, cfdata, model->name);
e_widget_ilist_append(cfdata->dmodel_list, NULL, buf, NULL,
cfdata, model->name);
if (model->name == e_xkb_cfg->default_model)
e_widget_ilist_selected_set(cfdata->dmodel_list, n);
n++;

View File

@ -284,28 +284,20 @@ e_xkb_update_icon(void)
e_theme_edje_object_set(inst->o_xkbswitch,
"base/theme/modules/xkbswitch",
"modules/xkbswitch/noflag");
edje_object_part_text_set(inst->o_xkbswitch, "label", name);
edje_object_part_text_set(inst->o_xkbswitch, "e.text.label", name);
}
}
else
{
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name);
EINA_LIST_FOREACH(instances, l, inst)
{
if (!inst->o_xkbflag)
{
inst->o_xkbflag = e_icon_add(inst->gcc->gadcon->evas);
e_icon_file_set(inst->o_xkbflag, buf);
edje_object_part_swallow(inst->o_xkbswitch, "flag",
inst->o_xkbflag);
}
else
e_icon_file_set(inst->o_xkbflag, buf);
edje_object_part_text_set(inst->o_xkbswitch, "label", name);
inst->o_xkbflag = e_icon_add(inst->gcc->gadcon->evas);
e_xkb_e_icon_flag_setup(inst->o_xkbflag, name);
edje_object_part_swallow(inst->o_xkbswitch, "e.swallow.flag",
inst->o_xkbflag);
edje_object_part_text_set(inst->o_xkbswitch, "e.text.label",
e_xkb_layout_name_reduce(name));
}
}
}
@ -316,7 +308,7 @@ e_xkb_update_layout(void)
E_XKB_Config_Layout *cl;
E_XKB_Config_Option *op;
Eina_List *l;
char buf[PATH_MAX];
Eina_Strbuf *buf;
if (!e_xkb_cfg->used_layouts) return;
@ -324,41 +316,45 @@ e_xkb_update_layout(void)
* set options.
*/
// XXX: this is unsafe. doesn't keep into account size of buf
snprintf(buf, sizeof(buf), "setxkbmap ");
buf = eina_strbuf_new();
eina_strbuf_append(buf, "setxkbmap '");
EINA_LIST_FOREACH(e_xkb_cfg->used_layouts, l, cl)
{
strcat(buf, cl->name);
eina_strbuf_append(buf, cl->name);
break;
if (l->next) strcat(buf, ",");
//if (l->next) eina_strbuf_append(buf, ",");
}
strcat(buf, " -variant ");
eina_strbuf_append(buf, "'");
eina_strbuf_append(buf, " -variant '");
EINA_LIST_FOREACH(e_xkb_cfg->used_layouts, l, cl)
{
strcat(buf, cl->variant);
strcat(buf, ",");
eina_strbuf_append(buf, cl->variant);
eina_strbuf_append(buf, ",");
break;
}
eina_strbuf_append(buf, "'");
strcat(buf, " -model ");
eina_strbuf_append(buf, " -model '");
cl = eina_list_data_get(e_xkb_cfg->used_layouts);
if (strcmp(cl->model, "default"))
strcat(buf, cl->model);
eina_strbuf_append(buf, cl->model);
else if (strcmp(e_xkb_cfg->default_model, "default"))
strcat(buf, e_xkb_cfg->default_model);
eina_strbuf_append(buf, e_xkb_cfg->default_model);
else
strcat(buf, "default");
eina_strbuf_append(buf, "default");
eina_strbuf_append(buf, "'");
EINA_LIST_FOREACH(e_xkb_cfg->used_options, l, op)
{
strcat(buf, " -option ");
strcat(buf, op->name);
eina_strbuf_append(buf, " -option '");
eina_strbuf_append(buf, op->name);
eina_strbuf_append(buf, "'");
break;
}
printf("RUN: '%s'\n", buf);
ecore_exe_run(buf, NULL);
printf("RUN: '%s'\n", eina_strbuf_string_get(buf));
ecore_exe_run(eina_strbuf_string_get(buf), NULL);
eina_strbuf_free(buf);
}
void
@ -399,6 +395,36 @@ e_xkb_layout_prev(void)
e_xkb_update_layout();
}
const char *
e_xkb_layout_name_reduce(const char *name)
{
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
return name;
}
void
e_xkb_e_icon_flag_setup(Evas_Object *eicon, const char *name)
{
int w, h;
char buf[PATH_MAX];
e_xkb_flag_file_get(buf, sizeof(buf), name);
e_icon_file_set(eicon, buf);
e_icon_size_get(eicon, &w, &h);
edje_extern_object_aspect_set(eicon, EDJE_ASPECT_CONTROL_BOTH, w, h);
}
void
e_xkb_flag_file_get(char *buf, size_t bufsize, const char *name)
{
name = e_xkb_layout_name_reduce(name);
snprintf(buf, bufsize, "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name ? name : "unknown");
if (!ecore_file_exists(buf))
snprintf(buf, bufsize, "%s/data/flags/unknown_flag.png",
e_prefix_data_get());
}
/* LOCAL STATIC FUNCTIONS */
static E_Gadcon_Client *
@ -407,23 +433,19 @@ _gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
Instance *inst;
const char *name;
char buf[PATH_MAX];
if (e_xkb_cfg->used_layouts)
name = ((E_XKB_Config_Layout*)eina_list_data_get(e_xkb_cfg->used_layouts))->name;
else name = NULL;
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
/* The instance */
inst = E_NEW(Instance, 1);
/* The gadget */
inst->o_xkbswitch = edje_object_add(gc->evas);
//XXX add to theme
e_theme_edje_object_set(inst->o_xkbswitch,
"base/theme/modules/xkbswitch",
"modules/xkbswitch/main");
if (name) edje_object_part_text_set(inst->o_xkbswitch, "label", name);
edje_object_part_text_set(inst->o_xkbswitch, "e.text.label",
e_xkb_layout_name_reduce(name));
/* The gadcon client */
inst->gcc = e_gadcon_client_new(gc, gcname, id, style, inst->o_xkbswitch);
inst->gcc->data = inst;
@ -431,11 +453,10 @@ _gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
if (!e_xkb_cfg->only_label)
{
inst->o_xkbflag = e_icon_add(gc->evas);
snprintf(buf, sizeof(buf), "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name ? name : "unknown");
e_icon_file_set(inst->o_xkbflag, buf);
e_xkb_e_icon_flag_setup(inst->o_xkbflag, name);
/* The icon is part of the gadget. */
edje_object_part_swallow(inst->o_xkbswitch, "flag", inst->o_xkbflag);
edje_object_part_swallow(inst->o_xkbswitch, "e.swallow.flag",
inst->o_xkbflag);
}
else inst->o_xkbflag = NULL;
@ -648,12 +669,7 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
e_menu_item_radio_group_set(mi, 1);
e_menu_item_toggle_set(mi,
(l == e_xkb_cfg->used_layouts) ? 1 : 0);
if (strchr(name, '/')) name = strchr(name, '/') + 1;
snprintf(buf, sizeof(buf), "%s/data/flags/%s_flag.png",
e_prefix_data_get(), name);
if (!ecore_file_exists(buf))
snprintf(buf, sizeof(buf), "%s/data/flags/unknown_flag.png",
e_prefix_data_get());
e_xkb_flag_file_get(buf, sizeof(buf), name);
e_menu_item_icon_file_set(mi, buf);
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name,
cl->model, cl->variant);

View File

@ -90,6 +90,10 @@ void e_xkb_update_layout(void);
void e_xkb_layout_next(void);
void e_xkb_layout_prev(void);
const char *e_xkb_layout_name_reduce(const char *name);
void e_xkb_e_icon_flag_setup(Evas_Object *eicon, const char *name);
void e_xkb_flag_file_get(char *buf, size_t bufsize, const char *name);
E_Config_Dialog *e_xkb_cfg_dialog(E_Container *con, const char *params);
extern E_XKB_Config *e_xkb_cfg;