From: Carsten Haitzler Date: Fri, 15 Jan 2010 09:32:43 +0000 (+0000) Subject: 1. fix list theme adapting - simply never got callbac ks to handle iot, X-Git-Tag: v1.0.0~4878 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c11b6e74d8b98ce99d94fc2af5ab507e9a496a5c;p=platform%2Fupstream%2Felementary.git 1. fix list theme adapting - simply never got callbac ks to handle iot, that's why! 2. make cmd-line tool to set scale, theme, finger size (more later) - used this to test this and fix it. 3. cmd-line tool... also uses elm - and... as a result... also has a dialog sayint its doing something - and... it can get a gui config later too! SVN revision: 45175 --- diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index e8bc554..d3eaef3 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -21,7 +21,7 @@ if ELEMENTARY_WINDOWS_BUILD AM_CPPFLAGS += -DELEMENTARY_BUILD endif -bin_PROGRAMS = elementary_test +bin_PROGRAMS = elementary_test elementary_config if BUILD_QUICKLAUNCH bin_PROGRAMS += elementary_quicklaunch elementary_run elementary_testql endif @@ -75,6 +75,12 @@ test_conform.c elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@ elementary_test_LDFLAGS = +elementary_config_SOURCES = \ +config.c + +elementary_config_LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@ +elementary_config_LDFLAGS = + if BUILD_QUICKLAUNCH elementary_quicklaunch_SOURCES = quicklaunch.c elementary_quicklaunch_LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@ diff --git a/src/bin/config.c b/src/bin/config.c new file mode 100644 index 0000000..ba27d29 --- /dev/null +++ b/src/bin/config.c @@ -0,0 +1,156 @@ +#include +#ifndef ELM_LIB_QUICKLAUNCH + +static int quiet = 0; +static int interactive = 1; + +static const char *theme_set = NULL; +static const char *finger_size_set = NULL; +static const char *scale_set = NULL; + +static void +my_win_del(void *data, Evas_Object *obj, void *event_info) +{ + /* called when my_win_main is requested to be deleted */ + elm_exit(); /* exit the program's main loop that runs in elm_run() */ +} + +static void +status_win(void) +{ + Evas_Object *win, *bg, *bx0; + + win = elm_win_add(NULL, "main", ELM_WIN_BASIC); + elm_win_title_set(win, "Elementary Config"); + + evas_object_smart_callback_add(win, "delete,request", my_win_del, NULL); + bg = elm_bg_add(win); + evas_object_size_hint_weight_set(bg, 0.0, 0.0); + elm_win_resize_object_add(win, bg); + evas_object_show(bg); + + bx0 = elm_box_add(win); + evas_object_size_hint_weight_set(bx0, 0.0, 0.0); + elm_win_resize_object_add(win, bx0); + evas_object_show(bx0); + + if (!interactive) + { + Evas_Object *lb, *fr; + + fr = elm_frame_add(win); + elm_frame_label_set(fr, "Information"); + elm_box_pack_end(bx0, fr); + evas_object_show(fr); + + lb = elm_label_add(win); + elm_label_label_set(lb, + "Applying configuration change" + ); + elm_frame_content_set(fr, lb); + evas_object_show(lb); + } + else + { + Evas_Object *lb, *fr; + + fr = elm_frame_add(win); + elm_frame_label_set(fr, "Fill me in"); + elm_box_pack_end(bx0, fr); + evas_object_show(fr); + + lb = elm_label_add(win); + elm_label_label_set(lb, + "Not done yet" + ); + elm_frame_content_set(fr, lb); + evas_object_show(lb); + } + + evas_object_show(win); +} + +static int +_exit_timer(void *data) +{ + elm_exit(); +} + +/* this is your elementary main function - it MUSt be called IMMEDIATELY + * after elm_init() and MUSt be passed argc and argv, and MUST be called + * elm_main and not be static - must be a visible symbol with EAPI infront */ +EAPI int +elm_main(int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-h")) + { + printf("Usage:\n" + " -h This help\n" + " -q Quiet mode (dont show window)\n" + " -t THEME Set theme to THEME (ELM_THEME spec)\n" + " -f SIZE Set finger size to SIZE pixels\n" + " -s SCALE Set scale factor to SCALE\n" + ); + } + else if (!strcmp(argv[i], "-q")) + { + quiet = 1; + interactive = 0; + } + else if ((!strcmp(argv[i], "-t")) && (i < argc - 1)) + { + i++; + theme_set = argv[i]; + interactive = 0; + } + else if ((!strcmp(argv[i], "-f")) && (i < argc - 1)) + { + i++; + finger_size_set = argv[i]; + interactive = 0; + } + else if ((!strcmp(argv[i], "-s")) && (i < argc - 1)) + { + i++; + scale_set = argv[i]; + interactive = 0; + } + } + /* put ere any init specific to this app like parsing args etc. */ + if (!quiet) + { + status_win(); /* create main window */ + ecore_timer_add(2.0, _exit_timer, NULL); + } + if (!interactive) + { + if (theme_set) + { + elm_theme_all_set(theme_set); + } + if (finger_size_set) + { + elm_finger_size_all_set(atoi(finger_size_set)); + } + if (scale_set) + { + elm_scale_all_set(atof(scale_set)); + } + if (quiet) + { + elm_exit(); + } + } + elm_run(); /* and run the program now and handle all events etc. */ + /* if the mainloop that elm_run() runs exist - we exit the app */ + elm_shutdown(); /* clean up and shut down */ + /* exit code */ + return 0; +} +#endif +/* all emeentary apps should use this. but it right after elm_main() */ +ELM_MAIN() diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 6a9fe30..6b00be0 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -222,9 +222,11 @@ extern "C" { EAPI double elm_scale_get(void); EAPI void elm_scale_set(double scale); + EAPI void elm_scale_all_set(double scale); EAPI Evas_Coord elm_finger_size_get(void); EAPI void elm_finger_size_set(Evas_Coord size); - + EAPI void elm_finger_size_all_set(Evas_Coord size); + EAPI void elm_object_focus(Evas_Object *obj); EAPI void elm_object_unfocus(Evas_Object *obj); EAPI void elm_object_focus_allow_set(Evas_Object *obj, Eina_Bool enable); @@ -242,7 +244,8 @@ extern "C" { EAPI void elm_theme_extension_add(const char *item); EAPI void elm_theme_extension_del(const char *item); EAPI void elm_theme_flush(void); - + EAPI void elm_theme_all_set(const char *theme); + EAPI Evas_Object *elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type); EAPI void elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj); EAPI void elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj); diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c index b5a2a5c..d3f5960 100644 --- a/src/lib/elm_button.c +++ b/src/lib/elm_button.c @@ -163,7 +163,7 @@ elm_button_add(Evas_Object *parent) elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_disable_hook_set(obj, _disable_hook); - elm_widget_can_focus_set( obj, 1 ); + elm_widget_can_focus_set(obj, 1 ); wd->btn = edje_object_add(e); _elm_theme_set(wd->btn, "button", "base", "default"); diff --git a/src/lib/elm_list.c b/src/lib/elm_list.c index 8ff8ac5..4c1d8c8 100644 --- a/src/lib/elm_list.c +++ b/src/lib/elm_list.c @@ -39,6 +39,7 @@ struct _Elm_List_Item }; static void _del_hook(Evas_Object *obj); +static void _theme_hook(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj); static void _on_focus_hook(void *data, Evas_Object *obj); static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); @@ -192,6 +193,23 @@ _sizing_eval(Evas_Object *obj) } static void +_theme_hook(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + Elm_List_Item *it; + Eina_List *n; + + elm_smart_scroller_theme_set(wd->scr, "scroller", "base", elm_widget_style_get(obj)); + edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale); + EINA_LIST_FOREACH(wd->items, n, it) + { + it->fixed = 0; + } + _fix_items(obj); + _sizing_eval(obj); +} + +static void _on_focus_hook(void *data, Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -670,6 +688,7 @@ elm_list_add(Evas_Object *parent) elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL); elm_widget_data_set(obj, wd); elm_widget_del_hook_set(obj, _del_hook); + elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_can_focus_set(obj, 1); wd->scr = elm_scroller_add(parent); diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 12c497a..e13b17c 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1320,6 +1320,27 @@ elm_scale_set(double scale) } /** + * Set the global scaling factor for all applications on the display + * + * This sets the globally configured scaling factor that is applied to all + * objects for all applications. + * @param scale The scaling factor to set + * @ingroup Scaling + */ +EAPI void +elm_scale_all_set(double scale) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + int scale_i = (int)(scale * 1000.0); + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_SCALE"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &scale_i, 1); +#endif +} + +/** * @defgroup Fingers Fingers * * Elementary is designed to be finger-friendly for touchscreens, and so in @@ -1358,6 +1379,28 @@ elm_finger_size_set(Evas_Coord size) } /** + * Set the configured finger size for all applications on the display + * + * This sets the globally configured finger size in pixels for all applications + * on the display + * + * @param size The finger size + * @ingroup Fingers + */ +EAPI void +elm_finger_size_all_set(Evas_Coord size) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + int size_i = (int)size; + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_FINGER_SIZE"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &size_i, 1); +#endif +} + +/** * Adjust size of an element for finger usage * * This takes width and height sizes (in pixels) as input and a size multiple diff --git a/src/lib/elm_theme.c b/src/lib/elm_theme.c index 26ee3e1..5d63fcc 100644 --- a/src/lib/elm_theme.c +++ b/src/lib/elm_theme.c @@ -140,6 +140,18 @@ elm_theme_flush(void) _elm_win_rescale(); } +EAPI void +elm_theme_all_set(const char *theme) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_THEME"); + ecore_x_window_prop_string_set(ecore_x_window_root_first_get(), + atom, theme); +#endif +} + int _elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style) {