File: show_message.C

package info (click to toggle)
peruser 4b33-10
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,944 kB
  • ctags: 1,064
  • sloc: cpp: 22,397; perl: 2,733; makefile: 345; sh: 335
file content (121 lines) | stat: -rw-r--r-- 3,987 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <gtk/gtk.h>

#include "npfile.h"
#include "npstringarray.h"
#include "npgroup.h"
#include "npnode.h"
#include "nptree.h"
#include "npcollections.h"

void NP_Collections::show_message( char *message, int button )
{
   if ( message == NULL || message_window != NULL )
      return;

   message_label = gtk_label_new( message );
   gtk_widget_show( message_label );
   if ( strlen( message ) > 80 )
      gtk_label_set_justify( GTK_LABEL( message_label ), GTK_JUSTIFY_LEFT );

   // window

   message_window = gtk_window_new( GTK_WINDOW_DIALOG );
   gtk_window_position( GTK_WINDOW( message_window ), GTK_WIN_POS_MOUSE );
   gtk_container_border_width( GTK_CONTAINER( message_window ), 10 );
   gtk_window_set_title( GTK_WINDOW( message_window ), "Message" );

   // vbox

   GtkWidget *vbox = gtk_vbox_new( FALSE, 10 );
   gtk_widget_show( vbox );
   gtk_container_add( GTK_CONTAINER( message_window ), vbox );
   gtk_box_pack_start( GTK_BOX( vbox ), message_label, TRUE, TRUE, 0 );

   if ( button == 1 )
   {
      GtkWidget *label =
         gtk_label_new( "\nAuthor:\nJames Bailie <jazzturk@home.com>\n"
                        "http://members.home.com/jazzturk\n" );
      gtk_widget_show( label );
      gtk_box_pack_start( GTK_BOX( vbox ), label, TRUE, TRUE, 0 );
   }

   if( button == 2 )
   {
      message_progress_bar = gtk_progress_bar_new();
      gtk_widget_show( message_progress_bar );
      gtk_box_pack_start( GTK_BOX( vbox ), message_progress_bar,
                          TRUE, TRUE, 0 );
   }

   // separator

   GtkWidget *separator = gtk_hseparator_new();
   gtk_widget_show( separator );
   gtk_box_pack_start( GTK_BOX( vbox ), separator, TRUE, TRUE, 10 );

   // bbox 

   GtkWidget *bbox = gtk_vbutton_box_new();
   gtk_widget_show( bbox );
   gtk_box_pack_start( GTK_BOX( vbox ), bbox, FALSE, FALSE, 0 );

   GtkWidget *new_button;
   
   gtk_widget_show( message_window );
   
   switch( button )
   {
   case 0:
      message_button = gtk_button_new_with_label( " Close Dialog " );
      gtk_signal_connect( GTK_OBJECT( message_button ), "clicked",
                          GTK_SIGNAL_FUNC( message_callback ), this );
      break;

   case 1:
      new_button = gtk_button_new_with_label(" Send email to Jimmy " );
      gtk_widget_show( new_button );
      GTK_WIDGET_SET_FLAGS( new_button, GTK_CAN_DEFAULT );
      gtk_object_set_data( GTK_OBJECT( new_button ), "collections", this );
      gtk_signal_connect( GTK_OBJECT( new_button ), "clicked",
                          GTK_SIGNAL_FUNC( author_email_website_callback ),
                          0 );
      gtk_box_pack_start( GTK_BOX( bbox ), new_button, TRUE, TRUE, 0 );

      new_button =
         gtk_button_new_with_label( " Visit the News Peruser website " );
      gtk_widget_show( new_button );
      gtk_signal_connect( GTK_OBJECT( new_button ), "clicked",
                          GTK_SIGNAL_FUNC( author_email_website_callback ),
                          ( gpointer )1 );
      GTK_WIDGET_SET_FLAGS( new_button, GTK_CAN_DEFAULT );
      gtk_object_set_data( GTK_OBJECT( new_button ), "collections", this );
      gtk_box_pack_start( GTK_BOX( bbox ), new_button, TRUE, TRUE, 0 );


      message_button = gtk_button_new_with_label( " Close Dialog " );
      gtk_signal_connect( GTK_OBJECT( message_button ), "clicked",
                          GTK_SIGNAL_FUNC( message_callback ), this );
      break;

   case 2:
   case 3:
      message_button = gtk_button_new_with_label( " Stop " );
      gtk_signal_connect( GTK_OBJECT( message_button ), "clicked",
                          GTK_SIGNAL_FUNC( stop_button_callback ), this );
      break;
   }

   gtk_widget_show( message_button );
   GTK_WIDGET_SET_FLAGS( message_button, GTK_CAN_DEFAULT );
   gtk_box_pack_start( GTK_BOX( bbox ), message_button, TRUE, TRUE, 0 );
   gtk_widget_grab_default( message_button );

   gtk_grab_add( message_window );

   return;
}