much cleaner iconboar. ok - right now it doesn't scroll. use the buidl

scritp again (pass in a directory path to set up.. i'd suggest

mkdir ~/.e
mkdir ~/.e/desktop
mkdir ~/.e/desktop/default
build_iconbar_db.sh ~/.e/desktop/default

the scritp is a bit smaller now :)


SVN revision: 5519
This commit is contained in:
Carsten Haitzler 2001-10-19 09:13:18 +00:00
parent 5d2c820b96
commit 8e5adf71a6
13 changed files with 544 additions and 861 deletions

View File

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = intl po src lib client doc
SUBDIRS = intl po src lib client tools doc
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
config.h.in config.sub configure install-sh \

View File

@ -1,4 +1,48 @@
/* config.h.in. Generated automatically from configure.ac by autoheader. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */
#undef C_ALLOCA
/* Define to empty if the keyword does not work. */
#undef const
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define as __inline if that's what the C compiler calls it. */
#undef inline
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#undef STACK_DIRECTION
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
#undef ENLIGHTENMENT_VERSION
#undef ENLIGHTENMENT_MAJOR
#undef ENLIGHTENMENT_MINOR
@ -16,191 +60,81 @@
#undef PACKAGE_LIB_DIR
#undef USE_FERITE
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define if you have the `dcgettext' function. */
#undef HAVE_DCGETTEXT
/* Define if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if you have the `feof_unlocked' function. */
#undef HAVE_FEOF_UNLOCKED
/* Define if you have the `fgets_unlocked' function. */
#undef HAVE_FGETS_UNLOCKED
/* Define if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* Define if you have the `getegid' function. */
#undef HAVE_GETEGID
/* Define if you have the `geteuid' function. */
#undef HAVE_GETEUID
/* Define if you have the `getgid' function. */
#undef HAVE_GETGID
/* Define if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define if you have the `munmap' function. */
#undef HAVE_MUNMAP
/* Define if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define if you have the `putenv' function. */
#undef HAVE_PUTENV
/* Define if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the `stpcpy' function. */
#undef HAVE_STPCPY
/* Define if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the `tsearch' function. */
#undef HAVE_TSEARCH
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the `__argz_count' function. */
/* Define if you have the __argz_count function. */
#undef HAVE___ARGZ_COUNT
/* Define if you have the `__argz_next' function. */
/* Define if you have the __argz_next function. */
#undef HAVE___ARGZ_NEXT
/* Define if you have the `__argz_stringify' function. */
/* Define if you have the __argz_stringify function. */
#undef HAVE___ARGZ_STRINGIFY
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Define if you have the dcgettext function. */
#undef HAVE_DCGETTEXT
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the munmap function. */
#undef HAVE_MUNMAP
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
/* Define if you have the setenv function. */
#undef HAVE_SETENV
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
/* Define if you have the stpcpy function. */
#undef HAVE_STPCPY
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the i library (-li). */
#undef HAVE_LIBI
/* Name of package */
#undef PACKAGE
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define if using the dmalloc debugging malloc package */
#undef WITH_DMALLOC
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#undef inline
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t

View File

@ -252,6 +252,7 @@ lib/Makefile
client/Makefile
intl/Makefile
po/Makefile.in
tools/Makefile
doc/Makefile
doc/kernel-doc
doc/html-customizations.dsl

Binary file not shown.

View File

@ -1,83 +1,40 @@
#!/bin/sh
# db to create
DB="./.e_iconbar.db"
DB=$1"/.e_iconbar.db"
BIT=$1"/.e_iconbar.bits.db"
# replace ICONDIR with where you keep icons, or just use full paths below
setup ()
{
NUM=0
ICONDIR="/usr/share/pixmaps"
E_PREFIX="/usr/local"
rm -f $DB
PREFIX="/usr/local"
SYSIC="/usr/share/pixmaps"
USRIC=$HOME"/stuff/icons"
NUM=0
rm -f $DB
}
finish ()
{
edb_ed $DB add "/ib/num" int $NUM
edb_ed $DB add "/icons/count" int $NUM
}
# usage: icon 'image_path' 'exec'
icon ()
{
edb_ed $DB add "/ib/"$NUM"/icon" str "$1"
edb_ed $DB add "/ib/"$NUM"/exec" str "$2"
NUM=$[ $NUM + 1 ];
e_img_import "$1" $DB":""/icons/"$NUM"/image"
edb_ed $DB add "/icons/"$NUM"/exec" str "$2"
NUM=$[ $NUM + 1 ];
}
config ()
{
edb_ed $DB add "/ib/"$1 int $2
}
str ()
{
edb_ed $DB add "/ib/"$1 str $2
}
#################################################
##
## Define Icons here
##
setup
# title is put at top or left of bar, this may be removed in future
# vline/hline are the images that are repeated as borders for the bar / scroll region (for vert / horiz. bars).
str 'image/title' $E_PREFIX'/share/enlightenment/data/images/ib_title.png'
str 'image/vline' $E_PREFIX'/share/enlightenment/data/images/vline.png'
str 'image/hline' $E_PREFIX'/share/enlightenment/data/images/hline.png'
# 0 width / height makes it equal view's width / height, negative values for left/top go from bottowm right corner. scroll_w is used for both horizontal and vertical bars (i guess it should be renamed scroll_thikness or something).
config 'geom/w' 0
config 'geom/h' 75
config 'geom/top' -75
config 'geom/left' 0
config 'geom/scroll_w' 16
config 'geom/horizontal' 1
config 'scroll_when_less' 0
# change icondir above, or replace with full pathname
icon $ICONDIR'/gnome-term.png' 'Eterm'
icon $ICONDIR'/gnome-ccdesktop.png' 'sylpheed'
icon $ICONDIR'/netscape.png' 'netscape'
icon $ICONDIR'/gnome-irc.png' 'xchat'
icon $ICONDIR'/gnome-gimp.png' 'gimp'
icon $ICONDIR'/mc/gnome-audio.png' 'xmms'
icon $ICONDIR'/home/raster/stuff/icons/star_office.png' '/home/raster/.desktop/Office'
#icon $ICONDIR'/write.png' 'abiword'
#icon $ICONDIR'/spreadsheet.png' 'gnumeric'
#icon $ICONDIR'/synth.png' 'SpiralSynth'
#icon $ICONDIR'/modsynth.png' 'SpiralSynthModular'
#icon $ICONDIR'/loops.png' 'SpiralLoops'
#icon $ICONDIR'/drakconf.png' 'gnomecc'
#icon $ICONDIR'/floppy.png' 'NULL'
#icon $ICONDIR'/trash.png' 'NULL'
icon $SYSIC"/gnome-term.png" "Eterm"
icon $SYSIC"/gnome-ccdesktop.png" "sylpheed"
icon $SYSIC"/netscape.png" "netscape"
icon $USRIC"/mozilla.png" "mozilla"
icon $SYSIC"/gnome-irc.png" "xchat"
icon $SYSIC"/gnome-gimp.png" "gimp"
icon $SYSIC"/mc/gnome-audio.png" "xmms"
icon $USRIC"star_office.png" "/home/raster/.desktop/Office"
finish
cp -f $PREFIX"/share/enlightenment/data/iconbar/iconbar_bottom.bits.db" $BIT

View File

@ -259,6 +259,14 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type)
(*((Evas_List *)(&(data[node->offset])))) = l2;
}
break;
case E_CFG_TYPE_KEY:
{
char *val;
sprintf(buf, "%s/%s", prefix, node->prefix);
(*((char **)(&(data[node->offset])))) = strdup(buf);
}
break;
default:
break;
}

View File

@ -162,7 +162,8 @@ enum _e_config_datatype
E_CFG_TYPE_INT,
E_CFG_TYPE_STR,
E_CFG_TYPE_FLOAT,
E_CFG_TYPE_LIST
E_CFG_TYPE_LIST,
E_CFG_TYPE_KEY
};
struct _e_config_base_type

View File

@ -1,567 +1,363 @@
#include "iconbar.h"
static Evas_List iconbars;
static Evas_List iconbars = NULL;
static E_Config_Base_Type *cf_iconbar = NULL;
static E_Config_Base_Type *cf_iconbar_icon = NULL;
static void ib_bits_show(void *data);
static void ib_bits_hide(void *data);
static void ib_bits_move(void *data, double x, double y);
static void ib_bits_resize(void *data, double w, double h);
static void ib_bits_raise(void *data);
static void ib_bits_lower(void *data);
static void ib_bits_set_layer(void *data, int l);
static void ib_bits_set_clip(void *data, Evas_Object clip);
static void ib_bits_set_color_class(void *data, char *cc, int r, int g, int b, int a);
static void ib_bits_get_min_size(void *data, double *w, double *h);
static void ib_bits_get_max_size(void *data, double *w, double *h);
static void ib_mouse_in(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
static void ib_mouse_out(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
static void ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
static void ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
void
e_iconbar_init()
{
cf_iconbar_icon = e_config_type_new();
E_CONFIG_NODE(cf_iconbar_icon, "exec", E_CFG_TYPE_STR, NULL, E_Iconbar_Icon, exec, 0, 0, "");
E_CONFIG_NODE(cf_iconbar_icon, "image", E_CFG_TYPE_KEY, NULL, E_Iconbar_Icon, image_path, 0, 0, "");
cf_iconbar = e_config_type_new();
E_CONFIG_NODE(cf_iconbar, "icons", E_CFG_TYPE_LIST, cf_iconbar_icon, E_Iconbar, icons, 0, 0, NULL);
}
E_Iconbar *
e_iconbar_new(E_View *v)
{
/* vertical lines (left, center, right) and title */
/* Evas_Object ovl, ovc, ovr, ot; */
E_Iconbar *ib;
ib = NEW(E_Iconbar, 1);
ZERO(ib, E_Iconbar, 1);
OBJ_INIT(ib, e_iconbar_free);
printf("in ib_new()\n");
ib->v = v;
ib->e = v->evas;
/* ib->name = strdup(v->dir); */
/* e_iconbar_draw(ib); */
iconbars = evas_list_append(iconbars, ib);
if(e_iconbar_config(ib) == 0)
return NULL;
return ib;
}
void
e_iconbar_realize(E_Iconbar *ib)
{
printf("in e_iconbar_realize()\n");
if(ib->geom.conf.left < 0)
ib->geom.left = ib->geom.conf.left + ib->v->size.w;
if(ib->geom.conf.top < 0)
ib->geom.top = ib->geom.conf.top + ib->v->size.h;
if(ib->geom.conf.w == 0)
ib->geom.w = ib->v->size.w;
if(ib->geom.conf.h == 0)
ib->geom.h = ib->v->size.h;
printf("w: %i, h: %i\nt: %i, l: %i\n", ib->geom.w, ib->geom.h, ib->geom.top, ib->geom.left);
/* horizontal */
if (ib->geom.horizontal)
{
ib->obj.scroll = evas_add_rectangle(ib->e);
ib->obj.line_l = evas_add_image_from_file(ib->e, ib->image.hline);
ib->obj.line_c = evas_add_image_from_file(ib->e, ib->image.hline);
ib->obj.line_r = evas_add_image_from_file(ib->e, ib->image.hline);
ib->obj.title = evas_add_image_from_file(ib->e, ib->image.title);
ib->obj.clip = evas_add_rectangle(ib->e);
evas_get_image_size(ib->e, ib->obj.title, &ib->geom.title_w, &ib->geom.title_h);
evas_get_image_size(ib->e, ib->obj.line_l, &ib->geom.line_w, &ib->geom.line_h);
evas_set_layer(ib->e, ib->obj.scroll, 400);
evas_resize(ib->e, ib->obj.scroll, ib->geom.w, ib->geom.scroll_w);
evas_resize(ib->e, ib->obj.line_l, ib->geom.w, ib->geom.line_h);
evas_resize(ib->e, ib->obj.line_c, ib->geom.w, ib->geom.line_h);
evas_resize(ib->e, ib->obj.line_r, ib->geom.w, ib->geom.line_h);
evas_resize(ib->e, ib->obj.clip, ib->geom.w, ib->geom.h);
evas_set_image_fill(ib->e, ib->obj.line_l, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_c, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_r, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_move(ib->e, ib->obj.scroll, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_r, ib->geom.left, ib->geom.top + ib->geom.h);
evas_move(ib->e, ib->obj.title, ib->geom.left - ib->geom.title_w - 5, ib->geom.top + (ib->geom.h - ib->geom.title_h) / 2);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
evas_set_color(ib->e, ib->obj.scroll, 129, 129, 129, 0);
evas_set_color(ib->e, ib->obj.clip, 255, 255, 255, 255);
}
/* vertical */
if (!ib->geom.horizontal)
{
ib->obj.scroll = evas_add_rectangle(ib->e);
ib->obj.line_l = evas_add_image_from_file(ib->e, ib->image.vline);
ib->obj.line_c = evas_add_image_from_file(ib->e, ib->image.vline);
ib->obj.line_r = evas_add_image_from_file(ib->e, ib->image.vline);
ib->obj.title = evas_add_image_from_file(ib->e, ib->image.title);
ib->obj.clip = evas_add_rectangle(ib->e);
evas_get_image_size(ib->e, ib->obj.title, &ib->geom.title_w, &ib->geom.title_h);
evas_get_image_size(ib->e, ib->obj.line_l, &ib->geom.line_w, &ib->geom.line_h);
evas_set_layer(ib->e, ib->obj.scroll, 400);
evas_resize(ib->e, ib->obj.scroll, ib->geom.scroll_w, ib->geom.h);
evas_resize(ib->e, ib->obj.line_l, ib->geom.line_w, ib->geom.h);
evas_resize(ib->e, ib->obj.line_c, ib->geom.line_w, ib->geom.h);
evas_resize(ib->e, ib->obj.line_r, ib->geom.line_w, ib->geom.h);
evas_resize(ib->e, ib->obj.clip, ib->geom.w, ib->geom.h);
evas_set_image_fill(ib->e, ib->obj.line_l, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_c, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_r, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_move(ib->e, ib->obj.scroll, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_r, ib->geom.left + ib->geom.w, ib->geom.top);
evas_move(ib->e, ib->obj.title, ib->geom.left + ((ib->geom.w - ib->geom.title_w - ib->geom.scroll_w) / 2 ), ib->geom.top - ib->geom.title_h - 5);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
evas_set_color(ib->e, ib->obj.scroll, 129, 129, 129, 0);
evas_set_color(ib->e, ib->obj.clip, 255, 255, 255, 255);
}
/* Clip icons */
{
Evas_List l;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *i;
i = l->data;
evas_set_clip(ib->e, i->image, ib->obj.clip);
}
}
/* show the iconbar */
evas_show(ib->e, ib->obj.scroll);
evas_show(ib->e, ib->obj.line_l);
evas_show(ib->e, ib->obj.line_c);
evas_show(ib->e, ib->obj.line_r);
evas_show(ib->e, ib->obj.title);
evas_show(ib->e, ib->obj.clip);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_MOVE, s_mouse_move, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_IN, s_mouse_in, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_OUT, s_mouse_out, ib);
e_iconbar_fix_icons(ib);
printf("realized!\n");
}
E_Iconbar_Icon *
e_iconbar_new_icon(E_Iconbar *ib, char *image, char *exec)
{
E_Iconbar_Icon *i;
i = NEW(E_Iconbar_Icon, 1);
i->image = evas_add_image_from_file(ib->e, image);
i->exec = strdup(exec);
evas_get_image_size(ib->e, i->image, &(i->w), &(i->h));
if (ib->geom.horizontal)
{
i->x = 0;
i->y = (ib->geom.h - i->h - ib->geom.scroll_w) / 2 + ib->geom.top;
}
else
{
i->x = (ib->geom.w - i->w - ib->geom.scroll_w) / 2 + ib->geom.left;
i->y = 0;
}
printf("x: %f, y: %f\n", i->x, i->y);
evas_callback_add(ib->e, i->image, CALLBACK_MOUSE_IN, i_mouse_in, NULL);
evas_callback_add(ib->e, i->image, CALLBACK_MOUSE_OUT, i_mouse_out, NULL);
evas_callback_add(ib->e, i->image, CALLBACK_MOUSE_DOWN, i_mouse_down, i->exec);
evas_set_color(ib->e, i->image, 255, 255, 255, 128);
evas_set_layer(ib->e, i->image, 400);
/* evas_set_clip(ib->e, i->image, ib->obj.clip); */
/* printf("before ib->icons set\n"); */
ib->icons = evas_list_append(ib->icons, i);
/* printf("after set\n"); */
return i;
}
int
e_iconbar_config(E_Iconbar *ib)
{
E_DB_File *db;
char buf[PATH_MAX], *userdir;
/* userdir = e_config_user_dir(); */
/* sprintf(buf, "%sbehavior/iconbar.db", userdir); */
sprintf(buf, "%s/.e_iconbar.db", ib->v->dir);
ib->db = strdup(buf);
db = e_db_open_read(ib->db);
if (!db)
{
/* ib->no_show = 1;
db = e_db_open(ib->db);
e_db_int_set(db, "/ib/num", 0);
e_db_int_set(db, "/ib/geom/w", 75);
e_db_int_set(db, "/ib/geom/h", 620);
e_db_int_set(db, "/ib/geom/top", 165);
e_db_int_set(db, "/ib/geom/left", -150);
e_db_int_set(db, "/ib/geom/scroll_w", 16);
e_db_int_set(db, "/ib/geom/horizontal", 0);
e_db_int_set(db, "/ib/scroll_when_less", 0);
e_db_str_set(db, "/ib/image/title", "/usr/local/share/enlightenment/data/ib_title.png");
e_db_str_set(db, "/ib/image/vline", "/usr/local/share/enlightenment/data/vline.png");
e_db_str_set(db, "/ib/image/hline", "/usr/local/share/enlightenment/data/hline.png");
*/
return 0;
}
e_db_int_get(db, "/ib/geom/w", &(ib->geom.conf.w) );
e_db_int_get(db, "/ib/geom/h", &(ib->geom.conf.h));
e_db_int_get(db, "/ib/geom/top", &(ib->geom.conf.top));
e_db_int_get(db, "/ib/geom/left", &(ib->geom.conf.left));
e_db_int_get(db, "/ib/geom/scroll_w", &(ib->geom.scroll_w));
e_db_int_get(db, "/ib/geom/horizontal", &(ib->geom.horizontal));
e_db_int_get(db, "/ib/scroll_when_less", &(ib->scroll_when_less));
ib->image.title = e_db_str_get(db, "/ib/image/title");
ib->image.vline = e_db_str_get(db, "/ib/image/vline");
ib->image.hline = e_db_str_get(db, "/ib/image/hline");
ib->start = 0.0;
ib->icons = NULL;
ib->geom.left = ib->geom.conf.left;
ib->geom.top = ib->geom.conf.top;
ib->geom.w = ib->geom.conf.w;
ib->geom.h = ib->geom.conf.h;
/*
{
double w, h;
evas_get_viewport(ib->e, NULL, NULL, &w, &h);
if(ib->geom.conf.left < 0)
ib->geom.left = ib->geom.conf.left + w;
else
ib->geom.left = ib->geom.conf.left;
if(ib->geom.conf.top < 0)
ib->geom.top = ib->geom.conf.top + h;
else
ib->geom.top = ib->geom.conf.top;
}
*/
printf("w: %i, h: %i\nt: %i, l: %i\n", ib->geom.w, ib->geom.h, ib->geom.top, ib->geom.left);
{
int i, num;
if (e_db_int_get(db, "/ib/num", &num))
{
printf("making %i icons...\n", num);
Evas_List l;
char buf[PATH_MAX];
E_Iconbar *ib;
sprintf(buf, "%s/.e_iconbar.db", v->dir);
ib = e_config_load(buf, "", cf_iconbar);
if (!ib) return NULL;
OBJ_INIT(ib, e_iconbar_free);
ib->view = v;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
for ( i = 0; i < num; i++)
{
char *icon, *exec, buf[PATH_MAX];
sprintf(buf, "/ib/%i/icon", i);
/* printf("reading #%i's icon...\n", i); */
icon = e_db_str_get(db, buf);
/* printf("icon: %s, reading #%i's exec...\n", icon, i); */
sprintf(buf, "/ib/%i/exec", i);
exec = e_db_str_get(db, buf);
printf("exec: %s... creating icon\n", exec);
/* printf("creating icon, %s, %s\n", icon, exec); */
e_iconbar_new_icon(ib, icon, exec);
printf("created...\n");
}
}
}
/* printf("created icon.\n"); */
e_db_close(db);
return 1;
}
void
e_iconbar_fix_icons(E_Iconbar *ib)
{
Evas_List l;
double cur, spacer;
spacer = 8.0;
if (!ib->geom.horizontal)
{
cur = ib->geom.top + ib->start + spacer;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *i;
i = l->data;
i->y = cur;
i->x = (ib->geom.w - i->w - ib->geom.scroll_w) / 2 + ib->geom.left;
cur = cur + i->h + spacer;
evas_move(ib->e, i->image, i->x, i->y);
evas_show(ib->e, i->image);
}
ib->length = cur - ib->start - ib->geom.top;
}
else
{
cur = ib->geom.left + ib->start + spacer;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *i;
i = l->data;
i->x = cur;
i->y = (ib->geom.h - i->h - ib->geom.scroll_w) / 2 + ib->geom.top;
cur = cur + i->w + spacer;
evas_move(ib->e, i->image, i->x, i->y);
evas_show(ib->e, i->image);
}
ib->length = cur - ib->start - ib->geom.left;
}
}
void
e_iconbar_scroll(int val, void *data)
{
E_Iconbar *ib;
double vis_length;
/* printf("before scroll data to ib set\n"); */
ib = data;
/* printf("after data set\n"); */
/* printf("start: %f, speed: %f\n", ib->start, ib->speed); */
ib->start = ib->start - ib->speed;
if (ib->geom.horizontal) vis_length = ib->geom.w;
else vis_length = ib->geom.h;
if (ib->length > vis_length)
{
if (ib->start > 0)
ib->start = 0;
else if (ib->start < vis_length - ib->length)
ib->start = vis_length - ib->length;
}
else if (ib->scroll_when_less)
{
/* icons scroll even if they don't fill the bar */
if (ib->start < 0)
ib->start = 0;
else if (ib->start > vis_length - ib->length)
ib->start = vis_length - ib->length;
}
else
{
ib->start = 0;
}
/* printf("before fix\n"); */
e_iconbar_fix_icons(ib);
/* printf("after fix\n"); */
if (ib->scrolling)
{
/* printf("before timer\n"); */
ecore_add_event_timer("e_iconbar_scroll()", 0.01, e_iconbar_scroll, 1, ib);
/* printf("after timer\n"); */
}
}
void
i_mouse_in(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
evas_set_color(_e, _o, 255, 255, 255, 255);
}
void
i_mouse_out(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
evas_set_color(_e, _o, 255, 255, 255, 128);
}
void
i_mouse_down(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
char *file = _data;
e_exec_run(file);
}
void
s_mouse_move(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar *ib;
double center;
int top_speed;
double r;
/* printf("set ib in s_mouse_move\n"); */
ib = _data;
top_speed = 5;
if (ib->geom.horizontal)
{
center = ib->geom.left + (.5 * ib->geom.w);
r = (_x - center) / (.5 * ib->geom.w);
}
else
{
center = ib->geom.top + (.5 * ib->geom.h);
r = (_y - center) / (.5 * ib->geom.h);
}
ib->speed = r * (double)top_speed;
e_iconbar_scroll(1, ib);
}
void
s_mouse_in(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar *ib;
ib = _data;
/* printf("setting scrolling\n"); */
ib->scrolling = 1;
/* printf("set scrolling\n"); */
}
void
s_mouse_out(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar *ib;
ib = _data;
ib->scrolling = 0;
ic = l->data;
OBJ_INIT(ic, e_iconbar_icon_free);
ic->iconbar = ib;
}
sprintf(buf, "%s/.e_iconbar.bits.db", v->dir);
ib->bit = ebits_load(buf);
if (!ib->bit)
{
OBJ_UNREF(ib);
return NULL;
}
return ib;
}
void
e_iconbar_free(E_Iconbar *ib)
{
iconbars = evas_list_remove(iconbars, ib);
ib->view->changed = 1;
if (ib->bit) ebits_free(ib->bit);
if (ib->icons)
{
Evas_List l;
Evas_List l;
printf("in e_iconbar_clean_up()\n");
iconbars = evas_list_remove(iconbars, ib);
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *i;
i = l->data;
FREE(i);
}
FREE(ib->icons);
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
ic = l->data;
OBJ_UNREF(ic);
}
evas_list_free(ib->icons);
}
FREE(ib);
e_db_runtime_flush();
printf("e_iconbar_clean_up() run successfully\n");
}
void
e_iconbar_icon_free(E_Iconbar_Icon *ic)
{
if (ic->image) evas_del_object(ic->iconbar->view->evas, ic->image);
IF_FREE(ic->image_path);
IF_FREE(ic->exec);
FREE(ic);
}
void
e_iconbar_realize(E_Iconbar *ib)
{
Evas_List l;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
char buf[PATH_MAX];
ic = l->data;
sprintf(buf, "%s/.e_iconbar.db:%s", ib->view->dir, ic->image_path);
ic->image = evas_add_image_from_file(ib->view->evas, buf);
evas_set_color(ib->view->evas, ic->image, 255, 255, 255, 128);
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_IN, ib_mouse_in, ic);
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_OUT, ib_mouse_out, ic);
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_DOWN, ib_mouse_down, ic);
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_UP, ib_mouse_up, ic);
}
ebits_add_to_evas(ib->bit, ib->view->evas);
ebits_set_named_bit_replace(ib->bit, "Icons",
ib_bits_show,
ib_bits_hide,
ib_bits_move,
ib_bits_resize,
ib_bits_raise,
ib_bits_lower,
ib_bits_set_layer,
ib_bits_set_clip,
ib_bits_set_color_class,
ib_bits_get_min_size,
ib_bits_get_max_size,
ib);
ebits_set_layer(ib->bit, 10000);
e_iconbar_fix(ib);
}
void
e_iconbar_fix(E_Iconbar *ib)
{
Evas_List l;
double ix, iy, aw, ah;
ebits_move(ib->bit, 0, 0);
ebits_resize(ib->bit, ib->view->size.w, ib->view->size.h);
ebits_show(ib->bit);
ib->view->changed = 1;
ix = ib->icon_area.x;
iy = ib->icon_area.y;
aw = ib->icon_area.w;
ah = ib->icon_area.h;
if (aw > ah) /* horizontal */
{
}
else /* vertical */
{
}
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
int iw, ih;
double w, h;
double ox, oy;
ic = l->data;
evas_get_image_size(ic->iconbar->view->evas, ic->image, &iw, &ih);
w = iw;
h = ih;
ox = 0;
oy = 0;
if (aw > ah) /* horizontal */
{
if (h > ah)
{
w = (ah * w) / h;
h = ah;
}
ox = 0;
oy = (ah - h) / 2;
evas_move(ic->iconbar->view->evas, ic->image, ix + ox, iy + oy);
evas_resize(ic->iconbar->view->evas, ic->image, w, h);
ix += w;
}
else /* vertical */
{
if (w > aw)
{
h = (aw * h) / w;
w = aw;
}
ox = (aw - w) / 2;
oy = 0;
evas_move(ic->iconbar->view->evas, ic->image, ix + ox, iy + oy);
evas_resize(ic->iconbar->view->evas, ic->image, w, h);
iy += h;
}
}
}
static void
e_iconbar_idle(void *data)
ib_bits_show(void *data)
{
Evas_List l;
for (l = iconbars; l; l = l->next)
{
E_Iconbar *ib;
ib = l->data;
e_iconbar_update(ib);
/* e_iconbar_redraw(ib); */
}
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
ic = l->data;
evas_show(ic->iconbar->view->evas, ic->image);
}
}
void
e_iconbar_update(E_Iconbar *ib)
static void
ib_bits_hide(void *data)
{
if (ib->v->changed)
{
e_iconbar_redraw(ib);
}
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
ic = l->data;
evas_hide(ic->iconbar->view->evas, ic->image);
}
}
void
e_iconbar_redraw(E_Iconbar *ib)
static void
ib_bits_move(void *data, double x, double y)
{
if(ib->geom.conf.left < 0)
ib->geom.left = ib->geom.conf.left + ib->v->size.w;
if(ib->geom.conf.top < 0)
ib->geom.top = ib->geom.conf.top + ib->v->size.h;
if(ib->geom.conf.w == 0)
ib->geom.w = ib->v->size.w;
if(ib->geom.conf.h == 0)
ib->geom.h = ib->v->size.h;
/* horizontal */
if (ib->geom.horizontal)
{
evas_move(ib->e, ib->obj.scroll, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_r, ib->geom.left, ib->geom.top + ib->geom.h);
evas_move(ib->e, ib->obj.title, ib->geom.left - ib->geom.title_w - 5, ib->geom.top + (ib->geom.h - ib->geom.title_h) / 2);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
}
/* vertical */
if (!ib->geom.horizontal)
{
evas_move(ib->e, ib->obj.scroll, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_r, ib->geom.left + ib->geom.w, ib->geom.top);
evas_move(ib->e, ib->obj.title, ib->geom.left + ((ib->geom.w - ib->geom.title_w - ib->geom.scroll_w) / 2 ), ib->geom.top - ib->geom.title_h - 5);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
}
/* Clip icons */
{
Evas_List l;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *i;
i = l->data;
evas_set_clip(ib->e, i->image, ib->obj.clip);
}
}
/* show the iconbar */
evas_show(ib->e, ib->obj.scroll);
evas_show(ib->e, ib->obj.line_l);
evas_show(ib->e, ib->obj.line_c);
evas_show(ib->e, ib->obj.line_r);
evas_show(ib->e, ib->obj.title);
evas_show(ib->e, ib->obj.clip);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_MOVE, s_mouse_move, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_IN, s_mouse_in, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_OUT, s_mouse_out, ib);
e_iconbar_fix_icons(ib);
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
ib->icon_area.x = x;
ib->icon_area.y = y;
}
void
e_iconbar_init()
static void
ib_bits_resize(void *data, double w, double h)
{
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
ib->icon_area.w = w;
ib->icon_area.h = h;
}
static void
ib_bits_raise(void *data)
{
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
ic = l->data;
evas_raise(ic->iconbar->view->evas, ic->image);
}
}
static void
ib_bits_lower(void *data)
{
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
ic = l->data;
evas_lower(ic->iconbar->view->evas, ic->image);
}
}
static void
ib_bits_set_layer(void *data, int lay)
{
E_Iconbar *ib;
Evas_List l;
ib = (E_Iconbar *)data;
for (l = ib->icons; l; l = l->next)
{
E_Iconbar_Icon *ic;
ic = l->data;
evas_set_layer(ic->iconbar->view->evas, ic->image, lay);
}
}
static void
ib_bits_set_clip(void *data, Evas_Object clip)
{
}
static void
ib_bits_set_color_class(void *data, char *cc, int r, int g, int b, int a)
{
}
static void
ib_bits_get_min_size(void *data, double *w, double *h)
{
*w = 0;
*h = 0;
}
static void
ib_bits_get_max_size(void *data, double *w, double *h)
{
*w = 999999;
*h = 999999;
}
static void
ib_mouse_in(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar_Icon *ic;
ic = (E_Iconbar_Icon *)data;
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 255);
ic->iconbar->view->changed = 1;
}
static void
ib_mouse_out(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar_Icon *ic;
ic = (E_Iconbar_Icon *)data;
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 128);
ic->iconbar->view->changed = 1;
}
static void
ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar_Icon *ic;
ic = (E_Iconbar_Icon *)data;
e_exec_run(ic->exec);
}
static void
ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
ecore_event_filter_idle_handler_add(e_iconbar_idle, NULL);
}

View File

@ -6,11 +6,7 @@
#include "exec.h"
#include "view.h"
#define SCROLL_W 16
#define SCREEN_W 1280
typedef struct _iconbar_icon E_Iconbar_Icon;
typedef struct _E_Iconbar_Icon E_Iconbar_Icon;
#ifndef E_ICONBAR_TYPEDEF
#define E_ICONBAR_TYPEDEF
typedef struct _E_Iconbar E_Iconbar;
@ -21,86 +17,38 @@ typedef struct _E_Iconbar E_Iconbar;
typedef struct _E_View E_View;
#endif
struct _iconbar_icon
{
OBJ_PROPERTIES;
Evas_Object image;
char *exec;
int w, h;
double x, y;
int selected;
};
struct _E_Iconbar
{
OBJ_PROPERTIES;
OBJ_PROPERTIES;
E_View *view;
Evas_List icons;
char *name;
E_View *v;
Evas e;
Evas_List icons;
char *db;
struct {
Evas_Object clip;
Evas_Object scroll;
Evas_Object line_l;
Evas_Object line_c;
Evas_Object line_r;
Evas_Object title;
} obj;
struct {
char *title;
char *vline;
char *hline;
} image;
double start, speed, length;
int scrolling, scroll_when_less;
struct {
int w;
int h;
int top;
int left;
int scroll_w;
int title_w, title_h, line_w, line_h;
int horizontal; /* 1 - horiz, 0 - vert */
struct {
int top;
int left;
int h;
int w;
} conf;
} geom;
Ebits_Object *bit;
struct {
double x, y, w, h;
} icon_area;
};
struct _E_Iconbar_Icon
{
OBJ_PROPERTIES;
E_Iconbar *iconbar;
Evas_Object image;
char *image_path;
char *exec;
int selected;
};
void e_iconbar_init(void);
E_Iconbar *e_iconbar_new(E_View *);
int e_iconbar_config(E_Iconbar *);
void e_iconbar_realize(E_Iconbar *);
void e_iconbar_redraw(E_Iconbar *);