Unique-ify the lists so that we can handle multiple excutable names for

2004-02-13  Jody Goldberg <jody@gnome.org>

	* gnome-default-applications-properties.c : Unique-ify the lists so
	  that we can handle multiple excutable names for the same browser
	  when the list jumps to gconf.  Remove the vile hack specifict to
	  evolution.

	* gnome-default-applications-properties-structs.c (};) : remove the
	  nremote flag and add a few new browsers.
This commit is contained in:
Jody Goldberg 2004-02-13 14:29:30 +00:00 committed by Jody Goldberg
parent ff003126bb
commit ed7b26ff46
3 changed files with 101 additions and 114 deletions

View file

@ -1,3 +1,13 @@
2004-02-13 Jody Goldberg <jody@gnome.org>
* gnome-default-applications-properties.c : Unique-ify the lists so
that we can handle multiple excutable names for the same browser
when the list jumps to gconf. Remove the vile hack specifict to
evolution.
* gnome-default-applications-properties-structs.c (};) : remove the
nremote flag and add a few new browsers.
2004-02-12 Mark McLoughlin <mark@skynet.ie>
* gnome-default-applications-properties.c: (dialog_response): Update

View file

@ -1,71 +1,55 @@
struct _BrowserDescription
{
gchar *name;
gchar *executable_name;
gchar *command;
gboolean needs_term;
gboolean nremote;
gboolean in_path;
};
struct _MailerDescription
{
gchar *name;
gchar *executable_name;
gchar *command;
struct _BrowserDescription {
gchar const *name;
gchar const *executable_name;
gchar const *command;
gboolean needs_term;
gboolean in_path;
};
BrowserDescription possible_browsers[] = {
{ N_("Epiphany"), "epiphany", "epiphany %s", FALSE, FALSE },
{ N_("Galeon"), "galeon", "galeon %s", FALSE, FALSE },
{ N_("Encompass"), "encompass", "encompass %s", FALSE, FALSE },
{ N_("Firebird/FireFox"), "mozilla-firebird", "mozilla-firebird %s", FALSE, FALSE },
{ N_("Mozilla/Netscape 6"), "mozilla-1.6", "mozilla-1.6 %s", FALSE, FALSE },
{ N_("Mozilla/Netscape 6"), "mozilla", "mozilla %s", FALSE, FALSE },
{ N_("Netscape Communicator"), "netscape", "netscape %s", FALSE, FALSE },
{ N_("Konqueror"), "konqueror", "konqueror %s", FALSE, FALSE },
{ N_("W3M Text Browser"), "w3n", "w3m %s", TRUE, FALSE },
{ N_("Lynx Text Browser"), "lynx", "lynx %s", TRUE, FALSE },
{ N_("Links Text Browser") , "links", "links %s", TRUE, FALSE }
};
struct _HelpViewDescription
{
gchar *name;
gchar *executable_name;
struct _MailerDescription {
gchar const *name;
gchar const *executable_name;
gchar const *command;
gboolean needs_term;
gboolean accepts_urls;
gboolean in_path;
};
struct _TerminalDesciption
{
gchar *name;
gchar *exec;
gchar *exec_arg;
gboolean in_path;
};
BrowserDescription possible_browsers[] =
{
{ N_("Epiphany"), "epiphany", "epiphany %s", FALSE, FALSE, FALSE },
{ N_("Galeon"), "galeon", "galeon %s", FALSE, FALSE, FALSE },
{ N_("Encompass"), "encompass", "encompass %s", FALSE, FALSE, FALSE },
{ N_("Mozilla/Netscape 6"), "mozilla", "mozilla %s", FALSE, TRUE, FALSE },
{ N_("Netscape Communicator"), "netscape", "netscape %s", FALSE, TRUE, FALSE },
{ N_("Konqueror"), "konqueror", "konqueror %s", FALSE, FALSE, FALSE },
{ N_("Lynx Text Browser"), "lynx", "lynx %s", TRUE, FALSE, FALSE },
{ N_("Links Text Browser") , "links", "links %s", TRUE, FALSE, FALSE }
};
MailerDescription possible_mailers[] =
{
MailerDescription possible_mailers[] = {
/* The code in gnome-default-applications-properties.c makes sure
* there is only one (the first entry in this list) Evolution entry
* in the list shown to the user
*/
{ N_("Evolution Mail Reader"), "evolution-1.4", "evolution-1.4 %s", FALSE, FALSE, },
{ N_("Evolution Mail Reader"), "evolution", "evolution %s", FALSE, FALSE, },
{ N_("Balsa"), "balsa", "balsa --compose=%s", FALSE, FALSE },
{ N_("KMail"), "kmail", "kmail %s", FALSE, FALSE },
{ N_("Mozilla Mail"), "mozilla", "mozilla -mail %s", FALSE, FALSE},
{ N_("Mutt") , "mutt", "mutt %s", TRUE, FALSE },
{ N_("Evolution Mail Reader"), "evolution-1.4", "evolution-1.4 %s", FALSE, FALSE, },
{ N_("Evolution Mail Reader"), "evolution", "evolution %s", FALSE, FALSE, },
{ N_("Balsa"), "balsa", "balsa --compose=%s", FALSE, FALSE },
{ N_("KMail"), "kmail", "kmail %s", FALSE, FALSE },
{ N_("Mozilla Mail"), "mozilla", "mozilla -mail %s", FALSE, FALSE},
{ N_("Mutt") , "mutt", "mutt %s", TRUE, FALSE },
};
TerminalDescription possible_terminals[] =
{
{ N_("Gnome Terminal"), "gnome-terminal", "-x", FALSE },
{ N_("Standard XTerminal"), "xterm", "-e", FALSE },
{ N_("NXterm"), "nxterm", "-e", FALSE },
{ N_("RXVT"), "rxvt", "-e", FALSE },
{ N_("ETerm"), "Eterm", "-e", FALSE }
struct _TerminalDesciption {
gchar const *name;
gchar const *exec;
gchar const *exec_arg;
gboolean in_path;
};
TerminalDescription possible_terminals[] = {
{ N_("Gnome Terminal"), "gnome-terminal", "-x", FALSE },
{ N_("Standard XTerminal"), "xterm", "-e", FALSE },
{ N_("NXterm"), "nxterm", "-e", FALSE },
{ N_("RXVT"), "rxvt", "-e", FALSE },
{ N_("ETerm"), "Eterm", "-e", FALSE }
};

View file

@ -117,7 +117,7 @@ on_text_custom_properties_clicked (GtkWidget *w, GladeXML *dialog)
g_free (mime_app->name);
g_free (mime_app->command);
} else {
mime_app = g_new0 (GnomeVFSMimeApplication, 1);
mime_app = g_new0 (GnomeVFSMimeApplication, 1);
mime_app->id = g_strdup (MIME_APPLICATION_ID);
}
@ -139,7 +139,7 @@ on_text_custom_properties_clicked (GtkWidget *w, GladeXML *dialog)
gnome_vfs_mime_set_default_application ("text/plain", mime_app->id);
gnome_vfs_mime_application_free (mime_app);
gnome_vfs_application_registry_sync ();
gnome_vfs_application_registry_sync ();
}
static void
@ -149,7 +149,7 @@ on_text_default_viewer_toggle (GtkWidget *toggle, GladeXML *dialog)
old_action_type = gnome_vfs_mime_get_default_action_type ("text/plain");
new_action_type = GTK_TOGGLE_BUTTON (toggle)->active
? GNOME_VFS_MIME_ACTION_TYPE_APPLICATION
? GNOME_VFS_MIME_ACTION_TYPE_APPLICATION
: GNOME_VFS_MIME_ACTION_TYPE_COMPONENT;
if (new_action_type == old_action_type)
@ -182,56 +182,50 @@ generic_guard (GtkWidget *toggle, GtkWidget *widget)
}
}
static gboolean
validate (GHashTable *unique, char const *name, char const *exec_name)
{
if (NULL == g_hash_table_lookup (unique, name)) {
char *path = g_find_program_in_path (exec_name);
if (path != NULL) {
g_hash_table_insert (unique, (gpointer)name, (gpointer)exec_name);
g_free (path);
return TRUE;
}
}
return FALSE;
}
static void
initialize_default_applications (void)
{
gint i;
/* This is used to only have one Evolution entry in the dropdown box
* in case the user has installed both evo for gnome1 and for gnome2
*/
gboolean evo_already_in_list = FALSE;
GHashTable *unique;
text_editors = gnome_vfs_mime_get_all_applications ("text/plain");
for (i = 0; i < G_N_ELEMENTS (possible_browsers); i++ ) {
gchar *browsers = g_find_program_in_path (possible_browsers[i].executable_name);
if (browsers) {
possible_browsers[i].in_path = TRUE;
g_free(browsers);
}
}
for (i = 0; i < G_N_ELEMENTS (possible_mailers); i++ ) {
gchar *mailers;
gchar *exec_name = possible_mailers[i].executable_name;
unique = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (possible_browsers); i++ )
possible_browsers[i].in_path = validate (unique,
possible_browsers[i].name, possible_browsers[i].executable_name);
g_hash_table_destroy (unique);
mailers = g_find_program_in_path (exec_name);
if (mailers) {
if (g_str_has_prefix (exec_name, "evolution")) {
if (evo_already_in_list) {
g_free (mailers);
continue;
} else {
evo_already_in_list = TRUE;
}
}
unique = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (possible_mailers); i++ )
possible_mailers[i].in_path = validate (unique,
possible_mailers[i].name, possible_mailers[i].executable_name);
g_hash_table_destroy (unique);
possible_mailers[i].in_path = TRUE;
g_free(mailers);
}
}
for (i = 0; i < G_N_ELEMENTS (possible_terminals); i++ ) {
gchar *terminals = g_find_program_in_path (possible_terminals[i].exec);
if (terminals) {
possible_terminals[i].in_path = TRUE;
g_free (terminals);
}
}
unique = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (possible_terminals); i++ )
possible_terminals[i].in_path = validate (unique,
possible_terminals[i].name, possible_terminals[i].exec);
g_hash_table_destroy (unique);
}
static void
update_editor_sensitivity (GladeXML *dialog)
{
{
gboolean predefined = GTK_TOGGLE_BUTTON (WID ("text_select_radio"))->active;
gtk_widget_set_sensitive (WID ("text_select_combo"), predefined);
@ -266,7 +260,7 @@ read_editor (GConfClient *client,
}
}
/*
/*
* the default editor wasn't set by us, and it wasn't in the
* list.
*/
@ -277,7 +271,7 @@ read_editor (GConfClient *client,
gnome_vfs_application_registry_save_mime_application (mime_app);
gnome_vfs_mime_set_default_application ("text/plain", mime_app->id);
gnome_vfs_application_registry_sync ();
gnome_vfs_application_registry_sync ();
read_editor_custom:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("text_select_radio")), TRUE);
@ -309,7 +303,7 @@ text_apply_editor (GtkWidget *entry,
mime_app = li->data;
if (! strcmp (mime_app->name, editor)) {
gnome_vfs_mime_set_default_application ("text/plain", mime_app->id);
gnome_vfs_application_registry_sync ();
gnome_vfs_application_registry_sync ();
return;
}
}
@ -337,19 +331,19 @@ text_apply_custom (GtkWidget *entry,
} else {
gnome_vfs_mime_set_default_application ("text/plain", mime_app->id);
gnome_vfs_mime_application_free (mime_app);
gnome_vfs_application_registry_sync ();
gnome_vfs_application_registry_sync ();
}
update_editor_sensitivity (dialog);
}
static void
static void
setup_peditors (GConfClient *client,
GladeXML *dialog)
{
GConfChangeSet *changeset = NULL;
gconf_peditor_new_boolean (changeset, DEFAULT_APPS_KEY_BROWSER_NEEDS_TERM,
WID ("web_custom_terminal_toggle"), NULL);
gconf_peditor_new_string (changeset, DEFAULT_APPS_KEY_BROWSER_EXEC,
@ -388,7 +382,7 @@ read_browser (GConfClient *client,
for (i = 0; i < G_N_ELEMENTS (possible_browsers); i++ ) {
if (possible_browsers[i].in_path == FALSE)
continue;
if (browser && strcmp (browser, possible_browsers[i].command) == 0 &&
needs_term == possible_browsers[i].needs_term) {
gtk_entry_set_text (GTK_ENTRY (WID ("web_select_combo_entry")),
@ -426,7 +420,7 @@ read_mailer (GConfClient *client,
for (i = 0; i < G_N_ELEMENTS (possible_mailers); i++ ) {
if (possible_mailers[i].in_path == FALSE)
continue;
if (mailer && strcmp (mailer, possible_mailers[i].command) == 0 &&
needs_term == possible_mailers[i].needs_term) {
gtk_entry_set_text (GTK_ENTRY (WID ("mail_select_combo_entry")),
@ -441,7 +435,7 @@ read_mailer (GConfClient *client,
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (WID ("mail_custom_radio")), TRUE);
g_free (mailer);
}
static void
@ -505,7 +499,7 @@ read_terminal (GConfClient *client,
for (i = 0; i < G_N_ELEMENTS (possible_terminals); i++ ) {
if (possible_terminals[i].in_path == FALSE)
continue;
if (strcmp (exec?exec:"", possible_terminals[i].exec) == 0 &&
strcmp (exec_arg?exec_arg:"", possible_terminals[i].exec_arg) == 0) {
gtk_entry_set_text (GTK_ENTRY (WID ("terminal_select_combo_entry")),
@ -572,7 +566,7 @@ create_dialog (GConfClient *client)
gint i;
dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gnome-default-applications-properties.glade", NULL, NULL);
capplet_set_icon (WID ("default_applications_dialog"), "default-applications-capplet.png");
setup_peditors (client, dialog);
/* Editors page */
@ -595,7 +589,7 @@ create_dialog (GConfClient *client)
g_signal_connect (G_OBJECT (WID ("text_select_combo_entry")),
"changed", G_CALLBACK (text_apply_editor),
dialog);
g_signal_connect (WID ("text_custom_properties"), "clicked",
g_signal_connect (WID ("text_custom_properties"), "clicked",
G_CALLBACK (on_text_custom_properties_clicked),
dialog);
g_signal_connect (WID ("text_default_viewer_toggle"), "toggled",
@ -673,7 +667,7 @@ create_dialog (GConfClient *client)
/* Terminal */
for (i = 0; i < G_N_ELEMENTS (possible_terminals); i++ ) {
if (possible_terminals[i].in_path)
strings = g_list_append (strings, _(possible_terminals[i].name));
@ -702,21 +696,20 @@ create_dialog (GConfClient *client)
g_signal_connect (G_OBJECT (WID ("terminal_custom_radio")),
"toggled", (GCallback) generic_guard,
WID ("terminal_custom_table"));
read_terminal (client, dialog);
read_terminal (client, dialog);
g_signal_connect (G_OBJECT (client), "value-changed", (GCallback) value_changed_cb, dialog);
g_signal_connect (G_OBJECT (WID ("default_applications_dialog")), "response", (GCallback) dialog_response, dialog);
gtk_widget_show (WID ("default_applications_dialog"));
return dialog;
}
static void
get_legacy_settings (void)
get_legacy_settings (void)
{
}
int