Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=grape.git;a=commitdiff;h=fa2a20a48d372659d3561f5ba7e5e7b919e0e416
commit fa2a20a48d372659d3561f5ba7e5e7b919e0e416 Author: James Buren <r...@frugalware.org> Date: Sat Apr 3 16:33:40 2010 -0500 exports.h/get_filename.c * add function for prompting user for a filename to save or open to/from diff --git a/src/exports.h b/src/exports.h index 5a892c5..8696368 100644 --- a/src/exports.h +++ b/src/exports.h @@ -41,6 +41,7 @@ GtkWidget *toolbar_new(SharedInfo *info); GtkWidget *text_widget_new(SharedInfo *info); GtkWidget *statusbar_new(SharedInfo *info); SharedInfo *window_new(const gchar *filename); +gchar *get_filename(GtkWindow *window,gboolean open); void box_pack_widgets(GtkWidget *box,gboolean expand,...); void new_action(GtkToolButton *btn,SharedInfo *info); void save_action(GtkToolButton *btn,SharedInfo *info); diff --git a/src/get_filename.c b/src/get_filename.c new file mode 100644 index 0000000..3b544d5 --- /dev/null +++ b/src/get_filename.c @@ -0,0 +1,43 @@ +// 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" + +gchar *get_filename(GtkWindow *window,gboolean open) { + GtkWidget *dialog; + gchar *filename; + + dialog = gtk_file_chooser_dialog_new((open) ? "Open File" : "Save File", + window, + (open) ? GTK_FILE_CHOOSER_ACTION_OPEN : GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + (open) ? GTK_STOCK_OPEN : GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT, + NULL); + + gtk_dialog_run(GTK_DIALOG(dialog)); + + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + + gtk_widget_destroy(dialog); + + return filename; +} _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git