diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2000-07-11 02:59:49 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2000-07-11 02:59:49 +0000 |
commit | ea1763455727a4285222c18eeef508c1aa77864c (patch) | |
tree | d141da192b86677d97bfaf5cac54d982933b5f74 | |
parent | 8f095d516e009785127508951f25fe9a517665ec (diff) | |
download | nautilus-ea1763455727a4285222c18eeef508c1aa77864c.tar.gz |
added a "web search" button to the toolbar. To do this, I also had to
added a "web search" button to the toolbar. To do this, I also
had to create a new toolbar subclass to overcome the problem
of using the maximum width for all the buttons.
-rw-r--r-- | ChangeLog | 38 | ||||
-rw-r--r-- | data/browser.xml | 8 | ||||
-rw-r--r-- | icons/arlo/sidebar_tab_pieces.png | bin | 6369 -> 6559 bytes | |||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.c | 20 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.h | 7 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.c | 20 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.h | 7 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 19 | ||||
-rw-r--r-- | src/nautilus-navigation-window.h | 4 | ||||
-rw-r--r-- | src/nautilus-object-window.c | 19 | ||||
-rw-r--r-- | src/nautilus-object-window.h | 4 | ||||
-rw-r--r-- | src/nautilus-property-browser.c | 10 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 19 | ||||
-rw-r--r-- | src/nautilus-spatial-window.h | 4 | ||||
-rw-r--r-- | src/nautilus-toolbar.c | 197 | ||||
-rw-r--r-- | src/nautilus-toolbar.h | 51 | ||||
-rw-r--r-- | src/nautilus-window-toolbars.c | 58 | ||||
-rw-r--r-- | src/nautilus-window.c | 19 | ||||
-rw-r--r-- | src/nautilus-window.h | 4 |
20 files changed, 465 insertions, 45 deletions
@@ -1,3 +1,41 @@ +2000-07-10 Andy Hertzfeld <andy@eazel.com> + + added a "web search" button to the toolbar + + * libnautilus-extensions/nautilus-global-preferences.c,h: + (global_preferences_create_dialog), + (global_preferences_register_for_ui): + added a preference for the web search uri. + + * src/Makefile.am: + * src/nautilus-toolbar.c,h: (nautilus_toolbar_new), + (nautilus_toolbar_initialize_class), (nautilus_toolbar_initialize), + (nautilus_toolbar_set_button_spacing), + (nautilus_toolbar_size_allocate): + added a new nautilus_toolbar class to overcome the problem that + the normal toolbar uses the maximum width for all the buttons, + because the "web search" button has a longer name than usual + + * src/nautilus-window-toolbars.c: (toolbar_clear_search_mode), + (toolbar_search_local_callback), (toolbar_search_web_callback), + (remember_buttons), (setup_toolbar_images), + (nautilus_window_initialize_toolbars): + used nautilus_toolbar instead of gtk_toolbar; + added a "web search" button to the toolbar + + * src/nautilus-window.c,h: (navigation_bar_mode_changed_callback), + (nautilus_window_set_search_mode), (nautilus_window_go_web_search): + added the semantics for web search, which is to invoke the + location specified by the web search uri + + * src/nautilus-property-browser.c: (remove_color), + (nautilus_property_browser_remove_element), + (make_properties_from_xml_node): + some minor clean-ups + * data/browser.xml: + capitalized titles for Arlo + + 2000-07-10 Robey Pointer <robey@eazel.com> * components/services/trilobite/helper/.cvsignore: diff --git a/data/browser.xml b/data/browser.xml index 104d92904..e7802d55d 100644 --- a/data/browser.xml +++ b/data/browser.xml @@ -1,8 +1,8 @@ <?xml version="1.0"?> <categories> - <category name="backgrounds" image="backgrounds.png" mode="directory" path="nautilus/backgrounds" type="property/bgimage" description="Drag a background tile to an object to change it"/> - <category name="emblems" image="emblems.png" mode="directory" path="nautilus/emblems" type="property/keyword" description="Drag an emblem to an object to add it to the object"/> - <category name="colors" image="colors.png" mode="inline" type="application/x-color" description="Drag a color to an object to change it to that color"> + <category name="Backgrounds" image="backgrounds.png" mode="directory" path="nautilus/backgrounds" type="property/bgimage" description="Drag a background tile to an object to change it"/> + <category name="Emblems" image="emblems.png" mode="directory" path="nautilus/emblems" type="property/keyword" description="Drag an emblem to an object to add it to the object"/> + <category name="Colors" image="colors.png" mode="inline" type="application/x-color" description="Drag a color to an object to change it to that color"> <color>rgb:FFFF/FFFF/3333</color> <color>rgb:FFFF/CCCC/3333</color> <color>rgb:FFFF/9999/3333</color> @@ -28,5 +28,5 @@ <color>rgb:CCCC/CCCC/CCCC</color> <color>rgb:FFFE/FFFE/FFFE</color> </category> - <category name="themes" image="colors.png" mode="themes" path="icons" type="property/theme" description="Click on a theme button to switch to that theme"/> + <category name="Themes" image="colors.png" mode="themes" path="icons" type="property/theme" description="Click on a theme button to switch to that theme"/> </categories> diff --git a/icons/arlo/sidebar_tab_pieces.png b/icons/arlo/sidebar_tab_pieces.png Binary files differindex 82c4f01a9..89a152bfa 100644 --- a/icons/arlo/sidebar_tab_pieces.png +++ b/icons/arlo/sidebar_tab_pieces.png diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c index f5f043fa1..c32fbc2ed 100644 --- a/libnautilus-extensions/nautilus-global-preferences.c +++ b/libnautilus-extensions/nautilus-global-preferences.c @@ -40,6 +40,9 @@ /* Constants */ #define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences") +/* default web search uri - this will soon be changed to point to our service */ +#define DEFAULT_SEARCH_WEB_URI "http://www.google.com" + /* Private stuff */ static GtkWidget *global_preferences_create_dialog (void); static GtkWidget *global_preferences_get_dialog (void); @@ -255,8 +258,14 @@ global_preferences_create_dialog (void) 1, NAUTILUS_PREFERENCES_SEARCH_METHOD, NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - + + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane), + "Search Locations"); + nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane), + 2, + NAUTILUS_PREFERENCES_SEARCH_WEB_URI, + NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING); /* * Navigation @@ -591,6 +600,13 @@ global_preferences_register_for_ui (void) "Search for files by text and by their properties", NAUTILUS_COMPLEX_SEARCH_BAR); + /* web search uri */ + global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, + "Search Web Location", + DEFAULT_SEARCH_WEB_URI, + DEFAULT_SEARCH_WEB_URI, + DEFAULT_SEARCH_WEB_URI); + /* * FIXME: These dont have a UI (yet ? maybe in the advanced settings ?). * They do need to have appropiate defaults nontheless. diff --git a/libnautilus-extensions/nautilus-global-preferences.h b/libnautilus-extensions/nautilus-global-preferences.h index 21918d762..e57691c0b 100644 --- a/libnautilus-extensions/nautilus-global-preferences.h +++ b/libnautilus-extensions/nautilus-global-preferences.h @@ -66,8 +66,11 @@ BEGIN_GNOME_DECLS #define NAUTILUS_PREFERENCES_THEME "preferences/theme" /* File Indexing */ -#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search" -#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type" +#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search" +#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type" + +/* searching */ +#define NAUTILUS_PREFERENCES_SEARCH_WEB_URI "preferences/search_web_uri" enum { diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index f5f043fa1..c32fbc2ed 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -40,6 +40,9 @@ /* Constants */ #define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences") +/* default web search uri - this will soon be changed to point to our service */ +#define DEFAULT_SEARCH_WEB_URI "http://www.google.com" + /* Private stuff */ static GtkWidget *global_preferences_create_dialog (void); static GtkWidget *global_preferences_get_dialog (void); @@ -255,8 +258,14 @@ global_preferences_create_dialog (void) 1, NAUTILUS_PREFERENCES_SEARCH_METHOD, NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - + + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane), + "Search Locations"); + nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane), + 2, + NAUTILUS_PREFERENCES_SEARCH_WEB_URI, + NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING); /* * Navigation @@ -591,6 +600,13 @@ global_preferences_register_for_ui (void) "Search for files by text and by their properties", NAUTILUS_COMPLEX_SEARCH_BAR); + /* web search uri */ + global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, + "Search Web Location", + DEFAULT_SEARCH_WEB_URI, + DEFAULT_SEARCH_WEB_URI, + DEFAULT_SEARCH_WEB_URI); + /* * FIXME: These dont have a UI (yet ? maybe in the advanced settings ?). * They do need to have appropiate defaults nontheless. diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index 21918d762..e57691c0b 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -66,8 +66,11 @@ BEGIN_GNOME_DECLS #define NAUTILUS_PREFERENCES_THEME "preferences/theme" /* File Indexing */ -#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search" -#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type" +#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search" +#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type" + +/* searching */ +#define NAUTILUS_PREFERENCES_SEARCH_WEB_URI "preferences/search_web_uri" enum { diff --git a/src/Makefile.am b/src/Makefile.am index 0131b51b2..6a9b26d3a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,6 +69,7 @@ noinst_HEADERS = \ nautilus-simple-search-bar.h \ nautilus-switchable-navigation-bar.h \ nautilus-switchable-search-bar.h \ + nautilus-toolbar.h \ nautilus-view-frame-private.h \ nautilus-view-frame.h \ nautilus-window-manage-views.h \ @@ -103,6 +104,7 @@ nautilus_SOURCES = \ nautilus-simple-search-bar.c \ nautilus-switchable-navigation-bar.c \ nautilus-switchable-search-bar.c \ + nautilus-toolbar.c \ nautilus-view-frame-bonobo-control.c \ nautilus-view-frame-bonobo-embeddable.c \ nautilus-view-frame-corba.c \ diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 6fd975f42..9bcda0312 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -68,6 +68,9 @@ /* GNOME Dock Items */ #define URI_ENTRY_DOCK_ITEM "uri_entry" +/* default web search uri - this will soon be changed to point to our service */ +#define DEFAULT_SEARCH_WEB_URI "http://www.google.com" + enum { ARG_0, ARG_APP_ID, @@ -183,10 +186,10 @@ navigation_bar_mode_changed_callback (GtkWidget *widget, { switch (mode) { case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), FALSE); break; case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), TRUE); break; default: } @@ -970,6 +973,18 @@ nautilus_window_set_search_mode (NautilusWindow *window, } void +nautilus_window_go_web_search (NautilusWindow *window) +{ + char *search_web_uri; + + search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, DEFAULT_SEARCH_WEB_URI); + g_assert (search_web_uri != NULL); + + nautilus_window_goto_uri (window, search_web_uri); + g_free (search_web_uri); +} + +void nautilus_window_go_home (NautilusWindow *window) { char *default_home_uri, *home_uri; diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index 7172322eb..a2f158e67 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -110,7 +110,8 @@ struct NautilusWindow { GtkWidget *forward_button; GtkWidget *up_button; GtkWidget *reload_button; - GtkWidget *search_button; + GtkWidget *search_local_button; + GtkWidget *search_web_button; GtkWidget *stop_button; GtkWidget *home_button; @@ -157,6 +158,7 @@ void nautilus_window_goto_uri (NautilusWindow *window void nautilus_window_set_search_mode (NautilusWindow *window, gboolean search_mode); void nautilus_window_go_home (NautilusWindow *window); +void nautilus_window_go_web_search (NautilusWindow *window); void nautilus_window_display_error (NautilusWindow *window, const char *error_msg); void nautilus_window_allow_back (NautilusWindow *window, diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 6fd975f42..9bcda0312 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -68,6 +68,9 @@ /* GNOME Dock Items */ #define URI_ENTRY_DOCK_ITEM "uri_entry" +/* default web search uri - this will soon be changed to point to our service */ +#define DEFAULT_SEARCH_WEB_URI "http://www.google.com" + enum { ARG_0, ARG_APP_ID, @@ -183,10 +186,10 @@ navigation_bar_mode_changed_callback (GtkWidget *widget, { switch (mode) { case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), FALSE); break; case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), TRUE); break; default: } @@ -970,6 +973,18 @@ nautilus_window_set_search_mode (NautilusWindow *window, } void +nautilus_window_go_web_search (NautilusWindow *window) +{ + char *search_web_uri; + + search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, DEFAULT_SEARCH_WEB_URI); + g_assert (search_web_uri != NULL); + + nautilus_window_goto_uri (window, search_web_uri); + g_free (search_web_uri); +} + +void nautilus_window_go_home (NautilusWindow *window) { char *default_home_uri, *home_uri; diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h index 7172322eb..a2f158e67 100644 --- a/src/nautilus-object-window.h +++ b/src/nautilus-object-window.h @@ -110,7 +110,8 @@ struct NautilusWindow { GtkWidget *forward_button; GtkWidget *up_button; GtkWidget *reload_button; - GtkWidget *search_button; + GtkWidget *search_local_button; + GtkWidget *search_web_button; GtkWidget *stop_button; GtkWidget *home_button; @@ -157,6 +158,7 @@ void nautilus_window_goto_uri (NautilusWindow *window void nautilus_window_set_search_mode (NautilusWindow *window, gboolean search_mode); void nautilus_window_go_home (NautilusWindow *window); +void nautilus_window_go_web_search (NautilusWindow *window); void nautilus_window_display_error (NautilusWindow *window, const char *error_msg); void nautilus_window_allow_back (NautilusWindow *window, diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index e8f13ffa6..5c18b08bc 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -541,7 +541,7 @@ title_clicked_callback (GtkWidget *widget, GdkEventButton *event, NautilusProper /* having trouble removing nodes, so instead I'll mark it invisible - eventually this needs to be fixed */ static void -remove_color(NautilusPropertyBrowser *property_browser, const char* color_value) +remove_color (NautilusPropertyBrowser *property_browser, const char* color_value) { /* load the local xml file to remove the color */ xmlNodePtr cur_node; @@ -645,7 +645,7 @@ remove_emblem(NautilusPropertyBrowser *property_browser, const char* emblem_name /* handle removing the passed in element */ static void -nautilus_property_browser_remove_element(NautilusPropertyBrowser *property_browser, const char* element_name) +nautilus_property_browser_remove_element (NautilusPropertyBrowser *property_browser, const char* element_name) { /* lookup category and get mode, then case out and handle the modes */ if (!strcmp(property_browser->details->category, "backgrounds")) { @@ -1392,8 +1392,8 @@ make_properties_from_xml_node (NautilusPropertyBrowser *property_browser, xmlNod if (!deleted && (!local_only || (local != NULL))) { GtkWidget *event_box = gtk_event_box_new(); - gtk_widget_set_usize(event_box, 48, 32); - gtk_widget_show(event_box); + gtk_widget_set_usize (event_box, 48, 32); + gtk_widget_show (event_box); frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); @@ -1437,7 +1437,7 @@ make_properties_from_xml_node (NautilusPropertyBrowser *property_browser, xmlNod FALSE, FALSE); - add_to_content_table(property_browser, frame, index++, 12); + add_to_content_table (property_browser, frame, index++, 12); } } } diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 6fd975f42..9bcda0312 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -68,6 +68,9 @@ /* GNOME Dock Items */ #define URI_ENTRY_DOCK_ITEM "uri_entry" +/* default web search uri - this will soon be changed to point to our service */ +#define DEFAULT_SEARCH_WEB_URI "http://www.google.com" + enum { ARG_0, ARG_APP_ID, @@ -183,10 +186,10 @@ navigation_bar_mode_changed_callback (GtkWidget *widget, { switch (mode) { case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), FALSE); break; case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), TRUE); break; default: } @@ -970,6 +973,18 @@ nautilus_window_set_search_mode (NautilusWindow *window, } void +nautilus_window_go_web_search (NautilusWindow *window) +{ + char *search_web_uri; + + search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, DEFAULT_SEARCH_WEB_URI); + g_assert (search_web_uri != NULL); + + nautilus_window_goto_uri (window, search_web_uri); + g_free (search_web_uri); +} + +void nautilus_window_go_home (NautilusWindow *window) { char *default_home_uri, *home_uri; diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h index 7172322eb..a2f158e67 100644 --- a/src/nautilus-spatial-window.h +++ b/src/nautilus-spatial-window.h @@ -110,7 +110,8 @@ struct NautilusWindow { GtkWidget *forward_button; GtkWidget *up_button; GtkWidget *reload_button; - GtkWidget *search_button; + GtkWidget *search_local_button; + GtkWidget *search_web_button; GtkWidget *stop_button; GtkWidget *home_button; @@ -157,6 +158,7 @@ void nautilus_window_goto_uri (NautilusWindow *window void nautilus_window_set_search_mode (NautilusWindow *window, gboolean search_mode); void nautilus_window_go_home (NautilusWindow *window); +void nautilus_window_go_web_search (NautilusWindow *window); void nautilus_window_display_error (NautilusWindow *window, const char *error_msg); void nautilus_window_allow_back (NautilusWindow *window, diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c new file mode 100644 index 000000000..166aa0b99 --- /dev/null +++ b/src/nautilus-toolbar.c @@ -0,0 +1,197 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-toolbar.c - toolbar for Nautilus to overcome fixed spacing problem + + 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; see the file COPYING. 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> +*/ + +#include <config.h> +#include <gtk/gtktoolbar.h> + +#include <gnome.h> +#include <libnautilus-extensions/nautilus-gtk-macros.h> + +#include "nautilus-toolbar.h" + +typedef struct _GtkToolbarChildSpace GtkToolbarChildSpace; +struct _GtkToolbarChildSpace +{ + GtkToolbarChild child; + + gint alloc_x, alloc_y; +}; + +static void nautilus_toolbar_initialize_class (NautilusToolbarClass *class); +static void nautilus_toolbar_initialize (NautilusToolbar *bar); +static void nautilus_toolbar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusToolbar, nautilus_toolbar, GTK_TYPE_TOOLBAR) + +GtkWidget * +nautilus_toolbar_new (void) +{ + return gtk_widget_new (NAUTILUS_TYPE_TOOLBAR, NULL); +} + + +static void +nautilus_toolbar_initialize_class (NautilusToolbarClass *klass) +{ + + GtkWidgetClass *widget_class; + + widget_class = (GtkWidgetClass *) klass; + widget_class->size_allocate = nautilus_toolbar_size_allocate; +} + +static void +nautilus_toolbar_initialize (NautilusToolbar *bar) +{ + bar->button_spacing = 48; /* default to reasonable amount */ +} + +void +nautilus_toolbar_set_button_spacing (NautilusToolbar *toolbar, int spacing) +{ + toolbar->button_spacing = spacing; +} + + +static void +nautilus_toolbar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkToolbar *toolbar; + GtkToolbarChildSpace *child_space; + NautilusToolbar *nautilus_toolbar; + GList *children; + GtkToolbarChild *child; + GtkAllocation alloc; + GtkRequisition child_requisition; + gint border_width; + gint spacing; + gint item_width, item_height; + gint width_to_use, height_to_use; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TOOLBAR (widget)); + g_return_if_fail (allocation != NULL); + + toolbar = GTK_TOOLBAR (widget); + nautilus_toolbar = NAUTILUS_TOOLBAR (widget); + spacing = nautilus_toolbar->button_spacing; + + widget->allocation = *allocation; + + border_width = GTK_CONTAINER (toolbar)->border_width; + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + alloc.x = allocation->x + border_width; + else + alloc.y = allocation->y + border_width; + + for (children = toolbar->children; children; children = children->next) + { + child = children->data; + + switch (child->type) + { + case GTK_TOOLBAR_CHILD_SPACE: + child_space = (GtkToolbarChildSpace *) child; + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + { + child_space->alloc_x = alloc.x; + child_space->alloc_y = allocation->y + (allocation->height - toolbar->button_maxh) / 2; + alloc.x += toolbar->space_size; + } + else + { + child_space->alloc_x = allocation->x + (allocation->width - toolbar->button_maxw) / 2; + child_space->alloc_y = alloc.y; + alloc.y += toolbar->space_size; + } + + break; + + case GTK_TOOLBAR_CHILD_BUTTON: + case GTK_TOOLBAR_CHILD_RADIOBUTTON: + case GTK_TOOLBAR_CHILD_TOGGLEBUTTON: + if (!GTK_WIDGET_VISIBLE (child->widget)) + break; + + item_width = child->widget->requisition.width; + item_height = child->widget->requisition.height; + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) { + width_to_use = (item_width > spacing) ? item_width : spacing; + height_to_use = toolbar->button_maxh; + } else { + width_to_use = toolbar->button_maxw; + height_to_use = (item_height > spacing) ? item_height : spacing; + } + + alloc.width = width_to_use; + alloc.height = height_to_use; + + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + alloc.y = allocation->y + (allocation->height - height_to_use) / 2; + else + alloc.x = allocation->x + (allocation->width - width_to_use) / 2; + + gtk_widget_size_allocate (child->widget, &alloc); + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + alloc.x += width_to_use; + else + alloc.y += height_to_use; + + break; + + case GTK_TOOLBAR_CHILD_WIDGET: + if (!GTK_WIDGET_VISIBLE (child->widget)) + break; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + alloc.width = child_requisition.width; + alloc.height = child_requisition.height; + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + alloc.y = allocation->y + (allocation->height - child_requisition.height) / 2; + else + alloc.x = allocation->x + (allocation->width - child_requisition.width) / 2; + + gtk_widget_size_allocate (child->widget, &alloc); + + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + alloc.x += child_requisition.width; + else + alloc.y += child_requisition.height; + + break; + + default: + g_assert_not_reached (); + } + } +} diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h new file mode 100644 index 000000000..a0178879c --- /dev/null +++ b/src/nautilus-toolbar.h @@ -0,0 +1,51 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-toolbar.h - Toolbar for Nautilus that overcomes fixed spacing problem + + 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; see the file COPYING. 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> +*/ + +#ifndef NAUTILUS_TOOLBAR_H +#define NAUTILUS_TOOLBAR_H + +#include <gtk/gtktoolbar.h> + +#define NAUTILUS_TYPE_TOOLBAR (nautilus_toolbar_get_type ()) +#define NAUTILUS_TOOLBAR(obj) \ + GTK_CHECK_CAST (obj, NAUTILUS_TYPE_TOOLBAR, NautilusToolbar) +#define NAUTILUS_TOOLBAR_CLASS(klass) \ + GTK_CHECK_CLASS_CAST (klass, NAUTILUS_TYPE_TOOLBAR, NautilusToolbarClass) +#define NAUTILUS_IS_TOOLBAR(obj) \ + GTK_CHECK_TYPE (obj, NAUTILUS_TYPE_TOOLBAR) + +typedef struct NautilusToolbar { + GtkToolbar parent; + int button_spacing; +} NautilusToolbar; + +typedef struct { + GtkToolbarClass parent_class; +} NautilusToolbarClass; + +GtkType nautilus_toolbar_get_type (void); +GtkWidget* nautilus_toolbar_new (void); +void nautilus_toolbar_set_button_spacing (NautilusToolbar *toolbar, int spacing); + +#endif /* NAUTILUS_TOOLBAR_H */ diff --git a/src/nautilus-window-toolbars.c b/src/nautilus-window-toolbars.c index fec6d30bd..6dfb4811e 100644 --- a/src/nautilus-window-toolbars.c +++ b/src/nautilus-window-toolbars.c @@ -24,6 +24,7 @@ */ #include <config.h> +#include "nautilus-toolbar.h" #include "nautilus-window.h" #include "nautilus-window-private.h" #include "nautilus-application.h" @@ -43,23 +44,24 @@ static void toolbar_services_callback (GtkWidget *widget, NautilusWindow *window /* toolbar definitions */ -#define TOOLBAR_BACK_BUTTON_INDEX 0 -#define TOOLBAR_FORWARD_BUTTON_INDEX 1 -#define TOOLBAR_UP_BUTTON_INDEX 2 -#define TOOLBAR_RELOAD_BUTTON_INDEX 3 +#define TOOLBAR_BACK_BUTTON_INDEX 0 +#define TOOLBAR_FORWARD_BUTTON_INDEX 1 +#define TOOLBAR_UP_BUTTON_INDEX 2 +#define TOOLBAR_RELOAD_BUTTON_INDEX 3 /* separator */ -#define TOOLBAR_HOME_BUTTON_INDEX 5 -#define TOOLBAR_SEARCH_BUTTON_INDEX 6 +#define TOOLBAR_HOME_BUTTON_INDEX 5 +#define TOOLBAR_SEARCH_LOCAL_BUTTON_INDEX 6 +#define TOOLBAR_SEARCH_WEB_BUTTON_INDEX 7 /* separator */ -#define TOOLBAR_STOP_BUTTON_INDEX 8 -#define TOOLBAR_SERVICES_INDEX 9 +#define TOOLBAR_STOP_BUTTON_INDEX 9 +#define TOOLBAR_SERVICES_INDEX 10 static void toolbar_clear_search_mode(NautilusWindow *window) { GtkToggleButton *button; - button = GTK_TOGGLE_BUTTON(window->search_button); + button = GTK_TOGGLE_BUTTON(window->search_local_button); if (button->active) { nautilus_window_set_search_mode (window, FALSE); gtk_toggle_button_set_active(button, FALSE); @@ -93,11 +95,17 @@ toolbar_home_callback (GtkWidget *widget, NautilusWindow *window) static void -toolbar_search_callback (GtkWidget *widget, NautilusWindow *window) +toolbar_search_local_callback (GtkWidget *widget, NautilusWindow *window) { nautilus_window_set_search_mode (window, GTK_TOGGLE_BUTTON (widget)->active); } +static void +toolbar_search_web_callback (GtkWidget *widget, NautilusWindow *window) +{ + nautilus_window_go_web_search (window); +} + #define NAUTILUS_GNOMEUIINFO_TOGGLEITEM_STOCK(label, tooltip, callback, stock_id) \ { GNOME_APP_UI_TOGGLEITEM, label, tooltip, (gpointer)callback, NULL, NULL, \ GNOME_APP_PIXMAP_STOCK, stock_id, 0, (GdkModifierType) 0, NULL } @@ -107,23 +115,35 @@ static GnomeUIInfo toolbar_info[] = { GNOMEUIINFO_ITEM_STOCK (N_("Back"), N_("Go to the previously visited directory"), toolbar_back_callback, "nautilus/eazel/Back.png"), + GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"), toolbar_forward_callback, "nautilus/eazel/Forward.png"), + GNOMEUIINFO_ITEM_STOCK (N_("Up"), N_("Go up a level in the directory hierarchy"), toolbar_up_callback, "nautilus/eazel/Up.png"), + GNOMEUIINFO_ITEM_STOCK (N_("Reload"), N_("Reload this view"), toolbar_reload_callback, "nautilus/eazel/Refresh.png"), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK (N_("Home"), N_("Go to your home directory"), toolbar_home_callback, "nautilus/eazel/Home.png"), + NAUTILUS_GNOMEUIINFO_TOGGLEITEM_STOCK - (N_("Search"), N_("Search for files"), - toolbar_search_callback, "nautilus/eazel/Search.png"), + (N_("Search"), N_("Search this computer for files"), + toolbar_search_local_callback, "nautilus/eazel/Search.png"), + + GNOMEUIINFO_ITEM_STOCK + (N_("Web Search"), N_("Search the web"), + toolbar_search_web_callback, "nautilus/eazel/Search.png"), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_ITEM_STOCK (N_("Stop"), N_("Interrupt loading"), toolbar_stop_callback, "nautilus/eazel/Stop.png"), @@ -230,7 +250,8 @@ remember_buttons(NautilusWindow *window, GnomeUIInfo current_toolbar_info[]) window->forward_button = current_toolbar_info[TOOLBAR_FORWARD_BUTTON_INDEX].widget; window->up_button = current_toolbar_info[TOOLBAR_UP_BUTTON_INDEX].widget; window->reload_button = current_toolbar_info[TOOLBAR_RELOAD_BUTTON_INDEX].widget; - window->search_button = current_toolbar_info[TOOLBAR_SEARCH_BUTTON_INDEX].widget; + window->search_local_button = current_toolbar_info[TOOLBAR_SEARCH_LOCAL_BUTTON_INDEX].widget; + window->search_web_button = current_toolbar_info[TOOLBAR_SEARCH_WEB_BUTTON_INDEX].widget; window->stop_button = current_toolbar_info[TOOLBAR_STOP_BUTTON_INDEX].widget; window->home_button = current_toolbar_info[TOOLBAR_HOME_BUTTON_INDEX].widget; } @@ -293,7 +314,8 @@ setup_toolbar_images(NautilusWindow *window) setup_button (window->up_button, theme_name, GNOME_STOCK_PIXMAP_UP); setup_button (window->home_button, theme_name, GNOME_STOCK_PIXMAP_HOME); setup_button (window->reload_button, theme_name, GNOME_STOCK_PIXMAP_REFRESH); - setup_button (window->search_button, theme_name, GNOME_STOCK_PIXMAP_SEARCH); + setup_button (window->search_local_button, theme_name, GNOME_STOCK_PIXMAP_SEARCH); + setup_button (window->search_web_button, theme_name, GNOME_STOCK_PIXMAP_SEARCH); setup_button (window->stop_button, theme_name, GNOME_STOCK_PIXMAP_STOP); g_free(theme_name); @@ -308,8 +330,12 @@ nautilus_window_initialize_toolbars (NautilusWindow *window) app = GNOME_APP (window); - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); - gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), toolbar_info, app->accel_group, app); + toolbar = nautilus_toolbar_new (); + gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_HORIZONTAL); + gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH); + nautilus_toolbar_set_button_spacing (NAUTILUS_TOOLBAR (toolbar), 50); + + gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), toolbar_info, app->accel_group, app); remember_buttons(window, toolbar_info); setup_toolbar_images(window); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 6fd975f42..9bcda0312 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -68,6 +68,9 @@ /* GNOME Dock Items */ #define URI_ENTRY_DOCK_ITEM "uri_entry" +/* default web search uri - this will soon be changed to point to our service */ +#define DEFAULT_SEARCH_WEB_URI "http://www.google.com" + enum { ARG_0, ARG_APP_ID, @@ -183,10 +186,10 @@ navigation_bar_mode_changed_callback (GtkWidget *widget, { switch (mode) { case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_LOCATION: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), FALSE); break; case NAUTILUS_SWITCHABLE_NAVIGATION_BAR_MODE_SEARCH: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_button), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NAUTILUS_WINDOW (window)->search_local_button), TRUE); break; default: } @@ -970,6 +973,18 @@ nautilus_window_set_search_mode (NautilusWindow *window, } void +nautilus_window_go_web_search (NautilusWindow *window) +{ + char *search_web_uri; + + search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, DEFAULT_SEARCH_WEB_URI); + g_assert (search_web_uri != NULL); + + nautilus_window_goto_uri (window, search_web_uri); + g_free (search_web_uri); +} + +void nautilus_window_go_home (NautilusWindow *window) { char *default_home_uri, *home_uri; diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 7172322eb..a2f158e67 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -110,7 +110,8 @@ struct NautilusWindow { GtkWidget *forward_button; GtkWidget *up_button; GtkWidget *reload_button; - GtkWidget *search_button; + GtkWidget *search_local_button; + GtkWidget *search_web_button; GtkWidget *stop_button; GtkWidget *home_button; @@ -157,6 +158,7 @@ void nautilus_window_goto_uri (NautilusWindow *window void nautilus_window_set_search_mode (NautilusWindow *window, gboolean search_mode); void nautilus_window_go_home (NautilusWindow *window); +void nautilus_window_go_web_search (NautilusWindow *window); void nautilus_window_display_error (NautilusWindow *window, const char *error_msg); void nautilus_window_allow_back (NautilusWindow *window, |