diff options
Diffstat (limited to 'widgets')
32 files changed, 4438 insertions, 0 deletions
diff --git a/widgets/Makefile.am b/widgets/Makefile.am new file mode 100644 index 000000000..a22ac9715 --- /dev/null +++ b/widgets/Makefile.am @@ -0,0 +1,30 @@ +# Makefile.am for anaconda widgets +# +# Copyright (C) 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY 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, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# + +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src python glade doc + +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in config.sub \ + depcomp gtk-doc.make install-sh ltmain.sh missing + +run-glade: + LD_LIBRARY_PATH=src/.libs GLADE_CATALOG_PATH=glade GLADE_MODULE_PATH=src/.libs glade diff --git a/widgets/TODO b/widgets/TODO new file mode 100644 index 000000000..e555245a3 --- /dev/null +++ b/widgets/TODO @@ -0,0 +1,33 @@ +BaseWindow - + +DiskOverview - + - add utilization pie chart + - need to specify big vs. small + +SpokeSelector - + - need to show incompleteness + +SpokeWindow - + +StandaloneWindow - + +New Widgets - + - light box dialog + - PersonalizationWindow + - physical member display + - capacity slider+drop down + - software RAID overview (#9-3-1, RAID tab, left side) + - disk viewer (shaded bars on #9-3-1) + - partition bar (colored bar part on #9-3-1) + - accordion on #9-3-1 + +glade Integration - + - add icons + - audit all widgets for which signals and properties should be exposed in glade UI + +Build - + +Misc - + - add test cases + - coding standard document + - should widgets use CSS instead of hardcoding things? diff --git a/widgets/autogen.sh b/widgets/autogen.sh new file mode 100755 index 000000000..7fdb21167 --- /dev/null +++ b/widgets/autogen.sh @@ -0,0 +1,10 @@ +#!/bin/bash +aclocal -I m4 +libtoolize --copy --force +gtkdocize +autoconf +autoheader +touch config.h.in +automake --foreign --add-missing --copy +rm -rf autom4te.cache +ln -sf /usr/share/gettext/gettext.h src diff --git a/widgets/config.rpath b/widgets/config.rpath new file mode 100755 index 000000000..17298f234 --- /dev/null +++ b/widgets/config.rpath @@ -0,0 +1,672 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2010 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's _LT_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32* | cegcc*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix[4-9]*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32* | cegcc*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF + +# How to pass a linker flag through the compiler. +wl="$escaped_wl" + +# Static library suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally "so"). +shlibext="$shlibext" + +# Format of library name prefix. +libname_spec="$escaped_libname_spec" + +# Library names that the linker finds when passed -lNAME. +library_names_spec="$escaped_library_names_spec" + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator="$hardcode_libdir_separator" + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct="$hardcode_direct" + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L="$hardcode_minus_L" + +EOF diff --git a/widgets/configure.ac b/widgets/configure.ac new file mode 100644 index 000000000..03e465afc --- /dev/null +++ b/widgets/configure.ac @@ -0,0 +1,60 @@ +# configure.ac for anaconda widgets +# +# Copyright (C) 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY 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, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# + +AC_PREREQ([2.63]) +AC_INIT([AnacondaWidgets], [1.0], [clumens@redhat.com]) +AM_INIT_AUTOMAKE(AnacondaWidgets, 1.0) +AM_SILENT_RULES([yes]) + +AM_PATH_PYTHON + +AC_CONFIG_SRCDIR([src/BaseWindow.c]) +AC_CONFIG_HEADERS([config.h]) + +AC_CONFIG_MACRO_DIR([m4]) + +AC_PROG_CC +AC_PROG_CXX +AC_PROG_LIBTOOL +AC_PROG_LN_S + +GOBJECT_INTROSPECTION_CHECK([0.6.7]) + +m4_ifdef([GTK_DOC_CHECK], [ +GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) +],[ +AM_CONDITIONAL([ENABLE_GTK_DOC], false) +]) + +PKG_PROG_PKG_CONFIG +PKG_CHECK_MODULES([GLADEUI], [gladeui-2.0 >= 3.10]) +PKG_CHECK_MODULES([GTK], [gtk+-x11-3.0 >= 3.0]) +PKG_CHECK_MODULES([GLIB], [glib-2.0]) +PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.30]) + +AC_CHECK_HEADERS([string.h]) + +AC_CONFIG_FILES([Makefile + doc/Makefile + glade/Makefile + src/Makefile + python/Makefile]) +AC_OUTPUT diff --git a/widgets/doc/AnacondaWidgets-docs.xml b/widgets/doc/AnacondaWidgets-docs.xml new file mode 100644 index 000000000..730c13a01 --- /dev/null +++ b/widgets/doc/AnacondaWidgets-docs.xml @@ -0,0 +1,51 @@ +<?xml version="1.0"?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [ +<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> +]> + +<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude"> + <bookinfo> + <title>The AnacondaWidgets Library Reference Manual</title> + + <authorgroup> + <author> + <firstname>Chris</firstname> + <surname>Lumens</surname> + <affiliation> + <address> + <email>clumens@redhat.com</email> + </address> + </affiliation> + </author> + </authorgroup> + </bookinfo> + + <chapter id="windows"> + <title>Window Widgets</title> + <xi:include href="xml/BaseWindow.xml" /> + <xi:include href="xml/HubWindow.xml" /> + <xi:include href="xml/SpokeWindow.xml" /> + <xi:include href="xml/StandaloneWindow.xml" /> + </chapter> + + <chapter id="disks"> + <title>Disk-Related Widgets</title> + <xi:include href="xml/DiskOverview.xml" /> + </chapter> + + <chapter id="miscellaneous"> + <title>Miscellaneous Widgets</title> + <xi:include href="xml/SpokeSelector.xml" /> + </chapter> + + <chapter id="hierarchy"> + <title>Object Hierarchy</title> + <xi:include href="xml/tree_index.sgml" /> + </chapter> + + <index id="api-index-full"> + <title>Index</title> + <xi:include href="xml/api-index-full.xml" /> + </index> +</book> diff --git a/widgets/doc/Makefile.am b/widgets/doc/Makefile.am new file mode 100644 index 000000000..f4e0b5571 --- /dev/null +++ b/widgets/doc/Makefile.am @@ -0,0 +1,59 @@ +# Makefile.am for anaconda widget documentation +# +# Copyright (C) 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY 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, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# + +## Process this file with automake to produce Makefile.in + +# The name of the module. +DOC_MODULE=AnacondaWidgets + +# The top-level SGML file. +DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml + +# Directories containing the source code. +DOC_SOURCE_DIR=$(top_srcdir) + +# Header files to ignore while scanning. +IGNORE_HFILES = config.h \ + gettext.h \ + intl.h + +# Extra options to supply to gtkdoc-scan. +SCAN_OPTIONS=--rebuild-types + +# Extra options to supply to gtkdoc-mkdb +MKDB_OPTIONS=--sgml-mode + +# Only needed if you are using gtkdoc-scangobj to dynamically query widget +# signals and properties (which we are). +GTKDOC_CFLAGS=$(GLIB_CFLAGS) $(GTK_CFLAGS) +GTKDOC_LIBS=$(GLIB_LIBS) $(GTK_LIBS) -lAnacondaWidgets -L$(top_srcdir)/src + +include $(top_srcdir)/gtk-doc.make + +if ENABLE_GTK_DOC +TESTS_ENVIRONMENT = cd $(srcdir) && \ + DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ + SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) +#TESTS = $(GTKDOC_CHECK) +endif + +MAINTAINERCLEANFILES = AnacondaWidgets-overrides.txt AnacondaWidgets-sections.txt \ + AnacondaWidgets.types Makefile.in diff --git a/widgets/glade/AnacondaWidgets.xml b/widgets/glade/AnacondaWidgets.xml new file mode 100644 index 000000000..2a2fadb88 --- /dev/null +++ b/widgets/glade/AnacondaWidgets.xml @@ -0,0 +1,118 @@ +<glade-catalog name="AnacondaWidgets" + version="1.0" + library="AnacondaWidgets" + domain="glade-3" + depends="gtk+"> + + <glade-widget-classes> + <glade-widget-class title="Base Window" + name="AnacondaBaseWindow" + icon-name="widget-gtk-window" + generic-name="AnacondaBaseWindow" + use-placeholders="True" + toplevel="True"> + <properties> + <property id="default-width" disabled="True" /> + <property id="default-height" disabled="True" /> + <property id="height-request" disabled="True" /> + <property id="modal" disabled="True" /> + <property id="resizable" disabled="True" /> + <property id="startup-id" visible="False" /> + <property id="title" disabled="True" /> + <property id="type" disabled="True" /> + <property id="width-request" disabled="True" /> + </properties> + </glade-widget-class> + + <glade-widget-class title="Standalone Spoke Window" + name="AnacondaStandaloneWindow" + icon-name="widget-gtk-window" + generic-name="AnacondaStandaloneWindow" + use-placeholders="True" + toplevel="True"> + <post-create-function>anaconda_standalone_window_post_create</post-create-function> + <write-widget-function>anaconda_standalone_window_write_widget</write-widget-function> + + <internal-children> + <object name="action_area" /> + </internal-children> + </glade-widget-class> + + <glade-widget-class title="Hub Window" + name="AnacondaHubWindow" + icon-name="widget-gtk-window" + generic-name="AnacondaHubWindow" + use-placeholders="True" + toplevel="True"> + <!-- Not a typo - we really can use the same functions here (for now) --> + <post-create-function>anaconda_standalone_window_post_create</post-create-function> + <write-widget-function>anaconda_standalone_window_write_widget</write-widget-function> + + <internal-children> + <object name="action_area"> + <object name="scrolled_window" /> + </object> + </internal-children> + </glade-widget-class> + + <glade-widget-class title="Spoke Window" + name="AnacondaSpokeWindow" + icon-name="widget-gtk-window" + generic-name="AnacondaSpokeWindow" + use-placeholders="True" + toplevel="True"> + <!-- Not a typo - we really can use the same functions here (for now) --> + <post-create-function>anaconda_standalone_window_post_create</post-create-function> + <write-widget-function>anaconda_standalone_window_write_widget</write-widget-function> + + <internal-children> + <object name="action_area" /> + </internal-children> + </glade-widget-class> + + <glade-widget-class title="Spoke Selector" + name="AnacondaSpokeSelector" + icon-name="widget-gtk-grid" + generic-name="AnacondaSpokeSelector"> + <properties> + <property id="column-spacing" default="6" visible="False" /> + + <property since="1.0" themed-icon="True" id="icon" name="Icon" default="gtk-missing-image" visible="True"> + <parameter-spec> + <type>GParamString</type> + </parameter-spec> + </property> + </properties> + </glade-widget-class> + + <glade-widget-class title="Disk Overview" + name="AnacondaDiskOverview" + icon-name="widget-gtk-vbox" + generic-name="AnacondaDiskOverview"> + <properties> + <property id="size" query="False" default="4" visible="False" /> + <property id="spacing" default="6" visible="False" /> + + <property since="1.0" themed-icon="True" id="kind" name="Kind" default="drive-harddisk" visible="True"> + <parameter-spec> + <type>GParamString</type> + </parameter-spec> + </property> + </properties> + </glade-widget-class> + </glade-widget-classes> + + <glade-widget-group name="anaconda-windows" title="Anaconda Windows"> + <glade-widget-class-ref name="AnacondaHubWindow" /> + <glade-widget-class-ref name="AnacondaStandaloneWindow" /> + <glade-widget-class-ref name="AnacondaSpokeWindow" /> + </glade-widget-group> + + <glade-widget-group name="anaconda-disk-widgets" title="Anaconda Disk Widgets"> + <glade-widget-class-ref name="AnacondaDiskOverview" /> + </glade-widget-group> + + <glade-widget-group name="anaconda-misc-widgets" title="Anaconda Miscellaneous Widgets"> + <glade-widget-class-ref name="AnacondaSpokeSelector" /> + </glade-widget-group> +</glade-catalog> diff --git a/widgets/glade/Makefile.am b/widgets/glade/Makefile.am new file mode 100644 index 000000000..a88814100 --- /dev/null +++ b/widgets/glade/Makefile.am @@ -0,0 +1,25 @@ +# Makefile.am for anaconda widget glade catalog +# +# Copyright (C) 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY 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, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# + +gladedir = $(datadir)/glade/catalogs +dist_glade_DATA = AnacondaWidgets.xml + +MAINTAINERCLEANFILES = Makefile.in diff --git a/widgets/m4/gettext.m4 b/widgets/m4/gettext.m4 new file mode 100644 index 000000000..f84e6a5d7 --- /dev/null +++ b/widgets/m4/gettext.m4 @@ -0,0 +1,383 @@ +# gettext.m4 serial 63 (gettext-0.18) +dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. +dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010. + +dnl Macro to add for using GNU gettext. + +dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). +dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The +dnl default (if it is not specified or empty) is 'no-libtool'. +dnl INTLSYMBOL should be 'external' for packages with no intl directory, +dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. +dnl If INTLSYMBOL is 'use-libtool', then a libtool library +dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, +dnl depending on --{enable,disable}-{shared,static} and on the presence of +dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library +dnl $(top_builddir)/intl/libintl.a will be created. +dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext +dnl implementations (in libc or libintl) without the ngettext() function +dnl will be ignored. If NEEDSYMBOL is specified and is +dnl 'need-formatstring-macros', then GNU gettext implementations that don't +dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored. +dnl INTLDIR is used to find the intl libraries. If empty, +dnl the value `$(top_builddir)/intl/' is used. +dnl +dnl The result of the configuration is one of three cases: +dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled +dnl and used. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], + [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define([gt_included_intl], + ifelse([$1], [external], + ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), + [yes])) + define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) + gt_NEEDS_INIT + AM_GNU_GETTEXT_NEED([$2]) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. + gt_INTL_MACOSX + + dnl Set USE_NLS. + AC_REQUIRE([AM_NLS]) + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl Add a version number to the cache macros. + case " $gt_needs " in + *" need-formatstring-macros "*) gt_api_version=3 ;; + *" need-ngettext "*) gt_api_version=2 ;; + *) gt_api_version=1 ;; + esac + gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" + gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH([included-gettext], + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + if test $gt_api_version -ge 3; then + gt_revision_test_code=' +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +' + else + gt_revision_test_code= + fi + if test $gt_api_version -ge 2; then + gt_expression_test_code=' + * ngettext ("", "", 0)' + else + gt_expression_test_code= + fi + + AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], + [AC_TRY_LINK([#include <libintl.h> +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], + [eval "$gt_func_gnugettext_libc=yes"], + [eval "$gt_func_gnugettext_libc=no"])]) + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + [$gt_func_gnugettext_libintl], + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_TRY_LINK([#include <libintl.h> +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [eval "$gt_func_gnugettext_libintl=yes"], + [eval "$gt_func_gnugettext_libintl=no"]) + dnl Now see whether libintl exists and depends on libiconv. + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include <libintl.h> +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ + || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + CATOBJEXT= + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test -n "$INTL_MACOSX_LIBS"; then + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Some extra flags are needed during linking. + LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" + LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" + fi + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE([ENABLE_NLS], [1], + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE([HAVE_GETTEXT], [1], + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE([HAVE_DCGETTEXT], [1], + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST([BUILD_INCLUDED_LIBINTL]) + AC_SUBST([USE_INCLUDED_LIBINTL]) + AC_SUBST([CATOBJEXT]) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST([DATADIRNAME]) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST([INSTOBJEXT]) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST([GENCAT]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLOBJS= + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST([INTLOBJS]) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST([INTLLIBS]) + + dnl Make all documented variables known to autoconf. + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + AC_SUBST([POSUB]) +]) + + +dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. +m4_define([gt_NEEDS_INIT], +[ + m4_divert_text([DEFAULTS], [gt_needs=]) + m4_define([gt_NEEDS_INIT], []) +]) + + +dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) +AC_DEFUN([AM_GNU_GETTEXT_NEED], +[ + m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) diff --git a/widgets/m4/iconv.m4 b/widgets/m4/iconv.m4 new file mode 100644 index 000000000..e2041b9b4 --- /dev/null +++ b/widgets/m4/iconv.m4 @@ -0,0 +1,214 @@ +# iconv.m4 serial 11 (gettext-0.18.1) +dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include <stdlib.h> +#include <iconv.h>], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [am_cv_func_iconv=yes]) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include <stdlib.h> +#include <iconv.h>], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + AC_TRY_RUN([ +#include <iconv.h> +#include <string.h> +int main () +{ + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + return 1; + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + return 1; + return 0; +}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], + [case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac]) + LIBS="$am_save_LIBS" + ]) + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + AC_DEFINE([HAVE_ICONV], [1], + [Define if you have the iconv() function and it works.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) +]) + +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])) +gl_iconv_AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_TRY_COMPILE([ +#include <stdlib.h> +#include <iconv.h> +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([ + $am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + [Define as const if the declaration of iconv() needs const.]) + fi +]) diff --git a/widgets/m4/introspection.m4 b/widgets/m4/introspection.m4 new file mode 100644 index 000000000..589721c5a --- /dev/null +++ b/widgets/m4/introspection.m4 @@ -0,0 +1,94 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) diff --git a/widgets/m4/nls.m4 b/widgets/m4/nls.m4 new file mode 100644 index 000000000..003704c4b --- /dev/null +++ b/widgets/m4/nls.m4 @@ -0,0 +1,32 @@ +# nls.m4 serial 5 (gettext-0.18) +dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. +dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003. + +AC_PREREQ([2.50]) + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE([nls], + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT([$USE_NLS]) + AC_SUBST([USE_NLS]) +]) diff --git a/widgets/m4/pkg.m4 b/widgets/m4/pkg.m4 new file mode 100644 index 000000000..73973f748 --- /dev/null +++ b/widgets/m4/pkg.m4 @@ -0,0 +1,157 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT]) + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see <http://pkg-config.freedesktop.org/>.]) + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])# PKG_CHECK_MODULES diff --git a/widgets/m4/po.m4 b/widgets/m4/po.m4 new file mode 100644 index 000000000..47f36a41a --- /dev/null +++ b/widgets/m4/po.m4 @@ -0,0 +1,449 @@ +# po.m4 serial 17 (gettext-0.18) +dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. +dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003. + +AC_PREREQ([2.50]) + +dnl Checks for all prerequisites of the po subdirectory. +AC_DEFUN([AM_PO_SUBDIRS], +[ + AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + AC_REQUIRE([AM_NLS])dnl + + dnl Release version of the gettext macros. This is used to ensure that + dnl the gettext macros and po/Makefile.in.in are in sync. + AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) + + dnl Perform the following tests also if --disable-nls has been given, + dnl because they are needed for "make dist" to work. + + dnl Search for GNU msgfmt in the PATH. + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) + + dnl Test whether it is GNU msgfmt >= 0.15. +changequote(,)dnl + case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; + *) MSGFMT_015=$MSGFMT ;; + esac +changequote([,])dnl + AC_SUBST([MSGFMT_015]) +changequote(,)dnl + case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; + *) GMSGFMT_015=$GMSGFMT ;; + esac +changequote([,])dnl + AC_SUBST([GMSGFMT_015]) + + dnl Search for GNU xgettext 0.12 or newer in the PATH. + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + dnl Test whether it is GNU xgettext >= 0.15. +changequote(,)dnl + case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; + *) XGETTEXT_015=$XGETTEXT ;; + esac +changequote([,])dnl + AC_SUBST([XGETTEXT_015]) + + dnl Search for GNU msgmerge 0.11 or newer in the PATH. + AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, + [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) + + dnl Installation directories. + dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we + dnl have to define it here, so that it can be used in po/Makefile. + test -n "$localedir" || localedir='${datadir}/locale' + AC_SUBST([localedir]) + + dnl Support for AM_XGETTEXT_OPTION. + test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= + AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) + + AC_CONFIG_COMMANDS([po-directories], [[ + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + # Treat a directory as a PO directory if and only if it has a + # POTFILES.in file. This allows packages to have multiple PO + # directories under different names or in different locations. + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done]], + [# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake < 1.5. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + ]) +]) + +dnl Postprocesses a Makefile in a directory containing PO files. +AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], +[ + # When this code is run, in config.status, two variables have already been + # set: + # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, + # - LINGUAS is the value of the environment variable LINGUAS at configure + # time. + +changequote(,)dnl + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + # Find a way to echo strings without interpreting backslash. + if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='echo' + else + if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='printf %s\n' + else + echo_func () { + cat <<EOT +$* +EOT + } + gt_echo='echo_func' + fi + fi + + # A sed script that extracts the value of VARIABLE from a Makefile. + sed_x_variable=' +# Test if the hold space is empty. +x +s/P/P/ +x +ta +# Yes it was empty. Look if we have the expected variable definition. +/^[ ]*VARIABLE[ ]*=/{ + # Seen the first line of the variable definition. + s/^[ ]*VARIABLE[ ]*=// + ba +} +bd +:a +# Here we are processing a line from the variable definition. +# Remove comment, more precisely replace it with a space. +s/#.*$/ / +# See if the line ends in a backslash. +tb +:b +s/\\$// +# Print the line, without the trailing backslash. +p +tc +# There was no trailing backslash. The end of the variable definition is +# reached. Clear the hold space. +s/^.*$// +x +bd +:c +# A trailing backslash means that the variable definition continues in the +# next line. Put a nonempty string into the hold space to indicate this. +s/^.*$/P/ +x +:d +' +changequote([,])dnl + + # Set POTFILES to the value of the Makefile variable POTFILES. + sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'` + POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"` + # Compute POTFILES_DEPS as + # $(foreach file, $(POTFILES), $(top_srcdir)/$(file)) + POTFILES_DEPS= + for file in $POTFILES; do + POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file" + done + POMAKEFILEDEPS="" + + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS. + sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'` + ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"` + fi + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + # Compute PROPERTIESFILES + # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties) + # Compute CLASSFILES + # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class) + # Compute QMFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm) + # Compute MSGFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg) + # Compute RESOURCESDLLFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + PROPERTIESFILES= + CLASSFILES= + QMFILES= + MSGFILES= + RESOURCESDLLFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties" + CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class" + QMFILES="$QMFILES $srcdirpre$lang.qm" + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg" + frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` + RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + JAVACATALOGS= + QTCATALOGS= + TCLCATALOGS= + CSHARPCATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties" + QTCATALOGS="$QTCATALOGS $lang.qm" + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg" + frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` + CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll" + done + fi + + sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp" + if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + cat >> "$ac_file.tmp" <<EOF +$frobbedlang.msg: $lang.po + @echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \ + \$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; } +EOF + done + fi + if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` + cat >> "$ac_file.tmp" <<EOF +$frobbedlang/\$(DOMAIN).resources.dll: $lang.po + @echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \ + \$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; } +EOF + done + fi + if test -n "$POMAKEFILEDEPS"; then + cat >> "$ac_file.tmp" <<EOF +Makefile: $POMAKEFILEDEPS +EOF + fi + mv "$ac_file.tmp" "$ac_file" +]) + +dnl Initializes the accumulator used by AM_XGETTEXT_OPTION. +AC_DEFUN([AM_XGETTEXT_OPTION_INIT], +[ + XGETTEXT_EXTRA_OPTIONS= +]) + +dnl Registers an option to be passed to xgettext in the po subdirectory. +AC_DEFUN([AM_XGETTEXT_OPTION], +[ + AC_REQUIRE([AM_XGETTEXT_OPTION_INIT]) + XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1" +]) diff --git a/widgets/python/AnacondaWidgets.py b/widgets/python/AnacondaWidgets.py new file mode 100644 index 000000000..a13c0d847 --- /dev/null +++ b/widgets/python/AnacondaWidgets.py @@ -0,0 +1,37 @@ +from ..importer import modules +from ..overrides import override + +Anaconda = modules['AnacondaWidgets']._introspection_module +__all__ = [] + +class SpokeSelector(Anaconda.SpokeSelector): + def __init__(self, title=None, icon=None, status=None): + Anaconda.SpokeSelector.__init__(self) + + if title: + self.set_property("title", title) + + if icon: + self.set_property("icon", icon) + + if status: + self.set_property("status", status) + +SpokeSelector = override(SpokeSelector) +__all__.append('SpokeSelector') + +class DiskOverview(Anaconda.DiskOverview): + def __init__(self, description, kind, capacity, os=None, popup=None): + Anaconda.DiskOverview.__init__(self) + self.set_property("description", description) + self.set_property("kind", kind) + self.set_property("capacity", capacity) + + if os: + self.set_property("os", os) + + if popup: + self.set_property("popup-info", popup) + +DiskOverview = override(DiskOverview) +__all__.append('DiskOverview') diff --git a/widgets/python/Makefile.am b/widgets/python/Makefile.am new file mode 100644 index 000000000..81910ec73 --- /dev/null +++ b/widgets/python/Makefile.am @@ -0,0 +1,25 @@ +# Makefile.am for anaconda widget python integration +# +# Copyright (C) 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY 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, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# + +overridesdir = $(shell python -c "import gi ; print gi._overridesdir") +dist_overrides_PYTHON = AnacondaWidgets.py + +MAINTAINERCLEANFILES = Makefile.in diff --git a/widgets/src/BaseWindow.c b/widgets/src/BaseWindow.c new file mode 100644 index 000000000..b050836d6 --- /dev/null +++ b/widgets/src/BaseWindow.c @@ -0,0 +1,318 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#include <string.h> + +#include "BaseWindow.h" +#include "intl.h" + +/** + * SECTION: BaseWindow + * @title: AnacondaBaseWindow + * @short_description: Top-level, non-resizeable window + * + * A #AnacondaBaseWindow is a top-level, non-resizeable window that contains + * other widgets and serves as the base class from which all other specialized + * Anaconda windows are derived. It is undecorated. + * + * The window consists of two areas: + * + * - A navigation area in the top of the screen, consisting of some basic + * information about what is being displayed and what is being installed. + * + * - An action area in the majority of the screen. This area is where + * subclasses should add their particular widgets. + * + * <refsect2 id="AnacondaBaseWindow-BUILDER-UI"><title>AnacondaBaseWindow as GtkBuildable</title> + * <para> + * The AnacondaBaseWindow implementation of the #GtkBuildable interface exposes + * the @action_area as an internal child with the name "action_area". + * </para> + * <example> + * <title>A <structname>AnacondaBaseWindow</structname> UI definition fragment.</title> + * <programlisting><![CDATA[ + * <object class="AnacondaBaseWindow" id="window1"> + * <child internal-child="action_area"> + * <object class="GtkVBox" id="vbox1"> + * <child> + * <object class="GtkLabel" id="label1"> + * <property name="label" translatable="yes">THIS IS ONE LABEL</property> + * </object> + * </child> + * <child> + * <object class="GtkLabel" id="label2"> + * <property name="label" translatable="yes">THIS IS ANOTHER LABEL</property> + * </object> + * </child> + * </object> + * </child> + * </object> + * ]]></programlisting> + * </example> + * </refsect2> + */ + +enum { + PROP_DISTRIBUTION = 1, + PROP_WINDOW_NAME +}; + +#define DEFAULT_DISTRIBUTION "DISTRIBUTION INSTALLATION" +#define DEFAULT_WINDOW_NAME "SPOKE NAME" + +struct _AnacondaBaseWindowPrivate { + gboolean is_beta; + GtkWidget *action_area; + GtkWidget *nav_area; + GtkWidget *name_label, *distro_label, *beta_label; +}; + +static void anaconda_base_window_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void anaconda_base_window_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void anaconda_base_window_buildable_init(GtkBuildableIface *iface); + +G_DEFINE_TYPE_WITH_CODE(AnacondaBaseWindow, anaconda_base_window, GTK_TYPE_WINDOW, + G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, anaconda_base_window_buildable_init)) + +static void anaconda_base_window_class_init(AnacondaBaseWindowClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->set_property = anaconda_base_window_set_property; + object_class->get_property = anaconda_base_window_get_property; + + /** + * AnacondaBaseWindow:distribution: + * + * The :distribution string is displayed in the upper right corner of all + * windows throughout installation. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_DISTRIBUTION, + g_param_spec_string("distribution", + P_("Distribution"), + P_("The distribution being installed"), + DEFAULT_DISTRIBUTION, + G_PARAM_READWRITE)); + + /** + * AnacondaBaseWindow:window-name: + * + * The name of the currently displayed window, displayed in the upper + * left corner of all windows with a title throughout installation. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_WINDOW_NAME, + g_param_spec_string("window-name", + P_("Window Name"), + P_("The name of this spoke"), + DEFAULT_WINDOW_NAME, + G_PARAM_READWRITE)); + + g_type_class_add_private(object_class, sizeof(AnacondaBaseWindowPrivate)); +} + +/** + * anaconda_base_window_new: + * + * Creates a new #AnacondaBaseWindow, which is a toplevel, non-resizeable + * window that contains other widgets. This is the base class for all other + * Anaconda windows and creates the window style that all windows will share. + * + * Returns: A new #AnacondaBaseWindow. + */ +GtkWidget *anaconda_base_window_new() { + return g_object_new(ANACONDA_TYPE_BASE_WINDOW, NULL); +} + +static void anaconda_base_window_init(AnacondaBaseWindow *win) { + char *markup; + + win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win, + ANACONDA_TYPE_BASE_WINDOW, + AnacondaBaseWindowPrivate); + + win->priv->is_beta = FALSE; + + /* Set properties on the parent (Gtk.Window) class. */ + gtk_window_set_decorated(GTK_WINDOW(win), FALSE); + gtk_window_maximize(GTK_WINDOW(win)); + gtk_container_set_border_width(GTK_CONTAINER(win), 6); + + win->priv->action_area = gtk_vbox_new(FALSE, 6); + + /* Create the navigation area. */ + win->priv->nav_area = gtk_grid_new(); + gtk_grid_set_row_homogeneous(GTK_GRID(win->priv->nav_area), FALSE); + gtk_grid_set_column_homogeneous(GTK_GRID(win->priv->nav_area), FALSE); + + /* Create the name label. */ + win->priv->name_label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span weight='bold'>%s</span>", _(DEFAULT_WINDOW_NAME)); + gtk_label_set_markup(GTK_LABEL(win->priv->name_label), markup); + g_free(markup); + gtk_misc_set_alignment(GTK_MISC(win->priv->name_label), 0, 0); + gtk_widget_set_hexpand(GTK_WIDGET(win->priv->name_label), TRUE); + + /* Create the distribution label. */ + win->priv->distro_label = gtk_label_new(_(DEFAULT_DISTRIBUTION)); + gtk_misc_set_alignment(GTK_MISC(win->priv->distro_label), 0, 0); + + /* Create the betanag label. */ + win->priv->beta_label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span foreground='red'>%s</span>", _("PRE-RELEASE / TESTING")); + gtk_label_set_markup(GTK_LABEL(win->priv->beta_label), markup); + g_free(markup); + gtk_misc_set_alignment(GTK_MISC(win->priv->beta_label), 0, 0); + gtk_widget_set_no_show_all(GTK_WIDGET(win->priv->beta_label), TRUE); + + /* Add everything to the nav area. */ + gtk_grid_attach(GTK_GRID(win->priv->nav_area), win->priv->name_label, 0, 0, 1, 1); + gtk_grid_attach(GTK_GRID(win->priv->nav_area), win->priv->distro_label, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(win->priv->nav_area), win->priv->beta_label, 1, 1, 1, 1); + + /* Put the grid into the action_area, and the action_area into the window. */ + gtk_box_pack_start(GTK_BOX(win->priv->action_area), GTK_WIDGET(win->priv->nav_area), FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(win->priv->action_area)); +} + +static void anaconda_base_window_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + AnacondaBaseWindow *widget = ANACONDA_BASE_WINDOW(object); + AnacondaBaseWindowPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_DISTRIBUTION: + g_value_set_string(value, gtk_label_get_text(GTK_LABEL(priv->distro_label))); + break; + + case PROP_WINDOW_NAME: + g_value_set_string(value, gtk_label_get_text(GTK_LABEL(priv->name_label))); + break; + } +} + +static void anaconda_base_window_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + AnacondaBaseWindow *widget = ANACONDA_BASE_WINDOW(object); + AnacondaBaseWindowPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_DISTRIBUTION: { + gtk_label_set_text(GTK_LABEL(priv->distro_label), g_value_get_string(value)); + break; + } + + case PROP_WINDOW_NAME: { + char *markup = g_markup_printf_escaped("<span weight='bold'>%s</span>", g_value_get_string(value)); + gtk_label_set_markup(GTK_LABEL(priv->name_label), markup); + g_free(markup); + break; + } + } +} + +/** + * anaconda_base_window_get_beta: + * @win: a #AnacondaBaseWindow + * + * Returns whether or not this window is set to display the betanag warning. + * + * Returns: Whether @win is set to display the betanag warning + * + * Since: 1.0 + */ +gboolean anaconda_base_window_get_beta(AnacondaBaseWindow *win) { + return win->priv->is_beta; +} + +/** + * anaconda_base_window_set_beta: + * @win: a #AnacondaBaseWindow + * @is_beta: %TRUE to display the betanag warning + * + * Sets up the window to display the betanag warning in red along the top of + * the screen. + * + * Since: 1.0 + */ +void anaconda_base_window_set_beta(AnacondaBaseWindow *win, gboolean is_beta) { + win->priv->is_beta = is_beta; + + if (is_beta) + gtk_widget_show(win->priv->beta_label); + else + gtk_widget_hide(win->priv->beta_label); +} + +/** + * anaconda_base_window_get_action_area: + * @win: a #AnacondaBaseWindow + * + * Returns the action area of @win. + * + * Returns: (transfer none): The action area + * + * Since: 1.0 + */ +GtkWidget *anaconda_base_window_get_action_area(AnacondaBaseWindow *win) { + return win->priv->action_area; +} + +/** + * anaconda_base_window_get_nav_area: + * @win: a #AnacondaBaseWindow + * + * Returns the navigation area of @win. + * + * Returns: (transfer none): The navigation area + * + * Since: 1.0 + */ +GtkWidget *anaconda_base_window_get_nav_area(AnacondaBaseWindow *win) { + return win->priv->nav_area; +} + +static GtkBuildableIface *parent_buildable_iface; + +static void +anaconda_base_window_buildable_add_child (GtkBuildable *window, + GtkBuilder *builder, + GObject *child, + const gchar *type) { + gtk_container_add(GTK_CONTAINER(anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(window))), + GTK_WIDGET(child)); +} + +static GObject * +anaconda_base_window_buildable_get_internal_child (GtkBuildable *buildable, + GtkBuilder *builder, + const gchar *childname) { + if (strcmp (childname, "action_area") == 0) + return G_OBJECT(anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(buildable))); + + return parent_buildable_iface->get_internal_child (buildable, builder, childname); +} + +static void anaconda_base_window_buildable_init (GtkBuildableIface *iface) { + parent_buildable_iface = g_type_interface_peek_parent (iface); + iface->add_child = anaconda_base_window_buildable_add_child; + iface->get_internal_child = anaconda_base_window_buildable_get_internal_child; +} diff --git a/widgets/src/BaseWindow.h b/widgets/src/BaseWindow.h new file mode 100644 index 000000000..088980400 --- /dev/null +++ b/widgets/src/BaseWindow.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _BASE_WINDOW_H +#define _BASE_WINDOW_H + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define ANACONDA_TYPE_BASE_WINDOW (anaconda_base_window_get_type()) +#define ANACONDA_BASE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANACONDA_TYPE_BASE_WINDOW, AnacondaBaseWindow)) +#define ANACONDA_IS_BASE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANACONDA_TYPE_BASE_WINDOW)) +#define ANACONDA_BASE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANACONDA_TYPE_BASE_WINDOW, AnacondaBaseWindowClass)) +#define ANACONDA_IS_BASE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANACONDA_TYPE_BASE_WINDOW)) +#define ANACONDA_BASE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANACONDA_TYPE_BASE_WINDOW, AnacondaBaseWindowClass)) + +typedef struct _AnacondaBaseWindow AnacondaBaseWindow; +typedef struct _AnacondaBaseWindowClass AnacondaBaseWindowClass; +typedef struct _AnacondaBaseWindowPrivate AnacondaBaseWindowPrivate; + +/** + * AnacondaBaseWindow: + * + * The AnacondaBaseWindow struct contains only private fields and should not + * be directly accessed. + */ +struct _AnacondaBaseWindow { + GtkWindow parent; + + /*< private >*/ + AnacondaBaseWindowPrivate *priv; +}; + +/** + * AnacondaBaseWindowClass: + * @parent_class: The object class structure needs to be the first element in + * the widget class structure in order for the class mechanism + * to work correctly. This allows a AnacondaBaseWindowClass + * pointer to be cast to a #GtkWindow pointer. + */ +struct _AnacondaBaseWindowClass { + GtkWindowClass parent_class; +}; + +GType anaconda_base_window_get_type (void); +GtkWidget *anaconda_base_window_new (); +gboolean anaconda_base_window_get_beta (AnacondaBaseWindow *win); +void anaconda_base_window_set_beta (AnacondaBaseWindow *win, gboolean is_beta); +GtkWidget *anaconda_base_window_get_action_area(AnacondaBaseWindow *win); +GtkWidget *anaconda_base_window_get_nav_area(AnacondaBaseWindow *win); + +G_END_DECLS + +#endif diff --git a/widgets/src/DiskOverview.c b/widgets/src/DiskOverview.c new file mode 100644 index 000000000..c8a90aba3 --- /dev/null +++ b/widgets/src/DiskOverview.c @@ -0,0 +1,347 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#include <string.h> + +#include "DiskOverview.h" +#include "intl.h" + +/** + * SECTION: DiskOverview + * @title: AnacondaDiskOverview + * @short_description: A widget that displays basic information about a disk + * + * A #AnacondaDiskOverview is a potentially selectable widget that displays a + * disk device's size, kind, and a prominant icon based on the kind of device. + * This widget can come in different sizes, depending on where it needs to be + * used. + * + * As a #AnacondaDiskOverview is a subclass of a #GtkEventBox, any signals + * may be caught. The #GtkWidget::button-press-event signal is already + * handled internally to change the background color, but may also be handled + * by user code in order to take some action based on the disk clicked upon. + */ +enum { + PROP_DESCRIPTION = 1, + PROP_KIND, + PROP_CAPACITY, + PROP_OS, + PROP_POPUP_INFO +}; + +/* Defaults for each property. */ +#define DEFAULT_DESCRIPTION "New Device" +#define DEFAULT_KIND "drive-harddisk" +#define DEFAULT_CAPACITY "0 MB" +#define DEFAULT_OS "" +#define DEFAULT_POPUP_INFO "" + +struct _AnacondaDiskOverviewPrivate { + GtkWidget *vbox; + GtkWidget *kind; + GtkWidget *description_label; + GtkWidget *capacity_label; + GtkWidget *os_label; + GtkWidget *tooltip; + + gboolean selected; +}; + +G_DEFINE_TYPE(AnacondaDiskOverview, anaconda_disk_overview, GTK_TYPE_EVENT_BOX) + +gboolean anaconda_disk_overview_clicked(AnacondaDiskOverview *widget, GdkEvent *event); +static void anaconda_disk_overview_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void anaconda_disk_overview_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); + +static void anaconda_disk_overview_class_init(AnacondaDiskOverviewClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->set_property = anaconda_disk_overview_set_property; + object_class->get_property = anaconda_disk_overview_get_property; + + /** + * AnacondaDiskOverview:kind: + * + * The :kind string specifies what type of disk device this is, used to + * figure out what icon to be displayed. This should be something like + * "drive-harddisk", "drive-removable-media", etc. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_KIND, + g_param_spec_string("kind", + P_("kind"), + P_("Drive kind icon"), + DEFAULT_KIND, + G_PARAM_READWRITE)); + + /** + * AnacondaDiskOverview:description: + * + * The :description string is a very basic description of the device + * and is displayed in bold letters under the icon. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_DESCRIPTION, + g_param_spec_string("description", + P_("Description"), + P_("The drive description"), + DEFAULT_DESCRIPTION, + G_PARAM_READWRITE)); + + /** + * AnacondaDiskOverview:capacity: + * + * The :capacity string is the total size of the disk, plus units. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_CAPACITY, + g_param_spec_string("capacity", + P_("Capacity"), + P_("The drive size (including units)"), + DEFAULT_CAPACITY, + G_PARAM_READWRITE)); + + /** + * AnacondaDiskOverview:os: + * + * The :os string describes any operating system found on this device. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_OS, + g_param_spec_string("os", + P_("Operating System"), + P_("Installed OS on this drive"), + DEFAULT_OS, + G_PARAM_READWRITE)); + + /** + * AnacondaDiskOverview:popup-info: + * + * The :popup-info string is text that should appear in a tooltip when the + * #AnacondaDiskOverview is hovered over. For normal disk devices, this + * could be available space information. For more complex devics, this + * could be WWID, LUN, and so forth. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_POPUP_INFO, + g_param_spec_string("popup-info", + P_("Detailed Disk Information"), + P_("Tooltip information for this drive"), + DEFAULT_POPUP_INFO, + G_PARAM_READWRITE)); + + g_type_class_add_private(object_class, sizeof(AnacondaDiskOverviewPrivate)); +} + +/** + * anaconda_disk_overview_new: + * + * Creates a new #AnacondaDiskOverview, which is a potentially selectable + * widget that displays basic information about a single storage device, be + * that a regular disk or a more complicated network device. + * + * Returns: A new #AnacondaDiskOverview. + */ +GtkWidget *anaconda_disk_overview_new() { + return g_object_new(ANACONDA_TYPE_DISK_OVERVIEW, NULL); +} + +/* Initialize the widgets in a newly allocated DiskOverview. */ +static void anaconda_disk_overview_init(AnacondaDiskOverview *widget) { + char *markup; + + widget->priv = G_TYPE_INSTANCE_GET_PRIVATE(widget, + ANACONDA_TYPE_DISK_OVERVIEW, + AnacondaDiskOverviewPrivate); + + /* Set some properties. */ + widget->priv->selected = FALSE; + + /* Create the vbox. */ + widget->priv->vbox = gtk_vbox_new(FALSE, 6); + + /* Create the capacity label. */ + widget->priv->capacity_label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span size='large'>%s</span>", DEFAULT_CAPACITY); + gtk_label_set_markup(GTK_LABEL(widget->priv->capacity_label), markup); + g_free(markup); + + /* Create the spoke's icon. */ + widget->priv->kind = gtk_image_new_from_icon_name(DEFAULT_KIND, GTK_ICON_SIZE_DIALOG); + gtk_image_set_pixel_size(GTK_IMAGE(widget->priv->kind), 200); + + /* Create the description label. */ + widget->priv->description_label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span weight='bold' size='large'>%s</span>", _(DEFAULT_DESCRIPTION)); + gtk_label_set_markup(GTK_LABEL(widget->priv->description_label), markup); + g_free(markup); + + /* Create the OS label. By default there is no operating system, so just + * create a new label here so we have a place for later, should an OS be + * specified. + */ + widget->priv->os_label = gtk_label_new(NULL); + + /* Add everything to the vbox, add the vbox to the widget. */ + gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->capacity_label); + gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->kind); + gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->description_label); + gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->os_label); + + gtk_container_add(GTK_CONTAINER(widget), widget->priv->vbox); + + /* We need to handle button-press-event in order to change the background color. */ + g_signal_connect(widget, "button-press-event", G_CALLBACK(anaconda_disk_overview_clicked), NULL); +} + +gboolean anaconda_disk_overview_clicked(AnacondaDiskOverview *widget, GdkEvent *event) { + GtkStateFlags new_state; + + /* This toggles whether the DiskOverview widget is selected or not. If it's selected, + * we then let GTK in on that secret and it'll render the background in whatever color + * the theme CSS says. + */ + new_state = gtk_widget_get_state_flags(GTK_WIDGET(widget)) & ~GTK_STATE_FLAG_SELECTED; + widget->priv->selected = !widget->priv->selected; + if (widget->priv->selected) + new_state |= GTK_STATE_FLAG_SELECTED; + + gtk_widget_set_state_flags(GTK_WIDGET(widget), new_state, TRUE); + + return FALSE; +} + +static void anaconda_disk_overview_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + AnacondaDiskOverview *widget = ANACONDA_DISK_OVERVIEW(object); + AnacondaDiskOverviewPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_DESCRIPTION: + g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->description_label))); + break; + + case PROP_KIND: + g_value_set_object (value, (GObject *)priv->kind); + break; + + case PROP_CAPACITY: + g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->capacity_label))); + break; + + case PROP_OS: + g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->os_label))); + break; + + case PROP_POPUP_INFO: + g_value_set_string (value, gtk_widget_get_tooltip_text(GTK_WIDGET(widget))); + break; + } +} + +static void anaconda_disk_overview_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + AnacondaDiskOverview *widget = ANACONDA_DISK_OVERVIEW(object); + AnacondaDiskOverviewPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_DESCRIPTION: { + char *markup = g_markup_printf_escaped("<span weight='bold' size='large'>%s</span>", g_value_get_string(value)); + gtk_label_set_markup(GTK_LABEL(priv->description_label), markup); + g_free(markup); + break; + } + + case PROP_KIND: + gtk_image_set_from_icon_name(GTK_IMAGE(priv->kind), g_value_get_string(value), GTK_ICON_SIZE_DIALOG); + gtk_image_set_pixel_size(GTK_IMAGE(priv->kind), 200); + break; + + case PROP_CAPACITY: { + char *markup = g_markup_printf_escaped("<span size='large'>%s</span>", DEFAULT_CAPACITY); + gtk_label_set_markup(GTK_LABEL(priv->capacity_label), markup); + g_free(markup); + break; + } + + case PROP_OS: { + /* If no OS is given, set the label to blank. This will prevent + * seeing a strange brown blob with no text in the middle of + * nowhere. + */ + if (!strcmp(g_value_get_string(value), "")) + gtk_label_set_text(GTK_LABEL(priv->os_label), NULL); + else { + char *markup = g_markup_printf_escaped("<span foreground='white' background='brown'>%s</span>", g_value_get_string(value)); + gtk_label_set_markup(GTK_LABEL(priv->os_label), markup); + g_free(markup); + break; + } + } + + case PROP_POPUP_INFO: { + if (!strcmp(g_value_get_string(value), "")) + gtk_widget_set_has_tooltip(GTK_WIDGET(widget), FALSE); + else { + gtk_widget_set_tooltip_text(GTK_WIDGET(widget), g_value_get_string(value)); + break; + } + } + } +} + +/** + * anaconda_disk_overview_get_selected: + * @widget: a #AnacondaDiskOverview + * + * Returns whether or not this disk has been selected by the user. + * + * Returns: Whether @widget has been selected. + * + * Since: 1.0 + */ +gboolean anaconda_disk_overview_get_selected(AnacondaDiskOverview *widget) { + return widget->priv->selected; +} + +/** + * anaconda_disk_overview_set_selected: + * @widget: a #AnacondaDiskOverview + * @is_selected: %TRUE if this disk is selected. + * + * Specifies whether the disk shown by this overview has been selected by + * the user for inclusion in installation. If so, a special background will + * be set as a visual indicator. + * + * Since: 1.0 + */ +void anaconda_disk_overview_set_selected(AnacondaDiskOverview *widget, gboolean is_selected) { + gboolean result; + + widget->priv->selected = is_selected; + g_signal_emit_by_name(widget, "button-press-event", &result); +} diff --git a/widgets/src/DiskOverview.h b/widgets/src/DiskOverview.h new file mode 100644 index 000000000..fd78e1790 --- /dev/null +++ b/widgets/src/DiskOverview.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _DISK_OVERVIEW_H +#define _DISK_OVERVIEW_H + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define ANACONDA_TYPE_DISK_OVERVIEW (anaconda_disk_overview_get_type()) +#define ANACONDA_DISK_OVERVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANACONDA_TYPE_DISK_OVERVIEW, AnacondaDiskOverview)) +#define ANACONDA_IS_DISK_OVERVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj)), ANACONDA_TYPE_DISK_OVERVIEW) +#define ANACONDA_DISK_OVERVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANACONDA_TYPE_DISK_OVERVIEW, AnacondaDiskOverviewClass)) +#define ANACONDA_IS_DISK_OVERVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANACONDA_TYPE_DISK_OVERVIEW)) +#define ANACONDA_DISK_OVERVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANACONDA_TYPE_DISK_OVERVIEW, AnacondaDiskOverviewClass)) + +typedef struct _AnacondaDiskOverview AnacondaDiskOverview; +typedef struct _AnacondaDiskOverviewClass AnacondaDiskOverviewClass; +typedef struct _AnacondaDiskOverviewPrivate AnacondaDiskOverviewPrivate; + +/** + * AnacondaDiskOverview: + * + * The AnacondaDiskOverview struct contains only private fields and should not + * be directly accessed. + */ +struct _AnacondaDiskOverview { + GtkEventBox parent; + + /*< private >*/ + AnacondaDiskOverviewPrivate *priv; +}; + +/** + * AnacondaDiskOverviewClass: + * @parent_class: The object class structure needs to be the first element in + * the widget class structure in order for the class mechanism + * to work correctly. This allows a AnacondaDiskOverviewClass + * pointer to be cast to a #GtkEventBox pointer. + */ +struct _AnacondaDiskOverviewClass { + GtkEventBoxClass parent_class; +}; + +GType anaconda_disk_overview_get_type (void); +GtkWidget *anaconda_disk_overview_new (); + +gboolean anaconda_disk_overview_get_selected(AnacondaDiskOverview *widget); +void anaconda_disk_overview_set_selected(AnacondaDiskOverview *widget, gboolean is_selected); + +G_END_DECLS + +#endif diff --git a/widgets/src/HubWindow.c b/widgets/src/HubWindow.c new file mode 100644 index 000000000..9707bb3fc --- /dev/null +++ b/widgets/src/HubWindow.c @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#include "BaseWindow.h" +#include "HubWindow.h" +#include "intl.h" + +/** + * SECTION: HubWindow + * @title: AnacondaHubWindow + * @short_description: Window for displaying a Hub + * + * A #AnacondaHubWindow is a top-level window that displays a hub on the + * entire screen. A Hub allows selection of multiple configuration spokes + * from a single interface, as well as a place to display current configuration + * selections. + * + * The window consists of three areas: + * + * - A navigation area in the top of the screen, inherited from #AnacondaBaseWindow. + * + * - A selection area in the middle of the screen, taking up a majority of the space. + * This is where spokes will be displayed and the user can decide what to do. + * + * - An action area on the bottom of the screen. This area is different for + * different kinds of hubs. It may have buttons, or it may have progress + * information. + * + * <refsect2 id="AnacondaHubWindow-BUILDER-UI"><title>AnacondaHubWindow as GtkBuildable</title> + * <para> + * The AnacondaHubWindow implementation of the #GtkBuildable interface exposes + * the @action_area and @scrolled_window as internal children with the names + * "action_area" and "scrolled_window". action_area, in this case, is largely + * there to give a box to contain both the scrolled_window and a #GtkButtonBox. + * </para> + * <example> + * <title>A <structname>AnacondaHubWindow</structname> UI definition fragment.</title> + * <programlisting><![CDATA[ + * <object class="AnacondaHubWindow" id="hub1"> + * <child internal-child="action_area"> + * <object class="GtkVBox" id="vbox1"> + * <child internal-child="scrolled_window"> + * <object class="GtkScrolledWindow" id="window1"> + * <child>...</child> + * </object> + * </child> + * <child> + * <object class="GtkHButtonBox" id="buttonbox1"> + * <child>...</child> + * </object> + * </child> + * </object> + * </child> + * </object> + * ]]></programlisting> + * </example> + * </refsect2> + */ + +struct _AnacondaHubWindowPrivate { + GtkWidget *scrolled_window; +}; + +static void anaconda_hub_window_buildable_init(GtkBuildableIface *iface); + +G_DEFINE_TYPE_WITH_CODE(AnacondaHubWindow, anaconda_hub_window, ANACONDA_TYPE_BASE_WINDOW, + G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, anaconda_hub_window_buildable_init)) + +static void anaconda_hub_window_class_init(AnacondaHubWindowClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + g_type_class_add_private(object_class, sizeof(AnacondaHubWindowPrivate)); +} + +/** + * anaconda_hub_window_new: + * + * Creates a new #AnacondaHubWindow, which is a window designed for displaying + * multiple spokes in one location. + * + * Returns: A new #AnacondaHubWindow. + */ +GtkWidget *anaconda_hub_window_new() { + return g_object_new(ANACONDA_TYPE_HUB_WINDOW, NULL); +} + +static void anaconda_hub_window_init(AnacondaHubWindow *win) { + GtkWidget *action_area = anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(win)); + + win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win, + ANACONDA_TYPE_HUB_WINDOW, + AnacondaHubWindowPrivate); + + win->priv->scrolled_window = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(win->priv->scrolled_window), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + gtk_box_pack_start(GTK_BOX(action_area), win->priv->scrolled_window, TRUE, TRUE, 0); +} + +/** + * anaconda_hub_window_get_spoke_area: + * @win: a #AnacondaHubWindow + * + * Returns the scrolled window of @win where spokes may be displayed + * + * Returns: (transfer none): The spoke area + * + * Since: 1.0 + */ +GtkWidget *anaconda_hub_window_get_spoke_area(AnacondaHubWindow *win) { + return win->priv->scrolled_window; +} + +static GtkBuildableIface *parent_buildable_iface; + +static GObject * +anaconda_hub_window_buildable_get_internal_child (GtkBuildable *buildable, + GtkBuilder *builder, + const gchar *childname) { + if (strcmp (childname, "scrolled_window") == 0) + return G_OBJECT(anaconda_hub_window_get_spoke_area(ANACONDA_HUB_WINDOW(buildable))); + + return parent_buildable_iface->get_internal_child (buildable, builder, childname); +} + +static void anaconda_hub_window_buildable_init (GtkBuildableIface *iface) { + parent_buildable_iface = g_type_interface_peek_parent (iface); + iface->get_internal_child = anaconda_hub_window_buildable_get_internal_child; +} diff --git a/widgets/src/HubWindow.h b/widgets/src/HubWindow.h new file mode 100644 index 000000000..8040eb8fc --- /dev/null +++ b/widgets/src/HubWindow.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _HUB_WINDOW_H +#define _HUB_WINDOW_H + +#include <gtk/gtk.h> + +#include "BaseWindow.h" + +G_BEGIN_DECLS + +#define ANACONDA_TYPE_HUB_WINDOW (anaconda_hub_window_get_type()) +#define ANACONDA_HUB_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANACONDA_TYPE_HUB_WINDOW, AnacondaHubWindow)) +#define ANACONDA_IS_HUB_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANACONDA_TYPE_HUB_WINDOW)) +#define ANACONDA_HUB_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANACONDA_TYPE_HUB_WINDOW, AnacondaHubWindowClass)) +#define ANACONDA_IS_HUB_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANACONDA_TYPE_HUB_WINDOW)) +#define ANACONDA_HUB_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANACONDA_TYPE_HUB_WINDOW, AnacondaHubWindowClass)) + +typedef struct _AnacondaHubWindow AnacondaHubWindow; +typedef struct _AnacondaHubWindowClass AnacondaHubWindowClass; +typedef struct _AnacondaHubWindowPrivate AnacondaHubWindowPrivate; + +/** + * AnacondaHubWindow: + * + * The AnacondaHubWindow struct contains only private fields and should not + * be directly accessed. + */ +struct _AnacondaHubWindow { + AnacondaBaseWindow parent; + + /*< private >*/ + AnacondaHubWindowPrivate *priv; +}; + +/** + * AnacondaHubWindowClass: + * @parent_class: The object class structure needs to be the first element in + * the widget class structure in order for the class mechanism + * to work correctly. This allows an AnacondaHubWindowClass + * pointer to be cast to an #AnacondaBaseWindow pointer. + */ +struct _AnacondaHubWindowClass { + AnacondaBaseWindowClass parent_class; +}; + +GType anaconda_hub_window_get_type (void); +GtkWidget *anaconda_hub_window_new (); +GtkWidget *anaconda_hub_window_get_spoke_area (AnacondaHubWindow *win); + +G_END_DECLS + +#endif diff --git a/widgets/src/Makefile.am b/widgets/src/Makefile.am new file mode 100644 index 000000000..067da353b --- /dev/null +++ b/widgets/src/Makefile.am @@ -0,0 +1,69 @@ +# Makefile.am for anaconda widgets +# +# Copyright (C) 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY 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, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# + +-include $(INTROSPECTION_MAKEFILE) + +ACLOCAL_AMFLAGS = -I m4 + +DISTCHECK_CONFIGURE_FLAGS = --enable-introspection --enable-gtk-doc + +SOURCES = BaseWindow.c \ + DiskOverview.c \ + HubWindow.c \ + SpokeSelector.c \ + SpokeWindow.c \ + StandaloneWindow.c + +HDRS = BaseWindow.h \ + DiskOverview.h \ + HubWindow.h \ + SpokeSelector.h \ + SpokeWindow.h \ + StandaloneWindow.h + +noinst_HEADERS = gettext.h intl.h + +lib_LTLIBRARIES = libAnacondaWidgets.la +libAnacondaWidgets_la_CFLAGS = $(GTK_CFLAGS) $(GLADEUI_CFLAGS) -Wall -g +libAnacondaWidgets_la_LIBADD = $(GTK_LIBS) $(GLADEUI_LIBS) +libAnacondaWidgets_la_LDFLAGS = $(LTLIBINTL) +libAnacondaWidgets_la_SOURCES = $(SOURCES) $(HDRS) \ + glade-adaptor.c + +lib_includedir=$(includedir)/AnacondaWidgets +lib_include_HEADERS = $(HDRS) + +if HAVE_INTROSPECTION +AnacondaWidgets-1.0.gir: libAnacondaWidgets.la + +AnacondaWidgets_1_0_gir_FILES = $(SOURCES) $(HDRS) +AnacondaWidgets_1_0_gir_LIBS = libAnacondaWidgets.la +AnacondaWidgets_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=Anaconda --symbol-prefix=anaconda +AnacondaWidgets_1_0_gir_INCLUDES = Gtk-3.0 + +INTROSPECTION_GIRS = AnacondaWidgets-1.0.gir + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES = AnacondaWidgets-1.0.gir $(typelib_DATA) +MAINTAINERCLEANFILES = Makefile.in +endif diff --git a/widgets/src/SpokeSelector.c b/widgets/src/SpokeSelector.c new file mode 100644 index 000000000..7f0279405 --- /dev/null +++ b/widgets/src/SpokeSelector.c @@ -0,0 +1,251 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#include "SpokeSelector.h" +#include "intl.h" + +/** + * SECTION: SpokeSelector + * @title: AnacondaSpokeSelector + * @short_description: A graphical way to enter a configuration spoke + * + * A #AnacondaSpokeSelector is a widget that is associated with a Spoke and + * is packed into a grid on a Hub. A Spoke allows the user to configure one + * piece of system, and the associated selector both displays the current + * configuration and allows for a place to click to do further configuration. + * + * Some Spokes can have their initial configuration guessed, while others + * (specifically storage) requires the user to do something. For those that + * the user has not entered, the selector may be set as incomplete. See + * #anaconda_spoke_selector_get_incomplete and #anaconda_spoke_selector_set_incomplete. + * + * As a #AnacondaSpokeSelector is a subclass of a #GtkEventBox, any signals + * may be caught. However ::button-press-event is the most important one and + * should be how control is transferred to a Spoke. + */ + +enum { + PROP_ICON = 1, + PROP_STATUS, + PROP_TITLE, +}; + +#define DEFAULT_ICON "gtk-missing-image" +#define DEFAULT_STATUS "None" +#define DEFAULT_TITLE "New Selector" + +struct _AnacondaSpokeSelectorPrivate { + gboolean is_incomplete; + GtkWidget *grid; + GtkWidget *icon; + GtkWidget *title_label; + GtkWidget *status_label; +}; + +G_DEFINE_TYPE(AnacondaSpokeSelector, anaconda_spoke_selector, GTK_TYPE_EVENT_BOX) + +static void anaconda_spoke_selector_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void anaconda_spoke_selector_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); + +static void anaconda_spoke_selector_class_init(AnacondaSpokeSelectorClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->set_property = anaconda_spoke_selector_set_property; + object_class->get_property = anaconda_spoke_selector_get_property; + + /** + * AnacondaSpokeSelector:icon: + * + * The :icon string is the standard icon name for an icon to display + * beside this spoke's :title. It is strongly suggested that one of the + * "-symbolic" icons be used, as that is consistent with the style we + * are going for. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_ICON, + g_param_spec_string("icon", + P_("Icon"), + P_("Icon to appear next to the title"), + DEFAULT_ICON, + G_PARAM_READWRITE)); + + /** + * AnacondaSpokeSelector:status: + * + * The :status string is text displayed underneath the spoke's :title and + * also beside the :icon. This text very briefly describes what has been + * selected on the spoke associated with this selector. For instance, it + * might be set up to "English" for a language-related spoke. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_STATUS, + g_param_spec_string("status", + P_("Status"), + P_("Status display"), + DEFAULT_STATUS, + G_PARAM_READWRITE)); + + /** + * AnacondaSpokeSelector:title: + * + * The :title of this selector, which will be displayed large and bold + * beside the :icon. + * + * Since: 1.0 + */ + g_object_class_install_property(object_class, + PROP_TITLE, + g_param_spec_string("title", + P_("Title"), + P_("The title of the spoke selector"), + DEFAULT_TITLE, + G_PARAM_READWRITE)); + + g_type_class_add_private(object_class, sizeof(AnacondaSpokeSelectorPrivate)); +} + +/** + * anaconda_spoke_selector_new: + * + * Creates a new #AnacondaSpokeSelector, which is a selectable display for a + * single spoke of an Anaconda hub. Many spokes may be put together into a + * grid, displaying everything that a user needs to do in one place. + * + * Returns: A new #AnacondaSpokeSelector. + */ +GtkWidget *anaconda_spoke_selector_new() { + return g_object_new(ANACONDA_TYPE_SPOKE_SELECTOR, NULL); +} + +static void anaconda_spoke_selector_init(AnacondaSpokeSelector *spoke) { + char *markup; + + spoke->priv = G_TYPE_INSTANCE_GET_PRIVATE(spoke, + ANACONDA_TYPE_SPOKE_SELECTOR, + AnacondaSpokeSelectorPrivate); + + /* Set property defaults. */ + spoke->priv->is_incomplete = FALSE; + + /* Create the grid. */ + spoke->priv->grid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(spoke->priv->grid), 6); + + /* Create the icon. */ + spoke->priv->icon = gtk_image_new_from_stock(DEFAULT_ICON, GTK_ICON_SIZE_DIALOG); + + /* Create the title label. */ + spoke->priv->title_label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span weight='bold'>%s</span>", _(DEFAULT_TITLE)); + gtk_label_set_markup(GTK_LABEL(spoke->priv->title_label), markup); + gtk_misc_set_alignment(GTK_MISC(spoke->priv->title_label), 0, 0); + g_free(markup); + + /* Create the status label. */ + spoke->priv->status_label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span style='italic'>%s</span>", _(DEFAULT_STATUS)); + gtk_label_set_markup(GTK_LABEL(spoke->priv->status_label), markup); + gtk_misc_set_alignment(GTK_MISC(spoke->priv->status_label), 0, 0); + g_free(markup); + + /* Add everything to the grid, add the grid to the widget. */ + gtk_grid_attach(GTK_GRID(spoke->priv->grid), spoke->priv->icon, 0, 0, 1, 2); + gtk_grid_attach(GTK_GRID(spoke->priv->grid), spoke->priv->title_label, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(spoke->priv->grid), spoke->priv->status_label, 1, 1, 1, 1); + + gtk_container_add(GTK_CONTAINER(spoke), spoke->priv->grid); +} + +static void anaconda_spoke_selector_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + AnacondaSpokeSelector *widget = ANACONDA_SPOKE_SELECTOR(object); + AnacondaSpokeSelectorPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_ICON: + g_value_set_object (value, (GObject *)priv->icon); + break; + + case PROP_STATUS: + g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->status_label))); + break; + + case PROP_TITLE: + g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->title_label))); + break; + } +} + +static void anaconda_spoke_selector_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + AnacondaSpokeSelector *widget = ANACONDA_SPOKE_SELECTOR(object); + AnacondaSpokeSelectorPrivate *priv = widget->priv; + + switch(prop_id) { + case PROP_ICON: + gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon), g_value_get_string(value), GTK_ICON_SIZE_DIALOG); + break; + + case PROP_STATUS: { + char *markup = g_markup_printf_escaped("<span style='italic'>%s</span>", g_value_get_string(value)); + gtk_label_set_markup(GTK_LABEL(priv->status_label), markup); + g_free(markup); + break; + } + + case PROP_TITLE: { + char *markup = g_markup_printf_escaped("<span weight='bold'>%s</span>", g_value_get_string(value)); + gtk_label_set_markup(GTK_LABEL(priv->title_label), markup); + g_free(markup); + break; + } + } +} + +/** + * anaconda_spoke_selector_get_incomplete: + * @spoke: a #AnacondaSpokeSelector + * + * Returns whether or not this spoke has been completed. + * + * Returns: Whether @spoke has been completed by the user. + * + * Since: 1.0 + */ +gboolean anaconda_spoke_selector_get_incomplete(AnacondaSpokeSelector *spoke) { + return spoke->priv->is_incomplete; +} + +/** + * anaconda_spoke_selector_set_incomplete: + * @spoke: a #AnacondaSpokeSelector + * @is_incomplete: %TRUE if this spoke still needs to be visited. + * + * Specifies whether this spoke must still be visited by the user. If so, this + * means anaconda doesn't have enough information to continue and the user must + * take some action. A warning icon will be displayed alongside the spoke's + * icon, and the continue button will be disabled. + * + * Since: 1.0 + */ +void anaconda_spoke_selector_set_incomplete(AnacondaSpokeSelector *spoke, gboolean is_incomplete) { + spoke->priv->is_incomplete = is_incomplete; +} diff --git a/widgets/src/SpokeSelector.h b/widgets/src/SpokeSelector.h new file mode 100644 index 000000000..4a2111d25 --- /dev/null +++ b/widgets/src/SpokeSelector.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _SPOKE_SELECTOR_H +#define _SPOKE_SELECTOR_H + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define ANACONDA_TYPE_SPOKE_SELECTOR (anaconda_spoke_selector_get_type()) +#define ANACONDA_SPOKE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANACONDA_TYPE_SPOKE_SELECTOR, AnacondaSpokeSelector)) +#define ANACONDA_IS_SPOKE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj)), ANACONDA_TYPE_SPOKE_SELECTOR) +#define ANACONDA_SPOKE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANACONDA_TYPE_SPOKE_SELECTOR, AnacondaSpokeSelectorClass)) +#define ANACONDA_IS_SPOKE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANACONDA_TYPE_SPOKE_SELECTOR)) +#define ANACONDA_SPOKE_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANACONDA_TYPE_SPOKE_SELECTOR, AnacondaSpokeSelectorClass)) + +typedef struct _AnacondaSpokeSelector AnacondaSpokeSelector; +typedef struct _AnacondaSpokeSelectorClass AnacondaSpokeSelectorClass; +typedef struct _AnacondaSpokeSelectorPrivate AnacondaSpokeSelectorPrivate; + +/** + * AnacondaSpokeSelector: + * + * The AnacondaSpokeSelector struct contains only private fields and should + * not be directly accessed. + */ +struct _AnacondaSpokeSelector { + GtkEventBox parent; + + /*< private >*/ + AnacondaSpokeSelectorPrivate *priv; +}; + +/** + * AnacondaSpokeSelectorClass: + * @parent_class: The object class structure needs to be the first element in + * the widget class structure in order for the class mechanism + * to work correctly. This allows an AnacondaSpokeSelectorClass + * pointer to be cast to a #GtkEventBox pointer. + */ +struct _AnacondaSpokeSelectorClass { + GtkEventBoxClass parent_class; +}; + +GType anaconda_spoke_selector_get_type (void); +GtkWidget *anaconda_spoke_selector_new (); +gboolean anaconda_spoke_selector_get_incomplete (AnacondaSpokeSelector *spoke); +void anaconda_spoke_selector_set_incomplete (AnacondaSpokeSelector *spoke, gboolean is_incomplete); + +G_END_DECLS + +#endif diff --git a/widgets/src/SpokeWindow.c b/widgets/src/SpokeWindow.c new file mode 100644 index 000000000..6b6adb29a --- /dev/null +++ b/widgets/src/SpokeWindow.c @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#include "BaseWindow.h" +#include "SpokeWindow.h" +#include "intl.h" + +/** + * SECTION: SpokeWindow + * @title: AnacondaSpokeWindow + * @short_description: Window for displaying single spokes + * + * A #AnacondaSpokeWindow is a top-level window that displays a single spoke + * on the entire screen. Examples include the keyboard and language + * configuration screens off the first hub. + * + * The iwndow consists of two areas: + * + * - A navigation area in the top of the screen, inherited from #AnacondaBaseWindow + * and augmented with a back button. + * + * - An action area in the rest of the screen, taking up a majority of the + * space. This is where widgets will be added and the user will do things. + */ + +enum { + SIGNAL_BACK_CLICKED, + LAST_SIGNAL +}; + +static guint window_signals[LAST_SIGNAL] = { 0 }; + +struct _AnacondaSpokeWindowPrivate { + GtkWidget *back_button; +}; + +static void anaconda_spoke_window_back_clicked(GtkButton *button, + AnacondaSpokeWindow *win); + +G_DEFINE_TYPE(AnacondaSpokeWindow, anaconda_spoke_window, ANACONDA_TYPE_BASE_WINDOW) + +static void anaconda_spoke_window_class_init(AnacondaSpokeWindowClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + klass->back_clicked = NULL; + + /** + * AnacondaSpokeWindow::back-clicked: + * @window: the window that received the signal + * + * Emitted when the back button has been activated (pressed and released). + * + * Since: 1.0 + */ + window_signals[SIGNAL_BACK_CLICKED] = g_signal_new("back-clicked", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(AnacondaSpokeWindowClass, back_clicked), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + g_type_class_add_private(object_class, sizeof(AnacondaSpokeWindowPrivate)); +} + +/** + * anaconda_spoke_window_new: + * + * Creates a new #AnacondaSpokeWindow, which is a window designed for + * displaying a single spoke, such as the keyboard or network configuration + * screens. + * + * Returns: A new #AnacondaSpokeWindow. + */ +GtkWidget *anaconda_spoke_window_new() { + return g_object_new(ANACONDA_TYPE_SPOKE_WINDOW, NULL); +} + +static void anaconda_spoke_window_init(AnacondaSpokeWindow *win) { + GtkWidget *nav_area; + + win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win, + ANACONDA_TYPE_SPOKE_WINDOW, + AnacondaSpokeWindowPrivate); + + /* Set some default properties. */ + gtk_window_set_modal(GTK_WINDOW(win), TRUE); + + /* Create the buttons. */ + win->priv->back_button = gtk_button_new_with_mnemonic(_("_Back to install summary")); + gtk_widget_set_halign(GTK_WIDGET(win->priv->back_button), GTK_ALIGN_START); + + /* Hook up some signals for that button. The signal handlers here will + * just raise our own custom signals for the whole window. + */ + g_signal_connect(win->priv->back_button, "clicked", + G_CALLBACK(anaconda_spoke_window_back_clicked), win); + + /* And then put the back button into the navigation area. */ + nav_area = anaconda_base_window_get_nav_area(ANACONDA_BASE_WINDOW(win)); + gtk_grid_attach(GTK_GRID(nav_area), win->priv->back_button, 0, 1, 1, 1); +} + +static void anaconda_spoke_window_back_clicked(GtkButton *button, + AnacondaSpokeWindow *win) { + g_signal_emit(win, window_signals[SIGNAL_BACK_CLICKED], 0); +} diff --git a/widgets/src/SpokeWindow.h b/widgets/src/SpokeWindow.h new file mode 100644 index 000000000..b6e1739d3 --- /dev/null +++ b/widgets/src/SpokeWindow.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _SPOKE_WINDOW_H +#define _SPOKE_WINDOW_H + +#include <gtk/gtk.h> + +#include "BaseWindow.h" + +G_BEGIN_DECLS + +#define ANACONDA_TYPE_SPOKE_WINDOW (anaconda_spoke_window_get_type()) +#define ANACONDA_SPOKE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANACONDA_TYPE_SPOKE_WINDOW, AnacondaSpokeWindow)) +#define ANACONDA_IS_SPOKE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANACONDA_TYPE_SPOKE_WINDOW)) +#define ANACONDA_SPOKE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANACONDA_TYPE_SPOKE_WINDOW, AnacondaSpokeWindowClass)) +#define ANACONDA_IS_SPOKE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANACONDA_TYPE_SPOKE_WINDOW)) +#define ANACONDA_SPOKE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANACONDA_TYPE_SPOKE_WINDOW, AnacondaSpokeWindowClass)) + +typedef struct _AnacondaSpokeWindow AnacondaSpokeWindow; +typedef struct _AnacondaSpokeWindowClass AnacondaSpokeWindowClass; +typedef struct _AnacondaSpokeWindowPrivate AnacondaSpokeWindowPrivate; + +/** + * AnacondaSpokeWindow: + * + * The AnacondaSpokeWindow struct contains only private fields and should not + * be directly accessed. + */ +struct _AnacondaSpokeWindow { + AnacondaBaseWindow parent; + + /*< private >*/ + AnacondaSpokeWindowPrivate *priv; +}; + +/** + * AnacondaSpokeWindowClass: + * @parent_class: The object class structure needs to be the first element in + * the widget class structure in order for the class mechanism + * to work correctly. This allows an AnacondaSpokeWindowClass + * pointer to be cast to an #AnacondaBaseWindow pointer. + * @back_clicked: Function pointer called when the #AnacondaSpokeWindow::back-clicked + * signal is emitted. + */ +struct _AnacondaSpokeWindowClass { + AnacondaBaseWindowClass parent_class; + + void (* back_clicked) (AnacondaSpokeWindow *window); +}; + +GType anaconda_spoke_window_get_type (void); +GtkWidget *anaconda_spoke_window_new (); + +G_END_DECLS + +#endif diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c new file mode 100644 index 000000000..6ba4031f0 --- /dev/null +++ b/widgets/src/StandaloneWindow.c @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#include "BaseWindow.h" +#include "StandaloneWindow.h" +#include "intl.h" + +/** + * SECTION: StandaloneWindow + * @title: AnacondaStandaloneWindow + * @short_description: Window for displaying standalone spokes + * + * A #AnacondaStandaloneWindow is a top-level window that displays a standalone + * spoke. A standalone spoke is like a normal spoke, but is not entered via a + * hub. Instead, it is displayed by itself. Examples include the welcome and + * network configuration screens at the beginning of installation. + * + * The window consist of three areas: + * + * - A navigation area in the top of the screen, inherited from #AnacondaBaseWindow. + * + * - A button box at the bottom of the screen, with Quit and Continue buttons. + * The Continue button may not be enabled until required information is + * entered by the user. + * + * - An action area in the middle of the screen, taking up a majority of the + * space. This is where widgets will be added and the user will do things. + */ + +enum { + SIGNAL_QUIT_CLICKED, + SIGNAL_CONTINUE_CLICKED, + LAST_SIGNAL +}; + +static guint window_signals[LAST_SIGNAL] = { 0 }; + +struct _AnacondaStandaloneWindowPrivate { + GtkWidget *button_box; + GtkWidget *continue_button, *quit_button; +}; + +static void anaconda_standalone_window_quit_clicked(GtkButton *button, + AnacondaStandaloneWindow *win); +static void anaconda_standalone_window_continue_clicked(GtkButton *button, + AnacondaStandaloneWindow *win); + +G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW) + +static void anaconda_standalone_window_class_init(AnacondaStandaloneWindowClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + klass->quit_clicked = NULL; + klass->continue_clicked = NULL; + + /** + * AnacondaStandaloneWindow::quit-clicked: + * @window: the window that received the signal + * + * Emitted when the quit button has been activated (pressed and released). + * + * Since: 1.0 + */ + window_signals[SIGNAL_QUIT_CLICKED] = g_signal_new("quit-clicked", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(AnacondaStandaloneWindowClass, quit_clicked), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** + * AnacondaStandaloneWindow::continue-clicked: + * @window: the window that received the signal + * + * Emitted when the continue button has been activated (pressed and released). + * + * Since: 1.0 + */ + window_signals[SIGNAL_CONTINUE_CLICKED] = g_signal_new("continue-clicked", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(AnacondaStandaloneWindowClass, continue_clicked), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + g_type_class_add_private(object_class, sizeof(AnacondaStandaloneWindowPrivate)); +} + +/** + * anaconda_standalone_window_new: + * + * Creates a new #AnacondaStandaloneWindow, which is a window designed for + * displaying a standalone spoke, such as the welcome screen or network + * configuration. + * + * Returns: A new #AnacondaStandaloneWindow. + */ +GtkWidget *anaconda_standalone_window_new() { + return g_object_new(ANACONDA_TYPE_STANDALONE_WINDOW, NULL); +} + +static void anaconda_standalone_window_init(AnacondaStandaloneWindow *win) { + /* This is the section of the parent AnacondaBaseWindow class where we + * put buttons, dialogs, etc. We need a reference to it here to pac + * things into. + */ + GtkWidget *action_area = anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(win)); + + win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win, + ANACONDA_TYPE_STANDALONE_WINDOW, + AnacondaStandaloneWindowPrivate); + + /* Create the buttons. */ + win->priv->quit_button = gtk_button_new_with_mnemonic(_("_QUIT")); + win->priv->continue_button = gtk_button_new_with_mnemonic(_("_CONTINUE")); + + /* Hook up some signals for those buttons. The signal handlers here will + * just raise our own custom signals for the whole window. + */ + g_signal_connect(win->priv->quit_button, "clicked", + G_CALLBACK(anaconda_standalone_window_quit_clicked), win); + g_signal_connect(win->priv->continue_button, "clicked", + G_CALLBACK(anaconda_standalone_window_continue_clicked), win); + + /* Create the button box and pack the buttons into it. */ + win->priv->button_box = gtk_hbutton_box_new(); + gtk_button_box_set_layout(GTK_BUTTON_BOX(win->priv->button_box), GTK_BUTTONBOX_EDGE); + gtk_container_add(GTK_CONTAINER(win->priv->button_box), win->priv->quit_button); + gtk_container_add(GTK_CONTAINER(win->priv->button_box), win->priv->continue_button); + + /* Pack the button box into the action_area. */ + gtk_box_pack_end(GTK_BOX(action_area), win->priv->button_box, FALSE, TRUE, 0); +} + +static void anaconda_standalone_window_quit_clicked(GtkButton *button, + AnacondaStandaloneWindow *win) { + g_signal_emit(win, window_signals[SIGNAL_QUIT_CLICKED], 0); +} + +static void anaconda_standalone_window_continue_clicked(GtkButton *button, + AnacondaStandaloneWindow *win) { + g_signal_emit(win, window_signals[SIGNAL_CONTINUE_CLICKED], 0); +} + +/** + * anaconda_standalone_window_get_may_continue: + * @win: a #AnacondaStandaloneWindow + * + * Returns whether or not the continue button is sensitive (thus, whether the + * user may continue forward from this window). + * + * Returns: Whether the continue button on @win is sensitive. + * + * Since: 1.0 + */ +gboolean anaconda_standalone_window_get_may_continue(AnacondaStandaloneWindow *win) { + return gtk_widget_get_sensitive(win->priv->continue_button); +} + +/** + * anaconda_standalone_window_set_may_continue: + * @win: a #AnacondaStandaloneWindow + * @may_continue: %TRUE if this window's continue button should be sensitive. + * + * Specifies whether the user may continue forward from this window. If so, + * the continue button will be made sensitive. Windows default to continuable + * so you must set it as false if you want. The reason the user may not be + * able to continue is if there is required information the user must enter + * when no reasonable default may be given. + * + * Since: 1.0 + */ +void anaconda_standalone_window_set_may_continue(AnacondaStandaloneWindow *win, + gboolean may_continue) { + gtk_widget_set_sensitive(win->priv->continue_button, may_continue); +} diff --git a/widgets/src/StandaloneWindow.h b/widgets/src/StandaloneWindow.h new file mode 100644 index 000000000..b1ba02938 --- /dev/null +++ b/widgets/src/StandaloneWindow.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _STANDALONE_WINDOW_H +#define _STANDALONE_WINDOW_H + +#include <gtk/gtk.h> + +#include "BaseWindow.h" + +G_BEGIN_DECLS + +#define ANACONDA_TYPE_STANDALONE_WINDOW (anaconda_standalone_window_get_type()) +#define ANACONDA_STANDALONE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANACONDA_TYPE_STANDALONE_WINDOW, AnacondaStandaloneWindow)) +#define ANACONDA_IS_STANDALONE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANACONDA_TYPE_STANDALONE_WINDOW)) +#define ANACONDA_STANDALONE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANACONDA_TYPE_STANDALONE_WINDOW, AnacondaStandaloneWindowClass)) +#define ANACONDA_IS_STANDALONE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANACONDA_TYPE_STANDALONE_WINDOW)) +#define ANACONDA_STANDALONE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANACONDA_TYPE_STANDALONE_WINDOW, AnacondaStandaloneWindowClass)) + +typedef struct _AnacondaStandaloneWindow AnacondaStandaloneWindow; +typedef struct _AnacondaStandaloneWindowClass AnacondaStandaloneWindowClass; +typedef struct _AnacondaStandaloneWindowPrivate AnacondaStandaloneWindowPrivate; + +/** + * AnacondaStandaloneWindow: + * + * The AnacondaStandaloneWindow struct contains only private fields and should not + * be directly accessed. + */ +struct _AnacondaStandaloneWindow { + AnacondaBaseWindow parent; + + /*< private >*/ + AnacondaStandaloneWindowPrivate *priv; +}; + +/** + * AnacondaStandaloneWindowClass: + * @parent_class: The object class structure needs to be the first element in + * the widget class structure in order for the class mechanism + * to work correctly. This allows an AnacondaStandaloneWindowClass + * pointer to be cast to an #AnacondaBaseWindow pointer. + * @quit_clicked: Function pointer called when the #AnacondaStandaloneWindow::quit-clicked + * signal is emitted. + * @continue_clicked: Function pointer called when the #AnacondaStandaloneWindow::continue-clicked + * signal is emitted. + */ +struct _AnacondaStandaloneWindowClass { + AnacondaBaseWindowClass parent_class; + + void (* quit_clicked) (AnacondaStandaloneWindow *window); + void (* continue_clicked) (AnacondaStandaloneWindow *window); +}; + +GType anaconda_standalone_window_get_type (void); +GtkWidget *anaconda_standalone_window_new (); +gboolean anaconda_standalone_window_get_may_continue (AnacondaStandaloneWindow *win); +void anaconda_standalone_window_set_may_continue (AnacondaStandaloneWindow *win, gboolean may_continue); + +G_END_DECLS + +#endif diff --git a/widgets/src/glade-adaptor.c b/widgets/src/glade-adaptor.c new file mode 100644 index 000000000..866d7950c --- /dev/null +++ b/widgets/src/glade-adaptor.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +/* This file contains code called by glade when it creates, reads, writes, or + * otherwise manipulates anaconda-specific widgets. Each function in this file + * that glade should call must be referenced in a glade-widget-class stanza of + * glade/AnacondaWidgets.xml. + * + * This file relies on a lot of halfway documented magic. Good luck. + */ +#include <gladeui/glade-project.h> +#include <gladeui/glade-widget.h> +#include <gladeui/glade-widget-adaptor.h> + +#include <gtk/gtk.h> + +#include "BaseWindow.h" +#include "SpokeWindow.h" + +void anaconda_standalone_window_post_create(GladeWidgetAdaptor *adaptor, + GObject *object, GladeCreateReason reason) { + GladeWidget *widget, *actionarea_widget; + AnacondaBaseWindow *window; + + if (reason != GLADE_CREATE_USER) + return; + + g_return_if_fail(ANACONDA_IS_BASE_WINDOW(object)); + + widget = glade_widget_get_from_gobject(GTK_WIDGET(object)); + if (!widget) + return; + + window = ANACONDA_BASE_WINDOW(object); + actionarea_widget = glade_widget_get_from_gobject(anaconda_base_window_get_action_area(window)); + + if (ANACONDA_IS_SPOKE_WINDOW(object)) + glade_widget_property_set(actionarea_widget, "size", 2); + else + glade_widget_property_set(actionarea_widget, "size", 3); +} + +void anaconda_standalone_window_write_widget(GladeWidgetAdaptor *adaptor, + GladeWidget *widget, + GladeXmlContext *context, GladeXmlNode *node) { + GladeProperty *startup_id_prop; + + if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET)) + return; + + /* Set a bogus startup-id in the output XML file. This doesn't really seem + * like it should be necessary, but glade will crash if I don't. + */ + startup_id_prop = glade_widget_get_property(widget, "startup-id"); + glade_property_set(startup_id_prop, "filler"); + glade_property_write(startup_id_prop, context, node); + + /* Chain up and write the parent's properties */ + GWA_GET_CLASS (GTK_TYPE_WINDOW)->write_widget (adaptor, widget, context, node); +} diff --git a/widgets/src/intl.h b/widgets/src/intl.h new file mode 100644 index 000000000..30bca59dc --- /dev/null +++ b/widgets/src/intl.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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: Chris Lumens <clumens@redhat.com> + */ + +#ifndef _INTL_H +#define _INTL_H + +#include "../config.h" +#include "gettext.h" + +#define _(x) gettext(x) + +#ifdef ENABLE_NLS +#define P_(String) g_dgettext(GETTEXT_PACKAGE "-properties",String) +#else +#define P_(String) (String) +#endif + +#endif |