summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-11-12 11:55:10 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-11-12 11:55:10 +0000
commit32f48c30337a0517797836b08dbe8b9c70cb79bc (patch)
tree04a14c070a855cd08712615991c9d9e32809f0b3 /fluid
parent643e98156f5ad5a40718f75a415a9cb2a6646ee9 (diff)
Fixed missing internationalisation of menus generate by Fluid (STR #2246)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7822 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
-rw-r--r--fluid/Fl_Menu_Type.cxx66
-rw-r--r--fluid/alignment_panel.cxx61
-rw-r--r--fluid/alignment_panel.fl69
-rw-r--r--fluid/alignment_panel.h4
4 files changed, 100 insertions, 100 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx
index de41a3a03..f9885b7f3 100644
--- a/fluid/Fl_Menu_Type.cxx
+++ b/fluid/Fl_Menu_Type.cxx
@@ -228,9 +228,13 @@ void Fl_Menu_Item_Type::write_static() {
// entire array out:
const char* k = class_name(1);
if (k) {
- int i; write_c("\nFl_Menu_Item %s::%s[] = {\n", k, menu_name(i));
+ int i;
+ if (i18n_type) write_c("\nunsigned char %s::%s_i18n_done = 0;", k, menu_name(i));
+ write_c("\nFl_Menu_Item %s::%s[] = {\n", k, menu_name(i));
} else {
- int i; write_c("\nFl_Menu_Item %s[] = {\n", menu_name(i));
+ int i;
+ if (i18n_type) write_c("\nunsigned char %s_i18n_done = 0;", menu_name(i));
+ write_c("\nFl_Menu_Item %s[] = {\n", menu_name(i));
}
Fl_Type* t = prev; while (t && t->is_menu_item()) t = t->prev;
for (Fl_Type* q = t->next; q && q->is_menu_item(); q = q->next) {
@@ -291,24 +295,7 @@ void Fl_Menu_Item_Type::write_item() {
write_c(" {");
if (image) write_c("0");
- else if (label()) {
- switch (i18n_type) {
- case 0 : /* None */
- write_cstring(label());
- break;
- case 1 : /* GNU gettext */
- write_c("%s(", i18n_function);
- write_cstring(label());
- write_c(")");
- break;
- case 2 : /* POSIX catgets */
- write_c("catgets(%s,%s,%d,", i18n_file[0] ? i18n_file : "_catalog",
- i18n_set, msgnum());
- write_cstring(label());
- write_c(")");
- break;
- }
- }
+ else if (label()) write_cstring(label()); // we will call i18n when the widget is instantiated for the first time
else write_c("\"\"");
if (((Fl_Button*)o)->shortcut()) {
int s = ((Fl_Button*)o)->shortcut();
@@ -341,10 +328,13 @@ void Fl_Menu_Item_Type::write_code1() {
int i; const char* mname = menu_name(i);
if (!prev->is_menu_item()) {
// for first menu item, declare the array
- if (class_name(1))
+ if (class_name(1)) {
+ if (i18n_type) write_h(" static unsigned char %s_i18n_done;\n", mname);
write_h(" static Fl_Menu_Item %s[];\n", mname);
- else
+ } else {
+ if (i18n_type) write_h("extern unsigned char %s_i18n_done;\n", mname);
write_h("extern Fl_Menu_Item %s[];\n", mname);
+ }
}
const char *c = array_name(this);
@@ -468,9 +458,39 @@ Fl_Type* Fl_Menu_Type::click_test(int, int) {
}
void Fl_Menu_Type::write_code2() {
- if (next && next->is_menu_item())
+ if (next && next->is_menu_item()) {
+ if (i18n_type) {
+ // take care of i18n now!
+ Fl_Menu_Item_Type *mi = (Fl_Menu_Item_Type*)next;
+ int i, nItem = 0, nLabel = 0;
+ const char *mName = mi->menu_name(i);
+ for (Fl_Type* q = next; q && q->is_menu_item(); q = q->next) {
+ if (((Fl_Menu_Item_Type*)q)->label()) nLabel++;
+ nItem++;
+ }
+ if (nLabel) {
+ write_c("%sif (!%s_i18n_done) {\n", indent(), mName);
+ write_c("%s int i=0;\n", indent());
+ write_c("%s for ( ; i<%d; i++)\n", indent(), nItem);
+ write_c("%s if (%s[i].label())\n", indent(), mName);
+ switch (i18n_type) {
+ case 1:
+ write_c("%s %s[i].label(%s(%s[i].label()));\n",
+ indent(), mName, i18n_function, mName);
+ break;
+ case 2:
+ write_c("%s %s[i].label(catgets(%s,%s,i+%d,%s[i].label()));\n",
+ indent(), mName, i18n_file[0] ? i18n_file : "_catalog",
+ i18n_set, mi->msgnum(), mName);
+ break;
+ }
+ write_c("%s %s_i18n_done = 1;\n", indent(), mName);
+ write_c("%s}\n", indent());
+ }
+ }
write_c("%s%s->menu(%s);\n", indent(), name() ? name() : "o",
unique_id(this, "menu", name(), label()));
+ }
Fl_Widget_Type::write_code2();
}
diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx
index a09b8dce8..4fd36941f 100644
--- a/fluid/alignment_panel.cxx
+++ b/fluid/alignment_panel.cxx
@@ -28,6 +28,7 @@
// generated by Fast Light User Interface Designer (fluid) version 1.0300
#include "alignment_panel.h"
+Fl_Text_Buffer *shell_run_buffer;
Fl_Double_Window *project_window=(Fl_Double_Window *)0;
@@ -46,9 +47,9 @@ Fl_Check_Button *use_FL_COMMAND_button=(Fl_Check_Button *)0;
Fl_Choice *i18n_type_chooser=(Fl_Choice *)0;
Fl_Menu_Item menu_i18n_type_chooser[] = {
- {"None", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0},
- {"GNU gettext", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0},
- {"POSIX catgets", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0},
+ {"None", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"GNU gettext", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"POSIX catgets", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0}
};
@@ -61,103 +62,82 @@ Fl_Input *i18n_set_input=(Fl_Input *)0;
Fl_Input *i18n_function_input=(Fl_Input *)0;
Fl_Double_Window* make_project_window() {
- { project_window = new Fl_Double_Window(358, 207, "Project Settings");
- { Fl_Button* o = new Fl_Button(293, 175, 52, 20, "Close");
+ { project_window = new Fl_Double_Window(399, 252, "Project Settings");
+ { Fl_Button* o = new Fl_Button(328, 216, 60, 25, "Close");
o->tooltip("Close this dialog.");
- o->labelsize(11);
o->callback((Fl_Callback*)cb_Close);
} // Fl_Button* o
- { Fl_Tabs* o = new Fl_Tabs(10, 10, 335, 151);
+ { Fl_Tabs* o = new Fl_Tabs(10, 10, 378, 195);
o->selection_color((Fl_Color)12);
- o->labelsize(11);
- { Fl_Group* o = new Fl_Group(10, 30, 335, 131, "Output");
- o->labelsize(11);
- { Fl_Box* o = new Fl_Box(15, 40, 325, 15, "Use \"name.ext\" to set name or just \".ext\" to set extension.");
- o->labelsize(11);
+ { Fl_Group* o = new Fl_Group(10, 36, 378, 169, "Output");
+ o->hide();
+ { Fl_Box* o = new Fl_Box(100, 49, 236, 49, "Use \"name.ext\" to set a file name or just \".ext\" to set extension.");
o->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
} // Fl_Box* o
- { header_file_input = new Fl_Input(96, 60, 228, 20, "Header File:");
+ { header_file_input = new Fl_Input(99, 103, 272, 20, "Header File:");
header_file_input->tooltip("The name of the generated header file.");
header_file_input->box(FL_THIN_DOWN_BOX);
header_file_input->labelfont(1);
- header_file_input->labelsize(11);
header_file_input->textfont(4);
- header_file_input->textsize(11);
header_file_input->callback((Fl_Callback*)header_input_cb, (void*)(1));
header_file_input->when(FL_WHEN_CHANGED);
} // Fl_Input* header_file_input
- { code_file_input = new Fl_Input(97, 85, 227, 20, "Code File:");
+ { code_file_input = new Fl_Input(100, 128, 272, 20, "Code File:");
code_file_input->tooltip("The name of the generated code file.");
code_file_input->box(FL_THIN_DOWN_BOX);
code_file_input->labelfont(1);
- code_file_input->labelsize(11);
code_file_input->textfont(4);
- code_file_input->textsize(11);
code_file_input->callback((Fl_Callback*)code_input_cb, (void*)(1));
code_file_input->when(FL_WHEN_CHANGED);
} // Fl_Input* code_file_input
- { include_H_from_C_button = new Fl_Check_Button(95, 110, 145, 20, "Include Header from Code");
+ { include_H_from_C_button = new Fl_Check_Button(100, 153, 272, 20, "Include Header from Code");
include_H_from_C_button->tooltip("Include the header file from the code file.");
include_H_from_C_button->down_box(FL_DOWN_BOX);
- include_H_from_C_button->labelsize(11);
include_H_from_C_button->callback((Fl_Callback*)include_H_from_C_button_cb);
} // Fl_Check_Button* include_H_from_C_button
- { use_FL_COMMAND_button = new Fl_Check_Button(95, 130, 245, 20, "Generate menu shortcuts using FL_COMMAND");
+ { use_FL_COMMAND_button = new Fl_Check_Button(100, 176, 272, 20, "Menu shortcuts use FL_COMMAND");
use_FL_COMMAND_button->tooltip("Replace FL_CTRL with FL_COMMAND when generating menu shortcut code.");
use_FL_COMMAND_button->down_box(FL_DOWN_BOX);
- use_FL_COMMAND_button->labelsize(11);
use_FL_COMMAND_button->callback((Fl_Callback*)use_FL_COMMAND_button_cb);
} // Fl_Check_Button* use_FL_COMMAND_button
o->end();
} // Fl_Group* o
- { Fl_Group* o = new Fl_Group(10, 30, 335, 131, "Internationalization");
- o->labelsize(11);
- o->hide();
- { i18n_type_chooser = new Fl_Choice(80, 42, 100, 20, "Use:");
+ { Fl_Group* o = new Fl_Group(10, 36, 378, 169, "Internationalization");
+ { i18n_type_chooser = new Fl_Choice(100, 48, 136, 25, "Use:");
i18n_type_chooser->tooltip("Type of internationalization to use.");
i18n_type_chooser->box(FL_THIN_UP_BOX);
i18n_type_chooser->down_box(FL_BORDER_BOX);
i18n_type_chooser->labelfont(1);
- i18n_type_chooser->labelsize(11);
- i18n_type_chooser->textsize(11);
i18n_type_chooser->callback((Fl_Callback*)i18n_type_cb);
i18n_type_chooser->menu(menu_i18n_type_chooser);
} // Fl_Choice* i18n_type_chooser
- { i18n_include_input = new Fl_Input(80, 67, 245, 20, "#include:");
+ { i18n_include_input = new Fl_Input(100, 78, 272, 20, "#include:");
i18n_include_input->tooltip("The include file for internationalization.");
i18n_include_input->box(FL_THIN_DOWN_BOX);
i18n_include_input->labelfont(1);
- i18n_include_input->labelsize(11);
i18n_include_input->textfont(4);
- i18n_include_input->textsize(11);
i18n_include_input->callback((Fl_Callback*)i18n_text_cb);
} // Fl_Input* i18n_include_input
- { i18n_file_input = new Fl_Input(80, 92, 245, 20, "File:");
+ { i18n_file_input = new Fl_Input(100, 104, 272, 20, "File:");
i18n_file_input->tooltip("The name of the message catalog.");
i18n_file_input->box(FL_THIN_DOWN_BOX);
i18n_file_input->labelfont(1);
- i18n_file_input->labelsize(11);
i18n_file_input->textfont(4);
- i18n_file_input->textsize(11);
i18n_file_input->callback((Fl_Callback*)i18n_text_cb);
} // Fl_Input* i18n_file_input
- { i18n_set_input = new Fl_Input(80, 117, 245, 20, "Set:");
+ { i18n_set_input = new Fl_Input(100, 128, 272, 20, "Set:");
i18n_set_input->tooltip("The message set number.");
i18n_set_input->type(2);
i18n_set_input->box(FL_THIN_DOWN_BOX);
i18n_set_input->labelfont(1);
- i18n_set_input->labelsize(11);
i18n_set_input->textfont(4);
- i18n_set_input->textsize(11);
i18n_set_input->callback((Fl_Callback*)i18n_text_cb);
} // Fl_Input* i18n_set_input
- { i18n_function_input = new Fl_Input(80, 92, 245, 20, "Function:");
+ { i18n_function_input = new Fl_Input(100, 103, 272, 20, "Function:");
i18n_function_input->tooltip("The function to call to internationalize the labels and tooltips.");
i18n_function_input->box(FL_THIN_DOWN_BOX);
i18n_function_input->labelfont(1);
- i18n_function_input->labelsize(11);
i18n_function_input->textfont(4);
- i18n_function_input->textsize(11);
i18n_function_input->callback((Fl_Callback*)i18n_text_cb);
} // Fl_Input* i18n_function_input
o->end();
@@ -169,7 +149,6 @@ Fl_Double_Window* make_project_window() {
} // Fl_Double_Window* project_window
return project_window;
}
-Fl_Text_Buffer *shell_run_buffer;
void scheme_cb(Fl_Choice *, void *);
Fl_Double_Window *settings_window=(Fl_Double_Window *)0;
diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl
index 3c782bb85..97e18c685 100644
--- a/fluid/alignment_panel.fl
+++ b/fluid/alignment_panel.fl
@@ -52,93 +52,100 @@ decl {extern int show_coredevmenus;} {public local
decl {extern struct Fl_Menu_Item *dbmanager_item;} {public local
}
-Function {make_project_window()} {} {
+decl {extern Fl_Preferences fluid_prefs;} {public local
+}
+
+decl {Fl_Text_Buffer *shell_run_buffer;} {public local
+}
+
+Function {make_project_window()} {open
+} {
Fl_Window project_window {
- label {Project Settings}
- xywh {393 460 358 207} type Double
+ label {Project Settings} open
+ xywh {393 460 399 252} type Double
code0 {\#include <FL/Fl_Preferences.H>}
code1 {\#include <FL/Fl_Tooltip.H>} modal visible
} {
Fl_Button {} {
label Close
callback {project_window->hide();}
- tooltip {Close this dialog.} xywh {293 175 52 20} labelsize 11
+ tooltip {Close this dialog.} xywh {328 216 60 25}
}
Fl_Tabs {} {open
- xywh {10 10 335 151} selection_color 12 labelsize 11
+ xywh {10 10 378 195} selection_color 12
} {
Fl_Group {} {
label Output open
- xywh {10 30 335 131} labelsize 11
+ xywh {10 36 378 169} hide
} {
Fl_Box {} {
- label {Use "name.ext" to set name or just ".ext" to set extension.}
- xywh {15 40 325 15} labelsize 11 align 144
+ label {Use "name.ext" to set a file name or just ".ext" to set extension.}
+ xywh {100 49 236 49} align 144
}
Fl_Input header_file_input {
label {Header File:}
user_data 1 user_data_type {void*}
callback header_input_cb
- tooltip {The name of the generated header file.} xywh {96 60 228 20} box THIN_DOWN_BOX labelfont 1 labelsize 11 when 1 textfont 4 textsize 11
+ tooltip {The name of the generated header file.} xywh {99 103 272 20} box THIN_DOWN_BOX labelfont 1 when 1 textfont 4
}
Fl_Input code_file_input {
label {Code File:}
user_data 1 user_data_type {void*}
callback code_input_cb
- tooltip {The name of the generated code file.} xywh {97 85 227 20} box THIN_DOWN_BOX labelfont 1 labelsize 11 when 1 textfont 4 textsize 11
+ tooltip {The name of the generated code file.} xywh {100 128 272 20} box THIN_DOWN_BOX labelfont 1 when 1 textfont 4
}
Fl_Check_Button include_H_from_C_button {
label {Include Header from Code}
callback include_H_from_C_button_cb
- tooltip {Include the header file from the code file.} xywh {95 110 145 20} down_box DOWN_BOX labelsize 11
+ tooltip {Include the header file from the code file.} xywh {100 153 272 20} down_box DOWN_BOX
}
Fl_Check_Button use_FL_COMMAND_button {
- label {Generate menu shortcuts using FL_COMMAND}
+ label {Menu shortcuts use FL_COMMAND}
callback use_FL_COMMAND_button_cb
- tooltip {Replace FL_CTRL with FL_COMMAND when generating menu shortcut code.} xywh {95 130 245 20} down_box DOWN_BOX labelsize 11
+ tooltip {Replace FL_CTRL with FL_COMMAND when generating menu shortcut code.} xywh {100 176 272 20} down_box DOWN_BOX
}
}
Fl_Group {} {
label Internationalization open
- xywh {10 30 335 131} labelsize 11 hide
+ xywh {10 36 378 169}
} {
Fl_Choice i18n_type_chooser {
label {Use:}
callback i18n_type_cb open
- tooltip {Type of internationalization to use.} xywh {80 42 100 20} box THIN_UP_BOX down_box BORDER_BOX labelfont 1 labelsize 11 textsize 11
+ tooltip {Type of internationalization to use.} xywh {100 48 136 25} box THIN_UP_BOX down_box BORDER_BOX labelfont 1
} {
MenuItem {} {
label None
- xywh {0 0 100 20} labelsize 11
+ xywh {0 0 100 20}
}
MenuItem {} {
- label {GNU gettext}
- xywh {0 0 100 20} labelsize 11
+ label {GNU gettext} selected
+ xywh {0 0 100 20}
}
MenuItem {} {
label {POSIX catgets}
- xywh {0 0 100 20} labelsize 11
+ xywh {0 0 100 20}
}
}
Fl_Input i18n_include_input {
label {\#include:}
callback i18n_text_cb
- tooltip {The include file for internationalization.} xywh {80 67 245 20} box THIN_DOWN_BOX labelfont 1 labelsize 11 textfont 4 textsize 11
+ tooltip {The include file for internationalization.} xywh {100 78 272 20} box THIN_DOWN_BOX labelfont 1 textfont 4
}
Fl_Input i18n_file_input {
label {File:}
callback i18n_text_cb
- tooltip {The name of the message catalog.} xywh {80 92 245 20} box THIN_DOWN_BOX labelfont 1 labelsize 11 textfont 4 textsize 11
+ tooltip {The name of the message catalog.} xywh {100 104 272 20} box THIN_DOWN_BOX labelfont 1 textfont 4
}
Fl_Input i18n_set_input {
label {Set:}
callback i18n_text_cb
- tooltip {The message set number.} xywh {80 117 245 20} type Int box THIN_DOWN_BOX labelfont 1 labelsize 11 textfont 4 textsize 11
+ tooltip {The message set number.} xywh {100 128 272 20} type Int box THIN_DOWN_BOX labelfont 1 textfont 4
}
Fl_Input i18n_function_input {
label {Function:}
callback i18n_text_cb
- tooltip {The function to call to internationalize the labels and tooltips.} xywh {80 92 245 20} box THIN_DOWN_BOX labelfont 1 labelsize 11 textfont 4 textsize 11
+ tooltip {The function to call to internationalize the labels and tooltips.} xywh {100 103 272 20} box THIN_DOWN_BOX labelfont 1 textfont 4
}
}
}
@@ -148,17 +155,10 @@ Function {make_project_window()} {} {
decl {extern void i18n_cb(Fl_Choice *,void *);} {public local
}
-decl {extern Fl_Preferences fluid_prefs;} {public local
-}
-
-decl {Fl_Text_Buffer *shell_run_buffer;} {public local
-}
-
decl {void scheme_cb(Fl_Choice *, void *);} {public local
}
-Function {make_settings_window()} {open
-} {
+Function {make_settings_window()} {} {
Fl_Window settings_window {
label {GUI Settings} open
xywh {393 191 339 241} type Double non_modal visible
@@ -189,7 +189,7 @@ Function {make_settings_window()} {open
xywh {10 10 35 25}
}
}
- Fl_Group {} {open selected
+ Fl_Group {} {open
xywh {116 43 220 126} labelfont 1 align 0
} {
Fl_Box {} {
@@ -260,7 +260,7 @@ load_history();}
Function {make_shell_window()} {} {
Fl_Window shell_window {
- label {Shell Command}
+ label {Shell Command} open
xywh {741 195 365 125} type Double visible
} {
Fl_Input shell_command_input {
@@ -323,7 +323,8 @@ Function {make_shell_window()} {} {
}
}
-Function {make_layout_window()} {} {
+Function {make_layout_window()} {open
+} {
Fl_Window grid_window {
label {Layout Settings} open
xywh {760 427 285 245} type Double non_modal visible
diff --git a/fluid/alignment_panel.h b/fluid/alignment_panel.h
index b5e6b201e..7f8a179f7 100644
--- a/fluid/alignment_panel.h
+++ b/fluid/alignment_panel.h
@@ -37,6 +37,8 @@ extern void redraw_browser();
extern int show_comments;
extern int show_coredevmenus;
extern struct Fl_Menu_Item *dbmanager_item;
+extern Fl_Preferences fluid_prefs;
+extern Fl_Text_Buffer *shell_run_buffer;
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Preferences.H>
#include <FL/Fl_Tooltip.H>
@@ -66,8 +68,6 @@ extern Fl_Input *i18n_function_input;
Fl_Double_Window* make_project_window();
extern Fl_Menu_Item menu_i18n_type_chooser[];
extern void i18n_cb(Fl_Choice *,void *);
-extern Fl_Preferences fluid_prefs;
-extern Fl_Text_Buffer *shell_run_buffer;
extern void scheme_cb(Fl_Choice *, void *);
extern Fl_Double_Window *settings_window;
extern void scheme_cb(Fl_Choice*, void*);