source: trunk/gtk/util.h @ 6402

Last change on this file since 6402 was 6402, checked in by charles, 13 years ago

(gtk) #1108: transmission includes several unlocalized strings

  • Property svn:keywords set to Date Rev Author Id
File size: 4.1 KB
Line 
1/******************************************************************************
2 * $Id: util.h 6402 2008-07-25 14:56:28Z charles $
3 *
4 * Copyright (c) 2005-2008 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#ifndef TG_UTIL_H
26#define TG_UTIL_H
27
28#include <sys/types.h>
29#include <stdarg.h>
30
31/* macro to shut up "unused parameter" warnings */
32#ifndef UNUSED
33#define UNUSED G_GNUC_UNUSED
34#endif
35
36/* return number of items in array */
37#define ALEN(a) ((signed)G_N_ELEMENTS(a))
38
39/* used for a callback function with a data parameter */
40typedef void (*callbackfunc_t)(void*);
41
42/* return a human-readable string for the size given in bytes. */
43char* tr_strlsize( char * buf, guint64 size, size_t buflen );
44
45/* return a human-readable string for the transfer rate given in bytes. */
46char* tr_strlspeed (char * buf, double KiBps, size_t buflen );
47
48/* return a human-readable string for the given ratio. */
49char* tr_strlratio( char * buf, double ratio, size_t buflen );
50
51/* return a human-readable string for the time given in seconds. */
52char* tr_strltime( char * buf, int secs, size_t buflen );
53
54char* gtr_localtime( time_t time );
55
56/* create a directory and any missing parent directories */
57gboolean
58mkdir_p(const char *name, mode_t mode);
59
60/* create a copy of a GSList of strings, this dups the actual strings too */
61GSList *
62dupstrlist( GSList * list );
63
64/* joins a GSList of strings into one string using an optional separator */
65char *
66joinstrlist(GSList *list, char *sep);
67
68/* free a GSList of strings */
69void
70freestrlist(GSList *list);
71
72/* decodes a string that has been urlencoded */
73char *
74decode_uri( const char * uri );
75
76/* return a list of cleaned-up paths, with invalid directories removed */
77GSList *
78checkfilenames( int argc, char ** argv );
79
80void gtr_open_file( const char * path );
81
82gboolean gtr_dbus_add_torrent( const char * filename );
83
84char* gtr_get_help_url( void );
85
86#ifdef GTK_MAJOR_VERSION
87
88GtkWidget * tr_button_new_from_stock( const char * stock,
89                                      const char * mnemonic );
90
91void addTorrentErrorDialog( GtkWidget  * window_or_child,
92                            int          err,
93                            const char * filename );
94
95/* create an error dialog, if wind is NULL or mapped then show dialog now,
96   otherwise show it when wind becomes mapped */
97void
98errmsg( GtkWindow * wind, const char * format, ... ) G_GNUC_PRINTF(2,3);
99
100/* create an error dialog but do not gtk_widget_show() it,
101   calls func( data ) when the dialog is closed */
102GtkWidget *
103errmsg_full( GtkWindow * wind, callbackfunc_t func, void * data,
104             const char * format, ... ) G_GNUC_PRINTF(4,5);
105
106/* pop up the context menu if a user right-clicks.
107   if the row they right-click on isn't selected, select it. */
108gboolean
109on_tree_view_button_pressed (GtkWidget       * view,
110                             GdkEventButton  * event,
111                             gpointer          unused);
112
113gpointer tr_object_ref_sink (gpointer object);
114
115void tr_file_trash_or_unlink( const char * filename );
116
117#endif /* GTK_MAJOR_VERSION */
118
119#endif /* TG_UTIL_H */
Note: See TracBrowser for help on using the repository browser.