static guint g_io_win32_fd_add_watch (GIOChannel *channel, gint priority, GIOCondition condition, GIOFunc func, gpointer user_data, GDestroyNotify notify) { GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; watch->channel = channel; g_io_channel_ref (channel); watch->callback = func; watch->condition = condition; /* This probably does not work, except for CONIN$. */ watch->pollfd.fd = _get_osfhandle (win32_channel->fd); watch->pollfd.events = condition; g_main_add_poll (&watch->pollfd, priority); return g_source_add (priority, TRUE, &win32_watch_fd_funcs, watch, user_data, notify); }
static guint g_io_win32_msg_add_watch (GIOChannel *channel, gint priority, GIOCondition condition, GIOFunc func, gpointer user_data, GDestroyNotify notify) { GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; watch->channel = channel; g_io_channel_ref (channel); watch->callback = func; watch->condition = condition; watch->pollfd.fd = G_WIN32_MSG_HANDLE; watch->pollfd.events = condition; g_main_add_poll (&watch->pollfd, priority); return g_source_add (priority, TRUE, &win32_watch_msg_funcs, watch, user_data, notify); }
guint g_idle_add_full (gint priority, GSourceFunc function, gpointer data, GDestroyNotify notify) { g_return_val_if_fail (function != NULL, 0); return g_source_add (priority, FALSE, &idle_funcs, (gpointer) function, data, notify); }
guint g_timeout_add_full (gint priority, guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify) { GTimeoutData *timeout_data = g_new (GTimeoutData, 1); GTimeVal current_time; timeout_data->interval = interval; timeout_data->callback = function; g_get_current_time (¤t_time); g_timeout_set_expiration (timeout_data, ¤t_time); return g_source_add (priority, FALSE, &timeout_funcs, timeout_data, data, notify); }
static guint g_io_win32_pipe_add_watch (GIOChannel *channel, gint priority, GIOCondition condition, GIOFunc func, gpointer user_data, GDestroyNotify notify) { GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; gint i; /* g_print ("g_io_win32_pipe_add_watch: %d\n", win32_channel->fd); */ watch->channel = channel; g_io_channel_ref (channel); watch->callback = func; watch->condition = condition; watch->pollfd.fd = win32_channel->fd; watch->pollfd.events = condition; for (i = 0; i < n_watched_pipes; i++) if (watched_pipes[i].fd == -1) break; if (i == N_WATCHED_PIPES) g_error ("Too many watched pipes"); else { watched_pipes[i].fd = win32_channel->fd; watched_pipes[i].watch = watch; watched_pipes[i].channel = win32_channel; watched_pipes[i].user_data = user_data; n_watched_pipes = MAX (i + 1, n_watched_pipes); } return g_source_add (priority, FALSE, &win32_watch_pipe_funcs, watch, user_data, notify); }
static guint g_io_unix_add_watch (GIOChannel *channel, gint priority, GIOCondition condition, GIOFunc func, gpointer user_data, GDestroyNotify notify) { GIOUnixWatch *watch = g_new (GIOUnixWatch, 1); GIOUnixChannel *unix_channel = (GIOUnixChannel *)channel; watch->channel = channel; g_io_channel_ref (channel); watch->callback = func; watch->condition = condition; watch->pollfd.fd = unix_channel->fd; watch->pollfd.events = condition; g_main_add_poll (&watch->pollfd, priority); return g_source_add (priority, TRUE, &unix_watch_funcs, watch, user_data, notify); }
int mozembed_main(int argc, char **argv) { if (argc > 1) { if (strstr(argv[1], "-port=")) { int port = atoi(&(argv[1][6])); gMessenger.SetPort(port); gMessenger.CreateServerSocket(); } else if (strcmp(argv[1], "-test") == 0) { gTestMode = 1; } } if (!gTestMode && gMessenger.IsFailed()) { ReportError("Failed to create server socket!"); exit(1); } gtk_set_locale(); gtk_init(&argc, &argv); // force the startup code to be executed because we need to start // the profile in a different way gtk_moz_embed_push_startup(); if (NS_FAILED(InitializeProfile())) { ReportError("Failed to initialize profile!"); exit(1); } gMsgLock = PR_NewLock(); if (!gTestMode) { PRThread *socketListenThread = PR_CreateThread(PR_USER_THREAD, PortListening, (void*)SocketMsgHandler, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); if (!socketListenThread) { ReportError("Failed to create socket listening thread!"); exit(1); } // add event source to process socket messages #ifdef MOZ_WIDGET_GTK g_source_add (GDK_PRIORITY_EVENTS, TRUE, &event_funcs, NULL, NULL, NULL); #endif #ifdef MOZ_WIDGET_GTK2 GSource *newsource = g_source_new(&event_funcs, sizeof(GSource)); g_source_attach(newsource, NULL); #endif } else { GtkBrowser *browser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME); // set our minimum size gtk_widget_set_usize(browser->mozEmbed, 400, 400); set_browser_visibility(browser, TRUE); } // get the singleton object and hook up to its new window callback // so we can create orphaned windows. GtkMozEmbedSingle *single; single = gtk_moz_embed_single_get(); if (!single) { ReportError("Failed to get singleton embed object!"); exit(1); } gtk_signal_connect(GTK_OBJECT(single), "new_window_orphan", GTK_SIGNAL_FUNC(new_window_orphan_cb), NULL); gtk_main(); gtk_moz_embed_pop_startup(); PR_DestroyLock(gMsgLock); return 0; }