reviewed (a bit) by: John Sullivan <sullivan@eazel.com>

Some tree view changes so it only does work when the tree view is
	open, not when it's closed. Also improved speed by not creating so
	many pixmaps, which required changing lots of classes to use
	pixbufs instead of pixmaps.

	* components/tree/libmain.c: (tree_shlib_object_destroyed),
	(tree_shlib_make_object): Changed to use NautilusTreeView
	subclass of NautilusView, not widget.

	* components/tree/main.c: (main): Use standard main.

	* components/rpmview/nautilus-rpm-view.c:
	(file_activation_callback), (fill_filename_tree_int),
	(fill_filename_tree), (nautilus_rpm_view_update_from_uri):
	Update to use NautilusCList instead of GtkCList.

	* components/tree/nautilus-tree-change-queue.h: Got rid of ADDED
	(it's now the same as CHANGED).

	* components/tree/nautilus-tree-model.h:
	* components/tree/nautilus-tree-model.c:
	(nautilus_tree_model_initialize_class): No more ADDED.
	(destroy_file_hash): New function.
	(nautilus_tree_model_destroy): Destroy deferral hashes.
	(nautilus_tree_model_node_begin_monitoring): Use changed instead
	of added.
	(report_node_changed): Emit changed instead of added.
	(process_file_change): New function.
	(process_directory_done_loading): New function.
	(add_file_to_hash): New function.
	(nautilus_tree_model_directory_files_changed_callback),
	(nautilus_tree_model_directory_done_loading_callback): Either put
	the file in the hash table or send the notification.
	(process_one_changed_file), (process_one_done_loading_file):
	Helper functions to send notifications.
	(nautilus_tree_model_set_defer_notifications): Start deferring
	notifications by making hash tables. Stop deferring notifications
	by sending out all the notifications and then getting rid of the
	hash tables.

	* components/tree/nautilus-tree-view.h:
	* components/tree/nautilus-tree-view-private.h:
	* components/tree/nautilus-tree-view.c:
	(nautilus_tree_view_insert_model_node), (ctree_is_node_expanded),
	(nautilus_tree_view_update_model_node),
	(awaited_node_or_uri_found), (notify_done_loading),
	(notify_node_seen), (get_selected_row),
	(get_selected_row_position), (set_selected_row_position),
	(dequeue_pending_idle_callback), (schedule_pending_idle_callback),
	(unschedule_pending_idle_callback),
	(nautilus_tree_view_load_from_filesystem), (ctree_compare_rows),
	(create_tree), (tree_map_callback), (tree_unmap_callback),
	(nautilus_tree_view_initialize), (nautilus_tree_view_destroy),
	(get_uri_sequence_to_root),
	(call_when_uri_loaded_or_parent_done_loading),
	(cancel_selection_in_progress),
	(expand_uri_sequence_and_select_end), (select_current_location),
	(tree_load_location_callback), (got_activation_uri_callback),
	(ctree_get_first_selected_node),
	(nautilus_tree_view_update_all_icons),
	(nautilus_tree_view_initialize_class):
	Convert to use pixbufs instead of pixmaps. Convert to use
	NautilusList instead of GtkCList. Fix storage leak of name.
	Get rid of weak use of callback function pointers. Add feature
	where the selected row is kept in position as new items are added.
	Eliminated ADDED and jsut used CHANGED instead. Defer creating the
	tree view until the first map. Turn off processing when unmapped.
	Change NautilusTreeView to be NautilusView subclass, not a widget.

	* components/tree/nautilus-tree-view-dnd.c:
	(nautilus_tree_view_drag_begin), (nautilus_tree_view_drag_motion),
	(get_data_on_first_target_we_support),
	(nautilus_tree_view_button_press),
	(nautilus_tree_view_button_release),
	(nautilus_tree_view_motion_notify),
	(nautilus_tree_view_set_dnd_icon),
	(nautilus_tree_view_collapse_node),
	(nautilus_tree_view_expand_or_collapse_row),
	(nautilus_tree_view_tree_node_at), (auto_scroll_timeout_callback),
	(nautilus_tree_view_real_scroll),
	(nautilus_tree_view_collapse_all),
	(nautilus_tree_view_receive_dropped_icons),
	(nautilus_tree_view_drag_destroy),
	(nautilus_tree_view_drag_destroy_real):
	Switch from GtkCList to NautilusCList. Also get rid of code that
	assumes NautilusTreeView is a widget. Also convert to use pixbufs
	instead of pixmaps.

	* cut-n-paste-code/widgets/nautilusclist/nautilusclist.h:
	* cut-n-paste-code/widgets/nautilusclist/nautilusclist.c:
	(nautilus_clist_optimal_column_width), (nautilus_clist_set_text),
	(nautilus_clist_set_pixbuf), (nautilus_clist_get_pixbuf),
	(nautilus_clist_set_pixtext), (nautilus_clist_get_pixtext),
	(set_cell_contents), (cell_size_request), (real_insert_row),
	(draw_row), (draw_rows), (row_delete):
	Change to use pixbufs instead of pixmaps. Remove most of the
	drawing code since this can only be used as a base class for
	NautilusList anyway. Add boolean to set_cell_contents so it
	redraws only if the cell has changed.

	* libnautilus-extensions/nautilus-ctree.h:
	* libnautilus-extensions/nautilus-ctree.c: (COLUMN_FROM_XPIXEL),
	(nautilus_ctree_get_type), (nautilus_ctree_class_init),
	(nautilus_ctree_set_arg), (nautilus_ctree_get_arg),
	(nautilus_ctree_init), (ctree_attach_styles),
	(ctree_detach_styles), (nautilus_ctree_realize),
	(nautilus_ctree_event), (nautilus_ctree_unrealize),
	(nautilus_ctree_button_press), (draw_drag_highlight),
	(nautilus_ctree_row_at), (get_cell_rectangle),
	(nautilus_ctree_set_prelight), (draw_cell_pixbuf),
	(get_cell_style), (nautilus_ctree_draw_expander),
	(nautilus_ctree_draw_lines), (draw_row), (tree_draw_node),
	(nautilus_ctree_link), (nautilus_ctree_unlink), (real_row_move),
	(real_tree_move), (change_focus_row_expansion), (real_tree_expand),
	(real_tree_collapse), (column_auto_resize), (auto_resize_columns),
	(cell_size_request), (set_cell_contents), (set_node_info),
	(row_new), (row_delete), (real_select_row), (real_unselect_row),
	(real_tree_select), (real_tree_unselect), (select_row_recursive),
	(real_select_all), (real_unselect_all), (ctree_is_hot_spot),
	(nautilus_ctree_construct), (real_insert_row),
	(nautilus_ctree_insert_node), (nautilus_ctree_insert_gnode),
	(real_remove_row), (nautilus_ctree_remove_node), (real_clear),
	(nautilus_ctree_post_recursive),
	(nautilus_ctree_post_recursive_to_depth),
	(nautilus_ctree_pre_recursive),
	(nautilus_ctree_pre_recursive_to_depth),
	(nautilus_ctree_find_node_ptr), (nautilus_ctree_node_nth),
	(nautilus_ctree_find), (nautilus_ctree_find_by_row_data),
	(nautilus_ctree_find_all_by_row_data),
	(nautilus_ctree_find_by_row_data_custom),
	(nautilus_ctree_find_all_by_row_data_custom),
	(nautilus_ctree_is_hot_spot), (nautilus_ctree_expand_recursive),
	(nautilus_ctree_expand_to_depth),
	(nautilus_ctree_collapse_recursive),
	(nautilus_ctree_collapse_to_depth),
	(nautilus_ctree_toggle_expansion_recursive),
	(nautilus_ctree_real_select_recursive),
	(nautilus_ctree_node_set_text), (nautilus_ctree_node_set_pixbuf),
	(nautilus_ctree_node_set_pixtext), (nautilus_ctree_set_node_info),
	(nautilus_ctree_node_set_shift), (remove_grab),
	(nautilus_ctree_node_set_selectable),
	(nautilus_ctree_node_get_cell_type),
	(nautilus_ctree_node_get_text), (nautilus_ctree_node_get_pixbuf),
	(nautilus_ctree_node_get_pixtext), (nautilus_ctree_get_node_info),
	(nautilus_ctree_node_set_cell_style),
	(nautilus_ctree_node_get_cell_style),
	(nautilus_ctree_node_set_row_style), (nautilus_ctree_node_moveto),
	(nautilus_ctree_node_is_visible), (nautilus_ctree_set_indent),
	(nautilus_ctree_set_spacing), (nautilus_ctree_set_show_stub),
	(nautilus_ctree_set_line_style), (tree_sort),
	(nautilus_ctree_sort_recursive), (real_sort_list),
	(nautilus_ctree_sort_node), (nautilus_ctree_sort_single_node),
	(fake_unselect_all), (selection_find), (resync_selection),
	(real_undo_selection), (check_drag), (drag_dest_info_destroy),
	(drag_dest_cell), (nautilus_ctree_drag_begin),
	(nautilus_ctree_drag_motion), (nautilus_ctree_drag_data_received):
	Change to use NautilusList instead of GtkCList. Change to use
	pixbufs instead of pixmaps. Use set_cell_contents boolean to only
	redraw when cell has changed.

	* libnautilus-extensions/nautilus-gtk-extensions.h:
	* libnautilus-extensions/nautilus-gtk-extensions.c:
	(nautilus_gtk_marshal_POINTER__INT): Add new marshal needed for
	the pixbuf version of a NautilusList call.
	(nautilus_drag_set_icon_pixbuf): Helper to convert pixbuf to
	a pixmap and mask for GTK's sake.

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(nautilus_icon_dnd_begin_drag): Use nautilus_drag_set_icon_pixbuf.

	* libnautilus-extensions/nautilus-list.h:
	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_initialize_class), (nautilus_list_initialize_dnd),
	(nautilus_list_initialize), (nautilus_list_destroy), (draw_cell),
	(nautilus_list_mark_cell_as_link),
	(nautilus_list_set_cell_contents), (set_list_cell),
	(get_list_cell), (nautilus_list_drag_start),
	(nautilus_list_receive_dropped_icons):
	Take advantage of the new changes in NautilusCList, which now uses
	pixmaps directly. Change drag signal to use a pixbuf, not a
	pixmap. Change so it doesn't do the DND stuff unless you
	explicitly call for it. Use set_cell_contents boolean to only
	redraw when cell has changed.

	* src/file-manager/fm-list-view.c: (fm_list_get_drag_pixbuf),
	(fm_list_get_sort_column_index), (create_list), (set_up_list):
	Change to use the new pixbuf signal instead of the old pixmap one.
	Make a call to ask NautilusList to do the DND stuff.
This commit is contained in:
Darin Adler 2001-03-28 01:39:16 +00:00
parent ef6366755e
commit a09a439c67
28 changed files with 2654 additions and 3455 deletions

193
ChangeLog
View file

@ -1,3 +1,196 @@
2001-03-27 Darin Adler <darin@eazel.com>
reviewed (a bit) by: John Sullivan <sullivan@eazel.com>
Some tree view changes so it only does work when the tree view is
open, not when it's closed. Also improved speed by not creating so
many pixmaps, which required changing lots of classes to use
pixbufs instead of pixmaps.
* components/tree/libmain.c: (tree_shlib_object_destroyed),
(tree_shlib_make_object): Changed to use NautilusTreeView
subclass of NautilusView, not widget.
* components/tree/main.c: (main): Use standard main.
* components/rpmview/nautilus-rpm-view.c:
(file_activation_callback), (fill_filename_tree_int),
(fill_filename_tree), (nautilus_rpm_view_update_from_uri):
Update to use NautilusCList instead of GtkCList.
* components/tree/nautilus-tree-change-queue.h: Got rid of ADDED
(it's now the same as CHANGED).
* components/tree/nautilus-tree-model.h:
* components/tree/nautilus-tree-model.c:
(nautilus_tree_model_initialize_class): No more ADDED.
(destroy_file_hash): New function.
(nautilus_tree_model_destroy): Destroy deferral hashes.
(nautilus_tree_model_node_begin_monitoring): Use changed instead
of added.
(report_node_changed): Emit changed instead of added.
(process_file_change): New function.
(process_directory_done_loading): New function.
(add_file_to_hash): New function.
(nautilus_tree_model_directory_files_changed_callback),
(nautilus_tree_model_directory_done_loading_callback): Either put
the file in the hash table or send the notification.
(process_one_changed_file), (process_one_done_loading_file):
Helper functions to send notifications.
(nautilus_tree_model_set_defer_notifications): Start deferring
notifications by making hash tables. Stop deferring notifications
by sending out all the notifications and then getting rid of the
hash tables.
* components/tree/nautilus-tree-view.h:
* components/tree/nautilus-tree-view-private.h:
* components/tree/nautilus-tree-view.c:
(nautilus_tree_view_insert_model_node), (ctree_is_node_expanded),
(nautilus_tree_view_update_model_node),
(awaited_node_or_uri_found), (notify_done_loading),
(notify_node_seen), (get_selected_row),
(get_selected_row_position), (set_selected_row_position),
(dequeue_pending_idle_callback), (schedule_pending_idle_callback),
(unschedule_pending_idle_callback),
(nautilus_tree_view_load_from_filesystem), (ctree_compare_rows),
(create_tree), (tree_map_callback), (tree_unmap_callback),
(nautilus_tree_view_initialize), (nautilus_tree_view_destroy),
(get_uri_sequence_to_root),
(call_when_uri_loaded_or_parent_done_loading),
(cancel_selection_in_progress),
(expand_uri_sequence_and_select_end), (select_current_location),
(tree_load_location_callback), (got_activation_uri_callback),
(ctree_get_first_selected_node),
(nautilus_tree_view_update_all_icons),
(nautilus_tree_view_initialize_class):
Convert to use pixbufs instead of pixmaps. Convert to use
NautilusList instead of GtkCList. Fix storage leak of name.
Get rid of weak use of callback function pointers. Add feature
where the selected row is kept in position as new items are added.
Eliminated ADDED and jsut used CHANGED instead. Defer creating the
tree view until the first map. Turn off processing when unmapped.
Change NautilusTreeView to be NautilusView subclass, not a widget.
* components/tree/nautilus-tree-view-dnd.c:
(nautilus_tree_view_drag_begin), (nautilus_tree_view_drag_motion),
(get_data_on_first_target_we_support),
(nautilus_tree_view_button_press),
(nautilus_tree_view_button_release),
(nautilus_tree_view_motion_notify),
(nautilus_tree_view_set_dnd_icon),
(nautilus_tree_view_collapse_node),
(nautilus_tree_view_expand_or_collapse_row),
(nautilus_tree_view_tree_node_at), (auto_scroll_timeout_callback),
(nautilus_tree_view_real_scroll),
(nautilus_tree_view_collapse_all),
(nautilus_tree_view_receive_dropped_icons),
(nautilus_tree_view_drag_destroy),
(nautilus_tree_view_drag_destroy_real):
Switch from GtkCList to NautilusCList. Also get rid of code that
assumes NautilusTreeView is a widget. Also convert to use pixbufs
instead of pixmaps.
* cut-n-paste-code/widgets/nautilusclist/nautilusclist.h:
* cut-n-paste-code/widgets/nautilusclist/nautilusclist.c:
(nautilus_clist_optimal_column_width), (nautilus_clist_set_text),
(nautilus_clist_set_pixbuf), (nautilus_clist_get_pixbuf),
(nautilus_clist_set_pixtext), (nautilus_clist_get_pixtext),
(set_cell_contents), (cell_size_request), (real_insert_row),
(draw_row), (draw_rows), (row_delete):
Change to use pixbufs instead of pixmaps. Remove most of the
drawing code since this can only be used as a base class for
NautilusList anyway. Add boolean to set_cell_contents so it
redraws only if the cell has changed.
* libnautilus-extensions/nautilus-ctree.h:
* libnautilus-extensions/nautilus-ctree.c: (COLUMN_FROM_XPIXEL),
(nautilus_ctree_get_type), (nautilus_ctree_class_init),
(nautilus_ctree_set_arg), (nautilus_ctree_get_arg),
(nautilus_ctree_init), (ctree_attach_styles),
(ctree_detach_styles), (nautilus_ctree_realize),
(nautilus_ctree_event), (nautilus_ctree_unrealize),
(nautilus_ctree_button_press), (draw_drag_highlight),
(nautilus_ctree_row_at), (get_cell_rectangle),
(nautilus_ctree_set_prelight), (draw_cell_pixbuf),
(get_cell_style), (nautilus_ctree_draw_expander),
(nautilus_ctree_draw_lines), (draw_row), (tree_draw_node),
(nautilus_ctree_link), (nautilus_ctree_unlink), (real_row_move),
(real_tree_move), (change_focus_row_expansion), (real_tree_expand),
(real_tree_collapse), (column_auto_resize), (auto_resize_columns),
(cell_size_request), (set_cell_contents), (set_node_info),
(row_new), (row_delete), (real_select_row), (real_unselect_row),
(real_tree_select), (real_tree_unselect), (select_row_recursive),
(real_select_all), (real_unselect_all), (ctree_is_hot_spot),
(nautilus_ctree_construct), (real_insert_row),
(nautilus_ctree_insert_node), (nautilus_ctree_insert_gnode),
(real_remove_row), (nautilus_ctree_remove_node), (real_clear),
(nautilus_ctree_post_recursive),
(nautilus_ctree_post_recursive_to_depth),
(nautilus_ctree_pre_recursive),
(nautilus_ctree_pre_recursive_to_depth),
(nautilus_ctree_find_node_ptr), (nautilus_ctree_node_nth),
(nautilus_ctree_find), (nautilus_ctree_find_by_row_data),
(nautilus_ctree_find_all_by_row_data),
(nautilus_ctree_find_by_row_data_custom),
(nautilus_ctree_find_all_by_row_data_custom),
(nautilus_ctree_is_hot_spot), (nautilus_ctree_expand_recursive),
(nautilus_ctree_expand_to_depth),
(nautilus_ctree_collapse_recursive),
(nautilus_ctree_collapse_to_depth),
(nautilus_ctree_toggle_expansion_recursive),
(nautilus_ctree_real_select_recursive),
(nautilus_ctree_node_set_text), (nautilus_ctree_node_set_pixbuf),
(nautilus_ctree_node_set_pixtext), (nautilus_ctree_set_node_info),
(nautilus_ctree_node_set_shift), (remove_grab),
(nautilus_ctree_node_set_selectable),
(nautilus_ctree_node_get_cell_type),
(nautilus_ctree_node_get_text), (nautilus_ctree_node_get_pixbuf),
(nautilus_ctree_node_get_pixtext), (nautilus_ctree_get_node_info),
(nautilus_ctree_node_set_cell_style),
(nautilus_ctree_node_get_cell_style),
(nautilus_ctree_node_set_row_style), (nautilus_ctree_node_moveto),
(nautilus_ctree_node_is_visible), (nautilus_ctree_set_indent),
(nautilus_ctree_set_spacing), (nautilus_ctree_set_show_stub),
(nautilus_ctree_set_line_style), (tree_sort),
(nautilus_ctree_sort_recursive), (real_sort_list),
(nautilus_ctree_sort_node), (nautilus_ctree_sort_single_node),
(fake_unselect_all), (selection_find), (resync_selection),
(real_undo_selection), (check_drag), (drag_dest_info_destroy),
(drag_dest_cell), (nautilus_ctree_drag_begin),
(nautilus_ctree_drag_motion), (nautilus_ctree_drag_data_received):
Change to use NautilusList instead of GtkCList. Change to use
pixbufs instead of pixmaps. Use set_cell_contents boolean to only
redraw when cell has changed.
* libnautilus-extensions/nautilus-gtk-extensions.h:
* libnautilus-extensions/nautilus-gtk-extensions.c:
(nautilus_gtk_marshal_POINTER__INT): Add new marshal needed for
the pixbuf version of a NautilusList call.
(nautilus_drag_set_icon_pixbuf): Helper to convert pixbuf to
a pixmap and mask for GTK's sake.
* libnautilus-extensions/nautilus-icon-dnd.c:
(nautilus_icon_dnd_begin_drag): Use nautilus_drag_set_icon_pixbuf.
* libnautilus-extensions/nautilus-list.h:
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_initialize_class), (nautilus_list_initialize_dnd),
(nautilus_list_initialize), (nautilus_list_destroy), (draw_cell),
(nautilus_list_mark_cell_as_link),
(nautilus_list_set_cell_contents), (set_list_cell),
(get_list_cell), (nautilus_list_drag_start),
(nautilus_list_receive_dropped_icons):
Take advantage of the new changes in NautilusCList, which now uses
pixmaps directly. Change drag signal to use a pixbuf, not a
pixmap. Change so it doesn't do the DND stuff unless you
explicitly call for it. Use set_cell_contents boolean to only
redraw when cell has changed.
* src/file-manager/fm-list-view.c: (fm_list_get_drag_pixbuf),
(fm_list_get_sort_column_index), (create_list), (set_up_list):
Change to use the new pixbuf signal instead of the old pixmap one.
Make a call to ask NautilusList to do the DND stuff.
2001-03-27 Ramiro Estrugo <ramiro@eazel.com>
* components/services/clone/.cvsignore:

View file

@ -24,22 +24,20 @@
/* The RPM view component is used to provide an easy-to-use overview of a rpm package */
#include <config.h>
#include "nautilus-rpm-view.h"
#include "nautilus-rpm-verify-window.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
#include <libnautilus/libnautilus.h>
#include <fcntl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gnome.h>
#include <gtk/gtklabel.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-ctree.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
@ -48,12 +46,11 @@
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-theme.h>
#include <libnautilus-extensions/nautilus-viewport.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtklabel.h>
#include <gnome.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnorba/gnorba.h>
#include <libnautilus/libnautilus.h>
#include <limits.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
/* must be after any services includes */
#include "nautilus-rpm-view-private.h"
@ -439,7 +436,7 @@ file_activation_callback (NautilusCTree *ctree, NautilusCTreeNode *node, int col
path_name = g_strdup ("");
while (1) {
nautilus_ctree_node_get_pixtext (ctree, node,
0, &path_item, NULL, NULL, NULL);
0, &path_item, NULL, NULL);
if (strcmp (path_item, "/") != 0) {
new_name = g_strdup_printf ("/%s%s", path_item, path_name);
g_free (path_name);
@ -497,7 +494,7 @@ fill_filename_tree_int (GtkWidget *ctree, NautilusCTreeNode *parent, GNode *node
for (child = g_node_first_child (node); child != NULL; child = g_node_next_sibling (child)) {
text[0] = (char *) child->data;
me = nautilus_ctree_insert_node (NAUTILUS_CTREE (ctree), parent, NULL, text,
0, NULL, NULL, NULL, NULL,
0, NULL, NULL,
(child->children == NULL) ? TRUE : FALSE,
TRUE);
fill_filename_tree_int (ctree, me, child);
@ -512,7 +509,7 @@ fill_filename_tree (NautilusRPMView *rpm_view)
top = nautilus_ctree_insert_node (NAUTILUS_CTREE (rpm_view->details->package_file_tree),
NULL, NULL, text,
0, NULL, NULL, NULL, NULL,
0, NULL, NULL,
FALSE, TRUE);
fill_filename_tree_int (rpm_view->details->package_file_tree, top, rpm_view->details->filename_tree);
}
@ -554,8 +551,8 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri)
}
/* set the file tree */
gtk_clist_freeze (GTK_CLIST (rpm_view->details->package_file_tree));
gtk_clist_clear (GTK_CLIST (rpm_view->details->package_file_tree));
nautilus_clist_freeze (NAUTILUS_CLIST (rpm_view->details->package_file_tree));
nautilus_clist_clear (NAUTILUS_CLIST (rpm_view->details->package_file_tree));
if (rpm_view->details->filename_tree != NULL) {
g_node_traverse (rpm_view->details->filename_tree, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
(GNodeTraverseFunc)filename_node_free, NULL);
@ -566,9 +563,9 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri)
fill_filename_tree (rpm_view);
temp_str = g_strdup_printf(_("Package Contents: %d files"),
g_list_length (rpm_view->details->package->provides));
gtk_clist_set_column_title (GTK_CLIST(rpm_view->details->package_file_tree), 0, temp_str);
nautilus_clist_set_column_title (NAUTILUS_CLIST(rpm_view->details->package_file_tree), 0, temp_str);
g_free(temp_str);
gtk_clist_thaw(GTK_CLIST(rpm_view->details->package_file_tree));
nautilus_clist_thaw(NAUTILUS_CLIST(rpm_view->details->package_file_tree));
temp_str = g_strdup_printf(_("Package \"%s\" "), rpm_view->details->package->name);
gtk_label_set_text (GTK_LABEL (rpm_view->details->package_title), temp_str);

View file

@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000, 2001 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
@ -26,25 +26,19 @@
#include <config.h>
#include "nautilus-tree-view.h"
#include "nautilus-tree-view-iids.h"
#include <liboaf/liboaf.h>
#include "nautilus-tree-view.h"
#include <bonobo.h>
#include <liboaf/liboaf.h>
/* FIXME bugzilla.eazel.com 2736: oaf_plugin_unuse can't possibly work! this sucks */
#if 0
static void
tree_shlib_object_destroyed (GtkObject *object)
{
/* FIXME bugzilla.eazel.com 2736: oaf_plugin_unuse can't possibly work! this sucks */
#if 0
oaf_plugin_unuse (gtk_object_get_user_data (object));
#endif
}
#endif
static CORBA_Object
tree_shlib_make_object (PortableServer_POA poa,
@ -53,8 +47,6 @@ tree_shlib_make_object (PortableServer_POA poa,
CORBA_Environment *ev)
{
NautilusTreeView *view;
NautilusView *nautilus_view;
if (strcmp (iid, TREE_VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
@ -62,32 +54,22 @@ tree_shlib_make_object (PortableServer_POA poa,
view = NAUTILUS_TREE_VIEW (gtk_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
nautilus_view = nautilus_tree_view_get_nautilus_view (view);
gtk_signal_connect (GTK_OBJECT (nautilus_view), "destroy", tree_shlib_object_destroyed, NULL);
gtk_object_set_user_data (GTK_OBJECT (nautilus_view), impl_ptr);
#if 0
gtk_signal_connect (GTK_OBJECT (view), "destroy", tree_shlib_object_destroyed, NULL);
#endif
oaf_plugin_use (poa, impl_ptr);
return CORBA_Object_duplicate (bonobo_object_corba_objref
(BONOBO_OBJECT (nautilus_view)), ev);
(BONOBO_OBJECT (view)), ev);
}
static const OAFPluginObject tree_plugin_list[] = {
{
TREE_VIEW_IID,
tree_shlib_make_object
},
{
NULL
}
{ TREE_VIEW_IID, tree_shlib_make_object },
{ NULL }
};
const OAFPlugin OAF_Plugin_info = {
tree_plugin_list,
"Nautilus Tree Sidebar Panel"
};

View file

@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000, 2001 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
@ -21,111 +21,25 @@
* Author: Maciej Stachowiak
*/
/* main.c - main function and object activation function for sample
content view component. */
#include <config.h>
#include "nautilus-tree-view.h"
#include "nautilus-tree-view-iids.h"
#include <libnautilus-extensions/nautilus-debug.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-init.h>
#include <liboaf/liboaf.h>
#include <bonobo.h>
#include <libgnomevfs/gnome-vfs.h>
static int object_count = 0;
static void
tree_exe_object_destroyed (GtkObject *object)
{
object_count--;
if (object_count <= 0) {
gtk_main_quit ();
}
}
static BonoboObject *
tree_exe_make_object (BonoboGenericFactory *factory,
const char *iid,
void *closure)
{
NautilusTreeView *view;
NautilusView *nautilus_view;
if (strcmp (iid, TREE_VIEW_IID)) {
return NULL;
}
view = NAUTILUS_TREE_VIEW (gtk_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
object_count++;
nautilus_view = nautilus_tree_view_get_nautilus_view (view);
gtk_signal_connect (GTK_OBJECT (nautilus_view), "destroy", tree_exe_object_destroyed, NULL);
return BONOBO_OBJECT (nautilus_view);
}
#include "nautilus-tree-view.h"
#include <libnautilus/nautilus-view-standard-main.h>
int
main (int argc, char *argv[])
{
CORBA_ORB orb;
BonoboGenericFactory *factory;
char *registration_id;
/* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set.
* Unfortunately, this has to be done explicitly for each domain.
*/
if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
nautilus_make_warnings_and_criticals_stop_in_debugger
(G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL);
}
/* Initialize gettext support */
#ifdef ENABLE_NLS /* sadly we need this ifdef because otherwise the following get empty statement warnings */
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
#endif
/* Disable session manager connection */
gnome_client_disable_master_connection ();
/* Initialize the services that we use. */
g_thread_init (NULL);
gnomelib_register_popt_table (oaf_popt_options, oaf_get_popt_table_name ());
orb = oaf_init (argc, argv);
gnome_init_with_popt_table("nautilus-tree-view", VERSION,
argc, argv);
gdk_rgb_init ();
gnome_vfs_init ();
bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);
registration_id = oaf_make_registration_id (TREE_VIEW_FACTORY_IID, g_getenv ("DISPLAY"));
factory = bonobo_generic_factory_new_multi (registration_id, tree_exe_make_object, NULL);
g_free (registration_id);
do {
bonobo_main ();
} while (object_count > 0);
gnome_vfs_shutdown ();
return 0;
return nautilus_view_standard_main ("nautilus-tree-view", VERSION,
argc, argv,
TREE_VIEW_FACTORY_IID,
TREE_VIEW_IID,
nautilus_view_create_from_get_type_function,
nautilus_tree_view_get_type);
}

View file

@ -41,7 +41,6 @@ typedef struct NautilusTreeChangeQueueClass NautilusTreeChangeQueueClass;
typedef enum {
NAUTILUS_TREE_CHANGE_TYPE_ADDED,
NAUTILUS_TREE_CHANGE_TYPE_CHANGED,
NAUTILUS_TREE_CHANGE_TYPE_REMOVED,
NAUTILUS_TREE_CHANGE_TYPE_DONE_LOADING

View file

@ -30,12 +30,12 @@
#include <gtk/gtksignal.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-extensions/nautilus-file-attributes.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <stdio.h>
#include <string.h>
enum {
NODE_ADDED,
NODE_CHANGED,
NODE_REMOVED,
NODE_BEING_RENAMED,
@ -55,6 +55,9 @@ struct NautilusTreeModelDetails {
NautilusTreeNode *root_node;
gboolean root_node_reported;
gint root_node_changed_signal_id;
GHashTable *changed_files;
GHashTable *done_loading_files;
};
@ -85,9 +88,6 @@ static void nautilus_tree_model_root_node_file_monitor (NautilusFile
static void nautilus_tree_model_directory_files_changed_callback (NautilusDirectory *directory,
GList *added_files,
NautilusTreeModel *model);
static void nautilus_tree_model_directory_files_added_callback (NautilusDirectory *directory,
GList *added_files,
NautilusTreeModel *model);
static void nautilus_tree_model_directory_done_loading_callback (NautilusDirectory *directory,
NautilusTreeModel *model);
@ -105,14 +105,6 @@ nautilus_tree_model_initialize_class (gpointer klass)
object_class->destroy = nautilus_tree_model_destroy;
signals[NODE_ADDED] =
gtk_signal_new ("node_added",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusTreeModelClass, node_added),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
signals[NODE_CHANGED] =
gtk_signal_new ("node_changed",
GTK_RUN_LAST,
@ -161,6 +153,18 @@ nautilus_tree_model_initialize (gpointer object, gpointer klass)
model->details->file_to_node_map = g_hash_table_new (NULL, NULL);
}
static void
destroy_file_hash (GHashTable *hash)
{
if (hash == NULL) {
return;
}
nautilus_g_hash_table_destroy_deep_custom
(hash,
(GFunc) nautilus_file_unref, NULL,
NULL, NULL);
}
static void
nautilus_tree_model_destroy (GtkObject *object)
{
@ -180,6 +184,9 @@ nautilus_tree_model_destroy (GtkObject *object)
g_hash_table_destroy (model->details->file_to_node_map);
destroy_file_hash (model->details->changed_files);
destroy_file_hash (model->details->done_loading_files);
g_free (model->details);
NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
@ -428,7 +435,7 @@ nautilus_tree_model_node_begin_monitoring (NautilusTreeModel *model,
node->details->files_added_id = gtk_signal_connect
(GTK_OBJECT (directory),
"files_added",
nautilus_tree_model_directory_files_added_callback,
nautilus_tree_model_directory_files_changed_callback,
model);
node->details->files_changed_id = gtk_signal_connect
@ -760,7 +767,7 @@ report_node_changed (NautilusTreeModel *model,
node);
gtk_signal_emit (GTK_OBJECT (model),
signals[NODE_ADDED],
signals[NODE_CHANGED],
node);
connect_unparented_nodes (model, node);
@ -889,6 +896,50 @@ nautilus_tree_model_root_node_file_monitor (NautilusFile *file,
}
}
static void
process_file_change (NautilusTreeModel *model,
NautilusFile *file)
{
NautilusTreeNode *node;
node = nautilus_tree_model_get_node_from_file (model, file);
if (nautilus_file_is_gone (file)) {
if (node != NULL) {
report_node_removed (model, node);
}
} else {
if (node == NULL) {
node = nautilus_tree_node_new (file);
} else {
gtk_object_ref (GTK_OBJECT (node));
}
report_node_changed (model, node);
gtk_object_unref (GTK_OBJECT (node));
}
}
static void
process_directory_done_loading (NautilusTreeModel *model,
NautilusFile *file)
{
NautilusTreeNode *node;
node = nautilus_tree_model_get_node_from_file (model, file);
if (node != NULL) {
report_done_loading (model, node);
}
}
static void
add_file_to_hash (GHashTable *hash,
NautilusFile *file)
{
if (g_hash_table_lookup (hash, file) == NULL) {
nautilus_file_ref (file);
g_hash_table_insert (hash, file, file);
}
}
static void
nautilus_tree_model_directory_files_changed_callback (NautilusDirectory *directory,
@ -897,81 +948,88 @@ nautilus_tree_model_directory_files_changed_callback (NautilusDirectory *
{
GList *p;
NautilusFile *file;
NautilusTreeNode *node;
char *uri;
for (p = changed_files; p != NULL; p = p->next) {
file = NAUTILUS_FILE (p->data);
node = nautilus_tree_model_get_node_from_file (model, file);
if (node == NULL) {
/* Do we need to add this node? */
uri = nautilus_file_get_uri (file);
g_free (uri);
if (model->details->changed_files != NULL) {
add_file_to_hash (model->details->changed_files, file);
} else {
if (nautilus_file_is_gone (file)) {
report_node_removed (model, node);
} else if (!nautilus_directory_contains_file (directory, file)) {
/* Let the view propagate the expansion state */
uri = nautilus_file_get_uri (file);
gtk_signal_emit (GTK_OBJECT (model),
signals[NODE_BEING_RENAMED],
node->details->uri, uri);
g_free (uri);
/* then remove the node - the added callback will get invoked
* after this function returns
*/
report_node_removed (model, node);
} else {
report_node_changed (model, node);
}
process_file_change (model, file);
}
}
}
static void
nautilus_tree_model_directory_files_added_callback (NautilusDirectory *directory,
GList *added_files,
NautilusTreeModel *model)
{
GList *p;
NautilusFile *file;
NautilusTreeNode *node;
for (p = added_files; p != NULL; p = p->next) {
file = (NautilusFile *) p->data;
node = nautilus_tree_model_get_node_from_file (model, file);
if (node == NULL) {
node = nautilus_tree_node_new (file);
} else {
gtk_object_ref (GTK_OBJECT (node));
}
report_node_changed (model, node);
gtk_object_unref (GTK_OBJECT (node));
}
}
static void
nautilus_tree_model_directory_done_loading_callback (NautilusDirectory *directory,
NautilusTreeModel *model)
{
NautilusFile *file;
NautilusTreeNode *node;
file = nautilus_directory_get_corresponding_file (directory);
node = nautilus_tree_model_get_node_from_file (model, file);
nautilus_file_unref (file);
if (node != NULL) {
report_done_loading (model, node);
if (model->details->done_loading_files != NULL) {
add_file_to_hash (model->details->done_loading_files, file);
} else {
g_warning ("Got done loading notification for nonexistent node %s", nautilus_directory_get_uri (directory));
process_directory_done_loading (model, file);
}
nautilus_file_unref (file);
}
static void
process_one_changed_file (gpointer key, gpointer value, gpointer callback_data)
{
g_assert (NAUTILUS_IS_FILE (key));
g_assert (key == value);
g_assert (NAUTILUS_IS_TREE_MODEL (callback_data));
process_file_change (callback_data, key);
}
static void
process_one_done_loading_file (gpointer key, gpointer value, gpointer callback_data)
{
g_assert (NAUTILUS_IS_FILE (key));
g_assert (key == value);
g_assert (NAUTILUS_IS_TREE_MODEL (callback_data));
process_directory_done_loading (callback_data, key);
}
void
nautilus_tree_model_set_defer_notifications (NautilusTreeModel *model,
gboolean defer)
{
gboolean already_deferring;
GHashTable *changed, *done_loading;
g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
g_return_if_fail (defer == FALSE || defer == TRUE);
already_deferring = model->details->changed_files != NULL;
if (already_deferring == defer) {
return;
}
if (defer) {
model->details->changed_files = g_hash_table_new (NULL, NULL);
model->details->done_loading_files = g_hash_table_new (NULL, NULL);
} else {
changed = model->details->changed_files;
done_loading = model->details->done_loading_files;
model->details->changed_files = NULL;
model->details->done_loading_files = NULL;
g_hash_table_foreach (changed,
process_one_changed_file,
model);
g_hash_table_foreach (done_loading,
process_one_done_loading_file,
model);
destroy_file_hash (changed);
destroy_file_hash (done_loading);
}
}

View file

@ -49,9 +49,6 @@ struct NautilusTreeModel {
struct NautilusTreeModelClass {
GtkObjectClass parent_class;
void (*node_added) (NautilusTreeModel *model,
NautilusTreeNode *node);
void (*node_changed) (NautilusTreeModel *model,
NautilusTreeNode *node);
@ -93,11 +90,9 @@ void nautilus_tree_model_stop_monitoring_node (NautilusTreeMod
NautilusTreeNode *node,
gconstpointer client);
void
nautilus_tree_model_stop_monitoring_node_recursive (NautilusTreeModel *model,
NautilusTreeNode *node,
gconstpointer client);
void nautilus_tree_model_stop_monitoring_node_recursive (NautilusTreeModel *model,
NautilusTreeNode *node,
gconstpointer client);
NautilusTreeNode *nautilus_tree_model_get_node (NautilusTreeModel *model,
const char *uri);
@ -114,6 +109,9 @@ NautilusTreeNode *nautilus_tree_model_get_nearest_parent_node (NautilusTreeMod
NautilusTreeNode *nautilus_tree_model_get_root_node (NautilusTreeModel *model);
#endif
void nautilus_tree_model_set_defer_notifications (NautilusTreeModel *model,
gboolean defer);
/* Debugging */
void nautilus_tree_model_dump_files (NautilusTreeModel *model);

View file

@ -28,19 +28,17 @@
#include <config.h>
#include "nautilus-tree-view-dnd.h"
#include <gtk/gtksignal.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-drag.h>
#include <libnautilus-extensions/nautilus-file-operations.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-drag.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-file-operations.h>
#define nopeMATHIEU_DEBUG 1
/* This constant is zero because right now it does not seem we need
extra delay on horizontal-only auto-scroll. However, it's left in
@ -126,9 +124,6 @@ static void nautilus_tree_view_receive_dropped_icons (NautilusTreeView
int x,
int y);
static void nautilus_tree_view_make_prelight_if_file_operation (NautilusTreeView *tree_view,
int x,
int y);
static void nautilus_tree_view_ensure_drag_data (NautilusTreeView *tree_view,
GdkDragContext *context,
guint32 time);
@ -299,7 +294,7 @@ nautilus_tree_view_drag_begin (GtkWidget *widget, GdkDragContext *context,
dnd->drag_info->got_drop_data_type = FALSE;
nautilus_tree_view_set_dnd_icon (NAUTILUS_TREE_VIEW (tree_view), context);
nautilus_tree_view_set_dnd_icon (tree_view, context);
}
@ -365,9 +360,6 @@ nautilus_tree_view_drag_motion (GtkWidget *widget, GdkDragContext *context,
nautilus_ctree_set_prelight (NAUTILUS_CTREE (tree_view->details->tree),
y);
nautilus_tree_view_make_prelight_if_file_operation (NAUTILUS_TREE_VIEW (tree_view),
x, y);
break;
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_COLOR:
@ -413,7 +405,7 @@ get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context,
if (gtk_target_list_find (nautilus_tree_view_dnd_target_list,
target_atom,
&dummy_info)) {
gtk_drag_get_data (GTK_WIDGET (widget), context,
gtk_drag_get_data (widget, context,
target_atom,
time);
break;
@ -562,12 +554,12 @@ static int
nautilus_tree_view_button_press (GtkWidget *widget, GdkEventButton *event)
{
int retval;
GtkCList *clist;
NautilusCList *clist;
NautilusTreeView *tree_view;
int press_row, press_column, on_row;
clist = GTK_CLIST (widget);
clist = NAUTILUS_CLIST (widget);
retval = FALSE;
if (event->window != clist->clist_window)
@ -575,10 +567,10 @@ nautilus_tree_view_button_press (GtkWidget *widget, GdkEventButton *event)
tree_view = NAUTILUS_TREE_VIEW (gtk_object_get_data (GTK_OBJECT (widget), "tree_view"));
on_row = gtk_clist_get_selection_info (GTK_CLIST (tree_view->details->tree),
event->x,
event->y,
&press_row, &press_column);
on_row = nautilus_clist_get_selection_info (clist,
event->x,
event->y,
&press_row, &press_column);
if (on_row == 0) {
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button-press-event");
return FALSE;
@ -631,7 +623,7 @@ static int
nautilus_tree_view_button_release (GtkWidget *widget, GdkEventButton *event)
{
int retval;
GtkCList *clist;
NautilusCList *clist;
NautilusTreeView *tree_view;
int release_row, release_column, on_row;
int distance_squared;
@ -640,7 +632,7 @@ nautilus_tree_view_button_release (GtkWidget *widget, GdkEventButton *event)
NautilusCTreeRow *ctree_row;
NautilusCTreeNode *node;
clist = GTK_CLIST (widget);
clist = NAUTILUS_CLIST (widget);
retval = FALSE;
if (event->window != clist->clist_window)
@ -651,10 +643,10 @@ nautilus_tree_view_button_release (GtkWidget *widget, GdkEventButton *event)
/* Set state of spinner. Use saved dnd x and y as the mouse may have moved out
* of the original row */
on_row = gtk_clist_get_selection_info (GTK_CLIST (tree_view->details->tree),
tree_view->details->dnd->press_x,
tree_view->details->dnd->press_y,
&press_row, &press_column);
on_row = nautilus_clist_get_selection_info (clist,
tree_view->details->dnd->press_x,
tree_view->details->dnd->press_y,
&press_row, &press_column);
ctree_row = ROW_ELEMENT (clist, press_row)->data;
if (ctree_row != NULL) {
ctree_row->mouse_down = FALSE;
@ -674,10 +666,10 @@ nautilus_tree_view_button_release (GtkWidget *widget, GdkEventButton *event)
is_still_hot_spot = nautilus_ctree_is_hot_spot (NAUTILUS_CTREE(tree_view->details->tree),
event->x, event->y);
on_row = gtk_clist_get_selection_info (GTK_CLIST (tree_view->details->tree),
event->x,
event->y,
&release_row, &release_column);
on_row = nautilus_clist_get_selection_info (clist,
event->x,
event->y,
&release_row, &release_column);
if (on_row == 1) {
@ -695,8 +687,8 @@ nautilus_tree_view_button_release (GtkWidget *widget, GdkEventButton *event)
/* Only button 1 triggers a selection */
if (event->button == 1) {
gtk_clist_select_row (GTK_CLIST (tree_view->details->tree),
release_row, release_column);
nautilus_clist_select_row (clist,
release_row, release_column);
}
}
}
@ -712,10 +704,10 @@ nautilus_tree_view_button_release (GtkWidget *widget, GdkEventButton *event)
static int
nautilus_tree_view_motion_notify (GtkWidget *widget, GdkEventButton *event)
{
GtkCList *clist;
NautilusCList *clist;
NautilusTreeView *tree_view;
clist = GTK_CLIST (widget);
clist = NAUTILUS_CLIST (widget);
if (event->window != clist->clist_window)
@ -784,13 +776,11 @@ nautilus_tree_view_motion_notify (GtkWidget *widget, GdkEventButton *event)
static void
nautilus_tree_view_set_dnd_icon (NautilusTreeView *tree_view, GdkDragContext *context)
{
GdkPixmap *pixmap;
GdkBitmap *mask;
GdkPixbuf *pixbuf;
NautilusCTreeNode *node;
gchar *text;
guint8 spacing;
GdkPixmap *pixmap_opened;
GdkBitmap *mask_opened;
GdkPixbuf *pixbuf_opened;
gboolean is_leaf;
gboolean expanded;
NautilusTreeViewDndDetails *dnd;
@ -806,56 +796,12 @@ nautilus_tree_view_set_dnd_icon (NautilusTreeView *tree_view, GdkDragContext *co
nautilus_ctree_get_node_info (NAUTILUS_CTREE (tree_view->details->tree),
node, &text,
&spacing, &pixmap,
&mask, &pixmap_opened,
&mask_opened, &is_leaf,
&spacing, &pixbuf,
&pixbuf_opened, &is_leaf,
&expanded);
gtk_drag_set_icon_pixmap (context,
gdk_rgb_get_cmap (),
pixmap, mask,
10, 10);
}
static void
nautilus_tree_view_make_prelight_if_file_operation (NautilusTreeView *tree_view,
int x, int y)
{
#if 0
NautilusTreeViewDndDetails *dnd;
NautilusCTreeNode *node;
gboolean is_directory;
g_assert (NAUTILUS_IS_TREE_VIEW (tree_view));
dnd = tree_view->details->dnd;
/* make the thing under us prelighted. */
node = nautilus_tree_view_tree_node_at (NAUTILUS_TREE_VIEW (tree_view), x, y);
if (node == NULL) {
return;
}
is_directory = nautilus_tree_view_is_tree_node_directory (NAUTILUS_TREE_VIEW (tree_view), node);
if (!is_directory) {
NautilusTreeNode *parent_node, *current_node;
current_node = nautilus_tree_view_node_to_model_node (tree_view, node);
parent_node = nautilus_tree_node_get_parent (current_node);
node = nautilus_tree_view_model_node_to_view_node (tree_view, parent_node);
}
if (node != dnd->current_prelighted_node
&& dnd->current_prelighted_node != NULL) {
nautilus_ctree_node_set_row_style (NAUTILUS_CTREE (tree_view->details->tree),
dnd->current_prelighted_node,
tree_view->details->dnd->normal_style);
}
nautilus_ctree_node_set_row_style (NAUTILUS_CTREE (tree_view->details->tree),
node,
tree_view->details->dnd->highlight_style);
dnd->current_prelighted_node = node;
#endif
/* FIXME: We can do better than 10,10 for the hot spot. */
nautilus_drag_set_icon_pixbuf (context, pixbuf, 10, 10);
}
@ -866,17 +812,15 @@ nautilus_tree_view_collapse_node (NautilusCTree *tree, NautilusCTreeNode *node)
{
char *node_text;
guint8 node_spacing;
GdkPixmap *pixmap_closed;
GdkBitmap *mask_closed;
GdkPixmap *pixmap_opened;
GdkBitmap *mask_opened;
GdkPixbuf *pixbuf_closed;
GdkPixbuf *pixbuf_opened;
gboolean is_leaf;
gboolean is_expanded;
nautilus_ctree_get_node_info (NAUTILUS_CTREE(tree),
node, &node_text,
&node_spacing, &pixmap_closed, &mask_closed,
&pixmap_opened, &mask_opened,
&node_spacing, &pixbuf_closed,
&pixbuf_opened,
&is_leaf, &is_expanded);
if (is_expanded) {
/* collapse */
@ -894,18 +838,16 @@ nautilus_tree_view_expand_or_collapse_row (NautilusCTree *tree, int row)
NautilusCTreeNode *node;
char *node_text;
guint8 node_spacing;
GdkPixmap *pixmap_closed;
GdkBitmap *mask_closed;
GdkPixmap *pixmap_opened;
GdkBitmap *mask_opened;
GdkPixbuf *pixbuf_closed;
GdkPixbuf *pixbuf_opened;
gboolean is_leaf;
gboolean is_expanded;
node = nautilus_ctree_node_nth (NAUTILUS_CTREE(tree), row);
nautilus_ctree_get_node_info (NAUTILUS_CTREE(tree),
node, &node_text,
&node_spacing, &pixmap_closed, &mask_closed,
&pixmap_opened, &mask_opened,
&node_spacing, &pixbuf_closed,
&pixbuf_opened,
&is_leaf, &is_expanded);
if (!is_expanded) {
/* expand */
@ -1007,13 +949,13 @@ nautilus_tree_view_tree_node_at (NautilusTreeView *tree_view,
NautilusCTreeNode *node;
on_row = gtk_clist_get_selection_info (GTK_CLIST (tree_view->details->tree),
x, y, &row, &column);
on_row = nautilus_clist_get_selection_info (NAUTILUS_CLIST (tree_view->details->tree),
x, y, &row, &column);
node = NULL;
if (on_row == 1) {
node = nautilus_ctree_node_nth (NAUTILUS_CTREE (tree_view->details->tree),
row);
row);
}
return node;
@ -1098,12 +1040,10 @@ auto_scroll_timeout_callback (gpointer data)
{
NautilusDragInfo *drag_info;
NautilusTreeView *tree_view;
GtkWidget *widget;
float x_scroll_delta, y_scroll_delta;
g_assert (NAUTILUS_IS_TREE_VIEW (data));
widget = GTK_WIDGET (data);
tree_view = NAUTILUS_TREE_VIEW (widget);
tree_view = NAUTILUS_TREE_VIEW (data);
drag_info = tree_view->details->dnd->drag_info;
nautilus_drag_autoscroll_calculate_delta (tree_view->details->tree, &x_scroll_delta, &y_scroll_delta);
@ -1143,24 +1083,19 @@ nautilus_tree_view_stop_auto_scroll (NautilusTreeView *tree_view)
nautilus_drag_autoscroll_stop (tree_view->details->dnd->drag_info);
}
static void
nautilus_tree_view_real_scroll (NautilusTreeView *tree_view, float delta_x, float delta_y)
{
GtkAdjustment *hadj, *vadj;
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (tree_view));
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tree_view));
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (tree_view->details->scrolled_window));
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tree_view->details->scrolled_window));
nautilus_gtk_adjustment_set_value (hadj, hadj->value + delta_x);
nautilus_gtk_adjustment_set_value (vadj, vadj->value + delta_y);
}
/******************************************
* Handle the data dropped on the tree view
******************************************/
@ -1232,19 +1167,6 @@ nautilus_tree_view_collapse_all (NautilusTreeView *tree_view,
expanded_node = (NautilusCTreeNode *) temp_list->data;
if (!nautilus_ctree_is_ancestor (NAUTILUS_CTREE (tree_view->details->tree),
expanded_node, current_node)) {
#ifdef MATHIEU_DEBUG
{
char *expanded_uri, *current_uri;
expanded_uri = nautilus_file_get_uri
(nautilus_tree_view_node_to_file (tree_view, expanded_node));
current_uri = nautilus_file_get_uri
(nautilus_tree_view_node_to_file (tree_view, current_node));
g_print ("collapsing %s in %s\n", expanded_uri, current_uri);
g_free (expanded_uri);
g_free (current_uri);
}
#endif
nautilus_tree_view_collapse_node (NAUTILUS_CTREE (tree_view->details->tree),
expanded_node);
}
@ -1289,28 +1211,6 @@ nautilus_tree_view_receive_dropped_icons (NautilusTreeView *view,
return;
}
#ifdef MATHIEU_DEBUG
{
char *action_string;
switch (context->action) {
case GDK_ACTION_MOVE:
action_string = "move";
break;
case GDK_ACTION_COPY:
action_string = "copy";
break;
case GDK_ACTION_LINK:
action_string = "link";
break;
default:
g_assert_not_reached ();
action_string = "error";
break;
}
g_print ("%s selection in %s\n",
action_string, drop_target_uri);
}
#endif
nautilus_tree_view_move_copy_files (tree_view, drag_info->selection_list,
context, drop_target_uri);
/* collapse all expanded directories during drag except the one we
@ -1328,26 +1228,6 @@ nautilus_tree_view_receive_dropped_icons (NautilusTreeView *view,
}
static void
nautilus_tree_view_prelight_stop (NautilusTreeView *tree_view)
{
#if 0
NautilusTreeViewDndDetails *dnd;
g_assert (NAUTILUS_IS_TREE_VIEW (tree_view));
dnd = tree_view->details->dnd;
if (dnd->current_prelighted_node != NULL) {
nautilus_ctree_node_set_row_style (NAUTILUS_CTREE (tree_view->details->tree),
dnd->current_prelighted_node,
tree_view->details->dnd->normal_style);
}
dnd->current_prelighted_node = NULL;
#endif
}
static void
nautilus_tree_view_drag_destroy (NautilusTreeView *tree_view)
@ -1368,7 +1248,6 @@ nautilus_tree_view_drag_destroy (NautilusTreeView *tree_view)
/* remove prelighting */
nautilus_ctree_set_prelight (NAUTILUS_CTREE (tree_view->details->tree),
-1);
nautilus_tree_view_prelight_stop (tree_view);
}
@ -1388,19 +1267,8 @@ nautilus_tree_view_drag_destroy_real (NautilusTreeView *tree_view)
nautilus_drag_destroy_selection_list (drag_info->selection_list);
drag_info->drop_occured = FALSE;
/* misc stuff */
/*
if (dnd_info->shadow != NULL) {
gtk_object_destroy (GTK_OBJECT (dnd_info->shadow));
dnd_info->shadow = NULL;
}
*/
if (drag_info->selection_data != NULL) {
nautilus_gtk_selection_data_free_deep (drag_info->selection_data);
drag_info->selection_data = NULL;
}
}

View file

@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000, 2001 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
@ -35,8 +35,6 @@
typedef struct NautilusTreeViewDndDetails NautilusTreeViewDndDetails;
typedef void (*TreeViewCallback) (NautilusTreeView *view);
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
(clist)->row_list_end : \
g_list_nth ((clist)->row_list, (row)))
@ -47,6 +45,7 @@ typedef void (*TreeViewCallback) (NautilusTreeView *view);
struct NautilusTreeViewDetails {
NautilusView *nautilus_view;
GtkWidget *scrolled_window;
GtkWidget *tree;
NautilusTreeModel *model;
@ -67,10 +66,8 @@ struct NautilusTreeViewDetails {
GList *unparented_tree_nodes;
TreeViewCallback root_seen_callback;
char *wait_uri;
NautilusTreeNode *wait_node;
TreeViewCallback uri_loaded_or_parent_done_loading;
GList *in_progress_select_uris;
gboolean root_seen;

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000, 2001 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
@ -28,7 +28,6 @@
#define NAUTILUS_TREE_VIEW_H
#include <libnautilus/nautilus-view.h>
#include <gtk/gtkscrolledwindow.h>
typedef struct NautilusTreeView NautilusTreeView;
typedef struct NautilusTreeViewClass NautilusTreeViewClass;
@ -42,21 +41,14 @@ typedef struct NautilusTreeViewClass NautilusTreeViewClass;
typedef struct NautilusTreeViewDetails NautilusTreeViewDetails;
struct NautilusTreeView {
GtkScrolledWindow parent;
NautilusView parent;
NautilusTreeViewDetails *details;
};
struct NautilusTreeViewClass {
GtkScrolledWindowClass parent_class;
NautilusViewClass parent_class;
};
/* GtkObject support */
GtkType nautilus_tree_view_get_type (void);
/* Component embedding support */
NautilusView *nautilus_tree_view_get_nautilus_view (NautilusTreeView *view);
GtkType nautilus_tree_view_get_type (void);
#endif /* NAUTILUS_TREE_VIEW_H */

View file

@ -379,15 +379,6 @@ static void get_cell_style (NautilusCList *clist,
GtkStyle **style,
GdkGC **fg_gc,
GdkGC **bg_gc);
static gint draw_cell_pixmap (GdkWindow *window,
GdkRectangle *clip_rectangle,
GdkGC *fg_gc,
GdkPixmap *pixmap,
GdkBitmap *mask,
gint x,
gint y,
gint width,
gint height);
static void draw_row (NautilusCList *clist,
GdkRectangle *area,
gint row,
@ -416,14 +407,13 @@ static void columns_delete (NautilusCList *clist);
static NautilusCListRow *row_new (NautilusCList *clist);
static void row_delete (NautilusCList *clist,
NautilusCListRow *clist_row);
static void set_cell_contents (NautilusCList *clist,
static gboolean set_cell_contents (NautilusCList *clist,
NautilusCListRow *clist_row,
gint column,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
static gint real_insert_row (NautilusCList *clist,
gint row,
gchar *text[]);
@ -1708,7 +1698,7 @@ nautilus_clist_optimal_column_width (NautilusCList *clist,
if (NAUTILUS_CLIST_SHOW_TITLES(clist) && clist->column[column].button)
width = (clist->column[column].button->requisition.width)
#if 0
(CELL_SPACING + (2 * COLUMN_INSET)))
+ (CELL_SPACING + (2 * COLUMN_INSET))
#endif
;
else
@ -2162,8 +2152,8 @@ column_title_passive_func (GtkWidget *widget,
* nautilus_clist_get_cell_type
* nautilus_clist_set_text
* nautilus_clist_get_text
* nautilus_clist_set_pixmap
* nautilus_clist_get_pixmap
* nautilus_clist_set_pixbuf
* nautilus_clist_get_pixbuf
* nautilus_clist_set_pixtext
* nautilus_clist_get_pixtext
* nautilus_clist_set_shift
@ -2207,14 +2197,15 @@ nautilus_clist_set_text (NautilusCList *clist,
clist_row = ROW_ELEMENT (clist, row)->data;
/* if text is null, then the cell is empty */
NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, column, NAUTILUS_CELL_TEXT, text, 0, NULL, NULL);
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
if (NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, column, NAUTILUS_CELL_TEXT, text, 0, NULL))
{
if (nautilus_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (nautilus_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
}
}
}
@ -2236,7 +2227,8 @@ nautilus_clist_get_text (NautilusCList *clist,
clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->cell[column].type != NAUTILUS_CELL_TEXT)
if (clist_row->cell[column].type != NAUTILUS_CELL_TEXT
&& clist_row->cell[column].type != NAUTILUS_CELL_LINK_TEXT)
return 0;
if (text)
@ -2246,11 +2238,10 @@ nautilus_clist_get_text (NautilusCList *clist,
}
void
nautilus_clist_set_pixmap (NautilusCList *clist,
nautilus_clist_set_pixbuf (NautilusCList *clist,
gint row,
gint column,
GdkPixmap *pixmap,
GdkBitmap *mask)
GdkPixbuf *pixbuf)
{
NautilusCListRow *clist_row;
@ -2264,27 +2255,23 @@ nautilus_clist_set_pixmap (NautilusCList *clist,
clist_row = ROW_ELEMENT (clist, row)->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, column, NAUTILUS_CELL_PIXMAP, NULL, 0, pixmap, mask);
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
if (NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, column, NAUTILUS_CELL_PIXBUF, NULL, 0, pixbuf))
{
if (nautilus_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (nautilus_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
}
}
}
gint
nautilus_clist_get_pixmap (NautilusCList *clist,
nautilus_clist_get_pixbuf (NautilusCList *clist,
gint row,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask)
GdkPixbuf **pixbuf)
{
NautilusCListRow *clist_row;
@ -2298,14 +2285,12 @@ nautilus_clist_get_pixmap (NautilusCList *clist,
clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->cell[column].type != NAUTILUS_CELL_PIXMAP)
if (clist_row->cell[column].type != NAUTILUS_CELL_PIXBUF)
return 0;
if (pixmap)
if (pixbuf)
{
*pixmap = NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->pixmap;
/* mask can be NULL */
*mask = NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->mask;
*pixbuf = NAUTILUS_CELL_PIXBUF (clist_row->cell[column])->pixbuf;
}
return 1;
@ -2317,8 +2302,7 @@ nautilus_clist_set_pixtext (NautilusCList *clist,
gint column,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask)
GdkPixbuf *pixbuf)
{
NautilusCListRow *clist_row;
@ -2332,16 +2316,15 @@ nautilus_clist_set_pixtext (NautilusCList *clist,
clist_row = ROW_ELEMENT (clist, row)->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, column, NAUTILUS_CELL_PIXTEXT, text, spacing, pixmap, mask);
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
if (NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, column, NAUTILUS_CELL_PIXTEXT, text, spacing, pixbuf))
{
if (nautilus_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (nautilus_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
}
}
}
@ -2351,8 +2334,7 @@ nautilus_clist_get_pixtext (NautilusCList *clist,
gint column,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap,
GdkBitmap **mask)
GdkPixbuf **pixbuf)
{
NautilusCListRow *clist_row;
@ -2373,11 +2355,8 @@ nautilus_clist_get_pixtext (NautilusCList *clist,
*text = NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->text;
if (spacing)
*spacing = NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->spacing;
if (pixmap)
*pixmap = NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixmap;
/* mask can be NULL */
*mask = NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->mask;
if (pixbuf)
*pixbuf = NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixbuf;
return 1;
}
@ -2420,47 +2399,88 @@ nautilus_clist_set_shift (NautilusCList *clist,
* set_cell_contents
* cell_size_request
*/
static void
static gboolean
set_cell_contents (NautilusCList *clist,
NautilusCListRow *clist_row,
gint column,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask)
GdkPixbuf *pixbuf)
{
GtkRequisition requisition;
g_return_if_fail (clist != NULL);
g_return_if_fail (NAUTILUS_IS_CLIST (clist));
g_return_if_fail (clist_row != NULL);
g_return_val_if_fail (NAUTILUS_IS_CLIST (clist), FALSE);
g_return_val_if_fail (clist_row != NULL, FALSE);
if (type == clist_row->cell[column].type)
{
switch (type)
{
case NAUTILUS_CELL_EMPTY:
return FALSE;
case NAUTILUS_CELL_TEXT:
case NAUTILUS_CELL_LINK_TEXT:
if (NAUTILUS_CELL_TEXT (clist_row->cell[column])->text == NULL)
{
if (text == NULL)
return FALSE;
}
else
{
if (text != NULL && strcmp (NAUTILUS_CELL_TEXT (clist_row->cell[column])->text, text) == 0)
return FALSE;
}
break;
case NAUTILUS_CELL_PIXBUF:
if (pixbuf == NAUTILUS_CELL_PIXBUF (clist_row->cell[column])->pixbuf)
return FALSE;
break;
case NAUTILUS_CELL_PIXTEXT:
if (pixbuf == NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixbuf)
{
if (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->text == NULL)
{
if (text == NULL)
return FALSE;
}
else
{
if (text != NULL && strcmp (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->text, text) == 0)
return FALSE;
}
}
break;
case NAUTILUS_CELL_WIDGET:
/* unimplemented */
break;
default:
break;
}
}
if (clist->column[column].auto_resize &&
!NAUTILUS_CLIST_AUTO_RESIZE_BLOCKED(clist))
NAUTILUS_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
column, &requisition);
column, &requisition);
switch (clist_row->cell[column].type)
{
case NAUTILUS_CELL_EMPTY:
break;
case NAUTILUS_CELL_TEXT:
case NAUTILUS_CELL_LINK_TEXT:
g_free (NAUTILUS_CELL_TEXT (clist_row->cell[column])->text);
break;
case NAUTILUS_CELL_PIXMAP:
gdk_pixmap_unref (NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->pixmap);
if (NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->mask)
gdk_bitmap_unref (NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->mask);
case NAUTILUS_CELL_PIXBUF:
gdk_pixbuf_unref (NAUTILUS_CELL_PIXBUF (clist_row->cell[column])->pixbuf);
break;
case NAUTILUS_CELL_PIXTEXT:
g_free (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->text);
gdk_pixmap_unref (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixmap);
if (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->mask)
gdk_bitmap_unref (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->mask);
gdk_pixbuf_unref (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixbuf);
break;
case NAUTILUS_CELL_WIDGET:
/* unimplimented */
/* unimplemented */
break;
default:
break;
@ -2471,29 +2491,27 @@ set_cell_contents (NautilusCList *clist,
switch (type)
{
case NAUTILUS_CELL_TEXT:
case NAUTILUS_CELL_LINK_TEXT:
if (text)
{
clist_row->cell[column].type = NAUTILUS_CELL_TEXT;
NAUTILUS_CELL_TEXT (clist_row->cell[column])->text = g_strdup (text);
}
break;
case NAUTILUS_CELL_PIXMAP:
if (pixmap)
case NAUTILUS_CELL_PIXBUF:
if (pixbuf)
{
clist_row->cell[column].type = NAUTILUS_CELL_PIXMAP;
NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->pixmap = pixmap;
/* We set the mask even if it is NULL */
NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->mask = mask;
clist_row->cell[column].type = NAUTILUS_CELL_PIXBUF;
NAUTILUS_CELL_PIXBUF (clist_row->cell[column])->pixbuf = gdk_pixbuf_ref (pixbuf);
}
break;
case NAUTILUS_CELL_PIXTEXT:
if (text && pixmap)
if (text && pixbuf)
{
clist_row->cell[column].type = NAUTILUS_CELL_PIXTEXT;
NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->text = g_strdup (text);
NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->spacing = spacing;
NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixmap = pixmap;
NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->mask = mask;
NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixbuf = gdk_pixbuf_ref (pixbuf);
}
break;
default:
@ -2503,6 +2521,8 @@ set_cell_contents (NautilusCList *clist,
if (clist->column[column].auto_resize &&
!NAUTILUS_CLIST_AUTO_RESIZE_BLOCKED(clist))
column_auto_resize (clist, clist_row, column, requisition.width);
return TRUE;
}
static void
@ -2525,27 +2545,26 @@ cell_size_request (NautilusCList *clist,
switch (clist_row->cell[column].type)
{
case NAUTILUS_CELL_TEXT:
case NAUTILUS_CELL_LINK_TEXT:
requisition->width =
gdk_string_width (style->font,
NAUTILUS_CELL_TEXT (clist_row->cell[column])->text);
requisition->height = style->font->ascent + style->font->descent;
break;
case NAUTILUS_CELL_PIXTEXT:
gdk_window_get_size (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixmap,
&width, &height);
width = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixbuf);
requisition->width = width +
NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->spacing +
gdk_string_width (style->font,
NAUTILUS_CELL_TEXT (clist_row->cell[column])->text);
height = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXTEXT (clist_row->cell[column])->pixbuf);
requisition->height = MAX (style->font->ascent + style->font->descent,
height);
break;
case NAUTILUS_CELL_PIXMAP:
gdk_window_get_size (NAUTILUS_CELL_PIXMAP (clist_row->cell[column])->pixmap,
&width, &height);
requisition->width = width;
requisition->height = height;
case NAUTILUS_CELL_PIXBUF:
requisition->width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXBUF (clist_row->cell[column])->pixbuf);
requisition->height = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXBUF (clist_row->cell[column])->pixbuf);
break;
default:
requisition->width = 0;
@ -2748,7 +2767,7 @@ real_insert_row (NautilusCList *clist,
for (i = 0; i < clist->columns; i++)
if (text[i])
NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, i, NAUTILUS_CELL_TEXT, text[i], 0, NULL ,NULL);
(clist, clist_row, i, NAUTILUS_CELL_TEXT, text[i], 0, NULL);
if (!clist->rows)
{
@ -4830,82 +4849,16 @@ nautilus_clist_unmap (GtkWidget *widget)
static void
nautilus_clist_draw (GtkWidget *widget,
GdkRectangle *area)
GdkRectangle *area)
{
NautilusCList *clist;
gint border_width;
GdkRectangle child_area;
int i;
g_assert (!"this should not be called, the NautilusList drawing would be disrupted by this");
g_return_if_fail (widget != NULL);
g_return_if_fail (NAUTILUS_IS_CLIST (widget));
g_return_if_fail (area != NULL);
if (GTK_WIDGET_DRAWABLE (widget))
{
clist = NAUTILUS_CLIST (widget);
border_width = GTK_CONTAINER (widget)->border_width;
gdk_window_clear_area (widget->window,
area->x - border_width,
area->y - border_width,
area->width, area->height);
/* draw list shadow/border */
gtk_draw_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, clist->shadow_type,
0, 0,
clist->clist_window_width +
(2 * widget->style->klass->xthickness),
clist->clist_window_height +
(2 * widget->style->klass->ythickness) +
clist->column_title_area.height);
gdk_window_clear_area (clist->clist_window, 0, 0, 0, 0);
NAUTILUS_CLIST_CLASS_FW (clist)->draw_all (clist);
for (i = 0; i < clist->columns; i++)
{
if (!clist->column[i].visible)
continue;
if (clist->column[i].button &&
gtk_widget_intersect(clist->column[i].button, area, &child_area))
gtk_widget_draw (clist->column[i].button, &child_area);
}
}
g_error ("this should not be called, the NautilusList drawing would be disrupted by this");
}
static gint
nautilus_clist_expose (GtkWidget *widget,
GdkEventExpose *event)
GdkEventExpose *event)
{
NautilusCList *clist;
g_assert (!"this should not be called, the NautilusList drawing would be disrupted by this");
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (NAUTILUS_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_WIDGET_DRAWABLE (widget))
{
clist = NAUTILUS_CLIST (widget);
/* draw border */
if (event->window == widget->window)
gtk_draw_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, clist->shadow_type,
0, 0,
clist->clist_window_width +
(2 * widget->style->klass->xthickness),
clist->clist_window_height +
(2 * widget->style->klass->ythickness) +
clist->column_title_area.height);
/* exposure events on the list */
if (event->window == clist->clist_window)
NAUTILUS_CLIST_CLASS_FW (clist)->draw_rows (clist, &event->area);
}
g_error ("this should not be called, the NautilusList drawing would be disrupted by this");
return FALSE;
}
@ -5622,7 +5575,6 @@ nautilus_clist_forall (GtkContainer *container,
/* PRIVATE DRAWING FUNCTIONS
* get_cell_style
* draw_cell_pixmap
* draw_row
* draw_rows
* draw_xor_line
@ -5694,382 +5646,27 @@ get_cell_style (NautilusCList *clist,
}
}
static gint
draw_cell_pixmap (GdkWindow *window,
GdkRectangle *clip_rectangle,
GdkGC *fg_gc,
GdkPixmap *pixmap,
GdkBitmap *mask,
gint x,
gint y,
gint width,
gint height)
{
gint xsrc = 0;
gint ysrc = 0;
if (mask)
{
gdk_gc_set_clip_mask (fg_gc, mask);
gdk_gc_set_clip_origin (fg_gc, x, y);
}
if (x < clip_rectangle->x)
{
xsrc = clip_rectangle->x - x;
width -= xsrc;
x = clip_rectangle->x;
}
if (x + width > clip_rectangle->x + clip_rectangle->width)
width = clip_rectangle->x + clip_rectangle->width - x;
if (y < clip_rectangle->y)
{
ysrc = clip_rectangle->y - y;
height -= ysrc;
y = clip_rectangle->y;
}
if (y + height > clip_rectangle->y + clip_rectangle->height)
height = clip_rectangle->y + clip_rectangle->height - y;
gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);
gdk_gc_set_clip_origin (fg_gc, 0, 0);
if (mask)
gdk_gc_set_clip_mask (fg_gc, NULL);
return x + MAX (width, 0);
}
static void
draw_row (NautilusCList *clist,
GdkRectangle *area,
gint row,
NautilusCListRow *clist_row)
draw_row (NautilusCList *clist,
GdkRectangle *area,
gint row,
NautilusCListRow *clist_row)
{
GtkWidget *widget;
GdkRectangle *rect;
GdkRectangle row_rectangle;
GdkRectangle cell_rectangle;
GdkRectangle clip_rectangle;
GdkRectangle intersect_rectangle;
gint last_column;
gint state;
gint i;
g_assert (!"this should not be called, the NautilusList drawing would be disrupted by this");
g_return_if_fail (clist != NULL);
/* bail now if we arn't drawable yet */
if (!GTK_WIDGET_DRAWABLE (clist) || row < 0 || row >= clist->rows)
return;
widget = GTK_WIDGET (clist);
/* if the function is passed the pointer to the row instead of null,
* it avoids this expensive lookup */
if (!clist_row)
clist_row = ROW_ELEMENT (clist, row)->data;
/* rectangle of the entire row */
row_rectangle.x = 0;
row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
row_rectangle.width = clist->clist_window_width;
row_rectangle.height = clist->row_height;
/* rectangle of the cell spacing above the row */
cell_rectangle.x = 0;
cell_rectangle.y = row_rectangle.y - CELL_SPACING;
cell_rectangle.width = row_rectangle.width;
cell_rectangle.height = CELL_SPACING;
/* rectangle used to clip drawing operations, its y and height
* positions only need to be set once, so we set them once here.
* the x and width are set withing the drawing loop below once per
* column */
clip_rectangle.y = row_rectangle.y;
clip_rectangle.height = row_rectangle.height;
if (clist_row->state == GTK_STATE_NORMAL)
{
if (clist_row->fg_set)
gdk_gc_set_foreground (clist->fg_gc, &clist_row->foreground);
if (clist_row->bg_set)
gdk_gc_set_foreground (clist->bg_gc, &clist_row->background);
}
state = clist_row->state;
/* draw the cell borders and background */
if (area)
{
rect = &intersect_rectangle;
if (gdk_rectangle_intersect (area, &cell_rectangle,
&intersect_rectangle))
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE],
TRUE,
intersect_rectangle.x,
intersect_rectangle.y,
intersect_rectangle.width,
intersect_rectangle.height);
/* the last row has to clear its bottom cell spacing too */
if (clist_row == clist->row_list_end->data)
{
cell_rectangle.y += clist->row_height + CELL_SPACING;
if (gdk_rectangle_intersect (area, &cell_rectangle,
&intersect_rectangle))
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE],
TRUE,
intersect_rectangle.x,
intersect_rectangle.y,
intersect_rectangle.width,
intersect_rectangle.height);
}
if (!gdk_rectangle_intersect (area, &row_rectangle,&intersect_rectangle))
return;
}
else
{
rect = &clip_rectangle;
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE],
TRUE,
cell_rectangle.x,
cell_rectangle.y,
cell_rectangle.width,
cell_rectangle.height);
/* the last row has to clear its bottom cell spacing too */
if (clist_row == clist->row_list_end->data)
{
cell_rectangle.y += clist->row_height + CELL_SPACING;
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE],
TRUE,
cell_rectangle.x,
cell_rectangle.y,
cell_rectangle.width,
cell_rectangle.height);
}
}
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--)
;
/* iterate and draw all the columns (row cells) and draw their contents */
for (i = 0; i < clist->columns; i++)
{
GtkStyle *style;
GdkGC *fg_gc;
GdkGC *bg_gc;
gint width;
gint height;
gint pixmap_width;
gint offset = 0;
gint row_center_offset;
if (!clist->column[i].visible)
continue;
get_cell_style (clist, clist_row, state, i, &style, &fg_gc, &bg_gc);
clip_rectangle.x = clist->column[i].area.x + clist->hoffset;
clip_rectangle.width = clist->column[i].area.width;
/* calculate clipping region clipping region */
clip_rectangle.x -= COLUMN_INSET + CELL_SPACING;
clip_rectangle.width += (2 * COLUMN_INSET + CELL_SPACING +
(i == last_column) * CELL_SPACING);
if (area && !gdk_rectangle_intersect (area, &clip_rectangle,
&intersect_rectangle))
continue;
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
rect->x, rect->y, rect->width, rect->height);
clip_rectangle.x += COLUMN_INSET + CELL_SPACING;
clip_rectangle.width -= (2 * COLUMN_INSET + CELL_SPACING +
(i == last_column) * CELL_SPACING);
/* calculate real width for column justification */
pixmap_width = 0;
offset = 0;
switch (clist_row->cell[i].type)
{
case NAUTILUS_CELL_TEXT:
width = gdk_string_width (style->font,
NAUTILUS_CELL_TEXT (clist_row->cell[i])->text);
break;
case NAUTILUS_CELL_PIXMAP:
gdk_window_get_size (NAUTILUS_CELL_PIXMAP (clist_row->cell[i])->pixmap,
&pixmap_width, &height);
width = pixmap_width;
break;
case NAUTILUS_CELL_PIXTEXT:
gdk_window_get_size (NAUTILUS_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
&pixmap_width, &height);
width = (pixmap_width +
NAUTILUS_CELL_PIXTEXT (clist_row->cell[i])->spacing +
gdk_string_width (style->font,
NAUTILUS_CELL_PIXTEXT
(clist_row->cell[i])->text));
break;
default:
continue;
break;
}
switch (clist->column[i].justification)
{
case GTK_JUSTIFY_LEFT:
offset = clip_rectangle.x + clist_row->cell[i].horizontal;
break;
case GTK_JUSTIFY_RIGHT:
offset = (clip_rectangle.x + clist_row->cell[i].horizontal +
clip_rectangle.width - width);
break;
case GTK_JUSTIFY_CENTER:
case GTK_JUSTIFY_FILL:
offset = (clip_rectangle.x + clist_row->cell[i].horizontal +
(clip_rectangle.width / 2) - (width / 2));
break;
};
/* Draw Text and/or Pixmap */
switch (clist_row->cell[i].type)
{
case NAUTILUS_CELL_PIXMAP:
draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,
NAUTILUS_CELL_PIXMAP (clist_row->cell[i])->pixmap,
NAUTILUS_CELL_PIXMAP (clist_row->cell[i])->mask,
offset,
clip_rectangle.y + clist_row->cell[i].vertical +
(clip_rectangle.height - height) / 2,
pixmap_width, height);
break;
case NAUTILUS_CELL_PIXTEXT:
offset =
draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,
NAUTILUS_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
NAUTILUS_CELL_PIXTEXT (clist_row->cell[i])->mask,
offset,
clip_rectangle.y + clist_row->cell[i].vertical+
(clip_rectangle.height - height) / 2,
pixmap_width, height);
offset += NAUTILUS_CELL_PIXTEXT (clist_row->cell[i])->spacing;
case NAUTILUS_CELL_TEXT:
if (style != GTK_WIDGET (clist)->style)
row_center_offset = (((clist->row_height - style->font->ascent -
style->font->descent - 1) / 2) + 1.5 +
style->font->ascent);
else
row_center_offset = clist->row_center_offset;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_string (clist->clist_window, style->font, fg_gc,
offset,
row_rectangle.y + row_center_offset +
clist_row->cell[i].vertical,
(clist_row->cell[i].type == NAUTILUS_CELL_PIXTEXT) ?
NAUTILUS_CELL_PIXTEXT (clist_row->cell[i])->text :
NAUTILUS_CELL_TEXT (clist_row->cell[i])->text);
gdk_gc_set_clip_rectangle (fg_gc, NULL);
break;
default:
break;
}
}
/* draw focus rectangle */
if (clist->focus_row == row &&
GTK_WIDGET_CAN_FOCUS (widget) && GTK_WIDGET_HAS_FOCUS(widget))
{
if (!area)
gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
row_rectangle.x, row_rectangle.y,
row_rectangle.width - 1, row_rectangle.height - 1);
else if (gdk_rectangle_intersect (area, &row_rectangle,
&intersect_rectangle))
{
gdk_gc_set_clip_rectangle (clist->xor_gc, &intersect_rectangle);
gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
row_rectangle.x, row_rectangle.y,
row_rectangle.width - 1,
row_rectangle.height - 1);
gdk_gc_set_clip_rectangle (clist->xor_gc, NULL);
}
}
g_error ("this should not be called, the NautilusList drawing would be disrupted by this");
}
static void
draw_all (NautilusCList *clist)
{
g_assert (!"this should not be called, the NautilusList drawing would be disrupted by this");
g_error ("this should not be called, the NautilusList drawing would be disrupted by this");
}
static void
draw_rows (NautilusCList *clist,
GdkRectangle *area)
draw_rows (NautilusCList *clist,
GdkRectangle *area)
{
GList *list;
NautilusCListRow *clist_row;
gint i;
gint first_row;
gint last_row;
g_assert (!"this should not be called, the NautilusList drawing would be disrupted by this");
g_return_if_fail (clist != NULL);
g_return_if_fail (NAUTILUS_IS_CLIST (clist));
if (clist->row_height == 0 ||
!GTK_WIDGET_DRAWABLE (clist))
return;
if (area)
{
first_row = ROW_FROM_YPIXEL (clist, area->y);
last_row = ROW_FROM_YPIXEL (clist, area->y + area->height);
}
else
{
first_row = ROW_FROM_YPIXEL (clist, 0);
last_row = ROW_FROM_YPIXEL (clist, clist->clist_window_height);
}
/* this is a small special case which exposes the bottom cell line
* on the last row -- it might go away if I change the wall the cell
* spacings are drawn
*/
if (clist->rows == first_row)
first_row--;
list = ROW_ELEMENT (clist, first_row);
i = first_row;
while (list)
{
clist_row = list->data;
list = list->next;
if (i > last_row)
return;
NAUTILUS_CLIST_CLASS_FW (clist)->draw_row (clist, area, i, clist_row);
i++;
}
if (!area)
gdk_window_clear_area (clist->clist_window, 0,
ROW_TOP_YPIXEL (clist, i), 0, 0);
g_error ("this should not be called, the NautilusList drawing would be disrupted by this");
}
static void
@ -6602,7 +6199,7 @@ row_delete (NautilusCList *clist,
for (i = 0; i < clist->columns; i++)
{
NAUTILUS_CLIST_CLASS_FW (clist)->set_cell_contents
(clist, clist_row, i, NAUTILUS_CELL_EMPTY, NULL, 0, NULL, NULL);
(clist, clist_row, i, NAUTILUS_CELL_EMPTY, NULL, 0, NULL);
if (clist_row->cell[i].style)
{
if (GTK_WIDGET_REALIZED (clist))
@ -7360,6 +6957,7 @@ default_compare (NautilusCList *clist,
switch (row1->cell[clist->sort_column].type)
{
case NAUTILUS_CELL_TEXT:
case NAUTILUS_CELL_LINK_TEXT:
text1 = NAUTILUS_CELL_TEXT (row1->cell[clist->sort_column])->text;
break;
case NAUTILUS_CELL_PIXTEXT:
@ -7372,6 +6970,7 @@ default_compare (NautilusCList *clist,
switch (row2->cell[clist->sort_column].type)
{
case NAUTILUS_CELL_TEXT:
case NAUTILUS_CELL_LINK_TEXT:
text2 = NAUTILUS_CELL_TEXT (row2->cell[clist->sort_column])->text;
break;
case NAUTILUS_CELL_PIXTEXT:

View file

@ -40,6 +40,7 @@
#include <gtk/gtkhscrollbar.h>
#include <gtk/gtkvscrollbar.h>
#include <gtk/gtkenums.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#ifdef __cplusplus
extern "C" {
@ -66,12 +67,11 @@ typedef enum
{
NAUTILUS_CELL_EMPTY,
NAUTILUS_CELL_TEXT,
NAUTILUS_CELL_PIXMAP,
NAUTILUS_CELL_PIXTEXT,
NAUTILUS_CELL_PIXBUF, /* new for Nautilus */
NAUTILUS_CELL_PIXTEXT, /* now uses pixbuf */
NAUTILUS_CELL_WIDGET,
NAUTILUS_CELL_PIXBUF_LIST, /* new for Nautilus */
NAUTILUS_CELL_LINK_TEXT, /* new for Nautilus */
NAUTILUS_CELL_PIXBUF, /* new for Nautilus */
NAUTILUS_CELL_LINK_TEXT /* new for Nautilus */
} NautilusCellType;
typedef enum
@ -116,7 +116,7 @@ typedef enum
/* pointer casting for cells */
#define NAUTILUS_CELL_TEXT(cell) (((NautilusCellText *) &(cell)))
#define NAUTILUS_CELL_PIXMAP(cell) (((NautilusCellPixmap *) &(cell)))
#define NAUTILUS_CELL_PIXBUF(cell) (((NautilusCellPixbuf *) &(cell)))
#define NAUTILUS_CELL_PIXTEXT(cell) (((NautilusCellPixText *) &(cell)))
#define NAUTILUS_CELL_WIDGET(cell) (((NautilusCellWidget *) &(cell)))
@ -127,7 +127,7 @@ typedef struct NautilusCListRow NautilusCListRow;
typedef struct NautilusCell NautilusCell;
typedef struct NautilusCellText NautilusCellText;
typedef struct NautilusCellPixmap NautilusCellPixmap;
typedef struct NautilusCellPixbuf NautilusCellPixbuf;
typedef struct NautilusCellPixText NautilusCellPixText;
typedef struct NautilusCellWidget NautilusCellWidget;
@ -312,14 +312,13 @@ struct NautilusCListClass
gchar *text[]);
void (*remove_row) (NautilusCList *clist,
gint row);
void (*set_cell_contents) (NautilusCList *clist,
gboolean (*set_cell_contents) (NautilusCList *clist,
NautilusCListRow *clist_row,
gint column,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
void (*cell_size_request) (NautilusCList *clist,
NautilusCListRow *clist_row,
gint column,
@ -378,7 +377,7 @@ struct NautilusCellText
gchar *text;
};
struct NautilusCellPixmap
struct NautilusCellPixbuf
{
NautilusCellType type;
@ -387,8 +386,7 @@ struct NautilusCellPixmap
GtkStyle *style;
GdkPixmap *pixmap;
GdkBitmap *mask;
GdkPixbuf *pixbuf;
};
struct NautilusCellPixText
@ -402,8 +400,7 @@ struct NautilusCellPixText
gchar *text;
guint8 spacing;
GdkPixmap *pixmap;
GdkBitmap *mask;
GdkPixbuf *pixbuf;
};
struct NautilusCellWidget
@ -431,15 +428,13 @@ struct NautilusCell
gchar *text;
struct {
GdkPixmap *pixmap;
GdkBitmap *mask;
} pm;
GdkPixbuf *pixbuf;
} pb;
struct {
gchar *text;
guint8 spacing;
GdkPixmap *pixmap;
GdkBitmap *mask;
GdkPixbuf *pixbuf;
} pt;
GtkWidget *widget;
@ -607,35 +602,31 @@ gint nautilus_clist_get_text (NautilusCList *clist,
gint column,
gchar **text);
/* sets a given cell's pixmap, replacing its current contents */
void nautilus_clist_set_pixmap (NautilusCList *clist,
gint row,
gint column,
GdkPixmap *pixmap,
GdkBitmap *mask);
/* sets a given cell's pixbuf, replacing its current contents */
void nautilus_clist_set_pixbuf (NautilusCList *clist,
gint row,
gint column,
GdkPixbuf *pixbuf);
gint nautilus_clist_get_pixmap (NautilusCList *clist,
gint row,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask);
gint nautilus_clist_get_pixbuf (NautilusCList *clist,
gint row,
gint column,
GdkPixbuf **pixbuf);
/* sets a given cell's pixmap and text, replacing its current contents */
/* sets a given cell's pixbuf and text, replacing its current contents */
void nautilus_clist_set_pixtext (NautilusCList *clist,
gint row,
gint column,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
gint nautilus_clist_get_pixtext (NautilusCList *clist,
gint row,
gint column,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap,
GdkBitmap **mask);
GdkPixbuf **pixbuf);
/* sets the foreground color of a row, the color must already
* be allocated

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@
#ifndef NAUTILUS_CTREE_H
#define NAUTILUS_CTREE_H
#include <gtk/gtkclist.h>
#include "nautilus-list.h"
#ifdef __cplusplus
extern "C" {
@ -102,7 +102,7 @@ typedef gboolean (*NautilusCTreeCompareDragFunc) (NautilusCTree *ctree,
struct _NautilusCTree
{
GtkCList clist;
NautilusList list;
GdkGC *lines_gc;
@ -122,7 +122,7 @@ struct _NautilusCTree
struct _NautilusCTreeClass
{
GtkCListClass parent_class;
NautilusListClass parent_class;
void (*tree_select_row) (NautilusCTree *ctree,
NautilusCTreeNode *row,
@ -147,16 +147,14 @@ struct _NautilusCTreeClass
struct _NautilusCTreeRow
{
GtkCListRow row;
NautilusCListRow row;
NautilusCTreeNode *parent;
NautilusCTreeNode *sibling;
NautilusCTreeNode *children;
GdkPixmap *pixmap_closed;
GdkBitmap *mask_closed;
GdkPixmap *pixmap_opened;
GdkBitmap *mask_opened;
GdkPixbuf *pixbuf_closed;
GdkPixbuf *pixbuf_opened;
guint16 level;
@ -192,10 +190,8 @@ NautilusCTreeNode * nautilus_ctree_insert_node (NautilusCTree *c
NautilusCTreeNode *sibling,
gchar *text[],
guint8 spacing,
GdkPixmap *pixmap_closed,
GdkBitmap *mask_closed,
GdkPixmap *pixmap_opened,
GdkBitmap *mask_opened,
GdkPixbuf *pixbuf_closed,
GdkPixbuf *pixbuf_opened,
gboolean is_leaf,
gboolean expanded);
void nautilus_ctree_remove_node (NautilusCTree *ctree,
@ -318,26 +314,22 @@ void nautilus_ctree_node_set_text (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
const gchar *text);
void nautilus_ctree_node_set_pixmap (NautilusCTree *ctree,
void nautilus_ctree_node_set_pixbuf (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
void nautilus_ctree_node_set_pixtext (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
void nautilus_ctree_set_node_info (NautilusCTree *ctree,
NautilusCTreeNode *node,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap_closed,
GdkBitmap *mask_closed,
GdkPixmap *pixmap_opened,
GdkBitmap *mask_opened,
GdkPixbuf *pixbuf_closed,
GdkPixbuf *pixbuf_opened,
gboolean is_leaf,
gboolean expanded);
void nautilus_ctree_node_set_shift (NautilusCTree *ctree,
@ -350,33 +342,29 @@ void nautilus_ctree_node_set_selectable (NautilusCTree *ctree,
gboolean selectable);
gboolean nautilus_ctree_node_get_selectable (NautilusCTree *ctree,
NautilusCTreeNode *node);
GtkCellType nautilus_ctree_node_get_cell_type (NautilusCTree *ctree,
NautilusCellType nautilus_ctree_node_get_cell_type (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column);
gint nautilus_ctree_node_get_text (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
gchar **text);
gint nautilus_ctree_node_get_pixmap (NautilusCTree *ctree,
gint nautilus_ctree_node_get_pixbuf (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask);
GdkPixbuf **pixbuf);
gint nautilus_ctree_node_get_pixtext (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap,
GdkBitmap **mask);
GdkPixbuf **pixbuf);
gint nautilus_ctree_get_node_info (NautilusCTree *ctree,
NautilusCTreeNode *node,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap_closed,
GdkBitmap **mask_closed,
GdkPixmap **pixmap_opened,
GdkBitmap **mask_opened,
GdkPixbuf **pixbuf_closed,
GdkPixbuf **pixbuf_opened,
gboolean *is_leaf,
gboolean *expanded);

View file

@ -27,21 +27,22 @@
#include <config.h>
#include "nautilus-gtk-extensions.h"
#include "nautilus-gdk-extensions.h"
#include "nautilus-gdk-font-extensions.h"
#include "nautilus-gdk-font-extensions.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-string.h"
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkrc.h>
#include <gtk/gtkselection.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkrc.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-geometry.h>
#include <libgnomeui/gnome-winhints.h>
#include "nautilus-glib-extensions.h"
#include "nautilus-string.h"
/* This number should be large enough to be visually noticeable,
* but small enough to not allow the user to perform other actions.
@ -952,6 +953,19 @@ nautilus_gtk_marshal_INT__NONE (GtkObject *object,
func_data);
}
void
nautilus_gtk_marshal_POINTER__INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
* GTK_RETLOC_POINTER (args[1]) =
(* (gpointer (*)(GtkObject *, int, gpointer)) func)
(object,
GTK_VALUE_INT (args[0]),
func_data);
}
void
nautilus_gtk_marshal_POINTER__POINTER (GtkObject *object,
GtkSignalFunc func,
@ -2121,3 +2135,23 @@ nautilus_get_current_event_time (void)
return time;
}
void
nautilus_drag_set_icon_pixbuf (GdkDragContext *context,
GdkPixbuf *pixbuf,
int hot_x,
int hot_y)
{
GdkPixmap *pixmap;
GdkBitmap *mask;
gdk_pixbuf_render_pixmap_and_mask
(pixbuf, &pixmap, &mask,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
gtk_drag_set_icon_pixmap
(context, gdk_rgb_get_cmap (), pixmap, mask, hot_x, hot_y);
/* FIXME: Verify that this does not leak the pixmap and mask.
* We've always done it this way, but maybe we've always
* leaked. Just doing the unref here definitely causes a
* problem, so it's not that simple.
*/
}

View file

@ -4,7 +4,7 @@
gtk classes. Perhaps some of these should be
rolled into gtk someday.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -28,6 +28,7 @@
#ifndef NAUTILUS_GTK_EXTENSIONS_H
#define NAUTILUS_GTK_EXTENSIONS_H
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
@ -41,7 +42,7 @@
/* GtkButton */
void nautilus_gtk_button_auto_click (GtkButton *button);
void nautilus_gtk_button_set_standard_padding (GtkButton *button);
void nautilus_gtk_button_set_standard_padding (GtkButton *button);
void nautilus_gtk_button_set_padding (GtkButton *button,
int pad_amount);
@ -70,14 +71,13 @@ void nautilus_gtk_signal_connect_full_while_alive (GtkObjec
gboolean object_signal,
gboolean after,
GtkObject *alive_object);
void nautilus_gtk_signal_connect_while_realized (GtkObject *object,
const char *name,
GtkSignalFunc callback,
gpointer callback_data,
GtkWidget *realized_widget);
void nautilus_nullify_when_destroyed (gpointer object_pointer_address);
void nautilus_nullify_cancel (gpointer object_pointer_address);
void nautilus_nullify_when_destroyed (gpointer object_pointer_address);
void nautilus_nullify_cancel (gpointer object_pointer_address);
/* list of GtkObject */
GList * nautilus_gtk_object_list_ref (GList *list);
@ -87,7 +87,7 @@ GList * nautilus_gtk_object_list_copy (GList
/* GtkWidget */
void nautilus_gtk_widget_set_shown (GtkWidget *widget,
gboolean shown);
gboolean shown);
gboolean nautilus_point_in_allocation (const GtkAllocation *allocation,
int x,
int y);
@ -137,8 +137,8 @@ void nautilus_pop_up_context_menu (GtkMenu
gint16 offset_x,
gint16 offset_y,
GdkEventButton *event);
GtkMenuItem *nautilus_gtk_menu_append_separator (GtkMenu *menu);
GtkMenuItem *nautilus_gtk_menu_insert_separator (GtkMenu *menu,
GtkMenuItem * nautilus_gtk_menu_append_separator (GtkMenu *menu);
GtkMenuItem * nautilus_gtk_menu_insert_separator (GtkMenu *menu,
int index);
void nautilus_gtk_menu_set_item_visibility (GtkMenu *menu,
int index,
@ -173,8 +173,13 @@ void nautilus_gtk_style_shade (GdkColor
* gtk style/theme purposes. */
void nautilus_gtk_class_name_make_like_existing_type (const char *class_name,
GtkType existing_gtk_type);
GList * nautilus_get_window_list_ordered_front_to_back (void);
GList *nautilus_get_window_list_ordered_front_to_back (void);
/* dnd */
void nautilus_drag_set_icon_pixbuf (GdkDragContext *context,
GdkPixbuf *pixbuf,
gint hot_x,
gint hot_y);
/* marshals */
@ -266,6 +271,10 @@ void nautilus_gtk_marshal_POINTER__NONE
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,

View file

@ -1251,8 +1251,6 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
GnomeCanvas *canvas;
GdkDragContext *context;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file;
int x_offset, y_offset;
ArtDRect world_rect;
ArtIRect window_rect;
@ -1285,11 +1283,6 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
/* we want to drag semi-transparent pixbufs, but X is too slow dealing with
stippled masks, so we had to remove the code; this comment is left as a memorial
to it, with the hope that we get it back someday as X Windows improves */
gdk_pixbuf_render_pixmap_and_mask (pixbuf,
&pixmap_for_dragged_file,
&mask_for_dragged_file,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
/* compute the image's offset */
nautilus_icon_canvas_item_get_icon_rectangle
@ -1299,12 +1292,8 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
x_offset = dnd_info->drag_info.start_x - window_rect.x0;
y_offset = dnd_info->drag_info.start_y - window_rect.y0;
/* set the pixmap and mask for dragging */
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (GTK_WIDGET (container)),
pixmap_for_dragged_file,
mask_for_dragged_file,
x_offset, y_offset);
/* set the icon for dragging */
nautilus_drag_set_icon_pixbuf (context, pixbuf, x_offset, y_offset);
}
static gboolean

View file

@ -1,9 +1,9 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-list.h: Enhanced version of GtkCList for Nautilus.
/* nautilus-list.c: Enhanced version of GtkCList for Nautilus.
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -193,7 +193,7 @@ enum {
HANDLE_DROPPED_ITEMS,
HANDLE_DRAGGED_ITEMS,
GET_DEFAULT_ACTION,
GET_DRAG_PIXMAP,
GET_DRAG_PIXBUF,
GET_SORT_COLUMN_INDEX,
LAST_SIGNAL
};
@ -281,14 +281,13 @@ static void nautilus_list_style_set (GtkWidget *w
GtkStyle *previous_style);
static void nautilus_list_realize (GtkWidget *widget);
static void nautilus_list_unrealize (GtkWidget *widget);
static void nautilus_list_set_cell_contents (NautilusCList *clist,
static gboolean nautilus_list_set_cell_contents (NautilusCList *clist,
NautilusCListRow *row,
int column_index,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
static void nautilus_list_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void nautilus_list_resize_column (NautilusCList *widget,
@ -438,17 +437,14 @@ nautilus_list_initialize_class (NautilusListClass *klass)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_UINT);
list_signals[GET_DRAG_PIXMAP] =
gtk_signal_new ("get_drag_pixmap",
list_signals[GET_DRAG_PIXBUF] =
gtk_signal_new ("get_drag_pixbuf",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusListClass, get_drag_pixmap),
nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER,
GTK_TYPE_NONE, 4,
GTK_TYPE_POINTER,
GTK_TYPE_INT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
GTK_SIGNAL_OFFSET (NautilusListClass, get_drag_pixbuf),
nautilus_gtk_marshal_POINTER__INT,
GTK_TYPE_POINTER, 1,
GTK_TYPE_INT);
list_signals[GET_SORT_COLUMN_INDEX] =
gtk_signal_new ("get_sort_column_index",
GTK_RUN_LAST,
@ -546,9 +542,11 @@ nautilus_list_set_anti_aliased_mode (NautilusList *list,
}
static void
nautilus_list_dnd_initialize (NautilusList *list)
void
nautilus_list_initialize_dnd (NautilusList *list)
{
g_assert (list->details->drag_info == NULL);
g_assert (!GTK_WIDGET_REALIZED (list));
list->details->drag_info = g_new0 (NautilusDragInfo, 1);
@ -577,7 +575,7 @@ nautilus_list_dnd_initialize (NautilusList *list)
gtk_signal_connect (GTK_OBJECT (list),
"drag_data_received",
GTK_SIGNAL_FUNC(nautilus_list_drag_data_received),
GTK_SIGNAL_FUNC (nautilus_list_drag_data_received),
list);
@ -595,7 +593,6 @@ nautilus_list_dnd_initialize (NautilusList *list)
static void
nautilus_list_initialize (NautilusList *list)
{
list->details = g_new0 (NautilusListDetails, 1);
list->details->anchor_row = -1;
@ -604,9 +601,6 @@ nautilus_list_initialize (NautilusList *list)
/* GtkCList does not specify pointer motion by default */
gtk_widget_add_events (GTK_WIDGET (list), GDK_POINTER_MOTION_MASK);
nautilus_list_dnd_initialize (list);
/* Emit "selection changed" signal when parent class changes selection */
list->details->select_row_signal_id = gtk_signal_connect (GTK_OBJECT (list),
"select_row",
@ -632,7 +626,9 @@ nautilus_list_destroy (GtkObject *object)
list = NAUTILUS_LIST (object);
nautilus_drag_finalize (list->details->drag_info);
if (list->details->drag_info != NULL) {
nautilus_drag_finalize (list->details->drag_info);
}
unschedule_keyboard_row_reveal (list);
@ -2066,50 +2062,6 @@ get_cell_style (NautilusList *list, NautilusCListRow *row,
}
}
static void
gdk_window_size_as_rectangle (GdkWindow *gdk_window, GdkRectangle *rectangle)
{
int width, height;
gdk_window_get_size (gdk_window, &width, &height);
rectangle->width = width;
rectangle->height = height;
}
static int
draw_cell_pixmap (GdkWindow *window, GdkRectangle *clip_rectangle, GdkGC *fg_gc,
GdkPixmap *pixmap, GdkBitmap *mask,
int x, int y)
{
GdkRectangle image_rectangle;
GdkRectangle intersect_rectangle;
gdk_window_size_as_rectangle (pixmap, &image_rectangle);
image_rectangle.x = x;
image_rectangle.y = y;
if (!gdk_rectangle_intersect (clip_rectangle, &image_rectangle, &intersect_rectangle)) {
return x;
}
if (mask) {
gdk_gc_set_clip_mask (fg_gc, mask);
gdk_gc_set_clip_origin (fg_gc, x, y);
}
gdk_draw_pixmap (window, fg_gc, pixmap,
intersect_rectangle.x - x, intersect_rectangle.y - y,
image_rectangle.x, image_rectangle.y,
intersect_rectangle.width, intersect_rectangle.height);
if (mask) {
gdk_gc_set_clip_origin (fg_gc, 0, 0);
gdk_gc_set_clip_mask (fg_gc, NULL);
}
return x + intersect_rectangle.width;
}
static int
draw_cell_pixbuf (NautilusCList *clist, GdkWindow *window, GdkRectangle *clip_rectangle,
GdkGC *fg_gc, guint32 bg_rgb, GdkPixbuf *pixbuf, int x, int y)
@ -2238,7 +2190,7 @@ get_cell_greater_rectangle (GdkRectangle *cell_rect, GdkRectangle *result,
static void
draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_index,
NautilusCListRow *row)
NautilusCListRow *row)
{
GtkStyle *style;
GdkGC *fg_gc;
@ -2250,7 +2202,7 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
int width;
int height;
int pixmap_width;
int pixbuf_width;
int offset = 0;
int baseline;
int row_center_offset;
@ -2280,8 +2232,7 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
/* calculate real width for column justification */
width = 0;
pixmap_width = 0;
offset = 0;
height = 0;
switch ((NautilusCellType)row->cell[column_index].type) {
case NAUTILUS_CELL_TEXT:
@ -2289,15 +2240,14 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
width = gdk_string_width (style->font,
NAUTILUS_CELL_TEXT (row->cell[column_index])->text);
break;
case NAUTILUS_CELL_PIXMAP:
gdk_window_get_size (NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
&pixmap_width, &height);
width = pixmap_width;
case NAUTILUS_CELL_PIXBUF:
width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf);
height = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf);
break;
case NAUTILUS_CELL_PIXTEXT:
gdk_window_get_size (NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixmap,
&pixmap_width, &height);
width = (pixmap_width +
pixbuf_width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixbuf);
height = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixbuf);
width = (pixbuf_width +
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->spacing +
gdk_string_width (style->font, NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->text));
break;
@ -2310,73 +2260,53 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
width += gdk_pixbuf_get_width (p->data);
}
break;
case NAUTILUS_CELL_PIXBUF:
width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXBUF (row->cell[column_index]));
break;
default:
case NAUTILUS_CELL_EMPTY:
case NAUTILUS_CELL_WIDGET:
return;
}
offset = get_cell_horizontal_start_position (clist, row, column_index, width);
/* Draw Text and/or Pixmap */
switch ((NautilusCellType)row->cell[column_index].type) {
case NAUTILUS_CELL_PIXMAP:
{
NautilusList *list = NAUTILUS_LIST (clist);
int dark_width, dark_height;
GdkPixbuf *src_pixbuf, *dark_pixbuf;
GdkPixmap *dark_pixmap;
GdkBitmap *dark_mask;
if (list->details->drag_prelight_row == row) {
gdk_window_get_geometry (NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
NULL, NULL, &dark_width, &dark_height, NULL);
src_pixbuf = gdk_pixbuf_get_from_drawable
(NULL,
NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
gdk_rgb_get_cmap (),
0, 0, 0, 0, dark_width, dark_height);
if (src_pixbuf != NULL) {
/* Create darkened pixmap */
dark_pixbuf = nautilus_create_darkened_pixbuf (src_pixbuf,
0.8 * 255,
0.8 * 255);
if (dark_pixbuf != NULL) {
gdk_pixbuf_render_pixmap_and_mask (dark_pixbuf,
&dark_pixmap, &dark_mask,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
draw_cell_pixmap (clist->clist_window, &cell_rectangle, fg_gc,
dark_pixmap, NAUTILUS_CELL_PIXMAP (row->cell[column_index])->mask, offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
gdk_pixbuf_unref (dark_pixbuf);
}
gdk_pixbuf_unref (src_pixbuf);
}
} else {
draw_cell_pixmap (clist->clist_window, &cell_rectangle, fg_gc,
NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
NAUTILUS_CELL_PIXMAP (row->cell[column_index])->mask,
offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
}
/* Draw Text and/or Pixbuf */
switch ((NautilusCellType) row->cell[column_index].type) {
case NAUTILUS_CELL_PIXBUF: {
NautilusList *list = NAUTILUS_LIST (clist);
GdkPixbuf *src_pixbuf, *dark_pixbuf;
if (list->details->drag_prelight_row == row) {
src_pixbuf = NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf;
if (src_pixbuf != NULL) {
/* Create darkened pixbuf */
dark_pixbuf = nautilus_create_darkened_pixbuf (src_pixbuf,
0.8 * 255,
0.8 * 255);
if (dark_pixbuf != NULL) {
draw_cell_pixbuf (clist, clist->clist_window, &cell_rectangle, fg_gc, bg_rgb,
dark_pixbuf, offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
gdk_pixbuf_unref (dark_pixbuf);
}
}
} else {
draw_cell_pixbuf (clist, clist->clist_window, &cell_rectangle, fg_gc, bg_rgb,
NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf,
offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
}
break;
}
case NAUTILUS_CELL_PIXTEXT:
offset = draw_cell_pixmap (clist->clist_window, &cell_rectangle, fg_gc,
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixmap,
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->mask,
offset,
cell_rectangle.y + row->cell[column_index].vertical+
(cell_rectangle.height - height) / 2);
offset = draw_cell_pixbuf (clist, clist->clist_window, &cell_rectangle, fg_gc, bg_rgb,
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixbuf,
offset,
cell_rectangle.y + row->cell[column_index].vertical+
(cell_rectangle.height - height) / 2);
offset += NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->spacing;
/* fall through */
case NAUTILUS_CELL_TEXT:
@ -2454,19 +2384,8 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
}
break;
}
case NAUTILUS_CELL_PIXBUF: {
GdkPixbuf *pixbuf;
guint height;
pixbuf = NAUTILUS_CELL_PIXBUF (row->cell[column_index]);
height = gdk_pixbuf_get_height (pixbuf);
offset = draw_cell_pixbuf (clist, clist->clist_window,
&cell_rectangle,
fg_gc, bg_rgb, pixbuf,
offset, cell_rectangle.y
+ row->cell[column_index].vertical
+ (cell_rectangle.height - height) / 2);
}
default:
case NAUTILUS_CELL_EMPTY:
case NAUTILUS_CELL_WIDGET:
break;
}
}
@ -2800,7 +2719,7 @@ nautilus_list_resize_column (NautilusCList *clist, int column_index, int width)
*
* Mark a text cell as a link cell. Link cells are drawn differently,
* and activate rather than select on single-click. The cell must
* be a text cell (not a pixmap cell or one of the other types).
* be a text cell (not a pixbuf cell or one of the other types).
*
* @list: The NautilusList in question.
* @column_index: The column of the desired cell.
@ -2825,7 +2744,7 @@ nautilus_list_mark_cell_as_link (NautilusList *list,
/*
* We only support changing text cells to links. Maybe someday
* we'll support pixmap or pixtext link cells too.
* we'll support pixbuf or pixtext link cells too.
*/
g_return_if_fail ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_TEXT);
@ -2833,16 +2752,17 @@ nautilus_list_mark_cell_as_link (NautilusList *list,
}
static void
static gboolean
nautilus_list_set_cell_contents (NautilusCList *clist,
NautilusCListRow *row,
int column_index,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask)
GdkPixbuf *pixbuf)
{
gboolean result;
/*
* Note that we don't do the auto_resize bracketing here that's done
* in the parent class. It would require copying over huge additional
@ -2853,29 +2773,19 @@ nautilus_list_set_cell_contents (NautilusCList *clist,
/* Clean up old data, which parent class doesn't know about. */
if ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_PIXBUF_LIST) {
nautilus_gdk_pixbuf_list_free (NAUTILUS_CELL_PIXBUF_LIST (row->cell[column_index])->pixbufs);
} else if ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_PIXBUF) {
gdk_pixbuf_unref (NAUTILUS_CELL_PIXBUF (row->cell[column_index]));
}
/* If old cell was a link-text cell, convert it back to a normal text
* cell so it gets cleaned up properly by GtkCList code.
*/
if ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_LINK_TEXT) {
row->cell[column_index].type = NAUTILUS_CELL_TEXT;
}
NAUTILUS_CALL_PARENT (NAUTILUS_CLIST_CLASS, set_cell_contents,
(clist, row, column_index, type, text, spacing, pixmap, mask));
result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(NAUTILUS_CLIST_CLASS, set_cell_contents,
(clist, row, column_index, type, text, spacing, pixbuf));
if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF_LIST) {
row->cell[column_index].type = NAUTILUS_CELL_PIXBUF_LIST;
/* Hideously, we concealed our list of pixbufs in the pixmap parameter. */
NAUTILUS_CELL_PIXBUF_LIST (row->cell[column_index])->pixbufs = (GList *)pixmap;
} else if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF) {
row->cell[column_index].type = NAUTILUS_CELL_PIXBUF;
/* Hideously, we concealed our pixbuf in the pixmap parameter. */
NAUTILUS_CELL_PIXBUF (row->cell[column_index]) = pixmap;
/* Hideously, we concealed our list of pixbufs in the pixbuf parameter. */
NAUTILUS_CELL_PIXBUF_LIST (row->cell[column_index])->pixbufs = (GList *)pixbuf;
}
return result;
}
static void
@ -2907,14 +2817,15 @@ set_list_cell (NautilusList *list,
* expected parameter type, we have to sneak it in by casting it into
* one of the expected parameters.
*/
NAUTILUS_CALL_METHOD (NAUTILUS_CLIST_CLASS, clist, set_cell_contents,
(clist, row, column_index, type, NULL, 0, (GdkPixmap *) data, NULL));
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist)
&& nautilus_clist_row_is_visible (clist, row_index) != GTK_VISIBILITY_NONE) {
NAUTILUS_CALL_METHOD (NAUTILUS_CLIST_CLASS, clist, draw_row,
(clist, NULL, row_index, row));
if (NAUTILUS_CALL_METHOD_WITH_RETURN_VALUE
(NAUTILUS_CLIST_CLASS, clist, set_cell_contents,
(clist, row, column_index, type, NULL, 0, data))) {
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist)
&& nautilus_clist_row_is_visible (clist, row_index) != GTK_VISIBILITY_NONE) {
NAUTILUS_CALL_METHOD (NAUTILUS_CLIST_CLASS, clist, draw_row,
(clist, NULL, row_index, row));
}
}
}
@ -2941,7 +2852,7 @@ get_list_cell (NautilusList *list,
row = ROW_ELEMENT (clist, row_index)->data;
if (row->cell[column_index].type == type) {
return NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap;
return NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf;
}
return NULL;
@ -3049,13 +2960,15 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
{
NautilusList *list;
GdkDragContext *context;
GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file;
int x_offset, y_offset;
GdkPixbuf *pixbuf;
g_return_if_fail (NAUTILUS_IS_LIST (widget));
list = NAUTILUS_LIST (widget);
if (list->details->drag_info == NULL) {
return;
}
list->details->drag_started = TRUE;
list->details->dnd_select_pending = FALSE;
/* reinit from last dnd if there was one */
@ -3070,20 +2983,15 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
list->details->dnd_press_button,
(GdkEvent *) event);
x_offset = 10;
y_offset = 10;
pixbuf = NULL;
gtk_signal_emit (GTK_OBJECT (list), list_signals[GET_DRAG_PIXBUF],
list->details->button_down_row, &pixbuf);
gtk_signal_emit (GTK_OBJECT (list), list_signals[GET_DRAG_PIXMAP],
list->details->button_down_row, &pixmap_for_dragged_file,
&mask_for_dragged_file);
if (pixmap_for_dragged_file) {
/* set the pixmap and mask for dragging */
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (widget),
pixmap_for_dragged_file,
mask_for_dragged_file,
x_offset, y_offset);
if (pixbuf != NULL) {
/* FIXME: We can do better than 10,10. */
nautilus_drag_set_icon_pixbuf (context, pixbuf, 10, 10);
gdk_pixbuf_unref (pixbuf);
}
}
@ -3414,7 +3322,7 @@ nautilus_list_receive_dropped_icons (NautilusList *list,
int x, int y, guint info)
{
NautilusDragInfo *drag_info;
GList * selected_items;
GList *selected_items;
g_assert (NAUTILUS_IS_LIST (list));
drag_info = list->details->drag_info;

View file

@ -3,7 +3,7 @@
/* nautilus-list.h: Enhanced version of GtkCList for Nautilus.
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -30,8 +30,7 @@
#define NAUTILUS_LIST_H
#include <libgnome/gnome-defs.h>
#include <widgets/nautilusclist/nautilusclist.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cut-n-paste-code/widgets/nautilusclist/nautilusclist.h>
/* This class was originally derived from the GtkFList class in gmc.
*/
@ -43,7 +42,6 @@
/* pointer casting for cells */
#define NAUTILUS_CELL_PIXBUF_LIST(cell) ((NautilusCellPixbufList *) &(cell))
#define NAUTILUS_CELL_PIXBUF(cell) ((GdkPixbuf *) ((cell).u.text))
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
/* returns the GList item for the nth row */
@ -109,8 +107,8 @@ struct NautilusListClass {
void (* select_matching_name) (GtkWidget *widget, const char *);
void (* select_previous_name) (GtkWidget *widget);
void (* select_next_name) (GtkWidget *widget);
void (* get_drag_pixmap) (GtkWidget *widget, int row_index, GdkPixmap **pixmap, GdkBitmap **mask);
int (* get_sort_column_index) (void);
GdkPixbuf (* get_drag_pixbuf) (NautilusList *list, int row_index);
int (* get_sort_column_index) (NautilusList *list);
/* dnd handling. defer the semantics of dnd to the application side, not nautilus-list */
gboolean (* handle_dragged_items) (GtkWidget *widget,
@ -141,6 +139,7 @@ typedef gboolean (* NautilusEachRowFunction) (NautilusCListRow *, int, gpointer)
GtkType nautilus_list_get_type (void);
GtkWidget * nautilus_list_new_with_titles (int columns,
const char * const *titles);
void nautilus_list_initialize_dnd (NautilusList *list);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@
#ifndef NAUTILUS_CTREE_H
#define NAUTILUS_CTREE_H
#include <gtk/gtkclist.h>
#include "nautilus-list.h"
#ifdef __cplusplus
extern "C" {
@ -102,7 +102,7 @@ typedef gboolean (*NautilusCTreeCompareDragFunc) (NautilusCTree *ctree,
struct _NautilusCTree
{
GtkCList clist;
NautilusList list;
GdkGC *lines_gc;
@ -122,7 +122,7 @@ struct _NautilusCTree
struct _NautilusCTreeClass
{
GtkCListClass parent_class;
NautilusListClass parent_class;
void (*tree_select_row) (NautilusCTree *ctree,
NautilusCTreeNode *row,
@ -147,16 +147,14 @@ struct _NautilusCTreeClass
struct _NautilusCTreeRow
{
GtkCListRow row;
NautilusCListRow row;
NautilusCTreeNode *parent;
NautilusCTreeNode *sibling;
NautilusCTreeNode *children;
GdkPixmap *pixmap_closed;
GdkBitmap *mask_closed;
GdkPixmap *pixmap_opened;
GdkBitmap *mask_opened;
GdkPixbuf *pixbuf_closed;
GdkPixbuf *pixbuf_opened;
guint16 level;
@ -192,10 +190,8 @@ NautilusCTreeNode * nautilus_ctree_insert_node (NautilusCTree *c
NautilusCTreeNode *sibling,
gchar *text[],
guint8 spacing,
GdkPixmap *pixmap_closed,
GdkBitmap *mask_closed,
GdkPixmap *pixmap_opened,
GdkBitmap *mask_opened,
GdkPixbuf *pixbuf_closed,
GdkPixbuf *pixbuf_opened,
gboolean is_leaf,
gboolean expanded);
void nautilus_ctree_remove_node (NautilusCTree *ctree,
@ -318,26 +314,22 @@ void nautilus_ctree_node_set_text (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
const gchar *text);
void nautilus_ctree_node_set_pixmap (NautilusCTree *ctree,
void nautilus_ctree_node_set_pixbuf (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
void nautilus_ctree_node_set_pixtext (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
void nautilus_ctree_set_node_info (NautilusCTree *ctree,
NautilusCTreeNode *node,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap_closed,
GdkBitmap *mask_closed,
GdkPixmap *pixmap_opened,
GdkBitmap *mask_opened,
GdkPixbuf *pixbuf_closed,
GdkPixbuf *pixbuf_opened,
gboolean is_leaf,
gboolean expanded);
void nautilus_ctree_node_set_shift (NautilusCTree *ctree,
@ -350,33 +342,29 @@ void nautilus_ctree_node_set_selectable (NautilusCTree *ctree,
gboolean selectable);
gboolean nautilus_ctree_node_get_selectable (NautilusCTree *ctree,
NautilusCTreeNode *node);
GtkCellType nautilus_ctree_node_get_cell_type (NautilusCTree *ctree,
NautilusCellType nautilus_ctree_node_get_cell_type (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column);
gint nautilus_ctree_node_get_text (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
gchar **text);
gint nautilus_ctree_node_get_pixmap (NautilusCTree *ctree,
gint nautilus_ctree_node_get_pixbuf (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask);
GdkPixbuf **pixbuf);
gint nautilus_ctree_node_get_pixtext (NautilusCTree *ctree,
NautilusCTreeNode *node,
gint column,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap,
GdkBitmap **mask);
GdkPixbuf **pixbuf);
gint nautilus_ctree_get_node_info (NautilusCTree *ctree,
NautilusCTreeNode *node,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap_closed,
GdkBitmap **mask_closed,
GdkPixmap **pixmap_opened,
GdkBitmap **mask_opened,
GdkPixbuf **pixbuf_closed,
GdkPixbuf **pixbuf_opened,
gboolean *is_leaf,
gboolean *expanded);

View file

@ -27,21 +27,22 @@
#include <config.h>
#include "nautilus-gtk-extensions.h"
#include "nautilus-gdk-extensions.h"
#include "nautilus-gdk-font-extensions.h"
#include "nautilus-gdk-font-extensions.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-string.h"
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkrc.h>
#include <gtk/gtkselection.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkrc.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-geometry.h>
#include <libgnomeui/gnome-winhints.h>
#include "nautilus-glib-extensions.h"
#include "nautilus-string.h"
/* This number should be large enough to be visually noticeable,
* but small enough to not allow the user to perform other actions.
@ -952,6 +953,19 @@ nautilus_gtk_marshal_INT__NONE (GtkObject *object,
func_data);
}
void
nautilus_gtk_marshal_POINTER__INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
* GTK_RETLOC_POINTER (args[1]) =
(* (gpointer (*)(GtkObject *, int, gpointer)) func)
(object,
GTK_VALUE_INT (args[0]),
func_data);
}
void
nautilus_gtk_marshal_POINTER__POINTER (GtkObject *object,
GtkSignalFunc func,
@ -2121,3 +2135,23 @@ nautilus_get_current_event_time (void)
return time;
}
void
nautilus_drag_set_icon_pixbuf (GdkDragContext *context,
GdkPixbuf *pixbuf,
int hot_x,
int hot_y)
{
GdkPixmap *pixmap;
GdkBitmap *mask;
gdk_pixbuf_render_pixmap_and_mask
(pixbuf, &pixmap, &mask,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
gtk_drag_set_icon_pixmap
(context, gdk_rgb_get_cmap (), pixmap, mask, hot_x, hot_y);
/* FIXME: Verify that this does not leak the pixmap and mask.
* We've always done it this way, but maybe we've always
* leaked. Just doing the unref here definitely causes a
* problem, so it's not that simple.
*/
}

View file

@ -4,7 +4,7 @@
gtk classes. Perhaps some of these should be
rolled into gtk someday.
Copyright (C) 1999, 2000 Eazel, Inc.
Copyright (C) 1999, 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -28,6 +28,7 @@
#ifndef NAUTILUS_GTK_EXTENSIONS_H
#define NAUTILUS_GTK_EXTENSIONS_H
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
@ -41,7 +42,7 @@
/* GtkButton */
void nautilus_gtk_button_auto_click (GtkButton *button);
void nautilus_gtk_button_set_standard_padding (GtkButton *button);
void nautilus_gtk_button_set_standard_padding (GtkButton *button);
void nautilus_gtk_button_set_padding (GtkButton *button,
int pad_amount);
@ -70,14 +71,13 @@ void nautilus_gtk_signal_connect_full_while_alive (GtkObjec
gboolean object_signal,
gboolean after,
GtkObject *alive_object);
void nautilus_gtk_signal_connect_while_realized (GtkObject *object,
const char *name,
GtkSignalFunc callback,
gpointer callback_data,
GtkWidget *realized_widget);
void nautilus_nullify_when_destroyed (gpointer object_pointer_address);
void nautilus_nullify_cancel (gpointer object_pointer_address);
void nautilus_nullify_when_destroyed (gpointer object_pointer_address);
void nautilus_nullify_cancel (gpointer object_pointer_address);
/* list of GtkObject */
GList * nautilus_gtk_object_list_ref (GList *list);
@ -87,7 +87,7 @@ GList * nautilus_gtk_object_list_copy (GList
/* GtkWidget */
void nautilus_gtk_widget_set_shown (GtkWidget *widget,
gboolean shown);
gboolean shown);
gboolean nautilus_point_in_allocation (const GtkAllocation *allocation,
int x,
int y);
@ -137,8 +137,8 @@ void nautilus_pop_up_context_menu (GtkMenu
gint16 offset_x,
gint16 offset_y,
GdkEventButton *event);
GtkMenuItem *nautilus_gtk_menu_append_separator (GtkMenu *menu);
GtkMenuItem *nautilus_gtk_menu_insert_separator (GtkMenu *menu,
GtkMenuItem * nautilus_gtk_menu_append_separator (GtkMenu *menu);
GtkMenuItem * nautilus_gtk_menu_insert_separator (GtkMenu *menu,
int index);
void nautilus_gtk_menu_set_item_visibility (GtkMenu *menu,
int index,
@ -173,8 +173,13 @@ void nautilus_gtk_style_shade (GdkColor
* gtk style/theme purposes. */
void nautilus_gtk_class_name_make_like_existing_type (const char *class_name,
GtkType existing_gtk_type);
GList * nautilus_get_window_list_ordered_front_to_back (void);
GList *nautilus_get_window_list_ordered_front_to_back (void);
/* dnd */
void nautilus_drag_set_icon_pixbuf (GdkDragContext *context,
GdkPixbuf *pixbuf,
gint hot_x,
gint hot_y);
/* marshals */
@ -266,6 +271,10 @@ void nautilus_gtk_marshal_POINTER__NONE
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__INT (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_POINTER__POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,

View file

@ -1251,8 +1251,6 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
GnomeCanvas *canvas;
GdkDragContext *context;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file;
int x_offset, y_offset;
ArtDRect world_rect;
ArtIRect window_rect;
@ -1285,11 +1283,6 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
/* we want to drag semi-transparent pixbufs, but X is too slow dealing with
stippled masks, so we had to remove the code; this comment is left as a memorial
to it, with the hope that we get it back someday as X Windows improves */
gdk_pixbuf_render_pixmap_and_mask (pixbuf,
&pixmap_for_dragged_file,
&mask_for_dragged_file,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
/* compute the image's offset */
nautilus_icon_canvas_item_get_icon_rectangle
@ -1299,12 +1292,8 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
x_offset = dnd_info->drag_info.start_x - window_rect.x0;
y_offset = dnd_info->drag_info.start_y - window_rect.y0;
/* set the pixmap and mask for dragging */
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (GTK_WIDGET (container)),
pixmap_for_dragged_file,
mask_for_dragged_file,
x_offset, y_offset);
/* set the icon for dragging */
nautilus_drag_set_icon_pixbuf (context, pixbuf, x_offset, y_offset);
}
static gboolean

View file

@ -1,9 +1,9 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-list.h: Enhanced version of GtkCList for Nautilus.
/* nautilus-list.c: Enhanced version of GtkCList for Nautilus.
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -193,7 +193,7 @@ enum {
HANDLE_DROPPED_ITEMS,
HANDLE_DRAGGED_ITEMS,
GET_DEFAULT_ACTION,
GET_DRAG_PIXMAP,
GET_DRAG_PIXBUF,
GET_SORT_COLUMN_INDEX,
LAST_SIGNAL
};
@ -281,14 +281,13 @@ static void nautilus_list_style_set (GtkWidget *w
GtkStyle *previous_style);
static void nautilus_list_realize (GtkWidget *widget);
static void nautilus_list_unrealize (GtkWidget *widget);
static void nautilus_list_set_cell_contents (NautilusCList *clist,
static gboolean nautilus_list_set_cell_contents (NautilusCList *clist,
NautilusCListRow *row,
int column_index,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
GdkPixbuf *pixbuf);
static void nautilus_list_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void nautilus_list_resize_column (NautilusCList *widget,
@ -438,17 +437,14 @@ nautilus_list_initialize_class (NautilusListClass *klass)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_UINT);
list_signals[GET_DRAG_PIXMAP] =
gtk_signal_new ("get_drag_pixmap",
list_signals[GET_DRAG_PIXBUF] =
gtk_signal_new ("get_drag_pixbuf",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusListClass, get_drag_pixmap),
nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER,
GTK_TYPE_NONE, 4,
GTK_TYPE_POINTER,
GTK_TYPE_INT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
GTK_SIGNAL_OFFSET (NautilusListClass, get_drag_pixbuf),
nautilus_gtk_marshal_POINTER__INT,
GTK_TYPE_POINTER, 1,
GTK_TYPE_INT);
list_signals[GET_SORT_COLUMN_INDEX] =
gtk_signal_new ("get_sort_column_index",
GTK_RUN_LAST,
@ -546,9 +542,11 @@ nautilus_list_set_anti_aliased_mode (NautilusList *list,
}
static void
nautilus_list_dnd_initialize (NautilusList *list)
void
nautilus_list_initialize_dnd (NautilusList *list)
{
g_assert (list->details->drag_info == NULL);
g_assert (!GTK_WIDGET_REALIZED (list));
list->details->drag_info = g_new0 (NautilusDragInfo, 1);
@ -577,7 +575,7 @@ nautilus_list_dnd_initialize (NautilusList *list)
gtk_signal_connect (GTK_OBJECT (list),
"drag_data_received",
GTK_SIGNAL_FUNC(nautilus_list_drag_data_received),
GTK_SIGNAL_FUNC (nautilus_list_drag_data_received),
list);
@ -595,7 +593,6 @@ nautilus_list_dnd_initialize (NautilusList *list)
static void
nautilus_list_initialize (NautilusList *list)
{
list->details = g_new0 (NautilusListDetails, 1);
list->details->anchor_row = -1;
@ -604,9 +601,6 @@ nautilus_list_initialize (NautilusList *list)
/* GtkCList does not specify pointer motion by default */
gtk_widget_add_events (GTK_WIDGET (list), GDK_POINTER_MOTION_MASK);
nautilus_list_dnd_initialize (list);
/* Emit "selection changed" signal when parent class changes selection */
list->details->select_row_signal_id = gtk_signal_connect (GTK_OBJECT (list),
"select_row",
@ -632,7 +626,9 @@ nautilus_list_destroy (GtkObject *object)
list = NAUTILUS_LIST (object);
nautilus_drag_finalize (list->details->drag_info);
if (list->details->drag_info != NULL) {
nautilus_drag_finalize (list->details->drag_info);
}
unschedule_keyboard_row_reveal (list);
@ -2066,50 +2062,6 @@ get_cell_style (NautilusList *list, NautilusCListRow *row,
}
}
static void
gdk_window_size_as_rectangle (GdkWindow *gdk_window, GdkRectangle *rectangle)
{
int width, height;
gdk_window_get_size (gdk_window, &width, &height);
rectangle->width = width;
rectangle->height = height;
}
static int
draw_cell_pixmap (GdkWindow *window, GdkRectangle *clip_rectangle, GdkGC *fg_gc,
GdkPixmap *pixmap, GdkBitmap *mask,
int x, int y)
{
GdkRectangle image_rectangle;
GdkRectangle intersect_rectangle;
gdk_window_size_as_rectangle (pixmap, &image_rectangle);
image_rectangle.x = x;
image_rectangle.y = y;
if (!gdk_rectangle_intersect (clip_rectangle, &image_rectangle, &intersect_rectangle)) {
return x;
}
if (mask) {
gdk_gc_set_clip_mask (fg_gc, mask);
gdk_gc_set_clip_origin (fg_gc, x, y);
}
gdk_draw_pixmap (window, fg_gc, pixmap,
intersect_rectangle.x - x, intersect_rectangle.y - y,
image_rectangle.x, image_rectangle.y,
intersect_rectangle.width, intersect_rectangle.height);
if (mask) {
gdk_gc_set_clip_origin (fg_gc, 0, 0);
gdk_gc_set_clip_mask (fg_gc, NULL);
}
return x + intersect_rectangle.width;
}
static int
draw_cell_pixbuf (NautilusCList *clist, GdkWindow *window, GdkRectangle *clip_rectangle,
GdkGC *fg_gc, guint32 bg_rgb, GdkPixbuf *pixbuf, int x, int y)
@ -2238,7 +2190,7 @@ get_cell_greater_rectangle (GdkRectangle *cell_rect, GdkRectangle *result,
static void
draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_index,
NautilusCListRow *row)
NautilusCListRow *row)
{
GtkStyle *style;
GdkGC *fg_gc;
@ -2250,7 +2202,7 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
int width;
int height;
int pixmap_width;
int pixbuf_width;
int offset = 0;
int baseline;
int row_center_offset;
@ -2280,8 +2232,7 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
/* calculate real width for column justification */
width = 0;
pixmap_width = 0;
offset = 0;
height = 0;
switch ((NautilusCellType)row->cell[column_index].type) {
case NAUTILUS_CELL_TEXT:
@ -2289,15 +2240,14 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
width = gdk_string_width (style->font,
NAUTILUS_CELL_TEXT (row->cell[column_index])->text);
break;
case NAUTILUS_CELL_PIXMAP:
gdk_window_get_size (NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
&pixmap_width, &height);
width = pixmap_width;
case NAUTILUS_CELL_PIXBUF:
width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf);
height = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf);
break;
case NAUTILUS_CELL_PIXTEXT:
gdk_window_get_size (NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixmap,
&pixmap_width, &height);
width = (pixmap_width +
pixbuf_width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixbuf);
height = gdk_pixbuf_get_height (NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixbuf);
width = (pixbuf_width +
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->spacing +
gdk_string_width (style->font, NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->text));
break;
@ -2310,73 +2260,53 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
width += gdk_pixbuf_get_width (p->data);
}
break;
case NAUTILUS_CELL_PIXBUF:
width = gdk_pixbuf_get_width (NAUTILUS_CELL_PIXBUF (row->cell[column_index]));
break;
default:
case NAUTILUS_CELL_EMPTY:
case NAUTILUS_CELL_WIDGET:
return;
}
offset = get_cell_horizontal_start_position (clist, row, column_index, width);
/* Draw Text and/or Pixmap */
switch ((NautilusCellType)row->cell[column_index].type) {
case NAUTILUS_CELL_PIXMAP:
{
NautilusList *list = NAUTILUS_LIST (clist);
int dark_width, dark_height;
GdkPixbuf *src_pixbuf, *dark_pixbuf;
GdkPixmap *dark_pixmap;
GdkBitmap *dark_mask;
if (list->details->drag_prelight_row == row) {
gdk_window_get_geometry (NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
NULL, NULL, &dark_width, &dark_height, NULL);
src_pixbuf = gdk_pixbuf_get_from_drawable
(NULL,
NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
gdk_rgb_get_cmap (),
0, 0, 0, 0, dark_width, dark_height);
if (src_pixbuf != NULL) {
/* Create darkened pixmap */
dark_pixbuf = nautilus_create_darkened_pixbuf (src_pixbuf,
0.8 * 255,
0.8 * 255);
if (dark_pixbuf != NULL) {
gdk_pixbuf_render_pixmap_and_mask (dark_pixbuf,
&dark_pixmap, &dark_mask,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
draw_cell_pixmap (clist->clist_window, &cell_rectangle, fg_gc,
dark_pixmap, NAUTILUS_CELL_PIXMAP (row->cell[column_index])->mask, offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
gdk_pixbuf_unref (dark_pixbuf);
}
gdk_pixbuf_unref (src_pixbuf);
}
} else {
draw_cell_pixmap (clist->clist_window, &cell_rectangle, fg_gc,
NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap,
NAUTILUS_CELL_PIXMAP (row->cell[column_index])->mask,
offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
}
/* Draw Text and/or Pixbuf */
switch ((NautilusCellType) row->cell[column_index].type) {
case NAUTILUS_CELL_PIXBUF: {
NautilusList *list = NAUTILUS_LIST (clist);
GdkPixbuf *src_pixbuf, *dark_pixbuf;
if (list->details->drag_prelight_row == row) {
src_pixbuf = NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf;
if (src_pixbuf != NULL) {
/* Create darkened pixbuf */
dark_pixbuf = nautilus_create_darkened_pixbuf (src_pixbuf,
0.8 * 255,
0.8 * 255);
if (dark_pixbuf != NULL) {
draw_cell_pixbuf (clist, clist->clist_window, &cell_rectangle, fg_gc, bg_rgb,
dark_pixbuf, offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
gdk_pixbuf_unref (dark_pixbuf);
}
}
} else {
draw_cell_pixbuf (clist, clist->clist_window, &cell_rectangle, fg_gc, bg_rgb,
NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf,
offset,
cell_rectangle.y + row->cell[column_index].vertical +
(cell_rectangle.height - height) / 2);
}
break;
}
case NAUTILUS_CELL_PIXTEXT:
offset = draw_cell_pixmap (clist->clist_window, &cell_rectangle, fg_gc,
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixmap,
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->mask,
offset,
cell_rectangle.y + row->cell[column_index].vertical+
(cell_rectangle.height - height) / 2);
offset = draw_cell_pixbuf (clist, clist->clist_window, &cell_rectangle, fg_gc, bg_rgb,
NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->pixbuf,
offset,
cell_rectangle.y + row->cell[column_index].vertical+
(cell_rectangle.height - height) / 2);
offset += NAUTILUS_CELL_PIXTEXT (row->cell[column_index])->spacing;
/* fall through */
case NAUTILUS_CELL_TEXT:
@ -2454,19 +2384,8 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
}
break;
}
case NAUTILUS_CELL_PIXBUF: {
GdkPixbuf *pixbuf;
guint height;
pixbuf = NAUTILUS_CELL_PIXBUF (row->cell[column_index]);
height = gdk_pixbuf_get_height (pixbuf);
offset = draw_cell_pixbuf (clist, clist->clist_window,
&cell_rectangle,
fg_gc, bg_rgb, pixbuf,
offset, cell_rectangle.y
+ row->cell[column_index].vertical
+ (cell_rectangle.height - height) / 2);
}
default:
case NAUTILUS_CELL_EMPTY:
case NAUTILUS_CELL_WIDGET:
break;
}
}
@ -2800,7 +2719,7 @@ nautilus_list_resize_column (NautilusCList *clist, int column_index, int width)
*
* Mark a text cell as a link cell. Link cells are drawn differently,
* and activate rather than select on single-click. The cell must
* be a text cell (not a pixmap cell or one of the other types).
* be a text cell (not a pixbuf cell or one of the other types).
*
* @list: The NautilusList in question.
* @column_index: The column of the desired cell.
@ -2825,7 +2744,7 @@ nautilus_list_mark_cell_as_link (NautilusList *list,
/*
* We only support changing text cells to links. Maybe someday
* we'll support pixmap or pixtext link cells too.
* we'll support pixbuf or pixtext link cells too.
*/
g_return_if_fail ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_TEXT);
@ -2833,16 +2752,17 @@ nautilus_list_mark_cell_as_link (NautilusList *list,
}
static void
static gboolean
nautilus_list_set_cell_contents (NautilusCList *clist,
NautilusCListRow *row,
int column_index,
NautilusCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask)
GdkPixbuf *pixbuf)
{
gboolean result;
/*
* Note that we don't do the auto_resize bracketing here that's done
* in the parent class. It would require copying over huge additional
@ -2853,29 +2773,19 @@ nautilus_list_set_cell_contents (NautilusCList *clist,
/* Clean up old data, which parent class doesn't know about. */
if ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_PIXBUF_LIST) {
nautilus_gdk_pixbuf_list_free (NAUTILUS_CELL_PIXBUF_LIST (row->cell[column_index])->pixbufs);
} else if ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_PIXBUF) {
gdk_pixbuf_unref (NAUTILUS_CELL_PIXBUF (row->cell[column_index]));
}
/* If old cell was a link-text cell, convert it back to a normal text
* cell so it gets cleaned up properly by GtkCList code.
*/
if ((NautilusCellType)row->cell[column_index].type == NAUTILUS_CELL_LINK_TEXT) {
row->cell[column_index].type = NAUTILUS_CELL_TEXT;
}
NAUTILUS_CALL_PARENT (NAUTILUS_CLIST_CLASS, set_cell_contents,
(clist, row, column_index, type, text, spacing, pixmap, mask));
result = NAUTILUS_CALL_PARENT_WITH_RETURN_VALUE
(NAUTILUS_CLIST_CLASS, set_cell_contents,
(clist, row, column_index, type, text, spacing, pixbuf));
if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF_LIST) {
row->cell[column_index].type = NAUTILUS_CELL_PIXBUF_LIST;
/* Hideously, we concealed our list of pixbufs in the pixmap parameter. */
NAUTILUS_CELL_PIXBUF_LIST (row->cell[column_index])->pixbufs = (GList *)pixmap;
} else if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF) {
row->cell[column_index].type = NAUTILUS_CELL_PIXBUF;
/* Hideously, we concealed our pixbuf in the pixmap parameter. */
NAUTILUS_CELL_PIXBUF (row->cell[column_index]) = pixmap;
/* Hideously, we concealed our list of pixbufs in the pixbuf parameter. */
NAUTILUS_CELL_PIXBUF_LIST (row->cell[column_index])->pixbufs = (GList *)pixbuf;
}
return result;
}
static void
@ -2907,14 +2817,15 @@ set_list_cell (NautilusList *list,
* expected parameter type, we have to sneak it in by casting it into
* one of the expected parameters.
*/
NAUTILUS_CALL_METHOD (NAUTILUS_CLIST_CLASS, clist, set_cell_contents,
(clist, row, column_index, type, NULL, 0, (GdkPixmap *) data, NULL));
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist)
&& nautilus_clist_row_is_visible (clist, row_index) != GTK_VISIBILITY_NONE) {
NAUTILUS_CALL_METHOD (NAUTILUS_CLIST_CLASS, clist, draw_row,
(clist, NULL, row_index, row));
if (NAUTILUS_CALL_METHOD_WITH_RETURN_VALUE
(NAUTILUS_CLIST_CLASS, clist, set_cell_contents,
(clist, row, column_index, type, NULL, 0, data))) {
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist)
&& nautilus_clist_row_is_visible (clist, row_index) != GTK_VISIBILITY_NONE) {
NAUTILUS_CALL_METHOD (NAUTILUS_CLIST_CLASS, clist, draw_row,
(clist, NULL, row_index, row));
}
}
}
@ -2941,7 +2852,7 @@ get_list_cell (NautilusList *list,
row = ROW_ELEMENT (clist, row_index)->data;
if (row->cell[column_index].type == type) {
return NAUTILUS_CELL_PIXMAP (row->cell[column_index])->pixmap;
return NAUTILUS_CELL_PIXBUF (row->cell[column_index])->pixbuf;
}
return NULL;
@ -3049,13 +2960,15 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
{
NautilusList *list;
GdkDragContext *context;
GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file;
int x_offset, y_offset;
GdkPixbuf *pixbuf;
g_return_if_fail (NAUTILUS_IS_LIST (widget));
list = NAUTILUS_LIST (widget);
if (list->details->drag_info == NULL) {
return;
}
list->details->drag_started = TRUE;
list->details->dnd_select_pending = FALSE;
/* reinit from last dnd if there was one */
@ -3070,20 +2983,15 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
list->details->dnd_press_button,
(GdkEvent *) event);
x_offset = 10;
y_offset = 10;
pixbuf = NULL;
gtk_signal_emit (GTK_OBJECT (list), list_signals[GET_DRAG_PIXBUF],
list->details->button_down_row, &pixbuf);
gtk_signal_emit (GTK_OBJECT (list), list_signals[GET_DRAG_PIXMAP],
list->details->button_down_row, &pixmap_for_dragged_file,
&mask_for_dragged_file);
if (pixmap_for_dragged_file) {
/* set the pixmap and mask for dragging */
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (widget),
pixmap_for_dragged_file,
mask_for_dragged_file,
x_offset, y_offset);
if (pixbuf != NULL) {
/* FIXME: We can do better than 10,10. */
nautilus_drag_set_icon_pixbuf (context, pixbuf, 10, 10);
gdk_pixbuf_unref (pixbuf);
}
}
@ -3414,7 +3322,7 @@ nautilus_list_receive_dropped_icons (NautilusList *list,
int x, int y, guint info)
{
NautilusDragInfo *drag_info;
GList * selected_items;
GList *selected_items;
g_assert (NAUTILUS_IS_LIST (list));
drag_info = list->details->drag_info;

View file

@ -3,7 +3,7 @@
/* nautilus-list.h: Enhanced version of GtkCList for Nautilus.
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -30,8 +30,7 @@
#define NAUTILUS_LIST_H
#include <libgnome/gnome-defs.h>
#include <widgets/nautilusclist/nautilusclist.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cut-n-paste-code/widgets/nautilusclist/nautilusclist.h>
/* This class was originally derived from the GtkFList class in gmc.
*/
@ -43,7 +42,6 @@
/* pointer casting for cells */
#define NAUTILUS_CELL_PIXBUF_LIST(cell) ((NautilusCellPixbufList *) &(cell))
#define NAUTILUS_CELL_PIXBUF(cell) ((GdkPixbuf *) ((cell).u.text))
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
/* returns the GList item for the nth row */
@ -109,8 +107,8 @@ struct NautilusListClass {
void (* select_matching_name) (GtkWidget *widget, const char *);
void (* select_previous_name) (GtkWidget *widget);
void (* select_next_name) (GtkWidget *widget);
void (* get_drag_pixmap) (GtkWidget *widget, int row_index, GdkPixmap **pixmap, GdkBitmap **mask);
int (* get_sort_column_index) (void);
GdkPixbuf (* get_drag_pixbuf) (NautilusList *list, int row_index);
int (* get_sort_column_index) (NautilusList *list);
/* dnd handling. defer the semantics of dnd to the application side, not nautilus-list */
gboolean (* handle_dragged_items) (GtkWidget *widget,
@ -141,6 +139,7 @@ typedef gboolean (* NautilusEachRowFunction) (NautilusCListRow *, int, gpointer)
GtkType nautilus_list_get_type (void);
GtkWidget * nautilus_list_new_with_titles (int columns,
const char * const *titles);
void nautilus_list_initialize_dnd (NautilusList *list);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);

View file

@ -31,7 +31,6 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-pixmap.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libnautilus-extensions/nautilus-art-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-art-extensions.h>
@ -917,28 +916,20 @@ fm_list_drag_data_get (GtkWidget *widget, GdkDragContext *context,
info, time, widget, each_icon_get_data_binder);
}
static void
fm_list_get_drag_pixmap (GtkWidget *widget, int row_index, GdkPixmap **pixmap,
GdkBitmap **mask, FMListView *list_view)
static GdkPixbuf *
fm_list_get_drag_pixbuf (GtkWidget *widget, int row_index, FMListView *list_view)
{
GdkPixbuf *pixbuf;
g_assert (FM_IS_LIST_VIEW (list_view));
g_assert (NAUTILUS_IS_LIST (widget));
pixbuf = nautilus_list_get_pixbuf (NAUTILUS_LIST (widget),
row_index, LIST_VIEW_COLUMN_ICON);
g_assert (pixbuf != NULL);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap, mask,
NAUTILUS_STANDARD_ALPHA_THRESHHOLD);
return nautilus_list_get_pixbuf (NAUTILUS_LIST (widget),
row_index,
LIST_VIEW_COLUMN_ICON);
}
static int
fm_list_get_sort_column_index (GtkWidget *widget, FMListView *list_view)
{
g_assert (NAUTILUS_IS_LIST (widget));
g_assert (FM_IS_LIST_VIEW (list_view));
return FM_LIST_VIEW (list_view)->details->sort_column;
}
@ -986,6 +977,7 @@ create_list (FMListView *list_view)
titles = get_column_titles (list_view);
list = NAUTILUS_LIST (nautilus_list_new_with_titles (get_number_of_columns (list_view),
titles));
nautilus_list_initialize_dnd (list);
g_free (titles);
clist = NAUTILUS_CLIST (list);
@ -1101,8 +1093,8 @@ set_up_list (FMListView *list_view)
fm_list_drag_data_get,
list_view);
gtk_signal_connect (GTK_OBJECT (list),
"get_drag_pixmap",
fm_list_get_drag_pixmap,
"get_drag_pixbuf",
GTK_SIGNAL_FUNC (fm_list_get_drag_pixbuf),
list_view);
gtk_signal_connect (GTK_OBJECT (list),
"get_sort_column_index",