Exemplo n.º 1
0
static void update_vol(FmPlacesModel* model, FmPlaceItem* item, GtkTreeIter* it, FmFileInfoJob* job)
{
    FmIcon* icon;
    GIcon* gicon;
    char* name;
    GdkPixbuf* pix;
    GMount* mount;
    FmPath* path;

    name = g_volume_get_name(item->vol);
    if(item->fi->icon)
        fm_icon_unref(item->fi->icon);
    gicon = g_volume_get_icon(item->vol);
    icon = fm_icon_from_gicon(gicon);
    item->fi->icon = icon;
    g_object_unref(gicon);

    mount = g_volume_get_mount(item->vol);
    if(mount)
    {
        GFile* gf = g_mount_get_root(mount);
        path = fm_path_new_for_gfile(gf);
        g_object_unref(gf);
        g_object_unref(mount);
        item->vol_mounted = TRUE;
    }
    else
    {
        path = NULL;
        item->vol_mounted = FALSE;
    }

    if(!fm_path_equal(item->fi->path, path))
    {
        fm_file_info_set_path(item->fi, path);
        if(path)
        {
            if(job)
                fm_file_info_job_add(job, path);
            else
            {
                job = fm_file_info_job_new(NULL, FM_FILE_INFO_JOB_FOLLOW_SYMLINK);
                model->jobs = g_slist_prepend(model->jobs, job);
                g_signal_connect(job, "finished", G_CALLBACK(on_file_info_job_finished), model);
                fm_job_run_async(FM_JOB(job));
            }
            fm_path_unref(path);
        }
    }

    pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
    gtk_list_store_set(GTK_LIST_STORE(model), it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, name, -1);
    g_object_unref(pix);
    g_free(name);
}
Exemplo n.º 2
0
static void update_vol(PlaceItem* item, GtkTreeIter* it)
{
    FmIcon* icon;
    GIcon* gicon;
    char* name;
    GdkPixbuf* pix;

    name = g_volume_get_name(item->vol);
    if(item->icon)
        fm_icon_unref(item->icon);
    gicon = g_volume_get_icon(item->vol);
    icon = fm_icon_from_gicon(gicon);
    item->icon = icon;
    g_object_unref(gicon);

    pix = fm_icon_get_pixbuf(item->icon, fm_config->pane_icon_size);
    gtk_list_store_set(model, it, COL_ICON, pix, COL_LABEL, name, -1);
    g_object_unref(pix);
    g_free(name);
}
Exemplo n.º 3
0
/**
 * fm_icon_from_name
 * @name: a name for icon
 *
 * Retrives a #FmIcon corresponding to @name from cache inserting new
 * one if there was no such icon there yet.
 *
 * Returns: (transfer full): a #FmIcon object.
 *
 * Since: 0.1.0
 */
FmIcon* fm_icon_from_name(const char* name)
{
    if(G_LIKELY(name))
    {
        FmIcon* icon;
        GIcon* gicon;
        gchar *dot;
        if(g_path_is_absolute(name))
        {
            GFile* gicon_file = g_file_new_for_path(name);
            gicon = g_file_icon_new(gicon_file);
            g_object_unref(gicon_file);
        }
        else if(G_UNLIKELY((dot = strrchr(name, '.')) != NULL && dot > name &&
                (g_ascii_strcasecmp(&dot[1], "png") == 0
                 || g_ascii_strcasecmp(&dot[1], "svg") == 0
                 || g_ascii_strcasecmp(&dot[1], "xpm") == 0)))
        {
            /* some desktop entries have invalid icon name which contains
               suffix so let strip the suffix from such invalid name */
            dot = g_strndup(name, dot - name);
            gicon = g_themed_icon_new_with_default_fallbacks(dot);
            g_free(dot);
        }
        else
            gicon = g_themed_icon_new_with_default_fallbacks(name);

        if(G_LIKELY(gicon))
        {
            icon = fm_icon_from_gicon(gicon);
            g_object_unref(gicon);
            return icon;
        }
    }
    return NULL;
}
Exemplo n.º 4
0
/**
 * fm_icon_from_name
 * @name: a name for icon
 *
 * Retrives a #FmIcon corresponding to @name from cache inserting new
 * one if there was no such icon there yet.
 *
 * Returns: (transfer full): a #FmIcon object.
 *
 * Since: 0.1.0
 */
FmIcon* fm_icon_from_name(const char* name)
{
    if(G_LIKELY(name))
    {
        FmIcon* icon;
        GIcon* gicon;
        if(g_path_is_absolute(name))
        {
            GFile* gicon_file = g_file_new_for_path(name);
            gicon = g_file_icon_new(gicon_file);
            g_object_unref(gicon_file);
        }
        else
            gicon = g_themed_icon_new_with_default_fallbacks(name);

        if(G_LIKELY(gicon))
        {
            icon = fm_icon_from_gicon(gicon);
            g_object_unref(gicon);
            return icon;
        }
    }
    return NULL;
}