filetypes.c File Reference

#include "config.h"
#include <gconf/gconf-client.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <string.h>
#include "ctb_log.h"
#include "filetypes.h"
#include "i18n.h"
Include dependency graph for filetypes.c:

Go to the source code of this file.

Data Structures

struct  filetype_info_t

Defines

#define CTB_GCONF_PATH   "/apps/er/sys/ctb"
#define REGKEY_SHOW_SDCARD   "show_sdcard"
#define GCONF_BUFFER_SIZE   128

Functions

static filetype_info_tfind_filetype_info (const gchar *file_ext, const gboolean is_directory, const gboolean with_default)
static gchar * read_gconf_value (const gchar *dir, const gchar *key, GConfClient *client)
static gboolean read_gconf_boolean (const gchar *dir, const gchar *key, GConfClient *client)
static void add_filetype_from_gconf (const gchar *dir, GConfClient *client)
static void add_filetypes_from_gconf ()
static void add_hardcoded_filetypes ()
static void on_gconf_key_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
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_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).
GdkPixbuf * get_icon_delete_toggle (gboolean toggled, filemodel_thumbsize_t icon_size)
gint compareString (gconstpointer a, gconstpointer b)
GdkPixbuf * get_icon_from_file (const gchar *icon_name, filemodel_thumbsize_t icon_size)
static void apply_icon_overlay (const filemodel_thumbsize_t icon_size, GdkPixbuf *icon, const gchar *overlay_name)
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.
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 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.
const char * g_extension_pointer (const char *path)

Variables

static const gchar * ICONS_DIRECTORY = DATADIR
static const gchar * ICONFILE_PREFIX = "icon-"
static const gchar * ICONFILE_POSTFIX [N_FILEMODEL_THUMB_SIZES]
static const gchar * ICONNAME_APPLICATION = "application"
static const gchar * ICONNAME_LIBRARY = "sdcard"
static const gchar * REGKEY_FILETYPE_DIR = CTB_GCONF_PATH "/filetypes"
static filetype_info_t g_hardcoded_filetypes []
static GArray * g_filetype_info = NULL
static GTree * g_icon_cache = NULL
static GConfClient * g_gconfclient = NULL
static gboolean g_showdir = FALSE

Define Documentation

#define CTB_GCONF_PATH   "/apps/er/sys/ctb"

Definition at line 78 of file filetypes.c.

Referenced by filetypes_init(), and on_gconf_key_changed().

#define GCONF_BUFFER_SIZE   128

Definition at line 93 of file filetypes.c.

Referenced by add_filetype_from_gconf(), read_gconf_boolean(), and read_gconf_value().

#define REGKEY_SHOW_SDCARD   "show_sdcard"

Definition at line 79 of file filetypes.c.

Referenced by filetypes_init(), and on_gconf_key_changed().


Function Documentation

static void add_filetype_from_gconf ( const gchar *  dir,
GConfClient *  client 
) [static]

Definition at line 147 of file filetypes.c.

References buffer, filetype_info_t::description, ERRORPRINTF, filetype_info_t::extension, find_filetype_info(), g_filetype_info, GCONF_BUFFER_SIZE, filetype_info_t::generate_thumbnail, filetype_info_t::icon_name, filetype_info_t::is_directory, read_gconf_boolean(), read_gconf_value(), filetype_info_t::reference_ext, and filetype_info_t::viewer_cmd.

Referenced by add_filetypes_from_gconf().

00149 {
00150     gchar buffer[GCONF_BUFFER_SIZE];
00151     gchar *descr = NULL;
00152     gchar *viewer_cmd = NULL;
00153     gchar *icon_name = NULL;
00154     gchar *reference_ext = NULL;
00155     GSList *ext = NULL;
00156     gboolean generate_thumbnail = FALSE;
00157 
00158     descr = read_gconf_value(dir, "descr", client);
00159     if (!descr) goto out_error;
00160 
00161     viewer_cmd = read_gconf_value(dir, "viewer_cmd", client);
00162     if (!viewer_cmd) goto out_error;
00163 
00164     icon_name = read_gconf_value(dir, "icon_name", client);
00165     if (!icon_name) goto out_error;
00166 
00167     generate_thumbnail = read_gconf_boolean(dir, "generate_thumbnail", client);
00168 
00169     g_assert(strlen(dir) + strlen("/extensions") < GCONF_BUFFER_SIZE);
00170     snprintf(buffer, GCONF_BUFFER_SIZE-1, "%s/extensions", dir);
00171     GSList *extensions = gconf_client_get_list(client, buffer, GCONF_VALUE_STRING, NULL);
00172     if (extensions == NULL) {
00173         ERRORPRINTF("gconf: cannot read %s", buffer);
00174         goto out_error;
00175     }
00176 
00177     for (ext = extensions; ext; ext = g_slist_next(ext)) {
00178         if (find_filetype_info(ext->data, FALSE, FALSE) != NULL) {
00179             ERRORPRINTF("gconf: ext %s is already registered, skipping", (gchar*)ext->data);
00180             continue;
00181         }
00182 
00183         filetype_info_t newtype;
00184         memset(&newtype, 0x00, sizeof(newtype));
00185         newtype.extension          = g_strdup(ext->data);
00186         newtype.reference_ext      = g_strdup(reference_ext);
00187         newtype.is_directory       = FALSE;
00188         newtype.icon_name          = g_strdup(icon_name);
00189         newtype.description        = g_strdup(descr);
00190         newtype.viewer_cmd         = g_strdup(viewer_cmd);
00191         newtype.generate_thumbnail = generate_thumbnail;
00192         g_array_append_val(g_filetype_info, newtype);
00193 
00194         if (reference_ext == NULL) reference_ext = ext->data;
00195     }
00196     g_slist_foreach (extensions, (GFunc)g_free, NULL);
00197     g_slist_free(extensions);
00198 out_error:
00199     g_free(icon_name);
00200     g_free(viewer_cmd);
00201     g_free(descr);
00202 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void add_filetypes_from_gconf (  )  [static]

Definition at line 205 of file filetypes.c.

References add_filetype_from_gconf(), client, ERRORPRINTF, and REGKEY_FILETYPE_DIR.

Referenced by filetypes_init().

00206 {
00207     GSList *types = NULL;
00208     GConfClient *client = gconf_client_get_default();
00209 
00210     gboolean exists = gconf_client_dir_exists(client, REGKEY_FILETYPE_DIR, NULL);
00211     if (exists == FALSE) {
00212         ERRORPRINTF("gconf: %s does not exist", REGKEY_FILETYPE_DIR);
00213         goto unref;
00214     }
00215 
00216     types = gconf_client_all_dirs(client, REGKEY_FILETYPE_DIR, NULL);
00217     if (types == NULL) {
00218         ERRORPRINTF("gconf: cannot read dir entries of %s", REGKEY_FILETYPE_DIR);
00219         goto unref;
00220     }
00221 
00222     g_slist_foreach (types, (GFunc)add_filetype_from_gconf, client);
00223     g_slist_foreach (types, (GFunc)g_free, NULL);
00224     g_slist_free(types);
00225 unref:
00226     g_object_unref(client);
00227 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void add_hardcoded_filetypes (  )  [static]

Definition at line 230 of file filetypes.c.

References filetype_info_t::description, filetype_info_t::extension, g_filetype_info, filetype_info_t::icon_name, filetype_info_t::is_directory, filetype_info_t::reference_ext, and filetype_info_t::viewer_cmd.

Referenced by filetypes_init().

00231 {
00232     filetype_info_t   *known_type = NULL;
00233     filetype_info_t   details;
00234 
00235     // fill array with hardcoded filetypes
00236     for ( known_type = g_hardcoded_filetypes ; known_type->extension ; known_type++ )
00237     {
00238         // set details
00239         memset(&details, 0x00, sizeof(details));
00240         details.extension       = g_strdup(known_type->extension     );
00241         details.reference_ext   = g_strdup(known_type->reference_ext );
00242         details.is_directory    = known_type->is_directory;
00243         details.icon_name       = g_strdup(known_type->icon_name     );
00244         details.description     = g_strdup(known_type->description   );
00245         details.viewer_cmd      = g_strdup(known_type->viewer_cmd    );
00246 
00247         // add to array
00248         g_array_append_val(g_filetype_info, details);
00249     }
00250 }

Here is the caller graph for this function:

static void apply_icon_overlay ( const filemodel_thumbsize_t  icon_size,
GdkPixbuf *  icon,
const gchar *  overlay_name 
) [static]

Definition at line 461 of file filetypes.c.

References get_icon_from_file().

Referenced by apply_icon_overlay_delete(), and apply_icon_overlay_shortcut().

00464 {
00465     if (icon == NULL) return;
00466 
00467     GdkPixbuf *overlay = get_icon_from_file(overlay_name, icon_size);
00468 
00469     // apply overlay to icon bitmap
00470     if (overlay)
00471     {
00472         gdk_pixbuf_composite( overlay,                      // src
00473                               icon,                         // dest
00474                               0, 0,                         // dest x, y
00475                               gdk_pixbuf_get_width(icon),   // dest width
00476                               gdk_pixbuf_get_height(icon),  // dest height
00477                               0.0, 0.0,                     // offset x, y
00478                               1.0, 1.0,                     // scale  x, y
00479                               GDK_INTERP_NEAREST,           // interpolation type: not needed, take the fastest
00480                               0xFF );                       // overall_alpha
00481     }
00482 }

Here is the call graph for this function:

Here is the caller graph for this function:

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:

gint compareString ( gconstpointer  a,
gconstpointer  b 
)

Definition at line 425 of file filetypes.c.

Referenced by get_icon_from_file(), and load_icon().

00425                                                      {
00426     return strcmp((const gchar*)a, (const gchar*)b);
00427 }

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:

static filetype_info_t * find_filetype_info ( const gchar *  file_ext,
const gboolean  is_directory,
const gboolean  with_default 
) [static]

Definition at line 301 of file filetypes.c.

References ERRORPRINTF, filetype_info_t::extension, g_filetype_info, filetype_info_t::is_directory, LOGPRINTF, and filetype_info_t::reference_ext.

Referenced by add_filetype_from_gconf(), get_generate_thumbnail(), get_icon_from_file_extension(), get_type_descr_from_file_extension(), and get_viewer_from_file_extension().

00304 {
00305 
00306     g_assert(g_filetype_info);
00307 
00308 //    LOGPRINTF("file_ext [%s] is_dir [%d]", file_ext, is_directory);
00309     if (file_ext == NULL)
00310     {
00311         file_ext = "";
00312     }
00313 
00314     gboolean done  = FALSE;
00315     gboolean found = FALSE;
00316     filetype_info_t *ret = NULL;
00317     while ( !done )
00318     {
00319         filetype_info_t *details = (filetype_info_t*) g_filetype_info->data;
00320         while (details->extension)
00321         {
00322             if (details->is_directory == is_directory 
00323                  && g_ascii_strcasecmp( details->extension, file_ext ) == 0 )
00324             {
00325                 ret = details;
00326                 found = TRUE;
00327                 break;
00328             }
00329             else
00330             {
00331                 details++;
00332             }
00333         }
00334 
00335         if ( found )
00336         {
00337             gchar *ref_ext = details->reference_ext;
00338 //            LOGPRINTF( "found filetype [%s] ref [%s] icon_name [%s] descr [%s]",
00339 //                    file_ext, ref_ext, details->icon_name, details->description );
00340             if (ref_ext)
00341             {
00342                 return find_filetype_info( ref_ext, is_directory, with_default );
00343             }
00344             done = TRUE;
00345         }
00346         else if (*file_ext)
00347         {
00348             LOGPRINTF("unkown filetype [%s] is_dir [%d]", file_ext, is_directory);
00349             if (with_default)
00350             {
00351                 file_ext = "";
00352             }
00353             else
00354             {
00355                 done = TRUE;
00356             }
00357         }
00358         else
00359         {
00360             ERRORPRINTF("no default fileinfo for is_dir [%d]", is_directory);
00361             done = TRUE;
00362         }
00363     }
00364 
00365     return ret;
00366 }

Here is the caller graph for this function:

const char* g_extension_pointer ( const char *  path  ) 

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.

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 }

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:

static void on_gconf_key_changed ( GConfClient *  client,
guint  cnxn_id,
GConfEntry *  entry,
gpointer  user_data 
) [static]

Definition at line 253 of file filetypes.c.

References CTB_GCONF_PATH, g_showdir, and REGKEY_SHOW_SDCARD.

Referenced by filetypes_init().

00257 {
00258     const gchar* key = gconf_entry_get_key(entry);
00259     if (strcmp(key, CTB_GCONF_PATH"/"REGKEY_SHOW_SDCARD) == 0) {
00260         const GConfValue* value = gconf_entry_get_value(entry);
00261         gboolean show = gconf_value_get_bool(value);
00262         g_showdir = show;
00263     }
00264 }

Here is the caller graph for this function:

static gboolean read_gconf_boolean ( const gchar *  dir,
const gchar *  key,
GConfClient *  client 
) [static]

Definition at line 133 of file filetypes.c.

References buffer, and GCONF_BUFFER_SIZE.

Referenced by add_filetype_from_gconf(), and filetypes_init().

00136 {
00137     gboolean value = FALSE;
00138     gchar buffer[GCONF_BUFFER_SIZE];
00139     g_assert(strlen(dir) + 1 + strlen(key) < GCONF_BUFFER_SIZE);
00140     snprintf(buffer, GCONF_BUFFER_SIZE-1, "%s/%s", dir, key);
00141 
00142     value = gconf_client_get_bool(client, buffer, NULL);
00143     return value;
00144 }

Here is the caller graph for this function:

static gchar* read_gconf_value ( const gchar *  dir,
const gchar *  key,
GConfClient *  client 
) [static]

Definition at line 117 of file filetypes.c.

References buffer, ERRORPRINTF, and GCONF_BUFFER_SIZE.

Referenced by add_filetype_from_gconf().

00120 {
00121     gchar buffer[GCONF_BUFFER_SIZE];
00122     gchar* value;
00123     g_assert(strlen(dir) + 1 + strlen(key) < GCONF_BUFFER_SIZE);
00124     snprintf(buffer, GCONF_BUFFER_SIZE-1, "%s/%s", dir, key);
00125     value = gconf_client_get_string(client, buffer, NULL);
00126     if (value == NULL) {
00127         ERRORPRINTF("gconf: cannot read %s", buffer);
00128     }
00129     return value;
00130 }

Here is the caller graph for this function:


Variable Documentation

GArray* g_filetype_info = NULL [static]
GConfClient* g_gconfclient = NULL [static]

Definition at line 101 of file filetypes.c.

Referenced by filetypes_init().

Initial value:
            {
                
                { ""                      , NULL, TRUE , "folder",  N_("Folder"),   NULL,      {}, FALSE },
                { ""                      , NULL, FALSE, "unknown", N_("Unknown"),  NULL,      {}, FALSE },
                { FILE_EXT_SHORTCUT       , NULL, FALSE, "unknown", N_("Shortcut"), NULL,      {}, FALSE },
                { FILE_EXT_SHORTCUT_TO_DIR, NULL, FALSE, "folder",  N_("Shortcut"), NULL,      {}, FALSE },
                { NULL,                     NULL, FALSE, NULL,      NULL,           NULL,      {}, FALSE },
            }

Definition at line 83 of file filetypes.c.

GTree* g_icon_cache = NULL [static]

Definition at line 100 of file filetypes.c.

Referenced by get_icon_from_file().

gboolean g_showdir = FALSE [static]

Definition at line 102 of file filetypes.c.

Referenced by filetypes_init(), filetypes_showdir(), and on_gconf_key_changed().

const gchar* ICONFILE_POSTFIX[N_FILEMODEL_THUMB_SIZES] [static]
Initial value:
                        {
                            "-mini.png",
                            "-small.png",
                            "-medium.png",
                            "-large.png"
                        }

Definition at line 67 of file filetypes.c.

Referenced by get_icon_from_file(), and get_icon_from_file_extension().

const gchar* ICONFILE_PREFIX = "icon-" [static]

Definition at line 66 of file filetypes.c.

Referenced by get_icon_from_file(), and get_icon_from_file_extension().

const gchar* ICONNAME_APPLICATION = "application" [static]

Definition at line 75 of file filetypes.c.

Referenced by get_icon_application().

const gchar* ICONNAME_LIBRARY = "sdcard" [static]

Definition at line 76 of file filetypes.c.

Referenced by get_icon_library().

const gchar* ICONS_DIRECTORY = DATADIR [static]

Definition at line 65 of file filetypes.c.

Referenced by get_icon_from_file(), and get_icon_from_file_extension().

const gchar* REGKEY_FILETYPE_DIR = CTB_GCONF_PATH "/filetypes" [static]

Definition at line 80 of file filetypes.c.

Referenced by add_filetypes_from_gconf().

Generated by  doxygen 1.6.2-20100208