Пример #1
0
void
display_queued_messages(void)
{
  queued_message_t *queued_message;

  while (message_queue != NULL) {
    queued_message = message_queue->data;
    message_queue = g_slist_remove(message_queue, queued_message);

    display_simple_dialog(queued_message->type, queued_message->btn_mask,
                          queued_message->message);

    g_free(queued_message->message);
    g_free(queued_message);
  }
}
Пример #2
0
gpointer
vsimple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, va_list ap)
{
  gchar             *vmessage;
  gchar             *message;
  queued_message_t *queued_message;
  GtkWidget        *win;
  GdkWindowState state = 0;

  /* Format the message. */
  vmessage = g_strdup_vprintf(msg_format, ap);

  /* convert character encoding from locale to UTF8 (using iconv) */
  message = g_locale_to_utf8(vmessage, -1, NULL, NULL, NULL);
  g_free(vmessage);

  if (top_level != NULL) {
    state = gdk_window_get_state(top_level->window);
  }

  /* If we don't yet have a main window or it's iconified, don't show the
     dialog. If showing up a dialog, while main window is iconified, program
     will become unresponsive! */
  if (top_level == NULL || state & GDK_WINDOW_STATE_ICONIFIED) {

    queued_message = g_malloc(sizeof (queued_message_t));
    queued_message->type = type;
    queued_message->btn_mask = btn_mask;
    queued_message->message = message;
    message_queue = g_slist_append(message_queue, queued_message);
    return NULL;
  }

  /*
   * Do we have any queued up messages?  If so, pop them up.
   */
  display_queued_messages();

  win = display_simple_dialog(type, btn_mask, message);

  g_free(message);

  return win;
}
Пример #3
0
gpointer
vsimple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, va_list ap)
{
  gchar            *message;
  queued_message_t *queued_message;
  GtkWidget        *win;
  GdkWindowState    state = (GdkWindowState)0;

  /* Format the message. */
  message = g_strdup_vprintf(msg_format, ap);

  if (top_level != NULL) {
    state = gdk_window_get_state(gtk_widget_get_window(top_level));
  }

  /* If we don't yet have a main window or it's iconified or hidden (i.e. not
     yet ready, don't show the dialog. If showing up a dialog, while main
     window is iconified, program will become unresponsive! */
  if ((top_level == NULL) || state & GDK_WINDOW_STATE_ICONIFIED
          || state & GDK_WINDOW_STATE_WITHDRAWN) {

    queued_message = (queued_message_t *)g_malloc(sizeof (queued_message_t));
    queued_message->type = type;
    queued_message->btn_mask = btn_mask;
    queued_message->message = message;
    message_queue = g_slist_append(message_queue, queued_message);
    return NULL;
  }

  /*
   * Do we have any queued up messages?  If so, pop them up.
   */
  display_queued_messages();

  win = display_simple_dialog(type, btn_mask, message);

  g_free(message);

  return win;
}