Mercurial > audlegacy
annotate src/libaudacious/util.c @ 2382:d41965d1806a trunk
[svn] - in vfs_buffered_file, we should only switch to live FD after 32768,
not AT 32768.
author | nenolod |
---|---|
date | Mon, 22 Jan 2007 01:01:33 -0800 |
parents | eb71fec30e9a |
children |
rev | line source |
---|---|
2313 | 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; under version 2 of the License. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 # include "config.h" | |
25 #endif | |
26 | |
2340
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
27 #include <stdlib.h> |
2313 | 28 #include <glib.h> |
29 #include <gtk/gtk.h> | |
30 | |
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 **/ | |
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 { | |
49 GtkWidget *dialog; | |
50 GtkWidget *dialog_vbox, *dialog_hbox, *dialog_bbox; | |
51 GtkWidget *dialog_bbox_b1; | |
52 GtkWidget *dialog_textlabel; | |
53 GtkWidget *dialog_icon; | |
54 | |
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 ); | |
60 | |
61 dialog_vbox = gtk_vbox_new( FALSE , 0 ); | |
62 dialog_hbox = gtk_hbox_new( FALSE , 0 ); | |
63 | |
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 ); | |
67 | |
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 ); | |
72 | |
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 ); | |
75 | |
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 ); | |
86 | |
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 ); | |
89 | |
90 gtk_container_add( GTK_CONTAINER(dialog) , dialog_vbox ); | |
91 gtk_widget_show_all(dialog); | |
92 | |
93 return dialog; | |
94 } | |
95 | |
2340
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
96 |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
97 /** |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
98 * audacious_get_localdir: |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
99 * |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
100 * Returns a string with the full path of Audacious local datadir (where config files are placed). |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
101 * It's useful in order to put in the right place custom config files for audacious plugins. |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
102 * |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
103 * Return value: a string with full path of Audacious local datadir (should be freed after use) |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
104 **/ |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
105 gchar* |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
106 audacious_get_localdir(void) |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
107 { |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
108 gchar *datadir; |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
109 gchar *tmp; |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
110 |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
111 if ( (tmp = getenv("XDG_CONFIG_HOME")) == NULL ) |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
112 datadir = g_build_filename( g_get_home_dir() , ".config" , "audacious" , NULL ); |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
113 else |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
114 datadir = g_build_filename( tmp , "audacious" , NULL ); |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
115 |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
116 return datadir; |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
117 } |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
118 |
eb71fec30e9a
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
2313
diff
changeset
|
119 |
2313 | 120 /** |
121 * xmms_check_realtime_priority: | |
122 * | |
123 * Legacy function included for compatibility with XMMS. | |
124 * | |
125 * Return value: FALSE | |
126 **/ | |
127 gboolean | |
128 xmms_check_realtime_priority(void) | |
129 { | |
130 return FALSE; | |
131 } | |
132 | |
133 /** | |
134 * xmms_usleep: | |
135 * @usec: The amount of microseconds to sleep. | |
136 * | |
137 * Legacy function included for compatibility with XMMS. | |
138 **/ | |
139 void | |
140 xmms_usleep(gint usec) | |
141 { | |
142 g_usleep(usec); | |
143 } |