summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-06-17 09:34:37 -0400
committerMike Blumenkrantz <zmike@samsung.com>2014-06-17 09:34:37 -0400
commit8fbb4723ccd103aba9cae126db733c405c2282fd (patch)
tree103794d60e7402685103f9396c90033abf88824d
-rw-r--r--.gitignore48
-rw-r--r--AUTHORS1
-rw-r--r--COPYING25
-rw-r--r--ChangeLog0
-rw-r--r--Makefile.am70
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh17
-rw-r--r--configure.ac77
-rw-r--r--e_modules-wallpaper2.spec.in47
-rw-r--r--module.desktop.in33
-rw-r--r--po/LINGUAS0
-rw-r--r--po/Makevars42
-rw-r--r--po/POTFILES.in3
-rw-r--r--po/wallpaper2.pot74
-rw-r--r--src/Makefile.am21
-rw-r--r--src/e_int_config_wallpaper.c1352
-rw-r--r--src/e_mod_main.c97
-rw-r--r--src/e_mod_main.h34
19 files changed, 1941 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..171da42
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,48 @@
1*~
2*.swo
3*.swp
4*.o
5*.lo
6*.la
7ABOUT-NLS
8INSTALL
9Makefile
10Makefile.in
11aclocal.m4
12autom4te.cache/
13config.guess
14config.h
15config.h.in
16config.log
17config.rpath
18config.status
19config.sub
20configure
21configure.ac.orig
22depcomp
23e_modules-*.spec
24install-sh
25libtool
26ltmain.sh
27*.m4
28missing
29mkinstalldirs
30module.desktop
31po/Makefile
32po/Makefile.in
33po/Makefile.in.in
34po/Makevars.template
35po/POTFILES
36po/Rules-quot
37po/*.gmo
38po/boldquot.sed
39po/en@boldquot.header
40po/en@quot.header
41po/insert-header.sin
42po/quot.sed
43po/remove-potcdate.sed
44po/remove-potcdate.sin
45po/stamp-po
46src/.deps/
47src/.libs/
48stamp-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) <raster@rasterman.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..4556b54
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,25 @@
1Copyright notice for Enlightenment:
2
3Copyright (C) 2000-2012 Carsten Haitzler and various contributors (see AUTHORS)
4
5All rights reserved.
6
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions are met:
9
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..ec79818
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,70 @@
1ACLOCAL_AMFLAGS = -I m4
2
3MAINTAINERCLEANFILES = \
4m4/libtool.m4 \
5m4/wchar_t.m4 \
6m4/uintmax_t.m4 \
7m4/inttypes-pri.m4 \
8m4/xsize.m4 \
9m4/longdouble.m4 \
10m4/nls.m4 \
11m4/lt~obsolete.m4 \
12m4/wint_t.m4 \
13m4/isc-posix.m4 \
14m4/printf-posix.m4 \
15m4/po.m4 \
16m4/signed.m4 \
17m4/lcmessage.m4 \
18m4/intmax.m4 \
19m4/ltoptions.m4 \
20m4/ulonglong.m4 \
21m4/progtest.m4 \
22m4/glibc21.m4 \
23m4/inttypes.m4 \
24m4/codeset.m4 \
25m4/stdint_h.m4 \
26m4/ltsugar.m4 \
27m4/longlong.m4 \
28m4/inttypes_h.m4 \
29m4/lib-ld.m4 \
30m4/lib-link.m4 \
31m4/gettext.m4 \
32m4/size_max.m4 \
33m4/ltversion.m4 \
34m4/lib-prefix.m4 \
35m4/iconv.m4 \
36m4/intdiv0.m4 \
37Makefile.in \
38aclocal.m4 \
39config.guess \
40config.h.in \
41config.sub \
42configure \
43depcomp \
44install-sh \
45ltmain.sh \
46missing \
47module.\
48desktop \
49config.rpath \
50mkinstalldirs
51
52SUBDIRS = src
53
54if HAVE_PO
55
56SUBDIRS += po
57
58endif
59
60filesdir = $(module_dir)/$(PACKAGE)
61files_DATA = module.desktop
62
63EXTRA_DIST = module.desktop.in
64
65clean-local:
66 rm -rf *.edj module.desktop *~
67
68uninstall-local:
69 rm -rf $(DESTDIR)$(module_dir)/$(PACKAGE)
70
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..ae01364
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,17 @@
1#!/bin/sh
2
3rm -rf autom4te.cache
4rm -f aclocal.m4 ltmain.sh
5
6touch README
7
8echo "Running autopoint..." ; autopoint -f || :
9echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1
10echo "Running autoheader..." ; autoheader || exit 1
11echo "Running autoconf..." ; autoconf || exit 1
12echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
13echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
14
15if [ -z "$NOCONFIGURE" ]; then
16 ./configure "$@"
17fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..222f2ad
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,77 @@
1dnl Process this file with autoconf to produce a configure script.
2
3# get rid of that stupid cache mechanism
4rm -f config.cache
5
6AC_INIT(wallpaper2, 0.1, enlightenment-devel@lists.sourceforge.net)
7AC_CONFIG_MACRO_DIR([m4])
8AC_PREREQ(2.52)
9AC_CONFIG_SRCDIR(configure.ac)
10AC_CANONICAL_BUILD
11AC_CANONICAL_HOST
12AC_ISC_POSIX
13
14AM_INIT_AUTOMAKE([1.8 dist-bzip2])
15AM_CONFIG_HEADER(config.h)
16m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
17
18AC_PROG_CC
19AM_PROG_CC_STDC
20
21define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
22define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
23AC_PROG_LIBTOOL
24
25m4_ifdef([AM_GNU_GETTEXT_VERSION], [
26AM_GNU_GETTEXT_VERSION([0.14])
27])
28
29m4_ifdef([AM_GNU_GETTEXT], [
30AM_GNU_GETTEXT([external])
31po_makefile_in=po/Makefile.in
32AM_CONDITIONAL([HAVE_PO], [true])
33],[
34AM_CONDITIONAL([HAVE_PO], [false])
35])
36AC_SUBST(LTLIBINTL)
37
38PKG_CHECK_MODULES([E], [enlightenment > 0.18.99])
39release=$(pkg-config --variable=release enlightenment)
40MODULE_ARCH="$host_os-$host_cpu-$release"
41AC_SUBST(MODULE_ARCH)
42AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
43
44module_dir="$(pkg-config --variable=modules enlightenment)"
45AC_SUBST(module_dir)
46datadir="$module_dir/wallpaper2"
47# Find edje_cc
48##AC_ARG_WITH(edje-cc,
49## AC_HELP_STRING([--with-edje-cc=PATH], [specify a specific path to edje_cc]),
50## [
51## v=$withval;
52## EDJE_CC=$v
53## ],[
54## EDJE_CC=$(pkg-config --variable=prefix edje)/bin/edje_cc
55## ]
56##)
57##AC_SUBST(EDJE_CC)
58##AC_MSG_CHECKING([Which edje_cc to use])
59##AC_MSG_RESULT(${EDJE_CC})
60
61m4_ifdef([v_mic],
62 [
63 EFL_COMPILER_FLAG([-Wshadow])
64 EFL_COMPILER_FLAG([-Wall])
65 EFL_COMPILER_FLAG([-Wpointer-arith])
66 EFL_COMPILER_FLAG([-W])
67 EFL_COMPILER_FLAG([-Wno-missing-field-initializers])
68 ])
69
70AC_OUTPUT([
71Makefile
72src/Makefile
73module.desktop
74$po_makefile_in
75], [
76])
77
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 @@
1%define module_name wallpaper2
2%{!?_rel:%{expand:%%global _rel 0.enl%{?dist}}}
3
4Summary: %{module_name} module for the Enlightenment window manager
5Name: e_modules-%{module_name}
6Version: @VERSION@
7Release: %{_rel}
8License: BSD
9Group: User Interface/Desktops
10URL: http://www.enlightenment.org/
11Source: ftp://ftp.enlightenment.org/pub/enlightenment/%{module_name}-%{version}.tar.gz
12Packager: %{?_packager:%{_packager}}%{!?_packager:Michael Jennings <mej@eterm.org>}
13Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)}
14Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
15BuildRequires: enlightenment-devel >= 0.18.999
16Requires: enlightenment >= 0.18.999
17BuildRoot: %{_tmppath}/%{name}-%{version}-root
18
19%description
20%{module_name} module for the Enlightenment window manager.
21
22%prep
23%setup -q -n %{module_name}-%{version}
24
25%build
26%{configure}
27%{__make} %{?_smp_mflags} %{?mflags}
28
29%install
30%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install
31%{find_lang} %{module_name} || true > %{module_name}.lang
32
33%clean
34test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
35
36%post
37/sbin/ldconfig
38
39%postun
40/sbin/ldconfig
41
42%files -f %{module_name}.lang
43%defattr(-, root, root)
44%doc AUTHORS ChangeLog COPYING* INSTALL NEWS README
45%{_libdir}/enlightenment/modules/%{module_name}*
46
47%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 @@
1[Desktop Entry]
2Encoding=UTF-8
3Type=Link
4Name=Wallpaper 2
5Name[ca]=Fons d'escriptori
6Name[cs]=Pozadí plochy
7Name[eo]=Tapeto
8Name[es]=Fondo de pantalla
9Name[fr]=Fond d'écran 2
10Name[gl]=Fondo de escritorio 2
11Name[hu]=Háttérkép
12Name[it]=Sfondo 2
13Name[ms]=Kertas Dinding 2
14Name[pt]=Papel de parede 2
15Name[ru]=Обои 2
16Name[sr]=Позадина површи 2
17Name[tr]=Duvarkağıdı 2
18Comment=Used to pick a wallpaper.
19Comment[ca]=Permet seleccionar el fons d'escriptori.
20Comment[cs]=Použit k volbě pozadí.
21Comment[eo]=Elekti tapeton.
22Comment[es]=Para elegir un fondo de pantalla.
23Comment[fr]=Sélection du fond d'écran.
24Comment[gl]=Usado para escoller un fondo de pantalla.
25Comment[hu]=Háttérkép beállító modul.
26Comment[it]=Usato per selezionare uno sfondo.
27Comment[ms]=Digunakan untuk mendapatkan kertas dinding.
28Comment[pt]=Permite-lhe escolher o papel de parede
29Comment[ru]=Используется для выбора обоев.
30Comment[sr]=Користи се за одабир слике радне површи.
31Comment[tr]=Duvarkağıdı seçiminde kullanılır.
32Icon=preferences-desktop-wallpaper
33X-Enlightenment-ModuleType=settings
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/po/LINGUAS
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..5b54556
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,42 @@
1# Makefile variables for PO directory in any package using GNU gettext.
2
3# Usually the message domain is the same as the package name.
4DOMAIN = $(PACKAGE)
5
6# These two variables depend on the location of this directory.
7subdir = po
8top_builddir = ..
9
10# These options get passed to xgettext.
11XGETTEXT_OPTIONS = --keyword=N_ --keyword=D_ --keyword=DP_:1,2 \
12 --from-code=UTF-8 --foreign-user
13
14# This is the copyright holder that gets inserted into the header of the
15# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
16# package. (Note that the msgstr strings, extracted from the package's
17# sources, belong to the copyright holder of the package.) Translators are
18# expected to transfer the copyright for their translations to this person
19# or entity, or to disclaim their copyright. The empty string stands for
20# the public domain; in this case the translators are expected to disclaim
21# their copyright.
22COPYRIGHT_HOLDER = Enlightenment development team
23
24# This is the email address or URL to which the translators shall report
25# bugs in the untranslated strings:
26# - Strings which are not entire sentences, see the maintainer guidelines
27# in the GNU gettext documentation, section 'Preparing Strings'.
28# - Strings which use unclear terms or require additional context to be
29# understood.
30# - Strings which make invalid assumptions about notation of date, time or
31# money.
32# - Pluralisation problems.
33# - Incorrect English spelling.
34# - Incorrect formatting.
35# It can be your email address, or a mailing list address where translators
36# can write to without being subscribed, or the URL of a web page through
37# which the translators can contact you.
38MSGID_BUGS_ADDRESS = enlightenment-devel@lists.sourceforge.net
39
40# This is the list of locale categories, beyond LC_MESSAGES, for which the
41# message catalogs shall be used. It is usually empty.
42EXTRA_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 @@
1src/e_int_config_wallpaper.c
2src/e_mod_main.c
3src/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 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR Enlightenment development team
3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#
6#, fuzzy
7msgid ""
8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: enlightenment-devel@lists.sourceforge.net\n"
11"POT-Creation-Date: 2014-06-17 09:26-0400\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=CHARSET\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20#: src/e_int_config_wallpaper.c:723 src/e_int_config_wallpaper.c:916
21msgid "Theme Wallpaper"
22msgstr ""
23
24#: src/e_int_config_wallpaper.c:1106
25msgid "Loading files..."
26msgstr ""
27
28#: src/e_int_config_wallpaper.c:1174
29msgid "Wallpaper Settings"
30msgstr ""
31
32#: src/e_int_config_wallpaper.c:1189
33msgid "OK"
34msgstr ""
35
36#: src/e_int_config_wallpaper.c:1195
37msgid "Apply"
38msgstr ""
39
40#: src/e_int_config_wallpaper.c:1201
41msgid "Close"
42msgstr ""
43
44#: src/e_int_config_wallpaper.c:1252
45msgid "All Desktops"
46msgstr ""
47
48#: src/e_int_config_wallpaper.c:1258
49msgid "This Desktop"
50msgstr ""
51
52#: src/e_int_config_wallpaper.c:1263
53msgid "This Screen"
54msgstr ""
55
56#: src/e_int_config_wallpaper.c:1276
57msgid "Add"
58msgstr ""
59
60#: src/e_int_config_wallpaper.c:1281
61msgid "Delete"
62msgstr ""
63
64#: src/e_mod_main.c:25
65msgid "Look"
66msgstr ""
67
68#: src/e_mod_main.c:26 src/e_mod_main.c:30 src/e_mod_main.c:94
69msgid "Wallpaper 2"
70msgstr ""
71
72#: src/e_mod_main.c:27
73msgid "Internal"
74msgstr ""
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 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = -I. \
4 -I$(top_srcdir) \
5 -I$(includedir) \
6 -DLOCALEDIR=\"$(datadir)/locale\" \
7 -DPACKAGE_DATA_DIR=\"$(module_dir)/$(PACKAGE)\" \
8 @E_CFLAGS@
9
10pkgdir = $(module_dir)/$(PACKAGE)/$(MODULE_ARCH)
11pkg_LTLIBRARIES = module.la
12module_la_SOURCES = e_mod_main.h \
13 e_mod_main.c \
14 e_int_config_wallpaper.c
15
16module_la_LIBADD = @E_LIBS@
17module_la_LDFLAGS = -module -avoid-version
18module_la_DEPENDENCIES = $(top_builddir)/config.h
19
20clean-local:
21 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 @@
1#include "e.h"
2#include "e_mod_main.h"
3
4// FIXME:
5// need choice after add (file, gradient, online source)
6// need delete select mode
7// need after select on delete an ok/cancel if file or "ok to remove whole online source" if online
8// need to make "exchange" wallpapers have a different look
9// bug: animated wp doesn't workon first show
10// need to be able to "type name to search/filter"
11
12typedef struct _Info Info;
13typedef struct _Smart_Data Smart_Data;
14typedef struct _Item Item;
15
16struct _Info
17{
18 E_Win *win;
19 Evas_Object *bg, *preview, *mini, *button, *box, *sframe, *span;
20 Eina_Stringshare *bg_file;
21 int iw, ih;
22 Eina_List *dirs;
23 char *curdir;
24 Eina_Iterator *dir;
25 Ecore_Idler *idler;
26 int scans;
27 int man_num, zone_num, desk_x, desk_y;
28 int use_theme_bg;
29 int mode;
30};
31
32struct _Smart_Data
33{
34 Eina_List *items;
35 Ecore_Idle_Enterer *idle_enter;
36 Ecore_Animator *animator;
37 Ecore_Timer *seltimer;
38 Info *info;
39 Evas_Coord x, y, w, h;
40 Evas_Coord cx, cy, cw, ch;
41 Evas_Coord sx, sy;
42 int id_num;
43 int sort_num;
44 double seltime;
45 double selmove;
46 Eina_Bool selin : 1;
47 Eina_Bool selout : 1;
48 Eina_Bool jump2hi : 1;
49};
50
51struct _Item
52{
53 Evas_Object *obj;
54 Evas_Coord x, y, w, h;
55 Eina_Stringshare *file;
56 char *sort_id;
57 Evas_Object *frame, *image;
58 Eina_Bool selected : 1;
59 Eina_Bool have_thumb : 1;
60 Eina_Bool do_thumb : 1;
61 Eina_Bool remote : 1;
62 Eina_Bool theme : 1;
63 Eina_Bool visible : 1;
64 Eina_Bool hilighted : 1;
65};
66
67static Info *global_info = NULL;
68
69static void _e_smart_reconfigure(Evas_Object *obj);
70static Eina_Bool _e_smart_reconfigure_do(void *data);
71static void _thumb_gen(void *data, Evas_Object *obj, void *event_info);
72static void _item_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
73static void _item_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
74static int _sort_cb(const void *d1, const void *d2);
75static void _scan(Info *info);
76
77static void
78_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
79{
80 Smart_Data *sd = evas_object_smart_data_get(obj);
81
82 if (x > (sd->cw - sd->w)) x = sd->cw - sd->w;
83 if (y > (sd->ch - sd->h)) y = sd->ch - sd->h;
84 if (x < 0) x = 0;
85 if (y < 0) y = 0;
86 if ((sd->cx == x) && (sd->cy == y)) return;
87 sd->cx = x;
88 sd->cy = y;
89 _e_smart_reconfigure(obj);
90}
91
92static void
93_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
94{
95 Smart_Data *sd = evas_object_smart_data_get(obj);
96
97 if (x) *x = sd->cx;
98 if (y) *y = sd->cy;
99}
100
101static void
102_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
103{
104 Smart_Data *sd = evas_object_smart_data_get(obj);
105
106 if (x)
107 {
108 if (sd->w < sd->cw) *x = sd->cw - sd->w;
109 else *x = 0;
110 }
111 if (y)
112 {
113 if (sd->h < sd->ch) *y = sd->ch - sd->h;
114 else *y = 0;
115 }
116}
117
118static void
119_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
120{
121 Smart_Data *sd = evas_object_smart_data_get(obj);
122
123 if (w) *w = sd->cw;
124 if (h) *h = sd->ch;
125}
126
127static Eina_Bool
128_e_smart_reconfigure_do(void *data)
129{
130 Evas_Object *obj = data;
131 Smart_Data *sd = evas_object_smart_data_get(obj);
132 Eina_List *l;
133 Item *it;
134 int iw, redo = 0, changed = 0;
135 static int recursion = 0;
136 Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox, oy, dd;
137 Evas_Coord vw, vh;
138 Evas *evas;
139
140 if (!sd) return ECORE_CALLBACK_CANCEL;
141 if (sd->cx > (sd->cw - sd->w)) sd->cx = sd->cw - sd->w;
142 if (sd->cy > (sd->ch - sd->h)) sd->cy = sd->ch - sd->h;
143 if (sd->cx < 0) sd->cx = 0;
144 if (sd->cy < 0) sd->cy = 0;
145
146 iw = sd->w / 4;
147 if (iw > (120 * e_scale)) iw = (120 * e_scale);
148 else
149 {
150 if (iw < (60 * e_scale)) iw = (sd->w / 3);
151 if (iw < (60 * e_scale)) iw = (sd->w / 2);
152 if (iw < (60 * e_scale)) iw = sd->w;
153 }
154 x = 0;
155 y = 0;
156 ww = iw;
157 hh = (sd->info->ih * iw) / (sd->info->iw);
158 mw = mh = 0;
159
160 evas = evas_object_evas_get(obj);
161 evas_output_viewport_get(evas, NULL, NULL, &vw, &vh);
162
163 EINA_LIST_FOREACH(sd->items, l, it)
164 {
165 if (x > (sd->w - ww))
166 {
167 x = 0;
168 y += hh;
169 }
170 it->x = x;
171 it->y = y;
172 it->w = ww;
173 it->h = hh;
174 if (it->selected)
175 {
176 sd->sx = it->x + (it->w / 2);
177 sd->sy = it->y + (it->h / 2);
178 }
179 if ((x + ww) > mw) mw = x + ww;
180 if ((y + hh) > mh) mh = y + hh;
181 x += ww;
182 }
183 if ((mw != sd->cw) || (mh != sd->ch))
184 {
185 sd->cw = mw;
186 sd->ch = mh;
187 if (sd->cx > (sd->cw - sd->w))
188 {
189 sd->cx = sd->cw - sd->w;
190 redo = 1;
191 }
192 if (sd->cy > (sd->ch - sd->h))
193 {
194 sd->cy = sd->ch - sd->h;
195 redo = 1;
196 }
197 if (sd->cx < 0)
198 {
199 sd->cx = 0;
200 redo = 1;
201 }
202 if (sd->cy < 0)
203 {
204 sd->cy = 0;
205 redo = 1;
206 }
207 if (redo)
208 {
209 recursion = 1;
210 _e_smart_reconfigure_do(obj);
211 recursion = 0;
212 }
213 changed = 1;
214 }
215
216 ox = 0;
217 if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2;
218 oy = 0;
219 if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2;
220
221 EINA_LIST_FOREACH(sd->items, l, it)
222 {
223 Evas_Coord dx, dy;
224
225 dx = dy = 0;
226 if ((sd->sx >= 0) && (sd->selmove > 0.0)
227
228/* &&
229 ((it->x + it->w) > sd->cx) &&
230 ((it->x) < (sd->cx + sd->w)) &&
231 ((it->y + it->h) > sd->cy) &&
232 ((it->y) < (sd->cy + sd->h))
233 */
234 )
235 {
236 double a, d;
237 int sum = 0;
238 char *p;
239
240 // -----0X0+++++
241 dx = (it->x + (it->w / 2)) - sd->sx;
242 dy = (it->y + (it->h / 2)) - sd->sy;
243 if (dx > 0)
244 {
245 // |/
246 // +--
247 if (dy < 0)
248 a = -atan(-(double)dy / (double)dx);
249 // +--
250 /* |\ */
251 else
252 a = atan((double)dy / (double)dx);
253 }
254 else if (dx == 0)
255 {
256 // |
257 // +
258 if (dy < 0) a = -M_PI / 2;
259 // +
260 // |
261 else a = M_PI / 2;
262 }
263 else
264 {
265 // \|
266 // --+
267 if (dy < 0)
268 a = -M_PI + atan((double)dy / (double)dx);
269 // --+
270 // /|
271 else
272 a = M_PI - atan(-(double)dy / (double)dx);
273 }
274 d = sqrt((double)(dx * dx) + (double)(dy * dy));
275
276 sum = 0;
277 if (it->file)
278 {
279 for (p = (char *)it->file; *p; p++) sum += (int)(*p);
280 }
281 sum = (sum & 0xff) - 128;
282 a = a + ((double)sum / 1024.0);
283 xx = sd->sx - sd->cx + ox;
284 yy = sd->sy - sd->cy + oy;
285 if (xx < (sd->w / 2)) dx = sd->w - xx;
286 else dx = xx;
287 if (yy < (sd->h / 2)) dy = sd->h - yy;
288 else dy = yy;
289 dd = dx - d;
290 if (dy > dx) dd = dy - d;
291 if (dd < 0) dd = 0;
292 dy = sin(a) * sd->selmove * (dd * 0.9);
293 dx = cos(a) * sd->selmove * (dd * 0.9);
294 }
295 xx = sd->x - sd->cx + it->x + ox;
296 yy = sd->y - sd->cy + it->y + oy;
297 if (E_INTERSECTS(xx, yy, it->w, it->h, 0, 0, vw, vh))
298 {
299 if (!it->have_thumb)
300 {
301 if (!it->do_thumb)
302 {
303 e_thumb_icon_begin(it->image);
304 it->do_thumb = EINA_TRUE;
305 }
306 }
307 else
308 {
309 if (!it->frame)
310 {
311 it->frame = edje_object_add(evas);
312 if (it->theme)
313 e_theme_edje_object_set(it->frame, "base/theme/widgets",
314 "e/conf/wallpaper/main/mini-theme");
315 else if (it->remote)
316 e_theme_edje_object_set(it->frame, "base/theme/widgets",
317 "e/conf/wallpaper/main/mini-remote");
318 else
319 e_theme_edje_object_set(it->frame, "base/theme/widgets",
320 "e/conf/wallpaper/main/mini");
321 if (it->hilighted)
322 {
323 edje_object_signal_emit(it->frame, "e,state,selected", "e");
324 evas_object_raise(it->frame);
325 }
326 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
327 _item_down, it);
328 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
329 _item_up, it);
330
331 evas_object_smart_member_add(it->frame, obj);
332 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
333 it->image = e_thumb_icon_add(evas);
334 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
335 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
336 if (it->theme)
337 {
338 const char *f;
339
340 f = e_theme_edje_file_get("base/theme/backgrounds",
341 "e/desktop/background");
342 e_thumb_icon_file_set(it->image, f,
343 "e/desktop/background");
344 }
345 else
346 e_thumb_icon_file_set(it->image, it->file,
347 "e/desktop/background");
348 e_thumb_icon_size_set(it->image, sd->info->iw,
349 sd->info->ih);
350 evas_object_show(it->image);
351
352 e_thumb_icon_begin(it->image);
353 }
354 }
355 evas_object_move(it->frame, xx + dx, yy + dy);
356 evas_object_resize(it->frame, it->w, it->h);
357 evas_object_show(it->frame);
358 it->visible = EINA_TRUE;
359 }
360 else
361 {
362 if (it->have_thumb)
363 {
364 if (it->do_thumb)
365 {
366 e_thumb_icon_end(it->image);
367 it->do_thumb = EINA_FALSE;
368 }
369 evas_object_del(it->image);
370 it->image = NULL;
371 evas_object_del(it->frame);
372 it->frame = NULL;
373 }
374 it->visible = EINA_FALSE;
375/*
376 if (it->have_thumb)
377 {
378 if (it->do_thumb)
379 {
380 e_thumb_icon_end(it->image);
381 it->do_thumb = EINA_FALSE;
382 }
383 evas_object_del(it->image);
384 it->have_thumb = EINA_FALSE;
385 it->image = e_thumb_icon_add(evas);
386 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
387 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
388 if (it->theme)
389 {
390 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
391 "e/desktop/background");
392 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
393 }
394 else
395 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
396 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
397 evas_object_show(it->image);
398 edje_object_signal_emit(it->frame, "e,action,thumb,ungen", "e");
399 }
400 else
401 {
402 if (it->sort_id)
403 {
404 if (it->do_thumb)
405 {
406 e_thumb_icon_end(it->image);
407 it->do_thumb = 0;
408 }
409 }
410 }
411 */
412 }
413 }
414
415 if (changed)
416 evas_object_smart_callback_call(obj, "changed", NULL);
417 if (recursion == 0) sd->idle_enter = NULL;
418 return ECORE_CALLBACK_CANCEL;
419}
420
421static void
422_e_smart_reconfigure(Evas_Object *obj)
423{
424 Smart_Data *sd = evas_object_smart_data_get(obj);
425
426 if (sd->idle_enter) return;
427 sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
428}
429
430static void
431_e_smart_add(Evas_Object *obj)
432{
433 Smart_Data *sd = calloc(1, sizeof(Smart_Data));
434
435 if (!sd) return;
436
437 sd->sx = sd->sy = -1;
438 evas_object_smart_data_set(obj, sd);
439}
440
441static void
442_e_smart_del(Evas_Object *obj)
443{
444 Smart_Data *sd = evas_object_smart_data_get(obj);
445 Item *it;
446
447 if (sd->seltimer)
448 ecore_timer_del(sd->seltimer);
449 if (sd->idle_enter)
450 ecore_idle_enterer_del(sd->idle_enter);
451 if (sd->animator)
452 ecore_animator_del(sd->animator);
453 // sd->info is just referenced
454 // sd->child_obj is unused
455 EINA_LIST_FREE(sd->items, it)
456 {
457 if (it->frame) evas_object_del(it->frame);
458 if (it->image) evas_object_del(it->image);
459 eina_stringshare_del(it->file);
460 free(it->sort_id);
461 free(it);
462 }
463 free(sd);
464 evas_object_smart_data_set(obj, NULL);
465}
466
467static void
468_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
469{
470 Smart_Data *sd = evas_object_smart_data_get(obj);
471
472 sd->x = x;
473 sd->y = y;
474 _e_smart_reconfigure(obj);
475}
476
477static void
478_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
479{
480 Smart_Data *sd = evas_object_smart_data_get(obj);
481
482 sd->w = w;
483 sd->h = h;
484 _e_smart_reconfigure(obj);
485 evas_object_smart_callback_call(obj, "changed", NULL);
486}
487
488static void
489_e_smart_show(Evas_Object *obj EINA_UNUSED)
490{
491// Smart_Data *sd = evas_object_smart_data_get(obj);
492// evas_object_show(sd->child_obj);
493}
494
495static void
496_e_smart_hide(Evas_Object *obj EINA_UNUSED)
497{
498// Smart_Data *sd = evas_object_smart_data_get(obj);
499// evas_object_hide(sd->child_obj);
500}
501
502static void
503_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)
504{
505// Smart_Data *sd = evas_object_smart_data_get(obj);
506// evas_object_color_set(sd->child_obj, r, g, b, a);
507}
508
509static void
510_e_smart_clip_set(Evas_Object *obj EINA_UNUSED, Evas_Object * clip EINA_UNUSED)
511{
512// Smart_Data *sd = evas_object_smart_data_get(obj);
513// evas_object_clip_set(sd->child_obj, clip);
514}
515
516static void
517_e_smart_clip_unset(Evas_Object *obj EINA_UNUSED)
518{
519// Smart_Data *sd = evas_object_smart_data_get(obj);
520// evas_object_clip_unset(sd->child_obj);
521}
522
523static Evas_Object *
524_pan_add(Evas *evas)
525{
526 static Evas_Smart *smart = NULL;
527 static const Evas_Smart_Class sc =
528 {
529 "wp_pan",
530 EVAS_SMART_CLASS_VERSION,
531 _e_smart_add,
532 _e_smart_del,
533 _e_smart_move,
534 _e_smart_resize,
535 _e_smart_show,
536 _e_smart_hide,
537 _e_smart_color_set,
538 _e_smart_clip_set,
539 _e_smart_clip_unset,
540 NULL,
541 NULL,
542 NULL,
543 NULL,
544 NULL,
545 NULL,
546 NULL
547 };
548 smart = evas_smart_class_new(&sc);
549 return evas_object_smart_add(evas, smart);
550}
551
552static void
553_pan_info_set(Evas_Object *obj, Info *info)
554{
555 Smart_Data *sd = evas_object_smart_data_get(obj);
556
557 sd->info = info;
558}
559
560static Eina_Bool
561_sel_anim(void *data)
562{
563 Evas_Object *obj = data;
564 Smart_Data *sd = evas_object_smart_data_get(obj);
565 double t = ecore_loop_time_get() - sd->seltime;
566 double len = 1.0;
567 double p = t / len;
568 double d;
569
570 if (p > 1.0) p = 1.0;
571 if (!sd->selin)
572 {
573 d = (p * 2) - 1.0;
574 if (d > 0.0)
575 {
576 d = 1.0 - d;
577 d = d * d * d;
578 d = 1.0 - d;
579 }
580 else
581 {
582 d = -1.0 - d;
583 d = d * d * d;
584 d = -1.0 - d;
585 }
586 d = (1.0 + d) / 2.0;
587 sd->selmove = d;
588 }
589 else
590 {
591 d = ((1.0 - p) * 2) - 1.0;
592 if (d > 0.0)
593 {
594 d = 1.0 - d;
595 d = d * d * d;
596 d = 1.0 - d;
597 }
598 else
599 {
600 d = -1.0 - d;
601 d = d * d * d;
602 d = -1.0 - d;
603 }
604 d = (1.0 + d) / 2.0;
605 sd->selmove = d;
606 }
607 _e_smart_reconfigure(obj);
608 if (p == 1.0)
609 {
610 if (sd->selout)
611 {
612 sd->selin = EINA_TRUE;
613 sd->selout = EINA_FALSE;
614 sd->seltime = ecore_loop_time_get();
615 return ECORE_CALLBACK_RENEW;
616 }
617 sd->selout = EINA_FALSE;
618 sd->selin = EINA_FALSE;
619 sd->animator = NULL;
620 return ECORE_CALLBACK_CANCEL;
621 }
622 return ECORE_CALLBACK_RENEW;
623}
624
625static Eina_Bool
626_sel_timer(void *data)
627{
628 Evas_Object *obj = data;
629 Smart_Data *sd = evas_object_smart_data_get(obj);
630
631 if (!sd->animator)
632 {
633 sd->seltime = ecore_time_get();
634 sd->animator = ecore_animator_add(_sel_anim, obj);
635 sd->selin = EINA_FALSE;
636 }
637 sd->seltimer = NULL;
638 return ECORE_CALLBACK_CANCEL;
639}
640
641static void
642_pan_unhilight(Evas_Object *obj EINA_UNUSED, Item *it)
643{
644// Smart_Data *sd = evas_object_smart_data_get(obj);
645 if (!it->hilighted) return;
646 it->hilighted = 0;
647 if (it->frame)
648 edje_object_signal_emit(it->frame, "e,state,unselected", "e");
649}
650
651static void
652_pan_hilight(Evas_Object *obj EINA_UNUSED, Item *it)
653{
654 Eina_List *l;
655 Item *it2;
656 Smart_Data *sd = evas_object_smart_data_get(obj);
657
658 if (it->hilighted) return;
659 EINA_LIST_FOREACH(sd->items, l, it2)
660 {
661 if (it2->hilighted)
662 {
663 _pan_unhilight(obj, it2);
664 break;
665 }
666 }
667 it->hilighted = 1;
668 if (it->frame)
669 {
670 edje_object_signal_emit(it->frame, "e,state,selected", "e");
671 evas_object_raise(it->frame);
672 }
673}
674
675
676static void
677_pan_sel(Evas_Object *obj, Item *it)
678{
679 Smart_Data *sd = evas_object_smart_data_get(obj);
680
681 if (sd->selmove > 0.0) return;
682 edje_object_signal_emit(it->frame, "e,state,selected", "e");
683 evas_object_raise(it->frame);
684 if (!it->selected)
685 {
686 Eina_List *l;
687 Item *it2;
688
689 EINA_LIST_FOREACH(sd->items, l, it2)
690 {
691 if (it2->selected) it2->selected = 0;
692 }
693 it->selected = EINA_TRUE;
694 eina_stringshare_del(sd->info->bg_file);
695 evas_object_hide(sd->info->mini);
696 if (it->file)
697 {
698 char *name = NULL, *p;
699
700 sd->info->use_theme_bg = 0;
701 sd->info->bg_file = eina_stringshare_ref(it->file);
702 edje_object_file_set(sd->info->mini, sd->info->bg_file,
703 "e/desktop/background");
704 p = strrchr(sd->info->bg_file, '/');
705 if (p)
706 {
707 p++;
708 name = strdupa(p);
709 p = strrchr(name, '.');
710 if (p) *p = 0;
711 }
712 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
713 }
714 else
715 {
716 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
717 "e/desktop/background");
718
719 edje_object_file_set(sd->info->mini, f, "e/desktop/background");
720 sd->info->use_theme_bg = 1;
721 sd->info->bg_file = NULL;
722 edje_object_part_text_set(sd->info->bg, "e.text.filename",
723 D_("Theme Wallpaper"));
724 }
725 evas_object_show(sd->info->mini);
726 }
727 if (sd->seltimer) ecore_timer_del(sd->seltimer);
728 sd->seltimer = ecore_timer_add(0.2, _sel_timer, obj);
729}
730
731static void
732_pan_sel_up(Evas_Object *obj)
733{
734 Smart_Data *sd = evas_object_smart_data_get(obj);
735
736 if (sd->selmove == 0.0) return;
737 if (!sd->animator)
738 {
739 sd->seltime = ecore_loop_time_get();
740 sd->animator = ecore_animator_add(_sel_anim, obj);
741 sd->selin = EINA_TRUE;
742 }
743 else
744 {
745 if (sd->selin) return;
746 sd->selout = EINA_TRUE;
747 }
748}
749
750static int
751_sort_cb(const void *d1, const void *d2)
752{
753 const Item *it1 = d1, *it2 = d2;
754
755 if ((!it1->sort_id) || (!it2->sort_id)) return 0;
756 return strcmp(it1->sort_id, it2->sort_id);
757}
758
759static void
760_item_sort(Item *it)
761{
762 Evas_Object *obj = it->obj;
763 Smart_Data *sd = evas_object_smart_data_get(obj);
764 int num, dosort = 0;
765
766 sd->id_num++;
767 sd->info->scans--;
768 num = eina_list_count(sd->items);
769// if (sd->sort_num < sd->id_num)
770// {
771// sd->sort_num = sd->id_num + 10;
772// dosort = 1;
773// }
774 if ((sd->id_num == num) || (dosort))
775 {
776 sd->items = eina_list_sort(sd->items, num, _sort_cb);
777 _e_smart_reconfigure_do(obj);
778 if (sd->jump2hi)
779 {
780 Eina_List *l;
781 Item *it2 = NULL;
782
783 EINA_LIST_FOREACH(sd->items, l, it2)
784 {
785 if (it2->hilighted) break;
786 it2 = NULL;
787 }
788 if (it2)
789 e_scrollframe_child_region_show(sd->info->sframe,
790 it2->x, it2->y, it2->w, it2->h);
791 sd->jump2hi = 1;
792 }
793 }
794 if (sd->info->scans == 0)
795 edje_object_signal_emit(sd->info->bg, "e,state,busy,off", "e");
796}
797
798static void
799_thumb_gen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
800{
801 Item *it = data;
802
803 edje_object_signal_emit(it->frame, "e,action,thumb,gen", "e");
804 if (!it->sort_id)
805 {
806 const char *id = e_thumb_sort_id_get(it->image);
807
808 if (id)
809 {
810 it->sort_id = strdup(id);
811 _item_sort(it);
812 }
813 }
814 it->have_thumb = EINA_TRUE;
815 if (!it->visible)
816 {
817 if (it->do_thumb)
818 {
819 e_thumb_icon_end(it->image);
820 it->do_thumb = EINA_FALSE;
821 }
822 evas_object_del(it->image);
823 it->image = NULL;
824 evas_object_del(it->frame);
825 it->frame = NULL;
826 }
827}
828
829static void
830_item_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
831{
832// Evas_Event_Mouse_Down *ev = event_info;
833// Item *it = data;
834// _pan_sel(it->obj, it);
835}
836
837static void
838_item_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
839{
840 Evas_Event_Mouse_Up *ev = event_info;
841 Item *it = data;
842
843 if (ev->button == 1)
844 {
845 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
846 {
847 _pan_hilight(it->obj, it);
848 _pan_sel(it->obj, it);
849 // FIXME: select image!!!
850 }
851 }
852}
853
854static void
855_pan_file_add(Evas_Object *obj, const char *file, Eina_Bool remote, Eina_Bool theme)
856{
857 Smart_Data *sd = evas_object_smart_data_get(obj);
858 Item *it = calloc(1, sizeof(Item));
859 Evas *evas;
860
861 if (!it) return;
862 evas = evas_object_evas_get(obj);
863 sd->items = eina_list_append(sd->items, it);
864 it->obj = obj;
865 it->remote = remote;
866 it->theme = theme;
867 it->file = eina_stringshare_add(file);
868 it->frame = edje_object_add(evas);
869 if (it->theme)
870 e_theme_edje_object_set(it->frame, "base/theme/widgets",
871 "e/conf/wallpaper/main/mini-theme");
872 else if (it->remote)
873 e_theme_edje_object_set(it->frame, "base/theme/widgets",
874 "e/conf/wallpaper/main/mini-remote");
875 else
876 e_theme_edje_object_set(it->frame, "base/theme/widgets",
877 "e/conf/wallpaper/main/mini");
878 if (it->hilighted)
879 {
880 edje_object_signal_emit(it->frame, "e,state,selected", "e");
881 evas_object_raise(it->frame);
882 }
883 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
884 _item_down, it);
885 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
886 _item_up, it);
887
888 evas_object_smart_member_add(it->frame, obj);
889 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
890 evas_object_show(it->frame);
891 it->image = e_thumb_icon_add(evas);
892 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
893 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
894 if (it->theme)
895 {
896 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
897 "e/desktop/background");
898
899 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
900 }
901 else
902 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
903 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
904 evas_object_show(it->image);
905
906 e_thumb_icon_begin(it->image);
907 it->do_thumb = 1;
908// e_thumb_icon_begin(it->image);
909
910 if (it->theme)
911 {
912 if (sd->info->use_theme_bg)
913 {
914 _pan_hilight(it->obj, it);
915 edje_object_part_text_set(sd->info->bg, "e.text.filename",
916 D_("Theme Wallpaper"));
917 }
918 }
919 else
920 {
921 if (sd->info->bg_file)
922 {
923 int match = 0;
924
925 if (sd->info->bg_file == it->file) match = 1;
926 if (!match)
927 {
928 const char *p1, *p2;
929
930 p1 = ecore_file_file_get(sd->info->bg_file);
931 p2 = ecore_file_file_get(it->file);
932 if (!strcmp(p1, p2)) match = 1;
933 }
934 if (match)
935 {
936 char *name = NULL, *p;
937
938 sd->jump2hi = 1;
939 _pan_hilight(it->obj, it);
940 p = strrchr(sd->info->bg_file, '/');
941 if (p)
942 {
943 p++;
944 name = strdupa(p);
945 p = strrchr(name, '.');
946 if (p) *p = 0;
947 }
948 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
949 }
950 }
951 }
952 _e_smart_reconfigure(obj);
953}
954
955////////
956
957static void
958_resize(E_Win *wn)
959{
960 Info *info = wn->data;
961
962 evas_object_resize(info->bg, wn->w, wn->h);
963}
964
965static void
966_delete(E_Win *wn EINA_UNUSED)
967{
968 e_object_del(E_OBJECT(global_info->win));
969}
970
971static void
972_bg_clicked(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
973{
974 Info *info = data;
975
976 _pan_sel_up(info->span);
977}
978
979static void
980_apply(void *data, void *data2 EINA_UNUSED)
981{
982 Info *info = data;
983
984 if (info->mode == 0)
985 {
986 /* all desktops */
987 while (e_config->desktop_backgrounds)
988 {
989 E_Config_Desktop_Background *cfbg;
990
991 cfbg = e_config->desktop_backgrounds->data;
992 e_bg_del(cfbg->manager, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
993 }
994 if ((info->use_theme_bg) || (!info->bg_file))
995 e_bg_default_set(NULL);
996 else
997 e_bg_default_set(info->bg_file);
998 }
999 else if (info->mode == 1)
1000 {
1001 /* specific desk */
1002 e_bg_del(info->man_num, info->zone_num, info->desk_x, info->desk_y);
1003 e_bg_add(info->man_num, info->zone_num, info->desk_x, info->desk_y,
1004 info->bg_file);
1005 }
1006 else
1007 {
1008 Eina_List *dlist = NULL, *l;
1009 E_Config_Desktop_Background *cfbg;
1010
1011 /* this screen */
1012 EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
1013 {
1014 if (cfbg->zone == info->zone_num)
1015 dlist = eina_list_append(dlist, cfbg);
1016 }
1017 EINA_LIST_FREE(dlist, cfbg)
1018 e_bg_del(cfbg->manager, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
1019 e_bg_add(info->man_num, info->zone_num, -1, -1, info->bg_file);
1020 }
1021 e_bg_update();
1022 e_config_save_queue();
1023}
1024
1025static void
1026_close(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
1027{
1028 e_object_del(E_OBJECT(global_info->win));
1029}
1030
1031static void
1032_ok(void *data, void *data2 EINA_UNUSED)
1033{
1034 _apply(data, data2);
1035 e_object_del(E_OBJECT(global_info->win));
1036}
1037
1038static void
1039_wp_add(void *data, void *data2 EINA_UNUSED)
1040{
1041 Info *info = data;
1042
1043 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1044}
1045
1046static void
1047_wp_delete(void *data, void *data2 EINA_UNUSED)
1048{
1049 Info *info = data;
1050
1051 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1052}
1053
1054static void
1055_wp_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1056{
1057 Info *info = data;
1058
1059 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1060}
1061
1062static Eina_Bool
1063_idler(void *data)
1064{
1065 Eina_File_Direct_Info *st;
1066 Info *info = data;
1067
1068 if (!info->dir)
1069 {
1070 info->idler = NULL;
1071 return ECORE_CALLBACK_CANCEL;
1072 }
1073 if (!eina_iterator_next(info->dir, (void**) &st))
1074 {
1075 E_FREE(info->curdir);
1076 eina_iterator_free(info->dir);
1077 info->dir = NULL;
1078 info->idler = NULL;
1079 _scan(info);
1080 return ECORE_CALLBACK_CANCEL;
1081 }
1082 if ((st->path[st->name_start]) == '.')
1083 return ECORE_CALLBACK_RENEW;
1084 if (st->type == EINA_FILE_DIR)
1085 {
1086 info->dirs = eina_list_append(info->dirs, strdup(st->path));
1087 return ECORE_CALLBACK_RENEW;
1088 }
1089 info->scans++;
1090 _pan_file_add(info->span, st->path, 0, 0);
1091
1092 e_util_wakeup();
1093 return ECORE_CALLBACK_RENEW;
1094}
1095
1096static void
1097_scan(Info *info)
1098{
1099 if (info->dirs)
1100 {
1101 if (info->scans <= 0)
1102 {
1103 info->scans = 0;
1104 edje_object_signal_emit(info->bg, "e,state,busy,on", "e");
1105 edje_object_part_text_set(info->bg, "e.text.busy_label",
1106 D_("Loading files..."));
1107 }
1108 free(info->curdir);
1109 info->curdir = info->dirs->data;
1110 info->dirs = eina_list_remove_list(info->dirs, info->dirs);
1111 if (!info->dir) info->dir = eina_file_stat_ls(info->curdir);
1112 info->idler = ecore_idler_add(_idler, info);
1113 }
1114}
1115
1116Info *
1117wp_browser_new(E_Comp *comp)
1118{
1119 Info *info;
1120 E_Win *win;
1121 E_Zone *zone;
1122 E_Desk *desk;
1123 const E_Config_Desktop_Background *cfbg;
1124 Evas_Coord mw, mh;
1125 Evas_Object *o, *o2, *ob;
1126 E_Radio_Group *rg;
1127 char buf[PATH_MAX];
1128
1129 info = calloc(1, sizeof(Info));
1130 if (!info) return NULL;
1131
1132 zone = e_zone_current_get(comp);
1133 desk = e_desk_current_get(zone);
1134 info->man_num = comp->num;
1135 info->zone_num = zone->num;
1136 info->desk_x = desk->x;
1137 info->desk_y = desk->y;
1138 info->mode = 0;
1139 cfbg = e_bg_config_get(comp->num, zone->num, desk->x, desk->y);
1140 if (cfbg)
1141 {
1142 if ((cfbg->manager >= 0) && (cfbg->zone >= 0))
1143 {
1144 if ((cfbg->desk_x >= 0) && (cfbg->desk_y >= 0))
1145 info->mode = 1;
1146 else
1147 info->mode = 2;
1148 }
1149 info->bg_file = eina_stringshare_ref(cfbg->file);
1150 }
1151 if ((!info->bg_file) && (e_config->desktop_default_background))
1152 info->bg_file = eina_stringshare_ref(e_config->desktop_default_background);
1153 else
1154 info->use_theme_bg = 1;
1155
1156 info->iw = (120 * e_scale);
1157 info->ih = (zone->h * info->iw) / (zone->w);
1158
1159 win = e_win_new(comp);
1160 if (!win)
1161 {
1162 eina_stringshare_del(info->bg_file);
1163 free(info);
1164 return NULL;
1165 }
1166 info->win = win;
1167 win->data = info;
1168
1169 e_user_dir_concat_static(buf, "backgrounds");
1170 info->dirs = eina_list_append(info->dirs, strdup(buf));
1171 e_prefix_data_concat_static(buf, "data/backgrounds");
1172 info->dirs = eina_list_append(info->dirs, strdup(buf));
1173
1174 e_win_title_set(win, D_("Wallpaper Settings"));
1175 e_win_name_class_set(win, "E", "_config::appearance/wallpaper2");
1176 e_win_resize_callback_set(win, _resize);
1177 e_win_delete_callback_set(win, _delete);
1178
1179 // bg + manager
1180 info->bg = edje_object_add(info->win->evas);
1181 e_theme_edje_object_set(info->bg, "base/theme/widgets",
1182 "e/conf/wallpaper/main/window");
1183 edje_object_signal_callback_add(info->bg, "e,action,click", "e",
1184 _bg_clicked, info);
1185
1186 info->box = e_widget_list_add(info->win->evas, 1, 1);
1187
1188 // ok button
1189 info->button = e_widget_button_add(info->win->evas, D_("OK"), NULL,
1190 _ok, info, NULL);
1191 evas_object_show(info->button);
1192 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1193
1194 // apply button
1195 info->button = e_widget_button_add(info->win->evas, D_("Apply"), NULL,
1196 _apply, info, NULL);
1197 evas_object_show(info->button);
1198 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1199
1200 // close button
1201 info->button = e_widget_button_add(info->win->evas, D_("Close"), NULL,
1202 _close, info, NULL);
1203 evas_object_show(info->button);
1204 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1205
1206 e_widget_size_min_get(info->box, &mw, &mh);
1207 evas_object_size_hint_min_set(info->box, mw, mh);
1208 edje_object_part_swallow(info->bg, "e.swallow.buttons", info->box);
1209 evas_object_show(info->box);
1210
1211 // preview
1212 info->preview = e_livethumb_add(info->win->evas);
1213 e_livethumb_vsize_set(info->preview, zone->w, zone->h);
1214 edje_extern_object_aspect_set(info->preview, EDJE_ASPECT_CONTROL_NEITHER,
1215 zone->w, zone->h);
1216 edje_object_part_swallow(info->bg, "e.swallow.preview", info->preview);
1217 evas_object_show(info->preview);
1218
1219 info->mini = edje_object_add(e_livethumb_evas_get(info->preview));
1220 e_livethumb_thumb_set(info->preview, info->mini);
1221 evas_object_show(info->mini);
1222 if (info->bg_file)
1223 edje_object_file_set(info->mini, info->bg_file, "e/desktop/background");
1224 else
1225 {
1226 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
1227 "e/desktop/background");
1228
1229 edje_object_file_set(info->mini, f, "e/desktop/background");
1230 }
1231
1232 // scrolled thumbs
1233 info->span = _pan_add(info->win->evas);
1234 _pan_info_set(info->span, info);
1235
1236 // the scrollframe holding the scrolled thumbs
1237 info->sframe = e_scrollframe_add(info->win->evas);
1238 e_scrollframe_custom_theme_set(info->sframe, "base/theme/widgets",
1239 "e/conf/wallpaper/main/scrollframe");
1240 e_scrollframe_extern_pan_set(info->sframe, info->span,
1241 _pan_set, _pan_get, _pan_max_get,
1242 _pan_child_size_get);
1243 edje_object_part_swallow(info->bg, "e.swallow.list", info->sframe);
1244 evas_object_show(info->sframe);
1245 evas_object_show(info->span);
1246
1247 ob = e_widget_list_add(info->win->evas, 0, 1);
1248
1249 o = e_widget_list_add(info->win->evas, 1, 0);
1250
1251 rg = e_widget_radio_group_new(&(info->mode));
1252 o2 = e_widget_radio_add(info->win->evas, D_("All Desktops"), 0, rg);
1253 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1254 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1255 e_widget_disabled_set(o2, (e_util_comp_desk_count_get(comp) < 2));
1256 evas_object_show(o2);
1257
1258 o2 = e_widget_radio_add(info->win->evas, D_("This Desktop"), 1, rg);
1259 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1260 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1261 evas_object_show(o2);
1262
1263 o2 = e_widget_radio_add(info->win->evas, D_("This Screen"), 2, rg);
1264 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1265 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1266 if (!(e_util_comp_zone_number_get(0, 1) ||
1267 (e_util_comp_zone_number_get(1, 0))))
1268 e_widget_disabled_set(o2, EINA_TRUE);
1269 evas_object_show(o2);
1270
1271 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1272 evas_object_show(o);
1273
1274 o = e_widget_list_add(info->win->evas, 1, 0);
1275
1276 o2 = e_widget_button_add(info->win->evas, D_("Add"), NULL,
1277 _wp_add, info, NULL);
1278 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1279 evas_object_show(o2);
1280
1281 o2 = e_widget_button_add(info->win->evas, D_("Delete"), NULL,
1282 _wp_delete, info, NULL);
1283 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1284 evas_object_show(o2);
1285
1286 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1287 evas_object_show(o);
1288
1289 e_widget_size_min_get(ob, &mw, &mh);
1290 evas_object_size_hint_min_set(ob, mw, mh);
1291 edje_object_part_swallow(info->bg, "e.swallow.extras", ob);
1292 evas_object_show(ob);
1293
1294 // min size calc
1295 edje_object_size_min_calc(info->bg, &mw, &mh);
1296 e_win_size_min_set(win, mw, mh);
1297 if ((zone->w / 4) > mw) mw = (zone->w / 4);
1298 if ((zone->h / 4) > mh) mh = (zone->h / 4);
1299 e_win_resize(win, mw, mh);
1300 e_win_centered_set(win, 1);
1301 e_win_show(win);
1302 e_win_client_icon_set(win, "preferences-desktop-wallpaper");
1303
1304 evas_object_resize(info->bg, info->win->w, info->win->h);
1305 evas_object_show(info->bg);
1306
1307 // add theme bg
1308 _pan_file_add(info->span, NULL, 0, 1);
1309
1310 _scan(info);
1311 return info;
1312}
1313
1314void
1315wp_broser_free(Info *info)
1316{
1317 char *s;
1318
1319 if (!info) return;
1320 if (info->win) e_object_del(E_OBJECT(info->win));
1321 if (info->dir) eina_iterator_free(info->dir);
1322 eina_stringshare_del(info->bg_file);
1323 free(info->curdir);
1324 EINA_LIST_FREE(info->dirs, s)
1325 free(s);
1326 if (info->idler) ecore_idler_del(info->idler);
1327 // del other stuff
1328 E_FREE(info);
1329}
1330
1331E_Config_Dialog *
1332wp_conf_show(E_Comp *comp, const char *params EINA_UNUSED)
1333{
1334 if (global_info)
1335 {
1336 e_win_show(global_info->win);
1337 e_win_raise(global_info->win);
1338 }
1339 global_info = wp_browser_new(comp);
1340
1341 return NULL;
1342}
1343
1344void
1345wp_conf_hide(void)
1346{
1347 if (global_info)
1348 {
1349 wp_broser_free(global_info);
1350 global_info = NULL;
1351 }
1352}
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 @@
1#include "e.h"
2#include "e_mod_main.h"
3
4/* actual module specifics */
5static void _e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi);
6static void _e_mod_menu_add(void *data, E_Menu *m);
7
8static E_Module *conf_module = NULL;
9static E_Int_Menu_Augmentation *maug = NULL;
10//static E_Fm2_Mime_Handler *import_hdl = NULL;
11
12/* module setup */
13EAPI E_Module_Api e_modapi =
14{
15 E_MODULE_API_VERSION,
16 "Settings - Wallpaper 2"
17};
18
19EAPI void *
20e_modapi_init(E_Module *m)
21{
22 bindtextdomain(PACKAGE, LOCALEDIR);
23 bind_textdomain_codeset(PACKAGE, "UTF-8");
24
25 e_configure_registry_category_add("appearance", 10, D_("Look"), NULL, "preferences-look");
26 e_configure_registry_item_add("appearance/wallpaper2", 10, D_("Wallpaper 2"), NULL, "preferences-desktop-wallpaper", wp_conf_show);
27 e_configure_registry_category_add("internal", -1, D_("Internal"), NULL, "enlightenment/internal");
28// e_configure_registry_item_add("internal/wallpaper_desk", -1, D_("Wallpaper 2"), NULL, "preferences-system-windows", e_int_config_wallpaper_desk);
29 maug = e_int_menus_menu_augmentation_add_sorted
30 ("config/1", D_("Wallpaper 2"), _e_mod_menu_add, NULL, NULL, NULL);
31
32// import_hdl = e_fm2_mime_handler_new(_("Set As Background 2"), "preferences-desktop-wallpaper",
33// e_int_config_wallpaper_handler_set, NULL,
34// e_int_config_wallpaper_handler_test, NULL);
35// if (import_hdl)
36// {
37// e_fm2_mime_handler_mime_add(import_hdl, "image/png");
38// e_fm2_mime_handler_mime_add(import_hdl, "image/jpeg");
39// }
40
41 conf_module = m;
42 e_module_delayed_set(m, 1);
43 return m;
44}
45
46EAPI int
47e_modapi_shutdown(E_Module *m EINA_UNUSED)
48{
49// E_Config_Dialog *cfd;
50 /* remove module-supplied menu additions */
51 if (maug)
52 {
53 e_int_menus_menu_augmentation_del("config/1", maug);
54 maug = NULL;
55 }
56// while ((cfd = e_config_dialog_get("E", "appearance/wallpaper2")))
57// e_object_del(E_OBJECT(cfd));
58// e_configure_registry_item_del("internal/wallpaper_desk");
59 e_configure_registry_category_del("internal");
60 e_configure_registry_item_del("appearance/wallpaper2");
61 e_configure_registry_category_del("appearance");
62
63// if (import_hdl)
64// {
65// e_fm2_mime_handler_mime_del(import_hdl, "image/png");
66// e_fm2_mime_handler_mime_del(import_hdl, "image/jpeg");
67// e_fm2_mime_handler_free(import_hdl);
68// }
69
70 conf_module = NULL;
71 return 1;
72}
73
74EAPI int
75e_modapi_save(E_Module *m EINA_UNUSED)
76{
77 return 1;
78}
79
80/* menu item callback(s) */
81static void
82_e_mod_run_cb(void *data EINA_UNUSED, E_Menu *m, E_Menu_Item *mi EINA_UNUSED)
83{
84 e_configure_registry_call("appearance/wallpaper2", m->zone->comp, NULL);
85}
86
87/* menu item add hook */
88static void
89_e_mod_menu_add(void *data EINA_UNUSED, E_Menu *m)
90{
91 E_Menu_Item *mi;
92
93 mi = e_menu_item_new(m);
94 e_menu_item_label_set(mi, D_("Wallpaper 2"));
95 e_util_menu_item_theme_icon_set(mi, "preferences-desktop-wallpaper");
96 e_menu_item_callback_set(mi, _e_mod_run_cb, NULL);
97}
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 @@
1#ifndef E_MOD_MAIN_H
2#define E_MOD_MAIN_H
3
4#ifdef ENABLE_NLS
5# include <libintl.h>
6# define D_(str) dgettext(PACKAGE, str)
7# define DP_(str, str_p, n) dngettext(PACKAGE, str, str_p, n)
8#else
9# define bindtextdomain(domain,dir)
10# define bind_textdomain_codeset(domain,codeset)
11# define D_(str) (str)
12# define DP_(str, str_p, n) (str_p)
13#endif
14
15#define N_(str) (str)
16
17E_Config_Dialog *wp_conf_show(E_Comp *comp, const char *params);
18void wp_conf_hide(void);
19
20/**
21 * @addtogroup Optional_Conf
22 * @{
23 *
24 * @defgroup Module_Conf_Wallpaper2 Wallpaper2 (Alternative Selector)
25 *
26 * More graphically appealing wallpaper selector. It is targeted at
27 * mobile devices.
28 *
29 * @note under development and not recommended for use yet.
30 *
31 * @see Module_Conf_Theme
32 * @}
33 */
34#endif