commit 8fbb4723ccd103aba9cae126db733c405c2282fd Author: Mike Blumenkrantz Date: Tue Jun 17 09:34:37 2014 -0400 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..171da42 --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +*~ +*.swo +*.swp +*.o +*.lo +*.la +ABOUT-NLS +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +config.guess +config.h +config.h.in +config.log +config.rpath +config.status +config.sub +configure +configure.ac.orig +depcomp +e_modules-*.spec +install-sh +libtool +ltmain.sh +*.m4 +missing +mkinstalldirs +module.desktop +po/Makefile +po/Makefile.in +po/Makefile.in.in +po/Makevars.template +po/POTFILES +po/Rules-quot +po/*.gmo +po/boldquot.sed +po/en@boldquot.header +po/en@quot.header +po/insert-header.sin +po/quot.sed +po/remove-potcdate.sed +po/remove-potcdate.sin +po/stamp-po +src/.deps/ +src/.libs/ +stamp-h1 diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..73ebbe2 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +The Rasterman (Carsten Haitzler) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..4556b54 --- /dev/null +++ b/COPYING @@ -0,0 +1,25 @@ +Copyright notice for Enlightenment: + +Copyright (C) 2000-2012 Carsten Haitzler and various contributors (see AUTHORS) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..ec79818 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,70 @@ +ACLOCAL_AMFLAGS = -I m4 + +MAINTAINERCLEANFILES = \ +m4/libtool.m4 \ +m4/wchar_t.m4 \ +m4/uintmax_t.m4 \ +m4/inttypes-pri.m4 \ +m4/xsize.m4 \ +m4/longdouble.m4 \ +m4/nls.m4 \ +m4/lt~obsolete.m4 \ +m4/wint_t.m4 \ +m4/isc-posix.m4 \ +m4/printf-posix.m4 \ +m4/po.m4 \ +m4/signed.m4 \ +m4/lcmessage.m4 \ +m4/intmax.m4 \ +m4/ltoptions.m4 \ +m4/ulonglong.m4 \ +m4/progtest.m4 \ +m4/glibc21.m4 \ +m4/inttypes.m4 \ +m4/codeset.m4 \ +m4/stdint_h.m4 \ +m4/ltsugar.m4 \ +m4/longlong.m4 \ +m4/inttypes_h.m4 \ +m4/lib-ld.m4 \ +m4/lib-link.m4 \ +m4/gettext.m4 \ +m4/size_max.m4 \ +m4/ltversion.m4 \ +m4/lib-prefix.m4 \ +m4/iconv.m4 \ +m4/intdiv0.m4 \ +Makefile.in \ +aclocal.m4 \ +config.guess \ +config.h.in \ +config.sub \ +configure \ +depcomp \ +install-sh \ +ltmain.sh \ +missing \ +module.\ +desktop \ +config.rpath \ +mkinstalldirs + +SUBDIRS = src + +if HAVE_PO + +SUBDIRS += po + +endif + +filesdir = $(module_dir)/$(PACKAGE) +files_DATA = module.desktop + +EXTRA_DIST = module.desktop.in + +clean-local: + rm -rf *.edj module.desktop *~ + +uninstall-local: + rm -rf $(DESTDIR)$(module_dir)/$(PACKAGE) + diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..ae01364 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +rm -rf autom4te.cache +rm -f aclocal.m4 ltmain.sh + +touch README + +echo "Running autopoint..." ; autopoint -f || : +echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1 +echo "Running autoheader..." ; autoheader || exit 1 +echo "Running autoconf..." ; autoconf || exit 1 +echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 +echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 + +if [ -z "$NOCONFIGURE" ]; then + ./configure "$@" +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..222f2ad --- /dev/null +++ b/configure.ac @@ -0,0 +1,77 @@ +dnl Process this file with autoconf to produce a configure script. + +# get rid of that stupid cache mechanism +rm -f config.cache + +AC_INIT(wallpaper2, 0.1, enlightenment-devel@lists.sourceforge.net) +AC_CONFIG_MACRO_DIR([m4]) +AC_PREREQ(2.52) +AC_CONFIG_SRCDIR(configure.ac) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_ISC_POSIX + +AM_INIT_AUTOMAKE([1.8 dist-bzip2]) +AM_CONFIG_HEADER(config.h) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +AC_PROG_CC +AM_PROG_CC_STDC + +define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl +define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl +AC_PROG_LIBTOOL + +m4_ifdef([AM_GNU_GETTEXT_VERSION], [ +AM_GNU_GETTEXT_VERSION([0.14]) +]) + +m4_ifdef([AM_GNU_GETTEXT], [ +AM_GNU_GETTEXT([external]) +po_makefile_in=po/Makefile.in +AM_CONDITIONAL([HAVE_PO], [true]) +],[ +AM_CONDITIONAL([HAVE_PO], [false]) +]) +AC_SUBST(LTLIBINTL) + +PKG_CHECK_MODULES([E], [enlightenment > 0.18.99]) +release=$(pkg-config --variable=release enlightenment) +MODULE_ARCH="$host_os-$host_cpu-$release" +AC_SUBST(MODULE_ARCH) +AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") + +module_dir="$(pkg-config --variable=modules enlightenment)" +AC_SUBST(module_dir) +datadir="$module_dir/wallpaper2" +# Find edje_cc +##AC_ARG_WITH(edje-cc, +## AC_HELP_STRING([--with-edje-cc=PATH], [specify a specific path to edje_cc]), +## [ +## v=$withval; +## EDJE_CC=$v +## ],[ +## EDJE_CC=$(pkg-config --variable=prefix edje)/bin/edje_cc +## ] +##) +##AC_SUBST(EDJE_CC) +##AC_MSG_CHECKING([Which edje_cc to use]) +##AC_MSG_RESULT(${EDJE_CC}) + +m4_ifdef([v_mic], + [ + EFL_COMPILER_FLAG([-Wshadow]) + EFL_COMPILER_FLAG([-Wall]) + EFL_COMPILER_FLAG([-Wpointer-arith]) + EFL_COMPILER_FLAG([-W]) + EFL_COMPILER_FLAG([-Wno-missing-field-initializers]) + ]) + +AC_OUTPUT([ +Makefile +src/Makefile +module.desktop +$po_makefile_in +], [ +]) + diff --git a/e_modules-wallpaper2.spec.in b/e_modules-wallpaper2.spec.in new file mode 100644 index 0000000..5564047 --- /dev/null +++ b/e_modules-wallpaper2.spec.in @@ -0,0 +1,47 @@ +%define module_name wallpaper2 +%{!?_rel:%{expand:%%global _rel 0.enl%{?dist}}} + +Summary: %{module_name} module for the Enlightenment window manager +Name: e_modules-%{module_name} +Version: @VERSION@ +Release: %{_rel} +License: BSD +Group: User Interface/Desktops +URL: http://www.enlightenment.org/ +Source: ftp://ftp.enlightenment.org/pub/enlightenment/%{module_name}-%{version}.tar.gz +Packager: %{?_packager:%{_packager}}%{!?_packager:Michael Jennings } +Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)} +Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} +BuildRequires: enlightenment-devel >= 0.18.999 +Requires: enlightenment >= 0.18.999 +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +%{module_name} module for the Enlightenment window manager. + +%prep +%setup -q -n %{module_name}-%{version} + +%build +%{configure} +%{__make} %{?_smp_mflags} %{?mflags} + +%install +%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install +%{find_lang} %{module_name} || true > %{module_name}.lang + +%clean +test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +%files -f %{module_name}.lang +%defattr(-, root, root) +%doc AUTHORS ChangeLog COPYING* INSTALL NEWS README +%{_libdir}/enlightenment/modules/%{module_name}* + +%changelog diff --git a/module.desktop.in b/module.desktop.in new file mode 100644 index 0000000..1100bda --- /dev/null +++ b/module.desktop.in @@ -0,0 +1,33 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Link +Name=Wallpaper 2 +Name[ca]=Fons d'escriptori +Name[cs]=Pozadí plochy +Name[eo]=Tapeto +Name[es]=Fondo de pantalla +Name[fr]=Fond d'écran 2 +Name[gl]=Fondo de escritorio 2 +Name[hu]=Háttérkép +Name[it]=Sfondo 2 +Name[ms]=Kertas Dinding 2 +Name[pt]=Papel de parede 2 +Name[ru]=Обои 2 +Name[sr]=Позадина површи 2 +Name[tr]=Duvarkağıdı 2 +Comment=Used to pick a wallpaper. +Comment[ca]=Permet seleccionar el fons d'escriptori. +Comment[cs]=Použit k volbě pozadí. +Comment[eo]=Elekti tapeton. +Comment[es]=Para elegir un fondo de pantalla. +Comment[fr]=Sélection du fond d'écran. +Comment[gl]=Usado para escoller un fondo de pantalla. +Comment[hu]=Háttérkép beállító modul. +Comment[it]=Usato per selezionare uno sfondo. +Comment[ms]=Digunakan untuk mendapatkan kertas dinding. +Comment[pt]=Permite-lhe escolher o papel de parede +Comment[ru]=Используется для выбора обоев. +Comment[sr]=Користи се за одабир слике радне површи. +Comment[tr]=Duvarkağıdı seçiminde kullanılır. +Icon=preferences-desktop-wallpaper +X-Enlightenment-ModuleType=settings diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..e69de29 diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..5b54556 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,42 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=N_ --keyword=D_ --keyword=DP_:1,2 \ + --from-code=UTF-8 --foreign-user + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Enlightenment development team + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = enlightenment-devel@lists.sourceforge.net + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..c618d63 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,3 @@ +src/e_int_config_wallpaper.c +src/e_mod_main.c +src/e_mod_main.h diff --git a/po/wallpaper2.pot b/po/wallpaper2.pot new file mode 100644 index 0000000..db5b78b --- /dev/null +++ b/po/wallpaper2.pot @@ -0,0 +1,74 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Enlightenment development team +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: enlightenment-devel@lists.sourceforge.net\n" +"POT-Creation-Date: 2014-06-17 09:26-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/e_int_config_wallpaper.c:723 src/e_int_config_wallpaper.c:916 +msgid "Theme Wallpaper" +msgstr "" + +#: src/e_int_config_wallpaper.c:1106 +msgid "Loading files..." +msgstr "" + +#: src/e_int_config_wallpaper.c:1174 +msgid "Wallpaper Settings" +msgstr "" + +#: src/e_int_config_wallpaper.c:1189 +msgid "OK" +msgstr "" + +#: src/e_int_config_wallpaper.c:1195 +msgid "Apply" +msgstr "" + +#: src/e_int_config_wallpaper.c:1201 +msgid "Close" +msgstr "" + +#: src/e_int_config_wallpaper.c:1252 +msgid "All Desktops" +msgstr "" + +#: src/e_int_config_wallpaper.c:1258 +msgid "This Desktop" +msgstr "" + +#: src/e_int_config_wallpaper.c:1263 +msgid "This Screen" +msgstr "" + +#: src/e_int_config_wallpaper.c:1276 +msgid "Add" +msgstr "" + +#: src/e_int_config_wallpaper.c:1281 +msgid "Delete" +msgstr "" + +#: src/e_mod_main.c:25 +msgid "Look" +msgstr "" + +#: src/e_mod_main.c:26 src/e_mod_main.c:30 src/e_mod_main.c:94 +msgid "Wallpaper 2" +msgstr "" + +#: src/e_mod_main.c:27 +msgid "Internal" +msgstr "" diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..391f9d4 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,21 @@ +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = -I. \ + -I$(top_srcdir) \ + -I$(includedir) \ + -DLOCALEDIR=\"$(datadir)/locale\" \ + -DPACKAGE_DATA_DIR=\"$(module_dir)/$(PACKAGE)\" \ + @E_CFLAGS@ + +pkgdir = $(module_dir)/$(PACKAGE)/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la +module_la_SOURCES = e_mod_main.h \ + e_mod_main.c \ + e_int_config_wallpaper.c + +module_la_LIBADD = @E_LIBS@ +module_la_LDFLAGS = -module -avoid-version +module_la_DEPENDENCIES = $(top_builddir)/config.h + +clean-local: + rm -rf *~ diff --git a/src/e_int_config_wallpaper.c b/src/e_int_config_wallpaper.c new file mode 100644 index 0000000..6c77e55 --- /dev/null +++ b/src/e_int_config_wallpaper.c @@ -0,0 +1,1352 @@ +#include "e.h" +#include "e_mod_main.h" + +// FIXME: +// need choice after add (file, gradient, online source) +// need delete select mode +// need after select on delete an ok/cancel if file or "ok to remove whole online source" if online +// need to make "exchange" wallpapers have a different look +// bug: animated wp doesn't workon first show +// need to be able to "type name to search/filter" + +typedef struct _Info Info; +typedef struct _Smart_Data Smart_Data; +typedef struct _Item Item; + +struct _Info +{ + E_Win *win; + Evas_Object *bg, *preview, *mini, *button, *box, *sframe, *span; + Eina_Stringshare *bg_file; + int iw, ih; + Eina_List *dirs; + char *curdir; + Eina_Iterator *dir; + Ecore_Idler *idler; + int scans; + int man_num, zone_num, desk_x, desk_y; + int use_theme_bg; + int mode; +}; + +struct _Smart_Data +{ + Eina_List *items; + Ecore_Idle_Enterer *idle_enter; + Ecore_Animator *animator; + Ecore_Timer *seltimer; + Info *info; + Evas_Coord x, y, w, h; + Evas_Coord cx, cy, cw, ch; + Evas_Coord sx, sy; + int id_num; + int sort_num; + double seltime; + double selmove; + Eina_Bool selin : 1; + Eina_Bool selout : 1; + Eina_Bool jump2hi : 1; +}; + +struct _Item +{ + Evas_Object *obj; + Evas_Coord x, y, w, h; + Eina_Stringshare *file; + char *sort_id; + Evas_Object *frame, *image; + Eina_Bool selected : 1; + Eina_Bool have_thumb : 1; + Eina_Bool do_thumb : 1; + Eina_Bool remote : 1; + Eina_Bool theme : 1; + Eina_Bool visible : 1; + Eina_Bool hilighted : 1; +}; + +static Info *global_info = NULL; + +static void _e_smart_reconfigure(Evas_Object *obj); +static Eina_Bool _e_smart_reconfigure_do(void *data); +static void _thumb_gen(void *data, Evas_Object *obj, void *event_info); +static void _item_down(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _item_up(void *data, Evas *e, Evas_Object *obj, void *event_info); +static int _sort_cb(const void *d1, const void *d2); +static void _scan(Info *info); + +static void +_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (x > (sd->cw - sd->w)) x = sd->cw - sd->w; + if (y > (sd->ch - sd->h)) y = sd->ch - sd->h; + if (x < 0) x = 0; + if (y < 0) y = 0; + if ((sd->cx == x) && (sd->cy == y)) return; + sd->cx = x; + sd->cy = y; + _e_smart_reconfigure(obj); +} + +static void +_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (x) *x = sd->cx; + if (y) *y = sd->cy; +} + +static void +_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (x) + { + if (sd->w < sd->cw) *x = sd->cw - sd->w; + else *x = 0; + } + if (y) + { + if (sd->h < sd->ch) *y = sd->ch - sd->h; + else *y = 0; + } +} + +static void +_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (w) *w = sd->cw; + if (h) *h = sd->ch; +} + +static Eina_Bool +_e_smart_reconfigure_do(void *data) +{ + Evas_Object *obj = data; + Smart_Data *sd = evas_object_smart_data_get(obj); + Eina_List *l; + Item *it; + int iw, redo = 0, changed = 0; + static int recursion = 0; + Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox, oy, dd; + Evas_Coord vw, vh; + Evas *evas; + + if (!sd) return ECORE_CALLBACK_CANCEL; + if (sd->cx > (sd->cw - sd->w)) sd->cx = sd->cw - sd->w; + if (sd->cy > (sd->ch - sd->h)) sd->cy = sd->ch - sd->h; + if (sd->cx < 0) sd->cx = 0; + if (sd->cy < 0) sd->cy = 0; + + iw = sd->w / 4; + if (iw > (120 * e_scale)) iw = (120 * e_scale); + else + { + if (iw < (60 * e_scale)) iw = (sd->w / 3); + if (iw < (60 * e_scale)) iw = (sd->w / 2); + if (iw < (60 * e_scale)) iw = sd->w; + } + x = 0; + y = 0; + ww = iw; + hh = (sd->info->ih * iw) / (sd->info->iw); + mw = mh = 0; + + evas = evas_object_evas_get(obj); + evas_output_viewport_get(evas, NULL, NULL, &vw, &vh); + + EINA_LIST_FOREACH(sd->items, l, it) + { + if (x > (sd->w - ww)) + { + x = 0; + y += hh; + } + it->x = x; + it->y = y; + it->w = ww; + it->h = hh; + if (it->selected) + { + sd->sx = it->x + (it->w / 2); + sd->sy = it->y + (it->h / 2); + } + if ((x + ww) > mw) mw = x + ww; + if ((y + hh) > mh) mh = y + hh; + x += ww; + } + if ((mw != sd->cw) || (mh != sd->ch)) + { + sd->cw = mw; + sd->ch = mh; + if (sd->cx > (sd->cw - sd->w)) + { + sd->cx = sd->cw - sd->w; + redo = 1; + } + if (sd->cy > (sd->ch - sd->h)) + { + sd->cy = sd->ch - sd->h; + redo = 1; + } + if (sd->cx < 0) + { + sd->cx = 0; + redo = 1; + } + if (sd->cy < 0) + { + sd->cy = 0; + redo = 1; + } + if (redo) + { + recursion = 1; + _e_smart_reconfigure_do(obj); + recursion = 0; + } + changed = 1; + } + + ox = 0; + if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2; + oy = 0; + if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2; + + EINA_LIST_FOREACH(sd->items, l, it) + { + Evas_Coord dx, dy; + + dx = dy = 0; + if ((sd->sx >= 0) && (sd->selmove > 0.0) + +/* && + ((it->x + it->w) > sd->cx) && + ((it->x) < (sd->cx + sd->w)) && + ((it->y + it->h) > sd->cy) && + ((it->y) < (sd->cy + sd->h)) + */ + ) + { + double a, d; + int sum = 0; + char *p; + + // -----0X0+++++ + dx = (it->x + (it->w / 2)) - sd->sx; + dy = (it->y + (it->h / 2)) - sd->sy; + if (dx > 0) + { + // |/ + // +-- + if (dy < 0) + a = -atan(-(double)dy / (double)dx); + // +-- + /* |\ */ + else + a = atan((double)dy / (double)dx); + } + else if (dx == 0) + { + // | + // + + if (dy < 0) a = -M_PI / 2; + // + + // | + else a = M_PI / 2; + } + else + { + // \| + // --+ + if (dy < 0) + a = -M_PI + atan((double)dy / (double)dx); + // --+ + // /| + else + a = M_PI - atan(-(double)dy / (double)dx); + } + d = sqrt((double)(dx * dx) + (double)(dy * dy)); + + sum = 0; + if (it->file) + { + for (p = (char *)it->file; *p; p++) sum += (int)(*p); + } + sum = (sum & 0xff) - 128; + a = a + ((double)sum / 1024.0); + xx = sd->sx - sd->cx + ox; + yy = sd->sy - sd->cy + oy; + if (xx < (sd->w / 2)) dx = sd->w - xx; + else dx = xx; + if (yy < (sd->h / 2)) dy = sd->h - yy; + else dy = yy; + dd = dx - d; + if (dy > dx) dd = dy - d; + if (dd < 0) dd = 0; + dy = sin(a) * sd->selmove * (dd * 0.9); + dx = cos(a) * sd->selmove * (dd * 0.9); + } + xx = sd->x - sd->cx + it->x + ox; + yy = sd->y - sd->cy + it->y + oy; + if (E_INTERSECTS(xx, yy, it->w, it->h, 0, 0, vw, vh)) + { + if (!it->have_thumb) + { + if (!it->do_thumb) + { + e_thumb_icon_begin(it->image); + it->do_thumb = EINA_TRUE; + } + } + else + { + if (!it->frame) + { + it->frame = edje_object_add(evas); + if (it->theme) + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/conf/wallpaper/main/mini-theme"); + else if (it->remote) + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/conf/wallpaper/main/mini-remote"); + else + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/conf/wallpaper/main/mini"); + if (it->hilighted) + { + edje_object_signal_emit(it->frame, "e,state,selected", "e"); + evas_object_raise(it->frame); + } + evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN, + _item_down, it); + evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP, + _item_up, it); + + evas_object_smart_member_add(it->frame, obj); + evas_object_clip_set(it->frame, evas_object_clip_get(obj)); + it->image = e_thumb_icon_add(evas); + edje_object_part_swallow(it->frame, "e.swallow.content", it->image); + evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it); + if (it->theme) + { + const char *f; + + f = e_theme_edje_file_get("base/theme/backgrounds", + "e/desktop/background"); + e_thumb_icon_file_set(it->image, f, + "e/desktop/background"); + } + else + e_thumb_icon_file_set(it->image, it->file, + "e/desktop/background"); + e_thumb_icon_size_set(it->image, sd->info->iw, + sd->info->ih); + evas_object_show(it->image); + + e_thumb_icon_begin(it->image); + } + } + evas_object_move(it->frame, xx + dx, yy + dy); + evas_object_resize(it->frame, it->w, it->h); + evas_object_show(it->frame); + it->visible = EINA_TRUE; + } + else + { + if (it->have_thumb) + { + if (it->do_thumb) + { + e_thumb_icon_end(it->image); + it->do_thumb = EINA_FALSE; + } + evas_object_del(it->image); + it->image = NULL; + evas_object_del(it->frame); + it->frame = NULL; + } + it->visible = EINA_FALSE; +/* + if (it->have_thumb) + { + if (it->do_thumb) + { + e_thumb_icon_end(it->image); + it->do_thumb = EINA_FALSE; + } + evas_object_del(it->image); + it->have_thumb = EINA_FALSE; + it->image = e_thumb_icon_add(evas); + edje_object_part_swallow(it->frame, "e.swallow.content", it->image); + evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it); + if (it->theme) + { + const char *f = e_theme_edje_file_get("base/theme/backgrounds", + "e/desktop/background"); + e_thumb_icon_file_set(it->image, f, "e/desktop/background"); + } + else + e_thumb_icon_file_set(it->image, it->file, "e/desktop/background"); + e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih); + evas_object_show(it->image); + edje_object_signal_emit(it->frame, "e,action,thumb,ungen", "e"); + } + else + { + if (it->sort_id) + { + if (it->do_thumb) + { + e_thumb_icon_end(it->image); + it->do_thumb = 0; + } + } + } + */ + } + } + + if (changed) + evas_object_smart_callback_call(obj, "changed", NULL); + if (recursion == 0) sd->idle_enter = NULL; + return ECORE_CALLBACK_CANCEL; +} + +static void +_e_smart_reconfigure(Evas_Object *obj) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (sd->idle_enter) return; + sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj); +} + +static void +_e_smart_add(Evas_Object *obj) +{ + Smart_Data *sd = calloc(1, sizeof(Smart_Data)); + + if (!sd) return; + + sd->sx = sd->sy = -1; + evas_object_smart_data_set(obj, sd); +} + +static void +_e_smart_del(Evas_Object *obj) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + Item *it; + + if (sd->seltimer) + ecore_timer_del(sd->seltimer); + if (sd->idle_enter) + ecore_idle_enterer_del(sd->idle_enter); + if (sd->animator) + ecore_animator_del(sd->animator); + // sd->info is just referenced + // sd->child_obj is unused + EINA_LIST_FREE(sd->items, it) + { + if (it->frame) evas_object_del(it->frame); + if (it->image) evas_object_del(it->image); + eina_stringshare_del(it->file); + free(it->sort_id); + free(it); + } + free(sd); + evas_object_smart_data_set(obj, NULL); +} + +static void +_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + sd->x = x; + sd->y = y; + _e_smart_reconfigure(obj); +} + +static void +_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + sd->w = w; + sd->h = h; + _e_smart_reconfigure(obj); + evas_object_smart_callback_call(obj, "changed", NULL); +} + +static void +_e_smart_show(Evas_Object *obj EINA_UNUSED) +{ +// Smart_Data *sd = evas_object_smart_data_get(obj); +// evas_object_show(sd->child_obj); +} + +static void +_e_smart_hide(Evas_Object *obj EINA_UNUSED) +{ +// Smart_Data *sd = evas_object_smart_data_get(obj); +// evas_object_hide(sd->child_obj); +} + +static void +_e_smart_color_set(Evas_Object *obj EINA_UNUSED, int r EINA_UNUSED, int g EINA_UNUSED, int b EINA_UNUSED, int a EINA_UNUSED) +{ +// Smart_Data *sd = evas_object_smart_data_get(obj); +// evas_object_color_set(sd->child_obj, r, g, b, a); +} + +static void +_e_smart_clip_set(Evas_Object *obj EINA_UNUSED, Evas_Object * clip EINA_UNUSED) +{ +// Smart_Data *sd = evas_object_smart_data_get(obj); +// evas_object_clip_set(sd->child_obj, clip); +} + +static void +_e_smart_clip_unset(Evas_Object *obj EINA_UNUSED) +{ +// Smart_Data *sd = evas_object_smart_data_get(obj); +// evas_object_clip_unset(sd->child_obj); +} + +static Evas_Object * +_pan_add(Evas *evas) +{ + static Evas_Smart *smart = NULL; + static const Evas_Smart_Class sc = + { + "wp_pan", + EVAS_SMART_CLASS_VERSION, + _e_smart_add, + _e_smart_del, + _e_smart_move, + _e_smart_resize, + _e_smart_show, + _e_smart_hide, + _e_smart_color_set, + _e_smart_clip_set, + _e_smart_clip_unset, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL + }; + smart = evas_smart_class_new(&sc); + return evas_object_smart_add(evas, smart); +} + +static void +_pan_info_set(Evas_Object *obj, Info *info) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + sd->info = info; +} + +static Eina_Bool +_sel_anim(void *data) +{ + Evas_Object *obj = data; + Smart_Data *sd = evas_object_smart_data_get(obj); + double t = ecore_loop_time_get() - sd->seltime; + double len = 1.0; + double p = t / len; + double d; + + if (p > 1.0) p = 1.0; + if (!sd->selin) + { + d = (p * 2) - 1.0; + if (d > 0.0) + { + d = 1.0 - d; + d = d * d * d; + d = 1.0 - d; + } + else + { + d = -1.0 - d; + d = d * d * d; + d = -1.0 - d; + } + d = (1.0 + d) / 2.0; + sd->selmove = d; + } + else + { + d = ((1.0 - p) * 2) - 1.0; + if (d > 0.0) + { + d = 1.0 - d; + d = d * d * d; + d = 1.0 - d; + } + else + { + d = -1.0 - d; + d = d * d * d; + d = -1.0 - d; + } + d = (1.0 + d) / 2.0; + sd->selmove = d; + } + _e_smart_reconfigure(obj); + if (p == 1.0) + { + if (sd->selout) + { + sd->selin = EINA_TRUE; + sd->selout = EINA_FALSE; + sd->seltime = ecore_loop_time_get(); + return ECORE_CALLBACK_RENEW; + } + sd->selout = EINA_FALSE; + sd->selin = EINA_FALSE; + sd->animator = NULL; + return ECORE_CALLBACK_CANCEL; + } + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_sel_timer(void *data) +{ + Evas_Object *obj = data; + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (!sd->animator) + { + sd->seltime = ecore_time_get(); + sd->animator = ecore_animator_add(_sel_anim, obj); + sd->selin = EINA_FALSE; + } + sd->seltimer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +static void +_pan_unhilight(Evas_Object *obj EINA_UNUSED, Item *it) +{ +// Smart_Data *sd = evas_object_smart_data_get(obj); + if (!it->hilighted) return; + it->hilighted = 0; + if (it->frame) + edje_object_signal_emit(it->frame, "e,state,unselected", "e"); +} + +static void +_pan_hilight(Evas_Object *obj EINA_UNUSED, Item *it) +{ + Eina_List *l; + Item *it2; + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (it->hilighted) return; + EINA_LIST_FOREACH(sd->items, l, it2) + { + if (it2->hilighted) + { + _pan_unhilight(obj, it2); + break; + } + } + it->hilighted = 1; + if (it->frame) + { + edje_object_signal_emit(it->frame, "e,state,selected", "e"); + evas_object_raise(it->frame); + } +} + + +static void +_pan_sel(Evas_Object *obj, Item *it) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (sd->selmove > 0.0) return; + edje_object_signal_emit(it->frame, "e,state,selected", "e"); + evas_object_raise(it->frame); + if (!it->selected) + { + Eina_List *l; + Item *it2; + + EINA_LIST_FOREACH(sd->items, l, it2) + { + if (it2->selected) it2->selected = 0; + } + it->selected = EINA_TRUE; + eina_stringshare_del(sd->info->bg_file); + evas_object_hide(sd->info->mini); + if (it->file) + { + char *name = NULL, *p; + + sd->info->use_theme_bg = 0; + sd->info->bg_file = eina_stringshare_ref(it->file); + edje_object_file_set(sd->info->mini, sd->info->bg_file, + "e/desktop/background"); + p = strrchr(sd->info->bg_file, '/'); + if (p) + { + p++; + name = strdupa(p); + p = strrchr(name, '.'); + if (p) *p = 0; + } + edje_object_part_text_set(sd->info->bg, "e.text.filename", name); + } + else + { + const char *f = e_theme_edje_file_get("base/theme/backgrounds", + "e/desktop/background"); + + edje_object_file_set(sd->info->mini, f, "e/desktop/background"); + sd->info->use_theme_bg = 1; + sd->info->bg_file = NULL; + edje_object_part_text_set(sd->info->bg, "e.text.filename", + D_("Theme Wallpaper")); + } + evas_object_show(sd->info->mini); + } + if (sd->seltimer) ecore_timer_del(sd->seltimer); + sd->seltimer = ecore_timer_add(0.2, _sel_timer, obj); +} + +static void +_pan_sel_up(Evas_Object *obj) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + + if (sd->selmove == 0.0) return; + if (!sd->animator) + { + sd->seltime = ecore_loop_time_get(); + sd->animator = ecore_animator_add(_sel_anim, obj); + sd->selin = EINA_TRUE; + } + else + { + if (sd->selin) return; + sd->selout = EINA_TRUE; + } +} + +static int +_sort_cb(const void *d1, const void *d2) +{ + const Item *it1 = d1, *it2 = d2; + + if ((!it1->sort_id) || (!it2->sort_id)) return 0; + return strcmp(it1->sort_id, it2->sort_id); +} + +static void +_item_sort(Item *it) +{ + Evas_Object *obj = it->obj; + Smart_Data *sd = evas_object_smart_data_get(obj); + int num, dosort = 0; + + sd->id_num++; + sd->info->scans--; + num = eina_list_count(sd->items); +// if (sd->sort_num < sd->id_num) +// { +// sd->sort_num = sd->id_num + 10; +// dosort = 1; +// } + if ((sd->id_num == num) || (dosort)) + { + sd->items = eina_list_sort(sd->items, num, _sort_cb); + _e_smart_reconfigure_do(obj); + if (sd->jump2hi) + { + Eina_List *l; + Item *it2 = NULL; + + EINA_LIST_FOREACH(sd->items, l, it2) + { + if (it2->hilighted) break; + it2 = NULL; + } + if (it2) + e_scrollframe_child_region_show(sd->info->sframe, + it2->x, it2->y, it2->w, it2->h); + sd->jump2hi = 1; + } + } + if (sd->info->scans == 0) + edje_object_signal_emit(sd->info->bg, "e,state,busy,off", "e"); +} + +static void +_thumb_gen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Item *it = data; + + edje_object_signal_emit(it->frame, "e,action,thumb,gen", "e"); + if (!it->sort_id) + { + const char *id = e_thumb_sort_id_get(it->image); + + if (id) + { + it->sort_id = strdup(id); + _item_sort(it); + } + } + it->have_thumb = EINA_TRUE; + if (!it->visible) + { + if (it->do_thumb) + { + e_thumb_icon_end(it->image); + it->do_thumb = EINA_FALSE; + } + evas_object_del(it->image); + it->image = NULL; + evas_object_del(it->frame); + it->frame = NULL; + } +} + +static void +_item_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ +// Evas_Event_Mouse_Down *ev = event_info; +// Item *it = data; +// _pan_sel(it->obj, it); +} + +static void +_item_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) +{ + Evas_Event_Mouse_Up *ev = event_info; + Item *it = data; + + if (ev->button == 1) + { + if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)) + { + _pan_hilight(it->obj, it); + _pan_sel(it->obj, it); + // FIXME: select image!!! + } + } +} + +static void +_pan_file_add(Evas_Object *obj, const char *file, Eina_Bool remote, Eina_Bool theme) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + Item *it = calloc(1, sizeof(Item)); + Evas *evas; + + if (!it) return; + evas = evas_object_evas_get(obj); + sd->items = eina_list_append(sd->items, it); + it->obj = obj; + it->remote = remote; + it->theme = theme; + it->file = eina_stringshare_add(file); + it->frame = edje_object_add(evas); + if (it->theme) + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/conf/wallpaper/main/mini-theme"); + else if (it->remote) + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/conf/wallpaper/main/mini-remote"); + else + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/conf/wallpaper/main/mini"); + if (it->hilighted) + { + edje_object_signal_emit(it->frame, "e,state,selected", "e"); + evas_object_raise(it->frame); + } + evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN, + _item_down, it); + evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP, + _item_up, it); + + evas_object_smart_member_add(it->frame, obj); + evas_object_clip_set(it->frame, evas_object_clip_get(obj)); + evas_object_show(it->frame); + it->image = e_thumb_icon_add(evas); + edje_object_part_swallow(it->frame, "e.swallow.content", it->image); + evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it); + if (it->theme) + { + const char *f = e_theme_edje_file_get("base/theme/backgrounds", + "e/desktop/background"); + + e_thumb_icon_file_set(it->image, f, "e/desktop/background"); + } + else + e_thumb_icon_file_set(it->image, it->file, "e/desktop/background"); + e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih); + evas_object_show(it->image); + + e_thumb_icon_begin(it->image); + it->do_thumb = 1; +// e_thumb_icon_begin(it->image); + + if (it->theme) + { + if (sd->info->use_theme_bg) + { + _pan_hilight(it->obj, it); + edje_object_part_text_set(sd->info->bg, "e.text.filename", + D_("Theme Wallpaper")); + } + } + else + { + if (sd->info->bg_file) + { + int match = 0; + + if (sd->info->bg_file == it->file) match = 1; + if (!match) + { + const char *p1, *p2; + + p1 = ecore_file_file_get(sd->info->bg_file); + p2 = ecore_file_file_get(it->file); + if (!strcmp(p1, p2)) match = 1; + } + if (match) + { + char *name = NULL, *p; + + sd->jump2hi = 1; + _pan_hilight(it->obj, it); + p = strrchr(sd->info->bg_file, '/'); + if (p) + { + p++; + name = strdupa(p); + p = strrchr(name, '.'); + if (p) *p = 0; + } + edje_object_part_text_set(sd->info->bg, "e.text.filename", name); + } + } + } + _e_smart_reconfigure(obj); +} + +//////// + +static void +_resize(E_Win *wn) +{ + Info *info = wn->data; + + evas_object_resize(info->bg, wn->w, wn->h); +} + +static void +_delete(E_Win *wn EINA_UNUSED) +{ + e_object_del(E_OBJECT(global_info->win)); +} + +static void +_bg_clicked(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED) +{ + Info *info = data; + + _pan_sel_up(info->span); +} + +static void +_apply(void *data, void *data2 EINA_UNUSED) +{ + Info *info = data; + + if (info->mode == 0) + { + /* all desktops */ + while (e_config->desktop_backgrounds) + { + E_Config_Desktop_Background *cfbg; + + cfbg = e_config->desktop_backgrounds->data; + e_bg_del(cfbg->manager, cfbg->zone, cfbg->desk_x, cfbg->desk_y); + } + if ((info->use_theme_bg) || (!info->bg_file)) + e_bg_default_set(NULL); + else + e_bg_default_set(info->bg_file); + } + else if (info->mode == 1) + { + /* specific desk */ + e_bg_del(info->man_num, info->zone_num, info->desk_x, info->desk_y); + e_bg_add(info->man_num, info->zone_num, info->desk_x, info->desk_y, + info->bg_file); + } + else + { + Eina_List *dlist = NULL, *l; + E_Config_Desktop_Background *cfbg; + + /* this screen */ + EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg) + { + if (cfbg->zone == info->zone_num) + dlist = eina_list_append(dlist, cfbg); + } + EINA_LIST_FREE(dlist, cfbg) + e_bg_del(cfbg->manager, cfbg->zone, cfbg->desk_x, cfbg->desk_y); + e_bg_add(info->man_num, info->zone_num, -1, -1, info->bg_file); + } + e_bg_update(); + e_config_save_queue(); +} + +static void +_close(void *data EINA_UNUSED, void *data2 EINA_UNUSED) +{ + e_object_del(E_OBJECT(global_info->win)); +} + +static void +_ok(void *data, void *data2 EINA_UNUSED) +{ + _apply(data, data2); + e_object_del(E_OBJECT(global_info->win)); +} + +static void +_wp_add(void *data, void *data2 EINA_UNUSED) +{ + Info *info = data; + + edje_object_signal_emit(info->bg, "e,action,panel,hide", "e"); +} + +static void +_wp_delete(void *data, void *data2 EINA_UNUSED) +{ + Info *info = data; + + edje_object_signal_emit(info->bg, "e,action,panel,hide", "e"); +} + +static void +_wp_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Info *info = data; + + edje_object_signal_emit(info->bg, "e,action,panel,hide", "e"); +} + +static Eina_Bool +_idler(void *data) +{ + Eina_File_Direct_Info *st; + Info *info = data; + + if (!info->dir) + { + info->idler = NULL; + return ECORE_CALLBACK_CANCEL; + } + if (!eina_iterator_next(info->dir, (void**) &st)) + { + E_FREE(info->curdir); + eina_iterator_free(info->dir); + info->dir = NULL; + info->idler = NULL; + _scan(info); + return ECORE_CALLBACK_CANCEL; + } + if ((st->path[st->name_start]) == '.') + return ECORE_CALLBACK_RENEW; + if (st->type == EINA_FILE_DIR) + { + info->dirs = eina_list_append(info->dirs, strdup(st->path)); + return ECORE_CALLBACK_RENEW; + } + info->scans++; + _pan_file_add(info->span, st->path, 0, 0); + + e_util_wakeup(); + return ECORE_CALLBACK_RENEW; +} + +static void +_scan(Info *info) +{ + if (info->dirs) + { + if (info->scans <= 0) + { + info->scans = 0; + edje_object_signal_emit(info->bg, "e,state,busy,on", "e"); + edje_object_part_text_set(info->bg, "e.text.busy_label", + D_("Loading files...")); + } + free(info->curdir); + info->curdir = info->dirs->data; + info->dirs = eina_list_remove_list(info->dirs, info->dirs); + if (!info->dir) info->dir = eina_file_stat_ls(info->curdir); + info->idler = ecore_idler_add(_idler, info); + } +} + +Info * +wp_browser_new(E_Comp *comp) +{ + Info *info; + E_Win *win; + E_Zone *zone; + E_Desk *desk; + const E_Config_Desktop_Background *cfbg; + Evas_Coord mw, mh; + Evas_Object *o, *o2, *ob; + E_Radio_Group *rg; + char buf[PATH_MAX]; + + info = calloc(1, sizeof(Info)); + if (!info) return NULL; + + zone = e_zone_current_get(comp); + desk = e_desk_current_get(zone); + info->man_num = comp->num; + info->zone_num = zone->num; + info->desk_x = desk->x; + info->desk_y = desk->y; + info->mode = 0; + cfbg = e_bg_config_get(comp->num, zone->num, desk->x, desk->y); + if (cfbg) + { + if ((cfbg->manager >= 0) && (cfbg->zone >= 0)) + { + if ((cfbg->desk_x >= 0) && (cfbg->desk_y >= 0)) + info->mode = 1; + else + info->mode = 2; + } + info->bg_file = eina_stringshare_ref(cfbg->file); + } + if ((!info->bg_file) && (e_config->desktop_default_background)) + info->bg_file = eina_stringshare_ref(e_config->desktop_default_background); + else + info->use_theme_bg = 1; + + info->iw = (120 * e_scale); + info->ih = (zone->h * info->iw) / (zone->w); + + win = e_win_new(comp); + if (!win) + { + eina_stringshare_del(info->bg_file); + free(info); + return NULL; + } + info->win = win; + win->data = info; + + e_user_dir_concat_static(buf, "backgrounds"); + info->dirs = eina_list_append(info->dirs, strdup(buf)); + e_prefix_data_concat_static(buf, "data/backgrounds"); + info->dirs = eina_list_append(info->dirs, strdup(buf)); + + e_win_title_set(win, D_("Wallpaper Settings")); + e_win_name_class_set(win, "E", "_config::appearance/wallpaper2"); + e_win_resize_callback_set(win, _resize); + e_win_delete_callback_set(win, _delete); + + // bg + manager + info->bg = edje_object_add(info->win->evas); + e_theme_edje_object_set(info->bg, "base/theme/widgets", + "e/conf/wallpaper/main/window"); + edje_object_signal_callback_add(info->bg, "e,action,click", "e", + _bg_clicked, info); + + info->box = e_widget_list_add(info->win->evas, 1, 1); + + // ok button + info->button = e_widget_button_add(info->win->evas, D_("OK"), NULL, + _ok, info, NULL); + evas_object_show(info->button); + e_widget_list_object_append(info->box, info->button, 1, 0, 0.5); + + // apply button + info->button = e_widget_button_add(info->win->evas, D_("Apply"), NULL, + _apply, info, NULL); + evas_object_show(info->button); + e_widget_list_object_append(info->box, info->button, 1, 0, 0.5); + + // close button + info->button = e_widget_button_add(info->win->evas, D_("Close"), NULL, + _close, info, NULL); + evas_object_show(info->button); + e_widget_list_object_append(info->box, info->button, 1, 0, 0.5); + + e_widget_size_min_get(info->box, &mw, &mh); + evas_object_size_hint_min_set(info->box, mw, mh); + edje_object_part_swallow(info->bg, "e.swallow.buttons", info->box); + evas_object_show(info->box); + + // preview + info->preview = e_livethumb_add(info->win->evas); + e_livethumb_vsize_set(info->preview, zone->w, zone->h); + edje_extern_object_aspect_set(info->preview, EDJE_ASPECT_CONTROL_NEITHER, + zone->w, zone->h); + edje_object_part_swallow(info->bg, "e.swallow.preview", info->preview); + evas_object_show(info->preview); + + info->mini = edje_object_add(e_livethumb_evas_get(info->preview)); + e_livethumb_thumb_set(info->preview, info->mini); + evas_object_show(info->mini); + if (info->bg_file) + edje_object_file_set(info->mini, info->bg_file, "e/desktop/background"); + else + { + const char *f = e_theme_edje_file_get("base/theme/backgrounds", + "e/desktop/background"); + + edje_object_file_set(info->mini, f, "e/desktop/background"); + } + + // scrolled thumbs + info->span = _pan_add(info->win->evas); + _pan_info_set(info->span, info); + + // the scrollframe holding the scrolled thumbs + info->sframe = e_scrollframe_add(info->win->evas); + e_scrollframe_custom_theme_set(info->sframe, "base/theme/widgets", + "e/conf/wallpaper/main/scrollframe"); + e_scrollframe_extern_pan_set(info->sframe, info->span, + _pan_set, _pan_get, _pan_max_get, + _pan_child_size_get); + edje_object_part_swallow(info->bg, "e.swallow.list", info->sframe); + evas_object_show(info->sframe); + evas_object_show(info->span); + + ob = e_widget_list_add(info->win->evas, 0, 1); + + o = e_widget_list_add(info->win->evas, 1, 0); + + rg = e_widget_radio_group_new(&(info->mode)); + o2 = e_widget_radio_add(info->win->evas, D_("All Desktops"), 0, rg); + evas_object_smart_callback_add(o2, "changed", _wp_changed, info); + e_widget_list_object_append(o, o2, 1, 0, 0.5); + e_widget_disabled_set(o2, (e_util_comp_desk_count_get(comp) < 2)); + evas_object_show(o2); + + o2 = e_widget_radio_add(info->win->evas, D_("This Desktop"), 1, rg); + evas_object_smart_callback_add(o2, "changed", _wp_changed, info); + e_widget_list_object_append(o, o2, 1, 0, 0.5); + evas_object_show(o2); + + o2 = e_widget_radio_add(info->win->evas, D_("This Screen"), 2, rg); + evas_object_smart_callback_add(o2, "changed", _wp_changed, info); + e_widget_list_object_append(o, o2, 1, 0, 0.5); + if (!(e_util_comp_zone_number_get(0, 1) || + (e_util_comp_zone_number_get(1, 0)))) + e_widget_disabled_set(o2, EINA_TRUE); + evas_object_show(o2); + + e_widget_list_object_append(ob, o, 1, 0, 0.5); + evas_object_show(o); + + o = e_widget_list_add(info->win->evas, 1, 0); + + o2 = e_widget_button_add(info->win->evas, D_("Add"), NULL, + _wp_add, info, NULL); + e_widget_list_object_append(o, o2, 1, 0, 0.5); + evas_object_show(o2); + + o2 = e_widget_button_add(info->win->evas, D_("Delete"), NULL, + _wp_delete, info, NULL); + e_widget_list_object_append(o, o2, 1, 0, 0.5); + evas_object_show(o2); + + e_widget_list_object_append(ob, o, 1, 0, 0.5); + evas_object_show(o); + + e_widget_size_min_get(ob, &mw, &mh); + evas_object_size_hint_min_set(ob, mw, mh); + edje_object_part_swallow(info->bg, "e.swallow.extras", ob); + evas_object_show(ob); + + // min size calc + edje_object_size_min_calc(info->bg, &mw, &mh); + e_win_size_min_set(win, mw, mh); + if ((zone->w / 4) > mw) mw = (zone->w / 4); + if ((zone->h / 4) > mh) mh = (zone->h / 4); + e_win_resize(win, mw, mh); + e_win_centered_set(win, 1); + e_win_show(win); + e_win_client_icon_set(win, "preferences-desktop-wallpaper"); + + evas_object_resize(info->bg, info->win->w, info->win->h); + evas_object_show(info->bg); + + // add theme bg + _pan_file_add(info->span, NULL, 0, 1); + + _scan(info); + return info; +} + +void +wp_broser_free(Info *info) +{ + char *s; + + if (!info) return; + if (info->win) e_object_del(E_OBJECT(info->win)); + if (info->dir) eina_iterator_free(info->dir); + eina_stringshare_del(info->bg_file); + free(info->curdir); + EINA_LIST_FREE(info->dirs, s) + free(s); + if (info->idler) ecore_idler_del(info->idler); + // del other stuff + E_FREE(info); +} + +E_Config_Dialog * +wp_conf_show(E_Comp *comp, const char *params EINA_UNUSED) +{ + if (global_info) + { + e_win_show(global_info->win); + e_win_raise(global_info->win); + } + global_info = wp_browser_new(comp); + + return NULL; +} + +void +wp_conf_hide(void) +{ + if (global_info) + { + wp_broser_free(global_info); + global_info = NULL; + } +} diff --git a/src/e_mod_main.c b/src/e_mod_main.c new file mode 100644 index 0000000..05cf1f6 --- /dev/null +++ b/src/e_mod_main.c @@ -0,0 +1,97 @@ +#include "e.h" +#include "e_mod_main.h" + +/* actual module specifics */ +static void _e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi); +static void _e_mod_menu_add(void *data, E_Menu *m); + +static E_Module *conf_module = NULL; +static E_Int_Menu_Augmentation *maug = NULL; +//static E_Fm2_Mime_Handler *import_hdl = NULL; + +/* module setup */ +EAPI E_Module_Api e_modapi = +{ + E_MODULE_API_VERSION, + "Settings - Wallpaper 2" +}; + +EAPI void * +e_modapi_init(E_Module *m) +{ + bindtextdomain(PACKAGE, LOCALEDIR); + bind_textdomain_codeset(PACKAGE, "UTF-8"); + + e_configure_registry_category_add("appearance", 10, D_("Look"), NULL, "preferences-look"); + e_configure_registry_item_add("appearance/wallpaper2", 10, D_("Wallpaper 2"), NULL, "preferences-desktop-wallpaper", wp_conf_show); + e_configure_registry_category_add("internal", -1, D_("Internal"), NULL, "enlightenment/internal"); +// e_configure_registry_item_add("internal/wallpaper_desk", -1, D_("Wallpaper 2"), NULL, "preferences-system-windows", e_int_config_wallpaper_desk); + maug = e_int_menus_menu_augmentation_add_sorted + ("config/1", D_("Wallpaper 2"), _e_mod_menu_add, NULL, NULL, NULL); + +// import_hdl = e_fm2_mime_handler_new(_("Set As Background 2"), "preferences-desktop-wallpaper", +// e_int_config_wallpaper_handler_set, NULL, +// e_int_config_wallpaper_handler_test, NULL); +// if (import_hdl) +// { +// e_fm2_mime_handler_mime_add(import_hdl, "image/png"); +// e_fm2_mime_handler_mime_add(import_hdl, "image/jpeg"); +// } + + conf_module = m; + e_module_delayed_set(m, 1); + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m EINA_UNUSED) +{ +// E_Config_Dialog *cfd; + /* remove module-supplied menu additions */ + if (maug) + { + e_int_menus_menu_augmentation_del("config/1", maug); + maug = NULL; + } +// while ((cfd = e_config_dialog_get("E", "appearance/wallpaper2"))) +// e_object_del(E_OBJECT(cfd)); +// e_configure_registry_item_del("internal/wallpaper_desk"); + e_configure_registry_category_del("internal"); + e_configure_registry_item_del("appearance/wallpaper2"); + e_configure_registry_category_del("appearance"); + +// if (import_hdl) +// { +// e_fm2_mime_handler_mime_del(import_hdl, "image/png"); +// e_fm2_mime_handler_mime_del(import_hdl, "image/jpeg"); +// e_fm2_mime_handler_free(import_hdl); +// } + + conf_module = NULL; + return 1; +} + +EAPI int +e_modapi_save(E_Module *m EINA_UNUSED) +{ + return 1; +} + +/* menu item callback(s) */ +static void +_e_mod_run_cb(void *data EINA_UNUSED, E_Menu *m, E_Menu_Item *mi EINA_UNUSED) +{ + e_configure_registry_call("appearance/wallpaper2", m->zone->comp, NULL); +} + +/* menu item add hook */ +static void +_e_mod_menu_add(void *data EINA_UNUSED, E_Menu *m) +{ + E_Menu_Item *mi; + + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, D_("Wallpaper 2")); + e_util_menu_item_theme_icon_set(mi, "preferences-desktop-wallpaper"); + e_menu_item_callback_set(mi, _e_mod_run_cb, NULL); +} diff --git a/src/e_mod_main.h b/src/e_mod_main.h new file mode 100644 index 0000000..207e207 --- /dev/null +++ b/src/e_mod_main.h @@ -0,0 +1,34 @@ +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + +#ifdef ENABLE_NLS +# include +# define D_(str) dgettext(PACKAGE, str) +# define DP_(str, str_p, n) dngettext(PACKAGE, str, str_p, n) +#else +# define bindtextdomain(domain,dir) +# define bind_textdomain_codeset(domain,codeset) +# define D_(str) (str) +# define DP_(str, str_p, n) (str_p) +#endif + +#define N_(str) (str) + +E_Config_Dialog *wp_conf_show(E_Comp *comp, const char *params); +void wp_conf_hide(void); + +/** + * @addtogroup Optional_Conf + * @{ + * + * @defgroup Module_Conf_Wallpaper2 Wallpaper2 (Alternative Selector) + * + * More graphically appealing wallpaper selector. It is targeted at + * mobile devices. + * + * @note under development and not recommended for use yet. + * + * @see Module_Conf_Theme + * @} + */ +#endif