E_API int
e_widget_preview_thumb_set(Evas_Object *obj, const char *file, const char *key, int w, int h)
{
   E_Widget_Data *wd;

   wd = e_widget_data_get(obj);
   if (wd->o_thumb) evas_object_del(wd->o_thumb);
   wd->o_thumb = e_thumb_icon_add(e_livethumb_evas_get(wd->img));
   if (eina_str_has_extension(file, "edj"))
     {
        if (key)
          e_thumb_icon_file_set(wd->o_thumb, file, key);
        else
        /* FIXME: There is probably a quicker way of doing this. */
        if (edje_file_group_exists(file, "icon"))
          e_thumb_icon_file_set(wd->o_thumb, file, "icon");
        else if (edje_file_group_exists(file, "e/desktop/background"))
          e_thumb_icon_file_set(wd->o_thumb, file, "e/desktop/background");
        else if (edje_file_group_exists(file, "e/init/splash"))
          e_thumb_icon_file_set(wd->o_thumb, file, "e/init/splash");
     }
   else
     e_thumb_icon_file_set(wd->o_thumb, file, NULL);
   evas_object_smart_callback_add(wd->o_thumb, "e_thumb_gen",
                                  _e_wid_preview_thumb_gen, wd);
   e_thumb_icon_size_set(wd->o_thumb, w, h);
   e_thumb_icon_begin(wd->o_thumb);
   e_livethumb_thumb_set(wd->img, wd->o_thumb);

   e_widget_change(obj);

   return 1;
}
Exemple #2
0
const char *
elicit_theme_find(Elicit *el, const char *theme)
{
  static char buf[PATH_MAX];

  // check in home dir
  if (el->path.confdir)
  {
    snprintf(buf, sizeof(buf), "%s/themes/%s.edj", el->path.confdir, theme);
    if (ecore_file_exists(buf) && edje_file_group_exists(buf, "elicit.main"))
      return buf;
  }

  // check in sys dir
  snprintf(buf, sizeof(buf), "%s/themes/%s.edj", el->path.datadir, theme);
  if (ecore_file_exists(buf) && edje_file_group_exists(buf, "elicit.main"))
    return buf;

  return NULL;
}
/* Edje: render() */
static Etk_Bool
_edje_render(Etk_Tree_Model * model, Etk_Tree_Row * row, Etk_Geometry geometry,
	     void *cell_data,
	     Evas_Object * cell_objects[ETK_TREE_MAX_OBJECTS_PER_MODEL],
	     Evas * evas)
{
	//g_debug("render called");

	Etk_Tree_Model_Edje *edje_model;
	Etk_Tree_Model_Edje_Data *edje_data;

	if (!(edje_model = (Etk_Tree_Model_Edje *) model) ||
	    !(edje_data = cell_data) || !evas || !edje_data->parameters)
		return ETK_FALSE;

	if (!
	    (cell_objects[0] =
	     etk_cache_find(edje_model->cache, edje_data->parameters, NULL))) {
		//g_debug("Rendering");

		cell_objects[0] = edje_object_add(evas);
		if (!cell_objects[0])
			return ETK_FALSE;
	}
	if (!edje_file_group_exists(edje_model->file, edje_model->part)) {
		g_error("%s does not exist in %s", edje_model->part,
			edje_model->file);
	}
	edje_object_file_set(cell_objects[0], edje_model->file,
			     edje_model->part);
	edje_extern_object_min_size_set(cell_objects[0], geometry.w,
					geometry.h);
	g_hash_table_foreach(edje_data->parameters, _edje_set_text_cb,
			     cell_objects[0]);
	evas_object_move(cell_objects[0], geometry.x, geometry.y);

	evas_object_resize(cell_objects[0], geometry.w, geometry.h);
	evas_object_show(cell_objects[0]);

	return ETK_TRUE;
}
int
main(int argc, char *argv[])
{
   Eina_Bool quit_option = EINA_FALSE;
   char *source = NULL, *header = NULL;
   int arg_index, ret = 0;
   Ecore_Getopt_Value values[] = {
     ECORE_GETOPT_VALUE_STR(prefix),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_NONE
   };

   setlocale(LC_NUMERIC, "C");

   eina_init();
   ecore_init();
   ecore_evas_init();
   edje_init();

   if (argc < 2)
     {
        fprintf(stderr, "Missing action. See '--help or -h'.\n");
        ret = 1;
	goto error_log;
     }

   _log_dom = eina_log_domain_register("elementary_codegen", EINA_COLOR_YELLOW);
   if (_log_dom < 0)
     {
        EINA_LOG_CRIT("could not register log domain 'elementary_codegen'");
        ret = 1;
        goto error_log;
     }

   arg_index = ecore_getopt_parse(&optdesc, values, argc, argv);
   if (arg_index < 0)
     {
        ERR("could not parse arguments.");
        ret = 1;
        goto error_getopt;
     }
   else if (quit_option) goto error_getopt;
   else if (arg_index != argc - 4)
     {
        fprintf(stderr, "Incorrect number of parameters. Requires "	\
		"fours arguments, an edje, the group, "			\
		"the source output (foo.c) and the header(foo.h).\n"    \
		"See %s --help\n", argv[0]);
        ret = 1;
        goto error_getopt;
     }

   file = argv[arg_index++];

   // check if the file is accessible
   if (access(file, R_OK) == -1)
     {
        ERR("File '%s' not accessible, error %d (%s).\n",
            file, errno, strerror(errno));
        ret = 1;
        goto error_getopt;
     }

   group = argv[arg_index++];
   source = argv[arg_index++];
   header = argv[arg_index++];

   if (!edje_file_group_exists(file, group))
     {
	ERR("The group %s not exists", group);
	ret = 2;
	goto error_getopt;
     }

   ee = ecore_evas_buffer_new(1, 1);
   if (!ee)
     {
	ERR("could not create ecore_evas_buffer");
	ret = 3;
	goto error_getopt;
     }

   if (!_file_descriptors_open(source, header))
     {
	ERR("Could not create the source files, error %d (%s)",
	    errno, strerror(errno));
	ret = 4;
	goto error_getopt;
     }

   if (!_headers_write(header))
     {
	ERR("Could not write the header, error %d (%s)",
	    errno, strerror(errno));
	ret = 5;
	goto error_getopt;
     }

   if (!_theme_set_write())
     WRN("Theme set getter/setter not created. Group name: %s invalid.", group);

   if (!_parse())
     {
	ERR("Could not parsing the EDJE");
	ret = 6;
	goto error_getopt;
     }

   if (!_footer_write(header))
     {
	ERR("Could not write the footer, error %d (%s)",
	    errno, strerror(errno));
	ret = 7;
	goto error_getopt;
     }

   if (!_file_descriptors_close())
     {
	ERR("Could not close the source files, error %d (%s)",
	    errno, strerror(errno));
	ret = 8;
     }

 error_getopt:
   if (ee)
     ecore_evas_free(ee);

 error_log:
   edje_shutdown();
   ecore_evas_shutdown();
   ecore_shutdown();
   eina_log_domain_unregister(_log_dom);
   eina_shutdown();

   if (ret > 4)
     {
	unlink(header);
	unlink(source);
     }

   return ret;
}
Exemple #5
0
int
elicit_theme_set(Elicit *el, const char *theme)
{
  const char *path;
  int w, h;

  if (!theme) theme = "default";
  /* first check if full path is given */
  if (theme[0] == '/')
  {
    if (!edje_file_group_exists(theme, "elicit.main"))
      return 0;
    path = theme;
  }
  else
    path = elicit_theme_find(el, theme);

  if (!path) {
    fprintf(stderr, "[Elicit] Warning: theme \"%s\" not found, falling back to default.\n", theme);
    theme = "default";
    path = elicit_theme_find(el, theme);
  }

  if (!path)
  {
    fprintf(stderr, "[Elicit] Error: theme \"%s\" not found.\n", theme);
    return 0;
  }

  if (el->path.theme) free(el->path.theme);
  el->path.theme = strdup(path);

  if (el->conf.theme != theme)
  {
    if (el->conf.theme) free(el->conf.theme);
    el->conf.theme = strdup(theme);
  }

  elicit_theme_unswallow_objs(el);

  edje_object_file_set(el->obj.main, path, "elicit.main");

  edje_object_size_min_get(el->obj.main, &w, &h);
  if (w > el->conf.w) el->conf.w = w;
  if (h > el->conf.h) el->conf.h = h;
  ecore_evas_size_min_set(el->ee, w, h);
  ecore_evas_resize(el->ee, el->conf.w, el->conf.h);

  evas_object_move(el->obj.main, 0, 0);
  evas_object_resize(el->obj.main, el->conf.w, el->conf.h);
  evas_object_show(el->obj.main);

  elicit_theme_swallow_objs(el);

  edje_object_signal_callback_add(el->obj.main, "elicit,*", "*", cb_edje_signal, el);
  edje_object_signal_callback_add(el->obj.main, "mouse,move", "*", cb_edje_move, el);

  color_changed(el->color);

  /* emit signals to set theme state */
  if (el->conf.grid_visible)
    edje_object_signal_emit(el->obj.main, "elicit,grid,on", "elicit");
  else
    edje_object_signal_emit(el->obj.main, "elicit,grid,off", "elicit");

  if (el->conf.show_band)
    edje_object_signal_emit(el->obj.main, "elicit,band,on", "elicit");
  else
    edje_object_signal_emit(el->obj.main, "elicit,band,off", "elicit");

  return 1;
}