]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkplug.c
Change FSF Address
[~andy/gtk] / gtk / gtkplug.c
index 8cb9a4e1839620012a944f83c991d27a2d7e0392..d584b7ff89b6dea3452b05e61c9fe98985f1450f 100644 (file)
@@ -12,8 +12,7 @@
  * 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>
  */
 
@@ -180,6 +182,8 @@ gtk_plug_class_init (GtkPlugClass *class)
 
   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;
@@ -662,11 +666,8 @@ gtk_plug_finalize (GObject *object)
   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);
 }
 
@@ -934,15 +935,17 @@ gtk_plug_filter_func (GdkXEvent *gdk_xevent,
                  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)
@@ -1127,14 +1130,14 @@ gtk_plug_map (GtkWidget *widget)
       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);
 
@@ -1153,6 +1156,7 @@ gtk_plug_unmap (GtkWidget *widget)
     {
       GtkPlug *plug = GTK_PLUG (widget);
       GdkWindow *window;
+      GtkWidget *child;
 
       window = gtk_widget_get_window (widget);
 
@@ -1160,6 +1164,10 @@ gtk_plug_unmap (GtkWidget *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,
@@ -1341,7 +1349,7 @@ gtk_plug_keys_changed (GtkWindow *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);
     }
 }