]> Pileus Git - ~andy/gtk/commitdiff
Add a singleton object that we can use to get notification when displays
authorOwen Taylor <otaylor@redhat.com>
Thu, 20 Jun 2002 23:29:19 +0000 (23:29 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 20 Jun 2002 23:29:19 +0000 (23:29 +0000)
Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>

        * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c
        gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c
        gdk/win32/gdkdisplay-win32.c: Add a singleton object that
        we can use to get notification when displays
        appear / disappear or the default display changes.

        gdk_set_default_display() => gdk_display_manager_set_default_display()
        gdk_list_displays() => gdk_display_manager_list_displays().
        (#85696)

        * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
        generation.

        * gdk/gdkintl.h: Add this.

        * gtk/gtkmain.c: Add gtk_parse_args() that initializes
        GTK+ without opening a display.

        * gtk/gtkmain.c: Set things up so if a module
        exports gtk_module_init() and gtk_module_display_init(),
        then we treat it as multihead aware, otherwise,
        we only initialize it after the default display is set.

21 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/gtk/tmpl/gtk-unused.sgml
docs/reference/gtk/tmpl/gtkfilesel.sgml
docs/reference/gtk/tmpl/gtkmain.sgml
docs/reference/gtk/tmpl/gtkstyle.sgml
gdk/Makefile.am
gdk/gdk.c
gdk/gdk.h
gdk/gdkdisplay.c
gdk/gdkintl.h [new file with mode: 0644]
gdk/gdkmarshalers.list [new file with mode: 0644]
gdk/win32/gdkdisplay-win32.c
gdk/x11/gdkdisplay-x11.c
gtk/gtkmain.c
gtk/gtkmain.h
po/POTFILES.in

index c537802d419ddb86833227f30800f5574a0897e7..52ac383c950db5ec7e5fe505e75e6cbf3b2eac38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c 
+       gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c 
+       gdk/win32/gdkdisplay-win32.c: Add a singleton object that
+       we can use to get notification when displays 
+       appear / disappear or the default display changes.
+
+       gdk_set_default_display() => gdk_display_manager_set_default_display()
+       gdk_list_displays() => gdk_display_manager_list_displays().
+       (#85696)
+
+       * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
+       generation.
+
+       * gdk/gdkintl.h: Add this.
+
+       * gtk/gtkmain.c: Add gtk_parse_args() that initializes
+       GTK+ without opening a display.
+
+       * gtk/gtkmain.c: Set things up so if a module
+       exports gtk_module_init() and gtk_module_display_init(), 
+       then we treat it as multihead aware, otherwise, 
+       we only initialize it after the default display is set.
+
 Thu Jun 20 15:53:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Erwann Chenede.
index c537802d419ddb86833227f30800f5574a0897e7..52ac383c950db5ec7e5fe505e75e6cbf3b2eac38 100644 (file)
@@ -1,3 +1,28 @@
+Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c 
+       gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c 
+       gdk/win32/gdkdisplay-win32.c: Add a singleton object that
+       we can use to get notification when displays 
+       appear / disappear or the default display changes.
+
+       gdk_set_default_display() => gdk_display_manager_set_default_display()
+       gdk_list_displays() => gdk_display_manager_list_displays().
+       (#85696)
+
+       * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
+       generation.
+
+       * gdk/gdkintl.h: Add this.
+
+       * gtk/gtkmain.c: Add gtk_parse_args() that initializes
+       GTK+ without opening a display.
+
+       * gtk/gtkmain.c: Set things up so if a module
+       exports gtk_module_init() and gtk_module_display_init(), 
+       then we treat it as multihead aware, otherwise, 
+       we only initialize it after the default display is set.
+
 Thu Jun 20 15:53:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Erwann Chenede.
index c537802d419ddb86833227f30800f5574a0897e7..52ac383c950db5ec7e5fe505e75e6cbf3b2eac38 100644 (file)
@@ -1,3 +1,28 @@
+Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c 
+       gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c 
+       gdk/win32/gdkdisplay-win32.c: Add a singleton object that
+       we can use to get notification when displays 
+       appear / disappear or the default display changes.
+
+       gdk_set_default_display() => gdk_display_manager_set_default_display()
+       gdk_list_displays() => gdk_display_manager_list_displays().
+       (#85696)
+
+       * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
+       generation.
+
+       * gdk/gdkintl.h: Add this.
+
+       * gtk/gtkmain.c: Add gtk_parse_args() that initializes
+       GTK+ without opening a display.
+
+       * gtk/gtkmain.c: Set things up so if a module
+       exports gtk_module_init() and gtk_module_display_init(), 
+       then we treat it as multihead aware, otherwise, 
+       we only initialize it after the default display is set.
+
 Thu Jun 20 15:53:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Erwann Chenede.
index c537802d419ddb86833227f30800f5574a0897e7..52ac383c950db5ec7e5fe505e75e6cbf3b2eac38 100644 (file)
@@ -1,3 +1,28 @@
+Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c 
+       gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c 
+       gdk/win32/gdkdisplay-win32.c: Add a singleton object that
+       we can use to get notification when displays 
+       appear / disappear or the default display changes.
+
+       gdk_set_default_display() => gdk_display_manager_set_default_display()
+       gdk_list_displays() => gdk_display_manager_list_displays().
+       (#85696)
+
+       * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
+       generation.
+
+       * gdk/gdkintl.h: Add this.
+
+       * gtk/gtkmain.c: Add gtk_parse_args() that initializes
+       GTK+ without opening a display.
+
+       * gtk/gtkmain.c: Set things up so if a module
+       exports gtk_module_init() and gtk_module_display_init(), 
+       then we treat it as multihead aware, otherwise, 
+       we only initialize it after the default display is set.
+
 Thu Jun 20 15:53:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Erwann Chenede.
index c537802d419ddb86833227f30800f5574a0897e7..52ac383c950db5ec7e5fe505e75e6cbf3b2eac38 100644 (file)
@@ -1,3 +1,28 @@
+Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c 
+       gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c 
+       gdk/win32/gdkdisplay-win32.c: Add a singleton object that
+       we can use to get notification when displays 
+       appear / disappear or the default display changes.
+
+       gdk_set_default_display() => gdk_display_manager_set_default_display()
+       gdk_list_displays() => gdk_display_manager_list_displays().
+       (#85696)
+
+       * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
+       generation.
+
+       * gdk/gdkintl.h: Add this.
+
+       * gtk/gtkmain.c: Add gtk_parse_args() that initializes
+       GTK+ without opening a display.
+
+       * gtk/gtkmain.c: Set things up so if a module
+       exports gtk_module_init() and gtk_module_display_init(), 
+       then we treat it as multihead aware, otherwise, 
+       we only initialize it after the default display is set.
+
 Thu Jun 20 15:53:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Erwann Chenede.
index c537802d419ddb86833227f30800f5574a0897e7..52ac383c950db5ec7e5fe505e75e6cbf3b2eac38 100644 (file)
@@ -1,3 +1,28 @@
+Thu Jun 20 16:49:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkdisplaymanager.[ch] gdk/gdk.[ch] gdk/gdkdisplay.c 
+       gdk/gdkinternals.h gdk/x11/gdkdisplay-x11.c 
+       gdk/win32/gdkdisplay-win32.c: Add a singleton object that
+       we can use to get notification when displays 
+       appear / disappear or the default display changes.
+
+       gdk_set_default_display() => gdk_display_manager_set_default_display()
+       gdk_list_displays() => gdk_display_manager_list_displays().
+       (#85696)
+
+       * gdk/Makefile.am gdk/gdkmarshalers.list: Add marshaler
+       generation.
+
+       * gdk/gdkintl.h: Add this.
+
+       * gtk/gtkmain.c: Add gtk_parse_args() that initializes
+       GTK+ without opening a display.
+
+       * gtk/gtkmain.c: Set things up so if a module
+       exports gtk_module_init() and gtk_module_display_init(), 
+       then we treat it as multihead aware, otherwise, 
+       we only initialize it after the default display is set.
+
 Thu Jun 20 15:53:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        Patch from Erwann Chenede.
index 143d5ddb62f5f3468d191df6ae9b578d2153021d..4d2776cfb71748c60a217c55565992e64f7fcb1d 100644 (file)
@@ -2830,6 +2830,15 @@ Creates a border around the arrows of a #GtkSpinButton. The type of border is de
 
 @Returns: 
 
+<!-- ##### FUNCTION gtk_style_get_font_for_display ##### -->
+<para>
+
+</para>
+
+@display: 
+@style: 
+@Returns: 
+
 <!-- ##### FUNCTION gtk_text_buffer_paste_primary ##### -->
 <para>
 
index 81760951282783c279a412882a84e3388b1ed8c1..a426eb3e74bcbf1ff782042f4410c22aef16a4c7 100644 (file)
@@ -135,8 +135,8 @@ Creates a new file selection dialog box. By default it will contain a #GtkCList
 <para>
 </para>
 
-@filesel:
-@filename:
+@filesel: 
+@filename: 
 
 
 <!-- ##### FUNCTION gtk_file_selection_get_filename ##### -->
index 9e96f7bb5afd52f434a4e03a27267c8cfe19af7e..885a793d997fb0886c10494a5776ed55c5cb72cc 100644 (file)
@@ -106,27 +106,15 @@ functions such as g_signal_connect().
 
 <!-- ##### FUNCTION gtk_init ##### -->
 <para>
-Call this function before using any other GTK+ functions in your GUI
-applications.  It will initialize everything needed to operate the toolkit and
-parses some standard command line options. <parameter>argc</parameter> and 
-<parameter>argv</parameter> are adjusted accordingly so your own code will 
-never see those standard arguments.
 </para>
 
 <note>
 <para>
-This function will terminate your program if it was unable to initialize 
-the GUI for some reason. If you want your program to fall back to a 
-textual interface you want to call gtk_init_check() instead.
 </para>
 </note>
 
-@argc: Address of the <parameter>argc</parameter> parameter of your 
-<function>main</function> function. Changed if any arguments were 
-handled.
-@argv: Address of the <parameter>argv</parameter> parameter of 
-<function>main()</function>. Any parameters understood by gtk_init() 
-are stripped before return.
+@argc: 
+@argv: 
 
 
 <!-- ##### FUNCTION gtk_init_check ##### -->
@@ -144,8 +132,7 @@ with the user - for example a curses or command line interface.
 <function>main()</function> function.
 @argv: A reference to the <parameter>argv</parameter> of the 
 <function>main()</function> function.
-@Returns: %TRUE if the GUI has been successfully initialized, 
-%FALSE otherwise.
+@Returns: 
 
 
 <!-- ##### FUNCTION gtk_exit ##### -->
index 0275f4ef3a516b285918cab52a8c066b3bce7c97..2f2fb10f64a72b497def77f1c0ee37c76604ae02 100644 (file)
@@ -179,16 +179,6 @@ Returns whether the style is attached to a window.
 @Returns: 
 
 
-<!-- ##### FUNCTION gtk_style_get_font_for_display ##### -->
-<para>
-
-</para>
-
-@display: 
-@style: 
-@Returns: 
-
-
 <!-- ##### FUNCTION gtk_style_set_font ##### -->
 <para>
 
index 5b89251424f0b6316c7fb526fb6a121747e19c56..8881a31244bd03481db72bf72cfc5bb05cb8ab70 100644 (file)
@@ -6,6 +6,7 @@ DIST_SUBDIRS=linux-fb win32 x11
 EXTRA_DIST =                   \
        gdkconfig.h.win32       \
        gdk.def                 \
+       gdkmarshalers.list      \
        makefile.mingw          \
        makefile.mingw.in       \
        makeenums.pl            \
@@ -86,32 +87,33 @@ LDFLAGS = @STRIP_BEGIN@                                             \
 #
 # Note: files added here may need to be be propagated to gdk_headers in gtk/Makefile.am
 #
-gdk_public_h_sources = @STRIP_BEGIN@ \
-       gdk.h           \
-       gdkcolor.h      \
-       gdkcursor.h     \
-       gdkdnd.h        \
-       gdkdrawable.h   \
-       gdkevents.h     \
-       gdkfont.h       \
-       gdkgc.h         \
-       gdkkeysyms.h    \
-       gdki18n.h       \
-       gdkimage.h      \
-       gdkinput.h      \
-       gdkkeys.h       \
-       gdkpango.h      \
-       gdkpixbuf.h     \
-       gdkpixmap.h     \
-       gdkproperty.h   \
-       gdkregion.h     \
-       gdkrgb.h        \
-       gdkselection.h  \
-       gdktypes.h      \
-       gdkvisual.h     \
-       gdkwindow.h     \
-       gdkdisplay.h    \
-       gdkscreen.h     \
+gdk_public_h_sources = @STRIP_BEGIN@           \
+       gdk.h                                   \
+       gdkcolor.h                              \
+       gdkcursor.h                             \
+       gdkdnd.h                                \
+       gdkdrawable.h                           \
+       gdkevents.h                             \
+       gdkfont.h                               \
+       gdkgc.h                                 \
+       gdkkeysyms.h                            \
+       gdki18n.h                               \
+       gdkimage.h                              \
+       gdkinput.h                              \
+       gdkkeys.h                               \
+       gdkdisplaymanager.h                     \
+       gdkpango.h                              \
+       gdkpixbuf.h                             \
+       gdkpixmap.h                             \
+       gdkproperty.h                           \
+       gdkregion.h                             \
+       gdkrgb.h                                \
+       gdkselection.h                          \
+       gdktypes.h                              \
+       gdkvisual.h                             \
+       gdkwindow.h                             \
+       gdkdisplay.h                            \
+       gdkscreen.h                             \
 @STRIP_END@
 
 gdk_headers = @STRIP_BEGIN@       \
@@ -133,6 +135,8 @@ gdk_c_sources = @STRIP_BEGIN@       \
        gdkkeyuni.c             \
        gdkimage.c              \
        gdkinternals.h          \
+       gdkintl.h               \
+       gdkdisplaymanager.c     \
        gdkpango.c              \
        gdkpixbuf-drawable.c    \
        gdkpixbuf-render.c      \
@@ -157,9 +161,10 @@ gdk_c_sources = @STRIP_BEGIN@      \
 gdkincludedir = $(includedir)/gtk-2.0/gdk
 gdkinclude_HEADERS = $(gdk_headers)
 
-libgdk_x11_2_0_la_SOURCES = $(gdk_c_sources) gdkenumtypes.c
-libgdk_linux_fb_2_0_la_SOURCES = $(gdk_c_sources) gdkenumtypes.c
-libgdk_win32_2_0_la_SOURCES = $(gdk_c_sources) gdkenumtypes.c
+# gdkmarshalers.c is commented out becuase it is currently an empty file
+libgdk_x11_2_0_la_SOURCES = $(gdk_c_sources) gdkenumtypes.c gdkmarshalers.h # gdkmarshalers.c
+libgdk_linux_fb_2_0_la_SOURCES = $(gdk_c_sources) gdkenumtypes.c gdkmarshalers.h # gdkmarshalers.c
+libgdk_win32_2_0_la_SOURCES = $(gdk_c_sources) gdkenumtypes.c # gdkmarshalers.c
 
 libgdk_x11_2_0_la_LIBADD = x11/libgdk-x11.la   
 libgdk_linux_fb_2_0_la_LIBADD = linux-fb/libgdk-linux-fb.la    
@@ -191,10 +196,10 @@ if DISABLE_EXPLICIT_DEPS
 endif
 
 #note: not gdkconfig.h
-BUILT_SOURCES = stamp-gc-h @REBUILD@ gdkenumtypes.h
+BUILT_SOURCES = stamp-gc-h
 
 # Generate built header without using automake-1.4 BUILT_SOURCES
-$(libgdk_x11_2_0_la_OBJECTS) $(libgdk_linux_fb_2_0_la_OBJECTS) $(libgdk_win32_2_0_la_OBJECTS): gdkenumtypes.h
+$(libgdk_x11_2_0_la_OBJECTS) $(libgdk_linux_fb_2_0_la_OBJECTS) $(libgdk_win32_2_0_la_OBJECTS): gdkenumtypes.h gdkmarshalers.h
 
 $(srcdir)/gdkenumtypes.h: stamp-gdkenumtypes.h
        @true
@@ -211,7 +216,7 @@ stamp-gdkenumtypes.h: @REBUILD@ $(gdk_public_h_sources) Makefile
 $(srcdir)/gdkenumtypes.c: @REBUILD@ $(gdk_public_h_sources) Makefile
        ( cd $(srcdir) && glib-mkenums \
                        --fhead "#define GDK_ENABLE_BROKEN\n#include \"gdk.h\"" \
-                       --fprod "\n/* enumerations from \"@filename@\" */" \
+               --fprod "\n/* enumerations from \"@filename@\" */" \
                        --vhead "GType\n@enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static const G@Type@Value values[] = {" \
                        --vprod "      { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
                        --vtail "      { 0, NULL, NULL }\n    };\n    etype = g_@type@_register_static (\"@EnumName@\", values);\n  }\n  return etype;\n}\n" \
@@ -219,6 +224,20 @@ $(srcdir)/gdkenumtypes.c: @REBUILD@ $(gdk_public_h_sources) Makefile
        && cp xgen-getc $(srcdir)/gdkenumtypes.c  \
        && rm -f xgen-getc
 
+# 
+# Marshaller generation
+#
+$(srcdir)/gdkmarshalers.h: @REBUILD@ gdkmarshalers.list
+       cd $(srcdir) &&                                                                                 \
+        ( @GLIB_GENMARSHAL@ --prefix=gdk_marshal gdkmarshalers.list --header > gdkmarshalers.tmp       \
+       && mv gdkmarshalers.tmp gdkmarshalers.h )                                                       \
+        || ( rm -f gdkmarshalers.tmp && exit 1 )
+$(srcdir)/gdkmarshalers.c: @REBUILD@ gdkmarshalers.list
+       cd $(srcdir) &&                                                                                 \
+       $( @GLIB_GENMARSHAL@ --prefix=gdk_marshal gdkmarshalers.list --body > gdkmarshalers.tmp \
+       && mv gdkmarshalers.tmp gdkmarshalers.c )                                                       \
+       || ( rm -f gdkmarshalers.tmp && exit 1 )
+
 gdkconfig.h: stamp-gc-h
        @if test -f gdkconfig.h; then :; \
        else rm -f stamp-gc-h; $(MAKE) stamp-gc-h; fi
index 98e0590ebfa6ea0388e38eed0df1da807806356c..b81f7d3e14faa0f86153706c3afeaed3416cccbd 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -287,7 +287,7 @@ gdk_parse_args (int    *argc,
   gint i;
 
   if (gdk_initialized)
-    return TRUE;
+    return;
 
   gdk_initialized = TRUE;
 
@@ -399,7 +399,8 @@ gdk_init_check (int    *argc,
 
   if (display)
     {
-      gdk_set_default_display (display);
+      gdk_display_manager_set_default_display (gdk_display_manager_get (),
+                                              display);
       return TRUE;
     }
   else
index cc624530c76b8461b52475d0881a51358c0f8b2e..1773398119e9e1cf28eab0f52f8b90c993004eea 100644 (file)
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -39,6 +39,7 @@
 #include <gdk/gdkimage.h>
 #include <gdk/gdkinput.h>
 #include <gdk/gdkkeys.h>
+#include <gdk/gdkdisplaymanager.h>
 #include <gdk/gdkpango.h>
 #include <gdk/gdkpixbuf.h>
 #include <gdk/gdkpixmap.h>
index 9a746d497867401453ec969057d45b76bf8f0471..d4fa23a3300b8f10a6f2c3b42744b2bca1c29be7 100644 (file)
@@ -31,8 +31,6 @@ static void gdk_display_class_init (GdkDisplayClass *class);
 static void gdk_display_init       (GdkDisplay      *display);
 static void gdk_display_finalize   (GObject         *object);
 
-static GdkDisplay *default_display = NULL;
-
 static GObjectClass *parent_class;
 
 GType
@@ -90,8 +88,9 @@ gdk_display_finalize (GObject *object)
   
   _gdk_displays = g_slist_remove (_gdk_displays, display);
 
-  if (default_display == display)
-    default_display = NULL;
+  if (gdk_get_default_display() == display)
+    gdk_display_manager_set_default_display (gdk_display_manager_get(),
+                                            NULL);
   
   parent_class->finalize (object);
 }
@@ -109,62 +108,6 @@ gdk_display_close (GdkDisplay *display)
   g_object_unref (G_OBJECT (display));
 }
 
-/**
- * gdk_set_default_display:
- * @display: a #GdkDisplay
- * 
- * Sets @display as the default display.
- **/
-void
-gdk_set_default_display (GdkDisplay *display)
-{
-  default_display = display;
-
-  _gdk_windowing_set_default_display (display);
-}
-
-/**
- * gdk_get_default_display:
- *
- * Gets the default #GdkDisplay. 
- * 
- * Returns: a #GdkDisplay, or %NULL if there is no default
- *   display.
- */
-GdkDisplay *
-gdk_get_default_display (void)
-{
-  return default_display;
-}
-
-/**
- * gdk_get_default_screen:
- *
- * Gets the default screen for the default display. (See
- * gdk_get_default_display ()).
- * 
- * Returns: a #GdkScreen.
- */
-GdkScreen *
-gdk_get_default_screen (void)
-{
-  return gdk_display_get_default_screen (gdk_get_default_display ());
-}
-
-/**
- * gdk_list_displays:
- *
- * List all currently open displays.
- * 
- * Return value: a newly allocated #GSList of #GdkDisplay objects.
- *  Free this list with g_slist_free() when you are done with it.
- **/
-GSList *
-gdk_list_displays (void)
-{
-  return g_slist_copy (_gdk_displays);
-}
-
 /**
  * gdk_display_get_event:
  * @display: a #GdkDisplay
diff --git a/gdk/gdkintl.h b/gdk/gdkintl.h
new file mode 100644 (file)
index 0000000..7cb426e
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __GDKINTL_H__
+#define __GDKINTL_H__
+
+#include "config.h"
+
+#ifdef ENABLE_NLS
+#include<libintl.h>
+#define _(String) dgettext(GETTEXT_PACKAGE,String)
+#ifdef gettext_noop
+#define N_(String) gettext_noop(String)
+#else
+#define N_(String) (String)
+#endif
+#else /* NLS is disabled */
+#define _(String) (String)
+#define N_(String) (String)
+#define textdomain(String) (String)
+#define gettext(String) (String)
+#define dgettext(Domain,String) (String)
+#define dcgettext(Domain,String,Type) (String)
+#define bindtextdomain(Domain,Directory) (Domain) 
+#endif
+
+#endif
diff --git a/gdk/gdkmarshalers.list b/gdk/gdkmarshalers.list
new file mode 100644 (file)
index 0000000..e22aea6
--- /dev/null
@@ -0,0 +1 @@
+VOID:OBJECT
index 296ae1d85f07eeff68ce072008e43e66c332cb53..0e9c4356aef86e6af017088dbaaf15856737582c 100644 (file)
@@ -51,6 +51,9 @@ gdk_open_display (const gchar *display_name)
   _gdk_input_init ();
   _gdk_dnd_init ();
 
+  g_signal_emit_by_name (gdk_display_manager_get (),
+                        "display_opened", _gdk_display);
+
   return _gdk_display;
 }
 
index 4f2861105aa200a0a265a10261afc9fd7f85e811..738a34095cf25ce499e96cf3855dc0a1756c036a 100644 (file)
@@ -199,7 +199,8 @@ gdk_open_display (const gchar *display_name)
   _gdk_input_init (display);
   _gdk_dnd_init (display);
 
-  g_signal_emit_by_name (gdk_library_get(), "display_opened", display);
+  g_signal_emit_by_name (gdk_display_manager_get(),
+                        "display_opened", display);
 
   return display;
 }
index eb33e039f227c035b8fe286099fadf1fd0388df0..73c007e026901607a04f8e90199a9b8cc9d9c0c6 100644 (file)
@@ -70,6 +70,7 @@ typedef struct _GtkInitFunction                GtkInitFunction;
 typedef struct _GtkQuitFunction                 GtkQuitFunction;
 typedef struct _GtkClosure              GtkClosure;
 typedef struct _GtkKeySnooperData       GtkKeySnooperData;
+typedef struct _GtkModuleInfo            GtkModuleInfo;
 
 struct _GtkInitFunction
 {
@@ -101,6 +102,12 @@ struct _GtkKeySnooperData
   guint id;
 };
 
+struct _GtkModuleInfo
+{
+  GtkModuleInitFunc init_func;
+  GtkModuleDisplayInitFunc display_init_func;
+};
+
 static gint  gtk_quit_invoke_function   (GtkQuitFunction    *quitf);
 static void  gtk_quit_destroy           (GtkQuitFunction    *quitf);
 static gint  gtk_invoke_key_snoopers    (GtkWidget          *grab_widget,
@@ -127,6 +134,13 @@ const guint gtk_micro_version = GTK_MICRO_VERSION;
 const guint gtk_binary_age = GTK_BINARY_AGE;
 const guint gtk_interface_age = GTK_INTERFACE_AGE;
 
+static GSList *gtk_modules;
+
+/* Saved argc,argv for delayed module initialization
+ */
+static gint    gtk_argc = 0;
+static gchar **gtk_argv = NULL;
+
 static guint gtk_main_loop_level = 0;
 static gint gtk_initialized = FALSE;
 static GList *current_events = NULL;
@@ -466,10 +480,11 @@ find_module (const gchar *name)
 }
 
 static GSList *
-load_module (GSList      *gtk_modules,
+load_module (GSList      *module_list,
             const gchar *name)
 {
   GtkModuleInitFunc modinit_func = NULL;
+  GtkModuleInfo *info;
   GModule *module = NULL;
   
   if (g_module_supported ())
@@ -479,11 +494,16 @@ load_module (GSList      *gtk_modules,
          g_module_symbol (module, "gtk_module_init", (gpointer *) &modinit_func) &&
          modinit_func)
        {
-         if (!g_slist_find (gtk_modules, (gconstpointer) modinit_func))
+         if (!g_slist_find (module_list, (gconstpointer) modinit_func))
            {
              g_module_make_resident (module);
-             gtk_modules = g_slist_prepend (gtk_modules,
-                                            (gpointer) modinit_func);
+             info = g_new (GtkModuleInfo, 1);
+
+             info->init_func = modinit_func;
+             g_module_symbol (module, "gtk_module_display_init",
+                              (gpointer *) &info->display_init_func);
+             
+             module_list = g_slist_prepend (module_list, info);
            }
          else
            {
@@ -501,24 +521,24 @@ load_module (GSList      *gtk_modules,
        g_module_close (module);
     }
   
-  return gtk_modules;
+  return module_list;
 }
 
 static GSList *
 load_modules (const char *module_str)
 {
   gchar **module_names = pango_split_file_list (module_str);
-  GSList *gtk_modules = NULL;
+  GSList *module_list = NULL;
   gint i;
   
   for (i = 0; module_names[i]; i++)
-    gtk_modules = load_module (gtk_modules, module_names[i]);
+    module_list = load_module (module_list, module_names[i]);
   
-  gtk_modules = g_slist_reverse (gtk_modules);
+  module_list = g_slist_reverse (module_list);
   
   g_strfreev (module_names);
 
-  return gtk_modules;
+  return module_list;
 }
 
 static gboolean do_setlocale = TRUE;
@@ -545,13 +565,75 @@ gtk_disable_setlocale (void)
 
 #undef gtk_init_check
 
+static void
+default_display_notify_cb (GdkDisplayManager *display_manager)
+{
+  GSList *slist;
+
+  /* Initialize non-multihead-aware modules when the
+   * default display is first set to a non-NULL value.
+   */
+  static gboolean initialized = FALSE;
+
+  if (!gdk_get_default_display () || initialized)
+    return;
+
+  initialized = TRUE;
+
+  for (slist = gtk_modules; slist; slist = slist->next)
+    {
+      if (slist->data)
+       {
+         GtkModuleInfo *info = slist->data;
+
+         if (!info->display_init_func)
+           info->init_func (&gtk_argc, &gtk_argv);
+       }
+    }
+}
+
+static void
+display_opened_cb (GdkDisplayManager *display_manager,
+                  GdkDisplay        *display)
+{
+  GSList *slist;
+  
+  for (slist = gtk_modules; slist; slist = slist->next)
+    {
+      if (slist->data)
+       {
+         GtkModuleInfo *info = slist->data;
+
+         if (info->display_init_func)
+           info->display_init_func (display);
+       }
+    }
+}
+
+/**
+ * gdk_parse_args:
+ * @argc: the number of command line arguments.
+ * @argv: the array of command line arguments.
+ * 
+ * Parses command line arguments, and initializes global
+ * attributes of GTK+, but does not actually open a connection
+ * to a display. (See gdk_open_display(), gdk_get_display_arg_name())
+ *
+ * Any arguments used by GTK or GDK are removed from the array and
+ * @argc and @argv are updated accordingly.
+ *
+ * You shouldn't call this function explicitely if you are using
+ * gtk_init(), or gtk_init_check().
+ *
+ * Return value: %TRUE if initialization succeeded, otherwise %FALSE.
+ **/
 gboolean
-gtk_init_check (int     *argc,
-               char   ***argv)
+gtk_parse_args (int    *argc,
+               char ***argv)
 {
   GString *gtk_modules_string = NULL;
-  GSList *gtk_modules = NULL;
   GSList *slist;
+  GdkDisplayManager *display_manager;
   const gchar *env_string;
 
   if (gtk_initialized)
@@ -572,13 +654,8 @@ gtk_init_check (int         *argc,
       if (!setlocale (LC_ALL, ""))
        g_warning ("Locale not supported by C library.\n\tUsing the fallback 'C' locale.");
     }
-  
-  /* Initialize "gdk". We pass along the 'argc' and 'argv'
-   *  parameters as they contain information that GDK uses
-   */
-  if (!gdk_init_check (argc, argv))
-    return FALSE;
 
+  gdk_parse_args (argc, argv);
   gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
   
 #ifdef G_ENABLE_DEBUG
@@ -697,6 +774,11 @@ gtk_init_check (int         *argc,
              *argc -= k;
            }
        }
+
+      gtk_argv = g_malloc ((gtk_argc + 1) * sizeof (char*));
+      for (i = 0; i < gtk_argc; i++)
+       gtk_argv[i] = g_strdup ((*argv)[i]);
+      gtk_argv[gtk_argc] = NULL;
     }
 
   if (gtk_debug_flags & GTK_DEBUG_UPDATES)
@@ -738,25 +820,97 @@ gtk_init_check (int        *argc,
    */
   gtk_initialized = TRUE;
 
-  /* initialize gtk modules
+  display_manager = gdk_display_manager_get ();
+  g_signal_connect (display_manager, "notify::default-display",
+                   G_CALLBACK (default_display_notify_cb), NULL);
+  g_signal_connect (display_manager, "display-opened",
+                   G_CALLBACK (display_opened_cb), NULL);
+
+  /* initialize multhead aware gtk modules; for other modules,
+   * we wait until we have a display open;
    */
   for (slist = gtk_modules; slist; slist = slist->next)
     {
       if (slist->data)
        {
-         GtkModuleInitFunc modinit;
-         
-         modinit = (GtkModuleInitFunc) slist->data;
-         modinit (argc, argv);
+         GtkModuleInfo *info = slist->data;
+
+         if (info->display_init_func)
+           info->init_func (argc, argv);
        }
     }
-  g_slist_free (gtk_modules);
   
   return TRUE;
 }
 
+#undef gtk_init_check
+
+/**
+ * gtk_init_check:
+ * @argc: Address of the <parameter>argc</parameter> parameter of your 
+ *   <function>main()</function> function. Changed if any arguments were 
+ *   handled.
+ * @argv: Address of the <parameter>argv</parameter> parameter of 
+ *   <function>main()</function>. Any parameters understood by gtk_init() 
+ *   are stripped before return.
+ * 
+ * This function does the same work as gtk_init() with only 
+ * a single change: It does not terminate the program if the GUI can't be 
+ * initialized. Instead it returns %FALSE on failure.
+ *
+ * This way the application can fall back to some other means of communication 
+ * with the user - for example a curses or command line interface.
+ * 
+ * Return value: %TRUE if the GUI has been successfully initialized, 
+ *               %FALSE otherwise.
+ **/
+gboolean
+gtk_init_check (int     *argc,
+               char   ***argv)
+{
+  GdkDisplay *display;
+  
+  if (!gtk_parse_args (argc, argv))
+    return FALSE;
+
+  if (gdk_get_default_display ())
+    return TRUE;
+
+  display = gdk_open_display (gdk_get_display_arg_name ());
+
+  if (display)
+    {
+      gdk_display_manager_set_default_display (gdk_display_manager_get (),
+                                              display);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
 #undef gtk_init
 
+/**
+ * gtk_init_check:
+ * @argc: Address of the <parameter>argc</parameter> parameter of your 
+ *   <function>main()</function> function. Changed if any arguments were 
+ *   handled.
+ * @argv: Address of the <parameter>argv</parameter> parameter of 
+ *   <function>main()</function>. Any parameters understood by gtk_init() 
+ *   are stripped before return.
+ * 
+ * Call this function before using any other GTK+ functions in your GUI
+ * applications.  It will initialize everything needed to operate the toolkit and
+ * parses some standard command line options. <parameter>argc</parameter> and 
+ * <parameter>argv</parameter> are adjusted accordingly so your own code will 
+ * never see those standard arguments.
+ *
+ * <note><para>
+ * This function will terminate your program if it was unable to initialize 
+ * the GUI for some reason. If you want your program to fall back to a 
+ * textual interface you want to call gtk_init_check() instead.
+ * </para></note>
+ **/
 void
 gtk_init (int *argc, char ***argv)
 {
index 7ca018e586009e2c5f2f7f2a309c2db8ef7b7789..7837bfc29c444961ca1b7e242f0818b3f2966567 100644 (file)
@@ -54,11 +54,12 @@ extern "C" {
 
 #endif /* GTK_DISABLE_DEPRECATED */
 
-typedef void   (*GtkModuleInitFunc)    (gint           *argc,
-                                        gchar        ***argv);
-typedef gint   (*GtkKeySnoopFunc)      (GtkWidget      *grab_widget,
-                                        GdkEventKey    *event,
-                                        gpointer        func_data);
+typedef void   (*GtkModuleInitFunc)        (gint         *argc,
+                                            gchar      ***argv);
+typedef void   (*GtkModuleDisplayInitFunc) (GdkDisplay   *display);
+typedef gint   (*GtkKeySnoopFunc)          (GtkWidget    *grab_widget,
+                                            GdkEventKey  *event,
+                                            gpointer      func_data);
 
 /* Gtk version.
  */
index 2cbc0639feb877e7cefd865a5122863c65942b8f..1bd4e8594573c473cc83269ea38c1813ae948f56 100644 (file)
@@ -17,6 +17,7 @@ gdk-pixbuf/io-tiff.c
 gdk-pixbuf/io-wbmp.c
 gdk-pixbuf/io-xbm.c
 gdk-pixbuf/io-xpm.c
+gdk/gdkdisplaymanager.c
 gtk/gtkaccellabel.c
 gtk/gtkalignment.c
 gtk/gtkarrow.c