X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=tests%2Ftestsocket_common.c;h=c93f1e27978e268d9a2ee074576150a1b420fabe;hb=9d0febc9a64a5bfb0fcfc3a88de4757f6c1ff090;hp=6d374de98ea62309fd58be18b8d417088a080bd0;hpb=06e735a652a9aefc787c696b44bfcc666ed61ef2;p=~andy%2Fgtk diff --git a/tests/testsocket_common.c b/tests/testsocket_common.c index 6d374de98..c93f1e279 100644 --- a/tests/testsocket_common.c +++ b/tests/testsocket_common.c @@ -13,16 +13,16 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ -#undef GTK_DISABLE_DEPRECATED - -#include -#include "x11/gdkx.h" +#include "config.h" #include +#if defined (GDK_WINDOWING_X11) +#include +#elif defined (GDK_WINDOWING_WIN32) +#include "win32/gdkwin32.h" +#endif enum { @@ -56,17 +56,6 @@ print_hello (GtkWidget *w, } } -static GtkItemFactoryEntry menu_items[] = { - { "/_File", NULL, NULL, 0, "" }, - { "/File/_New", "N", print_hello, ACTION_FILE_NEW, "" }, - { "/File/_Open", "O", print_hello, ACTION_FILE_OPEN, "" }, - { "/File/sep1", NULL, NULL, 0, "" }, - { "/File/Quit", "Q", gtk_main_quit, 0, "" }, - { "/O_K", "K",print_hello, ACTION_OK, "" }, - { "/_Help", NULL, NULL, 0, "" }, - { "/_Help/About", NULL, print_hello, ACTION_HELP_ABOUT, "" }, -}; - static void remove_buttons (GtkWidget *widget, GtkWidget *other_button) { @@ -93,7 +82,7 @@ blink (GtkWidget *widget, if (!blink_timeout) { - blink_timeout = g_timeout_add (1000, blink_cb, window); + blink_timeout = gdk_threads_add_timeout (1000, blink_cb, window); gtk_widget_hide (window); g_object_set_data (G_OBJECT (window), "blink", GUINT_TO_POINTER (blink_timeout)); @@ -141,25 +130,25 @@ add_buttons (GtkWidget *widget, GtkWidget *box) static GtkWidget * create_combo (void) { - GList *cbitems; - GtkCombo *combo; - - cbitems = NULL; - cbitems = g_list_append (cbitems, "item0"); - cbitems = g_list_append (cbitems, "item1 item1"); - cbitems = g_list_append (cbitems, "item2 item2 item2"); - cbitems = g_list_append (cbitems, "item3 item3 item3 item3"); - cbitems = g_list_append (cbitems, "item4 item4 item4 item4 item4"); - cbitems = g_list_append (cbitems, "item5 item5 item5 item5 item5 item5"); - cbitems = g_list_append (cbitems, "item6 item6 item6 item6 item6"); - cbitems = g_list_append (cbitems, "item7 item7 item7 item7"); - cbitems = g_list_append (cbitems, "item8 item8 item8"); - cbitems = g_list_append (cbitems, "item9 item9"); - - combo = GTK_COMBO (gtk_combo_new ()); - gtk_combo_set_popdown_strings (combo, cbitems); - gtk_entry_set_text (GTK_ENTRY (combo->entry), "hello world"); - gtk_editable_select_region (GTK_EDITABLE (combo->entry), 0, -1); + GtkComboBoxText *combo; + GtkWidget *entry; + + combo = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ()); + + gtk_combo_box_text_append_text (combo, "item0"); + gtk_combo_box_text_append_text (combo, "item1 item1"); + gtk_combo_box_text_append_text (combo, "item2 item2 item2"); + gtk_combo_box_text_append_text (combo, "item3 item3 item3 item3"); + gtk_combo_box_text_append_text (combo, "item4 item4 item4 item4 item4"); + gtk_combo_box_text_append_text (combo, "item5 item5 item5 item5 item5 item5"); + gtk_combo_box_text_append_text (combo, "item6 item6 item6 item6 item6"); + gtk_combo_box_text_append_text (combo, "item7 item7 item7 item7"); + gtk_combo_box_text_append_text (combo, "item8 item8 item8"); + gtk_combo_box_text_append_text (combo, "item9 item9"); + + entry = gtk_bin_get_child (GTK_BIN (combo)); + gtk_entry_set_text (GTK_ENTRY (entry), "hello world"); + gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); return GTK_WIDGET (combo); } @@ -167,19 +156,39 @@ create_combo (void) static GtkWidget * create_menubar (GtkWindow *window) { - GtkItemFactory *item_factory; GtkAccelGroup *accel_group=NULL; GtkWidget *menubar; - + GtkWidget *menuitem; + GtkWidget *menu; + accel_group = gtk_accel_group_new (); - item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "
", - accel_group); - gtk_item_factory_create_items (item_factory, - G_N_ELEMENTS (menu_items), - menu_items, NULL); - gtk_window_add_accel_group (window, accel_group); - menubar = gtk_item_factory_get_widget (item_factory, "
"); + + menubar = gtk_menu_bar_new (); + + menuitem = gtk_menu_item_new_with_mnemonic ("_File"); + gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); + menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL); + g_signal_connect (menuitem, "activate", G_CALLBACK (print_hello), window); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL); + g_signal_connect (menuitem, "activate", G_CALLBACK (gtk_main_quit), window); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + + menuitem = gtk_menu_item_new_with_mnemonic ("O_K"); + gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); + + menuitem = gtk_menu_item_new_with_mnemonic ("_Help"); + gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem); + menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL); + g_signal_connect (menuitem, "activate", G_CALLBACK (print_hello), window); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); return menubar; } @@ -187,12 +196,12 @@ create_menubar (GtkWindow *window) static GtkWidget * create_combo_box (void) { - GtkComboBox *combo_box = GTK_COMBO_BOX (gtk_combo_box_new_text ()); + GtkComboBoxText *combo_box = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ()); - gtk_combo_box_append_text (combo_box, "This"); - gtk_combo_box_append_text (combo_box, "Is"); - gtk_combo_box_append_text (combo_box, "A"); - gtk_combo_box_append_text (combo_box, "ComboBox"); + gtk_combo_box_text_append_text (combo_box, "This"); + gtk_combo_box_text_append_text (combo_box, "Is"); + gtk_combo_box_text_append_text (combo_box, "A"); + gtk_combo_box_text_append_text (combo_box, "ComboBox"); return GTK_WIDGET (combo_box); } @@ -206,7 +215,8 @@ create_content (GtkWindow *window, gboolean local) frame = gtk_frame_new (local? "Local" : "Remote"); gtk_container_set_border_width (GTK_CONTAINER (frame), 3); - vbox = gtk_vbox_new (TRUE, 0); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE); gtk_container_set_border_width (GTK_CONTAINER (vbox), 3); gtk_container_add (GTK_CONTAINER (frame), vbox); @@ -263,8 +273,14 @@ create_child_plug (guint32 xid, gtk_widget_show_all (window); - if (GTK_WIDGET_REALIZED (window)) - return GDK_WINDOW_XID (window->window); + if (gtk_widget_get_realized (window)) +#if defined (GDK_WINDOWING_X11) + return GDK_WINDOW_XID (gtk_widget_get_window (window)); +#elif defined (GDK_WINDOWING_WIN32) + return (guint32) GDK_WINDOW_HWND (gtk_widget_get_window (window)); +#elif defined (GDK_WINDOWING_BROADWAY) + return (guint32) 0; /* Child windows not supported */ +#endif else return 0; }