annotate gui/dialog/msgbox.c @ 36680:cc70b0fb8d36

Add a message box type "information".
author ib
date Sun, 02 Feb 2014 10:52:47 +0000
parents d8c696db2948
children eed2fb870f43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
1 /*
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
2 * This file is part of MPlayer.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
3 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
7 * (at your option) any later version.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
8 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
12 * GNU General Public License for more details.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
13 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
17 */
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
18
33738
998f94e62a61 Remove unnecessary #include "gui/interface.h".
ib
parents: 33572
diff changeset
19 #include <string.h>
998f94e62a61 Remove unnecessary #include "gui/interface.h".
ib
parents: 33572
diff changeset
20
35525
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35450
diff changeset
21 #include "gui/app/app.h"
36053
7affacef2f88 Define "MPlayer" string.
ib
parents: 36052
diff changeset
22 #include "gui/app/gui.h"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
23 #include "help_mp.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
24
35526
3c901704a27c Rebuild GUI directory structure.
ib
parents: 35525
diff changeset
25 #include "pixmaps/error.xpm"
3c901704a27c Rebuild GUI directory structure.
ib
parents: 35525
diff changeset
26 #include "pixmaps/warning.xpm"
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
27 #include "pixmaps/information.xpm"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
28
35529
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
29 #include "dialog.h"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
30 #include "msgbox.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
31 #include "tools.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
32
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
33 GtkWidget * gtkMessageBoxText;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
34 GtkWidget * MessageBox = NULL;
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
35 GtkWidget * InformationPixmap;
36031
8ae2e20462a7 Move variable declarations and definitions where they belong.
ib
parents: 36023
diff changeset
36 GtkWidget * WarningPixmap;
8ae2e20462a7 Move variable declarations and definitions where they belong.
ib
parents: 36023
diff changeset
37 GtkWidget * ErrorPixmap;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
38
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
39 static void on_Ok_released( GtkButton * button,gpointer user_data )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
40 {
36010
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
41 (void) button;
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
42 (void) user_data;
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
43
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
44 gtk_widget_destroy( MessageBox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
45 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
46
35996
6c891a0e3fea Cosmetic: Rename the functions creating the dialogs.
ib
parents: 35991
diff changeset
47 static GtkWidget * CreateMessageBox( void )
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
48 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
49 GtkWidget * vbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
50 GtkWidget * hbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
51 GtkWidget * hbuttonbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
52 GtkWidget * Ok;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
53 GtkAccelGroup * accel_group;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
54 GtkStyle * pixmapstyle;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
55 GdkPixmap * pixmapwid;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
56 GdkBitmap * mask;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
57
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
58 accel_group=gtk_accel_group_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
59
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
60 MessageBox=gtk_window_new( GTK_WINDOW_TOPLEVEL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
61 gtk_widget_set_events( MessageBox,GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_VISIBILITY_NOTIFY_MASK );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
62 gtk_window_set_title( GTK_WINDOW( MessageBox ),"MPlayer ..." );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
63 gtk_window_set_position( GTK_WINDOW( MessageBox ),GTK_WIN_POS_CENTER );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
64 gtk_window_set_modal( GTK_WINDOW( MessageBox ),TRUE );
36062
d8c696db2948 Don't allow the message box to be user-resizable.
ib
parents: 36053
diff changeset
65 gtk_window_set_policy( GTK_WINDOW( MessageBox ),FALSE,FALSE,TRUE );
36053
7affacef2f88 Define "MPlayer" string.
ib
parents: 36052
diff changeset
66 gtk_window_set_wmclass( GTK_WINDOW( MessageBox ),"Message",MPlayer );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
67
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
68 gtk_widget_realize( MessageBox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
69 gtkAddIcon( MessageBox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
70
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36010
diff changeset
71 vbox1=gtkAddVBox( gtkAddDialogFrame( MessageBox ),0 );
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36010
diff changeset
72 hbox1=gtkAddHBox( vbox1,1 );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
73
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
74 pixmapstyle=gtk_widget_get_style( MessageBox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
75
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
76 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )information_xpm );
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
77 InformationPixmap=gtk_pixmap_new( pixmapwid,mask );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
78 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )warning_xpm );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
79 WarningPixmap=gtk_pixmap_new( pixmapwid,mask );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
80 pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )error_xpm );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
81 ErrorPixmap=gtk_pixmap_new( pixmapwid,mask );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
82
36680
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
83 gtk_widget_hide( InformationPixmap );
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
84 gtk_box_pack_start( GTK_BOX( hbox1 ),InformationPixmap,FALSE,FALSE,0 );
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
85 gtk_widget_set_usize( InformationPixmap,55,-2 );
cc70b0fb8d36 Add a message box type "information".
ib
parents: 36062
diff changeset
86
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
87 gtk_widget_hide( WarningPixmap );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
88 gtk_box_pack_start( GTK_BOX( hbox1 ),WarningPixmap,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
89 gtk_widget_set_usize( WarningPixmap,55,-2 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
90
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
91 gtk_widget_hide( ErrorPixmap );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
92 gtk_box_pack_start( GTK_BOX( hbox1 ),ErrorPixmap,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
93 gtk_widget_set_usize( ErrorPixmap,55,-2 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
94
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
95 gtkMessageBoxText=gtk_label_new( "Text jol. Ha ezt megerted,akkor neked nagyon jo a magyar tudasod,te." );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
96 gtk_widget_show( gtkMessageBoxText );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
97 gtk_box_pack_start( GTK_BOX( hbox1 ),gtkMessageBoxText,TRUE,TRUE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
98 // gtk_label_set_justify( GTK_LABEL( gtkMessageBoxText ),GTK_JUSTIFY_FILL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
99 gtk_label_set_justify( GTK_LABEL( gtkMessageBoxText ),GTK_JUSTIFY_CENTER );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
100 gtk_label_set_line_wrap( GTK_LABEL( gtkMessageBoxText ),FALSE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
101
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36010
diff changeset
102 gtkAddHSeparator( vbox1 );
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36010
diff changeset
103 hbuttonbox1=gtkAddHButtonBox( vbox1 );
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36010
diff changeset
104 Ok=gtkAddButton( MSGTR_Ok,hbuttonbox1 );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
105
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
106 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
107 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
108
36008
d154d0035cb0 Don't use WidgetDestroy().
ib
parents: 36007
diff changeset
109 gtk_signal_connect( GTK_OBJECT( MessageBox ),"destroy",GTK_SIGNAL_FUNC( gtk_widget_destroyed ),&MessageBox );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
110 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Ok_released ),NULL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
111
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
112 gtk_window_add_accel_group( GTK_WINDOW( MessageBox ),accel_group );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
113
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
114 return MessageBox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
115 }
35991
4a5fcdaf31ff Make create_MessageBox() static.
ib
parents: 35529
diff changeset
116
4a5fcdaf31ff Make create_MessageBox() static.
ib
parents: 35529
diff changeset
117 void ShowMessageBox( const char * msg )
4a5fcdaf31ff Make create_MessageBox() static.
ib
parents: 35529
diff changeset
118 {
36007
90ff4280cc80 There is no need to hide the widget prior to destruction.
ib
parents: 35996
diff changeset
119 if ( MessageBox ) gtk_widget_destroy( MessageBox );
35996
6c891a0e3fea Cosmetic: Rename the functions creating the dialogs.
ib
parents: 35991
diff changeset
120 MessageBox=CreateMessageBox();
35991
4a5fcdaf31ff Make create_MessageBox() static.
ib
parents: 35529
diff changeset
121 if ( strlen( msg ) < 20 ) gtk_widget_set_usize( MessageBox,196,-1 );
4a5fcdaf31ff Make create_MessageBox() static.
ib
parents: 35529
diff changeset
122 }