예제 #1
0
void
xfsm_dns_check (void)
{
  GtkWidget *msgbox = NULL;
  gchar      hostname[256];
  gint       response;

  while (!check_for_dns ())
    {
      if (msgbox == NULL)
        {
          GdkScreen *screen = xfce_gdk_screen_get_active (NULL);

          queryhostname (hostname, 256, TRUE);

          msgbox = gtk_message_dialog_new (NULL, 0,
                                           GTK_MESSAGE_WARNING,
                                           GTK_BUTTONS_NONE,
                                           _("Could not look up internet address for %s.\n"
                                             "This will prevent Xfce from operating correctly.\n"
                                             "It may be possible to correct the problem by adding\n"
                                             "%s to the file /etc/hosts on your system."),
                                           hostname, hostname);

          gtk_dialog_add_buttons (GTK_DIALOG (msgbox),
                                  _("Continue anyway"), RESPONSE_LOG_IN,
                                  _("Try again"), RESPONSE_TRY_AGAIN,
                                  NULL);

          gtk_window_set_screen (GTK_WINDOW (msgbox), screen);
          gtk_container_set_border_width (GTK_CONTAINER (msgbox), 6);
          gtk_window_set_position (GTK_WINDOW (msgbox), GTK_WIN_POS_CENTER);
        }

      gtk_dialog_set_default_response (GTK_DIALOG (msgbox), RESPONSE_TRY_AGAIN);

      response = gtk_dialog_run (GTK_DIALOG (msgbox));
      if (response != RESPONSE_TRY_AGAIN)
        break;

      gtk_widget_hide (msgbox);
    }

  if (msgbox != NULL)
    gtk_widget_destroy (msgbox);
}
예제 #2
0
XfsmSplashScreen*
xfsm_splash_screen_new (GdkDisplay  *display,
                        const gchar *engine)
{
  XfsmSplashScreen *splash;
  XfsmSplashRc     *splash_rc;
  GdkScreen        *screen;
  gchar             name[128];
  int               monitor;
  XfconfChannel    *channel;

  /* locate monitor with pointer */
  screen = xfce_gdk_screen_get_active (&monitor);

  if (G_UNLIKELY (screen == NULL) || (gdk_screen_get_display (screen) != display))
    {
      screen  = gdk_display_get_screen (display, 0);
      monitor = 0;
    }

  /* initialize the screen struct */
  splash = g_new0 (XfsmSplashScreen, 1);
  splash->engine.display = display;
  splash->engine.primary_screen = screen;
  splash->engine.primary_monitor = monitor;

  /* load and setup the engine */
  if (G_LIKELY (engine != NULL && *engine != '\0'))
    {
      xfsm_splash_screen_load (splash, engine);
      if (G_LIKELY (splash->engine.setup != NULL))
        {
          g_snprintf (name, sizeof(name), "/splash/engines/%s", engine);
          channel = xfconf_channel_new_with_property_base ("xfce4-session",
                                                           name);
          splash_rc = xfsm_splash_rc_new (channel);
          g_object_unref (channel);
          splash->engine.setup (&splash->engine, splash_rc);
          xfsm_splash_rc_free (splash_rc);

          gdk_flush ();
        }
    }

  return splash;
}
예제 #3
0
void
module_test (Module     *module,
             GdkDisplay *display)
{
  static char *steps[] =
  {
    "Starting the Window Manager",
    "Starting the Desktop Manager",
    "Starting the Taskbar",
    "Starting the Panel",
    NULL,
  };

  void (*init) (XfsmSplashEngine *engine);
  XfsmSplashEngine  engine;
  GdkScreen        *screen;
  guint             id;
  int               monitor;
  int               step;

  /* properly initialize the engine struct with zeros! */
  bzero (&engine, sizeof (engine));

  /* locate monitor with pointer */
  screen = xfce_gdk_screen_get_active (&monitor);
  if (G_UNLIKELY (screen == NULL) || (gdk_screen_get_display(screen) != display))
    {
      screen  = gdk_display_get_screen (display, 0);
      monitor = 0;
    }

  /* initialize engine struct */
  engine.display          = display;
  engine.primary_screen   = screen;
  engine.primary_monitor  = monitor;

  /* load and setup the engine */
  if (g_module_symbol (module->handle, "engine_init", (gpointer)&init))
    {
      init (&engine);

      if (G_LIKELY (engine.setup != NULL))
        {
          engine.setup (&engine, module->config.rc);
          gdk_flush ();
        }

      if (G_LIKELY (engine.start != NULL))
        {
          engine.start (&engine, "Default", NULL, 4);
          gdk_flush ();
        }

      if (G_LIKELY (engine.next != NULL))
        {
          for (step = 0; steps[step] != NULL; ++step)
            {
              engine.next (&engine, steps[step]);
              id = g_timeout_add (1000, (GSourceFunc) gtk_main_quit, NULL);
              gtk_main ();
              g_source_remove (id);
            }
        }

      if (G_LIKELY (engine.destroy != NULL))
        engine.destroy (&engine);
    }
}
예제 #4
0
/**
 * xfce_dialog_show_help_with_version:
 * @parent    : (allow-none): transient parent of the dialog, or %NULL.
 * @component : (allow-none): name of the component opening the help page or %NULL. If the
 *              value is %NULL the target will be the main page of the
 *              documentation website.
 * @page      : (allow-none): subpage of the @component on the website or %NULL.
 * @offset    : (allow-none): anchor offset in @page or %NULL.
 * @version   : (allow-none): alternative version, or %NULL to use xfce_version_string().
 *
 * Asks the user to visit the online documentation. If confirmed, it will open
 * the webbrowser and redirect the user to the correct location.
 *
 * Appart from the @component, @page and @offset the following information
 * is also send to the server: user language and the xfce_version_string()
 * or @version if set.
 *
 * See also: xfce_dialog_show_help().
 *
 * Since: 4.12
 *
 */
void
xfce_dialog_show_help_with_version (GtkWindow   *parent,
                                    const gchar *component,
                                    const gchar *page,
                                    const gchar *offset,
                                    const gchar *version)
{
  GtkWidget   *dialog;
  const gchar *name;
  gchar       *primary;
  GString     *uri;
  gchar       *locale;
  GtkWidget   *message_box;
  GtkWidget   *button;
  XfceRc      *rc;
  gboolean     auto_online;
  GdkScreen   *screen;

  g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));

  /* get the user's locale without encoding */
  locale = g_strdup (setlocale (LC_MESSAGES, NULL));
  if (G_LIKELY (locale != NULL))
    locale = g_strdelimit (locale, ".", '\0');
  else
    locale = g_strdup ("C");

  /* use desktop version if none is set */
  if (version == NULL)
    version = xfce_version_string ();

  /* build the redirect uri */
  uri = g_string_new (MANUAL_WEBSITE);
  g_string_append_printf (uri, "?version=%s&locale=%s", version, locale);
  g_free (locale);

  if (component != NULL)
    g_string_append_printf (uri, "&component=%s", component);
  if (page != NULL)
    g_string_append_printf (uri, "&page=%s", page);
  if (offset != NULL)
    g_string_append_printf (uri, "&offset=%s", offset);

  /* check if we should automatically go online */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/help.rc", TRUE);
  if (rc != NULL)
    {
      auto_online = xfce_rc_read_bool_entry (rc, "auto-online", FALSE);
      xfce_rc_close (rc);

      if (auto_online)
        {
          if (parent != NULL)
            screen = gtk_window_get_screen (GTK_WINDOW (parent));
          else
            screen = xfce_gdk_screen_get_active (NULL);

          xfce_dialog_show_help_uri (screen, parent, uri);
          g_string_free (uri, TRUE);

          return;
        }
    }

  /* try to get a translated name of the application */
  name = g_get_application_name ();
  if (g_strcmp0 (name, g_get_prgname ()) == 0)
    name = NULL;

  /* try to get a decent primary text */
  if (name != NULL)
    primary = g_strdup_printf (_("Do you want to read the %s manual online?"), name);
  else
    primary = g_strdup (_("Do you want to read the manual online?"));

  dialog = xfce_message_dialog_new (parent,
                                    _("Online Documentation"),
#if !GTK_CHECK_VERSION (3, 10, 0)
                                    GTK_STOCK_DIALOG_QUESTION,
#else
                                    "dialog-question",
#endif
                                    primary,
                                    _("You will be redirected to the documentation website "
                                      "where the help pages are maintained and translated."),
#if !GTK_CHECK_VERSION (3, 10, 0)
                                    GTK_STOCK_CANCEL,
#else
                                    "gtk-cancel",
#endif
                                    GTK_RESPONSE_NO,
                                    XFCE_BUTTON_TYPE_MIXED,
#if !GTK_CHECK_VERSION (3, 10, 0)
                                    GTK_STOCK_HELP,
#else
                                    "help-browser",
#endif
                                    _("_Read Online"),
                                    GTK_RESPONSE_YES,
                                    NULL);
  g_free (primary);


  message_box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  g_return_if_fail (GTK_IS_BOX (message_box));

  button = gtk_check_button_new_with_mnemonic (_("_Always go directly to the online documentation"));
  gtk_box_pack_end (GTK_BOX (message_box), button, FALSE, TRUE, 0);
#if GTK_CHECK_VERSION (3, 0, 0)
  g_object_set (G_OBJECT (button), "halign", GTK_ALIGN_END, "margin-start", 8, "margin-end", 8, NULL);
  gtk_widget_set_hexpand (button, TRUE);
#endif
  g_signal_connect (G_OBJECT (button), "toggled",
      G_CALLBACK (xfce_dialog_show_help_auto_toggled), NULL);
  gtk_widget_show (button);

  /* don't focus the checkbutton */
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
  button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
  gtk_widget_grab_focus (button);

  /* show the dialog without locking the mainloop */
  gtk_window_set_modal (GTK_WINDOW (dialog), parent != NULL);
  g_signal_connect (G_OBJECT (dialog), "response",
      G_CALLBACK (xfce_dialog_show_help_response), uri);
  gtk_window_present (GTK_WINDOW (dialog));
}