[monet/monet-xml] Set mn_widget names for scrollbar elements.
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monet/monet-xml] Set mn_widget names for scrollbar elements.
- Date: Tue, 14 Sep 2010 21:32:13 +0000 (UTC)
commit 89c1a9de48548e999f8c1ddcf2499d5cb05f086b
Author: Benjamin Berg <benjamin sipsolutions net>
Date: Tue Sep 14 23:30:51 2010 +0200
Set mn_widget names for scrollbar elements.
monet-gtk/style.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++
monet/mn-config.h | 13 ++++++
2 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/monet-gtk/style.c b/monet-gtk/style.c
index b47d3ee..e133e2f 100644
--- a/monet-gtk/style.c
+++ b/monet-gtk/style.c
@@ -2,6 +2,10 @@
*
* Copyright (C) 2008 Benjamin Berg <benjamin sipsolutions net>
*
+ * Some portions adapted from Clearlooks:
+ * Copyright (C) 2006 Andrew Johnson <acjgenius earthlink net>
+ * Copyright (C) 2007 Benjamin Berg <benjamin sipsolutions net>
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
@@ -259,6 +263,99 @@ monet_gtk_draw_arrow (GtkStyle *style,
/*##################################*/
+static gboolean
+_check_orientable_is_horizontal (GtkOrientable *orientable)
+{
+ return (gtk_orientable_get_orientation (orientable)
+ == GTK_ORIENTATION_HORIZONTAL);
+}
+
+
+/* the following function is adapted from Clearlooks' support.c */
+const gchar *
+_scrollbar_get_stepper (GtkWidget *widget,
+ GdkRectangle *stepper)
+{
+ const gchar *value = NULL;
+ GdkRectangle tmp;
+ GdkRectangle check_rectangle;
+ gboolean horizontal;
+ gint border;
+
+ if (!GTK_IS_RANGE (widget))
+ return "";
+
+ check_rectangle.x = widget->allocation.x;
+ check_rectangle.y = widget->allocation.y;
+ check_rectangle.width = stepper->width;
+ check_rectangle.height = stepper->height;
+
+ horizontal = (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget))
+ == GTK_ORIENTATION_HORIZONTAL);
+
+ if (widget->allocation.x == -1 && widget->allocation.y == -1)
+ return "";
+
+ /* Assume that the border is the same on all sides. */
+ if (horizontal)
+ border = stepper->y - check_rectangle.y;
+ else
+ border = stepper->x - check_rectangle.x;
+
+ check_rectangle.x += border;
+ check_rectangle.y += border;
+
+ if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+ if (horizontal)
+ value = MN_SCROLLBAR_HSTEPPER_A;
+ else
+ value = MN_SCROLLBAR_VSTEPPER_A;
+
+ if (!value) /* Haven't found a match */
+ {
+ if (horizontal)
+ check_rectangle.x = widget->allocation.x + border + stepper->width;
+ else
+ check_rectangle.y = widget->allocation.y + border + stepper->height;
+
+ if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+ if (horizontal)
+ value = MN_SCROLLBAR_HSTEPPER_B;
+ else
+ value = MN_SCROLLBAR_VSTEPPER_B;
+ }
+
+ if (!value) /* Still haven't found a match */
+ {
+ if (horizontal)
+ check_rectangle.x = widget->allocation.x + widget->allocation.width - (stepper->width + border) * 2;
+ else
+ check_rectangle.y = widget->allocation.y + widget->allocation.height - (stepper->height + border) * 2;
+
+ if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+ if (horizontal)
+ value = MN_SCROLLBAR_HSTEPPER_C;
+ else
+ value = MN_SCROLLBAR_VSTEPPER_C;
+ }
+
+ if (!value) /* STILL haven't found a match */
+ {
+ if (horizontal)
+ check_rectangle.x = widget->allocation.x + widget->allocation.width - 2*border - stepper->width;
+ else
+ check_rectangle.y = widget->allocation.y + widget->allocation.height - 2*border - stepper->height;
+
+ if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+ if (horizontal)
+ value = MN_SCROLLBAR_HSTEPPER_D;
+ else
+ value = MN_SCROLLBAR_VSTEPPER_D;
+ }
+
+ return value;
+}
+
static void
monet_gtk_draw_box (GtkStyle *style,
GdkWindow *window,
@@ -312,6 +409,27 @@ monet_gtk_draw_box (GtkStyle *style,
{
mn_widget = MN_TOOL_BAR;
}
+ else if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar"))
+ mn_widget = _scrollbar_get_stepper (widget, area);
+ else if (DETAIL ("slider"))
+ {
+ if (widget && GTK_IS_SCROLLBAR (widget))
+ {
+ mn_widget = MN_VSCROLLBAR_SLIDER;
+ if (_check_orientable_is_horizontal (GTK_ORIENTABLE (widget)))
+ mn_widget = MN_HSCROLLBAR_SLIDER;
+ }
+ }
+ else if (DETAIL ("trough"))
+ {
+ if (widget && GTK_IS_SCROLLBAR (widget))
+ {
+ mn_widget = MN_VSCROLLBAR_BG;
+ if (_check_orientable_is_horizontal (GTK_ORIENTABLE (widget)))
+ mn_widget = MN_HSCROLLBAR_BG;
+ }
+ }
+
if (mn_widget != NULL)
{
diff --git a/monet/mn-config.h b/monet/mn-config.h
index bba10d8..492a456 100644
--- a/monet/mn-config.h
+++ b/monet/mn-config.h
@@ -69,6 +69,19 @@ typedef struct
#define MN_MENU_ITEM "menu-item"
#define MN_MENU_BAR "menu-bar"
#define MN_TOOL_BAR "tool-bar"
+#define MN_SCOLLBAR_HSTEPPER_A
+#define MN_VSCROLLBAR_SLIDER "scrollbar-vertical-slider"
+#define MN_HSCROLLBAR_SLIDER "scrollbar-horizontal-slider"
+#define MN_VSCROLLBAR_BG "scrollbar-vertical-background"
+#define MN_HSCROLLBAR_BG "scrollbar-horizontal-background"
+#define MN_SCROLLBAR_VSTEPPER_A "scrollbar-vstepper-a"
+#define MN_SCROLLBAR_VSTEPPER_B "scrollbar-vstepper-b"
+#define MN_SCROLLBAR_VSTEPPER_C "scrollbar-vstepper-c"
+#define MN_SCROLLBAR_VSTEPPER_D "scrollbar-vstepper-d"
+#define MN_SCROLLBAR_HSTEPPER_A "scrollbar-hstepper-a"
+#define MN_SCROLLBAR_HSTEPPER_B "scrollbar-hstepper-b"
+#define MN_SCROLLBAR_HSTEPPER_C "scrollbar-hstepper-c"
+#define MN_SCROLLBAR_HSTEPPER_D "scrollbar-hstepper-d"
struct _MnConfig
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]