diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-04-05 14:27:38 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-04-05 14:27:38 +0000 |
commit | de6dc4e973fb98358d7b4fade4072c3b0365e8ce (patch) | |
tree | 7521240772454326f836a5b02439059a71c430f1 | |
parent | b13b5a40dcfcd106780ec20ddfae6c61420fb7ed (diff) | |
download | nautilus-de6dc4e973fb98358d7b4fade4072c3b0365e8ce.tar.gz |
Remove depenency on Nautilus themes and thus libnautilus-extensions.
* components/rpmview/Makefile.am:
* components/rpmview/nautilus-rpm-view.c:
(nautilus_rpm_view_initialize),
(nautilus_rpm_view_update_from_uri),
(nautilus_rpm_view_drag_data_received), (pixbuf_new_named),
(image_new_named):
Remove depenency on Nautilus themes and thus libnautilus-extensions.
* components/services/install-view/Makefile.am:
* components/services/install-view/callbacks.c:
(nautilus_service_install_done):
* components/services/install-view/nautilus-service-install-view.c:
(nautilus_service_install_view_initialize_class):
* components/services/inventory-view/Makefile.am:
* components/services/login/nautilus-view/Makefile.am:
* components/services/nautilus-dependent-shared/Makefile.am:
* components/services/nautilus-dependent-shared/eazel-services-extensions.c:
(eazel_services_pixbuf_new), (eazel_services_image_new),
(eazel_services_image_new_clickable),
(eazel_services_image_new_from_uri),
(eazel_services_clickable_image_new_from_uri),
(eazel_services_label_new), (eazel_services_label_new_clickable),
(eazel_services_get_current_date_string),
(eazel_services_gconf_handle_error),
(preferences_unref_global_gconf_client),
(preferences_get_global_gconf_client),
(preferences_gconf_get_boolean), (preferences_gconf_get_string),
(smooth_graphics_changed_notice),
(listen_for_smooth_graphics_changes),
(eazel_services_get_user_level):
* components/services/nautilus-dependent-shared/eazel-services-extensions.h:
* components/services/summary/Makefile.am:
* components/services/summary/nautilus-summary-menu-items.c:
(ui_component_set_hidden), (update_menu_items):
* components/services/summary/nautilus-summary-view.c:
(nautilus_summary_view_initialize_class):
Remove dependency on libnautilus-extensions.
* libnautilus-extensions/Makefile.am:
* libnautilus-extensions/nautilus-tabs.h:
* libnautilus-extensions/nautilus-tabs.c:
* components/services/summary/nautilus-tabs.h:
* components/services/summary/nautilus-tabs.c:
Move the nautilus tabs widget to the only place where its used -
the summary view.
* libnautilus-extensions/nautilus-file-utilities.c:
Trim down the includes to only whats needed.
* libnautilus-extensions/nautilus-file-dnd.h:
* libnautilus-extensions/nautilus-file-dnd.c:
Make the ERASE_KEYWORD be part only of nautilus-file-dnd.h as
NAUTILUS_FILE_DND_ERASE_KEYWORD to make it clear where it lives.
* components/tree/nautilus-tree-view-dnd.c:
(nautilus_tree_view_move_copy_files):
(nautilus_drag_can_accept_items),
(nautilus_drag_file_receive_dropped_keyword):
* libnautilus-extensions/nautilus-icon-dnd.c:
(create_selection_shadow), (handle_local_move),
(handle_nonlocal_move), (selection_includes_special_link):
* src/file-manager/fm-list-view.c: (fm_list_receive_dropped_icons):
Update for eel dnd changes. Make sure all public eel dnd stuff
has the right namespace.
30 files changed, 488 insertions, 1167 deletions
@@ -1,5 +1,72 @@ 2001-04-05 Ramiro Estrugo <ramiro@eazel.com> + * components/rpmview/Makefile.am: + * components/rpmview/nautilus-rpm-view.c: + (nautilus_rpm_view_initialize), + (nautilus_rpm_view_update_from_uri), + (nautilus_rpm_view_drag_data_received), (pixbuf_new_named), + (image_new_named): + Remove depenency on Nautilus themes and thus libnautilus-extensions. + + * components/services/install-view/Makefile.am: + * components/services/install-view/callbacks.c: + (nautilus_service_install_done): + * components/services/install-view/nautilus-service-install-view.c: + (nautilus_service_install_view_initialize_class): + * components/services/inventory-view/Makefile.am: + * components/services/login/nautilus-view/Makefile.am: + * components/services/nautilus-dependent-shared/Makefile.am: + * components/services/nautilus-dependent-shared/eazel-services-extensions.c: + (eazel_services_pixbuf_new), (eazel_services_image_new), + (eazel_services_image_new_clickable), + (eazel_services_image_new_from_uri), + (eazel_services_clickable_image_new_from_uri), + (eazel_services_label_new), (eazel_services_label_new_clickable), + (eazel_services_get_current_date_string), + (eazel_services_gconf_handle_error), + (preferences_unref_global_gconf_client), + (preferences_get_global_gconf_client), + (preferences_gconf_get_boolean), (preferences_gconf_get_string), + (smooth_graphics_changed_notice), + (listen_for_smooth_graphics_changes), + (eazel_services_get_user_level): + * components/services/nautilus-dependent-shared/eazel-services-extensions.h: + * components/services/summary/Makefile.am: + * components/services/summary/nautilus-summary-menu-items.c: + (ui_component_set_hidden), (update_menu_items): + * components/services/summary/nautilus-summary-view.c: + (nautilus_summary_view_initialize_class): + Remove dependency on libnautilus-extensions. + + * libnautilus-extensions/Makefile.am: + * libnautilus-extensions/nautilus-tabs.h: + * libnautilus-extensions/nautilus-tabs.c: + * components/services/summary/nautilus-tabs.h: + * components/services/summary/nautilus-tabs.c: + Move the nautilus tabs widget to the only place where its used - + the summary view. + + * libnautilus-extensions/nautilus-file-utilities.c: + Trim down the includes to only whats needed. + + * libnautilus-extensions/nautilus-file-dnd.h: + * libnautilus-extensions/nautilus-file-dnd.c: + Make the ERASE_KEYWORD be part only of nautilus-file-dnd.h as + NAUTILUS_FILE_DND_ERASE_KEYWORD to make it clear where it lives. + + * components/tree/nautilus-tree-view-dnd.c: + (nautilus_tree_view_move_copy_files): + (nautilus_drag_can_accept_items), + (nautilus_drag_file_receive_dropped_keyword): + * libnautilus-extensions/nautilus-icon-dnd.c: + (create_selection_shadow), (handle_local_move), + (handle_nonlocal_move), (selection_includes_special_link): + * src/file-manager/fm-list-view.c: (fm_list_receive_dropped_icons): + Update for eel dnd changes. Make sure all public eel dnd stuff + has the right namespace. + +2001-04-05 Ramiro Estrugo <ramiro@eazel.com> + * src/nautilus-profiler.c: Add missing eel includes to fix profile build. diff --git a/components/rpmview/Makefile.am b/components/rpmview/Makefile.am index 16c3a4671..14f0f939c 100644 --- a/components/rpmview/Makefile.am +++ b/components/rpmview/Makefile.am @@ -9,6 +9,7 @@ INVENTORY_CFLAGS= endif INCLUDES = \ + -DDATADIR=\""$(datadir)"\" \ -DPREFIX=\"$(prefix)\" \ -DG_LOG_DOMAIN=\"Nautilus-RPM\" \ -I$(top_srcdir) \ @@ -52,7 +53,6 @@ nautilus_rpm_view_SOURCES = \ nautilus_rpm_view_LDADD = \ $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ $(EEL_LIBS) \ $(LIBRSVG_LIBS) \ $(INVENTORY_LIBS) \ diff --git a/components/rpmview/nautilus-rpm-view.c b/components/rpmview/nautilus-rpm-view.c index 30962e222..c5719549d 100644 --- a/components/rpmview/nautilus-rpm-view.c +++ b/components/rpmview/nautilus-rpm-view.c @@ -42,7 +42,6 @@ #include <gtk/gtklabel.h> #include <libgnomevfs/gnome-vfs.h> #include <eel/eel-ctree.h> -#include <libnautilus-extensions/nautilus-theme.h> #include <libnautilus/libnautilus.h> #include <limits.h> #include <stdio.h> @@ -63,24 +62,27 @@ static GtkTargetEntry rpm_dnd_target_table[] = { { "application/x-color", 0, TARGET_COLOR }, }; -static void nautilus_rpm_view_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - GtkSelectionData *selection_data, - guint info, - guint time); -static void nautilus_rpm_view_initialize_class (NautilusRPMViewClass *klass); -static void nautilus_rpm_view_initialize (NautilusRPMView *view); -static void nautilus_rpm_view_destroy (GtkObject *object); -static void rpm_view_load_location_callback (NautilusView *view, - const char *location, - NautilusRPMView *rpm_view); -static void nautilus_rpm_view_verify_package_callback (GtkWidget *widget, - NautilusRPMView *rpm_view); - -static void file_activation_callback (EelCTree *ctree, EelCTreeNode *node, int column, - NautilusRPMView *rpm_view); +static void nautilus_rpm_view_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + int x, + int y, + GtkSelectionData *selection_data, + guint info, + guint time); +static void nautilus_rpm_view_initialize_class (NautilusRPMViewClass *klass); +static void nautilus_rpm_view_initialize (NautilusRPMView *view); +static void nautilus_rpm_view_destroy (GtkObject *object); +static void rpm_view_load_location_callback (NautilusView *view, + const char *location, + NautilusRPMView *rpm_view); +static void nautilus_rpm_view_verify_package_callback (GtkWidget *widget, + NautilusRPMView *rpm_view); +static void file_activation_callback (EelCTree *ctree, + EelCTreeNode *node, + int column, + NautilusRPMView *rpm_view); +static GdkPixbuf *pixbuf_new_named (const char *name); +static GtkWidget *image_new_named (const char *name); EEL_DEFINE_CLASS_BOILERPLATE (NautilusRPMView, nautilus_rpm_view, GTK_TYPE_EVENT_BOX) @@ -106,7 +108,6 @@ nautilus_rpm_view_initialize (NautilusRPMView *rpm_view) GtkWidget *temp_box, *temp_widget; GtkWidget *icon_title_box, *title_box; GtkTable *table; - char *default_icon_path; GtkWidget *viewport; static gchar *list_headers[] = { N_("Package Contents") }; @@ -144,9 +145,7 @@ nautilus_rpm_view_initialize (NautilusRPMView *rpm_view) gtk_box_pack_start (GTK_BOX (rpm_view->details->package_container), icon_title_box, FALSE, FALSE, 0); /* allocate a nautilus_image to hold the icon */ - default_icon_path = nautilus_theme_get_image_path ("gnome-pack-rpm.png"); - rpm_view->details->package_image = eel_image_new (default_icon_path); - g_free (default_icon_path); + rpm_view->details->package_image = image_new_named ("gnome-pack-rpm.png"); gtk_widget_show (rpm_view->details->package_image); gtk_box_pack_start (GTK_BOX (icon_title_box), rpm_view->details->package_image, FALSE, FALSE, 8); @@ -527,14 +526,18 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) { char *temp_str; gboolean is_installed; - char *path_name, *default_icon_path; - + char *path_name; + GdkPixbuf *pixbuf; + path_name = gnome_vfs_get_local_path_from_uri (uri); /* load the standard icon as the default */ - default_icon_path = nautilus_theme_get_image_path ("gnome-pack-rpm.png"); - eel_image_set_pixbuf_from_file_name (EEL_IMAGE (rpm_view->details->package_image), default_icon_path); - g_free (default_icon_path); + pixbuf = pixbuf_new_named ("gnome-pack-rpm.png"); + + if (pixbuf != NULL) { + eel_image_set_pixbuf (EEL_IMAGE (rpm_view->details->package_image), pixbuf); + gdk_pixbuf_unref (pixbuf); + } #ifdef EAZEL_SERVICES rpm_view->details->package = eazel_package_system_load_package (rpm_view->details->package_system, @@ -787,3 +790,39 @@ nautilus_rpm_view_drag_data_received (GtkWidget *widget, GdkDragContext *context break; } } + +static GdkPixbuf * +pixbuf_new_named (const char *name) +{ + char *image_file_path; + GdkPixbuf *pixbuf = NULL; + + image_file_path = g_strdup_printf ("%s/%s", DATADIR "/pixmaps/nautilus", name); + + if (g_file_exists (image_file_path)) { + pixbuf =gdk_pixbuf_new_from_file (image_file_path); + } + g_free (image_file_path); + + return pixbuf; +} + +static GtkWidget * +image_new_named (const char *name) +{ + GtkWidget *image; + GdkPixbuf *pixbuf; + + g_return_val_if_fail (name != NULL, NULL); + + image = eel_image_new (NULL); + + pixbuf = pixbuf_new_named (name); + + if (pixbuf != NULL) { + eel_image_set_pixbuf (EEL_IMAGE (image), pixbuf); + gdk_pixbuf_unref (pixbuf); + } + + return image; +} diff --git a/components/services/install-view/Makefile.am b/components/services/install-view/Makefile.am index b1e79a023..021cc6cfe 100644 --- a/components/services/install-view/Makefile.am +++ b/components/services/install-view/Makefile.am @@ -39,7 +39,6 @@ nautilus_service_install_view_SOURCES = \ $(NULL) nautilus_service_install_view_LDADD = \ - $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ $(top_builddir)/libnautilus/libnautilus.la \ $(top_builddir)/components/services/install/lib/libeazelinstall.la \ $(top_builddir)/components/services/install/lib/libeazelpackagesystem.la \ diff --git a/components/services/install-view/callbacks.c b/components/services/install-view/callbacks.c index 9c7760e06..3810269d9 100644 --- a/components/services/install-view/callbacks.c +++ b/components/services/install-view/callbacks.c @@ -25,6 +25,7 @@ #include <config.h> #include "nautilus-service-install-view.h" +#include "eazel-services-extensions.h" #include "forms.h" #include "callbacks.h" #include "eazel-install-metadata.h" /* eazel_install_configure_check_jump_after_install */ @@ -34,7 +35,6 @@ #include <errno.h> #include <libeazelinstall.h> #include <eel/eel-label.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> #define MAX_DESCRIBE_MENUS 3 @@ -617,7 +617,7 @@ nautilus_service_install_done (EazelInstallCallback *cb, gboolean success, Nauti } if (view->details->cancelled_before_downloads || view->details->already_installed || - (nautilus_preferences_get_user_level () < NAUTILUS_USER_LEVEL_ADVANCED)) { + (eazel_services_get_user_level () < EAZEL_USER_LEVEL_ADVANCED)) { /* don't ask about erasing rpms */ question_dialog = FALSE; answer = TRUE; diff --git a/components/services/install-view/nautilus-service-install-view.c b/components/services/install-view/nautilus-service-install-view.c index 012577baf..615b88a6b 100644 --- a/components/services/install-view/nautilus-service-install-view.c +++ b/components/services/install-view/nautilus-service-install-view.c @@ -46,7 +46,6 @@ #include <eel/eel-password-dialog.h> #include <eel/eel-stock-dialogs.h> #include <eel/eel-viewport.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> #include <eel/eel-clickable-image.h> #include <stdio.h> #include <fcntl.h> @@ -139,8 +138,6 @@ nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass parent_class = gtk_type_class (gtk_event_box_get_type ()); object_class->destroy = nautilus_service_install_view_destroy; object_class->finalize = nautilus_service_install_view_finalize; - - nautilus_global_preferences_initialize (); } static void diff --git a/components/services/inventory-view/Makefile.am b/components/services/inventory-view/Makefile.am index fe29d50e2..1b305f671 100644 --- a/components/services/inventory-view/Makefile.am +++ b/components/services/inventory-view/Makefile.am @@ -36,7 +36,6 @@ nautilus_inventory_view_SOURCES = \ main.c nautilus_inventory_view_LDADD = \ - $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ $(top_builddir)/libnautilus/libnautilus.la \ $(top_builddir)/components/services/inventory/libtrilobite-inventory-service.la \ $(top_builddir)/components/services/nautilus-dependent-shared/libnautilusdepshared.a \ diff --git a/components/services/login/nautilus-view/Makefile.am b/components/services/login/nautilus-view/Makefile.am index da6575954..1b0390592 100644 --- a/components/services/login/nautilus-view/Makefile.am +++ b/components/services/login/nautilus-view/Makefile.am @@ -32,7 +32,6 @@ nautilus_change_password_view_SOURCES = \ $(NULL) nautilus_change_password_view_LDADD = \ - $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ $(top_builddir)/components/services/nautilus-dependent-shared/libnautilusdepshared.a \ $(top_builddir)/libnautilus/libnautilus.la \ diff --git a/components/services/nautilus-dependent-shared/Makefile.am b/components/services/nautilus-dependent-shared/Makefile.am index 1f0cbe6e3..4b8bc415e 100644 --- a/components/services/nautilus-dependent-shared/Makefile.am +++ b/components/services/nautilus-dependent-shared/Makefile.am @@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.shared SUBDIRS = icons INCLUDES = \ + -DDATADIR=\""$(datadir)"\" \ -DPREFIX=\"$(prefix)\" \ -DG_LOG_DOMAIN=\"eazel-service\" \ -I$(top_srcdir) \ @@ -35,7 +36,6 @@ libnautilusdepshared_a_SOURCES =\ test_footer_header_LDADD = \ $(top_builddir)/components/services/nautilus-dependent-shared/libnautilusdepshared.a \ - $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ $(top_builddir)/libnautilus/libnautilus.la \ $(EEL_LIBS) \ $(LIBRSVG_LIBS) \ diff --git a/components/services/nautilus-dependent-shared/eazel-services-extensions.c b/components/services/nautilus-dependent-shared/eazel-services-extensions.c index 938212a70..c7c0a74cc 100644 --- a/components/services/nautilus-dependent-shared/eazel-services-extensions.c +++ b/components/services/nautilus-dependent-shared/eazel-services-extensions.c @@ -23,32 +23,35 @@ */ #include <config.h> - #include "eazel-services-extensions.h" +#include <eel/eel-clickable-image.h> +#include <eel/eel-smooth-widget.h> +#include <eel/eel-stock-dialogs.h> +#include <eel/eel-string.h> +#include <gconf/gconf-client.h> +#include <gconf/gconf.h> #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> - -#include <libnautilus-extensions/nautilus-theme.h> -#include <eel/eel-string.h> -#include <eel/eel-clickable-image.h> - +#include <libgnome/gnome-util.h> #include <time.h> +static void listen_for_smooth_graphics_changes (void); + GdkPixbuf * eazel_services_pixbuf_new (const char *name) { - char *path; - GdkPixbuf *pixbuf; + char *image_file_path; + GdkPixbuf *pixbuf = NULL; - g_return_val_if_fail (name != NULL, NULL); - - path = nautilus_theme_get_image_path (name); + g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (path != NULL, NULL); + image_file_path = g_strdup_printf ("%s/%s", DATADIR "/pixmaps/nautilus", name); - pixbuf = gdk_pixbuf_new_from_file (path); - g_free (path); + if (g_file_exists (image_file_path)) { + pixbuf =gdk_pixbuf_new_from_file (image_file_path); + } + g_free (image_file_path); return pixbuf; } @@ -62,6 +65,8 @@ eazel_services_image_new (const char *icon_name, GdkPixbuf *pixbuf = NULL; GdkPixbuf *tile_pixbuf = NULL; + listen_for_smooth_graphics_changes (); + if (icon_name) { pixbuf = eazel_services_pixbuf_new (icon_name); } @@ -87,6 +92,8 @@ eazel_services_image_new_clickable (const char *icon_name, GdkPixbuf *pixbuf = NULL; GdkPixbuf *tile_pixbuf = NULL; + listen_for_smooth_graphics_changes (); + if (icon_name) { pixbuf = eazel_services_pixbuf_new (icon_name); } @@ -126,6 +133,8 @@ eazel_services_image_new_from_uri (const char *uri, g_return_val_if_fail (uri != NULL, NULL); + listen_for_smooth_graphics_changes (); + /* load the image - synchronously, at least at first */ pixbuf = eel_gdk_pixbuf_load (uri); @@ -163,6 +172,8 @@ eazel_services_clickable_image_new_from_uri (const char *uri, g_return_val_if_fail (uri != NULL, NULL); + listen_for_smooth_graphics_changes (); + /* load the image - synchronously, at least at first */ pixbuf = eel_gdk_pixbuf_load (uri); @@ -186,9 +197,6 @@ eazel_services_clickable_image_new_from_uri (const char *uri, return image; } - - - GtkWidget * eazel_services_label_new (const char *text, guint drop_shadow_offset, @@ -205,6 +213,8 @@ eazel_services_label_new (const char *text, GtkWidget *label; GdkPixbuf *tile_pixbuf = NULL; + listen_for_smooth_graphics_changes (); + if (tile_name != NULL) { tile_pixbuf = eazel_services_pixbuf_new (tile_name); } @@ -252,6 +262,8 @@ eazel_services_label_new_clickable (const char *text, GtkWidget *label; GdkPixbuf *tile_pixbuf = NULL; + listen_for_smooth_graphics_changes (); + if (tile_name != NULL) { tile_pixbuf = eazel_services_pixbuf_new (tile_name); } @@ -299,3 +311,206 @@ eazel_services_get_current_date_string (void) return eel_strdup_strftime (_("%A, %B %d"), my_localtime); } + +/* FIXME: It is obviously beyond words to describe how dauntingly lame + * this cut and pasted code here is. + * See also the USER_LEVEL macros in eazel-services-extensions.h + */ +#define SMOOTH_GRAPHICS_KEY "/apps/nautilus/preferences/smooth_graphics_mode" +#define USER_LEVEL_KEY "/apps/nautilus/user_level" + +/* Code cut-n-pasted from nautilus-gconf-extensions.c */ +static gboolean +eazel_services_gconf_handle_error (GError **error) +{ + char *message; + static gboolean shown_dialog = FALSE; + + g_return_val_if_fail (error != NULL, FALSE); + + if (*error != NULL) { + g_warning (_("GConf error:\n %s"), (*error)->message); + if (! shown_dialog) { + shown_dialog = TRUE; + + message = g_strdup_printf (_("GConf error:\n %s\n" + "All further errors shown " + "only on terminal"), + (*error)->message); + eel_show_error_dialog (message, _("GConf Error"), NULL); + g_free (message); + } + g_error_free (*error); + *error = NULL; + + return TRUE; + } + + return FALSE; +} + +static GConfClient *global_gconf_client = NULL; + +static void +preferences_unref_global_gconf_client (void) +{ + if (global_gconf_client == NULL) { + gtk_object_unref (GTK_OBJECT (global_gconf_client)); + } + + global_gconf_client = NULL; +} + +static GConfClient * +preferences_get_global_gconf_client (void) +{ + /* Initialize gconf if needed */ + if (!gconf_is_initialized ()) { + GError *error = NULL; + char *argv[] = { "eazel-services", NULL }; + + if (!gconf_init (1, argv, &error)) { + + if (eazel_services_gconf_handle_error (&error)) { + return NULL; + } + } + } + + if (global_gconf_client == NULL) { + global_gconf_client = gconf_client_get_default (); + + if (global_gconf_client == NULL) { + return NULL; + } + + g_atexit (preferences_unref_global_gconf_client); + + gconf_client_add_dir (global_gconf_client, + "/apps/nautilus", + GCONF_CLIENT_PRELOAD_NONE, + NULL); + } + + return global_gconf_client; +} + +static gboolean +preferences_gconf_get_boolean (const char *key) +{ + gboolean result; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, FALSE); + + client = preferences_get_global_gconf_client (); + g_return_val_if_fail (client != NULL, FALSE); + + result = gconf_client_get_bool (client, key, &error); + + if (eazel_services_gconf_handle_error (&error)) { + result = FALSE; + } + + return result; +} + +static char * +preferences_gconf_get_string (const char *key) +{ + char *result; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, NULL); + + client = preferences_get_global_gconf_client (); + g_return_val_if_fail (client != NULL, NULL); + + result = gconf_client_get_string (client, key, &error); + + if (eazel_services_gconf_handle_error (&error)) { + result = g_strdup (""); + } + + return result; +} + +static void +smooth_graphics_changed_notice (GConfClient *client, + guint connection_id, + GConfEntry *entry, + gpointer notice_data) +{ + g_return_if_fail (entry != NULL); + g_return_if_fail (entry->key != NULL); + + eel_smooth_widget_global_set_is_smooth (preferences_gconf_get_boolean (SMOOTH_GRAPHICS_KEY)); +} + +static void +listen_for_smooth_graphics_changes (void) +{ + static gboolean notification_installed = FALSE; + GConfClient *client; + GError *error; + + if (notification_installed) { + return; + } + + if (!gconf_is_initialized ()) { + char *argv[] = { "eazel-services", NULL }; + error = NULL; + + if (!gconf_init (1, argv, &error)) { + if (eazel_services_gconf_handle_error (&error)) { + return; + } + } + } + + client = preferences_get_global_gconf_client (); + g_return_if_fail (client != NULL); + + gconf_client_notify_add (client, + SMOOTH_GRAPHICS_KEY, + smooth_graphics_changed_notice, + NULL, + NULL, + &error); + + if (eazel_services_gconf_handle_error (&error)) { + return; + } + + notification_installed = TRUE; + + eel_smooth_widget_global_set_is_smooth (preferences_gconf_get_boolean (SMOOTH_GRAPHICS_KEY)); +} + +#define DEFAULT_USER_LEVEL EAZEL_USER_LEVEL_INTERMEDIATE + +int +eazel_services_get_user_level (void) +{ + char *user_level; + int result; + + user_level = preferences_gconf_get_string (USER_LEVEL_KEY); + + if (eel_str_is_equal (user_level, "advanced")) { + result = EAZEL_USER_LEVEL_ADVANCED; + } else if (eel_str_is_equal (user_level, "intermediate")) { + result = EAZEL_USER_LEVEL_INTERMEDIATE; + } else if (eel_str_is_equal (user_level, "novice")) { + result = EAZEL_USER_LEVEL_NOVICE; + } else { + result = DEFAULT_USER_LEVEL; + } + + g_free (user_level); + + return result; +} diff --git a/components/services/nautilus-dependent-shared/eazel-services-extensions.h b/components/services/nautilus-dependent-shared/eazel-services-extensions.h index 962d536ea..945511eab 100644 --- a/components/services/nautilus-dependent-shared/eazel-services-extensions.h +++ b/components/services/nautilus-dependent-shared/eazel-services-extensions.h @@ -56,6 +56,10 @@ #define EAZEL_SERVICES_HEADER_TEXT_SIZE_REL 4 +#define EAZEL_USER_LEVEL_NOVICE 0 +#define EAZEL_USER_LEVEL_INTERMEDIATE 1 +#define EAZEL_USER_LEVEL_ADVANCED 2 + /* * The xalign, yalign, xpadding, and ypadding attribures work * exactly as they do with GtkMisc. @@ -63,46 +67,47 @@ BEGIN_GNOME_DECLS -GdkPixbuf *eazel_services_pixbuf_new (const char *name); -GtkWidget *eazel_services_image_new (const char *icon_name, - const char *tile_name, - guint32 background_color); -GtkWidget *eazel_services_image_new_clickable (const char *icon_name, - const char *tile_name, - guint32 background_color); -GtkWidget *eazel_services_image_new_from_uri (const char *uri, - const char *tile_name, - guint32 background_color, - int max_width, - int max_height); +GdkPixbuf *eazel_services_pixbuf_new (const char *name); +GtkWidget *eazel_services_image_new (const char *icon_name, + const char *tile_name, + guint32 background_color); +GtkWidget *eazel_services_image_new_clickable (const char *icon_name, + const char *tile_name, + guint32 background_color); +GtkWidget *eazel_services_image_new_from_uri (const char *uri, + const char *tile_name, + guint32 background_color, + int max_width, + int max_height); GtkWidget *eazel_services_clickable_image_new_from_uri (const char *uri, const char *tile_name, guint32 background_color, int max_width, int max_height); -GtkWidget *eazel_services_label_new (const char *text, - guint drop_shadow_offset, - float xalign, - float yalign, - gint xpadding, - gint ypadding, - guint32 text_color, - guint32 background_color, - const char *tile_name, - gint num_larger_sizes, - gboolean bold); -GtkWidget *eazel_services_label_new_clickable (const char *text, - guint drop_shadow_offset, - float xalign, - float yalign, - gint xpadding, - gint ypadding, - guint32 text_color, - guint32 background_color, - const char *tile_name, - gint num_larger_sizes, - gboolean bold); -char * eazel_services_get_current_date_string (void); +GtkWidget *eazel_services_label_new (const char *text, + guint drop_shadow_offset, + float xalign, + float yalign, + gint xpadding, + gint ypadding, + guint32 text_color, + guint32 background_color, + const char *tile_name, + gint num_larger_sizes, + gboolean bold); +GtkWidget *eazel_services_label_new_clickable (const char *text, + guint drop_shadow_offset, + float xalign, + float yalign, + gint xpadding, + gint ypadding, + guint32 text_color, + guint32 background_color, + const char *tile_name, + gint num_larger_sizes, + gboolean bold); +char *eazel_services_get_current_date_string (void); +int eazel_services_get_user_level (void); END_GNOME_DECLS diff --git a/components/services/summary/Makefile.am b/components/services/summary/Makefile.am index 5a3b7cc80..8c81e3d33 100644 --- a/components/services/summary/Makefile.am +++ b/components/services/summary/Makefile.am @@ -46,10 +46,11 @@ nautilus_summary_view_SOURCES = \ nautilus-summary-view-private.h \ nautilus-summary-view.c \ nautilus-summary-view.h \ + nautilus-tabs.c \ + nautilus-tabs.h \ $(NULL) nautilus_summary_view_LDADD = \ - $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ $(top_builddir)/components/services/nautilus-dependent-shared/libnautilusdepshared.a \ $(INVENTORY_LIBS) \ diff --git a/components/services/summary/nautilus-summary-menu-items.c b/components/services/summary/nautilus-summary-menu-items.c index f93778db6..1be544926 100644 --- a/components/services/summary/nautilus-summary-menu-items.c +++ b/components/services/summary/nautilus-summary-menu-items.c @@ -44,7 +44,6 @@ #include <gnome-xml/tree.h> #include <libgnomeui/gnome-stock.h> #include <libgnomevfs/gnome-vfs-utils.h> -#include <libnautilus-extensions/nautilus-bonobo-extensions.h> #include <liboaf/liboaf.h> #include <libtrilobite/eazelproxy.h> #include <libtrilobite/libammonite.h> @@ -68,6 +67,18 @@ static void bonobo_preferences_callback (BonoboUIComponent *ui, gpointer user_data, const char *verb); +/* A tiny bit of code cut-n-pasted from nautilus-bonobo-extensions.h */ +static void +ui_component_set_hidden (BonoboUIComponent *ui, + const char *path, + gboolean hidden) +{ + g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); + bonobo_ui_component_set_prop (ui, path, + "hidden", + hidden ? "1" : "0", + NULL); +} /* update the visibility of the menu items according to the login state */ void @@ -79,21 +90,21 @@ update_menu_items (NautilusSummaryView *view, gboolean logged_in) (nautilus_view_get_bonobo_control (view->details->nautilus_view)); - nautilus_bonobo_set_hidden (ui, - "/commands/Register", - logged_in); + ui_component_set_hidden (ui, + "/commands/Register", + logged_in); - nautilus_bonobo_set_hidden (ui, - "/commands/Login", - logged_in); + ui_component_set_hidden (ui, + "/commands/Login", + logged_in); - nautilus_bonobo_set_hidden (ui, - "/commands/Preferences", - !logged_in); + ui_component_set_hidden (ui, + "/commands/Preferences", + !logged_in); - nautilus_bonobo_set_hidden (ui, - "/commands/Logout", - !logged_in); + ui_component_set_hidden (ui, + "/commands/Logout", + !logged_in); } /* this routine is invoked when the view is activated to merge in our menu items */ diff --git a/components/services/summary/nautilus-summary-view.c b/components/services/summary/nautilus-summary-view.c index 3fd689a50..4c5314875 100644 --- a/components/services/summary/nautilus-summary-view.c +++ b/components/services/summary/nautilus-summary-view.c @@ -33,6 +33,7 @@ #include "nautilus-summary-footer.h" #include "nautilus-summary-menu-items.h" #include "nautilus-summary-view-private.h" +#include "nautilus-tabs.h" #include <bonobo/bonobo-control.h> #include <eel/eel-background.h> #include <eel/eel-clickable-image.h> @@ -48,8 +49,6 @@ #include <gnome.h> #include <gtk/gtkalignment.h> #include <libgnomeui/gnome-stock.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> -#include <libnautilus-extensions/nautilus-tabs.h> #include <liboaf/liboaf.h> #include <libtrilobite/eazelproxy.h> #include <libtrilobite/libammonite.h> @@ -775,8 +774,6 @@ nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass) widget_class = GTK_WIDGET_CLASS (klass); parent_class = gtk_type_class (gtk_event_box_get_type ()); object_class->destroy = nautilus_summary_view_destroy; - - nautilus_global_preferences_initialize (); } static void diff --git a/libnautilus-extensions/nautilus-tabs.c b/components/services/summary/nautilus-tabs.c index e708e4c0d..71e142291 100644 --- a/libnautilus-extensions/nautilus-tabs.c +++ b/components/services/summary/nautilus-tabs.c @@ -37,7 +37,6 @@ #include <eel/eel-gtk-extensions.h> #include <eel/eel-gtk-macros.h> #include <eel/eel-scalable-font.h> -#include <libnautilus-extensions/nautilus-theme.h> #include <math.h> #include <stdio.h> #include <string.h> @@ -102,30 +101,34 @@ static guint signals[LAST_SIGNAL]; /* headers */ -static void nautilus_tabs_initialize_class (NautilusTabsClass *klass); -static void nautilus_tabs_initialize (NautilusTabs *pixmap); -static void nautilus_tabs_draw (GtkWidget *widget, GdkRectangle *box); - -static int nautilus_tabs_expose (GtkWidget *widget, - GdkEventExpose *event); -static void nautilus_tabs_destroy (GtkObject *object); -static void nautilus_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition); - -static int nautilus_tabs_hit_test (NautilusTabs *tabs, int x, int y); - -static void nautilus_tabs_load_tab_pieces (NautilusTabs *tabs, const char *tab_piece_directory); -static gboolean nautilus_tabs_motion_event (GtkWidget *tabs, - GdkEventMotion *event); -static gboolean nautilus_tabs_press_event (GtkWidget *widget, - GdkEventButton *event); -static gboolean nautilus_tabs_leave_event (GtkWidget *tabs_widget, GdkEventCrossing *event); -static void nautilus_tabs_prelight_tab (NautilusTabs *tabs, int which_tab); -static void nautilus_tabs_select_tab (NautilusTabs *tabs, int which_tab); -static void nautilus_tabs_unload_tab_pieces (NautilusTabs *tabs); - -static void draw_all_tabs (NautilusTabs *tabs); -static TabItem* tab_item_find_by_name (NautilusTabs *tabs, - const char *name); +static void nautilus_tabs_initialize_class (NautilusTabsClass *klass); +static void nautilus_tabs_initialize (NautilusTabs *pixmap); +static void nautilus_tabs_draw (GtkWidget *widget, + GdkRectangle *box); +static int nautilus_tabs_expose (GtkWidget *widget, + GdkEventExpose *event); +static void nautilus_tabs_destroy (GtkObject *object); +static void nautilus_tabs_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static int nautilus_tabs_hit_test (NautilusTabs *tabs, + int x, + int y); +static void nautilus_tabs_load_tab_pieces (NautilusTabs *tabs, + const char *tab_piece_directory); +static gboolean nautilus_tabs_motion_event (GtkWidget *tabs, + GdkEventMotion *event); +static gboolean nautilus_tabs_press_event (GtkWidget *widget, + GdkEventButton *event); +static gboolean nautilus_tabs_leave_event (GtkWidget *tabs_widget, + GdkEventCrossing *event); +static void nautilus_tabs_prelight_tab (NautilusTabs *tabs, + int which_tab); +static void nautilus_tabs_select_tab (NautilusTabs *tabs, + int which_tab); +static void nautilus_tabs_unload_tab_pieces (NautilusTabs *tabs); +static void draw_all_tabs (NautilusTabs *tabs); +static TabItem* tab_item_find_by_name (NautilusTabs *tabs, + const char *name); EEL_DEFINE_CLASS_BOILERPLATE (NautilusTabs, nautilus_tabs, GTK_TYPE_DRAWING_AREA) @@ -183,7 +186,7 @@ nautilus_tabs_initialize (NautilusTabs *tabs) tabs->details->tab_font = eel_scalable_font_get_default_bold_font (); tabs->details->font_size = 14; - gray_tab_directory_path = nautilus_theme_get_image_path ("gray_tab_pieces"); + gray_tab_directory_path = g_strdup (DATADIR "/pixmaps/nautilus/gray_tab_pieces"); nautilus_tabs_load_tab_pieces (tabs, gray_tab_directory_path); g_free (gray_tab_directory_path); diff --git a/libnautilus-extensions/nautilus-tabs.h b/components/services/summary/nautilus-tabs.h index 144f5d730..144f5d730 100644 --- a/libnautilus-extensions/nautilus-tabs.h +++ b/components/services/summary/nautilus-tabs.h diff --git a/components/tree/nautilus-tree-view-dnd.c b/components/tree/nautilus-tree-view-dnd.c index 4450503a1..43cbde190 100644 --- a/components/tree/nautilus-tree-view-dnd.c +++ b/components/tree/nautilus-tree-view-dnd.c @@ -872,7 +872,7 @@ nautilus_tree_view_move_copy_files (NautilusTreeView *tree_view, source_uris = NULL; for (p = selection_list; p != NULL; p = p->next) { /* do a shallow copy of all the uri strings of the copied files */ - source_uris = g_list_prepend (source_uris, ((DragSelectionItem *)p->data)->uri); + source_uris = g_list_prepend (source_uris, ((EelDragSelectionItem *)p->data)->uri); } source_uris = g_list_reverse (source_uris); diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am index aec8b8514..c0094f54d 100644 --- a/libnautilus-extensions/Makefile.am +++ b/libnautilus-extensions/Makefile.am @@ -114,7 +114,6 @@ libnautilus_extensions_la_SOURCES = \ nautilus-search-uri.c \ nautilus-sidebar-functions.c \ nautilus-sound.c \ - nautilus-tabs.c \ nautilus-theme.c \ nautilus-thumbnails.c \ nautilus-trash-directory.c \ @@ -191,7 +190,6 @@ noinst_HEADERS = \ nautilus-search-uri.h \ nautilus-sidebar-functions.h \ nautilus-sound.h \ - nautilus-tabs.h \ nautilus-theme.h \ nautilus-thumbnails.h \ nautilus-trash-directory.h \ diff --git a/libnautilus-extensions/nautilus-file-dnd.c b/libnautilus-extensions/nautilus-file-dnd.c index fe559b2d1..b7c12af26 100644 --- a/libnautilus-extensions/nautilus-file-dnd.c +++ b/libnautilus-extensions/nautilus-file-dnd.c @@ -73,7 +73,7 @@ nautilus_drag_can_accept_items (NautilusFile *drop_target_item, */ for (max = 100; items != NULL && max >= 0; items = items->next, max--) { if (!nautilus_drag_can_accept_item (drop_target_item, - ((DragSelectionItem *)items->data)->uri)) { + ((EelDragSelectionItem *)items->data)->uri)) { return FALSE; } } @@ -90,7 +90,7 @@ nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, char *keyword) g_return_if_fail (keyword != NULL); /* special case the erase emblem */ - if (strcmp (keyword, ERASE_KEYWORD) == 0) { + if (strcmp (keyword, NAUTILUS_FILE_DND_ERASE_KEYWORD) == 0) { keywords = NULL; } else { keywords = nautilus_file_get_keywords (file); diff --git a/libnautilus-extensions/nautilus-file-dnd.h b/libnautilus-extensions/nautilus-file-dnd.h index 484d5f643..7ae75fd93 100644 --- a/libnautilus-extensions/nautilus-file-dnd.h +++ b/libnautilus-extensions/nautilus-file-dnd.h @@ -28,6 +28,8 @@ #include <eel/eel-dnd.h> #include <libnautilus-extensions/nautilus-file.h> +#define NAUTILUS_FILE_DND_ERASE_KEYWORD "erase" + gboolean nautilus_drag_can_accept_item (NautilusFile *drop_target_item, const char *item_uri); gboolean nautilus_drag_can_accept_items (NautilusFile *drop_target_item, diff --git a/libnautilus-extensions/nautilus-file-utilities.c b/libnautilus-extensions/nautilus-file-utilities.c index e63df3514..d015879cd 100644 --- a/libnautilus-extensions/nautilus-file-utilities.c +++ b/libnautilus-extensions/nautilus-file-utilities.c @@ -25,28 +25,16 @@ #include <config.h> #include "nautilus-file-utilities.h" -#include "nautilus-file.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-link-set.h" #include "nautilus-metadata.h" #include "nautilus-metafile.h" -#include <ctype.h> #include <eel/eel-glib-extensions.h> #include <eel/eel-string.h> -#include <libgnome/gnome-defs.h> #include <libgnome/gnome-util.h> -#include <libgnomevfs/gnome-vfs-async-ops.h> -#include <libgnomevfs/gnome-vfs-find-directory.h> #include <libgnomevfs/gnome-vfs-ops.h> #include <libgnomevfs/gnome-vfs-uri.h> #include <libgnomevfs/gnome-vfs-utils.h> -#include <libgnomevfs/gnome-vfs-xfer.h> -#include <pthread.h> -#include <pwd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> -#include <unistd.h> #define NAUTILUS_USER_DIRECTORY_NAME ".nautilus" #define DEFAULT_NAUTILUS_DIRECTORY_MODE (0755) diff --git a/libnautilus-extensions/nautilus-icon-dnd.c b/libnautilus-extensions/nautilus-icon-dnd.c index 6fcb48ad0..4d5364ea3 100644 --- a/libnautilus-extensions/nautilus-icon-dnd.c +++ b/libnautilus-extensions/nautilus-icon-dnd.c @@ -153,7 +153,7 @@ create_selection_shadow (NautilusIconContainer *container, NULL)); for (p = list; p != NULL; p = p->next) { - DragSelectionItem *item; + EelDragSelectionItem *item; int x1, y1, x2, y2; item = p->data; @@ -784,7 +784,7 @@ handle_local_move (NautilusIconContainer *container, double world_x, double world_y) { GList *moved_icons, *p; - DragSelectionItem *item; + EelDragSelectionItem *item; NautilusIcon *icon; if (container->details->auto_layout) { @@ -836,7 +836,7 @@ handle_nonlocal_move (NautilusIconContainer *container, source_uris = NULL; for (p = container->details->dnd_info->drag_info.selection_list; p != NULL; p = p->next) { /* do a shallow copy of all the uri strings of the copied files */ - source_uris = g_list_prepend (source_uris, ((DragSelectionItem *)p->data)->uri); + source_uris = g_list_prepend (source_uris, ((EelDragSelectionItem *)p->data)->uri); } source_uris = g_list_reverse (source_uris); @@ -851,9 +851,9 @@ handle_nonlocal_move (NautilusIconContainer *container, for (index = 0, p = container->details->dnd_info->drag_info.selection_list; p != NULL; index++, p = p->next) { g_array_index (source_item_locations, GdkPoint, index).x = - ((DragSelectionItem *)p->data)->icon_x; + ((EelDragSelectionItem *)p->data)->icon_x; g_array_index (source_item_locations, GdkPoint, index).y = - ((DragSelectionItem *)p->data)->icon_y; + ((EelDragSelectionItem *)p->data)->icon_y; } } @@ -934,7 +934,7 @@ selection_includes_special_link (GList *selection_list) link_in_selection = FALSE; for (node = selection_list; node != NULL; node = node->next) { - uri = ((DragSelectionItem *) node->data)->uri; + uri = ((EelDragSelectionItem *) node->data)->uri; /* FIXME bugzilla.eazel.com 3020: This does sync. I/O and works only locally. */ local_path = gnome_vfs_get_local_path_from_uri (uri); diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index aec8b8514..c0094f54d 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -114,7 +114,6 @@ libnautilus_extensions_la_SOURCES = \ nautilus-search-uri.c \ nautilus-sidebar-functions.c \ nautilus-sound.c \ - nautilus-tabs.c \ nautilus-theme.c \ nautilus-thumbnails.c \ nautilus-trash-directory.c \ @@ -191,7 +190,6 @@ noinst_HEADERS = \ nautilus-search-uri.h \ nautilus-sidebar-functions.h \ nautilus-sound.h \ - nautilus-tabs.h \ nautilus-theme.h \ nautilus-thumbnails.h \ nautilus-trash-directory.h \ diff --git a/libnautilus-private/nautilus-file-dnd.c b/libnautilus-private/nautilus-file-dnd.c index fe559b2d1..b7c12af26 100644 --- a/libnautilus-private/nautilus-file-dnd.c +++ b/libnautilus-private/nautilus-file-dnd.c @@ -73,7 +73,7 @@ nautilus_drag_can_accept_items (NautilusFile *drop_target_item, */ for (max = 100; items != NULL && max >= 0; items = items->next, max--) { if (!nautilus_drag_can_accept_item (drop_target_item, - ((DragSelectionItem *)items->data)->uri)) { + ((EelDragSelectionItem *)items->data)->uri)) { return FALSE; } } @@ -90,7 +90,7 @@ nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, char *keyword) g_return_if_fail (keyword != NULL); /* special case the erase emblem */ - if (strcmp (keyword, ERASE_KEYWORD) == 0) { + if (strcmp (keyword, NAUTILUS_FILE_DND_ERASE_KEYWORD) == 0) { keywords = NULL; } else { keywords = nautilus_file_get_keywords (file); diff --git a/libnautilus-private/nautilus-file-dnd.h b/libnautilus-private/nautilus-file-dnd.h index 484d5f643..7ae75fd93 100644 --- a/libnautilus-private/nautilus-file-dnd.h +++ b/libnautilus-private/nautilus-file-dnd.h @@ -28,6 +28,8 @@ #include <eel/eel-dnd.h> #include <libnautilus-extensions/nautilus-file.h> +#define NAUTILUS_FILE_DND_ERASE_KEYWORD "erase" + gboolean nautilus_drag_can_accept_item (NautilusFile *drop_target_item, const char *item_uri); gboolean nautilus_drag_can_accept_items (NautilusFile *drop_target_item, diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c index e63df3514..d015879cd 100644 --- a/libnautilus-private/nautilus-file-utilities.c +++ b/libnautilus-private/nautilus-file-utilities.c @@ -25,28 +25,16 @@ #include <config.h> #include "nautilus-file-utilities.h" -#include "nautilus-file.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-link-set.h" #include "nautilus-metadata.h" #include "nautilus-metafile.h" -#include <ctype.h> #include <eel/eel-glib-extensions.h> #include <eel/eel-string.h> -#include <libgnome/gnome-defs.h> #include <libgnome/gnome-util.h> -#include <libgnomevfs/gnome-vfs-async-ops.h> -#include <libgnomevfs/gnome-vfs-find-directory.h> #include <libgnomevfs/gnome-vfs-ops.h> #include <libgnomevfs/gnome-vfs-uri.h> #include <libgnomevfs/gnome-vfs-utils.h> -#include <libgnomevfs/gnome-vfs-xfer.h> -#include <pthread.h> -#include <pwd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> -#include <unistd.h> #define NAUTILUS_USER_DIRECTORY_NAME ".nautilus" #define DEFAULT_NAUTILUS_DIRECTORY_MODE (0755) diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c index 6fcb48ad0..4d5364ea3 100644 --- a/libnautilus-private/nautilus-icon-dnd.c +++ b/libnautilus-private/nautilus-icon-dnd.c @@ -153,7 +153,7 @@ create_selection_shadow (NautilusIconContainer *container, NULL)); for (p = list; p != NULL; p = p->next) { - DragSelectionItem *item; + EelDragSelectionItem *item; int x1, y1, x2, y2; item = p->data; @@ -784,7 +784,7 @@ handle_local_move (NautilusIconContainer *container, double world_x, double world_y) { GList *moved_icons, *p; - DragSelectionItem *item; + EelDragSelectionItem *item; NautilusIcon *icon; if (container->details->auto_layout) { @@ -836,7 +836,7 @@ handle_nonlocal_move (NautilusIconContainer *container, source_uris = NULL; for (p = container->details->dnd_info->drag_info.selection_list; p != NULL; p = p->next) { /* do a shallow copy of all the uri strings of the copied files */ - source_uris = g_list_prepend (source_uris, ((DragSelectionItem *)p->data)->uri); + source_uris = g_list_prepend (source_uris, ((EelDragSelectionItem *)p->data)->uri); } source_uris = g_list_reverse (source_uris); @@ -851,9 +851,9 @@ handle_nonlocal_move (NautilusIconContainer *container, for (index = 0, p = container->details->dnd_info->drag_info.selection_list; p != NULL; index++, p = p->next) { g_array_index (source_item_locations, GdkPoint, index).x = - ((DragSelectionItem *)p->data)->icon_x; + ((EelDragSelectionItem *)p->data)->icon_x; g_array_index (source_item_locations, GdkPoint, index).y = - ((DragSelectionItem *)p->data)->icon_y; + ((EelDragSelectionItem *)p->data)->icon_y; } } @@ -934,7 +934,7 @@ selection_includes_special_link (GList *selection_list) link_in_selection = FALSE; for (node = selection_list; node != NULL; node = node->next) { - uri = ((DragSelectionItem *) node->data)->uri; + uri = ((EelDragSelectionItem *) node->data)->uri; /* FIXME bugzilla.eazel.com 3020: This does sync. I/O and works only locally. */ local_path = gnome_vfs_get_local_path_from_uri (uri); diff --git a/libnautilus-private/nautilus-tabs.c b/libnautilus-private/nautilus-tabs.c deleted file mode 100644 index e708e4c0d..000000000 --- a/libnautilus-private/nautilus-tabs.c +++ /dev/null @@ -1,923 +0,0 @@ -/* -*- 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 the implementation of a bit-map based tabs widget for the - * services summary view, but it's general enough to be used elsewhere. - * - */ - -#include <config.h> -#include "nautilus-tabs.h" - -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-util.h> -#include <eel/eel-gdk-extensions.h> -#include <eel/eel-gdk-pixbuf-extensions.h> -#include <eel/eel-glib-extensions.h> -#include <eel/eel-gnome-extensions.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-gtk-macros.h> -#include <eel/eel-scalable-font.h> -#include <libnautilus-extensions/nautilus-theme.h> -#include <math.h> -#include <stdio.h> -#include <string.h> - -/* constants for the tab piece pixbuf array */ - -#define TAB_BACKGROUND 0 -#define TAB_ACTIVE_LEFT 1 -#define TAB_ACTIVE_FILL 2 -#define TAB_ACTIVE_RIGHT 3 - -#define TAB_INACTIVE_LEFT 4 -#define TAB_INACTIVE_FILL 5 -#define TAB_INACTIVE_RIGHT 6 - -#define TAB_PRELIGHT_LEFT 7 -#define TAB_PRELIGHT_FILL 8 -#define TAB_PRELIGHT_RIGHT 9 - -#define TAB_INACTIVE_ACTIVE 10 -#define TAB_ACTIVE_INACTIVE 11 -#define TAB_PRELIGHT_ACTIVE 12 -#define TAB_ACTIVE_PRELIGHT 13 - -#define LAST_TAB_OFFSET 14 - -/* data structures */ - -typedef struct { - gboolean prelit; - gboolean selected; - char *tab_text; - int notebook_page; - GdkRectangle tab_rect; -} TabItem; - -struct NautilusTabsDetails { - int tab_count; - int total_height; - - GdkRectangle title_rect; - EelScalableFont *tab_font; - int font_size; - int selected_tab; - - GdkPixbuf *tab_piece_images[LAST_TAB_OFFSET]; - int tab_height; - int tab_left_offset; - - GList *tab_items; -}; - -/* constants */ -#define TAB_RIGHT_MARGIN 4 - -/* signals */ -enum { - TAB_SELECTED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL]; - -/* headers */ - -static void nautilus_tabs_initialize_class (NautilusTabsClass *klass); -static void nautilus_tabs_initialize (NautilusTabs *pixmap); -static void nautilus_tabs_draw (GtkWidget *widget, GdkRectangle *box); - -static int nautilus_tabs_expose (GtkWidget *widget, - GdkEventExpose *event); -static void nautilus_tabs_destroy (GtkObject *object); -static void nautilus_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition); - -static int nautilus_tabs_hit_test (NautilusTabs *tabs, int x, int y); - -static void nautilus_tabs_load_tab_pieces (NautilusTabs *tabs, const char *tab_piece_directory); -static gboolean nautilus_tabs_motion_event (GtkWidget *tabs, - GdkEventMotion *event); -static gboolean nautilus_tabs_press_event (GtkWidget *widget, - GdkEventButton *event); -static gboolean nautilus_tabs_leave_event (GtkWidget *tabs_widget, GdkEventCrossing *event); -static void nautilus_tabs_prelight_tab (NautilusTabs *tabs, int which_tab); -static void nautilus_tabs_select_tab (NautilusTabs *tabs, int which_tab); -static void nautilus_tabs_unload_tab_pieces (NautilusTabs *tabs); - -static void draw_all_tabs (NautilusTabs *tabs); -static TabItem* tab_item_find_by_name (NautilusTabs *tabs, - const char *name); - -EEL_DEFINE_CLASS_BOILERPLATE (NautilusTabs, nautilus_tabs, GTK_TYPE_DRAWING_AREA) - -static void -nautilus_tabs_initialize_class (NautilusTabsClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - object_class->destroy = nautilus_tabs_destroy; - widget_class->draw = nautilus_tabs_draw; - widget_class->expose_event = nautilus_tabs_expose; - widget_class->size_request = nautilus_tabs_size_request; - widget_class->button_press_event = nautilus_tabs_press_event; - widget_class->leave_notify_event = nautilus_tabs_leave_event; - widget_class->motion_notify_event = nautilus_tabs_motion_event; - - /* add the "tab selected" signal */ - signals[TAB_SELECTED] = gtk_signal_new - ("tab_selected", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusTabsClass, - tab_selected), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - - -/* initialize a newly allocated tabs object */ -static void -nautilus_tabs_initialize (NautilusTabs *tabs) -{ - GtkWidget *widget = GTK_WIDGET (tabs); - char *gray_tab_directory_path; - - GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_WINDOW); - - gtk_widget_set_events (widget, - gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); - - - tabs->details = g_new0 (NautilusTabsDetails, 1); - tabs->details->selected_tab = -1; - - /* FIXME bugzilla.eazel.com 5456: - * Hard coded font size. - */ - tabs->details->tab_font = eel_scalable_font_get_default_bold_font (); - tabs->details->font_size = 14; - - gray_tab_directory_path = nautilus_theme_get_image_path ("gray_tab_pieces"); - nautilus_tabs_load_tab_pieces (tabs, gray_tab_directory_path); - g_free (gray_tab_directory_path); - - gtk_widget_add_events (widget, GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); -} - -GtkWidget * -nautilus_tabs_new (void) -{ - return gtk_widget_new (nautilus_tabs_get_type (), NULL); -} - -/* utility to destroy all the storage used by a tab item */ - -static void -tab_item_destroy (TabItem *item) -{ - g_free (item->tab_text); - g_free (item); -} - -static void -tab_item_destroy_cover (gpointer item, gpointer callback_data) -{ - g_assert (callback_data == NULL); - tab_item_destroy (item); -} - -static void -nautilus_tabs_destroy (GtkObject *object) -{ - NautilusTabs *tabs = NAUTILUS_TABS(object); - - /* deallocate the tab piece images, if any */ - if (tabs->details->tab_piece_images[0] != NULL) { - nautilus_tabs_unload_tab_pieces (tabs); - } - - if (tabs->details->tab_font != NULL) { - gtk_object_unref (GTK_OBJECT (tabs->details->tab_font)); - } - - /* release the tab list, if any */ - eel_g_list_free_deep_custom (tabs->details->tab_items, - tab_item_destroy_cover, - NULL); - g_free (tabs->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - -/* unload the tab piece images, if any */ -static void -nautilus_tabs_unload_tab_pieces (NautilusTabs *tabs) -{ - int index; - for (index = 0; index < LAST_TAB_OFFSET; index++) { - if (tabs->details->tab_piece_images[index]) { - gdk_pixbuf_unref (tabs->details->tab_piece_images[index]); - tabs->details->tab_piece_images[index] = NULL; - } - } -} - -/* load the tab piece images */ - -static GdkPixbuf * -load_tab_piece (const char *piece_directory, const char *piece_name) -{ - GdkPixbuf *pixbuf; - gchar *image_path; - image_path = g_strdup_printf ("%s/%s.png", piece_directory, piece_name); - pixbuf = gdk_pixbuf_new_from_file (image_path); - if (pixbuf == NULL) { - g_warning ("cant load tab piece: %s", image_path); - } - - g_free (image_path); - return pixbuf; -} - -static void -nautilus_tabs_load_tab_pieces (NautilusTabs *tabs, const char* tab_piece_directory) -{ - tabs->details->tab_piece_images[TAB_BACKGROUND] = load_tab_piece (tab_piece_directory, "fill-background"); - - tabs->details->tab_piece_images[TAB_ACTIVE_LEFT] = load_tab_piece (tab_piece_directory, "active-left-bumper"); - tabs->details->tab_piece_images[TAB_ACTIVE_FILL] = load_tab_piece (tab_piece_directory, "active-fill"); - tabs->details->tab_piece_images[TAB_ACTIVE_RIGHT] = load_tab_piece (tab_piece_directory, "active-right-bumper"); - - tabs->details->tab_piece_images[TAB_INACTIVE_LEFT] = load_tab_piece (tab_piece_directory, "inactive-left-bumper"); - tabs->details->tab_piece_images[TAB_INACTIVE_FILL] = load_tab_piece (tab_piece_directory, "inactive-fill"); - tabs->details->tab_piece_images[TAB_INACTIVE_RIGHT] = load_tab_piece (tab_piece_directory, "inactive-right-bumper"); - - tabs->details->tab_piece_images[TAB_PRELIGHT_LEFT] = load_tab_piece (tab_piece_directory, "prelight-left-bumper"); - tabs->details->tab_piece_images[TAB_PRELIGHT_FILL] = load_tab_piece (tab_piece_directory, "prelight-fill"); - tabs->details->tab_piece_images[TAB_PRELIGHT_RIGHT] = load_tab_piece (tab_piece_directory, "prelight-right-bumper"); - - tabs->details->tab_piece_images[TAB_INACTIVE_ACTIVE] = load_tab_piece (tab_piece_directory, "inactive-active-bridge"); - tabs->details->tab_piece_images[TAB_ACTIVE_INACTIVE] = load_tab_piece (tab_piece_directory, "active-inactive-bridge"); - tabs->details->tab_piece_images[TAB_PRELIGHT_ACTIVE] = load_tab_piece (tab_piece_directory, "prelight-active-bridge"); - tabs->details->tab_piece_images[TAB_ACTIVE_PRELIGHT] = load_tab_piece (tab_piece_directory, "active-prelight-bridge"); -} - -/* determine the tab associated with the passed-in coordinates, and pass back the notebook - page index associated with it. */ - -static int -nautilus_tabs_hit_test (NautilusTabs *tabs, int x, int y) -{ - GList *current_item; - TabItem *tab_item; - GdkRectangle *rect_ptr; - int result; - - tabs->details->total_height = tabs->details->tab_height; - current_item = tabs->details->tab_items; - - if (current_item == NULL) - return -1; - - /* loop through the items, seeing if the passed in point is in one of the rectangles */ - tab_item = (TabItem*) current_item->data; - if (current_item->next) { - tab_item = (TabItem*) current_item->next->data; - } - - result = -1; - while (current_item != NULL) { - tab_item = (TabItem*) current_item->data; - rect_ptr = &tab_item->tab_rect; - - if ((x >= rect_ptr->x) && (x < rect_ptr->x + rect_ptr->width) && - (y >= rect_ptr->y) && (y< rect_ptr->y + rect_ptr->height)) - result = tab_item->notebook_page; - - current_item = current_item->next; - } - return result; -} - -/* utility routine to the height of the tabs */ -/* this assumes there's only one row of them */ -static int -measure_height (NautilusTabs *tabs) -{ - return gdk_pixbuf_get_height (tabs->details->tab_piece_images[TAB_ACTIVE_FILL]); -} - -/* resize the widget based on the number of tabs */ - -static void -recalculate_size(NautilusTabs *tabs) -{ - GtkWidget *widget = GTK_WIDGET (tabs); - - /* layout tabs to make sure height measurement is valid */ - tabs->details->total_height = measure_height (tabs); - - widget->requisition.width = widget->parent ? widget->parent->allocation.width: 136; - widget->requisition.height = tabs->details->total_height; - gtk_widget_queue_resize (widget); -} - -/* handle setting the size */ -static void -nautilus_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - requisition->width = widget->parent->allocation.width; - requisition->height = measure_height (NAUTILUS_TABS (widget));; -} - -/* utility to draw a single tab piece into a pixbuf */ -static int -draw_tab_piece_aa (NautilusTabs *tabs, GdkPixbuf *dest_pixbuf, int x, int y, int x_limit, int which_piece) -{ - GtkWidget *widget; - GdkPixbuf *pixbuf; - int width, height; - int dest_width, dest_height; - int blit_width, blit_height; - - widget = GTK_WIDGET (tabs); - pixbuf = tabs->details->tab_piece_images[which_piece]; - - /* if there's no pixbuf, just exit, returning a nominal size */ - if (pixbuf == NULL) { - return 32; - } - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - dest_width = gdk_pixbuf_get_width (dest_pixbuf); - dest_height = gdk_pixbuf_get_height (dest_pixbuf); - - /* trim tab piece to fit within the destination and the passed in limits */ - - if (x_limit > 0) { - if (x_limit < dest_width) { - dest_width = x_limit; - } - } - - if (x + width > dest_width) { - blit_width = dest_width - x; - } else { - blit_width = width; - } - - - if (y + height > dest_height) { - blit_height = dest_height - y; - } else { - blit_height = height; - } - - - if (x >= 0 && y >= 0 && width > 0 && height > 0) { - gdk_pixbuf_copy_area (pixbuf, - 0, 0, - blit_width, blit_height, - dest_pixbuf, - x, y); - } - return width; -} - -/* fill the canvas buffer with a tiled pixmap */ - -static void -draw_pixbuf_tiled_aa (GdkPixbuf *src_pixbuf, GdkPixbuf *dest_pixbuf, int offset) -{ - int x, y; - int start_x, start_y; - int end_x, end_y; - int tile_width, tile_height; - int blit_width, blit_height; - - tile_width = gdk_pixbuf_get_width (src_pixbuf); - tile_height = gdk_pixbuf_get_height (src_pixbuf); - - start_x = 0; - start_y = offset; - end_x = gdk_pixbuf_get_width (dest_pixbuf); - end_y = gdk_pixbuf_get_height (dest_pixbuf); - - for (y = start_y; y < end_y; y += tile_height) { - for (x = start_x; x < end_x; x += tile_width) { - - if (x + tile_width < end_x) { - blit_width = tile_width; - } else { - blit_width = end_x - x; - } - - if (y + tile_height < end_y) { - blit_height = tile_height; - } else { - blit_height = end_y - y; - } - - gdk_pixbuf_copy_area (src_pixbuf, - 0, 0, - blit_width, blit_height, - dest_pixbuf, - x, y); - } - } -} - -/* allocate_cleared_pixbuf allocates a new pixbuf with the passed-in dimensions and - clears it to be transparent */ -static GdkPixbuf* -allocate_cleared_pixbuf (int width, int height) -{ - guchar *pixels_ptr; - GdkPixbuf *pixbuf; - int y_index, row_stride; - - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); - - /* clear it */ - row_stride = gdk_pixbuf_get_rowstride (pixbuf); - pixels_ptr = gdk_pixbuf_get_pixels (pixbuf); - - for (y_index = 0; y_index < height; y_index++) { - memset (pixels_ptr, 0, row_stride); - pixels_ptr += row_stride; - } - - return pixbuf; -} - -static int -measure_tab_name (NautilusTabs *tabs, const char *tab_name) -{ - return eel_scalable_font_text_width (tabs->details->tab_font, - tabs->details->font_size, - tab_name, - strlen (tab_name)); -} - -/* utility to draw the tab label */ -static void -draw_tab_label (NautilusTabs *tabs, GdkPixbuf *tab_pixbuf, int x_pos, const char* label, gboolean is_active, gboolean is_prelit) -{ - int text_x, text_y; - uint text_color; - - text_x = x_pos + 1; - text_y = 5; /* calculate this to center font in label? */ - - /* make sure we can draw at least some of it */ - if (text_x < gdk_pixbuf_get_width (tab_pixbuf)) { - eel_scalable_font_draw_text (tabs->details->tab_font, tab_pixbuf, - text_x, text_y, - NULL, - tabs->details->font_size, - label, strlen (label), - EEL_RGB_COLOR_BLACK, EEL_OPACITY_FULLY_OPAQUE); - text_x -= 1; - text_y -= 1; - - if (is_active) { - text_color = EEL_RGB_COLOR_WHITE; - } else { - if (is_prelit) { - text_color = EEL_RGBA_COLOR_PACK (241, 241, 241, 255); - } else { - text_color = EEL_RGBA_COLOR_PACK (223, 223, 223, 255); - } - } - - eel_scalable_font_draw_text (tabs->details->tab_font, tab_pixbuf, - text_x, text_y, - NULL, - tabs->details->font_size, - label, strlen (label), - text_color, - EEL_OPACITY_FULLY_OPAQUE); - } -} - -/* draw or layout all of the tabs. - * - * NOTE: currently, this only supports two tabs since it was written quickly for the summary view, - * which only requires two. We should rewrite this to support any number of tabs when we have time. - */ - -static void -draw_all_tabs (NautilusTabs *tabs) -{ - int x_pos; - TabItem *left_tab, *right_tab; - GdkPixbuf *tab_pixbuf; - GtkWidget *widget; - int name_width; - int text_x_pos, right_edge_pos; - int left_bumper_piece, fill_piece_1; - int transition_type_piece, fill_piece_2, right_bumper_piece; - - g_assert (NAUTILUS_IS_TABS (tabs)); - - /* check if there's work to do; if there aren't any tabs or the widget isn't allocated yet, return */ - widget = GTK_WIDGET (tabs); - if (widget->allocation.width <= 0 || widget->allocation.height <= 0) { - return; - } - if (tabs->details->tab_items == NULL) { - return; - } - - /* set up the pointers to the two tab items */ - left_tab = (TabItem *) tabs->details->tab_items->data; - if (tabs->details->tab_items->next) { - right_tab = (TabItem *) tabs->details->tab_items->next->data; - } else { - right_tab = NULL; - } - - /* determine the images to use for the different tab pieces, given the selected and prelight state - of the two tabs. This obviously needs to be rewritten to handle more than two tabs, and should probably use - a table instead of the if statements */ - - if (left_tab->selected) { - if (left_tab->prelit) { - left_bumper_piece = TAB_PRELIGHT_LEFT; - fill_piece_1 = TAB_PRELIGHT_FILL; - - } else { - left_bumper_piece = TAB_ACTIVE_LEFT; - fill_piece_1 = TAB_ACTIVE_FILL; - } - - transition_type_piece = TAB_ACTIVE_INACTIVE; - - if (right_tab) { - if (right_tab->prelit) { - transition_type_piece = TAB_ACTIVE_PRELIGHT; - fill_piece_2 = TAB_PRELIGHT_FILL; - right_bumper_piece = TAB_PRELIGHT_RIGHT; - } else { - fill_piece_2 = TAB_INACTIVE_FILL; - right_bumper_piece = TAB_INACTIVE_RIGHT; - } - - } else { - transition_type_piece = TAB_ACTIVE_RIGHT; - fill_piece_2 = TAB_INACTIVE_FILL; - right_bumper_piece = TAB_INACTIVE_RIGHT; - } - } else { - - transition_type_piece = TAB_INACTIVE_ACTIVE; - - if (left_tab->prelit) { - left_bumper_piece = TAB_PRELIGHT_LEFT; - fill_piece_1 = TAB_PRELIGHT_FILL; - transition_type_piece = TAB_PRELIGHT_ACTIVE; - } else { - left_bumper_piece = TAB_INACTIVE_LEFT; - fill_piece_1 = TAB_INACTIVE_FILL; - } - - if (right_tab) { - fill_piece_2 = right_tab->prelit ? TAB_PRELIGHT_FILL : TAB_ACTIVE_FILL; - right_bumper_piece = right_tab->prelit ? TAB_PRELIGHT_RIGHT : TAB_ACTIVE_RIGHT; - } else { - fill_piece_2 = TAB_ACTIVE_FILL; - right_bumper_piece = TAB_ACTIVE_RIGHT; - } - } - - /* allocate a pixbuf to draw into, and clear it */ - tab_pixbuf = allocate_cleared_pixbuf (widget->allocation.width, widget->allocation.height); - x_pos = 0; - - /* first, fill the area with the tab background */ - draw_pixbuf_tiled_aa (tabs->details->tab_piece_images[TAB_BACKGROUND], tab_pixbuf, 0); - - /* draw the first tab's left bumper */ - x_pos += draw_tab_piece_aa (tabs, tab_pixbuf, x_pos, 0, -1, left_bumper_piece); - - /* measure the text to determine the first tab's size */ - name_width = measure_tab_name (tabs, left_tab->tab_text) + TAB_RIGHT_MARGIN; - - /* set up the first tab's rectangle for later hit-testing */ - left_tab->tab_rect.x = x_pos; - left_tab->tab_rect.y = 0; - left_tab->tab_rect.width = name_width; - left_tab->tab_rect.height = widget->allocation.height; - - /* draw the first tab's fill area in a loop */ - text_x_pos = x_pos; - right_edge_pos = x_pos + name_width; - while (x_pos < right_edge_pos) { - x_pos += draw_tab_piece_aa (tabs, tab_pixbuf, x_pos, 0, right_edge_pos, fill_piece_1); - } - x_pos = right_edge_pos; - - /* draw the first tab's label */ - draw_tab_label (tabs, tab_pixbuf, text_x_pos, left_tab->tab_text, left_tab->selected, left_tab->prelit); - - /* draw the transition piece */ - x_pos += draw_tab_piece_aa (tabs, tab_pixbuf, x_pos, 0, -1, transition_type_piece); - /* measure the text to determine the second tab's size */ - if (right_tab != NULL) { - name_width = measure_tab_name (tabs, right_tab->tab_text) + TAB_RIGHT_MARGIN; - - /* adjust position for transition piece - this shouldn't be hardwired */ - x_pos -= 12; - - /* set up the second tab's rectangle for hit-testing */ - right_tab->tab_rect.x = x_pos; - right_tab->tab_rect.y = 0; - right_tab->tab_rect.width = name_width; - right_tab->tab_rect.height = widget->allocation.height; - - /* draw the second tab's fill area */ - text_x_pos = x_pos; - right_edge_pos = x_pos + name_width; - while (x_pos < right_edge_pos) { - x_pos += draw_tab_piece_aa (tabs, tab_pixbuf, x_pos, 0, right_edge_pos, fill_piece_2); - } - x_pos = right_edge_pos; - - /* draw the second tab's label */ - draw_tab_label (tabs, tab_pixbuf, text_x_pos, right_tab->tab_text, right_tab->selected, right_tab->prelit); - - /* draw the second tab's right bumper piece */ - draw_tab_piece_aa (tabs, tab_pixbuf, x_pos, 0, -1, right_bumper_piece); - } - - /* draw the off-screen buffer to the screen, then release it */ - gdk_pixbuf_render_to_drawable_alpha (tab_pixbuf, - widget->window, - 0, 0, - 0, 0, - widget->allocation.width, widget->allocation.height, - GDK_PIXBUF_ALPHA_BILEVEL, 128, - GDK_RGB_DITHER_MAX, - 0, 0); - - gdk_pixbuf_unref (tab_pixbuf); -} - -/* find a tab with a given name, or return NULL if we can't find one */ -static TabItem * -tab_item_find_by_name (NautilusTabs *tabs, const char *name) -{ - GList *iterator; - - g_return_val_if_fail (NAUTILUS_IS_TABS (tabs), NULL); - g_return_val_if_fail (name != NULL, NULL); - - for (iterator = tabs->details->tab_items; iterator != NULL; iterator = iterator->next) { - TabItem *tab_item = iterator->data; - - g_assert (tab_item != NULL); - g_assert (tab_item->tab_text != NULL); - - if (strcmp (tab_item->tab_text, name) == 0) { - return tab_item; - } - } - - return NULL; -} - -/* handle an expose event by drawing the tabs */ - -static int -nautilus_tabs_expose (GtkWidget *widget, GdkEventExpose *event) -{ - NautilusTabs *tabs; - - g_return_val_if_fail (NAUTILUS_IS_TABS (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (widget->window == NULL) { - return FALSE; - } - - tabs = NAUTILUS_TABS (widget); - - if (tabs->details->tab_count > 0) { - draw_all_tabs (tabs); - } - return FALSE; -} - -static void -nautilus_tabs_draw (GtkWidget *widget, GdkRectangle *box) -{ - /* Clear the widget get the default widget background before drawing our stuff */ - gdk_window_clear_area (widget->window, - 0, - 0, - widget->allocation.width, - widget->allocation.height); - draw_all_tabs (NAUTILUS_TABS (widget)); -} - -/* add a new tab entry, return TRUE if we succeed */ - -gboolean -nautilus_tabs_add_tab (NautilusTabs *tabs, const char *name, int page_num) -{ - TabItem *new_tab_item; - - g_return_val_if_fail (NAUTILUS_IS_TABS (tabs), FALSE); - g_return_val_if_fail (name != NULL, FALSE); - - /* Check to see if we already have one with this name, if so, refuse to add it */ - if (tab_item_find_by_name (tabs, name)) { - g_warning ("nautilus_tabs_add_view: Trying to add duplicate item '%s'", name); - return FALSE; - } - - /* allocate a new entry, and initialize it */ - new_tab_item = g_new0 (TabItem, 1); - new_tab_item->tab_text = g_strdup (name); - new_tab_item->prelit = FALSE; - new_tab_item->selected = FALSE; - new_tab_item->notebook_page = page_num; - - /* add it to the list */ - tabs->details->tab_items = g_list_append (tabs->details->tab_items, new_tab_item); - if (tabs->details->selected_tab == -1) { - tabs->details->selected_tab = page_num; - new_tab_item->selected = TRUE; - } - - tabs->details->tab_count += 1; - recalculate_size (tabs); - gtk_widget_queue_draw (GTK_WIDGET (tabs)); - - return TRUE; -} - - -/* remove the specified tab entry */ -void -nautilus_tabs_remove_tab (NautilusTabs *tabs, const char *name) -{ - GList *next_tab; - TabItem *tab_item; - int old_page_number; - - g_return_if_fail (NAUTILUS_IS_TABS (tabs)); - g_return_if_fail (name != NULL); - - /* Look up the item */ - tab_item = tab_item_find_by_name (tabs, name); - - if (tab_item == NULL) { - g_warning ("nautilus_tabs_remove_view: Trying to remove a non-existing item '%s'", name); - return; - } - - /* Remove the item from the list */ - tabs->details->tab_items = g_list_remove (tabs->details->tab_items, tab_item); - - old_page_number = tab_item->notebook_page; - tab_item_destroy (tab_item); - - /* decrement all page numbers greater than the one we're removing */ - for (next_tab = tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - TabItem *item = next_tab->data; - if (item->notebook_page >= old_page_number) - item->notebook_page -= 1; - } - - tabs->details->tab_count -= 1; - - recalculate_size (tabs); - gtk_widget_queue_draw (GTK_WIDGET (tabs)); -} - -/* prelight a tab, from its associated notebook page number, by setting the prelight flag of - the proper tab and clearing the others. Don't allow prelighting of the selected tab */ -static void -nautilus_tabs_prelight_tab (NautilusTabs *tabs, int which_tab) -{ - GList *next_tab; - gboolean is_prelit; - gboolean changed = FALSE; - - g_return_if_fail (NAUTILUS_IS_TABS (tabs)); - - for (next_tab = tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - TabItem *item = next_tab->data; - is_prelit = (item->notebook_page == which_tab); - if (item->prelit != is_prelit && (!item->selected || !is_prelit)) { - item->prelit = is_prelit; - changed = TRUE; - } - } - - if (changed) - gtk_widget_queue_draw (GTK_WIDGET (tabs)); -} - -/* select a tab, in a similar fashion */ -static void -nautilus_tabs_select_tab (NautilusTabs *tabs, int which_tab) -{ - GList *next_tab; - gboolean is_selected; - gboolean changed = FALSE; - - g_return_if_fail (NAUTILUS_IS_TABS (tabs)); - - if (tabs->details->selected_tab == which_tab) { - return; - } - - tabs->details->selected_tab = which_tab; - - for (next_tab = tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - TabItem *item = next_tab->data; - is_selected = (item->notebook_page == which_tab); - if (item->selected != is_selected) { - item->selected = is_selected; - if (is_selected) { - item->prelit = FALSE; - } - changed = TRUE; - } - } - - if (changed) - gtk_widget_queue_draw (GTK_WIDGET (tabs)); - - gtk_signal_emit (GTK_OBJECT (tabs), - signals[TAB_SELECTED], which_tab); - -} - -/* handle mouse clicks by selecting a tab if necessary */ -static gboolean -nautilus_tabs_press_event (GtkWidget *widget, GdkEventButton *event) -{ - int which_tab; - - which_tab = nautilus_tabs_hit_test (NAUTILUS_TABS (widget), event->x, event->y); - if (which_tab >= 0) { - nautilus_tabs_select_tab (NAUTILUS_TABS (widget), which_tab); - } - return TRUE; -} - -/* handle the leave event by turning off the preliting */ -static gboolean -nautilus_tabs_leave_event (GtkWidget *tabs_widget, GdkEventCrossing *event) -{ - nautilus_tabs_prelight_tab (NAUTILUS_TABS (tabs_widget), -1); - return TRUE; -} - -/* handle mouse motion events by passing it to the tabs if necessary for pre-lighting */ -static gboolean -nautilus_tabs_motion_event (GtkWidget *tabs_widget, GdkEventMotion *event) -{ - int x, y; - int which_tab; - - gtk_widget_get_pointer (tabs_widget, &x, &y); - - - /* if the motion is in the main tabs, tell them about it */ - which_tab = nautilus_tabs_hit_test (NAUTILUS_TABS (tabs_widget), x, y); - - nautilus_tabs_prelight_tab (NAUTILUS_TABS (tabs_widget), which_tab); - - return TRUE; -} diff --git a/libnautilus-private/nautilus-tabs.h b/libnautilus-private/nautilus-tabs.h deleted file mode 100644 index 144f5d730..000000000 --- a/libnautilus-private/nautilus-tabs.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus 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. - * - * Nautilus 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 an image-based folder tabs widget. - */ - -#ifndef NAUTILUS_TABS_H -#define NAUTILUS_TABS_H - -#include <gtk/gtkdrawingarea.h> - -#define NAUTILUS_TYPE_TABS (nautilus_tabs_get_type ()) -#define NAUTILUS_TABS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TABS, NautilusTabs)) -#define NAUTILUS_TABS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TABS, NautilusTabsClass)) -#define NAUTILUS_IS_TABS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TABS)) -#define NAUTILUS_IS_TABS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TABS)) - -typedef struct NautilusTabsDetails NautilusTabsDetails; - -typedef struct -{ - GtkDrawingArea parent; - NautilusTabsDetails *details; -} NautilusTabs; - -typedef struct -{ - GtkDrawingAreaClass parent_class; - - void (*tab_selected) (NautilusTabs *tabs, int which_tab); -} NautilusTabsClass; - -GtkType nautilus_tabs_get_type (void); -GtkWidget *nautilus_tabs_new (void); -gboolean nautilus_tabs_add_tab (NautilusTabs *tabs, - const char *name, - int page_number); -void nautilus_tabs_remove_tab (NautilusTabs *tabs, - const char *name); - -#endif /* NAUTILUS_TABS_H */ diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 194925e79..6180ec413 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -648,7 +648,7 @@ fm_list_receive_dropped_icons (EelList *list, for (p = drop_data; p != NULL; p = p->next) { /* do a shallow copy of all the uri strings of the copied files */ source_uris = g_list_prepend (source_uris, - ((DragSelectionItem *)p->data)->uri); + ((EelDragSelectionItem *)p->data)->uri); } source_uris = g_list_reverse (source_uris); |