Re: [PATCH] random memprof UI tweaks



On Tue, 2002-08-20 at 17:10, Owen Taylor wrote:
> 
> Kristian Rietveld <kris gtk org> writes:
> 
> > Hello,
> > 
> > Appended fix makes the file selector in the run dialog work and enables
> > has_default in some dialogs and some small other things.
> > 
> > I had to convert the run and skip dialogs to GtkDialogs, because the
> > button handling of the gnome-glade GnomeDialog handling code is a bit
> > broken (also because the gnome-dialog API misses some things) (still
> > with me? :). I could cover all details here, but that's not really
> > interesting.
> 
> Sounds fine. Did you get a chance to look at turning on activates_default
> too? I keep getting annoyed that I can't type in a name and hit
> return in the "run program" dialog.

That's actually the has_default bit of the patch. The behavior you
describe already works fine. But, to really finish it, I'll add the
activates_default properties (just found these actually) (:.

>  
> > Index: process.c
> > ===================================================================
> > RCS file: /cvs/gnome/memprof/process.c,v
> > retrieving revision 1.23
> > diff -u -p -r1.23 process.c
> > --- process.c	17 Aug 2002 18:59:57 -0000	1.23
> > +++ process.c	20 Aug 2002 00:26:35 -0000
> > @@ -654,6 +654,21 @@ process_find_exec (char **args)
> >  	int i;
> >    
> >  	if (g_file_exists(args[0])) {
> > +		/* evil */
> > +		int j;
> > +		int len = strlen (args[0]);
> > +
> > +		for (j = 0; j < len; j++)
> > +			if (args[0][j] == '/')
> > +				break;
> > +
> > +		puts (args[0]);
> > +		if (j == len)
> > +			/* no slash found, assume path in current directory,
> > +			 * append "./", so loading the exec won't fail.
> > +			 */
> > +			return g_strdup_printf ("./%s", args[0]);
> > +
> >  		return g_strdup (args[0]);
> >  	} else {
> >  		char **paths;
> 
> How about simply:
> 
>  if (g_file_exists (args[0])) {
>         if (!g_path_is_absolute (args[0]))
>                  return g_strconcat ("./", args[0], NULL);
>         else
>                  return g_strdup (path[0]);
>  } else ...
> 
> Which doesn't strike me as particularly evil.
> 
> If we are only using the result as the first argument to exec(), then
> it doesn't matter if we have "././foo" or "./foo/bar".

Yep. I should really read all glib headers one day I think :).

I'll make the mentioned changes and commit.


thanks,


	Kris


> 
> Regards,
>                                         Owen
> 
> P.S. - your original algorithm could be implemented as:
> 
> 
>  if (g_file_exists (args[0])) {
>         if (strchr (args[0], '/') == NULL)
>                  return g_strconcat ("./", args[0], NULL);
>         else
>                  return g_strdup (path[0]);
>  } else ...
> 

Oh! How could I forget about strchr... I guess I was not really awake...




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