summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-03-07 21:10:44 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-03-07 21:10:44 +0000
commit9d1e2a13231fd894a5b7a0ee5a95035af6f55745 (patch)
tree19e4394033514eb94c7875eb3aca9fec606bcc3a /gtk
parent3beaeae49f22e90cb5672c456f635152a9d720dc (diff)
downloadgtk+-9d1e2a13231fd894a5b7a0ee5a95035af6f55745.tar.gz
new function, turns off decorations for a window.
2001-03-07 Havoc Pennington <hp@redhat.com> * gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns off decorations for a window. * demos/gtk-demo/button_box.c (create_bbox): adapt to button box changes * gtk/gtklabel.c (gtk_label_get_layout_offsets): new function to get location of PangoLayout inside the label, closes #51198 * gtk/testgtk.c (create_bbox): fix up button box usage * gtk/testcalendar.c (create_calendar): fix up button box usage * gtk/gtkfilesel.c (gtk_file_selection_init): fixup buttonbox usage * gtk/gtkdialog.c (gtk_dialog_init): fixup buttonbox usage * gtk/gtkhbbox.h: deprecations * gtk/gtkvbbox.h: deprecations * gtk/gtkbox.c (gtk_box_get_spacing): new function, used to emulate deprecated gtk_button_box_get_spacing * gtk/gtkbbox.h: deprecate some useless functions, remove entirely the "set global default" functions (struct _GtkButtonBox): remove "spacing" field, use the one from GtkBox base class * gtk/gtkbbox.c (_gtk_button_box_child_requisition): rename with uscore * gtk/gtkiconfactory.c (gtk_icon_set_render_icon): If we fail to render the icon, return the missing image icon. * gtk/gtkimage.c (gtk_image_set_from_file): fall back to missing image icon if the load fails. * gtk/gtkstock.h (GTK_STOCK_MISSING_IMAGE): Add stock icon for use when no image is found; should be the Netscape "missing image" icon eventually but for now is a random image * gtk/gtkwindow.c (gtk_window_set_role): new function, sets the role for the session manager * gtk/testgtk.c (dnd_drop): remove use of GTK_WINDOW_DIALOG * gtk/gtkcompat.h (GTK_WINDOW_DIALOG): compat #define GTK_WINDOW_DIALOG GTK_WINDOW_TOPLEVEL * gtk/gtkenums.h (enum GtkWindowType): remove GTK_WINDOW_DIALOG
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbbox.c60
-rw-r--r--gtk/gtkbbox.h33
-rw-r--r--gtk/gtkbox.c16
-rw-r--r--gtk/gtkbox.h1
-rw-r--r--gtk/gtkdialog.c2
-rw-r--r--gtk/gtkenums.h1
-rw-r--r--gtk/gtkfilesel.c2
-rw-r--r--gtk/gtkhbbox.c24
-rw-r--r--gtk/gtkhbbox.h3
-rw-r--r--gtk/gtkiconfactory.c31
-rw-r--r--gtk/gtkimage.c8
-rw-r--r--gtk/gtklabel.c25
-rw-r--r--gtk/gtklabel.h4
-rw-r--r--gtk/gtkstock.h2
-rw-r--r--gtk/gtkvbbox.c24
-rw-r--r--gtk/gtkvbbox.h2
-rw-r--r--gtk/gtkwindow.c115
-rw-r--r--gtk/gtkwindow.h12
-rw-r--r--gtk/testcalendar.c2
-rw-r--r--gtk/testgtk.c6
20 files changed, 249 insertions, 124 deletions
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index 5ee3b86d00..45fe3d3453 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -68,12 +68,16 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
GtkWidgetClass *widget_class;
widget_class = (GtkWidgetClass*) class;
+
+ /* FIXME we need to override the "spacing" property on GtkBox once
+ * libgobject allows that.
+ */
}
static void
gtk_button_box_init (GtkButtonBox *button_box)
{
- button_box->spacing = GTK_BUTTONBOX_DEFAULT;
+ GTK_BOX (button_box)->spacing = 0;
button_box->child_min_width = GTK_BUTTONBOX_DEFAULT;
button_box->child_min_height = GTK_BUTTONBOX_DEFAULT;
button_box->child_ipad_x = GTK_BUTTONBOX_DEFAULT;
@@ -81,43 +85,8 @@ gtk_button_box_init (GtkButtonBox *button_box)
button_box->layout_style = GTK_BUTTONBOX_DEFAULT_STYLE;
}
-
-/* set default values for child size and child internal padding */
-/* default spacing is in defined in subclasses */
-
-void gtk_button_box_set_child_size_default (gint width, gint height)
-{
- default_child_min_width = width;
- default_child_min_height = height;
-}
-
-void gtk_button_box_set_child_ipadding_default (gint ipad_x, gint ipad_y)
-{
- default_child_ipad_x = ipad_x;
- default_child_ipad_y = ipad_y;
-}
-
-/* get default values for child size and child internal padding */
-
-void gtk_button_box_get_child_size_default (gint *width, gint *height)
-{
- *width = default_child_min_width;
- *height = default_child_min_height;
-}
-
-void gtk_button_box_get_child_ipadding_default (gint *ipad_x, gint *ipad_y)
-{
- *ipad_x = default_child_ipad_x;
- *ipad_y = default_child_ipad_y;
-}
-
/* set per widget values for spacing, child size and child internal padding */
-void gtk_button_box_set_spacing (GtkButtonBox *widget, gint spacing)
-{
- widget->spacing = spacing;
-}
-
void gtk_button_box_set_child_size (GtkButtonBox *widget, gint width, gint height)
{
widget->child_min_width = width;
@@ -143,11 +112,6 @@ void gtk_button_box_set_layout (GtkButtonBox *widget,
/* get per widget values for spacing, child size and child internal padding */
-gint gtk_button_box_get_spacing (GtkButtonBox *widget)
-{
- return widget->spacing;
-}
-
void gtk_button_box_get_child_size (GtkButtonBox *widget,
gint *width, gint *height)
{
@@ -173,10 +137,10 @@ GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget)
to match minimum size and internal padding.
Returns the size each single child should have. */
void
-gtk_button_box_child_requisition (GtkWidget *widget,
- int *nvis_children,
- int *width,
- int *height)
+_gtk_button_box_child_requisition (GtkWidget *widget,
+ int *nvis_children,
+ int *width,
+ int *height)
{
GtkButtonBox *bbox;
GtkBoxChild *child;
@@ -202,8 +166,10 @@ gtk_button_box_child_requisition (GtkWidget *widget,
bbox = GTK_BUTTON_BOX (widget);
- gtk_button_box_get_child_size_default (&width_default, &height_default);
- gtk_button_box_get_child_ipadding_default (&ipad_x_default, &ipad_y_default);
+ width_default = default_child_min_width;
+ height_default = default_child_min_height;
+ ipad_x_default = default_child_ipad_x;
+ ipad_y_default = default_child_ipad_y;
child_min_width = bbox->child_min_width != GTK_BUTTONBOX_DEFAULT
? bbox->child_min_width : width_default;
diff --git a/gtk/gtkbbox.h b/gtk/gtkbbox.h
index ac2fd9f6a5..5ac286e799 100644
--- a/gtk/gtkbbox.h
+++ b/gtk/gtkbbox.h
@@ -51,7 +51,6 @@ typedef struct _GtkButtonBoxClass GtkButtonBoxClass;
struct _GtkButtonBox
{
GtkBox box;
- gint spacing;
gint child_min_width;
gint child_min_height;
gint child_ipad_x;
@@ -67,31 +66,27 @@ struct _GtkButtonBoxClass
GtkType gtk_button_box_get_type (void) G_GNUC_CONST;
-void gtk_button_box_get_child_size_default (gint *min_width, gint *min_height);
-void gtk_button_box_get_child_ipadding_default (gint *ipad_x, gint *ipad_y);
+GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget);
+void gtk_button_box_set_layout (GtkButtonBox *widget,
+ GtkButtonBoxStyle layout_style);
-void gtk_button_box_set_child_size_default (gint min_width, gint min_height);
-void gtk_button_box_set_child_ipadding_default (gint ipad_x, gint ipad_y);
+#ifndef GTK_DISABLE_DEPRECATED
+#define gtk_button_box_set_spacing gtk_box_set_spacing
+#define gtk_button_box_get_spacing gtk_box_get_spacing
-gint gtk_button_box_get_spacing (GtkButtonBox *widget);
-GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget);
-void gtk_button_box_get_child_size (GtkButtonBox *widget,
- gint *min_width, gint *min_height);
-void gtk_button_box_get_child_ipadding (GtkButtonBox *widget, gint *ipad_x, gint *ipad_y);
-
-void gtk_button_box_set_spacing (GtkButtonBox *widget, gint spacing);
-void gtk_button_box_set_layout (GtkButtonBox *widget,
- GtkButtonBoxStyle layout_style);
void gtk_button_box_set_child_size (GtkButtonBox *widget,
gint min_width, gint min_height);
void gtk_button_box_set_child_ipadding (GtkButtonBox *widget, gint ipad_x, gint ipad_y);
-
+void gtk_button_box_get_child_size (GtkButtonBox *widget,
+ gint *min_width, gint *min_height);
+void gtk_button_box_get_child_ipadding (GtkButtonBox *widget, gint *ipad_x, gint *ipad_y);
+#endif
/* Internal method - do not use. */
-void gtk_button_box_child_requisition (GtkWidget *widget,
- int *nvis_children,
- int *width,
- int *height);
+void _gtk_button_box_child_requisition (GtkWidget *widget,
+ int *nvis_children,
+ int *width,
+ int *height);
#ifdef __cplusplus
}
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 96fad211c0..e61d7a8a81 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -438,6 +438,22 @@ gtk_box_set_spacing (GtkBox *box,
}
}
+/**
+ * gtk_box_get_spacing:
+ * @box: a #GtkBox
+ *
+ * Gets the value set by gtk_box_set_spacing().
+ *
+ * Return value: spacing between children
+ **/
+gint
+gtk_box_get_spacing (GtkBox *box)
+{
+ g_return_if_fail (GTK_IS_BOX (box));
+
+ return box->spacing;
+}
+
void
gtk_box_reorder_child (GtkBox *box,
GtkWidget *child,
diff --git a/gtk/gtkbox.h b/gtk/gtkbox.h
index f079fb8fde..b6de573f5b 100644
--- a/gtk/gtkbox.h
+++ b/gtk/gtkbox.h
@@ -92,6 +92,7 @@ void gtk_box_set_homogeneous (GtkBox *box,
gboolean homogeneous);
void gtk_box_set_spacing (GtkBox *box,
gint spacing);
+gint gtk_box_get_spacing (GtkBox *box);
void gtk_box_reorder_child (GtkBox *box,
GtkWidget *child,
gint position);
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 1742f56780..ea47558750 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -129,7 +129,7 @@ gtk_dialog_init (GtkDialog *dialog)
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog->action_area),
GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (dialog->action_area), 5);
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
gtk_box_pack_end (GTK_BOX (dialog->vbox), dialog->action_area,
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index bb75cd24eb..b489b0744d 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -356,7 +356,6 @@ typedef enum
typedef enum
{
GTK_WINDOW_TOPLEVEL,
- GTK_WINDOW_DIALOG,
GTK_WINDOW_POPUP
} GtkWindowType;
diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c
index 538f799636..05aea054d1 100644
--- a/gtk/gtkfilesel.c
+++ b/gtk/gtkfilesel.c
@@ -499,7 +499,7 @@ gtk_file_selection_init (GtkFileSelection *filesel)
/* The horizontal box containing create, rename etc. buttons */
filesel->button_area = gtk_hbutton_box_new ();
gtk_button_box_set_layout (GTK_BUTTON_BOX (filesel->button_area), GTK_BUTTONBOX_START);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (filesel->button_area), 0);
+ gtk_box_set_spacing (GTK_BOX (filesel->button_area), 0);
gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->button_area,
FALSE, FALSE, 0);
gtk_widget_show (filesel->button_area);
diff --git a/gtk/gtkhbbox.c b/gtk/gtkhbbox.c
index e2bbdcf329..af95fe73ef 100644
--- a/gtk/gtkhbbox.c
+++ b/gtk/gtkhbbox.c
@@ -144,15 +144,14 @@ gtk_hbutton_box_size_request (GtkWidget *widget,
box = GTK_BOX (widget);
bbox = GTK_BUTTON_BOX (widget);
- spacing = bbox->spacing != GTK_BUTTONBOX_DEFAULT
- ? bbox->spacing : default_spacing;
+ spacing = box->spacing;
layout = bbox->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
? bbox->layout_style : default_layout_style;
- gtk_button_box_child_requisition (widget,
- &nvis_children,
- &child_width,
- &child_height);
+ _gtk_button_box_child_requisition (widget,
+ &nvis_children,
+ &child_width,
+ &child_height);
if (nvis_children == 0)
{
@@ -190,6 +189,7 @@ static void
gtk_hbutton_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkBox *base_box;
GtkButtonBox *box;
GtkHButtonBox *hbox;
GtkBoxChild *child;
@@ -210,16 +210,16 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_HBUTTON_BOX (widget));
g_return_if_fail (allocation != NULL);
+ base_box = GTK_BOX (widget);
box = GTK_BUTTON_BOX (widget);
hbox = GTK_HBUTTON_BOX (widget);
- spacing = box->spacing != GTK_BUTTONBOX_DEFAULT
- ? box->spacing : default_spacing;
+ spacing = base_box->spacing;
layout = box->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
? box->layout_style : default_layout_style;
- gtk_button_box_child_requisition (widget,
- &nvis_children,
- &child_width,
- &child_height);
+ _gtk_button_box_child_requisition (widget,
+ &nvis_children,
+ &child_width,
+ &child_height);
widget->allocation = *allocation;
width = allocation->width - GTK_CONTAINER (box)->border_width*2;
switch (layout)
diff --git a/gtk/gtkhbbox.h b/gtk/gtkhbbox.h
index c918b79266..41e62e26fd 100644
--- a/gtk/gtkhbbox.h
+++ b/gtk/gtkhbbox.h
@@ -63,12 +63,13 @@ GtkWidget* gtk_hbutton_box_new (void);
/* buttons can be added by gtk_container_add() */
+#ifndef GTK_DISABLE_DEPRECATED
gint gtk_hbutton_box_get_spacing_default (void);
GtkButtonBoxStyle gtk_hbutton_box_get_layout_default (void);
void gtk_hbutton_box_set_spacing_default (gint spacing);
void gtk_hbutton_box_set_layout_default (GtkButtonBoxStyle layout);
-
+#endif
#ifdef __cplusplus
}
diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c
index 07b5d5038c..4217869f8a 100644
--- a/gtk/gtkiconfactory.c
+++ b/gtk/gtkiconfactory.c
@@ -33,6 +33,9 @@
#include <ctype.h>
#include <string.h>
+/* FIXME use a better icon for this */
+#define MISSING_IMAGE_INLINE dialog_error
+
static gpointer parent_class = NULL;
static void gtk_icon_factory_init (GtkIconFactory *icon_factory);
@@ -384,6 +387,8 @@ get_default_icons (GtkIconFactory *factory)
add_unsized (factory, stock_new, GTK_STOCK_NEW);
add_unsized (factory, stock_open, GTK_STOCK_OPEN);
add_unsized (factory, stock_save, GTK_STOCK_SAVE);
+
+ add_unsized (factory, MISSING_IMAGE_INLINE, GTK_STOCK_MISSING_IMAGE);
}
/* Sizes */
@@ -878,6 +883,20 @@ find_and_prep_icon_source (GtkIconSet *icon_set,
return source;
}
+static GdkPixbuf*
+get_fallback_image (void)
+{
+ /* This icon can be used for any direction/state/size */
+ static GdkPixbuf *pixbuf = NULL;
+
+ if (pixbuf == NULL)
+ pixbuf = gdk_pixbuf_new_from_inline (MISSING_IMAGE_INLINE, FALSE, -1, NULL);
+ else
+ g_object_ref (G_OBJECT (pixbuf));
+
+ return pixbuf;
+}
+
/**
* gtk_icon_set_render_icon:
* @icon_set: a #GtkIconSet
@@ -908,17 +927,11 @@ gtk_icon_set_render_icon (GtkIconSet *icon_set,
GdkPixbuf *icon;
GtkIconSource *source;
- /* FIXME conceivably, everywhere this function
- * returns NULL, we should return some default
- * dummy icon like a question mark or the image icon
- * from netscape
- */
-
g_return_val_if_fail (icon_set != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
if (icon_set->sources == NULL)
- return NULL;
+ return get_fallback_image ();
icon = find_in_cache (icon_set, style, direction,
state, size);
@@ -933,7 +946,7 @@ gtk_icon_set_render_icon (GtkIconSet *icon_set,
source = find_and_prep_icon_source (icon_set, direction, state, size);
if (source == NULL)
- return NULL;
+ return get_fallback_image ();
g_assert (source->pixbuf != NULL);
@@ -948,7 +961,7 @@ gtk_icon_set_render_icon (GtkIconSet *icon_set,
if (icon == NULL)
{
g_warning ("Theme engine failed to render icon");
- return NULL;
+ return get_fallback_image ();
}
add_to_cache (icon_set, style, direction, state, size, icon);
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index d82effbb77..a28109419d 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -27,6 +27,7 @@
#include "gtkcontainer.h"
#include "gtkimage.h"
#include "gtkiconfactory.h"
+#include "gtkstock.h"
static void gtk_image_class_init (GtkImageClass *klass);
static void gtk_image_init (GtkImage *image);
@@ -388,7 +389,12 @@ gtk_image_set_from_file (GtkImage *image,
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
if (pixbuf == NULL)
- return;
+ {
+ gtk_image_set_from_stock (image,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_BUTTON);
+ return;
+ }
gtk_image_set_from_pixbuf (image, pixbuf);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 738f263427..fad59e5709 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -332,6 +332,7 @@ gtk_label_get_property (GObject *object,
case PROP_ACCEL_KEYVAL:
g_value_set_uint (value, label->accel_keyval);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1673,3 +1674,27 @@ gtk_label_select_region (GtkLabel *label,
}
}
+/**
+ * gtk_label_get_layout_offsets:
+ * @label: a #GtkLabel
+ * @x: location to store X offset of layout, or %NULL
+ * @y: location to store Y offset of layout, or %NULL
+ *
+ * Returns the coordinates where the label will draw the #PangoLayout
+ * representing the text in the label; useful to convert mouse events
+ * into coordinates inside the #PangoLayout, e.g. to take some action
+ * if some part of the label is clicked. Of course you will need to
+ * create a #GtkEventBox to receive the events, and pack the label
+ * inside it, since labels are a #GTK_NO_WINDOW widget.
+ *
+ **/
+void
+gtk_label_get_layout_offsets (GtkLabel *label,
+ gint *x,
+ gint *y)
+{
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ get_layout_location (label, x, y);
+}
+
diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h
index 7a8caa4165..d9bca17405 100644
--- a/gtk/gtklabel.h
+++ b/gtk/gtklabel.h
@@ -112,6 +112,10 @@ void gtk_label_select_region (GtkLabel *label,
gint start_offset,
gint end_offset);
+void gtk_label_get_layout_offsets (GtkLabel *label,
+ gint *x,
+ gint *y);
+
#ifndef GTK_DISABLE_COMPAT_H
# define gtk_label_set gtk_label_set_text
#endif /* GTK_DISABLE_COMPAT_H */
diff --git a/gtk/gtkstock.h b/gtk/gtkstock.h
index d40cb95602..a613446168 100644
--- a/gtk/gtkstock.h
+++ b/gtk/gtkstock.h
@@ -62,6 +62,8 @@ void gtk_stock_item_free (GtkStockItem *item);
/* Stock IDs */
+#define GTK_STOCK_MISSING_IMAGE "gtk-missing-image"
+
#define GTK_STOCK_DIALOG_INFO "gtk-dialog-info"
#define GTK_STOCK_DIALOG_WARNING "gtk-dialog-warning"
#define GTK_STOCK_DIALOG_ERROR "gtk-dialog-error"
diff --git a/gtk/gtkvbbox.c b/gtk/gtkvbbox.c
index b199d1d448..d427d2917a 100644
--- a/gtk/gtkvbbox.c
+++ b/gtk/gtkvbbox.c
@@ -146,15 +146,14 @@ gtk_vbutton_box_size_request (GtkWidget *widget,
box = GTK_BOX (widget);
bbox = GTK_BUTTON_BOX (widget);
- spacing = bbox->spacing != GTK_BUTTONBOX_DEFAULT
- ? bbox->spacing : default_spacing;
+ spacing = box->spacing;
layout = bbox->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
? bbox->layout_style : default_layout_style;
- gtk_button_box_child_requisition (widget,
- &nvis_children,
- &child_width,
- &child_height);
+ _gtk_button_box_child_requisition (widget,
+ &nvis_children,
+ &child_width,
+ &child_height);
if (nvis_children == 0)
{
@@ -193,6 +192,7 @@ static void
gtk_vbutton_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkBox *base_box;
GtkButtonBox *box;
GtkVButtonBox *hbox;
GtkBoxChild *child;
@@ -213,16 +213,16 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_VBUTTON_BOX (widget));
g_return_if_fail (allocation != NULL);
+ base_box = GTK_BOX (widget);
box = GTK_BUTTON_BOX (widget);
hbox = GTK_VBUTTON_BOX (widget);
- spacing = box->spacing != GTK_BUTTONBOX_DEFAULT
- ? box->spacing : default_spacing;
+ spacing = base_box->spacing;
layout = box->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
? box->layout_style : default_layout_style;
- gtk_button_box_child_requisition (widget,
- &nvis_children,
- &child_width,
- &child_height);
+ _gtk_button_box_child_requisition (widget,
+ &nvis_children,
+ &child_width,
+ &child_height);
widget->allocation = *allocation;
height = allocation->height - GTK_CONTAINER (box)->border_width*2;
switch (layout)
diff --git a/gtk/gtkvbbox.h b/gtk/gtkvbbox.h
index f4b3fbdc8f..b5dac7dd8f 100644
--- a/gtk/gtkvbbox.h
+++ b/gtk/gtkvbbox.h
@@ -63,11 +63,13 @@ GtkWidget *gtk_vbutton_box_new (void);
/* buttons can be added by gtk_container_add() */
+#ifndef GTK_DISABLE_DEPRECATED
gint gtk_vbutton_box_get_spacing_default (void);
void gtk_vbutton_box_set_spacing_default (gint spacing);
GtkButtonBoxStyle gtk_vbutton_box_get_layout_default (void);
void gtk_vbutton_box_set_layout_default (GtkButtonBoxStyle layout);
+#endif
#ifdef __cplusplus
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 710a5e32ad..494c091fc8 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -315,7 +315,8 @@ gtk_window_init (GtkWindow *window)
window->frame_top = 0;
window->frame_bottom = 0;
window->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
-
+ window->decorated = TRUE;
+
gtk_widget_ref (GTK_WIDGET (window));
gtk_object_sink (GTK_OBJECT (window));
window->has_user_ref_count = TRUE;
@@ -442,9 +443,13 @@ gtk_window_get_arg (GtkObject *object,
* contain other widgets. Nearly always, the type of the window should
* be #GTK_WINDOW_TOPLEVEL. If you're implementing something like a
* popup menu from scratch (which is a bad idea, just use #GtkMenu),
- * you might use #GTK_WINDOW_TOPLEVEL. #GTK_WINDOW_DIALOG is not
- * useful; dialogs should be of type #GTK_WINDOW_TOPLEVEL. (Probably
- * you want to use the #GtkDialog widget for dialogs anyway).
+ * you might use #GTK_WINDOW_POPUP. #GTK_WINDOW_POPUP is not for
+ * dialogs, though in some other toolkits dialogs are called "popups."
+ * In GTK+, #GTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip.
+ * Popup windows are not controlled by the window manager.
+ *
+ * If you simply want an undecorated window (no window borders), use
+ * gtk_window_set_decorated(), don't use #GTK_WINDOW_POPUP.
*
* Return value: a new #GtkWindow.
**/
@@ -500,13 +505,14 @@ gtk_window_set_title (GtkWindow *window,
* @wmclass_name: window name hint
* @wmclass_class: window class hint
*
- * This function sets the X Window System "class" and "name" hints for a window.
- * According to the ICCCM, you should always set these to the same value for
- * all windows in an application, and GTK sets them to that value by default,
- * so calling this function is sort of pointless. However, you may want to
- * call gtk_window_set_role() on each window in your application, for the
- * benefit of the session manager. Setting the role allows the window manager
- * to restore window positions when loading a saved session.
+ * Don't use this function. It sets the X Window System "class" and
+ * "name" hints for a window. According to the ICCCM, you should
+ * always set these to the same value for all windows in an
+ * application, and GTK sets them to that value by default, so calling
+ * this function is sort of pointless. However, you may want to call
+ * gtk_window_set_role() on each window in your application, for the
+ * benefit of the session manager. Setting the role allows the window
+ * manager to restore window positions when loading a saved session.
*
**/
void
@@ -524,7 +530,39 @@ gtk_window_set_wmclass (GtkWindow *window,
window->wmclass_class = g_strdup (wmclass_class);
if (GTK_WIDGET_REALIZED (window))
- g_warning ("shouldn't set wmclass after window is realized!\n");
+ g_warning ("gtk_window_set_wmclass: shouldn't set wmclass after window is realized!\n");
+}
+
+/**
+ * gtk_window_set_role:
+ * @window: a #GtkWindow
+ * @role: unique identifier for the window to be used when restoring a session
+ *
+ * In combination with the window title, the window role allows a
+ * window manager to identify "the same" window when an application is
+ * restarted. So for example you might set the "toolbox" role on your
+ * app's toolbox window, so that when the user restarts their session,
+ * the window manager can put the toolbox back in the same place.
+ *
+ * If a window already has a unique title, you don't need to set the
+ * role, since the WM can use the title to identify the window when
+ * restoring the session.
+ *
+ **/
+void
+gtk_window_set_role (GtkWindow *window,
+ const gchar *role)
+{
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ if (role == window->wm_role)
+ return;
+
+ g_free (window->wm_role);
+ window->wm_role = g_strdup (role);
+
+ if (GTK_WIDGET_REALIZED (window))
+ g_warning ("gtk_window_set_role(): shouldn't set role after window is realized!\n");
}
/**
@@ -927,7 +965,7 @@ gtk_window_unset_transient_for (GtkWindow *window)
* e.g. keep the dialog on top of the main window, or center the
* dialog over the main window. gtk_dialog_new_with_buttons() and
* other convenience functions in GTK+ will sometimes call
- * gtk_window_set_transient_for() on yoru behalf.
+ * gtk_window_set_transient_for() on your behalf.
*
**/
void
@@ -1112,6 +1150,40 @@ gtk_window_set_geometry_hints (GtkWindow *window,
}
/**
+ * gtk_window_set_decorated:
+ * @window: a #GtkWindow
+ * @setting: %TRUE to decorate the window
+ *
+ * By default, windows are decorated with a title bar, resize
+ * controls, etc. Some window managers allow GTK+ to disable these
+ * decorations, creating a borderless window. If you set the decorated
+ * property to %FALSE using this function, GTK+ will do its best to
+ * convince the window manager not to decorate the window.
+ *
+ **/
+void
+gtk_window_set_decorated (GtkWindow *window,
+ gboolean setting)
+{
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ setting = setting != FALSE;
+
+ if (setting == window->decorated)
+ return;
+
+ if (GTK_WIDGET (window)->window)
+ {
+ if (window->decorated)
+ gdk_window_set_decorations (GTK_WIDGET (window)->window,
+ GDK_DECOR_ALL);
+ else
+ gdk_window_set_decorations (GTK_WIDGET (window)->window,
+ 0);
+ }
+}
+
+/**
* gtk_window_set_default_size:
* @window: a #GtkWindow
* @width: width in pixels, or -1 to leave the default width unchanged
@@ -1128,6 +1200,11 @@ gtk_window_set_geometry_hints (GtkWindow *window,
*
* For more control over a window's initial size and how resizing works,
* investigate gtk_window_set_geometry_hints().
+ *
+ * A useful feature: if you set the "geometry widget" via
+ * gtk_window_set_geometry_hints(), the default size specified by
+ * gtk_window_set_default_size() will be the default size of that
+ * widget, not of the entire window.
*
**/
void
@@ -1376,12 +1453,12 @@ gtk_window_realize (GtkWidget *widget)
case GTK_WINDOW_TOPLEVEL:
attributes.window_type = GDK_WINDOW_TOPLEVEL;
break;
- case GTK_WINDOW_DIALOG:
- attributes.window_type = GDK_WINDOW_DIALOG;
- break;
case GTK_WINDOW_POPUP:
attributes.window_type = GDK_WINDOW_TEMP;
break;
+ default:
+ g_warning (G_STRLOC": Unknown window type %d!", window->type);
+ break;
}
attributes.title = window->title;
@@ -1454,6 +1531,12 @@ gtk_window_realize (GtkWidget *widget)
gdk_window_set_transient_for (widget->window,
GTK_WIDGET (window->transient_parent)->window);
+ if (window->wm_role)
+ gdk_window_set_role (widget->window, window->wm_role);
+
+ if (!window->decorated)
+ gdk_window_set_decorations (widget->window, 0);
+
gdk_window_set_type_hint (widget->window, window->type_hint);
/* transient_for must be set to allow the modal hint */
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 92d97a3e4b..d0c7ece481 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -57,6 +57,7 @@ struct _GtkWindow
gchar *title;
gchar *wmclass_name;
gchar *wmclass_class;
+ gchar *wm_role;
GtkWindowType type;
GdkWindow *frame;
@@ -90,8 +91,10 @@ struct _GtkWindow
guint stick_initially : 1;
guint maximize_initially : 1;
+ guint decorated : 1;
+
GdkWindowTypeHint type_hint : 2;
-
+
guint frame_left;
guint frame_top;
guint frame_right;
@@ -116,6 +119,8 @@ void gtk_window_set_title (GtkWindow *window,
void gtk_window_set_wmclass (GtkWindow *window,
const gchar *wmclass_name,
const gchar *wmclass_class);
+void gtk_window_set_role (GtkWindow *window,
+ const gchar *role);
void gtk_window_set_policy (GtkWindow *window,
gint allow_shrink,
gint allow_grow,
@@ -139,6 +144,11 @@ void gtk_window_set_geometry_hints (GtkWindow *window,
GtkWidget *geometry_widget,
GdkGeometry *geometry,
GdkWindowHints geom_mask);
+void gtk_window_set_decorations_hint (GtkWindow *window,
+ GdkWMDecoration decorations);
+void gtk_window_set_functions_hint (GtkWindow *window,
+ GdkWMFunction functions);
+
/* The following differs from gtk_widget_set_usize, in that
* gtk_widget_set_usize() overrides the requisition, so sets a minimum
* size, while this only sets the size requested from the WM.
diff --git a/gtk/testcalendar.c b/gtk/testcalendar.c
index 0eaa0c9602..d870890c80 100644
--- a/gtk/testcalendar.c
+++ b/gtk/testcalendar.c
@@ -296,7 +296,7 @@ void create_calendar()
hbbox = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(hbox), hbbox, FALSE, FALSE, DEF_PAD);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_SPREAD);
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 5);
+ gtk_box_set_spacing(GTK_BOX(hbbox), 5);
/* Calendar widget */
frame = gtk_frame_new("Calendar");
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 8b06fe0b38..c4cada989a 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -508,7 +508,7 @@ create_bbox (gint horizontal,
gtk_container_add (GTK_CONTAINER (frame), bbox);
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), spacing);
+ gtk_box_set_spacing (GTK_BOX (bbox), spacing);
gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), child_w, child_h);
button = gtk_button_new_with_label ("OK");
@@ -7228,7 +7228,7 @@ dnd_drop (GtkWidget *button, GdkEvent *event)
if (window)
return;
- window = gtk_window_new(GTK_WINDOW_DIALOG);
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER(window), 10);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
@@ -7606,6 +7606,8 @@ create_shapes (void)
with_region = shape_create_icon ("3DRings.xpm",
460, 270, 25,25, GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_decorated (GTK_WINDOW (with_region), FALSE);
+
gtk_signal_connect (GTK_OBJECT (with_region), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&with_region);