summaryrefslogtreecommitdiff
path: root/src/modules/everything-settings
diff options
context:
space:
mode:
authorHannes Janetzek <hannes.janetzek@gmail.com>2010-05-28 23:02:27 +0000
committerHannes Janetzek <hannes.janetzek@gmail.com>2010-05-28 23:02:27 +0000
commit249e926a61d1964e0ccc6f73772f5512d49851a5 (patch)
tree78d1ae5af5d6bdd8d804e8dccf24f635d72b4f69 /src/modules/everything-settings
parent9e581982f7317e401432b5f506a79ef4010ea863 (diff)
downloadenlightenment-249e926a61d1964e0ccc6f73772f5512d49851a5.tar.gz
initial config dialog for collection
suff mentioned in last commit msg SVN revision: 49263
Diffstat (limited to 'src/modules/everything-settings')
-rw-r--r--src/modules/everything-settings/e_mod_main.c148
1 files changed, 112 insertions, 36 deletions
diff --git a/src/modules/everything-settings/e_mod_main.c b/src/modules/everything-settings/e_mod_main.c
index 6221e68fab..2e91a4d01f 100644
--- a/src/modules/everything-settings/e_mod_main.c
+++ b/src/modules/everything-settings/e_mod_main.c
@@ -6,8 +6,16 @@
#include "e_mod_main.h"
#include "evry_api.h"
+typedef struct _Plugin Plugin;
typedef struct _Settings_Item Settings_Item;
+struct _Plugin
+{
+ Evry_Plugin base;
+ Eina_List *items;
+ Eina_List *categories;
+};
+
struct _Settings_Item
{
Evry_Item base;
@@ -16,22 +24,27 @@ struct _Settings_Item
E_Configure_It *eci;
};
-
static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL;
static Evry_Plugin *p;
static Evry_Action *act;
-static Eina_List *items = NULL;
+static Evry_Type E_SETTINGS;
static void
-_finish(Evry_Plugin *p)
+_finish(Evry_Plugin *plugin)
{
- Evry_Item *it;
-
+ Settings_Item *it;
+ GET_PLUGIN(p, plugin);
+
EVRY_PLUGIN_ITEMS_CLEAR(p);
- EINA_LIST_FREE(items, it)
- evry->item_free(it);
+ EINA_LIST_FREE(p->items, it)
+ EVRY_ITEM_FREE(it);
+
+ EINA_LIST_FREE(p->categories, it)
+ EVRY_ITEM_FREE(it);
+
+ E_FREE(p);
}
static Evas_Object *
@@ -40,50 +53,110 @@ _icon_get(Evry_Item *item, Evas *e)
Evas_Object *o;
Settings_Item *it = (Settings_Item *) item;
- if (it->eci->icon &&
+ if (it->eci && it->eci->icon &&
((o = evry->icon_theme_get(it->eci->icon, e)) ||
(o = e_util_icon_add(it->eci->icon, e))))
return o;
+ if (it->ecat->icon &&
+ ((o = evry->icon_theme_get(it->ecat->icon, e)) ||
+ (o = e_util_icon_add(it->ecat->icon, e))))
+ return o;
+
return NULL;
}
static Evry_Plugin *
-_begin(Evry_Plugin *p, const Evry_Item *item __UNUSED__)
+_browse(Evry_Plugin *plugin, const Evry_Item *item)
{
- Settings_Item *it;
- Eina_List *l, *ll;
- E_Configure_Cat *ecat;
- E_Configure_It *eci;
+ Plugin *p;
+ Eina_List *l;
+ Settings_Item *it, *it2;
+
+ if (!CHECK_TYPE(item, E_SETTINGS))
+ return NULL;
+
+ it = (Settings_Item *) item;
+
+ EVRY_PLUGIN_INSTANCE(p, plugin);
+
+ GET_PLUGIN(parent, item->plugin);
+
+ EINA_LIST_FOREACH(parent->items, l, it2)
+ {
+ if (it2->ecat == it->ecat)
+ {
+ EVRY_ITEM_REF(it2);
+ p->items = eina_list_append(p->items, it2);
+ }
+ }
+
+ return EVRY_PLUGIN(p);
+}
- EINA_LIST_FOREACH(e_configure_registry, l, ecat)
+static Evry_Plugin *
+_begin(Evry_Plugin *plugin, const Evry_Item *item __UNUSED__)
+{
+ Plugin *p;
+
+ EVRY_PLUGIN_INSTANCE(p, plugin);
+
+ return EVRY_PLUGIN(p);
+}
+
+static int
+_fetch(Evry_Plugin *plugin, const char *input)
+{
+ int len = input ? strlen(input) : 0;
+
+ GET_PLUGIN(p, plugin);
+
+ EVRY_PLUGIN_ITEMS_CLEAR(p);
+
+ if (len < plugin->config->min_query)
+ return 0;
+
+ if (!p->categories && !p->items)
{
- if ((ecat->pri < 0) || (!ecat->items)) continue;
- if (!strcmp(ecat->cat, "system")) continue;
+ Settings_Item *it;
+ Eina_List *l, *ll;
+ E_Configure_Cat *ecat;
+ E_Configure_It *eci;
- EINA_LIST_FOREACH(ecat->items, ll, eci)
+ EINA_LIST_FOREACH(e_configure_registry, l, ecat)
{
- if (eci->pri < 0) continue;
+ if ((ecat->pri < 0) || (!ecat->items)) continue;
+ if (!strcmp(ecat->cat, "system")) continue;
- it = EVRY_ITEM_NEW(Settings_Item, p, eci->label, _icon_get, NULL);
- it->eci = eci;
+ it = EVRY_ITEM_NEW(Settings_Item, p, ecat->label, _icon_get, NULL);
it->ecat = ecat;
- EVRY_ITEM_DETAIL_SET(it, ecat->label);
+ EVRY_ITEM(it)->browseable = EINA_TRUE;
+ p->categories = eina_list_append(p->categories, it);
+
+ EINA_LIST_FOREACH(ecat->items, ll, eci)
+ {
+ if (eci->pri < 0) continue;
+
+ it = EVRY_ITEM_NEW(Settings_Item, p, eci->label, _icon_get, NULL);
+ it->eci = eci;
+ it->ecat = ecat;
+ EVRY_ITEM_DETAIL_SET(it, ecat->label);
- items = eina_list_append(items, it);
+ p->items = eina_list_append(p->items, it);
+ }
}
}
- return p;
+
+ EVRY_PLUGIN_ITEMS_ADD(p, p->categories, input, 1, 1);
+
+ if (input || !p->categories)
+ return EVRY_PLUGIN_ITEMS_ADD(p, p->items, input, 1, 1);
}
static int
-_fetch(Evry_Plugin *p, const char *input)
+_action_check(Evry_Action *act, const Evry_Item *item)
{
- EVRY_PLUGIN_ITEMS_CLEAR(p);
-
- if (!input) return 0;
-
- return EVRY_PLUGIN_ITEMS_ADD(p, items, input, 1, 1);
+ return !!(((Settings_Item*)item)->eci);
}
static int
@@ -112,16 +185,19 @@ _plugins_init(const Evry_API *_api)
if (!evry->api_version_check(EVRY_API_VERSION))
return EINA_FALSE;
- p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"), "preferences-desktop",
- evry->type_register("E_SETTINGS"),
+ E_SETTINGS = evry->type_register("E_SETTINGS");
+
+ p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"),
+ "preferences-desktop", E_SETTINGS,
_begin, _finish, _fetch, NULL);
-
+ p->browse = &_browse;
evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 10);
- act = EVRY_ACTION_NEW(N_("Show Dialog"),
- evry->type_register("E_SETTINGS"), 0,
- "preferences-advanced", _action, NULL);
+ act = EVRY_ACTION_NEW(N_("Show Dialog"), E_SETTINGS, 0,
+ "preferences-advanced", _action, _action_check);
+ /* p->actions = eina_list_append(p->actions, act); */
+
evry->action_register(act, 0);
return EINA_TRUE;
@@ -134,7 +210,7 @@ _plugins_shutdown(void)
EVRY_PLUGIN_FREE(p);
- evry->action_free(act);
+ EVRY_ACTION_FREE(act);
evry_module->active = EINA_FALSE;
}