summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoeren Sandmann <sandmann@daimi.au.dk>2003-10-29 01:58:38 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2003-10-29 01:58:38 +0000
commitf36e68a1e80b00e780daba46b1196ed7a804d1e0 (patch)
tree6d61d8359a62c51c5d3fea1e35402e840d504a1f
parent077eee4dfb25eda4db6de0f691db6a7085f9b5c2 (diff)
downloadgtk+-f36e68a1e80b00e780daba46b1196ed7a804d1e0.tar.gz
Add this function; remove gtk_toolbar_highlight_drop_location() and
Wed Oct 29 02:54:35 2003 Soeren Sandmann <sandmann@daimi.au.dk> * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this function; remove gtk_toolbar_highlight_drop_location() and gtk_toolbar_unhighlight_drop_location(). Also fix bug where the number of overflowed items were miscounted.
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.pre-2-108
-rw-r--r--ChangeLog.pre-2-48
-rw-r--r--ChangeLog.pre-2-68
-rw-r--r--ChangeLog.pre-2-88
-rw-r--r--gtk/gtktoolbar.c73
-rw-r--r--gtk/gtktoolbar.h8
-rw-r--r--tests/testtoolbar.c6
8 files changed, 89 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 4045df270a..7bb4ceb990 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+ function; remove gtk_toolbar_highlight_drop_location() and
+ gtk_toolbar_unhighlight_drop_location().
+
+ Also fix bug where the number of overflowed items were miscounted.
+
Tue Oct 28 12:20:16 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 4045df270a..7bb4ceb990 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+ function; remove gtk_toolbar_highlight_drop_location() and
+ gtk_toolbar_unhighlight_drop_location().
+
+ Also fix bug where the number of overflowed items were miscounted.
+
Tue Oct 28 12:20:16 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 4045df270a..7bb4ceb990 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+ function; remove gtk_toolbar_highlight_drop_location() and
+ gtk_toolbar_unhighlight_drop_location().
+
+ Also fix bug where the number of overflowed items were miscounted.
+
Tue Oct 28 12:20:16 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 4045df270a..7bb4ceb990 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+ function; remove gtk_toolbar_highlight_drop_location() and
+ gtk_toolbar_unhighlight_drop_location().
+
+ Also fix bug where the number of overflowed items were miscounted.
+
Tue Oct 28 12:20:16 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 4045df270a..7bb4ceb990 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,11 @@
+Wed Oct 29 02:54:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.[ch] (gtk_toolbar_set_drop_highlight_item): Add this
+ function; remove gtk_toolbar_highlight_drop_location() and
+ gtk_toolbar_unhighlight_drop_location().
+
+ Also fix bug where the number of overflowed items were miscounted.
+
Tue Oct 28 12:20:16 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_has_toplevel_focus): Remove
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 42c318ecd1..3536ed0118 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -1830,24 +1830,26 @@ get_item_requisition (GtkToolbar *toolbar,
}
/**
- * gtk_toolbar_highlight_drop_location:
+ * gtk_toolbar_set_drop_highlight_item:
* @toolbar: a #GtkToolbar
- * @index: the toolbar position to highlight, or -1
- * @tool_item: a #GtkToolbar that isn't part of a widget hierarchy
- *
- * Highlights the position on the toolbar indicated by @index to give
- * an idea of how @toolbar would look if @tool_item was added to it at
- * @index.
+ * @item: a #GtkToolItem, or %NULL to turn of highlighting
+ * @index: a position on @toolbar
*
- * After calling this function gtk_toolbar_unhighlight_drop_location() must
- * be called before @tool_item can be added to any widget hierarchy.
+ * Highlights @toolbar to give an idea of what it would look like
+ * if @item was added to @toolbar at position indicated by @index. If @item
+ * is %NULL, highlighting is turned off. In that case @index is ignored.
+ *
+ * The @tool_item passed to this function must not be part of any widget
+ * hierarchy. When an item is set as drop highlight item it can not
+ * added to any widget hierarchy or used as highlight item for another
+ * toolbar.
*
* Since: 2.4
**/
void
-gtk_toolbar_highlight_drop_location (GtkToolbar *toolbar,
- gint index,
- GtkToolItem *tool_item)
+gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar,
+ GtkToolItem *tool_item,
+ gint index)
{
ToolbarContent *content;
GtkToolbarPrivate *priv;
@@ -1857,31 +1859,54 @@ gtk_toolbar_highlight_drop_location (GtkToolbar *toolbar,
GtkRequisition requisition;
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
- g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
+ g_return_if_fail (tool_item == NULL || GTK_IS_TOOL_ITEM (tool_item));
priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+ if (!tool_item)
+ {
+ if (priv->in_dnd)
+ {
+ priv->leaving_dnd = TRUE;
+ reset_all_placeholders (toolbar);
+ ensure_idle_handler (toolbar);
+
+ if (priv->highlight_tool_item)
+ {
+ gtk_widget_unparent (GTK_WIDGET (priv->highlight_tool_item));
+ g_object_unref (priv->highlight_tool_item);
+ priv->highlight_tool_item = NULL;
+ }
+ }
+
+ return;
+ }
+
if (tool_item != priv->highlight_tool_item)
{
if (priv->highlight_tool_item)
g_object_unref (priv->highlight_tool_item);
-
- gtk_object_sink (GTK_OBJECT (g_object_ref (tool_item)));
+
+ g_object_ref (tool_item);
+ gtk_object_sink (GTK_OBJECT (tool_item));
priv->highlight_tool_item = tool_item;
gtk_widget_set_parent (GTK_WIDGET (priv->highlight_tool_item),
GTK_WIDGET (toolbar));
}
-
+
if (!priv->in_dnd)
{
priv->n_overflow_items_when_dnd_started = 0;
for (list = priv->content; list != NULL; list = list->next)
{
content = list->data;
- if (content->is_overflow)
- priv->n_overflow_items_when_dnd_started++;
+ if (content->is_overflow &&
+ toolbar_item_visible (toolbar, content->item))
+ {
+ priv->n_overflow_items_when_dnd_started++;
+ }
}
}
@@ -1946,18 +1971,6 @@ gtk_toolbar_highlight_drop_location (GtkToolbar *toolbar,
void
gtk_toolbar_unhighlight_drop_location (GtkToolbar *toolbar)
{
- GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-
- priv->leaving_dnd = TRUE;
- reset_all_placeholders (toolbar);
- ensure_idle_handler (toolbar);
-
- if (priv->highlight_tool_item)
- {
- gtk_widget_unparent (GTK_WIDGET (priv->highlight_tool_item));
- g_object_unref (priv->highlight_tool_item);
- priv->highlight_tool_item = NULL;
- }
}
static void
diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h
index ec61e8f609..b15ace289c 100644
--- a/gtk/gtktoolbar.h
+++ b/gtk/gtktoolbar.h
@@ -159,11 +159,9 @@ GtkReliefStyle gtk_toolbar_get_relief_style (GtkToolbar *toolbar)
gint gtk_toolbar_get_drop_index (GtkToolbar *toolbar,
gint x,
gint y);
-void gtk_toolbar_highlight_drop_location (GtkToolbar *toolbar,
- gint index,
- GtkToolItem *tool_item);
-void gtk_toolbar_unhighlight_drop_location (GtkToolbar *toolbar);
-
+void gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar,
+ GtkToolItem *tool_item,
+ gint index);
/* internal function */
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
index d56c77677c..04ec128a6f 100644
--- a/tests/testtoolbar.c
+++ b/tests/testtoolbar.c
@@ -450,12 +450,12 @@ toolbar_drag_motion (GtkToolbar *toolbar,
drag_item = gtk_tool_button_new (NULL, "A quite long button");
gtk_object_sink (GTK_OBJECT (g_object_ref (drag_item)));
}
-
+
gdk_drag_status (context, GDK_ACTION_MOVE, time);
index = gtk_toolbar_get_drop_index (toolbar, x, y);
- gtk_toolbar_highlight_drop_location (toolbar, index, drag_item);
+ gtk_toolbar_set_drop_highlight_item (toolbar, drag_item, index);
return TRUE;
}
@@ -472,7 +472,7 @@ toolbar_drag_leave (GtkToolbar *toolbar,
drag_item = NULL;
}
- gtk_toolbar_unhighlight_drop_location (toolbar);
+ gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0);
}
gint