summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bouchaud (yoz) <yoz@efl.so>2019-01-13 15:50:28 +0100
committerMichael Bouchaud (yoz) <yoz@efl.so>2019-01-13 16:08:20 +0100
commit4ea6bfa3d62143f24790b382b988dc6458fe79dd (patch)
tree949e0c6222cb4d2941e6a2903640e481debdfbc3
parent9af43c432fa9dbd97413ec8211a0e88fc640a2ee (diff)
Improve gadget and old module infra, add a test mode too
-rw-r--r--meson.build25
-rw-r--r--meson_options.txt10
-rw-r--r--src/config.c20
-rw-r--r--src/main.c43
-rw-r--r--src/meson.build12
-rw-r--r--src/plugin_openweathermap.c6
-rw-r--r--src/weather.c9
-rw-r--r--src/weather.h2
-rw-r--r--weather.desktop.in2
-rw-r--r--weather_big.desktop.in2
-rw-r--r--weather_map.desktop.in2
11 files changed, 99 insertions, 34 deletions
diff --git a/meson.build b/meson.build
index db7387b..117bf2d 100644
--- a/meson.build
+++ b/meson.build
@@ -33,14 +33,17 @@ module_arch = '@0@-@1@-@2@'.format(host_os, host_machine.cpu_family(), release)
33dir_prefix = dep_e.get_pkgconfig_variable('prefix') 33dir_prefix = dep_e.get_pkgconfig_variable('prefix')
34dir_lib = join_paths(dir_prefix, get_option('libdir')) 34dir_lib = join_paths(dir_prefix, get_option('libdir'))
35if get_option('sandbox') 35if get_option('sandbox')
36 dir_gadgets = join_paths([dir_lib, 'enlightenment/gadgets', module_arch]) 36 dir_gadgets = join_paths([dir_lib, 'enlightenment/gadgets', module_arch, 'weather'])
37else 37else
38 dir_gadgets = join_paths([dir_lib, 'enlightenment/modules/weather', module_arch]) 38 dir_gadgets = join_paths([dir_lib, 'enlightenment/modules/weather'])
39endif 39endif
40 40
41config_h.set_quoted('PACKAGE_PREFIX', dir_prefix) 41config_h.set_quoted('PACKAGE_PREFIX', dir_prefix)
42if get_option('sandbox') 42if get_option('sandbox')
43 config_h.set_quoted('THEMEDIR', join_paths([dir_gadgets, 'weather'])) 43 if get_option('test')
44 config_h.set('WEATHER_TEST', '1')
45 endif
46 config_h.set_quoted('THEMEDIR', dir_gadgets)
44 config_h.set('WEATHER_SANDBOX', '1') 47 config_h.set('WEATHER_SANDBOX', '1')
45endif 48endif
46 49
@@ -60,32 +63,26 @@ desktop_data.set('GADGET_DIR', dir_gadgets)
60desktop_data.set('GADGET_VERSION', meson.project_version()) 63desktop_data.set('GADGET_VERSION', meson.project_version())
61 64
62if get_option('sandbox') 65if get_option('sandbox')
63 meson.add_install_script('ln', '--symbolic', '--force',
64 join_paths([dir_gadgets, 'weather', 'e_gadget_weather']),
65 join_paths([dir_gadgets, 'weather', 'e_gadget_weather_big']))
66 meson.add_install_script('ln', '--symbolic', '--force',
67 join_paths([dir_gadgets, 'weather', 'e_gadget_weather']),
68 join_paths([dir_gadgets, 'weather', 'e_gadget_weather_map']))
69 configure_file(input: 'weather.desktop.in', 66 configure_file(input: 'weather.desktop.in',
70 output: 'weather.desktop', 67 output: 'weather.desktop',
71 install: true, 68 install: true,
72 install_dir: join_paths([dir_gadgets, 'weather']), 69 install_dir: dir_gadgets,
73 configuration: desktop_data) 70 configuration: desktop_data)
74 configure_file(input: 'weather_big.desktop.in', 71 configure_file(input: 'weather_big.desktop.in',
75 output: 'weather_big.desktop', 72 output: 'weather_big.desktop',
76 install: true, 73 install: true,
77 install_dir: join_paths([dir_gadgets, 'weather']), 74 install_dir: dir_gadgets,
78 configuration: desktop_data) 75 configuration: desktop_data)
79 configure_file(input: 'weather_map.desktop.in', 76 configure_file(input: 'weather_map.desktop.in',
80 output: 'weather_map.desktop', 77 output: 'weather_map.desktop',
81 install: true, 78 install: true,
82 install_dir: join_paths([dir_gadgets, 'weather']), 79 install_dir: dir_gadgets,
83 configuration: desktop_data) 80 configuration: desktop_data)
84else 81else
85 configure_file(input: 'module.desktop.in', 82 configure_file(input: 'module.desktop.in',
86 output: 'module.desktop', 83 output: 'module.desktop',
87 install: true, 84 install: true,
88 install_dir: join_paths([dir_lib, 'enlightenment/modules/weather']), 85 install_dir: dir_gadgets,
89 configuration: desktop_data) 86 configuration: desktop_data)
90 87
91endif 88endif
@@ -95,6 +92,6 @@ configure_file(output : 'config.h',
95 configuration: config_h) 92 configuration: config_h)
96 93
97install_data('e-gadget-weather.edj', 94install_data('e-gadget-weather.edj',
98 install_dir: join_paths([dir_lib, 'enlightenment/modules/weather'])) 95 install_dir: dir_gadgets)
99 96
100 97
diff --git a/meson_options.txt b/meson_options.txt
index f1583d5..896f92a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -13,3 +13,13 @@ option('sandbox',
13 value: false, 13 value: false,
14 description: 'Build as a sandbox gadget of enlightenment') 14 description: 'Build as a sandbox gadget of enlightenment')
15 15
16option('home-install',
17 type: 'boolean',
18 value: false,
19 description: 'Install into home directory')
20
21option('test',
22 type: 'boolean',
23 value: false,
24 description: 'Install into home directory')
25
diff --git a/src/config.c b/src/config.c
index eb81cbd..aafb91c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -248,8 +248,18 @@ config_weather(Config_Item *ci, E_Zone *zone)
248 INF("Config popup"); 248 INF("Config popup");
249 249
250#ifdef WEATHER_SANDBOX 250#ifdef WEATHER_SANDBOX
251# ifdef WEATHER_TEST
252 (void)obj;
253 popup = elm_win_add(NULL, "win", ELM_WIN_BASIC);
254 elm_win_autodel_set(popup, EINA_TRUE);
255 o = elm_bg_add(popup);
256 E_EXPAND(o);
257 elm_win_resize_object_add(popup, o);
258 evas_object_show(o);
259# else
251 popup = elm_win_add(obj, "win", ELM_WIN_BASIC); 260 popup = elm_win_add(obj, "win", ELM_WIN_BASIC);
252 elm_win_alpha_set(popup, EINA_TRUE); 261 elm_win_alpha_set(popup, EINA_TRUE);
262# endif
253#else 263#else
254 popup = elm_popup_add(e_comp->elm); 264 popup = elm_popup_add(e_comp->elm);
255 E_EXPAND(popup); 265 E_EXPAND(popup);
@@ -419,8 +429,18 @@ config_weather_map(Config_Item *ci, E_Zone *zone)
419 int row = 0; 429 int row = 0;
420 430
421#ifdef WEATHER_SANDBOX 431#ifdef WEATHER_SANDBOX
432# ifdef WEATHER_TEST
433 (void)obj;
434 popup = elm_win_add(NULL, "win", ELM_WIN_BASIC);
435 elm_win_autodel_set(popup, EINA_TRUE);
436 o = elm_bg_add(popup);
437 E_EXPAND(o);
438 elm_win_resize_object_add(popup, o);
439 evas_object_show(o);
440# else
422 popup = elm_win_add(obj, "win", ELM_WIN_BASIC); 441 popup = elm_win_add(obj, "win", ELM_WIN_BASIC);
423 elm_win_alpha_set(popup, EINA_TRUE); 442 elm_win_alpha_set(popup, EINA_TRUE);
443# endif
424#else 444#else
425 popup = elm_popup_add(e_comp->elm); 445 popup = elm_popup_add(e_comp->elm);
426 E_EXPAND(popup); 446 E_EXPAND(popup);
diff --git a/src/main.c b/src/main.c
index 20ced71..18e5ced 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,16 +14,28 @@ _win_change(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
14{ 14{
15} 15}
16 16
17#ifdef WEATHER_TEST
18static void
19_config_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
20{
21 evas_object_smart_callback_call(data, "gadget_configure", NULL);
22}
23#endif
17 24
18EAPI_MAIN int 25EAPI_MAIN int
19elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) 26elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
20{ 27{
21 Evas_Object *win, *o; 28 Evas_Object *win, *o;
29#ifdef WEATHER_TEST
30 Evas_Object *bx;
31#endif
22 int gadget = 0, id_num = 0; 32 int gadget = 0, id_num = 0;
23 char buf[16]; 33 char buf[16];
24 const char *cmd_name = argv[0]; 34 const char *cmd_name = argv[0];
25 35
26 //eina_log_level_set(5); 36#ifdef WEATHER_TEST
37 eina_log_level_set(5);
38#endif
27 _main_log_domain = eina_log_domain_register("main", EINA_COLOR_CYAN); 39 _main_log_domain = eina_log_domain_register("main", EINA_COLOR_CYAN);
28 40
29 if (strrchr(cmd_name, '/')) cmd_name = strrchr(cmd_name, '/') + 1; 41 if (strrchr(cmd_name, '/')) cmd_name = strrchr(cmd_name, '/') + 1;
@@ -52,6 +64,14 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
52 elm_win_title_set(win, "weather"); 64 elm_win_title_set(win, "weather");
53 elm_win_autodel_set(win, EINA_TRUE); 65 elm_win_autodel_set(win, EINA_TRUE);
54 66
67#ifdef WEATHER_TEST
68 o = elm_bg_add(win);
69 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 elm_win_resize_object_add(win, o);
71 evas_object_show(o);
72 bx = elm_box_add(win);
73 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74#endif
55 75
56 INF("Launch %s", cmd_name); 76 INF("Launch %s", cmd_name);
57 if (!strcmp(cmd_name, CMD_WEATHER_MAP)) 77 if (!strcmp(cmd_name, CMD_WEATHER_MAP))
@@ -68,9 +88,26 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
68 } 88 }
69 DBG("Run weather instance %d", id_num); 89 DBG("Run weather instance %d", id_num);
70 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 90 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
71 elm_win_resize_object_add(win, o);
72 evas_object_show(o); 91 evas_object_show(o);
73 92
93#ifdef WEATHER_TEST
94 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
95 elm_box_pack_end(bx, o);
96
97 o = elm_button_add(win);
98 elm_object_text_set(o, "Configure");
99 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
100 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
101 evas_object_smart_callback_add(o, "clicked", _config_cb, win);
102 elm_box_pack_end(bx, o);
103 evas_object_show(o);
104 evas_object_show(bx);
105 elm_win_resize_object_add(win, bx);
106
107#else
108 elm_win_resize_object_add(win, o);
109#endif
110
74 if ((gadget) && (id_num > -1)) 111 if ((gadget) && (id_num > -1))
75 { 112 {
76 evas_object_smart_callback_add(win, "gadget_site_anchor", _win_change, NULL); 113 evas_object_smart_callback_add(win, "gadget_site_anchor", _win_change, NULL);
@@ -79,7 +116,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
79 116
80 if (!gadget) 117 if (!gadget)
81 { 118 {
82 evas_object_resize(win, 256, 256); 119 evas_object_resize(win, 640, 480);
83 elm_win_alpha_set(win, EINA_FALSE); 120 elm_win_alpha_set(win, EINA_FALSE);
84 } 121 }
85 else 122 else
diff --git a/src/meson.build b/src/meson.build
index f579f91..82368f7 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -13,16 +13,16 @@ if get_option('sandbox')
13 dependencies: deps, 13 dependencies: deps,
14 c_args : ['-fPIE', '-fPIC'], 14 c_args : ['-fPIE', '-fPIC'],
15 link_args : ['-rdynamic', '-pie'], 15 link_args : ['-rdynamic', '-pie'],
16 install_dir: join_paths([dir_gadgets, 'weather']), 16 install_dir: dir_gadgets,
17 install: true) 17 install: true)
18 18
19 meson.add_install_script('ln', '--symbolic', '--force', 19 meson.add_install_script('ln', '--symbolic', '--force',
20 join_paths([dir_gadgets, 'weather', 'e_gadget_weather']), 20 join_paths([dir_gadgets, 'e_gadget_weather']),
21 join_paths([dir_gadgets, 'weather_big', 'e_gadget_weather_big'])) 21 join_paths([dir_gadgets, 'e_gadget_weather_big']))
22 22
23 meson.add_install_script('ln', '--symbolic', '--force', 23 meson.add_install_script('ln', '--symbolic', '--force',
24 join_paths([dir_gadgets, 'weather', 'e_gadget_weather']), 24 join_paths([dir_gadgets, 'e_gadget_weather']),
25 join_paths([dir_gadgets, 'weather_map', 'e_gadget_weather_map'])) 25 join_paths([dir_gadgets, 'e_gadget_weather_map']))
26 26
27else 27else
28 build_files = [ 28 build_files = [
@@ -40,7 +40,7 @@ else
40 dependencies: deps, 40 dependencies: deps,
41 c_args : ['-fPIE', '-fPIC'], 41 c_args : ['-fPIE', '-fPIC'],
42 link_args : '-Wl,--unresolved-symbols=ignore-all', 42 link_args : '-Wl,--unresolved-symbols=ignore-all',
43 install_dir: dir_gadgets, 43 install_dir: join_paths([dir_gadgets, module_arch]),
44 install: true) 44 install: true)
45 45
46 46
diff --git a/src/plugin_openweathermap.c b/src/plugin_openweathermap.c
index de16e0f..9536f8a 100644
--- a/src/plugin_openweathermap.c
+++ b/src/plugin_openweathermap.c
@@ -474,9 +474,13 @@ _plugin_openweathermap_uri_get(Weather *w)
474{ 474{
475 char buf[4096]; 475 char buf[4096];
476 char buf_lang[1024]; 476 char buf_lang[1024];
477 const char *lang = ""; 477 const char *lang;
478 478
479#ifdef WEATHER_SANDBOX
479 lang = getenv("LANG"); 480 lang = getenv("LANG");
481#else
482 lang = e_intl_language_get();
483#endif
480 if (lang) 484 if (lang)
481 { 485 {
482 if ((!strncmp(lang, "en", 2)) 486 if ((!strncmp(lang, "en", 2))
diff --git a/src/weather.c b/src/weather.c
index abf2979..ec34686 100644
--- a/src/weather.c
+++ b/src/weather.c
@@ -659,9 +659,6 @@ _weather_popup_new(Instance *inst)
659 Evas_Object *nav; 659 Evas_Object *nav;
660 Evas_Object *o; 660 Evas_Object *o;
661 Elm_Object_Item *nav_it, *nav_promote, *it; 661 Elm_Object_Item *nav_it, *nav_promote, *it;
662#ifdef WEATHER_SANDBOX
663 Evas_Coord x, y;
664#endif
665 662
666 663
667 if (inst->popup) return; 664 if (inst->popup) return;
@@ -730,7 +727,6 @@ _weather_popup_new(Instance *inst)
730 727
731 elm_naviframe_item_promote(nav_promote); 728 elm_naviframe_item_promote(nav_promote);
732 evas_object_show(nav); 729 evas_object_show(nav);
733// evas_pointer_canvas_xy_get(evas_object_evas_get(inst->win), &x, &y);
734#ifdef WEATHER_SANDBOX 730#ifdef WEATHER_SANDBOX
735 elm_win_resize_object_add(inst->popup, hbx); 731 elm_win_resize_object_add(inst->popup, hbx);
736#else 732#else
@@ -1179,8 +1175,8 @@ weather_icon_add(Evas_Object *parent)
1179#endif 1175#endif
1180 elm_layout_file_set(o, buf, "e/gadget/weather/small"); 1176 elm_layout_file_set(o, buf, "e/gadget/weather/small");
1181 evas_object_size_hint_aspect_set(o, EVAS_ASPECT_CONTROL_BOTH, 1.5, 0.666667); 1177 evas_object_size_hint_aspect_set(o, EVAS_ASPECT_CONTROL_BOTH, 1.5, 0.666667);
1182 evas_object_size_hint_min_set(o, 32, 32); 1178// evas_object_size_hint_min_set(o, 32, 32);
1183 evas_object_size_hint_max_set(o, 32, 32); 1179// evas_object_size_hint_max_set(o, 32, 32);
1184 1180
1185 return o; 1181 return o;
1186} 1182}
@@ -1241,6 +1237,7 @@ weather_object_update(Evas_Object *obj, const Weather *w, const Weather_Data *wd
1241 time_t tt; 1237 time_t tt;
1242 const struct tm *now; 1238 const struct tm *now;
1243 1239
1240 if (!w || !wd) return;
1244 1241
1245 if (wd->time_start.tm_hour <= w->sunrise.tm_hour) 1242 if (wd->time_start.tm_hour <= w->sunrise.tm_hour)
1246 { 1243 {
diff --git a/src/weather.h b/src/weather.h
index 2b0604e..368eea5 100644
--- a/src/weather.h
+++ b/src/weather.h
@@ -1,6 +1,7 @@
1#ifndef WEATHER_H 1#ifndef WEATHER_H
2#define WEATHER_H 2#define WEATHER_H
3 3
4#include "../config.h"
4#include <Elementary.h> 5#include <Elementary.h>
5 6
6#ifdef WEATHER_SANDBOX 7#ifdef WEATHER_SANDBOX
@@ -11,7 +12,6 @@
11# include <e.h> 12# include <e.h>
12#endif 13#endif
13 14
14#include "../config.h"
15#ifdef HAVE_GETTEXT 15#ifdef HAVE_GETTEXT
16# include <libintl.h> 16# include <libintl.h>
17# define _(str) gettext(str) 17# define _(str) gettext(str)
diff --git a/weather.desktop.in b/weather.desktop.in
index e8be010..6ffc148 100644
--- a/weather.desktop.in
+++ b/weather.desktop.in
@@ -1,7 +1,7 @@
1[Desktop Entry] 1[Desktop Entry]
2Type=Application 2Type=Application
3Name=weather 3Name=weather
4Exec=@GADGET_DIR@/weather/e_gadget_weather 4Exec=@GADGET_DIR@/e_gadget_weather
5Icon=start-here 5Icon=start-here
6X-Gadget-Version=@GADGET_VERSION@ 6X-Gadget-Version=@GADGET_VERSION@
7X-Gadget-Bugreport=https://www.enlightenment.org/contrib/report-bug 7X-Gadget-Bugreport=https://www.enlightenment.org/contrib/report-bug
diff --git a/weather_big.desktop.in b/weather_big.desktop.in
index 34d01af..ed0c0fa 100644
--- a/weather_big.desktop.in
+++ b/weather_big.desktop.in
@@ -1,7 +1,7 @@
1[Desktop Entry] 1[Desktop Entry]
2Type=Application 2Type=Application
3Name=weather big 3Name=weather big
4Exec=@GADGET_DIR@/weather/e_gadget_weather_big 4Exec=@GADGET_DIR@/e_gadget_weather_big
5Icon=start-here 5Icon=start-here
6X-Gadget-Version=@GADGET_VERSION@ 6X-Gadget-Version=@GADGET_VERSION@
7X-Gadget-Bugreport=https://www.enlightenment.org/contrib/report-bug 7X-Gadget-Bugreport=https://www.enlightenment.org/contrib/report-bug
diff --git a/weather_map.desktop.in b/weather_map.desktop.in
index 6f7b16e..2839fbf 100644
--- a/weather_map.desktop.in
+++ b/weather_map.desktop.in
@@ -1,7 +1,7 @@
1[Desktop Entry] 1[Desktop Entry]
2Type=Application 2Type=Application
3Name=weather map 3Name=weather map
4Exec=@GADGET_DIR@/weather/e_gadget_weather_map 4Exec=@GADGET_DIR@/e_gadget_weather_map
5Icon=start-here 5Icon=start-here
6X-Gadget-Version=@GADGET_VERSION@ 6X-Gadget-Version=@GADGET_VERSION@
7X-Gadget-Bugreport=https://www.enlightenment.org/contrib/report-bug 7X-Gadget-Bugreport=https://www.enlightenment.org/contrib/report-bug