1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 00:04:06 +00:00

Update file icon when its name changes in details dialog (GTK+ client)

Additionally, make main window redraw the torrent so that new name and icon
are visible right away.
This commit is contained in:
Mike Gelfand 2017-02-21 23:18:52 +03:00
parent a26b4ec7bf
commit ecd1eb7914
3 changed files with 26 additions and 1 deletions

View file

@ -801,7 +801,17 @@ on_rename_done_idle (struct rename_data * data)
GtkTreeIter iter;
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
{

View file

@ -1354,6 +1354,19 @@ gtr_core_torrents_added (TrCore * self)
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
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_torrent_changed (TrCore * self, int id);
/******
*******
******/