Add boolean destroying (gtk_menu_destroy): Set priv->destroying

Tue Mar  9 02:11:50 2004  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtkmenu.c Fix bug 136446.
	(struct _GtkMenuPrivate): Add boolean destroying
	(gtk_menu_destroy): Set priv->destroying
	(gtk_menu_remove): don't update the table information when the
	menu is being destroyed.

	* gtk/gtkmenu.c (gtk_menu_set_monitor): Formatting fix

	* gtk/gtktoolbar.[ch]: Some formatting fixes
This commit is contained in:
Soeren Sandmann 2004-03-09 01:21:45 +00:00 committed by Søren Sandmann Pedersen
parent 6dcda29ed1
commit db6cc5f788
8 changed files with 272 additions and 194 deletions

View File

@ -1,3 +1,15 @@
Tue Mar 9 02:11:50 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c Fix bug 136446.
(struct _GtkMenuPrivate): Add boolean destroying
(gtk_menu_destroy): Set priv->destroying
(gtk_menu_remove): don't update the table information when the
menu is being destroyed.
* gtk/gtkmenu.c (gtk_menu_set_monitor): Formatting fix
* gtk/gtktoolbar.[ch]: Some formatting fixes
Tue Mar 9 01:25:10 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkframe.c (gtk_frame_paint): Fix a typo.

View File

@ -1,3 +1,15 @@
Tue Mar 9 02:11:50 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c Fix bug 136446.
(struct _GtkMenuPrivate): Add boolean destroying
(gtk_menu_destroy): Set priv->destroying
(gtk_menu_remove): don't update the table information when the
menu is being destroyed.
* gtk/gtkmenu.c (gtk_menu_set_monitor): Formatting fix
* gtk/gtktoolbar.[ch]: Some formatting fixes
Tue Mar 9 01:25:10 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkframe.c (gtk_frame_paint): Fix a typo.

View File

@ -1,3 +1,15 @@
Tue Mar 9 02:11:50 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c Fix bug 136446.
(struct _GtkMenuPrivate): Add boolean destroying
(gtk_menu_destroy): Set priv->destroying
(gtk_menu_remove): don't update the table information when the
menu is being destroyed.
* gtk/gtkmenu.c (gtk_menu_set_monitor): Formatting fix
* gtk/gtktoolbar.[ch]: Some formatting fixes
Tue Mar 9 01:25:10 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkframe.c (gtk_frame_paint): Fix a typo.

View File

@ -1,3 +1,15 @@
Tue Mar 9 02:11:50 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c Fix bug 136446.
(struct _GtkMenuPrivate): Add boolean destroying
(gtk_menu_destroy): Set priv->destroying
(gtk_menu_remove): don't update the table information when the
menu is being destroyed.
* gtk/gtkmenu.c (gtk_menu_set_monitor): Formatting fix
* gtk/gtktoolbar.[ch]: Some formatting fixes
Tue Mar 9 01:25:10 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkframe.c (gtk_frame_paint): Fix a typo.

View File

@ -1,3 +1,15 @@
Tue Mar 9 02:11:50 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c Fix bug 136446.
(struct _GtkMenuPrivate): Add boolean destroying
(gtk_menu_destroy): Set priv->destroying
(gtk_menu_remove): don't update the table information when the
menu is being destroyed.
* gtk/gtkmenu.c (gtk_menu_set_monitor): Formatting fix
* gtk/gtktoolbar.[ch]: Some formatting fixes
Tue Mar 9 01:25:10 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkframe.c (gtk_frame_paint): Fix a typo.

View File

@ -87,6 +87,8 @@ struct _GtkMenuPrivate
gint heights_length;
gint monitor_num;
gboolean destroying;
};
typedef struct
@ -767,6 +769,7 @@ gtk_menu_destroy (GtkObject *object)
{
GtkMenu *menu;
GtkMenuAttachData *data;
GtkMenuPrivate *priv;
g_return_if_fail (GTK_IS_MENU (object));
@ -804,6 +807,10 @@ gtk_menu_destroy (GtkObject *object)
if (menu->tearoff_window)
gtk_widget_destroy (menu->tearoff_window);
priv = gtk_menu_get_private (menu);
priv->destroying = TRUE;
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -982,11 +989,13 @@ gtk_menu_remove (GtkContainer *container,
GtkWidget *widget)
{
GtkMenu *menu;
GtkMenuPrivate *priv;
g_return_if_fail (GTK_IS_MENU (container));
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
menu = GTK_MENU (container);
priv = gtk_menu_get_private (menu);
/* Clear out old_active_menu_item if it matches the item we are removing
*/
@ -997,7 +1006,8 @@ gtk_menu_remove (GtkContainer *container,
}
GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
gtk_menu_do_remove (GTK_MENU_SHELL (container), widget);
if (!priv->destroying)
gtk_menu_do_remove (GTK_MENU_SHELL (container), widget);
g_object_set_data (G_OBJECT (widget), ATTACH_INFO_KEY, NULL);
}
@ -4090,8 +4100,9 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
*
* Since: 2.4
**/
void gtk_menu_set_monitor (GtkMenu *menu,
gint monitor_num)
void
gtk_menu_set_monitor (GtkMenu *menu,
gint monitor_num)
{
GtkMenuPrivate *priv;
g_return_if_fail (GTK_IS_MENU (menu));

View File

@ -138,87 +138,87 @@ struct _GtkToolbarPrivate
guint is_sliding : 1;
};
static void gtk_toolbar_init (GtkToolbar *toolbar);
static void gtk_toolbar_class_init (GtkToolbarClass *klass);
static void gtk_toolbar_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static gint gtk_toolbar_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_toolbar_realize (GtkWidget *widget);
static void gtk_toolbar_unrealize (GtkWidget *widget);
static void gtk_toolbar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_toolbar_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gtk_toolbar_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static gboolean gtk_toolbar_focus (GtkWidget *widget,
GtkDirectionType dir);
static void gtk_toolbar_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen);
static void gtk_toolbar_map (GtkWidget *widget);
static void gtk_toolbar_unmap (GtkWidget *widget);
static void gtk_toolbar_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_finalize (GObject *object);
static void gtk_toolbar_show_all (GtkWidget *widget);
static void gtk_toolbar_hide_all (GtkWidget *widget);
static void gtk_toolbar_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_toolbar_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_toolbar_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static GType gtk_toolbar_child_type (GtkContainer *container);
static void gtk_toolbar_orientation_changed (GtkToolbar *toolbar,
GtkOrientation orientation);
static void gtk_toolbar_real_style_changed (GtkToolbar *toolbar,
GtkToolbarStyle style);
static gboolean gtk_toolbar_move_focus (GtkToolbar *toolbar,
GtkDirectionType dir);
static gboolean gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
gboolean focus_home);
static gboolean gtk_toolbar_button_press (GtkWidget *toolbar,
GdkEventButton *event);
static gboolean gtk_toolbar_arrow_button_press (GtkWidget *button,
GdkEventButton *event,
GtkToolbar *toolbar);
static void gtk_toolbar_arrow_button_clicked (GtkWidget *button,
GtkToolbar *toolbar);
static void gtk_toolbar_update_button_relief (GtkToolbar *toolbar);
static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar);
static GtkWidget * internal_insert_element (GtkToolbar *toolbar,
GtkToolbarChildType type,
GtkWidget *widget,
const char *text,
const char *tooltip_text,
const char *tooltip_private_text,
GtkWidget *icon,
GtkSignalFunc callback,
gpointer user_data,
gint position,
gboolean use_stock);
static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
static gboolean gtk_toolbar_check_new_api (GtkToolbar *toolbar);
static gboolean gtk_toolbar_check_old_api (GtkToolbar *toolbar);
static void gtk_toolbar_init (GtkToolbar *toolbar);
static void gtk_toolbar_class_init (GtkToolbarClass *klass);
static void gtk_toolbar_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static gint gtk_toolbar_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_toolbar_realize (GtkWidget *widget);
static void gtk_toolbar_unrealize (GtkWidget *widget);
static void gtk_toolbar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_toolbar_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gtk_toolbar_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static gboolean gtk_toolbar_focus (GtkWidget *widget,
GtkDirectionType dir);
static void gtk_toolbar_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen);
static void gtk_toolbar_map (GtkWidget *widget);
static void gtk_toolbar_unmap (GtkWidget *widget);
static void gtk_toolbar_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_finalize (GObject *object);
static void gtk_toolbar_show_all (GtkWidget *widget);
static void gtk_toolbar_hide_all (GtkWidget *widget);
static void gtk_toolbar_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_toolbar_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_toolbar_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static GType gtk_toolbar_child_type (GtkContainer *container);
static void gtk_toolbar_orientation_changed (GtkToolbar *toolbar,
GtkOrientation orientation);
static void gtk_toolbar_real_style_changed (GtkToolbar *toolbar,
GtkToolbarStyle style);
static gboolean gtk_toolbar_move_focus (GtkToolbar *toolbar,
GtkDirectionType dir);
static gboolean gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
gboolean focus_home);
static gboolean gtk_toolbar_button_press (GtkWidget *toolbar,
GdkEventButton *event);
static gboolean gtk_toolbar_arrow_button_press (GtkWidget *button,
GdkEventButton *event,
GtkToolbar *toolbar);
static void gtk_toolbar_arrow_button_clicked (GtkWidget *button,
GtkToolbar *toolbar);
static void gtk_toolbar_update_button_relief (GtkToolbar *toolbar);
static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar);
static GtkWidget *internal_insert_element (GtkToolbar *toolbar,
GtkToolbarChildType type,
GtkWidget *widget,
const char *text,
const char *tooltip_text,
const char *tooltip_private_text,
GtkWidget *icon,
GtkSignalFunc callback,
gpointer user_data,
gint position,
gboolean use_stock);
static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
static gboolean gtk_toolbar_check_new_api (GtkToolbar *toolbar);
static gboolean gtk_toolbar_check_old_api (GtkToolbar *toolbar);
static GtkReliefStyle get_button_relief (GtkToolbar *toolbar);
static gint get_internal_padding (GtkToolbar *toolbar);
@ -2995,32 +2995,6 @@ gtk_toolbar_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
gchar *
_gtk_toolbar_elide_underscores (const gchar *original)
{
gchar *q, *result;
const gchar *p;
gboolean last_underscore;
q = result = g_malloc (strlen (original) + 1);
last_underscore = FALSE;
for (p = original; *p; p++)
{
if (!last_underscore && *p == '_')
last_underscore = TRUE;
else
{
last_underscore = FALSE;
*q++ = *p;
}
}
*q = '\0';
return result;
}
/*
* Deprecated API
*/
@ -3849,51 +3823,6 @@ calculate_max_homogeneous_pixels (GtkWidget *widget)
return PANGO_PIXELS (MAX_HOMOGENEOUS_N_CHARS * char_width);
}
gint
_gtk_toolbar_get_default_space_size (void)
{
return DEFAULT_SPACE_SIZE;
}
void
_gtk_toolbar_paint_space_line (GtkWidget *widget,
GtkToolbar *toolbar,
GdkRectangle *area,
GtkAllocation *allocation)
{
const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION);
const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION);
gint space_size;
GtkToolbarSpaceStyle space_style;
GtkOrientation orientation;
g_return_if_fail (GTK_IS_WIDGET (widget));
space_size = get_space_size (toolbar);
space_style = get_space_style (toolbar);
orientation = toolbar? toolbar->orientation : GTK_ORIENTATION_HORIZONTAL;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_paint_vline (widget->style, widget->window,
GTK_WIDGET_STATE (widget), area, widget,
"toolbar",
allocation->y + allocation->height * start_fraction,
allocation->y + allocation->height * end_fraction,
allocation->x + (space_size - widget->style->xthickness) / 2);
}
else
{
gtk_paint_hline (widget->style, widget->window,
GTK_WIDGET_STATE (widget), area, widget,
"toolbar",
allocation->x + allocation->width * start_fraction,
allocation->x + allocation->width * end_fraction,
allocation->y + (space_size - widget->style->ythickness) / 2);
}
}
static void
toolbar_content_expose (ToolbarContent *content,
GtkContainer *container,
@ -4596,6 +4525,9 @@ get_shadow_type (GtkToolbar *toolbar)
/*
* API checks
*/
#define mixed_api_warning \
"mixing deprecated and non-deprecated GtkToolbar API is not allowed"
static gboolean
gtk_toolbar_check_old_api (GtkToolbar *toolbar)
{
@ -4603,7 +4535,7 @@ gtk_toolbar_check_old_api (GtkToolbar *toolbar)
if (priv->api_mode == NEW_API)
{
g_warning ("mixing deprecated and non-deprecated GtkToolbar API is not allowed");
g_warning (mixed_api_warning);
return FALSE;
}
@ -4618,10 +4550,83 @@ gtk_toolbar_check_new_api (GtkToolbar *toolbar)
if (priv->api_mode == OLD_API)
{
g_warning ("mixing deprecated and non-deprecated GtkToolbar API is not allowed");
g_warning (mixed_api_warning);
return FALSE;
}
priv->api_mode = NEW_API;
return TRUE;
}
/* GTK+ internal methods */
gint
_gtk_toolbar_get_default_space_size (void)
{
return DEFAULT_SPACE_SIZE;
}
void
_gtk_toolbar_paint_space_line (GtkWidget *widget,
GtkToolbar *toolbar,
GdkRectangle *area,
GtkAllocation *allocation)
{
const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION);
const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION);
gint space_size;
GtkToolbarSpaceStyle space_style;
GtkOrientation orientation;
g_return_if_fail (GTK_IS_WIDGET (widget));
space_size = get_space_size (toolbar);
space_style = get_space_style (toolbar);
orientation = toolbar? toolbar->orientation : GTK_ORIENTATION_HORIZONTAL;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_paint_vline (widget->style, widget->window,
GTK_WIDGET_STATE (widget), area, widget,
"toolbar",
allocation->y + allocation->height * start_fraction,
allocation->y + allocation->height * end_fraction,
allocation->x + (space_size - widget->style->xthickness) / 2);
}
else
{
gtk_paint_hline (widget->style, widget->window,
GTK_WIDGET_STATE (widget), area, widget,
"toolbar",
allocation->x + allocation->width * start_fraction,
allocation->x + allocation->width * end_fraction,
allocation->y + (space_size - widget->style->ythickness) / 2);
}
}
gchar *
_gtk_toolbar_elide_underscores (const gchar *original)
{
gchar *q, *result;
const gchar *p;
gboolean last_underscore;
q = result = g_malloc (strlen (original) + 1);
last_underscore = FALSE;
for (p = original; *p; p++)
{
if (!last_underscore && *p == '_')
last_underscore = TRUE;
else
{
last_underscore = FALSE;
*q++ = *p;
}
}
*q = '\0';
return result;
}

View File

@ -133,46 +133,48 @@ struct _GtkToolbarClass
};
GType gtk_toolbar_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_toolbar_new (void);
void gtk_toolbar_insert (GtkToolbar *toolbar,
GtkToolItem *item,
gint pos);
gint gtk_toolbar_get_item_index (GtkToolbar *toolbar,
GtkToolItem *item);
gint gtk_toolbar_get_n_items (GtkToolbar *toolbar);
GtkToolItem * gtk_toolbar_get_nth_item (GtkToolbar *toolbar,
gint n);
gboolean gtk_toolbar_get_show_arrow (GtkToolbar *toolbar);
void gtk_toolbar_set_show_arrow (GtkToolbar *toolbar,
gboolean show_arrow);
GtkOrientation gtk_toolbar_get_orientation (GtkToolbar *toolbar);
void gtk_toolbar_set_orientation (GtkToolbar *toolbar,
GtkOrientation orientation);
gboolean gtk_toolbar_get_tooltips (GtkToolbar *toolbar);
void gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
gboolean enable);
GtkToolbarStyle gtk_toolbar_get_style (GtkToolbar *toolbar);
void gtk_toolbar_set_style (GtkToolbar *toolbar,
GtkToolbarStyle style);
void gtk_toolbar_unset_style (GtkToolbar *toolbar);
GtkIconSize gtk_toolbar_get_icon_size (GtkToolbar *toolbar);
GtkReliefStyle gtk_toolbar_get_relief_style (GtkToolbar *toolbar);
gint gtk_toolbar_get_drop_index (GtkToolbar *toolbar,
gint x,
gint y);
void gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar,
GtkToolItem *tool_item,
gint index);
GtkWidget* gtk_toolbar_new (void);
void gtk_toolbar_insert (GtkToolbar *toolbar,
GtkToolItem *item,
gint pos);
gint gtk_toolbar_get_item_index (GtkToolbar *toolbar,
GtkToolItem *item);
gint gtk_toolbar_get_n_items (GtkToolbar *toolbar);
GtkToolItem * gtk_toolbar_get_nth_item (GtkToolbar *toolbar,
gint n);
gboolean gtk_toolbar_get_show_arrow (GtkToolbar *toolbar);
void gtk_toolbar_set_show_arrow (GtkToolbar *toolbar,
gboolean show_arrow);
GtkOrientation gtk_toolbar_get_orientation (GtkToolbar *toolbar);
void gtk_toolbar_set_orientation (GtkToolbar *toolbar,
GtkOrientation orientation);
gboolean gtk_toolbar_get_tooltips (GtkToolbar *toolbar);
void gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
gboolean enable);
GtkToolbarStyle gtk_toolbar_get_style (GtkToolbar *toolbar);
void gtk_toolbar_set_style (GtkToolbar *toolbar,
GtkToolbarStyle style);
void gtk_toolbar_unset_style (GtkToolbar *toolbar);
GtkIconSize gtk_toolbar_get_icon_size (GtkToolbar *toolbar);
GtkReliefStyle gtk_toolbar_get_relief_style (GtkToolbar *toolbar);
gint gtk_toolbar_get_drop_index (GtkToolbar *toolbar,
gint x,
gint y);
void gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar,
GtkToolItem *tool_item,
gint index);
/* internal functions */
gchar * _gtk_toolbar_elide_underscores (const gchar *original);
void _gtk_toolbar_paint_space_line (GtkWidget *widget,
GtkToolbar *toolbar,
GdkRectangle *area,
GtkAllocation *allocation);
gint _gtk_toolbar_get_default_space_size (void);
gchar * _gtk_toolbar_elide_underscores (const gchar *original);
void _gtk_toolbar_paint_space_line (GtkWidget *widget,
GtkToolbar *toolbar,
GdkRectangle *area,
GtkAllocation *allocation);
gint _gtk_toolbar_get_default_space_size (void);
/* deprecated */
#ifndef GTK_DISABLE_DEPRECATED
void gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
GtkIconSize icon_size);