2002-06-15  Jody Goldberg <jody@gnome.org>

	http://bugzilla.gnome.org/show_bug.cgi?id=85397
	http://bugzilla.gnome.org/show_bug.cgi?id=84545
	* mime-types-model.c (mime_types_model_get_value) :
	  gtk_tree_view_search_equal_func does not like NULL.
	(IS_CATEGORY) : check for NULL.
	* file-types-capplet.c (create_dialog) : search the description not
	  the mime type.

2002-06-08  Jody Goldberg <jody@gnome.org>

	* mime-types-model.c (IS_CATEGORY) : test for null in case we are
	  stupid.

2002-06-07  Jody Goldberg <jody@gnome.org>

	* file-types-capplet.c (dialog_done_cb) : no need to save things
	  again.  The only caller had already done that.

	* mime-type-info.c (mime_type_info_save) : Don't mess with the
	  application here, it should already be setup.  However, be really
	  really anal about verifying it because I do not trust the
	  surrounding code or know it well enough to trust it.  Make sure that
	  the assigned app is on the short list of associated apps.

	* mime-category-edit-dialog.c (store_data) : Use
	  mime_edit_dialog_get_app.
	* mime-edit-dialog.c (store_data) : Use it here too.
	(mime_edit_dialog_get_app) : new.  split some duplicated code out of
	  the type and category dialogs and move it here.  Then make it
	  readable and less stupid about creating copies of existing
	  applications.  While we're at it have it handle the creation of new
	  applications, merging commands with existing applications and other
	  useful stuff.

2002-06-07  Jody Goldberg <jody@gnome.org>

	* mime-category-edit-dialog.c (store_data) : clarify and remove the
	  custom flag.

	* mime-type-info.c (mime_category_info_using_custom_app) : delete.
	(mime_type_info_using_custom_app) : delete.

	* mime-edit-dialog.c (validate_data) : correct the warning about
	  invalid type, we would _not_ create one for the user :-(
	  Allow a user to optionally overwrite an existing mime type.
	  This is useful when editing.
	* mime-edit-dialog.c (store_data) : clarify and remove the custom flag.


2002-06-10  Jody Goldberg <jody@gnome.org>

	* accessibility-keyboard.c : tweak the layout as requested and adjust
	  the max slowkey delay to 500 to avoid losing the keyboard due to some
	  sort of an X problem.

2002-06-13  Jody Goldberg <jody@gnome.org>

	* gnome-keyboard-properties.c (accessibility_button_clicked) : produce
	  a better warning for failure to launch the keyboard accessibility
	  capplet.
This commit is contained in:
Jody Goldberg 2002-06-18 18:55:14 +00:00 committed by Jody Goldberg
parent 50ce2ab6da
commit b4995826e8
19 changed files with 1484 additions and 1482 deletions

View file

@ -1,3 +1,9 @@
2002-06-10 Jody Goldberg <jody@gnome.org>
* accessibility-keyboard.c : tweak the layout as requested and adjust
the max slowkey delay to 500 to avoid losing the keyboard due to some
sort of an X problem.
2002-06-17 Jody Goldberg <jody@gnome.org>
* Release 2.0.0

View file

@ -4,6 +4,9 @@ libaccessibility_keyboard_a_SOURCES = \
accessibility-keyboard.c \
accessibility-keyboard.h
# in case we need to forward port the sun accessX extension
# AccessXcomm.c
bin_PROGRAMS = gnome-accessibility-keyboard-properties
gnome_accessibility_keyboard_properties_SOURCES = gnome-accessibility-keyboard-properties.c
@ -21,7 +24,7 @@ pixmap_DATA = \
accessibility-keyboard-bouncekey.png
Gladedir = $(GNOMECC_GLADE_DIR)
Glade_DATA = gnome-accessibility-keyboard-properties.glade2
Glade_DATA = gnome-accessibility-keyboard-properties.glade
iconsdir = $(GNOMECC_ICONS_DIR)
icons_DATA = accessibility-keyboard-capplet.png

View file

@ -44,27 +44,26 @@ static struct {
char const * const image;
char const * const image_file;
char const * const gconf_key;
gboolean only_for_dialog;
char const * const content [5];
char const * const content [3];
} const features [] = {
{ "bouncekeys_enable", "bouncekeys_image", IDIR "accessibility-keyboard-bouncekey.png",
CONFIG_ROOT "/bouncekeys_enable", FALSE,
{ "bouncekeys_delay_slide", "bouncekeys_delay_spin", "bouncekeys_label1", "bouncekeys_label2", "bouncekeys_box" } },
CONFIG_ROOT "/bouncekeys_enable",
{ "bouncekey_table", NULL, NULL } },
{ "slowkeys_enable", "slowkeys_image", IDIR "accessibility-keyboard-slowkey.png",
CONFIG_ROOT "/slowkeys_enable", FALSE,
{ "slowkeys_delay_slide", "slowkeys_delay_spin", "slowkeys_table", "slowkeys_label", NULL } },
CONFIG_ROOT "/slowkeys_enable",
{ "slowkeys_table", NULL, NULL } },
{ "mousekeys_enable", "mousekeys_image", IDIR "accessibility-keyboard-mousekey.png",
CONFIG_ROOT "/mousekeys_enable", FALSE,
{ "mousekeys_table", NULL, NULL, NULL, NULL } },
CONFIG_ROOT "/mousekeys_enable",
{ "mousekeys_table", NULL, NULL } },
{ "stickykeys_enable", "stickykeys_image", IDIR "accessibility-keyboard-stickykey.png",
CONFIG_ROOT "/stickykeys_enable", FALSE,
{ "stickykeys_two_key_off", "stickykeys_modifier_beep", NULL, NULL, NULL } },
CONFIG_ROOT "/stickykeys_enable",
{ "stickeykeys_table", NULL, NULL } },
{ "togglekeys_enable", "togglekeys_image", IDIR "accessibility-keyboard-togglekey.png",
CONFIG_ROOT "/togglekeys_enable", FALSE,
{ NULL, NULL, NULL, NULL, NULL } },
CONFIG_ROOT "/togglekeys_enable",
{ NULL, NULL, NULL } },
{ "timeout_enable", NULL, NULL,
CONFIG_ROOT "/timeout_enable", TRUE,
{ "timeout_slide", "timeout_spin", NULL, NULL, NULL } }
CONFIG_ROOT "/timeout_enable",
{ "timeout_slide", "timeout_spin", "timeout_label" } }
};
static struct {
@ -75,28 +74,22 @@ static struct {
int max_val;
int step_size;
char const * const gconf_key;
gboolean only_for_dialog;
} const ranges [] = {
{ "bouncekeys_delay_slide", "bouncekeys_delay_spin", 300, 10, 900, 10,
CONFIG_ROOT "/bouncekeys_delay", FALSE },
CONFIG_ROOT "/bouncekeys_delay" },
{ "slowkeys_delay_slide", "slowkeys_delay_spin", 300, 10, 900, 10,
CONFIG_ROOT "/slowkeys_delay", FALSE },
{ "mousekeys_max_speed_slide", "mousekeys_max_speed_spin", 300, 10, 1000, 20,
CONFIG_ROOT "/mousekeys_max_speed", FALSE },
CONFIG_ROOT "/slowkeys_delay" },
/* WARNING anything larger than approx 512 seems to loose all keyboard input */
{ "mousekeys_max_speed_slide", "mousekeys_max_speed_spin", 300, 10, 500, 20,
CONFIG_ROOT "/mousekeys_max_speed" },
{ "mousekeys_accel_time_slide", "mousekeys_accel_time_spin", 300, 10, 3000, 100,
CONFIG_ROOT "/mousekeys_accel_time", FALSE },
CONFIG_ROOT "/mousekeys_accel_time" },
{ "mousekeys_init_delay_slide", "mousekeys_init_delay_spin", 300, 10, 5000, 100,
CONFIG_ROOT "/mousekeys_init_delay", FALSE },
CONFIG_ROOT "/mousekeys_init_delay" },
{ "timeout_slide", "timeout_spin", 200, 10, 500, 10,
CONFIG_ROOT "/timeout", TRUE },
CONFIG_ROOT "/timeout" },
};
static void
cb_accessibility_toggled (GtkToggleButton *btn, GtkWidget *table)
{
gtk_widget_set_sensitive (table, gtk_toggle_button_get_active (btn));
}
static void
set_sensitive (GladeXML *dialog, char const *name, gboolean state)
{
@ -128,14 +121,13 @@ cb_feature_toggled (GtkToggleButton *btn, gpointer feature_index)
}
static void
setup_toggles (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
setup_toggles (GladeXML *dialog, GConfChangeSet *changeset)
{
GObject *peditor;
GtkWidget *checkbox;
int i = G_N_ELEMENTS (features);
while (i-- > 0)
if (as_dialog || !features [i].only_for_dialog) {
while (i-- > 0) {
checkbox = WID (features [i].checkbox);
g_return_if_fail (checkbox != NULL);
@ -150,26 +142,24 @@ setup_toggles (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
}
static void
setup_simple_toggles (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
setup_simple_toggles (GladeXML *dialog, GConfChangeSet *changeset)
{
static struct {
char const *gconf_key;
char const *checkbox;
gboolean only_for_dialog;
} const simple_toggles [] = {
{ CONFIG_ROOT "/feature_state_change_beep","feature_state_change_beep", TRUE },
{ CONFIG_ROOT "/bouncekeys_beep_reject", "bouncekeys_beep_reject", FALSE },
{ CONFIG_ROOT "/feature_state_change_beep","feature_state_change_beep" },
{ CONFIG_ROOT "/bouncekeys_beep_reject", "bouncekeys_beep_reject" },
{ CONFIG_ROOT "/slowkeys_beep_press", "slowkeys_beep_press", FALSE },
{ CONFIG_ROOT "/slowkeys_beep_accept", "slowkeys_beep_accept", FALSE },
{ CONFIG_ROOT "/slowkeys_beep_reject", "slowkeys_beep_reject", FALSE},
{ CONFIG_ROOT "/slowkeys_beep_press", "slowkeys_beep_press" },
{ CONFIG_ROOT "/slowkeys_beep_accept", "slowkeys_beep_accept" },
{ CONFIG_ROOT "/slowkeys_beep_reject", "slowkeys_beep_reject" },
{ CONFIG_ROOT "/stickykeys_two_key_off", "stickykeys_two_key_off", FALSE },
{ CONFIG_ROOT "/stickykeys_modifier_beep", "stickykeys_modifier_beep", FALSE},
{ CONFIG_ROOT "/stickykeys_two_key_off", "stickykeys_two_key_off" },
{ CONFIG_ROOT "/stickykeys_modifier_beep", "stickykeys_modifier_beep" },
};
int i = G_N_ELEMENTS (simple_toggles);
while (i-- > 0)
if (as_dialog || !simple_toggles [i].only_for_dialog) {
while (i-- > 0) {
GtkWidget *w = WID (simple_toggles [i].checkbox);
g_return_if_fail (w != NULL);
@ -192,7 +182,7 @@ cb_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
}
static void
setup_ranges (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
setup_ranges (GladeXML *dialog, GConfChangeSet *changeset)
{
GObject *peditor;
GtkWidget *slide, *spin;
@ -200,9 +190,6 @@ setup_ranges (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
int i = G_N_ELEMENTS (ranges);
while (i-- > 0) {
if (!as_dialog && ranges [i].only_for_dialog)
continue;
slide = WID (ranges [i].slide);
spin = WID (ranges [i].spin);
g_return_if_fail (slide != NULL);
@ -231,46 +218,32 @@ setup_ranges (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
}
static void
setup_images (GladeXML *dialog, gboolean as_dialog)
setup_images (GladeXML *dialog)
{
int i = G_N_ELEMENTS (features);
while (i-- > 0)
if (features [i].image != NULL &&
(as_dialog || !features [i].only_for_dialog)) {
if (features [i].image != NULL)
gtk_image_set_from_file (GTK_IMAGE (WID (features [i].image)),
features [i].image_file);
}
}
static void
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset, gboolean as_dialog)
cb_launch_keyboard_capplet (GtkButton *button, GtkWidget *dialog)
{
GtkWidget *content = WID ("keyboard_table");
GtkWidget *page = WID ("accessX_page");
GObject *label;
GError *err = NULL;
if (!g_spawn_command_line_async ("gnome-keyboard-properties", &err))
capplet_error_dialog (GTK_WINDOW (gtk_widget_get_toplevel (dialog)),
_("There was an error launching the keyboard capplet : %s"),
err);
}
g_return_if_fail (content != NULL);
g_return_if_fail (page != NULL);
setup_images (dialog, as_dialog);
setup_ranges (dialog, changeset, as_dialog);
setup_toggles (dialog, changeset, as_dialog);
setup_simple_toggles (dialog, changeset, as_dialog);
label = g_object_new (GTK_TYPE_CHECK_BUTTON,
"label", _("_Enable keyboard accessibility"),
"use_underline", TRUE,
/* init true so that if gconf is false toggle will fire */
"active", TRUE,
NULL);
gtk_frame_set_label_widget (GTK_FRAME (page), GTK_WIDGET (label));
g_signal_connect (label,
"toggled",
G_CALLBACK (cb_accessibility_toggled), content);
gconf_peditor_new_boolean (changeset,
CONFIG_ROOT "/enable",
GTK_WIDGET (label), NULL);
static void
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
{
setup_images (dialog);
setup_ranges (dialog, changeset);
setup_toggles (dialog, changeset);
setup_simple_toggles (dialog, changeset);
}
/*******************************************************************************/
@ -465,31 +438,26 @@ cb_load_CDE_file (GtkButton *button, GtkWidget *dialog)
/*******************************************************************************/
GtkWidget *
setup_accessX_dialog (GConfChangeSet *changeset, gboolean as_dialog)
setup_accessX_dialog (GConfChangeSet *changeset)
{
GConfClient *client;
#if 1
char const *toplevel_name = as_dialog ? "accessX_dialog" : "accessX_page";
char const *toplevel_name = "accessX_dialog";
GladeXML *dialog = glade_xml_new (GNOMECC_DATA_DIR
"/interfaces/gnome-accessibility-keyboard-properties.glade2",
"/interfaces/gnome-accessibility-keyboard-properties.glade",
toplevel_name, NULL);
GtkWidget *toplevel = WID (toplevel_name);
#else
char const *toplevel_name = "key_access_dialog";
GladeXML *dialog = glade_xml_new ("access-foo.glade",
toplevel_name, NULL);
GtkWidget *toplevel = WID (toplevel_name);
#endif
client = gconf_client_get_default ();
gconf_client_add_dir (client, CONFIG_ROOT, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
setup_dialog (dialog, changeset, as_dialog);
setup_dialog (dialog, changeset);
if (as_dialog) {
GtkWidget *load_cde = WID ("load_CDE_file");
g_signal_connect (G_OBJECT (load_cde),
g_signal_connect (G_OBJECT (WID ("load_CDE_file")),
"clicked",
G_CALLBACK (cb_load_CDE_file), toplevel);
}
g_signal_connect (G_OBJECT (WID ("launch_repeat_button")),
"clicked",
G_CALLBACK (cb_launch_keyboard_capplet), toplevel);
return toplevel;
}

View file

@ -27,6 +27,6 @@
#include <gconf/gconf-changeset.h>
#include <gtk/gtkwidget.h>
GtkWidget *setup_accessX_dialog (GConfChangeSet *changeset, gboolean as_dialog);
GtkWidget *setup_accessX_dialog (GConfChangeSet *changeset);
#endif /* GNOME_ACCESSIBILITY_KEYBOARD_H */

View file

@ -37,19 +37,11 @@ dialog_response (GtkWidget *widget,
gint response_id,
GConfChangeSet *changeset)
{
if (response_id == GTK_RESPONSE_HELP) {
GError *error = NULL;
/* TODO : get this written */
gnome_help_display_desktop (NULL,
"control-center-manual",
if (response_id == GTK_RESPONSE_HELP)
capplet_help (GTK_WINDOW (widget),
"accessibility-keyboard.xml",
"CONFIGURATION", &error);
if (error) {
g_warning ("help error: %s\n", error->message);
g_error_free (error);
}
} else
"CONFIGURATION");
else
gtk_main_quit ();
}
@ -69,7 +61,7 @@ main (int argc, char **argv)
activate_settings_daemon ();
changeset = NULL;
dialog = setup_accessX_dialog (changeset, TRUE);
dialog = setup_accessX_dialog (changeset);
g_signal_connect (G_OBJECT (dialog),
"response",
G_CALLBACK (dialog_response), changeset);

View file

@ -1,3 +1,8 @@
2002-06-13 Jody Goldberg <jody@gnome.org>
* capplet-util.c (capplet_help) : Use the new utility.
(capplet_error_dialog) : split out into a new utility.
2002-06-17 Jody Goldberg <jody@gnome.org>
* Release 2.0.0

View file

@ -285,6 +285,35 @@ capplet_init (int argc,
#endif
/**
* capplet_error_dialog :
*
* @parent :
* @msg : already translated.
* @err :
*
*/
void
capplet_error_dialog (GtkWindow *parent, char const *msg, GError *err)
{
if (err != NULL) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
msg, err->message);
g_signal_connect (G_OBJECT (dialog),
"response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_widget_show (dialog);
g_error_free (err);
}
}
/**
* capplet_help :
* @parent :
@ -305,21 +334,8 @@ capplet_help (GtkWindow *parent, char const *helpfile, char const *section)
gnome_help_display_desktop (NULL,
"user-guide",
helpfile, section, &error);
if (error) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
if (error != NULL)
capplet_error_dialog (parent,
_("There was an error displaying help: %s"),
error->message);
g_signal_connect (G_OBJECT (dialog),
"response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_widget_show (dialog);
g_error_free (error);
}
error);
}

View file

@ -90,6 +90,7 @@ void capplet_init (int argc,
SetupPropertyEditorsFn setup_property_editors_fn,
GetLegacySettingsFn get_legacy_settings_fn);
void capplet_error_dialog (GtkWindow *parent, char const *msg, GError *err);
void capplet_help (GtkWindow *parent, char const *helpfile, char const *section);
#endif /* __CAPPLET_UTIL_H */

View file

@ -1,12 +1,56 @@
2002-06-17 Jody Goldberg <jody@gnome.org>
* Release 2.0.0
2002-06-15 Jody Goldberg <jody@gnome.org>
http://bugzilla.gnome.org/show_bug.cgi?id=85397
http://bugzilla.gnome.org/show_bug.cgi?id=84545
* mime-types-model.c (mime_types_model_get_value) :
gtk_tree_view_search_equal_func does not like NULL.
(IS_CATEGORY) : check for NULL.
* file-types-capplet.c (create_dialog) : search the description not
the mime type.
2002-06-08 Jody Goldberg <jody@gnome.org>
* mime-types-model.c (IS_CATEGORY) : test for null in case we are
stupid.
2002-06-07 Jody Goldberg <jody@gnome.org>
* file-types-capplet.c (dialog_done_cb) : no need to save things
again. The only caller had already done that.
* mime-type-info.c (mime_type_info_save) : Don't mess with the
application here, it should already be setup. However, be really
really anal about verifying it because I do not trust the
surrounding code or know it well enough to trust it. Make sure that
the assigned app is on the short list of associated apps.
* mime-category-edit-dialog.c (store_data) : Use
mime_edit_dialog_get_app.
* mime-edit-dialog.c (store_data) : Use it here too.
(mime_edit_dialog_get_app) : new. split some duplicated code out of
the type and category dialogs and move it here. Then make it
readable and less stupid about creating copies of existing
applications. While we're at it have it handle the creation of new
applications, merging commands with existing applications and other
useful stuff.
2002-06-07 Jody Goldberg <jody@gnome.org>
* mime-category-edit-dialog.c (store_data) : clarify and remove the
custom flag.
* mime-type-info.c (mime_category_info_using_custom_app) : delete.
(mime_type_info_using_custom_app) : delete.
* mime-edit-dialog.c (validate_data) : correct the warning about
invalid type, we would _not_ create one for the user :-(
Allow a user to optionally overwrite an existing mime type.
This is useful when editing.
* mime-edit-dialog.c (store_data) : clarify and remove the custom flag.
2002-06-17 Jody Goldberg <jody@gnome.org>
* Release 2.0.0
2002-06-05 Jody Goldberg <jody@gnome.org>

View file

@ -219,6 +219,9 @@ create_dialog (void)
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes
(column, renderer, "text", MODEL_COLUMN_DESCRIPTION, NULL);
g_object_set (G_OBJECT (treeview),
"search_column", MODEL_COLUMN_DESCRIPTION,
NULL);
gtk_tree_view_column_set_title (column, _("Description"));
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
@ -255,9 +258,6 @@ create_dialog (void)
static void
dialog_done_cb (MimeEditDialog *dialog, gboolean done, MimeTypeInfo *info)
{
if (done)
mime_type_info_save (info);
gtk_main_quit ();
}

View file

@ -33,6 +33,7 @@
#include "mime-types-model.h"
#include "mime-type-info.h"
#include "mime-category-edit-dialog.h"
#include "mime-edit-dialog.h"
#define WID(x) (glade_xml_get_widget (dialog->p->dialog_xml, x))
@ -399,40 +400,11 @@ update_subcategories (ModelEntry *entry, MimeCategoryInfo *category)
static void
store_data (MimeCategoryEditDialog *dialog)
{
GtkOptionMenu *option_menu;
GtkMenuShell *menu_shell;
GObject *menu_item;
gint idx;
GnomeVFSMimeApplication *app;
option_menu = GTK_OPTION_MENU (WID ("default_action_select"));
menu_shell = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
idx = gtk_option_menu_get_history (option_menu);
menu_item = (g_list_nth (menu_shell->children, idx))->data;
app = g_object_get_data (menu_item, "app");
if (app != NULL) {
gnome_vfs_mime_application_free (dialog->p->info->default_action);
dialog->p->info->default_action = gnome_vfs_mime_application_copy (app);
} else {
if (!mime_category_info_using_custom_app (dialog->p->info)) {
gnome_vfs_mime_application_free (dialog->p->info->default_action);
dialog->p->info->default_action = g_new0 (GnomeVFSMimeApplication, 1);
}
g_free (dialog->p->info->default_action->command);
dialog->p->info->default_action->command
= g_strdup (gtk_entry_get_text (GTK_ENTRY
(gnome_file_entry_gtk_entry
(GNOME_FILE_ENTRY (WID ("program_entry"))))));
dialog->p->info->default_action->requires_terminal
= gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
}
dialog->p->info->use_parent_category =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("use_category_toggle")));
mime_edit_dialog_get_app (dialog->p->dialog_xml,
dialog->p->info->description,
&(dialog->p->info->default_action));
dialog->p->info->use_parent_category = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (WID ("use_category_toggle")));
model_entry_save (MODEL_ENTRY (dialog->p->info));
update_subcategories (MODEL_ENTRY (dialog->p->info), dialog->p->info);
}

View file

@ -602,6 +602,102 @@ collect_filename_extensions (MimeEditDialog *dialog)
return ret;
}
/**
* mime_edit_dialog_get_app :
* @glade :
* @mime_type : a fall back in case we can't generate a meaningful application name.
* @current :
*
* A utility routine for looking up applications. it should handle life cycle
* and hopefully merge in existing copies of custom applications.
**/
void
mime_edit_dialog_get_app (GladeXML *glade, char const *mime_type,
GnomeVFSMimeApplication **current)
{
GtkWidget *menu = glade_xml_get_widget (glade, "default_action_select");
gint idx = gtk_option_menu_get_history (GTK_OPTION_MENU (menu));
GtkWidget *shell = gtk_option_menu_get_menu (GTK_OPTION_MENU (menu));
GObject *item = (g_list_nth (GTK_MENU_SHELL (shell)->children, idx))->data;
GnomeVFSMimeApplication *res, *app = g_object_get_data (item, "app");
if (app == NULL) {
char *cmd = gnome_file_entry_get_full_path (
GNOME_FILE_ENTRY (glade_xml_get_widget (glade, "program_entry")), FALSE);
gboolean requires_terminal = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (glade_xml_get_widget (glade, "needs_terminal_toggle")));
char *base_cmd;
GList *ptr, *app_list = NULL;
/* I have no idea what semantics people want, but I'll be anal
* and avoid NULL
*/
if (cmd != NULL)
cmd = g_strdup ("");
base_cmd = g_path_get_basename (cmd);
if (base_cmd == NULL);
base_cmd = g_strdup ("");
app_list = gnome_vfs_application_registry_get_applications (NULL);
for (ptr = app_list; ptr != NULL ; ptr = ptr->next) {
char const *app_cmd = gnome_vfs_application_registry_peek_value (ptr->data,
GNOME_VFS_APPLICATION_REGISTRY_COMMAND);
/* Look for a matching application (with or without path) */
if (app_cmd != NULL &&
(!strcmp (cmd, app_cmd) || !strcmp (base_cmd, app_cmd))) {
gboolean ok, app_req = gnome_vfs_application_registry_get_bool_value (ptr->data,
GNOME_VFS_APPLICATION_REGISTRY_REQUIRES_TERMINAL, &ok);
if (ok && app_req == requires_terminal)
break;
}
}
/* No existing application, lets create one */
if (ptr == NULL) {
res = g_new0 (GnomeVFSMimeApplication, 1);
res->command = cmd;
res->requires_terminal = requires_terminal;
res->name = base_cmd;
if (res->name != NULL && *res->name) {
/* Can we use the app name as the id ?
* We know that there are no apps with the same
* command, so if the id is taken we are screwed
*/
if (gnome_vfs_application_registry_get_mime_application (res->name) == NULL)
res->id = g_strdup (res->name);
} else { /* fail safe to ensure a name */
g_free (res->name);
res->name = g_strdup_printf ("Custom %s", mime_type);
}
/* If there is no id yet, make up a unique string */
if (res->id == NULL) {
uuid_t app_uuid;
gchar app_uuid_str[100];
uuid_generate (app_uuid);
uuid_unparse (app_uuid, app_uuid_str);
res->id = g_strdup (app_uuid_str);
}
gnome_vfs_application_registry_save_mime_application (res);
} else {
g_free (cmd);
g_free (base_cmd);
res = gnome_vfs_application_registry_get_mime_application (ptr->data);
}
g_list_free (app_list);
} else
res = gnome_vfs_mime_application_copy (app);
gnome_vfs_mime_application_free (*current);
*current = res;
}
static void
store_data (MimeEditDialog *dialog)
{
@ -618,8 +714,6 @@ store_data (MimeEditDialog *dialog)
uuid_t mime_uuid;
gchar mime_uuid_str[100];
GnomeVFSMimeApplication *app;
GtkTreeIter iter;
GtkTreePath *path;
@ -665,31 +759,9 @@ store_data (MimeEditDialog *dialog)
CORBA_free (dialog->p->info->default_component);
dialog->p->info->default_component = g_object_get_data (menu_item, "component");
option_menu = GTK_OPTION_MENU (WID ("default_action_select"));
menu_shell = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
idx = gtk_option_menu_get_history (option_menu);
menu_item = (g_list_nth (menu_shell->children, idx))->data;
app = g_object_get_data (menu_item, "app");
if (app != NULL) {
gnome_vfs_mime_application_free (dialog->p->info->default_action);
dialog->p->info->default_action = gnome_vfs_mime_application_copy (app);
} else {
if (!mime_type_info_using_custom_app (dialog->p->info)) {
gnome_vfs_mime_application_free (dialog->p->info->default_action);
dialog->p->info->default_action = g_new0 (GnomeVFSMimeApplication, 1);
} else if (!dialog->p->info->default_action) {
dialog->p->info->default_action = g_new0 (GnomeVFSMimeApplication, 1);
}
g_free (dialog->p->info->default_action->command);
dialog->p->info->default_action->command
= g_strdup (gtk_entry_get_text (GTK_ENTRY
(gnome_file_entry_gtk_entry
(GNOME_FILE_ENTRY (WID ("program_entry"))))));
dialog->p->info->default_action->requires_terminal
= gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
}
mime_edit_dialog_get_app (dialog->p->dialog_xml,
dialog->p->info->mime_type,
&(dialog->p->info->default_action));
ext_list = collect_filename_extensions (dialog);
mime_type_info_set_file_extensions (dialog->p->info, ext_list);
@ -716,30 +788,33 @@ store_data (MimeEditDialog *dialog)
static gboolean
validate_data (MimeEditDialog *dialog)
{
const gchar *tmp;
const gchar *mesg = NULL;
const gchar *mime_type;
GtkWidget *err_dialog = NULL;
tmp = gtk_entry_get_text (GTK_ENTRY (WID ("mime_type_entry")));
mime_type = gtk_entry_get_text (GTK_ENTRY (WID ("mime_type_entry")));
if (tmp != NULL && *tmp != '\0') {
if (strchr (tmp, ' ') || !strchr (tmp, '/')) {
mesg = _("Invalid MIME type. Please enter a valid MIME type, or "
"leave the field blank to have one generated for you.");
} else if (dialog->p->is_add && (gnome_vfs_mime_type_is_known (tmp) ||
get_mime_type_info (tmp) != NULL)) {
mesg = _("There already exists a MIME type of that name.");
}
}
if (mesg != NULL) {
GtkWidget *err_dialog = gtk_message_dialog_new (
if (mime_type != NULL && *mime_type != '\0') {
if (strchr (mime_type, ' ') || !strchr (mime_type, '/')) {
err_dialog = gtk_message_dialog_new (
GTK_WINDOW (dialog->p->dialog_win),
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
mesg);
gtk_dialog_run (GTK_DIALOG (err_dialog));
GTK_BUTTONS_CANCEL,
_("Please enter a valid MIME type. It should be of the form "
"class/type and may not contain any spaces."));
} else if (dialog->p->is_add && (gnome_vfs_mime_type_is_known (mime_type) ||
get_mime_type_info (mime_type) != NULL)) {
err_dialog = gtk_message_dialog_new (
GTK_WINDOW (dialog->p->dialog_win),
GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_OK_CANCEL,
_("A MIME type with that name already exists, overwrite ?."));
}
}
if (err_dialog) {
int res = gtk_dialog_run (GTK_DIALOG (err_dialog));
gtk_object_destroy (GTK_OBJECT (err_dialog));
return FALSE;
return res != GTK_RESPONSE_CANCEL;
}
return TRUE;
}

View file

@ -58,6 +58,9 @@ GObject *mime_edit_dialog_new (GtkTreeModel *model,
MimeTypeInfo *info);
GObject *mime_add_dialog_new (GtkTreeModel *model, GtkWindow *parent);
void mime_edit_dialog_get_app (GladeXML *glade, char const *mime_type,
GnomeVFSMimeApplication **current);
G_END_DECLS
#endif /* __MIME_EDIT_DIALOG_H */

View file

@ -194,22 +194,6 @@ mime_type_info_get_category_name (const MimeTypeInfo *info)
return mime_category_info_get_full_description (MIME_CATEGORY_INFO (info->entry.parent));
}
gboolean
mime_type_info_using_custom_app (const MimeTypeInfo *info)
{
gchar *tmp;
gboolean ret;
if (!info->default_action || !info->default_action->name)
return TRUE;
tmp = g_strdup_printf ("Custom %s", info->mime_type);
ret = !strcmp (tmp, info->default_action->name);
g_free (tmp);
return ret;
}
void
mime_type_info_set_category_name (const MimeTypeInfo *info, const gchar *category_name, const gchar *category_desc, GtkTreeModel *model)
{
@ -234,42 +218,33 @@ mime_type_info_set_file_extensions (MimeTypeInfo *info, GList *list)
}
void
mime_type_info_save (const MimeTypeInfo *info)
mime_type_info_save (MimeTypeInfo *info)
{
gchar *tmp;
uuid_t app_uuid;
gchar app_uuid_str[100];
gnome_vfs_mime_freeze ();
gnome_vfs_mime_set_description (info->mime_type, info->description);
gnome_vfs_mime_set_icon (info->mime_type, info->icon_name);
if (info->default_action != NULL &&
info->default_action->command != NULL &&
info->default_action->command [0] != '\0') {
tmp = g_strdup_printf ("Custom %s", info->mime_type);
if (info->default_action->name == NULL)
info->default_action->name = tmp;
if (info->default_action->id == NULL) {
uuid_generate (app_uuid);
uuid_unparse (app_uuid, app_uuid_str);
info->default_action->id = g_strdup (app_uuid_str);
} else if (!strcmp (tmp, info->default_action->name)) {
gnome_vfs_application_registry_set_value (info->default_action->id, "command",
info->default_action->command);
gnome_vfs_application_registry_set_bool_value (info->default_action->id, "requires_terminal",
info->default_action->requires_terminal);
/* Be really anal about validating this action */
if (info->default_action != NULL) {
if ( info->default_action->command == NULL ||
*info->default_action->command == '\0' ||
info->default_action->id == NULL ||
*info->default_action->id == '\0') {
g_warning ("Invalid application");
gnome_vfs_mime_application_free (info->default_action);
info->default_action = NULL;
}
}
gnome_vfs_mime_set_default_application (info->mime_type, info->default_action->id);
gnome_vfs_application_registry_save_mime_application (info->default_action);
} else {
if (info->default_action != NULL) {
gnome_vfs_mime_set_default_application (info->mime_type,
info->default_action->id);
gnome_vfs_mime_add_application_to_short_list (info->mime_type,
info->default_action->id);
} else
gnome_vfs_mime_set_default_application (info->mime_type, NULL);
}
tmp = form_extensions_string (info, " ", NULL);
gnome_vfs_mime_set_extensions_list (info->mime_type, tmp);
@ -383,24 +358,6 @@ mime_category_info_load_all (MimeCategoryInfo *category)
g_free (tmp1);
}
gboolean
mime_category_info_using_custom_app (const MimeCategoryInfo *category)
{
gchar *tmp;
gboolean ret;
if (category == NULL ||
category->default_action == NULL ||
category->default_action->name == NULL)
return TRUE;
tmp = g_strdup_printf ("Custom %s", category->name);
ret = !strcmp (tmp, category->default_action->name);
g_free (tmp);
return ret;
}
static void
set_subcategory_ids (ModelEntry *entry, MimeCategoryInfo *category, gchar *app_id)
{
@ -427,54 +384,36 @@ set_subcategory_ids (ModelEntry *entry, MimeCategoryInfo *category, gchar *app_i
void
mime_category_info_save (MimeCategoryInfo *category)
{
gchar *tmp, *tmp1, *tmp2;
uuid_t app_uuid;
gchar app_uuid_str[100];
gchar *key, *basename;
gboolean set_ids;
tmp1 = get_gconf_base_name (category);
tmp = g_strconcat (tmp1, "/default-action-id", NULL);
if (category->default_action != NULL &&
category->default_action->command != NULL &&
*category->default_action->command != '\0')
{
tmp2 = g_strdup_printf ("Custom %s", category->name);
if (category->default_action->name == NULL)
category->default_action->name = tmp2;
if (category->default_action->id == NULL) {
uuid_generate (app_uuid);
uuid_unparse (app_uuid, app_uuid_str);
category->default_action->id = g_strdup (app_uuid_str);
gnome_vfs_application_registry_save_mime_application (category->default_action);
gnome_vfs_application_registry_sync ();
/* Be really anal about validating this action */
if (category->default_action != NULL) {
if ( category->default_action->command == NULL ||
*category->default_action->command == '\0' ||
category->default_action->id == NULL ||
*category->default_action->id == '\0') {
g_warning ("Invalid application");
gnome_vfs_mime_application_free (category->default_action);
category->default_action = NULL;
}
else if (!strcmp (tmp, category->default_action->name)) {
gnome_vfs_application_registry_set_value (category->default_action->id, "command",
category->default_action->command);
gnome_vfs_application_registry_set_bool_value (category->default_action->id, "requires_terminal",
category->default_action->requires_terminal);
}
basename = get_gconf_base_name (category);
key = g_strconcat (basename, "/default-action-id", NULL);
if (category->default_action != NULL) {
gconf_client_set_string (gconf_client_get_default (),
tmp, category->default_action->id, NULL);
key, category->default_action->id, NULL);
set_ids = TRUE;
} else {
gconf_client_unset (gconf_client_get_default (), tmp, NULL);
set_ids = FALSE;
}
} else
gconf_client_unset (gconf_client_get_default (), key, NULL);
g_free (key);
g_free (tmp);
tmp = g_strconcat (tmp1, "/use-parent-category", NULL);
gconf_client_set_bool (gconf_client_get_default (), tmp, category->use_parent_category, NULL);
g_free (tmp);
g_free (tmp1);
key = g_strconcat (basename, "/use-parent-category", NULL);
gconf_client_set_bool (gconf_client_get_default (), key,
category->use_parent_category, NULL);
g_free (key);
g_free (basename);
if (set_ids)
set_subcategory_ids (MODEL_ENTRY (category), category, category->default_action->id);
@ -570,10 +509,8 @@ reduce_supported_app_list (ModelEntry *entry, GList *list, gboolean top)
GList *
mime_category_info_find_apps (MimeCategoryInfo *info)
{
GList *ret;
ret = find_possible_supported_apps (MODEL_ENTRY (info), TRUE);
return reduce_supported_app_list (MODEL_ENTRY (info), ret, TRUE);
return reduce_supported_app_list (MODEL_ENTRY (info),
find_possible_supported_apps (MODEL_ENTRY (info), TRUE), TRUE);
}
gchar *

View file

@ -84,15 +84,13 @@ const GList *mime_type_info_get_file_extensions (MimeTypeInfo *info);
const gchar *mime_type_info_get_icon_path (MimeTypeInfo *info);
gboolean mime_type_info_get_use_category (MimeTypeInfo *info);
void mime_type_info_save (const MimeTypeInfo *info);
void mime_type_info_save (MimeTypeInfo *info);
void mime_type_info_free (MimeTypeInfo *info);
gchar *mime_type_info_get_file_extensions_pretty_string
(MimeTypeInfo *info);
gchar *mime_type_info_get_category_name (const MimeTypeInfo *info);
gboolean mime_type_info_using_custom_app (const MimeTypeInfo *info);
void mime_type_info_set_category_name (const MimeTypeInfo *info,
const gchar *category_name,
const gchar *category_desc,
@ -105,7 +103,6 @@ MimeCategoryInfo *mime_category_info_new (MimeCategoryInfo *parent,
const gchar *description,
GtkTreeModel *model);
void mime_category_info_load_all (MimeCategoryInfo *category);
gboolean mime_category_info_using_custom_app (const MimeCategoryInfo *category);
void mime_category_info_save (MimeCategoryInfo *category);
GList *mime_category_info_find_apps (MimeCategoryInfo *info);

View file

@ -1,3 +1,9 @@
2002-06-13 Jody Goldberg <jody@gnome.org>
* gnome-keyboard-properties.c (accessibility_button_clicked) : produce
a better warning for failure to launch the keyboard accessibility
capplet.
2002-06-17 Jody Goldberg <jody@gnome.org>
* Release 2.0.0

View file

@ -235,7 +235,11 @@ static void
accessibility_button_clicked (GtkWidget *widget,
gpointer data)
{
g_spawn_command_line_async ("gnome-accessibility-keyboard-properties", NULL);
GError *err = NULL;
if (!g_spawn_command_line_async ("gnome-accessibility-keyboard-properties", NULL))
capplet_error_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
_("There was an error launching the keyboard capplet : %s"),
err);
}
static void

View file

@ -34,6 +34,7 @@ gnome_settings_daemon_SOURCES = \
xsettings-manager.h \
gnome-settings-keybindings.c \
gnome-settings-keybindings.h \
$(AccessX_files) \
$(CORBA_GENERATED)
gnome_settings_daemon_LDADD = \
@ -42,6 +43,12 @@ gnome_settings_daemon_LDADD = \
$(top_builddir)/libsounds/libsounds.a \
$(XF86MISC_LIBS)
#AccessX_files = \
# AccessXcomm.c \
# extutil.h \
# AccessXproto.h \
# AccessXlibint.h
CORBA_GENERATED_HEADER_FILES = GNOME_SettingsDaemon.h
CORBA_GENERATED = \