source: branches/2.4x/gtk/util.h @ 12997

Last change on this file since 12997 was 12997, checked in by jordan, 10 years ago

(2.4x gtk) backported from r12963: add portability wrappers for gtk_hbox_new() and gtk_vbox_new(), which are deprecated now in GTK+ 3.2

  • Property svn:keywords set to Date Rev Author Id
File size: 4.3 KB
Line 
1/*
2 * This file Copyright (C) Mnemosyne LLC
3 *
4 * This file is licensed by the GPL version 2. Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: util.h 12997 2011-10-20 00:37:39Z jordan $
11 */
12
13#ifndef GTR_UTIL_H
14#define GTR_UTIL_H
15
16#include <sys/types.h>
17#include <glib.h>
18#include <gtk/gtk.h>
19
20#include <libtransmission/transmission.h>
21
22extern const int mem_K;
23extern const char * mem_K_str;
24extern const char * mem_M_str;
25extern const char * mem_G_str;
26extern const char * mem_T_str;
27
28extern const int disk_K;
29extern const char * disk_K_str;
30extern const char * disk_M_str;
31extern const char * disk_G_str;
32extern const char * disk_T_str;
33
34extern const int speed_K;
35extern const char * speed_K_str;
36extern const char * speed_M_str;
37extern const char * speed_G_str;
38extern const char * speed_T_str;
39
40/* macro to shut up "unused parameter" warnings */
41#ifndef UNUSED
42 #define UNUSED G_GNUC_UNUSED
43#endif
44
45enum
46{
47    GTR_UNICODE_UP,
48    GTR_UNICODE_DOWN,
49    GTR_UNICODE_INF,
50    GTR_UNICODE_BULLET
51};
52const char * gtr_get_unicode_string( int );
53
54/* return a percent formatted string of either x.xx, xx.x or xxx */
55char* tr_strlpercent( char * buf, double x, size_t buflen );
56
57/* return a human-readable string for the size given in bytes. */
58char* tr_strlsize( char * buf, guint64  size, size_t buflen );
59
60/* return a human-readable string for the given ratio. */
61char* tr_strlratio( char * buf, double ratio, size_t buflen );
62
63/* return a human-readable string for the time given in seconds. */
64char* tr_strltime( char * buf, int secs, size_t buflen );
65
66/***
67****
68***/
69
70/* http://www.legaltorrents.com/some/announce/url --> legaltorrents.com */
71void gtr_get_host_from_url( char * buf, size_t buflen, const char * url );
72
73gboolean gtr_is_magnet_link( const char * str );
74
75gboolean gtr_is_hex_hashcode( const char * str );
76
77/***
78****
79***/
80
81void        gtr_open_uri( const char * uri );
82
83void        gtr_open_file( const char * path );
84
85const char* gtr_get_help_uri( void );
86
87/***
88****
89***/
90
91/* backwards-compatible wrapper around gtk_hbox_new() */
92GtkWidget* gtr_hbox_new( gboolean homogenous, gint spacing );
93
94/* backwards-compatible wrapper around gtk_vbox_new() */
95GtkWidget* gtr_vbox_new( gboolean homogenous, gint spacing );
96
97/* backwards-compatible wrapper around gtk_widget_set_visible() */
98void gtr_widget_set_visible( GtkWidget *, gboolean );
99
100void gtr_dialog_set_content( GtkDialog * dialog, GtkWidget * content );
101
102/***
103****
104***/
105
106GtkWidget * gtr_priority_combo_new( void );
107#define gtr_priority_combo_get_value(w)     gtr_combo_box_get_active_enum(w)
108#define gtr_priority_combo_set_value(w,val) gtr_combo_box_set_active_enum(w,val)
109
110GtkWidget * gtr_combo_box_new_enum        ( const char * text_1, ... );
111int         gtr_combo_box_get_active_enum ( GtkComboBox * );
112void        gtr_combo_box_set_active_enum ( GtkComboBox *, int value );
113
114/***
115****
116***/
117
118void gtr_unrecognized_url_dialog( GtkWidget * parent, const char * url );
119
120void gtr_http_failure_dialog( GtkWidget * parent, const char * url, long response_code );
121
122void gtr_add_torrent_error_dialog( GtkWidget  * window_or_child,
123                                   int          err,
124                                   const char * filename );
125
126/* pop up the context menu if a user right-clicks.
127   if the row they right-click on isn't selected, select it. */
128gboolean on_tree_view_button_pressed( GtkWidget      * view,
129                                      GdkEventButton * event,
130                                      gpointer         unused );
131
132/* if the click didn't specify a row, clear the selection */
133gboolean on_tree_view_button_released( GtkWidget      * view,
134                                       GdkEventButton * event,
135                                       gpointer         unused );
136
137
138/* move a file to the trashcan if GIO is available; otherwise, delete it */
139int gtr_file_trash_or_remove( const char * filename );
140
141void gtr_paste_clipboard_url_into_entry( GtkWidget * entry );
142
143/* Only call gtk_label_set_text() if the new text differs from the old.
144 * This prevents the label from having to recalculate its size
145 * and prevents selected text in the label from being deselected */
146void gtr_label_set_text( GtkLabel * lb, const char * text );
147
148#endif /* GTR_UTIL_H */
Note: See TracBrowser for help on using the repository browser.