* src/mainwindow.c
authorChristoph Hohmann <reboot@gmx.ch>
Wed, 23 Oct 2002 23:15:49 +0000 (23:15 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Wed, 23 Oct 2002 23:15:49 +0000 (23:15 +0000)
* src/manual.[ch]
        o use manual of current locale or english if current
          locale is not available (and english is available)
        o also link to sylpheed doc project manuals

ChangeLog.claws
configure.in
src/mainwindow.c
src/manual.c
src/manual.h

index 89e786d..11bbfc2 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-24 [christoph] 0.8.5claws52
+
+       * src/mainwindow.c
+       * src/manual.[ch]
+               o use manual of current locale or english if current
+                 locale is not available (and english is available)
+               o also link to sylpheed doc project manuals
+
 2002-10-23 [paul]      0.8.5claws51
 
        * tools/README
index 1b23bb1..a552fc5 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws51
+EXTRA_VERSION=claws52
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index d1ae3bb..c854ee8 100644 (file)
@@ -484,9 +484,6 @@ static void online_switch_clicked(GtkButton     *btn,
 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,
@@ -802,18 +799,12 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                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}
 };
@@ -919,6 +910,9 @@ MainWindow *main_window_create(SeparateType type)
        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);
@@ -3525,12 +3519,7 @@ static void account_menu_cb(GtkMenuItem  *menuitem, gpointer data)
 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)
index 8afc4bd..981c734 100644 (file)
 
 #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);
 }
index 6ae384f..8b6d330 100644 (file)
 
 typedef enum
 {
-       MANUAL_LANG_DE,
-       MANUAL_LANG_EN,
-       MANUAL_LANG_ES,
-       MANUAL_LANG_FR,
-       MANUAL_LANG_IT,
-       MANUAL_LANG_JA,
-} ManualLang;
+       MANUAL_MANUAL_LOCAL,
+       MANUAL_MANUAL_SYLDOC,
+       MANUAL_FAQ_LOCAL,
+       MANUAL_FAQ_SYLDOC,
+} ManualType;
 
-void manual_open(ManualLang lang);
-void faq_open  (ManualLang lang);
+gboolean manual_available      (ManualType type);
+void    manual_open            (ManualType type);
 
 #endif /* __MANUAL_H__ */