本文整理汇总了C++中GTK_SOCKET函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_SOCKET函数的具体用法?C++ GTK_SOCKET怎么用?C++ GTK_SOCKET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_SOCKET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_xtbin_realize
static void
gtk_xtbin_realize (GtkWidget *widget)
{
GtkXtBin *xtbin;
GtkAllocation allocation = { 0, 0, 200, 200 };
#if GTK_CHECK_VERSION(2, 18, 0)
GtkAllocation widget_allocation;
#endif
#ifdef DEBUG_XTBIN
printf("gtk_xtbin_realize()\n");
#endif
g_return_if_fail (GTK_IS_XTBIN (widget));
xtbin = GTK_XTBIN (widget);
/* caculate the allocation before realize */
#if GTK_CHECK_VERSION(2, 24, 0)
allocation.width = gdk_window_get_width(xtbin->parent_window);
allocation.height = gdk_window_get_height(xtbin->parent_window);
#else
gint x, y, w, h, d; /* geometry of window */
gdk_window_get_geometry(xtbin->parent_window, &x, &y, &w, &h, &d);
allocation.width = w;
allocation.height = h;
#endif
gtk_widget_size_allocate (widget, &allocation);
#ifdef DEBUG_XTBIN
printf("initial allocation %d %d %d %d\n", x, y, w, h);
#endif
#if GTK_CHECK_VERSION(2, 18, 0)
gtk_widget_get_allocation(widget, &widget_allocation);
xtbin->width = widget_allocation.width;
xtbin->height = widget_allocation.height;
#else
xtbin->width = widget->allocation.width;
xtbin->height = widget->allocation.height;
#endif
/* use GtkSocket's realize */
(*GTK_WIDGET_CLASS(parent_class)->realize)(widget);
/* create the Xt client widget */
xt_client_create(&(xtbin->xtclient),
gtk_socket_get_id(GTK_SOCKET(xtbin)),
xtbin->height,
xtbin->width);
xtbin->xtwindow = XtWindow(xtbin->xtclient.child_widget);
gdk_flush();
/* now that we have created the xt client, add it to the socket. */
gtk_socket_add_id(GTK_SOCKET(widget), xtbin->xtwindow);
}
示例2: awn_ua_alignment_add_id
GdkWindow *
awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window)
{
GdkWindow * plugwin;
AwnUAAlignmentPrivate *priv;
priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window);
plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket));
g_signal_connect (priv->socket,"plug-removed",
G_CALLBACK(awn_ua_alignment_plug_removed),self);
gtk_widget_realize (priv->socket);
gtk_widget_show_all (priv->socket);
return plugwin;
}
示例3: gnoclSocketCmd
/***f* socket/gnoclSocketCmd
* AUTHOR
* PGB
* SOURCE
*/
int gnoclSocketCmd ( ClientData data, Tcl_Interp *interp,
int objc, Tcl_Obj * const objv[] )
{
int ret;
GtkSocket *socket;
if ( gnoclParseOptions ( interp, objc, objv, socketOptions ) != TCL_OK )
{
gnoclClearOptions ( socketOptions );
return TCL_ERROR;
}
socket = GTK_SOCKET ( gtk_socket_new() );
gtk_widget_show ( GTK_WIDGET ( socket ) );
ret = gnoclSetOptions ( interp, socketOptions, G_OBJECT ( socket ), -1 );
if ( ret == TCL_OK )
ret = configure ( interp, socket, socketOptions );
gnoclClearOptions ( socketOptions );
if ( ret != TCL_OK )
{
gtk_widget_destroy ( GTK_WIDGET ( socket ) );
return TCL_ERROR;
}
return gnoclRegisterWidget ( interp, GTK_WIDGET ( socket ), socketFunc );
}
示例4: setup_new_socket_for_plug
void
setup_new_socket_for_plug(struct Gtkabber *gtkabber)
{
struct ContainerData *cd;
static int __id;
{
cd = malloc( sizeof *cd );
if (cd == NULL)
{
fprintf( stderr, "Can't malloc() *cd\n" );
exit( EXIT_FAILURE );
}
memset( cd, '\0', sizeof *cd );
}
cd->id = ++__id;
cd->socket = gtk_socket_new();
new_tab_page( gtkabber, GTK_WIDGET(cd->socket) );
cd->xwin_id = gtk_socket_get_id( GTK_SOCKET( cd->socket ) );
gtkabber->toplevel.next_socket_id = cd->xwin_id;
gtkabber->socket_list = g_list_append( gtkabber->socket_list,
(gpointer)cd );
}
示例5: g_strdup
UzblInstance::UzblInstance(const char* u, const char* mainfifo, GtkNotebook* n, GtkTreeRowReference* r)
{
//id = ID++;
url = g_strdup(u);
title = g_strdup("...");
/*sprintf(fifopath, "/tmp/uzbl_fifo_%s", fifo);
sprintf(sockpath, "/tmp/uzbl_socket_%s", fifo);*/
row = r;
notebook = n;
children = NULL;
socket = GTK_SOCKET(gtk_socket_new());
//gtk_widget_set_can_focus(GTK_WIDGET(socket), false);
gtk_notebook_append_page(notebook, GTK_WIDGET(socket), NULL);
//gtk_widget_show_all(GTK_WIDGET(notebook));
gtk_widget_show(GTK_WIDGET(socket));
int rn = rand();
sprintf(name, "%d", rn &0x7FFFFFFF);
char cmd[1024];
sprintf(cmd, "uzbl-browser tab %d %s %s \"%s\"",
gtk_socket_get_id(socket), name, mainfifo, u);
printf("%s\n", cmd);
g_spawn_command_line_async(cmd, NULL);
}
示例6: printf
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
{
if(aPluginInstance) {
nsresult rv;
PRBool val = PR_FALSE;
if(!mGtkSocket) {
if (CanGetValueFromPlugin(aPluginInstance))
rv = aPluginInstance->GetValue
((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &val);
}
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", val);
#endif
if(val) {
CreateXEmbedWindow();
}
if(mGtkSocket) {
// Make sure to resize and re-place the window if required
SetAllocation();
window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mGtkSocket));
}
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window);
#endif
aPluginInstance->SetWindow(this);
}
else if (mPluginInstance)
mPluginInstance->SetWindow(nsnull);
SetPluginInstance(aPluginInstance);
return NS_OK;
}
示例7: m_plugin
NetscapePluginX11::NetscapePluginX11(NetscapePlugin& plugin, Display* display, uint64_t windowID)
: m_plugin(plugin)
, m_pluginDisplay(display)
, m_windowID(windowID)
{
// It seems flash needs the socket to be in the same process,
// I guess it uses gdk_window_lookup(), so we create a new socket here
// containing a plug with the UI process socket embedded.
m_platformPluginWidget = gtk_plug_new(static_cast<Window>(windowID));
// Hide the GtkPlug on delete-event since we assume the widget is valid while the plugin is active.
// platformDestroy() will be called anyway right after the delete-event.
g_signal_connect(m_platformPluginWidget, "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), nullptr);
GtkWidget* socket = gtk_socket_new();
// Do not show the plug widget until the socket is connected.
g_signal_connect_swapped(socket, "plug-added", G_CALLBACK(gtk_widget_show), m_platformPluginWidget);
g_signal_connect(socket, "plug-removed", G_CALLBACK(socketPlugRemovedCallback), nullptr);
gtk_container_add(GTK_CONTAINER(m_platformPluginWidget), socket);
gtk_widget_show(socket);
Display* hostDisplay = x11HostDisplay();
m_npWindowID = gtk_socket_get_id(GTK_SOCKET(socket));
GdkWindow* window = gtk_widget_get_window(socket);
m_setWindowCallbackStruct.display = GDK_WINDOW_XDISPLAY(window);
m_setWindowCallbackStruct.visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window));
m_setWindowCallbackStruct.depth = gdk_visual_get_depth(gdk_window_get_visual(window));
m_setWindowCallbackStruct.colormap = XCreateColormap(hostDisplay, GDK_ROOT_WINDOW(), m_setWindowCallbackStruct.visual, AllocNone);
XFlush(hostDisplay);
}
示例8: egg_tray_manager_handle_dock_request
static void
egg_tray_manager_handle_dock_request (EggTrayManager *manager,
XClientMessageEvent *xevent)
{
GtkWidget *socket;
Window *window;
socket = gtk_socket_new ();
/* We need to set the child window here
* so that the client can call _get functions
* in the signal handler
*/
window = g_new (Window, 1);
*window = xevent->data.l[2];
g_object_set_data_full (G_OBJECT (socket),
"egg-tray-child-window",
window, g_free);
g_signal_emit (manager, manager_signals[TRAY_ICON_ADDED], 0,
socket);
/* Add the socket only if it's been attached */
if (GTK_IS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket))))
{
g_signal_connect (socket, "plug_removed",
G_CALLBACK (egg_tray_manager_plug_removed), manager);
gtk_socket_add_id (GTK_SOCKET (socket), xevent->data.l[2]);
g_hash_table_insert (manager->socket_table, GINT_TO_POINTER (xevent->data.l[2]), socket);
}
else
gtk_widget_destroy (socket);
}
示例9: gdk_window_lookup
nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() {
if(!mGtkSocket) {
GdkWindow *win = gdk_window_lookup((XID)window);
mGtkSocket = gtk_socket_new();
//attach the socket to the container widget
gtk_widget_set_parent_window(mGtkSocket, win);
// Make sure to handle the plug_removed signal. If we don't the
// socket will automatically be destroyed when the plug is
// removed, which means we're destroying it more than once.
// SYNTAX ERROR.
g_signal_connect(mGtkSocket, "plug_removed",
G_CALLBACK(plug_removed_cb), NULL);
gpointer user_data = NULL;
gdk_window_get_user_data(win, &user_data);
GtkContainer *container = GTK_CONTAINER(user_data);
gtk_container_add(container, mGtkSocket);
gtk_widget_realize(mGtkSocket);
// Resize before we show
SetAllocation();
gtk_widget_show(mGtkSocket);
gdk_flush();
window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mGtkSocket));
}
return NS_OK;
}
示例10: na_tray_manager_handle_dock_request
static void
na_tray_manager_handle_dock_request (NaTrayManager *manager,
XClientMessageEvent *xevent)
{
Window icon_window = xevent->data.l[2];
GtkWidget *child;
if (g_hash_table_lookup (manager->socket_table,
GINT_TO_POINTER (icon_window)))
{
/* We already got this notification earlier, ignore this one */
return;
}
child = na_tray_child_new (manager->screen, icon_window);
if (child == NULL) /* already gone or other error */
return;
g_signal_emit (manager, manager_signals[TRAY_ICON_ADDED], 0,
child);
/* If the child wasn't attached, then destroy it */
if (!GTK_IS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (child))))
{
gtk_widget_destroy (child);
return;
}
g_signal_connect (child, "plug_removed",
G_CALLBACK (na_tray_manager_plug_removed), manager);
gtk_socket_add_id (GTK_SOCKET (child), icon_window);
if (!GTK_SOCKET (child)->plug_window)
{
/* Embedding failed, we won't get a plug-removed signal */
g_signal_emit (manager, manager_signals[TRAY_ICON_REMOVED], 0, child);
gtk_widget_destroy (child);
return;
}
g_hash_table_insert (manager->socket_table,
GINT_TO_POINTER (icon_window), child);
gtk_widget_show (child);
}
示例11: NS_ASSERTION
nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() {
NS_ASSERTION(!mSocketWidget,"Already created a socket widget!");
GdkWindow *parent_win = gdk_window_lookup((XID)window);
mSocketWidget = gtk_socket_new();
//attach the socket to the container widget
gtk_widget_set_parent_window(mSocketWidget, parent_win);
// Make sure to handle the plug_removed signal. If we don't the
// socket will automatically be destroyed when the plug is
// removed, which means we're destroying it more than once.
// SYNTAX ERROR.
g_signal_connect(mSocketWidget, "plug_removed",
G_CALLBACK(plug_removed_cb), NULL);
g_signal_connect(mSocketWidget, "unrealize",
G_CALLBACK(socket_unrealize_cb), NULL);
g_signal_connect(mSocketWidget, "destroy",
G_CALLBACK(gtk_widget_destroyed), &mSocketWidget);
gpointer user_data = NULL;
gdk_window_get_user_data(parent_win, &user_data);
GtkContainer *container = GTK_CONTAINER(user_data);
gtk_container_add(container, mSocketWidget);
gtk_widget_realize(mSocketWidget);
// The GtkSocket has a visible window, but the plugin's XEmbed plug will
// cover this window. Normally GtkSockets let the X server paint their
// background and this would happen immediately (before the plug is
// created). Setting the background to None prevents the server from
// painting this window, avoiding flicker.
gdk_window_set_back_pixmap(mSocketWidget->window, NULL, FALSE);
// Resize before we show
SetAllocation();
gtk_widget_show(mSocketWidget);
gdk_flush();
window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget));
// Fill out the ws_info structure.
// (The windowless case is done in nsObjectFrame.cpp.)
GdkWindow *gdkWindow = gdk_window_lookup((XID)window);
if(!gdkWindow)
return NS_ERROR_FAILURE;
mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow);
mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow));
GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow);
mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual);
mWsInfo.depth = gdkVisual->depth;
return NS_OK;
}
示例12: printf
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance)
{
if (aPluginInstance) {
if (type == NPWindowTypeWindow) {
if (!mSocketWidget) {
nsresult rv;
PRBool needXEmbed = PR_FALSE;
rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
needXEmbed = PR_FALSE;
}
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed);
#endif
if (needXEmbed) {
rv = CreateXEmbedWindow();
}
else {
rv = CreateXtWindow();
}
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
}
if (!mSocketWidget) {
return NS_ERROR_FAILURE;
}
// Make sure to resize and re-place the window if required.
// Need to reset "window" each time as nsObjectFrame::DidReflow sets it
// to the ancestor window.
if (GTK_IS_XTBIN(mSocketWidget)) {
gtk_xtbin_resize(mSocketWidget, width, height);
// Point the NPWindow structures window to the actual X window
window = (void*)GTK_XTBIN(mSocketWidget)->xtwindow;
}
else { // XEmbed
SetAllocation();
window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget));
}
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window);
#endif
} // NPWindowTypeWindow
aPluginInstance->SetWindow(this);
}
else if (mPluginInstance)
mPluginInstance->SetWindow(nsnull);
SetPluginInstance(aPluginInstance);
return NS_OK;
}
示例13: GTK_SOCKET
void MCNativeLayerX11::doAttach()
{
if (m_socket == NULL)
{
// Create a new GTK socket to deal with the XEMBED protocol
GtkSocket *t_socket;
t_socket = GTK_SOCKET(gtk_socket_new());
// Create a new GTK window to hold the socket
MCRectangle t_rect;
t_rect = m_object->getrect();
m_child_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP));
gtk_widget_set_parent_window(GTK_WIDGET(m_child_window), getStackGdkWindow());
gtk_widget_realize(GTK_WIDGET(m_child_window));
gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(m_child_window)), getStackGdkWindow(), t_rect.x, t_rect.y);
// Add the socket to the window
gtk_container_add(GTK_CONTAINER(m_child_window), GTK_WIDGET(t_socket));
// The socket needs to be realised before going any further or any
// operations on it will fail.
gtk_widget_realize(GTK_WIDGET(t_socket));
// Show the socket (we'll control visibility at the window level)
gtk_widget_show(GTK_WIDGET(t_socket));
// Create an empty region to act as an input mask while in edit mode
m_input_shape = gdk_region_new();
// Retain a reference to the socket
m_socket = GTK_SOCKET(g_object_ref(G_OBJECT(t_socket)));
}
// Attach the X11 window to this socket
if (gtk_socket_get_plug_window(m_socket) == NULL)
gtk_socket_add_id(m_socket, m_widget_xid);
//fprintf(stderr, "XID: %u\n", gtk_socket_get_id(m_socket));
// Act as if there were a re-layer to put the widget in the right place
doRelayer();
doSetViewportGeometry(m_viewport_rect);
doSetGeometry(m_rect);
doSetVisible(ShouldShowLayer());
}
示例14: printf
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
{
if(aPluginInstance) {
if (type == nsPluginWindowType_Window) {
nsresult rv;
if(!mSocketWidget) {
PRBool needXEmbed = PR_FALSE;
if (CanGetValueFromPlugin(aPluginInstance)) {
rv = aPluginInstance->GetValue
((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &needXEmbed);
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed);
#endif
}
nsresult rv;
if(needXEmbed) {
#ifdef MOZ_COMPOSITED_PLUGINS
rv = CreateXCompositedWindow();
#else
rv = CreateXEmbedWindow();
#endif
}
else {
rv = CreateXtWindow();
}
if(NS_FAILED(rv))
return NS_ERROR_FAILURE;
}
if(!mSocketWidget)
return NS_ERROR_FAILURE;
// Make sure to resize and re-place the window if required.
// Need to reset "window" each time as nsObjectFrame::DidReflow sets it
// to the ancestor window.
if(GTK_IS_XTBIN(mSocketWidget)) {
gtk_xtbin_resize(mSocketWidget, width, height);
// Point the NPWindow structures window to the actual X window
window = (nsPluginPort *)GTK_XTBIN(mSocketWidget)->xtwindow;
}
else { // XEmbed
SetAllocation();
window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mSocketWidget));
}
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window);
#endif
} // nsPluginWindowType_Window
aPluginInstance->SetWindow(this);
}
else if (mPluginInstance)
mPluginInstance->SetWindow(nsnull);
SetPluginInstance(aPluginInstance);
return NS_OK;
}
示例15: main
int main(int argc, char **argv)
{
GtkWidget *window, *button, *textview, *vbox;
GtkWidget *socket, *plug, *socket_box;
unsigned long kb_xid;
gtk_init (&argc, &argv);
install_signal_handlers();
kb_xid = launch_keyboard();
if (!kb_xid)
{
perror ("### 'matchbox-keyboard --xid', failed to return valid window ID. ### ");
exit(-1);
}
/* Window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (widget_destroy), NULL);
/* Container and textview */
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
textview = gtk_text_view_new();
gtk_box_pack_start (GTK_BOX(vbox), textview, TRUE, TRUE, 2);
/* Socket ( XEMBED ) stuff */
socket_box = gtk_event_box_new ();
gtk_widget_show (socket_box);
socket = gtk_socket_new ();
gtk_container_add (GTK_CONTAINER (socket_box), socket);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET(socket_box), TRUE, TRUE, 0);
gtk_socket_add_id(GTK_SOCKET(socket), kb_xid);
/* FIXME: handle "plug-added" & "plug-removed" signals for socket */
gtk_widget_show_all (window);
gtk_main ();
return 0;
}