Re: [gtk-list] Re: gdk.c suggestion.



On Sun, 31 May 1998 22:18:45 +0200 (CEST), Tim Janik wrote:

>On Sun, 31 May 1998, Asbjoern Pettersen wrote:
>
>>
>> Hello.
>> I'm the author of the OS/2 port of GIMP and i have some stange problems
>> when starting some plug-ins. The error occour in gdk.c
>>
>> To solve it i add some tests in gdk.c
>> The __EMX__ is a build in define for the emx compiler.
>> The code will only effect the OS/2 version.
>
>hm, is there an OS/2 specific define also (__OS_2__ or something the like)?
>
>> Suggestion:
>>
>> gdk.c
>>
>> #ifdef __EMX__
>>   if (gdk_display_name == NULL)
>>    {
>>     	gdk_display_name= getenv("DISPLAY");
>>     	if (gdk_display_name == NULL)	/* very strange ! */
>>     	   gdk_display_name="127.0.0.1:0.0";
>>    	g_print ("gdk_display_name=%s\n",gdk_display_name);
>>    }
>> #endif
>
>so we can do
>#ifdef __OS_2__
>  if (!gdk_display_name)
>    {
>      gdk_display_name = getenv("DISPLAY");
>      if (!gdk_display_name)
>        gdk_display_name="127.0.0.1:0.0";
>      GDK_NOTE (MISC,
>        g_print ("Gdk: OS/2 display fallback: %s\n", gdk_display_name));
>    }
>#endif /* __OS_2__ */
>
>>   gdk_display = XOpenDisplay (gdk_display_name);
>>   if (!gdk_display)
>>     {
>>       g_warning ("cannot open display: %s", XDisplayName (gdk_display_name));
>>       exit(1);
>>     }
>
>>
>> Can somebody add this test ?
>
>since __EMX__ is not only defined for OS/2, and if this fix is
>only required for OS/2, we should test for OS/2.

We could define our own  #define _OS2_VERSION 1

I'm useing DLL's  (libgdk.dll,libgtk.dll and libgtk.dll) and since there is global
variables like gdk_display_name i have to be sure that they are set.
Normally the X should handle NULL as display name but i got problems when
useing fork() in OS/2.
So the display name isn't set from the GIMP code !

I don't like the design of the gdk_init() . It's setting a lot of global variables + more.
Well i know init() functions is not the best designs but gdk_init() could be better.
Suggestion new funtion in gdk.c:

/*
/* This function setting al the gdk global variable from the arguments
/*
void gdk_set_gdk_globals_from_args(int argc, char **argv)
{
  /* set all gkd_** globals */

   if (argc && argv)
    {
      if (argc > 0)
	{
	  gchar *d;

	  d = strrchr((*argv)[0],'/');
	  if (d != NULL)
	    gdk_progname = g_strdup (d + 1);
	  else
	    gdk_progname = g_strdup ((*argv)[0]);
	  GDK_NOTE (MISC,
		    g_print ("Gdk: progname: \"%s\"\n", gdk_progname));
	}
               for (i = 1; i < argc;)
	{
 ........   /* the other gdk_xxx */
              }
       }
}

void gdk_init()
{
   ...
  if (argc && argv)
    {
      gdk_set_gdk_globals_from_args(argc_orig, argv_orig);

/*  and now the rest from the argument */
    ....
	  else if (strcmp ("--sync", (*argv)[i]) == 0)
	    {
	      (*argv)[i] = NULL;
	      synchronize = TRUE;
	    }

   ....
}


With this design i could call from the GIMP OS/2
the function:   gdk_set_gdk_globals_from_args(argc, argv)
to FORCE the name before gdk_init() is called.

Then we don't need this ugly patch in gdk.c !
#ifdef __OS_2__
  if (!gdk_display_name)
    {
      gdk_display_name = getenv("DISPLAY");
      if (!gdk_display_name)
        gdk_display_name="127.0.0.1:0.0";
      GDK_NOTE (MISC,
        g_print ("Gdk: OS/2 display fallback: %s\n", gdk_display_name));
    }
#endif /* __OS_2__ */


Asbjoern P.
***********************************************************
* Asbj rn Pettersen           Phone work: +47 77 66 08 91  *
* Kongsberg Spacetec a.s     Phone home: +47 77 67 32 14  *
*                              Telefax:    +47 77 65 58 59  *
* Prestvannveien 38          www:http://www.spacetec.no   *
* N-9005 Tromsoe, Norway     email:ape@spacetec.no  *
***********************************************************



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]