summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-03-16 22:26:53 +0000
committerDarin Adler <darin@src.gnome.org>2001-03-16 22:26:53 +0000
commitdcb478cf7e1500504a8273ad6ef0422f7fbc3e29 (patch)
treec1400dd09095b724e50805eec0f6c71122f20ca1
parenta85afd0f2524ca254099a41cf8585c435c19f0b8 (diff)
downloadnautilus-dcb478cf7e1500504a8273ad6ef0422f7fbc3e29.tar.gz
reviewed by: John Sullivan <sullivan@eazel.com>
Fix bug 6495 (Emacs-style keybindings not working in location bar and other NautilusEntry fields) by adding an expert preference to control whether the Emacs shortcuts or the ones in the menu bar take precedence. I started with Maciej's patch and did many refinements. Fix bug 1788 ("Select All" needs to be implemented for text): I had to add Select All so it won't do the icon view's Select All when you do a select all with the location bar focused. Fix bug 5612 (clicking to deselect causes incorrect menu sensitivity) by adding another signal handler for button clicks. Fix bug 7581 (When trying to restart Nautilus after crash from bug 7579 I get a Segmentation Fault). I was just lucky enough to run into the problem on my machine. * libnautilus-extensions/nautilus-global-preferences.h: * libnautilus-extensions/nautilus-global-preferences.c: (global_preferences_install_descriptions), (global_preferences_install_defaults), (global_preferences_install_visibility), (global_preferences_create_dialog): Added the new Emacs-shortcut preference with the wording requested in the bug report. * libnautilus-extensions/nautilus-entry.h: * libnautilus-extensions/nautilus-entry.c: (emacs_shortcuts_preference_changed_callback): Track the preference. (nautilus_entry_initialize): Set up the callback to track the preference. (nautilus_entry_destroy): Tear down the callback to track the preference. (nautilus_entry_key_press): Allow the emacs shortcuts built into GtkEntry to work if the preference is set that way. Also, only emit the selection_changed signal if the key is actually handled. (nautilus_entry_motion_notify): Simplify the logic, since it's OK to send the selection_changed signal a little too often. (select_all_at_idle): Handle the case where the object is destroyed. (nautilus_entry_select_all_at_idle): Ref the object to handle the case where the object is destroyed before the idle happens. (nautilus_entry_button_press): Send a selection_changed message, since pressing the button can cause a selection change. (nautilus_entry_button_release): Send a selection_changed message, since pressing the button can cause a selection change. (nautilus_entry_initialize_class): Add new default handlers. Also, move to bottom of file so we don't need so many forward declarations. * libnautilus/nautilus-clipboard-ui.xml: Add a Select All Text command. * libnautilus/nautilus-clipboard.c: (select_all): New function to select all the text in a GtkEditable. Sadly it needs a special case for GtkText. (select_all_idle_callback): Callback used to select the text from idle. (select_all_callback): Callback that sets up the idle. Called from the bonobo verb. (initialize_clipboard_component_with_callback_data): Add the callback for Select All. * librsvg/rsvg.c: (rsvg_state_init): Initialize more fields, including font_size. (rsvg_text_handler_characters): Don't try to draw if the font size is 0 or negative. * librsvg/art_render_mask.c: (art_render_mask_render): Handle cases where x1 < x0. The old code would seg. fault. This was the reason we got a crash in bug 7581. * configure.in: Upped the required version of gnome-vfs.
-rw-r--r--ChangeLog76
-rw-r--r--configure.in2
-rw-r--r--libnautilus-extensions/nautilus-entry.c253
-rw-r--r--libnautilus-extensions/nautilus-entry.h33
-rw-r--r--libnautilus-extensions/nautilus-global-preferences.c68
-rw-r--r--libnautilus-extensions/nautilus-global-preferences.h3
-rw-r--r--libnautilus-private/nautilus-entry.c253
-rw-r--r--libnautilus-private/nautilus-entry.h33
-rw-r--r--libnautilus-private/nautilus-global-preferences.c68
-rw-r--r--libnautilus-private/nautilus-global-preferences.h3
-rw-r--r--libnautilus/nautilus-clipboard-ui.xml5
-rw-r--r--libnautilus/nautilus-clipboard.c130
-rw-r--r--librsvg/art_render_mask.c14
-rw-r--r--librsvg/rsvg.c9
14 files changed, 609 insertions, 341 deletions
diff --git a/ChangeLog b/ChangeLog
index d4d227f47..0935f97ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,79 @@
+2001-03-16 Darin Adler <darin@eazel.com>
+
+ reviewed by: John Sullivan <sullivan@eazel.com>
+
+ Fix bug 6495 (Emacs-style keybindings not working in location bar
+ and other NautilusEntry fields) by adding an expert preference to
+ control whether the Emacs shortcuts or the ones in the menu bar
+ take precedence. I started with Maciej's patch and did many
+ refinements.
+
+ Fix bug 1788 ("Select All" needs to be implemented for text): I
+ had to add Select All so it won't do the icon view's Select All
+ when you do a select all with the location bar focused.
+
+ Fix bug 5612 (clicking to deselect causes incorrect menu
+ sensitivity) by adding another signal handler for button clicks.
+
+ Fix bug 7581 (When trying to restart Nautilus after crash from bug
+ 7579 I get a Segmentation Fault). I was just lucky enough to run
+ into the problem on my machine.
+
+ * libnautilus-extensions/nautilus-global-preferences.h:
+ * libnautilus-extensions/nautilus-global-preferences.c:
+ (global_preferences_install_descriptions),
+ (global_preferences_install_defaults),
+ (global_preferences_install_visibility),
+ (global_preferences_create_dialog): Added the new Emacs-shortcut
+ preference with the wording requested in the bug report.
+
+ * libnautilus-extensions/nautilus-entry.h:
+ * libnautilus-extensions/nautilus-entry.c:
+ (emacs_shortcuts_preference_changed_callback): Track the
+ preference.
+ (nautilus_entry_initialize): Set up the callback to track the
+ preference.
+ (nautilus_entry_destroy): Tear down the callback to track the
+ preference.
+ (nautilus_entry_key_press): Allow the emacs shortcuts built into
+ GtkEntry to work if the preference is set that way. Also, only
+ emit the selection_changed signal if the key is actually handled.
+ (nautilus_entry_motion_notify): Simplify the logic, since it's
+ OK to send the selection_changed signal a little too often.
+ (select_all_at_idle): Handle the case where the object is
+ destroyed.
+ (nautilus_entry_select_all_at_idle): Ref the object to handle the
+ case where the object is destroyed before the idle happens.
+ (nautilus_entry_button_press): Send a selection_changed message,
+ since pressing the button can cause a selection change.
+ (nautilus_entry_button_release): Send a selection_changed message,
+ since pressing the button can cause a selection change.
+ (nautilus_entry_initialize_class): Add new default handlers. Also,
+ move to bottom of file so we don't need so many forward
+ declarations.
+
+ * libnautilus/nautilus-clipboard-ui.xml: Add a Select All Text
+ command.
+ * libnautilus/nautilus-clipboard.c: (select_all): New function to
+ select all the text in a GtkEditable. Sadly it needs a special
+ case for GtkText.
+ (select_all_idle_callback): Callback used to select the text from
+ idle.
+ (select_all_callback): Callback that sets up the idle. Called from
+ the bonobo verb.
+ (initialize_clipboard_component_with_callback_data): Add the
+ callback for Select All.
+
+ * librsvg/rsvg.c: (rsvg_state_init): Initialize more fields,
+ including font_size.
+ (rsvg_text_handler_characters): Don't try to draw if the font
+ size is 0 or negative.
+ * librsvg/art_render_mask.c: (art_render_mask_render): Handle
+ cases where x1 < x0. The old code would seg. fault. This was the
+ reason we got a crash in bug 7581.
+
+ * configure.in: Upped the required version of gnome-vfs.
+
2001-03-16 Robey Pointer <robey@eazel.com>
* nautilus-installer/src/main.c: (main):
diff --git a/configure.in b/configure.in
index 55ca737f8..c2fe1d5da 100644
--- a/configure.in
+++ b/configure.in
@@ -19,7 +19,7 @@ CONTROL_CENTER_REQUIRED=1.2.3
IMLIB_REQUIRED=1.9.8
LIBXML_REQUIRED=1.8.10
ORBIT_REQUIRED=0.5.6
-GNOME_VFS_REQUIRED=0.4.2
+GNOME_VFS_REQUIRED=1.0
POPT_REQUIRED=1.5
FREETYPE_REQUIRED=2.0
MEDUSA_REQUIRED=0.2.2
diff --git a/libnautilus-extensions/nautilus-entry.c b/libnautilus-extensions/nautilus-entry.c
index 10af50e5d..4d4a684ff 100644
--- a/libnautilus-extensions/nautilus-entry.c
+++ b/libnautilus-extensions/nautilus-entry.c
@@ -28,20 +28,18 @@
#include "nautilus-entry.h"
#include "nautilus-gtk-macros.h"
-
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtksignal.h>
#include <gtk/gtkmain.h>
-#include <gtk/gtkwidget.h>
-
-#include <libgnome/gnome-defs.h>
+#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
-
#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+#include <libnautilus-extensions/nautilus-global-preferences.h>
#include <libnautilus-extensions/nautilus-undo-signal-handlers.h>
-
#include <orb/orbit.h>
+struct NautilusEntryDetails {
+ gboolean use_emacs_shortcuts;
+};
enum {
USER_CHANGED,
@@ -50,68 +48,22 @@ enum {
};
static guint signals[LAST_SIGNAL];
-static void nautilus_entry_initialize (NautilusEntry *entry);
+static void nautilus_entry_initialize (NautilusEntry *entry);
static void nautilus_entry_initialize_class (NautilusEntryClass *class);
-static void nautilus_entry_destroy (GtkObject *object);
-static gint nautilus_entry_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint nautilus_entry_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-static void nautilus_entry_insert_text (GtkEditable *editable,
- const gchar *text,
- gint length,
- gint *position);
-static gboolean nautilus_entry_selection_clear (GtkWidget *widget,
- GdkEventSelection *event);
-static void nautilus_entry_delete_text (GtkEditable *editable,
- gint start_pos,
- gint end_pos);
-static void nautilus_entry_set_selection (GtkEditable *editable,
- gint start_pos,
- gint end_pos);
-
-NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusEntry, nautilus_entry, GTK_TYPE_ENTRY)
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusEntry,
+ nautilus_entry,
+ GTK_TYPE_ENTRY)
static void
-nautilus_entry_initialize_class (NautilusEntryClass *class)
+emacs_shortcuts_preference_changed_callback (gpointer callback_data)
{
- GtkWidgetClass *widget_class;
- GtkObjectClass *object_class;
- GtkEditableClass *editable_class;
-
- widget_class = GTK_WIDGET_CLASS (class);
- object_class = GTK_OBJECT_CLASS (class);
- editable_class = GTK_EDITABLE_CLASS (class);
-
- widget_class->key_press_event = nautilus_entry_key_press;
- widget_class->motion_notify_event = nautilus_entry_motion_notify;
- widget_class->selection_clear_event = nautilus_entry_selection_clear;
-
- object_class->destroy = nautilus_entry_destroy;
-
- editable_class->insert_text = nautilus_entry_insert_text;
- editable_class->delete_text = nautilus_entry_delete_text;
- editable_class->set_selection = nautilus_entry_set_selection;
+ NautilusEntry *entry;
+ entry = NAUTILUS_ENTRY (callback_data);
- /* Set up signals */
- signals[USER_CHANGED] = gtk_signal_new
- ("user_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (NautilusEntryClass,
- user_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- signals[SELECTION_CHANGED] = gtk_signal_new
- ("selection_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (NautilusEntryClass,
- selection_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+ entry->details->use_emacs_shortcuts =
+ nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS);
}
static void
@@ -120,15 +72,19 @@ nautilus_entry_initialize (NautilusEntry *entry)
GtkWidget *widget;
widget = GTK_WIDGET (entry);
+ entry->details = g_new0 (NautilusEntryDetails, 1);
entry->user_edit = TRUE;
- entry->special_tab_handling = FALSE;
- entry->cursor_obscured = FALSE;
/* Allow pointer motion events so we can expose an obscured cursor if necessary */
gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_POINTER_MOTION_MASK);
nautilus_undo_set_up_nautilus_entry_for_undo (entry);
+
+ nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ emacs_shortcuts_preference_changed_callback,
+ entry);
+ emacs_shortcuts_preference_changed_callback (entry);
}
GtkWidget *
@@ -148,7 +104,6 @@ nautilus_entry_new_with_max_length (guint16 max)
return widget;
}
-
static void
nautilus_entry_destroy (GtkObject *object)
{
@@ -156,6 +111,12 @@ nautilus_entry_destroy (GtkObject *object)
entry = NAUTILUS_ENTRY (object);
+ nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ emacs_shortcuts_preference_changed_callback,
+ entry);
+
+ g_free (entry->details);
+
NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
@@ -170,14 +131,13 @@ obscure_cursor (NautilusEntry *entry)
nautilus_gdk_window_set_invisible_cursor (GTK_ENTRY (entry)->text_area);
}
-
-static gint
+static gboolean
nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
{
NautilusEntry *entry;
GtkEditable *editable;
int position;
- gint return_code;
+ gboolean result;
entry = NAUTILUS_ENTRY (widget);
editable = GTK_EDITABLE (widget);
@@ -194,8 +154,7 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
* should position the insertion point at the end of
* the selection.
*/
- if (entry->special_tab_handling
- && editable->has_selection) {
+ if (entry->special_tab_handling && editable->has_selection) {
position = strlen (gtk_entry_get_text (GTK_ENTRY (editable)));
gtk_entry_select_region (GTK_ENTRY (editable), position, position);
return TRUE;
@@ -203,9 +162,9 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
break;
case GDK_KP_Enter:
- /* Fix bug in GtkEntry where keypad Enter key inserts
- * a character rather than activating like the other
- * Enter key.
+ /* Work around bug in GtkEntry where keypad Enter key
+ * inserts a character rather than activating like the
+ * other Enter key.
*/
gtk_widget_activate (widget);
return TRUE;
@@ -214,27 +173,33 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
break;
}
- /* Filter out default GTKEntry alt and control key bindings. They have numerous conflicts
- * with Nautilus menu keyboard accelerators.
- */
- if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK) {
- return FALSE;
+ if (!entry->details->use_emacs_shortcuts) {
+ /* Filter out the emacs-style keyboard shortcuts in
+ * GtkEntry for alt and control keys. They have
+ * numerous conflicts with menu keyboard shortcuts.
+ */
+ if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK) {
+ return FALSE;
+ }
}
obscure_cursor (entry);
- return_code = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(GTK_WIDGET_CLASS, key_press_event, (widget, event));
- gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
- return return_code;
+ if (result) {
+ gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
+ }
+
+ return result;
}
-static gint
+static gboolean
nautilus_entry_motion_notify (GtkWidget *widget, GdkEventMotion *event)
{
- gint return_code;
+ int result;
guint old_start_pos, old_end_pos;
GdkCursor *cursor;
NautilusEntry *entry;
@@ -248,21 +213,17 @@ nautilus_entry_motion_notify (GtkWidget *widget, GdkEventMotion *event)
entry->cursor_obscured = FALSE;
}
- if (GTK_ENTRY (widget)->button == 0) {
- return FALSE;
- }
-
old_start_pos = GTK_EDITABLE (widget)->selection_start_pos;
old_end_pos = GTK_EDITABLE (widget)->selection_end_pos;
- return_code = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(GTK_WIDGET_CLASS, motion_notify_event, (widget, event));
- if (GTK_EDITABLE (widget)->selection_start_pos != old_start_pos ||
- GTK_EDITABLE (widget)->selection_end_pos != old_end_pos) {
+
+ if (result) {
gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
}
-
- return return_code;
+
+ return result;
}
/**
@@ -282,9 +243,15 @@ nautilus_entry_select_all (NautilusEntry *entry)
}
static gboolean
-select_all_at_idle (NautilusEntry *entry)
+select_all_at_idle (gpointer callback_data)
{
- nautilus_entry_select_all (entry);
+ NautilusEntry *entry;
+
+ entry = NAUTILUS_ENTRY (callback_data);
+ if (!GTK_OBJECT_DESTROYED (entry)) {
+ nautilus_entry_select_all (entry);
+ }
+ gtk_object_unref (GTK_OBJECT (entry));
return FALSE;
}
@@ -307,7 +274,8 @@ nautilus_entry_select_all_at_idle (NautilusEntry *entry)
* then gtk_entry_key_press will unselect (and we want
* to move the text cursor position to the end).
*/
- gtk_idle_add ((GtkFunction)select_all_at_idle, entry);
+ gtk_object_ref (GTK_OBJECT (entry));
+ gtk_idle_add (select_all_at_idle, entry);
}
/**
@@ -334,20 +302,52 @@ nautilus_entry_set_text (NautilusEntry *entry, const gchar *text)
gtk_signal_emit (GTK_OBJECT (entry), signals[SELECTION_CHANGED]);
}
-void
+static void
nautilus_entry_set_selection (GtkEditable *editable,
- gint start_pos,
- gint end_pos)
+ int start_pos,
+ int end_pos)
{
-
NAUTILUS_CALL_PARENT (GTK_EDITABLE_CLASS, set_selection,
(editable, start_pos, end_pos));
+
gtk_signal_emit (GTK_OBJECT (editable), signals[SELECTION_CHANGED]);
}
+static gboolean
+nautilus_entry_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ gboolean result;
+
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ (GTK_WIDGET_CLASS, button_press_event, (widget, event));
+
+ if (result) {
+ gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
+ }
+
+ return result;
+}
+
+static gboolean
+nautilus_entry_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ gboolean result;
+
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ (GTK_WIDGET_CLASS, button_release_event, (widget, event));
+
+ if (result) {
+ gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
+ }
+
+ return result;
+}
+
static void
nautilus_entry_insert_text (GtkEditable *editable, const gchar *text,
- gint length, gint *position)
+ int length, int *position)
{
NautilusEntry *entry;
@@ -360,18 +360,16 @@ nautilus_entry_insert_text (GtkEditable *editable, const gchar *text,
NAUTILUS_CALL_PARENT (GTK_EDITABLE_CLASS, insert_text,
(editable, text, length, position));
- gtk_signal_emit (GTK_OBJECT (editable), signals[SELECTION_CHANGED]);
+ gtk_signal_emit (GTK_OBJECT (editable), signals[SELECTION_CHANGED]);
}
-
static void
-nautilus_entry_delete_text (GtkEditable *editable, gint start_pos, gint end_pos)
+nautilus_entry_delete_text (GtkEditable *editable, int start_pos, int end_pos)
{
NautilusEntry *entry;
-
- entry = NAUTILUS_ENTRY(editable);
+ entry = NAUTILUS_ENTRY (editable);
/* Fire off user changed signals */
if (entry->user_edit) {
@@ -405,3 +403,46 @@ nautilus_entry_selection_clear (GtkWidget *widget,
return NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(GTK_WIDGET_CLASS, selection_clear_event, (widget, event));
}
+
+static void
+nautilus_entry_initialize_class (NautilusEntryClass *class)
+{
+ GtkWidgetClass *widget_class;
+ GtkObjectClass *object_class;
+ GtkEditableClass *editable_class;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ object_class = GTK_OBJECT_CLASS (class);
+ editable_class = GTK_EDITABLE_CLASS (class);
+
+ widget_class->button_press_event = nautilus_entry_button_press;
+ widget_class->button_release_event = nautilus_entry_button_release;
+ widget_class->key_press_event = nautilus_entry_key_press;
+ widget_class->motion_notify_event = nautilus_entry_motion_notify;
+ widget_class->selection_clear_event = nautilus_entry_selection_clear;
+
+ object_class->destroy = nautilus_entry_destroy;
+
+ editable_class->insert_text = nautilus_entry_insert_text;
+ editable_class->delete_text = nautilus_entry_delete_text;
+ editable_class->set_selection = nautilus_entry_set_selection;
+
+ /* Set up signals */
+ signals[USER_CHANGED] = gtk_signal_new
+ ("user_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusEntryClass,
+ user_changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ signals[SELECTION_CHANGED] = gtk_signal_new
+ ("selection_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusEntryClass,
+ selection_changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+}
diff --git a/libnautilus-extensions/nautilus-entry.h b/libnautilus-extensions/nautilus-entry.h
index d9fa23eb4..085f066c7 100644
--- a/libnautilus-extensions/nautilus-entry.h
+++ b/libnautilus-extensions/nautilus-entry.h
@@ -43,33 +43,32 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_IS_ENTRY_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ENTRY))
-typedef struct NautilusEntry NautilusEntry;
-typedef struct NautilusEntryClass NautilusEntryClass;
+typedef struct NautilusEntryDetails NautilusEntryDetails;
-struct NautilusEntry {
+typedef struct {
GtkEntry parent;
-
+ NautilusEntryDetails *details;
+
+ /* FIXME: should be in details struct */
gboolean user_edit;
gboolean special_tab_handling;
gboolean cursor_obscured;
-};
+} NautilusEntry;
-struct NautilusEntryClass {
+typedef struct {
GtkEntryClass parent_class;
- void (*user_changed) (NautilusEntry *entry);
-
+ void (*user_changed) (NautilusEntry *entry);
void (*selection_changed) (NautilusEntry *entry);
+} NautilusEntryClass;
-};
-
-GtkType nautilus_entry_get_type (void);
-GtkWidget *nautilus_entry_new (void);
-GtkWidget *nautilus_entry_new_with_max_length (guint16 max);
-void nautilus_entry_set_text (NautilusEntry *entry,
- const gchar *text);
-void nautilus_entry_select_all (NautilusEntry *entry);
-void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
+GtkType nautilus_entry_get_type (void);
+GtkWidget *nautilus_entry_new (void);
+GtkWidget *nautilus_entry_new_with_max_length (guint16 max);
+void nautilus_entry_set_text (NautilusEntry *entry,
+ const char *text);
+void nautilus_entry_select_all (NautilusEntry *entry);
+void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
END_GNOME_DECLS
diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c
index 88763d1a2..b802fdfac 100644
--- a/libnautilus-extensions/nautilus-global-preferences.c
+++ b/libnautilus-extensions/nautilus-global-preferences.c
@@ -217,6 +217,8 @@ global_preferences_install_descriptions (void)
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
_("Don't include the built-in bookmarks in the Bookmarks menu"));
+ nautilus_preferences_set_description (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ _("Use Emacs-style keyboard shortcuts in text fields"));
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_HOME_URI,
_("Location:"));
@@ -335,6 +337,10 @@ global_preferences_install_defaults (void)
nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_USER_LEVEL_NOVICE,
FALSE);
+
+ nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ NAUTILUS_USER_LEVEL_NOVICE,
+ FALSE);
/* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */
nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
@@ -475,6 +481,9 @@ global_preferences_install_visibility (void)
nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_USER_LEVEL_INTERMEDIATE);
+
+ nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ NAUTILUS_USER_LEVEL_ADVANCED);
}
/*
@@ -532,7 +541,8 @@ global_preferences_create_dialog (void)
appearance_pane = nautilus_preferences_box_add_pane (preference_box,
_("Appearance"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Smoother Graphics"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
+ _("Smoother Graphics"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
0,
@@ -551,13 +561,17 @@ global_preferences_create_dialog (void)
windows_and_desktop_pane = nautilus_preferences_box_add_pane (preference_box,
_("Windows & Desktop"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), _("Desktop"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Desktop"));
+
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
0,
NAUTILUS_PREFERENCES_SHOW_DESKTOP,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), _("Opening New Windows"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Opening New Windows"));
+
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
1,
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
@@ -580,35 +594,50 @@ global_preferences_create_dialog (void)
NAUTILUS_PREFERENCES_START_WITH_SIDEBAR,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), _("Trash Behavior"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Trash Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
2,
NAUTILUS_PREFERENCES_CONFIRM_TRASH,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
-
+ /* FIXME: This group clearly doesn't belong in Windows &
+ * Desktop, but there's no obviously-better place for it and
+ * it probably doesn't deserve a pane of its own.
+ */
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Keyboard Shortcuts"));
+
+ nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ 3,
+ NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
+
/*
* Folder Views pane
*/
directory_views_pane = nautilus_preferences_box_add_pane (preference_box,
_("Icon & List Views"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Click Behavior"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
+ _("Click Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
0,
NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_PREFERENCE_ITEM_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Executable Text Files"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
+ _("Executable Text Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
1,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
NAUTILUS_PREFERENCE_ITEM_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Show/Hide Options"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
+ _("Show/Hide Options"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
2,
@@ -683,14 +712,16 @@ global_preferences_create_dialog (void)
navigation_pane = nautilus_preferences_box_add_pane (preference_box,
_("Navigation"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), _("Home"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
+ _("Home"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
0,
NAUTILUS_PREFERENCES_HOME_URI,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), _("HTTP Proxy Settings"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
+ _("HTTP Proxy Settings"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
1,
@@ -715,44 +746,47 @@ global_preferences_create_dialog (void)
NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
-
/*
* Tradeoffs
*/
tradeoffs_pane = nautilus_preferences_box_add_pane (preference_box,
_("Speed Tradeoffs"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Text in Icons"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Show Text in Icons"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
0,
NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Count of Items in Folders"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Show Count of Items in Folders"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
1,
NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Thumbnails for Image Files"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Show Thumbnails for Image Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
2,
NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Preview Sound Files"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Preview Sound Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
3,
NAUTILUS_PREFERENCES_PREVIEW_SOUND,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
-
/* FIXME bugzilla.eazel.com 2560: This title phrase needs improvement. */
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Make Folder Appearance Details Public"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Make Folder Appearance Details Public"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
4,
diff --git a/libnautilus-extensions/nautilus-global-preferences.h b/libnautilus-extensions/nautilus-global-preferences.h
index 9409b1f03..3c17327f2 100644
--- a/libnautilus-extensions/nautilus-global-preferences.h
+++ b/libnautilus-extensions/nautilus-global-preferences.h
@@ -41,6 +41,9 @@ BEGIN_GNOME_DECLS
/* Does the system have audio output capability */
#define NAUTILUS_PREFERENCES_HAS_AUDIO_OUT "preferences/audio_out"
+/* Text fields */
+#define NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS "preferences/use_emacs_shortcuts"
+
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"
diff --git a/libnautilus-private/nautilus-entry.c b/libnautilus-private/nautilus-entry.c
index 10af50e5d..4d4a684ff 100644
--- a/libnautilus-private/nautilus-entry.c
+++ b/libnautilus-private/nautilus-entry.c
@@ -28,20 +28,18 @@
#include "nautilus-entry.h"
#include "nautilus-gtk-macros.h"
-
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtksignal.h>
#include <gtk/gtkmain.h>
-#include <gtk/gtkwidget.h>
-
-#include <libgnome/gnome-defs.h>
+#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
-
#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+#include <libnautilus-extensions/nautilus-global-preferences.h>
#include <libnautilus-extensions/nautilus-undo-signal-handlers.h>
-
#include <orb/orbit.h>
+struct NautilusEntryDetails {
+ gboolean use_emacs_shortcuts;
+};
enum {
USER_CHANGED,
@@ -50,68 +48,22 @@ enum {
};
static guint signals[LAST_SIGNAL];
-static void nautilus_entry_initialize (NautilusEntry *entry);
+static void nautilus_entry_initialize (NautilusEntry *entry);
static void nautilus_entry_initialize_class (NautilusEntryClass *class);
-static void nautilus_entry_destroy (GtkObject *object);
-static gint nautilus_entry_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint nautilus_entry_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-static void nautilus_entry_insert_text (GtkEditable *editable,
- const gchar *text,
- gint length,
- gint *position);
-static gboolean nautilus_entry_selection_clear (GtkWidget *widget,
- GdkEventSelection *event);
-static void nautilus_entry_delete_text (GtkEditable *editable,
- gint start_pos,
- gint end_pos);
-static void nautilus_entry_set_selection (GtkEditable *editable,
- gint start_pos,
- gint end_pos);
-
-NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusEntry, nautilus_entry, GTK_TYPE_ENTRY)
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusEntry,
+ nautilus_entry,
+ GTK_TYPE_ENTRY)
static void
-nautilus_entry_initialize_class (NautilusEntryClass *class)
+emacs_shortcuts_preference_changed_callback (gpointer callback_data)
{
- GtkWidgetClass *widget_class;
- GtkObjectClass *object_class;
- GtkEditableClass *editable_class;
-
- widget_class = GTK_WIDGET_CLASS (class);
- object_class = GTK_OBJECT_CLASS (class);
- editable_class = GTK_EDITABLE_CLASS (class);
-
- widget_class->key_press_event = nautilus_entry_key_press;
- widget_class->motion_notify_event = nautilus_entry_motion_notify;
- widget_class->selection_clear_event = nautilus_entry_selection_clear;
-
- object_class->destroy = nautilus_entry_destroy;
-
- editable_class->insert_text = nautilus_entry_insert_text;
- editable_class->delete_text = nautilus_entry_delete_text;
- editable_class->set_selection = nautilus_entry_set_selection;
+ NautilusEntry *entry;
+ entry = NAUTILUS_ENTRY (callback_data);
- /* Set up signals */
- signals[USER_CHANGED] = gtk_signal_new
- ("user_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (NautilusEntryClass,
- user_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- signals[SELECTION_CHANGED] = gtk_signal_new
- ("selection_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (NautilusEntryClass,
- selection_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+ entry->details->use_emacs_shortcuts =
+ nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS);
}
static void
@@ -120,15 +72,19 @@ nautilus_entry_initialize (NautilusEntry *entry)
GtkWidget *widget;
widget = GTK_WIDGET (entry);
+ entry->details = g_new0 (NautilusEntryDetails, 1);
entry->user_edit = TRUE;
- entry->special_tab_handling = FALSE;
- entry->cursor_obscured = FALSE;
/* Allow pointer motion events so we can expose an obscured cursor if necessary */
gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_POINTER_MOTION_MASK);
nautilus_undo_set_up_nautilus_entry_for_undo (entry);
+
+ nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ emacs_shortcuts_preference_changed_callback,
+ entry);
+ emacs_shortcuts_preference_changed_callback (entry);
}
GtkWidget *
@@ -148,7 +104,6 @@ nautilus_entry_new_with_max_length (guint16 max)
return widget;
}
-
static void
nautilus_entry_destroy (GtkObject *object)
{
@@ -156,6 +111,12 @@ nautilus_entry_destroy (GtkObject *object)
entry = NAUTILUS_ENTRY (object);
+ nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ emacs_shortcuts_preference_changed_callback,
+ entry);
+
+ g_free (entry->details);
+
NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
@@ -170,14 +131,13 @@ obscure_cursor (NautilusEntry *entry)
nautilus_gdk_window_set_invisible_cursor (GTK_ENTRY (entry)->text_area);
}
-
-static gint
+static gboolean
nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
{
NautilusEntry *entry;
GtkEditable *editable;
int position;
- gint return_code;
+ gboolean result;
entry = NAUTILUS_ENTRY (widget);
editable = GTK_EDITABLE (widget);
@@ -194,8 +154,7 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
* should position the insertion point at the end of
* the selection.
*/
- if (entry->special_tab_handling
- && editable->has_selection) {
+ if (entry->special_tab_handling && editable->has_selection) {
position = strlen (gtk_entry_get_text (GTK_ENTRY (editable)));
gtk_entry_select_region (GTK_ENTRY (editable), position, position);
return TRUE;
@@ -203,9 +162,9 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
break;
case GDK_KP_Enter:
- /* Fix bug in GtkEntry where keypad Enter key inserts
- * a character rather than activating like the other
- * Enter key.
+ /* Work around bug in GtkEntry where keypad Enter key
+ * inserts a character rather than activating like the
+ * other Enter key.
*/
gtk_widget_activate (widget);
return TRUE;
@@ -214,27 +173,33 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
break;
}
- /* Filter out default GTKEntry alt and control key bindings. They have numerous conflicts
- * with Nautilus menu keyboard accelerators.
- */
- if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK) {
- return FALSE;
+ if (!entry->details->use_emacs_shortcuts) {
+ /* Filter out the emacs-style keyboard shortcuts in
+ * GtkEntry for alt and control keys. They have
+ * numerous conflicts with menu keyboard shortcuts.
+ */
+ if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK) {
+ return FALSE;
+ }
}
obscure_cursor (entry);
- return_code = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(GTK_WIDGET_CLASS, key_press_event, (widget, event));
- gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
- return return_code;
+ if (result) {
+ gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
+ }
+
+ return result;
}
-static gint
+static gboolean
nautilus_entry_motion_notify (GtkWidget *widget, GdkEventMotion *event)
{
- gint return_code;
+ int result;
guint old_start_pos, old_end_pos;
GdkCursor *cursor;
NautilusEntry *entry;
@@ -248,21 +213,17 @@ nautilus_entry_motion_notify (GtkWidget *widget, GdkEventMotion *event)
entry->cursor_obscured = FALSE;
}
- if (GTK_ENTRY (widget)->button == 0) {
- return FALSE;
- }
-
old_start_pos = GTK_EDITABLE (widget)->selection_start_pos;
old_end_pos = GTK_EDITABLE (widget)->selection_end_pos;
- return_code = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(GTK_WIDGET_CLASS, motion_notify_event, (widget, event));
- if (GTK_EDITABLE (widget)->selection_start_pos != old_start_pos ||
- GTK_EDITABLE (widget)->selection_end_pos != old_end_pos) {
+
+ if (result) {
gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
}
-
- return return_code;
+
+ return result;
}
/**
@@ -282,9 +243,15 @@ nautilus_entry_select_all (NautilusEntry *entry)
}
static gboolean
-select_all_at_idle (NautilusEntry *entry)
+select_all_at_idle (gpointer callback_data)
{
- nautilus_entry_select_all (entry);
+ NautilusEntry *entry;
+
+ entry = NAUTILUS_ENTRY (callback_data);
+ if (!GTK_OBJECT_DESTROYED (entry)) {
+ nautilus_entry_select_all (entry);
+ }
+ gtk_object_unref (GTK_OBJECT (entry));
return FALSE;
}
@@ -307,7 +274,8 @@ nautilus_entry_select_all_at_idle (NautilusEntry *entry)
* then gtk_entry_key_press will unselect (and we want
* to move the text cursor position to the end).
*/
- gtk_idle_add ((GtkFunction)select_all_at_idle, entry);
+ gtk_object_ref (GTK_OBJECT (entry));
+ gtk_idle_add (select_all_at_idle, entry);
}
/**
@@ -334,20 +302,52 @@ nautilus_entry_set_text (NautilusEntry *entry, const gchar *text)
gtk_signal_emit (GTK_OBJECT (entry), signals[SELECTION_CHANGED]);
}
-void
+static void
nautilus_entry_set_selection (GtkEditable *editable,
- gint start_pos,
- gint end_pos)
+ int start_pos,
+ int end_pos)
{
-
NAUTILUS_CALL_PARENT (GTK_EDITABLE_CLASS, set_selection,
(editable, start_pos, end_pos));
+
gtk_signal_emit (GTK_OBJECT (editable), signals[SELECTION_CHANGED]);
}
+static gboolean
+nautilus_entry_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ gboolean result;
+
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ (GTK_WIDGET_CLASS, button_press_event, (widget, event));
+
+ if (result) {
+ gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
+ }
+
+ return result;
+}
+
+static gboolean
+nautilus_entry_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ gboolean result;
+
+ result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
+ (GTK_WIDGET_CLASS, button_release_event, (widget, event));
+
+ if (result) {
+ gtk_signal_emit (GTK_OBJECT (widget), signals[SELECTION_CHANGED]);
+ }
+
+ return result;
+}
+
static void
nautilus_entry_insert_text (GtkEditable *editable, const gchar *text,
- gint length, gint *position)
+ int length, int *position)
{
NautilusEntry *entry;
@@ -360,18 +360,16 @@ nautilus_entry_insert_text (GtkEditable *editable, const gchar *text,
NAUTILUS_CALL_PARENT (GTK_EDITABLE_CLASS, insert_text,
(editable, text, length, position));
- gtk_signal_emit (GTK_OBJECT (editable), signals[SELECTION_CHANGED]);
+ gtk_signal_emit (GTK_OBJECT (editable), signals[SELECTION_CHANGED]);
}
-
static void
-nautilus_entry_delete_text (GtkEditable *editable, gint start_pos, gint end_pos)
+nautilus_entry_delete_text (GtkEditable *editable, int start_pos, int end_pos)
{
NautilusEntry *entry;
-
- entry = NAUTILUS_ENTRY(editable);
+ entry = NAUTILUS_ENTRY (editable);
/* Fire off user changed signals */
if (entry->user_edit) {
@@ -405,3 +403,46 @@ nautilus_entry_selection_clear (GtkWidget *widget,
return NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(GTK_WIDGET_CLASS, selection_clear_event, (widget, event));
}
+
+static void
+nautilus_entry_initialize_class (NautilusEntryClass *class)
+{
+ GtkWidgetClass *widget_class;
+ GtkObjectClass *object_class;
+ GtkEditableClass *editable_class;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ object_class = GTK_OBJECT_CLASS (class);
+ editable_class = GTK_EDITABLE_CLASS (class);
+
+ widget_class->button_press_event = nautilus_entry_button_press;
+ widget_class->button_release_event = nautilus_entry_button_release;
+ widget_class->key_press_event = nautilus_entry_key_press;
+ widget_class->motion_notify_event = nautilus_entry_motion_notify;
+ widget_class->selection_clear_event = nautilus_entry_selection_clear;
+
+ object_class->destroy = nautilus_entry_destroy;
+
+ editable_class->insert_text = nautilus_entry_insert_text;
+ editable_class->delete_text = nautilus_entry_delete_text;
+ editable_class->set_selection = nautilus_entry_set_selection;
+
+ /* Set up signals */
+ signals[USER_CHANGED] = gtk_signal_new
+ ("user_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusEntryClass,
+ user_changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ signals[SELECTION_CHANGED] = gtk_signal_new
+ ("selection_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusEntryClass,
+ selection_changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+}
diff --git a/libnautilus-private/nautilus-entry.h b/libnautilus-private/nautilus-entry.h
index d9fa23eb4..085f066c7 100644
--- a/libnautilus-private/nautilus-entry.h
+++ b/libnautilus-private/nautilus-entry.h
@@ -43,33 +43,32 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_IS_ENTRY_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ENTRY))
-typedef struct NautilusEntry NautilusEntry;
-typedef struct NautilusEntryClass NautilusEntryClass;
+typedef struct NautilusEntryDetails NautilusEntryDetails;
-struct NautilusEntry {
+typedef struct {
GtkEntry parent;
-
+ NautilusEntryDetails *details;
+
+ /* FIXME: should be in details struct */
gboolean user_edit;
gboolean special_tab_handling;
gboolean cursor_obscured;
-};
+} NautilusEntry;
-struct NautilusEntryClass {
+typedef struct {
GtkEntryClass parent_class;
- void (*user_changed) (NautilusEntry *entry);
-
+ void (*user_changed) (NautilusEntry *entry);
void (*selection_changed) (NautilusEntry *entry);
+} NautilusEntryClass;
-};
-
-GtkType nautilus_entry_get_type (void);
-GtkWidget *nautilus_entry_new (void);
-GtkWidget *nautilus_entry_new_with_max_length (guint16 max);
-void nautilus_entry_set_text (NautilusEntry *entry,
- const gchar *text);
-void nautilus_entry_select_all (NautilusEntry *entry);
-void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
+GtkType nautilus_entry_get_type (void);
+GtkWidget *nautilus_entry_new (void);
+GtkWidget *nautilus_entry_new_with_max_length (guint16 max);
+void nautilus_entry_set_text (NautilusEntry *entry,
+ const char *text);
+void nautilus_entry_select_all (NautilusEntry *entry);
+void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
END_GNOME_DECLS
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 88763d1a2..b802fdfac 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -217,6 +217,8 @@ global_preferences_install_descriptions (void)
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
_("Don't include the built-in bookmarks in the Bookmarks menu"));
+ nautilus_preferences_set_description (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ _("Use Emacs-style keyboard shortcuts in text fields"));
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_HOME_URI,
_("Location:"));
@@ -335,6 +337,10 @@ global_preferences_install_defaults (void)
nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_USER_LEVEL_NOVICE,
FALSE);
+
+ nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ NAUTILUS_USER_LEVEL_NOVICE,
+ FALSE);
/* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */
nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
@@ -475,6 +481,9 @@ global_preferences_install_visibility (void)
nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_USER_LEVEL_INTERMEDIATE);
+
+ nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ NAUTILUS_USER_LEVEL_ADVANCED);
}
/*
@@ -532,7 +541,8 @@ global_preferences_create_dialog (void)
appearance_pane = nautilus_preferences_box_add_pane (preference_box,
_("Appearance"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Smoother Graphics"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
+ _("Smoother Graphics"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
0,
@@ -551,13 +561,17 @@ global_preferences_create_dialog (void)
windows_and_desktop_pane = nautilus_preferences_box_add_pane (preference_box,
_("Windows & Desktop"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), _("Desktop"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Desktop"));
+
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
0,
NAUTILUS_PREFERENCES_SHOW_DESKTOP,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), _("Opening New Windows"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Opening New Windows"));
+
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
1,
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
@@ -580,35 +594,50 @@ global_preferences_create_dialog (void)
NAUTILUS_PREFERENCES_START_WITH_SIDEBAR,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), _("Trash Behavior"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Trash Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
2,
NAUTILUS_PREFERENCES_CONFIRM_TRASH,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
-
+ /* FIXME: This group clearly doesn't belong in Windows &
+ * Desktop, but there's no obviously-better place for it and
+ * it probably doesn't deserve a pane of its own.
+ */
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ _("Keyboard Shortcuts"));
+
+ nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane),
+ 3,
+ NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS,
+ NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
+
/*
* Folder Views pane
*/
directory_views_pane = nautilus_preferences_box_add_pane (preference_box,
_("Icon & List Views"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Click Behavior"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
+ _("Click Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
0,
NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_PREFERENCE_ITEM_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Executable Text Files"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
+ _("Executable Text Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
1,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
NAUTILUS_PREFERENCE_ITEM_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Show/Hide Options"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
+ _("Show/Hide Options"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
2,
@@ -683,14 +712,16 @@ global_preferences_create_dialog (void)
navigation_pane = nautilus_preferences_box_add_pane (preference_box,
_("Navigation"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), _("Home"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
+ _("Home"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
0,
NAUTILUS_PREFERENCES_HOME_URI,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), _("HTTP Proxy Settings"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
+ _("HTTP Proxy Settings"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
1,
@@ -715,44 +746,47 @@ global_preferences_create_dialog (void)
NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
-
/*
* Tradeoffs
*/
tradeoffs_pane = nautilus_preferences_box_add_pane (preference_box,
_("Speed Tradeoffs"));
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Text in Icons"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Show Text in Icons"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
0,
NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Count of Items in Folders"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Show Count of Items in Folders"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
1,
NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Thumbnails for Image Files"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Show Thumbnails for Image Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
2,
NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Preview Sound Files"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Preview Sound Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
3,
NAUTILUS_PREFERENCES_PREVIEW_SOUND,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
-
/* FIXME bugzilla.eazel.com 2560: This title phrase needs improvement. */
- nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Make Folder Appearance Details Public"));
+ nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
+ _("Make Folder Appearance Details Public"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
4,
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 9409b1f03..3c17327f2 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -41,6 +41,9 @@ BEGIN_GNOME_DECLS
/* Does the system have audio output capability */
#define NAUTILUS_PREFERENCES_HAS_AUDIO_OUT "preferences/audio_out"
+/* Text fields */
+#define NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS "preferences/use_emacs_shortcuts"
+
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"
diff --git a/libnautilus/nautilus-clipboard-ui.xml b/libnautilus/nautilus-clipboard-ui.xml
index 34a0f90b1..431cb2017 100644
--- a/libnautilus/nautilus-clipboard-ui.xml
+++ b/libnautilus/nautilus-clipboard-ui.xml
@@ -1,9 +1,11 @@
<Root>
+
<commands>
<cmd name="Cut" accel="*Control*x" sensitive="1"/>
<cmd name="Copy" accel="*Control*c" sensitive="1"/>
<cmd name="Paste" accel="*Control*v" sensitive="1"/>
<cmd name="Clear" sensitive="1"/>
+ <cmd name="Select All" accel="*Control*a" sensitive="1"/>
</commands>
<menu>
@@ -28,6 +30,9 @@
_tip="Remove the selected text without putting it on the clipboard"
pixtype="stock" pixname="Clear"
verb="Clear"/>
+ <menuitem name="Select All"
+ _label="Select _All"
+ verb="Select All"/>
</submenu>
</menu>
</Root>
diff --git a/libnautilus/nautilus-clipboard.c b/libnautilus/nautilus-clipboard.c
index 584e9cc69..badb92339 100644
--- a/libnautilus/nautilus-clipboard.c
+++ b/libnautilus/nautilus-clipboard.c
@@ -28,14 +28,14 @@
*/
#include <config.h>
-#include "nautilus-bonobo-ui.h"
#include "nautilus-clipboard.h"
+#include "nautilus-bonobo-ui.h"
#include <bonobo/bonobo-ui-util.h>
-#include <gtk/gtkeditable.h>
#include <gtk/gtkinvisible.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
+#include <gtk/gtktext.h>
typedef void (* EditableFunction) (GtkEditable *editable);
@@ -134,6 +134,54 @@ clear_callback (BonoboUIComponent *ui,
}
static void
+select_all (GtkEditable *editable)
+{
+ int end;
+
+ /* Workaround for bug in GtkText. It can't handle a -1
+ * passed in to set_position.
+ */
+ end = -1;
+ if (GTK_IS_TEXT (editable)) {
+ end = gtk_text_get_length (GTK_TEXT (editable));
+ }
+
+ gtk_editable_set_position (editable, end);
+ gtk_editable_select_region (editable, 0, end);
+}
+
+static gboolean
+select_all_idle_callback (gpointer callback_data)
+{
+ GtkEditable *editable;
+
+ editable = GTK_EDITABLE (callback_data);
+
+ if (!GTK_OBJECT_DESTROYED (GTK_OBJECT (editable))) {
+ select_all (editable);
+ }
+
+ gtk_object_unref (GTK_OBJECT (editable));
+
+ return FALSE;
+}
+
+static void
+select_all_callback (BonoboUIComponent *ui,
+ gpointer callback_data,
+ const char *command_name)
+{
+ GtkEditable *editable;
+
+ g_assert (BONOBO_IS_UI_COMPONENT (ui));
+ g_assert (strcmp (command_name, "Select All") == 0);
+
+ editable = GTK_EDITABLE (callback_data);
+ gtk_object_ref (GTK_OBJECT (editable));
+ gtk_idle_add (select_all_idle_callback, editable);
+}
+
+static void
set_menu_item_sensitive (BonoboUIComponent *component,
const char *path,
gboolean sensitive)
@@ -146,23 +194,25 @@ set_menu_item_sensitive (BonoboUIComponent *component,
}
+#if 0
static void
set_paste_sensitive_if_clipboard_contains_data (BonoboUIComponent *component)
{
-#if 0
gboolean clipboard_contains_data;
- /* FIXME: This is wrong. This will only return non-null if
- the clipboard owner is in process, which may not be the case,
- and we may still be able to paste data */
-
+ /* FIXME: This check is wrong, because gdk_selection_owner_get
+ * will only return non-null if the clipboard owner is in
+ * process, which may not be the case, and we may still be
+ * able to paste data.
+ */
clipboard_contains_data =
(gdk_selection_owner_get (GDK_SELECTION_PRIMARY) != NULL);
-#endif
+
set_menu_item_sensitive (component,
NAUTILUS_COMMAND_PASTE,
- TRUE);
+ clipboard_contains_data);
}
+#endif
static void
set_clipboard_menu_items_sensitive (BonoboUIComponent *component)
@@ -176,13 +226,10 @@ set_clipboard_menu_items_sensitive (BonoboUIComponent *component)
set_menu_item_sensitive (component,
NAUTILUS_COMMAND_CLEAR,
TRUE);
- set_paste_sensitive_if_clipboard_contains_data (component);
}
-
static void
-set_clipboard_menu_items_insensitive (BonoboUIComponent *component,
- gboolean enable_paste_for_full_clipboard)
+set_clipboard_menu_items_insensitive (BonoboUIComponent *component)
{
set_menu_item_sensitive (component,
NAUTILUS_COMMAND_CUT,
@@ -193,17 +240,8 @@ set_clipboard_menu_items_insensitive (BonoboUIComponent *component,
set_menu_item_sensitive (component,
NAUTILUS_COMMAND_CLEAR,
FALSE);
- if (enable_paste_for_full_clipboard) {
- set_paste_sensitive_if_clipboard_contains_data (component);
- }
- else {
- set_menu_item_sensitive (component,
- NAUTILUS_COMMAND_PASTE,
- FALSE);
- }
}
-
typedef struct {
BonoboUIComponent *component;
Bonobo_UIContainer container;
@@ -213,19 +251,21 @@ typedef struct {
static gboolean
clipboard_items_are_merged_in (GtkWidget *widget)
{
- return GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), "clipboard_menu_items_merged"));
+ return GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
+ "Nautilus:clipboard_menu_items_merged"));
}
static void
-set_clipboard_items_are_merged_in (GtkObject *widget_object,
+set_clipboard_items_are_merged_in (GtkObject *widget_as_object,
gboolean merged_in)
{
- gtk_object_set_data (widget_object, "clipboard_menu_items_merged",
+ gtk_object_set_data (widget_as_object,
+ "Nautilus:clipboard_menu_items_merged",
GINT_TO_POINTER (merged_in));
}
static void
-merge_in_clipboard_menu_items (GtkObject *widget_object,
+merge_in_clipboard_menu_items (GtkObject *widget_as_object,
TargetCallbackData *target_data)
{
BonoboUIComponent *ui;
@@ -237,7 +277,6 @@ merge_in_clipboard_menu_items (GtkObject *widget_object,
container = target_data->container;
add_selection_callback = target_data->editable_shares_selection_changes;
-
bonobo_ui_component_set_container (ui,
container);
bonobo_ui_component_freeze (ui, NULL);
@@ -245,25 +284,23 @@ merge_in_clipboard_menu_items (GtkObject *widget_object,
DATADIR,
"nautilus-clipboard-ui.xml",
"nautilus");
-
if (add_selection_callback) {
- gtk_signal_connect_after (GTK_OBJECT (widget_object), "selection_changed",
+ gtk_signal_connect_after (GTK_OBJECT (widget_as_object), "selection_changed",
selection_changed_callback, target_data);
- selection_changed_callback (GTK_WIDGET (widget_object),
+ selection_changed_callback (GTK_WIDGET (widget_as_object),
target_data);
- }
- else {
+ } else {
/* If we don't use sensitivity, everything should be on */
set_clipboard_menu_items_sensitive (ui);
}
- set_clipboard_items_are_merged_in (widget_object, TRUE);
+ set_clipboard_items_are_merged_in (widget_as_object, TRUE);
bonobo_ui_component_thaw (ui, NULL);
}
static void
-merge_out_clipboard_menu_items (GtkObject *widget_object,
+merge_out_clipboard_menu_items (GtkObject *widget_as_object,
TargetCallbackData *target_data)
{
@@ -276,15 +313,13 @@ merge_out_clipboard_menu_items (GtkObject *widget_object,
bonobo_ui_component_unset_container (ui);
if (selection_callback_was_added) {
- gtk_signal_disconnect_by_func (GTK_OBJECT (widget_object),
+ gtk_signal_disconnect_by_func (GTK_OBJECT (widget_as_object),
selection_changed_callback,
target_data);
}
- set_clipboard_items_are_merged_in (widget_object, FALSE);
+ set_clipboard_items_are_merged_in (widget_as_object, FALSE);
}
-
-
static void
focus_changed_callback (GtkWidget *widget,
GdkEventAny *event,
@@ -301,7 +336,7 @@ focus_changed_callback (GtkWidget *widget,
/* Connect the component to the container if the widget has focus. */
ui = target_data->component;
if (GTK_WIDGET_HAS_FOCUS (widget)) {
- if (clipboard_items_are_merged_in (widget) == FALSE) {
+ if (!clipboard_items_are_merged_in (widget)) {
merge_in_clipboard_menu_items (GTK_OBJECT (widget),
target_data);
}
@@ -335,14 +370,11 @@ selection_changed_callback (GtkWidget *widget,
component = target_data->component;
editable = GTK_EDITABLE (widget);
- if (editable->selection_start_pos != editable->selection_end_pos) {
+ if (editable->selection_start_pos != editable->selection_end_pos) {
set_clipboard_menu_items_sensitive (component);
+ } else {
+ set_clipboard_menu_items_insensitive (component);
}
- else {
- set_clipboard_menu_items_insensitive (component,
- TRUE);
- }
-
}
static void
@@ -374,6 +406,7 @@ initialize_clipboard_component_with_callback_data (GtkEditable *target,
BONOBO_UI_VERB ("Copy", copy_callback),
BONOBO_UI_VERB ("Paste", paste_callback),
BONOBO_UI_VERB ("Clear", clear_callback),
+ BONOBO_UI_VERB ("Select All", select_all_callback),
BONOBO_UI_VERB_END
};
BonoboUIComponent *ui;
@@ -433,7 +466,8 @@ nautilus_clipboard_set_up_editable (GtkEditable *target,
static gboolean
widget_was_set_up_with_selection_sensitivity (GtkWidget *widget)
{
- return GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), "shares_selection_changes"));
+ return GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
+ "Nautilus:shares_selection_changes"));
}
static void
@@ -479,7 +513,9 @@ nautilus_clipboard_set_up_editable_in_control (GtkEditable *target,
/* We'd like to use gtk_signal_connect_while_alive, but it's
* not compatible with gtk_signal_disconnect calls.
*/
- gtk_object_set_data (GTK_OBJECT (target), "shares_selection_changes", GINT_TO_POINTER (shares_selection_changes));
+ gtk_object_set_data (GTK_OBJECT (target),
+ "Nautilus:shares_selection_changes",
+ GINT_TO_POINTER (shares_selection_changes));
gtk_signal_connect (GTK_OBJECT (target),
"focus_in_event",
first_focus_callback,
diff --git a/librsvg/art_render_mask.c b/librsvg/art_render_mask.c
index def056a04..81b28a273 100644
--- a/librsvg/art_render_mask.c
+++ b/librsvg/art_render_mask.c
@@ -63,26 +63,25 @@ art_render_mask_render (ArtRenderCallback *self, ArtRender *render,
int x0 = render->x0, x1 = render->x1;
int z_x0 = z->x0, z_x1 = z->x1;
int width = x1 - x0;
+ int z_width = z_x1 - z_x0;
art_u8 *alpha_buf = render->alpha_buf;
- if (y < z->y0 || y >= z->y1)
+ if (y < z->y0 || y >= z->y1 || z_width <= 0)
memset (alpha_buf, 0, width);
else
{
const art_u8 *src_line = z->mask_buf + (y - z->y0) * z->rowstride;
- art_u8 *dst_line = alpha_buf + z->x0 - x0;
- int z_width = z->x1 - z->x0;
+ art_u8 *dst_line = alpha_buf + z_x0 - x0;
if (z_x0 > x0)
memset (alpha_buf, 0, z_x0 - x0);
+
if (z->first)
- {
- memcpy (dst_line, src_line, z_width);
- }
+ memcpy (dst_line, src_line, z_width);
else
{
int x;
-
+
for (x = 0; x < z_width; x++)
{
int v;
@@ -99,6 +98,7 @@ art_render_mask_render (ArtRenderCallback *self, ArtRender *render,
}
}
}
+
if (z_x1 < x1)
memset (alpha_buf + z_x1 - x0, 0, x1 - z_x1);
}
diff --git a/librsvg/rsvg.c b/librsvg/rsvg.c
index 96b7c02a5..67902f86f 100644
--- a/librsvg/rsvg.c
+++ b/librsvg/rsvg.c
@@ -140,21 +140,18 @@ rsvg_ctx_new (void)
static void
rsvg_state_init (RsvgState *state)
{
+ memset (state, 0, sizeof (*state));
+
art_affine_identity (state->affine);
state->opacity = 0xff;
state->fill = rsvg_paint_server_parse (NULL, "#000");
state->fill_opacity = 0xff;
- state->stroke = NULL;
state->stroke_opacity = 0xff;
state->stroke_width = 1;
state->cap = ART_PATH_STROKE_CAP_BUTT;
state->join = ART_PATH_STROKE_JOIN_MITER;
- state->stop_color = 0;
state->stop_opacity = 0xff;
-
- state->in_defs = FALSE;
- state->save_pixbuf = NULL;
}
static void
@@ -952,7 +949,7 @@ rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len)
state = &ctx->state[ctx->n_state - 1];
- if (state->fill != NULL)
+ if (state->fill != NULL && state->font_size > 0)
{
pixbuf = ctx->pixbuf;
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);