示例#1
0
static E_Gadcon_Client *
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
   Evas_Object *o;
   E_Gadcon_Client *gcc;
   Config_Face *inst;

   inst = eina_hash_find(temperature_config->faces, id);
   if (!inst)
     {
        inst = E_NEW(Config_Face, 1);
        inst->id = eina_stringshare_add(id);
        inst->poll_interval = 128;
        inst->low = 30;
        inst->high = 80;
        inst->sensor_type = SENSOR_TYPE_NONE;
        inst->sensor_name = NULL;
        inst->temp = -900;
        inst->units = CELSIUS;
#ifdef HAVE_EEZE
        inst->backend = UDEV;
#endif
        if (!temperature_config->faces)
          temperature_config->faces = eina_hash_string_superfast_new(NULL);
        eina_hash_direct_add(temperature_config->faces, inst->id, inst);
     }
   if (!inst->id) inst->id = eina_stringshare_add(id);
   E_CONFIG_LIMIT(inst->poll_interval, 1, 1024);
   E_CONFIG_LIMIT(inst->low, 0, 100);
   E_CONFIG_LIMIT(inst->high, 0, 220);
   E_CONFIG_LIMIT(inst->units, CELSIUS, FAHRENHEIT);
#ifdef HAVE_EEZE
   E_CONFIG_LIMIT(inst->backend, TEMPGET, UDEV);
#endif

   o = edje_object_add(gc->evas);
   e_theme_edje_object_set(o, "base/theme/modules/temperature",
                           "e/modules/temperature/main");

   gcc = e_gadcon_client_new(gc, name, id, style, o);
   gcc->data = inst;

   inst->gcc = gcc;
   inst->o_temp = o;
   inst->module = temperature_config->module;
   inst->have_temp = EINA_FALSE;
   temperature_face_update_config(inst);

   evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
                                  _temperature_face_cb_mouse_down, inst);
   return gcc;
}
EAPI void *
e_modapi_init(E_Module *m)
{
   char buf[4096];
   Eina_List *l;

   snprintf(buf, sizeof(buf), "%s/locale", e_module_dir_get(m));
   bindtextdomain(PACKAGE, buf);
   bind_textdomain_codeset(PACKAGE, "UTF-8");

   _alarms_edd = E_CONFIG_DD_NEW("Alarm_Alarm", Alarm);
#undef T
#undef D
#define T Alarm
#define D _alarms_edd
   E_CONFIG_VAL(D, T, name, STR);
   E_CONFIG_VAL(D, T, state, SHORT);
   E_CONFIG_VAL(D, T, description, STR);
   E_CONFIG_VAL(D, T, autoremove, SHORT);
   E_CONFIG_VAL(D, T, open_popup, SHORT);
   E_CONFIG_VAL(D, T, run_program, SHORT);
   E_CONFIG_VAL(D, T, program, STR);
   E_CONFIG_VAL(D, T, sched.type, SHORT);
   E_CONFIG_VAL(D, T, sched.date_epoch, DOUBLE);
   E_CONFIG_VAL(D, T, sched.day_monday, SHORT);
   E_CONFIG_VAL(D, T, sched.day_tuesday, SHORT);
   E_CONFIG_VAL(D, T, sched.day_wenesday, SHORT);
   E_CONFIG_VAL(D, T, sched.day_thursday, SHORT);
   E_CONFIG_VAL(D, T, sched.day_friday, SHORT);
   E_CONFIG_VAL(D, T, sched.day_saturday, SHORT);
   E_CONFIG_VAL(D, T, sched.day_sunday, SHORT);
   E_CONFIG_VAL(D, T, sched.hour, SHORT);
   E_CONFIG_VAL(D, T, sched.minute, SHORT);
   E_CONFIG_VAL(D, T, snooze.hour, SHORT);
   E_CONFIG_VAL(D, T, snooze.minute, SHORT);
   E_CONFIG_VAL(D, T, snooze.remember, SHORT);
   _conf_edd = E_CONFIG_DD_NEW("Alarm_Config", Config);
#undef T
#undef D
#define T Config
#define D _conf_edd
   E_CONFIG_VAL(D, T, time_format, SHORT);
   E_CONFIG_VAL(D, T, alarms_state, SHORT);
   E_CONFIG_LIST(D, T, alarms, _alarms_edd);
   E_CONFIG_VAL(D, T, alarms_details, SHORT);
   E_CONFIG_VAL(D, T, alarms_autoremove_default, SHORT);
   E_CONFIG_VAL(D, T, alarms_open_popup_default, SHORT);
   E_CONFIG_VAL(D, T, alarms_run_program_default, SHORT);
   E_CONFIG_VAL(D, T, alarms_program_default, STR);
   E_CONFIG_VAL(D, T, config_version, SHORT);
   alarm_config = e_config_domain_load("module.alarm", _conf_edd);
   if (alarm_config)
     {
        if (alarm_config->config_version < CONFIG_VERSION)
          {
             snprintf(buf, sizeof(buf),
                      D_("<hilight>Alarm module : Configuration Upgraded</hilight><br><br>"
                         "Your configuration of alarm module<br>"
                         "has been upgraded<br>"
                         "Your settings and alarms were removed<br>"
                         "Sorry for the inconvenience<br><br>"
                         "(%d -> %d)"), alarm_config->config_version, CONFIG_VERSION);
             e_module_dialog_show(alarm_config->module, D_("Alarm Module version " MODULE_VERSION), buf);
             alarm_config = NULL;
          }
        else
          {
             if (alarm_config->config_version > CONFIG_VERSION)
               {
                  snprintf(buf, sizeof(buf),
                           D_("<hilight>Alarm module : Configuration Downgraded</hilight><br><br>"
                              "Your configuration of Alarm module<br>"
                              "has been downgraded<br>"
                              "Your settings and alarms were removed<br>"
                              "Sorry for the inconvenience<br><br>"
                              "(%d ->%d)"), alarm_config->config_version, CONFIG_VERSION);
                  e_module_dialog_show(alarm_config->module, D_("Alarm Module version " MODULE_VERSION), buf);
                  alarm_config = NULL;
               }
          }
     }

   if (!alarm_config)
     {
	alarm_config = E_NEW(Config, 1);
        alarm_config->time_format = TIME_FORMAT_DEFAULT;
        alarm_config->alarms_state = ALARM_STATE_OFF;
	alarm_config->alarms_details = ALARMS_DETAILS_DEFAULT;
        alarm_config->alarms_autoremove_default = ALARMS_AUTOREMOVE_DEFAULT;
        alarm_config->alarms_open_popup_default = ALARMS_OPEN_POPUP_DEFAULT;
        alarm_config->alarms_run_program_default = ALARMS_RUN_PROGRAM_DEFAULT;
        alarm_config->config_version = CONFIG_VERSION;
     }
   E_CONFIG_LIMIT(alarm_config->time_format, TIME_FORMAT_12, TIME_FORMAT_24);
   E_CONFIG_LIMIT(alarm_config->alarms_details, 0, 1);
   E_CONFIG_LIMIT(alarm_config->alarms_autoremove_default, 0, 1);
   E_CONFIG_LIMIT(alarm_config->alarms_open_popup_default, 0, 1);

   /* set the number of ringing alarms */
   for (l=alarm_config->alarms; l; l=eina_list_next(l))
     {
        Alarm *al;
        al = eina_list_data_get(l);
        if (al->state == ALARM_STATE_RINGING)
          alarm_config->alarms_ringing_nb++;
     }

   /* set alarms state and check dates */
   if (alarm_config->alarms)
     {
        for (l=alarm_config->alarms; l; l=eina_list_next(l))
          {
             Alarm *al;
             al = eina_list_data_get(l);
             _alarm_check_date(al, 0);
          }
        alarm_config->alarms_ring_etimer = ecore_timer_add(ALARMS_CHECK_TIMER,
                                                           _cb_alarms_ring_etimer,
                                                           NULL);
     }

   //FIXME not sure about that, maybe must use edje directly to find the part
   if (!e_theme_category_find(THEME_IN_E))
     {
        char buf[512];

        snprintf(buf, sizeof(buf), "%s/alarm.edj", e_module_dir_get(m));
        alarm_config->theme = strdup(buf);
     }
   
   alarm_config->module = m;

   e_gadcon_provider_register((const E_Gadcon_Client_Class *)&_gadcon_class);

   return alarm_config;
}
int
news_config_init(void)
{
   _news_feed_edd = E_CONFIG_DD_NEW("News_Feed", News_Feed);
#undef T
#undef D
#define T News_Feed
#define D _news_feed_edd
   E_CONFIG_VAL(D, T, name, STR);
   E_CONFIG_VAL(D, T, name_ovrw, SHORT);
   E_CONFIG_VAL(D, T, language, STR);
   E_CONFIG_VAL(D, T, language_ovrw, SHORT);
   E_CONFIG_VAL(D, T, description, STR);
   E_CONFIG_VAL(D, T, description_ovrw, SHORT);
   E_CONFIG_VAL(D, T, url_home, STR);
   E_CONFIG_VAL(D, T, url_home_ovrw, SHORT);
   E_CONFIG_VAL(D, T, url_feed, STR);
   E_CONFIG_VAL(D, T, icon, STR);
   E_CONFIG_VAL(D, T, icon_ovrw, SHORT);
   E_CONFIG_VAL(D, T, important, SHORT);
   _news_feed_ref_edd = E_CONFIG_DD_NEW("News_Feed_Ref", News_Feed_Ref);
#undef T
#undef D
#define T News_Feed_Ref
#define D _news_feed_ref_edd
   E_CONFIG_VAL(D, T, category, STR);
   E_CONFIG_VAL(D, T, name, STR);
   _news_feed_category_edd = E_CONFIG_DD_NEW("News_Feed_Category", News_Feed_Category);
#undef T
#undef D
#define T News_Feed_Category
#define D _news_feed_category_edd
   E_CONFIG_VAL(D, T, name, STR);
   E_CONFIG_VAL(D, T, icon, STR);
   E_CONFIG_LIST(D, T, feeds, _news_feed_edd);
   _news_feed_lang_edd = E_CONFIG_DD_NEW("News_Feed_Lang", News_Feed_Lang);
#undef T
#undef D
#define T News_Feed_Lang
#define D _news_feed_lang_edd
   E_CONFIG_VAL(D, T, key, STR);
   E_CONFIG_VAL(D, T, name, STR);
   _news_item_edd = E_CONFIG_DD_NEW("News_Item", News_Config_Item);
#undef T
#undef D
#define T News_Config_Item
#define D _news_item_edd
   E_CONFIG_VAL(D, T, id, STR);
   E_CONFIG_LIST(D, T, feed_refs, _news_feed_ref_edd);
   E_CONFIG_VAL(D, T, view_mode, SHORT);
   E_CONFIG_VAL(D, T, openmethod, SHORT);
   E_CONFIG_VAL(D, T, browser_open_home, SHORT);
   _news_edd = E_CONFIG_DD_NEW("News", News_Config);
#undef T
#undef D
#define T News_Config
#define D _news_edd
   E_CONFIG_VAL(D, T, version, SHORT);
   E_CONFIG_LIST(D, T, feed.categories, _news_feed_category_edd);
   E_CONFIG_VAL(D, T, feed.timer_m, INT);
   E_CONFIG_VAL(D, T, feed.sort_name, INT);
   E_CONFIG_LIST(D, T, feed.langs, _news_feed_lang_edd);
   E_CONFIG_VAL(D, T, feed.langs_all, SHORT);
   E_CONFIG_VAL(D, T, feed.langs_notset, SHORT);
   E_CONFIG_VAL(D, T, proxy.enable, SHORT);
   E_CONFIG_VAL(D, T, proxy.host, STR);
   E_CONFIG_VAL(D, T, proxy.port, INT);
   E_CONFIG_VAL(D, T, viewer.vfeeds.unread_first, SHORT);
   E_CONFIG_VAL(D, T, viewer.varticles.unread_first, SHORT);
   E_CONFIG_VAL(D, T, viewer.varticles.sort_date, SHORT);
   E_CONFIG_VAL(D, T, viewer.vcontent.font_size, SHORT);
   E_CONFIG_VAL(D, T, viewer.vcontent.font_color, STR);
   E_CONFIG_VAL(D, T, viewer.vcontent.font_shadow, SHORT);
   E_CONFIG_VAL(D, T, viewer.vcontent.font_shadow_color, STR);
   E_CONFIG_VAL(D, T, popup_news.active, SHORT);
   E_CONFIG_VAL(D, T, popup_news.timer_s, INT);
   E_CONFIG_VAL(D, T, popup_other.on_timeout, SHORT);
   E_CONFIG_VAL(D, T, popup_other.timer_s, INT);
   E_CONFIG_LIST(D, T, items, _news_item_edd);
   news->config = e_config_domain_load("module.news", _news_edd);

   if (news->config)
     {
        if (news->config->version < NEWS_CONFIG_VERSION)
          {
             news_util_message_show(D_("<hilight>News module : Configuration Upgraded</hilight><br><br>"
                                       "Your configuration of news module<br>"
                                       "has been upgraded<br>"
                                       "Your settings were removed<br>"
                                       "Sorry for the inconvenience<br><br>"
                                       "(%d -> %d)"), news->config->version, NEWS_CONFIG_VERSION);
             news->config = NULL;
          }
        else
          {
             if (news->config->version > NEWS_CONFIG_VERSION)
               {
                  news_util_message_show(D_("<hilight>News module : Configuration Downgraded</hilight><br><br>"
                                            "Your configuration of News module<br>"
                                            "has been downgraded<br>"
                                            "Your settings were removed<br>"
                                            "Sorry for the inconvenience<br><br>"
                                            "(%d ->%d)"), news->config->version, NEWS_CONFIG_VERSION);
                  news->config = NULL;
               }
          }
     }

   if (!news->config)
     {
        News_Config *c;

        c = E_NEW(News_Config, 1);
        news->config = c;
        c->version = NEWS_CONFIG_VERSION;

        news_feed_all_restore();

        c->feed.timer_m = NEWS_FEED_TIMER_DEFAULT;
        c->feed.sort_name = NEWS_FEED_SORT_NAME_DEFAULT;
        c->feed.langs = news_util_lang_detect();
        c->feed.langs_all = NEWS_FEED_LANG_ALL_DEFAULT;
        c->feed.langs_notset = 1;
        if (news_util_proxy_detect())
          c->proxy.enable = 1;
        else
          {
             c->proxy.host = NULL;
             c->proxy.port = NEWS_FEED_PROXY_PORT_DEFAULT;
          }

        c->viewer.vfeeds.unread_first = NEWS_VIEWER_VFEEDS_UNREAD_FIRST_DEFAULT;
        c->viewer.varticles.unread_first = NEWS_VIEWER_VARTICLES_UNREAD_FIRST_DEFAULT;
        c->viewer.varticles.sort_date = NEWS_VIEWER_VARTICLES_SORT_DATE_DEFAULT;
        c->viewer.vcontent.font_size = NEWS_VIEWER_VCONTENT_FONT_SIZE_DEFAULT;
        c->viewer.vcontent.font_color = eina_stringshare_add(NEWS_VIEWER_VCONTENT_FONT_COLOR_DEFAULT);
        c->viewer.vcontent.font_shadow = NEWS_VIEWER_VCONTENT_FONT_SHADOW_DEFAULT;
        c->viewer.vcontent.font_shadow_color = eina_stringshare_add(NEWS_VIEWER_VCONTENT_FONT_SHADOW_COLOR_DEFAULT);
        c->popup_news.active =  NEWS_FEED_POPUP_NEWS_ACTIVE_DEFAULT;
        c->popup_news.timer_s = NEWS_FEED_POPUP_NEWS_TIMER_S_DEFAULT;
        c->popup_other.on_timeout =  NEWS_FEED_POPUP_OTHER_ON_TIMEOUT_DEFAULT;
        c->popup_other.timer_s = NEWS_FEED_POPUP_OTHER_TIMER_S_DEFAULT;
     }

   E_CONFIG_LIMIT(news->config->feed.timer_m, NEWS_FEED_TIMER_MIN, NEWS_FEED_TIMER_MAX);
   E_CONFIG_LIMIT(news->config->feed.sort_name, 0, 1);
   E_CONFIG_LIMIT(news->config->proxy.enable, 0, 1);
   E_CONFIG_LIMIT(news->config->proxy.port, 1, 65535);
   E_CONFIG_LIMIT(news->config->viewer.vfeeds.unread_first, 0, 1);
   E_CONFIG_LIMIT(news->config->viewer.varticles.unread_first, 0, 1);
   E_CONFIG_LIMIT(news->config->viewer.varticles.sort_date, 0, 1);
   E_CONFIG_LIMIT(news->config->viewer.vcontent.font_size, NEWS_VIEWER_VCONTENT_FONT_SIZE_MIN, NEWS_VIEWER_VCONTENT_FONT_SIZE_MAX);
   E_CONFIG_LIMIT(news->config->viewer.vcontent.font_shadow, 0, 1);
   E_CONFIG_LIMIT(news->config->popup_news.timer_s, NEWS_POPUP_TIMER_S_MIN, NEWS_POPUP_TIMER_S_MAX);
   E_CONFIG_LIMIT(news->config->popup_other.on_timeout, 0, 1);
   E_CONFIG_LIMIT(news->config->popup_other.timer_s, NEWS_POPUP_TIMER_S_MIN, NEWS_POPUP_TIMER_S_MAX);

   return 1;
}
示例#4
0
文件: e_mod_main.c 项目: wargio/e17
EAPI void *
e_modapi_init(E_Module *m)
{
   char buf[4096];

   /* Set up a new configuration panel */
   snprintf(buf, sizeof(buf), "%s/e-module-gadman.edj", m->dir);
   e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, 
                                     "preferences-extensions");
   e_configure_registry_item_add("extensions/gadman", 150, _("Gadgets"), NULL, 
                                 buf, _config_gadman_module);

   /* Set this module to be loaded after all other modules, or we don't see
    modules loaded after this */
   e_module_priority_set(m, 100);

   gadman_init(m);

   //Settings values
   Man->conf_edd = E_CONFIG_DD_NEW("Gadman_Config", Config);
#undef T
#undef D
#define T Config
#define D Man->conf_edd
   E_CONFIG_VAL(D, T, bg_type, INT);
   E_CONFIG_VAL(D, T, color_r, INT);
   E_CONFIG_VAL(D, T, color_g, INT);
   E_CONFIG_VAL(D, T, color_b, INT);
   E_CONFIG_VAL(D, T, color_a, INT);
   E_CONFIG_VAL(D, T, anim_bg, INT);
   E_CONFIG_VAL(D, T, anim_gad, INT);
   E_CONFIG_VAL(D, T, custom_bg, STR);
   
   Man->conf = e_config_domain_load("module.gadman", Man->conf_edd);
   if (!Man->conf)
     {
	Man->conf = E_NEW(Config, 1);
	Man->conf->bg_type = 0;
	Man->conf->color_r = 255;
	Man->conf->color_g = 255;
	Man->conf->color_b = 255;
	Man->conf->color_a = 255;
	Man->conf->anim_bg = 1;
	Man->conf->anim_gad = 1;
	Man->conf->custom_bg = NULL;
     }
   E_CONFIG_LIMIT(Man->conf->bg_type, 0, 5);
   E_CONFIG_LIMIT(Man->conf->color_r, 0, 255);
   E_CONFIG_LIMIT(Man->conf->color_g, 0, 255);
   E_CONFIG_LIMIT(Man->conf->color_b, 0, 255);
   E_CONFIG_LIMIT(Man->conf->color_a, 0, 255);
   E_CONFIG_LIMIT(Man->conf->anim_bg, 0, 1);
   E_CONFIG_LIMIT(Man->conf->anim_gad, 0, 1);

   /* Menu augmentation */
   Man->icon_name = eina_stringshare_add(buf);
   Man->maug = NULL;
   Man->maug = 
     e_int_menus_menu_augmentation_add_sorted
     ("config/1", _("Gadgets"), _gadman_maug_add, (void *)Man->icon_name,
      NULL, NULL);
   /* Create toggle action */
   Man->action = e_action_add("gadman_toggle");
   if (Man->action)
     {
	Man->action->func.go = _gadman_action_cb;
	e_action_predef_name_set(_("Gadgets"), _("Show/hide gadgets"),
				 "gadman_toggle", NULL, NULL, 0);
     }

   gadman_update_bg();

   return Man;
}