static void manual_open_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
-static void faq_open_cb (MainWindow *mainwin,
- guint action,
- GtkWidget *widget);
static void scan_tree_func (Folder *folder,
FolderItem *item,
NULL, NULL, 0, "<Branch>"},
{N_("/_Help"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
- {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
- {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
- {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
- {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
- {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
- {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
- {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
- {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
- {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
+ {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
+ {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
+ NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
+ {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
+ {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
+ NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
{N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Help/_About"), NULL, about_show, 0, NULL}
};
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
ifactory = gtk_item_factory_from_widget(menubar);
+ menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
+ menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
+
handlebox = gtk_handle_box_new();
gtk_widget_show(handlebox);
gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
static void manual_open_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- manual_open((ManualLang)action);
-}
-
-static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
-{
- faq_open((ManualLang)action);
+ manual_open((ManualType)action);
}
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
#include <glib.h>
#include <string.h>
+#include <locale.h>
#include "prefs_common.h"
#include "manual.h"
#include "utils.h"
-static gchar *get_lang_str(ManualLang lang);
+static gchar *sylpheeddoc_manuals[] =
+{
+ "en",
+ "es",
+ "fr",
+ "de",
+};
-static gchar *get_lang_str(ManualLang lang)
+static gchar *get_language()
{
- switch (lang) {
- case MANUAL_LANG_DE:
- return "de";
- case MANUAL_LANG_EN:
- return "en";
- case MANUAL_LANG_ES:
- return "es";
- case MANUAL_LANG_FR:
- return "fr";
- case MANUAL_LANG_IT:
- return "it";
- case MANUAL_LANG_JA:
- return "ja";
- default:
- return NULL;
+ gchar *language;
+ gchar *c;
+
+ language = g_strdup(setlocale(LC_ALL, NULL));
+ if((c = strchr(language, ',')) != NULL)
+ *c = '\0';
+ if((c = strchr(language, '_')) != NULL)
+ *c = '\0';
+
+ return language;
+}
+
+static gchar *get_local_path_with_locale(gchar *rootpath)
+{
+ gchar *lang_str, *dir;
+
+ lang_str = get_language();
+ dir = g_strconcat(rootpath, G_DIR_SEPARATOR_S,
+ lang_str, NULL);
+ g_free(lang_str);
+ if(!is_dir_exist(dir)) {
+ g_free(dir);
+ dir = g_strconcat(rootpath, G_DIR_SEPARATOR_S,
+ "en", NULL);
+ if(!is_dir_exist(dir)) {
+ g_free(dir);
+ dir = NULL;
+ }
}
+
+ return dir;
}
-void manual_open(ManualLang lang)
+gboolean manual_available(ManualType type)
{
- gchar *lang_str;
- gchar *file_uri;
+ gboolean ret = FALSE;
+ gchar *dir = NULL;
+
+ switch (type) {
+ case MANUAL_MANUAL_LOCAL:
+ dir = get_local_path_with_locale(MANUALDIR);
+ if (dir != NULL) {
+ g_free(dir);
+ ret = TRUE;
+ }
+ break;
+ case MANUAL_FAQ_LOCAL:
+ dir = get_local_path_with_locale(FAQDIR);
+ if (dir != NULL) {
+ g_free(dir);
+ ret = TRUE;
+ }
+ break;
+ default:
+ ret = FALSE;
+ }
- lang_str = get_lang_str(lang);
- if (!lang_str) return;
+ return ret;
+}
- file_uri = g_strconcat("file://", MANUALDIR,
- G_DIR_SEPARATOR_S, lang_str, G_DIR_SEPARATOR_S,
- MANUAL_HTML_INDEX, NULL);
- debug_print("Opening manual: %s\n", file_uri);
- open_uri(file_uri, prefs_common.uri_cmd);
- g_free(file_uri);
+static gchar *get_syldoc_language()
+{
+ gchar *language;
+ int i;
+
+ language = get_language();
+ for (i = 0; i < sizeof(sylpheeddoc_manuals) / sizeof(sylpheeddoc_manuals[0]); i++) {
+ if (strcmp(language, sylpheeddoc_manuals[i]) == 0) {
+ return language;
+ }
+ }
+ g_free(language);
+
+ return g_strdup("en");
}
-void faq_open(ManualLang lang)
+void manual_open(ManualType type)
{
+ gchar *uri = NULL;
+ gchar *dir;
gchar *lang_str;
- gchar *file_uri;
- lang_str = get_lang_str(lang);
- if (!lang_str) return;
+ switch (type) {
+ case MANUAL_MANUAL_LOCAL:
+ dir = get_local_path_with_locale(MANUALDIR);
+ if (dir != NULL) {
+ uri = g_strconcat("file://", dir, G_DIR_SEPARATOR_S, MANUAL_HTML_INDEX, NULL);
+ g_free(dir);
+ }
+ break;
- file_uri = g_strconcat("file://", FAQDIR,
- G_DIR_SEPARATOR_S, lang_str, G_DIR_SEPARATOR_S,
- FAQ_HTML_INDEX, NULL);
- debug_print("Opening FAQ: %s\n", file_uri);
- open_uri(file_uri, prefs_common.uri_cmd);
- g_free(file_uri);
+ case MANUAL_FAQ_LOCAL:
+ dir = get_local_path_with_locale(FAQDIR);
+ if (dir != NULL) {
+ uri = g_strconcat("file://", dir, G_DIR_SEPARATOR_S, FAQ_HTML_INDEX, NULL);
+ g_free(dir);
+ }
+ break;
+
+ case MANUAL_MANUAL_SYLDOC:
+ lang_str = get_syldoc_language();
+ uri = g_strconcat("http://sylpheeddoc.sourceforge.net/", lang_str, "/manual/manual.html", NULL);
+ g_free(lang_str);
+ break;
+
+ case MANUAL_FAQ_SYLDOC:
+ lang_str = get_syldoc_language();
+ uri = g_strconcat("http://sylpheeddoc.sourceforge.net/", lang_str, "/faq/faq.html", NULL);
+ g_free(lang_str);
+ break;
+
+ default:
+ break;
+ }
+ open_uri(uri, prefs_common.uri_cmd);
+ g_free(uri);
}