mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-07-16 10:17:23 +00:00
Merged the nautilus-new-mime branch.
2004-07-21 Dave Camp <dave@novell.com> * Merged the nautilus-new-mime branch.
This commit is contained in:
parent
d8062f4a39
commit
eb6a30500d
121
ChangeLog
121
ChangeLog
|
@ -1,3 +1,124 @@
|
|||
2004-07-21 Dave Camp <dave@novell.com>
|
||||
|
||||
* Merged the nautilus-new-mime branch.
|
||||
|
||||
2004-07-21 Dave Camp <dave@novell.com>
|
||||
|
||||
* src/file-manager/fm-properties-window.c: (should_show_open_with),
|
||||
(create_open_with_page), (create_properties_window): Show
|
||||
the Open With tab in the properties window.
|
||||
|
||||
2004-07-19 Dave Camp <dave@novell.com>
|
||||
|
||||
* libnautilus-private/nautilus-mime-actions.c:
|
||||
(nautilus_mime_get_default_application_for_file_internal):
|
||||
* src/file-manager/fm-directory-view.c: (application_selected_cb),
|
||||
(choose_program), (file_is_launchable): Use the new eel
|
||||
open with dialog.
|
||||
|
||||
Mon Jul 19 12:52:04 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* src/file-manager/fm-directory-view.c
|
||||
(get_default_executable_text_file_action): default to ASK
|
||||
|
||||
2004-07-12 Dave Camp <dave@novell.com>
|
||||
|
||||
* libnautilus-private/nautilus-mime-actions.c:
|
||||
(nautilus_mime_actions_get_open_with_file_attributes),
|
||||
(nautilus_mime_actions_check_if_open_with_attributes_ready),
|
||||
(nautilus_mime_get_default_application_for_file_internal),
|
||||
(get_open_with_mime_applications),
|
||||
(nautilus_mime_get_open_with_applications_for_file):
|
||||
* libnautilus-private/nautilus-program-choosing.c:
|
||||
(nautilus_launch_show_file):
|
||||
* src/file-manager/fm-directory-view.c:
|
||||
(add_application_to_bonobo_menu),
|
||||
(get_default_executable_text_file_action),
|
||||
(get_executable_text_file_action), (can_use_component_for_file),
|
||||
(get_activation_action), (reset_bonobo_open_with_menu),
|
||||
(real_update_menus), (fm_directory_view_notify_selection_changed),
|
||||
(activate_callback):
|
||||
* src/file-manager/nautilus-directory-view-ui.xml:
|
||||
|
||||
MIME overhaul, part 2.
|
||||
|
||||
Show the application that will be executed in the Open menu
|
||||
item. If there are < 4 applications, show them in the main
|
||||
context menu, otherwise show them in the Open With menu.
|
||||
|
||||
2004-07-09 Dave Camp <dave@novell.com>
|
||||
|
||||
|
||||
* test/Makefile.am (noinst_PROGRAMS):
|
||||
* libnautilus-private/Makefile.am:
|
||||
* libnautilus-private/nautilus-mime-actions.c:
|
||||
(nautilus_mime_get_applications_for_file),
|
||||
(application_supports_uri_scheme_strcmp_style),
|
||||
(nautilus_mime_has_any_applications_for_file),
|
||||
(nautilus_mime_set_default_application_for_file),
|
||||
(gnome_vfs_mime_application_has_id),
|
||||
(gnome_vfs_mime_id_matches_application),
|
||||
(gnome_vfs_mime_application_has_id_not_in_list):
|
||||
* libnautilus-private/nautilus-mime-actions.h:
|
||||
* libnautilus-private/nautilus-program-choosing.c:
|
||||
(application_cannot_open_location), (nautilus_launch_show_file),
|
||||
(nautilus_launch_application):
|
||||
* libnautilus-private/nautilus-program-choosing.h:
|
||||
* libnautilus-private/nautilus-view-query.c: (is_known_mime_type),
|
||||
(nautilus_view_query_check_if_minimum_attributes_ready),
|
||||
(nautilus_view_query_check_if_full_attributes_ready),
|
||||
(nautilus_view_query_get_popup_file_attributes),
|
||||
(nautilus_view_query_check_if_popup_attributes_ready),
|
||||
(nautilus_view_query_get_default_component_sort_conditions),
|
||||
(nautilus_view_query_get_default_component_for_file_internal),
|
||||
(nautilus_view_query_get_default_component_for_file),
|
||||
(nautilus_view_query_get_fallback_component_for_file),
|
||||
(nautilus_view_query_get_components_for_file_extended),
|
||||
(nautilus_view_query_get_components_for_file),
|
||||
(nautilus_view_query_has_any_components_for_file_extended),
|
||||
(nautilus_view_query_has_any_components_for_file),
|
||||
(mime_get_components_for_uri_scheme),
|
||||
(nautilus_view_query_has_any_components_for_uri_scheme),
|
||||
(nautilus_view_query_set_default_component_for_file),
|
||||
(extract_prefix_add_suffix), (mime_type_get_supertype),
|
||||
(get_explicit_content_view_iids_from_metafile),
|
||||
(make_bonobo_activation_query_for_explicit_content_view_iids),
|
||||
(make_bonobo_activation_query_with_known_mime_type),
|
||||
(make_bonobo_activation_query_with_uri_scheme_only),
|
||||
(mime_type_list_to_hash_table), (free_key),
|
||||
(mime_type_hash_table_destroy), (server_has_content_requirements),
|
||||
(server_matches_content_requirements),
|
||||
(nautilus_do_component_query), (strv_length), (strv_concat),
|
||||
(nautilus_view_query_get_popup_components_for_file),
|
||||
(nautilus_view_query_get_property_components_for_file),
|
||||
(has_server_info_in_list), (server_info_list_intersection),
|
||||
(nautilus_view_query_get_property_components_for_files),
|
||||
(nautilus_view_query_get_popup_components_for_files):
|
||||
* libnautilus-private/nautilus-view-query.h:
|
||||
* src/file-manager/fm-directory-view.c: (choose_program),
|
||||
(open_with_other_program), (other_application_callback),
|
||||
(can_use_component_for_file), (activate_callback):
|
||||
* src/nautilus-applicable-views.c: (got_file_info_callback):
|
||||
* src/nautilus-information-panel.c: (open_with_callback),
|
||||
(nautilus_information_panel_update_buttons):
|
||||
* src/nautilus-navigation-window.c: (load_view_as_menu):
|
||||
* src/nautilus-shell-ui.xml:
|
||||
* src/nautilus-window-manage-views.c:
|
||||
(nautilus_window_set_content_view):
|
||||
* src/nautilus-window-menus.c:
|
||||
(nautilus_window_initialize_menus_part_1):
|
||||
* src/nautilus-window.c: (refresh_stored_viewers),
|
||||
(nautilus_window_set_viewed_file): MIME overhaul, part 1.
|
||||
Separated gnome-vfs application mime mapping from view querying,
|
||||
put them in different files.
|
||||
|
||||
Got rid of the short list/all application distinction.
|
||||
|
||||
Got rid of "View As...", all appropriate views are shown.
|
||||
|
||||
Only ever show folders in nautilus - everything else should be
|
||||
opened in an app.
|
||||
|
||||
2004-07-16 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* data/Makefile.am:
|
||||
|
|
|
@ -153,8 +153,6 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-module.h \
|
||||
nautilus-monitor.c \
|
||||
nautilus-monitor.h \
|
||||
nautilus-program-chooser.c \
|
||||
nautilus-program-chooser.h \
|
||||
nautilus-program-choosing.c \
|
||||
nautilus-program-choosing.h \
|
||||
nautilus-recent.h \
|
||||
|
@ -189,6 +187,8 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-vfs-file.h \
|
||||
nautilus-view-identifier.c \
|
||||
nautilus-view-identifier.h \
|
||||
nautilus-view-query.c \
|
||||
nautilus-view-query.h \
|
||||
$(NULL)
|
||||
|
||||
$(lib_LTLIBRARIES): $(dependency_static_libs)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -32,57 +32,15 @@
|
|||
|
||||
NautilusFileAttributes nautilus_mime_actions_get_minimum_file_attributes (void);
|
||||
NautilusFileAttributes nautilus_mime_actions_get_full_file_attributes (void);
|
||||
gboolean nautilus_mime_actions_file_needs_full_file_attributes (NautilusFile *file);
|
||||
GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_file (NautilusFile *file);
|
||||
GnomeVFSMimeAction * nautilus_mime_get_default_action_for_file (NautilusFile *file);
|
||||
|
||||
GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_file (NautilusFile *file);
|
||||
gboolean nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *file);
|
||||
Bonobo_ServerInfo * nautilus_mime_get_default_component_for_file (NautilusFile *file);
|
||||
Bonobo_ServerInfo * nautilus_mime_get_default_fallback_component_for_file (NautilusFile *file);
|
||||
gboolean nautilus_mime_is_default_component_for_file_user_chosen (NautilusFile *file);
|
||||
GList * nautilus_mime_get_short_list_applications_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_open_with_applications_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_short_list_components_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_all_applications_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_all_components_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_all_components_for_file_extended (NautilusFile *file, char *extra_requirements);
|
||||
GList * nautilus_mime_get_popup_components_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_popup_components_for_files (GList *files);
|
||||
GList * nautilus_mime_get_property_components_for_file (NautilusFile *file);
|
||||
GList * nautilus_mime_get_property_components_for_files (GList *files);
|
||||
gboolean nautilus_mime_has_any_components_for_file (NautilusFile *file);
|
||||
gboolean nautilus_mime_has_any_components_for_file_extended (NautilusFile *file, char *extra_requirements);
|
||||
GList * nautilus_mime_get_applications_for_file (NautilusFile *file);
|
||||
|
||||
|
||||
gboolean nautilus_mime_has_any_applications_for_file (NautilusFile *file);
|
||||
gboolean nautilus_mime_has_any_applications_for_file_type (NautilusFile *file);
|
||||
GnomeVFSResult nautilus_mime_set_default_action_type_for_file (NautilusFile *file,
|
||||
GnomeVFSMimeActionType action_type);
|
||||
|
||||
GnomeVFSResult nautilus_mime_set_default_application_for_file (NautilusFile *file,
|
||||
const char *application_id);
|
||||
GnomeVFSResult nautilus_mime_set_default_component_for_file (NautilusFile *file,
|
||||
const char *component_iid);
|
||||
/* Stored as delta to current user level */
|
||||
GnomeVFSResult nautilus_mime_set_short_list_applications_for_file (NautilusFile *file,
|
||||
GList *components);
|
||||
GnomeVFSResult nautilus_mime_add_application_to_short_list_for_file (NautilusFile *file,
|
||||
const char *application_id);
|
||||
GnomeVFSResult nautilus_mime_remove_application_from_short_list_for_file (NautilusFile *file,
|
||||
const char *application_id);
|
||||
GnomeVFSResult nautilus_mime_set_short_list_components_for_file (NautilusFile *file,
|
||||
GList *components);
|
||||
GnomeVFSResult nautilus_mime_add_component_to_short_list_for_file (NautilusFile *file,
|
||||
const char *iid);
|
||||
GnomeVFSResult nautilus_mime_remove_component_from_short_list_for_file (NautilusFile *file,
|
||||
const char *iid);
|
||||
|
||||
/* No way to override system list; can only add. */
|
||||
GnomeVFSResult nautilus_mime_extend_all_applications_for_file (NautilusFile *file,
|
||||
GList *applications);
|
||||
/* Only "user" entries may be removed. */
|
||||
GnomeVFSResult nautilus_mime_remove_from_all_applications_for_file (NautilusFile *file,
|
||||
GList *applications);
|
||||
gboolean nautilus_mime_has_any_components_for_uri_scheme (const char *uri_scheme);
|
||||
|
||||
|
||||
/* No way to add to all components; oafinfo database assumed trusted in this regard. */
|
||||
|
||||
#endif /* NAUTILUS_MIME_ACTIONS_H */
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nautilus-program-choosing.h"
|
||||
|
||||
#include "nautilus-mime-actions.h"
|
||||
#include "nautilus-program-chooser.h"
|
||||
#include "nautilus-global-preferences.h"
|
||||
#include "nautilus-icon-factory.h"
|
||||
#include <eel/eel-glib-extensions.h>
|
||||
|
@ -63,22 +62,6 @@
|
|||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
NautilusFile *file;
|
||||
GtkWindow *parent_window;
|
||||
NautilusApplicationChoiceCallback callback;
|
||||
gpointer callback_data;
|
||||
} ChooseApplicationCallbackData;
|
||||
|
||||
typedef struct {
|
||||
NautilusFile *file;
|
||||
GtkWindow *parent_window;
|
||||
NautilusComponentChoiceCallback callback;
|
||||
gpointer callback_data;
|
||||
} ChooseComponentCallbackData;
|
||||
|
||||
static GHashTable *choose_application_hash_table, *choose_component_hash_table;
|
||||
|
||||
extern char **environ;
|
||||
|
||||
/* Cut and paste from gdkspawn-x11.c */
|
||||
|
@ -119,429 +102,6 @@ my_gdk_spawn_make_environment_for_screen (GdkScreen *screen,
|
|||
}
|
||||
|
||||
|
||||
static guint
|
||||
choose_application_hash (gconstpointer p)
|
||||
{
|
||||
const ChooseApplicationCallbackData *data;
|
||||
|
||||
data = p;
|
||||
return GPOINTER_TO_UINT (data->file)
|
||||
^ GPOINTER_TO_UINT (data->callback)
|
||||
^ GPOINTER_TO_UINT (data->callback_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
choose_application_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
const ChooseApplicationCallbackData *data_a, *data_b;
|
||||
|
||||
data_a = a;
|
||||
data_b = a;
|
||||
return data_a->file == data_b->file
|
||||
&& data_a->callback == data_b->callback
|
||||
&& data_a->callback_data == data_b->callback_data;
|
||||
}
|
||||
|
||||
static void
|
||||
choose_application_destroy (ChooseApplicationCallbackData *choose_data)
|
||||
{
|
||||
nautilus_file_unref (choose_data->file);
|
||||
if (choose_data->parent_window != NULL) {
|
||||
g_object_unref (choose_data->parent_window);
|
||||
}
|
||||
g_free (choose_data);
|
||||
}
|
||||
|
||||
static guint
|
||||
choose_component_hash (gconstpointer p)
|
||||
{
|
||||
const ChooseApplicationCallbackData *data;
|
||||
|
||||
data = p;
|
||||
return GPOINTER_TO_UINT (data->file)
|
||||
^ GPOINTER_TO_UINT (data->callback)
|
||||
^ GPOINTER_TO_UINT (data->callback_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
choose_component_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
const ChooseApplicationCallbackData *data_a, *data_b;
|
||||
|
||||
data_a = a;
|
||||
data_b = a;
|
||||
return data_a->file == data_b->file
|
||||
&& data_a->callback == data_b->callback
|
||||
&& data_a->callback_data == data_b->callback_data;
|
||||
}
|
||||
|
||||
static void
|
||||
choose_component_destroy (ChooseComponentCallbackData *choose_data)
|
||||
{
|
||||
nautilus_file_unref (choose_data->file);
|
||||
if (choose_data->parent_window != NULL) {
|
||||
g_object_unref (choose_data->parent_window);
|
||||
}
|
||||
g_free (choose_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 GtkWidget *
|
||||
set_up_program_chooser (NautilusFile *file,
|
||||
GnomeVFSMimeActionType type,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
g_assert (NAUTILUS_IS_FILE (file));
|
||||
|
||||
dialog = nautilus_program_chooser_new (type, file);
|
||||
if (parent != NULL) {
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
static void
|
||||
choose_component_callback (NautilusFile *file,
|
||||
gpointer callback_data)
|
||||
{
|
||||
ChooseComponentCallbackData *choose_data;
|
||||
NautilusViewIdentifier *identifier;
|
||||
GtkWidget *dialog;
|
||||
|
||||
choose_data = callback_data;
|
||||
|
||||
/* Remove from the hash table. */
|
||||
g_assert (g_hash_table_lookup (choose_component_hash_table,
|
||||
choose_data) == choose_data);
|
||||
g_hash_table_remove (choose_component_hash_table,
|
||||
choose_data);
|
||||
|
||||
/* The API uses a callback so we can do this non-modally in the future,
|
||||
* but for now we just use a modal dialog.
|
||||
*/
|
||||
|
||||
identifier = NULL;
|
||||
dialog = NULL;
|
||||
if (nautilus_mime_has_any_components_for_file_extended (file,
|
||||
"NOT nautilus:property_page_name.defined()")) {
|
||||
dialog = set_up_program_chooser (file, GNOME_VFS_MIME_ACTION_TYPE_COMPONENT,
|
||||
choose_data->parent_window);
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
|
||||
identifier = nautilus_program_chooser_get_component (NAUTILUS_PROGRAM_CHOOSER (dialog));
|
||||
}
|
||||
} else {
|
||||
nautilus_program_chooser_show_no_choices_message (GNOME_VFS_MIME_ACTION_TYPE_COMPONENT,
|
||||
file,
|
||||
choose_data->parent_window);
|
||||
}
|
||||
|
||||
/* Call callback even if identifier is NULL, so caller can
|
||||
* free callback_data if necessary and present some cancel UI
|
||||
* if desired.
|
||||
*/
|
||||
(* choose_data->callback) (identifier, choose_data->callback_data);
|
||||
|
||||
if (dialog != NULL) {
|
||||
/* Destroy only after callback, since view identifier will
|
||||
* be destroyed too.
|
||||
*/
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
choose_component_destroy (choose_data);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_choose_component_for_file (NautilusFile *file,
|
||||
GtkWindow *parent_window,
|
||||
NautilusComponentChoiceCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
ChooseComponentCallbackData *choose_data;
|
||||
NautilusFileAttributes attributes;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_FILE (file));
|
||||
g_return_if_fail (parent_window == NULL || GTK_IS_WINDOW (parent_window));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
/* Grab refs to the objects so they will still be around at
|
||||
* callback time.
|
||||
*/
|
||||
nautilus_file_ref (file);
|
||||
if (parent_window != NULL) {
|
||||
g_object_ref (parent_window);
|
||||
}
|
||||
|
||||
/* Create data to pass through. */
|
||||
choose_data = g_new (ChooseComponentCallbackData, 1);
|
||||
choose_data->file = file;
|
||||
choose_data->parent_window = parent_window;
|
||||
choose_data->callback = callback;
|
||||
choose_data->callback_data = callback_data;
|
||||
|
||||
/* Put pending entry into choose hash table. */
|
||||
if (choose_component_hash_table == NULL) {
|
||||
choose_component_hash_table = eel_g_hash_table_new_free_at_exit
|
||||
(choose_component_hash,
|
||||
choose_component_equal,
|
||||
"choose component");
|
||||
}
|
||||
g_hash_table_insert (choose_component_hash_table,
|
||||
choose_data, choose_data);
|
||||
|
||||
/* Do the rest of the work when the attributes are ready. */
|
||||
attributes = nautilus_mime_actions_get_full_file_attributes ();
|
||||
nautilus_file_call_when_ready (file,
|
||||
attributes,
|
||||
choose_component_callback,
|
||||
choose_data);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_cancel_choose_component_for_file (NautilusFile *file,
|
||||
NautilusComponentChoiceCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
ChooseComponentCallbackData search_criteria;
|
||||
ChooseComponentCallbackData *choose_data;
|
||||
|
||||
if (choose_component_hash_table == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Search for an existing choose in progress. */
|
||||
search_criteria.file = file;
|
||||
search_criteria.callback = callback;
|
||||
search_criteria.callback_data = callback_data;
|
||||
choose_data = g_hash_table_lookup (choose_component_hash_table,
|
||||
&search_criteria);
|
||||
if (choose_data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Stop it. */
|
||||
g_hash_table_remove (choose_component_hash_table,
|
||||
choose_data);
|
||||
nautilus_file_cancel_call_when_ready (file,
|
||||
choose_component_callback,
|
||||
choose_data);
|
||||
choose_component_destroy (choose_data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dialog_response (GtkDialog *dialog,
|
||||
int response_id,
|
||||
ChooseApplicationCallbackData *choose_data)
|
||||
{
|
||||
GnomeVFSMimeApplication *application;
|
||||
|
||||
application = NULL;
|
||||
|
||||
switch (response_id) {
|
||||
case GTK_RESPONSE_OK:
|
||||
application = nautilus_program_chooser_get_application (NAUTILUS_PROGRAM_CHOOSER (dialog));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
(* choose_data->callback) (application, choose_data->callback_data);
|
||||
|
||||
if (dialog != NULL) {
|
||||
/* Destroy only after callback, since view identifier
|
||||
* will be destroyed too.
|
||||
*/
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
choose_application_destroy (choose_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.
|
||||
*/
|
||||
|
||||
static void
|
||||
choose_application_callback (NautilusFile *file,
|
||||
gpointer callback_data)
|
||||
{
|
||||
ChooseApplicationCallbackData *choose_data;
|
||||
GtkWidget *dialog;
|
||||
GnomeVFSMimeApplication *application;
|
||||
|
||||
choose_data = callback_data;
|
||||
|
||||
/* Remove from the hash table. */
|
||||
g_assert (g_hash_table_lookup (choose_application_hash_table,
|
||||
choose_data) == choose_data);
|
||||
g_hash_table_remove (choose_application_hash_table,
|
||||
choose_data);
|
||||
|
||||
/* The API uses a callback so we can do this non-modally in the future,
|
||||
* but for now we just use a modal dialog.
|
||||
*/
|
||||
application = NULL;
|
||||
dialog = NULL;
|
||||
|
||||
if (nautilus_mime_has_any_applications_for_file_type (file)) {
|
||||
dialog = set_up_program_chooser (file, GNOME_VFS_MIME_ACTION_TYPE_APPLICATION,
|
||||
choose_data->parent_window);
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (dialog_response), choose_data);
|
||||
gtk_widget_show (dialog);
|
||||
} else {
|
||||
nautilus_program_chooser_show_no_choices_message (GNOME_VFS_MIME_ACTION_TYPE_APPLICATION,
|
||||
file,
|
||||
choose_data->parent_window);
|
||||
|
||||
/* Call callback even if identifier is NULL, so caller can
|
||||
* free callback_data if necessary and present some cancel
|
||||
* UI if desired.
|
||||
*/
|
||||
(* choose_data->callback) (application, choose_data->callback_data);
|
||||
|
||||
choose_application_destroy (choose_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_choose_application_for_file (NautilusFile *file,
|
||||
GtkWindow *parent_window,
|
||||
NautilusApplicationChoiceCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
ChooseApplicationCallbackData *choose_data;
|
||||
NautilusFileAttributes attributes;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_FILE (file));
|
||||
g_return_if_fail (parent_window == NULL || GTK_IS_WINDOW (parent_window));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
/* Grab refs to the objects so they will still be around at
|
||||
* callback time.
|
||||
*/
|
||||
nautilus_file_ref (file);
|
||||
if (parent_window != NULL) {
|
||||
g_object_ref (parent_window);
|
||||
}
|
||||
|
||||
/* Create data to pass through. */
|
||||
choose_data = g_new (ChooseApplicationCallbackData, 1);
|
||||
choose_data->file = file;
|
||||
choose_data->parent_window = parent_window;
|
||||
choose_data->callback = callback;
|
||||
choose_data->callback_data = callback_data;
|
||||
|
||||
/* Put pending entry into choose hash table. */
|
||||
if (choose_application_hash_table == NULL) {
|
||||
choose_application_hash_table = eel_g_hash_table_new_free_at_exit
|
||||
(choose_application_hash,
|
||||
choose_application_equal,
|
||||
"choose application");
|
||||
}
|
||||
g_hash_table_insert (choose_application_hash_table,
|
||||
choose_data, choose_data);
|
||||
|
||||
/* Do the rest of the work when the attributes are ready. */
|
||||
attributes = nautilus_mime_actions_get_full_file_attributes ();
|
||||
nautilus_file_call_when_ready (file,
|
||||
attributes,
|
||||
choose_application_callback,
|
||||
choose_data);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
NautilusFile *file;
|
||||
GtkWindow *parent_window;
|
||||
} LaunchParameters;
|
||||
|
||||
static LaunchParameters *
|
||||
launch_parameters_new (NautilusFile *file,
|
||||
GtkWindow *parent_window)
|
||||
{
|
||||
LaunchParameters *launch_parameters;
|
||||
|
||||
launch_parameters = g_new0 (LaunchParameters, 1);
|
||||
nautilus_file_ref (file);
|
||||
launch_parameters->file = file;
|
||||
g_object_ref (parent_window);
|
||||
launch_parameters->parent_window = parent_window;
|
||||
|
||||
return launch_parameters;
|
||||
}
|
||||
|
||||
static void
|
||||
launch_parameters_free (LaunchParameters *launch_parameters)
|
||||
{
|
||||
g_assert (launch_parameters != NULL);
|
||||
|
||||
nautilus_file_unref (launch_parameters->file);
|
||||
g_object_unref (launch_parameters->parent_window);
|
||||
|
||||
g_free (launch_parameters);
|
||||
}
|
||||
|
||||
static void
|
||||
launch_application_callback (GnomeVFSMimeApplication *application,
|
||||
gpointer callback_data)
|
||||
{
|
||||
LaunchParameters *launch_parameters;
|
||||
|
||||
g_assert (callback_data != NULL);
|
||||
|
||||
launch_parameters = (LaunchParameters *) callback_data;
|
||||
|
||||
if (application != NULL) {
|
||||
g_assert (NAUTILUS_IS_FILE (launch_parameters->file));
|
||||
|
||||
nautilus_launch_application (application,
|
||||
launch_parameters->file,
|
||||
launch_parameters->parent_window);
|
||||
}
|
||||
|
||||
launch_parameters_free (launch_parameters);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* application_cannot_open_location
|
||||
*
|
||||
|
@ -562,6 +122,7 @@ application_cannot_open_location (GnomeVFSMimeApplication *application,
|
|||
const char *uri_scheme,
|
||||
GtkWindow *parent_window)
|
||||
{
|
||||
#if NEW_MIME_COMPLETE
|
||||
GtkDialog *message_dialog;
|
||||
LaunchParameters *launch_parameters;
|
||||
char *prompt;
|
||||
|
@ -625,6 +186,7 @@ application_cannot_open_location (GnomeVFSMimeApplication *application,
|
|||
}
|
||||
|
||||
g_free (file_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||
|
@ -872,8 +434,7 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
GtkWindow *parent_window)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSMimeAction *action;
|
||||
GnomeVFSMimeActionType action_type;
|
||||
GnomeVFSMimeApplication *application;
|
||||
GdkScreen *screen;
|
||||
char **envp;
|
||||
char *uri, *uri_scheme;
|
||||
|
@ -889,6 +450,8 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
startup_notify = FALSE;
|
||||
#endif
|
||||
|
||||
g_return_if_fail (!nautilus_file_needs_slow_mime_type (file));
|
||||
|
||||
uri = NULL;
|
||||
if (nautilus_file_is_nautilus_link (file)) {
|
||||
uri = nautilus_file_get_activation_uri (file);
|
||||
|
@ -898,10 +461,7 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
uri = nautilus_file_get_uri (file);
|
||||
}
|
||||
|
||||
action = nautilus_mime_get_default_action_for_file (file);
|
||||
|
||||
action_type = (action) ? action->action_type :
|
||||
GNOME_VFS_MIME_ACTION_TYPE_NONE;
|
||||
application = nautilus_mime_get_default_application_for_file (file);
|
||||
|
||||
screen = gtk_window_get_screen (parent_window);
|
||||
envp = my_gdk_spawn_make_environment_for_screen (screen, NULL);
|
||||
|
@ -912,10 +472,12 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
sn_error_trap_pop);
|
||||
|
||||
/* Only initiate notification if application supports it. */
|
||||
if (action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) {
|
||||
startup_notify = gnome_vfs_application_registry_get_bool_value (action->action.application->id,
|
||||
if (application) {
|
||||
startup_notify = gnome_vfs_application_registry_get_bool_value (application->id,
|
||||
GNOME_VFS_APPLICATION_REGISTRY_STARTUP_NOTIFY,
|
||||
NULL);
|
||||
} else {
|
||||
startup_notify = FALSE;
|
||||
}
|
||||
|
||||
if (startup_notify == TRUE) {
|
||||
|
@ -954,7 +516,7 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
|
||||
timestamp = slowly_and_stupidly_obtain_timestamp (sn_display);
|
||||
|
||||
binary_name = action->action.application->command;
|
||||
binary_name = application->command;
|
||||
|
||||
sn_launcher_context_set_binary_name (sn_context,
|
||||
binary_name);
|
||||
|
@ -1016,9 +578,11 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
|
||||
case GNOME_VFS_ERROR_NO_DEFAULT:
|
||||
case GNOME_VFS_ERROR_NO_HANDLER:
|
||||
#if NEW_MIME_COMPLETE
|
||||
nautilus_program_chooser_show_no_choices_message
|
||||
(action_type, file, parent_window);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case GNOME_VFS_ERROR_LAUNCH:
|
||||
/* TODO: These strings suck pretty badly, but we're in string-freeze,
|
||||
|
@ -1066,8 +630,11 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
break;
|
||||
case GNOME_VFS_OK:
|
||||
default:
|
||||
#if NEW_MIME_COMPLETE
|
||||
nautilus_program_chooser_show_invalid_message
|
||||
(action_type, file, parent_window);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1082,80 +649,13 @@ void nautilus_launch_show_file (NautilusFile *file,
|
|||
|
||||
g_free (uri_for_display);
|
||||
|
||||
if (action != NULL)
|
||||
gnome_vfs_mime_action_free (action);
|
||||
if (application != NULL)
|
||||
gnome_vfs_mime_application_free (application);
|
||||
|
||||
g_strfreev (envp);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_launch_action:
|
||||
*
|
||||
* Forks off a process to launch the action with a given file
|
||||
* as a parameter. Provide parent window for error dialogs.
|
||||
*
|
||||
* @action: the action to launch
|
||||
* @file: the file whose location should be passed as a parameter.
|
||||
* @parent_window: window to use as parent for error dialogs.
|
||||
*/
|
||||
void nautilus_launch_action (GnomeVFSMimeAction *action,
|
||||
NautilusFile *file,
|
||||
GtkWindow *parent_window)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GnomeVFSResult result;
|
||||
GList uris;
|
||||
char *uri;
|
||||
char **envp;
|
||||
|
||||
switch (action->action_type) {
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION:
|
||||
|
||||
nautilus_launch_application (action->action.application, file, parent_window);
|
||||
|
||||
break;
|
||||
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT:
|
||||
|
||||
uri = NULL;
|
||||
if (nautilus_file_is_nautilus_link (file)) {
|
||||
uri = nautilus_file_get_activation_uri (file);
|
||||
}
|
||||
|
||||
if (uri == NULL) {
|
||||
uri = nautilus_file_get_uri (file);
|
||||
}
|
||||
|
||||
uris.next = NULL;
|
||||
uris.prev = NULL;
|
||||
uris.data = uri;
|
||||
|
||||
screen = gtk_window_get_screen (parent_window);
|
||||
envp = my_gdk_spawn_make_environment_for_screen (screen, NULL);
|
||||
|
||||
result = gnome_vfs_mime_action_launch_with_env (action, &uris, envp);
|
||||
|
||||
switch (result) {
|
||||
case GNOME_VFS_OK:
|
||||
break;
|
||||
|
||||
default:
|
||||
nautilus_program_chooser_show_invalid_message
|
||||
(action->action_type, file, parent_window);
|
||||
}
|
||||
|
||||
g_strfreev (envp);
|
||||
g_free (uri);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
nautilus_program_chooser_show_invalid_message
|
||||
(action->action_type, file, parent_window);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_launch_application:
|
||||
*
|
||||
|
@ -1293,9 +793,11 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
|
|||
break;
|
||||
|
||||
default:
|
||||
#if NEW_MIME_COMPLETE
|
||||
nautilus_program_chooser_show_invalid_message
|
||||
(GNOME_VFS_MIME_ACTION_TYPE_APPLICATION, file, parent_window);
|
||||
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,23 +39,6 @@ typedef void (*NautilusApplicationChoiceCallback) (GnomeVFSMimeApplication *app
|
|||
typedef void (*NautilusComponentChoiceCallback) (NautilusViewIdentifier *identifier,
|
||||
gpointer callback_data);
|
||||
|
||||
void nautilus_choose_application_for_file (NautilusFile *file,
|
||||
GtkWindow *parent_window,
|
||||
NautilusApplicationChoiceCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_cancel_choose_application_for_file (NautilusFile *file,
|
||||
NautilusComponentChoiceCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_choose_component_for_file (NautilusFile *file,
|
||||
GtkWindow *parent_window,
|
||||
NautilusComponentChoiceCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_cancel_choose_component_for_file (NautilusFile *file,
|
||||
NautilusComponentChoiceCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_launch_action (GnomeVFSMimeAction *action,
|
||||
NautilusFile *file,
|
||||
GtkWindow *parent_window);
|
||||
void nautilus_launch_application (GnomeVFSMimeApplication *application,
|
||||
NautilusFile *file,
|
||||
GtkWindow *parent_window);
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <libnautilus-extension/nautilus-property-page-provider.h>
|
||||
#include <libnautilus-private/nautilus-mime-actions.h>
|
||||
#include <libnautilus-private/nautilus-view-identifier.h>
|
||||
#include <libnautilus-private/nautilus-view-query.h>
|
||||
|
||||
typedef struct {
|
||||
char *id;
|
||||
|
@ -340,7 +341,7 @@ fm_bonobo_provider_get_file_items (NautilusMenuProvider *provider,
|
|||
GList *items;
|
||||
GList *l;
|
||||
|
||||
components = nautilus_mime_get_popup_components_for_files (selection);
|
||||
components = nautilus_view_query_get_popup_components_for_files (selection);
|
||||
|
||||
items = NULL;
|
||||
for (l = components; l; l = l->next) {
|
||||
|
@ -511,7 +512,7 @@ fm_bonobo_provider_get_pages (NautilusPropertyPageProvider *provider,
|
|||
GList *pages;
|
||||
|
||||
/* find all the property pages for this file */
|
||||
all_components = nautilus_mime_get_property_components_for_files
|
||||
all_components = nautilus_view_query_get_property_components_for_files
|
||||
(files);
|
||||
|
||||
/* filter out property pages that don't support multiple files */
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <eel/eel-gnome-extensions.h>
|
||||
#include <eel/eel-gtk-extensions.h>
|
||||
#include <eel/eel-gtk-macros.h>
|
||||
#include <eel/eel-open-with-dialog.h>
|
||||
#include <eel/eel-stock-dialogs.h>
|
||||
#include <eel/eel-string.h>
|
||||
#include <eel/eel-vfs-extensions.h>
|
||||
|
@ -154,8 +155,10 @@
|
|||
#define FM_DIRECTORY_VIEW_MENU_PATH_DELETE "/menu/Edit/Dangerous File Items Placeholder/Delete"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_EMPTY_TRASH "/menu/File/Global File Items Placeholder/Empty Trash"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_CREATE_LINK "/menu/Edit/File Items Placeholder/Create Link"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER "/menu/File/Open Placeholder/Open With/Applications Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION "/menu/File/Open Placeholder/Open With/OtherApplication"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/menu/File/Open Placeholder/Open With/Applications Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER "/menu/File/Open Placeholder/Applications Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION_PLACEHOLDER "/menu/File/Open Placeholder/OtherApplicationPlaceholder"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION "/menu/File/Open Placeholder/OtherApplicationPlaceholder/OtherApplication"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER "/menu/File/Open Placeholder/Scripts/Scripts Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_SEPARATOR "/menu/File/Open Placeholder/Scripts/After Scripts"
|
||||
#define FM_DIRECTORY_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER "/menu/File/New Items Placeholder/New Documents/New Documents Placeholder"
|
||||
|
@ -176,7 +179,12 @@
|
|||
#define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_PLACEHOLDER "/popups/background/Before Zoom Items/New Documents/New Documents Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_SEPARATOR "/popups/background/Before Zoom Items/New Documents/After New Documents"
|
||||
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER "/popups/selection/Open Placeholder/Open With/Applications Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/popups/selection/Open Placeholder/Open With/Applications Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER "/popups/selection/Open Placeholder/Applications Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_OPEN_PLACEHOLDER "/popups/selection/Open Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_OTHER_APPLICATION_PLACEHOLDER "/popups/selection/Open Placeholder/OtherApplicationPlaceholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_OTHER_APPLICATION "/popups/selection/Open Placeholder/OtherApplicationPlaceholder/OtherApplication"
|
||||
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER "/popups/selection/Open Placeholder/Scripts/Scripts Placeholder"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_SEPARATOR "/popups/selection/Open Placeholder/Scripts/After Scripts"
|
||||
#define FM_DIRECTORY_VIEW_POPUP_PATH_OPEN_WITH "/popups/selection/Open Placeholder/Open With"
|
||||
|
@ -273,10 +281,14 @@ struct FMDirectoryViewDetails
|
|||
};
|
||||
|
||||
typedef enum {
|
||||
ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE,
|
||||
ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND,
|
||||
ACTIVATION_ACTION_ASK,
|
||||
ACTIVATION_ACTION_LAUNCH,
|
||||
ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
|
||||
ACTIVATION_ACTION_DISPLAY,
|
||||
ACTIVATION_ACTION_DO_NOTHING
|
||||
ACTIVATION_ACTION_OPEN_IN_VIEW,
|
||||
ACTIVATION_ACTION_OPEN_IN_APPLICATION,
|
||||
ACTIVATION_ACTION_DO_NOTHING,
|
||||
} ActivationAction;
|
||||
|
||||
typedef struct {
|
||||
|
@ -396,12 +408,6 @@ typedef struct {
|
|||
FMDirectoryView *directory_view;
|
||||
} ApplicationLaunchParameters;
|
||||
|
||||
typedef struct {
|
||||
NautilusViewIdentifier *identifier;
|
||||
char *uri;
|
||||
FMDirectoryView *directory_view;
|
||||
} ViewerLaunchParameters;
|
||||
|
||||
typedef struct {
|
||||
NautilusFile *file;
|
||||
FMDirectoryView *directory_view;
|
||||
|
@ -439,30 +445,6 @@ application_launch_parameters_free (ApplicationLaunchParameters *parameters)
|
|||
g_free (parameters);
|
||||
}
|
||||
|
||||
static ViewerLaunchParameters *
|
||||
viewer_launch_parameters_new (NautilusViewIdentifier *identifier,
|
||||
const char *uri,
|
||||
FMDirectoryView *directory_view)
|
||||
{
|
||||
ViewerLaunchParameters *result;
|
||||
|
||||
result = g_new0 (ViewerLaunchParameters, 1);
|
||||
result->identifier = nautilus_view_identifier_copy (identifier);
|
||||
g_object_ref (directory_view);
|
||||
result->directory_view = directory_view;
|
||||
result->uri = g_strdup (uri);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
viewer_launch_parameters_free (ViewerLaunchParameters *parameters)
|
||||
{
|
||||
nautilus_view_identifier_free (parameters->identifier);
|
||||
g_object_unref (parameters->directory_view);
|
||||
g_free (parameters->uri);
|
||||
g_free (parameters);
|
||||
}
|
||||
|
||||
static ScriptLaunchParameters *
|
||||
script_launch_parameters_new (NautilusFile *file,
|
||||
|
@ -665,6 +647,7 @@ fm_directory_view_launch_application (GnomeVFSMimeApplication *application,
|
|||
g_free (uri);
|
||||
}
|
||||
|
||||
#if NEW_MIME_COMPLETE
|
||||
static void
|
||||
fm_directory_view_chose_application_callback (GnomeVFSMimeApplication *application,
|
||||
gpointer callback_data)
|
||||
|
@ -685,6 +668,7 @@ fm_directory_view_chose_application_callback (GnomeVFSMimeApplication *applicati
|
|||
|
||||
application_launch_parameters_free (launch_parameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
open_location (FMDirectoryView *directory_view,
|
||||
|
@ -713,98 +697,67 @@ open_location (FMDirectoryView *directory_view,
|
|||
}
|
||||
|
||||
static void
|
||||
switch_location_and_view (NautilusViewIdentifier *identifier,
|
||||
const char *new_uri,
|
||||
FMDirectoryView *directory_view)
|
||||
application_selected_cb (EelOpenWithDialog *dialog,
|
||||
GnomeVFSMimeApplication *app,
|
||||
gpointer user_data)
|
||||
{
|
||||
FMDirectoryView *view;
|
||||
NautilusFile *file;
|
||||
|
||||
g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
|
||||
g_assert (identifier != NULL);
|
||||
g_assert (new_uri != NULL);
|
||||
view = FM_DIRECTORY_VIEW (user_data);
|
||||
|
||||
file = g_object_get_data (G_OBJECT (dialog), "directory-view:file");
|
||||
|
||||
/* User has explicitly chosen a viewer other than the default, so
|
||||
* make it the default and then switch locations.
|
||||
*/
|
||||
/* FIXME bugzilla.gnome.org 41053: We might want an atomic operation
|
||||
* for switching location and viewer together, so we don't have to
|
||||
* rely on metadata for holding the default location.
|
||||
*/
|
||||
file = nautilus_file_get (new_uri);
|
||||
nautilus_mime_set_default_component_for_file (file, identifier->iid);
|
||||
nautilus_file_unref (file);
|
||||
|
||||
open_location (directory_view, new_uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
fm_directory_view_chose_component_callback (NautilusViewIdentifier *identifier,
|
||||
gpointer callback_data)
|
||||
{
|
||||
ViewerLaunchParameters *launch_parameters;
|
||||
|
||||
g_assert (callback_data != NULL);
|
||||
|
||||
launch_parameters = (ViewerLaunchParameters *)callback_data;
|
||||
g_assert (launch_parameters->identifier == NULL);
|
||||
|
||||
if (identifier != NULL) {
|
||||
switch_location_and_view (identifier, /* NOT the (empty) identifier in launch_parameters */
|
||||
launch_parameters->uri,
|
||||
launch_parameters->directory_view);
|
||||
}
|
||||
|
||||
viewer_launch_parameters_free (launch_parameters);
|
||||
fm_directory_view_launch_application (app, file, view);
|
||||
}
|
||||
|
||||
static void
|
||||
choose_program (FMDirectoryView *view,
|
||||
NautilusFile *file,
|
||||
GnomeVFSMimeActionType type)
|
||||
NautilusFile *file)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
char *uri;
|
||||
char *mime_type;
|
||||
|
||||
g_assert (FM_IS_DIRECTORY_VIEW (view));
|
||||
g_assert (NAUTILUS_IS_FILE (file));
|
||||
g_assert (type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT ||
|
||||
type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION);
|
||||
|
||||
nautilus_file_ref (file);
|
||||
uri = nautilus_file_get_uri (file);
|
||||
mime_type = nautilus_file_get_mime_type (file);
|
||||
|
||||
if (type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) {
|
||||
nautilus_choose_component_for_file
|
||||
(file,
|
||||
fm_directory_view_get_containing_window (view),
|
||||
fm_directory_view_chose_component_callback,
|
||||
viewer_launch_parameters_new
|
||||
(NULL, uri, view));
|
||||
} else {
|
||||
nautilus_choose_application_for_file
|
||||
(file,
|
||||
fm_directory_view_get_containing_window (view),
|
||||
fm_directory_view_chose_application_callback,
|
||||
application_launch_parameters_new
|
||||
(NULL, file, view));
|
||||
}
|
||||
dialog = eel_open_with_dialog_new (uri, mime_type);
|
||||
g_object_set_data_full (G_OBJECT (dialog),
|
||||
"directory-view:file",
|
||||
g_object_ref (file),
|
||||
(GDestroyNotify)g_object_unref);
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (dialog),
|
||||
gtk_widget_get_screen (GTK_WIDGET (view)));
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_free (uri);
|
||||
g_signal_connect_object (dialog,
|
||||
"application_selected",
|
||||
G_CALLBACK (application_selected_cb),
|
||||
view,
|
||||
0);
|
||||
|
||||
g_free (uri);
|
||||
g_free (mime_type);
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
|
||||
static void
|
||||
open_with_other_program (FMDirectoryView *view, GnomeVFSMimeActionType action_type)
|
||||
open_with_other_program (FMDirectoryView *view)
|
||||
{
|
||||
GList *selection;
|
||||
|
||||
g_assert (FM_IS_DIRECTORY_VIEW (view));
|
||||
g_assert (action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION ||
|
||||
action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT);
|
||||
|
||||
selection = fm_directory_view_get_selection (view);
|
||||
|
||||
if (selection_contains_one_item_in_menu_callback (view, selection)) {
|
||||
choose_program (view, NAUTILUS_FILE (selection->data), action_type);
|
||||
choose_program (view, NAUTILUS_FILE (selection->data));
|
||||
}
|
||||
|
||||
nautilus_file_list_free (selection);
|
||||
|
@ -815,8 +768,7 @@ other_application_callback (BonoboUIComponent *component, gpointer callback_data
|
|||
{
|
||||
g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
|
||||
|
||||
open_with_other_program (FM_DIRECTORY_VIEW (callback_data),
|
||||
GNOME_VFS_MIME_ACTION_TYPE_APPLICATION);
|
||||
open_with_other_program (FM_DIRECTORY_VIEW (callback_data));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3720,48 +3672,186 @@ static void
|
|||
add_application_to_bonobo_menu (FMDirectoryView *directory_view,
|
||||
GnomeVFSMimeApplication *application,
|
||||
NautilusFile *file,
|
||||
int index)
|
||||
int index,
|
||||
const char *menu_placeholder,
|
||||
const char *popup_placeholder)
|
||||
{
|
||||
ApplicationLaunchParameters *launch_parameters;
|
||||
char *tip;
|
||||
char *label;
|
||||
|
||||
launch_parameters = application_launch_parameters_new
|
||||
(application, file, directory_view);
|
||||
label = g_strdup_printf (_("Open with \"%s\""), application->name);
|
||||
tip = g_strdup_printf (_("Use \"%s\" to open the selected item"), application->name);
|
||||
|
||||
add_numbered_menu_item (directory_view->details->ui,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER,
|
||||
application->name,
|
||||
menu_placeholder,
|
||||
label,
|
||||
tip,
|
||||
index,
|
||||
NULL,
|
||||
bonobo_launch_application_callback,
|
||||
launch_parameters,
|
||||
(GDestroyNotify) application_launch_parameters_free);
|
||||
|
||||
|
||||
/* Use same launch parameters and no DestroyNotify for popup item, which has same
|
||||
* lifetime as the item in the File menu in the menu bar.
|
||||
*/
|
||||
add_numbered_menu_item (directory_view->details->ui,
|
||||
FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER,
|
||||
application->name,
|
||||
popup_placeholder,
|
||||
label,
|
||||
tip,
|
||||
index,
|
||||
NULL,
|
||||
bonobo_launch_application_callback,
|
||||
launch_parameters,
|
||||
NULL);
|
||||
g_free (label);
|
||||
g_free (tip);
|
||||
}
|
||||
|
||||
|
||||
static ActivationAction
|
||||
get_default_executable_text_file_action (void)
|
||||
{
|
||||
int preferences_value;
|
||||
|
||||
preferences_value = eel_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
|
||||
switch (preferences_value) {
|
||||
case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
|
||||
return ACTIVATION_ACTION_LAUNCH;
|
||||
case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
|
||||
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
|
||||
case NAUTILUS_EXECUTABLE_TEXT_ASK:
|
||||
default:
|
||||
return ACTIVATION_ACTION_ASK;
|
||||
}
|
||||
}
|
||||
|
||||
static ActivationAction
|
||||
get_executable_text_file_action (FMDirectoryView *view, NautilusFile *file)
|
||||
{
|
||||
GtkDialog *dialog;
|
||||
char *file_name;
|
||||
char *prompt;
|
||||
char *detail;
|
||||
int preferences_value;
|
||||
int response;
|
||||
|
||||
g_assert (nautilus_file_contains_text (file));
|
||||
|
||||
preferences_value = eel_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
|
||||
switch (preferences_value) {
|
||||
case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
|
||||
return ACTIVATION_ACTION_LAUNCH;
|
||||
case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
|
||||
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
|
||||
case NAUTILUS_EXECUTABLE_TEXT_ASK:
|
||||
break;
|
||||
default:
|
||||
/* Complain non-fatally, since preference data can't be trusted */
|
||||
g_warning ("Unknown value %d for NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION",
|
||||
preferences_value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
file_name = nautilus_file_get_display_name (file);
|
||||
prompt = g_strdup_printf (_("Do you want to run \"%s\", or display its contents?"),
|
||||
file_name);
|
||||
detail = g_strdup_printf (_("\"%s\" is an executable text file."),
|
||||
file_name);
|
||||
g_free (file_name);
|
||||
|
||||
dialog = eel_create_question_dialog (prompt,
|
||||
detail,
|
||||
_("Run or Display?"),
|
||||
_("Run in _Terminal"), RESPONSE_RUN_IN_TERMINAL,
|
||||
_("_Display"), RESPONSE_DISPLAY,
|
||||
fm_directory_view_get_containing_window (view));
|
||||
gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||
gtk_dialog_add_button (dialog, _("_Run"), RESPONSE_RUN);
|
||||
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
|
||||
gtk_widget_show (GTK_WIDGET (dialog));
|
||||
|
||||
g_free (prompt);
|
||||
g_free (detail);
|
||||
|
||||
response = gtk_dialog_run (dialog);
|
||||
gtk_object_destroy (GTK_OBJECT (dialog));
|
||||
|
||||
switch (response) {
|
||||
case RESPONSE_RUN:
|
||||
return ACTIVATION_ACTION_LAUNCH;
|
||||
case RESPONSE_RUN_IN_TERMINAL:
|
||||
return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL;
|
||||
case RESPONSE_DISPLAY:
|
||||
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
|
||||
default:
|
||||
return ACTIVATION_ACTION_DO_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
can_use_component_for_file (NautilusFile *file)
|
||||
{
|
||||
return (nautilus_file_is_directory (file) ||
|
||||
NAUTILUS_IS_DESKTOP_ICON_FILE (file));
|
||||
}
|
||||
|
||||
static ActivationAction
|
||||
get_activation_action (NautilusFile *file)
|
||||
{
|
||||
ActivationAction action;
|
||||
char *activation_uri;
|
||||
|
||||
activation_uri = nautilus_file_get_activation_uri (file);
|
||||
if (activation_uri == NULL) {
|
||||
activation_uri = nautilus_file_get_uri (file);
|
||||
}
|
||||
|
||||
action = ACTIVATION_ACTION_DO_NOTHING;
|
||||
|
||||
if (eel_str_has_prefix (activation_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
|
||||
action = ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE;
|
||||
} else if (eel_str_has_prefix (activation_uri, NAUTILUS_COMMAND_SPECIFIER)) {
|
||||
action = ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND;
|
||||
} else if (file_is_launchable (file)) {
|
||||
char *executable_path;
|
||||
|
||||
action = ACTIVATION_ACTION_LAUNCH;
|
||||
|
||||
executable_path = gnome_vfs_get_local_path_from_uri (activation_uri);
|
||||
if (!executable_path) {
|
||||
action = ACTIVATION_ACTION_DO_NOTHING;
|
||||
} else if (nautilus_file_contains_text (file)) {
|
||||
action = get_default_executable_text_file_action ();
|
||||
}
|
||||
g_free (executable_path);
|
||||
}
|
||||
|
||||
if (action == ACTIVATION_ACTION_DO_NOTHING) {
|
||||
if (can_use_component_for_file (file)) {
|
||||
action = ACTIVATION_ACTION_OPEN_IN_VIEW;
|
||||
} else {
|
||||
action = ACTIVATION_ACTION_OPEN_IN_APPLICATION;
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
static void
|
||||
reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection)
|
||||
{
|
||||
GList *applications, *node;
|
||||
NautilusFile *file;
|
||||
gboolean sensitive;
|
||||
gboolean any_applications;
|
||||
gboolean any_viewers;
|
||||
gboolean submenu_visible;
|
||||
char *uri;
|
||||
int num_applications;
|
||||
int index;
|
||||
|
||||
/* Clear any previous inserted items in the applications and viewers placeholders */
|
||||
|
@ -3769,43 +3859,87 @@ reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection)
|
|||
(view->details->ui, FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER);
|
||||
nautilus_bonobo_remove_menu_items_and_commands
|
||||
(view->details->ui, FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER);
|
||||
nautilus_bonobo_remove_menu_items_and_commands
|
||||
(view->details->ui, FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER);
|
||||
nautilus_bonobo_remove_menu_items_and_commands
|
||||
(view->details->ui, FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER);
|
||||
|
||||
num_applications = 0;
|
||||
|
||||
/* This menu is only displayed when there's one selected item. */
|
||||
if (!eel_g_list_exactly_one_item (selection)) {
|
||||
sensitive = FALSE;
|
||||
} else {
|
||||
sensitive = TRUE;
|
||||
any_applications = FALSE;
|
||||
any_viewers = FALSE;
|
||||
submenu_visible = FALSE;
|
||||
} else {
|
||||
GnomeVFSMimeApplication *default_app;
|
||||
ActivationAction action;
|
||||
|
||||
file = NAUTILUS_FILE (selection->data);
|
||||
|
||||
uri = nautilus_file_get_uri (file);
|
||||
|
||||
|
||||
action = get_activation_action (file);
|
||||
if (action == ACTIVATION_ACTION_OPEN_IN_APPLICATION) {
|
||||
default_app = nautilus_mime_get_default_application_for_file (file);
|
||||
} else {
|
||||
default_app = NULL;
|
||||
}
|
||||
|
||||
applications = nautilus_mime_get_open_with_applications_for_file (NAUTILUS_FILE (selection->data));
|
||||
|
||||
num_applications = g_list_length (applications);
|
||||
|
||||
|
||||
|
||||
for (node = applications, index = 0; node != NULL; node = node->next, index++) {
|
||||
any_applications = TRUE;
|
||||
add_application_to_bonobo_menu (view, node->data, file, index);
|
||||
GnomeVFSMimeApplication *application;
|
||||
char *menu_path;
|
||||
char *popup_path;
|
||||
|
||||
application = node->data;
|
||||
|
||||
if (default_app && !strcmp (default_app->id, application->id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (num_applications > 3) {
|
||||
menu_path = FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER;
|
||||
popup_path = FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER;
|
||||
} else {
|
||||
menu_path = FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER;
|
||||
popup_path = FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
add_application_to_bonobo_menu (view,
|
||||
node->data,
|
||||
file,
|
||||
index,
|
||||
menu_path,popup_path);
|
||||
}
|
||||
gnome_vfs_mime_application_list_free (applications);
|
||||
nautilus_bonobo_set_label
|
||||
(view->details->ui,
|
||||
FM_DIRECTORY_VIEW_COMMAND_OTHER_APPLICATION,
|
||||
any_applications ? _("Other _Application...") : _("An _Application..."));
|
||||
|
||||
|
||||
g_free (uri);
|
||||
|
||||
submenu_visible = (num_applications > 3);
|
||||
}
|
||||
|
||||
/* It's OK to set the sensitivity of the menu items (rather than the verbs)
|
||||
/* It's OK to set the visibility of the menu items (rather than the verbs)
|
||||
* here because these are submenu titles, not items with verbs.
|
||||
*/
|
||||
nautilus_bonobo_set_sensitive (view->details->ui,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH,
|
||||
sensitive);
|
||||
nautilus_bonobo_set_sensitive (view->details->ui,
|
||||
FM_DIRECTORY_VIEW_POPUP_PATH_OPEN_WITH,
|
||||
sensitive);
|
||||
nautilus_bonobo_set_hidden (view->details->ui,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH,
|
||||
!submenu_visible);
|
||||
nautilus_bonobo_set_hidden (view->details->ui,
|
||||
FM_DIRECTORY_VIEW_POPUP_PATH_OPEN_WITH,
|
||||
!submenu_visible);
|
||||
|
||||
|
||||
nautilus_bonobo_set_hidden (view->details->ui,
|
||||
FM_DIRECTORY_VIEW_POPUP_PATH_OTHER_APPLICATION_PLACEHOLDER,
|
||||
submenu_visible);
|
||||
|
||||
nautilus_bonobo_set_hidden (view->details->ui,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION_PLACEHOLDER,
|
||||
submenu_visible);
|
||||
}
|
||||
|
||||
static GList *
|
||||
|
@ -5727,6 +5861,8 @@ real_update_menus (FMDirectoryView *view)
|
|||
gboolean show_separate_delete_command;
|
||||
gboolean vfolder_directory;
|
||||
gboolean show_open_alternate;
|
||||
gboolean can_open;
|
||||
ActivationAction action;
|
||||
EelBackground *background;
|
||||
|
||||
if (view->details->ui == NULL) {
|
||||
|
@ -5766,6 +5902,39 @@ real_update_menus (FMDirectoryView *view)
|
|||
FM_DIRECTORY_VIEW_COMMAND_OPEN,
|
||||
selection_count != 0);
|
||||
|
||||
label_with_underscore = NULL;
|
||||
can_open = TRUE;
|
||||
if (selection_count == 1) {
|
||||
NautilusFile *file;
|
||||
|
||||
file = NAUTILUS_FILE (selection->data);
|
||||
|
||||
action = get_activation_action (file);
|
||||
|
||||
if (action == ACTIVATION_ACTION_OPEN_IN_APPLICATION) {
|
||||
GnomeVFSMimeApplication *app;
|
||||
|
||||
app = nautilus_mime_get_default_application_for_file (file);
|
||||
if (app) {
|
||||
label_with_underscore = g_strdup_printf (_("_Open with \"%s\""),
|
||||
app->name);
|
||||
gnome_vfs_mime_application_free (app);
|
||||
} else {
|
||||
can_open = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nautilus_bonobo_set_label
|
||||
(view->details->ui,
|
||||
FM_DIRECTORY_VIEW_COMMAND_OPEN,
|
||||
label_with_underscore ? label_with_underscore : _("_Open"));
|
||||
nautilus_bonobo_set_hidden
|
||||
(view->details->ui,
|
||||
FM_DIRECTORY_VIEW_COMMAND_OPEN,
|
||||
!can_open);
|
||||
g_free (label_with_underscore);
|
||||
|
||||
if (nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_NAVIGATION) {
|
||||
show_open_alternate = TRUE;
|
||||
label_with_underscore = g_strdup_printf (ngettext("Open in New Window",
|
||||
|
@ -6100,6 +6269,12 @@ fm_directory_view_notify_selection_changed (FMDirectoryView *view)
|
|||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
nautilus_file_call_when_ready
|
||||
(file,
|
||||
NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
nautilus_file_list_free (selection);
|
||||
}
|
||||
|
@ -6118,7 +6293,8 @@ file_is_launchable (NautilusFile *file)
|
|||
return type_can_be_executable
|
||||
&& nautilus_file_can_get_permissions (file)
|
||||
&& nautilus_file_can_execute (file)
|
||||
&& nautilus_file_is_executable (file);
|
||||
&& nautilus_file_is_executable (file)
|
||||
&& !nautilus_file_is_directory (file);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6171,80 +6347,6 @@ report_broken_symbolic_link (FMDirectoryView *view, NautilusFile *file)
|
|||
g_free (detail);
|
||||
}
|
||||
|
||||
static ActivationAction
|
||||
get_executable_text_file_action (FMDirectoryView *view, NautilusFile *file)
|
||||
{
|
||||
GtkDialog *dialog;
|
||||
char *file_name;
|
||||
char *prompt;
|
||||
char *detail;
|
||||
int preferences_value;
|
||||
int response;
|
||||
|
||||
g_assert (nautilus_file_contains_text (file));
|
||||
|
||||
preferences_value = eel_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
|
||||
switch (preferences_value) {
|
||||
case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
|
||||
return ACTIVATION_ACTION_LAUNCH;
|
||||
case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
|
||||
return ACTIVATION_ACTION_DISPLAY;
|
||||
case NAUTILUS_EXECUTABLE_TEXT_ASK:
|
||||
break;
|
||||
default:
|
||||
/* Complain non-fatally, since preference data can't be trusted */
|
||||
g_warning ("Unknown value %d for NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION",
|
||||
preferences_value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
file_name = nautilus_file_get_display_name (file);
|
||||
prompt = g_strdup_printf (_("Do you want to run \"%s\", or display its contents?"),
|
||||
file_name);
|
||||
detail = g_strdup_printf (_("\"%s\" is an executable text file."),
|
||||
file_name);
|
||||
g_free (file_name);
|
||||
|
||||
dialog = eel_create_question_dialog (prompt,
|
||||
detail,
|
||||
_("Run or Display?"),
|
||||
_("Run in _Terminal"), RESPONSE_RUN_IN_TERMINAL,
|
||||
_("_Display"), RESPONSE_DISPLAY,
|
||||
fm_directory_view_get_containing_window (view));
|
||||
gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||
gtk_dialog_add_button (dialog, _("_Run"), RESPONSE_RUN);
|
||||
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
|
||||
gtk_widget_show (GTK_WIDGET (dialog));
|
||||
|
||||
g_free (prompt);
|
||||
g_free (detail);
|
||||
|
||||
response = gtk_dialog_run (dialog);
|
||||
gtk_object_destroy (GTK_OBJECT (dialog));
|
||||
|
||||
switch (response) {
|
||||
case RESPONSE_RUN:
|
||||
return ACTIVATION_ACTION_LAUNCH;
|
||||
case RESPONSE_RUN_IN_TERMINAL:
|
||||
return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL;
|
||||
case RESPONSE_DISPLAY:
|
||||
return ACTIVATION_ACTION_DISPLAY;
|
||||
default:
|
||||
return ACTIVATION_ACTION_DO_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
can_use_component_for_file (FMDirectoryView *view,
|
||||
NautilusFile *file)
|
||||
{
|
||||
return (nautilus_file_is_directory (file) ||
|
||||
NAUTILUS_IS_DESKTOP_ICON_FILE (file) ||
|
||||
nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_NAVIGATION);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_weak_notify (gpointer user_data,
|
||||
GObject *object)
|
||||
|
@ -6262,6 +6364,7 @@ stop_activate (ActivateParameters *parameters)
|
|||
parameters);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
activate_callback (NautilusFile *file, gpointer callback_data)
|
||||
{
|
||||
|
@ -6270,7 +6373,6 @@ activate_callback (NautilusFile *file, gpointer callback_data)
|
|||
char *orig_uri, *uri, *file_uri;
|
||||
char *executable_path, *quoted_path, *name;
|
||||
char *old_working_dir;
|
||||
GnomeVFSMimeActionType action_type;
|
||||
ActivationAction action;
|
||||
GdkScreen *screen;
|
||||
|
||||
|
@ -6289,82 +6391,73 @@ activate_callback (NautilusFile *file, gpointer callback_data)
|
|||
|
||||
orig_uri = uri = nautilus_file_get_activation_uri (file);
|
||||
|
||||
action = ACTIVATION_ACTION_DISPLAY;
|
||||
action = get_activation_action (file);
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (view));
|
||||
|
||||
if (eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
|
||||
if (action == ACTIVATION_ACTION_ASK) {
|
||||
/* Special case for executable text files, since it might be
|
||||
* dangerous & unexpected to launch these.
|
||||
*/
|
||||
action = get_executable_text_file_action (view, file);
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE :
|
||||
file_uri = nautilus_file_get_uri (file);
|
||||
nautilus_launch_desktop_file (
|
||||
screen, file_uri, NULL,
|
||||
fm_directory_view_get_containing_window (view));
|
||||
g_free (file_uri);
|
||||
action = ACTIVATION_ACTION_DO_NOTHING;
|
||||
} else if (eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
|
||||
break;
|
||||
case ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND :
|
||||
uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
|
||||
nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
|
||||
action = ACTIVATION_ACTION_DO_NOTHING;
|
||||
}
|
||||
|
||||
if (action != ACTIVATION_ACTION_DO_NOTHING && file_is_launchable (file)) {
|
||||
|
||||
break;
|
||||
case ACTIVATION_ACTION_LAUNCH :
|
||||
case ACTIVATION_ACTION_LAUNCH_IN_TERMINAL :
|
||||
old_working_dir = change_to_view_directory (view);
|
||||
|
||||
/* Launch executables to activate them. */
|
||||
action = ACTIVATION_ACTION_LAUNCH;
|
||||
|
||||
executable_path = gnome_vfs_get_local_path_from_uri (uri);
|
||||
|
||||
/* Non-local executables don't get launched. They act like non-executables. */
|
||||
if (executable_path == NULL) {
|
||||
action = ACTIVATION_ACTION_DISPLAY;
|
||||
} else if (nautilus_file_contains_text (file)) {
|
||||
/* Special case for executable text files, since it might be
|
||||
* dangerous & unexpected to launch these.
|
||||
*/
|
||||
action = get_executable_text_file_action (view, file);
|
||||
}
|
||||
|
||||
if (action == ACTIVATION_ACTION_LAUNCH ||
|
||||
action == ACTIVATION_ACTION_LAUNCH_IN_TERMINAL) {
|
||||
quoted_path = g_shell_quote (executable_path);
|
||||
name = nautilus_file_get_name (file);
|
||||
nautilus_launch_application_from_command
|
||||
(screen, name, quoted_path, NULL,
|
||||
(action == ACTIVATION_ACTION_LAUNCH_IN_TERMINAL) /* use terminal */ );
|
||||
g_free (name);
|
||||
g_free (quoted_path);
|
||||
}
|
||||
quoted_path = g_shell_quote (executable_path);
|
||||
name = nautilus_file_get_name (file);
|
||||
nautilus_launch_application_from_command
|
||||
(screen, name, quoted_path, NULL,
|
||||
(action == ACTIVATION_ACTION_LAUNCH_IN_TERMINAL) /* use terminal */ );
|
||||
g_free (name);
|
||||
g_free (quoted_path);
|
||||
|
||||
chdir (old_working_dir);
|
||||
g_free (old_working_dir);
|
||||
g_free (executable_path);
|
||||
}
|
||||
|
||||
if (action == ACTIVATION_ACTION_DISPLAY) {
|
||||
action_type = nautilus_mime_get_default_action_type_for_file (file);
|
||||
if (action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT &&
|
||||
nautilus_mime_has_any_components_for_file (file) &&
|
||||
can_use_component_for_file (view, file)) {
|
||||
open_location (view, uri, parameters->mode, parameters->flags);
|
||||
} else {
|
||||
nautilus_launch_show_file
|
||||
(file, fm_directory_view_get_containing_window (view));
|
||||
|
||||
if ((parameters->flags & Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND) != 0) {
|
||||
if (nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_SPATIAL) {
|
||||
nautilus_view_close_window (view->details->nautilus_view);
|
||||
}
|
||||
}
|
||||
|
||||
/* We should not add trash and directory uris.*/
|
||||
if ((!nautilus_file_is_in_trash (file)) &&
|
||||
(!nautilus_file_is_directory (file))) {
|
||||
file_uri = nautilus_file_get_uri (file);
|
||||
egg_recent_model_add (nautilus_recent_get_model (), file_uri);
|
||||
g_free (file_uri);
|
||||
|
||||
break;
|
||||
case ACTIVATION_ACTION_OPEN_IN_VIEW :
|
||||
open_location (view, uri, parameters->mode, parameters->flags);
|
||||
break;
|
||||
case ACTIVATION_ACTION_OPEN_IN_APPLICATION :
|
||||
nautilus_launch_show_file
|
||||
(file, fm_directory_view_get_containing_window (view));
|
||||
|
||||
if ((parameters->flags & Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND) != 0) {
|
||||
if (nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_SPATIAL) {
|
||||
nautilus_view_close_window (view->details->nautilus_view);
|
||||
}
|
||||
}
|
||||
|
||||
/* We should not add trash and directory uris.*/
|
||||
if ((!nautilus_file_is_in_trash (file)) &&
|
||||
(!nautilus_file_is_directory (file))) {
|
||||
file_uri = nautilus_file_get_uri (file);
|
||||
egg_recent_model_add (nautilus_recent_get_model (), file_uri);
|
||||
g_free (file_uri);
|
||||
}
|
||||
break;
|
||||
case ACTIVATION_ACTION_DO_NOTHING :
|
||||
break;
|
||||
case ACTIVATION_ACTION_ASK :
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
nautilus_file_unref (file);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <eel/eel-gnome-extensions.h>
|
||||
#include <eel/eel-gtk-extensions.h>
|
||||
#include <eel/eel-labeled-image.h>
|
||||
#include <eel/eel-mime-application-chooser.h>
|
||||
#include <eel/eel-stock-dialogs.h>
|
||||
#include <eel/eel-string.h>
|
||||
#include <eel/eel-vfs-extensions.h>
|
||||
|
@ -3264,6 +3265,33 @@ file_changed_callback (NautilusFile *file, gpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
should_show_open_with (FMPropertiesWindow *window)
|
||||
{
|
||||
return !is_multi_file_window (window);
|
||||
}
|
||||
|
||||
static void
|
||||
create_open_with_page (FMPropertiesWindow *window)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
char *uri;
|
||||
char *mime_type;
|
||||
|
||||
uri = nautilus_file_get_uri (get_target_file (window));
|
||||
mime_type = nautilus_file_get_mime_type (get_target_file (window));
|
||||
|
||||
vbox = eel_mime_application_chooser_new (uri, mime_type);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
g_free (uri);
|
||||
g_free (mime_type);
|
||||
|
||||
gtk_notebook_append_page (window->details->notebook,
|
||||
vbox, gtk_label_new (_("Open With")));
|
||||
}
|
||||
|
||||
|
||||
static FMPropertiesWindow *
|
||||
create_properties_window (StartupData *startup_data)
|
||||
{
|
||||
|
@ -3362,6 +3390,10 @@ create_properties_window (StartupData *startup_data)
|
|||
create_permissions_page (window);
|
||||
}
|
||||
|
||||
if (should_show_open_with (window)) {
|
||||
create_open_with_page (window);
|
||||
}
|
||||
|
||||
/* append pages from available views */
|
||||
append_extension_pages (window);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
_label="_Open Scripts Folder"
|
||||
_tip="Show the folder containing the scripts that appear in this menu"/>
|
||||
<cmd name="OtherApplication"
|
||||
_label="Other _Application..."
|
||||
_label="Open with Other _Application..."
|
||||
_tip="Choose another application with which to open the selected item"/>
|
||||
<cmd name="Show Hidden Files"
|
||||
_label="Show _Hidden Files"
|
||||
|
@ -130,13 +130,19 @@
|
|||
<menuitem name="OpenAlternate"
|
||||
accel="*Control**Shift*o"
|
||||
verb="OpenAlternate"/>
|
||||
<placeholder name="Applications Placeholder" delimit="top"/>
|
||||
<submenu name="Open With"
|
||||
_label="Open Wit_h"
|
||||
_tip="Choose a program with which to open the selected item">
|
||||
<placeholder name="Applications Placeholder" delimit="none"/>
|
||||
<separator/>
|
||||
<menuitem name="OtherApplication"
|
||||
verb="OtherApplication"/>
|
||||
</submenu>
|
||||
<placeholder name="OtherApplicationPlaceholder">
|
||||
<menuitem name="OtherApplication"
|
||||
verb="OtherApplication"/>
|
||||
</placeholder>
|
||||
<menuitem name="Edit Launcher"
|
||||
verb="Edit Launcher"/>
|
||||
<submenu name="Scripts"
|
||||
|
@ -267,13 +273,19 @@
|
|||
verb="Open"/>
|
||||
<menuitem name="OpenAlternate"
|
||||
verb="OpenAlternate"/>
|
||||
<placeholder name="Applications Placeholder" delimit="top"/>
|
||||
<submenu name="Open With"
|
||||
_label="Open Wit_h"
|
||||
tearoff="0"
|
||||
_tip="Choose a program with which to open the selected item">
|
||||
<placeholder name="Applications Placeholder" delimit="none"/>
|
||||
<separator/>
|
||||
<menuitem name="OtherApplication" verb="OtherApplication"/>
|
||||
</submenu>
|
||||
<placeholder name="OtherApplicationPlaceholder">
|
||||
<menuitem name="OtherApplication"
|
||||
verb="OtherApplication"/>
|
||||
</placeholder>
|
||||
<menuitem name="Edit Launcher"
|
||||
verb="Edit Launcher"/>
|
||||
<submenu name="Scripts"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <libgnomevfs/gnome-vfs-result.h>
|
||||
#include <libnautilus-private/nautilus-file.h>
|
||||
#include <libnautilus-private/nautilus-mime-actions.h>
|
||||
#include <libnautilus-private/nautilus-view-query.h>
|
||||
#include <libnautilus-private/nautilus-view-identifier.h>
|
||||
|
||||
struct NautilusDetermineViewHandle {
|
||||
|
@ -111,9 +112,9 @@ got_file_info_callback (NautilusFile *file,
|
|||
|| vfs_result_code == GNOME_VFS_ERROR_NOT_SUPPORTED
|
||||
|| vfs_result_code == GNOME_VFS_ERROR_INVALID_URI) {
|
||||
if (handle->fallback) {
|
||||
default_component = nautilus_mime_get_default_fallback_component_for_file (handle->file);
|
||||
default_component = nautilus_view_query_get_fallback_component_for_file (handle->file);
|
||||
} else {
|
||||
default_component = nautilus_mime_get_default_component_for_file (handle->file);
|
||||
default_component = nautilus_view_query_get_default_component_for_file (handle->file);
|
||||
}
|
||||
if (default_component != NULL) {
|
||||
default_id = nautilus_view_identifier_new_from_content_view (default_component);
|
||||
|
@ -126,7 +127,7 @@ got_file_info_callback (NautilusFile *file,
|
|||
|
||||
if (vfs_result_code == GNOME_VFS_OK && default_id == NULL) {
|
||||
/* If the complete list is non-empty, the default shouldn't have been NULL */
|
||||
g_assert (!nautilus_mime_has_any_components_for_file (handle->file));
|
||||
g_assert (!nautilus_view_query_has_any_components_for_file (handle->file));
|
||||
result_code = NAUTILUS_DETERMINE_VIEW_NO_HANDLER_FOR_TYPE;
|
||||
} else {
|
||||
result_code = get_view_result_from_gnome_vfs_result (vfs_result_code);
|
||||
|
|
|
@ -831,6 +831,7 @@ metadata_button_callback (GtkWidget *button, const char *command_str)
|
|||
information_panel = NAUTILUS_INFORMATION_PANEL (g_object_get_data (G_OBJECT (button), "user_data"));
|
||||
}
|
||||
|
||||
#if NEW_MIME_COMPLETE
|
||||
static void
|
||||
nautilus_information_panel_chose_application_callback (GnomeVFSMimeApplication *application,
|
||||
gpointer callback_data)
|
||||
|
@ -846,10 +847,12 @@ nautilus_information_panel_chose_application_callback (GnomeVFSMimeApplication *
|
|||
nautilus_information_panel_get_window (information_panel));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
open_with_callback (GtkWidget *button, gpointer ignored)
|
||||
{
|
||||
#if NEW_MIME_COMPLETE
|
||||
NautilusInformationPanel *information_panel;
|
||||
|
||||
information_panel = NAUTILUS_INFORMATION_PANEL (g_object_get_data (G_OBJECT (button), "user_data"));
|
||||
|
@ -861,6 +864,7 @@ open_with_callback (GtkWidget *button, gpointer ignored)
|
|||
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (information_panel))),
|
||||
nautilus_information_panel_chose_application_callback,
|
||||
information_panel);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* utility routine that allocates the command buttons from the command list */
|
||||
|
@ -1069,7 +1073,7 @@ nautilus_information_panel_update_buttons (NautilusInformationPanel *information
|
|||
|
||||
if (nautilus_mime_has_any_applications_for_file (information_panel->details->file)) {
|
||||
short_application_list =
|
||||
nautilus_mime_get_short_list_applications_for_file (information_panel->details->file);
|
||||
nautilus_mime_get_applications_for_file (information_panel->details->file);
|
||||
add_command_buttons (information_panel, short_application_list);
|
||||
gnome_vfs_mime_application_list_free (short_application_list);
|
||||
}
|
||||
|
|
|
@ -619,41 +619,6 @@ create_view_as_menu_item (NautilusWindow *window,
|
|||
return menu_item;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
new_gtk_separator (void)
|
||||
{
|
||||
GtkWidget *result;
|
||||
|
||||
result = gtk_menu_item_new ();
|
||||
gtk_widget_show (result);
|
||||
gtk_widget_set_sensitive (result, FALSE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
view_as_menu_choose_view_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
NautilusWindow *window;
|
||||
|
||||
g_assert (GTK_IS_MENU_ITEM (widget));
|
||||
g_assert (NAUTILUS_IS_WINDOW (data));
|
||||
|
||||
window = NAUTILUS_WINDOW (data);
|
||||
|
||||
/* Set the option menu back to its previous setting (Don't
|
||||
* leave it on this dialog-producing "View as..."
|
||||
* setting). If the menu choice causes a content view change,
|
||||
* this will be updated again later, in
|
||||
* nautilus_window_load_view_as_menus. Do this right away so
|
||||
* the user never sees the option menu set to "View as
|
||||
* Other...".
|
||||
*/
|
||||
load_view_as_menu (window);
|
||||
|
||||
nautilus_window_show_view_as_dialog (window);
|
||||
}
|
||||
|
||||
static void
|
||||
load_view_as_menu (NautilusWindow *window)
|
||||
{
|
||||
|
@ -692,18 +657,6 @@ load_view_as_menu (NautilusWindow *window)
|
|||
selected_index = index;
|
||||
}
|
||||
|
||||
/* Add/Show separator before "View as..." if there are any other viewers in menu. */
|
||||
if (window->details->short_list_viewers != NULL) {
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), new_gtk_separator ());
|
||||
}
|
||||
|
||||
/* Add "View as..." extra bonus choice. */
|
||||
menu_item = gtk_menu_item_new_with_label (_("View as..."));
|
||||
g_signal_connect_object (menu_item, "activate",
|
||||
G_CALLBACK (view_as_menu_choose_view_callback), window, 0);
|
||||
gtk_widget_show (menu_item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item);
|
||||
|
||||
/* We create and attach a new menu here because adding/removing
|
||||
* items from existing menu screws up the size of the option menu.
|
||||
*/
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
_tip="Show the contents in less detail"/>
|
||||
<cmd name="Zoom Normal" _label="Normal Si_ze"
|
||||
_tip="Show the contents at the normal size"/>
|
||||
<cmd name="View as" _label="View as..."
|
||||
_tip="Choose a view for the current location, or modify the set of views"/>
|
||||
</commands>
|
||||
|
||||
<keybindings>
|
||||
|
@ -166,8 +164,6 @@
|
|||
<placeholder name="Extra Viewer" delimit="top"/>
|
||||
<separator name="Before Short List"/>
|
||||
<placeholder name="Short List"/>
|
||||
<separator name="After Short List"/>
|
||||
<menuitem name="View as" _label="_View as..." verb="View as"/>
|
||||
</placeholder>
|
||||
</submenu>
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include <libnautilus-private/nautilus-monitor.h>
|
||||
#include <libnautilus-private/nautilus-search-uri.h>
|
||||
#include <libnautilus-private/nautilus-theme.h>
|
||||
#include <libnautilus-private/nautilus-view-query.h>
|
||||
|
||||
/* FIXME bugzilla.gnome.org 41243:
|
||||
* We should use inheritance instead of these special cases
|
||||
|
@ -1628,7 +1629,7 @@ nautilus_window_set_content_view (NautilusWindow *window,
|
|||
end_location_change (window);
|
||||
|
||||
file = nautilus_file_get (window->details->location);
|
||||
nautilus_mime_set_default_component_for_file
|
||||
nautilus_view_query_set_default_component_for_file
|
||||
(file, id->iid);
|
||||
nautilus_file_unref (file);
|
||||
|
||||
|
|
|
@ -474,14 +474,6 @@ view_menu_zoom_normal_callback (BonoboUIComponent *component,
|
|||
nautilus_window_zoom_to_level (NAUTILUS_WINDOW (user_data), 1.0);
|
||||
}
|
||||
|
||||
static void
|
||||
view_menu_view_as_callback (BonoboUIComponent *component,
|
||||
gpointer user_data,
|
||||
const char *verb)
|
||||
{
|
||||
nautilus_window_show_view_as_dialog (NAUTILUS_WINDOW (user_data));
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_respond_callback (GtkDialog *dialog,
|
||||
gint response_id)
|
||||
|
@ -676,7 +668,6 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
|
|||
BONOBO_UI_VERB ("Zoom In", view_menu_zoom_in_callback),
|
||||
BONOBO_UI_VERB ("Zoom Out", view_menu_zoom_out_callback),
|
||||
BONOBO_UI_VERB ("Zoom Normal", view_menu_zoom_normal_callback),
|
||||
BONOBO_UI_VERB ("View as", view_menu_view_as_callback),
|
||||
|
||||
#ifdef ENABLE_PROFILER
|
||||
BONOBO_UI_VERB ("Start Profiling", nautilus_profiler_bonobo_ui_start_callback),
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
#include <libnautilus-private/nautilus-mime-actions.h>
|
||||
#include <libnautilus-private/nautilus-program-choosing.h>
|
||||
#include <libnautilus-private/nautilus-sidebar-functions.h>
|
||||
#include <libnautilus-private/nautilus-view-query.h>
|
||||
#include <libnautilus/nautilus-bonobo-ui.h>
|
||||
#include <libnautilus/nautilus-clipboard.h>
|
||||
#include <libnautilus/nautilus-undo.h>
|
||||
|
@ -996,55 +997,13 @@ nautilus_window_synch_view_as_menus (NautilusWindow *window)
|
|||
g_free (verb_name);
|
||||
}
|
||||
|
||||
static void
|
||||
chose_component_callback (NautilusViewIdentifier *identifier, gpointer callback_data)
|
||||
{
|
||||
NautilusWindow *window;
|
||||
|
||||
window = NAUTILUS_WINDOW (callback_data);
|
||||
if (identifier != NULL) {
|
||||
nautilus_window_set_content_view (window, identifier);
|
||||
}
|
||||
|
||||
/* FIXME bugzilla.gnome.org 41334: There should be some global
|
||||
* way to signal that the file type associations have changed,
|
||||
* so that the places that display these lists can react. For
|
||||
* now, hardwire this case, which is the most obvious one by
|
||||
* far.
|
||||
*/
|
||||
nautilus_window_load_view_as_menus (window);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_chose_component_callback (NautilusWindow *window)
|
||||
{
|
||||
if (window->details->viewed_file != NULL) {
|
||||
nautilus_cancel_choose_component_for_file (window->details->viewed_file,
|
||||
chose_component_callback,
|
||||
window);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_window_show_view_as_dialog (NautilusWindow *window)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
|
||||
|
||||
/* Call back when the user chose the component. */
|
||||
cancel_chose_component_callback (window);
|
||||
nautilus_choose_component_for_file (window->details->viewed_file,
|
||||
GTK_WINDOW (window),
|
||||
chose_component_callback,
|
||||
window);
|
||||
}
|
||||
|
||||
static void
|
||||
refresh_stored_viewers (NautilusWindow *window)
|
||||
{
|
||||
GList *components, *node, *viewers;
|
||||
NautilusViewIdentifier *identifier;
|
||||
|
||||
components = nautilus_mime_get_short_list_components_for_file (window->details->viewed_file);
|
||||
components = nautilus_view_query_get_components_for_file (window->details->viewed_file);
|
||||
viewers = NULL;
|
||||
for (node = components; node != NULL; node = node->next) {
|
||||
identifier = nautilus_view_identifier_new_from_content_view (node->data);
|
||||
|
@ -1399,7 +1358,6 @@ nautilus_window_set_viewed_file (NautilusWindow *window,
|
|||
nautilus_file_ref (file);
|
||||
|
||||
cancel_view_as_callback (window);
|
||||
cancel_chose_component_callback (window);
|
||||
|
||||
if (window->details->viewed_file != NULL) {
|
||||
if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
|
||||
|
|
|
@ -15,13 +15,9 @@ LDADD =\
|
|||
$(NULL)
|
||||
|
||||
noinst_PROGRAMS =\
|
||||
test-nautilus-mime-actions \
|
||||
test-nautilus-mime-actions-set \
|
||||
test-nautilus-wrap-table \
|
||||
$(NULL)
|
||||
|
||||
test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c test.c
|
||||
test_nautilus_mime_actions_set_SOURCES = test-nautilus-mime-actions-set.c test.c
|
||||
test_nautilus_wrap_table_SOURCES = test-nautilus-wrap-table.c test.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
|
|
@ -76,48 +76,6 @@ print_application (GnomeVFSMimeApplication *application)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_component (Bonobo_ServerInfo *component)
|
||||
{
|
||||
if (component == NULL) {
|
||||
puts ("(none)");
|
||||
} else {
|
||||
printf ("iid: %s\n", component->iid);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_action (GnomeVFSMimeAction *action)
|
||||
{
|
||||
if (action == NULL) {
|
||||
puts ("(none)");
|
||||
} else {
|
||||
if (action->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) {
|
||||
puts ("type: application");
|
||||
print_application (action->action.application);
|
||||
} else {
|
||||
puts ("type: component");
|
||||
print_component (action->action.component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_component_list (GList *components)
|
||||
{
|
||||
GList *p;
|
||||
|
||||
if (components == NULL) {
|
||||
puts ("(none)");
|
||||
} else {
|
||||
for (p = components; p != NULL; p = p->next) {
|
||||
print_component (p->data);
|
||||
puts ("------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_application_list (GList *applications)
|
||||
{
|
||||
|
@ -145,12 +103,7 @@ main (int argc, char **argv)
|
|||
{
|
||||
const char *uri;
|
||||
GnomeVFSMimeApplication *default_application;
|
||||
Bonobo_ServerInfo *default_component;
|
||||
GnomeVFSMimeAction *default_action;
|
||||
GList *all_components;
|
||||
GList *all_applications;
|
||||
GList *short_list_components;
|
||||
GList *short_list_applications;
|
||||
NautilusFile *file;
|
||||
NautilusFileAttributes attributes;
|
||||
|
||||
|
@ -172,41 +125,16 @@ main (int argc, char **argv)
|
|||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
default_action = nautilus_mime_get_default_action_for_file (file);
|
||||
puts ("Default Action");
|
||||
print_action (default_action);
|
||||
puts ("");
|
||||
|
||||
default_application = nautilus_mime_get_default_application_for_file (file);
|
||||
puts("Default Application");
|
||||
print_application (default_application);
|
||||
puts ("");
|
||||
|
||||
default_component = nautilus_mime_get_default_component_for_file (file);
|
||||
puts("Default Component");
|
||||
print_component (default_component);
|
||||
puts ("");
|
||||
|
||||
short_list_applications = nautilus_mime_get_short_list_applications_for_file (file);
|
||||
puts("Short List Applications");
|
||||
print_application_list (short_list_applications);
|
||||
puts ("");
|
||||
|
||||
short_list_components = nautilus_mime_get_short_list_components_for_file (file);
|
||||
puts("Short List Components");
|
||||
print_component_list (short_list_components);
|
||||
puts ("");
|
||||
|
||||
all_applications = nautilus_mime_get_all_applications_for_file (file);
|
||||
all_applications = nautilus_mime_get_applications_for_file (file);
|
||||
puts("All Applications");
|
||||
print_application_list (all_applications);
|
||||
puts ("");
|
||||
|
||||
all_components = nautilus_mime_get_all_components_for_file (file);
|
||||
puts("All Components");
|
||||
print_component_list (all_components);
|
||||
puts ("");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue