[Xfce4-commits] <mousepad:master> * MousepadHelp.in, mousepad/mousepad-{dialogs, window}.{c, h}: Add support for the help file. * Mousepad.spec.in: Add spec file.

Nick Schermer noreply at xfce.org
Sat May 5 21:30:56 CEST 2012


Updating branch refs/heads/master
         to ec4cae752aa01e235b870df476b0c3008cb24f4d (commit)
       from 673f739167aa23710a7b570eb7e863871fd09e4d (commit)

commit ec4cae752aa01e235b870df476b0c3008cb24f4d
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Oct 26 08:43:19 2007 +0000

    	* MousepadHelp.in, mousepad/mousepad-{dialogs,window}.{c,h}:
    	  Add support for the help file.
    	* Mousepad.spec.in: Add spec file.
    
    (Old svn revision: 26199)

 ChangeLog                   |    6 +++++
 Makefile.am                 |   14 +++++++++++
 Mousepad.spec.in            |   51 +++++++++++++++++++++++++++++++++++++++++++
 MousepadHelp.in             |   51 +++++++++++++++++++++++++++++++++++++++++++
 mousepad/mousepad-dialogs.c |   51 +++++++++++++++++++++++++++++++++++++++++++
 mousepad/mousepad-dialogs.h |    4 +++
 mousepad/mousepad-window.c  |    2 +-
 7 files changed, 178 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 718f5ec..e64012a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-10-26	Nick Schermer <nick at xfce.org>
+	* MousepadHelp.in, mousepad/mousepad-{dialogs,window}.{c,h}:
+	  Add support for the help file.
+	* Mousepad.spec.in: Add spec file.
+
+
 2007-10-25	Nick Schermer <nick at xfce.org>
 	* mousepad/mousepad-view.c: Redraw selection on theme change.
 
diff --git a/Makefile.am b/Makefile.am
index cc32972..aafee93 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,6 +13,16 @@ rpm: dist
 	rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
 	@rm -f $(PACKAGE)-$(VERSION).tar.gz
 
+libexec_SCRIPTS =								\
+	MousepadHelp
+
+MousepadHelp: MousepadHelp.in Makefile
+	rm -f MousepadHelp.gen MousepadHelp
+	sed -e "s,\@datadir\@,$(datadir),g" 					\
+		< $(srcdir)/MousepadHelp.in					\
+		> MousepadHelp.gen
+	mv MousepadHelp.gen MousepadHelp
+
 desktopdir = $(datadir)/applications
 desktop_in_in_files = 								\
 	Mousepad.desktop.in.in
@@ -23,12 +33,16 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
 EXTRA_DIST =									\
+	MousepadHelp.in								\
+	Mousepad.spec.in							\
 	intltool-extract.in							\
 	intltool-merge.in							\
 	intltool-update.in							\
 	$(desktop_in_in_files)
 
 DISTCLEANFILES =								\
+	MousepadHelp								\
+	Mousepad.spec								\
 	intltool-extract							\
 	intltool-merge								\
 	intltool-update								\
diff --git a/Mousepad.spec.in b/Mousepad.spec.in
new file mode 100644
index 0000000..eaf1459
--- /dev/null
+++ b/Mousepad.spec.in
@@ -0,0 +1,51 @@
+Summary:	Mousepad Text Editor
+Name:		@PACKAGE_TARNAME@
+Version:	@PACKAGE_VERSION@
+Release:	1
+License:	GPL
+URL:		http://www.xfce.org/
+Source0:	%{name}-%{version}.tar.gz
+Group:		Applications/X11
+BuildRoot:	%{_tmppath}/%{name}-root
+Requires:	gtk2 >= @GTK_REQUIRED_VERSION@
+Requires:	libxfce4util >= @LIBXFCE4UTIL_REQUIRED_VERSION@
+BuildRequires:	gtk2-devel >= @GTK_REQUIRED_VERSION@
+BuildRequires:	libxfce4util-devel >= @LIBXFCE4UTIL_REQUIRED_VERSION@
+
+%description
+Mousepad is a simple text editor for the Xfce Desktop Environment.
+
+%prep
+%setup -q
+
+%build
+%configure --enable-dbus --enable-final --enable-xsltproc
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post
+update-desktop-database &> /dev/null ||:
+touch --no-create %{_datadir}/icons/hicolor || :
+if [ -x %{_bindir}/gtk-update-icon-cache ]; then
+   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
+fi
+
+%postun
+update-desktop-database &> /dev/null ||:
+touch --no-create %{_datadir}/icons/hicolor || :
+if [ -x %{_bindir}/gtk-update-icon-cache ]; then
+   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
+fi
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS ChangeLog COPYING INSTALL NEWS README THANKS TODO
+%{_bindir}/
+%{_datadir}/
+%{_libexecdir}/
diff --git a/MousepadHelp.in b/MousepadHelp.in
new file mode 100644
index 0000000..773b8a0
--- /dev/null
+++ b/MousepadHelp.in
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# $Id$
+#
+# Copyright (c) 2004-2006 Benedikt Meurer <benny at xfce.org>
+# Copyright (c) 2007      Nick Schermer <nick at xfce.org>
+#
+# 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.
+#
+
+HELPDIR="@datadir@/doc/Mousepad/html"
+
+if test -n "$LC_ALL"; then
+  LC=$LC_ALL
+elif test -n "$LANG"; then
+  LC=$LANG
+else
+  LC="C"
+fi
+
+if test -n "$1"; then
+  HELPFILE="$1.html"
+else
+  HELPFILE="index.html"
+fi
+
+if test -r "$HELPDIR/$LC/$HELPFILE"; then
+  URL="$HELPDIR/$LC/$HELPFILE"
+elif test -r "$HELPDIR/`echo $LC | sed 's/\(..\)_.*/\1/'`/$HELPFILE"; then
+  URL="$HELPDIR/`echo $LC | sed 's/\(..\)_.*/\1/'`/$HELPFILE"
+else
+  URL="$HELPDIR/C/index.html"
+fi
+
+[ -n "$2" ] && URL="$URL#$2"
+
+exec exo-open --launch WebBrowser "file://$URL"
+
+# vim:set ts=2 sw=2 et ai:
diff --git a/mousepad/mousepad-dialogs.c b/mousepad/mousepad-dialogs.c
index e404cba..b1c9ab2 100644
--- a/mousepad/mousepad-dialogs.c
+++ b/mousepad/mousepad-dialogs.c
@@ -78,6 +78,57 @@ mousepad_dialogs_show_error (GtkWindow    *parent,
 
 
 
+void
+mousepad_dialogs_show_help (GtkWindow   *parent,
+                            const gchar *page,
+                            const gchar *offset)
+{
+  GdkScreen *screen;
+  GError    *error = NULL;
+  gchar     *command;
+  gchar     *tmp;
+
+  /* get screen */
+  if (G_LIKELY (parent))
+    screen = gtk_widget_get_screen (GTK_WIDGET (parent));
+  else
+    screen = gdk_screen_get_default ();
+
+  /* generate the command for the documentation browser */
+  command = g_strdup (LIBEXECDIR "/MousepadHelp");
+
+  /* check if a page is given */
+  if (G_UNLIKELY (page != NULL))
+    {
+      /* append page as second parameter */
+      tmp = g_strconcat (command, " ", page, NULL);
+      g_free (command);
+      command = tmp;
+
+      /* check if an offset is given */
+      if (G_UNLIKELY (offset != NULL))
+        {
+          /* append offset as third parameter */
+          tmp = g_strconcat (command, " ", offset, NULL);
+          g_free (command);
+          command = tmp;
+        }
+    }
+
+  /* try to run the documentation browser */
+  if (!gdk_spawn_command_line_on_screen (screen, command, &error))
+    {
+      /* display an error message to the user */
+      mousepad_dialogs_show_error (parent, error, _("Failed to open the documentation browser"));
+      g_error_free (error);
+    }
+
+  /* cleanup */
+  g_free (command);
+}
+
+
+
 gint
 mousepad_dialogs_other_tab_size (GtkWindow *parent,
                                  gint      active_size)
diff --git a/mousepad/mousepad-dialogs.h b/mousepad/mousepad-dialogs.h
index 128488c..af47175 100644
--- a/mousepad/mousepad-dialogs.h
+++ b/mousepad/mousepad-dialogs.h
@@ -46,6 +46,10 @@ void       mousepad_dialogs_show_error     (GtkWindow    *parent,
                                             const GError *error,
                                             const gchar  *message);
 
+void       mousepad_dialogs_show_help      (GtkWindow    *parent,
+                                            const gchar  *page,
+                                            const gchar  *offset);
+
 gint       mousepad_dialogs_other_tab_size (GtkWindow    *parent,
                                             gint          active_size);
 
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 3bab8a5..f46cc83 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -3320,7 +3320,7 @@ static void
 mousepad_window_action_contents (GtkAction      *action,
                                  MousepadWindow *window)
 {
-
+  mousepad_dialogs_show_help (GTK_WINDOW (window), NULL, NULL);
 }
 
 


More information about the Xfce4-commits mailing list