Esempio n. 1
0
/**
 * mpl_panel_clutter_load_base_style:
 *
 * Loads the base css style for the Panel. This function is called automatically
 * when the panel is constructed, so it is rarely necessary to call this from
 * the panel application. Calling this function mutliple times is safe (nop).
 */
void
mpl_panel_clutter_load_base_style (void)
{
  static gboolean already_loaded = FALSE;

  if (!already_loaded)
    {
      GError *error = NULL;

      /* Load in a base cache and a base style */
      mx_texture_cache_load_cache (mx_texture_cache_get_default (),
                                     MX_CACHE);
#if 0
      mx_style_load_from_file (mx_style_get_default (),
                                 THEMEDIR "/theme.css", NULL);
#endif
      mx_style_load_from_file (mx_style_get_default (),
                               DAWATI_RUNTIME_THEME_DIR "/shared/shared.css",
                               &error);

      if (error)
        {
          g_warning ("Error loading Dawati style: %s", error->message);
          g_clear_error (&error);
        }

      already_loaded = TRUE;
    }
}
Esempio n. 2
0
/**
 * mpl_panel_clutter_load_base_style:
 *
 * Loads the base css style for the Panel. This function is called automatically
 * when the panel is constructed, so it is rarely necessary to call this from
 * the panel application. Calling this function mutliple times is safe (nop).
 */
void
mpl_panel_clutter_load_base_style (void)
{
  static gboolean already_loaded = FALSE;

  if (!already_loaded)
    {
      GError *error = NULL;
      gboolean envset;

      /* Load in a base cache and a base style */
      mx_texture_cache_load_cache (mx_texture_cache_get_default (),
                                     MX_CACHE);
#if 0
      mx_style_load_from_file (mx_style_get_default (),
                                 THEMEDIR "/theme.css", NULL);
#endif

      /* Won't override MX_RC_FILE env if it's alread set */
      envset = g_setenv ("MX_RC_FILE", DAWATI_MX_THEME "/default.css", FALSE);

      if (!envset)
        g_message ("MX_RC_FILE not set");

      mx_style_load_from_file (mx_style_get_default (),
                               DAWATI_RUNTIME_THEME_DIR "/shared/shared.css",
                               &error);

      if (error)
        {
          g_warning ("Error loading Dawati style: %s", error->message);
          g_clear_error (&error);
        }

      already_loaded = TRUE;
    }
}
int
main (int     argc,
      char  **argv)
{
  bool standalone = false;
  char const *geometry = NULL;
  int dpi = 0;
  GOptionEntry _options[] = {
    { "standalone", 's', 0, G_OPTION_ARG_NONE, &standalone,
      "Run as standalone app (for testing purpose)", NULL },
    { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry,
      "Window geometry in standalone mode", NULL },
#if CLUTTER_CHECK_VERSION(1, 3, 0)
    { "clutter-font-dpi", 'd', 0, G_OPTION_ARG_INT, &dpi,
      "Set clutter font resolution to <dpi>", "<dpi>" },
#endif
    { NULL }
  };

  ClutterActor     *shell;
  GOptionContext   *context;
  ClutterInitError  clutter_error;
  GError           *error = NULL;

  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  context = g_option_context_new ("- Dawati devices panel");
  g_option_context_add_main_entries (context, _options, GETTEXT_PACKAGE);
  g_option_context_add_group (context, clutter_get_option_group_without_init ());
  if (!g_option_context_parse (context, &argc, &argv, &error))
  {
    g_critical ("%s %s", G_STRLOC, error->message);
    g_critical ("Starting in standalone mode.");
    g_clear_error (&error);
    standalone = true;
  }
  g_option_context_free (context);

  clutter_error = clutter_init (&argc, &argv);
  if (clutter_error != CLUTTER_INIT_SUCCESS)
    {
      g_critical ("Unable to initialise clutter");
      return EXIT_FAILURE;
    }

  notify_init (_("Dawati Devices Panel"));

  /* Just for icon theme, no widgets. */
  gtk_init (&argc, &argv);

  if (dpi)
    {
#if CLUTTER_CHECK_VERSION(1, 3, 0)
      ClutterSettings *settings = clutter_settings_get_default ();
      g_object_set (settings, "font-dpi", dpi * 1000, NULL);
#endif
    }

  /* Load base styling for default font size */
  mpl_panel_clutter_load_base_style ();

  mx_texture_cache_load_cache (mx_texture_cache_get_default (),
                               PKGDATADIR "/mx.cache");
  mx_style_load_from_file (mx_style_get_default (),
                           THEMEDIR "/panel.css", NULL);

  if (standalone)
  {
    ClutterActor *stage = clutter_stage_get_default ();

    if (geometry)
    {
      int x, y;
      unsigned int width, height;
      XParseGeometry (geometry, &x, &y, &width, &height);
      clutter_actor_set_size (stage, width, height);
    } else
    {
      clutter_actor_set_size (stage, MPD_SHELL_WIDTH, MPD_SHELL_HEIGHT);
    }

    shell = mpd_shell_new ();

    g_signal_connect (shell, "request-hide",
                      G_CALLBACK (_shell_request_hide_cb), NULL);
    g_signal_connect (stage, "notify::width",
                      G_CALLBACK (_stage_width_notify_cb), shell);
    g_signal_connect (stage, "notify::height",
                      G_CALLBACK (_stage_height_notify_cb), shell);

    clutter_container_add_actor (CLUTTER_CONTAINER (stage), shell);
    clutter_actor_show_all (stage);

  } else {

    MplPanelClient *panel = mpd_panel_new ("devices",
                                           _("devices"),
                                           "devices-button");
    shell = mpd_shell_new ();
    mpd_shell_set_client (MPD_SHELL (shell), panel);
    g_signal_connect (shell, "request-hide",
                      G_CALLBACK (_shell_request_hide_cb), panel);
    g_signal_connect (shell, "request-show",
                      G_CALLBACK (_shell_request_show_cb), panel);
    g_signal_connect (panel, "size-changed",
                      G_CALLBACK (_panel_set_size_cb), shell);
    clutter_container_add_actor (CLUTTER_CONTAINER (panel), shell);
  }

  clutter_main ();
  return EXIT_SUCCESS;
}