Commit a1a252ce authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat().

Fri Feb  2 12:26:50 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of
	a bunch of g_strdup_printf("%s%s") in favor of g_strconcat().

	* gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix),
	since some people set $(libdir) separately. (#1290, David Kaelbling)

Thu Feb  1 18:25:46 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not
	defined, define MAXPATHLEN to 2048. (The Hurd doesn't have
	MAXPATHLEN, but the code here depends on a fixed value.)
	(#4524)

Wed Jan 31 22:01:04 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case
	where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g)

Wed Jan 31 21:20:39 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkctree.c (real_tree_move): If the node being moved isn't
	viewable there is no way that moving the node will cause the
	focus row to become not viewable, so omit check on the visibility
	of new_sibling, which is irrelevant. (Fixes #8002, David Helder)

Wed Jan 31 20:38:17 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current
	selection before inserting new text.

Wed Jan 31 18:49:33 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb):
	Make the sensitivity of the reparented child track that of
	the original parent menu item. (#34218, David Hodson)

	* gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle
	the case where the current item is destroyed properly.

	* gtk/gtkoptionmenu.c: Some additional code cleanups and fix
	some edge cases with child-less menuitems.

Wed Jan 31 17:16:13 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return
	key pop down window. (#12074, Jon K Hellan)

Wed Jan 31 16:21:42 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow
	toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan)
	The solution here isn't perfect - you get an extraneous
	emission of "toggle", which could conceivably confuse an app,
	but better than the current situation. LXR search seems to
	indicate that no apps in GNOME CVS connect to "toggle".

Wed Jan 31 15:46:13 2001  Owen Taylor  <otaylor@redhat.com>

        * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from
        gtk_public_h_sources to directly here to avoid warning when
        building srcdir != builddir. (#9656)

Tue Jan 30 19:49:02 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkrange.c: Patch from Kipp Hickman to make the event
	handlers in gtkrange.c return the proper values (TRUE == handled)
	(#10316).

	This is just the tip of the iceberg, but gtkrange.c is the
	most common place where the propagation is problematical,
	and also a place where it is almost certainly safe to change
	this in the stable branch.

	(You don't want right click popups on a range control or anything...)

Tue Jan 30 18:57:59 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktext.c (clear_focus_area): We need to clear the focus
	area on focus out, even if a background pixmap isn't set.
	(#13941)

Tue Jan 30 18:24:10 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham
	to deal with setting the shape properly when scrolling arrows are
	turned on, but not visible because there is sufficient space.
	(#13432)

Tue Jan 30 16:39:25 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu
	items with submenus, destroy the item along with the submenu.
	(#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...'
	properly.

	* gtk/testgtk.c (menu_items): Add a dummy branch that we delete
	later.

Tue Jan 30 15:51:25 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where
	the focus widget sometimes wasn't drawn with the default if there
	was no default widget.

	* gtk/gtkstyle.c (gtk_style_real_unrealize): free colors,
	unreference pixmaps.

	* gtk/gtkstyle.c (gtk_style_realize): Reference colormap
	for some extra safety.

Mon Jan 29 19:00:01 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting
	the text of a cell to the old pointer value better, by
	copying the new text before freeing the old text. Some code
	cleanup. (#8079, Karl Nelson)

Mon Jan 29 16:50:19 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text()
	gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN.

Mon Jan 29 15:22:51 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkmenu.c (gtk_menu_remove): When removing an
	item from a menu, check to see if it matches
	menu->old_active_menu_item, and if so, unref and clear
	old_active_menu_item (Patch from Pavel Cisler)

	* gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset
	menu_shell->active_menu_item, if it is the child being
	removed. (Patch based on that of Gene Ragan, #50337)
parent d11bfcbd
......@@ -1307,6 +1307,16 @@ gdk_events_queue (void)
#else
XNextEvent (gdk_display, &xevent);
#endif
switch (xevent.type)
{
case KeyPress:
case KeyRelease:
break;
default:
if (XFilterEvent (&xevent, None))
continue;
}
event = gdk_event_new ();
......
......@@ -5,7 +5,7 @@ SUBDIRS=stock-icons
INCLUDES = @STRIP_BEGIN@ \
-DG_LOG_DOMAIN=\"Gtk\" \
-DGTK_DISABLE_COMPAT_H \
-DGTK_EXE_PREFIX=\"$(exec_prefix)\" \
-DGTK_LIBDIR=\"$(libdir)\" \
-DGTK_DATA_PREFIX=\"$(prefix)\" \
-DGTK_SYSCONFDIR=\"$(sysconfdir)\" \
-DGTK_LOCALEDIR=\"$(gtklocaledir)\" \
......@@ -70,7 +70,6 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkcolorsel.h \
gtkcolorseldialog.h \
gtkcombo.h \
gtkcompat.h \
gtkcontainer.h \
gtkctree.h \
gtkcurve.h \
......@@ -423,7 +422,7 @@ gtk_extra_sources = @STRIP_BEGIN@ \
#
# setup GTK+ sources and their dependancies
#
gtk_target_headers = $(gtk_public_h_sources) $(gtk_built_public_sources)
gtk_target_headers = $(gtk_public_h_sources) $(gtk_built_public_sources) gtkcompat.h
gtk_target_sources = $(gtk_c_sources)
MAINTAINERCLEANFILES += $(gtk_built_sources)
EXTRA_HEADERS +=
......
......@@ -2421,7 +2421,10 @@ set_cell_contents (GtkCList *clist,
GdkBitmap *mask)
{
GtkRequisition requisition;
gchar *old_text = NULL;
GdkPixmap *old_pixmap = NULL;
GdkBitmap *old_mask = NULL;
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
g_return_if_fail (clist_row != NULL);
......@@ -2436,18 +2439,16 @@ set_cell_contents (GtkCList *clist,
case GTK_CELL_EMPTY:
break;
case GTK_CELL_TEXT:
g_free (GTK_CELL_TEXT (clist_row->cell[column])->text);
old_text = GTK_CELL_TEXT (clist_row->cell[column])->text;
break;
case GTK_CELL_PIXMAP:
gdk_pixmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap);
if (GTK_CELL_PIXMAP (clist_row->cell[column])->mask)
gdk_bitmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->mask);
old_pixmap = GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap;
old_mask = GTK_CELL_PIXMAP (clist_row->cell[column])->mask;
break;
case GTK_CELL_PIXTEXT:
g_free (GTK_CELL_PIXTEXT (clist_row->cell[column])->text);
gdk_pixmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap);
if (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask)
gdk_bitmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask);
old_text = GTK_CELL_PIXTEXT (clist_row->cell[column])->text;
old_pixmap = GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap;
old_mask = GTK_CELL_PIXTEXT (clist_row->cell[column])->mask;
break;
case GTK_CELL_WIDGET:
/* unimplimented */
......@@ -2458,6 +2459,8 @@ set_cell_contents (GtkCList *clist,
clist_row->cell[column].type = GTK_CELL_EMPTY;
/* Note that pixmap and mask were already ref'ed by the caller
*/
switch (type)
{
case GTK_CELL_TEXT:
......@@ -2493,6 +2496,13 @@ set_cell_contents (GtkCList *clist,
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
column_auto_resize (clist, clist_row, column, requisition.width);
if (old_text)
g_free (old_text);
if (old_pixmap)
gdk_pixmap_unref (old_pixmap);
if (old_mask)
gdk_pixmap_unref (old_mask);
}
PangoLayout *
......
......@@ -46,51 +46,54 @@ const gchar *gtk_combo_string_key = "gtk-combo-string-value";
#define COMBO_LIST_MAX_HEIGHT (400)
#define EMPTY_LIST_HEIGHT (15)
static void gtk_combo_class_init (GtkComboClass *klass);
static void gtk_combo_init (GtkCombo *combo);
static void gtk_combo_destroy (GtkObject *combo);
static GtkListItem *gtk_combo_find (GtkCombo *combo);
static gchar * gtk_combo_func (GtkListItem *li);
static gint gtk_combo_focus_idle (GtkCombo *combo);
static gint gtk_combo_entry_focus_out (GtkEntry *entry,
GdkEventFocus *event,
GtkCombo *combo);
static void gtk_combo_get_pos (GtkCombo *combo,
gint *x,
gint *y,
gint *height,
gint *width);
static void gtk_combo_popup_list (GtkCombo *combo);
static void gtk_combo_activate (GtkWidget *widget,
GtkCombo *combo);
static void gtk_combo_class_init (GtkComboClass *klass);
static void gtk_combo_init (GtkCombo *combo);
static void gtk_combo_destroy (GtkObject *combo);
static GtkListItem *gtk_combo_find (GtkCombo *combo);
static gchar * gtk_combo_func (GtkListItem *li);
static gint gtk_combo_focus_idle (GtkCombo *combo);
static gint gtk_combo_entry_focus_out (GtkEntry *entry,
GdkEventFocus *event,
GtkCombo *combo);
static void gtk_combo_get_pos (GtkCombo *combo,
gint *x,
gint *y,
gint *height,
gint *width);
static void gtk_combo_popup_list (GtkCombo *combo);
static void gtk_combo_activate (GtkWidget *widget,
GtkCombo *combo);
static void gtk_combo_popup_button_press (GtkWidget *button,
GdkEventButton *event,
GtkCombo *combo);
static void gtk_combo_popup_button_leave (GtkWidget *button,
GdkEventCrossing *event,
GtkCombo *combo);
static void gtk_combo_update_entry (GtkList *list,
GtkCombo *combo);
static void gtk_combo_update_list (GtkEntry *entry,
GtkCombo *combo);
static gint gtk_combo_button_press (GtkWidget *widget,
GdkEvent *event,
GtkCombo *combo);
static gint gtk_combo_button_release (GtkWidget *widget,
GdkEvent *event,
GtkCombo *combo);
static gint gtk_combo_list_enter (GtkWidget *widget,
GdkEventCrossing *event,
GtkCombo *combo);
static gint gtk_combo_list_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkCombo *combo);
static gint gtk_combo_entry_key_press (GtkEntry *widget,
GdkEventKey *event,
GtkCombo *combo);
static void gtk_combo_item_destroy (GtkObject *object);
static void gtk_combo_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_combo_update_entry (GtkList *list,
GtkCombo *combo);
static void gtk_combo_update_list (GtkEntry *entry,
GtkCombo *combo);
static gint gtk_combo_button_press (GtkWidget *widget,
GdkEvent *event,
GtkCombo *combo);
static gint gtk_combo_button_release (GtkWidget *widget,
GdkEvent *event,
GtkCombo *combo);
static gint gtk_combo_list_enter (GtkWidget *widget,
GdkEventCrossing *event,
GtkCombo *combo);
static gint gtk_combo_list_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkCombo *combo);
static gint gtk_combo_entry_key_press (GtkEntry *widget,
GdkEventKey *event,
GtkCombo *combo);
static gint gtk_combo_window_key_press (GtkWidget *window,
GdkEventKey *event,
GtkCombo *combo);
static void gtk_combo_item_destroy (GtkObject *object);
static void gtk_combo_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static GtkHBoxClass *parent_class = NULL;
......@@ -208,6 +211,34 @@ gtk_combo_entry_key_press (GtkEntry * entry, GdkEventKey * event, GtkCombo * com
return FALSE;
}
static int
gtk_combo_window_key_press (GtkWidget *window,
GdkEventKey *event,
GtkCombo *combo)
{
GList *li;
if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
{
if (GTK_WIDGET_VISIBLE (combo->popwin))
{
gtk_widget_hide (combo->popwin);
if (GTK_WIDGET_HAS_GRAB (combo->popwin))
{
gtk_grab_remove (combo->popwin);
gdk_pointer_ungrab (event->time);
}
}
gtk_signal_emit_stop_by_name (GTK_OBJECT (window), "key_press_event");
return TRUE;
}
return FALSE;
}
static GtkListItem *
gtk_combo_find (GtkCombo * combo)
{
......@@ -686,6 +717,9 @@ gtk_combo_init (GtkCombo * combo)
combo->popwin = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_ref (combo->popwin);
gtk_window_set_policy (GTK_WINDOW (combo->popwin), 1, 1, 0);
gtk_signal_connect (GTK_OBJECT (combo->popwin), "key_press_event",
GTK_SIGNAL_FUNC (gtk_combo_window_key_press), combo);
gtk_widget_set_events (combo->popwin, GDK_KEY_PRESS_MASK);
......
......@@ -2418,8 +2418,7 @@ real_tree_move (GtkCTree *ctree,
gtk_clist_freeze (clist);
work = NULL;
if (gtk_ctree_is_viewable (ctree, node) ||
gtk_ctree_is_viewable (ctree, new_sibling))
if (gtk_ctree_is_viewable (ctree, node))
work = GTK_CTREE_NODE (g_list_nth (clist->row_list, clist->focus_row));
gtk_ctree_unlink (ctree, node, FALSE);
......@@ -2904,6 +2903,9 @@ set_cell_contents (GtkCList *clist,
gboolean visible = FALSE;
GtkCTree *ctree;
GtkRequisition requisition;
gchar *old_text = NULL;
GdkPixmap *old_pixmap = NULL;
GdkBitmap *old_mask = NULL;
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
......@@ -2930,26 +2932,17 @@ set_cell_contents (GtkCList *clist,
{
case GTK_CELL_EMPTY:
break;
case GTK_CELL_TEXT:
g_free (GTK_CELL_TEXT (clist_row->cell[column])->text);
old_text = GTK_CELL_TEXT (clist_row->cell[column])->text;
break;
case GTK_CELL_PIXMAP:
gdk_pixmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap);
if (GTK_CELL_PIXMAP (clist_row->cell[column])->mask)
gdk_bitmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->mask);
old_pixmap = GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap;
old_mask = GTK_CELL_PIXMAP (clist_row->cell[column])->mask;
break;
case GTK_CELL_PIXTEXT:
if (GTK_CELL_PIXTEXT (clist_row->cell[column])->text)
g_free (GTK_CELL_PIXTEXT (clist_row->cell[column])->text);
if (GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap)
{
gdk_pixmap_unref
(GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap);
if (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask)
gdk_bitmap_unref
(GTK_CELL_PIXTEXT (clist_row->cell[column])->mask);
}
old_text = GTK_CELL_PIXTEXT (clist_row->cell[column])->text;
old_pixmap = GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap;
old_mask = GTK_CELL_PIXTEXT (clist_row->cell[column])->mask;
break;
case GTK_CELL_WIDGET:
/* unimplimented */
......@@ -2963,6 +2956,8 @@ set_cell_contents (GtkCList *clist,
if (column == ctree->tree_column && type != GTK_CELL_EMPTY)
type = GTK_CELL_PIXTEXT;
/* Note that pixmap and mask were already ref'ed by the caller
*/
switch (type)
{
case GTK_CELL_TEXT:
......@@ -3017,6 +3012,13 @@ set_cell_contents (GtkCList *clist,
if (visible && clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
column_auto_resize (clist, clist_row, column, requisition.width);
if (old_text)
g_free (old_text);
if (old_pixmap)
gdk_pixmap_unref (old_pixmap);
if (old_mask)
gdk_pixmap_unref (old_mask);
}
static void
......
......@@ -1732,6 +1732,8 @@ gtk_entry_commit_cb (GtkIMContext *context,
GtkEditable *editable = GTK_EDITABLE (entry);
gint tmp_pos = entry->current_pos;
gtk_editable_delete_selection (editable);
gtk_editable_insert_text (editable, str, strlen (str), &tmp_pos);
gtk_editable_set_position (editable, tmp_pos);
}
......
......@@ -89,6 +89,18 @@
#define FILE_LIST_WIDTH 180
#define FILE_LIST_HEIGHT 180
/* The Hurd doesn't define either PATH_MAX or MAXPATHLEN, so we put this
* in here, since the rest of the code in the file does require some
* fixed maximum.
*/
#ifndef MAXPATHLEN
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
# else
# define MAXPATHLEN 2048
# endif
#endif
/* I've put this here so it doesn't get confused with the
* file completion interface */
typedef struct _HistoryCallbackArg HistoryCallbackArg;
......
......@@ -73,12 +73,6 @@ static void gtk_frame_real_compute_child_allocation (GtkFrame *frame,
static GtkBinClass *parent_class = NULL;
/* Here until I convince timj about memory management behavior
*/
gchar * gtk_frame_get_label (GtkFrame *frame);
gchar * gtk_label_get_text (GtkLabel *label);
GtkType
gtk_frame_get_type (void)
{
......@@ -276,7 +270,7 @@ gtk_frame_set_label (GtkFrame *frame,
* was no label widget or the lable widget was not
* a #GtkLabel. This value must be freed with g_free().
**/
gchar *
G_CONST_RETURN gchar *
gtk_frame_get_label (GtkFrame *frame)
{
g_return_val_if_fail (frame != NULL, NULL);
......
......@@ -70,10 +70,11 @@ struct _GtkFrameClass
GtkType gtk_frame_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_frame_new (const gchar *label);
void gtk_frame_set_label (GtkFrame *frame,
const gchar *label);
/* Temporarily commented out until memory management behavior is figured out */
/* gchar * gtk_frame_get_label (GtkFrame *frame); */
void gtk_frame_set_label (GtkFrame *frame,
const gchar *label);
G_CONST_RETURN gchar *gtk_frame_get_label (GtkFrame *frame);
void gtk_frame_set_label_widget (GtkFrame *frame,
GtkWidget *label_widget);
void gtk_frame_set_label_align (GtkFrame *frame,
......
......@@ -443,6 +443,7 @@ gtk_handle_box_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
GtkHandleBox *hb;
GdkRectangle new_area;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HANDLE_BOX (widget));
......@@ -880,27 +881,29 @@ gtk_handle_box_button_changed (GtkWidget *widget,
return FALSE;
child = GTK_BIN (hb)->child;
switch (hb->handle_position)
if (child)
{
case GTK_POS_LEFT:
in_handle = event->x < DRAG_HANDLE_SIZE;
break;
case GTK_POS_TOP:
in_handle = event->y < DRAG_HANDLE_SIZE;
break;
case GTK_POS_RIGHT:
in_handle = event->x > 2 * GTK_CONTAINER (hb)->border_width + child->allocation.width;
break;
case GTK_POS_BOTTOM:
in_handle = event->y > 2 * GTK_CONTAINER (hb)->border_width + child->allocation.height;
break;
default:
in_handle = FALSE;
break;
switch (hb->handle_position)
{
case GTK_POS_LEFT:
in_handle = event->x < DRAG_HANDLE_SIZE;
break;
case GTK_POS_TOP:
in_handle = event->y < DRAG_HANDLE_SIZE;
break;
case GTK_POS_RIGHT:
in_handle = event->x > 2 * GTK_CONTAINER (hb)->border_width + child->allocation.width;
break;
case GTK_POS_BOTTOM:
in_handle = event->y > 2 * GTK_CONTAINER (hb)->border_width + child->allocation.height;
break;
default:
in_handle = FALSE;
break;
}
}
if (!child)
else
{
in_handle = FALSE;
event_handled = TRUE;
......
......@@ -1318,8 +1318,7 @@ gtk_item_factory_delete_item (GtkItemFactory *ifactory,
const gchar *path)
{
GtkItemFactoryClass *class;
GtkItemFactoryItem *item;
gchar *fpath;
GtkWidget *widget;
g_return_if_fail (ifactory != NULL);
g_return_if_fail (GTK_IS_ITEM_FACTORY (ifactory));
......@@ -1327,25 +1326,14 @@ gtk_item_factory_delete_item (GtkItemFactory *ifactory,
class = GTK_ITEM_FACTORY_GET_CLASS (ifactory);
fpath = g_strconcat (ifactory->path, path, NULL);
item = g_hash_table_lookup (class->item_ht, fpath);
g_free (fpath);
widget = gtk_item_factory_get_widget (ifactory, path);
if (item)
if (widget)
{
GtkWidget *widget = NULL;
GSList *slist;
for (slist = item->widgets; slist; slist = slist->next)
{
widget = slist->data;
if (gtk_item_factory_from_widget (widget) == ifactory)
break;
}
if (GTK_IS_MENU (widget))
widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
if (slist)
gtk_widget_destroy (widget);
gtk_widget_destroy (widget);
}
}
......
......@@ -337,13 +337,13 @@ gtk_label_set_markup_with_accel (GtkLabel *label,
* Return value: the text in the label widget. This value must
* be freed with g_free().
**/
gchar *
G_CONST_RETURN gchar *
gtk_label_get_text (GtkLabel *label)
{
g_return_val_if_fail (label != NULL, NULL);
g_return_val_if_fail (GTK_IS_LABEL (label), NULL);
return g_strdup (label->label);
return label->label;
}
void
......
......@@ -71,8 +71,11 @@ struct _GtkLabelClass
GtkType gtk_label_get_type (void) G_GNUC_CONST;
GtkWidget *gtk_label_new (const char *str);
void gtk_label_set_text (GtkLabel *label,
const char *str);
void gtk_label_set_text (GtkLabel *label,
const char *str);
G_CONST_RETURN gchar *gtk_label_get_text (GtkLabel *label);
void gtk_label_set_attributes (GtkLabel *label,
PangoAttrList *attrs);
......@@ -81,8 +84,6 @@ void gtk_label_set_markup (GtkLabel *label,
guint gtk_label_set_markup_with_accel (GtkLabel *label,
const gchar *str);
/* Temporarily commented out until memory management behavior is figured out *//* gchar * gtk_label_get_text (GtkLabel *label); */
void gtk_label_set_justify (GtkLabel *label,
GtkJustification jtype);
void gtk_label_set_pattern (GtkLabel *label,
......
......@@ -2700,6 +2700,14 @@ gtk_list_signal_item_toggle (GtkListItem *list_item,
g_return_if_fail (list != NULL);
g_return_if_fail (GTK_IS_LIST (list));
if ((list->selection_mode == GTK_SELECTION_BROWSE ||
list->selection_mode == GTK_SELECTION_EXTENDED) &&
GTK_WIDGET (list_item)->state == GTK_STATE_NORMAL)
{
gtk_widget_set_state (GTK_WIDGET (list_item), GTK_STATE_SELECTED);
return;
}
switch (GTK_WIDGET (list_item)->state)
{
case GTK_STATE_SELECTED:
......
......@@ -110,6 +110,8 @@ static void gtk_menu_position (GtkMenu *menu);
static void gtk_menu_reparent (GtkMenu *menu,
GtkWidget *new_parent,
gboolean unrealize);
static void gtk_menu_remove (GtkContainer *menu,
GtkWidget *widget);
static GtkMenuShellClass *parent_class = NULL;
static const gchar *attach_data_key = "gtk-menu-attach-data";
......@@ -169,6 +171,8 @@ gtk_menu_class_init (GtkMenuClass *class)
widget_class->hide_all = gtk_menu_hide_all;
widget_class->enter_notify_event = gtk_menu_enter_notify;
widget_class->leave_notify_event = gtk_menu_leave_notify;
container_class->remove = gtk_menu_remove;
menu_shell_class->submenu_placement = GTK_LEFT_RIGHT;
menu_shell_class->deactivate = gtk_menu_deactivate;
......@@ -396,6 +400,28 @@ gtk_menu_detach (GtkMenu *menu)
gtk_widget_unref (GTK_WIDGET (menu));
}
void
gtk_menu_remove(GtkContainer *container,
GtkWidget *widget)
{
GtkMenu *menu;
g_return_if_fail (GTK_IS_MENU (container));
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
menu = GTK_MENU (container);
/* Clear out old_active_menu_item if it matches the item we are removing
*/
if (menu->old_active_menu_item == widget)
{
gtk_widget_unref (menu->old_active_menu_item);
menu->old_active_menu_item = NULL;
}
GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
}
GtkWidget*
gtk_menu_new (void)
{
......
......@@ -683,6 +683,12 @@ gtk_menu_shell_remove (GtkContainer *container,
menu_shell = GTK_MENU_SHELL (container);
menu_shell->children = g_list_remove (menu_shell->children, widget);
if (widget == menu_shell->active_menu_item)
{
gtk_item_deselect (GTK_ITEM (menu_shell->active_menu_item));
menu_shell->active_menu_item = NULL;
}
gtk_widget_unparent (widget);
/* queue resize regardless of GTK_WIDGET_VISIBLE (container),
......
......@@ -2547,8 +2547,8 @@ gtk_notebook_set_shape (GtkNotebook *notebook)
}
gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height);
/* if theres an area for scrollign arrows draw the shape for them */
if (notebook->panel)
/* if theres an area for scrolling arrows draw the shape for them */
if (notebook->panel && gdk_window_is_visible (notebook->panel))
{
gdk_window_get_geometry(notebook->panel, &x, &y, &width, &height, &depth);
gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height);
......
......@@ -558,6 +558,56 @@ gtk_option_menu_changed (GtkOptionMenu *option_menu)
g_signal_emit (G_OBJECT (option_menu), signals[CHANGED], 0);
}
static void
gtk_option_menu_select_first_sensitive (GtkOptionMenu *option_menu)
{
if (option_menu->menu)
{
GList *children = GTK_MENU_SHELL (option_menu->menu)->children;
gint index = 0;
while (children)
{
if (GTK_WIDGET_SENSITIVE (children->data))
{
gtk_option_menu_set_history (option_menu, index);
return;
}
children = children->next;
index++;
}
}
}
static void
gtk_option_menu_item_state_changed_cb (GtkWidget *widget,
GtkStateType previous_state,
GtkOptionMenu *option_menu)
{
GtkWidget *child = GTK_BIN (option_menu)->child;
if (child && GTK_WIDGET_SENSITIVE (child) != GTK_WIDGET_IS_SENSITIVE (widget))
gtk_widget_set_sensitive (child, GTK_WIDGET_IS_SENSITIVE (widget));
}
static void
gtk_option_menu_item_destroy_cb (GtkWidget *widget,
GtkOptionMenu *option_menu)
{
GtkWidget *child = GTK_BIN (option_menu)->child;
if (child)
{
gtk_widget_ref (child);
gtk_option_menu_remove_contents (option_menu);
gtk_widget_destroy (child);
gtk_widget_unref (child);
gtk_option_menu_select_first_sensitive (option_menu);
}
}
static void
gtk_option_menu_update_contents (GtkOptionMenu *option_menu)
{
......@@ -580,14 +630,16 @@ gtk_option_menu_update_contents (GtkOptionMenu *option_menu)
child = GTK_BIN (option_menu->menu_item)->child;
if (child)
{
if (GTK_BIN (option_menu)->child)
gtk_container_remove (GTK_CONTAINER (option_menu),
GTK_BIN (option_menu)->child);
if (GTK_WIDGET (option_menu)->state != child->state)
gtk_widget_set_state (child, GTK_WIDGET (option_menu)->state);
if (!GTK_WIDGET_IS_SENSITIVE (option_menu->menu_item))
gtk_widget_set_sensitive (child, FALSE);
gtk_widget_reparent (child, GTK_WIDGET (option_menu));
}
gtk_signal_connect (GTK_OBJECT (option_menu->menu_item), "state_changed",
GTK_SIGNAL_FUNC (gtk_option_menu_item_state_changed_cb), option_menu);
gtk_signal_connect (GTK_OBJECT (option_menu->menu_item), "destroy",
GTK_SIGNAL_FUNC (gtk_option_menu_item_destroy_cb), option_menu);
gtk_widget_size_request (child, &child_requisition);
gtk_widget_size_allocate (GTK_WIDGET (option_menu),
&(GTK_WIDGET (option_menu)->allocation));
......@@ -604,15 +656,28 @@ gtk_option_menu_update_contents (GtkOptionMenu *option_menu)
static void
gtk_option_menu_remove_contents (GtkOptionMenu *option_menu)
{
GtkWidget *child;
g_return_if_fail (option_menu != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));
if (GTK_BIN (option_menu)->child)
if (option_menu->menu_item)
{
if (GTK_WIDGET (option_menu->menu_item)->state != GTK_BIN (option_menu)->child->state)
gtk_widget_set_state (GTK_BIN (option_menu)->child,
GTK_WIDGET (option_menu->menu_item)->state);
gtk_widget_reparent (GTK_BIN (option_menu)->child, option_menu->menu_item);
child = GTK_BIN (option_menu)->child;
if (child)
{
gtk_widget_set_sensitive (child, TRUE);
gtk_widget_reparent (child, option_menu->menu_item);
}
gtk_signal_disconnect_by_func (GTK_OBJECT (option_menu->menu_item),
GTK_SIGNAL_FUNC (gtk_option_menu_item_state_changed_cb),
option_menu);
gtk_signal_disconnect_by_func (GTK_OBJECT (option_menu->menu_item),
GTK_SIGNAL_FUNC (gtk_option_menu_item_destroy_cb),
option_menu);
gtk_widget_unref (option_menu->menu_item);
option_menu->menu_item = NULL;
}
......
......@@ -926,7 +926,7 @@ gtk_range_button_press (GtkWidget *widget,
}
}