[gcalctool/gcalctool-newui2] merges from main
- From: Robert Ancell <rancell src gnome org>
- To: svn-commits-list gnome org
- Subject: [gcalctool/gcalctool-newui2] merges from main
- Date: Mon, 29 Jun 2009 08:29:50 +0000 (UTC)
commit 077c0b50178a49ad65a3ced89aea716aa16f37b7
Author: Robert Ancell <robert ancell gmail com>
Date: Mon Jun 29 16:08:37 2009 +1000
merges from main
src/gtk.c | 60 ++++++++++++++++++++-------------------------
src/mp-convert.c | 4 +-
src/mp-equation-parser.y | 5 +--
src/unittest.c | 1 +
4 files changed, 32 insertions(+), 38 deletions(-)
---
diff --git a/src/gtk.c b/src/gtk.c
index 185adc1..013a530 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -20,8 +20,6 @@
* 02111-1307, USA.
*/
-//â?°Â¹Â²Â³â?´â?µâ?¶â?·â?¸â?¹â?»â??â??â??â??â??â??â??â??â??â??â??
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -383,7 +381,8 @@ static struct button_widget button_widgets[] = {
};
#define NBUTTONS (sizeof(button_widgets) / sizeof(struct button_widget))
-#define UI_FILE PACKAGE_UI_DIR "/gcalctool.ui"
+#define UI_FILE PACKAGE_UI_DIR "/gcalctool.ui"
+#define UI_FINC_FILE PACKAGE_UI_DIR "/financial.ui"
#define MAXBITS 64 /* Bit panel: number of bit fields. */
@@ -465,6 +464,29 @@ typedef enum {
POPUP_CENTERED /* Center popup within baseframe */
} PopupLocation;
+static void load_ui(GtkBuilder *ui, const gchar *filename)
+{
+ GError *error = NULL;
+ GtkWidget *dialog;
+
+ gtk_builder_add_from_file(ui, filename, &error);
+ if (error == NULL)
+ return;
+
+ dialog = gtk_message_dialog_new(NULL, 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_NONE,
+ /* Translators: Title of the error dialog when unable to load the UI files */
+ N_("Error loading user interface"));
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+ /* Translators: Description in UI error dialog when unable to load the UI files. %s is replaced with the error message provided by GTK+ */
+ N_("A required file is missing or damaged, please check your installation.\n\n%s"), error->message);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT, NULL);
+
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ exit(0);
+}
+
static void set_data(GtkBuilder *ui, const gchar *object_name, const gchar *name, gpointer value)
{
g_object_set_data(gtk_builder_get_object(ui, object_name), name, value);
@@ -1214,19 +1236,10 @@ finc_response_cb(GtkWidget *widget, gint response_id)
static void
setup_finc_dialogs(void)
{
- GError *error = NULL;
int i, j;
- // FIXME: Use same code as main UI
X.financial = gtk_builder_new();
- gtk_builder_add_from_file(X.financial, PACKAGE_UI_DIR "/financial.ui", &error);
- if (error != NULL)
- {
- g_object_unref(X.financial);
- X.financial = NULL;
- g_warning("Error loading financial UI: %s\n", error->message);
- return;
- }
+ load_ui(X.financial, UI_FINC_FILE);
set_int_data(X.financial, "ctrm_dialog", "finc_dialog", FINC_CTRM_DIALOG);
set_int_data(X.financial, "ddb_dialog", "finc_dialog", FINC_DDB_DIALOG);
@@ -1826,28 +1839,9 @@ create_main_window()
PangoFontDescription *font_desc;
GtkSizeGroup *size_group;
GtkWidget *treeview;
- GError *error = NULL;
X.ui = gtk_builder_new();
- gtk_builder_add_from_file(X.ui, UI_FILE, &error);
- if (error != NULL) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new(NULL, 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_NONE,
- /* Translators: Title of the error dialog when unable to load the UI files */
- N_("Error loading user interface"));
- // FIXME: Use error->message
- g_warning("Unable to load file %s: %s\n", UI_FILE, error->message);
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- /* Translators: Description in UI error dialog when unable to load the UI files. %s is replaced with the path of the missing file */
- N_("The user interface file %s is missing or unable to be loaded. Please check your installation."), UI_FILE);
- gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT, NULL);
-
- gtk_dialog_run(GTK_DIALOG(dialog));
- exit(0);
- }
+ load_ui(X.ui, UI_FILE);
gtk_builder_connect_signals(X.ui, NULL);
X.clipboard_atom = gdk_atom_intern("CLIPBOARD", FALSE);
diff --git a/src/mp-convert.c b/src/mp-convert.c
index fef376b..e693445 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -600,7 +600,7 @@ mp_set_from_string(const char *str, MPNumber *z)
int base_values[] = {2, 8, 16, 10};
const char *fractions[] = {"½", "â??", "â??", "¼", "¾", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", NULL};
int numerators[] = { 1, 1, 2, 1, 3, 1, 2, 3, 4, 1, 5, 1, 3, 5, 7};
- int denominators[] = { 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 8, 8, 8, 8};
+ int denominators[] = { 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 8, 8, 8, 8};
/* Find the base */
end = str;
@@ -623,7 +623,7 @@ mp_set_from_string(const char *str, MPNumber *z)
negate = 1;
c += strlen("â??");
}
-
+
/* Convert integer part */
mp_set_from_integer(0, z);
while ((i = char_val(*c, base)) >= 0) {
diff --git a/src/mp-equation-parser.y b/src/mp-equation-parser.y
index 37db7bc..dce713d 100644
--- a/src/mp-equation-parser.y
+++ b/src/mp-equation-parser.y
@@ -89,8 +89,7 @@
%token tXOR
%token <int_t> tNUMBER
-%token <integer> tREG
-%token <integer> tSUBNUM tSUPNUM
+%token <integer> tREG tSUBNUM tSUPNUM
%token NEG
@@ -201,7 +200,7 @@ term:
| tROOT4 term {mp_root(&$2, 4, &$$);}
| term tDIVIDE term {mp_divide(&$1, &$3, &$$);}
| term tMULTIPLY term {mp_multiply(&$1, &$3, &$$);}
-| tABS exp tABS {mp_abs(&$2, &$$);}
+| tABS exp tABS {mp_abs(&$2, &$$);}
| term '!' {mp_factorial(&$1, &$$);}
| term tSUPNUM {mp_pwr_integer(&$1, $2, &$$);}
| term '%' {mp_divide_integer(&$1, 100, &$$);}
diff --git a/src/unittest.c b/src/unittest.c
index d4ecef5..0a02a51 100644
--- a/src/unittest.c
+++ b/src/unittest.c
@@ -171,6 +171,7 @@ test_parser()
test("2²", "4", 0);
test("2³", "8", 0);
+ test("2¹�", "1024", 0);
test("2^0", "1", 0);
test("2^1", "2", 0);
test("2^2", "4", 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]