rm -rf with glib?

2010-02-07 Thread Michael Libby
I see there are convenience wrappers in glib for remove(), unlink()
and rmdir(). But these only work on a single file or directory at a
time.

I don't see any way to delete an entire directory tree at once, as
with `rm -rf`.

I know how to write a recursive function using the functions above to
get at this, and in the situation I'm doing this I'm not worried about
any complications like permissions, symlinks back up the tree
(infinite recursion), or anything that would rule out a very naive
implementation.

But I'm curious if this functionality is out there somewhere in gtk or
glib already and I just haven't stumbled on it. Googling this topic
generates a lot of false leads.

Thanks.

-- 
Michael C. Libby
www.mikelibby.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


g_debug as bug fixer?

2009-12-21 Thread Michael Libby
I am the strangest thing with some C code I'm writing that uses glib.

I was having some issues with seg faults and/or corruption, so I
decided to try and track where it was happening by throwing a couple
of quick g_debug statements into my code.

But this had the effect of causing the error to go away. Not knowing
what I'd done that was fixing my code, but figuring I'd done
*something* I removed the g_debug's.

Back came the crashing program. So back to the g_debugs. Problem
solved. And so on. Whenever the g_debugs are there it runs, when they
are not, it fails.

Any ideas? If I can't resolve and no one has any ideas, I'll see if I
can isolate some code that replicates the issue, but what I can say
is: it's happening inside a glib unit test that uses a fixture and
seems to be happening when calling a function that allocates memory to
some struct members.

-Michael


-- 
Michael C. Libby
www.mikelibby.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_test_find_widget bug?

2009-11-09 Thread Michael Libby
On Mon, Nov 9, 2009 at 3:57 PM, Michael Libby michael.c.li...@gmail.com wrote:
 This seems to be either a bug in my understanding of how to use this
 functionality or a bug in the gtk_test_find_widget function itself.

After reading the source for the various gtk_test_find_* functions and
the documentation over again, the bug was my own understanding.

The function gtk_test_find_widget() is trying to find a widget *near*
a label with the text in question, whereas I was thinking it would
find the widget that *contained* the text in question.

No surprise that the existing function has somewhat strange behavior
when attempting to locate menu items.

Suggest to add something like to find the widget with the actual text:

GtkWidget*
gtk_test_find_widget_by_text (GtkWidget *widget,
  const gchar *label_pattern,
  GType widget_type)
{
  if (GTK_IS_LABEL (widget))
{
  const gchar *text = gtk_label_get_text (GTK_LABEL (widget));
  if (g_pattern_match_simple (label_pattern, text))
return widget;
}
  if (GTK_IS_CONTAINER (widget))
{
  GList *node, *list = gtk_container_get_children (GTK_CONTAINER (widget));
  for (node = list; node; node = node-next)
{
  GtkWidget *label = gtk_test_find_widget_by_text (node-data,
label_pattern, widget_type);

  if (label)
{
  if (g_type_is_a (G_OBJECT_TYPE (widget), widget_type))
{
  return widget;
}
  else
{
  return label;
}
}
}
  g_list_free (list);
}
  return NULL;
}


-- 
Michael C. Libby
www.mikelibby.com
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Mocks and coverage with gtk/glib test frameworks?

2009-10-26 Thread Michael Libby
Forgive me if I'm on the wrong list with these questions, but gtk-devel
seems to be the place where most gtk/glib test discussion has occurred. If
there's a more appropriate place to bring this up, please let me know.

I am using the gtk/glib test frameworks to do test driven development in C.

Two things that I'm wondering:

1. Is there a way to build mocks to use with the gtk or glib test
frameworks?

I can code a mock_whatever.c file that implements the interface defined by
whatever.h and link the resulting whatever.o in my test fixture... and maybe
that's the easiest/best way? But I am curious if there is already a way to
do mocking that I should be aware of.

2. Is there any way to measure code coverage?

I'm sure the debugger must instrument the code somehow. And I'm sure I could
measure coverage with macros or a preprocessor that finds all the
checkpoints to measure and puts calls to a few functions that record
coverage data. But I wonder if there is already a way to do this with
existing tools or methods?

Thanks!

-- 
Michael C. Libby
www.mikelibby.com
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list