'everything' module: allow external plugins to be build

- install header and everything.pc


SVN revision: 41740
This commit is contained in:
Hannes Janetzek 2009-08-13 15:10:54 +00:00
parent ce831c4ea7
commit 2e8857ee2a
16 changed files with 250 additions and 214 deletions

View File

@ -559,6 +559,7 @@ src/modules/syscon/Makefile
src/modules/syscon/module.desktop
src/modules/everything/Makefile
src/modules/everything/module.desktop
src/modules/everything/everything.pc
src/modules/systray/Makefile
src/modules/systray/module.desktop
src/preload/Makefile

View File

@ -0,0 +1,153 @@
#include "e.h"
#define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1
#define EVRY_ACTION_CONTINUE 2
#define EVRY_ASYNC_UPDATE_ADD 0
#define EVRY_ASYNC_UPDATE_CLEAR 1
typedef struct _Evry_Plugin Evry_Plugin;
typedef struct _Evry_Item Evry_Item;
typedef struct _Evry_Action Evry_Action;
typedef struct _Evry_App Evry_App;
typedef struct _Plugin_Config Plugin_Config;
struct _Plugin_Config
{
const char *name;
int loaded;
int enabled;
/* minimum input chars to query this source */
int min_query;
int priority;
const char *trigger;
};
struct _Evry_Item
{
Evry_Plugin *plugin;
const char *label;
const char *uri;
const char *mime;
Eina_Bool browseable;
/* these are only for internally use by plugins */
/* used e.g. as pointer for item data (Efreet_Desktop) or */
/* for internal stuff, like priority hints for sorting, etc */
void *data[4];
int priority;
/* not to be set by plugin! */
Evas_Object *o_icon;
Evas_Object *o_bg;
};
struct _Evry_Plugin
{
const char *name;
const char *icon;
enum { type_subject, type_action, type_object } type;
const char *type_in;
const char *type_out;
const char *trigger;
/* sync/async ?*/
Eina_Bool async_query;
/* whether candidates can be shown without input
* e.g. borders, app history */
Eina_Bool need_query;
Eina_Bool browseable;
/* run when plugin is activated. */
int (*begin) (Evry_Plugin *p, const Evry_Item *item);
int (*browse) (Evry_Plugin *p, const Evry_Item *item);
/* get candidates matching string, fills 'candidates' list */
int (*fetch) (Evry_Plugin *p, const char *input);
/* run before new query and when hiding 'everything' */
void (*cleanup) (Evry_Plugin *p);
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e);
/* provide more information for a candidate */
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
/* optional: default action for this plugins items */
int (*action) (Evry_Plugin *p, const Evry_Item *item, const char *input);
Evry_Action *act;
/* optional: create list of items when shown (e.g. for sorting) */
void (*realize_items) (Evry_Plugin *p, Evas *e);
Eina_List *items;
Evas_Object *(*config_page) (void);
void (*config_apply) (void);
/* only for internal use by plugin */
void *private;
/* not to be set by plugin! */
Evas_Object *tab;
Plugin_Config *config;
};
struct _Evry_Action
{
const char *name;
const char *type_in1;
const char *type_in2;
const char *type_out;
int (*action) (Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input);
int (*check_item) (Evry_Action *act, const Evry_Item *it);
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
/* use icon name from theme */
const char *icon;
Eina_Bool is_default;
/* only for internal use by plugin */
void *private;
/* not to be set by plugin! */
Evas_Object *o_icon;
};
struct _Evry_App
{
const char *file;
Efreet_Desktop *desktop;
};
void evry_plugin_register(Evry_Plugin *p);
void evry_plugin_unregister(Evry_Plugin *p);
void evry_action_register(Evry_Action *act);
void evry_action_unregister(Evry_Action *act);
Evry_Item *evry_item_new(Evry_Plugin *p, const char *label);
void evry_item_free(Evry_Item *it);
void evry_plugin_async_update(Evry_Plugin *plugin, int state);
void evry_clear_input(void);
int evry_icon_theme_set(Evas_Object *obj, const char *icon);

View File

@ -1,4 +1,4 @@
MAINTAINERCLEANFILES = Makefile.in
MAINTAINERCLEANFILES = Makefile.in everything.pc
MODULE = everything
# data files for the module
@ -16,9 +16,15 @@ INCLUDES = -I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/modules \
@e_cflags@
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
EVRYHEADERS = Evry.h
module_la_SOURCES = $(EVRYHEADERS) \
e_mod_main.c \
e_mod_main.h \
evry.c \
evry_config.c
@ -28,64 +34,71 @@ module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
installed_headersdir = $(prefix)/include/@PACKAGE@
installed_headers_DATA = $(EVRYHEADERS)
evry_plug_appsdir = $(pkgdir)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = everything.pc
plugindir = $(libdir)/enlightenment/everything_plugins/core/$(MODULE_ARCH)
evry_plug_appsdir = $(plugindir)
evry_plug_apps_LTLIBRARIES = evry_plug_apps.la
evry_plug_apps_la_SOURCES = evry_plug_apps.c
evry_plug_apps_la_LIBADD = @e_libs@
evry_plug_apps_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_apps_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_borderdir = $(pkgdir)
evry_plug_borderdir = $(plugindir)
evry_plug_border_LTLIBRARIES = evry_plug_border.la
evry_plug_border_la_SOURCES = evry_plug_border.c
evry_plug_border_la_LIBADD = @e_libs@
evry_plug_border_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_border_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_border_actdir = $(pkgdir)
evry_plug_border_actdir = $(plugindir)
evry_plug_border_act_LTLIBRARIES = evry_plug_border_act.la
evry_plug_border_act_la_SOURCES = evry_plug_border_act.c
evry_plug_border_act_la_LIBADD = @e_libs@
evry_plug_border_act_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_border_act_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_dir_browsedir = $(pkgdir)
evry_plug_dir_browsedir = $(plugindir)
evry_plug_dir_browse_LTLIBRARIES = evry_plug_dir_browse.la
evry_plug_dir_browse_la_SOURCES = evry_plug_dir_browse.c
evry_plug_dir_browse_la_LIBADD = @e_libs@
evry_plug_dir_browse_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_dir_browse_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_trackerdir = $(pkgdir)
evry_plug_trackerdir = $(plugindir)
evry_plug_tracker_LTLIBRARIES = evry_plug_tracker.la
evry_plug_tracker_la_SOURCES = evry_plug_tracker.c
evry_plug_tracker_la_LIBADD = @e_libs@
evry_plug_tracker_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_tracker_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_calcdir = $(pkgdir)
evry_plug_calcdir = $(plugindir)
evry_plug_calc_LTLIBRARIES = evry_plug_calc.la
evry_plug_calc_la_SOURCES = evry_plug_calc.c
evry_plug_calc_la_LIBADD = @e_libs@
evry_plug_calc_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_calc_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_configdir = $(pkgdir)
evry_plug_configdir = $(plugindir)
evry_plug_config_LTLIBRARIES = evry_plug_config.la
evry_plug_config_la_SOURCES = evry_plug_config.c
evry_plug_config_la_LIBADD = @e_libs@
evry_plug_config_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_config_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_aspelldir = $(pkgdir)
evry_plug_aspelldir = $(plugindir)
evry_plug_aspell_LTLIBRARIES = evry_plug_aspell.la
evry_plug_aspell_la_SOURCES = evry_plug_aspell.c
evry_plug_aspell_la_LIBADD = @e_libs@
evry_plug_aspell_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_aspell_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_clipboarddir = $(pkgdir)
evry_plug_clipboarddir = $(plugindir)
evry_plug_clipboard_LTLIBRARIES = evry_plug_clipboard.la
evry_plug_clipboard_la_SOURCES = evry_plug_clipboard.c
evry_plug_clipboard_la_LIBADD = @e_libs@

View File

@ -2,6 +2,11 @@
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
/* TODO
- watch plugin directories
- get plugins from ~/.e/e/everything_plugins
*/
#include "e_mod_main.h"
/* actual module specifics */
@ -41,7 +46,10 @@ static Eina_Bool list_cb(Eina_Module *m, void *data)
EAPI void *
e_modapi_init(E_Module *m)
{
char buf[4096];
Eina_List *files;
char buf[4096], dir[4096];
char *file;
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything",
e_user_homedir_get(), e_config_profile_get());
ecore_file_mkdir(buf);
@ -93,11 +101,19 @@ e_modapi_init(E_Module *m)
evry_init();
eina_module_init();
plugins = eina_module_list_get(NULL, m->dir, 1, &list_cb, NULL);
if (plugins)
printf("plugins loaded\n");
else
printf("could not find plugins in %s\n", m->dir);
snprintf(dir, sizeof(dir), "%s/enlightenment/everything_plugins", e_prefix_lib_get());
files = ecore_file_ls(dir);
EINA_LIST_FREE(files, file)
{
snprintf(buf, sizeof(buf), "%s/%s/%s", dir, file, MODULE_ARCH);
if (ecore_file_is_dir(buf))
plugins = eina_module_list_get(plugins, buf, 1, &list_cb, NULL);
free(file);
}
/* add module supplied action */
act = e_action_add("everything");
@ -142,9 +158,12 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
eina_list_free(evry_conf->plugins);
eina_list_free(evry_conf->actions);
eina_module_list_unload(plugins);
eina_module_list_flush(plugins);
eina_array_free(plugins);
if (plugins)
{
eina_module_list_unload(plugins);
eina_module_list_flush(plugins);
eina_array_free(plugins);
}
eina_module_shutdown();

View File

@ -1,30 +1,10 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
#include "Evry.h"
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
#define E_TYPEDEFS 1
typedef struct _Evry_Plugin Evry_Plugin;
typedef struct _Evry_Item Evry_Item;
typedef struct _Evry_Action Evry_Action;
typedef struct _Evry_App Evry_App;
#undef E_TYPEDEFS
typedef struct _Config Config;
typedef struct _Plugin_Config Plugin_Config;
#define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1
#define EVRY_ACTION_CONTINUE 2
#define EVRY_ASYNC_UPDATE_ADD 0
#define EVRY_ASYNC_UPDATE_CLEAR 1
struct _Config
{
@ -50,133 +30,6 @@ struct _Config
Eina_Hash *history;
};
struct _Plugin_Config
{
const char *name;
int loaded;
int enabled;
/* minimum input chars to query this source */
int min_query;
int priority;
const char *trigger;
};
struct _Evry_Item
{
Evry_Plugin *plugin;
const char *label;
const char *uri;
const char *mime;
Eina_Bool browseable;
/* these are only for internally use by plugins */
/* used e.g. as pointer for item data (Efreet_Desktop) or */
/* for internal stuff, like priority hints for sorting, etc */
void *data[4];
int priority;
/* not to be set by plugin! */
Evas_Object *o_icon;
Evas_Object *o_bg;
};
struct _Evry_Plugin
{
const char *name;
const char *icon;
enum {type_subject, type_action, type_object } type;
const char *type_in;
const char *type_out;
const char *trigger;
/* sync/async ?*/
Eina_Bool async_query;
/* whether candidates can be shown without input
* e.g. borders, app history */
Eina_Bool need_query;
Eina_Bool browseable;
/* run when plugin is activated. */
int (*begin) (Evry_Plugin *p, const Evry_Item *item);
int (*browse) (Evry_Plugin *p, const Evry_Item *item);
/* get candidates matching string, fills 'candidates' list */
int (*fetch) (Evry_Plugin *p, const char *input);
/* run before new query and when hiding 'everything' */
void (*cleanup) (Evry_Plugin *p);
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e);
/* provide more information for a candidate */
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
/* optional: default action for this plugins items */
int (*action) (Evry_Plugin *p, const Evry_Item *item, const char *input);
Evry_Action *act;
/* optional: create list of items when shown (e.g. for sorting) */
void (*realize_items) (Evry_Plugin *p, Evas *e);
Eina_List *items;
Evas_Object *(*config_page) (void);
void (*config_apply) (void);
/* only for internal use by plugin */
void *private;
/* not to be set by plugin! */
Evas_Object *tab;
Plugin_Config *config;
};
struct _Evry_Action
{
const char *name;
const char *type_in1;
const char *type_in2;
const char *type_out;
int (*action) (Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input);
int (*check_item) (Evry_Action *act, const Evry_Item *it);
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
/* use icon name from theme */
const char *icon;
Eina_Bool is_default;
/* only for internal use by plugin */
void *private;
/* not to be set by plugin! */
Evas_Object *o_icon;
};
struct _Evry_App
{
const char *file;
Efreet_Desktop *desktop;
};
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *m);
@ -184,20 +37,10 @@ EAPI int e_modapi_shutdown (E_Module *m);
EAPI int e_modapi_save (E_Module *m);
EAPI E_Config_Dialog *evry_config_dialog(E_Container *con, const char *params);
EAPI int evry_init(void);
EAPI int evry_shutdown(void);
EAPI int evry_show(E_Zone *zone);
EAPI void evry_hide(void);
EAPI void evry_plugin_register(Evry_Plugin *p);
EAPI void evry_plugin_unregister(Evry_Plugin *p);
EAPI void evry_action_register(Evry_Action *act);
EAPI void evry_action_unregister(Evry_Action *act);
EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state);
EAPI void evry_clear_input(void);
EAPI Evry_Item *evry_item_new(Evry_Plugin *p, const char *label);
EAPI void evry_item_free(Evry_Item *it);
EAPI int evry_icon_theme_set(Evas_Object *obj, const char *icon);
int evry_init(void);
int evry_shutdown(void);
int evry_show(E_Zone *zone);
void evry_hide(void);
extern Config *evry_conf;

View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/@PACKAGE@
Name: e17-everything
Description: Everything Module for E17
Requires: enlightenment
Version: @VERSION@
Libs: -L${libdir}
Libs.private:
Cflags: -I${includedir}

View File

@ -184,7 +184,7 @@ static Evry_Selector *selector = NULL;
static Evry_Plugin *action_selector = NULL;
/* externally accessible functions */
EAPI int
int
evry_init(void)
{
_evry_plug_actions_init();
@ -192,7 +192,7 @@ evry_init(void)
return 1;
}
EAPI int
int
evry_shutdown(void)
{
// TODO free action_selector
@ -200,7 +200,7 @@ evry_shutdown(void)
return 1;
}
EAPI int
int
evry_show(E_Zone *zone)
{
if (win) return 0;
@ -286,7 +286,7 @@ evry_show(E_Zone *zone)
return 0;
}
EAPI void
void
evry_hide(void)
{
Ecore_Event *ev;
@ -323,7 +323,7 @@ evry_hide(void)
}
EAPI void
void
evry_clear_input(void)
{
Evry_State *s = selector->state;
@ -334,7 +334,7 @@ evry_clear_input(void)
}
}
EAPI Evry_Item *
Evry_Item *
evry_item_new(Evry_Plugin *p, const char *label)
{
Evry_Item *it;
@ -348,7 +348,7 @@ evry_item_new(Evry_Plugin *p, const char *label)
return it;
}
EAPI void
void
evry_item_free(Evry_Item *it)
{
if (it->label) eina_stringshare_del(it->label);
@ -1021,10 +1021,12 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
else if (!strcmp(ev->key, "Down"))
_evry_list_item_next(s);
else if (!strcmp(ev->key, "Right") &&
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
_evry_list_plugin_next(s);
else if (!strcmp(ev->key, "Left") &&
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
_evry_list_plugin_prev(s);
else if (!strcmp(ev->key, "Right"))
_evry_browse_item(selector);
@ -2080,7 +2082,7 @@ _evry_plugin_list_insert(Evry_State *s, Evry_Plugin *p)
}
EAPI void
void
evry_plugin_async_update(Evry_Plugin *p, int action)
{
Evry_State *s;

View File

@ -1,5 +1,4 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
typedef struct _Inst Inst;

View File

@ -1,5 +1,4 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
#include <ctype.h>
static const char TRIGGER[] = "aspell ";

View File

@ -1,5 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
static Evry_Plugin *p;

View File

@ -1,5 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
typedef struct _Inst Inst;

View File

@ -1,5 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
static void _item_add(Evry_Plugin *p, char *output, int prio);
static int _cb_data(void *data, int type, void *event);

View File

@ -1,5 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
static Evry_Action *act;
static Ecore_X_Window clipboard_win = 0;

View File

@ -1,5 +1,4 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
static Evry_Plugin *p;
static Evry_Action *act;

View File

@ -1,5 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
#define MAX_ITEMS 100
@ -242,7 +242,6 @@ _cleanup(Evry_Plugin *p)
static int
_fetch(Evry_Plugin *p, const char *input)
{
const char *directory = NULL;
Evry_Item *it;
Eina_List *l;
char match1[4096];
@ -321,9 +320,6 @@ _fetch(Evry_Plugin *p, const char *input)
s->command = EINA_FALSE;
}
if (!directory)
directory = s->directory;
if (input)
{
snprintf(match1, sizeof(match1), "%s*", input);

View File

@ -1,5 +1,5 @@
#include "e.h"
#include "e_mod_main.h"
#include "Evry.h"
/* TODO check if trackerd is running and version */