Commit dcc9ff97 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

desktop: resort icons when file changes

parent 005db8c3
......@@ -679,6 +679,14 @@ create_icon_info (GfIconView *self,
return gf_icon_info_new (icon);
}
static void
icon_changed_cb (GfIcon *icon,
GfIconView *self)
{
if (self->placement == GF_PLACEMENT_AUTO_ARRANGE_ICONS)
resort_icons (self, FALSE);
}
static void
query_info_cb (GObject *object,
GAsyncResult *res,
......@@ -710,6 +718,8 @@ query_info_cb (GObject *object,
icon = gf_icon_new (self, file, file_info);
g_object_unref (file_info);
g_signal_connect (icon, "changed", G_CALLBACK (icon_changed_cb), self);
icon_info = create_icon_info (self, icon);
self->icons = g_list_prepend (self->icons, icon_info);
......@@ -1681,6 +1691,8 @@ next_files_cb (GObject *object,
icon = gf_icon_new (self, file, info);
g_object_unref (file);
g_signal_connect (icon, "changed", G_CALLBACK (icon_changed_cb), self);
icon_info = create_icon_info (self, icon);
self->icons = g_list_prepend (self->icons, icon_info);
}
......
......@@ -85,6 +85,8 @@ enum
{
SELECTED,
CHANGED,
LAST_SIGNAL
};
......@@ -840,21 +842,33 @@ update_icon (GfIcon *self)
gtk_image_set_pixel_size (GTK_IMAGE (priv->image), priv->icon_size);
}
static void
static gboolean
update_text (GfIcon *self)
{
GfIconPrivate *priv;
const char *name;
char *old_name;
priv = gf_icon_get_instance_private (self);
name = GF_ICON_GET_CLASS (self)->get_text (self);
old_name = priv->name;
priv->name = g_strdup (name);
gtk_label_set_text (GTK_LABEL (priv->label), name);
g_clear_pointer (&priv->name_collated, g_free);
priv->name_collated = g_utf8_collate_key_for_filename (name, -1);
if (g_strcmp0 (old_name, name) != 0)
{
g_free (old_name);
return TRUE;
}
g_free (old_name);
return FALSE;
}
static void
......@@ -929,7 +943,7 @@ load_thumbnail (GfIcon *self)
g_free (uri);
}
static void
static gboolean
icon_refresh (GfIcon *self)
{
GfIconPrivate *priv;
......@@ -953,7 +967,8 @@ icon_refresh (GfIcon *self)
}
update_icon (self);
update_text (self);
return update_text (self);
}
static void
......@@ -985,6 +1000,8 @@ query_info_cb (GObject *object,
priv->info = file_info;
icon_refresh (self);
g_signal_emit (self, icon_signals[CHANGED], 0);
}
static void
......@@ -1024,7 +1041,8 @@ file_changed_cb (GFileMonitor *monitor,
break;
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
icon_refresh (self);
if (icon_refresh (self))
g_signal_emit (self, icon_signals[CHANGED], 0);
break;
case G_FILE_MONITOR_EVENT_DELETED:
......@@ -1376,6 +1394,10 @@ install_signals (void)
icon_signals[SELECTED] =
g_signal_new ("selected", GF_TYPE_ICON, G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
icon_signals[CHANGED] =
g_signal_new ("changed", GF_TYPE_ICON, G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment