diff options
author | Steve Zesch <[email protected]> | 2012-11-24 20:47:50 -0500 |
---|---|---|
committer | Steve Zesch <[email protected]> | 2012-11-24 20:47:50 -0500 |
commit | 3e4dfc47e7803d16d14ffe655f9568871c4f2339 (patch) | |
tree | dd7b9139791c854ce92ab5b2334e0894dded34b1 | |
parent | 6b24c91d3aa81fdb99500c8c2c12f830fabaefb6 (diff) | |
download | mate-calc-3e4dfc47e7803d16d14ffe655f9568871c4f2339.tar.bz2 mate-calc-3e4dfc47e7803d16d14ffe655f9568871c4f2339.tar.xz |
GTK2 support. Menu fix. Code cleanups.
-rw-r--r-- | data/buttons-advanced.ui | 88 | ||||
-rw-r--r-- | data/buttons-basic.ui | 87 | ||||
-rw-r--r-- | po/bg.po | 2 | ||||
-rw-r--r-- | src/mate-calc.c | 258 | ||||
-rw-r--r-- | src/math-converter.c | 2 | ||||
-rw-r--r-- | src/math-display.c | 4 | ||||
-rw-r--r-- | src/math-variable-popup.c | 6 | ||||
-rw-r--r-- | src/math-window.c | 292 | ||||
-rw-r--r-- | src/math-window.h | 11 |
9 files changed, 452 insertions, 298 deletions
diff --git a/data/buttons-advanced.ui b/data/buttons-advanced.ui index ac94ecf..f784bda 100644 --- a/data/buttons-advanced.ui +++ b/data/buttons-advanced.ui @@ -3,9 +3,11 @@ <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> <child> <object class="GtkTable" id="button_panel"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="n_rows">5</property> <property name="n_columns">10</property> <property name="homogeneous">True</property> @@ -14,6 +16,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_inverse_button-atkobject"> @@ -24,6 +27,7 @@ <child> <object class="GtkLabel" id="label20"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label"><i>x</i><sup>−1</sup></property> <property name="use_markup">True</property> <property name="justify">center</property> @@ -45,6 +49,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> @@ -68,6 +73,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_factorial_button-atkobject"> @@ -78,6 +84,7 @@ <child> <object class="GtkLabel" id="label14"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label"><i>x</i>!</property> <property name="use_markup">True</property> </object> @@ -98,6 +105,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -116,12 +124,14 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> <child> <object class="GtkLabel" id="imaginary_label"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label"><i>i</i></property> <property name="use_markup">True</property> </object> @@ -142,6 +152,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -159,6 +170,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -176,6 +188,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -195,6 +208,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -214,6 +228,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -233,6 +248,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -252,6 +268,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -271,6 +288,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -288,6 +306,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -308,6 +327,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -325,6 +345,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="numeric_point_cb" swapped="no"/> @@ -344,6 +365,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="digit_cb" swapped="no"/> @@ -363,6 +385,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -382,6 +405,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="subtract_cb" swapped="no"/> @@ -401,6 +425,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -420,6 +445,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="solve_cb" swapped="no"/> @@ -435,18 +461,13 @@ </child> <child> <object class="GtkButton" id="calc_clear_button"> + <property name="label" translatable="yes">Clear</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="clear_cb" swapped="no"/> - <child> - <object class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="icon-name">edit-clear-symbolic</property> - </object> - </child> </object> <packing> <property name="left_attach">5</property> @@ -460,6 +481,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_subscript_button-atkobject"> @@ -470,6 +492,7 @@ <child> <object class="GtkLabel" id="label4"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label">↓n</property> <property name="use_markup">True</property> </object> @@ -485,6 +508,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_superscript_button-atkobject"> @@ -495,6 +519,7 @@ <child> <object class="GtkLabel" id="label3"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label">↑n</property> <property name="use_markup">True</property> </object> @@ -512,6 +537,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> @@ -523,6 +549,7 @@ <child> <object class="GtkLabel" id="label2"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label">×10<sup><i>y</i></sup></property> <property name="use_markup">True</property> </object> @@ -541,6 +568,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -558,6 +586,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -577,6 +606,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -595,6 +625,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_memory_button-atkobject"> @@ -605,25 +636,31 @@ <child> <object class="GtkHBox" id="hbox20"> <property name="visible">True</property> + <property name="can_focus">False</property> <child> <object class="GtkLabel" id="label23"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label" translatable="yes" comments="The label on the memory button">x</property> <attributes> <attribute name="style" value="italic"/> </attributes> </object> <packing> + <property name="expand">True</property> + <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkArrow" id="arrow14"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="arrow_type">down</property> </object> <packing> <property name="expand">False</property> + <property name="fill">True</property> <property name="position">1</property> </packing> </child> @@ -644,6 +681,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> @@ -655,6 +693,7 @@ <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label">|<i>x</i>|</property> <property name="use_markup">True</property> </object> @@ -675,6 +714,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -694,6 +734,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -713,6 +754,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -732,6 +774,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -751,6 +794,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -768,6 +812,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_x_pow_y_button-atkobject"> @@ -778,6 +823,7 @@ <child> <object class="GtkLabel" id="x_pow_y_label"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label"><i>x</i><sup><i>y</i></sup></property> <property name="use_markup">True</property> </object> @@ -798,6 +844,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> @@ -813,18 +860,13 @@ </child> <child> <object class="GtkButton" id="calc_undo_button"> + <property name="label" translatable="yes">Undo</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="undo_cb" swapped="no"/> - <child> - <object class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="icon-name">edit-undo-symbolic</property> - </object> - </child> </object> <packing> <property name="left_attach">4</property> @@ -838,12 +880,14 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> <child> <object class="GtkLabel" id="pi_label"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label">π</property> <property name="use_markup">True</property> </object> @@ -863,12 +907,14 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> <child> <object class="GtkLabel" id="eulers_number_label"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label"><i>e</i></property> <property name="use_markup">True</property> </object> @@ -886,6 +932,7 @@ <child> <object class="GtkTable" id="table1"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="n_rows">2</property> <property name="n_columns">3</property> <property name="homogeneous">True</property> @@ -895,6 +942,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -909,6 +957,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -925,6 +974,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -941,6 +991,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -957,6 +1008,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -975,6 +1027,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <signal name="clicked" handler="button_cb" swapped="no"/> </object> @@ -999,6 +1052,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_function_button-atkobject"> @@ -1009,22 +1063,28 @@ <child> <object class="GtkHBox" id="hbox2"> <property name="visible">True</property> + <property name="can_focus">False</property> <child> <object class="GtkLabel" id="label5"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label">f(x)</property> </object> <packing> + <property name="expand">True</property> + <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkArrow" id="arrow1"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="arrow_type">down</property> </object> <packing> <property name="expand">False</property> + <property name="fill">True</property> <property name="position">1</property> </packing> </child> diff --git a/data/buttons-basic.ui b/data/buttons-basic.ui index c8b1de6..b6b0008 100644 --- a/data/buttons-basic.ui +++ b/data/buttons-basic.ui @@ -3,9 +3,11 @@ <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> <child> <object class="GtkTable" id="button_panel"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="n_rows">4</property> <property name="n_columns">6</property> <property name="homogeneous">True</property> @@ -15,9 +17,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="top_attach">1</property> @@ -32,9 +35,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property> @@ -47,9 +51,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="left_attach">1</property> @@ -64,9 +69,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="left_attach">2</property> @@ -81,9 +87,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="left_attach">1</property> @@ -100,9 +107,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="left_attach">2</property> @@ -119,9 +127,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">3</property> @@ -136,9 +145,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="top_attach">2</property> @@ -153,9 +163,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="left_attach">1</property> @@ -173,9 +184,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="top_attach">3</property> @@ -190,9 +202,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="numeric_point_cb"/> + <signal name="clicked" handler="numeric_point_cb" swapped="no"/> </object> <packing> <property name="left_attach">1</property> @@ -209,9 +222,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">2</property> @@ -228,9 +242,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="digit_cb"/> + <signal name="clicked" handler="digit_cb" swapped="no"/> </object> <packing> <property name="left_attach">2</property> @@ -247,9 +262,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">3</property> @@ -266,9 +282,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="subtract_cb"/> + <signal name="clicked" handler="subtract_cb" swapped="no"/> </object> <packing> <property name="left_attach">3</property> @@ -285,9 +302,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">3</property> @@ -304,9 +322,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="solve_cb"/> + <signal name="clicked" handler="solve_cb" swapped="no"/> </object> <packing> <property name="left_attach">4</property> @@ -323,9 +342,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">4</property> @@ -342,9 +362,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">5</property> @@ -357,18 +378,13 @@ </child> <child> <object class="GtkButton" id="calc_clear_button"> + <property name="label" translatable="yes">Clear</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="clear_cb"/> - <child> - <object class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="icon-name">edit-clear-symbolic</property> - </object> - </child> + <signal name="clicked" handler="clear_cb" swapped="no"/> </object> <packing> <property name="left_attach">5</property> @@ -383,9 +399,10 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> </object> <packing> <property name="left_attach">5</property> @@ -401,16 +418,18 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="focus_on_click">False</property> <child internal-child="accessible"> <object class="AtkObject" id="calc_x_squared_button-atkobject"> <property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the exponentiation (x to the power of y) button">Exponent</property> </object> </child> - <signal name="clicked" handler="button_cb"/> + <signal name="clicked" handler="button_cb" swapped="no"/> <child> <object class="GtkLabel" id="x_squared_label"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label"><i>x</i><sup><i>2</i></sup></property> <property name="use_markup">True</property> </object> @@ -427,18 +446,14 @@ </child> <child> <object class="GtkButton" id="calc_undo_button"> + <property name="label" translatable="yes">Undo</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="focus_on_click">False</property> - <signal name="clicked" handler="undo_cb"/> - <child> - <object class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="icon-name">edit-undo-symbolic</property> - </object> - </child> + <signal name="clicked" handler="undo_cb" swapped="no"/> </object> <packing> <property name="left_attach">4</property> @@ -10,7 +10,7 @@ # msgid "" msgstr "" -"Project-Id-Version: gaclctool mate-3-6\n" +"Project-Id-Version: mate-calc mate-1-5\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-10-11 06:47+0300\n" "PO-Revision-Date: 2012-10-11 06:46+0300\n" diff --git a/src/mate-calc.c b/src/mate-calc.c index 15efc97..f23ff38 100644 --- a/src/mate-calc.c +++ b/src/mate-calc.c @@ -23,7 +23,6 @@ static GSettings *settings = NULL; static MathWindow *window; -static MathPreferencesDialog *preferences_dialog; static void version(const gchar *progname) @@ -249,12 +248,9 @@ programming_base_cb(MathButtons *buttons, GParamSpec *spec) } -static void -mode_cb(MathButtons *buttons, GParamSpec *spec, GApplication *app) +/*static void +mode_cb(MathButtons *buttons, GParamSpec *spec) { - const char *state; - GAction *action; - g_settings_set_enum(settings, "button-mode", math_buttons_get_mode(buttons)); switch(math_buttons_get_mode(buttons)) @@ -277,162 +273,17 @@ mode_cb(MathButtons *buttons, GParamSpec *spec, GApplication *app) state = "programming"; break; } - - action = g_action_map_lookup_action(G_ACTION_MAP(app), "mode"); - g_simple_action_set_state(G_SIMPLE_ACTION(action), - g_variant_new_string(state)); -} - - -static void -copy_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - math_equation_copy(math_window_get_equation(window)); -} +}*/ static void -paste_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) +quit_cb(MathWindow *window) { - math_equation_paste(math_window_get_equation(window)); + gtk_main_quit(); } -static void -undo_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - math_equation_undo(math_window_get_equation(window)); -} - - -static void -redo_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - math_equation_redo(math_window_get_equation(window)); -} - - -static void -mode_changed_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - const char *mode_str; - int mode = BASIC; - - mode_str = g_variant_get_string(parameter, NULL); - if (strcmp(mode_str, "basic") == 0) - mode = BASIC; - else if (strcmp(mode_str, "advanced") == 0) - mode = ADVANCED; - else if (strcmp(mode_str, "financial") == 0) - mode = FINANCIAL; - else if (strcmp(mode_str, "programming") == 0) - mode = PROGRAMMING; - math_buttons_set_mode(math_window_get_buttons(window), mode); -} - - -static void -show_preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - if (!preferences_dialog) { - preferences_dialog = math_preferences_dialog_new(math_window_get_equation(window)); - gtk_window_set_transient_for(GTK_WINDOW(preferences_dialog), GTK_WINDOW(window)); - } - gtk_window_present(GTK_WINDOW(preferences_dialog)); -} - - -static void -help_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - GdkScreen *screen; - GError *error = NULL; - - screen = gtk_widget_get_screen(GTK_WIDGET(window)); - gtk_show_uri(screen, "help:mate-calc", gtk_get_current_event_time(), &error); - - if (error != NULL) - { - GtkWidget *d; - /* Translators: Error message displayed when unable to launch help browser */ - const char *message = _("Unable to open help file"); - - d = gtk_message_dialog_new(GTK_WINDOW (window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", message); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG (d), - "%s", error->message); - g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_window_present(GTK_WINDOW(d)); - - g_error_free(error); - } -} - - -static void -about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - const gchar *authors[] = { - "Rich Burridge <[email protected]>", - "Robert Ancell <[email protected]>", - "Klaus Niederkrüger <[email protected]>", - "Robin Sonefors <[email protected]>", - NULL - }; - const gchar *documenters[] = { - "Sun Microsystems", - NULL - }; - - /* The translator credits. Please translate this with your name(s). */ - const gchar *translator_credits = _("translator-credits"); - - /* The license this software is under (GPL2+) */ - char *license = _("mate-calc is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "mate-calc is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with mate-calc; if not, write to the Free Software Foundation, Inc.,\n" - "151 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA"); - - gtk_show_about_dialog(GTK_WINDOW(window), - "name", - /* Program name in the about dialog */ - _("mate-calc"), - "version", VERSION, - "copyright", - /* Copyright notice in the about dialog */ - _("\xc2\xa9 1986–2010 The gcalctool authors\n 2011-2012 mate-calc authors"), - "license", license, - "comments", - /* Short description in the about dialog */ - _("Calculator with financial and scientific modes."), - "authors", authors, - "documenters", documenters, - "translator_credits", translator_credits, - "logo-icon-name", "accessories-calculator", - "website", "http://mate-desktop.org", - NULL); -} - - -static void -quit_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) -{ - gtk_widget_destroy(GTK_WIDGET(window)); -} - - -static GActionEntry app_entries[] = { +/*static GActionEntry app_entries[] = { { "copy", copy_cb, NULL, NULL, NULL }, { "paste", paste_cb, NULL, NULL, NULL }, { "undo", undo_cb, NULL, NULL, NULL }, @@ -442,11 +293,10 @@ static GActionEntry app_entries[] = { { "help", help_cb, NULL, NULL, NULL }, { "about", about_cb, NULL, NULL, NULL }, { "quit", quit_cb, NULL, NULL, NULL }, -}; +};*/ -static void -startup_cb(GApplication *application) +int main(int argc, char **argv) { MathEquation *equation; MathButtons *buttons; @@ -457,7 +307,16 @@ startup_cb(GApplication *application) ButtonMode button_mode; gchar *source_currency, *target_currency; gchar *source_units, *target_units; - GMenu *menu, *section; + + g_type_init(); + + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + /* Seed random number generator. */ + srand48((long) time((time_t *) 0)); settings = g_settings_new ("org.mate.calc"); accuracy = g_settings_get_int(settings, "accuracy"); @@ -500,80 +359,23 @@ startup_cb(GApplication *application) g_signal_connect(equation, "notify::source-units", G_CALLBACK(source_units_cb), NULL); g_signal_connect(equation, "notify::target-units", G_CALLBACK(target_units_cb), NULL); - g_action_map_add_action_entries(G_ACTION_MAP(application), app_entries, G_N_ELEMENTS(app_entries), NULL); - - window = math_window_new(GTK_APPLICATION(application), equation); - buttons = math_window_get_buttons(window); - math_buttons_set_programming_base(buttons, base); - math_buttons_set_mode(buttons, button_mode); // FIXME: We load the basic buttons even if we immediately switch to the next type - g_signal_connect(buttons, "notify::programming-base", G_CALLBACK(programming_base_cb), NULL); - g_signal_connect(buttons, "notify::mode", G_CALLBACK(mode_cb), application); - mode_cb (buttons, NULL, application); - - menu = g_menu_new(); - - section = g_menu_new(); - g_menu_append(section, _("Basic"), "app.mode::basic"); - g_menu_append(section, _("Advanced"), "app.mode::advanced"); - g_menu_append(section, _("Financial"), "app.mode::financial"); - g_menu_append(section, _("Programming"), "app.mode::programming"); - g_menu_append_section(menu, _("Mode"), G_MENU_MODEL(section)); - - section = g_menu_new(); - g_menu_append(section, _("Preferences"), "app.preferences"); - g_menu_append_section(menu, NULL, G_MENU_MODEL(section)); - - section = g_menu_new(); - g_menu_append(section, _("About Calculator"), "app.about"); - g_menu_append(section, _("Help"), "app.help"); - g_menu_append(section, _("Quit"), "app.quit"); - g_menu_append_section(menu, NULL, G_MENU_MODEL(section)); - - gtk_application_set_app_menu(GTK_APPLICATION(application), G_MENU_MODEL(menu)); - - gtk_application_add_accelerator(GTK_APPLICATION(application), "<control>Q", "app.quit", NULL); - gtk_application_add_accelerator(GTK_APPLICATION(application), "F1", "app.help", NULL); - gtk_application_add_accelerator(GTK_APPLICATION(application), "<control>C", "app.copy", NULL); - gtk_application_add_accelerator(GTK_APPLICATION(application), "<control>V", "app.paste", NULL); - gtk_application_add_accelerator(GTK_APPLICATION(application), "<control>Z", "app.undo", NULL); - gtk_application_add_accelerator(GTK_APPLICATION(application), "<control><shift>Z", "app.redo", NULL); -} - - -static void -activate_cb(GApplication *application) -{ - gtk_window_present(GTK_WINDOW(window)); -} - - -int -main(int argc, char **argv) -{ - GtkApplication *app; - int status; - - setlocale(LC_ALL, ""); - bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); - - /* Seed random number generator. */ - srand48((long) time((time_t *) 0)); - - g_type_init(); - get_options(argc, argv); gtk_init(&argc, &argv); - gtk_window_set_default_icon_name("accessories-calculator"); + //gtk_window_set_default_icon_name("accessories-calculator"); - app = gtk_application_new(NULL, G_APPLICATION_NON_UNIQUE); - g_signal_connect(app, "startup", G_CALLBACK(startup_cb), NULL); - g_signal_connect(app, "activate", G_CALLBACK(activate_cb), NULL); + window = math_window_new(equation); + buttons = math_window_get_buttons(window); + g_signal_connect(G_OBJECT(window), "quit", G_CALLBACK(quit_cb), NULL); + math_buttons_set_programming_base(buttons, base); + math_buttons_set_mode(buttons, button_mode); // FIXME: We load the basic buttons even if we immediately switch to the next type + g_signal_connect(buttons, "notify::programming-base", G_CALLBACK(programming_base_cb), NULL); + //g_signal_connect(buttons, "notify::mode", G_CALLBACK(mode_cb), NULL); + //mode_cb (buttons, NULL); - status = g_application_run(G_APPLICATION(app), argc, argv); + gtk_widget_show(GTK_WIDGET(window)); + gtk_main(); - return status; + return 0; } diff --git a/src/math-converter.c b/src/math-converter.c index ff28500..2f543fe 100644 --- a/src/math-converter.c +++ b/src/math-converter.c @@ -391,7 +391,7 @@ math_converter_init(MathConverter *converter) gtk_box_set_spacing(GTK_BOX(converter), 6); - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(converter), hbox, FALSE, TRUE, 0); diff --git a/src/math-display.c b/src/math-display.c index 6718665..fb5af8b 100644 --- a/src/math-display.c +++ b/src/math-display.c @@ -326,7 +326,7 @@ create_gui(MathDisplay *display) int i; GtkStyle *style; - main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + main_box = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(display), main_box); g_signal_connect(display, "key-press-event", G_CALLBACK(key_press_cb), display); @@ -350,7 +350,7 @@ create_gui(MathDisplay *display) g_signal_connect(display->priv->text_view, "key-press-event", G_CALLBACK(display_key_press_cb), display); gtk_box_pack_start(GTK_BOX(main_box), display->priv->text_view, TRUE, TRUE, 0); - info_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); + info_box = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(main_box), info_box, FALSE, TRUE, 0); info_view = gtk_text_view_new(); diff --git a/src/math-variable-popup.c b/src/math-variable-popup.c index d033571..1287f7a 100644 --- a/src/math-variable-popup.c +++ b/src/math-variable-popup.c @@ -131,7 +131,7 @@ make_variable_entry(MathVariablePopup *popup, const gchar *name, const MPNumber GtkWidget *hbox, *button, *label; gchar *text; - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); + hbox = gtk_hbox_new(FALSE, 6); if (value) { @@ -211,7 +211,7 @@ math_variable_popup_set_property(GObject *object, } g_strfreev(names); - entry = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); + entry = gtk_hbox_new(FALSE, 6); gtk_widget_show(entry); // TODO: Show greyed "variable name" text to give user a hint how to use @@ -301,7 +301,7 @@ math_variable_popup_init(MathVariablePopup *popup) /* Destroy this window when it loses focus */ g_signal_connect(G_OBJECT(popup), "focus-out-event", G_CALLBACK(variable_focus_out_event_cb), popup); - popup->priv->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); + popup->priv->vbox = gtk_vbox_new(FALSE, 6); gtk_box_set_homogeneous(GTK_BOX(popup->priv->vbox), TRUE); gtk_container_add(GTK_CONTAINER(popup), popup->priv->vbox); gtk_widget_show(popup->priv->vbox); diff --git a/src/math-window.c b/src/math-window.c index 4ecc5f7..4692ec8 100644 --- a/src/math-window.c +++ b/src/math-window.c @@ -22,23 +22,39 @@ enum { struct MathWindowPrivate { + GtkWidget *menu_bar; MathEquation *equation; MathDisplay *display; MathButtons *buttons; + MathPreferencesDialog *preferences_dialog; gboolean right_aligned; + GtkWidget *mode_basic_menu_item; + GtkWidget *mode_advanced_menu_item; + GtkWidget *mode_financial_menu_item; + GtkWidget *mode_programming_menu_item; }; -G_DEFINE_TYPE (MathWindow, math_window, GTK_TYPE_APPLICATION_WINDOW); +G_DEFINE_TYPE (MathWindow, math_window, GTK_TYPE_WINDOW); +enum +{ + QUIT, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0, }; MathWindow * -math_window_new(GtkApplication *app, MathEquation *equation) +math_window_new(MathEquation *equation) { return g_object_new(math_window_get_type(), - "application", app, - "equation", equation, NULL); + "equation", equation, NULL); } +GtkWidget *math_window_get_menu_bar(MathWindow *window) +{ + return window->priv->menu_bar; +} MathEquation * math_window_get_equation(MathWindow *window) @@ -83,9 +99,32 @@ math_window_critical_error(MathWindow *window, const gchar *title, const gchar * gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(GTK_WIDGET(window)); + g_signal_emit(window, signals[QUIT], 0); +} + +static void mode_changed_cb(GtkWidget *menu, MathWindow *window) +{ + int mode; + + if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu))) + { + return; + } + + mode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "calcmode")); + math_buttons_set_mode(window->priv->buttons, mode); } +static void show_preferences_cb(GtkMenuItem *menu, MathWindow *window) +{ + if (!window->priv->preferences_dialog) + { + window->priv->preferences_dialog = math_preferences_dialog_new(window->priv->equation); + gtk_window_set_transient_for(GTK_WINDOW(window->priv->preferences_dialog), GTK_WINDOW(window)); + } + + gtk_window_present(GTK_WINDOW(window->priv->preferences_dialog)); +} static gboolean key_press_cb(MathWindow *window, GdkEventKey *event) @@ -118,6 +157,104 @@ key_press_cb(MathWindow *window, GdkEventKey *event) return result; } +static void delete_cb(MathWindow *window, GdkEvent *event) +{ + g_signal_emit(window, signals[QUIT], 0); +} + +static void copy_cb(GtkWidget *widget, MathWindow *window) +{ + math_equation_copy(window->priv->equation); +} + +static void paste_cb(GtkWidget *widget, MathWindow *window) +{ + math_equation_paste(window->priv->equation); +} + +static void undo_cb(GtkWidget *widget, MathWindow *window) +{ + math_equation_undo(window->priv->equation); +} + +static void redo_cb(GtkWidget *widget, MathWindow *window) +{ + math_equation_redo(window->priv->equation); +} + +static void help_cb(GtkWidget *widget, MathWindow *window) +{ + GdkScreen *screen; + GError *error = NULL; + + screen = gtk_widget_get_screen(GTK_WIDGET(window)); + gtk_show_uri(screen, "ghelp:mate-calc", gtk_get_current_event_time(), &error); + + if (error != NULL) + { + GtkWidget *d; + /* Translators: Error message displayed when unable to launch help browser */ + const char *message = _("Unable to open help file"); + + d = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(d), "%s", error->message); + g_signal_connect(d, "respones", G_CALLBACK(gtk_widget_destroy), NULL); + gtk_window_present(GTK_WINDOW (d)); + + g_error_free(error); + } +} + +static void about_cb(GtkWidget* widget, MathWindow* window) +{ + char* authors[] = { + "Rich Burridge <[email protected]>", + "Robert Ancell <[email protected]>", + "Klaus Niederkrüger <[email protected]>", + NULL + }; + + char* documenters[] = { + "Sun Microsystems", + NULL + }; + + /* The translator credits. Please translate this with your name(s). */ + char* translator_credits = _("translator-credits"); + + char copyright[] = \ + "Copyright \xc2\xa9 1986–2010 The GCalctool authors\n" + "Copyright \xc2\xa9 2011-2012 MATE developers"; + + /* The license this software is under (GPL2+) */ + char* license = _("mate-calc is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 2 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "mate-calc is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with mate-calc; if not, write to the Free Software Foundation, Inc.,\n" + "151 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA"); + + gtk_show_about_dialog(GTK_WINDOW(window), + "name", _("mate-calc"), + "version", VERSION, + "copyright", copyright, + "license", license, + "comments", _("Calculator with financial and scientific modes."), + "authors", authors, + "documenters", documenters, + "translator_credits", translator_credits, + "logo-icon-name", "accessories-calculator", + "website", "http://mate-desktop.org", + NULL); +} static void scroll_changed_cb(GtkAdjustment *adjustment, MathWindow *window) @@ -136,18 +273,144 @@ scroll_value_changed_cb(GtkAdjustment *adjustment, MathWindow *window) window->priv->right_aligned = FALSE; } +static void button_mode_changed_cb(MathButtons *buttons, GParamSpec *spec, MathWindow *window) +{ + GtkWidget *menu; + + switch (math_buttons_get_mode(buttons)) + { + default: + case BASIC: + menu = window->priv->mode_basic_menu_item; + break; + case ADVANCED: + menu = window->priv->mode_advanced_menu_item; + break; + case FINANCIAL: + menu = window->priv->mode_financial_menu_item; + break; + case PROGRAMMING: + menu = window->priv->mode_programming_menu_item; + break; + } + + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); +} + +static GtkWidget *add_menu(GtkWidget *menu_bar, const gchar *name) +{ + GtkWidget *menu_item; + GtkWidget *menu; + + menu_item = gtk_menu_item_new_with_mnemonic(name); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_item); + gtk_widget_show(menu_item); + menu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); + + return menu; +} + +static void quit_cb(GtkWidget* widget, MathWindow* window) +{ + g_signal_emit(window, signals[QUIT], 0); +} + +static GtkWidget *add_menu_item(GtkWidget *menu, GtkWidget *menu_item, GCallback callback, gpointer callback_data) +{ + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); + + if (callback) + { + g_signal_connect(G_OBJECT(menu_item), "activate", callback, callback_data); + } + + return menu_item; +} + +static GtkWidget *radio_menu_item_new(GSList **group, const gchar *name) +{ + GtkWidget *menu_item = gtk_radio_menu_item_new_with_mnemonic(*group, name); + + *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menu_item)); + + return menu_item; +} + +static void create_menu(MathWindow* window) +{ + GtkAccelGroup* accel_group; + GtkWidget* menu; + GtkWidget* menu_item; + GSList* group = NULL; + + accel_group = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); + + /* Calculator menu */ + #define CALCULATOR_MENU_LABEL _("_Calculator") + /* Mode menu */ + #define MODE_MENU_LABEL _("_Mode") + /* Help menu label */ + #define HELP_MENU_LABEL _("_Help") + /* Basic menu label */ + #define MODE_BASIC_LABEL _("_Basic") + /* Advanced menu label */ + #define MODE_ADVANCED_LABEL _("_Advanced") + /* Financial menu label */ + #define MODE_FINANCIAL_LABEL _("_Financial") + /* Programming menu label */ + #define MODE_PROGRAMMING_LABEL _("_Programming") + /* Help>Contents menu label */ + #define HELP_CONTENTS_LABEL _("_Contents") + + menu = add_menu(window->priv->menu_bar, CALCULATOR_MENU_LABEL); + add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_group), G_CALLBACK(copy_cb), window); + add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_group), G_CALLBACK(paste_cb), window); + menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_UNDO, accel_group), G_CALLBACK(undo_cb), window); + gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_REDO, accel_group), G_CALLBACK(redo_cb), window); + gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); + add_menu_item(menu, gtk_separator_menu_item_new(), NULL, NULL); + add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, accel_group), G_CALLBACK(show_preferences_cb), window); + add_menu_item(menu, gtk_separator_menu_item_new(), NULL, NULL); + menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel_group), G_CALLBACK(quit_cb), window); + gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_w, GDK_CONTROL_MASK, 0); + + menu = add_menu(window->priv->menu_bar, MODE_MENU_LABEL); + window->priv->mode_basic_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_BASIC_LABEL), G_CALLBACK(mode_changed_cb), window); + g_object_set_data(G_OBJECT(window->priv->mode_basic_menu_item), "calcmode", GINT_TO_POINTER(BASIC)); + window->priv->mode_advanced_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_ADVANCED_LABEL), G_CALLBACK(mode_changed_cb), window); + g_object_set_data(G_OBJECT(window->priv->mode_advanced_menu_item), "calcmode", GINT_TO_POINTER(ADVANCED)); + window->priv->mode_financial_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_FINANCIAL_LABEL), G_CALLBACK(mode_changed_cb), window); + g_object_set_data(G_OBJECT(window->priv->mode_financial_menu_item), "calcmode", GINT_TO_POINTER(FINANCIAL)); + window->priv->mode_programming_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_PROGRAMMING_LABEL), G_CALLBACK(mode_changed_cb), window); + g_object_set_data(G_OBJECT(window->priv->mode_programming_menu_item), "calcmode", GINT_TO_POINTER(PROGRAMMING)); + + menu = add_menu(window->priv->menu_bar, HELP_MENU_LABEL); + menu_item = add_menu_item(menu, gtk_menu_item_new_with_mnemonic(HELP_CONTENTS_LABEL), G_CALLBACK(help_cb), window); + gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_F1, 0, GTK_ACCEL_VISIBLE); + add_menu_item(menu, gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, accel_group), G_CALLBACK(about_cb), window); +} static void create_gui(MathWindow *window) { GtkWidget *main_vbox, *vbox; GtkWidget *scrolled_window; - - main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + + main_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), main_vbox); gtk_widget_show(main_vbox); - vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); + window->priv->menu_bar = gtk_menu_bar_new(); + gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menu_bar, TRUE, TRUE, 0); + gtk_widget_show(window->priv->menu_bar); + + create_menu(window); + + vbox = gtk_vbox_new(FALSE, 6); gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); gtk_box_pack_start(GTK_BOX(main_vbox), vbox, TRUE, TRUE, 0); gtk_widget_show(vbox); @@ -155,7 +418,7 @@ create_gui(MathWindow *window) scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); - gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scrolled_window), FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scrolled_window), TRUE, TRUE, 0); g_signal_connect(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window)), "changed", G_CALLBACK(scroll_changed_cb), window); g_signal_connect(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window)), "value-changed", G_CALLBACK(scroll_value_changed_cb), window); window->priv->right_aligned = TRUE; @@ -166,6 +429,8 @@ create_gui(MathWindow *window) gtk_widget_show(GTK_WIDGET(window->priv->display)); window->priv->buttons = math_buttons_new(window->priv->equation); + g_signal_connect(window->priv->buttons, "notify::mode", G_CALLBACK(button_mode_changed_cb), window); + button_mode_changed_cb(window->priv->buttons, NULL, window); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(window->priv->buttons), TRUE, TRUE, 0); gtk_widget_show(GTK_WIDGET(window->priv->buttons)); } @@ -231,6 +496,14 @@ math_window_class_init(MathWindowClass *klass) "Equation being calculated", math_equation_get_type(), G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + signals[QUIT] = g_signal_new("quit", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MathWindowClass, quit), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } @@ -244,4 +517,5 @@ math_window_init(MathWindow *window) gtk_window_set_role(GTK_WINDOW(window), "mate-calc"); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); g_signal_connect_after(G_OBJECT(window), "key-press-event", G_CALLBACK(key_press_cb), NULL); + g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(delete_cb), NULL); } diff --git a/src/math-window.h b/src/math-window.h index 22360fa..5575cf3 100644 --- a/src/math-window.h +++ b/src/math-window.h @@ -16,6 +16,7 @@ #include "math-equation.h" #include "math-display.h" #include "math-buttons.h" +#include "math-preferences.h" G_BEGIN_DECLS @@ -25,20 +26,22 @@ typedef struct MathWindowPrivate MathWindowPrivate; typedef struct { - GtkApplicationWindow parent_instance; + GtkWindow parent_instance; MathWindowPrivate *priv; } MathWindow; typedef struct { - GtkApplicationWindowClass parent_class; + GtkWindowClass parent_class; - void (*quit)(MathWindow *window); + void (*quit) (MathWindow *window); } MathWindowClass; GType math_window_get_type(void); -MathWindow *math_window_new(GtkApplication *app, MathEquation *equation); +MathWindow *math_window_new(MathEquation *equation); + +GtkWidget *math_window_get_menu_bar(MathWindow *window); MathEquation *math_window_get_equation(MathWindow *window); |