'everything' module:
authorHannes Janetzek <hannes.janetzek@gmail.com>
Mon, 8 Jun 2009 16:37:40 +0000 (16:37 +0000)
committerHannes Janetzek <hannes.janetzek@gmail.com>
Mon, 8 Jun 2009 16:37:40 +0000 (16:37 +0000)
- fix update matches to show the right current source
- beginning to add settings

SVN revision: 40974

src/modules/everything/e_mod_main.c
src/modules/everything/e_mod_main.h
src/modules/everything/evry.c

index 9fd65fc..930612c 100644 (file)
@@ -14,6 +14,10 @@ static E_Module *conf_module = NULL;
 static E_Action *act = NULL;
 static E_Int_Menu_Augmentation *maug = NULL;
 
+static E_Config_DD *conf_edd = NULL;
+static E_Config_DD *conf_item_edd = NULL;
+Config *evry_conf;
+
 /* module setup */
 EAPI E_Module_Api e_modapi =
   {
@@ -24,6 +28,41 @@ EAPI E_Module_Api e_modapi =
 EAPI void *
 e_modapi_init(E_Module *m)
 {
+   char buf[4096];
+   snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything", 
+           e_user_homedir_get(), e_config_profile_get());
+   ecore_file_mkdir(buf);
+
+   conf_item_edd = E_CONFIG_DD_NEW("Source_Config", Source_Config);
+#undef T
+#undef D
+#define T Source_Config
+#define D conf_item_edd
+   E_CONFIG_VAL(D, T, name, STR);
+   E_CONFIG_VAL(D, T, min_query, INT);
+   conf_edd = E_CONFIG_DD_NEW("Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+   E_CONFIG_VAL(D, T, width, INT);
+   E_CONFIG_VAL(D, T, height, INT);
+   E_CONFIG_VAL(D, T, rel_x, DOUBLE);
+   E_CONFIG_VAL(D, T, rel_y, DOUBLE);
+   E_CONFIG_LIST(D, T, sources, conf_item_edd);
+#undef T
+#undef D
+   evry_conf = e_config_domain_load("module.everything", conf_edd);
+
+   if (!evry_conf)
+     {
+       evry_conf = E_NEW(Config, 1);
+       evry_conf->rel_x = 50.0;
+       evry_conf->rel_y = 50.0;
+       evry_conf->width = 400;
+       evry_conf->height = 350;
+     }
+   
    conf_module = m;
    evry_init();
 
@@ -67,12 +106,17 @@ e_modapi_shutdown(E_Module *m)
 
    evry_shutdown();
    conf_module = NULL;
+
+   /* Clean EET */
+   E_CONFIG_DD_FREE(conf_item_edd);
+   E_CONFIG_DD_FREE(conf_edd);
    return 1;
 }
 
 EAPI int
 e_modapi_save(E_Module *m)
 {
+   e_config_domain_save("module.everything", conf_edd, evry_conf);
    return 1;
 }
 
index b30395d..30dba29 100644 (file)
 #undef E_TYPEDEFS
 #include "evry.h"
 
+typedef struct _Config Config;
+typedef struct _Source_Config Source_Config;
+
+struct _Config
+{
+  /* position */
+  double rel_x, rel_y;
+  /* size */
+  int width, height;
+
+  /* generic plugin config */
+  Eina_List *sources;
+};
+
+struct _Source_Config
+{
+  const char *name;
+
+  /* minimum input chars to query this source */
+  int min_query;
+};
+
+  
+
 EAPI extern E_Module_Api e_modapi;
 
 EAPI void *e_modapi_init     (E_Module *m);
@@ -25,4 +49,6 @@ EAPI int  evry_plug_border_shutdown(void);
 EAPI int  evry_plug_config_init(void);
 EAPI int  evry_plug_config_shutdown(void);
 
+extern Config *evry_conf;
+
 #endif
index 2cff5dd..69387c9 100644 (file)
@@ -2,8 +2,6 @@
 #include "e_mod_main.h"
 #include "evry.h"
 
-#define WIDTH 400
-#define HEIGHT 350
 #define INPUTLEN 40
 #define MATCH_LAG 0.33
 
@@ -91,7 +89,7 @@ EAPI int
 evry_show(E_Zone *zone)
 {
    Evas_Object *o;
-   int x, y, w, h;
+   int x, y;
 
    E_OBJECT_CHECK_RETURN(zone, 0);
    E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);
@@ -108,12 +106,10 @@ evry_show(E_Zone *zone)
        return 0;
      }
 
-   w = WIDTH;
-   h = HEIGHT;
-   x = zone->x + (zone->w / 2) - (w / 2);
-   y = zone->y + (zone->h / 2) - (h / 2);
+   x = zone->x + (zone->w / 2) - (evry_conf->width / 2);
+   y = zone->y + (zone->h / 2) - (evry_conf->height / 2);
 
-   popup = e_popup_new(zone, x, y, w, h);
+   popup = e_popup_new(zone, x, y, evry_conf->width, evry_conf->height);
    if (!popup) return 0;
 
    cmd_buf = malloc(INPUTLEN);
@@ -146,7 +142,7 @@ evry_show(E_Zone *zone)
 
    o = o_main;
    evas_object_move(o, 0, 0);
-   evas_object_resize(o, w, h);
+   evas_object_resize(o, evry_conf->width, evry_conf->height);
    evas_object_show(o);
    e_popup_edje_bg_object_set(popup, o);
 
@@ -567,17 +563,16 @@ _evry_matches_update()
             snprintf(buf, 64, "%s (%d)", plugin->name,
                      eina_list_count(plugin->candidates));
 
-            e_widget_toolbar_item_append(o_toolbar,
-                                         NULL, buf,
-                                         _evry_cb_plugin_sel,
-                                         plugin, NULL);
+            e_widget_toolbar_item_append(o_toolbar, NULL, buf,
+                                         _evry_cb_plugin_sel, plugin, NULL);
 
             cur_sources = eina_list_append(cur_sources, plugin);
             plugin_count++;
          }
      }
 
-   if (!cur_source && (plugin_count > 0))
+   if ((!cur_source || !eina_list_data_find(cur_sources, cur_source)) &&
+       (plugin_count > 0))
      {
        _evry_show_candidates(cur_sources->data);
      }