summaryrefslogtreecommitdiff
path: root/tests/testtoolbar.c
diff options
context:
space:
mode:
authorSoeren Sandmann <sandmann@daimi.au.dk>2003-10-20 18:56:05 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2003-10-20 18:56:05 +0000
commit7c659465e2f01209d398d54524a6ad71f6495a09 (patch)
tree23dc222be8707a34b9cde73f5e420272728205f4 /tests/testtoolbar.c
parentc7353d84eefc443adf1c0651c91f868773708e51 (diff)
downloadgtk+-7c659465e2f01209d398d54524a6ad71f6495a09.tar.gz
Add support for OS X like sliding of toolbar items during drag and drop,
Mon Oct 20 20:27:22 2003 Soeren Sandmann <sandmann@daimi.au.dk> Add support for OS X like sliding of toolbar items during drag and drop, (#110919, Dave Bordoley) Make dnd highlighting the responsibility of the application. (Fixes #116298, Owen Taylor) * gtk/gtktoolbar.h: Add prototypes for new API. * gtk/gtktoolbar.c (physical_to_logical, logical_to_physical): new functions converting between "position including placeholders" and "position excluding placeholders". (gtk_toolbar_class_init): remove drag_leave and drag_motion handlers (struct _ToolbarContent): new struct containing information related to toolbar items. (gtk_toolbar_highlight_drop_location): new public function (gtk_toolbar_unhighlight_drop_location): new public function * tests/testtoolbar.c (toolbar_drag_motion, toolbar_drag_leave): new functions (main): connect to dnd signals. Make the "New" item expand to make drag and drop more exciting.
Diffstat (limited to 'tests/testtoolbar.c')
-rw-r--r--tests/testtoolbar.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
index 4eab1e3bf4..2127676b66 100644
--- a/tests/testtoolbar.c
+++ b/tests/testtoolbar.c
@@ -472,6 +472,28 @@ popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button_number)
return TRUE;
}
+static gboolean
+toolbar_drag_motion (GtkToolbar *toolbar,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ gpointer null)
+{
+ gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ gtk_toolbar_highlight_drop_location (toolbar, x, y, 100, 60);
+ return TRUE;
+}
+
+static void
+toolbar_drag_leave (GtkToolbar *toolbar,
+ GdkDragContext *context,
+ guint time,
+ gpointer null)
+{
+ gtk_toolbar_unhighlight_drop_location (toolbar);
+}
+
gint
main (gint argc, gchar **argv)
{
@@ -577,6 +599,7 @@ main (gint argc, gchar **argv)
gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), NULL);
add_item_to_list (store, item, "New");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+ gtk_tool_item_set_expand (item, TRUE);
item = gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
add_item_to_list (store, item, "Open");
@@ -624,7 +647,10 @@ main (gint argc, gchar **argv)
add_item_to_list (store, item, "Left");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
- item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_CENTER); make_prop_editor (G_OBJECT (item));
+ item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_CENTER);
+#if 0
+ make_prop_editor (G_OBJECT (item));
+#endif
group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
add_item_to_list (store, item, "Center");
@@ -668,12 +694,18 @@ main (gint argc, gchar **argv)
gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
target_table, G_N_ELEMENTS (target_table),
GDK_ACTION_MOVE);
+ g_signal_connect (toolbar, "drag_motion",
+ G_CALLBACK (toolbar_drag_motion), NULL);
+ g_signal_connect (toolbar, "drag_leave",
+ G_CALLBACK (toolbar_drag_leave), NULL);
g_signal_connect (toolbar, "drag_drop",
G_CALLBACK (toolbar_drag_drop), label);
gtk_widget_show_all (window);
+#if 0
make_prop_editor (G_OBJECT (toolbar));
+#endif
g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);