Merge branch 'gh37-update-icon-on-rename'

Fixes: #37
This commit is contained in:
Mike Gelfand 2017-02-22 00:00:07 +03:00
commit d5d9b61212
5 changed files with 31 additions and 1 deletions

View File

@ -801,7 +801,17 @@ on_rename_done_idle (struct rename_data * data)
GtkTreeIter iter; GtkTreeIter iter;
if (gtk_tree_model_get_iter_from_string (data->file_data->model, &iter, data->path_string)) if (gtk_tree_model_get_iter_from_string (data->file_data->model, &iter, data->path_string))
gtk_tree_store_set (data->file_data->store, &iter, FC_LABEL, data->newname, -1); {
const gboolean isLeaf = !gtk_tree_model_iter_has_child (data->file_data->model, &iter);
const char * mime_type = isLeaf ? gtr_get_mime_type_from_filename (data->newname) : DIRECTORY_MIME_TYPE;
GdkPixbuf * icon = gtr_get_mime_type_icon (mime_type, GTK_ICON_SIZE_MENU, data->file_data->view);
gtk_tree_store_set (data->file_data->store, &iter, FC_LABEL, data->newname, FC_ICON, icon, -1);
GtkTreeIter parent;
if (!gtk_tree_model_iter_parent (data->file_data->model, &parent, &iter))
gtr_core_torrent_changed (data->file_data->core, data->file_data->torrentId);
}
} }
else else
{ {

View File

@ -1354,6 +1354,19 @@ gtr_core_torrents_added (TrCore * self)
core_emit_err (self, TR_CORE_ERR_NO_MORE_TORRENTS, NULL); core_emit_err (self, TR_CORE_ERR_NO_MORE_TORRENTS, NULL);
} }
void
gtr_core_torrent_changed (TrCore * self, int id)
{
GtkTreeIter iter;
GtkTreeModel * model = core_raw_model (self);
if (find_row_from_torrent_id (model, id, &iter))
{
GtkTreePath * path = gtk_tree_model_get_path (model, &iter);
gtk_tree_model_row_changed (model, path, &iter);
}
}
void void
gtr_core_remove_torrent (TrCore * core, int id, gboolean delete_local_data) gtr_core_remove_torrent (TrCore * core, int id, gboolean delete_local_data)
{ {

View File

@ -125,6 +125,8 @@ void gtr_core_add_torrent (TrCore*, tr_torrent*, gboolean do_notify);
*/ */
void gtr_core_torrents_added (TrCore * self); void gtr_core_torrents_added (TrCore * self);
void gtr_core_torrent_changed (TrCore * self, int id);
/****** /******
******* *******
******/ ******/

View File

@ -131,6 +131,8 @@
{ {
[fName release]; [fName release];
fName = [newName copy]; fName = [newName copy];
[fIcon release];
fIcon = nil;
return YES; return YES;
} }
} }

View File

@ -1968,6 +1968,9 @@ bool trashDataFile(const char * filename, tr_error ** error)
[fFlatFileList release]; [fFlatFileList release];
[self sortFileList: flatFileList]; [self sortFileList: flatFileList];
fFlatFileList = flatFileList; fFlatFileList = flatFileList;
[fIcon release];
fIcon = nil;
} }
else else
NSLog(@"Error renaming %@ to %@", oldPath, [path stringByAppendingPathComponent: newName]); NSLog(@"Error renaming %@ to %@", oldPath, [path stringByAppendingPathComponent: newName]);