[gdl] Ported remaining stuff to gtk+-3.0 (master)
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdl] Ported remaining stuff to gtk+-3.0 (master)
- Date: Tue, 26 Oct 2010 17:54:37 +0000 (UTC)
commit 6521d9b7b7f413bfdc466a1f73ef567147a299cf
Author: Johannes Schmid <jhs gnome org>
Date: Tue Oct 26 16:57:49 2010 +0200
Ported remaining stuff to gtk+-3.0 (master)
* GdkRegion -> cairo_region_t
* expose-event ->draw
* Created a new class for the preview window
gdl/Makefile.am | 6 +-
gdl/gdl-dock-item-button-image.c | 14 +---
gdl/gdl-dock-item-grip.c | 39 ++++-------
gdl/gdl-dock-item.c | 35 ++++------
gdl/gdl-dock-master.c | 65 ++++++++----------
gdl/gdl-dock-object.h | 10 ++--
gdl/gdl-dock-tablabel.c | 31 +++++----
gdl/gdl-dock.c | 70 +++++++------------
gdl/gdl-dock.h | 1 +
gdl/gdl-preview-window.c | 139 ++++++++++++++++++++++++++++++++++++++
gdl/gdl-preview-window.h | 53 ++++++++++++++
gdl/gdl-switcher.c | 10 ++--
12 files changed, 308 insertions(+), 165 deletions(-)
---
diff --git a/gdl/Makefile.am b/gdl/Makefile.am
index 365bc70..ececa88 100644
--- a/gdl/Makefile.am
+++ b/gdl/Makefile.am
@@ -58,7 +58,9 @@ libgdl_3_la_SOURCES = \
libgdltypebuiltins.h \
libgdltypebuiltins.c \
libgdlmarshal.h \
- libgdlmarshal.c
+ libgdlmarshal.c \
+ gdl-preview-window.h \
+ gdl-preview-window.c
libgdl_3_la_LIBADD = \
$(GDL_DEPENDENCIES_LIBS) \
@@ -67,7 +69,7 @@ libgdl_3_la_LIBADD = \
libgdl_3_la_LDFLAGS = $(EXTRA_LDFLAGS) \
-version-info $(GDL_CURRENT):$(GDL_REVISION):$(GDL_AGE)
-noinst_PROGRAMS=test-dock
+bin_PROGRAMS=test-dock
test_dock_sources=test-dock.c
test_dock_LDADD=libgdl-3.la $(XML_LIBS)
diff --git a/gdl/gdl-dock-item-button-image.c b/gdl/gdl-dock-item-button-image.c
index 446df47..ef7cbe6 100644
--- a/gdl/gdl-dock-item-button-image.c
+++ b/gdl/gdl-dock-item-button-image.c
@@ -31,8 +31,8 @@ G_DEFINE_TYPE (GdlDockItemButtonImage,
GTK_TYPE_WIDGET);
static gint
-gdl_dock_item_button_image_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gdl_dock_item_button_image_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GdlDockItemButtonImage *button_image;
GtkStyle *style;
@@ -41,9 +41,6 @@ gdl_dock_item_button_image_expose (GtkWidget *widget,
g_return_val_if_fail (widget != NULL, 0);
button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget);
- cairo_t *cr = gdk_cairo_create (event->window);
- cairo_translate (cr, event->area.x, event->area.y);
-
/* Set up the pen */
cairo_set_line_width(cr, 1.0);
@@ -107,9 +104,6 @@ gdl_dock_item_button_image_expose (GtkWidget *widget,
cairo_fill (cr);
- /* Finish up */
- cairo_destroy (cr);
-
return 0;
}
@@ -138,8 +132,8 @@ gdl_dock_item_button_image_class_init (
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->expose_event =
- gdl_dock_item_button_image_expose;
+ widget_class->draw =
+ gdl_dock_item_button_image_draw;
widget_class->size_request =
gdl_dock_item_button_image_size_request;
}
diff --git a/gdl/gdl-dock-item-grip.c b/gdl/gdl-dock-item-grip.c
index 400e134..ff10762 100644
--- a/gdl/gdl-dock-item-grip.c
+++ b/gdl/gdl-dock-item-grip.c
@@ -101,38 +101,25 @@ gdl_dock_item_create_label_widget(GdlDockItemGrip *grip)
}
static gint
-gdl_dock_item_grip_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gdl_dock_item_grip_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GdlDockItemGrip *grip;
GtkAllocation allocation;
- GdkRectangle handle_area;
- GdkRectangle expose_area;
+ cairo_rectangle_int_t handle_area;
+ cairo_rectangle_int_t expose_area;
grip = GDL_DOCK_ITEM_GRIP (widget);
- if(grip->_priv->handle_shown) {
-
- gtk_widget_get_allocation (widget, &allocation);
-
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
- handle_area.x = allocation.x;
- handle_area.y = allocation.y;
- handle_area.width = DRAG_HANDLE_SIZE;
- handle_area.height = allocation.height;
- } else {
- handle_area.x = allocation.x + allocation.width - DRAG_HANDLE_SIZE;
- handle_area.y = allocation.y;
- handle_area.width = DRAG_HANDLE_SIZE;
- handle_area.height = allocation.height;
- }
-
- if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) {
-
+ if (grip->_priv->handle_shown)
+ {
+ if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
+ {
gtk_paint_handle (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ cr,
gtk_widget_get_state (widget),
- GTK_SHADOW_NONE, &expose_area, widget,
+ GTK_SHADOW_NONE,
+ widget,
"handlebox", handle_area.x, handle_area.y,
handle_area.width, handle_area.height,
GTK_ORIENTATION_VERTICAL);
@@ -141,7 +128,7 @@ gdl_dock_item_grip_expose (GtkWidget *widget,
}
- return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->expose_event (widget, event);
+ return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->draw (widget, cr);
}
static void
@@ -683,7 +670,7 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass)
widget_class->destroy = gdl_dock_item_grip_destroy;
- widget_class->expose_event = gdl_dock_item_grip_expose;
+ widget_class->draw = gdl_dock_item_grip_draw;
widget_class->realize = gdl_dock_item_grip_realize;
widget_class->unrealize = gdl_dock_item_grip_unrealize;
widget_class->map = gdl_dock_item_grip_map;
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 29b9f00..6c17db5 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -88,8 +88,8 @@ static void gdl_dock_item_unmap (GtkWidget *widget);
static void gdl_dock_item_realize (GtkWidget *widget);
static void gdl_dock_item_style_set (GtkWidget *widget,
GtkStyle *previous_style);
-static gint gdl_dock_item_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint gdl_dock_item_draw (GtkWidget *widget,
+ cairo_t *cr);
static gint gdl_dock_item_button_changed (GtkWidget *widget,
GdkEventButton *event);
@@ -220,7 +220,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
widget_class->size_request = gdl_dock_item_size_request;
widget_class->size_allocate = gdl_dock_item_size_allocate;
widget_class->style_set = gdl_dock_item_style_set;
- widget_class->expose_event = gdl_dock_item_expose;
+ widget_class->draw = gdl_dock_item_draw;
widget_class->button_press_event = gdl_dock_item_button_changed;
widget_class->button_release_event = gdl_dock_item_button_changed;
widget_class->motion_notify_event = gdl_dock_item_motion;
@@ -916,13 +916,12 @@ gdl_dock_item_realize (GtkWidget *widget)
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = (gtk_widget_get_events (widget) |
GDK_EXPOSURE_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gtk_widget_set_window (widget, window);
@@ -931,7 +930,6 @@ gdl_dock_item_realize (GtkWidget *widget)
gtk_widget_style_attach (widget);
gtk_style_set_background (gtk_widget_get_style (widget), window,
gtk_widget_get_state (GTK_WIDGET (item)));
- gdk_window_set_back_pixmap (window, NULL, TRUE);
if (item->child)
gtk_widget_set_parent_window (item->child, window);
@@ -956,41 +954,38 @@ gdl_dock_item_style_set (GtkWidget *widget,
gtk_style_set_background (gtk_widget_get_style (widget),
window,
gtk_widget_get_state (widget));
- if (gtk_widget_is_drawable (widget))
- gdk_window_clear (window);
}
}
static void
gdl_dock_item_paint (GtkWidget *widget,
- GdkEventExpose *event)
+ cairo_t *cr)
{
GdlDockItem *item;
item = GDL_DOCK_ITEM (widget);
gtk_paint_box (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ cr,
gtk_widget_get_state (widget),
GTK_SHADOW_NONE,
- &event->area, widget,
+ widget,
"dockitem",
- 0, 0, -1, -1);
+ 0, 0, 0, 0);
}
static gint
-gdl_dock_item_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gdl_dock_item_draw (GtkWidget *widget,
+ cairo_t *cr)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
+ g_return_val_if_fail (cr != NULL, FALSE);
- if (gtk_widget_is_drawable (widget) &&
- event->window == gtk_widget_get_window (widget))
+ if (gtk_widget_is_drawable (widget))
{
- gdl_dock_item_paint (widget, event);
- GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->expose_event (widget,event);
+ gdl_dock_item_paint (widget, cr);
+ GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->draw (widget, cr);
}
return FALSE;
@@ -1137,7 +1132,7 @@ gdl_dock_item_key_press (GtkWidget *widget,
gboolean event_handled = FALSE;
if (GDL_DOCK_ITEM_IN_DRAG (widget)) {
- if (event->keyval == GDK_Escape) {
+ if (event->keyval == GDK_KEY_Escape) {
gdl_dock_item_drag_end (GDL_DOCK_ITEM (widget), TRUE);
event_handled = TRUE;
}
diff --git a/gdl/gdl-dock-master.c b/gdl/gdl-dock-master.c
index d2a3cbd..7386457 100644
--- a/gdl/gdl-dock-master.c
+++ b/gdl/gdl-dock-master.c
@@ -31,6 +31,7 @@
#include "gdl-dock.h"
#include "gdl-dock-item.h"
#include "gdl-dock-notebook.h"
+#include "gdl-preview-window.h"
#include "gdl-switcher.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
@@ -91,7 +92,6 @@ struct _GdlDockMasterPrivate {
gint number; /* for naming nameless manual objects */
gchar *default_title;
- GdkGC *root_xor_gc;
gboolean rect_drawn;
GdlDock *rect_owner;
@@ -109,6 +109,9 @@ struct _GdlDockMasterPrivate {
GHashTable *unlocked_items;
GdlSwitcherStyle switcher_style;
+
+ /* Window for preview rect */
+ GtkWidget* area_window;
};
#define COMPUTE_LOCKED(master) \
@@ -282,10 +285,6 @@ gdl_dock_master_dispose (GObject *g_object)
if (master->_priv->idle_layout_changed_id)
g_source_remove (master->_priv->idle_layout_changed_id);
- if (master->_priv->root_xor_gc) {
- g_object_unref (master->_priv->root_xor_gc);
- master->_priv->root_xor_gc = NULL;
- }
if (master->_priv->drag_request) {
if (G_IS_VALUE (&master->_priv->drag_request->extra))
g_value_unset (&master->_priv->drag_request->extra);
@@ -299,6 +298,12 @@ gdl_dock_master_dispose (GObject *g_object)
master->_priv->locked_items = NULL;
g_hash_table_destroy (master->_priv->unlocked_items);
master->_priv->unlocked_items = NULL;
+
+ if (master->_priv->area_window)
+ {
+ gtk_widget_destroy (master->_priv->area_window);
+ master->_priv->area_window = NULL;
+ }
g_free (master->_priv);
master->_priv = NULL;
@@ -435,8 +440,14 @@ gdl_dock_master_drag_end (GdlDockItem *item,
/* Erase previously drawn rectangle */
if (master->_priv->rect_drawn)
- gdl_dock_master_xor_rect (master);
-
+ {
+ gtk_widget_hide (master->_priv->area_window);
+ }
+ if (master->_priv->rect_owner)
+ {
+ gdl_dock_xor_rect_hide (master->_priv->rect_owner);
+ }
+
/* cancel conditions */
if (cancelled || request->applicant == request->target)
return;
@@ -605,9 +616,7 @@ _gdl_dock_master_foreach (gpointer key,
static void
gdl_dock_master_xor_rect (GdlDockMaster *master)
{
- gint8 dash_list [2];
- GdkWindow *window;
- GdkRectangle *rect;
+ cairo_rectangle_int_t *rect;
if (!master->_priv || !master->_priv->drag_request)
return;
@@ -615,41 +624,23 @@ gdl_dock_master_xor_rect (GdlDockMaster *master)
master->_priv->rect_drawn = ~master->_priv->rect_drawn;
if (master->_priv->rect_owner) {
+ if (master->_priv->area_window)
+ {
+ gtk_widget_hide (master->_priv->area_window);
+ }
gdl_dock_xor_rect (master->_priv->rect_owner,
&master->_priv->drag_request->rect);
return;
}
rect = &master->_priv->drag_request->rect;
- window = gdk_get_default_root_window ();
-
- if (!master->_priv->root_xor_gc) {
- GdkGCValues values;
-
- values.function = GDK_INVERT;
- values.subwindow_mode = GDK_INCLUDE_INFERIORS;
- master->_priv->root_xor_gc = gdk_gc_new_with_values (
- window, &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW);
- };
- gdk_gc_set_line_attributes (master->_priv->root_xor_gc, 1,
- GDK_LINE_ON_OFF_DASH,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_BEVEL);
-
- dash_list[0] = 1;
- dash_list[1] = 1;
- gdk_gc_set_dashes (master->_priv->root_xor_gc, 1, dash_list, 2);
-
- gdk_draw_rectangle (window, master->_priv->root_xor_gc, 0,
- rect->x, rect->y,
- rect->width, rect->height);
-
- gdk_gc_set_dashes (master->_priv->root_xor_gc, 0, dash_list, 2);
+ if (!master->_priv->area_window)
+ {
+ master->_priv->area_window = gdl_preview_window_new ();
+ }
- gdk_draw_rectangle (window, master->_priv->root_xor_gc, 0,
- rect->x + 1, rect->y + 1,
- rect->width - 2, rect->height - 2);
+ gdl_preview_window_update (GDL_PREVIEW_WINDOW (master->_priv->area_window), rect);
}
static void
diff --git a/gdl/gdl-dock-object.h b/gdl/gdl-dock-object.h
index 9ee14c5..9721b74 100644
--- a/gdl/gdl-dock-object.h
+++ b/gdl/gdl-dock-object.h
@@ -71,11 +71,11 @@ typedef struct _GdlDockObjectClass GdlDockObjectClass;
typedef struct _GdlDockRequest GdlDockRequest;
struct _GdlDockRequest {
- GdlDockObject *applicant;
- GdlDockObject *target;
- GdlDockPlacement position;
- GdkRectangle rect;
- GValue extra;
+ GdlDockObject *applicant;
+ GdlDockObject *target;
+ GdlDockPlacement position;
+ cairo_rectangle_int_t rect;
+ GValue extra;
};
struct _GdlDockObject {
diff --git a/gdl/gdl-dock-tablabel.c b/gdl/gdl-dock-tablabel.c
index d9843e3..e27c5fd 100644
--- a/gdl/gdl-dock-tablabel.c
+++ b/gdl/gdl-dock-tablabel.c
@@ -56,9 +56,9 @@ static void gdl_dock_tablabel_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gdl_dock_tablabel_paint (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gdl_dock_tablabel_expose (GtkWidget *widget,
- GdkEventExpose *event);
+ cairo_t *cr);
+static gint gdl_dock_tablabel_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gdl_dock_tablabel_button_event (GtkWidget *widget,
GdkEventButton *event);
@@ -109,7 +109,7 @@ gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass)
widget_class->size_request = gdl_dock_tablabel_size_request;
widget_class->size_allocate = gdl_dock_tablabel_size_allocate;
- widget_class->expose_event = gdl_dock_tablabel_expose;
+ widget_class->draw = gdl_dock_tablabel_draw;
widget_class->button_press_event = gdl_dock_tablabel_button_event;
widget_class->button_release_event = gdl_dock_tablabel_button_event;
widget_class->motion_notify_event = gdl_dock_tablabel_motion_event;
@@ -352,13 +352,13 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget,
static void
gdl_dock_tablabel_paint (GtkWidget *widget,
- GdkEventExpose *event)
+ cairo_t *cr)
{
- GdkRectangle dest, rect;
GtkBin *bin;
GtkAllocation widget_allocation;
GdlDockTablabel *tablabel;
gint border_width;
+ cairo_rectangle_int_t rect;
bin = GTK_BIN (widget);
tablabel = GDL_DOCK_TABLABEL (widget);
@@ -369,28 +369,29 @@ gdl_dock_tablabel_paint (GtkWidget *widget,
rect.y = widget_allocation.y + border_width;
rect.width = tablabel->drag_handle_size * HANDLE_RATIO;
rect.height = widget_allocation.height - 2*border_width;
-
- if (gdk_rectangle_intersect (&event->area, &rect, &dest)) {
- gtk_paint_handle (gtk_widget_get_style (widget), gtk_widget_get_window (widget),
+
+ if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
+ {
+ gtk_paint_handle (gtk_widget_get_style (widget), cr,
tablabel->active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE,
GTK_SHADOW_NONE,
- &dest, widget, "dock-tablabel",
+ widget, "dock-tablabel",
rect.x, rect.y, rect.width, rect.height,
GTK_ORIENTATION_VERTICAL);
};
}
static gint
-gdl_dock_tablabel_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gdl_dock_tablabel_draw (GtkWidget *widget,
+ cairo_t *cr)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
+ g_return_val_if_fail (cr != NULL, FALSE);
if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) {
- GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->expose_event (widget,event);
- gdl_dock_tablabel_paint (widget, event);
+ GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->draw (widget, cr);
+ gdl_dock_tablabel_paint (widget, cr);
};
return FALSE;
diff --git a/gdl/gdl-dock.c b/gdl/gdl-dock.c
index d65c387..ba20cce 100644
--- a/gdl/gdl-dock.c
+++ b/gdl/gdl-dock.c
@@ -33,6 +33,7 @@
#include "gdl-dock-paned.h"
#include "gdl-dock-notebook.h"
#include "gdl-dock-placeholder.h"
+#include "gdl-preview-window.h"
#include "libgdlmarshal.h"
@@ -122,8 +123,7 @@ struct _GdlDockPrivate
gint width;
gint height;
- /* auxiliary fields */
- GdkGC *xor_gc;
+ GtkWidget *area_window;
};
enum {
@@ -513,13 +513,13 @@ gdl_dock_destroy (GtkWidget *object)
priv->floating = FALSE;
priv->window = NULL;
}
-
- /* destroy the xor gc */
- if (priv->xor_gc) {
- g_object_unref (priv->xor_gc);
- priv->xor_gc = NULL;
- }
+ if (priv->area_window)
+ {
+ gtk_widget_destroy (priv->area_window);
+ priv->area_window = NULL;
+ }
+
g_free (priv);
}
@@ -1319,45 +1319,25 @@ gdl_dock_object_get_toplevel (GdlDockObject *object)
void
gdl_dock_xor_rect (GdlDock *dock,
- GdkRectangle *rect)
+ cairo_rectangle_int_t *rect)
{
- GtkWidget *widget;
- GdkWindow *window;
- gint8 dash_list [2];
-
- widget = GTK_WIDGET (dock);
-
- if (!dock->_priv->xor_gc) {
- if (gtk_widget_get_realized (widget)) {
- GdkGCValues values;
-
- values.function = GDK_INVERT;
- values.subwindow_mode = GDK_INCLUDE_INFERIORS;
- dock->_priv->xor_gc = gdk_gc_new_with_values
- (gtk_widget_get_window (widget), &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW);
- } else
- return;
- };
-
- gdk_gc_set_line_attributes (dock->_priv->xor_gc, 1,
- GDK_LINE_ON_OFF_DASH,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_BEVEL);
-
- window = gtk_widget_get_window (widget);
-
- dash_list [0] = 1;
- dash_list [1] = 1;
+ gint x, y;
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (dock));
+ gdk_window_get_origin (window, &x, &y);
- gdk_gc_set_dashes (dock->_priv->xor_gc, 1, dash_list, 2);
-
- gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE,
- rect->x, rect->y,
- rect->width, rect->height);
+ if (!dock->_priv->area_window) {
+ dock->_priv->area_window = gdl_preview_window_new ();
+ }
- gdk_gc_set_dashes (dock->_priv->xor_gc, 0, dash_list, 2);
+ rect->x += x;
+ rect->y += y;
+
+ gdl_preview_window_update (GDL_PREVIEW_WINDOW (dock->_priv->area_window), rect);
+}
- gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE,
- rect->x + 1, rect->y + 1,
- rect->width - 2, rect->height - 2);
+void
+gdl_dock_xor_rect_hide (GdlDock *dock)
+{
+ if (dock->_priv->area_window)
+ gtk_widget_hide (dock->_priv->area_window);
}
diff --git a/gdl/gdl-dock.h b/gdl/gdl-dock.h
index 2bad5fc..981a70a 100644
--- a/gdl/gdl-dock.h
+++ b/gdl/gdl-dock.h
@@ -93,6 +93,7 @@ GdlDock *gdl_dock_object_get_toplevel (GdlDockObject *object);
void gdl_dock_xor_rect (GdlDock *dock,
GdkRectangle *rect);
+void gdl_dock_xor_rect_hide (GdlDock *dock);
G_END_DECLS
diff --git a/gdl/gdl-preview-window.c b/gdl/gdl-preview-window.c
new file mode 100644
index 0000000..0b13c41
--- /dev/null
+++ b/gdl/gdl-preview-window.c
@@ -0,0 +1,139 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
+/*
+ * gdl
+ * Copyright (C) Johannes Schmid 2010 <jhs Obelix>
+ *
+ * gdl is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gdl 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gdl-preview-window.h"
+
+
+
+G_DEFINE_TYPE (GdlPreviewWindow, gdl_preview_window, GTK_TYPE_WINDOW);
+
+static void
+gdl_preview_window_init (GdlPreviewWindow *window)
+{
+ GdkScreen *screen;
+ GdkVisual *visual;
+
+ screen = gdk_screen_get_default ();
+ visual = gdk_screen_get_rgba_visual (screen);
+
+ if (gdk_screen_is_composited (screen) &&
+ visual)
+ {
+ gtk_widget_set_visual (GTK_WIDGET(window), visual);
+ gtk_widget_set_app_paintable (GTK_WIDGET(window), TRUE);
+ }
+}
+
+static gboolean
+gdl_preview_window_draw (GtkWidget *window,
+ cairo_t *cr)
+{
+ GtkAllocation allocation;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (window);
+
+ if (gtk_widget_get_app_paintable (window))
+ {
+ cairo_set_line_width (cr, 1.0);
+
+ gtk_widget_get_allocation (window, &allocation);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0);
+ cairo_paint (cr);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]);
+ cairo_paint_with_alpha (cr, 0.25);
+
+ cairo_rectangle (cr,
+ allocation.x + 0.5, allocation.y + 0.5,
+ allocation.width - 1, allocation.height - 1);
+ cairo_stroke (cr);
+ }
+ else
+ {
+ gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]);
+ cairo_paint (cr);
+ }
+
+ return TRUE;
+}
+
+static void
+gdl_preview_window_class_init (GdlPreviewWindowClass *klass)
+{
+ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->draw = gdl_preview_window_draw;
+}
+
+
+GtkWidget*
+gdl_preview_window_new (void)
+{
+ return GTK_WIDGET (g_object_new (GDL_TYPE_PREVIEW_WINDOW,
+ "type", GTK_WINDOW_POPUP, NULL));
+}
+
+void
+gdl_preview_window_update (GdlPreviewWindow * pre_window, GdkRectangle *rect)
+{
+ GtkWidget* window = GTK_WIDGET (pre_window);
+
+ if (rect->width <= 0 || rect->height <= 0)
+ {
+ gtk_widget_hide (window);
+ return;
+ }
+
+ gtk_window_move (GTK_WINDOW (window), rect->x, rect->y);
+ gtk_window_resize (GTK_WINDOW (window), rect->width, rect->height);
+ gtk_widget_show (window);
+
+ /* We (ab)use app-paintable to indicate if we have an RGBA window */
+ if (!gtk_widget_get_app_paintable (window))
+ {
+ GdkWindow *gdkwindow = gtk_widget_get_window (window);
+
+ /* Shape the window to make only the outline visible */
+ if (rect->width > 2 && rect->height > 2)
+ {
+ cairo_region_t *region, *region2;
+ cairo_rectangle_int_t region_rect = { 0, 0,
+ rect->width - 2, rect->height - 2 };
+
+ region = cairo_region_create_rectangle (®ion_rect);
+ region_rect.x++;
+ region_rect.y++;
+ region_rect.width -= 2;
+ region_rect.height -= 2;
+ region2 = cairo_region_create_rectangle (®ion_rect);
+ cairo_region_subtract (region, region2);
+
+ gdk_window_shape_combine_region (gdkwindow, region, 0, 0);
+
+ cairo_region_destroy (region);
+ cairo_region_destroy (region2);
+ }
+ else
+ gdk_window_shape_combine_region (gdkwindow, NULL, 0, 0);
+ }
+}
diff --git a/gdl/gdl-preview-window.h b/gdl/gdl-preview-window.h
new file mode 100644
index 0000000..6d10421
--- /dev/null
+++ b/gdl/gdl-preview-window.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * gdl
+ * Copyright (C) Johannes Schmid 2010 <jhs Obelix>
+ *
+ * gdl is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gdl 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GDL_PREVIEW_WINDOW_H_
+#define _GDL_PREVIEW_WINDOW_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GDL_TYPE_PREVIEW_WINDOW (gdl_preview_window_get_type ())
+#define GDL_PREVIEW_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_PREVIEW_WINDOW, GdlPreviewWindow))
+#define GDL_PREVIEW_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_PREVIEW_WINDOW, GdlPreviewWindowClass))
+#define GDL_IS_PREVIEW_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_PREVIEW_WINDOW))
+#define GDL_IS_PREVIEW_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_PREVIEW_WINDOW))
+#define GDL_PREVIEW_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_PREVIEW_WINDOW, GdlPreviewWindowClass))
+
+typedef struct _GdlPreviewWindowClass GdlPreviewWindowClass;
+typedef struct _GdlPreviewWindow GdlPreviewWindow;
+
+struct _GdlPreviewWindowClass
+{
+ GtkWindowClass parent_class;
+};
+
+struct _GdlPreviewWindow
+{
+ GtkWindow parent_instance;
+};
+
+GType gdl_preview_window_get_type (void) G_GNUC_CONST;
+GtkWidget* gdl_preview_window_new (void);
+void gdl_preview_window_update (GdlPreviewWindow * window, GdkRectangle *rect);
+
+G_END_DECLS
+
+#endif /* _GDL_PREVIEW_WINDOW_H_ */
diff --git a/gdl/gdl-switcher.c b/gdl/gdl-switcher.c
index f657a77..046b9f3 100644
--- a/gdl/gdl-switcher.c
+++ b/gdl/gdl-switcher.c
@@ -540,18 +540,18 @@ gdl_switcher_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
}
static gint
-gdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event)
+gdl_switcher_draw (GtkWidget *widget, cairo_t *cr)
{
GSList *p;
GdlSwitcher *switcher = GDL_SWITCHER (widget);
if (switcher->priv->show) {
for (p = switcher->priv->buttons; p != NULL; p = p->next) {
GtkWidget *button = ((Button *) p->data)->button_widget;
- gtk_container_propagate_expose (GTK_CONTAINER (widget),
- button, event);
+ gtk_container_propagate_draw (GTK_CONTAINER (widget),
+ button, cr);
}
}
- return GTK_WIDGET_CLASS (gdl_switcher_parent_class)->expose_event (widget, event);
+ return GTK_WIDGET_CLASS (gdl_switcher_parent_class)->draw (widget, cr);
}
static void
@@ -714,7 +714,7 @@ gdl_switcher_class_init (GdlSwitcherClass *klass)
widget_class->size_request = gdl_switcher_size_request;
widget_class->size_allocate = gdl_switcher_size_allocate;
- widget_class->expose_event = gdl_switcher_expose;
+ widget_class->draw = gdl_switcher_draw;
widget_class->map = gdl_switcher_map;
object_class->dispose = gdl_switcher_dispose;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]