Re: Message Boxes



Deekshit Mantampady wrote:
> 
> Hi,
> 
>   This is regarding the reply sent my Tara M, on my query regarding
> message boxes. I am a beginner to GTK and I didn't understand what do
> you mean by MAPPING, mentioned in the reply. Or can you please send me
> the code (pseudo code is also OK).
> 
> Regrads
> Deekshit M
> 
>   ------------------------------------------------------------------------
>                            Name: Wipro_Disclaimer.txt
>    Wipro_Disclaimer.txt    Type: Plain Text (text/plain)
>                        Encoding: 7bit
Here is a small example for a message box ... you could remove the type
or made an own one and 
use other pixmaps ... hope this helps 
--------------------------------------------
void
message_box (KRunningMessageType type, const gchar * format, ...)
{
  GtkWidget *dialog_window = NULL;
  GtkWidget *label;
  GtkWidget *hbox;
  GtkWidget *hbuttonbox;
  GtkWidget *button;
  GtkWidget *dialog_action_area2;
  GtkWidget *dialog_type_pixmap = NULL;
  gchar *string;
  va_list args;

  dialog_window = gtk_dialog_new ();

  gtk_window_set_title (GTK_WINDOW (dialog_window), _("Message"));
  gtk_window_set_policy (GTK_WINDOW (dialog_window), FALSE, FALSE,
FALSE);
  gtk_window_set_position (GTK_WINDOW (dialog_window),
GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (dialog_window), TRUE);
  gtk_container_border_width (GTK_CONTAINER (dialog_window), 0);

  dialog_action_area2 = GTK_DIALOG (dialog_window)->action_area;
  gtk_widget_show (dialog_action_area2);
  gtk_container_border_width (GTK_CONTAINER (dialog_action_area2), 10);

  hbuttonbox = gtk_hbutton_box_new ();
  gtk_widget_show (hbuttonbox);
  gtk_box_pack_start (GTK_BOX (dialog_action_area2), hbuttonbox, TRUE,
TRUE,
		      0);
  gtk_container_border_width (GTK_CONTAINER (hbuttonbox), 2);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox),
GTK_BUTTONBOX_END);
  gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 10);
  gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (hbuttonbox), 2, 0);

  button = gtk_button_new_with_label (_("Ok"));
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
  gtk_widget_grab_default (button);
  gtk_widget_show (button);
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (dialog_window));

  hbox = gtk_hbox_new (FALSE, 2);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->vbox), hbox,
TRUE,
		      TRUE, 0);
  gtk_widget_show (hbox);

  switch (type)
    {
    case WARNING:
      dialog_type_pixmap =
	gtk_pixmap_new (KRunningxpm.gnome_warning,
			KRunningxpm.gnome_warning_mask);
      break;
    case ERROR:
      dialog_type_pixmap =
	gtk_pixmap_new (KRunningxpm.gnome_error,
			KRunningxpm.gnome_error_mask);
      break;
    case INFO:
      dialog_type_pixmap =
	gtk_pixmap_new (KRunningxpm.gnome_info, KRunningxpm.gnome_info_mask);
      break;
    case DEFAULT:
      dialog_type_pixmap =
	gtk_pixmap_new (KRunningxpm.gnome_default,
			KRunningxpm.gnome_default_mask);
      break;
    }
  gtk_widget_show (dialog_type_pixmap);
  gtk_box_pack_start (GTK_BOX (hbox), dialog_type_pixmap, FALSE, FALSE,
0);

  va_start (args, format);
  string = g_strdup_vprintf (format, args);
  label = gtk_label_new (string);
  gtk_misc_set_padding (GTK_MISC (label), 10, 10);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);
  va_end (args);

  if (!GTK_WIDGET_VISIBLE (dialog_window))
    gtk_widget_show (dialog_window);
  else
    gtk_widget_destroy (dialog_window);
  g_free (string);
}
-----------------------------------------------
Andreas Scherf
-- 
ICQ: 52910964
scherfa fh-trier de
scherfa web de




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]