capplets/default-applications/gnome-default-applications-properties-struct

2003-06-25  Christophe Fergeau <teuf@users.sourceforge.net>

	* capplets/default-applications/gnome-default-applications-properties-structs.c
	* capplets/default-applications/gnome-default-applications-properties.c
	* capplets/default-applications/gnome-default-applications-properties.glade
	Added a tab to choose the preferred mailer, added epiphany to the list
	known browsers, don't select any checkbox there is no default browser
	or mailer

2003-06-24  Jody Goldberg <jody@gnome.org>
This commit is contained in:
Christophe Fergeau 2003-06-25 21:49:01 +00:00 committed by Christophe Fergeau
parent 4e66e604e9
commit f4e17b14f9
4 changed files with 433 additions and 29 deletions

View file

@ -1,3 +1,12 @@
2003-06-25 Christophe Fergeau <teuf@users.sourceforge.net>
* capplets/default-applications/gnome-default-applications-properties-structs.c
* capplets/default-applications/gnome-default-applications-properties.c
* capplets/default-applications/gnome-default-applications-properties.glade
Added a tab to choose the preferred mailer, added epiphany to the list
known browsers, don't select any checkbox there is no default browser
or mailer
2003-06-24 Jody Goldberg <jody@gnome.org>
* Release 2.3.3

View file

@ -8,6 +8,15 @@ struct _BrowserDescription
gboolean in_path;
};
struct _MailerDescription
{
gchar *name;
gchar *executable_name;
gchar *command;
gboolean needs_term;
gboolean in_path;
};
struct _HelpViewDescription
{
gchar *name;
@ -27,13 +36,24 @@ struct _TerminalDesciption
BrowserDescription possible_browsers[] =
{
{ "Lynx Text Browser", "lynx", "lynx %s", TRUE, FALSE, FALSE },
{ "Links Text Browser" , "links", "links %s", TRUE, FALSE, FALSE },
{ "Netscape Communicator", "netscape", "netscape %s", FALSE, TRUE, FALSE },
{ "Mozilla/Netscape 6", "mozilla", "mozilla %s", FALSE, TRUE, FALSE },
{ "Epiphany", "epiphany", "epiphany %s", FALSE, FALSE, FALSE },
{ "Galeon", "galeon", "galeon %s", FALSE, FALSE, FALSE },
{ "Encompass", "encompass", "encompass %s", FALSE, FALSE, FALSE },
{ "Konqueror", "konqueror", "konqueror %s", FALSE, FALSE, FALSE }
{ "Mozilla/Netscape 6", "mozilla", "mozilla %s", FALSE, TRUE, FALSE },
{ "Netscape Communicator", "netscape", "netscape %s", FALSE, TRUE, FALSE },
{ "Konqueror", "konqueror", "konqueror %s", FALSE, FALSE, FALSE },
{ "Lynx Text Browser", "lynx", "lynx %s", TRUE, FALSE, FALSE },
{ "Links Text Browser" , "links", "links %s", TRUE, FALSE, FALSE }
};
MailerDescription possible_mailers[] =
{
{ "Evolution Mail Reader", "evolution", "evolution %s", FALSE, FALSE, },
{ "Evolution Mail Reader for GNOME2", "evolution-1.3", "evolution-1.3 %s", FALSE, FALSE, },
{ "Balsa", "balsa", "balsa --compose=%s", FALSE, FALSE },
{ "Mozilla Mail", "mozilla", "mozilla -mail %s", FALSE, FALSE},
{ "Mutt" , "mutt", "mutt %s", TRUE, FALSE },
};
HelpViewDescription possible_help_viewers[] =

View file

@ -39,19 +39,28 @@
#include "capplet-util.h"
#include "gconf-property-editor.h"
#define DEFAULT_APPS_KEY_BROWSER_NEEDS_TERM "/desktop/gnome/url-handlers/unknown/need-terminal"
#define DEFAULT_APPS_KEY_BROWSER_EXEC "/desktop/gnome/url-handlers/unknown/command"
#define DEFAULT_APPS_KEY_HELP_VIEWER_NEEDS_TERM "/desktop/gnome/applications/help_viewer/needs_term"
#define DEFAULT_APPS_KEY_HELP_VIEWER_ACCEPTS_URLS "/desktop/gnome/applications/help_viewer/accepts_urls"
#define DEFAULT_APPS_KEY_HELP_VIEWER_EXEC "/desktop/gnome/applications/help_viewer/exec"
#define DEFAULT_APPS_KEY_BROWSER_PATH "/desktop/gnome/url-handlers/unknown"
#define DEFAULT_APPS_KEY_BROWSER_NEEDS_TERM DEFAULT_APPS_KEY_BROWSER_PATH"/needs_terminal"
#define DEFAULT_APPS_KEY_BROWSER_EXEC DEFAULT_APPS_KEY_BROWSER_PATH"/command"
#define DEFAULT_APPS_KEY_TERMINAL_EXEC_ARG "/desktop/gnome/applications/terminal/exec_arg"
#define DEFAULT_APPS_KEY_TERMINAL_EXEC "/desktop/gnome/applications/terminal/exec"
#define DEFAULT_APPS_KEY_MAILER_PATH "/desktop/gnome/url-handlers/mailto"
#define DEFAULT_APPS_KEY_MAILER_NEEDS_TERM DEFAULT_APPS_KEY_MAILER_PATH"/needs_terminal"
#define DEFAULT_APPS_KEY_MAILER_EXEC DEFAULT_APPS_KEY_MAILER_PATH"/command"
#define DEFAULT_APPS_KEY_HELP_VIEWER_PATH "/desktop/gnome/applications/help_viewer"
#define DEFAULT_APPS_KEY_HELP_VIEWER_NEEDS_TERM DEFAULT_APPS_KEY_HELP_VIEWER_PATH"/needs_term"
#define DEFAULT_APPS_KEY_HELP_VIEWER_ACCEPTS_URLS DEFAULT_APPS_KEY_HELP_VIEWER_PATH"/accepts_urls"
#define DEFAULT_APPS_KEY_HELP_VIEWER_EXEC DEFAULT_APPS_KEY_HELP_VIEWER_PATH"/exec"
#define DEFAULT_APPS_KEY_TERMINAL_PATH "/desktop/gnome/applications/terminal"
#define DEFAULT_APPS_KEY_TERMINAL_EXEC_ARG DEFAULT_APPS_KEY_TERMINAL_PATH"/exec_arg"
#define DEFAULT_APPS_KEY_TERMINAL_EXEC DEFAULT_APPS_KEY_TERMINAL_PATH"/exec"
#define MIME_APPLICATION_ID "gnome-default-applications-editor"
typedef struct _BrowserDescription BrowserDescription;
typedef struct _MailerDescription MailerDescription;
typedef struct _HelpViewDescription HelpViewDescription;
typedef struct _TerminalDesciption TerminalDescription;
@ -159,6 +168,8 @@ on_text_default_viewer_toggle (GtkWidget *toggle, GladeXML *dialog)
static void
generic_guard (GtkWidget *toggle, GtkWidget *widget)
{
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (toggle), FALSE);
gtk_widget_set_sensitive (widget, GTK_TOGGLE_BUTTON (toggle)->active);
if (GTK_TOGGLE_BUTTON (toggle)->active) {
@ -191,6 +202,13 @@ initialize_default_applications (void)
g_free(browsers);
}
}
for (i = 0; i < G_N_ELEMENTS (possible_mailers); i++ ) {
gchar *mailers = g_find_program_in_path (possible_mailers[i].executable_name);
if (mailers) {
possible_mailers[i].in_path = TRUE;
g_free(mailers);
}
}
for (i = 0; i < G_N_ELEMENTS (possible_help_viewers); i++ ) {
gchar *help_viewers = g_find_program_in_path (possible_help_viewers[i].executable_name);
if (help_viewers) {
@ -333,6 +351,11 @@ setup_peditors (GConfClient *client,
gconf_peditor_new_string (changeset, DEFAULT_APPS_KEY_BROWSER_EXEC,
WID ("web_custom_command_entry"), NULL);
gconf_peditor_new_boolean (changeset, DEFAULT_APPS_KEY_MAILER_NEEDS_TERM,
WID ("mail_custom_terminal_toggle"), NULL);
gconf_peditor_new_string (changeset, DEFAULT_APPS_KEY_MAILER_EXEC,
WID ("mail_custom_command_entry"), NULL);
gconf_peditor_new_boolean (changeset, DEFAULT_APPS_KEY_HELP_VIEWER_NEEDS_TERM,
WID ("help_custom_terminal_toggle"), NULL);
gconf_peditor_new_boolean (changeset, DEFAULT_APPS_KEY_HELP_VIEWER_ACCEPTS_URLS,
@ -379,9 +402,47 @@ read_browser (GConfClient *client,
return;
}
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("web_select_radio")), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("web_custom_radio")), TRUE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (WID ("web_select_radio")), TRUE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (WID ("web_custom_radio")), TRUE);
g_free (browser);
}
static void
read_mailer (GConfClient *client,
GladeXML *dialog)
{
GError *error = NULL;
gchar *mailer;
gboolean needs_term;
gint i;
needs_term = gconf_client_get_bool (client, DEFAULT_APPS_KEY_MAILER_NEEDS_TERM, &error);
if (error) {
/* hp will shoot me -- I'll do this later. */
return;
}
mailer = gconf_client_get_string (client, DEFAULT_APPS_KEY_MAILER_EXEC, &error);
if (error) {
return;
}
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")),
_(possible_mailers[i].name));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("mail_custom_radio")), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("mail_select_radio")), TRUE);
g_free (mailer);
return;
}
}
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (WID ("mail_select_radio")), TRUE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (WID ("mail_custom_radio")), TRUE);
g_free (mailer);
}
@ -404,6 +465,23 @@ browser_setup_custom (GtkWidget *entry,
}
}
static void
mailer_setup_custom (GtkWidget *entry,
GladeXML *dialog)
{
gint i;
const gchar *mailer = gtk_entry_get_text (GTK_ENTRY (entry));
for (i = 0; i < G_N_ELEMENTS (possible_mailers); i++ ) {
if (! strcmp (_(possible_mailers[i].name), mailer)) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("mail_custom_terminal_toggle")),
possible_mailers[i].needs_term);
gtk_entry_set_text (GTK_ENTRY (WID ("mail_custom_command_entry")),
possible_mailers[i].command);
return;
}
}
}
static void
read_help_viewer (GConfClient *client,
@ -539,11 +617,11 @@ value_changed_cb (GConfClient *client,
GladeXML *dialog)
{
g_return_if_fail (key != NULL);
if (strncmp (key, "/desktop/gnome/applications/editor", strlen ("/desktop/gnome/applications/editor")) == 0) {
} else if (strncmp (key, "/desktop/gnome/applications/browser/exec", strlen ("/desktop/gnome/applications/browser/exec")) == 0) {
} else if (strncmp (key, "/desktop/gnome/applications/help_viewer", strlen ("/desktop/gnome/applications/help_viewer")) == 0) {
} else if (strncmp (key, "/desktop/gnome/applications/terminal", strlen ("/desktop/gnome/applications/terminal")) == 0) {
if (strncmp (key, DEFAULT_APPS_KEY_MAILER_PATH, strlen (DEFAULT_APPS_KEY_MAILER_PATH)) == 0) {
gconf_client_set_bool (client, DEFAULT_APPS_KEY_MAILER_PATH"/enabled", TRUE, NULL);
} else if (strncmp (key, DEFAULT_APPS_KEY_BROWSER_PATH, strlen (DEFAULT_APPS_KEY_BROWSER_PATH)) == 0) {
} else if (strncmp (key, DEFAULT_APPS_KEY_HELP_VIEWER_PATH, strlen (DEFAULT_APPS_KEY_HELP_VIEWER_PATH)) == 0) {
} else if (strncmp (key, DEFAULT_APPS_KEY_TERMINAL_PATH, strlen (DEFAULT_APPS_KEY_TERMINAL_PATH)) == 0) {
}
}
@ -625,14 +703,46 @@ create_dialog (GConfClient *client)
"changed", (GCallback) browser_setup_custom,
dialog);
g_signal_connect (G_OBJECT (WID ("web_select_radio")),
"toggled", (GCallback) generic_guard,
"clicked", (GCallback) generic_guard,
WID ("web_select_combo"));
g_signal_connect (G_OBJECT (WID ("web_custom_radio")),
"toggled", (GCallback) generic_guard,
"clicked", (GCallback) generic_guard,
WID ("web_custom_vbox"));
read_browser (client, dialog);
/* Mail readers page */
for (i = 0; i < G_N_ELEMENTS (possible_mailers); i++ ) {
if (possible_mailers[i].in_path)
strings = g_list_append (strings, _(possible_mailers[i].name));
}
if (strings) {
/* We have default browsers */
gtk_combo_set_popdown_strings (GTK_COMBO(WID ("mail_select_combo")), strings);
g_list_free (strings);
strings = NULL;
} else {
/* No default browsers */
gtk_widget_set_sensitive (WID ("mail_select_radio"), FALSE);
}
/* Source of command string */
g_object_set_data (G_OBJECT (WID ("mail_select_radio")), "entry", WID ("mail_select_combo_entry"));
/* Source of command string */
g_object_set_data (G_OBJECT (WID ("mail_custom_radio")), "entry", WID ("mail_custom_command_entry"));
g_signal_connect (G_OBJECT (WID ("mail_select_combo_entry")),
"changed", (GCallback) mailer_setup_custom,
dialog);
g_signal_connect (G_OBJECT (WID ("mail_select_radio")),
"clicked", (GCallback) generic_guard,
WID ("mail_select_combo"));
g_signal_connect (G_OBJECT (WID ("mail_custom_radio")),
"clicked", (GCallback) generic_guard,
WID ("mail_custom_vbox"));
read_mailer (client, dialog);
/* Help page */
for (i = 0; i < G_N_ELEMENTS (possible_help_viewers); i++ ) {

View file

@ -2,6 +2,7 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<widget class="GtkDialog" id="default_applications_dialog">
<property name="title" translatable="yes">Preferred Applications</property>
@ -14,17 +15,14 @@
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="border_width">2</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">8</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">10</property>
<child>
<widget class="GtkButton" id="button5">
@ -66,8 +64,6 @@
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="tab_hborder">2</property>
<property name="tab_vborder">2</property>
<property name="enable_popup">False</property>
<child>
@ -355,6 +351,278 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame6">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkTable" id="table6">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">16</property>
<property name="column_spacing">4</property>
<child>
<widget class="GtkRadioButton" id="mail_select_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Select a Mail Reader:</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCombo" id="mail_select_combo">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="value_in_list">False</property>
<property name="allow_empty">True</property>
<property name="case_sensitive">False</property>
<property name="enable_arrow_keys">True</property>
<property name="enable_arrows_always">False</property>
<child internal-child="entry">
<widget class="GtkEntry" id="mail_select_combo_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
</child>
<child internal-child="list">
<widget class="GtkList" id="list1">
<property name="visible">True</property>
<property name="selection_mode">GTK_SELECTION_BROWSE</property>
<child>
<widget class="GtkListItem" id="listitem1">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="mail_custom_vbox">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="homogeneous">False</property>
<property name="spacing">4</property>
<child>
<widget class="GtkHBox" id="hbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">4</property>
<child>
<widget class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="label" translatable="yes">Co_mmand:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">web_custom_command_entry</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="mail_custom_command_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="mail_custom_terminal_toggle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Start in T_erminal</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0</property>
<property name="xscale">1</property>
<property name="yscale">0</property>
<child>
<widget class="GtkRadioButton" id="mail_custom_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">C_ustom Mail Reader:</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">mail_select_radio</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="label" translatable="yes">Default Mail Reader</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="label" translatable="yes">Mail Reader</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame1">
<property name="border_width">4</property>
@ -1384,17 +1652,14 @@
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
<property name="border_width">2</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">10</property>
<child>
<widget class="GtkButton" id="button8">