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

Unset allocation on unparent, to force reallocation if we get adding back

Thu Mar  5 01:22:06 1998  Owen Taylor  <owt1@cornell.edu>

	* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
	  on unparent, to force reallocation if we get adding back
	  to a new parent which is already size-allocated.

	* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
	  for each colormap, removed the idle hack.

	* gdk/gdk.c: Don't warn when unable to open XIM method,
	  since X11R5 apparently has no default method.

	* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
	  call size_request on initial emission - since the
	  widget size isn't set yet, it can't change.

	* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
	  testgtk with the correct working directory.

	* gtk/gtkentry.c (gtk_move_forward_word):
	  Check for position at end of line.

	* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
	  removed 'gpointer data' arguments from default handler
	  structures.
parent 793a1305
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
Thu Mar 5 01:22:06 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c (gtk_widget_unparent): Unset allocation
on unparent, to force reallocation if we get adding back
to a new parent which is already size-allocated.
* gtk/gtktreeitem.c: Keep track of separate +/- pixmaps
for each colormap, removed the idle hack.
* gdk/gdk.c: Don't warn when unable to open XIM method,
since X11R5 apparently has no default method.
* gtk/gtkwidget.c (gtk_widget_set_style_internal): Don't
call size_request on initial emission - since the
widget size isn't set yet, it can't change.
* gtk/Makefile.am: New rules 'test' and 'test-debug' to run
testgtk with the correct working directory.
* gtk/gtkentry.c (gtk_move_forward_word):
Check for position at end of line.
* gtk/gtkinputdialog.h (struct _GtkInputDialogClass):
removed 'gpointer data' arguments from default handler
structures.
Wed Mar 4 20:06:47 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Drags can only be started with
......@@ -42,7 +68,6 @@ Mon Mar 2 17:48:38 1998 Owen Taylor <owt1@cornell.edu>
* gtk/testgtk.c: GList where there should have been GSList
>>>>>>> 1.174
Mon Mar 2 12:26:59 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkentry.c: Changed 'entry != NULL' to 'editable != NULL'
......
......@@ -61,6 +61,8 @@ Bugs:
* Change bitfields to guints from enums for C++ ?
* Force paned window handle to be kept on screen
Additions:
* it might be good to ues stdio and getch() instead of 1-character reads.
so one can take advantage of buffering. Currently each read() takes a separate
......@@ -86,7 +88,6 @@ Additions:
void gtk_rc_string_export (const gchar *rc_additions,
gboolean override_rc_styles);
TODO AFTER GTK 1.0
------------------
......@@ -210,3 +211,29 @@ TODO AFTER GTK 1.0
characters be shown?)
- Horizontal scrolling
- Disable pasting compound text
? Allow moving the separator for paned widgets by dragging
it directly instead of using the handle.
? Mark public use of gtk_tree_remove_item as deprecated - it should be used
as:
gtk_container_remove (GTK_CONTAINER(tree), widget);
* Standardize that all strings should be passed as gchar *, not
guchar *. But what about non-string data? (gdk_property_change,
gtk_selection_data_set) X makes these sort of things guchar...
* Check into XAddConnectionWatch - is this needed for XIM?
* Places where a _full variant is needed:
gtk_clist_set_row_data
gtk_init_add
gtk_menu_popup
gtk_toolbar_prepend_element
gtk_toolbar_insert_element
gtk_widget_dnd_data_set (should be guchar * with a copy?
shouldn't be there at all...)
??? GtkDrawingarea.draw_data
\ No newline at end of file
......@@ -551,8 +551,6 @@ gdk_init (int *argc,
xim_window = (GdkWindow*)NULL;
gdk_im_open (NULL, NULL, NULL);
if (gdk_im_get () == NULL)
g_warning ("unable to open input method.");
#endif
initialized = 1;
......@@ -3358,7 +3356,7 @@ gdk_im_open (XrmDatabase db, gchar* res_name, gchar* res_class)
xim_im = XOpenIM (GDK_DISPLAY(), db, res_name, res_class);
if (xim_im == NULL)
{
g_warning ("Don\'t open IM.");
GDK_NOTE (XIM, g_warning ("Unable to open open IM."));
return FALSE;
}
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
......
......@@ -551,8 +551,6 @@ gdk_init (int *argc,
xim_window = (GdkWindow*)NULL;
gdk_im_open (NULL, NULL, NULL);
if (gdk_im_get () == NULL)
g_warning ("unable to open input method.");
#endif
initialized = 1;
......@@ -3358,7 +3356,7 @@ gdk_im_open (XrmDatabase db, gchar* res_name, gchar* res_class)
xim_im = XOpenIM (GDK_DISPLAY(), db, res_name, res_class);
if (xim_im == NULL)
{
g_warning ("Don\'t open IM.");
GDK_NOTE (XIM, g_warning ("Unable to open open IM."));
return FALSE;
}
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
......
......@@ -269,3 +269,9 @@ files:
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
echo $$p; \
done
test: testgtk
( CWD=`pwd` ; cd $(srcdir) ; $$CWD/testgtk )
test-debug: testgtk
( CWD=`pwd` ; cd $(srcdir) ; gdb $$CWD/testgtk )
......@@ -731,6 +731,9 @@ gtk_entry_button_press (GtkWidget *widget,
gtk_grab_add (widget);
tmp_pos = gtk_entry_position (entry, event->x + entry->scroll_offset);
/* Set it now, so we display things right. We'll unset it
* later if things don't work out */
editable->has_selection = TRUE;
gtk_entry_set_selection (editable, tmp_pos, tmp_pos);
editable->current_pos = editable->selection_start_pos;
break;
......@@ -749,7 +752,7 @@ gtk_entry_button_press (GtkWidget *widget,
}
else if (event->type == GDK_BUTTON_PRESS)
{
if (event->button == 2)
if ((event->button == 2) && editable->editable)
{
if (editable->selection_start_pos == editable->selection_end_pos ||
editable->has_selection)
......@@ -765,6 +768,9 @@ gtk_entry_button_press (GtkWidget *widget,
gtk_entry_set_selection (editable, tmp_pos, tmp_pos);
editable->has_selection = FALSE;
editable->current_pos = editable->selection_start_pos;
if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == widget->window)
gtk_selection_owner_set (NULL, GDK_SELECTION_PRIMARY, event->time);
}
}
......@@ -795,10 +801,9 @@ gtk_entry_button_release (GtkWidget *widget,
if (gtk_selection_owner_set (widget,
GDK_SELECTION_PRIMARY,
event->time))
{
editable->has_selection = TRUE;
gtk_entry_queue_draw (entry);
}
editable->has_selection = TRUE;
else
gtk_entry_queue_draw (entry);
}
else
{
......@@ -809,8 +814,6 @@ gtk_entry_button_release (GtkWidget *widget,
else if (event->button == 3)
{
gtk_grab_remove (widget);
if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == widget->window)
gtk_selection_owner_set (NULL, GDK_SELECTION_PRIMARY, event->time);
}
return FALSE;
......@@ -1577,7 +1580,7 @@ gtk_move_forward_word (GtkEntry *entry)
GtkEditable *editable;
editable = GTK_EDITABLE (entry);
if (entry->text)
if (entry->text && (editable->current_pos < entry->text_length))
{
text = entry->text;
i = editable->current_pos;
......
......@@ -34,6 +34,20 @@ enum {
LAST_SIGNAL
};
typedef struct _GtkTreePixmaps GtkTreePixmaps;
struct _GtkTreePixmaps {
gint refcount;
GdkColormap *colormap;
GdkPixmap *pixmap_plus;
GdkPixmap *pixmap_minus;
GdkBitmap *mask_plus;
GdkBitmap *mask_minus;
};
static GList *pixmaps = NULL;
typedef void (*GtkTreeItemSignal) (GtkObject *object,
gpointer arg1,
gpointer data);
......@@ -70,6 +84,9 @@ static void gtk_tree_item_subtree_button_changed_state (GtkWidget *widget);
static void gtk_tree_item_map(GtkWidget*);
static void gtk_tree_item_unmap(GtkWidget*);
static void gtk_tree_item_add_pixmaps (GtkTreeItem *tree_item);
static void gtk_tree_item_remove_pixmaps (GtkTreeItem *tree_item);
static GtkItemClass *parent_class = NULL;
static GtkContainerClass *container_class = NULL;
static gint tree_item_signals[LAST_SIGNAL] = { 0 };
......@@ -338,33 +355,87 @@ gtk_tree_item_collapse (GtkTreeItem *tree_item)
}
static gint
gtk_tree_item_idle_hack (GtkTreeItem *tree_item)
static void
gtk_tree_item_add_pixmaps (GtkTreeItem *tree_item)
{
static GdkPixmap *pixmap_plus = NULL;
static GdkPixmap *pixmap_minus = NULL;
static GdkBitmap *mask_plus = NULL;
static GdkBitmap *mask_minus = NULL;
GdkColor xpmcolor = { 0, 0, 0, 0 };
if (!pixmap_plus)
GList *tmp_list;
GdkColormap *colormap;
GtkTreePixmaps *pixmap_node = NULL;
if (tree_item->pixmaps)
return;
colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_item));
tmp_list = pixmaps;
while (tmp_list)
{
pixmap_node = (GtkTreePixmaps *)tmp_list->data;
if (pixmap_node->colormap == colormap)
break;
tmp_list = tmp_list->next;
}
if (tmp_list)
{
pixmap_node->refcount++;
tree_item->pixmaps = tmp_list;
}
else
{
pixmap_node = g_new (GtkTreePixmaps, 1);
pixmap_node->colormap = colormap;
pixmap_node->refcount = 1;
/* create pixmaps for plus icon */
pixmap_plus = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (tree_item)->window,
&mask_plus,
&xpmcolor,
tree_plus);
pixmap_node->pixmap_plus =
gdk_pixmap_create_from_xpm_d (GTK_WIDGET (tree_item)->window,
&pixmap_node->mask_plus,
NULL,
tree_plus);
/* create pixmaps for minus icon */
pixmap_minus = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (tree_item)->window,
&mask_minus,
&xpmcolor,
tree_minus);
pixmap_node->pixmap_minus =
gdk_pixmap_create_from_xpm_d (GTK_WIDGET (tree_item)->window,
&pixmap_node->mask_minus,
NULL,
tree_minus);
tree_item->pixmaps = pixmaps = g_list_prepend (pixmaps, pixmap_node);
}
gtk_pixmap_set (GTK_PIXMAP (tree_item->plus_pix_widget), pixmap_plus, mask_plus);
gtk_pixmap_set (GTK_PIXMAP (tree_item->minus_pix_widget), pixmap_minus, mask_minus);
gtk_pixmap_set (GTK_PIXMAP (tree_item->plus_pix_widget),
pixmap_node->pixmap_plus, pixmap_node->mask_plus);
gtk_pixmap_set (GTK_PIXMAP (tree_item->minus_pix_widget),
pixmap_node->pixmap_minus, pixmap_node->mask_minus);
}
return FALSE;
static void
gtk_tree_item_remove_pixmaps (GtkTreeItem *tree_item)
{
if (tree_item->pixmaps)
{
GtkTreePixmaps *pixmap_node = (GtkTreePixmaps *)tree_item->pixmaps->data;
g_assert (pixmap_node->refcount > 0);
if (--pixmap_node->refcount == 0)
{
gdk_pixmap_unref (pixmap_node->pixmap_plus);
gdk_bitmap_unref (pixmap_node->mask_plus);
gdk_pixmap_unref (pixmap_node->pixmap_minus);
gdk_bitmap_unref (pixmap_node->mask_minus);
pixmaps = g_list_remove_link (pixmaps, tree_item->pixmaps);
g_list_free_1 (tree_item->pixmaps);
g_free (pixmap_node);
}
tree_item->pixmaps = NULL;
}
}
static void
......@@ -379,9 +450,7 @@ gtk_tree_item_realize (GtkWidget *widget)
gdk_window_set_background (widget->window,
&widget->style->base[GTK_STATE_NORMAL]);
gtk_idle_add_priority (-64,
(GtkFunction) gtk_tree_item_idle_hack,
(gpointer) widget);
gtk_tree_item_add_pixmaps (GTK_TREE_ITEM (widget));
}
static void
......@@ -875,6 +944,7 @@ gtk_tree_item_destroy (GtkObject *object)
item->pixmaps_box = NULL;
}
/* destroy plus pixmap */
if (item->plus_pix_widget)
{
......@@ -890,6 +960,11 @@ gtk_tree_item_destroy (GtkObject *object)
gtk_widget_unref (item->minus_pix_widget);
item->minus_pix_widget = NULL;
}
/* By removing the pixmaps here, and not in unrealize, we depend on
* the fact that a widget can never change colormap or visual.
*/
gtk_tree_item_remove_pixmaps (item);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
......
......@@ -1140,6 +1140,14 @@ gtk_widget_unparent (GtkWidget *widget)
GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);
}
/* Reset the width and height here, to force reallocation if we
* get added back to a new parent. This won't work if our new
* allocation is smaller than 1x1 and we actually want a size of 1x1...
* (would 0x0 be OK here?)
*/
widget->allocation.width = 1;
widget->allocation.height = 1;
if (widget->window &&
GTK_WIDGET_NO_WINDOW (widget) &&
GTK_WIDGET_DRAWABLE (widget))
......@@ -2473,7 +2481,7 @@ gtk_widget_set_style_internal (GtkWidget *widget,
initial_emission ? NULL : previous_style);
gtk_style_unref (previous_style);
if (widget->parent)
if (widget->parent && !initial_emission)
{
GtkRequisition old_requisition;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment