summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Goldberg <jody@gnome.org>2002-06-05 04:17:14 +0000
committerJody Goldberg <jody@src.gnome.org>2002-06-05 04:17:14 +0000
commit9137407127f1e1681c7926a2a2817610ef649944 (patch)
tree9583a20d4dc9d335c3444631fee38300fb6693a9
parent6a336cde955ba00042235a0dea8c20bb77adb928 (diff)
downloadgnome-control-center-9137407127f1e1681c7926a2a2817610ef649944.tar.gz
new. (fill_dialog) : mime type is always sensitive.
2002-06-05 Jody Goldberg <jody@gnome.org> * mime-edit-dialog.c (mime_add_dialog_new) : * mime-edit-dialog.c (mime_edit_editable_enters) : new. (fill_dialog) : mime type is always sensitive. (mime_edit_dialog_init) : use mime_edit_editable_enters and set the default response. (mime_add_dialog_new) : forceably define the model before is-add and set the parent. * model-entry.c (model_entry_insert_child) : be paranoid. Sort the mime entries too. * file-types-capplet.c (main) : !KLUDGE! if we are editing application/octet-stream assume that people really want to create a new mime type. 2002-06-04 Jody Goldberg <jody@gnome.org> * mime-type-info.c (mime_type_info_save) : Add a freeze/thaw around the assignments.
-rw-r--r--capplets/file-types/ChangeLog24
-rw-r--r--capplets/file-types/file-types-capplet.c11
-rw-r--r--capplets/file-types/file-types-capplet.h35
-rw-r--r--capplets/file-types/file-types-icon-entry.c1
-rw-r--r--capplets/file-types/mime-edit-dialog.c61
-rw-r--r--capplets/file-types/mime-edit-dialog.h2
-rw-r--r--capplets/file-types/mime-type-info.c9
-rw-r--r--capplets/file-types/model-entry.c21
8 files changed, 100 insertions, 64 deletions
diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog
index 066215b22..45f4909bf 100644
--- a/capplets/file-types/ChangeLog
+++ b/capplets/file-types/ChangeLog
@@ -1,3 +1,27 @@
+2002-06-05 Jody Goldberg <jody@gnome.org>
+
+ * mime-edit-dialog.c (mime_add_dialog_new) :
+
+ * mime-edit-dialog.c (mime_edit_editable_enters) : new.
+ (fill_dialog) : mime type is always sensitive.
+ (mime_edit_dialog_init) : use mime_edit_editable_enters and set the
+ default response.
+ (mime_add_dialog_new) : forceably define the model before is-add and
+ set the parent.
+
+
+ * model-entry.c (model_entry_insert_child) : be paranoid. Sort the
+ mime entries too.
+
+ * file-types-capplet.c (main) : !KLUDGE! if we are editing
+ application/octet-stream assume that people really want to create a
+ new mime type.
+
+2002-06-04 Jody Goldberg <jody@gnome.org>
+
+ * mime-type-info.c (mime_type_info_save) : Add a freeze/thaw around
+ the assignments.
+
2002-05-31 Jody Goldberg <jody@gnome.org>
* mime-type-info.c (get_category_name) : disable debug spew.
diff --git a/capplets/file-types/file-types-capplet.c b/capplets/file-types/file-types-capplet.c
index 11a418550..f066b6969 100644
--- a/capplets/file-types/file-types-capplet.c
+++ b/capplets/file-types/file-types-capplet.c
@@ -53,7 +53,8 @@ add_mime_cb (GtkButton *button, GladeXML *dialog)
treeview = GTK_TREE_VIEW (WID ("mime_types_tree"));
model = gtk_tree_view_get_model (treeview);
- add_dialog = mime_add_dialog_new (model);
+ add_dialog = mime_add_dialog_new (model,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))));
}
static void
@@ -285,9 +286,11 @@ main (int argc, char **argv)
gtk_widget_show_all (WID ("main_dialog"));
} else {
model = GTK_TREE_MODEL (mime_types_model_new (FALSE));
- info = mime_type_info_new (mime_type, model);
- mime_dialog = mime_edit_dialog_new (model, info);
-
+ if (strcmp (GNOME_VFS_MIME_TYPE_UNKNOWN, mime_type)) {
+ info = mime_type_info_new (mime_type, model);
+ mime_dialog = mime_edit_dialog_new (model, info);
+ } else
+ mime_dialog = mime_add_dialog_new (model, NULL);
g_signal_connect (mime_dialog, "done", (GCallback) dialog_done_cb, info);
}
diff --git a/capplets/file-types/file-types-capplet.h b/capplets/file-types/file-types-capplet.h
deleted file mode 100644
index 914a2cb58..000000000
--- a/capplets/file-types/file-types-capplet.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* nautilus-mime-type-capplet.h
- *
- * Copyright (C) 2000 Free Software Foundaton
- * Copyright (C) 2000 Eazel, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Gene Z. Ragan <gzr@eazel.com>
- */
-
-#ifndef NAUTILUS_MIME_TYPE_CAPPLET_H
-#define NAUTILUS_MIME_TYPE_CAPPLET_H
-
-void nautilus_mime_type_capplet_update_info (const char *mime_type);
-void nautilus_mime_type_capplet_update_application_info (const char *mime_type);
-void nautilus_mime_type_capplet_update_viewer_info (const char *mime_type);
-void nautilus_mime_type_capplet_add_extension (const char *extension);
-const char *nautilus_mime_type_capplet_get_selected_item_mime_type (void);
-void nautilus_mime_type_capplet_update_mime_list_icon_and_description (const char *mime_string);
-
-#endif /* NAUTILUS_MIME_TYPE_CAPPLET_H */
diff --git a/capplets/file-types/file-types-icon-entry.c b/capplets/file-types/file-types-icon-entry.c
index 74ead133e..2e416f657 100644
--- a/capplets/file-types/file-types-icon-entry.c
+++ b/capplets/file-types/file-types-icon-entry.c
@@ -12,7 +12,6 @@
#include <config.h>
#include "file-types-icon-entry.h"
-#include "file-types-capplet.h"
#include <gdk_imlib.h>
#include <gnome.h>
diff --git a/capplets/file-types/mime-edit-dialog.c b/capplets/file-types/mime-edit-dialog.c
index 9e9e8a3fd..c2a8a1e5b 100644
--- a/capplets/file-types/mime-edit-dialog.c
+++ b/capplets/file-types/mime-edit-dialog.c
@@ -74,7 +74,6 @@ static GObjectClass *parent_class;
static void mime_edit_dialog_init (MimeEditDialog *mime_edit_dialog,
MimeEditDialogClass *class);
static void mime_edit_dialog_class_init (MimeEditDialogClass *class);
-static void mime_edit_dialog_base_init (MimeEditDialogClass *class);
static void mime_edit_dialog_set_prop (GObject *object,
guint prop_id,
@@ -106,6 +105,7 @@ static void response_cb (MimeEditDialog *dialog,
static void update_sensitivity (MimeEditDialog *dialog);
+
GType
mime_edit_dialog_get_type (void)
{
@@ -114,7 +114,7 @@ mime_edit_dialog_get_type (void)
if (!mime_edit_dialog_type) {
GTypeInfo mime_edit_dialog_info = {
sizeof (MimeEditDialogClass),
- (GBaseInitFunc) mime_edit_dialog_base_init,
+ (GBaseInitFunc) NULL,
NULL, /* GBaseFinalizeFunc */
(GClassInitFunc) mime_edit_dialog_class_init,
NULL, /* GClassFinalizeFunc */
@@ -134,6 +134,31 @@ mime_edit_dialog_get_type (void)
return mime_edit_dialog_type;
}
+/**
+ * mime_edit_editable_enters: Make the "activate" signal of an editable click
+ * the default dialog button.
+ * @dialog: dialog to affect.
+ * @editable: Editable to affect.
+ *
+ * This is a literal copy of gnome_dialog_editable_enters, but not restricted
+ * to GnomeDialogs.
+ *
+ * Normally if there's an editable widget (such as #GtkEntry) in your
+ * dialog, pressing Enter will activate the editable rather than the
+ * default dialog button. However, in most cases, the user expects to
+ * type something in and then press enter to close the dialog. This
+ * function enables that behavior.
+ *
+ **/
+static void
+mime_edit_editable_enters (MimeEditDialog *dialog, GtkEditable *editable)
+{
+ g_signal_connect_swapped (G_OBJECT (editable),
+ "activate",
+ G_CALLBACK (gtk_window_activate_default),
+ GTK_WINDOW (dialog->p->dialog_win));
+}
+
static void
mime_edit_dialog_init (MimeEditDialog *dialog, MimeEditDialogClass *class)
{
@@ -168,6 +193,8 @@ mime_edit_dialog_init (MimeEditDialog *dialog, MimeEditDialogClass *class)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog->p->dialog_win),
+ GTK_RESPONSE_OK);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->p->dialog_win)->vbox), WID ("edit_widget"), TRUE, TRUE, 0);
@@ -179,11 +206,10 @@ mime_edit_dialog_init (MimeEditDialog *dialog, MimeEditDialogClass *class)
(GCallback) use_category_defaults_toggled_cb, dialog);
g_signal_connect_swapped (G_OBJECT (dialog->p->dialog_win), "response", (GCallback) response_cb, dialog);
-}
-static void
-mime_edit_dialog_base_init (MimeEditDialogClass *class)
-{
+ mime_edit_editable_enters (dialog, GTK_EDITABLE (WID ("description_entry")));
+ mime_edit_editable_enters (dialog, GTK_EDITABLE (WID ("mime_type_entry")));
+ mime_edit_editable_enters (dialog, GTK_EDITABLE (WID ("category_entry")));
}
static void
@@ -262,7 +288,8 @@ mime_edit_dialog_set_prop (GObject *object, guint prop_id, const GValue *value,
mime_edit_dialog->p->is_add = g_value_get_boolean (value);
if (mime_edit_dialog->p->is_add) {
- mime_edit_dialog->p->info = mime_type_info_new (NULL, NULL);
+ mime_edit_dialog->p->info = mime_type_info_new (NULL,
+ mime_edit_dialog->p->model);
setup_add_dialog (mime_edit_dialog);
gtk_window_set_title (GTK_WINDOW (mime_edit_dialog->p->dialog_win),
(_("Add file type")));
@@ -350,12 +377,19 @@ mime_edit_dialog_new (GtkTreeModel *model, MimeTypeInfo *info)
}
GObject *
-mime_add_dialog_new (GtkTreeModel *model)
+mime_add_dialog_new (GtkTreeModel *model, GtkWindow *parent)
{
- return g_object_new (mime_edit_dialog_get_type (),
- "model", model,
- "is-add", TRUE,
- NULL);
+ GObject *obj = g_object_new (mime_edit_dialog_get_type (),
+ "model", model, /* must be before is-add */
+ NULL);
+ g_object_set (obj,
+ "is-add", TRUE,
+ NULL);
+ if (parent != NULL)
+ gtk_window_set_transient_for (
+ GTK_WINDOW (MIME_EDIT_DIALOG (obj)->p->dialog_win),
+ parent);
+ return obj;
}
static void
@@ -388,9 +422,6 @@ fill_dialog (MimeEditDialog *dialog)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("use_category_defaults_toggle")), dialog->p->use_cat_dfl);
update_sensitivity (dialog);
- if (dialog->p->info->mime_type != NULL && *dialog->p->info->mime_type != '\0')
- gtk_widget_set_sensitive (WID ("mime_type_entry"), FALSE);
-
gnome_icon_entry_set_filename (GNOME_ICON_ENTRY (WID ("icon_entry")), mime_type_info_get_icon_path (dialog->p->info));
populate_component_list (dialog);
diff --git a/capplets/file-types/mime-edit-dialog.h b/capplets/file-types/mime-edit-dialog.h
index de5429d5b..8d54f449a 100644
--- a/capplets/file-types/mime-edit-dialog.h
+++ b/capplets/file-types/mime-edit-dialog.h
@@ -56,7 +56,7 @@ GType mime_edit_dialog_get_type (void);
GObject *mime_edit_dialog_new (GtkTreeModel *model,
MimeTypeInfo *info);
-GObject *mime_add_dialog_new (GtkTreeModel *model);
+GObject *mime_add_dialog_new (GtkTreeModel *model, GtkWindow *parent);
G_END_DECLS
diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c
index 23d908b8b..88e017a71 100644
--- a/capplets/file-types/mime-type-info.c
+++ b/capplets/file-types/mime-type-info.c
@@ -240,10 +240,13 @@ mime_type_info_save (const MimeTypeInfo *info)
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') {
+ 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)
@@ -254,8 +257,7 @@ mime_type_info_save (const MimeTypeInfo *info)
uuid_unparse (app_uuid, app_uuid_str);
info->default_action->id = g_strdup (app_uuid_str);
- }
- else if (!strcmp (tmp, info->default_action->name)) {
+ } 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",
@@ -285,6 +287,7 @@ mime_type_info_save (const MimeTypeInfo *info)
gnome_vfs_mime_set_value (info->mime_type, "use_category_default", info->use_category ? "yes" : "no");
gnome_vfs_application_registry_sync ();
+ gnome_vfs_mime_thaw ();
}
void
diff --git a/capplets/file-types/model-entry.c b/capplets/file-types/model-entry.c
index 8c7b8c256..551f0d63e 100644
--- a/capplets/file-types/model-entry.c
+++ b/capplets/file-types/model-entry.c
@@ -104,11 +104,22 @@ model_entry_insert_child (ModelEntry *parent, ModelEntry *child, GtkTreeModel *m
for (tmp = &parent->first_child; *tmp != NULL; tmp = &((*tmp)->next)) {
if ((*tmp)->type < child->type)
continue;
- if ((*tmp)->type > child->type ||
- (child->type == MODEL_ENTRY_CATEGORY &&
- strcmp (MIME_CATEGORY_INFO (child)->name,
- MIME_CATEGORY_INFO (*tmp)->name) < 0))
- break;
+ if ((*tmp)->type > child->type)
+ break;
+
+ if (child->type == MODEL_ENTRY_CATEGORY) {
+ if (MIME_CATEGORY_INFO (child)->name != NULL &&
+ MIME_CATEGORY_INFO (*tmp)->name != NULL &&
+ strcmp (MIME_CATEGORY_INFO (child)->name,
+ MIME_CATEGORY_INFO (*tmp)->name) < 0)
+ break;
+ } else if (child->type == MODEL_ENTRY_MIME_TYPE) {
+ if (MIME_TYPE_INFO (child)->description != NULL &&
+ MIME_TYPE_INFO (*tmp)->description != NULL &&
+ strcmp (MIME_TYPE_INFO (child)->description,
+ MIME_TYPE_INFO (*tmp)->description) < 0)
+ break;
+ }
}
child->parent = parent;