Commit f81dc0d4 authored by Andy Hertzfeld's avatar Andy Hertzfeld

1st cut at the property browser for drag and drop customization


         1st cut at the property browser for drag and drop customization
parent 94ee23bd
2000-05-02 Andy Hertzfeld <andy@eazel.com>
1st cut at property browser for drag and drop customization;
Backgrounds are fully implemented, emblems are only partially there,
more coming soon
* src/Makefile.am: added property browser source files
* src/nautilus-property-browser.c,h:
new class that implements the property browser
* src/nautilus-window-menus.c:
added "customize" menu item and a callback that brings up
the property browser
* src/ntl-index-panel.c:
changed index panel to accept "property/bgimage" drag type and
change the background image accordingly
* libnautilus-extensions/nautilus-icon-dnd.c:
changed icon canvas to accept "property/bgimage" drag type and
change the background image accordingly; removed the old shift key hack
* libnautilus-extensions/nautilus-icon-dnd.h:
defined constants for the new drag type
* configure.in: two new data directories for backgrounds and emblems
* data/Makefile.am: added two new directories
* data/browser.xml: xml file that defines the categories
added some background images to play with:
* data/backgrounds/.cvsignore
* data/backgrounds/Makefile.am
* data/backgrounds/baize.png
* data/backgrounds/bricks.jpg
* data/backgrounds/bubbles.png
* data/backgrounds/buffedwood.jpg
* data/backgrounds/burlap.jpg
* data/backgrounds/chalk.jpg
* data/backgrounds/cherrywood.jpg
* data/backgrounds/cork.png
* data/backgrounds/dark-gnome.jpg
* data/backgrounds/darkwood.png
* data/backgrounds/frost.jpg
* data/backgrounds/gnome.jpg
* data/backgrounds/gold.jpg
* data/backgrounds/grass.png
* data/backgrounds/gray_fabric.png
* data/backgrounds/greenery.jpg
* data/backgrounds/manila.jpg
* data/backgrounds/pink_fabric.png
* data/backgrounds/puzzle.jpg
* data/backgrounds/raindrops.png
* data/backgrounds/sky.jpg
* data/backgrounds/stucco.jpg
* data/backgrounds/white_marble.jpg
* data/backgrounds/white_paper.jpg
* data/backgrounds/yellow_paper.jpg
added some emblem images:
* data/emblems/.cvsignore
* data/emblems/Makefile.am
* data/emblems/certified.gif
* data/emblems/changed.gif
* data/emblems/confidential.gif
* data/emblems/encrypted.gif
* data/emblems/important.gif
* data/emblems/new.gif
* data/emblems/personal.gif
* data/emblems/remote.gif
added images for the top-level categories
* icons/Makefile.am: added 2 images to Makefile
* icons/backgrounds.png
* icons/emblems.png
2000-05-02 Maciej Stachowiak <mjs@eazel.com>
* RENAMING: Added some idl-related renamings.
......
......@@ -295,6 +295,8 @@ icons/Makefile
icons/eazel/Makefile
data/Makefile
data/top/Makefile
data/backgrounds/Makefile
data/emblems/Makefile
idl/Makefile
librsvg/Makefile
libnautilus/Makefile
......
NULL=
SUBDIRS =\
infodir = $(datadir)/nautilus
info_DATA = \
browser.xml \
$(NULL)
EXTRA_DIST = $(info_DATA)
SUBDIRS = \
backgrounds \
emblems \
top \
$(NULL)
Makefile
Makefile.in
NULL=
backdir = $(datadir)/nautilus/backgrounds
back_DATA = \
baize.png \
bricks.jpg \
bubbles.png \
buffedwood.jpg \
burlap.jpg \
chalk.jpg \
cherrywood.jpg \
cork.png \
dark-gnome.jpg \
darkwood.png \
frost.jpg \
gnome.jpg \
gold.jpg \
grass.png \
gray_fabric.png \
greenery.jpg \
manila.jpg \
pink_fabric.png \
puzzle.jpg \
raindrops.png \
sky.jpg \
stucco.jpg \
white_marble.jpg \
white_paper.jpg \
yellow_paper.jpg \
$(NULL)
EXTRA_DIST = $(back_DATA)
<?xml version="1.0"?>
<categories>
<category name="backgrounds" image="nautilus/backgrounds.png" mode="directory" path="nautilus/backgrounds" type="property/bgimage"/>
<category name="emblems" image="nautilus/emblems.png" mode="directory" path="nautilus/emblems" type="property/emblem"/>
</categories>
Makefile
Makefile.in
NULL=
emblemsdir = $(datadir)/nautilus/emblems
emblems_DATA = \
certified.gif \
changed.gif \
confidential.gif \
encrypted.gif \
important.gif \
new.gif \
personal.gif \
remote.gif \
$(NULL)
EXTRA_DIST = $(emblems_DATA)
......@@ -3,6 +3,7 @@ SUBDIRS = eazel
icondir = $(datadir)/pixmaps/nautilus
icon_DATA = \
backgrounds.png \
computer.png \
eazel-logo.gif \
emblem-certified.gif \
......@@ -14,6 +15,7 @@ icon_DATA = \
emblem-personal.gif \
emblem-remote.gif \
emblem-symbolic-link.png \
emblems.png \
gnome-audio-x-mp3.png \
gnome-compressed.png \
gnome-library.png \
......
......@@ -82,7 +82,8 @@ static GtkTargetEntry drop_types [] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR }
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE }
};
static GnomeCanvasItem *
......@@ -496,7 +497,9 @@ drag_data_received_callback (GtkWidget *widget,
nautilus_icon_container_dropped_icon_feedback (widget, data, x, y);
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
/* Save the data so we can do the actual work on drop. */
dnd_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
break;
default:
......@@ -665,20 +668,11 @@ nautilus_icon_canvas_item_can_accept_items (NautilusIconContainer *container,
}
static void
receive_dropped_tile_image (NautilusIconContainer *container)
receive_dropped_tile_image (NautilusIconContainer *container, gpointer data)
{
GList *list;
/* We only accept the image if it's the only thing dragged. */
list = container->details->dnd_info->selection_list;
g_assert (list != NULL);
if (list->next != NULL) {
return;
}
g_assert(data != NULL);
nautilus_background_set_tile_image_uri
(nautilus_get_widget_background (GTK_WIDGET (container)),
((DndSelectionItem *) list->data)->uri);
(nautilus_get_widget_background (GTK_WIDGET (container)), data);
}
static void
......@@ -697,22 +691,11 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
GdkPoint *source_item_locations;
int index;
int count;
GdkModifierType modifiers;
if (container->details->dnd_info->selection_list == NULL) {
return;
}
/* If the shift key is down, then this is a drag that customizes
* the background tile image.
*/
gdk_window_get_pointer (GTK_WIDGET (container)->window,
NULL, NULL, &modifiers);
if ((modifiers & GDK_SHIFT_MASK) != 0) {
receive_dropped_tile_image (container);
return;
}
gnome_canvas_window_to_world (GNOME_CANVAS (container),
x, y, &world_x, &world_y);
......@@ -1147,6 +1130,9 @@ drag_drop_callback (GtkWidget *widget,
widget, x, y, dnd_info->selection_data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_BGIMAGE:
receive_dropped_tile_image (NAUTILUS_ICON_CONTAINER (widget), dnd_info->selection_data->data);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
}
......
......@@ -40,7 +40,8 @@ enum NautilusIconDndTargetType {
NAUTILUS_ICON_DND_GNOME_ICON_LIST,
NAUTILUS_ICON_DND_URI_LIST,
NAUTILUS_ICON_DND_URL,
NAUTILUS_ICON_DND_COLOR
NAUTILUS_ICON_DND_COLOR,
NAUTILUS_ICON_DND_BGIMAGE
};
/* DnD target names. */
......@@ -48,6 +49,7 @@ enum NautilusIconDndTargetType {
#define NAUTILUS_ICON_DND_URI_LIST_TYPE "text/uri-list"
#define NAUTILUS_ICON_DND_URL_TYPE "_NETSCAPE_URL"
#define NAUTILUS_ICON_DND_COLOR_TYPE "application/x-color"
#define NAUTILUS_ICON_DND_BGIMAGE_TYPE "property/bgimage"
/* DnD-related information. */
struct NautilusIconDndInfo {
......
......@@ -82,7 +82,8 @@ static GtkTargetEntry drop_types [] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR }
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE }
};
static GnomeCanvasItem *
......@@ -496,7 +497,9 @@ drag_data_received_callback (GtkWidget *widget,
nautilus_icon_container_dropped_icon_feedback (widget, data, x, y);
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
/* Save the data so we can do the actual work on drop. */
dnd_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
break;
default:
......@@ -665,20 +668,11 @@ nautilus_icon_canvas_item_can_accept_items (NautilusIconContainer *container,
}
static void
receive_dropped_tile_image (NautilusIconContainer *container)
receive_dropped_tile_image (NautilusIconContainer *container, gpointer data)
{
GList *list;
/* We only accept the image if it's the only thing dragged. */
list = container->details->dnd_info->selection_list;
g_assert (list != NULL);
if (list->next != NULL) {
return;
}
g_assert(data != NULL);
nautilus_background_set_tile_image_uri
(nautilus_get_widget_background (GTK_WIDGET (container)),
((DndSelectionItem *) list->data)->uri);
(nautilus_get_widget_background (GTK_WIDGET (container)), data);
}
static void
......@@ -697,22 +691,11 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container,
GdkPoint *source_item_locations;
int index;
int count;
GdkModifierType modifiers;
if (container->details->dnd_info->selection_list == NULL) {
return;
}
/* If the shift key is down, then this is a drag that customizes
* the background tile image.
*/
gdk_window_get_pointer (GTK_WIDGET (container)->window,
NULL, NULL, &modifiers);
if ((modifiers & GDK_SHIFT_MASK) != 0) {
receive_dropped_tile_image (container);
return;
}
gnome_canvas_window_to_world (GNOME_CANVAS (container),
x, y, &world_x, &world_y);
......@@ -1147,6 +1130,9 @@ drag_drop_callback (GtkWidget *widget,
widget, x, y, dnd_info->selection_data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_BGIMAGE:
receive_dropped_tile_image (NAUTILUS_ICON_CONTAINER (widget), dnd_info->selection_data->data);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
}
......
......@@ -40,7 +40,8 @@ enum NautilusIconDndTargetType {
NAUTILUS_ICON_DND_GNOME_ICON_LIST,
NAUTILUS_ICON_DND_URI_LIST,
NAUTILUS_ICON_DND_URL,
NAUTILUS_ICON_DND_COLOR
NAUTILUS_ICON_DND_COLOR,
NAUTILUS_ICON_DND_BGIMAGE
};
/* DnD target names. */
......@@ -48,6 +49,7 @@ enum NautilusIconDndTargetType {
#define NAUTILUS_ICON_DND_URI_LIST_TYPE "text/uri-list"
#define NAUTILUS_ICON_DND_URL_TYPE "_NETSCAPE_URL"
#define NAUTILUS_ICON_DND_COLOR_TYPE "application/x-color"
#define NAUTILUS_ICON_DND_BGIMAGE_TYPE "property/bgimage"
/* DnD-related information. */
struct NautilusIconDndInfo {
......
......@@ -45,6 +45,8 @@ nautilus_SOURCES =\
nautilus-index-title.h \
nautilus-location-bar.c \
nautilus-location-bar.h \
nautilus-property-browser.c \
nautilus-property-browser.h \
nautilus-self-check-functions.c \
nautilus-self-check-functions.h \
nautilus-signaller.c \
......
......@@ -91,12 +91,14 @@ static void add_command_buttons (NautilusIndexPanel *ind
enum {
TARGET_URI_LIST,
TARGET_COLOR,
TARGET_BGIMAGE,
TARGET_GNOME_URI_LIST
};
static GtkTargetEntry target_table[] = {
{ "text/uri-list", 0, TARGET_URI_LIST },
{ "application/x-color", 0, TARGET_COLOR },
{ "property/bgimage", 0, TARGET_BGIMAGE },
{ "special/x-gnome-icon-list", 0, TARGET_GNOME_URI_LIST }
};
......@@ -393,7 +395,11 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont
case TARGET_COLOR:
receive_dropped_color (index_panel, x, y, selection_data);
break;
case TARGET_BGIMAGE:
if (hit_test (index_panel, x, y) == BACKGROUND_PART)
receive_dropped_uri_list (index_panel, x, y, selection_data);
break;
default:
g_warning ("unknown drop type");
}
......
......@@ -30,6 +30,8 @@
#include "nautilus-signaller.h"
#include "ntl-app.h"
#include "ntl-window-private.h"
#include "nautilus-property-browser.h"
#include "libnautilus-extensions/nautilus-undo-manager.h"
#include <libnautilus/nautilus-bonobo-ui.h>
......@@ -70,6 +72,7 @@ typedef struct {
* don't want other code relying on their existence.
*/
#define NAUTILUS_MENU_PATH_GENERAL_SETTINGS_ITEM "/Settings/General Settings"
#define NAUTILUS_MENU_PATH_CUSTOMIZE_ITEM "/Settings/Customize"
#define NAUTILUS_MENU_PATH_USE_EAZEL_THEME_ICONS_ITEM "/Settings/Use Eazel Theme Icons"
#define NAUTILUS_MENU_PATH_DEBUG_MENU "/Debug"
#define NAUTILUS_MENU_PATH_SHOW_COLOR_SELECTOR_ITEM "/Debug/Show Color Selector"
......@@ -247,6 +250,14 @@ settings_menu_general_settings_callback (BonoboUIHandler *ui_handler,
nautilus_global_preferences_show_dialog ();
}
static void
settings_menu_customize_callback (BonoboUIHandler *ui_handler,
gpointer user_data,
const char *path)
{
nautilus_property_browser_new();
}
static void
settings_menu_use_eazel_theme_icons_callback (BonoboUIHandler *ui_handler,
gpointer user_data,
......@@ -800,6 +811,18 @@ nautilus_window_initialize_menus (NautilusWindow *window)
settings_menu_general_settings_callback,
NULL);
bonobo_ui_handler_menu_new_item (ui_handler,
NAUTILUS_MENU_PATH_CUSTOMIZE_ITEM,
_("_Customize..."),
_("Displays the Property Browser, to add properties to objects and customize appearance"),
-1,
BONOBO_UI_HANDLER_PIXMAP_NONE,
NULL,
0,
0,
settings_menu_customize_callback,
NULL);
/* It's called SEPARATOR_AFTER_USER_LEVELS because "General Settings" is
* going to expand into the user level choices plus the choice that brings
* up the user-level-details customizing dialog.
......
This diff is collapsed.
/* -*- 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 property browser window, which gives the user access to an
* extensible palette of properties which can be dropped on various elements of the user interface
* to customize them
*/
#ifndef NTL_PROPERTY_BROWSER_H
#define NTL_PROPERTY_BROWSER_H
#include <gtk/gtkwindow.h>
typedef struct NautilusPropertyBrowser NautilusPropertyBrowser;
typedef struct NautilusPropertyBrowserClass NautilusPropertyBrowserClass;
#define NAUTILUS_TYPE_PROPERTY_BROWSER \
(nautilus_property_browser_get_type ())
#define NAUTILUS_PROPERTY_BROWSER(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PROPERTY_BROWSER, NautilusPropertyBrowser))
#define NAUTILUS_PROPERTY_BROWSER_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PROPERTY_BROWSER, NautilusPropertyBrowserClass))
#define NAUTILUS_IS_PROPERTY_BROWSER(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PROPERTY_BROWSER))
#define NAUTILUS_IS_PROPERTY_BROWSER_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PROPERTY_BROWSER))
typedef struct NautilusPropertyBrowserDetails NautilusPropertyBrowserDetails;
struct NautilusPropertyBrowser
{
GtkWindow window;
NautilusPropertyBrowserDetails *details;
};
struct NautilusPropertyBrowserClass
{
GtkWindowClass parent_class;
};
GtkType nautilus_property_browser_get_type (void);
NautilusPropertyBrowser *nautilus_property_browser_new (void);
void nautilus_property_browser_set_path (NautilusPropertyBrowser *panel,
const char *new_path);
#endif /* NTL_PROPERTY_BROWSER_H */
......@@ -91,12 +91,14 @@ static void add_command_buttons (NautilusIndexPanel *ind
enum {
TARGET_URI_LIST,
TARGET_COLOR,
TARGET_BGIMAGE,
TARGET_GNOME_URI_LIST
};
static GtkTargetEntry target_table[] = {
{ "text/uri-list", 0, TARGET_URI_LIST },
{ "application/x-color", 0, TARGET_COLOR },
{ "property/bgimage", 0, TARGET_BGIMAGE },
{ "special/x-gnome-icon-list", 0, TARGET_GNOME_URI_LIST }
};
......@@ -393,7 +395,11 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont
case TARGET_COLOR:
receive_dropped_color (index_panel, x, y, selection_data);
break;
case TARGET_BGIMAGE:
if (hit_test (index_panel, x, y) == BACKGROUND_PART)
receive_dropped_uri_list (index_panel, x, y, selection_data);
break;
default:
g_warning ("unknown drop type");
}
......
......@@ -30,6 +30,8 @@
#include "nautilus-signaller.h"
#include "ntl-app.h"
#include "ntl-window-private.h"
#include "nautilus-property-browser.h"
#include "libnautilus-extensions/nautilus-undo-manager.h"
#include <libnautilus/nautilus-bonobo-ui.h>
......@@ -70,6 +72,7 @@ typedef struct {
* don't want other code relying on their existence.
*/
#define NAUTILUS_MENU_PATH_GENERAL_SETTINGS_ITEM "/Settings/General Settings"
#define NAUTILUS_MENU_PATH_CUSTOMIZE_ITEM "/Settings/Customize"
#define NAUTILUS_MENU_PATH_USE_EAZEL_THEME_ICONS_ITEM "/Settings/Use Eazel Theme Icons"
#define NAUTILUS_MENU_PATH_DEBUG_MENU "/Debug"
#define NAUTILUS_MENU_PATH_SHOW_COLOR_SELECTOR_ITEM "/Debug/Show Color Selector"
......@@ -247,6 +250,14 @@ settings_menu_general_settings_callback (BonoboUIHandler *ui_handler,
nautilus_global_preferences_show_dialog ();
}
static void
settings_menu_customize_callback (BonoboUIHandler *ui_handler,