Make G_CONST_RETURN.

Thu Mar  8 00:02:30 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
	G_CONST_RETURN.

	* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
	::hierarchy-changed signal when a widget changes
	from anchored to unanchored or vice versa.
	(anchored means
	 gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
	Use a private flag to keep track of this efficiently.
This commit is contained in:
Owen Taylor 2001-03-08 06:14:43 +00:00 committed by Owen Taylor
parent d85dd6bd98
commit 85af79635a
12 changed files with 141 additions and 8 deletions

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -1,3 +1,15 @@
Thu Mar 8 00:02:30 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_name): Make
G_CONST_RETURN.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add a
::hierarchy-changed signal when a widget changes
from anchored to unanchored or vice versa.
(anchored means
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) != NULL.)
Use a private flag to keep track of this efficiently.
2001-03-07 Havoc Pennington <hp@redhat.com>
* gtk/testgtk.c (create_spins): uglify so that size request gets

View File

@ -48,7 +48,8 @@ typedef enum
PRIVATE_GTK_HAS_SHAPE_MASK = 1 << 5,
PRIVATE_GTK_IN_REPARENT = 1 << 6,
PRIVATE_GTK_DIRECTION_SET = 1 << 7, /* If the reading direction is not DIR_NONE */
PRIVATE_GTK_DIRECTION_LTR = 1 << 8 /* If the reading direction is DIR_LTR */
PRIVATE_GTK_DIRECTION_LTR = 1 << 8, /* If the reading direction is DIR_LTR */
PRIVATE_GTK_ANCHORED = 1 << 9 /* If widget has a GtkWindow ancestor */
} GtkPrivateFlags;
/* Macros for extracting a widgets private_flags from GtkWidget.
@ -62,6 +63,7 @@ typedef enum
#define GTK_WIDGET_IN_REPARENT(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_IN_REPARENT) != 0)
#define GTK_WIDGET_DIRECTION_SET(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_SET) != 0)
#define GTK_WIDGET_DIRECTION_LTR(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_LTR) != 0)
#define GTK_WIDGET_ANCHORED(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_ANCHORED) != 0)
/* Macros for setting and clearing private widget flags.
* we use a preprocessor string concatenation here for a clear

View File

@ -56,6 +56,7 @@ enum {
SIZE_ALLOCATE,
STATE_CHANGED,
PARENT_SET,
HIERARCHY_CHANGED,
STYLE_SET,
DIRECTION_CHANGED,
ADD_ACCELERATOR,
@ -182,6 +183,9 @@ static void gtk_widget_set_style_internal (GtkWidget *widget,
static void gtk_widget_set_style_recurse (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
gpointer client_data);
static GtkWidgetAuxInfo* gtk_widget_aux_info_new (void);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
@ -286,6 +290,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->size_allocate = gtk_widget_real_size_allocate;
klass->state_changed = NULL;
klass->parent_set = NULL;
klass->hierarchy_changed = NULL;
klass->style_set = gtk_widget_style_set;
klass->direction_changed = gtk_widget_direction_changed;
klass->add_accelerator = (void*) gtk_accel_group_handle_add;
@ -418,6 +423,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_VOID__OBJECT,
GTK_TYPE_NONE, 1,
GTK_TYPE_OBJECT);
widget_signals[HIERARCHY_CHANGED] =
gtk_signal_new ("hierarchy_changed",
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, hierarchy_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[STYLE_SET] =
gtk_signal_new ("style_set",
GTK_RUN_FIRST,
@ -1213,6 +1225,7 @@ gtk_widget_unparent (GtkWidget *widget)
widget->parent = NULL;
gtk_widget_set_parent_window (widget, NULL);
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], old_parent);
gtk_widget_propagate_hierarchy_changed (widget, NULL);
gtk_widget_unref (widget);
}
@ -2761,7 +2774,7 @@ gtk_widget_set_name (GtkWidget *widget,
*
* Return value: name of the widget
**/
gchar*
G_CONST_RETURN gchar*
gtk_widget_get_name (GtkWidget *widget)
{
g_return_val_if_fail (widget != NULL, NULL);
@ -2961,6 +2974,7 @@ gtk_widget_set_parent (GtkWidget *widget,
gtk_widget_set_style_recurse (widget, NULL);
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], NULL);
gtk_widget_propagate_hierarchy_changed (widget, NULL);
}
/*****************************************
@ -3442,6 +3456,34 @@ gtk_widget_set_style_recurse (GtkWidget *widget,
NULL);
}
static void
gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
gpointer client_data)
{
gboolean new_anchored;
new_anchored = widget->parent && GTK_WIDGET_ANCHORED (widget->parent);
if (GTK_WIDGET_ANCHORED (widget) != new_anchored)
{
gtk_widget_ref (widget);
if (new_anchored)
GTK_PRIVATE_SET_FLAG (widget, GTK_ANCHORED);
else
GTK_PRIVATE_UNSET_FLAG (widget, GTK_ANCHORED);
g_signal_emit (GTK_OBJECT (widget), widget_signals[HIERARCHY_CHANGED], 0);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_propagate_hierarchy_changed,
NULL);
gtk_widget_unref (widget);
}
}
void
gtk_widget_reset_rc_styles (GtkWidget *widget)
{
@ -4991,8 +5033,9 @@ gtk_widget_path (GtkWidget *widget,
len = 0;
do
{
gchar *string;
gchar *d, *s;
const gchar *string;
const gchar *s;
gchar *d;
guint l;
string = gtk_widget_get_name (widget);
@ -5055,8 +5098,9 @@ gtk_widget_class_path (GtkWidget *widget,
len = 0;
do
{
gchar *string;
gchar *d, *s;
const gchar *string;
const gchar *s;
gchar *d;
guint l;
string = gtk_type_name (GTK_WIDGET_TYPE (widget));

View File

@ -250,6 +250,7 @@ struct _GtkWidgetClass
GtkStateType previous_state);
void (* parent_set) (GtkWidget *widget,
GtkWidget *previous_parent);
void (* hierarchy_changed) (GtkWidget *widget);
void (* style_set) (GtkWidget *widget,
GtkStyle *previous_style);
void (* direction_changed) (GtkWidget *widget,
@ -486,7 +487,7 @@ void gtk_widget_grab_default (GtkWidget *widget);
void gtk_widget_set_name (GtkWidget *widget,
const gchar *name);
gchar* gtk_widget_get_name (GtkWidget *widget);
G_CONST_RETURN gchar* gtk_widget_get_name (GtkWidget *widget);
void gtk_widget_set_state (GtkWidget *widget,
GtkStateType state);
void gtk_widget_set_sensitive (GtkWidget *widget,

View File

@ -292,6 +292,8 @@ gtk_window_init (GtkWindow *window)
GTK_WIDGET_UNSET_FLAGS (window, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (window, GTK_TOPLEVEL);
GTK_PRIVATE_SET_FLAG (window, GTK_ANCHORED);
gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
window->title = NULL;

View File

@ -36,7 +36,7 @@ void
steal (GtkWidget *window, GtkEntry *entry)
{
guint32 xid;
gchar *text;
const gchar *text;
GtkWidget *socket;
text = gtk_entry_get_text (entry);