[gcalctool] Remove code accidentally committed



commit d93c3d3443174af497c0c813a3ec5a7fdee8c70f
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Apr 20 10:06:03 2011 +1000

    Remove code accidentally committed

 src/gcalctool.c   |    8 ++------
 src/math-window.c |   28 ++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/gcalctool.c b/src/gcalctool.c
index a439725..3c03670 100644
--- a/src/gcalctool.c
+++ b/src/gcalctool.c
@@ -170,13 +170,11 @@ get_options(int argc, char *argv[])
 }
 
 
-static gboolean
+static void
 quit_cb(MathWindow *window)
 {
     MathEquation *equation;
     MathButtons *buttons;
-  
-  g_debug ("!");
 
     equation = math_window_get_equation(window);
     buttons = math_window_get_buttons(window);
@@ -196,8 +194,6 @@ quit_cb(MathWindow *window)
     g_settings_sync();
 
     gtk_main_quit();
-
-    return FALSE;
 }
 
 
@@ -258,7 +254,7 @@ main(int argc, char **argv)
     gtk_init(&argc, &argv);
 
     window = math_window_new(equation);
-    g_signal_connect_after(G_OBJECT(window), "destroy-event", G_CALLBACK(quit_cb), NULL);
+    g_signal_connect(G_OBJECT(window), "quit", G_CALLBACK(quit_cb), NULL);
     math_buttons_set_programming_base(math_window_get_buttons(window), base);
     math_buttons_set_mode(math_window_get_buttons(window), button_mode); // FIXME: We load the basic buttons even if we immediately switch to the next type
 
diff --git a/src/math-window.c b/src/math-window.c
index 7021d98..07984df 100644
--- a/src/math-window.c
+++ b/src/math-window.c
@@ -34,6 +34,13 @@ struct MathWindowPrivate
 
 G_DEFINE_TYPE (MathWindow, math_window, GTK_TYPE_WINDOW);
 
+enum
+{
+    QUIT,
+    LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0, };
+
 
 MathWindow *
 math_window_new(MathEquation *equation)
@@ -85,7 +92,7 @@ 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);
 }
 
 
@@ -226,7 +233,7 @@ about_cb(GtkWidget *widget, MathWindow *window)
 static void
 quit_cb(GtkWidget *widget, MathWindow *window)
 {
-    gtk_widget_destroy(GTK_WIDGET(window));
+    g_signal_emit(window, signals[QUIT], 0);
 }
 
 
@@ -240,6 +247,13 @@ key_press_cb(MathWindow *window, GdkEventKey *event)
 
 
 static void
+delete_cb(MathWindow *window, GdkEvent *event)
+{
+    g_signal_emit(window, signals[QUIT], 0);
+}
+
+
+static void
 scroll_changed_cb(GtkAdjustment *adjustment, MathWindow *window)
 {
     if (window->priv->right_aligned)
@@ -480,6 +494,15 @@ 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);
 }
 
 
@@ -494,4 +517,5 @@ math_window_init(MathWindow *window)
     gtk_window_set_role(GTK_WINDOW(window), "gcalctool");
     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);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]