Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=grape.git;a=commitdiff;h=2d6d034e67b39b4c2734b3a779357dcaf03fb624
commit 2d6d034e67b39b4c2734b3a779357dcaf03fb624 Author: James Buren <r...@frugalware.org> Date: Sun Apr 4 05:04:09 2010 -0500 exports.h/load_action.c/window_new.c * add new callback for loading functions diff --git a/src/exports.h b/src/exports.h index e92f86f..21d3111 100644 --- a/src/exports.h +++ b/src/exports.h @@ -48,6 +48,7 @@ void box_pack_widgets(GtkWidget *box,gboolean expand,...); void new_action(GtkToolButton *btn,SharedInfo *info); void save_action(GtkToolButton *btn,SharedInfo *info); void open_action(GtkToolButton *btn,SharedInfo *info); +gboolean load_action(GtkWidget *widget,GdkEvent *event,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); diff --git a/src/load_action.c b/src/load_action.c new file mode 100644 index 0000000..bce40d5 --- /dev/null +++ b/src/load_action.c @@ -0,0 +1,42 @@ +// 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 load_action(GtkWidget *widget,GdkEvent *event,SharedInfo *info) { + GError *error = NULL; + gchar *contents; + gsize length; + + if(!info->filename) + return FALSE; + + if(!g_file_get_contents(info->filename,&contents,&length,&error)) { + display_error(info,error->message); + g_error_free(error); + return FALSE; + } + + gtk_text_buffer_set_text(GTK_TEXT_BUFFER(info->buffer),contents,length); + + g_free(contents); + + return FALSE; +} diff --git a/src/window_new.c b/src/window_new.c index 3dff62e..91cfda0 100644 --- a/src/window_new.c +++ b/src/window_new.c @@ -44,5 +44,7 @@ SharedInfo *window_new(const gchar *filename) { g_signal_connect(info->parent,"delete-event",G_CALLBACK(delete_action),info); + g_signal_connect(info->parent,"map-event",G_CALLBACK(load_action),info); + return info; } _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git