http://bugzilla.gnome.org/show_bug.cgi?id=426638 Index: capplets/default-applications/gnome-da-capplet.c ================================================================================ --- capplets/default-applications/gnome-da-capplet.c +++ capplets/default-applications/gnome-da-capplet.c @@ -63,9 +63,15 @@ if (widget == capplet->web_browser_command_entry) { gconf_client_set_string (capplet->gconf, DEFAULT_APPS_KEY_HTTP_EXEC, text, &error); } + else if (widget == capplet->ftp_client_command_entry) { + gconf_client_set_string (capplet->gconf, DEFAULT_APPS_KEY_FTP_EXEC, text, &error); + } else if (widget == capplet->mail_reader_command_entry) { gconf_client_set_string (capplet->gconf, DEFAULT_APPS_KEY_MAILER_EXEC, text, &error); } + else if (widget == capplet->news_reader_command_entry) { + gconf_client_set_string (capplet->gconf, DEFAULT_APPS_KEY_NEWS_EXEC, text, &error); + } else if (widget == capplet->terminal_command_entry) { gconf_client_set_string (capplet->gconf, DEFAULT_APPS_KEY_TERMINAL_EXEC, text, &error); } @@ -98,15 +104,22 @@ is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (togglebutton)); - if (togglebutton == capplet->web_browser_terminal_checkbutton) { - gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_HTTP_NEEDS_TERM, is_active, &error); - } - else if (togglebutton == capplet->mail_reader_terminal_checkbutton) { - gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_MAILER_NEEDS_TERM, is_active, &error); - } - else if (togglebutton == capplet->media_player_terminal_checkbutton) { - gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_MEDIA_NEEDS_TERM, is_active, &error); - } + + if (GTK_WIDGET (togglebutton) == capplet->web_browser_terminal_checkbutton) { + gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_HTTP_NEEDS_TERM, is_active, &error); + } + else if (GTK_WIDGET (togglebutton) == capplet->ftp_client_terminal_checkbutton) { + gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_FTP_NEEDS_TERM, is_active, &error); + } + else if (GTK_WIDGET (togglebutton) == capplet->mail_reader_terminal_checkbutton) { + gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_MAILER_NEEDS_TERM, is_active, &error); + } + else if (GTK_WIDGET (togglebutton) == capplet->news_reader_terminal_checkbutton) { + gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_NEWS_NEEDS_TERM, is_active, &error); + } + else if (GTK_WIDGET (togglebutton) == capplet->media_player_terminal_checkbutton) { + gconf_client_set_bool (capplet->gconf, DEFAULT_APPS_KEY_MEDIA_NEEDS_TERM, is_active, &error); + } if (error != NULL) { g_warning (_("Error saving configuration: %s"), error->message); @@ -248,6 +261,97 @@ /* FIXME: Refactor these two functions below into one... */ static void +ftp_combo_changed_cb (GtkComboBox *combo, GnomeDACapplet *capplet) +{ + GtkTreeIter iter; + GtkTreePath *path; + guint current_index; + gboolean is_custom_active; + GnomeDAFtpItem *item; + GConfChangeSet *cs; + GError *error = NULL; + char *ftp_cmd; + gboolean ftp_term; + + gtk_combo_box_get_active_iter (combo, &iter); + path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo), &iter); + current_index = gtk_tree_path_get_indices (path)[0]; + gtk_tree_path_free (path); + + if (current_index == 0) { + is_custom_active = FALSE; + cs = gconf_change_set_new (); + gconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_FTP_ENABLED, FALSE); + + gconf_client_commit_change_set (capplet->gconf, cs, TRUE, &error); + + if (error != NULL) { + g_warning (_("Error saving configuration: %s"), error->message); + g_error_free (error); + error = NULL; + } + ftp_cmd = g_strdup (""); + + } else { + if (current_index == 1) { + is_custom_active = FALSE; + cs = gconf_change_set_new (); + ftp_cmd = gconf_client_get_string (capplet->gconf, DEFAULT_APPS_KEY_HTTP_EXEC, NULL); + gconf_change_set_set_string (cs, DEFAULT_APPS_KEY_FTP_EXEC, ftp_cmd); + g_free (ftp_cmd); + ftp_term = gconf_client_get_bool (capplet->gconf, DEFAULT_APPS_KEY_HTTP_NEEDS_TERM, NULL); + gconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_FTP_NEEDS_TERM, ftp_term); + gconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_FTP_ENABLED, TRUE); + + gconf_client_commit_change_set (capplet->gconf, cs, TRUE, &error); + + if (error != NULL) { + g_warning (_("Error saving configuration: %s"), error->message); + g_error_free (error); + error = NULL; + } + } + else { + current_index -= 2; + if (current_index < g_list_length (capplet->ftp_clients)) { + item = (GnomeDAFtpItem*) g_list_nth_data (capplet->ftp_clients, current_index); + is_custom_active = FALSE; + + cs = gconf_change_set_new (); + + gconf_change_set_set_string (cs, DEFAULT_APPS_KEY_FTP_EXEC, item->generic.command); + gconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_FTP_NEEDS_TERM, item->run_in_terminal); + gconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_FTP_ENABLED, TRUE); + + gconf_client_commit_change_set (capplet->gconf, cs, TRUE, &error); + + if (error != NULL) { + g_warning (_("Error saving configuration: %s"), error->message); + g_error_free (error); + error = NULL; + } + + gconf_change_set_unref (cs); + } + else { + is_custom_active = TRUE; + } + + } + ftp_cmd = gconf_client_get_string (capplet->gconf, DEFAULT_APPS_KEY_FTP_EXEC, NULL); + + } + gtk_entry_set_text (GTK_ENTRY (capplet->ftp_client_command_entry), ftp_cmd); + g_free (ftp_cmd); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->ftp_client_terminal_checkbutton), + gconf_client_get_bool (capplet->gconf, DEFAULT_APPS_KEY_FTP_NEEDS_TERM, NULL)); + + gtk_editable_set_editable (GTK_EDITABLE (capplet->ftp_client_command_entry), is_custom_active); + gtk_widget_set_sensitive (capplet->ftp_client_command_label, is_custom_active); + gtk_widget_set_sensitive (capplet->ftp_client_terminal_checkbutton, is_custom_active); +} + +static void mail_combo_changed_cb (GtkComboBox *combo, GnomeDACapplet *capplet) { GtkTreeIter iter; @@ -350,6 +454,57 @@ } static void +news_combo_changed_cb (GtkComboBox *combo, GnomeDACapplet *capplet) +{ + GtkTreeIter iter; + GtkTreePath *path; + guint current_index; + gboolean is_custom_active; + GnomeDANewsItem *item; + GConfChangeSet *cs; + GError *error = NULL; + char *news_cmd; + + gtk_combo_box_get_active_iter (combo, &iter); + path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo), &iter); + current_index = gtk_tree_path_get_indices (path)[0]; + gtk_tree_path_free (path); + + if (current_index < g_list_length (capplet->news_readers)) { + item = (GnomeDANewsItem*) g_list_nth_data (capplet->news_readers, current_index); + is_custom_active = FALSE; + + cs = gconf_change_set_new (); + + gconf_change_set_set_string (cs, DEFAULT_APPS_KEY_NEWS_EXEC, item->generic.command); + gconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_NEWS_NEEDS_TERM, item->run_in_terminal); + + gconf_client_commit_change_set (capplet->gconf, cs, TRUE, &error); + + if (error != NULL) { + g_warning (_("Error saving configuration: %s"), error->message); + g_error_free (error); + error = NULL; + } + + gconf_change_set_unref (cs); + } + else { + is_custom_active = TRUE; + } + + news_cmd = gconf_client_get_string (capplet->gconf, DEFAULT_APPS_KEY_NEWS_EXEC, NULL); + gtk_entry_set_text (GTK_ENTRY (capplet->news_reader_command_entry), news_cmd); + g_free (news_cmd); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->news_reader_terminal_checkbutton), + gconf_client_get_bool (capplet->gconf, DEFAULT_APPS_KEY_NEWS_NEEDS_TERM, NULL)); + + gtk_editable_set_editable (GTK_EDITABLE (capplet->news_reader_command_entry), is_custom_active); + gtk_widget_set_sensitive (capplet->news_reader_command_label, is_custom_active); + gtk_widget_set_sensitive (capplet->news_reader_terminal_checkbutton, is_custom_active); +} + +static void terminal_combo_changed_cb (GtkComboBox *combo, GnomeDACapplet *capplet) { GtkTreeIter iter; @@ -533,7 +688,9 @@ const gchar *icon; } icons[] = { { "web_browser_image", "web-browser" }, + { "ftp_client_image", "folder-remove" }, { "mail_reader_image", "stock_mail-open" }, + { "news_reader_image", "stock_news" }, { "media_player_image", "gnome-audio" }, { "visual_image", "zoom-best-fit" }, { "mobility_image", "preferences-desktop-accessibility" }, @@ -556,7 +713,9 @@ } refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers); + refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->ftp_combo_box), capplet->ftp_clients); refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers); + refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->news_combo_box), capplet->news_readers); refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->media_combo_box), capplet->media_players); refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->term_combo_box), capplet->terminals); refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->visual_combo_box), capplet->visual_ats); @@ -684,6 +843,46 @@ /* FIXME: Refactor these two functions below into single one... */ static void +ftp_client_update_combo_box (GnomeDACapplet *capplet, const gchar *command) +{ + GList *entry; + gint index; + gboolean is_custom_active; + + if (!command) { + index = 0; + is_custom_active = FALSE; + } + else if (!strcmp (command, gtk_entry_get_text (GTK_ENTRY (capplet->web_browser_command_entry)))) { + is_custom_active = FALSE; + index = 1; + } + else { + + entry = g_list_find_custom (capplet->ftp_clients, command, (GCompareFunc) generic_item_comp); + + if (entry) { + index = g_list_position (capplet->ftp_clients, entry) + 2; + is_custom_active = FALSE; + } + else { + /* index of 'Custom' combo box entry */ + index = g_list_length (capplet->ftp_clients) + 3; + is_custom_active = TRUE; + } + } + + gtk_entry_set_text (GTK_ENTRY (capplet->ftp_client_command_entry), (command ? command : "")); + + gtk_editable_set_editable (GTK_EDITABLE (capplet->ftp_client_command_entry), is_custom_active); + gtk_widget_set_sensitive (capplet->ftp_client_command_label, is_custom_active); + gtk_widget_set_sensitive (capplet->ftp_client_terminal_checkbutton, is_custom_active); + + if (gtk_combo_box_get_active (GTK_COMBO_BOX (capplet->ftp_combo_box)) != index) + gtk_combo_box_set_active (GTK_COMBO_BOX (capplet->ftp_combo_box), index); +} + +static void mail_reader_update_combo_box (GnomeDACapplet *capplet, const gchar *command) { GList *entry; @@ -742,6 +941,35 @@ } static void +news_reader_update_combo_box (GnomeDACapplet *capplet, const gchar *command) +{ + GList *entry; + gint index; + gboolean is_custom_active; + + entry = g_list_find_custom (capplet->news_readers, command, (GCompareFunc) generic_item_comp); + + if (entry) { + index = g_list_position (capplet->news_readers, entry); + is_custom_active = FALSE; + } + else { + /* index of 'Custom' combo box entry */ + index = g_list_length (capplet->news_readers) + 1; + is_custom_active = TRUE; + } + + gtk_entry_set_text (GTK_ENTRY (capplet->news_reader_command_entry), command); + + gtk_editable_set_editable (GTK_EDITABLE (capplet->news_reader_command_entry), is_custom_active); + gtk_widget_set_sensitive (capplet->news_reader_command_label, is_custom_active); + gtk_widget_set_sensitive (capplet->news_reader_terminal_checkbutton, is_custom_active); + + if (gtk_combo_box_get_active (GTK_COMBO_BOX (capplet->news_combo_box)) != index) + gtk_combo_box_set_active (GTK_COMBO_BOX (capplet->news_combo_box), index); +} + +static void terminal_update_combo_box (GnomeDACapplet *capplet, const gchar *command) { GList *entry; @@ -836,11 +1064,20 @@ GError *error = NULL; GList *list_entry; + GtkTreeIter iter; + GtkTreePath *path; + guint current_index; + g_return_if_fail (gconf_entry_get_key (entry) != NULL); if (!(value = gconf_entry_get_value (entry))) return; + gtk_combo_box_get_active_iter (GTK_COMBO_BOX (capplet->ftp_combo_box), &iter); + path = gtk_tree_model_get_path (gtk_combo_box_get_model (GTK_COMBO_BOX (capplet->ftp_combo_box)), &iter); + current_index = gtk_tree_path_get_indices (path)[0]; + gtk_tree_path_free (path); + if (strcmp (entry->key, DEFAULT_APPS_KEY_HTTP_EXEC) == 0) { gchar *short_browser, *pos; const gchar *value_str = gconf_value_get_string (value); @@ -853,6 +1090,9 @@ gconf_change_set_set (cs, DEFAULT_APPS_KEY_HTTPS_EXEC, value); gconf_change_set_set (cs, DEFAULT_APPS_KEY_UNKNOWN_EXEC, value); gconf_change_set_set (cs, DEFAULT_APPS_KEY_ABOUT_EXEC, value); + if (current_index == 1) { + gconf_change_set_set (cs, DEFAULT_APPS_KEY_FTP_EXEC, value); + } pos = strstr (value_str, " "); if (pos == NULL) short_browser = g_strdup (value_str); @@ -892,6 +1132,9 @@ gconf_change_set_set (cs, DEFAULT_APPS_KEY_UNKNOWN_NEEDS_TERM, value); gconf_change_set_set (cs, DEFAULT_APPS_KEY_ABOUT_NEEDS_TERM, value); gconf_change_set_set (cs, DEFAULT_APPS_KEY_BROWSER_NEEDS_TERM, value); + if (current_index == 1) { + gconf_change_set_set (cs, DEFAULT_APPS_KEY_FTP_NEEDS_TERM, value); + } gconf_client_commit_change_set (capplet->gconf, cs, TRUE, &error); @@ -907,6 +1150,35 @@ /* FIXME: Refactor these two functions below into single one... */ static void +ftp_gconf_changed_cb (GConfClient *client, guint id, GConfEntry *entry, GnomeDACapplet *capplet) +{ + GConfValue *value; + + g_return_if_fail (gconf_entry_get_key (entry) != NULL); + + if (!(value = gconf_entry_get_value (entry))) + return; + + if (strcmp (entry->key, DEFAULT_APPS_KEY_FTP_ENABLED) == 0) { + if (gconf_value_get_bool (value)) + ftp_client_update_combo_box (capplet, gconf_client_get_string (capplet->gconf, DEFAULT_APPS_KEY_FTP_EXEC, NULL)); + else + ftp_client_update_combo_box (capplet, NULL); + } + if (strcmp (entry->key, DEFAULT_APPS_KEY_FTP_EXEC) == 0) { + if (gconf_client_get_bool (capplet->gconf, DEFAULT_APPS_KEY_FTP_ENABLED, NULL)) + ftp_client_update_combo_box (capplet, gconf_value_get_string (value)); + else + ftp_client_update_combo_box (capplet, NULL); + } + /* TODO: Remove when GConfPropertyEditor will be used */ + else if (strcmp (entry->key, DEFAULT_APPS_KEY_FTP_NEEDS_TERM) == 0) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->ftp_client_terminal_checkbutton), + gconf_value_get_bool (value)); + } +} + +static void mail_gconf_changed_cb (GConfClient *client, guint id, GConfEntry *entry, GnomeDACapplet *capplet) { GConfValue *value; @@ -947,6 +1219,26 @@ } static void +news_gconf_changed_cb (GConfClient *client, guint id, GConfEntry *entry, GnomeDACapplet *capplet) +{ + GConfValue *value; + + g_return_if_fail (gconf_entry_get_key (entry) != NULL); + + if (!(value = gconf_entry_get_value (entry))) + return; + + if (strcmp (entry->key, DEFAULT_APPS_KEY_NEWS_EXEC) == 0) { + news_reader_update_combo_box (capplet, gconf_value_get_string (value)); + } + /* TODO: Remove when GConfPropertyEditor will be used */ + else if (strcmp (entry->key, DEFAULT_APPS_KEY_NEWS_NEEDS_TERM) == 0) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->news_reader_terminal_checkbutton), + gconf_value_get_bool (value)); + } +} + +static void term_gconf_changed_cb (GConfClient *client, guint id, GConfEntry *entry, GnomeDACapplet *capplet) { GConfValue *value; @@ -1021,7 +1313,7 @@ } static void -fill_combo_box (GtkIconTheme *theme, GtkComboBox *combo_box, GList *app_list) +fill_combo_box (GtkIconTheme *theme, GtkComboBox *combo_box, GList *app_list, gboolean ftp) { GList *entry; GtkTreeModel *model; @@ -1033,8 +1325,13 @@ theme = gtk_icon_theme_get_default (); } - gtk_combo_box_set_row_separator_func (combo_box, is_separator, - GINT_TO_POINTER (g_list_length (app_list)), NULL); + if (ftp) +/* FIXME: Add one another separator between Default web browser and list. */ + gtk_combo_box_set_row_separator_func (combo_box, is_separator, + GINT_TO_POINTER (g_list_length (app_list)+2), NULL); + else + gtk_combo_box_set_row_separator_func (combo_box, is_separator, + GINT_TO_POINTER (g_list_length (app_list)), NULL); model = GTK_TREE_MODEL (gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING)); gtk_combo_box_set_model (combo_box, model); @@ -1054,6 +1351,25 @@ "text", TEXT_COL, NULL); + if (ftp) { + pixbuf = gtk_icon_theme_load_icon (theme, "stock_autocompletion", 22, 0, NULL); + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + PIXBUF_COL, pixbuf, + TEXT_COL, _("File type based"), + -1); + if (pixbuf) + g_object_unref (pixbuf); + pixbuf = gtk_icon_theme_load_icon (theme, "web-browser", 22, 0, NULL); + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + PIXBUF_COL, pixbuf, + TEXT_COL, _("Use default web browser"), + -1); + if (pixbuf) + g_object_unref (pixbuf); + } + for (entry = app_list; entry != NULL; entry = g_list_next (entry)) { GnomeDAItem *item; item = (GnomeDAItem *) entry->data; @@ -1117,10 +1433,19 @@ capplet->new_win_radiobutton = glade_xml_get_widget (capplet->xml, "web_browser_new_win_radiobutton"); capplet->new_tab_radiobutton = glade_xml_get_widget (capplet->xml, "web_browser_new_tab_radiobutton"); + capplet->ftp_client_command_entry = glade_xml_get_widget (capplet->xml, "ftp_client_command_entry"); + capplet->ftp_client_command_label = glade_xml_get_widget (capplet->xml, "ftp_client_command_label"); + capplet->ftp_client_terminal_checkbutton = glade_xml_get_widget (capplet->xml, + "ftp_client_terminal_checkbutton"); + capplet->mail_reader_command_entry = glade_xml_get_widget (capplet->xml, "mail_reader_command_entry"); capplet->mail_reader_command_label = glade_xml_get_widget (capplet->xml, "mail_reader_command_label"); capplet->mail_reader_terminal_checkbutton = glade_xml_get_widget (capplet->xml, "mail_reader_terminal_checkbutton"); + capplet->news_reader_command_entry = glade_xml_get_widget (capplet->xml, "news_reader_command_entry"); + capplet->news_reader_command_label = glade_xml_get_widget (capplet->xml, "news_reader_command_label"); + capplet->news_reader_terminal_checkbutton = glade_xml_get_widget (capplet->xml, "news_reader_terminal_checkbutton"); + capplet->terminal_command_entry = glade_xml_get_widget (capplet->xml, "terminal_command_entry"); capplet->terminal_command_label = glade_xml_get_widget (capplet->xml, "terminal_command_label"); capplet->terminal_exec_flag_entry = glade_xml_get_widget (capplet->xml, "terminal_exec_flag_entry"); @@ -1139,7 +1464,9 @@ capplet->mobility_startup_checkbutton = glade_xml_get_widget (capplet->xml, "mobility_start_checkbutton"); capplet->web_combo_box = glade_xml_get_widget (capplet->xml, "web_browser_combobox"); + capplet->ftp_combo_box = glade_xml_get_widget (capplet->xml, "ftp_client_combobox"); capplet->mail_combo_box = glade_xml_get_widget (capplet->xml, "mail_reader_combobox"); + capplet->news_combo_box = glade_xml_get_widget (capplet->xml, "news_reader_combobox"); capplet->term_combo_box = glade_xml_get_widget (capplet->xml, "terminal_combobox"); capplet->media_combo_box = glade_xml_get_widget (capplet->xml, "media_player_combobox"); capplet->visual_combo_box = glade_xml_get_widget (capplet->xml, "visual_combobox"); @@ -1148,12 +1475,22 @@ g_signal_connect (capplet->window, "screen-changed", G_CALLBACK (screen_changed_cb), capplet); screen_changed_cb (capplet->window, gdk_screen_get_default (), capplet); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->term_combo_box), capplet->terminals); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->media_combo_box), capplet->media_players); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->visual_combo_box), capplet->visual_ats); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->mobility_combo_box), capplet->mobility_ats); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers, + FALSE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->ftp_combo_box), capplet->ftp_clients, + TRUE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers, + FALSE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->news_combo_box), capplet->news_readers, + FALSE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->term_combo_box), capplet->terminals, + FALSE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->media_combo_box), capplet->media_players, + FALSE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->visual_combo_box), capplet->visual_ats, + FALSE); + fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->mobility_combo_box), + capplet->mobility_ats, FALSE); /* update ui to gconf content */ value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_HTTP_EXEC, NULL); @@ -1172,6 +1509,27 @@ gconf_value_free (value); } + value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_FTP_ENABLED, NULL); + if (gconf_value_get_bool (value)) + { + value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_FTP_EXEC, NULL); + if (value) + { + ftp_client_update_combo_box (capplet, gconf_value_get_string (value)); + gconf_value_free (value); + } + + value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_FTP_NEEDS_TERM, NULL); + if (value) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->ftp_client_terminal_checkbutton), + gconf_value_get_bool (value)); + gconf_value_free (value); + } + } + else + ftp_client_update_combo_box (capplet, NULL); + value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_MAILER_EXEC, NULL); if (value) { @@ -1219,6 +1577,21 @@ value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_VISUAL_EXEC, NULL); + value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_NEWS_EXEC, NULL); + if (value) + { + news_reader_update_combo_box (capplet, gconf_value_get_string (value)); + gconf_value_free (value); + } + + value = gconf_client_get (capplet->gconf, DEFAULT_APPS_KEY_NEWS_NEEDS_TERM, NULL); + if (value) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->news_reader_terminal_checkbutton), + gconf_value_get_bool (value)); + gconf_value_free (value); + } + if (value) { visual_update_combo_box (capplet, gconf_value_get_string (value)); @@ -1254,7 +1627,9 @@ } g_signal_connect (capplet->web_combo_box, "changed", G_CALLBACK (web_combo_changed_cb), capplet); + g_signal_connect (capplet->ftp_combo_box, "changed", G_CALLBACK (ftp_combo_changed_cb), capplet); g_signal_connect (capplet->mail_combo_box, "changed", G_CALLBACK (mail_combo_changed_cb), capplet); + g_signal_connect (capplet->news_combo_box, "changed", G_CALLBACK (news_combo_changed_cb), capplet); g_signal_connect (capplet->term_combo_box, "changed", G_CALLBACK (terminal_combo_changed_cb), capplet); g_signal_connect (capplet->media_combo_box, "changed", G_CALLBACK (media_combo_changed_cb), capplet); g_signal_connect (capplet->visual_combo_box, "changed", G_CALLBACK (visual_combo_changed_cb), capplet); @@ -1263,8 +1638,12 @@ /* TODO: Remove when GConfPropertyEditor will be used */ g_signal_connect (capplet->web_browser_terminal_checkbutton, "toggled", G_CALLBACK (terminal_checkbutton_toggled_cb), capplet); + g_signal_connect (capplet->ftp_client_terminal_checkbutton, "toggled", + G_CALLBACK (terminal_checkbutton_toggled_cb), capplet); g_signal_connect (capplet->mail_reader_terminal_checkbutton, "toggled", G_CALLBACK (terminal_checkbutton_toggled_cb), capplet); + g_signal_connect (capplet->news_reader_terminal_checkbutton, "toggled", + G_CALLBACK (terminal_checkbutton_toggled_cb), capplet); g_signal_connect (capplet->media_player_terminal_checkbutton, "toggled", G_CALLBACK (terminal_checkbutton_toggled_cb), capplet); g_signal_connect (capplet->visual_startup_checkbutton, "toggled", @@ -1274,7 +1653,9 @@ /* TODO: Remove when GConfPropertyEditor will be used */ g_signal_connect (capplet->web_browser_command_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); + g_signal_connect (capplet->ftp_client_command_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); g_signal_connect (capplet->mail_reader_command_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); + g_signal_connect (capplet->news_reader_command_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); g_signal_connect (capplet->terminal_command_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); g_signal_connect (capplet->terminal_exec_flag_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); g_signal_connect (capplet->media_player_command_entry, "focus-out-event", G_CALLBACK (entry_focus_out_event_cb), capplet); @@ -1322,9 +1703,15 @@ gconf_client_notify_add (capplet->gconf, DEFAULT_APPS_KEY_HTTP_PATH, (GConfClientNotifyFunc) web_gconf_changed_cb, capplet, NULL, NULL); + gconf_client_notify_add (capplet->gconf, DEFAULT_APPS_KEY_FTP_PATH, + (GConfClientNotifyFunc) ftp_gconf_changed_cb, + capplet, NULL, NULL); gconf_client_notify_add (capplet->gconf, DEFAULT_APPS_KEY_MAILER_PATH, (GConfClientNotifyFunc) mail_gconf_changed_cb, capplet, NULL, NULL); + gconf_client_notify_add (capplet->gconf, DEFAULT_APPS_KEY_NEWS_PATH, + (GConfClientNotifyFunc) news_gconf_changed_cb, + capplet, NULL, NULL); gconf_client_notify_add (capplet->gconf, DEFAULT_APPS_KEY_TERMINAL_PATH, (GConfClientNotifyFunc) term_gconf_changed_cb, capplet, NULL, NULL); --- capplets/default-applications/gnome-da-capplet.h +++ capplets/default-applications/gnome-da-capplet.h @@ -45,10 +45,19 @@ #define DEFAULT_APPS_KEY_ABOUT_NEEDS_TERM DEFAULT_APPS_KEY_ABOUT_PATH"/needs_terminal" #define DEFAULT_APPS_KEY_ABOUT_EXEC DEFAULT_APPS_KEY_ABOUT_PATH"/command" +#define DEFAULT_APPS_KEY_FTP_PATH "/desktop/gnome/url-handlers/ftp" +#define DEFAULT_APPS_KEY_FTP_NEEDS_TERM DEFAULT_APPS_KEY_FTP_PATH"/needs_terminal" +#define DEFAULT_APPS_KEY_FTP_EXEC DEFAULT_APPS_KEY_FTP_PATH"/command" +#define DEFAULT_APPS_KEY_FTP_ENABLED DEFAULT_APPS_KEY_FTP_PATH"/enabled" + #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_NEWS_PATH "/desktop/gnome/url-handlers/news" +#define DEFAULT_APPS_KEY_NEWS_NEEDS_TERM DEFAULT_APPS_KEY_NEWS_PATH"/needs_terminal" +#define DEFAULT_APPS_KEY_NEWS_EXEC DEFAULT_APPS_KEY_NEWS_PATH"/command" + #define DEFAULT_APPS_KEY_BROWSER_PATH "/desktop/gnome/applications/browser" #define DEFAULT_APPS_KEY_BROWSER_EXEC DEFAULT_APPS_KEY_BROWSER_PATH"/exec" #define DEFAULT_APPS_KEY_BROWSER_NEEDS_TERM DEFAULT_APPS_KEY_BROWSER_PATH"/needs_term" @@ -80,7 +89,9 @@ GtkWidget *window; GtkWidget *web_combo_box; + GtkWidget *ftp_combo_box; GtkWidget *mail_combo_box; + GtkWidget *news_combo_box; GtkWidget *term_combo_box; GtkWidget *media_combo_box; GtkWidget *visual_combo_box; @@ -93,10 +104,18 @@ GtkWidget *new_win_radiobutton; GtkWidget *new_tab_radiobutton; + GtkWidget *ftp_client_command_entry; + GtkWidget *ftp_client_command_label; + GtkWidget *ftp_client_terminal_checkbutton; + GtkWidget *mail_reader_command_entry; GtkWidget *mail_reader_command_label; GtkWidget *mail_reader_terminal_checkbutton; + GtkWidget *news_reader_command_entry; + GtkWidget *news_reader_command_label; + GtkWidget *news_reader_terminal_checkbutton; + GtkWidget *terminal_command_entry; GtkWidget *terminal_command_label; GtkWidget *terminal_exec_flag_entry; @@ -117,7 +136,9 @@ GConfClient *gconf; GList *web_browsers; + GList *ftp_clients; GList *mail_readers; + GList *news_readers; GList *terminals; GList *media_players; GList *visual_ats; --- capplets/default-applications/gnome-da-item.c +++ capplets/default-applications/gnome-da-item.c @@ -31,6 +31,16 @@ return item; } +GnomeDAFtpItem* +gnome_da_ftp_item_new (void) +{ + GnomeDAFtpItem *item = NULL; + + item = g_new0 (GnomeDAFtpItem, 1); + + return item; +} + GnomeDASimpleItem* gnome_da_simple_item_new (void) { @@ -41,6 +51,16 @@ return item; } +GnomeDANewsItem* +gnome_da_news_item_new (void) +{ + GnomeDANewsItem *item = NULL; + + item = g_new0 (GnomeDANewsItem, 1); + + return item; +} + GnomeDATermItem* gnome_da_term_item_new (void) { @@ -89,6 +109,20 @@ } void +gnome_da_ftp_item_free (GnomeDAFtpItem *item) +{ + g_return_if_fail (item != NULL); + + g_free (item->generic.name); + g_free (item->generic.executable); + g_free (item->generic.command); + g_free (item->generic.icon_name); + g_free (item->generic.icon_path); + + g_free (item); +} + +void gnome_da_simple_item_free (GnomeDASimpleItem *item) { g_return_if_fail (item != NULL); @@ -103,6 +137,20 @@ } void +gnome_da_news_item_free (GnomeDANewsItem *item) +{ + g_return_if_fail (item != NULL); + + g_free (item->generic.name); + g_free (item->generic.executable); + g_free (item->generic.command); + g_free (item->generic.icon_name); + g_free (item->generic.icon_path); + + g_free (item); +} + +void gnome_da_term_item_free (GnomeDATermItem *item) { g_return_if_fail (item != NULL); --- capplets/default-applications/gnome-da-item.h +++ capplets/default-applications/gnome-da-item.h @@ -26,6 +26,8 @@ typedef struct _GnomeDAItem GnomeDAItem; typedef struct _GnomeDAWebItem GnomeDAWebItem; +typedef struct _GnomeDAFtpItem GnomeDAFtpItem; +typedef struct _GnomeDANewsItem GnomeDANewsItem; typedef struct _GnomeDATermItem GnomeDATermItem; typedef struct _GnomeDASimpleItem GnomeDASimpleItem; typedef struct _GnomeDAVisualItem GnomeDAVisualItem; @@ -47,11 +49,21 @@ gchar *win_command; }; +struct _GnomeDAFtpItem { + GnomeDAItem generic; + gboolean run_in_terminal; +}; + struct _GnomeDASimpleItem { GnomeDAItem generic; gboolean run_in_terminal; }; +struct _GnomeDANewsItem { + GnomeDAItem generic; + gboolean run_in_terminal; +}; + struct _GnomeDATermItem { GnomeDAItem generic; gchar *exec_flag; @@ -68,11 +80,15 @@ }; GnomeDAWebItem* gnome_da_web_item_new (void); +GnomeDAFtpItem* gnome_da_ftp_item_new (void); +GnomeDANewsItem* gnome_da_news_item_new (void); GnomeDATermItem* gnome_da_term_item_new (void); GnomeDASimpleItem* gnome_da_simple_item_new (void); GnomeDAVisualItem* gnome_da_visual_item_new (void); GnomeDAMobilityItem* gnome_da_mobility_item_new (void); void gnome_da_web_item_free (GnomeDAWebItem *item); +void gnome_da_ftp_item_free (GnomeDAFtpItem *item); +void gnome_da_news_item_free (GnomeDANewsItem *item); void gnome_da_term_item_free (GnomeDATermItem *item); void gnome_da_simple_item_free (GnomeDASimpleItem *item); void gnome_da_visual_item_free (GnomeDAVisualItem *item); --- capplets/default-applications/gnome-da-xml.c +++ capplets/default-applications/gnome-da-xml.c @@ -130,7 +130,9 @@ xmlNode *root, *section, *element; gchar *executable; GnomeDAWebItem *web_item; + GnomeDAFtpItem *ftp_item; GnomeDASimpleItem *mail_item; + GnomeDANewsItem *news_item; GnomeDASimpleItem *media_item; GnomeDATermItem *term_item; GnomeDAVisualItem *visual_item; @@ -170,6 +172,27 @@ } } } + else if (!xmlStrncmp (section->name, "ftp-clients", 12)) { + for (element = section->children; element != NULL; element = element->next) { + if (!xmlStrncmp (element->name, "ftp-client", 11)) { + executable = gnome_da_xml_get_string (element, "executable"); + if (is_executable_valid (executable)) { + ftp_item = gnome_da_ftp_item_new (); + + ftp_item->generic.name = gnome_da_xml_get_string (element, "name"); + ftp_item->generic.executable = executable; + ftp_item->generic.command = gnome_da_xml_get_string (element, "command"); + ftp_item->generic.icon_name = gnome_da_xml_get_string (element, "icon-name"); + + ftp_item->run_in_terminal = gnome_da_xml_get_bool (element, "run-in-terminal"); + + capplet->ftp_clients = g_list_append (capplet->ftp_clients, ftp_item); + } + else + g_free (executable); + } + } + } else if (!xmlStrncmp (section->name, "mail-readers", 12)) { for (element = section->children; element != NULL; element = element->next) { if (!xmlStrncmp (element->name, "mail-reader", 11)) { @@ -191,6 +214,27 @@ } } } + else if (!xmlStrncmp (section->name, "news-readers", 12)) { + for (element = section->children; element != NULL; element = element->next) { + if (!xmlStrncmp (element->name, "news-reader", 11)) { + executable = gnome_da_xml_get_string (element, "executable"); + if (is_executable_valid (executable)) { + news_item = gnome_da_news_item_new (); + + news_item->generic.name = gnome_da_xml_get_string (element, "name"); + news_item->generic.executable = executable; + news_item->generic.command = gnome_da_xml_get_string (element, "command"); + news_item->generic.icon_name = gnome_da_xml_get_string (element, "icon-name"); + + news_item->run_in_terminal = gnome_da_xml_get_bool (element, "run-in-terminal"); + + capplet->news_readers = g_list_append (capplet->news_readers, news_item); + } + else + g_free (executable); + } + } + } else if (!xmlStrncmp (section->name, "terminals", 9)) { for (element = section->children; element != NULL; element = element->next) { if (!xmlStrncmp (element->name, "terminal", 8)) { @@ -302,14 +346,18 @@ gnome_da_xml_free (GnomeDACapplet *capplet) { g_list_foreach (capplet->web_browsers, (GFunc) gnome_da_web_item_free, NULL); + g_list_foreach (capplet->ftp_clients, (GFunc) gnome_da_ftp_item_free, NULL); g_list_foreach (capplet->mail_readers, (GFunc) gnome_da_simple_item_free, NULL); + g_list_foreach (capplet->news_readers, (GFunc) gnome_da_news_item_free, NULL); g_list_foreach (capplet->terminals, (GFunc) gnome_da_term_item_free, NULL); g_list_foreach (capplet->media_players, (GFunc) gnome_da_simple_item_free, NULL); g_list_foreach (capplet->visual_ats, (GFunc) gnome_da_visual_item_free, NULL); g_list_foreach (capplet->mobility_ats, (GFunc) gnome_da_mobility_item_free, NULL); g_list_free (capplet->web_browsers); + g_list_free (capplet->ftp_clients); g_list_free (capplet->mail_readers); + g_list_free (capplet->news_readers); g_list_free (capplet->terminals); g_list_free (capplet->media_players); g_list_free (capplet->visual_ats); --- capplets/default-applications/gnome-default-applications-properties.glade +++ capplets/default-applications/gnome-default-applications-properties.glade @@ -336,6 +336,189 @@ + + True + False + 6 + + + + True + <b>FTP Client</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + 0.5 + 0 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + False + True + + + 0 + False + True + + + + + + True + 1 + 3 + False + 6 + 12 + + + + True + False + Co_mmand: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + ftp_client_command_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + All %s occurrences will be replaced with actual link + True + False + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + False + True + Run in t_erminal + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 2 + 3 + 0 + 1 + fill + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + False + True + + + + True False @@ -699,6 +882,190 @@ True + + + + True + False + 6 + + + + True + <b>News Reader</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + 0.5 + 0 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + False + True + + + 0 + False + True + + + + + + True + 1 + 3 + False + 6 + 12 + + + + True + False + Co_mmand: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + news_reader_command_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + All %s occurrences will be replaced with actual link + True + False + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + False + True + Run in t_erminal + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 2 + 3 + 0 + 1 + fill + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + False + True + + + False --- capplets/default-applications/gnome-default-applications.xml.in +++ capplets/default-applications/gnome-default-applications.xml.in @@ -155,6 +155,25 @@ + + + <_name>Nautilus + nautilus + nautilus %s + file-manager + false + false + + + <_name>gFTP + gftp + gftp %s + gftp + false + false + + + <_name>Evolution Mail Reader 2.4 @@ -284,6 +303,52 @@ + + + <_name>Debian Sensible Browser + sensible-browser + sensible-browser %s + + false + false + + + <_name>Thunderbird + thunderbird + thunderbird %s + thunderbird + false + + + <_name>Mozilla News 1.6 + mozilla-1.6 + mozilla-1.6 -news %s + mozilla-icon + false + true + mozilla-1.6 -news -remote "openurl(%s,new-tab)" + mozilla-1.6 -news -remote "openurl(%s,new-window)" + + + <_name>Mozilla News + mozilla + mozilla -news %s + mozilla-icon + false + true + mozilla -news -remote "openurl(%s,new-tab)" + mozilla -news -remote "openurl(%s,new-window)" + + + <_name>TIN News Reader + tin + tin %s + gnome-mime-application-x-executable + true + false + + + <_name>Debian Terminal Emulator