|
|
|
@ -1,833 +0,0 @@
|
|
|
|
|
Index: eel/Makefile.am
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: /cvs/gnome/eel/eel/Makefile.am,v
|
|
|
|
|
retrieving revision 1.61
|
|
|
|
|
retrieving revision 1.62
|
|
|
|
|
diff -d -u -r1.61 -r1.62
|
|
|
|
|
--- eel/Makefile.am 3 Jul 2002 05:18:33 -0000 1.61
|
|
|
|
|
+++ eel/Makefile.am 24 Jul 2002 20:19:50 -0000 1.62
|
|
|
|
|
@@ -29,7 +29,7 @@
|
|
|
|
|
eel-art-extensions.c \
|
|
|
|
|
eel-art-gtk-extensions.c \
|
|
|
|
|
eel-background.c \
|
|
|
|
|
- eel-background-style.c \
|
|
|
|
|
+ eel-background-box.c \
|
|
|
|
|
eel-canvas-rect.c \
|
|
|
|
|
eel-caption-table.c \
|
|
|
|
|
eel-caption.c \
|
|
|
|
|
@@ -83,7 +83,7 @@
|
|
|
|
|
eel-art-extensions.h \
|
|
|
|
|
eel-art-gtk-extensions.h \
|
|
|
|
|
eel-background.h \
|
|
|
|
|
- eel-background-style.h \
|
|
|
|
|
+ eel-background-box.h \
|
|
|
|
|
eel-canvas-rect.h \
|
|
|
|
|
eel-caption-table.h \
|
|
|
|
|
eel-caption.h \
|
|
|
|
|
Index: eel/eel-background-box.c
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: eel/eel-background-box.c
|
|
|
|
|
diff -N eel/eel-background-box.c
|
|
|
|
|
--- /dev/null 1 Jan 1970 00:00:00 -0000
|
|
|
|
|
+++ eel/eel-background-box.c 24 Jul 2002 20:19:51 -0000 1.1
|
|
|
|
|
@@ -0,0 +1,70 @@
|
|
|
|
|
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
|
|
|
|
+
|
|
|
|
|
+/* eel-background-box.c - an event box that renders an eel background
|
|
|
|
|
+
|
|
|
|
|
+ Copyright (C) 2002 Sun Microsystems, Inc.
|
|
|
|
|
+
|
|
|
|
|
+ The Gnome 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.
|
|
|
|
|
+
|
|
|
|
|
+ The Gnome 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 the Gnome Library; see the file COPYING.LIB. If not,
|
|
|
|
|
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
+ Boston, MA 02111-1307, USA.
|
|
|
|
|
+
|
|
|
|
|
+ Author: Dave Camp <dave@ximian.com>
|
|
|
|
|
+*/
|
|
|
|
|
+
|
|
|
|
|
+#include <config.h>
|
|
|
|
|
+#include "eel-background-box.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "eel-gtk-macros.h"
|
|
|
|
|
+#include "eel-background.h"
|
|
|
|
|
+
|
|
|
|
|
+static void eel_background_box_class_init (EelBackgroundBoxClass *background_box_class);
|
|
|
|
|
+static void eel_background_box_init (EelBackgroundBox *background);
|
|
|
|
|
+
|
|
|
|
|
+EEL_CLASS_BOILERPLATE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX)
|
|
|
|
|
+
|
|
|
|
|
+static gboolean
|
|
|
|
|
+eel_background_box_expose_event (GtkWidget *widget,
|
|
|
|
|
+ GdkEventExpose *event)
|
|
|
|
|
+{
|
|
|
|
|
+ eel_background_expose (widget, event);
|
|
|
|
|
+
|
|
|
|
|
+ gtk_container_propagate_expose (GTK_CONTAINER (widget),
|
|
|
|
|
+ GTK_BIN (widget)->child,
|
|
|
|
|
+ event);
|
|
|
|
|
+
|
|
|
|
|
+ return TRUE;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+eel_background_box_class_init (EelBackgroundBoxClass *klass)
|
|
|
|
|
+{
|
|
|
|
|
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
+
|
|
|
|
|
+ widget_class->expose_event = eel_background_box_expose_event;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+eel_background_box_init (EelBackgroundBox *box)
|
|
|
|
|
+{
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+GtkWidget*
|
|
|
|
|
+eel_background_box_new (void)
|
|
|
|
|
+{
|
|
|
|
|
+ EelBackgroundBox *background_box;
|
|
|
|
|
+
|
|
|
|
|
+ background_box = EEL_BACKGROUND_BOX (gtk_widget_new (eel_background_box_get_type (), NULL));
|
|
|
|
|
+
|
|
|
|
|
+ return GTK_WIDGET (background_box);
|
|
|
|
|
+}
|
|
|
|
|
Index: eel/eel-background-box.h
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: eel/eel-background-box.h
|
|
|
|
|
diff -N eel/eel-background-box.h
|
|
|
|
|
--- /dev/null 1 Jan 1970 00:00:00 -0000
|
|
|
|
|
+++ eel/eel-background-box.h 24 Jul 2002 20:19:51 -0000 1.1
|
|
|
|
|
@@ -0,0 +1,61 @@
|
|
|
|
|
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
|
|
|
|
+
|
|
|
|
|
+/* eel-background-box.c - an event box that renders an eel background
|
|
|
|
|
+
|
|
|
|
|
+ Copyright (C) 2002 Sun Microsystems, Inc.
|
|
|
|
|
+
|
|
|
|
|
+ The Gnome 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.
|
|
|
|
|
+
|
|
|
|
|
+ The Gnome 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 the Gnome Library; see the file COPYING.LIB. If not,
|
|
|
|
|
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
+ Boston, MA 02111-1307, USA.
|
|
|
|
|
+
|
|
|
|
|
+ Author: Dave Camp <dave@ximian.com>
|
|
|
|
|
+*/
|
|
|
|
|
+
|
|
|
|
|
+#ifndef EEL_BACKGROUND_BOX_H
|
|
|
|
|
+#define EEL_BACKGROUND_BOX_H
|
|
|
|
|
+
|
|
|
|
|
+#include <glib.h>
|
|
|
|
|
+#include <gtk/gtkeventbox.h>
|
|
|
|
|
+
|
|
|
|
|
+G_BEGIN_DECLS
|
|
|
|
|
+
|
|
|
|
|
+#define EEL_TYPE_BACKGROUND_BOX (eel_background_box_get_type ())
|
|
|
|
|
+#define EEL_BACKGROUND_BOX(obj) (GTK_CHECK_CAST ((obj), EEL_TYPE_BACKGROUND_BOX, EelBackgroundBox))
|
|
|
|
|
+#define EEL_BACKGROUND_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EEL_TYPE_BACKGROUND_BOX, EelBackgroundBoxClass))
|
|
|
|
|
+#define EEL_IS_BACKGROUND_BOX(obj) (GTK_CHECK_TYPE ((obj), EEL_TYPE_BACKGROUND_BOX))
|
|
|
|
|
+#define EEL_IS_BACKGROUND_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EEL_TYPE_BACKGROUND_BOX))
|
|
|
|
|
+
|
|
|
|
|
+typedef struct EelBackgroundBox EelBackgroundBox;
|
|
|
|
|
+typedef struct EelBackgroundBoxClass EelBackgroundBoxClass;
|
|
|
|
|
+typedef struct EelBackgroundBoxDetails EelBackgroundBoxDetails;
|
|
|
|
|
+
|
|
|
|
|
+struct EelBackgroundBox
|
|
|
|
|
+{
|
|
|
|
|
+ /* Superclass */
|
|
|
|
|
+ GtkEventBox event_box;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+struct EelBackgroundBoxClass
|
|
|
|
|
+{
|
|
|
|
|
+ GtkEventBoxClass parent_class;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+GtkType eel_background_box_get_type (void);
|
|
|
|
|
+GtkWidget *eel_background_box_new (void);
|
|
|
|
|
+
|
|
|
|
|
+G_END_DECLS
|
|
|
|
|
+
|
|
|
|
|
+#endif /* EEL_BACKGROUND_TABLE_H */
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
Index: eel/eel-background-style.c
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: eel/eel-background-style.c
|
|
|
|
|
diff -N eel/eel-background-style.c
|
|
|
|
|
--- eel/eel-background-style.c 17 May 2002 10:38:08 -0000 1.6
|
|
|
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
|
|
|
@@ -1,236 +0,0 @@
|
|
|
|
|
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
|
|
|
|
-
|
|
|
|
|
- eel-background-style.c: Style subclass used by EelBackground.
|
|
|
|
|
-
|
|
|
|
|
- Copyright (C) 2001 Bent Spoon Software
|
|
|
|
|
-
|
|
|
|
|
- This program 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 program is distributed in the hope that it will be useful,
|
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
- Library General Public License for more details.
|
|
|
|
|
-
|
|
|
|
|
- You should have received a copy of the GNU Library General Public
|
|
|
|
|
- License along with this program; if not, write to the
|
|
|
|
|
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
- Boston, MA 02111-1307, USA.
|
|
|
|
|
-
|
|
|
|
|
- Author: Darin Adler <darin@bentspoon.com>
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
-#include <config.h>
|
|
|
|
|
-#include "eel-background-style.h"
|
|
|
|
|
-
|
|
|
|
|
-#include "eel-gdk-extensions.h"
|
|
|
|
|
-#include <gtk/gtktreeview.h>
|
|
|
|
|
-#include <libgnome/gnome-macros.h>
|
|
|
|
|
-
|
|
|
|
|
-GNOME_CLASS_BOILERPLATE (EelBackgroundStyle, eel_background_style,
|
|
|
|
|
- GtkStyle, GTK_TYPE_STYLE)
|
|
|
|
|
-
|
|
|
|
|
-struct EelBackgroundStyleDetails {
|
|
|
|
|
- EelBackground *background;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_style_instance_init (EelBackgroundStyle *style)
|
|
|
|
|
-{
|
|
|
|
|
- style->details = g_new0 (EelBackgroundStyleDetails, 1);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_style_finalize (GObject *object)
|
|
|
|
|
-{
|
|
|
|
|
- EelBackgroundStyle *style;
|
|
|
|
|
-
|
|
|
|
|
- style = EEL_BACKGROUND_STYLE (object);
|
|
|
|
|
-
|
|
|
|
|
- if (style->details->background) {
|
|
|
|
|
- g_object_unref (style->details->background);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- g_free (style->details);
|
|
|
|
|
-
|
|
|
|
|
- GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_style_draw_flat_box (GtkStyle *style,
|
|
|
|
|
- GdkWindow *window,
|
|
|
|
|
- GtkStateType state_type,
|
|
|
|
|
- GtkShadowType shadow_type,
|
|
|
|
|
- GdkRectangle *area,
|
|
|
|
|
- GtkWidget *widget,
|
|
|
|
|
- const char *detail,
|
|
|
|
|
- int x,
|
|
|
|
|
- int y,
|
|
|
|
|
- int width,
|
|
|
|
|
- int height)
|
|
|
|
|
-{
|
|
|
|
|
- gboolean call_parent;
|
|
|
|
|
- EelBackground *background;
|
|
|
|
|
- GdkGC *gc;
|
|
|
|
|
- GdkGCValues gc_values;
|
|
|
|
|
- EelBackgroundStyleDetails *details;
|
|
|
|
|
- GdkGCValuesMask value_mask;
|
|
|
|
|
- GdkColor color;
|
|
|
|
|
- GdkPixmap *pixmap;
|
|
|
|
|
- gboolean changes_with_size;
|
|
|
|
|
- int window_width, window_height;
|
|
|
|
|
-
|
|
|
|
|
- call_parent = TRUE;
|
|
|
|
|
-
|
|
|
|
|
- background = NULL;
|
|
|
|
|
- if (state_type == GTK_STATE_NORMAL) {
|
|
|
|
|
- background = eel_get_widget_background (widget);
|
|
|
|
|
- if (background != NULL && !GTK_IS_TREE_VIEW (widget)) {
|
|
|
|
|
- call_parent = FALSE;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (call_parent) {
|
|
|
|
|
- GNOME_CALL_PARENT (GTK_STYLE_CLASS, draw_flat_box,
|
|
|
|
|
- (style, window, state_type, shadow_type, area, widget,
|
|
|
|
|
- detail, x, y, width, height));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- details = EEL_BACKGROUND_STYLE (style)->details;
|
|
|
|
|
-
|
|
|
|
|
- gdk_drawable_get_size (window, &window_width, &window_height);
|
|
|
|
|
-
|
|
|
|
|
- pixmap = eel_background_get_pixmap_and_color (background, window,
|
|
|
|
|
- window_width, window_height,
|
|
|
|
|
- &color,
|
|
|
|
|
- &changes_with_size);
|
|
|
|
|
-
|
|
|
|
|
- if (!changes_with_size) {
|
|
|
|
|
- /* The background was already drawn by X, since we set
|
|
|
|
|
- * the GdkWindow background/back_pixmap.
|
|
|
|
|
- * No need to draw it again. */
|
|
|
|
|
- if (pixmap != NULL) {
|
|
|
|
|
- g_object_unref (pixmap);
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (pixmap != NULL) {
|
|
|
|
|
- gc_values.tile = pixmap;
|
|
|
|
|
- gc_values.ts_x_origin = 0;
|
|
|
|
|
- gc_values.ts_y_origin = 0;
|
|
|
|
|
- gc_values.fill = GDK_TILED;
|
|
|
|
|
- value_mask = GDK_GC_FILL | GDK_GC_TILE |
|
|
|
|
|
- GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN;
|
|
|
|
|
- } else {
|
|
|
|
|
- gdk_rgb_find_color (gtk_widget_get_colormap (widget), &color);
|
|
|
|
|
- gc_values.foreground = color;
|
|
|
|
|
- gc_values.fill = GDK_SOLID;
|
|
|
|
|
- value_mask = GDK_GC_FILL | GDK_GC_FOREGROUND;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- gc = gdk_gc_new_with_values (window, &gc_values, value_mask);
|
|
|
|
|
-
|
|
|
|
|
- if (area != NULL) {
|
|
|
|
|
- gdk_gc_set_clip_rectangle (gc, area);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if (width == -1) {
|
|
|
|
|
- width = window_width;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (height == -1) {
|
|
|
|
|
- height = window_height;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- gdk_draw_rectangle (window, gc, TRUE,
|
|
|
|
|
- x, y,
|
|
|
|
|
- width, height);
|
|
|
|
|
-
|
|
|
|
|
- g_object_unref (gc);
|
|
|
|
|
-
|
|
|
|
|
- if (pixmap != NULL) {
|
|
|
|
|
- g_object_unref (pixmap);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-EelBackgroundStyle *
|
|
|
|
|
-eel_background_style_new (GtkStyle *base_style,
|
|
|
|
|
- EelBackground *background)
|
|
|
|
|
-{
|
|
|
|
|
- EelBackgroundStyle *style;
|
|
|
|
|
-
|
|
|
|
|
- g_return_val_if_fail (GTK_IS_STYLE (base_style), NULL);
|
|
|
|
|
- g_return_val_if_fail (EEL_IS_BACKGROUND (background), NULL);
|
|
|
|
|
-
|
|
|
|
|
- style = g_object_new (EEL_TYPE_BACKGROUND_STYLE, NULL);
|
|
|
|
|
-
|
|
|
|
|
- GTK_STYLE_CLASS (g_type_class_peek (GTK_TYPE_STYLE))->copy (GTK_STYLE (style), base_style);
|
|
|
|
|
-
|
|
|
|
|
- style->details->background = g_object_ref (background);
|
|
|
|
|
-
|
|
|
|
|
- return style;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_style_set_background (GtkStyle *gtkstyle,
|
|
|
|
|
- GdkWindow *window,
|
|
|
|
|
- GtkStateType state_type)
|
|
|
|
|
-{
|
|
|
|
|
- EelBackgroundStyle *style;
|
|
|
|
|
- EelBackground *background;
|
|
|
|
|
- GdkColor color;
|
|
|
|
|
- GdkPixmap *pixmap;
|
|
|
|
|
- gboolean changes_with_size;
|
|
|
|
|
- int window_width, window_height;
|
|
|
|
|
-
|
|
|
|
|
- style = EEL_BACKGROUND_STYLE (gtkstyle);
|
|
|
|
|
-
|
|
|
|
|
- background = style->details->background;
|
|
|
|
|
-
|
|
|
|
|
- g_return_if_fail (background != NULL);
|
|
|
|
|
-
|
|
|
|
|
- gdk_drawable_get_size (window, &window_width, &window_height);
|
|
|
|
|
- pixmap = eel_background_get_pixmap_and_color (background, window,
|
|
|
|
|
- window_width, window_height,
|
|
|
|
|
- &color,
|
|
|
|
|
- &changes_with_size);
|
|
|
|
|
- gdk_rgb_find_color (gtkstyle->colormap, &color);
|
|
|
|
|
-
|
|
|
|
|
- if (pixmap != NULL && !changes_with_size) {
|
|
|
|
|
- gdk_window_set_back_pixmap (window, pixmap, FALSE);
|
|
|
|
|
- } else {
|
|
|
|
|
- gdk_window_set_background (window, &color);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (pixmap != NULL) {
|
|
|
|
|
- g_object_unref (pixmap);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static GtkStyle *
|
|
|
|
|
-eel_background_style_clone (GtkStyle *style)
|
|
|
|
|
-{
|
|
|
|
|
- EelBackgroundStyle *new_style;
|
|
|
|
|
-
|
|
|
|
|
- new_style = g_object_new (G_OBJECT_TYPE (style), NULL);
|
|
|
|
|
- if (EEL_BACKGROUND_STYLE (style)->details->background != NULL) {
|
|
|
|
|
- new_style->details->background = g_object_ref (EEL_BACKGROUND_STYLE (style)->details->background);
|
|
|
|
|
- }
|
|
|
|
|
- return GTK_STYLE (new_style);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_style_class_init (EelBackgroundStyleClass *class)
|
|
|
|
|
-{
|
|
|
|
|
- G_OBJECT_CLASS (class)->finalize = eel_background_style_finalize;
|
|
|
|
|
- GTK_STYLE_CLASS (class)->clone = eel_background_style_clone;
|
|
|
|
|
- GTK_STYLE_CLASS (class)->draw_flat_box = eel_background_style_draw_flat_box;
|
|
|
|
|
- GTK_STYLE_CLASS (class)->set_background = eel_background_style_set_background;
|
|
|
|
|
-}
|
|
|
|
|
Index: eel/eel-background-style.h
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: eel/eel-background-style.h
|
|
|
|
|
diff -N eel/eel-background-style.h
|
|
|
|
|
--- eel/eel-background-style.h 4 Feb 2002 16:57:24 -0000 1.2
|
|
|
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
|
|
|
@@ -1,61 +0,0 @@
|
|
|
|
|
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
|
|
|
|
-
|
|
|
|
|
- eel-background-style.h: Style subclass used by EelBackground.
|
|
|
|
|
-
|
|
|
|
|
- Copyright (C) 2001 Bent Spoon Software
|
|
|
|
|
-
|
|
|
|
|
- This program 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 program is distributed in the hope that it will be useful,
|
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
- Library General Public License for more details.
|
|
|
|
|
-
|
|
|
|
|
- You should have received a copy of the GNU Library General Public
|
|
|
|
|
- License along with this program; if not, write to the
|
|
|
|
|
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
- Boston, MA 02111-1307, USA.
|
|
|
|
|
-
|
|
|
|
|
- Authors: Darin Adler <darin@bentspoon.com>
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
-#ifndef EEL_BACKGROUND_STYLE_H
|
|
|
|
|
-#define EEL_BACKGROUND_STYLE_H
|
|
|
|
|
-
|
|
|
|
|
-#include <eel/eel-background.h>
|
|
|
|
|
-
|
|
|
|
|
-typedef struct EelBackgroundStyle EelBackgroundStyle;
|
|
|
|
|
-typedef struct EelBackgroundStyleClass EelBackgroundStyleClass;
|
|
|
|
|
-
|
|
|
|
|
-#define EEL_TYPE_BACKGROUND_STYLE \
|
|
|
|
|
- (eel_background_style_get_type ())
|
|
|
|
|
-#define EEL_BACKGROUND_STYLE(obj) \
|
|
|
|
|
- (GTK_CHECK_CAST ((obj), EEL_TYPE_BACKGROUND_STYLE, EelBackgroundStyle))
|
|
|
|
|
-#define EEL_BACKGROUND_STYLE_CLASS(klass) \
|
|
|
|
|
- (GTK_CHECK_CLASS_CAST ((klass), EEL_TYPE_BACKGROUND_STYLE, EelBackgroundStyleClass))
|
|
|
|
|
-#define EEL_IS_BACKGROUND_STYLE(obj) \
|
|
|
|
|
- (GTK_CHECK_TYPE ((obj), EEL_TYPE_BACKGROUND_STYLE))
|
|
|
|
|
-#define EEL_IS_BACKGROUND_STYLE_CLASS(klass) \
|
|
|
|
|
- (GTK_CHECK_CLASS_TYPE ((klass), EEL_TYPE_BACKGROUND_STYLE))
|
|
|
|
|
-
|
|
|
|
|
-GtkType eel_background_style_get_type (void);
|
|
|
|
|
-EelBackgroundStyle *eel_background_style_new (GtkStyle *base_style,
|
|
|
|
|
- EelBackground *background);
|
|
|
|
|
-
|
|
|
|
|
-typedef struct EelBackgroundStyleDetails EelBackgroundStyleDetails;
|
|
|
|
|
-
|
|
|
|
|
-struct EelBackgroundStyle
|
|
|
|
|
-{
|
|
|
|
|
- GtkStyle parent;
|
|
|
|
|
- EelBackgroundStyleDetails *details;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-struct EelBackgroundStyleClass
|
|
|
|
|
-{
|
|
|
|
|
- GtkStyleClass parent_class;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-#endif /* EEL_BACKGROUND_STYLE_H */
|
|
|
|
|
Index: eel/eel-background.c
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: /cvs/gnome/eel/eel/eel-background.c,v
|
|
|
|
|
retrieving revision 1.34
|
|
|
|
|
retrieving revision 1.35
|
|
|
|
|
diff -d -u -r1.34 -r1.35
|
|
|
|
|
--- eel/eel-background.c 19 Jul 2002 20:21:50 -0000 1.34
|
|
|
|
|
+++ eel/eel-background.c 24 Jul 2002 20:19:51 -0000 1.35
|
|
|
|
|
@@ -25,7 +25,6 @@
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include "eel-background.h"
|
|
|
|
|
|
|
|
|
|
-#include "eel-background-style.h"
|
|
|
|
|
#include "eel-gdk-extensions.h"
|
|
|
|
|
#include "eel-gdk-pixbuf-extensions.h"
|
|
|
|
|
#include "eel-glib-extensions.h"
|
|
|
|
|
@@ -105,7 +104,6 @@
|
|
|
|
|
int background_entire_height;
|
|
|
|
|
GdkColor background_color;
|
|
|
|
|
gboolean background_changes_with_size;
|
|
|
|
|
- guint respond_to_style_set : 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
@@ -172,7 +170,6 @@
|
|
|
|
|
background->details = g_new0 (EelBackgroundDetails, 1);
|
|
|
|
|
background->details->constant_size = FALSE;
|
|
|
|
|
background->details->is_solid_color = TRUE;
|
|
|
|
|
- background->details->respond_to_style_set = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The safe way to clear an image from a background is:
|
|
|
|
|
@@ -718,6 +715,72 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
+eel_background_expose (GtkWidget *widget,
|
|
|
|
|
+ GdkEventExpose *event)
|
|
|
|
|
+{
|
|
|
|
|
+ GdkColor color;
|
|
|
|
|
+ int window_width;
|
|
|
|
|
+ int window_height;
|
|
|
|
|
+ gboolean changes_with_size;
|
|
|
|
|
+ GdkPixmap *pixmap;
|
|
|
|
|
+ GdkGC *gc;
|
|
|
|
|
+ GdkGCValues gc_values;
|
|
|
|
|
+ GdkGCValuesMask value_mask;
|
|
|
|
|
+
|
|
|
|
|
+ EelBackground *background;
|
|
|
|
|
+
|
|
|
|
|
+ if (event->window != widget->window) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ background = eel_get_widget_background (widget);
|
|
|
|
|
+
|
|
|
|
|
+ gdk_drawable_get_size (widget->window, &window_width, &window_height);
|
|
|
|
|
+
|
|
|
|
|
+ pixmap = eel_background_get_pixmap_and_color (background,
|
|
|
|
|
+ widget->window,
|
|
|
|
|
+ window_width,
|
|
|
|
|
+ window_height,
|
|
|
|
|
+ &color,
|
|
|
|
|
+ &changes_with_size);
|
|
|
|
|
+
|
|
|
|
|
+ if (!changes_with_size) {
|
|
|
|
|
+ /* The background was already drawn by X, since we set
|
|
|
|
|
+ * the GdkWindow background/back_pixmap.
|
|
|
|
|
+ * No need to draw it again. */
|
|
|
|
|
+ if (pixmap) {
|
|
|
|
|
+ g_object_unref (pixmap);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (pixmap) {
|
|
|
|
|
+ gc_values.tile = pixmap;
|
|
|
|
|
+ gc_values.ts_x_origin = 0;
|
|
|
|
|
+ gc_values.ts_y_origin = 0;
|
|
|
|
|
+ gc_values.fill = GDK_TILED;
|
|
|
|
|
+ value_mask = GDK_GC_FILL | GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ gdk_rgb_find_color (gtk_widget_get_colormap (widget), &color);
|
|
|
|
|
+ gc_values.foreground = color;
|
|
|
|
|
+ gc_values.fill = GDK_SOLID;
|
|
|
|
|
+ value_mask = GDK_GC_FILL | GDK_GC_FOREGROUND;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ gc = gdk_gc_new_with_values (widget->window, &gc_values, value_mask);
|
|
|
|
|
+
|
|
|
|
|
+ gdk_gc_set_clip_rectangle (gc, &event->area);
|
|
|
|
|
+
|
|
|
|
|
+ gdk_draw_rectangle (widget->window, gc, TRUE, 0, 0, window_width, window_height);
|
|
|
|
|
+
|
|
|
|
|
+ g_object_unref (gc);
|
|
|
|
|
+
|
|
|
|
|
+ if (pixmap) {
|
|
|
|
|
+ g_object_unref (pixmap);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void
|
|
|
|
|
eel_background_pre_draw (EelBackground *background, int entire_width, int entire_height)
|
|
|
|
|
{
|
|
|
|
|
eel_background_ensure_image_scaled (background, entire_width, entire_height);
|
|
|
|
|
@@ -1125,59 +1188,6 @@
|
|
|
|
|
eel_background_set_image_uri_and_color (background, image_uri, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_set_style_font_from_default (GtkStyle *style,
|
|
|
|
|
- GtkSettings *settings)
|
|
|
|
|
-{
|
|
|
|
|
- char *fontname;
|
|
|
|
|
-
|
|
|
|
|
- fontname = NULL;
|
|
|
|
|
-
|
|
|
|
|
- g_object_get (settings,
|
|
|
|
|
- "gtk-font-name", &fontname,
|
|
|
|
|
- NULL);
|
|
|
|
|
-
|
|
|
|
|
- if (fontname != NULL) {
|
|
|
|
|
- if (style->font_desc) {
|
|
|
|
|
- pango_font_description_free (style->font_desc);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- style->font_desc = pango_font_description_from_string (fontname);
|
|
|
|
|
- g_free (fontname);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-eel_background_set_widget_style (EelBackground *background,
|
|
|
|
|
- GtkWidget *widget)
|
|
|
|
|
-{
|
|
|
|
|
- GtkStyle *style;
|
|
|
|
|
- gboolean old_respond_value;
|
|
|
|
|
-
|
|
|
|
|
- g_return_if_fail (EEL_IS_BACKGROUND (background));
|
|
|
|
|
- g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
-
|
|
|
|
|
- style = GTK_STYLE (eel_background_style_new (gtk_widget_get_style (widget),
|
|
|
|
|
- background));
|
|
|
|
|
-
|
|
|
|
|
- /* Bad hack to make font changing work: */
|
|
|
|
|
- eel_background_set_style_font_from_default (style, gtk_widget_get_settings (widget));
|
|
|
|
|
-
|
|
|
|
|
- old_respond_value = background->details->respond_to_style_set;
|
|
|
|
|
- background->details->respond_to_style_set = FALSE;
|
|
|
|
|
- gtk_widget_set_style (widget, style);
|
|
|
|
|
- /* HACK: unset the USER_STYLE flag because otherwise we will not be
|
|
|
|
|
- * notified of theme changes through the "style_set" signal. The real
|
|
|
|
|
- * solution is not to use a style of our own, but rather paint the
|
|
|
|
|
- * widget by hand when needed.
|
|
|
|
|
- */
|
|
|
|
|
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
|
|
|
|
|
- background->details->respond_to_style_set = old_respond_value;
|
|
|
|
|
-
|
|
|
|
|
- g_object_unref (style);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
|
|
|
* eel_background_is_set:
|
|
|
|
|
*
|
|
|
|
|
@@ -1286,6 +1296,44 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
+eel_background_set_up_widget (EelBackground *background, GtkWidget *widget)
|
|
|
|
|
+{
|
|
|
|
|
+ GtkStyle *style;
|
|
|
|
|
+ GdkPixmap *pixmap;
|
|
|
|
|
+ GdkColor color;
|
|
|
|
|
+ int window_width;
|
|
|
|
|
+ int window_height;
|
|
|
|
|
+ gboolean changes_with_size;
|
|
|
|
|
+
|
|
|
|
|
+ if (!GTK_WIDGET_REALIZED (widget)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ gdk_drawable_get_size (widget->window, &window_width, &window_height);
|
|
|
|
|
+
|
|
|
|
|
+ pixmap = eel_background_get_pixmap_and_color (background,
|
|
|
|
|
+ widget->window,
|
|
|
|
|
+ window_width,
|
|
|
|
|
+ window_height,
|
|
|
|
|
+ &color,
|
|
|
|
|
+ &changes_with_size);
|
|
|
|
|
+
|
|
|
|
|
+ style = gtk_widget_get_style (widget);
|
|
|
|
|
+
|
|
|
|
|
+ gdk_rgb_find_color (style->colormap, &color);
|
|
|
|
|
+
|
|
|
|
|
+ if (pixmap && !changes_with_size) {
|
|
|
|
|
+ gdk_window_set_back_pixmap (widget->window, pixmap, FALSE);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ gdk_window_set_background (widget->window, &color);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (pixmap) {
|
|
|
|
|
+ g_object_unref (pixmap);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
eel_background_set_up_canvas (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
if (!GNOME_IS_CANVAS (widget)) {
|
|
|
|
|
@@ -1309,64 +1357,22 @@
|
|
|
|
|
eel_widget_background_changed (GtkWidget *widget, EelBackground *background)
|
|
|
|
|
{
|
|
|
|
|
eel_background_unrealize (background);
|
|
|
|
|
- eel_background_set_widget_style (background, widget);
|
|
|
|
|
+ eel_background_set_up_widget (background, widget);
|
|
|
|
|
eel_background_set_up_canvas (widget);
|
|
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-/* Bad hack to make font changes work for EelBackgrounds */
|
|
|
|
|
-static void
|
|
|
|
|
-eel_widget_font_changed (GtkWidget *widget,
|
|
|
|
|
- GParamSpec *pspec,
|
|
|
|
|
- GtkSettings *settings)
|
|
|
|
|
-{
|
|
|
|
|
- EelBackground *background;
|
|
|
|
|
- GtkStyle *style;
|
|
|
|
|
- gboolean old_respond_value;
|
|
|
|
|
-
|
|
|
|
|
- background = eel_get_widget_background (widget);
|
|
|
|
|
-
|
|
|
|
|
- style = gtk_style_copy (gtk_widget_get_style (widget));
|
|
|
|
|
-
|
|
|
|
|
- eel_background_set_style_font_from_default (style, settings);
|
|
|
|
|
-
|
|
|
|
|
- old_respond_value = background->details->respond_to_style_set;
|
|
|
|
|
- background->details->respond_to_style_set = FALSE;
|
|
|
|
|
- gtk_widget_set_style (widget, style);
|
|
|
|
|
- /* HACK: unset the USER_STYLE flag because otherwise we will not be
|
|
|
|
|
- * notified of theme changes through the "style_set" signal. The real
|
|
|
|
|
- * solution is not to use a style of our own, but rather paint the
|
|
|
|
|
- * widget by hand when needed.
|
|
|
|
|
- */
|
|
|
|
|
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
|
|
|
|
|
- background->details->respond_to_style_set = old_respond_value;
|
|
|
|
|
-
|
|
|
|
|
- g_object_unref (style);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/* Callback used when the style of a widget changes. We have to regenerate its
|
|
|
|
|
- * EelBackgroundStyle so that it will match the chosen GTK+ theme.
|
|
|
|
|
- */
|
|
|
|
|
-static void
|
|
|
|
|
-widget_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, gpointer data)
|
|
|
|
|
-{
|
|
|
|
|
- EelBackground *background;
|
|
|
|
|
-
|
|
|
|
|
- background = EEL_BACKGROUND (data);
|
|
|
|
|
-
|
|
|
|
|
- if (!background->details->respond_to_style_set)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- eel_widget_background_changed (widget, background);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
/* Gets the background attached to a widget.
|
|
|
|
|
|
|
|
|
|
If the widget doesn't already have a EelBackground object,
|
|
|
|
|
this will create one. To change the widget's background, you can
|
|
|
|
|
just call eel_background methods on the widget.
|
|
|
|
|
|
|
|
|
|
+ If the widget is a canvas, nothing more needs to be done. For
|
|
|
|
|
+ normal widgets, you need to call eel_background_expose() from your
|
|
|
|
|
+ expose handler to draw the background.
|
|
|
|
|
+
|
|
|
|
|
Later, we might want a call to find out if we already have a background,
|
|
|
|
|
or a way to share the same background among multiple widgets; both would
|
|
|
|
|
be straightforward.
|
|
|
|
|
@@ -1376,7 +1382,6 @@
|
|
|
|
|
{
|
|
|
|
|
gpointer data;
|
|
|
|
|
EelBackground *background;
|
|
|
|
|
- GtkSettings *settings;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
|
|
|
|
|
|
|
|
|
@@ -1398,14 +1403,6 @@
|
|
|
|
|
g_signal_connect_object (background, "appearance_changed",
|
|
|
|
|
G_CALLBACK (eel_widget_background_changed), widget, G_CONNECT_SWAPPED);
|
|
|
|
|
eel_widget_background_changed (widget, background);
|
|
|
|
|
-
|
|
|
|
|
- settings = gtk_widget_get_settings (widget);
|
|
|
|
|
- g_signal_connect_object (settings, "notify::gtk-font-name",
|
|
|
|
|
- G_CALLBACK (eel_widget_font_changed), widget, G_CONNECT_SWAPPED);
|
|
|
|
|
-
|
|
|
|
|
- g_signal_connect (widget, "style_set",
|
|
|
|
|
- G_CALLBACK (widget_style_set_cb),
|
|
|
|
|
- background);
|
|
|
|
|
|
|
|
|
|
return background;
|
|
|
|
|
}
|
|
|
|
|
Index: eel/eel-background.h
|
|
|
|
|
===================================================================
|
|
|
|
|
RCS file: /cvs/gnome/eel/eel/eel-background.h,v
|
|
|
|
|
retrieving revision 1.9
|
|
|
|
|
retrieving revision 1.10
|
|
|
|
|
diff -d -u -r1.9 -r1.10
|
|
|
|
|
--- eel/eel-background.h 3 Mar 2002 20:50:16 -0000 1.9
|
|
|
|
|
+++ eel/eel-background.h 24 Jul 2002 20:19:51 -0000 1.10
|
|
|
|
|
@@ -109,6 +109,10 @@
|
|
|
|
|
gboolean *changes_with_size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+/* Helper function for widgets using EelBackground */
|
|
|
|
|
+void eel_background_expose (GtkWidget *widget,
|
|
|
|
|
+ GdkEventExpose *event);
|
|
|
|
|
+
|
|
|
|
|
/* For preping the background to be used in one of the two calls
|
|
|
|
|
* below. Only intended to be called by eel_background_canvas_group_update.
|
|
|
|
|
*/
|
|
|
|
|
--- eel/Makefile.in.orig Thu Jul 25 15:10:22 2002
|
|
|
|
|
+++ eel/Makefile.in Thu Jul 25 15:41:03 2002
|
|
|
|
|
@@ -151,7 +151,7 @@
|
|
|
|
|
eel-art-extensions.c \
|
|
|
|
|
eel-art-gtk-extensions.c \
|
|
|
|
|
eel-background.c \
|
|
|
|
|
- eel-background-style.c \
|
|
|
|
|
+ eel-background-box.c \
|
|
|
|
|
eel-canvas-rect.c \
|
|
|
|
|
eel-caption-table.c \
|
|
|
|
|
eel-caption.c \
|
|
|
|
|
@@ -206,7 +206,7 @@
|
|
|
|
|
eel-art-extensions.h \
|
|
|
|
|
eel-art-gtk-extensions.h \
|
|
|
|
|
eel-background.h \
|
|
|
|
|
- eel-background-style.h \
|
|
|
|
|
+ eel-background-box.h \
|
|
|
|
|
eel-canvas-rect.h \
|
|
|
|
|
eel-caption-table.h \
|
|
|
|
|
eel-caption.h \
|
|
|
|
|
@@ -318,7 +318,7 @@
|
|
|
|
|
LIBS = @LIBS@
|
|
|
|
|
libeel_2_la_LIBADD =
|
|
|
|
|
libeel_2_la_OBJECTS = eel-accessibility.lo eel-art-extensions.lo \
|
|
|
|
|
-eel-art-gtk-extensions.lo eel-background.lo eel-background-style.lo \
|
|
|
|
|
+eel-art-gtk-extensions.lo eel-background.lo eel-background-box.lo \
|
|
|
|
|
eel-canvas-rect.lo eel-caption-table.lo eel-caption.lo \
|
|
|
|
|
eel-cell-renderer-pixbuf-list.lo eel-dateedit-extensions.lo \
|
|
|
|
|
eel-debug-drawing.lo eel-debug.lo eel-ellipsizing-label.lo \
|