[planner] Revert the removal of Windows specific code for opening URIs
- From: Maurice van der Pot <mvdpot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner] Revert the removal of Windows specific code for opening URIs
- Date: Thu, 21 Oct 2010 16:24:35 +0000 (UTC)
commit 4fe1e6e1800866819e3c32a0e0d8f7c10eb73460
Author: Maurice van der Pot <griffon26 kfk4ever com>
Date: Thu Oct 21 17:32:58 2010 +0200
Revert the removal of Windows specific code for opening URIs
gtk_show_uri does not work on Windows yet, so for now we'll use the old
Windows specific code that was removed earlier
src/Makefile.win32 | 2 +-
src/planner-util-win32.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
src/planner-util.c | 6 ++++
src/planner-util.h | 1 +
src/planner-window.c | 2 +-
5 files changed, 81 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.win32 b/src/Makefile.win32
index 480253d..1a011a9 100644
--- a/src/Makefile.win32
+++ b/src/Makefile.win32
@@ -81,7 +81,7 @@ C_SRC = \
planner-task-date-widget.c \
planner-task-dialog.c \
planner-task-input-dialog.c \
- planner-util.c \
+ planner-util-win32.c \
planner-view.c \
planner-window.c \
planner-working-time-dialog.c \
diff --git a/src/planner-util-win32.c b/src/planner-util-win32.c
new file mode 100644
index 0000000..14ee835
--- /dev/null
+++ b/src/planner-util-win32.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2005 Francisco Moraes
+ *
+ * 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.
+ */
+
+#include <windows.h>
+#include <shellapi.h>
+#include <stdio.h>
+
+#include "planner-util.h"
+
+void
+planner_util_show_url (GtkWindow *parent,
+ const gchar *url)
+{
+ GtkWidget *dialog;
+ int res;
+
+ res = (int) ShellExecute (NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
+
+ if (res <= 32) {
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "Unable to open '%s'", url);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
+
+void
+planner_util_show_help (GtkWindow *parent)
+{
+ GtkWidget *dialog;
+ int res;
+ gchar *path;
+ gchar *file;
+
+ // should use HtmlHelp but it is not part of MingW yet
+ path = g_win32_get_package_installation_subdirectory (NULL, NULL, ".");
+ file = g_build_filename (path, "planner.chm", NULL);
+
+ res = (int) ShellExecute (NULL, "open", file, NULL, NULL, SW_SHOWNORMAL);
+ g_free (file);
+ g_free (path);
+
+ if (res <= 32) {
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "Unable to open help file");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
diff --git a/src/planner-util.c b/src/planner-util.c
index 8a7588a..026c8f6 100644
--- a/src/planner-util.c
+++ b/src/planner-util.c
@@ -23,6 +23,12 @@
#include "planner-util.h"
void
+planner_util_show_help (GtkWindow *parent)
+{
+ planner_util_show_url(parent, "ghelp:planner");
+}
+
+void
planner_util_show_url (GtkWindow *parent, const gchar *url)
{
GtkWidget *dialog;
diff --git a/src/planner-util.h b/src/planner-util.h
index 64f7ce9..109c569 100644
--- a/src/planner-util.h
+++ b/src/planner-util.h
@@ -24,6 +24,7 @@
#include <gtk/gtk.h>
#include <glib.h>
+void planner_util_show_help (GtkWindow *parent);
void planner_util_show_url (GtkWindow *parent,
const gchar *url);
diff --git a/src/planner-window.c b/src/planner-window.c
index 8b81102..ffd480b 100644
--- a/src/planner-window.c
+++ b/src/planner-window.c
@@ -1158,7 +1158,7 @@ static void
window_help_cb (GtkAction *action,
gpointer data)
{
- planner_util_show_url (NULL, "ghelp:planner");
+ planner_util_show_help (NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]