mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
Adapted much of the open-with and view-as code to use
the new API, whose implementation awaits. This causes us to temporarily lose the command-buttons-in-sidebar feature until the new API's implementation happens. Some of these changes are only partially done; I've got a list of things to finish still. But feel free to bug me about anything in particular that seems bad. * libnautilus-extensions/nautilus-program-chooser.h: * libnautilus-extensions/nautilus-program-chooser.c: (populate_program_list): Use real API to add programs to list in dialog. (nautilus_program_chooser_new): Remember whether this is an application-choosing or component-choosing dialog. (nautilus_program_chooser_get_application), (nautilus_program_chooser_get_component): New functions, get the item in the list that the user selected. * libnautilus-extensions/nautilus-program-choosing.h: Change parameter in NautilusApplicationChoiceCallback from char * to GnomeVFSMimeApplication. * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_choose_application_for_file), (nautilus_choose_component_for_file): Get the chosen item from the dialog instead of returning a hardwired value. * src/file-manager/fm-directory-view.c: (fm_directory_view_chose_application_callback): Take GnomeVFSMimeApplication instead of char *. (add_open_with_gtk_menu_item): Enable menu items now that they work. (launch_application_from_menu_item): New function, callback used when user picks an app from context menu. (view_uri_from_menu_item): New function, callback used when user picks a viewer from context menu. (add_application_to_gtk_menu), (add_component_to_gtk_menu): New functions, set up menu items. (create_open_with_gtk_menu): Use real API to populate open_with context menu items. (bonobo_menu_select_all_callback), (select_all_callback), (fm_directory_view_real_merge_menus): Fixed bug where context menu "Select All" didn't work by separating bonobo and gtk callbacks. * src/nautilus-sidebar.c: (nautilus_index_panel_chose_application_callback), (add_command_buttons), (gnome_vfs_mime_application_list_free), (nautilus_index_panel_update_buttons): Use real API instead of hardwired set of buttons for different MIME types. This currently means you always get only the "Open with ..." button, but the real buttons will reappear once we have our new application-choosing scheme in place.
This commit is contained in:
parent
eab1242a6e
commit
29279c2e93
10 changed files with 561 additions and 199 deletions
54
ChangeLog
54
ChangeLog
|
@ -1,3 +1,57 @@
|
|||
2000-05-30 John Sullivan <sullivan@eazel.com>
|
||||
|
||||
Adapted much of the open-with and view-as code to use
|
||||
the new API, whose implementation awaits. This causes
|
||||
us to temporarily lose the command-buttons-in-sidebar
|
||||
feature until the new API's implementation happens.
|
||||
|
||||
Some of these changes are only partially done; I've
|
||||
got a list of things to finish still. But feel free
|
||||
to bug me about anything in particular that seems bad.
|
||||
|
||||
* libnautilus-extensions/nautilus-program-chooser.h:
|
||||
* libnautilus-extensions/nautilus-program-chooser.c:
|
||||
(populate_program_list): Use real API to add programs
|
||||
to list in dialog.
|
||||
(nautilus_program_chooser_new): Remember whether this
|
||||
is an application-choosing or component-choosing dialog.
|
||||
(nautilus_program_chooser_get_application),
|
||||
(nautilus_program_chooser_get_component): New functions,
|
||||
get the item in the list that the user selected.
|
||||
* libnautilus-extensions/nautilus-program-choosing.h:
|
||||
Change parameter in NautilusApplicationChoiceCallback
|
||||
from char * to GnomeVFSMimeApplication.
|
||||
* libnautilus-extensions/nautilus-program-choosing.c:
|
||||
(nautilus_choose_application_for_file),
|
||||
(nautilus_choose_component_for_file): Get the chosen
|
||||
item from the dialog instead of returning a hardwired
|
||||
value.
|
||||
* src/file-manager/fm-directory-view.c:
|
||||
(fm_directory_view_chose_application_callback): Take
|
||||
GnomeVFSMimeApplication instead of char *.
|
||||
(add_open_with_gtk_menu_item): Enable menu items now
|
||||
that they work.
|
||||
(launch_application_from_menu_item): New function, callback
|
||||
used when user picks an app from context menu.
|
||||
(view_uri_from_menu_item): New function, callback used
|
||||
when user picks a viewer from context menu.
|
||||
(add_application_to_gtk_menu),
|
||||
(add_component_to_gtk_menu): New functions, set up menu items.
|
||||
(create_open_with_gtk_menu): Use real API to populate
|
||||
open_with context menu items.
|
||||
(bonobo_menu_select_all_callback), (select_all_callback),
|
||||
(fm_directory_view_real_merge_menus):
|
||||
Fixed bug where context menu "Select All" didn't work by
|
||||
separating bonobo and gtk callbacks.
|
||||
* src/nautilus-sidebar.c:
|
||||
(nautilus_index_panel_chose_application_callback),
|
||||
(add_command_buttons), (gnome_vfs_mime_application_list_free),
|
||||
(nautilus_index_panel_update_buttons): Use real API instead
|
||||
of hardwired set of buttons for different MIME types. This
|
||||
currently means you always get only the "Open with ..." button,
|
||||
but the real buttons will reappear once we have our new
|
||||
application-choosing scheme in place.
|
||||
|
||||
2000-05-30 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* src/file-manager/fm-icon-view.c: (play_file),
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nautilus-program-chooser.h"
|
||||
|
||||
#include "nautilus-gtk-extensions.h"
|
||||
#include "nautilus-view-identifier.h"
|
||||
|
||||
#include <gtk/gtkradiobutton.h>
|
||||
#include <gtk/gtkclist.h>
|
||||
|
@ -61,31 +62,55 @@ populate_program_list (NautilusProgramChooserType type,
|
|||
NautilusFile *file,
|
||||
GtkCList *clist)
|
||||
{
|
||||
int i;
|
||||
char **text;
|
||||
char *uri;
|
||||
GList *programs, *program;
|
||||
NautilusViewIdentifier *view_identifier;
|
||||
GnomeVFSMimeApplication *application;
|
||||
int new_row;
|
||||
|
||||
g_assert (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS
|
||||
|| type == NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS);
|
||||
|
||||
if (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS) {
|
||||
for (i = 0; i < 10; ++i) {
|
||||
/* One extra slot so it's NULL-terminated */
|
||||
text = g_new0 (char *, PROGRAM_LIST_COLUMN_COUNT+1);
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup_printf ("View as Viewer %d", i+1);
|
||||
gtk_clist_append (clist, text);
|
||||
|
||||
g_strfreev (text);
|
||||
}
|
||||
} else {
|
||||
g_assert (type == NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS);
|
||||
for (i = 0; i < 10; ++i) {
|
||||
/* One extra slot so it's NULL-terminated */
|
||||
text = g_new0 (char *, PROGRAM_LIST_COLUMN_COUNT+1);
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup_printf ("Application %d", i+1);
|
||||
gtk_clist_append (clist, text);
|
||||
|
||||
g_strfreev (text);
|
||||
uri = nautilus_file_get_uri (file);
|
||||
programs = type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS
|
||||
? gnome_vfs_mime_get_all_components_for_uri (uri)
|
||||
: gnome_vfs_mime_get_all_applications_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
|
||||
for (program = programs; program != NULL; program = program->next) {
|
||||
/* One extra slot so it's NULL-terminated */
|
||||
text = g_new0 (char *, PROGRAM_LIST_COLUMN_COUNT+1);
|
||||
|
||||
if (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS) {
|
||||
view_identifier = nautilus_view_identifier_new_from_content_view
|
||||
((OAF_ServerInfo *)program->data);
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup_printf
|
||||
("View as %s", view_identifier->name);
|
||||
/* Free the OAF_ServerInfo now, we're done with it. */
|
||||
CORBA_free (program->data);
|
||||
} else {
|
||||
application = (GnomeVFSMimeApplication *)program->data;
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup (application->name);
|
||||
gnome_vfs_mime_application_free (application);
|
||||
}
|
||||
|
||||
new_row = gtk_clist_append (clist, text);
|
||||
|
||||
if (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS) {
|
||||
gtk_clist_set_row_data_full
|
||||
(clist, new_row, view_identifier, (GtkDestroyNotify)nautilus_view_identifier_free);
|
||||
} else {
|
||||
gtk_clist_set_row_data_full
|
||||
(clist, new_row, application, (GtkDestroyNotify)gnome_vfs_mime_application_free);
|
||||
}
|
||||
|
||||
g_strfreev (text);
|
||||
}
|
||||
|
||||
/* Don't free the data here, just the list shell. The data is freed elsewhere. */
|
||||
g_list_free (programs);
|
||||
}
|
||||
|
||||
static NautilusFile *
|
||||
|
@ -395,6 +420,8 @@ nautilus_program_chooser_new (NautilusProgramChooserType type,
|
|||
NO_DEFAULT_MAGIC_NUMBER,
|
||||
PROGRAM_CHOOSER_DEFAULT_HEIGHT);
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (window), "type", GINT_TO_POINTER (type));
|
||||
|
||||
dialog_vbox = GNOME_DIALOG (window)->vbox;
|
||||
|
||||
/* Prompt at top of dialog. */
|
||||
|
@ -419,6 +446,8 @@ nautilus_program_chooser_new (NautilusProgramChooserType type,
|
|||
gtk_container_add (GTK_CONTAINER (list_scroller), clist);
|
||||
gtk_clist_column_titles_hide (GTK_CLIST (clist));
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (window), "list", clist);
|
||||
|
||||
/* Framed area with selection-specific details */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame);
|
||||
|
@ -471,3 +500,69 @@ nautilus_program_chooser_new (NautilusProgramChooserType type,
|
|||
|
||||
return GNOME_DIALOG (window);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_program_chooser_get_application:
|
||||
*
|
||||
* Get the currently-chosen application in the program-choosing dialog.
|
||||
* Usually used after the dialog has been closed (but not yet destroyed)
|
||||
* to get the user's final choice. The returned value is the actual one
|
||||
* stored in the dialog, and thus cannot be accessed after the dialog
|
||||
* has been destroyed.
|
||||
*
|
||||
* @program_chooser: The result of calling nautilus_program_chooser_new
|
||||
* with type NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS.
|
||||
*
|
||||
* Return value: a GnomeVFSMimeApplication specifying a component. The caller
|
||||
* should make a copy if they want to use it after the dialog has been
|
||||
* destroyed.
|
||||
*/
|
||||
GnomeVFSMimeApplication *
|
||||
nautilus_program_chooser_get_application (GnomeDialog *program_chooser)
|
||||
{
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_val_if_fail (GNOME_IS_DIALOG (program_chooser), NULL);
|
||||
|
||||
g_return_val_if_fail
|
||||
(GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (program_chooser), "type"))
|
||||
== NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS,
|
||||
NULL);
|
||||
|
||||
clist = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (program_chooser), "list"));
|
||||
return (GnomeVFSMimeApplication *)gtk_clist_get_row_data
|
||||
(clist, nautilus_gtk_clist_get_first_selected_row (clist));
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_program_chooser_get_component:
|
||||
*
|
||||
* Get the currently-chosen component in the program-choosing dialog.
|
||||
* Usually used after the dialog has been closed (but not yet destroyed)
|
||||
* to get the user's final choice. The returned value is the actual one
|
||||
* stored in the dialog, and thus cannot be accessed after the dialog
|
||||
* has been destroyed.
|
||||
*
|
||||
* @program_chooser: The result of calling nautilus_program_chooser_new
|
||||
* with type NAUTILUS_PROGRAM_CHOOSER_COMPONENTS.
|
||||
*
|
||||
* Return value: a NautilusViewIdentifier specifying a component. The caller
|
||||
* should make a copy if they want to use it after the dialog has been
|
||||
* destroyed.
|
||||
*/
|
||||
NautilusViewIdentifier *
|
||||
nautilus_program_chooser_get_component (GnomeDialog *program_chooser)
|
||||
{
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_val_if_fail (GNOME_IS_DIALOG (program_chooser), NULL);
|
||||
|
||||
g_return_val_if_fail
|
||||
(GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (program_chooser), "type"))
|
||||
== NAUTILUS_PROGRAM_CHOOSER_COMPONENTS,
|
||||
NULL);
|
||||
|
||||
clist = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (program_chooser), "list"));
|
||||
return (NautilusViewIdentifier *)gtk_clist_get_row_data
|
||||
(clist, nautilus_gtk_clist_get_first_selected_row (clist));
|
||||
}
|
||||
|
|
|
@ -28,14 +28,20 @@
|
|||
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include <libgnomeui/gnome-dialog.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
|
||||
#include "nautilus-file.h"
|
||||
#include "nautilus-view-identifier.h"
|
||||
|
||||
typedef enum {
|
||||
NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS,
|
||||
NAUTILUS_PROGRAM_CHOOSER_COMPONENTS,
|
||||
} NautilusProgramChooserType;
|
||||
|
||||
GnomeDialog *nautilus_program_chooser_new (NautilusProgramChooserType type,
|
||||
NautilusFile *file);
|
||||
GnomeDialog *nautilus_program_chooser_new (NautilusProgramChooserType type,
|
||||
NautilusFile *file);
|
||||
|
||||
GnomeVFSMimeApplication *nautilus_program_chooser_get_application (GnomeDialog *program_chooser);
|
||||
NautilusViewIdentifier *nautilus_program_chooser_get_component (GnomeDialog *program_chooser);
|
||||
|
||||
#endif /* NAUTILUS_PROGRAM_CHOOSER_H */
|
||||
|
|
|
@ -96,19 +96,21 @@ nautilus_choose_component_for_file (NautilusFile *file,
|
|||
(file, NAUTILUS_PROGRAM_CHOOSER_COMPONENTS, parent_window);
|
||||
|
||||
if (gnome_dialog_run (dialog) == GNOME_OK) {
|
||||
/* FIXME: Need to extract result from dialog! */
|
||||
identifier = NULL;
|
||||
identifier = nautilus_program_chooser_get_component (dialog);;
|
||||
} 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);
|
||||
|
||||
/* Destroy only after callback, since view identifier will
|
||||
* be destroyed too.
|
||||
*/
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,8 +130,8 @@ nautilus_choose_application_for_file (NautilusFile *file,
|
|||
NautilusApplicationChoiceCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
char *command_string;
|
||||
GnomeDialog *dialog;
|
||||
GnomeVFSMimeApplication *application;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_FILE (file));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
@ -141,25 +143,21 @@ nautilus_choose_application_for_file (NautilusFile *file,
|
|||
(file, NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS, parent_window);
|
||||
|
||||
if (gnome_dialog_run (dialog) == GNOME_OK) {
|
||||
/* FIXME: Need to extract result from dialog! */
|
||||
#ifdef TESTING_LAUNCH
|
||||
/* FIXME: investigate why passing wrong text here ("gnotepad")
|
||||
* causes an X error.
|
||||
*/
|
||||
command_string = "gnp";
|
||||
#else
|
||||
command_string = NULL;
|
||||
#endif
|
||||
application = nautilus_program_chooser_get_application (dialog);
|
||||
} else {
|
||||
command_string = NULL;
|
||||
application = 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);
|
||||
(* callback) (application, callback_data);
|
||||
|
||||
/* Destroy only after callback, since application struct will
|
||||
* be destroyed too.
|
||||
*/
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nautilus-program-chooser.h"
|
||||
|
||||
#include "nautilus-gtk-extensions.h"
|
||||
#include "nautilus-view-identifier.h"
|
||||
|
||||
#include <gtk/gtkradiobutton.h>
|
||||
#include <gtk/gtkclist.h>
|
||||
|
@ -61,31 +62,55 @@ populate_program_list (NautilusProgramChooserType type,
|
|||
NautilusFile *file,
|
||||
GtkCList *clist)
|
||||
{
|
||||
int i;
|
||||
char **text;
|
||||
char *uri;
|
||||
GList *programs, *program;
|
||||
NautilusViewIdentifier *view_identifier;
|
||||
GnomeVFSMimeApplication *application;
|
||||
int new_row;
|
||||
|
||||
g_assert (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS
|
||||
|| type == NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS);
|
||||
|
||||
if (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS) {
|
||||
for (i = 0; i < 10; ++i) {
|
||||
/* One extra slot so it's NULL-terminated */
|
||||
text = g_new0 (char *, PROGRAM_LIST_COLUMN_COUNT+1);
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup_printf ("View as Viewer %d", i+1);
|
||||
gtk_clist_append (clist, text);
|
||||
|
||||
g_strfreev (text);
|
||||
}
|
||||
} else {
|
||||
g_assert (type == NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS);
|
||||
for (i = 0; i < 10; ++i) {
|
||||
/* One extra slot so it's NULL-terminated */
|
||||
text = g_new0 (char *, PROGRAM_LIST_COLUMN_COUNT+1);
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup_printf ("Application %d", i+1);
|
||||
gtk_clist_append (clist, text);
|
||||
|
||||
g_strfreev (text);
|
||||
uri = nautilus_file_get_uri (file);
|
||||
programs = type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS
|
||||
? gnome_vfs_mime_get_all_components_for_uri (uri)
|
||||
: gnome_vfs_mime_get_all_applications_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
|
||||
for (program = programs; program != NULL; program = program->next) {
|
||||
/* One extra slot so it's NULL-terminated */
|
||||
text = g_new0 (char *, PROGRAM_LIST_COLUMN_COUNT+1);
|
||||
|
||||
if (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS) {
|
||||
view_identifier = nautilus_view_identifier_new_from_content_view
|
||||
((OAF_ServerInfo *)program->data);
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup_printf
|
||||
("View as %s", view_identifier->name);
|
||||
/* Free the OAF_ServerInfo now, we're done with it. */
|
||||
CORBA_free (program->data);
|
||||
} else {
|
||||
application = (GnomeVFSMimeApplication *)program->data;
|
||||
text[PROGRAM_LIST_NAME_COLUMN] = g_strdup (application->name);
|
||||
gnome_vfs_mime_application_free (application);
|
||||
}
|
||||
|
||||
new_row = gtk_clist_append (clist, text);
|
||||
|
||||
if (type == NAUTILUS_PROGRAM_CHOOSER_COMPONENTS) {
|
||||
gtk_clist_set_row_data_full
|
||||
(clist, new_row, view_identifier, (GtkDestroyNotify)nautilus_view_identifier_free);
|
||||
} else {
|
||||
gtk_clist_set_row_data_full
|
||||
(clist, new_row, application, (GtkDestroyNotify)gnome_vfs_mime_application_free);
|
||||
}
|
||||
|
||||
g_strfreev (text);
|
||||
}
|
||||
|
||||
/* Don't free the data here, just the list shell. The data is freed elsewhere. */
|
||||
g_list_free (programs);
|
||||
}
|
||||
|
||||
static NautilusFile *
|
||||
|
@ -395,6 +420,8 @@ nautilus_program_chooser_new (NautilusProgramChooserType type,
|
|||
NO_DEFAULT_MAGIC_NUMBER,
|
||||
PROGRAM_CHOOSER_DEFAULT_HEIGHT);
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (window), "type", GINT_TO_POINTER (type));
|
||||
|
||||
dialog_vbox = GNOME_DIALOG (window)->vbox;
|
||||
|
||||
/* Prompt at top of dialog. */
|
||||
|
@ -419,6 +446,8 @@ nautilus_program_chooser_new (NautilusProgramChooserType type,
|
|||
gtk_container_add (GTK_CONTAINER (list_scroller), clist);
|
||||
gtk_clist_column_titles_hide (GTK_CLIST (clist));
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (window), "list", clist);
|
||||
|
||||
/* Framed area with selection-specific details */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame);
|
||||
|
@ -471,3 +500,69 @@ nautilus_program_chooser_new (NautilusProgramChooserType type,
|
|||
|
||||
return GNOME_DIALOG (window);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_program_chooser_get_application:
|
||||
*
|
||||
* Get the currently-chosen application in the program-choosing dialog.
|
||||
* Usually used after the dialog has been closed (but not yet destroyed)
|
||||
* to get the user's final choice. The returned value is the actual one
|
||||
* stored in the dialog, and thus cannot be accessed after the dialog
|
||||
* has been destroyed.
|
||||
*
|
||||
* @program_chooser: The result of calling nautilus_program_chooser_new
|
||||
* with type NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS.
|
||||
*
|
||||
* Return value: a GnomeVFSMimeApplication specifying a component. The caller
|
||||
* should make a copy if they want to use it after the dialog has been
|
||||
* destroyed.
|
||||
*/
|
||||
GnomeVFSMimeApplication *
|
||||
nautilus_program_chooser_get_application (GnomeDialog *program_chooser)
|
||||
{
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_val_if_fail (GNOME_IS_DIALOG (program_chooser), NULL);
|
||||
|
||||
g_return_val_if_fail
|
||||
(GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (program_chooser), "type"))
|
||||
== NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS,
|
||||
NULL);
|
||||
|
||||
clist = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (program_chooser), "list"));
|
||||
return (GnomeVFSMimeApplication *)gtk_clist_get_row_data
|
||||
(clist, nautilus_gtk_clist_get_first_selected_row (clist));
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_program_chooser_get_component:
|
||||
*
|
||||
* Get the currently-chosen component in the program-choosing dialog.
|
||||
* Usually used after the dialog has been closed (but not yet destroyed)
|
||||
* to get the user's final choice. The returned value is the actual one
|
||||
* stored in the dialog, and thus cannot be accessed after the dialog
|
||||
* has been destroyed.
|
||||
*
|
||||
* @program_chooser: The result of calling nautilus_program_chooser_new
|
||||
* with type NAUTILUS_PROGRAM_CHOOSER_COMPONENTS.
|
||||
*
|
||||
* Return value: a NautilusViewIdentifier specifying a component. The caller
|
||||
* should make a copy if they want to use it after the dialog has been
|
||||
* destroyed.
|
||||
*/
|
||||
NautilusViewIdentifier *
|
||||
nautilus_program_chooser_get_component (GnomeDialog *program_chooser)
|
||||
{
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_val_if_fail (GNOME_IS_DIALOG (program_chooser), NULL);
|
||||
|
||||
g_return_val_if_fail
|
||||
(GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (program_chooser), "type"))
|
||||
== NAUTILUS_PROGRAM_CHOOSER_COMPONENTS,
|
||||
NULL);
|
||||
|
||||
clist = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (program_chooser), "list"));
|
||||
return (NautilusViewIdentifier *)gtk_clist_get_row_data
|
||||
(clist, nautilus_gtk_clist_get_first_selected_row (clist));
|
||||
}
|
||||
|
|
|
@ -28,14 +28,20 @@
|
|||
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include <libgnomeui/gnome-dialog.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
|
||||
#include "nautilus-file.h"
|
||||
#include "nautilus-view-identifier.h"
|
||||
|
||||
typedef enum {
|
||||
NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS,
|
||||
NAUTILUS_PROGRAM_CHOOSER_COMPONENTS,
|
||||
} NautilusProgramChooserType;
|
||||
|
||||
GnomeDialog *nautilus_program_chooser_new (NautilusProgramChooserType type,
|
||||
NautilusFile *file);
|
||||
GnomeDialog *nautilus_program_chooser_new (NautilusProgramChooserType type,
|
||||
NautilusFile *file);
|
||||
|
||||
GnomeVFSMimeApplication *nautilus_program_chooser_get_application (GnomeDialog *program_chooser);
|
||||
NautilusViewIdentifier *nautilus_program_chooser_get_component (GnomeDialog *program_chooser);
|
||||
|
||||
#endif /* NAUTILUS_PROGRAM_CHOOSER_H */
|
||||
|
|
|
@ -96,19 +96,21 @@ nautilus_choose_component_for_file (NautilusFile *file,
|
|||
(file, NAUTILUS_PROGRAM_CHOOSER_COMPONENTS, parent_window);
|
||||
|
||||
if (gnome_dialog_run (dialog) == GNOME_OK) {
|
||||
/* FIXME: Need to extract result from dialog! */
|
||||
identifier = NULL;
|
||||
identifier = nautilus_program_chooser_get_component (dialog);;
|
||||
} 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);
|
||||
|
||||
/* Destroy only after callback, since view identifier will
|
||||
* be destroyed too.
|
||||
*/
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,8 +130,8 @@ nautilus_choose_application_for_file (NautilusFile *file,
|
|||
NautilusApplicationChoiceCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
char *command_string;
|
||||
GnomeDialog *dialog;
|
||||
GnomeVFSMimeApplication *application;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_FILE (file));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
@ -141,25 +143,21 @@ nautilus_choose_application_for_file (NautilusFile *file,
|
|||
(file, NAUTILUS_PROGRAM_CHOOSER_APPLICATIONS, parent_window);
|
||||
|
||||
if (gnome_dialog_run (dialog) == GNOME_OK) {
|
||||
/* FIXME: Need to extract result from dialog! */
|
||||
#ifdef TESTING_LAUNCH
|
||||
/* FIXME: investigate why passing wrong text here ("gnotepad")
|
||||
* causes an X error.
|
||||
*/
|
||||
command_string = "gnp";
|
||||
#else
|
||||
command_string = NULL;
|
||||
#endif
|
||||
application = nautilus_program_chooser_get_application (dialog);
|
||||
} else {
|
||||
command_string = NULL;
|
||||
application = 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);
|
||||
(* callback) (application, callback_data);
|
||||
|
||||
/* Destroy only after callback, since application struct will
|
||||
* be destroyed too.
|
||||
*/
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <libgnomevfs/gnome-vfs-async-ops.h>
|
||||
#include <libgnomevfs/gnome-vfs-directory-list.h>
|
||||
#include <libgnomevfs/gnome-vfs-file-info.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <libgnomevfs/gnome-vfs-utils.h>
|
||||
#include <libgnomevfs/gnome-vfs-result.h>
|
||||
|
@ -156,12 +157,6 @@ static void open_one_in_new_window
|
|||
gpointer user_data);
|
||||
static void open_one_properties_window (gpointer data,
|
||||
gpointer user_data);
|
||||
static void select_all_callback (GtkMenuItem *item,
|
||||
FMDirectoryView *directory_view);
|
||||
static void zoom_in_callback (GtkMenuItem *item,
|
||||
FMDirectoryView *directory_view);
|
||||
static void zoom_out_callback (GtkMenuItem *item,
|
||||
FMDirectoryView *directory_view);
|
||||
static void zoomable_zoom_in_callback (NautilusZoomable *zoomable,
|
||||
FMDirectoryView *directory_view);
|
||||
static void zoomable_zoom_out_callback (NautilusZoomable *zoomable,
|
||||
|
@ -318,7 +313,7 @@ bonobo_menu_open_in_new_window_callback (BonoboUIHandler *ui_handler, gpointer u
|
|||
}
|
||||
|
||||
static void
|
||||
fm_directory_view_chose_application_callback (const char *command_string,
|
||||
fm_directory_view_chose_application_callback (GnomeVFSMimeApplication *application,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NautilusFile *file;
|
||||
|
@ -328,9 +323,9 @@ fm_directory_view_chose_application_callback (const char *command_string,
|
|||
|
||||
file = NAUTILUS_FILE (callback_data);
|
||||
|
||||
if (command_string != NULL) {
|
||||
if (application != NULL) {
|
||||
uri = nautilus_file_get_uri (file);
|
||||
nautilus_launch_application (command_string, uri);
|
||||
nautilus_launch_application (application->command, uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
|
@ -472,6 +467,14 @@ bonobo_menu_duplicate_callback (BonoboUIHandler *ui_handler, gpointer user_data,
|
|||
nautilus_file_list_free (selection);
|
||||
}
|
||||
|
||||
static void
|
||||
bonobo_menu_select_all_callback (BonoboUIHandler *ui_handler, gpointer user_data, const char *path)
|
||||
{
|
||||
g_assert (FM_IS_DIRECTORY_VIEW (user_data));
|
||||
|
||||
fm_directory_view_select_all (user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
bonobo_menu_empty_trash_callback (BonoboUIHandler *ui_handler, gpointer user_data, const char *path)
|
||||
{
|
||||
|
@ -879,12 +882,14 @@ done_loading (FMDirectoryView *view)
|
|||
|
||||
|
||||
|
||||
/* handle the "select all" menu command */
|
||||
|
||||
static void
|
||||
select_all_callback (GtkMenuItem *item, FMDirectoryView *directory_view)
|
||||
select_all_callback (GtkMenuItem *item, gpointer callback_data)
|
||||
{
|
||||
fm_directory_view_select_all (directory_view);
|
||||
g_assert (GTK_IS_MENU_ITEM (item));
|
||||
g_assert (callback_data == NULL);
|
||||
|
||||
fm_directory_view_select_all (
|
||||
FM_DIRECTORY_VIEW (gtk_object_get_data (GTK_OBJECT (item), "directory_view")) );
|
||||
}
|
||||
|
||||
/* handle the zoom in/out menu items */
|
||||
|
@ -1864,42 +1869,167 @@ add_open_with_gtk_menu_item (GtkMenu *menu, const char *label)
|
|||
menu_item = gtk_menu_item_new ();
|
||||
}
|
||||
|
||||
finish_adding_menu_item (menu, menu_item, FALSE);
|
||||
finish_adding_menu_item (menu, menu_item, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
launch_application_from_menu_item (GtkMenuItem *menu_item, gpointer user_data)
|
||||
{
|
||||
char *uri, *command;
|
||||
|
||||
g_assert (GTK_IS_MENU_ITEM (menu_item));
|
||||
g_assert (user_data == NULL);
|
||||
|
||||
command = (char *)gtk_object_get_data (GTK_OBJECT (menu_item), "command");
|
||||
g_assert (command != NULL);
|
||||
|
||||
uri = (char *)gtk_object_get_data (GTK_OBJECT (menu_item), "uri");
|
||||
g_assert (uri != NULL);
|
||||
|
||||
nautilus_launch_application (command, uri);
|
||||
}
|
||||
|
||||
static void
|
||||
view_uri_from_menu_item (GtkMenuItem *menu_item, gpointer user_data)
|
||||
{
|
||||
NautilusViewIdentifier *identifier;
|
||||
char *uri;
|
||||
|
||||
g_assert (GTK_IS_MENU_ITEM (menu_item));
|
||||
g_assert (user_data == NULL);
|
||||
|
||||
identifier = (NautilusViewIdentifier *)gtk_object_get_data
|
||||
(GTK_OBJECT (menu_item), "identifier");
|
||||
g_assert (identifier != NULL);
|
||||
|
||||
uri = (char *)gtk_object_get_data (GTK_OBJECT (menu_item), "uri");
|
||||
g_assert (uri != NULL);
|
||||
|
||||
/* FIXME: Need to switch to new viewer, opening new window if user's
|
||||
* preference is set that way, with the given uri.
|
||||
*/
|
||||
g_message ("POOF! (switch to \"%s\" with viewer \"%s\" here)", uri, identifier->iid);
|
||||
}
|
||||
|
||||
static void
|
||||
add_application_to_gtk_menu (GtkMenu *menu,
|
||||
GnomeVFSMimeApplication *application,
|
||||
const char *uri)
|
||||
{
|
||||
GtkWidget *menu_item;
|
||||
char *label_string;
|
||||
|
||||
g_assert (GTK_IS_MENU (menu));
|
||||
|
||||
label_string = g_strdup (application->name);
|
||||
menu_item = gtk_menu_item_new_with_label (label_string);
|
||||
g_free (label_string);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (menu_item),
|
||||
"command",
|
||||
g_strdup (application->command),
|
||||
g_free);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (menu_item),
|
||||
"uri",
|
||||
g_strdup (uri),
|
||||
g_free);
|
||||
|
||||
gtk_signal_connect
|
||||
(GTK_OBJECT (menu_item),
|
||||
"activate",
|
||||
launch_application_from_menu_item,
|
||||
NULL);
|
||||
|
||||
finish_adding_menu_item (menu, menu_item, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
add_component_to_gtk_menu (GtkMenu *menu,
|
||||
OAF_ServerInfo *component,
|
||||
const char *uri)
|
||||
{
|
||||
GtkWidget *menu_item;
|
||||
NautilusViewIdentifier *identifier;
|
||||
|
||||
g_assert (GTK_IS_MENU (menu));
|
||||
|
||||
identifier = nautilus_view_identifier_new_from_content_view (component);
|
||||
|
||||
menu_item = gtk_menu_item_new_with_label (identifier->name);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (menu_item),
|
||||
"identifier",
|
||||
identifier,
|
||||
(GtkDestroyNotify) nautilus_view_identifier_free);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (menu_item),
|
||||
"uri",
|
||||
g_strdup (uri),
|
||||
g_free);
|
||||
|
||||
gtk_signal_connect
|
||||
(GTK_OBJECT (menu_item),
|
||||
"activate",
|
||||
view_uri_from_menu_item,
|
||||
NULL);
|
||||
|
||||
finish_adding_menu_item (menu, menu_item, TRUE);
|
||||
}
|
||||
|
||||
static GtkMenu *
|
||||
create_open_with_gtk_menu (FMDirectoryView *view, GList *files)
|
||||
{
|
||||
GtkMenu *open_with_menu;
|
||||
char *label;
|
||||
int i;
|
||||
GList *applications, *components;
|
||||
GList *node;
|
||||
char *uri;
|
||||
|
||||
open_with_menu = GTK_MENU (gtk_menu_new ());
|
||||
gtk_widget_show (GTK_WIDGET (open_with_menu));
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
label = g_strdup_printf (_("Application %d"), i+1);
|
||||
add_open_with_gtk_menu_item (open_with_menu, label);
|
||||
g_free (label);
|
||||
}
|
||||
append_gtk_menu_item_with_view (view,
|
||||
open_with_menu,
|
||||
files,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION,
|
||||
other_application_callback);
|
||||
/* This menu is only displayed when there's one selected item. */
|
||||
if (nautilus_g_list_exactly_one_item (files)) {
|
||||
uri = nautilus_file_get_uri (NAUTILUS_FILE (files->data));
|
||||
|
||||
add_open_with_gtk_menu_item (open_with_menu, NULL);
|
||||
applications =
|
||||
gnome_vfs_mime_get_short_list_applications_for_uri (uri);
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
label = g_strdup_printf (_("Viewer %d"), i+1);
|
||||
add_open_with_gtk_menu_item (open_with_menu, label);
|
||||
g_free (label);
|
||||
for (node = applications; node != NULL; node = node->next) {
|
||||
add_application_to_gtk_menu (open_with_menu, node->data, uri);
|
||||
}
|
||||
|
||||
/* FIXME: Need to free list, but API not yet existent:
|
||||
* gnome_vfs_mime_application_list_free (applications);
|
||||
*/
|
||||
|
||||
append_gtk_menu_item_with_view (view,
|
||||
open_with_menu,
|
||||
files,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION,
|
||||
other_application_callback);
|
||||
|
||||
add_open_with_gtk_menu_item (open_with_menu, NULL);
|
||||
|
||||
components =
|
||||
gnome_vfs_mime_get_short_list_components_for_uri (uri);
|
||||
|
||||
for (node = components; node != NULL; node = node->next) {
|
||||
add_component_to_gtk_menu (open_with_menu, node->data, uri);
|
||||
}
|
||||
|
||||
/* FIXME: Need to free list, but API not yet existent:
|
||||
* gnome_vfs_mime_component_list_free (components);
|
||||
*/
|
||||
|
||||
g_free (uri);
|
||||
|
||||
append_gtk_menu_item_with_view (view,
|
||||
open_with_menu,
|
||||
files,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OTHER_VIEWER,
|
||||
other_viewer_callback);
|
||||
}
|
||||
append_gtk_menu_item_with_view (view,
|
||||
open_with_menu,
|
||||
files,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_OTHER_VIEWER,
|
||||
other_viewer_callback);
|
||||
|
||||
return open_with_menu;
|
||||
}
|
||||
|
@ -2141,7 +2271,7 @@ fm_directory_view_real_merge_menus (FMDirectoryView *view)
|
|||
_("Select all items in this window"),
|
||||
bonobo_ui_handler_menu_get_pos (ui_handler, NAUTILUS_MENU_PATH_SELECT_ALL_ITEM),
|
||||
0, 0, /* Accelerator will be inherited */
|
||||
(BonoboUIHandlerCallbackFunc) select_all_callback, view);
|
||||
bonobo_menu_select_all_callback, view);
|
||||
|
||||
bonobo_ui_handler_menu_new_separator
|
||||
(ui_handler,
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <libgnomeui/gnome-uidefs.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libgnomevfs/gnome-vfs-types.h>
|
||||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
@ -87,7 +88,7 @@ static void nautilus_index_panel_update_info (NautilusIndexPanel *ind
|
|||
const char *title);
|
||||
static void nautilus_index_panel_update_buttons (NautilusIndexPanel *index_panel);
|
||||
static void add_command_buttons (NautilusIndexPanel *index_panel,
|
||||
GList *command_list);
|
||||
GList *application_list);
|
||||
|
||||
#define DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/FFFF"
|
||||
#define DEFAULT_TAB_COLOR "rgb:9999/9999/9999"
|
||||
|
@ -723,14 +724,14 @@ command_button_callback (GtkWidget *button, char *command_str)
|
|||
}
|
||||
|
||||
static void
|
||||
nautilus_index_panel_chose_application_callback (const char *command_string,
|
||||
nautilus_index_panel_chose_application_callback (GnomeVFSMimeApplication *application,
|
||||
gpointer callback_data)
|
||||
{
|
||||
g_assert (NAUTILUS_IS_INDEX_PANEL (callback_data));
|
||||
|
||||
if (command_string != NULL) {
|
||||
if (application != NULL) {
|
||||
nautilus_launch_application
|
||||
(command_string,
|
||||
(application->command,
|
||||
NAUTILUS_INDEX_PANEL (callback_data)->details->uri);
|
||||
}
|
||||
}
|
||||
|
@ -758,19 +759,20 @@ open_with_callback (GtkWidget *button, gpointer ignored)
|
|||
/* utility routine that allocates the command buttons from the command list */
|
||||
|
||||
static void
|
||||
add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
||||
add_command_buttons (NautilusIndexPanel *index_panel, GList *application_list)
|
||||
{
|
||||
char *command_string, *temp_str;
|
||||
GList *p;
|
||||
GtkWidget *temp_button;
|
||||
NautilusCommandInfo *info;
|
||||
|
||||
for (p = command_list; p != NULL; p = p->next) {
|
||||
info = p->data;
|
||||
|
||||
index_panel->details->has_buttons = TRUE;
|
||||
GnomeVFSMimeApplication *application;
|
||||
|
||||
temp_str = g_strdup_printf (_("Open with %s"), info->display_name);
|
||||
/* There's always at least the "Open with..." button */
|
||||
index_panel->details->has_buttons = TRUE;
|
||||
|
||||
for (p = application_list; p != NULL; p = p->next) {
|
||||
application = p->data;
|
||||
|
||||
temp_str = g_strdup_printf (_("Open with %s"), application->name);
|
||||
temp_button = gtk_button_new_with_label (temp_str);
|
||||
gtk_box_pack_start (GTK_BOX (index_panel->details->button_box),
|
||||
temp_button,
|
||||
|
@ -781,7 +783,7 @@ add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
|||
nautilus_str_has_prefix (index_panel->details->uri, "file://") ?
|
||||
index_panel->details->uri + 7 : index_panel->details->uri);
|
||||
|
||||
command_string = g_strdup_printf (info->command_string, temp_str);
|
||||
command_string = g_strdup_printf (application->command, temp_str);
|
||||
g_free(temp_str);
|
||||
|
||||
nautilus_gtk_signal_connect_free_data
|
||||
|
@ -793,7 +795,7 @@ add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
|||
}
|
||||
|
||||
/* Catch-all button after all the others. */
|
||||
temp_button = gtk_button_new_with_label (_("Open with ..."));
|
||||
temp_button = gtk_button_new_with_label (_("Open with..."));
|
||||
gtk_signal_connect (GTK_OBJECT (temp_button), "clicked",
|
||||
open_with_callback, NULL);
|
||||
gtk_object_set_user_data (GTK_OBJECT (temp_button), index_panel);
|
||||
|
@ -802,47 +804,35 @@ add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
|||
temp_button, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
/* here's where we set up the command buttons, based on the mime-type of the associated URL */
|
||||
/* FIXME bugzilla.eazel.com 596: eventually, we need a way to
|
||||
* override/augment the type from info in the metadata.
|
||||
/* FIXME: This is a placeholder awaiting the real call. */
|
||||
static void
|
||||
gnome_vfs_mime_application_list_free (GList *list)
|
||||
{}
|
||||
|
||||
/**
|
||||
* nautilus_index_panel_update_buttons:
|
||||
*
|
||||
* Update the list of program-launching buttons based on the current uri.
|
||||
*/
|
||||
void
|
||||
nautilus_index_panel_update_buttons (NautilusIndexPanel *index_panel)
|
||||
{
|
||||
NautilusFile *file;
|
||||
GList *command_list;
|
||||
char *mime_type;
|
||||
GList *application_list;
|
||||
|
||||
/* dispose any existing buttons */
|
||||
/* dispose of any existing buttons */
|
||||
if (index_panel->details->has_buttons) {
|
||||
gtk_container_remove (GTK_CONTAINER (index_panel->details->container),
|
||||
GTK_WIDGET (index_panel->details->button_box_centerer));
|
||||
make_button_box (index_panel);
|
||||
}
|
||||
|
||||
/* allocate a file object and fetch the associated mime-type */
|
||||
|
||||
file = nautilus_file_get (index_panel->details->uri);
|
||||
if (file != NULL) {
|
||||
mime_type = nautilus_file_get_mime_type (file);
|
||||
|
||||
/* generate a command list from the mime-type */
|
||||
if (mime_type != NULL) {
|
||||
command_list = nautilus_mime_type_get_commands (mime_type);
|
||||
g_free (mime_type);
|
||||
application_list = gnome_vfs_mime_get_short_list_applications_for_uri (index_panel->details->uri);
|
||||
add_command_buttons (index_panel, application_list);
|
||||
gnome_vfs_mime_application_list_free (application_list);
|
||||
|
||||
/* install a button for each command in the list */
|
||||
if (command_list != NULL) {
|
||||
add_command_buttons (index_panel, command_list);
|
||||
nautilus_mime_type_dispose_list (command_list);
|
||||
|
||||
if (index_panel->details->selected_index != -1)
|
||||
gtk_widget_hide (GTK_WIDGET (index_panel->details->button_box));
|
||||
}
|
||||
}
|
||||
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
/* Hide button box if a sidebar panel is showing. */
|
||||
if (index_panel->details->selected_index != -1)
|
||||
gtk_widget_hide (GTK_WIDGET (index_panel->details->button_box));
|
||||
}
|
||||
|
||||
/* this routine populates the index panel with the per-uri information */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <libgnomeui/gnome-uidefs.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libgnomevfs/gnome-vfs-types.h>
|
||||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
@ -87,7 +88,7 @@ static void nautilus_index_panel_update_info (NautilusIndexPanel *ind
|
|||
const char *title);
|
||||
static void nautilus_index_panel_update_buttons (NautilusIndexPanel *index_panel);
|
||||
static void add_command_buttons (NautilusIndexPanel *index_panel,
|
||||
GList *command_list);
|
||||
GList *application_list);
|
||||
|
||||
#define DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/FFFF"
|
||||
#define DEFAULT_TAB_COLOR "rgb:9999/9999/9999"
|
||||
|
@ -723,14 +724,14 @@ command_button_callback (GtkWidget *button, char *command_str)
|
|||
}
|
||||
|
||||
static void
|
||||
nautilus_index_panel_chose_application_callback (const char *command_string,
|
||||
nautilus_index_panel_chose_application_callback (GnomeVFSMimeApplication *application,
|
||||
gpointer callback_data)
|
||||
{
|
||||
g_assert (NAUTILUS_IS_INDEX_PANEL (callback_data));
|
||||
|
||||
if (command_string != NULL) {
|
||||
if (application != NULL) {
|
||||
nautilus_launch_application
|
||||
(command_string,
|
||||
(application->command,
|
||||
NAUTILUS_INDEX_PANEL (callback_data)->details->uri);
|
||||
}
|
||||
}
|
||||
|
@ -758,19 +759,20 @@ open_with_callback (GtkWidget *button, gpointer ignored)
|
|||
/* utility routine that allocates the command buttons from the command list */
|
||||
|
||||
static void
|
||||
add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
||||
add_command_buttons (NautilusIndexPanel *index_panel, GList *application_list)
|
||||
{
|
||||
char *command_string, *temp_str;
|
||||
GList *p;
|
||||
GtkWidget *temp_button;
|
||||
NautilusCommandInfo *info;
|
||||
|
||||
for (p = command_list; p != NULL; p = p->next) {
|
||||
info = p->data;
|
||||
|
||||
index_panel->details->has_buttons = TRUE;
|
||||
GnomeVFSMimeApplication *application;
|
||||
|
||||
temp_str = g_strdup_printf (_("Open with %s"), info->display_name);
|
||||
/* There's always at least the "Open with..." button */
|
||||
index_panel->details->has_buttons = TRUE;
|
||||
|
||||
for (p = application_list; p != NULL; p = p->next) {
|
||||
application = p->data;
|
||||
|
||||
temp_str = g_strdup_printf (_("Open with %s"), application->name);
|
||||
temp_button = gtk_button_new_with_label (temp_str);
|
||||
gtk_box_pack_start (GTK_BOX (index_panel->details->button_box),
|
||||
temp_button,
|
||||
|
@ -781,7 +783,7 @@ add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
|||
nautilus_str_has_prefix (index_panel->details->uri, "file://") ?
|
||||
index_panel->details->uri + 7 : index_panel->details->uri);
|
||||
|
||||
command_string = g_strdup_printf (info->command_string, temp_str);
|
||||
command_string = g_strdup_printf (application->command, temp_str);
|
||||
g_free(temp_str);
|
||||
|
||||
nautilus_gtk_signal_connect_free_data
|
||||
|
@ -793,7 +795,7 @@ add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
|||
}
|
||||
|
||||
/* Catch-all button after all the others. */
|
||||
temp_button = gtk_button_new_with_label (_("Open with ..."));
|
||||
temp_button = gtk_button_new_with_label (_("Open with..."));
|
||||
gtk_signal_connect (GTK_OBJECT (temp_button), "clicked",
|
||||
open_with_callback, NULL);
|
||||
gtk_object_set_user_data (GTK_OBJECT (temp_button), index_panel);
|
||||
|
@ -802,47 +804,35 @@ add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list)
|
|||
temp_button, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
/* here's where we set up the command buttons, based on the mime-type of the associated URL */
|
||||
/* FIXME bugzilla.eazel.com 596: eventually, we need a way to
|
||||
* override/augment the type from info in the metadata.
|
||||
/* FIXME: This is a placeholder awaiting the real call. */
|
||||
static void
|
||||
gnome_vfs_mime_application_list_free (GList *list)
|
||||
{}
|
||||
|
||||
/**
|
||||
* nautilus_index_panel_update_buttons:
|
||||
*
|
||||
* Update the list of program-launching buttons based on the current uri.
|
||||
*/
|
||||
void
|
||||
nautilus_index_panel_update_buttons (NautilusIndexPanel *index_panel)
|
||||
{
|
||||
NautilusFile *file;
|
||||
GList *command_list;
|
||||
char *mime_type;
|
||||
GList *application_list;
|
||||
|
||||
/* dispose any existing buttons */
|
||||
/* dispose of any existing buttons */
|
||||
if (index_panel->details->has_buttons) {
|
||||
gtk_container_remove (GTK_CONTAINER (index_panel->details->container),
|
||||
GTK_WIDGET (index_panel->details->button_box_centerer));
|
||||
make_button_box (index_panel);
|
||||
}
|
||||
|
||||
/* allocate a file object and fetch the associated mime-type */
|
||||
|
||||
file = nautilus_file_get (index_panel->details->uri);
|
||||
if (file != NULL) {
|
||||
mime_type = nautilus_file_get_mime_type (file);
|
||||
|
||||
/* generate a command list from the mime-type */
|
||||
if (mime_type != NULL) {
|
||||
command_list = nautilus_mime_type_get_commands (mime_type);
|
||||
g_free (mime_type);
|
||||
application_list = gnome_vfs_mime_get_short_list_applications_for_uri (index_panel->details->uri);
|
||||
add_command_buttons (index_panel, application_list);
|
||||
gnome_vfs_mime_application_list_free (application_list);
|
||||
|
||||
/* install a button for each command in the list */
|
||||
if (command_list != NULL) {
|
||||
add_command_buttons (index_panel, command_list);
|
||||
nautilus_mime_type_dispose_list (command_list);
|
||||
|
||||
if (index_panel->details->selected_index != -1)
|
||||
gtk_widget_hide (GTK_WIDGET (index_panel->details->button_box));
|
||||
}
|
||||
}
|
||||
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
/* Hide button box if a sidebar panel is showing. */
|
||||
if (index_panel->details->selected_index != -1)
|
||||
gtk_widget_hide (GTK_WIDGET (index_panel->details->button_box));
|
||||
}
|
||||
|
||||
/* this routine populates the index panel with the per-uri information */
|
||||
|
|
Loading…
Reference in a new issue