58
56
gsize name_len, upath_len;
58
file = fopen( path, "r" );
61
while( fgets( line, sizeof(line), file ) )
63
/* Every line is an URI containing no space charactetrs
64
with its name appended (optional) */
65
uri = strtok( line, " \r\n" );
68
path = g_filename_from_uri(uri, NULL, NULL);
71
upath = g_filename_to_utf8(path, -1, NULL, &upath_len, NULL);
72
g_free( (gpointer) path );
75
name = strtok( NULL, "\r\n" );
78
name_len = strlen( name );
83
name = basename = g_path_get_basename( upath );
84
name_len = strlen( basename );
86
item = ptk_bookmarks_item_new( name, name_len,
88
bookmarks.list = g_list_append( bookmarks.list,
99
static void on_bookmark_file_changed( VFSFileMonitor* fm,
100
VFSFileMonitorEvent event,
101
const char* file_name,
104
/* This callback is called from IO channel handler insode VFSFileMonotor. */
107
g_list_foreach( bookmarks.list, (GFunc)g_free, NULL );
108
g_list_free( bookmarks.list );
113
ptk_bookmarks_notify();
118
Get a self-maintained list of bookmarks
119
This is read from "~/.gtk-bookmarks".
121
PtkBookmarks* ptk_bookmarks_get ()
60
124
if( 0 == bookmarks.n_ref )
62
126
path = g_build_filename( g_get_home_dir(), bookmarks_file_name, NULL );
63
file = fopen( path, "r" );
127
monitor = vfs_file_monitor_add_file( path, on_bookmark_file_changed, NULL );
67
while( fgets( line, sizeof(line), file ) )
69
/* Every line is an URI containing no space charactetrs
70
with its name appended (optional) */
71
uri = strtok( line, " \r\n" );
74
path = g_filename_from_uri(uri, NULL, NULL);
77
upath = g_filename_to_utf8(path, -1, NULL, &upath_len, NULL);
81
name = strtok( NULL, "\r\n" );
84
name_len = strlen( name );
89
name = basename = g_path_get_basename( upath );
90
name_len = strlen( basename );
92
item = ptk_bookmarks_item_new( name, name_len,
94
bookmarks.list = g_list_append( bookmarks.list,
131
g_atomic_int_inc( &bookmarks.n_ref );
105
132
return &bookmarks;