Fixed bug #581. Ui for specifying whether applicaition can open multiple
2000-06-22 Gene Z. Ragan <gzr@eazel.com> Fixed bug #581. Ui for specifying whether applicaition can open multiple files at once. * libgnomevfs/gnome-vfs-mime-handlers.c: * libgnomevfs/gnome-vfs-mime-handlers.h: (gnome_vfs_mime_define_application): Added const char * argument for mime type. Removed placeholder mime type. * mime-type-capplet/nautilus-mime-type-capplet-dialogs.c: (populate_default_applications_list), (populate_default_components_box), (initialize_edit_applications_dialog), (add_new_application), (show_new_application_window), (show_edit_application_window): Modified edit applicaiton list dialog to use a GtkList with embedded check buttons and labels. This allows single list items to be selected so that individual items can be edited or deleted. * test/test-mime-handlers-set.c: (main): Fixed call to gnome_vfs_mime_define_application to use new argument.
This commit is contained in:
parent
6a7fb3c737
commit
7f3302d6b8
1 changed files with 91 additions and 47 deletions
|
@ -129,11 +129,12 @@ application_button_toggled_callback (GtkToggleButton *button, gpointer user_data
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
populate_default_applications_box (GtkWidget *box, const char *mime_type)
|
populate_default_applications_list (GtkWidget *list, const char *mime_type)
|
||||||
{
|
{
|
||||||
GList *short_list, *app_list, *list_element;
|
GList *short_list, *app_list, *list_element;
|
||||||
GnomeVFSMimeApplication *application;
|
GnomeVFSMimeApplication *application;
|
||||||
GtkWidget *button;
|
GtkWidget *button, *list_item;
|
||||||
|
GtkWidget *hbox, *label;
|
||||||
|
|
||||||
/* Get the application short list */
|
/* Get the application short list */
|
||||||
short_list = gnome_vfs_mime_get_short_list_applications (mime_type);
|
short_list = gnome_vfs_mime_get_short_list_applications (mime_type);
|
||||||
|
@ -144,9 +145,21 @@ populate_default_applications_box (GtkWidget *box, const char *mime_type)
|
||||||
for (list_element = app_list; list_element != NULL; list_element = list_element->next) {
|
for (list_element = app_list; list_element != NULL; list_element = list_element->next) {
|
||||||
application = list_element->data;
|
application = list_element->data;
|
||||||
|
|
||||||
|
/* Create list item */
|
||||||
|
list_item = gtk_list_item_new ();
|
||||||
|
|
||||||
/* Create check button */
|
/* Create check button */
|
||||||
button = gtk_check_button_new_with_label (application->name);
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
|
gtk_container_add (GTK_CONTAINER (list_item), hbox);
|
||||||
|
|
||||||
|
button = gtk_check_button_new ();
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
label = gtk_label_new (application->name);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
/* Add list item to list */
|
||||||
|
gtk_container_add (GTK_CONTAINER (list), list_item);
|
||||||
|
|
||||||
/* Save ID and mime type*/
|
/* Save ID and mime type*/
|
||||||
gtk_object_set_data_full (GTK_OBJECT (button), "application_id", g_strdup (application->id), g_free);
|
gtk_object_set_data_full (GTK_OBJECT (button), "application_id", g_strdup (application->id), g_free);
|
||||||
|
@ -282,9 +295,9 @@ populate_default_components_box (GtkWidget *box, const char *mime_type)
|
||||||
static void
|
static void
|
||||||
initialize_edit_applications_dialog (const char *mime_type)
|
initialize_edit_applications_dialog (const char *mime_type)
|
||||||
{
|
{
|
||||||
GtkWidget *main_vbox, *vbox, *hbox;
|
GtkWidget *main_vbox, *hbox;
|
||||||
GtkWidget *scroller, *label;
|
GtkWidget *scroller, *label;
|
||||||
GtkWidget *button;
|
GtkWidget *button, *list;
|
||||||
char *label_text;
|
char *label_text;
|
||||||
|
|
||||||
edit_application_details = g_new0 (edit_dialog_details, 1);
|
edit_application_details = g_new0 (edit_dialog_details, 1);
|
||||||
|
@ -323,8 +336,10 @@ initialize_edit_applications_dialog (const char *mime_type)
|
||||||
GTK_POLICY_NEVER,
|
GTK_POLICY_NEVER,
|
||||||
GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
list = gtk_list_new ();
|
||||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller), vbox);
|
//gtk_container_add (GTK_CONTAINER (scroller), list);
|
||||||
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller), list);
|
||||||
|
gtk_list_set_selection_mode (GTK_LIST (list), GTK_SELECTION_BROWSE);
|
||||||
|
|
||||||
/* Add edit buttons */
|
/* Add edit buttons */
|
||||||
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
|
@ -341,7 +356,7 @@ initialize_edit_applications_dialog (const char *mime_type)
|
||||||
button = gtk_button_new_with_label (_("Delete Application"));
|
button = gtk_button_new_with_label (_("Delete Application"));
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
populate_default_applications_box (vbox, mime_type);
|
populate_default_applications_list (list, mime_type);
|
||||||
|
|
||||||
gtk_widget_show_all (main_vbox);
|
gtk_widget_show_all (main_vbox);
|
||||||
}
|
}
|
||||||
|
@ -642,13 +657,20 @@ nautilus_mime_type_capplet_show_new_extension_window (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add_new_application
|
||||||
|
*
|
||||||
|
* Create a new GnomeVFSMimeApplication and register
|
||||||
|
* it with the mime database.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
add_new_application (const char *name, const char *id, const char *command)
|
add_new_application (const char *name, const char *id, const char *command,
|
||||||
|
gboolean multiple, gboolean uri)
|
||||||
{
|
{
|
||||||
GnomeVFSMimeApplication *app;
|
GnomeVFSMimeApplication *app;
|
||||||
const char *mime_type;
|
const char *mime_type;
|
||||||
|
|
||||||
if ((strlen (id) <= 0) || (strlen (command) <= 0)) {
|
/* Check for empty strings. Command can be empty. */
|
||||||
|
if ((strlen (name) <= 0) || (strlen (id) <= 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,31 +682,32 @@ add_new_application (const char *name, const char *id, const char *command)
|
||||||
app->id = g_strdup (id);
|
app->id = g_strdup (id);
|
||||||
app->name = g_strdup (name);
|
app->name = g_strdup (name);
|
||||||
app->command = g_strdup (command);
|
app->command = g_strdup (command);
|
||||||
app->can_open_multiple_files = FALSE;
|
app->can_open_multiple_files = multiple;
|
||||||
app->can_open_uris = FALSE;
|
app->can_open_uris = uri;
|
||||||
app->requires_terminal = FALSE;
|
app->requires_terminal = FALSE;
|
||||||
|
|
||||||
|
gnome_vfs_mime_define_application (mime_type, app);
|
||||||
gnome_vfs_mime_application_free (app);
|
gnome_vfs_mime_add_application_to_short_list (mime_type, app->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_new_application_window (void)
|
show_new_application_window (void)
|
||||||
{
|
{
|
||||||
GtkWidget *app_entry, *command_entry;
|
GtkWidget *app_entry, *id_entry, *command_entry;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *behavior_frame, *frame_vbox;
|
GtkWidget *behavior_frame, *frame_vbox;
|
||||||
GtkWidget *check_box;
|
GtkWidget *multiple_check_box, *uri_check_box;
|
||||||
GtkWidget *table;
|
GtkWidget *table;
|
||||||
dialog = gnome_dialog_new (_("New Application"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
|
dialog = gnome_dialog_new (_("New Application"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
|
||||||
|
|
||||||
/* Create table */
|
/* Create table */
|
||||||
table = gtk_table_new (3, 2, FALSE);
|
table = gtk_table_new (4, 2, FALSE);
|
||||||
gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog)->vbox), table);
|
gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog)->vbox), table);
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
||||||
|
|
||||||
|
/* Application Name label and entry */
|
||||||
label = gtk_label_new (_("Application Name:"));
|
label = gtk_label_new (_("Application Name:"));
|
||||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 0, 1);
|
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 0, 1);
|
||||||
|
@ -692,25 +715,34 @@ show_new_application_window (void)
|
||||||
app_entry = gtk_entry_new ();
|
app_entry = gtk_entry_new ();
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), app_entry, 1, 2, 0, 1);
|
gtk_table_attach_defaults ( GTK_TABLE (table), app_entry, 1, 2, 0, 1);
|
||||||
|
|
||||||
label = gtk_label_new (_("Application Command:"));
|
/* Application ID label and entry */
|
||||||
|
label = gtk_label_new (_("Application ID:"));
|
||||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 1, 2);
|
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 1, 2);
|
||||||
|
|
||||||
|
id_entry = gtk_entry_new ();
|
||||||
|
gtk_table_attach_defaults ( GTK_TABLE (table), id_entry, 1, 2, 1, 2);
|
||||||
|
|
||||||
|
/* Application Command label and entry */
|
||||||
|
label = gtk_label_new (_("Application Command:"));
|
||||||
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
|
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 2, 3);
|
||||||
|
|
||||||
command_entry = gtk_entry_new ();
|
command_entry = gtk_entry_new ();
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), command_entry, 1, 2, 1, 2);
|
gtk_table_attach_defaults ( GTK_TABLE (table), command_entry, 1, 2, 2, 3);
|
||||||
|
|
||||||
/* Open Behavior frame */
|
/* Open Behavior frame */
|
||||||
behavior_frame = gtk_frame_new (_("Open Behavior"));
|
behavior_frame = gtk_frame_new (_("Open Behavior"));
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), behavior_frame, 0, 2, 2, 3);
|
gtk_table_attach_defaults ( GTK_TABLE (table), behavior_frame, 0, 2, 3, 4);
|
||||||
|
|
||||||
frame_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
frame_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
gtk_container_add (GTK_CONTAINER (behavior_frame), frame_vbox);
|
gtk_container_add (GTK_CONTAINER (behavior_frame), frame_vbox);
|
||||||
|
|
||||||
check_box = gtk_check_button_new_with_label (_("Can open multiple files"));
|
multiple_check_box = gtk_check_button_new_with_label (_("Can open multiple files"));
|
||||||
gtk_box_pack_start (GTK_BOX (frame_vbox), check_box, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (frame_vbox), multiple_check_box, FALSE, FALSE, 0);
|
||||||
|
|
||||||
check_box = gtk_check_button_new_with_label (_("Can open from URI"));
|
uri_check_box = gtk_check_button_new_with_label (_("Can open from URI"));
|
||||||
gtk_box_pack_start (GTK_BOX (frame_vbox), check_box, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (frame_vbox), uri_check_box, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
|
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
|
||||||
|
@ -721,9 +753,10 @@ show_new_application_window (void)
|
||||||
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
|
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
|
||||||
case 0:
|
case 0:
|
||||||
add_new_application (gtk_entry_get_text (GTK_ENTRY (app_entry)),
|
add_new_application (gtk_entry_get_text (GTK_ENTRY (app_entry)),
|
||||||
gtk_entry_get_text (GTK_ENTRY (app_entry)),
|
gtk_entry_get_text (GTK_ENTRY (id_entry)),
|
||||||
gtk_entry_get_text (GTK_ENTRY (command_entry)));
|
gtk_entry_get_text (GTK_ENTRY (command_entry)),
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (multiple_check_box)),
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uri_check_box)));
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
|
@ -737,20 +770,21 @@ show_new_application_window (void)
|
||||||
static void
|
static void
|
||||||
show_edit_application_window (void)
|
show_edit_application_window (void)
|
||||||
{
|
{
|
||||||
GtkWidget *app_entry, *command_entry;
|
GtkWidget *app_entry, *id_entry, *command_entry;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *behavior_frame, *frame_vbox;
|
GtkWidget *behavior_frame, *frame_vbox;
|
||||||
GtkWidget *check_box;
|
GtkWidget *multiple_check_box, *uri_check_box;
|
||||||
GtkWidget *table;
|
GtkWidget *table;
|
||||||
dialog = gnome_dialog_new (_("Edit Application"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
|
dialog = gnome_dialog_new (_("New Application"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
|
||||||
|
|
||||||
/* Create table */
|
/* Create table */
|
||||||
table = gtk_table_new (3, 2, FALSE);
|
table = gtk_table_new (4, 2, FALSE);
|
||||||
gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog)->vbox), table);
|
gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog)->vbox), table);
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
||||||
|
|
||||||
|
/* Application Name label and entry */
|
||||||
label = gtk_label_new (_("Application Name:"));
|
label = gtk_label_new (_("Application Name:"));
|
||||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 0, 1);
|
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 0, 1);
|
||||||
|
@ -758,25 +792,34 @@ show_edit_application_window (void)
|
||||||
app_entry = gtk_entry_new ();
|
app_entry = gtk_entry_new ();
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), app_entry, 1, 2, 0, 1);
|
gtk_table_attach_defaults ( GTK_TABLE (table), app_entry, 1, 2, 0, 1);
|
||||||
|
|
||||||
label = gtk_label_new (_("Application Command:"));
|
/* Application ID label and entry */
|
||||||
|
label = gtk_label_new (_("Application ID:"));
|
||||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 1, 2);
|
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 1, 2);
|
||||||
|
|
||||||
|
id_entry = gtk_entry_new ();
|
||||||
|
gtk_table_attach_defaults ( GTK_TABLE (table), id_entry, 1, 2, 1, 2);
|
||||||
|
|
||||||
|
/* Application Command label and entry */
|
||||||
|
label = gtk_label_new (_("Application Command:"));
|
||||||
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
|
gtk_table_attach_defaults ( GTK_TABLE (table), label, 0, 1, 2, 3);
|
||||||
|
|
||||||
command_entry = gtk_entry_new ();
|
command_entry = gtk_entry_new ();
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), command_entry, 1, 2, 1, 2);
|
gtk_table_attach_defaults ( GTK_TABLE (table), command_entry, 1, 2, 2, 3);
|
||||||
|
|
||||||
/* Open Behavior frame */
|
/* Open Behavior frame */
|
||||||
behavior_frame = gtk_frame_new (_("Open Behavior"));
|
behavior_frame = gtk_frame_new (_("Open Behavior"));
|
||||||
gtk_table_attach_defaults ( GTK_TABLE (table), behavior_frame, 0, 2, 2, 3);
|
gtk_table_attach_defaults ( GTK_TABLE (table), behavior_frame, 0, 2, 3, 4);
|
||||||
|
|
||||||
frame_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
frame_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
gtk_container_add (GTK_CONTAINER (behavior_frame), frame_vbox);
|
gtk_container_add (GTK_CONTAINER (behavior_frame), frame_vbox);
|
||||||
|
|
||||||
check_box = gtk_check_button_new_with_label (_("Can open multiple files"));
|
multiple_check_box = gtk_check_button_new_with_label (_("Can open multiple files"));
|
||||||
gtk_box_pack_start (GTK_BOX (frame_vbox), check_box, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (frame_vbox), multiple_check_box, FALSE, FALSE, 0);
|
||||||
|
|
||||||
check_box = gtk_check_button_new_with_label (_("Can open from URI"));
|
uri_check_box = gtk_check_button_new_with_label (_("Can open from URI"));
|
||||||
gtk_box_pack_start (GTK_BOX (frame_vbox), check_box, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (frame_vbox), uri_check_box, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
|
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
|
||||||
|
@ -787,9 +830,10 @@ show_edit_application_window (void)
|
||||||
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
|
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
|
||||||
case 0:
|
case 0:
|
||||||
add_new_application (gtk_entry_get_text (GTK_ENTRY (app_entry)),
|
add_new_application (gtk_entry_get_text (GTK_ENTRY (app_entry)),
|
||||||
gtk_entry_get_text (GTK_ENTRY (app_entry)),
|
gtk_entry_get_text (GTK_ENTRY (id_entry)),
|
||||||
gtk_entry_get_text (GTK_ENTRY (command_entry)));
|
gtk_entry_get_text (GTK_ENTRY (command_entry)),
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (multiple_check_box)),
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uri_check_box)));
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue