This commit is contained in:
Mike Blumenkrantz 2013-10-03 14:34:52 +01:00
commit cc4189531b
18 changed files with 665 additions and 0 deletions

52
.gitignore vendored Normal file
View File

@ -0,0 +1,52 @@
*~
*.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-module-desksanity.edj
e_modules-desksanity.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/desksanity.pot
po/stamp-po
src/.deps/
src/.libs/
src/Makefile
src/Makefile.in
stamp-h1

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Mike Blumenkrantz <zmike@enlightenment.org>

25
COPYING Normal file
View File

@ -0,0 +1,25 @@
Copyright notice for desksanity
Copyright (C) 2013 Mike Blumenkrantz 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.

2
COPYING_ARTS Normal file
View File

@ -0,0 +1,2 @@
trophy.png: http://findicons.com/icon/456447/trophy?id=456457
freeware license (non commercial)

0
ChangeLog Normal file
View File

35
Makefile.am Normal file
View File

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS = -I m4
MAINTAINERCLEANFILES = 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
EDJE_FLAGS = -v \
-id $(top_srcdir)/images
filesdir = $(module_dir)/$(PACKAGE)
files_DATA = module.desktop e-module-echievements.edj images/trophy.png
EXTRA_DIST = module.desktop.in \
e_modules-echievements.spec.in \
e-module-echievements.edc \
images/trophy.png
e-module-echievements.edj: Makefile e-module-echievements.edc images/trophy.png
e-module-echievements.edj: e-module-echievements.edc
$(EDJE_CC) $(EDJE_FLAGS) $< $@
clean-local:
rm -rf *.edj module.desktop e_modules-echievements.spec *~
uninstall-local:
rm -rf $(DESTDIR)$(module_dir)/$(PACKAGE)

0
NEWS Normal file
View File

0
README Normal file
View File

17
autogen.sh Executable file
View File

@ -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

70
configure.ac Normal file
View File

@ -0,0 +1,70 @@
dnl Process this file with autoconf to produce a configure script.
# get rid of that stupid cache mechanism
rm -f config.cache
AC_INIT(desksanity, 0.1, zmike@enlightenment.org)
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], [efx enlightenment])
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/desksanity"
# 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})
AC_OUTPUT([
Makefile
src/Makefile
module.desktop
e_modules-desksanity.spec
], [
])
#$po_makefile_in

View File

@ -0,0 +1,48 @@
%define module_name desksanity
%{!?_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 <mej@eterm.org>}
Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)}
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
BuildRequires: efx-devel
BuildRequires: efx-devel, 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

0
m4/.gitignore vendored Normal file
View File

6
module.desktop.in Normal file
View File

@ -0,0 +1,6 @@
[Desktop Entry]
Type=Link
Name=Desksanity
Icon=e-module-desksanity
Comment=Desktop Insanity for Enlightenment
X-Enlightenment-ModuleType=look

22
src/Makefile.am Normal file
View File

@ -0,0 +1,22 @@
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_mod_config.c \
desksanity.c
module_la_LIBADD = @E_LIBS@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
clean-local:
rm -rf *~

19
src/desksanity.c Normal file
View File

@ -0,0 +1,19 @@
#include "e_mod_main.h"
static void
_ds_flip(void *data, E_Desk *desk, Eina_Bool show)
{
}
EINTERN void
ds_init(void)
{
e_desk_flip_cb_set(_ds_flip, NULL);
}
EINTERN void
ds_shutdown(void)
{
e_desk_flip_cb_set(NULL, NULL);
}

244
src/e_mod_config.c Normal file
View File

@ -0,0 +1,244 @@
#include "e_mod_main.h"
#if 0
static void
_free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata EINA_UNUSED)
{
mod->cfd = NULL;
mod->label = mod->cfd_list[0] = mod->cfd_list[1] = NULL;
}
/*
static void *
_create_data(E_Config_Dialog *cfd EINA_UNUSED)
{
return NULL;
}
static int
_basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata EINA_UNUSED)
{
return 0;
}
static int
_basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata EINA_UNUSED)
{
return 0;
}
*/
static void
_obj_del(Echievement *ec, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
if (obj == ec->dialog.icon)
ec->dialog.icon = NULL;
else
ec->dialog.label = NULL;
}
static Evas_Object *
_item_create(Evas *evas, Echievement *ec, Eina_Bool save)
{
Evas_Object *table, *icon, *label;
char progress[128];
unsigned int goal, counter;
etrophy_trophy_goal_get(ec->trophy, &goal, &counter);
table = e_widget_frametable_add(evas, D_(etrophy_trophy_name_get(ec->trophy)), 1);
icon = e_widget_image_add_from_file(evas, PACKAGE_DATA_DIR "/trophy.png",
64, 64);
if (save) ec->dialog.icon = icon;
evas_object_event_callback_add(icon, EVAS_CALLBACK_DEL, (Evas_Object_Event_Cb)_obj_del, ec);
e_widget_frametable_object_append(table, icon, 0, 0, 1, 2, 1, 1, 1, 0);
label = e_widget_label_add(evas, D_(etrophy_trophy_description_get(ec->trophy)));
e_widget_frametable_object_append(table, label, 1, 0, 3, 1, 1, 1, 1, 0);
if (etrophy_trophy_earned_get(ec->trophy))
{
char date[256];
char buf[512];
time_t t0;
t0 = etrophy_trophy_date_get(ec->trophy);
strftime(date, sizeof(date), "%d %B %Y - %r", localtime(&t0));
snprintf(buf, sizeof(buf), D_("Achieved: %s"), date);
label = e_widget_label_add(evas, buf);
}
else if (goal < 2)
label = e_widget_label_add(evas, D_("Not achieved"));
else
{
snprintf(progress, sizeof(progress), D_("Progress: %u/%u"), counter, goal);
label = e_widget_label_add(evas, progress);
}
if (save) ec->dialog.label = label;
evas_object_event_callback_add(label, EVAS_CALLBACK_DEL, (Evas_Object_Event_Cb)_obj_del, ec);
e_widget_frametable_object_append(table, label, 1, 1, 3, 1, 1, 1, 1, 0);
return table;
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata EINA_UNUSED)
{
Evas_Object *toolbook, *list, *item, *sf;
Echievement *ec;
int mw, mh, mww;
toolbook = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
/* FIXME it should be scrollable and all initial items should
be visible */
mod->cfd_list[0] = list = e_widget_list_add(evas, 1, 0);
EINA_INLIST_FOREACH(EINA_INLIST_GET(mod->trophies_list), ec)
{
if (!etrophy_trophy_earned_get(ec->trophy)) continue;
item = _item_create(evas, ec, EINA_FALSE);
e_widget_list_object_append(list, item, 1, 1, 0.5);
}
e_widget_size_min_get(list, &mw, &mh);
if (mw < 320) mw = 320;
if (mh < 220) mh = 220;
evas_object_resize(list, mw, mh);
sf = e_widget_scrollframe_simple_add(evas, list);
e_widget_size_min_set(sf, 320, 220);
e_widget_toolbook_page_append(toolbook, NULL, D_("My Trophies"),
sf, 1, 1, 1, 1, 0.5, 0.0);
mod->cfd_list[1] = list = e_widget_list_add(evas, 1, 0);
EINA_INLIST_FOREACH(EINA_INLIST_GET(mod->trophies_list), ec)
{
if ((!etrophy_trophy_earned_get(ec->trophy)) && (!etrophy_trophy_visibility_get(ec->trophy))) continue;
item = _item_create(evas, ec, EINA_TRUE);
e_widget_list_object_append(list, item, 1, 1, 0.5);
}
e_widget_size_min_get(list, &mww, &mh);
if (mww < mw) mww = mw;
if (mh < 220) mh = 220;
evas_object_resize(list, mww, mh);
sf = e_widget_scrollframe_simple_add(evas, list);
e_widget_size_min_set(sf, 320, 220);
e_widget_toolbook_page_append(toolbook, NULL, D_("All Trophies"),
sf, 1, 1, 1, 1, 0.5, 0.0);
e_widget_toolbook_page_show(toolbook, 0);
list = e_widget_list_add(evas, 0, 0);
e_widget_list_object_append(list, toolbook, 1, 1, 0.5);
{
char buf[1024];
unsigned score = etrophy_gamescore_trophies_points_get(ds_config->gs);
/* FIXME: this can look better */
snprintf(buf, sizeof(buf), DP_("%u Echievement Point", "%u Echievement Points", score), score);
mod->label = item = e_widget_label_add(evas, buf);
e_widget_list_object_append(list, item, 0, 0, 0.5);
}
return list;
}
static void
_totals_update(void)
{
char buf[1024];
unsigned score = etrophy_gamescore_trophies_points_get(ds_config->gs);
snprintf(buf, sizeof(buf), DP_("%u Echievement Point", "%u Echievement Points", score), score);
e_widget_label_text_set(mod->label, buf);
}
E_Config_Dialog *
e_int_config_echievements(E_Container *con, const char *params EINA_UNUSED)
{
E_Config_Dialog *cfd = NULL;
E_Config_Dialog_View *v = NULL;
char buf[4096];
if (e_config_dialog_find("Echievements", "extensions/echievements"))
return NULL;
mod->obj_del_cb = (Evas_Object_Event_Cb)_obj_del;
v = E_NEW(E_Config_Dialog_View, 1);
v->free_cfdata = _free_data;
v->basic.create_widgets = _basic_create;
/*
v->create_cfdata = _create_data;
v->basic.apply_cfdata = _basic_apply;
v->basic.check_changed = _basic_check_changed;
*/
snprintf(buf, sizeof(buf), "%s/e-module-echievements.edj",
mod->module->dir);
cfd = e_config_dialog_new(con, D_("Echievements"), "Echievements",
"extensions/echievements", buf, 0, v, NULL);
e_dialog_resizable_set(cfd->dia, 1);
mod->cfd = cfd;
return cfd;
}
EINTERN void
ech_cfg_ech_update(Echievement *ec)
{
char progress[128];
unsigned int goal, counter;
if (!mod->cfd) return;
if ((!ec->dialog.icon) || (!ec->dialog.label)) return;
etrophy_trophy_goal_get(ec->trophy, &goal, &counter);
if (etrophy_trophy_earned_get(ec->trophy))
{
char date[256];
char buf[512];
time_t t0;
t0 = etrophy_trophy_date_get(ec->trophy);
strftime(date, sizeof(date), "%d %B %Y - %r", localtime(&t0));
snprintf(buf, sizeof(buf), D_("Achieved: %s"), date);
e_widget_label_text_set(ec->dialog.label, buf);
}
else if (goal < 2)
e_widget_label_text_set(ec->dialog.label, D_("Not achieved"));
else
{
snprintf(progress, sizeof(progress), D_("Progress: %u/%u"), counter, goal);
e_widget_label_text_set(ec->dialog.label, progress);
}
e_widget_frametable_object_repack(e_widget_parent_get(ec->dialog.label), ec->dialog.label, 1, 1, 3, 1, 1, 1, 1, 0);
_totals_update();
}
EINTERN void
ech_cfg_ech_add(Echievement *ec)
{
Evas *e;
Evas_Object *item;
int mh;
int w;
if (!mod->cfd) return;
/* use "all trophies" list current width
* since it's guaranteed to be correct for the moment
*/
evas_object_geometry_get(mod->cfd_list[1], NULL, NULL, &w, NULL);
e = evas_object_evas_get(mod->cfd_list[0]);
item = _item_create(e, ec, EINA_FALSE);
e_widget_list_object_append(mod->cfd_list[0], item, 1, 1, 0.5);
e_widget_size_min_get(mod->cfd_list[0], NULL, &mh);
evas_object_resize(mod->cfd_list[0], w, mh);
if (ec->dialog.icon || ec->dialog.label) return;
item = _item_create(e, ec, EINA_TRUE);
e_widget_list_object_append(mod->cfd_list[1], item, 1, 1, 0.5);
e_widget_size_min_get(mod->cfd_list[1], NULL, &mh);
evas_object_resize(mod->cfd_list[1], w, mh);
_totals_update();
}
#endif

82
src/e_mod_main.c Normal file
View File

@ -0,0 +1,82 @@
#include "e_mod_main.h"
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Desksanity"};
static E_Config_DD *conf_edd = NULL;
static Eina_List *handlers = NULL;
EINTERN Mod *mod = NULL;
EINTERN Config *ds_config = NULL;
static void
_e_mod_ech_config_load(void)
{
#undef T
#undef D
conf_edd = E_CONFIG_DD_NEW("Config", Config);
#define T Config
#define D conf_edd
E_CONFIG_VAL(D, T, config_version, UINT);
ds_config = e_config_domain_load("module.desksanity", conf_edd);
if (ds_config)
{
if (!e_util_module_config_check("Desksanity", ds_config->config_version, MOD_CONFIG_FILE_VERSION))
{}
}
if (!ds_config)
{
ds_config = E_NEW(Config, 1);
ds_config->config_version = (MOD_CONFIG_FILE_EPOCH << 16);
}
}
EAPI void *
e_modapi_init(E_Module *m)
{
char buf[4096];
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
snprintf(buf, sizeof(buf), "%s/e-module-desksanity.edj", m->dir);
//
//e_configure_registry_category_add("appearance", 80, D_("Look"),
//NULL, "preferences-look");
//e_configure_registry_item_add("extensions/desksanity", 110, D_("Echievements"),
//NULL, buf, e_int_config_desksanity);
efx_init();
mod = E_NEW(Mod, 1);
mod->module = m;
ds_init();
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m EINA_UNUSED)
{
e_configure_registry_item_del("appearance/desksanity");
e_configure_registry_category_del("extensions");
E_FN_DEL(e_object_del, mod->cfd);
ds_shutdown();
e_config_domain_save("module.desksanity", conf_edd, ds_config);
E_CONFIG_DD_FREE(conf_edd);
E_FREE(mod);
E_FREE_LIST(handlers, ecore_event_handler_del);
efx_shutdown();
return 1;
}
EAPI int
e_modapi_save(E_Module *m EINA_UNUSED)
{
e_config_domain_save("module.desksanity", conf_edd, ds_config);
return 1;
}

42
src/e_mod_main.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <e.h>
#include <Efx.h>
#ifdef ENABLE_NLS
# include <libintl.h>
# 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)
#define MOD_CONFIG_FILE_EPOCH 0
#define MOD_CONFIG_FILE_GENERATION 1
#define MOD_CONFIG_FILE_VERSION ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION)
typedef struct Mod
{
E_Config_Dialog *cfd;
E_Module *module;
} Mod;
typedef struct Config
{
unsigned int config_version;
} Config;
extern Mod *mod;
extern Config *ds_config;
#endif