mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 10:45:41 +00:00
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.
This commit is contained in:
parent
8f095d516e
commit
ea17634557
38
ChangeLog
38
ChangeLog
|
@ -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:
|
||||
|
|
|
@ -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>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.4 KiB |
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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:
|
||||
}
|
||||
|
@ -969,6 +972,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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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:
|
||||
}
|
||||
|
@ -969,6 +972,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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
}
|
||||
|
@ -969,6 +972,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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
197
src/nautilus-toolbar.c
Normal file
197
src/nautilus-toolbar.c
Normal file
|
@ -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 ();
|
||||
}
|
||||
}
|
||||
}
|
51
src/nautilus-toolbar.h
Normal file
51
src/nautilus-toolbar.h
Normal file
|
@ -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 */
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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:
|
||||
}
|
||||
|
@ -969,6 +972,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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue