~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/browser/gtk/tests/TestGtkEmbedSocket.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The contents of this file are subject to the Mozilla Public
 
3
 * License Version 1.1 (the "License"); you may not use this file
 
4
 * except in compliance with the License. You may obtain a copy of
 
5
 * the License at http://www.mozilla.org/MPL/
 
6
 * 
 
7
 * Software distributed under the License is distributed on an "AS
 
8
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 * implied. See the License for the specific language governing
 
10
 * rights and limitations under the License.
 
11
 * 
 
12
 * The Original Code is mozilla.org code.
 
13
 * 
 
14
 * The Initial Developer of the Original Code is Christopher Blizzard.
 
15
 * Portions created by Christopher Blizzard are Copyright (C)
 
16
 * Christopher Blizzard.  All Rights Reserved.
 
17
 * 
 
18
 * Contributor(s):
 
19
 *   Christopher Blizzard <blizzard@mozilla.org>
 
20
 */
 
21
 
 
22
#include <gtk/gtk.h>
 
23
#include <gdk/gdkx.h>
 
24
#include <stdio.h>
 
25
#include <sys/types.h>
 
26
#include <unistd.h>
 
27
 
 
28
GtkWidget *toplevel_window = 0;
 
29
GtkWidget *button = 0;
 
30
GtkWidget *vbox = 0;
 
31
GtkWidget *gtk_socket = 0;
 
32
 
 
33
void
 
34
insert_mozilla(gpointer data);
 
35
 
 
36
int
 
37
main(int argc, char **argv)
 
38
{
 
39
  gtk_init(&argc, &argv);
 
40
 
 
41
  toplevel_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
42
 
 
43
  gtk_signal_connect(GTK_OBJECT(toplevel_window), "destroy",
 
44
                     (GtkSignalFunc) gtk_exit, NULL);
 
45
 
 
46
  vbox = gtk_vbox_new(FALSE, 0);
 
47
  gtk_container_add(GTK_CONTAINER(toplevel_window), vbox);
 
48
  gtk_widget_show(vbox);
 
49
 
 
50
  button = gtk_button_new_with_label("Insert Mozilla");
 
51
 
 
52
  gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
53
  gtk_widget_show(button);
 
54
 
 
55
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
 
56
                     GTK_SIGNAL_FUNC(insert_mozilla), NULL);
 
57
 
 
58
  gtk_widget_show(toplevel_window);
 
59
 
 
60
  gtk_main();
 
61
 
 
62
  return 0;
 
63
}
 
64
 
 
65
void
 
66
insert_mozilla(gpointer data)
 
67
{
 
68
  char buffer[20];
 
69
  int pid;
 
70
 
 
71
  if (gtk_socket)
 
72
    return;
 
73
 
 
74
  gtk_socket = gtk_socket_new();
 
75
  gtk_box_pack_start(GTK_BOX(vbox), gtk_socket, TRUE, TRUE, 0);
 
76
  gtk_widget_show(gtk_socket);
 
77
 
 
78
  sprintf(buffer, "%#lx", GDK_WINDOW_XWINDOW(gtk_socket->window));
 
79
 
 
80
  gdk_flush();
 
81
 
 
82
  if ((pid = fork()) == 0) { /* child */
 
83
    execl("./TestGtkEmbedChild", "./TestGtkEmbedChild", buffer, NULL);
 
84
    fprintf(stderr, "can't exec child\n");
 
85
    _exit(1);
 
86
  }
 
87
  else if (pid > 0) { /* parent */
 
88
  }
 
89
  else {
 
90
    fprintf(stderr, "Can't fork.\n");
 
91
  }
 
92
}