filemodel.h File Reference

#include <gtk/gtk.h>
#include <libermetadb/ermetadb.h>
Include dependency graph for filemodel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  filelist_entry_t

Defines

#define SPECIAL_ITEM_NAME   "special"
#define SPECIAL_BOOKS   "books"
#define SPECIAL_IMAGES   "images"
#define SPECIAL_NEWS   "news"
#define SPECIAL_HELP   "help"
#define SPECIAL_PERSONAL   "personal"
#define SPECIAL_DIR   "dir"
#define SPECIAL_SHORTCUTS   "shortcuts"
#define SPECIAL_NOTES   "notes"
#define SPECIAL_SETTINGS   "settings"
#define SPECIAL_SEARCH   "search"
#define SPECIAL_RECENT   "recent"
#define SPECIAL_UPDIR   ".."
#define DIR_DESKTOP_TEMPLATE   SYSCONFDIR "/desktop"
#define DIR_DESKTOP_INTERNAL   "/var/tmp/"
#define DIR_STORAGE_MNT   "/media"
#define DIR_LIBRARY   DIR_STORAGE_MNT "/mmcblk0p1"
#define FILEMODEL_COLUMN_TYPES
#define ALPHA_HAS_DIR   0x01
#define ALPHA_HAS_FILE   0x02
#define FILEMODEL_NUM_ALPHA   27

Enumerations

enum  filemodel_column_t {
  MODCOL_FILENAME = 0, MODCOL_TITLE, MODCOL_FILETYPE, MODCOL_FILETYPE_DISPLAY,
  MODCOL_DIRECTORY_PATH, MODCOL_IS_DIRECTORY, MODCOL_FILESIZE, MODCOL_FILEDATE,
  MODCOL_SUBTITLE, MODCOL_THUMBNAIL, MODCOL_TOGGLED, N_FILEMODEL_COLUMNS
}
enum  filemodel_thumbsize_t {
  MODTHUMB_MINI = 0, MODTHUMB_SMALL, MODTHUMB_MEDIUM, MODTHUMB_LARGE,
  N_FILEMODEL_THUMB_SIZES
}
enum  ctb_viewmodes_t { BROWSE_MODE = 0, DELETE_MODE }
enum  ctb_sort_order_t {
  CTB_SORT_BY_NAME = 0, CTB_SORT_BY_TYPE, CTB_SORT_BY_SIZE, CTB_SORT_BY_DATE_ADDED,
  CTB_SORT_BY_DATE_READ, CTB_SORT_BY_AUTHOR, N_CTB_SORT_ORDER
}
enum  ViewMode {
  DESKTOP_VIEW = 0, SETTINGS_VIEW, BOOKS_VIEW, NEWS_VIEW,
  IMAGES_VIEW, PERSONAL_VIEW, DIR_VIEW, SHORTCUT_VIEW,
  NOTES_VIEW, HELP_VIEW, RECENT_VIEW, SEARCH_VIEW
}

Functions

void filemodel_init ()
void filemodel_quit ()
GtkTreeModel * get_filemodel ()
 Get a pointer to the file model.
erMetadb filemodel_get_database ()
 Get the currently open metadata database.
gboolean filemodel_set_sortorder (ctb_sort_order_t sort_order, const gchar *cursor_item, gboolean updateScreen)
void filemodel_set_viewmode2 (ViewMode newmode)
void filemodel_set_search_filter (const gchar *search_string)
const gchar * filemodel_get_title ()
const gchar * filemodel_get_subtitle ()
const gchar * filemodel_get_menu_content ()
gboolean filemodel_set_viewsize (const int n_items, gboolean updateScreen)
 Set number of items in view, same number must be loaded in model.
void filemodel_set_viewmode (ctb_viewmodes_t newmode, gboolean updateScreen)
void filemodel_set_thumbsize (const filemodel_thumbsize_t thumb_size, gboolean reload)
 Set thumbnail to be loaded in model.
gboolean filemodel_has_prev_page ()
gboolean filemodel_has_next_page ()
void filemodel_page_previous ()
void filemodel_page_next ()
void filemodel_update_pagecounter ()
int filemodel_scroll_to_letter (gchar letter, gboolean jump_to_dir, gboolean *same_page)
void filemodel_scroll_to_filename (const gchar *filename)
int filemodel_get_display_index (const gchar *filename)
int filemodel_chdir_desktop ()
int filemodel_chdir_down (const gchar *dir, const gchar *last_item)
gchar * filemodel_chdir_up ()
gboolean filemodel_resync (gboolean force_reload)
gboolean filemodel_current_is_desktop ()
const gchar * filemodel_get_current_dir ()
int filemodel_get_dir_depth ()
int filemodel_get_first_alpha_index ()
const gchar * filemodel_get_alpha_list ()
gboolean filemodel_show_alphabar ()
gboolean filemodel_has_searchbutton ()
void filemodel_toggle_entry (int index, int state, GtkTreeIter *iter)
void filemodel_delete_toggled ()
int filemodel_num_toggled ()
void filemodel_set_delete_text (const gchar *text)
filelist_entry_titer_to_entry (GtkTreeModel *model, GtkTreeIter *iter)
filelist_entry_tfilelist_entry_new ()
void filelist_entry_free (filelist_entry_t *thiz)
filelist_entry_tfilelist_entry_copy (const filelist_entry_t *src)
gboolean filemodel_window_is_on_top ()
void filemodel_set_window_is_on_top (gboolean is_on_top)

Define Documentation

#define ALPHA_HAS_DIR   0x01

Definition at line 302 of file filemodel.h.

Referenced by filemodel_scroll_to_letter(), and update_alpha_list().

#define ALPHA_HAS_FILE   0x02

Definition at line 303 of file filemodel.h.

Referenced by filemodel_scroll_to_letter(), and update_alpha_list().

#define DIR_DESKTOP_INTERNAL   "/var/tmp/"
#define DIR_DESKTOP_TEMPLATE   SYSCONFDIR "/desktop"

Definition at line 59 of file filemodel.h.

#define DIR_LIBRARY   DIR_STORAGE_MNT "/mmcblk0p1"
#define DIR_STORAGE_MNT   "/media"

Definition at line 61 of file filemodel.h.

Referenced by get_thumbnail_for_shortcut().

#define FILEMODEL_COLUMN_TYPES
Value:
G_TYPE_STRING,      /* MODCOL_FILENAME         */  \
            G_TYPE_STRING,      /* MODCOL_TITLE */  \
            G_TYPE_STRING,      /* MODCOL_FILETYPE         */  \
            G_TYPE_STRING,      /* MODCOL_FILETYPE_DISPLAY */  \
            G_TYPE_STRING,      /* MODCOL_DIRECTORY_PATH   */  \
            G_TYPE_BOOLEAN,     /* MODCOL_IS_DIRECTORY     */  \
            G_TYPE_STRING,      /* MODCOL_FILESIZE         */  \
            G_TYPE_STRING,      /* MODCOL_FILEDATE         */  \
            G_TYPE_STRING,      /* MODCOL_SUBTITLE           */  \
            GDK_TYPE_PIXBUF,    /* MODCOL_THUMBNAIL        */  \
            G_TYPE_INT,         /* MODCOL_TOGGLED          */  \
            NULL

Definition at line 81 of file filemodel.h.

Referenced by get_filemodel().

#define FILEMODEL_NUM_ALPHA   27
#define SPECIAL_BOOKS   "books"

Definition at line 45 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_DIR   "dir"

Definition at line 50 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_HELP   "help"

Definition at line 48 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_IMAGES   "images"

Definition at line 46 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_ITEM_NAME   "special"

File Name : filemodel.h

Description: Content browser data for file model Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 44 of file filemodel.h.

Referenced by activate_item(), add_desktop_item(), add_previous_dir(), and shortcut_allowed().

#define SPECIAL_NEWS   "news"

Definition at line 47 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_NOTES   "notes"

Definition at line 52 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_PERSONAL   "personal"

Definition at line 49 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_RECENT   "recent"

Definition at line 55 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_SEARCH   "search"

Definition at line 54 of file filemodel.h.

Referenced by add_desktop_items(), fileview_show_search_dialog(), and handle_special_item().

#define SPECIAL_SETTINGS   "settings"

Definition at line 53 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_SHORTCUTS   "shortcuts"

Definition at line 51 of file filemodel.h.

Referenced by add_desktop_items(), and handle_special_item().

#define SPECIAL_UPDIR   ".."

Definition at line 56 of file filemodel.h.

Referenced by handle_special_item().


Enumeration Type Documentation

Enumerator:
CTB_SORT_BY_NAME 
CTB_SORT_BY_TYPE 
CTB_SORT_BY_SIZE 
CTB_SORT_BY_DATE_ADDED 
CTB_SORT_BY_DATE_READ 
CTB_SORT_BY_AUTHOR 
N_CTB_SORT_ORDER 

Definition at line 122 of file filemodel.h.

Enumerator:
BROWSE_MODE 
DELETE_MODE 

Definition at line 115 of file filemodel.h.

00116         {
00117             BROWSE_MODE = 0,
00118             DELETE_MODE,
00119         } ctb_viewmodes_t;

Enumerator:
MODCOL_FILENAME 
MODCOL_TITLE 
MODCOL_FILETYPE 
MODCOL_FILETYPE_DISPLAY 
MODCOL_DIRECTORY_PATH 
MODCOL_IS_DIRECTORY 
MODCOL_FILESIZE 
MODCOL_FILEDATE 
MODCOL_SUBTITLE 
MODCOL_THUMBNAIL 
MODCOL_TOGGLED 
N_FILEMODEL_COLUMNS 

Definition at line 65 of file filemodel.h.

Enumerator:
MODTHUMB_MINI 
MODTHUMB_SMALL 
MODTHUMB_MEDIUM 
MODTHUMB_LARGE 
N_FILEMODEL_THUMB_SIZES 

Definition at line 96 of file filemodel.h.

enum ViewMode
Enumerator:
DESKTOP_VIEW 
SETTINGS_VIEW 
BOOKS_VIEW 
NEWS_VIEW 
IMAGES_VIEW 
PERSONAL_VIEW 
DIR_VIEW 
SHORTCUT_VIEW 
NOTES_VIEW 
HELP_VIEW 
RECENT_VIEW 
SEARCH_VIEW 

Definition at line 133 of file filemodel.h.

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;


Function Documentation

filelist_entry_t* filelist_entry_copy ( const filelist_entry_t src  ) 

Definition at line 2135 of file filemodel.c.

References filelist_entry_t::directory_path, filelist_entry_new(), filelist_entry_t::filename, filelist_entry_t::filename_display, filelist_entry_t::filetype, and filelist_entry_t::is_directory.

02136 {
02137 
02138     g_assert(src);
02139     g_assert(src->filename         && src->filename->str);
02140     g_assert(src->filename_display && src->filename_display->str);
02141     g_assert(src->filetype         && src->filetype->str);
02142     g_assert(src->directory_path   && src->directory_path->str);
02143 
02144     filelist_entry_t *thiz = filelist_entry_new();
02145     thiz->filename = g_string_new(src->filename->str);
02146     thiz->directory_path = g_string_new(src->directory_path->str);
02147     thiz->filename_display = g_string_new(src->filename_display->str);
02148     thiz->filetype = g_string_new(src->filetype->str);
02149     thiz->is_directory = src->is_directory;
02150 
02151     return thiz;
02152 }

Here is the call graph for this function:

void filelist_entry_free ( filelist_entry_t thiz  ) 

Definition at line 2122 of file filemodel.c.

References filelist_entry_t::directory_path, filelist_entry_t::filename, filelist_entry_t::filename_display, and filelist_entry_t::filetype.

Referenced by activate_shortcut(), clear_last_read(), delete_entry_at_offset(), fileview_create_shortcut(), get_filename_at_cursor(), and handle_activate_item().

02123 {
02124     if (thiz)
02125     {
02126         if (thiz->filename) g_string_free(thiz->filename, TRUE);
02127         if (thiz->filename_display) g_string_free(thiz->filename_display, TRUE);
02128         if (thiz->filetype) g_string_free(thiz->filetype, TRUE);
02129         if (thiz->directory_path) g_string_free(thiz->directory_path, TRUE);
02130         g_free(thiz);
02131     }
02132 }

Here is the caller graph for this function:

filelist_entry_t* filelist_entry_new (  ) 

Definition at line 2112 of file filemodel.c.

References filelist_entry_t::is_directory.

Referenced by activate_shortcut(), delete_entry_at_offset(), filelist_entry_copy(), and iter_to_entry().

02113 {
02114     filelist_entry_t *thiz = g_new0(filelist_entry_t, 1);
02115     g_assert(thiz);
02116     thiz->is_directory = FALSE;
02117 
02118     return thiz;
02119 }

Here is the caller graph for this function:

int filemodel_chdir_desktop (  ) 

Definition at line 950 of file filemodel.c.

References clear_dir_stack(), DESKTOP_VIEW, DIR_DESKTOP_INTERNAL, filemodel_chdir(), filemodel_set_viewmode2(), and g_desktop_offset.

Referenced by fileview_media_unmounted(), fileview_show_desktop(), and fileview_show_search_dialog().

00951 {
00952     clear_dir_stack();
00953     g_desktop_offset = 0;
00954     filemodel_set_viewmode2(DESKTOP_VIEW);
00955     return filemodel_chdir(DIR_DESKTOP_INTERNAL, NULL);
00956 }

Here is the call graph for this function:

Here is the caller graph for this function:

int filemodel_chdir_down ( const gchar *  dir,
const gchar *  last_item 
)

Definition at line 989 of file filemodel.c.

References create_stack_entry(), filemodel_chdir(), g_current_dir, g_dir_stack, and LOGPRINTF.

Referenced by fileview_dir_down().

00990 {
00991     LOGPRINTF("dir=%s  last_item=%s", dir, last_item);
00992     g_dir_stack = g_list_append(g_dir_stack, create_stack_entry(g_current_dir, last_item));
00993 
00994     filemodel_chdir(dir, NULL);
00995     return 0;
00996 }

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* filemodel_chdir_up (  ) 

Definition at line 999 of file filemodel.c.

References DESKTOP_VIEW, DIR_DESKTOP_INTERNAL, filemodel_chdir(), filemodel_set_viewmode2(), free_stack_entry(), g_dir_stack, stack_entry_t::last_item, LOGPRINTF, and stack_entry_t::parent_dir.

Referenced by fileview_dir_up().

01000 {
01001     LOGPRINTF("");
01002     g_assert(g_dir_stack);
01003     GList* last = g_list_last(g_dir_stack);
01004     stack_entry_t *entry = (stack_entry_t*)last->data;
01005     g_dir_stack = g_list_delete_link(g_dir_stack, last);
01006 
01007     if (g_dir_stack)
01008     {
01009         // still can go up more
01010         filemodel_chdir(entry->parent_dir, entry->last_item);
01011     }
01012     else
01013     {
01014         // on desktop
01015         filemodel_set_viewmode2(DESKTOP_VIEW);
01016         filemodel_chdir(DIR_DESKTOP_INTERNAL, NULL);
01017     }
01018     gchar* last_item = g_strdup(entry->last_item);
01019     free_stack_entry(entry);
01020 
01021     return last_item;
01022 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean filemodel_current_is_desktop (  ) 
void filemodel_delete_toggled (  ) 

Definition at line 1240 of file filemodel.c.

References clear_toggled_list(), compare_toggled_entries(), delete_entry_at_offset(), filemodel_resync(), and toggled_list.

Referenced by handle_delete_activated().

01241 {
01242     if (toggled_list) { // if none toggled do nothing
01243         toggled_list = g_slist_sort(toggled_list, compare_toggled_entries);
01244         GSList *iter = toggled_list;
01245         while (iter) {
01246             int item_offset = (int)iter->data;
01247             delete_entry_at_offset(item_offset);
01248             iter = g_slist_next(iter);
01249         }
01250         clear_toggled_list();
01251         filemodel_resync(FALSE);
01252     }
01253 }

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* filemodel_get_alpha_list (  ) 

Definition at line 1142 of file filemodel.c.

References g_alpha_list.

Referenced by alphabar_select(), alphabar_update(), find_nearest_active(), and on_letter_click().

01143 {
01144     return g_alpha_list;
01145 }

Here is the caller graph for this function:

const gchar* filemodel_get_current_dir (  ) 

Definition at line 1101 of file filemodel.c.

References g_current_dir.

Referenced by get_entry_at_cursor().

01102 {
01103     return g_current_dir;
01104 }

Here is the caller graph for this function:

erMetadb filemodel_get_database (  ) 

Get the currently open metadata database.

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

Name : filemodel_get_database

Parameters:
none 
Returns:
Currently open metadata database, or NULL if no database open

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

Definition at line 188 of file filemodel.c.

References get_database().

Referenced by create_shortcut_item(), and delete_item().

00189 {
00190     return get_database();
00191 }

Here is the call graph for this function:

Here is the caller graph for this function:

int filemodel_get_dir_depth (  ) 

Definition at line 1107 of file filemodel.c.

References g_dir_stack.

Referenced by fileview_dir_up().

01108 {
01109     int depth = 0;
01110     if (g_dir_stack != NULL)
01111     {
01112         depth = g_list_length(g_dir_stack);
01113     }
01114     return depth;
01115 }

Here is the caller graph for this function:

int filemodel_get_display_index ( const gchar *  filename  ) 

Definition at line 874 of file filemodel.c.

References metadata_table::cell_data, desktop_names, filemodel_current_is_desktop(), g_item_offset, g_total_items, METADATA_TEXT, metadata_table::n_columns, num_items_per_page(), num_specials_per_page(), metadata_cell::type, metadata_cell::v_text, and metadata_cell::value.

Referenced by set_cursor_at_filename().

00875 {
00876     if (!filename || !*filename) return 0;
00877 
00878     // special for desktop
00879     if (filemodel_current_is_desktop()) {
00880         int index = 0;
00881         GSList *iter = desktop_names;
00882         while (iter) {
00883             if (strcmp(filename, (const char*)iter->data) == 0) return index;
00884             index++;
00885             iter = g_slist_next(iter);
00886         }
00887     }
00888     else if (g_values)
00889     {
00890         int num_per_page = num_items_per_page();
00891         int columns = g_values->n_columns;
00892         const metadata_cell *cell = (const metadata_cell*) (g_values->cell_data->data);
00893         // skip g_item_offset rows
00894         cell += (g_item_offset * g_values->n_columns);
00895         // search within currently visible window
00896         int row;
00897         for (row=g_item_offset; row < (g_item_offset + num_per_page) && row < g_total_items ; row++)
00898         {
00899             g_assert(cell->type == METADATA_TEXT);
00900             if (strcmp( filename, cell->value.v_text->str) == 0) {
00901                 int item_idx = row - g_item_offset;
00902                 item_idx += num_specials_per_page();
00903                 return item_idx;
00904                 break;
00905             }
00906             cell += columns;
00907         }
00908     }
00909 
00910     return 0;
00911 }

Here is the call graph for this function:

Here is the caller graph for this function:

int filemodel_get_first_alpha_index (  ) 

Definition at line 854 of file filemodel.c.

References alpha2index(), metadata_table::cell_data, g_item_offset, g_total_items, get_sorted_name(), metadata_table::n_columns, and name.

Referenced by fileview_dir_up(), fileview_page_next(), fileview_page_previous(), fileview_refresh(), on_idle_set_cursor_at_filename(), and update_view_size().

00855 {
00856     if (g_total_items == 0) return -1;
00857     g_assert(g_values);
00858 
00859     const metadata_cell *cell = (const metadata_cell*) (g_values->cell_data->data);
00860     cell += (g_item_offset * g_values->n_columns);
00861     const gchar* name = get_sorted_name(cell);
00862     if (name == NULL) return -1;
00863     return alpha2index(name[0]);
00864 }

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* filemodel_get_menu_content (  ) 

Definition at line 623 of file filemodel.c.

References DELETE_MODE, filemodel_current_is_media(), g_viewmode, g_viewmode2, MENU_CONTENT, MENU_CONTENT_DELETE_MODE, MENU_CONTENT_MEDIA, MENU_CONTENT_RECENT_MODE, and RECENT_VIEW.

Referenced by menu_set_current_is_media(), menu_show(), and menu_update_view_mode().

00624 {
00625     if (g_viewmode == DELETE_MODE) return MENU_CONTENT_DELETE_MODE;
00626 
00627     if (g_viewmode2 == RECENT_VIEW) return MENU_CONTENT_RECENT_MODE;
00628 
00629     if (filemodel_current_is_media()) return MENU_CONTENT_MEDIA;
00630 
00631     return MENU_CONTENT;
00632 }

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* filemodel_get_subtitle (  ) 

Definition at line 598 of file filemodel.c.

References g_subtitle, and g_viewmode2.

Referenced by fileview_set_sort_order(), and update_titles().

00599 {
00600     if (g_viewmodes[g_viewmode2].fixed_order) return "";
00601     else return g_subtitle;
00602 }

Here is the caller graph for this function:

const gchar* filemodel_get_title (  ) 

Definition at line 592 of file filemodel.c.

References g_viewmode2.

Referenced by update_titles().

00593 {
00594     return _(g_viewmodes[g_viewmode2].title);
00595 }

Here is the caller graph for this function:

gboolean filemodel_has_next_page (  ) 

Definition at line 702 of file filemodel.c.

References g_has_next_page.

Referenced by on_iconview_navigate_cursor(), and on_listview_navigate_cursor().

00703 {
00704     return g_has_next_page;
00705 }

Here is the caller graph for this function:

gboolean filemodel_has_prev_page (  ) 

Definition at line 695 of file filemodel.c.

References filemodel_current_is_desktop(), g_desktop_offset, and g_item_offset.

Referenced by on_iconview_navigate_cursor(), and on_listview_navigate_cursor().

00696 {
00697     if (filemodel_current_is_desktop()) return (g_desktop_offset > 0);
00698     else return (g_item_offset > 0);
00699 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean filemodel_has_searchbutton (  ) 

Definition at line 561 of file filemodel.c.

References DESKTOP_VIEW, g_viewmode2, and SETTINGS_VIEW.

Referenced by update_gui().

00562 {
00563     if (g_viewmode2 == DESKTOP_VIEW || g_viewmode2 == SETTINGS_VIEW) return FALSE;
00564     return TRUE;
00565 }

Here is the caller graph for this function:

void filemodel_init (  ) 

Definition at line 180 of file filemodel.c.

References DESKTOP_VIEW, filemodel_set_viewmode2(), filetypes_init(), and get_filemodel().

Referenced by fileview_init().

00181 {
00182     filetypes_init(TRUE);
00183     get_filemodel();
00184     filemodel_set_viewmode2(DESKTOP_VIEW);
00185 }

Here is the call graph for this function:

Here is the caller graph for this function:

int filemodel_num_toggled (  ) 

Definition at line 1256 of file filemodel.c.

References toggled_list.

Referenced by handle_delete_activated().

01257 {
01258     int count = 0;
01259     GSList *iter = toggled_list;
01260     while (iter) {
01261         count++;
01262         iter = g_slist_next(iter);
01263     }
01264     return count;
01265 }

Here is the caller graph for this function:

void filemodel_page_next (  ) 

Definition at line 726 of file filemodel.c.

References filemodel_current_is_desktop(), g_desktop_items, g_desktop_offset, g_has_next_page, g_item_offset, g_items_per_page, g_total_items, load_items_in_model(), LOGPRINTF, and num_items_per_page().

Referenced by fileview_page_next().

00727 {
00728     if (g_has_next_page)
00729     {
00730         LOGPRINTF("entry: old offset [%d] page size [%d]", g_item_offset, g_items_per_page);
00731         if (filemodel_current_is_desktop()) {
00732             g_desktop_offset += g_items_per_page;
00733             g_assert(g_desktop_offset < g_desktop_items);
00734         } else {
00735             g_item_offset += num_items_per_page();
00736             g_assert(g_item_offset < g_total_items);
00737         }
00738         load_items_in_model();
00739     }
00740 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_page_previous (  ) 

Definition at line 708 of file filemodel.c.

References filemodel_current_is_desktop(), g_desktop_offset, g_item_offset, g_items_per_page, load_items_in_model(), and num_items_per_page().

Referenced by fileview_page_previous().

00709 {
00710     if (filemodel_current_is_desktop()) {
00711         if (g_desktop_offset > 0) {
00712             g_desktop_offset -= g_items_per_page;
00713             if (g_desktop_offset < 0) g_desktop_offset = 0;
00714             load_items_in_model();
00715         }
00716     } else {
00717         if (g_item_offset > 0) {
00718             g_item_offset -= num_items_per_page();
00719             if (g_item_offset < 0) g_item_offset = 0;
00720             load_items_in_model();
00721         }
00722     }
00723 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_quit (  ) 

Definition at line 205 of file filemodel.c.

References clear_last_read(), clear_toggled_list(), close_database(), and metadata_table_free.

Referenced by main().

00206 {
00207     close_database();
00208     if (g_values) metadata_table_free(g_values);
00209     g_values = NULL;
00210     clear_last_read();
00211     clear_toggled_list();
00212 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean filemodel_resync ( gboolean  force_reload  ) 

Definition at line 1025 of file filemodel.c.

References filemodel_current_is_desktop(), g_desktop_items, g_desktop_offset, g_item_offset, g_items_per_page, g_total_items, is_database_changed(), load_dir_from_metadb(), and num_items_per_page().

Referenced by filemodel_delete_toggled(), and fileview_refresh().

01026 {
01027     if (!force_reload && !is_database_changed()) return FALSE;
01028 
01029     if (filemodel_current_is_desktop()) {
01030         if (g_desktop_items <= g_items_per_page) g_desktop_offset = 0;
01031     }
01032     int old_offset = g_item_offset;
01033     load_dir_from_metadb();
01034 
01035     // set new offset as close to old one as possible
01036     g_item_offset = old_offset;
01037     int num_per_page = num_items_per_page();
01038     while (g_item_offset >= g_total_items) {
01039         g_item_offset -= num_per_page;
01040     }
01041     if (g_item_offset < 0) g_item_offset = 0;
01042     return TRUE;
01043 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_scroll_to_filename ( const gchar *  filename  ) 

Definition at line 867 of file filemodel.c.

References load_items_in_model(), and scroll_to_filename().

Referenced by fileview_refresh(), and on_idle_set_cursor_at_filename().

00868 {
00869     scroll_to_filename(filename);
00870     load_items_in_model();
00871 }

Here is the call graph for this function:

Here is the caller graph for this function:

int filemodel_scroll_to_letter ( gchar  letter,
gboolean  jump_to_dir,
gboolean *  same_page 
)

Definition at line 803 of file filemodel.c.

References alpha2index(), ALPHA_HAS_DIR, ALPHA_HAS_FILE, metadata_table::cell_data, g_alpha_list, g_item_offset, g_total_items, get_row_is_directory(), get_sorted_name(), load_items_in_model(), metadata_table::n_columns, name, num_items_per_page(), and num_specials_per_page().

Referenced by scroll_to_letter().

00804 {
00805     g_assert(g_values);
00806     gint item_idx  = 0;
00807     gboolean found = FALSE;
00808 
00809     gboolean first_ok = TRUE;
00810     int index = alpha2index(letter);
00811     if (g_alpha_list[index] == (ALPHA_HAS_DIR|ALPHA_HAS_FILE)) first_ok = FALSE;
00812 
00813     int row;
00814     const metadata_cell *cell = (const metadata_cell*) (g_values->cell_data->data);
00815     for (row = 0; row < g_total_items; row++) {
00816         const gchar* name = get_sorted_name(cell);
00817         if (name) {
00818             char current = name[0];
00819             if (current == letter || current == tolower(letter) ||  // normal char (a-z)
00820                 (letter == '#' && !isalpha(current))) {             // special char (0-9,!,?, etc)
00821                 // check whether it's the preferred type
00822                 if (first_ok || jump_to_dir == get_row_is_directory(cell)) {
00823                     item_idx = row;
00824                     found = TRUE;
00825                     break;
00826                 }
00827             }
00828         }
00829         cell += g_values->n_columns;
00830     }
00831 
00832     int num_per_page = num_items_per_page();
00833     if (item_idx >= g_item_offset && item_idx < (g_item_offset + num_per_page)) {
00834         *same_page = TRUE;
00835     } else {
00836         *same_page = FALSE;
00837     }
00838 
00839     int page = item_idx / num_per_page;
00840     g_item_offset = page * num_per_page;
00841     
00842     if (found) {
00843         item_idx = item_idx % num_per_page;
00844         item_idx += num_specials_per_page();
00845     } else {
00846         // shouldn't really happen!
00847         item_idx = -1;
00848     }
00849     if (!*same_page) load_items_in_model();
00850     return item_idx;
00851 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_set_delete_text ( const gchar *  text  ) 

Definition at line 1268 of file filemodel.c.

References DELETE_MODE, g_delete_text, g_filestore, g_viewmode, and MODCOL_TITLE.

Referenced by fileview_update_screen_texts(), handle_delete_activated(), and reset_delete_state().

01269 {
01270     if (g_delete_text != NULL && strcmp(g_delete_text, text) == 0) return;
01271     g_free(g_delete_text);
01272     g_delete_text = g_strdup(text);
01273     if (g_viewmode == DELETE_MODE) {
01274         GtkTreeIter first;
01275         GtkTreeModel *model = GTK_TREE_MODEL(g_filestore);
01276         gboolean valid = gtk_tree_model_get_iter_first(model, &first);
01277         if (valid) {
01278             gtk_list_store_set (GTK_LIST_STORE(model), &first,
01279                                 MODCOL_TITLE, g_delete_text, -1);
01280         }
01281     }
01282 }

Here is the caller graph for this function:

void filemodel_set_search_filter ( const gchar *  search_string  ) 

Definition at line 583 of file filemodel.c.

References g_search_filter.

Referenced by fileview_show_search_dialog().

00584 {
00585     g_free(g_search_filter);
00586     g_search_filter = NULL;
00587     if (search_string == NULL || strcmp(search_string, "") == 0) return;
00588     g_search_filter = g_strdup(search_string);
00589 }

Here is the caller graph for this function:

gboolean filemodel_set_sortorder ( ctb_sort_order_t  sort_order,
const gchar *  cursor_item,
gboolean  updateScreen 
)

Definition at line 530 of file filemodel.c.

References g_sort_order, g_viewmode2, load_dir_from_metadb(), load_items_in_model(), ViewModeInfo::order, scroll_to_filename(), and set_sortorder().

Referenced by fileview_set_sort_order().

00533 {
00534     if (g_sort_order == sort_order) return FALSE;
00535 
00536     g_assert(!g_viewmodes[g_viewmode2].fixed_order);
00537     g_viewmodes[g_viewmode2].order = sort_order;
00538     set_sortorder(sort_order);
00539 
00540     if (updateScreen) {
00541         load_dir_from_metadb();
00542         if (g_values) scroll_to_filename(cursor_item);
00543         load_items_in_model();
00544     }
00545     return TRUE;
00546 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_set_thumbsize ( const filemodel_thumbsize_t  thumb_size,
gboolean  reload 
)

Set thumbnail to be loaded in model.

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

Name : filemodel_set_thumbsize

Parameters:
[in] thumb_size - thumbnail size to be loaded in model
[in] reload - whether to reload data from metadb. If more calls follow that also cause a reload, use false here.
Returns:
--

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

Definition at line 671 of file filemodel.c.

References g_filestore, g_thumbnail_size, load_dir_from_metadb(), and LOGPRINTF.

Referenced by fileview_set_view_type().

00672 {
00673     LOGPRINTF("thumb_size [%d]", thumb_size);
00674 
00675     if (thumb_size == g_thumbnail_size) return;
00676 
00677     g_thumbnail_size = thumb_size;
00678     if (reload) load_dir_from_metadb();
00679     // NOTE: 'fixes' wrong height in contentview
00680     gtk_list_store_clear(g_filestore);
00681 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_set_viewmode ( ctb_viewmodes_t  newmode,
gboolean  updateScreen 
)

Definition at line 658 of file filemodel.c.

References clear_toggled_list(), g_boundary_check, g_curpage, g_numpages, g_viewmode, ipc_menu_set_pagecounter(), load_items_in_model(), LOGPRINTF, and menu_update_view_mode().

Referenced by setViewMode().

00659 {
00660     LOGPRINTF("mode: %d->%d  update=%d", g_viewmode, newmode, updateScreen);
00661     g_viewmode = newmode;
00662     clear_toggled_list();
00663     if (updateScreen) {
00664         load_items_in_model();
00665     }
00666     menu_update_view_mode(g_viewmode);
00667     ipc_menu_set_pagecounter(g_curpage, g_numpages, g_boundary_check);
00668 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_set_viewmode2 ( ViewMode  newmode  ) 

Definition at line 568 of file filemodel.c.

References DESKTOP_VIEW, g_viewmode2, LOGPRINTF, menu_set_category(), set_sortorder(), and ViewModeInfo::title.

Referenced by filemodel_chdir_desktop(), filemodel_chdir_up(), filemodel_init(), fileview_show_search_dialog(), and set_special_viewmode().

00569 {
00570     LOGPRINTF("viewmode %d -> %d", g_viewmode2, newmode);
00571     if (g_viewmode2 != newmode) {
00572         g_viewmode2 = newmode;
00573         set_sortorder(g_viewmodes[newmode].order);
00574         const char* category = NULL;
00575         if (newmode != DESKTOP_VIEW) {
00576             category = g_viewmodes[newmode].title;
00577         }
00578         menu_set_category(category);
00579     }
00580 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean filemodel_set_viewsize ( const int  n_items,
gboolean  updateScreen 
)

Set number of items in view, same number must be loaded in model.

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

Name : filemodel_set_viewsize

Parameters:
[in] n_items - number of items to be loaded in model (> 0) [in] updateScreen - whether to load data in gui model
Returns:
--

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

Definition at line 635 of file filemodel.c.

References g_desktop_offset, g_item_offset, g_items_per_page, load_items_in_model(), and LOGPRINTF.

Referenced by update_view_size().

00636 {
00637     LOGPRINTF("items=%d->%d  updateScreen=%d", g_items_per_page, n_items, updateScreen);
00638     g_return_val_if_fail(n_items > 0  && n_items < 100, FALSE);
00639     if (n_items == g_items_per_page) return FALSE;
00640 
00641     g_items_per_page = n_items;
00642 
00643     // round g_desktop_offset down to new pagination
00644     int desktop_page = g_desktop_offset / g_items_per_page;
00645     g_desktop_offset = desktop_page * g_items_per_page;
00646 
00647     // round g_item_offset down to new pagination
00648     int page = g_item_offset / g_items_per_page;
00649     g_item_offset = page * g_items_per_page;
00650 
00651     if (updateScreen) {
00652         load_items_in_model();
00653     }
00654     return TRUE;
00655 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_set_window_is_on_top ( gboolean  is_on_top  ) 

Definition at line 1095 of file filemodel.c.

References g_window_is_on_top.

Referenced by fileview_set_on_top().

01096 {
01097     g_window_is_on_top = is_on_top;
01098 }

Here is the caller graph for this function:

gboolean filemodel_show_alphabar (  ) 

Definition at line 549 of file filemodel.c.

References CTB_SORT_BY_AUTHOR, CTB_SORT_BY_NAME, DESKTOP_VIEW, g_sort_order, g_viewmode2, and SETTINGS_VIEW.

Referenced by alphabar_update().

00549                                    {
00550     // depends on viewmode
00551     if (g_viewmode2 == DESKTOP_VIEW || g_viewmode2 == SETTINGS_VIEW) return FALSE;
00552 
00553     // otherwise depend on sortorder
00554     if (g_sort_order == CTB_SORT_BY_NAME || g_sort_order == CTB_SORT_BY_AUTHOR) {
00555         return TRUE;
00556     }
00557     return FALSE;
00558 }

Here is the caller graph for this function:

void filemodel_toggle_entry ( int  index,
int  state,
GtkTreeIter *  iter 
)

Definition at line 1178 of file filemodel.c.

References metadata_table::cell_data, create_delete_overlay(), DELETE_MODE, g_filestore, g_item_offset, g_thumbnail_size, g_viewmode, get_thumbnail(), MODCOL_THUMBNAIL, MODCOL_TOGGLED, MODTHUMB_MEDIUM, metadata_table::n_columns, num_specials_per_page(), and toggled_list.

Referenced by handle_delete_activated().

01179 {
01180     index -= num_specials_per_page();
01181     int item_index = g_item_offset + index;
01182     
01183     if (state == 0) {
01184         toggled_list = g_slist_remove(toggled_list, (int*)item_index);
01185     } else {
01186         toggled_list = g_slist_prepend(toggled_list, (int*)item_index);
01187     }
01188 
01189     GtkTreeModel *model = GTK_TREE_MODEL(g_filestore);
01190 
01191     // add overlay for delete mode in iconView
01192     if (g_viewmode == DELETE_MODE && g_thumbnail_size == MODTHUMB_MEDIUM)
01193     {
01194         const metadata_cell *cell = (const metadata_cell*) (g_values->cell_data->data);
01195         cell += (item_index * g_values->n_columns);
01196         GdkPixbuf *thumbnail = get_thumbnail(cell);
01197         GdkPixbuf *thumbnail_delete = create_delete_overlay(thumbnail, state);
01198 
01199         gtk_list_store_set (GTK_LIST_STORE(model), iter, MODCOL_THUMBNAIL, thumbnail_delete, -1);
01200         g_object_unref(thumbnail);
01201         g_object_unref(thumbnail_delete);
01202     }
01203     gtk_list_store_set (GTK_LIST_STORE(model), iter, MODCOL_TOGGLED, state, -1);
01204 }

Here is the call graph for this function:

Here is the caller graph for this function:

void filemodel_update_pagecounter (  ) 

Definition at line 743 of file filemodel.c.

References g_boundary_check, g_curpage, g_numpages, and ipc_menu_set_pagecounter().

Referenced by menu_show().

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean filemodel_window_is_on_top (  ) 

Definition at line 1089 of file filemodel.c.

References g_window_is_on_top.

Referenced by fileview_refresh(), menu_show(), on_iconview_size_allocate(), on_listview_size_allocate(), update_category(), and update_numpages().

01090 {
01091     return g_window_is_on_top;
01092 }

Here is the caller graph for this function:

GtkTreeModel* get_filemodel (  ) 

Get a pointer to the file model.

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

Name : get_filemodel

Parameters:
none 
Returns:
GtkTreeModel interface on the filestore object

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

Definition at line 215 of file filemodel.c.

References FILEMODEL_COLUMN_TYPES, g_filestore, and N_FILEMODEL_COLUMNS.

Referenced by create_contentview(), create_iconview(), create_listview(), filemodel_init(), get_entry_at_cursor(), and on_iconview_item_activated_delete().

00216 {
00217     if (g_filestore == NULL)
00218     {
00219         g_filestore = gtk_list_store_new(N_FILEMODEL_COLUMNS, FILEMODEL_COLUMN_TYPES);
00220     }
00221     return GTK_TREE_MODEL(g_filestore);
00222 }

Here is the caller graph for this function:

filelist_entry_t* iter_to_entry ( GtkTreeModel *  model,
GtkTreeIter *  iter 
)

Definition at line 2081 of file filemodel.c.

References filelist_entry_t::directory_path, filelist_entry_new(), filelist_entry_t::filename, filelist_entry_t::filename_display, filelist_entry_t::filetype, filelist_entry_t::is_directory, MODCOL_DIRECTORY_PATH, MODCOL_FILENAME, MODCOL_FILETYPE, MODCOL_IS_DIRECTORY, and MODCOL_TITLE.

Referenced by get_entry_at_cursor().

02082 {
02083     gchar    *filename         = NULL;
02084     gchar    *filename_display = NULL;
02085     gchar    *filetype         = NULL;
02086     gchar    *directory_path   = NULL;
02087     gboolean is_directory      = FALSE;
02088 
02089     gtk_tree_model_get( model, iter, MODCOL_FILENAME,         &filename,
02090                                      MODCOL_TITLE, &filename_display,
02091                                      MODCOL_FILETYPE,         &filetype,
02092                                      MODCOL_DIRECTORY_PATH,   &directory_path,
02093                                      MODCOL_IS_DIRECTORY,     &is_directory,
02094                                      -1 );
02095 
02096     filelist_entry_t *entry = filelist_entry_new();
02097     entry->filename         = g_string_new(filename);
02098     entry->filename_display = g_string_new(filename_display);
02099     entry->filetype         = g_string_new(filetype);
02100     entry->directory_path   = g_string_new(directory_path);
02101     entry->is_directory     = is_directory;
02102 
02103     g_free(filename);
02104     g_free(filename_display);
02105     g_free(filetype);
02106     g_free(directory_path);
02107 
02108     return entry;
02109 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208