Exemplo n.º 1
0
Arquivo: icons.c Projeto: g7/fbpanel
static int
read_dicon(icons_priv *ics, gchar *name)
{
    gchar *fname;
    GdkPixbuf *gp;
    int size;
    gulong *data;
    
    ENTER;
    fname = expand_tilda(name);
    if (!fname)
        RET(0);
    gp = gdk_pixbuf_new_from_file(fname, NULL);  
    if (gp)
    {
        if ((data = pixbuf2argb(gp, &size)))
        {
            ics->dicon = g_new0 (wmpix_t, 1);
            ics->dicon->data = data;
            ics->dicon->size = size;
        }
        g_object_unref(gp);
    }
    g_free(fname);    
    RET(1);
}
Exemplo n.º 2
0
Arquivo: icons.c Projeto: g7/fbpanel
static int
read_application(icons_priv *ics, xconf *xc)
{
    GdkPixbuf *gp = NULL;

    gchar *fname, *iname, *appname, *classname;
    wmpix_t *wp = NULL;
    gulong *data;
    int size;
    
    ENTER;
    iname = fname = appname = classname = NULL;
    XCG(xc, "image", &fname, str);
    XCG(xc, "icon", &iname, str);
    XCG(xc, "appname", &appname, str);
    XCG(xc, "classname", &classname, str);
    fname = expand_tilda(fname);

    DBG("appname=%s classname=%s\n", appname, classname);
    if (!(fname || iname))
        goto error;
    gp = fb_pixbuf_new(iname, fname, 48, 48, FALSE);  
    if (gp)
    {
        if ((data = pixbuf2argb(gp, &size)))
        {
            wp = g_new0 (wmpix_t, 1);
            wp->next = ics->wmpix;
            wp->data = data;
            wp->size = size;
            wp->ch.res_name = g_strdup(appname);
            wp->ch.res_class = g_strdup(classname);
            DBG("read name=[%s] class=[%s]\n",
                wp->ch.res_name, wp->ch.res_class);
            ics->wmpix = wp;
        }
        g_object_unref(gp);
    }
    g_free(fname);
    RET(1);
  
error:
    g_free(fname);
    RET(0);
}
Exemplo n.º 3
0
static int
read_application(plugin *p)
{
    icons *ics = (icons *)p->priv;
    GdkPixbuf *gp = NULL;
    line s;
    gchar *fname, *iname, *appname, *classname;
    wmpix_t *wp = NULL;
    gulong *data;
    int size;

    ENTER;
    s.len = 256;
    iname = fname = appname = classname = NULL;
    while (get_line(p->fp, &s) != LINE_BLOCK_END) {
        if (s.type == LINE_NONE) {
            ERR( "icons: illegal token %s\n", s.str);
            goto error;
        }
        if (s.type == LINE_VAR) {
            if (!g_ascii_strcasecmp(s.t[0], "image"))
                fname = expand_tilda(s.t[1]);
            else if (!g_ascii_strcasecmp(s.t[0], "icon"))
                iname = g_strdup(s.t[1]);
            else if (!g_ascii_strcasecmp(s.t[0], "appname"))
                appname = g_strdup(s.t[1]);
            else if (!g_ascii_strcasecmp(s.t[0], "classname"))
                classname = g_strdup(s.t[1]);
            else {
                ERR( "icons: unknown var %s\n", s.t[0]);
                goto error;
            }
        } else {
            ERR( "icons: illegal in this context %s\n", s.str);
            goto error;
        }
    }
    if (!(fname || iname))
        goto error;
    gp = fb_pixbuf_new_from_icon_file(iname, fname, 48, 48);
    if (gp) {
        if ((data = pixbuf2argb(gp, &size))) {
            wp = g_new0 (wmpix_t, 1);
            wp->next = ics->wmpix;
            wp->data = data;
            wp->size = size;
            wp->ch.res_name = appname;
            wp->ch.res_class = classname;
            ics->wmpix = wp;
            ics->wmpixno++;
        }
        g_object_unref(gp);
    }
    g_free(fname);
    RET(1);

error:
    g_free(fname);
    g_free(appname);
    g_free(classname);
    RET(0);
}