Remove GNOME support files

This commit is contained in:
Maurus Cuelenaere 2011-12-13 16:56:20 +01:00
parent d70eb7949b
commit c189cf6cd5
11 changed files with 1 additions and 1789 deletions

View File

@ -1,15 +1,9 @@
noinst_LIBRARIES = libgnomeui.a libmisc.a
noinst_LIBRARIES = libmisc.a
INCLUDES = @GTK_CFLAGS@
noinst_HEADERS = \
gnome-i18nP.h \
gnome-color-picker.h \
gnome-dateedit.h \
getopt.h \
nvstore.h
libgnomeui_a_SOURCES = gnome-color-picker.c gnome-dateedit.c
libmisc_a_SOURCES = getopt.c getopt1.c nvstore.c
libmisc_a_LIBADD = @LIBOBJS@
EXTRA_DIST = README.gnome

View File

@ -1,10 +0,0 @@
The Gnome files here were ripped out of libgnome and libgnomeui (in the
gnome-libs tarball) and have been modified slightly:
*: Removed trivial Gnome dependencies (BEGIN_GNOME_DECLS et. al.)
gnome-color-picker: Hacked out the GdkImlib dependency. This widget now
works with pure GTK+, sans alpha rendering and dithering.
gnome-dateedit: Contains a small hack to clear the popdown calendar after
a single-click date selection (instead of after a double-click).

View File

@ -1,810 +0,0 @@
/* Color picker button for GNOME
*
* Copyright (C) 1998 Red Hat Software, Inc.
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#include <config.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkcolorsel.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtkframe.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkcompat.h>
#include "gnome-color-picker.h"
#include "gnome-i18nP.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkbutton.h>
/* These are the dimensions of the color sample in the color picker */
#define COLOR_PICKER_WIDTH 32
#define COLOR_PICKER_HEIGHT 20
#define COLOR_PICKER_PAD 1
/* Size of checks and gray levels for alpha compositing checkerboard*/
#define CHECK_SIZE 4
#define CHECK_DARK (1.0 / 3.0)
#define CHECK_LIGHT (2.0 / 3.0)
/* Stipple for disabled state */
#define gnome_color_picker_stipple_width 2
#define gnome_color_picker_stipple_height 2
static char gnome_color_picker_stipple_bits[] = {
0x02, 0x01, };
enum {
COLOR_SET,
LAST_SIGNAL
};
typedef void (* GnomeColorPickerSignal1) (GtkObject *object,
gint arg1,
gint arg2,
gint arg3,
gint arg4,
gpointer data);
static void gnome_color_picker_marshal_signal_1 (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
static void gnome_color_picker_class_init (GnomeColorPickerClass *class);
static void gnome_color_picker_init (GnomeColorPicker *cp);
static void gnome_color_picker_destroy (GtkObject *object);
static void gnome_color_picker_clicked (GtkButton *button);
static void gnome_color_picker_state_changed (GtkWidget *widget, GtkStateType previous_state);
static void gnome_color_picker_realize (GtkWidget *widget);
static void gnome_color_picker_style_set (GtkWidget *widget, GtkStyle *previous_style);
static guint color_picker_signals[LAST_SIGNAL] = { 0 };
static GdkPixmap *stipple = NULL;
static GtkButtonClass *parent_class;
GtkType
gnome_color_picker_get_type (void)
{
static GtkType cp_type = 0;
if (!cp_type) {
GtkTypeInfo cp_info = {
"GnomeColorPicker",
sizeof (GnomeColorPicker),
sizeof (GnomeColorPickerClass),
(GtkClassInitFunc) gnome_color_picker_class_init,
(GtkObjectInitFunc) gnome_color_picker_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
cp_type = gtk_type_unique (gtk_button_get_type (), &cp_info);
}
return cp_type;
}
static void
gnome_color_picker_class_init (GnomeColorPickerClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
object_class = (GtkObjectClass *) class;
button_class = (GtkButtonClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_button_get_type ());
color_picker_signals[COLOR_SET] =
gtk_signal_new ("color_set",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeColorPickerClass, color_set),
gnome_color_picker_marshal_signal_1,
GTK_TYPE_NONE, 4,
GTK_TYPE_UINT,
GTK_TYPE_UINT,
GTK_TYPE_UINT,
GTK_TYPE_UINT);
gtk_object_class_add_signals (object_class, color_picker_signals, LAST_SIGNAL);
object_class->destroy = gnome_color_picker_destroy;
widget_class->state_changed = gnome_color_picker_state_changed;
widget_class->realize = gnome_color_picker_realize;
widget_class->style_set = gnome_color_picker_style_set;
button_class->clicked = gnome_color_picker_clicked;
class->color_set = NULL;
}
/* Renders the pixmap for the case of dithered or use_alpha */
static void
render_dither (GnomeColorPicker *cp)
{
#ifdef GCP_PRISTINE_SOURCE
gint dark_r, dark_g, dark_b;
gint light_r, light_g, light_b;
gint x, y;
gint c1[3], c2[3];
guchar *p;
GdkPixmap *pixmap;
/* Compute dark and light check colors */
if (cp->use_alpha) {
dark_r = (int) ((CHECK_DARK + (cp->r - CHECK_DARK) * cp->a) * 255.0 + 0.5);
dark_g = (int) ((CHECK_DARK + (cp->g - CHECK_DARK) * cp->a) * 255.0 + 0.5);
dark_b = (int) ((CHECK_DARK + (cp->b - CHECK_DARK) * cp->a) * 255.0 + 0.5);
light_r = (int) ((CHECK_LIGHT + (cp->r - CHECK_LIGHT) * cp->a) * 255.0 + 0.5);
light_g = (int) ((CHECK_LIGHT + (cp->g - CHECK_LIGHT) * cp->a) * 255.0 + 0.5);
light_b = (int) ((CHECK_LIGHT + (cp->b - CHECK_LIGHT) * cp->a) * 255.0 + 0.5);
} else {
dark_r = light_r = (int) (cp->r * 255.0 + 0.5);
dark_g = light_g = (int) (cp->g * 255.0 + 0.5);
dark_b = light_b = (int) (cp->b * 255.0 + 0.5);
}
/* Fill image buffer */
p = cp->im->rgb_data;
for (y = 0; y < COLOR_PICKER_HEIGHT; y++) {
if ((y / CHECK_SIZE) & 1) {
c1[0] = dark_r;
c1[1] = dark_g;
c1[2] = dark_b;
c2[0] = light_r;
c2[1] = light_g;
c2[2] = light_b;
} else {
c1[0] = light_r;
c1[1] = light_g;
c1[2] = light_b;
c2[0] = dark_r;
c2[1] = dark_g;
c2[2] = dark_b;
}
for (x = 0; x < COLOR_PICKER_WIDTH; x++)
if ((x / CHECK_SIZE) & 1) {
*p++ = c1[0];
*p++ = c1[1];
*p++ = c1[2];
} else {
*p++ = c2[0];
*p++ = c2[1];
*p++ = c2[2];
}
}
/* Render the image and copy it to our pixmap */
gdk_imlib_changed_image (cp->im);
gdk_imlib_render (cp->im, COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
pixmap = gdk_imlib_move_image (cp->im);
gdk_draw_pixmap (cp->pixmap,
cp->gc,
pixmap,
0, 0,
0, 0,
COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
gdk_imlib_free_pixmap (pixmap);
#endif /* GCP_PRISTINE_SOURCE */
}
/* Renders the pixmap with the contents of the color sample */
static void
render (GnomeColorPicker *cp)
{
GdkColor c;
#ifndef GCP_PRISTINE_SOURCE
GdkColormap *cmap;
#endif
if (cp->dither || cp->use_alpha)
render_dither (cp);
else {
c.red = (gushort) (cp->r * 65535.0 + 0.5);
c.green = (gushort) (cp->g * 65535.0 + 0.5);
c.blue = (gushort) (cp->b * 65535.0 + 0.5);
#ifdef GCP_PRISTINE_SOURCE
gdk_imlib_best_color_get (&c);
#else
cmap = gtk_widget_get_colormap( cp->da );
gdk_colormap_free_colors( cmap, &cp->c, 1 );
gdk_colormap_alloc_color( cmap, &c, FALSE, TRUE );
cp->c.pixel = c.pixel;
cp->c.red = c.red;
cp->c.green = c.green;
cp->c.blue = c.blue;
#endif
gdk_gc_set_foreground (cp->gc, &c);
gdk_draw_rectangle (cp->pixmap,
cp->gc,
TRUE,
0, 0,
COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
}
#ifdef GCP_PRISTINE_SOURCE
if (!GTK_WIDGET_IS_SENSITIVE (cp) && GTK_WIDGET_REALIZED (cp)) {
gdk_gc_set_stipple (cp->da->style->bg_gc[GTK_STATE_NORMAL], stipple);
gdk_gc_set_fill (cp->da->style->bg_gc[GTK_STATE_NORMAL], GDK_STIPPLED);
gdk_draw_rectangle (cp->pixmap,
cp->da->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
0, 0,
COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
gdk_gc_set_fill (cp->da->style->bg_gc[GTK_STATE_NORMAL], GDK_SOLID);
}
#endif
}
/* Handle exposure events for the color picker's drawing area */
static gint
expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GnomeColorPicker *cp;
cp = data;
gdk_draw_pixmap (widget->window,
cp->gc,
cp->pixmap,
event->area.x,
event->area.y,
event->area.x,
event->area.y,
event->area.width,
event->area.height);
return FALSE;
}
static void
gnome_color_picker_realize (GtkWidget *widget)
{
if (GTK_WIDGET_CLASS(parent_class)->realize)
GTK_WIDGET_CLASS (parent_class)->realize (widget);
render (GNOME_COLOR_PICKER (widget));
}
static void
gnome_color_picker_style_set (GtkWidget *widget, GtkStyle *previous_style)
{
if (GTK_WIDGET_CLASS(parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
if (GTK_WIDGET_REALIZED (widget))
render (GNOME_COLOR_PICKER (widget));
}
static void
gnome_color_picker_state_changed (GtkWidget *widget, GtkStateType previous_state)
{
if (widget->state == GTK_STATE_INSENSITIVE || previous_state == GTK_STATE_INSENSITIVE)
render (GNOME_COLOR_PICKER (widget));
}
static void
gnome_color_picker_init (GnomeColorPicker *cp)
{
GtkWidget *alignment;
GtkWidget *frame;
#ifdef GCP_PRISTINE_SOURCE
guchar *buf;
#endif
/* Create the widgets */
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), COLOR_PICKER_PAD);
gtk_container_add (GTK_CONTAINER (cp), alignment);
gtk_widget_show (alignment);
frame = gtk_frame_new (NULL);
#ifdef GCP_PRISTINE_SOURCE
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
#endif
gtk_container_add (GTK_CONTAINER (alignment), frame);
gtk_widget_show (frame);
#ifdef GCP_PRISTINE_SOURCE
gtk_widget_push_visual (gdk_imlib_get_visual ());
gtk_widget_push_colormap (gdk_imlib_get_colormap ());
#else
gtk_widget_push_visual( gtk_widget_get_visual( frame ) );
gtk_widget_push_colormap( gtk_widget_get_colormap( frame ) );
#endif
cp->da = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (cp->da), COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
gtk_signal_connect (GTK_OBJECT (cp->da), "expose_event",
(GtkSignalFunc) expose_event,
cp);
gtk_container_add (GTK_CONTAINER (frame), cp->da);
gtk_widget_show (cp->da);
cp->title = g_strdup (_("Pick a color")); /* default title */
/* Create the buffer for the image so that we can create an imlib image. Also create the
* picker's pixmap.
*/
#ifdef GCP_PRISTINE_SOURCE
buf = g_malloc0 (COLOR_PICKER_WIDTH * COLOR_PICKER_HEIGHT * 3 * sizeof (guchar));
cp->im = gdk_imlib_create_image_from_data (buf, NULL, COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
g_free (buf);
gdk_imlib_render (cp->im, COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT);
cp->pixmap = gdk_imlib_copy_image (cp->im);
#else
cp->pixmap = gdk_pixmap_new( NULL, COLOR_PICKER_WIDTH, COLOR_PICKER_HEIGHT, gdk_visual_get_best_depth( ) );
#endif
cp->gc = gdk_gc_new (cp->pixmap);
if (stipple == NULL) {
stipple = gdk_bitmap_create_from_data (NULL,
gnome_color_picker_stipple_bits,
gnome_color_picker_stipple_width,
gnome_color_picker_stipple_height);
}
gtk_widget_pop_colormap ();
gtk_widget_pop_visual ();
/* Start with opaque black, dither on, alpha disabled */
cp->r = 0.0;
cp->g = 0.0;
cp->b = 0.0;
cp->a = 1.0;
cp->dither = TRUE;
cp->use_alpha = FALSE;
#ifndef GCP_PRISTINE_SOURCE
cp->dither = FALSE;
cp->c.pixel = 0;
#endif
}
static void
gnome_color_picker_destroy (GtkObject *object)
{
GnomeColorPicker *cp;
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (object));
cp = GNOME_COLOR_PICKER (object);
#ifdef GCP_PRISTINE_SOURCE
gdk_imlib_free_pixmap (cp->pixmap);
gdk_imlib_destroy_image (cp->im);
#else
gdk_pixmap_unref( cp->pixmap );
#endif
gdk_gc_destroy (cp->gc);
if (cp->cs_dialog)
gtk_widget_destroy (cp->cs_dialog);
if (cp->title)
g_free (cp->title);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/**
* gnome_color_picker_new
*
* Creates a new GNOME color picker widget. This returns a widget in the form of a small button
* containing a swatch representing the current selected color. When the button is clicked,
* a color-selection dialog will open, allowing the user to select a color. The swatch will be
* updated to reflect the new color when the user finishes.
*
* Returns:
* Pointer to new GNOME color picker widget.
*/
GtkWidget *
gnome_color_picker_new (void)
{
return GTK_WIDGET (gtk_type_new (gnome_color_picker_get_type ()));
}
/* Callback used when the color selection dialog is destroyed */
static gboolean
cs_destroy (GtkWidget *widget, gpointer data)
{
GnomeColorPicker *cp;
cp = GNOME_COLOR_PICKER (data);
cp->cs_dialog = NULL;
return FALSE;
}
/* Callback for when the OK button in the color selection dialog is clicked */
static void
cs_ok_clicked (GtkWidget *widget, gpointer data)
{
GnomeColorPicker *cp;
gdouble color[4];
gushort r, g, b, a;
cp = GNOME_COLOR_PICKER (data);
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (cp->cs_dialog)->colorsel),
color);
gtk_widget_destroy (cp->cs_dialog);
cp->r = color[0];
cp->g = color[1];
cp->b = color[2];
cp->a = cp->use_alpha ? color[3] : 1.0;
render (cp);
gtk_widget_draw (cp->da, NULL);
/* Notify the world that the color was set */
gnome_color_picker_get_i16 (cp, &r, &g, &b, &a);
gtk_signal_emit (GTK_OBJECT (cp), color_picker_signals[COLOR_SET],
r, g, b, a);
}
static int
key_pressed (GtkWidget *widget, GdkEventKey *event, GnomeColorPicker *cp)
{
if (event->keyval == GDK_Escape){
gtk_button_clicked (GTK_BUTTON (GTK_COLOR_SELECTION_DIALOG (widget)->cancel_button));
return 1;
}
return 0;
}
static void
gnome_color_picker_clicked (GtkButton *button)
{
GnomeColorPicker *cp;
GtkColorSelectionDialog *csd;
gdouble color[4];
g_return_if_fail (button != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (button));
cp = GNOME_COLOR_PICKER (button);
/*if dialog already exists, make sure it's shown and raised*/
if(cp->cs_dialog) {
csd = GTK_COLOR_SELECTION_DIALOG (cp->cs_dialog);
gtk_widget_show(cp->cs_dialog);
if(cp->cs_dialog->window)
gdk_window_raise(cp->cs_dialog->window);
} else {
/* Create the dialog and connects its buttons */
cp->cs_dialog = gtk_color_selection_dialog_new (cp->title);
csd = GTK_COLOR_SELECTION_DIALOG (cp->cs_dialog);
gtk_signal_connect (GTK_OBJECT (cp->cs_dialog), "destroy",
(GtkSignalFunc) cs_destroy,
cp);
gtk_signal_connect (GTK_OBJECT (cp->cs_dialog), "key_press_event",
(GtkSignalFunc) key_pressed, cp);
gtk_signal_connect (GTK_OBJECT (csd->ok_button), "clicked",
(GtkSignalFunc) cs_ok_clicked,
cp);
gtk_signal_connect_object (GTK_OBJECT (csd->cancel_button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT(cp->cs_dialog));
/* FIXME: do something about the help button */
#ifndef GCP_PRISTINE_SOURCE
gtk_widget_hide( csd->help_button ); /* How's this? :-) */
#endif
gtk_window_set_position (GTK_WINDOW (cp->cs_dialog), GTK_WIN_POS_MOUSE);
/* If there is a grabed window, set new dialog as modal */
if (gtk_grab_get_current())
gtk_window_set_modal(GTK_WINDOW(cp->cs_dialog),TRUE);
}
gtk_color_selection_set_opacity (GTK_COLOR_SELECTION (csd->colorsel), cp->use_alpha);
color[0] = cp->r;
color[1] = cp->g;
color[2] = cp->b;
color[3] = cp->use_alpha ? cp->a : 1.0;
/* Hack: we set the color twice so that GtkColorSelection will remember its history */
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel), color);
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel), color);
gtk_widget_show (cp->cs_dialog);
}
/**
* gnome_color_picker_set_d
* @cp: Pointer to GNOME color picker widget.
* @r: Red color component, values are in [0.0, 1.0]
* @g: Green color component, values are in [0.0, 1.0]
* @b: Blue color component, values are in [0.0, 1.0]
* @a: Alpha component, values are in [0.0, 1.0]
*
* Description:
* Set color shown in the color picker widget using floating point values.
*/
void
gnome_color_picker_set_d (GnomeColorPicker *cp, gdouble r, gdouble g, gdouble b, gdouble a)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
g_return_if_fail ((r >= 0.0) && (r <= 1.0));
g_return_if_fail ((g >= 0.0) && (g <= 1.0));
g_return_if_fail ((b >= 0.0) && (b <= 1.0));
g_return_if_fail ((a >= 0.0) && (a <= 1.0));
cp->r = r;
cp->g = g;
cp->b = b;
cp->a = a;
render (cp);
gtk_widget_draw (cp->da, NULL);
}
/**
* gnome_color_picker_get_d
* @cp: Pointer to GNOME color picker widget.
* @r: Output location of red color component, values are in [0.0, 1.0]
* @g: Output location of green color component, values are in [0.0, 1.0]
* @b: Output location of blue color component, values are in [0.0, 1.0]
* @a: Output location of alpha color component, values are in [0.0, 1.0]
*
* Description:
* Retrieve color currently selected in the color picker widget in the form of floating point values.
*/
void
gnome_color_picker_get_d (GnomeColorPicker *cp, gdouble *r, gdouble *g, gdouble *b, gdouble *a)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
if (r)
*r = cp->r;
if (g)
*g = cp->g;
if (b)
*b = cp->b;
if (a)
*a = cp->a;
}
/**
* gnome_color_picker_set_i8
* @cp: Pointer to GNOME color picker widget.
* @r: Red color component, values are in [0, 255]
* @g: Green color component, values are in [0, 255]
* @b: Blue color component, values are in [0, 255]
* @a: Alpha component, values are in [0, 255]
*
* Description:
* Set color shown in the color picker widget using 8-bit integer values.
*/
void
gnome_color_picker_set_i8 (GnomeColorPicker *cp, guint8 r, guint8 g, guint8 b, guint8 a)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
/* Don't check range of r,g,b,a since it's a 8 bit unsigned type. */
cp->r = r / 255.0;
cp->g = g / 255.0;
cp->b = b / 255.0;
cp->a = a / 255.0;
render (cp);
gtk_widget_draw (cp->da, NULL);
}
/**
* gnome_color_picker_get_i8
* @cp: Pointer to GNOME color picker widget.
* @r: Output location of red color component, values are in [0, 255]
* @g: Output location of green color component, values are in [0, 255]
* @b: Output location of blue color component, values are in [0, 255]
* @a: Output location of alpha color component, values are in [0, 255]
*
* Description:
* Retrieve color currently selected in the color picker widget in the form of 8-bit integer values.
*/
void
gnome_color_picker_get_i8 (GnomeColorPicker *cp, guint8 *r, guint8 *g, guint8 *b, guint8 *a)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
if (r)
*r = (guint8) (cp->r * 255.0 + 0.5);
if (g)
*g = (guint8) (cp->g * 255.0 + 0.5);
if (b)
*b = (guint8) (cp->b * 255.0 + 0.5);
if (a)
*a = (guint8) (cp->a * 255.0 + 0.5);
}
/**
* gnome_color_picker_set_i16
* @cp: Pointer to GNOME color picker widget.
* @r: Red color component, values are in [0, 65535]
* @g: Green color component, values are in [0, 65535]
* @b: Blue color component, values are in [0, 65535]
* @a: Alpha component, values are in [0, 65535]
*
* Description:
* Set color shown in the color picker widget using 16-bit integer values.
*/
void
gnome_color_picker_set_i16 (GnomeColorPicker *cp, gushort r, gushort g, gushort b, gushort a)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
/* Don't check range of r,g,b,a since it's a 16 bit unsigned type. */
cp->r = r / 65535.0;
cp->g = g / 65535.0;
cp->b = b / 65535.0;
cp->a = a / 65535.0;
render (cp);
gtk_widget_draw (cp->da, NULL);
}
/**
* gnome_color_picker_get_i16
* @cp: Pointer to GNOME color picker widget.
* @r: Output location of red color component, values are in [0, 65535]
* @g: Output location of green color component, values are in [0, 65535]
* @b: Output location of blue color component, values are in [0, 65535]
* @a: Output location of alpha color component, values are in [0, 65535]
*
* Description:
* Retrieve color currently selected in the color picker widget in the form of 16-bit integer values.
*/
void
gnome_color_picker_get_i16 (GnomeColorPicker *cp, gushort *r, gushort *g, gushort *b, gushort *a)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
if (r)
*r = (gushort) (cp->r * 65535.0 + 0.5);
if (g)
*g = (gushort) (cp->g * 65535.0 + 0.5);
if (b)
*b = (gushort) (cp->b * 65535.0 + 0.5);
if (a)
*a = (gushort) (cp->a * 65535.0 + 0.5);
}
/**
* gnome_color_picker_set_dither
* @cp: Pointer to GNOME color picker widget.
* @dither: %TRUE if color sample should be dithered, %FALSE if not.
*
* Description:
* Sets whether the picker should dither the color sample or just paint
* a solid rectangle.
*/
void
gnome_color_picker_set_dither (GnomeColorPicker *cp, gboolean dither)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
cp->dither = dither ? TRUE : FALSE;
render (cp);
gtk_widget_draw (cp->da, NULL);
}
/**
* gnome_color_picker_set_use_alpha
* @cp: Pointer to GNOME color picker widget.
* @use_alpha: %TRUE if color sample should use alpha channel, %FALSE if not.
*
* Description:
* Sets whether or not the picker should use the alpha channel.
*/
void
gnome_color_picker_set_use_alpha (GnomeColorPicker *cp, gboolean use_alpha)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
cp->use_alpha = use_alpha ? TRUE : FALSE;
render (cp);
gtk_widget_draw (cp->da, NULL);
}
/**
* gnome_color_picker_set_title
* @cp: Pointer to GNOME color picker widget.
* @title: String containing new window title.
*
* Description:
* Sets the title for the color selection dialog.
*/
void
gnome_color_picker_set_title (GnomeColorPicker *cp, const gchar *title)
{
g_return_if_fail (cp != NULL);
g_return_if_fail (GNOME_IS_COLOR_PICKER (cp));
if (cp->title)
g_free (cp->title);
cp->title = g_strdup (title);
if (cp->cs_dialog)
gtk_window_set_title (GTK_WINDOW (cp->cs_dialog), cp->title);
}
static void
gnome_color_picker_marshal_signal_1 (GtkObject *object, GtkSignalFunc func, gpointer func_data, GtkArg *args)
{
GnomeColorPickerSignal1 rfunc;
rfunc = (GnomeColorPickerSignal1) func;
(* rfunc) (object,
GTK_VALUE_UINT (args[0]),
GTK_VALUE_UINT (args[1]),
GTK_VALUE_UINT (args[2]),
GTK_VALUE_UINT (args[3]),
func_data);
}

View File

@ -1,101 +0,0 @@
/* Color picker button for GNOME
*
* Copyright (C) 1998 Red Hat Software, Inc.
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#ifndef GNOME_COLOR_PICKER_H
#define GNOME_COLOR_PICKER_H
/* #include <libgnome/gnome-defs.h> */
#include <gtk/gtkbutton.h>
/* #include <gdk_imlib.h> */
/* BEGIN_GNOME_DECLS */
/* The GnomeColorPicker widget is a simple color picker in a button. The button displays a sample
* of the currently selected color. When the user clicks on the button, a color selection dialog
* pops up. The color picker emits the "color_changed" signal when the color is set
*
* By default, the color picker does dithering when drawing the color sample box. This can be
* disabled for cases where it is useful to see the allocated color without dithering.
*/
#define GNOME_TYPE_COLOR_PICKER (gnome_color_picker_get_type ())
#define GNOME_COLOR_PICKER(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_COLOR_PICKER, GnomeColorPicker))
#define GNOME_COLOR_PICKER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_COLOR_PICKER, GnomeColorPickerClass))
#define GNOME_IS_COLOR_PICKER(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_COLOR_PICKER))
#define GNOME_IS_COLOR_PICKER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_COLOR_PICKER))
typedef struct _GnomeColorPicker GnomeColorPicker;
typedef struct _GnomeColorPickerClass GnomeColorPickerClass;
struct _GnomeColorPicker {
GtkButton button;
gdouble r, g, b, a; /* Red, green, blue, and alpha values */
#ifdef GCP_PRISTINE_SOURCE
GdkImlibImage *im; /* Imlib image for rendering dithered sample */
#else
GdkColor c; /* Color of sample */
#endif
GdkPixmap *pixmap; /* Pixmap with the sample contents */
GdkGC *gc; /* GC for drawing */
GtkWidget *da; /* Drawing area for color sample */
GtkWidget *cs_dialog; /* Color selection dialog */
gchar *title; /* Title for the color selection window */
guint dither : 1; /* Dither or just paint a solid color? */
guint use_alpha : 1; /* Use alpha or not */
};
struct _GnomeColorPickerClass {
GtkButtonClass parent_class;
/* Signal that is emitted when the color is set. The rgba values are in the [0, 65535]
* range. If you need a different color format, use the provided functions to get the
* values from the color picker.
*/
/* (should be gushort, but Gtk can't marshal that.) */
void (* color_set) (GnomeColorPicker *cp, guint r, guint g, guint b, guint a);
};
/* Standard Gtk function */
GtkType gnome_color_picker_get_type (void);
/* Creates a new color picker widget */
GtkWidget *gnome_color_picker_new (void);
/* Set/get the color in the picker. Values are in [0.0, 1.0] */
void gnome_color_picker_set_d (GnomeColorPicker *cp, gdouble r, gdouble g, gdouble b, gdouble a);
void gnome_color_picker_get_d (GnomeColorPicker *cp, gdouble *r, gdouble *g, gdouble *b, gdouble *a);
/* Set/get the color in the picker. Values are in [0, 255] */
void gnome_color_picker_set_i8 (GnomeColorPicker *cp, guint8 r, guint8 g, guint8 b, guint8 a);
void gnome_color_picker_get_i8 (GnomeColorPicker *cp, guint8 *r, guint8 *g, guint8 *b, guint8 *a);
/* Set/get the color in the picker. Values are in [0, 65535] */
void gnome_color_picker_set_i16 (GnomeColorPicker *cp, gushort r, gushort g, gushort b, gushort a);
void gnome_color_picker_get_i16 (GnomeColorPicker *cp, gushort *r, gushort *g, gushort *b, gushort *a);
/* Sets whether the picker should dither the color sample or just paint a solid rectangle */
void gnome_color_picker_set_dither (GnomeColorPicker *cp, gboolean dither);
/* Sets whether the picker should use the alpha channel or not */
void gnome_color_picker_set_use_alpha (GnomeColorPicker *cp, gboolean use_alpha);
/* Sets the title for the color selection dialog */
void gnome_color_picker_set_title (GnomeColorPicker *cp, const gchar *title);
/* END_GNOME_DECLS */
#endif

View File

@ -1,727 +0,0 @@
/*
* Date editor widget
* Copyright (C) 1998 the Free Software Foundation
*
* Author: Miguel de Icaza
*/
#include <config.h>
#include <string.h>
#include <stdlib.h> /* atoi */
#include <stdio.h>
#include <time.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "gnome-dateedit.h"
#include "gnome-i18nP.h"
/* #include <libgnomeui/gnome-stock.h> */
#include <ctype.h> /* isdigit */
enum {
DATE_CHANGED,
TIME_CHANGED,
LAST_SIGNAL
};
static guint date_edit_signals [LAST_SIGNAL] = { 0 };
static void gnome_date_edit_init (GnomeDateEdit *gde);
static void gnome_date_edit_class_init (GnomeDateEditClass *class);
static void gnome_date_edit_destroy (GtkObject *object);
static void gnome_date_edit_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callbabck_data);
static GtkHBoxClass *parent_class;
#ifndef GDE_PRISTINE_SOURCE
static char hide_popup_flag[] = "HideCalendarPopupOnButtonRelease";
#endif
/**
* gnome_date_edit_get_type:
*
* Returns the GtkType for the GnomeDateEdit widget
*/
guint
gnome_date_edit_get_type (void)
{
static guint date_edit_type = 0;
if (!date_edit_type){
GtkTypeInfo date_edit_info = {
"GnomeDateEdit",
sizeof (GnomeDateEdit),
sizeof (GnomeDateEditClass),
(GtkClassInitFunc) gnome_date_edit_class_init,
(GtkObjectInitFunc) gnome_date_edit_init,
NULL,
NULL,
};
date_edit_type = gtk_type_unique (gtk_hbox_get_type (), &date_edit_info);
}
return date_edit_type;
}
static void
hide_popup (GnomeDateEdit *gde)
{
gtk_widget_hide (gde->cal_popup);
gtk_grab_remove (gde->cal_popup);
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
static void
day_selected (GtkCalendar *calendar, GnomeDateEdit *gde)
{
char buffer [40];
guint year, month, day;
#ifndef GDE_PRISTINE_SOURCE
char *flag;
#endif
gtk_calendar_get_date (calendar, &year, &month, &day);
/* FIXME: internationalize this - strftime()*/
g_snprintf (buffer, sizeof(buffer), "%u/%u/%u", month + 1, day, year);
gtk_entry_set_text (GTK_ENTRY (gde->date_entry), buffer);
gtk_signal_emit (GTK_OBJECT (gde), date_edit_signals [DATE_CHANGED]);
#ifndef GDE_PRISTINE_SOURCE
flag = gtk_object_get_data( GTK_OBJECT(gde), hide_popup_flag );
if (*flag == 'o')
gtk_object_set_data( GTK_OBJECT(gde), hide_popup_flag, "1" );
if (*flag == 'i')
gtk_object_set_data( GTK_OBJECT(gde), hide_popup_flag, "o" );
#endif
}
static void
day_selected_double_click (GtkCalendar *calendar, GnomeDateEdit *gde)
{
hide_popup (gde);
}
#ifndef GDE_PRISTINE_SOURCE
static void
year_or_month_changed( GtkCalendar *unused, GnomeDateEdit *gde )
{
char *flag;
flag = gtk_object_get_data( GTK_OBJECT(gde), hide_popup_flag );
if (*flag == 'o')
gtk_object_set_data( GTK_OBJECT(gde), hide_popup_flag, "0" );
}
static gint
button_release_calendar( GtkCalendar *unused1, GdkEventButton *unused2, GnomeDateEdit *gde )
{
char *flag;
flag = gtk_object_get_data( GTK_OBJECT(gde), hide_popup_flag );
if (*flag == '1') {
hide_popup( gde );
gtk_object_set_data( GTK_OBJECT(gde), hide_popup_flag, "i" );
}
else
gtk_object_set_data( GTK_OBJECT(gde), hide_popup_flag, "o" );
return FALSE;
}
#endif /* not GDE_PRISTINE_SOURCE */
static gint
delete_popup (GtkWidget *widget, gpointer data)
{
GnomeDateEdit *gde;
gde = data;
hide_popup (gde);
return TRUE;
}
static gint
key_press_popup (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
GnomeDateEdit *gde;
if (event->keyval != GDK_Escape)
return FALSE;
gde = data;
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
hide_popup (gde);
return TRUE;
}
/* This function is yanked from gtkcombo.c */
static gint
button_press_popup (GtkWidget *widget, GdkEventButton *event, gpointer data)
{
GnomeDateEdit *gde;
GtkWidget *child;
gde = data;
child = gtk_get_event_widget ((GdkEvent *) event);
/* We don't ask for button press events on the grab widget, so
* if an event is reported directly to the grab widget, it must
* be on a window outside the application (and thus we remove
* the popup window). Otherwise, we check if the widget is a child
* of the grab widget, and only remove the popup window if it
* is not.
*/
if (child != widget) {
while (child) {
if (child == widget)
return FALSE;
child = child->parent;
}
}
hide_popup (gde);
return TRUE;
}
static void
position_popup (GnomeDateEdit *gde)
{
gint x, y;
gint bwidth, bheight;
gtk_widget_size_request (gde->cal_popup, &gde->cal_popup->requisition);
gdk_window_get_origin (gde->date_button->window, &x, &y);
gdk_window_get_size (gde->date_button->window, &bwidth, &bheight);
x += bwidth - gde->cal_popup->requisition.width;
y += bheight;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
gtk_widget_set_uposition (gde->cal_popup, x, y);
}
static void
select_clicked (GtkWidget *widget, GnomeDateEdit *gde)
{
struct tm mtm;
GdkCursor *cursor;
/* This code is pretty much just copied from gtk_date_edit_get_date */
sscanf (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), "%d/%d/%d",
&mtm.tm_mon, &mtm.tm_mday, &mtm.tm_year); /* FIXME: internationalize this - strptime()*/
mtm.tm_mon--;
/* Hope the user does not actually mean years early in the A.D. days...
* This date widget will obviously not work for a history program :-)
*/
if (mtm.tm_year >= 1900)
mtm.tm_year -= 1900;
gtk_calendar_select_month (GTK_CALENDAR (gde->calendar), mtm.tm_mon, 1900 + mtm.tm_year);
gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), mtm.tm_mday);
position_popup (gde);
gtk_widget_show (gde->cal_popup);
gtk_widget_grab_focus (gde->cal_popup);
gtk_grab_add (gde->cal_popup);
cursor = gdk_cursor_new (GDK_ARROW);
gdk_pointer_grab (gde->cal_popup->window, TRUE,
(GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK),
NULL, cursor, GDK_CURRENT_TIME);
gdk_cursor_destroy (cursor);
}
typedef struct {
char *hour;
GnomeDateEdit *gde;
} hour_info_t;
static void
set_time (GtkWidget *widget, hour_info_t *hit)
{
gtk_entry_set_text (GTK_ENTRY (hit->gde->time_entry), hit->hour);
gtk_signal_emit (GTK_OBJECT (hit->gde), date_edit_signals [TIME_CHANGED]);
}
static void
free_resources (GtkWidget *widget, hour_info_t *hit)
{
g_free (hit->hour);
g_free (hit);
}
static void
fill_time_popup (GtkWidget *widget, GnomeDateEdit *gde)
{
GtkWidget *menu;
struct tm *mtm;
time_t current_time;
int i, j;
if (gde->lower_hour > gde->upper_hour)
return;
menu = gtk_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (gde->time_popup), menu);
time (&current_time);
mtm = localtime (&current_time);
for (i = gde->lower_hour; i <= gde->upper_hour; i++){
GtkWidget *item, *submenu;
hour_info_t *hit;
char buffer [40];
mtm->tm_hour = i;
mtm->tm_min = 0;
hit = g_new (hour_info_t, 1);
if (gde->flags & GNOME_DATE_EDIT_24_HR)
strftime (buffer, sizeof (buffer), "%H:00", mtm);
else
strftime (buffer, sizeof (buffer), "%I:00 %p ", mtm);
hit->hour = g_strdup (buffer);
hit->gde = gde;
item = gtk_menu_item_new_with_label (buffer);
gtk_menu_append (GTK_MENU (menu), item);
#if 0
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (set_time), hit);
#endif
gtk_signal_connect (GTK_OBJECT (item), "destroy",
GTK_SIGNAL_FUNC (free_resources), hit);
gtk_widget_show (item);
submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
for (j = 0; j < 60; j += 15){
GtkWidget *mins;
mtm->tm_min = j;
hit = g_new (hour_info_t, 1);
if (gde->flags & GNOME_DATE_EDIT_24_HR)
strftime (buffer, sizeof (buffer), "%H:%M", mtm);
else
strftime (buffer, sizeof (buffer), "%I:%M %p", mtm);
hit->hour = g_strdup (buffer);
hit->gde = gde;
mins = gtk_menu_item_new_with_label (buffer);
gtk_menu_append (GTK_MENU (submenu), mins);
gtk_signal_connect (GTK_OBJECT (mins), "activate",
GTK_SIGNAL_FUNC (set_time), hit);
gtk_signal_connect (GTK_OBJECT (item), "destroy",
GTK_SIGNAL_FUNC (free_resources), hit);
gtk_widget_show (mins);
}
}
}
static void
gnome_date_edit_class_init (GnomeDateEditClass *class)
{
GtkObjectClass *object_class = (GtkObjectClass *) class;
GtkContainerClass *container_class = (GtkContainerClass *) class;
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gtk_hbox_get_type ());
date_edit_signals [TIME_CHANGED] =
gtk_signal_new ("time_changed",
GTK_RUN_FIRST, object_class->type,
GTK_SIGNAL_OFFSET (GnomeDateEditClass, time_changed),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
date_edit_signals [DATE_CHANGED] =
gtk_signal_new ("date_changed",
GTK_RUN_FIRST, object_class->type,
GTK_SIGNAL_OFFSET (GnomeDateEditClass, date_changed),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, date_edit_signals, LAST_SIGNAL);
container_class->forall = gnome_date_edit_forall;
object_class->destroy = gnome_date_edit_destroy;
class->date_changed = NULL;
class->time_changed = NULL;
}
static void
gnome_date_edit_init (GnomeDateEdit *gde)
{
gde->lower_hour = 7;
gde->upper_hour = 19;
gde->flags = GNOME_DATE_EDIT_SHOW_TIME;
}
static void
gnome_date_edit_destroy (GtkObject *object)
{
GnomeDateEdit *gde;
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_DATE_EDIT (object));
gde = GNOME_DATE_EDIT (object);
gtk_widget_destroy (gde->cal_popup);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gnome_date_edit_forall (GtkContainer *container, gboolean include_internals,
GtkCallback callback, gpointer callback_data)
{
g_return_if_fail (container != NULL);
g_return_if_fail (GNOME_IS_DATE_EDIT (container));
g_return_if_fail (callback != NULL);
/* Let GtkBox handle things only if the internal widgets need to be
* poked.
*/
if (include_internals)
if (GTK_CONTAINER_CLASS (parent_class)->forall)
(* GTK_CONTAINER_CLASS (parent_class)->forall) (container,
include_internals,
callback,
callback_data);
}
/**
* gnome_date_edit_set_time:
* @gde: the GnomeDateEdit widget
* @the_time: The time and date that should be set on the widget
*
* Changes the displayed date and time in the GnomeDateEdit widget
* to be the one represented by @the_time.
*/
void
gnome_date_edit_set_time (GnomeDateEdit *gde, time_t the_time)
{
struct tm *mytm;
char buffer [40];
g_return_if_fail(gde != NULL);
if (the_time == 0)
the_time = time (NULL);
gde->initial_time = the_time;
mytm = localtime (&the_time);
/* Set the date */
g_snprintf (buffer, sizeof(buffer), "%d/%d/%d",
mytm->tm_mon + 1,
mytm->tm_mday,
1900 + mytm->tm_year);
gtk_entry_set_text (GTK_ENTRY (gde->date_entry), buffer);
/* Set the time */
if (gde->flags & GNOME_DATE_EDIT_24_HR)
strftime (buffer, sizeof (buffer), "%H:%M", mytm);
else
strftime (buffer, sizeof (buffer), "%I:%M %p", mytm);
gtk_entry_set_text (GTK_ENTRY (gde->time_entry), buffer);
}
/**
* gnome_date_edit_set_popup_range:
* @gde: The GnomeDateEdit widget
* @low_hour: low boundary for the time-range display popup.
* @up_hour: upper boundary for the time-range display popup.
*
* Sets the range of times that will be provide by the time popup
* selectors.
*/
void
gnome_date_edit_set_popup_range (GnomeDateEdit *gde, int low_hour, int up_hour)
{
g_return_if_fail(gde != NULL);
gde->lower_hour = low_hour;
gde->upper_hour = up_hour;
fill_time_popup(NULL, gde);
}
static void
create_children (GnomeDateEdit *gde)
{
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *arrow;
gde->date_entry = gtk_entry_new ();
gtk_widget_set_usize (gde->date_entry, 90, 0);
gtk_box_pack_start (GTK_BOX (gde), gde->date_entry, TRUE, TRUE, 0);
gtk_widget_show (gde->date_entry);
gde->date_button = gtk_button_new ();
gtk_signal_connect (GTK_OBJECT (gde->date_button), "clicked",
GTK_SIGNAL_FUNC (select_clicked), gde);
gtk_box_pack_start (GTK_BOX (gde), gde->date_button, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 3);
gtk_container_add (GTK_CONTAINER (gde->date_button), hbox);
gtk_widget_show (hbox);
/* Calendar label, only shown if the date editor has a time field */
gde->cal_label = gtk_label_new (_("Calendar"));
gtk_misc_set_alignment (GTK_MISC (gde->cal_label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), gde->cal_label, TRUE, TRUE, 0);
if (gde->flags & GNOME_DATE_EDIT_SHOW_TIME)
gtk_widget_show (gde->cal_label);
arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
gtk_widget_show (arrow);
gtk_widget_show (gde->date_button);
gde->time_entry = gtk_entry_new_with_max_length (12);
gtk_widget_set_usize (gde->time_entry, 88, 0);
gtk_box_pack_start (GTK_BOX (gde), gde->time_entry, TRUE, TRUE, 0);
gde->time_popup = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (gde), gde->time_popup, FALSE, FALSE, 0);
/* We do not create the popup menu with the hour range until we are
* realized, so that it uses the values that the user might supply in a
* future call to gnome_date_edit_set_popup_range
*/
gtk_signal_connect (GTK_OBJECT (gde), "realize",
GTK_SIGNAL_FUNC (fill_time_popup), gde);
if (gde->flags & GNOME_DATE_EDIT_SHOW_TIME) {
gtk_widget_show (gde->time_entry);
gtk_widget_show (gde->time_popup);
}
gde->cal_popup = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_events (gde->cal_popup,
gtk_widget_get_events (gde->cal_popup) | GDK_KEY_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (gde->cal_popup), "delete_event",
(GtkSignalFunc) delete_popup,
gde);
gtk_signal_connect (GTK_OBJECT (gde->cal_popup), "key_press_event",
(GtkSignalFunc) key_press_popup,
gde);
gtk_signal_connect (GTK_OBJECT (gde->cal_popup), "button_press_event",
(GtkSignalFunc) button_press_popup,
gde);
gtk_window_set_policy (GTK_WINDOW (gde->cal_popup), FALSE, FALSE, TRUE);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (gde->cal_popup), frame);
gtk_widget_show (frame);
gde->calendar = gtk_calendar_new ();
gtk_calendar_display_options (GTK_CALENDAR (gde->calendar),
(GTK_CALENDAR_SHOW_DAY_NAMES
| GTK_CALENDAR_SHOW_HEADING
| ((gde->flags & GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY)
? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
gtk_signal_connect (GTK_OBJECT (gde->calendar), "day_selected",
GTK_SIGNAL_FUNC (day_selected), gde);
gtk_signal_connect (GTK_OBJECT (gde->calendar), "day_selected_double_click",
GTK_SIGNAL_FUNC (day_selected_double_click), gde);
#ifndef GDE_PRISTINE_SOURCE
gtk_signal_connect( GTK_OBJECT(gde->calendar), "month_changed", GTK_SIGNAL_FUNC(year_or_month_changed), gde );
gtk_signal_connect( GTK_OBJECT(gde->calendar), "prev_year", GTK_SIGNAL_FUNC(year_or_month_changed), gde );
gtk_signal_connect( GTK_OBJECT(gde->calendar), "next_year", GTK_SIGNAL_FUNC(year_or_month_changed), gde );
gtk_signal_connect( GTK_OBJECT(gde->calendar), "button_release_event", GTK_SIGNAL_FUNC(button_release_calendar), gde );
gtk_object_set_data( GTK_OBJECT(gde), hide_popup_flag, "i" );
#endif
gtk_container_add (GTK_CONTAINER (frame), gde->calendar);
gtk_widget_show (gde->calendar);
}
/**
* gnome_date_edit_new:
* @the_time: date and time to be displayed on the widget
* @show_time: whether time should be displayed
* @use_24_format: whether 24-hour format is desired for the time display.
*
* Creates a new GnomeDateEdit widget which can be used to provide
* an easy to use way for entering dates and times.
*
* Returns a GnomeDateEdit widget.
*/
GtkWidget *
gnome_date_edit_new (time_t the_time, int show_time, int use_24_format)
{
return gnome_date_edit_new_flags (the_time,
((show_time ? GNOME_DATE_EDIT_SHOW_TIME : 0)
| (use_24_format ? GNOME_DATE_EDIT_24_HR : 0)));
}
/**
* gnome_date_edit_new_flags:
* @the_time: The initial time for the date editor.
* @flags: A bitmask of GnomeDateEditFlags values.
*
* Creates a new GnomeDateEdit widget with the specified flags.
*
* Return value: the newly-created date editor widget.
**/
GtkWidget *
gnome_date_edit_new_flags (time_t the_time, GnomeDateEditFlags flags)
{
GnomeDateEdit *gde;
gde = gtk_type_new (gnome_date_edit_get_type ());
gde->flags = flags;
create_children (gde);
gnome_date_edit_set_time (gde, the_time);
return GTK_WIDGET (gde);
}
/**
* gnome_date_edit_get_date:
* @gde: The GnomeDateEdit widget
*
* Returns the time entered in the GnomeDateEdit widget
*/
time_t
gnome_date_edit_get_date (GnomeDateEdit *gde)
{
struct tm tm = {0};
char *str, *flags = NULL;
/* Assert, because we're just hosed if it's NULL */
g_assert(gde != NULL);
g_assert(GNOME_IS_DATE_EDIT(gde));
sscanf (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), "%d/%d/%d",
&tm.tm_mon, &tm.tm_mday, &tm.tm_year); /* FIXME: internationalize this - strptime()*/
tm.tm_mon--;
/* Hope the user does not actually mean years early in the A.D. days...
* This date widget will obviously not work for a history program :-)
*/
if (tm.tm_year >= 1900)
tm.tm_year -= 1900;
if (gde->flags & GNOME_DATE_EDIT_SHOW_TIME) {
char *tokp, *temp;
str = g_strdup (gtk_entry_get_text (GTK_ENTRY (gde->time_entry)));
temp = strtok_r (str, ": ", &tokp);
if (temp) {
tm.tm_hour = atoi (temp);
temp = strtok_r (NULL, ": ", &tokp);
if (temp) {
if (isdigit (*temp)) {
tm.tm_min = atoi (temp);
flags = strtok_r (NULL, ": ", &tokp);
if (flags && isdigit (*flags)) {
tm.tm_sec = atoi (flags);
flags = strtok_r (NULL, ": ", &tokp);
}
} else
flags = temp;
}
}
if (flags && (strcasecmp (flags, "PM") == 0)){
if (tm.tm_hour < 12)
tm.tm_hour += 12;
}
g_free (str);
}
tm.tm_isdst = -1;
return mktime (&tm);
}
/**
* gnome_date_edit_set_flags:
* @gde: The date editor widget whose flags should be changed.
* @flags: The new bitmask of GnomeDateEditFlags values.
*
* Changes the display flags on an existing date editor widget.
**/
void
gnome_date_edit_set_flags (GnomeDateEdit *gde, GnomeDateEditFlags flags)
{
GnomeDateEditFlags old_flags;
g_return_if_fail (gde != NULL);
g_return_if_fail (GNOME_IS_DATE_EDIT (gde));
old_flags = gde->flags;
gde->flags = flags;
if ((flags & GNOME_DATE_EDIT_SHOW_TIME) != (old_flags & GNOME_DATE_EDIT_SHOW_TIME)) {
if (flags & GNOME_DATE_EDIT_SHOW_TIME) {
gtk_widget_show (gde->cal_label);
gtk_widget_show (gde->time_entry);
gtk_widget_show (gde->time_popup);
} else {
gtk_widget_hide (gde->cal_label);
gtk_widget_hide (gde->time_entry);
gtk_widget_hide (gde->time_popup);
}
}
if ((flags & GNOME_DATE_EDIT_24_HR) != (old_flags & GNOME_DATE_EDIT_24_HR))
fill_time_popup (GTK_WIDGET (gde), gde); /* This will destroy the old menu properly */
if ((flags & GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY)
!= (old_flags & GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY)) {
if (flags & GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY)
gtk_calendar_display_options (GTK_CALENDAR (gde->calendar),
(GTK_CALENDAR (gde->calendar)->display_flags
| GTK_CALENDAR_WEEK_START_MONDAY));
else
gtk_calendar_display_options (GTK_CALENDAR (gde->calendar),
(GTK_CALENDAR (gde->calendar)->display_flags
& ~GTK_CALENDAR_WEEK_START_MONDAY));
}
}
/**
* gnome_date_edit_get_flags:
* @gde: The date editor whose flags should be queried.
*
* Queries the display flags on a date editor widget.
*
* Return value: The current display flags for the specified date editor widget.
**/
int
gnome_date_edit_get_flags (GnomeDateEdit *gde)
{
g_return_val_if_fail (gde != NULL, 0);
g_return_val_if_fail (GNOME_IS_DATE_EDIT (gde), 0);
return gde->flags;
}

View File

@ -1,60 +0,0 @@
#ifndef __GNOME_DATE_EDIT_H_
#define __GNOME_DATE_EDIT_H_
#include <gtk/gtkhbox.h>
/* #include <libgnome/gnome-defs.h> */
/* BEGIN_GNOME_DECLS */
typedef enum {
GNOME_DATE_EDIT_SHOW_TIME = 1 << 0,
GNOME_DATE_EDIT_24_HR = 1 << 1,
GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY = 1 << 2
} GnomeDateEditFlags;
#define GNOME_DATE_EDIT(obj) GTK_CHECK_CAST (obj, gnome_date_edit_get_type(), GnomeDateEdit)
#define GNOME_DATE_EDIT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gnome_date_edit_get_type(), GnomeDateEditClass)
#define GNOME_IS_DATE_EDIT(obj) GTK_CHECK_TYPE (obj, gnome_date_edit_get_type ())
typedef struct {
GtkHBox hbox;
GtkWidget *date_entry;
GtkWidget *date_button;
GtkWidget *time_entry;
GtkWidget *time_popup;
GtkWidget *cal_label;
GtkWidget *cal_popup;
GtkWidget *calendar;
int lower_hour;
int upper_hour;
time_t initial_time;
int flags;
} GnomeDateEdit;
typedef struct {
GtkHBoxClass parent_class;
void (*date_changed) (GnomeDateEdit *gde);
void (*time_changed) (GnomeDateEdit *gde);
} GnomeDateEditClass;
guint gnome_date_edit_get_type (void);
GtkWidget *gnome_date_edit_new (time_t the_time, int show_time, int use_24_format);
GtkWidget *gnome_date_edit_new_flags (time_t the_time, GnomeDateEditFlags flags);
void gnome_date_edit_set_time (GnomeDateEdit *gde, time_t the_time);
void gnome_date_edit_set_popup_range (GnomeDateEdit *gde, int low_hour, int up_hour);
time_t gnome_date_edit_get_date (GnomeDateEdit *gde);
void gnome_date_edit_set_flags (GnomeDateEdit *gde, GnomeDateEditFlags flags);
int gnome_date_edit_get_flags (GnomeDateEdit *gde);
/* END_GNOME_DECLS */
#endif

View File

@ -1,44 +0,0 @@
/*
* Handles i18n for the Gnome libraries. Libraries need to use
* dgettext in order to use a non-default translation domain.
* Author: Tom Tromey <tromey@creche.cygnus.com>
*/
#ifndef __GNOME_I18NP_H__
#define __GNOME_I18NP_H__
#ifdef __GNOME_I18N_H__
/* #warning "You should use either gnome-i18n.h OR gnome-i18nP.h" */
#endif
/* BEGIN_GNOME_DECLS */
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
/* Stubs that do something close enough. */
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
const char *gnome_i18n_get_language(void);
GList *gnome_i18n_get_language_list (const gchar *category_name);
void gnome_i18n_init (void);
void gnome_i18n_set_preferred_language (const char *val);
const char *gnome_i18n_get_preferred_language (void);
/* END_GNOME_DECLS */
#endif /* __GNOME_UTIL_H__ */

View File

@ -59,7 +59,6 @@ fsv_SOURCES = \
fsv_LDADD = \
$(DEBUG_LIBS) \
$(top_builddir)/lib/libgnomeui.a \
$(top_builddir)/lib/libmisc.a \
@GTKGL_LIBS@ \
@GL_LIBS@ \

View File

@ -924,34 +924,6 @@ g_list_replace( GList *list, gpointer old_data, gpointer new_data )
}
/* GLib-style routine. Inserts a new element "data" into a list, before the
* element "before_data". If "before_data" is NULL, then the new element is
* added to the end of the list. Returns the updated list */
GList *
g_list_insert_before( GList *list, gpointer before_data, gpointer data )
{
GList *before_llink;
GList *new_llink;
GList *updated_list;
g_return_val_if_fail( list != NULL, NULL );
if (before_data == NULL)
updated_list = g_list_append( list, data );
else {
before_llink = g_list_find( list, before_data );
g_return_val_if_fail( before_llink != NULL, list );
new_llink = g_list_prepend( before_llink, data );
if (before_llink == list)
updated_list = new_llink;
else
updated_list = list;
}
return updated_list;
}
/* The wrong way out */
void
quit( char *message )

View File

@ -323,7 +323,6 @@ RGBcolor hex2rgb( const char *hex_color );
RGBcolor rainbow_color( double x );
RGBcolor heat_color( double x );
GList *g_list_replace( GList *list, gpointer old_data, gpointer new_data );
GList *g_list_insert_before( GList *list, gpointer before_data, gpointer data );
int gnome_config_get_token( const char *path, const char **tokens );
void gnome_config_set_token( const char *path, int new_value, const char **tokens );
void quit( char *message );

BIN
src/common.o Normal file

Binary file not shown.