Logo Search packages:      
Sourcecode: xarchiver version File versions  Download package

support.c

/*
 *  Copyright (c) 2006 Giuseppe Torelli <colossus73@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "support.h"

GtkWidget *xa_main_window_find_image(gchar *filename, GtkIconSize size)
{
      GError *error = NULL;
    GtkWidget *file_image;
      gchar *path;
      path = g_strconcat(DATADIR, "/xarchiver/pixmaps/", filename, NULL);
      GdkPixbuf *file_pixbuf = gdk_pixbuf_new_from_file(path, &error);
      if(!file_pixbuf)
      {
            /*
            * perhaps xarchiver has not been installed and is being executed from source dir
            */
            g_free(error);
            error = NULL;
            path = g_strconcat("./pixmaps/", filename, NULL);
            file_pixbuf = gdk_pixbuf_new_from_file(path, &error);
    }
    if(file_pixbuf)
    {
            file_image = gtk_image_new_from_pixbuf(file_pixbuf);
            g_object_unref(file_pixbuf);
    }
    else
      {
            g_free(error);
            file_image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, size);
    }
    g_free(path);
    return file_image;
}


Generated by  Doxygen 1.6.0   Back to index