summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--ChangeLog.pre-2-033
-rw-r--r--ChangeLog.pre-2-1033
-rw-r--r--ChangeLog.pre-2-233
-rw-r--r--ChangeLog.pre-2-433
-rw-r--r--ChangeLog.pre-2-633
-rw-r--r--ChangeLog.pre-2-833
-rw-r--r--gdk/gdkcolor.h2
-rw-r--r--gtk/gtkcheckbutton.c9
-rw-r--r--gtk/gtkcheckmenuitem.c55
-rw-r--r--gtk/gtkcheckmenuitem.h5
-rw-r--r--gtk/gtkradiobutton.c3
-rw-r--r--gtk/gtkradiomenuitem.c3
-rw-r--r--gtk/gtkstyle.c120
-rw-r--r--gtk/gtktogglebutton.c60
-rw-r--r--gtk/gtktogglebutton.h4
-rw-r--r--gtk/testgtk.c21
-rw-r--r--tests/testgtk.c21
18 files changed, 474 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 557d3e2c28..edc4d8403f 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,36 @@
+2001-02-19 Havoc Pennington <hp@redhat.com>
+
+ * gdk/gdkcolor.h: test was backward, so deprecated functions were
+ excluded by default
+
+ * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+ clean up the old code a bit
+
+ * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+ inconsistent state
+
+ * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+ draw inconsistent state
+
+ * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+ (create_menu): add inconsistent test
+
+ * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+ new function
+ (gtk_check_menu_item_get_inconsistent): new function
+ (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+ state (using etched in for now)
+
+ * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+ draw inconsistent state
+
+ * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+ function, used when the user has selected a range of stuff in
+ different states
+ (gtk_toggle_button_get_inconsistent): accessor for that
+ (gtk_toggle_button_paint): draw inconsistent state (etched in?
+ don't know what else to do)
+
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
diff --git a/gdk/gdkcolor.h b/gdk/gdkcolor.h
index e703b38d9d..8487ca36e8 100644
--- a/gdk/gdkcolor.h
+++ b/gdk/gdkcolor.h
@@ -97,7 +97,7 @@ gboolean gdk_color_equal (const GdkColor *colora,
const GdkColor *colorb);
/* The following functions are deprecated */
-#ifdef GDK_DISABLE_DEPRECATED
+#ifndef GDK_DISABLE_DEPRECATED
void gdk_colors_store (GdkColormap *colormap,
GdkColor *colors,
gint ncolors);
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 681082d7ec..dc92a23c8d 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -356,8 +356,13 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
-
- if (GTK_TOGGLE_BUTTON (widget)->active)
+
+ if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
+ {
+ state_type = GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget);
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ }
+ else if (GTK_TOGGLE_BUTTON (widget)->active)
{
state_type = GTK_STATE_ACTIVE;
shadow_type = GTK_SHADOW_IN;
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index 09b37baf79..a7cabb7361 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -173,6 +173,52 @@ gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item)
gtk_signal_emit (GTK_OBJECT (check_menu_item), check_menu_item_signals[TOGGLED]);
}
+/**
+ * gtk_check_menu_item_set_inconsistent:
+ * @check_menu_item: a #GtkCheckMenuItem
+ * @setting: %TRUE to display an "inconsistent" third state check
+ *
+ * If the user has selected a range of elements (such as some text or
+ * spreadsheet cells) that are affected by a boolean setting, and the
+ * current values in that range are inconsistent, you may want to
+ * display the check in an "in between" state. This function turns on
+ * "in between" display. Normally you would turn off the inconsistent
+ * state again if the user explicitly selects a setting. This has to be
+ * done manually, gtk_check_menu_item_set_inconsistent() only affects
+ * visual appearance, it doesn't affect the semantics of the widget.
+ *
+ **/
+void
+gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
+ gboolean setting)
+{
+ g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
+
+ setting = setting != FALSE;
+
+ if (setting != check_menu_item->inconsistent)
+ {
+ check_menu_item->inconsistent = setting;
+ gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
+ }
+}
+
+/**
+ * gtk_check_menu_item_get_inconsistent:
+ * @check_menu_item: a #GtkCheckMenuItem
+ *
+ * Retrieves the value set by gtk_check_menu_item_set_inconsistent().
+ *
+ * Return value: %TRUE if inconsistent
+ **/
+gboolean
+gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
+{
+ g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
+
+ return check_menu_item->inconsistent;
+}
+
static void
gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
{
@@ -265,7 +311,14 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
(state_type == GTK_STATE_PRELIGHT))
shadow_type = GTK_SHADOW_OUT;
}
-
+
+ if (check_menu_item->inconsistent)
+ {
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ if (state_type == GTK_STATE_ACTIVE)
+ state_type = GTK_STATE_NORMAL;
+ }
+
gtk_paint_check (widget->style, widget->window,
state_type, shadow_type,
area, widget, "check",
diff --git a/gtk/gtkcheckmenuitem.h b/gtk/gtkcheckmenuitem.h
index 4142fe9030..010088c366 100644
--- a/gtk/gtkcheckmenuitem.h
+++ b/gtk/gtkcheckmenuitem.h
@@ -54,6 +54,7 @@ struct _GtkCheckMenuItem
guint active : 1;
guint always_show_toggle : 1;
+ guint inconsistent : 1;
};
struct _GtkCheckMenuItemClass
@@ -75,6 +76,10 @@ void gtk_check_menu_item_set_show_toggle (GtkCheckMenuItem *menu_item,
gboolean always);
void gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item);
+void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
+ gboolean setting);
+gboolean gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item);
+
#ifdef __cplusplus
}
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 093993aea7..e231f51f95 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -416,6 +416,9 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;
+
+ if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
+ shadow_type = GTK_SHADOW_ETCHED_IN;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
x = widget->allocation.x + widget->allocation.width - (width + x - widget->allocation.x);
diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c
index a8b2ac3207..27db681dcb 100644
--- a/gtk/gtkradiomenuitem.c
+++ b/gtk/gtkradiomenuitem.c
@@ -298,6 +298,9 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
else
shadow_type = GTK_SHADOW_OUT;
+ if (check_menu_item->inconsistent)
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+
gtk_paint_option (widget->style, widget->window,
state_type, shadow_type,
area, widget, "option",
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 3469c74cdc..20013e4f56 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -2229,6 +2229,18 @@ gtk_default_draw_diamond (GtkStyle *style,
{
gint half_width;
gint half_height;
+ GdkGC *outer_nw = NULL;
+ GdkGC *outer_ne = NULL;
+ GdkGC *outer_sw = NULL;
+ GdkGC *outer_se = NULL;
+ GdkGC *middle_nw = NULL;
+ GdkGC *middle_ne = NULL;
+ GdkGC *middle_sw = NULL;
+ GdkGC *middle_se = NULL;
+ GdkGC *inner_nw = NULL;
+ GdkGC *inner_ne = NULL;
+ GdkGC *inner_sw = NULL;
+ GdkGC *inner_se = NULL;
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
@@ -2250,89 +2262,91 @@ gtk_default_draw_diamond (GtkStyle *style,
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->black_gc, area);
}
+
switch (shadow_type)
{
case GTK_SHADOW_IN:
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 2, y + half_height,
- x + half_width, y + height - 2);
- gdk_draw_line (window, style->bg_gc[state_type],
- x + half_width, y + height - 2,
- x + width - 2, y + half_height);
- gdk_draw_line (window, style->light_gc[state_type],
- x + 1, y + half_height,
- x + half_width, y + height - 1);
- gdk_draw_line (window, style->light_gc[state_type],
- x + half_width, y + height - 1,
- x + width - 1, y + half_height);
- gdk_draw_line (window, style->light_gc[state_type],
- x, y + half_height,
- x + half_width, y + height);
- gdk_draw_line (window, style->light_gc[state_type],
- x + half_width, y + height,
- x + width, y + half_height);
-
- gdk_draw_line (window, style->black_gc,
- x + 2, y + half_height,
- x + half_width, y + 2);
- gdk_draw_line (window, style->black_gc,
- x + half_width, y + 2,
- x + width - 2, y + half_height);
- gdk_draw_line (window, style->dark_gc[state_type],
- x + 1, y + half_height,
- x + half_width, y + 1);
- gdk_draw_line (window, style->dark_gc[state_type],
- x + half_width, y + 1,
- x + width - 1, y + half_height);
- gdk_draw_line (window, style->dark_gc[state_type],
- x, y + half_height,
- x + half_width, y);
- gdk_draw_line (window, style->dark_gc[state_type],
- x + half_width, y,
- x + width, y + half_height);
+ inner_sw = inner_se = style->bg_gc[state_type];
+ middle_sw = middle_se = style->light_gc[state_type];
+ outer_sw = outer_se = style->light_gc[state_type];
+ inner_nw = inner_ne = style->black_gc;
+ middle_nw = middle_ne = style->dark_gc[state_type];
+ outer_nw = outer_ne = style->dark_gc[state_type];
break;
+
case GTK_SHADOW_OUT:
- gdk_draw_line (window, style->dark_gc[state_type],
+ inner_sw = inner_se = style->dark_gc[state_type];
+ middle_sw = middle_se = style->dark_gc[state_type];
+ outer_sw = outer_se = style->black_gc;
+ inner_nw = inner_ne = style->bg_gc[state_type];
+ middle_nw = middle_ne = style->light_gc[state_type];
+ outer_nw = outer_ne = style->light_gc[state_type];
+ break;
+
+ case GTK_SHADOW_ETCHED_IN:
+ inner_sw = inner_se = style->bg_gc[state_type];
+ middle_sw = middle_se = style->dark_gc[state_type];
+ outer_sw = outer_se = style->light_gc[state_type];
+ inner_nw = inner_ne = style->bg_gc[state_type];
+ middle_nw = middle_ne = style->light_gc[state_type];
+ outer_nw = outer_ne = style->dark_gc[state_type];
+ break;
+
+ case GTK_SHADOW_ETCHED_OUT:
+ inner_sw = inner_se = style->bg_gc[state_type];
+ middle_sw = middle_se = style->light_gc[state_type];
+ outer_sw = outer_se = style->dark_gc[state_type];
+ inner_nw = inner_ne = style->bg_gc[state_type];
+ middle_nw = middle_ne = style->dark_gc[state_type];
+ outer_nw = outer_ne = style->light_gc[state_type];
+ break;
+
+ default:
+
+ break;
+ }
+
+ if (inner_sw)
+ {
+ gdk_draw_line (window, inner_sw,
x + 2, y + half_height,
x + half_width, y + height - 2);
- gdk_draw_line (window, style->dark_gc[state_type],
+ gdk_draw_line (window, inner_se,
x + half_width, y + height - 2,
x + width - 2, y + half_height);
- gdk_draw_line (window, style->dark_gc[state_type],
+ gdk_draw_line (window, middle_sw,
x + 1, y + half_height,
x + half_width, y + height - 1);
- gdk_draw_line (window, style->dark_gc[state_type],
+ gdk_draw_line (window, middle_se,
x + half_width, y + height - 1,
x + width - 1, y + half_height);
- gdk_draw_line (window, style->black_gc,
+ gdk_draw_line (window, outer_sw,
x, y + half_height,
x + half_width, y + height);
- gdk_draw_line (window, style->black_gc,
+ gdk_draw_line (window, outer_se,
x + half_width, y + height,
x + width, y + half_height);
-
- gdk_draw_line (window, style->bg_gc[state_type],
+
+ gdk_draw_line (window, inner_nw,
x + 2, y + half_height,
x + half_width, y + 2);
- gdk_draw_line (window, style->bg_gc[state_type],
+ gdk_draw_line (window, inner_ne,
x + half_width, y + 2,
x + width - 2, y + half_height);
- gdk_draw_line (window, style->light_gc[state_type],
+ gdk_draw_line (window, middle_nw,
x + 1, y + half_height,
x + half_width, y + 1);
- gdk_draw_line (window, style->light_gc[state_type],
+ gdk_draw_line (window, middle_ne,
x + half_width, y + 1,
x + width - 1, y + half_height);
- gdk_draw_line (window, style->light_gc[state_type],
+ gdk_draw_line (window, outer_nw,
x, y + half_height,
x + half_width, y);
- gdk_draw_line (window, style->light_gc[state_type],
+ gdk_draw_line (window, outer_ne,
x + half_width, y,
x + width, y + half_height);
- break;
- default:
- break;
}
+
if (area)
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index c1bb468562..e51ee8400f 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -305,6 +305,51 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button)
gtk_signal_emit (GTK_OBJECT (toggle_button), toggle_button_signals[TOGGLED]);
}
+/**
+ * gtk_toggle_button_set_inconsistent:
+ * @toggle_button: a #GtkToggleButton
+ * @setting: %TRUE if state is inconsistent
+ *
+ * If the user has selected a range of elements (such as some text or
+ * spreadsheet cells) that are affected by a toggle button, and the
+ * current values in that range are inconsistent, you may want to
+ * display the toggle in an "in between" state. This function turns on
+ * "in between" display. Normally you would turn off the inconsistent
+ * state again if the user toggles the toggle button. This has to be
+ * done manually, gtk_toggle_button_set_inconsistent() only affects
+ * visual appearance, it doesn't affect the semantics of the button.
+ *
+ **/
+void
+gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
+ gboolean setting)
+{
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+
+ setting = setting != FALSE;
+
+ if (setting != toggle_button->inconsistent)
+ {
+ toggle_button->inconsistent = setting;
+ gtk_widget_queue_draw (GTK_WIDGET (toggle_button));
+ }
+}
+
+/**
+ * gtk_toggle_button_get_inconsistent:
+ * @toggle_button: a #GtkToggleButton
+ *
+ * Gets the value set by gtk_toggle_button_set_inconsistent().
+ *
+ * Return value: %TRUE if the button is displayed as inconsistent, %FALSE otherwise
+ **/
+gboolean
+gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button)
+{
+ g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE);
+
+ return toggle_button->inconsistent;
+}
static void
gtk_toggle_button_paint (GtkWidget *widget,
@@ -313,6 +358,7 @@ gtk_toggle_button_paint (GtkWidget *widget,
GtkButton *button;
GtkToggleButton *toggle_button;
GtkShadowType shadow_type;
+ GtkStateType state_type;
gint width, height;
gint x, y;
@@ -356,9 +402,17 @@ gtk_toggle_button_paint (GtkWidget *widget,
height -= 2;
}
- if ((GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) ||
+ state_type = GTK_WIDGET_STATE (widget);
+
+ if (toggle_button->inconsistent)
+ {
+ if (state_type == GTK_STATE_ACTIVE)
+ state_type = GTK_STATE_NORMAL;
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ }
+ else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) ||
toggle_button->active)
- shadow_type = GTK_SHADOW_IN;
+ shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;
@@ -366,7 +420,7 @@ gtk_toggle_button_paint (GtkWidget *widget,
(GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL &&
GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))
gtk_paint_box (widget->style, widget->window,
- GTK_WIDGET_STATE (widget),
+ state_type,
shadow_type, area, widget, "togglebutton",
x, y, width, height);
diff --git a/gtk/gtktogglebutton.h b/gtk/gtktogglebutton.h
index def107e5ac..c00b98bad5 100644
--- a/gtk/gtktogglebutton.h
+++ b/gtk/gtktogglebutton.h
@@ -54,6 +54,7 @@ struct _GtkToggleButton
guint active : 1;
guint draw_indicator : 1;
+ guint inconsistent : 1;
GdkWindow *event_window;
};
@@ -76,6 +77,9 @@ void gtk_toggle_button_set_active (GtkToggleButton *toggle_button,
gboolean gtk_toggle_button_get_active (GtkToggleButton *toggle_button);
void gtk_toggle_button_toggled (GtkToggleButton *toggle_button);
+void gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
+ gboolean setting);
+gboolean gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button);
#ifdef __cplusplus
}
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 97bf5e270d..41374de05b 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -316,6 +316,10 @@ create_toggle_buttons (void)
button = gtk_toggle_button_new_with_label ("button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ button = gtk_toggle_button_new_with_label ("inconsistent");
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
@@ -378,6 +382,10 @@ create_check_buttons (void)
button = gtk_check_button_new_with_label ("button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ button = gtk_check_button_new_with_label ("inconsistent");
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
@@ -445,6 +453,12 @@ create_radio_buttons (void)
"button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ button = gtk_radio_button_new_with_label (
+ gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
+ "inconsistent");
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
@@ -2788,15 +2802,22 @@ create_menu (gint depth, gint length, gboolean tearoff)
for (i = 0, j = 1; i < length; i++, j++)
{
sprintf (buf, "item %2d - %d", depth, j);
+
menuitem = gtk_radio_menu_item_new_with_label (group, buf);
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
+
if (depth % 2)
gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
+
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
if (i == 3)
gtk_widget_set_sensitive (menuitem, FALSE);
+ if (i == 5)
+ gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (menuitem),
+ TRUE);
+
if (i < 5)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, 5, TRUE));
}
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 97bf5e270d..41374de05b 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -316,6 +316,10 @@ create_toggle_buttons (void)
button = gtk_toggle_button_new_with_label ("button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ button = gtk_toggle_button_new_with_label ("inconsistent");
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
@@ -378,6 +382,10 @@ create_check_buttons (void)
button = gtk_check_button_new_with_label ("button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ button = gtk_check_button_new_with_label ("inconsistent");
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
@@ -445,6 +453,12 @@ create_radio_buttons (void)
"button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ button = gtk_radio_button_new_with_label (
+ gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
+ "inconsistent");
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
@@ -2788,15 +2802,22 @@ create_menu (gint depth, gint length, gboolean tearoff)
for (i = 0, j = 1; i < length; i++, j++)
{
sprintf (buf, "item %2d - %d", depth, j);
+
menuitem = gtk_radio_menu_item_new_with_label (group, buf);
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
+
if (depth % 2)
gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
+
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
if (i == 3)
gtk_widget_set_sensitive (menuitem, FALSE);
+ if (i == 5)
+ gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (menuitem),
+ TRUE);
+
if (i < 5)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, 5, TRUE));
}