* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
*/
/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
* SECTION:gtkplug
* @Short_description: Toplevel for embedding into other processes
* @Title: GtkPlug
+ * @include: gtk/gtkx.h
* @See_also: #GtkSocket
*
- * Together with #GtkSocket, #GtkPlug provides the ability
- * to embed widgets from one process into another process
- * in a fashion that is transparent to the user. One
- * process creates a #GtkSocket widget and passes the
- * ID of that widget's window to the other process,
- * which then creates a #GtkPlug with that window ID.
- * Any widgets contained in the #GtkPlug then will appear
- * inside the first application's window.
+ * Together with #GtkSocket, #GtkPlug provides the ability to embed
+ * widgets from one process into another process in a fashion that is
+ * transparent to the user. One process creates a #GtkSocket widget
+ * and passes the ID of that widget's window to the other process,
+ * which then creates a #GtkPlug with that window ID. Any widgets
+ * contained in the #GtkPlug then will appear inside the first
+ * application's window.
*
* The communication between a #GtkSocket and a #GtkPlug follows the
* <ulink url="http://www.freedesktop.org/Standards/xembed-spec">XEmbed</ulink>
- * protocol. This protocol has also been implemented in other toolkits, e.g.
- * <application>Qt</application>, allowing the same level of integration
- * when embedding a <application>Qt</application> widget in GTK or vice versa.
+ * protocol. This protocol has also been implemented in other toolkits,
+ * e.g. <application>Qt</application>, allowing the same level of
+ * integration when embedding a <application>Qt</application> widget
+ * in GTK+ or vice versa.
*
* <note>
- * The #GtkPlug and #GtkSocket widgets are only available when GTK is
- * compiled for the X11 platform and %GDK_WINDOWING_X11 is defined.
- * They can only be used on a #GdkX11Display.
+ * The #GtkPlug and #GtkSocket widgets are only available when GTK+
+ * is compiled for the X11 platform and %GDK_WINDOWING_X11 is defined.
+ * They can only be used on a #GdkX11Display. To use #GtkPlug and
+ * #GtkSocket, you need to include the <filename>gtk/gtkx.h</filename>
+ * header.
* </note>
*/
widget_class->focus = gtk_plug_focus;
+ gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
+
container_class->check_resize = gtk_plug_check_resize;
window_class->set_focus = gtk_plug_set_focus;
/**
* gtk_plug_handle_modality_on:
- *
* @plug: a #GtkPlug
*
* Called from the GtkPlug backend when the corresponding socket has
/**
* gtk_plug_handle_modality_off:
- *
* @plug: a #GtkPlug
*
* Called from the GtkPlug backend when the corresponding socket has
g_signal_emit_by_name (socket_, "plug-added");
}
-/**
- * _gtk_plug_send_delete_event:
+/*
+ * gtk_plug_send_delete_event:
* @widget: a #GtkWidget
*
* Send a GDK_DELETE event to the @widget and destroy it if
* necessary. Internal GTK function, called from this file or the
* backend-specific GtkPlug implementation.
*/
-void
-_gtk_plug_send_delete_event (GtkWidget *widget)
+static void
+gtk_plug_send_delete_event (GtkWidget *widget)
{
GdkEvent *event = gdk_event_new (GDK_DELETE);
gtk_widget_destroy (GTK_WIDGET (socket_));
if (window)
- _gtk_plug_send_delete_event (widget);
+ gtk_plug_send_delete_event (widget);
g_object_unref (plug);
GtkPlugPrivate *priv = plug->priv;
if (priv->grabbed_keys)
- {
- g_hash_table_destroy (priv->grabbed_keys);
- priv->grabbed_keys = NULL;
- }
-
+ g_hash_table_destroy (priv->grabbed_keys);
+
G_OBJECT_CLASS (gtk_plug_parent_class)->finalize (object);
}
if (priv->socket_window != NULL)
{
- gdk_window_set_user_data (priv->socket_window, NULL);
+ gtk_widget_unregister_window (widget, priv->socket_window);
g_object_unref (priv->socket_window);
priv->socket_window = NULL;
/**
* gtk_plug_focus_first_last:
- *
* @plug: a #GtkPlug
* @direction: a direction
*
{
GtkWidget *widget = GTK_WIDGET (plug);
- gdk_window_set_user_data (priv->socket_window, NULL);
+ gtk_widget_unregister_window (widget, priv->socket_window);
g_object_unref (priv->socket_window);
priv->socket_window = NULL;
if (xre->parent == GDK_WINDOW_XID (gdk_screen_get_root_window (screen)))
{
GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: calling gtk_plug_send_delete_event()"));
- _gtk_plug_send_delete_event (widget);
+ gtk_plug_send_delete_event (widget);
g_object_notify (G_OBJECT (plug), "embedded");
}
break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */
}
- g_hash_table_iter_init (&iter, priv->grabbed_keys);
-
- while (g_hash_table_iter_next (&iter, &key, NULL))
+ if (priv->grabbed_keys)
{
- GrabbedKey *grabbed_key = key;
-
- _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_GRAB_KEY, 0,
- grabbed_key->accelerator_key,
- grabbed_key->accelerator_mods);
+ g_hash_table_iter_init (&iter, priv->grabbed_keys);
+ while (g_hash_table_iter_next (&iter, &key, NULL))
+ {
+ GrabbedKey *grabbed_key = key;
+
+ _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_GRAB_KEY, 0,
+ grabbed_key->accelerator_key,
+ grabbed_key->accelerator_mods);
+ }
}
if (!was_embedded)
gdk_event_set_device (event, keyboard);
keymap = gdk_keymap_get_for_display (display);
+
+ event->key.group = gdk_x11_keymap_get_group_for_state (keymap, xevent->xkey.state);
+ event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
+
gdk_keymap_translate_keyboard_state (keymap,
event->key.hardware_keycode,
event->key.state,
event->key.length = 0;
event->key.string = g_strdup ("");
- /* FIXME: These should be filled in properly */
- event->key.group = 0;
- event->key.is_modifier = FALSE;
-
return_val = GDK_FILTER_TRANSLATE;
}
}
gtk_widget_set_window (widget, gdk_window);
}
- gdk_window_set_user_data (gdk_window, window);
+ gtk_widget_register_window (widget, gdk_window);
gtk_style_context_set_background (gtk_widget_get_style_context (widget),
gdk_window);
-
- gdk_window_enable_synchronized_configure (gdk_window);
}
static void
GtkBin *bin = GTK_BIN (widget);
GtkPlug *plug = GTK_PLUG (widget);
GtkWidget *child;
-
+
gtk_widget_set_mapped (widget, TRUE);
child = gtk_bin_get_child (bin);
if (child != NULL &&
gtk_widget_get_visible (child) &&
- !gtk_widget_get_mapped (child))
- gtk_widget_map (child);
+ !gtk_widget_get_mapped (child))
+ gtk_widget_map (child);
xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), XEMBED_MAPPED);
{
GtkPlug *plug = GTK_PLUG (widget);
GdkWindow *window;
+ GtkWidget *child;
window = gtk_widget_get_window (widget);
gdk_window_hide (window);
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_unmap (child);
+
xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), 0);
gdk_synthesize_window_state (window,
if (old_grabbed_keys)
{
if (priv->socket_window)
- g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug);
+ g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug);
g_hash_table_destroy (old_grabbed_keys);
}
}