~ubuntu-branches/ubuntu/oneiric/denemo/oneiric

« back to all changes in this revision

Viewing changes to .pc/help.c.diff/src/help.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-10-27 08:00:18 UTC
  • mfrom: (1.2.7 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101027080018-suwj9ozy99d0a5a2
Tags: 0.8.16-1ubuntu1
* Merge with Debian testing (LP: #638617), Ubuntu remaining changes:
  - debian/patches/ubuntuize.diff:
    + Provide a Ubuntu-specific customization.
  - debian/patches/fix_desktop.diff:
    + Add missing trailing semicolon.
    + Add MIME types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* help.cpp
 
2
 * implements the stuff under Help in the menubar
 
3
 *
 
4
 * for Denemo, a gtk+ frontend to GNU Lilypond
 
5
 * (c) 2000-2005 Matthew Hiller
 
6
 */
 
7
 
 
8
#include <denemo/denemo.h>
 
9
#include "config.h"
 
10
#include "utils.h"
 
11
#include <string.h>             /* for strlen */
 
12
/* The tutorial mentioned that the actual gchar * held within a
 
13
 * GtkText widget needs to be freed.  I don't do such a free, though,
 
14
 * so I think this function has a memory leak in it. */
 
15
 
 
16
/** 
 
17
 * Create the about dialog
 
18
 *
 
19
 */
 
20
void
 
21
about (GtkAction * action, gpointer callback_data)
 
22
{
 
23
  GtkWidget *dialog;
 
24
  DenemoGUI *gui = (DenemoGUI *)callback_data;
 
25
  const char *authors[] = { "Richard Shann", "Jeremiah Benham", "Matthew Hiller", "Adam Tee", NULL };
 
26
 
 
27
  dialog = gtk_about_dialog_new ();
 
28
  gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (dialog), _("Denemo"));
 
29
  gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (dialog),
 
30
                                 _("The GNU graphical score editor"));
 
31
  gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (dialog), VERSION);
 
32
  gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog),
 
33
                                "http://denemo.org");
 
34
  gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG (dialog),
 
35
                                      _("Denemo website"));
 
36
  gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (dialog),
 
37
                                _
 
38
                                ("(c) 1999 - 2008 Matthew Hiller, Adam Tee, and others.\n\n\
 
39
http://www.denemo.org\n\n\
 
40
This program is licensed under the terms of the GNU\n\
 
41
General Public License and is provided with absolutely\n\
 
42
NO WARRANTY; see the file COPYING for details."));
 
43
 
 
44
 
 
45
  gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (dialog), authors);
 
46
  gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(Denemo.window));
 
47
  gtk_dialog_run(GTK_DIALOG(dialog));
 
48
  gtk_widget_destroy(dialog);
 
49
}
 
50
 
 
51
 
 
52
/** 
 
53
 * Function to allow browsing the user manual
 
54
 * uses the given web browser to display the manual
 
55
 * If param contains a url it opens that
 
56
 */
 
57
void
 
58
browse_manual (GtkAction * action, DenemoScriptParam *param)
 
59
{
 
60
  GET_1PARAM(action, param, url);
 
61
  DenemoGUI *gui = Denemo.gui;
 
62
  gboolean retval;
 
63
  GError *error = NULL;
 
64
 
 
65
  /* get the uri to the manual */
 
66
  gchar *manualpath = g_build_filename (get_data_dir (), "manual",
 
67
                                        "denemo-manual.html", NULL);
 
68
  gchar *manualuri =  url?g_strdup(url):g_filename_to_uri (manualpath, NULL, NULL);
 
69
 
 
70
  /* check that the browser exists */
 
71
  gchar *browserpath = g_find_program_in_path (Denemo.prefs.browser->str);
 
72
  if (browserpath == NULL)
 
73
    {
 
74
      if(run_file_association(manualuri))
 
75
        return;
 
76
      /* show a warning dialog */
 
77
      GtkWidget *dialog =
 
78
        gtk_message_dialog_new (GTK_WINDOW (Denemo.window),
 
79
                                GTK_DIALOG_DESTROY_WITH_PARENT,
 
80
                                GTK_MESSAGE_WARNING,
 
81
                                GTK_BUTTONS_OK,
 
82
                                _("Could not find %s in the path"),
 
83
                                Denemo.prefs.browser->str);
 
84
      gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
 
85
                                                _("Please edit the chosen "
 
86
                                                  "browser in the "
 
87
                                                  "preferences."));
 
88
      gtk_dialog_run (GTK_DIALOG (dialog));
 
89
 
 
90
      /* free the memory and return */
 
91
      gtk_widget_destroy (dialog);
 
92
      g_free (manualpath);
 
93
      g_free (manualuri);
 
94
      return;
 
95
    }
 
96
 
 
97
  /* spawn the process to show the manual */
 
98
  gchar *argv[] = {Denemo.prefs.browser->str,
 
99
                   manualuri,
 
100
                   NULL};
 
101
  retval = g_spawn_async (NULL, argv, NULL,
 
102
                          G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
 
103
  if (!retval)
 
104
    {
 
105
      g_message (_("Could not execute specified web browser: %s\n"),
 
106
                 error->message);
 
107
      g_error_free (error);
 
108
    }
 
109
 
 
110
  /* free the memory */
 
111
  g_free (browserpath);
 
112
  g_free (manualpath);
 
113
  g_free (manualuri);
 
114
}