1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-04 23:37:33 +02:00
fped/gui_tools.c
werner 0015f96f14 - renamed gui_icons to gui_tools
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5383 99fdad57-331a-0410-800a-d7fa5415bdb3
2009-08-04 07:24:13 +00:00

88 lines
2.2 KiB
C

/*
* gui_tools.c - GUI, tool bar
*
* Written 2009 by Werner Almesberger
* Copyright 2009 by Werner Almesberger
*
* 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.
*/
#include <gtk/gtk.h>
#include "gui_util.h"
#include "gui_tools.h"
#include "icons/arc.xpm"
#include "icons/circ.xpm"
#include "icons/frame.xpm"
#include "icons/line.xpm"
#include "icons/meas.xpm"
#include "icons/pad.xpm"
#include "icons/point.xpm"
#include "icons/rect.xpm"
#include "icons/vec.xpm"
static GtkToolItem *tool_button(GtkWidget *bar, GdkDrawable *drawable,
char **xpm, GtkToolItem *last)
{
GdkPixmap *pixmap;
GtkWidget *image;
GtkToolItem *item;
pixmap = gdk_pixmap_create_from_xpm_d(drawable, NULL, NULL, xpm);
image = gtk_image_new_from_pixmap(pixmap, NULL);
/*
* gtk_radio_tool_button_new_from_widget is *huge*. we try to do things in a
* more compact way.
*/
#if 0
if (last)
item = gtk_radio_tool_button_new_from_widget(
GTK_RADIO_TOOL_BUTTON(last));
else
item = gtk_radio_tool_button_new(NULL);
gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), image);
#else
item = gtk_tool_item_new();
gtk_container_add(GTK_CONTAINER(item), image);
gtk_container_set_border_width(GTK_CONTAINER(item), 1);
#endif
gtk_toolbar_insert(GTK_TOOLBAR(bar), item, -1);
return item;
}
GtkWidget *gui_setup_tools(GdkDrawable *drawable)
{
GtkWidget *bar;
GtkToolItem *last;
bar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS);
gtk_toolbar_set_orientation(GTK_TOOLBAR(bar),
GTK_ORIENTATION_VERTICAL);
//gtk_container_set_border_width(GTK_CONTAINER(bar), 5);
last = tool_button(bar, drawable, xpm_point, NULL);
last = tool_button(bar, drawable, xpm_vec, last);
last = tool_button(bar, drawable, xpm_frame, last);
last = tool_button(bar, drawable, xpm_pad, last);
last = tool_button(bar, drawable, xpm_line, last);
last = tool_button(bar, drawable, xpm_rect, last);
last = tool_button(bar, drawable, xpm_circ, last);
last = tool_button(bar, drawable, xpm_arc, last);
last = tool_button(bar, drawable, xpm_meas, last);
return bar;
}