filetypes.h File Reference

#include <gdk/gdk.h>
#include <glib.h>
#include "filemodel.h"
Include dependency graph for filetypes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FILE_EXT_DRZ   "drz"
#define FILE_EXT_SHORTCUT   "desktop"
#define FILE_EXT_SHORTCUT_TO_DIR   "directory"
#define DIR_DRZ   "System/drz"
#define DIR_SHORTCUTS   "System/Shortcuts"
#define DIR_NOTES   "Notes"
#define DIR_ADE_THUMBS   "Digital Editions/Thumbnails"

Functions

void filetypes_init (gboolean watch)
gboolean filetypes_showdir ()
GdkPixbuf * get_icon_from_file_extension (const gchar *file_ext, const gboolean is_directory, const filemodel_thumbsize_t icon_size)
 Get icon for specified file extension.
GdkPixbuf * get_icon_from_file (const gchar *icon_name, filemodel_thumbsize_t icon_size)
GdkPixbuf * get_icon_delete_toggle (gboolean toggled, filemodel_thumbsize_t icon_size)
GdkPixbuf * get_icon_application (const filemodel_thumbsize_t icon_size)
 Get icon for application (executable file).
GdkPixbuf * get_icon_library (const filemodel_thumbsize_t icon_size)
 Get icon for library (SD card).
void apply_icon_overlay_shortcut (const filemodel_thumbsize_t icon_size, GdkPixbuf *icon)
 Apply overlay for shortcuts to the given icon.
void apply_icon_overlay_delete (const filemodel_thumbsize_t icon_size, GdkPixbuf *icon, gboolean toggled)
const gchar * get_type_descr_from_file_extension (const gchar *file_ext, const gboolean is_directory)
 Get filetype description for specified file extension.
const gchar * get_viewer_from_file_extension (const gchar *file_ext)
 Get executable for viewer application to be used for specified file extension.
gboolean get_generate_thumbnail (const gchar *file_ext)
 Get boolean to determine whether or not to generate thumbnail.
gboolean is_drz_file_extension (const gchar *file_ext)
 Tell whether the specified file extension is a drz file or not.
gboolean is_shortcut_file_extension (const gchar *file_ext)
 Tell whether the specified file extension is a shortcut file or not.
gboolean is_shortcut_file (const char *filename)
const char * g_extension_pointer (const char *path)

Define Documentation

#define DIR_ADE_THUMBS   "Digital Editions/Thumbnails"

Definition at line 56 of file filetypes.h.

Referenced by index_full().

#define DIR_DRZ   "System/drz"

Definition at line 53 of file filetypes.h.

Referenced by index_full().

#define DIR_NOTES   "Notes"

Definition at line 55 of file filetypes.h.

Referenced by add_desktop_items().

#define DIR_SHORTCUTS   "System/Shortcuts"

Definition at line 54 of file filetypes.h.

Referenced by add_desktop_items(), create_shortcut_item(), and index_full().

#define FILE_EXT_DRZ   "drz"

File Name : filetypes.h

Description: Content browser filetype specific utilities Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 49 of file filetypes.h.

Referenced by is_drz_file_extension().

#define FILE_EXT_SHORTCUT   "desktop"

Definition at line 50 of file filetypes.h.

Referenced by create_shortcut_file(), and is_shortcut_file_extension().

#define FILE_EXT_SHORTCUT_TO_DIR   "directory"

Definition at line 51 of file filetypes.h.

Referenced by create_shortcut_file(), and is_shortcut_file_extension().


Function Documentation

void apply_icon_overlay_delete ( const filemodel_thumbsize_t  icon_size,
GdkPixbuf *  icon,
gboolean  toggled 
)

Definition at line 492 of file filetypes.c.

References apply_icon_overlay().

Referenced by create_delete_overlay().

00495 {
00496     if (toggled)
00497         apply_icon_overlay( icon_size, icon, "overlay-delete-toggled");
00498     else
00499         apply_icon_overlay( icon_size, icon, "overlay-delete-untoggled");
00500 }

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_icon_overlay_shortcut ( const filemodel_thumbsize_t  icon_size,
GdkPixbuf *  icon 
)

Apply overlay for shortcuts to the given icon.

---------------------------------------------------------------------------

Name : apply_icon_overlay_shortcut

Parameters:
[in] icon_size - specifies which icon overlay is requested
[in,out] icon - a pixbuf holding a bitmap of the icon to be modified
Returns:
--

--------------------------------------------------------------------------

Definition at line 485 of file filetypes.c.

References apply_icon_overlay().

Referenced by get_thumbnail_for_shortcut().

00487 {
00488     apply_icon_overlay( icon_size, icon, "overlay-shortcut");
00489 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filetypes_init ( gboolean  watch  ) 

Definition at line 267 of file filetypes.c.

References add_filetypes_from_gconf(), add_hardcoded_filetypes(), CTB_GCONF_PATH, g_filetype_info, g_gconfclient, g_showdir, on_gconf_key_changed(), read_gconf_boolean(), and REGKEY_SHOW_SDCARD.

Referenced by filemodel_init(), and index_full().

00268 {
00269     g_filetype_info = g_array_new( TRUE, TRUE, sizeof(filetype_info_t) );
00270     g_assert(g_filetype_info);
00271 
00272     add_hardcoded_filetypes();
00273     add_filetypes_from_gconf();
00274 
00275     if (watch) {
00276         g_gconfclient = gconf_client_get_default();
00277         g_assert(g_gconfclient);
00278         g_showdir = read_gconf_boolean(CTB_GCONF_PATH, REGKEY_SHOW_SDCARD, g_gconfclient);
00279 
00280         gconf_client_add_dir(g_gconfclient,
00281                              CTB_GCONF_PATH,
00282                              GCONF_CLIENT_PRELOAD_NONE,
00283                              NULL);
00284 
00285         gconf_client_notify_add(g_gconfclient,
00286                                 CTB_GCONF_PATH,
00287                                 on_gconf_key_changed,
00288                                 NULL,
00289                                 NULL,
00290                                 NULL);
00291     }
00292 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean filetypes_showdir (  ) 

Definition at line 295 of file filetypes.c.

References g_showdir.

Referenced by add_desktop_items().

00296 {
00297     return g_showdir;
00298 }

Here is the caller graph for this function:

const char* g_extension_pointer ( const char *  path  ) 

---------------------------------------------------------------------------

g_extension_pointer:

Parameters:
path A filename or file path.

Extracts the extension from the end of a filename (the part after the final '.' in the filename).

Returns: A pointer to the extension part of the filename, or a pointer to the end of the string if the filename does not have an extension.

--------------------------------------------------------------------------

g_extension_pointer: : A filename or file path.

Extracts the extension from the end of a filename (the part after the final '.' in the filename).

Returns: A pointer to the extension part of the filename, or a pointer to the end of the string if the filename does not have an extension.

Definition at line 585 of file filetypes.c.

Referenced by activate_shortcut(), add_filename(), get_tag_for_file(), get_thumbnail_for_shortcut(), ignore_thumbnail_generation(), is_shortcut_file(), and read_directory().

00586 {
00587    char * s;
00588 
00589    g_return_val_if_fail(path != NULL, NULL);
00590 
00591    /* get the dot in the last element of the path */
00592    char *t = strrchr(path, G_DIR_SEPARATOR);
00593    if (t != NULL)
00594       s = strrchr(t, '.');
00595    else
00596       s = strrchr(path, '.');
00597 
00598    if (s == NULL)
00599       return path + strlen(path); /* There is no extension. */
00600    else {
00601       ++s;      /* pass the . */
00602       return s;
00603    }
00604 }

Here is the caller graph for this function:

gboolean get_generate_thumbnail ( const gchar *  file_ext  ) 

Get boolean to determine whether or not to generate thumbnail.

--------------------------------------------------------------------------- Name : get_generate_thumbnail

Parameters:
[in] file_ext - file extension for which viewer is requested
Returns:
Boolean, true to generate thumbnail, false for not --------------------------------------------------------------------------

Definition at line 564 of file filetypes.c.

References find_filetype_info(), and filetype_info_t::generate_thumbnail.

Referenced by ignore_thumbnail_generation().

00565 {
00566     filetype_info_t *details = find_filetype_info(file_ext, FALSE, FALSE);
00567     return details->generate_thumbnail;
00568 }

Here is the call graph for this function:

Here is the caller graph for this function:

GdkPixbuf* get_icon_application ( const filemodel_thumbsize_t  icon_size  ) 

Get icon for application (executable file).

---------------------------------------------------------------------------

Name : get_icon_application

Parameters:
[in] icon_size - specifies which icon is requested
Returns:
Pointer to pixbuf holding the requested icon or NULL on error. Lifetime of the pixbuf is guaranteed until the next call to this function, caller must g_object_ref() / _unref() the pixbuf when it needs the pixbuf longer than that.

--------------------------------------------------------------------------

Definition at line 404 of file filetypes.c.

References get_icon_from_file(), and ICONNAME_APPLICATION.

Referenced by get_thumbnail_for_shortcut().

00405 {
00406     return get_icon_from_file(ICONNAME_APPLICATION, icon_size);
00407 }

Here is the call graph for this function:

Here is the caller graph for this function:

GdkPixbuf* get_icon_delete_toggle ( gboolean  toggled,
filemodel_thumbsize_t  icon_size 
)

Definition at line 416 of file filetypes.c.

References get_icon_from_file().

Referenced by toggle_cell_function().

00417 {
00418     if (toggled) {
00419         return get_icon_from_file("delete-toggled", icon_size);
00420     } else {
00421         return get_icon_from_file("delete-untoggled", icon_size);
00422     }
00423 }

Here is the call graph for this function:

Here is the caller graph for this function:

GdkPixbuf* get_icon_from_file ( const gchar *  icon_name,
filemodel_thumbsize_t  icon_size 
)

Definition at line 430 of file filetypes.c.

References compareString(), ERRORPRINTF, g_icon_cache, ICONFILE_POSTFIX, ICONFILE_PREFIX, and ICONS_DIRECTORY.

Referenced by add_browse_mode_specials(), add_delete_mode_specials(), add_desktop_item(), add_previous_dir(), apply_icon_overlay(), get_icon_application(), get_icon_delete_toggle(), and get_icon_library().

00431 {
00432     if (g_icon_cache == NULL) g_icon_cache = g_tree_new(compareString);
00433 
00434     g_assert(icon_name && *icon_name);
00435     gchar icon_file[256];
00436     snprintf(icon_file, 255, "%s/%s%s%s",
00437                                  ICONS_DIRECTORY,
00438                                  ICONFILE_PREFIX,
00439                                  icon_name,
00440                                  ICONFILE_POSTFIX[icon_size]);
00441     int len = strlen(ICONS_DIRECTORY) + strlen(ICONFILE_PREFIX) + 1;
00442     gchar* short_name = icon_file + len;
00443     gpointer cache = g_tree_lookup(g_icon_cache, short_name);
00444     GdkPixbuf *icon = NULL;
00445     if (cache) {
00446         icon = (GdkPixbuf *)cache;
00447     } else {
00448         GError *err = NULL;
00449         icon = gdk_pixbuf_new_from_file(icon_file, &err);
00450         if (icon) {
00451             g_tree_insert(g_icon_cache, g_strdup(short_name), icon);
00452         } else  {
00453             ERRORPRINTF("cannot load iconfile [%s] error [%s]", icon_file, err->message);
00454             g_clear_error(&err);
00455         }
00456     }
00457     return icon;
00458 }

Here is the call graph for this function:

Here is the caller graph for this function:

GdkPixbuf* get_icon_from_file_extension ( const gchar *  file_ext,
const gboolean  is_directory,
const filemodel_thumbsize_t  icon_size 
)

Get icon for specified file extension.

---------------------------------------------------------------------------

Name : get_icon_from_file_extension

Parameters:
[in] file_ext - file extension for which icon is requested or empty string
[in] is_directory - whether file_ext is a directory
[in] icon_size - specifies which icon is requested
Returns:
Pointer to pixbuf holding the requested icon or NULL on error. Lifetime of the pixbuf is guaranteed until the next call to this function, caller must g_object_ref() / _unref() the pixbuf when it needs the pixbuf longer than that.

--------------------------------------------------------------------------

Definition at line 369 of file filetypes.c.

References ERRORPRINTF, find_filetype_info(), filetype_info_t::icon_name, ICONFILE_POSTFIX, ICONFILE_PREFIX, ICONS_DIRECTORY, and filetype_info_t::pixbuf_icon.

Referenced by get_thumbnail(), and get_thumbnail_for_shortcut().

00372 {
00373     GdkPixbuf *icon               = NULL;
00374 
00375     filetype_info_t *details = find_filetype_info(file_ext, is_directory, TRUE);
00376     if (details)
00377     {
00378         // get normal icon
00379         GdkPixbuf **p_pixbuf_icon = &(details->pixbuf_icon[icon_size]);
00380         icon = *p_pixbuf_icon;
00381         if (icon == NULL)
00382         {
00383             // load filetype icon from file
00384             gchar* icon_file = g_strdup_printf( "%s/%s%s%s",
00385                     ICONS_DIRECTORY,
00386                     ICONFILE_PREFIX,
00387                     details->icon_name,
00388                     ICONFILE_POSTFIX[icon_size] );
00389             GError *err = NULL;
00390             icon = gdk_pixbuf_new_from_file( icon_file, &err );
00391             if (icon) *p_pixbuf_icon = icon;
00392             else
00393             {
00394                 ERRORPRINTF("cannot load iconfile [%s] error [%s]", icon_file, err->message);
00395                 g_clear_error(&err);
00396             }
00397             g_free(icon_file);
00398         }
00399     }
00400     return icon;
00401 }

Here is the call graph for this function:

Here is the caller graph for this function:

GdkPixbuf* get_icon_library ( const filemodel_thumbsize_t  icon_size  ) 

Get icon for library (SD card).

---------------------------------------------------------------------------

Name : get_icon_library

Parameters:
[in] icon_size - specifies which icon is requested
Returns:
Pointer to pixbuf holding the requested icon or NULL on error. Lifetime of the pixbuf is guaranteed until the next call to this function, caller must g_object_ref() / _unref() the pixbuf when it needs the pixbuf longer than that.

--------------------------------------------------------------------------

Definition at line 410 of file filetypes.c.

References get_icon_from_file(), and ICONNAME_LIBRARY.

Referenced by get_thumbnail_for_shortcut().

00411 {
00412     return get_icon_from_file(ICONNAME_LIBRARY, icon_size);
00413 }

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* get_type_descr_from_file_extension ( const gchar *  file_ext,
const gboolean  is_directory 
)

Get filetype description for specified file extension.

---------------------------------------------------------------------------

Name : get_type_descr_from_file_extension

Parameters:
[in] file_ext - file extension for which a description is requested or empty string
[in] is_directory - whether filename is a directory
Returns:
filetype description or NULL when no description for the specified file extension

--------------------------------------------------------------------------

Definition at line 503 of file filetypes.c.

References filetype_info_t::description, ERRORPRINTF, and find_filetype_info().

Referenced by load_items_in_model().

00505 {
00506     filetype_info_t *details = find_filetype_info(file_ext, is_directory, TRUE);
00507 
00508     const gchar *description = "";
00509     if (details)
00510     {
00511         if (details->description)
00512         {
00513             description = _( details->description );
00514         }
00515         else
00516         {
00517             ERRORPRINTF( "filetype [%s] is_dir [%d] has no description",
00518                          details->description, is_directory);
00519         }
00520     }
00521 
00522     return description;
00523 }

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* get_viewer_from_file_extension ( const gchar *  file_ext  ) 

Get executable for viewer application to be used for specified file extension.

---------------------------------------------------------------------------

Name : get_viewer_from_file_extension

Parameters:
[in] file_ext - file extension for which viewer is requested or empty string
Returns:
Command-line command for the requested viewer application or NULL when no viewer known for the specified filename

--------------------------------------------------------------------------

Definition at line 555 of file filetypes.c.

References find_filetype_info(), and filetype_info_t::viewer_cmd.

Referenced by activate_item(), delete_item(), ignore_file(), and ignore_thumbnail_generation().

00556 {
00557     filetype_info_t *details = find_filetype_info(file_ext, FALSE, FALSE);
00558 
00559     const gchar *viewer_cmd = (details) ?  details->viewer_cmd : NULL;
00560     return viewer_cmd;
00561 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean is_drz_file_extension ( const gchar *  file_ext  ) 

Tell whether the specified file extension is a drz file or not.

---------------------------------------------------------------------------

Name : is_drz_file_extension

Parameters:
[in] file_ext - file extension to be checked or empty string
Returns:
TRUE when file extension is a drz file or FALSE when file extension not a drz file, or error

--------------------------------------------------------------------------

Definition at line 526 of file filetypes.c.

References FILE_EXT_DRZ.

Referenced by read_directory().

00527 {
00528     if ( strcmp( file_ext, FILE_EXT_DRZ ) == 0 )
00529     {
00530         return TRUE;
00531     }
00532     return FALSE;
00533 }

Here is the caller graph for this function:

gboolean is_shortcut_file ( const char *  filename  ) 

Definition at line 547 of file filetypes.c.

References g_extension_pointer(), and is_shortcut_file_extension().

Referenced by check_shortcut(), and handle_changes().

00548 {
00549     const char* ext = g_extension_pointer(filename);
00550     return is_shortcut_file_extension(ext);
00551 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean is_shortcut_file_extension ( const gchar *  file_ext  ) 

Tell whether the specified file extension is a shortcut file or not.

---------------------------------------------------------------------------

Name : is_shortcut_file_extension

Parameters:
[in] file_ext - file extension to be checked or empty string
Returns:
TRUE when file extension is a shortcut file or FALSE when file extension not a shortcut file, or error

--------------------------------------------------------------------------

Definition at line 536 of file filetypes.c.

References FILE_EXT_SHORTCUT, and FILE_EXT_SHORTCUT_TO_DIR.

Referenced by activate_item(), get_thumbnail(), ignore_file(), is_shortcut_file(), load_items_in_model(), and shortcut_allowed().

00537 {
00538     if (   strcmp( file_ext, FILE_EXT_SHORTCUT       ) == 0
00539         || strcmp( file_ext, FILE_EXT_SHORTCUT_TO_DIR) == 0 )
00540     {
00541         return TRUE;
00542     }
00543     return FALSE;
00544 }

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208