Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=grape.git;a=commitdiff;h=146200c7fe30b9e68cb311e6ae0d410b542473f9

commit 146200c7fe30b9e68cb311e6ae0d410b542473f9
Author: James Buren <r...@frugalware.org>
Date:   Sat Apr 3 14:42:05 2010 -0500

delete_action.c/exports.h/main.c/window_new.c
* add routines for freeing memory usage when window is deleted
* also exit if no more window references exist

diff --git a/src/delete_action.c b/src/delete_action.c
new file mode 100644
index 0000000..27075eb
--- /dev/null
+++ b/src/delete_action.c
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 James Buren
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to 
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include "exports.h"
+
+gboolean delete_action(GtkWidget *window,GdkEvent *event,SharedInfo *info) {
+  static gint windows = 0;
+
+  if(!window && !event && !info) {
+    ++windows;
+    return FALSE;
+  }
+
+  g_free(info->filename);
+
+  g_free(info);
+
+  --windows;
+
+  if(!windows)
+    gtk_main_quit();
+
+  return FALSE;
+}
diff --git a/src/exports.h b/src/exports.h
index de35902..5a892c5 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -47,5 +47,6 @@ void save_action(GtkToolButton *btn,SharedInfo *info);
void open_action(GtkToolButton *btn,SharedInfo *info);
void input_action(GtkTextView *view,SharedInfo *info);
void cursor_action(GtkTextBuffer *buffer,GtkTextIter *iter,GtkTextMark 
*mark,SharedInfo *info);
+gboolean delete_action(GtkWidget *window,GdkEvent *event,SharedInfo *info);
gint main(gint argc,gchar **argv);
#endif
diff --git a/src/main.c b/src/main.c
index d5159da..573665b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,7 +27,7 @@ gint main(gint argc,gchar **argv) {

info = window_new(NULL);

-  gtk_widget_show_all(info->parent);
+  gtk_widget_show_all(GTK_WIDGET(info->parent));

gtk_main();

diff --git a/src/window_new.c b/src/window_new.c
index 50739cd..3dff62e 100644
--- a/src/window_new.c
+++ b/src/window_new.c
@@ -40,5 +40,9 @@ SharedInfo *window_new(const gchar *filename) {

box_pack_widgets(vbox,FALSE,gtk_hseparator_new(),statusbar_new(info),NULL);

+  delete_action(NULL,NULL,NULL);
+
+  g_signal_connect(info->parent,"delete-event",G_CALLBACK(delete_action),info);
+
return info;
}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to