2053
|
1 /* Audacious
|
|
2 * Copyright (C) 2005-2007 Audacious team
|
|
3 *
|
|
4 * XMMS - Cross-platform multimedia player
|
|
5 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas,
|
|
6 * Thomas Nilsson and 4Front Technologies
|
|
7 * Copyright (C) 1999-2003 Haavard Kvaalen
|
|
8 *
|
|
9 * This program is free software; you can redistribute it and/or modify
|
|
10 * it under the terms of the GNU General Public License as published by
|
|
11 * the Free Software Foundation; either version 2 of the License, or
|
|
12 * (at your option) any later version.
|
|
13 *
|
|
14 * This program is distributed in the hope that it will be useful,
|
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 * GNU General Public License for more details.
|
|
18 *
|
|
19 * You should have received a copy of the GNU General Public License
|
|
20 * along with this program; if not, write to the Free Software
|
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
22 */
|
|
23
|
0
|
24 #ifdef HAVE_CONFIG_H
|
|
25 # include "config.h"
|
|
26 #endif
|
|
27
|
|
28 #include <glib.h>
|
|
29 #include <gtk/gtk.h>
|
|
30
|
2053
|
31 /**
|
|
32 * xmms_show_message:
|
|
33 * @title: The title of the message to show.
|
|
34 * @text: The text of the message to show.
|
|
35 * @button_text: The text of the button which will close the messagebox.
|
|
36 * @modal: Whether or not the messagebox should be modal.
|
|
37 * @button_action: Code to execute on when the messagebox is closed, or %NULL.
|
|
38 * @action_data: Optional opaque data to pass to @button_action.
|
|
39 *
|
|
40 * Displays a message box.
|
|
41 *
|
|
42 * Return value: A GTK widget handle for the message box.
|
|
43 **/
|
0
|
44 GtkWidget *
|
|
45 xmms_show_message(const gchar * title, const gchar * text,
|
|
46 const gchar * button_text, gboolean modal,
|
|
47 GtkSignalFunc button_action, gpointer action_data)
|
|
48 {
|
863
|
49 GtkWidget *dialog;
|
|
50 GtkWidget *dialog_vbox, *dialog_hbox, *dialog_bbox;
|
|
51 GtkWidget *dialog_bbox_b1;
|
|
52 GtkWidget *dialog_textlabel;
|
|
53 GtkWidget *dialog_icon;
|
0
|
54
|
863
|
55 dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
56 gtk_window_set_type_hint( GTK_WINDOW(dialog) , GDK_WINDOW_TYPE_HINT_DIALOG );
|
|
57 gtk_window_set_modal( GTK_WINDOW(dialog) , modal );
|
|
58 gtk_window_set_title( GTK_WINDOW(dialog) , title );
|
|
59 gtk_container_set_border_width( GTK_CONTAINER(dialog) , 10 );
|
0
|
60
|
863
|
61 dialog_vbox = gtk_vbox_new( FALSE , 0 );
|
|
62 dialog_hbox = gtk_hbox_new( FALSE , 0 );
|
0
|
63
|
863
|
64 /* icon */
|
|
65 dialog_icon = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO , GTK_ICON_SIZE_DIALOG );
|
|
66 gtk_box_pack_start( GTK_BOX(dialog_hbox) , dialog_icon , FALSE , FALSE , 2 );
|
0
|
67
|
863
|
68 /* label */
|
|
69 dialog_textlabel = gtk_label_new( text );
|
|
70 /* gtk_label_set_selectable( GTK_LABEL(dialog_textlabel) , TRUE ); */
|
|
71 gtk_box_pack_start( GTK_BOX(dialog_hbox) , dialog_textlabel , TRUE , TRUE , 2 );
|
0
|
72
|
863
|
73 gtk_box_pack_start( GTK_BOX(dialog_vbox) , dialog_hbox , FALSE , FALSE , 2 );
|
|
74 gtk_box_pack_start( GTK_BOX(dialog_vbox) , gtk_hseparator_new() , FALSE , FALSE , 4 );
|
0
|
75
|
863
|
76 dialog_bbox = gtk_hbutton_box_new();
|
|
77 gtk_button_box_set_layout( GTK_BUTTON_BOX(dialog_bbox) , GTK_BUTTONBOX_END );
|
|
78 dialog_bbox_b1 = gtk_button_new_with_label( button_text );
|
|
79 g_signal_connect_swapped( G_OBJECT(dialog_bbox_b1) , "clicked" ,
|
|
80 G_CALLBACK(gtk_widget_destroy) , dialog );
|
|
81 if ( button_action )
|
|
82 g_signal_connect( G_OBJECT(dialog_bbox_b1) , "clicked" ,
|
|
83 button_action , action_data );
|
|
84 GTK_WIDGET_SET_FLAGS( dialog_bbox_b1 , GTK_CAN_DEFAULT);
|
|
85 gtk_widget_grab_default( dialog_bbox_b1 );
|
0
|
86
|
863
|
87 gtk_container_add( GTK_CONTAINER(dialog_bbox) , dialog_bbox_b1 );
|
|
88 gtk_box_pack_start( GTK_BOX(dialog_vbox) , dialog_bbox , FALSE , FALSE , 0 );
|
0
|
89
|
863
|
90 gtk_container_add( GTK_CONTAINER(dialog) , dialog_vbox );
|
|
91 gtk_widget_show_all(dialog);
|
0
|
92
|
863
|
93 return dialog;
|
0
|
94 }
|
|
95
|
2053
|
96 /**
|
|
97 * xmms_check_realtime_priority:
|
|
98 *
|
|
99 * Legacy function included for compatibility with XMMS.
|
|
100 *
|
|
101 * Return value: FALSE
|
|
102 **/
|
0
|
103 gboolean
|
|
104 xmms_check_realtime_priority(void)
|
|
105 {
|
|
106 return FALSE;
|
|
107 }
|
|
108
|
2053
|
109 /**
|
|
110 * xmms_usleep:
|
|
111 * @usec: The amount of microseconds to sleep.
|
|
112 *
|
|
113 * Legacy function included for compatibility with XMMS.
|
|
114 **/
|
0
|
115 void
|
|
116 xmms_usleep(gint usec)
|
|
117 {
|
|
118 g_usleep(usec);
|
|
119 }
|