[monkey-bubble: 2/753] Initial revision



commit 18f645242be77f40effda081cda34838ba189172
Author: Elliot Lee <sopwith src gnome org>
Date:   Mon Nov 24 22:32:12 1997 +0000

    Initial revision

 libgnomeui/.cvsignore             |    6 +
 libgnomeui/Makefile.am            |   36 +++++
 libgnomeui/gnome-actionarea.c     |   51 ++++++
 libgnomeui/gnome-actionarea.h     |   35 ++++
 libgnomeui/gnome-color-selector.c |  310 +++++++++++++++++++++++++++++++++++++
 libgnomeui/gnome-color-selector.h |   53 +++++++
 libgnomeui/gnome-colors.c         |  133 ++++++++++++++++
 libgnomeui/gnome-colors.h         |   57 +++++++
 libgnomeui/gnome-messagebox.c     |  298 +++++++++++++++++++++++++++++++++++
 libgnomeui/gnome-messagebox.h     |   84 ++++++++++
 libgnomeui/gnome-pixmap.c         |  141 +++++++++++++++++
 libgnomeui/gnome-pixmap.h         |   16 ++
 libgnomeui/gnome-properties.c     |   76 +++++++++
 libgnomeui/gnome-properties.h     |   34 ++++
 libgnomeui/gnome-toolbar.c        |  157 +++++++++++++++++++
 libgnomeui/gnome-toolbar.h        |   92 +++++++++++
 libgnomeui/gnome-ui-init.c        |   90 +++++++++++
 libgnomeui/libgnomeui.h           |   19 +++
 18 files changed, 1688 insertions(+), 0 deletions(-)
---
diff --git a/libgnomeui/.cvsignore b/libgnomeui/.cvsignore
new file mode 100644
index 0000000..97239af
--- /dev/null
+++ b/libgnomeui/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.deps
+*.la
+*.lo
+_libs
diff --git a/libgnomeui/Makefile.am b/libgnomeui/Makefile.am
new file mode 100644
index 0000000..7f8f60c
--- /dev/null
+++ b/libgnomeui/Makefile.am
@@ -0,0 +1,36 @@
+## Process this file with automake to produce Makefile.in
+
+libgnomeuiincludedir = $(includedir)/libgnomeui
+
+INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir)
+
+lib_LTLIBRARIES = libgnomeui.la
+
+libgnomeui_la_SOURCES = \
+	gnome-color-selector.c 		\
+	gnome-properties.c		\
+	gnome-init.c			\
+	gnome-actionarea.c		\
+	gnome-messagebox.c		\
+	gnome-pixmap.c			\
+	gnome-toolbar.c			\
+	gnome-colors.c
+
+libgnomeuiinclude_HEADERS = 		\
+        gnome-actionarea.h     		\
+	gnome-color-selector.h 		\
+	gnome-colors.h         		\
+	gnome-messagebox.h		\
+	gnome-properties.h     		\
+	gnome-pixmap.h			\
+	gnome-toolbar.h			\
+	libgnomeui.h
+
+
+libgnomeui_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir)
+libgnomeui_la_LIBADD = $(GTK_LIBS)
+
+files:
+        @files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
+          echo $$p; \
+        done
diff --git a/libgnomeui/gnome-actionarea.c b/libgnomeui/gnome-actionarea.c
new file mode 100644
index 0000000..07eb78d
--- /dev/null
+++ b/libgnomeui/gnome-actionarea.c
@@ -0,0 +1,51 @@
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <config.h>
+#include <gtk/gtk.h>
+#include "libgnome/gnome-defs.h"
+#include "gnome-actionarea.h"
+
+void
+gnome_build_action_area (GtkDialog *      dlg,
+			 GnomeActionAreaItem * actions,
+			 int              num_actions,
+			 int              default_action)
+{
+  GtkWidget *button;
+  int i;
+
+  gtk_container_border_width (GTK_CONTAINER (dlg->action_area), 2);
+
+  for (i = 0; i < num_actions; i++)
+    {
+      button = gtk_button_new_with_label (actions[i].label);
+      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+      gtk_box_pack_start (GTK_BOX (dlg->action_area), button, TRUE, TRUE, 0);
+
+      if (actions[i].callback)
+	gtk_signal_connect (GTK_OBJECT (button), "clicked",
+			    (GtkSignalFunc) actions[i].callback,
+			    actions[i].user_data);
+
+      if (default_action == i)
+	gtk_widget_grab_default (button);
+      gtk_widget_show (button);
+
+      actions[i].widget = button;
+    }
+}
diff --git a/libgnomeui/gnome-actionarea.h b/libgnomeui/gnome-actionarea.h
new file mode 100644
index 0000000..9734cb6
--- /dev/null
+++ b/libgnomeui/gnome-actionarea.h
@@ -0,0 +1,35 @@
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef GNOME_ACTIONAREA_H
+#define GNOME_ACTIONAREA_H
+
+typedef void (*GnomeActionCallback) (GtkWidget *, gpointer);
+
+typedef struct {
+  char *label;
+  GnomeActionCallback callback;
+  gpointer user_data;
+  GtkWidget *widget;
+} GnomeActionAreaItem;
+
+void gnome_build_action_area (GtkDialog           * dlg,
+			      GnomeActionAreaItem * actions,
+			      int                 num_actions,
+			      int                 default_action);
+
+#endif
diff --git a/libgnomeui/gnome-color-selector.c b/libgnomeui/gnome-color-selector.c
new file mode 100644
index 0000000..227e6fb
--- /dev/null
+++ b/libgnomeui/gnome-color-selector.c
@@ -0,0 +1,310 @@
+/* GNOME color selector in a button.
+ * Written by Federico Mena <federico nuclecu unam mx>
+ */
+
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include "libgnome/gnome-defs.h"
+#include "gnome-color-selector.h"
+
+#define PREVIEW_WIDTH  36
+#define PREVIEW_HEIGHT 16
+
+
+static void
+gnome_color_selector_fill_buffer(guchar *buf, int width, double r, double g, double b)
+{
+	int     ir, ig, ib;
+	guchar *p;
+
+	g_assert(buf != NULL);
+
+	ir = (int) (r * 255 + 0.5);
+	ig = (int) (g * 255 + 0.5);
+	ib = (int) (b * 255 + 0.5);
+
+	p = buf;
+
+	for (; width; width--) {
+		*p++ = ir;
+		*p++ = ig;
+		*p++ = ib;
+	} /* for */
+} /* gnome_color_selector_fill_buffer */
+
+
+static void
+gnome_color_selector_render_preview(GtkPreview *preview,
+				    guchar     *buf,
+				    int         width,
+				    int         height)
+{
+	int y;
+
+	g_assert(preview != NULL);
+	g_assert(buf != NULL);
+
+	for (y = 0; y < height; y++)
+		gtk_preview_draw_row(preview, buf, 0, y, width);
+
+	gtk_widget_draw(GTK_WIDGET(preview), NULL);
+} /* gnome_color_selector_render_preview */
+
+static void
+gnome_color_selector_set_cs_color(GnomeColorSelector *gcs)
+{
+	double                   color[4];
+	GtkColorSelection       *cs;
+	GtkColorSelectionDialog *csd;
+	
+	g_assert(gcs != NULL);
+
+	if (gcs->cs_dialog) {
+		color[0] = gcs->r;
+		color[1] = gcs->g;
+		color[2] = gcs->b;
+		color[3] = 1.0; /* Always opaque */
+		
+		csd = GTK_COLOR_SELECTION_DIALOG(gcs->cs_dialog);
+		cs  = GTK_COLOR_SELECTION(csd->colorsel);
+		
+		gtk_color_selection_set_color(cs, color);
+	} /* if */
+} /* gnome_color_selector_set_cs_color */
+
+
+static void
+gnome_color_selector_ok_clicked(GtkWidget *widget,
+				gpointer   data)
+{
+	GnomeColorSelector *gcs;
+
+	gcs = data;
+
+	gtk_widget_hide(gcs->cs_dialog);
+
+	if (gcs->set_color_func)
+		(*gcs->set_color_func) (gcs, gcs->set_color_data);
+} /* gnome_color_selector_ok_clicked */
+
+
+static void
+gnome_color_selector_cancel_clicked(GtkWidget *widget,
+				    gpointer   data)
+{
+	GnomeColorSelector *gcs;
+
+	gcs = data;
+
+	gtk_widget_hide(gcs->cs_dialog);
+
+	gnome_color_selector_set_color(gcs, gcs->tr, gcs->tg, gcs->tb);
+} /* gnome_color_selector_cancel_clicked */
+
+
+static void
+gnome_color_selector_color_changed(GtkWidget *widget,
+				   gpointer   data)
+{
+	GnomeColorSelector *gcs;
+	GtkColorSelection  *cs;
+	double              color[4];
+
+	gcs = data;
+	cs  = GTK_COLOR_SELECTION(widget);
+
+	gtk_color_selection_get_color(cs, color);
+
+	gcs->r = color[0];
+	gcs->g = color[1];
+	gcs->b = color[2];
+
+	gnome_color_selector_fill_buffer(gcs->buf, PREVIEW_WIDTH, gcs->r, gcs->g, gcs->b);
+	gnome_color_selector_render_preview(GTK_PREVIEW(gcs->preview), gcs->buf, PREVIEW_WIDTH, PREVIEW_HEIGHT);
+} /* gnome_color_selector_color_changed */
+
+
+static void
+gnome_color_selector_button_clicked(GtkWidget *widget,
+				    gpointer   data)
+{
+	GnomeColorSelector      *gcs;
+	GtkColorSelectionDialog *csd;
+	GtkColorSelection       *cs;
+
+	gcs = data;
+
+	if (!gcs->cs_dialog) {
+		gcs->cs_dialog = gtk_color_selection_dialog_new("Pick a color");
+
+		csd = GTK_COLOR_SELECTION_DIALOG(gcs->cs_dialog);
+		cs  = GTK_COLOR_SELECTION(csd->colorsel);
+
+		gtk_color_selection_set_opacity(cs, FALSE);
+
+		gtk_signal_connect(GTK_OBJECT(cs), "color_changed",
+				   (GtkSignalFunc) gnome_color_selector_color_changed,
+				   gcs);
+
+		gtk_signal_connect(GTK_OBJECT(csd->ok_button), "clicked",
+				   (GtkSignalFunc) gnome_color_selector_ok_clicked,
+				   gcs);
+
+		gtk_signal_connect(GTK_OBJECT(csd->cancel_button), "clicked",
+				   (GtkSignalFunc) gnome_color_selector_cancel_clicked,
+				   gcs);
+
+		gtk_window_position(GTK_WINDOW(csd), GTK_WIN_POS_MOUSE);
+	} /* if */
+
+	if (!GTK_WIDGET_VISIBLE(gcs->cs_dialog)) {
+		gnome_color_selector_get_color(gcs, &gcs->tr, &gcs->tg, &gcs->tb);  /* Save for cancel */
+
+		/* FIXME: this is a hack; we set the color twice so
+                 * that the color selector remembers it as its `old'
+                 * color, too */
+		
+		gnome_color_selector_set_cs_color(gcs);
+		gnome_color_selector_set_cs_color(gcs);
+
+		gtk_widget_show(gcs->cs_dialog);
+	} /* if */
+} /* gnome_color_selector_button_clicked */
+
+
+GnomeColorSelector *
+gnome_color_selector_new(SetColorFunc set_color_func,
+			 gpointer     set_color_data)
+{
+	GnomeColorSelector *gcs;
+	GtkWidget          *alignment;
+	GtkWidget          *frame;
+
+	gcs = g_malloc(sizeof(GnomeColorSelector));
+
+	gcs->cs_dialog = NULL;
+
+	gcs->buf = g_malloc(PREVIEW_WIDTH * 3 * sizeof(guchar));
+
+	gcs->set_color_func = set_color_func;
+	gcs->set_color_data = set_color_data;
+	
+	gcs->button = gtk_button_new();
+	gtk_signal_connect(GTK_OBJECT(gcs->button), "clicked",
+			   (GtkSignalFunc) gnome_color_selector_button_clicked,
+			   gcs);
+
+	alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+	gtk_container_border_width(GTK_CONTAINER(alignment), 1);
+	gtk_container_add(GTK_CONTAINER(gcs->button), alignment);
+	gtk_widget_show(alignment);
+
+	frame = gtk_frame_new(NULL);
+	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+	gtk_container_add(GTK_CONTAINER(alignment), frame);
+	gtk_widget_show(frame);
+	
+	gcs->preview = gtk_preview_new(GTK_PREVIEW_COLOR);
+	gtk_preview_size(GTK_PREVIEW(gcs->preview), PREVIEW_WIDTH, PREVIEW_HEIGHT);
+	gtk_container_add(GTK_CONTAINER(frame), gcs->preview);
+	gtk_widget_show(gcs->preview);
+
+	gnome_color_selector_set_color(gcs, 0.0, 0.0, 0.0);
+
+	return gcs;
+} /* gnome_color_selector_new */
+
+
+void
+gnome_color_selector_destroy(GnomeColorSelector *gcs)
+{
+	g_assert(gcs != NULL);
+
+	if (gcs->buf)
+		g_free(gcs->buf);
+
+	if (gcs->cs_dialog)
+		gtk_widget_destroy(gcs->cs_dialog);
+
+	g_free(gcs);
+} /* gnome_color_selector_destroy */
+
+
+GtkWidget *
+gnome_color_selector_get_button(GnomeColorSelector *gcs)
+{
+	g_assert(gcs != NULL);
+
+	return gcs->button;
+} /* gnome_color_selector_get_button */
+
+
+void
+gnome_color_selector_set_color(GnomeColorSelector *gcs,
+			       double              r,
+			       double              g,
+			       double              b)
+{
+	g_assert(gcs != NULL);
+
+	gcs->r = CLAMP(r, 0.0, 1.0);
+	gcs->g = CLAMP(g, 0.0, 1.0);
+	gcs->b = CLAMP(b, 0.0, 1.0);
+
+	gnome_color_selector_fill_buffer(gcs->buf, PREVIEW_WIDTH, gcs->r, gcs->g, gcs->b);
+	gnome_color_selector_render_preview(GTK_PREVIEW(gcs->preview), gcs->buf, PREVIEW_WIDTH, PREVIEW_HEIGHT);
+
+	gnome_color_selector_set_cs_color(gcs);
+} /* gnome_color_selector_set_color */
+
+
+void
+gnome_color_selector_set_color_int(GnomeColorSelector *gcs,
+				   int                 r,
+				   int                 g,
+				   int                 b,
+				   int                 scale)
+{
+	g_assert(gcs != NULL);
+
+	gnome_color_selector_set_color(gcs,
+				       (double) r / scale,
+				       (double) g / scale,
+				       (double) b / scale);
+} /* gnome_color_selector_set_color_int */
+
+
+void
+gnome_color_selector_get_color(GnomeColorSelector *gcs,
+			       double             *r,
+			       double             *g,
+			       double             *b)
+{
+	g_assert(gcs != NULL);
+	g_assert(r != NULL);
+	g_assert(g != NULL);
+	g_assert(b != NULL);
+
+	*r = gcs->r;
+	*g = gcs->g;
+	*b = gcs->b;
+} /* gnome_color_selector_get_color */
+
+
+void
+gnome_color_selector_get_color_int(GnomeColorSelector *gcs,
+				   int                *r,
+				   int                *g,
+				   int                *b,
+				   int                 scale)
+{
+	g_assert(gcs != NULL);
+	g_assert(r != NULL);
+	g_assert(g != NULL);
+	g_assert(b != NULL);
+
+	*r = (int) (gcs->r * scale + 0.5);
+	*g = (int) (gcs->g * scale + 0.5);
+	*b = (int) (gcs->b * scale + 0.5);
+} /* gnome_color_selector_get_color_int */
diff --git a/libgnomeui/gnome-color-selector.h b/libgnomeui/gnome-color-selector.h
new file mode 100644
index 0000000..055b558
--- /dev/null
+++ b/libgnomeui/gnome-color-selector.h
@@ -0,0 +1,53 @@
+/* GNOME color selector in a button.
+ * Written by Federico Mena <federico nuclecu unam mx>
+ */
+
+
+#ifndef GNOME_COLOR_SELECTOR_H
+#define GNOME_COLOR_SELECTOR_H
+
+BEGIN_GNOME_DECLS
+
+typedef struct _GnomeColorSelector GnomeColorSelector;
+
+typedef void (* SetColorFunc) (GnomeColorSelector *gcs, gpointer data);
+
+struct _GnomeColorSelector {
+	double         r, g, b;
+	double         tr, tg, tb;
+	guchar        *buf;
+	SetColorFunc   set_color_func;
+	gpointer       set_color_data;
+	GtkWidget     *cs_dialog;
+	GtkWidget     *preview;
+	GtkWidget     *button;
+};
+
+
+GnomeColorSelector* gnome_color_selector_new           (SetColorFunc        set_color_func,
+					              	gpointer            set_color_data);
+void                gnome_color_selector_destroy       (GnomeColorSelector *gcs);
+GtkWidget*          gnome_color_selector_get_button    (GnomeColorSelector *gcs);
+void                gnome_color_selector_set_color     (GnomeColorSelector *gcs,
+						      	double              r,
+						      	double              g,
+						      	double              b);
+void                gnome_color_selector_set_color_int (GnomeColorSelector *gcs,
+						      	int                 r,
+						      	int                 g,
+						      	int                 b,
+							int                 scale);
+void                gnome_color_selector_get_color     (GnomeColorSelector *gcs,
+						      	double             *r,
+						      	double             *g,
+						      	double             *b);
+void                gnome_color_selector_get_color_int (GnomeColorSelector *gcs,
+							int                *r,
+							int                *g,
+							int                *b,
+							int                 scale);
+
+
+END_GNOME_DECLS
+
+#endif 
diff --git a/libgnomeui/gnome-colors.c b/libgnomeui/gnome-colors.c
new file mode 100644
index 0000000..cdb03a4
--- /dev/null
+++ b/libgnomeui/gnome-colors.c
@@ -0,0 +1,133 @@
+#include <gtk/gtk.h>
+#include "libgnome/gnome-defs.h"
+#include "gnome-colors.h"
+
+
+GdkVisual   *gnome_visual = NULL;
+GdkColormap *gnome_colormap = NULL;
+
+gulong gnome_black_pixel;
+gulong gnome_gray_pixel;
+gulong gnome_white_pixel;
+
+GtkDitherInfo *gnome_red_ordered_dither;
+GtkDitherInfo *gnome_green_ordered_dither;
+GtkDitherInfo *gnome_blue_ordered_dither;
+GtkDitherInfo *gnome_gray_ordered_dither;
+
+guchar ***gnome_ordered_dither_matrix;
+
+gulong *gnome_lookup_red;
+gulong *gnome_lookup_green;
+gulong *gnome_lookup_blue;
+
+gulong *gnome_color_pixel_vals;
+gulong *gnome_gray_pixel_vals;
+
+static double gamma_val         = 1.0; /* FIXME: these should be read from the configuration files */
+static int color_cube_shades[4] = { 6, 6, 4, 24 };
+static int install_cmap         = FALSE;
+
+
+static void
+set_app_colors (void)
+{
+	gnome_black_pixel = gnome_colors_get_pixel(0, 0, 0);
+	gnome_gray_pixel  = gnome_colors_get_pixel(127, 127, 127);
+	gnome_white_pixel = gnome_colors_get_pixel(255, 255, 255);
+}
+
+
+static unsigned
+gamma_correct(int intensity, double gamma)
+{
+	unsigned val;
+	double   ind;
+	double   one_over_gamma;
+
+	if(gamma == 0.0)
+	    one_over_gamma = 1.0;
+	else
+	    one_over_gamma = 1.0 / gamma;
+
+	ind = (double) intensity / 255.0;
+	val = (int) (255 * pow(ind, one_over_gamma) + 0.5);
+
+	return val;
+}
+
+
+void
+gnome_colors_init(void)
+{
+	GtkPreviewInfo *info;
+
+	gtk_preview_set_gamma(gamma_val);
+	gtk_preview_set_color_cube(color_cube_shades[0],
+				   color_cube_shades[1],
+				   color_cube_shades[2],
+				   color_cube_shades[3]);
+	gtk_preview_set_install_cmap(install_cmap);
+
+	gtk_widget_set_default_visual(gtk_preview_get_visual());
+	gtk_widget_set_default_colormap(gtk_preview_get_cmap());
+
+	info = gtk_preview_get_info();
+
+	gnome_visual           = info->visual;
+	gnome_colormap         = info->cmap;
+	gnome_color_pixel_vals = info->color_pixels;
+	gnome_gray_pixel_vals  = info->gray_pixels;
+
+	gnome_red_ordered_dither   = info->dither_red;
+	gnome_green_ordered_dither = info->dither_green;
+	gnome_blue_ordered_dither  = info->dither_blue;
+	gnome_gray_ordered_dither  = info->dither_gray;
+
+	gnome_ordered_dither_matrix = info->dither_matrix;
+
+	gnome_lookup_red   = info->lookup_red;
+	gnome_lookup_green = info->lookup_green;
+	gnome_lookup_blue  = info->lookup_blue;
+
+	set_app_colors();
+}
+
+
+gulong
+gnome_colors_get_pixel(int red, int green, int blue)
+{
+	gulong pixel;
+
+	if (gnome_visual->depth == 8)
+		pixel = gnome_color_pixel_vals[(gnome_red_ordered_dither[red].s[1] +
+						gnome_green_ordered_dither[green].s[1] +
+						gnome_blue_ordered_dither[blue].s[1])];
+	else
+		gnome_colors_store_color(&pixel, red, green, blue);
+
+	return pixel;
+}
+
+
+void
+gnome_colors_store_color(gulong *pixel, int red, int green, int blue)
+{
+	GdkColor col;
+
+	red   = gamma_correct(red, gamma_val);
+	green = gamma_correct(green, gamma_val);
+	blue  = gamma_correct(blue, gamma_val);
+
+	col.red   = red | (red << 8);
+	col.green = green | (green << 8);
+	col.blue  = blue | (blue << 8);
+	col.pixel = *pixel;
+
+	if (gnome_visual->depth == 8)
+		gdk_color_change(gnome_colormap, &col);
+	else
+		gdk_color_alloc(gnome_colormap, &col);
+
+	*pixel = col.pixel;
+}
diff --git a/libgnomeui/gnome-colors.h b/libgnomeui/gnome-colors.h
new file mode 100644
index 0000000..d022740
--- /dev/null
+++ b/libgnomeui/gnome-colors.h
@@ -0,0 +1,57 @@
+/* GNOME color management, based on the GIMP's color management functions. */
+
+
+#ifndef GNOME_COLORS_H
+#define GNOME_COLORS_H
+
+BEGIN_GNOME_DECLS
+
+/* NOTE NOTE NOTE
+ *
+ * This module is almost straightly ripped off from the GIMP's
+ * colormaps.[ch].  I still don't know what stuff is interesting to
+ * GNOME apps, so I'm just including most of it here.
+ */
+
+
+/* This is a macro for arranging the red, green, and blue components
+ * into a value acceptable to the target X server.  */
+
+#define GNOME_COLOR_COMPOSE(r, g, b) (lookup_red[r] | lookup_green[g] | lookup_blue[b])
+
+
+/* Visual and colormap used by everything */
+
+extern GdkVisual   *gnome_visual;
+extern GdkColormap *gnome_colormap;
+
+
+/* Pixel values */
+
+extern gulong gnome_black_pixel;
+extern gulong gnome_gray_pixel;
+extern gulong gnome_white_pixel;
+
+extern GtkDitherInfo *gnome_red_ordered_dither;
+extern GtkDitherInfo *gnome_green_ordered_dither;
+extern GtkDitherInfo *gnome_blue_ordered_dither;
+extern GtkDitherInfo *gnome_gray_ordered_dither;
+
+extern guchar ***gnome_ordered_dither_matrix;
+
+extern gulong *gnome_lookup_red;
+extern gulong *gnome_lookup_green;
+extern gulong *gnome_lookup_blue;
+
+extern gulong *gnome_color_pixel_vals;
+extern gulong *gnome_gray_pixel_vals;
+
+
+void   gnome_colors_init        (void);
+gulong gnome_colors_get_pixel   (int red, int green, int blue);
+void   gnome_colors_store_color (gulong *pixel, int red, int green, int blue);
+
+
+END_GNOME_DECLS
+
+#endif
diff --git a/libgnomeui/gnome-messagebox.c b/libgnomeui/gnome-messagebox.c
new file mode 100644
index 0000000..e6f0313
--- /dev/null
+++ b/libgnomeui/gnome-messagebox.c
@@ -0,0 +1,298 @@
+/* GNOME GUI Library
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include "libgnome/gnome-defs.h"
+#include "gnome-messagebox.h"
+#include <string.h> /* for strcmp */
+#include <gtk/gtk.h>
+
+enum {
+  CLICKED,
+  LAST_SIGNAL
+};
+
+typedef void (*GnomeMessageBoxSignal1) (GtkObject *object,
+				        gint       arg1,
+				        gpointer   data);
+
+static void gnome_messagebox_marshal_signal_1 (GtkObject         *object,
+					       GtkSignalFunc      func,
+					       gpointer           func_data,
+					       GtkArg            *args);
+
+static void gnome_messagebox_class_init (GnomeMessageBoxClass *klass);
+static void gnome_messagebox_init       (GnomeMessageBox      *messagebox);
+
+static GtkWindowClass *parent_class;
+static gint messagebox_signals[LAST_SIGNAL] = { 0 };
+
+guint
+gnome_messagebox_get_type ()
+{
+  static guint messagebox_type = 0;
+
+  if (!messagebox_type)
+    {
+      GtkTypeInfo messagebox_info =
+      {
+	"GnomeMessageBox",
+	sizeof (GnomeMessageBox),
+	sizeof (GnomeMessageBoxClass),
+	(GtkClassInitFunc) gnome_messagebox_class_init,
+	(GtkObjectInitFunc) gnome_messagebox_init,
+	(GtkArgFunc) NULL,
+      };
+
+      messagebox_type = gtk_type_unique (gtk_window_get_type (), &messagebox_info);
+    }
+
+  return messagebox_type;
+}
+
+static void
+gnome_messagebox_class_init (GnomeMessageBoxClass *klass)
+{
+  GtkObjectClass *object_class;
+  GtkWidgetClass *widget_class;
+  GtkWindowClass *window_class;
+
+  object_class = (GtkObjectClass*) klass;
+  widget_class = (GtkWidgetClass*) klass;
+  window_class = (GtkWindowClass*) klass;
+
+  parent_class = gtk_type_class (gtk_window_get_type ());
+
+  messagebox_signals[CLICKED] =
+    gtk_signal_new ("clicked",
+                    GTK_RUN_LAST,
+                    object_class->type,
+                    GTK_SIGNAL_OFFSET (GnomeMessageBoxClass, clicked),
+                    gnome_messagebox_marshal_signal_1,
+                    GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
+  gtk_object_class_add_signals (object_class, messagebox_signals, LAST_SIGNAL);
+
+}
+
+static void
+gnome_messagebox_marshal_signal_1 (GtkObject      *object,
+			           GtkSignalFunc   func,
+			           gpointer        func_data,
+			           GtkArg         *args)
+{
+  GnomeMessageBoxSignal1 rfunc;
+
+  rfunc = (GnomeMessageBoxSignal1) func;
+
+  (* rfunc) (object, GTK_VALUE_INT (args[0]), func_data);
+}
+
+static void
+gnome_messagebox_init (GnomeMessageBox *messagebox)
+{
+  messagebox->modal = FALSE;
+}
+
+GtkWidget*
+gnome_messagebox_new (gchar           *message,
+		      gchar           *messagebox_type,
+		      gchar           *button1,
+		      gchar           *button2,
+		      gchar           *button3)
+{
+  GnomeMessageBox *messagebox;
+  GtkWidget *hbox;
+  GtkWidget *vbox;
+  GtkWidget *label;
+  GtkWidget *separator;
+
+  GtkWidget *pixmapwid;
+  GdkPixmap *pixmap;
+  GdkBitmap *mask;                 
+  GtkStyle *style;
+
+  messagebox = gtk_type_new (gnome_messagebox_get_type ());
+
+  gtk_window_set_policy (GTK_WINDOW (messagebox), FALSE, FALSE, FALSE);
+  gtk_widget_set_usize (GTK_WIDGET (messagebox), GNOME_MESSAGEBOX_WIDTH,
+			GNOME_MESSAGEBOX_HEIGHT);
+  gtk_container_border_width (GTK_CONTAINER (messagebox), 
+			      GNOME_MESSAGEBOX_BORDER_WIDTH);
+
+  style = gtk_widget_get_style (GTK_WIDGET (messagebox));
+
+  if (strcmp(GNOME_MESSAGEBOX_INFO, messagebox_type) == 0)
+    {
+      gtk_window_set_title (GTK_WINDOW (messagebox), "Information");
+      pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (messagebox)->window, 
+					   &mask, 
+					   &style->bg[GTK_STATE_NORMAL],
+					   "bomb.xpm");
+    }
+  else if (strcmp(GNOME_MESSAGEBOX_WARNING, messagebox_type) == 0)
+    {
+      gtk_window_set_title (GTK_WINDOW (messagebox), "Warning");
+      pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (messagebox)->window,
+					   &mask, 
+					   &style->bg[GTK_STATE_NORMAL],
+					   "bomb.xpm");
+    }
+  else if (strcmp(GNOME_MESSAGEBOX_ERROR, messagebox_type) == 0)
+    {
+      gtk_window_set_title (GTK_WINDOW (messagebox), "Error");
+      pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (messagebox)->window, 
+					   &mask, 
+					   &style->bg[GTK_STATE_NORMAL],
+					   "bomb.xpm");
+    }
+  else if (strcmp(GNOME_MESSAGEBOX_QUESTION, messagebox_type) == 0)
+    {
+      gtk_window_set_title (GTK_WINDOW (messagebox), "Question");
+      pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (messagebox)->window, 
+					   &mask, 
+					   &style->bg[GTK_STATE_NORMAL],
+					   "bomb.xpm");
+    }
+  else
+    {
+      gtk_window_set_title (GTK_WINDOW (messagebox), "");
+      pixmap = NULL;
+    }
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (messagebox), vbox);
+  gtk_widget_show (vbox);
+
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10);
+  gtk_widget_show (hbox);
+  
+  if (pixmap)
+    {
+      pixmapwid = gtk_pixmap_new (pixmap, mask);
+      gtk_box_pack_start (GTK_BOX (hbox), pixmapwid, FALSE, TRUE, 0);
+      gtk_widget_show (pixmapwid);
+    }
+
+  label = gtk_label_new (message);
+  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+  gtk_widget_show (label);
+
+  separator = gtk_hseparator_new ();
+  gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE,
+		      GNOME_MESSAGEBOX_BORDER_WIDTH);
+  gtk_widget_show (separator);
+
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+  gtk_widget_show (hbox);
+
+  if (button1)
+    messagebox->button1 = gtk_button_new_with_label (button1);
+  else
+    messagebox->button1 = gtk_button_new_with_label ("OK");
+  GTK_WIDGET_SET_FLAGS (GTK_WIDGET (messagebox->button1), GTK_CAN_DEFAULT);
+  gtk_widget_set_usize (GTK_WIDGET (messagebox->button1), 
+			GNOME_MESSAGEBOX_BUTTON_WIDTH,
+			GNOME_MESSAGEBOX_BUTTON_HEIGHT);
+  gtk_box_pack_start (GTK_BOX (hbox), messagebox->button1, TRUE, FALSE, 0);
+  gtk_widget_grab_default (GTK_WIDGET (messagebox->button1));
+  gtk_widget_show (messagebox->button1);
+  
+  gtk_signal_connect (GTK_OBJECT (messagebox->button1), "clicked",
+		      (GtkSignalFunc) gnome_messagebox_button_clicked,
+		      messagebox);
+
+  if (button2)
+    {
+      messagebox->button2 = gtk_button_new_with_label (button2);
+      GTK_WIDGET_SET_FLAGS (messagebox->button2, GTK_CAN_DEFAULT);
+      gtk_widget_set_usize (GTK_WIDGET (messagebox->button2), 
+			    GNOME_MESSAGEBOX_BUTTON_WIDTH,
+			    GNOME_MESSAGEBOX_BUTTON_HEIGHT);
+      gtk_box_pack_start (GTK_BOX (hbox), messagebox->button2, TRUE, FALSE, 0);
+      gtk_widget_show (messagebox->button2);
+      
+      gtk_signal_connect (GTK_OBJECT (messagebox->button2), "clicked",
+			  (GtkSignalFunc) gnome_messagebox_button_clicked,
+			  messagebox);
+    }
+
+  if (button3)
+    {
+      messagebox->button3 = gtk_button_new_with_label (button3);
+      GTK_WIDGET_SET_FLAGS (messagebox->button3, GTK_CAN_DEFAULT);
+      gtk_widget_set_usize (GTK_WIDGET (messagebox->button3), 
+			    GNOME_MESSAGEBOX_BUTTON_WIDTH,
+			    GNOME_MESSAGEBOX_BUTTON_HEIGHT);
+      gtk_box_pack_start (GTK_BOX (hbox), messagebox->button3, TRUE, FALSE, 0);
+      gtk_widget_show (messagebox->button3);
+      
+      gtk_signal_connect (GTK_OBJECT (messagebox->button3), "clicked",
+			  (GtkSignalFunc) gnome_messagebox_button_clicked,
+			  messagebox);
+    }
+
+  return GTK_WIDGET (messagebox);
+}
+
+void
+gnome_messagebox_set_modal (GnomeMessageBox     *messagebox)
+{
+  messagebox->modal = TRUE;
+  gtk_grab_add (GTK_WIDGET (messagebox));
+}
+
+void
+gnome_messagebox_set_default (GnomeMessageBox     *messagebox,
+                              gint                button)
+{
+  switch (button)
+    {
+    case 1:
+      if (messagebox->button1)
+        gtk_widget_grab_default (GTK_WIDGET (messagebox->button1));
+      break;
+    case 2:
+      if (messagebox->button2)
+        gtk_widget_grab_default (GTK_WIDGET (messagebox->button2));
+      break;
+    case 3:
+      if (messagebox->button3)
+        gtk_widget_grab_default (GTK_WIDGET (messagebox->button3));
+      break;
+    default:
+      break;
+    }
+}
+
+void
+gnome_messagebox_button_clicked (GtkWidget   *button, 
+			         GtkWidget   *messagebox)
+{
+  if (button == GNOME_MESSAGEBOX (messagebox)->button1)
+    gtk_signal_emit (GTK_OBJECT (messagebox), messagebox_signals[CLICKED], 1);
+  else if (button == GNOME_MESSAGEBOX (messagebox)->button2)
+    gtk_signal_emit (GTK_OBJECT (messagebox), messagebox_signals[CLICKED], 2);
+  else
+     gtk_signal_emit (GTK_OBJECT (messagebox), messagebox_signals[CLICKED], 3);
+
+  if (GNOME_MESSAGEBOX (messagebox)->modal)
+    gtk_grab_remove (GTK_WIDGET (messagebox));
+ 
+  gtk_widget_destroy (messagebox);
+}
diff --git a/libgnomeui/gnome-messagebox.h b/libgnomeui/gnome-messagebox.h
new file mode 100644
index 0000000..84e64df
--- /dev/null
+++ b/libgnomeui/gnome-messagebox.h
@@ -0,0 +1,84 @@
+/* GNOME GUI Library
+ * Copyright (C) 1995-1997 Jay Painter
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef __GNOME_MESSAGEBOX_H__
+#define __GNOME_MESSAGEBOX_H__
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkwindow.h>
+
+
+#define GNOME_MESSAGEBOX_WIDTH  425
+#define GNOME_MESSAGEBOX_HEIGHT 125
+#define GNOME_MESSAGEBOX_BORDER_WIDTH 5
+
+#define GNOME_MESSAGEBOX_BUTTON_WIDTH 100
+#define GNOME_MESSAGEBOX_BUTTON_HEIGHT 40
+
+
+BEGIN_GNOME_DECLS
+
+#define GNOME_MESSAGEBOX(obj)        GTK_CHECK_CAST (obj, gnome_messagebox_get_type (), GnomeMessageBox)
+#define GNOME_MESSAGEBOX_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, gnome_messagebox_get_type (), GnomeMessageBoxClass)
+#define GNOME_IS_MESSAGEBOX(obj)       GTK_CHECK_TYPE (obj, gnome_messagebox_get_type ())
+
+
+#define GNOME_MESSAGEBOX_INFO      "info"
+#define GNOME_MESSAGEBOX_WARNING   "warning"
+#define GNOME_MESSAGEBOX_ERROR     "error"
+#define GNOME_MESSAGEBOX_QUESTION  "question"
+#define GNOME_MESSAGEBOX_GENERIC   "generic"
+
+
+typedef struct _GnomeMessageBox        GnomeMessageBox;
+typedef struct _GnomeMessageBoxClass   GnomeMessageBoxClass;
+typedef struct _GnomeMessageBoxButton  GnomeMessageBoxButton;
+
+struct _GnomeMessageBox
+{
+  GtkWindow window;
+
+  GtkWidget *button1;
+  GtkWidget *button2;
+  GtkWidget *button3;
+
+  int modal : 1;
+};
+
+struct _GnomeMessageBoxClass
+{
+  GtkWindowClass parent_class;
+
+  void (* clicked)  (GnomeMessageBox *messagebox, gint button);
+};
+
+
+guint      gnome_messagebox_get_type       (void);
+GtkWidget* gnome_messagebox_new            (gchar           *message,
+					    gchar           *messagebox_type,
+					    gchar           *button1,
+					    gchar           *button2,
+					    gchar           *button3);
+void       gnome_messagebox_set_modal      (GnomeMessageBox *messagebox);
+void       gnome_messagebox_set_default    (GnomeMessageBox *messagebox,
+                                            gint            button);
+void       gnome_messagebox_button_clicked (GtkWidget       *button,
+					    GtkWidget       *messagebox);
+
+END_GNOME_DECLS
+
+#endif /* __GNOME_MESSAGEBOX_H__ */
diff --git a/libgnomeui/gnome-pixmap.c b/libgnomeui/gnome-pixmap.c
new file mode 100644
index 0000000..171fd6e
--- /dev/null
+++ b/libgnomeui/gnome-pixmap.c
@@ -0,0 +1,141 @@
+/* GNOME GUI Library
+ * Copyright (C) 1997 the Free Software Foundation
+ *
+ * Authors: Miguel de Icaza
+ *          Federico Mena
+ */
+
+#include <gtk/gtk.h>
+#include "libgnome/gnome-defs.h"
+#include "libgnome/libgnome.h"
+#include "gnome-messagebox.h"
+
+struct pixmap_item {
+	GdkPixmap *pixmap;
+	GdkBitmap *mask;
+};
+
+static GHashTable *pixmap_hash;
+
+
+static void
+destroy_hash_element (void *key, void *val, void *data)
+{
+	struct pixmap_item *pi = val;
+
+	gdk_pixmap_destroy (pi->pixmap);
+	gdk_pixmap_destroy (pi->mask);
+	g_free (val);
+	g_free (key);
+}
+
+void
+gnome_destroy_pixmap_cache (void)
+{
+	if (!pixmap_hash)
+		return;
+
+	g_hash_table_foreach (pixmap_hash, destroy_hash_element, 0);
+	g_hash_table_destroy (pixmap_hash);
+	pixmap_hash = NULL;
+}
+
+static void
+check_hash_table(void)
+{
+	if (!pixmap_hash)
+		pixmap_hash = g_hash_table_new (g_string_hash, g_string_equal);
+}
+
+static void
+load_pixmap(GdkWindow *window, GdkPixmap **pixmap, GdkBitmap **mask, GdkColor *transparent, char *filename)
+{
+	struct pixmap_item *pit;
+
+	check_hash_table();
+
+	pit = g_hash_table_lookup(pixmap_hash, filename);
+
+	if (!pit) {
+		pit = g_new(struct pixmap_item, 1);
+		pit->pixmap = gdk_pixmap_create_from_xpm(window, &pit->mask, transparent, filename);
+		
+		g_hash_table_insert(pixmap_hash, g_strdup(filename), pit);
+	}
+	
+	*pixmap = pit->pixmap;
+	*mask   = pit->mask;
+}
+
+void
+gnome_create_pixmap_gdk (GdkWindow *window, GdkPixmap **pixmap, GdkBitmap **mask, GdkColor *transparent, char *file)
+{
+	g_assert(window != NULL);
+	g_assert(pixmap != NULL);
+	g_assert(mask != NULL);
+	g_assert(transparent != NULL);
+
+	if (!file || !g_file_exists(file)) {
+		*pixmap = NULL;
+		*mask = NULL;
+		return;
+	}
+
+	load_pixmap(window, pixmap, mask, transparent, file);
+}
+
+void
+gnome_create_pixmap_gtk (GtkWidget *window, GdkPixmap **pixmap, GdkBitmap **mask, GtkWidget *holder, char *file)
+{
+	GtkStyle *style;
+	
+	g_assert(window != NULL);
+	g_assert(pixmap != NULL);
+	g_assert(mask != NULL);
+	g_assert(holder != NULL);
+
+	if (!file || !g_file_exists(file)) {
+		*pixmap = NULL;
+		*mask = NULL;
+		return;
+	}
+
+	if (!GTK_WIDGET_REALIZED(window))
+		gtk_widget_realize(window);
+
+	style = gtk_widget_get_style (holder);
+
+	load_pixmap(window->window, pixmap, mask,
+		    style ? &style->bg[GTK_STATE_NORMAL] : NULL, /* XXX: NULL will make it bomb */
+		    file);
+}
+
+GtkWidget *
+gnome_create_pixmap_widget (GtkWidget *window, GtkWidget *holder, char *file)
+{
+	GdkPixmap *pixmap;
+	GdkBitmap *mask;
+
+	if (!file || !g_file_exists(file))
+		return NULL;
+
+	gnome_create_pixmap_gtk(window, &pixmap, &mask, holder, file);
+
+	return gtk_pixmap_new(pixmap, mask);
+}
+
+void
+gnome_set_pixmap_widget (GtkPixmap *pixmap, GtkWidget *window, GtkWidget *holder, gchar *file)
+{
+	GdkPixmap *gpixmap;
+	GdkBitmap *mask;
+	
+	g_assert (pixmap != NULL);
+
+	if (!file || !g_file_exists(file))
+		return;
+
+	gnome_create_pixmap_gtk(window, &gpixmap, &mask, holder, file);
+
+	gtk_pixmap_set(pixmap, gpixmap, mask);
+}
diff --git a/libgnomeui/gnome-pixmap.h b/libgnomeui/gnome-pixmap.h
new file mode 100644
index 0000000..bc294d0
--- /dev/null
+++ b/libgnomeui/gnome-pixmap.h
@@ -0,0 +1,16 @@
+#ifndef __GNOME_PIXMAP_H__
+#define __GNOME_PIXMAP_H__
+
+BEGIN_GNOME_DECLS
+
+void gnome_destroy_pixmap_cache (void);
+
+void gnome_create_pixmap_gdk (GdkWindow *window, GdkPixmap **pixmap, GdkBitmap **mask, GdkColor *transparent, char *file);
+void gnome_create_pixmap_gtk (GtkWidget *window, GdkPixmap **pixmap, GdkBitmap **mask, GtkWidget *holder, char *file);
+
+GtkWidget *gnome_create_pixmap_widget (GtkWidget *window, GtkWidget *holder, char *file);
+void gnome_set_pixmap_widget (GtkPixmap *pixmap, GtkWidget *window, GtkWidget *holder, char *file);
+
+END_GNOME_DECLS
+
+#endif /* __GNOME_PIXMAP_H__ */
diff --git a/libgnomeui/gnome-properties.c b/libgnomeui/gnome-properties.c
new file mode 100644
index 0000000..29ee9d3
--- /dev/null
+++ b/libgnomeui/gnome-properties.c
@@ -0,0 +1,76 @@
+#include <gtk/gtk.h>
+#include <string.h>
+#include "libgnome/gnome-defs.h"
+#include "gnome-properties.h"
+#include "gnome-actionarea.h"
+
+GnomePropertyConfigurator *
+gnome_property_configurator_new (void)
+{
+	GnomePropertyConfigurator *this = g_malloc (sizeof (GnomePropertyConfigurator));
+
+	this->props = NULL;
+	this->notebook = NULL;
+
+	return this;
+}
+
+void
+gnome_property_configurator_destroy (GnomePropertyConfigurator *this)
+{
+	if (this->notebook)
+		gtk_widget_destroy (this->notebook);
+	g_list_free (this->props);
+}
+
+
+
+void
+gnome_property_configurator_register (GnomePropertyConfigurator *this,
+				      int (*callback)(GnomePropertyRequest))
+{
+	this->props = g_list_append (this->props, callback);
+}
+
+void
+gnome_property_configurator_setup (GnomePropertyConfigurator *this)
+{
+	this->notebook = gtk_notebook_new ();
+	gtk_widget_show (this->notebook);
+}
+
+gint
+gnome_property_configurator_request (GnomePropertyConfigurator *th,
+				     GnomePropertyRequest r)
+{
+	int (*cb)(GnomePropertyRequest);
+
+	if (!th->notebook)
+		return 0;
+
+	cb = (int (*)(GnomePropertyRequest))
+		(g_list_nth
+		 (th->props,
+		  gtk_notebook_current_page (GTK_NOTEBOOK (th->notebook)))->data);
+
+
+	// printf ("request %d %x\n", gtk_notebook_current_page (th->notebook), cb);
+
+	if (cb)
+		return (*cb) (r);
+	else
+		return 0;
+}
+
+static void
+request (int (*cb)(GnomePropertyRequest), GnomePropertyRequest r)
+{
+	(*cb) (r);
+}
+
+gint
+gnome_property_configurator_request_foreach (GnomePropertyConfigurator *th,
+					     GnomePropertyRequest r)
+{
+	g_list_foreach (th->props, (GFunc)request, (gpointer)r);
+}
diff --git a/libgnomeui/gnome-properties.h b/libgnomeui/gnome-properties.h
new file mode 100644
index 0000000..280cda7
--- /dev/null
+++ b/libgnomeui/gnome-properties.h
@@ -0,0 +1,34 @@
+#ifndef GNOME_PROPERTIES_H
+#define GNOME_PROPERTIES_H
+
+BEGIN_GNOME_DECLS
+
+typedef struct {
+	GtkWidget *notebook;
+
+	GList *props;
+} GnomePropertyConfigurator;
+
+/* This is the first parameter to the callback function */
+typedef enum {
+	GNOME_PROPERTY_READ,
+	GNOME_PROPERTY_WRITE,
+	GNOME_PROPERTY_APPLY,
+	GNOME_PROPERTY_SETUP
+} GnomePropertyRequest;
+
+GnomePropertyConfigurator
+     *gnome_property_configurator_new (void);
+  
+void gnome_property_configurator_destroy (GnomePropertyConfigurator *);
+void gnome_property_configurator_register (GnomePropertyConfigurator *, 
+					   int (*callback)(GnomePropertyRequest));
+void gnome_property_configurator_setup (GnomePropertyConfigurator *);
+gint gnome_property_configurator_request (GnomePropertyConfigurator *,
+					  GnomePropertyRequest);
+gint gnome_property_configurator_request_foreach (GnomePropertyConfigurator *th,
+						  GnomePropertyRequest r);
+
+END_GNOME_DECLS
+
+#endif
diff --git a/libgnomeui/gnome-toolbar.c b/libgnomeui/gnome-toolbar.c
new file mode 100644
index 0000000..3aae9e5
--- /dev/null
+++ b/libgnomeui/gnome-toolbar.c
@@ -0,0 +1,157 @@
+/* GNOME GUI Library
+ * Copyright (C) 1997 The Free Software Foundation
+ *
+ * Author: Aldy Hernandez (aldy uaa edu)
+ *
+ * GNOME toolbar implementation
+ */
+
+#include <gtk/gtk.h>
+#include "gnome-toolbar.h"
+#include "libgnome/gnome-defs.h"
+#include "libgnomeui/gnome-pixmap.h"
+
+/* Make sure these match ``enum ToolbarDefaultItem'' */
+static struct {
+  char *label;
+  char *pixmap_filename;
+} ToolbarDefaultItems [] =
+  {
+    { "Open",	"gnome-open-icon.xpm" },
+    { "Close",	"gnome-close-icon.xpm" },
+    { "Reload",	"gnome-reload-icon.xpm" },
+    { "Print",	"gnome-print-icon.xpm" },
+    { "Exit",	"gnome-exit-icon.xpm" }
+  };
+
+GnomeToolbar *
+gnome_create_toolbar (void *parent,
+		      enum GnomePackMethod packmethod)
+{
+	GnomeToolbar *tb;
+	
+	tb = (GnomeToolbar *) g_malloc (sizeof (GnomeToolbar));
+	tb->toolbar = NULL;
+	tb->box = gtk_hbox_new (FALSE, 0);
+	tb->style = GNOME_TB_NOTHING;
+	tb->items = NULL;
+	tb->nitems = 0;
+	
+	switch (packmethod){
+	case GNOME_TB_CONTAINER_ADD:
+		gtk_container_add (GTK_CONTAINER ((GtkWidget *)parent), tb->box);
+		break;
+		
+	case GNOME_TB_PACK_START:
+		gtk_box_pack_start (GTK_BOX ((GtkWidget *) parent), tb->box, FALSE, FALSE, 0);
+		break;
+		
+	case GNOME_TB_PACK_END:
+		gtk_box_pack_end (GTK_BOX ((GtkWidget *) parent), tb->box, FALSE, FALSE, 0);
+		break;
+		
+	default:
+		printf ("gnome_create_toolbar: invalid packmethod %d\n", packmethod);
+	}
+	
+	gtk_container_border_width (GTK_CONTAINER (tb->box), 2);
+	gtk_widget_show (tb->box);
+	
+	return tb;
+}
+
+/* Destroy toolbar permanently */
+void
+gnome_destroy_toolbar (GnomeToolbar *toolbar)
+{
+	gtk_widget_destroy (toolbar->box);
+}
+
+void
+gnome_toolbar_add (GnomeToolbar *toolbar, char *label, char *pixmap_filename,
+		   GnomeToolbarFunc func, void *data)
+{
+	int i = toolbar->nitems;
+	
+	toolbar->items = g_realloc (toolbar->items, sizeof (GnomeToolbarItem) * (toolbar->nitems + 1));
+	
+	toolbar->items[i].label = label;
+	toolbar->items[i].func = func;
+	toolbar->items[i].data = data;
+	toolbar->items[i].pixmap_filename = pixmap_filename;
+	++toolbar->nitems;
+}
+
+void
+gnome_toolbar_add_default (GnomeToolbar *toolbar,
+			   enum GnomeToolbarDefaultItem tb_default,
+			   GnomeToolbarFunc func, void *data)
+{
+	gnome_toolbar_add (toolbar, ToolbarDefaultItems[tb_default].label,
+			   ToolbarDefaultItems[tb_default].pixmap_filename,
+			   func, data);
+}
+
+void
+gnome_toolbar_set_style (GnomeToolbar *toolbar,
+			 enum GnomeToolbarStyle style)
+{
+	int i;
+	
+	toolbar->style = style;
+	
+	if (toolbar->toolbar)
+		gtk_widget_destroy (toolbar->toolbar);
+	
+	if (style & GNOME_TB_VERTICAL)
+		toolbar->toolbar = gtk_vbox_new (FALSE, 0);
+	else
+		toolbar->toolbar = gtk_hbox_new (FALSE, 0);
+	
+	gtk_container_border_width (GTK_CONTAINER (toolbar->toolbar), 3);
+	gtk_box_pack_start (GTK_BOX (toolbar->box), toolbar->toolbar, FALSE, FALSE, 3);
+	
+	for (i=0; i < toolbar->nitems; ++i){
+		GtkWidget *button;
+		GtkWidget *vbox;
+		GtkWidget *label = NULL;
+		GtkWidget *pixmap = NULL;
+		
+		button = gtk_button_new ();
+		vbox = gtk_vbox_new (FALSE, 0);
+		
+		if (style & GNOME_TB_TEXT && toolbar->items[i].label)
+			label = gtk_label_new (toolbar->items[i].label);
+		
+		if (style & GNOME_TB_ICONS && toolbar->items[i].pixmap_filename)
+			pixmap = gnome_create_pixmap_widget (toolbar->box,
+							     toolbar->box,
+							     toolbar->items[i].pixmap_filename);
+		
+		if (style & GNOME_TB_ICONS && !pixmap) 
+			label = gtk_label_new ("undefined");
+		
+		gtk_container_add (GTK_CONTAINER (button), vbox);
+		gtk_container_border_width (GTK_CONTAINER (button), 1);
+		
+		if (pixmap) {		/* Place pixmap */
+			gtk_box_pack_start (GTK_BOX (vbox), pixmap, FALSE, FALSE, 0);
+			gtk_widget_show (pixmap);
+		}
+		
+		if (label) {		/* Place label */
+			gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+			gtk_widget_show (label);
+		}
+		
+		gtk_box_pack_start (GTK_BOX (toolbar->toolbar), button, FALSE, FALSE, 0);
+		gtk_widget_show (button);
+		gtk_widget_show (vbox);
+		
+		gtk_signal_connect (GTK_OBJECT (button), "clicked",
+				    (GtkSignalFunc) toolbar->items[i].func,
+				    toolbar->items[i].data);
+	}
+	gtk_widget_show (toolbar->toolbar);
+}
+
diff --git a/libgnomeui/gnome-toolbar.h b/libgnomeui/gnome-toolbar.h
new file mode 100644
index 0000000..0498ab2
--- /dev/null
+++ b/libgnomeui/gnome-toolbar.h
@@ -0,0 +1,92 @@
+/* GNOME GUI Library
+ * Copyright (C) 1997 The Free Software Foundation
+ *
+ * Author: Aldy Hernandez (aldy uaa edu)
+ *
+ * GNOME toolbar support definitions
+ */
+
+#ifndef __GNOME_TOOLBAR_H__
+#define __GNOME_TOOLBAR_H__
+
+#include "libgnome/gnome-defs.h"
+
+BEGIN_GNOME_DECLS
+
+typedef struct _GnomeToolbar		GnomeToolbar;
+typedef struct _GnomeToolbarItem	GnomeToolbarItem;
+
+typedef void (*GnomeToolbarFunc) (void *data);
+
+enum GnomeToolbarStyle
+{
+	GNOME_TB_NOTHING    = 0,
+	GNOME_TB_TEXT       = 2,
+	GNOME_TB_ICONS      = 4,
+	GNOME_TB_VERTICAL   = 8,
+	GNOME_TB_HORIZONTAL = 16,
+	GNOME_TB_AXIS       = 24
+};
+
+enum GnomePackMethod
+{
+	GNOME_TB_CONTAINER_ADD,
+	GNOME_TB_PACK_START,
+	GNOME_TB_PACK_END
+};
+
+enum GnomeToolbarDefaultItem
+{
+	GNOME_TOOLBAR_OPEN,
+	GNOME_TOOLBAR_CLOSE,
+	GNOME_TOOLBAR_RELOAD,
+	GNOME_TOOLBAR_PRINT,
+	GNOME_TOOLBAR_EXIT
+};
+
+struct _GnomeToolbar
+{
+	/* Actual toolbar widget */
+	GtkWidget *toolbar;
+	
+	/* Parent box in which to put ``toolbar''.  We need a separate box
+	 * in which to put the toolbar in so we can destroy and recreate the
+	 * toolbar at will.
+	 */
+	GtkWidget *box;
+	
+	enum GnomeToolbarStyle style;
+	
+	int nitems;
+	
+	GnomeToolbarItem *items;
+};
+
+struct _GnomeToolbarItem
+{
+	char *label;
+	char *pixmap_filename;
+	void *data;
+	GnomeToolbarFunc func;
+};
+
+GnomeToolbar*	gnome_create_toolbar	  (void                         *parent,
+					   enum GnomePackMethod         packmethod);
+void		gnome_destroy_toolbar	  (GnomeToolbar                 *toolbar);
+void		gnome_toolbar_add 	  (GnomeToolbar                 *toolbar,
+					   char                         *label,
+					   char                         *pixmap_filename,
+					   GnomeToolbarFunc             func,
+					   void                         *data);
+void		gnome_toolbar_add_default (GnomeToolbar                 *toolbar,
+					   enum GnomeToolbarDefaultItem tb_default,
+					   GnomeToolbarFunc             func,
+					   void                         *data);
+void		gnome_toolbar_set_style   (GnomeToolbar                 *toolbar,
+					   enum GnomeToolbarStyle       style);
+
+END_GNOME_DECLS
+
+#endif /* __GNOME_TOOLBAR_H__ */
+
+
diff --git a/libgnomeui/gnome-ui-init.c b/libgnomeui/gnome-ui-init.c
new file mode 100644
index 0000000..1f8dc27
--- /dev/null
+++ b/libgnomeui/gnome-ui-init.c
@@ -0,0 +1,90 @@
+#include <config.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <gtk/gtk.h>
+#include "libgnome/libgnome.h"
+#include "gnome-colors.h"
+
+static void gnome_rc_parse(gchar *command);
+
+void
+gnome_init (gint *argc, gchar ***argv)
+{
+	/* now we replace gtk_init() with gnome_init() in our apps */
+	gtk_init(argc, argv);
+	gnome_colors_init();
+	
+	gnome_rc_parse(*argv[0]);
+	
+	gnomelib_init (argc, argv);
+}
+
+/* perhaps this belongs in libgnome.. move it if you like. */
+
+/* automagically parse all the gtkrc files for us.
+ * 
+ * Parse:
+ * $gnomedatadir/gtkrc
+ * $gnomedatadir/$apprc
+ * ~/.ghome/gtkrc
+ * ~/.gnome/$apprc
+ *
+ * appname is derived from argv[0].  IMHO this is a great solution.
+ * It provides good consistancy (you always know the rc file will be
+ * the same name as the executable), and it's easy for the programmer.
+ * 
+ * If you don't like it.. give me a good reason.  Symlin
+ */
+static void gnome_rc_parse(gchar *command)
+{
+	gint i;
+	gint buf_len;
+	gint found = 0;
+	gchar *buf = NULL;
+	gchar *file;
+	gchar *apprc;
+	
+	buf_len = strlen(command);
+	
+	for (i = 0; i < buf_len; i++) {
+		if (command[buf_len - i] == '/') {
+			buf = g_strdup (&command[buf_len - i + 1]);
+			found = TRUE;
+			break;
+		}
+	}
+	
+	if (!found)
+		buf = g_strdup (command);
+	
+	apprc = g_malloc (strlen(buf) + 3);
+	sprintf(apprc, "%src", buf);
+	
+	g_free(buf);
+	
+	
+	/* <gnomedatadir>/gtkrc */
+	file = gnome_datadir_file("gtkrc");
+	gtk_rc_parse (file);
+	g_free (file);
+
+	/* <gnomedatadir>/<progname> */
+	file = gnome_datadir_file(apprc);
+	gtk_rc_parse (file);
+	g_free (file);
+	
+	/* ~/.gnome/gtkrc */
+	file = gnome_util_home_file("gtkrc");
+	gtk_rc_parse (file);
+	g_free (file);
+	
+	/* ~/.gnome/<progname> */
+	file = gnome_util_home_file(apprc);
+	gtk_rc_parse (file);
+	g_free (file);
+	
+	g_free (apprc);
+}
diff --git a/libgnomeui/libgnomeui.h b/libgnomeui/libgnomeui.h
new file mode 100644
index 0000000..49ecea0
--- /dev/null
+++ b/libgnomeui/libgnomeui.h
@@ -0,0 +1,19 @@
+#ifndef LIBGNOMEUI_H
+#define LIBGNOMEUI_H
+
+#include "libgnome/gnome-defs.h"
+#include "libgnomeui/gnome-actionarea.h"
+#include "libgnomeui/gnome-colors.h"
+#include "libgnomeui/gnome-color-selector.h"
+#include "libgnomeui/gnome-messagebox.h"
+#include "libgnomeui/gnome-pixmap.h"
+#include "libgnomeui/gnome-toolbar.h"
+#include "libgnomeui/gnome-actionarea.h"
+
+BEGIN_GNOME_DECLS
+
+void gnome_init (int *argc, char ***argv);
+
+END_GNOME_DECLS
+
+#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]