3 * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
4 * Copyright (C) 2002 James Henstridge <james@daa.com.au>
5 * Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 #include "prop-editor.h"
27 change_orientation (GtkWidget *button, GtkWidget *toolbar)
30 GtkOrientation orientation;
32 table = gtk_widget_get_parent (toolbar);
33 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
34 orientation = GTK_ORIENTATION_VERTICAL;
36 orientation = GTK_ORIENTATION_HORIZONTAL;
38 g_object_ref (toolbar);
39 gtk_container_remove (GTK_CONTAINER (table), toolbar);
40 gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar), orientation);
41 if (orientation == GTK_ORIENTATION_HORIZONTAL)
43 gtk_table_attach (GTK_TABLE (table), toolbar,
44 0,2, 0,1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
48 gtk_table_attach (GTK_TABLE (table), toolbar,
49 0,1, 0,4, GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0);
51 g_object_unref (toolbar);
55 change_show_arrow (GtkWidget *button, GtkWidget *toolbar)
57 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar),
58 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
62 set_toolbar_style_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
64 GtkWidget *option_menu;
67 option_menu = g_object_get_data (G_OBJECT (button), "option-menu");
69 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
71 style = gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu));
73 gtk_toolbar_set_style (toolbar, style);
74 gtk_widget_set_sensitive (option_menu, TRUE);
78 gtk_toolbar_unset_style (toolbar);
79 gtk_widget_set_sensitive (option_menu, FALSE);
84 change_toolbar_style (GtkWidget *option_menu, GtkWidget *toolbar)
86 GtkToolbarStyle style;
88 style = gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu));
89 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
93 set_visible_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
94 GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
96 GtkToolItem *tool_item;
99 gtk_tree_model_get (model, iter, 0, &tool_item, -1);
101 g_object_get (tool_item, "visible", &visible, NULL);
102 g_object_set (cell, "active", visible, NULL);
103 g_object_unref (tool_item);
107 visibile_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
112 GtkToolItem *tool_item;
115 path = gtk_tree_path_new_from_string (path_str);
116 gtk_tree_model_get_iter (model, &iter, path);
118 gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
119 g_object_get (tool_item, "visible", &visible, NULL);
120 g_object_set (tool_item, "visible", !visible, NULL);
121 g_object_unref (tool_item);
123 gtk_tree_model_row_changed (model, path, &iter);
124 gtk_tree_path_free (path);
128 set_expand_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
129 GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
131 GtkToolItem *tool_item;
133 gtk_tree_model_get (model, iter, 0, &tool_item, -1);
135 g_object_set (cell, "active", gtk_tool_item_get_expand (tool_item), NULL);
136 g_object_unref (tool_item);
140 expand_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
145 GtkToolItem *tool_item;
147 path = gtk_tree_path_new_from_string (path_str);
148 gtk_tree_model_get_iter (model, &iter, path);
150 gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
151 gtk_tool_item_set_expand (tool_item, !gtk_tool_item_get_expand (tool_item));
152 g_object_unref (tool_item);
154 gtk_tree_model_row_changed (model, path, &iter);
155 gtk_tree_path_free (path);
159 set_homogeneous_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
160 GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
162 GtkToolItem *tool_item;
164 gtk_tree_model_get (model, iter, 0, &tool_item, -1);
166 g_object_set (cell, "active", gtk_tool_item_get_homogeneous (tool_item), NULL);
167 g_object_unref (tool_item);
171 homogeneous_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
176 GtkToolItem *tool_item;
178 path = gtk_tree_path_new_from_string (path_str);
179 gtk_tree_model_get_iter (model, &iter, path);
181 gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
182 gtk_tool_item_set_homogeneous (tool_item, !gtk_tool_item_get_homogeneous (tool_item));
183 g_object_unref (tool_item);
185 gtk_tree_model_row_changed (model, path, &iter);
186 gtk_tree_path_free (path);
191 set_important_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
192 GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
194 GtkToolItem *tool_item;
196 gtk_tree_model_get (model, iter, 0, &tool_item, -1);
198 g_object_set (cell, "active", gtk_tool_item_get_is_important (tool_item), NULL);
199 g_object_unref (tool_item);
203 important_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
208 GtkToolItem *tool_item;
210 path = gtk_tree_path_new_from_string (path_str);
211 gtk_tree_model_get_iter (model, &iter, path);
213 gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
214 gtk_tool_item_set_is_important (tool_item, !gtk_tool_item_get_is_important (tool_item));
215 g_object_unref (tool_item);
217 gtk_tree_model_row_changed (model, path, &iter);
218 gtk_tree_path_free (path);
221 static GtkListStore *
222 create_items_list (GtkWidget **tree_view_p)
224 GtkWidget *tree_view;
225 GtkListStore *list_store;
226 GtkCellRenderer *cell;
228 list_store = gtk_list_store_new (2, GTK_TYPE_TOOL_ITEM, G_TYPE_STRING);
230 tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
232 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
234 gtk_cell_renderer_text_new (),
237 cell = gtk_cell_renderer_toggle_new ();
238 g_signal_connect (cell, "toggled", G_CALLBACK (visibile_toggled),
240 gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
243 set_visible_func, NULL, NULL);
245 cell = gtk_cell_renderer_toggle_new ();
246 g_signal_connect (cell, "toggled", G_CALLBACK (expand_toggled),
248 gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
251 set_expand_func, NULL, NULL);
253 cell = gtk_cell_renderer_toggle_new ();
254 g_signal_connect (cell, "toggled", G_CALLBACK (homogeneous_toggled),
256 gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
259 set_homogeneous_func, NULL,NULL);
261 cell = gtk_cell_renderer_toggle_new ();
262 g_signal_connect (cell, "toggled", G_CALLBACK (important_toggled),
264 gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
267 set_important_func, NULL,NULL);
269 g_object_unref (list_store);
271 *tree_view_p = tree_view;
277 add_item_to_list (GtkListStore *store, GtkToolItem *item, const gchar *text)
281 gtk_list_store_append (store, &iter);
282 gtk_list_store_set (store, &iter,
290 bold_toggled (GtkToggleToolButton *button)
292 g_message ("Bold toggled (active=%d)",
293 gtk_toggle_tool_button_get_active (button));
297 set_icon_size_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
299 GtkWidget *option_menu;
302 option_menu = g_object_get_data (G_OBJECT (button), "option-menu");
304 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
306 if (gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu)) == 0)
307 icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
309 icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
311 gtk_toolbar_set_icon_size (toolbar, icon_size);
312 gtk_widget_set_sensitive (option_menu, TRUE);
316 gtk_toolbar_unset_icon_size (toolbar);
317 gtk_widget_set_sensitive (option_menu, FALSE);
322 icon_size_history_changed (GtkComboBox *menu, GtkToolbar *toolbar)
326 if (gtk_combo_box_get_active (menu) == 0)
327 icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
329 icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
331 gtk_toolbar_set_icon_size (toolbar, icon_size);
335 toolbar_drag_drop (GtkWidget *widget, GdkDragContext *context,
336 gint x, gint y, guint time, GtkWidget *label)
340 g_snprintf(buf, sizeof(buf), "%d",
341 gtk_toolbar_get_drop_index (GTK_TOOLBAR (widget), x, y));
342 gtk_label_set_label (GTK_LABEL (label), buf);
347 static GtkTargetEntry target_table[] = {
348 { "application/x-toolbar-item", 0, 0 }
352 make_prop_editor (GObject *object)
354 GtkWidget *prop_editor = create_prop_editor (object, 0);
355 gtk_widget_show (prop_editor);
360 rtl_toggled (GtkCheckButton *check)
362 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
363 gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
365 gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR);
375 position_function (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
377 /* Do not do this in your own code */
379 MenuPositionData *position_data = user_data;
382 *x = position_data->x;
385 *y = position_data->y;
392 popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button_number)
394 MenuPositionData position_data;
396 GtkMenu *menu = GTK_MENU (gtk_menu_new ());
399 for (i = 0; i < 5; i++)
402 gchar *label = g_strdup_printf ("Item _%d", i);
403 item = gtk_menu_item_new_with_mnemonic (label);
404 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
406 gtk_widget_show_all (GTK_WIDGET (menu));
408 if (button_number != -1)
413 gtk_menu_popup (menu, NULL, NULL, position_function,
414 &position_data, button_number, gtk_get_current_event_time());
417 gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
422 static GtkToolItem *drag_item = NULL;
425 toolbar_drag_motion (GtkToolbar *toolbar,
426 GdkDragContext *context,
436 drag_item = gtk_tool_button_new (NULL, "A quite long button");
437 g_object_ref_sink (g_object_ref (drag_item));
440 gdk_drag_status (context, GDK_ACTION_MOVE, time);
442 index = gtk_toolbar_get_drop_index (toolbar, x, y);
444 gtk_toolbar_set_drop_highlight_item (toolbar, drag_item, index);
450 toolbar_drag_leave (GtkToolbar *toolbar,
451 GdkDragContext *context,
457 g_object_unref (drag_item);
461 gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0);
465 timeout_cb (GtkWidget *widget)
467 static gboolean sensitive = TRUE;
469 sensitive = !sensitive;
471 gtk_widget_set_sensitive (widget, sensitive);
477 timeout_cb1 (GtkWidget *widget)
479 static gboolean sensitive = TRUE;
480 sensitive = !sensitive;
481 gtk_widget_set_sensitive (widget, sensitive);
486 main (gint argc, gchar **argv)
488 GtkWidget *window, *toolbar, *table, *treeview, *scrolled_window;
489 GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
491 static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
492 "both (horizontal)" };
502 gtk_init (&argc, &argv);
504 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
506 g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
508 table = gtk_table_new (4, 2, FALSE);
509 gtk_container_add (GTK_CONTAINER (window), table);
511 toolbar = gtk_toolbar_new ();
512 gtk_table_attach (GTK_TABLE (table), toolbar,
513 0,2, 0,1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
515 hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
516 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5);
517 gtk_table_attach (GTK_TABLE (table), hbox1,
518 1,2, 1,2, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
520 hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
521 gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
522 gtk_table_attach (GTK_TABLE (table), hbox2,
523 1,2, 2,3, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
525 checkbox = gtk_check_button_new_with_mnemonic("_Vertical");
526 gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
527 g_signal_connect (checkbox, "toggled",
528 G_CALLBACK (change_orientation), toolbar);
530 checkbox = gtk_check_button_new_with_mnemonic("_Show Arrow");
531 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
532 gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
533 g_signal_connect (checkbox, "toggled",
534 G_CALLBACK (change_show_arrow), toolbar);
536 checkbox = gtk_check_button_new_with_mnemonic("_Set Toolbar Style:");
537 g_signal_connect (checkbox, "toggled", G_CALLBACK (set_toolbar_style_toggled), toolbar);
538 gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
540 option_menu = gtk_combo_box_text_new ();
541 gtk_widget_set_sensitive (option_menu, FALSE);
542 g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
544 for (i = 0; i < G_N_ELEMENTS (toolbar_styles); i++)
545 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), toolbar_styles[i]);
546 gtk_combo_box_set_active (GTK_COMBO_BOX (option_menu),
547 gtk_toolbar_get_style (GTK_TOOLBAR (toolbar)));
548 gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
549 g_signal_connect (option_menu, "changed",
550 G_CALLBACK (change_toolbar_style), toolbar);
552 checkbox = gtk_check_button_new_with_mnemonic("_Set Icon Size:");
553 g_signal_connect (checkbox, "toggled", G_CALLBACK (set_icon_size_toggled), toolbar);
554 gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
556 option_menu = gtk_combo_box_text_new ();
557 g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
558 gtk_widget_set_sensitive (option_menu, FALSE);
559 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), "small toolbar");
560 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), "large toolbar");
562 gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
563 g_signal_connect (option_menu, "changed",
564 G_CALLBACK (icon_size_history_changed), toolbar);
566 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
567 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
568 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
569 gtk_table_attach (GTK_TABLE (table), scrolled_window,
570 1,2, 3,4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
572 store = create_items_list (&treeview);
573 gtk_container_add (GTK_CONTAINER (scrolled_window), treeview);
575 item = gtk_tool_button_new_from_stock (GTK_STOCK_NEW);
576 gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Custom label");
577 gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), NULL);
578 add_item_to_list (store, item, "New");
579 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
580 gdk_threads_add_timeout (3000, (GSourceFunc) timeout_cb, item);
581 gtk_tool_item_set_expand (item, TRUE);
583 menu = gtk_menu_new ();
584 for (i = 0; i < 20; i++)
587 text = g_strdup_printf ("Menuitem %d", i);
588 menuitem = gtk_menu_item_new_with_label (text);
590 gtk_widget_show (menuitem);
591 gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
594 item = gtk_menu_tool_button_new_from_stock (GTK_STOCK_OPEN);
595 gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (item), menu);
596 add_item_to_list (store, item, "Open");
597 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
598 gdk_threads_add_timeout (3000, (GSourceFunc) timeout_cb1, item);
600 menu = gtk_menu_new ();
601 for (i = 0; i < 20; i++)
604 text = g_strdup_printf ("A%d", i);
605 menuitem = gtk_menu_item_new_with_label (text);
607 gtk_widget_show (menuitem);
608 gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
611 item = gtk_menu_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
612 gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (item), menu);
613 add_item_to_list (store, item, "BackWithHistory");
614 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
616 item = gtk_separator_tool_item_new ();
617 add_item_to_list (store, item, "-----");
618 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
620 image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
621 item = gtk_tool_item_new ();
622 gtk_widget_show (image);
623 gtk_container_add (GTK_CONTAINER (item), image);
624 add_item_to_list (store, item, "(Custom Item)");
625 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
627 item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
628 add_item_to_list (store, item, "Back");
629 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
631 item = gtk_separator_tool_item_new ();
632 add_item_to_list (store, item, "-----");
633 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
635 item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
636 add_item_to_list (store, item, "Forward");
637 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
639 item = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_BOLD);
640 g_signal_connect (item, "toggled", G_CALLBACK (bold_toggled), NULL);
641 add_item_to_list (store, item, "Bold");
642 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
643 gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
645 item = gtk_separator_tool_item_new ();
646 add_item_to_list (store, item, "-----");
647 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
648 gtk_tool_item_set_expand (item, TRUE);
649 gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
650 g_assert (gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), 0) != 0);
652 item = gtk_radio_tool_button_new_from_stock (NULL, GTK_STOCK_JUSTIFY_LEFT);
653 group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
654 add_item_to_list (store, item, "Left");
655 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
658 item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_CENTER);
659 make_prop_editor (G_OBJECT (item));
661 group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
662 add_item_to_list (store, item, "Center");
663 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
665 item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_RIGHT);
666 add_item_to_list (store, item, "Right");
667 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
669 item = gtk_tool_button_new (gtk_image_new_from_file ("apple-red.png"), "_Apple");
670 add_item_to_list (store, item, "Apple");
671 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
672 gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (item), TRUE);
674 gicon = g_content_type_get_icon ("video/ogg");
675 image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_LARGE_TOOLBAR);
676 g_object_unref (gicon);
677 item = gtk_tool_button_new (image, "Video");
678 add_item_to_list (store, item, "Video");
679 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
681 image = gtk_image_new_from_icon_name ("utilities-terminal", GTK_ICON_SIZE_LARGE_TOOLBAR);
682 item = gtk_tool_button_new (image, "Terminal");
683 add_item_to_list (store, item, "Terminal");
684 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
686 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
687 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
688 gtk_table_attach (GTK_TABLE (table), hbox,
689 1,2, 4,5, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
691 button = gtk_button_new_with_label ("Drag me to the toolbar");
692 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
694 label = gtk_label_new ("Drop index:");
695 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
697 label = gtk_label_new ("");
698 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
700 checkbox = gtk_check_button_new_with_mnemonic("_Right to left");
701 if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
702 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
704 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), FALSE);
705 g_signal_connect (checkbox, "toggled", G_CALLBACK (rtl_toggled), NULL);
707 gtk_box_pack_end (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
709 gtk_drag_source_set (button, GDK_BUTTON1_MASK,
710 target_table, G_N_ELEMENTS (target_table),
712 gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
713 target_table, G_N_ELEMENTS (target_table),
715 g_signal_connect (toolbar, "drag_motion",
716 G_CALLBACK (toolbar_drag_motion), NULL);
717 g_signal_connect (toolbar, "drag_leave",
718 G_CALLBACK (toolbar_drag_leave), NULL);
719 g_signal_connect (toolbar, "drag_drop",
720 G_CALLBACK (toolbar_drag_drop), label);
722 gtk_widget_show_all (window);
724 make_prop_editor (G_OBJECT (toolbar));
726 g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
728 g_signal_connect (toolbar, "popup_context_menu", G_CALLBACK (popup_context_menu), NULL);