summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbbox.h2
-rw-r--r--gtk/gtkbutton.c45
-rw-r--r--gtk/gtkbutton.h23
-rw-r--r--gtk/gtkcolorsel.h32
-rw-r--r--gtk/gtkenums.h7
-rw-r--r--gtk/gtktoolbar.c40
-rw-r--r--gtk/gtktoolbar.h4
-rw-r--r--gtk/gtkvbbox.h2
-rw-r--r--gtk/gtkwindow.c4
-rw-r--r--gtk/gtkwindow.h4
-rw-r--r--gtk/testgtk.c39
11 files changed, 164 insertions, 38 deletions
diff --git a/gtk/gtkbbox.h b/gtk/gtkbbox.h
index 22bbd497d1..6ec7585926 100644
--- a/gtk/gtkbbox.h
+++ b/gtk/gtkbbox.h
@@ -19,7 +19,7 @@
#ifndef __GTK_BUTTON_BOX_H__
#define __GTK_BUTTON_BOX_H__
-#include "gtkbox.h"
+#include <gtk/gtkbox.h>
#ifdef __cplusplus
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 68933ed224..d54c98b645 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -206,6 +206,7 @@ gtk_button_init (GtkButton *button)
button->child = NULL;
button->in_button = FALSE;
button->button_down = FALSE;
+ button->relief = GTK_RELIEF_NORMAL;
}
static void
@@ -290,6 +291,25 @@ gtk_button_leave (GtkButton *button)
gtk_signal_emit (GTK_OBJECT (button), button_signals[LEAVE]);
}
+void
+gtk_button_set_relief (GtkButton *button,
+ GtkReliefStyle newrelief)
+{
+ g_return_if_fail (button != NULL);
+ g_return_if_fail (GTK_IS_BUTTON (button));
+
+ button->relief = newrelief;
+}
+
+GtkReliefStyle
+gtk_button_get_relief(GtkButton *button)
+{
+ g_return_val_if_fail (button != NULL, GTK_RELIEF_NORMAL);
+ g_return_val_if_fail (GTK_IS_BUTTON (button), GTK_RELIEF_NORMAL);
+
+ return button->relief;
+}
+
static void
gtk_button_map (GtkWidget *widget)
{
@@ -507,7 +527,11 @@ gtk_button_paint (GtkWidget *widget,
if (gdk_rectangle_intersect (area, &restrict_area, &new_area))
{
- gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (widget));
+ if ((GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) &&
+ (GTK_BUTTON (widget)->relief == GTK_RELIEF_NONE))
+ gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ else
+ gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (widget));
gdk_window_clear_area (widget->window,
new_area.x, new_area.y,
new_area.width, new_area.height);
@@ -631,10 +655,14 @@ gtk_button_draw_focus (GtkWidget *widget)
gdk_draw_rectangle (widget->window,
widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE,
x + 1, y + 1, width - 4, height - 4);
- else
+ else if (button->relief == GTK_RELIEF_NORMAL)
gdk_draw_rectangle (widget->window,
widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE,
x + 2, y + 2, width - 5, height - 5);
+ else
+ gdk_draw_rectangle (widget->window,
+ widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE,
+ x, y, width - 1, height - 1);
}
if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE)
@@ -642,9 +670,14 @@ gtk_button_draw_focus (GtkWidget *widget)
else
shadow_type = GTK_SHADOW_OUT;
- gtk_draw_shadow (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), shadow_type,
- x, y, width, height);
+ if ((button->relief == GTK_RELIEF_NORMAL) ||
+ ((GTK_WIDGET_STATE (widget) != GTK_STATE_NORMAL) &&
+ (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE)))
+ {
+ gtk_draw_shadow (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget), shadow_type,
+ x, y, width, height);
+ }
if (GTK_WIDGET_HAS_FOCUS (widget))
{
@@ -676,7 +709,7 @@ gtk_button_draw_default (GtkWidget *widget)
width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2;
- if (GTK_WIDGET_HAS_DEFAULT (widget))
+ if (GTK_WIDGET_HAS_DEFAULT (widget) && gtk_button_get_relief (GTK_BUTTON (widget)) == GTK_RELIEF_NORMAL)
{
gtk_draw_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h
index 66b5f5eb06..0a74aba7fd 100644
--- a/gtk/gtkbutton.h
+++ b/gtk/gtkbutton.h
@@ -22,6 +22,7 @@
#include <gdk/gdk.h>
#include <gtk/gtkcontainer.h>
+#include <gtk/gtkenums.h>
#ifdef __cplusplus
@@ -47,12 +48,13 @@ struct _GtkButton
guint in_button : 1;
guint button_down : 1;
+ guint relief : 2;
};
struct _GtkButtonClass
{
GtkContainerClass parent_class;
-
+
void (* pressed) (GtkButton *button);
void (* released) (GtkButton *button);
void (* clicked) (GtkButton *button);
@@ -61,14 +63,17 @@ struct _GtkButtonClass
};
-GtkType gtk_button_get_type (void);
-GtkWidget* gtk_button_new (void);
-GtkWidget* gtk_button_new_with_label (const gchar *label);
-void gtk_button_pressed (GtkButton *button);
-void gtk_button_released (GtkButton *button);
-void gtk_button_clicked (GtkButton *button);
-void gtk_button_enter (GtkButton *button);
-void gtk_button_leave (GtkButton *button);
+GtkType gtk_button_get_type (void);
+GtkWidget* gtk_button_new (void);
+GtkWidget* gtk_button_new_with_label (const gchar *label);
+void gtk_button_pressed (GtkButton *button);
+void gtk_button_released (GtkButton *button);
+void gtk_button_clicked (GtkButton *button);
+void gtk_button_enter (GtkButton *button);
+void gtk_button_leave (GtkButton *button);
+void gtk_button_set_relief (GtkButton *button,
+ GtkReliefStyle newstyle);
+GtkReliefStyle gtk_button_get_relief (GtkButton *button);
#ifdef __cplusplus
diff --git a/gtk/gtkcolorsel.h b/gtk/gtkcolorsel.h
index acb44e38e0..9646605fe9 100644
--- a/gtk/gtkcolorsel.h
+++ b/gtk/gtkcolorsel.h
@@ -24,22 +24,22 @@
#include <math.h>
#include <gdk/gdk.h>
-#include "gtkwindow.h"
-#include "gtkvbox.h"
-#include "gtkframe.h"
-#include "gtkpreview.h"
-#include "gtkbutton.h"
-#include "gtkentry.h"
-#include "gtkhbox.h"
-#include "gtklabel.h"
-#include "gtkmain.h"
-#include "gtksignal.h"
-#include "gtkmisc.h"
-#include "gtkrange.h"
-#include "gtkscale.h"
-#include "gtkhscale.h"
-#include "gtktable.h"
-#include "gtkeventbox.h"
+#include <gtk/gtkwindow.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkframe.h>
+#include <gtk/gtkpreview.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkmisc.h>
+#include <gtk/gtkrange.h>
+#include <gtk/gtkscale.h>
+#include <gtk/gtkhscale.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkeventbox.h>
#ifdef __cplusplus
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 9624090ad0..130ed1091c 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -209,6 +209,13 @@ typedef enum
GTK_TOOLBAR_BOTH
} GtkToolbarStyle;
+/* Style for buttons */
+typedef enum
+{
+ GTK_RELIEF_NORMAL,
+ GTK_RELIEF_NONE
+} GtkReliefStyle;
+
/* Generic visibility flags */
typedef enum
{
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index ac1dda62ae..ad19b4b209 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -160,6 +160,7 @@ gtk_toolbar_init (GtkToolbar *toolbar)
toolbar->children = NULL;
toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
toolbar->style = GTK_TOOLBAR_ICONS;
+ toolbar->relief = GTK_RELIEF_NORMAL;
toolbar->space_size = DEFAULT_SPACE_SIZE;
toolbar->tooltips = gtk_tooltips_new ();
toolbar->button_maxw = 0;
@@ -765,7 +766,10 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
case GTK_TOOLBAR_CHILD_RADIOBUTTON:
if (type == GTK_TOOLBAR_CHILD_BUTTON)
- child->widget = gtk_button_new ();
+ {
+ child->widget = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (child->widget), toolbar->relief);
+ }
else if (type == GTK_TOOLBAR_CHILD_TOGGLEBUTTON)
{
child->widget = gtk_toggle_button_new ();
@@ -881,6 +885,40 @@ gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
gtk_tooltips_disable (toolbar->tooltips);
}
+void
+gtk_toolbar_set_button_relief (GtkToolbar *toolbar,
+ GtkReliefStyle relief)
+{
+ GList *children;
+ GtkToolbarChild *child;
+
+ g_return_if_fail (toolbar != NULL);
+ g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
+
+ if (toolbar->relief != relief)
+ {
+ toolbar->relief = relief;
+
+ for (children = toolbar->children; children; children = children->next)
+ {
+ child = children->data;
+ if (child->type == GTK_TOOLBAR_CHILD_BUTTON)
+ gtk_button_set_relief (GTK_BUTTON (child->widget), relief);
+ }
+
+ gtk_widget_queue_resize (GTK_WIDGET (toolbar));
+ }
+}
+
+GtkReliefStyle
+gtk_toolbar_get_button_relief (GtkToolbar *toolbar)
+{
+ g_return_val_if_fail (toolbar != NULL, GTK_RELIEF_NORMAL);
+ g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), GTK_RELIEF_NORMAL);
+
+ return toolbar->relief;
+}
+
static void
gtk_toolbar_marshal_signal_1 (GtkObject *object,
GtkSignalFunc func,
diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h
index 8e81abf9ab..ea689460be 100644
--- a/gtk/gtktoolbar.h
+++ b/gtk/gtktoolbar.h
@@ -75,6 +75,7 @@ struct _GtkToolbar
gint button_maxw;
gint button_maxh;
+ GtkReliefStyle relief;
};
struct _GtkToolbarClass
@@ -178,6 +179,9 @@ void gtk_toolbar_set_space_size (GtkToolbar *toolbar,
gint space_size);
void gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
gint enable);
+void gtk_toolbar_set_button_relief (GtkToolbar *toolbar,
+ GtkReliefStyle relief);
+GtkReliefStyle gtk_toolbar_get_button_relief (GtkToolbar *toolbar);
#ifdef __cplusplus
diff --git a/gtk/gtkvbbox.h b/gtk/gtkvbbox.h
index 493c9c3459..596b304d40 100644
--- a/gtk/gtkvbbox.h
+++ b/gtk/gtkvbbox.h
@@ -20,7 +20,7 @@
#define __GTK_VBUTTON_BOX_H__
-#include "gtkbbox.h"
+#include <gtk/gtkbbox.h>
#ifdef __cplusplus
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index d077514dff..c618097d03 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -329,8 +329,8 @@ gtk_window_set_title (GtkWindow *window,
void
gtk_window_set_wmclass (GtkWindow *window,
- gchar *wmclass_name,
- gchar *wmclass_class)
+ const gchar *wmclass_name,
+ const gchar *wmclass_class)
{
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 8940f8525f..5c90caf6a1 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -84,8 +84,8 @@ GtkWidget* gtk_window_new (GtkWindowType type);
void gtk_window_set_title (GtkWindow *window,
const gchar *title);
void gtk_window_set_wmclass (GtkWindow *window,
- gchar *wmclass_name,
- gchar *wmclass_class);
+ const gchar *wmclass_name,
+ const gchar *wmclass_class);
void gtk_window_set_focus (GtkWindow *window,
GtkWidget *focus);
void gtk_window_set_default (GtkWindow *window,
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 4ed3a25eb3..a851873262 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -649,6 +649,20 @@ set_toolbar_disable (GtkWidget *widget,
}
static void
+set_toolbar_borders (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_toolbar_set_button_relief (GTK_TOOLBAR (data), GTK_RELIEF_NORMAL);
+}
+
+static void
+set_toolbar_borderless (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_toolbar_set_button_relief (GTK_TOOLBAR (data), GTK_RELIEF_NONE);
+}
+
+static void
create_toolbar (void)
{
static GtkWidget *window = NULL;
@@ -669,6 +683,7 @@ create_toolbar (void)
gtk_widget_realize (window);
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
+ gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
"Horizontal", "Horizontal toolbar layout", "Toolbar/Horizontal",
@@ -722,6 +737,17 @@ create_toolbar (void)
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
(GtkSignalFunc) set_toolbar_disable, toolbar);
+ gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
+ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+ "Borders", "Show Borders", NULL,
+ new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+ (GtkSignalFunc) set_toolbar_borders, toolbar);
+ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+ "Borderless", "Hide Borders", NULL,
+ new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+ (GtkSignalFunc) set_toolbar_borderless, toolbar);
+
gtk_container_add (GTK_CONTAINER (window), toolbar);
gtk_widget_show (toolbar);
}
@@ -741,6 +767,7 @@ make_toolbar (GtkWidget *window)
gtk_widget_realize (window);
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
+ gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
"Horizontal", "Horizontal toolbar layout", NULL,
@@ -788,6 +815,17 @@ make_toolbar (GtkWidget *window)
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
(GtkSignalFunc) set_toolbar_disable, toolbar);
+ gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
+ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+ "Borders", "Show Borders", NULL,
+ new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+ (GtkSignalFunc) set_toolbar_borders, toolbar);
+ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+ "Borderless", "Hide Borders", NULL,
+ new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+ (GtkSignalFunc) set_toolbar_borderless, toolbar);
+
return toolbar;
}
@@ -1553,6 +1591,7 @@ create_handle_box (void)
gtk_widget_show (handle_box);
toolbar = make_toolbar (window);
+ gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NORMAL);
gtk_container_add (GTK_CONTAINER (handle_box), toolbar);
gtk_widget_show (toolbar);