Change Language

  • Lutz

    Lutz - 2004-09-19

    I ones did a small patch to gaim 0.74 which allowed to change the language for the spellchecking for each conversation.
    I simply added a small drop down box to the toolbar. Unluckily did the source code of gaim changed quite a lot afterwards so the patch does not any longer apply.

    So I wanted to ask if somebody could point me to where the toolbar is put together now.

    I would also submit the patch if somebody else would be intressted in having a such a feature :)

    • laksefisker

      laksefisker - 2004-10-03

      I would be highly interested in such a feature!! In fact, I've been doing some poking around myself trying to figure out how to change the language for the spellchecker to no avail. Please, submit this patch! :-D

    • Lutz

      Lutz - 2004-10-05

      I can (will post it at the end) but I am not sure if it will be a of use for you. Simply because I did write it for the version 0.74.  And it did apply upto 0.7something. But not for anything from 0.8 or later.

      Untill now I was to lazy to go through code again and try to find out myself how to do that again. Thatsway I did ask if somebody could give me a hint where to start - so to say where the toolbar is put together now. But Maybe I will take a loke soon again.

      But anyway the patch is not one of the more pretty ones. The main problem is that it uses a drop-down-box  that is prefiled with de_de and en_en. But you can type in what ever else you want.
      It just should be supported by gtkspell (and therefore by aspell)

      I am also thinking about to write it as a plugin. - There is just the trouble that I have absolutly no idea how to do that. So if somebody could direct me there (like telling me how to add an widget to the toolbar and how modify properties of the conversation/entry window :)

      But maybe you have some sparetime right now and can transform that into something working again:

      diff -c gaim-0.74.orig/src/gtkconv.c gaim-0.74/src/gtkconv.c
      *** gaim-0.74.orig/src/gtkconv.c    Fri Nov 21 19:12:55 2003
      --- gaim-0.74/src/gtkconv.c    Sun Dec  7 14:26:52 2003
      *** 127,132 ****
      --- 127,133 ----
        static void do_small(GtkWidget *smalltb, GaimGtkConversation *gtkconv);
        static void do_normal(GtkWidget *normal, GaimGtkConversation *gtkconv);
        static void do_big(GtkWidget *large, GaimGtkConversation *gtkconv);
      + static void do_lang(GtkWidget *language, GaimGtkConversation *gtkconv);
        static void toggle_font(GtkWidget *font, GaimConversation *conv);
        static void toggle_fg_color(GtkWidget *color, GaimConversation *conv);
        static void toggle_bg_color(GtkWidget *color, GaimConversation *conv);
      *** 2205,2210 ****
      --- 2206,2249 ----
        static void
      + report_gtkspell_error(const char *err, GaimGtkConversation *gtkconv) {
      +     GtkWidget *dlg;
      +     dlg = gtk_message_dialog_new(
      +             NULL,
      +             0,
      +             GTK_MESSAGE_ERROR,
      +             GTK_BUTTONS_CLOSE,
      +             "GtkSpell error: %s", err);
      +     gtk_dialog_run(GTK_DIALOG(dlg));
      +     gtk_widget_destroy(dlg);
      + }
      + static void
      + do_lang(GtkWidget *language, GaimGtkConversation *gtkconv)
      + {
      + #ifdef USE_GTKSPELL
      +     GtkSpell *spell;
      +     gchar *lang;
      +     GError *error = NULL;
      +     g_print("Language will be set to\n");
      +     g_print("\t%s\n",gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (gtkconv->toolbar.language)->entry)));
      +     spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry));
      +     if (spell == NULL)
      +         return;
      +     lang = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (gtkconv->toolbar.language)->entry));
      +     if (lang[0]!=0) {
      +         if (!gtkspell_set_language(spell, lang, &error)) {
      +                 report_gtkspell_error(error->message,gtkconv);
      +                 g_error_free(error);
      +         }   
      +     }
      + #endif /* USE_GTKSPELL */
      + }
      + static void
        do_underline(GtkWidget *underline, GaimGtkConversation *gtkconv)
            if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(underline)))
      *** 3224,3230 ****
      --- 3263,3271 ----
            GtkWidget *hbox;
            GtkWidget *button;
            GtkWidget *sep;
      +     GtkWidget *combo;
            GtkSizeGroup *sg;
      +     GList *langs=NULL;
            gtkconv = GAIM_GTK_CONVERSATION(conv);

      *** 3387,3392 ****
      --- 3428,3454 ----
                             G_CALLBACK(insert_smiley_cb), conv);
            gtkconv->toolbar.smiley = button;
      +     /* Insert language-selection for gtkspell (languages are hardcoded - not nice but a first hack) */
      +     if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) {
      +            langs=g_list_append(langs,"en_en");
      +            langs=g_list_append(langs,"de_de");
      +            combo=gtk_combo_new();
      +            gtk_combo_set_popdown_strings(GTK_COMBO(combo),langs);
      +            gtk_widget_set_usize (combo, 80, -2);
      +            gtk_combo_disable_activate(GTK_COMBO(combo));
      +            gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
      +            gtk_tooltips_set_tip(gtkconv->tooltips, combo, _("Change language for spellcheck"), NULL);
      +            g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry), "activate",
      +                      G_CALLBACK(do_lang), gtkconv);
      +            g_signal_connect(G_OBJECT(GTK_COMBO(combo)->popwin), "hide",
      +                      G_CALLBACK(do_lang), gtkconv);
      +            gtkconv->toolbar.language = combo;
      +     }
            sep = gtk_hseparator_new();
      diff -c gaim-0.74.orig/src/gtkconv.h gaim-0.74/src/gtkconv.h
      *** gaim-0.74.orig/src/gtkconv.h    Sat Oct 25 02:03:13 2003
      --- gaim-0.74/src/gtkconv.h    Sat Dec  6 12:38:30 2003
      *** 174,179 ****
      --- 174,180 ----
                GtkWidget *image;
                GtkWidget *link;
                GtkWidget *smiley;
      +             GtkWidget *language;
                GtkWidget *log;
            } toolbar;

    • laksefisker

      laksefisker - 2004-10-06

      I did some poking around, trying to piece it together. It seems that the toolbar has been separated into gtkimhtmltoolbar.c/.h, but not all of that patch "fits in" in those files. gtkconv.c is a monster, and I can't seem to find out where to put the rest of the patch in there.

      It's a case of "so close, yet still so far". This being the first time I've ever hacked at Gaim doesn't help either. :-/ If someone else is up for the challenge, it'd be great. It's just a matter of taking the code provided above and sticking it in the right place, I think.

      • Luke Schierer

        Luke Schierer - 2004-10-06

        a preference to change the language used for spell checking is currently waiting on the release of gtkspell 3.0 which we are told will significantly simplify the code needed to determine what language is currently in use and what languages are available to use.

        • laksefisker

          laksefisker - 2004-10-07

          Excellent! So there are plans to make this feature user-selectable?

          Gaim already is the best IM client out there, this feature will have it totally outclass the competition! :-D

          • Merlin

            Merlin - 2004-12-26

            I would really love this feature. Like the previous poster said, this would be a feature other IMs I know are lacking. Setting the language per contact would be just great.

    • Lutz

      Lutz - 2004-10-19

      Sorry For not responding earlier but somehow I got a bit busy.
      Nice to hear that this feature is about to come.

      Maybe it would have been a better idea to hack gtkspell in the first place. :)

    • Lutz

      Lutz - 2004-11-29

      Can aybody give me a hint on how to get from  GtkIMHtmlToolbar  back to the conversation-window. Especialy the entry element of GaimGtkConversation.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks