Permalink
Browse files

Show how to implement optional features in application

  • Loading branch information...
1 parent 14f82a6 commit e27f318d9d1248493f6dd58ae1958b8c7f658d88 @tadeboro committed Aug 29, 2010
Showing with 33 additions and 2 deletions.
  1. +7 −1 Makefile.am
  2. +10 −1 configure.ac
  3. +16 −0 src/snrmga.c
View
@@ -34,10 +34,16 @@ snrmga_defines = -DDATADIR=\""$(datadir)"\" \
#
# Not exactly what we want;)
+if ENABLE_DEBUG
+ debug_flags = -g
+else
+ debug_flags =
+endif
+
# Application
bin_PROGRAMS = src/snrmga
src_snrmga_SOURCES = src/snrmga.c
-src_snrmga_CPPFLAGS = $(snrmga_defines) $(SNRMGA_CFLAGS)
+src_snrmga_CPPFLAGS = $(debug_flags) $(snrmga_defines) $(SNRMGA_CFLAGS)
src_snrmga_LDADD = $(SNRMGA_LIBS)
# This part specifies program components of our package. SNRMGA_CFLAGS and
# SNRMGA_LIBS variables are defined by PKG_CHECK_MODULES inside configure.ac.
View
@@ -8,7 +8,7 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-AC_INIT([Snrmga], [0.0.1], [tadeboro@gmail.com], [snrmga])
+AC_INIT([Snrmga], [0.0.2], [tadeboro@gmail.com], [snrmga])
# This line initializes autoconf and tells it that our package is named
# "Snrmga", current version is "0.0.1", bugs can be reported to
# "tadeboro@gmail.com" and that tarball should be named snrmga.tar.gz
@@ -54,6 +54,15 @@ AC_DEFINE([GETTEXT_PACKAGE], [PACKAGE_TARNAME], [Define to the package name.])
# initialize intltool and gettext (used to extract translatable strings) and
# set some macros that we need in sources to init translations.
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug],
+ [Build with debugging support])])
+AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
+AS_IF([test "x$enable_debug" = "xyes"],
+ [AC_DEFINE([ENABLE_DEBUG], [1],
+ [Define to enable debugging])])
+ # This code snippet adds configure switch that turns on debug support.
+
SNRMGA_MODS="gtk+-2.0 >= 2.14 gmodule-2.0"
PKG_CHECK_MODULES([SNRMGA], [$SNRMGA_MODS])
# These two lines specify our application's dependencies and provide proper
View
@@ -39,6 +39,10 @@ G_MODULE_EXPORT void
cb_clicked_unset_image (GtkButton *button,
Data *data)
{
+#ifdef ENABLE_DEBUG
+ g_print ("Inside 'cb_clicked_unset_image\n");
+#endif
+
gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), NULL);
}
@@ -48,6 +52,10 @@ cb_clicked_set_image_a (GtkButton *button,
{
char *path = g_build_filename (PKGPIXMAPSDIR, "image_a.png", NULL);
+#ifdef ENABLE_DEBUG
+ g_print ("Inside 'cb_clicked_set_image_a\n");
+#endif
+
gtk_image_set_from_file (GTK_IMAGE (data->image), path);
g_free (path);
}
@@ -58,6 +66,10 @@ cb_clicked_set_image_b (GtkButton *button,
{
char *path = g_build_filename (PKGPIXMAPSDIR, "image_b.png", NULL);
+#ifdef ENABLE_DEBUG
+ g_print ("Inside 'cb_clicked_set_image_b\n");
+#endif
+
gtk_image_set_from_file (GTK_IMAGE (data->image), path);
g_free (path);
}
@@ -81,6 +93,10 @@ main (int argc,
/* Initialize GTK+ */
gtk_init (&argc, &argv);
+#ifdef ENABLE_DEBUG
+ g_print ("Running application in debug mode\n");
+#endif
+
/* Allocate shared data memory */
data = g_slice_new0 (Data);

0 comments on commit e27f318

Please sign in to comment.