Commit 7c97b308 authored by Andy Hertzfeld's avatar Andy Hertzfeld

added zoom control to location bar, not yet wired up to the content view


       added zoom control to location bar, not yet wired up to the content view
parent 39b26449
2000-02-02 Andy Hertzfeld <andy@eazel.com>
added a zoom control to location bar, not yet wired up to the content view
* icons/Makefile.am:
* icons/zoom.png:
added zoom image for use in zoom control
* src/nautilus-zoom-control.h:
* src/nautilus-zoom-control.c:
* src/Makefile.am
new zoom control widget
* src/ntl-window.c:
added zoom control to location bar
2000-02-01 Darin Adler <darin@eazel.com>
* libnautilus/nautilus-icon-factory.h:
......
......@@ -21,6 +21,7 @@ icon_DATA = \
i-zipdisk2.png \
multi-ok.png \
not.png \
nautilus3.jpg
nautilus3.jpg \
zoom.png
EXTRA_DIST = $(icon_DATA)
......@@ -32,6 +32,8 @@ nautilus_SOURCES= \
nautilus-bookmarks-window.h \
nautilus-self-check-functions.c \
nautilus-self-check-functions.h \
nautilus-zoom-control.c \
nautilus-zoom-control.h \
ntl-app.c \
ntl-app.h \
ntl-content-view.c \
......
......@@ -36,6 +36,7 @@
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-gtk-extensions.h>
#include "nautilus-zoom-control.h"
static void nautilus_window_realize (GtkWidget *widget);
static void nautilus_window_real_set_content_view (NautilusWindow *window, NautilusView *new_view);
......@@ -415,7 +416,7 @@ nautilus_window_constructed(NautilusWindow *window)
{
GnomeApp *app;
GtkWidget *location_bar_box, *statusbar;
GtkWidget *temp_frame;
GtkWidget *temp_frame, *zoom_control;
app = GNOME_APP(window);
......@@ -435,16 +436,22 @@ nautilus_window_constructed(NautilusWindow *window)
window->ent_uri = explorer_location_bar_new();
gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed",
nautilus_window_goto_uri_cb, window);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL);
gnome_app_add_docked(app, location_bar_box, "uri-entry",
GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL,
GNOME_DOCK_TOP, 2, 0, 0);
/* Option menu for content view types; it's empty here, filled in when a uri is set. */
window->option_cvtype = gtk_option_menu_new();
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_BIG);
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_SMALL);
gtk_widget_show(window->option_cvtype);
/* allocate the zoom control and place on the right next to the menu */
zoom_control = nautilus_zoom_control_new();
gtk_widget_show(zoom_control);
gtk_box_pack_end(GTK_BOX(location_bar_box), zoom_control, FALSE, FALSE, 0);
gtk_widget_show_all(location_bar_box);
/* set up status bar */
......
......@@ -36,6 +36,7 @@
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-gtk-extensions.h>
#include "nautilus-zoom-control.h"
static void nautilus_window_realize (GtkWidget *widget);
static void nautilus_window_real_set_content_view (NautilusWindow *window, NautilusView *new_view);
......@@ -415,7 +416,7 @@ nautilus_window_constructed(NautilusWindow *window)
{
GnomeApp *app;
GtkWidget *location_bar_box, *statusbar;
GtkWidget *temp_frame;
GtkWidget *temp_frame, *zoom_control;
app = GNOME_APP(window);
......@@ -435,16 +436,22 @@ nautilus_window_constructed(NautilusWindow *window)
window->ent_uri = explorer_location_bar_new();
gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed",
nautilus_window_goto_uri_cb, window);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL);
gnome_app_add_docked(app, location_bar_box, "uri-entry",
GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL,
GNOME_DOCK_TOP, 2, 0, 0);
/* Option menu for content view types; it's empty here, filled in when a uri is set. */
window->option_cvtype = gtk_option_menu_new();
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_BIG);
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_SMALL);
gtk_widget_show(window->option_cvtype);
/* allocate the zoom control and place on the right next to the menu */
zoom_control = nautilus_zoom_control_new();
gtk_widget_show(zoom_control);
gtk_box_pack_end(GTK_BOX(location_bar_box), zoom_control, FALSE, FALSE, 0);
gtk_widget_show_all(location_bar_box);
/* set up status bar */
......
......@@ -36,6 +36,7 @@
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-gtk-extensions.h>
#include "nautilus-zoom-control.h"
static void nautilus_window_realize (GtkWidget *widget);
static void nautilus_window_real_set_content_view (NautilusWindow *window, NautilusView *new_view);
......@@ -415,7 +416,7 @@ nautilus_window_constructed(NautilusWindow *window)
{
GnomeApp *app;
GtkWidget *location_bar_box, *statusbar;
GtkWidget *temp_frame;
GtkWidget *temp_frame, *zoom_control;
app = GNOME_APP(window);
......@@ -435,16 +436,22 @@ nautilus_window_constructed(NautilusWindow *window)
window->ent_uri = explorer_location_bar_new();
gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed",
nautilus_window_goto_uri_cb, window);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL);
gnome_app_add_docked(app, location_bar_box, "uri-entry",
GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL,
GNOME_DOCK_TOP, 2, 0, 0);
/* Option menu for content view types; it's empty here, filled in when a uri is set. */
window->option_cvtype = gtk_option_menu_new();
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_BIG);
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_SMALL);
gtk_widget_show(window->option_cvtype);
/* allocate the zoom control and place on the right next to the menu */
zoom_control = nautilus_zoom_control_new();
gtk_widget_show(zoom_control);
gtk_box_pack_end(GTK_BOX(location_bar_box), zoom_control, FALSE, FALSE, 0);
gtk_widget_show_all(location_bar_box);
/* set up status bar */
......
......@@ -36,6 +36,7 @@
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-gtk-extensions.h>
#include "nautilus-zoom-control.h"
static void nautilus_window_realize (GtkWidget *widget);
static void nautilus_window_real_set_content_view (NautilusWindow *window, NautilusView *new_view);
......@@ -415,7 +416,7 @@ nautilus_window_constructed(NautilusWindow *window)
{
GnomeApp *app;
GtkWidget *location_bar_box, *statusbar;
GtkWidget *temp_frame;
GtkWidget *temp_frame, *zoom_control;
app = GNOME_APP(window);
......@@ -435,16 +436,22 @@ nautilus_window_constructed(NautilusWindow *window)
window->ent_uri = explorer_location_bar_new();
gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed",
nautilus_window_goto_uri_cb, window);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL);
gnome_app_add_docked(app, location_bar_box, "uri-entry",
GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL,
GNOME_DOCK_TOP, 2, 0, 0);
/* Option menu for content view types; it's empty here, filled in when a uri is set. */
window->option_cvtype = gtk_option_menu_new();
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_BIG);
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_SMALL);
gtk_widget_show(window->option_cvtype);
/* allocate the zoom control and place on the right next to the menu */
zoom_control = nautilus_zoom_control_new();
gtk_widget_show(zoom_control);
gtk_box_pack_end(GTK_BOX(location_bar_box), zoom_control, FALSE, FALSE, 0);
gtk_widget_show_all(location_bar_box);
/* set up status bar */
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* Nautilus
* Copyright (C) 2000 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Andy Hertzfeld <andy@eazel.com>
*
* This is the zoom control for the location bar
*
*/
#include <gdk/gdk.h>
#include <gtk/gtkeventbox.h>
#include <gtk/gtkwidget.h>
#include <stdio.h>
#include <gnome.h>
#include <math.h>
#include <libnautilus/nautilus-gtk-macros.h>
#include <libnautilus/nautilus-icon-factory.h>
#include "nautilus-zoom-control.h"
static void nautilus_zoom_control_class_initialize (NautilusZoomControlClass *klass);
static void nautilus_zoom_control_initialize (NautilusZoomControl *pixmap);
static void nautilus_zoom_control_draw (GtkWidget *widget, GdkRectangle *box);
static gboolean nautilus_zoom_control_button_press_event (GtkWidget *widget, GdkEventButton *event);
static GtkEventBoxClass *parent_class;
GtkType
nautilus_zoom_control_get_type (void)
{
static GtkType zoom_control_type = 0;
if (!zoom_control_type)
{
static const GtkTypeInfo zoom_control_info =
{
"NautilusZoomControl",
sizeof (NautilusZoomControl),
sizeof (NautilusZoomControlClass),
(GtkClassInitFunc) nautilus_zoom_control_class_initialize,
(GtkObjectInitFunc) nautilus_zoom_control_initialize,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
zoom_control_type = gtk_type_unique (gtk_event_box_get_type(), &zoom_control_info);
}
return zoom_control_type;
}
static void
nautilus_zoom_control_class_initialize (NautilusZoomControlClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (gtk_event_box_get_type ());
widget_class->draw = nautilus_zoom_control_draw;
widget_class->button_press_event = nautilus_zoom_control_button_press_event;
}
static void
nautilus_zoom_control_initialize (NautilusZoomControl *zoom_control)
{
gchar *file_name;
GtkWidget *pix_widget;
zoom_control->current_zoom = NAUTILUS_ZOOM_LEVEL_STANDARD;
zoom_control->min_zoom = NAUTILUS_ZOOM_LEVEL_SMALLEST;
zoom_control->max_zoom = NAUTILUS_ZOOM_LEVEL_LARGEST;
zoom_control->zoom_factor = 1.0;
/* allocate the pixmap that holds the image */
file_name = gnome_pixmap_file ("nautilus/zoom.png");
pix_widget = GTK_WIDGET (gnome_pixmap_new_from_file (file_name));
gtk_widget_show (pix_widget);
gtk_container_add (GTK_CONTAINER(zoom_control), pix_widget);
g_free (file_name);
}
GtkWidget*
nautilus_zoom_control_new ()
{
NautilusZoomControl *zoom_control = gtk_type_new (nautilus_zoom_control_get_type ());
return GTK_WIDGET (zoom_control);
}
static void
nautilus_zoom_control_draw (GtkWidget *widget, GdkRectangle *box)
{
NautilusZoomControl *zoom_control;
gchar buffer[8];
GdkFont *label_font;
GdkGC* temp_gc;
gint x, y, percent;
g_return_if_fail (widget != NULL);
g_return_if_fail (NAUTILUS_IS_ZOOM_CONTROL (widget));
zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
/* invoke our superclass to draw the image */
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, draw, (widget, box));
/* draw the current zoom level percentage */
label_font = gdk_font_load("-bitstream-courier-medium-r-normal-*-9-*-*-*-*-*-*-*");
temp_gc = gdk_gc_new(widget->window);
percent = floor((100.0 * zoom_control->zoom_factor) + .5);
g_snprintf(buffer, 8, "%d", percent);
x = (box->width - gdk_string_width(label_font, buffer)) >> 1;
y = (box->height >> 1) + 3;
gdk_draw_string (widget->window, label_font, temp_gc, x, y, &buffer[0]);
gdk_font_unref(label_font);
gdk_gc_unref(temp_gc);
}
/* hit-test the index tabs and activate if necessary */
static gboolean
nautilus_zoom_control_button_press_event (GtkWidget *widget, GdkEventButton *event)
{
NautilusZoomControl *zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
gint width = widget->allocation.width;
gint changed = FALSE;
if (event->x < (width / 3) && (zoom_control->current_zoom > zoom_control->min_zoom))
{
zoom_control->current_zoom -= 1;
changed = TRUE;
}
else if ((event->x > ((2 * width) / 3)) && (zoom_control->current_zoom < zoom_control->max_zoom))
{
zoom_control->current_zoom += 1;
changed = TRUE;
}
if (changed)
{
gtk_widget_queue_draw(widget);
zoom_control->zoom_factor = (double) nautilus_icon_size_for_zoom_level (zoom_control->current_zoom)
/ NAUTILUS_ICON_SIZE_STANDARD;
/* FIXME: tell the content view about the zoom change here soon */
}
return TRUE;
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* Nautilus
* Copyright (C) 2000 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Andy Hertzfeld <andy@eazel.com>
*
* This is the header file for the zoom control on the location bar
*
*/
#ifndef __NAUTILUS_ZOOM_CONTROL_H__
#define __NAUTILUS_ZOOM_CONTROL_H__
#include <gdk/gdk.h>
#include <gtk/gtkpixmap.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define NAUTILUS_TYPE_ZOOM_CONTROL (nautilus_zoom_control_get_type ())
#define NAUTILUS_ZOOM_CONTROL(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ZOOM_CONTROL, NautilusZoomControl))
#define NAUTILUS_ZOOM_CONTROL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ZOOM_CONTROL, NautilusZoomControlClass))
#define NAUTILUS_IS_ZOOM_CONTROL(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ZOOM_CONTROL))
#define NAUTILUS_IS_ZOOM_CONTROL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ZOOM_CONTROL))
typedef struct _NautilusZoomControl NautilusZoomControl;
typedef struct _NautilusZoomControlClass NautilusZoomControlClass;
struct _NautilusZoomControl
{
GtkPixmap pixmap;
gint current_zoom;
gint min_zoom;
gint max_zoom;
double zoom_factor;
};
struct _NautilusZoomControlClass
{
GtkEventBoxClass parent_class;
};
GtkType nautilus_zoom_control_get_type (void);
GtkWidget* nautilus_zoom_control_new (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __NAUTILUS_ZOOM_CONTROL_H__ */
......@@ -36,6 +36,7 @@
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-gtk-extensions.h>
#include "nautilus-zoom-control.h"
static void nautilus_window_realize (GtkWidget *widget);
static void nautilus_window_real_set_content_view (NautilusWindow *window, NautilusView *new_view);
......@@ -415,7 +416,7 @@ nautilus_window_constructed(NautilusWindow *window)
{
GnomeApp *app;
GtkWidget *location_bar_box, *statusbar;
GtkWidget *temp_frame;
GtkWidget *temp_frame, *zoom_control;
app = GNOME_APP(window);
......@@ -435,16 +436,22 @@ nautilus_window_constructed(NautilusWindow *window)
window->ent_uri = explorer_location_bar_new();
gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed",
nautilus_window_goto_uri_cb, window);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD);
gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL);
gnome_app_add_docked(app, location_bar_box, "uri-entry",
GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL,
GNOME_DOCK_TOP, 2, 0, 0);
/* Option menu for content view types; it's empty here, filled in when a uri is set. */
window->option_cvtype = gtk_option_menu_new();
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_BIG);
gtk_box_pack_end(GTK_BOX(location_bar_box), window->option_cvtype, FALSE, FALSE, GNOME_PAD_SMALL);
gtk_widget_show(window->option_cvtype);
/* allocate the zoom control and place on the right next to the menu */
zoom_control = nautilus_zoom_control_new();
gtk_widget_show(zoom_control);
gtk_box_pack_end(GTK_BOX(location_bar_box), zoom_control, FALSE, FALSE, 0);
gtk_widget_show_all(location_bar_box);
/* set up status bar */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment