Esempio n. 1
0
static char *icon_path(char *to, const char *icon) {
    if (STR_IS_EMPTY(icon)) {
        to[0] = 0;
        return to;
    }
    GtkIconInfo* info = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(),
            icon, GTK_ICON_SIZE_SMALL_TOOLBAR, 0);
    if (info != NULL) {
        const char *path = gtk_icon_info_get_filename(info);
        strcpy(to, path);
        gtk_icon_info_free(info);
    } else {
        strcpy(to, icon);
    }
    return to;
}
Esempio n. 2
0
static GtkWidget *get_image(const char *icon_name) {
    if (STR_IS_EMPTY(icon_name))
        icon_name = "applications-other";

    GtkWidget *image = NULL;

    if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), icon_name)) {
        GdkPixbuf *pixbuf = get_pixbuf_from_icon(icon_name);
        if (!pixbuf && *icon_name != '/') {
            char buf[1024] = { 0 };
            snprintf(buf, 1024, "/usr/share/pixmaps/%s", icon_name);
            pixbuf = get_pixbuf_from_icon(buf);
        }
        if (pixbuf) {
            image = gtk_image_new_from_pixbuf(pixbuf);
        }
    }

    if (!image) {
        image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
    }

    return image;
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
    if(argc <= 1)
    {
        return usage();
    }
    
    /* printf setup and main code setup */
    printf("extern printf\n"\
           "segment .data\n"\
           "\toutputfmt:\tdb \"= %%d\", 10, 0\n\n"\
           "segment .text\n"\
           "\tglobal main\n"
           "main:\n");
    
    int len = strlen(argv[1]);
    int i;
    for(i=0; i<len; i++)
    {
        char c = argv[1][i];
        if(IS_NUMERIC(c))
        {
            printf("\tpush\tdword %c\n", c);
        }
        else
        {
            char op[4];
            switch(c)
            {
            case '+':
                strcpy(op, "add");
                break;
            case '-':
                strcpy(op, "sub");
                break;
            case '*':
                strcpy(op, "mul");
                break;
            case '/':
                strcpy(op, "div");
                break;
            default:
                op[0] = '\0';
                break;
            }
            
            if(!STR_IS_EMPTY(op))
            {
                /* `pop` expression operand 1 to eax and operand 2 to ebx. */
                printf("\tpop\tebx\n"\
                       "\tpop\teax\n"\
                       "\t%s\teax, ebx\n"\
                       "\tpush\teax\n", op);
            }
        }
    }
    
    printf("\tpush\tdword outputfmt\n"\
           "\tcall\tprintf\n");
#ifdef __GNUC__
    printf("\tmov\teax, 1\n"\
	       "\tmov\tebx, 0\n"\
           "\tint\t80h\n");
#elif defined(_WIN32)
    printf("\tmov\teax, 0xf\n"\
           "\tmov\tedx, 0\n"\
           "\tint\t21h\n");
#endif
    
    return 0;
}