Changeset 8846 for trunk/gtk/util.h


Ignore:
Timestamp:
Jul 22, 2009, 3:55:48 PM (13 years ago)
Author:
charles
Message:

remove some unused utilities. better commenting on the utils that remain.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/util.h

    r8757 r8846  
    1 /******************************************************************************
    2  * $Id$
     1/*
     2 * This file Copyright (C) 2008-2009 Charles Kerr <charles@transmissionbt.com>
    33 *
    4  * Copyright (c) 2005-2008 Transmission authors and contributors
     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.
    59 *
    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  *****************************************************************************/
     10 * $Id:$
     11 */
    2412
    25 #ifndef TG_UTIL_H
    26 #define TG_UTIL_H
     13#ifndef GTR_UTIL_H
     14#define GTR_UTIL_H
    2715
    2816#include <sys/types.h>
    29 #include <stdarg.h>
    3017
    3118/* macro to shut up "unused parameter" warnings */
     
    3421#endif
    3522
    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 */
    40 typedef void ( *callbackfunc_t )( void* );
    41 
    4223/* return a human-readable string for the size given in bytes. */
    43 char*       tr_strlsize( char *   buf,
    44                          guint64  size,
    45                          size_t   buflen );
     24char* tr_strlsize( char * buf, guint64  size, size_t buflen );
    4625
    4726/* return a human-readable string for the transfer rate given in bytes. */
    48 char*       tr_strlspeed( char * buf,
    49                           double KiBps,
    50                           size_t buflen );
     27char* tr_strlspeed( char * buf, double KiBps, size_t buflen );
    5128
    5229/* return a human-readable string for the given ratio. */
    53 char*       tr_strlratio( char * buf,
    54                           double ratio,
    55                           size_t buflen );
     30char* tr_strlratio( char * buf, double ratio, size_t buflen );
    5631
    5732/* return a human-readable string for the time given in seconds. */
    58 char*       tr_strltime( char * buf,
    59                          int    secs,
    60                          size_t buflen );
     33char* tr_strltime( char * buf, int secs, size_t buflen );
    6134
    62 char*       gtr_localtime( time_t time );
     35/* similar to asctime, but is utf8-clean */
     36char* gtr_localtime( time_t time );
    6337
    64 char*       gtr_localtime2( char * buf, time_t time, size_t buflen );
     38/* similar to asctime, but is utf8-clean */
     39char* gtr_localtime2( char * buf, time_t time, size_t buflen );
    6540
    6641/* create a directory and any missing parent directories */
    67 int         mkdir_p( const char *name,
    68                      mode_t      mode );
     42int mkdir_p( const char *name, mode_t mode );
     43
     44/***
     45****
     46***/
    6947
    7048/* create a copy of a GSList of strings, this dups the actual strings too */
    71 GSList *    dupstrlist( GSList * list );
     49GSList * dupstrlist( GSList * list );
    7250
    7351/* joins a GSList of strings into one string using an optional separator */
    74 char *      joinstrlist( GSList *list,
    75                          char *  sep );
     52char * joinstrlist( GSList *list, char *  sep );
    7653
    7754/* free a GSList of strings */
    78 void        freestrlist( GSList *list );
     55void freestrlist( GSList *list );
    7956
    8057/* decodes a string that has been urlencoded */
    81 char *      decode_uri( const char * uri );
     58char * decode_uri( const char * uri );
    8259
    8360/* return a list of cleaned-up paths, with invalid directories removed */
    84 GSList *    checkfilenames( int     argc,
    85                             char ** argv );
     61GSList * checkfilenames( int argc, char ** argv );
     62
     63/***
     64****
     65***/
    8666
    8767void        gtr_open_file( const char * path );
     
    9373char*       gtr_get_help_url( void );
    9474
     75/***
     76****
     77***/
     78
     79/* GTK-related utilities */
    9580#ifdef GTK_MAJOR_VERSION
    9681
    97 guint       gtr_timeout_add_seconds( guint       seconds,
    98                                      GSourceFunc function,
    99                                      gpointer    data );
     82/* backwards-compatible wrapper around gdk_threads_add_timeout_seconds() */
     83guint gtr_timeout_add_seconds( guint seconds, GSourceFunc func, gpointer data );
    10084
    101 void        gtr_idle_add( GSourceFunc  func,
    102                           gpointer    data );
     85/* backwards-compatible wrapper around gdk_threads_add_idle() */
     86void gtr_idle_add( GSourceFunc  func, gpointer data );
    10387
    104 void        gtr_toolbar_set_orientation( GtkToolbar      * toolbar,
    105                                          GtkOrientation    orientation );
     88/* backwards-compatible wrapper around gtk_orientable_set_orientation() */
     89void gtr_toolbar_set_orientation( GtkToolbar * tb, GtkOrientation orientation );
    10690
    107 void        gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip );
     91/* backwards-compatible wrapper around gtk_widget_set_tooltip_text() */
     92void gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip );
    10893
     94/* backwards-compatible wrapper around g_object_ref_sink() */
     95gpointer tr_object_ref_sink( gpointer object );
     96
     97/***
     98****
     99***/
     100
     101/* create a button with the specified mnemonic and stock icon */
    109102GtkWidget * gtr_button_new_from_stock( const char * stock,
    110103                                       const char * mnemonic );
    111104
    112 void        addTorrentErrorDialog( GtkWidget *  window_or_child,
    113                                    int          err,
    114                                    const char * filename );
    115 
    116 /* create an error dialog, if wind is NULL or mapped then show dialog now,
    117    otherwise show it when wind becomes mapped */
    118 void        errmsg( GtkWindow *  wind,
    119                     const char * format,
    120                     ... ) G_GNUC_PRINTF( 2, 3 );
    121 
    122 /* create an error dialog but do not gtk_widget_show() it,
    123    calls func( data ) when the dialog is closed */
    124 GtkWidget * errmsg_full( GtkWindow *    wind,
    125                          callbackfunc_t func,
    126                          void *         data,
    127                          const char *   format,
    128                          ... ) G_GNUC_PRINTF( 4, 5 );
     105void addTorrentErrorDialog( GtkWidget  * window_or_child,
     106                            int          err,
     107                            const char * filename );
    129108
    130109/* pop up the context menu if a user right-clicks.
    131110   if the row they right-click on isn't selected, select it. */
    132 gboolean    on_tree_view_button_pressed( GtkWidget *      view,
    133                                          GdkEventButton * event,
    134                                          gpointer         unused );
     111gboolean on_tree_view_button_pressed( GtkWidget      * view,
     112                                      GdkEventButton * event,
     113                                      gpointer         unused );
    135114
    136115/* if the click didn't specify a row, clear the selection */
    137 gboolean    on_tree_view_button_released( GtkWidget *      view,
    138                                           GdkEventButton * event,
    139                                           gpointer         unused );
     116gboolean on_tree_view_button_released( GtkWidget      * view,
     117                                       GdkEventButton * event,
     118                                       gpointer         unused );
    140119
    141120
    142 
    143 gpointer    tr_object_ref_sink( gpointer object );
    144 
    145 int         tr_file_trash_or_remove( const char * filename );
     121/* move a file to the trashcan if GIO is available; otherwise, delete it */
     122int tr_file_trash_or_remove( const char * filename );
    146123
    147124#endif /* GTK_MAJOR_VERSION */
    148125
    149 #endif /* TG_UTIL_H */
     126#endif /* GTR_UTIL_H */
Note: See TracChangeset for help on using the changeset viewer.