/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-msg-composer-select-file.c
 *
 * Copyright (C) 2000 Helix Code, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: Ettore Perazzoli
 */

#include <gtk/gtkfilesel.h>

#include "e-msg-composer-select-file.h"


struct _FileSelectionInfo {
	GtkWidget *widget;
	char *selected_file;
};
typedef struct _FileSelectionInfo FileSelectionInfo;


static void
confirm (FileSelectionInfo *info)
{
	const char *filename;

	filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (info->widget));
	info->selected_file = g_strdup (filename);

	gtk_widget_hide (info->widget);

	gtk_main_quit ();
}

static void
cancel (FileSelectionInfo *info)
{
	g_assert (info->selected_file == NULL);

	gtk_widget_hide (info->widget);

	gtk_main_quit ();
}


/* Callbacks.  */

static void
ok_clicked_cb (GtkWidget *widget,
	       void *data)
{
	FileSelectionInfo *info;

	info = (FileSelectionInfo *) data;
	confirm (info);
}

static void
cancel_clicked_cb (GtkWidget *widget,
		   void *data)
{
	FileSelectionInfo *info;

	info = (FileSelectionInfo *) data;
	cancel (info);
}

static int
delete_event_cb (GtkWidget *widget,
		 GdkEventAny *event,
		 void *data)
{
	FileSelectionInfo *info;

	info = (FileSelectionInfo *) data;
	cancel (info);

	return TRUE;
}


/* Setup.  */

static FileSelectionInfo *
create_file_selection (EMsgComposer *composer)
{
	FileSelectionInfo *info;
	GtkWidget *widget;
	GtkWidget *ok_button;
	GtkWidget *cancel_button;

	info = g_new (FileSelectionInfo, 1);

	widget        = gtk_file_selection_new (NULL);
	ok_button     = GTK_FILE_SELECTION (widget)->ok_button;
	cancel_button = GTK_FILE_SELECTION (widget)->cancel_button;

	gtk_signal_connect (GTK_OBJECT (ok_button),
			    "clicked", GTK_SIGNAL_FUNC (ok_clicked_cb), info);
	gtk_signal_connect (GTK_OBJECT (cancel_button),
			    "clicked", GTK_SIGNAL_FUNC (cancel_clicked_cb), info);
	gtk_signal_connect (GTK_OBJECT (widget), "delete_event",
			    GTK_SIGNAL_FUNC (delete_event_cb), info);

	info->widget        = widget;
	info->selected_file = NULL;

	return info;
}

static void
file_selection_info_destroy_notify (void *data)
{
	FileSelectionInfo *info;

	info = (FileSelectionInfo *) data;

	g_free (info->selected_file);
	g_free (info);
}


char *
e_msg_composer_select_file (EMsgComposer *composer,
			    const char *title)
{
	FileSelectionInfo *info;
	char *retval;

	g_return_val_if_fail (composer != NULL, NULL);
	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);

	info = gtk_object_get_data (GTK_OBJECT (composer),
				    "e-msg-composer-file-selection-info");

	if (info == NULL) {
		info = create_file_selection (composer);
		gtk_object_set_data_full (GTK_OBJECT (composer),
					  "e-msg-composer-file-selection-info", info,
					  file_selection_info_destroy_notify);
	}

	if (GTK_WIDGET_VISIBLE (info->widget))
		return NULL;		/* Busy!  */

	gtk_window_set_title (GTK_WINDOW (info->widget), title);
	gtk_widget_show (info->widget);

	GDK_THREADS_ENTER();
	gtk_main ();
	GDK_THREADS_LEAVE();

	retval = info->selected_file;
	info->selected_file = NULL;

	return retval;
}
n6/files/node-fetch-2.6.1'>dependabot/npm_and_yarn/devel/electron6/files/node-fetch-2.6.1</option>
<option value='dependabot/npm_and_yarn/devel/electron6/files/serve-10.1.2'>dependabot/npm_and_yarn/devel/electron6/files/serve-10.1.2</option>
<option value='gnome-3.22'>gnome-3.22</option>
<option value='gnome-3.24'>gnome-3.24</option>
<option value='gnome-3.26'>gnome-3.26</option>
<option value='gnome-3.28'>gnome-3.28</option>
<option value='gnome-3.32'>gnome-3.32</option>
<option value='gnome-3.36'>gnome-3.36</option>
<option value='gstreamer' selected='selected'>gstreamer</option>
<option value='gstreamer-1.16'>gstreamer-1.16</option>
<option value='gstreamer0.10-removal'>gstreamer0.10-removal</option>
<option value='main'>main</option>
<option value='master'>master</option>
<option value='mate-1.16'>mate-1.16</option>
<option value='mate-1.18'>mate-1.18</option>
<option value='mate-1.20'>mate-1.20</option>
<option value='mate-1.22'>mate-1.22</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)</td><td class='sub right'></td></tr></table>
<table class='tabs'><tr><td>
<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/about/?h=gstreamer'>about</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/?h=gstreamer'>summary</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/refs/?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>refs</a><a class='active' href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/textproc/kmflcomp?h=gstreamer'>log</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/tree/textproc/kmflcomp?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>tree</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>commit</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/diff/textproc/kmflcomp?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>diff</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/stats/textproc/kmflcomp?h=gstreamer'>stats</a></td><td class='form'><form class='right' method='get' action='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/textproc/kmflcomp'>
<input type='hidden' name='h' value='gstreamer'/><input type='hidden' name='id' value='29e98fda03a61a22e24f6d026d0d91f041e59921'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>root</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/textproc?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>textproc</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/textproc/kmflcomp?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921'>kmflcomp</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th></th><th class='left'>Commit message (<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/textproc/kmflcomp?h=gstreamer&amp;id=29e98fda03a61a22e24f6d026d0d91f041e59921&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Age</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=2ff80f55375ee2811ca2895a06b853699c3e0915'>Remove ${PORTSDIR}/ from dependencies, categories r, s, t, and u.</a></td><td>mat</td><td><span title='2016-04-01 22:25:16 +0800'>2016-04-01</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=d843ecd4966c8a5bed60cf3aaeb27edb6b5b2389'>Cleanup DIST* variables.</a></td><td>mat</td><td><span title='2015-05-12 02:34:57 +0800'>2015-05-12</span></td><td>1</td><td><span class='deletions'>-2</span>/<span class='insertions'>+2</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=7e5d6580d01e1321ae6ac828c5a26b9c5a66c408'>Cleanup plist</a></td><td>antoine</td><td><span title='2014-11-16 00:26:32 +0800'>2014-11-16</span></td><td>1</td><td><span class='deletions'>-3</span>/<span class='insertions'>+0</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=6886eb76b1f0e7553b1ca09373b80cd4ed5fa32e'>- Stage support</a></td><td>miwi</td><td><span title='2014-06-27 22:27:33 +0800'>2014-06-27</span></td><td>2</td><td><span class='deletions'>-10</span>/<span class='insertions'>+9</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=260207ce91e2656af49dbcb8b2556c315389b3a2'>Add NO_STAGE all over the place in preparation for the staging support (cat: ...</a></td><td>bapt</td><td><span title='2013-09-21 07:17:30 +0800'>2013-09-21</span></td><td>1</td><td><span class='deletions'>-5</span>/<span class='insertions'>+2</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=41290677b018da2819144b0188ac8bd1b91a88e4'>- Make ports use the libc provided iconv implementation on 10-CURRENT</a></td><td>madpilot</td><td><span title='2013-09-05 02:06:07 +0800'>2013-09-05</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=a99e7e687dd8959b456b245eeaafe101878e92d8'>- Convert USE_ICONV=yes to USES=iconv</a></td><td>mva</td><td><span title='2013-04-28 02:25:24 +0800'>2013-04-28</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=2c31cf01f2df98206684cc980aacec3c320afe63'>s/X11BASE/LOCALBASE/, or equivalent.</a></td><td>dougb</td><td><span title='2012-06-25 05:53:38 +0800'>2012-06-25</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=e61d6a701f43e8cec5a4ec8c9641daf5376441de'>- Add LDFLAGS to CONFIGURE_ENV and MAKE_ENV (as it was done with LDFLAGS)</a></td><td>amdmi3</td><td><span title='2011-09-24 06:26:39 +0800'>2011-09-24</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+0</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=f71eccdfb62eef79ba26dcb29eedae91be886ae2'>- Patch SCIM KMFL engine (textproc/scim-kmfl-imengine) to use</a></td><td>wxs</td><td><span title='2011-05-29 21:28:25 +0800'>2011-05-29</span></td><td>3</td><td><span class='deletions'>-11</span>/<span class='insertions'>+12</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=76296cc7e969c6611fbf51fccb323bcbb2ea63f2'>Update to 1.0.3</a></td><td>makc</td><td><span title='2010-07-24 06:07:44 +0800'>2010-07-24</span></td><td>4</td><td><span class='deletions'>-72</span>/<span class='insertions'>+6</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=e2c96987937e0a69132812ed9cb3c18957cfd043'>Remove incorrect gettext dependency. USE_ICONV and -liconv is sufficient</a></td><td>wxs</td><td><span title='2010-06-19 22:31:32 +0800'>2010-06-19</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=86ef5adf937c4c198a5dc6f2b511ee5d230028e0'>- Fixes kmflcomp coredumping on amd64 systems; the patches are provided by Do...</a></td><td>miwi</td><td><span title='2009-11-29 04:32:35 +0800'>2009-11-29</span></td><td>3</td><td><span class='deletions'>-0</span>/<span class='insertions'>+64</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=ba03e051e82fca13597a0f6f7b3268d0c405d2d2'>- Switch SourceForge ports to the new File Release System: categories startin...</a></td><td>amdmi3</td><td><span title='2009-08-22 08:37:17 +0800'>2009-08-22</span></td><td>1</td><td><span class='deletions'>-2</span>/<span class='insertions'>+2</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=768df320ca2a75e3df062efddfe90ba77e46cda3'>- Update to 0.9.8</a></td><td>wxs</td><td><span title='2009-07-03 21:47:46 +0800'>2009-07-03</span></td><td>3</td><td><span class='deletions'>-8</span>/<span class='insertions'>+7</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=c8007265d81e778bec43e1f7b073b196887b3604'>Update CONFIGURE_ARGS for how we pass CONFIGURE_TARGET to configure script.</a></td><td>rafan</td><td><span title='2008-08-21 14:18:49 +0800'>2008-08-21</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+0</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/textproc/kmflcomp?h=gstreamer&amp;id=ebc610cf091515158990f61905366db93dafb89f'>- Fix bison dependency wrong committed on import</a></td><td>garga</td><td><span title='2007-10-24 23:43:17 +0800'>2007-10-24</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+3</span></td></tr>