filetypes.h

Go to the documentation of this file.
00001 #ifndef __FILETYPES_H__
00002 #define __FILETYPES_H__
00003 
00004 /**
00005  * File Name  : filetypes.h
00006  *
00007  * Description: Content browser filetype specific utilities
00008  */
00009 
00010 /*
00011  * This file is part of ctb.
00012  *
00013  * ctb is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * ctb is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2008 iRex Technologies B.V.
00029  * All rights reserved.
00030  */
00031 
00032 
00033 //----------------------------------------------------------------------------
00034 // Include Files
00035 //----------------------------------------------------------------------------
00036 
00037 #include <gdk/gdk.h>
00038 #include <glib.h>
00039 
00040 #include "filemodel.h"
00041 
00042 G_BEGIN_DECLS
00043 
00044 
00045 //----------------------------------------------------------------------------
00046 // Macro Definitions
00047 //---------------------------------------------------------------------------- 
00048 
00049 #define FILE_EXT_DRZ             "drz"
00050 #define FILE_EXT_SHORTCUT        "desktop"
00051 #define FILE_EXT_SHORTCUT_TO_DIR "directory"
00052 
00053 #define DIR_DRZ                  "System/drz"
00054 #define DIR_SHORTCUTS            "System/Shortcuts"
00055 #define DIR_NOTES                "Notes"
00056 #define DIR_ADE_THUMBS           "Digital Editions/Thumbnails"
00057 
00058 
00059 void filetypes_init(gboolean watch);
00060 
00061 gboolean filetypes_showdir();
00062 
00063 /**---------------------------------------------------------------------------
00064  *
00065  * Name :  get_icon_from_file_extension
00066  *
00067  * @brief  Get icon for specified file extension
00068  *
00069  * @param  [in]  file_ext - file extension for which icon is requested
00070  *                          or empty string
00071  * @param  [in]  is_directory - whether file_ext is a directory
00072  * @param  [in]  icon_size - specifies which icon is requested
00073  *
00074  * @return Pointer to pixbuf holding the requested icon
00075  *         or NULL on error.
00076  *         Lifetime of the pixbuf is guaranteed until the next call to this function,
00077  *         caller must g_object_ref() / _unref() the pixbuf when it needs the pixbuf longer than that.
00078  *
00079  *--------------------------------------------------------------------------*/
00080 GdkPixbuf* get_icon_from_file_extension ( const gchar                 *file_ext,
00081                                           const gboolean              is_directory,
00082                                           const filemodel_thumbsize_t icon_size     );
00083 
00084 GdkPixbuf* get_icon_from_file(const gchar* icon_name, filemodel_thumbsize_t icon_size);
00085 
00086 GdkPixbuf* get_icon_delete_toggle(gboolean toggled, filemodel_thumbsize_t icon_size);
00087 
00088 /**---------------------------------------------------------------------------
00089  *
00090  * Name :  get_icon_application
00091  *
00092  * @brief  Get icon for application (executable file)
00093  *
00094  * @param  [in]  icon_size - specifies which icon is requested
00095  *
00096  * @return Pointer to pixbuf holding the requested icon
00097  *         or NULL on error.
00098  *         Lifetime of the pixbuf is guaranteed until the next call to this function,
00099  *         caller must g_object_ref() / _unref() the pixbuf when it needs the pixbuf longer than that.
00100  *
00101  *--------------------------------------------------------------------------*/
00102 GdkPixbuf* get_icon_application ( const filemodel_thumbsize_t icon_size );
00103 
00104 
00105 /**---------------------------------------------------------------------------
00106  *
00107  * Name :  get_icon_library
00108  *
00109  * @brief  Get icon for library (SD card)
00110  *
00111  * @param  [in]  icon_size - specifies which icon is requested
00112  *
00113  * @return Pointer to pixbuf holding the requested icon
00114  *         or NULL on error.
00115  *         Lifetime of the pixbuf is guaranteed until the next call to this function,
00116  *         caller must g_object_ref() / _unref() the pixbuf when it needs the pixbuf longer than that.
00117  *
00118  *--------------------------------------------------------------------------*/
00119 GdkPixbuf* get_icon_library ( const filemodel_thumbsize_t icon_size );
00120 
00121 
00122 /**---------------------------------------------------------------------------
00123  *
00124  * Name :  apply_icon_overlay_shortcut
00125  *
00126  * @brief  Apply overlay for shortcuts to the given icon
00127  *
00128  * @param  [in]     icon_size - specifies which icon overlay is requested
00129  * @param  [in,out] icon - a pixbuf holding a bitmap of the icon to be modified
00130  *
00131  * @return --
00132  *
00133  *--------------------------------------------------------------------------*/
00134 void apply_icon_overlay_shortcut ( const filemodel_thumbsize_t icon_size,
00135                                          GdkPixbuf             *icon     );
00136 
00137 
00138 void apply_icon_overlay_delete ( const filemodel_thumbsize_t icon_size,
00139                                  GdkPixbuf             *icon,
00140                                  gboolean toggled);
00141 
00142 /**---------------------------------------------------------------------------
00143  *
00144  * Name :  get_type_descr_from_file_extension
00145  *
00146  * @brief  Get filetype description for specified file extension
00147  *
00148  * @param  [in]  file_ext - file extension for which a description is requested
00149  *                          or empty string
00150  * @param  [in]  is_directory - whether filename is a directory
00151  *
00152  * @return filetype description
00153  *         or NULL when no description for the specified file extension
00154  *
00155  *--------------------------------------------------------------------------*/
00156 const gchar* get_type_descr_from_file_extension ( const gchar    *file_ext,
00157                                                   const gboolean is_directory);
00158 
00159 
00160 /**---------------------------------------------------------------------------
00161  *
00162  * Name :  get_viewer_from_file_extension
00163  *
00164  * @brief  Get executable for viewer application to be used for specified file extension
00165  *
00166  * @param  [in]  file_ext - file extension for which viewer is requested
00167  *                          or empty string
00168  *
00169  * @return Command-line command for the requested viewer application
00170  *         or NULL when no viewer known for the specified filename
00171  *
00172  *--------------------------------------------------------------------------*/
00173 const gchar* get_viewer_from_file_extension ( const gchar *file_ext );
00174 
00175 /**---------------------------------------------------------------------------
00176  * Name :  get_generate_thumbnail
00177  * @brief  Get boolean to determine whether or not to generate thumbnail
00178  * @param  [in]  file_ext - file extension for which viewer is requested
00179  * @return Boolean, true to generate thumbnail, false for not
00180  *--------------------------------------------------------------------------*/
00181 gboolean get_generate_thumbnail ( const gchar *file_ext );
00182 
00183 /**---------------------------------------------------------------------------
00184  *
00185  * Name :  is_drz_file_extension
00186  *
00187  * @brief  Tell whether the specified file extension is a drz file or not
00188  *
00189  * @param  [in]  file_ext - file extension to be checked
00190  *                          or empty string
00191  *
00192  * @return TRUE  when file extension is a drz file or
00193  *         FALSE when file extension not a drz file, or error
00194  *
00195  *--------------------------------------------------------------------------*/
00196 gboolean is_drz_file_extension ( const gchar *file_ext );
00197 
00198 /**---------------------------------------------------------------------------
00199  *
00200  * Name :  is_shortcut_file_extension
00201  *
00202  * @brief  Tell whether the specified file extension is a shortcut file or not
00203  *
00204  * @param  [in]  file_ext - file extension to be checked
00205  *                          or empty string
00206  *
00207  * @return TRUE  when file extension is a shortcut file or
00208  *         FALSE when file extension not a shortcut file, or error
00209  *
00210  *--------------------------------------------------------------------------*/
00211 gboolean is_shortcut_file_extension ( const gchar *file_ext );
00212 
00213 gboolean is_shortcut_file(const char* filename);
00214 
00215 // copied from libgnome-2.6.1.1 gnome-util.c:
00216 /**---------------------------------------------------------------------------
00217  *
00218  * g_extension_pointer:
00219  * @param path A filename or file path.
00220  *
00221  * Extracts the extension from the end of a filename (the part after the final
00222  * '.' in the filename).
00223  *
00224  * Returns: A pointer to the extension part of the filename, or a
00225  * pointer to the end of the string if the filename does not
00226  * have an extension.
00227  *
00228  *--------------------------------------------------------------------------*/
00229 const char* g_extension_pointer ( const char *path );
00230 
00231 
00232 G_END_DECLS
00233 
00234 #endif // __FILETYPES_H__
Generated by  doxygen 1.6.2-20100208