aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--data/themes/default_battery.edc50
-rw-r--r--data/themes/default_clock.edc202
-rw-r--r--data/themes/default_ibar.edc47
-rw-r--r--data/themes/default_pager.edc70
-rw-r--r--data/themes/images/e17_clock_bg.pngbin6685 -> 10270 bytes
-rw-r--r--data/themes/images/e17_clock_fg.pngbin21301 -> 17026 bytes
-rw-r--r--debian/control15
-rw-r--r--debian/enlightenment-data.install2
-rw-r--r--debian/enlightenment.install4
-rw-r--r--src/bin/e_border.c15
-rw-r--r--src/bin/e_config.c143
-rw-r--r--src/bin/e_config.h3
-rw-r--r--src/bin/e_dnd.c5
-rw-r--r--src/bin/e_gadcon.c910
-rw-r--r--src/bin/e_gadcon.h32
-rw-r--r--src/bin/e_includes.h1
-rw-r--r--src/bin/e_main.c3
-rw-r--r--src/bin/e_place.c497
-rw-r--r--src/bin/e_popup.c17
-rw-r--r--src/bin/e_resist.c32
-rw-r--r--src/bin/e_shelf.c28
-rw-r--r--src/bin/e_shelf.h1
-rw-r--r--src/modules/battery/Makefile.am3
-rw-r--r--src/modules/battery/e_mod_config.c60
-rw-r--r--src/modules/battery/e_mod_config.h8
-rw-r--r--src/modules/battery/e_mod_main.c865
-rw-r--r--src/modules/battery/e_mod_main.h57
-rw-r--r--src/modules/clock/Makefile.am4
-rw-r--r--src/modules/clock/e_mod_config.c99
-rw-r--r--src/modules/clock/e_mod_config.h8
-rw-r--r--src/modules/clock/e_mod_main.c480
-rw-r--r--src/modules/clock/e_mod_main.h44
-rw-r--r--src/modules/cpufreq/e_mod_main.c1365
-rw-r--r--src/modules/cpufreq/e_mod_main.h69
-rw-r--r--src/modules/dropshadow/e_mod_main.c2
-rw-r--r--src/modules/ibar/Makefile.am3
-rw-r--r--src/modules/ibar/e_mod_config.c177
-rw-r--r--src/modules/ibar/e_mod_config.h8
-rw-r--r--src/modules/ibar/e_mod_main.c2327
-rw-r--r--src/modules/ibar/e_mod_main.h91
-rw-r--r--src/modules/pager/Makefile.am3
-rw-r--r--src/modules/pager/e_mod_config.c117
-rw-r--r--src/modules/pager/e_mod_config.h8
-rw-r--r--src/modules/pager/e_mod_main.c2392
-rw-r--r--src/modules/pager/e_mod_main.h139
-rw-r--r--src/modules/start/e_mod_main.c32
-rw-r--r--src/modules/start/e_mod_main.h4
-rw-r--r--src/modules/temperature/Makefile.am3
-rw-r--r--src/modules/temperature/e_mod_config.c112
-rw-r--r--src/modules/temperature/e_mod_config.h8
-rw-r--r--src/modules/temperature/e_mod_main.c491
-rw-r--r--src/modules/temperature/e_mod_main.h43
53 files changed, 4589 insertions, 6512 deletions
diff --git a/Makefile.am b/Makefile.am
index 57b298f89..36aa42a53 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,7 @@ bin_SCRIPTS = enlightenment-config
EXTRA_DIST = README AUTHORS COPYING COPYING-PLAIN enlightenment.spec \
debian/changelog debian/changelog.in debian/copyright \
debian/rules debian/enlightenment.install \
- debian/enlightenment.docs debian/enlightenment-data.install \
+ debian/enlightenment.docs \
debian/libe.install debian/libe-dev.install debian/control \
enlightenment.spec.in
diff --git a/data/themes/default_battery.edc b/data/themes/default_battery.edc
index 5a52a32cd..85deac42e 100644
--- a/data/themes/default_battery.edc
+++ b/data/themes/default_battery.edc
@@ -115,6 +115,31 @@ group {
}
}
part {
+ name: "ac";
+ clip_to: "fade_clip";
+ description {
+ state: "default" 0.0;
+ aspect: 0.975609756 0.975609756;
+ align: 1.0 1.0;
+ max: 40 41;
+ visible: 0;
+ rel1 {
+ relative: 0.5 0.5;
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ }
+ image {
+ normal: "e17_battery_ac.png";
+ }
+ }
+ description {
+ state: "active" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part {
name: "reading";
type: TEXT;
effect: SOFT_SHADOW;
@@ -171,31 +196,6 @@ group {
}
}
part {
- name: "ac";
- clip_to: "fade_clip";
- description {
- state: "default" 0.0;
- aspect: 0.975609756 0.975609756;
- align: 1.0 1.0;
- max: 40 41;
- visible: 0;
- rel1 {
- relative: 0.5 0.5;
- }
- rel2 {
- relative: 1.0 1.0;
- }
- image {
- normal: "e17_battery_ac.png";
- }
- }
- description {
- state: "active" 0.0;
- inherit: "default" 0.0;
- visible: 1;
- }
- }
- part {
name: "fade_clip";
type: RECT;
mouse_events: 0;
diff --git a/data/themes/default_clock.edc b/data/themes/default_clock.edc
index 7cfcf885d..abfec1912 100644
--- a/data/themes/default_clock.edc
+++ b/data/themes/default_clock.edc
@@ -1,8 +1,6 @@
images {
image: "e17_clock_bg.png" COMP;
image: "e17_clock_fg.png" COMP;
- image: "e17_ibar_over_h.png" COMP;
- image: "e17_ibar_bg_h.png" COMP;
image: "e17_clock_seconds_00.png" COMP;
image: "e17_clock_seconds_01.png" COMP;
image: "e17_clock_seconds_02.png" COMP;
@@ -189,24 +187,10 @@ group {
script {
public clock_cb(val) {
new buf[11];
- new digitalVal[15];
- new hourStr[4], minuteStr[4], secondStr[4];
new year, month, day, yearday, weekday, hour, minute;
new Float:second;
new v;
- new isAfternoon;
- new digiBuf[2];
- new digitalStyle;
- new DIGITAL_STYLE_NONE, DIGITAL_STYLE_NORMAL, DIGITAL_STYLE_24HOUR;
-
- DIGITAL_STYLE_NONE = 0;
- DIGITAL_STYLE_NORMAL = 1;
- DIGITAL_STYLE_24HOUR = 2;
-
- get_text(PART:"digitalStyle", digiBuf, 2);
-
- digitalStyle = atoi(digiBuf);
-
+
date(year, month, day, yearday, weekday, hour, minute, second);
v = round(second);
#if E17_PROFILE != HIRES_PDA && E17_PROFILE != LOWRES_PDA && E17_PROFILE != MEDIUMRES_PDA
@@ -216,7 +200,6 @@ group {
#endif
#if E17_PROFILE != HIRES_PDA && E17_PROFILE != LOWRES_PDA && E17_PROFILE != MEDIUMRES_PDA
buf[0] = 0;
- digitalVal[0] = 0;
if (v < 10) {snprintf(buf, 10, "0%i", v);}
else {snprintf(buf, 10, "%i", v);}
set_state(PART:"seconds", buf, 0.0);
@@ -232,59 +215,6 @@ group {
if (v < 10) {snprintf(buf, 10, "0%i", v);}
else {snprintf(buf, 10, "%i", v);}
set_state(PART:"hour", buf, 0.0);
-
-
- buf[0] = 0;
- v = round(second);
- if (v < 10) {snprintf(buf, 10, "0%i", v);}
- else {snprintf(buf, 10, "%i", v);}
- snprintf(secondStr, 3, "%s", buf);
-
- buf[0] = 0;
- if (minute < 10) {snprintf(buf, 10, "0%i", minute);}
- else {snprintf(buf, 10, "%i", minute);}
- snprintf(minuteStr, 3, "%s", buf);
-
- buf[0] = 0;
- isAfternoon = 0;
- v = hour;
- if (hour >= 12 && hour < 24) { isAfternoon = 1; }
- if (digitalStyle == DIGITAL_STYLE_NORMAL) {
- v = (v % 12);
- if (v == 0) { v = 12; }
- }
- if (digitalStyle == DIGITAL_STYLE_24HOUR && v < 10) {
- snprintf(buf, 10, "0%i", v);
- } else {
- snprintf(buf, 10, "%i", v);
- }
- snprintf(hourStr, 3, "%s", buf);
-
- buf[0] = 0;
-
- if (isAfternoon == 1) {
- snprintf(buf, 10, "PM");
- } else {
- snprintf(buf, 10, "AM");
- }
-
- if (digitalStyle != DIGITAL_STYLE_NONE) {
- if (digitalStyle == DIGITAL_STYLE_NORMAL) {
- snprintf(digitalVal, 14, "%s:%s:%s %s", hourStr, minuteStr, secondStr, buf);
- } else if (digitalStyle == DIGITAL_STYLE_24HOUR) {
- snprintf(digitalVal, 14, " %s:%s:%s ", hourStr, minuteStr, secondStr);
- }
-
- set_text(PART:"digital", digitalVal);
- set_state(PART:"digital", "digital", 0.0);
- set_state(PART:"digital_bg", "digital", 0.0);
- set_state(PART:"digital_bg_overlay", "digital", 0.0);
- } else {
- set_text(PART:"digital", "");
- set_state(PART:"digital", "hidden", 0.0);
- set_state(PART:"digital_bg", "hidden", 0.0);
- set_state(PART:"digital_bg_overlay", "hidden", 0.0);
- }
}
}
parts {
@@ -310,10 +240,10 @@ group {
state: "default" 0.0;
aspect: 1.0 1.0;
rel1 {
- relative: 0.1 0.1;
+ relative: 0.05 0.05;
}
rel2 {
- relative: 0.9 0.9;
+ relative: 0.95 0.95;
}
image {
normal: "e17_clock_"IND"_00.png";
@@ -403,10 +333,10 @@ group {
state: "default" 0.0;
aspect: 1.0 1.0;
rel1 {
- relative: 0.1 0.1;
+ relative: 0.05 0.05;
}
rel2 {
- relative: 0.9 0.9;
+ relative: 0.95 0.95;
}
image {
normal: "e17_clock_"IND"_00.png";
@@ -495,10 +425,10 @@ group {
state: "default" 0.0;
aspect: 1.0 1.0;
rel1 {
- relative: 0.2 0.2;
+ relative: 0.1 0.1;
}
rel2 {
- relative: 0.8 0.8;
+ relative: 0.9 0.9;
}
image {
normal: "e17_clock_"IND"_00.png";
@@ -592,124 +522,6 @@ group {
}
}
}
- part {
- name: "digital_bg_area";
- type: "RECT";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 16 16;
- rel1 {
- relative: 0.0 0.8;
- }
- rel2 {
- relative: 1.0 1.0;
- }
- visible: 0;
- }
- }
- part {
- name: "digital_bg_overlay";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1 {
- to: "digital_bg_area";
- relative: 0.0 0.0;
- }
- rel2 {
- to: "digital_bg_area";
- relative: 1.0 1.0;
- }
- image {
- normal: "e17_ibar_over_h.png";
- border: 13 13 13 13;
- }
- fill {
- smooth: 0;
- }
- color: 255 255 255 192;
- }
- description {
- state: "hidden" 0.0;
- visible: 0;
- image {
- normal: "e17_ibar_over_h.png";
- border: 13 13 13 13;
- middle: 0;
- }
- }
- }
- part {
- name: "digital_bg";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1 {
- to: "digital_bg_area";
- relative: 0.0 0.0;
- }
- rel2 {
- to: "digital_bg_area";
- relative: 1.0 1.0;
- }
- image {
- normal: "e17_ibar_bg_h.png";
- border: 6 6 6 6;
- }
- fill {
- smooth: 0;
- }
- color: 255 255 255 128;
- }
- description {
- state: "hidden" 0.0;
- visible: 0;
- image {
- normal: "e17_ibar_bg_h.png";
- border: 6 6 6 6;
- middle: 0;
- }
- }
- }
- part {
- name: "digital";
- type: TEXT;
- effect: SOFT_SHADOW;
- description {
- state: "default" 0.0;
- rel1 {
- to: "digital_bg_area";
- offset: 3 4;
- }
- rel2 {
- to: "digital_bg_area";
- offset: -2 -2;
- }
- color: 255 255 255 255;
- color3: 0 0 0 32;
- text {
- text: "00:00:00 AM";
- font: "Edje-Vera";
- size: 15;
- fit: 0 1;
- align: 0.5 0.5;
- text_class: "clock";
- }
- }
- description {
- state: "hidden" 0.0;
- visible: 0;
- }
- }
- part {
- name: "digitalStyle";
- type: TEXT;
- description {
- state: "hidden" 0.0;
- visible: 0;
- }
- }
}
programs {
program {
diff --git a/data/themes/default_ibar.edc b/data/themes/default_ibar.edc
index 44ffb5434..94915442c 100644
--- a/data/themes/default_ibar.edc
+++ b/data/themes/default_ibar.edc
@@ -621,18 +621,55 @@ group {
state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
- offset: 4 4;
+ offset: 2 2;
}
rel2 {
relative: 1.0 1.0;
- offset: -5 -5;
+ offset: -3 -3;
}
color: 0 0 0 0;
}
+ description {
+ state: "bigger" 0.0;
+ inherit: "default" 0.0;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 0 0;
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ offset: -1 -1;
+ }
+ }
+ }
+ part {
+ name: "over";
+ type: RECT;
+ repeat_events: 0;
+ description {
+ state: "default" 0.0;
+ color: 0 0 0 0;
+ }
}
}
programs {
program {
+ name: "hover_in";
+ signal: "mouse,in";
+ source: "over";
+ action: STATE_SET "bigger" 0.0;
+ transition: LINEAR 0.1;
+ target: "item";
+ }
+ program {
+ name: "hover_out";
+ signal: "mouse,out";
+ source: "over";
+ action: STATE_SET "default" 0.0;
+ transition: LINEAR 0.2;
+ target: "item";
+ }
+ program {
name: "exec_start";
signal: "start";
source: "";
@@ -671,12 +708,6 @@ group {
mouse_events: 0;
description {
state: "default" 0.0;
- rel1 {
- offset: 4 4;
- }
- rel2 {
- offset: -5 -5;
- }
color: 255 255 255 0;
}
}
diff --git a/data/themes/default_pager.edc b/data/themes/default_pager.edc
index 7542ba38b..aa6170830 100644
--- a/data/themes/default_pager.edc
+++ b/data/themes/default_pager.edc
@@ -151,10 +151,64 @@ group {
}
}
part {
- name: "pager";
+ name: "background";
mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "overlay";
+ }
+ rel2 {
+ to: "overlay";
+ }
+ image {
+ normal: "e17_ibar_bg_h.png";
+ border: 6 6 6 6;
+ }
+ fill {
+ smooth: 0;
+ }
+ }
+ }
+ part {
+ name: "items_clip";
+ type: RECT;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "background";
+ offset: 4 4;
+ }
+ rel2 {
+ to: "background";
+ offset: -5 -5;
+ }
+ color: 255 255 255 255;
+ }
+ }
+ part {
+ name: "pager";
type: SWALLOW;
- description {
+ mouse_events: 0;
+ clip_to: "items_clip";
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "overlay";
+ offset: 4 4;
+ }
+ rel2 {
+ to: "overlay";
+ offset: -5 -5;
+ }
+ color: 0 0 0 0;
+ }
+ }
+ part {
+ name: "overlay";
+ mouse_events: 0;
+ description {
state: "default" 0.0;
rel1 {
to_y: "title_overlay";
@@ -165,7 +219,14 @@ group {
relative: 1.0 1.0;
offset: -17 -17;
}
- color: 0 0 0 0;
+ image {
+ normal: "e17_ibar_over_h.png";
+ border: 13 13 13 13;
+ middle: 0;
+ }
+ fill {
+ smooth: 0;
+ }
}
}
}
@@ -377,7 +438,8 @@ group {
}
part {
name: "overlay";
- mouse_events: 0;
+ repeat_events: 1;
+// mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
diff --git a/data/themes/images/e17_clock_bg.png b/data/themes/images/e17_clock_bg.png
index a1ac3ed76..d766d1327 100644
--- a/data/themes/images/e17_clock_bg.png
+++ b/data/themes/images/e17_clock_bg.png
Binary files differ
diff --git a/data/themes/images/e17_clock_fg.png b/data/themes/images/e17_clock_fg.png
index b48a591a7..9dca2c547 100644
--- a/data/themes/images/e17_clock_fg.png
+++ b/data/themes/images/e17_clock_fg.png
Binary files differ
diff --git a/debian/control b/debian/control
index f5b56689a..9067180f3 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: enlightenment
Section: x11
Priority: optional
Maintainer: E17 Debian Team <debian@edevelop.org>
-Build-Depends: libevas-dev, libecore-dev, libeet-dev, libedje-dev, edje-bin, libembryo-dev, xlibs-dev, automake1.7 | automaken, libtool, debhelper (>= 4.0)
+Build-Depends: libevas-dev, libecore-dev, libeet-dev, libedje-dev, edje-bin, libembryo-dev, libx11-dev, x-dev, libxext-dev, automake1.7 | automaken, libtool, debhelper (>= 4.0)
Standards-Version: 3.6.2.2
Package: enlightenment
@@ -10,24 +10,13 @@ Architecture: any
Section: x11
Recommends: libevas-engine-xrender
Suggests: entrance
-Depends: ${shlibs:Depends}, libe, enlightenment-data (>= 0.16.999), libevas, libecore, libecore-con, libecore-evas, libecore-file, libecore-ipc, libecore-job, libecore-txt, libecore-x, libeet, libembryo, embryo-bin, edje-bin, libedje, libevas-loader-eet, libevas-loader-jpeg, libevas-loader-png, libevas-saver-eet, libevas-saver-jpeg, libevas-saver-png, libevas-engine-buffer, libevas-engine-software-x11
+Depends: ${shlibs:Depends}, libe, libevas, libecore, libecore-con, libecore-evas, libecore-file, libecore-ipc, libecore-job, libecore-txt, libecore-x, libeet, libembryo, embryo-bin, edje-bin, libedje, libevas-loader-eet, libevas-loader-jpeg, libevas-loader-png, libevas-saver-eet, libevas-saver-jpeg, libevas-saver-png, libevas-engine-buffer, libevas-engine-software-x11
Description: Enlightenment themes, etc.
Enlightenment is an advanced window manager for X11. Unique
features include: a fully animated background, nice drop shadows
around windows, backed by an extremely clean and optimized
foundation of APIs.
-Package: enlightenment-data
-Architecture: any
-Section: x11
-Depends: enlightenment (= ${Source-Version})
-Conflicts: enlightenment-data (< 0.16.999)
-Description: Enlightenment themes, etc.
- Enlightenment is an advanced window manager for X11. Unique
- features include: a fully animated background, nice drop shadows
- around windows, a unique application launcher module (ibar). All
- backed by an extremely clean and optimized foundation of APIs.
-
Package: libe
Section: libs
Architecture: any
diff --git a/debian/enlightenment-data.install b/debian/enlightenment-data.install
deleted file mode 100644
index 11e6d0f63..000000000
--- a/debian/enlightenment-data.install
+++ /dev/null
@@ -1,2 +0,0 @@
-debian/tmp/usr/share/enlightenment/data/themes/*.edj
-debian/tmp/usr/share/enlightenment/data/init/*.edj
diff --git a/debian/enlightenment.install b/debian/enlightenment.install
index 3aa7a7e34..d7d8f85fc 100644
--- a/debian/enlightenment.install
+++ b/debian/enlightenment.install
@@ -21,9 +21,5 @@ debian/tmp/usr/lib/enlightenment/modules/start/*.png
debian/tmp/usr/lib/enlightenment/modules/temperature/*/*.so
debian/tmp/usr/lib/enlightenment/modules/temperature/*.png
debian/tmp/usr/share/enlightenment
-debian/tmp/usr/share/enlightenment
-debian/tmp/usr/share/enlightenment
-debian/tmp/usr/share/enlightenment
-debian/tmp/usr/share/enlightenment
debian/tmp/usr/share/locale
debian/tmp/usr/share/xsessions
diff --git a/src/bin/e_border.c b/src/bin/e_border.c
index 43f089e5f..7ba31277f 100644
--- a/src/bin/e_border.c
+++ b/src/bin/e_border.c
@@ -5727,6 +5727,21 @@ _e_border_eval(E_Border *bd)
changed = 0;
for (i = 0; i < num; i++)
{
+ if (rects[i].x < 0)
+ {
+ rects[i].width -= rects[i].x;
+ rects[i].x = 0;
+ }
+ if ((rects[i].x + rects[i].width) > bd->w)
+ rects[i].width = rects[i].width - rects[i].x;
+ if (rects[i].y < 0)
+ {
+ rects[i].height -= rects[i].y;
+ rects[i].y = 0;
+ }
+ if ((rects[i].y + rects[i].height) > bd->h)
+ rects[i].height = rects[i].height - rects[i].y;
+
if ((orects[i].x != rects[i].x) ||
(orects[i].y != rects[i].y) ||
(orects[i].width != rects[i].width) ||
diff --git a/src/bin/e_config.c b/src/bin/e_config.c
index ca14885f1..a5f89165c 100644
--- a/src/bin/e_config.c
+++ b/src/bin/e_config.c
@@ -91,6 +91,7 @@ e_config_init(void)
E_CONFIG_VAL(D, T, geom.res, INT);
E_CONFIG_VAL(D, T, style, STR);
E_CONFIG_VAL(D, T, autoscroll, UCHAR);
+ E_CONFIG_VAL(D, T, resizable, UCHAR);
_e_config_gadcon_edd = E_CONFIG_DD_NEW("E_Config_Gadcon", E_Config_Gadcon);
#undef T
@@ -1016,71 +1017,111 @@ e_config_init(void)
"desk_linear_flip_by", "1");
}
IFCFGEND;
- /* yes - this causes a small leak - i know. it is for testing temporarily x*/
+ IFCFG(0x0093); /* the version # where this value(s) was introduced */
+ /* FIXME: wipe previous shelves and gadcons - remove this eventually */
e_config->shelves = NULL;
e_config->gadcons = NULL;
-// IFCFG(0x008e); /* the version # where this value(s) was introduced */
-#if 1 // this is liable to change
{
E_Config_Shelf *cf_es;
- 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;
- cf_es->orient = E_GADCON_ORIENT_TOP;
- cf_es->fit_along = 1;
- cf_es->fit_size = 0;
- cf_es->style = evas_stringshare_add("default");
- cf_es->size = 40;
- e_config->shelves = evas_list_append(e_config->shelves, cf_es);
+#define CFG_SHELF(_name, _con, _zone, _pop, _lay, _orient, _fita, _fits, _style, _size) \
+ cf_es = E_NEW(E_Config_Shelf, 1); \
+ cf_es->name = evas_stringshare_add(_name); \
+ cf_es->container = _con; \
+ cf_es->zone = _zone; \
+ cf_es->popup = _pop; \
+ cf_es->layer = _lay; \
+ cf_es->orient = _orient; \
+ cf_es->fit_along = _fita; \
+ cf_es->fit_size = _fits; \
+ cf_es->style = evas_stringshare_add(_style); \
+ cf_es->size = _size; \
+ e_config->shelves = evas_list_append(e_config->shelves, cf_es)
+ /* shelves for 4 zones on head 0 by default */
+ CFG_SHELF("shelf", 0, 0,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
+ CFG_SHELF("shelf", 0, 1,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
+ CFG_SHELF("shelf", 0, 2,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
+ CFG_SHELF("shelf", 0, 3,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
+ /* shelves for heada 1, 2, and 3 by default */
+ CFG_SHELF("shelf", 1, 0,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
+ CFG_SHELF("shelf", 2, 0,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
+ CFG_SHELF("shelf", 3, 0,
+ 1, 200, E_GADCON_ORIENT_BOTTOM,
+ 1, 0, "default", 40);
}
{
E_Config_Gadcon *cf_gc;
E_Config_Gadcon_Client *cf_gcc;
+
+#define CFG_GADCON(_name, _id) \
+ cf_gc = E_NEW(E_Config_Gadcon, 1);\
+ cf_gc->name = evas_stringshare_add(_name); \
+ cf_gc->id = evas_stringshare_add(_id); \
+ e_config->gadcons = evas_list_append(e_config->gadcons, cf_gc)
+#define CFG_GADCON_CLIENT(_name, _id, _res, _size, _pos, _style, _autoscr, _resizable) \
+ cf_gcc = E_NEW(E_Config_Gadcon_Client, 1); \
+ cf_gcc->name = evas_stringshare_add(_name); \
+ cf_gcc->id = evas_stringshare_add(_id); \
+ cf_gcc->geom.res = _res; \
+ cf_gcc->geom.size = _size; \
+ cf_gcc->geom.pos = _pos; \
+ if (_style) cf_gcc->style = evas_stringshare_add(_style); \
+ else cf_gcc->style = NULL; \
+ cf_gcc->autoscroll = _autoscr; \
+ cf_gcc->resizable = _resizable; \
+ cf_gc->clients = evas_list_append(cf_gc->clients, cf_gcc)
+
+ /* the default shelf on the default head/zone */
+ CFG_GADCON("shelf", "0");
+ CFG_GADCON_CLIENT("start", "default", 800, 32,
+ 0, NULL, 0, 0);
+ CFG_GADCON_CLIENT("pager", "default", 800, 120,
+ 32, "inset", 0, 0);
+ CFG_GADCON_CLIENT("ibar", "default", 800, 200,
+ 400 - (16 / 2), "inset", 1, 0);
+ CFG_GADCON_CLIENT("temperature", "default", 800, 32,
+ 800 - (4 * 32), NULL, 0, 0);
+ CFG_GADCON_CLIENT("cpufreq", "default", 800, 32,
+ 800 - (3 * 32), NULL, 0, 0);
+ CFG_GADCON_CLIENT("battery", "default", 800, 32,
+ 800 - (2 * 32), NULL, 0, 0);
+ CFG_GADCON_CLIENT("clock", "default", 800, 32,
+ 800 - (1 * 32), NULL, 0, 0);
+ /* additional shelves for up to 3 more heads by default */
+ CFG_GADCON("shelf", "1");
+ CFG_GADCON_CLIENT("pager", "default2", 800, 120,
+ 0, "inset", 0, 0);
+ CFG_GADCON_CLIENT("ibar", "default2", 800, 16,
+ 400 - (16 / 2), "inset", 1, 0);
- cf_gc = E_NEW(E_Config_Gadcon, 1);
- cf_gc->name = evas_stringshare_add("shelf");
- cf_gc->id = evas_stringshare_add("0");
- e_config->gadcons = evas_list_append(e_config->gadcons, cf_gc);
-
- cf_gcc = E_NEW(E_Config_Gadcon_Client, 1);
- cf_gcc->name = evas_stringshare_add("ibar");
- cf_gcc->id = evas_stringshare_add("default");
- cf_gcc->geom.res = 800;
- cf_gcc->geom.size = 200;
- cf_gcc->geom.pos = 400 - (cf_gcc->geom.size / 2);
- cf_gcc->style = evas_stringshare_add("inset");
- cf_gcc->autoscroll = 0;
- cf_gc->clients = evas_list_append(cf_gc->clients, cf_gcc);
-
- cf_gcc = E_NEW(E_Config_Gadcon_Client, 1);
- cf_gcc->name = evas_stringshare_add("clock");
- cf_gcc->id = evas_stringshare_add("default");
- cf_gcc->geom.res = 800;
- cf_gcc->geom.size = 32;
- cf_gcc->geom.pos = 800 - (cf_gcc->geom.size);
- cf_gcc->style = NULL;
- cf_gcc->autoscroll = 0;
- cf_gc->clients = evas_list_append(cf_gc->clients, cf_gcc);
+ CFG_GADCON("shelf", "2");
+ CFG_GADCON_CLIENT("pager", "default3", 800, 120,
+ 0, "inset", 0, 0);
+ CFG_GADCON_CLIENT("ibar", "default2", 800, 16,
+ 400 - (16 / 2), "inset", 1, 0);
- cf_gcc = E_NEW(E_Config_Gadcon_Client, 1);
- cf_gcc->name = evas_stringshare_add("start");
- cf_gcc->id = evas_stringshare_add("default");
- cf_gcc->geom.res = 800;
- cf_gcc->geom.size = 32;
- cf_gcc->geom.pos = 0;
- cf_gcc->style = NULL;
- cf_gcc->autoscroll = 0;
- cf_gc->clients = evas_list_append(cf_gc->clients, cf_gcc);
+ CFG_GADCON("shelf", "3");
+ CFG_GADCON_CLIENT("pager", "default4", 800, 120,
+ 0, "inset", 0, 0);
+ CFG_GADCON_CLIENT("ibar", "default2", 800, 16,
+ 400 - (16 / 2), "inset", 1, 0);
}
-#endif
-// IFCFGEND;
+ IFCFGEND;
#if 0 /* example of new config */
- IFCFG(0x008e); /* the version # where this value(s) was introduced */
+ IFCFG(0x0090); /* the version # where this value(s) was introduced */
e_config->new_value = 10; /* set the value(s) */
IFCFGEND;
#endif
diff --git a/src/bin/e_config.h b/src/bin/e_config.h
index 1d6c10e15..0ea1cea3c 100644
--- a/src/bin/e_config.h
+++ b/src/bin/e_config.h
@@ -50,7 +50,7 @@ typedef Eet_Data_Descriptor E_Config_DD;
/* increment this whenever a new set of configvalues are added but the users
* config doesn't need top be wiped - simply new values need to be put in
*/
-#define E_CONFIG_FILE_GENERATION 0x008e
+#define E_CONFIG_FILE_GENERATION 0x0093
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
#define E_EVAS_ENGINE_DEFAULT 0
@@ -317,6 +317,7 @@ struct _E_Config_Gadcon_Client
} geom;
const char *style;
unsigned char autoscroll;
+ unsigned char resizable;
};
struct _E_Config_Shelf
diff --git a/src/bin/e_dnd.c b/src/bin/e_dnd.c
index d6afa1ac9..30b09c78c 100644
--- a/src/bin/e_dnd.c
+++ b/src/bin/e_dnd.c
@@ -3,6 +3,11 @@
*/
#include "e.h"
+/* FIXME: broken when drop areas intersect
+ * (sub window has drop area on top of lower window or desktop -
+ * also shutdown is broken (walking list and deleting from the list as u go
+ * in this code is broken)
+ */
/*
* TODO:
* - Let an internal drag work with several types.
diff --git a/src/bin/e_gadcon.c b/src/bin/e_gadcon.c
index e8f1c9946..776c1190c 100644
--- a/src/bin/e_gadcon.c
+++ b/src/bin/e_gadcon.c
@@ -6,8 +6,14 @@
static void _e_gadcon_free(E_Gadcon *gc);
static void _e_gadcon_client_free(E_Gadcon_Client *gcc);
+static void _e_gadcon_movereisze_handle(E_Gadcon_Client *gcc);
+static int _e_gadcon_cb_client_scroll_timer(void *data);
+static int _e_gadcon_cb_client_scroll_animator(void *data);
+static void _e_gadcon_cb_client_frame_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _e_gadcon_cb_client_frame_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_gadcon_client_save(E_Gadcon_Client *gcc);
+static void _e_gadcon_cb_min_size_request(void *data, Evas_Object *obj, void *event_info);
static void _e_gadcon_cb_size_request(void *data, Evas_Object *obj, void *event_info);
static void _e_gadcon_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _e_gadcon_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
@@ -25,12 +31,6 @@ static void _e_gadcon_cb_signal_resize_left_go(void *data, Evas_Object *obj, con
static void _e_gadcon_cb_signal_resize_right_start(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _e_gadcon_cb_signal_resize_right_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _e_gadcon_cb_signal_resize_right_go(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _e_gadcon_cb_signal_resize_up_start(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _e_gadcon_cb_signal_resize_up_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _e_gadcon_cb_signal_resize_up_go(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _e_gadcon_cb_signal_resize_down_start(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _e_gadcon_cb_signal_resize_down_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _e_gadcon_cb_signal_resize_down_go(void *data, Evas_Object *obj, const char *emission, const char *source);
static Evas_Object *e_gadcon_layout_add(Evas *evas);
static void e_gadcon_layout_orientation_set(Evas_Object *obj, int horizontal);
@@ -50,69 +50,11 @@ static void e_gadcon_layout_unpack(Evas_Object *obj);
static Evas_Hash *providers = NULL;
static Evas_List *gadcons = NULL;
-
-static E_Gadcon_Client *
-__test(E_Gadcon *gc, char *name, char *id, char *style)
-{
- Evas_Object *o;
- E_Gadcon_Client *gcc;
-
- printf("create gadcon client \"%s\" \"%s\" \"%s\" for \"%s\" \"%s\"\n",
- name, id, style,
- gc->name, gc->id);
- o = evas_object_rectangle_add(gc->evas);
- evas_object_color_set(o, rand() & 0xff, rand() & 0xff, rand() & 0xff, 150);
- gcc = e_gadcon_client_new(gc, name, id, style, o);
- gcc->data = NULL; // this is where a module would hook private data
- return gcc;
-}
-
-static void
-__test2(E_Gadcon_Client *gcc)
-{
- evas_object_del(gcc->o_base);
-}
-
-static void
-__test3(E_Gadcon_Client *gcc)
-{
- e_gadcon_client_min_size_set(gcc, 200, 20);
-}
-
-static void
-__test4(E_Gadcon_Client *gcc)
-{
- e_gadcon_client_min_size_set(gcc, 32, 20);
-}
/* externally accessible functions */
EAPI int
e_gadcon_init(void)
{
- /* FIXME: these would be provided by modules registering gadget creation
- * classes */
- {
- static E_Gadcon_Client_Class cc =
- {
- GADCON_CLIENT_CLASS_VERSION,
- "ibar",
- {
- __test, __test2, __test3
- }
- };
- e_gadcon_provider_register(&cc);
- }
- {
- static E_Gadcon_Client_Class cc =
- {
- GADCON_CLIENT_CLASS_VERSION,
- "clock",
- {
- __test, __test2, __test4
- }
- };
- e_gadcon_provider_register(&cc);
- }
return 1;
}
@@ -125,12 +67,40 @@ e_gadcon_shutdown(void)
EAPI void
e_gadcon_provider_register(E_Gadcon_Client_Class *cc)
{
+ Evas_List *l;
+ E_Gadcon *gc;
+
providers = evas_hash_direct_add(providers, cc->name, cc);
+ for (l = gadcons; l; l = l->next)
+ {
+ gc = l->data;
+ e_gadcon_populate_class(gc, cc);
+ }
}
EAPI void
e_gadcon_provider_unregister(E_Gadcon_Client_Class *cc)
{
+ Evas_List *l, *ll, *dlist = NULL;
+ E_Gadcon *gc;
+ E_Gadcon_Client *gcc;
+
+ for (l = gadcons; l; l = l->next)
+ {
+ gc = l->data;
+ for (ll = gc->clients; ll; ll = ll->next)
+ {
+ gcc = ll->data;
+ if (gcc->client_class == cc)
+ dlist = evas_list_append(dlist, gcc);
+ }
+ }
+ while (dlist)
+ {
+ gcc = dlist->data;
+ dlist = evas_list_remove_list(dlist, dlist);
+ e_object_del(E_OBJECT(gcc));
+ }
providers = evas_hash_del(providers, cc->name, cc);
}
@@ -154,6 +124,8 @@ e_gadcon_swallowed_new(const char *name, char *id, Evas_Object *obj, char *swall
gc->o_container = e_gadcon_layout_add(gc->evas);
evas_object_smart_callback_add(gc->o_container, "size_request",
_e_gadcon_cb_size_request, gc);
+ evas_object_smart_callback_add(gc->o_container, "min_size_request",
+ _e_gadcon_cb_min_size_request, gc);
evas_object_show(gc->o_container);
edje_object_part_swallow(gc->edje.o_parent, gc->edje.swallow_name,
gc->o_container);
@@ -173,6 +145,16 @@ e_gadcon_swallowed_min_size_set(E_Gadcon *gc, Evas_Coord w, Evas_Coord h)
}
EAPI void
+e_gadcon_min_size_request_callback_set(E_Gadcon *gc, void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data)
+{
+ E_OBJECT_CHECK(gc);
+ E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
+
+ gc->min_size_request.func = func;
+ gc->min_size_request.data = data;
+}
+
+EAPI void
e_gadcon_size_request_callback_set(E_Gadcon *gc, void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data)
{
E_OBJECT_CHECK(gc);
@@ -242,7 +224,7 @@ e_gadcon_populate(E_Gadcon *gc)
cf_gcc->style);
if (gcc)
{
- gcc->client_class = *cc;
+ gcc->client_class = cc;
gcc->config.pos = cf_gcc->geom.pos;
gcc->config.size = cf_gcc->geom.size;
gcc->config.res = cf_gcc->geom.res;
@@ -256,8 +238,76 @@ e_gadcon_populate(E_Gadcon *gc)
gcc->config.pos,
gcc->config.size,
gcc->config.res);
- if (gcc->client_class.func.orient)
- gcc->client_class.func.orient(gcc);
+ e_gadcon_client_autoscroll_set(gcc, cf_gcc->autoscroll);
+ e_gadcon_client_resizable_set(gcc, cf_gcc->resizable);
+ if (gcc->client_class->func.orient)
+ gcc->client_class->func.orient(gcc);
+ }
+ }
+ }
+ }
+ e_gadcon_layout_thaw(gc->o_container);
+}
+
+EAPI void
+e_gadcon_unpopulate(E_Gadcon *gc)
+{
+ E_OBJECT_CHECK(gc);
+ E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
+ while (gc->clients) e_object_del(E_OBJECT(gc->clients->data));
+}
+
+EAPI void
+e_gadcon_populate_class(E_Gadcon *gc, E_Gadcon_Client_Class *cc)
+{
+ Evas_List *l;
+ int ok;
+ E_Config_Gadcon *cf_gc;
+ E_Config_Gadcon_Client *cf_gcc;
+
+ E_OBJECT_CHECK(gc);
+ E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
+ ok = 0;
+ e_gadcon_layout_freeze(gc->o_container);
+ for (l = e_config->gadcons; l; l = l->next)
+ {
+ cf_gc = l->data;
+ if ((!strcmp(cf_gc->name, gc->name)) &&
+ (!strcmp(cf_gc->id, gc->id)))
+ {
+ ok = 1;
+ break;
+ }
+ }
+ if (ok)
+ {
+ for (l = cf_gc->clients; l; l = l->next)
+ {
+ cf_gcc = l->data;
+ if (!strcmp(cf_gcc->name, cc->name))
+ {
+ E_Gadcon_Client *gcc;
+
+ gcc = cc->func.init(gc, cf_gcc->name, cf_gcc->id,
+ cf_gcc->style);
+ if (gcc)
+ {
+ gcc->client_class = cc;
+ gcc->config.pos = cf_gcc->geom.pos;
+ gcc->config.size = cf_gcc->geom.size;
+ gcc->config.res = cf_gcc->geom.res;
+ if (gcc->o_frame)
+ e_gadcon_layout_pack_options_set(gcc->o_frame,
+ gcc->config.pos,
+ gcc->config.size,
+ gcc->config.res);
+ else
+ e_gadcon_layout_pack_options_set(gcc->o_base,
+ gcc->config.pos,
+ gcc->config.size,
+ gcc->config.res);
+ if (gcc->client_class->func.orient)
+ gcc->client_class->func.orient(gcc);
}
}
}
@@ -280,8 +330,32 @@ e_gadcon_orient(E_Gadcon *gc, E_Gadcon_Orient orient)
E_Gadcon_Client *gcc;
gcc = l->data;
- if (gcc->client_class.func.orient)
- gcc->client_class.func.orient(gcc);
+ if (gcc->client_class->func.orient)
+ gcc->client_class->func.orient(gcc);
+ switch (gcc->gadcon->orient)
+ {
+ case E_GADCON_ORIENT_FLOAT:
+ case E_GADCON_ORIENT_HORIZ:
+ case E_GADCON_ORIENT_TOP:
+ case E_GADCON_ORIENT_BOTTOM:
+ case E_GADCON_ORIENT_CORNER_TL:
+ case E_GADCON_ORIENT_CORNER_TR:
+ case E_GADCON_ORIENT_CORNER_BL:
+ case E_GADCON_ORIENT_CORNER_BR:
+ e_box_orientation_set(gcc->o_box, 1);
+ break;
+ case E_GADCON_ORIENT_VERT:
+ case E_GADCON_ORIENT_LEFT:
+ case E_GADCON_ORIENT_RIGHT:
+ case E_GADCON_ORIENT_CORNER_LT:
+ case E_GADCON_ORIENT_CORNER_RT:
+ case E_GADCON_ORIENT_CORNER_LB:
+ case E_GADCON_ORIENT_CORNER_RB:
+ e_box_orientation_set(gcc->o_box, 0);
+ break;
+ default:
+ break;
+ }
}
e_gadcon_layout_thaw(gc->o_container);
}
@@ -409,9 +483,50 @@ e_gadcon_client_new(E_Gadcon *gc, char *name, char *id, char *style, Evas_Object
style);
if (gcc->o_frame)
{
+ gcc->inset = 1;
edje_object_size_min_calc(gcc->o_frame,
&(gcc->pad.w), &(gcc->pad.h));
- edje_object_part_swallow(gcc->o_frame, "items", gcc->o_base);
+ gcc->o_box = e_box_add(gcc->gadcon->evas);
+ switch (gcc->gadcon->orient)
+ {
+ case E_GADCON_ORIENT_FLOAT:
+ case E_GADCON_ORIENT_HORIZ:
+ case E_GADCON_ORIENT_TOP:
+ case E_GADCON_ORIENT_BOTTOM:
+ case E_GADCON_ORIENT_CORNER_TL:
+ case E_GADCON_ORIENT_CORNER_TR:
+ case E_GADCON_ORIENT_CORNER_BL:
+ case E_GADCON_ORIENT_CORNER_BR:
+ e_box_orientation_set(gcc->o_box, 1);
+ break;
+ case E_GADCON_ORIENT_VERT:
+ case E_GADCON_ORIENT_LEFT:
+ case E_GADCON_ORIENT_RIGHT:
+ case E_GADCON_ORIENT_CORNER_LT:
+ case E_GADCON_ORIENT_CORNER_RT:
+ case E_GADCON_ORIENT_CORNER_LB:
+ case E_GADCON_ORIENT_CORNER_RB:
+ e_box_orientation_set(gcc->o_box, 0);
+ break;
+ default:
+ break;
+ }
+ evas_object_event_callback_add(gcc->o_box, EVAS_CALLBACK_MOVE,
+ _e_gadcon_cb_client_frame_moveresize, gcc);
+ evas_object_event_callback_add(gcc->o_box, EVAS_CALLBACK_RESIZE,
+ _e_gadcon_cb_client_frame_moveresize, gcc);
+ evas_object_event_callback_add(gcc->o_frame, EVAS_CALLBACK_MOUSE_MOVE,
+ _e_gadcon_cb_client_frame_mouse_move, gcc);
+ e_box_pack_end(gcc->o_box, gcc->o_base);
+ e_box_pack_options_set(gcc->o_base,
+ 1, 1, /* fill */
+ 1, 1, /* expand */
+ 0.5, 0.5, /* align */
+ 0, 0, /* min */
+ -1, -1 /* max */
+ );
+ edje_object_part_swallow(gcc->o_frame, "items", gcc->o_box);
+ evas_object_show(gcc->o_box);
evas_object_show(gcc->o_frame);
}
}
@@ -444,8 +559,18 @@ e_gadcon_client_edit_begin(E_Gadcon_Client *gcc)
e_theme_edje_object_set(gcc->o_control, "base/theme/gadman",
"gadman/control");
- edje_object_signal_emit(gcc->o_control, "hsize", "off");
- edje_object_signal_emit(gcc->o_control, "vsize", "off");
+ if ((gcc->autoscroll) || (gcc->resizable))
+ {
+ if (e_box_orientation_get(gcc->o_box))
+ edje_object_signal_emit(gcc->o_control, "hsize", "on");
+ else
+ edje_object_signal_emit(gcc->o_control, "vsize", "on");
+ }
+ else
+ {
+ edje_object_signal_emit(gcc->o_control, "hsize", "off");
+ edje_object_signal_emit(gcc->o_control, "vsize", "off");
+ }
edje_object_signal_emit(gcc->o_control, "move", "on");
gcc->o_event = evas_object_rectangle_add(gcc->gadcon->evas);
@@ -474,17 +599,17 @@ e_gadcon_client_edit_begin(E_Gadcon_Client *gcc)
edje_object_signal_callback_add(gcc->o_control, "resize_go", "right",
_e_gadcon_cb_signal_resize_right_go, gcc);
edje_object_signal_callback_add(gcc->o_control, "resize_start", "up",
- _e_gadcon_cb_signal_resize_up_start, gcc);
+ _e_gadcon_cb_signal_resize_left_start, gcc);
edje_object_signal_callback_add(gcc->o_control, "resize_stop", "up",
- _e_gadcon_cb_signal_resize_up_stop, gcc);
+ _e_gadcon_cb_signal_resize_left_stop, gcc);
edje_object_signal_callback_add(gcc->o_control, "resize_go", "up",
- _e_gadcon_cb_signal_resize_up_go, gcc);
+ _e_gadcon_cb_signal_resize_left_go, gcc);
edje_object_signal_callback_add(gcc->o_control, "resize_start", "down",
- _e_gadcon_cb_signal_resize_down_start, gcc);
+ _e_gadcon_cb_signal_resize_right_start, gcc);
edje_object_signal_callback_add(gcc->o_control, "resize_stop", "down",
- _e_gadcon_cb_signal_resize_down_stop, gcc);
+ _e_gadcon_cb_signal_resize_right_stop, gcc);
edje_object_signal_callback_add(gcc->o_control, "resize_go", "down",
- _e_gadcon_cb_signal_resize_down_go, gcc);
+ _e_gadcon_cb_signal_resize_right_go, gcc);
evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_DOWN, _e_gadcon_cb_mouse_down, gcc);
evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_UP, _e_gadcon_cb_mouse_up, gcc);
@@ -576,10 +701,16 @@ e_gadcon_client_min_size_set(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h)
{
E_OBJECT_CHECK(gcc);
E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
- if (gcc->o_frame)
- e_gadcon_layout_pack_min_size_set(gcc->o_frame, w + gcc->pad.w, h + gcc->pad.h);
- else
- e_gadcon_layout_pack_min_size_set(gcc->o_base, w, h);
+ gcc->min.w = w;
+ gcc->min.h = h;
+ if ((!gcc->autoscroll) && (!gcc->resizable))
+ {
+ if (gcc->o_frame)
+ e_gadcon_layout_pack_min_size_set(gcc->o_frame, w + gcc->pad.w, h + gcc->pad.h);
+ else
+ e_gadcon_layout_pack_min_size_set(gcc->o_base, w, h);
+ }
+ _e_gadcon_movereisze_handle(gcc);
}
EAPI void
@@ -587,19 +718,228 @@ e_gadcon_client_aspect_set(E_Gadcon_Client *gcc, int w, int h)
{
E_OBJECT_CHECK(gcc);
E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
- if (gcc->o_frame)
+ gcc->aspect.w = w;
+ gcc->aspect.h = h;
+ if ((!gcc->autoscroll) && (!gcc->resizable))
+ {
+ if (gcc->o_frame)
+ {
+ e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_frame, w, h);
+ }
+ else
+ e_gadcon_layout_pack_aspect_set(gcc->o_base, w, h);
+ }
+ _e_gadcon_movereisze_handle(gcc);
+}
+
+EAPI void
+e_gadcon_client_autoscroll_set(E_Gadcon_Client *gcc, int autoscroll)
+{
+ E_OBJECT_CHECK(gcc);
+ E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
+
+ gcc->autoscroll = autoscroll;
+ if (gcc->autoscroll)
+ {
+ if (gcc->o_frame)
+ {
+ e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_frame, 0, 0);
+ e_gadcon_layout_pack_min_size_set(gcc->o_frame, 0, 0);
+ }
+ else
+ {
+ e_gadcon_layout_pack_min_size_set(gcc->o_base, 0, 0);
+ e_gadcon_layout_pack_aspect_set(gcc->o_base, 0, 0);
+ }
+ }
+ else
+ {
+ if (gcc->o_frame)
+ {
+ e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_frame, gcc->aspect.w, gcc->aspect.h);
+ e_gadcon_layout_pack_min_size_set(gcc->o_frame, gcc->min.w, gcc->min.h);
+ }
+ else
+ {
+ e_gadcon_layout_pack_min_size_set(gcc->o_base, gcc->min.w, gcc->min.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_base, gcc->aspect.w, gcc->aspect.h);
+ }
+ }
+}
+
+EAPI void
+e_gadcon_client_resizable_set(E_Gadcon_Client *gcc, int resizable)
+{
+ E_OBJECT_CHECK(gcc);
+ E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
+
+ gcc->resizable = resizable;
+ if (gcc->resizable)
{
- e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
- e_gadcon_layout_pack_aspect_set(gcc->o_frame, w, h);
+ if (gcc->o_frame)
+ {
+ e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_frame, 0, 0);
+ e_gadcon_layout_pack_min_size_set(gcc->o_frame, 0, 0);
+ }
+ else
+ {
+ e_gadcon_layout_pack_min_size_set(gcc->o_base, 0, 0);
+ e_gadcon_layout_pack_aspect_set(gcc->o_base, 0, 0);
+ }
}
else
- e_gadcon_layout_pack_aspect_set(gcc->o_base, w, h);
+ {
+ if (gcc->o_frame)
+ {
+ e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_frame, gcc->aspect.w, gcc->aspect.h);
+ e_gadcon_layout_pack_min_size_set(gcc->o_frame, gcc->min.w, gcc->min.h);
+ }
+ else
+ {
+ e_gadcon_layout_pack_min_size_set(gcc->o_base, gcc->min.w, gcc->min.h);
+ e_gadcon_layout_pack_aspect_set(gcc->o_base, gcc->aspect.w, gcc->aspect.h);
+ }
+ }
+}
+
+static void
+_e_gadcon_client_cb_menu_inset(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ E_Gadcon_Client *gcc;
+ E_Gadcon *gc;
+
+ gcc = data;
+ gc = gcc->gadcon;
+ if (gcc->inset) gcc->inset = 0;
+ else gcc->inset = 1;
+ _e_gadcon_client_save(gcc);
+ e_gadcon_unpopulate(gc);
+ e_gadcon_populate(gc);
+}
+
+static void
+_e_gadcon_client_cb_menu_autoscroll(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ E_Gadcon_Client *gcc;
+ E_Gadcon *gc;
+
+ gcc = data;
+ gc = gcc->gadcon;
+ if (gcc->autoscroll) gcc->autoscroll = 0;
+ else gcc->autoscroll = 1;
+ _e_gadcon_client_save(gcc);
+ e_gadcon_unpopulate(gc);
+ e_gadcon_populate(gc);
+}
+
+static void
+_e_gadcon_client_cb_menu_resizable(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ E_Gadcon_Client *gcc;
+ E_Gadcon *gc;
+
+ gcc = data;
+ gc = gcc->gadcon;
+ if (gcc->resizable) gcc->resizable = 0;
+ else gcc->resizable = 1;
+ _e_gadcon_client_save(gcc);
+ e_gadcon_unpopulate(gc);
+ e_gadcon_populate(gc);
+}
+
+EAPI void
+e_gadcon_client_util_menu_items_append(E_Gadcon_Client *gcc, E_Menu *menu, int flags)
+{
+ E_Menu_Item *mi;
+
+ E_OBJECT_CHECK(gcc);
+ E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
+
+ mi = e_menu_item_new(menu);
+ e_menu_item_label_set(mi, _("Inset appearance"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/inset");
+ e_menu_item_check_set(mi, 1);
+ if (gcc->o_frame) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _e_gadcon_client_cb_menu_inset, gcc);
+
+ mi = e_menu_item_new(menu);
+ e_menu_item_label_set(mi, _("Automatically scroll contents"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/autoscroll");
+ e_menu_item_check_set(mi, 1);
+ if (gcc->autoscroll) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _e_gadcon_client_cb_menu_autoscroll, gcc);
+
+ mi = e_menu_item_new(menu);
+ e_menu_item_label_set(mi, _("Able to be resized"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/resizable");
+ e_menu_item_check_set(mi, 1);
+ if (gcc->resizable) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _e_gadcon_client_cb_menu_resizable, gcc);
+}
+
+static void
+_e_gadcon_client_cb_menu_post(void *data, E_Menu *m)
+{
+ E_Gadcon_Client *gcc;
+
+ gcc = data;
+ if (!gcc->menu) return;
+ e_object_del(E_OBJECT(gcc->menu));
+ gcc->menu = NULL;
+}
+
+static void
+_e_gadcon_client_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Down *ev;
+ E_Gadcon_Client *gcc;
+
+ ev = event_info;
+ gcc = data;
+ if (gcc->menu) return;
+ if (ev->button == 3)
+ {
+ E_Menu *mn;
+ int cx, cy, cw, ch;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _e_gadcon_client_cb_menu_post,
+ gcc);
+ gcc->menu = mn;
+
+ e_gadcon_client_util_menu_items_append(gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &cx, &cy, &cw, &ch);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ cx + ev->output.x, cy + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ }
+}
+
+EAPI void
+e_gadcon_client_util_menu_attach(E_Gadcon_Client *gcc)
+{
+ E_OBJECT_CHECK(gcc);
+ E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
+ if (gcc->o_frame)
+ evas_object_event_callback_add(gcc->o_frame, EVAS_CALLBACK_MOUSE_DOWN, _e_gadcon_client_cb_mouse_down, gcc);
+ else
+ evas_object_event_callback_add(gcc->o_base, EVAS_CALLBACK_MOUSE_DOWN, _e_gadcon_client_cb_mouse_down, gcc);
}
/* local subsystem functions */
static void
_e_gadcon_free(E_Gadcon *gc)
{
+ e_gadcon_unpopulate(gc);
gadcons = evas_list_remove(gadcons, gc);
if (gc->o_container) evas_object_del(gc->o_container);
evas_stringshare_del(gc->name);
@@ -611,15 +951,139 @@ _e_gadcon_free(E_Gadcon *gc)
static void
_e_gadcon_client_free(E_Gadcon_Client *gcc)
{
+ if (gcc->menu)
+ {
+ e_object_del(E_OBJECT(gcc->menu));
+ gcc->menu = NULL;
+ }
e_gadcon_client_edit_end(gcc);
+ gcc->client_class->func.shutdown(gcc);
gcc->gadcon->clients = evas_list_remove(gcc->gadcon->clients, gcc);
+ if (gcc->o_box) evas_object_del(gcc->o_box);
if (gcc->o_frame) evas_object_del(gcc->o_frame);
evas_stringshare_del(gcc->name);
evas_stringshare_del(gcc->id);
+ if (gcc->scroll_timer) ecore_timer_del(gcc->scroll_timer);
+ if (gcc->scroll_animator) ecore_animator_del(gcc->scroll_animator);
free(gcc);
}
static void
+_e_gadcon_movereisze_handle(E_Gadcon_Client *gcc)
+{
+ Evas_Coord x, y, w, h;
+
+ evas_object_geometry_get(gcc->o_box, &x, &y, &w, &h);
+ if ((gcc->autoscroll) || (gcc->resizable))
+ {
+ if (e_box_orientation_get(gcc->o_box))
+ {
+ if ((gcc->aspect.w > 0) && (gcc->aspect.h > 0))
+ w = (h * gcc->aspect.w) / gcc->aspect.h;
+ else
+ w = gcc->min.w;
+ }
+ else
+ {
+ if ((gcc->aspect.w > 0) && (gcc->aspect.h > 0))
+ h = (w * gcc->aspect.h) / gcc->aspect.w;
+ else
+ h = gcc->min.h;
+ }
+ }
+ e_box_pack_options_set(gcc->o_base,
+ 1, 1, /* fill */
+ 1, 1, /* expand */
+ 0.5, 0.5, /* align */
+ w, h, /* min */
+ w, h /* max */
+ );
+}
+
+static int
+_e_gadcon_cb_client_scroll_timer(void *data)
+{
+ E_Gadcon_Client *gcc;
+ double d, v;
+
+ gcc = data;
+ d = gcc->scroll_wanted - gcc->scroll_pos;
+ if (d < 0) d = -d;
+ if (d < 0.001)
+ {
+ gcc->scroll_pos = gcc->scroll_wanted;
+ gcc->scroll_timer = NULL;
+ return 0;
+ }
+ v = 0.05;
+ gcc->scroll_pos = (gcc->scroll_pos * (1.0 - v)) + (gcc->scroll_wanted * v);
+ return 1;
+}
+
+static int
+_e_gadcon_cb_client_scroll_animator(void *data)
+{
+ E_Gadcon_Client *gcc;
+
+ gcc = data;
+ if (e_box_orientation_get(gcc->o_box))
+ e_box_align_set(gcc->o_box, 1.0 - gcc->scroll_pos, 0.5);
+ else
+ e_box_align_set(gcc->o_box, 0.5, 1.0 - gcc->scroll_pos);
+ if (!gcc->scroll_timer)
+ {
+ gcc->scroll_animator = NULL;
+ return 0;
+ }
+ return 1;
+}
+
+static void
+_e_gadcon_cb_client_frame_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Move *ev;
+ E_Gadcon_Client *gcc;
+ Evas_Coord x, y, w, h;
+
+ ev = event_info;
+ gcc = data;
+ if (gcc->autoscroll)
+ {
+ double d;
+
+ evas_object_geometry_get(gcc->o_box, &x, &y, &w, &h);
+ x = ev->cur.output.x - x;
+ y = ev->cur.output.y - y;
+ if (e_box_orientation_get(gcc->o_box))
+ {
+ if (w > 1) d = (double)x / (double)(w - 1);
+ else d = 0;
+ }
+ else
+ {
+ if (h > 1) d = (double)y / (double)(h - 1);
+ else d = 0;
+ }
+ if (d < 0.0) d = 0.0;
+ else if (d > 1.0) d = 1.0;
+ if (!gcc->scroll_timer)
+ gcc->scroll_timer = ecore_timer_add(0.01, _e_gadcon_cb_client_scroll_timer, gcc);
+ if (!gcc->scroll_animator)
+ gcc->scroll_animator = ecore_animator_add(_e_gadcon_cb_client_scroll_animator, gcc);
+ gcc->scroll_wanted = d;
+ }
+}
+
+static void
+_e_gadcon_cb_client_frame_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ E_Gadcon_Client *gcc;
+
+ gcc = data;
+ _e_gadcon_movereisze_handle(gcc);
+}
+
+static void
_e_gadcon_client_save(E_Gadcon_Client *gcc)
{
Evas_List *l, *l2;
@@ -645,6 +1109,12 @@ _e_gadcon_client_save(E_Gadcon_Client *gcc)
cf_gcc->geom.pos = gcc->config.pos;
cf_gcc->geom.size = gcc->config.size;
cf_gcc->geom.res = gcc->config.res;
+ cf_gcc->autoscroll = gcc->autoscroll;
+ if (cf_gcc->style) evas_stringshare_del(cf_gcc->style);
+ cf_gcc->style = NULL;
+ if (gcc->inset)
+ cf_gcc->style = evas_stringshare_add("inset");
+ cf_gcc->resizable = gcc->resizable;
ok++;
break;
}
@@ -668,6 +1138,12 @@ _e_gadcon_client_save(E_Gadcon_Client *gcc)
cf_gcc->geom.pos = gcc->config.pos;
cf_gcc->geom.size = gcc->config.size;
cf_gcc->geom.res = gcc->config.res;
+ cf_gcc->autoscroll = gcc->autoscroll;
+ if (cf_gcc->style) evas_stringshare_del(cf_gcc->style);
+ cf_gcc->style = NULL;
+ if (gcc->inset)
+ cf_gcc->style = evas_stringshare_add("inset");
+ cf_gcc->resizable = gcc->resizable;
cf_gc->clients = evas_list_append(cf_gc->clients, cf_gcc);
ok++;
}
@@ -675,6 +1151,21 @@ _e_gadcon_client_save(E_Gadcon_Client *gcc)
}
static void
+_e_gadcon_cb_min_size_request(void *data, Evas_Object *obj, void *event_info)
+{
+ E_Gadcon *gc;
+
+ gc = data;
+ if (gc->min_size_request.func)
+ {
+ Evas_Coord w, h;
+
+ e_gadcon_layout_min_size_get(gc->o_container, &w, &h);
+ gc->min_size_request.func(gc->min_size_request.data, gc, w, h);
+ }
+}
+
+static void
_e_gadcon_cb_size_request(void *data, Evas_Object *obj, void *event_info)
{
E_Gadcon *gc;
@@ -683,8 +1174,9 @@ _e_gadcon_cb_size_request(void *data, Evas_Object *obj, void *event_info)
if (gc->resize_request.func)
{
Evas_Coord w, h;
+
+ e_gadcon_layout_asked_size_get(gc->o_container, &w, &h);
- e_gadcon_layout_min_size_get(gc->o_container, &w, &h);
gc->resize_request.func(gc->resize_request.data, gc, w, h);
}
}
@@ -771,7 +1263,10 @@ _e_gadcon_cb_signal_move_start(void *data, Evas_Object *obj, const char *emissio
gcc->moving = 1;
evas_pointer_canvas_xy_get(gcc->gadcon->evas, &gcc->dx, &gcc->dy);
evas_object_geometry_get(gcc->gadcon->o_container, &x, &y, NULL, NULL);
- evas_object_geometry_get(gcc->o_base, &gcc->sx, &gcc->sy, NULL, NULL);
+ if (gcc->o_frame)
+ evas_object_geometry_get(gcc->o_frame, &gcc->sx, &gcc->sy, NULL, NULL);
+ else
+ evas_object_geometry_get(gcc->o_base, &gcc->sx, &gcc->sy, NULL, NULL);
gcc->sx -= x;
gcc->sy -= y;
}
@@ -826,99 +1321,130 @@ _e_gadcon_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
}
static void
-_e_gadcon_cb_signal_resize_left_start(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- E_Gadcon_Client *gcc;
-
- gcc = data;
-}
-
-static void
-_e_gadcon_cb_signal_resize_left_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- E_Gadcon_Client *gcc;
-
- gcc = data;
-}
-
-static void
-_e_gadcon_cb_signal_resize_left_go(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- E_Gadcon_Client *gcc;
-
- gcc = data;
-}
-
-static void
-_e_gadcon_cb_signal_resize_right_start(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- E_Gadcon_Client *gcc;
-
- gcc = data;
-}
-
-static void
-_e_gadcon_cb_signal_resize_right_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_client_resize_start(E_Gadcon_Client *gcc)
{
- E_Gadcon_Client *gcc;
+ Evas_Coord x, y;
- gcc = data;
+ evas_object_raise(gcc->o_event);
+ evas_object_stack_below(gcc->o_control, gcc->o_event);
+ gcc->resizing = 1;
+ evas_pointer_canvas_xy_get(gcc->gadcon->evas, &gcc->dx, &gcc->dy);
+ evas_object_geometry_get(gcc->gadcon->o_container, &x, &y, NULL, NULL);
+ if (gcc->o_frame)
+ evas_object_geometry_get(gcc->o_frame, &gcc->sx, &gcc->sy, &gcc->sw, &gcc->sh);
+ else
+ evas_object_geometry_get(gcc->o_base, &gcc->sx, &gcc->sy, &gcc->sw, &gcc->sh);
+ gcc->sx -= x;
+ gcc->sy -= y;
}
static void
-_e_gadcon_cb_signal_resize_right_go(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadconclient_resize_stop(E_Gadcon_Client *gcc)
{
- E_Gadcon_Client *gcc;
-
- gcc = data;
+ gcc->resizing = 0;
+ _e_gadcon_client_save(gcc);
}
static void
-_e_gadcon_cb_signal_resize_up_start(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_cb_signal_resize_left_start(void *data, Evas_Object *obj, const char *emission, const char *source)
{
- E_Gadcon_Client *gcc;
-
- gcc = data;
+ _e_gadcon_client_resize_start(data);
}
static void
-_e_gadcon_cb_signal_resize_up_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_cb_signal_resize_left_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
{
- E_Gadcon_Client *gcc;
-
- gcc = data;
+ _e_gadconclient_resize_stop(data);
}
static void
-_e_gadcon_cb_signal_resize_up_go(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_cb_signal_resize_left_go(void *data, Evas_Object *obj, const char *emission, const char *source)
{
E_Gadcon_Client *gcc;
+ Evas_Coord x, y, w, h;
gcc = data;
+ if (!gcc->resizing) return;
+ evas_pointer_canvas_xy_get(gcc->gadcon->evas, &x, &y);
+ x = x - gcc->dx;
+ y = y - gcc->dy;
+ if (gcc->o_frame)
+ evas_object_geometry_get(gcc->o_frame, NULL, NULL, &w, &h);
+ else
+ evas_object_geometry_get(gcc->o_base, NULL, NULL, &w, &h);
+ if (e_gadcon_layout_orientation_get(gcc->gadcon->o_container))
+ {
+ if (gcc->o_frame)
+ e_gadcon_layout_pack_request_set(gcc->o_frame, gcc->sx + x, gcc->sw - x);
+ else
+ e_gadcon_layout_pack_request_set(gcc->o_base, gcc->sx + x, gcc->sw - x);
+ gcc->config.pos = gcc->sx + x;
+ gcc->config.size = gcc->sw - x;
+ evas_object_geometry_get(gcc->gadcon->o_container, NULL, NULL, &w, &h);
+ gcc->config.res = w;
+ }
+ else
+ {
+ if (gcc->o_frame)
+ e_gadcon_layout_pack_request_set(gcc->o_frame, gcc->sy + y, gcc->sh - y);
+ else
+ e_gadcon_layout_pack_request_set(gcc->o_base, gcc->sy + y, gcc->sh - y);
+ gcc->config.pos = gcc->sy + y;
+ gcc->config.size = gcc->sh - y;
+ evas_object_geometry_get(gcc->gadcon->o_container, NULL, NULL, &w, &h);
+ gcc->config.res = h;
+ }
}
static void
-_e_gadcon_cb_signal_resize_down_start(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_cb_signal_resize_right_start(void *data, Evas_Object *obj, const char *emission, const char *source)
{
- E_Gadcon_Client *gcc;
-
- gcc = data;
+ _e_gadcon_client_resize_start(data);
}
static void
-_e_gadcon_cb_signal_resize_down_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_cb_signal_resize_right_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
{
- E_Gadcon_Client *gcc;
-
- gcc = data;
+ _e_gadconclient_resize_stop(data);
}
static void
-_e_gadcon_cb_signal_resize_down_go(void *data, Evas_Object *obj, const char *emission, const char *source)
+_e_gadcon_cb_signal_resize_right_go(void *data, Evas_Object *obj, const char *emission, const char *source)
{
E_Gadcon_Client *gcc;
+ Evas_Coord x, y, w, h;
gcc = data;
+ if (!gcc->resizing) return;
+ evas_pointer_canvas_xy_get(gcc->gadcon->evas, &x, &y);
+ x = x - gcc->dx;
+ y = y - gcc->dy;
+ if (gcc->o_frame)
+ evas_object_geometry_get(gcc->o_frame, NULL, NULL, &w, &h);
+ else
+ evas_object_geometry_get(gcc->o_base, NULL, NULL, &w, &h);
+ if (e_gadcon_layout_orientation_get(gcc->gadcon->o_container))
+ {
+ if (gcc->o_frame)
+ e_gadcon_layout_pack_request_set(gcc->o_frame, gcc->sx, gcc->sw + x);
+ else
+ e_gadcon_layout_pack_request_set(gcc->o_base, gcc->sx, gcc->sw + x);
+ gcc->config.pos = gcc->sx;
+ gcc->config.size = gcc->sw + x;
+ evas_object_geometry_get(gcc->gadcon->o_container, NULL, NULL, &w, &h);
+ gcc->config.res = w;
+ }
+ else
+ {
+ if (gcc->o_frame)
+ e_gadcon_layout_pack_request_set(gcc->o_frame, gcc->sy, gcc->sh + y);
+ else
+ e_gadcon_layout_pack_request_set(gcc->o_base, gcc->sy, gcc->sh + y);
+ gcc->config.pos = gcc->sy;
+ gcc->config.size = gcc->sh + y;
+ evas_object_geometry_get(gcc->gadcon->o_container, NULL, NULL, &w, &h);
+ gcc->config.res = h;
+ }
}
@@ -940,7 +1466,7 @@ struct _E_Smart_Data
unsigned char redo_config : 1;
Evas_List *items;
int frozen;
- Evas_Coord minw, minh;
+ Evas_Coord minw, minh, req;
};
struct _E_Gadcon_Layout_Item
@@ -1077,6 +1603,11 @@ e_gadcon_layout_asked_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
+ if (sd->horizontal)
+ tw = sd->req;
+ else
+ th = sd->req;
+/*
for (l = sd->items; l; l = l->next)
{
E_Gadcon_Layout_Item *bi;
@@ -1093,6 +1624,7 @@ e_gadcon_layout_asked_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
th += bi->ask.size;
}
}
+ */
if (w) *w = tw;
if (h) *h = th;
}
@@ -1338,14 +1870,9 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
return;
}
- x = sd->x;
- y = sd->y;
- w = sd->w;
- h = sd->h;
-
- min = 0;
- mino = 0;
- cur = 0;
+ x = sd->x; y = sd->y; w = sd->w; h = sd->h;
+ min = mino = cur = 0;
+
for (l = sd->items; l; l = l->next)
{
E_Gadcon_Layout_Item *bi;
@@ -1353,17 +1880,6 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
- cur += bi->ask.size;
- if (sd->horizontal)
- {
- min += bi->min.w;
- if (bi->min.h > mino) mino = bi->min.h;
- }
- else
- {
- min += bi->min.h;
- if (bi->min.w > mino) mino = bi->min.w;
- }
bi->ask.size2 = bi->ask.size;
if ((bi->aspect.w > 0) && (bi->aspect.h > 0))
{
@@ -1372,20 +1888,60 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
bi->ask.size2 = (((h - bi->aspect_pad.h) * bi->aspect.w) /
bi->aspect.h) + bi->aspect_pad.w;
if (bi->ask.size2 > bi->min.w)
- min += (bi->ask.size2 - bi->min.w);
+ {
+ min += bi->ask.size2;
+ cur += bi->ask.size2;
+ }
+ else
+ {
+ cur += bi->min.w;
+ min += bi->min.w;
+ }
}
else
{
bi->ask.size2 = (((w - bi->aspect_pad.w) * bi->aspect.h) /
bi->aspect.w) + bi->aspect_pad.h;
if (bi->ask.size2 > bi->min.h)
- min += (bi->ask.size2 - bi->min.h);
+ {
+ min += bi->ask.size2;
+ cur += bi->ask.size2;
+ }
+ else
+ {
+ cur += bi->min.h;
+ min += bi->min.h;
+ }
+ }
+ }
+ else
+ {
+ if (sd->horizontal)
+ {
+ min += bi->min.w;
+ if (bi->min.h > mino) mino = bi->min.h;
+ if (bi->ask.size < bi->min.w)
+ cur += bi->min.w;
+ else
+ cur += bi->ask.size;
+ }
+ else
+ {
+ min += bi->min.h;
+ if (bi->min.w > mino) mino = bi->min.w;
+ if (bi->ask.size < bi->min.h)
+ cur += bi->min.h;
+ else
+ cur += bi->ask.size;
}
}
}
+
+ printf("CUR = %i | %i %i\n", cur, min, mino);
+
if (sd->horizontal)
{
- if (cur < w)
+ if (cur <= w)
{
/* all is fine - it should all fit */
}
@@ -1396,6 +1952,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
sub = cur - w; /* we need to find "sub" extra pixels */
if (min <= w)
{
+ printf("blum\n");
for (l = sd->items; l; l = l->next)
{
E_Gadcon_Layout_Item *bi;
@@ -1407,11 +1964,13 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
if (give < sub) give = sub;
bi->ask.size2 = bi->ask.size - give;
sub -= give;
+ printf("GIVE: %i\n", give);
if (sub <= 0) break;
}
}
else
{ /* EEK - all items just cant fit at their minimum! what do we do? */
+ printf("EEK - nofit!\n");
num = 0;
num = evas_list_count(sd->items);
give = min - w; // how much give total below minw we need
@@ -1781,19 +2340,28 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
}
if (sd->horizontal)
{
- if ((sd->minw < min) || (sd->minh < mino))
+ if ((sd->minw != min) || (sd->minh != mino))
{
sd->minw = min;
sd->minh = mino;
- evas_object_smart_callback_call(sd->obj, "size_request", NULL);
+ evas_object_smart_callback_call(sd->obj, "min_size_request", NULL);
}
}
else
{
- if ((sd->minh < min) || (sd->minw < mino))
+ if ((sd->minh != min) || (sd->minw != mino))
{
sd->minw = mino;
sd->minh = min;
+ evas_object_smart_callback_call(sd->obj, "min_size_request", NULL);
+ }
+ }
+ if (sd->req != cur)
+ {
+ if (((sd->horizontal) && (cur >= sd->minw)) ||
+ ((!sd->horizontal) && (cur >= sd->minh)))
+ {
+ sd->req = cur;
evas_object_smart_callback_call(sd->obj, "size_request", NULL);
}
}
diff --git a/src/bin/e_gadcon.h b/src/bin/e_gadcon.h
index 86c477785..ea6ffb11e 100644
--- a/src/bin/e_gadcon.h
+++ b/src/bin/e_gadcon.h
@@ -65,7 +65,7 @@ struct _E_Gadcon
struct {
void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
void *data;
- } resize_request;
+ } resize_request, min_size_request;
struct {
Evas_Object *(*func) (void *data, E_Gadcon_Client *gcc, const char *style);
void *data;
@@ -91,20 +91,30 @@ struct _E_Gadcon_Client
char *name;
char *id;
Evas_Object *o_base;
+ Evas_Object *o_box;
Evas_Object *o_frame;
Evas_Object *o_control;
Evas_Object *o_event;
- E_Gadcon_Client_Class client_class;
+ E_Gadcon_Client_Class *client_class;
void *data;
struct {
int pos, size, res;
} config;
struct {
Evas_Coord w, h;
- } pad;
+ } pad, min, aspect;
+ unsigned char inset : 1;
+ unsigned char autoscroll : 1;
+ unsigned char resizable : 1;
+ Ecore_Timer *scroll_timer;
+ Ecore_Animator *scroll_animator;
+ double scroll_pos;
+ double scroll_wanted;
+ E_Menu *menu;
unsigned char moving : 1;
- Evas_Coord dx, dy, sx, sy;
+ unsigned char resizing : 1;
+ Evas_Coord dx, dy, sx, sy, sw, sh;
};
EAPI int e_gadcon_init(void);
@@ -113,10 +123,13 @@ EAPI void e_gadcon_provider_register(E_Gadcon_Client_Class *cc);
EAPI void e_gadcon_provider_unregister(E_Gadcon_Client_Class *cc);
EAPI E_Gadcon *e_gadcon_swallowed_new(const char *name, char *id, Evas_Object *obj, char *swallow_name);
EAPI void e_gadcon_swallowed_min_size_set(E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
+EAPI void e_gadcon_min_size_request_callback_set(E_Gadcon *gc, void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data);
EAPI void e_gadcon_size_request_callback_set(E_Gadcon *gc, void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data);
EAPI void e_gadcon_frame_request_callback_set(E_Gadcon *gc, Evas_Object *(*func) (void *data, E_Gadcon_Client *gcc, const char *style), void *data);
EAPI void e_gadcon_layout_policy_set(E_Gadcon *gc, E_Gadcon_Layout_Policy layout_policy);
EAPI void e_gadcon_populate(E_Gadcon *gc);
+EAPI void e_gadcon_unpopulate(E_Gadcon *gc);
+EAPI void e_gadcon_populate_class(E_Gadcon *gc, E_Gadcon_Client_Class *cc);
EAPI void e_gadcon_orient(E_Gadcon *gc, E_Gadcon_Orient orient);
EAPI void e_gadcon_edit_begin(E_Gadcon *gc);
EAPI void e_gadcon_edit_end(E_Gadcon *gc);
@@ -128,11 +141,16 @@ EAPI void e_gadcon_ecore_evas_set(E_Gadcon *gc, Ecore_Evas *ee);
EAPI int e_gadcon_canvas_zone_geometry_get(E_Gadcon *gc, int *x, int *y, int *w, int *h);
EAPI E_Gadcon_Client *e_gadcon_client_new(E_Gadcon *gc, char *name, char *id, char *style, Evas_Object *base_obj);
+EAPI void e_gadcon_client_edit_begin(E_Gadcon_Client *gcc);
+EAPI void e_gadcon_client_edit_end(E_Gadcon_Client *gcc);
EAPI void e_gadcon_client_size_request(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h);
EAPI void e_gadcon_client_min_size_set(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h);
EAPI void e_gadcon_client_aspect_set(E_Gadcon_Client *gcc, int w, int h);
-EAPI void e_gadcon_client_edit_begin(E_Gadcon_Client *gcc);
-EAPI void e_gadcon_client_edit_end(E_Gadcon_Client *gcc);
-
+EAPI void e_gadcon_client_autoscroll_set(E_Gadcon_Client *gcc, int autoscroll);
+EAPI void e_gadcon_client_resizable_set(E_Gadcon_Client *gcc, int resizable);
+
+EAPI void e_gadcon_client_util_menu_items_append(E_Gadcon_Client *gcc, E_Menu *menu, int flags);
+EAPI void e_gadcon_client_util_menu_attach(E_Gadcon_Client *gcc);
+
#endif
#endif
diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h
index dafd26f26..052792de2 100644
--- a/src/bin/e_includes.h
+++ b/src/bin/e_includes.h
@@ -129,5 +129,6 @@
#include "e_gadcon.h"
#include "e_shelf.h"
#include "e_tlist.h"
+#include "e_widget_tlist.h"
#include "e_widget_preview.h"
#include "e_int_config_paths.h"
diff --git a/src/bin/e_main.c b/src/bin/e_main.c
index 57d0b1da5..a40c96a05 100644
--- a/src/bin/e_main.c
+++ b/src/bin/e_main.c
@@ -676,7 +676,8 @@ main(int argc, char **argv)
e_test();
/* FIXME: for testing only */
-// e_shelf_config_init();
+//
+ e_shelf_config_init();
/* no longer starting up */
starting = 0;
diff --git a/src/bin/e_place.c b/src/bin/e_place.c
index f2c9c9fce..1bf7da2d2 100644
--- a/src/bin/e_place.c
+++ b/src/bin/e_place.c
@@ -64,6 +64,83 @@ _e_place_cb_sort_cmp(const void *v1, const void *v2)
return (*((int *)v1)) - (*((int *)v2));
}
+static int
+_e_place_coverage_border_add(E_Zone *zone, Evas_List *skiplist, int ar, int x, int y, int w, int h)
+{
+ Evas_List *ll;
+ E_Border_List *bl;
+ E_Border *bd;
+ int x2, y2, w2, h2;
+ int ok;
+ int iw, ih;
+ int x0, x00, y0, y00;
+
+ bl = e_container_border_list_first(zone->container);
+ while ((bd = e_container_border_list_next(bl)))
+ {
+ ok = 1;
+ x2 = (bd->x - zone->x); y2 = (bd->y - zone->y); w2 = bd->w; h2 = bd->h;
+ for (ll = skiplist; ll; ll = ll->next)
+ {
+ if (ll->data == bd)
+ {
+ ok = 0;
+ break;
+ }
+ }
+ if ((ok) && (bd->visible) && E_INTERSECTS(x, y, w, h, x2, y2, w2, h2))
+ {
+ x0 = x;
+ if (x < x2) x0 = x2;
+ x00 = (x + w);
+ if ((x2 + w2) < (x + w)) x00 = (x2 + w2);
+ y0 = y;
+ if (y < y2) y0 = y2;
+ y00 = (y + h);
+ if ((y2 + h2) < (y + h)) y00 = (y2 + h2);
+ iw = x00 - x0;
+ ih = y00 - y0;
+ ar += (iw * ih);
+ }
+ }
+ e_container_border_list_free(bl);
+ return ar;
+}
+
+static int
+_e_place_coverage_shelf_add(E_Zone *zone, int ar, int x, int y, int w, int h)
+{
+ Evas_List *l;
+ E_Shelf *es;
+ int x2, y2, w2, h2;
+ int ok;
+ int iw, ih;
+ int x0, x00, y0, y00;
+
+ for (l = e_shelf_list(); l; l = l->next)
+ {
+
+ es = l->data;
+ if (es->zone != zone) continue;
+ x2 = es->x; y2 = es->y; w2 = es->w; h2 = es->h;
+ if (E_INTERSECTS(x, y, w, h, x2, y2, w2, h2))
+ {
+ x0 = x;
+ if (x < x2) x0 = x2;
+ x00 = (x + w);
+ if ((x2 + w2) < (x + w)) x00 = (x2 + w2);
+ y0 = y;
+ if (y < y2) y0 = y2;
+ y00 = (y + h);
+ if ((y2 + h2) < (y + h)) y00 = (y2 + h2);
+ iw = x00 - x0;
+ ih = y00 - y0;
+ ar += (iw * ih) * 100; /* 100 == 100 times more unlikely for overlap than a normal window */
+ }
+ }
+ return ar;
+}
+
EAPI int
e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry)
{
@@ -90,59 +167,9 @@ e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w
x -= zone->x;
y -= zone->y;
+ zw = zone->w;
+ zh = zone->h;
- if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_ANTIGADGET)
- {
- Evas_List *l;
- int cx1, cx2, cy1, cy2;
-
- cx1 = zone->x;
- cy1 = zone->y;
- cx2 = zone->x + zone->w;
- cy2 = zone->y + zone->h;
-
- /* Find the smallest box */
- for (l = zone->container->gadman->clients; l; l = l->next)
- {
- E_Gadman_Client *gmc;
- double ax, ay;
-
- gmc = l->data;
- if ((gmc->zone != zone)) continue;
-
- ax = gmc->ax;
- ay = gmc->ay;
-
- if (((ax == 0.0) || (ax == 1.0)) &&
- ((ay == 0.0) || (ay == 1.0)))
- {
- /* corner gadget */
- /* Fake removal from one alignment :) */
- if (gmc->w > gmc->h)
- ax = 0.5;
- else
- ay = 0.5;
- }
-
- if ((ax == 0.0) && (gmc->x + gmc->w) > cx1)
- cx1 = (gmc->x + gmc->w);
- else if ((ax == 1.0) && (gmc->x < cx2))
- cx2 = gmc->x;
- else if ((ay == 0.0) && ((gmc->y + gmc->h) > cy1))
- cy1 = (gmc->y + gmc->h);
- else if ((ay == 1.0) && (gmc->y < cy2))
- cy2 = gmc->y;
- }
-
-
- zw = cx2 - cx1;
- zh = cy2 - cy1;
- }
- else
- {
- zw = zone->w;
- zh = zone->h;
- }
u_x = calloc(zw + 1, sizeof(char));
u_y = calloc(zh + 1, sizeof(char));
@@ -150,7 +177,135 @@ e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w
a_x[1] = zw;
a_y[0] = 0;
a_y[1] = zh;
-
+
+ if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_ANTIGADGET)
+ {
+ Evas_List *l;
+
+ for (l = zone->container->gadman->clients; l; l = l->next)
+ {
+ E_Gadman_Client *gmc;
+ int bx, by, bw, bh;
+
+ gmc = l->data;
+ if ((gmc->zone != zone)) continue;
+
+ bx = gmc->x;
+ by = gmc->y;
+ bw = gmc->w;
+ bh = gmc->h;
+ if (E_INTERSECTS(bx, by, bw, bh, 0, 0, zw, zh))
+ {
+ if ((bx > 0) && (bx <= zw) && (!u_x[bx]))
+ {
+ a_w++;
+ if (a_w > a_alloc_w)
+ {
+ a_alloc_w += 32;
+ E_REALLOC(a_x, int, a_alloc_w);
+ }
+ a_x[a_w - 1] = bx;
+ u_x[bx] = 1;
+ }
+ if (((bx + bw) > 0) && ((bx + bw) <= zw) && (!u_x[bx + bw]))
+ {
+ a_w++;
+ if (a_w > a_alloc_w)
+ {
+ a_alloc_w += 32;
+ E_REALLOC(a_x, int, a_alloc_w);
+ }
+ a_x[a_w - 1] = bx + bw;
+ u_x[bx + bw] = 1;
+ }
+ if ((by > 0) && (by <= zh) && (!u_y[by]))
+ {
+ a_h++;
+ if (a_h > a_alloc_h)
+ {
+ a_alloc_h += 32;
+ E_REALLOC(a_y, int, a_alloc_h);
+ }
+ a_y[a_h - 1] = by;
+ u_y[by] = 1;
+ }
+ if (((by + bh) > 0) && ((by + bh) <= zh) && (!u_y[by + bh]))
+ {
+ a_h++;
+ if (a_h > a_alloc_h)
+ {
+ a_alloc_h += 32;
+ E_REALLOC(a_y, int, a_alloc_h);
+ }
+ a_y[a_h - 1] = by + bh;
+ u_y[by + bh] = 1;
+ }
+ }
+ }
+ for (l = e_shelf_list(); l; l = l->next)
+ {
+ E_Shelf *es;
+
+ es = l->data;
+ if (es->zone == zone)
+ {
+ int bx, by, bw, bh;
+
+ bx = es->x;
+ by = es->y;
+ bw = es->w;
+ bh = es->h;
+ if (E_INTERSECTS(bx, by, bw, bh, 0, 0, zw, zh))
+ {
+ if ((bx > 0) && (bx <= zw) && (!u_x[bx]))
+ {
+ a_w++;
+ if (a_w > a_alloc_w)
+ {
+ a_alloc_w += 32;
+ E_REALLOC(a_x, int, a_alloc_w);
+ }
+ a_x[a_w - 1] = bx;
+ u_x[bx] = 1;
+ }
+ if (((bx + bw) > 0) && ((bx + bw) <= zw) && (!u_x[bx + bw]))
+ {
+ a_w++;
+ if (a_w > a_alloc_w)
+ {
+ a_alloc_w += 32;
+ E_REALLOC(a_x, int, a_alloc_w);
+ }
+ a_x[a_w - 1] = bx + bw;
+ u_x[bx + bw] = 1;
+ }
+ if ((by > 0) && (by <= zh) && (!u_y[by]))
+ {
+ a_h++;
+ if (a_h > a_alloc_h)
+ {
+ a_alloc_h += 32;
+ E_REALLOC(a_y, int, a_alloc_h);
+ }
+ a_y[a_h - 1] = by;
+ u_y[by] = 1;
+ }
+ if (((by + bh) > 0) && ((by + bh) <= zh) && (!u_y[by + bh]))
+ {
+ a_h++;
+ if (a_h > a_alloc_h)
+ {
+ a_alloc_h += 32;
+ E_REALLOC(a_y, int, a_alloc_h);
+ }
+ a_y[a_h - 1] = by + bh;
+ u_y[by + bh] = 1;
+ }
+ }
+ }
+ }
+ }
+
bl = e_container_border_list_first(zone->container);
while ((bd = e_container_border_list_next(bl)))
{
@@ -240,252 +395,72 @@ e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w
{
int ar = 0;
- bl = e_container_border_list_first(zone->container);
- while ((bd = e_container_border_list_next(bl)))
- {
- int x1, y1, w1, h1, x2, y2, w2, h2;
- int ok;
-
- ok = 1;
- x1 = a_x[i];
- y1 = a_y[j];
- w1 = w;
- h1 = h;
- x2 = (bd->x - zone->x);
- y2 = (bd->y - zone->y);
- w2 = bd->w;
- h2 = bd->h;
- for (ll = skiplist; ll; ll = ll->next)
- {
- if (ll->data == bd)
- {
- ok = 0;
- break;
- }
- }
- if ((ok) && (bd->visible) &&
- E_INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2))
- {
- int iw, ih;
- int x0, x00, y0, y00;
-
- x0 = x1;
- if (x1 < x2)
- x0 = x2;
- x00 = (x1 + w1);
- if ((x2 + w2) < (x1 + w1))
- x00 = (x2 + w2);
-
- y0 = y1;
- if (y1 < y2)
- y0 = y2;
- y00 = (y1 + h1);
- if ((y2 + h2) < (y1 + h1))
- y00 = (y2 + h2);
-
- iw = x00 - x0;
- ih = y00 - y0;
- ar += (iw * ih);
- }
- }
- e_container_border_list_free(bl);
-
+ ar = _e_place_coverage_border_add(zone, skiplist, ar,
+ a_x[i], a_y[j],
+ w, h);
+ ar = _e_place_coverage_shelf_add(zone, ar,
+ a_x[i], a_y[j],
+ w, h);
if (ar < area)
{
area = ar;
*rx = a_x[i];
*ry = a_y[j];
- if (ar == 0)
- goto done;
+ if (ar == 0) goto done;
}
}
if ((a_x[i + 1] - w > 0) && (a_y[j] < (zh - h)))
{
int ar = 0;
- bl = e_container_border_list_first(zone->container);
- while ((bd = e_container_border_list_next(bl)))
- {
- int x1, y1, w1, h1, x2, y2, w2, h2;
- int ok;
-
- ok = 1;
- x1 = a_x[i + 1] - w;
- y1 = a_y[j];
- w1 = w;
- h1 = h;
- x2 = (bd->x - zone->x);
- y2 = (bd->y - zone->y);
- w2 = bd->w;
- h2 = bd->h;
- for (ll = skiplist; ll; ll = ll->next)
- {
- if (ll->data == bd)
- {
- ok = 0;
- break;
- }
- }
- if ((ok) && (bd->visible) &&
- E_INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2))
- {
- int iw, ih;
- int x0, x00, y0, y00;
-
- x0 = x1;
- if (x1 < x2)
- x0 = x2;
- x00 = (x1 + w1);
- if ((x2 + w2) < (x1 + w1))
- x00 = (x2 + w2);
-
- y0 = y1;
- if (y1 < y2)
- y0 = y2;
- y00 = (y1 + h1);
- if ((y2 + h2) < (y1 + h1))
- y00 = (y2 + h2);
-
- iw = x00 - x0;
- ih = y00 - y0;
- ar += (iw * ih);
- }
- }
- e_container_border_list_free(bl);
-
+ ar = _e_place_coverage_border_add(zone, skiplist, ar,
+ a_x[i + 1] - w, a_y[j],
+ w, h);
+ ar = _e_place_coverage_shelf_add(zone, ar,
+ a_x[i + 1] - w, a_y[j],
+ w, h);
if (ar < area)
{
area = ar;
*rx = a_x[i + 1] - w;
*ry = a_y[j];
- if (ar == 0)
- goto done;
+ if (ar == 0) goto done;
}
}
if ((a_x[i + 1] - w > 0) && (a_y[j + 1] - h > 0))
{
int ar = 0;
- bl = e_container_border_list_first(zone->container);
- while ((bd = e_container_border_list_next(bl)))
- {
- int x1, y1, w1, h1, x2, y2, w2, h2;
- int ok;
-
- ok = 1;
- x1 = a_x[i + 1] - w;
- y1 = a_y[j + 1] - h;
- w1 = w;
- h1 = h;
- x2 = (bd->x - zone->x);
- y2 = (bd->y - zone->y);
- w2 = bd->w;
- h2 = bd->h;
- for (ll = skiplist; ll; ll = ll->next)
- {
- if (ll->data == bd)
- {
- ok = 0;
- break;
- }
- }
- if ((ok) && (bd->visible) &&
- E_INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2))
- {
- int iw, ih;
- int x0, x00, y0, y00;
-
- x0 = x1;
- if (x1 < x2)
- x0 = x2;
- x00 = (x1 + w1);
- if ((x2 + w2) < (x1 + w1))
- x00 = (x2 + w2);
-
- y0 = y1;
- if (y1 < y2)
- y0 = y2;
- y00 = (y1 + h1);
- if ((y2 + h2) < (y1 + h1))
- y00 = (y2 + h2);
-
- iw = x00 - x0;
- ih = y00 - y0;
- ar += (iw * ih);
- }
- }
- e_container_border_list_free(bl);
-
+ ar = _e_place_coverage_border_add(zone, skiplist, ar,
+ a_x[i + 1] - w, a_y[j + 1] - h,
+ w, h);
+ ar = _e_place_coverage_shelf_add(zone, ar,
+ a_x[i + 1] - w, a_y[j + 1] - h,
+ w, h);
if (ar < area)
{
area = ar;
*rx = a_x[i + 1] - w;
*ry = a_y[j + 1] - h;
- if (ar == 0)
- goto done;
+ if (ar == 0) goto done;
}
}
if ((a_x[i] < (zw - w)) && (a_y[j + 1] - h > 0))
{
int ar = 0;
- bl = e_container_border_list_first(zone->container);
- while ((bd = e_container_border_list_next(bl)))
- {
- int x1, y1, w1, h1, x2, y2, w2, h2;
- int ok;
-
- ok = 1;
- x1 = a_x[i];
- y1 = a_y[j + 1] - h;
- w1 = w;
- h1 = h;
- x2 = (bd->x - zone->x);
- y2 = (bd->y - zone->y);
- w2 = bd->w;
- h2 = bd->h;
- for (ll = skiplist; ll; ll = ll->next)
- {
- if (ll->data == bd)
- {
- ok = 0;
- break;
- }
- }
- if ((ok) && (bd->visible) &&
- E_INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2))
- {
- int iw, ih;
- int x0, x00, y0, y00;
-
- x0 = x1;
- if (x1 < x2)
- x0 = x2;
- x00 = (x1 + w1);
- if ((x2 + w2) < (x1 + w1))
- x00 = (x2 + w2);
-
- y0 = y1;
- if (y1 < y2)
- y0 = y2;
- y00 = (y1 + h1);
- if ((y2 + h2) < (y1 + h1))
- y00 = (y2 + h2);
-
- iw = x00 - x0;
- ih = y00 - y0;
- ar += (iw * ih);
- }
- }
- e_container_border_list_free(bl);
-
+ ar = _e_place_coverage_border_add(zone, skiplist, ar,
+ a_x[i], a_y[j + 1] - h,
+ w, h);
+ ar = _e_place_coverage_shelf_add(zone, ar,
+ a_x[i], a_y[j + 1] - h,
+ w, h);
if (ar < area)
{
area = ar;
*rx = a_x[i];
*ry = a_y[j + 1] - h;
- if (ar == 0)
- goto done;
+ if (ar == 0) goto done;
}
}
}
diff --git a/src/bin/e_popup.c b/src/bin/e_popup.c
index 5fa773d22..48a896b08 100644
--- a/src/bin/e_popup.c
+++ b/src/bin/e_popup.c
@@ -207,6 +207,21 @@ e_popup_idler_before(void)
orects = pop->shape_rects;
for (i = 0; i < num; i++)
{
+ if (rects[i].x < 0)
+ {
+ rects[i].width -= rects[i].x;
+ rects[i].x = 0;
+ }
+ if ((rects[i].x + rects[i].width) > pop->w)
+ rects[i].width = rects[i].width - rects[i].x;
+ if (rects[i].y < 0)
+ {
+ rects[i].height -= rects[i].y;
+ rects[i].y = 0;
+ }
+ if ((rects[i].y + rects[i].height) > pop->h)
+ rects[i].height = rects[i].height - rects[i].y;
+
if ((orects[i].x != rects[i].x) ||
(orects[i].y != rects[i].y) ||
(orects[i].width != rects[i].width) ||
@@ -216,7 +231,7 @@ e_popup_idler_before(void)
break;
}
}
- changed = 0;
+// changed = 0;
}
if (changed)
{
diff --git a/src/bin/e_resist.c b/src/bin/e_resist.c
index e2c68b36c..6ad0732a5 100644
--- a/src/bin/e_resist.c
+++ b/src/bin/e_resist.c
@@ -92,6 +92,17 @@ e_resist_container_border_position(E_Container *con, Evas_List *skiplist,
gmc = l->data;
OBSTACLE(gmc->x, gmc->y, gmc->w, gmc->h, e_config->gadget_resist);
}
+ for (l = e_shelf_list(); l; l = l->next)
+ {
+ E_Shelf *es;
+
+ es = l->data;
+ if (es->zone->container == con)
+ {
+ OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
+ e_config->gadget_resist);
+ }
+ }
if (rects)
{
_e_resist_rects(rects,
@@ -141,17 +152,22 @@ e_resist_container_gadman_position(E_Container *con, Evas_List *skiplist,
}
if (ok)
{
- r = E_NEW(E_Resist_Rect, 1);
-
- r->x = gmc->x;
- r->y = gmc->y;
- r->w = gmc->w;
- r->h = gmc->h;
- r->v1 = e_config->gadget_resist;
- rects = evas_list_append(rects, r);
+ OBSTACLE(gmc->x, gmc->y, gmc->w, gmc->h, e_config->gadget_resist);
}
}
+ for (l = e_shelf_list(); l; l = l->next)
+ {
+ E_Shelf *es;
+
+ es = l->data;
+ if (es->zone->container == con)
+ {
+ OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
+ e_config->gadget_resist);
+ }
+ }
+
if (rects)
{
_e_resist_rects(rects,
diff --git a/src/bin/e_shelf.c b/src/bin/e_shelf.c
index f6b1aae46..48a22f136 100644
--- a/src/bin/e_shelf.c
+++ b/src/bin/e_shelf.c
@@ -6,6 +6,7 @@
static void _e_shelf_free(E_Shelf *es);
static const char *_e_shelf_orient_string_get(E_Shelf *es);
static void _e_shelf_position_calc(E_Shelf *es);
+static void _e_shelf_gadcon_min_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
static void _e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
static Evas_Object *_e_shelf_gadcon_frame_request(void *data, E_Gadcon_Client *gcc, const char *style);
@@ -47,6 +48,8 @@ e_shelf_config_init(void)
if (es)
{
es->cfg = cf_es;
+ es->fit_along = cf_es->fit_along;
+ es->fit_size = cf_es->fit_size;
e_shelf_orient(es, cf_es->orient);
_e_shelf_position_calc(es);
e_shelf_populate(es);
@@ -56,6 +59,12 @@ e_shelf_config_init(void)
}
}
+EAPI Evas_List *
+e_shelf_list(void)
+{
+ return shelves;
+}
+
EAPI E_Shelf *
e_shelf_zone_new(E_Zone *zone, const char *name, const char *style, int popup, int layer)
{
@@ -114,6 +123,9 @@ e_shelf_zone_new(E_Zone *zone, const char *name, const char *style, int popup, i
snprintf(buf, sizeof(buf), "%i", shelf_id);
shelf_id++;
es->gadcon = e_gadcon_swallowed_new(es->name, buf, es->o_base, "items");
+ e_gadcon_min_size_request_callback_set(es->gadcon,
+ _e_shelf_gadcon_min_size_request,
+ es);
e_gadcon_size_request_callback_set(es->gadcon,
_e_shelf_gadcon_size_request,
es);
@@ -466,6 +478,12 @@ _e_shelf_position_calc(E_Shelf *es)
}
static void
+_e_shelf_gadcon_min_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h)
+{
+ return;
+}
+
+static void
_e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h)
{
E_Shelf *es;
@@ -477,7 +495,7 @@ _e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord
nw = es->w;
nh = es->h;
ww = hh = 0;
- printf("req min = %i %i\n", w, h);
+ printf("req = %i %i\n", w, h);
evas_object_geometry_get(gc->o_container, NULL, NULL, &ww, &hh);
switch (gc->orient)
{
@@ -537,7 +555,7 @@ _e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord
if (!es->fit_size) nw = es->w;
if (nw > es->zone->w) nw = es->zone->w;
if (nh > es->zone->h) nh = es->zone->h;
- if (nh != es->h) ny = es->y + ((es->h - nh) / 2);
+ if (nh != es->h) ny = (es->zone->h - nh) / 2;
nx = 0;
break;
case E_GADCON_ORIENT_RIGHT:
@@ -545,7 +563,7 @@ _e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord
if (!es->fit_size) nw = es->w;
if (nw > es->zone->w) nw = es->zone->w;
if (nh > es->zone->h) nh = es->zone->h;
- if (nh != es->h) ny = es->y + ((es->h - nh) / 2);
+ if (nh != es->h) ny = (es->zone->h - nh) / 2;
nx = es->zone->w - nw;
break;
case E_GADCON_ORIENT_TOP:
@@ -553,7 +571,7 @@ _e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord
if (!es->fit_size) nh = es->h;
if (nw > es->zone->w) nw = es->zone->w;
if (nh > es->zone->h) nh = es->zone->h;
- if (nw != es->w) nx = es->x + ((es->w - nw) / 2);
+ if (nw != es->w) nx = (es->zone->w - nw) / 2;
ny = 0;
break;
case E_GADCON_ORIENT_BOTTOM:
@@ -561,7 +579,7 @@ _e_shelf_gadcon_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord
if (!es->fit_size) nh = es->h;
if (nw > es->zone->w) nw = es->zone->w;
if (nh > es->zone->h) nh = es->zone->h;
- if (nw != es->w) nx = es->x + ((es->w - nw) / 2);
+ if (nw != es->w) nx = (es->zone->w - nw) / 2;
ny = es->zone->h - nh;
break;
case E_GADCON_ORIENT_CORNER_TL:
diff --git a/src/bin/e_shelf.h b/src/bin/e_shelf.h
index e6fb0cf91..17c7ff56e 100644
--- a/src/bin/e_shelf.h
+++ b/src/bin/e_shelf.h
@@ -34,6 +34,7 @@ struct _E_Shelf
EAPI int e_shelf_init(void);
EAPI int e_shelf_shutdown(void);
EAPI void e_shelf_config_init(void);
+EAPI Evas_List *e_shelf_list(void);
EAPI E_Shelf *e_shelf_zone_new(E_Zone *zone, const char *name, const char *style, int popup, int layer);
EAPI void e_shelf_populate(E_Shelf *es);
EAPI void e_shelf_show(E_Shelf *es);
diff --git a/src/modules/battery/Makefile.am b/src/modules/battery/Makefile.am
index c8225ec4e..82dbe63b0 100644
--- a/src/modules/battery/Makefile.am
+++ b/src/modules/battery/Makefile.am
@@ -21,8 +21,7 @@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
- e_mod_config.c \
- e_mod_config.h
+ e_mod_config.c
module_la_LIBADD = @e_libs@ @cf_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
diff --git a/src/modules/battery/e_mod_config.c b/src/modules/battery/e_mod_config.c
index 3e5a3d6d9..7199a7a85 100644
--- a/src/modules/battery/e_mod_config.c
+++ b/src/modules/battery/e_mod_config.c
@@ -1,7 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
struct _E_Config_Dialog_Data
{
@@ -19,7 +17,7 @@ static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas,
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
void
-_config_battery_module(E_Container *con, Battery *bat)
+_config_battery_module(void)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
@@ -33,15 +31,18 @@ _config_battery_module(E_Container *con, Battery *bat)
v->advanced.apply_cfdata = _advanced_apply_data;
v->advanced.create_widgets = _advanced_create_widgets;
- cfd = e_config_dialog_new(con, _("Battery Configuration"), NULL, 0, v, bat);
- bat->config_dialog = cfd;
+ cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
+ _("Battery Monitor Configuration"),
+ NULL, 0, v, NULL);
+ battery_config->config_dialog = cfd;
}
static void
-_fill_data(Battery *b, E_Config_Dialog_Data *cfdata)
+_fill_data(E_Config_Dialog_Data *cfdata)
{
- cfdata->alarm_time = b->conf->alarm;
- cfdata->poll_time = b->conf->poll_time;
+ if (!battery_config) return;
+ cfdata->alarm_time = battery_config->alarm;
+ cfdata->poll_time = battery_config->poll_time;
if (cfdata->alarm_time > 0)
cfdata->show_alert = 1;
else
@@ -52,21 +53,17 @@ static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
- Battery *b;
- b = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
- _fill_data(b, cfdata);
+ _fill_data(cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Battery *b;
-
- b = cfd->data;
- b->config_dialog = NULL;
+ if (!battery_config) return;
+ battery_config->config_dialog = NULL;
free(cfdata);
}
@@ -86,16 +83,13 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Battery *b;
-
- b = cfd->data;
- e_border_button_bindings_ungrab_all();
- b->conf->poll_time = 10.0;
-
- e_border_button_bindings_grab_all();
+ if (!battery_config) return;
+ if (cfdata->show_alert)
+ battery_config->alarm = cfdata->alarm_time;
+ else
+ battery_config->alarm = 0;
+ _battery_config_updated();
e_config_save_queue();
-
- _battery_face_cb_config_updated(b);
return 1;
}
@@ -130,20 +124,14 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
static int
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Battery *b;
-
- b = cfd->data;
- e_border_button_bindings_ungrab_all();
-
- b->conf->poll_time = cfdata->poll_time;
+ if (!battery_config) return;
+ battery_config->poll_time = cfdata->poll_time;
if (cfdata->show_alert)
- b->conf->alarm = cfdata->alarm_time;
+ battery_config->alarm = cfdata->alarm_time;
else
- b->conf->alarm = 0;
-
- e_border_button_bindings_grab_all();
+ battery_config->alarm = 0;
+ _battery_config_updated();
e_config_save_queue();
-
- _battery_face_cb_config_updated(b);
return 1;
}
+
diff --git a/src/modules/battery/e_mod_config.h b/src/modules/battery/e_mod_config.h
deleted file mode 100644
index 8f0dbaaee..000000000
--- a/src/modules/battery/e_mod_config.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifdef E_TYPEDEFS
-#else
-#ifndef E_MOD_CONFIG_H
-#define E_MOD_CONFIG_H
-#include "e_mod_main.h"
-void _config_battery_module(E_Container *con, Battery *b);
-#endif
-#endif
diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c
index d7e32b3cb..0767d1cd9 100644
--- a/src/modules/battery/e_mod_main.c
+++ b/src/modules/battery/e_mod_main.c
@@ -3,7 +3,6 @@
*/
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
#ifdef __FreeBSD__
# include <sys/types.h>
@@ -14,7 +13,6 @@
# endif
# include <stdio.h>
#endif
-
#ifdef HAVE_CFBASE_H
#include <CFBase.h>
#include <CFNumber.h>
@@ -25,445 +23,172 @@
#include <ps/IOPowerSources.h>
#endif
-/* TODO List:
- *
- * which options should be in main menu, and which in face menu?
- */
-
-/* module private routines */
-static Battery *_battery_new();
-static void _battery_shutdown(Battery *e);
-static void _battery_config_menu_new(Battery *e);
-static int _battery_cb_check(void *data);
-static Status *_battery_linux_acpi_check(Battery *ef);
-static Status *_battery_linux_apm_check(Battery *ef);
-/* linux on powerbook */
-static Status *_battery_linux_powerbook_check(Battery *ef);
-/* Should these be #ifdef'd ? */
-#ifdef __FreeBSD__
-static Status *_battery_bsd_acpi_check(Battery *ef);
-static Status *_battery_bsd_apm_check(Battery *ef);
-#endif
-
-#ifdef HAVE_CFBASE_H
-static Status *_battery_darwin_check(Battery *ef);
-#endif
-
-static Battery_Face *_battery_face_new(Battery *bat, E_Container *con);
-static void _battery_face_free(Battery_Face *ef);
-static void _battery_face_menu_new(Battery_Face *face);
-static void _battery_face_enable(Battery_Face *face);
-static void _battery_face_disable(Battery_Face *face);
-static void _battery_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
-static void _battery_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _battery_face_level_set(Battery_Face *ef, double level);
-static void _battery_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
-
-static int _battery_int_get(char *buf);
-static char *_battery_string_get(char *buf);
-
-static void _battery_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
-
-static E_Config_DD *conf_edd;
-static E_Config_DD *conf_face_edd;
-
-static int battery_count;
-
-/* public module routines. all modules must have these */
-EAPI E_Module_Api e_modapi =
-{
- E_MODULE_API_VERSION,
- "Battery"
-};
-
-EAPI void *
-e_modapi_init(E_Module *m)
+/***************************************************************************/
+/**/
+/* gadcon requirements */
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static void _gc_shutdown(E_Gadcon_Client *gcc);
+static void _gc_orient(E_Gadcon_Client *gcc);
+/* and actually define the gadcon class that this module provides (just 1) */
+static const E_Gadcon_Client_Class _gadcon_class =
{
- Battery *e;
-
- /* actually init battery */
- e = _battery_new();
- m->config_menu = e->config_menu;
- return e;
-}
-
-EAPI int
-e_modapi_shutdown(E_Module *m)
-{
- Battery *e;
- if (m->config_menu)
- m->config_menu = NULL;
-
- e = m->data;
- if (e)
+ GADCON_CLIENT_CLASS_VERSION,
+ "battery",
{
- if (e->config_dialog)
- {
- e_object_del(E_OBJECT(e->config_dialog));
- e->config_dialog = NULL;
- }
- _battery_shutdown(e);
- }
- return 1;
-}
-
-EAPI int
-e_modapi_save(E_Module *m)
-{
- Battery *e;
-
- e = m->data;
- e_config_domain_save("module.battery", conf_edd, e->conf);
- return 1;
-}
-
-EAPI int
-e_modapi_info(E_Module *m)
-{
- char buf[4096];
-
- snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
- m->icon_file = strdup(buf);
- return 1;
-}
-
-EAPI int
-e_modapi_about(E_Module *m)
-{
- e_module_dialog_show(_("Enlightenment Battery Module"),
- _("A basic battery meter that uses either"
- "<hilight>ACPI</hilight> or <hilight>APM</hilight><br>"
- "on Linux to monitor your battery and AC power adaptor<br>"
- "status. This will work under Linux and FreeBSD and is only<br>"
- "as accurate as your BIOS or kernel drivers."));
- return 1;
-}
-
-EAPI int
-e_modapi_config(E_Module *m)
-{
- Battery *e;
- Evas_List *l;
-
- e = m->data;
- if (!e) return 0;
- if (!e->faces) return 0;
- for (l = e->faces; l; l = l->next)
- {
- Battery_Face *face;
- face = l->data;
- if (!face) return 0;
- if (face->con == e_container_current_get(e_manager_current_get()))
- {
- _config_battery_module(face->con, face->battery);
- break;
- }
- }
- return 1;
-}
-
-/* module private routines */
-static Battery *
-_battery_new()
-{
- Battery *e;
- Evas_List *managers, *l, *l2, *cl;
-
- E_Menu_Item *mi;
-
- battery_count = 0;
- e = E_NEW(Battery, 1);
- if (!e) return NULL;
-
- conf_face_edd = E_CONFIG_DD_NEW("Battery_Config_Face", Config_Face);
-#undef T
-#undef D
-#define T Config_Face
-#define D conf_face_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
-
- conf_edd = E_CONFIG_DD_NEW("Battery_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D conf_edd
- E_CONFIG_VAL(D, T, poll_time, DOUBLE);
- E_CONFIG_VAL(D, T, alarm, INT);
- E_CONFIG_LIST(D, T, faces, conf_face_edd);
-
- e->conf = e_config_domain_load("module.battery", conf_edd);
- if (!e->conf)
- {
- e->conf = E_NEW(Config, 1);
- e->conf->poll_time = 30.0;
- e->conf->alarm = 30;
- }
- E_CONFIG_LIMIT(e->conf->poll_time, 0.5, 1000.0);
- E_CONFIG_LIMIT(e->conf->alarm, 0, 60);
-
- _battery_config_menu_new(e);
-
- e->battery_check_mode = CHECK_NONE;
- e->battery_prev_drain = 1;
- e->battery_prev_ac = -1;
- e->battery_prev_battery = -1;
- e->battery_check_timer = ecore_timer_add(e->conf->poll_time, _battery_cb_check, e);
-
- managers = e_manager_list();
- cl = e->conf->faces;
- for (l = managers; l; l = l->next)
- {
- E_Manager *man;
-
- man = l->data;
- for (l2 = man->containers; l2; l2 = l2->next)
- {
- E_Container *con;
- Battery_Face *ef;
-
- con = l2->data;
- ef = _battery_face_new(e, con);
- if (ef)
- {
- ef->battery = e;
- e->faces = evas_list_append(e->faces, ef);
-
- /* Config */
- if (!cl)
- {
- ef->conf = E_NEW(Config_Face, 1);
- ef->conf->enabled = 1;
- e->conf->faces = evas_list_append(e->conf->faces, ef->conf);
- }
- else
- {
- ef->conf = cl->data;
- cl = cl->next;
- }
-
- /* Menu */
- /* This menu must be initialized after conf */
- _battery_face_menu_new(ef);
-
- /* Add main menu to face menu */
- mi = e_menu_item_new(e->config_menu);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _battery_face_cb_menu_configure, ef);
-
- mi = e_menu_item_new(e->config_menu);
- e_menu_item_label_set(mi, con->name);
- e_menu_item_submenu_set(mi, ef->menu);
-
- /* Setup */
- if (!ef->conf->enabled)
- _battery_face_disable(ef);
- }
- }
+ _gc_init, _gc_shutdown, _gc_orient
}
+};
+/**/
+/***************************************************************************/
- _battery_cb_check(e);
+/***************************************************************************/
+/**/
+/* actual module specifics */
- return e;
-}
+typedef struct _Instance Instance;
-static void
-_battery_shutdown(Battery *e)
+struct _Instance
{
- Evas_List *l;
-
- E_CONFIG_DD_FREE(conf_edd);
- E_CONFIG_DD_FREE(conf_face_edd);
-
- for (l = e->faces; l; l = l->next)
- _battery_face_free(l->data);
- evas_list_free(e->faces);
-
- e_object_del(E_OBJECT(e->config_menu));
-
- ecore_timer_del(e->battery_check_timer);
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_battery;
+};
- evas_list_free(e->conf->faces);
- free(e->conf);
- free(e);
-}
+static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _menu_cb_post(void *data, E_Menu *m);
+static Status *_battery_linux_acpi_check(void);
+static Status *_battery_linux_apm_check(void);
+static Status *_battery_linux_powerbook_check(void);
+#ifdef __FreeBSD__
+static Status *_battery_bsd_acpi_check(void);
+static Status *_battery_bsd_apm_check(void);
+#endif
+#ifdef HAVE_CFBASE_H
+static Status *_battery_darwin_check(void);
+#endif
+static void _battery_face_level_set(Instance *inst, double level);
+static int _battery_int_get(char *buf);
+static char *_battery_string_get(char *buf);
+static int _battery_cb_check(void *data);
+static void _battery_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
-static void
-_battery_config_menu_new(Battery *e)
-{
- E_Menu *mn;
+static E_Config_DD *conf_edd = NULL;
- /* Alarm */
- mn = e_menu_new();
- e->config_menu = mn;
-}
+Config *battery_config = NULL;
-static Battery_Face *
-_battery_face_new(Battery *bat, E_Container *con)
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
{
Evas_Object *o;
- Battery_Face *ef;
- E_Gadman_Policy policy;
-
- ef = E_NEW(Battery_Face, 1);
- if (!ef) return NULL;
-
- ef->con = con;
- e_object_ref(E_OBJECT(con));
-
- evas_event_freeze(con->bg_evas);
- o = edje_object_add(con->bg_evas);
- ef->bat_object = o;
-
+ E_Gadcon_Client *gcc;
+ Instance *inst;
+
+ inst = E_NEW(Instance, 1);
+
+ o = edje_object_add(gc->evas);
e_theme_edje_object_set(o, "base/theme/modules/battery",
"modules/battery/main");
- evas_object_show(o);
-
- o = evas_object_rectangle_add(con->bg_evas);
- ef->event_object = o;
- evas_object_layer_set(o, 2);
- evas_object_repeat_events_set(o, 1);
- evas_object_color_set(o, 0, 0, 0, 0);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _battery_face_cb_mouse_down, ef);
- evas_object_show(o);
-
- ef->gmc = e_gadman_client_new(con->gadman);
- e_gadman_client_domain_set(ef->gmc, "module.battery", battery_count++);
-
- policy = E_GADMAN_POLICY_ANYWHERE |
- E_GADMAN_POLICY_HMOVE |
- E_GADMAN_POLICY_VMOVE |
- E_GADMAN_POLICY_HSIZE |
- E_GADMAN_POLICY_VSIZE;
- e_gadman_client_policy_set(ef->gmc, policy);
- e_gadman_client_min_size_set(ef->gmc, 4, 4);
- e_gadman_client_max_size_set(ef->gmc, 128, 128);
- e_gadman_client_auto_size_set(ef->gmc, 40, 40);
- e_gadman_client_align_set(ef->gmc, 1.0, 1.0);
- e_gadman_client_resize(ef->gmc, 40, 40);
- e_gadman_client_change_func_set(ef->gmc, _battery_face_cb_gmc_change, ef);
- e_gadman_client_load(ef->gmc);
- evas_event_thaw(con->bg_evas);
-
- return ef;
-}
-
-static void
-_battery_face_free(Battery_Face *ef)
-{
- e_object_unref(E_OBJECT(ef->con));
- e_object_del(E_OBJECT(ef->gmc));
- e_object_del(E_OBJECT(ef->menu));
- evas_object_del(ef->bat_object);
- evas_object_del(ef->event_object);
-
- free(ef->conf);
- free(ef);
- battery_count--;
-}
-
-static void
-_battery_face_menu_new(Battery_Face *face)
-{
- E_Menu *mn;
- E_Menu_Item *mi;
-
- mn = e_menu_new();
- face->menu = mn;
-
- /* Config */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _battery_face_cb_menu_configure, face);
- /* Edit */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Edit Mode"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _battery_face_cb_menu_edit, face);
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+
+ inst->gcc = gcc;
+ inst->o_battery = o;
+
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
+ _button_cb_mouse_down, inst);
+ battery_config->instances = evas_list_append(battery_config->instances, inst);
+ battery_config->battery_check_mode = CHECK_NONE;
+ battery_config->battery_prev_drain = 1;
+ battery_config->battery_prev_ac = -1;
+ battery_config->battery_prev_battery = -1;
+ _battery_cb_check(NULL);
+ return gcc;
}
static void
-_battery_face_enable(Battery_Face *face)
+_gc_shutdown(E_Gadcon_Client *gcc)
{
- face->conf->enabled = 1;
- evas_object_show(face->bat_object);
- evas_object_show(face->event_object);
- e_config_save_queue();
+ Instance *inst;
+
+ inst = gcc->data;
+ battery_config->instances = evas_list_remove(battery_config->instances, inst);
+ evas_object_del(inst->o_battery);
+ free(inst);
}
static void
-_battery_face_disable(Battery_Face *face)
+_gc_orient(E_Gadcon_Client *gcc)
{
- face->conf->enabled = 0;
- evas_object_hide(face->bat_object);
- evas_object_hide(face->event_object);
- e_config_save_queue();
+ Instance *inst;
+
+ inst = gcc->data;
+ e_gadcon_client_aspect_set(gcc, 16, 16);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
+/**/
+/***************************************************************************/
+/***************************************************************************/
+/**/
static void
-_battery_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
+_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Battery_Face *ef;
- Evas_Coord x, y, w, h;
-
- ef = data;
- switch (change)
+ Instance *inst;
+ Evas_Event_Mouse_Down *ev;
+
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!battery_config->menu))
{
- case E_GADMAN_CHANGE_MOVE_RESIZE:
- e_gadman_client_geometry_get(ef->gmc, &x, &y, &w, &h);
- evas_object_move(ef->bat_object, x, y);
- evas_object_move(ef->event_object, x, y);
- evas_object_resize(ef->bat_object, w, h);
- evas_object_resize(ef->event_object, w, h);
- break;
- case E_GADMAN_CHANGE_RAISE:
- evas_object_raise(ef->bat_object);
- evas_object_raise(ef->event_object);
- break;
- case E_GADMAN_CHANGE_EDGE:
- case E_GADMAN_CHANGE_ZONE:
- /* FIXME
- * Must we do something here?
- */
- break;
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int cx, cy, cw, ch;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _menu_cb_post, inst);
+ battery_config->menu = mn;
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Configuration"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
+ e_menu_item_callback_set(mi, _battery_face_cb_menu_configure, NULL);
+
+ e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &cx, &cy, &cw, &ch);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ cx + ev->output.x, cy + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
}
static void
-_battery_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_menu_cb_post(void *data, E_Menu *m)
{
- Evas_Event_Mouse_Down *ev;
- Battery_Face *ef;
-
- ev = event_info;
- ef = data;
- if (ev->button == 3)
- {
- e_menu_activate_mouse(ef->menu, e_zone_current_get(ef->con),
- ev->output.x, ev->output.y, 1, 1,
- E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
- e_util_container_fake_mouse_up_all_later(ef->con);
- }
+ if (!battery_config->menu) return;
+ e_object_del(E_OBJECT(battery_config->menu));
+ battery_config->menu = NULL;
}
static int
_battery_cb_check(void *data)
{
- Battery *ef;
- Battery_Face *face;
- Evas_List *l;
+ Instance *inst;
Status *ret = NULL;
-
- ef = data;
+ Evas_List *l;
#ifdef __FreeBSD__
int acline;
size_t len;
int apm_fd = -1;
int acline_mib[3] = {-1};
-
- if (ef->battery_check_mode == 0)
+#endif
+
+#ifdef __FreeBSD__
+ if (battery_config->battery_check_mode == 0)
{
len = sizeof(acline);
if (sysctlbyname("hw.acpi.acline", &acline, &len, NULL, 0) == 0)
@@ -482,177 +207,153 @@ _battery_cb_check(void *data)
switch (ef->battery_check_mode)
{
case CHECK_ACPI:
- ret = _battery_bsd_acpi_check(ef);
+ ret = _battery_bsd_acpi_check();
break;
case CHECK_APM:
- ret = _battery_bsd_apm_check(ef);
+ ret = _battery_bsd_apm_check();
break;
default:
break;
}
#elif defined(HAVE_CFBASE_H) /* OS X */
- ret = _battery_darwin_check(ef);
+ ret = _battery_darwin_check();
#else
- if (ef->battery_check_mode == 0)
+ if (battery_config->battery_check_mode == 0)
{
if (ecore_file_is_dir("/proc/acpi"))
- ef->battery_check_mode = CHECK_ACPI;
+ battery_config->battery_check_mode = CHECK_ACPI;
else if (ecore_file_exists("/proc/apm"))
- ef->battery_check_mode = CHECK_APM;
+ battery_config->battery_check_mode = CHECK_APM;
else if (ecore_file_is_dir("/proc/pmu"))
- ef->battery_check_mode = CHECK_PMU;
+ battery_config->battery_check_mode = CHECK_PMU;
}
- switch (ef->battery_check_mode)
+ switch (battery_config->battery_check_mode)
{
case CHECK_ACPI:
- ret = _battery_linux_acpi_check(ef);
+ ret = _battery_linux_acpi_check();
break;
case CHECK_APM:
- ret = _battery_linux_apm_check(ef);
+ ret = _battery_linux_apm_check();
break;
case CHECK_PMU:
- ret = _battery_linux_powerbook_check(ef);
+ ret = _battery_linux_powerbook_check();
break;
default:
break;
}
#endif
- if (ret)
+ for (l = battery_config->instances; l; l = l->next)
{
- if (ret->has_battery)
+ Instance *inst;
+
+ inst = l->data;
+ if (ret)
{
- if (ret->state == BATTERY_STATE_CHARGING)
+ if (ret->has_battery)
{
- for (l = ef->faces; l; l = l->next)
+ if (ret->state == BATTERY_STATE_CHARGING)
{
- face = l->data;
- if (ef->battery_prev_ac != 1)
- edje_object_signal_emit(face->bat_object, "charge", "");
- edje_object_signal_emit(face->bat_object, "pulsestop", "");
- edje_object_part_text_set(face->bat_object, "reading", ret->reading);
- edje_object_part_text_set(face->bat_object, "time", ret->time);
- _battery_face_level_set(face, ret->level);
-
+ if (battery_config->battery_prev_ac != 1)
+ edje_object_signal_emit(inst->o_battery, "charge", "");
+ edje_object_signal_emit(inst->o_battery, "pulsestop", "");
+ edje_object_part_text_set(inst->o_battery, "reading", ret->reading);
+ edje_object_part_text_set(inst->o_battery, "time", ret->time);
+ _battery_face_level_set(inst, ret->level);
+ battery_config->battery_prev_ac = 1;
}
- ef->battery_prev_ac = 1;
- }
- else if (ret->state == BATTERY_STATE_DISCHARGING)
- {
- for (l = ef->faces; l; l = l->next)
+ else if (ret->state == BATTERY_STATE_DISCHARGING)
{
- face = l->data;
- if (ef->battery_prev_ac != 0)
- edje_object_signal_emit(face->bat_object, "discharge", "");
+ if (battery_config->battery_prev_ac != 0)
+ edje_object_signal_emit(inst->o_battery, "discharge", "");
if (ret->alarm)
{
- if (!ef->alarm_triggered)
+ if (!battery_config->alarm_triggered)
{
E_Dialog *dia;
-
+
dia = e_dialog_new(e_container_current_get(e_manager_current_get()));
if (!dia) return 0;
e_dialog_title_set(dia, "Enlightenment Battery Module");
e_dialog_icon_set(dia, "enlightenment/e", 64);
- e_dialog_text_set(dia, _("Battery Running Low<br>"
- "Your battery is running low.<br>"
- "You may wish to switch to an AC source."));
+ e_dialog_text_set(dia,
+ _("Battery Running Low<br>"
+ "Your battery is running low.<br>"
+ "You may wish to switch to an AC source."));
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
e_win_centered_set(dia->win, 1);
e_dialog_show(dia);
}
- edje_object_signal_emit(face->bat_object, "pulse", "");
+ edje_object_signal_emit(inst->o_battery, "pulse", "");
}
- edje_object_part_text_set(face->bat_object, "reading", ret->reading);
- edje_object_part_text_set(face->bat_object, "time", ret->time);
- _battery_face_level_set(face, ret->level);
-
+ edje_object_part_text_set(inst->o_battery, "reading", ret->reading);
+ edje_object_part_text_set(inst->o_battery, "time", ret->time);
+ _battery_face_level_set(inst, ret->level);
+ battery_config->battery_prev_ac = 0;
+ if (ret->alarm)
+ battery_config->alarm_triggered = 1;
}
- ef->battery_prev_ac = 0;
- if (ret->alarm)
- ef->alarm_triggered = 1;
- }
- else
- {
- /* ret->state == BATTERY_STATE_NONE */
- for (l = ef->faces; l; l = l->next)
+ else
{
- face = l->data;
- if (ef->battery_prev_ac != 1)
- edje_object_signal_emit(face->bat_object, "charge", "");
- if (ef->battery_prev_battery == 0)
- edje_object_signal_emit(face->bat_object, "charge", "");
- edje_object_part_text_set(face->bat_object, "reading", ret->reading);
- edje_object_part_text_set(face->bat_object, "time", ret->time);
- _battery_face_level_set(face, ret->level);
-
+ /* ret->state == BATTERY_STATE_NONE */
+ if (battery_config->battery_prev_ac != 1)
+ edje_object_signal_emit(inst->o_battery, "charge", "");
+ if (battery_config->battery_prev_battery == 0)
+ edje_object_signal_emit(inst->o_battery, "charge", "");
+ edje_object_part_text_set(inst->o_battery, "reading", ret->reading);
+ edje_object_part_text_set(inst->o_battery, "time", ret->time);
+ _battery_face_level_set(inst, ret->level);
+ battery_config->battery_prev_ac = 1;
+ battery_config->battery_prev_battery = 1;
}
- ef->battery_prev_ac = 1;
- ef->battery_prev_battery = 1;
}
- }
- else
- {
- /* Hasn't battery */
- for (l = ef->faces; l; l = l->next)
+ else
{
- face = l->data;
- if (ef->battery_prev_battery != 0)
- edje_object_signal_emit(face->bat_object, "unknown", "");
- edje_object_part_text_set(face->bat_object, "reading", ret->reading);
- edje_object_part_text_set(face->bat_object, "time", ret->time);
- _battery_face_level_set(face, ret->level);
-
+ /* Hasn't battery */
+ if (battery_config->battery_prev_battery != 0)
+ edje_object_signal_emit(inst->o_battery, "unknown", "");
+ edje_object_part_text_set(inst->o_battery, "reading", ret->reading);
+ edje_object_part_text_set(inst->o_battery, "time", ret->time);
+ _battery_face_level_set(inst, ret->level);
+ battery_config->battery_prev_battery = 0;
}
- ef->battery_prev_battery = 0;
+ free(ret->reading);
+ free(ret->time);
+ free(ret);
}
- free(ret->reading);
- free(ret->time);
- free(ret);
- }
- else
- {
- /* Error reading status */
- for (l = ef->faces; l; l = l->next)
+ else
{
- face = l->data;
-
- if (ef->battery_prev_battery != -2)
- edje_object_signal_emit(face->bat_object, "unknown", "");
- edje_object_part_text_set(face->bat_object, "reading", _("NO INFO"));
- edje_object_part_text_set(face->bat_object, "time", "--:--");
- _battery_face_level_set(face, (double)(rand() & 0xff) / 255.0);
+ /* Error reading status */
+ if (battery_config->battery_prev_battery != -2)
+ edje_object_signal_emit(inst->o_battery, "unknown", "");
+ edje_object_part_text_set(inst->o_battery, "reading", _("NO INFO"));
+ edje_object_part_text_set(inst->o_battery, "time", "--:--");
+ _battery_face_level_set(inst, (double)(rand() & 0xff) / 255.0);
+ battery_config->battery_prev_battery = -2;
+ battery_config->battery_check_mode = CHECK_NONE;
}
- ef->battery_prev_battery = -2;
- ef->battery_check_mode = CHECK_NONE;
}
return 1;
}
static Status *
-_battery_linux_acpi_check(Battery *ef)
+_battery_linux_acpi_check(void)
{
Ecore_List *bats;
char buf[4096], buf2[4096];
char *name;
-
int bat_max = 0;
int bat_filled = 0;
int bat_level = 0;
int bat_drain = 1;
-
int bat_val = 0;
-
int discharging = 0;
int charging = 0;
int battery = 0;
-
int design_cap_unknown = 0;
int last_full_unknown = 0;
int rate_unknown = 0;
int level_unknown = 0;
-
int hours, minutes;
-
Status *stat;
stat = E_NEW(Status, 1);
@@ -767,9 +468,9 @@ _battery_linux_acpi_check(Battery *ef)
ecore_list_destroy(bats);
}
- if (ef->battery_prev_drain < 1) ef->battery_prev_drain = 1;
- if (bat_drain < 1) bat_drain = ef->battery_prev_drain;
- ef->battery_prev_drain = bat_drain;
+ if (battery_config->battery_prev_drain < 1) battery_config->battery_prev_drain = 1;
+ if (bat_drain < 1) bat_drain = battery_config->battery_prev_drain;
+ battery_config->battery_prev_drain = bat_drain;
if (bat_filled > 0) bat_val = (100 * bat_level) / bat_filled;
else bat_val = 100;
@@ -799,19 +500,19 @@ _battery_linux_acpi_check(Battery *ef)
}
else if ((charging) || (discharging))
{
- ef->battery_prev_battery = 1;
+ battery_config->battery_prev_battery = 1;
stat->has_battery = 1;
if (charging)
{
stat->state = BATTERY_STATE_CHARGING;
- ef->alarm_triggered = 0;
+ battery_config->alarm_triggered = 0;
}
else if (discharging)
{
stat->state = BATTERY_STATE_DISCHARGING;
if (stat->level < 0.1)
{
- if (((hours * 60) + minutes) <= ef->conf->alarm)
+ if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
}
}
@@ -849,7 +550,7 @@ _battery_linux_acpi_check(Battery *ef)
}
static Status *
-_battery_linux_apm_check(Battery *ef)
+_battery_linux_apm_check(void)
{
FILE *f;
char s[256], s1[32], s2[32], s3[32], buf[4096];
@@ -888,7 +589,7 @@ _battery_linux_apm_check(Battery *ef)
}
- ef->battery_prev_battery = 1;
+ battery_config->battery_prev_battery = 1;
stat->has_battery = 1;
if (bat_val >= 0)
{
@@ -936,7 +637,7 @@ _battery_linux_apm_check(Battery *ef)
stat->time = strdup(buf);
if (stat->level < 0.1)
{
- if (((hours * 60) + minutes) <= ef->conf->alarm)
+ if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
}
}
@@ -981,7 +682,7 @@ axtoi(char *arg)
}
static Status *
-_battery_linux_powerbook_check(Battery *ef)
+_battery_linux_powerbook_check(void)
{
Ecore_List *bats;
char buf[4096], buf2[4096];
@@ -1116,14 +817,14 @@ _battery_linux_powerbook_check(Battery *ef)
if (charging)
{
stat->state = BATTERY_STATE_CHARGING;
- ef->alarm_triggered = 0;
+ battery_config->alarm_triggered = 0;
}
else if (discharging)
{
stat->state = BATTERY_STATE_DISCHARGING;
if (stat->level < 0.1)
{
- if (((hours * 60) + minutes) <= ef->conf->alarm)
+ if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
}
}
@@ -1151,7 +852,7 @@ _battery_linux_powerbook_check(Battery *ef)
#ifdef __FreeBSD__
static Status *
-_battery_bsd_acpi_check(Battery *ef)
+_battery_bsd_acpi_check(void)
{
/* Assumes only a single battery - I don't know how multiple batts
* are represented in sysctl */
@@ -1225,13 +926,13 @@ _battery_bsd_acpi_check(Battery *ef)
/* ERROR */
batteries = 1;
- if (ef->battery_prev_drain < 1)
- ef->battery_prev_drain = 1;
+ if (battery_config->battery_prev_drain < 1)
+ battery_config->battery_prev_drain = 1;
if (bat_drain < 1)
- bat_drain = ef->battery_prev_drain;
+ bat_drain = battery_config->battery_prev_drain;
- ef->battery_prev_drain = bat_drain;
+ battery_config->battery_prev_drain = bat_drain;
/*if (bat_filled > 0)
bat_val = (100 * bat_level) / bat_filled;
@@ -1267,19 +968,19 @@ _battery_bsd_acpi_check(Battery *ef)
else if ((state == BATTERY_STATE_CHARGING) ||
(state == BATTERY_STATE_DISCHARGING))
{
- ef->battery_prev_battery = 1;
+ battery_config->battery_prev_battery = 1;
stat->has_battery = 1;
if (state == BATTERY_STATE_CHARGING)
{
stat->state = BATTERY_STATE_CHARGING;
- ef->alarm_triggered = 0;
+ battery_config->alarm_triggered = 0;
}
else if (state == BATTERY_STATE_DISCHARGING)
{
stat->state = BATTERY_STATE_DISCHARGING;
if (stat->level < 0.1) /* Why this if condition */
{
- if (((hours * 60) + minutes) <= ef->conf->alarm)
+ if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
}
}
@@ -1317,7 +1018,7 @@ _battery_bsd_acpi_check(Battery *ef)
}
static Status *
-_battery_bsd_apm_check(Battery *ef)
+_battery_bsd_apm_check(void)
{
#ifdef __i386__
int ac_stat, bat_stat, bat_val, time_val;
@@ -1358,7 +1059,7 @@ _battery_bsd_apm_check(Battery *ef)
}
- ef->battery_prev_battery = 1;
+ battery_config->battery_prev_battery = 1;
stat->has_battery = 1;
if (ac_stat) /* Wallpowered */
@@ -1402,7 +1103,7 @@ _battery_bsd_apm_check(Battery *ef)
if (stat->level < 0.1) /* Why this if condition? */
{
- if (((hours * 60) + minutes) <= ef->conf->alarm)
+ if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
}
}
@@ -1419,7 +1120,7 @@ _battery_bsd_apm_check(Battery *ef)
* There is a good chance this will work with a UPS as well as a battery.
*/
static Status *
-_battery_darwin_check(Battery *ef)
+_battery_darwin_check(void)
{
const void *values;
int device_num;
@@ -1496,7 +1197,7 @@ _battery_darwin_check(Battery *ef)
/*
* A battery was found so move along based on that assumption.
*/
- ef->battery_prev_battery = 1;
+ battery_config->battery_prev_battery = 1;
stat->has_battery = 1;
/*
@@ -1540,7 +1241,7 @@ _battery_darwin_check(Battery *ef)
/*
* Check if an alarm should be raised.
*/
- if (currentval <= ef->conf->alarm)
+ if (currentval <= battery_config->alarm)
stat->alarm = 1;
}
else
@@ -1574,23 +1275,14 @@ _battery_darwin_check(Battery *ef)
#endif
static void
-_battery_face_level_set(Battery_Face *ef, double level)
+_battery_face_level_set(Instance *inst, double level)
{
Edje_Message_Float msg;
if (level < 0.0) level = 0.0;
else if (level > 1.0) level = 1.0;
msg.val = level;
- edje_object_message_send(ef->bat_object, EDJE_MESSAGE_FLOAT, 1, &msg);
-}
-
-static void
-_battery_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Battery_Face *face;
-
- face = data;
- e_gadman_mode_set(face->gmc->gadman, E_GADMAN_MODE_EDIT);
+ edje_object_message_send(inst->o_battery, EDJE_MESSAGE_FLOAT, 1, &msg);
}
static int
@@ -1626,18 +1318,113 @@ _battery_string_get(char *buf)
static void
_battery_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
{
- Battery_Face *face;
+ if (!battery_config) return;
+ if (battery_config->config_dialog) return;
+ _config_battery_module();
+}
+
+void
+_battery_config_updated(void)
+{
+ if (!battery_config) return;
+ ecore_timer_del(battery_config->battery_check_timer);
+ battery_config->battery_check_timer = ecore_timer_add(battery_config->poll_time,
+ _battery_cb_check, NULL);
+ _battery_cb_check(NULL);
+}
+
+/***************************************************************************/
+/**/
+/* module setup */
+EAPI E_Module_Api e_modapi =
+{
+ E_MODULE_API_VERSION,
+ "Battery"
+};
+
+EAPI void *
+e_modapi_init(E_Module *m)
+{
+ conf_edd = E_CONFIG_DD_NEW("Battery_Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+ E_CONFIG_VAL(D, T, poll_time, DOUBLE);
+ E_CONFIG_VAL(D, T, alarm, INT);
+
+ battery_config = e_config_domain_load("module.battery", conf_edd);
+ if (!battery_config)
+ {
+ battery_config = E_NEW(Config, 1);
+ battery_config->poll_time = 30.0;
+ battery_config->alarm = 30;
+ }
+ E_CONFIG_LIMIT(battery_config->poll_time, 0.5, 1000.0);
+ E_CONFIG_LIMIT(battery_config->alarm, 0, 60);
+
+ battery_config->battery_check_mode = CHECK_NONE;
+ battery_config->battery_prev_drain = 1;
+ battery_config->battery_prev_ac = -1;
+ battery_config->battery_prev_battery = -1;
+ battery_config->battery_check_timer = ecore_timer_add(battery_config->poll_time,
+ _battery_cb_check, NULL);
+ e_gadcon_provider_register(&_gadcon_class);
+ return 1;
+}
+
+EAPI int
+e_modapi_shutdown(E_Module *m)
+{
+ e_gadcon_provider_unregister(&_gadcon_class);
- face = data;
- if (!face) return;
- _config_battery_module(face->con, face->battery);
+ if (battery_config->config_dialog)
+ e_object_del(E_OBJECT(battery_config->config_dialog));
+ if (battery_config->battery_check_timer)
+ ecore_timer_del(battery_config->battery_check_timer);
+ if (battery_config->menu) e_object_del(E_OBJECT(battery_config->menu));
+ free(battery_config);
+ battery_config = NULL;
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
}
-void
-_battery_face_cb_config_updated(Battery *bat)
+EAPI int
+e_modapi_save(E_Module *m)
{
- /* Update Poll Time */
- ecore_timer_del(bat->battery_check_timer);
- bat->battery_check_timer = ecore_timer_add(bat->conf->poll_time, _battery_cb_check, bat);
+ e_config_domain_save("module.battery", conf_edd, battery_config);
+ return 1;
}
+EAPI int
+e_modapi_info(E_Module *m)
+{
+ char buf[4096];
+
+ snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
+ m->icon_file = strdup(buf);
+ return 1;
+}
+
+EAPI int
+e_modapi_about(E_Module *m)
+{
+ e_module_dialog_show(_("Enlightenment Battery Module"),
+ _("A basic battery meter that uses either"
+ "<hilight>ACPI</hilight> or <hilight>APM</hilight><br>"
+ "on Linux to monitor your battery and AC power adaptor<br>"
+ "status. This will work under Linux and FreeBSD and is only<br>"
+ "as accurate as your BIOS or kernel drivers."));
+ return 1;
+}
+
+EAPI int
+e_modapi_config(E_Module *m)
+{
+ if (!battery_config) return 0;
+ if (battery_config->config_dialog) return 0;
+ _config_battery_module();
+ return 1;
+}
+/**/
+/***************************************************************************/
diff --git a/src/modules/battery/e_mod_main.h b/src/modules/battery/e_mod_main.h
index 6420821cf..f16fde742 100644
--- a/src/modules/battery/e_mod_main.h
+++ b/src/modules/battery/e_mod_main.h
@@ -5,10 +5,6 @@
#define E_MOD_MAIN_H
typedef struct _Config Config;
-typedef struct _Config_Face Config_Face;
-typedef struct _Battery Battery;
-typedef struct _Battery_Face Battery_Face;
-
typedef struct _Status Status;
#define CHECK_NONE 0
@@ -18,44 +14,19 @@ typedef struct _Status Status;
struct _Config
{
- double poll_time;
- int alarm;
- Evas_List *faces;
-};
-
-struct _Config_Face
-{
- unsigned char enabled;
-};
-
-struct _Battery
-{
- E_Menu *config_menu;
- Evas_List *faces;
-
- Config *conf;
- int alarm_triggered;
-
- int battery_check_mode;
- Ecore_Timer *battery_check_timer;
- int battery_prev_drain;
- int battery_prev_ac;
- int battery_prev_battery;
+ /* saved * loaded config values */
+ double poll_time;
+ int alarm;
+ /* just config state */
E_Config_Dialog *config_dialog;
-};
-
-struct _Battery_Face
-{
- Battery *battery;
- E_Container *con;
-
- E_Menu *menu;
- Config_Face *conf;
-
- Evas_Object *bat_object;
- Evas_Object *event_object;
-
- E_Gadman_Client *gmc;
+ Evas_List *instances;
+ E_Menu *menu;
+ int alarm_triggered;
+ int battery_check_mode;
+ Ecore_Timer *battery_check_timer;
+ int battery_prev_drain;
+ int battery_prev_ac;
+ int battery_prev_battery;
};
#ifdef __FreeBSD__
@@ -95,6 +66,8 @@ EAPI int e_modapi_info (E_Module *m);
EAPI int e_modapi_about (E_Module *m);
EAPI int e_modapi_config (E_Module *m);
-void _battery_face_cb_config_updated(Battery *bat);
+void _config_battery_module(void);
+void _battery_config_updated(void);
+extern Config *battery_config;
#endif
diff --git a/src/modules/clock/Makefile.am b/src/modules/clock/Makefile.am
index 782c308ca..20a027de4 100644
--- a/src/modules/clock/Makefile.am
+++ b/src/modules/clock/Makefile.am
@@ -19,9 +19,7 @@ INCLUDES = -I. \
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
- e_mod_main.h \
- e_mod_config.c \
- e_mod_config.h
+ e_mod_main.h
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
diff --git a/src/modules/clock/e_mod_config.c b/src/modules/clock/e_mod_config.c
deleted file mode 100644
index c6fa3ad06..000000000
--- a/src/modules/clock/e_mod_config.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#include "e.h"
-#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
-
-struct _E_Config_Dialog_Data
-{
- int digital_style;
-};
-
-/* Protos */
-static void *_create_data(E_Config_Dialog *cfd);
-static void _free_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);
-static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
-
-void
-_config_clock_module(E_Container *con, Clock_Face *c)
-{
- E_Config_Dialog *cfd;
- E_Config_Dialog_View *v;
-
- v = E_NEW(E_Config_Dialog_View, 1);
-
- /* Dialog Methods */
- v->create_cfdata = _create_data;
- v->free_cfdata = _free_data;
- v->basic.apply_cfdata = _basic_apply_data;
- v->basic.create_widgets = _basic_create_widgets;
-
- /* Create The Dialog */
- cfd = e_config_dialog_new(con, _("Clock Configuration"), NULL, 0, v, c);
- c->config_dialog = cfd;
-}
-
-static void
-_fill_data(Clock_Face *clk, E_Config_Dialog_Data *cfdata)
-{
- cfdata->digital_style = clk->conf->digitalStyle;
-}
-
-static void *
-_create_data(E_Config_Dialog *cfd)
-{
- E_Config_Dialog_Data *cfdata;
- Clock_Face *cf;
-
- cf = cfd->data;
- cfdata = E_NEW(E_Config_Dialog_Data, 1);
- _fill_data(cf, cfdata);
- return cfdata;
-}
-
-static void
-_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
-{
- Clock_Face *c;
-
- c = cfd->data;
- c->config_dialog = NULL;
- free(cfdata);
-}
-
-static Evas_Object *
-_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
-{
- Evas_Object *o, *of, *ob;
- E_Radio_Group *rg;
-
- o = e_widget_list_add(evas, 0, 0);
- of = e_widget_framelist_add(evas, _("General Settings"), 0);
- rg = e_widget_radio_group_new(&(cfdata->digital_style));
- ob = e_widget_radio_add(evas, _("No Digital Display"), 0, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("12 Hour Display"), 1, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("24 Hour Display"), 2, rg);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
- return o;
-}
-
-static int
-_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
-{
- Clock_Face *clk;
-
- clk = cfd->data;
- e_border_button_bindings_ungrab_all();
- clk->conf->digitalStyle = cfdata->digital_style;
-
- e_border_button_bindings_grab_all();
- e_config_save_queue();
-
- _clock_face_cb_config_updated(clk);
- return 1;
-}
-
diff --git a/src/modules/clock/e_mod_config.h b/src/modules/clock/e_mod_config.h
deleted file mode 100644
index 7c53bdcce..000000000
--- a/src/modules/clock/e_mod_config.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifdef E_TYPEDEFS
-#else
-#ifndef E_MOD_CONFIG_H
-#define E_MOD_CONFIG_H
-#include "e_mod_main.h"
-void _config_clock_module(E_Container *con, Clock_Face *c);
-#endif
-#endif
diff --git a/src/modules/clock/e_mod_main.c b/src/modules/clock/e_mod_main.c
index bfa485c5b..b86b89b34 100644
--- a/src/modules/clock/e_mod_main.c
+++ b/src/modules/clock/e_mod_main.c
@@ -3,39 +3,93 @@
*/
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-/* TODO List:
- *
- */
+/***************************************************************************/
+/**/
+/* gadcon requirements */
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static void _gc_shutdown(E_Gadcon_Client *gcc);
+static void _gc_orient(E_Gadcon_Client *gcc);
+/* and actually define the gadcon class that this module provides (just 1) */
+static const E_Gadcon_Client_Class _gadcon_class =
+{
+ GADCON_CLIENT_CLASS_VERSION,
+ "clock",
+ {
+ _gc_init, _gc_shutdown, _gc_orient
+ }
+};
+/**/
+/***************************************************************************/
-/* module private routines */
-static Clock *_clock_new();
-static void _clock_shutdown(Clock *clock);
-static void _clock_config_menu_new(Clock *clock);
+/***************************************************************************/
+/**/
+/* actual module specifics */
-static Clock_Face *_clock_face_new(Clock *clock, E_Container *con);
-static void _clock_face_free(Clock_Face *face);
-/* static void _clock_face_enable(Clock_Face *face); */
-static void _clock_face_disable(Clock_Face *face);
-static void _clock_face_menu_new(Clock_Face *face);
-static void _clock_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
-static void _clock_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _clock_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _clock_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
+typedef struct _Instance Instance;
-static int _clock_count;
+struct _Instance
+{
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_clock;
+};
-static E_Config_DD *conf_edd;
-static E_Config_DD *conf_face_edd;
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
+{
+ Evas_Object *o;
+ E_Gadcon_Client *gcc;
+ Instance *inst;
+
+ inst = E_NEW(Instance, 1);
+
+ o = edje_object_add(gc->evas);
+ e_theme_edje_object_set(o, "base/theme/modules/clock",
+ "modules/clock/main");
+ evas_object_show(o);
+
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+
+ inst->gcc = gcc;
+ inst->o_clock = o;
+
+ e_gadcon_client_util_menu_attach(gcc);
+
+ return gcc;
+}
-const int
- DIGITAL_STYLE_NONE = 0,
- DIGITAL_STYLE_12HOUR = 1,
- DIGITAL_STYLE_24HOUR = 2
- ;
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
+{
+ Instance *inst;
+
+ inst = gcc->data;
+ evas_object_del(inst->o_clock);
+ free(inst);
+}
+
+static void
+_gc_orient(E_Gadcon_Client *gcc)
+{
+ Instance *inst;
+
+ inst = gcc->data;
+ e_gadcon_client_aspect_set(gcc, 16, 16);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
+}
+/**/
+/***************************************************************************/
+
+/***************************************************************************/
+/**/
+
+/**/
+/***************************************************************************/
-/* public module routines. all modules must have these */
+/***************************************************************************/
+/**/
+/* module setup */
EAPI E_Module_Api e_modapi =
{
E_MODULE_API_VERSION,
@@ -45,37 +99,20 @@ EAPI E_Module_Api e_modapi =
EAPI void *
e_modapi_init(E_Module *module)
{
- Clock *clock;
-
- /* actually init clock */
- clock = _clock_new();
- module->config_menu = clock->config_menu;
- return clock;
+ e_gadcon_provider_register(&_gadcon_class);
+ return 1;
}
EAPI int
e_modapi_shutdown(E_Module *module)
{
- Clock *clock;
-
- if (module->config_menu)
- module->config_menu = NULL;
-
- clock = module->data;
- if (clock)
- {
- _clock_shutdown(clock);
- }
+ e_gadcon_provider_unregister(&_gadcon_class);
return 1;
}
EAPI int
e_modapi_save(E_Module *module)
{
- Clock *clock;
-
- clock = module->data;
- e_config_domain_save("module.clock", conf_edd, clock->conf);
return 1;
}
@@ -96,354 +133,3 @@ e_modapi_about(E_Module *module)
_("A simple module to give E17 a clock."));
return 1;
}
-
-EAPI int
-e_modapi_config(E_Module *m)
-{
- Clock *e;
- Clock_Face *face;
-
- e = m->data;
- if (!e) return 0;
- if (!e->faces) return 0;
- face = e->faces->data;
- if (!face) return 0;
- _config_clock_module(face->con, face);
- return 1;
-}
-
-/* module private routines */
-static Clock *
-_clock_new()
-{
- Clock *clock;
- Evas_List *managers, *l, *l2, *cl;
- E_Menu_Item *mi;
-
- _clock_count = 0;
- clock = E_NEW(Clock, 1);
- if (!clock) return NULL;
-
- conf_face_edd = E_CONFIG_DD_NEW("Clock_Config_Face", Config_Face);
-#undef T
-#undef D
-#define T Config_Face
-#define D conf_face_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
- E_CONFIG_VAL(D, T, digitalStyle, INT);
-
- conf_edd = E_CONFIG_DD_NEW("Clock_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D conf_edd
- E_CONFIG_LIST(D, T, faces, conf_face_edd);
-
- clock->conf = e_config_domain_load("module.clock", conf_edd);
- if (!clock->conf)
- {
- clock->conf = E_NEW(Config, 1);
- }
-
- _clock_config_menu_new(clock);
-
- managers = e_manager_list();
- cl = clock->conf->faces;
- for (l = managers; l; l = l->next)
- {
- E_Manager *man;
-
- man = l->data;
- for (l2 = man->containers; l2; l2 = l2->next)
- {
- E_Container *con;
- Clock_Face *face;
-
- con = l2->data;
- face = _clock_face_new(clock, con);
- if (face)
- {
- face->clock = clock;
- clock->faces = evas_list_append(clock->faces, face);
- /* Config */
- if (!cl)
- {
- face->conf = E_NEW(Config_Face, 1);
- face->conf->enabled = 1;
- face->conf->digitalStyle = DIGITAL_STYLE_NONE;
- clock->conf->faces = evas_list_append(clock->conf->faces, face->conf);
- }
- else
- {
- face->conf = cl->data;
- cl = cl->next;
- }
-
- _clock_face_cb_config_updated(face);
-
- /* Menu */
- /* This menu must be initialized after conf */
- _clock_face_menu_new(face);
-
- mi = e_menu_item_new(clock->config_menu);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _clock_face_cb_menu_configure, face);
-
- mi = e_menu_item_new(clock->config_menu);
- e_menu_item_label_set(mi, con->name);
-
- e_menu_item_submenu_set(mi, face->menu);
-
- /* Setup */
- if (!face->conf->enabled)
- _clock_face_disable(face);
- }
- }
- }
- return clock;
-}
-
-static void
-_clock_shutdown(Clock *clock)
-{
- Evas_List *list;
-
- E_CONFIG_DD_FREE(conf_edd);
- E_CONFIG_DD_FREE(conf_face_edd);
-
- for (list = clock->faces; list; list = list->next)
- _clock_face_free(list->data);
- evas_list_free(clock->faces);
-
- e_object_del(E_OBJECT(clock->config_menu));
-
- evas_list_free(clock->conf->faces);
- free(clock->conf);
- free(clock);
-}
-
-static void
-_clock_config_menu_new(Clock *clock)
-{
- clock->config_menu = e_menu_new();
-}
-
-static Clock_Face *
-_clock_face_new(Clock *clock, E_Container *con)
-{
- Clock_Face *face;
- Evas_Object *o;
- Evas_Coord x, y, w, h;
- E_Gadman_Policy policy;
-
- face = E_NEW(Clock_Face, 1);
- if (!face) return NULL;
-
- face->con = con;
- e_object_ref(E_OBJECT(con));
-
- evas_event_freeze(con->bg_evas);
- o = edje_object_add(con->bg_evas);
- face->clock_object = o;
-
- e_theme_edje_object_set(o, "base/theme/modules/clock",
- "modules/clock/main");
- evas_object_show(o);
-
- o = evas_object_rectangle_add(con->bg_evas);
- face->event_object = o;
- evas_object_layer_set(o, 2);
- evas_object_repeat_events_set(o, 1);
- evas_object_color_set(o, 0, 0, 0, 0);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _clock_face_cb_mouse_down, face);
- evas_object_show(o);
-
- evas_object_resize(face->clock_object, 200, 200);
- edje_object_calc_force(face->clock_object);
- edje_object_part_geometry_get(face->clock_object, "main", &x, &y, &w, &h);
- face->inset.l = x;
- face->inset.r = 200 - (x + w);
- face->inset.t = y;
- face->inset.b = 200 - (y + h);
-
- face->gmc = e_gadman_client_new(con->gadman);
- e_gadman_client_domain_set(face->gmc, "module.clock", _clock_count++);
-
- policy = E_GADMAN_POLICY_ANYWHERE |
- E_GADMAN_POLICY_HMOVE |
- E_GADMAN_POLICY_VMOVE |
- E_GADMAN_POLICY_HSIZE |
- E_GADMAN_POLICY_VSIZE;
-
- e_gadman_client_policy_set(face->gmc, policy);
- e_gadman_client_min_size_set(face->gmc, 4, 4);
- e_gadman_client_max_size_set(face->gmc, 512, 512);
- e_gadman_client_auto_size_set(face->gmc,
- 40 + (face->inset.l + face->inset.r),
- 40 + (face->inset.t + face->inset.b));
- e_gadman_client_align_set(face->gmc, 1.0, 1.0);
- e_gadman_client_aspect_set(face->gmc, 1.0, 1.0);
- e_gadman_client_padding_set(face->gmc,
- face->inset.l, face->inset.r,
- face->inset.t, face->inset.b);
- e_gadman_client_resize(face->gmc,
- 40 + (face->inset.l + face->inset.r),
- 40 + (face->inset.t + face->inset.b));
- e_gadman_client_change_func_set(face->gmc, _clock_face_cb_gmc_change, face);
- e_gadman_client_load(face->gmc);
-
- evas_event_thaw(con->bg_evas);
-
- return face;
-}
-
-static void
-_clock_face_free(Clock_Face *face)
-{
- if (face->config_dialog)
- {
- e_object_del(E_OBJECT(face->config_dialog));
- face->config_dialog = NULL;
- }
- e_object_unref(E_OBJECT(face->con));
- e_object_del(E_OBJECT(face->gmc));
- evas_object_del(face->clock_object);
- evas_object_del(face->event_object);
- e_object_del(E_OBJECT(face->menu));
-
- free(face->conf);
- free(face);
- _clock_count--;
-}
-
-/*
-static void
-_clock_face_enable(Clock_Face *face)
-{
- face->conf->enabled = 1;
- evas_object_show(face->clock_object);
- evas_object_show(face->event_object);
- e_config_save_queue();
-}
-*/
-
-static void
-_clock_face_disable(Clock_Face *face)
-{
- face->conf->enabled = 0;
- evas_object_hide(face->clock_object);
- evas_object_hide(face->event_object);
- e_config_save_queue();
-}
-
-static void
-_clock_face_menu_new(Clock_Face *face)
-{
- E_Menu *mn;
- E_Menu_Item *mi;
-
- mn = e_menu_new();
- face->menu = mn;
-
- /* Enabled */
- /*
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Enabled"));
- e_menu_item_check_set(mi, 1);
- if (face->conf->enabled) e_menu_item_toggle_set(mi, 1);
- e_menu_item_callback_set(mi, _clock_face_cb_menu_enabled, face);
- */
-
- /* Config */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _clock_face_cb_menu_configure, face);
-
- /* Edit */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Edit Mode"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _clock_face_cb_menu_edit, face);
-}
-
-static void
-_clock_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
-{
- Clock_Face *face;
- Evas_Coord x, y, w, h;
-
- face = data;
- switch (change)
- {
- case E_GADMAN_CHANGE_MOVE_RESIZE:
- e_gadman_client_geometry_get(face->gmc, &x, &y, &w, &h);
- evas_object_move(face->clock_object, x, y);
- evas_object_move(face->event_object, x, y);
- evas_object_resize(face->clock_object, w, h);
- evas_object_resize(face->event_object, w, h);
- break;
- case E_GADMAN_CHANGE_RAISE:
- evas_object_raise(face->clock_object);
- evas_object_raise(face->event_object);
- break;
- case E_GADMAN_CHANGE_EDGE:
- case E_GADMAN_CHANGE_ZONE:
- /* FIXME
- * Must we do something here?
- */
- break;
- }
-}
-
-static void
-_clock_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Clock_Face *face;
- Evas_Event_Mouse_Down *ev;
-
- face = data;
- ev = event_info;
- if (ev->button == 3)
- {
- e_menu_activate_mouse(face->menu, e_zone_current_get(face->con),
- ev->output.x, ev->output.y, 1, 1,
- E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
- e_util_container_fake_mouse_up_all_later(face->con);
- }
-}
-
-static void
-_clock_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Clock_Face *face;
-
- face = data;
- e_gadman_mode_set(face->gmc->gadman, E_GADMAN_MODE_EDIT);
-}
-
-static void
-_clock_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Clock_Face *face;
-
- face = data;
- if (!face) return;
- _config_clock_module(face->con, face);
-}
-
-void
-_clock_face_cb_config_updated(void *data)
-{
- Clock_Face *face;
- char buf[2];
-
- face = data;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "%i", face->conf->digitalStyle);
- edje_object_part_text_set(face->clock_object, "digitalStyle", buf);
-
-}
-
diff --git a/src/modules/clock/e_mod_main.h b/src/modules/clock/e_mod_main.h
index 891f453c6..29677a219 100644
--- a/src/modules/clock/e_mod_main.h
+++ b/src/modules/clock/e_mod_main.h
@@ -4,48 +4,6 @@
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
-typedef struct _Config Config;
-typedef struct _Config_Face Config_Face;
-typedef struct _Clock Clock;
-typedef struct _Clock_Face Clock_Face;
-
-struct _Config
-{
- Evas_List *faces;
-};
-
-struct _Config_Face
-{
- unsigned char enabled;
- int digitalStyle;
-};
-
-struct _Clock
-{
- Evas_List *faces;
- E_Menu *config_menu;
-
- Config *conf;
-};
-
-struct _Clock_Face
-{
- E_Container *con;
- E_Menu *menu;
- Config_Face *conf;
- Clock *clock;
-
- struct {
- Evas_Coord l, r, t, b;
- } inset;
-
- Evas_Object *clock_object;
- Evas_Object *event_object;
-
- E_Gadman_Client *gmc;
- E_Config_Dialog *config_dialog;
-};
-
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *module);
@@ -55,6 +13,4 @@ EAPI int e_modapi_info (E_Module *module);
EAPI int e_modapi_about (E_Module *module);
EAPI int e_modapi_config (E_Module *module);
-void _clock_face_cb_config_updated(void *data);
-
#endif
diff --git a/src/modules/cpufreq/e_mod_main.c b/src/modules/cpufreq/e_mod_main.c
index b5b7f3f66..d2a79813d 100644
--- a/src/modules/cpufreq/e_mod_main.c
+++ b/src/modules/cpufreq/e_mod_main.c
@@ -1,296 +1,302 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
-#include <Ecore.h>
-#include <errno.h>
-#include <ctype.h>
+#include "e.h"
#include "e_mod_main.h"
-#include "config.h"
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
-/* FIXME: check permissions (can execute) setfreq before trying
- * FIXME: display throttling state ???
- * FIXME: handle multiple cpu's (yes it's likely rare - but possible)
- */
+/***************************************************************************/
+/**/
+/* gadcon requirements */
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static void _gc_shutdown(E_Gadcon_Client *gcc);
+static void _gc_orient(E_Gadcon_Client *gcc);
+/* and actually define the gadcon class that this module provides (just 1) */
+static const E_Gadcon_Client_Class _gadcon_class =
+{
+ GADCON_CLIENT_CLASS_VERSION,
+ "cpufreq",
+ {
+ _gc_init, _gc_shutdown, _gc_orient
+ }
+};
+/**/
+/***************************************************************************/
-static Cpufreq *_cpufreq_new(E_Module *module);
-static void _cpufreq_free(Cpufreq *cpufreq);
-static void _cpufreq_set_governor(Cpufreq *cpufreq, const char *governor);
-static void _cpufreq_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_restore_governor(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_governor(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_config_menu_new(Cpufreq *cpufreq);
-static int _cpufreq_cb_check(void *data);
-
-static Status * _cpufreq_status_new();
-static void _cpufreq_status_free(Status *e);
-static int _cpufreq_status_check_available(Status *e);
-static int _cpufreq_status_check_current(Status *e);
-static int _cpufreq_cb_sort(void *item1, void *item2);
-
-static Cpufreq_Face *_cpufreq_face_new(E_Container *con, Cpufreq *owner);
-static void _cpufreq_face_free(Cpufreq_Face *face);
-static void _cpufreq_face_menu_new(Cpufreq_Face *face);
-static void _cpufreq_face_enable(Cpufreq_Face *face);
-static void _cpufreq_face_disable(Cpufreq_Face *face);
-static void _cpufreq_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
-static void _cpufreq_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _cpufreq_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _cpufreq_face_update_available(Cpufreq_Face *face);
-static void _cpufreq_face_update_current(Cpufreq_Face *face);
-static void _cpufreq_face_cb_set_frequency(void *data, Evas_Object *o, const char *emission, const char *source);
-static void _cpufreq_face_cb_set_governor(void *data, Evas_Object *o, const char *emission, const char *source);
-
-static E_Config_DD *conf_edd;
-static E_Config_DD *conf_face_edd;
-
-static int cpufreq_count;
-
-/* public module routines */
-EAPI E_Module_Api e_modapi =
+/***************************************************************************/
+/**/
+/* actual module specifics */
+
+typedef struct _Instance Instance;
+
+struct _Instance
{
- E_MODULE_API_VERSION,
- "Cpufreq"
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_cpu;
};
-EAPI void *
-e_modapi_init(E_Module *module)
+static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _menu_cb_post(void *data, E_Menu *m);
+static void _cpufreq_set_governor(const char *governor);
+static void _cpufreq_set_frequency(int frequency);
+static int _cpufreq_cb_check(void *data);
+static Status *_cpufreq_status_new();
+static void _cpufreq_status_free(Status *s);
+static int _cpufreq_status_check_available(Status *s);
+static int _cpufreq_status_check_current(Status *s);
+static int _cpufreq_cb_sort(void *item1, void *item2);
+static void _cpufreq_face_update_available(Instance *inst);
+static void _cpufreq_face_update_current(Instance *inst);
+static void _cpufreq_face_cb_set_frequency(void *data, Evas_Object *o, const char *emission, const char *source);
+static void _cpufreq_face_cb_set_governor(void *data, Evas_Object *o, const char *emission, const char *source);
+
+static void _cpufreq_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_restore_governor(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_governor(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi);
+
+static E_Config_DD *conf_edd = NULL;
+
+Config *cpufreq_config = NULL;
+
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
{
- Cpufreq *freq;
+ Evas_Object *o;
+ E_Gadcon_Client *gcc;
+ Instance *inst;
- freq = _cpufreq_new(module);
- module->config_menu = freq->config_menu;
- return freq;
+ inst = E_NEW(Instance, 1);
+
+ o = edje_object_add(gc->evas);
+ e_theme_edje_object_set(o, "base/theme/modules/cpufreq",
+ "modules/cpufreq/main");
+ edje_object_signal_callback_add(o, "next_governor", "governor", _cpufreq_face_cb_set_governor, NULL);
+ edje_object_signal_callback_add(o, "increase_frequency", "frequency", _cpufreq_face_cb_set_frequency, NULL);
+ edje_object_signal_callback_add(o, "decrease_frequency", "frequency", _cpufreq_face_cb_set_frequency, NULL);
+
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+
+ inst->gcc = gcc;
+ inst->o_cpu = o;
+
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
+ _button_cb_mouse_down, inst);
+ cpufreq_config->instances = evas_list_append(cpufreq_config->instances, inst);
+ if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status);
+ cpufreq_config->status = _cpufreq_status_new();
+ _cpufreq_cb_check(NULL);
+ _cpufreq_face_update_available(inst);
+ return gcc;
}
-EAPI int
-e_modapi_shutdown(E_Module *module)
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
{
- Cpufreq *cpufreq;
-
- if (module->config_menu)
- module->config_menu = NULL;
-
- cpufreq = module->data;
- if (cpufreq)
- _cpufreq_free(cpufreq);
+ Instance *inst;
- return 1;
+ inst = gcc->data;
+ cpufreq_config->instances = evas_list_remove(cpufreq_config->instances, inst);
+ evas_object_del(inst->o_cpu);
+ free(inst);
}
-EAPI int
-e_modapi_save(E_Module *module)
+static void
+_gc_orient(E_Gadcon_Client *gcc)
{
- Cpufreq *e;
-
- e = module->data;
- e_config_domain_save("module.cpufreq", conf_edd, e->conf);
- return 1;
+ Instance *inst;
+
+ inst = gcc->data;
+ e_gadcon_client_aspect_set(gcc, 16, 16);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
+/**/
+/***************************************************************************/
-EAPI int
-e_modapi_info(E_Module *module)
+/***************************************************************************/
+/**/
+static void
+_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- char buf[4096];
+ Instance *inst;
+ Evas_Event_Mouse_Down *ev;
- snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(module));
- module->icon_file = strdup(buf);
- return 1;
-}
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!cpufreq_config->menu))
+ {
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int cx, cy, cw, ch;
+ Evas_List *l;
+ char buf[256];
+
+ mn = e_menu_new();
+ cpufreq_config->menu_poll = mn;
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Fast (0.5 sec)"));
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ if (cpufreq_config->poll_time <= 0.5) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_fast, NULL);
-EAPI int
-e_modapi_about(E_Module *module)
-{
- e_module_dialog_show(_("CPU Frequency Controller Module"),
- _("A simple module to control the frequency of the system CPU.<br>"
- "This is especially useful to save power on laptops."));
- return 1;
-}
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Medium (1 sec)"));
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ if (cpufreq_config->poll_time > 0.5) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_medium, NULL);
-static Cpufreq *
-_cpufreq_new(E_Module *module)
-{
- Cpufreq *e;
- Evas_List *managers, *l, *l2, *cl;
- E_Menu_Item *mi;
- char buf[4096];
-
- cpufreq_count = 0;
- e = E_NEW(Cpufreq, 1);
- if (!e) return NULL;
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Normal (2 sec)"));
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ if (cpufreq_config->poll_time >= 2.0) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_normal, NULL);
- conf_face_edd = E_CONFIG_DD_NEW("Cpufreq_Config_Face", Config_Face);
-#undef T
-#undef D
-#define T Config_Face
-#define D conf_face_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Slow (5 sec)"));
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ if (cpufreq_config->poll_time >= 5.0) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_slow, NULL);
- conf_edd = E_CONFIG_DD_NEW("Cpufreq_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D conf_edd
- E_CONFIG_VAL(D, T, poll_time, DOUBLE);
- E_CONFIG_LIST(D, T, faces, conf_face_edd);
- E_CONFIG_VAL(D, T, restore_governor, INT);
- E_CONFIG_VAL(D, T, governor, STR);
-
- e->conf = e_config_domain_load("module.cpufreq", conf_edd);
- if (!e->conf)
- {
- e->conf = E_NEW(Config, 1);
- e->conf->poll_time = 2.0;
- e->conf->restore_governor = 0;
- e->conf->governor = NULL;
- }
- E_CONFIG_LIMIT(e->conf->poll_time, 0.5, 60.0);
-#ifdef __FreeBSD__
- /* does e_module_dir_get(module) work correctly in linux??? - yes it does... what's wrong in bsd? */
- snprintf(buf, sizeof(buf), "%s/%s/cpufreq/freqset", e_module_dir_get(module), MODULE_ARCH);
-#else
- snprintf(buf, sizeof(buf), "%s/%s/freqset", e_module_dir_get(module), MODULE_ARCH);
-#endif
- buf[sizeof(buf) - 1] = 0;
- e->set_exe_path = strdup(buf);
- e->frequency_check_timer = ecore_timer_add(e->conf->poll_time, _cpufreq_cb_check, e);
- e->status = _cpufreq_status_new();
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Very Slow (30 sec)"));
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ if (cpufreq_config->poll_time >= 30.0) e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_very_slow, NULL);
- _cpufreq_status_check_available(e->status);
- if ((e->conf->restore_governor) && (e->conf->governor))
- {
- /* If the governor is available, restore it */
- for (l = e->status->governors; l; l = l->next)
+ if (cpufreq_config->status->governors)
{
- if (!strcmp(l->data, e->conf->governor))
- _cpufreq_set_governor(e, e->conf->governor);
+ mn = e_menu_new();
+ cpufreq_config->menu_governor = mn;
+
+ for (l = cpufreq_config->status->governors; l; l = l->next)
+ {
+ mi = e_menu_item_new(mn);
+ if (!strcmp(l->data, "userspace"))
+ e_menu_item_label_set(mi, _("Manual"));
+ else if (!strcmp(l->data, "ondemand"))
+ e_menu_item_label_set(mi, _("Automatic"));
+ else if (!strcmp(l->data, "conservative"))
+ e_menu_item_label_set(mi, _("Lower Power Automatic"));
+ else if (!strcmp(l->data, "powersave"))
+ e_menu_item_label_set(mi, _("Minimum Speed"));
+ else if (!strcmp(l->data, "performance"))
+ e_menu_item_label_set(mi, _("Maximum Speed"));
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ e_object_data_set(E_OBJECT(mi), l->data);
+ if (!strcmp(cpufreq_config->status->cur_governor, l->data))
+ e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_governor, NULL);
+ }
}
- }
- _cpufreq_config_menu_new(e);
-
- managers = e_manager_list();
- cl = e->conf->faces;
- for (l = managers; l; l = l->next)
- {
- E_Manager *man;
-
- man = l->data;
- for (l2 = man->containers; l2; l2 = l2->next)
- {
- E_Container *con;
- Cpufreq_Face *ef;
- con = l2->data;
- ef = _cpufreq_face_new(con, e);
- if (ef)
+ if ((cpufreq_config->status->frequencies) &&
+ (cpufreq_config->status->can_set_frequency))
+ {
+ mn = e_menu_new();
+ cpufreq_config->menu_frequency = mn;
+
+ for (l = cpufreq_config->status->frequencies; l; l = l->next)
{
- e->faces = evas_list_append(e->faces, ef);
-
- if (!cl)
- {
- ef->conf = E_NEW(Config_Face, 1);
- ef->conf->enabled = 1;
- e->conf->faces = evas_list_append(e->conf->faces, ef->conf);
- }
- else
- {
- ef->conf = cl->data;
- cl = cl->next;
- }
-
- _cpufreq_face_menu_new(ef);
-
- /* Add poll time menu to this face */
- mi = e_menu_item_new(ef->menu);
- e_menu_item_label_set(mi, _("Set Poll Time"));
- e_menu_item_submenu_set(mi, e->config_menu_poll);
-
- if (e->menu_governor)
- {
- mi = e_menu_item_new(ef->menu);
- e_menu_item_label_set(mi, _("Restore Controller on Startup"));
- e_menu_item_check_set(mi, 1);
- e_menu_item_toggle_set(mi, e->conf->restore_governor);
- e_menu_item_callback_set(mi, _cpufreq_menu_restore_governor, e);
-
- /* Add governors menu to this face */
- mi = e_menu_item_new(ef->menu);
- e_menu_item_label_set(mi, _("Set Controller"));
- e_menu_item_submenu_set(mi, e->menu_governor);
- }
+ int frequency;
- if (e->menu_frequency)
- {
- /* Add frequency menu to this face */
- mi = e_menu_item_new(ef->menu);
- e_menu_item_label_set(mi, _("Set Speed"));
- e_menu_item_submenu_set(mi, e->menu_frequency);
- }
-
- /* Add this face to the main menu */
- mi = e_menu_item_new(e->config_menu);
- e_menu_item_label_set(mi, con->name);
- e_menu_item_submenu_set(mi, ef->menu);
-
- if (!ef->conf->enabled)
- _cpufreq_face_disable(ef);
+ frequency = (int)l->data;
+ mi = e_menu_item_new(mn);
+ if (frequency < 1000000)
+ snprintf(buf, sizeof(buf), _("%i MHz"), frequency / 1000);
+ else
+ snprintf(buf, sizeof(buf), _("%i.%i GHz"),
+ frequency / 1000000, (frequency % 1000000) / 100000);
+ buf[sizeof(buf) - 1] = 0;
+ e_menu_item_label_set(mi, buf);
+ e_menu_item_radio_set(mi, 1);
+ e_menu_item_radio_group_set(mi, 1);
+ e_object_data_set(E_OBJECT(mi), l->data);
+ if (cpufreq_config->status->cur_frequency == frequency)
+ e_menu_item_toggle_set(mi, 1);
+ e_menu_item_callback_set(mi, _cpufreq_menu_frequency, NULL);
}
}
- }
+
+ mn = e_menu_new();
+ cpufreq_config->menu = mn;
+ e_menu_post_deactivate_callback_set(mn, _menu_cb_post, inst);
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Time Between Updates"));
+ e_menu_item_submenu_set(mi, cpufreq_config->menu_poll);
- _cpufreq_cb_check(e);
+ if (cpufreq_config->menu_governor)
+ {
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Restore CPU Power Policy"));
+ e_menu_item_check_set(mi, 1);
+ e_menu_item_toggle_set(mi, cpufreq_config->restore_governor);
+ e_menu_item_callback_set(mi, _cpufreq_menu_restore_governor, NULL);
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Set CPU Power Policy"));
+ e_menu_item_submenu_set(mi, cpufreq_config->menu_governor);
+ }
+
+ if (cpufreq_config->menu_frequency)
+ {
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Set CPU Speed"));
+ e_menu_item_submenu_set(mi, cpufreq_config->menu_frequency);
+ }
+
+ e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &cx, &cy, &cw, &ch);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ cx + ev->output.x, cy + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ }
- return e;
}
static void
-_cpufreq_free(Cpufreq *e)
+_menu_cb_post(void *data, E_Menu *m)
{
- Evas_List *l;
-
- E_CONFIG_DD_FREE(conf_edd);
- E_CONFIG_DD_FREE(conf_face_edd);
-
- for (l = e->faces; l; l = l->next)
- _cpufreq_face_free(l->data);
- evas_list_free(e->faces);
-
- e_object_del(E_OBJECT(e->config_menu));
- e_object_del(E_OBJECT(e->config_menu_poll));
- if (e->menu_governor)
- e_object_del(E_OBJECT(e->menu_governor));
- if (e->menu_frequency)
- e_object_del(E_OBJECT(e->menu_frequency));
-
- ecore_timer_del(e->frequency_check_timer);
-
- _cpufreq_status_free(e->status);
-
- evas_list_free(e->conf->faces);
- free(e->set_exe_path);
- if (e->conf->governor) evas_stringshare_del(e->conf->governor);
- free(e->conf);
- free(e);
+ if (!cpufreq_config->menu) return;
+ e_object_del(E_OBJECT(cpufreq_config->menu));
+ cpufreq_config->menu = NULL;
+ if (cpufreq_config->menu_poll) e_object_del(E_OBJECT(cpufreq_config->menu_poll));
+ cpufreq_config->menu_poll = NULL;
+ if (cpufreq_config->menu_governor) e_object_del(E_OBJECT(cpufreq_config->menu_governor));
+ cpufreq_config->menu_governor = NULL;
+ if (cpufreq_config->menu_frequency) e_object_del(E_OBJECT(cpufreq_config->menu_frequency));
+ cpufreq_config->menu_frequency = NULL;
}
static void
-_cpufreq_set_governor(Cpufreq *e, const char *governor)
+_cpufreq_set_governor(const char *governor)
{
- /* TODO: Use ecore_exe */
char buf[4096];
int ret;
snprintf(buf, sizeof(buf),
- "%s %s %s", e->set_exe_path, "governor", governor);
+ "%s %s %s", cpufreq_config->set_exe_path, "governor", governor);
ret = system(buf);
if (ret != 0)
{
@@ -300,8 +306,9 @@ _cpufreq_set_governor(Cpufreq *e, const char *governor)
if (!dia) return;
e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
e_dialog_icon_set(dia, "enlightenment/e", 64);
- e_dialog_text_set(dia, _("There was an error trying to set the cpu frequency<br>"
- "governor via the module's setfreq utility."));
+ e_dialog_text_set(dia, _("There was an error trying to set the<br>"
+ "cpu frequency governor via the module's<br>"
+ "setfreq utility."));
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
e_win_centered_set(dia->win, 1);
e_dialog_show(dia);
@@ -309,7 +316,7 @@ _cpufreq_set_governor(Cpufreq *e, const char *governor)
}
static void
-_cpufreq_set_frequency(Cpufreq *e, int frequency)
+_cpufreq_set_frequency(int frequency)
{
char buf[4096];
int ret;
@@ -317,10 +324,7 @@ _cpufreq_set_frequency(Cpufreq *e, int frequency)
#ifdef __FreeBSD__
frequency /= 1000;
#endif
- snprintf(buf, sizeof(buf),
- "%s %s %i", e->set_exe_path, "frequency", frequency);
- ret = system(buf);
- if (ret != 0)
+ if (!cpufreq_config->status->can_set_frequency)
{
E_Dialog *dia;
@@ -328,274 +332,60 @@ _cpufreq_set_frequency(Cpufreq *e, int frequency)
if (!dia) return;
e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
e_dialog_icon_set(dia, "enlightenment/e", 64);
- e_dialog_text_set(dia, _("There was an error trying to set the cpu frequency<br>"
- "setting via the module's setfreq utility."));
+ e_dialog_text_set(dia, _("Your kernel does not support setting the<br>"
+ "CPU frequency at all. You may be missing<br>"
+ "Kernel modules or features, or your CPU<br>"
+ "simply does not support this feature."));
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
e_win_centered_set(dia->win, 1);
e_dialog_show(dia);
+ return;
}
-}
-
-static void
-_cpufreq_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
-
- e = data;
- e->conf->poll_time = 0.5;
- ecore_timer_del(e->frequency_check_timer);
- e->frequency_check_timer = ecore_timer_add(e->conf->poll_time, _cpufreq_cb_check, e);
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
-
- e = data;
- e->conf->poll_time = 1.0;
- ecore_timer_del(e->frequency_check_timer);
- e->frequency_check_timer = ecore_timer_add(e->conf->poll_time, _cpufreq_cb_check, e);
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
-
- e = data;
- e->conf->poll_time = 2.0;
- ecore_timer_del(e->frequency_check_timer);
- e->frequency_check_timer = ecore_timer_add(e->conf->poll_time, _cpufreq_cb_check, e);
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
-
- e = data;
- e->conf->poll_time = 5.0;
- ecore_timer_del(e->frequency_check_timer);
- e->frequency_check_timer = ecore_timer_add(e->conf->poll_time, _cpufreq_cb_check, e);
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
-
- e = data;
- e->conf->poll_time = 30.0;
- ecore_timer_del(e->frequency_check_timer);
- e->frequency_check_timer = ecore_timer_add(e->conf->poll_time, _cpufreq_cb_check, e);
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_restore_governor(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
-
- e = data;
- e->conf->restore_governor = e_menu_item_toggle_get(mi);
- if ((!e->conf->governor) || strcmp(e->status->cur_governor, e->conf->governor))
- {
- if (e->conf->governor) evas_stringshare_del(e->conf->governor);
- e->conf->governor = evas_stringshare_add(e->status->cur_governor);
- }
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_governor(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Cpufreq *e;
- char *governor;
-
- e = data;
- governor = e_object_data_get(E_OBJECT(mi));
- if (governor)
- {
- _cpufreq_set_governor(e, governor);
- if (e->conf->governor) evas_stringshare_del(e->conf->governor);
- e->conf->governor = evas_stringshare_add(governor);
- }
- e_config_save_queue();
-}
-
-static void
-_cpufreq_menu_frequency(void * data, E_Menu *m, E_Menu_Item *mi)
-{
- int frequency;
-
- frequency = (int) e_object_data_get(E_OBJECT(mi));
- if (frequency > 0)
- {
- _cpufreq_set_frequency(data, frequency);
- }
-}
-
-static void
-_cpufreq_config_menu_new(Cpufreq *e)
-{
- E_Menu *mn;
- E_Menu_Item *mi;
- Evas_List *l;
- char buf[256];
-
- mn = e_menu_new();
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Check Fast (0.5 sec)"));
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- if (e->conf->poll_time <= 0.5) e_menu_item_toggle_set(mi, 1);
- e_menu_item_callback_set(mi, _cpufreq_menu_fast, e);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Check Medium (1 sec)"));
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- if (e->conf->poll_time > 0.5) e_menu_item_toggle_set(mi, 1);
- e_menu_item_callback_set(mi, _cpufreq_menu_medium, e);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Check Normal (2 sec)"));
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- if (e->conf->poll_time >= 2.0) e_menu_item_toggle_set(mi, 1);
- e_menu_item_callback_set(mi, _cpufreq_menu_normal, e);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Check Slow (5 sec)"));
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- if (e->conf->poll_time >= 5.0) e_menu_item_toggle_set(mi, 1);
- e_menu_item_callback_set(mi, _cpufreq_menu_slow, e);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Check Very Slow (30 sec)"));
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- if (e->conf->poll_time >= 30.0) e_menu_item_toggle_set(mi, 1);
- e_menu_item_callback_set(mi, _cpufreq_menu_very_slow, e);
-
- e->config_menu_poll = mn;
-
- if (e->status->governors)
- {
- mn = e_menu_new();
-
- for (l = e->status->governors; l; l = l->next)
- {
- mi = e_menu_item_new(mn);
- if (!strcmp(l->data, "userspace"))
- e_menu_item_label_set(mi, _("Manual"));
- else if (!strcmp(l->data, "ondemand"))
- e_menu_item_label_set(mi, _("Automatic"));
- else if (!strcmp(l->data, "conservative"))
- e_menu_item_label_set(mi, _("Lower Power Automatic"));
- else if (!strcmp(l->data, "powersave"))
- e_menu_item_label_set(mi, _("Minimum Speed"));
- else if (!strcmp(l->data, "performance"))
- e_menu_item_label_set(mi, _("Maximum Speed"));
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- e_object_data_set(E_OBJECT(mi), l->data);
- e_menu_item_callback_set(mi, _cpufreq_menu_governor, e);
- }
-
- e->menu_governor = mn;
- }
-
- if (e->status->frequencies)
- {
- mn = e_menu_new();
-
- /* FIXME: sotring ints in pointers for freq's? BAD! */
- for (l = e->status->frequencies; l; l = l->next)
- {
- int frequency;
-
- frequency = (int)l->data;
- mi = e_menu_item_new(mn);
- if (frequency < 1000000)
- snprintf(buf, sizeof(buf), _("%i MHz"),
- frequency / 1000);
- else
- snprintf(buf, sizeof(buf), _("%i.%i GHz"),
- frequency / 1000000, (frequency % 1000000) / 100000);
- buf[sizeof(buf) - 1] = 0;
- e_menu_item_label_set(mi, buf);
- e_menu_item_radio_set(mi, 1);
- e_menu_item_radio_group_set(mi, 1);
- e_object_data_set(E_OBJECT(mi), l->data);
- e_menu_item_callback_set(mi, _cpufreq_menu_frequency, e);
- }
- e->menu_frequency = mn;
- }
-
- mn = e_menu_new();
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Set Poll Time"));
- e_menu_item_submenu_set(mi, e->config_menu_poll);
-
- if (e->menu_governor)
+ snprintf(buf, sizeof(buf),
+ "%s %s %i", cpufreq_config->set_exe_path, "frequency", frequency);
+ ret = system(buf);
+ if (ret != 0)
{
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Restore Governor on Startup"));
- e_menu_item_check_set(mi, 1);
- e_menu_item_toggle_set(mi, e->conf->restore_governor);
- e_menu_item_callback_set(mi, _cpufreq_menu_restore_governor, e);
+ E_Dialog *dia;
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Set Controller"));
- e_menu_item_submenu_set(mi, e->menu_governor);
- }
-
- if (e->menu_frequency)
- {
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Set Speed"));
- e_menu_item_submenu_set(mi, e->menu_frequency);
+ dia = e_dialog_new(e_container_current_get(e_manager_current_get()));
+ if (!dia) return;
+ e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
+ e_dialog_icon_set(dia, "enlightenment/e", 64);
+ e_dialog_text_set(dia, _("There was an error trying to set the<br>"
+ "cpu frequency setting via the module's<br>"
+ "setfreq utility."));
+ e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
+ e_win_centered_set(dia->win, 1);
+ e_dialog_show(dia);
}
-
- e->config_menu = mn;
}
static int
_cpufreq_cb_check(void *data)
{
- Cpufreq *e;
- Cpufreq_Face *face;
+ Instance *inst;
Evas_List *l;
int active;
- e = data;
- active = e->status->active;
- if (_cpufreq_status_check_current(e->status))
+ active = cpufreq_config->status->active;
+ if (_cpufreq_status_check_current(cpufreq_config->status))
{
- for (l = e->faces; l; l = l->next)
+ for (l = cpufreq_config->instances; l; l = l->next)
{
- face = l->data;
- _cpufreq_face_update_current(face);
+ inst = l->data;
+ _cpufreq_face_update_current(inst);
}
}
- if (active != e->status->active)
+ if (active != cpufreq_config->status->active)
{
- for (l = e->faces; l; l = l->next)
+ for (l = cpufreq_config->instances; l; l = l->next)
{
- face = l->data;
- if (e->status->active == 0)
- edje_object_signal_emit(face->freq_object, "passive", "");
- else if (e->status->active == 1)
- edje_object_signal_emit(face->freq_object, "active", "");
+ inst = l->data;
+ if (cpufreq_config->status->active == 0)
+ edje_object_signal_emit(inst->o_cpu, "passive", "");
+ else if (cpufreq_config->status->active == 1)
+ edje_object_signal_emit(inst->o_cpu, "active", "");
}
}
@@ -605,38 +395,27 @@ _cpufreq_cb_check(void *data)
static Status *
_cpufreq_status_new()
{
- Status *e;
-
- e = E_NEW(Status, 1);
- if (!e) return NULL;
+ Status *s;
- e->frequencies = NULL;
- e->governors = NULL;
- e->cur_frequency = 0;
- e->can_set_frequency = 0;
- e->cur_governor = NULL;
- e->active = -1;
-
- return e;
+ s = E_NEW(Status, 1);
+ if (!s) return NULL;
+ s->active = -1;
+ return s;
}
static void
-_cpufreq_status_free(Status *e)
+_cpufreq_status_free(Status *s)
{
Evas_List *l;
- if (e->frequencies)
- evas_list_free(e->frequencies);
- if (e->governors)
+ if (s->frequencies) evas_list_free(s->frequencies);
+ if (s->governors)
{
- for (l = e->governors; l; l = l->next)
- free(l->data);
- evas_list_free(e->governors);
+ for (l = s->governors; l; l = l->next) free(l->data);
+ evas_list_free(s->governors);
}
- if (e->cur_governor)
- free(e->cur_governor);
-
- free(e);
+ if (s->cur_governor) free(s->cur_governor);
+ free(s);
}
static int
@@ -644,18 +423,15 @@ _cpufreq_cb_sort(void *item1, void *item2)
{
int a, b;
- a = (int) item1;
- b = (int) item2;
- if (a < b)
- return -1;
- else if (a > b)
- return 1;
- else
- return 0;
+ a = (int)item1;
+ b = (int)item2;
+ if (a < b) return -1;
+ else if (a > b) return 1;
+ return 0;
}
static int
-_cpufreq_status_check_available(Status *e)
+_cpufreq_status_check_available(Status *s)
{
char buf[4096];
Evas_List *l;
@@ -669,13 +445,13 @@ _cpufreq_status_check_available(Status *e)
if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) == 0)
{
/* sysctl returns 0 on success */
- if (e->frequencies)
+ if (s->frequencies)
{
- evas_list_free(e->frequencies);
- e->frequencies = NULL;
+ evas_list_free(s->frequencies);
+ s->frequencies = NULL;
}
- /* parse freqs and store the frequencies in e->frequencies */
+ /* parse freqs and store the frequencies in s->frequencies */
pos = buf;
while (pos)
{
@@ -685,7 +461,7 @@ _cpufreq_status_check_available(Status *e)
*q = '\0';
freq = atoi(pos);
freq *= 1000;
- e->frequencies = evas_list_append(e->frequencies, (void *)freq);
+ s->frequencies = evas_list_append(s->frequencies, (void *)freq);
pos = q + 1;
pos = strchr(pos, ' ');
@@ -694,11 +470,11 @@ _cpufreq_status_check_available(Status *e)
/* sort is not necessary because freq_levels is already sorted */
/* freebsd doesn't have governors */
- if (e->governors)
+ if (s->governors)
{
- for (l = e->governors; l; l = l->next) free(l->data);
- evas_list_free(e->governors);
- e->governors = NULL;
+ for (l = s->governors; l; l = l->next) free(l->data);
+ evas_list_free(s->governors);
+ s->governors = NULL;
}
#else
FILE *f;
@@ -708,10 +484,10 @@ _cpufreq_status_check_available(Status *e)
{
char *freq;
- if (e->frequencies)
+ if (s->frequencies)
{
- evas_list_free(e->frequencies);
- e->frequencies = NULL;
+ evas_list_free(s->frequencies);
+ s->frequencies = NULL;
}
fgets(buf, sizeof(buf), f);
@@ -723,15 +499,15 @@ _cpufreq_status_check_available(Status *e)
{
if (atoi(freq) != 0)
{
- e->frequencies = evas_list_append(e->frequencies,
+ s->frequencies = evas_list_append(s->frequencies,
(void *) atoi(freq));
}
freq = strtok(NULL, " ");
}
while (freq != NULL);
- // sort list
- e->frequencies = evas_list_sort(e->frequencies, evas_list_count(e->frequencies),
+ s->frequencies = evas_list_sort(s->frequencies,
+ evas_list_count(s->frequencies),
_cpufreq_cb_sort);
}
@@ -740,12 +516,12 @@ _cpufreq_status_check_available(Status *e)
{
char *gov;
- if (e->governors)
+ if (s->governors)
{
- for (l = e->governors; l; l = l->next)
+ for (l = s->governors; l; l = l->next)
free(l->data);
- evas_list_free(e->governors);
- e->governors = NULL;
+ evas_list_free(s->governors);
+ s->governors = NULL;
}
fgets(buf, sizeof(buf), f);
@@ -757,19 +533,13 @@ _cpufreq_status_check_available(Status *e)
{
while ((*gov) && (isspace(*gov))) gov++;
if (strlen(gov) != 0)
- {
-// if ((!strcmp(gov, "ondemand")) ||
-// (!strcmp(gov, "userspace")) ||
-// (!strcmp(gov, "powersave")) ||
-// (!strcmp(gov, "performance"))
-// )
- e->governors = evas_list_append(e->governors, strdup(gov));
- }
+ s->governors = evas_list_append(s->governors, strdup(gov));
gov = strtok(NULL, " ");
}
while (gov != NULL);
- e->governors = evas_list_sort(e->governors, evas_list_count(e->governors),
+ s->governors = evas_list_sort(s->governors,
+ evas_list_count(s->governors),
(int (*)(void *, void *))strcmp);
}
#endif
@@ -777,7 +547,7 @@ _cpufreq_status_check_available(Status *e)
}
static int
-_cpufreq_status_check_current(Status *e)
+_cpufreq_status_check_current(Status *s)
{
char buf[4096];
int i;
@@ -787,21 +557,21 @@ _cpufreq_status_check_current(Status *e)
#ifdef __FreeBSD__
int len = 4;
- e->active = 0;
+ s->active = 0;
/* frequency is stored in dev.cpu.0.freq */
if (sysctlbyname("dev.cpu.0.freq", &frequency, &len, NULL, 0) == 0)
{
frequency *= 1000;
- if (frequency != e->cur_frequency) ret = 1;
- e->cur_frequency = frequency;
- e->active = 1;
+ if (frequency != s->cur_frequency) ret = 1;
+ s->cur_frequency = frequency;
+ s->active = 1;
}
/* hardcoded for testing */
- e->can_set_frequency = 1;
- e->cur_governor = NULL;
+ s->can_set_frequency = 1;
+ s->cur_governor = NULL;
#else
- e->active = 0;
+ s->active = 0;
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r");
if (f)
@@ -811,21 +581,21 @@ _cpufreq_status_check_current(Status *e)
fclose(f);
frequency = atoi(buf);
- if (frequency != e->cur_frequency)
+ if (frequency != s->cur_frequency)
ret = 1;
- e->cur_frequency = frequency;
- e->active = 1;
+ s->cur_frequency = frequency;
+ s->active = 1;
}
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", "r");
if (f)
{
- e->can_set_frequency = 1;
+ s->can_set_frequency = 1;
fclose(f);
}
else
{
- e->can_set_frequency = 0;
+ s->can_set_frequency = 0;
}
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "r");
@@ -835,18 +605,18 @@ _cpufreq_status_check_current(Status *e)
buf[sizeof(buf) - 1] = 0;
fclose(f);
- if ((e->cur_governor == NULL) || (strcmp(buf, e->cur_governor)))
+ if ((s->cur_governor == NULL) || (strcmp(buf, s->cur_governor)))
{
ret = 1;
- if (e->cur_governor)
- free(e->cur_governor);
- e->cur_governor = strdup(buf);
+ if (s->cur_governor)
+ free(s->cur_governor);
+ s->cur_governor = strdup(buf);
- for (i = strlen(e->cur_governor) - 1; i >= 0; i--)
+ for (i = strlen(s->cur_governor) - 1; i >= 0; i--)
{
- if (isspace(e->cur_governor[i]))
- e->cur_governor[i] = 0;
+ if (isspace(s->cur_governor[i]))
+ s->cur_governor[i] = 0;
else
break;
}
@@ -856,306 +626,291 @@ _cpufreq_status_check_current(Status *e)
return ret;
}
-static Cpufreq_Face *
-_cpufreq_face_new(E_Container *con, Cpufreq *owner)
+static void
+_cpufreq_face_update_available(Instance *inst)
{
- Evas_Object *o;
- Cpufreq_Face *ef;
- E_Gadman_Policy policy;
+ Edje_Message_Int_Set *frequency_msg;
+ Edje_Message_String_Set *governor_msg;
+ Evas_List *l;
+ int i;
+ int count;
+
+ count = evas_list_count(cpufreq_config->status->frequencies);
+ frequency_msg = malloc(sizeof(Edje_Message_Int_Set) + (count - 1) * sizeof(int));
+ frequency_msg->count = count;
+ for (l = cpufreq_config->status->frequencies, i = 0; l; l = l->next, i++)
+ frequency_msg->val[i] = (int)l->data;
+ edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_INT_SET, 1, frequency_msg);
+ free(frequency_msg);
- ef = E_NEW(Cpufreq_Face, 1);
- if (!ef) return NULL;
+ count = evas_list_count(cpufreq_config->status->governors);
+ governor_msg = malloc(sizeof(Edje_Message_String_Set) + (count - 1) * sizeof(char *));
+ governor_msg->count = count;
+ for (l = cpufreq_config->status->governors, i = 0; l; l = l->next, i++)
+ governor_msg->str[i] = (char *)l->data;
+ edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_STRING_SET, 2, governor_msg);
+ free(governor_msg);
+}
- ef->con = con;
- e_object_ref(E_OBJECT(con));
- ef->owner = owner;
+static void
+_cpufreq_face_update_current(Instance *inst)
+{
+ Edje_Message_Int_Set *frequency_msg;
+ Edje_Message_String governor_msg;
- evas_event_freeze(con->bg_evas);
+ frequency_msg = malloc(sizeof(Edje_Message_Int_Set) + sizeof(int));
+ frequency_msg->count = 2;
+ frequency_msg->val[0] = cpufreq_config->status->cur_frequency;
+ frequency_msg->val[1] = cpufreq_config->status->can_set_frequency;
+ edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_INT_SET, 3,
+ frequency_msg);
+ free(frequency_msg);
- o = edje_object_add(con->bg_evas);
- ef->freq_object = o;
- e_theme_edje_object_set(o, "base/theme/modules/cpufreq",
- "modules/cpufreq/main");
- edje_object_signal_callback_add(o, "next_governor", "governor", _cpufreq_face_cb_set_governor, owner);
- edje_object_signal_callback_add(o, "increase_frequency", "frequency", _cpufreq_face_cb_set_frequency, owner);
- edje_object_signal_callback_add(o, "decrease_frequency", "frequency", _cpufreq_face_cb_set_frequency, owner);
- evas_object_show(o);
-
- o = evas_object_rectangle_add(con->bg_evas);
- ef->event_object = o;
- evas_object_layer_set(o, 0);
- evas_object_repeat_events_set(o, 1);
- evas_object_color_set(o, 0, 0, 0, 0);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _cpufreq_face_cb_mouse_down, ef);
- evas_object_show(o);
-
- ef->gmc = e_gadman_client_new(ef->con->gadman);
- e_gadman_client_domain_set(ef->gmc, "module.cpufreq", cpufreq_count++);
-
- policy = E_GADMAN_POLICY_ANYWHERE |
- E_GADMAN_POLICY_HMOVE |
- E_GADMAN_POLICY_VMOVE |
- E_GADMAN_POLICY_HSIZE |
- E_GADMAN_POLICY_VSIZE;
-
- e_gadman_client_policy_set(ef->gmc, policy);
- e_gadman_client_min_size_set(ef->gmc, 4, 4);
- e_gadman_client_max_size_set(ef->gmc, 128, 128);
- /* This module needs a slightly higher min size */
- e_gadman_client_auto_size_set(ef->gmc, 40, 40);
- e_gadman_client_align_set(ef->gmc, 1.0, 1.0);
- e_gadman_client_resize(ef->gmc, 40, 40);
- e_gadman_client_change_func_set(ef->gmc, _cpufreq_face_cb_gmc_change, ef);
- e_gadman_client_load(ef->gmc);
-
- _cpufreq_face_update_available(ef);
-
- evas_event_thaw(con->bg_evas);
-
- return ef;
+ /* BSD crashes here without the if-condition
+ * since it has no governors (yet) */
+ if (cpufreq_config->status->cur_governor != NULL)
+ {
+ governor_msg.str = cpufreq_config->status->cur_governor;
+ edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_STRING, 4,
+ &governor_msg);
+ }
}
static void
-_cpufreq_face_free(Cpufreq_Face *ef)
+_cpufreq_face_cb_set_frequency(void *data, Evas_Object *obj, const char *emission, const char *src)
{
- e_object_unref(E_OBJECT(ef->con));
- e_object_del(E_OBJECT(ef->gmc));
- e_object_del(E_OBJECT(ef->menu));
- evas_object_del(ef->freq_object);
- evas_object_del(ef->event_object);
-
- free(ef->conf);
- free(ef);
- cpufreq_count--;
+ Evas_List *l;
+ int next_frequency = 0;
+
+ for (l = cpufreq_config->status->frequencies; l; l = l->next)
+ {
+ if (cpufreq_config->status->cur_frequency == (int)l->data)
+ {
+ if (!strcmp(emission, "increase_frequency"))
+ {
+ if (l->next) next_frequency = (int)l->next->data;
+ break;
+ }
+ else if (!strcmp(emission, "decrease_frequency"))
+ {
+ if (l->prev) next_frequency = (int)l->prev->data;
+ break;
+ }
+ else
+ break;
+ }
+ }
+ if (next_frequency != 0) _cpufreq_set_frequency(next_frequency);
}
static void
-_cpufreq_face_menu_new(Cpufreq_Face *face)
+_cpufreq_face_cb_set_governor(void *data, Evas_Object *obj, const char *emission, const char *src)
{
- E_Menu *mn;
- E_Menu_Item *mi;
+ Evas_List *l;
+ char *next_governor = NULL;
- mn = e_menu_new();
- face->menu = mn;
-
- /* Edit */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Edit Mode"));
- e_menu_item_callback_set(mi, _cpufreq_face_cb_menu_edit, face);
+ for (l = cpufreq_config->status->governors; l; l = l->next)
+ {
+ if (!strcmp(l->data, cpufreq_config->status->cur_governor))
+ {
+ if (l->next)
+ next_governor = l->next->data;
+ else
+ next_governor = cpufreq_config->status->governors->data;
+ break;
+ }
+ }
+ if (next_governor != NULL) _cpufreq_set_governor(next_governor);
}
static void
-_cpufreq_face_enable(Cpufreq_Face *face)
+_cpufreq_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi)
{
- face->conf->enabled = 1;
- evas_object_show(face->freq_object);
- evas_object_show(face->event_object);
+ cpufreq_config->poll_time = 0.5;
+ ecore_timer_del(cpufreq_config->frequency_check_timer);
+ cpufreq_config->frequency_check_timer = ecore_timer_add(cpufreq_config->poll_time, _cpufreq_cb_check, NULL);
e_config_save_queue();
}
static void
-_cpufreq_face_disable(Cpufreq_Face *face)
+_cpufreq_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi)
{
- face->conf->enabled = 0;
- evas_object_hide(face->freq_object);
- evas_object_hide(face->event_object);
+ cpufreq_config->poll_time = 1.0;
+ ecore_timer_del(cpufreq_config->frequency_check_timer);
+ cpufreq_config->frequency_check_timer = ecore_timer_add(cpufreq_config->poll_time, _cpufreq_cb_check, NULL);
e_config_save_queue();
}
static void
-_cpufreq_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
+_cpufreq_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi)
{
- Cpufreq_Face *ef;
- Evas_Coord x, y, w, h;
-
- ef = data;
- switch (change)
- {
- case E_GADMAN_CHANGE_MOVE_RESIZE:
- e_gadman_client_geometry_get(ef->gmc, &x, &y, &w, &h);
- evas_object_move(ef->freq_object, x, y);
- evas_object_move(ef->event_object, x, y);
- evas_object_resize(ef->freq_object, w, h);
- evas_object_resize(ef->event_object, w, h);
- break;
- case E_GADMAN_CHANGE_RAISE:
- evas_object_raise(ef->freq_object);
- evas_object_raise(ef->event_object);
- break;
- case E_GADMAN_CHANGE_EDGE:
- case E_GADMAN_CHANGE_ZONE:
- break;
- }
+ cpufreq_config->poll_time = 2.0;
+ ecore_timer_del(cpufreq_config->frequency_check_timer);
+ cpufreq_config->frequency_check_timer = ecore_timer_add(cpufreq_config->poll_time, _cpufreq_cb_check, NULL);
+ e_config_save_queue();
}
static void
-_cpufreq_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
+_cpufreq_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi)
{
- Cpufreq_Face *face;
-
- face = data;
- e_gadman_mode_set(face->gmc->gadman, E_GADMAN_MODE_EDIT);
+ cpufreq_config->poll_time = 5.0;
+ ecore_timer_del(cpufreq_config->frequency_check_timer);
+ cpufreq_config->frequency_check_timer = ecore_timer_add(cpufreq_config->poll_time, _cpufreq_cb_check, NULL);
+ e_config_save_queue();
}
static void
-_cpufreq_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_cpufreq_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi)
{
- Evas_Event_Mouse_Down *ev;
- Cpufreq_Face *ef;
+ cpufreq_config->poll_time = 30.0;
+ ecore_timer_del(cpufreq_config->frequency_check_timer);
+ cpufreq_config->frequency_check_timer = ecore_timer_add(cpufreq_config->poll_time, _cpufreq_cb_check, NULL);
+ e_config_save_queue();
+}
- ev = event_info;
- ef = data;
- if (ev->button == 3)
+static void
+_cpufreq_menu_restore_governor(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ cpufreq_config->restore_governor = e_menu_item_toggle_get(mi);
+ if ((!cpufreq_config->governor) ||
+ (strcmp(cpufreq_config->status->cur_governor, cpufreq_config->governor)))
{
- e_menu_activate_mouse(ef->menu, e_zone_current_get(ef->con),
- ev->output.x, ev->output.y, 1, 1,
- E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
- e_util_container_fake_mouse_up_all_later(ef->con);
+ if (cpufreq_config->governor) evas_stringshare_del(cpufreq_config->governor);
+ cpufreq_config->governor = evas_stringshare_add(cpufreq_config->status->cur_governor);
}
+ e_config_save_queue();
}
static void
-_cpufreq_face_update_available(Cpufreq_Face *face)
+_cpufreq_menu_governor(void *data, E_Menu *m, E_Menu_Item *mi)
{
- Edje_Message_Int_Set *frequency_msg;
- Edje_Message_String_Set *governor_msg;
- Evas_List *l;
- int i;
- int count;
+ char *governor;
- count = evas_list_count(face->owner->status->frequencies);
- frequency_msg = malloc(sizeof(Edje_Message_Int_Set) + (count - 1) * sizeof(int));
- frequency_msg->count = count;
- for (l = face->owner->status->frequencies, i = 0; l; l = l->next, i++)
+ governor = e_object_data_get(E_OBJECT(mi));
+ if (governor)
{
- frequency_msg->val[i] = (int) l->data;
+ _cpufreq_set_governor(governor);
+ if (cpufreq_config->governor) evas_stringshare_del(cpufreq_config->governor);
+ cpufreq_config->governor = evas_stringshare_add(governor);
}
- edje_object_message_send(face->freq_object, EDJE_MESSAGE_INT_SET, 1, frequency_msg);
- free(frequency_msg);
-
- count = evas_list_count(face->owner->status->governors);
- governor_msg = malloc(sizeof(Edje_Message_String_Set) + (count - 1) * sizeof(char *));
- governor_msg->count = count;
- for (l = face->owner->status->governors, i = 0; l; l = l->next, i++)
- governor_msg->str[i] = (char *) l->data;
- edje_object_message_send(face->freq_object, EDJE_MESSAGE_STRING_SET, 2, governor_msg);
- free(governor_msg);
+ e_config_save_queue();
}
static void
-_cpufreq_face_update_current(Cpufreq_Face *face)
+_cpufreq_menu_frequency(void * data, E_Menu *m, E_Menu_Item *mi)
{
- Edje_Message_Int_Set *frequency_msg;
- Edje_Message_String governor_msg;
-
- frequency_msg = malloc(sizeof(Edje_Message_Int_Set) + sizeof(int));
- frequency_msg->count = 2;
- frequency_msg->val[0] = face->owner->status->cur_frequency;
- frequency_msg->val[1] = face->owner->status->can_set_frequency;
- edje_object_message_send(face->freq_object, EDJE_MESSAGE_INT_SET, 3, frequency_msg);
- free(frequency_msg);
-
- /* BSD crashes here without the if-condition
- * since it has no governors (yet) */
- if (face->owner->status->cur_governor != NULL)
- {
- governor_msg.str = face->owner->status->cur_governor;
- edje_object_message_send(face->freq_object, EDJE_MESSAGE_STRING, 4, &governor_msg);
- }
-
- if (face->owner->menu_frequency)
- {
- Evas_List *l;
-
- for (l = face->owner->menu_frequency->items; l; l = l->next)
- {
- E_Menu_Item *mi;
- int freq;
-
- mi = l->data;
- freq = (int)e_object_data_get(E_OBJECT(mi));
- if (freq == face->owner->status->cur_frequency)
- {
- e_menu_item_toggle_set(mi, 1);
- break;
- }
- }
- }
- if (face->owner->menu_governor)
+ int frequency;
+
+ frequency = (int)e_object_data_get(E_OBJECT(mi));
+ if (frequency > 0)
{
- Evas_List *l;
-
- for (l = face->owner->menu_governor->items; l; l = l->next)
- {
- E_Menu_Item *mi;
- char *gov;
-
- mi = l->data;
- gov = (char *)e_object_data_get(E_OBJECT(mi));
- if (!strcmp(face->owner->status->cur_governor, gov))
- {
- e_menu_item_toggle_set(mi, 1);
- break;
- }
- }
+ _cpufreq_set_frequency(frequency);
}
}
-static void
-_cpufreq_face_cb_set_frequency(void *data, Evas_Object *obj, const char *emission, const char *src)
+/***************************************************************************/
+/**/
+/* module setup */
+EAPI E_Module_Api e_modapi =
{
- Cpufreq *e;
- Evas_List *l;
- int next_frequency = 0;
+ E_MODULE_API_VERSION,
+ "Cpufreq"
+};
- e = data;
+EAPI void *
+e_modapi_init(E_Module *module)
+{
+ char buf[4096];
+ Evas_List *l;
+
+ conf_edd = E_CONFIG_DD_NEW("Cpufreq_Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+ E_CONFIG_VAL(D, T, poll_time, DOUBLE);
+ E_CONFIG_VAL(D, T, restore_governor, INT);
+ E_CONFIG_VAL(D, T, governor, STR);
- for (l = e->status->frequencies; l; l = l->next)
+ cpufreq_config = e_config_domain_load("module.cpufreq", conf_edd);
+ if (!cpufreq_config)
{
- if (e->status->cur_frequency == (int) l->data)
+ cpufreq_config = E_NEW(Config, 1);
+ cpufreq_config->poll_time = 2.0;
+ cpufreq_config->restore_governor = 0;
+ cpufreq_config->governor = NULL;
+ }
+ E_CONFIG_LIMIT(cpufreq_config->poll_time, 0.5, 60.0);
+
+ snprintf(buf, sizeof(buf), "%s/%s/freqset",
+ e_module_dir_get(module), MODULE_ARCH);
+ cpufreq_config->set_exe_path = strdup(buf);
+ cpufreq_config->frequency_check_timer = ecore_timer_add(cpufreq_config->poll_time,
+ _cpufreq_cb_check, NULL);
+ cpufreq_config->status = _cpufreq_status_new();
+
+ _cpufreq_status_check_available(cpufreq_config->status);
+ if ((cpufreq_config->restore_governor) && (cpufreq_config->governor))
+ {
+ /* If the governor is available, restore it */
+ for (l = cpufreq_config->status->governors; l; l = l->next)
{
- if (!strcmp(emission, "increase_frequency"))
+ if (!strcmp(l->data, cpufreq_config->governor))
{
- if (l->next)
- next_frequency = (int) l->next->data;
+ _cpufreq_set_governor(cpufreq_config->governor);
break;
}
- else if (!strcmp(emission, "decrease_frequency"))
- {
- if (l->prev)
- next_frequency = (int) l->prev->data;
- break;
- }
- else
- break;
}
}
+
+ e_gadcon_provider_register(&_gadcon_class);
+ return 1;
+}
- if (next_frequency != 0)
- _cpufreq_set_frequency(e, next_frequency);
+EAPI int
+e_modapi_shutdown(E_Module *module)
+{
+ e_gadcon_provider_unregister(&_gadcon_class);
+
+ if (cpufreq_config->frequency_check_timer)
+ ecore_timer_del(cpufreq_config->frequency_check_timer);
+ if (cpufreq_config->menu) e_object_del(E_OBJECT(cpufreq_config->menu));
+ if (cpufreq_config->menu_poll) e_object_del(E_OBJECT(cpufreq_config->menu_poll));
+ if (cpufreq_config->menu_governor) e_object_del(E_OBJECT(cpufreq_config->menu_governor));
+ if (cpufreq_config->menu_frequency) e_object_del(E_OBJECT(cpufreq_config->menu_frequency));
+ if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status);
+ if (cpufreq_config->governor)
+ evas_stringshare_del(cpufreq_config->governor);
+ free(cpufreq_config);
+ cpufreq_config = NULL;
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
}
-static void
-_cpufreq_face_cb_set_governor(void *data, Evas_Object *obj, const char *emission, const char *src)
+EAPI int
+e_modapi_save(E_Module *module)
{
- Cpufreq *e;
- Evas_List *l;
- char *next_governor = NULL;
+ e_config_domain_save("module.cpufreq", conf_edd, cpufreq_config);
+ return 1;
+}
- e = data;
+EAPI int
+e_modapi_info(E_Module *module)
+{
+ char buf[4096];
- for (l = e->status->governors; l; l = l->next)
- {
- if (!strcmp(l->data, e->status->cur_governor))
- {
- if (l->next)
- next_governor = l->next->data;
- else
- next_governor = e->status->governors->data;
- break;
- }
- }
+ snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(module));
+ module->icon_file = strdup(buf);
+ return 1;
+}
- if (next_governor != NULL)
- _cpufreq_set_governor(e, next_governor);
+EAPI int
+e_modapi_about(E_Module *module)
+{
+ e_module_dialog_show(_("CPU Frequency Controller Module"),
+ _("A simple module to control the frequency of the system CPU.<br>"
+ "This is especially useful to save power on laptops."));
+ return 1;
}
+/**/
+/***************************************************************************/
diff --git a/src/modules/cpufreq/e_mod_main.h b/src/modules/cpufreq/e_mod_main.h
index 57baf322e..fb24d6966 100644
--- a/src/modules/cpufreq/e_mod_main.h
+++ b/src/modules/cpufreq/e_mod_main.h
@@ -1,67 +1,34 @@
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
-#include <e.h>
-#include <Evas.h>
-
typedef struct _Status Status;
typedef struct _Config Config;
-typedef struct _Config_Face Config_Face;
-typedef struct _Cpufreq Cpufreq;
-typedef struct _Cpufreq_Face Cpufreq_Face;
struct _Status
{
- Evas_List *frequencies;
- Evas_List *governors;
- int cur_frequency;
- int can_set_frequency;
- char *cur_governor;
- unsigned char active;
+ Evas_List *frequencies;
+ Evas_List *governors;
+ int cur_frequency;
+ int can_set_frequency;
+ char *cur_governor;
+ unsigned char active;
};
struct _Config
{
- double poll_time;
- Evas_List *faces;
-
- int restore_governor;
- char *governor;
-};
-
-struct _Config_Face
-{
- unsigned char enabled;
-};
-
-struct _Cpufreq
-{
- E_Menu *config_menu;
- E_Menu *config_menu_poll;
- E_Menu *menu_governor;
- E_Menu *menu_frequency;
- Evas_List *faces;
-
- Config *conf;
- Status *status;
-
- char *set_exe_path;
-
- Ecore_Timer *frequency_check_timer;
-};
-
-struct _Cpufreq_Face
-{
- E_Container *con;
-
+ /* saved * loaded config values */
+ double poll_time;
+ int restore_governor;
+ char *governor;
+ /* just config state */
+ Evas_List *instances;
E_Menu *menu;
- Config_Face *conf;
- Cpufreq *owner;
-
- Evas_Object *freq_object;
- Evas_Object *event_object;
-
- E_Gadman_Client *gmc;
+ E_Menu *menu_poll;
+ E_Menu *menu_governor;
+ E_Menu *menu_frequency;
+ Status *status;
+ char *set_exe_path;
+ Ecore_Timer *frequency_check_timer;
};
EAPI extern E_Module_Api e_modapi;
diff --git a/src/modules/dropshadow/e_mod_main.c b/src/modules/dropshadow/e_mod_main.c
index 2bcd6be83..3ad62583b 100644
--- a/src/modules/dropshadow/e_mod_main.c
+++ b/src/modules/dropshadow/e_mod_main.c
@@ -694,7 +694,7 @@ static void
_ds_shadow_resize(Shadow *sh, int w, int h)
{
unsigned char toosmall = 0;
-
+
_ds_shadow_obj_init(sh);
if ((w < ((sh->ds->conf->blur_size * 2) + 2)) ||
(h < ((sh->ds->conf->blur_size * 2) + 2)))
diff --git a/src/modules/ibar/Makefile.am b/src/modules/ibar/Makefile.am
index cc7461136..7aade0e37 100644
--- a/src/modules/ibar/Makefile.am
+++ b/src/modules/ibar/Makefile.am
@@ -20,8 +20,7 @@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
- e_mod_config.c \
- e_mod_config.h
+ e_mod_config.c
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
diff --git a/src/modules/ibar/e_mod_config.c b/src/modules/ibar/e_mod_config.c
index a1fdc4ac0..6d71bb12d 100644
--- a/src/modules/ibar/e_mod_config.c
+++ b/src/modules/ibar/e_mod_config.c
@@ -1,15 +1,12 @@
-#include <e.h>
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
struct _E_Config_Dialog_Data
{
- int autofit;
- int follower;
- int iconsize;
- double follow_speed;
- double autoscroll_speed;
+ char *dir;
};
/* Protos */
@@ -21,156 +18,110 @@ static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
void
-_config_ibar_module(E_Container *con, IBar *ibar)
+_config_ibar_module(Config_Item *ci)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
v = E_NEW(E_Config_Dialog_View, 1);
-
+
/* Dialog Methods */
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;
-
+ v->advanced.apply_cfdata = NULL;
+ v->advanced.create_widgets = NULL;
+
/* Create The Dialog */
- cfd = e_config_dialog_new(con, _("IBar Configuration"), NULL, 0, v, ibar);
- ibar->config_dialog = cfd;
+ cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
+ _("IBar Configuration"), NULL, 0, v, ci);
+ ibar_config->config_dialog = cfd;
}
static void
-_fill_data(IBar *ib, E_Config_Dialog_Data *cfdata)
+_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
{
- cfdata->autofit = (ib->conf->width == IBAR_WIDTH_AUTO);
- cfdata->follower = ib->conf->follower;
- cfdata->iconsize = ib->conf->iconsize;
- cfdata->follow_speed = ib->conf->follow_speed;
- cfdata->autoscroll_speed = ib->conf->autoscroll_speed;
+ if (ci->dir)
+ cfdata->dir = strdup(ci->dir);
+ else
+ cfdata->dir = strdup("");
}
static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
- IBar *ib;
+ Config_Item *ci;
- ib = cfd->data;
+ ci = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
- _fill_data(ib, cfdata);
+ _fill_data(ci, cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- IBar *ib;
-
- ib = cfd->data;
- ib->config_dialog = NULL;
+ if (cfdata->dir) free(cfdata->dir);
+ ibar_config->config_dialog = NULL;
free(cfdata);
}
static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
- Evas_Object *o, *ob;
-
- o = e_widget_list_add(evas, 0, 0);
- ob = e_widget_check_add(evas, _("Show Follower"), &(cfdata->follower));
- e_widget_list_object_append(o, ob, 1, 1, 0.5);
- ob = e_widget_check_add(evas, _("Auto Fit Icons"), &(cfdata->autofit));
- e_widget_list_object_append(o, ob, 1, 1, 0.5);
- return o;
-}
-
-static int
-_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
-{
- IBar *ib;
+ Evas_Object *o, *of, *ol;
+ Ecore_List *dirs;
+ char *home, buf[4096], *file;
+ int selnum = -1;
- ib = cfd->data;
- e_border_button_bindings_ungrab_all();
- if ((cfdata->follower) && (!ib->conf->follower))
- ib->conf->follower = 1;
- else if (!(cfdata->follower) && (ib->conf->follower))
- ib->conf->follower = 0;
+ o = e_widget_framelist_add(evas, _("Selected Bar Source"), 0);
- if ((cfdata->autofit) && (ib->conf->width == IBAR_WIDTH_FIXED))
- ib->conf->width = IBAR_WIDTH_AUTO;
- else if (!(cfdata->autofit) && (ib->conf->width == IBAR_WIDTH_AUTO))
- ib->conf->width = IBAR_WIDTH_FIXED;
-
- e_border_button_bindings_grab_all();
- e_config_save_queue();
+ ol = e_widget_tlist_add(evas, &(cfdata->dir));
+ e_widget_min_size_set(ol, 160, 200);
+ e_widget_framelist_object_append(o, ol);
- _ibar_bar_cb_config_updated(ib);
- return 1;
-}
-
-static Evas_Object *
-_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
-{
- Evas_Object *o, *of, *ob;
-
- o = e_widget_list_add(evas, 0, 0);
+ home = e_user_homedir_get();
+ snprintf(buf, sizeof(buf), "%s/.e/e/applications", home);
+ dirs = ecore_file_ls(buf);
- of = e_widget_framelist_add(evas, _("Follower"), 0);
- ob = e_widget_check_add(evas, _("Visible"), &(cfdata->follower));
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_label_add(evas, _("Follow Speed"));
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_slider_add(evas, 1, 0, _("%1.2f px/s"), 0.0, 1.0, 0.01, 0, &(cfdata->follow_speed), NULL,200);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
- of = e_widget_framelist_add(evas, _("Icon Size"), 0);
- ob = e_widget_slider_add(evas, 1, 0, _("%3.0f pixels"), 8.0, 128.0, 1.0, 0, NULL, &(cfdata->iconsize), 200);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
- of = e_widget_framelist_add(evas, _("Width"), 0);
- ob = e_widget_check_add(evas, _("Auto Fit"), &(cfdata->autofit));
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_label_add(evas, _("Autoscroll Speed:"));
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_slider_add(evas, 1, 0, _("%1.2f px/s"), 0.0, 1.0, 0.01, 0, &(cfdata->autoscroll_speed), NULL,200);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
+ if (dirs)
+ {
+ int i;
+
+ i = 0;
+ while ((file = ecore_list_next(dirs)))
+ {
+ if (file[0] == '.') continue;
+ snprintf(buf, sizeof(buf), "%s/.e/e/applications/%s", home, file);
+ if (ecore_file_is_dir(buf))
+ {
+ e_widget_tlist_append(ol, file, NULL, NULL, file);
+ if ((cfdata->dir) && (!strcmp(cfdata->dir, file)))
+ selnum = i;
+ i++;
+ }
+ }
+ ecore_list_destroy(dirs);
+ }
+ free(home);
+ e_widget_tlist_go(ol);
+ if (selnum >= 0)
+ e_widget_tlist_selected_set(ol, selnum);
return o;
}
static int
-_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
+_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- IBar *ib;
+ Config_Item *ci;
- ib = cfd->data;
- e_border_button_bindings_ungrab_all();
- if ((cfdata->follower) && (!ib->conf->follower))
- ib->conf->follower = 1;
- else if (!(cfdata->follower) && (ib->conf->follower))
- ib->conf->follower = 0;
-
- if ((cfdata->autofit) && (ib->conf->width == IBAR_WIDTH_FIXED))
- ib->conf->width = IBAR_WIDTH_AUTO;
- else if (!(cfdata->autofit) && (ib->conf->width == IBAR_WIDTH_AUTO))
- ib->conf->width = IBAR_WIDTH_FIXED;
-
- if (cfdata->iconsize != ib->conf->iconsize)
- ib->conf->iconsize = cfdata->iconsize;
- if (cfdata->follow_speed != ib->conf->follow_speed)
- ib->conf->follow_speed = cfdata->follow_speed;
- if (cfdata->autoscroll_speed != ib->conf->autoscroll_speed)
- ib->conf->autoscroll_speed = cfdata->autoscroll_speed;
-
- e_border_button_bindings_grab_all();
+ ci = cfd->data;
+ if (ci->dir) evas_stringshare_del(ci->dir);
+ ci->dir = NULL;
+ if (cfdata->dir) ci->dir = evas_stringshare_add(cfdata->dir);
+ _ibar_config_update();
e_config_save_queue();
-
- _ibar_bar_cb_config_updated(ib);
return 1;
}
-
diff --git a/src/modules/ibar/e_mod_config.h b/src/modules/ibar/e_mod_config.h
deleted file mode 100644
index 261cf1ae5..000000000
--- a/src/modules/ibar/e_mod_config.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifdef E_TYPEDEFS
-#else
-#ifndef E_MOD_CONFIG_H
-#define E_MOD_CONFIG_H
-#include "e_mod_main.h"
-void _config_ibar_module(E_Container *con, IBar *ibar);
-#endif
-#endif
diff --git a/src/modules/ibar/e_mod_main.c b/src/modules/ibar/e_mod_main.c
index c99693575..3a3fdb25e 100644
--- a/src/modules/ibar/e_mod_main.c
+++ b/src/modules/ibar/e_mod_main.c
@@ -3,1275 +3,795 @@
*/
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-
-/* TODO List:
- *
- * * Listen to change of main e_app!
- *
- * * Create separate config for each bar
- * * Fix menu
- *
- * * icon labels & label tooltips supported for the name of the app
- * * use part list to know how many icons & where to put in the overlay of an icon
- * * description bubbles/tooltips for icons
- * * support dynamic iconsize change on the fly
- * * app subdirs - need to somehow handle these...
- * * use overlay object and repeat events for doing auto hide/show
- * * emit signals on hide/show due to autohide/show
- * * virtualise autoshow/hide to later allow for key bindings, mouse events elsewhere, ipc and other singals to show/hide
- *
- */
-static int bar_count;
-static E_Config_DD *conf_edd;
-static E_Config_DD *conf_bar_edd;
-
-static int drag, drag_start;
-static int drag_x, drag_y;
-
-/* const strings */
-static const char *_ibar_main_orientation[] =
-{"left", "right", "top", "bottom"};
-
-/* module private routines */
-static IBar *_ibar_new();
-static void _ibar_free(IBar *ib);
-static void _ibar_app_change(void *data, E_App *a, E_App_Change ch);
-static void _ibar_config_menu_new(IBar *ib);
-
-static IBar_Bar *_ibar_bar_new(IBar *ib, E_Container *con);
-static void _ibar_bar_free(IBar_Bar *ibb);
-static void _ibar_bar_menu_new(IBar_Bar *ibb);
-/* static void _ibar_bar_enable(IBar_Bar *ibb); */
-static void _ibar_bar_disable(IBar_Bar *ibb);
-static void _ibar_bar_frame_resize(IBar_Bar *ibb);
-static void _ibar_bar_edge_change(IBar_Bar *ibb, int edge);
-static void _ibar_bar_update_policy(IBar_Bar *ibb);
-static void _ibar_bar_motion_handle(IBar_Bar *ibb, Evas_Coord mx, Evas_Coord my);
-static void _ibar_bar_timer_handle(IBar_Bar *ibb);
-static void _ibar_bar_follower_reset(IBar_Bar *ibb);
-
-static IBar_Icon *_ibar_icon_new(IBar_Bar *ibb, E_App *a);
-static void _ibar_icon_free(IBar_Icon *ic);
-static IBar_Icon *_ibar_icon_find(IBar_Bar *ibb, E_App *a);
-static IBar_Icon *_ibar_icon_pos_find(IBar_Bar *ibb, int x, int y);
-static void _ibar_icon_reorder_after(IBar_Icon *ic, IBar_Icon *after);
-
-static void _ibar_bar_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
-static void _ibar_bar_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
-static void _ibar_bar_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
-static void _ibar_bar_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_bar_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_bar_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_bar_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_bar_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static int _ibar_bar_cb_timer(void *data);
-static int _ibar_bar_cb_animator(void *data);
-
-static void _ibar_bar_cb_enter(void *data, const char *type, void *event);
-static void _ibar_bar_cb_move(void *data, const char *type, void *event);
-static void _ibar_bar_cb_leave(void *data, const char *type, void *event);
-
-static void _ibar_bar_cb_drop(void *data, const char *type, void *event);
-static void _ibar_bar_cb_finished(E_Drag *drag, int dropped);
-
-static void _ibar_icon_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
-static void _ibar_icon_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
-static void _ibar_icon_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_icon_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_icon_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_icon_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _ibar_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
-
-#if 0
-static void _ibar_icon_reorder_before(IBar_Icon *ic, IBar_Icon *before);
-#endif
-
-static void _ibar_bar_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _ibar_bar_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _ibar_drag_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
-static void _ibar_drag_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
-
-/* Config Updated Function Protos */
-static void _ibar_bar_cb_width_auto(void *data);
-static void _ibar_bar_cb_follower(void *data);
-static void _ibar_bar_cb_iconsize_change(void *data);
-
-/* public module routines. all modules must have these */
-EAPI E_Module_Api e_modapi =
+/***************************************************************************/
+/**/
+/* gadcon requirements */
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static void _gc_shutdown(E_Gadcon_Client *gcc);
+static void _gc_orient(E_Gadcon_Client *gcc);
+/* and actually define the gadcon class that this module provides (just 1) */
+static const E_Gadcon_Client_Class _gadcon_class =
{
- E_MODULE_API_VERSION,
- "IBar"
+ GADCON_CLIENT_CLASS_VERSION,
+ "ibar",
+ {
+ _gc_init, _gc_shutdown, _gc_orient
+ }
};
+/**/
+/***************************************************************************/
-EAPI void *
-e_modapi_init(E_Module *m)
-{
- IBar *ib;
+/***************************************************************************/
+/**/
+/* actual module specifics */
- /* actually init ibar */
- ib = _ibar_new();
- m->config_menu = ib->config_menu;
- return ib;
-}
+typedef struct _Instance Instance;
-EAPI int
-e_modapi_shutdown(E_Module *m)
-{
- IBar *ib;
+typedef struct _IBar IBar;
+typedef struct _IBar_Icon IBar_Icon;
- if (m->config_menu)
- m->config_menu = NULL;
-
- ib = m->data;
- if (ib)
- {
- if (ib->config_dialog)
- {
- e_object_del(E_OBJECT(ib->config_dialog));
- ib->config_dialog = NULL;
- }
- _ibar_free(ib);
- }
- return 1;
-}
-
-EAPI int
-e_modapi_save(E_Module *m)
+struct _Instance
{
- IBar *ib;
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_ibar;
+ IBar *ibar;
+ E_Drop_Handler *drop_handler;
+ Ecore_Timer *drop_recalc_timer;
+ char *dir;
+};
- ib = m->data;
- e_config_domain_save("module.ibar", conf_edd, ib->conf);
- return 1;
-}
+struct _IBar
+{
+ Instance *inst;
+ Evas_Object *o_box;
+ Evas_Object *o_drop;
+ Evas_Object *o_drop_over;
+ IBar_Icon *ic_drop_before;
+ int drop_before;
+ E_App *apps;
+ Evas_List *icons;
+};
-EAPI int
-e_modapi_info(E_Module *m)
+struct _IBar_Icon
{
- char buf[4096];
+ IBar *ibar;
+ Evas_Object *o_holder;
+ Evas_Object *o_icon;
+ Evas_Object *o_holder2;
+ Evas_Object *o_icon2;
+ E_App *app;
+ struct {
+ unsigned char start : 1;
+ unsigned char dnd : 1;
+ int x, y;
+ int dx, dy;
+ } drag;
+};
- snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
- m->icon_file = strdup(buf);
- return 1;
+static IBar *_ibar_new(Evas *evas, char *dir);
+static void _ibar_free(IBar *b);
+static void _ibar_fill(IBar *b);
+static void _ibar_empty(IBar *b);
+static void _ibar_orient_set(IBar *b, int horizontal);
+static void _ibar_resize_handle(IBar *b);
+static void _ibar_instance_drop_zone_recalc(Instance *inst);
+static Config_Item *_ibar_config_item_get(char *id);
+static IBar_Icon *_ibar_icon_find(IBar *b, E_App *a);
+static IBar_Icon *_ibar_icon_at_coord(IBar *b, Evas_Coord x, Evas_Coord y);
+static IBar_Icon *_ibar_icon_new(IBar *b, E_App *a);
+static void _ibar_icon_free(IBar_Icon *ic);
+static void _ibar_icon_fill(IBar_Icon *ic);
+static void _ibar_icon_empty(IBar_Icon *ic);
+static void _ibar_cb_app_change(void *data, E_App *a, E_App_Change ch);
+static int _ibar_cb_timer_drop_recalc(void *data);
+static void _ibar_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_menu_icon_properties(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _ibar_cb_menu_icon_remove(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _ibar_cb_menu_configuration(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _ibar_cb_menu_post(void *data, E_Menu *m);
+static void _ibar_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_icon_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_icon_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _ibar_cb_drag_finished(E_Drag *drag, int dropped);
+static void _ibar_inst_cb_enter(void *data, const char *type, void *event_info);
+static void _ibar_inst_cb_move(void *data, const char *type, void *event_info);
+static void _ibar_inst_cb_leave(void *data, const char *type, void *event_info);
+static void _ibar_inst_cb_drop(void *data, const char *type, void *event_info);
+
+static E_Config_DD *conf_edd = NULL;
+static E_Config_DD *conf_item_edd = NULL;
+
+Config *ibar_config = NULL;
+
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
+{
+ IBar *b;
+ Evas_Object *o;
+ E_Gadcon_Client *gcc;
+ Instance *inst;
+ Evas_Coord x, y, w, h;
+ int cx, cy, cw, ch;
+ const char *drop[] = { "enlightenment/eapp", "enlightenment/border", "text/uri-list" };
+ Evas_List *l;
+ Config_Item *ci;
+
+ inst = E_NEW(Instance, 1);
+
+ ci = _ibar_config_item_get(id);
+ if (!ci->dir) ci->dir = evas_stringshare_add("bar");
+ inst->dir = evas_stringshare_add(ci->dir);
+ b = _ibar_new(gc->evas, ci->dir);
+ b->inst = inst;
+ inst->ibar = b;
+ o = b->o_box;
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+
+ inst->gcc = gcc;
+ inst->o_ibar = o;
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ evas_object_geometry_get(o, &x, &y, &w, &h);
+ inst->drop_handler =
+ e_drop_handler_add(inst,
+ _ibar_inst_cb_enter, _ibar_inst_cb_move,
+ _ibar_inst_cb_leave, _ibar_inst_cb_drop,
+ drop, 3, cx + x, cy + y, w, h);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE,
+ _ibar_cb_obj_moveresize, inst);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
+ _ibar_cb_obj_moveresize, inst);
+ ibar_config->instances = evas_list_append(ibar_config->instances, inst);
+ /* FIXME: HACK!!!! */
+ inst->drop_recalc_timer = ecore_timer_add(1.0, _ibar_cb_timer_drop_recalc,
+ inst);
+ return gcc;
}
-EAPI int
-e_modapi_about(E_Module *m)
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
{
- e_module_dialog_show(_("Enlightenment IBar Module"),
- _("This is the IBar Application Launcher bar module for Enlightenment.<br>"
- "It is a first example module and is being used to flesh out several<br>"
- "interfaces in Enlightenment 0.17.0. It is under heavy development,<br>"
- "so expect it to <hilight>break often</hilight> and change as it improves."));
- return 1;
+ Instance *inst;
+
+ inst = gcc->data;
+ evas_stringshare_del(inst->dir);
+ ecore_timer_del(inst->drop_recalc_timer);
+ ibar_config->instances = evas_list_remove(ibar_config->instances, inst);
+ e_drop_handler_del(inst->drop_handler);
+ _ibar_free(inst->ibar);
+ free(inst);
}
-EAPI int
-e_modapi_config(E_Module *m)
+static void
+_gc_orient(E_Gadcon_Client *gcc)
{
- IBar *ib;
- Evas_List *l;
+ Instance *inst;
- ib = m->data;
- if (!ib) return 0;
- if (!ib->bars) return 0;
- for (l = ib->bars; l; l = l->next)
+ inst = gcc->data;
+ switch (gcc->gadcon->orient)
{
- IBar_Bar *ibb;
-
- ibb = l->data;
- if (!ibb) return 0;
- if (ibb->con == e_container_current_get(e_manager_current_get()))
- {
- _config_ibar_module(ibb->con, ib);
- break;
- }
+ case E_GADCON_ORIENT_FLOAT:
+ case E_GADCON_ORIENT_HORIZ:
+ case E_GADCON_ORIENT_TOP:
+ case E_GADCON_ORIENT_BOTTOM:
+ case E_GADCON_ORIENT_CORNER_TL:
+ case E_GADCON_ORIENT_CORNER_TR:
+ case E_GADCON_ORIENT_CORNER_BL:
+ case E_GADCON_ORIENT_CORNER_BR:
+ e_gadcon_client_aspect_set(gcc, evas_list_count(inst->ibar->icons), 1);
+ break;
+ case E_GADCON_ORIENT_VERT:
+ case E_GADCON_ORIENT_LEFT:
+ case E_GADCON_ORIENT_RIGHT:
+ case E_GADCON_ORIENT_CORNER_LT:
+ case E_GADCON_ORIENT_CORNER_RT:
+ case E_GADCON_ORIENT_CORNER_LB:
+ case E_GADCON_ORIENT_CORNER_RB:
+ e_gadcon_client_aspect_set(gcc, 1, evas_list_count(inst->ibar->icons));
+ break;
+ default:
+ break;
}
- return 1;
+ if (evas_list_count(inst->ibar->icons) < 1)
+ e_gadcon_client_aspect_set(gcc, 1, 1);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
+/**/
+/***************************************************************************/
-/* module private routines */
+/***************************************************************************/
+/**/
+
+// FIXME: ibar specific calls here
static IBar *
-_ibar_new()
+_ibar_new(Evas *evas, char *dir)
{
- IBar *ib;
+ IBar *b;
char buf[4096];
- Evas_List *managers, *l, *l2, *cl;
-
- bar_count = 0;
- ib = E_NEW(IBar, 1);
- if (!ib) return NULL;
-
- conf_bar_edd = E_CONFIG_DD_NEW("IBar_Config_Bar", Config_Bar);
-#undef T
-#undef D
-#define T Config_Bar
-#define D conf_bar_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
-
- conf_edd = E_CONFIG_DD_NEW("IBar_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D conf_edd
- E_CONFIG_VAL(D, T, appdir, STR);
- E_CONFIG_VAL(D, T, follower, INT);
- E_CONFIG_VAL(D, T, follow_speed, DOUBLE);
- E_CONFIG_VAL(D, T, autoscroll_speed, DOUBLE);
- E_CONFIG_VAL(D, T, iconsize, INT);
- E_CONFIG_VAL(D, T, width, INT);
- E_CONFIG_LIST(D, T, bars, conf_bar_edd);
-
- ib->conf = e_config_domain_load("module.ibar", conf_edd);
- if (!ib->conf)
- {
- ib->conf = E_NEW(Config, 1);
- ib->conf->appdir = evas_stringshare_add("bar");
- ib->conf->follower = 1;
- ib->conf->follow_speed = 0.9;
- ib->conf->autoscroll_speed = 0.95;
- ib->conf->iconsize = 24;
- ib->conf->width = IBAR_WIDTH_AUTO;
- }
- E_CONFIG_LIMIT(ib->conf->follow_speed, 0.01, 1.0);
- E_CONFIG_LIMIT(ib->conf->autoscroll_speed, 0.01, 1.0);
- E_CONFIG_LIMIT(ib->conf->iconsize, 2, 400);
- E_CONFIG_LIMIT(ib->conf->width, -2, -1);
-
- _ibar_config_menu_new(ib);
-
- if (ib->conf->appdir[0] != '/')
+
+ b = E_NEW(IBar, 1);
+ b->o_box = e_box_add(evas);
+ e_box_homogenous_set(b->o_box, 1);
+ e_box_orientation_set(b->o_box, 1);
+ e_box_align_set(b->o_box, 0.5, 0.5);
+ if (dir[0] != '/')
{
char *homedir;
homedir = e_user_homedir_get();
if (homedir)
{
- snprintf(buf, sizeof(buf), "%s/.e/e/applications/%s", homedir, ib->conf->appdir);
+ snprintf(buf, sizeof(buf), "%s/.e/e/applications/%s", homedir, dir);
free(homedir);
}
}
else
- strcpy(buf, ib->conf->appdir);
-
- ib->apps = e_app_new(buf, 0);
- if (ib->apps) e_app_subdir_scan(ib->apps, 0);
- e_app_change_callback_add(_ibar_app_change, ib);
-
- managers = e_manager_list();
- cl = ib->conf->bars;
- for (l = managers; l; l = l->next)
- {
- E_Manager *man;
-
- man = l->data;
- for (l2 = man->containers; l2; l2 = l2->next)
- {
- E_Container *con;
- IBar_Bar *ibb;
- /* Config */
- con = l2->data;
- ibb = _ibar_bar_new(ib, con);
- if (ibb)
- {
- E_Menu_Item *mi;
-
- if (!cl)
- {
- ibb->conf = E_NEW(Config_Bar, 1);
- ibb->conf->enabled = 1;
- ib->conf->bars = evas_list_append(ib->conf->bars, ibb->conf);
- }
- else
- {
- ibb->conf = cl->data;
- cl = cl->next;
- }
- /* Menu */
- _ibar_bar_menu_new(ibb);
-
- mi = e_menu_item_new(ib->config_menu);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _ibar_bar_cb_menu_configure, ibb);
-
- mi = e_menu_item_new(ib->config_menu);
- e_menu_item_label_set(mi, con->name);
- e_menu_item_submenu_set(mi, ibb->menu);
-
- /* Setup */
- if (!ibb->conf->enabled)
- _ibar_bar_disable(ibb);
-
- }
- }
- }
- return ib;
+ snprintf(buf, sizeof(buf), dir);
+ b->apps = e_app_new(buf, 0);
+ if (b->apps) e_app_subdir_scan(b->apps, 0);
+ e_app_change_callback_add(_ibar_cb_app_change, b);
+ _ibar_fill(b);
+ return b;
}
static void
-_ibar_free(IBar *ib)
+_ibar_free(IBar *b)
{
- E_CONFIG_DD_FREE(conf_edd);
- E_CONFIG_DD_FREE(conf_bar_edd);
-
- while (ib->bars)
- _ibar_bar_free(ib->bars->data);
- if (ib->apps)
- e_object_unref(E_OBJECT(ib->apps));
-
- if (ib->conf->appdir) evas_stringshare_del(ib->conf->appdir);
- e_app_change_callback_del(_ibar_app_change, ib);
- e_object_del(E_OBJECT(ib->config_menu));
- evas_list_free(ib->conf->bars);
- free(ib->conf);
- free(ib);
+ _ibar_empty(b);
+ evas_object_del(b->o_box);
+ if (b->o_drop) evas_object_del(b->o_drop);
+ if (b->o_drop_over) evas_object_del(b->o_drop_over);
+ e_object_unref(E_OBJECT(b->apps));
+ e_app_change_callback_del(_ibar_cb_app_change, b);
+ free(b);
}
static void
-_ibar_app_change(void *data, E_App *a, E_App_Change ch)
-{
- IBar *ib;
- Evas_List *l, *ll;
-
- ib = data;
- for (l = ib->bars; l; l = l->next)
- {
- IBar_Bar *ibb;
-
- ibb = l->data;
- switch (ch)
- {
- case E_APP_ADD:
- if (e_app_is_parent(ib->apps, a))
- {
- IBar_Icon *ic;
-
- if (e_app_valid_exe_get(a) || (!a->exe))
- {
- ic = _ibar_icon_new(ibb, a);
- if (ic)
- {
- for (ll = ib->apps->subapps; ll; ll = ll->next)
- {
- E_App *a2;
-
- a2 = ll->data;
- ic = _ibar_icon_find(ibb, a2);
- if (ic) _ibar_icon_reorder_after(ic, NULL);
- }
- _ibar_bar_frame_resize(ibb);
- }
- }
- }
- break;
- case E_APP_DEL:
- if (e_app_is_parent(ib->apps, a))
- {
- IBar_Icon *ic;
-
- ic = _ibar_icon_find(ibb, a);
- if (ic) _ibar_icon_free(ic);
- _ibar_bar_frame_resize(ibb);
- }
- break;
- case E_APP_CHANGE:
- if (e_app_is_parent(ib->apps, a))
- {
- IBar_Icon *ic;
-
- ic = _ibar_icon_find(ibb, a);
- if (ic) _ibar_icon_free(ic);
- evas_image_cache_flush(ibb->evas);
- evas_image_cache_reload(ibb->evas);
- ic = _ibar_icon_new(ibb, a);
- if (ic)
- {
- for (ll = ib->apps->subapps; ll; ll = ll->next)
- {
- E_App *a2;
-
- a2 = ll->data;
- ic = _ibar_icon_find(ibb, a2);
- if (ic) _ibar_icon_reorder_after(ic, NULL);
- }
- _ibar_bar_frame_resize(ibb);
- }
- }
- break;
- case E_APP_ORDER:
- if (a == ib->apps)
- {
- for (ll = ib->apps->subapps; ll; ll = ll->next)
- {
- IBar_Icon *ic;
- E_App *a2;
-
- a2 = ll->data;
- ic = _ibar_icon_find(ibb, a2);
- if (ic) _ibar_icon_reorder_after(ic, NULL);
- }
- }
- break;
- case E_APP_EXEC:
- if (e_app_is_parent(ib->apps, a))
- {
- IBar_Icon *ic;
-
- ic = _ibar_icon_find(ibb, a);
- if (ic)
- {
- if (a->startup_notify)
- {
- edje_object_signal_emit(ic->icon_object, "start", "");
- for (ll = ic->extra_icons; ll; ll = ll->next) edje_object_signal_emit(ll->data, "start", "");
- edje_object_signal_emit(ic->bg_object, "start", "");
- edje_object_signal_emit(ic->overlay_object, "start", "");
- if (ic->ibb->overlay_object)
- edje_object_signal_emit(ic->ibb->overlay_object, "start", "");
- }
- else
- {
- edje_object_signal_emit(ic->icon_object, "exec", "");
- for (ll = ic->extra_icons; ll; ll = ll->next) edje_object_signal_emit(ll->data, "exec", "");
- edje_object_signal_emit(ic->bg_object, "exec", "");
- edje_object_signal_emit(ic->overlay_object, "exec", "");
- if (ic->ibb->overlay_object)
- edje_object_signal_emit(ic->ibb->overlay_object, "exec", "");
- }
- }
- }
- break;
- case E_APP_READY:
- case E_APP_READY_EXPIRE:
- case E_APP_EXIT:
- if (e_app_is_parent(ib->apps, a))
- {
- if (a->startup_notify)
- {
- IBar_Icon *ic;
-
- ic = _ibar_icon_find(ibb, a);
- if (ic)
- {
- edje_object_signal_emit(ic->icon_object, "stop", "");
- for (ll = ic->extra_icons; ll; ll = ll->next) edje_object_signal_emit(ll->data, "stop", "");
- edje_object_signal_emit(ic->bg_object, "stop", "");
- edje_object_signal_emit(ic->overlay_object, "stop", "");
- if (ic->ibb->overlay_object)
- edje_object_signal_emit(ic->ibb->overlay_object, "stop", "");
- }
- }
- }
- break;
- default:
- break;
- }
- }
-}
-
-static IBar_Bar *
-_ibar_bar_new(IBar *ib, E_Container *con)
+_ibar_fill(IBar *b)
{
- IBar_Bar *ibb;
+ IBar_Icon *ic;
Evas_List *l;
- Evas_Object *o;
- E_Gadman_Policy policy;
- Evas_Coord x, y, w, h;
- const char *drop[] = { "enlightenment/eapp", "enlightenment/border", "text/uri-list" };
-
- ibb = E_NEW(IBar_Bar, 1);
- if (!ibb) return NULL;
- ibb->ibar = ib;
- ib->bars = evas_list_append(ib->bars, ibb);
-
- ibb->con = con;
- e_object_ref(E_OBJECT(con));
- ibb->evas = con->bg_evas;
-
- ibb->x = ibb->y = ibb->w = ibb->h = -1;
+ E_App *a;
- evas_event_freeze(ibb->evas);
- o = edje_object_add(ibb->evas);
- ibb->bar_object = o;
- e_theme_edje_object_set(o, "base/theme/modules/ibar",
- "modules/ibar/main");
- evas_object_show(o);
-
- if (ibb->ibar->conf->follower)
+ for (l = b->apps->subapps; l; l = l->next)
{
- o = edje_object_add(ibb->evas);
- ibb->overlay_object = o;
- evas_object_layer_set(o, 2);
- e_theme_edje_object_set(o, "base/theme/modules/ibar",
- "modules/ibar/follower");
- evas_object_show(o);
+ a = l->data;
+ ic = _ibar_icon_new(b, a);
+ b->icons = evas_list_append(b->icons, ic);
+ e_box_pack_end(b->o_box, ic->o_holder);
}
-
- o = evas_object_rectangle_add(ibb->evas);
- ibb->event_object = o;
- evas_object_layer_set(o, 3);
- evas_object_repeat_events_set(o, 1);
- evas_object_color_set(o, 0, 0, 0, 0);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _ibar_bar_cb_mouse_in, ibb);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _ibar_bar_cb_mouse_out, ibb);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _ibar_bar_cb_mouse_down, ibb);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _ibar_bar_cb_mouse_up, ibb);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _ibar_bar_cb_mouse_move, ibb);
- evas_object_show(o);
-
- o = e_box_add(ibb->evas);
- ibb->box_object = o;
- evas_object_intercept_move_callback_add(o, _ibar_bar_cb_intercept_move, ibb);
- evas_object_intercept_resize_callback_add(o, _ibar_bar_cb_intercept_resize, ibb);
- e_box_freeze(o);
- edje_object_part_swallow(ibb->bar_object, "items", o);
- evas_object_show(o);
-
- if (ibb->ibar->apps)
- {
- for (l = ibb->ibar->apps->subapps; l; l = l->next)
- {
- E_App *a;
- IBar_Icon *ic;
-
- a = l->data;
- if (e_app_valid_exe_get(a) || (!a->exe))
- {
- ic = _ibar_icon_new(ibb, a);
- }
- }
- }
- ibb->align_req = 0.5;
- ibb->align = 0.5;
- e_box_align_set(ibb->box_object, 0.5, 0.5);
-
- e_box_thaw(ibb->box_object);
-
- evas_object_resize(ibb->bar_object, 1000, 1000);
- edje_object_calc_force(ibb->bar_object);
- edje_object_part_geometry_get(ibb->bar_object, "items", &x, &y, &w, &h);
- ibb->bar_inset.l = x;
- ibb->bar_inset.r = 1000 - (x + w);
- ibb->bar_inset.t = y;
- ibb->bar_inset.b = 1000 - (y + h);
-
- o = edje_object_add(ibb->evas);
- e_theme_edje_object_set(o, "base/theme/modules/ibar",
- "modules/ibar/icon");
- evas_object_resize(o, 100, 100);
- edje_object_calc_force(o);
- edje_object_part_geometry_get(o, "item", &x, &y, &w, &h);
- ibb->icon_inset.l = x;
- ibb->icon_inset.r = 100 - (x + w);
- ibb->icon_inset.t = y;
- ibb->icon_inset.b = 100 - (y + h);
- evas_object_del(o);
-
- ibb->drop_handler = e_drop_handler_add(ibb,
- _ibar_bar_cb_enter, _ibar_bar_cb_move,
- _ibar_bar_cb_leave, _ibar_bar_cb_drop,
- drop, 3,
- ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
- ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
- ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
-
- ibb->gmc = e_gadman_client_new(ibb->con->gadman);
- e_gadman_client_domain_set(ibb->gmc, "module.ibar", bar_count++);
- policy = E_GADMAN_POLICY_EDGES | E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_VMOVE;
- if (ibb->ibar->conf->width == IBAR_WIDTH_FIXED)
- policy |= E_GADMAN_POLICY_HSIZE;
-
- e_gadman_client_policy_set(ibb->gmc, policy);
- e_gadman_client_min_size_set(ibb->gmc, 8, 8);
- e_gadman_client_max_size_set(ibb->gmc, 3200, 3200);
- e_gadman_client_auto_size_set(ibb->gmc, -1, -1);
- e_gadman_client_align_set(ibb->gmc, 0.5, 1.0);
- e_gadman_client_resize(ibb->gmc, 400, 40);
- e_gadman_client_change_func_set(ibb->gmc, _ibar_bar_cb_gmc_change, ibb);
- e_gadman_client_edge_set(ibb->gmc, E_GADMAN_EDGE_BOTTOM);
- e_gadman_client_load(ibb->gmc);
-
- evas_event_thaw(ibb->evas);
-
- /* We need to resize, if the width is auto and the number
- * of apps has changed since last startup */
- _ibar_bar_frame_resize(ibb);
-
- /*
- edje_object_signal_emit(ibb->bar_object, "passive", "");
- edje_object_signal_emit(ibb->overlay_object, "passive", "");
- */
-
- return ibb;
-}
-
-static void
-_ibar_bar_free(IBar_Bar *ibb)
-{
- e_object_unref(E_OBJECT(ibb->con));
-
- e_object_del(E_OBJECT(ibb->menu));
-
- while (ibb->icons)
- _ibar_icon_free(ibb->icons->data);
-
- e_drop_handler_del(ibb->drop_handler);
-
- if (ibb->timer) ecore_timer_del(ibb->timer);
- if (ibb->animator) ecore_animator_del(ibb->animator);
- evas_object_del(ibb->bar_object);
- if (ibb->overlay_object) evas_object_del(ibb->overlay_object);
- evas_object_del(ibb->box_object);
- evas_object_del(ibb->event_object);
- if (ibb->drag_object) evas_object_del(ibb->drag_object);
- ibb->drag_object = NULL;
- if (ibb->drag_object_overlay) evas_object_del(ibb->drag_object_overlay);
- ibb->drag_object_overlay = NULL;
-
- e_gadman_client_save(ibb->gmc);
- e_object_del(E_OBJECT(ibb->gmc));
-
- ibb->ibar->bars = evas_list_remove(ibb->ibar->bars, ibb);
-
- free(ibb->conf);
- free(ibb);
- bar_count--;
+ _ibar_resize_handle(b);
}
static void
-_ibar_bar_menu_new(IBar_Bar *ibb)
+_ibar_empty(IBar *b)
{
- E_Menu *mn;
- E_Menu_Item *mi;
-
- mn = e_menu_new();
- ibb->menu = mn;
-
- /* Config */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _ibar_bar_cb_menu_configure, ibb);
-
- /* Edit */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Edit Mode"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _ibar_bar_cb_menu_edit, ibb);
+ while (b->icons)
+ {
+ _ibar_icon_free(b->icons->data);
+ b->icons = evas_list_remove_list(b->icons, b->icons);
+ }
}
static void
-_ibar_bar_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
+_ibar_orient_set(IBar *b, int horizontal)
{
- IBar_Bar *ibb;
-
- ibb = data;
- if (!ibb) return;
- _config_ibar_module(ibb->con, ibb->ibar);
+ e_box_orientation_set(b->o_box, horizontal);
+ e_box_align_set(b->o_box, 0.5, 0.5);
}
-/*
static void
-_ibar_bar_enable(IBar_Bar *ibb)
+_ibar_resize_handle(IBar *b)
{
- ibb->conf->enabled = 1;
- evas_object_show(ibb->bar_object);
- if (ibb->overlay_object) evas_object_show(ibb->overlay_object);
- evas_object_show(ibb->box_object);
- evas_object_show(ibb->event_object);
- e_config_save_queue();
+ Evas_List *l;
+ IBar_Icon *ic;
+ Evas_Coord w, h;
+
+ evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
+ if (e_box_orientation_get(b->o_box))
+ w = h;
+ else
+ h = w;
+ e_box_freeze(b->o_box);
+ for (l = b->icons; l; l = l->next)
+ {
+ ic = l->data;
+ e_box_pack_options_set(ic->o_holder,
+ 1, 1, /* fill */
+ 0, 0, /* expand */
+ 0.5, 0.5, /* align */
+ w, h, /* min */
+ w, h /* max */
+ );
+ }
+ e_box_thaw(b->o_box);
}
-*/
static void
-_ibar_bar_disable(IBar_Bar *ibb)
+_ibar_instance_drop_zone_recalc(Instance *inst)
{
- ibb->conf->enabled = 0;
- evas_object_hide(ibb->bar_object);
- if (ibb->overlay_object) evas_object_hide(ibb->overlay_object);
- evas_object_hide(ibb->box_object);
- evas_object_hide(ibb->event_object);
- e_config_save_queue();
-}
+ Evas_Coord x, y, w, h;
+ int cx, cy, cw, ch;
+
+ evas_object_geometry_get(inst->o_ibar, &x, &y, &w, &h);
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ e_drop_handler_geometry_set(inst->drop_handler, cx + x, cy + y, w, h);
+}
-static IBar_Icon *
-_ibar_icon_new(IBar_Bar *ibb, E_App *a)
+static Config_Item *
+_ibar_config_item_get(char *id)
{
- IBar_Icon *ic;
- // char *str;
- Evas_Object *o;
- Evas_Coord w, h;
-
- ic = E_NEW(IBar_Icon, 1);
- if (!ic) return NULL;
- ic->ibb = ibb;
- ic->app = a;
- e_object_ref(E_OBJECT(a));
- ibb->icons = evas_list_append(ibb->icons, ic);
-
- o = evas_object_rectangle_add(ibb->evas);
- ic->event_object = o;
- evas_object_layer_set(o, 1);
- evas_object_clip_set(o, evas_object_clip_get(ibb->box_object));
- evas_object_color_set(o, 0, 0, 0, 0);
- evas_object_repeat_events_set(o, 1);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _ibar_icon_cb_mouse_in, ic);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _ibar_icon_cb_mouse_out, ic);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _ibar_icon_cb_mouse_down, ic);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _ibar_icon_cb_mouse_up, ic);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _ibar_icon_cb_mouse_move, ic);
- evas_object_show(o);
-
- o = edje_object_add(ibb->evas);
- ic->bg_object = o;
- evas_object_intercept_move_callback_add(o, _ibar_icon_cb_intercept_move, ic);
- evas_object_intercept_resize_callback_add(o, _ibar_icon_cb_intercept_resize, ic);
- e_theme_edje_object_set(o, "base/theme/modules/ibar",
- "modules/ibar/icon");
- evas_object_show(o);
-
- o = edje_object_add(ibb->evas);
- ic->icon_object = o;
- evas_object_resize(o, ibb->ibar->conf->iconsize, ibb->ibar->conf->iconsize);
- edje_object_file_set(o, ic->app->path, "icon");
- edje_object_part_swallow(ic->bg_object, "item", o);
- evas_object_pass_events_set(o, 1);
- evas_object_show(o);
-
- o = edje_object_add(ibb->evas);
- ic->overlay_object = o;
- evas_object_intercept_move_callback_add(o, _ibar_icon_cb_intercept_move, ic);
- evas_object_intercept_resize_callback_add(o, _ibar_icon_cb_intercept_resize, ic);
- e_theme_edje_object_set(o, "base/theme/modules/ibar",
- "modules/ibar/icon_overlay");
- evas_object_show(o);
-
- o = edje_object_add(ibb->evas);
- ic->extra_icons = evas_list_append(ic->extra_icons, o);
- edje_object_file_set(o, ic->app->path, "icon");
- edje_object_part_swallow(ic->overlay_object, "item", o);
- evas_object_pass_events_set(o, 1);
- evas_object_show(o);
-
- evas_object_raise(ic->event_object);
-
- w = ibb->ibar->conf->iconsize + ibb->icon_inset.l + ibb->icon_inset.r;
- h = ibb->ibar->conf->iconsize + ibb->icon_inset.t + ibb->icon_inset.b;
- e_box_pack_end(ibb->box_object, ic->bg_object);
- e_box_pack_options_set(ic->bg_object,
- 1, 1, /* fill */
- 0, 0, /* expand */
- 0.5, 0.5, /* align */
- w, h, /* min */
- w, h /* max */
- );
-
-/*
- str = (char *)edje_object_data_get(ic->icon_object, "raise_on_hilight");
- if (str)
+ Evas_List *l;
+ Config_Item *ci;
+
+ for (l = ibar_config->items; l; l = l->next)
{
- if (atoi(str) == 1) ic->raise_on_hilight = 1;
+ ci = l->data;
+ if ((ci->id) && (ci->dir) && (!strcmp(ci->id, id)))
+ return ci;
}
-*/
- edje_object_signal_emit(ic->bg_object, "passive", "");
- edje_object_signal_emit(ic->overlay_object, "passive", "");
- return ic;
+ ci = E_NEW(Config_Item, 1);
+ ci->id = evas_stringshare_add(id);
+ ibar_config->items = evas_list_append(ibar_config->items, ci);
+ return ci;
}
-static void
-_ibar_icon_free(IBar_Icon *ic)
+void
+_ibar_config_update(void)
{
- ic->ibb->icons = evas_list_remove(ic->ibb->icons, ic);
- if (ic->bg_object) evas_object_del(ic->bg_object);
- if (ic->overlay_object) evas_object_del(ic->overlay_object);
- if (ic->icon_object) evas_object_del(ic->icon_object);
- if (ic->event_object) evas_object_del(ic->event_object);
- while (ic->extra_icons)
+ Evas_List *l;
+
+ for (l = ibar_config->instances; l; l = l->next)
{
- Evas_Object *o;
-
- o = ic->extra_icons->data;
- ic->extra_icons = evas_list_remove_list(ic->extra_icons, ic->extra_icons);
- evas_object_del(o);
+ Instance *inst;
+ Config_Item *ci;
+
+ inst = l->data;
+ ci = _ibar_config_item_get(inst->gcc->id);
+ if ((inst->dir) && (ci->dir) && (strcmp(ci->dir, inst->dir)))
+ {
+ char buf[4096];
+
+ evas_stringshare_del(inst->dir);
+ inst->dir = evas_stringshare_add(ci->dir);
+ _ibar_empty(inst->ibar);
+ e_object_unref(E_OBJECT(inst->ibar->apps));
+ if (inst->dir[0] != '/')
+ {
+ char *homedir;
+
+ homedir = e_user_homedir_get();
+ if (homedir)
+ {
+ snprintf(buf, sizeof(buf), "%s/.e/e/applications/%s", homedir, inst->dir);
+ free(homedir);
+ }
+ }
+ else
+ snprintf(buf, sizeof(buf), inst->dir);
+ inst->ibar->apps = e_app_new(buf, 0);
+ if (inst->ibar->apps) e_app_subdir_scan(inst->ibar->apps, 0);
+ _ibar_fill(inst->ibar);
+ _ibar_resize_handle(inst->ibar);
+ _gc_orient(inst->gcc);
+ }
}
- e_object_unref(E_OBJECT(ic->app));
- free(ic);
}
static IBar_Icon *
-_ibar_icon_find(IBar_Bar *ibb, E_App *a)
+_ibar_icon_find(IBar *b, E_App *a)
{
Evas_List *l;
-
- for (l = ibb->icons; l; l = l->next)
+ IBar_Icon *ic;
+
+ for (l = b->icons; l; l = l->next)
{
- IBar_Icon *ic;
-
ic = l->data;
- if (e_app_equals(ic->app, a))
- return ic;
+
+ if (ic->app == a) return ic;
}
return NULL;
}
static IBar_Icon *
-_ibar_icon_pos_find(IBar_Bar *ibb, int x, int y)
+_ibar_icon_at_coord(IBar *b, Evas_Coord x, Evas_Coord y)
{
+ Evas_List *l;
IBar_Icon *ic;
- double pos, iw;
- int w, h;
-
- x = x - (ibb->x + ibb->bar_inset.l);
- y = y - (ibb->y + ibb->bar_inset.t);
- w = ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r);
- h = ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b);
-
- if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
- {
- iw = w / (double) e_box_pack_count_get(ibb->box_object);
- pos = x / iw;
- }
- else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
+
+ for (l = b->icons; l; l = l->next)
{
- iw = h / (double) e_box_pack_count_get(ibb->box_object);
- pos = y / iw;
+ Evas_Coord dx, dy, dw, dh;
+ ic = l->data;
+
+ evas_object_geometry_get(ic->o_holder, &dx, &dy, &dw, &dh);
+ if (E_INSIDE(x, y, dx, dy, dw, dh)) return ic;
}
-
- ic = evas_list_nth(ibb->icons, pos);
- return ic;
+ return NULL;
}
-void
-_ibar_config_menu_new(IBar *ib)
+static IBar_Icon *
+_ibar_icon_new(IBar *b, E_App *a)
{
- E_Menu *mn;
-
- mn = e_menu_new();
- ib->config_menu = mn;
+ IBar_Icon *ic;
+
+ ic = E_NEW(IBar_Icon, 1);
+ e_object_ref(E_OBJECT(a));
+ ic->ibar = b;
+ ic->app = a;
+ ic->o_holder = edje_object_add(evas_object_evas_get(b->o_box));
+ e_theme_edje_object_set(ic->o_holder, "base/theme/modules/ibar",
+ "modules/ibar/icon");
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_IN, _ibar_cb_icon_mouse_in, ic);
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_OUT, _ibar_cb_icon_mouse_out, ic);
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_DOWN, _ibar_cb_icon_mouse_down, ic);
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_UP, _ibar_cb_icon_mouse_up, ic);
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_MOVE, _ibar_cb_icon_mouse_move, ic);
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOVE, _ibar_cb_icon_move, ic);
+ evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_RESIZE, _ibar_cb_icon_resize, ic);
+ evas_object_show(ic->o_holder);
+
+ ic->o_holder2 = edje_object_add(evas_object_evas_get(b->o_box));
+ e_theme_edje_object_set(ic->o_holder2, "base/theme/modules/ibar",
+ "modules/ibar/icon_overlay");
+ evas_object_layer_set(ic->o_holder2, 9999);
+ evas_object_pass_events_set(ic->o_holder2, 1);
+ evas_object_show(ic->o_holder2);
+
+ _ibar_icon_fill(ic);
+ return ic;
}
-#if 0
static void
-_ibar_icon_reorder_before(IBar_Icon *ic, IBar_Icon *before)
+_ibar_icon_free(IBar_Icon *ic)
{
- Evas_Coord bw, bh;
+ Evas_Object *o;
- e_box_freeze(ic->ibb->box_object);
- e_box_unpack(ic->bg_object);
- ic->ibb->icons = evas_list_remove(ic->ibb->icons, ic);
- if (before)
- {
- ic->ibb->icons = evas_list_prepend_relative(ic->ibb->icons, ic, before);
- e_box_pack_before(ic->ibb->box_object, ic->bg_object, before->bg_object);
- }
- else
+ if (ibar_config->menu)
{
- ic->ibb->icons = evas_list_prepend(ic->ibb->icons, ic);
- e_box_pack_start(ic->ibb->box_object, ic->bg_object);
+ e_object_del(E_OBJECT(ibar_config->menu));
+ ibar_config->menu = NULL;
}
- edje_object_size_min_calc(ic->bg_object, &bw, &bh);
- e_box_pack_options_set(ic->bg_object,
- 1, 1, /* fill */
- 0, 0, /* expand */
- 0.5, 0.5, /* align */
- bw, bh, /* min */
- bw, bh /* max */
- );
- e_box_thaw(ic->ibb->box_object);
+ if (ic->ibar->ic_drop_before == ic)
+ ic->ibar->ic_drop_before = NULL;
+ _ibar_icon_empty(ic);
+ evas_object_del(ic->o_holder);
+ evas_object_del(ic->o_holder2);
+ e_object_unref(E_OBJECT(ic->app));
+ free(ic);
}
-#endif
static void
-_ibar_icon_reorder_after(IBar_Icon *ic, IBar_Icon *after)
+_ibar_icon_fill(IBar_Icon *ic)
{
- Evas_Coord w, h;
-
- e_box_freeze(ic->ibb->box_object);
- e_box_unpack(ic->bg_object);
- ic->ibb->icons = evas_list_remove(ic->ibb->icons, ic);
- if (after)
- {
- ic->ibb->icons = evas_list_append_relative(ic->ibb->icons, ic, after);
- e_box_pack_after(ic->ibb->box_object, ic->bg_object, after->bg_object);
- }
- else
- {
- ic->ibb->icons = evas_list_append(ic->ibb->icons, ic);
- e_box_pack_end(ic->ibb->box_object, ic->bg_object);
- }
- w = ic->ibb->ibar->conf->iconsize + ic->ibb->icon_inset.l + ic->ibb->icon_inset.r;
- h = ic->ibb->ibar->conf->iconsize + ic->ibb->icon_inset.t + ic->ibb->icon_inset.b;
- e_box_pack_options_set(ic->bg_object,
- 1, 1, /* fill */
- 0, 0, /* expand */
- 0.5, 0.5, /* align */
- w, h, /* min */
- w, h /* max */
- );
- e_box_thaw(ic->ibb->box_object);
+ ic->o_icon = edje_object_add(evas_object_evas_get(ic->ibar->o_box));
+ edje_object_file_set(ic->o_icon, ic->app->path, "icon");
+ edje_object_part_swallow(ic->o_holder, "item", ic->o_icon);
+ evas_object_pass_events_set(ic->o_icon, 1);
+ evas_object_show(ic->o_icon);
+ ic->o_icon2 = edje_object_add(evas_object_evas_get(ic->ibar->o_box));
+ edje_object_file_set(ic->o_icon2, ic->app->path, "icon");
+ edje_object_part_swallow(ic->o_holder2, "item", ic->o_icon2);
+ evas_object_pass_events_set(ic->o_icon2, 1);
+ evas_object_show(ic->o_icon2);
}
static void
-_ibar_bar_frame_resize(IBar_Bar *ibb)
+_ibar_icon_empty(IBar_Icon *ic)
{
- Evas_Coord w, h, bw, bh;
- /* Not finished loading config yet! */
- if ((ibb->x == -1) || (ibb->y == -1) ||
- (ibb->w == -1) || (ibb->h == -1))
- return;
-
- evas_event_freeze(ibb->evas);
- e_box_freeze(ibb->box_object);
-
- e_box_min_size_get(ibb->box_object, &w, &h);
- edje_extern_object_min_size_set(ibb->box_object, w, h);
- edje_object_part_swallow(ibb->bar_object, "items", ibb->box_object);
- edje_object_size_min_calc(ibb->bar_object, &bw, &bh);
- edje_extern_object_min_size_set(ibb->box_object, 0, 0);
- edje_object_part_swallow(ibb->bar_object, "items", ibb->box_object);
-
- e_box_thaw(ibb->box_object);
- evas_event_thaw(ibb->evas);
-
- if (ibb->ibar->conf->width == IBAR_WIDTH_AUTO)
- {
- e_gadman_client_resize(ibb->gmc, bw, bh);
- }
- else
- {
- if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
- {
- /* h is the width of the bar */
- e_gadman_client_resize(ibb->gmc, bw, ibb->h);
- }
- else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM))
- {
- /* w is the width of the bar */
- e_gadman_client_resize(ibb->gmc, ibb->w, bh);
- }
- }
+ evas_object_del(ic->o_icon);
+ evas_object_del(ic->o_icon2);
+ ic->o_icon = NULL;
}
static void
-_ibar_bar_edge_change(IBar_Bar *ibb, int edge)
+_ibar_icon_signal_emit(IBar_Icon *ic, char *sig, char *src)
{
- Evas_List *l;
- Evas_Coord w, h, tmp;
- Evas_Object *o;
- E_Gadman_Policy policy;
- int changed;
-
- evas_event_freeze(ibb->evas);
- o = ibb->bar_object;
- edje_object_signal_emit(o, "set_orientation", _ibar_main_orientation[edge]);
- edje_object_message_signal_process(o);
-
- if (ibb->overlay_object)
- {
- o = ibb->overlay_object;
- edje_object_signal_emit(o, "set_orientation", _ibar_main_orientation[edge]);
- edje_object_message_signal_process(o);
- }
-
- e_box_freeze(ibb->box_object);
-
- for (l = ibb->icons; l; l = l->next)
- {
- IBar_Icon *ic;
-
- ic = l->data;
- o = ic->bg_object;
- edje_object_signal_emit(o, "set_orientation", _ibar_main_orientation[edge]);
- edje_object_message_signal_process(o);
-
- o = ic->overlay_object;
- edje_object_signal_emit(o, "set_orientation", _ibar_main_orientation[edge]);
- edje_object_message_signal_process(o);
-
- w = ibb->ibar->conf->iconsize + ibb->icon_inset.l + ibb->icon_inset.r;
- h = ibb->ibar->conf->iconsize + ibb->icon_inset.t + ibb->icon_inset.b;
- e_box_pack_options_set(ic->bg_object,
- 1, 1, /* fill */
- 0, 0, /* expand */
- 0.5, 0.5, /* align */
- w, h, /* min */
- w, h /* max */
- );
- }
+ edje_object_signal_emit(ic->o_holder, sig, src);
+ edje_object_signal_emit(ic->o_icon, sig, src);
+ edje_object_signal_emit(ic->o_holder2, sig, src);
+ edje_object_signal_emit(ic->o_icon2, sig, src);
+}
- ibb->align_req = 0.5;
- ibb->align = 0.5;
- e_box_align_set(ibb->box_object, 0.5, 0.5);
+static void
+_ibar_cb_app_change(void *data, E_App *a, E_App_Change ch)
+{
+ IBar *b;
- policy = E_GADMAN_POLICY_EDGES | E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_VMOVE;
- if ((edge == E_GADMAN_EDGE_BOTTOM) ||
- (edge == E_GADMAN_EDGE_TOP))
+ b = data;
+ switch (ch)
{
- changed = (e_box_orientation_get(ibb->box_object) != 1);
- if (changed)
+ case E_APP_ADD:
+ printf("ADD! %3.4f\n", ecore_time_get());
+ if (e_app_is_parent(b->apps, a))
{
- e_box_orientation_set(ibb->box_object, 1);
- if (ibb->ibar->conf->width == IBAR_WIDTH_FIXED)
- policy |= E_GADMAN_POLICY_HSIZE;
- e_gadman_client_policy_set(ibb->gmc, policy);
- tmp = ibb->w;
- ibb->w = ibb->h;
- ibb->h = tmp;
+ E_App *a2, *a_before = NULL;
+ IBar_Icon *ic2 = NULL, *ic;
+ Evas_List *l;
+
+ ic = _ibar_icon_find(b, a);
+ if (!ic)
+ {
+ for (l = b->apps->subapps; l; l = l->next)
+ {
+ a2 = l->data;
+ if ((a2 == a) && (l->next))
+ {
+ a_before = l->next->data;
+ break;
+ }
+ }
+ ic = _ibar_icon_new(b, a);
+ if (a_before) ic2 = _ibar_icon_find(b, a_before);
+ if (ic2)
+ {
+ b->icons = evas_list_prepend_relative(b->icons, ic, ic2);
+ e_box_pack_before(b->o_box, ic->o_holder, ic2->o_holder);
+ }
+ else
+ {
+ b->icons = evas_list_append(b->icons, ic);
+ e_box_pack_end(b->o_box, ic->o_holder);
+ }
+ _ibar_resize_handle(b);
+ _gc_orient(b->inst->gcc);
+ }
+ else
+ {
+ /* FIXME: complain */
+ }
}
- }
- else if ((edge == E_GADMAN_EDGE_LEFT) ||
- (edge == E_GADMAN_EDGE_RIGHT))
- {
- changed = (e_box_orientation_get(ibb->box_object) != 0);
- if (changed)
+ break;
+ case E_APP_DEL:
+ printf("DEL! %3.4f\n", ecore_time_get());
+ if (e_app_is_parent(b->apps, a))
{
- e_box_orientation_set(ibb->box_object, 0);
- if (ibb->ibar->conf->width == IBAR_WIDTH_FIXED)
- policy |= E_GADMAN_POLICY_VSIZE;
- e_gadman_client_policy_set(ibb->gmc, policy);
- tmp = ibb->w;
- ibb->w = ibb->h;
- ibb->h = tmp;
+ IBar_Icon *ic;
+
+ ic = _ibar_icon_find(b, a);
+ if (ic)
+ {
+ b->icons = evas_list_remove(b->icons, ic);
+ _ibar_icon_free(ic);
+ }
+ _ibar_resize_handle(b);
+ _gc_orient(b->inst->gcc);
}
- }
-
- e_box_thaw(ibb->box_object);
- evas_event_thaw(ibb->evas);
-
- _ibar_bar_frame_resize(ibb);
-}
-
-static void
-_ibar_bar_update_policy(IBar_Bar *ibb)
-{
- E_Gadman_Policy policy;
-
- policy = E_GADMAN_POLICY_EDGES | E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_VMOVE;
-
- if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
- {
- if (ibb->ibar->conf->width == IBAR_WIDTH_FIXED)
- policy |= E_GADMAN_POLICY_HSIZE;
- e_gadman_client_policy_set(ibb->gmc, policy);
- }
- else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
- {
- if (ibb->ibar->conf->width == IBAR_WIDTH_FIXED)
- policy |= E_GADMAN_POLICY_VSIZE;
- e_gadman_client_policy_set(ibb->gmc, policy);
- }
-}
-
-static void
-_ibar_bar_motion_handle(IBar_Bar *ibb, Evas_Coord mx, Evas_Coord my)
-{
- Evas_Coord x, y, w, h;
- double relx, rely;
-
- evas_object_geometry_get(ibb->box_object, &x, &y, &w, &h);
- if (w > 0) relx = (double)(mx - x) / (double)w;
- else relx = 0.0;
- if (h > 0) rely = (double)(my - y) / (double)h;
- else rely = 0.0;
- if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
- {
- ibb->align_req = 1.0 - relx;
- ibb->follow_req = relx;
- }
- else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
- {
- ibb->align_req = 1.0 - rely;
- ibb->follow_req = rely;
+ break;
+ case E_APP_CHANGE:
+ printf("CHANGE! %3.4f\n", ecore_time_get());
+ if (e_app_is_parent(b->apps, a))
+ {
+ IBar_Icon *ic;
+
+ ic = _ibar_icon_find(b, a);
+ if (ic)
+ {
+ _ibar_icon_empty(ic);
+ _ibar_icon_fill(ic);
+ }
+ _ibar_resize_handle(b);
+ _gc_orient(b->inst->gcc);
+ }
+ break;
+ case E_APP_ORDER:
+ printf("ORDER! %3.4f\n", ecore_time_get());
+ if (a == b->apps)
+ {
+ _ibar_empty(b);
+ _ibar_fill(b);
+ _ibar_resize_handle(b);
+ _gc_orient(b->inst->gcc);
+ }
+ break;
+ case E_APP_EXEC:
+ if (e_app_is_parent(b->apps, a))
+ {
+ IBar_Icon *ic;
+
+ ic = _ibar_icon_find(b, a);
+ if (ic)
+ {
+ if (a->startup_notify)
+ _ibar_icon_signal_emit(ic, "start", "");
+ else
+ _ibar_icon_signal_emit(ic, "exec", "");
+ }
+ }
+ break;
+ case E_APP_READY:
+ case E_APP_READY_EXPIRE:
+ case E_APP_EXIT:
+ if (e_app_is_parent(b->apps, a))
+ {
+ IBar_Icon *ic;
+
+ ic = _ibar_icon_find(b, a);
+ if (ic) _ibar_icon_signal_emit(ic, "stop", "");
+ }
+ break;
+ default:
+ break;
}
}
-static void
-_ibar_bar_timer_handle(IBar_Bar *ibb)
+static int
+_ibar_cb_timer_drop_recalc(void *data)
{
- if (!ibb->timer)
- ibb->timer = ecore_timer_add(0.01, _ibar_bar_cb_timer, ibb);
- if (!ibb->animator)
- ibb->animator = ecore_animator_add(_ibar_bar_cb_animator, ibb);
+ Instance *inst;
+
+ inst = data;
+ _ibar_instance_drop_zone_recalc(inst);
+ return 1;
}
static void
-_ibar_bar_follower_reset(IBar_Bar *ibb)
+_ibar_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Evas_Coord ww, hh, bx, by, bw, bh, d1, d2, mw, mh;
-
- if (!ibb->overlay_object) return;
-
- evas_output_viewport_get(ibb->evas, NULL, NULL, &ww, &hh);
- evas_object_geometry_get(ibb->box_object, &bx, &by, &bw, &bh);
- edje_object_size_min_get(ibb->overlay_object, &mw, &mh);
- if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
- {
- d1 = bx;
- d2 = ww - (bx + bw);
- if (bw > 0)
- {
- if (d1 < d2)
- ibb->follow_req = -((double)(d1 + (mw * 4)) / (double)bw);
- else
- ibb->follow_req = 1.0 + ((double)(d2 + (mw * 4)) / (double)bw);
- }
- }
- else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
- {
- d1 = by;
- d2 = hh - (by + bh);
- if (bh > 0)
- {
- if (d1 < d2)
- ibb->follow_req = -((double)(d1 + (mh * 4)) / (double)bh);
- else
- ibb->follow_req = 1.0 + ((double)(d2 + (mh * 4)) / (double)bh);
- }
- }
+ Instance *inst;
+
+ inst = data;
+ _ibar_resize_handle(inst->ibar);
+ _ibar_instance_drop_zone_recalc(inst);
}
static void
-_ibar_icon_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y)
+_ibar_cb_menu_icon_properties(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar_Icon *ic;
-
+
ic = data;
- evas_object_move(o, x, y);
- evas_object_move(ic->event_object, x, y);
- evas_object_move(ic->overlay_object, x, y);
+ /* FIXME: - show eap editor on the ic->app */
}
static void
-_ibar_icon_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h)
+_ibar_cb_menu_icon_remove(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar_Icon *ic;
-
+
ic = data;
- evas_object_resize(o, w, h);
- evas_object_resize(ic->event_object, w, h);
- evas_object_resize(ic->overlay_object, w, h);
+ ic->ibar->icons = evas_list_remove(ic->ibar->icons, ic);
+ _ibar_resize_handle(ic->ibar);
+ _gc_orient(ic->ibar->inst->gcc);
+ e_app_remove(ic->app);
+ _ibar_icon_free(ic);
}
static void
-_ibar_bar_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y)
+_ibar_cb_menu_configuration(void *data, E_Menu *m, E_Menu_Item *mi)
{
- IBar_Bar *ibb;
-
- ibb = data;
- evas_object_move(o, x, y);
- evas_object_move(ibb->event_object, x, y);
+ IBar_Icon *ic;
+ Config_Item *ci;
+
+ ic = data;
+ ci = _ibar_config_item_get(ic->ibar->inst->gcc->id);
+ _config_ibar_module(ci);
}
static void
-_ibar_bar_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h)
+_ibar_cb_menu_post(void *data, E_Menu *m)
{
- IBar_Bar *ibb;
-
- ibb = data;
-
- evas_object_resize(o, w, h);
- evas_object_resize(ibb->event_object, w, h);
+ if (!ibar_config->menu) return;
+ e_object_del(E_OBJECT(ibar_config->menu));
+ ibar_config->menu = NULL;
}
static void
-_ibar_icon_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_In *ev;
IBar_Icon *ic;
-
+
ev = event_info;
ic = data;
- evas_event_freeze(ic->ibb->evas);
- evas_object_raise(ic->event_object);
- if (ic->raise_on_hilight)
- evas_object_stack_below(ic->bg_object, ic->event_object);
- evas_object_stack_below(ic->overlay_object, ic->event_object);
- evas_event_thaw(ic->ibb->evas);
- edje_object_signal_emit(ic->bg_object, "active", "");
- edje_object_signal_emit(ic->overlay_object, "active", "");
- if (ic->ibb->overlay_object)
- edje_object_signal_emit(ic->ibb->overlay_object, "active", "");
+ _ibar_icon_signal_emit(ic, "active", "");
}
static void
-_ibar_icon_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Out *ev;
IBar_Icon *ic;
-
+
ev = event_info;
ic = data;
- edje_object_signal_emit(ic->bg_object, "passive", "");
- edje_object_signal_emit(ic->overlay_object, "passive", "");
- if (ic->ibb->overlay_object)
- edje_object_signal_emit(ic->ibb->overlay_object, "passive", "");
+ _ibar_icon_signal_emit(ic, "passive", "");
}
static void
-_ibar_icon_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Down *ev;
IBar_Icon *ic;
-
+
ev = event_info;
ic = data;
if (ev->button == 1)
{
- drag_x = ev->output.x;
- drag_y = ev->output.y;
- drag_start = 1;
- drag = 0;
+ ic->drag.x = ev->output.x;
+ ic->drag.y = ev->output.y;
+ ic->drag.start = 1;
+ ic->drag.dnd = 0;
+ }
+ else if ((ev->button == 3) && (!ibar_config->menu))
+ {
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int cx, cy, cw, ch;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _ibar_cb_menu_post, NULL);
+ ibar_config->menu = mn;
+
+ /* FIXME: other icon options go here too */
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Change Icon Properties"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/properties");
+ e_menu_item_callback_set(mi, _ibar_cb_menu_icon_properties, ic);
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Remove Icon"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/delete");
+ e_menu_item_callback_set(mi, _ibar_cb_menu_icon_remove, ic);
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_separator_set(mi, 1);
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Configuration"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
+ e_menu_item_callback_set(mi, _ibar_cb_menu_configuration, ic);
+
+ e_gadcon_client_util_menu_items_append(ic->ibar->inst->gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(ic->ibar->inst->gcc->gadcon,
+ &cx, &cy, &cw, &ch);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ cx + ev->output.x, cy + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(ic->ibar->inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
}
static void
-_ibar_icon_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Up *ev;
IBar_Icon *ic;
-
+
ev = event_info;
ic = data;
- if (ev->button == 1)
+ if ((ev->button == 1) && (!ic->drag.dnd))
{
- if (!drag)
- {
- e_zone_app_exec(ic->ibb->gmc->zone, ic->app);
- e_exehist_add("ibar", ic->app->exe);
- }
- drag = 0;
- drag_start = 0;
+ e_zone_app_exec(ic->ibar->inst->gcc->gadcon->zone, ic->app);
+ e_exehist_add("ibar", ic->app->exe);
+ ic->drag.start = 0;
+ ic->drag.dnd = 0;
}
}
static void
-_ibar_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Move *ev;
IBar_Icon *ic;
-
+
ev = event_info;
ic = data;
-
- if (drag_start)
+ if (ic->drag.start)
{
int dx, dy;
- dx = ev->cur.output.x - drag_x;
- dy = ev->cur.output.y - drag_y;
+ dx = ev->cur.output.x - ic->drag.x;
+ dy = ev->cur.output.y - ic->drag.y;
if (((dx * dx) + (dy * dy)) >
(e_config->drag_resist * e_config->drag_resist))
{
@@ -1280,298 +800,217 @@ _ibar_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info
Evas_Coord x, y, w, h;
const char *drag_types[] = { "enlightenment/eapp" };
- drag = 1;
- drag_start = 0;
+ ic->drag.dnd = 1;
+ ic->drag.start = 0;
- evas_object_geometry_get(ic->icon_object,
- &x, &y, &w, &h);
- d = e_drag_new(ic->ibb->con, x, y, drag_types, 1,
- ic->app, -1, _ibar_bar_cb_finished);
+ evas_object_geometry_get(ic->o_icon, &x, &y, &w, &h);
+ d = e_drag_new(ic->ibar->inst->gcc->gadcon->zone->container,
+ x, y, drag_types, 1,
+ ic->app, -1, _ibar_cb_drag_finished);
o = edje_object_add(e_drag_evas_get(d));
edje_object_file_set(o, ic->app->path, "icon");
e_drag_object_set(d, o);
e_drag_resize(d, w, h);
- e_drag_start(d, drag_x, drag_y);
- evas_event_feed_mouse_up(ic->ibb->evas, 1, EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ e_drag_start(d, ic->drag.x, ic->drag.y);
+ evas_event_feed_mouse_up(ic->ibar->inst->gcc->gadcon->evas,
+ 1, EVAS_BUTTON_NONE,
+ ecore_x_current_time_get(), NULL);
+ e_object_ref(E_OBJECT(ic->app));
+ ic->ibar->icons = evas_list_remove(ic->ibar->icons, ic);
+ _ibar_resize_handle(ic->ibar);
+ _gc_orient(ic->ibar->inst->gcc);
e_app_remove(ic->app);
+ _ibar_icon_free(ic);
}
}
}
static void
-_ibar_bar_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Evas_Event_Mouse_In *ev;
- IBar_Bar *ibb;
-
- ev = event_info;
- ibb = data;
- if (ibb->overlay_object)
- edje_object_signal_emit(ibb->overlay_object, "active", "");
- _ibar_bar_motion_handle(ibb, ev->canvas.x, ev->canvas.y);
- _ibar_bar_timer_handle(ibb);
+ IBar_Icon *ic;
+ Evas_Coord x, y;
+
+ ic = data;
+ evas_object_geometry_get(ic->o_holder, &x, &y, NULL, NULL);
+ evas_object_move(ic->o_holder2, x, y);
+ evas_object_raise(ic->o_holder2);
}
static void
-_ibar_bar_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_icon_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Evas_Event_Mouse_Out *ev;
- IBar_Bar *ibb;
-
- ev = event_info;
- ibb = data;
- if (ibb->overlay_object)
- edje_object_signal_emit(ibb->overlay_object, "passive", "");
- _ibar_bar_follower_reset(ibb);
- _ibar_bar_timer_handle(ibb);
+ IBar_Icon *ic;
+ Evas_Coord w, h;
+
+ ic = data;
+ evas_object_geometry_get(ic->o_holder, NULL, NULL, &w, &h);
+ evas_object_resize(ic->o_holder2, w, h);
+ evas_object_raise(ic->o_holder2);
}
static void
-_ibar_bar_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_drag_finished(E_Drag *drag, int dropped)
{
- Evas_Event_Mouse_Down *ev;
- IBar_Bar *ibb;
-
- ev = event_info;
- ibb = data;
- if (ev->button == 3)
- {
- e_menu_activate_mouse(ibb->menu, e_zone_current_get(ibb->con),
- ev->output.x, ev->output.y, 1, 1,
- E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
- e_util_container_fake_mouse_up_later(ibb->con, 3);
- }
+ e_object_unref(E_OBJECT(drag->data));
}
static void
-_ibar_bar_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_ibar_cb_drop_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Evas_Event_Mouse_Up *ev;
- IBar_Bar *ibb;
-
- ev = event_info;
- ibb = data;
+ IBar *b;
+ Evas_Coord x, y;
+
+ b = data;
+ evas_object_geometry_get(b->o_drop, &x, &y, NULL, NULL);
+ evas_object_move(b->o_drop_over, x, y);
}
static void
-_ibar_bar_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Move *ev;
- IBar_Bar *ibb;
-
- ev = event_info;
- ibb = data;
- _ibar_bar_motion_handle(ibb, ev->cur.canvas.x, ev->cur.canvas.y);
- _ibar_bar_timer_handle(ibb);
-}
-
-static int
-_ibar_bar_cb_timer(void *data)
+_ibar_cb_drop_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- IBar_Bar *ibb;
- double dif, dif2;
- double v;
-
- ibb = data;
- v = ibb->ibar->conf->autoscroll_speed;
- ibb->align = (ibb->align_req * (1.0 - v)) + (ibb->align * v);
- v = ibb->ibar->conf->follow_speed;
- ibb->follow = (ibb->follow_req * (1.0 - v)) + (ibb->follow * v);
-
- dif = ibb->align - ibb->align_req;
- if (dif < 0) dif = -dif;
- if (dif < 0.001) ibb->align = ibb->align_req;
-
- dif2 = ibb->follow - ibb->follow_req;
- if (dif2 < 0) dif2 = -dif2;
- if (dif2 < 0.001) ibb->follow = ibb->follow_req;
-
- if ((dif < 0.001) && (dif2 < 0.001))
- {
- ibb->timer = NULL;
- return 0;
- }
- return 1;
-}
-
-static int
-_ibar_bar_cb_animator(void *data)
-{
- IBar_Bar *ibb;
- Evas_Coord x, y, w, h, mw, mh;
-
- ibb = data;
-
- if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
- {
- e_box_min_size_get(ibb->box_object, &mw, &mh);
- evas_object_geometry_get(ibb->box_object, NULL, NULL, &w, &h);
- if (mw > w)
- e_box_align_set(ibb->box_object, ibb->align, 0.5);
- else
- e_box_align_set(ibb->box_object, 0.5, 0.5);
-
- if (ibb->overlay_object)
- {
- evas_object_geometry_get(ibb->box_object, &x, &y, &w, &h);
- edje_object_size_min_get(ibb->overlay_object, &mw, &mh);
- evas_object_resize(ibb->overlay_object, mw, h);
- evas_object_move(ibb->overlay_object, x + (w * ibb->follow) - (mw / 2), y);
- }
- }
- else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
- (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
- {
- e_box_min_size_get(ibb->box_object, &mw, &mh);
- evas_object_geometry_get(ibb->box_object, NULL, NULL, &w, &h);
- if (mh > h)
- e_box_align_set(ibb->box_object, 0.5, ibb->align);
- else
- e_box_align_set(ibb->box_object, 0.5, 0.5);
-
- if (ibb->overlay_object)
- {
- evas_object_geometry_get(ibb->box_object, &x, &y, &w, &h);
- edje_object_size_min_get(ibb->overlay_object, &mw, &mh);
- evas_object_resize(ibb->overlay_object, w, mh);
- evas_object_move(ibb->overlay_object, x, y + (h * ibb->follow) - (mh / 2));
- }
- }
- if (ibb->timer) return 1;
- ibb->animator = NULL;
- return 0;
+ IBar *b;
+ Evas_Coord w, h;
+
+ b = data;
+ evas_object_geometry_get(b->o_drop, NULL, NULL, &w, &h);
+ evas_object_resize(b->o_drop_over, w, h);
}
static void
-_ibar_bar_cb_enter(void *data, const char *type, void *event)
+_ibar_inst_cb_enter(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Enter *ev;
+ Instance *inst;
Evas_Object *o, *o2;
- IBar_Bar *ibb;
IBar_Icon *ic;
- int w, h;
-
- ev = event;
- ibb = data;
-
- o = edje_object_add(ibb->evas);
- ibb->drag_object = o;
- o2 = edje_object_add(ibb->evas);
- ibb->drag_object_overlay = o2;
- evas_object_intercept_move_callback_add(o, _ibar_drag_cb_intercept_move, o2);
- evas_object_intercept_resize_callback_add(o, _ibar_drag_cb_intercept_resize, o2);
+ int cx, cy, cw, ch;
+
+ ev = event_info;
+ inst = data;
+ o = edje_object_add(evas_object_evas_get(inst->ibar->o_box));
+ inst->ibar->o_drop = o;
+ o2 = edje_object_add(evas_object_evas_get(inst->ibar->o_box));
+ inst->ibar->o_drop_over = o2;
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _ibar_cb_drop_move, inst->ibar);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _ibar_cb_drop_resize, inst->ibar);
e_theme_edje_object_set(o, "base/theme/modules/ibar",
"modules/ibar/drop");
e_theme_edje_object_set(o2, "base/theme/modules/ibar",
"modules/ibar/drop_overlay");
- edje_object_signal_emit(o, "set_orientation",
- _ibar_main_orientation[e_gadman_client_edge_get(ibb->gmc)]);
- edje_object_signal_emit(o2, "set_orientation",
- _ibar_main_orientation[e_gadman_client_edge_get(ibb->gmc)]);
- evas_object_resize(o, ibb->ibar->conf->iconsize, ibb->ibar->conf->iconsize);
-
- ic = _ibar_icon_pos_find(ibb, ev->x, ev->y);
-
- e_box_freeze(ibb->box_object);
- evas_object_show(ibb->drag_object);
- evas_object_show(ibb->drag_object_overlay);
+ evas_object_layer_set(o2, 19999);
+ evas_object_show(o);
+ evas_object_show(o2);
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ ic = _ibar_icon_at_coord(inst->ibar, ev->x - cx, ev->y - cy);
+ inst->ibar->ic_drop_before = ic;
if (ic)
{
- /* Add new eapp before this icon */
- e_box_pack_before(ibb->box_object, ibb->drag_object, ic->bg_object);
- }
- else
- {
- /* Add at the end */
- e_box_pack_end(ibb->box_object, ibb->drag_object);
+ Evas_Coord ix, iy, iw, ih;
+ int before = 0;
+
+ evas_object_geometry_get(ic->o_holder, &ix, &iy, &iw, &ih);
+ if (e_box_orientation_get(inst->ibar->o_box))
+ {
+ if ((ev->x - cx) < (ix + (iw / 2))) before = 1;
+ }
+ else
+ {
+ if ((ev->y - cy) < (iy + (ih / 2))) before = 1;
+ }
+ if (before)
+ e_box_pack_before(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
+ else
+ e_box_pack_after(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
+ inst->ibar->drop_before = before;
}
- w = ibb->ibar->conf->iconsize + ibb->icon_inset.l + ibb->icon_inset.r;
- h = ibb->ibar->conf->iconsize + ibb->icon_inset.t + ibb->icon_inset.b;
- e_box_pack_options_set(ibb->drag_object,
+ else e_box_pack_end(inst->ibar->o_box, o);
+ e_box_pack_options_set(o,
1, 1, /* fill */
0, 0, /* expand */
0.5, 0.5, /* align */
- w, h, /* min */
- w, h /* max */
+ 1, 1, /* min */
+ -1, -1 /* max */
);
- e_box_thaw(ibb->box_object);
-
- _ibar_bar_frame_resize(ibb);
+ _ibar_resize_handle(inst->ibar);
+ _gc_orient(inst->gcc);
}
static void
-_ibar_bar_cb_move(void *data, const char *type, void *event)
+_ibar_inst_cb_move(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Move *ev;
- IBar_Bar *ibb;
+ Instance *inst;
IBar_Icon *ic;
- int w, h;
-
- ev = event;
- ibb = data;
-
- ic = _ibar_icon_pos_find(ibb, ev->x, ev->y);
-
- e_box_freeze(ibb->box_object);
- evas_object_show(ibb->drag_object);
- e_box_unpack(ibb->drag_object);
+ int cx, cy, cw, ch;
+
+ ev = event_info;
+ inst = data;
+ e_box_unpack(inst->ibar->o_drop);
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ ic = _ibar_icon_at_coord(inst->ibar, ev->x - cx, ev->y - cy);
+ inst->ibar->ic_drop_before = ic;
if (ic)
{
- /* Add new eapp before this icon */
- e_box_pack_before(ibb->box_object, ibb->drag_object, ic->bg_object);
- }
- else
- {
- /* Add at the end */
- e_box_pack_end(ibb->box_object, ibb->drag_object);
+ Evas_Coord ix, iy, iw, ih;
+ int before = 0;
+
+ evas_object_geometry_get(ic->o_holder, &ix, &iy, &iw, &ih);
+ if (e_box_orientation_get(inst->ibar->o_box))
+ {
+ if ((ev->x - cx) < (ix + (iw / 2))) before = 1;
+ }
+ else
+ {
+ if ((ev->y - cy) < (iy + (ih / 2))) before = 1;
+ }
+ if (before)
+ e_box_pack_before(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
+ else
+ e_box_pack_after(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
+ inst->ibar->drop_before = before;
}
- w = ibb->ibar->conf->iconsize + ibb->icon_inset.l + ibb->icon_inset.r;
- h = ibb->ibar->conf->iconsize + ibb->icon_inset.t + ibb->icon_inset.b;
- e_box_pack_options_set(ibb->drag_object,
+ else e_box_pack_end(inst->ibar->o_box, inst->ibar->o_drop);
+ e_box_pack_options_set(inst->ibar->o_drop,
1, 1, /* fill */
0, 0, /* expand */
0.5, 0.5, /* align */
- w, h, /* min */
- w, h /* max */
+ 1, 1, /* min */
+ -1, -1 /* max */
);
- e_box_thaw(ibb->box_object);
-
- _ibar_bar_frame_resize(ibb);
+ _ibar_resize_handle(inst->ibar);
+ _gc_orient(inst->gcc);
}
static void
-_ibar_bar_cb_leave(void *data, const char *type, void *event)
+_ibar_inst_cb_leave(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Leave *ev;
- IBar_Bar *ibb;
-
- ev = event;
- ibb = data;
-
- e_box_freeze(ibb->box_object);
- e_box_unpack(ibb->drag_object);
- evas_object_del(ibb->drag_object);
- ibb->drag_object = NULL;
- evas_object_del(ibb->drag_object_overlay);
- ibb->drag_object_overlay = NULL;
- e_box_thaw(ibb->box_object);
-
- _ibar_bar_frame_resize(ibb);
+ Instance *inst;
+
+ ev = event_info;
+ inst = data;
+ inst->ibar->ic_drop_before = NULL;
+ evas_object_del(inst->ibar->o_drop);
+ inst->ibar->o_drop = NULL;
+ evas_object_del(inst->ibar->o_drop_over);
+ inst->ibar->o_drop_over = NULL;
+ _ibar_resize_handle(inst->ibar);
+ _gc_orient(inst->gcc);
}
static void
-_ibar_bar_cb_drop(void *data, const char *type, void *event)
+_ibar_inst_cb_drop(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Drop *ev;
+ Instance *inst;
E_App *app = NULL;
Evas_List *l = NULL;
- IBar_Bar *ibb;
IBar_Icon *ic;
-
- ev = event;
- ibb = data;
+
+ ev = event_info;
+ inst = data;
if (!strcmp(type, "enlightenment/eapp"))
{
app = ev->data;
@@ -1599,15 +1038,6 @@ _ibar_bar_cb_drop(void *data, const char *type, void *event)
{
E_Dialog *dia;
- e_box_freeze(ibb->box_object);
- e_box_unpack(ibb->drag_object);
- evas_object_del(ibb->drag_object);
- ibb->drag_object = NULL;
- evas_object_del(ibb->drag_object_overlay);
- ibb->drag_object_overlay = NULL;
- e_box_thaw(ibb->box_object);
- _ibar_bar_frame_resize(ibb);
-
dia = e_dialog_new(e_container_current_get(e_manager_current_get()));
e_dialog_title_set(dia, _("Cannot add icon"));
e_dialog_text_set(dia,
@@ -1627,24 +1057,26 @@ _ibar_bar_cb_drop(void *data, const char *type, void *event)
{
l = ev->data;
}
-
- /* add dropped element */
- ic = _ibar_icon_pos_find(ibb, ev->x, ev->y);
-
- /* remove drag marker */
- e_box_freeze(ibb->box_object);
- e_box_unpack(ibb->drag_object);
- evas_object_del(ibb->drag_object);
- ibb->drag_object = NULL;
- evas_object_del(ibb->drag_object_overlay);
- ibb->drag_object_overlay = NULL;
- e_box_thaw(ibb->box_object);
-
- _ibar_bar_frame_resize(ibb);
-
+
+ ic = inst->ibar->ic_drop_before;
if (ic)
{
/* Add new eapp before this icon */
+ if (!inst->ibar->drop_before)
+ {
+ for (l = inst->ibar->icons; l; l = l->next)
+ {
+ if (l->data == ic)
+ {
+ if (l->next)
+ ic = l->next->data;
+ else
+ ic = NULL;
+ break;
+ }
+ }
+ }
+ if (!ic) goto atend;
if (app)
e_app_list_prepend_relative(app, ic->app);
else if (l)
@@ -1652,186 +1084,139 @@ _ibar_bar_cb_drop(void *data, const char *type, void *event)
}
else
{
- /* Add at the end */
+ atend:
if (app)
- e_app_list_append(app, ibb->ibar->apps);
+ e_app_list_append(app, inst->ibar->apps);
else if (l)
- e_app_files_list_append(l, ibb->ibar->apps);
+ e_app_files_list_append(l, inst->ibar->apps);
}
+
+ evas_object_del(inst->ibar->o_drop);
+ inst->ibar->o_drop = NULL;
+ evas_object_del(inst->ibar->o_drop_over);
+ inst->ibar->o_drop_over = NULL;
+ _ibar_resize_handle(inst->ibar);
+ _gc_orient(inst->gcc);
}
-static void
-_ibar_bar_cb_finished(E_Drag *drag, int dropped)
-{
- /* Unref the object so it will be deleted. */
- if (!dropped)
- e_object_unref(E_OBJECT(drag->data));
-}
-
-static void
-_ibar_bar_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
+/***************************************************************************/
+/**/
+/* module setup */
+EAPI E_Module_Api e_modapi =
{
- IBar_Bar *ibb;
-
- ibb = data;
- switch (change)
- {
- case E_GADMAN_CHANGE_MOVE_RESIZE:
- e_gadman_client_geometry_get(ibb->gmc, &ibb->x, &ibb->y, &ibb->w, &ibb->h);
-
- edje_extern_object_min_size_set(ibb->box_object, 0, 0);
- edje_object_part_swallow(ibb->bar_object, "items", ibb->box_object);
-
- evas_object_move(ibb->bar_object, ibb->x, ibb->y);
- evas_object_resize(ibb->bar_object, ibb->w, ibb->h);
-
- _ibar_bar_follower_reset(ibb);
- _ibar_bar_timer_handle(ibb);
-
- e_drop_handler_geometry_set(ibb->drop_handler,
- ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
- ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
- ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
- break;
- case E_GADMAN_CHANGE_EDGE:
- _ibar_bar_edge_change(ibb, e_gadman_client_edge_get(ibb->gmc));
- break;
- case E_GADMAN_CHANGE_RAISE:
- case E_GADMAN_CHANGE_ZONE:
- /* FIXME
- * Must we do something here?
- */
- break;
- }
-}
-
-void
-_ibar_bar_cb_config_updated(void *data)
-{
- /* Call Any Needed Funcs To Let Module Handle Config Changes */
- _ibar_bar_cb_follower(data);
- _ibar_bar_cb_width_auto(data);
- _ibar_bar_cb_iconsize_change(data);
-}
+ E_MODULE_API_VERSION,
+ "IBar"
+};
-static void
-_ibar_bar_cb_width_auto(void *data)
+EAPI void *
+e_modapi_init(E_Module *module)
{
- IBar *ib;
- IBar_Bar *ibb;
- Evas_List *l;
-
- ib = data;
- for (l = ib->bars; l; l = l->next)
+ conf_item_edd = E_CONFIG_DD_NEW("IBar_Config_Item", Config_Item);
+#undef T
+#undef D
+#define T Config_Item
+#define D conf_item_edd
+ E_CONFIG_VAL(D, T, id, STR);
+ E_CONFIG_VAL(D, T, dir, STR);
+
+ conf_edd = E_CONFIG_DD_NEW("IBar_Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+ E_CONFIG_LIST(D, T, items, conf_item_edd);
+
+ ibar_config = e_config_domain_load("module.ibar", conf_edd);
+
+ if (!ibar_config)
{
- ibb = l->data;
- _ibar_bar_update_policy(ibb);
- _ibar_bar_frame_resize(ibb);
+ Config_Item *ci;
+
+ ibar_config = E_NEW(Config, 1);
+
+ ci = E_NEW(Config_Item, 1);
+ ci->id = evas_stringshare_add("0");
+ ci->dir = evas_stringshare_add("bar");
+
+ ibar_config->items = evas_list_append(ibar_config->items, ci);
}
+
+ e_gadcon_provider_register(&_gadcon_class);
+ return 1;
}
-static void
-_ibar_bar_cb_follower(void *data)
+EAPI int
+e_modapi_shutdown(E_Module *module)
{
- IBar *ib;
- IBar_Bar *ibb;
- unsigned char enabled;
- Evas_List *l;
-
- ib = data;
- enabled = ib->conf->follower;
- if (enabled)
+ e_gadcon_provider_unregister(&_gadcon_class);
+
+ if (ibar_config->config_dialog)
+ e_object_del(E_OBJECT(ibar_config->config_dialog));
+ while (ibar_config->handlers)
{
- for (l = ib->bars; l; l = l->next)
- {
- Evas_Object *o;
-
- ibb = l->data;
- if (ibb->overlay_object) continue;
- o = edje_object_add(ibb->evas);
- ibb->overlay_object = o;
- evas_object_layer_set(o, 2);
- e_theme_edje_object_set(o, "base/theme/modules/ibar",
- "modules/ibar/follower");
-
- edje_object_signal_emit(o, "set_orientation", _ibar_main_orientation[e_gadman_client_edge_get(ibb->gmc)]);
- edje_object_message_signal_process(o);
-
- evas_object_show(o);
- }
+ ecore_event_handler_del(ibar_config->handlers->data);
+ ibar_config->handlers = evas_list_remove_list(ibar_config->handlers, ibar_config->handlers);
}
- else if (!enabled)
+ if (ibar_config->menu) e_object_del(E_OBJECT(ibar_config->menu));
+ while (ibar_config->items)
{
- for (l = ib->bars; l; l = l->next)
- {
- ibb = l->data;
- if (!ibb->overlay_object) continue;
- evas_object_del(ibb->overlay_object);
- ibb->overlay_object = NULL;
- }
+ Config_Item *ci;
+
+ ci = ibar_config->items->data;
+ ibar_config->items = evas_list_remove_list(ibar_config->items, ibar_config->items);
+ if (ci->id) evas_stringshare_del(ci->id);
+ if (ci->dir) evas_stringshare_del(ci->dir);
+ free(ci);
}
+ free(ibar_config);
+ ibar_config = NULL;
+ E_CONFIG_DD_FREE(conf_item_edd);
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
}
-static void
-_ibar_bar_cb_iconsize_change(void *data)
+EAPI int
+e_modapi_save(E_Module *module)
{
- IBar *ib;
- Evas_List *l, *ll;
-
- ib = data;
- for (l = ib->bars; l; l = l->next)
+ Evas_List *l, *l2;
+
+ for (l = ibar_config->instances; l; l = l->next)
{
- IBar_Bar *ibb;
-
- ibb = l->data;
-
- e_box_freeze(ibb->box_object);
- for (ll = ibb->icons; ll; ll = ll->next)
- {
- IBar_Icon *ic;
- Evas_Object *o;
- Evas_Coord w, h;
-
- ic = ll->data;
- o = ic->icon_object;
-
- evas_object_resize(o, ibb->ibar->conf->iconsize, ibb->ibar->conf->iconsize);
- edje_object_part_swallow(ic->bg_object, "item", o);
-
- w = ibb->ibar->conf->iconsize + ibb->icon_inset.l + ibb->icon_inset.r;
- h = ibb->ibar->conf->iconsize + ibb->icon_inset.t + ibb->icon_inset.b;
- e_box_pack_options_set(ic->bg_object,
- 1, 1, /* fill */
- 0, 0, /* expand */
- 0.5, 0.5, /* align */
- w, h, /* min */
- w, h /* max */
- );
- }
- e_box_thaw(ibb->box_object);
- _ibar_bar_frame_resize(ibb);
+ Instance *inst;
+ int found;
+ Config_Item *ci;
+
+ inst = l->data;
+ found = 0;
+ ci = _ibar_config_item_get(inst->gcc->id);
+ if (ci->dir) evas_stringshare_del(ci->dir);
+ /* FIXME: path should be recorded from setup */
+ ci->dir = evas_stringshare_add(inst->dir);
}
+ e_config_domain_save("module.ibar", conf_edd, ibar_config);
+ return 1;
}
-static void
-_ibar_bar_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
+EAPI int
+e_modapi_info(E_Module *module)
{
- IBar_Bar *ibb;
-
- ibb = data;
- e_gadman_mode_set(ibb->gmc->gadman, E_GADMAN_MODE_EDIT);
+ char buf[4096];
+
+ snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(module));
+ module->icon_file = strdup(buf);
+ return 1;
}
-static void
-_ibar_drag_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y)
+EAPI int
+e_modapi_about(E_Module *module)
{
- evas_object_move(o, x, y);
- evas_object_move(data, x, y);
+ e_module_dialog_show(_("Enlightenment IBar Module"),
+ _("This is the IBar Application Launcher bar module for Enlightenment.<br>"
+ "It is a first example module and is being used to flesh out several<br>"
+ "interfaces in Enlightenment 0.17.0. It is under heavy development,<br>"
+ "so expect it to <hilight>break often</hilight> and change as it improves."));
+ return 1;
}
-static void
-_ibar_drag_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h)
-{
- evas_object_resize(o, w, h);
- evas_object_resize(data, w, h);
-}
+/**/
+/***************************************************************************/
diff --git a/src/modules/ibar/e_mod_main.h b/src/modules/ibar/e_mod_main.h
index c3b7943aa..6837ea8f2 100644
--- a/src/modules/ibar/e_mod_main.h
+++ b/src/modules/ibar/e_mod_main.h
@@ -5,87 +5,23 @@
#define E_MOD_MAIN_H
typedef struct _Config Config;
-typedef struct _Config_Bar Config_Bar;
-typedef struct _IBar IBar;
-typedef struct _IBar_Bar IBar_Bar;
-typedef struct _IBar_Icon IBar_Icon;
-
-#define IBAR_WIDTH_AUTO -1
-#define IBAR_WIDTH_FIXED -2
+typedef struct _Config_Item Config_Item;
struct _Config
{
- const char *appdir;
- int follower;
- double follow_speed;
- double autoscroll_speed;
- int iconsize;
- int width;
- Evas_List *bars;
-};
-
-struct _Config_Bar
-{
- unsigned char enabled;
-};
-
-struct _IBar
-{
- E_App *apps;
- Evas_List *bars;
- E_Menu *config_menu;
-
- Config *conf;
- E_Config_Dialog *config_dialog;
+ /* saved * loaded config values */
+ Evas_List *items;
+ /* just config state */
+ E_Config_Dialog *config_dialog;
+ Evas_List *instances;
+ E_Menu *menu;
+ Evas_List *handlers;
};
-struct _IBar_Bar
+struct _Config_Item
{
- IBar *ibar;
- E_Container *con;
- Evas *evas;
- E_Menu *menu;
-
- Evas_Object *bar_object;
- Evas_Object *overlay_object;
- Evas_Object *box_object;
- Evas_Object *event_object;
- Evas_Object *drag_object;
- Evas_Object *drag_object_overlay;
-
- Evas_List *icons;
-
- double align, align_req;
- double follow, follow_req;
- Ecore_Timer *timer;
- Ecore_Animator *animator;
-
- Evas_Coord x, y, w, h;
- struct {
- Evas_Coord l, r, t, b;
- } bar_inset;
- struct {
- Evas_Coord l, r, t, b;
- } icon_inset;
-
- E_Gadman_Client *gmc;
-
- Config_Bar *conf;
-
- E_Drop_Handler *drop_handler;
-};
-
-struct _IBar_Icon
-{
- IBar_Bar *ibb;
- E_App *app;
- Evas_Object *bg_object;
- Evas_Object *overlay_object;
- Evas_Object *icon_object;
- Evas_Object *event_object;
- Evas_List *extra_icons;
-
- unsigned char raise_on_hilight : 1;
+ char *id;
+ char *dir;
};
EAPI extern E_Module_Api e_modapi;
@@ -95,8 +31,9 @@ EAPI int e_modapi_shutdown (E_Module *m);
EAPI int e_modapi_save (E_Module *m);
EAPI int e_modapi_info (E_Module *m);
EAPI int e_modapi_about (E_Module *m);
-/* EAPI int e_modapi_config (E_Module *m); */
-void _ibar_bar_cb_config_updated(void *data);
+void _ibar_config_update(void);
+void _config_ibar_module(Config_Item *ci);
+extern Config *ibar_config;
#endif
diff --git a/src/modules/pager/Makefile.am b/src/modules/pager/Makefile.am
index db9b53528..369b2a075 100644
--- a/src/modules/pager/Makefile.am
+++ b/src/modules/pager/Makefile.am
@@ -20,8 +20,7 @@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
- e_mod_config.c \
- e_mod_config.h
+ e_mod_config.c
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
diff --git a/src/modules/pager/e_mod_config.c b/src/modules/pager/e_mod_config.c
index 236b2b011..d75ab0d17 100644
--- a/src/modules/pager/e_mod_config.c
+++ b/src/modules/pager/e_mod_config.c
@@ -1,12 +1,8 @@
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
struct _E_Config_Dialog_Data
{
- int show_name;
- int name_pos;
int show_popup;
double popup_speed;
int drag_resist;
@@ -21,7 +17,7 @@ static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
void
-_config_pager_module(E_Container *con, Pager *pager)
+_config_pager_module(Config_Item *ci)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
@@ -35,49 +31,36 @@ _config_pager_module(E_Container *con, Pager *pager)
v->advanced.apply_cfdata = _advanced_apply_data;
v->advanced.create_widgets = _advanced_create_widgets;
- cfd = e_config_dialog_new(con, _("Pager Configuration"), NULL, 0, v, pager);
- pager->config_dialog = cfd;
+ cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
+ _("Pager Configuration"), NULL, 0, v, ci);
+ pager_config->config_dialog = cfd;
}
static void
-_fill_data(Pager *p, E_Config_Dialog_Data *cfdata)
+_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
{
- /* Name Pos, Show Popup, popup_speed */
- cfdata->name_pos = p->conf->deskname_pos;
- if (cfdata->name_pos == PAGER_DESKNAME_NONE)
- {
- cfdata->show_name = 0;
- cfdata->name_pos = PAGER_DESKNAME_TOP;
- }
- else
- {
- cfdata->show_name = 1;
- }
-
- cfdata->show_popup = p->conf->popup;
- cfdata->popup_speed = p->conf->popup_speed;
- cfdata->drag_resist = p->conf->drag_resist;
+ /* FIXME: configure zone config item */
+ cfdata->show_popup = pager_config->popup;
+ cfdata->popup_speed = pager_config->popup_speed;
+ cfdata->drag_resist = pager_config->drag_resist;
}
static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
- Pager *p;
+ Config_Item *ci;
- p = cfd->data;
+ ci = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
- _fill_data(p, cfdata);
+ _fill_data(ci, cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Pager *p;
-
- p = cfd->data;
- p->config_dialog = NULL;
+ pager_config->config_dialog = NULL;
free(cfdata);
}
@@ -91,43 +74,17 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
of = e_widget_framelist_add(evas, _("General Settings"), 0);
ob = e_widget_check_add(evas, _("Show Popup"), &(cfdata->show_popup));
e_widget_framelist_object_append(of, ob);
- ob = e_widget_check_add(evas, _("Show Desktop Name"), &(cfdata->show_name));
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
- of = e_widget_framelist_add(evas, _("Desktop Name Position"), 0);
- rg = e_widget_radio_group_new(&(cfdata->name_pos));
- ob = e_widget_radio_add(evas, _("Top"), PAGER_DESKNAME_TOP, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("Bottom"), PAGER_DESKNAME_BOTTOM, rg);
- e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
- /* Not Supported Yet ??
- ob = e_widget_radio_add(evas, _("Left"), PAGER_DESKNAME_LEFT, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("Right"), PAGER_DESKNAME_RIGHT, rg);
- e_widget_framelist_object_append(of, ob);
- */
-
return o;
}
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Pager *p;
-
- p = cfd->data;
- p->conf->popup = cfdata->show_popup;
-
- p->conf->deskname_pos = cfdata->name_pos;
- if (!cfdata->show_name)
- p->conf->deskname_pos = PAGER_DESKNAME_NONE;
-
+ pager_config->popup = cfdata->show_popup;
+ _pager_cb_config_updated();
e_config_save_queue();
-
- _pager_cb_config_updated(p);
return 1;
}
@@ -138,33 +95,14 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
E_Radio_Group *rg;
o = e_widget_list_add(evas, 0, 0);
- of = e_widget_framelist_add(evas, _("General Settings"), 0);
- ob = e_widget_check_add(evas, _("Show Popup"), &(cfdata->show_popup));
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_check_add(evas, _("Show Desktop Name"), &(cfdata->show_name));
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_label_add(evas, _("Resistance to Dragging Windows:"));
- e_widget_framelist_object_append(of, ob);
+ of = e_widget_framelist_add(evas, _("Resistance to Dragging Windows:"), 0);
ob = e_widget_slider_add(evas, 1, 0, _("%.0f px"), 0.0, 10.0, 1.0, 0, NULL, &(cfdata->drag_resist), 200);
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
- of = e_widget_framelist_add(evas, _("Desktop Name Position"), 0);
- rg = e_widget_radio_group_new(&(cfdata->name_pos));
- ob = e_widget_radio_add(evas, _("Top"), PAGER_DESKNAME_TOP, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("Bottom"), PAGER_DESKNAME_BOTTOM, rg);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
- /* Not Supported Yet ??
- ob = e_widget_radio_add(evas, _("Left"), PAGER_DESKNAME_LEFT, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, _("Right"), PAGER_DESKNAME_RIGHT, rg);
- e_widget_framelist_object_append(of, ob);
- */
-
of = e_widget_framelist_add(evas, _("Popup Settings"), 0);
+ ob = e_widget_check_add(evas, _("Show Popup"), &(cfdata->show_popup));
+ e_widget_framelist_object_append(of, ob);
ob = e_widget_label_add(evas, _("Popup Speed"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_slider_add(evas, 1, 0, _("%1.1f seconds"), 0.1, 10.0, 0.1, 0, &(cfdata->popup_speed), NULL, 200);
@@ -177,21 +115,10 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
static int
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Pager *p;
-
- p = cfd->data;
- e_border_button_bindings_ungrab_all();
- p->conf->popup = cfdata->show_popup;
-
- p->conf->deskname_pos = cfdata->name_pos;
- if (!cfdata->show_name)
- p->conf->deskname_pos = PAGER_DESKNAME_NONE;
- p->conf->popup_speed = cfdata->popup_speed;
- p->conf->drag_resist = cfdata->drag_resist;
-
- e_border_button_bindings_grab_all();
+ pager_config->popup = cfdata->show_popup;
+ pager_config->popup_speed = cfdata->popup_speed;
+ pager_config->drag_resist = cfdata->drag_resist;
+ _pager_cb_config_updated();
e_config_save_queue();
-
- _pager_cb_config_updated(p);
return 1;
}
diff --git a/src/modules/pager/e_mod_config.h b/src/modules/pager/e_mod_config.h
deleted file mode 100644
index 05648c975..000000000
--- a/src/modules/pager/e_mod_config.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifdef E_TYPEDEFS
-#else
-#ifndef E_MOD_CONFIG_H
-#define E_MOD_CONFIG_H
-#include "e_mod_main.h"
-void _config_pager_module(E_Container *con, Pager *pager);
-#endif
-#endif
diff --git a/src/modules/pager/e_mod_main.c b/src/modules/pager/e_mod_main.c
index db0245ec7..569dad791 100644
--- a/src/modules/pager/e_mod_main.c
+++ b/src/modules/pager/e_mod_main.c
@@ -3,627 +3,286 @@
*/
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-/* TODO
- * which options should be in main menu, and which in face menu?
- * check if a new desk is in the current zone
- * check if padding changes on resize
- * include deskname in padding
- */
-
-/* module private routines */
-static Pager *_pager_new(void);
-static void _pager_free(Pager *pager);
-static void _pager_config_menu_new(Pager *pager);
-
-static Pager_Face *_pager_face_new(Pager *pager, E_Zone *zone, Evas *evas, int use_gmc);
-static void _pager_face_free(Pager_Face *face);
-static void _pager_face_menu_new(Pager_Face *face);
-static void _pager_face_disable(Pager_Face *face);
-static void _pager_face_zone_set(Pager_Face *face, E_Zone *zone);
-static void _pager_face_zone_unset(Pager_Face *face);
-
-static Pager_Desk *_pager_desk_new(Pager_Face *face, E_Desk *desk, int x, int y);
-static void _pager_desk_free(Pager_Desk *pd);
-
-static Pager_Win *_pager_window_new(Pager_Desk *pd, E_Border *border);
-static void _pager_window_free(Pager_Win *pw);
-static void _pager_window_move(Pager_Face *face, Pager_Win *pw);
-
-static Pager_Win *_pager_face_border_find(Pager_Face *face, E_Border *border);
-static Pager_Win *_pager_desk_border_find(Pager_Desk *pd, E_Border *border);
-static Pager_Desk *_pager_face_desk_find(Pager_Face *face, E_Desk *desk);
-static Pager_Desk *_pager_face_desk_at_coord(Pager_Face *face, Evas_Coord x, Evas_Coord y);
-static void _pager_face_desk_select(Pager_Desk *pd);
-static void _pager_popup_free(Pager_Popup *pp);
-
-static int _pager_cb_event_border_resize(void *data, int type, void *event);
-static int _pager_cb_event_border_move(void *data, int type, void *event);
-static int _pager_cb_event_border_add(void *data, int type, void *event);
-static int _pager_cb_event_border_remove(void *data, int type, void *event);
-static int _pager_cb_event_border_iconify(void *data, int type, void *event);
-static int _pager_cb_event_border_uniconify(void *data, int type, void *event);
-static int _pager_cb_event_border_stick(void *data, int type, void *event);
-static int _pager_cb_event_border_unstick(void *data, int type, void *event);
-static int _pager_cb_event_border_desk_set(void *data, int type, void *event);
-static int _pager_cb_event_border_stack(void *data, int type, void *event);
-static int _pager_cb_event_border_icon_change(void *data, int type, void *event);
-static int _pager_cb_event_zone_desk_count_set(void *data, int type, void *event);
-static int _pager_cb_event_desk_show(void *data, int type, void *event);
-static int _pager_cb_event_desk_name_change(void *data, int type, void *event);
-
-static void _pager_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
-static void _pager_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
-
-static void _pager_desk_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_desk_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_desk_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_desk_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_desk_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_desk_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
-
-static void _pager_desk_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
-static void _pager_desk_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
-
-static void _pager_window_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_window_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_window_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_window_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _pager_window_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
-
-static void _pager_window_cb_drag_finished(E_Drag *drag, int dropped);
-
-static void _pager_face_cb_enter(void *data, const char *type, void *drop);
-static void _pager_face_cb_move(void *data, const char *type, void *drop);
-static void _pager_face_cb_leave(void *data, const char *type, void *drop);
-static void _pager_face_cb_drop(void *data, const char *type, void *drop);
-
-static void _pager_face_deskname_position_change(Pager_Face *face);
-static int _pager_popup_cb_timeout(void *data);
-
-static void _pager_menu_cb_aspect_keep_height(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _pager_menu_cb_aspect_keep_width(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _pager_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi);
-
-static int _pager_count;
-
-static E_Config_DD *_conf_edd;
-static E_Config_DD *_conf_face_edd;
-
-/* public module routines. all modules must have these */
-EAPI E_Module_Api e_modapi =
-{
- E_MODULE_API_VERSION,
- "Pager"
-};
-
-EAPI void *
-e_modapi_init(E_Module *module)
-{
- Pager *pager = NULL;
-
- /* actually init pager */
- pager = _pager_new();
- module->config_menu = pager->config_menu;
-
- return pager;
-}
-
-EAPI int
-e_modapi_shutdown(E_Module *module)
-{
- Pager *pager;
-
- if (module->config_menu)
- module->config_menu = NULL;
-
- pager = module->data;
- if (pager)
+/***************************************************************************/
+/**/
+/* gadcon requirements */
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static void _gc_shutdown(E_Gadcon_Client *gcc);
+static void _gc_orient(E_Gadcon_Client *gcc);
+/* and actually define the gadcon class that this module provides (just 1) */
+static const E_Gadcon_Client_Class _gadcon_class =
+{
+ GADCON_CLIENT_CLASS_VERSION,
+ "pager",
{
- if (pager->config_dialog)
- {
- e_object_del(E_OBJECT(pager->config_dialog));
- pager->config_dialog = NULL;
- }
- _pager_free(pager);
+ _gc_init, _gc_shutdown, _gc_orient
}
- return 1;
-}
+};
+/**/
+/***************************************************************************/
-EAPI int
-e_modapi_save(E_Module *module)
-{
- Pager *pager;
+/***************************************************************************/
+/**/
+/* actual module specifics */
- pager = module->data;
- e_config_domain_save("module.pager", _conf_edd, pager->conf);
+typedef struct _Instance Instance;
- return 1;
-}
+typedef struct _Pager Pager;
+typedef struct _Pager_Desk Pager_Desk;
+typedef struct _Pager_Win Pager_Win;
+typedef struct _Pager_Popup Pager_Popup;
-EAPI int
-e_modapi_info(E_Module *module)
+struct _Instance
{
- char buf[4096];
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_pager; // table
+ Pager *pager;
+ E_Drop_Handler *drop_handler;
+ Ecore_Timer *drop_recalc_timer;
+};
- snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(module));
- module->icon_file = strdup(buf);
- return 1;
-}
+struct _Pager
+{
+ Instance *inst;
+ Evas_Object *o_table;
+ E_Zone *zone;
+ int xnum, ynum;
+ Evas_List *desks;
+ Pager_Popup *popup;
+ E_Drag *drag;
+ unsigned char dragging : 1;
+ unsigned char just_dragged : 1;
+};
-EAPI int
-e_modapi_about(E_Module *module)
+struct _Pager_Desk
{
- e_module_dialog_show(_("Enlightenment Pager Module"),
- _("A pager module to navigate virtual desktops."));
- return 1;
-}
+ Pager *pager;
+ E_Desk *desk;
+ Evas_List *wins;
+ Evas_Object *o_desk;
+ Evas_Object *o_layout;
+ int xpos, ypos;
+ int current : 1;
+};
-EAPI int
-e_modapi_config(E_Module *m)
-{
- Pager *e;
- Evas_List *l;
- E_Zone *zone;
- E_Container *con;
-
- e = m->data;
- if (!e) return 0;
- if (!e->faces) return 0;
- con = e_container_current_get(e_manager_current_get());
- zone = e_zone_current_get(con);
- for (l = e->faces; l; l = l->next)
- {
- Pager_Face *face;
- face = l->data;
- if (!face) return 0;
- if (face->zone == zone)
- {
- _config_pager_module(con, e);
- break;
- }
- }
- return 1;
-}
+struct _Pager_Win
+{
+ E_Border *border;
+ Pager_Desk *desk;
+ Evas_Object *o_window;
+ Evas_Object *o_icon;
+ struct {
+ Pager *from_pager;
+ unsigned char start : 1;
+ unsigned char in_pager : 1;
+ unsigned char no_place : 1;
+ int x, y;
+ int dx, dy;
+ int button;
+ } drag;
+};
-/* module private routines */
-static Pager *
-_pager_new(void)
+struct _Pager_Popup
{
- Pager *pager;
- Pager_Face *face;
-
- Evas_List *managers, *l, *l2, *l3, *cl;
- E_Manager *man;
- E_Container *con;
- E_Zone *zone;
- E_Menu *mn;
- E_Menu_Item *mi;
-
- _pager_count = 0;
-
- pager = E_NEW(Pager, 1);
- if (!pager) return NULL;
-
- _conf_face_edd = E_CONFIG_DD_NEW("Pager_Config_Face", Config_Face);
-#undef T
-#undef D
-#define T Config_Face
-#define D _conf_face_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
- E_CONFIG_VAL(D, T, scale, UCHAR);
- E_CONFIG_VAL(D, T, resize, UCHAR);
-
- _conf_edd = E_CONFIG_DD_NEW("Pager_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D _conf_edd
- E_CONFIG_LIST(D, T, faces, _conf_face_edd);
- E_CONFIG_VAL(D, T, deskname_pos, UINT);
- E_CONFIG_VAL(D, T, popup_speed, DOUBLE);
- E_CONFIG_VAL(D, T, popup, UINT);
- E_CONFIG_VAL(D, T, drag_resist, UINT);
-
- pager->conf = e_config_domain_load("module.pager", _conf_edd);
-
- if (!pager->conf)
- {
- pager->conf = E_NEW(Config, 1);
- pager->conf->deskname_pos = PAGER_DESKNAME_NONE;
- pager->conf->popup_speed = 1.0;
- pager->conf->popup = 1;
- pager->conf->drag_resist = 3;
- }
- E_CONFIG_LIMIT(pager->conf->deskname_pos, PAGER_DESKNAME_NONE, PAGER_DESKNAME_RIGHT);
- E_CONFIG_LIMIT(pager->conf->popup_speed, 0.1, 10.0);
- E_CONFIG_LIMIT(pager->conf->popup, 0, 1);
-
- _pager_config_menu_new(pager);
-
- managers = e_manager_list();
- cl = pager->conf->faces;
- for (l = managers; l; l = l->next)
- {
- man = l->data;
-
- for (l2 = man->containers; l2; l2 = l2->next)
- {
- con = l2->data;
-
- mi = e_menu_item_new(pager->config_menu);
- e_menu_item_label_set(mi, con->name);
-
- mn = e_menu_new();
- e_menu_item_submenu_set(mi, mn);
- pager->menus = evas_list_append(pager->menus, mn);
-
- for (l3 = con->zones; l3; l3 = l3->next)
- {
- zone = l3->data;
-
- face = _pager_face_new(pager, zone, zone->container->bg_evas,
- 1);
- if (face)
- {
- pager->faces = evas_list_append(pager->faces, face);
-
- /* Config */
- if (!cl)
- {
- face->conf = E_NEW(Config_Face, 1);
- face->conf->enabled = 1;
- face->conf->resize = PAGER_RESIZE_BOTH;
- face->conf->scale = 1;
- pager->conf->faces = evas_list_append(pager->conf->faces, face->conf);
- }
- else
- {
- face->conf = cl->data;
- cl = cl->next;
- }
-
- /* Menu */
- /* This menu must be initialized after conf */
- _pager_face_menu_new(face);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, zone->name);
- e_menu_item_submenu_set(mi, face->menu);
-
- /* Setup */
- if (!face->conf->enabled)
- _pager_face_disable(face);
- }
- }
- }
- }
-
- /* set up event handles for when windows change and desktops */
- pager->ev_handler_border_resize =
- ecore_event_handler_add(E_EVENT_BORDER_RESIZE,
- _pager_cb_event_border_resize, pager);
- pager->ev_handler_border_move =
- ecore_event_handler_add(E_EVENT_BORDER_MOVE,
- _pager_cb_event_border_move, pager);
- pager->ev_handler_border_add =
- ecore_event_handler_add(E_EVENT_BORDER_ADD,
- _pager_cb_event_border_add, pager);
- pager->ev_handler_border_remove =
- ecore_event_handler_add(E_EVENT_BORDER_REMOVE,
- _pager_cb_event_border_remove, pager);
- pager->ev_handler_border_iconify =
- ecore_event_handler_add(E_EVENT_BORDER_ICONIFY,
- _pager_cb_event_border_iconify, pager);
- pager->ev_handler_border_uniconify =
- ecore_event_handler_add(E_EVENT_BORDER_UNICONIFY,
- _pager_cb_event_border_uniconify, pager);
- pager->ev_handler_border_stick =
- ecore_event_handler_add(E_EVENT_BORDER_STICK,
- _pager_cb_event_border_stick, pager);
- pager->ev_handler_border_unstick =
- ecore_event_handler_add(E_EVENT_BORDER_UNSTICK,
- _pager_cb_event_border_unstick, pager);
- pager->ev_handler_border_desk_set =
- ecore_event_handler_add(E_EVENT_BORDER_DESK_SET,
- _pager_cb_event_border_desk_set, pager);
- pager->ev_handler_border_stack =
- ecore_event_handler_add(E_EVENT_BORDER_STACK,
- _pager_cb_event_border_stack, pager);
- pager->ev_handler_border_icon_change =
- ecore_event_handler_add(E_EVENT_BORDER_ICON_CHANGE,
- _pager_cb_event_border_icon_change, pager);
- pager->ev_handler_zone_desk_count_set =
- ecore_event_handler_add(E_EVENT_ZONE_DESK_COUNT_SET,
- _pager_cb_event_zone_desk_count_set, pager);
- pager->ev_handler_desk_show =
- ecore_event_handler_add(E_EVENT_DESK_SHOW,
- _pager_cb_event_desk_show, pager);
- pager->ev_handler_desk_name_change =
- ecore_event_handler_add(E_EVENT_DESK_NAME_CHANGE,
- _pager_cb_event_desk_name_change, pager);
- return pager;
-}
+ E_Popup *popup;
+ Pager *pager, *src_pager;
+ Evas_Object *o_bg;
+ Ecore_Timer *timer;
+};
-static void
-_pager_free(Pager *pager)
+static int _pager_cb_timer_drop_recalc(void *data);
+static void _pager_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _menu_cb_post(void *data, E_Menu *m);
+static void _pager_inst_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _pager_instance_drop_zone_recalc(Instance *inst);
+static int _pager_cb_event_border_resize(void *data, int type, void *event);
+static int _pager_cb_event_border_move(void *data, int type, void *event);
+static int _pager_cb_event_border_add(void *data, int type, void *event);
+static int _pager_cb_event_border_remove(void *data, int type, void *event);
+static int _pager_cb_event_border_iconify(void *data, int type, void *event);
+static int _pager_cb_event_border_uniconify(void *data, int type, void *event);
+static int _pager_cb_event_border_stick(void *data, int type, void *event);
+static int _pager_cb_event_border_unstick(void *data, int type, void *event);
+static int _pager_cb_event_border_desk_set(void *data, int type, void *event);
+static int _pager_cb_event_border_stack(void *data, int type, void *event);
+static int _pager_cb_event_border_icon_change(void *data, int type, void *event);
+static int _pager_cb_event_zone_desk_count_set(void *data, int type, void *event);
+static int _pager_cb_event_desk_show(void *data, int type, void *event);
+static int _pager_cb_event_desk_name_change(void *data, int type, void *event);
+static void _pager_window_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_window_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_window_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_window_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_window_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_window_cb_drag_finished(E_Drag *drag, int dropped);
+static void _pager_inst_cb_enter(void *data, const char *type, void *event_info);
+static void _pager_inst_cb_move(void *data, const char *type, void *event_info);
+static void _pager_inst_cb_leave(void *data, const char *type, void *event_info);
+static void _pager_inst_cb_drop(void *data, const char *type, void *event_info);
+static void _pager_desk_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_desk_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_desk_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _pager_desk_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static int _pager_popup_cb_timeout(void *data);
+static Pager *_pager_new(Evas *evas, E_Zone *zone);
+static void _pager_free(Pager *p);
+static void _pager_fill(Pager *p);
+static void _pager_empty(Pager *p);
+static Pager_Desk *_pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos);
+static void _pager_desk_free(Pager_Desk *pd);
+static Pager_Desk *_pager_desk_at_coord(Pager *p, Evas_Coord x, Evas_Coord y);
+static void _pager_desk_select(Pager_Desk *pd);
+static Pager_Desk *_pager_desk_find(Pager *p, E_Desk *desk);
+static Pager_Win *_pager_window_new(Pager_Desk *pd, E_Border *border);
+static void _pager_window_free(Pager_Win *pw);
+static void _pager_window_move(Pager_Win *pw);
+static Pager_Win *_pager_window_find(Pager *p, E_Border *border);
+static Pager_Win *_pager_desk_window_find(Pager_Desk *pd, E_Border *border);
+static Pager_Popup *_pager_popup_new(Pager *p);
+static void _pager_popup_free(Pager_Popup *pp);
+
+static E_Config_DD *conf_edd = NULL;
+
+Config *pager_config = NULL;
+
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
{
- Evas_List *l;
-
- E_CONFIG_DD_FREE(_conf_edd);
- E_CONFIG_DD_FREE(_conf_face_edd);
-
- for (l = pager->faces; l; l = l->next)
- _pager_face_free(l->data);
- evas_list_free(pager->faces);
-
- for (l = pager->menus; l; l = l->next)
- e_object_del(E_OBJECT(l->data));
- evas_list_free(pager->menus);
- e_object_del(E_OBJECT(pager->config_menu));
-
- if (pager->ev_handler_border_resize)
- ecore_event_handler_del(pager->ev_handler_border_resize);
- if (pager->ev_handler_border_move)
- ecore_event_handler_del(pager->ev_handler_border_move);
- if (pager->ev_handler_border_add)
- ecore_event_handler_del(pager->ev_handler_border_add);
- if (pager->ev_handler_border_remove)
- ecore_event_handler_del(pager->ev_handler_border_remove);
- if (pager->ev_handler_border_iconify)
- ecore_event_handler_del(pager->ev_handler_border_iconify);
- if (pager->ev_handler_border_uniconify)
- ecore_event_handler_del(pager->ev_handler_border_uniconify);
- if (pager->ev_handler_border_stick)
- ecore_event_handler_del(pager->ev_handler_border_stick);
- if (pager->ev_handler_border_unstick)
- ecore_event_handler_del(pager->ev_handler_border_unstick);
- if (pager->ev_handler_border_desk_set)
- ecore_event_handler_del(pager->ev_handler_border_desk_set);
- if (pager->ev_handler_border_stack)
- ecore_event_handler_del(pager->ev_handler_border_stack);
- if (pager->ev_handler_border_icon_change)
- ecore_event_handler_del(pager->ev_handler_border_icon_change);
- if (pager->ev_handler_zone_desk_count_set)
- ecore_event_handler_del(pager->ev_handler_zone_desk_count_set);
- if (pager->ev_handler_desk_show)
- ecore_event_handler_del(pager->ev_handler_desk_show);
- if (pager->ev_handler_desk_name_change)
- ecore_event_handler_del(pager->ev_handler_desk_name_change);
-
- evas_list_free(pager->conf->faces);
- free(pager->conf);
- free(pager);
+ Pager *p;
+ Evas_Object *o;
+ E_Gadcon_Client *gcc;
+ Instance *inst;
+ Evas_Coord x, y, w, h;
+ int cx, cy, cw, ch;
+ const char *drop[] = { "enlightenment/border", "enlightenment/pager_win" };
+
+ inst = E_NEW(Instance, 1);
+
+ p = _pager_new(gc->evas, gc->zone);
+ p->inst = inst;
+ inst->pager = p;
+ o = p->o_table;
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+
+ inst->gcc = gcc;
+ inst->o_pager = o;
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ evas_object_geometry_get(o, &x, &y, &w, &h);
+ inst->drop_handler =
+ e_drop_handler_add(inst,
+ _pager_inst_cb_enter, _pager_inst_cb_move,
+ _pager_inst_cb_leave, _pager_inst_cb_drop,
+ drop, 2, cx + x, cy + y, w, h);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE,
+ _pager_cb_obj_moveresize, inst);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
+ _pager_cb_obj_moveresize, inst);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
+ _button_cb_mouse_down, inst);
+ pager_config->instances = evas_list_append(pager_config->instances, inst);
+ /* FIXME: HACK!!!! */
+ inst->drop_recalc_timer = ecore_timer_add(1.0, _pager_cb_timer_drop_recalc,
+ inst);
+ return gcc;
}
-static void
-_pager_config_menu_new(Pager *pager)
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
{
- E_Menu *mn;
- E_Menu_Item *mi;
-
- mn = e_menu_new();
- pager->config_menu = mn;
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _pager_menu_cb_configure, pager);
-
- mi = e_menu_item_new(pager->config_menu);
- e_menu_item_label_set(mi, _("Fix Aspect (Keep Height)"));
- e_menu_item_callback_set(mi, _pager_menu_cb_aspect_keep_height, pager);
-
- mi = e_menu_item_new(pager->config_menu);
- e_menu_item_label_set(mi, _("Fix Aspect (Keep Width)"));
- e_menu_item_callback_set(mi, _pager_menu_cb_aspect_keep_width, pager);
+ Instance *inst;
+
+ inst = gcc->data;
+ ecore_timer_del(inst->drop_recalc_timer);
+ pager_config->instances = evas_list_remove(pager_config->instances, inst);
+ e_drop_handler_del(inst->drop_handler);
+ _pager_free(inst->pager);
+ free(inst);
}
-static Pager_Face *
-_pager_face_new(Pager *pager, E_Zone *zone, Evas *evas, int use_gmc)
+static void
+_gc_orient(E_Gadcon_Client *gcc)
{
- Pager_Face *face;
- Evas_Object *o;
- Evas_Coord x, y, w, h;
- double aspect;
- const char *drop[] = { "enlightenment/border", "enlightenment/pager_win" };
- E_Gadman_Policy policy;
-
- face = E_NEW(Pager_Face, 1);
- if (!face) return NULL;
-
- face->pager = pager;
-
- /* store what evas we live in */
- face->evas = evas;
-
- /* the bg */
- o = edje_object_add(face->evas);
- face->pager_object = o;
- e_theme_edje_object_set(o, "base/theme/modules/pager",
- "modules/pager/main");
- evas_object_show(o);
-
- o = e_table_add(face->evas);
- face->table_object = o;
- e_table_homogenous_set(o, 1);
- edje_object_part_swallow(face->pager_object, "items", face->table_object);
- evas_object_show(o);
-
- evas_object_resize(face->pager_object, 1000, 1000);
- edje_object_calc_force(face->pager_object);
- edje_object_part_geometry_get(face->pager_object, "items", &x, &y, &w, &h);
- face->inset.l = x;
- face->inset.r = 1000 - (x + w);
- face->inset.t = y;
- face->inset.b = 1000 - (y + h);
-
- face->drop_handler = e_drop_handler_add(face,
- _pager_face_cb_enter, _pager_face_cb_move,
- _pager_face_cb_leave, _pager_face_cb_drop,
- drop, 2,
- face->fx, face->fy, face->fw, face->fh);
-
- _pager_face_zone_set(face, zone);
- _pager_face_deskname_position_change(face);
-
- /* popup does not want a gadman entry! */
- if (!use_gmc)
- return face;
-
- face->gmc = e_gadman_client_new(zone->container->gadman);
-
- e_gadman_client_domain_set(face->gmc, "module.pager", _pager_count++);
- e_gadman_client_zone_set(face->gmc, face->zone);
-
- policy = E_GADMAN_POLICY_ANYWHERE |
- E_GADMAN_POLICY_HMOVE |
- E_GADMAN_POLICY_VMOVE |
- E_GADMAN_POLICY_HSIZE |
- // E_GADMAN_POLICY_FIXED_ZONE |
- E_GADMAN_POLICY_VSIZE;
-
- e_gadman_client_policy_set(face->gmc, policy);
-
- e_gadman_client_min_size_set(face->gmc, 8, 8);
- e_gadman_client_max_size_set(face->gmc, 600, 600);
- e_gadman_client_auto_size_set(face->gmc,
- (face->xnum * 40) + (face->inset.l + face->inset.r),
- (face->ynum * 30) + (face->inset.t + face->inset.b));
- e_gadman_client_align_set(face->gmc, 0.0, 1.0);
- aspect = (double)(face->xnum * face->zone->w) / (double)(face->ynum * face->zone->h);
- e_gadman_client_aspect_set(face->gmc, aspect, aspect);
- e_gadman_client_padding_set(face->gmc,
- face->inset.l, face->inset.r,
- face->inset.t, face->inset.b);
- e_gadman_client_resize(face->gmc,
- (face->xnum * 40) + (face->inset.l + face->inset.r),
- (face->ynum * 30) + (face->inset.t + face->inset.b));
- e_gadman_client_change_func_set(face->gmc, _pager_face_cb_gmc_change, face);
- e_gadman_client_load(face->gmc);
-
- Evas_Coord g, z;
- e_gadman_client_geometry_get(face->gmc, NULL, NULL, &g, &z);
-
- return face;
+ Instance *inst;
+
+ inst = gcc->data;
+ e_gadcon_client_aspect_set(gcc,
+ inst->pager->xnum * inst->pager->zone->w,
+ inst->pager->ynum * inst->pager->zone->h);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
+/**/
+/***************************************************************************/
-void
-_pager_face_free(Pager_Face *face)
+/***************************************************************************/
+/**/
+static Pager *
+_pager_new(Evas *evas, E_Zone *zone)
{
- if (face->pager_object) evas_object_del(face->pager_object);
- if (face->table_object) evas_object_del(face->table_object);
- if (face->gmc)
- {
- e_gadman_client_save(face->gmc);
- e_object_del(E_OBJECT(face->gmc));
- }
-
- e_drop_handler_del(face->drop_handler);
-
- _pager_face_zone_unset(face);
-
- if (face->current_popup)
- _pager_popup_free(face->current_popup);
-
- if (face->menu)
- e_object_del(E_OBJECT(face->menu));
-
- free(face->conf);
- free(face);
-
- _pager_count--;
-}
-
-static void
-_pager_face_menu_new(Pager_Face *face)
-{
- E_Menu *mn;
- E_Menu_Item *mi;
-
- mn = e_menu_new();
- face->menu = mn;
-
- /* Config */
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _pager_menu_cb_configure, face->pager);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Edit Mode"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _pager_face_cb_menu_edit, face);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Fix Aspect (Keep Height)"));
- e_menu_item_callback_set(mi, _pager_menu_cb_aspect_keep_height, face->pager);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Fix Aspect (Keep Width)"));
- e_menu_item_callback_set(mi, _pager_menu_cb_aspect_keep_width, face->pager);
+ Pager *p;
+
+ p = E_NEW(Pager, 1);
+ p->o_table = e_table_add(evas);
+ e_table_homogenous_set(p->o_table, 1);
+ p->zone = zone;
+ _pager_fill(p);
+ return p;
}
static void
-_pager_face_disable(Pager_Face *face)
+_pager_free(Pager *p)
{
- Evas_List *l;
-
- face->conf->enabled = 0;
- evas_object_hide(face->pager_object);
- for (l = face->desks; l; l = l->next)
- {
- Pager_Desk *pd;
-
- pd = l->data;
- evas_object_hide(pd->event_object);
- }
- e_config_save_queue();
+ if (p->drag) e_object_del(E_OBJECT(p->drag));
+ _pager_empty(p);
+ evas_object_del(p->o_table);
+ free(p);
}
static void
-_pager_face_zone_set(Pager_Face *face, E_Zone *zone)
+_pager_fill(Pager *p)
{
- int desks_x, desks_y, x, y;
-
- face->zone = zone;
- e_object_ref(E_OBJECT(zone));
- e_zone_desk_count_get(zone, &desks_x, &desks_y);
- face->xnum = desks_x;
- face->ynum = desks_y;
- for (x = 0; x < desks_x; x++)
+ int x, y;
+
+ e_zone_desk_count_get(p->zone, &(p->xnum), &(p->ynum));
+ for (x = 0; x < p->xnum; x++)
{
- for (y = 0; y < desks_y; y++)
+ for (y = 0; y < p->ynum; y++)
{
Pager_Desk *pd;
E_Desk *desk;
- desk = e_desk_at_xy_get(zone, x, y);
- pd = _pager_desk_new(face, desk, x, y);
+ desk = e_desk_at_xy_get(p->zone, x, y);
+ pd = _pager_desk_new(p, desk, x, y);
if (pd)
{
- face->desks = evas_list_append(face->desks, pd);
+ p->desks = evas_list_append(p->desks, pd);
if (desk == e_desk_current_get(desk->zone))
- _pager_face_desk_select(pd);
+ _pager_desk_select(pd);
}
}
}
}
static void
-_pager_face_zone_unset(Pager_Face *face)
+_pager_empty(Pager *p)
{
- Evas_List *list;
-
- e_object_unref(E_OBJECT(face->zone));
- for (list = face->desks; list; list = list->next)
- _pager_desk_free(list->data);
- evas_list_free(face->desks);
+ if (p->popup)
+ {
+ _pager_popup_free(p->popup);
+ p->popup = NULL;
+ }
+ while (p->desks)
+ {
+ _pager_desk_free(p->desks->data);
+ p->desks = evas_list_remove_list(p->desks, p->desks);
+ }
}
static Pager_Desk *
-_pager_desk_new(Pager_Face *face, E_Desk *desk, int xpos, int ypos)
+_pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos)
{
Pager_Desk *pd;
Evas_Object *o;
@@ -638,38 +297,28 @@ _pager_desk_new(Pager_Face *face, E_Desk *desk, int xpos, int ypos)
pd->desk = desk;
e_object_ref(E_OBJECT(desk));
- pd->face = face;
+ pd->pager = p;
- o = edje_object_add(face->evas);
- pd->desk_object = o;
+ o = edje_object_add(evas_object_evas_get(p->o_table));
+ pd->o_desk = o;
e_theme_edje_object_set(o, "base/theme/modules/pager",
"modules/pager/desk");
- e_table_pack(face->table_object, o, xpos, ypos, 1, 1);
+ edje_object_part_text_set(o, "label", desk->name);
+ e_table_pack(p->o_table, o, xpos, ypos, 1, 1);
e_table_pack_options_set(o, 1, 1, 1, 1, 0.5, 0.5, 0, 0, -1, -1);
- evas_object_show(o);
-
- o = e_layout_add(face->evas);
- pd->layout_object = o;
- evas_object_intercept_move_callback_add(o, _pager_desk_cb_intercept_move, pd);
- evas_object_intercept_resize_callback_add(o, _pager_desk_cb_intercept_resize, pd);
-
- e_layout_virtual_size_set(o, desk->zone->w, desk->zone->h);
- edje_object_part_swallow(pd->desk_object, "items", pd->layout_object);
- evas_object_show(o);
-
- o = evas_object_rectangle_add(face->evas);
- pd->event_object = o;
- evas_object_layer_set(o, 1);
- evas_object_repeat_events_set(o, 1);
- evas_object_color_set(o, 0, 0, 0, 0);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _pager_desk_cb_mouse_in, pd);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _pager_desk_cb_mouse_out, pd);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _pager_desk_cb_mouse_down, pd);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _pager_desk_cb_mouse_up, pd);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _pager_desk_cb_mouse_move, pd);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _pager_desk_cb_mouse_wheel, pd);
evas_object_show(o);
+ o = e_layout_add(evas_object_evas_get(p->o_table));
+ pd->o_layout = o;
+
+ e_layout_virtual_size_set(o, desk->zone->w, desk->zone->h);
+ edje_object_part_swallow(pd->o_desk, "items", pd->o_layout);
+ evas_object_show(o);
+
bl = e_container_border_list_first(desk->zone->container);
while ((bd = e_container_border_list_next(bl)))
{
@@ -677,11 +326,9 @@ _pager_desk_new(Pager_Face *face, E_Desk *desk, int xpos, int ypos)
if ((bd->new_client) || ((bd->desk != desk) && (!bd->sticky))) continue;
pw = _pager_window_new(pd, bd);
- if (pw)
- pd->wins = evas_list_append(pd->wins, pw);
+ if (pw) pd->wins = evas_list_append(pd->wins, pw);
}
e_container_border_list_free(bl);
-
return pd;
}
@@ -690,17 +337,73 @@ _pager_desk_free(Pager_Desk *pd)
{
Evas_List *l;
- if (pd->desk_object) evas_object_del(pd->desk_object);
- if (pd->layout_object) evas_object_del(pd->layout_object);
- if (pd->event_object) evas_object_del(pd->event_object);
-
- for (l = pd->wins; l; l = l->next)
- _pager_window_free(l->data);
- pd->wins = evas_list_free(pd->wins);
+ evas_object_del(pd->o_desk);
+ evas_object_del(pd->o_layout);
+ for (l = pd->wins; l; l = l->next) _pager_window_free(l->data);
+ evas_list_free(pd->wins);
e_object_unref(E_OBJECT(pd->desk));
free(pd);
}
+static Pager_Desk *
+_pager_desk_at_coord(Pager *p, Evas_Coord x, Evas_Coord y)
+{
+ Evas_List *l;
+
+ for (l = p->desks; l; l = l->next)
+ {
+ Pager_Desk *pd;
+ Evas_Coord dx, dy, dw, dh;
+
+ pd = l->data;
+ evas_object_geometry_get(pd->o_desk, &dx, &dy, &dw, &dh);
+ if (E_INSIDE(x, y, dx, dy, dw, dh)) return pd;
+ }
+ return NULL;
+}
+
+static void
+_pager_desk_select(Pager_Desk *pd)
+{
+ Evas_List *l;
+
+ if (pd->current) return;
+ for (l = pd->pager->desks; l; l = l->next)
+ {
+ Pager_Desk *pd2;
+
+ pd2 = l->data;
+ if (pd == pd2)
+ {
+ pd2->current = 1;
+ edje_object_signal_emit(pd2->o_desk, "active", "");
+ }
+ else
+ {
+ if (pd2->current)
+ {
+ pd2->current = 0;
+ edje_object_signal_emit(pd2->o_desk, "passive", "");
+ }
+ }
+ }
+}
+
+static Pager_Desk *
+_pager_desk_find(Pager *p, E_Desk *desk)
+{
+ Evas_List *l;
+
+ for (l = p->desks; l; l = l->next)
+ {
+ Pager_Desk *pd;
+
+ pd = l->data;
+ if (pd->desk == desk) return pd;
+ }
+ return NULL;
+}
+
static Pager_Win *
_pager_window_new(Pager_Desk *pd, E_Border *border)
{
@@ -718,93 +421,81 @@ _pager_window_new(Pager_Desk *pd, E_Border *border)
visible = !border->iconic;
pw->desk = pd;
- o = edje_object_add(pd->face->evas);
- pw->window_object = o;
+ o = edje_object_add(evas_object_evas_get(pd->pager->o_table));
+ pw->o_window = o;
e_theme_edje_object_set(o, "base/theme/modules/pager",
"modules/pager/window");
if (visible) evas_object_show(o);
- e_layout_pack(pd->layout_object, pw->window_object);
- e_layout_child_raise(pw->window_object);
- o = e_border_icon_add(border, pd->face->evas);
- if (o)
- {
- pw->icon_object = o;
- evas_object_show(o);
- edje_object_part_swallow(pw->window_object, "icon", o);
- }
-
- /* add an event object */
-
- o = evas_object_rectangle_add(pd->face->evas);
- pw->event_object = o;
-
- evas_object_repeat_events_set(o, 1);
- evas_object_color_set(o, 0, 0, 0, 0);
-// evas_object_color_set(o, rand()%255, rand()%255, rand()%255, 255);
-
-
+ e_layout_pack(pd->o_layout, pw->o_window);
+ e_layout_child_raise(pw->o_window);
+
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _pager_window_cb_mouse_in, pw);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _pager_window_cb_mouse_out, pw);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _pager_window_cb_mouse_down, pw);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _pager_window_cb_mouse_up, pw);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _pager_window_cb_mouse_move, pw);
+ o = e_border_icon_add(border, evas_object_evas_get(pd->pager->o_table));
+ if (o)
+ {
+ pw->o_icon = o;
+ evas_object_show(o);
+ edje_object_part_swallow(pw->o_window, "icon", o);
+ }
+
evas_object_show(o);
- e_layout_pack(pd->layout_object, pw->event_object);
- e_layout_child_raise(pw->event_object);
-
- _pager_window_move(pd->face, pw);
+ _pager_window_move(pw);
return pw;
}
static void
_pager_window_free(Pager_Win *pw)
{
- if (pw->window_object) evas_object_del(pw->window_object);
- if (pw->icon_object) evas_object_del(pw->icon_object);
- if (pw->event_object) evas_object_del(pw->event_object);
+ if ((pw->drag.from_pager) && (pw->desk->pager->dragging))
+ {
+ if (pw->desk->pager->drag)
+ e_object_del(E_OBJECT(pw->desk->pager->drag));
+ pw->desk->pager->drag = NULL;
+ pw->desk->pager->dragging = 0;
+ }
+ if (pw->o_window) evas_object_del(pw->o_window);
+ if (pw->o_icon) evas_object_del(pw->o_icon);
e_object_unref(E_OBJECT(pw->border));
free(pw);
}
static void
-_pager_window_move(Pager_Face *face, Pager_Win *pw)
+_pager_window_move(Pager_Win *pw)
{
- e_layout_child_move(pw->window_object,
+ e_layout_child_move(pw->o_window,
pw->border->x - pw->desk->desk->zone->x,
pw->border->y - pw->desk->desk->zone->y);
- e_layout_child_resize(pw->window_object,
- pw->border->w,
- pw->border->h);
- e_layout_child_move(pw->event_object,
- pw->border->x - pw->desk->desk->zone->x,
- pw->border->y - pw->desk->desk->zone->y);
- e_layout_child_resize(pw->event_object,
+ e_layout_child_resize(pw->o_window,
pw->border->w,
pw->border->h);
}
static Pager_Win *
-_pager_face_border_find(Pager_Face *face, E_Border *border)
+_pager_window_find(Pager *p, E_Border *border)
{
Evas_List *l;
- for (l = face->desks; l; l = l->next)
+ for (l = p->desks; l; l = l->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l->data;
- pw = _pager_desk_border_find(pd, border);
+ pw = _pager_desk_window_find(pd, border);
if (pw) return pw;
}
return NULL;
}
static Pager_Win *
-_pager_desk_border_find(Pager_Desk *pd, E_Border *border)
+_pager_desk_window_find(Pager_Desk *pd, E_Border *border)
{
Evas_List *l;
@@ -818,141 +509,183 @@ _pager_desk_border_find(Pager_Desk *pd, E_Border *border)
return NULL;
}
-static Pager_Desk *
-_pager_face_desk_find(Pager_Face *face, E_Desk *desk)
+static Pager_Popup *
+_pager_popup_new(Pager *p)
{
- Evas_List *l;
-
- for (l = face->desks; l; l = l->next)
+ Pager_Popup *pp;
+ Evas_Coord w, h;
+ E_Desk *desk;
+
+ pp = E_NEW(Pager_Popup, 1);
+ if (!pp) return NULL;
+
+ /* Show popup */
+ pp->popup = e_popup_new(p->zone, 0, 0, 1, 1);
+ if (!pp->popup)
{
- Pager_Desk *pd;
-
- pd = l->data;
- if (pd->desk == desk) return pd;
+ free(pp);
+ return NULL;
}
- return NULL;
+ e_popup_layer_set(pp->popup, 999);
+ pp->src_pager = p;
+
+ p->popup = pp;
+
+ evas_object_geometry_get(p->o_table, NULL, NULL, &w, &h);
+
+ pp->pager = _pager_new(pp->popup->evas, p->zone);
+ evas_object_move(pp->pager->o_table, 0, 0);
+ evas_object_resize(pp->pager->o_table, w, h);
+
+ pp->o_bg = edje_object_add(pp->popup->evas);
+ e_theme_edje_object_set(pp->o_bg,
+ "base/theme/modules/pager",
+ "widgets/pager/popup");
+ desk = e_desk_current_get(p->zone);
+ if (desk)
+ edje_object_part_text_set(pp->o_bg, "text", desk->name);
+ evas_object_show(pp->o_bg);
+ edje_extern_object_min_size_set(pp->pager->o_table, w, h);
+ edje_object_part_swallow(pp->o_bg, "pager", pp->pager->o_table);
+ edje_object_size_min_calc(pp->o_bg, &w, &h);
+
+ evas_object_move(pp->o_bg, 0, 0);
+ evas_object_resize(pp->o_bg, w, h);
+ e_popup_edje_bg_object_set(pp->popup, pp->o_bg);
+ e_popup_ignore_events_set(pp->popup, 1);
+ e_popup_move_resize(pp->popup, ((p->zone->w - w) / 2),
+ ((p->zone->h - h) / 2), w, h);
+ e_bindings_mouse_grab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
+ e_bindings_wheel_grab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
+ e_popup_show(pp->popup);
+
+ pp->timer = ecore_timer_add(pager_config->popup_speed,
+ _pager_popup_cb_timeout, pp);
}
-/**
- * Return Pager_Desk at canvas coord x, y
- */
-static Pager_Desk *
-_pager_face_desk_at_coord(Pager_Face *face, Evas_Coord x, Evas_Coord y)
+static void
+_pager_popup_free(Pager_Popup *pp)
{
- Evas_List *l;
-
- for (l = face->desks; l; l = l->next)
- {
- Pager_Desk *pd;
- Evas_Coord dx, dy, dw, dh;
+ pp->src_pager->popup = NULL;
+ if (pp->timer) ecore_timer_del(pp->timer);
+ evas_object_del(pp->o_bg);
+ _pager_free(pp->pager);
+ e_bindings_mouse_ungrab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
+ e_bindings_wheel_ungrab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
+ e_object_del(E_OBJECT(pp->popup));
+ free(pp);
+}
- pd = l->data;
- evas_object_geometry_get(pd->desk_object, &dx, &dy, &dw, &dh);
- if (E_INSIDE(x, y, dx, dy, dw, dh))
- {
- return pd;
- }
- }
- return NULL;
+static int
+_pager_cb_timer_drop_recalc(void *data)
+{
+ Instance *inst;
+
+ inst = data;
+ _pager_instance_drop_zone_recalc(inst);
+ return 1;
}
static void
-_pager_face_desk_select(Pager_Desk *pd)
+_pager_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Evas_List *l;
+ Instance *inst;
+
+ inst = data;
+ _pager_instance_drop_zone_recalc(inst);
+}
- if (pd->current) return;
- for (l = pd->face->desks; l; l = l->next)
+static void
+_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Instance *inst;
+ Evas_Event_Mouse_Down *ev;
+
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!pager_config->menu))
{
- Pager_Desk *pd2;
-
- pd2 = l->data;
- if (pd == pd2)
- {
- pd2->current = 1;
- edje_object_signal_emit(pd2->desk_object, "active", "");
- }
- else
- {
- if (pd2->current)
- {
- pd2->current = 0;
- edje_object_signal_emit(pd2->desk_object, "passive", "");
- }
- }
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int cx, cy, cw, ch;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _menu_cb_post, inst);
+ pager_config->menu = mn;
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Configuration"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
+ e_menu_item_callback_set(mi, _pager_inst_cb_menu_configure, NULL);
+
+ e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &cx, &cy, &cw, &ch);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ cx + ev->output.x, cy + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
- edje_object_part_text_set(pd->face->pager_object, "desktop_name", pd->desk->name);
}
static void
-_pager_popup_free(Pager_Popup *pp)
+_menu_cb_post(void *data, E_Menu *m)
{
- pp->src_face->current_popup = NULL;
- if (pp->timer) ecore_timer_del(pp->timer);
- pp->face->pager->faces = evas_list_remove(pp->face->pager->faces, pp->face);
- evas_object_del(pp->bg_object);
- _pager_face_free(pp->face);
- e_bindings_mouse_ungrab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
- e_bindings_wheel_ungrab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
- e_object_del(E_OBJECT(pp->popup));
- free(pp);
+ if (!pager_config->menu) return;
+ e_object_del(E_OBJECT(pager_config->menu));
+ pager_config->menu = NULL;
}
static void
-_pager_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
+_pager_inst_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
{
- Pager_Face *face;
- Evas_Coord x, y, w, h;
+ if (!pager_config) return;
+ if (pager_config->config_dialog) return;
+ /* FIXME: pass zone config item */
+ _config_pager_module(NULL);
+}
- face = data;
- e_gadman_client_geometry_get(face->gmc, &x, &y, &w, &h);
+static void
+_pager_instance_drop_zone_recalc(Instance *inst)
+{
+ Evas_Coord x, y, w, h;
+ int cx, cy, cw, ch;
- face->fx = x;
- face->fy = y;
- face->fw = w;
- face->fh = h;
- e_drop_handler_geometry_set(face->drop_handler,
- face->fx + face->inset.l, face->fy + face->inset.t,
- face->fw - (face->inset.l + face->inset.r),
- face->fh - (face->inset.t + face->inset.b));
- switch (change)
- {
- case E_GADMAN_CHANGE_MOVE_RESIZE:
- evas_object_move(face->pager_object, face->fx, face->fy);
- evas_object_resize(face->pager_object, face->fw, face->fh);
- break;
- case E_GADMAN_CHANGE_RAISE:
- evas_object_raise(face->pager_object);
- break;
- default:
- break;
- }
+ evas_object_geometry_get(inst->o_pager, &x, &y, &w, &h);
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ e_drop_handler_geometry_set(inst->drop_handler, cx + x, cy + y, w, h);
+}
+
+void
+_pager_cb_config_updated(void)
+{
+ if (!pager_config) return;
}
static int
_pager_cb_event_border_resize(void *data, int type, void *event)
{
E_Event_Border_Resize *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
- if (pw)
- _pager_window_move(face, pw);
+ pw = _pager_desk_window_find(pd, ev->border);
+ if (pw) _pager_window_move(pw);
}
}
return 1;
@@ -962,26 +695,23 @@ static int
_pager_cb_event_border_move(void *data, int type, void *event)
{
E_Event_Border_Move *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
- if (pw)
- _pager_window_move(face, pw);
+ pw = _pager_desk_window_find(pd, ev->border);
+ if (pw) _pager_window_move(pw);
}
}
return 1;
@@ -991,29 +721,25 @@ static int
_pager_cb_event_border_add(void *data, int type, void *event)
{
E_Event_Border_Add *ev;
- Pager *pager;
Evas_List *l;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
Pager_Desk *pd;
- face = l->data;
- if ((face->zone != ev->border->zone) ||
- (_pager_face_border_find(face, ev->border)))
+ inst = l->data;
+ if ((inst->pager->zone != ev->border->zone) ||
+ (_pager_window_find(inst->pager, ev->border)))
continue;
-
- pd = _pager_face_desk_find(face, ev->border->desk);
+ pd = _pager_desk_find(inst->pager, ev->border->desk);
if (pd)
{
Pager_Win *pw;
pw = _pager_window_new(pd, ev->border);
- if (pw)
- pd->wins = evas_list_append(pd->wins, pw);
+ if (pw) pd->wins = evas_list_append(pd->wins, pw);
}
}
return 1;
@@ -1023,24 +749,22 @@ static int
_pager_cb_event_border_remove(void *data, int type, void *event)
{
E_Event_Border_Remove *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
+ pw = _pager_desk_window_find(pd, ev->border);
if (pw)
{
pd->wins = evas_list_remove(pd->wins, pw);
@@ -1055,28 +779,32 @@ static int
_pager_cb_event_border_iconify(void *data, int type, void *event)
{
E_Event_Border_Hide *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
+ pw = _pager_desk_window_find(pd, ev->border);
if (pw)
{
- evas_object_hide(pw->window_object);
- evas_object_hide(pw->event_object);
+ if ((pw->drag.from_pager) && (pw->desk->pager->dragging))
+ {
+ if (pw->desk->pager->drag)
+ e_object_del(E_OBJECT(pw->desk->pager->drag));
+ pw->desk->pager->drag = NULL;
+ pw->desk->pager->dragging = 0;
+ }
+ evas_object_hide(pw->o_window);
}
}
}
@@ -1087,29 +815,23 @@ static int
_pager_cb_event_border_uniconify(void *data, int type, void *event)
{
E_Event_Border_Show *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
- if (pw)
- {
- evas_object_show(pw->window_object);
- evas_object_show(pw->event_object);
- }
+ pw = _pager_desk_window_find(pd, ev->border);
+ if (pw) evas_object_show(pw->o_window);
}
}
return 1;
@@ -1119,21 +841,19 @@ static int
_pager_cb_event_border_stick(void *data, int type, void *event)
{
E_Event_Border_Stick *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
- Pager_Win *pw;
-
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- pw = _pager_face_border_find(face, ev->border);
+ Instance *inst;
+ Pager_Win *pw;
+
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ pw = _pager_window_find(inst->pager, ev->border);
if (!pw) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
@@ -1141,8 +861,7 @@ _pager_cb_event_border_stick(void *data, int type, void *event)
if (ev->border->desk != pd->desk)
{
pw = _pager_window_new(pd, ev->border);
- if (pw)
- pd->wins = evas_list_append(pd->wins, pw);
+ if (pw) pd->wins = evas_list_append(pd->wins, pw);
}
}
}
@@ -1153,18 +872,16 @@ static int
_pager_cb_event_border_unstick(void *data, int type, void *event)
{
E_Event_Border_Unstick *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
@@ -1173,7 +890,7 @@ _pager_cb_event_border_unstick(void *data, int type, void *event)
{
Pager_Win *pw;
- pw = _pager_desk_border_find(pd, ev->border);
+ pw = _pager_desk_window_find(pd, ev->border);
if (pw)
{
pd->wins = evas_list_remove(pd->wins, pw);
@@ -1189,28 +906,25 @@ static int
_pager_cb_event_border_desk_set(void *data, int type, void *event)
{
E_Event_Border_Desk_Set *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
Pager_Win *pw;
Pager_Desk *pd;
- face = l->data;
-
+ inst = l->data;
/* if this pager is not for the zone of the border */
- if (face->zone != ev->border->zone)
+ if (inst->pager->zone != ev->border->zone)
{
/* look at all desks in the pager */
- for (l2 = face->desks; l2; l2 = l2->next)
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
pd = l2->data;
/* find this border in this desk */
- pw = _pager_desk_border_find(pd, ev->border);
+ pw = _pager_desk_window_find(pd, ev->border);
if (pw)
{
/* if it is found - remove it. it does not belong in this
@@ -1223,7 +937,7 @@ _pager_cb_event_border_desk_set(void *data, int type, void *event)
}
/* and this pager zone is for this border */
/* see if the window is in this pager at all */
- pw = _pager_face_border_find(face, ev->border);
+ pw = _pager_window_find(inst->pager, ev->border);
if (pw)
{
/* is it sticky */
@@ -1235,7 +949,7 @@ _pager_cb_event_border_desk_set(void *data, int type, void *event)
}
/* move it to the right desk */
/* find the pager desk of the target desk */
- pd = _pager_face_desk_find(face, ev->border->desk);
+ pd = _pager_desk_find(inst->pager, ev->border->desk);
if (pd)
{
Pager_Win *pw2 = NULL;
@@ -1243,30 +957,22 @@ _pager_cb_event_border_desk_set(void *data, int type, void *event)
/* remove it from whatever desk it was on */
pw->desk->wins = evas_list_remove(pw->desk->wins, pw);
- e_layout_unpack(pw->window_object);
- e_layout_unpack(pw->event_object);
+ e_layout_unpack(pw->o_window);
/* add it to the one its MEANT to be on */
pw->desk = pd;
pd->wins = evas_list_append(pd->wins, pw);
- e_layout_pack(pd->layout_object, pw->window_object);
- e_layout_pack(pd->layout_object, pw->event_object);
+ e_layout_pack(pd->o_layout, pw->o_window);
bd = e_util_desk_border_above(pw->border);
if (bd)
- pw2 = _pager_desk_border_find(pd, bd);
+ pw2 = _pager_desk_window_find(pd, bd);
if (pw2)
- {
- e_layout_child_lower_below(pw->window_object, pw2->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_lower_below(pw->o_window, pw2->o_window);
else
- {
- e_layout_child_raise(pw->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_raise(pw->o_window);
- _pager_window_move(face, pw);
+ _pager_window_move(pw);
}
}
/* the border isnt in this pager at all - it must have moved zones */
@@ -1275,7 +981,7 @@ _pager_cb_event_border_desk_set(void *data, int type, void *event)
if (!ev->border->sticky)
{
/* find the pager desk it needs to go to */
- pd = _pager_face_desk_find(face, ev->border->desk);
+ pd = _pager_desk_find(inst->pager, ev->border->desk);
if (pd)
{
/* create it and add it */
@@ -1288,26 +994,20 @@ _pager_cb_event_border_desk_set(void *data, int type, void *event)
pd->wins = evas_list_append(pd->wins, pw);
bd = e_util_desk_border_above(pw->border);
if (bd)
- pw2 = _pager_desk_border_find(pd, bd);
+ pw2 = _pager_desk_window_find(pd, bd);
if (pw2)
- {
- e_layout_child_lower_below(pw->window_object, pw2->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_lower_below(pw->o_window, pw2->o_window);
else
- {
- e_layout_child_raise(pw->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_raise(pw->o_window);
- _pager_window_move(face, pw);
+ _pager_window_move(pw);
}
}
}
else
{
/* go through all desks */
- for (l2 = face->desks; l2; l2 = l2->next)
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
pd = l2->data;
/* create it and add it */
@@ -1320,19 +1020,13 @@ _pager_cb_event_border_desk_set(void *data, int type, void *event)
pd->wins = evas_list_append(pd->wins, pw);
bd = e_util_desk_border_above(pw->border);
if (bd)
- pw2 = _pager_desk_border_find(pd, bd);
+ pw2 = _pager_desk_window_find(pd, bd);
if (pw2)
- {
- e_layout_child_lower_below(pw->window_object, pw2->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_lower_below(pw->o_window, pw2->o_window);
else
- {
- e_layout_child_raise(pw->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_raise(pw->o_window);
- _pager_window_move(face, pw);
+ _pager_window_move(pw);
}
}
}
@@ -1345,29 +1039,27 @@ static int
_pager_cb_event_border_stack(void *data, int type, void *event)
{
E_Event_Border_Stack *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw, *pw2 = NULL;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
+ pw = _pager_desk_window_find(pd, ev->border);
if (pw)
{
if (ev->stack)
{
- pw2 = _pager_desk_border_find(pd, ev->stack);
+ pw2 = _pager_desk_window_find(pd, ev->stack);
if (!pw2)
{
/* This border is on another desk... */
@@ -1377,39 +1069,24 @@ _pager_cb_event_border_stack(void *data, int type, void *event)
bd = e_util_desk_border_below(ev->border);
else if (ev->type == E_STACKING_BELOW)
bd = e_util_desk_border_above(ev->border);
-
- if (bd)
- pw2 = _pager_desk_border_find(pd, bd);
+ if (bd) pw2 = _pager_desk_window_find(pd, bd);
}
}
if (ev->type == E_STACKING_ABOVE)
{
if (pw2)
- {
- e_layout_child_raise_above(pw->window_object, pw2->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- e_layout_child_raise_above(pw2->event_object, pw2->window_object);
- }
+ e_layout_child_raise_above(pw->o_window, pw2->o_window);
else
- {
- /* If we aren't above any window, we are at the bottom */
- e_layout_child_lower(pw->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ /* If we aren't above any window, we are at the bottom */
+ e_layout_child_lower(pw->o_window);
}
else if (ev->type == E_STACKING_BELOW)
{
if (pw2)
- {
- e_layout_child_lower_below(pw->window_object, pw2->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ e_layout_child_lower_below(pw->o_window, pw2->o_window);
else
- {
- /* If we aren't below any window, we are at the top */
- e_layout_child_raise(pw->window_object);
- e_layout_child_raise_above(pw->event_object, pw->window_object);
- }
+ /* If we aren't below any window, we are at the top */
+ e_layout_child_raise(pw->o_window);
}
}
}
@@ -1421,39 +1098,38 @@ static int
_pager_cb_event_border_icon_change(void *data, int type, void *event)
{
E_Event_Border_Icon_Change *ev;
- Pager *pager;
Evas_List *l, *l2;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
- face = l->data;
- if (face->zone != ev->border->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
+ inst = l->data;
+ if (inst->pager->zone != ev->border->zone) continue;
+ for (l2 = inst->pager->desks; l2; l2 = l2->next)
{
Pager_Desk *pd;
Pager_Win *pw;
pd = l2->data;
- pw = _pager_desk_border_find(pd, ev->border);
+ pw = _pager_desk_window_find(pd, ev->border);
if (pw)
{
Evas_Object *o;
- if (pw->icon_object)
+ if (pw->o_icon)
{
- evas_object_del(pw->icon_object);
- pw->icon_object = NULL;
+ evas_object_del(pw->o_icon);
+ pw->o_icon = NULL;
}
- o = e_border_icon_add(ev->border, pd->face->evas);
+ o = e_border_icon_add
+ (ev->border, evas_object_evas_get(inst->pager->o_table));
if (o)
{
- pw->icon_object = o;
+ pw->o_icon = o;
evas_object_show(o);
- edje_object_part_swallow(pw->window_object, "icon", o);
+ edje_object_part_swallow(pw->o_window, "icon", o);
}
}
}
@@ -1464,76 +1140,15 @@ _pager_cb_event_border_icon_change(void *data, int type, void *event)
static int
_pager_cb_event_zone_desk_count_set(void *data, int type, void *event)
{
- E_Event_Zone_Desk_Count_Set *ev;
- Pager *pager;
- Evas_List *l, *l2;
-
- pager = data;
- ev = event;
+ Evas_List *l;
+ Instance *inst;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
- Pager_Desk *pd, *pd2;
- E_Desk *desk;
- int desks_x, desks_y;
- int x, y;
- Evas_Coord lw, lh, dw, dh;
- double aspect;
-
- face = l->data;
-
- if (face->zone != ev->zone) continue;
- e_zone_desk_count_get(ev->zone, &desks_x, &desks_y);
- if ((face->xnum == desks_x) && (face->ynum == desks_y)) continue;
-
- evas_object_geometry_get(face->table_object, NULL, NULL, &lw, &lh);
- if (face->xnum > 0) dw = lw / face->xnum;
- else dw = 0;
- dw *= (desks_x - face->xnum);
- if (face->ynum > 0) dh = lh / face->ynum;
- else dh = 0;
- dh *= (desks_y - face->ynum);
-
- /* Loop to add new desks */
- for (x = 0; x < desks_x; x++)
- {
- for (y = 0; y < desks_y; y++)
- {
- if ((x >= face->xnum) || (y >= face->ynum))
- {
- /* add desk */
- desk = e_desk_at_xy_get(ev->zone, x, y);
- pd = _pager_desk_new(face, desk, x, y);
- if (pd)
- face->desks = evas_list_append(face->desks, pd);
- }
- }
- }
- /* Loop to remove extra desks */
- for (l2 = face->desks; l2;)
- {
- pd = l2->data;
- l2 = l2->next;
- if ((pd->xpos >= desks_x) || (pd->ypos >= desks_y))
- {
- /* remove desk */
- if (pd->current)
- {
- desk = e_desk_current_get(ev->zone);
- pd2 = _pager_face_desk_find(face, desk);
- _pager_face_desk_select(pd2);
- }
- face->desks = evas_list_remove(face->desks, pd);
- _pager_desk_free(pd);
- }
- }
-
- face->xnum = desks_x;
- face->ynum = desks_y;
- aspect = (double)(face->xnum * face->zone->w) / (double)(face->ynum * face->zone->h);
- e_gadman_client_aspect_set(face->gmc, aspect, aspect);
- e_gadman_client_resize(face->gmc, face->fw + dw, face->fh + dh);
+ inst = l->data;
+ _pager_empty(inst->pager);
+ _pager_fill(inst->pager);
+ _gc_orient(inst->gcc);
}
return 1;
}
@@ -1542,240 +1157,55 @@ static int
_pager_cb_event_desk_show(void *data, int type, void *event)
{
E_Event_Desk_Show *ev;
- Pager *pager;
- Pager_Popup *pp = NULL;
- Evas_List *l;
+ Evas_List *l;
- pager = data;
ev = event;
- for (l = pager->faces; l; l = l->next)
+ for (l = pager_config->instances; l; l = l->next)
{
- Pager_Face *face;
+ Instance *inst;
Pager_Desk *pd;
- face = l->data;
- if (face->zone != ev->desk->zone) continue;
+ inst = l->data;
+ if (inst->pager->zone != ev->desk->zone) continue;
- pd = _pager_face_desk_find(face, ev->desk);
+ pd = _pager_desk_find(inst->pager, ev->desk);
if (pd)
{
- Evas_Coord w, h;
-
- _pager_face_desk_select(pd);
-
- /* If the popup is defined, we don't want another */
- if ((!face->pager->conf->popup) || (pp)) continue;
-
- pp = face->current_popup;
- face->current_popup = NULL;
- if (pp) _pager_popup_free(pp);
-
- pp = E_NEW(Pager_Popup, 1);
- if (!pp) continue;
-
- /* Show popup */
- pp->popup = e_popup_new(face->zone, 0, 0, 1, 1);
- if (!pp->popup)
+ _pager_desk_select(pd);
+ if (pd->pager->popup) _pager_popup_free(pd->pager->popup);
+ if (pager_config->popup)
{
- free(pp);
- continue;
+ Pager_Popup *pp;
+
+ pp = _pager_popup_new(pd->pager);
}
- e_popup_layer_set(pp->popup, 999);
- pp->src_face = face;
-
- face->current_popup = pp;
-
- evas_object_geometry_get(face->pager_object, NULL, NULL, &w, &h);
-
- pp->face = _pager_face_new(face->pager, face->zone,
- pp->popup->evas, 0);
- evas_object_move(pp->face->pager_object, 0, 0);
- evas_object_resize(pp->face->pager_object, w, h);
-
- pp->bg_object = edje_object_add(pp->face->evas);
- e_theme_edje_object_set(pp->bg_object, "base/theme/modules/pager",
- "widgets/pager/popup");
- edje_object_part_text_set(pp->bg_object, "text", pd->desk->name);
- evas_object_show(pp->bg_object);
- edje_extern_object_min_size_set(pp->face->pager_object, w, h);
- edje_object_part_swallow(pp->bg_object, "pager", pp->face->pager_object);
- edje_object_calc_force(pp->face->pager_object);
- edje_object_size_min_calc(pp->bg_object, &w, &h);
-
- evas_object_move(pp->bg_object, 0, 0);
- evas_object_resize(pp->bg_object, w, h);
- e_popup_edje_bg_object_set(pp->popup, pp->bg_object);
- e_popup_ignore_events_set(pp->popup, 1);
- e_popup_move_resize(pp->popup,
- ((pp->popup->zone->w - w) / 2),
- ((pp->popup->zone->h - h) / 2),
- w, h);
- e_bindings_mouse_grab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
- e_bindings_wheel_grab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win);
- e_popup_show(pp->popup);
-
- pp->timer = ecore_timer_add(face->pager->conf->popup_speed,
- _pager_popup_cb_timeout, pp);
}
}
-
return 1;
}
static int
-_pager_popup_cb_timeout(void *data)
-{
- Pager_Popup *pp;
-
- pp = data;
- _pager_popup_free(pp);
- return 0;
-}
-
-static int
_pager_cb_event_desk_name_change(void *data, int type, void *event)
{
- E_Event_Desk_Show *ev;
- Pager *pager;
- Evas_List *l, *l2;
-
- pager = data;
- ev = event;
- for (l = pager->faces; l; l = l->next)
- {
- Pager_Face *face;
-
- face = l->data;
- if (face->zone != ev->desk->zone) continue;
- for (l2 = face->desks; l2; l2 = l2->next)
- {
- Pager_Desk *pd;
- pd = l2->data;
-
- if ((pd->desk == ev->desk) && (pd->current))
- {
- edje_object_part_text_set(pd->face->pager_object, "desktop_name", ev->desk->name);
- break;
- }
-
- }
- }
- return 1;
-}
-
-static void
-_pager_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
-{
- Pager_Face *face;
-
- face = data;
- e_gadman_mode_set(face->gmc->gadman, E_GADMAN_MODE_EDIT);
-}
-
-/*****/
-
-static void
-_pager_desk_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_In *ev;
- Pager_Desk *desk;
-
- ev = event_info;
- desk = data;
-
- edje_object_part_text_set(desk->face->pager_object, "desktop_name", desk->desk->name);
-}
-
-static void
-_pager_desk_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Out *ev;
- Pager_Desk *desk;
+ E_Event_Desk_Name_Change *ev;
Evas_List *l;
- ev = event_info;
- desk = data;
-
- for (l = desk->face->desks; l; l = l->next)
+ ev = event;
+ for (l = pager_config->instances; l; l = l->next)
{
+ Instance *inst;
Pager_Desk *pd;
- pd = l->data;
- if (pd->current)
- {
- edje_object_part_text_set(pd->face->pager_object, "desktop_name", pd->desk->name);
- break;
- }
- }
-}
-
-static void
-_pager_desk_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Down *ev;
- Pager_Desk *pd;
-
- ev = event_info;
- pd = data;
- if ((ev->button == 3) && (pd->face->menu))
- {
- e_menu_activate_mouse(pd->face->menu, pd->face->zone,
- ev->output.x, ev->output.y, 1, 1,
- E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
- e_util_container_fake_mouse_up_later(pd->face->zone->container, 3);
- }
-}
-
-static void
-_pager_desk_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Up *ev;
- Pager_Desk *desk;
-
- ev = event_info;
- desk = data;
- if ((ev->button == 1) && (!desk->face->dragging))
- {
- e_desk_show(desk->desk);
+ inst = l->data;
+ if (inst->pager->zone != ev->desk->zone) continue;
+ pd = _pager_desk_find(inst->pager, ev->desk);
+ if (pd)
+ edje_object_part_text_set(pd->o_desk, "label", ev->desk->name);
}
+ return 1;
}
static void
-_pager_desk_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Move *ev;
- Pager_Desk *desk;
-
- ev = event_info;
- desk = data;
-}
-
-/*****/
-
-static void
-_pager_desk_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y)
-{
- Pager_Desk *desk;
-
- desk = data;
- evas_object_move(o, x, y);
- evas_object_move(desk->event_object, x, y);
-}
-
-static void
-_pager_desk_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h)
-{
- Pager_Desk *desk;
-
- desk = data;
- evas_object_resize(o, w, h);
- evas_object_resize(desk->event_object, w, h);
-}
-
-
-/*****/
-
-static void
_pager_window_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_In *ev;
@@ -1783,7 +1213,7 @@ _pager_window_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_inf
ev = event_info;
pw = data;
-
+ /* FIXME: display window title in some tooltip thing */
}
static void
@@ -1794,7 +1224,7 @@ _pager_window_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_in
ev = event_info;
pw = data;
-
+ /* FIXME: close tooltip */
}
static void
@@ -1806,20 +1236,21 @@ _pager_window_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_i
ev = event_info;
pw = data;
if (!pw) return;
-
- /* make this configurable */
- if (ev->button == 1)
+ /* FIXME: make this configurable */
+ if ((ev->button == 1) || (ev->button == 2))
{
Evas_Coord ox, oy;
- evas_object_geometry_get(pw->window_object, &ox, &oy, NULL, NULL);
+ evas_object_geometry_get(pw->o_window, &ox, &oy, NULL, NULL);
pw->drag.in_pager = 1;
-
pw->drag.x = ev->canvas.x;
pw->drag.y = ev->canvas.y;
pw->drag.dx = ox - ev->canvas.x;
pw->drag.dy = oy - ev->canvas.y;
pw->drag.start = 1;
+ pw->drag.no_place = 0;
+ pw->drag.button = ev->button;
+ if (ev->button == 2) pw->drag.no_place = 1;
}
}
@@ -1832,10 +1263,17 @@ _pager_window_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_inf
ev = event_info;
pw = data;
if (!pw) return;
-
- pw->drag.in_pager = 0;
- pw->drag.start = 0;
- pw->desk->face->dragging = 0;
+ /* FIXME: make this configurable as above */
+ if ((ev->button == 1) || (ev->button == 2))
+ {
+ if (!pw->drag.from_pager)
+ {
+ if (!pw->drag.start) pw->desk->pager->just_dragged = 1;
+ pw->drag.in_pager = 0;
+ pw->drag.start = 0;
+ pw->desk->pager->dragging = 0;
+ }
+ }
}
static void
@@ -1846,9 +1284,7 @@ _pager_window_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_i
ev = event_info;
pw = data;
-
if (!pw) return;
-
/* prevent drag for a few pixels */
if (pw->drag.start)
{
@@ -1857,12 +1293,12 @@ _pager_window_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_i
dx = pw->drag.x - ev->cur.output.x;
dy = pw->drag.y - ev->cur.output.y;
- if (pw->desk && pw->desk->face && pw->desk->face->pager)
- resist = pw->desk->face->pager->conf->drag_resist;
+ if (pw->desk && pw->desk->pager && pw->desk->pager->inst)
+ resist = pager_config->drag_resist;
if (((dx * dx) + (dy * dy)) <= (resist * resist)) return;
- pw->desk->face->dragging = 1;
+ pw->desk->pager->dragging = 1;
pw->drag.start = 0;
}
@@ -1870,65 +1306,61 @@ _pager_window_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_i
if (pw->drag.in_pager)
{
Evas_Coord mx, my, vx, vy;
- Pager_Desk *desk;
+ Pager_Desk *pd;
/* m for mouse */
mx = ev->cur.canvas.x;
my = ev->cur.canvas.y;
/* find desk at pointer */
- desk = _pager_face_desk_at_coord(pw->desk->face, mx, my);
-
- if (desk)
+ pd = _pager_desk_at_coord(pw->desk->pager, mx, my);
+ if ((pd) && (!pw->drag.no_place))
{
- e_layout_coord_canvas_to_virtual(desk->layout_object, mx + pw->drag.dx, my + pw->drag.dy, &vx, &vy);
-
- if (desk != pw->desk) e_border_desk_set(pw->border, desk->desk);
- e_border_move(pw->border, vx + desk->desk->zone->x, vy + desk->desk->zone->y);
+ e_layout_coord_canvas_to_virtual(pd->o_layout,
+ mx + pw->drag.dx,
+ my + pw->drag.dy, &vx, &vy);
+ if (pd != pw->desk)
+ e_border_desk_set(pw->border, pd->desk);
+ e_border_move(pw->border,
+ vx + pd->desk->zone->x,
+ vy + pd->desk->zone->y);
}
else
{
- /* not over a desk, start dnd drag */
- if (pw->window_object)
- {
- E_Drag *drag;
- Evas_Object *o, *oo;
- Evas_Coord x, y, w, h;
- const char *file, *part;
- const char *drag_types[] = { "enlightenment/pager_win" };
-
- evas_object_geometry_get(pw->window_object,
- &x, &y, &w, &h);
-
- /* XXX this relies on screen and canvas coords matching. is this a valid assumption? */
- drag = e_drag_new(pw->desk->face->zone->container, x, y,
- drag_types, 1, pw, -1,
- _pager_window_cb_drag_finished);
-
-
- o = edje_object_add(drag->evas);
- edje_object_file_get(pw->window_object, &file, &part);
- edje_object_file_set(o, file, part);
-
- oo = o;
-
- o = edje_object_add(drag->evas);
- edje_object_file_get(pw->icon_object, &file, &part);
- edje_object_file_set(o, file, part);
- edje_object_part_swallow(oo, "icon", o);
-
- e_drag_object_set(drag, oo);
-
- e_drag_resize(drag, w, h);
- e_drag_start(drag, x - pw->drag.dx, y - pw->drag.dy);
-
- /* this prevents the desk from switching on drags */
- pw->drag.from_face = pw->desk->face;
- pw->drag.from_face->dragging = 1;
- evas_event_feed_mouse_up(pw->desk->face->evas, 1,
- EVAS_BUTTON_NONE, ecore_time_get(), NULL);
- }
+ E_Drag *drag;
+ Evas_Object *o, *oo;
+ Evas_Coord x, y, w, h;
+ const char *file = NULL, *part = NULL;
+ const char *drag_types[] = { "enlightenment/pager_win" };
+
+ evas_object_geometry_get(pw->o_window, &x, &y, &w, &h);
+ evas_object_hide(pw->o_window);
+
+ drag = e_drag_new(pw->desk->pager->inst->gcc->gadcon->zone->container,
+ x, y, drag_types, 1, pw, -1,
+ _pager_window_cb_drag_finished);
+ pw->desk->pager->drag = drag;
+
+ o = edje_object_add(drag->evas);
+ edje_object_file_get(pw->o_window, &file, &part);
+ edje_object_file_set(o, file, part);
+
+ oo = o;
+ o = edje_object_add(drag->evas);
+ edje_object_file_get(pw->o_icon, &file, &part);
+ edje_object_file_set(o, file, part);
+ edje_object_part_swallow(oo, "icon", o);
+ e_drag_object_set(drag, oo);
+ e_drag_resize(drag, w, h);
+ e_drag_start(drag, x - pw->drag.dx, y - pw->drag.dy);
+
+ /* this prevents the desk from switching on drags */
+ pw->drag.from_pager = pw->desk->pager;
+ pw->drag.from_pager->dragging = 1;
pw->drag.in_pager = 0;
+ evas_event_feed_mouse_up(evas_object_evas_get(pw->desk->pager->o_table),
+ pw->drag.button, EVAS_BUTTON_NONE,
+ ecore_x_current_time_get(), NULL);
}
}
}
@@ -1939,9 +1371,9 @@ _pager_window_cb_drag_finished(E_Drag *drag, int dropped)
Pager_Win *pw;
pw = drag->data;
-
if (!pw) return;
-
+ evas_object_show(pw->o_window);
+ pw->desk->pager->drag = NULL;
if (!dropped)
{
/* wasn't dropped (on pager). move it to position of mouse on screen */
@@ -1958,177 +1390,111 @@ _pager_window_cb_drag_finished(E_Drag *drag, int dropped)
e_border_desk_set(pw->border, desk);
ecore_x_pointer_last_xy_get(&x, &y);
- x = x + zone->x;
- y = y + zone->y;
-
+
dx = (pw->border->w / 2);
dy = (pw->border->h / 2);
-
+
/* offset so that center of window is on mouse, but keep within desk bounds */
if (dx < x)
{
x -= dx;
- if ((pw->border->w < zone->w) && (x + pw->border->w > zone->x + zone->w))
- {
- x -= x + pw->border->w - (zone->x + zone->w);
- }
+ if ((pw->border->w < zone->w) &&
+ (x + pw->border->w > zone->x + zone->w))
+ x -= x + pw->border->w - (zone->x + zone->w);
}
else x = 0;
-
+
if (dy < y)
{
y -= dy;
- if ((pw->border->h < zone->h) && (y + pw->border->h > zone->y + zone->h))
- {
- y -= y + pw->border->h - (zone->y + zone->h);
- }
+ if ((pw->border->h < zone->h) &&
+ (y + pw->border->h > zone->y + zone->h))
+ y -= y + pw->border->h - (zone->y + zone->h);
}
else y = 0;
-
e_border_move(pw->border, x, y);
-
- }
- if (pw && pw->drag.from_face)
- {
- pw->drag.from_face->dragging = 0;
- }
-
-}
-
-static void
-_pager_desk_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- Evas_Event_Mouse_Wheel *ev;
- Evas_List *l;
- Pager_Desk *desk;
- Pager_Face *face;
-
- ev = event_info;
- desk = data;
- face = desk->face;
- l = face->desks;
-
- for (l = face->desks; l; l = l->next)
- {
- Pager_Desk *pd;
- pd = l->data;
- if (pd->current)
- {
- /* Mouse wheel up, scroll back through desks */
- if (ev->z < 0)
- {
- if (l->prev)
- {
- pd = l->prev->data;
- e_desk_show(pd->desk);
- }
- else
- {
- /* We've looped around, go to the last desk. Not sure if there's a better way. */
- Evas_List *l2;
- for (l2 = face->desks; l2->next; l2 = l2->next);
- pd = l2->data;
- e_desk_show(pd->desk);
- }
- }
- /* Mouse wheel down, scroll forward through desks */
- else if (ev->z > 0)
- {
- if (l->next)
- {
- pd = l->next->data;
- e_desk_show(pd->desk);
- }
- else
- {
- /* We've looped around, start back at the first desk */
- pd = face->desks->data;
- e_desk_show(pd->desk);
- }
- }
- break;
- }
}
+ if (pw && pw->drag.from_pager) pw->drag.from_pager->dragging = 0;
+ pw->drag.from_pager = NULL;
+ pw->drag.in_pager = 0;
+ pw->drag.start = 0;
}
-/*****/
static void
-_pager_face_cb_enter(void *data, const char *type, void *event_info)
+_pager_inst_cb_enter(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Enter *ev;
- Pager_Face *face;
+ Instance *inst;
ev = event_info;
- face = data;
+ inst = data;
}
static void
-_pager_face_cb_move(void *data, const char *type, void *event_info)
+_pager_inst_cb_move(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Move *ev;
- Pager_Face *face;
- Pager_Desk *pd;
- int x, y;
- double w, h;
+ Instance *inst;
+ Pager_Desk *pd, *pd2;
Evas_List *l;
+ int cx, cy, cw, ch;
ev = event_info;
- face = data;
-
- w = (face->fw - (face->inset.l + face->inset.r)) / (double) face->xnum;
- h = (face->fh - (face->inset.t + face->inset.b)) / (double) face->ynum;
-
- x = (ev->x - (face->fx + face->inset.l)) / w;
- y = (ev->y - (face->fy + face->inset.t)) / h;
-
- for (l = face->desks; l; l = l->next)
+ inst = data;
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ pd = _pager_desk_at_coord(inst->pager, ev->x - cx, ev->y - cy);
+ /* FIXME: keep track which one its over so we only emit drag in/out
+ * when it actually goes form one desk to another */
+ for (l = inst->pager->desks; l; l = l->next)
{
- pd = l->data;
- if ((pd->xpos == x) && (pd->ypos == y))
- edje_object_signal_emit(pd->desk_object, "drag", "in");
+ pd2 = l->data;
+ if (pd == pd2)
+ edje_object_signal_emit(pd2->o_desk, "drag", "in");
else
- edje_object_signal_emit(pd->desk_object, "drag", "out");
+ edje_object_signal_emit(pd2->o_desk, "drag", "out");
}
}
static void
-_pager_face_cb_leave(void *data, const char *type, void *event_info)
+_pager_inst_cb_leave(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Leave *ev;
- Pager_Face *face;
+ Instance *inst;
Evas_List *l;
ev = event_info;
- face = data;
-
- for (l = face->desks; l; l = l->next)
+ inst = data;
+ /* FIXME: keep track which one its over so we only emit drag in/out
+ * when it actually goes form one desk to another */
+ for (l = inst->pager->desks; l; l = l->next)
{
Pager_Desk *pd;
+
pd = l->data;
- edje_object_signal_emit(pd->desk_object, "drag", "out");
+ edje_object_signal_emit(pd->o_desk, "drag", "out");
}
}
static void
-_pager_face_cb_drop(void *data, const char *type, void *event_info)
+_pager_inst_cb_drop(void *data, const char *type, void *event_info)
{
E_Event_Dnd_Drop *ev;
- Pager_Face *face;
- Pager_Desk *desk;
- E_Border *bd;
+ Instance *inst;
+ Pager_Desk *pd;
+ E_Border *bd = NULL;
Evas_List *l;
int dx = 0, dy = 0;
+ int cx, cy, cw, ch;
+ Pager_Win *pw = NULL;
ev = event_info;
- face = data;
-
- /* XXX convert screen -> evas coords? */
- desk = _pager_face_desk_at_coord(face, ev->x, ev->y);
- if (desk)
+ inst = data;
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ pd = _pager_desk_at_coord(inst->pager, ev->x - cx, ev->y - cy);
+ if (pd)
{
if (!strcmp(type, "enlightenment/pager_win"))
{
- Pager_Win *pw;
pw = (Pager_Win *)(ev->data);
if (pw)
{
@@ -2140,133 +1506,277 @@ _pager_face_cb_drop(void *data, const char *type, void *event_info)
else if (!strcmp(type, "enlightenment/border"))
{
Evas_Coord wx, wy, wx2, wy2;
+
bd = ev->data;
- e_layout_coord_virtual_to_canvas(desk->layout_object, bd->x, bd->y, &wx, &wy);
- e_layout_coord_virtual_to_canvas(desk->layout_object, bd->x + bd->w, bd->y + bd->h, &wx2, &wy2);
+ e_layout_coord_virtual_to_canvas(pd->o_layout, bd->x, bd->y, &wx, &wy);
+ e_layout_coord_virtual_to_canvas(pd->o_layout, bd->x + bd->w, bd->y + bd->h, &wx2, &wy2);
dx = (wx - wx2) / 2;
dy = (wy - wy2) / 2;
}
else
- {
- return;
- }
+ return;
- if ((bd) && (desk))
+ if (bd)
{
Evas_Coord nx, ny;
- e_border_desk_set(bd, desk->desk);
- e_layout_coord_canvas_to_virtual(desk->layout_object, ev->x + dx, ev->y + dy, &nx, &ny);
-
- e_border_move(bd, nx + desk->desk->zone->x, ny + desk->desk->zone->y);
+
+ e_border_desk_set(bd, pd->desk);
+ if ((!pw) || ((pw) && (!pw->drag.no_place)))
+ {
+ e_layout_coord_canvas_to_virtual(pd->o_layout,
+ ev->x - cx + dx, ev->y - cy + dy,
+ &nx, &ny);
+ e_border_move(bd, nx + pd->desk->zone->x, ny + pd->desk->zone->y);
+ }
}
-
}
-
- for (l = face->desks; l; l = l->next)
- {
- Pager_Desk *pd;
- pd = l->data;
- edje_object_signal_emit(pd->desk_object, "drag", "out");
- }
+ /* FIXME: keep track which one its over so we only emit drag in/out
+ * when it actually goes form one desk to another */
+ for (l = inst->pager->desks; l; l = l->next)
+ {
+ pd = l->data;
+ edje_object_signal_emit(pd->o_desk, "drag", "out");
+ }
}
static void
-_pager_face_deskname_position_change(Pager_Face *face)
+_pager_desk_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- switch (face->pager->conf->deskname_pos)
+ Evas_Event_Mouse_Down *ev;
+ Pager_Desk *pd;
+
+ ev = event_info;
+ pd = data;
+ if (ev->button == 1)
{
- case PAGER_DESKNAME_NONE:
- edje_object_signal_emit(face->pager_object, "desktop_name,none", "");
- break;
- case PAGER_DESKNAME_TOP:
- edje_object_signal_emit(face->pager_object, "desktop_name,top", "");
- break;
- case PAGER_DESKNAME_BOTTOM:
- edje_object_signal_emit(face->pager_object, "desktop_name,bottom", "");
- break;
- case PAGER_DESKNAME_LEFT:
- edje_object_signal_emit(face->pager_object, "desktop_name,left", "");
- break;
- case PAGER_DESKNAME_RIGHT:
- edje_object_signal_emit(face->pager_object, "desktop_name,right", "");
- break;
}
}
static void
-_pager_menu_cb_aspect_keep_height(void *data, E_Menu *m, E_Menu_Item *mi)
+_pager_desk_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Pager *pager;
- Evas_List *l;
-
- pager = data;
+ Evas_Event_Mouse_Up *ev;
+ Pager_Desk *pd;
- for (l = pager->faces; l; l = l->next)
+ ev = event_info;
+ pd = data;
+ /* FIXME: pd->pager->dragging is 0 when finishing a drag from desk to desk */
+ if ((ev->button == 1) && (!pd->pager->dragging) &&
+ (!pd->pager->just_dragged))
{
- Pager_Face *face;
- int w, h;
-
- face = l->data;
-
- h = ((face->fh - (face->inset.t + face->inset.b)) / face->ynum);
+ e_desk_show(pd->desk);
+ }
+ pd->pager->just_dragged = 0;
+}
- w = h * face->zone->w / (double)face->zone->h;
- w *= face->xnum;
- w += (face->inset.l + face->inset.r);
+static void
+_pager_desk_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Move *ev;
+ Pager_Desk *pd;
- e_gadman_client_resize(face->gmc, w, face->fh);
- }
+ ev = event_info;
+ pd = data;
}
static void
-_pager_menu_cb_aspect_keep_width(void *data, E_Menu *m, E_Menu_Item *mi)
+_pager_desk_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Pager *pager;
+ Evas_Event_Mouse_Wheel *ev;
+ Pager_Desk *pd;
Evas_List *l;
- pager = data;
-
- for (l = pager->faces; l; l = l->next)
+ ev = event_info;
+ pd = data;
+ for (l = pd->pager->desks; l; l = l->next)
{
- Pager_Face *face;
- int w, h;
+ Pager_Desk *pd;
+
+ pd = l->data;
+ if (pd->current)
+ {
+ /* Mouse wheel up, scroll back through desks */
+ if (ev->z < 0)
+ {
+ if (l->prev)
+ {
+ pd = l->prev->data;
+ e_desk_show(pd->desk);
+ }
+ else
+ {
+ /* We've looped around, go to the last desk. Not sure if there's a better way. */
+ Evas_List *l2;
+
+ l2 =evas_list_last(pd->pager->desks);
+ if (l2)
+ {
+ pd = l2->data;
+ e_desk_show(pd->desk);
+ }
+ }
+ }
+ /* Mouse wheel down, scroll forward through desks */
+ else if (ev->z > 0)
+ {
+ if (l->next)
+ {
+ pd = l->next->data;
+ e_desk_show(pd->desk);
+ }
+ else
+ {
+ /* We've looped around, start back at the first desk */
+ pd = pd->pager->desks->data;
+ e_desk_show(pd->desk);
+ }
+ }
+ break;
+ }
+ }
+}
- face = l->data;
+static int
+_pager_popup_cb_timeout(void *data)
+{
+ Pager_Popup *pp;
+
+ pp = data;
+ _pager_popup_free(pp);
+ return 0;
+}
+
+/***************************************************************************/
+/**/
+/* module setup */
+EAPI E_Module_Api e_modapi =
+{
+ E_MODULE_API_VERSION,
+ "Pager"
+};
- w = ((face->fw - (face->inset.l + face->inset.r)) / face->xnum);
+EAPI void *
+e_modapi_init(E_Module *module)
+{
+ conf_edd = E_CONFIG_DD_NEW("Pager_Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+ E_CONFIG_VAL(D, T, popup_speed, DOUBLE);
+ E_CONFIG_VAL(D, T, popup, UINT);
+ E_CONFIG_VAL(D, T, drag_resist, UINT);
+ E_CONFIG_VAL(D, T, scale, UCHAR);
+ E_CONFIG_VAL(D, T, resize, UCHAR);
- h = w * face->zone->h / (double)face->zone->w;
- h *= face->ynum;
- h += (face->inset.t + face->inset.b);
+ pager_config = e_config_domain_load("module.pager", conf_edd);
- e_gadman_client_resize(face->gmc, face->fw, h);
+ if (!pager_config)
+ {
+ pager_config = E_NEW(Config, 1);
+ pager_config->popup_speed = 1.0;
+ pager_config->popup = 1;
+ pager_config->drag_resist = 3;
+ pager_config->scale = 1;
+ pager_config->resize = PAGER_RESIZE_BOTH;
}
+ E_CONFIG_LIMIT(pager_config->popup_speed, 0.1, 10.0);
+ E_CONFIG_LIMIT(pager_config->popup, 0, 1);
+ E_CONFIG_LIMIT(pager_config->drag_resist, 0, 50);
+ E_CONFIG_LIMIT(pager_config->scale, 0, 1);
+ E_CONFIG_LIMIT(pager_config->resize, PAGER_RESIZE_HORZ, PAGER_RESIZE_BOTH);
+
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_RESIZE, _pager_cb_event_border_resize, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_MOVE, _pager_cb_event_border_move, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_ADD, _pager_cb_event_border_add, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_REMOVE, _pager_cb_event_border_remove, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_ICONIFY, _pager_cb_event_border_iconify, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_UNICONIFY, _pager_cb_event_border_uniconify, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_STICK, _pager_cb_event_border_stick, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_UNSTICK, _pager_cb_event_border_unstick, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_DESK_SET, _pager_cb_event_border_desk_set, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_STACK, _pager_cb_event_border_stack, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_ICON_CHANGE, _pager_cb_event_border_icon_change, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_ZONE_DESK_COUNT_SET, _pager_cb_event_zone_desk_count_set, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_DESK_SHOW, _pager_cb_event_desk_show, NULL));
+ pager_config->handlers = evas_list_append
+ (pager_config->handlers, ecore_event_handler_add
+ (E_EVENT_DESK_NAME_CHANGE, _pager_cb_event_desk_name_change, NULL));
+
+ e_gadcon_provider_register(&_gadcon_class);
+ return 1;
}
-static void
-_pager_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
+EAPI int
+e_modapi_shutdown(E_Module *module)
{
- Pager *p;
+ e_gadcon_provider_unregister(&_gadcon_class);
+
+ if (pager_config->config_dialog)
+ e_object_del(E_OBJECT(pager_config->config_dialog));
+ while (pager_config->handlers)
+ {
+ ecore_event_handler_del(pager_config->handlers->data);
+ pager_config->handlers = evas_list_remove_list(pager_config->handlers, pager_config->handlers);
+ }
- p = data;
- if (!p) return;
- _config_pager_module(e_container_current_get(e_manager_current_get()), p);
+ if (pager_config->menu) e_object_del(E_OBJECT(pager_config->menu));
+ free(pager_config);
+ pager_config = NULL;
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
}
-void
-_pager_cb_config_updated(void *data)
+EAPI int
+e_modapi_save(E_Module *module)
{
- Pager *pager;
- Evas_List *l;
+ e_config_domain_save("module.pager", conf_edd, pager_config);
+ return 1;
+}
- /* Handle Desktop Name Position Change */
- pager = data;
- for (l = pager->faces; l; l = l->next)
- {
- Pager_Face *face;
+EAPI int
+e_modapi_info(E_Module *module)
+{
+ char buf[4096];
- face = l->data;
- _pager_face_deskname_position_change(face);
- }
+ snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(module));
+ module->icon_file = strdup(buf);
+ return 1;
+}
+
+EAPI int
+e_modapi_about(E_Module *module)
+{
+ e_module_dialog_show(_("Enlightenment Pager Module"),
+ _("A pager module to navigate virtual desktops."));
+ return 1;
}
+/**/
+/***************************************************************************/
diff --git a/src/modules/pager/e_mod_main.h b/src/modules/pager/e_mod_main.h
index b04b8f0e9..fa0584712 100644
--- a/src/modules/pager/e_mod_main.h
+++ b/src/modules/pager/e_mod_main.h
@@ -5,12 +5,7 @@
#define E_MOD_MAIN_H
typedef struct _Config Config;
-typedef struct _Config_Face Config_Face;
-typedef struct _Pager Pager;
-typedef struct _Pager_Face Pager_Face;
-typedef struct _Pager_Desk Pager_Desk;
-typedef struct _Pager_Win Pager_Win;
-typedef struct _Pager_Popup Pager_Popup;
+typedef struct _Config_Item Config_Item;
#define PAGER_RESIZE_NONE 0
#define PAGER_RESIZE_HORZ 1
@@ -25,125 +20,24 @@ typedef struct _Pager_Popup Pager_Popup;
struct _Config
{
- Evas_List *faces;
- /* Position of desktop name */
- unsigned int deskname_pos;
- /* How the popup is shown on desk change */
- double popup_speed;
- /* Show popup? */
- unsigned int popup;
-
- unsigned int drag_resist;
-};
-
-struct _Config_Face
-{
- /* Show face */
- unsigned char enabled;
- /* Keep scale of desktops */
- unsigned char scale;
- /* Resize pager when adding/removing desktops */
- unsigned char resize;
-};
-
-struct _Pager
-{
- Evas_List *faces;
- E_Menu *config_menu;
- E_Menu *config_menu_deskname;
- E_Menu *config_menu_speed;
- Evas_List *menus;
-
- Config *conf;
-
- Ecore_Event_Handler *ev_handler_border_resize;
- Ecore_Event_Handler *ev_handler_border_move;
- Ecore_Event_Handler *ev_handler_border_add;
- Ecore_Event_Handler *ev_handler_border_remove;
- Ecore_Event_Handler *ev_handler_border_iconify;
- Ecore_Event_Handler *ev_handler_border_uniconify;
- Ecore_Event_Handler *ev_handler_border_stick;
- Ecore_Event_Handler *ev_handler_border_unstick;
- Ecore_Event_Handler *ev_handler_border_desk_set;
- Ecore_Event_Handler *ev_handler_border_stack;
- Ecore_Event_Handler *ev_handler_border_icon_change;
- Ecore_Event_Handler *ev_handler_zone_desk_count_set;
- Ecore_Event_Handler *ev_handler_desk_show;
- Ecore_Event_Handler *ev_handler_desk_name_change;
-
+ /* saved * loaded config values */
+ double popup_speed;
+ unsigned int popup;
+ unsigned int drag_resist;
+ unsigned char scale;
+ unsigned char resize;
+ Evas_List *items; /* FIXME: save/load this */
+ /* just config state */
E_Config_Dialog *config_dialog;
-};
-
-struct _Pager_Face
-{
- Pager *pager;
- E_Gadman_Client *gmc;
+ Evas_List *instances;
E_Menu *menu;
- Evas *evas;
-
- E_Zone *zone;
- Evas_List *desks;
-
- Evas_Object *pager_object;
- Evas_Object *table_object;
-
- Evas_Coord fx, fy, fw, fh;
- struct {
- Evas_Coord l, r, t, b;
- } inset;
-
- /* Current nr. of desktops */
- int xnum, ynum;
-
- Config_Face *conf;
-
- E_Drop_Handler *drop_handler;
-
- Pager_Popup *current_popup;
-
- unsigned char dragging:1;
-};
-
-struct _Pager_Desk
-{
- E_Desk *desk;
- Pager_Face *face;
- Evas_List *wins;
-
- Evas_Object *desk_object;
- Evas_Object *layout_object;
- Evas_Object *event_object;
-
- int xpos, ypos;
-
- int current : 1;
-};
-
-struct _Pager_Win
-{
- E_Border *border;
- Pager_Desk *desk;
-
- Evas_Object *window_object;
- Evas_Object *icon_object;
- Evas_Object *event_object;
-
- struct {
- Pager_Face *from_face;
- unsigned char start : 1;
- unsigned char in_pager : 1;
- unsigned char dnd : 1;
- int x, y;
- int dx, dy;
- } drag;
+ Evas_List *handlers;
};
-struct _Pager_Popup
+struct _Config_Item
{
- E_Popup *popup;
- Pager_Face *src_face, *face;
- Evas_Object *bg_object;
- Ecore_Timer *timer;
+ char *id;
+ int zone_num;
};
EAPI extern E_Module_Api e_modapi;
@@ -153,8 +47,9 @@ EAPI int e_modapi_shutdown (E_Module *module);
EAPI int e_modapi_save (E_Module *module);
EAPI int e_modapi_info (E_Module *module);
EAPI int e_modapi_about (E_Module *module);
-EAPI int e_modapi_config (E_Module *module);
-void _pager_cb_config_updated(void *data);
+void _pager_cb_config_updated(void);
+void _config_pager_module(Config_Item *ci);
+extern Config *pager_config;
#endif
diff --git a/src/modules/start/e_mod_main.c b/src/modules/start/e_mod_main.c
index cbe5ecf7d..e5b5bee99 100644
--- a/src/modules/start/e_mod_main.c
+++ b/src/modules/start/e_mod_main.c
@@ -45,7 +45,6 @@ _gc_init(E_Gadcon *gc, char *name, char *id, char *style)
E_Gadcon_Client *gcc;
Instance *inst;
- printf("CREATE START GADCON %s %s\n", name, id);
inst = E_NEW(Instance, 1);
o = edje_object_add(gc->evas);
@@ -59,13 +58,10 @@ _gc_init(E_Gadcon *gc, char *name, char *id, char *style)
inst->o_button = o;
inst->main_menu = NULL;
+ e_gadcon_client_util_menu_attach(gcc);
+
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_button_cb_mouse_down, inst);
- /* FIXME: add callback to resize - and based off one dimension, request
- * another to be the same */
- e_gadcon_client_size_request(gcc, 32, 32);
- e_gadcon_client_min_size_set(gcc, 16, 16);
- e_gadcon_client_aspect_set(gcc, 1, 1);
return gcc;
}
@@ -75,6 +71,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
Instance *inst;
inst = gcc->data;
+ evas_object_del(inst->o_button);
free(inst);
}
@@ -84,9 +81,8 @@ _gc_orient(E_Gadcon_Client *gcc)
Instance *inst;
inst = gcc->data;
- printf("OREINT to %i\n", gcc->gadcon->orient);
- e_gadcon_client_aspect_set(gcc, 20, 20);
- e_gadcon_client_min_size_set(gcc, 20, 20);
+ e_gadcon_client_aspect_set(gcc, 16, 16);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
/**/
/***************************************************************************/
@@ -105,15 +101,12 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Coord x, y, w, h;
int cx, cy, cw, ch;
- E_Zone *zone;
evas_object_geometry_get(inst->o_button, &x, &y, &w, &h);
- e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &cx, &cy, &cw, &ch);
x += cx;
y += cy;
- zone = e_gadcon_zone_get(inst->gcc->gadcon);
- if (!zone)
- zone = e_util_zone_current_get(e_manager_current_get());
if (!inst->main_menu)
inst->main_menu = e_int_menus_main_new();
if (inst->main_menu)
@@ -152,7 +145,8 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
x, y, w, h,
dir, ev->timestamp);
edje_object_signal_emit(inst->o_button, "active", "");
- evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
}
}
@@ -184,7 +178,7 @@ EAPI void *
e_modapi_init(E_Module *m)
{
e_gadcon_provider_register(&_gadcon_class);
- return NULL;
+ return 1;
}
EAPI int
@@ -217,11 +211,5 @@ e_modapi_about(E_Module *m)
_("Experimental Button module for E17"));
return 1;
}
-
-int
-e_modapi_config(E_Module *m)
-{
- return 0;
-}
/**/
/***************************************************************************/
diff --git a/src/modules/start/e_mod_main.h b/src/modules/start/e_mod_main.h
index 4e5acc824..f00a37985 100644
--- a/src/modules/start/e_mod_main.h
+++ b/src/modules/start/e_mod_main.h
@@ -1,7 +1,9 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
-/* standard module api calls e looks for */
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *m);
diff --git a/src/modules/temperature/Makefile.am b/src/modules/temperature/Makefile.am
index 1d6544048..f0a8236d9 100644
--- a/src/modules/temperature/Makefile.am
+++ b/src/modules/temperature/Makefile.am
@@ -20,8 +20,7 @@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
- e_mod_config.c \
- e_mod_config.h
+ e_mod_config.c
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
diff --git a/src/modules/temperature/e_mod_config.c b/src/modules/temperature/e_mod_config.c
index 0abde2aa7..c35a0be4d 100644
--- a/src/modules/temperature/e_mod_config.c
+++ b/src/modules/temperature/e_mod_config.c
@@ -3,8 +3,6 @@
*/
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
/* celsius */
#define TEMP_LOW_LOW 32
@@ -42,7 +40,7 @@ static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas,
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
void
-_config_temperature_module(E_Container *con, Temperature *temp)
+_config_temperature_module(void)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
@@ -56,22 +54,23 @@ _config_temperature_module(E_Container *con, Temperature *temp)
v->advanced.apply_cfdata = _advanced_apply_data;
v->advanced.create_widgets = _advanced_create_widgets;
- cfd = e_config_dialog_new(con, _("Temperature Configuration"), NULL, 0, v, temp);
- temp->config_dialog = cfd;
+ cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
+ _("Temperature Configuration"), NULL, 0, v, NULL);
+ temperature_config->config_dialog = cfd;
}
static void
-_fill_data(Temperature *t, E_Config_Dialog_Data *cfdata)
+_fill_data(E_Config_Dialog_Data *cfdata)
{
double p;
- cfdata->units = t->conf->units;
- if (t->conf->units == CELCIUS)
+ cfdata->units = temperature_config->units;
+ if (temperature_config->units == CELCIUS)
cfdata->unit_method = 0;
else
cfdata->unit_method = 1;
- p = t->conf->poll_time;
+ p = temperature_config->poll_time;
cfdata->poll_time = p;
if ((p >= 0) && (p <= 5))
cfdata->poll_method = 1; //Fast
@@ -82,7 +81,7 @@ _fill_data(Temperature *t, E_Config_Dialog_Data *cfdata)
else if (p > 30)
cfdata->poll_method = 60; //Very Slow
- p = t->conf->low;
+ p = temperature_config->low;
if (cfdata->units == FAHRENHEIT)
p = FAR_2_CEL(p - 1); // -1 so the conversion doesn't make mid go hi
cfdata->low_temp = p;
@@ -93,7 +92,7 @@ _fill_data(Temperature *t, E_Config_Dialog_Data *cfdata)
else if (p > TEMP_LOW_MID)
cfdata->low_method = TEMP_LOW_HIGH;
- p = t->conf->high;
+ p = temperature_config->high;
if (cfdata->units == FAHRENHEIT)
p = FAR_2_CEL(p - 1);
cfdata->high_temp = p;
@@ -104,11 +103,11 @@ _fill_data(Temperature *t, E_Config_Dialog_Data *cfdata)
else if (p > TEMP_HIGH_MID)
cfdata->high_method = TEMP_HIGH_HIGH;
- if (!strcmp(t->conf->sensor_name, "temp1"))
+ if (!strcmp(temperature_config->sensor_name, "temp1"))
cfdata->sensor = 0;
- else if (!strcmp(t->conf->sensor_name, "temp2"))
+ else if (!strcmp(temperature_config->sensor_name, "temp2"))
cfdata->sensor = 1;
- else if (!strcmp(t->conf->sensor_name, "temp3"))
+ else if (!strcmp(temperature_config->sensor_name, "temp3"))
cfdata->sensor = 2;
}
@@ -116,21 +115,16 @@ static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
- Temperature *t;
- t = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
- _fill_data(t, cfdata);
+ _fill_data(cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Temperature *t;
-
- t = cfd->data;
- t->config_dialog = NULL;
+ temperature_config->config_dialog = NULL;
free(cfdata);
}
@@ -217,33 +211,23 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Temperature *t;
-
- t = cfd->data;
- e_border_button_bindings_ungrab_all();
if (cfdata->unit_method == 0)
- t->conf->units = CELCIUS;
+ temperature_config->units = CELCIUS;
else
- t->conf->units = FAHRENHEIT;
-
- t->conf->poll_time = (double)cfdata->poll_method;
-
- if (t->conf->units == FAHRENHEIT)
+ temperature_config->units = FAHRENHEIT;
+ temperature_config->poll_time = (double)cfdata->poll_method;
+ if (temperature_config->units == FAHRENHEIT)
{
- t->conf->low = CEL_2_FAR(cfdata->low_method);
- t->conf->high = CEL_2_FAR(cfdata->high_method);
+ temperature_config->low = CEL_2_FAR(cfdata->low_method);
+ temperature_config->high = CEL_2_FAR(cfdata->high_method);
}
else
{
- t->conf->low = cfdata->low_method;
- t->conf->high = cfdata->high_method;
+ temperature_config->low = cfdata->low_method;
+ temperature_config->high = cfdata->high_method;
}
-
- e_border_button_bindings_grab_all();
+ _temperature_face_cb_config_updated();
e_config_save_queue();
-
- /* Call Config Update */
- _temperature_face_cb_config_updated(t);
return 1;
}
@@ -252,9 +236,6 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
{
Evas_Object *o, *of, *ob;
E_Radio_Group *rg;
- Temperature *t;
-
- t = cfd->data;
o = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, _("Display Units"), 0);
@@ -312,10 +293,10 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
- cfdata->low_temp = t->conf->low;
- cfdata->high_temp = t->conf->high;
+// cfdata->low_temp = temperature_config->low;
+// cfdata->high_temp = temperature_config->high;
- if (t->conf->units == FAHRENHEIT)
+ if (cfdata->units == FAHRENHEIT)
{
/* round-off to closest 5 */
if (cfdata->high_temp % 5 > 3)
@@ -357,14 +338,7 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
static int
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- Temperature *t;
-
- t = cfd->data;
-
- e_border_button_bindings_ungrab_all();
-
- /* Check if Display Units has been toggled */
- if (cfdata->unit_method != t->conf->units)
+ if (cfdata->unit_method != temperature_config->units)
{
if (cfdata->unit_method == 0)
{
@@ -377,35 +351,29 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
cfdata->low_temp = CEL_2_FAR(cfdata->low_temp);
}
}
-
if (cfdata->unit_method == 0)
- t->conf->units = CELCIUS;
+ temperature_config->units = CELCIUS;
else
- t->conf->units = FAHRENHEIT;
-
- t->conf->poll_time = cfdata->poll_time;
-
- t->conf->low = cfdata->low_temp;
- t->conf->high = cfdata->high_temp;
-
+ temperature_config->units = FAHRENHEIT;
+ temperature_config->poll_time = cfdata->poll_time;
+ temperature_config->low = cfdata->low_temp;
+ temperature_config->high = cfdata->high_temp;
+ if (temperature_config->sensor_name)
+ evas_stringshare_del(temperature_config->sensor_name);
+ temperature_config->sensor_name = NULL;
switch (cfdata->sensor)
{
case 0:
- t->conf->sensor_name = strdup("temp1");
+ temperature_config->sensor_name = evas_stringshare_add("temp1");
break;
case 1:
- t->conf->sensor_name = strdup("temp2");
+ temperature_config->sensor_name = evas_stringshare_add("temp2");
break;
case 2:
- t->conf->sensor_name = strdup("temp3");
+ temperature_config->sensor_name = evas_stringshare_add("temp3");
break;
}
-
- e_border_button_bindings_grab_all();
+ _temperature_face_cb_config_updated();
e_config_save_queue();
-
- /* Call Config Update */
- _temperature_face_cb_config_updated(t);
-
return 1;
}
diff --git a/src/modules/temperature/e_mod_config.h b/src/modules/temperature/e_mod_config.h
deleted file mode 100644
index 22b42db6d..000000000
--- a/src/modules/temperature/e_mod_config.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifdef E_TYPEDEFS
-#else
-#ifndef E_MOD_CONFIG_H
-#define E_MOD_CONFIG_H
-#include "e_mod_main.h"
-void _config_temperature_module(E_Container *con, Temperature *temp);
-#endif
-#endif
diff --git a/src/modules/temperature/e_mod_main.c b/src/modules/temperature/e_mod_main.c
index 1ad5a57da..9cde248f0 100644
--- a/src/modules/temperature/e_mod_main.c
+++ b/src/modules/temperature/e_mod_main.c
@@ -3,255 +3,153 @@
*/
#include "e.h"
#include "e_mod_main.h"
-#include "e_mod_config.h"
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
-/* TODO List:
- *
- * which options should be in main menu, and which in face menu?
- */
-
-/* module private routines */
-static Temperature *_temperature_new();
-static void _temperature_free(Temperature *e);
-static int _temperature_cb_check(void *data);
-
-static void _temperature_face_init(void *data, E_Gadget_Face *face);
-static void _temperature_face_free(void *data, E_Gadget_Face *face);
-
-static void _temperature_face_level_set(E_Gadget_Face *face, double level);
-
-static E_Config_DD *conf_edd;
-static E_Config_DD *conf_face_edd;
-
-/* public module routines. all modules must have these */
-EAPI E_Module_Api e_modapi =
+/***************************************************************************/
+/**/
+/* gadcon requirements */
+static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
+static void _gc_shutdown(E_Gadcon_Client *gcc);
+static void _gc_orient(E_Gadcon_Client *gcc);
+/* and actually define the gadcon class that this module provides (just 1) */
+static const E_Gadcon_Client_Class _gadcon_class =
{
- E_MODULE_API_VERSION,
- "Temperature"
+ GADCON_CLIENT_CLASS_VERSION,
+ "temperature",
+ {
+ _gc_init, _gc_shutdown, _gc_orient
+ }
};
+/**/
+/***************************************************************************/
-EAPI void *
-e_modapi_init(E_Module *m)
-{
- E_Gadget *gad = NULL;
- E_Gadget_Api *api;
- Temperature *e;
-
- e = _temperature_new();
-
- /* set up our actual gadget */
- api = E_NEW(E_Gadget_Api, 1);
- api->module = m;
- api->name = "temperature";
- api->func_face_init = _temperature_face_init;
- api->func_face_free = _temperature_face_free;
- api->data = e;
-
- gad = e_gadget_new(api);
- E_FREE(api);
-
- /* start the timer */
- e->gad = gad;
- e->temperature_check_timer = ecore_timer_add(e->conf->poll_time, _temperature_cb_check, gad);
- return gad;
-}
-
-EAPI int
-e_modapi_shutdown(E_Module *m)
-{
- E_Gadget *gad;
- Temperature *e;
+/***************************************************************************/
+/**/
+/* actual module specifics */
- E_CONFIG_DD_FREE(conf_edd);
- E_CONFIG_DD_FREE(conf_face_edd);
+typedef struct _Instance Instance;
- gad = m->data;
- if (!gad) return 0;
- e = gad->data;
- if (e)
- {
- if (e->config_dialog)
- {
- e_object_del(E_OBJECT(e->config_dialog));
- e->config_dialog = NULL;
- }
- _temperature_free(e);
- }
- e_object_del(E_OBJECT(gad));
- return 1;
-}
-
-EAPI int
-e_modapi_save(E_Module *m)
+struct _Instance
{
- E_Gadget *gad;
- Temperature *e;
-
- gad = m->data;
- if (!gad) return 0;
- e = gad->data;
- if (!e) return 0;
- e_config_domain_save("module.temperature", conf_edd, e->conf);
- return 1;
-}
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_temp;
+};
-EAPI int
-e_modapi_info(E_Module *m)
-{
- char buf[4096];
+static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _menu_cb_post(void *data, E_Menu *m);
+static int _temperature_cb_check(void *data);
+static void _temperature_face_level_set(Instance *inst, double level);
+static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
- snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
- m->icon_file = strdup(buf);
- return 1;
-}
+static E_Config_DD *conf_edd = NULL;
-EAPI int
-e_modapi_about(E_Module *m)
-{
- e_module_dialog_show(_("Enlightenment Temperature Module"),
- _("A module to measure the <hilight>ACPI Thermal sensor</hilight> on Linux.<br>"
- "It is especially useful for modern Laptops with high speed<br>"
- "CPUs that generate a lot of heat."));
- return 1;
-}
+Config *temperature_config = NULL;
-EAPI int
-e_modapi_config(E_Module *m)
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
{
- E_Gadget *gad;
- Temperature *e;
+ Evas_Object *o;
+ E_Gadcon_Client *gcc;
+ Instance *inst;
- gad = m->data;
- if (!gad) return 0;
- e = gad->data;
- _config_temperature_module(e_container_current_get(e_manager_current_get()), e);
-
- return 1;
+ inst = E_NEW(Instance, 1);
+
+ o = edje_object_add(gc->evas);
+ e_theme_edje_object_set(o, "base/theme/modules/temperature",
+ "modules/temperature/main");
+
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+
+ inst->gcc = gcc;
+ inst->o_temp = o;
+
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
+ _button_cb_mouse_down, inst);
+ temperature_config->instances = evas_list_append(temperature_config->instances, inst);
+ temperature_config->have_temp = -1;
+ _temperature_cb_check(NULL);
+ return gcc;
}
-
-
-/* module private routines */
-static Temperature *
-_temperature_new()
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
{
- Temperature *e;
-
- e = E_NEW(Temperature, 1);
- if (!e) return NULL;
-
- /* create the config edd */
- conf_face_edd = E_CONFIG_DD_NEW("Temperature_Config_Face", Config_Face);
-#undef T
-#undef D
-#define T Config_Face
-#define D conf_face_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
-
- conf_edd = E_CONFIG_DD_NEW("Temperature_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D conf_edd
- E_CONFIG_VAL(D, T, poll_time, DOUBLE);
- E_CONFIG_VAL(D, T, low, INT);
- E_CONFIG_VAL(D, T, high, INT);
- E_CONFIG_LIST(D, T, faces, conf_face_edd);
- E_CONFIG_VAL(D, T, sensor_name, STR);
- E_CONFIG_VAL(D, T, units, INT);
-
- e->conf = e_config_domain_load("module.temperature", conf_edd);
- if (!e->conf)
- {
- e->conf = E_NEW(Config, 1);
- e->conf->poll_time = 10.0;
- e->conf->low = 30;
- e->conf->high = 80;
- e->conf->sensor_name = "temp1";
- e->conf->units = CELCIUS;
- }
- E_CONFIG_LIMIT(e->conf->poll_time, 0.5, 1000.0);
- E_CONFIG_LIMIT(e->conf->low, 0, 100);
- E_CONFIG_LIMIT(e->conf->high, 0, 220);
- E_CONFIG_LIMIT(e->conf->units, CELCIUS, FAHRENHEIT);
-
- e->have_temp = -1;
-
- return e;
+ Instance *inst;
+
+ inst = gcc->data;
+ temperature_config->instances = evas_list_remove(temperature_config->instances, inst);
+ evas_object_del(inst->o_temp);
+ free(inst);
}
-void _temperature_face_init(void *data, E_Gadget_Face *face)
+static void
+_gc_orient(E_Gadcon_Client *gcc)
{
- Temperature *e;
- Temperature_Face *ef;
- E_Gadman_Policy policy;
-
- e = data;
-
- ef = E_NEW(Temperature_Face, 1);
- if (!ef) return;
-
- e_gadget_face_theme_set(face, "base/theme/modules/temperature",
- "modules/temperature/main");
-
- policy = E_GADMAN_POLICY_ANYWHERE |
- E_GADMAN_POLICY_HMOVE |
- E_GADMAN_POLICY_VMOVE |
- E_GADMAN_POLICY_HSIZE |
- E_GADMAN_POLICY_VSIZE;
-
- e_gadman_client_policy_set(face->gmc, policy);
-
- ef->conf = evas_list_nth(e->conf->faces, face->face_num);
- if (!ef->conf)
- {
- ef->conf = E_NEW(Config_Face, 1);
- ef->conf->enabled = 1;
- e->conf->faces = evas_list_append(e->conf->faces, ef->conf);
- }
-
- face->data = ef;
-
- _temperature_cb_check(face->gad);
-
- return;
+ Instance *inst;
+
+ inst = gcc->data;
+ e_gadcon_client_aspect_set(gcc, 16, 16);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
+/**/
+/***************************************************************************/
+/***************************************************************************/
+/**/
static void
-_temperature_free(Temperature *e)
+_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Evas_List *l;
-
- ecore_timer_del(e->temperature_check_timer);
-
- for (l = e->conf->faces; l; l = l->next)
- free(l->data);
- evas_list_free(e->conf->faces);
- free(e->conf);
- free(e);
+ Instance *inst;
+ Evas_Event_Mouse_Down *ev;
+
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!temperature_config->menu))
+ {
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int cx, cy, cw, ch;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _menu_cb_post, inst);
+ temperature_config->menu = mn;
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Configuration"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
+ e_menu_item_callback_set(mi, _temperature_face_cb_menu_configure, NULL);
+
+ e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &cx, &cy, &cw, &ch);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ cx + ev->output.x, cy + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ }
}
static void
-_temperature_face_free(void *data, E_Gadget_Face *face)
+_menu_cb_post(void *data, E_Menu *m)
{
- Temperature_Face *ef;
- ef = face->data;
-
- free(ef);
+ if (!temperature_config->menu) return;
+ e_object_del(E_OBJECT(temperature_config->menu));
+ temperature_config->menu = NULL;
}
static int
_temperature_cb_check(void *data)
{
- E_Gadget *gad;
- E_Gadget_Face *face;
- Temperature *t;
int ret = 0;
+ Instance *inst;
Ecore_List *therms;
Evas_List *l;
int temp = 0;
@@ -261,11 +159,6 @@ _temperature_cb_check(void *data)
int len;
#endif
- gad = data;
- if (!gad) return 0;
- t = gad->data;
- if (!t) return 0;
-
#ifdef __FreeBSD__
if (mib[0] == -1)
{
@@ -305,7 +198,7 @@ _temperature_cb_check(void *data)
{
char *name, *sensor;
- sensor = t->conf->sensor_name;
+ sensor = temperature_config->sensor_name;
if (!sensor) sensor = "temp1";
while ((name = ecore_list_next(therms)))
@@ -370,77 +263,183 @@ _temperature_cb_check(void *data)
}
#endif
- if (t->conf->units == FAHRENHEIT)
- temp = (temp * 9.0 / 5.0) + 32;
+ if (temperature_config->units == FAHRENHEIT)
+ temp = (temp * 9.0 / 5.0) + 32;
if (ret)
{
char *utf8;
- if (t->have_temp != 1)
+ if (temperature_config->have_temp != 1)
{
/* enable therm object */
- for (l = gad->faces; l; l = l->next)
+ for (l = temperature_config->instances; l; l = l->next)
{
- face = l->data;
- edje_object_signal_emit(face->main_obj, "known", "");
+ inst = l->data;
+ edje_object_signal_emit(inst->o_temp, "known", "");
}
- t->have_temp = 1;
+ temperature_config->have_temp = 1;
}
- if (t->conf->units == FAHRENHEIT)
+ if (temperature_config->units == FAHRENHEIT)
snprintf(buf, sizeof(buf), "%iF", temp);
else
snprintf(buf, sizeof(buf), "%iC", temp);
utf8 = ecore_txt_convert("iso-8859-1", "utf-8", buf);
- for (l = gad->faces; l; l = l->next)
+ for (l = temperature_config->instances; l; l = l->next)
{
- face = l->data;
- _temperature_face_level_set(face,
- (double)(temp - t->conf->low) /
- (double)(t->conf->high - t->conf->low));
-
- edje_object_part_text_set(face->main_obj, "reading", utf8);
+ inst = l->data;
+ _temperature_face_level_set(inst,
+ (double)(temp - temperature_config->low) /
+ (double)(temperature_config->high - temperature_config->low));
+ edje_object_part_text_set(inst->o_temp, "reading", utf8);
}
free(utf8);
}
else
{
- if (t->have_temp != 0)
+ if (temperature_config->have_temp != 0)
{
/* disable therm object */
- for (l = gad->faces; l; l = l->next)
-
+ for (l = temperature_config->instances; l; l = l->next)
{
- face = l->data;
- edje_object_signal_emit(face->main_obj, "unknown", "");
- edje_object_part_text_set(face->main_obj, "reading", "NO TEMP");
- _temperature_face_level_set(face, 0.5);
+ inst = l->data;
+ edje_object_signal_emit(inst->o_temp, "unknown", "");
+ edje_object_part_text_set(inst->o_temp, "reading", "NO TEMP");
+ _temperature_face_level_set(inst, 0.5);
}
- t->have_temp = 0;
+ temperature_config->have_temp = 0;
}
}
return 1;
}
static void
-_temperature_face_level_set(E_Gadget_Face *face, double level)
+_temperature_face_level_set(Instance *inst, double level)
{
Edje_Message_Float msg;
if (level < 0.0) level = 0.0;
else if (level > 1.0) level = 1.0;
msg.val = level;
- edje_object_message_send(face->main_obj, EDJE_MESSAGE_FLOAT, 1, &msg);
+ edje_object_message_send(inst->o_temp, EDJE_MESSAGE_FLOAT, 1, &msg);
+}
+
+static void
+_temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ if (!temperature_config) return;
+ if (temperature_config->config_dialog) return;
+ _config_temperature_module();
}
void
-_temperature_face_cb_config_updated(Temperature *temp)
+_temperature_face_cb_config_updated(void)
+{
+ ecore_timer_del(temperature_config->temperature_check_timer);
+ temperature_config->temperature_check_timer =
+ ecore_timer_add(temperature_config->poll_time, _temperature_cb_check,
+ NULL);
+}
+
+/***************************************************************************/
+/**/
+/* module setup */
+EAPI E_Module_Api e_modapi =
+{
+ E_MODULE_API_VERSION,
+ "Temperature"
+};
+
+EAPI void *
+e_modapi_init(E_Module *m)
+{
+ conf_edd = E_CONFIG_DD_NEW("Temperature_Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+ E_CONFIG_VAL(D, T, poll_time, DOUBLE);
+ E_CONFIG_VAL(D, T, low, INT);
+ E_CONFIG_VAL(D, T, high, INT);
+ E_CONFIG_VAL(D, T, sensor_name, STR);
+ E_CONFIG_VAL(D, T, units, INT);
+
+ temperature_config = e_config_domain_load("module.temperature", conf_edd);
+ if (!temperature_config)
+ {
+ temperature_config = E_NEW(Config, 1);
+ temperature_config->poll_time = 10.0;
+ temperature_config->low = 30;
+ temperature_config->high = 80;
+ temperature_config->sensor_name = evas_stringshare_add("temp1");
+ temperature_config->units = CELCIUS;
+ }
+ E_CONFIG_LIMIT(temperature_config->poll_time, 0.5, 1000.0);
+ E_CONFIG_LIMIT(temperature_config->low, 0, 100);
+ E_CONFIG_LIMIT(temperature_config->high, 0, 220);
+ E_CONFIG_LIMIT(temperature_config->units, CELCIUS, FAHRENHEIT);
+
+ temperature_config->have_temp = -1;
+ temperature_config->temperature_check_timer =
+ ecore_timer_add(temperature_config->poll_time, _temperature_cb_check,
+ NULL);
+ e_gadcon_provider_register(&_gadcon_class);
+ return 1;
+}
+
+EAPI int
+e_modapi_shutdown(E_Module *m)
{
- /* Call all funcs needed to handle update */
- ecore_timer_del(temp->temperature_check_timer);
- temp->temperature_check_timer = ecore_timer_add(temp->conf->poll_time, _temperature_cb_check, temp->gad);
+ e_gadcon_provider_unregister(&_gadcon_class);
+ if (temperature_config->config_dialog)
+ e_object_del(E_OBJECT(temperature_config->config_dialog));
+ if (temperature_config->temperature_check_timer)
+ ecore_timer_del(temperature_config->temperature_check_timer);
+ if (temperature_config->sensor_name)
+ evas_stringshare_del(temperature_config->sensor_name);
+ free(temperature_config);
+ temperature_config = NULL;
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
+}
+
+EAPI int
+e_modapi_save(E_Module *m)
+{
+ e_config_domain_save("module.temperature", conf_edd, temperature_config);
+ return 1;
+}
+
+EAPI int
+e_modapi_info(E_Module *m)
+{
+ char buf[4096];
+
+ snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
+ m->icon_file = strdup(buf);
+ return 1;
}
+EAPI int
+e_modapi_about(E_Module *m)
+{
+ e_module_dialog_show(_("Enlightenment Temperature Module"),
+ _("A module to measure the <hilight>ACPI Thermal sensor</hilight> on Linux.<br>"
+ "It is especially useful for modern Laptops with high speed<br>"
+ "CPUs that generate a lot of heat."));
+ return 1;
+}
+
+EAPI int
+e_modapi_config(E_Module *m)
+{
+ if (!temperature_config) return 0;
+ if (temperature_config->config_dialog) return 0;
+ _config_temperature_module();
+ return 1;
+}
+/**/
+/***************************************************************************/
diff --git a/src/modules/temperature/e_mod_main.h b/src/modules/temperature/e_mod_main.h
index b766f16bf..187125c9c 100644
--- a/src/modules/temperature/e_mod_main.h
+++ b/src/modules/temperature/e_mod_main.h
@@ -5,9 +5,6 @@
#define E_MOD_MAIN_H
typedef struct _Config Config;
-typedef struct _Config_Face Config_Face;
-typedef struct _Temperature Temperature;
-typedef struct _Temperature_Face Temperature_Face;
typedef enum _Unit
{
@@ -17,32 +14,17 @@ typedef enum _Unit
struct _Config
{
- double poll_time;
- int low, high;
- Evas_List *faces;
- char *sensor_name;
- Unit units;
-};
-
-struct _Config_Face
-{
- unsigned char enabled;
-};
-
-struct _Temperature
-{
- Config *conf;
- Ecore_Timer *temperature_check_timer;
- E_Config_Dialog *config_dialog;
+ /* saved * loaded config values */
+ double poll_time;
+ int low, high;
+ char *sensor_name;
+ Unit units;
+ /* just config state */
+ E_Config_Dialog *config_dialog;
+ Evas_List *instances;
+ E_Menu *menu;
+ Ecore_Timer *temperature_check_timer;
unsigned char have_temp;
- E_Gadget *gad;
-};
-
-struct _Temperature_Face
-{
- Temperature *temp;
- Config_Face *conf;
-
};
EAPI extern E_Module_Api e_modapi;
@@ -54,6 +36,9 @@ EAPI int e_modapi_info (E_Module *m);
EAPI int e_modapi_about (E_Module *m);
EAPI int e_modapi_config (E_Module *m);
-void _temperature_face_cb_config_updated(Temperature *temp);
+void _config_temperature_module(void);
+void _temperature_face_cb_config_updated(void);
+extern Config *temperature_config;
+
#endif