Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/mb.c @ 6854:ded48a755830
gtk dialog bug fix
author | pontscho |
---|---|
date | Tue, 30 Jul 2002 23:09:24 +0000 |
parents | 77980ab4e296 |
children | 138a7ff52a26 |
rev | line source |
---|---|
2901 | 1 |
2 #include "../../events.h" | |
3 #include "../../../config.h" | |
4 #include "../../../help_mp.h" | |
5 | |
6 #include "../pixmaps/error.xpm" | |
7 #include "../pixmaps/warning.xpm" | |
8 | |
9 #include "../widgets.h" | |
10 #include "mb.h" | |
11 | |
12 GtkWidget * gtkMessageBoxText; | |
6146 | 13 GtkWidget * MessageBox; |
2901 | 14 |
6146 | 15 int gtkVMessageBox = 0; |
16 | |
17 void ShowMessageBox( char * msg ) | |
18 { | |
19 if ( gtkVMessageBox ) gtkActive( MessageBox ); | |
20 else MessageBox=create_MessageBox( 0 ); | |
6794 | 21 gtkSetLayer( MessageBox ); |
6146 | 22 if ( strlen( msg ) < 20 ) gtk_widget_set_usize( MessageBox,196,-1 ); |
6854 | 23 gtkIncVisible(); |
6146 | 24 } |
25 | |
26 static void on_Ok_released( GtkButton * button,gpointer user_data ) | |
6854 | 27 { gtkVMessageBox=0; gtk_widget_hide( MessageBox ); gtk_widget_destroy( MessageBox ); gtkDecVisible(); } |
6146 | 28 |
29 static void on_MessageBox_show( GtkButton * button,gpointer user_data ) | |
30 { gtkVMessageBox=(int)user_data; } | |
2901 | 31 |
32 GtkWidget * create_MessageBox( int type ) | |
33 { | |
34 GtkWidget * MessageBox; | |
35 GtkWidget * frame1; | |
36 GtkWidget * frame2; | |
37 GtkWidget * frame3; | |
38 GtkWidget * frame4; | |
39 GtkWidget * vbox1; | |
40 GtkWidget * hbox1; | |
41 GtkWidget * hseparator1; | |
42 GtkWidget * hbuttonbox1; | |
43 GtkWidget * Ok; | |
44 GtkAccelGroup * accel_group; | |
45 GtkStyle * pixmapstyle; | |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
46 GdkPixmap * pixmapwid; |
2901 | 47 GdkBitmap * mask; |
48 | |
6044 | 49 accel_group=gtk_accel_group_new(); |
2901 | 50 |
6044 | 51 MessageBox=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
52 gtk_widget_set_name( MessageBox,"MessageBox" ); | |
53 gtk_object_set_data( GTK_OBJECT( MessageBox ),"MessageBox",MessageBox ); | |
54 gtk_widget_set_events( MessageBox,GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); | |
55 gtk_window_set_title( GTK_WINDOW( MessageBox ),"MPlayer ..." ); | |
56 gtk_window_set_position( GTK_WINDOW( MessageBox ),GTK_WIN_POS_CENTER ); | |
57 gtk_window_set_modal( GTK_WINDOW( MessageBox ),TRUE ); | |
58 gtk_window_set_policy( GTK_WINDOW( MessageBox ),TRUE,TRUE,FALSE ); | |
6651 | 59 gtk_window_set_wmclass( GTK_WINDOW( MessageBox ),"Message","MPlayer" ); |
60 | |
61 gtk_widget_realize( MessageBox ); | |
62 gtkAddIcon( MessageBox ); | |
2901 | 63 |
6044 | 64 frame1=gtk_frame_new( NULL ); |
65 gtk_widget_set_name( frame1,"frame1" ); | |
66 gtk_widget_ref( frame1 ); | |
6146 | 67 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"frame1",frame1,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 68 gtk_widget_show( frame1 ); |
69 gtk_container_add( GTK_CONTAINER( MessageBox ),frame1 ); | |
70 gtk_container_set_border_width( GTK_CONTAINER( frame1 ),1 ); | |
71 gtk_frame_set_shadow_type( GTK_FRAME( frame1 ),GTK_SHADOW_IN ); | |
2901 | 72 |
6044 | 73 frame2=gtk_frame_new( NULL ); |
74 gtk_widget_set_name( frame2,"frame2" ); | |
75 gtk_widget_ref( frame2 ); | |
6146 | 76 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"frame2",frame2,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 77 gtk_widget_show( frame2 ); |
78 gtk_container_add( GTK_CONTAINER( frame1 ),frame2 ); | |
79 gtk_frame_set_shadow_type( GTK_FRAME( frame2 ),GTK_SHADOW_NONE ); | |
2901 | 80 |
6044 | 81 frame3=gtk_frame_new( NULL ); |
82 gtk_widget_set_name( frame3,"frame3" ); | |
83 gtk_widget_ref( frame3 ); | |
6146 | 84 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"frame3",frame3,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 85 gtk_widget_show( frame3 ); |
86 gtk_container_add( GTK_CONTAINER( frame2 ),frame3 ); | |
87 gtk_frame_set_shadow_type( GTK_FRAME( frame3 ),GTK_SHADOW_ETCHED_OUT ); | |
2901 | 88 |
6044 | 89 frame4=gtk_frame_new( NULL ); |
90 gtk_widget_set_name( frame4,"frame4" ); | |
91 gtk_widget_ref( frame4 ); | |
6146 | 92 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"frame4",frame4,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 93 gtk_widget_show( frame4 ); |
94 gtk_container_add( GTK_CONTAINER( frame3 ),frame4 ); | |
95 gtk_frame_set_shadow_type( GTK_FRAME( frame4 ),GTK_SHADOW_NONE ); | |
2901 | 96 |
6044 | 97 vbox1=gtk_vbox_new( FALSE,0 ); |
98 gtk_widget_set_name( vbox1,"vbox1" ); | |
99 gtk_widget_ref( vbox1 ); | |
6146 | 100 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"vbox1",vbox1,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 101 gtk_widget_show( vbox1 ); |
102 gtk_container_add( GTK_CONTAINER( frame4 ),vbox1 ); | |
2901 | 103 |
6044 | 104 hbox1=gtk_hbox_new( FALSE,0 ); |
105 gtk_widget_set_name( hbox1,"hbox1" ); | |
106 gtk_widget_ref( hbox1 ); | |
6146 | 107 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"hbox1",hbox1,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 108 gtk_widget_show( hbox1 ); |
109 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
2901 | 110 |
111 pixmapstyle=gtk_widget_get_style( MessageBox ); | |
112 | |
6146 | 113 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )warning_xpm ); |
2901 | 114 WarningPixmap=gtk_pixmap_new( pixmapwid,mask ); |
6146 | 115 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )error_xpm ); |
2901 | 116 ErrorPixmap=gtk_pixmap_new( pixmapwid,mask ); |
117 | |
6044 | 118 gtk_widget_set_name( WarningPixmap,"pixmap1" ); |
119 gtk_widget_ref( WarningPixmap ); | |
120 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"pixmap1",WarningPixmap,(GtkDestroyNotify )gtk_widget_unref ); | |
121 gtk_widget_hide( WarningPixmap ); | |
122 gtk_box_pack_start( GTK_BOX( hbox1 ),WarningPixmap,FALSE,FALSE,0 ); | |
123 gtk_widget_set_usize( WarningPixmap,55,-2 ); | |
2901 | 124 |
6044 | 125 gtk_widget_set_name( ErrorPixmap,"pixmap1" ); |
126 gtk_widget_ref( ErrorPixmap ); | |
127 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"pixmap1",ErrorPixmap,(GtkDestroyNotify )gtk_widget_unref ); | |
128 gtk_widget_hide( ErrorPixmap ); | |
129 gtk_box_pack_start( GTK_BOX( hbox1 ),ErrorPixmap,FALSE,FALSE,0 ); | |
130 gtk_widget_set_usize( ErrorPixmap,55,-2 ); | |
2901 | 131 |
6044 | 132 gtkMessageBoxText=gtk_label_new( "Text jol. Ha ezt megerted,akkor neked nagyon jo a magyar tudasod,te." ); |
133 gtk_widget_set_name( gtkMessageBoxText,"gtkMessageBoxText" ); | |
134 gtk_widget_ref( gtkMessageBoxText ); | |
6146 | 135 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"gtkMessageBoxText",gtkMessageBoxText,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 136 gtk_widget_show( gtkMessageBoxText ); |
137 gtk_box_pack_start( GTK_BOX( hbox1 ),gtkMessageBoxText,TRUE,TRUE,0 ); | |
138 gtk_label_set_justify( GTK_LABEL( gtkMessageBoxText ),GTK_JUSTIFY_FILL ); | |
6146 | 139 gtk_label_set_line_wrap( GTK_LABEL( gtkMessageBoxText ),FALSE ); |
2901 | 140 |
6146 | 141 hseparator1=gtk_hseparator_new(); |
6044 | 142 gtk_widget_set_name( hseparator1,"hseparator1" ); |
143 gtk_widget_ref( hseparator1 ); | |
6146 | 144 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"hseparator1",hseparator1,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 145 gtk_widget_show( hseparator1 ); |
146 gtk_box_pack_start( GTK_BOX( vbox1 ),hseparator1,FALSE,FALSE,0 ); | |
147 gtk_widget_set_usize( hseparator1,-2,9 ); | |
2901 | 148 |
6146 | 149 hbuttonbox1=gtk_hbutton_box_new(); |
6044 | 150 gtk_widget_set_name( hbuttonbox1,"hbuttonbox1" ); |
151 gtk_widget_ref( hbuttonbox1 ); | |
6146 | 152 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),"hbuttonbox1",hbuttonbox1,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 153 gtk_widget_show( hbuttonbox1 ); |
3617 | 154 gtk_widget_set_usize( hbuttonbox1,-2,25 ); |
155 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox1 ),75,0 ); | |
6044 | 156 gtk_box_pack_start( GTK_BOX( vbox1 ),hbuttonbox1,FALSE,FALSE,0 ); |
2901 | 157 |
6044 | 158 Ok=gtk_button_new_with_label( MSGTR_Ok ); |
159 gtk_widget_set_name( Ok,MSGTR_Ok ); | |
160 gtk_widget_ref( Ok ); | |
6146 | 161 gtk_object_set_data_full( GTK_OBJECT( MessageBox ),MSGTR_Ok,Ok,(GtkDestroyNotify)gtk_widget_unref ); |
6044 | 162 gtk_widget_show( Ok ); |
163 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Ok ); | |
164 gtk_widget_add_accelerator( Ok,"released",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
165 gtk_widget_add_accelerator( Ok,"released",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
2901 | 166 |
6146 | 167 gtk_signal_connect( GTK_OBJECT( MessageBox ),"destroy_event",GTK_SIGNAL_FUNC( on_Ok_released ),NULL ); |
6794 | 168 gtk_signal_connect( GTK_OBJECT( MessageBox ),"show",GTK_SIGNAL_FUNC( on_MessageBox_show ),(void *)1 ); |
6146 | 169 gtk_signal_connect( GTK_OBJECT( MessageBox ),"hide",GTK_SIGNAL_FUNC( on_MessageBox_show ),0 ); |
170 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( on_Ok_released ),NULL ); | |
2901 | 171 |
6044 | 172 gtk_window_add_accel_group( GTK_WINDOW( MessageBox ),accel_group ); |
2901 | 173 |
174 return MessageBox; | |
175 } |