예제 #1
0
/* main function */
int main(int argc, char **argv)
{
   // if etk init fails, print error msg to stderr
   if(!etk_init(argc, argv))
   {
      fprintf(stderr, _("Could not init Etk. Exiting...\n"));
      return 1;
   }
   // if you set --help in arguments, it will print some help information
   if(etk_argument_is_set("help", 0, ETK_FALSE))
   {
      printf(_("Usage: etk_prefs ARGUMENTS\n"));
      printf(_("ARGUMENTS:\n"));
      printf(_("   --help : print this message\n"));
      printf(_("   --theme=THEME : set theme from command line\n"));
      printf(_("   --themes-list : list themes\n"));
      return 0;
   }
   else if(etk_argument_is_set("themes-list", 0, ETK_FALSE)) // or if you will set --themes-list, it will print a list of available themes
   {
      Eina_List *themes;
      Eina_List *l;
      char *theme;
      themes = etk_theme_widget_available_themes_get();
      for(l = themes; l; l = l->next)
      {	 
	 theme = l->data;
         printf("%s\n", theme);
      }
      return 0;
   }
   
   etk_argument_value_get("theme", 0, ETK_FALSE, &_widget_theme); // if --theme argument set, it will set theme from commandline, if bad theme provided, it will print error to stderr
   if (_widget_theme)
   {
      if (etk_theme_widget_find(_widget_theme))
      {
         _etk_prefs_widget_theme = strdup(_widget_theme);   
         _etk_prefs_apply(); // apply changes
         etk_config_save(); // save them
         return 0;
      }
      else
      {
         fprintf(stderr, _("Theme %s not found. Exitting..\n"), _widget_theme); // print error message
         return 1;
      }
   }
   
   etk_prefs_show(); // show etk_prefs dialog
   
   etk_main(); // main loop
   etk_shutdown(); // shutdown etk
   
   return 0; // return success
}
예제 #2
0
/**
 * @brief Does the same thing as etk_init() except you can specify custom arguments that could be then retrieved with
 * etk_argument_* functions. For example, etk_init_full(argc, argv, "--option1 value --toggle1")
 * @param argc the location of the "argc" parameter passed to main(). It is used to parse the arguments specific to Etk.
 * It can be set to NULL.
 * @param argv the location of the "argv" parameter passed to main(). It is used to parse the arguments specific to Etk.
 * It can be set to NULL.
 * @param custom_opts a string corresponding to the custom arguments to add to argv. It can be set to NULL
 * @return Returns the number of times Etk has been initialized, or 0 on failure
 * @note It initializes Evas, Ecore and Edje so you don't need to initialize them after an etk_init()
 * @see etk_init()
 * @see etk_shutdown()
 */
int etk_init_full(int argc, char **argv, const char *custom_opts)
{
   char *engine_name = NULL;

   if (_etk_main_init_count > 0)
   {
      _etk_main_init_count++;
      return _etk_main_init_count;
   }
   else
   {
      /* Parse the arguments */
      etk_argument_init(argc, argv, custom_opts);
      etk_argument_value_get("etk-engine", 0, ETK_TRUE, &engine_name);

      /* Initialize the EFL */
      if (!evas_init())
      {
         ETK_WARNING("Evas initialization failed!");
         return 0;
      }
      if (!ecore_init())
      {
         ETK_WARNING("Ecore initialization failed!");
         return 0;
      }
      if (!ecore_imf_init())
      {
         ETK_WARNING("Ecore_IMF initialization failed!");
      }
      if (!edje_init())
      {
         ETK_WARNING("Edje initialization failed!");
         return 0;
      }

      /* TODO: maybe we should do this in etk_main().
       * Problem: if we do this, a program that uses directly ecore_main_loop_begin() and not etk_main() won't work */
      _etk_main_idle_enterer = ecore_idle_enterer_add(_etk_main_idle_enterer_cb, NULL);

      /* Initialize the subsystems of Etk */
      if (!etk_config_init())
      {
         ETK_WARNING("Etk_Config initialization failed!");
         return 0;
      }
      etk_config_load();
      etk_theme_init();
      if (!etk_engine_init())
      {
         ETK_WARNING("Etk_Engine initialization failed!");
         return 0;
      }
      if (!etk_engine_load(engine_name ? engine_name : "ecore_evas_software_x11"))
      {
         ETK_WARNING("Etk can not load the requested engine!");
         return 0;
      }
      etk_event_init();
      etk_tooltips_init();

      /* Initialize Gettext */
      setlocale(LC_ALL, "");
      bindtextdomain(PACKAGE, LOCALEDIR);
      textdomain(PACKAGE);

      free(engine_name);
      _etk_main_init_count++;
      return _etk_main_init_count;
   }
}