filemodel.h

Go to the documentation of this file.
00001 #ifndef __FILEMODEL_H__
00002 #define __FILEMODEL_H__
00003 
00004 /**
00005  * File Name  : filemodel.h
00006  *
00007  * Description: Content browser data for file model
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 <gtk/gtk.h>
00038 
00039 #include <libermetadb/ermetadb.h>
00040 
00041 G_BEGIN_DECLS
00042 
00043 // special item filenames
00044 #define SPECIAL_ITEM_NAME "special"
00045 #define SPECIAL_BOOKS "books"
00046 #define SPECIAL_IMAGES "images"
00047 #define SPECIAL_NEWS "news"
00048 #define SPECIAL_HELP "help"
00049 #define SPECIAL_PERSONAL "personal"
00050 #define SPECIAL_DIR "dir"
00051 #define SPECIAL_SHORTCUTS "shortcuts"
00052 #define SPECIAL_NOTES "notes"
00053 #define SPECIAL_SETTINGS "settings"
00054 #define SPECIAL_SEARCH "search"
00055 #define SPECIAL_RECENT "recent"
00056 #define SPECIAL_UPDIR ".."
00057 
00058 // special directory locations
00059 #define DIR_DESKTOP_TEMPLATE        SYSCONFDIR "/desktop"
00060 #define DIR_DESKTOP_INTERNAL        "/var/tmp/"         // NOT really used
00061 #define DIR_STORAGE_MNT             "/media"                        // mountpoint for removable storage devices
00062 #define DIR_LIBRARY                 DIR_STORAGE_MNT "/mmcblk0p1"    // mountpoint for internal SD card
00063 
00064 // columns in file model
00065 typedef enum
00066         {
00067             MODCOL_FILENAME = 0,
00068             MODCOL_TITLE,
00069             MODCOL_FILETYPE,
00070             MODCOL_FILETYPE_DISPLAY,
00071             MODCOL_DIRECTORY_PATH,
00072             MODCOL_IS_DIRECTORY,
00073             MODCOL_FILESIZE,
00074             MODCOL_FILEDATE,
00075             MODCOL_SUBTITLE,
00076             MODCOL_THUMBNAIL,
00077             MODCOL_TOGGLED,
00078             N_FILEMODEL_COLUMNS
00079         } filemodel_column_t;
00080 
00081 #define FILEMODEL_COLUMN_TYPES                                 \
00082             G_TYPE_STRING,      /* MODCOL_FILENAME         */  \
00083             G_TYPE_STRING,      /* MODCOL_TITLE */  \
00084             G_TYPE_STRING,      /* MODCOL_FILETYPE         */  \
00085             G_TYPE_STRING,      /* MODCOL_FILETYPE_DISPLAY */  \
00086             G_TYPE_STRING,      /* MODCOL_DIRECTORY_PATH   */  \
00087             G_TYPE_BOOLEAN,     /* MODCOL_IS_DIRECTORY     */  \
00088             G_TYPE_STRING,      /* MODCOL_FILESIZE         */  \
00089             G_TYPE_STRING,      /* MODCOL_FILEDATE         */  \
00090             G_TYPE_STRING,      /* MODCOL_SUBTITLE           */  \
00091             GDK_TYPE_PIXBUF,    /* MODCOL_THUMBNAIL        */  \
00092             G_TYPE_INT,         /* MODCOL_TOGGLED          */  \
00093             NULL  /* end of list */
00094 
00095 // thumbnail size
00096 typedef enum
00097         {
00098             MODTHUMB_MINI = 0,
00099             MODTHUMB_SMALL,
00100             MODTHUMB_MEDIUM,
00101             MODTHUMB_LARGE,
00102             N_FILEMODEL_THUMB_SIZES
00103         } filemodel_thumbsize_t;
00104 
00105 // entry in filelist delivered by filemodel_get_filenames_xx()
00106 typedef struct
00107         {
00108             GString     *filename;
00109             GString     *filename_display;
00110             GString     *filetype;
00111             GString     *directory_path;
00112             gboolean    is_directory;
00113         } filelist_entry_t;
00114 
00115 typedef enum
00116         {
00117             BROWSE_MODE = 0,
00118             DELETE_MODE,
00119         } ctb_viewmodes_t;
00120 
00121 // sorting order in content browser views
00122 typedef enum
00123         {
00124             CTB_SORT_BY_NAME = 0,
00125             CTB_SORT_BY_TYPE,
00126             CTB_SORT_BY_SIZE,
00127             CTB_SORT_BY_DATE_ADDED,
00128             CTB_SORT_BY_DATE_READ,
00129             CTB_SORT_BY_AUTHOR,
00130             N_CTB_SORT_ORDER
00131         } ctb_sort_order_t;
00132 
00133 typedef enum
00134         {
00135             DESKTOP_VIEW = 0,
00136             SETTINGS_VIEW,
00137             BOOKS_VIEW,
00138             NEWS_VIEW,
00139             IMAGES_VIEW,
00140             PERSONAL_VIEW,
00141             DIR_VIEW,
00142             SHORTCUT_VIEW,
00143             NOTES_VIEW,
00144             HELP_VIEW,
00145             RECENT_VIEW,
00146             SEARCH_VIEW,
00147         } ViewMode;
00148 
00149 //----------------------------------------------------------------------------
00150 // Global Constants
00151 //----------------------------------------------------------------------------
00152 
00153 
00154 //============================================================================
00155 // Public Functions
00156 //============================================================================
00157 
00158 
00159 // creates initial desktop etc
00160 void filemodel_init();
00161 
00162 void filemodel_quit();
00163 
00164 
00165 /**---------------------------------------------------------------------------
00166  *
00167  * Name :  get_filemodel
00168  *
00169  * @brief  Get a pointer to the file model
00170  *
00171  * @param  none
00172  *
00173  * @return GtkTreeModel interface on the filestore object
00174  *
00175  *--------------------------------------------------------------------------*/
00176 GtkTreeModel* get_filemodel();
00177 
00178 
00179 /**---------------------------------------------------------------------------
00180  *
00181  * Name :  filemodel_get_database
00182  *
00183  * @brief  Get the currently open metadata database
00184  *
00185  * @param  none
00186  *
00187  * @return Currently open metadata database,
00188  *         or NULL if no database open
00189  *
00190  *--------------------------------------------------------------------------*/
00191 erMetadb filemodel_get_database();
00192 
00193 
00194 // DISPLAY ATTRIBUTES
00195 
00196 gboolean filemodel_set_sortorder(ctb_sort_order_t sort_order,
00197                                  const gchar* cursor_item,
00198                                  gboolean updateScreen);
00199 
00200 // filters all db results to be of indicated type
00201 void filemodel_set_viewmode2(ViewMode newmode);
00202 
00203 void filemodel_set_search_filter(const gchar* search_string);
00204 
00205 const gchar* filemodel_get_title();
00206 
00207 const gchar* filemodel_get_subtitle();
00208 
00209 const gchar* filemodel_get_menu_content();
00210 
00211 /**---------------------------------------------------------------------------
00212  *
00213  * Name :  filemodel_set_viewsize
00214  *
00215  * @brief  Set number of items in view, same number must be loaded in model
00216  *
00217  * @param  [in]  n_items - number of items to be loaded in model (> 0)
00218  *         [in]  updateScreen - whether to load data in gui model
00219  *
00220  * @return --
00221  *
00222  *--------------------------------------------------------------------------*/
00223 gboolean filemodel_set_viewsize(const int n_items, gboolean updateScreen);
00224 
00225 // if updateScreen is False, caller has to make other calls that update the screen
00226 void filemodel_set_viewmode(ctb_viewmodes_t newmode, gboolean updateScreen);
00227 
00228 
00229 /**---------------------------------------------------------------------------
00230  *
00231  * Name :  filemodel_set_thumbsize
00232  *
00233  * @brief  Set thumbnail to be loaded in model
00234  *
00235  * @param  [in]  thumb_size - thumbnail size to be loaded in model
00236  * @param  [in]  reload - whether to reload data from metadb.
00237  *          If more calls follow that also cause a reload, use false here.
00238  *
00239  * @return --
00240  *
00241  *--------------------------------------------------------------------------*/
00242 void filemodel_set_thumbsize(const filemodel_thumbsize_t thumb_size, gboolean reload);
00243 
00244 
00245 // NAVIGATION WITHIN DIRECTORY
00246 gboolean filemodel_has_prev_page();
00247 
00248 gboolean filemodel_has_next_page();
00249 
00250 void filemodel_page_previous();
00251 
00252 void filemodel_page_next();
00253 
00254 void filemodel_update_pagecounter();
00255 /*
00256  * Name: filemodel_scroll_to_letter
00257  *
00258  * @param  [in]  letter  initial of file/dir to jump to
00259  * @param  [in]  jump_to_dir  whether to prefer a dir or not
00260  * @parem [out]  same_page whether index is on same page
00261  *
00262  * @return display index of letter (-1 if not found)
00263  * The column that's being examined depends on the current
00264  * sort order (Name/Author). */
00265 int filemodel_scroll_to_letter(gchar letter, gboolean jump_to_dir, gboolean* same_page);
00266 
00267 void filemodel_scroll_to_filename(const gchar *filename);
00268 
00269 // returns index for filename in currently displayed items (page)
00270 // 0 is first item
00271 int filemodel_get_display_index(const gchar *filename);
00272 
00273 
00274 // NAVIGATION BETWEEN DIRECTORIES
00275 // change model to desktop
00276 int filemodel_chdir_desktop();
00277 
00278 // enter a directory
00279 int filemodel_chdir_down(const gchar *dir, const gchar *last_item);
00280 
00281 // goes back a dir. Returns cursor_item name of parent dir
00282 gchar *filemodel_chdir_up();
00283 
00284 // reloads data from metadata.dd. Does not load items into GUI
00285 // offset stays the same. Returns whether data has been reloaded
00286 gboolean filemodel_resync(gboolean force_reload);
00287 
00288 gboolean filemodel_current_is_desktop();
00289 
00290 const gchar* filemodel_get_current_dir();
00291 
00292 // Returns the current directory depth. Desktop has depth 0.
00293 int filemodel_get_dir_depth();
00294 
00295 // returns first letter of first visible entry. -1 if no items
00296 // or if first item has no letter (e.g. no author)
00297 int filemodel_get_first_alpha_index();
00298 
00299 // returns an array of FILEMODEL_NUM_ALPHA long. The array indicates
00300 // whether entries are active or not. The returned list does not need
00301 // to be freed.
00302 #define ALPHA_HAS_DIR 0x01
00303 #define ALPHA_HAS_FILE 0x02
00304 #define FILEMODEL_NUM_ALPHA 27
00305 const gchar* filemodel_get_alpha_list();
00306 
00307 gboolean filemodel_show_alphabar();
00308 
00309 gboolean filemodel_has_searchbutton();
00310 
00311 // SELECTION stuff
00312 // toggled entry for deletion. Index is offset in visible window.
00313 void filemodel_toggle_entry(int index, int state, GtkTreeIter *iter);
00314 
00315 // delete all the toggled entries. Also resyncs with metadb
00316 void filemodel_delete_toggled();
00317 
00318 // return the number of toggled entries
00319 int filemodel_num_toggled();
00320 
00321 // set the text that will be shown on first item in Delete mode
00322 void filemodel_set_delete_text(const gchar* text);
00323 
00324 #if MACHINE_IS_DR800S || MACHINE_IS_DR800SG || MACHINE_IS_DR800SW
00325 void filemodel_update_last_read(const filelist_entry_t *fileinfo);
00326 #endif
00327 
00328 // FILELIST_ENTRY methods
00329 filelist_entry_t* iter_to_entry(GtkTreeModel *model, GtkTreeIter *iter);
00330 
00331 filelist_entry_t* filelist_entry_new();
00332 
00333 void filelist_entry_free(filelist_entry_t *thiz);
00334 
00335 filelist_entry_t* filelist_entry_copy(const filelist_entry_t *src);
00336 
00337 gboolean filemodel_window_is_on_top();
00338 
00339 void filemodel_set_window_is_on_top(gboolean is_on_top );
00340 
00341 #if (TIMING_ON)
00342 void start_duration_timer();
00343 void stop_duration_timer();
00344 #endif
00345 
00346 G_END_DECLS
00347 
00348 #endif
00349 
Generated by  doxygen 1.6.2-20100208