Example #1
0
/**
 * @brief Loads a background script by name.
 */
int background_load( const char *name )
{
   int ret;
   lua_State *L;
   const char *err;

   /* Free if exists. */
   background_clearCurrent();

   /* Load default. */
   if (name == NULL)
      bkg_cur_L = bkg_def_L;
   /* Load new script. */
   else
      bkg_cur_L = background_create( name );

   /* Comfort. */
   L = bkg_cur_L;
   if (L == NULL)
      return -1;

   /* Run Lua. */
   ret = 0;
   lua_getglobal(L,"background");
   ret = lua_pcall(L, 0, 0, 0);
   if (ret != 0) { /* error has occured */
      err = (lua_isstring(L,-1)) ? lua_tostring(L,-1) : NULL;
      WARN("Background -> 'background' : %s",
            (err) ? err : "unknown error");
      lua_pop(L, 1);
      ret = -1;
   }
   return 0;
}
Example #2
0
struct compressor * compressor_create(void) {
  struct compressor *cc;

  cc = safe_malloc(sizeof(struct compressor));
  cc->bgd = background_create(job,cc);
  ref_create(&(cc->r));
  ref_on_release(&(cc->r),cc_ref_release,cc);
  ref_on_free(&(cc->r),cc_ref_free,cc);
  return cc;
}
Example #3
0
int
main (int argc,
    char *argv[])
{
  struct desktop *desktop;

  gdk_set_allowed_backends ("wayland");

  gtk_init (&argc, &argv);

  g_resources_register (maynard_get_resource ());

  desktop = malloc (sizeof *desktop);
  desktop->output = NULL;
  desktop->shell = NULL;
  desktop->helper = NULL;

  desktop->gdk_display = gdk_display_get_default ();
  desktop->display =
    gdk_wayland_display_get_wl_display (desktop->gdk_display);
  if (desktop->display == NULL)
    {
      fprintf (stderr, "failed to get display: %m\n");
      return -1;
    }

  desktop->registry = wl_display_get_registry (desktop->display);
  wl_registry_add_listener (desktop->registry,
      &registry_listener, desktop);

  /* Wait until we have been notified about the compositor,
   * shell, and shell helper objects */
  while (!desktop->output || !desktop->shell || !desktop->helper)
    wl_display_roundtrip (desktop->display);

  desktop->grid_visible = FALSE;
  desktop->system_visible = FALSE;
  desktop->volume_visible = FALSE;

  css_setup (desktop);
  background_create (desktop);

  /* panel needs to be first so the clock and launcher grid can
   * be added to its layer */
  panel_create (desktop);
  clock_create (desktop);
  launcher_grid_create (desktop);

  gtk_main ();

  /* TODO cleanup */
  return EXIT_SUCCESS;
}
Example #4
0
/**
 * @brief Loads a background script by name.
 */
int background_load( const char *name )
{
   int ret, errf;
   lua_State *L;
   const char *err;

   /* Free if exists. */
   background_clearCurrent();

   /* Load default. */
   if (name == NULL)
      bkg_cur_L = bkg_def_L;
   /* Load new script. */
   else
      bkg_cur_L = background_create( name );

   /* Comfort. */
   L = bkg_cur_L;
   if (L == NULL)
      return -1;

#if DEBUGGING
   lua_pushcfunction(L, nlua_errTrace);
   errf = -2;
#else /* DEBUGGING */
   errf = 0;
#endif /* DEBUGGING */

   /* Run Lua. */
   ret = 0;
   lua_getglobal(L,"background");
   ret = lua_pcall(L, 0, 0, errf);
   if (ret != 0) { /* error has occurred */
      err = (lua_isstring(L,-1)) ? lua_tostring(L,-1) : NULL;
      WARN("Background -> 'background' : %s",
            (err) ? err : "unknown error");
      lua_pop(L, 1);
   }
#if DEBUGGING
   lua_pop(L, 1);
#endif /* DEBUGGING */
   return ret;
}
Example #5
0
/**
 * @brief Initializes the background system.
 */
int background_init (void)
{
   /* Load Lua. */
   bkg_def_L = background_create( "default" );
   return 0;
}