aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore4
-rw-r--r--Makefile.am8
-rw-r--r--Makefile.am.coverage48
-rw-r--r--NEWS2
-rw-r--r--configure.ac46
-rw-r--r--example/Makefile.am4
-rw-r--r--example/menus.c12
-rw-r--r--example/messagedialog.c4
-rw-r--r--m4/gcov.m486
-rw-r--r--m4/gtest.m463
-rw-r--r--src/Makefile.am21
-rw-r--r--src/idocalendarmenuitem.c32
-rw-r--r--src/idoentrymenuitem.c28
-rw-r--r--src/idomessagedialog.c24
-rw-r--r--src/idorange.c33
-rw-r--r--src/idorange.h2
-rw-r--r--src/idoscalemenuitem.c32
-rw-r--r--src/idoswitchmenuitem.c120
-rw-r--r--src/idoswitchmenuitem.h57
-rw-r--r--tests/Makefile.am47
-rw-r--r--tests/gtest-menuitems.cpp102
21 files changed, 584 insertions, 191 deletions
diff --git a/.bzrignore b/.bzrignore
index a59b116..95c37a1 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -28,3 +28,7 @@ src/idotypebuiltins.lo
src/libido3-0.1.la
src/stamp-idotypebuiltins.h
m4
+m4/gtk-doc.m4
+.deps
+.libs
+gtest-menuitems
diff --git a/Makefile.am b/Makefile.am
index 30a0adc..4b2a6d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,16 +1,12 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-if USE_GTK3
VER=3
-else
-VER=
-endif
V = @
Q = $(V:1=)
QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
-SUBDIRS = src example
+SUBDIRS = src example tests
%-0.1.pc: %.pc
$(QUIET_GEN) cp -f $< $@
@@ -23,3 +19,5 @@ DISTCLEANFILES = libido.pc libido3.pc
EXTRA_DIST = libido.pc.in libido3.pc.in
DISTCHECK_CONFIGURE_FLAGS = --disable-gtk-doc
+
+include $(top_srcdir)/Makefile.am.coverage
diff --git a/Makefile.am.coverage b/Makefile.am.coverage
new file mode 100644
index 0000000..fb97747
--- /dev/null
+++ b/Makefile.am.coverage
@@ -0,0 +1,48 @@
+
+# Coverage targets
+
+.PHONY: clean-gcno clean-gcda \
+ coverage-html generate-coverage-html clean-coverage-html \
+ coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
+
+clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
+
+if HAVE_GCOV
+
+clean-gcno:
+ @echo Removing old coverage instrumentation
+ -find -name '*.gcno' -print | xargs -r rm
+
+clean-gcda:
+ @echo Removing old coverage results
+ -find -name '*.gcda' -print | xargs -r rm
+
+coverage-html: clean-gcda
+ -$(MAKE) $(AM_MAKEFLAGS) -k check
+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
+
+generate-coverage-html:
+ @echo Collecting coverage data
+ $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
+ LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
+
+clean-coverage-html: clean-gcda
+ -$(LCOV) --directory $(top_builddir) -z
+ -rm -rf coverage.info coveragereport
+
+if HAVE_GCOVR
+
+coverage-gcovr: clean-gcda
+ -$(MAKE) $(AM_MAKEFLAGS) -k check
+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
+
+generate-coverage-gcovr:
+ @echo Generating coverage GCOVR report
+ $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
+
+clean-coverage-gcovr: clean-gcda
+ -rm -rf $(top_builddir)/coverage.xml
+
+endif # HAVE_GCOVR
+
+endif # HAVE_GCOV
diff --git a/NEWS b/NEWS
index e69de29..a3995c7 100644
--- a/NEWS
+++ b/NEWS
@@ -0,0 +1,2 @@
+12.10.0:
+ * new widget IdoSwitchMenuItem
diff --git a/configure.ac b/configure.ac
index 491c87e..963de1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,9 +1,9 @@
#
# shamelessly stolen from clutter-gtk
#
-m4_define([ido_major_version], [0])
-m4_define([ido_minor_version], [3])
-m4_define([ido_micro_version], [3])
+m4_define([ido_major_version], [12])
+m4_define([ido_minor_version], [10])
+m4_define([ido_micro_version], [0])
m4_define([ido_api_version],
[ido_major_version.ido_minor_version])
@@ -57,6 +57,7 @@ dnl ===========================================================================
# Checks for programs
AC_PROG_CC
AM_PROG_CC_C_O
+AC_PROG_CXX
# Initialize libtool
LT_PREREQ([2.2])
@@ -76,20 +77,14 @@ AC_C_CONST
AC_FUNC_MALLOC
AC_FUNC_MMAP
AC_CHECK_FUNCS([memset munmap strcasecmp strdup])
+AC_CHECK_LIBM
+
+GLIB_REQUIRED_VERSION=2.32.0
+GTK_REQUIRED_VERSION=3.4.0
+
+PKG_CHECK_MODULES(GTK,[gtk+-3.0 >= $GTK_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION])
-AC_ARG_WITH([gtk],
- [AS_HELP_STRING([--with-gtk],
- [Which version of gtk to use @<:@default=3@:>@])],
- [],
- [with_gtk=3])
-AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3])
-
-if test "x$with_gtk" = "x2"; then
- PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.19.7)
-else
- PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0.0)
- AC_DEFINE_UNQUOTED(USE_GTK3, , [Use GTK3])
-fi
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
@@ -117,6 +112,22 @@ AS_IF([test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"],
AC_SUBST(MAINTAINER_CFLAGS)
+dnl = gcov Coverage Reporting =================================================
+
+m4_include([m4/gcov.m4])
+AC_TDD_GCOV
+AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
+AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
+AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
+AC_SUBST(COVERAGE_CFLAGS)
+AC_SUBST(COVERAGE_CXXFLAGS)
+AC_SUBST(COVERAGE_LDFLAGS)
+
+dnl = Google Test Framework ===================================================
+
+m4_include([m4/gtest.m4])
+CHECK_GTEST
+CHECK_XORG_GTEST
dnl = GTK Doc Check ===========================================================
@@ -128,6 +139,7 @@ AC_CONFIG_FILES([
Makefile
src/Makefile
example/Makefile
+ tests/Makefile
libido.pc
libido3.pc
])
@@ -139,7 +151,7 @@ echo " ido $VERSION"
echo " ==============================="
echo ""
echo " Prefix : ${prefix}"
-echo " GTK : ${with_gtk}"
+echo " gcov : ${use_gcov}"
echo ""
echo " Documentation: ${enable_gtk_doc}"
echo ""
diff --git a/example/Makefile.am b/example/Makefile.am
index b986b9b..a578404 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,8 +1,4 @@
-if USE_GTK3
VER=3
-else
-VER=
-endif
noinst_PROGRAMS = \
messagedialog \
diff --git a/example/menus.c b/example/menus.c
index b563eaf..5687b8e 100644
--- a/example/menus.c
+++ b/example/menus.c
@@ -3,6 +3,7 @@
#include "idoscalemenuitem.h"
#include "idocalendarmenuitem.h"
#include "idoentrymenuitem.h"
+#include "idoswitchmenuitem.h"
#include "config.h"
static void
@@ -27,6 +28,7 @@ main (int argc, char *argv[])
GtkWidget *root;
GtkWidget *menubar;
GtkWidget *image;
+ GtkWidget *label;
g_unsetenv ("UBUNTU_MENUPROXY");
@@ -38,11 +40,7 @@ main (int argc, char *argv[])
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
-#ifdef USE_GTK3
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-#else
- vbox = gtk_vbox_new (FALSE, 0);
-#endif
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -76,6 +74,12 @@ main (int argc, char *argv[])
menuitem = ido_entry_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ menuitem = ido_switch_menu_item_new ();
+ label = gtk_label_new ("This is a switch");
+ gtk_widget_show(label);
+ gtk_container_add (ido_switch_menu_item_get_content_area(IDO_SWITCH_MENU_ITEM(menuitem)), label);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
menuitem = ido_calendar_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
diff --git a/example/messagedialog.c b/example/messagedialog.c
index 4ba866b..d9cfc21 100644
--- a/example/messagedialog.c
+++ b/example/messagedialog.c
@@ -41,11 +41,7 @@ main (int argc, char *argv[])
gtk_window_set_title (GTK_WINDOW (window), "Message Dialogs");
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
-#ifdef USE_GTK3
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-#else
- vbox = gtk_vbox_new (FALSE, 0);
-#endif
gtk_container_add (GTK_CONTAINER (window), vbox);
diff --git a/m4/gcov.m4 b/m4/gcov.m4
new file mode 100644
index 0000000..3163584
--- /dev/null
+++ b/m4/gcov.m4
@@ -0,0 +1,86 @@
+# Checks for existence of coverage tools:
+# * gcov
+# * lcov
+# * genhtml
+# * gcovr
+#
+# Sets ac_cv_check_gcov to yes if tooling is present
+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
+AC_DEFUN([AC_TDD_GCOV],
+[
+ AC_ARG_ENABLE(gcov,
+ AS_HELP_STRING([--enable-gcov],
+ [enable coverage testing with gcov]),
+ [use_gcov=$enableval], [use_gcov=no])
+
+ if test "x$use_gcov" = "xyes"; then
+ # we need gcc:
+ if test "$GCC" != "yes"; then
+ AC_MSG_ERROR([GCC is required for --enable-gcov])
+ fi
+
+ # Check if ccache is being used
+ AC_CHECK_PROG(SHTOOL, shtool, shtool)
+ case `$SHTOOL path $CC` in
+ *ccache*[)] gcc_ccache=yes;;
+ *[)] gcc_ccache=no;;
+ esac
+
+ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
+ AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
+ fi
+
+ lcov_version_list="1.6 1.7 1.8 1.9"
+ AC_CHECK_PROG(LCOV, lcov, lcov)
+ AC_CHECK_PROG(GENHTML, genhtml, genhtml)
+
+ if test "$LCOV"; then
+ AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
+ glib_cv_lcov_version=invalid
+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
+ for lcov_check_version in $lcov_version_list; do
+ if test "$lcov_version" = "$lcov_check_version"; then
+ glib_cv_lcov_version="$lcov_check_version (ok)"
+ fi
+ done
+ ])
+ else
+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
+ AC_MSG_ERROR([$lcov_msg])
+ fi
+
+ case $glib_cv_lcov_version in
+ ""|invalid[)]
+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
+ AC_MSG_ERROR([$lcov_msg])
+ LCOV="exit 0;"
+ ;;
+ esac
+
+ if test -z "$GENHTML"; then
+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
+ fi
+
+ ac_cv_check_gcov=yes
+ ac_cv_check_lcov=yes
+
+ # Remove all optimization flags from CFLAGS
+ changequote({,})
+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
+ changequote([,])
+
+ # Add the special gcc flags
+ COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
+ COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
+ COVERAGE_LDFLAGS="-lgcov"
+
+ # Check availability of gcovr
+ AC_CHECK_PROG(GCOVR, gcovr, gcovr)
+ if test -z "$GCOVR"; then
+ ac_cv_check_gcovr=no
+ else
+ ac_cv_check_gcovr=yes
+ fi
+
+fi
+]) # AC_TDD_GCOV
diff --git a/m4/gtest.m4 b/m4/gtest.m4
new file mode 100644
index 0000000..2de334c
--- /dev/null
+++ b/m4/gtest.m4
@@ -0,0 +1,63 @@
+# Copyright (C) 2012 Canonical, Ltd.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# Checks whether the gtest source is available on the system. Allows for
+# adjusting the include and source path. Sets have_gtest=yes if the source is
+# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
+# source location respectively.
+AC_DEFUN([CHECK_GTEST],
+[
+ AC_ARG_WITH([gtest-include-path],
+ [AS_HELP_STRING([--with-gtest-include-path],
+ [location of the Google test headers])],
+ [GTEST_CPPFLAGS="-I$withval"])
+
+ AC_ARG_WITH([gtest-source-path],
+ [AS_HELP_STRING([--with-gtest-source-path],
+ [location of the Google test sources, defaults to /usr/src/gtest])],
+ [GTEST_SOURCE="$withval"],
+ [GTEST_SOURCE="/usr/src/gtest"])
+
+ GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
+
+ AC_LANG_PUSH([C++])
+
+ tmp_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS"
+
+ AC_CHECK_HEADER([gtest/gtest.h])
+
+ CPPFLAGS="$tmp_CPPFLAGS"
+
+ AC_LANG_POP
+
+ AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
+ [$GTEST_SOURCE/src/gtest_main.cc],
+ [have_gtest_source=yes],
+ [have_gtest_source=no])
+
+ AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \
+ "x$have_gtest_source" = xyes],
+ [have_gtest=yes]
+ [AC_SUBST(GTEST_CPPFLAGS)]
+ [AC_SUBST(GTEST_SOURCE)],
+ [have_gtest=no])
+]) # CHECK_GTEST
diff --git a/src/Makefile.am b/src/Makefile.am
index 6180422..017874f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,10 +1,5 @@
-if USE_GTK3
VER=3
lib_LTLIBRARIES = libido3-0.1.la
-else
-VER=
-lib_LTLIBRARIES = libido-0.1.la
-endif
ido_built_public_sources = \
idotypebuiltins.h
@@ -19,6 +14,7 @@ sources_h = \
idomessagedialog.h \
idorange.h \
idoscalemenuitem.h \
+ idoswitchmenuitem.h \
idotimeline.h \
libido.h
@@ -57,6 +53,9 @@ AM_CPPFLAGS = \
$(MAINTAINER_CFLAGS) \
-Wall -Werror -Wextra -Wno-unused-parameter
+AM_CFLAGS = \
+ $(COVERAGE_CFLAGS)
+
libido_0_1_la_SOURCES = \
idotypebuiltins.c \
idocalendarmenuitem.c \
@@ -64,6 +63,7 @@ libido_0_1_la_SOURCES = \
idomessagedialog.c \
idorange.c \
idoscalemenuitem.c \
+ idoswitchmenuitem.c \
idotimeline.c
libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES)
@@ -76,13 +76,18 @@ libidoinclude_HEADERS = \
idomessagedialog.h \
idorange.h \
idoscalemenuitem.h \
+ idoswitchmenuitem.h \
idotimeline.h \
libido.h
-libido_0_1_la_LIBADD = $(GTK_LIBS)
-libido_0_1_la_LDFLAGS = $(GTK_LT_LDFLAGS)
+libido_0_1_la_LIBADD = $(GTK_LIBS) $(LIBM)
+libido_0_1_la_LDFLAGS = \
+ $(GTK_LT_LDFLAGS) \
+ $(COVERAGE_LDFLAGS)
libido3_0_1_la_LIBADD = $(libido_0_1_la_LIBADD)
-libido3_0_1_la_LDFLAGS = $(libido_0_1_la_LDFLAGS)
+libido3_0_1_la_LDFLAGS = \
+ $(libido_0_1_la_LDFLAGS) \
+ $(COVERAGE_LDFLAGS)
DISTCLEANFILES = \
stamp-idotypebuiltins.h \
diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c
index da7c436..84bee80 100644
--- a/src/idocalendarmenuitem.c
+++ b/src/idocalendarmenuitem.c
@@ -27,13 +27,8 @@
#include "idocalendarmenuitem.h"
#include "config.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
static void ido_calendar_menu_item_select (GtkMenuItem *item);
static void ido_calendar_menu_item_deselect (GtkMenuItem *item);
-#else
-static void ido_calendar_menu_item_select (GtkItem *item);
-static void ido_calendar_menu_item_deselect (GtkItem *item);
-#endif
static gboolean ido_calendar_menu_item_button_release (GtkWidget *widget,
GdkEventButton *event);
static gboolean ido_calendar_menu_item_button_press (GtkWidget *widget,
@@ -71,27 +66,16 @@ ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass)
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
GtkMenuItemClass *menu_item_class;
-#if ! GTK_CHECK_VERSION (3, 0, 0)
- GtkItemClass *item_class;
-#endif
gobject_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
menu_item_class = GTK_MENU_ITEM_CLASS (klass);
-#if ! GTK_CHECK_VERSION (3, 0, 0)
- item_class = GTK_ITEM_CLASS (klass);
-#endif
widget_class->button_release_event = ido_calendar_menu_item_button_release;
widget_class->button_press_event = ido_calendar_menu_item_button_press;
-#if GTK_CHECK_VERSION (3, 0, 0)
menu_item_class->select = ido_calendar_menu_item_select;
menu_item_class->deselect = ido_calendar_menu_item_deselect;
-#else
- item_class->select = ido_calendar_menu_item_select;
- item_class->deselect = ido_calendar_menu_item_deselect;
-#endif
menu_item_class->hide_on_activate = TRUE;
@@ -132,11 +116,7 @@ ido_calendar_menu_item_init (IdoCalendarMenuItem *item)
G_CALLBACK (calendar_move_focus_cb),
item);
-#ifdef USE_GTK3
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- priv->box = gtk_hbox_new (FALSE, 0);
-#endif
gtk_box_pack_start (GTK_BOX (priv->box), priv->calendar, FALSE, FALSE, 0);
@@ -213,7 +193,6 @@ ido_calendar_menu_item_button_press (GtkWidget *widget,
gtk_widget_grab_focus (calendar);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkEvent * newevent = gdk_event_copy((GdkEvent *)(event));
GList * children = gdk_window_get_children(gtk_widget_get_window(calendar));
GList * child;
@@ -242,7 +221,6 @@ ido_calendar_menu_item_button_press (GtkWidget *widget,
((GdkEventButton *)newevent)->window = event->window;
gdk_event_free(newevent);
-#endif
return TRUE;
}
@@ -254,20 +232,14 @@ static gboolean
ido_calendar_menu_item_button_release (GtkWidget *widget,
GdkEventButton *event)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar;
GTK_WIDGET_GET_CLASS(calendar)->button_release_event(GTK_WIDGET(calendar), event);
-#endif
return TRUE;
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
ido_calendar_menu_item_select (GtkMenuItem *item)
-#else
-ido_calendar_menu_item_select (GtkItem *item)
-#endif
{
IDO_CALENDAR_MENU_ITEM (item)->priv->selected = TRUE;
@@ -275,11 +247,7 @@ ido_calendar_menu_item_select (GtkItem *item)
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
ido_calendar_menu_item_deselect (GtkMenuItem *item)
-#else
-ido_calendar_menu_item_deselect (GtkItem *item)
-#endif
{
IDO_CALENDAR_MENU_ITEM (item)->priv->selected = FALSE;
diff --git a/src/idoentrymenuitem.c b/src/idoentrymenuitem.c
index 088c559..5390d0b 100644
--- a/src/idoentrymenuitem.c
+++ b/src/idoentrymenuitem.c
@@ -27,13 +27,8 @@
#include "idoentrymenuitem.h"
#include "config.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
static void ido_entry_menu_item_select (GtkMenuItem *item);
static void ido_entry_menu_item_deselect (GtkMenuItem *item);
-#else
-static void ido_entry_menu_item_select (GtkItem *item);
-static void ido_entry_menu_item_deselect (GtkItem *item);
-#endif
static gboolean ido_entry_menu_item_button_release (GtkWidget *widget,
GdkEventButton *event);
static gboolean ido_entry_menu_item_key_press (GtkWidget *widget,
@@ -66,27 +61,16 @@ ido_entry_menu_item_class_init (IdoEntryMenuItemClass *klass)
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
GtkMenuItemClass *menu_item_class;
-#if ! GTK_CHECK_VERSION (3, 0, 0)
- GtkItemClass *item_class;
-#endif
gobject_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
menu_item_class = GTK_MENU_ITEM_CLASS (klass);
-#if ! GTK_CHECK_VERSION (3, 0, 0)
- item_class = GTK_ITEM_CLASS (klass);
-#endif
widget_class->button_release_event = ido_entry_menu_item_button_release;
widget_class->button_press_event = ido_entry_menu_item_button_press;
-#if GTK_CHECK_VERSION (3, 0, 0)
menu_item_class->select = ido_entry_menu_item_select;
menu_item_class->deselect = ido_entry_menu_item_deselect;
-#else
- item_class->select = ido_entry_menu_item_select;
- item_class->deselect = ido_entry_menu_item_deselect;
-#endif
menu_item_class->hide_on_activate = TRUE;
@@ -119,11 +103,7 @@ ido_entry_menu_item_init (IdoEntryMenuItem *item)
G_CALLBACK (entry_move_focus_cb),
item);
-#ifdef USE_GTK3
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- priv->box = gtk_hbox_new (FALSE, 0);
-#endif
gtk_box_pack_start (GTK_BOX (priv->box), priv->entry, FALSE, FALSE, 0);
@@ -235,11 +215,7 @@ ido_entry_menu_item_button_release (GtkWidget *widget,
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
ido_entry_menu_item_select (GtkMenuItem *item)
-#else
-ido_entry_menu_item_select (GtkItem *item)
-#endif
{
IDO_ENTRY_MENU_ITEM (item)->priv->selected = TRUE;
@@ -247,11 +223,7 @@ ido_entry_menu_item_select (GtkItem *item)
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
ido_entry_menu_item_deselect (GtkMenuItem *item)
-#else
-ido_entry_menu_item_deselect (GtkItem *item)
-#endif
{
IDO_ENTRY_MENU_ITEM (item)->priv->selected = FALSE;
diff --git a/src/idomessagedialog.c b/src/idomessagedialog.c
index d4a3e2f..41ff2e7 100644
--- a/src/idomessagedialog.c
+++ b/src/idomessagedialog.c
@@ -167,22 +167,14 @@ ido_message_dialog_focus_in_event (GtkWidget *widget,
IdoTimeline *timeline;
IdoMessageDialogMorphContext *context;
-#ifdef USE_GTK3
gtk_widget_get_preferred_size (GTK_WIDGET (dialog), NULL, &start);
-#else
- gtk_widget_get_requisition (GTK_WIDGET (dialog), &start);
-#endif
priv->expanded = TRUE;
gtk_widget_show (priv->action_area);
gtk_widget_show (priv->secondary_label);
-#ifdef USE_GTK3
gtk_widget_get_preferred_size (GTK_WIDGET (dialog), NULL, &end);
-#else
- gtk_widget_get_requisition (GTK_WIDGET (dialog), &end);
-#endif
gtk_widget_hide (priv->action_area);
gtk_widget_hide (priv->secondary_label);
@@ -289,14 +281,6 @@ ido_message_dialog_new (GtkWindow *parent,
NULL);
dialog = GTK_DIALOG (widget);
-#if ! GTK_CHECK_VERSION(3, 0, 0)
- if (flags & GTK_DIALOG_NO_SEPARATOR)
- {
- g_warning ("The GTK_DIALOG_NO_SEPARATOR flag cannot be used for IdoMessageDialog");
- flags &= ~GTK_DIALOG_NO_SEPARATOR;
- }
-#endif
-
if (message_format)
{
va_start (args, message_format);
@@ -379,11 +363,7 @@ ido_message_dialog_get_label (IdoMessageDialog *dialog, gboolean primary)
for (list = children; list != NULL; list = list->next)
{
-#ifdef USE_GTK3
if (G_TYPE_FROM_INSTANCE (list->data) == GTK_TYPE_BOX && gtk_orientable_get_orientation (list->data) == GTK_ORIENTATION_HORIZONTAL)
-#else
- if (G_TYPE_FROM_INSTANCE (list->data) == GTK_TYPE_HBOX)
-#endif
{
GList *hchildren;
GList *hlist;
@@ -393,11 +373,7 @@ ido_message_dialog_get_label (IdoMessageDialog *dialog, gboolean primary)
for (hlist = hchildren; hlist != NULL; hlist = hlist->next)
{
-#ifdef USE_GTK3
if (G_TYPE_FROM_INSTANCE (hlist->data) == GTK_TYPE_BOX && gtk_orientable_get_orientation (hlist->data) == GTK_ORIENTATION_VERTICAL)
-#else
- if (G_TYPE_FROM_INSTANCE (hlist->data) == GTK_TYPE_VBOX)
-#endif
{
GList *vlist;
GtkWidget *vbox = GTK_WIDGET (hlist->data);
diff --git a/src/idorange.c b/src/idorange.c
index a97d770..3e88fd9 100644
--- a/src/idorange.c
+++ b/src/idorange.c
@@ -41,10 +41,6 @@ static void ido_range_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-#ifdef USE_GTK3
-static void ido_range_grab_notify (GtkWidget *widget,
- gboolean was_grabbed);
-#endif
#define IDO_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_RANGE, IdoRangePrivate))
@@ -65,10 +61,6 @@ ido_range_class_init (IdoRangeClass *class)
gobject_class->set_property = ido_range_set_property;
gobject_class->get_property = ido_range_get_property;
-#ifdef USE_GTK3
- widget_class->grab_notify = ido_range_grab_notify;
-#endif
-
g_object_class_install_property (gobject_class,
PROP_STYLE,
g_param_spec_enum ("range-style",
@@ -139,21 +131,6 @@ ido_range_set_property (GObject *object,
}
}
-#ifdef USE_GTK3
-static void
-ido_range_grab_notify (GtkWidget *widget, gboolean was_grabbed)
-{
- /*
- * FIXME: workaround for lp bug #865122.
- * Without this handler, GtkRange will call remove_grab which results
- * in an infinite loop of grab_notifies.
- *
- * The widget will still work properly, because grab-broken-event will get
- * properly fired and internal state of GtkRange will be properly updated.
- */
-}
-#endif
-
static void
ido_range_constructed (GObject *object)
{
@@ -176,16 +153,6 @@ ido_range_constructed (GObject *object)
"knob-width", &width,
"knob-height", &height,
NULL);
-
-#ifndef USE_GTK3
- g_snprintf (buf, sizeof (buf),
- "style \"ido-range\" {\n"
- " GtkRange::slider-width = %d\n"
- " GtkScale::slider-length = %d\n"
- "} widget \"*.idorange-%p\" style \"ido-range\"\n",
- width, height, range);
- gtk_rc_parse_string (buf);
-#endif
}
gtk_range_set_slider_size_fixed (GTK_RANGE (range), TRUE);
diff --git a/src/idorange.h b/src/idorange.h
index 0dd6952..7c2e79b 100644
--- a/src/idorange.h
+++ b/src/idorange.h
@@ -28,6 +28,8 @@
#include <gtk/gtk.h>
+G_BEGIN_DECLS
+
#define IDO_TYPE_RANGE (ido_range_get_type ())
#define IDO_RANGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_RANGE, IdoRange))
#define IDO_RANGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), IDO_TYPE_RANGE, IdoRangeClass))
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c
index 499c28f..986d9a7 100644
--- a/src/idoscalemenuitem.c
+++ b/src/idoscalemenuitem.c
@@ -144,27 +144,15 @@ ido_scale_menu_item_size_allocate (GtkWidget *widget,
switch (priv->style)
{
case IDO_SCALE_MENU_ITEM_STYLE_IMAGE:
-#ifdef USE_GTK3
gtk_widget_get_preferred_size (priv->primary_image, &primary_req, NULL);
gtk_widget_get_preferred_size (priv->secondary_image, &secondary_req, NULL);
-#else
- gtk_widget_get_child_requisition (priv->primary_image, &primary_req);
- gtk_widget_get_child_requisition (priv->secondary_image, &secondary_req);
-#endif
-
primary_padding = gtk_widget_get_visible (priv->primary_image) ? primary_req.width : 0;
secondary_padding = gtk_widget_get_visible (priv->secondary_image) ? secondary_req.width : 0;
break;
case IDO_SCALE_MENU_ITEM_STYLE_LABEL:
-#ifdef USE_GTK3
gtk_widget_get_preferred_size (priv->primary_label, &primary_req, NULL);
gtk_widget_get_preferred_size (priv->secondary_label, &secondary_req, NULL);
-#else
- gtk_widget_get_child_requisition (priv->primary_label, &primary_req);
- gtk_widget_get_child_requisition (priv->secondary_label, &secondary_req);
-#endif
-
primary_padding = gtk_widget_get_visible (priv->primary_label) ? primary_req.width : 0;
secondary_padding = gtk_widget_get_visible (priv->secondary_label) ? secondary_req.width : 0;
break;
@@ -236,11 +224,7 @@ ido_scale_menu_item_constructed (GObject *object)
g_object_ref (priv->scale);
gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE);
-#ifdef USE_GTK3
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- hbox = gtk_hbox_new (FALSE, 0);
-#endif
priv->primary_image = gtk_image_new ();
g_signal_connect (priv->primary_image, "notify",
@@ -485,10 +469,6 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem,
IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
gdouble x;
-#ifndef USE_GTK3
- GtkWidget *scale = priv->scale;
-#endif
-
// can we block emissions of "grab-notify" on parent??
translate_event_coordinates (menuitem, event->x, &x);
@@ -497,28 +477,16 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem,
translate_event_coordinates (menuitem, event->x_root, &x);
event->x_root = x;
-#ifndef USE_GTK3
- ubuntu_gtk_widget_set_has_grab (scale, TRUE);
-#endif
-
gtk_widget_event (priv->scale,
((GdkEvent *)(void*)(event)));
-#ifndef USE_GTK3
- ubuntu_gtk_widget_set_has_grab (scale, FALSE);
-#endif
-
if (!priv->grabbed)
{
priv->grabbed = TRUE;
g_signal_emit (menuitem, signals[SLIDER_GRABBED], 0);
}
-#ifdef USE_GTK3
return FALSE;
-#else
- return TRUE;
-#endif
}
static gboolean
diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c
new file mode 100644
index 0000000..3831336
--- /dev/null
+++ b/src/idoswitchmenuitem.c
@@ -0,0 +1,120 @@
+/*
+ * A GtkCheckMenuItem that uses a GtkSwitch to show its 'active' property
+ *
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#include "config.h"
+
+#include "idoswitchmenuitem.h"
+
+static gboolean ido_switch_menu_button_release_event (GtkWidget * widget,
+ GdkEventButton * event);
+
+
+struct _IdoSwitchMenuItemPrivate
+{
+ GtkWidget * box;
+ GtkWidget * content_area;
+ GtkWidget * switch_w;
+};
+
+/***
+**** Life Cycle
+***/
+
+G_DEFINE_TYPE (IdoSwitchMenuItem, ido_switch_menu_item, GTK_TYPE_CHECK_MENU_ITEM)
+
+static void
+ido_switch_menu_item_class_init (IdoSwitchMenuItemClass *klass)
+{
+ GObjectClass * gobject_class;
+ GtkWidgetClass * widget_class;
+ GtkCheckMenuItemClass * check_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (gobject_class, sizeof (IdoSwitchMenuItemPrivate));
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->button_release_event = ido_switch_menu_button_release_event;
+
+ check_class = GTK_CHECK_MENU_ITEM_CLASS (klass);
+ check_class->draw_indicator = NULL;
+}
+
+static void
+ido_switch_menu_item_init (IdoSwitchMenuItem *item)
+{
+ IdoSwitchMenuItemPrivate *priv;
+
+ priv = item->priv = G_TYPE_INSTANCE_GET_PRIVATE (item, IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemPrivate);
+ priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ priv->content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ priv->switch_w = gtk_switch_new ();
+
+ gtk_box_pack_start (GTK_BOX (priv->box), priv->content_area, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (priv->box), priv->switch_w, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (item), priv->box);
+ gtk_widget_show_all (priv->box);
+
+ g_object_bind_property (item, "active",
+ priv->switch_w, "active",
+ G_BINDING_SYNC_CREATE);
+}
+
+/***
+**** Don't popdown the menu immediately after clicking on a switch...
+**** wait a moment so the user can see the GtkSwitch be toggled.
+***/
+
+static gboolean
+popdown_later_cb (gpointer widget)
+{
+ GtkWidget * parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU (parent))
+ {
+ gtk_menu_shell_deactivate (GTK_MENU_SHELL(parent));
+ }
+ g_object_unref (widget);
+ return FALSE; /* only call this cb once */
+}
+
+static gboolean
+ido_switch_menu_button_release_event (GtkWidget * widget, GdkEventButton * event)
+{
+ gtk_menu_item_activate (GTK_MENU_ITEM(widget));
+ g_timeout_add (500, popdown_later_cb, g_object_ref(widget));
+ return TRUE; /* stop the event so that it doesn't trigger popdown() */
+}
+
+/***
+**** Public API
+***/
+
+GtkWidget *
+ido_switch_menu_item_new (void)
+{
+ return g_object_new (IDO_TYPE_SWITCH_MENU_ITEM, NULL);
+}
+
+GtkContainer *
+ido_switch_menu_item_get_content_area (IdoSwitchMenuItem * item)
+{
+ g_return_val_if_fail (IDO_IS_SWITCH_MENU_ITEM(item), NULL);
+
+ return GTK_CONTAINER (item->priv->content_area);
+}
diff --git a/src/idoswitchmenuitem.h b/src/idoswitchmenuitem.h
new file mode 100644
index 0000000..7e7e2d2
--- /dev/null
+++ b/src/idoswitchmenuitem.h
@@ -0,0 +1,57 @@
+/*
+ * A GtkCheckMenuItem that uses a GtkSwitch to show its 'active' property.
+ *
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef __IDO_SWITCH_MENU_ITEM_H__
+#define __IDO_SWITCH_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define IDO_TYPE_SWITCH_MENU_ITEM (ido_switch_menu_item_get_type ())
+#define IDO_SWITCH_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItem))
+#define IDO_SWITCH_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemClass))
+#define IDO_IS_SWITCH_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), IDO_TYPE_SWITCH_MENU_ITEM))
+#define IDO_IS_SWITCH_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), IDO_TYPE_SWITCH_MENU_ITEM))
+#define IDO_SWITCH_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemClass))
+
+typedef struct _IdoSwitchMenuItem IdoSwitchMenuItem;
+typedef struct _IdoSwitchMenuItemClass IdoSwitchMenuItemClass;
+typedef struct _IdoSwitchMenuItemPrivate IdoSwitchMenuItemPrivate;
+
+struct _IdoSwitchMenuItem
+{
+ GtkCheckMenuItem parent_instance;
+
+ IdoSwitchMenuItemPrivate *priv;
+};
+
+struct _IdoSwitchMenuItemClass
+{
+ GtkCheckMenuItemClass parent_class;
+};
+
+GType ido_switch_menu_item_get_type (void) G_GNUC_CONST;
+GtkWidget *ido_switch_menu_item_new (void);
+GtkContainer *ido_switch_menu_item_get_content_area (IdoSwitchMenuItem * item);
+
+G_END_DECLS
+
+#endif /* __IDO_SWITCH_MENU_ITEM_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..89b9b5b
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,47 @@
+VER=3
+IDOLIB = $(top_builddir)/src/libido3-0.1.la
+
+check_LIBRARIES = libgtest.a
+check_PROGRAMS =
+TESTS =
+
+AM_CPPFLAGS = \
+ $(GTEST_CPPFLAGS) \
+ -I${top_srcdir}/src
+
+#############################
+# Google Test base library
+#############################
+
+nodist_libgtest_a_SOURCES = \
+ $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp \
+ $(GTEST_SOURCE)/src/gtest-all.cc \
+ $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp
+libgtest_a_CPPFLAGS = \
+ $(XORG_GTEST_CPPFLAGS) \
+ $(AM_CPPFLAGS) \
+ $(GTEST_CPPFLAGS) -w
+libgtest_a_CXXFLAGS = \
+ $(AM_CXXFLAGS)
+
+#############################
+# Menuitem tests
+#############################
+
+TESTS += gtest-menuitems
+check_PROGRAMS += gtest-menuitems
+
+gtest_menuitems_SOURCES = \
+ gtest-menuitems.cpp
+gtest_menuitems_CPPFLAGS = \
+ $(GCC_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(MAINTAINER_CFLAGS) \
+ $(AM_CPPFLAGS)
+gtest_menuitems_LDFLAGS = \
+ -pthread
+gtest_menuitems_LDADD = \
+ $(GTK_LIBS) \
+ $(IDOLIB) \
+ libgtest.a
+
diff --git a/tests/gtest-menuitems.cpp b/tests/gtest-menuitems.cpp
new file mode 100644
index 0000000..269d360
--- /dev/null
+++ b/tests/gtest-menuitems.cpp
@@ -0,0 +1,102 @@
+
+#include <gtk/gtk.h>
+#include <gtest/gtest.h>
+#include "idocalendarmenuitem.h"
+#include "idoentrymenuitem.h"
+#include "idoscalemenuitem.h"
+
+class TestMenuitems : public ::testing::Test
+{
+public:
+ TestMenuitems()
+ {
+ gint argc = 0;
+ gchar * argv[] = {NULL};
+ gtk_init(&argc, (gchar ***)&argv);
+ return;
+ }
+};
+
+TEST_F(TestMenuitems, BuildCalendar) {
+ GtkWidget * cal = ido_calendar_menu_item_new();
+
+ EXPECT_TRUE(cal != NULL);
+ EXPECT_TRUE(IDO_IS_CALENDAR_MENU_ITEM(cal));
+ EXPECT_TRUE(GTK_IS_MENU_ITEM(cal));
+
+ GtkWidget * menu = gtk_menu_new();
+ gtk_widget_show(menu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), cal);
+
+ gtk_widget_show(cal);
+ gtk_widget_realize(cal);
+
+ EXPECT_TRUE(gtk_widget_get_realized(cal));
+
+ g_object_ref_sink(menu);
+ g_object_unref(menu);
+ return;
+}
+
+TEST_F(TestMenuitems, BuildEntry) {
+ GtkWidget * entry = ido_entry_menu_item_new();
+
+ EXPECT_TRUE(entry != NULL);
+ EXPECT_TRUE(IDO_IS_ENTRY_MENU_ITEM(entry));
+ EXPECT_TRUE(GTK_IS_MENU_ITEM(entry));
+
+ GtkWidget * menu = gtk_menu_new();
+ gtk_widget_show(menu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
+
+ gtk_widget_show(entry);
+ gtk_widget_realize(entry);
+
+ EXPECT_TRUE(gtk_widget_get_realized(entry));
+
+ g_object_ref_sink(menu);
+ g_object_unref(menu);
+ return;
+}
+
+TEST_F(TestMenuitems, BuildScaleDefault) {
+ GtkWidget * scale = ido_scale_menu_item_new("Label", IDO_RANGE_STYLE_DEFAULT, gtk_adjustment_new(0.5, 0.0, 1.0, 0.01, 0.1, 0.1));
+
+ EXPECT_TRUE(scale != NULL);
+ EXPECT_TRUE(IDO_IS_SCALE_MENU_ITEM(scale));
+ EXPECT_TRUE(GTK_IS_MENU_ITEM(scale));
+
+ GtkWidget * menu = gtk_menu_new();
+ gtk_widget_show(menu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), scale);
+
+ gtk_widget_show(scale);
+ gtk_widget_realize(scale);
+
+ EXPECT_TRUE(gtk_widget_get_realized(scale));
+
+ g_object_ref_sink(menu);
+ g_object_unref(menu);
+ return;
+}
+
+TEST_F(TestMenuitems, BuildScaleSmall) {
+ GtkWidget * scale = ido_scale_menu_item_new("Label", IDO_RANGE_STYLE_SMALL, gtk_adjustment_new(0.5, 0.0, 1.0, 0.01, 0.1, 0.1));
+
+ EXPECT_TRUE(scale != NULL);
+ EXPECT_TRUE(IDO_IS_SCALE_MENU_ITEM(scale));
+ EXPECT_TRUE(GTK_IS_MENU_ITEM(scale));
+
+ GtkWidget * menu = gtk_menu_new();
+ gtk_widget_show(menu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), scale);
+
+ gtk_widget_show(scale);
+ gtk_widget_realize(scale);
+
+ EXPECT_TRUE(gtk_widget_get_realized(scale));
+
+ g_object_ref_sink(menu);
+ g_object_unref(menu);
+ return;
+}