Commit c9692eff authored by Andy Hertzfeld's avatar Andy Hertzfeld

hooked up zooming to the background context menu


      hooked up zooming to the background context menu
parent a5d6405d
2000-01-27 Andy Hertzfeld <andy@eazel.com>
hooked zooming up to the background context menu; right now the canvas item
doesn't work at different zoom levels properly, which we'll fix soon.
* libnautilus/fm-directory-view.c,h:
enable zoom in and zoom out items and hooked them up to callback
added a bump_zoom_level slot, to be overriden by subclasses, which the zoom callback use
* libnautilus/fm-directory-view-icons.c:
added method for bump_zoom_index that calls the icon container to do the work
* libnautilus/gnome-icon-container-private.h:
added a private instance variable for zoom level
* libnautilus/gnome-icon-container.c,.h:
added methods for get_zoom_level and set_zoom_level
2000-01-27 Darin Adler <darin@eazel.com> 2000-01-27 Darin Adler <darin@eazel.com>
* libnautilus/gnome-icon-container.c: * libnautilus/gnome-icon-container.c:
......
...@@ -161,10 +161,26 @@ struct _GnomeIconContainerDetails { ...@@ -161,10 +161,26 @@ struct _GnomeIconContainerDetails {
/* DnD info. */ /* DnD info. */
GnomeIconContainerDndInfo *dnd_info; GnomeIconContainerDndInfo *dnd_info;
/* zoom level */
gint zoom_level;
/* default font used to draw labels */ /* default font used to draw labels */
GdkFont *label_font; GdkFont *label_font;
}; };
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME: These are also defined in fm-icon-cache.h and shouldn't be in both places */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
NAUTILUS_ZOOM_LEVEL_SMALLER,
NAUTILUS_ZOOM_LEVEL_SMALL,
NAUTILUS_ZOOM_LEVEL_STANDARD,
NAUTILUS_ZOOM_LEVEL_LARGE,
NAUTILUS_ZOOM_LEVEL_LARGER,
NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;
/* Layout and icon size constants. /* Layout and icon size constants.
These will change based on the zoom level eventually, so they These will change based on the zoom level eventually, so they
should probably become function calls instead of macros. should probably become function calls instead of macros.
......
...@@ -134,6 +134,7 @@ icon_new_pixbuf (GnomeIconContainer *container, ...@@ -134,6 +134,7 @@ icon_new_pixbuf (GnomeIconContainer *container,
image = nautilus_icons_controller_get_icon_image (details->controller, data); image = nautilus_icons_controller_get_icon_image (details->controller, data);
name = nautilus_icons_controller_get_icon_name (details->controller, data); name = nautilus_icons_controller_get_icon_name (details->controller, data);
new->item = gnome_canvas_item_new new->item = gnome_canvas_item_new
(GNOME_CANVAS_GROUP (canvas->root), (GNOME_CANVAS_GROUP (canvas->root),
nautilus_icons_view_icon_item_get_type (), nautilus_icons_view_icon_item_get_type (),
...@@ -142,6 +143,7 @@ icon_new_pixbuf (GnomeIconContainer *container, ...@@ -142,6 +143,7 @@ icon_new_pixbuf (GnomeIconContainer *container,
"x", (gdouble) 0, "x", (gdouble) 0,
"y", (gdouble) 0, "y", (gdouble) 0,
NULL); NULL);
g_free (name); g_free (name);
return new; return new;
...@@ -1642,7 +1644,8 @@ destroy (GtkObject *object) ...@@ -1642,7 +1644,8 @@ destroy (GtkObject *object)
icon_grid_destroy (container->details->grid); icon_grid_destroy (container->details->grid);
g_hash_table_destroy (container->details->canvas_item_to_icon); g_hash_table_destroy (container->details->canvas_item_to_icon);
unschedule_kbd_icon_visibility (container); unschedule_kbd_icon_visibility (container);
if (container->details->idle_id != 0)
if (container->details->idle_id != 0)
gtk_idle_remove (container->details->idle_id); gtk_idle_remove (container->details->idle_id);
if (container->details->linger_selection_mode_timer_tag != -1) if (container->details->linger_selection_mode_timer_tag != -1)
gtk_timeout_remove (container->details->linger_selection_mode_timer_tag); gtk_timeout_remove (container->details->linger_selection_mode_timer_tag);
...@@ -2029,6 +2032,7 @@ gnome_icon_container_initialize (GnomeIconContainer *container) ...@@ -2029,6 +2032,7 @@ gnome_icon_container_initialize (GnomeIconContainer *container)
details->kbd_icon_visibility_timer_tag = -1; details->kbd_icon_visibility_timer_tag = -1;
details->linger_selection_mode_timer_tag = -1; details->linger_selection_mode_timer_tag = -1;
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
/* FIXME: soon we'll need fonts at multiple sizes */ /* FIXME: soon we'll need fonts at multiple sizes */
details->label_font = gdk_font_load("-bitstream-charter-medium-r-normal-*-12-*-*-*-*-*-*-*"); details->label_font = gdk_font_load("-bitstream-charter-medium-r-normal-*-12-*-*-*-*-*-*-*");
...@@ -2336,6 +2340,32 @@ gnome_icon_container_add_auto (GnomeIconContainer *container, ...@@ -2336,6 +2340,32 @@ gnome_icon_container_add_auto (GnomeIconContainer *container,
add_idle (container); add_idle (container);
} }
/* zooming */
gint
gnome_icon_container_get_zoom_level(GnomeIconContainer *container)
{
return container->details->zoom_level;
}
void
gnome_icon_container_set_zoom_level(GnomeIconContainer *container, gint new_level)
{
gint pinned_level = new_level;
double zoom_levels[7] = { 0.25, 0.50, 0.75, 1.0, 1.5, 2.0, 4.0 };
if (pinned_level < NAUTILUS_ZOOM_LEVEL_SMALLEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
if (pinned_level != container->details->zoom_level)
{
container->details->zoom_level = pinned_level;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), zoom_levels[pinned_level]);
}
}
/** /**
* gnome_icon_container_relayout: * gnome_icon_container_relayout:
......
...@@ -85,6 +85,9 @@ void gnome_icon_container_line_up (GnomeIconContainer ...@@ -85,6 +85,9 @@ void gnome_icon_container_line_up (GnomeIconContainer
GList * gnome_icon_container_get_selection (GnomeIconContainer *view); GList * gnome_icon_container_get_selection (GnomeIconContainer *view);
gint gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view, gint new_zoom_level);
void gnome_icon_container_unselect_all (GnomeIconContainer *view); void gnome_icon_container_unselect_all (GnomeIconContainer *view);
void gnome_icon_container_select_all (GnomeIconContainer *view); void gnome_icon_container_select_all (GnomeIconContainer *view);
......
...@@ -161,10 +161,26 @@ struct _GnomeIconContainerDetails { ...@@ -161,10 +161,26 @@ struct _GnomeIconContainerDetails {
/* DnD info. */ /* DnD info. */
GnomeIconContainerDndInfo *dnd_info; GnomeIconContainerDndInfo *dnd_info;
/* zoom level */
gint zoom_level;
/* default font used to draw labels */ /* default font used to draw labels */
GdkFont *label_font; GdkFont *label_font;
}; };
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME: These are also defined in fm-icon-cache.h and shouldn't be in both places */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
NAUTILUS_ZOOM_LEVEL_SMALLER,
NAUTILUS_ZOOM_LEVEL_SMALL,
NAUTILUS_ZOOM_LEVEL_STANDARD,
NAUTILUS_ZOOM_LEVEL_LARGE,
NAUTILUS_ZOOM_LEVEL_LARGER,
NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;
/* Layout and icon size constants. /* Layout and icon size constants.
These will change based on the zoom level eventually, so they These will change based on the zoom level eventually, so they
should probably become function calls instead of macros. should probably become function calls instead of macros.
......
...@@ -134,6 +134,7 @@ icon_new_pixbuf (GnomeIconContainer *container, ...@@ -134,6 +134,7 @@ icon_new_pixbuf (GnomeIconContainer *container,
image = nautilus_icons_controller_get_icon_image (details->controller, data); image = nautilus_icons_controller_get_icon_image (details->controller, data);
name = nautilus_icons_controller_get_icon_name (details->controller, data); name = nautilus_icons_controller_get_icon_name (details->controller, data);
new->item = gnome_canvas_item_new new->item = gnome_canvas_item_new
(GNOME_CANVAS_GROUP (canvas->root), (GNOME_CANVAS_GROUP (canvas->root),
nautilus_icons_view_icon_item_get_type (), nautilus_icons_view_icon_item_get_type (),
...@@ -142,6 +143,7 @@ icon_new_pixbuf (GnomeIconContainer *container, ...@@ -142,6 +143,7 @@ icon_new_pixbuf (GnomeIconContainer *container,
"x", (gdouble) 0, "x", (gdouble) 0,
"y", (gdouble) 0, "y", (gdouble) 0,
NULL); NULL);
g_free (name); g_free (name);
return new; return new;
...@@ -1642,7 +1644,8 @@ destroy (GtkObject *object) ...@@ -1642,7 +1644,8 @@ destroy (GtkObject *object)
icon_grid_destroy (container->details->grid); icon_grid_destroy (container->details->grid);
g_hash_table_destroy (container->details->canvas_item_to_icon); g_hash_table_destroy (container->details->canvas_item_to_icon);
unschedule_kbd_icon_visibility (container); unschedule_kbd_icon_visibility (container);
if (container->details->idle_id != 0)
if (container->details->idle_id != 0)
gtk_idle_remove (container->details->idle_id); gtk_idle_remove (container->details->idle_id);
if (container->details->linger_selection_mode_timer_tag != -1) if (container->details->linger_selection_mode_timer_tag != -1)
gtk_timeout_remove (container->details->linger_selection_mode_timer_tag); gtk_timeout_remove (container->details->linger_selection_mode_timer_tag);
...@@ -2029,6 +2032,7 @@ gnome_icon_container_initialize (GnomeIconContainer *container) ...@@ -2029,6 +2032,7 @@ gnome_icon_container_initialize (GnomeIconContainer *container)
details->kbd_icon_visibility_timer_tag = -1; details->kbd_icon_visibility_timer_tag = -1;
details->linger_selection_mode_timer_tag = -1; details->linger_selection_mode_timer_tag = -1;
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
/* FIXME: soon we'll need fonts at multiple sizes */ /* FIXME: soon we'll need fonts at multiple sizes */
details->label_font = gdk_font_load("-bitstream-charter-medium-r-normal-*-12-*-*-*-*-*-*-*"); details->label_font = gdk_font_load("-bitstream-charter-medium-r-normal-*-12-*-*-*-*-*-*-*");
...@@ -2336,6 +2340,32 @@ gnome_icon_container_add_auto (GnomeIconContainer *container, ...@@ -2336,6 +2340,32 @@ gnome_icon_container_add_auto (GnomeIconContainer *container,
add_idle (container); add_idle (container);
} }
/* zooming */
gint
gnome_icon_container_get_zoom_level(GnomeIconContainer *container)
{
return container->details->zoom_level;
}
void
gnome_icon_container_set_zoom_level(GnomeIconContainer *container, gint new_level)
{
gint pinned_level = new_level;
double zoom_levels[7] = { 0.25, 0.50, 0.75, 1.0, 1.5, 2.0, 4.0 };
if (pinned_level < NAUTILUS_ZOOM_LEVEL_SMALLEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
if (pinned_level != container->details->zoom_level)
{
container->details->zoom_level = pinned_level;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), zoom_levels[pinned_level]);
}
}
/** /**
* gnome_icon_container_relayout: * gnome_icon_container_relayout:
......
...@@ -85,6 +85,9 @@ void gnome_icon_container_line_up (GnomeIconContainer ...@@ -85,6 +85,9 @@ void gnome_icon_container_line_up (GnomeIconContainer
GList * gnome_icon_container_get_selection (GnomeIconContainer *view); GList * gnome_icon_container_get_selection (GnomeIconContainer *view);
gint gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view, gint new_zoom_level);
void gnome_icon_container_unselect_all (GnomeIconContainer *view); void gnome_icon_container_unselect_all (GnomeIconContainer *view);
void gnome_icon_container_select_all (GnomeIconContainer *view); void gnome_icon_container_select_all (GnomeIconContainer *view);
......
...@@ -161,10 +161,26 @@ struct _GnomeIconContainerDetails { ...@@ -161,10 +161,26 @@ struct _GnomeIconContainerDetails {
/* DnD info. */ /* DnD info. */
GnomeIconContainerDndInfo *dnd_info; GnomeIconContainerDndInfo *dnd_info;
/* zoom level */
gint zoom_level;
/* default font used to draw labels */ /* default font used to draw labels */
GdkFont *label_font; GdkFont *label_font;
}; };
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME: These are also defined in fm-icon-cache.h and shouldn't be in both places */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
NAUTILUS_ZOOM_LEVEL_SMALLER,
NAUTILUS_ZOOM_LEVEL_SMALL,
NAUTILUS_ZOOM_LEVEL_STANDARD,
NAUTILUS_ZOOM_LEVEL_LARGE,
NAUTILUS_ZOOM_LEVEL_LARGER,
NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;
/* Layout and icon size constants. /* Layout and icon size constants.
These will change based on the zoom level eventually, so they These will change based on the zoom level eventually, so they
should probably become function calls instead of macros. should probably become function calls instead of macros.
......
...@@ -134,6 +134,7 @@ icon_new_pixbuf (GnomeIconContainer *container, ...@@ -134,6 +134,7 @@ icon_new_pixbuf (GnomeIconContainer *container,
image = nautilus_icons_controller_get_icon_image (details->controller, data); image = nautilus_icons_controller_get_icon_image (details->controller, data);
name = nautilus_icons_controller_get_icon_name (details->controller, data); name = nautilus_icons_controller_get_icon_name (details->controller, data);
new->item = gnome_canvas_item_new new->item = gnome_canvas_item_new
(GNOME_CANVAS_GROUP (canvas->root), (GNOME_CANVAS_GROUP (canvas->root),
nautilus_icons_view_icon_item_get_type (), nautilus_icons_view_icon_item_get_type (),
...@@ -142,6 +143,7 @@ icon_new_pixbuf (GnomeIconContainer *container, ...@@ -142,6 +143,7 @@ icon_new_pixbuf (GnomeIconContainer *container,
"x", (gdouble) 0, "x", (gdouble) 0,
"y", (gdouble) 0, "y", (gdouble) 0,
NULL); NULL);
g_free (name); g_free (name);
return new; return new;
...@@ -1642,7 +1644,8 @@ destroy (GtkObject *object) ...@@ -1642,7 +1644,8 @@ destroy (GtkObject *object)
icon_grid_destroy (container->details->grid); icon_grid_destroy (container->details->grid);
g_hash_table_destroy (container->details->canvas_item_to_icon); g_hash_table_destroy (container->details->canvas_item_to_icon);
unschedule_kbd_icon_visibility (container); unschedule_kbd_icon_visibility (container);
if (container->details->idle_id != 0)
if (container->details->idle_id != 0)
gtk_idle_remove (container->details->idle_id); gtk_idle_remove (container->details->idle_id);
if (container->details->linger_selection_mode_timer_tag != -1) if (container->details->linger_selection_mode_timer_tag != -1)
gtk_timeout_remove (container->details->linger_selection_mode_timer_tag); gtk_timeout_remove (container->details->linger_selection_mode_timer_tag);
...@@ -2029,6 +2032,7 @@ gnome_icon_container_initialize (GnomeIconContainer *container) ...@@ -2029,6 +2032,7 @@ gnome_icon_container_initialize (GnomeIconContainer *container)
details->kbd_icon_visibility_timer_tag = -1; details->kbd_icon_visibility_timer_tag = -1;
details->linger_selection_mode_timer_tag = -1; details->linger_selection_mode_timer_tag = -1;
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
/* FIXME: soon we'll need fonts at multiple sizes */ /* FIXME: soon we'll need fonts at multiple sizes */
details->label_font = gdk_font_load("-bitstream-charter-medium-r-normal-*-12-*-*-*-*-*-*-*"); details->label_font = gdk_font_load("-bitstream-charter-medium-r-normal-*-12-*-*-*-*-*-*-*");
...@@ -2336,6 +2340,32 @@ gnome_icon_container_add_auto (GnomeIconContainer *container, ...@@ -2336,6 +2340,32 @@ gnome_icon_container_add_auto (GnomeIconContainer *container,
add_idle (container); add_idle (container);
} }
/* zooming */
gint
gnome_icon_container_get_zoom_level(GnomeIconContainer *container)
{
return container->details->zoom_level;
}
void
gnome_icon_container_set_zoom_level(GnomeIconContainer *container, gint new_level)
{
gint pinned_level = new_level;
double zoom_levels[7] = { 0.25, 0.50, 0.75, 1.0, 1.5, 2.0, 4.0 };
if (pinned_level < NAUTILUS_ZOOM_LEVEL_SMALLEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
if (pinned_level != container->details->zoom_level)
{
container->details->zoom_level = pinned_level;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), zoom_levels[pinned_level]);
}
}
/** /**
* gnome_icon_container_relayout: * gnome_icon_container_relayout:
......
...@@ -85,6 +85,9 @@ void gnome_icon_container_line_up (GnomeIconContainer ...@@ -85,6 +85,9 @@ void gnome_icon_container_line_up (GnomeIconContainer
GList * gnome_icon_container_get_selection (GnomeIconContainer *view); GList * gnome_icon_container_get_selection (GnomeIconContainer *view);
gint gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view, gint new_zoom_level);
void gnome_icon_container_unselect_all (GnomeIconContainer *view); void gnome_icon_container_unselect_all (GnomeIconContainer *view);
void gnome_icon_container_select_all (GnomeIconContainer *view); void gnome_icon_container_select_all (GnomeIconContainer *view);
......
...@@ -61,6 +61,8 @@ static void fm_directory_view_icons_background_changed_cb (NautilusBackground *b ...@@ -61,6 +61,8 @@ static void fm_directory_view_icons_background_changed_cb (NautilusBackground *b
FMDirectoryViewIcons *icon_view); FMDirectoryViewIcons *icon_view);
static void fm_directory_view_icons_begin_loading static void fm_directory_view_icons_begin_loading
(FMDirectoryView *view); (FMDirectoryView *view);
static void fm_directory_view_icons_bump_zoom_level
(FMDirectoryView *view, gint zoom_increment);
static void fm_directory_view_icons_clear (FMDirectoryView *view); static void fm_directory_view_icons_clear (FMDirectoryView *view);
static void fm_directory_view_icons_destroy (GtkObject *view); static void fm_directory_view_icons_destroy (GtkObject *view);
static void fm_directory_view_icons_done_adding_entries static void fm_directory_view_icons_done_adding_entries
...@@ -114,14 +116,17 @@ fm_directory_view_icons_initialize_class (FMDirectoryViewIconsClass *klass) ...@@ -114,14 +116,17 @@ fm_directory_view_icons_initialize_class (FMDirectoryViewIconsClass *klass)
= fm_directory_view_icons_begin_loading; = fm_directory_view_icons_begin_loading;
fm_directory_view_class->get_selection fm_directory_view_class->get_selection
= fm_directory_view_icons_get_selection; = fm_directory_view_icons_get_selection;
fm_directory_view_class->bump_zoom_level
= fm_directory_view_icons_bump_zoom_level;
} }
static void static void
fm_directory_view_icons_initialize (FMDirectoryViewIcons *icon_view) fm_directory_view_icons_initialize (FMDirectoryViewIcons *icon_view)
{ {
GnomeIconContainer *icon_container; GnomeIconContainer *icon_container;
g_return_if_fail (GTK_BIN (icon_view)->child == NULL); g_return_if_fail (GTK_BIN (icon_view)->child == NULL);
icon_view->details = g_new0 (FMDirectoryViewIconsDetails, 1); icon_view->details = g_new0 (FMDirectoryViewIconsDetails, 1);
...@@ -290,6 +295,15 @@ fm_directory_view_icons_begin_loading (FMDirectoryView *view) ...@@ -290,6 +295,15 @@ fm_directory_view_icons_begin_loading (FMDirectoryView *view)
{ {
} }
static void
fm_directory_view_icons_bump_zoom_level (FMDirectoryView *view, gint zoom_increment)
{
GnomeIconContainer *icon_container = get_icon_container(FM_DIRECTORY_VIEW_ICONS (view));
gint current_zoom_level = gnome_icon_container_get_zoom_level(icon_container);
gnome_icon_container_set_zoom_level(icon_container, current_zoom_level + zoom_increment);
}
static GList * static GList *
fm_directory_view_icons_get_selection (FMDirectoryView *view) fm_directory_view_icons_get_selection (FMDirectoryView *view)
{ {
......
...@@ -93,11 +93,14 @@ static void notify_location_change_cb (NautilusViewFrame *view_frame, ...@@ -93,11 +93,14 @@ static void notify_location_change_cb (NautilusViewFrame *view_frame,
Nautilus_NavigationInfo *nav_context, Nautilus_NavigationInfo *nav_context,
FMDirectoryView *directory_view); FMDirectoryView *directory_view);
static void fm_directory_view_repopulate (FMDirectoryView *view); static void fm_directory_view_repopulate (FMDirectoryView *view);
static void zoom_in_cb (GtkMenuItem *item, FMDirectoryView *directory_view);
static void zoom_out_cb (GtkMenuItem *item, FMDirectoryView *directory_view);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW) NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_entry) NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_entry)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear) NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection) NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, bump_zoom_level)
static void static void
fm_directory_view_initialize_class (FMDirectoryViewClass *klass) fm_directory_view_initialize_class (FMDirectoryViewClass *klass)
...@@ -147,6 +150,7 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass) ...@@ -147,6 +150,7 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass)
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, add_entry); NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, add_entry);
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, clear); NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, clear);
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_selection); NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_selection);
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, bump_zoom_level);
} }
static void static void
...@@ -358,6 +362,19 @@ stop_load (FMDirectoryView *view, gboolean error) ...@@ -358,6 +362,19 @@ stop_load (FMDirectoryView *view, gboolean error)
/* handle the zoom in/out menu items */
static void
zoom_in_cb(GtkMenuItem *item, FMDirectoryView *directory_view)
{
fm_directory_view_bump_zoom_level (directory_view, 1);
}
static void
zoom_out_cb(GtkMenuItem *item, FMDirectoryView *directory_view)
{
fm_directory_view_bump_zoom_level (directory_view, -1);
}
/** /**
* fm_directory_view_repopulate: * fm_directory_view_repopulate:
...@@ -586,6 +603,20 @@ fm_directory_view_begin_loading (FMDirectoryView *view) ...@@ -586,6 +603,20 @@ fm_directory_view_begin_loading (FMDirectoryView *view)
gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[BEGIN_LOADING]); gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[BEGIN_LOADING]);
} }
/**
* fm_directory_view_bump_zoom_level:
*
* bump the current zoom level by invoking the relevant subclass through the slot
*
**/
void
fm_directory_view_bump_zoom_level (FMDirectoryView *view, gint zoom_increment)
{
g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
(* FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (view)->klass)->bump_zoom_level) (view, zoom_increment);
}
/** /**
* fm_directory_view_get_selection: * fm_directory_view_get_selection:
* *
...@@ -700,13 +731,17 @@ create_background_context_menu (FMDirectoryView *view) ...@@ -700,13 +731,17 @@ create_background_context_menu (FMDirectoryView *view)
gtk_menu_append (menu, menu_item); gtk_menu_append (menu, menu_item);
menu_item = gtk_menu_item_new_with_label ("Zoom in"); menu_item = gtk_menu_item_new_with_label ("Zoom in");
gtk_widget_set_sensitive (menu_item, FALSE); gtk_signal_connect(GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (zoom_in_cb), view);
gtk_widget_show (menu_item); gtk_widget_show (menu_item);
gtk_menu_append (menu, menu_item); gtk_menu_append (menu, menu_item);
menu_item = gtk_menu_item_new_with_label ("Zoom out"); menu_item = gtk_menu_item_new_with_label ("Zoom out");
gtk_widget_set_sensitive (menu_item, FALSE); gtk_signal_connect(GTK_OBJECT (menu_item), "activate",
gtk_widget_show (menu_item); GTK_SIGNAL_FUNC (zoom_out_cb), view);
gtk_widget_show (menu_item);
gtk_menu_append (menu, menu_item); gtk_menu_append (menu, menu_item);
gtk_object_ref(GTK_OBJECT(menu)); gtk_object_ref(GTK_OBJECT(menu));
......
...@@ -99,6 +99,10 @@ struct _FMDirectoryViewClass { ...@@ -99,6 +99,10 @@ struct _FMDirectoryViewClass {
*/ */