Support icon stretching and drive formatting

This commit is contained in:
Matthias Clasen 2005-10-28 12:43:41 +00:00
parent 6bdfd2f175
commit a95948e73e
3 changed files with 392 additions and 17 deletions

View File

@ -1,5 +1,5 @@
--- nautilus-2.12.1/src/file-manager/fm-actions.h.format 2005-07-01 06:22:19.000000000 -0400
+++ nautilus-2.12.1/src/file-manager/fm-actions.h 2005-10-21 10:35:58.000000000 -0400
+++ nautilus-2.12.1/src/file-manager/fm-actions.h 2005-10-27 14:35:29.000000000 -0400
@@ -57,6 +57,7 @@
#define FM_ACTION_MOUNT_VOLUME "Mount Volume"
#define FM_ACTION_UNMOUNT_VOLUME "Unmount Volume"
@ -9,7 +9,7 @@
#define FM_ACTION_NEW_DOCUMENTS "New Documents"
#define FM_ACTION_NEW_EMPTY_FILE "New Empty File"
--- nautilus-2.12.1/src/file-manager/fm-directory-view.c.format 2005-09-27 04:31:43.000000000 -0400
+++ nautilus-2.12.1/src/file-manager/fm-directory-view.c 2005-10-21 10:38:28.000000000 -0400
+++ nautilus-2.12.1/src/file-manager/fm-directory-view.c 2005-10-27 23:14:56.000000000 -0400
@@ -377,6 +377,8 @@
gpointer data);
static void action_unmount_volume_callback (GtkAction *action,
@ -19,7 +19,7 @@
/* location popup-related actions */
@@ -5796,6 +5798,31 @@
@@ -5796,6 +5798,43 @@
nautilus_file_list_free (selection);
}
@ -30,6 +30,8 @@
+ NautilusFile *file;
+ GList *selection, *l;
+ GnomeVFSDrive *drive;
+ char *device_path;
+ char *cmdline;
+ FMDirectoryView *view;
+
+ view = FM_DIRECTORY_VIEW (data);
@ -40,9 +42,19 @@
+
+ if (nautilus_file_has_drive (file)) {
+ drive = nautilus_file_get_drive (file);
+ device_path = gnome_vfs_drive_get_device_path (drive);
+
+ if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY) {
+ g_spawn_command_line_async ("gfloppy", NULL);
+
+
+ cmdline = g_strconcat ("gfloppy ", device_path, NULL);
+ }
+ else {
+ cmdline = g_strconcat ("userformat ", device_path, NULL);
+ }
+ g_spawn_command_line_async (cmdline, NULL);
+ g_free (cmdline);
+ g_free (device_path);
+ }
+ }
+ nautilus_file_list_free (selection);
@ -51,7 +63,7 @@
static void
action_eject_volume_callback (GtkAction *action,
gpointer data)
@@ -6218,6 +6245,10 @@
@@ -6218,6 +6257,10 @@
N_("_Eject"), NULL, /* label, accelerator */
N_("Eject the selected volume"), /* tooltip */
G_CALLBACK (action_eject_volume_callback) },
@ -62,7 +74,7 @@
{ "OpenCloseParent", NULL, /* name, stock id */
N_("Open File and Close window"), "<alt><shift>Down", /* label, accelerator */
NULL, /* tooltip */
@@ -6457,7 +6488,8 @@
@@ -6457,7 +6500,8 @@
gboolean *show_mount,
gboolean *show_unmount,
gboolean *show_eject,
@ -72,7 +84,7 @@
{
GnomeVFSVolume *volume;
GnomeVFSDrive *drive;
@@ -6467,6 +6499,7 @@
@@ -6467,6 +6511,7 @@
*show_unmount = FALSE;
*show_eject = FALSE;
*show_connect = FALSE;
@ -80,19 +92,26 @@
if (nautilus_file_has_volume (file)) {
*show_unmount = TRUE;
@@ -6481,6 +6514,11 @@
@@ -6476,11 +6521,18 @@
} else if (nautilus_file_has_drive (file)) {
drive = nautilus_file_get_drive (file);
*show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
+ if ((gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY &&
+ g_find_program_in_path ("gfloppy")) ||
+ g_find_program_in_path ("userformat")) {
+ *show_format = TRUE;
+ }
if (gnome_vfs_drive_is_mounted (drive)) {
*show_unmount = TRUE;
+ *show_format = FALSE;
} else {
*show_mount = TRUE;
}
+
+ if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY &&
+ g_find_program_in_path ("gfloppy")) {
+ *show_format = TRUE;
+ }
} else if (nautilus_file_is_nautilus_link (file)) {
uri = nautilus_file_get_activation_uri (file);
if (uri != NULL &&
@@ -6507,32 +6545,38 @@
@@ -6507,32 +6559,38 @@
gboolean show_unmount;
gboolean show_eject;
gboolean show_connect;
@ -133,7 +152,7 @@
}
/* We don't want both eject and unmount, since eject
@@ -6556,6 +6600,10 @@
@@ -6556,6 +6614,10 @@
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_EJECT_VOLUME);
gtk_action_set_visible (action, show_eject);
@ -145,7 +164,7 @@
static void
--- nautilus-2.12.1/src/file-manager/nautilus-directory-view-ui.xml.format 2005-10-03 03:45:27.000000000 -0400
+++ nautilus-2.12.1/src/file-manager/nautilus-directory-view-ui.xml 2005-10-21 10:35:58.000000000 -0400
+++ nautilus-2.12.1/src/file-manager/nautilus-directory-view-ui.xml 2005-10-27 14:35:29.000000000 -0400
@@ -147,6 +147,7 @@
<menuitem name="Mount Volume" action="Mount Volume"/>
<menuitem name="Unmount Volume" action="Unmount Volume"/>

View File

@ -0,0 +1,346 @@
--- nautilus-2.12.1/src/nautilus-window-manage-views.c.stretch 2005-07-11 04:37:43.000000000 -0400
+++ nautilus-2.12.1/src/nautilus-window-manage-views.c 2005-10-27 14:35:29.000000000 -0400
@@ -1532,10 +1532,7 @@
action = gtk_action_group_get_action (window->details->main_action_group,
NAUTILUS_ACTION_ZOOM_NORMAL);
gtk_action_set_visible (action, supports_zooming);
- gtk_action_set_sensitive (action,
- TRUE);
-
- /* FIXME bugzilla.gnome.org 43442: Desensitize "Zoom Normal"? */
+ gtk_action_set_sensitive (action, supports_zooming);
}
static void
--- nautilus-2.12.1/libnautilus-private/nautilus-icon-canvas-item.h.stretch 2005-06-22 12:25:45.000000000 -0400
+++ nautilus-2.12.1/libnautilus-private/nautilus-icon-canvas-item.h 2005-10-27 14:35:29.000000000 -0400
@@ -84,7 +84,8 @@
gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
ArtIRect canvas_rect);
gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
- ArtPoint world_point);
+ ArtPoint world_point,
+ GtkCornerType *corner);
void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
ArtDRect nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item);
ArtDRect nautilus_icon_canvas_item_get_text_rectangle (const NautilusIconCanvasItem *item);
--- nautilus-2.12.1/libnautilus-private/nautilus-icon-container.c.stretch 2005-10-03 04:00:26.000000000 -0400
+++ nautilus-2.12.1/libnautilus-private/nautilus-icon-container.c 2005-10-27 14:45:53.000000000 -0400
@@ -3367,6 +3367,8 @@
NautilusIcon *icon;
ArtPoint world_point;
GtkWidget *toplevel;
+ GtkCornerType corner;
+ GdkCursor *cursor;
details = container->details;
icon = details->stretch_icon;
@@ -3374,11 +3376,27 @@
/* Check if we hit the stretch handles. */
world_point.x = details->drag_x;
world_point.y = details->drag_y;
- if (!nautilus_icon_canvas_item_hit_test_stretch_handles
- (icon->item, world_point)) {
+ if (!nautilus_icon_canvas_item_hit_test_stretch_handles (icon->item, world_point, &corner)) {
return FALSE;
}
+ switch (corner) {
+ case GTK_CORNER_TOP_LEFT:
+ cursor = gdk_cursor_new (GDK_TOP_LEFT_CORNER);
+ break;
+ case GTK_CORNER_BOTTOM_LEFT:
+ cursor = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER);
+ break;
+ case GTK_CORNER_TOP_RIGHT:
+ cursor = gdk_cursor_new (GDK_TOP_RIGHT_CORNER);
+ break;
+ case GTK_CORNER_BOTTOM_RIGHT:
+ cursor = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
+ break;
+ default:
+ cursor = NULL;
+ break;
+ }
/* Set up the dragging. */
details->drag_state = DRAG_STATE_STRETCH;
eel_canvas_w2c (EEL_CANVAS (container),
@@ -3396,8 +3414,10 @@
eel_canvas_item_grab (EEL_CANVAS_ITEM (icon->item),
(GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK),
- NULL,
+ cursor,
GDK_CURRENT_TIME);
+ if (cursor)
+ gdk_cursor_unref (cursor);
/* Ensure the window itself is focused.. */
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
@@ -3458,6 +3478,43 @@
}
}
+static gboolean
+keyboard_stretching (NautilusIconContainer *container,
+ GdkEventKey *event)
+{
+ NautilusIcon *icon;
+ guint size;
+
+ icon = container->details->stretch_icon;
+
+ if (icon == NULL || !icon->is_selected) {
+ return FALSE;
+ }
+
+ icon_get_size (container, icon, &size);
+
+ switch (event->keyval) {
+ case GDK_equal:
+ case GDK_plus:
+ case GDK_KP_Add:
+ icon_set_size (container, icon, size + 5, FALSE, FALSE);
+ break;
+ case GDK_minus:
+ case GDK_KP_Subtract:
+ icon_set_size (container, icon, size - 5, FALSE, FALSE);
+ break;
+ case GDK_0:
+ case GDK_KP_0:
+ nautilus_icon_container_move_icon (container, icon,
+ icon->x, icon->y,
+ 1.0, 1.0,
+ FALSE, TRUE, TRUE);
+ break;
+ }
+
+ return TRUE;
+}
+
static void
ungrab_stretch_icon (NautilusIconContainer *container)
{
@@ -3489,7 +3546,7 @@
redo_layout (container);
}
-static void
+static gboolean
undo_stretching (NautilusIconContainer *container)
{
NautilusIcon *stretched_icon;
@@ -3497,7 +3554,7 @@
stretched_icon = container->details->stretch_icon;
if (stretched_icon == NULL) {
- return;
+ return FALSE;
}
if (container->details->drag_state == DRAG_STATE_STRETCH) {
@@ -3519,6 +3576,8 @@
container->details->stretch_icon = NULL;
emit_stretch_ended (container, stretched_icon);
redo_layout (container);
+
+ return TRUE;
}
static gboolean
@@ -3857,9 +3916,19 @@
handled = TRUE;
break;
- case GDK_Escape:
- undo_stretching (container);
- handled = TRUE;
+ case GDK_Escape:
+ handled = undo_stretching (container);
+ break;
+ case GDK_plus:
+ case GDK_minus:
+ case GDK_equal:
+ case GDK_KP_Add:
+ case GDK_KP_Subtract:
+ case GDK_0:
+ case GDK_KP_0:
+ if (event->state & GDK_CONTROL_MASK) {
+ handled = keyboard_stretching (container, event);
+ }
break;
case GDK_F10:
/* handle Ctrl+F10 because we want to display the
--- nautilus-2.12.1/libnautilus-private/nautilus-icon-canvas-item.c.stretch 2005-09-26 11:30:05.000000000 -0400
+++ nautilus-2.12.1/libnautilus-private/nautilus-icon-canvas-item.c 2005-10-27 14:35:29.000000000 -0400
@@ -44,6 +44,7 @@
#include <eel/eel-accessibility.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtksignal.h>
+#include <gdk/gdk.h>
#include <libart_lgpl/art_rgb.h>
#include <libart_lgpl/art_rgb_affine.h>
#include <libart_lgpl/art_rgb_rgba_affine.h>
@@ -209,7 +210,8 @@
GdkGC *gc);
static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item,
- ArtIRect canvas_rect);
+ ArtIRect canvas_rect,
+ GtkCornerType *corner);
static void clear_rounded_corners (GdkPixbuf *destination_pixbuf,
GdkPixbuf *corner_pixbuf,
int corner_size);
@@ -1152,12 +1154,30 @@
draw_or_measure_label_text (item, drawable, create_mask, icon_rect);
}
+static GdkPixbuf *
+get_knob_pixbuf (void)
+{
+ GdkPixbuf *knob_pixbuf;
+ char *knob_filename;
+
+ knob_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ "stock-nautilus-knob",
+ 8, 0, NULL);
+ if (!knob_pixbuf) {
+ knob_filename = nautilus_pixmap_file ("knob.png");
+ knob_pixbuf = gdk_pixbuf_new_from_file (knob_filename, NULL);
+ g_free (knob_filename);
+ }
+
+ return knob_pixbuf;
+}
+
static void
draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
const ArtIRect *rect)
{
+ GtkWidget *widget;
GdkGC *gc;
- char *knob_filename;
GdkPixbuf *knob_pixbuf;
GdkBitmap *stipple;
int knob_width, knob_height;
@@ -1166,17 +1186,27 @@
return;
}
+ widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
+
gc = gdk_gc_new (drawable);
- knob_filename = nautilus_pixmap_file ("knob.png");
- knob_pixbuf = gdk_pixbuf_new_from_file (knob_filename, NULL);
+ knob_pixbuf = get_knob_pixbuf ();
knob_width = gdk_pixbuf_get_width (knob_pixbuf);
knob_height = gdk_pixbuf_get_height (knob_pixbuf);
stipple = eel_stipple_bitmap_for_screen (
gdk_drawable_get_screen (GDK_DRAWABLE (drawable)));
- /* first draw the box */
+ /* first draw the box */
+ gdk_gc_set_rgb_fg_color (gc, &widget->style->white);
+ gdk_draw_rectangle
+ (drawable, gc, FALSE,
+ rect->x0,
+ rect->y0,
+ rect->x1 - rect->x0 - 1,
+ rect->y1 - rect->y0 - 1);
+
+ gdk_gc_set_rgb_fg_color (gc, &widget->style->black);
gdk_gc_set_stipple (gc, stipple);
gdk_gc_set_fill (gc, GDK_STIPPLED);
gdk_draw_rectangle
@@ -1192,8 +1222,6 @@
draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height);
draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0);
draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height);
-
- g_free (knob_filename);
g_object_unref (knob_pixbuf);
g_object_unref (gc);
@@ -1828,7 +1856,7 @@
}
/* Check for hits in the stretch handles. */
- if (hit_test_stretch_handle (icon_item, canvas_rect)) {
+ if (hit_test_stretch_handle (icon_item, canvas_rect, NULL)) {
return TRUE;
}
@@ -2055,12 +2083,13 @@
/* Check if one of the stretch handles was hit. */
static gboolean
hit_test_stretch_handle (NautilusIconCanvasItem *item,
- ArtIRect probe_canvas_rect)
+ ArtIRect probe_canvas_rect,
+ GtkCornerType *corner)
{
ArtIRect icon_rect;
- char *knob_filename;
GdkPixbuf *knob_pixbuf;
int knob_width, knob_height;
+ int hit_corner;
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE);
@@ -2075,24 +2104,36 @@
return FALSE;
}
- knob_filename = nautilus_pixmap_file ("knob.png");
- knob_pixbuf = gdk_pixbuf_new_from_file (knob_filename, NULL);
+
+ knob_pixbuf = get_knob_pixbuf ();
knob_width = gdk_pixbuf_get_width (knob_pixbuf);
knob_height = gdk_pixbuf_get_height (knob_pixbuf);
+ g_object_unref (knob_pixbuf);
- g_free (knob_filename);
- g_object_unref (knob_pixbuf);
-
/* Check for hits in the stretch handles. */
- return (probe_canvas_rect.x0 < icon_rect.x0 + knob_width
- || probe_canvas_rect.x1 >= icon_rect.x1 - knob_width)
- && (probe_canvas_rect.y0 < icon_rect.y0 + knob_height
- || probe_canvas_rect.y1 >= icon_rect.y1 - knob_height);
+ hit_corner = -1;
+ if (probe_canvas_rect.x0 < icon_rect.x0 + knob_width) {
+ if (probe_canvas_rect.y0 < icon_rect.y0 + knob_height)
+ hit_corner = GTK_CORNER_TOP_LEFT;
+ else if (probe_canvas_rect.y1 >= icon_rect.y1 - knob_height)
+ hit_corner = GTK_CORNER_BOTTOM_LEFT;
+ }
+ else if (probe_canvas_rect.x1 >= icon_rect.x1 - knob_width) {
+ if (probe_canvas_rect.y0 < icon_rect.y0 + knob_height)
+ hit_corner = GTK_CORNER_TOP_RIGHT;
+ else if (probe_canvas_rect.y1 >= icon_rect.y1 - knob_height)
+ hit_corner = GTK_CORNER_BOTTOM_RIGHT;
+ }
+ if (corner)
+ *corner = hit_corner;
+
+ return hit_corner != -1;
}
gboolean
nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
- ArtPoint world_point)
+ ArtPoint world_point,
+ GtkCornerType *corner)
{
ArtIRect canvas_rect;
@@ -2105,7 +2146,7 @@
&canvas_rect.y0);
canvas_rect.x1 = canvas_rect.x0 + 1;
canvas_rect.y1 = canvas_rect.y0 + 1;
- return hit_test_stretch_handle (item, canvas_rect);
+ return hit_test_stretch_handle (item, canvas_rect, corner);
}
/* nautilus_icon_canvas_item_hit_test_rectangle

View File

@ -18,7 +18,7 @@
Name: nautilus
Summary: Nautilus is a file manager for GNOME.
Version: 2.12.1
Release: 3
Release: 5
License: GPL
Group: User Interface/Desktops
Source: ftp://ftp.gnome.org/pub/GNOME/sources/2.7/%{name}/%{name}-%{version}.tar.bz2
@ -78,8 +78,10 @@ Obsoletes: nautilus-media
# Some changes to default config
Patch1: nautilus-2.5.7-rhconfig.patch
# Upstream in 2.13
# Partially upstream in 2.13
Patch2: nautilus-2.12.1-format.patch
# Upstream in 2.13
Patch3: nautilus-2.12.1-stretch.patch
%description
Nautilus integrates access to files, applications, media,
@ -93,6 +95,7 @@ GNOME desktop project.
%patch1 -p1 -b .rhconfig
%patch2 -p1 -b .format
%patch3 -p1 -b .stretch
%build
@ -169,6 +172,13 @@ scrollkeeper-update
%{_includedir}/nautilus
%changelog
* Sat Oct 28 2005 Matthias Clasen <mclasen@redhat.com> 2.12.1-5
- Implement icon stretching keynav
- Support formatting non-floppy devices
* Sat Oct 22 2005 Matthias Clasen <mclasen@redhat.com> 2.12.1-4
- Improve icon stretching ui
* Fri Oct 21 2005 Matthias Clasen <mclasen@redhat.com> 2.12.1-3
- Only show the "Format menu item if gfloppy is present