Commit 08a71e32 authored by John Sullivan's avatar John Sullivan

Some pieces of the application and component-choosing UI.

	They don't do anything useful yet.

	* libnautilus-extensions/nautilus-program-chooser.h,
	* libnautilus-extensions/nautilus-program-chooser.c:
	New files with code for creating a program-choosing
	dialog (which is really degenerate right now).

	* libnautilus-extensions/nautilus-program-choosing.h,
	* libnautilus-extensions/nautilus-program-choosing.c:
	New files with functions for choosing a component or other
	program to display or open a file with. This uses the
	dialog in nautilus-program-chooser, but callers don't
	need to know that.

	* libnautilus-extensions/Makefile.am: add these new
	files to the build.

	* src/file-manager/fm-directory-view.c:
	(fm_directory_view_chose_application_callback),
	(fm_directory_view_chose_component_callback), (choose_application),
	(choose_component), (bonobo_menu_other_program_callback),
	(other_application_callback), (other_viewer_callback):
	New functions that connect the program-choosing UI to the
	menu items.
	(compute_menu_item_info): Stop desensitizing the "Other ..." items.
	(append_gtk_menu_item): Eliminated this function, made callers use
	more elaborate append_gtk_menu_item_with_view instead.
	(fm_directory_view_real_create_background_context_menu_items),
	(create_open_with_gtk_menu):
	Updated callers to append_gtk_menu_item.
	(fm_directory_view_real_create_selection_context_menu_items):
	Pass view to create_open_with_gtk_menu.
	(reset_bonobo_open_with_menu): Now takes an FMDirectoryView and
	uses it as callback data for "Other..." items.
	(fm_directory_view_real_merge_menus),
	(fm_directory_view_real_update_menus): Pass view to
	reset_bonobo_open_with_menu.

	* src/ntl-index-panel.c: (command_button_callback): Renamed from
	command_button_cb, also broke out application-launching code and
	moved it to libnautilus-extensions/nautilus-program-choosing.c.
	(nautilus_index_panel_chose_application_callback),
	(open_with_callback): New functions, used to wire up functionality
	of "Open with ..." button.
	(add_command_buttons): Stop desensitizing "Open with ..." button,
	and wire it up to do something.

	* src/ntl-window.h: Renamed field "option_cvtype" to "view_as_option_menu".
	* src/ntl-window.c:
	(nautilus_window_constructed): Updated to match field name change.
	(nautilus_window_switch_views): New function, broken out of
	view_menu_switch_views_callback; switches window to new content view.
	(view_menu_switch_views_callback): Now calls nautilus_window_switch_views.
	(synch_view_as_menu): New function, resets displayed name of "View as"
	menu to match current content view.
	(chose_component_callback), (view_menu_choose_view_callback): New
	functions, used to implement "View as ..." menu item.
	(nautilus_window_load_content_view_menu): Store iid in menu item;
	call synch_view_as_menu; wire up "View as ..." menu item.


	* src/ntl-window-msgs.c: (handle_unreadable_location):
	Tweaked wording of an error message.

	* src/file-manager/fm-error-reporting.c:
	(fm_report_error_renaming_file): Tweaked wording of an error message.
parent 9970b3cb
2000-05-23 John Sullivan <sullivan@eazel.com>
Some pieces of the application and component-choosing UI.
They don't do anything useful yet.
* libnautilus-extensions/nautilus-program-chooser.h,
* libnautilus-extensions/nautilus-program-chooser.c:
New files with code for creating a program-choosing
dialog (which is really degenerate right now).
* libnautilus-extensions/nautilus-program-choosing.h,
* libnautilus-extensions/nautilus-program-choosing.c:
New files with functions for choosing a component or other
program to display or open a file with. This uses the
dialog in nautilus-program-chooser, but callers don't
need to know that.
* libnautilus-extensions/Makefile.am: add these new
files to the build.
* src/file-manager/fm-directory-view.c:
(fm_directory_view_chose_application_callback),
(fm_directory_view_chose_component_callback), (choose_application),
(choose_component), (bonobo_menu_other_program_callback),
(other_application_callback), (other_viewer_callback):
New functions that connect the program-choosing UI to the
menu items.
(compute_menu_item_info): Stop desensitizing the "Other ..." items.
(append_gtk_menu_item): Eliminated this function, made callers use
more elaborate append_gtk_menu_item_with_view instead.
(fm_directory_view_real_create_background_context_menu_items),
(create_open_with_gtk_menu):
Updated callers to append_gtk_menu_item.
(fm_directory_view_real_create_selection_context_menu_items):
Pass view to create_open_with_gtk_menu.
(reset_bonobo_open_with_menu): Now takes an FMDirectoryView and
uses it as callback data for "Other..." items.
(fm_directory_view_real_merge_menus),
(fm_directory_view_real_update_menus): Pass view to
reset_bonobo_open_with_menu.
* src/ntl-index-panel.c: (command_button_callback): Renamed from
command_button_cb, also broke out application-launching code and
moved it to libnautilus-extensions/nautilus-program-choosing.c.
(nautilus_index_panel_chose_application_callback),
(open_with_callback): New functions, used to wire up functionality
of "Open with ..." button.
(add_command_buttons): Stop desensitizing "Open with ..." button,
and wire it up to do something.
* src/ntl-window.h: Renamed field "option_cvtype" to "view_as_option_menu".
* src/ntl-window.c:
(nautilus_window_constructed): Updated to match field name change.
(nautilus_window_switch_views): New function, broken out of
view_menu_switch_views_callback; switches window to new content view.
(view_menu_switch_views_callback): Now calls nautilus_window_switch_views.
(synch_view_as_menu): New function, resets displayed name of "View as"
menu to match current content view.
(chose_component_callback), (view_menu_choose_view_callback): New
functions, used to implement "View as ..." menu item.
(nautilus_window_load_content_view_menu): Store iid in menu item;
call synch_view_as_menu; wire up "View as ..." menu item.
* src/ntl-window-msgs.c: (handle_unreadable_location):
Tweaked wording of an error message.
* src/file-manager/fm-error-reporting.c:
(fm_report_error_renaming_file): Tweaked wording of an error message.
2000-05-23 Darin Adler <darin@eazel.com>
* libnautilus/nautilus-undo-manager.c:
......
......@@ -61,6 +61,8 @@ libnautilus_extensionsinclude_HEADERS= \
nautilus-list.h \
nautilus-metadata.h \
nautilus-mime-type.h \
nautilus-program-chooser.h \
nautilus-program-choosing.h \
nautilus-self-checks.h \
nautilus-string-list.h \
nautilus-string.h \
......@@ -111,6 +113,8 @@ libnautilus_extensions_la_SOURCES = \
nautilus-list-column-title.c \
nautilus-list.c \
nautilus-mime-type.c \
nautilus-program-chooser.c \
nautilus-program-choosing.c \
nautilus-self-checks.c \
nautilus-string-list.c \
nautilus-string.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-chooser.c - implementation for window that lets user choose
a program from a list
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#include <config.h>
#include "nautilus-program-chooser.h"
#include <gtk/gtklabel.h>
#include <gtk/gtkvbox.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
GnomeDialog *
nautilus_program_chooser_new (NautilusProgramChooserType type,
NautilusFile *file)
{
GtkWidget *window;
GtkWidget *prompt_label;
char *file_name, *prompt;
const char *title;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
file_name = nautilus_file_get_name (file);
switch (type) {
case NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS:
title = _("Nautilus: Choose an application");
prompt = g_strdup_printf (_("Choose an application with which to open \"%s\"\n\n(Doesn't do anything yet)"), file_name);
break;
case NAUTILUS_PROGRAM_CHOOSER_COMPONENTS:
default:
title = _("Nautilus: Choose a viewer");
prompt = g_strdup_printf (_("Choose a viewer with which to display \"%s\"\n\n(Doesn't do anything yet)"), file_name);
break;
}
g_free (file_name);
window = gnome_dialog_new (title,
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), GNOME_PAD);
prompt_label = gtk_label_new (prompt);
gtk_widget_show (prompt_label);
g_free (prompt);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (window)->vbox),
prompt_label);
/* Buttons close this dialog. */
gnome_dialog_set_close (GNOME_DIALOG (window), TRUE);
return GNOME_DIALOG (window);
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-chooser.h - interface for window that lets user choose
a program from a list
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_PROGRAM_CHOOSER_H
#define NAUTILUS_PROGRAM_CHOOSER_H
#include <gtk/gtkwindow.h>
#include <libgnomeui/gnome-dialog.h>
#include "nautilus-file.h"
typedef enum {
NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS,
NAUTILUS_PROGRAM_CHOOSER_COMPONENTS,
} NautilusProgramChooserType;
GnomeDialog *nautilus_program_chooser_new (NautilusProgramChooserType type,
NautilusFile *file);
#endif /* NAUTILUS_PROGRAM_CHOOSER_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-choosing.c - functions for selecting and activating
programs for opening/viewing particular files.
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#include <config.h>
#include "nautilus-program-choosing.h"
#include "nautilus-program-chooser.h"
#include "nautilus-string.h"
#include <libgnomeui/gnome-uidefs.h>
/**
* set_up_program_chooser:
*
* Create but don't yet run a program-choosing dialog.
* The caller should run the dialog and destroy it.
*
* @file: Which NautilusFile programs are being chosen for.
* @type: Which type of program is being chosen.
* @parent: Optional window to parent the dialog on.
*
* Return value: The program-choosing dialog, ready to be run.
*/
static GnomeDialog *
set_up_program_chooser (NautilusFile *file,
NautilusProgramChooserType type,
GtkWindow *parent)
{
GnomeDialog *dialog;
g_assert (NAUTILUS_IS_FILE (file));
dialog = nautilus_program_chooser_new (type, file);
if (parent != NULL) {
gnome_dialog_set_parent (dialog, parent);
}
/* Don't destroy on close because callers will need
* to extract some information from the dialog after
* it closes.
*/
gnome_dialog_close_hides (dialog, TRUE);
return dialog;
}
/**
* nautilus_choose_component_for_file:
*
* Lets user choose a component with which to view a given file.
*
* @file: The NautilusFile to be viewed.
* @parent_window: If supplied, the component-choosing dialog is parented
* on this window.
* @callback: Callback called when choice has been made.
* @callback_data: Parameter passed back when callback is called.
*/
void
nautilus_choose_component_for_file (NautilusFile *file,
GtkWindow *parent_window,
NautilusComponentChoiceCallback callback,
gpointer callback_data)
{
NautilusViewIdentifier *identifier;
GnomeDialog *dialog;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (callback != NULL);
/* The API uses a callback so we can do this non-modally in the future,
* but for now we just use a modal dialog.
*/
dialog = set_up_program_chooser
(file, NAUTILUS_PROGRAM_CHOOSER_COMPONENTS, parent_window);
if (gnome_dialog_run (dialog) == GNOME_OK) {
/* FIXME: Need to extract result from dialog! */
identifier = NULL;
} else {
identifier = NULL;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
/* Call callback even if identifier is NULL, so caller can
* free callback_data if necessary and present some cancel
* UI if desired.
*/
(* callback) (identifier, callback_data);
}
/**
* nautilus_choose_application_for_file:
*
* Lets user choose an application with which to open a given file.
*
* @file: The NautilusFile to be viewed.
* @parent_window: If supplied, the application-choosing dialog is parented
* on this window.
* @callback: Callback called when choice has been made.
* @callback_data: Parameter passed back when callback is called.
*/
void
nautilus_choose_application_for_file (NautilusFile *file,
GtkWindow *parent_window,
NautilusApplicationChoiceCallback callback,
gpointer callback_data)
{
char *command_string;
GnomeDialog *dialog;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (callback != NULL);
/* The API uses a callback so we can do this non-modally in the future,
* but for now we just use a modal dialog.
*/
dialog = set_up_program_chooser
(file, NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS, parent_window);
if (gnome_dialog_run (dialog) == GNOME_OK) {
/* FIXME: Need to extract result from dialog! */
#ifdef TESTING_LAUNCH
command_string = g_strdup ("gnotepad");
#else
command_string = NULL;
#endif
} else {
command_string = NULL;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
/* Call callback even if identifier is NULL, so caller can
* free callback_data if necessary and present some cancel
* UI if desired.
*/
(* callback) (command_string, callback_data);
}
/**
* nautilus_launch_application:
*
* Fork off a process to launch an application with a given uri as
* a parameter.
*
* @command_string: The application to be launched, with any desired
* command-line options.
* @uri: Passed as a parameter to the application. "file://" is stripped
* from the beginning if present.
*/
void
nautilus_launch_application (const char *command_string, const char *uri)
{
const char *uri_parameter;
pid_t new_process_id;
if (nautilus_str_has_prefix (uri, "file://")) {
uri_parameter = uri + 7;
} else {
uri_parameter = uri;
}
new_process_id = fork();
if (new_process_id == 0) {
execlp (command_string, command_string, uri_parameter, NULL);
exit (0);
}
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-choosing.h - functions for selecting and activating
programs for opening/viewing particular files.
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_PROGRAM_CHOOSING_H
#define NAUTILUS_PROGRAM_CHOOSING_H
#include "nautilus-file.h"
#include "nautilus-view-identifier.h"
#include <gtk/gtkwindow.h>
typedef void (*NautilusComponentChoiceCallback) (NautilusViewIdentifier *identifier,
gpointer callback_data);
typedef void (*NautilusApplicationChoiceCallback) (char *command_string,
gpointer callback_data);
void nautilus_choose_application_for_file (NautilusFile *file,
GtkWindow *parent_window,
NautilusApplicationChoiceCallback callback,
gpointer callback_data);
void nautilus_choose_component_for_file (NautilusFile *file,
GtkWindow *parent_window,
NautilusComponentChoiceCallback callback,
gpointer callback_data);
void nautilus_launch_application (const char *command_string,
const char *uri);
#endif /* NAUTILUS_PROGRAM_CHOOSING_H */
......@@ -61,6 +61,8 @@ libnautilus_extensionsinclude_HEADERS= \
nautilus-list.h \
nautilus-metadata.h \
nautilus-mime-type.h \
nautilus-program-chooser.h \
nautilus-program-choosing.h \
nautilus-self-checks.h \
nautilus-string-list.h \
nautilus-string.h \
......@@ -111,6 +113,8 @@ libnautilus_extensions_la_SOURCES = \
nautilus-list-column-title.c \
nautilus-list.c \
nautilus-mime-type.c \
nautilus-program-chooser.c \
nautilus-program-choosing.c \
nautilus-self-checks.c \
nautilus-string-list.c \
nautilus-string.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-chooser.c - implementation for window that lets user choose
a program from a list
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#include <config.h>
#include "nautilus-program-chooser.h"
#include <gtk/gtklabel.h>
#include <gtk/gtkvbox.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
GnomeDialog *
nautilus_program_chooser_new (NautilusProgramChooserType type,
NautilusFile *file)
{
GtkWidget *window;
GtkWidget *prompt_label;
char *file_name, *prompt;
const char *title;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
file_name = nautilus_file_get_name (file);
switch (type) {
case NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS:
title = _("Nautilus: Choose an application");
prompt = g_strdup_printf (_("Choose an application with which to open \"%s\"\n\n(Doesn't do anything yet)"), file_name);
break;
case NAUTILUS_PROGRAM_CHOOSER_COMPONENTS:
default:
title = _("Nautilus: Choose a viewer");
prompt = g_strdup_printf (_("Choose a viewer with which to display \"%s\"\n\n(Doesn't do anything yet)"), file_name);
break;
}
g_free (file_name);
window = gnome_dialog_new (title,
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), GNOME_PAD);
prompt_label = gtk_label_new (prompt);
gtk_widget_show (prompt_label);
g_free (prompt);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (window)->vbox),
prompt_label);
/* Buttons close this dialog. */
gnome_dialog_set_close (GNOME_DIALOG (window), TRUE);
return GNOME_DIALOG (window);
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-chooser.h - interface for window that lets user choose
a program from a list
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_PROGRAM_CHOOSER_H
#define NAUTILUS_PROGRAM_CHOOSER_H
#include <gtk/gtkwindow.h>
#include <libgnomeui/gnome-dialog.h>
#include "nautilus-file.h"
typedef enum {
NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS,
NAUTILUS_PROGRAM_CHOOSER_COMPONENTS,
} NautilusProgramChooserType;
GnomeDialog *nautilus_program_chooser_new (NautilusProgramChooserType type,
NautilusFile *file);
#endif /* NAUTILUS_PROGRAM_CHOOSER_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-program-choosing.c - functions for selecting and activating
programs for opening/viewing particular files.
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: John Sullivan <sullivan@eazel.com>
*/
#include <config.h>
#include "nautilus-program-choosing.h"
#include "nautilus-program-chooser.h"
#include "nautilus-string.h"
#include <libgnomeui/gnome-uidefs.h>
/**
* set_up_program_chooser:
*
* Create but don't yet run a program-choosing dialog.
* The caller should run the dialog and destroy it.
*
* @file: Which NautilusFile programs are being chosen for.
* @type: Which type of program is being chosen.
* @parent: Optional window to parent the dialog on.
*
* Return value: The program-choosing dialog, ready to be run.
*/
static GnomeDialog *
set_up_program_chooser (NautilusFile *file,
NautilusProgramChooserType type,
GtkWindow *parent)
{
GnomeDialog *dialog;
g_assert (NAUTILUS_IS_FILE (file));
dialog = nautilus_program_chooser_new (type, file);
if (parent != NULL) {
gnome_dialog_set_parent (dialog, parent);
}
/* Don't destroy on close because callers will need
* to extract some information from the dialog after
* it closes.
*/
gnome_dialog_close_hides (dialog, TRUE);
return dialog;
}
/**
* nautilus_choose_component_for_file:
*
* Lets user choose a component with which to view a given file.
*
* @file: The NautilusFile to be viewed.
* @parent_window: If supplied, the component-choosing dialog is parented
* on this window.
* @callback: Callback called when choice has been made.
* @callback_data: Parameter passed back when callback is called.
*/
void
nautilus_choose_component_for_file (NautilusFile *file,
GtkWindow *parent_window,
NautilusComponentChoiceCallback callback,
gpointer callback_data)
{
NautilusViewIdentifier *identifier;
GnomeDialog *dialog;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (callback != NULL);
/* The API uses a callback so we can do this non-modally in the future,
* but for now we just use a modal dialog.
*/
dialog = set_up_program_chooser
(file, NAUTILUS_PROGRAM_CHOOSER_COMPONENTS, parent_window);
if (gnome_dialog_run (dialog) == GNOME_OK) {
/* FIXME: Need to extract result from dialog! */
identifier = NULL;
} else {
identifier = NULL;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
/* Call callback even if identifier is NULL, so caller can
* free callback_data if necessary and present some cancel
* UI if desired.
*/
(* callback) (identifier, callback_data);
}